@plait/mind 0.14.0 → 0.15.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/constants/node-topic-style.d.ts +2 -0
- package/esm2020/constants/node-topic-style.mjs +3 -1
- package/esm2020/plugins/with-mind-create.mjs +3 -3
- package/esm2020/plugins/with-mind.mjs +7 -9
- package/esm2020/utils/clipboard.mjs +14 -5
- package/esm2020/utils/draw/node-link/indented-link.mjs +4 -15
- package/esm2020/utils/node/adjust-node.mjs +3 -7
- package/fesm2015/plait-mind.mjs +22 -29
- package/fesm2015/plait-mind.mjs.map +1 -1
- package/fesm2020/plait-mind.mjs +22 -29
- package/fesm2020/plait-mind.mjs.map +1 -1
- package/package.json +1 -1
- package/utils/clipboard.d.ts +1 -1
package/fesm2020/plait-mind.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Component, ChangeDetectionStrategy, NgModule, NgZone, Directive, Input, HostListener } from '@angular/core';
|
|
3
3
|
import * as i2 from '@plait/core';
|
|
4
|
-
import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, RectangleClient, PlaitElement, idCreator, isNullOrUndefined, Transforms, clearSelectedElement, addSelectedElement, PlaitBoard, depthFirstRecursion, Path, drawLinearPath, createG, updateForeignObject, PlaitNode, drawRoundRectangle, getRectangleByElements, getSelectedElements, NODE_TO_PARENT, distanceBetweenPointAndRectangle, createForeignObject, drawAbstractRoundRectangle, createText, PlaitPointerType, PlaitPluginElementComponent, NODE_TO_INDEX, PlaitModule, transformPoint, toPoint, getHitElements, distanceBetweenPointAndPoint, CLIP_BOARD_FORMAT_KEY, isMainPointer, BOARD_TO_HOST, PlaitPluginKey, throttleRAF, BoardTransforms, removeSelectedElement, PlaitHistoryBoard, hotkeys } from '@plait/core';
|
|
4
|
+
import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, RectangleClient, PlaitElement, idCreator, isNullOrUndefined, Transforms, clearSelectedElement, addSelectedElement, PlaitBoard, depthFirstRecursion, Path, drawLinearPath, drawBezierPath, createG, updateForeignObject, PlaitNode, drawRoundRectangle, getRectangleByElements, getSelectedElements, NODE_TO_PARENT, distanceBetweenPointAndRectangle, createForeignObject, drawAbstractRoundRectangle, createText, PlaitPointerType, PlaitPluginElementComponent, NODE_TO_INDEX, PlaitModule, transformPoint, toPoint, getHitElements, distanceBetweenPointAndPoint, CLIP_BOARD_FORMAT_KEY, isMainPointer, BOARD_TO_HOST, PlaitPluginKey, throttleRAF, BoardTransforms, removeSelectedElement, PlaitHistoryBoard, hotkeys } from '@plait/core';
|
|
5
5
|
import { MindLayoutType, isIndentedLayout, getNonAbstractChildren, isStandardLayout, AbstractNode, isLeftLayout, isRightLayout, isVerticalLogicLayout, isHorizontalLogicLayout, isTopLayout, isBottomLayout, isHorizontalLayout, getCorrectStartEnd, getAbstractLayout, ConnectingPosition, GlobalLayout } from '@plait/layouts';
|
|
6
6
|
import { TEXT_DEFAULT_HEIGHT, buildText, getTextSize, TextManage, TextModule, getTextFromClipboard } from '@plait/text';
|
|
7
7
|
import { fromEvent, Subject } from 'rxjs';
|
|
@@ -335,6 +335,8 @@ const TOPIC_FONT_SIZE = 14;
|
|
|
335
335
|
const ROOT_TOPIC_FONT_SIZE = 18;
|
|
336
336
|
const ROOT_TOPIC_HEIGHT = 25;
|
|
337
337
|
const TOPIC_DEFAULT_MAX_WORD_COUNT = 34;
|
|
338
|
+
const DEFAULT_FONT_FAMILY = 'PingFangSC-Regular, "PingFang SC"';
|
|
339
|
+
const BRANCH_FONT_FAMILY = 'PingFangSC-Medium, "PingFang SC"';
|
|
338
340
|
|
|
339
341
|
const createEmptyMind = (point) => {
|
|
340
342
|
const element = createMindElement('思维导图', 72, ROOT_TOPIC_HEIGHT, { layout: MindLayoutType.right });
|
|
@@ -585,10 +587,6 @@ const adjustRootToNode = (board, node) => {
|
|
|
585
587
|
delete newNode.isRoot;
|
|
586
588
|
delete newNode.rightNodeCount;
|
|
587
589
|
delete newNode.type;
|
|
588
|
-
const text = Node.string(node.data.topic.children[0]) || ' ';
|
|
589
|
-
const { width, height } = getTextSize(board, text, TOPIC_DEFAULT_MAX_WORD_COUNT);
|
|
590
|
-
newNode.width = Math.max(width, NODE_MIN_WIDTH);
|
|
591
|
-
newNode.height = height;
|
|
592
590
|
if (newNode.layout === MindLayoutType.standard) {
|
|
593
591
|
delete newNode.layout;
|
|
594
592
|
}
|
|
@@ -612,7 +610,7 @@ const adjustNodeToRoot = (board, node) => {
|
|
|
612
610
|
delete newElement?.isCollapsed;
|
|
613
611
|
const { width, height } = getTextSize(board, newElement.data.topic, TOPIC_DEFAULT_MAX_WORD_COUNT, {
|
|
614
612
|
fontSize: ROOT_TOPIC_FONT_SIZE,
|
|
615
|
-
fontFamily:
|
|
613
|
+
fontFamily: BRANCH_FONT_FAMILY
|
|
616
614
|
});
|
|
617
615
|
newElement.width = Math.max(width, NODE_MIN_WIDTH);
|
|
618
616
|
newElement.height = height;
|
|
@@ -1106,15 +1104,6 @@ function drawIndentedLink(board, node, child, defaultStroke = null, needDrawUnde
|
|
|
1106
1104
|
endY = isUnderlineShape ? endNode.y + endNode.height - endNode.vGap : endNode.y + endNode.height / 2;
|
|
1107
1105
|
//根据位置,设置正负参数
|
|
1108
1106
|
let plusMinus = isChildUp(node, child) ? (node.left ? [-1, -1] : [1, -1]) : node.left ? [-1, 1] : [1, 1];
|
|
1109
|
-
const layout = MindQueries.getCorrectLayoutByElement(board, node.origin);
|
|
1110
|
-
if (beginNode.origin.isRoot) {
|
|
1111
|
-
if (layout === MindLayoutType.leftBottomIndented || layout === MindLayoutType.rightBottomIndented) {
|
|
1112
|
-
beginY += branchWidth;
|
|
1113
|
-
}
|
|
1114
|
-
if (layout === MindLayoutType.leftTopIndented || layout === MindLayoutType.rightTopIndented) {
|
|
1115
|
-
beginY -= branchWidth;
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
1107
|
let curve = [
|
|
1119
1108
|
[beginX, beginY],
|
|
1120
1109
|
[beginX, beginY],
|
|
@@ -1136,8 +1125,8 @@ function drawIndentedLink(board, node, child, defaultStroke = null, needDrawUnde
|
|
|
1136
1125
|
];
|
|
1137
1126
|
return drawLinearPath(polylinePoints, { stroke: branchColor, strokeWidth: branchWidth });
|
|
1138
1127
|
}
|
|
1139
|
-
const points = pointsOnBezierCurves(curve);
|
|
1140
|
-
return
|
|
1128
|
+
const points = pointsOnBezierCurves(curve, 0.001);
|
|
1129
|
+
return drawBezierPath(points, { stroke: branchColor, strokeWidth: branchWidth });
|
|
1141
1130
|
}
|
|
1142
1131
|
|
|
1143
1132
|
function drawLogicLink(board, parent, node, isHorizontal, defaultStroke = null, defaultStrokeWidth) {
|
|
@@ -3190,6 +3179,10 @@ const insertClipboardData = (board, elements, targetPoint) => {
|
|
|
3190
3179
|
if (hasTargetParent) {
|
|
3191
3180
|
if (item.isRoot) {
|
|
3192
3181
|
newElement = adjustRootToNode(board, newElement);
|
|
3182
|
+
const styles = PlaitMind.isMind(targetParent) ? { fontFamily: BRANCH_FONT_FAMILY } : { fontFamily: DEFAULT_FONT_FAMILY };
|
|
3183
|
+
const { width, height } = getTextSize(board, newElement.data.topic, TOPIC_DEFAULT_MAX_WORD_COUNT, styles);
|
|
3184
|
+
newElement.width = Math.max(width, NODE_MIN_WIDTH);
|
|
3185
|
+
newElement.height = height;
|
|
3193
3186
|
}
|
|
3194
3187
|
// handle abstract start and end
|
|
3195
3188
|
if (AbstractNode.isAbstract(newElement)) {
|
|
@@ -3215,10 +3208,11 @@ const insertClipboardData = (board, elements, targetPoint) => {
|
|
|
3215
3208
|
});
|
|
3216
3209
|
Transforms.setSelectionWithTemporaryElements(board, newELements);
|
|
3217
3210
|
};
|
|
3218
|
-
const insertClipboardText = (board,
|
|
3211
|
+
const insertClipboardText = (board, targetParent, text) => {
|
|
3212
|
+
const styles = PlaitMind.isMind(targetParent) ? { fontFamily: BRANCH_FONT_FAMILY } : { fontFamily: DEFAULT_FONT_FAMILY };
|
|
3213
|
+
const { width, height } = getTextSize(board, text, TOPIC_DEFAULT_MAX_WORD_COUNT, styles);
|
|
3219
3214
|
const newElement = createMindElement(text, width, height, {});
|
|
3220
|
-
|
|
3221
|
-
Transforms.insertNode(board, newElement, path);
|
|
3215
|
+
Transforms.insertNode(board, newElement, findNewChildNodePath(board, targetParent));
|
|
3222
3216
|
return;
|
|
3223
3217
|
};
|
|
3224
3218
|
|
|
@@ -3361,7 +3355,7 @@ const withCreateMind = (board) => {
|
|
|
3361
3355
|
}
|
|
3362
3356
|
if (PlaitBoard.isPointer(board, MindPointerType.mind)) {
|
|
3363
3357
|
throttleRAF(() => {
|
|
3364
|
-
const movingPoint = PlaitBoard.
|
|
3358
|
+
const movingPoint = PlaitBoard.getMovingPointInBoard(board);
|
|
3365
3359
|
if (movingPoint) {
|
|
3366
3360
|
const targetPoint = transformPoint(board, toPoint(movingPoint[0], movingPoint[1], PlaitBoard.getHost(board)));
|
|
3367
3361
|
const emptyMind = createEmptyMind(targetPoint);
|
|
@@ -3403,7 +3397,7 @@ const withCreateMind = (board) => {
|
|
|
3403
3397
|
mousemove(event);
|
|
3404
3398
|
};
|
|
3405
3399
|
newBoard.mouseup = (event) => {
|
|
3406
|
-
const movingPoint = PlaitBoard.
|
|
3400
|
+
const movingPoint = PlaitBoard.getMovingPointInBoard(board);
|
|
3407
3401
|
if (movingPoint && fakeCreateNodeRef && PlaitBoard.isPointer(board, MindPointerType.mind)) {
|
|
3408
3402
|
const targetPoint = transformPoint(board, toPoint(movingPoint[0], movingPoint[1], PlaitBoard.getHost(board)));
|
|
3409
3403
|
const emptyMind = createEmptyMind(targetPoint);
|
|
@@ -3698,13 +3692,12 @@ const withMind = (board) => {
|
|
|
3698
3692
|
insertClipboardData(board, elements, targetPoint || [0, 0]);
|
|
3699
3693
|
}
|
|
3700
3694
|
else {
|
|
3701
|
-
const text = getTextFromClipboard(data);
|
|
3702
|
-
const { width, height } = getTextSize(board, text, TOPIC_DEFAULT_MAX_WORD_COUNT, {
|
|
3703
|
-
fontFamily: 'PingFangSC-Regular, "PingFang SC"'
|
|
3704
|
-
});
|
|
3705
3695
|
const selectedElements = getSelectedElements(board);
|
|
3706
|
-
if (
|
|
3707
|
-
|
|
3696
|
+
if (selectedElements.length === 1) {
|
|
3697
|
+
const text = getTextFromClipboard(data);
|
|
3698
|
+
if (text) {
|
|
3699
|
+
insertClipboardText(board, selectedElements[0], buildText(text));
|
|
3700
|
+
}
|
|
3708
3701
|
}
|
|
3709
3702
|
}
|
|
3710
3703
|
insertFragment(data, targetPoint);
|
|
@@ -3773,5 +3766,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
3773
3766
|
* Generated bundle index. Do not edit.
|
|
3774
3767
|
*/
|
|
3775
3768
|
|
|
3776
|
-
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_WIDTH, BaseDrawer, BranchShape, DefaultAbstractNodeStyle, DefaultNodeStyle, ELEMENT_TO_NODE, EXTEND_DIAMETER, EXTEND_OFFSET, GRAY_COLOR, INHERIT_ATTRIBUTE_KEYS, IS_DRAGGING, LayoutDirection, LayoutDirectionsMap, MindColorfulThemeColor, MindDarkThemeColor, MindDefaultThemeColor, MindElement, MindElementShape, MindEmojiBaseComponent, MindModule, MindNode, MindNodeComponent, MindPointerType, MindQueries, MindRetroThemeColor, MindSoftThemeColor, MindStarryThemeColor, MindThemeColor, MindThemeColors, MindTransforms, NODE_MIN_WIDTH, PRIMARY_COLOR, PlaitMind, PlaitMindComponent, QUICK_INSERT_CIRCLE_COLOR, QUICK_INSERT_CIRCLE_OFFSET, QUICK_INSERT_INNER_CROSS_COLOR, ROOT_TOPIC_FONT_SIZE, ROOT_TOPIC_HEIGHT, STROKE_WIDTH, TOPIC_COLOR, TOPIC_DEFAULT_MAX_WORD_COUNT, TOPIC_FONT_SIZE, TRANSPARENT, addActiveOnDragOrigin, adjustAbstractToNode, adjustNodeToRoot, adjustRootToNode, canSetAbstract, copyNewNode, correctLayoutByDirection, createDefaultMind, createEmptyMind, createMindElement, deleteElementHandleAbstract, deleteElementsHandleRightNodeCount, detectDropTarget, directionCorrector, directionDetector, divideElementByParent, drawFakeDragNode, drawFakeDropNode, editTopic, extractNodesText, findLastChild, findLocationLeftIndex, getAbstractBranchColor, getAbstractBranchWidth, getAbstractHandleRectangle, getAllowedDirection, getAvailableSubLayoutsByLayoutDirections, getBehindAbstracts, getBranchColorByMindElement, getBranchDirectionsByLayouts, getBranchShapeByMindElement, getBranchWidthByMindElement, getChildrenCount, getCorrespondingAbstract, getDefaultBranchColor, getDefaultBranchColorByIndex, getDefaultLayout, getEmojiForeignRectangle, getEmojiRectangle, getFirstLevelElement, getHitAbstractHandle, getInCorrectLayoutDirection, getLayoutDirection$1 as getLayoutDirection, getLayoutReverseDirection, getLocationScope, getMindThemeColor, getNextBranchColor, getOverallAbstracts, getPathByDropTarget, getRectangleByElement, getRectangleByNode, getRectangleByResizingLocation, getRelativeStartEndByAbstractRef, getRootLayout, getShapeByElement, getStrokeByMindElement, getTopicRectangleByElement, getTopicRectangleByNode, getValidAbstractRefs, handleTouchedAbstract, hasAfterDraw, hasPreviousOrNextOfDropPath, insertElementHandleAbstract, insertElementHandleRightNodeCount, insertMindElement, isChildElement, isChildRight, isChildUp, isCorrectLayout, isDragging, isDropStandardRight, isHitEmojis, isHitMindElement, isInRightBranchOfStandardLayout, isMixedLayout, isSetAbstract, isValidTarget, isVirtualKey, removeActiveOnDragOrigin, separateChildren, setIsDragging, withMind, withMindExtend };
|
|
3769
|
+
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_FONT_FAMILY, BRANCH_WIDTH, BaseDrawer, BranchShape, DEFAULT_FONT_FAMILY, DefaultAbstractNodeStyle, DefaultNodeStyle, ELEMENT_TO_NODE, EXTEND_DIAMETER, EXTEND_OFFSET, GRAY_COLOR, INHERIT_ATTRIBUTE_KEYS, IS_DRAGGING, LayoutDirection, LayoutDirectionsMap, MindColorfulThemeColor, MindDarkThemeColor, MindDefaultThemeColor, MindElement, MindElementShape, MindEmojiBaseComponent, MindModule, MindNode, MindNodeComponent, MindPointerType, MindQueries, MindRetroThemeColor, MindSoftThemeColor, MindStarryThemeColor, MindThemeColor, MindThemeColors, MindTransforms, NODE_MIN_WIDTH, PRIMARY_COLOR, PlaitMind, PlaitMindComponent, QUICK_INSERT_CIRCLE_COLOR, QUICK_INSERT_CIRCLE_OFFSET, QUICK_INSERT_INNER_CROSS_COLOR, ROOT_TOPIC_FONT_SIZE, ROOT_TOPIC_HEIGHT, STROKE_WIDTH, TOPIC_COLOR, TOPIC_DEFAULT_MAX_WORD_COUNT, TOPIC_FONT_SIZE, TRANSPARENT, addActiveOnDragOrigin, adjustAbstractToNode, adjustNodeToRoot, adjustRootToNode, canSetAbstract, copyNewNode, correctLayoutByDirection, createDefaultMind, createEmptyMind, createMindElement, deleteElementHandleAbstract, deleteElementsHandleRightNodeCount, detectDropTarget, directionCorrector, directionDetector, divideElementByParent, drawFakeDragNode, drawFakeDropNode, editTopic, extractNodesText, findLastChild, findLocationLeftIndex, getAbstractBranchColor, getAbstractBranchWidth, getAbstractHandleRectangle, getAllowedDirection, getAvailableSubLayoutsByLayoutDirections, getBehindAbstracts, getBranchColorByMindElement, getBranchDirectionsByLayouts, getBranchShapeByMindElement, getBranchWidthByMindElement, getChildrenCount, getCorrespondingAbstract, getDefaultBranchColor, getDefaultBranchColorByIndex, getDefaultLayout, getEmojiForeignRectangle, getEmojiRectangle, getFirstLevelElement, getHitAbstractHandle, getInCorrectLayoutDirection, getLayoutDirection$1 as getLayoutDirection, getLayoutReverseDirection, getLocationScope, getMindThemeColor, getNextBranchColor, getOverallAbstracts, getPathByDropTarget, getRectangleByElement, getRectangleByNode, getRectangleByResizingLocation, getRelativeStartEndByAbstractRef, getRootLayout, getShapeByElement, getStrokeByMindElement, getTopicRectangleByElement, getTopicRectangleByNode, getValidAbstractRefs, handleTouchedAbstract, hasAfterDraw, hasPreviousOrNextOfDropPath, insertElementHandleAbstract, insertElementHandleRightNodeCount, insertMindElement, isChildElement, isChildRight, isChildUp, isCorrectLayout, isDragging, isDropStandardRight, isHitEmojis, isHitMindElement, isInRightBranchOfStandardLayout, isMixedLayout, isSetAbstract, isValidTarget, isVirtualKey, removeActiveOnDragOrigin, separateChildren, setIsDragging, withMind, withMindExtend };
|
|
3777
3770
|
//# sourceMappingURL=plait-mind.mjs.map
|