refactor(editor): fix edgeless toolbar theme (#10897)

This commit is contained in:
fundon
2025-03-20 02:08:20 +00:00
parent ccc210f88a
commit a7acd5c5b1
9 changed files with 54 additions and 63 deletions
@@ -9,10 +9,7 @@ import {
LineWidth,
resolveColor,
} from '@blocksuite/affine-model';
import {
FeatureFlagService,
type ToolbarModuleConfig,
} from '@blocksuite/affine-shared/services';
import { type ToolbarModuleConfig } from '@blocksuite/affine-shared/services';
import {
getMostCommonResolvedValue,
getMostCommonValue,
@@ -58,10 +55,8 @@ export const builtinBrushToolbarConfig = {
const models = ctx.getSurfaceModelsByType(BrushElementModel);
if (!models.length) return null;
const enableCustomColor = ctx.std
.get(FeatureFlagService)
.getFlag('enable_color_picker');
const theme = ctx.themeProvider.edgelessTheme;
const enableCustomColor = ctx.features.getFlag('enable_color_picker');
const theme = ctx.theme.edgeless$.value;
const field = 'color';
const firstModel = models[0];
@@ -21,11 +21,10 @@ import {
resolveColor,
StrokeStyle,
} from '@blocksuite/affine-model';
import {
FeatureFlagService,
type ToolbarContext,
type ToolbarGenericAction,
type ToolbarModuleConfig,
import type {
ToolbarContext,
ToolbarGenericAction,
ToolbarModuleConfig,
} from '@blocksuite/affine-shared/services';
import {
getMostCommonResolvedValue,
@@ -129,10 +128,8 @@ export const builtinConnectorToolbarConfig = {
const models = ctx.getSurfaceModelsByType(ConnectorElementModel);
if (!models.length) return null;
const enableCustomColor = ctx.std
.get(FeatureFlagService)
.getFlag('enable_color_picker');
const theme = ctx.themeProvider.edgelessTheme;
const enableCustomColor = ctx.features.getFlag('enable_color_picker');
const theme = ctx.theme.edgeless$.value;
const field = 'stroke';
const firstModel = models[0];
@@ -16,7 +16,6 @@ import {
SurfaceRefBlockSchema,
} from '@blocksuite/affine-model';
import {
FeatureFlagService,
type ToolbarModuleConfig,
ToolbarModuleExtension,
} from '@blocksuite/affine-shared/services';
@@ -125,10 +124,8 @@ const builtinSurfaceToolbarConfig = {
const models = ctx.getSurfaceModelsByType(FrameBlockModel);
if (!models.length) return null;
const theme = ctx.themeProvider.edgelessTheme;
const enableCustomColor = ctx.std
.get(FeatureFlagService)
.getFlag('enable_color_picker');
const enableCustomColor = ctx.features.getFlag('enable_color_picker');
const theme = ctx.theme.edgeless$.value;
const field = 'background';
const firstModel = models[0];
@@ -24,10 +24,9 @@ import {
ShapeType,
StrokeStyle,
} from '@blocksuite/affine-model';
import {
FeatureFlagService,
type ToolbarGenericAction,
type ToolbarModuleConfig,
import type {
ToolbarGenericAction,
ToolbarModuleConfig,
} from '@blocksuite/affine-shared/services';
import { getMostCommonValue } from '@blocksuite/affine-shared/utils';
import { Bound } from '@blocksuite/global/gfx';
@@ -184,10 +183,8 @@ export const builtinShapeToolbarConfig = {
const models = ctx.getSurfaceModelsByType(ShapeElementModel);
if (!models.length) return null;
const enableCustomColor = ctx.std
.get(FeatureFlagService)
.getFlag('enable_color_picker');
const theme = ctx.themeProvider.edgelessTheme;
const enableCustomColor = ctx.features.getFlag('enable_color_picker');
const theme = ctx.theme.edgeless$.value;
const firstModel = models[0];
const originalFillColor = firstModel.fillColor;
@@ -16,10 +16,9 @@ import {
TextAlign,
type TextStyleProps,
} from '@blocksuite/affine-model';
import {
FeatureFlagService,
type ToolbarActions,
type ToolbarContext,
import type {
ToolbarActions,
ToolbarContext,
} from '@blocksuite/affine-shared/services';
import {
getMostCommonResolvedValue,
@@ -180,10 +179,8 @@ export function createTextActions<
);
if (!allowed) return null;
const enableCustomColor = ctx.std
.get(FeatureFlagService)
.getFlag('enable_color_picker');
const theme = ctx.themeProvider.edgelessTheme;
const enableCustomColor = ctx.features.getFlag('enable_color_picker');
const theme = ctx.theme.edgeless$.value;
const palettes =
type === 'shape'