@plait/mind 0.2.0-next.9 → 0.2.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/draw/richtext.d.ts +1 -1
- package/esm2020/draw/indented-link.mjs +3 -3
- package/esm2020/draw/link/logic-link.mjs +6 -4
- package/esm2020/draw/link.mjs +4 -4
- package/esm2020/draw/richtext.mjs +10 -8
- package/esm2020/draw/shape.mjs +2 -2
- package/esm2020/drawer/quick-insert.drawer.mjs +3 -3
- package/esm2020/interfaces/element.mjs +15 -1
- package/esm2020/interfaces/node.mjs +1 -10
- package/esm2020/node.component.mjs +34 -27
- package/esm2020/plugins/emoji/emoji.drawer.mjs +4 -8
- package/esm2020/plugins/emoji/emoji.mjs +31 -3
- package/esm2020/plugins/with-dnd.mjs +14 -9
- package/esm2020/plugins/with-mind.mjs +33 -27
- package/esm2020/queries/get-available-sublayouts-by-element.mjs +3 -3
- package/esm2020/queries/get-branch-layouts.mjs +4 -4
- package/esm2020/queries/get-layout-by-element.mjs +4 -4
- package/esm2020/transforms/abstract-node.mjs +3 -3
- package/esm2020/utils/dnd.mjs +9 -5
- package/esm2020/utils/draw-placeholder.mjs +7 -5
- package/esm2020/utils/index.mjs +1 -2
- package/esm2020/utils/mind.mjs +9 -16
- package/esm2020/utils/node-space.mjs +23 -18
- package/esm2020/utils/node-style/branch.mjs +14 -27
- package/esm2020/utils/node-style/common.mjs +13 -0
- package/esm2020/utils/node-style/index.mjs +3 -2
- package/esm2020/utils/node-style/shape.mjs +21 -0
- package/fesm2015/plait-mind.mjs +205 -172
- package/fesm2015/plait-mind.mjs.map +1 -1
- package/fesm2020/plait-mind.mjs +205 -171
- package/fesm2020/plait-mind.mjs.map +1 -1
- package/interfaces/element.d.ts +2 -0
- package/interfaces/node.d.ts +0 -1
- package/node.component.d.ts +0 -1
- package/package.json +1 -1
- package/plugins/emoji/emoji.d.ts +5 -1
- package/styles/styles.scss +19 -19
- package/utils/index.d.ts +0 -1
- package/utils/mind.d.ts +1 -2
- package/utils/node-space.d.ts +5 -4
- package/utils/node-style/branch.d.ts +4 -2
- package/utils/node-style/common.d.ts +3 -0
- package/utils/node-style/index.d.ts +2 -1
- package/utils/node-style/shape.d.ts +4 -0
- package/esm2020/utils/node-style/node.mjs +0 -23
- package/esm2020/utils/shape.mjs +0 -17
- package/utils/node-style/node.d.ts +0 -3
- package/utils/shape.d.ts +0 -2
package/fesm2020/plait-mind.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Component, ChangeDetectionStrategy, NgModule, Directive, Input } from '@angular/core';
|
|
3
3
|
import * as i2 from '@plait/core';
|
|
4
|
-
import { distanceBetweenPointAndRectangle, PlaitBoard, PlaitNode, NODE_TO_PARENT, Path, ELEMENT_TO_COMPONENT, PlaitElement, Transforms, idCreator, isNullOrUndefined, clearSelectedElement, addSelectedElement, drawRoundRectangle, getRectangleByElements, RectangleClient, getSelectedElements, createG, drawAbstractRoundRectangle, PlaitPluginElementComponent, PlaitPointerType, NODE_TO_INDEX, createText, IS_TEXT_EDITABLE, MERGING, transformPoint, toPoint, depthFirstRecursion, PlaitModule, distanceBetweenPointAndPoint, CLIP_BOARD_FORMAT_KEY, BOARD_TO_HOST, removeSelectedElement, PlaitHistoryBoard, hotkeys } from '@plait/core';
|
|
4
|
+
import { distanceBetweenPointAndRectangle, PlaitBoard, PlaitNode, NODE_TO_PARENT, Path, ELEMENT_TO_COMPONENT, PlaitElement, Transforms, idCreator, isNullOrUndefined, clearSelectedElement, addSelectedElement, drawRoundRectangle, getRectangleByElements, RectangleClient, getSelectedElements, createG, drawAbstractRoundRectangle, PlaitPluginElementComponent, PlaitPointerType, NODE_TO_INDEX, createText, IS_TEXT_EDITABLE, MERGING, transformPoint, toPoint, depthFirstRecursion, PlaitModule, distanceBetweenPointAndPoint, updateForeignObject as updateForeignObject$1, CLIP_BOARD_FORMAT_KEY, BOARD_TO_HOST, Selection, removeSelectedElement, PlaitHistoryBoard, hotkeys } from '@plait/core';
|
|
5
5
|
import { MindLayoutType, AbstractNode, getAbstractLayout, isIndentedLayout, isStandardLayout, isHorizontalLogicLayout, isVerticalLogicLayout, isTopLayout, isLeftLayout, isBottomLayout, isRightLayout, isHorizontalLayout, getNonAbstractChildren, getCorrectStartEnd, ConnectingPosition, GlobalLayout } from '@plait/layouts';
|
|
6
6
|
import { getSizeByText, ROOT_DEFAULT_HEIGHT, TEXT_DEFAULT_HEIGHT, drawRichtext, updateForeignObject, createForeignObject, updateRichText, setFullSelectionAndFocus, getRichtextContentSize, hasEditableTarget, RichtextModule } from '@plait/richtext';
|
|
7
7
|
import { fromEvent, Subject, timer } from 'rxjs';
|
|
@@ -129,18 +129,18 @@ const getBranchLayouts = (board, element) => {
|
|
|
129
129
|
// TODO: getCorrectLayoutByElement 含有递归操作,getBranchLayouts 本身也有递归操作,有待优化
|
|
130
130
|
layouts.unshift(getCorrectLayoutByElement(board, element));
|
|
131
131
|
}
|
|
132
|
-
let parent =
|
|
132
|
+
let parent = MindElement.findParent(element);
|
|
133
133
|
while (parent) {
|
|
134
134
|
if (parent.layout) {
|
|
135
135
|
layouts.unshift(parent.layout);
|
|
136
136
|
}
|
|
137
|
-
parent =
|
|
137
|
+
parent = MindElement.findParent(parent);
|
|
138
138
|
}
|
|
139
139
|
return layouts;
|
|
140
140
|
};
|
|
141
141
|
|
|
142
142
|
const getAvailableSubLayoutsByElement = (board, element) => {
|
|
143
|
-
const parentElement =
|
|
143
|
+
const parentElement = MindElement.findParent(element);
|
|
144
144
|
if (parentElement) {
|
|
145
145
|
const branchLayouts = getBranchLayouts(board, parentElement);
|
|
146
146
|
if (branchLayouts[0] === MindLayoutType.standard) {
|
|
@@ -266,8 +266,8 @@ const getLayoutByElement = (element) => {
|
|
|
266
266
|
if (layout) {
|
|
267
267
|
return layout;
|
|
268
268
|
}
|
|
269
|
-
const parent = MindElement.getParent(element);
|
|
270
|
-
if (AbstractNode.isAbstract(element)) {
|
|
269
|
+
const parent = !PlaitMind.isMind(element) && MindElement.getParent(element);
|
|
270
|
+
if (AbstractNode.isAbstract(element) && parent) {
|
|
271
271
|
return getAbstractLayout(getLayoutByElement(parent));
|
|
272
272
|
}
|
|
273
273
|
if (parent) {
|
|
@@ -314,6 +314,13 @@ const MindElement = {
|
|
|
314
314
|
const parent = NODE_TO_PARENT.get(node);
|
|
315
315
|
return parent;
|
|
316
316
|
},
|
|
317
|
+
findParent(node) {
|
|
318
|
+
if (PlaitMind.isMind(node)) {
|
|
319
|
+
return undefined;
|
|
320
|
+
}
|
|
321
|
+
const parent = NODE_TO_PARENT.get(node);
|
|
322
|
+
return parent;
|
|
323
|
+
},
|
|
317
324
|
getRoot(board, element) {
|
|
318
325
|
const path = PlaitBoard.findPath(board, element);
|
|
319
326
|
return PlaitNode.get(board, path.slice(0, 1));
|
|
@@ -336,6 +343,13 @@ const MindElement = {
|
|
|
336
343
|
}
|
|
337
344
|
return node;
|
|
338
345
|
},
|
|
346
|
+
findParentNode(element) {
|
|
347
|
+
if (PlaitMind.isMind(element)) {
|
|
348
|
+
return undefined;
|
|
349
|
+
}
|
|
350
|
+
const parent = MindElement.getParent(element);
|
|
351
|
+
return MindElement.getNode(parent);
|
|
352
|
+
},
|
|
339
353
|
hasEmojis(element) {
|
|
340
354
|
if (element.data.emojis) {
|
|
341
355
|
return true;
|
|
@@ -365,15 +379,6 @@ const MindNode = {
|
|
|
365
379
|
node = node.children[p];
|
|
366
380
|
}
|
|
367
381
|
return node;
|
|
368
|
-
},
|
|
369
|
-
isEquals(node, otherNode) {
|
|
370
|
-
const hasSameSize = node.x === otherNode.x && node.y === otherNode.y && node.width === otherNode.width && node.height === otherNode.height;
|
|
371
|
-
const hasSameOrigin = node.origin === otherNode.origin;
|
|
372
|
-
let hasSameParentOriginChildren = false;
|
|
373
|
-
if (node.parent && otherNode.parent) {
|
|
374
|
-
hasSameParentOriginChildren = node.parent.origin.children == otherNode.parent.origin.children;
|
|
375
|
-
}
|
|
376
|
-
return hasSameSize && hasSameOrigin && hasSameParentOriginChildren;
|
|
377
382
|
}
|
|
378
383
|
};
|
|
379
384
|
|
|
@@ -566,7 +571,7 @@ const setAbstractByStandardLayout = (board, element) => {
|
|
|
566
571
|
}
|
|
567
572
|
};
|
|
568
573
|
const insertAbstract = (board, elements) => {
|
|
569
|
-
let elementGroup =
|
|
574
|
+
let elementGroup = getFirstLevelElement(elements);
|
|
570
575
|
const { parentElements, abstractIncludedGroups } = divideElementByParent(elementGroup);
|
|
571
576
|
abstractIncludedGroups.forEach((group, index) => {
|
|
572
577
|
const groupParent = parentElements[index];
|
|
@@ -698,21 +703,14 @@ const MindTransforms = {
|
|
|
698
703
|
setAbstractByStandardLayout
|
|
699
704
|
};
|
|
700
705
|
|
|
701
|
-
function findParentElement(element) {
|
|
702
|
-
const component = PlaitElement.getComponent(element);
|
|
703
|
-
if (component && component.parent) {
|
|
704
|
-
return component.parent.origin;
|
|
705
|
-
}
|
|
706
|
-
return undefined;
|
|
707
|
-
}
|
|
708
706
|
function findUpElement(element) {
|
|
709
707
|
let branch;
|
|
710
708
|
let root = element;
|
|
711
|
-
let parent =
|
|
709
|
+
let parent = MindElement.findParent(element);
|
|
712
710
|
while (parent) {
|
|
713
711
|
branch = root;
|
|
714
712
|
root = parent;
|
|
715
|
-
parent =
|
|
713
|
+
parent = MindElement.findParent(parent);
|
|
716
714
|
}
|
|
717
715
|
return { root, branch };
|
|
718
716
|
}
|
|
@@ -723,16 +721,16 @@ const getChildrenCount = (element) => {
|
|
|
723
721
|
return count + element.children.length;
|
|
724
722
|
};
|
|
725
723
|
const isChildElement = (origin, child) => {
|
|
726
|
-
let parent =
|
|
724
|
+
let parent = MindElement.findParent(child);
|
|
727
725
|
while (parent) {
|
|
728
726
|
if (parent === origin) {
|
|
729
727
|
return true;
|
|
730
728
|
}
|
|
731
|
-
parent =
|
|
729
|
+
parent = MindElement.findParent(parent);
|
|
732
730
|
}
|
|
733
731
|
return false;
|
|
734
732
|
};
|
|
735
|
-
const
|
|
733
|
+
const getFirstLevelElement = (elements) => {
|
|
736
734
|
let result = [];
|
|
737
735
|
elements.forEach(element => {
|
|
738
736
|
const isChild = elements.some(node => {
|
|
@@ -822,7 +820,7 @@ const changeRightNodeCount = (board, parentPath, changeNumber) => {
|
|
|
822
820
|
}, parentPath);
|
|
823
821
|
};
|
|
824
822
|
const shouldChangeRightNodeCount = (selectedElement) => {
|
|
825
|
-
const parentElement =
|
|
823
|
+
const parentElement = MindElement.findParent(selectedElement);
|
|
826
824
|
if (parentElement) {
|
|
827
825
|
const nodeIndex = parentElement.children.findIndex(item => item.id === selectedElement.id);
|
|
828
826
|
if (parentElement.isRoot &&
|
|
@@ -908,7 +906,7 @@ const findLastChild = (child) => {
|
|
|
908
906
|
return result;
|
|
909
907
|
};
|
|
910
908
|
const deleteSelectedELements = (board, selectedElements) => {
|
|
911
|
-
const deletableElements =
|
|
909
|
+
const deletableElements = getFirstLevelElement(selectedElements).reverse();
|
|
912
910
|
const abstractRefs = deleteElementHandleAbstract(board, deletableElements);
|
|
913
911
|
MindTransforms.setAbstractsByRefs(board, abstractRefs);
|
|
914
912
|
//翻转,从下到上修改,防止找不到 path
|
|
@@ -943,51 +941,28 @@ const divideElementByParent = (elements) => {
|
|
|
943
941
|
return { parentElements, abstractIncludedGroups };
|
|
944
942
|
};
|
|
945
943
|
|
|
946
|
-
const
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
944
|
+
const getAvailableProperty = (board, element, propertyKey) => {
|
|
945
|
+
const ancestors = MindElement.getAncestors(board, element);
|
|
946
|
+
ancestors.unshift(element);
|
|
947
|
+
const ancestor = ancestors.find(value => value[propertyKey]);
|
|
948
|
+
if (ancestor) {
|
|
949
|
+
return ancestor[propertyKey];
|
|
950
950
|
}
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
if (parent.shape) {
|
|
954
|
-
return parent.shape;
|
|
955
|
-
}
|
|
956
|
-
parent = findParentElement(parent);
|
|
951
|
+
else {
|
|
952
|
+
return undefined;
|
|
957
953
|
}
|
|
958
|
-
return MindElementShape.roundRectangle;
|
|
959
954
|
};
|
|
960
955
|
|
|
961
956
|
/**
|
|
962
957
|
* Processing of branch color, width, style, etc. of the mind node
|
|
963
958
|
*/
|
|
964
959
|
const getBranchColorByMindElement = (board, element) => {
|
|
965
|
-
const
|
|
966
|
-
|
|
967
|
-
const ancestor = ancestors.find(value => value.branchColor);
|
|
968
|
-
if (ancestor && ancestor.branchColor) {
|
|
969
|
-
return ancestor.branchColor;
|
|
970
|
-
}
|
|
971
|
-
const root = ancestors[ancestors.length - 1];
|
|
972
|
-
const branch = ancestors[ancestors.length - 2];
|
|
973
|
-
if (branch) {
|
|
974
|
-
const index = root.children.indexOf(branch);
|
|
975
|
-
const length = BRANCH_COLORS.length;
|
|
976
|
-
const remainder = index % length;
|
|
977
|
-
return BRANCH_COLORS[remainder];
|
|
978
|
-
}
|
|
979
|
-
else {
|
|
980
|
-
throw new Error('root element should not have branch color');
|
|
981
|
-
}
|
|
960
|
+
const branchColor = getAvailableProperty(board, element, 'branchColor');
|
|
961
|
+
return branchColor || getDefaultBranchColor(board, element);
|
|
982
962
|
};
|
|
983
963
|
const getBranchWidthByMindElement = (board, element) => {
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
const ancestor = ancestors.find(value => value.branchColor);
|
|
987
|
-
if (ancestor && ancestor.branchWidth) {
|
|
988
|
-
return ancestor.branchWidth;
|
|
989
|
-
}
|
|
990
|
-
return BRANCH_WIDTH;
|
|
964
|
+
const branchWidth = getAvailableProperty(board, element, 'branchWidth');
|
|
965
|
+
return branchWidth || BRANCH_WIDTH;
|
|
991
966
|
};
|
|
992
967
|
const getAbstractBranchWidth = (board, element) => {
|
|
993
968
|
if (!isNullOrUndefined(element.branchWidth)) {
|
|
@@ -1003,29 +978,33 @@ const getAbstractBranchColor = (board, element) => {
|
|
|
1003
978
|
};
|
|
1004
979
|
const getNextBranchColor = (root) => {
|
|
1005
980
|
const index = root.children.length;
|
|
981
|
+
return getDefaultBranchColorByIndex(index);
|
|
982
|
+
};
|
|
983
|
+
const getDefaultBranchColor = (board, element) => {
|
|
984
|
+
const path = PlaitBoard.findPath(board, element);
|
|
985
|
+
return getDefaultBranchColorByIndex(path[1]);
|
|
986
|
+
};
|
|
987
|
+
const getDefaultBranchColorByIndex = (index) => {
|
|
1006
988
|
const length = BRANCH_COLORS.length;
|
|
1007
989
|
const remainder = index % length;
|
|
1008
990
|
return BRANCH_COLORS[remainder];
|
|
1009
991
|
};
|
|
1010
992
|
|
|
1011
993
|
const getStrokeByMindElement = (board, element) => {
|
|
994
|
+
if (PlaitMind.isMind(element)) {
|
|
995
|
+
return element.strokeColor || DefaultRootStyle.strokeColor;
|
|
996
|
+
}
|
|
1012
997
|
const ancestors = MindElement.getAncestors(board, element);
|
|
1013
998
|
ancestors.unshift(element);
|
|
1014
999
|
const ancestor = ancestors.find(value => value.strokeColor);
|
|
1015
|
-
if (ancestor && ancestor.strokeColor) {
|
|
1000
|
+
if (ancestor && ancestor.strokeColor && !PlaitMind.isMind(ancestor)) {
|
|
1016
1001
|
return ancestor.strokeColor;
|
|
1017
1002
|
}
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
const remainder = index % length;
|
|
1024
|
-
return BRANCH_COLORS[remainder];
|
|
1025
|
-
}
|
|
1026
|
-
else {
|
|
1027
|
-
return DefaultRootStyle.strokeColor;
|
|
1028
|
-
}
|
|
1003
|
+
return getDefaultBranchColor(board, element);
|
|
1004
|
+
};
|
|
1005
|
+
const getShapeByElement = (board, element) => {
|
|
1006
|
+
const shape = getAvailableProperty(board, element, 'shape');
|
|
1007
|
+
return shape || MindElementShape.roundRectangle;
|
|
1029
1008
|
};
|
|
1030
1009
|
|
|
1031
1010
|
function isVirtualKey(e) {
|
|
@@ -1054,7 +1033,7 @@ function drawLink(board, node, child, defaultStroke = null, isHorizontal = true,
|
|
|
1054
1033
|
endY = endNode.y + endNode.height / 2;
|
|
1055
1034
|
if (node.parent &&
|
|
1056
1035
|
isIndentedLayout(MindQueries.getLayoutByElement(node.parent?.origin)) &&
|
|
1057
|
-
|
|
1036
|
+
getShapeByElement(board, node.origin) === MindElementShape.underline) {
|
|
1058
1037
|
if (isChildRight(node, child)) {
|
|
1059
1038
|
beginY = node.y + node.height - node.vGap;
|
|
1060
1039
|
}
|
|
@@ -1098,7 +1077,7 @@ function drawLink(board, node, child, defaultStroke = null, isHorizontal = true,
|
|
|
1098
1077
|
[endX - (beginNode.hGap + endNode.hGap) / 2, endY],
|
|
1099
1078
|
[endX, endY]
|
|
1100
1079
|
];
|
|
1101
|
-
const shape =
|
|
1080
|
+
const shape = getShapeByElement(board, child.origin);
|
|
1102
1081
|
if (!node.origin.isRoot) {
|
|
1103
1082
|
if (node.x > child.x) {
|
|
1104
1083
|
curve = [
|
|
@@ -1198,8 +1177,9 @@ const drawPlaceholderDropNodeG = (board, dropTarget, fakeDropNodeG) => {
|
|
|
1198
1177
|
if (dropTarget.detectResult && ['right', 'left'].includes(dropTarget.detectResult)) {
|
|
1199
1178
|
drawStraightDropNodeG(board, targetRect, dropTarget.detectResult, targetComponent, fakeDropNodeG);
|
|
1200
1179
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1180
|
+
const targetParent = MindElement.findParent(targetComponent.element);
|
|
1181
|
+
if (targetParent && dropTarget.detectResult && ['top', 'bottom'].includes(dropTarget.detectResult)) {
|
|
1182
|
+
const parentComponent = PlaitElement.getComponent(targetParent);
|
|
1203
1183
|
const targetIndex = parentComponent.node.origin.children.indexOf(targetComponent.node.origin);
|
|
1204
1184
|
drawCurvePlaceholderDropNodeG(board, targetRect, dropTarget.detectResult, targetIndex, targetComponent, parentComponent, fakeDropNodeG);
|
|
1205
1185
|
}
|
|
@@ -1241,7 +1221,7 @@ const drawCurvePlaceholderDropNodeG = (board, targetRect, detectResult, targetIn
|
|
|
1241
1221
|
}
|
|
1242
1222
|
if (isVerticalLogicLayout(layout)) {
|
|
1243
1223
|
parentComponent = targetComponent;
|
|
1244
|
-
targetComponent = PlaitElement.getComponent(targetComponent.
|
|
1224
|
+
targetComponent = PlaitElement.getComponent(MindElement.getParent(targetComponent.element));
|
|
1245
1225
|
fakeX = parentComponent.node.x;
|
|
1246
1226
|
width = parentComponent.node.width;
|
|
1247
1227
|
const vGap = BASE * 6 + strokeWidth;
|
|
@@ -1362,7 +1342,7 @@ const drawStraightDropNodeG = (board, targetRect, detectResult, targetComponent,
|
|
|
1362
1342
|
* b. 最后一个节点的右侧:固定值(来源于 getMainAxle,第二级节点:BASE * 8,其他 BASE * 3 + strokeWidth / 2);
|
|
1363
1343
|
*/
|
|
1364
1344
|
fakeY = targetComponent.node.y;
|
|
1365
|
-
const parentComponent = PlaitElement.getComponent(targetComponent.
|
|
1345
|
+
const parentComponent = PlaitElement.getComponent(MindElement.getParent(targetComponent.element));
|
|
1366
1346
|
const targetIndex = parentComponent.node.origin.children.indexOf(targetComponent.node.origin);
|
|
1367
1347
|
if (detectResult === 'left') {
|
|
1368
1348
|
let offsetX = 0;
|
|
@@ -1872,7 +1852,7 @@ function handleTouchedAbstract(board, touchedAbstract, endPoint) {
|
|
|
1872
1852
|
function drawIndentedLink(board, node, child, defaultStroke = null, needDrawUnderline = true) {
|
|
1873
1853
|
const branchWidth = getBranchWidthByMindElement(board, child.origin);
|
|
1874
1854
|
const branchColor = defaultStroke || getBranchColorByMindElement(board, child.origin);
|
|
1875
|
-
const isUnderlineShape =
|
|
1855
|
+
const isUnderlineShape = getShapeByElement(board, child.origin) === MindElementShape.underline;
|
|
1876
1856
|
let beginX, beginY, endX, endY, beginNode = node, endNode = child;
|
|
1877
1857
|
const beginRectangle = getRectangleByNode(beginNode);
|
|
1878
1858
|
const endRectangle = getRectangleByNode(endNode);
|
|
@@ -2021,8 +2001,10 @@ function drawLogicLink(board, node, parent, isHorizontal) {
|
|
|
2021
2001
|
const branchColor = getBranchColorByMindElement(board, node.origin);
|
|
2022
2002
|
const branchWidth = getBranchWidthByMindElement(board, node.origin);
|
|
2023
2003
|
const hasStraightLine = !parent.origin.isRoot;
|
|
2024
|
-
const
|
|
2025
|
-
const
|
|
2004
|
+
const parentShape = getShapeByElement(board, parent.origin);
|
|
2005
|
+
const shape = node.origin.shape ? node.origin.shape : parentShape;
|
|
2006
|
+
const hasUnderlineShape = shape === MindElementShape.underline;
|
|
2007
|
+
const hasUnderlineShapeOfParent = parentShape === MindElementShape.underline;
|
|
2026
2008
|
const nodeClient = getRectangleByNode(node);
|
|
2027
2009
|
const parentClient = getRectangleByNode(parent);
|
|
2028
2010
|
const linkDirection = getLayoutDirection(node, isHorizontal);
|
|
@@ -2062,7 +2044,7 @@ function drawLogicLink(board, node, parent, isHorizontal) {
|
|
|
2062
2044
|
return PlaitBoard.getRoughSVG(board).curve(points, { stroke: branchColor, strokeWidth: branchWidth });
|
|
2063
2045
|
}
|
|
2064
2046
|
|
|
2065
|
-
function
|
|
2047
|
+
function getEmojisWidthHeight(board, element) {
|
|
2066
2048
|
const options = board.getMindOptions();
|
|
2067
2049
|
const count = element.data.emojis.length;
|
|
2068
2050
|
const fontSize = getEmojiFontSize(element);
|
|
@@ -2079,6 +2061,31 @@ function getEmojiFontSize(element) {
|
|
|
2079
2061
|
return 14 + 2;
|
|
2080
2062
|
}
|
|
2081
2063
|
}
|
|
2064
|
+
function getEmojiRectangle(board, element) {
|
|
2065
|
+
let { x, y } = getRectangleByNode(MindElement.getNode(element));
|
|
2066
|
+
x = x + NodeSpace.getEmojiLeftSpace(board, element);
|
|
2067
|
+
const { width, height } = getEmojisWidthHeight(board, element);
|
|
2068
|
+
return {
|
|
2069
|
+
x,
|
|
2070
|
+
y,
|
|
2071
|
+
width,
|
|
2072
|
+
height
|
|
2073
|
+
};
|
|
2074
|
+
}
|
|
2075
|
+
function getEmojiForeignRectangle(board, element) {
|
|
2076
|
+
let { x, y } = getRectangleByNode(MindElement.getNode(element));
|
|
2077
|
+
x = x + NodeSpace.getEmojiLeftSpace(board, element);
|
|
2078
|
+
const { width, height } = getEmojisWidthHeight(board, element);
|
|
2079
|
+
return {
|
|
2080
|
+
x,
|
|
2081
|
+
y,
|
|
2082
|
+
width,
|
|
2083
|
+
height: height + NodeSpace.getEmojiTopSpace(element) * 2
|
|
2084
|
+
};
|
|
2085
|
+
}
|
|
2086
|
+
const isHitEmojis = (board, element, point) => {
|
|
2087
|
+
return RectangleClient.isHit(RectangleClient.toRectangleClient([point, point]), getEmojiRectangle(board, element));
|
|
2088
|
+
};
|
|
2082
2089
|
|
|
2083
2090
|
const NodeDefaultSpace = {
|
|
2084
2091
|
horizontal: {
|
|
@@ -2098,26 +2105,30 @@ const RootDefaultSpace = {
|
|
|
2098
2105
|
nodeAndText: BASE * 2
|
|
2099
2106
|
}
|
|
2100
2107
|
};
|
|
2101
|
-
const getHorizontalSpaceBetweenNodeAndText = (element) => {
|
|
2108
|
+
const getHorizontalSpaceBetweenNodeAndText = (board, element) => {
|
|
2102
2109
|
const isMind = PlaitMind.isMind(element);
|
|
2103
2110
|
const nodeAndText = isMind ? RootDefaultSpace.horizontal.nodeAndText : NodeDefaultSpace.horizontal.nodeAndText;
|
|
2104
2111
|
return nodeAndText;
|
|
2105
2112
|
};
|
|
2106
|
-
const getHorizontalSpaceEmojiAndText = (element) => {
|
|
2107
|
-
const isMind = PlaitMind.isMind(element);
|
|
2108
|
-
const emojiAndText = isMind ? RootDefaultSpace.horizontal.emojiAndText : NodeDefaultSpace.horizontal.emojiAndText;
|
|
2109
|
-
return emojiAndText;
|
|
2110
|
-
};
|
|
2111
2113
|
const getVerticalSpaceBetweenNodeAndText = (element) => {
|
|
2112
2114
|
const isMind = PlaitMind.isMind(element);
|
|
2113
2115
|
const nodeAndText = isMind ? RootDefaultSpace.vertical.nodeAndText : NodeDefaultSpace.vertical.nodeAndText;
|
|
2114
2116
|
return nodeAndText;
|
|
2115
2117
|
};
|
|
2118
|
+
const getSpaceEmojiAndText = (element) => {
|
|
2119
|
+
const isMind = PlaitMind.isMind(element);
|
|
2120
|
+
const emojiAndText = isMind ? RootDefaultSpace.horizontal.emojiAndText : NodeDefaultSpace.horizontal.emojiAndText;
|
|
2121
|
+
return emojiAndText;
|
|
2122
|
+
};
|
|
2116
2123
|
const NodeSpace = {
|
|
2117
2124
|
getNodeWidth(board, element) {
|
|
2118
|
-
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(element);
|
|
2125
|
+
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(board, element);
|
|
2119
2126
|
if (MindElement.hasEmojis(element)) {
|
|
2120
|
-
return
|
|
2127
|
+
return (NodeSpace.getEmojiLeftSpace(board, element) +
|
|
2128
|
+
getEmojisWidthHeight(board, element).width +
|
|
2129
|
+
getSpaceEmojiAndText(element) +
|
|
2130
|
+
element.width +
|
|
2131
|
+
nodeAndText);
|
|
2121
2132
|
}
|
|
2122
2133
|
return nodeAndText + element.width + nodeAndText;
|
|
2123
2134
|
},
|
|
@@ -2125,31 +2136,32 @@ const NodeSpace = {
|
|
|
2125
2136
|
const nodeAndText = getVerticalSpaceBetweenNodeAndText(element);
|
|
2126
2137
|
return nodeAndText + element.height + nodeAndText;
|
|
2127
2138
|
},
|
|
2128
|
-
|
|
2129
|
-
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(element);
|
|
2139
|
+
getTextLeftSpace(board, element) {
|
|
2140
|
+
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(board, element);
|
|
2130
2141
|
if (MindElement.hasEmojis(element)) {
|
|
2131
|
-
return
|
|
2142
|
+
return NodeSpace.getEmojiLeftSpace(board, element) + getEmojisWidthHeight(board, element).width + getSpaceEmojiAndText(element);
|
|
2132
2143
|
}
|
|
2133
2144
|
else {
|
|
2134
2145
|
return nodeAndText;
|
|
2135
2146
|
}
|
|
2136
2147
|
},
|
|
2137
|
-
|
|
2148
|
+
getTextTopSpace(element) {
|
|
2138
2149
|
const nodeAndText = getVerticalSpaceBetweenNodeAndText(element);
|
|
2139
2150
|
return nodeAndText;
|
|
2140
2151
|
},
|
|
2141
|
-
|
|
2142
|
-
const
|
|
2143
|
-
|
|
2152
|
+
getEmojiLeftSpace(board, element) {
|
|
2153
|
+
const options = board.getMindOptions();
|
|
2154
|
+
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(board, element);
|
|
2155
|
+
return nodeAndText - options.emojiPadding;
|
|
2144
2156
|
},
|
|
2145
|
-
|
|
2157
|
+
getEmojiTopSpace(element) {
|
|
2146
2158
|
const nodeAndText = getVerticalSpaceBetweenNodeAndText(element);
|
|
2147
2159
|
return nodeAndText;
|
|
2148
2160
|
}
|
|
2149
2161
|
};
|
|
2150
2162
|
|
|
2151
2163
|
function drawMindNodeRichtext(board, node, viewContainerRef) {
|
|
2152
|
-
const { x, y } = getRichtextRectangleByNode(board, node);
|
|
2164
|
+
const { x, y, width, height } = getRichtextRectangleByNode(board, node);
|
|
2153
2165
|
const classList = [];
|
|
2154
2166
|
if (node.origin.isRoot) {
|
|
2155
2167
|
classList.push('root-node');
|
|
@@ -2162,7 +2174,7 @@ function drawMindNodeRichtext(board, node, viewContainerRef) {
|
|
|
2162
2174
|
classList.push('child-node');
|
|
2163
2175
|
}
|
|
2164
2176
|
// COMPAT: last character can not show in safari browser
|
|
2165
|
-
return drawRichtext(x, y,
|
|
2177
|
+
return drawRichtext(x, y, width, height, node.origin.data.topic, viewContainerRef, classList);
|
|
2166
2178
|
}
|
|
2167
2179
|
function updateMindNodeTopicSize(board, node, g, isEditable) {
|
|
2168
2180
|
const { x, y, width, height } = getRichtextRectangleByNode(board, node);
|
|
@@ -2172,14 +2184,16 @@ function updateMindNodeTopicSize(board, node, g, isEditable) {
|
|
|
2172
2184
|
}
|
|
2173
2185
|
else {
|
|
2174
2186
|
// COMPAT: last character can not show in safari browser
|
|
2175
|
-
updateForeignObject(g,
|
|
2187
|
+
updateForeignObject(g, width, height, x, y);
|
|
2176
2188
|
}
|
|
2177
2189
|
}
|
|
2178
2190
|
function getRichtextRectangleByNode(board, node) {
|
|
2179
|
-
let { x, y
|
|
2180
|
-
x = x + NodeSpace.
|
|
2181
|
-
y = y + NodeSpace.
|
|
2182
|
-
|
|
2191
|
+
let { x, y } = getRectangleByNode(node);
|
|
2192
|
+
x = x + NodeSpace.getTextLeftSpace(board, node.origin);
|
|
2193
|
+
y = y + NodeSpace.getTextTopSpace(node.origin);
|
|
2194
|
+
const width = Math.ceil(node.origin.width);
|
|
2195
|
+
const height = Math.ceil(node.origin.height);
|
|
2196
|
+
return { height, width, x, y };
|
|
2183
2197
|
}
|
|
2184
2198
|
|
|
2185
2199
|
function drawRectangleNode(board, node) {
|
|
@@ -2276,10 +2290,8 @@ class EmojisDrawer {
|
|
|
2276
2290
|
if (MindElement.hasEmojis(element)) {
|
|
2277
2291
|
this.g = createG();
|
|
2278
2292
|
this.g.classList.add('emojis');
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
const { width, height } = getEmojisRectangle(this.board, element);
|
|
2282
|
-
const foreignObject = createForeignObject(x, y, width, height + NodeSpace.getEmojiVerticalSpace(element) * 2);
|
|
2293
|
+
const foreignRectangle = getEmojiForeignRectangle(this.board, element);
|
|
2294
|
+
const foreignObject = createForeignObject(foreignRectangle.x, foreignRectangle.y, foreignRectangle.width, foreignRectangle.height);
|
|
2283
2295
|
this.g.append(foreignObject);
|
|
2284
2296
|
const container = document.createElement('div');
|
|
2285
2297
|
container.classList.add('node-emojis-container');
|
|
@@ -2417,7 +2429,7 @@ class QuickInsertDrawer extends BaseDrawer {
|
|
|
2417
2429
|
* 3. 上、上左、上右
|
|
2418
2430
|
* 4. 下、下左、下右
|
|
2419
2431
|
*/
|
|
2420
|
-
const shape =
|
|
2432
|
+
const shape = getShapeByElement(this.board, element);
|
|
2421
2433
|
// 形状是矩形要偏移边框的线宽
|
|
2422
2434
|
const branchWidth = getBranchWidthByMindElement(this.board, element);
|
|
2423
2435
|
let offsetBorderLineWidth = 0;
|
|
@@ -2613,10 +2625,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2613
2625
|
this.emojisDrawer = new EmojisDrawer(this.board, this.viewContainerRef);
|
|
2614
2626
|
this.quickInsertDrawer = new QuickInsertDrawer(this.board);
|
|
2615
2627
|
super.ngOnInit();
|
|
2616
|
-
this.node =
|
|
2617
|
-
if (!PlaitMind.isMind(this.element)) {
|
|
2618
|
-
this.parent = MindElement.getNode(MindElement.getParent(this.element));
|
|
2619
|
-
}
|
|
2628
|
+
this.node = MindElement.getNode(this.element);
|
|
2620
2629
|
this.index = NODE_TO_INDEX.get(this.element) || 0;
|
|
2621
2630
|
this.roughSVG = PlaitBoard.getRoughSVG(this.board);
|
|
2622
2631
|
this.parentG = PlaitElement.getComponent(MindElement.getRoot(this.board, this.element)).rootG;
|
|
@@ -2631,21 +2640,18 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2631
2640
|
this.drawQuickInsert();
|
|
2632
2641
|
}
|
|
2633
2642
|
onContextChanged(value, previous) {
|
|
2634
|
-
const newNode =
|
|
2635
|
-
if (!PlaitMind.isMind(this.element)) {
|
|
2636
|
-
this.parent = MindElement.getNode(MindElement.getParent(this.element));
|
|
2637
|
-
}
|
|
2643
|
+
const newNode = MindElement.getNode(value.element);
|
|
2638
2644
|
// resolve move node richtext lose issue
|
|
2639
2645
|
if (this.node !== newNode) {
|
|
2640
2646
|
if (this.foreignObject && this.foreignObject.children.length <= 0) {
|
|
2641
2647
|
this.foreignObject?.appendChild(this.richtextComponentRef?.instance.editable);
|
|
2642
2648
|
}
|
|
2643
2649
|
}
|
|
2644
|
-
const
|
|
2650
|
+
const isEqualNode = RectangleClient.isEqual(this.node, newNode);
|
|
2645
2651
|
this.node = newNode;
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2652
|
+
if (!isEqualNode || value.element !== previous.element) {
|
|
2653
|
+
this.drawActiveG();
|
|
2654
|
+
this.updateActiveClass();
|
|
2649
2655
|
this.drawShape();
|
|
2650
2656
|
this.drawLink();
|
|
2651
2657
|
this.updateRichtext();
|
|
@@ -2654,6 +2660,20 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2654
2660
|
this.drawQuickInsert();
|
|
2655
2661
|
this.drawEmojis();
|
|
2656
2662
|
}
|
|
2663
|
+
else {
|
|
2664
|
+
if (value.selected !== previous.selected) {
|
|
2665
|
+
this.drawActiveG();
|
|
2666
|
+
this.updateActiveClass();
|
|
2667
|
+
}
|
|
2668
|
+
if (!PlaitMind.isMind(value.element)) {
|
|
2669
|
+
const parent = MindElement.getParent(previous.element);
|
|
2670
|
+
const newParent = MindElement.getParent(value.element);
|
|
2671
|
+
const hasSameChildren = parent.children.length === newParent.children.length;
|
|
2672
|
+
if (!hasSameChildren) {
|
|
2673
|
+
this.drawLink();
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2657
2677
|
}
|
|
2658
2678
|
drawEmojis() {
|
|
2659
2679
|
const g = this.emojisDrawer.drawEmojis(this.element);
|
|
@@ -2673,7 +2693,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2673
2693
|
}
|
|
2674
2694
|
drawShape() {
|
|
2675
2695
|
this.destroyShape();
|
|
2676
|
-
const shape =
|
|
2696
|
+
const shape = getShapeByElement(this.board, this.node.origin);
|
|
2677
2697
|
switch (shape) {
|
|
2678
2698
|
case MindElementShape.roundRectangle:
|
|
2679
2699
|
this.shapeG = drawRectangleNode(this.board, this.node);
|
|
@@ -2690,29 +2710,29 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2690
2710
|
}
|
|
2691
2711
|
}
|
|
2692
2712
|
drawLink() {
|
|
2693
|
-
if (
|
|
2713
|
+
if (PlaitMind.isMind(this.element)) {
|
|
2694
2714
|
return;
|
|
2695
2715
|
}
|
|
2716
|
+
const parent = MindElement.getParent(this.element);
|
|
2717
|
+
const parentNode = MindElement.getNode(parent);
|
|
2696
2718
|
if (this.linkG) {
|
|
2697
2719
|
this.linkG.remove();
|
|
2698
2720
|
}
|
|
2699
|
-
const layout = MindQueries.getLayoutByElement(
|
|
2721
|
+
const layout = MindQueries.getLayoutByElement(parent);
|
|
2700
2722
|
if (AbstractNode.isAbstract(this.node.origin)) {
|
|
2701
2723
|
this.linkG = drawAbstractLink(this.board, this.node, isHorizontalLayout(layout));
|
|
2702
2724
|
}
|
|
2703
|
-
else if (MindElement.isIndentedLayout(
|
|
2704
|
-
this.linkG = drawIndentedLink(this.board,
|
|
2725
|
+
else if (MindElement.isIndentedLayout(parent)) {
|
|
2726
|
+
this.linkG = drawIndentedLink(this.board, parentNode, this.node);
|
|
2705
2727
|
}
|
|
2706
2728
|
else {
|
|
2707
|
-
this.linkG = drawLogicLink(this.board, this.node,
|
|
2729
|
+
this.linkG = drawLogicLink(this.board, this.node, parentNode, isHorizontalLayout(layout));
|
|
2708
2730
|
}
|
|
2709
2731
|
this.g.append(this.linkG);
|
|
2710
2732
|
}
|
|
2711
2733
|
destroyLine() {
|
|
2712
|
-
if (this.
|
|
2713
|
-
|
|
2714
|
-
this.linkG.remove();
|
|
2715
|
-
}
|
|
2734
|
+
if (this.linkG) {
|
|
2735
|
+
this.linkG.remove();
|
|
2716
2736
|
}
|
|
2717
2737
|
}
|
|
2718
2738
|
drawMaskG() {
|
|
@@ -2876,7 +2896,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2876
2896
|
let circleOffset = [EXTEND_RADIUS / 2, 0];
|
|
2877
2897
|
if (isHorizontalLayout(nodeLayout) && !isIndentedLayout(nodeLayout)) {
|
|
2878
2898
|
extendLineYOffset =
|
|
2879
|
-
|
|
2899
|
+
getShapeByElement(this.board, this.node.origin) === MindElementShape.roundRectangle
|
|
2880
2900
|
? [0, 0]
|
|
2881
2901
|
: [height / 2, height / 2];
|
|
2882
2902
|
if (isLeftLayout(nodeLayout)) {
|
|
@@ -3330,19 +3350,22 @@ const updateRightNodeCount = (board, activeComponent, targetComponent, detectRes
|
|
|
3330
3350
|
const mindComponent = ELEMENT_TO_COMPONENT.get(mindElement);
|
|
3331
3351
|
const activeIndex = mindComponent?.root.children.indexOf(activeComponent.node);
|
|
3332
3352
|
const targetIndex = mindComponent?.root.children.indexOf(targetComponent.node);
|
|
3333
|
-
const
|
|
3334
|
-
const
|
|
3353
|
+
const activeParent = MindElement.getParent(activeComponent.element);
|
|
3354
|
+
const targetParent = MindElement.findParent(targetComponent.element);
|
|
3355
|
+
const isActiveOnRight = activeIndex !== -1 && activeIndex <= activeParent.rightNodeCount - 1;
|
|
3356
|
+
const isTargetOnRight = targetParent && targetIndex !== -1 && targetIndex <= targetParent.rightNodeCount - 1;
|
|
3335
3357
|
const isBothOnRight = isActiveOnRight && isTargetOnRight;
|
|
3336
3358
|
const rootChildCount = mindComponent.root.children?.length;
|
|
3337
3359
|
const rootRightNodeCount = mindComponent?.root.origin.rightNodeCount;
|
|
3338
3360
|
if (!isBothOnRight) {
|
|
3339
3361
|
if (isActiveOnRight) {
|
|
3340
3362
|
rightNodeCount = rootChildCount < rootRightNodeCount ? rootChildCount - 1 : rootRightNodeCount - 1;
|
|
3341
|
-
Transforms.setNode(board, { rightNodeCount }, PlaitBoard.findPath(board,
|
|
3363
|
+
Transforms.setNode(board, { rightNodeCount }, PlaitBoard.findPath(board, activeParent));
|
|
3342
3364
|
}
|
|
3343
3365
|
if (isTargetOnRight && detectResult !== 'right') {
|
|
3344
3366
|
rightNodeCount = rootChildCount < rootRightNodeCount ? rootRightNodeCount : rootRightNodeCount + 1;
|
|
3345
|
-
|
|
3367
|
+
const parent = MindElement.getParent(targetComponent.element);
|
|
3368
|
+
Transforms.setNode(board, { rightNodeCount }, PlaitBoard.findPath(board, parent));
|
|
3346
3369
|
}
|
|
3347
3370
|
//二级子节点拖动到根节点左侧
|
|
3348
3371
|
if (targetComponent.node.origin.isRoot && detectResult === 'left' && activeIndex === -1) {
|
|
@@ -3385,8 +3408,8 @@ const withDnd = (board) => {
|
|
|
3385
3408
|
return;
|
|
3386
3409
|
}
|
|
3387
3410
|
if (PlaitMind.isMind(value)) {
|
|
3388
|
-
const
|
|
3389
|
-
const root =
|
|
3411
|
+
const mindComponent = ELEMENT_TO_COMPONENT.get(value);
|
|
3412
|
+
const root = mindComponent.root;
|
|
3390
3413
|
root.eachNode((node) => {
|
|
3391
3414
|
if (activeElement) {
|
|
3392
3415
|
return;
|
|
@@ -3435,7 +3458,6 @@ const withDnd = (board) => {
|
|
|
3435
3458
|
const offsetX = endPoint[0] - startPoint[0];
|
|
3436
3459
|
const offsetY = endPoint[1] - startPoint[1];
|
|
3437
3460
|
const activeComponent = PlaitElement.getComponent(activeElement);
|
|
3438
|
-
const roughSVG = PlaitBoard.getRoughSVG(board);
|
|
3439
3461
|
const fakeDraggingNode = {
|
|
3440
3462
|
...activeComponent.node,
|
|
3441
3463
|
children: [],
|
|
@@ -3445,9 +3467,16 @@ const withDnd = (board) => {
|
|
|
3445
3467
|
const textRectangle = getRichtextRectangleByNode(board, activeComponent.node);
|
|
3446
3468
|
const fakeNodeG = drawRectangleNode(board, fakeDraggingNode);
|
|
3447
3469
|
const richtextG = activeComponent.richtextG?.cloneNode(true);
|
|
3448
|
-
updateForeignObject(richtextG, textRectangle.width
|
|
3470
|
+
updateForeignObject$1(richtextG, textRectangle.width, textRectangle.height, textRectangle.x + offsetX, textRectangle.y + offsetY);
|
|
3449
3471
|
fakeDragNodeG?.append(fakeNodeG);
|
|
3450
3472
|
fakeDragNodeG?.append(richtextG);
|
|
3473
|
+
// draw emojis
|
|
3474
|
+
if (MindElement.hasEmojis(activeElement)) {
|
|
3475
|
+
const fakeEmojisG = activeComponent.emojisDrawer.g.cloneNode(true);
|
|
3476
|
+
const foreignRectangle = getEmojiForeignRectangle(board, activeElement);
|
|
3477
|
+
updateForeignObject$1(fakeEmojisG, foreignRectangle.width, foreignRectangle.height, foreignRectangle.x + offsetX, foreignRectangle.y + offsetY);
|
|
3478
|
+
fakeDragNodeG?.append(fakeEmojisG);
|
|
3479
|
+
}
|
|
3451
3480
|
// drop position detect
|
|
3452
3481
|
const { x, y } = getRectangleByNode(fakeDraggingNode);
|
|
3453
3482
|
const detectCenterPoint = [x + textRectangle.width / 2, y + textRectangle.height / 2];
|
|
@@ -3774,7 +3803,11 @@ const withMind = (board) => {
|
|
|
3774
3803
|
board.isHitSelection = (element, range) => {
|
|
3775
3804
|
if (MindElement.isMindElement(board, element) && board.selection) {
|
|
3776
3805
|
const client = getRectangleByNode(MindElement.getNode(element));
|
|
3777
|
-
|
|
3806
|
+
const isHit = RectangleClient.isHit(RectangleClient.toRectangleClient([range.anchor, range.focus]), client);
|
|
3807
|
+
if (isHit && MindElement.hasEmojis(element) && Selection.isCollapsed(range) && isHitEmojis(board, element, range.anchor)) {
|
|
3808
|
+
return false;
|
|
3809
|
+
}
|
|
3810
|
+
return isHit;
|
|
3778
3811
|
}
|
|
3779
3812
|
return isHitSelection(element, range);
|
|
3780
3813
|
};
|
|
@@ -3820,31 +3853,32 @@ const withMind = (board) => {
|
|
|
3820
3853
|
if (hotkeys.isDeleteBackward(event) || hotkeys.isDeleteForward(event)) {
|
|
3821
3854
|
event.preventDefault();
|
|
3822
3855
|
deleteSelectedELements(board, selectedElements);
|
|
3823
|
-
let
|
|
3824
|
-
const firstLevelElements =
|
|
3856
|
+
let activeElement;
|
|
3857
|
+
const firstLevelElements = getFirstLevelElement(selectedElements);
|
|
3858
|
+
if (AbstractNode.isAbstract(firstLevelElements[0])) {
|
|
3859
|
+
const parent = MindElement.getParent(firstLevelElements[0]);
|
|
3860
|
+
activeElement = parent.children[firstLevelElements[0].start];
|
|
3861
|
+
}
|
|
3825
3862
|
const firstElement = firstLevelElements[0];
|
|
3826
|
-
const
|
|
3827
|
-
const
|
|
3828
|
-
|
|
3829
|
-
return findParentElement(element) && findParentElement(firstLevelElements[0]) === findParentElement(element);
|
|
3863
|
+
const firstElementParent = MindElement.findParent(firstElement);
|
|
3864
|
+
const hasSameParent = firstLevelElements.every(element => {
|
|
3865
|
+
return MindElement.findParent(element) === firstElementParent;
|
|
3830
3866
|
});
|
|
3831
|
-
if (
|
|
3832
|
-
const
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
lastNode = firstComponent?.parent.children[firstLevelElements.length];
|
|
3867
|
+
if (firstElementParent && hasSameParent && !activeElement) {
|
|
3868
|
+
const firstElementIndex = firstElementParent.children.indexOf(firstElement);
|
|
3869
|
+
const childrenCount = firstElementParent.children.length;
|
|
3870
|
+
// active parent element
|
|
3871
|
+
if (childrenCount === firstLevelElements.length) {
|
|
3872
|
+
activeElement = firstElementParent;
|
|
3838
3873
|
}
|
|
3839
|
-
else
|
|
3840
|
-
|
|
3874
|
+
else {
|
|
3875
|
+
if (firstElementIndex > 0) {
|
|
3876
|
+
activeElement = firstElementParent.children[firstElementIndex - 1];
|
|
3877
|
+
}
|
|
3841
3878
|
}
|
|
3842
3879
|
}
|
|
3843
|
-
if (
|
|
3844
|
-
|
|
3845
|
-
}
|
|
3846
|
-
if (lastNode) {
|
|
3847
|
-
addSelectedElement(board, lastNode.origin);
|
|
3880
|
+
if (activeElement) {
|
|
3881
|
+
addSelectedElement(board, activeElement);
|
|
3848
3882
|
}
|
|
3849
3883
|
return;
|
|
3850
3884
|
}
|
|
@@ -3871,8 +3905,8 @@ const withMind = (board) => {
|
|
|
3871
3905
|
const point = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3872
3906
|
board.children
|
|
3873
3907
|
.filter(value => PlaitMind.isMind(value))
|
|
3874
|
-
.forEach(
|
|
3875
|
-
depthFirstRecursion(
|
|
3908
|
+
.forEach(mindMap => {
|
|
3909
|
+
depthFirstRecursion(mindMap, node => {
|
|
3876
3910
|
if (!PlaitBoard.hasBeenTextEditing(board) && hitMindElement(board, point, node)) {
|
|
3877
3911
|
enterNodeEditing(node);
|
|
3878
3912
|
}
|
|
@@ -3884,7 +3918,7 @@ const withMind = (board) => {
|
|
|
3884
3918
|
dblclick(event);
|
|
3885
3919
|
};
|
|
3886
3920
|
board.setFragment = (data) => {
|
|
3887
|
-
const selectedElements =
|
|
3921
|
+
const selectedElements = getFirstLevelElement(getSelectedElements(board));
|
|
3888
3922
|
if (selectedElements.length) {
|
|
3889
3923
|
const elements = buildClipboardData(board, selectedElements);
|
|
3890
3924
|
setClipboardData(data, elements);
|
|
@@ -3958,5 +3992,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
3958
3992
|
* Generated bundle index. Do not edit.
|
|
3959
3993
|
*/
|
|
3960
3994
|
|
|
3961
|
-
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_COLORS, BRANCH_WIDTH, DefaultAbstractNodeStyle, DefaultNodeStyle, DefaultRootStyle, ELEMENT_TO_NODE, EXTEND_OFFSET, EXTEND_RADIUS, GRAY_COLOR, LayoutDirection, LayoutDirectionsMap, MindElement, MindElementShape, MindEmojiBaseComponent, MindModule, MindNode, MindNodeComponent, 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, canSetAbstract, changeRightNodeCount, copyNewNode, correctLayoutByDirection, createDefaultMindMapElement, createMindElement, deleteElementHandleAbstract, deleteSelectedELements, directionCorrector, directionDetector, divideElementByParent, drawCurvePlaceholderDropNodeG, drawIndentNodeG, drawPlaceholderDropNodeG, drawStraightDropNodeG, extractNodesText,
|
|
3995
|
+
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_COLORS, BRANCH_WIDTH, DefaultAbstractNodeStyle, DefaultNodeStyle, DefaultRootStyle, ELEMENT_TO_NODE, EXTEND_OFFSET, EXTEND_RADIUS, GRAY_COLOR, LayoutDirection, LayoutDirectionsMap, MindElement, MindElementShape, MindEmojiBaseComponent, MindModule, MindNode, MindNodeComponent, 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, canSetAbstract, changeRightNodeCount, copyNewNode, correctLayoutByDirection, createDefaultMindMapElement, createMindElement, deleteElementHandleAbstract, deleteSelectedELements, directionCorrector, directionDetector, divideElementByParent, drawCurvePlaceholderDropNodeG, drawIndentNodeG, drawPlaceholderDropNodeG, drawStraightDropNodeG, extractNodesText, findLastChild, findLocationLeftIndex, findUpElement, getAbstractBranchColor, getAbstractBranchWidth, getAbstractHandleRectangle, getAllowedDirection, getAvailableSubLayoutsByLayoutDirections, getBehindAbstracts, getBranchColorByMindElement, getBranchDirectionsByLayouts, getBranchWidthByMindElement, getChildrenCount, getCorrespondingAbstract, getDefaultBranchColor, getDefaultBranchColorByIndex, getDefaultLayout, getEmojiFontSize, getEmojiForeignRectangle, getEmojiRectangle, getEmojisWidthHeight, getFirstLevelElement, getHitAbstractHandle, getHorizontalFakeY, getInCorrectLayoutDirection, getIndentedFakePoint, getLayoutDirection$1 as getLayoutDirection, getLayoutReverseDirection, getLocationScope, getNextBranchColor, getOverallAbstracts, getRectangleByNode, getRectangleByResizingLocation, getRootLayout, getShapeByElement, getStrokeByMindElement, handleTouchedAbstract, hitMindElement, insertElementHandleAbstract, insertMindElement, isChildElement, isChildRight, isChildUp, isCorrectLayout, isHitEmojis, isMixedLayout, isSetAbstract, isVirtualKey, readjustmentDropTarget, separateChildren, shouldChangeRightNodeCount, transformAbstractToNode, transformNodeToRoot, transformRootToNode, withExtendMind, withMind };
|
|
3962
3996
|
//# sourceMappingURL=plait-mind.mjs.map
|