@plait/mind 0.83.1 → 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.
@@ -1,6 +1,3 @@
1
1
  export declare const TOPIC_FONT_SIZE = 14;
2
2
  export declare const ROOT_TOPIC_FONT_SIZE = 18;
3
3
  export declare const TOPIC_DEFAULT_MAX_WORD_COUNT = 34;
4
- export declare const NodeTopicThreshold: {
5
- defaultTextMaxWidth: number;
6
- };
@@ -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, DEFAULT_FONT_FAMILY, measureElement, buildText, getFirstTextEditor, RESIZE_HANDLE_DIAMETER, getRectangleResizeHandleRefs, addElementOfFocusedImage, ImageGenerator, removeElementOfFocusedImage, getStrokeLineDash, getXDistanceBetweenPoint, moveXOfPoint, moveYOfPoint, Generator, PropertyTransforms, TRANSPARENT, isResizing, CommonElementFlavour, WithTextPluginKey, TextManage, isDrawingMode, isDndMode, setCreationMode, BoardCreationMode, isExpandHotkey, isTabHotkey, isEnterHotkey, isVirtualKey, isDelete, isSpaceHotkey, getElementOfFocusedImage, acceptImageTypes, buildImage, withResize, getElementsText } from '@plait/common';
4
- import { TEXT_DEFAULT_HEIGHT, PlaitMarkEditor, MarkTypes, DEFAULT_FONT_SIZE, FontSizes } from '@plait/text-plugins';
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 ELEMENT_TO_NODE = new WeakMap();
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 topicSize = getTopicSize(board, true, false, buildText(text));
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 = 'mindmap';
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, width, height, options) => {
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('', TOPIC_FONT_SIZE, TEXT_DEFAULT_HEIGHT, newNode);
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 getDefaultMindElementFontSize = (board, element) => {
801
+ const getDefaultFontSizeForMindElement = (element) => {
825
802
  if (PlaitMind.isMind(element)) {
826
803
  return ROOT_TOPIC_FONT_SIZE;
827
804
  }
828
- if (MindElement.isMindElement(board, element)) {
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,
@@ -875,29 +857,38 @@ const NodeSpace = {
875
857
  return (NodeSpace.getEmojiLeftSpace(board, element) +
876
858
  getEmojisWidthHeight(board, element).width +
877
859
  getSpaceEmojiAndText(element) +
878
- NodeSpace.getNodeDynamicWidth(board, element) +
860
+ NodeSpace.getTopicDynamicWidth(board, element) +
879
861
  nodeAndText);
880
862
  }
881
- return nodeAndText + NodeSpace.getNodeDynamicWidth(board, element) + nodeAndText;
863
+ return nodeAndText + NodeSpace.getTopicDynamicWidth(board, element) + nodeAndText;
882
864
  },
883
865
  getNodeHeight(board, element) {
866
+ const topicSize = getElementSize(board, element.data.topic, { fontSize: DEFAULT_FONT_SIZE, fontFamily: DEFAULT_FONT_FAMILY }, NodeSpace.getTopicMaxDynamicWidth(board, element));
867
+ const normalizedSize = normalizeWidthAndHeight(board, element, topicSize.width, topicSize.height);
884
868
  const nodeAndText = getVerticalSpaceBetweenNodeAndText(board, element);
885
869
  if (MindElement.hasImage(element)) {
886
- return NodeSpace.getTextTopSpace(board, element) + element.height + nodeAndText;
870
+ return NodeSpace.getTextTopSpace(board, element) + normalizedSize.height + nodeAndText;
887
871
  }
888
- return nodeAndText + element.height + nodeAndText;
872
+ return nodeAndText + normalizedSize.height + nodeAndText;
889
873
  },
890
- getNodeDynamicWidth(board, element) {
891
- const width = element.manualWidth || element.width;
874
+ getTopicDynamicWidth(board, element) {
875
+ const topicSize = getElementSize(board, element.data.topic, { fontSize: getDefaultFontSizeForMindElement(element), fontFamily: DEFAULT_FONT_FAMILY }, NodeSpace.getTopicMaxDynamicWidth(board, element));
876
+ const normalizedSize = normalizeWidthAndHeight(board, element, topicSize.width, topicSize.width);
877
+ const width = element.manualWidth || normalizedSize.width;
892
878
  const imageWidth = MindElement.hasImage(element) ? element.data.image?.width : 0;
893
879
  return Math.max(width, imageWidth);
894
880
  },
895
- /**
896
- * use it when upload image first or resize image
897
- */
898
- getNodeNewDynamicWidth(board, element, imageWidth) {
899
- const width = element.manualWidth || element.width;
900
- return Math.max(width, imageWidth);
881
+ getTopicHeight(board, element) {
882
+ const topicSize = getElementSize(board, element.data.topic, { fontSize: DEFAULT_FONT_SIZE, fontFamily: DEFAULT_FONT_FAMILY }, NodeSpace.getTopicMaxDynamicWidth(board, element));
883
+ const normalizedSize = normalizeWidthAndHeight(board, element, topicSize.width, topicSize.height);
884
+ return normalizedSize.height;
885
+ },
886
+ getTopicMaxDynamicWidth(board, element) {
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);
901
892
  },
902
893
  getNodeResizableMinWidth(board, element) {
903
894
  const minTopicWidth = NodeSpace.getNodeTopicMinWidth(board, element);
@@ -909,11 +900,7 @@ const NodeSpace = {
909
900
  }
910
901
  },
911
902
  getNodeTopicMinWidth(board, element) {
912
- const defaultFontSize = getDefaultMindElementFontSize(board, element);
913
- const editor = getFirstTextEditor(element);
914
- const marks = PlaitMarkEditor.getMarks(editor);
915
- const fontSize = marks[MarkTypes.fontSize] || defaultFontSize;
916
- return fontSize;
903
+ return getFontSizeByMindElement(board, element);
917
904
  },
918
905
  getTextLeftSpace(board, element) {
919
906
  const nodeAndText = getHorizontalSpaceBetweenNodeAndText(board, element);
@@ -947,15 +934,17 @@ const NodeSpace = {
947
934
  return nodeAndText;
948
935
  }
949
936
  };
950
- const getFontSizeBySlateElement = (text) => {
951
- const defaultFontSize = DEFAULT_FONT_SIZE;
952
- if (typeof text === 'string') {
953
- return defaultFontSize;
954
- }
955
- const marks = PlaitMarkEditor.getMarksByElement(text);
937
+ const getFontSizeByMindElement = (board, element) => {
938
+ const defaultFontSize = getDefaultFontSizeForMindElement(element);
939
+ const marks = PlaitMarkEditor.getMarksByElement(element.data.topic);
956
940
  const fontSize = marks[MarkTypes.fontSize] || defaultFontSize;
957
941
  return fontSize;
958
942
  };
943
+ const normalizeWidthAndHeight = (board, element, width, height) => {
944
+ const minWidth = NodeSpace.getNodeTopicMinWidth(board, element);
945
+ const newWidth = width < minWidth ? minWidth : width;
946
+ return { width: newWidth, height };
947
+ };
959
948
 
960
949
  function getRectangleByNode(node) {
961
950
  const x = node.x + node.hGap;
@@ -981,7 +970,7 @@ function getRectangleByElement(board, element) {
981
970
  return nodeRectangle;
982
971
  }
983
972
  function isHitMindElement(board, point, element) {
984
- const node = MindElement.getNode(element);
973
+ const node = MIND_ELEMENT_TO_NODE.get(element);
985
974
  if (node && distanceBetweenPointAndRectangle(point[0], point[1], getRectangleByNode(node)) === 0) {
986
975
  return true;
987
976
  }
@@ -1019,14 +1008,13 @@ const isHitEmojis = (board, element, point) => {
1019
1008
  function getTopicRectangleByNode(board, node) {
1020
1009
  let nodeRectangle = getRectangleByNode(node);
1021
1010
  const result = getTopicRectangleByElement(board, nodeRectangle, node.origin);
1022
- result.width = result.width;
1023
1011
  return result;
1024
1012
  }
1025
1013
  function getTopicRectangleByElement(board, nodeRectangle, element) {
1026
1014
  const x = nodeRectangle.x + NodeSpace.getTextLeftSpace(board, element);
1027
1015
  const y = nodeRectangle.y + NodeSpace.getTextTopSpace(board, element);
1028
- const width = NodeSpace.getNodeDynamicWidth(board, element);
1029
- const height = Math.ceil(element.height);
1016
+ const width = NodeSpace.getTopicDynamicWidth(board, element);
1017
+ const height = NodeSpace.getTopicHeight(board, element);
1030
1018
  return { height, width, x, y };
1031
1019
  }
1032
1020
 
@@ -1065,7 +1053,7 @@ const adjustRootToNode = (board, node) => {
1065
1053
  const newNode = { ...node };
1066
1054
  delete newNode.isRoot;
1067
1055
  delete newNode.rightNodeCount;
1068
- delete newNode.type;
1056
+ newNode.type = 'mind_child';
1069
1057
  if (newNode.layout === MindLayoutType.standard) {
1070
1058
  delete newNode.layout;
1071
1059
  }
@@ -1091,7 +1079,7 @@ const adjustNodeToRoot = (board, node) => {
1091
1079
  ...newElement,
1092
1080
  layout: newElement.layout ?? MindLayoutType.right,
1093
1081
  isRoot: true,
1094
- type: 'mindmap'
1082
+ type: 'mind'
1095
1083
  };
1096
1084
  };
1097
1085
 
@@ -2274,9 +2262,10 @@ const MindQueries = {
2274
2262
  getCorrectLayoutByElement
2275
2263
  };
2276
2264
 
2265
+ const LEGACY_MIND_TYPE = 'mindmap';
2277
2266
  const PlaitMind = {
2278
2267
  isMind: (value) => {
2279
- return value.type === 'mindmap';
2268
+ return value.type === 'mind' || value.type === LEGACY_MIND_TYPE;
2280
2269
  }
2281
2270
  };
2282
2271
  const MindElement = {
@@ -2289,10 +2278,7 @@ const MindElement = {
2289
2278
  return isIndentedLayout(_layout);
2290
2279
  },
2291
2280
  isMindElement(board, element) {
2292
- // Design error: The type of the element should be identified based on type.
2293
- // Now it is very awkward whether it is dynamically calculated(query root node) or using other characteristic attributes(current).
2294
- // Using dynamically calculated will cause more issue like pasting from clipboard, finding elements by id(isRecursion)
2295
- if (element.data && element.data.topic && !isNullOrUndefined(element.width) && !isNullOrUndefined(element.height)) {
2281
+ if ((element.data && element.data.topic) || element.type === 'mind_child') {
2296
2282
  return true;
2297
2283
  }
2298
2284
  else {
@@ -2329,7 +2315,7 @@ const MindElement = {
2329
2315
  return parents;
2330
2316
  },
2331
2317
  getNode(element) {
2332
- const node = ELEMENT_TO_NODE.get(element);
2318
+ const node = MIND_ELEMENT_TO_NODE.get(element);
2333
2319
  if (!node) {
2334
2320
  throw new Error(`can not get node from ${JSON.stringify(element)}`);
2335
2321
  }
@@ -2478,8 +2464,7 @@ const setAbstractByElements = (board, groupParent, group) => {
2478
2464
  };
2479
2465
  const insertAbstractNode = (board, path, start, end) => {
2480
2466
  const abstractNodeText = getAbstractNodeText(board);
2481
- const { width, height } = getTopicSize(board, false, false, buildText(abstractNodeText));
2482
- const mindElement = createMindElement(abstractNodeText, width, height, {
2467
+ const mindElement = createMindElement(abstractNodeText, {
2483
2468
  strokeWidth: DefaultAbstractNodeStyle.branch.width,
2484
2469
  branchWidth: DefaultAbstractNodeStyle.branch.width
2485
2470
  });
@@ -2490,42 +2475,25 @@ const insertAbstractNode = (board, path, start, end) => {
2490
2475
  addSelectedElement(board, mindElement);
2491
2476
  };
2492
2477
 
2493
- const normalizeWidthAndHeight = (board, element, width, height) => {
2494
- const minWidth = NodeSpace.getNodeTopicMinWidth(board, element);
2495
- const newWidth = width < minWidth ? minWidth : width;
2496
- return { width: Math.ceil(newWidth), height };
2497
- };
2498
- const setTopic = (board, element, topic, width, height) => {
2478
+ const setTopic = (board, element, topic) => {
2499
2479
  const newElement = {
2500
- data: { ...element.data, topic },
2501
- ...normalizeWidthAndHeight(board, element, width, height)
2480
+ data: { ...element.data }
2502
2481
  };
2482
+ if (topic) {
2483
+ newElement.data.topic = topic;
2484
+ }
2503
2485
  const path = PlaitBoard.findPath(board, element);
2504
2486
  Transforms.setNode(board, newElement, path);
2505
2487
  };
2506
- const setNodeManualWidth = (board, element, width, height) => {
2488
+ const setNodeManualWidth = (board, element, width) => {
2507
2489
  const path = PlaitBoard.findPath(board, element);
2508
- const { width: normalizedWidth, height: normalizedHeight } = normalizeWidthAndHeight(board, element, width, height);
2509
- const newElement = { manualWidth: normalizedWidth, height: normalizedHeight };
2490
+ const { width: normalizedWidth } = normalizeWidthAndHeight(board, element, width, 0);
2491
+ const newElement = { manualWidth: normalizedWidth, data: { ...element.data, topic: { ...element.data.topic } } };
2510
2492
  Transforms.setNode(board, newElement, path);
2511
2493
  };
2512
- const setTopicSize = (board, element, width, height) => {
2513
- const newElement = {
2514
- ...normalizeWidthAndHeight(board, element, width, height)
2515
- };
2516
- let isEqualWidth = Math.ceil(element.width) === Math.ceil(newElement.width);
2517
- let isEqualHeight = Math.ceil(element.height) === Math.ceil(newElement.height);
2518
- if (element.manualWidth) {
2519
- isEqualWidth = true;
2520
- }
2521
- if (!isEqualWidth || !isEqualHeight) {
2522
- const path = PlaitBoard.findPath(board, element);
2523
- Transforms.setNode(board, newElement, path);
2524
- }
2525
- };
2526
2494
  const insertNodes = (board, elements, path) => {
2527
2495
  const pathRef = board.pathRef(path);
2528
- elements.forEach(element => {
2496
+ elements.forEach((element) => {
2529
2497
  if (pathRef.current) {
2530
2498
  Transforms.insertNode(board, element, pathRef.current);
2531
2499
  }
@@ -2535,7 +2503,7 @@ const insertNodes = (board, elements, path) => {
2535
2503
  const insertAbstractNodes = (board, validAbstractRefs, elements, path) => {
2536
2504
  const parent = PlaitNode.get(board, Path$1.parent(path));
2537
2505
  const abstractPath = [...Path$1.parent(path), parent.children?.length];
2538
- const abstracts = validAbstractRefs.map(refs => {
2506
+ const abstracts = validAbstractRefs.map((refs) => {
2539
2507
  const { start, end } = getRelativeStartEndByAbstractRef(refs, elements);
2540
2508
  return {
2541
2509
  ...refs.abstract,
@@ -2546,7 +2514,7 @@ const insertAbstractNodes = (board, validAbstractRefs, elements, path) => {
2546
2514
  insertNodes(board, abstracts, abstractPath);
2547
2515
  };
2548
2516
  const setRightNodeCountByRefs = (board, refs) => {
2549
- refs.forEach(ref => {
2517
+ refs.forEach((ref) => {
2550
2518
  Transforms.setNode(board, { rightNodeCount: ref.rightNodeCount }, ref.path);
2551
2519
  });
2552
2520
  };
@@ -2622,26 +2590,16 @@ const replaceEmoji = (board, element, oldEmoji, newEmoji) => {
2622
2590
  const removeImage = (board, element) => {
2623
2591
  removeImageFocus(board, element);
2624
2592
  const newElement = {
2625
- data: { ...element.data }
2593
+ data: { ...element.data, topic: { ...element.data.topic } }
2626
2594
  };
2627
2595
  delete newElement.data.image;
2628
2596
  const path = PlaitBoard.findPath(board, element);
2629
- const newDynamicWidth = NodeSpace.getNodeNewDynamicWidth(board, element, 0);
2630
- const newHeight = getNewNodeHeight(board, element, newDynamicWidth);
2631
- if (newHeight) {
2632
- newElement.height = newHeight;
2633
- }
2634
2597
  Transforms.setNode(board, newElement, path);
2635
2598
  };
2636
2599
  const setImage = (board, element, imageItem) => {
2637
2600
  const newElement = {
2638
- data: { ...element.data, image: imageItem }
2601
+ data: { ...element.data, image: imageItem, topic: { ...element.data.topic } }
2639
2602
  };
2640
- const newDynamicWidth = NodeSpace.getNodeNewDynamicWidth(board, element, imageItem.width);
2641
- const newHeight = getNewNodeHeight(board, element, newDynamicWidth);
2642
- if (newHeight) {
2643
- newElement.height = newHeight;
2644
- }
2645
2603
  const path = PlaitBoard.findPath(board, element);
2646
2604
  Transforms.setNode(board, newElement, path);
2647
2605
  };
@@ -2698,7 +2656,6 @@ const MindTransforms = {
2698
2656
  setBranchWidth,
2699
2657
  setBranchColor,
2700
2658
  setTopic,
2701
- setTopicSize,
2702
2659
  setNodeManualWidth,
2703
2660
  addEmoji,
2704
2661
  removeEmoji,
@@ -2944,22 +2901,10 @@ class MindNodeComponent extends CommonElementFlavour {
2944
2901
  return rect;
2945
2902
  },
2946
2903
  onChange: (data) => {
2947
- const width = data.width;
2948
- const height = data.height;
2949
- if (data.newText) {
2950
- MindTransforms.setTopic(this.board, this.element, data.newText, width, height);
2951
- }
2952
- else {
2953
- MindTransforms.setTopicSize(this.board, this.element, width, height);
2954
- }
2904
+ MindTransforms.setTopic(this.board, this.element, data.newText);
2955
2905
  },
2956
2906
  getMaxWidth: () => {
2957
- if (this.element.manualWidth) {
2958
- return NodeSpace.getNodeDynamicWidth(this.board, this.element);
2959
- }
2960
- else {
2961
- return Math.max(NodeSpace.getNodeDynamicWidth(this.board, this.element), NodeTopicThreshold.defaultTextMaxWidth);
2962
- }
2907
+ return NodeSpace.getTopicMaxDynamicWidth(this.board, this.element);
2963
2908
  },
2964
2909
  textPlugins: plugins || []
2965
2910
  });
@@ -3069,8 +3014,8 @@ class MindNodeComponent extends CommonElementFlavour {
3069
3014
  this.nodeEmojisGenerator.destroy();
3070
3015
  this.imageGenerator.destroy();
3071
3016
  this.activeGenerator.destroy();
3072
- if (ELEMENT_TO_NODE.get(this.element) === this.node) {
3073
- ELEMENT_TO_NODE.delete(this.element);
3017
+ if (MIND_ELEMENT_TO_NODE.get(this.element) === this.node) {
3018
+ MIND_ELEMENT_TO_NODE.delete(this.element);
3074
3019
  }
3075
3020
  this.getRef().destroyTextManage();
3076
3021
  }
@@ -3099,7 +3044,7 @@ class PlaitMindComponent extends MindNodeComponent {
3099
3044
  depthFirstRecursion(this.root, (node) => {
3100
3045
  node.x = node.x - offsetX + element.points[0][0];
3101
3046
  node.y = node.y - offsetY + element.points[0][1];
3102
- ELEMENT_TO_NODE.set(node.origin, node);
3047
+ MIND_ELEMENT_TO_NODE.set(node.origin, node);
3103
3048
  });
3104
3049
  }
3105
3050
  }
@@ -3808,7 +3753,7 @@ const withNodeResize = (board) => {
3808
3753
  beforeResize: (resizeRef) => {
3809
3754
  targetElementRef = {
3810
3755
  minWidth: NodeSpace.getNodeResizableMinWidth(board, resizeRef.element),
3811
- currentWidth: NodeSpace.getNodeDynamicWidth(board, resizeRef.element),
3756
+ currentWidth: NodeSpace.getTopicDynamicWidth(board, resizeRef.element),
3812
3757
  path: PlaitBoard.findPath(board, resizeRef.element),
3813
3758
  textManage: getFirstTextManage(resizeRef.element)
3814
3759
  };
@@ -3820,9 +3765,7 @@ const withNodeResize = (board) => {
3820
3765
  }
3821
3766
  const newTarget = PlaitNode.get(board, targetElementRef.path);
3822
3767
  if (newTarget && NodeSpace.getNodeTopicMinWidth(board, newTarget) !== resizedWidth) {
3823
- targetElementRef.textManage.updateRectangleWidth(resizedWidth);
3824
- const { height } = targetElementRef.textManage.getSize(undefined, resizedWidth);
3825
- MindTransforms.setNodeManualWidth(board, newTarget, resizedWidth, height);
3768
+ MindTransforms.setNodeManualWidth(board, newTarget, resizedWidth);
3826
3769
  }
3827
3770
  },
3828
3771
  afterResize: (resizeRef) => {
@@ -3950,9 +3893,6 @@ const insertClipboardData = (board, elements, targetPoint, operationType) => {
3950
3893
  if (hasTargetParent && operationType !== WritableClipboardOperationType.duplicate) {
3951
3894
  if (item.isRoot) {
3952
3895
  newElement = adjustRootToNode(board, newElement);
3953
- const { width, height } = getTopicSizeByElement(board, newElement, targetParent);
3954
- newElement.width = width;
3955
- newElement.height = height;
3956
3896
  }
3957
3897
  // handle abstract start and end
3958
3898
  if (AbstractNode.isAbstract(newElement)) {
@@ -3969,9 +3909,6 @@ const insertClipboardData = (board, elements, targetPoint, operationType) => {
3969
3909
  }
3970
3910
  if (!item.isRoot) {
3971
3911
  newElement = adjustNodeToRoot(board, newElement);
3972
- const { width, height } = getTopicSizeByElement(board, newElement);
3973
- newElement.width = width;
3974
- newElement.height = height;
3975
3912
  }
3976
3913
  path = [board.children.length];
3977
3914
  }
@@ -3982,14 +3919,10 @@ const insertClipboardData = (board, elements, targetPoint, operationType) => {
3982
3919
  Transforms.addSelectionWithTemporaryElements(board, newELements);
3983
3920
  };
3984
3921
  const insertClipboardText = (board, targetParent, text) => {
3985
- const { width, height } = getTopicSize(board, false, PlaitMind.isMind(targetParent), buildText(text));
3986
- const newElement = createMindElement(text, Math.max(width, getFontSizeBySlateElement(text)), height, {});
3922
+ const newElement = createMindElement(text, {});
3987
3923
  Transforms.insertNode(board, newElement, findNewChildNodePath(board, targetParent));
3988
3924
  Transforms.addSelectionWithTemporaryElements(board, [newElement]);
3989
3925
  };
3990
- const getTopicSizeByElement = (board, element, parentElement) => {
3991
- return getTopicSize(board, PlaitMind.isMind(element), (parentElement && PlaitMind.isMind(parentElement)) || false, element.data.topic, element.manualWidth);
3992
- };
3993
3926
 
3994
3927
  const withMindFragment = (baseBoard) => {
3995
3928
  const board = baseBoard;
@@ -4096,12 +4029,6 @@ const isNormalizedData = (element) => {
4096
4029
  }
4097
4030
  return true;
4098
4031
  };
4099
- const isNormalizedWidthAndHeight = (element) => {
4100
- if (isNullOrUndefined(element.width) || isNullOrUndefined(element.height)) {
4101
- return false;
4102
- }
4103
- return true;
4104
- };
4105
4032
  const fixMindElementData = (element) => {
4106
4033
  const emptyTopic = {
4107
4034
  children: [
@@ -4120,14 +4047,6 @@ const fixMindElementData = (element) => {
4120
4047
  element.data.topic = emptyTopic;
4121
4048
  }
4122
4049
  };
4123
- const fixMindElementWidthAndHeight = (element) => {
4124
- if (isNullOrUndefined(element.width)) {
4125
- element.width = 56;
4126
- }
4127
- if (isNullOrUndefined(element.height)) {
4128
- element.width = 20;
4129
- }
4130
- };
4131
4050
 
4132
4051
  const withMind = (baseBoard) => {
4133
4052
  const board = baseBoard;
@@ -4138,9 +4057,6 @@ const withMind = (baseBoard) => {
4138
4057
  if (!isNormalizedData(node)) {
4139
4058
  fixMindElementData(node);
4140
4059
  }
4141
- if (!isNormalizedWidthAndHeight(node)) {
4142
- fixMindElementWidthAndHeight(node);
4143
- }
4144
4060
  });
4145
4061
  }
4146
4062
  normalizeElement(context);
@@ -4273,5 +4189,5 @@ class MindEmojiBaseComponent {
4273
4189
  * Generated bundle index. Do not edit.
4274
4190
  */
4275
4191
 
4276
- 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, ELEMENT_TO_NODE, 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, 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, NodeTopicThreshold, 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, 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 };
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 };
4277
4193
  //# sourceMappingURL=plait-mind.mjs.map