@plait/mind 0.83.1 → 0.84.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/fesm2022/plait-mind.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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,
|
|
4
|
-
import { TEXT_DEFAULT_HEIGHT,
|
|
3
|
+
import { StrokeStyle, getFirstTextManage, DEFAULT_FONT_FAMILY, measureElement, buildText, getElementSize, 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, getFirstTextMarks, MarkTypes, DEFAULT_FONT_SIZE, PlaitMarkEditor, 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';
|
|
@@ -875,23 +875,35 @@ const NodeSpace = {
|
|
|
875
875
|
return (NodeSpace.getEmojiLeftSpace(board, element) +
|
|
876
876
|
getEmojisWidthHeight(board, element).width +
|
|
877
877
|
getSpaceEmojiAndText(element) +
|
|
878
|
-
NodeSpace.
|
|
878
|
+
NodeSpace.getTopicDynamicWidth(board, element) +
|
|
879
879
|
nodeAndText);
|
|
880
880
|
}
|
|
881
|
-
return nodeAndText + NodeSpace.
|
|
881
|
+
return nodeAndText + NodeSpace.getTopicDynamicWidth(board, element) + nodeAndText;
|
|
882
882
|
},
|
|
883
883
|
getNodeHeight(board, element) {
|
|
884
|
+
const topicSize = getElementSize(board, element.data.topic, { fontSize: DEFAULT_FONT_SIZE, fontFamily: DEFAULT_FONT_FAMILY }, NodeSpace.getTopicMaxDynamicWidth(board, element));
|
|
885
|
+
const normalizedSize = normalizeWidthAndHeight(board, element, topicSize.width, topicSize.height);
|
|
884
886
|
const nodeAndText = getVerticalSpaceBetweenNodeAndText(board, element);
|
|
885
887
|
if (MindElement.hasImage(element)) {
|
|
886
|
-
return NodeSpace.getTextTopSpace(board, element) +
|
|
888
|
+
return NodeSpace.getTextTopSpace(board, element) + normalizedSize.height + nodeAndText;
|
|
887
889
|
}
|
|
888
|
-
return nodeAndText +
|
|
890
|
+
return nodeAndText + normalizedSize.height + nodeAndText;
|
|
889
891
|
},
|
|
890
|
-
|
|
891
|
-
const
|
|
892
|
+
getTopicDynamicWidth(board, element) {
|
|
893
|
+
const topicSize = getElementSize(board, element.data.topic, { fontSize: getDefaultMindElementFontSize(board, element), fontFamily: DEFAULT_FONT_FAMILY }, NodeSpace.getTopicMaxDynamicWidth(board, element));
|
|
894
|
+
const normalizedSize = normalizeWidthAndHeight(board, element, topicSize.width, topicSize.width);
|
|
895
|
+
const width = element.manualWidth || normalizedSize.width;
|
|
892
896
|
const imageWidth = MindElement.hasImage(element) ? element.data.image?.width : 0;
|
|
893
897
|
return Math.max(width, imageWidth);
|
|
894
898
|
},
|
|
899
|
+
getTopicHeight(board, element) {
|
|
900
|
+
const topicSize = getElementSize(board, element.data.topic, { fontSize: DEFAULT_FONT_SIZE, fontFamily: DEFAULT_FONT_FAMILY }, NodeSpace.getTopicMaxDynamicWidth(board, element));
|
|
901
|
+
const normalizedSize = normalizeWidthAndHeight(board, element, topicSize.width, topicSize.height);
|
|
902
|
+
return normalizedSize.height;
|
|
903
|
+
},
|
|
904
|
+
getTopicMaxDynamicWidth(board, element) {
|
|
905
|
+
return Math.max(NodeTopicThreshold.defaultTextMaxWidth, element.manualWidth || 0, MindElement.hasImage(element) ? element.data.image?.width : 0);
|
|
906
|
+
},
|
|
895
907
|
/**
|
|
896
908
|
* use it when upload image first or resize image
|
|
897
909
|
*/
|
|
@@ -910,9 +922,8 @@ const NodeSpace = {
|
|
|
910
922
|
},
|
|
911
923
|
getNodeTopicMinWidth(board, element) {
|
|
912
924
|
const defaultFontSize = getDefaultMindElementFontSize(board, element);
|
|
913
|
-
const
|
|
914
|
-
const
|
|
915
|
-
const fontSize = marks[MarkTypes.fontSize] || defaultFontSize;
|
|
925
|
+
const firstText = getFirstTextMarks(element.data.topic);
|
|
926
|
+
const fontSize = (firstText[MarkTypes.fontSize] ? Number(firstText[MarkTypes.fontSize]) : null) || defaultFontSize;
|
|
916
927
|
return fontSize;
|
|
917
928
|
},
|
|
918
929
|
getTextLeftSpace(board, element) {
|
|
@@ -956,6 +967,11 @@ const getFontSizeBySlateElement = (text) => {
|
|
|
956
967
|
const fontSize = marks[MarkTypes.fontSize] || defaultFontSize;
|
|
957
968
|
return fontSize;
|
|
958
969
|
};
|
|
970
|
+
const normalizeWidthAndHeight = (board, element, width, height) => {
|
|
971
|
+
const minWidth = NodeSpace.getNodeTopicMinWidth(board, element);
|
|
972
|
+
const newWidth = width < minWidth ? minWidth : width;
|
|
973
|
+
return { width: newWidth, height };
|
|
974
|
+
};
|
|
959
975
|
|
|
960
976
|
function getRectangleByNode(node) {
|
|
961
977
|
const x = node.x + node.hGap;
|
|
@@ -1019,14 +1035,13 @@ const isHitEmojis = (board, element, point) => {
|
|
|
1019
1035
|
function getTopicRectangleByNode(board, node) {
|
|
1020
1036
|
let nodeRectangle = getRectangleByNode(node);
|
|
1021
1037
|
const result = getTopicRectangleByElement(board, nodeRectangle, node.origin);
|
|
1022
|
-
result.width = result.width;
|
|
1023
1038
|
return result;
|
|
1024
1039
|
}
|
|
1025
1040
|
function getTopicRectangleByElement(board, nodeRectangle, element) {
|
|
1026
1041
|
const x = nodeRectangle.x + NodeSpace.getTextLeftSpace(board, element);
|
|
1027
1042
|
const y = nodeRectangle.y + NodeSpace.getTextTopSpace(board, element);
|
|
1028
|
-
const width = NodeSpace.
|
|
1029
|
-
const height =
|
|
1043
|
+
const width = NodeSpace.getTopicDynamicWidth(board, element);
|
|
1044
|
+
const height = NodeSpace.getTopicHeight(board, element);
|
|
1030
1045
|
return { height, width, x, y };
|
|
1031
1046
|
}
|
|
1032
1047
|
|
|
@@ -2490,11 +2505,6 @@ const insertAbstractNode = (board, path, start, end) => {
|
|
|
2490
2505
|
addSelectedElement(board, mindElement);
|
|
2491
2506
|
};
|
|
2492
2507
|
|
|
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
2508
|
const setTopic = (board, element, topic, width, height) => {
|
|
2499
2509
|
const newElement = {
|
|
2500
2510
|
data: { ...element.data, topic },
|
|
@@ -2525,7 +2535,7 @@ const setTopicSize = (board, element, width, height) => {
|
|
|
2525
2535
|
};
|
|
2526
2536
|
const insertNodes = (board, elements, path) => {
|
|
2527
2537
|
const pathRef = board.pathRef(path);
|
|
2528
|
-
elements.forEach(element => {
|
|
2538
|
+
elements.forEach((element) => {
|
|
2529
2539
|
if (pathRef.current) {
|
|
2530
2540
|
Transforms.insertNode(board, element, pathRef.current);
|
|
2531
2541
|
}
|
|
@@ -2535,7 +2545,7 @@ const insertNodes = (board, elements, path) => {
|
|
|
2535
2545
|
const insertAbstractNodes = (board, validAbstractRefs, elements, path) => {
|
|
2536
2546
|
const parent = PlaitNode.get(board, Path$1.parent(path));
|
|
2537
2547
|
const abstractPath = [...Path$1.parent(path), parent.children?.length];
|
|
2538
|
-
const abstracts = validAbstractRefs.map(refs => {
|
|
2548
|
+
const abstracts = validAbstractRefs.map((refs) => {
|
|
2539
2549
|
const { start, end } = getRelativeStartEndByAbstractRef(refs, elements);
|
|
2540
2550
|
return {
|
|
2541
2551
|
...refs.abstract,
|
|
@@ -2546,7 +2556,7 @@ const insertAbstractNodes = (board, validAbstractRefs, elements, path) => {
|
|
|
2546
2556
|
insertNodes(board, abstracts, abstractPath);
|
|
2547
2557
|
};
|
|
2548
2558
|
const setRightNodeCountByRefs = (board, refs) => {
|
|
2549
|
-
refs.forEach(ref => {
|
|
2559
|
+
refs.forEach((ref) => {
|
|
2550
2560
|
Transforms.setNode(board, { rightNodeCount: ref.rightNodeCount }, ref.path);
|
|
2551
2561
|
});
|
|
2552
2562
|
};
|
|
@@ -2954,12 +2964,7 @@ class MindNodeComponent extends CommonElementFlavour {
|
|
|
2954
2964
|
}
|
|
2955
2965
|
},
|
|
2956
2966
|
getMaxWidth: () => {
|
|
2957
|
-
|
|
2958
|
-
return NodeSpace.getNodeDynamicWidth(this.board, this.element);
|
|
2959
|
-
}
|
|
2960
|
-
else {
|
|
2961
|
-
return Math.max(NodeSpace.getNodeDynamicWidth(this.board, this.element), NodeTopicThreshold.defaultTextMaxWidth);
|
|
2962
|
-
}
|
|
2967
|
+
return NodeSpace.getTopicMaxDynamicWidth(this.board, this.element);
|
|
2963
2968
|
},
|
|
2964
2969
|
textPlugins: plugins || []
|
|
2965
2970
|
});
|
|
@@ -3808,7 +3813,7 @@ const withNodeResize = (board) => {
|
|
|
3808
3813
|
beforeResize: (resizeRef) => {
|
|
3809
3814
|
targetElementRef = {
|
|
3810
3815
|
minWidth: NodeSpace.getNodeResizableMinWidth(board, resizeRef.element),
|
|
3811
|
-
currentWidth: NodeSpace.
|
|
3816
|
+
currentWidth: NodeSpace.getTopicDynamicWidth(board, resizeRef.element),
|
|
3812
3817
|
path: PlaitBoard.findPath(board, resizeRef.element),
|
|
3813
3818
|
textManage: getFirstTextManage(resizeRef.element)
|
|
3814
3819
|
};
|
|
@@ -4273,5 +4278,5 @@ class MindEmojiBaseComponent {
|
|
|
4273
4278
|
* Generated bundle index. Do not edit.
|
|
4274
4279
|
*/
|
|
4275
4280
|
|
|
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 };
|
|
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, 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, normalizeWidthAndHeight, removeActiveOnDragOrigin, removeImageFocus, separateChildren, setMindDragging, withEmoji, withMind, withMindExtend };
|
|
4277
4282
|
//# sourceMappingURL=plait-mind.mjs.map
|