@plait/mind 0.27.0-next.1 → 0.27.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/base/emoji-base.component.d.ts +1 -1
- package/base/image-base.component.d.ts +1 -1
- package/constants/node-topic-style.d.ts +3 -0
- package/{esm2020 → esm2022}/base/emoji-base.component.mjs +4 -4
- package/esm2022/base/image-base.component.mjs +75 -0
- package/{esm2020 → esm2022}/constants/node-topic-style.mjs +4 -1
- package/esm2022/interfaces/element-data.mjs +2 -0
- package/{esm2020 → esm2022}/mind.component.mjs +6 -6
- package/{esm2020 → esm2022}/mind.module.mjs +5 -5
- package/esm2022/node.component.mjs +251 -0
- package/{fesm2020 → fesm2022}/plait-mind.mjs +33 -24
- package/fesm2022/plait-mind.mjs.map +1 -0
- package/interfaces/element-data.d.ts +2 -2
- package/package.json +7 -13
- package/utils/abstract/common.d.ts +2 -2
- package/esm2020/base/image-base.component.mjs +0 -72
- package/esm2020/interfaces/element-data.mjs +0 -2
- package/esm2020/node.component.mjs +0 -248
- package/fesm2015/plait-mind.mjs +0 -4382
- package/fesm2015/plait-mind.mjs.map +0 -1
- package/fesm2020/plait-mind.mjs.map +0 -1
- /package/{esm2020 → esm2022}/base/base.drawer.mjs +0 -0
- /package/{esm2020 → esm2022}/base/index.mjs +0 -0
- /package/{esm2020 → esm2022}/constants/abstract-node.mjs +0 -0
- /package/{esm2020 → esm2022}/constants/default.mjs +0 -0
- /package/{esm2020 → esm2022}/constants/image.mjs +0 -0
- /package/{esm2020 → esm2022}/constants/index.mjs +0 -0
- /package/{esm2020 → esm2022}/constants/node-style.mjs +0 -0
- /package/{esm2020 → esm2022}/constants/theme.mjs +0 -0
- /package/{esm2020 → esm2022}/drawer/node-active.drawer.mjs +0 -0
- /package/{esm2020 → esm2022}/drawer/node-collapse.drawer.mjs +0 -0
- /package/{esm2020 → esm2022}/drawer/node-emojis.drawer.mjs +0 -0
- /package/{esm2020 → esm2022}/drawer/node-image.drawer.mjs +0 -0
- /package/{esm2020 → esm2022}/drawer/node-insert.drawer.mjs +0 -0
- /package/{esm2020 → esm2022}/interfaces/element.mjs +0 -0
- /package/{esm2020 → esm2022}/interfaces/index.mjs +0 -0
- /package/{esm2020 → esm2022}/interfaces/layout.mjs +0 -0
- /package/{esm2020 → esm2022}/interfaces/node.mjs +0 -0
- /package/{esm2020 → esm2022}/interfaces/options.mjs +0 -0
- /package/{esm2020 → esm2022}/interfaces/pointer.mjs +0 -0
- /package/{esm2020 → esm2022}/interfaces/theme-color.mjs +0 -0
- /package/{esm2020 → esm2022}/interfaces/types.mjs +0 -0
- /package/{esm2020 → esm2022}/plait-mind.mjs +0 -0
- /package/{esm2020 → esm2022}/plugins/with-abstract-resize.board.mjs +0 -0
- /package/{esm2020 → esm2022}/plugins/with-abstract-resize.mjs +0 -0
- /package/{esm2020 → esm2022}/plugins/with-mind-create.mjs +0 -0
- /package/{esm2020 → esm2022}/plugins/with-mind-extend.mjs +0 -0
- /package/{esm2020 → esm2022}/plugins/with-mind-hotkey.mjs +0 -0
- /package/{esm2020 → esm2022}/plugins/with-mind.board.mjs +0 -0
- /package/{esm2020 → esm2022}/plugins/with-mind.mjs +0 -0
- /package/{esm2020 → esm2022}/plugins/with-node-dnd.mjs +0 -0
- /package/{esm2020 → esm2022}/plugins/with-node-hover-detect.mjs +0 -0
- /package/{esm2020 → esm2022}/plugins/with-node-image-resize.mjs +0 -0
- /package/{esm2020 → esm2022}/plugins/with-node-image.mjs +0 -0
- /package/{esm2020 → esm2022}/plugins/with-node-resize.mjs +0 -0
- /package/{esm2020 → esm2022}/public-api.mjs +0 -0
- /package/{esm2020 → esm2022}/queries/get-available-sublayouts-by-element.mjs +0 -0
- /package/{esm2020 → esm2022}/queries/get-branch-layouts.mjs +0 -0
- /package/{esm2020 → esm2022}/queries/get-correct-layout-by-element.mjs +0 -0
- /package/{esm2020 → esm2022}/queries/get-layout-by-element.mjs +0 -0
- /package/{esm2020 → esm2022}/queries/index.mjs +0 -0
- /package/{esm2020 → esm2022}/transforms/abstract-node.mjs +0 -0
- /package/{esm2020 → esm2022}/transforms/emoji.mjs +0 -0
- /package/{esm2020 → esm2022}/transforms/image.mjs +0 -0
- /package/{esm2020 → esm2022}/transforms/index.mjs +0 -0
- /package/{esm2020 → esm2022}/transforms/layout.mjs +0 -0
- /package/{esm2020 → esm2022}/transforms/node.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/abstract/common.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/abstract/resize.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/clipboard.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/dnd/common.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/dnd/detector.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/draw/abstract-outline.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/draw/node-dnd.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/draw/node-link/abstract-link.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/draw/node-link/draw-link.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/draw/node-link/indented-link.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/draw/node-link/logic-link.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/draw/node-shape.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/index.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/layout.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/mind.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/node/adjust-node.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/node/common.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/node/create-node.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/node/dynamic-width.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/node/image.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/node/index.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/node/right-node-count.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/node-hover/extend.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/node-style/branch.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/node-style/common.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/node-style/index.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/node-style/shape.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/path.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/point-placement.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/position/emoji.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/position/image.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/position/index.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/position/node.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/position/topic.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/space/emoji.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/space/index.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/space/layout-options.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/space/node-space.mjs +0 -0
- /package/{esm2020 → esm2022}/utils/weak-maps.mjs +0 -0
package/fesm2015/plait-mind.mjs
DELETED
|
@@ -1,4382 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, ChangeDetectionStrategy, NgModule, NgZone, Directive, Input, HostListener } from '@angular/core';
|
|
3
|
-
import * as i2 from '@plait/core';
|
|
4
|
-
import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, RectangleClient, PlaitElement, PlaitPluginKey, getSelectedElements, idCreator, isNullOrUndefined, Transforms, clearSelectedElement, addSelectedElement, PlaitBoard, Path, PlaitNode, PlaitContextService, depthFirstRecursion, getIsRecursionFunc, drawLinearPath, drawBezierPath, createG, updateForeignObject, drawRoundRectangle, getRectangleByElements, NODE_TO_PARENT, distanceBetweenPointAndRectangle, createForeignObject, createText, PlaitPointerType, PlaitPluginElementComponent, NODE_TO_INDEX, PlaitModule, isMainPointer, transformPoint, toPoint, getHitElements, distanceBetweenPointAndPoint, setClipboardData, setClipboardDataByText, BOARD_TO_HOST, throttleRAF, BoardTransforms, removeSelectedElement, PlaitHistoryBoard, hotkeys, setClipboardDataByMedia, getClipboardDataByMedia, ResizeCursorClass, preventTouchMove, PRESS_AND_MOVE_BUFFER, MERGING, getDataFromClipboard } from '@plait/core';
|
|
5
|
-
import { MindLayoutType, isIndentedLayout, AbstractNode, isStandardLayout, isHorizontalLogicLayout, isVerticalLogicLayout, getNonAbstractChildren, isLeftLayout, isRightLayout, isTopLayout, isBottomLayout, isHorizontalLayout, getCorrectStartEnd, ConnectingPosition, getAbstractLayout, GlobalLayout } from '@plait/layouts';
|
|
6
|
-
import { PlaitMarkEditor, MarkTypes, DEFAULT_FONT_SIZE, TEXT_DEFAULT_HEIGHT, buildText, getTextSize, TextManage, ExitOrigin, TextModule, getTextFromClipboard } from '@plait/text';
|
|
7
|
-
import { fromEvent, Subject } from 'rxjs';
|
|
8
|
-
import { RESIZE_HANDLE_DIAMETER, getRectangleResizeHandleRefs, isExpandHotkey, isTabHotkey, isEnterHotkey, isVirtualKey, isSpaceHotkey, MediaKeys, ResizeHandle, withResize, ActiveGenerator } from '@plait/common';
|
|
9
|
-
import { Node as Node$1, Path as Path$1 } from 'slate';
|
|
10
|
-
import { __awaiter } from 'tslib';
|
|
11
|
-
import { pointsOnBezierCurves } from 'points-on-curve';
|
|
12
|
-
import { take, filter } from 'rxjs/operators';
|
|
13
|
-
import * as i1 from '@angular/common';
|
|
14
|
-
import { CommonModule } from '@angular/common';
|
|
15
|
-
|
|
16
|
-
const ELEMENT_TO_NODE = new WeakMap();
|
|
17
|
-
|
|
18
|
-
const MindNode = {
|
|
19
|
-
get(root, path) {
|
|
20
|
-
let node = root;
|
|
21
|
-
for (let i = 0; i < path.length; i++) {
|
|
22
|
-
const p = path[i];
|
|
23
|
-
if (!node || !node.children || !node.children[p]) {
|
|
24
|
-
throw new Error(`Cannot find a descendant at path [${path}]`);
|
|
25
|
-
}
|
|
26
|
-
node = node.children[p];
|
|
27
|
-
}
|
|
28
|
-
return node;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
var LayoutDirection;
|
|
33
|
-
(function (LayoutDirection) {
|
|
34
|
-
LayoutDirection["top"] = "top";
|
|
35
|
-
LayoutDirection["right"] = "right";
|
|
36
|
-
LayoutDirection["bottom"] = "bottom";
|
|
37
|
-
LayoutDirection["left"] = "left";
|
|
38
|
-
})(LayoutDirection || (LayoutDirection = {}));
|
|
39
|
-
const LayoutDirectionsMap = {
|
|
40
|
-
[MindLayoutType.right]: [LayoutDirection.right],
|
|
41
|
-
[MindLayoutType.left]: [LayoutDirection.left],
|
|
42
|
-
[MindLayoutType.upward]: [LayoutDirection.top],
|
|
43
|
-
[MindLayoutType.downward]: [LayoutDirection.bottom],
|
|
44
|
-
[MindLayoutType.rightBottomIndented]: [LayoutDirection.right, LayoutDirection.bottom],
|
|
45
|
-
[MindLayoutType.rightTopIndented]: [LayoutDirection.right, LayoutDirection.top],
|
|
46
|
-
[MindLayoutType.leftBottomIndented]: [LayoutDirection.left, LayoutDirection.bottom],
|
|
47
|
-
[MindLayoutType.leftTopIndented]: [LayoutDirection.left, LayoutDirection.top]
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
var MindPointerType;
|
|
51
|
-
(function (MindPointerType) {
|
|
52
|
-
MindPointerType["mind"] = "mind";
|
|
53
|
-
})(MindPointerType || (MindPointerType = {}));
|
|
54
|
-
|
|
55
|
-
const DEFAULT_BRANCH_COLORS = [
|
|
56
|
-
'#A287E0',
|
|
57
|
-
'#6E80DB',
|
|
58
|
-
'#6DC4C4',
|
|
59
|
-
'#E0B75E',
|
|
60
|
-
'#B1C675',
|
|
61
|
-
'#77C386',
|
|
62
|
-
'#C18976',
|
|
63
|
-
'#E48484',
|
|
64
|
-
'#E582D4',
|
|
65
|
-
'#6AB1E4'
|
|
66
|
-
];
|
|
67
|
-
const COLORFUL_BRANCH_COLORS = [
|
|
68
|
-
'#F94239',
|
|
69
|
-
'#FF8612',
|
|
70
|
-
'#F3D222',
|
|
71
|
-
'#B3D431',
|
|
72
|
-
'#00BC7B',
|
|
73
|
-
'#06ADBF',
|
|
74
|
-
'#476BFF',
|
|
75
|
-
'#4E49BE',
|
|
76
|
-
'#8957E5',
|
|
77
|
-
'#FE5DA1'
|
|
78
|
-
];
|
|
79
|
-
const SOFT_BRANCH_COLORS = [
|
|
80
|
-
'#6D89C1',
|
|
81
|
-
'#F2BDC7',
|
|
82
|
-
'#B796D9',
|
|
83
|
-
'#5BA683',
|
|
84
|
-
'#B3D431 ',
|
|
85
|
-
'#F2DC6C',
|
|
86
|
-
'#F7C98D',
|
|
87
|
-
'#60B4D1',
|
|
88
|
-
'#838F9E',
|
|
89
|
-
'#C1A381'
|
|
90
|
-
];
|
|
91
|
-
const RETRO_BRANCH_COLORS = [
|
|
92
|
-
'#459476',
|
|
93
|
-
'#9A894F',
|
|
94
|
-
'#D48444',
|
|
95
|
-
'#E9C358 ',
|
|
96
|
-
'#4B9D9D',
|
|
97
|
-
'#C14C41',
|
|
98
|
-
'#827086 ',
|
|
99
|
-
'#60718D',
|
|
100
|
-
'#D38183',
|
|
101
|
-
'#9DC19D'
|
|
102
|
-
];
|
|
103
|
-
const DARK_BRANCH_COLORS = [
|
|
104
|
-
'#3DD1AE',
|
|
105
|
-
'#F6C659',
|
|
106
|
-
'#A9E072',
|
|
107
|
-
'#FF877B ',
|
|
108
|
-
'#F693E7',
|
|
109
|
-
'#5DCFFF',
|
|
110
|
-
'#868AF6',
|
|
111
|
-
'#4C6DC7',
|
|
112
|
-
'#D97C26',
|
|
113
|
-
'#268FAC'
|
|
114
|
-
];
|
|
115
|
-
const STARRY_BRANCH_COLORS = [
|
|
116
|
-
'#E46C57',
|
|
117
|
-
'#579360',
|
|
118
|
-
'#B98339',
|
|
119
|
-
'#3A62D1 ',
|
|
120
|
-
'#B883B7',
|
|
121
|
-
'#42ABE5',
|
|
122
|
-
'#2B9D8F',
|
|
123
|
-
'#A4705E',
|
|
124
|
-
'#265833',
|
|
125
|
-
'#787865'
|
|
126
|
-
];
|
|
127
|
-
|
|
128
|
-
const MindDefaultThemeColor = Object.assign(Object.assign({}, DefaultThemeColor), { branchColors: DEFAULT_BRANCH_COLORS, rootFill: '#f5f5f5', rootTextColor: '#333333' });
|
|
129
|
-
const MindColorfulThemeColor = Object.assign(Object.assign({}, ColorfulThemeColor), { branchColors: COLORFUL_BRANCH_COLORS, rootFill: '#333333', rootTextColor: '#FFFFFF' });
|
|
130
|
-
const MindSoftThemeColor = Object.assign(Object.assign({}, SoftThemeColor), { branchColors: SOFT_BRANCH_COLORS, rootFill: '#FFFFFF', rootTextColor: '#333333' });
|
|
131
|
-
const MindRetroThemeColor = Object.assign(Object.assign({}, RetroThemeColor), { branchColors: RETRO_BRANCH_COLORS, rootFill: '#153D5D', rootTextColor: '#FFFFFF' });
|
|
132
|
-
const MindDarkThemeColor = Object.assign(Object.assign({}, DarkThemeColor), { branchColors: DARK_BRANCH_COLORS, rootFill: '#FFFFFF', rootTextColor: '#333333' });
|
|
133
|
-
const MindStarryThemeColor = Object.assign(Object.assign({}, StarryThemeColor), { branchColors: STARRY_BRANCH_COLORS, rootFill: '#FFFFFF', rootTextColor: '#333333' });
|
|
134
|
-
const MindThemeColors = [
|
|
135
|
-
MindDefaultThemeColor,
|
|
136
|
-
MindColorfulThemeColor,
|
|
137
|
-
MindSoftThemeColor,
|
|
138
|
-
MindRetroThemeColor,
|
|
139
|
-
MindDarkThemeColor,
|
|
140
|
-
MindStarryThemeColor
|
|
141
|
-
];
|
|
142
|
-
const MindThemeColor = {
|
|
143
|
-
isMindThemeColor(value) {
|
|
144
|
-
if (value.branchColors && value.rootFill && value.rootTextColor) {
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const WithMindPluginKey = 'plait-mind-plugin-key';
|
|
154
|
-
const BASE = 4;
|
|
155
|
-
const PRIMARY_COLOR = '#6698FF';
|
|
156
|
-
const TRANSPARENT = 'transparent';
|
|
157
|
-
const GRAY_COLOR = '#AAAAAA';
|
|
158
|
-
const STROKE_WIDTH = 3;
|
|
159
|
-
const BRANCH_WIDTH = 3;
|
|
160
|
-
const EXTEND_OFFSET = 8;
|
|
161
|
-
const EXTEND_DIAMETER = 16;
|
|
162
|
-
const QUICK_INSERT_CIRCLE_OFFSET = 9;
|
|
163
|
-
const QUICK_INSERT_CIRCLE_COLOR = '#6698FF';
|
|
164
|
-
const QUICK_INSERT_INNER_CROSS_COLOR = 'white';
|
|
165
|
-
|
|
166
|
-
function getEmojisWidthHeight(board, element) {
|
|
167
|
-
const options = board.getPluginOptions(WithMindPluginKey);
|
|
168
|
-
const count = element.data.emojis.length;
|
|
169
|
-
const fontSize = getEmojiFontSize(element);
|
|
170
|
-
return {
|
|
171
|
-
width: fontSize * count + count * 2 * options.emojiPadding + (count - 1) * options.spaceBetweenEmojis,
|
|
172
|
-
height: element.height
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
function getEmojiFontSize(element) {
|
|
176
|
-
if (PlaitMind.isMind(element)) {
|
|
177
|
-
return 18 + 2;
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
return 14 + 2;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const TOPIC_COLOR = '#333';
|
|
185
|
-
const TOPIC_FONT_SIZE = 14;
|
|
186
|
-
const ROOT_TOPIC_FONT_SIZE = 18;
|
|
187
|
-
const ROOT_TOPIC_HEIGHT = 25;
|
|
188
|
-
const TOPIC_DEFAULT_MAX_WORD_COUNT = 34;
|
|
189
|
-
const DEFAULT_FONT_FAMILY = 'PingFangSC-Regular, "PingFang SC"';
|
|
190
|
-
const BRANCH_FONT_FAMILY = 'PingFangSC-Medium, "PingFang SC"';
|
|
191
|
-
|
|
192
|
-
const NodeDefaultSpace = {
|
|
193
|
-
horizontal: {
|
|
194
|
-
nodeAndText: BASE * 2.5,
|
|
195
|
-
emojiAndText: BASE * 1.5
|
|
196
|
-
},
|
|
197
|
-
vertical: {
|
|
198
|
-
nodeAndText: BASE,
|
|
199
|
-
nodeAndImage: BASE,
|
|
200
|
-
imageAndText: BASE * 1.5
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
const RootDefaultSpace = {
|
|
204
|
-
horizontal: {
|
|
205
|
-
nodeAndText: BASE * 4,
|
|
206
|
-
emojiAndText: BASE * 2
|
|
207
|
-
},
|
|
208
|
-
vertical: {
|
|
209
|
-
nodeAndText: BASE * 2
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
const getHorizontalSpaceBetweenNodeAndText = (board, element) => {
|
|
213
|
-
const isMind = PlaitMind.isMind(element);
|
|
214
|
-
const nodeAndText = isMind ? RootDefaultSpace.horizontal.nodeAndText : NodeDefaultSpace.horizontal.nodeAndText;
|
|
215
|
-
const strokeWidth = getStrokeWidthByElement(board, element);
|
|
216
|
-
return nodeAndText + strokeWidth / 2;
|
|
217
|
-
};
|
|
218
|
-
const getVerticalSpaceBetweenNodeAndText = (board, element) => {
|
|
219
|
-
const isMind = PlaitMind.isMind(element);
|
|
220
|
-
const strokeWidth = getStrokeWidthByElement(board, element);
|
|
221
|
-
const nodeAndText = isMind ? RootDefaultSpace.vertical.nodeAndText : NodeDefaultSpace.vertical.nodeAndText;
|
|
222
|
-
return nodeAndText + strokeWidth / 2;
|
|
223
|
-
};
|
|
224
|
-
const getSpaceEmojiAndText = (element) => {
|
|
225
|
-
const isMind = PlaitMind.isMind(element);
|
|
226
|
-
const emojiAndText = isMind ? RootDefaultSpace.horizontal.emojiAndText : NodeDefaultSpace.horizontal.emojiAndText;
|
|
227
|
-
return emojiAndText;
|
|
228
|
-
};
|
|
229
|
-
const NodeSpace = {
|
|
230
|
-
getNodeWidth(board, element) {
|
|
231
|
-
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(board, element);
|
|
232
|
-
if (MindElement.hasEmojis(element)) {
|
|
233
|
-
return (NodeSpace.getEmojiLeftSpace(board, element) +
|
|
234
|
-
getEmojisWidthHeight(board, element).width +
|
|
235
|
-
getSpaceEmojiAndText(element) +
|
|
236
|
-
NodeSpace.getNodeDynamicWidth(board, element) +
|
|
237
|
-
nodeAndText);
|
|
238
|
-
}
|
|
239
|
-
return nodeAndText + NodeSpace.getNodeDynamicWidth(board, element) + nodeAndText;
|
|
240
|
-
},
|
|
241
|
-
getNodeHeight(board, element) {
|
|
242
|
-
const nodeAndText = getVerticalSpaceBetweenNodeAndText(board, element);
|
|
243
|
-
if (MindElement.hasImage(element)) {
|
|
244
|
-
return NodeSpace.getTextTopSpace(board, element) + element.height + nodeAndText;
|
|
245
|
-
}
|
|
246
|
-
return nodeAndText + element.height + nodeAndText;
|
|
247
|
-
},
|
|
248
|
-
getNodeDynamicWidth(board, element) {
|
|
249
|
-
var _a;
|
|
250
|
-
const width = element.manualWidth || element.width;
|
|
251
|
-
const imageWidth = MindElement.hasImage(element) ? (_a = element.data.image) === null || _a === void 0 ? void 0 : _a.width : 0;
|
|
252
|
-
return Math.max(width, imageWidth);
|
|
253
|
-
},
|
|
254
|
-
/**
|
|
255
|
-
* use this when upload image first or resize image
|
|
256
|
-
* @param board
|
|
257
|
-
* @param element
|
|
258
|
-
* @param imageWidth
|
|
259
|
-
* @returns
|
|
260
|
-
*/
|
|
261
|
-
getNodeNewDynamicWidth(board, element, imageWidth) {
|
|
262
|
-
const width = element.manualWidth || element.width;
|
|
263
|
-
return Math.max(width, imageWidth);
|
|
264
|
-
},
|
|
265
|
-
getNodeResizableMinWidth(board, element) {
|
|
266
|
-
const minTopicWidth = NodeSpace.getNodeTopicMinWidth(board, element);
|
|
267
|
-
if (MindElement.hasImage(element) && element.data.image.width > minTopicWidth) {
|
|
268
|
-
return element.data.image.width;
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
return minTopicWidth;
|
|
272
|
-
}
|
|
273
|
-
},
|
|
274
|
-
getNodeTopicMinWidth(board, element, isRoot = false) {
|
|
275
|
-
const defaultFontSize = getNodeDefaultFontSize(isRoot);
|
|
276
|
-
const editor = MindElement.getTextEditor(element);
|
|
277
|
-
const marks = PlaitMarkEditor.getMarks(editor);
|
|
278
|
-
const fontSize = marks[MarkTypes.fontSize] || defaultFontSize;
|
|
279
|
-
return fontSize;
|
|
280
|
-
},
|
|
281
|
-
getTextLeftSpace(board, element) {
|
|
282
|
-
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(board, element);
|
|
283
|
-
if (MindElement.hasEmojis(element)) {
|
|
284
|
-
return NodeSpace.getEmojiLeftSpace(board, element) + getEmojisWidthHeight(board, element).width + getSpaceEmojiAndText(element);
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
return nodeAndText;
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
|
-
getTextTopSpace(board, element) {
|
|
291
|
-
const nodeAndText = getVerticalSpaceBetweenNodeAndText(board, element);
|
|
292
|
-
if (MindElement.hasImage(element)) {
|
|
293
|
-
return NodeSpace.getImageTopSpace(board, element) + element.data.image.height + NodeDefaultSpace.vertical.imageAndText;
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
return nodeAndText;
|
|
297
|
-
}
|
|
298
|
-
},
|
|
299
|
-
getImageTopSpace(board, element) {
|
|
300
|
-
const strokeWidth = getStrokeWidthByElement(board, element);
|
|
301
|
-
return strokeWidth / 2 + NodeDefaultSpace.vertical.nodeAndImage;
|
|
302
|
-
},
|
|
303
|
-
getEmojiLeftSpace(board, element) {
|
|
304
|
-
const options = board.getPluginOptions(WithMindPluginKey);
|
|
305
|
-
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(board, element);
|
|
306
|
-
const strokeWidth = getStrokeWidthByElement(board, element);
|
|
307
|
-
return strokeWidth / 2 + nodeAndText - options.emojiPadding;
|
|
308
|
-
},
|
|
309
|
-
getEmojiTopSpace(board, element) {
|
|
310
|
-
const nodeAndText = getVerticalSpaceBetweenNodeAndText(board, element);
|
|
311
|
-
return nodeAndText;
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
const getFontSizeBySlateElement = (text) => {
|
|
315
|
-
const defaultFontSize = DEFAULT_FONT_SIZE;
|
|
316
|
-
if (typeof text === 'string') {
|
|
317
|
-
return defaultFontSize;
|
|
318
|
-
}
|
|
319
|
-
const marks = PlaitMarkEditor.getMarksByElement(text);
|
|
320
|
-
const fontSize = marks[MarkTypes.fontSize] || defaultFontSize;
|
|
321
|
-
return fontSize;
|
|
322
|
-
};
|
|
323
|
-
const getNodeDefaultFontSize = (isRoot = false) => {
|
|
324
|
-
const defaultFontSize = isRoot ? ROOT_TOPIC_FONT_SIZE : DEFAULT_FONT_SIZE;
|
|
325
|
-
return defaultFontSize;
|
|
326
|
-
};
|
|
327
|
-
|
|
328
|
-
function getEmojiRectangle(board, element) {
|
|
329
|
-
let { x, y } = getRectangleByNode(MindElement.getNode(element));
|
|
330
|
-
x = x + NodeSpace.getEmojiLeftSpace(board, element);
|
|
331
|
-
const { width, height } = getEmojisWidthHeight(board, element);
|
|
332
|
-
return {
|
|
333
|
-
x,
|
|
334
|
-
y,
|
|
335
|
-
width,
|
|
336
|
-
height
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
|
-
function getEmojiForeignRectangle(board, element) {
|
|
340
|
-
let { x, y } = getRectangleByNode(MindElement.getNode(element));
|
|
341
|
-
x = x + NodeSpace.getEmojiLeftSpace(board, element);
|
|
342
|
-
const { width } = getEmojisWidthHeight(board, element);
|
|
343
|
-
return {
|
|
344
|
-
x,
|
|
345
|
-
y,
|
|
346
|
-
width,
|
|
347
|
-
height: NodeSpace.getNodeHeight(board, element)
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
const isHitEmojis = (board, element, point) => {
|
|
351
|
-
return RectangleClient.isHit(RectangleClient.toRectangleClient([point, point]), getEmojiRectangle(board, element));
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
function getTopicRectangleByNode(board, node) {
|
|
355
|
-
let nodeRectangle = getRectangleByNode(node);
|
|
356
|
-
const result = getTopicRectangleByElement(board, nodeRectangle, node.origin);
|
|
357
|
-
// add buffer width to avoid unexpected text breaks in different scene
|
|
358
|
-
result.width = result.width + 4;
|
|
359
|
-
return result;
|
|
360
|
-
}
|
|
361
|
-
function getTopicRectangleByElement(board, nodeRectangle, element) {
|
|
362
|
-
const x = nodeRectangle.x + NodeSpace.getTextLeftSpace(board, element);
|
|
363
|
-
const y = nodeRectangle.y + NodeSpace.getTextTopSpace(board, element);
|
|
364
|
-
const width = NodeSpace.getNodeDynamicWidth(board, element);
|
|
365
|
-
const height = Math.ceil(element.height);
|
|
366
|
-
return { height, width, x, y };
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
function getImageForeignRectangle(board, element) {
|
|
370
|
-
let { x, y } = getRectangleByNode(MindElement.getNode(element));
|
|
371
|
-
const elementWidth = element.manualWidth || element.width;
|
|
372
|
-
x =
|
|
373
|
-
elementWidth > element.data.image.width
|
|
374
|
-
? x + NodeSpace.getTextLeftSpace(board, element) + (elementWidth - element.data.image.width) / 2
|
|
375
|
-
: x + NodeSpace.getTextLeftSpace(board, element);
|
|
376
|
-
y = NodeSpace.getImageTopSpace(board, element) + y;
|
|
377
|
-
const { width, height } = element.data.image;
|
|
378
|
-
const rectangle = {
|
|
379
|
-
x,
|
|
380
|
-
y,
|
|
381
|
-
width,
|
|
382
|
-
height
|
|
383
|
-
};
|
|
384
|
-
return rectangle;
|
|
385
|
-
}
|
|
386
|
-
const isHitImage = (board, element, range) => {
|
|
387
|
-
const imageRectangle = getImageForeignRectangle(board, element);
|
|
388
|
-
const imageOutlineRectangle = RectangleClient.getOutlineRectangle(imageRectangle, -RESIZE_HANDLE_DIAMETER / 2);
|
|
389
|
-
return RectangleClient.isHit(RectangleClient.toRectangleClient([range.anchor, range.focus]), imageOutlineRectangle);
|
|
390
|
-
};
|
|
391
|
-
const getHitImageResizeHandleDirection = (board, element, point) => {
|
|
392
|
-
const imageRectangle = getImageForeignRectangle(board, element);
|
|
393
|
-
const resizeHandleRefs = getRectangleResizeHandleRefs(imageRectangle, RESIZE_HANDLE_DIAMETER);
|
|
394
|
-
const result = resizeHandleRefs.find(resizeHandleRef => {
|
|
395
|
-
return RectangleClient.isHit(RectangleClient.toRectangleClient([point, point]), resizeHandleRef.rectangle);
|
|
396
|
-
});
|
|
397
|
-
return result;
|
|
398
|
-
};
|
|
399
|
-
|
|
400
|
-
function editTopic(element) {
|
|
401
|
-
const component = PlaitElement.getComponent(element);
|
|
402
|
-
component === null || component === void 0 ? void 0 : component.editTopic();
|
|
403
|
-
}
|
|
404
|
-
const temporaryDisableSelection = (board) => {
|
|
405
|
-
const currentOptions = board.getPluginOptions(PlaitPluginKey.withSelection);
|
|
406
|
-
board.setPluginOptions(PlaitPluginKey.withSelection, {
|
|
407
|
-
isDisabledSelect: true
|
|
408
|
-
});
|
|
409
|
-
setTimeout(() => {
|
|
410
|
-
board.setPluginOptions(PlaitPluginKey.withSelection, Object.assign({}, currentOptions));
|
|
411
|
-
}, 0);
|
|
412
|
-
};
|
|
413
|
-
const getSelectedMindElements = (board) => {
|
|
414
|
-
const selectedElements = getSelectedElements(board).filter(value => MindElement.isMindElement(board, value));
|
|
415
|
-
return selectedElements;
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
const createEmptyMind = (point) => {
|
|
419
|
-
const element = createMindElement('思维导图', 72, ROOT_TOPIC_HEIGHT, { layout: MindLayoutType.right });
|
|
420
|
-
element.isRoot = true;
|
|
421
|
-
element.points = [point];
|
|
422
|
-
element.type = 'mindmap';
|
|
423
|
-
return element;
|
|
424
|
-
};
|
|
425
|
-
const createDefaultMind = (point, rightNodeCount, layout) => {
|
|
426
|
-
const root = createMindElement('思维导图', 72, ROOT_TOPIC_HEIGHT, { layout });
|
|
427
|
-
root.rightNodeCount = rightNodeCount;
|
|
428
|
-
root.isRoot = true;
|
|
429
|
-
root.type = 'mindmap';
|
|
430
|
-
root.points = [point];
|
|
431
|
-
const children = [1, 1, 1].map(() => {
|
|
432
|
-
return createMindElement('新建节点', 56, TEXT_DEFAULT_HEIGHT, {});
|
|
433
|
-
});
|
|
434
|
-
root.children = children;
|
|
435
|
-
return root;
|
|
436
|
-
};
|
|
437
|
-
const createMindElement = (text, width, height, options) => {
|
|
438
|
-
const newElement = {
|
|
439
|
-
id: idCreator(),
|
|
440
|
-
data: {
|
|
441
|
-
topic: buildText(text)
|
|
442
|
-
},
|
|
443
|
-
children: [],
|
|
444
|
-
width,
|
|
445
|
-
height
|
|
446
|
-
};
|
|
447
|
-
let key;
|
|
448
|
-
for (key in options) {
|
|
449
|
-
if (!isNullOrUndefined(options[key])) {
|
|
450
|
-
newElement[key] = options[key];
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
return newElement;
|
|
454
|
-
};
|
|
455
|
-
const INHERIT_ATTRIBUTE_KEYS = [
|
|
456
|
-
'fill',
|
|
457
|
-
'strokeColor',
|
|
458
|
-
'strokeWidth',
|
|
459
|
-
'shape',
|
|
460
|
-
'layout',
|
|
461
|
-
'branchColor',
|
|
462
|
-
'branchWidth',
|
|
463
|
-
'branchShape'
|
|
464
|
-
];
|
|
465
|
-
|
|
466
|
-
const getChildrenCount = (element) => {
|
|
467
|
-
const count = element.children.reduce((p, c) => {
|
|
468
|
-
return p + getChildrenCount(c);
|
|
469
|
-
}, 0);
|
|
470
|
-
return count + element.children.length;
|
|
471
|
-
};
|
|
472
|
-
const isChildElement = (origin, child) => {
|
|
473
|
-
let parent = MindElement.findParent(child);
|
|
474
|
-
while (parent) {
|
|
475
|
-
if (parent === origin) {
|
|
476
|
-
return true;
|
|
477
|
-
}
|
|
478
|
-
parent = MindElement.findParent(parent);
|
|
479
|
-
}
|
|
480
|
-
return false;
|
|
481
|
-
};
|
|
482
|
-
const getFirstLevelElement = (elements) => {
|
|
483
|
-
let result = [];
|
|
484
|
-
elements.forEach(element => {
|
|
485
|
-
const isChild = elements.some(node => {
|
|
486
|
-
return isChildElement(node, element);
|
|
487
|
-
});
|
|
488
|
-
if (!isChild) {
|
|
489
|
-
result.push(element);
|
|
490
|
-
}
|
|
491
|
-
});
|
|
492
|
-
return result;
|
|
493
|
-
};
|
|
494
|
-
const isChildRight = (node, child) => {
|
|
495
|
-
return node.x < child.x;
|
|
496
|
-
};
|
|
497
|
-
const isChildUp = (node, child) => {
|
|
498
|
-
return node.y > child.y;
|
|
499
|
-
};
|
|
500
|
-
const copyNewNode = (node) => {
|
|
501
|
-
const newNode = Object.assign({}, node);
|
|
502
|
-
newNode.id = idCreator();
|
|
503
|
-
newNode.children = [];
|
|
504
|
-
for (const childNode of node.children) {
|
|
505
|
-
newNode.children.push(copyNewNode(childNode));
|
|
506
|
-
}
|
|
507
|
-
return newNode;
|
|
508
|
-
};
|
|
509
|
-
const extractNodesText = (node) => {
|
|
510
|
-
let str = '';
|
|
511
|
-
if (node) {
|
|
512
|
-
str += Node$1.string(node.data.topic) + ' ';
|
|
513
|
-
for (const childNode of node.children) {
|
|
514
|
-
str += extractNodesText(childNode);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
return str;
|
|
518
|
-
};
|
|
519
|
-
const insertMindElement = (board, inheritNode, path) => {
|
|
520
|
-
const newNode = {};
|
|
521
|
-
if (!inheritNode.isRoot) {
|
|
522
|
-
INHERIT_ATTRIBUTE_KEYS.forEach(attr => {
|
|
523
|
-
newNode[attr] = inheritNode[attr];
|
|
524
|
-
});
|
|
525
|
-
delete newNode.layout;
|
|
526
|
-
}
|
|
527
|
-
const newElement = createMindElement('', getNodeDefaultFontSize(), TEXT_DEFAULT_HEIGHT, newNode);
|
|
528
|
-
Transforms.insertNode(board, newElement, path);
|
|
529
|
-
clearSelectedElement(board);
|
|
530
|
-
addSelectedElement(board, newElement);
|
|
531
|
-
setTimeout(() => {
|
|
532
|
-
editTopic(newElement);
|
|
533
|
-
});
|
|
534
|
-
};
|
|
535
|
-
const findLastChild = (child) => {
|
|
536
|
-
let result = child;
|
|
537
|
-
while (result.children.length !== 0) {
|
|
538
|
-
result = result.children[result.children.length - 1];
|
|
539
|
-
}
|
|
540
|
-
return result;
|
|
541
|
-
};
|
|
542
|
-
const divideElementByParent = (elements) => {
|
|
543
|
-
const abstractIncludedGroups = [];
|
|
544
|
-
const parentElements = [];
|
|
545
|
-
for (let i = 0; i < elements.length; i++) {
|
|
546
|
-
const parent = MindElement.getParent(elements[i]);
|
|
547
|
-
const parentIndex = parentElements.indexOf(parent);
|
|
548
|
-
if (parentIndex === -1) {
|
|
549
|
-
parentElements.push(parent);
|
|
550
|
-
abstractIncludedGroups.push([elements[i]]);
|
|
551
|
-
}
|
|
552
|
-
else {
|
|
553
|
-
abstractIncludedGroups[parentIndex].push(elements[i]);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
return { parentElements, abstractIncludedGroups };
|
|
557
|
-
};
|
|
558
|
-
|
|
559
|
-
const getBranchDirectionsByLayouts = (branchLayouts) => {
|
|
560
|
-
const branchDirections = [];
|
|
561
|
-
branchLayouts.forEach(l => {
|
|
562
|
-
const directions = LayoutDirectionsMap[l];
|
|
563
|
-
directions.forEach(d => {
|
|
564
|
-
if (!branchDirections.includes(d) && !branchDirections.includes(getLayoutReverseDirection(d))) {
|
|
565
|
-
branchDirections.push(d);
|
|
566
|
-
}
|
|
567
|
-
});
|
|
568
|
-
});
|
|
569
|
-
return branchDirections;
|
|
570
|
-
};
|
|
571
|
-
const isCorrectLayout = (root, layout) => {
|
|
572
|
-
const rootLayout = root.layout || getDefaultLayout();
|
|
573
|
-
return !getInCorrectLayoutDirection(rootLayout, layout);
|
|
574
|
-
};
|
|
575
|
-
const isMixedLayout = (parentLayout, layout) => {
|
|
576
|
-
return (!isIndentedLayout(parentLayout) && isIndentedLayout(layout)) || (isIndentedLayout(parentLayout) && !isIndentedLayout(layout));
|
|
577
|
-
};
|
|
578
|
-
const getInCorrectLayoutDirection = (rootLayout, layout) => {
|
|
579
|
-
const directions = LayoutDirectionsMap[rootLayout];
|
|
580
|
-
const subLayoutDirections = LayoutDirectionsMap[layout];
|
|
581
|
-
if (!subLayoutDirections) {
|
|
582
|
-
throw new Error(`unexpected layout: ${layout} on correct layout`);
|
|
583
|
-
}
|
|
584
|
-
return subLayoutDirections.find(d => directions.includes(getLayoutReverseDirection(d)));
|
|
585
|
-
};
|
|
586
|
-
const correctLayoutByDirection = (layout, direction) => {
|
|
587
|
-
const isHorizontal = direction === LayoutDirection.left || direction === LayoutDirection.right ? true : false;
|
|
588
|
-
let inverseDirectionLayout = MindLayoutType.standard;
|
|
589
|
-
switch (layout) {
|
|
590
|
-
case MindLayoutType.left:
|
|
591
|
-
inverseDirectionLayout = MindLayoutType.right;
|
|
592
|
-
break;
|
|
593
|
-
case MindLayoutType.right:
|
|
594
|
-
inverseDirectionLayout = MindLayoutType.left;
|
|
595
|
-
break;
|
|
596
|
-
case MindLayoutType.downward:
|
|
597
|
-
inverseDirectionLayout = MindLayoutType.upward;
|
|
598
|
-
break;
|
|
599
|
-
case MindLayoutType.upward:
|
|
600
|
-
inverseDirectionLayout = MindLayoutType.downward;
|
|
601
|
-
break;
|
|
602
|
-
case MindLayoutType.rightBottomIndented:
|
|
603
|
-
inverseDirectionLayout = isHorizontal ? MindLayoutType.leftBottomIndented : MindLayoutType.rightTopIndented;
|
|
604
|
-
break;
|
|
605
|
-
case MindLayoutType.leftBottomIndented:
|
|
606
|
-
inverseDirectionLayout = isHorizontal ? MindLayoutType.rightBottomIndented : MindLayoutType.leftTopIndented;
|
|
607
|
-
break;
|
|
608
|
-
case MindLayoutType.rightTopIndented:
|
|
609
|
-
inverseDirectionLayout = isHorizontal ? MindLayoutType.leftTopIndented : MindLayoutType.rightBottomIndented;
|
|
610
|
-
break;
|
|
611
|
-
case MindLayoutType.leftTopIndented:
|
|
612
|
-
inverseDirectionLayout = isHorizontal ? MindLayoutType.rightTopIndented : MindLayoutType.leftBottomIndented;
|
|
613
|
-
break;
|
|
614
|
-
}
|
|
615
|
-
return inverseDirectionLayout;
|
|
616
|
-
};
|
|
617
|
-
const getLayoutDirection$1 = (root) => {
|
|
618
|
-
const layout = root.layout || getDefaultLayout();
|
|
619
|
-
return LayoutDirectionsMap[layout];
|
|
620
|
-
};
|
|
621
|
-
const getDefaultLayout = () => {
|
|
622
|
-
return MindLayoutType.standard;
|
|
623
|
-
};
|
|
624
|
-
const getAvailableSubLayoutsByLayoutDirections = (directions) => {
|
|
625
|
-
const result = [];
|
|
626
|
-
const reverseDirections = directions.map(getLayoutReverseDirection);
|
|
627
|
-
for (const key in MindLayoutType) {
|
|
628
|
-
const layout = MindLayoutType[key];
|
|
629
|
-
const layoutDirections = LayoutDirectionsMap[layout];
|
|
630
|
-
if (layoutDirections) {
|
|
631
|
-
const hasSameDirection = layoutDirections.some(d => directions.includes(d));
|
|
632
|
-
const hasReverseDirection = layoutDirections.some(r => reverseDirections.includes(r));
|
|
633
|
-
if (hasSameDirection && !hasReverseDirection) {
|
|
634
|
-
result.push(layout);
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
return result;
|
|
639
|
-
};
|
|
640
|
-
const getLayoutReverseDirection = (layoutDirection) => {
|
|
641
|
-
let reverseDirection = LayoutDirection.right;
|
|
642
|
-
switch (layoutDirection) {
|
|
643
|
-
case LayoutDirection.top:
|
|
644
|
-
reverseDirection = LayoutDirection.bottom;
|
|
645
|
-
break;
|
|
646
|
-
case LayoutDirection.bottom:
|
|
647
|
-
reverseDirection = LayoutDirection.top;
|
|
648
|
-
break;
|
|
649
|
-
case LayoutDirection.right:
|
|
650
|
-
reverseDirection = LayoutDirection.left;
|
|
651
|
-
break;
|
|
652
|
-
case LayoutDirection.left:
|
|
653
|
-
reverseDirection = LayoutDirection.right;
|
|
654
|
-
break;
|
|
655
|
-
}
|
|
656
|
-
return reverseDirection;
|
|
657
|
-
};
|
|
658
|
-
const getRootLayout = (root) => {
|
|
659
|
-
return root.layout || getDefaultLayout();
|
|
660
|
-
};
|
|
661
|
-
|
|
662
|
-
const adjustRootToNode = (board, node) => {
|
|
663
|
-
const newNode = Object.assign({}, node);
|
|
664
|
-
delete newNode.isRoot;
|
|
665
|
-
delete newNode.rightNodeCount;
|
|
666
|
-
delete newNode.type;
|
|
667
|
-
if (newNode.layout === MindLayoutType.standard) {
|
|
668
|
-
delete newNode.layout;
|
|
669
|
-
}
|
|
670
|
-
return newNode;
|
|
671
|
-
};
|
|
672
|
-
const adjustAbstractToNode = (node) => {
|
|
673
|
-
const newNode = Object.assign({}, node);
|
|
674
|
-
delete newNode.start;
|
|
675
|
-
delete newNode.end;
|
|
676
|
-
return newNode;
|
|
677
|
-
};
|
|
678
|
-
const adjustNodeToRoot = (board, node) => {
|
|
679
|
-
var _a;
|
|
680
|
-
const newElement = Object.assign({}, node);
|
|
681
|
-
if (!Node$1.string(newElement.data.topic)) {
|
|
682
|
-
newElement.data.topic = { children: [{ text: '思维导图' }] };
|
|
683
|
-
}
|
|
684
|
-
newElement === null || newElement === void 0 ? true : delete newElement.strokeColor;
|
|
685
|
-
newElement === null || newElement === void 0 ? true : delete newElement.fill;
|
|
686
|
-
newElement === null || newElement === void 0 ? true : delete newElement.shape;
|
|
687
|
-
newElement === null || newElement === void 0 ? true : delete newElement.strokeWidth;
|
|
688
|
-
newElement === null || newElement === void 0 ? true : delete newElement.isCollapsed;
|
|
689
|
-
const { width, height } = getTextSize(board, newElement.data.topic, TOPIC_DEFAULT_MAX_WORD_COUNT, {
|
|
690
|
-
fontSize: ROOT_TOPIC_FONT_SIZE,
|
|
691
|
-
fontFamily: BRANCH_FONT_FAMILY,
|
|
692
|
-
width: node.manualWidth ? node.manualWidth : undefined
|
|
693
|
-
});
|
|
694
|
-
newElement.width = Math.max(width, getNodeDefaultFontSize(true));
|
|
695
|
-
newElement.height = height;
|
|
696
|
-
return Object.assign(Object.assign({}, newElement), { layout: (_a = newElement.layout) !== null && _a !== void 0 ? _a : MindLayoutType.right, isRoot: true, type: 'mindmap' });
|
|
697
|
-
};
|
|
698
|
-
|
|
699
|
-
const DefaultAbstractNodeStyle = {
|
|
700
|
-
branch: { color: GRAY_COLOR, width: 2 },
|
|
701
|
-
shape: {
|
|
702
|
-
strokeColor: GRAY_COLOR,
|
|
703
|
-
strokeWidth: 2
|
|
704
|
-
}
|
|
705
|
-
};
|
|
706
|
-
const DefaultNodeStyle = {
|
|
707
|
-
branch: {
|
|
708
|
-
width: 3
|
|
709
|
-
},
|
|
710
|
-
shape: {
|
|
711
|
-
rectangleRadius: 4,
|
|
712
|
-
strokeWidth: 3,
|
|
713
|
-
fill: 'none'
|
|
714
|
-
}
|
|
715
|
-
};
|
|
716
|
-
|
|
717
|
-
const setAbstractsByRefs = (board, abstractRefs) => {
|
|
718
|
-
abstractRefs.forEach((newProperty, element) => {
|
|
719
|
-
const start = element.start + newProperty.start;
|
|
720
|
-
const end = element.end + newProperty.end;
|
|
721
|
-
const path = PlaitBoard.findPath(board, element);
|
|
722
|
-
if (start > end) {
|
|
723
|
-
Transforms.removeNode(board, path);
|
|
724
|
-
}
|
|
725
|
-
else {
|
|
726
|
-
Transforms.setNode(board, { start, end }, path);
|
|
727
|
-
}
|
|
728
|
-
});
|
|
729
|
-
};
|
|
730
|
-
const setAbstractByStandardLayout = (board, element) => {
|
|
731
|
-
const rightNodeCount = element.rightNodeCount;
|
|
732
|
-
const abstract = element.children.find(child => {
|
|
733
|
-
return AbstractNode.isAbstract(child) && child.end >= rightNodeCount && child.start < rightNodeCount;
|
|
734
|
-
});
|
|
735
|
-
if (abstract) {
|
|
736
|
-
const path = PlaitBoard.findPath(board, abstract);
|
|
737
|
-
Transforms.setNode(board, { end: rightNodeCount - 1 }, path);
|
|
738
|
-
}
|
|
739
|
-
};
|
|
740
|
-
const insertAbstract = (board, elements) => {
|
|
741
|
-
let elementGroup = getFirstLevelElement(elements);
|
|
742
|
-
const { parentElements, abstractIncludedGroups } = divideElementByParent(elementGroup);
|
|
743
|
-
abstractIncludedGroups.forEach((group, index) => {
|
|
744
|
-
const groupParent = parentElements[index];
|
|
745
|
-
setAbstractByElements(board, groupParent, group);
|
|
746
|
-
});
|
|
747
|
-
};
|
|
748
|
-
const setAbstractByElements = (board, groupParent, group) => {
|
|
749
|
-
const indexArray = group.map(child => groupParent.children.indexOf(child)).sort((a, b) => a - b);
|
|
750
|
-
const rightNodeCount = groupParent === null || groupParent === void 0 ? void 0 : groupParent.rightNodeCount;
|
|
751
|
-
const start = indexArray[0], end = indexArray[indexArray.length - 1];
|
|
752
|
-
if (isStandardLayout(MindQueries.getLayoutByElement(groupParent)) &&
|
|
753
|
-
rightNodeCount &&
|
|
754
|
-
start < rightNodeCount &&
|
|
755
|
-
end >= rightNodeCount) {
|
|
756
|
-
const childrenLength = groupParent.children.length;
|
|
757
|
-
const path = [...PlaitBoard.findPath(board, groupParent), childrenLength];
|
|
758
|
-
const leftChildren = indexArray.filter(index => index >= rightNodeCount);
|
|
759
|
-
const rightChildren = indexArray.filter(index => index < rightNodeCount);
|
|
760
|
-
insertAbstractNode(board, path, rightChildren[0], rightChildren[rightChildren.length - 1]);
|
|
761
|
-
insertAbstractNode(board, Path.next(path), leftChildren[0], leftChildren[leftChildren.length - 1]);
|
|
762
|
-
}
|
|
763
|
-
else {
|
|
764
|
-
const path = [...PlaitBoard.findPath(board, groupParent), groupParent.children.length];
|
|
765
|
-
insertAbstractNode(board, path, start, end);
|
|
766
|
-
}
|
|
767
|
-
};
|
|
768
|
-
const insertAbstractNode = (board, path, start, end) => {
|
|
769
|
-
const mindElement = createMindElement('概要', 28, 20, {
|
|
770
|
-
strokeWidth: DefaultAbstractNodeStyle.branch.width,
|
|
771
|
-
branchWidth: DefaultAbstractNodeStyle.branch.width
|
|
772
|
-
});
|
|
773
|
-
mindElement.start = start;
|
|
774
|
-
mindElement.end = end;
|
|
775
|
-
Transforms.insertNode(board, mindElement, path);
|
|
776
|
-
clearSelectedElement(board);
|
|
777
|
-
addSelectedElement(board, mindElement);
|
|
778
|
-
};
|
|
779
|
-
|
|
780
|
-
const setLayout = (board, layout, path) => {
|
|
781
|
-
correctLogicLayoutNode(board, layout, path);
|
|
782
|
-
const element = PlaitNode.get(board, path);
|
|
783
|
-
if (PlaitMind.isMind(element) && isStandardLayout(layout)) {
|
|
784
|
-
MindTransforms.setAbstractByStandardLayout(board, element);
|
|
785
|
-
}
|
|
786
|
-
Transforms.setNode(board, { layout }, path);
|
|
787
|
-
};
|
|
788
|
-
const correctLogicLayoutNode = (board, layout, path) => {
|
|
789
|
-
var _a;
|
|
790
|
-
const node = PlaitNode.get(board, path);
|
|
791
|
-
if (node && layout) {
|
|
792
|
-
(_a = node.children) === null || _a === void 0 ? void 0 : _a.forEach((value, index) => {
|
|
793
|
-
var _a;
|
|
794
|
-
if (value.layout) {
|
|
795
|
-
if ((isHorizontalLogicLayout(layout) && isVerticalLogicLayout(value.layout)) ||
|
|
796
|
-
(isVerticalLogicLayout(layout) && isHorizontalLogicLayout(value.layout))) {
|
|
797
|
-
Transforms.setNode(board, { layout: null }, [...path, index]);
|
|
798
|
-
}
|
|
799
|
-
if ((_a = value.children) === null || _a === void 0 ? void 0 : _a.length) {
|
|
800
|
-
correctLogicLayoutNode(board, layout, [...path, index]);
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
};
|
|
806
|
-
|
|
807
|
-
const separateChildren = (parentElement) => {
|
|
808
|
-
const rightNodeCount = parentElement.rightNodeCount;
|
|
809
|
-
const children = parentElement.children;
|
|
810
|
-
let rightChildren = [], leftChildren = [];
|
|
811
|
-
for (let i = 0; i < children.length; i++) {
|
|
812
|
-
const child = children[i];
|
|
813
|
-
if (AbstractNode.isAbstract(child) && child.end < rightNodeCount) {
|
|
814
|
-
rightChildren.push(child);
|
|
815
|
-
continue;
|
|
816
|
-
}
|
|
817
|
-
if (AbstractNode.isAbstract(child) && child.start >= rightNodeCount) {
|
|
818
|
-
leftChildren.push(child);
|
|
819
|
-
continue;
|
|
820
|
-
}
|
|
821
|
-
if (i < rightNodeCount) {
|
|
822
|
-
rightChildren.push(child);
|
|
823
|
-
}
|
|
824
|
-
else {
|
|
825
|
-
leftChildren.push(child);
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
return { leftChildren, rightChildren };
|
|
829
|
-
};
|
|
830
|
-
const isSetAbstract = (element) => {
|
|
831
|
-
return !!getCorrespondingAbstract(element);
|
|
832
|
-
};
|
|
833
|
-
const canSetAbstract = (element) => {
|
|
834
|
-
return !PlaitElement.isRootElement(element) && !AbstractNode.isAbstract(element) && !isSetAbstract(element);
|
|
835
|
-
};
|
|
836
|
-
const getCorrespondingAbstract = (element) => {
|
|
837
|
-
const parent = MindElement.findParent(element);
|
|
838
|
-
if (!parent)
|
|
839
|
-
return undefined;
|
|
840
|
-
const elementIndex = parent.children.indexOf(element);
|
|
841
|
-
return parent.children.find(child => {
|
|
842
|
-
return AbstractNode.isAbstract(child) && elementIndex >= child.start && elementIndex <= child.end;
|
|
843
|
-
});
|
|
844
|
-
};
|
|
845
|
-
const getBehindAbstracts = (element) => {
|
|
846
|
-
const parent = MindElement.findParent(element);
|
|
847
|
-
if (!parent)
|
|
848
|
-
return [];
|
|
849
|
-
const index = parent.children.indexOf(element);
|
|
850
|
-
return parent.children.filter(child => AbstractNode.isAbstract(child) && child.start > index);
|
|
851
|
-
};
|
|
852
|
-
/**
|
|
853
|
-
* return corresponding abstract that is not child of elements
|
|
854
|
-
*/
|
|
855
|
-
const getOverallAbstracts = (board, elements) => {
|
|
856
|
-
const overallAbstracts = [];
|
|
857
|
-
elements
|
|
858
|
-
.filter(value => !AbstractNode.isAbstract(value) && !PlaitMind.isMind(value))
|
|
859
|
-
.forEach(value => {
|
|
860
|
-
const abstract = getCorrespondingAbstract(value);
|
|
861
|
-
if (abstract && elements.indexOf(abstract) === -1 && overallAbstracts.indexOf(abstract) === -1) {
|
|
862
|
-
const { start, end } = abstract;
|
|
863
|
-
const parent = MindElement.getParent(value);
|
|
864
|
-
const isOverall = parent.children.slice(start, end + 1).every(includedElement => elements.indexOf(includedElement) > -1);
|
|
865
|
-
if (isOverall) {
|
|
866
|
-
overallAbstracts.push(abstract);
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
});
|
|
870
|
-
return overallAbstracts;
|
|
871
|
-
};
|
|
872
|
-
/**
|
|
873
|
-
* abstract node is valid when elements contains at least one element it is referenced with
|
|
874
|
-
*/
|
|
875
|
-
const getValidAbstractRefs = (board, elements) => {
|
|
876
|
-
const validAbstractRefs = [];
|
|
877
|
-
elements
|
|
878
|
-
.filter(value => !AbstractNode.isAbstract(value) && !PlaitMind.isMind(value))
|
|
879
|
-
.forEach(value => {
|
|
880
|
-
const abstract = getCorrespondingAbstract(value);
|
|
881
|
-
if (abstract && elements.indexOf(abstract) > 0) {
|
|
882
|
-
const index = validAbstractRefs.findIndex(value => value.abstract === abstract);
|
|
883
|
-
if (index === -1) {
|
|
884
|
-
validAbstractRefs.push({
|
|
885
|
-
abstract: abstract,
|
|
886
|
-
references: [value]
|
|
887
|
-
});
|
|
888
|
-
}
|
|
889
|
-
else {
|
|
890
|
-
validAbstractRefs[index].references.push(value);
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
});
|
|
894
|
-
return validAbstractRefs;
|
|
895
|
-
};
|
|
896
|
-
function getRelativeStartEndByAbstractRef(abstractRef, elements) {
|
|
897
|
-
const start = elements.indexOf(abstractRef.references[0]);
|
|
898
|
-
const end = elements.indexOf(abstractRef.references[abstractRef.references.length - 1]);
|
|
899
|
-
return { start, end };
|
|
900
|
-
}
|
|
901
|
-
const insertElementHandleAbstract = (board, path, step = 1,
|
|
902
|
-
//由此区分拖拽和新增到概要概括最后一个节点
|
|
903
|
-
isExtendPreviousNode = true, effectedAbstracts = new Map()) => {
|
|
904
|
-
const parent = PlaitNode.parent(board, path);
|
|
905
|
-
const hasPreviousNode = path[path.length - 1] !== 0;
|
|
906
|
-
let behindAbstracts;
|
|
907
|
-
if (!hasPreviousNode) {
|
|
908
|
-
behindAbstracts = parent.children.filter(child => AbstractNode.isAbstract(child));
|
|
909
|
-
}
|
|
910
|
-
else {
|
|
911
|
-
const selectedElement = PlaitNode.get(board, Path.previous(path));
|
|
912
|
-
behindAbstracts = getBehindAbstracts(selectedElement);
|
|
913
|
-
}
|
|
914
|
-
if (behindAbstracts.length) {
|
|
915
|
-
behindAbstracts.forEach(abstract => {
|
|
916
|
-
let newProperties = effectedAbstracts.get(abstract);
|
|
917
|
-
if (!newProperties) {
|
|
918
|
-
newProperties = { start: 0, end: 0 };
|
|
919
|
-
effectedAbstracts.set(abstract, newProperties);
|
|
920
|
-
}
|
|
921
|
-
newProperties.start = newProperties.start + step;
|
|
922
|
-
newProperties.end = newProperties.end + step;
|
|
923
|
-
});
|
|
924
|
-
}
|
|
925
|
-
if (!hasPreviousNode) {
|
|
926
|
-
return effectedAbstracts;
|
|
927
|
-
}
|
|
928
|
-
const selectedElement = PlaitNode.get(board, Path.previous(path));
|
|
929
|
-
const correspondingAbstract = getCorrespondingAbstract(selectedElement);
|
|
930
|
-
const isDragToLast = !isExtendPreviousNode && correspondingAbstract && correspondingAbstract.end === path[path.length - 1] - 1;
|
|
931
|
-
if (correspondingAbstract && !isDragToLast) {
|
|
932
|
-
let newProperties = effectedAbstracts.get(correspondingAbstract);
|
|
933
|
-
if (!newProperties) {
|
|
934
|
-
newProperties = { start: 0, end: 0 };
|
|
935
|
-
effectedAbstracts.set(correspondingAbstract, newProperties);
|
|
936
|
-
}
|
|
937
|
-
newProperties.end = newProperties.end + step;
|
|
938
|
-
}
|
|
939
|
-
return effectedAbstracts;
|
|
940
|
-
};
|
|
941
|
-
const deleteElementHandleAbstract = (board, deletableElements, effectedAbstracts = new Map()) => {
|
|
942
|
-
deletableElements.forEach(node => {
|
|
943
|
-
if (!PlaitMind.isMind(node)) {
|
|
944
|
-
const behindAbstracts = getBehindAbstracts(node).filter(abstract => !deletableElements.includes(abstract));
|
|
945
|
-
if (behindAbstracts.length) {
|
|
946
|
-
behindAbstracts.forEach(abstract => {
|
|
947
|
-
let newProperties = effectedAbstracts.get(abstract);
|
|
948
|
-
if (!newProperties) {
|
|
949
|
-
newProperties = { start: 0, end: 0 };
|
|
950
|
-
effectedAbstracts.set(abstract, newProperties);
|
|
951
|
-
}
|
|
952
|
-
newProperties.start = newProperties.start - 1;
|
|
953
|
-
newProperties.end = newProperties.end - 1;
|
|
954
|
-
});
|
|
955
|
-
}
|
|
956
|
-
const correspondingAbstract = getCorrespondingAbstract(node);
|
|
957
|
-
if (correspondingAbstract && !deletableElements.includes(correspondingAbstract)) {
|
|
958
|
-
let newProperties = effectedAbstracts.get(correspondingAbstract);
|
|
959
|
-
if (!newProperties) {
|
|
960
|
-
newProperties = { start: 0, end: 0 };
|
|
961
|
-
effectedAbstracts.set(correspondingAbstract, newProperties);
|
|
962
|
-
}
|
|
963
|
-
newProperties.end = newProperties.end - 1;
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
});
|
|
967
|
-
return effectedAbstracts;
|
|
968
|
-
};
|
|
969
|
-
const isChildOfAbstract = (board, element) => {
|
|
970
|
-
const ancestors = MindElement.getAncestors(board, element);
|
|
971
|
-
return !!ancestors.find((value) => AbstractNode.isAbstract(value));
|
|
972
|
-
};
|
|
973
|
-
|
|
974
|
-
const normalizeWidthAndHeight = (board, element, width, height) => {
|
|
975
|
-
const minWidth = NodeSpace.getNodeTopicMinWidth(board, element, element.isRoot);
|
|
976
|
-
const newWidth = width < minWidth * board.viewport.zoom ? minWidth : width / board.viewport.zoom;
|
|
977
|
-
const newHeight = height / board.viewport.zoom;
|
|
978
|
-
return { width: newWidth, height: newHeight };
|
|
979
|
-
};
|
|
980
|
-
const setTopic = (board, element, topic, width, height) => {
|
|
981
|
-
const newElement = Object.assign({ data: Object.assign(Object.assign({}, element.data), { topic }) }, normalizeWidthAndHeight(board, element, width, height));
|
|
982
|
-
const path = PlaitBoard.findPath(board, element);
|
|
983
|
-
Transforms.setNode(board, newElement, path);
|
|
984
|
-
};
|
|
985
|
-
const setNodeManualWidth = (board, element, width, height) => {
|
|
986
|
-
const path = PlaitBoard.findPath(board, element);
|
|
987
|
-
const { width: normalizedWidth, height: normalizedHeight } = normalizeWidthAndHeight(board, element, width, height);
|
|
988
|
-
const newElement = { manualWidth: normalizedWidth, height: normalizedHeight };
|
|
989
|
-
Transforms.setNode(board, newElement, path);
|
|
990
|
-
};
|
|
991
|
-
const setTopicSize = (board, element, width, height) => {
|
|
992
|
-
const newElement = Object.assign({}, normalizeWidthAndHeight(board, element, width, height));
|
|
993
|
-
let isEqualWidth = Math.ceil(element.width) === Math.ceil(newElement.width);
|
|
994
|
-
let isEqualHeight = Math.ceil(element.height) === Math.ceil(newElement.height);
|
|
995
|
-
if (element.manualWidth) {
|
|
996
|
-
isEqualWidth = true;
|
|
997
|
-
}
|
|
998
|
-
if (!isEqualWidth || !isEqualHeight) {
|
|
999
|
-
const path = PlaitBoard.findPath(board, element);
|
|
1000
|
-
Transforms.setNode(board, newElement, path);
|
|
1001
|
-
}
|
|
1002
|
-
};
|
|
1003
|
-
const removeElements = (board, elements) => {
|
|
1004
|
-
const deletableElements = getFirstLevelElement(elements);
|
|
1005
|
-
deletableElements
|
|
1006
|
-
.map(element => {
|
|
1007
|
-
const path = PlaitBoard.findPath(board, element);
|
|
1008
|
-
const ref = board.pathRef(path);
|
|
1009
|
-
return () => {
|
|
1010
|
-
Transforms.removeNode(board, ref.current);
|
|
1011
|
-
ref.unref();
|
|
1012
|
-
};
|
|
1013
|
-
})
|
|
1014
|
-
.forEach(action => {
|
|
1015
|
-
action();
|
|
1016
|
-
});
|
|
1017
|
-
};
|
|
1018
|
-
const insertNodes = (board, elements, path) => {
|
|
1019
|
-
const pathRef = board.pathRef(path);
|
|
1020
|
-
elements.forEach(element => {
|
|
1021
|
-
if (pathRef.current) {
|
|
1022
|
-
Transforms.insertNode(board, element, pathRef.current);
|
|
1023
|
-
}
|
|
1024
|
-
});
|
|
1025
|
-
pathRef.unref();
|
|
1026
|
-
};
|
|
1027
|
-
const insertAbstractNodes = (board, validAbstractRefs, elements, path) => {
|
|
1028
|
-
var _a;
|
|
1029
|
-
const parent = PlaitNode.get(board, Path$1.parent(path));
|
|
1030
|
-
const abstractPath = [...Path$1.parent(path), (_a = parent.children) === null || _a === void 0 ? void 0 : _a.length];
|
|
1031
|
-
const abstracts = validAbstractRefs.map(refs => {
|
|
1032
|
-
const { start, end } = getRelativeStartEndByAbstractRef(refs, elements);
|
|
1033
|
-
return Object.assign(Object.assign({}, refs.abstract), { start: start + path[path.length - 1], end: end + path[path.length - 1] });
|
|
1034
|
-
});
|
|
1035
|
-
insertNodes(board, abstracts, abstractPath);
|
|
1036
|
-
};
|
|
1037
|
-
const setRightNodeCountByRefs = (board, refs) => {
|
|
1038
|
-
refs.forEach(ref => {
|
|
1039
|
-
Transforms.setNode(board, { rightNodeCount: ref.rightNodeCount }, ref.path);
|
|
1040
|
-
});
|
|
1041
|
-
};
|
|
1042
|
-
|
|
1043
|
-
const addEmoji = (board, element, emojiItem) => {
|
|
1044
|
-
const emojis = element.data.emojis || [];
|
|
1045
|
-
const newEmojis = [...emojis];
|
|
1046
|
-
newEmojis.push(emojiItem);
|
|
1047
|
-
const newElement = {
|
|
1048
|
-
data: Object.assign(Object.assign({}, element.data), { emojis: newEmojis })
|
|
1049
|
-
};
|
|
1050
|
-
const path = PlaitBoard.findPath(board, element);
|
|
1051
|
-
Transforms.setNode(board, newElement, path);
|
|
1052
|
-
};
|
|
1053
|
-
const removeEmoji = (board, element, emojiItem) => {
|
|
1054
|
-
const emojis = element.data.emojis.filter(value => value !== emojiItem);
|
|
1055
|
-
const newElement = {
|
|
1056
|
-
data: { topic: element.data.topic }
|
|
1057
|
-
};
|
|
1058
|
-
if (MindElement.hasImage(element)) {
|
|
1059
|
-
newElement.data.image = element.data.image;
|
|
1060
|
-
}
|
|
1061
|
-
if (emojis.length > 0) {
|
|
1062
|
-
newElement.data.emojis = emojis;
|
|
1063
|
-
}
|
|
1064
|
-
const path = PlaitBoard.findPath(board, element);
|
|
1065
|
-
Transforms.setNode(board, newElement, path);
|
|
1066
|
-
};
|
|
1067
|
-
const replaceEmoji = (board, element, oldEmoji, newEmoji) => {
|
|
1068
|
-
const newElement = {
|
|
1069
|
-
data: Object.assign({}, element.data)
|
|
1070
|
-
};
|
|
1071
|
-
const newEmojis = element.data.emojis.map(value => {
|
|
1072
|
-
if (value === oldEmoji) {
|
|
1073
|
-
return newEmoji;
|
|
1074
|
-
}
|
|
1075
|
-
return value;
|
|
1076
|
-
});
|
|
1077
|
-
newElement.data.emojis = newEmojis;
|
|
1078
|
-
const path = PlaitBoard.findPath(board, element);
|
|
1079
|
-
Transforms.setNode(board, newElement, path);
|
|
1080
|
-
};
|
|
1081
|
-
|
|
1082
|
-
/**
|
|
1083
|
-
* 1. return new node height if height changed
|
|
1084
|
-
* 2. new height is effected by zoom
|
|
1085
|
-
*/
|
|
1086
|
-
const getNewNodeHeight = (board, element, newNodeDynamicWidth) => {
|
|
1087
|
-
const textManage = PlaitElement.getComponent(element).textManage;
|
|
1088
|
-
const { height } = textManage.getSize();
|
|
1089
|
-
textManage.updateWidth(newNodeDynamicWidth);
|
|
1090
|
-
const { height: newHeight } = textManage.getSize();
|
|
1091
|
-
if (!element.manualWidth) {
|
|
1092
|
-
textManage.updateWidth(0);
|
|
1093
|
-
}
|
|
1094
|
-
if (height !== newHeight) {
|
|
1095
|
-
return newHeight;
|
|
1096
|
-
}
|
|
1097
|
-
if (Math.abs(newHeight / board.viewport.zoom - element.height) > 2) {
|
|
1098
|
-
return newHeight;
|
|
1099
|
-
}
|
|
1100
|
-
return undefined;
|
|
1101
|
-
};
|
|
1102
|
-
|
|
1103
|
-
const removeImage = (board, element) => {
|
|
1104
|
-
setImageFocus(board, element, false);
|
|
1105
|
-
const newElement = {
|
|
1106
|
-
data: Object.assign({}, element.data)
|
|
1107
|
-
};
|
|
1108
|
-
delete newElement.data.image;
|
|
1109
|
-
const path = PlaitBoard.findPath(board, element);
|
|
1110
|
-
const newDynamicWidth = NodeSpace.getNodeNewDynamicWidth(board, element, 0);
|
|
1111
|
-
const newHeight = getNewNodeHeight(board, element, newDynamicWidth);
|
|
1112
|
-
if (newHeight) {
|
|
1113
|
-
newElement.height = newHeight / board.viewport.zoom;
|
|
1114
|
-
}
|
|
1115
|
-
Transforms.setNode(board, newElement, path);
|
|
1116
|
-
};
|
|
1117
|
-
const setImage = (board, element, imageItem) => {
|
|
1118
|
-
const newElement = {
|
|
1119
|
-
data: Object.assign(Object.assign({}, element.data), { image: imageItem })
|
|
1120
|
-
};
|
|
1121
|
-
const newDynamicWidth = NodeSpace.getNodeNewDynamicWidth(board, element, imageItem.width);
|
|
1122
|
-
const newHeight = getNewNodeHeight(board, element, newDynamicWidth);
|
|
1123
|
-
if (newHeight) {
|
|
1124
|
-
newElement.height = newHeight / board.viewport.zoom;
|
|
1125
|
-
}
|
|
1126
|
-
const path = PlaitBoard.findPath(board, element);
|
|
1127
|
-
Transforms.setNode(board, newElement, path);
|
|
1128
|
-
};
|
|
1129
|
-
|
|
1130
|
-
const MindTransforms = {
|
|
1131
|
-
setLayout,
|
|
1132
|
-
setTopic,
|
|
1133
|
-
setTopicSize,
|
|
1134
|
-
setNodeManualWidth,
|
|
1135
|
-
addEmoji,
|
|
1136
|
-
removeEmoji,
|
|
1137
|
-
replaceEmoji,
|
|
1138
|
-
insertAbstract,
|
|
1139
|
-
setAbstractsByRefs,
|
|
1140
|
-
setAbstractByStandardLayout,
|
|
1141
|
-
removeElements,
|
|
1142
|
-
insertNodes,
|
|
1143
|
-
insertAbstractNodes,
|
|
1144
|
-
setRightNodeCountByRefs,
|
|
1145
|
-
removeImage,
|
|
1146
|
-
setImage
|
|
1147
|
-
};
|
|
1148
|
-
|
|
1149
|
-
const PICTURE_ACCEPTED_UPLOAD_SIZE = 20;
|
|
1150
|
-
const acceptImageTypes = ['png', 'jpeg', 'gif', 'bmp'];
|
|
1151
|
-
const DEFAULT_IMAGE_WIDTH = 240;
|
|
1152
|
-
|
|
1153
|
-
const BOARD_TO_SELECTED_IMAGE_ELEMENT = new WeakMap();
|
|
1154
|
-
const getSelectedImageElement = (board) => {
|
|
1155
|
-
return BOARD_TO_SELECTED_IMAGE_ELEMENT.get(board);
|
|
1156
|
-
};
|
|
1157
|
-
const addSelectedImageElement = (board, element) => {
|
|
1158
|
-
BOARD_TO_SELECTED_IMAGE_ELEMENT.set(board, element);
|
|
1159
|
-
};
|
|
1160
|
-
const removeSelectedImageElement = (board) => {
|
|
1161
|
-
BOARD_TO_SELECTED_IMAGE_ELEMENT.delete(board);
|
|
1162
|
-
};
|
|
1163
|
-
const setImageFocus = (board, element, isFocus) => {
|
|
1164
|
-
if (isFocus) {
|
|
1165
|
-
addSelectedImageElement(board, element);
|
|
1166
|
-
}
|
|
1167
|
-
else {
|
|
1168
|
-
removeSelectedImageElement(board);
|
|
1169
|
-
}
|
|
1170
|
-
const elementComponent = PlaitElement.getComponent(element);
|
|
1171
|
-
elementComponent.imageDrawer.componentRef.instance.isFocus = isFocus;
|
|
1172
|
-
elementComponent.imageDrawer.componentRef.instance.cdr.markForCheck();
|
|
1173
|
-
};
|
|
1174
|
-
const selectImage = (board, element, acceptImageTypes = ['png', 'jpeg', 'gif', 'bmp']) => {
|
|
1175
|
-
const inputFile = document.createElement('input');
|
|
1176
|
-
inputFile.setAttribute('type', 'file');
|
|
1177
|
-
const acceptImageTypesString = '.' + acceptImageTypes.join(',.');
|
|
1178
|
-
inputFile.setAttribute('accept', acceptImageTypesString);
|
|
1179
|
-
inputFile.onchange = (event) => {
|
|
1180
|
-
buildImage(board, element, event.target.files[0]);
|
|
1181
|
-
};
|
|
1182
|
-
inputFile.click();
|
|
1183
|
-
};
|
|
1184
|
-
const buildImage = (board, element, imageFile) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1185
|
-
let width = 0, height = 0;
|
|
1186
|
-
yield getImageSize(imageFile).then((value) => {
|
|
1187
|
-
width = value.width;
|
|
1188
|
-
height = value.height;
|
|
1189
|
-
});
|
|
1190
|
-
let imageItem = null;
|
|
1191
|
-
const url = URL.createObjectURL(imageFile);
|
|
1192
|
-
const context = PlaitBoard.getComponent(board).viewContainerRef.injector.get(PlaitContextService);
|
|
1193
|
-
context.setUploadingFile({ url, file: imageFile });
|
|
1194
|
-
imageItem = {
|
|
1195
|
-
url,
|
|
1196
|
-
width,
|
|
1197
|
-
height
|
|
1198
|
-
};
|
|
1199
|
-
MindTransforms.setImage(board, element, imageItem);
|
|
1200
|
-
});
|
|
1201
|
-
function getImageSize(file, defaultImageWidth = DEFAULT_IMAGE_WIDTH) {
|
|
1202
|
-
return new Promise((resolve, reject) => {
|
|
1203
|
-
const image = new Image();
|
|
1204
|
-
image.src = URL.createObjectURL(file);
|
|
1205
|
-
image.onload = function () {
|
|
1206
|
-
const width = defaultImageWidth;
|
|
1207
|
-
const height = (defaultImageWidth * image.naturalHeight) / image.naturalWidth;
|
|
1208
|
-
resolve(image.naturalWidth > defaultImageWidth ? { width, height } : { width: image.naturalWidth, height: image.naturalHeight });
|
|
1209
|
-
};
|
|
1210
|
-
});
|
|
1211
|
-
}
|
|
1212
|
-
|
|
1213
|
-
const getAvailableProperty = (board, element, propertyKey) => {
|
|
1214
|
-
return element[propertyKey];
|
|
1215
|
-
};
|
|
1216
|
-
|
|
1217
|
-
/**
|
|
1218
|
-
* Processing of branch color, width, style, etc. of the mind node
|
|
1219
|
-
*/
|
|
1220
|
-
const getBranchColorByMindElement = (board, element) => {
|
|
1221
|
-
if (AbstractNode.isAbstract(element) || isChildOfAbstract(board, element)) {
|
|
1222
|
-
return getAbstractBranchColor(board, element);
|
|
1223
|
-
}
|
|
1224
|
-
const branchColor = getAvailableProperty(board, element, 'branchColor');
|
|
1225
|
-
return branchColor || getDefaultBranchColor(board, element);
|
|
1226
|
-
};
|
|
1227
|
-
const getBranchShapeByMindElement = (board, element) => {
|
|
1228
|
-
const branchShape = getAvailableProperty(board, element, 'branchShape');
|
|
1229
|
-
return branchShape || BranchShape.bight;
|
|
1230
|
-
};
|
|
1231
|
-
const getBranchWidthByMindElement = (board, element) => {
|
|
1232
|
-
const branchWidth = getAvailableProperty(board, element, 'branchWidth');
|
|
1233
|
-
return branchWidth || BRANCH_WIDTH;
|
|
1234
|
-
};
|
|
1235
|
-
const getAbstractBranchWidth = (board, element) => {
|
|
1236
|
-
if (!isNullOrUndefined(element.branchWidth)) {
|
|
1237
|
-
return element.branchWidth;
|
|
1238
|
-
}
|
|
1239
|
-
return DefaultAbstractNodeStyle.branch.width;
|
|
1240
|
-
};
|
|
1241
|
-
const getAbstractBranchColor = (board, element) => {
|
|
1242
|
-
if (element.branchColor) {
|
|
1243
|
-
return element.branchColor;
|
|
1244
|
-
}
|
|
1245
|
-
return DefaultAbstractNodeStyle.branch.color;
|
|
1246
|
-
};
|
|
1247
|
-
const getNextBranchColor = (board, root) => {
|
|
1248
|
-
const index = root.children.length;
|
|
1249
|
-
return getDefaultBranchColorByIndex(board, index);
|
|
1250
|
-
};
|
|
1251
|
-
const getDefaultBranchColor = (board, element) => {
|
|
1252
|
-
const path = PlaitBoard.findPath(board, element);
|
|
1253
|
-
return getDefaultBranchColorByIndex(board, path[1]);
|
|
1254
|
-
};
|
|
1255
|
-
const getDefaultBranchColorByIndex = (board, index) => {
|
|
1256
|
-
const themeColor = getMindThemeColor(board);
|
|
1257
|
-
const length = themeColor.branchColors.length;
|
|
1258
|
-
const remainder = index % length;
|
|
1259
|
-
return themeColor.branchColors[remainder];
|
|
1260
|
-
};
|
|
1261
|
-
const getMindThemeColor = (board) => {
|
|
1262
|
-
const themeColors = PlaitBoard.getThemeColors(board);
|
|
1263
|
-
const themeColor = themeColors.find(val => val.mode === board.theme.themeColorMode);
|
|
1264
|
-
if (themeColor && MindThemeColor.isMindThemeColor(themeColor)) {
|
|
1265
|
-
return themeColor;
|
|
1266
|
-
}
|
|
1267
|
-
else {
|
|
1268
|
-
return MindDefaultThemeColor;
|
|
1269
|
-
}
|
|
1270
|
-
};
|
|
1271
|
-
|
|
1272
|
-
const getStrokeByMindElement = (board, element) => {
|
|
1273
|
-
if (PlaitMind.isMind(element)) {
|
|
1274
|
-
const defaultRootStroke = getMindThemeColor(board).rootFill;
|
|
1275
|
-
return element.strokeColor || defaultRootStroke;
|
|
1276
|
-
}
|
|
1277
|
-
if (AbstractNode.isAbstract(element) || isChildOfAbstract(board, element)) {
|
|
1278
|
-
return element.strokeColor || DefaultAbstractNodeStyle.shape.strokeColor;
|
|
1279
|
-
}
|
|
1280
|
-
return getAvailableProperty(board, element, 'strokeColor') || getDefaultBranchColor(board, element);
|
|
1281
|
-
};
|
|
1282
|
-
const getStrokeWidthByElement = (board, element) => {
|
|
1283
|
-
const strokeWidth = element.strokeWidth ||
|
|
1284
|
-
(AbstractNode.isAbstract(element) ? DefaultAbstractNodeStyle.shape.strokeWidth : DefaultNodeStyle.shape.strokeWidth);
|
|
1285
|
-
return strokeWidth;
|
|
1286
|
-
};
|
|
1287
|
-
const getFillByElement = (board, element) => {
|
|
1288
|
-
if (element.fill) {
|
|
1289
|
-
return element.fill;
|
|
1290
|
-
}
|
|
1291
|
-
const defaultRootFill = getMindThemeColor(board).rootFill;
|
|
1292
|
-
return element.isRoot ? defaultRootFill : DefaultNodeStyle.shape.fill;
|
|
1293
|
-
};
|
|
1294
|
-
const getShapeByElement = (board, element) => {
|
|
1295
|
-
const shape = getAvailableProperty(board, element, 'shape');
|
|
1296
|
-
return shape || MindElementShape.roundRectangle;
|
|
1297
|
-
};
|
|
1298
|
-
|
|
1299
|
-
const IS_DRAGGING = new WeakMap();
|
|
1300
|
-
const addActiveOnDragOrigin = (activeElement) => {
|
|
1301
|
-
const activeComponent = PlaitElement.getComponent(activeElement);
|
|
1302
|
-
activeComponent.g.classList.add('dragging-node');
|
|
1303
|
-
!activeElement.isCollapsed &&
|
|
1304
|
-
activeElement.children.forEach(child => {
|
|
1305
|
-
addActiveOnDragOrigin(child);
|
|
1306
|
-
});
|
|
1307
|
-
};
|
|
1308
|
-
const removeActiveOnDragOrigin = (activeElement) => {
|
|
1309
|
-
const activeComponent = PlaitElement.getComponent(activeElement);
|
|
1310
|
-
activeComponent.g.classList.remove('dragging-node');
|
|
1311
|
-
!activeElement.isCollapsed &&
|
|
1312
|
-
activeElement.children.forEach(child => {
|
|
1313
|
-
removeActiveOnDragOrigin(child);
|
|
1314
|
-
});
|
|
1315
|
-
};
|
|
1316
|
-
const isDragging = (board) => {
|
|
1317
|
-
return !!IS_DRAGGING.get(board);
|
|
1318
|
-
};
|
|
1319
|
-
const setIsDragging = (board, state) => {
|
|
1320
|
-
IS_DRAGGING.set(board, state);
|
|
1321
|
-
if (state) {
|
|
1322
|
-
PlaitBoard.getBoardContainer(board).classList.add('mind-node-dragging');
|
|
1323
|
-
}
|
|
1324
|
-
else {
|
|
1325
|
-
PlaitBoard.getBoardContainer(board).classList.remove('mind-node-dragging');
|
|
1326
|
-
}
|
|
1327
|
-
};
|
|
1328
|
-
const hasPreviousOrNextOfDropPath = (parent, dropTarget, dropPath) => {
|
|
1329
|
-
let children = getNonAbstractChildren(parent);
|
|
1330
|
-
if (PlaitMind.isMind(parent) && isStandardLayout(getRootLayout(parent))) {
|
|
1331
|
-
const isDropRight = isDropStandardRight(parent, dropTarget);
|
|
1332
|
-
if (isDropRight) {
|
|
1333
|
-
children = children.slice(0, parent.rightNodeCount);
|
|
1334
|
-
}
|
|
1335
|
-
if (!isDropRight) {
|
|
1336
|
-
children = children.slice(parent.rightNodeCount, children.length);
|
|
1337
|
-
dropPath = [...dropPath, dropPath[dropPath.length - 1] - parent.rightNodeCount];
|
|
1338
|
-
}
|
|
1339
|
-
}
|
|
1340
|
-
let hasPreviousNode = dropPath[dropPath.length - 1] !== 0;
|
|
1341
|
-
let hasNextNode = dropPath[dropPath.length - 1] !== ((children === null || children === void 0 ? void 0 : children.length) || 0);
|
|
1342
|
-
if (parent.isCollapsed) {
|
|
1343
|
-
hasNextNode = false;
|
|
1344
|
-
hasPreviousNode = false;
|
|
1345
|
-
}
|
|
1346
|
-
return {
|
|
1347
|
-
hasPreviousNode,
|
|
1348
|
-
hasNextNode
|
|
1349
|
-
};
|
|
1350
|
-
};
|
|
1351
|
-
const isDropStandardRight = (parent, dropTarget) => {
|
|
1352
|
-
const target = dropTarget.target;
|
|
1353
|
-
return ((PlaitMind.isMind(parent) &&
|
|
1354
|
-
isStandardLayout(getRootLayout(parent)) &&
|
|
1355
|
-
parent.children.indexOf(target) !== -1 &&
|
|
1356
|
-
parent.children.indexOf(target) < parent.rightNodeCount) ||
|
|
1357
|
-
(PlaitMind.isMind(target) && isStandardLayout(getRootLayout(target)) && dropTarget.detectResult === 'right'));
|
|
1358
|
-
};
|
|
1359
|
-
|
|
1360
|
-
const directionCorrector = (board, node, detectResults) => {
|
|
1361
|
-
if (!node.origin.isRoot && !AbstractNode.isAbstract(node.origin)) {
|
|
1362
|
-
const parentLayout = MindQueries.getCorrectLayoutByElement(board, node === null || node === void 0 ? void 0 : node.parent.origin);
|
|
1363
|
-
if (isStandardLayout(parentLayout)) {
|
|
1364
|
-
const idx = node.parent.children.findIndex(x => x === node);
|
|
1365
|
-
const isLeft = idx >= (node.parent.origin.rightNodeCount || 0);
|
|
1366
|
-
return getAllowedDirection(detectResults, [isLeft ? 'right' : 'left']);
|
|
1367
|
-
}
|
|
1368
|
-
if (isLeftLayout(parentLayout)) {
|
|
1369
|
-
return getAllowedDirection(detectResults, ['right']);
|
|
1370
|
-
}
|
|
1371
|
-
if (isRightLayout(parentLayout)) {
|
|
1372
|
-
return getAllowedDirection(detectResults, ['left']);
|
|
1373
|
-
}
|
|
1374
|
-
if (parentLayout === MindLayoutType.upward) {
|
|
1375
|
-
return getAllowedDirection(detectResults, ['bottom']);
|
|
1376
|
-
}
|
|
1377
|
-
if (parentLayout === MindLayoutType.downward) {
|
|
1378
|
-
return getAllowedDirection(detectResults, ['top']);
|
|
1379
|
-
}
|
|
1380
|
-
}
|
|
1381
|
-
else {
|
|
1382
|
-
const layout = MindQueries.getCorrectLayoutByElement(board, node === null || node === void 0 ? void 0 : node.origin);
|
|
1383
|
-
if (isStandardLayout(layout)) {
|
|
1384
|
-
return getAllowedDirection(detectResults, ['top', 'bottom']);
|
|
1385
|
-
}
|
|
1386
|
-
if (layout === MindLayoutType.upward) {
|
|
1387
|
-
return getAllowedDirection(detectResults, ['left', 'right', 'bottom']);
|
|
1388
|
-
}
|
|
1389
|
-
if (layout === MindLayoutType.downward) {
|
|
1390
|
-
return getAllowedDirection(detectResults, ['left', 'right', 'top']);
|
|
1391
|
-
}
|
|
1392
|
-
if (isLeftLayout(layout)) {
|
|
1393
|
-
return getAllowedDirection(detectResults, ['right', 'top', 'bottom']);
|
|
1394
|
-
}
|
|
1395
|
-
if (isRightLayout(layout)) {
|
|
1396
|
-
return getAllowedDirection(detectResults, ['left', 'top', 'bottom']);
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
return null;
|
|
1400
|
-
};
|
|
1401
|
-
const getAllowedDirection = (detectResults, illegalDirections) => {
|
|
1402
|
-
const directions = detectResults;
|
|
1403
|
-
illegalDirections.forEach(item => {
|
|
1404
|
-
const bottomDirectionIndex = directions.findIndex(direction => direction === item);
|
|
1405
|
-
if (bottomDirectionIndex !== -1) {
|
|
1406
|
-
directions.splice(bottomDirectionIndex, 1);
|
|
1407
|
-
}
|
|
1408
|
-
});
|
|
1409
|
-
return directions.length ? directions : null;
|
|
1410
|
-
};
|
|
1411
|
-
const detectDropTarget = (board, detectPoint, dropTarget, activeElements) => {
|
|
1412
|
-
let detectResult = null;
|
|
1413
|
-
depthFirstRecursion(board, element => {
|
|
1414
|
-
if (!MindElement.isMindElement(board, element) || detectResult) {
|
|
1415
|
-
return;
|
|
1416
|
-
}
|
|
1417
|
-
const node = MindElement.getNode(element);
|
|
1418
|
-
const directions = directionDetector(node, detectPoint);
|
|
1419
|
-
if (directions) {
|
|
1420
|
-
detectResult = directionCorrector(board, node, directions);
|
|
1421
|
-
}
|
|
1422
|
-
dropTarget = null;
|
|
1423
|
-
const isValid = activeElements.every(element => isValidTarget(element, node.origin));
|
|
1424
|
-
if (detectResult && isValid) {
|
|
1425
|
-
dropTarget = { target: node.origin, detectResult: detectResult[0] };
|
|
1426
|
-
}
|
|
1427
|
-
}, getIsRecursionFunc(board));
|
|
1428
|
-
return dropTarget;
|
|
1429
|
-
};
|
|
1430
|
-
const directionDetector = (targetNode, centerPoint) => {
|
|
1431
|
-
const { x, y, width, height } = getRectangleByNode(targetNode);
|
|
1432
|
-
const yCenter = y + height / 2;
|
|
1433
|
-
const xCenter = x + width / 2;
|
|
1434
|
-
const top = targetNode.y;
|
|
1435
|
-
const bottom = targetNode.y + targetNode.height;
|
|
1436
|
-
const left = targetNode.x;
|
|
1437
|
-
const right = targetNode.x + targetNode.width;
|
|
1438
|
-
const direction = [];
|
|
1439
|
-
// x 轴
|
|
1440
|
-
if (centerPoint[1] > y && centerPoint[1] < y + height) {
|
|
1441
|
-
if (centerPoint[0] > left && centerPoint[0] < xCenter) {
|
|
1442
|
-
direction.push('left');
|
|
1443
|
-
}
|
|
1444
|
-
if (centerPoint[0] > xCenter && centerPoint[0] < right) {
|
|
1445
|
-
direction.push('right');
|
|
1446
|
-
}
|
|
1447
|
-
// 重合区域,返回两个方向
|
|
1448
|
-
if ((centerPoint[0] > x && centerPoint[0] < xCenter) || (centerPoint[0] > xCenter && centerPoint[0] < x + width)) {
|
|
1449
|
-
if (centerPoint[1] < yCenter) {
|
|
1450
|
-
direction.push('top');
|
|
1451
|
-
}
|
|
1452
|
-
else {
|
|
1453
|
-
direction.push('bottom');
|
|
1454
|
-
}
|
|
1455
|
-
}
|
|
1456
|
-
return direction.length ? direction : null;
|
|
1457
|
-
}
|
|
1458
|
-
// y 轴
|
|
1459
|
-
if (centerPoint[0] > x && centerPoint[0] < x + width) {
|
|
1460
|
-
if (centerPoint[1] > top && centerPoint[1] < yCenter) {
|
|
1461
|
-
direction.push('top');
|
|
1462
|
-
}
|
|
1463
|
-
if (centerPoint[1] > yCenter && centerPoint[1] < bottom) {
|
|
1464
|
-
direction.push('bottom');
|
|
1465
|
-
}
|
|
1466
|
-
if ((centerPoint[1] > y && centerPoint[1] < y + height) || (centerPoint[1] > yCenter && centerPoint[1] < y + height)) {
|
|
1467
|
-
if (centerPoint[0] < xCenter) {
|
|
1468
|
-
direction.push('left');
|
|
1469
|
-
}
|
|
1470
|
-
else {
|
|
1471
|
-
direction.push('right');
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
return direction.length ? direction : null;
|
|
1475
|
-
}
|
|
1476
|
-
return null;
|
|
1477
|
-
};
|
|
1478
|
-
const isValidTarget = (origin, target) => {
|
|
1479
|
-
return origin !== target && !isChildElement(origin, target);
|
|
1480
|
-
};
|
|
1481
|
-
const getPathByDropTarget = (board, dropTarget) => {
|
|
1482
|
-
let targetPath = PlaitBoard.findPath(board, dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.target);
|
|
1483
|
-
const layout = PlaitMind.isMind(dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.target)
|
|
1484
|
-
? getRootLayout(dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.target)
|
|
1485
|
-
: MindQueries.getCorrectLayoutByElement(board, MindElement.getParent(dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.target));
|
|
1486
|
-
const children = getNonAbstractChildren(dropTarget.target);
|
|
1487
|
-
// 上下布局:左右是兄弟节点,上下是子节点
|
|
1488
|
-
if (isVerticalLogicLayout(layout)) {
|
|
1489
|
-
if (dropTarget.detectResult === 'top' || dropTarget.detectResult === 'bottom') {
|
|
1490
|
-
targetPath.push(children.length);
|
|
1491
|
-
}
|
|
1492
|
-
// 如果是左,位置不变,右则插入到下一个兄弟节点
|
|
1493
|
-
if (dropTarget.detectResult === 'right') {
|
|
1494
|
-
targetPath = Path.next(targetPath);
|
|
1495
|
-
}
|
|
1496
|
-
}
|
|
1497
|
-
// 水平布局/标准布局:上下是兄弟节点,左右是子节点
|
|
1498
|
-
if (isHorizontalLogicLayout(layout)) {
|
|
1499
|
-
if (dropTarget.detectResult === 'right') {
|
|
1500
|
-
if (PlaitMind.isMind(dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.target) && isStandardLayout(layout)) {
|
|
1501
|
-
targetPath.push(dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.target.rightNodeCount);
|
|
1502
|
-
}
|
|
1503
|
-
else {
|
|
1504
|
-
targetPath.push(children.length);
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
if (dropTarget.detectResult === 'left') {
|
|
1508
|
-
targetPath.push(children.length);
|
|
1509
|
-
}
|
|
1510
|
-
// 如果是上,位置不变,下插入到下一个兄弟节点
|
|
1511
|
-
if (dropTarget.detectResult === 'bottom') {
|
|
1512
|
-
targetPath = Path.next(targetPath);
|
|
1513
|
-
}
|
|
1514
|
-
}
|
|
1515
|
-
// 缩进布局:上下是兄弟节点,左右是子节点,但上(左上/右上),探测到上是子节点,下则位置不变,反之同理。
|
|
1516
|
-
if (isIndentedLayout(layout)) {
|
|
1517
|
-
if (isTopLayout(layout) && dropTarget.detectResult === 'top') {
|
|
1518
|
-
targetPath = Path.next(targetPath);
|
|
1519
|
-
}
|
|
1520
|
-
if (isBottomLayout(layout) && dropTarget.detectResult === 'bottom') {
|
|
1521
|
-
targetPath = Path.next(targetPath);
|
|
1522
|
-
}
|
|
1523
|
-
if (isLeftLayout(layout) && dropTarget.detectResult === 'left') {
|
|
1524
|
-
targetPath.push(children.length);
|
|
1525
|
-
}
|
|
1526
|
-
if (isRightLayout(layout) && dropTarget.detectResult === 'right') {
|
|
1527
|
-
targetPath.push(children.length);
|
|
1528
|
-
}
|
|
1529
|
-
}
|
|
1530
|
-
return targetPath;
|
|
1531
|
-
};
|
|
1532
|
-
|
|
1533
|
-
const ABSTRACT_HANDLE_COLOR = '#6698FF80'; //primary color 50% opacity
|
|
1534
|
-
const ABSTRACT_INCLUDED_OUTLINE_OFFSET = 3.5;
|
|
1535
|
-
const ABSTRACT_HANDLE_LENGTH = 10;
|
|
1536
|
-
const ABSTRACT_HANDLE_MASK_WIDTH = 8;
|
|
1537
|
-
|
|
1538
|
-
var HorizontalPlacement;
|
|
1539
|
-
(function (HorizontalPlacement) {
|
|
1540
|
-
HorizontalPlacement["left"] = "left";
|
|
1541
|
-
HorizontalPlacement["center"] = "center";
|
|
1542
|
-
HorizontalPlacement["right"] = "right";
|
|
1543
|
-
})(HorizontalPlacement || (HorizontalPlacement = {}));
|
|
1544
|
-
var VerticalPlacement;
|
|
1545
|
-
(function (VerticalPlacement) {
|
|
1546
|
-
VerticalPlacement["top"] = "top";
|
|
1547
|
-
VerticalPlacement["middle"] = "middle";
|
|
1548
|
-
VerticalPlacement["bottom"] = "bottom";
|
|
1549
|
-
})(VerticalPlacement || (VerticalPlacement = {}));
|
|
1550
|
-
|
|
1551
|
-
const getPointByPlacement = (client, placement) => {
|
|
1552
|
-
let x = client.x;
|
|
1553
|
-
let y = client.y;
|
|
1554
|
-
if (placement[0] === HorizontalPlacement.center) {
|
|
1555
|
-
x = client.x + client.width / 2;
|
|
1556
|
-
}
|
|
1557
|
-
if (placement[0] === HorizontalPlacement.right) {
|
|
1558
|
-
x = client.x + client.width;
|
|
1559
|
-
}
|
|
1560
|
-
if (placement[1] === VerticalPlacement.middle) {
|
|
1561
|
-
y = client.y + client.height / 2;
|
|
1562
|
-
}
|
|
1563
|
-
if (placement[1] === VerticalPlacement.bottom) {
|
|
1564
|
-
y = client.y + client.height;
|
|
1565
|
-
}
|
|
1566
|
-
return [x, y];
|
|
1567
|
-
};
|
|
1568
|
-
const getXDistanceBetweenPoint = (point1, point2, isHorizontalLayout) => {
|
|
1569
|
-
if (isHorizontalLayout) {
|
|
1570
|
-
return Math.abs(point1[0] - point2[0]);
|
|
1571
|
-
}
|
|
1572
|
-
else {
|
|
1573
|
-
return Math.abs(point1[1] - point2[1]);
|
|
1574
|
-
}
|
|
1575
|
-
};
|
|
1576
|
-
const getYDistanceBetweenPoint = (point1, point2, isHorizontalLayout) => {
|
|
1577
|
-
getXDistanceBetweenPoint(point1, point2, !isHorizontalLayout);
|
|
1578
|
-
};
|
|
1579
|
-
const getLayoutDirection = (node, isHorizontal) => {
|
|
1580
|
-
if (isHorizontal) {
|
|
1581
|
-
if (node.left) {
|
|
1582
|
-
return LayoutDirection.left;
|
|
1583
|
-
}
|
|
1584
|
-
else {
|
|
1585
|
-
return LayoutDirection.right;
|
|
1586
|
-
}
|
|
1587
|
-
}
|
|
1588
|
-
else {
|
|
1589
|
-
if (node.up) {
|
|
1590
|
-
return LayoutDirection.top;
|
|
1591
|
-
}
|
|
1592
|
-
else {
|
|
1593
|
-
return LayoutDirection.bottom;
|
|
1594
|
-
}
|
|
1595
|
-
}
|
|
1596
|
-
};
|
|
1597
|
-
// 以右为基准
|
|
1598
|
-
// 右 -> 左:
|
|
1599
|
-
// 1. 终点 -> 起点/起点 -> 终点
|
|
1600
|
-
// 2. 加 -> 减
|
|
1601
|
-
// 水平 -> 垂直:
|
|
1602
|
-
// 1. 起点/终点 -> 纵轴
|
|
1603
|
-
// 2. 加减 -> 纵轴
|
|
1604
|
-
// 下 -> 上:
|
|
1605
|
-
// 1. 终点 -> 起点/终点 -> 起点
|
|
1606
|
-
// 2. 加 -> 减
|
|
1607
|
-
const moveXOfPoint = (point, distance, direction = LayoutDirection.right) => {
|
|
1608
|
-
if (direction === LayoutDirection.left) {
|
|
1609
|
-
return [point[0] - distance, point[1]];
|
|
1610
|
-
}
|
|
1611
|
-
if (direction === LayoutDirection.bottom) {
|
|
1612
|
-
return [point[0], point[1] + distance];
|
|
1613
|
-
}
|
|
1614
|
-
if (direction === LayoutDirection.top) {
|
|
1615
|
-
return [point[0], point[1] - distance];
|
|
1616
|
-
}
|
|
1617
|
-
return [point[0] + distance, point[1]];
|
|
1618
|
-
};
|
|
1619
|
-
const moveYOfPoint = (point, distance, direction = LayoutDirection.right) => {
|
|
1620
|
-
if (direction === LayoutDirection.bottom) {
|
|
1621
|
-
return [point[0] + distance, point[1]];
|
|
1622
|
-
}
|
|
1623
|
-
if (direction === LayoutDirection.top) {
|
|
1624
|
-
return [point[0] + distance, point[1]];
|
|
1625
|
-
}
|
|
1626
|
-
return [point[0], point[1] + distance];
|
|
1627
|
-
};
|
|
1628
|
-
const transformPlacement = (placement, direction) => {
|
|
1629
|
-
// to left
|
|
1630
|
-
if (direction === LayoutDirection.left) {
|
|
1631
|
-
if (placement[0] === HorizontalPlacement.right) {
|
|
1632
|
-
placement[0] = HorizontalPlacement.left;
|
|
1633
|
-
}
|
|
1634
|
-
else if (placement[0] === HorizontalPlacement.left) {
|
|
1635
|
-
placement[0] = HorizontalPlacement.right;
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
|
-
// to bottom
|
|
1639
|
-
if (direction === LayoutDirection.bottom || direction === LayoutDirection.top) {
|
|
1640
|
-
let horizontal = HorizontalPlacement.center;
|
|
1641
|
-
let vertical = VerticalPlacement.middle;
|
|
1642
|
-
if (placement[1] === VerticalPlacement.top) {
|
|
1643
|
-
horizontal = HorizontalPlacement.left;
|
|
1644
|
-
}
|
|
1645
|
-
if (placement[1] === VerticalPlacement.bottom) {
|
|
1646
|
-
horizontal = HorizontalPlacement.right;
|
|
1647
|
-
}
|
|
1648
|
-
if (placement[0] === HorizontalPlacement.left) {
|
|
1649
|
-
vertical = VerticalPlacement.top;
|
|
1650
|
-
}
|
|
1651
|
-
if (placement[0] === HorizontalPlacement.right) {
|
|
1652
|
-
vertical = VerticalPlacement.bottom;
|
|
1653
|
-
}
|
|
1654
|
-
placement[0] = horizontal;
|
|
1655
|
-
placement[1] = vertical;
|
|
1656
|
-
}
|
|
1657
|
-
// to up
|
|
1658
|
-
if (direction === LayoutDirection.top) {
|
|
1659
|
-
if (placement[1] === VerticalPlacement.bottom) {
|
|
1660
|
-
placement[1] = VerticalPlacement.top;
|
|
1661
|
-
}
|
|
1662
|
-
else if (placement[1] === VerticalPlacement.top) {
|
|
1663
|
-
placement[1] = VerticalPlacement.bottom;
|
|
1664
|
-
}
|
|
1665
|
-
}
|
|
1666
|
-
};
|
|
1667
|
-
|
|
1668
|
-
function drawIndentedLink(board, node, child, defaultStroke = null, needDrawUnderline = true, defaultStrokeWidth) {
|
|
1669
|
-
var _a;
|
|
1670
|
-
const branchShape = getBranchShapeByMindElement(board, node.origin);
|
|
1671
|
-
const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board, node.origin);
|
|
1672
|
-
const branchColor = defaultStroke || ((_a = node.origin) === null || _a === void 0 ? void 0 : _a.branchColor) || getBranchColorByMindElement(board, child.origin);
|
|
1673
|
-
const isUnderlineShape = getShapeByElement(board, child.origin) === MindElementShape.underline;
|
|
1674
|
-
let beginX, beginY, endX, endY, beginNode = node, endNode = child;
|
|
1675
|
-
const beginRectangle = getRectangleByNode(beginNode);
|
|
1676
|
-
const endRectangle = getRectangleByNode(endNode);
|
|
1677
|
-
beginX = beginNode.x + beginNode.width / 2;
|
|
1678
|
-
beginY = isChildUp(node, child) ? beginRectangle.y : beginRectangle.y + beginRectangle.height;
|
|
1679
|
-
endX = node.left ? endNode.x + endNode.hGap + endRectangle.width : endNode.x + endNode.hGap;
|
|
1680
|
-
endY = isUnderlineShape ? endNode.y + endNode.height - endNode.vGap : endNode.y + endNode.height / 2;
|
|
1681
|
-
//根据位置,设置正负参数
|
|
1682
|
-
let plusMinus = isChildUp(node, child) ? (node.left ? [-1, -1] : [1, -1]) : node.left ? [-1, 1] : [1, 1];
|
|
1683
|
-
let curve = [
|
|
1684
|
-
[beginX, beginY],
|
|
1685
|
-
[beginX, beginY],
|
|
1686
|
-
[beginX, beginY],
|
|
1687
|
-
[beginX, endY - (endNode.hGap * 3 * plusMinus[1]) / 5],
|
|
1688
|
-
[beginX, endY - (endNode.hGap * plusMinus[1]) / 5],
|
|
1689
|
-
[beginX + (endNode.hGap * plusMinus[0]) / 4, endY],
|
|
1690
|
-
[beginX + (endNode.hGap * plusMinus[0] * 3) / 5, endY],
|
|
1691
|
-
isUnderlineShape && needDrawUnderline ? [endX + (endNode.width - endNode.hGap * 2) * plusMinus[0], endY] : [endX, endY],
|
|
1692
|
-
isUnderlineShape && needDrawUnderline ? [endX + (endNode.width - endNode.hGap * 2) * plusMinus[0], endY] : [endX, endY],
|
|
1693
|
-
isUnderlineShape && needDrawUnderline ? [endX + (endNode.width - endNode.hGap * 2) * plusMinus[0], endY] : [endX, endY]
|
|
1694
|
-
];
|
|
1695
|
-
if (branchShape === BranchShape.polyline) {
|
|
1696
|
-
const polylinePoints = [
|
|
1697
|
-
[beginX, beginY],
|
|
1698
|
-
[beginX, endY],
|
|
1699
|
-
[endX, endY],
|
|
1700
|
-
isUnderlineShape && needDrawUnderline ? [endX + (endNode.width - endNode.hGap * 2) * plusMinus[0], endY] : [endX, endY]
|
|
1701
|
-
];
|
|
1702
|
-
return drawLinearPath(polylinePoints, { stroke: branchColor, strokeWidth: branchWidth });
|
|
1703
|
-
}
|
|
1704
|
-
const points = pointsOnBezierCurves(curve, 0.001);
|
|
1705
|
-
return drawBezierPath(points, { stroke: branchColor, strokeWidth: branchWidth });
|
|
1706
|
-
}
|
|
1707
|
-
|
|
1708
|
-
function drawLogicLink(board, parent, node, isHorizontal, defaultStroke = null, defaultStrokeWidth) {
|
|
1709
|
-
var _a;
|
|
1710
|
-
const branchShape = getBranchShapeByMindElement(board, parent.origin);
|
|
1711
|
-
const branchColor = defaultStroke || ((_a = parent.origin) === null || _a === void 0 ? void 0 : _a.branchColor) || getBranchColorByMindElement(board, node.origin);
|
|
1712
|
-
const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board, parent.origin);
|
|
1713
|
-
const hasStraightLine = branchShape === BranchShape.polyline ? true : !parent.origin.isRoot;
|
|
1714
|
-
const parentShape = getShapeByElement(board, parent.origin);
|
|
1715
|
-
const shape = getShapeByElement(board, node.origin);
|
|
1716
|
-
const hasUnderlineShape = shape === MindElementShape.underline;
|
|
1717
|
-
const hasUnderlineShapeOfParent = parentShape === MindElementShape.underline;
|
|
1718
|
-
const nodeClient = getRectangleByNode(node);
|
|
1719
|
-
const parentClient = getRectangleByNode(parent);
|
|
1720
|
-
const linkDirection = getLayoutDirection(node, isHorizontal);
|
|
1721
|
-
// ① ensure begin placement and end placement
|
|
1722
|
-
// begin placement represent parent connector position and end placement represent child connector
|
|
1723
|
-
const beginPlacement = [HorizontalPlacement.right, VerticalPlacement.middle];
|
|
1724
|
-
const endPlacement = [HorizontalPlacement.left, VerticalPlacement.middle];
|
|
1725
|
-
transformPlacement(beginPlacement, linkDirection);
|
|
1726
|
-
transformPlacement(endPlacement, linkDirection);
|
|
1727
|
-
// underline shape and horizontal
|
|
1728
|
-
if (isHorizontal && hasUnderlineShapeOfParent && !parent.origin.isRoot) {
|
|
1729
|
-
beginPlacement[1] = VerticalPlacement.bottom;
|
|
1730
|
-
}
|
|
1731
|
-
if (isHorizontal && hasUnderlineShape) {
|
|
1732
|
-
endPlacement[1] = VerticalPlacement.bottom;
|
|
1733
|
-
}
|
|
1734
|
-
let beginPoint = getPointByPlacement(parentClient, beginPlacement);
|
|
1735
|
-
let endPoint = getPointByPlacement(nodeClient, endPlacement);
|
|
1736
|
-
// ② 确定凸出直线,从起始点开始画一条直线,从直线的结束位置绘制曲线,保证收起图标可以完美覆盖起始连线,根节点不需要这条直线
|
|
1737
|
-
// 绘制贝塞尔曲线要求,需要增加三个点,正常两个点就可以确定这条直线
|
|
1738
|
-
const straightLineDistance = 8;
|
|
1739
|
-
const beginPoint2 = hasStraightLine ? moveXOfPoint(beginPoint, straightLineDistance, linkDirection) : beginPoint;
|
|
1740
|
-
let straightLine = hasStraightLine ? [beginPoint, beginPoint2, beginPoint2] : [];
|
|
1741
|
-
// ③ 确定曲线
|
|
1742
|
-
const beginBufferDistance = (parent.hGap + node.hGap) / 3;
|
|
1743
|
-
const endBufferDistance = -(parent.hGap + node.hGap) / 2.4;
|
|
1744
|
-
let curve = [
|
|
1745
|
-
beginPoint2,
|
|
1746
|
-
moveXOfPoint(beginPoint2, beginBufferDistance, linkDirection),
|
|
1747
|
-
moveXOfPoint(endPoint, endBufferDistance, linkDirection),
|
|
1748
|
-
endPoint
|
|
1749
|
-
];
|
|
1750
|
-
// ④ 下划线绘制,underline shape and horizontal
|
|
1751
|
-
const underlineEnd = moveXOfPoint(endPoint, nodeClient.width, linkDirection);
|
|
1752
|
-
const underline = hasUnderlineShape && isHorizontal ? [underlineEnd, underlineEnd, underlineEnd] : [];
|
|
1753
|
-
const points = pointsOnBezierCurves([...straightLine, ...curve, ...underline]);
|
|
1754
|
-
if (branchShape === BranchShape.polyline) {
|
|
1755
|
-
const buffer = 8;
|
|
1756
|
-
const movePoint = moveXOfPoint(beginPoint2, buffer, linkDirection);
|
|
1757
|
-
const polylinePoints = [
|
|
1758
|
-
...straightLine,
|
|
1759
|
-
movePoint,
|
|
1760
|
-
isHorizontal ? [movePoint[0], endPoint[1]] : [endPoint[0], movePoint[1]],
|
|
1761
|
-
endPoint,
|
|
1762
|
-
...underline
|
|
1763
|
-
];
|
|
1764
|
-
return drawLinearPath(polylinePoints, { stroke: branchColor, strokeWidth: branchWidth });
|
|
1765
|
-
}
|
|
1766
|
-
return PlaitBoard.getRoughSVG(board).curve(points, { stroke: branchColor, strokeWidth: branchWidth });
|
|
1767
|
-
}
|
|
1768
|
-
|
|
1769
|
-
function drawLink(board, parentNode, node, isHorizontal, needDrawUnderline, defaultStroke, defaultStrokeWidth) {
|
|
1770
|
-
return MindElement.isIndentedLayout(parentNode.origin)
|
|
1771
|
-
? drawIndentedLink(board, parentNode, node, defaultStroke, needDrawUnderline, defaultStrokeWidth)
|
|
1772
|
-
: drawLogicLink(board, parentNode, node, isHorizontal, defaultStroke, defaultStrokeWidth);
|
|
1773
|
-
}
|
|
1774
|
-
|
|
1775
|
-
const drawFakeDragNode = (board, element, offsetX, offsetY) => {
|
|
1776
|
-
const activeComponent = PlaitElement.getComponent(element);
|
|
1777
|
-
const dragFakeNodeG = createG();
|
|
1778
|
-
dragFakeNodeG.classList.add('dragging', 'fake-node', 'plait-board-attached');
|
|
1779
|
-
const fakeDraggingNode = Object.assign(Object.assign({}, activeComponent.node), { children: [], x: activeComponent.node.x + offsetX, y: activeComponent.node.y + offsetY });
|
|
1780
|
-
const textRectangle = getTopicRectangleByNode(board, activeComponent.node);
|
|
1781
|
-
const fakeNodeG = drawRoundRectangleByNode(board, fakeDraggingNode);
|
|
1782
|
-
const richtextG = activeComponent.textManage.g.cloneNode(true);
|
|
1783
|
-
updateForeignObject(richtextG, textRectangle.width, textRectangle.height, textRectangle.x + offsetX, textRectangle.y + offsetY);
|
|
1784
|
-
dragFakeNodeG === null || dragFakeNodeG === void 0 ? void 0 : dragFakeNodeG.append(fakeNodeG);
|
|
1785
|
-
dragFakeNodeG === null || dragFakeNodeG === void 0 ? void 0 : dragFakeNodeG.append(richtextG);
|
|
1786
|
-
// draw emojis
|
|
1787
|
-
if (MindElement.hasEmojis(element)) {
|
|
1788
|
-
const fakeEmojisG = activeComponent.nodeEmojisDrawer.g.cloneNode(true);
|
|
1789
|
-
const foreignRectangle = getEmojiForeignRectangle(board, element);
|
|
1790
|
-
updateForeignObject(fakeEmojisG, foreignRectangle.width, foreignRectangle.height, foreignRectangle.x + offsetX, foreignRectangle.y + offsetY);
|
|
1791
|
-
dragFakeNodeG === null || dragFakeNodeG === void 0 ? void 0 : dragFakeNodeG.append(fakeEmojisG);
|
|
1792
|
-
}
|
|
1793
|
-
if (MindElement.hasImage(element)) {
|
|
1794
|
-
const fakeImageG = activeComponent.imageDrawer.g.cloneNode(true);
|
|
1795
|
-
const foreignRectangle = getImageForeignRectangle(board, element);
|
|
1796
|
-
updateForeignObject(fakeImageG, foreignRectangle.width, foreignRectangle.height, foreignRectangle.x + offsetX, foreignRectangle.y + offsetY);
|
|
1797
|
-
dragFakeNodeG === null || dragFakeNodeG === void 0 ? void 0 : dragFakeNodeG.append(fakeImageG);
|
|
1798
|
-
}
|
|
1799
|
-
return dragFakeNodeG;
|
|
1800
|
-
};
|
|
1801
|
-
const drawFakeDropNode = (board, dropTarget, path) => {
|
|
1802
|
-
const target = dropTarget.target;
|
|
1803
|
-
const fakeDropNodeG = createG();
|
|
1804
|
-
const parent = PlaitNode.get(board, Path.parent(path));
|
|
1805
|
-
const layout = MindQueries.getLayoutByElement(parent);
|
|
1806
|
-
const isHorizontal = isHorizontalLayout(layout);
|
|
1807
|
-
const { hasNextNode, hasPreviousNode } = hasPreviousOrNextOfDropPath(parent, dropTarget, path);
|
|
1808
|
-
const width = 30;
|
|
1809
|
-
const height = 12;
|
|
1810
|
-
let fakeNode, centerPoint, basicNode, linkDirection;
|
|
1811
|
-
if (!hasPreviousNode && !hasNextNode) {
|
|
1812
|
-
const parentNode = MindElement.getNode(parent);
|
|
1813
|
-
const parentRect = getRectangleByNode(parentNode);
|
|
1814
|
-
linkDirection = getLayoutDirection(parentNode, isHorizontal);
|
|
1815
|
-
basicNode = parentNode;
|
|
1816
|
-
if (PlaitMind.isMind(target) && isStandardLayout(layout)) {
|
|
1817
|
-
if (dropTarget.detectResult === 'left') {
|
|
1818
|
-
linkDirection = LayoutDirection.left;
|
|
1819
|
-
basicNode.left = true;
|
|
1820
|
-
}
|
|
1821
|
-
else {
|
|
1822
|
-
linkDirection = LayoutDirection.right;
|
|
1823
|
-
basicNode.left = false;
|
|
1824
|
-
}
|
|
1825
|
-
}
|
|
1826
|
-
const placement = [HorizontalPlacement.right, VerticalPlacement.middle];
|
|
1827
|
-
transformPlacement(placement, linkDirection);
|
|
1828
|
-
const parentCenterPoint = getPointByPlacement(parentRect, placement);
|
|
1829
|
-
if (isIndentedLayout(layout)) {
|
|
1830
|
-
const placement = [
|
|
1831
|
-
HorizontalPlacement.center,
|
|
1832
|
-
isTopLayout(layout) ? VerticalPlacement.top : VerticalPlacement.bottom
|
|
1833
|
-
];
|
|
1834
|
-
const parentCenterPoint = getPointByPlacement(parentRect, placement);
|
|
1835
|
-
centerPoint = moveXOfPoint(parentCenterPoint, height, linkDirection);
|
|
1836
|
-
centerPoint[1] = isTopLayout(layout) ? centerPoint[1] - height : centerPoint[1] + height;
|
|
1837
|
-
}
|
|
1838
|
-
else {
|
|
1839
|
-
centerPoint = moveXOfPoint(parentCenterPoint, width, linkDirection);
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
|
-
else if (!hasPreviousNode && hasNextNode) {
|
|
1843
|
-
const nextElement = PlaitNode.get(board, path);
|
|
1844
|
-
basicNode = MindElement.getNode(nextElement);
|
|
1845
|
-
const nextRect = getRectangleByNode(basicNode);
|
|
1846
|
-
linkDirection = getLayoutDirection(basicNode, isHorizontal);
|
|
1847
|
-
const placement = [HorizontalPlacement.left, VerticalPlacement.top];
|
|
1848
|
-
transformPlacement(placement, linkDirection);
|
|
1849
|
-
let offset = -height;
|
|
1850
|
-
if (MindElement.isIndentedLayout(parent)) {
|
|
1851
|
-
offset = isTopLayout(layout) ? offset / 2 + basicNode.height - basicNode.vGap : 0;
|
|
1852
|
-
}
|
|
1853
|
-
centerPoint = getPointByPlacement(nextRect, placement);
|
|
1854
|
-
centerPoint = moveYOfPoint(centerPoint, offset, linkDirection);
|
|
1855
|
-
}
|
|
1856
|
-
else if (hasPreviousNode && !hasNextNode) {
|
|
1857
|
-
const previousElement = PlaitNode.get(board, Path.previous(path));
|
|
1858
|
-
basicNode = MindElement.getNode(previousElement);
|
|
1859
|
-
const previousRect = getRectangleByNode(basicNode);
|
|
1860
|
-
linkDirection = getLayoutDirection(basicNode, isHorizontal);
|
|
1861
|
-
const placement = [HorizontalPlacement.left, VerticalPlacement.bottom];
|
|
1862
|
-
transformPlacement(placement, linkDirection);
|
|
1863
|
-
let offset = height;
|
|
1864
|
-
if (MindElement.isIndentedLayout(parent)) {
|
|
1865
|
-
offset = isTopLayout(layout) ? -offset - (basicNode.height - basicNode.vGap) : offset;
|
|
1866
|
-
}
|
|
1867
|
-
centerPoint = getPointByPlacement(previousRect, placement);
|
|
1868
|
-
centerPoint = moveYOfPoint(centerPoint, offset, linkDirection);
|
|
1869
|
-
}
|
|
1870
|
-
else {
|
|
1871
|
-
const previousElement = PlaitNode.get(board, Path.previous(path));
|
|
1872
|
-
basicNode = MindElement.getNode(previousElement);
|
|
1873
|
-
const previousRect = getRectangleByNode(basicNode);
|
|
1874
|
-
const nextElement = PlaitNode.get(board, path);
|
|
1875
|
-
const nextNode = MindElement.getNode(nextElement);
|
|
1876
|
-
const nextRect = getRectangleByNode(nextNode);
|
|
1877
|
-
const beginPlacement = [HorizontalPlacement.left, VerticalPlacement.bottom];
|
|
1878
|
-
const endPlacement = [HorizontalPlacement.left, VerticalPlacement.top];
|
|
1879
|
-
linkDirection = getLayoutDirection(basicNode, isHorizontal);
|
|
1880
|
-
transformPlacement(beginPlacement, linkDirection);
|
|
1881
|
-
transformPlacement(endPlacement, linkDirection);
|
|
1882
|
-
const previousPoint = getPointByPlacement(previousRect, beginPlacement);
|
|
1883
|
-
const nextPoint = getPointByPlacement(nextRect, endPlacement);
|
|
1884
|
-
centerPoint = [(previousPoint[0] + nextPoint[0]) / 2, (previousPoint[1] + nextPoint[1]) / 2];
|
|
1885
|
-
}
|
|
1886
|
-
let cornerPoint = centerPoint, oppositePoint = centerPoint;
|
|
1887
|
-
const offsetY = isHorizontal ? height : width;
|
|
1888
|
-
const offsetX = isHorizontal ? width : height;
|
|
1889
|
-
cornerPoint = moveYOfPoint(cornerPoint, -offsetY / 2, linkDirection);
|
|
1890
|
-
oppositePoint = moveYOfPoint(oppositePoint, offsetY / 2, linkDirection);
|
|
1891
|
-
oppositePoint = moveXOfPoint(oppositePoint, offsetX, linkDirection);
|
|
1892
|
-
const x = Math.min(cornerPoint[0], oppositePoint[0]);
|
|
1893
|
-
const y = Math.min(cornerPoint[1], oppositePoint[1]);
|
|
1894
|
-
fakeNode = Object.assign(Object.assign({}, basicNode), { x,
|
|
1895
|
-
y,
|
|
1896
|
-
width,
|
|
1897
|
-
height, hGap: MindElement.isIndentedLayout(parent) ? BASE * 4 + (basicNode.origin.strokeWidth || STROKE_WIDTH) : 0, vGap: MindElement.isIndentedLayout(parent) ? BASE : 0 });
|
|
1898
|
-
const fakeRectangleG = drawRoundRectangle(PlaitBoard.getRoughSVG(board), fakeNode.x, fakeNode.y, fakeNode.x + width, fakeNode.y + height, {
|
|
1899
|
-
stroke: PRIMARY_COLOR,
|
|
1900
|
-
strokeWidth: 2,
|
|
1901
|
-
fill: PRIMARY_COLOR,
|
|
1902
|
-
fillStyle: 'solid'
|
|
1903
|
-
});
|
|
1904
|
-
const link = drawLink(board, MindElement.getNode(parent), fakeNode, isHorizontal, false, PRIMARY_COLOR, STROKE_WIDTH);
|
|
1905
|
-
fakeDropNodeG === null || fakeDropNodeG === void 0 ? void 0 : fakeDropNodeG.appendChild(link);
|
|
1906
|
-
fakeDropNodeG === null || fakeDropNodeG === void 0 ? void 0 : fakeDropNodeG.appendChild(fakeRectangleG);
|
|
1907
|
-
return fakeDropNodeG;
|
|
1908
|
-
};
|
|
1909
|
-
|
|
1910
|
-
var AbstractHandlePosition;
|
|
1911
|
-
(function (AbstractHandlePosition) {
|
|
1912
|
-
AbstractHandlePosition["start"] = "start";
|
|
1913
|
-
AbstractHandlePosition["end"] = "end";
|
|
1914
|
-
})(AbstractHandlePosition || (AbstractHandlePosition = {}));
|
|
1915
|
-
var AbstractResizeState;
|
|
1916
|
-
(function (AbstractResizeState) {
|
|
1917
|
-
AbstractResizeState["start"] = "start";
|
|
1918
|
-
AbstractResizeState["resizing"] = "resizing";
|
|
1919
|
-
AbstractResizeState["end"] = "end";
|
|
1920
|
-
})(AbstractResizeState || (AbstractResizeState = {}));
|
|
1921
|
-
|
|
1922
|
-
const getRectangleByResizingLocation = (abstractRectangle, location, activeHandlePosition, isHorizontal) => {
|
|
1923
|
-
if (isHorizontal) {
|
|
1924
|
-
if (activeHandlePosition === AbstractHandlePosition.start) {
|
|
1925
|
-
return Object.assign(Object.assign({}, abstractRectangle), { y: location, height: abstractRectangle.height + abstractRectangle.y - location });
|
|
1926
|
-
}
|
|
1927
|
-
else {
|
|
1928
|
-
return Object.assign(Object.assign({}, abstractRectangle), { height: location - abstractRectangle.y });
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
else {
|
|
1932
|
-
if (activeHandlePosition === AbstractHandlePosition.start) {
|
|
1933
|
-
return Object.assign(Object.assign({}, abstractRectangle), { x: location, width: abstractRectangle.width + abstractRectangle.x - location });
|
|
1934
|
-
}
|
|
1935
|
-
else {
|
|
1936
|
-
return Object.assign(Object.assign({}, abstractRectangle), { width: location - abstractRectangle.x });
|
|
1937
|
-
}
|
|
1938
|
-
}
|
|
1939
|
-
};
|
|
1940
|
-
const getLocationScope = (board, handlePosition, parentChildren, element, parent, isHorizontal) => {
|
|
1941
|
-
const node = MindElement.getNode(element);
|
|
1942
|
-
const { start, end } = getCorrectStartEnd(node.origin, parent);
|
|
1943
|
-
const startNode = parentChildren[start];
|
|
1944
|
-
const endNode = parentChildren[end];
|
|
1945
|
-
if (handlePosition === AbstractHandlePosition.start) {
|
|
1946
|
-
const abstractNode = parentChildren.filter(child => AbstractNode.isAbstract(child) && child.end < element.start);
|
|
1947
|
-
let minNode;
|
|
1948
|
-
if (abstractNode.length) {
|
|
1949
|
-
const index = abstractNode
|
|
1950
|
-
.map(node => {
|
|
1951
|
-
const { end } = getCorrectStartEnd(node, parent);
|
|
1952
|
-
return end;
|
|
1953
|
-
})
|
|
1954
|
-
.sort((a, b) => b - a)[0];
|
|
1955
|
-
minNode = parentChildren[index + 1];
|
|
1956
|
-
}
|
|
1957
|
-
else {
|
|
1958
|
-
minNode = parentChildren[0];
|
|
1959
|
-
}
|
|
1960
|
-
const minNodeRectangle = getRectangleByElements(board, [minNode], true);
|
|
1961
|
-
const endNodeRectangle = getRectangleByElements(board, [endNode], false);
|
|
1962
|
-
if (isHorizontal) {
|
|
1963
|
-
return {
|
|
1964
|
-
max: endNodeRectangle.y - ABSTRACT_INCLUDED_OUTLINE_OFFSET,
|
|
1965
|
-
min: minNodeRectangle.y - ABSTRACT_INCLUDED_OUTLINE_OFFSET
|
|
1966
|
-
};
|
|
1967
|
-
}
|
|
1968
|
-
else {
|
|
1969
|
-
return {
|
|
1970
|
-
max: endNodeRectangle.x - ABSTRACT_INCLUDED_OUTLINE_OFFSET,
|
|
1971
|
-
min: minNodeRectangle.x - ABSTRACT_INCLUDED_OUTLINE_OFFSET
|
|
1972
|
-
};
|
|
1973
|
-
}
|
|
1974
|
-
}
|
|
1975
|
-
else {
|
|
1976
|
-
const abstractNode = parentChildren.filter(child => AbstractNode.isAbstract(child) && child.start > element.end);
|
|
1977
|
-
let maxNode;
|
|
1978
|
-
if (abstractNode.length) {
|
|
1979
|
-
const index = abstractNode
|
|
1980
|
-
.map(node => {
|
|
1981
|
-
const { start } = getCorrectStartEnd(node, parent);
|
|
1982
|
-
return start;
|
|
1983
|
-
})
|
|
1984
|
-
.sort((a, b) => a - b)[0];
|
|
1985
|
-
maxNode = parentChildren[index - 1];
|
|
1986
|
-
}
|
|
1987
|
-
else {
|
|
1988
|
-
const children = parentChildren.filter(child => !AbstractNode.isAbstract(child));
|
|
1989
|
-
maxNode = parentChildren[children.length - 1];
|
|
1990
|
-
}
|
|
1991
|
-
const maxNodeRectangle = getRectangleByElements(board, [maxNode], true);
|
|
1992
|
-
const startNodeRectangle = getRectangleByElements(board, [startNode], false);
|
|
1993
|
-
if (isHorizontal) {
|
|
1994
|
-
return {
|
|
1995
|
-
max: maxNodeRectangle.y + maxNodeRectangle.height + ABSTRACT_INCLUDED_OUTLINE_OFFSET,
|
|
1996
|
-
min: startNodeRectangle.y + startNodeRectangle.height + ABSTRACT_INCLUDED_OUTLINE_OFFSET
|
|
1997
|
-
};
|
|
1998
|
-
}
|
|
1999
|
-
else {
|
|
2000
|
-
return {
|
|
2001
|
-
max: maxNodeRectangle.x + maxNodeRectangle.width + ABSTRACT_INCLUDED_OUTLINE_OFFSET,
|
|
2002
|
-
min: startNodeRectangle.x + startNodeRectangle.width + ABSTRACT_INCLUDED_OUTLINE_OFFSET
|
|
2003
|
-
};
|
|
2004
|
-
}
|
|
2005
|
-
}
|
|
2006
|
-
};
|
|
2007
|
-
const getHitAbstractHandle = (board, element, point) => {
|
|
2008
|
-
const nodeLayout = MindQueries.getCorrectLayoutByElement(board, element);
|
|
2009
|
-
const isHorizontal = isHorizontalLayout(nodeLayout);
|
|
2010
|
-
const parentElement = MindElement.getParent(element);
|
|
2011
|
-
const includedElements = parentElement.children.slice(element.start, element.end + 1);
|
|
2012
|
-
let abstractRectangle = getRectangleByElements(board, includedElements, true);
|
|
2013
|
-
abstractRectangle = RectangleClient.getOutlineRectangle(abstractRectangle, -ABSTRACT_INCLUDED_OUTLINE_OFFSET);
|
|
2014
|
-
const startHandleRec = getAbstractHandleRectangle(abstractRectangle, isHorizontal, AbstractHandlePosition.start);
|
|
2015
|
-
const endHandleRec = getAbstractHandleRectangle(abstractRectangle, isHorizontal, AbstractHandlePosition.end);
|
|
2016
|
-
const pointRec = RectangleClient.toRectangleClient([point, point]);
|
|
2017
|
-
if (RectangleClient.isHit(pointRec, startHandleRec))
|
|
2018
|
-
return AbstractHandlePosition.start;
|
|
2019
|
-
if (RectangleClient.isHit(pointRec, endHandleRec))
|
|
2020
|
-
return AbstractHandlePosition.end;
|
|
2021
|
-
return undefined;
|
|
2022
|
-
};
|
|
2023
|
-
const getAbstractHandleRectangle = (rectangle, isHorizontal, position) => {
|
|
2024
|
-
let result;
|
|
2025
|
-
if (position === AbstractHandlePosition.start) {
|
|
2026
|
-
const location = isHorizontal ? rectangle.y : rectangle.x;
|
|
2027
|
-
result = getRectangleByResizingLocation(rectangle, location + ABSTRACT_HANDLE_MASK_WIDTH / 2, AbstractHandlePosition.end, isHorizontal);
|
|
2028
|
-
result = getRectangleByResizingLocation(result, location - ABSTRACT_HANDLE_MASK_WIDTH / 2, position, isHorizontal);
|
|
2029
|
-
}
|
|
2030
|
-
else {
|
|
2031
|
-
const location = isHorizontal ? rectangle.y + rectangle.height : rectangle.x + rectangle.width;
|
|
2032
|
-
result = getRectangleByResizingLocation(rectangle, location - ABSTRACT_HANDLE_MASK_WIDTH / 2, AbstractHandlePosition.start, isHorizontal);
|
|
2033
|
-
result = getRectangleByResizingLocation(result, location + ABSTRACT_HANDLE_MASK_WIDTH / 2, position, isHorizontal);
|
|
2034
|
-
}
|
|
2035
|
-
return result;
|
|
2036
|
-
};
|
|
2037
|
-
function findLocationLeftIndex(board, parentChildren, location, isHorizontal) {
|
|
2038
|
-
const children = parentChildren.filter(child => {
|
|
2039
|
-
return !AbstractNode.isAbstract(child);
|
|
2040
|
-
});
|
|
2041
|
-
const recArray = children.map(child => {
|
|
2042
|
-
return getRectangleByElements(board, [child], false);
|
|
2043
|
-
});
|
|
2044
|
-
const firstRec = getRectangleByElements(board, [children[0]], true);
|
|
2045
|
-
const fakeLeftRec = {
|
|
2046
|
-
x: firstRec.x - firstRec.width,
|
|
2047
|
-
y: firstRec.y - firstRec.height,
|
|
2048
|
-
width: firstRec.width,
|
|
2049
|
-
height: firstRec.height
|
|
2050
|
-
};
|
|
2051
|
-
const lastRec = getRectangleByElements(board, [children[children.length - 1]], true);
|
|
2052
|
-
const fakeRightRec = {
|
|
2053
|
-
x: lastRec.x + lastRec.width,
|
|
2054
|
-
y: lastRec.y + lastRec.height,
|
|
2055
|
-
width: lastRec.width,
|
|
2056
|
-
height: lastRec.height
|
|
2057
|
-
};
|
|
2058
|
-
recArray.push(fakeRightRec);
|
|
2059
|
-
recArray.unshift(fakeLeftRec);
|
|
2060
|
-
for (let i = 0; i < recArray.length - 1; i++) {
|
|
2061
|
-
const recXOrY = isHorizontal ? recArray[i].y : recArray[i].x;
|
|
2062
|
-
const recWidthOrHeight = isHorizontal ? recArray[i].height : recArray[i].width;
|
|
2063
|
-
if (location >= recXOrY + recWidthOrHeight / 2 &&
|
|
2064
|
-
location <= recArray[i + 1][isHorizontal ? 'y' : 'x'] + recArray[i + 1][isHorizontal ? 'height' : 'width'] / 2) {
|
|
2065
|
-
return i - 1;
|
|
2066
|
-
}
|
|
2067
|
-
}
|
|
2068
|
-
return 0;
|
|
2069
|
-
}
|
|
2070
|
-
function handleTouchedAbstract(board, touchedAbstract, endPoint) {
|
|
2071
|
-
let touchedHandle;
|
|
2072
|
-
const abstract = getSelectedElements(board).filter(element => AbstractNode.isAbstract(element)).find(element => {
|
|
2073
|
-
touchedHandle = getHitAbstractHandle(board, element, endPoint);
|
|
2074
|
-
return touchedHandle;
|
|
2075
|
-
});
|
|
2076
|
-
if (touchedAbstract === abstract) {
|
|
2077
|
-
return touchedAbstract;
|
|
2078
|
-
}
|
|
2079
|
-
if (touchedAbstract) {
|
|
2080
|
-
const component = PlaitElement.getComponent(touchedAbstract);
|
|
2081
|
-
component.activeDrawer.updateAbstractOutline(touchedAbstract);
|
|
2082
|
-
touchedAbstract = undefined;
|
|
2083
|
-
}
|
|
2084
|
-
if (abstract) {
|
|
2085
|
-
touchedAbstract = abstract;
|
|
2086
|
-
const component = PlaitElement.getComponent(touchedAbstract);
|
|
2087
|
-
component.activeDrawer.updateAbstractOutline(touchedAbstract, touchedHandle);
|
|
2088
|
-
}
|
|
2089
|
-
return touchedAbstract;
|
|
2090
|
-
}
|
|
2091
|
-
|
|
2092
|
-
const isInRightBranchOfStandardLayout = (selectedElement) => {
|
|
2093
|
-
const parentElement = MindElement.findParent(selectedElement);
|
|
2094
|
-
if (parentElement) {
|
|
2095
|
-
const nodeIndex = parentElement.children.findIndex(item => item.id === selectedElement.id);
|
|
2096
|
-
if (parentElement.isRoot &&
|
|
2097
|
-
getRootLayout(parentElement) === MindLayoutType.standard &&
|
|
2098
|
-
parentElement.rightNodeCount &&
|
|
2099
|
-
nodeIndex <= parentElement.rightNodeCount - 1) {
|
|
2100
|
-
return true;
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
return false;
|
|
2104
|
-
};
|
|
2105
|
-
const insertElementHandleRightNodeCount = (board, path, insertCount, effectedRightNodeCount = []) => {
|
|
2106
|
-
let index = effectedRightNodeCount.findIndex(ref => Path.equals(ref.path, path));
|
|
2107
|
-
const mind = PlaitNode.get(board, path);
|
|
2108
|
-
if (index === -1) {
|
|
2109
|
-
effectedRightNodeCount.push({ path, rightNodeCount: mind.rightNodeCount + insertCount });
|
|
2110
|
-
}
|
|
2111
|
-
else {
|
|
2112
|
-
effectedRightNodeCount[index].rightNodeCount += insertCount;
|
|
2113
|
-
}
|
|
2114
|
-
return effectedRightNodeCount;
|
|
2115
|
-
};
|
|
2116
|
-
const deleteElementsHandleRightNodeCount = (board, deletableElements, effectedRightNodeCount = []) => {
|
|
2117
|
-
deletableElements.forEach(element => {
|
|
2118
|
-
if (isInRightBranchOfStandardLayout(element)) {
|
|
2119
|
-
const mind = MindElement.getParent(element);
|
|
2120
|
-
const path = PlaitBoard.findPath(board, mind);
|
|
2121
|
-
let index = effectedRightNodeCount.findIndex(ref => Path.equals(ref.path, path));
|
|
2122
|
-
if (index === -1) {
|
|
2123
|
-
effectedRightNodeCount.push({ path, rightNodeCount: mind.rightNodeCount - 1 });
|
|
2124
|
-
}
|
|
2125
|
-
else {
|
|
2126
|
-
effectedRightNodeCount[index].rightNodeCount -= 1;
|
|
2127
|
-
}
|
|
2128
|
-
}
|
|
2129
|
-
});
|
|
2130
|
-
return effectedRightNodeCount;
|
|
2131
|
-
};
|
|
2132
|
-
|
|
2133
|
-
const getLayoutOptions = (board) => {
|
|
2134
|
-
function getMainAxle(element, parent) {
|
|
2135
|
-
const strokeWidth = element.strokeWidth || STROKE_WIDTH;
|
|
2136
|
-
if (element.isRoot) {
|
|
2137
|
-
return BASE * 12;
|
|
2138
|
-
}
|
|
2139
|
-
if (parent && parent.isRoot()) {
|
|
2140
|
-
return BASE * 3 + strokeWidth / 2;
|
|
2141
|
-
}
|
|
2142
|
-
return BASE * 3 + strokeWidth / 2;
|
|
2143
|
-
}
|
|
2144
|
-
function getSecondAxle(element, parent) {
|
|
2145
|
-
const strokeWidth = element.strokeWidth || STROKE_WIDTH;
|
|
2146
|
-
if (element.isRoot) {
|
|
2147
|
-
return BASE * 10 + strokeWidth / 2;
|
|
2148
|
-
}
|
|
2149
|
-
return BASE * 6 + strokeWidth / 2;
|
|
2150
|
-
}
|
|
2151
|
-
return {
|
|
2152
|
-
getHeight(element) {
|
|
2153
|
-
return NodeSpace.getNodeHeight(board, element);
|
|
2154
|
-
},
|
|
2155
|
-
getWidth(element) {
|
|
2156
|
-
return NodeSpace.getNodeWidth(board, element);
|
|
2157
|
-
},
|
|
2158
|
-
getHorizontalGap(element, parent) {
|
|
2159
|
-
const _layout = (parent && parent.layout) || getRootLayout(element);
|
|
2160
|
-
const isHorizontal = isHorizontalLayout(_layout);
|
|
2161
|
-
const strokeWidth = element.strokeWidth || STROKE_WIDTH;
|
|
2162
|
-
if (isIndentedLayout(_layout)) {
|
|
2163
|
-
return BASE * 4 + strokeWidth;
|
|
2164
|
-
}
|
|
2165
|
-
if (!isHorizontal) {
|
|
2166
|
-
return getMainAxle(element, parent);
|
|
2167
|
-
}
|
|
2168
|
-
else {
|
|
2169
|
-
return getSecondAxle(element, parent);
|
|
2170
|
-
}
|
|
2171
|
-
},
|
|
2172
|
-
getVerticalGap(element, parent) {
|
|
2173
|
-
const _layout = (parent && parent.layout) || getRootLayout(element);
|
|
2174
|
-
if (isIndentedLayout(_layout)) {
|
|
2175
|
-
return BASE;
|
|
2176
|
-
}
|
|
2177
|
-
const isHorizontal = isHorizontalLayout(_layout);
|
|
2178
|
-
if (isHorizontal) {
|
|
2179
|
-
return getMainAxle(element, parent);
|
|
2180
|
-
}
|
|
2181
|
-
else {
|
|
2182
|
-
return getSecondAxle(element, parent);
|
|
2183
|
-
}
|
|
2184
|
-
},
|
|
2185
|
-
getVerticalConnectingPosition(element, parent) {
|
|
2186
|
-
if (element.shape === MindElementShape.underline && parent && isHorizontalLogicLayout(parent.layout)) {
|
|
2187
|
-
return ConnectingPosition.bottom;
|
|
2188
|
-
}
|
|
2189
|
-
return undefined;
|
|
2190
|
-
},
|
|
2191
|
-
getExtendHeight(node) {
|
|
2192
|
-
return BASE * 6;
|
|
2193
|
-
},
|
|
2194
|
-
getIndentedCrossLevelGap() {
|
|
2195
|
-
return BASE * 2;
|
|
2196
|
-
}
|
|
2197
|
-
};
|
|
2198
|
-
};
|
|
2199
|
-
|
|
2200
|
-
/**
|
|
2201
|
-
* get correctly layout:
|
|
2202
|
-
* 1. root is standard -> left or right
|
|
2203
|
-
* 2. correct layout by incorrect layout direction
|
|
2204
|
-
* @param element
|
|
2205
|
-
*/
|
|
2206
|
-
const getCorrectLayoutByElement = (board, element) => {
|
|
2207
|
-
const ancestors = MindElement.getAncestors(board, element);
|
|
2208
|
-
ancestors.unshift(element);
|
|
2209
|
-
const root = ancestors[ancestors.length - 1];
|
|
2210
|
-
let rootLayout = getRootLayout(root);
|
|
2211
|
-
if (PlaitMind.isMind(element)) {
|
|
2212
|
-
return rootLayout;
|
|
2213
|
-
}
|
|
2214
|
-
const node = MindElement.getNode(element);
|
|
2215
|
-
let correctRootLayout = rootLayout;
|
|
2216
|
-
if (rootLayout === MindLayoutType.standard) {
|
|
2217
|
-
correctRootLayout = node.left ? MindLayoutType.left : MindLayoutType.right;
|
|
2218
|
-
}
|
|
2219
|
-
let layout = null;
|
|
2220
|
-
const elementWithLayout = ancestors.find(value => value.layout || AbstractNode.isAbstract(value));
|
|
2221
|
-
if (elementWithLayout) {
|
|
2222
|
-
if (AbstractNode.isAbstract(elementWithLayout)) {
|
|
2223
|
-
const parent = MindElement.getParent(elementWithLayout);
|
|
2224
|
-
const parentLayout = getCorrectLayoutByElement(board, parent);
|
|
2225
|
-
layout = getAbstractLayout(parentLayout);
|
|
2226
|
-
}
|
|
2227
|
-
else {
|
|
2228
|
-
layout = elementWithLayout === null || elementWithLayout === void 0 ? void 0 : elementWithLayout.layout;
|
|
2229
|
-
}
|
|
2230
|
-
}
|
|
2231
|
-
if (layout === MindLayoutType.standard || !layout) {
|
|
2232
|
-
return correctRootLayout;
|
|
2233
|
-
}
|
|
2234
|
-
else {
|
|
2235
|
-
const incorrectDirection = getInCorrectLayoutDirection(correctRootLayout, layout);
|
|
2236
|
-
if (incorrectDirection) {
|
|
2237
|
-
return correctLayoutByDirection(layout, incorrectDirection);
|
|
2238
|
-
}
|
|
2239
|
-
else {
|
|
2240
|
-
return layout;
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
|
-
};
|
|
2244
|
-
|
|
2245
|
-
const getBranchLayouts = (board, element) => {
|
|
2246
|
-
const layouts = [];
|
|
2247
|
-
if (element.layout) {
|
|
2248
|
-
// TODO: getCorrectLayoutByElement 含有递归操作,getBranchLayouts 本身也有递归操作,有待优化
|
|
2249
|
-
layouts.unshift(getCorrectLayoutByElement(board, element));
|
|
2250
|
-
}
|
|
2251
|
-
let parent = MindElement.findParent(element);
|
|
2252
|
-
while (parent) {
|
|
2253
|
-
if (parent.layout) {
|
|
2254
|
-
layouts.unshift(parent.layout);
|
|
2255
|
-
}
|
|
2256
|
-
parent = MindElement.findParent(parent);
|
|
2257
|
-
}
|
|
2258
|
-
return layouts;
|
|
2259
|
-
};
|
|
2260
|
-
|
|
2261
|
-
const getAvailableSubLayoutsByElement = (board, element) => {
|
|
2262
|
-
const parentElement = MindElement.findParent(element);
|
|
2263
|
-
if (parentElement) {
|
|
2264
|
-
const branchLayouts = getBranchLayouts(board, parentElement);
|
|
2265
|
-
if (branchLayouts[0] === MindLayoutType.standard) {
|
|
2266
|
-
const node = MindElement.getNode(element);
|
|
2267
|
-
branchLayouts[0] = node.left ? MindLayoutType.left : MindLayoutType.right;
|
|
2268
|
-
}
|
|
2269
|
-
const currentLayoutDirections = getBranchDirectionsByLayouts(branchLayouts);
|
|
2270
|
-
let availableSubLayouts = getAvailableSubLayoutsByLayoutDirections(currentLayoutDirections);
|
|
2271
|
-
const parentLayout = [branchLayouts[branchLayouts.length - 1]];
|
|
2272
|
-
const parentDirections = getBranchDirectionsByLayouts(parentLayout);
|
|
2273
|
-
const parentAvailableSubLayouts = getAvailableSubLayoutsByLayoutDirections(parentDirections);
|
|
2274
|
-
availableSubLayouts = availableSubLayouts.filter(layout => parentAvailableSubLayouts.some(parentAvailableSubLayout => parentAvailableSubLayout === layout));
|
|
2275
|
-
return availableSubLayouts;
|
|
2276
|
-
}
|
|
2277
|
-
return undefined;
|
|
2278
|
-
};
|
|
2279
|
-
|
|
2280
|
-
const getLayoutByElement = (element) => {
|
|
2281
|
-
const layout = element.layout;
|
|
2282
|
-
if (layout) {
|
|
2283
|
-
return layout;
|
|
2284
|
-
}
|
|
2285
|
-
const parent = !PlaitMind.isMind(element) && MindElement.getParent(element);
|
|
2286
|
-
if (AbstractNode.isAbstract(element) && parent) {
|
|
2287
|
-
return getAbstractLayout(getLayoutByElement(parent));
|
|
2288
|
-
}
|
|
2289
|
-
if (parent) {
|
|
2290
|
-
return getLayoutByElement(parent);
|
|
2291
|
-
}
|
|
2292
|
-
return getDefaultLayout();
|
|
2293
|
-
};
|
|
2294
|
-
|
|
2295
|
-
const MindQueries = {
|
|
2296
|
-
getAvailableSubLayoutsByElement,
|
|
2297
|
-
getBranchLayouts,
|
|
2298
|
-
getLayoutByElement,
|
|
2299
|
-
getCorrectLayoutByElement
|
|
2300
|
-
};
|
|
2301
|
-
|
|
2302
|
-
const PlaitMind = {
|
|
2303
|
-
isMind: (value) => {
|
|
2304
|
-
return value.type === 'mindmap';
|
|
2305
|
-
}
|
|
2306
|
-
};
|
|
2307
|
-
const MindElement = {
|
|
2308
|
-
hasLayout(value, layout) {
|
|
2309
|
-
const _layout = MindQueries.getLayoutByElement(value);
|
|
2310
|
-
return _layout === layout;
|
|
2311
|
-
},
|
|
2312
|
-
isIndentedLayout(value) {
|
|
2313
|
-
const _layout = MindQueries.getLayoutByElement(value);
|
|
2314
|
-
return isIndentedLayout(_layout);
|
|
2315
|
-
},
|
|
2316
|
-
isMindElement(board, element) {
|
|
2317
|
-
if (element.data && element.data.topic && element.width && element.height) {
|
|
2318
|
-
return true;
|
|
2319
|
-
}
|
|
2320
|
-
else {
|
|
2321
|
-
return false;
|
|
2322
|
-
}
|
|
2323
|
-
},
|
|
2324
|
-
getParent(node) {
|
|
2325
|
-
if (PlaitMind.isMind(node)) {
|
|
2326
|
-
throw new Error('mind root node can not get parent');
|
|
2327
|
-
}
|
|
2328
|
-
const parent = NODE_TO_PARENT.get(node);
|
|
2329
|
-
return parent;
|
|
2330
|
-
},
|
|
2331
|
-
findParent(node) {
|
|
2332
|
-
if (PlaitMind.isMind(node)) {
|
|
2333
|
-
return undefined;
|
|
2334
|
-
}
|
|
2335
|
-
const parent = NODE_TO_PARENT.get(node);
|
|
2336
|
-
return parent;
|
|
2337
|
-
},
|
|
2338
|
-
getRoot(board, element) {
|
|
2339
|
-
const path = PlaitBoard.findPath(board, element);
|
|
2340
|
-
return PlaitNode.get(board, path.slice(0, 1));
|
|
2341
|
-
},
|
|
2342
|
-
getAncestors(board, element) {
|
|
2343
|
-
const path = PlaitBoard.findPath(board, element);
|
|
2344
|
-
const parents = [];
|
|
2345
|
-
for (const p of Path.ancestors(path, { reverse: true })) {
|
|
2346
|
-
const n = PlaitNode.get(board, p);
|
|
2347
|
-
if (n && !PlaitBoard.isBoard(n)) {
|
|
2348
|
-
parents.push(n);
|
|
2349
|
-
}
|
|
2350
|
-
}
|
|
2351
|
-
return parents;
|
|
2352
|
-
},
|
|
2353
|
-
getNode(element) {
|
|
2354
|
-
const node = ELEMENT_TO_NODE.get(element);
|
|
2355
|
-
if (!node) {
|
|
2356
|
-
throw new Error(`can not get node from ${JSON.stringify(element)}`);
|
|
2357
|
-
}
|
|
2358
|
-
return node;
|
|
2359
|
-
},
|
|
2360
|
-
findParentNode(element) {
|
|
2361
|
-
if (PlaitMind.isMind(element)) {
|
|
2362
|
-
return undefined;
|
|
2363
|
-
}
|
|
2364
|
-
const parent = MindElement.getParent(element);
|
|
2365
|
-
return MindElement.getNode(parent);
|
|
2366
|
-
},
|
|
2367
|
-
hasEmojis(element) {
|
|
2368
|
-
if (element.data.emojis) {
|
|
2369
|
-
return true;
|
|
2370
|
-
}
|
|
2371
|
-
else {
|
|
2372
|
-
return false;
|
|
2373
|
-
}
|
|
2374
|
-
},
|
|
2375
|
-
hasImage(element) {
|
|
2376
|
-
if (element.data.image) {
|
|
2377
|
-
return true;
|
|
2378
|
-
}
|
|
2379
|
-
else {
|
|
2380
|
-
return false;
|
|
2381
|
-
}
|
|
2382
|
-
},
|
|
2383
|
-
getEmojis(element) {
|
|
2384
|
-
return element.data.emojis;
|
|
2385
|
-
},
|
|
2386
|
-
hasMounted(element) {
|
|
2387
|
-
const component = PlaitElement.getComponent(element);
|
|
2388
|
-
return !!component;
|
|
2389
|
-
},
|
|
2390
|
-
getTextEditor(element) {
|
|
2391
|
-
const component = PlaitElement.getComponent(element);
|
|
2392
|
-
if (component) {
|
|
2393
|
-
return component.textManage.componentRef.instance.editor;
|
|
2394
|
-
}
|
|
2395
|
-
throw new Error('can not get correctly component in get text editor');
|
|
2396
|
-
}
|
|
2397
|
-
};
|
|
2398
|
-
var MindElementShape;
|
|
2399
|
-
(function (MindElementShape) {
|
|
2400
|
-
MindElementShape["roundRectangle"] = "round-rectangle";
|
|
2401
|
-
MindElementShape["underline"] = "underline";
|
|
2402
|
-
})(MindElementShape || (MindElementShape = {}));
|
|
2403
|
-
var BranchShape;
|
|
2404
|
-
(function (BranchShape) {
|
|
2405
|
-
BranchShape["bight"] = "bight";
|
|
2406
|
-
BranchShape["polyline"] = "polyline";
|
|
2407
|
-
})(BranchShape || (BranchShape = {}));
|
|
2408
|
-
|
|
2409
|
-
function getRectangleByNode(node) {
|
|
2410
|
-
const x = node.x + node.hGap;
|
|
2411
|
-
let y = node.y + node.vGap;
|
|
2412
|
-
const width = node.width - node.hGap * 2;
|
|
2413
|
-
const height = node.height - node.vGap * 2;
|
|
2414
|
-
return {
|
|
2415
|
-
x,
|
|
2416
|
-
y,
|
|
2417
|
-
width,
|
|
2418
|
-
height
|
|
2419
|
-
};
|
|
2420
|
-
}
|
|
2421
|
-
function getRectangleByElement(board, originPoint, element) {
|
|
2422
|
-
const nodeRectangle = {
|
|
2423
|
-
x: originPoint[0],
|
|
2424
|
-
y: originPoint[1],
|
|
2425
|
-
width: NodeSpace.getNodeWidth(board, element),
|
|
2426
|
-
height: NodeSpace.getNodeHeight(board, element)
|
|
2427
|
-
};
|
|
2428
|
-
return nodeRectangle;
|
|
2429
|
-
}
|
|
2430
|
-
function isHitMindElement(board, point, element) {
|
|
2431
|
-
const node = MindElement.getNode(element);
|
|
2432
|
-
if (node && distanceBetweenPointAndRectangle(point[0], point[1], getRectangleByNode(node)) === 0) {
|
|
2433
|
-
return true;
|
|
2434
|
-
}
|
|
2435
|
-
else {
|
|
2436
|
-
return false;
|
|
2437
|
-
}
|
|
2438
|
-
}
|
|
2439
|
-
|
|
2440
|
-
function drawRoundRectangleByNode(board, node) {
|
|
2441
|
-
const rectangle = getRectangleByNode(node);
|
|
2442
|
-
return drawRoundRectangleByElement(board, rectangle, node.origin);
|
|
2443
|
-
}
|
|
2444
|
-
function drawRoundRectangleByElement(board, nodeRectangle, element) {
|
|
2445
|
-
const fill = getFillByElement(board, element);
|
|
2446
|
-
const stroke = getStrokeByMindElement(board, element);
|
|
2447
|
-
const strokeWidth = getStrokeWidthByElement(board, element);
|
|
2448
|
-
const nodeG = drawRoundRectangle(PlaitBoard.getRoughSVG(board), nodeRectangle.x, nodeRectangle.y, nodeRectangle.x + nodeRectangle.width, nodeRectangle.y + nodeRectangle.height, {
|
|
2449
|
-
stroke,
|
|
2450
|
-
strokeWidth,
|
|
2451
|
-
fill,
|
|
2452
|
-
fillStyle: 'solid'
|
|
2453
|
-
}, false, DefaultNodeStyle.shape.rectangleRadius);
|
|
2454
|
-
return nodeG;
|
|
2455
|
-
}
|
|
2456
|
-
|
|
2457
|
-
function drawAbstractLink(board, node, isHorizontal) {
|
|
2458
|
-
const linkPadding = 15;
|
|
2459
|
-
const branchWidth = getAbstractBranchWidth(board, node.origin);
|
|
2460
|
-
const branchColor = getAbstractBranchColor(board, node.origin);
|
|
2461
|
-
const parent = node.parent;
|
|
2462
|
-
const branchShape = getBranchShapeByMindElement(board, node.origin);
|
|
2463
|
-
const abstractRectangle = getRectangleByNode(node);
|
|
2464
|
-
let includedElements = parent.children.slice(node.origin.start, node.origin.end + 1).map(node => {
|
|
2465
|
-
return node.origin;
|
|
2466
|
-
});
|
|
2467
|
-
const includedElementsRectangle = getRectangleByElements(board, includedElements, true);
|
|
2468
|
-
const linkDirection = getLayoutDirection(node, isHorizontal);
|
|
2469
|
-
const bezierBeginPlacement = [HorizontalPlacement.right, VerticalPlacement.top];
|
|
2470
|
-
const bezierEndPlacement = [HorizontalPlacement.right, VerticalPlacement.bottom];
|
|
2471
|
-
const abstractConnectorPlacement = [HorizontalPlacement.left, VerticalPlacement.middle];
|
|
2472
|
-
transformPlacement(bezierBeginPlacement, linkDirection);
|
|
2473
|
-
transformPlacement(bezierEndPlacement, linkDirection);
|
|
2474
|
-
transformPlacement(abstractConnectorPlacement, linkDirection);
|
|
2475
|
-
let bezierBeginPoint = getPointByPlacement(includedElementsRectangle, bezierBeginPlacement);
|
|
2476
|
-
let bezierEndPoint = getPointByPlacement(includedElementsRectangle, bezierEndPlacement);
|
|
2477
|
-
let abstractConnectorPoint = getPointByPlacement(abstractRectangle, abstractConnectorPlacement);
|
|
2478
|
-
let curveDistance = getXDistanceBetweenPoint(abstractConnectorPoint, bezierBeginPoint, isHorizontal) - linkPadding * 2;
|
|
2479
|
-
bezierBeginPoint = moveXOfPoint(bezierBeginPoint, linkPadding, linkDirection);
|
|
2480
|
-
let c1 = moveXOfPoint(bezierBeginPoint, curveDistance, linkDirection);
|
|
2481
|
-
bezierEndPoint = moveXOfPoint(bezierEndPoint, linkPadding, linkDirection);
|
|
2482
|
-
let c2 = moveXOfPoint(bezierEndPoint, curveDistance, linkDirection);
|
|
2483
|
-
let bezierConnectorPoint = moveXOfPoint(abstractConnectorPoint, -linkPadding, linkDirection);
|
|
2484
|
-
if (branchShape === BranchShape.polyline) {
|
|
2485
|
-
const g = createG();
|
|
2486
|
-
const polyline = drawLinearPath([bezierBeginPoint, c1, bezierConnectorPoint, c2, bezierEndPoint], {
|
|
2487
|
-
stroke: branchColor,
|
|
2488
|
-
strokeWidth: branchWidth
|
|
2489
|
-
});
|
|
2490
|
-
const straightLine = drawLinearPath([abstractConnectorPoint, bezierConnectorPoint], {
|
|
2491
|
-
stroke: branchColor,
|
|
2492
|
-
strokeWidth: branchWidth
|
|
2493
|
-
});
|
|
2494
|
-
g.appendChild(polyline);
|
|
2495
|
-
g.appendChild(straightLine);
|
|
2496
|
-
return g;
|
|
2497
|
-
}
|
|
2498
|
-
const link = PlaitBoard.getRoughSVG(board).path(`M${bezierBeginPoint[0]},${bezierBeginPoint[1]} Q${c1[0]},${c1[1]} ${bezierConnectorPoint[0]},${bezierConnectorPoint[1]} Q${c2[0]},${c2[1]} ${bezierEndPoint[0]},${bezierEndPoint[1]} M${abstractConnectorPoint[0]},${abstractConnectorPoint[1]} L${bezierConnectorPoint[0]},${bezierConnectorPoint[1]}`, {
|
|
2499
|
-
stroke: branchColor,
|
|
2500
|
-
strokeWidth: branchWidth
|
|
2501
|
-
});
|
|
2502
|
-
return link;
|
|
2503
|
-
}
|
|
2504
|
-
|
|
2505
|
-
class EmojiDrawer {
|
|
2506
|
-
constructor(board, viewContainerRef) {
|
|
2507
|
-
this.board = board;
|
|
2508
|
-
this.viewContainerRef = viewContainerRef;
|
|
2509
|
-
this.componentRef = null;
|
|
2510
|
-
}
|
|
2511
|
-
draw(emoji, element) {
|
|
2512
|
-
this.destroy();
|
|
2513
|
-
const componentType = this.board.drawEmoji(emoji, element);
|
|
2514
|
-
this.componentRef = this.viewContainerRef.createComponent(componentType);
|
|
2515
|
-
this.componentRef.instance.emojiItem = emoji;
|
|
2516
|
-
this.componentRef.instance.board = this.board;
|
|
2517
|
-
this.componentRef.instance.element = element;
|
|
2518
|
-
this.componentRef.instance.fontSize = getEmojiFontSize(element);
|
|
2519
|
-
}
|
|
2520
|
-
get nativeElement() {
|
|
2521
|
-
if (this.componentRef) {
|
|
2522
|
-
return this.componentRef.instance.nativeElement;
|
|
2523
|
-
}
|
|
2524
|
-
else {
|
|
2525
|
-
return null;
|
|
2526
|
-
}
|
|
2527
|
-
}
|
|
2528
|
-
destroy() {
|
|
2529
|
-
if (this.componentRef) {
|
|
2530
|
-
this.componentRef.destroy();
|
|
2531
|
-
this.componentRef = null;
|
|
2532
|
-
}
|
|
2533
|
-
}
|
|
2534
|
-
}
|
|
2535
|
-
class NodeEmojisDrawer {
|
|
2536
|
-
constructor(board, viewContainerRef) {
|
|
2537
|
-
this.board = board;
|
|
2538
|
-
this.viewContainerRef = viewContainerRef;
|
|
2539
|
-
this.emojiDrawers = [];
|
|
2540
|
-
}
|
|
2541
|
-
drawEmojis(element) {
|
|
2542
|
-
this.destroy();
|
|
2543
|
-
if (MindElement.hasEmojis(element)) {
|
|
2544
|
-
this.g = createG();
|
|
2545
|
-
this.g.classList.add('emojis');
|
|
2546
|
-
const foreignRectangle = getEmojiForeignRectangle(this.board, element);
|
|
2547
|
-
const foreignObject = createForeignObject(foreignRectangle.x, foreignRectangle.y, foreignRectangle.width, foreignRectangle.height);
|
|
2548
|
-
this.g.append(foreignObject);
|
|
2549
|
-
const container = document.createElement('div');
|
|
2550
|
-
container.classList.add('node-emojis-container');
|
|
2551
|
-
foreignObject.append(container);
|
|
2552
|
-
this.emojiDrawers = element.data.emojis.map(emojiItem => {
|
|
2553
|
-
const drawer = new EmojiDrawer(this.board, this.viewContainerRef);
|
|
2554
|
-
drawer.draw(emojiItem, element);
|
|
2555
|
-
return drawer;
|
|
2556
|
-
});
|
|
2557
|
-
this.emojiDrawers.forEach(drawer => {
|
|
2558
|
-
container.append(drawer.nativeElement);
|
|
2559
|
-
});
|
|
2560
|
-
return this.g;
|
|
2561
|
-
}
|
|
2562
|
-
return undefined;
|
|
2563
|
-
}
|
|
2564
|
-
destroy() {
|
|
2565
|
-
if (this.g) {
|
|
2566
|
-
this.g.remove();
|
|
2567
|
-
}
|
|
2568
|
-
this.emojiDrawers.forEach(drawer => drawer.destroy());
|
|
2569
|
-
this.emojiDrawers = [];
|
|
2570
|
-
}
|
|
2571
|
-
}
|
|
2572
|
-
|
|
2573
|
-
class BaseDrawer {
|
|
2574
|
-
constructor(board) {
|
|
2575
|
-
this.board = board;
|
|
2576
|
-
}
|
|
2577
|
-
draw(element, parentG, data) {
|
|
2578
|
-
this.destroy();
|
|
2579
|
-
if (this.canDraw && this.canDraw(element, data)) {
|
|
2580
|
-
const g = this.baseDraw(element, data);
|
|
2581
|
-
if (g) {
|
|
2582
|
-
parentG.append(g);
|
|
2583
|
-
}
|
|
2584
|
-
if (hasAfterDraw(this)) {
|
|
2585
|
-
this.afterDraw(element);
|
|
2586
|
-
}
|
|
2587
|
-
}
|
|
2588
|
-
}
|
|
2589
|
-
destroy() {
|
|
2590
|
-
if (this.g) {
|
|
2591
|
-
this.g.remove();
|
|
2592
|
-
}
|
|
2593
|
-
}
|
|
2594
|
-
}
|
|
2595
|
-
function hasAfterDraw(value) {
|
|
2596
|
-
if (value.afterDraw) {
|
|
2597
|
-
return true;
|
|
2598
|
-
}
|
|
2599
|
-
return false;
|
|
2600
|
-
}
|
|
2601
|
-
|
|
2602
|
-
function findNewChildNodePath(board, element) {
|
|
2603
|
-
const children = getNonAbstractChildren(element);
|
|
2604
|
-
return PlaitBoard.findPath(board, element).concat(children.length);
|
|
2605
|
-
}
|
|
2606
|
-
function findNewSiblingNodePath(board, element) {
|
|
2607
|
-
const path = PlaitBoard.findPath(board, element);
|
|
2608
|
-
return Path$1.next(path);
|
|
2609
|
-
}
|
|
2610
|
-
|
|
2611
|
-
class NodeInsertDrawer extends BaseDrawer {
|
|
2612
|
-
canDraw(element) {
|
|
2613
|
-
if (PlaitBoard.isReadonly(this.board) || (element === null || element === void 0 ? void 0 : element.isCollapsed)) {
|
|
2614
|
-
return false;
|
|
2615
|
-
}
|
|
2616
|
-
return true;
|
|
2617
|
-
}
|
|
2618
|
-
baseDraw(element) {
|
|
2619
|
-
const quickInsertG = createG();
|
|
2620
|
-
this.g = quickInsertG;
|
|
2621
|
-
quickInsertG.classList.add('quick-insert');
|
|
2622
|
-
const node = MindElement.getNode(element);
|
|
2623
|
-
const layout = MindQueries.getLayoutByElement(element);
|
|
2624
|
-
const isHorizontal = isHorizontalLayout(layout);
|
|
2625
|
-
let linkDirection = getLayoutDirection(node, isHorizontal);
|
|
2626
|
-
if (isIndentedLayout(layout)) {
|
|
2627
|
-
linkDirection = isTopLayout(layout) ? LayoutDirection.top : LayoutDirection.bottom;
|
|
2628
|
-
}
|
|
2629
|
-
const isUnderlineShape = getShapeByElement(this.board, element) === MindElementShape.underline;
|
|
2630
|
-
const nodeClient = getRectangleByNode(node);
|
|
2631
|
-
const branchWidth = getBranchWidthByMindElement(this.board, element);
|
|
2632
|
-
const branchColor = PlaitMind.isMind(element)
|
|
2633
|
-
? getNextBranchColor(this.board, element)
|
|
2634
|
-
: getBranchColorByMindElement(this.board, element);
|
|
2635
|
-
let distance = 8;
|
|
2636
|
-
let placement = [HorizontalPlacement.right, VerticalPlacement.middle];
|
|
2637
|
-
transformPlacement(placement, linkDirection);
|
|
2638
|
-
// underline shape and horizontal
|
|
2639
|
-
if (isHorizontal && isUnderlineShape && !element.isRoot) {
|
|
2640
|
-
placement[1] = VerticalPlacement.bottom;
|
|
2641
|
-
}
|
|
2642
|
-
let beginPoint = getPointByPlacement(nodeClient, placement);
|
|
2643
|
-
if (element.children.length > 0 && !element.isRoot) {
|
|
2644
|
-
beginPoint = moveXOfPoint(beginPoint, EXTEND_DIAMETER + 8, linkDirection);
|
|
2645
|
-
distance = 5;
|
|
2646
|
-
}
|
|
2647
|
-
const endPoint = moveXOfPoint(beginPoint, distance, linkDirection);
|
|
2648
|
-
const circleCenter = moveXOfPoint(endPoint, 8, linkDirection);
|
|
2649
|
-
const line = PlaitBoard.getRoughSVG(this.board).line(beginPoint[0], beginPoint[1], endPoint[0], endPoint[1], {
|
|
2650
|
-
stroke: branchColor,
|
|
2651
|
-
strokeWidth: branchWidth
|
|
2652
|
-
});
|
|
2653
|
-
const circle = PlaitBoard.getRoughSVG(this.board).circle(circleCenter[0], circleCenter[1], EXTEND_DIAMETER, {
|
|
2654
|
-
fill: QUICK_INSERT_CIRCLE_COLOR,
|
|
2655
|
-
stroke: QUICK_INSERT_CIRCLE_COLOR,
|
|
2656
|
-
fillStyle: 'solid'
|
|
2657
|
-
});
|
|
2658
|
-
const HLineBeginPoint = [circleCenter[0] - 5, circleCenter[1]];
|
|
2659
|
-
const HLineEndPoint = [circleCenter[0] + 5, circleCenter[1]];
|
|
2660
|
-
const VLineBeginPoint = [circleCenter[0], circleCenter[1] - 5];
|
|
2661
|
-
const VLineEndPoint = [circleCenter[0], circleCenter[1] + 5];
|
|
2662
|
-
const innerCrossHLine = PlaitBoard.getRoughSVG(this.board).line(HLineBeginPoint[0], HLineBeginPoint[1], HLineEndPoint[0], HLineEndPoint[1], {
|
|
2663
|
-
stroke: QUICK_INSERT_INNER_CROSS_COLOR,
|
|
2664
|
-
strokeWidth: 2
|
|
2665
|
-
});
|
|
2666
|
-
const innerCrossVLine = PlaitBoard.getRoughSVG(this.board).line(VLineBeginPoint[0], VLineBeginPoint[1], VLineEndPoint[0], VLineEndPoint[1], {
|
|
2667
|
-
stroke: QUICK_INSERT_INNER_CROSS_COLOR,
|
|
2668
|
-
strokeWidth: 2
|
|
2669
|
-
});
|
|
2670
|
-
quickInsertG.appendChild(line);
|
|
2671
|
-
quickInsertG.appendChild(circle);
|
|
2672
|
-
quickInsertG.appendChild(innerCrossHLine);
|
|
2673
|
-
quickInsertG.appendChild(innerCrossVLine);
|
|
2674
|
-
return quickInsertG;
|
|
2675
|
-
}
|
|
2676
|
-
afterDraw(element) {
|
|
2677
|
-
if (!this.g) {
|
|
2678
|
-
throw new Error(`can not find quick insert g`);
|
|
2679
|
-
}
|
|
2680
|
-
fromEvent(this.g, 'mousedown')
|
|
2681
|
-
.pipe(take(1))
|
|
2682
|
-
.subscribe(e => {
|
|
2683
|
-
e.stopPropagation();
|
|
2684
|
-
});
|
|
2685
|
-
fromEvent(this.g, 'mouseup')
|
|
2686
|
-
.pipe(take(1))
|
|
2687
|
-
.subscribe(() => {
|
|
2688
|
-
const path = findNewChildNodePath(this.board, element);
|
|
2689
|
-
insertMindElement(this.board, element, path);
|
|
2690
|
-
});
|
|
2691
|
-
}
|
|
2692
|
-
}
|
|
2693
|
-
|
|
2694
|
-
function drawAbstractIncludedOutline(board, roughSVG, element, activeHandlePosition, resizingLocation) {
|
|
2695
|
-
const abstractIncludedG = createG();
|
|
2696
|
-
const parentElement = MindElement.getParent(element);
|
|
2697
|
-
const nodeLayout = MindQueries.getCorrectLayoutByElement(board, element);
|
|
2698
|
-
const isHorizontal = isHorizontalLayout(nodeLayout);
|
|
2699
|
-
const includedElements = parentElement.children.slice(element.start, element.end + 1);
|
|
2700
|
-
let abstractRectangle = getRectangleByElements(board, includedElements, true);
|
|
2701
|
-
abstractRectangle = RectangleClient.getOutlineRectangle(abstractRectangle, -ABSTRACT_INCLUDED_OUTLINE_OFFSET);
|
|
2702
|
-
if (resizingLocation) {
|
|
2703
|
-
abstractRectangle = getRectangleByResizingLocation(abstractRectangle, resizingLocation, activeHandlePosition, isHorizontal);
|
|
2704
|
-
}
|
|
2705
|
-
const rectangle = drawAbstractRoundRectangle(roughSVG, abstractRectangle.x, abstractRectangle.y, abstractRectangle.x + abstractRectangle.width, abstractRectangle.y + abstractRectangle.height, isHorizontal, {
|
|
2706
|
-
stroke: PRIMARY_COLOR,
|
|
2707
|
-
strokeWidth: 1,
|
|
2708
|
-
fillStyle: 'solid'
|
|
2709
|
-
});
|
|
2710
|
-
const startPlacement = [HorizontalPlacement.center, VerticalPlacement.top];
|
|
2711
|
-
const endPlacement = [HorizontalPlacement.center, VerticalPlacement.bottom];
|
|
2712
|
-
const linkDirection = getLayoutDirection(MindElement.getNode(element), isHorizontal);
|
|
2713
|
-
transformPlacement(startPlacement, linkDirection);
|
|
2714
|
-
transformPlacement(endPlacement, linkDirection);
|
|
2715
|
-
let startCenterPoint = getPointByPlacement(abstractRectangle, startPlacement);
|
|
2716
|
-
let endCenterPoint = getPointByPlacement(abstractRectangle, endPlacement);
|
|
2717
|
-
const startPoint1 = moveXOfPoint(startCenterPoint, -ABSTRACT_HANDLE_LENGTH / 2, linkDirection);
|
|
2718
|
-
const startPoint2 = moveXOfPoint(startCenterPoint, ABSTRACT_HANDLE_LENGTH / 2, linkDirection);
|
|
2719
|
-
const endPoint1 = moveXOfPoint(endCenterPoint, -ABSTRACT_HANDLE_LENGTH / 2, linkDirection);
|
|
2720
|
-
const endPoint2 = moveXOfPoint(endCenterPoint, ABSTRACT_HANDLE_LENGTH / 2, linkDirection);
|
|
2721
|
-
const startHandle = roughSVG.line(startPoint1[0], startPoint1[1], startPoint2[0], startPoint2[1], getHandleOption(activeHandlePosition === AbstractHandlePosition.start));
|
|
2722
|
-
const endHandle = roughSVG.line(endPoint1[0], endPoint1[1], endPoint2[0], endPoint2[1], getHandleOption(activeHandlePosition === AbstractHandlePosition.end));
|
|
2723
|
-
handleBoardClass(board, activeHandlePosition, isHorizontal);
|
|
2724
|
-
startHandle.setAttribute('stroke-linecap', 'round');
|
|
2725
|
-
endHandle.setAttribute('stroke-linecap', 'round');
|
|
2726
|
-
abstractIncludedG.append(startHandle);
|
|
2727
|
-
abstractIncludedG.append(endHandle);
|
|
2728
|
-
abstractIncludedG.append(rectangle);
|
|
2729
|
-
return abstractIncludedG;
|
|
2730
|
-
}
|
|
2731
|
-
function getHandleOption(isHover) {
|
|
2732
|
-
return isHover
|
|
2733
|
-
? {
|
|
2734
|
-
stroke: PRIMARY_COLOR,
|
|
2735
|
-
strokeWidth: 4,
|
|
2736
|
-
fillStyle: 'solid'
|
|
2737
|
-
}
|
|
2738
|
-
: {
|
|
2739
|
-
stroke: ABSTRACT_HANDLE_COLOR,
|
|
2740
|
-
strokeWidth: 3,
|
|
2741
|
-
fillStyle: 'solid'
|
|
2742
|
-
};
|
|
2743
|
-
}
|
|
2744
|
-
function handleBoardClass(board, activeHandlePosition, isHorizontal) {
|
|
2745
|
-
if (activeHandlePosition) {
|
|
2746
|
-
if (isHorizontal) {
|
|
2747
|
-
PlaitBoard.getBoardContainer(board).classList.add('abstract-resizing-horizontal');
|
|
2748
|
-
}
|
|
2749
|
-
else {
|
|
2750
|
-
PlaitBoard.getBoardContainer(board).classList.add('abstract-resizing-vertical');
|
|
2751
|
-
}
|
|
2752
|
-
}
|
|
2753
|
-
else {
|
|
2754
|
-
PlaitBoard.getBoardContainer(board).classList.remove('abstract-resizing-horizontal');
|
|
2755
|
-
PlaitBoard.getBoardContainer(board).classList.remove('abstract-resizing-vertical');
|
|
2756
|
-
}
|
|
2757
|
-
}
|
|
2758
|
-
function drawAbstractRoundRectangle(rs, x1, y1, x2, y2, isHorizontal, options) {
|
|
2759
|
-
const width = Math.abs(x1 - x2);
|
|
2760
|
-
const height = Math.abs(y1 - y2);
|
|
2761
|
-
const radius = 5;
|
|
2762
|
-
const handleGap = 4;
|
|
2763
|
-
const handleLength = 10;
|
|
2764
|
-
const handleSpace = handleLength + handleGap * 2;
|
|
2765
|
-
if (isHorizontal) {
|
|
2766
|
-
const handleSideLine = (width - handleSpace - radius * 2) / 2;
|
|
2767
|
-
const sideLine = height - radius * 2;
|
|
2768
|
-
return rs.path(`M${x1 + radius},${y1}
|
|
2769
|
-
l${handleSideLine},0
|
|
2770
|
-
m${handleSpace},0
|
|
2771
|
-
l${handleSideLine},0
|
|
2772
|
-
a${radius},${radius},0,0,1,${radius},${radius}
|
|
2773
|
-
l0,${sideLine}
|
|
2774
|
-
a${radius},${radius},0,0,1,-${radius},${radius}
|
|
2775
|
-
l-${handleSideLine},0
|
|
2776
|
-
m-${handleSpace},0
|
|
2777
|
-
l-${handleSideLine},0
|
|
2778
|
-
a${radius},${radius},0,0,1,-${radius},-${radius}
|
|
2779
|
-
l0,-${sideLine}
|
|
2780
|
-
a${radius},${radius},0,0,1,${radius},-${radius}`, options);
|
|
2781
|
-
}
|
|
2782
|
-
else {
|
|
2783
|
-
const handleSideLine = (height - handleSpace - radius * 2) / 2;
|
|
2784
|
-
const sideLine = width - radius * 2;
|
|
2785
|
-
return rs.path(`M${x1 + radius},${y1}
|
|
2786
|
-
l${sideLine},0
|
|
2787
|
-
a${radius},${radius},0,0,1,${radius},${radius}
|
|
2788
|
-
l0,${handleSideLine}
|
|
2789
|
-
m0,${handleSpace}
|
|
2790
|
-
l0,${handleSideLine}
|
|
2791
|
-
a${radius},${radius},0,0,1,-${radius},${radius}
|
|
2792
|
-
l-${sideLine},0
|
|
2793
|
-
a${radius},${radius},0,0,1,-${radius},-${radius}
|
|
2794
|
-
l0,-${handleSideLine}
|
|
2795
|
-
m0,-${handleSpace}
|
|
2796
|
-
l0,-${handleSideLine}
|
|
2797
|
-
a${radius},${radius},0,0,1,${radius},-${radius}`, options);
|
|
2798
|
-
}
|
|
2799
|
-
}
|
|
2800
|
-
|
|
2801
|
-
class NodeActiveDrawer extends BaseDrawer {
|
|
2802
|
-
canDraw(element, data) {
|
|
2803
|
-
if (data.selected) {
|
|
2804
|
-
return true;
|
|
2805
|
-
}
|
|
2806
|
-
else {
|
|
2807
|
-
return false;
|
|
2808
|
-
}
|
|
2809
|
-
}
|
|
2810
|
-
baseDraw(element, data) {
|
|
2811
|
-
const activeG = createG();
|
|
2812
|
-
this.g = activeG;
|
|
2813
|
-
if (AbstractNode.isAbstract(element)) {
|
|
2814
|
-
this.abstractOutlineG = drawAbstractIncludedOutline(this.board, PlaitBoard.getRoughSVG(this.board), element);
|
|
2815
|
-
activeG.append(this.abstractOutlineG);
|
|
2816
|
-
}
|
|
2817
|
-
const node = MindElement.getNode(element);
|
|
2818
|
-
const rectangle = getRectangleByNode(node);
|
|
2819
|
-
const activeStrokeWidth = 2;
|
|
2820
|
-
// add 0.1 to avoid white gap
|
|
2821
|
-
const offset = (getStrokeWidthByElement(this.board, element) + activeStrokeWidth) / 2 - 0.1;
|
|
2822
|
-
const activeRectangle = RectangleClient.getOutlineRectangle(rectangle, -offset);
|
|
2823
|
-
const strokeG = drawRoundRectangle(PlaitBoard.getRoughSVG(this.board), activeRectangle.x, activeRectangle.y, activeRectangle.x + activeRectangle.width, activeRectangle.y + activeRectangle.height, { stroke: PRIMARY_COLOR, strokeWidth: activeStrokeWidth, fill: '' }, true, DefaultNodeStyle.shape.rectangleRadius + offset);
|
|
2824
|
-
this.g.appendChild(strokeG);
|
|
2825
|
-
return activeG;
|
|
2826
|
-
}
|
|
2827
|
-
updateAbstractOutline(element, activeHandlePosition, resizingLocation) {
|
|
2828
|
-
if (this.abstractOutlineG) {
|
|
2829
|
-
this.abstractOutlineG.remove();
|
|
2830
|
-
}
|
|
2831
|
-
this.abstractOutlineG = drawAbstractIncludedOutline(this.board, PlaitBoard.getRoughSVG(this.board), element, activeHandlePosition, resizingLocation);
|
|
2832
|
-
this.g.append(this.abstractOutlineG);
|
|
2833
|
-
}
|
|
2834
|
-
}
|
|
2835
|
-
|
|
2836
|
-
class CollapseDrawer extends BaseDrawer {
|
|
2837
|
-
canDraw(element) {
|
|
2838
|
-
if (element.children.length && !PlaitMind.isMind(element)) {
|
|
2839
|
-
return true;
|
|
2840
|
-
}
|
|
2841
|
-
return false;
|
|
2842
|
-
}
|
|
2843
|
-
baseDraw(element) {
|
|
2844
|
-
const collapseG = createG();
|
|
2845
|
-
this.g = collapseG;
|
|
2846
|
-
collapseG.classList.add('collapse-container');
|
|
2847
|
-
const node = MindElement.getNode(element);
|
|
2848
|
-
const stroke = getBranchColorByMindElement(this.board, element);
|
|
2849
|
-
const branchWidth = getBranchWidthByMindElement(this.board, element);
|
|
2850
|
-
const layout = MindQueries.getLayoutByElement(element);
|
|
2851
|
-
const isUnderlineShape = getShapeByElement(this.board, element) === MindElementShape.underline;
|
|
2852
|
-
const isHorizontal = isHorizontalLayout(layout);
|
|
2853
|
-
const nodeClient = getRectangleByNode(node);
|
|
2854
|
-
let linkDirection = getLayoutDirection(node, isHorizontal);
|
|
2855
|
-
if (isIndentedLayout(layout)) {
|
|
2856
|
-
linkDirection = isTopLayout(layout) ? LayoutDirection.top : LayoutDirection.bottom;
|
|
2857
|
-
}
|
|
2858
|
-
let placement = [HorizontalPlacement.right, VerticalPlacement.middle];
|
|
2859
|
-
transformPlacement(placement, linkDirection);
|
|
2860
|
-
// underline shape and horizontal
|
|
2861
|
-
if (isHorizontal && isUnderlineShape && !element.isRoot) {
|
|
2862
|
-
placement[1] = VerticalPlacement.bottom;
|
|
2863
|
-
}
|
|
2864
|
-
let startPoint = getPointByPlacement(nodeClient, placement);
|
|
2865
|
-
const endPoint = moveXOfPoint(startPoint, EXTEND_OFFSET, linkDirection);
|
|
2866
|
-
const circleCenter = moveXOfPoint(endPoint, EXTEND_DIAMETER / 2, linkDirection);
|
|
2867
|
-
const arrowPoints = this.getArrowPoints(circleCenter, linkDirection);
|
|
2868
|
-
const arrowLine = drawLinearPath(arrowPoints, {
|
|
2869
|
-
stroke,
|
|
2870
|
-
strokeWidth: 2
|
|
2871
|
-
});
|
|
2872
|
-
const extendLine = PlaitBoard.getRoughSVG(this.board).line(startPoint[0], startPoint[1], endPoint[0], endPoint[1], {
|
|
2873
|
-
strokeWidth: branchWidth,
|
|
2874
|
-
stroke
|
|
2875
|
-
});
|
|
2876
|
-
const badge = PlaitBoard.getRoughSVG(this.board).circle(circleCenter[0], circleCenter[1], EXTEND_DIAMETER, {
|
|
2877
|
-
fill: stroke,
|
|
2878
|
-
stroke,
|
|
2879
|
-
fillStyle: 'solid'
|
|
2880
|
-
});
|
|
2881
|
-
const hideCircleG = PlaitBoard.getRoughSVG(this.board).circle(circleCenter[0], circleCenter[1], EXTEND_DIAMETER, {
|
|
2882
|
-
fill: '#fff',
|
|
2883
|
-
stroke,
|
|
2884
|
-
strokeWidth: branchWidth > 3 ? 3 : branchWidth,
|
|
2885
|
-
fillStyle: 'solid'
|
|
2886
|
-
});
|
|
2887
|
-
if (element.isCollapsed) {
|
|
2888
|
-
let numberOffset = 0;
|
|
2889
|
-
if (getChildrenCount(element) >= 10)
|
|
2890
|
-
numberOffset = -2;
|
|
2891
|
-
if (getChildrenCount(element) === 1)
|
|
2892
|
-
numberOffset = 1;
|
|
2893
|
-
const badgeText = createText(circleCenter[0] - 4 + numberOffset, circleCenter[1] + 4, stroke, `${getChildrenCount(element)}`);
|
|
2894
|
-
badge.setAttribute('style', 'opacity: 0.15');
|
|
2895
|
-
badgeText.setAttribute('style', 'font-size: 12px');
|
|
2896
|
-
collapseG.appendChild(badge);
|
|
2897
|
-
collapseG.appendChild(badgeText);
|
|
2898
|
-
collapseG.appendChild(extendLine);
|
|
2899
|
-
}
|
|
2900
|
-
else {
|
|
2901
|
-
collapseG.appendChild(hideCircleG);
|
|
2902
|
-
collapseG.appendChild(arrowLine);
|
|
2903
|
-
}
|
|
2904
|
-
collapseG.appendChild(extendLine);
|
|
2905
|
-
return collapseG;
|
|
2906
|
-
}
|
|
2907
|
-
afterDraw(element) {
|
|
2908
|
-
if (!this.g) {
|
|
2909
|
-
throw new Error(`can not find quick insert g`);
|
|
2910
|
-
}
|
|
2911
|
-
fromEvent(this.g, 'mouseup')
|
|
2912
|
-
.pipe(filter(() => !PlaitBoard.isPointer(this.board, PlaitPointerType.hand) || !!PlaitBoard.isReadonly(this.board)), take(1))
|
|
2913
|
-
.subscribe(() => {
|
|
2914
|
-
const isCollapsed = !element.isCollapsed;
|
|
2915
|
-
const newElement = { isCollapsed };
|
|
2916
|
-
const path = PlaitBoard.findPath(this.board, element);
|
|
2917
|
-
Transforms.setNode(this.board, newElement, path);
|
|
2918
|
-
});
|
|
2919
|
-
}
|
|
2920
|
-
getArrowPoints(circleCenter, linkDirection) {
|
|
2921
|
-
let arrowTopPoint = moveXOfPoint(circleCenter, 2, linkDirection);
|
|
2922
|
-
arrowTopPoint = moveYOfPoint(arrowTopPoint, 4, linkDirection);
|
|
2923
|
-
const arrowMiddlePoint = moveXOfPoint(circleCenter, -2, linkDirection);
|
|
2924
|
-
let arrowBottomPoint = moveXOfPoint(circleCenter, 2, linkDirection);
|
|
2925
|
-
arrowBottomPoint = moveYOfPoint(arrowBottomPoint, -4, linkDirection);
|
|
2926
|
-
return [arrowTopPoint, arrowMiddlePoint, arrowBottomPoint];
|
|
2927
|
-
}
|
|
2928
|
-
}
|
|
2929
|
-
|
|
2930
|
-
class NodeImageDrawer {
|
|
2931
|
-
constructor(board, viewContainerRef) {
|
|
2932
|
-
this.board = board;
|
|
2933
|
-
this.viewContainerRef = viewContainerRef;
|
|
2934
|
-
this.componentRef = null;
|
|
2935
|
-
}
|
|
2936
|
-
drawImage(nodeG, element) {
|
|
2937
|
-
if (!MindElement.hasImage(element)) {
|
|
2938
|
-
this.destroy();
|
|
2939
|
-
return;
|
|
2940
|
-
}
|
|
2941
|
-
this.g = createG();
|
|
2942
|
-
const foreignRectangle = getImageForeignRectangle(this.board, element);
|
|
2943
|
-
this.foreignObject = createForeignObject(foreignRectangle.x, foreignRectangle.y, foreignRectangle.width, foreignRectangle.height);
|
|
2944
|
-
this.g.append(this.foreignObject);
|
|
2945
|
-
const componentType = this.board.getPluginOptions(WithMindPluginKey).imageComponentType;
|
|
2946
|
-
if (!componentType) {
|
|
2947
|
-
throw new Error('Not implement drawEmoji method error.');
|
|
2948
|
-
}
|
|
2949
|
-
this.componentRef = this.viewContainerRef.createComponent(componentType);
|
|
2950
|
-
this.componentRef.instance.board = this.board;
|
|
2951
|
-
this.componentRef.instance.element = element;
|
|
2952
|
-
this.componentRef.instance.imageItem = element.data.image;
|
|
2953
|
-
this.componentRef.instance.cdr.markForCheck();
|
|
2954
|
-
this.foreignObject.append(this.componentRef.instance.nativeElement);
|
|
2955
|
-
nodeG.appendChild(this.g);
|
|
2956
|
-
}
|
|
2957
|
-
updateImage(nodeG, previous, current) {
|
|
2958
|
-
var _a;
|
|
2959
|
-
if (!MindElement.hasImage(previous) || !MindElement.hasImage(current)) {
|
|
2960
|
-
this.drawImage(nodeG, current);
|
|
2961
|
-
return;
|
|
2962
|
-
}
|
|
2963
|
-
if (previous !== current && this.componentRef) {
|
|
2964
|
-
this.componentRef.instance.element = current;
|
|
2965
|
-
this.componentRef.instance.imageItem = current.data.image;
|
|
2966
|
-
}
|
|
2967
|
-
const currentForeignObject = getImageForeignRectangle(this.board, current);
|
|
2968
|
-
updateForeignObject(this.g, currentForeignObject.width, currentForeignObject.height, currentForeignObject.x, currentForeignObject.y);
|
|
2969
|
-
// solve image lose on move node
|
|
2970
|
-
if (this.foreignObject.children.length === 0) {
|
|
2971
|
-
this.foreignObject.append(this.componentRef.instance.nativeElement);
|
|
2972
|
-
}
|
|
2973
|
-
(_a = this.componentRef) === null || _a === void 0 ? void 0 : _a.instance.cdr.markForCheck();
|
|
2974
|
-
}
|
|
2975
|
-
destroy() {
|
|
2976
|
-
if (this.g) {
|
|
2977
|
-
this.g.remove();
|
|
2978
|
-
}
|
|
2979
|
-
if (this.componentRef) {
|
|
2980
|
-
this.componentRef.destroy();
|
|
2981
|
-
this.componentRef = null;
|
|
2982
|
-
}
|
|
2983
|
-
}
|
|
2984
|
-
}
|
|
2985
|
-
|
|
2986
|
-
// 1. When the text at the end has an italic attribute, the text is partially covered
|
|
2987
|
-
// 2. There will be some differences in the width measured by different browsers
|
|
2988
|
-
const WIDTH_BUFFER = 4;
|
|
2989
|
-
class MindNodeComponent extends PlaitPluginElementComponent {
|
|
2990
|
-
constructor(viewContainerRef, cdr) {
|
|
2991
|
-
super(cdr);
|
|
2992
|
-
this.viewContainerRef = viewContainerRef;
|
|
2993
|
-
this.cdr = cdr;
|
|
2994
|
-
this.shapeG = null;
|
|
2995
|
-
this.destroy$ = new Subject();
|
|
2996
|
-
this.trackBy = (index, node) => {
|
|
2997
|
-
return node.origin.id;
|
|
2998
|
-
};
|
|
2999
|
-
}
|
|
3000
|
-
initializeDrawer() {
|
|
3001
|
-
this.nodeEmojisDrawer = new NodeEmojisDrawer(this.board, this.viewContainerRef);
|
|
3002
|
-
this.nodeInsertDrawer = new NodeInsertDrawer(this.board);
|
|
3003
|
-
this.activeDrawer = new NodeActiveDrawer(this.board);
|
|
3004
|
-
this.collapseDrawer = new CollapseDrawer(this.board);
|
|
3005
|
-
this.imageDrawer = new NodeImageDrawer(this.board, this.viewContainerRef);
|
|
3006
|
-
const plugins = this.board.getPluginOptions(WithMindPluginKey).textPlugins;
|
|
3007
|
-
this.textManage = new TextManage(this.board, this.viewContainerRef, {
|
|
3008
|
-
getRectangle: () => {
|
|
3009
|
-
const rect = getTopicRectangleByNode(this.board, this.node);
|
|
3010
|
-
return rect;
|
|
3011
|
-
},
|
|
3012
|
-
onValueChangeHandle: (textManageRef) => {
|
|
3013
|
-
const width = textManageRef.width;
|
|
3014
|
-
const height = textManageRef.height;
|
|
3015
|
-
if (textManageRef.newValue) {
|
|
3016
|
-
MindTransforms.setTopic(this.board, this.element, textManageRef.newValue, width, height);
|
|
3017
|
-
}
|
|
3018
|
-
else {
|
|
3019
|
-
MindTransforms.setTopicSize(this.board, this.element, width, height);
|
|
3020
|
-
}
|
|
3021
|
-
},
|
|
3022
|
-
textPlugins: plugins
|
|
3023
|
-
});
|
|
3024
|
-
}
|
|
3025
|
-
ngOnInit() {
|
|
3026
|
-
super.ngOnInit();
|
|
3027
|
-
this.initializeDrawer();
|
|
3028
|
-
this.node = MindElement.getNode(this.element);
|
|
3029
|
-
this.index = NODE_TO_INDEX.get(this.element) || 0;
|
|
3030
|
-
this.roughSVG = PlaitBoard.getRoughSVG(this.board);
|
|
3031
|
-
this.parentG = PlaitElement.getComponent(MindElement.getRoot(this.board, this.element)).rootG;
|
|
3032
|
-
this.drawShape();
|
|
3033
|
-
this.drawLink();
|
|
3034
|
-
this.drawTopic();
|
|
3035
|
-
this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: this.textManage.isEditing });
|
|
3036
|
-
this.drawEmojis();
|
|
3037
|
-
this.drawExtend();
|
|
3038
|
-
this.imageDrawer.drawImage(this.g, this.element);
|
|
3039
|
-
if (PlaitMind.isMind(this.context.parent)) {
|
|
3040
|
-
this.g.classList.add('branch');
|
|
3041
|
-
}
|
|
3042
|
-
}
|
|
3043
|
-
onContextChanged(value, previous) {
|
|
3044
|
-
const newNode = MindElement.getNode(value.element);
|
|
3045
|
-
const isEqualNode = RectangleClient.isEqual(this.node, newNode);
|
|
3046
|
-
this.node = newNode;
|
|
3047
|
-
const isChangeTheme = this.board.operations.find(op => op.type === 'set_theme');
|
|
3048
|
-
if (!isEqualNode || value.element !== previous.element || isChangeTheme) {
|
|
3049
|
-
this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: this.textManage.isEditing });
|
|
3050
|
-
this.drawShape();
|
|
3051
|
-
this.drawLink();
|
|
3052
|
-
this.drawEmojis();
|
|
3053
|
-
this.drawExtend();
|
|
3054
|
-
this.imageDrawer.updateImage(this.g, previous.element, value.element);
|
|
3055
|
-
this.updateTopic();
|
|
3056
|
-
}
|
|
3057
|
-
else {
|
|
3058
|
-
const hasSameSelected = value.selected === previous.selected;
|
|
3059
|
-
const hasSameParent = value.parent === previous.parent;
|
|
3060
|
-
if (!hasSameSelected) {
|
|
3061
|
-
this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: this.textManage.isEditing });
|
|
3062
|
-
}
|
|
3063
|
-
if (!hasSameParent) {
|
|
3064
|
-
this.drawLink();
|
|
3065
|
-
}
|
|
3066
|
-
}
|
|
3067
|
-
}
|
|
3068
|
-
drawEmojis() {
|
|
3069
|
-
const g = this.nodeEmojisDrawer.drawEmojis(this.element);
|
|
3070
|
-
if (g) {
|
|
3071
|
-
this.g.append(g);
|
|
3072
|
-
}
|
|
3073
|
-
}
|
|
3074
|
-
drawShape() {
|
|
3075
|
-
this.destroyShape();
|
|
3076
|
-
const shape = getShapeByElement(this.board, this.node.origin);
|
|
3077
|
-
switch (shape) {
|
|
3078
|
-
case MindElementShape.roundRectangle:
|
|
3079
|
-
this.shapeG = drawRoundRectangleByNode(this.board, this.node);
|
|
3080
|
-
this.g.prepend(this.shapeG);
|
|
3081
|
-
break;
|
|
3082
|
-
default:
|
|
3083
|
-
break;
|
|
3084
|
-
}
|
|
3085
|
-
}
|
|
3086
|
-
destroyShape() {
|
|
3087
|
-
if (this.shapeG) {
|
|
3088
|
-
this.shapeG.remove();
|
|
3089
|
-
this.shapeG = null;
|
|
3090
|
-
}
|
|
3091
|
-
}
|
|
3092
|
-
drawLink() {
|
|
3093
|
-
if (PlaitMind.isMind(this.element)) {
|
|
3094
|
-
return;
|
|
3095
|
-
}
|
|
3096
|
-
const parent = MindElement.getParent(this.element);
|
|
3097
|
-
const parentNode = MindElement.getNode(parent);
|
|
3098
|
-
if (this.linkG) {
|
|
3099
|
-
this.linkG.remove();
|
|
3100
|
-
}
|
|
3101
|
-
const layout = MindQueries.getLayoutByElement(parent);
|
|
3102
|
-
if (AbstractNode.isAbstract(this.node.origin)) {
|
|
3103
|
-
this.linkG = drawAbstractLink(this.board, this.node, isHorizontalLayout(layout));
|
|
3104
|
-
}
|
|
3105
|
-
else {
|
|
3106
|
-
this.linkG = drawLink(this.board, parentNode, this.node, isHorizontalLayout(layout));
|
|
3107
|
-
}
|
|
3108
|
-
this.g.append(this.linkG);
|
|
3109
|
-
}
|
|
3110
|
-
destroyLine() {
|
|
3111
|
-
if (this.linkG) {
|
|
3112
|
-
this.linkG.remove();
|
|
3113
|
-
}
|
|
3114
|
-
}
|
|
3115
|
-
drawExtend() {
|
|
3116
|
-
this.destroyExtend();
|
|
3117
|
-
this.extendG = createG();
|
|
3118
|
-
this.extendG.classList.add('extend');
|
|
3119
|
-
this.g.append(this.extendG);
|
|
3120
|
-
if (this.element.isCollapsed) {
|
|
3121
|
-
this.g.classList.add('collapsed');
|
|
3122
|
-
}
|
|
3123
|
-
else {
|
|
3124
|
-
this.g.classList.remove('collapsed');
|
|
3125
|
-
}
|
|
3126
|
-
this.nodeInsertDrawer.draw(this.element, this.extendG);
|
|
3127
|
-
this.collapseDrawer.draw(this.element, this.extendG);
|
|
3128
|
-
}
|
|
3129
|
-
destroyExtend() {
|
|
3130
|
-
if (this.extendG) {
|
|
3131
|
-
this.extendG.remove();
|
|
3132
|
-
}
|
|
3133
|
-
}
|
|
3134
|
-
drawTopic() {
|
|
3135
|
-
this.textManage.draw(this.element.data.topic);
|
|
3136
|
-
this.g.append(this.textManage.g);
|
|
3137
|
-
if (this.element.manualWidth) {
|
|
3138
|
-
const width = NodeSpace.getNodeDynamicWidth(this.board, this.element);
|
|
3139
|
-
this.textManage.updateWidth(width);
|
|
3140
|
-
}
|
|
3141
|
-
}
|
|
3142
|
-
updateTopic() {
|
|
3143
|
-
this.textManage.updateText(this.element.data.topic);
|
|
3144
|
-
this.textManage.updateRectangle();
|
|
3145
|
-
if (this.element.manualWidth) {
|
|
3146
|
-
const width = NodeSpace.getNodeDynamicWidth(this.board, this.element);
|
|
3147
|
-
this.textManage.updateWidth(width);
|
|
3148
|
-
}
|
|
3149
|
-
}
|
|
3150
|
-
editTopic() {
|
|
3151
|
-
this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: true });
|
|
3152
|
-
// update text max-width when image width greater than topic default max width to cover node topic default max width style
|
|
3153
|
-
const defaultMaxWidth = TOPIC_DEFAULT_MAX_WORD_COUNT * (PlaitMind.isMind(this.element) ? ROOT_TOPIC_FONT_SIZE : TOPIC_FONT_SIZE);
|
|
3154
|
-
let hasMaxWidth = false;
|
|
3155
|
-
if (!this.element.manualWidth && MindElement.hasImage(this.element) && this.element.data.image.width > defaultMaxWidth) {
|
|
3156
|
-
const width = NodeSpace.getNodeDynamicWidth(this.board, this.element);
|
|
3157
|
-
this.textManage.updateWidth(width);
|
|
3158
|
-
hasMaxWidth = true;
|
|
3159
|
-
}
|
|
3160
|
-
this.textManage.edit((origin) => {
|
|
3161
|
-
if (origin === ExitOrigin.default) {
|
|
3162
|
-
this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: false });
|
|
3163
|
-
}
|
|
3164
|
-
if (hasMaxWidth) {
|
|
3165
|
-
this.textManage.updateWidth(0);
|
|
3166
|
-
}
|
|
3167
|
-
});
|
|
3168
|
-
}
|
|
3169
|
-
ngOnDestroy() {
|
|
3170
|
-
super.ngOnDestroy();
|
|
3171
|
-
this.textManage.destroy();
|
|
3172
|
-
this.nodeEmojisDrawer.destroy();
|
|
3173
|
-
this.imageDrawer.destroy();
|
|
3174
|
-
this.destroy$.next();
|
|
3175
|
-
this.destroy$.complete();
|
|
3176
|
-
if (ELEMENT_TO_NODE.get(this.element) === this.node) {
|
|
3177
|
-
ELEMENT_TO_NODE.delete(this.element);
|
|
3178
|
-
}
|
|
3179
|
-
}
|
|
3180
|
-
}
|
|
3181
|
-
MindNodeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindNodeComponent, deps: [{ token: i0.ViewContainerRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
3182
|
-
MindNodeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: MindNodeComponent, selector: "plait-mind-node", usesInheritance: true, ngImport: i0, template: `
|
|
3183
|
-
<plait-children
|
|
3184
|
-
*ngIf="!element.isCollapsed"
|
|
3185
|
-
[board]="board"
|
|
3186
|
-
[parent]="element"
|
|
3187
|
-
[effect]="effect"
|
|
3188
|
-
[parentG]="parentG"
|
|
3189
|
-
></plait-children>
|
|
3190
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: i2.PlaitChildrenElement, selector: "plait-children", inputs: ["board", "parent", "effect", "parentG"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3191
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindNodeComponent, decorators: [{
|
|
3192
|
-
type: Component,
|
|
3193
|
-
args: [{
|
|
3194
|
-
selector: 'plait-mind-node',
|
|
3195
|
-
template: `
|
|
3196
|
-
<plait-children
|
|
3197
|
-
*ngIf="!element.isCollapsed"
|
|
3198
|
-
[board]="board"
|
|
3199
|
-
[parent]="element"
|
|
3200
|
-
[effect]="effect"
|
|
3201
|
-
[parentG]="parentG"
|
|
3202
|
-
></plait-children>
|
|
3203
|
-
`,
|
|
3204
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
3205
|
-
}]
|
|
3206
|
-
}], ctorParameters: function () { return [{ type: i0.ViewContainerRef }, { type: i0.ChangeDetectorRef }]; } });
|
|
3207
|
-
|
|
3208
|
-
class PlaitMindComponent extends MindNodeComponent {
|
|
3209
|
-
ngOnInit() {
|
|
3210
|
-
this.updateMindLayout();
|
|
3211
|
-
super.ngOnInit();
|
|
3212
|
-
this.g.classList.add('root');
|
|
3213
|
-
}
|
|
3214
|
-
beforeContextChange(value) {
|
|
3215
|
-
if (value.element !== this.element && this.initialized) {
|
|
3216
|
-
this.updateMindLayout(value.element);
|
|
3217
|
-
}
|
|
3218
|
-
}
|
|
3219
|
-
updateMindLayout(element = this.element) {
|
|
3220
|
-
const mindLayoutType = element.layout || getDefaultLayout();
|
|
3221
|
-
this.root = GlobalLayout.layout(element, getLayoutOptions(this.board), mindLayoutType);
|
|
3222
|
-
this.updateMindNodeLocation(element);
|
|
3223
|
-
}
|
|
3224
|
-
updateMindNodeLocation(element) {
|
|
3225
|
-
const { x, y, hGap, vGap } = this.root;
|
|
3226
|
-
const offsetX = x + hGap;
|
|
3227
|
-
const offsetY = y + vGap;
|
|
3228
|
-
depthFirstRecursion(this.root, node => {
|
|
3229
|
-
node.x = node.x - offsetX + element.points[0][0];
|
|
3230
|
-
node.y = node.y - offsetY + element.points[0][1];
|
|
3231
|
-
ELEMENT_TO_NODE.set(node.origin, node);
|
|
3232
|
-
});
|
|
3233
|
-
}
|
|
3234
|
-
}
|
|
3235
|
-
PlaitMindComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitMindComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
3236
|
-
PlaitMindComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.5", type: PlaitMindComponent, selector: "plait-mind", usesInheritance: true, ngImport: i0, template: `
|
|
3237
|
-
<plait-children [board]="board" [parent]="element" [effect]="effect" [parentG]="rootG"></plait-children>
|
|
3238
|
-
`, isInline: true, dependencies: [{ kind: "component", type: i2.PlaitChildrenElement, selector: "plait-children", inputs: ["board", "parent", "effect", "parentG"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
3239
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: PlaitMindComponent, decorators: [{
|
|
3240
|
-
type: Component,
|
|
3241
|
-
args: [{
|
|
3242
|
-
selector: 'plait-mind',
|
|
3243
|
-
template: `
|
|
3244
|
-
<plait-children [board]="board" [parent]="element" [effect]="effect" [parentG]="rootG"></plait-children>
|
|
3245
|
-
`,
|
|
3246
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
3247
|
-
}]
|
|
3248
|
-
}] });
|
|
3249
|
-
|
|
3250
|
-
class MindModule {
|
|
3251
|
-
}
|
|
3252
|
-
MindModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
3253
|
-
MindModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.5", ngImport: i0, type: MindModule, declarations: [PlaitMindComponent, MindNodeComponent], imports: [CommonModule, TextModule, PlaitModule], exports: [PlaitMindComponent, MindNodeComponent] });
|
|
3254
|
-
MindModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindModule, imports: [CommonModule, TextModule, PlaitModule] });
|
|
3255
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindModule, decorators: [{
|
|
3256
|
-
type: NgModule,
|
|
3257
|
-
args: [{
|
|
3258
|
-
declarations: [PlaitMindComponent, MindNodeComponent],
|
|
3259
|
-
imports: [CommonModule, TextModule, PlaitModule],
|
|
3260
|
-
exports: [PlaitMindComponent, MindNodeComponent]
|
|
3261
|
-
}]
|
|
3262
|
-
}] });
|
|
3263
|
-
|
|
3264
|
-
const DRAG_MOVE_BUFFER = 5;
|
|
3265
|
-
const withNodeDnd = (board) => {
|
|
3266
|
-
const { pointerDown, pointerMove, globalPointerUp } = board;
|
|
3267
|
-
let activeElements = [];
|
|
3268
|
-
let correspondingElements = [];
|
|
3269
|
-
let startPoint;
|
|
3270
|
-
let dragFakeNodeG;
|
|
3271
|
-
let fakeDropNodeG;
|
|
3272
|
-
let dropTarget = null;
|
|
3273
|
-
let targetPath;
|
|
3274
|
-
board.pointerDown = (event) => {
|
|
3275
|
-
if (PlaitBoard.isReadonly(board) ||
|
|
3276
|
-
PlaitBoard.hasBeenTextEditing(board) ||
|
|
3277
|
-
!PlaitBoard.isPointer(board, PlaitPointerType.selection) ||
|
|
3278
|
-
!isMainPointer(event)) {
|
|
3279
|
-
pointerDown(event);
|
|
3280
|
-
return;
|
|
3281
|
-
}
|
|
3282
|
-
const point = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3283
|
-
const selectedElements = getSelectedElements(board);
|
|
3284
|
-
const hitTarget = getHitElements(board, { ranges: [{ anchor: point, focus: point }] }, (element) => {
|
|
3285
|
-
return MindElement.isMindElement(board, element);
|
|
3286
|
-
});
|
|
3287
|
-
const targetElement = hitTarget && hitTarget.length === 1 ? hitTarget[0] : null;
|
|
3288
|
-
if (targetElement &&
|
|
3289
|
-
MindElement.isMindElement(board, targetElement) &&
|
|
3290
|
-
!targetElement.isRoot &&
|
|
3291
|
-
!AbstractNode.isAbstract(targetElement)) {
|
|
3292
|
-
const targetElements = selectedElements.filter(element => MindElement.isMindElement(board, element) && !element.isRoot && !AbstractNode.isAbstract(element));
|
|
3293
|
-
const isMultiple = selectedElements.length > 0 && selectedElements.includes(targetElement);
|
|
3294
|
-
if (isMultiple) {
|
|
3295
|
-
activeElements = targetElements;
|
|
3296
|
-
startPoint = point;
|
|
3297
|
-
}
|
|
3298
|
-
else {
|
|
3299
|
-
activeElements = [targetElement];
|
|
3300
|
-
startPoint = point;
|
|
3301
|
-
}
|
|
3302
|
-
}
|
|
3303
|
-
if (activeElements.length) {
|
|
3304
|
-
correspondingElements = getOverallAbstracts(board, activeElements);
|
|
3305
|
-
}
|
|
3306
|
-
pointerDown(event);
|
|
3307
|
-
};
|
|
3308
|
-
board.pointerMove = (event) => {
|
|
3309
|
-
if (!board.options.readonly && (activeElements === null || activeElements === void 0 ? void 0 : activeElements.length) && startPoint) {
|
|
3310
|
-
// prevent text from being selected
|
|
3311
|
-
event.preventDefault();
|
|
3312
|
-
const endPoint = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3313
|
-
const distance = distanceBetweenPointAndPoint(startPoint[0], startPoint[1], endPoint[0], endPoint[1]);
|
|
3314
|
-
if (distance < DRAG_MOVE_BUFFER) {
|
|
3315
|
-
return;
|
|
3316
|
-
}
|
|
3317
|
-
setIsDragging(board, true);
|
|
3318
|
-
fakeDropNodeG === null || fakeDropNodeG === void 0 ? void 0 : fakeDropNodeG.remove();
|
|
3319
|
-
const detectPoint = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3320
|
-
dropTarget = detectDropTarget(board, detectPoint, dropTarget, [...activeElements, ...correspondingElements]);
|
|
3321
|
-
if (dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.target) {
|
|
3322
|
-
targetPath = getPathByDropTarget(board, dropTarget);
|
|
3323
|
-
fakeDropNodeG = drawFakeDropNode(board, dropTarget, targetPath);
|
|
3324
|
-
PlaitBoard.getHost(board).appendChild(fakeDropNodeG);
|
|
3325
|
-
}
|
|
3326
|
-
const offsetX = endPoint[0] - startPoint[0];
|
|
3327
|
-
const offsetY = endPoint[1] - startPoint[1];
|
|
3328
|
-
dragFakeNodeG === null || dragFakeNodeG === void 0 ? void 0 : dragFakeNodeG.remove();
|
|
3329
|
-
dragFakeNodeG = createG();
|
|
3330
|
-
[...activeElements, ...correspondingElements].forEach(element => {
|
|
3331
|
-
addActiveOnDragOrigin(element);
|
|
3332
|
-
});
|
|
3333
|
-
activeElements.forEach(element => {
|
|
3334
|
-
const nodeG = drawFakeDragNode(board, element, offsetX, offsetY);
|
|
3335
|
-
dragFakeNodeG === null || dragFakeNodeG === void 0 ? void 0 : dragFakeNodeG.appendChild(nodeG);
|
|
3336
|
-
});
|
|
3337
|
-
PlaitBoard.getHost(board).appendChild(dragFakeNodeG);
|
|
3338
|
-
}
|
|
3339
|
-
pointerMove(event);
|
|
3340
|
-
};
|
|
3341
|
-
board.globalPointerUp = (event) => {
|
|
3342
|
-
const firstLevelElements = getFirstLevelElement(activeElements);
|
|
3343
|
-
if (!board.options.readonly && firstLevelElements.length) {
|
|
3344
|
-
firstLevelElements.push(...correspondingElements);
|
|
3345
|
-
if (isDragging(board)) {
|
|
3346
|
-
firstLevelElements.forEach(element => {
|
|
3347
|
-
removeActiveOnDragOrigin(element);
|
|
3348
|
-
});
|
|
3349
|
-
}
|
|
3350
|
-
if (dropTarget) {
|
|
3351
|
-
const targetPathRef = board.pathRef(targetPath);
|
|
3352
|
-
const targetPreviousPathRef = Path.hasPrevious(targetPath) && board.pathRef(Path.previous(targetPath));
|
|
3353
|
-
const targetElementPathRef = board.pathRef(PlaitBoard.findPath(board, dropTarget.target));
|
|
3354
|
-
let abstractRefs = getValidAbstractRefs(board, firstLevelElements);
|
|
3355
|
-
const normalElements = firstLevelElements
|
|
3356
|
-
.filter(element => !abstractRefs.some(refs => refs.abstract === element))
|
|
3357
|
-
.map(element => {
|
|
3358
|
-
if (AbstractNode.isAbstract(element)) {
|
|
3359
|
-
return adjustAbstractToNode(element);
|
|
3360
|
-
}
|
|
3361
|
-
return element;
|
|
3362
|
-
});
|
|
3363
|
-
const hasPreviousNode = targetPath[targetPath.length - 1] !== 0;
|
|
3364
|
-
if (hasPreviousNode) {
|
|
3365
|
-
const previousElement = PlaitNode.get(board, Path.previous(targetPath));
|
|
3366
|
-
const correspondingAbstract = getCorrespondingAbstract(previousElement);
|
|
3367
|
-
const targetHasCorrespondAbstract = correspondingAbstract && correspondingAbstract.end !== targetPath[targetPath.length - 1] - 1;
|
|
3368
|
-
if (targetHasCorrespondAbstract) {
|
|
3369
|
-
const adjustedNode = abstractRefs.map(ref => {
|
|
3370
|
-
return adjustAbstractToNode(ref.abstract);
|
|
3371
|
-
});
|
|
3372
|
-
normalElements.push(...adjustedNode);
|
|
3373
|
-
abstractRefs = [];
|
|
3374
|
-
}
|
|
3375
|
-
}
|
|
3376
|
-
const effectedAbstracts = deleteElementHandleAbstract(board, firstLevelElements);
|
|
3377
|
-
insertElementHandleAbstract(board, targetPath, normalElements.length, false, effectedAbstracts);
|
|
3378
|
-
MindTransforms.setAbstractsByRefs(board, effectedAbstracts);
|
|
3379
|
-
let refs = deleteElementsHandleRightNodeCount(board, firstLevelElements);
|
|
3380
|
-
const parent = PlaitNode.get(board, Path.parent(targetPath));
|
|
3381
|
-
const shouldChangeRoot = isDropStandardRight(parent, dropTarget);
|
|
3382
|
-
if (shouldChangeRoot && targetElementPathRef.current) {
|
|
3383
|
-
refs = insertElementHandleRightNodeCount(board, targetElementPathRef.current.slice(0, 1), normalElements.length, refs);
|
|
3384
|
-
}
|
|
3385
|
-
MindTransforms.setRightNodeCountByRefs(board, refs);
|
|
3386
|
-
MindTransforms.removeElements(board, firstLevelElements);
|
|
3387
|
-
let insertPath = targetPathRef.current;
|
|
3388
|
-
const parentPath = Path.parent(targetPathRef.current || targetPath);
|
|
3389
|
-
if (!insertPath) {
|
|
3390
|
-
//当插入位置和选中节点位置相同时,使用记录的 previousPath
|
|
3391
|
-
const previousPath = targetPreviousPathRef && targetPreviousPathRef.unref();
|
|
3392
|
-
if (previousPath) {
|
|
3393
|
-
insertPath = Path.next(previousPath);
|
|
3394
|
-
}
|
|
3395
|
-
else {
|
|
3396
|
-
const parent = PlaitNode.get(board, parentPath);
|
|
3397
|
-
const children = getNonAbstractChildren(parent);
|
|
3398
|
-
insertPath = [...parentPath, children.length || 0];
|
|
3399
|
-
}
|
|
3400
|
-
}
|
|
3401
|
-
MindTransforms.insertNodes(board, normalElements, insertPath);
|
|
3402
|
-
if (abstractRefs.length) {
|
|
3403
|
-
MindTransforms.insertAbstractNodes(board, abstractRefs, normalElements, insertPath);
|
|
3404
|
-
}
|
|
3405
|
-
if (targetElementPathRef.current &&
|
|
3406
|
-
targetPathRef.current &&
|
|
3407
|
-
Path.isAncestor(targetElementPathRef.current, targetPathRef.current) &&
|
|
3408
|
-
dropTarget.target.isCollapsed) {
|
|
3409
|
-
Transforms.setNode(board, { isCollapsed: false }, targetElementPathRef.current);
|
|
3410
|
-
}
|
|
3411
|
-
targetElementPathRef.unref();
|
|
3412
|
-
targetPathRef.unref();
|
|
3413
|
-
let setActiveElements = [];
|
|
3414
|
-
depthFirstRecursion(board, node => {
|
|
3415
|
-
const isSelected = activeElements.some(element => element.id === node.id);
|
|
3416
|
-
if (isSelected) {
|
|
3417
|
-
setActiveElements.push(node);
|
|
3418
|
-
}
|
|
3419
|
-
});
|
|
3420
|
-
Transforms.setSelectionWithTemporaryElements(board, setActiveElements);
|
|
3421
|
-
}
|
|
3422
|
-
setIsDragging(board, false);
|
|
3423
|
-
activeElements = [];
|
|
3424
|
-
dragFakeNodeG === null || dragFakeNodeG === void 0 ? void 0 : dragFakeNodeG.remove();
|
|
3425
|
-
dragFakeNodeG = undefined;
|
|
3426
|
-
fakeDropNodeG === null || fakeDropNodeG === void 0 ? void 0 : fakeDropNodeG.remove();
|
|
3427
|
-
fakeDropNodeG = undefined;
|
|
3428
|
-
dropTarget = null;
|
|
3429
|
-
}
|
|
3430
|
-
globalPointerUp(event);
|
|
3431
|
-
};
|
|
3432
|
-
return board;
|
|
3433
|
-
};
|
|
3434
|
-
|
|
3435
|
-
const buildClipboardData = (board, selectedElements, startPoint) => {
|
|
3436
|
-
let result = [];
|
|
3437
|
-
// get overall abstract
|
|
3438
|
-
const overallAbstracts = getOverallAbstracts(board, selectedElements);
|
|
3439
|
-
// get valid abstract refs
|
|
3440
|
-
const validAbstractRefs = getValidAbstractRefs(board, [...selectedElements, ...overallAbstracts]);
|
|
3441
|
-
// keep correct order
|
|
3442
|
-
const newSelectedElements = selectedElements.filter(value => !validAbstractRefs.find(ref => ref.abstract === value));
|
|
3443
|
-
newSelectedElements.push(...validAbstractRefs.map(value => value.abstract));
|
|
3444
|
-
const selectedMindNodes = newSelectedElements.map(value => MindElement.getNode(value));
|
|
3445
|
-
newSelectedElements.forEach((element, index) => {
|
|
3446
|
-
// handle relative location
|
|
3447
|
-
const nodeRectangle = getRectangleByNode(selectedMindNodes[index]);
|
|
3448
|
-
const points = [[nodeRectangle.x - startPoint[0], nodeRectangle.y - startPoint[1]]];
|
|
3449
|
-
// handle invalid abstract
|
|
3450
|
-
const abstractRef = validAbstractRefs.find(ref => ref.abstract === element);
|
|
3451
|
-
if (AbstractNode.isAbstract(element) && abstractRef) {
|
|
3452
|
-
const { start, end } = getRelativeStartEndByAbstractRef(abstractRef, newSelectedElements);
|
|
3453
|
-
result.push(Object.assign(Object.assign({}, element), { points,
|
|
3454
|
-
start,
|
|
3455
|
-
end }));
|
|
3456
|
-
}
|
|
3457
|
-
else {
|
|
3458
|
-
if (AbstractNode.isAbstract(element)) {
|
|
3459
|
-
let newElement = Object.assign(Object.assign({}, element), { points });
|
|
3460
|
-
delete newElement.start;
|
|
3461
|
-
delete newElement.end;
|
|
3462
|
-
result.push(newElement);
|
|
3463
|
-
}
|
|
3464
|
-
else {
|
|
3465
|
-
result.push(Object.assign(Object.assign({}, element), { points: points }));
|
|
3466
|
-
}
|
|
3467
|
-
}
|
|
3468
|
-
});
|
|
3469
|
-
return result;
|
|
3470
|
-
};
|
|
3471
|
-
const setMindClipboardData = (data, elements) => {
|
|
3472
|
-
const text = elements.reduce((string, currentNode) => {
|
|
3473
|
-
return string + extractNodesText(currentNode);
|
|
3474
|
-
}, '');
|
|
3475
|
-
setClipboardData(data, elements);
|
|
3476
|
-
setClipboardDataByText(data, text);
|
|
3477
|
-
};
|
|
3478
|
-
const insertClipboardData = (board, elements, targetPoint) => {
|
|
3479
|
-
let newElement, path;
|
|
3480
|
-
const selectedElements = getSelectedElements(board);
|
|
3481
|
-
let newELements = [];
|
|
3482
|
-
const hasTargetParent = selectedElements.length === 1;
|
|
3483
|
-
const targetParent = selectedElements[0];
|
|
3484
|
-
const targetParentPath = targetParent && PlaitBoard.findPath(board, targetParent);
|
|
3485
|
-
const nonAbstractChildrenLength = targetParent && getNonAbstractChildren(targetParent).length;
|
|
3486
|
-
elements.forEach((item, index) => {
|
|
3487
|
-
newElement = copyNewNode(item);
|
|
3488
|
-
if (hasTargetParent) {
|
|
3489
|
-
if (item.isRoot) {
|
|
3490
|
-
newElement = adjustRootToNode(board, newElement);
|
|
3491
|
-
const styles = PlaitMind.isMind(targetParent) ? { fontFamily: BRANCH_FONT_FAMILY } : { fontFamily: DEFAULT_FONT_FAMILY };
|
|
3492
|
-
const { width, height } = getTextSize(board, newElement.data.topic, TOPIC_DEFAULT_MAX_WORD_COUNT, Object.assign(Object.assign({}, styles), { width: newElement.manualWidth ? newElement.manualWidth : undefined }));
|
|
3493
|
-
newElement.width = Math.max(width, getNodeDefaultFontSize());
|
|
3494
|
-
newElement.height = height;
|
|
3495
|
-
}
|
|
3496
|
-
// handle abstract start and end
|
|
3497
|
-
if (AbstractNode.isAbstract(newElement)) {
|
|
3498
|
-
newElement.start = newElement.start + nonAbstractChildrenLength;
|
|
3499
|
-
newElement.end = newElement.end + nonAbstractChildrenLength;
|
|
3500
|
-
}
|
|
3501
|
-
path = [...targetParentPath, nonAbstractChildrenLength + index];
|
|
3502
|
-
}
|
|
3503
|
-
else {
|
|
3504
|
-
const point = [targetPoint[0] + item.points[0][0], targetPoint[1] + item.points[0][1]];
|
|
3505
|
-
newElement.points = [point];
|
|
3506
|
-
if (AbstractNode.isAbstract(item)) {
|
|
3507
|
-
newElement = adjustAbstractToNode(newElement);
|
|
3508
|
-
}
|
|
3509
|
-
if (!item.isRoot) {
|
|
3510
|
-
newElement = adjustNodeToRoot(board, newElement);
|
|
3511
|
-
}
|
|
3512
|
-
path = [board.children.length];
|
|
3513
|
-
}
|
|
3514
|
-
newELements.push(newElement);
|
|
3515
|
-
Transforms.insertNode(board, newElement, path);
|
|
3516
|
-
return;
|
|
3517
|
-
});
|
|
3518
|
-
Transforms.setSelectionWithTemporaryElements(board, newELements);
|
|
3519
|
-
};
|
|
3520
|
-
const insertClipboardText = (board, targetParent, text) => {
|
|
3521
|
-
const styles = PlaitMind.isMind(targetParent) ? { fontFamily: BRANCH_FONT_FAMILY } : { fontFamily: DEFAULT_FONT_FAMILY };
|
|
3522
|
-
const { width, height } = getTextSize(board, text, TOPIC_DEFAULT_MAX_WORD_COUNT, styles);
|
|
3523
|
-
const newElement = createMindElement(text, Math.max(width, getFontSizeBySlateElement(text)), height, {});
|
|
3524
|
-
Transforms.insertNode(board, newElement, findNewChildNodePath(board, targetParent));
|
|
3525
|
-
return;
|
|
3526
|
-
};
|
|
3527
|
-
|
|
3528
|
-
const withAbstract = (board) => {
|
|
3529
|
-
const newBoard = board;
|
|
3530
|
-
const { mousedown, mousemove, mouseup } = board;
|
|
3531
|
-
let activeAbstractElement;
|
|
3532
|
-
let abstractHandlePosition;
|
|
3533
|
-
let touchedAbstract;
|
|
3534
|
-
let startPoint;
|
|
3535
|
-
let newProperty;
|
|
3536
|
-
board.mousedown = (event) => {
|
|
3537
|
-
if (!isMainPointer(event)) {
|
|
3538
|
-
mousedown(event);
|
|
3539
|
-
return;
|
|
3540
|
-
}
|
|
3541
|
-
const activeAbstractElements = getSelectedElements(board).filter(element => AbstractNode.isAbstract(element));
|
|
3542
|
-
const host = BOARD_TO_HOST.get(board);
|
|
3543
|
-
const point = transformPoint(board, toPoint(event.x, event.y, host));
|
|
3544
|
-
activeAbstractElement = activeAbstractElements.find(element => {
|
|
3545
|
-
abstractHandlePosition = getHitAbstractHandle(board, element, point);
|
|
3546
|
-
return abstractHandlePosition;
|
|
3547
|
-
});
|
|
3548
|
-
if (activeAbstractElement) {
|
|
3549
|
-
if (newBoard === null || newBoard === void 0 ? void 0 : newBoard.onAbstractResize) {
|
|
3550
|
-
newBoard.onAbstractResize(AbstractResizeState.start);
|
|
3551
|
-
}
|
|
3552
|
-
startPoint = point;
|
|
3553
|
-
return;
|
|
3554
|
-
}
|
|
3555
|
-
mousedown(event);
|
|
3556
|
-
};
|
|
3557
|
-
board.mousemove = (event) => {
|
|
3558
|
-
getSelectedElements(board);
|
|
3559
|
-
const host = BOARD_TO_HOST.get(board);
|
|
3560
|
-
const endPoint = transformPoint(board, toPoint(event.x, event.y, host));
|
|
3561
|
-
touchedAbstract = handleTouchedAbstract(board, touchedAbstract, endPoint);
|
|
3562
|
-
if (abstractHandlePosition && activeAbstractElement) {
|
|
3563
|
-
// prevent text from being selected
|
|
3564
|
-
event.preventDefault();
|
|
3565
|
-
const abstractComponent = PlaitElement.getComponent(activeAbstractElement);
|
|
3566
|
-
const element = abstractComponent.element;
|
|
3567
|
-
const nodeLayout = MindQueries.getCorrectLayoutByElement(board, activeAbstractElement);
|
|
3568
|
-
const isHorizontal = isHorizontalLayout(nodeLayout);
|
|
3569
|
-
const parentElement = MindElement.getParent(element);
|
|
3570
|
-
let children = parentElement.children;
|
|
3571
|
-
const parentLayout = MindQueries.getLayoutByElement(parentElement);
|
|
3572
|
-
if (isStandardLayout(parentLayout)) {
|
|
3573
|
-
const rightNodeCount = parentElement.rightNodeCount;
|
|
3574
|
-
const { leftChildren, rightChildren } = separateChildren(parentElement);
|
|
3575
|
-
if (activeAbstractElement.end < rightNodeCount) {
|
|
3576
|
-
children = rightChildren;
|
|
3577
|
-
}
|
|
3578
|
-
if (activeAbstractElement.start >= rightNodeCount) {
|
|
3579
|
-
children = leftChildren;
|
|
3580
|
-
}
|
|
3581
|
-
}
|
|
3582
|
-
if (newBoard === null || newBoard === void 0 ? void 0 : newBoard.onAbstractResize) {
|
|
3583
|
-
newBoard.onAbstractResize(AbstractResizeState.resizing);
|
|
3584
|
-
}
|
|
3585
|
-
const resizingLocation = isHorizontal ? endPoint[1] : endPoint[0];
|
|
3586
|
-
const parent = MindElement.getNode(parentElement);
|
|
3587
|
-
const scope = getLocationScope(board, abstractHandlePosition, children, element, parent, isHorizontal);
|
|
3588
|
-
const location = Math.min(scope.max, Math.max(scope.min, resizingLocation));
|
|
3589
|
-
let locationIndex = findLocationLeftIndex(board, children, location, isHorizontal);
|
|
3590
|
-
const isPropertyUnchanged = (abstractHandlePosition === AbstractHandlePosition.start &&
|
|
3591
|
-
locationIndex + 1 === activeAbstractElement.start) ||
|
|
3592
|
-
(abstractHandlePosition === AbstractHandlePosition.end && locationIndex === activeAbstractElement.end);
|
|
3593
|
-
if (isPropertyUnchanged) {
|
|
3594
|
-
newProperty = undefined;
|
|
3595
|
-
}
|
|
3596
|
-
else {
|
|
3597
|
-
if (isStandardLayout(parent.layout)) {
|
|
3598
|
-
const rightNodeCount = parent.origin.rightNodeCount;
|
|
3599
|
-
let start = element.start;
|
|
3600
|
-
if (start >= rightNodeCount) {
|
|
3601
|
-
locationIndex += rightNodeCount;
|
|
3602
|
-
}
|
|
3603
|
-
}
|
|
3604
|
-
newProperty =
|
|
3605
|
-
abstractHandlePosition === AbstractHandlePosition.start ? { start: locationIndex + 1 } : { end: locationIndex };
|
|
3606
|
-
}
|
|
3607
|
-
abstractComponent.activeDrawer.updateAbstractOutline(activeAbstractElement, abstractHandlePosition, location);
|
|
3608
|
-
}
|
|
3609
|
-
mousemove(event);
|
|
3610
|
-
};
|
|
3611
|
-
board.mouseup = (event) => {
|
|
3612
|
-
startPoint = undefined;
|
|
3613
|
-
abstractHandlePosition = undefined;
|
|
3614
|
-
if (activeAbstractElement) {
|
|
3615
|
-
if (newBoard === null || newBoard === void 0 ? void 0 : newBoard.onAbstractResize) {
|
|
3616
|
-
newBoard.onAbstractResize(AbstractResizeState.end);
|
|
3617
|
-
}
|
|
3618
|
-
if (newProperty) {
|
|
3619
|
-
const path = PlaitBoard.findPath(board, activeAbstractElement);
|
|
3620
|
-
Transforms.setNode(board, newProperty, path);
|
|
3621
|
-
}
|
|
3622
|
-
else {
|
|
3623
|
-
const abstractComponent = PlaitElement.getComponent(activeAbstractElement);
|
|
3624
|
-
abstractComponent.activeDrawer.updateAbstractOutline(activeAbstractElement);
|
|
3625
|
-
}
|
|
3626
|
-
activeAbstractElement = undefined;
|
|
3627
|
-
}
|
|
3628
|
-
mouseup(event);
|
|
3629
|
-
};
|
|
3630
|
-
return board;
|
|
3631
|
-
};
|
|
3632
|
-
|
|
3633
|
-
const withMindExtend = (board) => {
|
|
3634
|
-
const newBoard = board;
|
|
3635
|
-
newBoard.drawEmoji = (emoji, element) => {
|
|
3636
|
-
throw new Error('Not implement drawEmoji method error.');
|
|
3637
|
-
};
|
|
3638
|
-
board.setPluginOptions(WithMindPluginKey, { spaceBetweenEmojis: 4, emojiPadding: 0 });
|
|
3639
|
-
return newBoard;
|
|
3640
|
-
};
|
|
3641
|
-
|
|
3642
|
-
const DefaultHotkey = 'm';
|
|
3643
|
-
const withCreateMind = (board) => {
|
|
3644
|
-
const newBoard = board;
|
|
3645
|
-
const { keydown, mousedown, mousemove, mouseup } = board;
|
|
3646
|
-
let fakeCreateNodeRef = null;
|
|
3647
|
-
newBoard.mousedown = (event) => {
|
|
3648
|
-
if (fakeCreateNodeRef && PlaitBoard.isPointer(board, MindPointerType.mind)) {
|
|
3649
|
-
const currentOptions = board.getPluginOptions(PlaitPluginKey.withSelection);
|
|
3650
|
-
board.setPluginOptions(PlaitPluginKey.withSelection, {
|
|
3651
|
-
isDisabledSelect: true
|
|
3652
|
-
});
|
|
3653
|
-
setTimeout(() => {
|
|
3654
|
-
board.setPluginOptions(PlaitPluginKey.withSelection, Object.assign({}, currentOptions));
|
|
3655
|
-
}, 0);
|
|
3656
|
-
}
|
|
3657
|
-
mousedown(event);
|
|
3658
|
-
};
|
|
3659
|
-
newBoard.mousemove = (event) => {
|
|
3660
|
-
if (PlaitBoard.isReadonly(board)) {
|
|
3661
|
-
mousemove(event);
|
|
3662
|
-
return;
|
|
3663
|
-
}
|
|
3664
|
-
if (PlaitBoard.isPointer(board, MindPointerType.mind)) {
|
|
3665
|
-
throttleRAF(() => {
|
|
3666
|
-
const movingPoint = PlaitBoard.getMovingPointInBoard(board);
|
|
3667
|
-
if (movingPoint) {
|
|
3668
|
-
const targetPoint = transformPoint(board, toPoint(movingPoint[0], movingPoint[1], PlaitBoard.getHost(board)));
|
|
3669
|
-
const emptyMind = createEmptyMind(targetPoint);
|
|
3670
|
-
const nodeRectangle = getRectangleByElement(newBoard, targetPoint, emptyMind);
|
|
3671
|
-
const nodeG = drawRoundRectangleByElement(board, nodeRectangle, emptyMind);
|
|
3672
|
-
const topicRectangle = getTopicRectangleByElement(newBoard, nodeRectangle, emptyMind);
|
|
3673
|
-
if (!fakeCreateNodeRef) {
|
|
3674
|
-
const textManage = new TextManage(board, PlaitBoard.getComponent(board).viewContainerRef, {
|
|
3675
|
-
getRectangle: () => {
|
|
3676
|
-
return topicRectangle;
|
|
3677
|
-
}
|
|
3678
|
-
});
|
|
3679
|
-
PlaitBoard.getComponent(board)
|
|
3680
|
-
.viewContainerRef.injector.get(NgZone)
|
|
3681
|
-
.run(() => {
|
|
3682
|
-
textManage.draw(emptyMind.data.topic);
|
|
3683
|
-
});
|
|
3684
|
-
fakeCreateNodeRef = {
|
|
3685
|
-
g: createG(),
|
|
3686
|
-
nodeG,
|
|
3687
|
-
textManage
|
|
3688
|
-
};
|
|
3689
|
-
fakeCreateNodeRef.g.classList.add('root');
|
|
3690
|
-
fakeCreateNodeRef.g.setAttribute('plait-mind-temporary', 'true');
|
|
3691
|
-
PlaitBoard.getHost(board).append(fakeCreateNodeRef.g);
|
|
3692
|
-
fakeCreateNodeRef.g.append(...[fakeCreateNodeRef.nodeG, textManage.g]);
|
|
3693
|
-
}
|
|
3694
|
-
else {
|
|
3695
|
-
fakeCreateNodeRef.textManage.updateRectangle(topicRectangle);
|
|
3696
|
-
fakeCreateNodeRef.nodeG.remove();
|
|
3697
|
-
fakeCreateNodeRef.nodeG = nodeG;
|
|
3698
|
-
fakeCreateNodeRef.g.append(nodeG);
|
|
3699
|
-
fakeCreateNodeRef.g.append(fakeCreateNodeRef.textManage.g);
|
|
3700
|
-
}
|
|
3701
|
-
}
|
|
3702
|
-
});
|
|
3703
|
-
}
|
|
3704
|
-
else {
|
|
3705
|
-
destroy();
|
|
3706
|
-
}
|
|
3707
|
-
mousemove(event);
|
|
3708
|
-
};
|
|
3709
|
-
newBoard.mouseup = (event) => {
|
|
3710
|
-
const movingPoint = PlaitBoard.getMovingPointInBoard(board);
|
|
3711
|
-
if (movingPoint && fakeCreateNodeRef && PlaitBoard.isPointer(board, MindPointerType.mind)) {
|
|
3712
|
-
const targetPoint = transformPoint(board, toPoint(movingPoint[0], movingPoint[1], PlaitBoard.getHost(board)));
|
|
3713
|
-
const emptyMind = createEmptyMind(targetPoint);
|
|
3714
|
-
Transforms.insertNode(board, emptyMind, [board.children.length]);
|
|
3715
|
-
clearSelectedElement(board);
|
|
3716
|
-
addSelectedElement(board, emptyMind);
|
|
3717
|
-
BoardTransforms.updatePointerType(board, PlaitPointerType.selection);
|
|
3718
|
-
}
|
|
3719
|
-
destroy();
|
|
3720
|
-
mouseup(event);
|
|
3721
|
-
};
|
|
3722
|
-
board.keydown = (event) => {
|
|
3723
|
-
if (PlaitBoard.isReadonly(board) || getSelectedElements(board).length > 0) {
|
|
3724
|
-
keydown(event);
|
|
3725
|
-
return;
|
|
3726
|
-
}
|
|
3727
|
-
if (event.key === DefaultHotkey && !PlaitBoard.isPointer(board, MindPointerType.mind)) {
|
|
3728
|
-
BoardTransforms.updatePointerType(board, MindPointerType.mind);
|
|
3729
|
-
event.preventDefault();
|
|
3730
|
-
return;
|
|
3731
|
-
}
|
|
3732
|
-
keydown(event);
|
|
3733
|
-
};
|
|
3734
|
-
function destroy() {
|
|
3735
|
-
if (fakeCreateNodeRef) {
|
|
3736
|
-
fakeCreateNodeRef.textManage.destroy();
|
|
3737
|
-
fakeCreateNodeRef.g.remove();
|
|
3738
|
-
fakeCreateNodeRef = null;
|
|
3739
|
-
}
|
|
3740
|
-
}
|
|
3741
|
-
return newBoard;
|
|
3742
|
-
};
|
|
3743
|
-
|
|
3744
|
-
const withMindHotkey = (baseBoard) => {
|
|
3745
|
-
const board = baseBoard;
|
|
3746
|
-
const { keydown, deleteFragment } = board;
|
|
3747
|
-
board.keydown = (event) => {
|
|
3748
|
-
const selectedElements = getSelectedElements(board);
|
|
3749
|
-
const isSingleSelection = selectedElements.length === 1;
|
|
3750
|
-
const isSingleMindElement = selectedElements.length === 1 && MindElement.isMindElement(board, selectedElements[0]);
|
|
3751
|
-
const targetElement = selectedElements[0];
|
|
3752
|
-
if (isExpandHotkey(event) && isSingleMindElement && !PlaitMind.isMind(targetElement)) {
|
|
3753
|
-
if (targetElement.children && targetElement.children.length > 0) {
|
|
3754
|
-
Transforms.setNode(board, { isCollapsed: targetElement.isCollapsed ? false : true }, PlaitBoard.findPath(board, targetElement));
|
|
3755
|
-
return;
|
|
3756
|
-
}
|
|
3757
|
-
}
|
|
3758
|
-
if (!PlaitBoard.isReadonly(board)) {
|
|
3759
|
-
if (isTabHotkey(event) && isSingleMindElement) {
|
|
3760
|
-
event.preventDefault();
|
|
3761
|
-
removeSelectedElement(board, targetElement);
|
|
3762
|
-
const targetElementPath = PlaitBoard.findPath(board, targetElement);
|
|
3763
|
-
if (targetElement.isCollapsed) {
|
|
3764
|
-
const newElement = { isCollapsed: false };
|
|
3765
|
-
PlaitHistoryBoard.withoutSaving(board, () => {
|
|
3766
|
-
Transforms.setNode(board, newElement, targetElementPath);
|
|
3767
|
-
});
|
|
3768
|
-
}
|
|
3769
|
-
insertMindElement(board, targetElement, findNewChildNodePath(board, targetElement));
|
|
3770
|
-
return;
|
|
3771
|
-
}
|
|
3772
|
-
if (isEnterHotkey(event) &&
|
|
3773
|
-
isSingleMindElement &&
|
|
3774
|
-
!PlaitMind.isMind(targetElement) &&
|
|
3775
|
-
!AbstractNode.isAbstract(targetElement)) {
|
|
3776
|
-
const targetElementPath = PlaitBoard.findPath(board, targetElement);
|
|
3777
|
-
if (isInRightBranchOfStandardLayout(targetElement)) {
|
|
3778
|
-
const refs = insertElementHandleRightNodeCount(board, targetElementPath.slice(0, 1), 1);
|
|
3779
|
-
MindTransforms.setRightNodeCountByRefs(board, refs);
|
|
3780
|
-
}
|
|
3781
|
-
const abstractRefs = insertElementHandleAbstract(board, Path.next(targetElementPath));
|
|
3782
|
-
MindTransforms.setAbstractsByRefs(board, abstractRefs);
|
|
3783
|
-
insertMindElement(board, targetElement, findNewSiblingNodePath(board, targetElement));
|
|
3784
|
-
return;
|
|
3785
|
-
}
|
|
3786
|
-
if (!isVirtualKey(event) && !isSpaceHotkey(event) && isSingleSelection && MindElement.isMindElement(board, targetElement)) {
|
|
3787
|
-
event.preventDefault();
|
|
3788
|
-
editTopic(targetElement);
|
|
3789
|
-
return;
|
|
3790
|
-
}
|
|
3791
|
-
}
|
|
3792
|
-
keydown(event);
|
|
3793
|
-
};
|
|
3794
|
-
board.deleteFragment = (data) => {
|
|
3795
|
-
const targetMindElements = getSelectedMindElements(board);
|
|
3796
|
-
if (targetMindElements.length) {
|
|
3797
|
-
const firstLevelElements = getFirstLevelElement(targetMindElements).reverse();
|
|
3798
|
-
const abstractRefs = deleteElementHandleAbstract(board, firstLevelElements);
|
|
3799
|
-
MindTransforms.setAbstractsByRefs(board, abstractRefs);
|
|
3800
|
-
const refs = deleteElementsHandleRightNodeCount(board, targetMindElements);
|
|
3801
|
-
MindTransforms.setRightNodeCountByRefs(board, refs);
|
|
3802
|
-
MindTransforms.removeElements(board, targetMindElements);
|
|
3803
|
-
const nextSelected = getNextSelectedElement(board, firstLevelElements);
|
|
3804
|
-
if (nextSelected) {
|
|
3805
|
-
addSelectedElement(board, nextSelected);
|
|
3806
|
-
}
|
|
3807
|
-
}
|
|
3808
|
-
deleteFragment(data);
|
|
3809
|
-
};
|
|
3810
|
-
return board;
|
|
3811
|
-
};
|
|
3812
|
-
const getNextSelectedElement = (board, firstLevelElements) => {
|
|
3813
|
-
let activeElement;
|
|
3814
|
-
const firstLevelElement = firstLevelElements[0];
|
|
3815
|
-
const firstLevelElementPath = PlaitBoard.findPath(board, firstLevelElement);
|
|
3816
|
-
let nextSelectedPath = firstLevelElementPath;
|
|
3817
|
-
if (Path.hasPrevious(firstLevelElementPath)) {
|
|
3818
|
-
nextSelectedPath = Path.previous(firstLevelElementPath);
|
|
3819
|
-
}
|
|
3820
|
-
if (AbstractNode.isAbstract(firstLevelElement)) {
|
|
3821
|
-
const parent = MindElement.getParent(firstLevelElement);
|
|
3822
|
-
if (!firstLevelElements.includes(parent.children[firstLevelElement.start])) {
|
|
3823
|
-
activeElement = parent.children[firstLevelElement.start];
|
|
3824
|
-
}
|
|
3825
|
-
}
|
|
3826
|
-
try {
|
|
3827
|
-
if (!activeElement) {
|
|
3828
|
-
activeElement = PlaitNode.get(board, nextSelectedPath);
|
|
3829
|
-
}
|
|
3830
|
-
}
|
|
3831
|
-
catch (error) { }
|
|
3832
|
-
const firstElement = firstLevelElements[0];
|
|
3833
|
-
const firstElementParent = MindElement.findParent(firstElement);
|
|
3834
|
-
const hasSameParent = firstLevelElements.every(element => {
|
|
3835
|
-
return MindElement.findParent(element) === firstElementParent;
|
|
3836
|
-
});
|
|
3837
|
-
if (firstElementParent && hasSameParent && !activeElement) {
|
|
3838
|
-
activeElement = firstElementParent;
|
|
3839
|
-
}
|
|
3840
|
-
return activeElement;
|
|
3841
|
-
};
|
|
3842
|
-
|
|
3843
|
-
const mouseMoveHandle = (board, event, nodeHoveredExtendRef) => {
|
|
3844
|
-
let target = null;
|
|
3845
|
-
const point = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3846
|
-
depthFirstRecursion(board, element => {
|
|
3847
|
-
if (target) {
|
|
3848
|
-
return;
|
|
3849
|
-
}
|
|
3850
|
-
if (!MindElement.isMindElement(board, element)) {
|
|
3851
|
-
return;
|
|
3852
|
-
}
|
|
3853
|
-
const isHitElement = isHitMindElement(board, point, element);
|
|
3854
|
-
if (isHitElement) {
|
|
3855
|
-
target = element;
|
|
3856
|
-
}
|
|
3857
|
-
}, getIsRecursionFunc(board), true);
|
|
3858
|
-
if (nodeHoveredExtendRef && target && nodeHoveredExtendRef.element === target) {
|
|
3859
|
-
return nodeHoveredExtendRef;
|
|
3860
|
-
}
|
|
3861
|
-
if (nodeHoveredExtendRef) {
|
|
3862
|
-
removeHovered(nodeHoveredExtendRef.element);
|
|
3863
|
-
}
|
|
3864
|
-
if (target) {
|
|
3865
|
-
addHovered(target);
|
|
3866
|
-
if (nodeHoveredExtendRef) {
|
|
3867
|
-
nodeHoveredExtendRef.element = target;
|
|
3868
|
-
}
|
|
3869
|
-
else {
|
|
3870
|
-
nodeHoveredExtendRef = { element: target };
|
|
3871
|
-
}
|
|
3872
|
-
}
|
|
3873
|
-
else {
|
|
3874
|
-
nodeHoveredExtendRef = null;
|
|
3875
|
-
}
|
|
3876
|
-
return nodeHoveredExtendRef;
|
|
3877
|
-
};
|
|
3878
|
-
const mouseLeaveHandle = (board, event, nodeHoveredExtendRef) => {
|
|
3879
|
-
if (nodeHoveredExtendRef) {
|
|
3880
|
-
removeHovered(nodeHoveredExtendRef.element);
|
|
3881
|
-
}
|
|
3882
|
-
};
|
|
3883
|
-
const addHovered = (element) => {
|
|
3884
|
-
const component = PlaitElement.getComponent(element);
|
|
3885
|
-
component.g.classList.add('hovered');
|
|
3886
|
-
};
|
|
3887
|
-
const removeHovered = (element) => {
|
|
3888
|
-
const component = PlaitElement.getComponent(element);
|
|
3889
|
-
if (component && component.g) {
|
|
3890
|
-
component.g.classList.remove('hovered');
|
|
3891
|
-
}
|
|
3892
|
-
};
|
|
3893
|
-
|
|
3894
|
-
const withNodeHoverDetect = (board) => {
|
|
3895
|
-
const { mousemove, mouseleave } = board;
|
|
3896
|
-
let nodeHoveredExtendRef = null;
|
|
3897
|
-
board.mousemove = (event) => {
|
|
3898
|
-
nodeHoveredExtendRef = mouseMoveHandle(board, event, nodeHoveredExtendRef);
|
|
3899
|
-
mousemove(event);
|
|
3900
|
-
};
|
|
3901
|
-
board.mouseleave = (event) => {
|
|
3902
|
-
mouseLeaveHandle(board, event, nodeHoveredExtendRef);
|
|
3903
|
-
nodeHoveredExtendRef = null;
|
|
3904
|
-
mouseleave(event);
|
|
3905
|
-
};
|
|
3906
|
-
return board;
|
|
3907
|
-
};
|
|
3908
|
-
|
|
3909
|
-
const withNodeImage = (board) => {
|
|
3910
|
-
const { keydown, pointerDown, globalPointerUp, setFragment, insertFragment, deleteFragment } = board;
|
|
3911
|
-
board.pointerDown = (event) => {
|
|
3912
|
-
const selectedImageElement = getSelectedImageElement(board);
|
|
3913
|
-
if (PlaitBoard.isReadonly(board) || !isMainPointer(event) || !PlaitBoard.isPointer(board, PlaitPointerType.selection)) {
|
|
3914
|
-
if (selectedImageElement) {
|
|
3915
|
-
setImageFocus(board, selectedImageElement, false);
|
|
3916
|
-
}
|
|
3917
|
-
pointerDown(event);
|
|
3918
|
-
return;
|
|
3919
|
-
}
|
|
3920
|
-
const point = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3921
|
-
const range = { anchor: point, focus: point };
|
|
3922
|
-
const hitImageElements = getHitElements(board, { ranges: [range] }, (value) => MindElement.isMindElement(board, value) && MindElement.hasImage(value));
|
|
3923
|
-
const hasImage = hitImageElements.length;
|
|
3924
|
-
const hitImage = hasImage > 0 && isHitImage(board, hitImageElements[0], range);
|
|
3925
|
-
if (selectedImageElement && hitImage && hitImageElements[0] === selectedImageElement) {
|
|
3926
|
-
temporaryDisableSelection(board);
|
|
3927
|
-
pointerDown(event);
|
|
3928
|
-
return;
|
|
3929
|
-
}
|
|
3930
|
-
if (selectedImageElement) {
|
|
3931
|
-
setImageFocus(board, selectedImageElement, false);
|
|
3932
|
-
}
|
|
3933
|
-
if (hitImage) {
|
|
3934
|
-
temporaryDisableSelection(board);
|
|
3935
|
-
setImageFocus(board, hitImageElements[0], true);
|
|
3936
|
-
}
|
|
3937
|
-
pointerDown(event);
|
|
3938
|
-
};
|
|
3939
|
-
board.keydown = (event) => {
|
|
3940
|
-
const selectedImageElement = getSelectedImageElement(board);
|
|
3941
|
-
if (!PlaitBoard.isReadonly(board) && selectedImageElement && (hotkeys.isDeleteBackward(event) || hotkeys.isDeleteForward(event))) {
|
|
3942
|
-
addSelectedElement(board, selectedImageElement);
|
|
3943
|
-
MindTransforms.removeImage(board, selectedImageElement);
|
|
3944
|
-
return;
|
|
3945
|
-
}
|
|
3946
|
-
keydown(event);
|
|
3947
|
-
};
|
|
3948
|
-
board.globalPointerUp = (event) => {
|
|
3949
|
-
if (PlaitBoard.isFocus(board)) {
|
|
3950
|
-
const isInBoard = event.target instanceof Node && PlaitBoard.getBoardContainer(board).contains(event.target);
|
|
3951
|
-
const selectedImageElement = getSelectedImageElement(board);
|
|
3952
|
-
// Clear image selection when mouse board outside area
|
|
3953
|
-
if (selectedImageElement && !isInBoard) {
|
|
3954
|
-
setImageFocus(board, selectedImageElement, false);
|
|
3955
|
-
}
|
|
3956
|
-
}
|
|
3957
|
-
globalPointerUp(event);
|
|
3958
|
-
};
|
|
3959
|
-
board.setFragment = (data, rectangle) => {
|
|
3960
|
-
const selectedImageElement = getSelectedImageElement(board);
|
|
3961
|
-
if (selectedImageElement) {
|
|
3962
|
-
setClipboardDataByMedia(data, selectedImageElement.data.image, MediaKeys.image);
|
|
3963
|
-
return;
|
|
3964
|
-
}
|
|
3965
|
-
setFragment(data, rectangle);
|
|
3966
|
-
};
|
|
3967
|
-
board.deleteFragment = (data) => {
|
|
3968
|
-
const selectedImageElement = getSelectedImageElement(board);
|
|
3969
|
-
if (selectedImageElement) {
|
|
3970
|
-
MindTransforms.removeImage(board, selectedImageElement);
|
|
3971
|
-
}
|
|
3972
|
-
deleteFragment(data);
|
|
3973
|
-
};
|
|
3974
|
-
board.insertFragment = (data, targetPoint) => {
|
|
3975
|
-
const selectedElements = getSelectedElements(board);
|
|
3976
|
-
const isSelectedImage = !!getSelectedImageElement(board);
|
|
3977
|
-
const isSingleSelection = selectedElements.length === 1 && MindElement.isMindElement(board, selectedElements[0]);
|
|
3978
|
-
if ((data === null || data === void 0 ? void 0 : data.files.length) && (isSingleSelection || isSelectedImage)) {
|
|
3979
|
-
const selectedElement = (selectedElements[0] || getSelectedImageElement(board));
|
|
3980
|
-
const acceptImageArray = acceptImageTypes.map(type => 'image/' + type);
|
|
3981
|
-
if (acceptImageArray.includes(data === null || data === void 0 ? void 0 : data.files[0].type)) {
|
|
3982
|
-
const imageFile = data.files[0];
|
|
3983
|
-
buildImage(board, selectedElement, imageFile);
|
|
3984
|
-
return;
|
|
3985
|
-
}
|
|
3986
|
-
}
|
|
3987
|
-
const imageItem = getClipboardDataByMedia(data, MediaKeys.image);
|
|
3988
|
-
if (imageItem && (isSingleSelection || isSelectedImage)) {
|
|
3989
|
-
const selectedElement = (selectedElements[0] || getSelectedImageElement(board));
|
|
3990
|
-
MindTransforms.setImage(board, selectedElement, imageItem);
|
|
3991
|
-
return;
|
|
3992
|
-
}
|
|
3993
|
-
insertFragment(data, targetPoint);
|
|
3994
|
-
};
|
|
3995
|
-
return board;
|
|
3996
|
-
};
|
|
3997
|
-
|
|
3998
|
-
const withNodeResize = (board) => {
|
|
3999
|
-
const { pointerDown, pointerMove, globalPointerUp } = board;
|
|
4000
|
-
let targetElement = null;
|
|
4001
|
-
let targetElementRef = null;
|
|
4002
|
-
let startPoint = null;
|
|
4003
|
-
board.pointerDown = (event) => {
|
|
4004
|
-
const point = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
4005
|
-
const newTargetElement = getSelectedTarget(board, point);
|
|
4006
|
-
if (newTargetElement) {
|
|
4007
|
-
PlaitBoard.getBoardContainer(board).classList.add(ResizeCursorClass['ew-resize']);
|
|
4008
|
-
targetElement = newTargetElement;
|
|
4009
|
-
startPoint = [event.x, event.y];
|
|
4010
|
-
return;
|
|
4011
|
-
}
|
|
4012
|
-
pointerDown(event);
|
|
4013
|
-
};
|
|
4014
|
-
board.pointerMove = (event) => {
|
|
4015
|
-
if (PlaitBoard.isReadonly(board) || PlaitBoard.hasBeenTextEditing(board)) {
|
|
4016
|
-
pointerMove(event);
|
|
4017
|
-
return;
|
|
4018
|
-
}
|
|
4019
|
-
if (startPoint && targetElement && !isMindNodeResizing(board)) {
|
|
4020
|
-
// prevent text from being selected
|
|
4021
|
-
event.preventDefault();
|
|
4022
|
-
preventTouchMove(board, true);
|
|
4023
|
-
const endPoint = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
4024
|
-
const distance = distanceBetweenPointAndPoint(startPoint[0], startPoint[1], endPoint[0], endPoint[1]);
|
|
4025
|
-
if (distance > PRESS_AND_MOVE_BUFFER) {
|
|
4026
|
-
addResizing(board, targetElement);
|
|
4027
|
-
targetElementRef = {
|
|
4028
|
-
minWidth: NodeSpace.getNodeResizableMinWidth(board, targetElement),
|
|
4029
|
-
currentWidth: NodeSpace.getNodeDynamicWidth(board, targetElement),
|
|
4030
|
-
path: PlaitBoard.findPath(board, targetElement),
|
|
4031
|
-
textManage: PlaitElement.getComponent(targetElement).textManage
|
|
4032
|
-
};
|
|
4033
|
-
MERGING.set(board, true);
|
|
4034
|
-
}
|
|
4035
|
-
}
|
|
4036
|
-
if (isMindNodeResizing(board) && startPoint && targetElementRef) {
|
|
4037
|
-
// prevent text from being selected
|
|
4038
|
-
event.preventDefault();
|
|
4039
|
-
preventTouchMove(board, true);
|
|
4040
|
-
throttleRAF(() => {
|
|
4041
|
-
if (!startPoint) {
|
|
4042
|
-
return;
|
|
4043
|
-
}
|
|
4044
|
-
const endPoint = [event.x, event.y];
|
|
4045
|
-
const offsetX = endPoint[0] - startPoint[0];
|
|
4046
|
-
const zoom = board.viewport.zoom;
|
|
4047
|
-
let resizedWidth = targetElementRef.currentWidth + offsetX / zoom;
|
|
4048
|
-
if (resizedWidth <= targetElementRef.minWidth) {
|
|
4049
|
-
resizedWidth = targetElementRef.minWidth;
|
|
4050
|
-
}
|
|
4051
|
-
const newTarget = PlaitNode.get(board, targetElementRef.path);
|
|
4052
|
-
if (newTarget && NodeSpace.getNodeTopicMinWidth(board, newTarget) !== resizedWidth) {
|
|
4053
|
-
targetElementRef.textManage.updateWidth(resizedWidth);
|
|
4054
|
-
const { height } = targetElementRef.textManage.getSize();
|
|
4055
|
-
MindTransforms.setNodeManualWidth(board, newTarget, resizedWidth * zoom, height);
|
|
4056
|
-
}
|
|
4057
|
-
});
|
|
4058
|
-
return;
|
|
4059
|
-
}
|
|
4060
|
-
else {
|
|
4061
|
-
// press and start drag when node is non selected
|
|
4062
|
-
if (!isDragging(board)) {
|
|
4063
|
-
const point = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
4064
|
-
const newTargetElement = getSelectedTarget(board, point);
|
|
4065
|
-
if (newTargetElement) {
|
|
4066
|
-
PlaitBoard.getBoardContainer(board).classList.add(ResizeCursorClass['ew-resize']);
|
|
4067
|
-
}
|
|
4068
|
-
else {
|
|
4069
|
-
PlaitBoard.getBoardContainer(board).classList.remove(ResizeCursorClass['ew-resize']);
|
|
4070
|
-
}
|
|
4071
|
-
}
|
|
4072
|
-
}
|
|
4073
|
-
pointerMove(event);
|
|
4074
|
-
};
|
|
4075
|
-
board.globalPointerUp = (event) => {
|
|
4076
|
-
globalPointerUp(event);
|
|
4077
|
-
if (isMindNodeResizing(board) || targetElement) {
|
|
4078
|
-
targetElement && removeResizing(board, targetElement);
|
|
4079
|
-
targetElementRef = null;
|
|
4080
|
-
targetElement = null;
|
|
4081
|
-
startPoint = null;
|
|
4082
|
-
MERGING.set(board, false);
|
|
4083
|
-
preventTouchMove(board, false);
|
|
4084
|
-
}
|
|
4085
|
-
};
|
|
4086
|
-
return board;
|
|
4087
|
-
};
|
|
4088
|
-
const IS_MIND_NODE_RESIZING = new WeakMap();
|
|
4089
|
-
const isMindNodeResizing = (board) => {
|
|
4090
|
-
return !!IS_MIND_NODE_RESIZING.get(board);
|
|
4091
|
-
};
|
|
4092
|
-
const addResizing = (board, element) => {
|
|
4093
|
-
PlaitBoard.getBoardContainer(board).classList.add('mind-node-resizing');
|
|
4094
|
-
const component = PlaitElement.getComponent(element);
|
|
4095
|
-
component.g.classList.add('resizing');
|
|
4096
|
-
IS_MIND_NODE_RESIZING.set(board, true);
|
|
4097
|
-
};
|
|
4098
|
-
const removeResizing = (board, element) => {
|
|
4099
|
-
PlaitBoard.getBoardContainer(board).classList.remove('mind-node-resizing');
|
|
4100
|
-
PlaitBoard.getBoardContainer(board).classList.remove(ResizeCursorClass['ew-resize']);
|
|
4101
|
-
const component = PlaitElement.getComponent(element);
|
|
4102
|
-
if (component && component.g) {
|
|
4103
|
-
component.g.classList.remove('resizing');
|
|
4104
|
-
}
|
|
4105
|
-
IS_MIND_NODE_RESIZING.set(board, false);
|
|
4106
|
-
};
|
|
4107
|
-
const getSelectedTarget = (board, point) => {
|
|
4108
|
-
const selectedElements = getSelectedElements(board).filter(value => MindElement.isMindElement(board, value));
|
|
4109
|
-
if (selectedElements.length > 0) {
|
|
4110
|
-
const target = selectedElements.find(value => {
|
|
4111
|
-
const rectangle = getResizeActiveRectangle(board, value);
|
|
4112
|
-
return distanceBetweenPointAndRectangle(point[0], point[1], rectangle) <= 0;
|
|
4113
|
-
});
|
|
4114
|
-
return target ? target : null;
|
|
4115
|
-
}
|
|
4116
|
-
return null;
|
|
4117
|
-
};
|
|
4118
|
-
const getResizeActiveRectangle = (board, element) => {
|
|
4119
|
-
const node = MindElement.getNode(element);
|
|
4120
|
-
const rectangle = getRectangleByNode(node);
|
|
4121
|
-
return { x: rectangle.x + rectangle.width - EXTEND_OFFSET, y: rectangle.y, width: EXTEND_OFFSET * 2, height: rectangle.height };
|
|
4122
|
-
};
|
|
4123
|
-
|
|
4124
|
-
const withNodeImageResize = (board) => {
|
|
4125
|
-
const options = {
|
|
4126
|
-
key: 'mind-node-image',
|
|
4127
|
-
canResize: () => {
|
|
4128
|
-
return true;
|
|
4129
|
-
},
|
|
4130
|
-
detect: (point) => {
|
|
4131
|
-
const selectedMindElement = getSelectedImageElement(board);
|
|
4132
|
-
if (selectedMindElement) {
|
|
4133
|
-
const result = getHitImageResizeHandleDirection(board, selectedMindElement, point);
|
|
4134
|
-
if (result) {
|
|
4135
|
-
return {
|
|
4136
|
-
element: selectedMindElement,
|
|
4137
|
-
handle: result.handle,
|
|
4138
|
-
cursorClass: result.cursorClass
|
|
4139
|
-
};
|
|
4140
|
-
}
|
|
4141
|
-
}
|
|
4142
|
-
return null;
|
|
4143
|
-
},
|
|
4144
|
-
onResize: (resizeRef, resizeState) => {
|
|
4145
|
-
let offsetX = resizeState.offsetX;
|
|
4146
|
-
let offsetY = resizeState.offsetY;
|
|
4147
|
-
if (resizeRef.handle === ResizeHandle.nw || resizeRef.handle === ResizeHandle.sw) {
|
|
4148
|
-
offsetX = -offsetX;
|
|
4149
|
-
}
|
|
4150
|
-
const originWidth = resizeRef.element.data.image.width;
|
|
4151
|
-
const originHeight = resizeRef.element.data.image.height;
|
|
4152
|
-
let width = originWidth + offsetX;
|
|
4153
|
-
if (width <= 100) {
|
|
4154
|
-
width = 100;
|
|
4155
|
-
}
|
|
4156
|
-
const ratio = originWidth / width;
|
|
4157
|
-
const height = originHeight / ratio;
|
|
4158
|
-
const imageItem = Object.assign(Object.assign({}, resizeRef.element.data.image), { width, height });
|
|
4159
|
-
MindTransforms.setImage(board, PlaitNode.get(board, resizeRef.path), imageItem);
|
|
4160
|
-
addSelectedImageElement(board, PlaitNode.get(board, resizeRef.path));
|
|
4161
|
-
}
|
|
4162
|
-
};
|
|
4163
|
-
withResize(board, options);
|
|
4164
|
-
return board;
|
|
4165
|
-
};
|
|
4166
|
-
|
|
4167
|
-
const withMind = (baseBoard) => {
|
|
4168
|
-
const board = baseBoard;
|
|
4169
|
-
const { drawElement, dblclick, insertFragment, setFragment, isHitSelection, getRectangle, isMovable, isRecursion } = board;
|
|
4170
|
-
board.drawElement = (context) => {
|
|
4171
|
-
if (PlaitMind.isMind(context.element)) {
|
|
4172
|
-
return PlaitMindComponent;
|
|
4173
|
-
}
|
|
4174
|
-
else if (MindElement.isMindElement(board, context.element)) {
|
|
4175
|
-
return MindNodeComponent;
|
|
4176
|
-
}
|
|
4177
|
-
return drawElement(context);
|
|
4178
|
-
};
|
|
4179
|
-
board.applyTheme = (element) => {
|
|
4180
|
-
const mindElement = element;
|
|
4181
|
-
const shouldClearProperty = !PlaitBoard.isBoard(element) && ((mindElement === null || mindElement === void 0 ? void 0 : mindElement.branchColor) || (mindElement === null || mindElement === void 0 ? void 0 : mindElement.fill) || (mindElement === null || mindElement === void 0 ? void 0 : mindElement.strokeColor));
|
|
4182
|
-
if (shouldClearProperty) {
|
|
4183
|
-
const path = PlaitBoard.findPath(board, element);
|
|
4184
|
-
Transforms.setNode(board, { fill: null, strokeColor: null, branchColor: null }, path);
|
|
4185
|
-
}
|
|
4186
|
-
};
|
|
4187
|
-
board.getRectangle = element => {
|
|
4188
|
-
if (MindElement.isMindElement(board, element)) {
|
|
4189
|
-
return getRectangleByNode(MindElement.getNode(element));
|
|
4190
|
-
}
|
|
4191
|
-
return getRectangle(element);
|
|
4192
|
-
};
|
|
4193
|
-
board.isRecursion = element => {
|
|
4194
|
-
if (MindElement.isMindElement(board, element) && element.isCollapsed) {
|
|
4195
|
-
return false;
|
|
4196
|
-
}
|
|
4197
|
-
return isRecursion(element);
|
|
4198
|
-
};
|
|
4199
|
-
board.isHitSelection = (element, range) => {
|
|
4200
|
-
if (MindElement.isMindElement(board, element)) {
|
|
4201
|
-
const client = getRectangleByNode(MindElement.getNode(element));
|
|
4202
|
-
const isHit = RectangleClient.isHit(RectangleClient.toRectangleClient([range.anchor, range.focus]), client);
|
|
4203
|
-
return isHit;
|
|
4204
|
-
}
|
|
4205
|
-
return isHitSelection(element, range);
|
|
4206
|
-
};
|
|
4207
|
-
board.isMovable = element => {
|
|
4208
|
-
if (PlaitMind.isMind(element) && element.isRoot) {
|
|
4209
|
-
return true;
|
|
4210
|
-
}
|
|
4211
|
-
return isMovable(element);
|
|
4212
|
-
};
|
|
4213
|
-
board.dblclick = (event) => {
|
|
4214
|
-
if (PlaitBoard.isReadonly(board)) {
|
|
4215
|
-
dblclick(event);
|
|
4216
|
-
return;
|
|
4217
|
-
}
|
|
4218
|
-
const point = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
4219
|
-
board.children
|
|
4220
|
-
.filter(value => PlaitMind.isMind(value))
|
|
4221
|
-
.forEach(mindMap => {
|
|
4222
|
-
depthFirstRecursion(mindMap, node => {
|
|
4223
|
-
if (!PlaitBoard.hasBeenTextEditing(board) && isHitMindElement(board, point, node)) {
|
|
4224
|
-
editTopic(node);
|
|
4225
|
-
}
|
|
4226
|
-
}, getIsRecursionFunc(board));
|
|
4227
|
-
});
|
|
4228
|
-
if (PlaitBoard.hasBeenTextEditing(board)) {
|
|
4229
|
-
return;
|
|
4230
|
-
}
|
|
4231
|
-
dblclick(event);
|
|
4232
|
-
};
|
|
4233
|
-
board.setFragment = (data, rectangle) => {
|
|
4234
|
-
const targetMindElements = getSelectedMindElements(board);
|
|
4235
|
-
const firstLevelElements = getFirstLevelElement(targetMindElements);
|
|
4236
|
-
if (firstLevelElements.length) {
|
|
4237
|
-
const elements = buildClipboardData(board, firstLevelElements, rectangle ? [rectangle.x, rectangle.y] : [0, 0]);
|
|
4238
|
-
setMindClipboardData(data, elements);
|
|
4239
|
-
}
|
|
4240
|
-
setFragment(data, rectangle);
|
|
4241
|
-
};
|
|
4242
|
-
board.insertFragment = (data, targetPoint) => {
|
|
4243
|
-
const elements = getDataFromClipboard(data);
|
|
4244
|
-
const mindElements = elements.filter(value => MindElement.isMindElement(board, value));
|
|
4245
|
-
if (elements.length > 0 && mindElements.length > 0) {
|
|
4246
|
-
insertClipboardData(board, mindElements, targetPoint);
|
|
4247
|
-
}
|
|
4248
|
-
else if (elements.length === 0) {
|
|
4249
|
-
const mindElements = getSelectedMindElements(board);
|
|
4250
|
-
if (mindElements.length === 1) {
|
|
4251
|
-
const text = getTextFromClipboard(data);
|
|
4252
|
-
if (text) {
|
|
4253
|
-
insertClipboardText(board, mindElements[0], buildText(text));
|
|
4254
|
-
return;
|
|
4255
|
-
}
|
|
4256
|
-
}
|
|
4257
|
-
}
|
|
4258
|
-
insertFragment(data, targetPoint);
|
|
4259
|
-
};
|
|
4260
|
-
return withNodeResize(withNodeImageResize(withNodeImage(withNodeHoverDetect(withMindHotkey(withMindExtend(withCreateMind(withAbstract(withNodeDnd(board)))))))));
|
|
4261
|
-
};
|
|
4262
|
-
|
|
4263
|
-
class MindEmojiBaseComponent {
|
|
4264
|
-
get nativeElement() {
|
|
4265
|
-
return this.elementRef.nativeElement;
|
|
4266
|
-
}
|
|
4267
|
-
handleClick() {
|
|
4268
|
-
const currentOptions = this.board.getPluginOptions(PlaitPluginKey.withSelection);
|
|
4269
|
-
this.board.setPluginOptions(PlaitPluginKey.withSelection, {
|
|
4270
|
-
isDisabledSelect: true
|
|
4271
|
-
});
|
|
4272
|
-
setTimeout(() => {
|
|
4273
|
-
this.board.setPluginOptions(PlaitPluginKey.withSelection, Object.assign({}, currentOptions));
|
|
4274
|
-
}, 0);
|
|
4275
|
-
}
|
|
4276
|
-
constructor(elementRef) {
|
|
4277
|
-
this.elementRef = elementRef;
|
|
4278
|
-
this.fontSize = 14;
|
|
4279
|
-
}
|
|
4280
|
-
ngOnInit() {
|
|
4281
|
-
this.elementRef.nativeElement.style.fontSize = `${this.fontSize}px`;
|
|
4282
|
-
}
|
|
4283
|
-
}
|
|
4284
|
-
MindEmojiBaseComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindEmojiBaseComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
4285
|
-
MindEmojiBaseComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: MindEmojiBaseComponent, inputs: { fontSize: "fontSize", emojiItem: "emojiItem", board: "board", element: "element" }, host: { listeners: { "mousedown": "handleClick()" }, classAttribute: "mind-node-emoji" }, ngImport: i0 });
|
|
4286
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindEmojiBaseComponent, decorators: [{
|
|
4287
|
-
type: Directive,
|
|
4288
|
-
args: [{
|
|
4289
|
-
host: {
|
|
4290
|
-
class: 'mind-node-emoji'
|
|
4291
|
-
}
|
|
4292
|
-
}]
|
|
4293
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { fontSize: [{
|
|
4294
|
-
type: Input
|
|
4295
|
-
}], emojiItem: [{
|
|
4296
|
-
type: Input
|
|
4297
|
-
}], board: [{
|
|
4298
|
-
type: Input
|
|
4299
|
-
}], element: [{
|
|
4300
|
-
type: Input
|
|
4301
|
-
}], handleClick: [{
|
|
4302
|
-
type: HostListener,
|
|
4303
|
-
args: ['mousedown']
|
|
4304
|
-
}] } });
|
|
4305
|
-
|
|
4306
|
-
class MindImageBaseComponent {
|
|
4307
|
-
set imageItem(value) {
|
|
4308
|
-
this.afterImageItemChange(this._imageItem, value);
|
|
4309
|
-
this._imageItem = value;
|
|
4310
|
-
this.drawFocus();
|
|
4311
|
-
}
|
|
4312
|
-
get imageItem() {
|
|
4313
|
-
return this._imageItem;
|
|
4314
|
-
}
|
|
4315
|
-
set isFocus(value) {
|
|
4316
|
-
this._isFocus = value;
|
|
4317
|
-
this.drawFocus();
|
|
4318
|
-
}
|
|
4319
|
-
get isFocus() {
|
|
4320
|
-
return this._isFocus;
|
|
4321
|
-
}
|
|
4322
|
-
get nativeElement() {
|
|
4323
|
-
return this.elementRef.nativeElement;
|
|
4324
|
-
}
|
|
4325
|
-
constructor(elementRef, cdr) {
|
|
4326
|
-
this.elementRef = elementRef;
|
|
4327
|
-
this.cdr = cdr;
|
|
4328
|
-
this.initialized = false;
|
|
4329
|
-
}
|
|
4330
|
-
ngOnInit() {
|
|
4331
|
-
this.activeGenerator = new ActiveGenerator(this.board, {
|
|
4332
|
-
activeStrokeWidth: 1,
|
|
4333
|
-
getRectangle: (element) => {
|
|
4334
|
-
return getImageForeignRectangle(this.board, this.element);
|
|
4335
|
-
},
|
|
4336
|
-
getStrokeWidthByElement: () => {
|
|
4337
|
-
return 0;
|
|
4338
|
-
}
|
|
4339
|
-
});
|
|
4340
|
-
this.initialized = true;
|
|
4341
|
-
}
|
|
4342
|
-
drawFocus() {
|
|
4343
|
-
if (this.initialized) {
|
|
4344
|
-
const com = PlaitElement.getComponent(this.element);
|
|
4345
|
-
this.activeGenerator.draw(this.element, com.g, { selected: this._isFocus });
|
|
4346
|
-
}
|
|
4347
|
-
}
|
|
4348
|
-
ngOnDestroy() {
|
|
4349
|
-
if (this.activeGenerator) {
|
|
4350
|
-
this.activeGenerator.destroy();
|
|
4351
|
-
}
|
|
4352
|
-
}
|
|
4353
|
-
}
|
|
4354
|
-
MindImageBaseComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindImageBaseComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
4355
|
-
MindImageBaseComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: MindImageBaseComponent, inputs: { imageItem: "imageItem", board: "board", element: "element", isFocus: "isFocus" }, host: { classAttribute: "mind-node-image" }, ngImport: i0 });
|
|
4356
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindImageBaseComponent, decorators: [{
|
|
4357
|
-
type: Directive,
|
|
4358
|
-
args: [{
|
|
4359
|
-
host: {
|
|
4360
|
-
class: 'mind-node-image'
|
|
4361
|
-
}
|
|
4362
|
-
}]
|
|
4363
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { imageItem: [{
|
|
4364
|
-
type: Input
|
|
4365
|
-
}], board: [{
|
|
4366
|
-
type: Input
|
|
4367
|
-
}], element: [{
|
|
4368
|
-
type: Input
|
|
4369
|
-
}], isFocus: [{
|
|
4370
|
-
type: Input
|
|
4371
|
-
}] } });
|
|
4372
|
-
|
|
4373
|
-
/*
|
|
4374
|
-
* Public API Surface of mind
|
|
4375
|
-
*/
|
|
4376
|
-
|
|
4377
|
-
/**
|
|
4378
|
-
* Generated bundle index. Do not edit.
|
|
4379
|
-
*/
|
|
4380
|
-
|
|
4381
|
-
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_FONT_FAMILY, BRANCH_WIDTH, BaseDrawer, BranchShape, DEFAULT_FONT_FAMILY, DefaultAbstractNodeStyle, DefaultNodeStyle, ELEMENT_TO_NODE, EXTEND_DIAMETER, EXTEND_OFFSET, GRAY_COLOR, INHERIT_ATTRIBUTE_KEYS, IS_DRAGGING, LayoutDirection, LayoutDirectionsMap, MindColorfulThemeColor, MindDarkThemeColor, MindDefaultThemeColor, MindElement, MindElementShape, MindEmojiBaseComponent, MindImageBaseComponent, MindModule, MindNode, MindNodeComponent, MindPointerType, MindQueries, MindRetroThemeColor, MindSoftThemeColor, MindStarryThemeColor, MindThemeColor, MindThemeColors, MindTransforms, NodeSpace, PRIMARY_COLOR, PlaitMind, PlaitMindComponent, QUICK_INSERT_CIRCLE_COLOR, QUICK_INSERT_CIRCLE_OFFSET, QUICK_INSERT_INNER_CROSS_COLOR, ROOT_TOPIC_FONT_SIZE, ROOT_TOPIC_HEIGHT, STROKE_WIDTH, TOPIC_COLOR, TOPIC_DEFAULT_MAX_WORD_COUNT, TOPIC_FONT_SIZE, TRANSPARENT, WithMindPluginKey, addActiveOnDragOrigin, addSelectedImageElement, adjustAbstractToNode, adjustNodeToRoot, adjustRootToNode, buildImage, canSetAbstract, copyNewNode, correctLayoutByDirection, createDefaultMind, createEmptyMind, createMindElement, deleteElementHandleAbstract, deleteElementsHandleRightNodeCount, detectDropTarget, directionCorrector, directionDetector, divideElementByParent, drawFakeDragNode, drawFakeDropNode, editTopic, extractNodesText, findLastChild, findLocationLeftIndex, getAbstractBranchColor, getAbstractBranchWidth, getAbstractHandleRectangle, getAllowedDirection, getAvailableSubLayoutsByLayoutDirections, getBehindAbstracts, getBranchColorByMindElement, getBranchDirectionsByLayouts, getBranchShapeByMindElement, getBranchWidthByMindElement, getChildrenCount, getCorrespondingAbstract, getDefaultBranchColor, getDefaultBranchColorByIndex, getDefaultLayout, getEmojiFontSize, getEmojiForeignRectangle, getEmojiRectangle, getEmojisWidthHeight, getFillByElement, getFirstLevelElement, getFontSizeBySlateElement, getHitAbstractHandle, getHitImageResizeHandleDirection, getImageForeignRectangle, getInCorrectLayoutDirection, getLayoutDirection$1 as getLayoutDirection, getLayoutOptions, getLayoutReverseDirection, getLocationScope, getMindThemeColor, getNewNodeHeight, getNextBranchColor, getNodeDefaultFontSize, getOverallAbstracts, getPathByDropTarget, getRectangleByElement, getRectangleByNode, getRectangleByResizingLocation, getRelativeStartEndByAbstractRef, getRootLayout, getSelectedImageElement, getSelectedMindElements, getShapeByElement, getStrokeByMindElement, getStrokeWidthByElement, getTopicRectangleByElement, getTopicRectangleByNode, getValidAbstractRefs, handleTouchedAbstract, hasAfterDraw, hasPreviousOrNextOfDropPath, insertElementHandleAbstract, insertElementHandleRightNodeCount, insertMindElement, isChildElement, isChildOfAbstract, isChildRight, isChildUp, isCorrectLayout, isDragging, isDropStandardRight, isHitEmojis, isHitImage, isHitMindElement, isInRightBranchOfStandardLayout, isMixedLayout, isSetAbstract, isValidTarget, removeActiveOnDragOrigin, removeSelectedImageElement, selectImage, separateChildren, setImageFocus, setIsDragging, temporaryDisableSelection, withMind, withMindExtend };
|
|
4382
|
-
//# sourceMappingURL=plait-mind.mjs.map
|