@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/fesm2015/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];
|
|
@@ -700,21 +705,14 @@ const MindTransforms = {
|
|
|
700
705
|
setAbstractByStandardLayout
|
|
701
706
|
};
|
|
702
707
|
|
|
703
|
-
function findParentElement(element) {
|
|
704
|
-
const component = PlaitElement.getComponent(element);
|
|
705
|
-
if (component && component.parent) {
|
|
706
|
-
return component.parent.origin;
|
|
707
|
-
}
|
|
708
|
-
return undefined;
|
|
709
|
-
}
|
|
710
708
|
function findUpElement(element) {
|
|
711
709
|
let branch;
|
|
712
710
|
let root = element;
|
|
713
|
-
let parent =
|
|
711
|
+
let parent = MindElement.findParent(element);
|
|
714
712
|
while (parent) {
|
|
715
713
|
branch = root;
|
|
716
714
|
root = parent;
|
|
717
|
-
parent =
|
|
715
|
+
parent = MindElement.findParent(parent);
|
|
718
716
|
}
|
|
719
717
|
return { root, branch };
|
|
720
718
|
}
|
|
@@ -725,16 +723,16 @@ const getChildrenCount = (element) => {
|
|
|
725
723
|
return count + element.children.length;
|
|
726
724
|
};
|
|
727
725
|
const isChildElement = (origin, child) => {
|
|
728
|
-
let parent =
|
|
726
|
+
let parent = MindElement.findParent(child);
|
|
729
727
|
while (parent) {
|
|
730
728
|
if (parent === origin) {
|
|
731
729
|
return true;
|
|
732
730
|
}
|
|
733
|
-
parent =
|
|
731
|
+
parent = MindElement.findParent(parent);
|
|
734
732
|
}
|
|
735
733
|
return false;
|
|
736
734
|
};
|
|
737
|
-
const
|
|
735
|
+
const getFirstLevelElement = (elements) => {
|
|
738
736
|
let result = [];
|
|
739
737
|
elements.forEach(element => {
|
|
740
738
|
const isChild = elements.some(node => {
|
|
@@ -819,7 +817,7 @@ const changeRightNodeCount = (board, parentPath, changeNumber) => {
|
|
|
819
817
|
}, parentPath);
|
|
820
818
|
};
|
|
821
819
|
const shouldChangeRightNodeCount = (selectedElement) => {
|
|
822
|
-
const parentElement =
|
|
820
|
+
const parentElement = MindElement.findParent(selectedElement);
|
|
823
821
|
if (parentElement) {
|
|
824
822
|
const nodeIndex = parentElement.children.findIndex(item => item.id === selectedElement.id);
|
|
825
823
|
if (parentElement.isRoot &&
|
|
@@ -905,7 +903,7 @@ const findLastChild = (child) => {
|
|
|
905
903
|
return result;
|
|
906
904
|
};
|
|
907
905
|
const deleteSelectedELements = (board, selectedElements) => {
|
|
908
|
-
const deletableElements =
|
|
906
|
+
const deletableElements = getFirstLevelElement(selectedElements).reverse();
|
|
909
907
|
const abstractRefs = deleteElementHandleAbstract(board, deletableElements);
|
|
910
908
|
MindTransforms.setAbstractsByRefs(board, abstractRefs);
|
|
911
909
|
//翻转,从下到上修改,防止找不到 path
|
|
@@ -940,51 +938,28 @@ const divideElementByParent = (elements) => {
|
|
|
940
938
|
return { parentElements, abstractIncludedGroups };
|
|
941
939
|
};
|
|
942
940
|
|
|
943
|
-
const
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
941
|
+
const getAvailableProperty = (board, element, propertyKey) => {
|
|
942
|
+
const ancestors = MindElement.getAncestors(board, element);
|
|
943
|
+
ancestors.unshift(element);
|
|
944
|
+
const ancestor = ancestors.find(value => value[propertyKey]);
|
|
945
|
+
if (ancestor) {
|
|
946
|
+
return ancestor[propertyKey];
|
|
947
947
|
}
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
if (parent.shape) {
|
|
951
|
-
return parent.shape;
|
|
952
|
-
}
|
|
953
|
-
parent = findParentElement(parent);
|
|
948
|
+
else {
|
|
949
|
+
return undefined;
|
|
954
950
|
}
|
|
955
|
-
return MindElementShape.roundRectangle;
|
|
956
951
|
};
|
|
957
952
|
|
|
958
953
|
/**
|
|
959
954
|
* Processing of branch color, width, style, etc. of the mind node
|
|
960
955
|
*/
|
|
961
956
|
const getBranchColorByMindElement = (board, element) => {
|
|
962
|
-
const
|
|
963
|
-
|
|
964
|
-
const ancestor = ancestors.find(value => value.branchColor);
|
|
965
|
-
if (ancestor && ancestor.branchColor) {
|
|
966
|
-
return ancestor.branchColor;
|
|
967
|
-
}
|
|
968
|
-
const root = ancestors[ancestors.length - 1];
|
|
969
|
-
const branch = ancestors[ancestors.length - 2];
|
|
970
|
-
if (branch) {
|
|
971
|
-
const index = root.children.indexOf(branch);
|
|
972
|
-
const length = BRANCH_COLORS.length;
|
|
973
|
-
const remainder = index % length;
|
|
974
|
-
return BRANCH_COLORS[remainder];
|
|
975
|
-
}
|
|
976
|
-
else {
|
|
977
|
-
throw new Error('root element should not have branch color');
|
|
978
|
-
}
|
|
957
|
+
const branchColor = getAvailableProperty(board, element, 'branchColor');
|
|
958
|
+
return branchColor || getDefaultBranchColor(board, element);
|
|
979
959
|
};
|
|
980
960
|
const getBranchWidthByMindElement = (board, element) => {
|
|
981
|
-
const
|
|
982
|
-
|
|
983
|
-
const ancestor = ancestors.find(value => value.branchColor);
|
|
984
|
-
if (ancestor && ancestor.branchWidth) {
|
|
985
|
-
return ancestor.branchWidth;
|
|
986
|
-
}
|
|
987
|
-
return BRANCH_WIDTH;
|
|
961
|
+
const branchWidth = getAvailableProperty(board, element, 'branchWidth');
|
|
962
|
+
return branchWidth || BRANCH_WIDTH;
|
|
988
963
|
};
|
|
989
964
|
const getAbstractBranchWidth = (board, element) => {
|
|
990
965
|
if (!isNullOrUndefined(element.branchWidth)) {
|
|
@@ -1000,29 +975,33 @@ const getAbstractBranchColor = (board, element) => {
|
|
|
1000
975
|
};
|
|
1001
976
|
const getNextBranchColor = (root) => {
|
|
1002
977
|
const index = root.children.length;
|
|
978
|
+
return getDefaultBranchColorByIndex(index);
|
|
979
|
+
};
|
|
980
|
+
const getDefaultBranchColor = (board, element) => {
|
|
981
|
+
const path = PlaitBoard.findPath(board, element);
|
|
982
|
+
return getDefaultBranchColorByIndex(path[1]);
|
|
983
|
+
};
|
|
984
|
+
const getDefaultBranchColorByIndex = (index) => {
|
|
1003
985
|
const length = BRANCH_COLORS.length;
|
|
1004
986
|
const remainder = index % length;
|
|
1005
987
|
return BRANCH_COLORS[remainder];
|
|
1006
988
|
};
|
|
1007
989
|
|
|
1008
990
|
const getStrokeByMindElement = (board, element) => {
|
|
991
|
+
if (PlaitMind.isMind(element)) {
|
|
992
|
+
return element.strokeColor || DefaultRootStyle.strokeColor;
|
|
993
|
+
}
|
|
1009
994
|
const ancestors = MindElement.getAncestors(board, element);
|
|
1010
995
|
ancestors.unshift(element);
|
|
1011
996
|
const ancestor = ancestors.find(value => value.strokeColor);
|
|
1012
|
-
if (ancestor && ancestor.strokeColor) {
|
|
997
|
+
if (ancestor && ancestor.strokeColor && !PlaitMind.isMind(ancestor)) {
|
|
1013
998
|
return ancestor.strokeColor;
|
|
1014
999
|
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
const remainder = index % length;
|
|
1021
|
-
return BRANCH_COLORS[remainder];
|
|
1022
|
-
}
|
|
1023
|
-
else {
|
|
1024
|
-
return DefaultRootStyle.strokeColor;
|
|
1025
|
-
}
|
|
1000
|
+
return getDefaultBranchColor(board, element);
|
|
1001
|
+
};
|
|
1002
|
+
const getShapeByElement = (board, element) => {
|
|
1003
|
+
const shape = getAvailableProperty(board, element, 'shape');
|
|
1004
|
+
return shape || MindElementShape.roundRectangle;
|
|
1026
1005
|
};
|
|
1027
1006
|
|
|
1028
1007
|
function isVirtualKey(e) {
|
|
@@ -1052,7 +1031,7 @@ function drawLink(board, node, child, defaultStroke = null, isHorizontal = true,
|
|
|
1052
1031
|
endY = endNode.y + endNode.height / 2;
|
|
1053
1032
|
if (node.parent &&
|
|
1054
1033
|
isIndentedLayout(MindQueries.getLayoutByElement((_a = node.parent) === null || _a === void 0 ? void 0 : _a.origin)) &&
|
|
1055
|
-
|
|
1034
|
+
getShapeByElement(board, node.origin) === MindElementShape.underline) {
|
|
1056
1035
|
if (isChildRight(node, child)) {
|
|
1057
1036
|
beginY = node.y + node.height - node.vGap;
|
|
1058
1037
|
}
|
|
@@ -1096,7 +1075,7 @@ function drawLink(board, node, child, defaultStroke = null, isHorizontal = true,
|
|
|
1096
1075
|
[endX - (beginNode.hGap + endNode.hGap) / 2, endY],
|
|
1097
1076
|
[endX, endY]
|
|
1098
1077
|
];
|
|
1099
|
-
const shape =
|
|
1078
|
+
const shape = getShapeByElement(board, child.origin);
|
|
1100
1079
|
if (!node.origin.isRoot) {
|
|
1101
1080
|
if (node.x > child.x) {
|
|
1102
1081
|
curve = [
|
|
@@ -1196,8 +1175,9 @@ const drawPlaceholderDropNodeG = (board, dropTarget, fakeDropNodeG) => {
|
|
|
1196
1175
|
if (dropTarget.detectResult && ['right', 'left'].includes(dropTarget.detectResult)) {
|
|
1197
1176
|
drawStraightDropNodeG(board, targetRect, dropTarget.detectResult, targetComponent, fakeDropNodeG);
|
|
1198
1177
|
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1178
|
+
const targetParent = MindElement.findParent(targetComponent.element);
|
|
1179
|
+
if (targetParent && dropTarget.detectResult && ['top', 'bottom'].includes(dropTarget.detectResult)) {
|
|
1180
|
+
const parentComponent = PlaitElement.getComponent(targetParent);
|
|
1201
1181
|
const targetIndex = parentComponent.node.origin.children.indexOf(targetComponent.node.origin);
|
|
1202
1182
|
drawCurvePlaceholderDropNodeG(board, targetRect, dropTarget.detectResult, targetIndex, targetComponent, parentComponent, fakeDropNodeG);
|
|
1203
1183
|
}
|
|
@@ -1239,7 +1219,7 @@ const drawCurvePlaceholderDropNodeG = (board, targetRect, detectResult, targetIn
|
|
|
1239
1219
|
}
|
|
1240
1220
|
if (isVerticalLogicLayout(layout)) {
|
|
1241
1221
|
parentComponent = targetComponent;
|
|
1242
|
-
targetComponent = PlaitElement.getComponent(targetComponent.
|
|
1222
|
+
targetComponent = PlaitElement.getComponent(MindElement.getParent(targetComponent.element));
|
|
1243
1223
|
fakeX = parentComponent.node.x;
|
|
1244
1224
|
width = parentComponent.node.width;
|
|
1245
1225
|
const vGap = BASE * 6 + strokeWidth;
|
|
@@ -1360,7 +1340,7 @@ const drawStraightDropNodeG = (board, targetRect, detectResult, targetComponent,
|
|
|
1360
1340
|
* b. 最后一个节点的右侧:固定值(来源于 getMainAxle,第二级节点:BASE * 8,其他 BASE * 3 + strokeWidth / 2);
|
|
1361
1341
|
*/
|
|
1362
1342
|
fakeY = targetComponent.node.y;
|
|
1363
|
-
const parentComponent = PlaitElement.getComponent(targetComponent.
|
|
1343
|
+
const parentComponent = PlaitElement.getComponent(MindElement.getParent(targetComponent.element));
|
|
1364
1344
|
const targetIndex = parentComponent.node.origin.children.indexOf(targetComponent.node.origin);
|
|
1365
1345
|
if (detectResult === 'left') {
|
|
1366
1346
|
let offsetX = 0;
|
|
@@ -1856,7 +1836,7 @@ function handleTouchedAbstract(board, touchedAbstract, endPoint) {
|
|
|
1856
1836
|
function drawIndentedLink(board, node, child, defaultStroke = null, needDrawUnderline = true) {
|
|
1857
1837
|
const branchWidth = getBranchWidthByMindElement(board, child.origin);
|
|
1858
1838
|
const branchColor = defaultStroke || getBranchColorByMindElement(board, child.origin);
|
|
1859
|
-
const isUnderlineShape =
|
|
1839
|
+
const isUnderlineShape = getShapeByElement(board, child.origin) === MindElementShape.underline;
|
|
1860
1840
|
let beginX, beginY, endX, endY, beginNode = node, endNode = child;
|
|
1861
1841
|
const beginRectangle = getRectangleByNode(beginNode);
|
|
1862
1842
|
const endRectangle = getRectangleByNode(endNode);
|
|
@@ -2005,8 +1985,10 @@ function drawLogicLink(board, node, parent, isHorizontal) {
|
|
|
2005
1985
|
const branchColor = getBranchColorByMindElement(board, node.origin);
|
|
2006
1986
|
const branchWidth = getBranchWidthByMindElement(board, node.origin);
|
|
2007
1987
|
const hasStraightLine = !parent.origin.isRoot;
|
|
2008
|
-
const
|
|
2009
|
-
const
|
|
1988
|
+
const parentShape = getShapeByElement(board, parent.origin);
|
|
1989
|
+
const shape = node.origin.shape ? node.origin.shape : parentShape;
|
|
1990
|
+
const hasUnderlineShape = shape === MindElementShape.underline;
|
|
1991
|
+
const hasUnderlineShapeOfParent = parentShape === MindElementShape.underline;
|
|
2010
1992
|
const nodeClient = getRectangleByNode(node);
|
|
2011
1993
|
const parentClient = getRectangleByNode(parent);
|
|
2012
1994
|
const linkDirection = getLayoutDirection(node, isHorizontal);
|
|
@@ -2046,7 +2028,7 @@ function drawLogicLink(board, node, parent, isHorizontal) {
|
|
|
2046
2028
|
return PlaitBoard.getRoughSVG(board).curve(points, { stroke: branchColor, strokeWidth: branchWidth });
|
|
2047
2029
|
}
|
|
2048
2030
|
|
|
2049
|
-
function
|
|
2031
|
+
function getEmojisWidthHeight(board, element) {
|
|
2050
2032
|
const options = board.getMindOptions();
|
|
2051
2033
|
const count = element.data.emojis.length;
|
|
2052
2034
|
const fontSize = getEmojiFontSize(element);
|
|
@@ -2063,6 +2045,31 @@ function getEmojiFontSize(element) {
|
|
|
2063
2045
|
return 14 + 2;
|
|
2064
2046
|
}
|
|
2065
2047
|
}
|
|
2048
|
+
function getEmojiRectangle(board, element) {
|
|
2049
|
+
let { x, y } = getRectangleByNode(MindElement.getNode(element));
|
|
2050
|
+
x = x + NodeSpace.getEmojiLeftSpace(board, element);
|
|
2051
|
+
const { width, height } = getEmojisWidthHeight(board, element);
|
|
2052
|
+
return {
|
|
2053
|
+
x,
|
|
2054
|
+
y,
|
|
2055
|
+
width,
|
|
2056
|
+
height
|
|
2057
|
+
};
|
|
2058
|
+
}
|
|
2059
|
+
function getEmojiForeignRectangle(board, element) {
|
|
2060
|
+
let { x, y } = getRectangleByNode(MindElement.getNode(element));
|
|
2061
|
+
x = x + NodeSpace.getEmojiLeftSpace(board, element);
|
|
2062
|
+
const { width, height } = getEmojisWidthHeight(board, element);
|
|
2063
|
+
return {
|
|
2064
|
+
x,
|
|
2065
|
+
y,
|
|
2066
|
+
width,
|
|
2067
|
+
height: height + NodeSpace.getEmojiTopSpace(element) * 2
|
|
2068
|
+
};
|
|
2069
|
+
}
|
|
2070
|
+
const isHitEmojis = (board, element, point) => {
|
|
2071
|
+
return RectangleClient.isHit(RectangleClient.toRectangleClient([point, point]), getEmojiRectangle(board, element));
|
|
2072
|
+
};
|
|
2066
2073
|
|
|
2067
2074
|
const NodeDefaultSpace = {
|
|
2068
2075
|
horizontal: {
|
|
@@ -2082,26 +2089,30 @@ const RootDefaultSpace = {
|
|
|
2082
2089
|
nodeAndText: BASE * 2
|
|
2083
2090
|
}
|
|
2084
2091
|
};
|
|
2085
|
-
const getHorizontalSpaceBetweenNodeAndText = (element) => {
|
|
2092
|
+
const getHorizontalSpaceBetweenNodeAndText = (board, element) => {
|
|
2086
2093
|
const isMind = PlaitMind.isMind(element);
|
|
2087
2094
|
const nodeAndText = isMind ? RootDefaultSpace.horizontal.nodeAndText : NodeDefaultSpace.horizontal.nodeAndText;
|
|
2088
2095
|
return nodeAndText;
|
|
2089
2096
|
};
|
|
2090
|
-
const getHorizontalSpaceEmojiAndText = (element) => {
|
|
2091
|
-
const isMind = PlaitMind.isMind(element);
|
|
2092
|
-
const emojiAndText = isMind ? RootDefaultSpace.horizontal.emojiAndText : NodeDefaultSpace.horizontal.emojiAndText;
|
|
2093
|
-
return emojiAndText;
|
|
2094
|
-
};
|
|
2095
2097
|
const getVerticalSpaceBetweenNodeAndText = (element) => {
|
|
2096
2098
|
const isMind = PlaitMind.isMind(element);
|
|
2097
2099
|
const nodeAndText = isMind ? RootDefaultSpace.vertical.nodeAndText : NodeDefaultSpace.vertical.nodeAndText;
|
|
2098
2100
|
return nodeAndText;
|
|
2099
2101
|
};
|
|
2102
|
+
const getSpaceEmojiAndText = (element) => {
|
|
2103
|
+
const isMind = PlaitMind.isMind(element);
|
|
2104
|
+
const emojiAndText = isMind ? RootDefaultSpace.horizontal.emojiAndText : NodeDefaultSpace.horizontal.emojiAndText;
|
|
2105
|
+
return emojiAndText;
|
|
2106
|
+
};
|
|
2100
2107
|
const NodeSpace = {
|
|
2101
2108
|
getNodeWidth(board, element) {
|
|
2102
|
-
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(element);
|
|
2109
|
+
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(board, element);
|
|
2103
2110
|
if (MindElement.hasEmojis(element)) {
|
|
2104
|
-
return
|
|
2111
|
+
return (NodeSpace.getEmojiLeftSpace(board, element) +
|
|
2112
|
+
getEmojisWidthHeight(board, element).width +
|
|
2113
|
+
getSpaceEmojiAndText(element) +
|
|
2114
|
+
element.width +
|
|
2115
|
+
nodeAndText);
|
|
2105
2116
|
}
|
|
2106
2117
|
return nodeAndText + element.width + nodeAndText;
|
|
2107
2118
|
},
|
|
@@ -2109,24 +2120,25 @@ const NodeSpace = {
|
|
|
2109
2120
|
const nodeAndText = getVerticalSpaceBetweenNodeAndText(element);
|
|
2110
2121
|
return nodeAndText + element.height + nodeAndText;
|
|
2111
2122
|
},
|
|
2112
|
-
|
|
2113
|
-
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(element);
|
|
2123
|
+
getTextLeftSpace(board, element) {
|
|
2124
|
+
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(board, element);
|
|
2114
2125
|
if (MindElement.hasEmojis(element)) {
|
|
2115
|
-
return
|
|
2126
|
+
return NodeSpace.getEmojiLeftSpace(board, element) + getEmojisWidthHeight(board, element).width + getSpaceEmojiAndText(element);
|
|
2116
2127
|
}
|
|
2117
2128
|
else {
|
|
2118
2129
|
return nodeAndText;
|
|
2119
2130
|
}
|
|
2120
2131
|
},
|
|
2121
|
-
|
|
2132
|
+
getTextTopSpace(element) {
|
|
2122
2133
|
const nodeAndText = getVerticalSpaceBetweenNodeAndText(element);
|
|
2123
2134
|
return nodeAndText;
|
|
2124
2135
|
},
|
|
2125
|
-
|
|
2126
|
-
const
|
|
2127
|
-
|
|
2136
|
+
getEmojiLeftSpace(board, element) {
|
|
2137
|
+
const options = board.getMindOptions();
|
|
2138
|
+
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(board, element);
|
|
2139
|
+
return nodeAndText - options.emojiPadding;
|
|
2128
2140
|
},
|
|
2129
|
-
|
|
2141
|
+
getEmojiTopSpace(element) {
|
|
2130
2142
|
const nodeAndText = getVerticalSpaceBetweenNodeAndText(element);
|
|
2131
2143
|
return nodeAndText;
|
|
2132
2144
|
}
|
|
@@ -2134,7 +2146,7 @@ const NodeSpace = {
|
|
|
2134
2146
|
|
|
2135
2147
|
function drawMindNodeRichtext(board, node, viewContainerRef) {
|
|
2136
2148
|
var _a, _b;
|
|
2137
|
-
const { x, y } = getRichtextRectangleByNode(board, node);
|
|
2149
|
+
const { x, y, width, height } = getRichtextRectangleByNode(board, node);
|
|
2138
2150
|
const classList = [];
|
|
2139
2151
|
if (node.origin.isRoot) {
|
|
2140
2152
|
classList.push('root-node');
|
|
@@ -2147,7 +2159,7 @@ function drawMindNodeRichtext(board, node, viewContainerRef) {
|
|
|
2147
2159
|
classList.push('child-node');
|
|
2148
2160
|
}
|
|
2149
2161
|
// COMPAT: last character can not show in safari browser
|
|
2150
|
-
return drawRichtext(x, y,
|
|
2162
|
+
return drawRichtext(x, y, width, height, node.origin.data.topic, viewContainerRef, classList);
|
|
2151
2163
|
}
|
|
2152
2164
|
function updateMindNodeTopicSize(board, node, g, isEditable) {
|
|
2153
2165
|
const { x, y, width, height } = getRichtextRectangleByNode(board, node);
|
|
@@ -2157,14 +2169,16 @@ function updateMindNodeTopicSize(board, node, g, isEditable) {
|
|
|
2157
2169
|
}
|
|
2158
2170
|
else {
|
|
2159
2171
|
// COMPAT: last character can not show in safari browser
|
|
2160
|
-
updateForeignObject(g,
|
|
2172
|
+
updateForeignObject(g, width, height, x, y);
|
|
2161
2173
|
}
|
|
2162
2174
|
}
|
|
2163
2175
|
function getRichtextRectangleByNode(board, node) {
|
|
2164
|
-
let { x, y
|
|
2165
|
-
x = x + NodeSpace.
|
|
2166
|
-
y = y + NodeSpace.
|
|
2167
|
-
|
|
2176
|
+
let { x, y } = getRectangleByNode(node);
|
|
2177
|
+
x = x + NodeSpace.getTextLeftSpace(board, node.origin);
|
|
2178
|
+
y = y + NodeSpace.getTextTopSpace(node.origin);
|
|
2179
|
+
const width = Math.ceil(node.origin.width);
|
|
2180
|
+
const height = Math.ceil(node.origin.height);
|
|
2181
|
+
return { height, width, x, y };
|
|
2168
2182
|
}
|
|
2169
2183
|
|
|
2170
2184
|
function drawRectangleNode(board, node) {
|
|
@@ -2261,10 +2275,8 @@ class EmojisDrawer {
|
|
|
2261
2275
|
if (MindElement.hasEmojis(element)) {
|
|
2262
2276
|
this.g = createG();
|
|
2263
2277
|
this.g.classList.add('emojis');
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
const { width, height } = getEmojisRectangle(this.board, element);
|
|
2267
|
-
const foreignObject = createForeignObject(x, y, width, height + NodeSpace.getEmojiVerticalSpace(element) * 2);
|
|
2278
|
+
const foreignRectangle = getEmojiForeignRectangle(this.board, element);
|
|
2279
|
+
const foreignObject = createForeignObject(foreignRectangle.x, foreignRectangle.y, foreignRectangle.width, foreignRectangle.height);
|
|
2268
2280
|
this.g.append(foreignObject);
|
|
2269
2281
|
const container = document.createElement('div');
|
|
2270
2282
|
container.classList.add('node-emojis-container');
|
|
@@ -2402,7 +2414,7 @@ class QuickInsertDrawer extends BaseDrawer {
|
|
|
2402
2414
|
* 3. 上、上左、上右
|
|
2403
2415
|
* 4. 下、下左、下右
|
|
2404
2416
|
*/
|
|
2405
|
-
const shape =
|
|
2417
|
+
const shape = getShapeByElement(this.board, element);
|
|
2406
2418
|
// 形状是矩形要偏移边框的线宽
|
|
2407
2419
|
const branchWidth = getBranchWidthByMindElement(this.board, element);
|
|
2408
2420
|
let offsetBorderLineWidth = 0;
|
|
@@ -2598,10 +2610,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2598
2610
|
this.emojisDrawer = new EmojisDrawer(this.board, this.viewContainerRef);
|
|
2599
2611
|
this.quickInsertDrawer = new QuickInsertDrawer(this.board);
|
|
2600
2612
|
super.ngOnInit();
|
|
2601
|
-
this.node =
|
|
2602
|
-
if (!PlaitMind.isMind(this.element)) {
|
|
2603
|
-
this.parent = MindElement.getNode(MindElement.getParent(this.element));
|
|
2604
|
-
}
|
|
2613
|
+
this.node = MindElement.getNode(this.element);
|
|
2605
2614
|
this.index = NODE_TO_INDEX.get(this.element) || 0;
|
|
2606
2615
|
this.roughSVG = PlaitBoard.getRoughSVG(this.board);
|
|
2607
2616
|
this.parentG = PlaitElement.getComponent(MindElement.getRoot(this.board, this.element)).rootG;
|
|
@@ -2617,21 +2626,18 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2617
2626
|
}
|
|
2618
2627
|
onContextChanged(value, previous) {
|
|
2619
2628
|
var _a, _b;
|
|
2620
|
-
const newNode =
|
|
2621
|
-
if (!PlaitMind.isMind(this.element)) {
|
|
2622
|
-
this.parent = MindElement.getNode(MindElement.getParent(this.element));
|
|
2623
|
-
}
|
|
2629
|
+
const newNode = MindElement.getNode(value.element);
|
|
2624
2630
|
// resolve move node richtext lose issue
|
|
2625
2631
|
if (this.node !== newNode) {
|
|
2626
2632
|
if (this.foreignObject && this.foreignObject.children.length <= 0) {
|
|
2627
2633
|
(_a = this.foreignObject) === null || _a === void 0 ? void 0 : _a.appendChild((_b = this.richtextComponentRef) === null || _b === void 0 ? void 0 : _b.instance.editable);
|
|
2628
2634
|
}
|
|
2629
2635
|
}
|
|
2630
|
-
const
|
|
2636
|
+
const isEqualNode = RectangleClient.isEqual(this.node, newNode);
|
|
2631
2637
|
this.node = newNode;
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2638
|
+
if (!isEqualNode || value.element !== previous.element) {
|
|
2639
|
+
this.drawActiveG();
|
|
2640
|
+
this.updateActiveClass();
|
|
2635
2641
|
this.drawShape();
|
|
2636
2642
|
this.drawLink();
|
|
2637
2643
|
this.updateRichtext();
|
|
@@ -2640,6 +2646,20 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2640
2646
|
this.drawQuickInsert();
|
|
2641
2647
|
this.drawEmojis();
|
|
2642
2648
|
}
|
|
2649
|
+
else {
|
|
2650
|
+
if (value.selected !== previous.selected) {
|
|
2651
|
+
this.drawActiveG();
|
|
2652
|
+
this.updateActiveClass();
|
|
2653
|
+
}
|
|
2654
|
+
if (!PlaitMind.isMind(value.element)) {
|
|
2655
|
+
const parent = MindElement.getParent(previous.element);
|
|
2656
|
+
const newParent = MindElement.getParent(value.element);
|
|
2657
|
+
const hasSameChildren = parent.children.length === newParent.children.length;
|
|
2658
|
+
if (!hasSameChildren) {
|
|
2659
|
+
this.drawLink();
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2643
2663
|
}
|
|
2644
2664
|
drawEmojis() {
|
|
2645
2665
|
const g = this.emojisDrawer.drawEmojis(this.element);
|
|
@@ -2660,7 +2680,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2660
2680
|
}
|
|
2661
2681
|
drawShape() {
|
|
2662
2682
|
this.destroyShape();
|
|
2663
|
-
const shape =
|
|
2683
|
+
const shape = getShapeByElement(this.board, this.node.origin);
|
|
2664
2684
|
switch (shape) {
|
|
2665
2685
|
case MindElementShape.roundRectangle:
|
|
2666
2686
|
this.shapeG = drawRectangleNode(this.board, this.node);
|
|
@@ -2677,29 +2697,29 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2677
2697
|
}
|
|
2678
2698
|
}
|
|
2679
2699
|
drawLink() {
|
|
2680
|
-
if (
|
|
2700
|
+
if (PlaitMind.isMind(this.element)) {
|
|
2681
2701
|
return;
|
|
2682
2702
|
}
|
|
2703
|
+
const parent = MindElement.getParent(this.element);
|
|
2704
|
+
const parentNode = MindElement.getNode(parent);
|
|
2683
2705
|
if (this.linkG) {
|
|
2684
2706
|
this.linkG.remove();
|
|
2685
2707
|
}
|
|
2686
|
-
const layout = MindQueries.getLayoutByElement(
|
|
2708
|
+
const layout = MindQueries.getLayoutByElement(parent);
|
|
2687
2709
|
if (AbstractNode.isAbstract(this.node.origin)) {
|
|
2688
2710
|
this.linkG = drawAbstractLink(this.board, this.node, isHorizontalLayout(layout));
|
|
2689
2711
|
}
|
|
2690
|
-
else if (MindElement.isIndentedLayout(
|
|
2691
|
-
this.linkG = drawIndentedLink(this.board,
|
|
2712
|
+
else if (MindElement.isIndentedLayout(parent)) {
|
|
2713
|
+
this.linkG = drawIndentedLink(this.board, parentNode, this.node);
|
|
2692
2714
|
}
|
|
2693
2715
|
else {
|
|
2694
|
-
this.linkG = drawLogicLink(this.board, this.node,
|
|
2716
|
+
this.linkG = drawLogicLink(this.board, this.node, parentNode, isHorizontalLayout(layout));
|
|
2695
2717
|
}
|
|
2696
2718
|
this.g.append(this.linkG);
|
|
2697
2719
|
}
|
|
2698
2720
|
destroyLine() {
|
|
2699
|
-
if (this.
|
|
2700
|
-
|
|
2701
|
-
this.linkG.remove();
|
|
2702
|
-
}
|
|
2721
|
+
if (this.linkG) {
|
|
2722
|
+
this.linkG.remove();
|
|
2703
2723
|
}
|
|
2704
2724
|
}
|
|
2705
2725
|
drawMaskG() {
|
|
@@ -2864,7 +2884,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2864
2884
|
let circleOffset = [EXTEND_RADIUS / 2, 0];
|
|
2865
2885
|
if (isHorizontalLayout(nodeLayout) && !isIndentedLayout(nodeLayout)) {
|
|
2866
2886
|
extendLineYOffset =
|
|
2867
|
-
|
|
2887
|
+
getShapeByElement(this.board, this.node.origin) === MindElementShape.roundRectangle
|
|
2868
2888
|
? [0, 0]
|
|
2869
2889
|
: [height / 2, height / 2];
|
|
2870
2890
|
if (isLeftLayout(nodeLayout)) {
|
|
@@ -3322,19 +3342,22 @@ const updateRightNodeCount = (board, activeComponent, targetComponent, detectRes
|
|
|
3322
3342
|
const mindComponent = ELEMENT_TO_COMPONENT.get(mindElement);
|
|
3323
3343
|
const activeIndex = mindComponent === null || mindComponent === void 0 ? void 0 : mindComponent.root.children.indexOf(activeComponent.node);
|
|
3324
3344
|
const targetIndex = mindComponent === null || mindComponent === void 0 ? void 0 : mindComponent.root.children.indexOf(targetComponent.node);
|
|
3325
|
-
const
|
|
3326
|
-
const
|
|
3345
|
+
const activeParent = MindElement.getParent(activeComponent.element);
|
|
3346
|
+
const targetParent = MindElement.findParent(targetComponent.element);
|
|
3347
|
+
const isActiveOnRight = activeIndex !== -1 && activeIndex <= activeParent.rightNodeCount - 1;
|
|
3348
|
+
const isTargetOnRight = targetParent && targetIndex !== -1 && targetIndex <= targetParent.rightNodeCount - 1;
|
|
3327
3349
|
const isBothOnRight = isActiveOnRight && isTargetOnRight;
|
|
3328
3350
|
const rootChildCount = (_a = mindComponent.root.children) === null || _a === void 0 ? void 0 : _a.length;
|
|
3329
3351
|
const rootRightNodeCount = mindComponent === null || mindComponent === void 0 ? void 0 : mindComponent.root.origin.rightNodeCount;
|
|
3330
3352
|
if (!isBothOnRight) {
|
|
3331
3353
|
if (isActiveOnRight) {
|
|
3332
3354
|
rightNodeCount = rootChildCount < rootRightNodeCount ? rootChildCount - 1 : rootRightNodeCount - 1;
|
|
3333
|
-
Transforms.setNode(board, { rightNodeCount }, PlaitBoard.findPath(board,
|
|
3355
|
+
Transforms.setNode(board, { rightNodeCount }, PlaitBoard.findPath(board, activeParent));
|
|
3334
3356
|
}
|
|
3335
3357
|
if (isTargetOnRight && detectResult !== 'right') {
|
|
3336
3358
|
rightNodeCount = rootChildCount < rootRightNodeCount ? rootRightNodeCount : rootRightNodeCount + 1;
|
|
3337
|
-
|
|
3359
|
+
const parent = MindElement.getParent(targetComponent.element);
|
|
3360
|
+
Transforms.setNode(board, { rightNodeCount }, PlaitBoard.findPath(board, parent));
|
|
3338
3361
|
}
|
|
3339
3362
|
//二级子节点拖动到根节点左侧
|
|
3340
3363
|
if (targetComponent.node.origin.isRoot && detectResult === 'left' && activeIndex === -1) {
|
|
@@ -3377,8 +3400,8 @@ const withDnd = (board) => {
|
|
|
3377
3400
|
return;
|
|
3378
3401
|
}
|
|
3379
3402
|
if (PlaitMind.isMind(value)) {
|
|
3380
|
-
const
|
|
3381
|
-
const root =
|
|
3403
|
+
const mindComponent = ELEMENT_TO_COMPONENT.get(value);
|
|
3404
|
+
const root = mindComponent.root;
|
|
3382
3405
|
root.eachNode((node) => {
|
|
3383
3406
|
if (activeElement) {
|
|
3384
3407
|
return;
|
|
@@ -3428,14 +3451,20 @@ const withDnd = (board) => {
|
|
|
3428
3451
|
const offsetX = endPoint[0] - startPoint[0];
|
|
3429
3452
|
const offsetY = endPoint[1] - startPoint[1];
|
|
3430
3453
|
const activeComponent = PlaitElement.getComponent(activeElement);
|
|
3431
|
-
const roughSVG = PlaitBoard.getRoughSVG(board);
|
|
3432
3454
|
const fakeDraggingNode = Object.assign(Object.assign({}, activeComponent.node), { children: [], x: activeComponent.node.x + offsetX, y: activeComponent.node.y + offsetY });
|
|
3433
3455
|
const textRectangle = getRichtextRectangleByNode(board, activeComponent.node);
|
|
3434
3456
|
const fakeNodeG = drawRectangleNode(board, fakeDraggingNode);
|
|
3435
3457
|
const richtextG = (_a = activeComponent.richtextG) === null || _a === void 0 ? void 0 : _a.cloneNode(true);
|
|
3436
|
-
updateForeignObject(richtextG, textRectangle.width
|
|
3458
|
+
updateForeignObject$1(richtextG, textRectangle.width, textRectangle.height, textRectangle.x + offsetX, textRectangle.y + offsetY);
|
|
3437
3459
|
fakeDragNodeG === null || fakeDragNodeG === void 0 ? void 0 : fakeDragNodeG.append(fakeNodeG);
|
|
3438
3460
|
fakeDragNodeG === null || fakeDragNodeG === void 0 ? void 0 : fakeDragNodeG.append(richtextG);
|
|
3461
|
+
// draw emojis
|
|
3462
|
+
if (MindElement.hasEmojis(activeElement)) {
|
|
3463
|
+
const fakeEmojisG = activeComponent.emojisDrawer.g.cloneNode(true);
|
|
3464
|
+
const foreignRectangle = getEmojiForeignRectangle(board, activeElement);
|
|
3465
|
+
updateForeignObject$1(fakeEmojisG, foreignRectangle.width, foreignRectangle.height, foreignRectangle.x + offsetX, foreignRectangle.y + offsetY);
|
|
3466
|
+
fakeDragNodeG === null || fakeDragNodeG === void 0 ? void 0 : fakeDragNodeG.append(fakeEmojisG);
|
|
3467
|
+
}
|
|
3439
3468
|
// drop position detect
|
|
3440
3469
|
const { x, y } = getRectangleByNode(fakeDraggingNode);
|
|
3441
3470
|
const detectCenterPoint = [x + textRectangle.width / 2, y + textRectangle.height / 2];
|
|
@@ -3756,7 +3785,11 @@ const withMind = (board) => {
|
|
|
3756
3785
|
board.isHitSelection = (element, range) => {
|
|
3757
3786
|
if (MindElement.isMindElement(board, element) && board.selection) {
|
|
3758
3787
|
const client = getRectangleByNode(MindElement.getNode(element));
|
|
3759
|
-
|
|
3788
|
+
const isHit = RectangleClient.isHit(RectangleClient.toRectangleClient([range.anchor, range.focus]), client);
|
|
3789
|
+
if (isHit && MindElement.hasEmojis(element) && Selection.isCollapsed(range) && isHitEmojis(board, element, range.anchor)) {
|
|
3790
|
+
return false;
|
|
3791
|
+
}
|
|
3792
|
+
return isHit;
|
|
3760
3793
|
}
|
|
3761
3794
|
return isHitSelection(element, range);
|
|
3762
3795
|
};
|
|
@@ -3767,7 +3800,6 @@ const withMind = (board) => {
|
|
|
3767
3800
|
return isMovable(element);
|
|
3768
3801
|
};
|
|
3769
3802
|
board.keydown = (event) => {
|
|
3770
|
-
var _a, _b;
|
|
3771
3803
|
if (board.options.readonly || IS_TEXT_EDITABLE.get(board)) {
|
|
3772
3804
|
keydown(event);
|
|
3773
3805
|
return;
|
|
@@ -3803,31 +3835,32 @@ const withMind = (board) => {
|
|
|
3803
3835
|
if (hotkeys.isDeleteBackward(event) || hotkeys.isDeleteForward(event)) {
|
|
3804
3836
|
event.preventDefault();
|
|
3805
3837
|
deleteSelectedELements(board, selectedElements);
|
|
3806
|
-
let
|
|
3807
|
-
const firstLevelElements =
|
|
3838
|
+
let activeElement;
|
|
3839
|
+
const firstLevelElements = getFirstLevelElement(selectedElements);
|
|
3840
|
+
if (AbstractNode.isAbstract(firstLevelElements[0])) {
|
|
3841
|
+
const parent = MindElement.getParent(firstLevelElements[0]);
|
|
3842
|
+
activeElement = parent.children[firstLevelElements[0].start];
|
|
3843
|
+
}
|
|
3808
3844
|
const firstElement = firstLevelElements[0];
|
|
3809
|
-
const
|
|
3810
|
-
const
|
|
3811
|
-
|
|
3812
|
-
return findParentElement(element) && findParentElement(firstLevelElements[0]) === findParentElement(element);
|
|
3845
|
+
const firstElementParent = MindElement.findParent(firstElement);
|
|
3846
|
+
const hasSameParent = firstLevelElements.every(element => {
|
|
3847
|
+
return MindElement.findParent(element) === firstElementParent;
|
|
3813
3848
|
});
|
|
3814
|
-
if (
|
|
3815
|
-
const
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
lastNode = firstComponent === null || firstComponent === void 0 ? void 0 : firstComponent.parent.children[firstLevelElements.length];
|
|
3849
|
+
if (firstElementParent && hasSameParent && !activeElement) {
|
|
3850
|
+
const firstElementIndex = firstElementParent.children.indexOf(firstElement);
|
|
3851
|
+
const childrenCount = firstElementParent.children.length;
|
|
3852
|
+
// active parent element
|
|
3853
|
+
if (childrenCount === firstLevelElements.length) {
|
|
3854
|
+
activeElement = firstElementParent;
|
|
3821
3855
|
}
|
|
3822
|
-
else
|
|
3823
|
-
|
|
3856
|
+
else {
|
|
3857
|
+
if (firstElementIndex > 0) {
|
|
3858
|
+
activeElement = firstElementParent.children[firstElementIndex - 1];
|
|
3859
|
+
}
|
|
3824
3860
|
}
|
|
3825
3861
|
}
|
|
3826
|
-
if (
|
|
3827
|
-
|
|
3828
|
-
}
|
|
3829
|
-
if (lastNode) {
|
|
3830
|
-
addSelectedElement(board, lastNode.origin);
|
|
3862
|
+
if (activeElement) {
|
|
3863
|
+
addSelectedElement(board, activeElement);
|
|
3831
3864
|
}
|
|
3832
3865
|
return;
|
|
3833
3866
|
}
|
|
@@ -3854,8 +3887,8 @@ const withMind = (board) => {
|
|
|
3854
3887
|
const point = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3855
3888
|
board.children
|
|
3856
3889
|
.filter(value => PlaitMind.isMind(value))
|
|
3857
|
-
.forEach(
|
|
3858
|
-
depthFirstRecursion(
|
|
3890
|
+
.forEach(mindMap => {
|
|
3891
|
+
depthFirstRecursion(mindMap, node => {
|
|
3859
3892
|
if (!PlaitBoard.hasBeenTextEditing(board) && hitMindElement(board, point, node)) {
|
|
3860
3893
|
enterNodeEditing(node);
|
|
3861
3894
|
}
|
|
@@ -3867,7 +3900,7 @@ const withMind = (board) => {
|
|
|
3867
3900
|
dblclick(event);
|
|
3868
3901
|
};
|
|
3869
3902
|
board.setFragment = (data) => {
|
|
3870
|
-
const selectedElements =
|
|
3903
|
+
const selectedElements = getFirstLevelElement(getSelectedElements(board));
|
|
3871
3904
|
if (selectedElements.length) {
|
|
3872
3905
|
const elements = buildClipboardData(board, selectedElements);
|
|
3873
3906
|
setClipboardData(data, elements);
|
|
@@ -3941,5 +3974,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
3941
3974
|
* Generated bundle index. Do not edit.
|
|
3942
3975
|
*/
|
|
3943
3976
|
|
|
3944
|
-
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,
|
|
3977
|
+
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 };
|
|
3945
3978
|
//# sourceMappingURL=plait-mind.mjs.map
|