refactor(editor): extract common toolbar config (#11069)

This commit is contained in:
Saul-Mirone
2025-03-21 11:45:33 +00:00
parent ee3494e01d
commit 73807193cb
19 changed files with 144 additions and 120 deletions

View File

@@ -88,6 +88,7 @@ export {
getBgGridGap,
getLastPropsKey,
getSurfaceBlock,
getSurfaceComponent,
normalizeWheelDeltaY,
} from './utils';
export * from './utils/mindmap/style-svg';

View File

@@ -1,8 +1,16 @@
import type { BlockStdScope } from '@blocksuite/block-std';
import type { Store } from '@blocksuite/store';
import type { SurfaceBlockComponent } from '../surface-block';
import type { SurfaceBlockModel } from '../surface-model';
export function getSurfaceBlock(doc: Store) {
const blocks = doc.getBlocksByFlavour('affine:surface');
return blocks.length !== 0 ? (blocks[0].model as SurfaceBlockModel) : null;
}
export function getSurfaceComponent(std: BlockStdScope) {
const surface = getSurfaceBlock(std.store);
if (!surface) return null;
return std.view.getBlock(surface.id) as SurfaceBlockComponent | null;
}

View File

@@ -36,5 +36,5 @@ export function normalizeWheelDeltaY(delta: number, zoom = 1) {
export { addNote, addNoteAtPoint } from './add-note';
export { getBgGridGap } from './get-bg-grip-gap';
export { getLastPropsKey } from './get-last-props-key';
export { getSurfaceBlock } from './get-surface-block';
export * from './get-surface-block';
export * from './mindmap/style-svg.js';