refactor(editor): improve query methods in toolbar context (#10714)

This commit is contained in:
fundon
2025-03-19 00:52:22 +00:00
parent 02d707feab
commit 3cce147c60
14 changed files with 317 additions and 359 deletions
@@ -42,7 +42,7 @@ export const sideMap = new Map([
['affine:surface:frame', { top: 28 }],
// includes group element
['affine:surface:group', { top: 20 }],
// only one shape element
// has only one shape element
['affine:surface:shape', { top: 26, bottom: -26 }],
]);
@@ -196,6 +196,11 @@ export function renderToolbar(
.flat()
.map(key => toolbarRegistry.modules.get(key))
.filter(module => !!module)
.filter(module =>
typeof module.config.when === 'function'
? module.config.when(context)
: (module.config.when ?? true)
)
.map<ToolbarActions>(module => module.config.actions)
.flat();
@@ -220,7 +225,7 @@ export function renderToolbar(
);
// if (moreMenuItems.length) {
// TODO(@fundon): edgeless case needs to be considered
const key = `${context.getCurrentModel()?.id ?? context.getCurrentElement()?.id}`;
const key = `${context.getCurrentModel()?.id}`;
primaryActionGroup.push({
id: 'more',