@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/fesm2015/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,94 @@ 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 = Object.assign(Object.assign({}, DefaultThemeColor), { branchColors: DEFAULT_BRANCH_COLORS, rootFill: '#f5f5f5', rootTextColor: '#333333' });
|
|
164
|
+
const MindColorfulThemeColor = Object.assign(Object.assign({}, ColorfulThemeColor), { branchColors: COLORFUL_BRANCH_COLORS, rootFill: '#333333', rootTextColor: '#FFFFFF' });
|
|
165
|
+
const MindSoftThemeColor = Object.assign(Object.assign({}, SoftThemeColor), { branchColors: SOFT_BRANCH_COLORS, rootFill: '#FFFFFF', rootTextColor: '#333333' });
|
|
166
|
+
const MindRetroThemeColor = Object.assign(Object.assign({}, RetroThemeColor), { branchColors: RETRO_BRANCH_COLORS, rootFill: '#153D5D', rootTextColor: '#FFFFFF' });
|
|
167
|
+
const MindDarkThemeColor = Object.assign(Object.assign({}, DarkThemeColor), { branchColors: DARK_BRANCH_COLORS, rootFill: '#FFFFFF', rootTextColor: '#333333' });
|
|
168
|
+
const MindStarryThemeColor = Object.assign(Object.assign({}, StarryThemeColor), { branchColors: STARRY_BRANCH_COLORS, rootFill: '#FFFFFF', rootTextColor: '#333333' });
|
|
169
|
+
const MindThemeColors = [
|
|
170
|
+
MindDefaultThemeColor,
|
|
171
|
+
MindColorfulThemeColor,
|
|
172
|
+
MindSoftThemeColor,
|
|
173
|
+
MindRetroThemeColor,
|
|
174
|
+
MindDarkThemeColor,
|
|
175
|
+
MindStarryThemeColor
|
|
176
|
+
];
|
|
177
|
+
|
|
96
178
|
function getRectangleByNode(node) {
|
|
97
179
|
const x = node.x + node.hGap;
|
|
98
180
|
let y = node.y + node.vGap;
|
|
@@ -243,26 +325,11 @@ const createMindElement = (text, width, height, options) => {
|
|
|
243
325
|
strokeWidth: options.strokeWidth,
|
|
244
326
|
shape: options.shape
|
|
245
327
|
};
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
}
|
|
252
|
-
if (!isNullOrUndefined(options.strokeWidth)) {
|
|
253
|
-
newElement.strokeWidth = options.strokeWidth;
|
|
254
|
-
}
|
|
255
|
-
if (options.shape) {
|
|
256
|
-
newElement.shape = options.shape;
|
|
257
|
-
}
|
|
258
|
-
if (options.layout) {
|
|
259
|
-
newElement.layout = options.layout;
|
|
260
|
-
}
|
|
261
|
-
if (options.branchColor) {
|
|
262
|
-
newElement.branchColor = options.branchColor;
|
|
263
|
-
}
|
|
264
|
-
if (!isNullOrUndefined(options.branchWidth)) {
|
|
265
|
-
newElement.branchWidth = options.branchWidth;
|
|
328
|
+
let key;
|
|
329
|
+
for (key in options) {
|
|
330
|
+
if (!isNullOrUndefined(options[key])) {
|
|
331
|
+
newElement[key] = options[key];
|
|
332
|
+
}
|
|
266
333
|
}
|
|
267
334
|
return newElement;
|
|
268
335
|
};
|
|
@@ -322,14 +389,15 @@ const extractNodesText = (node) => {
|
|
|
322
389
|
};
|
|
323
390
|
// layoutLevel 用来表示插入兄弟节点还是子节点
|
|
324
391
|
const insertMindElement = (board, inheritNode, path) => {
|
|
325
|
-
|
|
392
|
+
const inheritAttributeKeys = Object.keys({});
|
|
393
|
+
const newNode = {};
|
|
326
394
|
if (!inheritNode.isRoot) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
395
|
+
inheritAttributeKeys.forEach(attr => {
|
|
396
|
+
newNode[attr] = inheritNode[attr];
|
|
397
|
+
});
|
|
398
|
+
delete newNode.layout;
|
|
330
399
|
}
|
|
331
|
-
|
|
332
|
-
const newElement = createMindElement('', NODE_MIN_WIDTH, TEXT_DEFAULT_HEIGHT, { fill, strokeColor, strokeWidth, shape });
|
|
400
|
+
const newElement = createMindElement('', NODE_MIN_WIDTH, TEXT_DEFAULT_HEIGHT, newNode);
|
|
333
401
|
Transforms.insertNode(board, newElement, path);
|
|
334
402
|
clearSelectedElement(board);
|
|
335
403
|
addSelectedElement(board, newElement);
|
|
@@ -480,8 +548,10 @@ const getAvailableProperty = (board, element, propertyKey) => {
|
|
|
480
548
|
* Processing of branch color, width, style, etc. of the mind node
|
|
481
549
|
*/
|
|
482
550
|
const getBranchColorByMindElement = (board, element) => {
|
|
551
|
+
var _a;
|
|
483
552
|
const branchColor = getAvailableProperty(board, element, 'branchColor');
|
|
484
|
-
|
|
553
|
+
const parentBranchColor = (_a = MindElement.getParent(element)) === null || _a === void 0 ? void 0 : _a.branchColor;
|
|
554
|
+
return parentBranchColor || branchColor || getDefaultBranchColor(board, element);
|
|
485
555
|
};
|
|
486
556
|
const getBranchShapeByMindElement = (board, element) => {
|
|
487
557
|
const branchShape = getAvailableProperty(board, element, 'branchShape');
|
|
@@ -503,23 +573,29 @@ const getAbstractBranchColor = (board, element) => {
|
|
|
503
573
|
}
|
|
504
574
|
return DefaultAbstractNodeStyle.branchColor;
|
|
505
575
|
};
|
|
506
|
-
const getNextBranchColor = (root) => {
|
|
576
|
+
const getNextBranchColor = (board, root) => {
|
|
507
577
|
const index = root.children.length;
|
|
508
|
-
return getDefaultBranchColorByIndex(index);
|
|
578
|
+
return getDefaultBranchColorByIndex(board, index);
|
|
509
579
|
};
|
|
510
580
|
const getDefaultBranchColor = (board, element) => {
|
|
511
581
|
const path = PlaitBoard.findPath(board, element);
|
|
512
|
-
return getDefaultBranchColorByIndex(path[1]);
|
|
582
|
+
return getDefaultBranchColorByIndex(board, path[1]);
|
|
513
583
|
};
|
|
514
|
-
const getDefaultBranchColorByIndex = (index) => {
|
|
515
|
-
const
|
|
584
|
+
const getDefaultBranchColorByIndex = (board, index) => {
|
|
585
|
+
const themeColor = getMindThemeColor(board);
|
|
586
|
+
const length = themeColor.branchColors.length;
|
|
516
587
|
const remainder = index % length;
|
|
517
|
-
return
|
|
588
|
+
return themeColor.branchColors[remainder];
|
|
589
|
+
};
|
|
590
|
+
const getMindThemeColor = (board) => {
|
|
591
|
+
const themeColors = PlaitBoard.getThemeColors(board);
|
|
592
|
+
return themeColors.find(val => val.mode === board.theme.themeColorMode) || MindDefaultThemeColor;
|
|
518
593
|
};
|
|
519
594
|
|
|
520
595
|
const getStrokeByMindElement = (board, element) => {
|
|
521
596
|
if (PlaitMind.isMind(element)) {
|
|
522
|
-
|
|
597
|
+
const defaultRootStroke = getMindThemeColor(board).rootFill;
|
|
598
|
+
return element.strokeColor || defaultRootStroke;
|
|
523
599
|
}
|
|
524
600
|
const ancestors = MindElement.getAncestors(board, element);
|
|
525
601
|
ancestors.unshift(element);
|
|
@@ -547,30 +623,20 @@ function isVirtualKey(e) {
|
|
|
547
623
|
}
|
|
548
624
|
|
|
549
625
|
const IS_DRAGGING = new WeakMap();
|
|
550
|
-
const addActiveOnDragOrigin = (activeElement
|
|
626
|
+
const addActiveOnDragOrigin = (activeElement) => {
|
|
551
627
|
const activeComponent = PlaitElement.getComponent(activeElement);
|
|
552
|
-
|
|
553
|
-
activeComponent.g.classList.add('dragging-origin');
|
|
554
|
-
}
|
|
555
|
-
else {
|
|
556
|
-
activeComponent.g.classList.add('dragging-child');
|
|
557
|
-
}
|
|
628
|
+
activeComponent.g.classList.add('dragging-node');
|
|
558
629
|
!activeElement.isCollapsed &&
|
|
559
630
|
activeElement.children.forEach(child => {
|
|
560
|
-
addActiveOnDragOrigin(child
|
|
631
|
+
addActiveOnDragOrigin(child);
|
|
561
632
|
});
|
|
562
633
|
};
|
|
563
|
-
const removeActiveOnDragOrigin = (activeElement
|
|
634
|
+
const removeActiveOnDragOrigin = (activeElement) => {
|
|
564
635
|
const activeComponent = PlaitElement.getComponent(activeElement);
|
|
565
|
-
|
|
566
|
-
activeComponent.g.classList.remove('dragging-origin');
|
|
567
|
-
}
|
|
568
|
-
else {
|
|
569
|
-
activeComponent.g.classList.remove('dragging-child');
|
|
570
|
-
}
|
|
636
|
+
activeComponent.g.classList.remove('dragging-node');
|
|
571
637
|
!activeElement.isCollapsed &&
|
|
572
638
|
activeElement.children.forEach(child => {
|
|
573
|
-
removeActiveOnDragOrigin(child
|
|
639
|
+
removeActiveOnDragOrigin(child);
|
|
574
640
|
});
|
|
575
641
|
};
|
|
576
642
|
const isDragging = (board) => {
|
|
@@ -579,22 +645,20 @@ const isDragging = (board) => {
|
|
|
579
645
|
const setIsDragging = (board, state) => {
|
|
580
646
|
IS_DRAGGING.set(board, state);
|
|
581
647
|
};
|
|
582
|
-
const hasPreviousOrNextOfDropPath = (parent,
|
|
583
|
-
|
|
584
|
-
let hasPreviousNode = dropPath[dropPath.length - 1] !== 0;
|
|
585
|
-
let hasNextNode = dropPath[dropPath.length - 1] !== ((children === null || children === void 0 ? void 0 : children.length) || 0);
|
|
648
|
+
const hasPreviousOrNextOfDropPath = (parent, dropTarget, dropPath) => {
|
|
649
|
+
let children = getNonAbstractChildren(parent);
|
|
586
650
|
if (PlaitMind.isMind(parent) && isStandardLayout(getRootLayout(parent))) {
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
hasPreviousNode = true;
|
|
591
|
-
hasNextNode = false;
|
|
651
|
+
const isDropRight = isDropStandardRight(parent, dropTarget);
|
|
652
|
+
if (isDropRight) {
|
|
653
|
+
children = children.slice(0, parent.rightNodeCount);
|
|
592
654
|
}
|
|
593
|
-
if (
|
|
594
|
-
|
|
595
|
-
|
|
655
|
+
if (!isDropRight) {
|
|
656
|
+
children = children.slice(parent.rightNodeCount, children.length);
|
|
657
|
+
dropPath = [...dropPath, dropPath[dropPath.length - 1] - parent.rightNodeCount];
|
|
596
658
|
}
|
|
597
659
|
}
|
|
660
|
+
let hasPreviousNode = dropPath[dropPath.length - 1] !== 0;
|
|
661
|
+
let hasNextNode = dropPath[dropPath.length - 1] !== ((children === null || children === void 0 ? void 0 : children.length) || 0);
|
|
598
662
|
if (parent.isCollapsed) {
|
|
599
663
|
hasNextNode = false;
|
|
600
664
|
hasPreviousNode = false;
|
|
@@ -604,6 +668,14 @@ const hasPreviousOrNextOfDropPath = (parent, target, dropPath) => {
|
|
|
604
668
|
hasNextNode
|
|
605
669
|
};
|
|
606
670
|
};
|
|
671
|
+
const isDropStandardRight = (parent, dropTarget) => {
|
|
672
|
+
const target = dropTarget.target;
|
|
673
|
+
return ((PlaitMind.isMind(parent) &&
|
|
674
|
+
isStandardLayout(getRootLayout(parent)) &&
|
|
675
|
+
parent.children.indexOf(target) !== -1 &&
|
|
676
|
+
parent.children.indexOf(target) < parent.rightNodeCount) ||
|
|
677
|
+
(PlaitMind.isMind(target) && isStandardLayout(getRootLayout(target)) && dropTarget.detectResult === 'right'));
|
|
678
|
+
};
|
|
607
679
|
|
|
608
680
|
const directionCorrector = (board, node, detectResults) => {
|
|
609
681
|
if (!node.origin.isRoot && !AbstractNode.isAbstract(node.origin)) {
|
|
@@ -730,88 +802,6 @@ const directionDetector = (targetNode, centerPoint) => {
|
|
|
730
802
|
}
|
|
731
803
|
return null;
|
|
732
804
|
};
|
|
733
|
-
/* 根据布局调整 target 以及 direction */
|
|
734
|
-
const readjustmentDropTarget = (board, dropTarget) => {
|
|
735
|
-
const { target, detectResult } = dropTarget;
|
|
736
|
-
const newDropTarget = { target, detectResult };
|
|
737
|
-
const targetComponent = PlaitElement.getComponent(target);
|
|
738
|
-
if (targetComponent.node.children.length > 0 && dropTarget.detectResult) {
|
|
739
|
-
const layout = MindQueries.getCorrectLayoutByElement(board, targetComponent.node.origin);
|
|
740
|
-
const parentLayout = MindQueries.getCorrectLayoutByElement(board, targetComponent.node.origin.isRoot ? targetComponent.node.origin : targetComponent.node.parent.origin);
|
|
741
|
-
const children = getNonAbstractChildren(targetComponent.node);
|
|
742
|
-
if (['right', 'left'].includes(dropTarget.detectResult)) {
|
|
743
|
-
if (!isMixedLayout(parentLayout, layout)) {
|
|
744
|
-
if (targetComponent.node.origin.isRoot) {
|
|
745
|
-
const layout = MindQueries.getCorrectLayoutByElement(board, targetComponent.node.origin);
|
|
746
|
-
// 标准布局,根节点
|
|
747
|
-
if (isStandardLayout(layout)) {
|
|
748
|
-
const rightNodeCount = targetComponent.node.origin.rightNodeCount;
|
|
749
|
-
if (detectResult === 'left') {
|
|
750
|
-
// 作为左的第一个节点
|
|
751
|
-
if (targetComponent.node.children.length === rightNodeCount) {
|
|
752
|
-
return newDropTarget;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
else {
|
|
756
|
-
// 作为右的第一个节点或最后一个节点
|
|
757
|
-
if (rightNodeCount === 0) {
|
|
758
|
-
newDropTarget.target = target;
|
|
759
|
-
}
|
|
760
|
-
else {
|
|
761
|
-
newDropTarget.target = targetComponent.node.children[rightNodeCount - 1].origin;
|
|
762
|
-
newDropTarget.detectResult = 'bottom';
|
|
763
|
-
}
|
|
764
|
-
return newDropTarget;
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
// 缩进布局探测到第一个子节点
|
|
769
|
-
if (isIndentedLayout(parentLayout)) {
|
|
770
|
-
newDropTarget.target = targetComponent.node.children[0].origin;
|
|
771
|
-
newDropTarget.detectResult = isTopLayout(parentLayout) ? 'bottom' : 'top';
|
|
772
|
-
return newDropTarget;
|
|
773
|
-
}
|
|
774
|
-
// 上下布局的根节点只可以探测到上或者下,子节点的左右探测不处理,跳过。
|
|
775
|
-
if (isVerticalLogicLayout(parentLayout)) {
|
|
776
|
-
return newDropTarget;
|
|
777
|
-
}
|
|
778
|
-
// 剩下是水平布局的默认情况:插入最后一个子节点的下方
|
|
779
|
-
const lastChildNodeIndex = children.length - 1;
|
|
780
|
-
newDropTarget.target = targetComponent.node.children[lastChildNodeIndex].origin;
|
|
781
|
-
newDropTarget.detectResult = 'bottom';
|
|
782
|
-
}
|
|
783
|
-
else {
|
|
784
|
-
// 处理左右布局下的混合布局
|
|
785
|
-
if ([MindLayoutType.left, MindLayoutType.right].includes(parentLayout)) {
|
|
786
|
-
const layout = MindQueries.getCorrectLayoutByElement(board, targetComponent.node.origin);
|
|
787
|
-
if (isIndentedLayout(layout)) {
|
|
788
|
-
newDropTarget.target = targetComponent.node.children[0].origin;
|
|
789
|
-
newDropTarget.detectResult = isTopLayout(layout) ? 'bottom' : 'top';
|
|
790
|
-
return newDropTarget;
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
if (['top', 'bottom'].includes(dropTarget.detectResult)) {
|
|
796
|
-
// 缩进布局移动至第一个节点
|
|
797
|
-
if (targetComponent.node.origin.isRoot && isIndentedLayout(layout)) {
|
|
798
|
-
newDropTarget.target = targetComponent.node.children[0].origin;
|
|
799
|
-
newDropTarget.detectResult = isTopLayout(layout) ? 'bottom' : 'top';
|
|
800
|
-
return newDropTarget;
|
|
801
|
-
}
|
|
802
|
-
// 上下布局,插到右边
|
|
803
|
-
const parentLayout = MindQueries.getCorrectLayoutByElement(board, targetComponent.node.origin.isRoot ? targetComponent.node.origin : targetComponent.node.parent.origin);
|
|
804
|
-
if (isVerticalLogicLayout(parentLayout)) {
|
|
805
|
-
const lastChildNodeIndex = children.length - 1;
|
|
806
|
-
newDropTarget.target = targetComponent.node.children[lastChildNodeIndex].origin;
|
|
807
|
-
newDropTarget.detectResult = 'right';
|
|
808
|
-
return newDropTarget;
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
return newDropTarget;
|
|
812
|
-
}
|
|
813
|
-
return dropTarget;
|
|
814
|
-
};
|
|
815
805
|
const isValidTarget = (origin, target) => {
|
|
816
806
|
return origin !== target && !isChildElement(origin, target);
|
|
817
807
|
};
|
|
@@ -833,7 +823,13 @@ const getPathByDropTarget = (board, dropTarget) => {
|
|
|
833
823
|
}
|
|
834
824
|
// 水平布局/标准布局:上下是兄弟节点,左右是子节点
|
|
835
825
|
if (isHorizontalLogicLayout(layout)) {
|
|
836
|
-
if (dropTarget.detectResult === 'right' || dropTarget
|
|
826
|
+
if (dropTarget.detectResult === 'right' && !PlaitMind.isMind(dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.target)) {
|
|
827
|
+
targetPath.push(children.length);
|
|
828
|
+
}
|
|
829
|
+
if (dropTarget.detectResult === 'right' && PlaitMind.isMind(dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.target) && isStandardLayout(layout)) {
|
|
830
|
+
targetPath.push(dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.target.rightNodeCount);
|
|
831
|
+
}
|
|
832
|
+
if (dropTarget.detectResult === 'left') {
|
|
837
833
|
targetPath.push(children.length);
|
|
838
834
|
}
|
|
839
835
|
// 如果是上,位置不变,下插入到下一个兄弟节点
|
|
@@ -864,7 +860,8 @@ function drawRoundRectangleByNode(board, node) {
|
|
|
864
860
|
return drawRoundRectangleByElement(board, rectangle, node.origin);
|
|
865
861
|
}
|
|
866
862
|
function drawRoundRectangleByElement(board, nodeRectangle, element) {
|
|
867
|
-
const
|
|
863
|
+
const defaultRootFill = getMindThemeColor(board).rootFill;
|
|
864
|
+
const fill = element.fill ? element.fill : element.isRoot ? defaultRootFill : DefaultNodeStyle.fill;
|
|
868
865
|
const stroke = getStrokeByMindElement(board, element);
|
|
869
866
|
const strokeWidth = element.strokeWidth ? element.strokeWidth : DefaultNodeStyle.strokeWidth;
|
|
870
867
|
const nodeG = drawRoundRectangle(PlaitBoard.getRoughSVG(board), nodeRectangle.x, nodeRectangle.y, nodeRectangle.x + nodeRectangle.width, nodeRectangle.y + nodeRectangle.height, {
|
|
@@ -1008,7 +1005,7 @@ const transformPlacement = (placement, direction) => {
|
|
|
1008
1005
|
|
|
1009
1006
|
function drawIndentedLink(board, node, child, defaultStroke = null, needDrawUnderline = true, defaultStrokeWidth) {
|
|
1010
1007
|
const branchShape = getBranchShapeByMindElement(board, node.origin);
|
|
1011
|
-
const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board,
|
|
1008
|
+
const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board, node.origin);
|
|
1012
1009
|
const branchColor = defaultStroke || getBranchColorByMindElement(board, child.origin);
|
|
1013
1010
|
const isUnderlineShape = getShapeByElement(board, child.origin) === MindElementShape.underline;
|
|
1014
1011
|
let beginX, beginY, endX, endY, beginNode = node, endNode = child;
|
|
@@ -1056,7 +1053,7 @@ function drawIndentedLink(board, node, child, defaultStroke = null, needDrawUnde
|
|
|
1056
1053
|
function drawLogicLink(board, parent, node, isHorizontal, defaultStroke = null, defaultStrokeWidth) {
|
|
1057
1054
|
const branchShape = getBranchShapeByMindElement(board, parent.origin);
|
|
1058
1055
|
const branchColor = defaultStroke || getBranchColorByMindElement(board, node.origin);
|
|
1059
|
-
const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board,
|
|
1056
|
+
const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board, parent.origin);
|
|
1060
1057
|
const hasStraightLine = !parent.origin.isRoot;
|
|
1061
1058
|
const parentShape = getShapeByElement(board, parent.origin);
|
|
1062
1059
|
const shape = node.origin.shape ? node.origin.shape : parentShape;
|
|
@@ -1119,8 +1116,9 @@ function drawLink(board, parentNode, node, isHorizontal, needDrawUnderline, defa
|
|
|
1119
1116
|
: drawLogicLink(board, parentNode, node, isHorizontal, defaultStroke, defaultStrokeWidth);
|
|
1120
1117
|
}
|
|
1121
1118
|
|
|
1122
|
-
const drawFakeDragNode = (board,
|
|
1119
|
+
const drawFakeDragNode = (board, element, offsetX, offsetY) => {
|
|
1123
1120
|
var _a;
|
|
1121
|
+
const activeComponent = PlaitElement.getComponent(element);
|
|
1124
1122
|
const dragFakeNodeG = createG();
|
|
1125
1123
|
dragFakeNodeG.classList.add('dragging', 'fake-node', 'plait-board-attached');
|
|
1126
1124
|
const fakeDraggingNode = Object.assign(Object.assign({}, activeComponent.node), { children: [], x: activeComponent.node.x + offsetX, y: activeComponent.node.y + offsetY });
|
|
@@ -1130,14 +1128,22 @@ const drawFakeDragNode = (board, activeComponent, offsetX, offsetY) => {
|
|
|
1130
1128
|
updateForeignObject(richtextG, textRectangle.width, textRectangle.height, textRectangle.x + offsetX, textRectangle.y + offsetY);
|
|
1131
1129
|
dragFakeNodeG === null || dragFakeNodeG === void 0 ? void 0 : dragFakeNodeG.append(fakeNodeG);
|
|
1132
1130
|
dragFakeNodeG === null || dragFakeNodeG === void 0 ? void 0 : dragFakeNodeG.append(richtextG);
|
|
1131
|
+
// draw emojis
|
|
1132
|
+
if (MindElement.hasEmojis(element)) {
|
|
1133
|
+
const fakeEmojisG = activeComponent.emojisDrawer.g.cloneNode(true);
|
|
1134
|
+
const foreignRectangle = getEmojiForeignRectangle(board, element);
|
|
1135
|
+
updateForeignObject(fakeEmojisG, foreignRectangle.width, foreignRectangle.height, foreignRectangle.x + offsetX, foreignRectangle.y + offsetY);
|
|
1136
|
+
dragFakeNodeG === null || dragFakeNodeG === void 0 ? void 0 : dragFakeNodeG.append(fakeEmojisG);
|
|
1137
|
+
}
|
|
1133
1138
|
return dragFakeNodeG;
|
|
1134
1139
|
};
|
|
1135
|
-
const drawFakeDropNode = (board,
|
|
1140
|
+
const drawFakeDropNode = (board, dropTarget, path) => {
|
|
1141
|
+
const target = dropTarget.target;
|
|
1136
1142
|
const fakeDropNodeG = createG();
|
|
1137
1143
|
const parent = PlaitNode.get(board, Path.parent(path));
|
|
1138
1144
|
const layout = MindQueries.getLayoutByElement(parent);
|
|
1139
1145
|
const isHorizontal = isHorizontalLayout(layout);
|
|
1140
|
-
const { hasNextNode, hasPreviousNode } = hasPreviousOrNextOfDropPath(parent,
|
|
1146
|
+
const { hasNextNode, hasPreviousNode } = hasPreviousOrNextOfDropPath(parent, dropTarget, path);
|
|
1141
1147
|
const width = 30;
|
|
1142
1148
|
const height = 12;
|
|
1143
1149
|
let fakeNode, centerPoint, basicNode, linkDirection;
|
|
@@ -1146,6 +1152,16 @@ const drawFakeDropNode = (board, target, path) => {
|
|
|
1146
1152
|
const parentRect = getRectangleByNode(parentNode);
|
|
1147
1153
|
linkDirection = getLayoutDirection(parentNode, isHorizontal);
|
|
1148
1154
|
basicNode = parentNode;
|
|
1155
|
+
if (PlaitMind.isMind(target) && isStandardLayout(layout)) {
|
|
1156
|
+
if (dropTarget.detectResult === 'left') {
|
|
1157
|
+
linkDirection = LayoutDirection.left;
|
|
1158
|
+
basicNode.left = true;
|
|
1159
|
+
}
|
|
1160
|
+
else {
|
|
1161
|
+
linkDirection = LayoutDirection.right;
|
|
1162
|
+
basicNode.left = false;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1149
1165
|
const placement = [HorizontalPlacement.right, VerticalPlacement.middle];
|
|
1150
1166
|
transformPlacement(placement, linkDirection);
|
|
1151
1167
|
const parentCenterPoint = getPointByPlacement(parentRect, placement);
|
|
@@ -2464,7 +2480,9 @@ class QuickInsertDrawer extends BaseDrawer {
|
|
|
2464
2480
|
underlineCoordinates[MindLayoutType.right].startY -= height * 0.5;
|
|
2465
2481
|
underlineCoordinates[MindLayoutType.right].endY -= height * 0.5;
|
|
2466
2482
|
}
|
|
2467
|
-
const branchColor = PlaitMind.isMind(element)
|
|
2483
|
+
const branchColor = PlaitMind.isMind(element)
|
|
2484
|
+
? getNextBranchColor(this.board, element)
|
|
2485
|
+
: getBranchColorByMindElement(this.board, element);
|
|
2468
2486
|
let nodeLayout = MindQueries.getCorrectLayoutByElement(this.board, element);
|
|
2469
2487
|
if (element.isRoot && isStandardLayout(nodeLayout)) {
|
|
2470
2488
|
const root = element;
|
|
@@ -2576,7 +2594,8 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2576
2594
|
}
|
|
2577
2595
|
const isEqualNode = RectangleClient.isEqual(this.node, newNode);
|
|
2578
2596
|
this.node = newNode;
|
|
2579
|
-
|
|
2597
|
+
const isChangeTheme = this.board.operations.find(op => op.type === 'set_theme');
|
|
2598
|
+
if (!isEqualNode || value.element !== previous.element || isChangeTheme) {
|
|
2580
2599
|
this.drawActiveG();
|
|
2581
2600
|
this.updateActiveClass();
|
|
2582
2601
|
this.drawShape();
|
|
@@ -2796,7 +2815,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2796
2815
|
}
|
|
2797
2816
|
// interactive
|
|
2798
2817
|
fromEvent(collapseG, 'mouseup')
|
|
2799
|
-
.pipe(filter(() => !this.handActive ||
|
|
2818
|
+
.pipe(filter(() => !this.handActive || !!PlaitBoard.isReadonly(this.board)), take(1))
|
|
2800
2819
|
.subscribe(() => {
|
|
2801
2820
|
const isCollapsed = !this.node.origin.isCollapsed;
|
|
2802
2821
|
const newElement = { isCollapsed };
|
|
@@ -3231,7 +3250,7 @@ const withDnd = (board) => {
|
|
|
3231
3250
|
startPoint = point;
|
|
3232
3251
|
}
|
|
3233
3252
|
else if (isMultiple) {
|
|
3234
|
-
activeElements =
|
|
3253
|
+
activeElements = selectedElements;
|
|
3235
3254
|
startPoint = point;
|
|
3236
3255
|
}
|
|
3237
3256
|
}, node => {
|
|
@@ -3260,7 +3279,7 @@ const withDnd = (board) => {
|
|
|
3260
3279
|
dropTarget = detectDropTarget(board, detectPoint, dropTarget, [...activeElements, ...correspondingElements]);
|
|
3261
3280
|
if (dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.target) {
|
|
3262
3281
|
targetPath = getPathByDropTarget(board, dropTarget);
|
|
3263
|
-
fakeDropNodeG = drawFakeDropNode(board, dropTarget
|
|
3282
|
+
fakeDropNodeG = drawFakeDropNode(board, dropTarget, targetPath);
|
|
3264
3283
|
PlaitBoard.getHost(board).appendChild(fakeDropNodeG);
|
|
3265
3284
|
}
|
|
3266
3285
|
const offsetX = endPoint[0] - startPoint[0];
|
|
@@ -3269,27 +3288,29 @@ const withDnd = (board) => {
|
|
|
3269
3288
|
dragFakeNodeG = createG();
|
|
3270
3289
|
[...activeElements, ...correspondingElements].forEach(element => {
|
|
3271
3290
|
addActiveOnDragOrigin(element);
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
}
|
|
3291
|
+
});
|
|
3292
|
+
activeElements.forEach(element => {
|
|
3293
|
+
const nodeG = drawFakeDragNode(board, element, offsetX, offsetY);
|
|
3294
|
+
dragFakeNodeG === null || dragFakeNodeG === void 0 ? void 0 : dragFakeNodeG.appendChild(nodeG);
|
|
3277
3295
|
});
|
|
3278
3296
|
PlaitBoard.getHost(board).appendChild(dragFakeNodeG);
|
|
3279
3297
|
}
|
|
3280
3298
|
mousemove(event);
|
|
3281
3299
|
};
|
|
3282
3300
|
board.globalMouseup = (event) => {
|
|
3283
|
-
|
|
3284
|
-
|
|
3301
|
+
const firstLevelElements = getFirstLevelElement(activeElements);
|
|
3302
|
+
if (!board.options.readonly && firstLevelElements.length) {
|
|
3303
|
+
firstLevelElements.push(...correspondingElements);
|
|
3285
3304
|
if (isDragging(board)) {
|
|
3286
|
-
|
|
3305
|
+
firstLevelElements.forEach(element => {
|
|
3306
|
+
removeActiveOnDragOrigin(element);
|
|
3307
|
+
});
|
|
3287
3308
|
}
|
|
3288
3309
|
if (dropTarget) {
|
|
3289
3310
|
const targetPathRef = board.pathRef(targetPath);
|
|
3290
3311
|
const targetElementPathRef = board.pathRef(PlaitBoard.findPath(board, dropTarget.target));
|
|
3291
|
-
|
|
3292
|
-
const normalElements =
|
|
3312
|
+
let abstractRefs = getValidAbstractRefs(board, firstLevelElements);
|
|
3313
|
+
const normalElements = firstLevelElements
|
|
3293
3314
|
.filter(element => !abstractRefs.some(refs => refs.abstract === element))
|
|
3294
3315
|
.map(element => {
|
|
3295
3316
|
if (AbstractNode.isAbstract(element)) {
|
|
@@ -3300,18 +3321,30 @@ const withDnd = (board) => {
|
|
|
3300
3321
|
}
|
|
3301
3322
|
return element;
|
|
3302
3323
|
});
|
|
3303
|
-
const
|
|
3324
|
+
const hasPreviousNode = targetPath[targetPath.length - 1] !== 0;
|
|
3325
|
+
if (hasPreviousNode) {
|
|
3326
|
+
const previousElement = PlaitNode.get(board, Path.previous(targetPath));
|
|
3327
|
+
const correspondingAbstract = getCorrespondingAbstract(previousElement);
|
|
3328
|
+
const targetHasCorrespondAbstract = correspondingAbstract && correspondingAbstract.end !== targetPath[targetPath.length - 1] - 1;
|
|
3329
|
+
if (targetHasCorrespondAbstract) {
|
|
3330
|
+
const adjustedNode = abstractRefs.map(ref => {
|
|
3331
|
+
return adjustAbstractToNode(ref.abstract);
|
|
3332
|
+
});
|
|
3333
|
+
normalElements.push(...adjustedNode);
|
|
3334
|
+
abstractRefs = [];
|
|
3335
|
+
}
|
|
3336
|
+
}
|
|
3337
|
+
const effectedAbstracts = deleteElementHandleAbstract(board, firstLevelElements);
|
|
3304
3338
|
insertElementHandleAbstract(board, targetPath, normalElements.length, false, effectedAbstracts);
|
|
3305
3339
|
MindTransforms.setAbstractsByRefs(board, effectedAbstracts);
|
|
3306
|
-
let refs = deleteElementsHandleRightNodeCount(board,
|
|
3307
|
-
const
|
|
3308
|
-
|
|
3309
|
-
(Path.isSibling(targetPath, targetElementPathRef.current) || Path.equals(targetPath, targetElementPathRef.current));
|
|
3340
|
+
let refs = deleteElementsHandleRightNodeCount(board, firstLevelElements);
|
|
3341
|
+
const parent = PlaitNode.get(board, Path.parent(targetPath));
|
|
3342
|
+
const shouldChangeRoot = isDropStandardRight(parent, dropTarget);
|
|
3310
3343
|
if (shouldChangeRoot && targetElementPathRef.current) {
|
|
3311
3344
|
refs = insertElementHandleRightNodeCount(board, targetElementPathRef.current.slice(0, 1), normalElements.length, refs);
|
|
3312
3345
|
}
|
|
3313
3346
|
MindTransforms.setRightNodeCountByRefs(board, refs);
|
|
3314
|
-
MindTransforms.removeElements(board,
|
|
3347
|
+
MindTransforms.removeElements(board, firstLevelElements);
|
|
3315
3348
|
let insertPath = targetPathRef.current;
|
|
3316
3349
|
const parentPath = Path.parent(targetPathRef.current || targetPath);
|
|
3317
3350
|
if (!insertPath) {
|
|
@@ -3571,8 +3604,20 @@ const withMindExtend = (board) => {
|
|
|
3571
3604
|
const DefaultHotkey = 'm';
|
|
3572
3605
|
const withCreateMind = (board) => {
|
|
3573
3606
|
const newBoard = board;
|
|
3574
|
-
const { keydown, mousemove, mouseup } = board;
|
|
3607
|
+
const { keydown, mousedown, mousemove, mouseup } = board;
|
|
3575
3608
|
let fakeCreateNodeRef = null;
|
|
3609
|
+
newBoard.mousedown = (event) => {
|
|
3610
|
+
if (fakeCreateNodeRef && PlaitBoard.isPointer(board, MindPointerType.mind)) {
|
|
3611
|
+
const currentOptions = board.getPluginOptions(PlaitPluginKey.withSelection);
|
|
3612
|
+
board.setPluginOptions(PlaitPluginKey.withSelection, {
|
|
3613
|
+
isDisabledSelect: true
|
|
3614
|
+
});
|
|
3615
|
+
setTimeout(() => {
|
|
3616
|
+
board.setPluginOptions(PlaitPluginKey.withSelection, Object.assign({}, currentOptions));
|
|
3617
|
+
}, 0);
|
|
3618
|
+
}
|
|
3619
|
+
mousedown(event);
|
|
3620
|
+
};
|
|
3576
3621
|
newBoard.mousemove = (event) => {
|
|
3577
3622
|
if (PlaitBoard.isReadonly(board)) {
|
|
3578
3623
|
mousemove(event);
|
|
@@ -3603,7 +3648,7 @@ const withCreateMind = (board) => {
|
|
|
3603
3648
|
fakeCreateNodeRef.nodeG = nodeG;
|
|
3604
3649
|
PlaitBoard.getHost(board).append(nodeG);
|
|
3605
3650
|
PlaitBoard.getHost(board).append(fakeCreateNodeRef.topicG);
|
|
3606
|
-
updateForeignObject
|
|
3651
|
+
updateForeignObject(fakeCreateNodeRef.topicG, topicRectangle.width, topicRectangle.height, topicRectangle.x, topicRectangle.y);
|
|
3607
3652
|
}
|
|
3608
3653
|
}
|
|
3609
3654
|
});
|
|
@@ -3648,6 +3693,31 @@ const withCreateMind = (board) => {
|
|
|
3648
3693
|
return newBoard;
|
|
3649
3694
|
};
|
|
3650
3695
|
|
|
3696
|
+
const withMindHotkey = (board) => {
|
|
3697
|
+
const { keydown } = board;
|
|
3698
|
+
board.keydown = (keyboardEvent) => {
|
|
3699
|
+
if (!PlaitBoard.getMovingPoint(board)) {
|
|
3700
|
+
return;
|
|
3701
|
+
}
|
|
3702
|
+
if (isExpandHotkey(keyboardEvent)) {
|
|
3703
|
+
const selectedMindElements = getSelectedElements(board).filter(element => MindElement.isMindElement(board, element));
|
|
3704
|
+
if (selectedMindElements.length === 1 &&
|
|
3705
|
+
!PlaitMind.isMind(selectedMindElements[0]) &&
|
|
3706
|
+
selectedMindElements[0].children &&
|
|
3707
|
+
selectedMindElements[0].children.length > 0) {
|
|
3708
|
+
const element = selectedMindElements[0];
|
|
3709
|
+
Transforms.setNode(board, { isCollapsed: element.isCollapsed ? false : true }, PlaitBoard.findPath(board, element));
|
|
3710
|
+
return;
|
|
3711
|
+
}
|
|
3712
|
+
}
|
|
3713
|
+
keydown(keyboardEvent);
|
|
3714
|
+
};
|
|
3715
|
+
return board;
|
|
3716
|
+
};
|
|
3717
|
+
const isExpandHotkey = (keyboardEvent) => {
|
|
3718
|
+
return isKeyHotkey('mod+/', keyboardEvent);
|
|
3719
|
+
};
|
|
3720
|
+
|
|
3651
3721
|
const withMind = (board) => {
|
|
3652
3722
|
const { drawElement, dblclick, keydown, insertFragment, setFragment, deleteFragment, isHitSelection, getRectangle, isMovable, isRecursion } = board;
|
|
3653
3723
|
board.drawElement = (context) => {
|
|
@@ -3659,6 +3729,20 @@ const withMind = (board) => {
|
|
|
3659
3729
|
}
|
|
3660
3730
|
return drawElement(context);
|
|
3661
3731
|
};
|
|
3732
|
+
board.applyTheme = (element) => {
|
|
3733
|
+
const mindElement = element;
|
|
3734
|
+
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));
|
|
3735
|
+
const isAbstract = AbstractNode.isAbstract(element);
|
|
3736
|
+
if (shouldClearProperty) {
|
|
3737
|
+
const path = PlaitBoard.findPath(board, element);
|
|
3738
|
+
if (isAbstract) {
|
|
3739
|
+
Transforms.setNode(board, { fill: null, strokeColor: DefaultAbstractNodeStyle.strokeColor, branchColor: DefaultAbstractNodeStyle.branchColor }, path);
|
|
3740
|
+
}
|
|
3741
|
+
else {
|
|
3742
|
+
Transforms.setNode(board, { fill: null, strokeColor: null, branchColor: null }, path);
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
3745
|
+
};
|
|
3662
3746
|
board.getRectangle = element => {
|
|
3663
3747
|
if (MindElement.isMindElement(board, element)) {
|
|
3664
3748
|
return getRectangleByNode(MindElement.getNode(element));
|
|
@@ -3672,12 +3756,9 @@ const withMind = (board) => {
|
|
|
3672
3756
|
return isRecursion(element);
|
|
3673
3757
|
};
|
|
3674
3758
|
board.isHitSelection = (element, range) => {
|
|
3675
|
-
if (MindElement.isMindElement(board, element)
|
|
3759
|
+
if (MindElement.isMindElement(board, element)) {
|
|
3676
3760
|
const client = getRectangleByNode(MindElement.getNode(element));
|
|
3677
3761
|
const isHit = RectangleClient.isHit(RectangleClient.toRectangleClient([range.anchor, range.focus]), client);
|
|
3678
|
-
if (isHit && MindElement.hasEmojis(element) && Selection.isCollapsed(range) && isHitEmojis(board, element, range.anchor)) {
|
|
3679
|
-
return false;
|
|
3680
|
-
}
|
|
3681
3762
|
return isHit;
|
|
3682
3763
|
}
|
|
3683
3764
|
return isHitSelection(element, range);
|
|
@@ -3839,13 +3920,22 @@ const withMind = (board) => {
|
|
|
3839
3920
|
MindTransforms.removeElements(board, selectedElements);
|
|
3840
3921
|
deleteFragment(data);
|
|
3841
3922
|
};
|
|
3842
|
-
return withMindExtend(withCreateMind(withAbstract(withDnd(board))));
|
|
3923
|
+
return withMindHotkey(withMindExtend(withCreateMind(withAbstract(withDnd(board)))));
|
|
3843
3924
|
};
|
|
3844
3925
|
|
|
3845
3926
|
class MindEmojiBaseComponent {
|
|
3846
3927
|
get nativeElement() {
|
|
3847
3928
|
return this.elementRef.nativeElement;
|
|
3848
3929
|
}
|
|
3930
|
+
handleClick() {
|
|
3931
|
+
const currentOptions = this.board.getPluginOptions(PlaitPluginKey.withSelection);
|
|
3932
|
+
this.board.setPluginOptions(PlaitPluginKey.withSelection, {
|
|
3933
|
+
isDisabledSelect: true
|
|
3934
|
+
});
|
|
3935
|
+
setTimeout(() => {
|
|
3936
|
+
this.board.setPluginOptions(PlaitPluginKey.withSelection, Object.assign({}, currentOptions));
|
|
3937
|
+
}, 0);
|
|
3938
|
+
}
|
|
3849
3939
|
constructor(elementRef) {
|
|
3850
3940
|
this.elementRef = elementRef;
|
|
3851
3941
|
this.fontSize = 14;
|
|
@@ -3855,7 +3945,7 @@ class MindEmojiBaseComponent {
|
|
|
3855
3945
|
}
|
|
3856
3946
|
}
|
|
3857
3947
|
MindEmojiBaseComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindEmojiBaseComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
3858
|
-
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 });
|
|
3948
|
+
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 });
|
|
3859
3949
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindEmojiBaseComponent, decorators: [{
|
|
3860
3950
|
type: Directive,
|
|
3861
3951
|
args: [{
|
|
@@ -3871,6 +3961,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
3871
3961
|
type: Input
|
|
3872
3962
|
}], element: [{
|
|
3873
3963
|
type: Input
|
|
3964
|
+
}], handleClick: [{
|
|
3965
|
+
type: HostListener,
|
|
3966
|
+
args: ['mousedown']
|
|
3874
3967
|
}] } });
|
|
3875
3968
|
|
|
3876
3969
|
/*
|
|
@@ -3881,5 +3974,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
3881
3974
|
* Generated bundle index. Do not edit.
|
|
3882
3975
|
*/
|
|
3883
3976
|
|
|
3884
|
-
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE,
|
|
3977
|
+
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 };
|
|
3885
3978
|
//# sourceMappingURL=plait-mind.mjs.map
|