@plait/mind 0.7.0 → 0.8.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/esm2020/node.component.mjs +2 -2
- package/esm2020/plugins/with-node-dnd.mjs +2 -1
- package/esm2020/transforms/node.mjs +4 -2
- package/esm2020/utils/dnd/detector.mjs +8 -6
- package/esm2020/utils/draw/node-link/abstract-link.mjs +2 -2
- package/esm2020/utils/draw/node-link/indented-link.mjs +4 -3
- package/esm2020/utils/draw/node-link/logic-link.mjs +3 -3
- package/esm2020/utils/node-style/branch.mjs +3 -4
- package/fesm2015/plait-mind.mjs +21 -15
- package/fesm2015/plait-mind.mjs.map +1 -1
- package/fesm2020/plait-mind.mjs +19 -14
- package/fesm2020/plait-mind.mjs.map +1 -1
- package/package.json +1 -1
package/fesm2020/plait-mind.mjs
CHANGED
|
@@ -591,8 +591,7 @@ const getAvailableProperty = (board, element, propertyKey) => {
|
|
|
591
591
|
*/
|
|
592
592
|
const getBranchColorByMindElement = (board, element) => {
|
|
593
593
|
const branchColor = getAvailableProperty(board, element, 'branchColor');
|
|
594
|
-
|
|
595
|
-
return parentBranchColor || branchColor || getDefaultBranchColor(board, element);
|
|
594
|
+
return branchColor || getDefaultBranchColor(board, element);
|
|
596
595
|
};
|
|
597
596
|
const getBranchShapeByMindElement = (board, element) => {
|
|
598
597
|
const branchShape = getAvailableProperty(board, element, 'branchShape');
|
|
@@ -864,11 +863,13 @@ const getPathByDropTarget = (board, dropTarget) => {
|
|
|
864
863
|
}
|
|
865
864
|
// 水平布局/标准布局:上下是兄弟节点,左右是子节点
|
|
866
865
|
if (isHorizontalLogicLayout(layout)) {
|
|
867
|
-
if (dropTarget.detectResult === 'right'
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
866
|
+
if (dropTarget.detectResult === 'right') {
|
|
867
|
+
if (PlaitMind.isMind(dropTarget?.target) && isStandardLayout(layout)) {
|
|
868
|
+
targetPath.push(dropTarget?.target.rightNodeCount);
|
|
869
|
+
}
|
|
870
|
+
else {
|
|
871
|
+
targetPath.push(children.length);
|
|
872
|
+
}
|
|
872
873
|
}
|
|
873
874
|
if (dropTarget.detectResult === 'left') {
|
|
874
875
|
targetPath.push(children.length);
|
|
@@ -1047,7 +1048,7 @@ const transformPlacement = (placement, direction) => {
|
|
|
1047
1048
|
function drawIndentedLink(board, node, child, defaultStroke = null, needDrawUnderline = true, defaultStrokeWidth) {
|
|
1048
1049
|
const branchShape = getBranchShapeByMindElement(board, node.origin);
|
|
1049
1050
|
const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board, node.origin);
|
|
1050
|
-
const branchColor = defaultStroke || getBranchColorByMindElement(board, child.origin);
|
|
1051
|
+
const branchColor = defaultStroke || node.origin?.branchColor || getBranchColorByMindElement(board, child.origin);
|
|
1051
1052
|
const isUnderlineShape = getShapeByElement(board, child.origin) === MindElementShape.underline;
|
|
1052
1053
|
let beginX, beginY, endX, endY, beginNode = node, endNode = child;
|
|
1053
1054
|
const beginRectangle = getRectangleByNode(beginNode);
|
|
@@ -1083,7 +1084,8 @@ function drawIndentedLink(board, node, child, defaultStroke = null, needDrawUnde
|
|
|
1083
1084
|
const polylinePoints = [
|
|
1084
1085
|
[beginX, beginY],
|
|
1085
1086
|
[beginX, endY],
|
|
1086
|
-
[endX, endY]
|
|
1087
|
+
[endX, endY],
|
|
1088
|
+
isUnderlineShape && needDrawUnderline ? [endX + (endNode.width - endNode.hGap * 2) * plusMinus[0], endY] : [endX, endY]
|
|
1087
1089
|
];
|
|
1088
1090
|
return drawLinearPath(polylinePoints, { stroke: branchColor, strokeWidth: branchWidth });
|
|
1089
1091
|
}
|
|
@@ -1093,9 +1095,9 @@ function drawIndentedLink(board, node, child, defaultStroke = null, needDrawUnde
|
|
|
1093
1095
|
|
|
1094
1096
|
function drawLogicLink(board, parent, node, isHorizontal, defaultStroke = null, defaultStrokeWidth) {
|
|
1095
1097
|
const branchShape = getBranchShapeByMindElement(board, parent.origin);
|
|
1096
|
-
const branchColor = defaultStroke || getBranchColorByMindElement(board, node.origin);
|
|
1098
|
+
const branchColor = defaultStroke || parent.origin?.branchColor || getBranchColorByMindElement(board, node.origin);
|
|
1097
1099
|
const branchWidth = defaultStrokeWidth || getBranchWidthByMindElement(board, parent.origin);
|
|
1098
|
-
const hasStraightLine = !parent.origin.isRoot;
|
|
1100
|
+
const hasStraightLine = branchShape === BranchShape.polyline ? true : !parent.origin.isRoot;
|
|
1099
1101
|
const parentShape = getShapeByElement(board, parent.origin);
|
|
1100
1102
|
const shape = node.origin.shape ? node.origin.shape : parentShape;
|
|
1101
1103
|
const hasUnderlineShape = shape === MindElementShape.underline;
|
|
@@ -2009,7 +2011,7 @@ function drawAbstractLink(board, node, isHorizontal) {
|
|
|
2009
2011
|
const branchWidth = getAbstractBranchWidth(board, node.origin);
|
|
2010
2012
|
const branchColor = getAbstractBranchColor(board, node.origin);
|
|
2011
2013
|
const parent = node.parent;
|
|
2012
|
-
const branchShape = getBranchShapeByMindElement(board,
|
|
2014
|
+
const branchShape = getBranchShapeByMindElement(board, node.origin);
|
|
2013
2015
|
const abstractRectangle = getRectangleByNode(node);
|
|
2014
2016
|
let includedElements = parent.children.slice(node.origin.start, node.origin.end + 1).map(node => {
|
|
2015
2017
|
return node.origin;
|
|
@@ -2226,7 +2228,9 @@ const setTopicSize = (board, element, width, height) => {
|
|
|
2226
2228
|
height: height / board.viewport.zoom
|
|
2227
2229
|
};
|
|
2228
2230
|
const path = PlaitBoard.findPath(board, element);
|
|
2229
|
-
|
|
2231
|
+
if (newElement.width !== element.width || newElement.height !== element.height) {
|
|
2232
|
+
Transforms.setNode(board, newElement, path);
|
|
2233
|
+
}
|
|
2230
2234
|
};
|
|
2231
2235
|
const removeElements = (board, elements) => {
|
|
2232
2236
|
const deletableElements = getFirstLevelElement(elements);
|
|
@@ -2969,7 +2973,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2969
2973
|
const hideCircleG = this.roughSVG.circle(extendLineXY[1][0] + circleOffset[0], extendLineXY[1][1] + circleOffset[1], EXTEND_RADIUS - 1, {
|
|
2970
2974
|
fill: '#fff',
|
|
2971
2975
|
stroke,
|
|
2972
|
-
strokeWidth: branchWidth,
|
|
2976
|
+
strokeWidth: branchWidth > 3 ? 3 : branchWidth,
|
|
2973
2977
|
fillStyle: 'solid'
|
|
2974
2978
|
});
|
|
2975
2979
|
collapseG.appendChild(hideCircleG);
|
|
@@ -3322,6 +3326,7 @@ const withDnd = (board) => {
|
|
|
3322
3326
|
});
|
|
3323
3327
|
if (activeElements.length) {
|
|
3324
3328
|
correspondingElements = getOverallAbstracts(board, activeElements);
|
|
3329
|
+
event.preventDefault();
|
|
3325
3330
|
}
|
|
3326
3331
|
mousedown(event);
|
|
3327
3332
|
};
|