@plait/mind 0.4.0 → 0.6.0
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 -0
- package/constants/node-style.d.ts +0 -6
- package/constants/theme.d.ts +6 -0
- package/esm2020/base/emoji-base.component.mjs +16 -3
- package/esm2020/constants/node-style.mjs +4 -10
- package/esm2020/constants/theme.mjs +73 -0
- package/esm2020/drawer/emojis.drawer.mjs +2 -3
- package/esm2020/drawer/quick-insert.drawer.mjs +4 -2
- package/esm2020/interfaces/index.mjs +2 -1
- package/esm2020/interfaces/theme-color.mjs +47 -0
- package/esm2020/node.component.mjs +4 -3
- package/esm2020/plugins/with-mind-create.mjs +15 -3
- package/esm2020/plugins/with-mind-hotkey.mjs +28 -0
- package/esm2020/plugins/with-mind.mjs +20 -8
- package/esm2020/plugins/with-node-dnd.mjs +36 -22
- package/esm2020/utils/dnd/common.mjs +25 -29
- package/esm2020/utils/dnd/detector.mjs +10 -86
- package/esm2020/utils/draw/node-dnd.mjs +27 -8
- package/esm2020/utils/draw/node-link/indented-link.mjs +2 -2
- package/esm2020/utils/draw/node-link/logic-link.mjs +2 -2
- package/esm2020/utils/draw/node-shape.mjs +5 -3
- package/esm2020/utils/draw/node-topic.mjs +3 -3
- package/esm2020/utils/mind.mjs +8 -8
- package/esm2020/utils/node/create-node.mjs +6 -21
- package/esm2020/utils/node-style/branch.mjs +16 -10
- package/esm2020/utils/node-style/shape.mjs +4 -4
- package/fesm2015/plait-mind.mjs +286 -193
- package/fesm2015/plait-mind.mjs.map +1 -1
- package/fesm2020/plait-mind.mjs +315 -193
- package/fesm2020/plait-mind.mjs.map +1 -1
- package/interfaces/index.d.ts +1 -0
- package/interfaces/theme-color.d.ts +14 -0
- package/package.json +1 -1
- package/plugins/with-mind-hotkey.d.ts +3 -0
- package/plugins/with-mind.d.ts +1 -1
- package/styles/mixins.scss +31 -0
- package/styles/styles.scss +5 -2
- package/utils/dnd/common.d.ts +11 -3
- package/utils/dnd/detector.d.ts +0 -7
- package/utils/draw/node-dnd.d.ts +6 -4
- package/utils/mind.d.ts +5 -5
- package/utils/node/create-node.d.ts +5 -3
- package/utils/node-style/branch.d.ts +4 -2
package/fesm2020/plait-mind.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Component, ChangeDetectionStrategy, NgModule, Directive, Input } from '@angular/core';
|
|
2
|
+
import { Component, ChangeDetectionStrategy, NgModule, Directive, Input, HostListener } from '@angular/core';
|
|
3
3
|
import * as i2 from '@plait/core';
|
|
4
|
-
import { distanceBetweenPointAndRectangle, RectangleClient, PlaitElement, PlaitBoard, idCreator, isNullOrUndefined, Transforms, clearSelectedElement, addSelectedElement, depthFirstRecursion, Path, drawRoundRectangle, drawLinearPath, createG, PlaitNode, getRectangleByElements, getSelectedElements, NODE_TO_PARENT, drawAbstractRoundRectangle, PlaitPluginElementComponent, PlaitPointerType, NODE_TO_INDEX, createText, IS_TEXT_EDITABLE, MERGING, transformPoint, toPoint, PlaitModule, distanceBetweenPointAndPoint, CLIP_BOARD_FORMAT_KEY, isMainPointer, BOARD_TO_HOST,
|
|
5
|
-
import { MindLayoutType, isIndentedLayout, getNonAbstractChildren, isStandardLayout, AbstractNode, isLeftLayout, isRightLayout,
|
|
6
|
-
import { getSizeByText, ROOT_DEFAULT_HEIGHT, TEXT_DEFAULT_HEIGHT,
|
|
4
|
+
import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, distanceBetweenPointAndRectangle, RectangleClient, PlaitElement, PlaitBoard, idCreator, isNullOrUndefined, Transforms, clearSelectedElement, addSelectedElement, depthFirstRecursion, Path, drawRoundRectangle, drawLinearPath, createG, updateForeignObject, PlaitNode, getRectangleByElements, getSelectedElements, NODE_TO_PARENT, createForeignObject, drawAbstractRoundRectangle, PlaitPluginElementComponent, PlaitPointerType, NODE_TO_INDEX, createText, IS_TEXT_EDITABLE, MERGING, transformPoint, toPoint, PlaitModule, distanceBetweenPointAndPoint, CLIP_BOARD_FORMAT_KEY, isMainPointer, BOARD_TO_HOST, PlaitPluginKey, throttleRAF, BoardTransforms, removeSelectedElement, PlaitHistoryBoard, hotkeys } from '@plait/core';
|
|
5
|
+
import { MindLayoutType, isIndentedLayout, getNonAbstractChildren, isStandardLayout, AbstractNode, isLeftLayout, isRightLayout, isVerticalLogicLayout, isHorizontalLogicLayout, isTopLayout, isBottomLayout, isHorizontalLayout, getCorrectStartEnd, getAbstractLayout, ConnectingPosition, GlobalLayout } from '@plait/layouts';
|
|
6
|
+
import { getSizeByText, ROOT_DEFAULT_HEIGHT, TEXT_DEFAULT_HEIGHT, drawRichtext, updateRichText, setFullSelectionAndFocus, getRichtextContentSize, hasEditableTarget, RichtextModule } from '@plait/richtext';
|
|
7
7
|
import { fromEvent, Subject, timer } from 'rxjs';
|
|
8
8
|
import { take, takeUntil, filter, debounceTime } from 'rxjs/operators';
|
|
9
9
|
import { Node, Path as Path$1, Editor, Operation } from 'slate';
|
|
@@ -30,19 +30,13 @@ const DefaultAbstractNodeStyle = {
|
|
|
30
30
|
strokeColor: GRAY_COLOR,
|
|
31
31
|
strokeWidth: 2,
|
|
32
32
|
branchColor: GRAY_COLOR,
|
|
33
|
-
branchWidth: 2
|
|
34
|
-
fill: '#FFFFFF'
|
|
33
|
+
branchWidth: 2
|
|
35
34
|
};
|
|
36
35
|
const DefaultNodeStyle = {
|
|
37
36
|
strokeWidth: 3,
|
|
38
37
|
branchWidth: 3,
|
|
39
|
-
fill: '
|
|
38
|
+
fill: 'none'
|
|
40
39
|
};
|
|
41
|
-
const DefaultRootStyle = {
|
|
42
|
-
fill: '#F5F5F5',
|
|
43
|
-
strokeColor: '#F5F5F5',
|
|
44
|
-
};
|
|
45
|
-
const BRANCH_COLORS = ['#A287E1', '#6F81DB', '#6EC4C4', '#DFB85D', '#B1C774', '#77C386', '#C28976', '#E48484', '#E482D4', '#69B1E4'];
|
|
46
40
|
|
|
47
41
|
const TOPIC_COLOR = '#333';
|
|
48
42
|
const TOPIC_FONT_SIZE = 14;
|
|
@@ -93,6 +87,124 @@ var MindPointerType;
|
|
|
93
87
|
MindPointerType["mind"] = "mind";
|
|
94
88
|
})(MindPointerType || (MindPointerType = {}));
|
|
95
89
|
|
|
90
|
+
const DEFAULT_BRANCH_COLORS = [
|
|
91
|
+
'#A287E0',
|
|
92
|
+
'#6E80DB',
|
|
93
|
+
'#6DC4C4',
|
|
94
|
+
'#E0B75E',
|
|
95
|
+
'#B1C675',
|
|
96
|
+
'#77C386',
|
|
97
|
+
'#C18976',
|
|
98
|
+
'#E48484',
|
|
99
|
+
'#E582D4',
|
|
100
|
+
'#6AB1E4'
|
|
101
|
+
];
|
|
102
|
+
const COLORFUL_BRANCH_COLORS = [
|
|
103
|
+
'#F94239',
|
|
104
|
+
'#FF8612',
|
|
105
|
+
'#F3D222',
|
|
106
|
+
'#B3D431',
|
|
107
|
+
'#00BC7B',
|
|
108
|
+
'#06ADBF',
|
|
109
|
+
'#476BFF',
|
|
110
|
+
'#4E49BE',
|
|
111
|
+
'#8957E5',
|
|
112
|
+
'#FE5DA1'
|
|
113
|
+
];
|
|
114
|
+
const SOFT_BRANCH_COLORS = [
|
|
115
|
+
'#6D89C1',
|
|
116
|
+
'#F2BDC7',
|
|
117
|
+
'#B796D9',
|
|
118
|
+
'#5BA683',
|
|
119
|
+
'#B3D431 ',
|
|
120
|
+
'#F2DC6C',
|
|
121
|
+
'#F7C98D',
|
|
122
|
+
'#60B4D1',
|
|
123
|
+
'#838F9E',
|
|
124
|
+
'#C1A381'
|
|
125
|
+
];
|
|
126
|
+
const RETRO_BRANCH_COLORS = [
|
|
127
|
+
'#459476',
|
|
128
|
+
'#9A894F',
|
|
129
|
+
'#D48444',
|
|
130
|
+
'#E9C358 ',
|
|
131
|
+
'#4B9D9D',
|
|
132
|
+
'#C14C41',
|
|
133
|
+
'#827086 ',
|
|
134
|
+
'#60718D',
|
|
135
|
+
'#D38183',
|
|
136
|
+
'#9DC19D'
|
|
137
|
+
];
|
|
138
|
+
const DARK_BRANCH_COLORS = [
|
|
139
|
+
'#3DD1AE',
|
|
140
|
+
'#F6C659',
|
|
141
|
+
'#A9E072',
|
|
142
|
+
'#FF877B ',
|
|
143
|
+
'#F693E7',
|
|
144
|
+
'#5DCFFF',
|
|
145
|
+
'#868AF6',
|
|
146
|
+
'#4C6DC7',
|
|
147
|
+
'#D97C26',
|
|
148
|
+
'#268FAC'
|
|
149
|
+
];
|
|
150
|
+
const STARRY_BRANCH_COLORS = [
|
|
151
|
+
'#E46C57',
|
|
152
|
+
'#579360',
|
|
153
|
+
'#B98339',
|
|
154
|
+
'#3A62D1 ',
|
|
155
|
+
'#B883B7',
|
|
156
|
+
'#42ABE5',
|
|
157
|
+
'#2B9D8F',
|
|
158
|
+
'#A4705E',
|
|
159
|
+
'#265833',
|
|
160
|
+
'#787865'
|
|
161
|
+
];
|
|
162
|
+
|
|
163
|
+
const MindDefaultThemeColor = {
|
|
164
|
+
...DefaultThemeColor,
|
|
165
|
+
branchColors: DEFAULT_BRANCH_COLORS,
|
|
166
|
+
rootFill: '#f5f5f5',
|
|
167
|
+
rootTextColor: '#333333'
|
|
168
|
+
};
|
|
169
|
+
const MindColorfulThemeColor = {
|
|
170
|
+
...ColorfulThemeColor,
|
|
171
|
+
branchColors: COLORFUL_BRANCH_COLORS,
|
|
172
|
+
rootFill: '#333333',
|
|
173
|
+
rootTextColor: '#FFFFFF'
|
|
174
|
+
};
|
|
175
|
+
const MindSoftThemeColor = {
|
|
176
|
+
...SoftThemeColor,
|
|
177
|
+
branchColors: SOFT_BRANCH_COLORS,
|
|
178
|
+
rootFill: '#FFFFFF',
|
|
179
|
+
rootTextColor: '#333333'
|
|
180
|
+
};
|
|
181
|
+
const MindRetroThemeColor = {
|
|
182
|
+
...RetroThemeColor,
|
|
183
|
+
branchColors: RETRO_BRANCH_COLORS,
|
|
184
|
+
rootFill: '#153D5D',
|
|
185
|
+
rootTextColor: '#FFFFFF'
|
|
186
|
+
};
|
|
187
|
+
const MindDarkThemeColor = {
|
|
188
|
+
...DarkThemeColor,
|
|
189
|
+
branchColors: DARK_BRANCH_COLORS,
|
|
190
|
+
rootFill: '#FFFFFF',
|
|
191
|
+
rootTextColor: '#333333'
|
|
192
|
+
};
|
|
193
|
+
const MindStarryThemeColor = {
|
|
194
|
+
...StarryThemeColor,
|
|
195
|
+
branchColors: STARRY_BRANCH_COLORS,
|
|
196
|
+
rootFill: '#FFFFFF',
|
|
197
|
+
rootTextColor: '#333333'
|
|
198
|
+
};
|
|
199
|
+
const MindThemeColors = [
|
|
200
|
+
MindDefaultThemeColor,
|
|
201
|
+
MindColorfulThemeColor,
|
|
202
|
+
MindSoftThemeColor,
|
|
203
|
+
MindRetroThemeColor,
|
|
204
|
+
MindDarkThemeColor,
|
|
205
|
+
MindStarryThemeColor
|
|
206
|
+
];
|
|
207
|
+
|
|
96
208
|
function getRectangleByNode(node) {
|
|
97
209
|
const x = node.x + node.hGap;
|
|
98
210
|
let y = node.y + node.vGap;
|
|
@@ -248,26 +360,11 @@ const createMindElement = (text, width, height, options) => {
|
|
|
248
360
|
strokeWidth: options.strokeWidth,
|
|
249
361
|
shape: options.shape
|
|
250
362
|
};
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
}
|
|
257
|
-
if (!isNullOrUndefined(options.strokeWidth)) {
|
|
258
|
-
newElement.strokeWidth = options.strokeWidth;
|
|
259
|
-
}
|
|
260
|
-
if (options.shape) {
|
|
261
|
-
newElement.shape = options.shape;
|
|
262
|
-
}
|
|
263
|
-
if (options.layout) {
|
|
264
|
-
newElement.layout = options.layout;
|
|
265
|
-
}
|
|
266
|
-
if (options.branchColor) {
|
|
267
|
-
newElement.branchColor = options.branchColor;
|
|
268
|
-
}
|
|
269
|
-
if (!isNullOrUndefined(options.branchWidth)) {
|
|
270
|
-
newElement.branchWidth = options.branchWidth;
|
|
363
|
+
let key;
|
|
364
|
+
for (key in options) {
|
|
365
|
+
if (!isNullOrUndefined(options[key])) {
|
|
366
|
+
newElement[key] = options[key];
|
|
367
|
+
}
|
|
271
368
|
}
|
|
272
369
|
return newElement;
|
|
273
370
|
};
|
|
@@ -327,14 +424,15 @@ const extractNodesText = (node) => {
|
|
|
327
424
|
};
|
|
328
425
|
// layoutLevel 用来表示插入兄弟节点还是子节点
|
|
329
426
|
const insertMindElement = (board, inheritNode, path) => {
|
|
330
|
-
|
|
427
|
+
const inheritAttributeKeys = Object.keys({});
|
|
428
|
+
const newNode = {};
|
|
331
429
|
if (!inheritNode.isRoot) {
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
430
|
+
inheritAttributeKeys.forEach(attr => {
|
|
431
|
+
newNode[attr] = inheritNode[attr];
|
|
432
|
+
});
|
|
433
|
+
delete newNode.layout;
|
|
335
434
|
}
|
|
336
|
-
|
|
337
|
-
const newElement = createMindElement('', NODE_MIN_WIDTH, TEXT_DEFAULT_HEIGHT, { fill, strokeColor, strokeWidth, shape });
|
|
435
|
+
const newElement = createMindElement('', NODE_MIN_WIDTH, TEXT_DEFAULT_HEIGHT, newNode);
|
|
338
436
|
Transforms.insertNode(board, newElement, path);
|
|
339
437
|
clearSelectedElement(board);
|
|
340
438
|
addSelectedElement(board, newElement);
|
|
@@ -486,7 +584,8 @@ const getAvailableProperty = (board, element, propertyKey) => {
|
|
|
486
584
|
*/
|
|
487
585
|
const getBranchColorByMindElement = (board, element) => {
|
|
488
586
|
const branchColor = getAvailableProperty(board, element, 'branchColor');
|
|
489
|
-
|
|
587
|
+
const parentBranchColor = MindElement.getParent(element)?.branchColor;
|
|
588
|
+
return parentBranchColor || branchColor || getDefaultBranchColor(board, element);
|
|
490
589
|
};
|
|
491
590
|
const getBranchShapeByMindElement = (board, element) => {
|
|
492
591
|
const branchShape = getAvailableProperty(board, element, 'branchShape');
|
|
@@ -508,23 +607,29 @@ const getAbstractBranchColor = (board, element) => {
|
|
|
508
607
|
}
|
|
509
608
|
return DefaultAbstractNodeStyle.branchColor;
|
|
510
609
|
};
|
|
511
|
-
const getNextBranchColor = (root) => {
|
|
610
|
+
const getNextBranchColor = (board, root) => {
|
|
512
611
|
const index = root.children.length;
|
|
513
|
-
return getDefaultBranchColorByIndex(index);
|
|
612
|
+
return getDefaultBranchColorByIndex(board, index);
|
|
514
613
|
};
|
|
515
614
|
const getDefaultBranchColor = (board, element) => {
|
|
516
615
|
const path = PlaitBoard.findPath(board, element);
|
|
517
|
-
return getDefaultBranchColorByIndex(path[1]);
|
|
616
|
+
return getDefaultBranchColorByIndex(board, path[1]);
|
|
518
617
|
};
|
|
519
|
-
const getDefaultBranchColorByIndex = (index) => {
|
|
520
|
-
const
|
|
618
|
+
const getDefaultBranchColorByIndex = (board, index) => {
|
|
619
|
+
const themeColor = getMindThemeColor(board);
|
|
620
|
+
const length = themeColor.branchColors.length;
|
|
521
621
|
const remainder = index % length;
|
|
522
|
-
return
|
|
622
|
+
return themeColor.branchColors[remainder];
|
|
623
|
+
};
|
|
624
|
+
const getMindThemeColor = (board) => {
|
|
625
|
+
const themeColors = PlaitBoard.getThemeColors(board);
|
|
626
|
+
return themeColors.find(val => val.mode === board.theme.themeColorMode) || MindDefaultThemeColor;
|
|
523
627
|
};
|
|
524
628
|
|
|
525
629
|
const getStrokeByMindElement = (board, element) => {
|
|
526
630
|
if (PlaitMind.isMind(element)) {
|
|
527
|
-
|
|
631
|
+
const defaultRootStroke = getMindThemeColor(board).rootFill;
|
|
632
|
+
return element.strokeColor || defaultRootStroke;
|
|
528
633
|
}
|
|
529
634
|
const ancestors = MindElement.getAncestors(board, element);
|
|
530
635
|
ancestors.unshift(element);
|
|
@@ -552,30 +657,20 @@ function isVirtualKey(e) {
|
|
|
552
657
|
}
|
|
553
658
|
|
|
554
659
|
const IS_DRAGGING = new WeakMap();
|
|
555
|
-
const addActiveOnDragOrigin = (activeElement
|
|
660
|
+
const addActiveOnDragOrigin = (activeElement) => {
|
|
556
661
|
const activeComponent = PlaitElement.getComponent(activeElement);
|
|
557
|
-
|
|
558
|
-
activeComponent.g.classList.add('dragging-origin');
|
|
559
|
-
}
|
|
560
|
-
else {
|
|
561
|
-
activeComponent.g.classList.add('dragging-child');
|
|
562
|
-
}
|
|
662
|
+
activeComponent.g.classList.add('dragging-node');
|
|
563
663
|
!activeElement.isCollapsed &&
|
|
564
664
|
activeElement.children.forEach(child => {
|
|
565
|
-
addActiveOnDragOrigin(child
|
|
665
|
+
addActiveOnDragOrigin(child);
|
|
566
666
|
});
|
|
567
667
|
};
|
|
568
|
-
const removeActiveOnDragOrigin = (activeElement
|
|
668
|
+
const removeActiveOnDragOrigin = (activeElement) => {
|
|
569
669
|
const activeComponent = PlaitElement.getComponent(activeElement);
|
|
570
|
-
|
|
571
|
-
activeComponent.g.classList.remove('dragging-origin');
|
|
572
|
-
}
|
|
573
|
-
else {
|
|
574
|
-
activeComponent.g.classList.remove('dragging-child');
|
|
575
|
-
}
|
|
670
|
+
activeComponent.g.classList.remove('dragging-node');
|
|
576
671
|
!activeElement.isCollapsed &&
|
|
577
672
|
activeElement.children.forEach(child => {
|
|
578
|
-
removeActiveOnDragOrigin(child
|
|
673
|
+
removeActiveOnDragOrigin(child);
|
|
579
674
|
});
|
|
580
675
|
};
|
|
581
676
|
const isDragging = (board) => {
|
|
@@ -584,22 +679,20 @@ const isDragging = (board) => {
|
|
|
584
679
|
const setIsDragging = (board, state) => {
|
|
585
680
|
IS_DRAGGING.set(board, state);
|
|
586
681
|
};
|
|
587
|
-
const hasPreviousOrNextOfDropPath = (parent,
|
|
588
|
-
|
|
589
|
-
let hasPreviousNode = dropPath[dropPath.length - 1] !== 0;
|
|
590
|
-
let hasNextNode = dropPath[dropPath.length - 1] !== (children?.length || 0);
|
|
682
|
+
const hasPreviousOrNextOfDropPath = (parent, dropTarget, dropPath) => {
|
|
683
|
+
let children = getNonAbstractChildren(parent);
|
|
591
684
|
if (PlaitMind.isMind(parent) && isStandardLayout(getRootLayout(parent))) {
|
|
592
|
-
const
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
hasPreviousNode = true;
|
|
596
|
-
hasNextNode = false;
|
|
685
|
+
const isDropRight = isDropStandardRight(parent, dropTarget);
|
|
686
|
+
if (isDropRight) {
|
|
687
|
+
children = children.slice(0, parent.rightNodeCount);
|
|
597
688
|
}
|
|
598
|
-
if (
|
|
599
|
-
|
|
600
|
-
|
|
689
|
+
if (!isDropRight) {
|
|
690
|
+
children = children.slice(parent.rightNodeCount, children.length);
|
|
691
|
+
dropPath = [...dropPath, dropPath[dropPath.length - 1] - parent.rightNodeCount];
|
|
601
692
|
}
|
|
602
693
|
}
|
|
694
|
+
let hasPreviousNode = dropPath[dropPath.length - 1] !== 0;
|
|
695
|
+
let hasNextNode = dropPath[dropPath.length - 1] !== (children?.length || 0);
|
|
603
696
|
if (parent.isCollapsed) {
|
|
604
697
|
hasNextNode = false;
|
|
605
698
|
hasPreviousNode = false;
|
|
@@ -609,6 +702,14 @@ const hasPreviousOrNextOfDropPath = (parent, target, dropPath) => {
|
|
|
609
702
|
hasNextNode
|
|
610
703
|
};
|
|
611
704
|
};
|
|
705
|
+
const isDropStandardRight = (parent, dropTarget) => {
|
|
706
|
+
const target = dropTarget.target;
|
|
707
|
+
return ((PlaitMind.isMind(parent) &&
|
|
708
|
+
isStandardLayout(getRootLayout(parent)) &&
|
|
709
|
+
parent.children.indexOf(target) !== -1 &&
|
|
710
|
+
parent.children.indexOf(target) < parent.rightNodeCount) ||
|
|
711
|
+
(PlaitMind.isMind(target) && isStandardLayout(getRootLayout(target)) && dropTarget.detectResult === 'right'));
|
|
712
|
+
};
|
|
612
713
|
|
|
613
714
|
const directionCorrector = (board, node, detectResults) => {
|
|
614
715
|
if (!node.origin.isRoot && !AbstractNode.isAbstract(node.origin)) {
|
|
@@ -735,88 +836,6 @@ const directionDetector = (targetNode, centerPoint) => {
|
|
|
735
836
|
}
|
|
736
837
|
return null;
|
|
737
838
|
};
|
|
738
|
-
/* 根据布局调整 target 以及 direction */
|
|
739
|
-
const readjustmentDropTarget = (board, dropTarget) => {
|
|
740
|
-
const { target, detectResult } = dropTarget;
|
|
741
|
-
const newDropTarget = { target, detectResult };
|
|
742
|
-
const targetComponent = PlaitElement.getComponent(target);
|
|
743
|
-
if (targetComponent.node.children.length > 0 && dropTarget.detectResult) {
|
|
744
|
-
const layout = MindQueries.getCorrectLayoutByElement(board, targetComponent.node.origin);
|
|
745
|
-
const parentLayout = MindQueries.getCorrectLayoutByElement(board, targetComponent.node.origin.isRoot ? targetComponent.node.origin : targetComponent.node.parent.origin);
|
|
746
|
-
const children = getNonAbstractChildren(targetComponent.node);
|
|
747
|
-
if (['right', 'left'].includes(dropTarget.detectResult)) {
|
|
748
|
-
if (!isMixedLayout(parentLayout, layout)) {
|
|
749
|
-
if (targetComponent.node.origin.isRoot) {
|
|
750
|
-
const layout = MindQueries.getCorrectLayoutByElement(board, targetComponent.node.origin);
|
|
751
|
-
// 标准布局,根节点
|
|
752
|
-
if (isStandardLayout(layout)) {
|
|
753
|
-
const rightNodeCount = targetComponent.node.origin.rightNodeCount;
|
|
754
|
-
if (detectResult === 'left') {
|
|
755
|
-
// 作为左的第一个节点
|
|
756
|
-
if (targetComponent.node.children.length === rightNodeCount) {
|
|
757
|
-
return newDropTarget;
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
else {
|
|
761
|
-
// 作为右的第一个节点或最后一个节点
|
|
762
|
-
if (rightNodeCount === 0) {
|
|
763
|
-
newDropTarget.target = target;
|
|
764
|
-
}
|
|
765
|
-
else {
|
|
766
|
-
newDropTarget.target = targetComponent.node.children[rightNodeCount - 1].origin;
|
|
767
|
-
newDropTarget.detectResult = 'bottom';
|
|
768
|
-
}
|
|
769
|
-
return newDropTarget;
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
// 缩进布局探测到第一个子节点
|
|
774
|
-
if (isIndentedLayout(parentLayout)) {
|
|
775
|
-
newDropTarget.target = targetComponent.node.children[0].origin;
|
|
776
|
-
newDropTarget.detectResult = isTopLayout(parentLayout) ? 'bottom' : 'top';
|
|
777
|
-
return newDropTarget;
|
|
778
|
-
}
|
|
779
|
-
// 上下布局的根节点只可以探测到上或者下,子节点的左右探测不处理,跳过。
|
|
780
|
-
if (isVerticalLogicLayout(parentLayout)) {
|
|
781
|
-
return newDropTarget;
|
|
782
|
-
}
|
|
783
|
-
// 剩下是水平布局的默认情况:插入最后一个子节点的下方
|
|
784
|
-
const lastChildNodeIndex = children.length - 1;
|
|
785
|
-
newDropTarget.target = targetComponent.node.children[lastChildNodeIndex].origin;
|
|
786
|
-
newDropTarget.detectResult = 'bottom';
|
|
787
|
-
}
|
|
788
|
-
else {
|
|
789
|
-
// 处理左右布局下的混合布局
|
|
790
|
-
if ([MindLayoutType.left, MindLayoutType.right].includes(parentLayout)) {
|
|
791
|
-
const layout = MindQueries.getCorrectLayoutByElement(board, targetComponent.node.origin);
|
|
792
|
-
if (isIndentedLayout(layout)) {
|
|
793
|
-
newDropTarget.target = targetComponent.node.children[0].origin;
|
|
794
|
-
newDropTarget.detectResult = isTopLayout(layout) ? 'bottom' : 'top';
|
|
795
|
-
return newDropTarget;
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
if (['top', 'bottom'].includes(dropTarget.detectResult)) {
|
|
801
|
-
// 缩进布局移动至第一个节点
|
|
802
|
-
if (targetComponent.node.origin.isRoot && isIndentedLayout(layout)) {
|
|
803
|
-
newDropTarget.target = targetComponent.node.children[0].origin;
|
|
804
|
-
newDropTarget.detectResult = isTopLayout(layout) ? 'bottom' : 'top';
|
|
805
|
-
return newDropTarget;
|
|
806
|
-
}
|
|
807
|
-
// 上下布局,插到右边
|
|
808
|
-
const parentLayout = MindQueries.getCorrectLayoutByElement(board, targetComponent.node.origin.isRoot ? targetComponent.node.origin : targetComponent.node.parent.origin);
|
|
809
|
-
if (isVerticalLogicLayout(parentLayout)) {
|
|
810
|
-
const lastChildNodeIndex = children.length - 1;
|
|
811
|
-
newDropTarget.target = targetComponent.node.children[lastChildNodeIndex].origin;
|
|
812
|
-
newDropTarget.detectResult = 'right';
|
|
813
|
-
return newDropTarget;
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
return newDropTarget;
|
|
817
|
-
}
|
|
818
|
-
return dropTarget;
|
|
819
|
-
};
|
|
820
839
|
const isValidTarget = (origin, target) => {
|
|
821
840
|
return origin !== target && !isChildElement(origin, target);
|
|
822
841
|
};
|
|
@@ -838,7 +857,13 @@ const getPathByDropTarget = (board, dropTarget) => {
|
|
|
838
857
|
}
|
|
839
858
|
// 水平布局/标准布局:上下是兄弟节点,左右是子节点
|
|
840
859
|
if (isHorizontalLogicLayout(layout)) {
|
|
841
|
-
if (dropTarget.detectResult === 'right'
|
|
860
|
+
if (dropTarget.detectResult === 'right' && !PlaitMind.isMind(dropTarget?.target)) {
|
|
861
|
+
targetPath.push(children.length);
|
|
862
|
+
}
|
|
863
|
+
if (dropTarget.detectResult === 'right' && PlaitMind.isMind(dropTarget?.target) && isStandardLayout(layout)) {
|
|
864
|
+
targetPath.push(dropTarget?.target.rightNodeCount);
|
|
865
|
+
}
|
|
866
|
+
if (dropTarget.detectResult === 'left') {
|
|
842
867
|
targetPath.push(children.length);
|
|
843
868
|
}
|
|
844
869
|
// 如果是上,位置不变,下插入到下一个兄弟节点
|
|
@@ -869,7 +894,8 @@ function drawRoundRectangleByNode(board, node) {
|
|
|
869
894
|
return drawRoundRectangleByElement(board, rectangle, node.origin);
|
|
870
895
|
}
|
|
871
896
|
function drawRoundRectangleByElement(board, nodeRectangle, element) {
|
|
872
|
-
const
|
|
897
|
+
const defaultRootFill = getMindThemeColor(board).rootFill;
|
|
898
|
+
const fill = element.fill ? element.fill : element.isRoot ? defaultRootFill : DefaultNodeStyle.fill;
|
|
873
899
|
const stroke = getStrokeByMindElement(board, element);
|
|
874
900
|
const strokeWidth = element.strokeWidth ? element.strokeWidth : DefaultNodeStyle.strokeWidth;
|
|
875
901
|
const nodeG = drawRoundRectangle(PlaitBoard.getRoughSVG(board), nodeRectangle.x, nodeRectangle.y, nodeRectangle.x + nodeRectangle.width, nodeRectangle.y + nodeRectangle.height, {
|
|
@@ -1013,7 +1039,7 @@ const transformPlacement = (placement, direction) => {
|
|
|
1013
1039
|
|
|
1014
1040
|
function drawIndentedLink(board, node, child, defaultStroke = null, needDrawUnderline = true, defaultStrokeWidth) {
|
|
1015
1041
|
const branchShape = getBranchShapeByMindElement(board, node.origin);
|
|
1016
|
-
const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board,
|
|
1042
|
+
const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board, node.origin);
|
|
1017
1043
|
const branchColor = defaultStroke || getBranchColorByMindElement(board, child.origin);
|
|
1018
1044
|
const isUnderlineShape = getShapeByElement(board, child.origin) === MindElementShape.underline;
|
|
1019
1045
|
let beginX, beginY, endX, endY, beginNode = node, endNode = child;
|
|
@@ -1061,7 +1087,7 @@ function drawIndentedLink(board, node, child, defaultStroke = null, needDrawUnde
|
|
|
1061
1087
|
function drawLogicLink(board, parent, node, isHorizontal, defaultStroke = null, defaultStrokeWidth) {
|
|
1062
1088
|
const branchShape = getBranchShapeByMindElement(board, parent.origin);
|
|
1063
1089
|
const branchColor = defaultStroke || getBranchColorByMindElement(board, node.origin);
|
|
1064
|
-
const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board,
|
|
1090
|
+
const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board, parent.origin);
|
|
1065
1091
|
const hasStraightLine = !parent.origin.isRoot;
|
|
1066
1092
|
const parentShape = getShapeByElement(board, parent.origin);
|
|
1067
1093
|
const shape = node.origin.shape ? node.origin.shape : parentShape;
|
|
@@ -1124,7 +1150,8 @@ function drawLink(board, parentNode, node, isHorizontal, needDrawUnderline, defa
|
|
|
1124
1150
|
: drawLogicLink(board, parentNode, node, isHorizontal, defaultStroke, defaultStrokeWidth);
|
|
1125
1151
|
}
|
|
1126
1152
|
|
|
1127
|
-
const drawFakeDragNode = (board,
|
|
1153
|
+
const drawFakeDragNode = (board, element, offsetX, offsetY) => {
|
|
1154
|
+
const activeComponent = PlaitElement.getComponent(element);
|
|
1128
1155
|
const dragFakeNodeG = createG();
|
|
1129
1156
|
dragFakeNodeG.classList.add('dragging', 'fake-node', 'plait-board-attached');
|
|
1130
1157
|
const fakeDraggingNode = {
|
|
@@ -1139,14 +1166,22 @@ const drawFakeDragNode = (board, activeComponent, offsetX, offsetY) => {
|
|
|
1139
1166
|
updateForeignObject(richtextG, textRectangle.width, textRectangle.height, textRectangle.x + offsetX, textRectangle.y + offsetY);
|
|
1140
1167
|
dragFakeNodeG?.append(fakeNodeG);
|
|
1141
1168
|
dragFakeNodeG?.append(richtextG);
|
|
1169
|
+
// draw emojis
|
|
1170
|
+
if (MindElement.hasEmojis(element)) {
|
|
1171
|
+
const fakeEmojisG = activeComponent.emojisDrawer.g.cloneNode(true);
|
|
1172
|
+
const foreignRectangle = getEmojiForeignRectangle(board, element);
|
|
1173
|
+
updateForeignObject(fakeEmojisG, foreignRectangle.width, foreignRectangle.height, foreignRectangle.x + offsetX, foreignRectangle.y + offsetY);
|
|
1174
|
+
dragFakeNodeG?.append(fakeEmojisG);
|
|
1175
|
+
}
|
|
1142
1176
|
return dragFakeNodeG;
|
|
1143
1177
|
};
|
|
1144
|
-
const drawFakeDropNode = (board,
|
|
1178
|
+
const drawFakeDropNode = (board, dropTarget, path) => {
|
|
1179
|
+
const target = dropTarget.target;
|
|
1145
1180
|
const fakeDropNodeG = createG();
|
|
1146
1181
|
const parent = PlaitNode.get(board, Path.parent(path));
|
|
1147
1182
|
const layout = MindQueries.getLayoutByElement(parent);
|
|
1148
1183
|
const isHorizontal = isHorizontalLayout(layout);
|
|
1149
|
-
const { hasNextNode, hasPreviousNode } = hasPreviousOrNextOfDropPath(parent,
|
|
1184
|
+
const { hasNextNode, hasPreviousNode } = hasPreviousOrNextOfDropPath(parent, dropTarget, path);
|
|
1150
1185
|
const width = 30;
|
|
1151
1186
|
const height = 12;
|
|
1152
1187
|
let fakeNode, centerPoint, basicNode, linkDirection;
|
|
@@ -1155,6 +1190,16 @@ const drawFakeDropNode = (board, target, path) => {
|
|
|
1155
1190
|
const parentRect = getRectangleByNode(parentNode);
|
|
1156
1191
|
linkDirection = getLayoutDirection(parentNode, isHorizontal);
|
|
1157
1192
|
basicNode = parentNode;
|
|
1193
|
+
if (PlaitMind.isMind(target) && isStandardLayout(layout)) {
|
|
1194
|
+
if (dropTarget.detectResult === 'left') {
|
|
1195
|
+
linkDirection = LayoutDirection.left;
|
|
1196
|
+
basicNode.left = true;
|
|
1197
|
+
}
|
|
1198
|
+
else {
|
|
1199
|
+
linkDirection = LayoutDirection.right;
|
|
1200
|
+
basicNode.left = false;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1158
1203
|
const placement = [HorizontalPlacement.right, VerticalPlacement.middle];
|
|
1159
1204
|
transformPlacement(placement, linkDirection);
|
|
1160
1205
|
const parentCenterPoint = getPointByPlacement(parentRect, placement);
|
|
@@ -2493,7 +2538,9 @@ class QuickInsertDrawer extends BaseDrawer {
|
|
|
2493
2538
|
underlineCoordinates[MindLayoutType.right].startY -= height * 0.5;
|
|
2494
2539
|
underlineCoordinates[MindLayoutType.right].endY -= height * 0.5;
|
|
2495
2540
|
}
|
|
2496
|
-
const branchColor = PlaitMind.isMind(element)
|
|
2541
|
+
const branchColor = PlaitMind.isMind(element)
|
|
2542
|
+
? getNextBranchColor(this.board, element)
|
|
2543
|
+
: getBranchColorByMindElement(this.board, element);
|
|
2497
2544
|
let nodeLayout = MindQueries.getCorrectLayoutByElement(this.board, element);
|
|
2498
2545
|
if (element.isRoot && isStandardLayout(nodeLayout)) {
|
|
2499
2546
|
const root = element;
|
|
@@ -2604,7 +2651,8 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2604
2651
|
}
|
|
2605
2652
|
const isEqualNode = RectangleClient.isEqual(this.node, newNode);
|
|
2606
2653
|
this.node = newNode;
|
|
2607
|
-
|
|
2654
|
+
const isChangeTheme = this.board.operations.find(op => op.type === 'set_theme');
|
|
2655
|
+
if (!isEqualNode || value.element !== previous.element || isChangeTheme) {
|
|
2608
2656
|
this.drawActiveG();
|
|
2609
2657
|
this.updateActiveClass();
|
|
2610
2658
|
this.drawShape();
|
|
@@ -2822,7 +2870,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2822
2870
|
}
|
|
2823
2871
|
// interactive
|
|
2824
2872
|
fromEvent(collapseG, 'mouseup')
|
|
2825
|
-
.pipe(filter(() => !this.handActive ||
|
|
2873
|
+
.pipe(filter(() => !this.handActive || !!PlaitBoard.isReadonly(this.board)), take(1))
|
|
2826
2874
|
.subscribe(() => {
|
|
2827
2875
|
const isCollapsed = !this.node.origin.isCollapsed;
|
|
2828
2876
|
const newElement = { isCollapsed };
|
|
@@ -3254,7 +3302,7 @@ const withDnd = (board) => {
|
|
|
3254
3302
|
startPoint = point;
|
|
3255
3303
|
}
|
|
3256
3304
|
else if (isMultiple) {
|
|
3257
|
-
activeElements =
|
|
3305
|
+
activeElements = selectedElements;
|
|
3258
3306
|
startPoint = point;
|
|
3259
3307
|
}
|
|
3260
3308
|
}, node => {
|
|
@@ -3283,7 +3331,7 @@ const withDnd = (board) => {
|
|
|
3283
3331
|
dropTarget = detectDropTarget(board, detectPoint, dropTarget, [...activeElements, ...correspondingElements]);
|
|
3284
3332
|
if (dropTarget?.target) {
|
|
3285
3333
|
targetPath = getPathByDropTarget(board, dropTarget);
|
|
3286
|
-
fakeDropNodeG = drawFakeDropNode(board, dropTarget
|
|
3334
|
+
fakeDropNodeG = drawFakeDropNode(board, dropTarget, targetPath);
|
|
3287
3335
|
PlaitBoard.getHost(board).appendChild(fakeDropNodeG);
|
|
3288
3336
|
}
|
|
3289
3337
|
const offsetX = endPoint[0] - startPoint[0];
|
|
@@ -3292,27 +3340,29 @@ const withDnd = (board) => {
|
|
|
3292
3340
|
dragFakeNodeG = createG();
|
|
3293
3341
|
[...activeElements, ...correspondingElements].forEach(element => {
|
|
3294
3342
|
addActiveOnDragOrigin(element);
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
}
|
|
3343
|
+
});
|
|
3344
|
+
activeElements.forEach(element => {
|
|
3345
|
+
const nodeG = drawFakeDragNode(board, element, offsetX, offsetY);
|
|
3346
|
+
dragFakeNodeG?.appendChild(nodeG);
|
|
3300
3347
|
});
|
|
3301
3348
|
PlaitBoard.getHost(board).appendChild(dragFakeNodeG);
|
|
3302
3349
|
}
|
|
3303
3350
|
mousemove(event);
|
|
3304
3351
|
};
|
|
3305
3352
|
board.globalMouseup = (event) => {
|
|
3306
|
-
|
|
3307
|
-
|
|
3353
|
+
const firstLevelElements = getFirstLevelElement(activeElements);
|
|
3354
|
+
if (!board.options.readonly && firstLevelElements.length) {
|
|
3355
|
+
firstLevelElements.push(...correspondingElements);
|
|
3308
3356
|
if (isDragging(board)) {
|
|
3309
|
-
|
|
3357
|
+
firstLevelElements.forEach(element => {
|
|
3358
|
+
removeActiveOnDragOrigin(element);
|
|
3359
|
+
});
|
|
3310
3360
|
}
|
|
3311
3361
|
if (dropTarget) {
|
|
3312
3362
|
const targetPathRef = board.pathRef(targetPath);
|
|
3313
3363
|
const targetElementPathRef = board.pathRef(PlaitBoard.findPath(board, dropTarget.target));
|
|
3314
|
-
|
|
3315
|
-
const normalElements =
|
|
3364
|
+
let abstractRefs = getValidAbstractRefs(board, firstLevelElements);
|
|
3365
|
+
const normalElements = firstLevelElements
|
|
3316
3366
|
.filter(element => !abstractRefs.some(refs => refs.abstract === element))
|
|
3317
3367
|
.map(element => {
|
|
3318
3368
|
if (AbstractNode.isAbstract(element)) {
|
|
@@ -3323,18 +3373,30 @@ const withDnd = (board) => {
|
|
|
3323
3373
|
}
|
|
3324
3374
|
return element;
|
|
3325
3375
|
});
|
|
3326
|
-
const
|
|
3376
|
+
const hasPreviousNode = targetPath[targetPath.length - 1] !== 0;
|
|
3377
|
+
if (hasPreviousNode) {
|
|
3378
|
+
const previousElement = PlaitNode.get(board, Path.previous(targetPath));
|
|
3379
|
+
const correspondingAbstract = getCorrespondingAbstract(previousElement);
|
|
3380
|
+
const targetHasCorrespondAbstract = correspondingAbstract && correspondingAbstract.end !== targetPath[targetPath.length - 1] - 1;
|
|
3381
|
+
if (targetHasCorrespondAbstract) {
|
|
3382
|
+
const adjustedNode = abstractRefs.map(ref => {
|
|
3383
|
+
return adjustAbstractToNode(ref.abstract);
|
|
3384
|
+
});
|
|
3385
|
+
normalElements.push(...adjustedNode);
|
|
3386
|
+
abstractRefs = [];
|
|
3387
|
+
}
|
|
3388
|
+
}
|
|
3389
|
+
const effectedAbstracts = deleteElementHandleAbstract(board, firstLevelElements);
|
|
3327
3390
|
insertElementHandleAbstract(board, targetPath, normalElements.length, false, effectedAbstracts);
|
|
3328
3391
|
MindTransforms.setAbstractsByRefs(board, effectedAbstracts);
|
|
3329
|
-
let refs = deleteElementsHandleRightNodeCount(board,
|
|
3330
|
-
const
|
|
3331
|
-
|
|
3332
|
-
(Path.isSibling(targetPath, targetElementPathRef.current) || Path.equals(targetPath, targetElementPathRef.current));
|
|
3392
|
+
let refs = deleteElementsHandleRightNodeCount(board, firstLevelElements);
|
|
3393
|
+
const parent = PlaitNode.get(board, Path.parent(targetPath));
|
|
3394
|
+
const shouldChangeRoot = isDropStandardRight(parent, dropTarget);
|
|
3333
3395
|
if (shouldChangeRoot && targetElementPathRef.current) {
|
|
3334
3396
|
refs = insertElementHandleRightNodeCount(board, targetElementPathRef.current.slice(0, 1), normalElements.length, refs);
|
|
3335
3397
|
}
|
|
3336
3398
|
MindTransforms.setRightNodeCountByRefs(board, refs);
|
|
3337
|
-
MindTransforms.removeElements(board,
|
|
3399
|
+
MindTransforms.removeElements(board, firstLevelElements);
|
|
3338
3400
|
let insertPath = targetPathRef.current;
|
|
3339
3401
|
const parentPath = Path.parent(targetPathRef.current || targetPath);
|
|
3340
3402
|
if (!insertPath) {
|
|
@@ -3600,8 +3662,20 @@ const withMindExtend = (board) => {
|
|
|
3600
3662
|
const DefaultHotkey = 'm';
|
|
3601
3663
|
const withCreateMind = (board) => {
|
|
3602
3664
|
const newBoard = board;
|
|
3603
|
-
const { keydown, mousemove, mouseup } = board;
|
|
3665
|
+
const { keydown, mousedown, mousemove, mouseup } = board;
|
|
3604
3666
|
let fakeCreateNodeRef = null;
|
|
3667
|
+
newBoard.mousedown = (event) => {
|
|
3668
|
+
if (fakeCreateNodeRef && PlaitBoard.isPointer(board, MindPointerType.mind)) {
|
|
3669
|
+
const currentOptions = board.getPluginOptions(PlaitPluginKey.withSelection);
|
|
3670
|
+
board.setPluginOptions(PlaitPluginKey.withSelection, {
|
|
3671
|
+
isDisabledSelect: true
|
|
3672
|
+
});
|
|
3673
|
+
setTimeout(() => {
|
|
3674
|
+
board.setPluginOptions(PlaitPluginKey.withSelection, { ...currentOptions });
|
|
3675
|
+
}, 0);
|
|
3676
|
+
}
|
|
3677
|
+
mousedown(event);
|
|
3678
|
+
};
|
|
3605
3679
|
newBoard.mousemove = (event) => {
|
|
3606
3680
|
if (PlaitBoard.isReadonly(board)) {
|
|
3607
3681
|
mousemove(event);
|
|
@@ -3632,7 +3706,7 @@ const withCreateMind = (board) => {
|
|
|
3632
3706
|
fakeCreateNodeRef.nodeG = nodeG;
|
|
3633
3707
|
PlaitBoard.getHost(board).append(nodeG);
|
|
3634
3708
|
PlaitBoard.getHost(board).append(fakeCreateNodeRef.topicG);
|
|
3635
|
-
updateForeignObject
|
|
3709
|
+
updateForeignObject(fakeCreateNodeRef.topicG, topicRectangle.width, topicRectangle.height, topicRectangle.x, topicRectangle.y);
|
|
3636
3710
|
}
|
|
3637
3711
|
}
|
|
3638
3712
|
});
|
|
@@ -3677,6 +3751,31 @@ const withCreateMind = (board) => {
|
|
|
3677
3751
|
return newBoard;
|
|
3678
3752
|
};
|
|
3679
3753
|
|
|
3754
|
+
const withMindHotkey = (board) => {
|
|
3755
|
+
const { keydown } = board;
|
|
3756
|
+
board.keydown = (keyboardEvent) => {
|
|
3757
|
+
if (!PlaitBoard.getMovingPoint(board)) {
|
|
3758
|
+
return;
|
|
3759
|
+
}
|
|
3760
|
+
if (isExpandHotkey(keyboardEvent)) {
|
|
3761
|
+
const selectedMindElements = getSelectedElements(board).filter(element => MindElement.isMindElement(board, element));
|
|
3762
|
+
if (selectedMindElements.length === 1 &&
|
|
3763
|
+
!PlaitMind.isMind(selectedMindElements[0]) &&
|
|
3764
|
+
selectedMindElements[0].children &&
|
|
3765
|
+
selectedMindElements[0].children.length > 0) {
|
|
3766
|
+
const element = selectedMindElements[0];
|
|
3767
|
+
Transforms.setNode(board, { isCollapsed: element.isCollapsed ? false : true }, PlaitBoard.findPath(board, element));
|
|
3768
|
+
return;
|
|
3769
|
+
}
|
|
3770
|
+
}
|
|
3771
|
+
keydown(keyboardEvent);
|
|
3772
|
+
};
|
|
3773
|
+
return board;
|
|
3774
|
+
};
|
|
3775
|
+
const isExpandHotkey = (keyboardEvent) => {
|
|
3776
|
+
return isKeyHotkey('mod+/', keyboardEvent);
|
|
3777
|
+
};
|
|
3778
|
+
|
|
3680
3779
|
const withMind = (board) => {
|
|
3681
3780
|
const { drawElement, dblclick, keydown, insertFragment, setFragment, deleteFragment, isHitSelection, getRectangle, isMovable, isRecursion } = board;
|
|
3682
3781
|
board.drawElement = (context) => {
|
|
@@ -3688,6 +3787,20 @@ const withMind = (board) => {
|
|
|
3688
3787
|
}
|
|
3689
3788
|
return drawElement(context);
|
|
3690
3789
|
};
|
|
3790
|
+
board.applyTheme = (element) => {
|
|
3791
|
+
const mindElement = element;
|
|
3792
|
+
const shouldClearProperty = !PlaitBoard.isBoard(element) && (mindElement?.branchColor || mindElement?.fill || mindElement?.strokeColor);
|
|
3793
|
+
const isAbstract = AbstractNode.isAbstract(element);
|
|
3794
|
+
if (shouldClearProperty) {
|
|
3795
|
+
const path = PlaitBoard.findPath(board, element);
|
|
3796
|
+
if (isAbstract) {
|
|
3797
|
+
Transforms.setNode(board, { fill: null, strokeColor: DefaultAbstractNodeStyle.strokeColor, branchColor: DefaultAbstractNodeStyle.branchColor }, path);
|
|
3798
|
+
}
|
|
3799
|
+
else {
|
|
3800
|
+
Transforms.setNode(board, { fill: null, strokeColor: null, branchColor: null }, path);
|
|
3801
|
+
}
|
|
3802
|
+
}
|
|
3803
|
+
};
|
|
3691
3804
|
board.getRectangle = element => {
|
|
3692
3805
|
if (MindElement.isMindElement(board, element)) {
|
|
3693
3806
|
return getRectangleByNode(MindElement.getNode(element));
|
|
@@ -3701,12 +3814,9 @@ const withMind = (board) => {
|
|
|
3701
3814
|
return isRecursion(element);
|
|
3702
3815
|
};
|
|
3703
3816
|
board.isHitSelection = (element, range) => {
|
|
3704
|
-
if (MindElement.isMindElement(board, element)
|
|
3817
|
+
if (MindElement.isMindElement(board, element)) {
|
|
3705
3818
|
const client = getRectangleByNode(MindElement.getNode(element));
|
|
3706
3819
|
const isHit = RectangleClient.isHit(RectangleClient.toRectangleClient([range.anchor, range.focus]), client);
|
|
3707
|
-
if (isHit && MindElement.hasEmojis(element) && Selection.isCollapsed(range) && isHitEmojis(board, element, range.anchor)) {
|
|
3708
|
-
return false;
|
|
3709
|
-
}
|
|
3710
3820
|
return isHit;
|
|
3711
3821
|
}
|
|
3712
3822
|
return isHitSelection(element, range);
|
|
@@ -3868,13 +3978,22 @@ const withMind = (board) => {
|
|
|
3868
3978
|
MindTransforms.removeElements(board, selectedElements);
|
|
3869
3979
|
deleteFragment(data);
|
|
3870
3980
|
};
|
|
3871
|
-
return withMindExtend(withCreateMind(withAbstract(withDnd(board))));
|
|
3981
|
+
return withMindHotkey(withMindExtend(withCreateMind(withAbstract(withDnd(board)))));
|
|
3872
3982
|
};
|
|
3873
3983
|
|
|
3874
3984
|
class MindEmojiBaseComponent {
|
|
3875
3985
|
get nativeElement() {
|
|
3876
3986
|
return this.elementRef.nativeElement;
|
|
3877
3987
|
}
|
|
3988
|
+
handleClick() {
|
|
3989
|
+
const currentOptions = this.board.getPluginOptions(PlaitPluginKey.withSelection);
|
|
3990
|
+
this.board.setPluginOptions(PlaitPluginKey.withSelection, {
|
|
3991
|
+
isDisabledSelect: true
|
|
3992
|
+
});
|
|
3993
|
+
setTimeout(() => {
|
|
3994
|
+
this.board.setPluginOptions(PlaitPluginKey.withSelection, { ...currentOptions });
|
|
3995
|
+
}, 0);
|
|
3996
|
+
}
|
|
3878
3997
|
constructor(elementRef) {
|
|
3879
3998
|
this.elementRef = elementRef;
|
|
3880
3999
|
this.fontSize = 14;
|
|
@@ -3884,7 +4003,7 @@ class MindEmojiBaseComponent {
|
|
|
3884
4003
|
}
|
|
3885
4004
|
}
|
|
3886
4005
|
MindEmojiBaseComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindEmojiBaseComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
3887
|
-
MindEmojiBaseComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.5", type: MindEmojiBaseComponent, inputs: { fontSize: "fontSize", emojiItem: "emojiItem", board: "board", element: "element" }, host: { classAttribute: "mind-node-emoji" }, ngImport: i0 });
|
|
4006
|
+
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 });
|
|
3888
4007
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindEmojiBaseComponent, decorators: [{
|
|
3889
4008
|
type: Directive,
|
|
3890
4009
|
args: [{
|
|
@@ -3900,6 +4019,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
3900
4019
|
type: Input
|
|
3901
4020
|
}], element: [{
|
|
3902
4021
|
type: Input
|
|
4022
|
+
}], handleClick: [{
|
|
4023
|
+
type: HostListener,
|
|
4024
|
+
args: ['mousedown']
|
|
3903
4025
|
}] } });
|
|
3904
4026
|
|
|
3905
4027
|
/*
|
|
@@ -3910,5 +4032,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
3910
4032
|
* Generated bundle index. Do not edit.
|
|
3911
4033
|
*/
|
|
3912
4034
|
|
|
3913
|
-
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE,
|
|
4035
|
+
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_WIDTH, BaseDrawer, BranchShape, DefaultAbstractNodeStyle, DefaultNodeStyle, ELEMENT_TO_NODE, EXTEND_OFFSET, EXTEND_RADIUS, GRAY_COLOR, IS_DRAGGING, LayoutDirection, LayoutDirectionsMap, MindColorfulThemeColor, MindDarkThemeColor, MindDefaultThemeColor, MindElement, MindElementShape, MindEmojiBaseComponent, MindModule, MindNode, MindNodeComponent, MindPointerType, MindQueries, MindRetroThemeColor, MindSoftThemeColor, MindStarryThemeColor, MindThemeColors, MindTransforms, NODE_MIN_WIDTH, PRIMARY_COLOR, PlaitMind, PlaitMindComponent, QUICK_INSERT_CIRCLE_COLOR, QUICK_INSERT_CIRCLE_OFFSET, QUICK_INSERT_INNER_CROSS_COLOR, ROOT_TOPIC_FONT_SIZE, STROKE_WIDTH, TOPIC_COLOR, TOPIC_DEFAULT_MAX_WORD_COUNT, TOPIC_FONT_SIZE, TRANSPARENT, addActiveOnDragOrigin, adjustAbstractToNode, adjustNodeToRoot, adjustRootToNode, canSetAbstract, copyNewNode, correctLayoutByDirection, createDefaultMind, createEmptyMind, createMindElement, deleteElementHandleAbstract, deleteElementsHandleRightNodeCount, detectDropTarget, directionCorrector, directionDetector, divideElementByParent, drawFakeDragNode, drawFakeDropNode, enterNodeEditing, extractNodesText, findLastChild, findLocationLeftIndex, getAbstractBranchColor, getAbstractBranchWidth, getAbstractHandleRectangle, getAllowedDirection, getAvailableSubLayoutsByLayoutDirections, getBehindAbstracts, getBranchColorByMindElement, getBranchDirectionsByLayouts, getBranchShapeByMindElement, getBranchWidthByMindElement, getChildrenCount, getCorrespondingAbstract, getDefaultBranchColor, getDefaultBranchColorByIndex, getDefaultLayout, getEmojiForeignRectangle, getEmojiRectangle, getFirstLevelElement, getHitAbstractHandle, getInCorrectLayoutDirection, getLayoutDirection$1 as getLayoutDirection, getLayoutReverseDirection, getLocationScope, getMindThemeColor, getNextBranchColor, getOverallAbstracts, getPathByDropTarget, getRectangleByElement, getRectangleByNode, getRectangleByResizingLocation, getRelativeStartEndByAbstractRef, getRootLayout, getShapeByElement, getStrokeByMindElement, getTopicRectangleByElement, getTopicRectangleByNode, getValidAbstractRefs, handleTouchedAbstract, hasAfterDraw, hasPreviousOrNextOfDropPath, insertElementHandleAbstract, insertElementHandleRightNodeCount, insertMindElement, isChildElement, isChildRight, isChildUp, isCorrectLayout, isDragging, isDropStandardRight, isHitEmojis, isHitMindElement, isInRightBranchOfStandardLayout, isMixedLayout, isSetAbstract, isValidTarget, isVirtualKey, removeActiveOnDragOrigin, separateChildren, setIsDragging, withMind, withMindExtend };
|
|
3914
4036
|
//# sourceMappingURL=plait-mind.mjs.map
|