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