@plait/mind 0.4.0 → 0.5.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/esm2020/base/emoji-base.component.mjs +16 -3
- package/esm2020/node.component.mjs +2 -2
- package/esm2020/plugins/with-mind-create.mjs +15 -3
- package/esm2020/plugins/with-mind.mjs +3 -7
- 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 -7
- package/esm2020/utils/node-style/branch.mjs +4 -3
- package/fesm2015/plait-mind.mjs +120 -144
- package/fesm2015/plait-mind.mjs.map +1 -1
- package/fesm2020/plait-mind.mjs +119 -144
- package/fesm2020/plait-mind.mjs.map +1 -1
- package/package.json +1 -1
- package/styles/styles.scss +1 -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/fesm2015/plait-mind.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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, throttleRAF, updateForeignObject as updateForeignObject$1, BoardTransforms,
|
|
5
|
-
import { MindLayoutType, isIndentedLayout, getNonAbstractChildren, isStandardLayout, AbstractNode, isLeftLayout, isRightLayout,
|
|
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, PlaitPluginKey, throttleRAF, updateForeignObject as updateForeignObject$1, 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
6
|
import { getSizeByText, ROOT_DEFAULT_HEIGHT, TEXT_DEFAULT_HEIGHT, updateForeignObject, drawRichtext, createForeignObject, 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';
|
|
@@ -480,8 +480,10 @@ const getAvailableProperty = (board, element, propertyKey) => {
|
|
|
480
480
|
* Processing of branch color, width, style, etc. of the mind node
|
|
481
481
|
*/
|
|
482
482
|
const getBranchColorByMindElement = (board, element) => {
|
|
483
|
+
var _a;
|
|
483
484
|
const branchColor = getAvailableProperty(board, element, 'branchColor');
|
|
484
|
-
|
|
485
|
+
const parentBranchColor = (_a = MindElement.getParent(element)) === null || _a === void 0 ? void 0 : _a.branchColor;
|
|
486
|
+
return parentBranchColor || branchColor || getDefaultBranchColor(board, element);
|
|
485
487
|
};
|
|
486
488
|
const getBranchShapeByMindElement = (board, element) => {
|
|
487
489
|
const branchShape = getAvailableProperty(board, element, 'branchShape');
|
|
@@ -547,30 +549,20 @@ function isVirtualKey(e) {
|
|
|
547
549
|
}
|
|
548
550
|
|
|
549
551
|
const IS_DRAGGING = new WeakMap();
|
|
550
|
-
const addActiveOnDragOrigin = (activeElement
|
|
552
|
+
const addActiveOnDragOrigin = (activeElement) => {
|
|
551
553
|
const activeComponent = PlaitElement.getComponent(activeElement);
|
|
552
|
-
|
|
553
|
-
activeComponent.g.classList.add('dragging-origin');
|
|
554
|
-
}
|
|
555
|
-
else {
|
|
556
|
-
activeComponent.g.classList.add('dragging-child');
|
|
557
|
-
}
|
|
554
|
+
activeComponent.g.classList.add('dragging-node');
|
|
558
555
|
!activeElement.isCollapsed &&
|
|
559
556
|
activeElement.children.forEach(child => {
|
|
560
|
-
addActiveOnDragOrigin(child
|
|
557
|
+
addActiveOnDragOrigin(child);
|
|
561
558
|
});
|
|
562
559
|
};
|
|
563
|
-
const removeActiveOnDragOrigin = (activeElement
|
|
560
|
+
const removeActiveOnDragOrigin = (activeElement) => {
|
|
564
561
|
const activeComponent = PlaitElement.getComponent(activeElement);
|
|
565
|
-
|
|
566
|
-
activeComponent.g.classList.remove('dragging-origin');
|
|
567
|
-
}
|
|
568
|
-
else {
|
|
569
|
-
activeComponent.g.classList.remove('dragging-child');
|
|
570
|
-
}
|
|
562
|
+
activeComponent.g.classList.remove('dragging-node');
|
|
571
563
|
!activeElement.isCollapsed &&
|
|
572
564
|
activeElement.children.forEach(child => {
|
|
573
|
-
removeActiveOnDragOrigin(child
|
|
565
|
+
removeActiveOnDragOrigin(child);
|
|
574
566
|
});
|
|
575
567
|
};
|
|
576
568
|
const isDragging = (board) => {
|
|
@@ -579,22 +571,20 @@ const isDragging = (board) => {
|
|
|
579
571
|
const setIsDragging = (board, state) => {
|
|
580
572
|
IS_DRAGGING.set(board, state);
|
|
581
573
|
};
|
|
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);
|
|
574
|
+
const hasPreviousOrNextOfDropPath = (parent, dropTarget, dropPath) => {
|
|
575
|
+
let children = getNonAbstractChildren(parent);
|
|
586
576
|
if (PlaitMind.isMind(parent) && isStandardLayout(getRootLayout(parent))) {
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
hasPreviousNode = true;
|
|
591
|
-
hasNextNode = false;
|
|
577
|
+
const isDropRight = isDropStandardRight(parent, dropTarget);
|
|
578
|
+
if (isDropRight) {
|
|
579
|
+
children = children.slice(0, parent.rightNodeCount);
|
|
592
580
|
}
|
|
593
|
-
if (
|
|
594
|
-
|
|
595
|
-
|
|
581
|
+
if (!isDropRight) {
|
|
582
|
+
children = children.slice(parent.rightNodeCount, children.length);
|
|
583
|
+
dropPath = [...dropPath, dropPath[dropPath.length - 1] - parent.rightNodeCount];
|
|
596
584
|
}
|
|
597
585
|
}
|
|
586
|
+
let hasPreviousNode = dropPath[dropPath.length - 1] !== 0;
|
|
587
|
+
let hasNextNode = dropPath[dropPath.length - 1] !== ((children === null || children === void 0 ? void 0 : children.length) || 0);
|
|
598
588
|
if (parent.isCollapsed) {
|
|
599
589
|
hasNextNode = false;
|
|
600
590
|
hasPreviousNode = false;
|
|
@@ -604,6 +594,14 @@ const hasPreviousOrNextOfDropPath = (parent, target, dropPath) => {
|
|
|
604
594
|
hasNextNode
|
|
605
595
|
};
|
|
606
596
|
};
|
|
597
|
+
const isDropStandardRight = (parent, dropTarget) => {
|
|
598
|
+
const target = dropTarget.target;
|
|
599
|
+
return ((PlaitMind.isMind(parent) &&
|
|
600
|
+
isStandardLayout(getRootLayout(parent)) &&
|
|
601
|
+
parent.children.indexOf(target) !== -1 &&
|
|
602
|
+
parent.children.indexOf(target) < parent.rightNodeCount) ||
|
|
603
|
+
(PlaitMind.isMind(target) && isStandardLayout(getRootLayout(target)) && dropTarget.detectResult === 'right'));
|
|
604
|
+
};
|
|
607
605
|
|
|
608
606
|
const directionCorrector = (board, node, detectResults) => {
|
|
609
607
|
if (!node.origin.isRoot && !AbstractNode.isAbstract(node.origin)) {
|
|
@@ -730,88 +728,6 @@ const directionDetector = (targetNode, centerPoint) => {
|
|
|
730
728
|
}
|
|
731
729
|
return null;
|
|
732
730
|
};
|
|
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
731
|
const isValidTarget = (origin, target) => {
|
|
816
732
|
return origin !== target && !isChildElement(origin, target);
|
|
817
733
|
};
|
|
@@ -833,7 +749,13 @@ const getPathByDropTarget = (board, dropTarget) => {
|
|
|
833
749
|
}
|
|
834
750
|
// 水平布局/标准布局:上下是兄弟节点,左右是子节点
|
|
835
751
|
if (isHorizontalLogicLayout(layout)) {
|
|
836
|
-
if (dropTarget.detectResult === 'right' || dropTarget
|
|
752
|
+
if (dropTarget.detectResult === 'right' && !PlaitMind.isMind(dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.target)) {
|
|
753
|
+
targetPath.push(children.length);
|
|
754
|
+
}
|
|
755
|
+
if (dropTarget.detectResult === 'right' && PlaitMind.isMind(dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.target) && isStandardLayout(layout)) {
|
|
756
|
+
targetPath.push(dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.target.rightNodeCount);
|
|
757
|
+
}
|
|
758
|
+
if (dropTarget.detectResult === 'left') {
|
|
837
759
|
targetPath.push(children.length);
|
|
838
760
|
}
|
|
839
761
|
// 如果是上,位置不变,下插入到下一个兄弟节点
|
|
@@ -1119,8 +1041,9 @@ function drawLink(board, parentNode, node, isHorizontal, needDrawUnderline, defa
|
|
|
1119
1041
|
: drawLogicLink(board, parentNode, node, isHorizontal, defaultStroke, defaultStrokeWidth);
|
|
1120
1042
|
}
|
|
1121
1043
|
|
|
1122
|
-
const drawFakeDragNode = (board,
|
|
1044
|
+
const drawFakeDragNode = (board, element, offsetX, offsetY) => {
|
|
1123
1045
|
var _a;
|
|
1046
|
+
const activeComponent = PlaitElement.getComponent(element);
|
|
1124
1047
|
const dragFakeNodeG = createG();
|
|
1125
1048
|
dragFakeNodeG.classList.add('dragging', 'fake-node', 'plait-board-attached');
|
|
1126
1049
|
const fakeDraggingNode = Object.assign(Object.assign({}, activeComponent.node), { children: [], x: activeComponent.node.x + offsetX, y: activeComponent.node.y + offsetY });
|
|
@@ -1130,14 +1053,22 @@ const drawFakeDragNode = (board, activeComponent, offsetX, offsetY) => {
|
|
|
1130
1053
|
updateForeignObject(richtextG, textRectangle.width, textRectangle.height, textRectangle.x + offsetX, textRectangle.y + offsetY);
|
|
1131
1054
|
dragFakeNodeG === null || dragFakeNodeG === void 0 ? void 0 : dragFakeNodeG.append(fakeNodeG);
|
|
1132
1055
|
dragFakeNodeG === null || dragFakeNodeG === void 0 ? void 0 : dragFakeNodeG.append(richtextG);
|
|
1056
|
+
// draw emojis
|
|
1057
|
+
if (MindElement.hasEmojis(element)) {
|
|
1058
|
+
const fakeEmojisG = activeComponent.emojisDrawer.g.cloneNode(true);
|
|
1059
|
+
const foreignRectangle = getEmojiForeignRectangle(board, element);
|
|
1060
|
+
updateForeignObject(fakeEmojisG, foreignRectangle.width, foreignRectangle.height, foreignRectangle.x + offsetX, foreignRectangle.y + offsetY);
|
|
1061
|
+
dragFakeNodeG === null || dragFakeNodeG === void 0 ? void 0 : dragFakeNodeG.append(fakeEmojisG);
|
|
1062
|
+
}
|
|
1133
1063
|
return dragFakeNodeG;
|
|
1134
1064
|
};
|
|
1135
|
-
const drawFakeDropNode = (board,
|
|
1065
|
+
const drawFakeDropNode = (board, dropTarget, path) => {
|
|
1066
|
+
const target = dropTarget.target;
|
|
1136
1067
|
const fakeDropNodeG = createG();
|
|
1137
1068
|
const parent = PlaitNode.get(board, Path.parent(path));
|
|
1138
1069
|
const layout = MindQueries.getLayoutByElement(parent);
|
|
1139
1070
|
const isHorizontal = isHorizontalLayout(layout);
|
|
1140
|
-
const { hasNextNode, hasPreviousNode } = hasPreviousOrNextOfDropPath(parent,
|
|
1071
|
+
const { hasNextNode, hasPreviousNode } = hasPreviousOrNextOfDropPath(parent, dropTarget, path);
|
|
1141
1072
|
const width = 30;
|
|
1142
1073
|
const height = 12;
|
|
1143
1074
|
let fakeNode, centerPoint, basicNode, linkDirection;
|
|
@@ -1146,6 +1077,16 @@ const drawFakeDropNode = (board, target, path) => {
|
|
|
1146
1077
|
const parentRect = getRectangleByNode(parentNode);
|
|
1147
1078
|
linkDirection = getLayoutDirection(parentNode, isHorizontal);
|
|
1148
1079
|
basicNode = parentNode;
|
|
1080
|
+
if (PlaitMind.isMind(target) && isStandardLayout(layout)) {
|
|
1081
|
+
if (dropTarget.detectResult === 'left') {
|
|
1082
|
+
linkDirection = LayoutDirection.left;
|
|
1083
|
+
basicNode.left = true;
|
|
1084
|
+
}
|
|
1085
|
+
else {
|
|
1086
|
+
linkDirection = LayoutDirection.right;
|
|
1087
|
+
basicNode.left = false;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1149
1090
|
const placement = [HorizontalPlacement.right, VerticalPlacement.middle];
|
|
1150
1091
|
transformPlacement(placement, linkDirection);
|
|
1151
1092
|
const parentCenterPoint = getPointByPlacement(parentRect, placement);
|
|
@@ -2796,7 +2737,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2796
2737
|
}
|
|
2797
2738
|
// interactive
|
|
2798
2739
|
fromEvent(collapseG, 'mouseup')
|
|
2799
|
-
.pipe(filter(() => !this.handActive ||
|
|
2740
|
+
.pipe(filter(() => !this.handActive || PlaitBoard.isReadonly(this.board)), take(1))
|
|
2800
2741
|
.subscribe(() => {
|
|
2801
2742
|
const isCollapsed = !this.node.origin.isCollapsed;
|
|
2802
2743
|
const newElement = { isCollapsed };
|
|
@@ -3231,7 +3172,7 @@ const withDnd = (board) => {
|
|
|
3231
3172
|
startPoint = point;
|
|
3232
3173
|
}
|
|
3233
3174
|
else if (isMultiple) {
|
|
3234
|
-
activeElements =
|
|
3175
|
+
activeElements = selectedElements;
|
|
3235
3176
|
startPoint = point;
|
|
3236
3177
|
}
|
|
3237
3178
|
}, node => {
|
|
@@ -3260,7 +3201,7 @@ const withDnd = (board) => {
|
|
|
3260
3201
|
dropTarget = detectDropTarget(board, detectPoint, dropTarget, [...activeElements, ...correspondingElements]);
|
|
3261
3202
|
if (dropTarget === null || dropTarget === void 0 ? void 0 : dropTarget.target) {
|
|
3262
3203
|
targetPath = getPathByDropTarget(board, dropTarget);
|
|
3263
|
-
fakeDropNodeG = drawFakeDropNode(board, dropTarget
|
|
3204
|
+
fakeDropNodeG = drawFakeDropNode(board, dropTarget, targetPath);
|
|
3264
3205
|
PlaitBoard.getHost(board).appendChild(fakeDropNodeG);
|
|
3265
3206
|
}
|
|
3266
3207
|
const offsetX = endPoint[0] - startPoint[0];
|
|
@@ -3269,27 +3210,29 @@ const withDnd = (board) => {
|
|
|
3269
3210
|
dragFakeNodeG = createG();
|
|
3270
3211
|
[...activeElements, ...correspondingElements].forEach(element => {
|
|
3271
3212
|
addActiveOnDragOrigin(element);
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
}
|
|
3213
|
+
});
|
|
3214
|
+
activeElements.forEach(element => {
|
|
3215
|
+
const nodeG = drawFakeDragNode(board, element, offsetX, offsetY);
|
|
3216
|
+
dragFakeNodeG === null || dragFakeNodeG === void 0 ? void 0 : dragFakeNodeG.appendChild(nodeG);
|
|
3277
3217
|
});
|
|
3278
3218
|
PlaitBoard.getHost(board).appendChild(dragFakeNodeG);
|
|
3279
3219
|
}
|
|
3280
3220
|
mousemove(event);
|
|
3281
3221
|
};
|
|
3282
3222
|
board.globalMouseup = (event) => {
|
|
3283
|
-
|
|
3284
|
-
|
|
3223
|
+
const firstLevelElements = getFirstLevelElement(activeElements);
|
|
3224
|
+
if (!board.options.readonly && firstLevelElements.length) {
|
|
3225
|
+
firstLevelElements.push(...correspondingElements);
|
|
3285
3226
|
if (isDragging(board)) {
|
|
3286
|
-
|
|
3227
|
+
firstLevelElements.forEach(element => {
|
|
3228
|
+
removeActiveOnDragOrigin(element);
|
|
3229
|
+
});
|
|
3287
3230
|
}
|
|
3288
3231
|
if (dropTarget) {
|
|
3289
3232
|
const targetPathRef = board.pathRef(targetPath);
|
|
3290
3233
|
const targetElementPathRef = board.pathRef(PlaitBoard.findPath(board, dropTarget.target));
|
|
3291
|
-
|
|
3292
|
-
const normalElements =
|
|
3234
|
+
let abstractRefs = getValidAbstractRefs(board, firstLevelElements);
|
|
3235
|
+
const normalElements = firstLevelElements
|
|
3293
3236
|
.filter(element => !abstractRefs.some(refs => refs.abstract === element))
|
|
3294
3237
|
.map(element => {
|
|
3295
3238
|
if (AbstractNode.isAbstract(element)) {
|
|
@@ -3300,18 +3243,30 @@ const withDnd = (board) => {
|
|
|
3300
3243
|
}
|
|
3301
3244
|
return element;
|
|
3302
3245
|
});
|
|
3303
|
-
const
|
|
3246
|
+
const hasPreviousNode = targetPath[targetPath.length - 1] !== 0;
|
|
3247
|
+
if (hasPreviousNode) {
|
|
3248
|
+
const previousElement = PlaitNode.get(board, Path.previous(targetPath));
|
|
3249
|
+
const correspondingAbstract = getCorrespondingAbstract(previousElement);
|
|
3250
|
+
const targetHasCorrespondAbstract = correspondingAbstract && correspondingAbstract.end !== targetPath[targetPath.length - 1] - 1;
|
|
3251
|
+
if (targetHasCorrespondAbstract) {
|
|
3252
|
+
const adjustedNode = abstractRefs.map(ref => {
|
|
3253
|
+
return adjustAbstractToNode(ref.abstract);
|
|
3254
|
+
});
|
|
3255
|
+
normalElements.push(...adjustedNode);
|
|
3256
|
+
abstractRefs = [];
|
|
3257
|
+
}
|
|
3258
|
+
}
|
|
3259
|
+
const effectedAbstracts = deleteElementHandleAbstract(board, firstLevelElements);
|
|
3304
3260
|
insertElementHandleAbstract(board, targetPath, normalElements.length, false, effectedAbstracts);
|
|
3305
3261
|
MindTransforms.setAbstractsByRefs(board, effectedAbstracts);
|
|
3306
|
-
let refs = deleteElementsHandleRightNodeCount(board,
|
|
3307
|
-
const
|
|
3308
|
-
|
|
3309
|
-
(Path.isSibling(targetPath, targetElementPathRef.current) || Path.equals(targetPath, targetElementPathRef.current));
|
|
3262
|
+
let refs = deleteElementsHandleRightNodeCount(board, firstLevelElements);
|
|
3263
|
+
const parent = PlaitNode.get(board, Path.parent(targetPath));
|
|
3264
|
+
const shouldChangeRoot = isDropStandardRight(parent, dropTarget);
|
|
3310
3265
|
if (shouldChangeRoot && targetElementPathRef.current) {
|
|
3311
3266
|
refs = insertElementHandleRightNodeCount(board, targetElementPathRef.current.slice(0, 1), normalElements.length, refs);
|
|
3312
3267
|
}
|
|
3313
3268
|
MindTransforms.setRightNodeCountByRefs(board, refs);
|
|
3314
|
-
MindTransforms.removeElements(board,
|
|
3269
|
+
MindTransforms.removeElements(board, firstLevelElements);
|
|
3315
3270
|
let insertPath = targetPathRef.current;
|
|
3316
3271
|
const parentPath = Path.parent(targetPathRef.current || targetPath);
|
|
3317
3272
|
if (!insertPath) {
|
|
@@ -3571,8 +3526,20 @@ const withMindExtend = (board) => {
|
|
|
3571
3526
|
const DefaultHotkey = 'm';
|
|
3572
3527
|
const withCreateMind = (board) => {
|
|
3573
3528
|
const newBoard = board;
|
|
3574
|
-
const { keydown, mousemove, mouseup } = board;
|
|
3529
|
+
const { keydown, mousedown, mousemove, mouseup } = board;
|
|
3575
3530
|
let fakeCreateNodeRef = null;
|
|
3531
|
+
newBoard.mousedown = (event) => {
|
|
3532
|
+
if (fakeCreateNodeRef && PlaitBoard.isPointer(board, MindPointerType.mind)) {
|
|
3533
|
+
const currentOptions = board.getPluginOptions(PlaitPluginKey.withSelection);
|
|
3534
|
+
board.setPluginOptions(PlaitPluginKey.withSelection, {
|
|
3535
|
+
isDisabledSelect: true
|
|
3536
|
+
});
|
|
3537
|
+
setTimeout(() => {
|
|
3538
|
+
board.setPluginOptions(PlaitPluginKey.withSelection, Object.assign({}, currentOptions));
|
|
3539
|
+
}, 0);
|
|
3540
|
+
}
|
|
3541
|
+
mousedown(event);
|
|
3542
|
+
};
|
|
3576
3543
|
newBoard.mousemove = (event) => {
|
|
3577
3544
|
if (PlaitBoard.isReadonly(board)) {
|
|
3578
3545
|
mousemove(event);
|
|
@@ -3672,12 +3639,9 @@ const withMind = (board) => {
|
|
|
3672
3639
|
return isRecursion(element);
|
|
3673
3640
|
};
|
|
3674
3641
|
board.isHitSelection = (element, range) => {
|
|
3675
|
-
if (MindElement.isMindElement(board, element)
|
|
3642
|
+
if (MindElement.isMindElement(board, element)) {
|
|
3676
3643
|
const client = getRectangleByNode(MindElement.getNode(element));
|
|
3677
3644
|
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
3645
|
return isHit;
|
|
3682
3646
|
}
|
|
3683
3647
|
return isHitSelection(element, range);
|
|
@@ -3846,6 +3810,15 @@ class MindEmojiBaseComponent {
|
|
|
3846
3810
|
get nativeElement() {
|
|
3847
3811
|
return this.elementRef.nativeElement;
|
|
3848
3812
|
}
|
|
3813
|
+
handleClick() {
|
|
3814
|
+
const currentOptions = this.board.getPluginOptions(PlaitPluginKey.withSelection);
|
|
3815
|
+
this.board.setPluginOptions(PlaitPluginKey.withSelection, {
|
|
3816
|
+
isDisabledSelect: true
|
|
3817
|
+
});
|
|
3818
|
+
setTimeout(() => {
|
|
3819
|
+
this.board.setPluginOptions(PlaitPluginKey.withSelection, Object.assign({}, currentOptions));
|
|
3820
|
+
}, 0);
|
|
3821
|
+
}
|
|
3849
3822
|
constructor(elementRef) {
|
|
3850
3823
|
this.elementRef = elementRef;
|
|
3851
3824
|
this.fontSize = 14;
|
|
@@ -3855,7 +3828,7 @@ class MindEmojiBaseComponent {
|
|
|
3855
3828
|
}
|
|
3856
3829
|
}
|
|
3857
3830
|
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 });
|
|
3831
|
+
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
3832
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImport: i0, type: MindEmojiBaseComponent, decorators: [{
|
|
3860
3833
|
type: Directive,
|
|
3861
3834
|
args: [{
|
|
@@ -3871,6 +3844,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
3871
3844
|
type: Input
|
|
3872
3845
|
}], element: [{
|
|
3873
3846
|
type: Input
|
|
3847
|
+
}], handleClick: [{
|
|
3848
|
+
type: HostListener,
|
|
3849
|
+
args: ['mousedown']
|
|
3874
3850
|
}] } });
|
|
3875
3851
|
|
|
3876
3852
|
/*
|
|
@@ -3881,5 +3857,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
3881
3857
|
* Generated bundle index. Do not edit.
|
|
3882
3858
|
*/
|
|
3883
3859
|
|
|
3884
|
-
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_COLORS, BRANCH_WIDTH, BaseDrawer, BranchShape, DefaultAbstractNodeStyle, DefaultNodeStyle, DefaultRootStyle, ELEMENT_TO_NODE, EXTEND_OFFSET, EXTEND_RADIUS, GRAY_COLOR, IS_DRAGGING, LayoutDirection, LayoutDirectionsMap, MindElement, MindElementShape, MindEmojiBaseComponent, MindModule, MindNode, MindNodeComponent, MindPointerType, MindQueries, 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, getNextBranchColor, getOverallAbstracts, getPathByDropTarget, getRectangleByElement, getRectangleByNode, getRectangleByResizingLocation, getRelativeStartEndByAbstractRef, getRootLayout, getShapeByElement, getStrokeByMindElement, getTopicRectangleByElement, getTopicRectangleByNode, getValidAbstractRefs, handleTouchedAbstract, hasAfterDraw, hasPreviousOrNextOfDropPath, insertElementHandleAbstract, insertElementHandleRightNodeCount, insertMindElement, isChildElement, isChildRight, isChildUp, isCorrectLayout, isDragging, isHitEmojis, isHitMindElement, isInRightBranchOfStandardLayout, isMixedLayout, isSetAbstract, isValidTarget, isVirtualKey,
|
|
3860
|
+
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_COLORS, BRANCH_WIDTH, BaseDrawer, BranchShape, DefaultAbstractNodeStyle, DefaultNodeStyle, DefaultRootStyle, ELEMENT_TO_NODE, EXTEND_OFFSET, EXTEND_RADIUS, GRAY_COLOR, IS_DRAGGING, LayoutDirection, LayoutDirectionsMap, MindElement, MindElementShape, MindEmojiBaseComponent, MindModule, MindNode, MindNodeComponent, MindPointerType, MindQueries, 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, 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
3861
|
//# sourceMappingURL=plait-mind.mjs.map
|