@plait/mind 0.75.0 → 0.77.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/default.d.ts +3 -0
- package/constants/node-topic-style.d.ts +0 -2
- package/esm2022/constants/default.mjs +5 -1
- package/esm2022/constants/node-topic-style.mjs +1 -3
- package/esm2022/generators/node-active.generator.mjs +5 -4
- package/esm2022/mind-node.component.mjs +10 -5
- package/esm2022/plugins/with-abstract-resize.mjs +7 -6
- package/esm2022/plugins/with-node-image.mjs +15 -6
- package/esm2022/plugins/with-node-resize.mjs +3 -3
- package/esm2022/utils/clipboard.mjs +7 -20
- package/esm2022/utils/common.mjs +22 -0
- package/esm2022/utils/draw/abstract-outline.mjs +9 -8
- package/esm2022/utils/index.mjs +2 -1
- package/esm2022/utils/node/create-node.mjs +5 -16
- package/fesm2022/plait-mind.mjs +83 -69
- package/fesm2022/plait-mind.mjs.map +1 -1
- package/package.json +1 -1
- package/utils/clipboard.d.ts +0 -5
- package/utils/common.d.ts +8 -0
- package/utils/index.d.ts +1 -0
- package/utils/node/create-node.d.ts +0 -1
package/fesm2022/plait-mind.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DefaultThemeColor, DEFAULT_COLOR, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, PlaitElement, PlaitNode, Path, isNullOrUndefined, PlaitBoard, getSelectedElements, idCreator, Transforms, clearSelectedElement, addSelectedElement, distanceBetweenPointAndRectangle, RectangleClient, setDragging, depthFirstRecursion, getIsRecursionFunc, drawRoundRectangle, drawLinearPath, drawBezierPath, setStrokeLinecap, createG, createForeignObject, updateForeignObject, getRectangleByElements, ACTIVE_STROKE_WIDTH, SELECTION_RECTANGLE_CLASS_NAME, NODE_TO_PARENT, removeSelectedElement, PlaitHistoryBoard, createText, PlaitPointerType, NODE_TO_INDEX, isMainPointer, toViewBoxPoint, toHostPoint, getHitElementByPoint, distanceBetweenPointAndPoint, isDragging, CoreTransforms,
|
|
1
|
+
import { DefaultThemeColor, DEFAULT_COLOR, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, PlaitElement, PlaitNode, Path, isNullOrUndefined, PlaitBoard, getSelectedElements, getI18nValue, idCreator, Transforms, clearSelectedElement, addSelectedElement, distanceBetweenPointAndRectangle, RectangleClient, setDragging, depthFirstRecursion, getIsRecursionFunc, drawRoundRectangle, drawLinearPath, drawBezierPath, setStrokeLinecap, createG, createForeignObject, updateForeignObject, getRectangleByElements, toActiveRectangleFromViewBoxRectangle, ACTIVE_STROKE_WIDTH, SELECTION_RECTANGLE_CLASS_NAME, NODE_TO_PARENT, removeSelectedElement, PlaitHistoryBoard, createText, PlaitPointerType, NODE_TO_INDEX, isMainPointer, toViewBoxPoint, toHostPoint, getHitElementByPoint, distanceBetweenPointAndPoint, isDragging, CoreTransforms, toActivePointFromViewBoxPoint, BoardTransforms, throttleRAF, isContextmenu, temporaryDisableSelection, hotkeys, createClipboardContext, WritableClipboardType, ResizeCursorClass, Point, WritableClipboardOperationType, addOrCreateClipboardContext } from '@plait/core';
|
|
2
2
|
import { MindLayoutType, AbstractNode, isIndentedLayout, isHorizontalLayout, isHorizontalLogicLayout, ConnectingPosition, getNonAbstractChildren, isStandardLayout, isLeftLayout, isRightLayout, isVerticalLogicLayout, isTopLayout, isBottomLayout, getCorrectStartEnd, getAbstractLayout, GlobalLayout } from '@plait/layouts';
|
|
3
|
-
import { StrokeStyle, getFirstTextManage, buildText, getFirstTextEditor, RESIZE_HANDLE_DIAMETER, getRectangleResizeHandleRefs, addElementOfFocusedImage, ImageGenerator, removeElementOfFocusedImage, getStrokeLineDash, Generator, PropertyTransforms, CommonElementFlavour, WithTextPluginKey, TextManage, isDrawingMode, isDndMode, setCreationMode, BoardCreationMode, isExpandHotkey, isTabHotkey, isEnterHotkey, isVirtualKey, isDelete, isSpaceHotkey, getElementOfFocusedImage, acceptImageTypes, buildImage, withResize,
|
|
3
|
+
import { StrokeStyle, getFirstTextManage, measureElement, buildText, getFirstTextEditor, RESIZE_HANDLE_DIAMETER, getRectangleResizeHandleRefs, addElementOfFocusedImage, ImageGenerator, removeElementOfFocusedImage, getStrokeLineDash, Generator, PropertyTransforms, CommonElementFlavour, WithTextPluginKey, TextManage, isDrawingMode, isDndMode, setCreationMode, BoardCreationMode, isExpandHotkey, isTabHotkey, isEnterHotkey, isVirtualKey, isDelete, isSpaceHotkey, getElementOfFocusedImage, acceptImageTypes, buildImage, withResize, getElementsText } from '@plait/common';
|
|
4
4
|
import { TEXT_DEFAULT_HEIGHT, PlaitMarkEditor, MarkTypes, DEFAULT_FONT_SIZE } from '@plait/text-plugins';
|
|
5
5
|
import { Node as Node$1, Path as Path$1 } from 'slate';
|
|
6
6
|
import { pointsOnBezierCurves } from 'points-on-curve';
|
|
@@ -186,6 +186,10 @@ const QUICK_INSERT_CIRCLE_OFFSET = 9;
|
|
|
186
186
|
const QUICK_INSERT_CIRCLE_COLOR = '#6698FF';
|
|
187
187
|
const QUICK_INSERT_INNER_CROSS_COLOR = 'white';
|
|
188
188
|
const DEFAULT_MIND_IMAGE_WIDTH = 240;
|
|
189
|
+
var MindI18nKey;
|
|
190
|
+
(function (MindI18nKey) {
|
|
191
|
+
MindI18nKey["mindCentralText"] = "mind-center-text";
|
|
192
|
+
})(MindI18nKey || (MindI18nKey = {}));
|
|
189
193
|
|
|
190
194
|
function getEmojisWidthHeight(board, element) {
|
|
191
195
|
const options = board.getPluginOptions(WithMindPluginKey);
|
|
@@ -491,17 +495,6 @@ const getSelectedMindElements = (board, elements) => {
|
|
|
491
495
|
return selectedElements.filter(value => MindElement.isMindElement(board, value));
|
|
492
496
|
};
|
|
493
497
|
|
|
494
|
-
const TOPIC_FONT_SIZE = 14;
|
|
495
|
-
const ROOT_TOPIC_FONT_SIZE = 18;
|
|
496
|
-
const ROOT_TOPIC_HEIGHT = 25;
|
|
497
|
-
const ROOT_TOPIC_WIDTH = 72;
|
|
498
|
-
const TOPIC_DEFAULT_MAX_WORD_COUNT = 34;
|
|
499
|
-
const DEFAULT_FONT_FAMILY = 'PingFangSC-Regular, "PingFang SC"';
|
|
500
|
-
const BRANCH_FONT_FAMILY = 'PingFangSC-Medium, "PingFang SC"';
|
|
501
|
-
const NodeTopicThreshold = {
|
|
502
|
-
defaultTextMaxWidth: 34 * 14
|
|
503
|
-
};
|
|
504
|
-
|
|
505
498
|
const getBranchDirectionsByLayouts = (branchLayouts) => {
|
|
506
499
|
const branchDirections = [];
|
|
507
500
|
branchLayouts.forEach(l => {
|
|
@@ -669,8 +662,42 @@ const getLayoutOptions = (board) => {
|
|
|
669
662
|
};
|
|
670
663
|
};
|
|
671
664
|
|
|
665
|
+
const TOPIC_FONT_SIZE = 14;
|
|
666
|
+
const ROOT_TOPIC_FONT_SIZE = 18;
|
|
667
|
+
const TOPIC_DEFAULT_MAX_WORD_COUNT = 34;
|
|
668
|
+
const DEFAULT_FONT_FAMILY = 'PingFangSC-Regular, "PingFang SC"';
|
|
669
|
+
const BRANCH_FONT_FAMILY = 'PingFangSC-Medium, "PingFang SC"';
|
|
670
|
+
const NodeTopicThreshold = {
|
|
671
|
+
defaultTextMaxWidth: 34 * 14
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
const ABSTRACT_HANDLE_COLOR = '#6698FF80'; //primary color 50% opacity
|
|
675
|
+
const ABSTRACT_INCLUDED_OUTLINE_OFFSET = 3.5;
|
|
676
|
+
const ABSTRACT_HANDLE_LENGTH = 10;
|
|
677
|
+
const ABSTRACT_HANDLE_MASK_WIDTH = 8;
|
|
678
|
+
|
|
679
|
+
const MIND_CENTRAL_TEXT = '中心主题';
|
|
680
|
+
const getDefaultMindNameText = (board) => {
|
|
681
|
+
return getI18nValue(board, MindI18nKey.mindCentralText, MIND_CENTRAL_TEXT);
|
|
682
|
+
};
|
|
683
|
+
const getTopicSize = (isRoot, isBranch, topic, manualWidth) => {
|
|
684
|
+
let fontFamily = DEFAULT_FONT_FAMILY;
|
|
685
|
+
let fontSize = TOPIC_FONT_SIZE;
|
|
686
|
+
if (isRoot) {
|
|
687
|
+
fontFamily = BRANCH_FONT_FAMILY;
|
|
688
|
+
fontSize = ROOT_TOPIC_FONT_SIZE;
|
|
689
|
+
}
|
|
690
|
+
else if (isBranch) {
|
|
691
|
+
fontFamily = BRANCH_FONT_FAMILY;
|
|
692
|
+
}
|
|
693
|
+
const maxWidth = fontSize * TOPIC_DEFAULT_MAX_WORD_COUNT;
|
|
694
|
+
return measureElement(topic, { fontSize, fontFamily }, manualWidth ? manualWidth : maxWidth);
|
|
695
|
+
};
|
|
696
|
+
|
|
672
697
|
const createEmptyMind = (board, point) => {
|
|
673
|
-
const
|
|
698
|
+
const text = getDefaultMindNameText(board);
|
|
699
|
+
const topicSize = getTopicSize(true, false, buildText(text));
|
|
700
|
+
const element = createMindElement(text, topicSize.width, topicSize.height, { layout: MindLayoutType.right });
|
|
674
701
|
element.isRoot = true;
|
|
675
702
|
element.type = 'mindmap';
|
|
676
703
|
const width = NodeSpace.getNodeWidth(board, element);
|
|
@@ -678,18 +705,6 @@ const createEmptyMind = (board, point) => {
|
|
|
678
705
|
element.points = [[point[0] - width / 2, point[1] - height / 2]];
|
|
679
706
|
return element;
|
|
680
707
|
};
|
|
681
|
-
const createDefaultMind = (point, rightNodeCount, layout) => {
|
|
682
|
-
const root = createMindElement('思维导图', ROOT_TOPIC_WIDTH, ROOT_TOPIC_HEIGHT, { layout });
|
|
683
|
-
root.rightNodeCount = rightNodeCount;
|
|
684
|
-
root.isRoot = true;
|
|
685
|
-
root.type = 'mindmap';
|
|
686
|
-
root.points = [point];
|
|
687
|
-
const children = [1, 1, 1].map(() => {
|
|
688
|
-
return createMindElement('新建节点', 56, TEXT_DEFAULT_HEIGHT, {});
|
|
689
|
-
});
|
|
690
|
-
root.children = children;
|
|
691
|
-
return root;
|
|
692
|
-
};
|
|
693
708
|
const createMindElement = (text, width, height, options) => {
|
|
694
709
|
const newElement = {
|
|
695
710
|
id: idCreator(),
|
|
@@ -1346,11 +1361,6 @@ function drawRoundRectangleByElement(board, nodeRectangle, element) {
|
|
|
1346
1361
|
return nodeG;
|
|
1347
1362
|
}
|
|
1348
1363
|
|
|
1349
|
-
const ABSTRACT_HANDLE_COLOR = '#6698FF80'; //primary color 50% opacity
|
|
1350
|
-
const ABSTRACT_INCLUDED_OUTLINE_OFFSET = 3.5;
|
|
1351
|
-
const ABSTRACT_HANDLE_LENGTH = 10;
|
|
1352
|
-
const ABSTRACT_HANDLE_MASK_WIDTH = 8;
|
|
1353
|
-
|
|
1354
1364
|
var HorizontalPlacement;
|
|
1355
1365
|
(function (HorizontalPlacement) {
|
|
1356
1366
|
HorizontalPlacement["left"] = "left";
|
|
@@ -1820,12 +1830,13 @@ function drawAbstractIncludedOutline(board, roughSVG, element, activeHandlePosit
|
|
|
1820
1830
|
const nodeLayout = MindQueries.getCorrectLayoutByElement(board, element);
|
|
1821
1831
|
const isHorizontal = isHorizontalLayout(nodeLayout);
|
|
1822
1832
|
const includedElements = parentElement.children.slice(element.start, element.end + 1);
|
|
1823
|
-
|
|
1824
|
-
|
|
1833
|
+
const abstractRectangle = getRectangleByElements(board, includedElements, true);
|
|
1834
|
+
const activeAbstractRectangle = toActiveRectangleFromViewBoxRectangle(board, abstractRectangle);
|
|
1835
|
+
let activeAbstractOutlineRectangle = RectangleClient.getOutlineRectangle(activeAbstractRectangle, -ABSTRACT_INCLUDED_OUTLINE_OFFSET);
|
|
1825
1836
|
if (resizingLocation) {
|
|
1826
|
-
|
|
1837
|
+
activeAbstractOutlineRectangle = getRectangleByResizingLocation(activeAbstractOutlineRectangle, resizingLocation, activeHandlePosition, isHorizontal);
|
|
1827
1838
|
}
|
|
1828
|
-
const rectangle = drawAbstractRoundRectangle(roughSVG,
|
|
1839
|
+
const rectangle = drawAbstractRoundRectangle(roughSVG, activeAbstractOutlineRectangle.x, activeAbstractOutlineRectangle.y, activeAbstractOutlineRectangle.x + activeAbstractOutlineRectangle.width, activeAbstractOutlineRectangle.y + activeAbstractOutlineRectangle.height, isHorizontal, {
|
|
1829
1840
|
stroke: PRIMARY_COLOR,
|
|
1830
1841
|
strokeWidth: 1,
|
|
1831
1842
|
fillStyle: 'solid'
|
|
@@ -1835,8 +1846,8 @@ function drawAbstractIncludedOutline(board, roughSVG, element, activeHandlePosit
|
|
|
1835
1846
|
const linkDirection = getLayoutDirection(MindElement.getNode(element), isHorizontal);
|
|
1836
1847
|
transformPlacement(startPlacement, linkDirection);
|
|
1837
1848
|
transformPlacement(endPlacement, linkDirection);
|
|
1838
|
-
let startCenterPoint = getPointByPlacement(
|
|
1839
|
-
let endCenterPoint = getPointByPlacement(
|
|
1849
|
+
let startCenterPoint = getPointByPlacement(activeAbstractOutlineRectangle, startPlacement);
|
|
1850
|
+
let endCenterPoint = getPointByPlacement(activeAbstractOutlineRectangle, endPlacement);
|
|
1840
1851
|
const startPoint1 = moveXOfPoint(startCenterPoint, -ABSTRACT_HANDLE_LENGTH / 2, linkDirection);
|
|
1841
1852
|
const startPoint2 = moveXOfPoint(startCenterPoint, ABSTRACT_HANDLE_LENGTH / 2, linkDirection);
|
|
1842
1853
|
const endPoint1 = moveXOfPoint(endCenterPoint, -ABSTRACT_HANDLE_LENGTH / 2, linkDirection);
|
|
@@ -1935,10 +1946,11 @@ class NodeActiveGenerator extends Generator {
|
|
|
1935
1946
|
const activeG = createG();
|
|
1936
1947
|
const node = MindElement.getNode(element);
|
|
1937
1948
|
const rectangle = getRectangleByNode(node);
|
|
1949
|
+
const activeRectangle1 = toActiveRectangleFromViewBoxRectangle(this.board, rectangle);
|
|
1938
1950
|
const strokeWidth = getStrokeWidthByElement(this.board, element);
|
|
1939
1951
|
const activeStrokeWidth = ACTIVE_STROKE_WIDTH;
|
|
1940
|
-
const
|
|
1941
|
-
const strokeG = drawRoundRectangle(PlaitBoard.getRoughSVG(this.board),
|
|
1952
|
+
const activeRectangleWithInflated = RectangleClient.inflate(activeRectangle1, activeStrokeWidth);
|
|
1953
|
+
const strokeG = drawRoundRectangle(PlaitBoard.getRoughSVG(this.board), activeRectangleWithInflated.x, activeRectangleWithInflated.y, activeRectangleWithInflated.x + activeRectangleWithInflated.width, activeRectangleWithInflated.y + activeRectangleWithInflated.height, { stroke: PRIMARY_COLOR, strokeWidth: activeStrokeWidth, fill: '' }, true, DefaultNodeStyle.shape.rectangleRadius + (activeStrokeWidth + strokeWidth) / 2);
|
|
1942
1954
|
if (AbstractNode.isAbstract(element)) {
|
|
1943
1955
|
this.abstractOutlineG = drawAbstractIncludedOutline(this.board, PlaitBoard.getRoughSVG(this.board), element);
|
|
1944
1956
|
activeG.append(this.abstractOutlineG);
|
|
@@ -2986,6 +2998,11 @@ class MindNodeComponent extends CommonElementFlavour {
|
|
|
2986
2998
|
this.getRef().addGenerator(NodeEmojisGenerator.key, this.nodeEmojisGenerator);
|
|
2987
2999
|
this.getRef().addGenerator(ImageGenerator.key, this.imageGenerator);
|
|
2988
3000
|
this.getRef().initializeTextManage(textManage);
|
|
3001
|
+
this.getRef().updateActiveSection = () => {
|
|
3002
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
3003
|
+
selected: this.selected
|
|
3004
|
+
});
|
|
3005
|
+
};
|
|
2989
3006
|
}
|
|
2990
3007
|
initialize() {
|
|
2991
3008
|
super.initialize();
|
|
@@ -2996,7 +3013,7 @@ class MindNodeComponent extends CommonElementFlavour {
|
|
|
2996
3013
|
this.nodeShapeGenerator.processDrawing(this.element, this.getElementG(), { node: this.node });
|
|
2997
3014
|
this.drawLink();
|
|
2998
3015
|
this.drawTopic();
|
|
2999
|
-
this.activeGenerator.processDrawing(this.element, PlaitBoard.
|
|
3016
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
3000
3017
|
selected: this.selected
|
|
3001
3018
|
});
|
|
3002
3019
|
this.drawEmojis();
|
|
@@ -3011,7 +3028,7 @@ class MindNodeComponent extends CommonElementFlavour {
|
|
|
3011
3028
|
const isEqualNode = RectangleClient.isEqual(this.node, newNode);
|
|
3012
3029
|
this.node = newNode;
|
|
3013
3030
|
if (!isEqualNode || value.element !== previous.element || value.hasThemeChanged) {
|
|
3014
|
-
this.activeGenerator.processDrawing(this.element, PlaitBoard.
|
|
3031
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
3015
3032
|
selected: this.selected
|
|
3016
3033
|
});
|
|
3017
3034
|
this.nodeShapeGenerator.processDrawing(this.element, this.getElementG(), { node: this.node });
|
|
@@ -3032,8 +3049,8 @@ class MindNodeComponent extends CommonElementFlavour {
|
|
|
3032
3049
|
else {
|
|
3033
3050
|
const hasSameSelected = value.selected === previous.selected;
|
|
3034
3051
|
const hasSameParent = value.parent === previous.parent;
|
|
3035
|
-
if (!hasSameSelected) {
|
|
3036
|
-
this.activeGenerator.processDrawing(this.element, PlaitBoard.
|
|
3052
|
+
if (!hasSameSelected || value.selected) {
|
|
3053
|
+
this.activeGenerator.processDrawing(this.element, PlaitBoard.getActiveHost(this.board), {
|
|
3037
3054
|
selected: this.selected
|
|
3038
3055
|
});
|
|
3039
3056
|
}
|
|
@@ -3309,9 +3326,9 @@ const withAbstract = (board) => {
|
|
|
3309
3326
|
pointerDown(event);
|
|
3310
3327
|
return;
|
|
3311
3328
|
}
|
|
3312
|
-
const activeAbstractElements = getSelectedElements(board).filter(element => AbstractNode.isAbstract(element));
|
|
3329
|
+
const activeAbstractElements = getSelectedElements(board).filter((element) => AbstractNode.isAbstract(element));
|
|
3313
3330
|
const point = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
|
|
3314
|
-
activeAbstractElement = activeAbstractElements.find(element => {
|
|
3331
|
+
activeAbstractElement = activeAbstractElements.find((element) => {
|
|
3315
3332
|
abstractHandlePosition = getHitAbstractHandle(board, element, point);
|
|
3316
3333
|
return abstractHandlePosition;
|
|
3317
3334
|
});
|
|
@@ -3326,7 +3343,6 @@ const withAbstract = (board) => {
|
|
|
3326
3343
|
};
|
|
3327
3344
|
board.pointerMove = (event) => {
|
|
3328
3345
|
getSelectedElements(board);
|
|
3329
|
-
const host = BOARD_TO_HOST.get(board);
|
|
3330
3346
|
const endPoint = toViewBoxPoint(board, toHostPoint(board, event.x, event.y));
|
|
3331
3347
|
touchedAbstract = handleTouchedAbstract(board, touchedAbstract, endPoint);
|
|
3332
3348
|
if (abstractHandlePosition && activeAbstractElement) {
|
|
@@ -3372,7 +3388,8 @@ const withAbstract = (board) => {
|
|
|
3372
3388
|
}
|
|
3373
3389
|
const ref = PlaitElement.getElementRef(activeAbstractElement);
|
|
3374
3390
|
const activeGenerator = ref.getGenerator(NodeActiveGenerator.key);
|
|
3375
|
-
|
|
3391
|
+
const activeLocation = toActivePointFromViewBoxPoint(board, [location, location]);
|
|
3392
|
+
activeGenerator.updateAbstractOutline(activeAbstractElement, abstractHandlePosition, isHorizontal ? activeLocation[1] : activeLocation[0]);
|
|
3376
3393
|
}
|
|
3377
3394
|
pointerMove(event);
|
|
3378
3395
|
};
|
|
@@ -3393,6 +3410,7 @@ const withAbstract = (board) => {
|
|
|
3393
3410
|
activeGenerator.updateAbstractOutline(activeAbstractElement);
|
|
3394
3411
|
}
|
|
3395
3412
|
activeAbstractElement = undefined;
|
|
3413
|
+
return;
|
|
3396
3414
|
}
|
|
3397
3415
|
pointerUp(event);
|
|
3398
3416
|
};
|
|
@@ -3626,7 +3644,7 @@ const withNodeHoverHitTest = (board) => {
|
|
|
3626
3644
|
};
|
|
3627
3645
|
|
|
3628
3646
|
const withNodeImage = (board) => {
|
|
3629
|
-
const { keyDown, pointerUp, globalPointerUp, buildFragment, insertFragment, deleteFragment } = board;
|
|
3647
|
+
const { keyDown, pointerUp, globalPointerUp, buildFragment, insertFragment, deleteFragment, afterChange } = board;
|
|
3630
3648
|
board.pointerUp = (event) => {
|
|
3631
3649
|
const elementOfFocusedImage = getElementOfFocusedImage(board);
|
|
3632
3650
|
if (elementOfFocusedImage &&
|
|
@@ -3701,11 +3719,11 @@ const withNodeImage = (board) => {
|
|
|
3701
3719
|
const isSingleSelection = selectedElements.length === 1 && MindElement.isMindElement(board, selectedElements[0]);
|
|
3702
3720
|
if (isSelectedImage || isSingleSelection) {
|
|
3703
3721
|
if (clipboardData?.files?.length) {
|
|
3704
|
-
const acceptImageArray = acceptImageTypes.map(type => 'image/' + type);
|
|
3722
|
+
const acceptImageArray = acceptImageTypes.map((type) => 'image/' + type);
|
|
3705
3723
|
const selectedElement = (selectedElements[0] || getElementOfFocusedImage(board));
|
|
3706
3724
|
if (acceptImageArray.includes(clipboardData.files[0].type)) {
|
|
3707
3725
|
const imageFile = clipboardData.files[0];
|
|
3708
|
-
buildImage(board, imageFile, DEFAULT_MIND_IMAGE_WIDTH, imageItem => {
|
|
3726
|
+
buildImage(board, imageFile, DEFAULT_MIND_IMAGE_WIDTH, (imageItem) => {
|
|
3709
3727
|
MindTransforms.setImage(board, selectedElement, imageItem);
|
|
3710
3728
|
});
|
|
3711
3729
|
return;
|
|
@@ -3719,6 +3737,15 @@ const withNodeImage = (board) => {
|
|
|
3719
3737
|
}
|
|
3720
3738
|
insertFragment(clipboardData, targetPoint, operationType);
|
|
3721
3739
|
};
|
|
3740
|
+
board.afterChange = () => {
|
|
3741
|
+
afterChange();
|
|
3742
|
+
const selectedImageElement = getElementOfFocusedImage(board);
|
|
3743
|
+
if (selectedImageElement && MindElement.isMindElement(board, selectedImageElement)) {
|
|
3744
|
+
const commonElementRef = PlaitElement.getElementRef(selectedImageElement);
|
|
3745
|
+
const imageGenerator = commonElementRef.getGenerator(ImageGenerator.key);
|
|
3746
|
+
imageGenerator.setFocus(selectedImageElement, true);
|
|
3747
|
+
}
|
|
3748
|
+
};
|
|
3722
3749
|
return board;
|
|
3723
3750
|
};
|
|
3724
3751
|
|
|
@@ -3727,7 +3754,7 @@ const withNodeResize = (board) => {
|
|
|
3727
3754
|
const options = {
|
|
3728
3755
|
key: 'mind-node',
|
|
3729
3756
|
canResize: () => {
|
|
3730
|
-
return
|
|
3757
|
+
return true;
|
|
3731
3758
|
},
|
|
3732
3759
|
hitTest: (point) => {
|
|
3733
3760
|
const newTargetElement = getSelectedTarget(board, point);
|
|
@@ -3832,15 +3859,15 @@ const buildClipboardData = (board, selectedElements, startPoint) => {
|
|
|
3832
3859
|
// get valid abstract refs
|
|
3833
3860
|
const validAbstractRefs = getValidAbstractRefs(board, [...selectedElements, ...overallAbstracts]);
|
|
3834
3861
|
// keep correct order
|
|
3835
|
-
const newSelectedElements = selectedElements.filter(value => !validAbstractRefs.find(ref => ref.abstract === value));
|
|
3836
|
-
newSelectedElements.push(...validAbstractRefs.map(value => value.abstract));
|
|
3837
|
-
const selectedMindNodes = newSelectedElements.map(value => MindElement.getNode(value));
|
|
3862
|
+
const newSelectedElements = selectedElements.filter((value) => !validAbstractRefs.find((ref) => ref.abstract === value));
|
|
3863
|
+
newSelectedElements.push(...validAbstractRefs.map((value) => value.abstract));
|
|
3864
|
+
const selectedMindNodes = newSelectedElements.map((value) => MindElement.getNode(value));
|
|
3838
3865
|
newSelectedElements.forEach((element, index) => {
|
|
3839
3866
|
// handle relative location
|
|
3840
3867
|
const nodeRectangle = getRectangleByNode(selectedMindNodes[index]);
|
|
3841
3868
|
const points = [[nodeRectangle.x - startPoint[0], nodeRectangle.y - startPoint[1]]];
|
|
3842
3869
|
// handle invalid abstract
|
|
3843
|
-
const abstractRef = validAbstractRefs.find(ref => ref.abstract === element);
|
|
3870
|
+
const abstractRef = validAbstractRefs.find((ref) => ref.abstract === element);
|
|
3844
3871
|
if (AbstractNode.isAbstract(element) && abstractRef) {
|
|
3845
3872
|
const { start, end } = getRelativeStartEndByAbstractRef(abstractRef, newSelectedElements);
|
|
3846
3873
|
result.push({
|
|
@@ -3920,19 +3947,6 @@ const insertClipboardText = (board, targetParent, text) => {
|
|
|
3920
3947
|
const getTopicSizeByElement = (element, parentElement) => {
|
|
3921
3948
|
return getTopicSize(PlaitMind.isMind(element), (parentElement && PlaitMind.isMind(parentElement)) || false, element.data.topic, element.manualWidth);
|
|
3922
3949
|
};
|
|
3923
|
-
const getTopicSize = (isRoot, isBranch, topic, manualWidth) => {
|
|
3924
|
-
let fontFamily = DEFAULT_FONT_FAMILY;
|
|
3925
|
-
let fontSize = TOPIC_FONT_SIZE;
|
|
3926
|
-
if (isRoot) {
|
|
3927
|
-
fontFamily = BRANCH_FONT_FAMILY;
|
|
3928
|
-
fontSize = ROOT_TOPIC_FONT_SIZE;
|
|
3929
|
-
}
|
|
3930
|
-
else if (isBranch) {
|
|
3931
|
-
fontFamily = BRANCH_FONT_FAMILY;
|
|
3932
|
-
}
|
|
3933
|
-
const maxWidth = fontSize * TOPIC_DEFAULT_MAX_WORD_COUNT;
|
|
3934
|
-
return measureElement(topic, { fontSize, fontFamily }, manualWidth ? manualWidth : maxWidth);
|
|
3935
|
-
};
|
|
3936
3950
|
|
|
3937
3951
|
const withMindFragment = (baseBoard) => {
|
|
3938
3952
|
const board = baseBoard;
|
|
@@ -4216,5 +4230,5 @@ class MindEmojiBaseComponent {
|
|
|
4216
4230
|
* Generated bundle index. Do not edit.
|
|
4217
4231
|
*/
|
|
4218
4232
|
|
|
4219
|
-
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_FONT_FAMILY, BranchShape, DEFAULT_FONT_FAMILY, DEFAULT_MIND_IMAGE_WIDTH, DefaultAbstractNodeStyle, DefaultNodeStyle, ELEMENT_TO_NODE, EXTEND_DIAMETER, EXTEND_OFFSET, GRAY_COLOR, INHERIT_ATTRIBUTE_KEYS, LayoutDirection, LayoutDirectionsMap, MindColorfulThemeColor, MindDarkThemeColor, MindDefaultThemeColor, MindElement, MindElementShape, MindEmojiBaseComponent, MindNode, MindNodeComponent, MindPointerType, MindQueries, MindRetroThemeColor, MindSoftThemeColor, MindStarryThemeColor, MindThemeColor, MindThemeColors, MindTransforms, NodeSpace, NodeTopicThreshold, PRIMARY_COLOR, PlaitMind, PlaitMindComponent, QUICK_INSERT_CIRCLE_COLOR, QUICK_INSERT_CIRCLE_OFFSET, QUICK_INSERT_INNER_CROSS_COLOR, ROOT_TOPIC_FONT_SIZE,
|
|
4233
|
+
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_FONT_FAMILY, BranchShape, DEFAULT_FONT_FAMILY, DEFAULT_MIND_IMAGE_WIDTH, DefaultAbstractNodeStyle, DefaultNodeStyle, ELEMENT_TO_NODE, EXTEND_DIAMETER, EXTEND_OFFSET, GRAY_COLOR, INHERIT_ATTRIBUTE_KEYS, LayoutDirection, LayoutDirectionsMap, MIND_CENTRAL_TEXT, MindColorfulThemeColor, MindDarkThemeColor, MindDefaultThemeColor, MindElement, MindElementShape, MindEmojiBaseComponent, MindI18nKey, MindNode, MindNodeComponent, MindPointerType, MindQueries, MindRetroThemeColor, MindSoftThemeColor, MindStarryThemeColor, MindThemeColor, MindThemeColors, MindTransforms, NodeSpace, NodeTopicThreshold, PRIMARY_COLOR, PlaitMind, PlaitMindComponent, QUICK_INSERT_CIRCLE_COLOR, QUICK_INSERT_CIRCLE_OFFSET, QUICK_INSERT_INNER_CROSS_COLOR, ROOT_TOPIC_FONT_SIZE, STROKE_WIDTH, TOPIC_DEFAULT_MAX_WORD_COUNT, TOPIC_FONT_SIZE, WithMindPluginKey, addActiveOnDragOrigin, addImageFocus, adjustAbstractToNode, adjustNodeToRoot, adjustRootToNode, canSetAbstract, copyNewNode, correctLayoutByDirection, createEmptyMind, createMindElement, deleteElementHandleAbstract, deleteElementsHandleRightNodeCount, detectDropTarget, directionCorrector, directionDetector, divideElementByParent, drawFakeDragNode, drawFakeDropNode, editTopic, findLastChild, findLocationLeftIndex, findNewChildNodePath, findNewSiblingNodePath, getAbstractBranchColor, getAbstractBranchWidth, getAbstractHandleRectangle, getAllowedDirection, getAvailableSubLayoutsByLayoutDirections, getBehindAbstracts, getBranchColorByMindElement, getBranchDirectionsByLayouts, getBranchShapeByMindElement, getBranchWidthByMindElement, getChildrenCount, getCorrespondingAbstract, getDefaultBranchColor, getDefaultBranchColorByIndex, getDefaultLayout, getDefaultMindElementFontSize, getDefaultMindNameText, getEmojiFontSize, getEmojiForeignRectangle, getEmojiRectangle, getEmojisWidthHeight, getFillByElement, getFirstLevelElement, getFontSizeBySlateElement, getHitAbstractHandle, getHitImageResizeHandleDirection, getImageForeignRectangle, getInCorrectLayoutDirection, getLayoutDirection$1 as getLayoutDirection, getLayoutOptions, getLayoutReverseDirection, getLocationScope, getMindThemeColor, getNewNodeHeight, getNextBranchColor, getOverallAbstracts, getPathByDropTarget, getRectangleByElement, getRectangleByNode, getRectangleByResizingLocation, getRelativeStartEndByAbstractRef, getRootLayout, getSelectedMindElements, getShapeByElement, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getTopicRectangleByElement, getTopicRectangleByNode, getTopicSize, getValidAbstractRefs, handleTouchedAbstract, hasPreviousOrNextOfDropPath, insertElementHandleAbstract, insertElementHandleRightNodeCount, insertMindElement, isChildElement, isChildOfAbstract, isChildRight, isChildUp, isCorrectLayout, isDropStandardRight, isHitEmojis, isHitImage, isHitMindElement, isInRightBranchOfStandardLayout, isMixedLayout, isSetAbstract, isValidTarget, removeActiveOnDragOrigin, removeImageFocus, separateChildren, setMindDragging, withEmoji, withMind, withMindExtend };
|
|
4220
4234
|
//# sourceMappingURL=plait-mind.mjs.map
|