mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
refactor(editor): move mindmap view to mindmap package (#11102)
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
|||||||
} 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 { ConnectorTool } from '@blocksuite/affine-gfx-connector';
|
||||||
|
import { 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';
|
||||||
@@ -19,7 +20,6 @@ import { EdgelessRootBlockSpec } from './edgeless-root-spec.js';
|
|||||||
import { ConnectorFilter } from './element-transform/connector-filter.js';
|
import { ConnectorFilter } from './element-transform/connector-filter.js';
|
||||||
import { MindMapDragExtension } from './element-transform/mind-map-drag.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 { MindMapIndicatorOverlay } from './element-transform/utils/indicator-overlay.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';
|
||||||
import { EmptyTool } from './gfx-tool/empty-tool.js';
|
import { EmptyTool } from './gfx-tool/empty-tool.js';
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { ConnectorElementView } from '@blocksuite/affine-gfx-connector';
|
||||||
|
import { MindMapView } from '@blocksuite/affine-gfx-mindmap';
|
||||||
import { ViewportElementExtension } from '@blocksuite/affine-shared/services';
|
import { ViewportElementExtension } from '@blocksuite/affine-shared/services';
|
||||||
import { autoConnectWidget } from '@blocksuite/affine-widget-edgeless-auto-connect';
|
import { autoConnectWidget } from '@blocksuite/affine-widget-edgeless-auto-connect';
|
||||||
import { edgelessToolbarWidget } from '@blocksuite/affine-widget-edgeless-toolbar';
|
import { edgelessToolbarWidget } from '@blocksuite/affine-widget-edgeless-toolbar';
|
||||||
@@ -59,6 +61,8 @@ const EdgelessCommonExtension: ExtensionType[] = [
|
|||||||
ToolController,
|
ToolController,
|
||||||
EdgelessRootService,
|
EdgelessRootService,
|
||||||
ViewportElementExtension('.affine-edgeless-viewport'),
|
ViewportElementExtension('.affine-edgeless-viewport'),
|
||||||
|
MindMapView,
|
||||||
|
ConnectorElementView,
|
||||||
...quickTools,
|
...quickTools,
|
||||||
...seniorTools,
|
...seniorTools,
|
||||||
].flat();
|
].flat();
|
||||||
|
|||||||
@@ -1,10 +1,18 @@
|
|||||||
import {
|
import {
|
||||||
MindmapUtils,
|
|
||||||
NODE_HORIZONTAL_SPACING,
|
|
||||||
NODE_VERTICAL_SPACING,
|
|
||||||
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,
|
||||||
@@ -26,7 +34,6 @@ import type { Bound, IVec } from '@blocksuite/global/gfx';
|
|||||||
import { isSingleMindMapNode } from '../utils/mindmap';
|
import { isSingleMindMapNode } from '../utils/mindmap';
|
||||||
import { isMindmapNode } from '../utils/query';
|
import { isMindmapNode } from '../utils/query';
|
||||||
import { calculateResponseArea } from './utils/drag-utils';
|
import { calculateResponseArea } from './utils/drag-utils';
|
||||||
import type { MindMapIndicatorOverlay } from './utils/indicator-overlay';
|
|
||||||
|
|
||||||
type DragMindMapCtx = {
|
type DragMindMapCtx = {
|
||||||
mindmap: MindmapElementModel;
|
mindmap: MindmapElementModel;
|
||||||
@@ -89,7 +96,7 @@ export class MindMapDragExtension extends TransformExtension {
|
|||||||
hoveredCtx?.abort?.();
|
hoveredCtx?.abort?.();
|
||||||
|
|
||||||
const hoveredNode = hoveredMindMap
|
const hoveredNode = hoveredMindMap
|
||||||
? MindmapUtils.findTargetNode(hoveredMindMap, [x, y])
|
? findTargetNode(hoveredMindMap, [x, y])
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
hoveredCtx = {
|
hoveredCtx = {
|
||||||
@@ -104,13 +111,9 @@ export class MindMapDragExtension extends TransformExtension {
|
|||||||
if (
|
if (
|
||||||
hoveredNode &&
|
hoveredNode &&
|
||||||
hoveredMindMap &&
|
hoveredMindMap &&
|
||||||
!MindmapUtils.containsNode(
|
!containsNode(hoveredMindMap, hoveredNode, dragMindMapCtx.node)
|
||||||
hoveredMindMap,
|
|
||||||
hoveredNode,
|
|
||||||
dragMindMapCtx.node
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
const operation = MindmapUtils.tryMoveNode(
|
const operation = tryMoveNode(
|
||||||
hoveredMindMap,
|
hoveredMindMap,
|
||||||
hoveredNode,
|
hoveredNode,
|
||||||
dragMindMapCtx.mindmap,
|
dragMindMapCtx.mindmap,
|
||||||
@@ -156,7 +159,7 @@ export class MindMapDragExtension extends TransformExtension {
|
|||||||
} else {
|
} else {
|
||||||
hoveredCtx.detach = true;
|
hoveredCtx.detach = true;
|
||||||
|
|
||||||
const reset = (hoveredCtx.abort = MindmapUtils.hideNodeConnector(
|
const reset = (hoveredCtx.abort = hideNodeConnector(
|
||||||
dragMindMapCtx.mindmap,
|
dragMindMapCtx.mindmap,
|
||||||
dragMindMapCtx.node
|
dragMindMapCtx.node
|
||||||
));
|
));
|
||||||
@@ -183,11 +186,8 @@ export class MindMapDragExtension extends TransformExtension {
|
|||||||
.serialize();
|
.serialize();
|
||||||
|
|
||||||
if (dragMindMapCtx.node !== dragMindMapCtx.mindmap.tree) {
|
if (dragMindMapCtx.node !== dragMindMapCtx.mindmap.tree) {
|
||||||
MindmapUtils.detachMindmap(
|
detachMindmap(dragMindMapCtx.mindmap, dragMindMapCtx.node);
|
||||||
dragMindMapCtx.mindmap,
|
const mindmap = createFromTree(
|
||||||
dragMindMapCtx.node
|
|
||||||
);
|
|
||||||
const mindmap = MindmapUtils.createFromTree(
|
|
||||||
dragMindMapCtx.node,
|
dragMindMapCtx.node,
|
||||||
dragMindMapCtx.mindmap.style,
|
dragMindMapCtx.mindmap.style,
|
||||||
dragMindMapCtx.mindmap.layoutType,
|
dragMindMapCtx.mindmap.layoutType,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
NODE_HORIZONTAL_SPACING,
|
NODE_HORIZONTAL_SPACING,
|
||||||
NODE_VERTICAL_SPACING,
|
NODE_VERTICAL_SPACING,
|
||||||
} from '@blocksuite/affine-block-surface';
|
} from '@blocksuite/affine-gfx-mindmap';
|
||||||
import {
|
import {
|
||||||
LayoutType,
|
LayoutType,
|
||||||
type MindmapElementModel,
|
type MindmapElementModel,
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import {
|
|||||||
NOTE_SLICER_WIDGET,
|
NOTE_SLICER_WIDGET,
|
||||||
NoteSlicer,
|
NoteSlicer,
|
||||||
} from './edgeless/components/note-slicer/index.js';
|
} from './edgeless/components/note-slicer/index.js';
|
||||||
import { EdgelessFontFamilyPanel } from './edgeless/components/panel/font-family-panel.js';
|
|
||||||
import { EdgelessFontWeightAndStylePanel } from './edgeless/components/panel/font-weight-and-style-panel.js';
|
|
||||||
import { EdgelessScalePanel } from './edgeless/components/panel/scale-panel.js';
|
import { EdgelessScalePanel } from './edgeless/components/panel/scale-panel.js';
|
||||||
import { EdgelessSizePanel } from './edgeless/components/panel/size-panel.js';
|
import { EdgelessSizePanel } from './edgeless/components/panel/size-panel.js';
|
||||||
import { StrokeStylePanel } from './edgeless/components/panel/stroke-style-panel.js';
|
import { StrokeStylePanel } from './edgeless/components/panel/stroke-style-panel.js';
|
||||||
@@ -151,13 +149,8 @@ function registerEdgelessToolbarComponents() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function registerEdgelessPanelComponents() {
|
function registerEdgelessPanelComponents() {
|
||||||
customElements.define(
|
|
||||||
'edgeless-font-weight-and-style-panel',
|
|
||||||
EdgelessFontWeightAndStylePanel
|
|
||||||
);
|
|
||||||
customElements.define('edgeless-size-panel', EdgelessSizePanel);
|
customElements.define('edgeless-size-panel', EdgelessSizePanel);
|
||||||
customElements.define('edgeless-scale-panel', EdgelessScalePanel);
|
customElements.define('edgeless-scale-panel', EdgelessScalePanel);
|
||||||
customElements.define('edgeless-font-family-panel', EdgelessFontFamilyPanel);
|
|
||||||
customElements.define('stroke-style-panel', StrokeStylePanel);
|
customElements.define('stroke-style-panel', StrokeStylePanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,8 +210,6 @@ declare global {
|
|||||||
'edgeless-auto-complete-panel': EdgelessAutoCompletePanel;
|
'edgeless-auto-complete-panel': EdgelessAutoCompletePanel;
|
||||||
'edgeless-auto-complete': EdgelessAutoComplete;
|
'edgeless-auto-complete': EdgelessAutoComplete;
|
||||||
'note-slicer': NoteSlicer;
|
'note-slicer': NoteSlicer;
|
||||||
'edgeless-font-family-panel': EdgelessFontFamilyPanel;
|
|
||||||
'edgeless-font-weight-and-style-panel': EdgelessFontWeightAndStylePanel;
|
|
||||||
'edgeless-scale-panel': EdgelessScalePanel;
|
'edgeless-scale-panel': EdgelessScalePanel;
|
||||||
'edgeless-size-panel': EdgelessSizePanel;
|
'edgeless-size-panel': EdgelessSizePanel;
|
||||||
'stroke-style-panel': StrokeStylePanel;
|
'stroke-style-panel': StrokeStylePanel;
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ export { fitContent } from './renderer/elements/shape/utils.js';
|
|||||||
export * from './renderer/elements/type.js';
|
export * from './renderer/elements/type.js';
|
||||||
export { Overlay, OverlayIdentifier } from './renderer/overlay.js';
|
export { Overlay, OverlayIdentifier } from './renderer/overlay.js';
|
||||||
export { ToolOverlay } from './renderer/tool-overlay.js';
|
export { ToolOverlay } from './renderer/tool-overlay.js';
|
||||||
export { MindMapView } from './view/mindmap.js';
|
|
||||||
import {
|
import {
|
||||||
getCursorByCoord,
|
getCursorByCoord,
|
||||||
getLineHeight,
|
getLineHeight,
|
||||||
@@ -49,6 +48,7 @@ export {
|
|||||||
EdgelessSurfaceBlockAdapterExtensions,
|
EdgelessSurfaceBlockAdapterExtensions,
|
||||||
SurfaceBlockAdapterExtensions,
|
SurfaceBlockAdapterExtensions,
|
||||||
} from './adapters/index.js';
|
} from './adapters/index.js';
|
||||||
|
export * from './extensions';
|
||||||
export type { SurfaceContext } from './surface-block.js';
|
export type { SurfaceContext } from './surface-block.js';
|
||||||
export { SurfaceBlockComponent } from './surface-block.js';
|
export { SurfaceBlockComponent } from './surface-block.js';
|
||||||
export {
|
export {
|
||||||
@@ -62,25 +62,6 @@ export {
|
|||||||
PageSurfaceBlockSpec,
|
PageSurfaceBlockSpec,
|
||||||
} from './surface-spec.js';
|
} from './surface-spec.js';
|
||||||
export { SurfaceBlockTransformer } from './surface-transformer.js';
|
export { SurfaceBlockTransformer } from './surface-transformer.js';
|
||||||
export { AStarRunner } from './utils/a-star.js';
|
|
||||||
export {
|
|
||||||
NODE_FIRST_LEVEL_HORIZONTAL_SPACING,
|
|
||||||
NODE_HORIZONTAL_SPACING,
|
|
||||||
NODE_VERTICAL_SPACING,
|
|
||||||
} from './utils/mindmap/layout.js';
|
|
||||||
export { RoughCanvas } from './utils/rough/canvas.js';
|
|
||||||
|
|
||||||
import {
|
|
||||||
addTree,
|
|
||||||
containsNode,
|
|
||||||
createFromTree,
|
|
||||||
detachMindmap,
|
|
||||||
findTargetNode,
|
|
||||||
hideNodeConnector,
|
|
||||||
moveNode,
|
|
||||||
tryMoveNode,
|
|
||||||
} from './utils/mindmap/utils';
|
|
||||||
export * from './extensions';
|
|
||||||
export {
|
export {
|
||||||
addNote,
|
addNote,
|
||||||
addNoteAtPoint,
|
addNoteAtPoint,
|
||||||
@@ -91,7 +72,8 @@ export {
|
|||||||
getSurfaceComponent,
|
getSurfaceComponent,
|
||||||
normalizeWheelDeltaY,
|
normalizeWheelDeltaY,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
export * from './utils/mindmap/style-svg';
|
export { AStarRunner } from './utils/a-star.js';
|
||||||
|
export { RoughCanvas } from './utils/rough/canvas.js';
|
||||||
export type { Options } from './utils/rough/core';
|
export type { Options } from './utils/rough/core';
|
||||||
export { sortIndex } from './utils/sort';
|
export { sortIndex } from './utils/sort';
|
||||||
export { updateXYWH } from './utils/update-xywh.js';
|
export { updateXYWH } from './utils/update-xywh.js';
|
||||||
@@ -114,15 +96,4 @@ export const TextUtils = {
|
|||||||
isSameFontFamily,
|
isSameFontFamily,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MindmapUtils = {
|
|
||||||
addTree,
|
|
||||||
createFromTree,
|
|
||||||
detachMindmap,
|
|
||||||
moveNode,
|
|
||||||
findTargetNode,
|
|
||||||
tryMoveNode,
|
|
||||||
hideNodeConnector,
|
|
||||||
containsNode,
|
|
||||||
};
|
|
||||||
|
|
||||||
export * from './commands';
|
export * from './commands';
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ import {
|
|||||||
} from './extensions';
|
} from './extensions';
|
||||||
import { ExportManagerExtension } from './extensions/export-manager/export-manager';
|
import { ExportManagerExtension } from './extensions/export-manager/export-manager';
|
||||||
import { SurfaceBlockService } from './surface-service';
|
import { SurfaceBlockService } from './surface-service';
|
||||||
import { ConnectorElementView } from './view/connector';
|
|
||||||
import { MindMapView } from './view/mindmap';
|
|
||||||
|
|
||||||
const CommonSurfaceBlockSpec: ExtensionType[] = [
|
const CommonSurfaceBlockSpec: ExtensionType[] = [
|
||||||
FlavourExtension('affine:surface'),
|
FlavourExtension('affine:surface'),
|
||||||
@@ -23,8 +21,6 @@ const CommonSurfaceBlockSpec: ExtensionType[] = [
|
|||||||
ExportManagerExtension,
|
ExportManagerExtension,
|
||||||
];
|
];
|
||||||
|
|
||||||
const ElementModelViews = [MindMapView, ConnectorElementView];
|
|
||||||
|
|
||||||
export const PageSurfaceBlockSpec: ExtensionType[] = [
|
export const PageSurfaceBlockSpec: ExtensionType[] = [
|
||||||
...CommonSurfaceBlockSpec,
|
...CommonSurfaceBlockSpec,
|
||||||
...SurfaceBlockAdapterExtensions,
|
...SurfaceBlockAdapterExtensions,
|
||||||
@@ -34,6 +30,5 @@ export const PageSurfaceBlockSpec: ExtensionType[] = [
|
|||||||
export const EdgelessSurfaceBlockSpec: ExtensionType[] = [
|
export const EdgelessSurfaceBlockSpec: ExtensionType[] = [
|
||||||
...CommonSurfaceBlockSpec,
|
...CommonSurfaceBlockSpec,
|
||||||
...EdgelessSurfaceBlockAdapterExtensions,
|
...EdgelessSurfaceBlockAdapterExtensions,
|
||||||
...ElementModelViews,
|
|
||||||
BlockViewExtension('affine:surface', literal`affine-surface`),
|
BlockViewExtension('affine:surface', literal`affine-surface`),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -37,4 +37,3 @@ export { addNote, addNoteAtPoint } from './add-note';
|
|||||||
export { getBgGridGap } from './get-bg-grip-gap';
|
export { getBgGridGap } from './get-bg-grip-gap';
|
||||||
export { getLastPropsKey } from './get-last-props-key';
|
export { getLastPropsKey } from './get-last-props-key';
|
||||||
export * from './get-surface-block';
|
export * from './get-surface-block';
|
||||||
export * from './mindmap/style-svg.js';
|
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ export * from './connector-tool';
|
|||||||
export * from './text';
|
export * from './text';
|
||||||
export * from './toolbar/config';
|
export * from './toolbar/config';
|
||||||
export * from './toolbar/quick-tool';
|
export * from './toolbar/quick-tool';
|
||||||
|
export * from './view';
|
||||||
|
|||||||
1
blocksuite/affine/gfx/connector/src/view/index.ts
Normal file
1
blocksuite/affine/gfx/connector/src/view/index.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from './view';
|
||||||
@@ -1 +1,3 @@
|
|||||||
|
export * from './indicator-overlay';
|
||||||
export * from './toolbar/config';
|
export * from './toolbar/config';
|
||||||
|
export * from './view';
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
import {
|
import { Overlay, PathGenerator } from '@blocksuite/affine-block-surface';
|
||||||
NODE_HORIZONTAL_SPACING,
|
|
||||||
NODE_VERTICAL_SPACING,
|
|
||||||
Overlay,
|
|
||||||
PathGenerator,
|
|
||||||
} from '@blocksuite/affine-block-surface';
|
|
||||||
import {
|
import {
|
||||||
ConnectorMode,
|
ConnectorMode,
|
||||||
LayoutType,
|
LayoutType,
|
||||||
@@ -21,6 +16,8 @@ import {
|
|||||||
} from '@blocksuite/global/gfx';
|
} 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';
|
||||||
|
|
||||||
export class MindMapIndicatorOverlay extends Overlay {
|
export class MindMapIndicatorOverlay extends Overlay {
|
||||||
static INDICATOR_SIZE = [48, 22];
|
static INDICATOR_SIZE = [48, 22];
|
||||||
|
|
||||||
@@ -1,9 +1,3 @@
|
|||||||
import {
|
|
||||||
MindmapStyleFour,
|
|
||||||
MindmapStyleOne,
|
|
||||||
MindmapStyleThree,
|
|
||||||
MindmapStyleTwo,
|
|
||||||
} from '@blocksuite/affine-block-surface';
|
|
||||||
import {
|
import {
|
||||||
LayoutType,
|
LayoutType,
|
||||||
MindmapElementModel,
|
MindmapElementModel,
|
||||||
@@ -22,6 +16,13 @@ import {
|
|||||||
import { BlockFlavourIdentifier } from '@blocksuite/block-std';
|
import { BlockFlavourIdentifier } from '@blocksuite/block-std';
|
||||||
import { RadiantIcon, RightLayoutIcon, StyleIcon } from '@blocksuite/icons/lit';
|
import { RadiantIcon, RightLayoutIcon, StyleIcon } from '@blocksuite/icons/lit';
|
||||||
|
|
||||||
|
import {
|
||||||
|
MindmapStyleFour,
|
||||||
|
MindmapStyleOne,
|
||||||
|
MindmapStyleThree,
|
||||||
|
MindmapStyleTwo,
|
||||||
|
} from '../view';
|
||||||
|
|
||||||
const MINDMAP_STYLE_LIST = [
|
const MINDMAP_STYLE_LIST = [
|
||||||
{
|
{
|
||||||
value: MindmapStyle.ONE,
|
value: MindmapStyle.ONE,
|
||||||
|
|||||||
4
blocksuite/affine/gfx/mindmap/src/view/index.ts
Normal file
4
blocksuite/affine/gfx/mindmap/src/view/index.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export * from './layout';
|
||||||
|
export * from './style-svg';
|
||||||
|
export * from './utils';
|
||||||
|
export * from './view';
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { fitContent } from '@blocksuite/affine-block-surface';
|
||||||
import {
|
import {
|
||||||
applyNodeStyle,
|
applyNodeStyle,
|
||||||
LayoutType,
|
LayoutType,
|
||||||
@@ -19,7 +20,6 @@ import isEqual from 'lodash-es/isEqual';
|
|||||||
import last from 'lodash-es/last';
|
import last from 'lodash-es/last';
|
||||||
import * as Y from 'yjs';
|
import * as Y from 'yjs';
|
||||||
|
|
||||||
import { fitContent } from '../../renderer/elements/shape/utils.js';
|
|
||||||
import { layout } from './layout.js';
|
import { layout } from './layout.js';
|
||||||
|
|
||||||
export function getHoveredArea(
|
export function getHoveredArea(
|
||||||
@@ -10,7 +10,7 @@ import { requestThrottledConnectedFrame } from '@blocksuite/affine-shared/utils'
|
|||||||
import type { PointerEventState } from '@blocksuite/block-std';
|
import type { PointerEventState } from '@blocksuite/block-std';
|
||||||
import { GfxElementModelView } from '@blocksuite/block-std/gfx';
|
import { GfxElementModelView } from '@blocksuite/block-std/gfx';
|
||||||
|
|
||||||
import { handleLayout } from '../utils/mindmap/utils.js';
|
import { handleLayout } from './utils.js';
|
||||||
|
|
||||||
export class MindMapView extends GfxElementModelView<MindmapElementModel> {
|
export class MindMapView extends GfxElementModelView<MindmapElementModel> {
|
||||||
static override type = 'mindmap';
|
static override type = 'mindmap';
|
||||||
@@ -4,11 +4,18 @@ import {
|
|||||||
EDGELESS_TOOLBAR_WIDGET,
|
EDGELESS_TOOLBAR_WIDGET,
|
||||||
EdgelessToolbarWidget,
|
EdgelessToolbarWidget,
|
||||||
} from './edgeless-toolbar';
|
} from './edgeless-toolbar';
|
||||||
|
import { EdgelessFontFamilyPanel } from './panel/font-family-panel';
|
||||||
|
import { EdgelessFontWeightAndStylePanel } from './panel/font-weight-and-style-panel';
|
||||||
|
|
||||||
export function effects() {
|
export function effects() {
|
||||||
customElements.define(EDGELESS_TOOLBAR_WIDGET, EdgelessToolbarWidget);
|
customElements.define(EDGELESS_TOOLBAR_WIDGET, EdgelessToolbarWidget);
|
||||||
customElements.define('edgeless-toolbar-button', EdgelessToolbarButton);
|
customElements.define('edgeless-toolbar-button', EdgelessToolbarButton);
|
||||||
customElements.define('edgeless-tool-icon-button', EdgelessToolIconButton);
|
customElements.define('edgeless-tool-icon-button', EdgelessToolIconButton);
|
||||||
|
customElements.define(
|
||||||
|
'edgeless-font-weight-and-style-panel',
|
||||||
|
EdgelessFontWeightAndStylePanel
|
||||||
|
);
|
||||||
|
customElements.define('edgeless-font-family-panel', EdgelessFontFamilyPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
@@ -16,5 +23,7 @@ declare global {
|
|||||||
'edgeless-tool-icon-button': EdgelessToolIconButton;
|
'edgeless-tool-icon-button': EdgelessToolIconButton;
|
||||||
'edgeless-toolbar-button': EdgelessToolbarButton;
|
'edgeless-toolbar-button': EdgelessToolbarButton;
|
||||||
'edgeless-toolbar-widget': EdgelessToolbarWidget;
|
'edgeless-toolbar-widget': EdgelessToolbarWidget;
|
||||||
|
'edgeless-font-weight-and-style-panel': EdgelessFontWeightAndStylePanel;
|
||||||
|
'edgeless-font-family-panel': EdgelessFontFamilyPanel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { MindMapView } from '@blocksuite/affine/blocks/surface';
|
import type { MindMapView } from '@blocksuite/affine/gfx/mindmap';
|
||||||
import { LayoutType, type MindmapElementModel } from '@blocksuite/affine-model';
|
import { LayoutType, type MindmapElementModel } from '@blocksuite/affine-model';
|
||||||
import type { GfxController } from '@blocksuite/block-std/gfx';
|
import type { GfxController } from '@blocksuite/block-std/gfx';
|
||||||
import { Bound } from '@blocksuite/global/gfx';
|
import { Bound } from '@blocksuite/global/gfx';
|
||||||
|
|||||||
@@ -5,12 +5,9 @@ import {
|
|||||||
EDGELESS_TEXT_BLOCK_MIN_WIDTH,
|
EDGELESS_TEXT_BLOCK_MIN_WIDTH,
|
||||||
} from '@blocksuite/affine/blocks/edgeless-text';
|
} from '@blocksuite/affine/blocks/edgeless-text';
|
||||||
import { addImages } from '@blocksuite/affine/blocks/image';
|
import { addImages } from '@blocksuite/affine/blocks/image';
|
||||||
import {
|
import { fitContent, getSurfaceBlock } from '@blocksuite/affine/blocks/surface';
|
||||||
fitContent,
|
|
||||||
getSurfaceBlock,
|
|
||||||
MindmapUtils,
|
|
||||||
} from '@blocksuite/affine/blocks/surface';
|
|
||||||
import { LightLoadingIcon } from '@blocksuite/affine/components/icons';
|
import { LightLoadingIcon } from '@blocksuite/affine/components/icons';
|
||||||
|
import { addTree } from '@blocksuite/affine/gfx/mindmap';
|
||||||
import { Bound } from '@blocksuite/affine/global/gfx';
|
import { Bound } from '@blocksuite/affine/global/gfx';
|
||||||
import type {
|
import type {
|
||||||
MindmapElementModel,
|
MindmapElementModel,
|
||||||
@@ -379,7 +376,7 @@ export function responseToExpandMindmap(host: EditorHost, ctx: AIContext) {
|
|||||||
const mindmap = elements[0].group as MindmapElementModel;
|
const mindmap = elements[0].group as MindmapElementModel;
|
||||||
if (mindmapNode.children) {
|
if (mindmapNode.children) {
|
||||||
mindmapNode.children.forEach(childTree => {
|
mindmapNode.children.forEach(childTree => {
|
||||||
MindmapUtils.addTree(mindmap, elements[0].id, childTree);
|
addTree(mindmap, elements[0].id, childTree);
|
||||||
});
|
});
|
||||||
|
|
||||||
const subtree = mindmap.getNode(elements[0].id);
|
const subtree = mindmap.getNode(elements[0].id);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { WorkspaceImpl } from '@affine/core/modules/workspace/impls/workspace.js';
|
import { WorkspaceImpl } from '@affine/core/modules/workspace/impls/workspace.js';
|
||||||
import { BlockStdScope, type EditorHost } from '@blocksuite/affine/block-std';
|
import { BlockStdScope, type EditorHost } from '@blocksuite/affine/block-std';
|
||||||
|
import type { SurfaceBlockModel } from '@blocksuite/affine/blocks/surface';
|
||||||
import {
|
import {
|
||||||
MindmapStyleFour,
|
MindmapStyleFour,
|
||||||
MindmapStyleOne,
|
MindmapStyleOne,
|
||||||
MindmapStyleThree,
|
MindmapStyleThree,
|
||||||
MindmapStyleTwo,
|
MindmapStyleTwo,
|
||||||
type SurfaceBlockModel,
|
} from '@blocksuite/affine/gfx/mindmap';
|
||||||
} from '@blocksuite/affine/blocks/surface';
|
|
||||||
import type { ServiceProvider } from '@blocksuite/affine/global/di';
|
import type { ServiceProvider } from '@blocksuite/affine/global/di';
|
||||||
import { WithDisposable } from '@blocksuite/affine/global/lit';
|
import { WithDisposable } from '@blocksuite/affine/global/lit';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -2,10 +2,8 @@ import {
|
|||||||
BlockViewExtension,
|
BlockViewExtension,
|
||||||
FlavourExtension,
|
FlavourExtension,
|
||||||
} from '@blocksuite/affine/block-std';
|
} from '@blocksuite/affine/block-std';
|
||||||
import {
|
import { SurfaceBlockSchema } from '@blocksuite/affine/blocks/surface';
|
||||||
MindMapView,
|
import { MindMapView } from '@blocksuite/affine/gfx/mindmap';
|
||||||
SurfaceBlockSchema,
|
|
||||||
} from '@blocksuite/affine/blocks/surface';
|
|
||||||
import { RootBlockSchema } from '@blocksuite/affine/model';
|
import { RootBlockSchema } from '@blocksuite/affine/model';
|
||||||
import {
|
import {
|
||||||
DocModeService,
|
DocModeService,
|
||||||
|
|||||||
Reference in New Issue
Block a user