mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
refactor(editor): extract common toolbar config (#11069)
This commit is contained in:
@@ -88,6 +88,7 @@ export {
|
||||
getBgGridGap,
|
||||
getLastPropsKey,
|
||||
getSurfaceBlock,
|
||||
getSurfaceComponent,
|
||||
normalizeWheelDeltaY,
|
||||
} from './utils';
|
||||
export * from './utils/mindmap/style-svg';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user