refactor(editor): move mindmap transform to its package (#11115)
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
|||||||
OverlayIdentifier,
|
OverlayIdentifier,
|
||||||
TextUtils,
|
TextUtils,
|
||||||
} from '@blocksuite/affine-block-surface';
|
} from '@blocksuite/affine-block-surface';
|
||||||
|
import { isMindmapNode } from '@blocksuite/affine-gfx-mindmap';
|
||||||
import {
|
import {
|
||||||
type BookmarkBlockModel,
|
type BookmarkBlockModel,
|
||||||
ConnectorElementModel,
|
ConnectorElementModel,
|
||||||
@@ -85,7 +86,6 @@ import {
|
|||||||
isEmbedSyncedDocBlock,
|
isEmbedSyncedDocBlock,
|
||||||
isEmbedYoutubeBlock,
|
isEmbedYoutubeBlock,
|
||||||
isImageBlock,
|
isImageBlock,
|
||||||
isMindmapNode,
|
|
||||||
} from '../../utils/query.js';
|
} from '../../utils/query.js';
|
||||||
import {
|
import {
|
||||||
HandleDirection,
|
HandleDirection,
|
||||||
|
|||||||
@@ -4,8 +4,14 @@ import {
|
|||||||
PresentTool,
|
PresentTool,
|
||||||
} from '@blocksuite/affine-block-frame';
|
} from '@blocksuite/affine-block-frame';
|
||||||
import { ConnectionOverlay } from '@blocksuite/affine-block-surface';
|
import { ConnectionOverlay } from '@blocksuite/affine-block-surface';
|
||||||
import { ConnectorTool } from '@blocksuite/affine-gfx-connector';
|
import {
|
||||||
import { MindMapIndicatorOverlay } from '@blocksuite/affine-gfx-mindmap';
|
ConnectorFilter,
|
||||||
|
ConnectorTool,
|
||||||
|
} from '@blocksuite/affine-gfx-connector';
|
||||||
|
import {
|
||||||
|
MindMapDragExtension,
|
||||||
|
MindMapIndicatorOverlay,
|
||||||
|
} from '@blocksuite/affine-gfx-mindmap';
|
||||||
import { NoteTool } from '@blocksuite/affine-gfx-note';
|
import { NoteTool } from '@blocksuite/affine-gfx-note';
|
||||||
import { ShapeTool } from '@blocksuite/affine-gfx-shape';
|
import { ShapeTool } from '@blocksuite/affine-gfx-shape';
|
||||||
import { TextTool } from '@blocksuite/affine-gfx-text';
|
import { TextTool } from '@blocksuite/affine-gfx-text';
|
||||||
@@ -17,8 +23,6 @@ import type { ExtensionType } from '@blocksuite/store';
|
|||||||
|
|
||||||
import { EdgelessElementToolbarExtension } from './configs/toolbar';
|
import { EdgelessElementToolbarExtension } from './configs/toolbar';
|
||||||
import { EdgelessRootBlockSpec } from './edgeless-root-spec.js';
|
import { EdgelessRootBlockSpec } from './edgeless-root-spec.js';
|
||||||
import { ConnectorFilter } from './element-transform/connector-filter.js';
|
|
||||||
import { MindMapDragExtension } from './element-transform/mind-map-drag.js';
|
|
||||||
import { SnapExtension } from './element-transform/snap-manager.js';
|
import { SnapExtension } from './element-transform/snap-manager.js';
|
||||||
import { BrushTool } from './gfx-tool/brush-tool.js';
|
import { BrushTool } from './gfx-tool/brush-tool.js';
|
||||||
import { DefaultTool } from './gfx-tool/default-tool.js';
|
import { DefaultTool } from './gfx-tool/default-tool.js';
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ import { EdgelessTextBlockComponent } from '@blocksuite/affine-block-edgeless-te
|
|||||||
import { isNoteBlock } from '@blocksuite/affine-block-surface';
|
import { isNoteBlock } from '@blocksuite/affine-block-surface';
|
||||||
import { toast } from '@blocksuite/affine-components/toast';
|
import { toast } from '@blocksuite/affine-components/toast';
|
||||||
import { mountConnectorLabelEditor } from '@blocksuite/affine-gfx-connector';
|
import { mountConnectorLabelEditor } from '@blocksuite/affine-gfx-connector';
|
||||||
|
import {
|
||||||
|
getNearestTranslation,
|
||||||
|
isElementOutsideViewport,
|
||||||
|
isSingleMindMapNode,
|
||||||
|
} from '@blocksuite/affine-gfx-mindmap';
|
||||||
import { mountShapeTextEditor, ShapeTool } from '@blocksuite/affine-gfx-shape';
|
import { mountShapeTextEditor, ShapeTool } from '@blocksuite/affine-gfx-shape';
|
||||||
import {
|
import {
|
||||||
ConnectorElementModel,
|
ConnectorElementModel,
|
||||||
@@ -43,11 +48,6 @@ import {
|
|||||||
} from './utils/consts.js';
|
} from './utils/consts.js';
|
||||||
import { deleteElements } from './utils/crud.js';
|
import { deleteElements } from './utils/crud.js';
|
||||||
import { getNextShapeType } from './utils/hotkey-utils.js';
|
import { getNextShapeType } from './utils/hotkey-utils.js';
|
||||||
import {
|
|
||||||
getNearestTranslation,
|
|
||||||
isElementOutsideViewport,
|
|
||||||
isSingleMindMapNode,
|
|
||||||
} from './utils/mindmap.js';
|
|
||||||
import { isCanvasElement } from './utils/query.js';
|
import { isCanvasElement } from './utils/query.js';
|
||||||
|
|
||||||
export class EdgelessPageKeyboardManager extends PageKeyboardManager {
|
export class EdgelessPageKeyboardManager extends PageKeyboardManager {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
getBgGridGap,
|
getBgGridGap,
|
||||||
normalizeWheelDeltaY,
|
normalizeWheelDeltaY,
|
||||||
} from '@blocksuite/affine-block-surface';
|
} from '@blocksuite/affine-block-surface';
|
||||||
|
import { isSingleMindMapNode } from '@blocksuite/affine-gfx-mindmap';
|
||||||
import { mountShapeTextEditor } from '@blocksuite/affine-gfx-shape';
|
import { mountShapeTextEditor } from '@blocksuite/affine-gfx-shape';
|
||||||
import {
|
import {
|
||||||
NoteBlockModel,
|
NoteBlockModel,
|
||||||
@@ -51,7 +52,6 @@ import { EdgelessClipboardController } from './clipboard/clipboard.js';
|
|||||||
import type { EdgelessSelectedRectWidget } from './components/rects/edgeless-selected-rect.js';
|
import type { EdgelessSelectedRectWidget } from './components/rects/edgeless-selected-rect.js';
|
||||||
import { EdgelessPageKeyboardManager } from './edgeless-keyboard.js';
|
import { EdgelessPageKeyboardManager } from './edgeless-keyboard.js';
|
||||||
import type { EdgelessRootService } from './edgeless-root-service.js';
|
import type { EdgelessRootService } from './edgeless-root-service.js';
|
||||||
import { isSingleMindMapNode } from './utils/mindmap.js';
|
|
||||||
import { isCanvasElement } from './utils/query.js';
|
import { isCanvasElement } from './utils/query.js';
|
||||||
|
|
||||||
export class EdgelessRootBlockComponent extends BlockComponent<
|
export class EdgelessRootBlockComponent extends BlockComponent<
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import {
|
|||||||
type EmbedSyncedDocModel,
|
type EmbedSyncedDocModel,
|
||||||
type EmbedYoutubeModel,
|
type EmbedYoutubeModel,
|
||||||
type ImageBlockModel,
|
type ImageBlockModel,
|
||||||
MindmapElementModel,
|
|
||||||
ShapeElementModel,
|
ShapeElementModel,
|
||||||
TextElementModel,
|
TextElementModel,
|
||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
@@ -23,7 +22,6 @@ import {
|
|||||||
isTopLevelBlock,
|
isTopLevelBlock,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import type {
|
import type {
|
||||||
GfxBlockElementModel,
|
|
||||||
GfxModel,
|
GfxModel,
|
||||||
GfxPrimitiveElementModel,
|
GfxPrimitiveElementModel,
|
||||||
GfxToolsFullOptionValue,
|
GfxToolsFullOptionValue,
|
||||||
@@ -33,10 +31,6 @@ import type { PointLocation } from '@blocksuite/global/gfx';
|
|||||||
import { Bound } from '@blocksuite/global/gfx';
|
import { Bound } from '@blocksuite/global/gfx';
|
||||||
import type { BlockModel } from '@blocksuite/store';
|
import type { BlockModel } from '@blocksuite/store';
|
||||||
|
|
||||||
export function isMindmapNode(element: GfxBlockElementModel | GfxModel | null) {
|
|
||||||
return element?.group instanceof MindmapElementModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isEdgelessTextBlock(
|
export function isEdgelessTextBlock(
|
||||||
element: BlockModel | GfxModel | null
|
element: BlockModel | GfxModel | null
|
||||||
): element is EdgelessTextBlockModel {
|
): element is EdgelessTextBlockModel {
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './connector-filter';
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
export * from './connector-tool';
|
export * from './connector-tool';
|
||||||
|
export * from './element-transform';
|
||||||
export * from './text';
|
export * from './text';
|
||||||
export * from './toolbar/config';
|
export * from './toolbar/config';
|
||||||
export * from './toolbar/quick-tool';
|
export * from './toolbar/quick-tool';
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
import {
|
|
||||||
NODE_HORIZONTAL_SPACING,
|
|
||||||
NODE_VERTICAL_SPACING,
|
|
||||||
} from '@blocksuite/affine-gfx-mindmap';
|
|
||||||
import {
|
import {
|
||||||
LayoutType,
|
LayoutType,
|
||||||
type MindmapElementModel,
|
type MindmapElementModel,
|
||||||
@@ -11,6 +7,8 @@ import {
|
|||||||
import { Bound } from '@blocksuite/global/gfx';
|
import { Bound } from '@blocksuite/global/gfx';
|
||||||
import last from 'lodash-es/last';
|
import last from 'lodash-es/last';
|
||||||
|
|
||||||
|
import { NODE_HORIZONTAL_SPACING, NODE_VERTICAL_SPACING } from '../view/layout';
|
||||||
|
|
||||||
const isOnEdge = (node: MindmapNode, direction: 'tail' | 'head') => {
|
const isOnEdge = (node: MindmapNode, direction: 'tail' | 'head') => {
|
||||||
let current = node;
|
let current = node;
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './mind-map-drag';
|
||||||
@@ -2,17 +2,6 @@ import {
|
|||||||
OverlayIdentifier,
|
OverlayIdentifier,
|
||||||
type SurfaceBlockComponent,
|
type SurfaceBlockComponent,
|
||||||
} from '@blocksuite/affine-block-surface';
|
} from '@blocksuite/affine-block-surface';
|
||||||
import {
|
|
||||||
containsNode,
|
|
||||||
createFromTree,
|
|
||||||
detachMindmap,
|
|
||||||
findTargetNode,
|
|
||||||
hideNodeConnector,
|
|
||||||
type MindMapIndicatorOverlay,
|
|
||||||
NODE_HORIZONTAL_SPACING,
|
|
||||||
NODE_VERTICAL_SPACING,
|
|
||||||
tryMoveNode,
|
|
||||||
} from '@blocksuite/affine-gfx-mindmap';
|
|
||||||
import {
|
import {
|
||||||
type LayoutType,
|
type LayoutType,
|
||||||
type LocalConnectorElementModel,
|
type LocalConnectorElementModel,
|
||||||
@@ -31,9 +20,18 @@ import {
|
|||||||
} from '@blocksuite/block-std/gfx';
|
} from '@blocksuite/block-std/gfx';
|
||||||
import type { Bound, IVec } from '@blocksuite/global/gfx';
|
import type { Bound, IVec } from '@blocksuite/global/gfx';
|
||||||
|
|
||||||
import { isSingleMindMapNode } from '../utils/mindmap';
|
import type { MindMapIndicatorOverlay } from '../indicator-overlay';
|
||||||
import { isMindmapNode } from '../utils/query';
|
import { isMindmapNode, isSingleMindMapNode } from '../utils';
|
||||||
import { calculateResponseArea } from './utils/drag-utils';
|
import { NODE_HORIZONTAL_SPACING, NODE_VERTICAL_SPACING } from '../view/layout';
|
||||||
|
import {
|
||||||
|
containsNode,
|
||||||
|
createFromTree,
|
||||||
|
detachMindmap,
|
||||||
|
findTargetNode,
|
||||||
|
hideNodeConnector,
|
||||||
|
tryMoveNode,
|
||||||
|
} from '../view/utils';
|
||||||
|
import { calculateResponseArea } from './drag-utils';
|
||||||
|
|
||||||
type DragMindMapCtx = {
|
type DragMindMapCtx = {
|
||||||
mindmap: MindmapElementModel;
|
mindmap: MindmapElementModel;
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
export * from './element-transform';
|
||||||
export * from './indicator-overlay';
|
export * from './indicator-overlay';
|
||||||
export * from './toolbar/config';
|
export * from './toolbar/config';
|
||||||
|
export * from './utils';
|
||||||
export * from './view';
|
export * from './view';
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
import { MindmapElementModel } from '@blocksuite/affine-model';
|
import { MindmapElementModel } from '@blocksuite/affine-model';
|
||||||
import type { GfxModel, Viewport } from '@blocksuite/block-std/gfx';
|
import type {
|
||||||
|
GfxBlockElementModel,
|
||||||
|
GfxModel,
|
||||||
|
Viewport,
|
||||||
|
} from '@blocksuite/block-std/gfx';
|
||||||
|
|
||||||
|
export function isMindmapNode(element: GfxBlockElementModel | GfxModel | null) {
|
||||||
|
return element?.group instanceof MindmapElementModel;
|
||||||
|
}
|
||||||
|
|
||||||
export function isSingleMindMapNode(els: GfxModel[]) {
|
export function isSingleMindMapNode(els: GfxModel[]) {
|
||||||
return els.length === 1 && els[0].group instanceof MindmapElementModel;
|
return els.length === 1 && els[0].group instanceof MindmapElementModel;
|
||||||
Reference in New Issue
Block a user