@plait/mind 0.84.0 → 0.85.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 +0 -3
- package/fesm2022/plait-mind.mjs +58 -147
- package/fesm2022/plait-mind.mjs.map +1 -1
- package/interfaces/element.d.ts +9 -8
- package/package.json +1 -1
- package/transforms/index.d.ts +2 -3
- package/transforms/node.d.ts +2 -3
- package/utils/clipboard.d.ts +0 -4
- package/utils/common.d.ts +0 -5
- package/utils/mind.d.ts +2 -2
- package/utils/node/create-node.d.ts +1 -1
- package/utils/normalize.d.ts +0 -2
- package/utils/space/emoji.d.ts +1 -1
- package/utils/space/node-space.d.ts +2 -6
- package/utils/weak-maps.d.ts +1 -1
package/fesm2022/plait-mind.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { DEFAULT_COLOR, DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, rgbaToHEX, 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, isSelectedElement, createText, isSelectionMoving, isDragging, isMovingElements, NODE_TO_INDEX, PlaitPointerType, isMainPointer, toViewBoxPoint, toHostPoint, getHitElementByPoint, distanceBetweenPointAndPoint, CoreTransforms, toActivePointFromViewBoxPoint, BoardTransforms, throttleRAF, isContextmenu, temporaryDisableSelection, hotkeys, createClipboardContext, WritableClipboardType, Point, ResizeCursorClass, WritableClipboardOperationType, addOrCreateClipboardContext } from '@plait/core';
|
|
2
2
|
import { MindLayoutType, AbstractNode, isIndentedLayout, isHorizontalLogicLayout, ConnectingPosition, isHorizontalLayout, getNonAbstractChildren, isStandardLayout, isLeftLayout, isRightLayout, isVerticalLogicLayout, isTopLayout, isBottomLayout, getCorrectStartEnd, getAbstractLayout, GlobalLayout } from '@plait/layouts';
|
|
3
|
-
import { StrokeStyle, getFirstTextManage,
|
|
4
|
-
import {
|
|
3
|
+
import { StrokeStyle, getFirstTextManage, buildText, getElementSize, DEFAULT_FONT_FAMILY, RESIZE_HANDLE_DIAMETER, getRectangleResizeHandleRefs, addElementOfFocusedImage, ImageGenerator, removeElementOfFocusedImage, getStrokeLineDash, getXDistanceBetweenPoint, moveXOfPoint, moveYOfPoint, Generator, PropertyTransforms, TRANSPARENT, measureElement, isResizing, CommonElementFlavour, WithTextPluginKey, TextManage, isDrawingMode, isDndMode, setCreationMode, BoardCreationMode, isExpandHotkey, isTabHotkey, isEnterHotkey, isVirtualKey, isDelete, isSpaceHotkey, getElementOfFocusedImage, acceptImageTypes, buildImage, withResize, getElementsText } from '@plait/common';
|
|
4
|
+
import { DEFAULT_FONT_SIZE, PlaitMarkEditor, MarkTypes, FontSizes } 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';
|
|
7
7
|
import { isHotkey } from 'is-hotkey';
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const MIND_ELEMENT_TO_NODE = new WeakMap();
|
|
10
10
|
|
|
11
11
|
const MindNode = {
|
|
12
12
|
get(root, path) {
|
|
@@ -664,18 +664,6 @@ const getLayoutOptions = (board) => {
|
|
|
664
664
|
};
|
|
665
665
|
};
|
|
666
666
|
|
|
667
|
-
const TOPIC_FONT_SIZE = 14;
|
|
668
|
-
const ROOT_TOPIC_FONT_SIZE = 18;
|
|
669
|
-
const TOPIC_DEFAULT_MAX_WORD_COUNT = 34;
|
|
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
667
|
const MIND_CENTRAL_TEXT = '中心主题';
|
|
680
668
|
const ABSTRACT_NODE_TEXT = '概要';
|
|
681
669
|
const getDefaultMindNameText = (board) => {
|
|
@@ -684,40 +672,25 @@ const getDefaultMindNameText = (board) => {
|
|
|
684
672
|
const getAbstractNodeText = (board) => {
|
|
685
673
|
return getI18nValue(board, MindI18nKey.abstractNodeText, ABSTRACT_NODE_TEXT);
|
|
686
674
|
};
|
|
687
|
-
const getTopicSize = (board, isRoot, isBranch, topic, manualWidth) => {
|
|
688
|
-
let fontFamily = DEFAULT_FONT_FAMILY;
|
|
689
|
-
let fontSize = TOPIC_FONT_SIZE;
|
|
690
|
-
if (isRoot) {
|
|
691
|
-
fontFamily = DEFAULT_FONT_FAMILY;
|
|
692
|
-
fontSize = ROOT_TOPIC_FONT_SIZE;
|
|
693
|
-
}
|
|
694
|
-
else if (isBranch) {
|
|
695
|
-
fontFamily = DEFAULT_FONT_FAMILY;
|
|
696
|
-
}
|
|
697
|
-
const maxWidth = fontSize * TOPIC_DEFAULT_MAX_WORD_COUNT;
|
|
698
|
-
return measureElement(board, topic, { fontSize, fontFamily }, manualWidth ? manualWidth : maxWidth);
|
|
699
|
-
};
|
|
700
675
|
|
|
701
676
|
const createEmptyMind = (board, point) => {
|
|
702
677
|
const text = getDefaultMindNameText(board);
|
|
703
|
-
const
|
|
704
|
-
const element = createMindElement(text, topicSize.width, topicSize.height, { layout: MindLayoutType.right });
|
|
678
|
+
const element = createMindElement(text, { layout: MindLayoutType.right });
|
|
705
679
|
element.isRoot = true;
|
|
706
|
-
element.type = '
|
|
680
|
+
element.type = 'mind';
|
|
707
681
|
const width = NodeSpace.getNodeWidth(board, element);
|
|
708
682
|
const height = NodeSpace.getNodeHeight(board, element);
|
|
709
683
|
element.points = [[point[0] - width / 2, point[1] - height / 2]];
|
|
710
684
|
return element;
|
|
711
685
|
};
|
|
712
|
-
const createMindElement = (text,
|
|
686
|
+
const createMindElement = (text, options) => {
|
|
713
687
|
const newElement = {
|
|
714
688
|
id: idCreator(),
|
|
689
|
+
type: 'mind_child',
|
|
715
690
|
data: {
|
|
716
691
|
topic: buildText(text)
|
|
717
692
|
},
|
|
718
|
-
children: []
|
|
719
|
-
width,
|
|
720
|
-
height
|
|
693
|
+
children: []
|
|
721
694
|
};
|
|
722
695
|
let key;
|
|
723
696
|
for (key in options) {
|
|
@@ -739,6 +712,10 @@ const INHERIT_ATTRIBUTE_KEYS = [
|
|
|
739
712
|
'branchShape'
|
|
740
713
|
];
|
|
741
714
|
|
|
715
|
+
const TOPIC_FONT_SIZE = 14;
|
|
716
|
+
const ROOT_TOPIC_FONT_SIZE = 18;
|
|
717
|
+
const TOPIC_DEFAULT_MAX_WORD_COUNT = 34;
|
|
718
|
+
|
|
742
719
|
const getChildrenCount = (element) => {
|
|
743
720
|
const count = element.children.reduce((p, c) => {
|
|
744
721
|
return p + getChildrenCount(c);
|
|
@@ -757,8 +734,8 @@ const isChildElement = (origin, child) => {
|
|
|
757
734
|
};
|
|
758
735
|
const getFirstLevelElement = (elements) => {
|
|
759
736
|
let result = [];
|
|
760
|
-
elements.forEach(element => {
|
|
761
|
-
const isChild = elements.some(node => {
|
|
737
|
+
elements.forEach((element) => {
|
|
738
|
+
const isChild = elements.some((node) => {
|
|
762
739
|
return isChildElement(node, element);
|
|
763
740
|
});
|
|
764
741
|
if (!isChild) {
|
|
@@ -785,12 +762,12 @@ const copyNewNode = (node) => {
|
|
|
785
762
|
const insertMindElement = (board, inheritNode, path) => {
|
|
786
763
|
const newNode = {};
|
|
787
764
|
if (!inheritNode.isRoot) {
|
|
788
|
-
INHERIT_ATTRIBUTE_KEYS.forEach(attr => {
|
|
765
|
+
INHERIT_ATTRIBUTE_KEYS.forEach((attr) => {
|
|
789
766
|
newNode[attr] = inheritNode[attr];
|
|
790
767
|
});
|
|
791
768
|
delete newNode.layout;
|
|
792
769
|
}
|
|
793
|
-
const newElement = createMindElement('',
|
|
770
|
+
const newElement = createMindElement('', newNode);
|
|
794
771
|
Transforms.insertNode(board, newElement, path);
|
|
795
772
|
clearSelectedElement(board);
|
|
796
773
|
addSelectedElement(board, newElement);
|
|
@@ -821,16 +798,21 @@ const divideElementByParent = (elements) => {
|
|
|
821
798
|
}
|
|
822
799
|
return { parentElements, abstractIncludedGroups };
|
|
823
800
|
};
|
|
824
|
-
const
|
|
801
|
+
const getDefaultFontSizeForMindElement = (element) => {
|
|
825
802
|
if (PlaitMind.isMind(element)) {
|
|
826
803
|
return ROOT_TOPIC_FONT_SIZE;
|
|
827
804
|
}
|
|
828
|
-
if (MindElement.isMindElement(
|
|
805
|
+
if (MindElement.isMindElement(null, element)) {
|
|
829
806
|
return TOPIC_FONT_SIZE;
|
|
830
807
|
}
|
|
831
808
|
throw new Error('can not find default font-size');
|
|
832
809
|
};
|
|
833
810
|
|
|
811
|
+
const ABSTRACT_HANDLE_COLOR = '#6698FF80'; //primary color 50% opacity
|
|
812
|
+
const ABSTRACT_INCLUDED_OUTLINE_OFFSET = 3.5;
|
|
813
|
+
const ABSTRACT_HANDLE_LENGTH = 10;
|
|
814
|
+
const ABSTRACT_HANDLE_MASK_WIDTH = 8;
|
|
815
|
+
|
|
834
816
|
const NodeDefaultSpace = {
|
|
835
817
|
horizontal: {
|
|
836
818
|
nodeAndText: BASE * 2.5,
|
|
@@ -890,7 +872,7 @@ const NodeSpace = {
|
|
|
890
872
|
return nodeAndText + normalizedSize.height + nodeAndText;
|
|
891
873
|
},
|
|
892
874
|
getTopicDynamicWidth(board, element) {
|
|
893
|
-
const topicSize = getElementSize(board, element.data.topic, { fontSize:
|
|
875
|
+
const topicSize = getElementSize(board, element.data.topic, { fontSize: getDefaultFontSizeForMindElement(element), fontFamily: DEFAULT_FONT_FAMILY }, NodeSpace.getTopicMaxDynamicWidth(board, element));
|
|
894
876
|
const normalizedSize = normalizeWidthAndHeight(board, element, topicSize.width, topicSize.width);
|
|
895
877
|
const width = element.manualWidth || normalizedSize.width;
|
|
896
878
|
const imageWidth = MindElement.hasImage(element) ? element.data.image?.width : 0;
|
|
@@ -902,14 +884,11 @@ const NodeSpace = {
|
|
|
902
884
|
return normalizedSize.height;
|
|
903
885
|
},
|
|
904
886
|
getTopicMaxDynamicWidth(board, element) {
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
getNodeNewDynamicWidth(board, element, imageWidth) {
|
|
911
|
-
const width = element.manualWidth || element.width;
|
|
912
|
-
return Math.max(width, imageWidth);
|
|
887
|
+
const fontSize = getDefaultFontSizeForMindElement(element);
|
|
888
|
+
if (element.manualWidth) {
|
|
889
|
+
return Math.max(element.manualWidth, MindElement.hasImage(element) ? element.data.image?.width : 0);
|
|
890
|
+
}
|
|
891
|
+
return Math.max(fontSize * TOPIC_DEFAULT_MAX_WORD_COUNT, MindElement.hasImage(element) ? element.data.image?.width : 0);
|
|
913
892
|
},
|
|
914
893
|
getNodeResizableMinWidth(board, element) {
|
|
915
894
|
const minTopicWidth = NodeSpace.getNodeTopicMinWidth(board, element);
|
|
@@ -921,10 +900,7 @@ const NodeSpace = {
|
|
|
921
900
|
}
|
|
922
901
|
},
|
|
923
902
|
getNodeTopicMinWidth(board, element) {
|
|
924
|
-
|
|
925
|
-
const firstText = getFirstTextMarks(element.data.topic);
|
|
926
|
-
const fontSize = (firstText[MarkTypes.fontSize] ? Number(firstText[MarkTypes.fontSize]) : null) || defaultFontSize;
|
|
927
|
-
return fontSize;
|
|
903
|
+
return getFontSizeByMindElement(board, element);
|
|
928
904
|
},
|
|
929
905
|
getTextLeftSpace(board, element) {
|
|
930
906
|
const nodeAndText = getHorizontalSpaceBetweenNodeAndText(board, element);
|
|
@@ -958,12 +934,9 @@ const NodeSpace = {
|
|
|
958
934
|
return nodeAndText;
|
|
959
935
|
}
|
|
960
936
|
};
|
|
961
|
-
const
|
|
962
|
-
const defaultFontSize =
|
|
963
|
-
|
|
964
|
-
return defaultFontSize;
|
|
965
|
-
}
|
|
966
|
-
const marks = PlaitMarkEditor.getMarksByElement(text);
|
|
937
|
+
const getFontSizeByMindElement = (board, element) => {
|
|
938
|
+
const defaultFontSize = getDefaultFontSizeForMindElement(element);
|
|
939
|
+
const marks = PlaitMarkEditor.getMarksByElement(element.data.topic);
|
|
967
940
|
const fontSize = marks[MarkTypes.fontSize] || defaultFontSize;
|
|
968
941
|
return fontSize;
|
|
969
942
|
};
|
|
@@ -997,7 +970,7 @@ function getRectangleByElement(board, element) {
|
|
|
997
970
|
return nodeRectangle;
|
|
998
971
|
}
|
|
999
972
|
function isHitMindElement(board, point, element) {
|
|
1000
|
-
const node =
|
|
973
|
+
const node = MIND_ELEMENT_TO_NODE.get(element);
|
|
1001
974
|
if (node && distanceBetweenPointAndRectangle(point[0], point[1], getRectangleByNode(node)) === 0) {
|
|
1002
975
|
return true;
|
|
1003
976
|
}
|
|
@@ -1080,7 +1053,7 @@ const adjustRootToNode = (board, node) => {
|
|
|
1080
1053
|
const newNode = { ...node };
|
|
1081
1054
|
delete newNode.isRoot;
|
|
1082
1055
|
delete newNode.rightNodeCount;
|
|
1083
|
-
|
|
1056
|
+
newNode.type = 'mind_child';
|
|
1084
1057
|
if (newNode.layout === MindLayoutType.standard) {
|
|
1085
1058
|
delete newNode.layout;
|
|
1086
1059
|
}
|
|
@@ -1106,7 +1079,7 @@ const adjustNodeToRoot = (board, node) => {
|
|
|
1106
1079
|
...newElement,
|
|
1107
1080
|
layout: newElement.layout ?? MindLayoutType.right,
|
|
1108
1081
|
isRoot: true,
|
|
1109
|
-
type: '
|
|
1082
|
+
type: 'mind'
|
|
1110
1083
|
};
|
|
1111
1084
|
};
|
|
1112
1085
|
|
|
@@ -2289,9 +2262,10 @@ const MindQueries = {
|
|
|
2289
2262
|
getCorrectLayoutByElement
|
|
2290
2263
|
};
|
|
2291
2264
|
|
|
2265
|
+
const LEGACY_MIND_TYPE = 'mindmap';
|
|
2292
2266
|
const PlaitMind = {
|
|
2293
2267
|
isMind: (value) => {
|
|
2294
|
-
return value.type === '
|
|
2268
|
+
return value.type === 'mind' || value.type === LEGACY_MIND_TYPE;
|
|
2295
2269
|
}
|
|
2296
2270
|
};
|
|
2297
2271
|
const MindElement = {
|
|
@@ -2304,10 +2278,7 @@ const MindElement = {
|
|
|
2304
2278
|
return isIndentedLayout(_layout);
|
|
2305
2279
|
},
|
|
2306
2280
|
isMindElement(board, element) {
|
|
2307
|
-
|
|
2308
|
-
// Now it is very awkward whether it is dynamically calculated(query root node) or using other characteristic attributes(current).
|
|
2309
|
-
// Using dynamically calculated will cause more issue like pasting from clipboard, finding elements by id(isRecursion)
|
|
2310
|
-
if (element.data && element.data.topic && !isNullOrUndefined(element.width) && !isNullOrUndefined(element.height)) {
|
|
2281
|
+
if ((element.data && element.data.topic) || element.type === 'mind_child') {
|
|
2311
2282
|
return true;
|
|
2312
2283
|
}
|
|
2313
2284
|
else {
|
|
@@ -2344,7 +2315,7 @@ const MindElement = {
|
|
|
2344
2315
|
return parents;
|
|
2345
2316
|
},
|
|
2346
2317
|
getNode(element) {
|
|
2347
|
-
const node =
|
|
2318
|
+
const node = MIND_ELEMENT_TO_NODE.get(element);
|
|
2348
2319
|
if (!node) {
|
|
2349
2320
|
throw new Error(`can not get node from ${JSON.stringify(element)}`);
|
|
2350
2321
|
}
|
|
@@ -2493,8 +2464,7 @@ const setAbstractByElements = (board, groupParent, group) => {
|
|
|
2493
2464
|
};
|
|
2494
2465
|
const insertAbstractNode = (board, path, start, end) => {
|
|
2495
2466
|
const abstractNodeText = getAbstractNodeText(board);
|
|
2496
|
-
const
|
|
2497
|
-
const mindElement = createMindElement(abstractNodeText, width, height, {
|
|
2467
|
+
const mindElement = createMindElement(abstractNodeText, {
|
|
2498
2468
|
strokeWidth: DefaultAbstractNodeStyle.branch.width,
|
|
2499
2469
|
branchWidth: DefaultAbstractNodeStyle.branch.width
|
|
2500
2470
|
});
|
|
@@ -2505,34 +2475,22 @@ const insertAbstractNode = (board, path, start, end) => {
|
|
|
2505
2475
|
addSelectedElement(board, mindElement);
|
|
2506
2476
|
};
|
|
2507
2477
|
|
|
2508
|
-
const setTopic = (board, element, topic
|
|
2478
|
+
const setTopic = (board, element, topic) => {
|
|
2509
2479
|
const newElement = {
|
|
2510
|
-
data: { ...element.data
|
|
2511
|
-
...normalizeWidthAndHeight(board, element, width, height)
|
|
2480
|
+
data: { ...element.data }
|
|
2512
2481
|
};
|
|
2482
|
+
if (topic) {
|
|
2483
|
+
newElement.data.topic = topic;
|
|
2484
|
+
}
|
|
2513
2485
|
const path = PlaitBoard.findPath(board, element);
|
|
2514
2486
|
Transforms.setNode(board, newElement, path);
|
|
2515
2487
|
};
|
|
2516
|
-
const setNodeManualWidth = (board, element, width
|
|
2488
|
+
const setNodeManualWidth = (board, element, width) => {
|
|
2517
2489
|
const path = PlaitBoard.findPath(board, element);
|
|
2518
|
-
const { width: normalizedWidth
|
|
2519
|
-
const newElement = { manualWidth: normalizedWidth,
|
|
2490
|
+
const { width: normalizedWidth } = normalizeWidthAndHeight(board, element, width, 0);
|
|
2491
|
+
const newElement = { manualWidth: normalizedWidth, data: { ...element.data, topic: { ...element.data.topic } } };
|
|
2520
2492
|
Transforms.setNode(board, newElement, path);
|
|
2521
2493
|
};
|
|
2522
|
-
const setTopicSize = (board, element, width, height) => {
|
|
2523
|
-
const newElement = {
|
|
2524
|
-
...normalizeWidthAndHeight(board, element, width, height)
|
|
2525
|
-
};
|
|
2526
|
-
let isEqualWidth = Math.ceil(element.width) === Math.ceil(newElement.width);
|
|
2527
|
-
let isEqualHeight = Math.ceil(element.height) === Math.ceil(newElement.height);
|
|
2528
|
-
if (element.manualWidth) {
|
|
2529
|
-
isEqualWidth = true;
|
|
2530
|
-
}
|
|
2531
|
-
if (!isEqualWidth || !isEqualHeight) {
|
|
2532
|
-
const path = PlaitBoard.findPath(board, element);
|
|
2533
|
-
Transforms.setNode(board, newElement, path);
|
|
2534
|
-
}
|
|
2535
|
-
};
|
|
2536
2494
|
const insertNodes = (board, elements, path) => {
|
|
2537
2495
|
const pathRef = board.pathRef(path);
|
|
2538
2496
|
elements.forEach((element) => {
|
|
@@ -2632,26 +2590,16 @@ const replaceEmoji = (board, element, oldEmoji, newEmoji) => {
|
|
|
2632
2590
|
const removeImage = (board, element) => {
|
|
2633
2591
|
removeImageFocus(board, element);
|
|
2634
2592
|
const newElement = {
|
|
2635
|
-
data: { ...element.data }
|
|
2593
|
+
data: { ...element.data, topic: { ...element.data.topic } }
|
|
2636
2594
|
};
|
|
2637
2595
|
delete newElement.data.image;
|
|
2638
2596
|
const path = PlaitBoard.findPath(board, element);
|
|
2639
|
-
const newDynamicWidth = NodeSpace.getNodeNewDynamicWidth(board, element, 0);
|
|
2640
|
-
const newHeight = getNewNodeHeight(board, element, newDynamicWidth);
|
|
2641
|
-
if (newHeight) {
|
|
2642
|
-
newElement.height = newHeight;
|
|
2643
|
-
}
|
|
2644
2597
|
Transforms.setNode(board, newElement, path);
|
|
2645
2598
|
};
|
|
2646
2599
|
const setImage = (board, element, imageItem) => {
|
|
2647
2600
|
const newElement = {
|
|
2648
|
-
data: { ...element.data, image: imageItem }
|
|
2601
|
+
data: { ...element.data, image: imageItem, topic: { ...element.data.topic } }
|
|
2649
2602
|
};
|
|
2650
|
-
const newDynamicWidth = NodeSpace.getNodeNewDynamicWidth(board, element, imageItem.width);
|
|
2651
|
-
const newHeight = getNewNodeHeight(board, element, newDynamicWidth);
|
|
2652
|
-
if (newHeight) {
|
|
2653
|
-
newElement.height = newHeight;
|
|
2654
|
-
}
|
|
2655
2603
|
const path = PlaitBoard.findPath(board, element);
|
|
2656
2604
|
Transforms.setNode(board, newElement, path);
|
|
2657
2605
|
};
|
|
@@ -2708,7 +2656,6 @@ const MindTransforms = {
|
|
|
2708
2656
|
setBranchWidth,
|
|
2709
2657
|
setBranchColor,
|
|
2710
2658
|
setTopic,
|
|
2711
|
-
setTopicSize,
|
|
2712
2659
|
setNodeManualWidth,
|
|
2713
2660
|
addEmoji,
|
|
2714
2661
|
removeEmoji,
|
|
@@ -2954,14 +2901,7 @@ class MindNodeComponent extends CommonElementFlavour {
|
|
|
2954
2901
|
return rect;
|
|
2955
2902
|
},
|
|
2956
2903
|
onChange: (data) => {
|
|
2957
|
-
|
|
2958
|
-
const height = data.height;
|
|
2959
|
-
if (data.newText) {
|
|
2960
|
-
MindTransforms.setTopic(this.board, this.element, data.newText, width, height);
|
|
2961
|
-
}
|
|
2962
|
-
else {
|
|
2963
|
-
MindTransforms.setTopicSize(this.board, this.element, width, height);
|
|
2964
|
-
}
|
|
2904
|
+
MindTransforms.setTopic(this.board, this.element, data.newText);
|
|
2965
2905
|
},
|
|
2966
2906
|
getMaxWidth: () => {
|
|
2967
2907
|
return NodeSpace.getTopicMaxDynamicWidth(this.board, this.element);
|
|
@@ -3074,8 +3014,8 @@ class MindNodeComponent extends CommonElementFlavour {
|
|
|
3074
3014
|
this.nodeEmojisGenerator.destroy();
|
|
3075
3015
|
this.imageGenerator.destroy();
|
|
3076
3016
|
this.activeGenerator.destroy();
|
|
3077
|
-
if (
|
|
3078
|
-
|
|
3017
|
+
if (MIND_ELEMENT_TO_NODE.get(this.element) === this.node) {
|
|
3018
|
+
MIND_ELEMENT_TO_NODE.delete(this.element);
|
|
3079
3019
|
}
|
|
3080
3020
|
this.getRef().destroyTextManage();
|
|
3081
3021
|
}
|
|
@@ -3104,7 +3044,7 @@ class PlaitMindComponent extends MindNodeComponent {
|
|
|
3104
3044
|
depthFirstRecursion(this.root, (node) => {
|
|
3105
3045
|
node.x = node.x - offsetX + element.points[0][0];
|
|
3106
3046
|
node.y = node.y - offsetY + element.points[0][1];
|
|
3107
|
-
|
|
3047
|
+
MIND_ELEMENT_TO_NODE.set(node.origin, node);
|
|
3108
3048
|
});
|
|
3109
3049
|
}
|
|
3110
3050
|
}
|
|
@@ -3825,9 +3765,7 @@ const withNodeResize = (board) => {
|
|
|
3825
3765
|
}
|
|
3826
3766
|
const newTarget = PlaitNode.get(board, targetElementRef.path);
|
|
3827
3767
|
if (newTarget && NodeSpace.getNodeTopicMinWidth(board, newTarget) !== resizedWidth) {
|
|
3828
|
-
|
|
3829
|
-
const { height } = targetElementRef.textManage.getSize(undefined, resizedWidth);
|
|
3830
|
-
MindTransforms.setNodeManualWidth(board, newTarget, resizedWidth, height);
|
|
3768
|
+
MindTransforms.setNodeManualWidth(board, newTarget, resizedWidth);
|
|
3831
3769
|
}
|
|
3832
3770
|
},
|
|
3833
3771
|
afterResize: (resizeRef) => {
|
|
@@ -3955,9 +3893,6 @@ const insertClipboardData = (board, elements, targetPoint, operationType) => {
|
|
|
3955
3893
|
if (hasTargetParent && operationType !== WritableClipboardOperationType.duplicate) {
|
|
3956
3894
|
if (item.isRoot) {
|
|
3957
3895
|
newElement = adjustRootToNode(board, newElement);
|
|
3958
|
-
const { width, height } = getTopicSizeByElement(board, newElement, targetParent);
|
|
3959
|
-
newElement.width = width;
|
|
3960
|
-
newElement.height = height;
|
|
3961
3896
|
}
|
|
3962
3897
|
// handle abstract start and end
|
|
3963
3898
|
if (AbstractNode.isAbstract(newElement)) {
|
|
@@ -3974,9 +3909,6 @@ const insertClipboardData = (board, elements, targetPoint, operationType) => {
|
|
|
3974
3909
|
}
|
|
3975
3910
|
if (!item.isRoot) {
|
|
3976
3911
|
newElement = adjustNodeToRoot(board, newElement);
|
|
3977
|
-
const { width, height } = getTopicSizeByElement(board, newElement);
|
|
3978
|
-
newElement.width = width;
|
|
3979
|
-
newElement.height = height;
|
|
3980
3912
|
}
|
|
3981
3913
|
path = [board.children.length];
|
|
3982
3914
|
}
|
|
@@ -3987,14 +3919,10 @@ const insertClipboardData = (board, elements, targetPoint, operationType) => {
|
|
|
3987
3919
|
Transforms.addSelectionWithTemporaryElements(board, newELements);
|
|
3988
3920
|
};
|
|
3989
3921
|
const insertClipboardText = (board, targetParent, text) => {
|
|
3990
|
-
const
|
|
3991
|
-
const newElement = createMindElement(text, Math.max(width, getFontSizeBySlateElement(text)), height, {});
|
|
3922
|
+
const newElement = createMindElement(text, {});
|
|
3992
3923
|
Transforms.insertNode(board, newElement, findNewChildNodePath(board, targetParent));
|
|
3993
3924
|
Transforms.addSelectionWithTemporaryElements(board, [newElement]);
|
|
3994
3925
|
};
|
|
3995
|
-
const getTopicSizeByElement = (board, element, parentElement) => {
|
|
3996
|
-
return getTopicSize(board, PlaitMind.isMind(element), (parentElement && PlaitMind.isMind(parentElement)) || false, element.data.topic, element.manualWidth);
|
|
3997
|
-
};
|
|
3998
3926
|
|
|
3999
3927
|
const withMindFragment = (baseBoard) => {
|
|
4000
3928
|
const board = baseBoard;
|
|
@@ -4101,12 +4029,6 @@ const isNormalizedData = (element) => {
|
|
|
4101
4029
|
}
|
|
4102
4030
|
return true;
|
|
4103
4031
|
};
|
|
4104
|
-
const isNormalizedWidthAndHeight = (element) => {
|
|
4105
|
-
if (isNullOrUndefined(element.width) || isNullOrUndefined(element.height)) {
|
|
4106
|
-
return false;
|
|
4107
|
-
}
|
|
4108
|
-
return true;
|
|
4109
|
-
};
|
|
4110
4032
|
const fixMindElementData = (element) => {
|
|
4111
4033
|
const emptyTopic = {
|
|
4112
4034
|
children: [
|
|
@@ -4125,14 +4047,6 @@ const fixMindElementData = (element) => {
|
|
|
4125
4047
|
element.data.topic = emptyTopic;
|
|
4126
4048
|
}
|
|
4127
4049
|
};
|
|
4128
|
-
const fixMindElementWidthAndHeight = (element) => {
|
|
4129
|
-
if (isNullOrUndefined(element.width)) {
|
|
4130
|
-
element.width = 56;
|
|
4131
|
-
}
|
|
4132
|
-
if (isNullOrUndefined(element.height)) {
|
|
4133
|
-
element.width = 20;
|
|
4134
|
-
}
|
|
4135
|
-
};
|
|
4136
4050
|
|
|
4137
4051
|
const withMind = (baseBoard) => {
|
|
4138
4052
|
const board = baseBoard;
|
|
@@ -4143,9 +4057,6 @@ const withMind = (baseBoard) => {
|
|
|
4143
4057
|
if (!isNormalizedData(node)) {
|
|
4144
4058
|
fixMindElementData(node);
|
|
4145
4059
|
}
|
|
4146
|
-
if (!isNormalizedWidthAndHeight(node)) {
|
|
4147
|
-
fixMindElementWidthAndHeight(node);
|
|
4148
|
-
}
|
|
4149
4060
|
});
|
|
4150
4061
|
}
|
|
4151
4062
|
normalizeElement(context);
|
|
@@ -4278,5 +4189,5 @@ class MindEmojiBaseComponent {
|
|
|
4278
4189
|
* Generated bundle index. Do not edit.
|
|
4279
4190
|
*/
|
|
4280
4191
|
|
|
4281
|
-
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, ABSTRACT_NODE_TEXT, AbstractHandlePosition, AbstractResizeState, BASE, BranchShape, DEFAULT_MIND_IMAGE_WIDTH, DefaultAbstractNodeStyle, DefaultNodeStyle,
|
|
4192
|
+
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, ABSTRACT_NODE_TEXT, AbstractHandlePosition, AbstractResizeState, BASE, BranchShape, DEFAULT_MIND_IMAGE_WIDTH, DefaultAbstractNodeStyle, DefaultNodeStyle, GRAY_COLOR, INHERIT_ATTRIBUTE_KEYS, LayoutDirection, LayoutDirectionsMap, MIND_CENTRAL_TEXT, MIND_ELEMENT_TO_NODE, MindColorfulThemeColor, MindDarkThemeColor, MindDefaultThemeColor, MindElement, MindElementShape, MindEmojiBaseComponent, MindI18nKey, MindNode, MindNodeComponent, MindPointerType, MindQueries, MindRetroThemeColor, MindSoftThemeColor, MindStarryThemeColor, MindThemeColor, MindThemeColors, MindTransforms, NODE_ADD_CIRCLE_COLOR, NODE_ADD_HOVER_COLOR, NODE_ADD_INNER_CROSS_COLOR, NODE_MORE_BRIDGE_DISTANCE, NODE_MORE_ICON_DIAMETER, NODE_MORE_LINE_DISTANCE, NODE_MORE_STROKE_WIDTH, NodeSpace, PRIMARY_COLOR, PlaitMind, PlaitMindComponent, RESIZE_HANDLE_BUFFER_DISTANCE, 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, getAbstractNodeText, getAllowedDirection, getAvailableSubLayoutsByLayoutDirections, getBehindAbstracts, getBranchColorByMindElement, getBranchDirectionsByLayouts, getBranchShapeByMindElement, getBranchWidthByMindElement, getChildrenCount, getCorrespondingAbstract, getDefaultBranchColor, getDefaultBranchColorByIndex, getDefaultFontSizeForMindElement, getDefaultLayout, getDefaultMindNameText, getEmojiFontSize, getEmojiForeignRectangle, getEmojiRectangle, getEmojisWidthHeight, getFillByElement, getFirstLevelElement, getFontSizeByMindElement, 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, getValidAbstractRefs, handleTouchedAbstract, hasPreviousOrNextOfDropPath, insertElementHandleAbstract, insertElementHandleRightNodeCount, insertMindElement, isChildElement, isChildOfAbstract, isChildRight, isChildUp, isCorrectLayout, isDropStandardRight, isHitEmojis, isHitImage, isHitMindElement, isInRightBranchOfStandardLayout, isMixedLayout, isSetAbstract, isValidTarget, normalizeWidthAndHeight, removeActiveOnDragOrigin, removeImageFocus, separateChildren, setMindDragging, withEmoji, withMind, withMindExtend };
|
|
4282
4193
|
//# sourceMappingURL=plait-mind.mjs.map
|