@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/fesm2015/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';
|
|
@@ -305,6 +305,8 @@ const TOPIC_FONT_SIZE = 14;
|
|
|
305
305
|
const ROOT_TOPIC_FONT_SIZE = 18;
|
|
306
306
|
const ROOT_TOPIC_HEIGHT = 25;
|
|
307
307
|
const TOPIC_DEFAULT_MAX_WORD_COUNT = 34;
|
|
308
|
+
const DEFAULT_FONT_FAMILY = 'PingFangSC-Regular, "PingFang SC"';
|
|
309
|
+
const BRANCH_FONT_FAMILY = 'PingFangSC-Medium, "PingFang SC"';
|
|
308
310
|
|
|
309
311
|
const createEmptyMind = (point) => {
|
|
310
312
|
const element = createMindElement('思维导图', 72, ROOT_TOPIC_HEIGHT, { layout: MindLayoutType.right });
|
|
@@ -555,10 +557,6 @@ const adjustRootToNode = (board, node) => {
|
|
|
555
557
|
delete newNode.isRoot;
|
|
556
558
|
delete newNode.rightNodeCount;
|
|
557
559
|
delete newNode.type;
|
|
558
|
-
const text = Node.string(node.data.topic.children[0]) || ' ';
|
|
559
|
-
const { width, height } = getTextSize(board, text, TOPIC_DEFAULT_MAX_WORD_COUNT);
|
|
560
|
-
newNode.width = Math.max(width, NODE_MIN_WIDTH);
|
|
561
|
-
newNode.height = height;
|
|
562
560
|
if (newNode.layout === MindLayoutType.standard) {
|
|
563
561
|
delete newNode.layout;
|
|
564
562
|
}
|
|
@@ -583,7 +581,7 @@ const adjustNodeToRoot = (board, node) => {
|
|
|
583
581
|
newElement === null || newElement === void 0 ? true : delete newElement.isCollapsed;
|
|
584
582
|
const { width, height } = getTextSize(board, newElement.data.topic, TOPIC_DEFAULT_MAX_WORD_COUNT, {
|
|
585
583
|
fontSize: ROOT_TOPIC_FONT_SIZE,
|
|
586
|
-
fontFamily:
|
|
584
|
+
fontFamily: BRANCH_FONT_FAMILY
|
|
587
585
|
});
|
|
588
586
|
newElement.width = Math.max(width, NODE_MIN_WIDTH);
|
|
589
587
|
newElement.height = height;
|
|
@@ -1073,15 +1071,6 @@ function drawIndentedLink(board, node, child, defaultStroke = null, needDrawUnde
|
|
|
1073
1071
|
endY = isUnderlineShape ? endNode.y + endNode.height - endNode.vGap : endNode.y + endNode.height / 2;
|
|
1074
1072
|
//根据位置,设置正负参数
|
|
1075
1073
|
let plusMinus = isChildUp(node, child) ? (node.left ? [-1, -1] : [1, -1]) : node.left ? [-1, 1] : [1, 1];
|
|
1076
|
-
const layout = MindQueries.getCorrectLayoutByElement(board, node.origin);
|
|
1077
|
-
if (beginNode.origin.isRoot) {
|
|
1078
|
-
if (layout === MindLayoutType.leftBottomIndented || layout === MindLayoutType.rightBottomIndented) {
|
|
1079
|
-
beginY += branchWidth;
|
|
1080
|
-
}
|
|
1081
|
-
if (layout === MindLayoutType.leftTopIndented || layout === MindLayoutType.rightTopIndented) {
|
|
1082
|
-
beginY -= branchWidth;
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
1074
|
let curve = [
|
|
1086
1075
|
[beginX, beginY],
|
|
1087
1076
|
[beginX, beginY],
|
|
@@ -1103,8 +1092,8 @@ function drawIndentedLink(board, node, child, defaultStroke = null, needDrawUnde
|
|
|
1103
1092
|
];
|
|
1104
1093
|
return drawLinearPath(polylinePoints, { stroke: branchColor, strokeWidth: branchWidth });
|
|
1105
1094
|
}
|
|
1106
|
-
const points = pointsOnBezierCurves(curve);
|
|
1107
|
-
return
|
|
1095
|
+
const points = pointsOnBezierCurves(curve, 0.001);
|
|
1096
|
+
return drawBezierPath(points, { stroke: branchColor, strokeWidth: branchWidth });
|
|
1108
1097
|
}
|
|
1109
1098
|
|
|
1110
1099
|
function drawLogicLink(board, parent, node, isHorizontal, defaultStroke = null, defaultStrokeWidth) {
|
|
@@ -3122,6 +3111,10 @@ const insertClipboardData = (board, elements, targetPoint) => {
|
|
|
3122
3111
|
if (hasTargetParent) {
|
|
3123
3112
|
if (item.isRoot) {
|
|
3124
3113
|
newElement = adjustRootToNode(board, newElement);
|
|
3114
|
+
const styles = PlaitMind.isMind(targetParent) ? { fontFamily: BRANCH_FONT_FAMILY } : { fontFamily: DEFAULT_FONT_FAMILY };
|
|
3115
|
+
const { width, height } = getTextSize(board, newElement.data.topic, TOPIC_DEFAULT_MAX_WORD_COUNT, styles);
|
|
3116
|
+
newElement.width = Math.max(width, NODE_MIN_WIDTH);
|
|
3117
|
+
newElement.height = height;
|
|
3125
3118
|
}
|
|
3126
3119
|
// handle abstract start and end
|
|
3127
3120
|
if (AbstractNode.isAbstract(newElement)) {
|
|
@@ -3147,10 +3140,11 @@ const insertClipboardData = (board, elements, targetPoint) => {
|
|
|
3147
3140
|
});
|
|
3148
3141
|
Transforms.setSelectionWithTemporaryElements(board, newELements);
|
|
3149
3142
|
};
|
|
3150
|
-
const insertClipboardText = (board,
|
|
3143
|
+
const insertClipboardText = (board, targetParent, text) => {
|
|
3144
|
+
const styles = PlaitMind.isMind(targetParent) ? { fontFamily: BRANCH_FONT_FAMILY } : { fontFamily: DEFAULT_FONT_FAMILY };
|
|
3145
|
+
const { width, height } = getTextSize(board, text, TOPIC_DEFAULT_MAX_WORD_COUNT, styles);
|
|
3151
3146
|
const newElement = createMindElement(text, width, height, {});
|
|
3152
|
-
|
|
3153
|
-
Transforms.insertNode(board, newElement, path);
|
|
3147
|
+
Transforms.insertNode(board, newElement, findNewChildNodePath(board, targetParent));
|
|
3154
3148
|
return;
|
|
3155
3149
|
};
|
|
3156
3150
|
|
|
@@ -3293,7 +3287,7 @@ const withCreateMind = (board) => {
|
|
|
3293
3287
|
}
|
|
3294
3288
|
if (PlaitBoard.isPointer(board, MindPointerType.mind)) {
|
|
3295
3289
|
throttleRAF(() => {
|
|
3296
|
-
const movingPoint = PlaitBoard.
|
|
3290
|
+
const movingPoint = PlaitBoard.getMovingPointInBoard(board);
|
|
3297
3291
|
if (movingPoint) {
|
|
3298
3292
|
const targetPoint = transformPoint(board, toPoint(movingPoint[0], movingPoint[1], PlaitBoard.getHost(board)));
|
|
3299
3293
|
const emptyMind = createEmptyMind(targetPoint);
|
|
@@ -3335,7 +3329,7 @@ const withCreateMind = (board) => {
|
|
|
3335
3329
|
mousemove(event);
|
|
3336
3330
|
};
|
|
3337
3331
|
newBoard.mouseup = (event) => {
|
|
3338
|
-
const movingPoint = PlaitBoard.
|
|
3332
|
+
const movingPoint = PlaitBoard.getMovingPointInBoard(board);
|
|
3339
3333
|
if (movingPoint && fakeCreateNodeRef && PlaitBoard.isPointer(board, MindPointerType.mind)) {
|
|
3340
3334
|
const targetPoint = transformPoint(board, toPoint(movingPoint[0], movingPoint[1], PlaitBoard.getHost(board)));
|
|
3341
3335
|
const emptyMind = createEmptyMind(targetPoint);
|
|
@@ -3630,13 +3624,12 @@ const withMind = (board) => {
|
|
|
3630
3624
|
insertClipboardData(board, elements, targetPoint || [0, 0]);
|
|
3631
3625
|
}
|
|
3632
3626
|
else {
|
|
3633
|
-
const text = getTextFromClipboard(data);
|
|
3634
|
-
const { width, height } = getTextSize(board, text, TOPIC_DEFAULT_MAX_WORD_COUNT, {
|
|
3635
|
-
fontFamily: 'PingFangSC-Regular, "PingFang SC"'
|
|
3636
|
-
});
|
|
3637
3627
|
const selectedElements = getSelectedElements(board);
|
|
3638
|
-
if (
|
|
3639
|
-
|
|
3628
|
+
if (selectedElements.length === 1) {
|
|
3629
|
+
const text = getTextFromClipboard(data);
|
|
3630
|
+
if (text) {
|
|
3631
|
+
insertClipboardText(board, selectedElements[0], buildText(text));
|
|
3632
|
+
}
|
|
3640
3633
|
}
|
|
3641
3634
|
}
|
|
3642
3635
|
insertFragment(data, targetPoint);
|
|
@@ -3705,5 +3698,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.5", ngImpor
|
|
|
3705
3698
|
* Generated bundle index. Do not edit.
|
|
3706
3699
|
*/
|
|
3707
3700
|
|
|
3708
|
-
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 };
|
|
3701
|
+
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 };
|
|
3709
3702
|
//# sourceMappingURL=plait-mind.mjs.map
|