mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-09 21:25:45 +08:00
feat(editor): insert a mindmap slash menu action (#10930)
Close [BS-2516](https://linear.app/affine-design/issue/BS-2516/添加mind-map入口)
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
import { getSurfaceBlock } from '@blocksuite/affine-block-surface';
|
||||
import {
|
||||
FrameBlockModel,
|
||||
type SurfaceRefProps,
|
||||
} from '@blocksuite/affine-model';
|
||||
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||
import { EdgelessCRUDExtension } from '@blocksuite/affine-block-surface';
|
||||
import { type SurfaceRefProps } from '@blocksuite/affine-model';
|
||||
import type { Command } from '@blocksuite/block-std';
|
||||
import { GfxPrimitiveElementModel } from '@blocksuite/block-std/gfx';
|
||||
import type { BlockModel } from '@blocksuite/store';
|
||||
|
||||
export const insertSurfaceRefBlockCommand: Command<
|
||||
@@ -33,21 +30,19 @@ export const insertSurfaceRefBlockCommand: Command<
|
||||
reference,
|
||||
};
|
||||
|
||||
const surface = getSurfaceBlock(std.store);
|
||||
if (!surface) return;
|
||||
const crud = std.get(EdgelessCRUDExtension);
|
||||
const element = crud.getElementById(reference);
|
||||
|
||||
const element = surface.getElementById(reference);
|
||||
const blockModel = std.store.getBlock(reference)?.model ?? null;
|
||||
|
||||
if (element?.type === 'group') {
|
||||
surfaceRefProps.refFlavour = 'group';
|
||||
} else if (matchModels(blockModel, [FrameBlockModel])) {
|
||||
surfaceRefProps.refFlavour = 'frame';
|
||||
} else {
|
||||
if (!element) {
|
||||
console.error(`reference not found ${reference}`);
|
||||
return;
|
||||
}
|
||||
|
||||
surfaceRefProps.refFlavour =
|
||||
element instanceof GfxPrimitiveElementModel
|
||||
? element.type
|
||||
: element.flavour;
|
||||
|
||||
const result = std.store.addSiblingBlocks(
|
||||
targetModel,
|
||||
[surfaceRefProps],
|
||||
|
||||
Reference in New Issue
Block a user