@plait/mind 0.49.0 → 0.50.1
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/esm2022/plugins/with-mind-fragment.mjs +28 -19
- package/esm2022/plugins/with-node-image.mjs +25 -24
- package/esm2022/utils/clipboard.mjs +3 -10
- package/esm2022/utils/mind.mjs +1 -12
- package/fesm2022/plait-mind.mjs +49 -57
- package/fesm2022/plait-mind.mjs.map +1 -1
- package/package.json +1 -1
- package/utils/clipboard.d.ts +0 -1
- package/utils/mind.d.ts +0 -1
package/fesm2022/plait-mind.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Component, ChangeDetectionStrategy, NgZone, Directive, Input, HostListener } from '@angular/core';
|
|
3
|
-
import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, PlaitElement, PlaitNode, Path, isNullOrUndefined, PlaitBoard, getSelectedElements, idCreator, Transforms, clearSelectedElement, addSelectedElement, distanceBetweenPointAndRectangle, RectangleClient, depthFirstRecursion, getIsRecursionFunc, drawRoundRectangle, drawLinearPath, drawBezierPath, createG, updateForeignObject, getRectangleByElements, NODE_TO_PARENT, createForeignObject, removeSelectedElement, PlaitHistoryBoard, setStrokeLinecap, ACTIVE_STROKE_WIDTH, createText, PlaitPointerType, NODE_TO_INDEX, PlaitChildrenElementComponent, isMainPointer, toViewBoxPoint, toHostPoint, getHitElementByPoint, distanceBetweenPointAndPoint, CoreTransforms, BOARD_TO_HOST, BoardTransforms, throttleRAF, temporaryDisableSelection, hotkeys,
|
|
3
|
+
import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, PlaitElement, PlaitNode, Path, isNullOrUndefined, PlaitBoard, getSelectedElements, idCreator, Transforms, clearSelectedElement, addSelectedElement, distanceBetweenPointAndRectangle, RectangleClient, depthFirstRecursion, getIsRecursionFunc, drawRoundRectangle, drawLinearPath, drawBezierPath, createG, updateForeignObject, getRectangleByElements, NODE_TO_PARENT, createForeignObject, removeSelectedElement, PlaitHistoryBoard, setStrokeLinecap, ACTIVE_STROKE_WIDTH, createText, PlaitPointerType, NODE_TO_INDEX, PlaitChildrenElementComponent, isMainPointer, toViewBoxPoint, toHostPoint, getHitElementByPoint, distanceBetweenPointAndPoint, CoreTransforms, BOARD_TO_HOST, BoardTransforms, throttleRAF, isContextmenu, temporaryDisableSelection, hotkeys, createClipboardContext, WritableClipboardType, ResizeCursorClass, addClipboardContext, PlaitPluginKey } from '@plait/core';
|
|
4
4
|
import { MindLayoutType, AbstractNode, isIndentedLayout, isHorizontalLayout, isHorizontalLogicLayout, ConnectingPosition, getNonAbstractChildren, isStandardLayout, isLeftLayout, isRightLayout, isVerticalLogicLayout, isTopLayout, isBottomLayout, getCorrectStartEnd, getAbstractLayout, GlobalLayout } from '@plait/layouts';
|
|
5
|
-
import { TEXT_DEFAULT_HEIGHT, buildText, PlaitMarkEditor, MarkTypes, DEFAULT_FONT_SIZE, getTextSize, TextManage, ExitOrigin
|
|
5
|
+
import { TEXT_DEFAULT_HEIGHT, buildText, PlaitMarkEditor, MarkTypes, DEFAULT_FONT_SIZE, getTextSize, TextManage, ExitOrigin } from '@plait/text';
|
|
6
6
|
import { fromEvent, Subject } from 'rxjs';
|
|
7
|
-
import { getFirstTextEditor, RESIZE_HANDLE_DIAMETER, getRectangleResizeHandleRefs, addElementOfFocusedImage, removeElementOfFocusedImage, getFirstTextManage, PropertyTransforms, Generator, CommonPluginElement, ImageGenerator, WithTextPluginKey, isDrawingMode, isDndMode, setCreationMode, BoardCreationMode, isExpandHotkey, isTabHotkey, isEnterHotkey, isVirtualKey, isDelete, isSpaceHotkey, getElementOfFocusedImage,
|
|
7
|
+
import { getFirstTextEditor, RESIZE_HANDLE_DIAMETER, getRectangleResizeHandleRefs, addElementOfFocusedImage, removeElementOfFocusedImage, getFirstTextManage, PropertyTransforms, Generator, CommonPluginElement, ImageGenerator, WithTextPluginKey, isDrawingMode, isDndMode, setCreationMode, BoardCreationMode, isExpandHotkey, isTabHotkey, isEnterHotkey, isVirtualKey, isDelete, isSpaceHotkey, getElementOfFocusedImage, acceptImageTypes, buildImage, withResize, ResizeHandle, getElementsText } from '@plait/common';
|
|
8
8
|
import { Node as Node$1, Path as Path$1 } from 'slate';
|
|
9
9
|
import { pointsOnBezierCurves } from 'points-on-curve';
|
|
10
10
|
import { take, filter } from 'rxjs/operators';
|
|
@@ -760,16 +760,6 @@ const copyNewNode = (node) => {
|
|
|
760
760
|
}
|
|
761
761
|
return newNode;
|
|
762
762
|
};
|
|
763
|
-
const extractNodesText = (node) => {
|
|
764
|
-
let str = '';
|
|
765
|
-
if (node) {
|
|
766
|
-
str += Node$1.string(node.data.topic) + ' ';
|
|
767
|
-
for (const childNode of node.children) {
|
|
768
|
-
str += extractNodesText(childNode);
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
return str;
|
|
772
|
-
};
|
|
773
763
|
const insertMindElement = (board, inheritNode, path) => {
|
|
774
764
|
const newNode = {};
|
|
775
765
|
if (!inheritNode.isRoot) {
|
|
@@ -3695,7 +3685,8 @@ const withNodeImage = (board) => {
|
|
|
3695
3685
|
const { keydown, pointerDown, globalPointerUp, setFragment, insertFragment, deleteFragment } = board;
|
|
3696
3686
|
board.pointerDown = (event) => {
|
|
3697
3687
|
const elementOfFocusedImage = getElementOfFocusedImage(board);
|
|
3698
|
-
if (
|
|
3688
|
+
if (!isContextmenu(event) &&
|
|
3689
|
+
(PlaitBoard.isReadonly(board) || !isMainPointer(event) || !PlaitBoard.isPointer(board, PlaitPointerType.selection))) {
|
|
3699
3690
|
if (elementOfFocusedImage && MindElement.isMindElement(board, elementOfFocusedImage)) {
|
|
3700
3691
|
removeImageFocus(board, elementOfFocusedImage);
|
|
3701
3692
|
}
|
|
@@ -3742,13 +3733,12 @@ const withNodeImage = (board) => {
|
|
|
3742
3733
|
}
|
|
3743
3734
|
globalPointerUp(event);
|
|
3744
3735
|
};
|
|
3745
|
-
board.setFragment = (data, rectangle, type) => {
|
|
3736
|
+
board.setFragment = (data, clipboardContext, rectangle, type) => {
|
|
3746
3737
|
const selectedImageElement = getElementOfFocusedImage(board);
|
|
3747
3738
|
if (selectedImageElement) {
|
|
3748
|
-
|
|
3749
|
-
return;
|
|
3739
|
+
clipboardContext = createClipboardContext(WritableClipboardType.medias, [selectedImageElement.data.image], '');
|
|
3750
3740
|
}
|
|
3751
|
-
setFragment(data, rectangle, type);
|
|
3741
|
+
setFragment(data, clipboardContext, rectangle, type);
|
|
3752
3742
|
};
|
|
3753
3743
|
board.deleteFragment = (data) => {
|
|
3754
3744
|
const selectedImageElement = getElementOfFocusedImage(board);
|
|
@@ -3757,28 +3747,29 @@ const withNodeImage = (board) => {
|
|
|
3757
3747
|
}
|
|
3758
3748
|
deleteFragment(data);
|
|
3759
3749
|
};
|
|
3760
|
-
board.insertFragment = (data, targetPoint) => {
|
|
3750
|
+
board.insertFragment = (data, clipboardData, targetPoint) => {
|
|
3761
3751
|
const selectedElements = getSelectedElements(board);
|
|
3762
3752
|
const isSelectedImage = !!getElementOfFocusedImage(board);
|
|
3763
3753
|
const isSingleSelection = selectedElements.length === 1 && MindElement.isMindElement(board, selectedElements[0]);
|
|
3764
|
-
if (
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3754
|
+
if (isSelectedImage || isSingleSelection) {
|
|
3755
|
+
if (clipboardData?.files?.length) {
|
|
3756
|
+
const acceptImageArray = acceptImageTypes.map(type => 'image/' + type);
|
|
3757
|
+
const selectedElement = (selectedElements[0] || getElementOfFocusedImage(board));
|
|
3758
|
+
if (acceptImageArray.includes(clipboardData.files[0].type)) {
|
|
3759
|
+
const imageFile = clipboardData.files[0];
|
|
3760
|
+
buildImage(board, imageFile, DEFAULT_MIND_IMAGE_WIDTH, imageItem => {
|
|
3761
|
+
MindTransforms.setImage(board, selectedElement, imageItem);
|
|
3762
|
+
});
|
|
3763
|
+
return;
|
|
3764
|
+
}
|
|
3765
|
+
}
|
|
3766
|
+
if (clipboardData?.medias?.length) {
|
|
3767
|
+
const selectedElement = (selectedElements[0] || getElementOfFocusedImage(board));
|
|
3768
|
+
MindTransforms.setImage(board, selectedElement, clipboardData.medias[0]);
|
|
3772
3769
|
return;
|
|
3773
3770
|
}
|
|
3774
3771
|
}
|
|
3775
|
-
|
|
3776
|
-
if (imageItem && (isSingleSelection || isSelectedImage)) {
|
|
3777
|
-
const selectedElement = (selectedElements[0] || getElementOfFocusedImage(board));
|
|
3778
|
-
MindTransforms.setImage(board, selectedElement, imageItem);
|
|
3779
|
-
return;
|
|
3780
|
-
}
|
|
3781
|
-
insertFragment(data, targetPoint);
|
|
3772
|
+
insertFragment(data, clipboardData, targetPoint);
|
|
3782
3773
|
};
|
|
3783
3774
|
return board;
|
|
3784
3775
|
};
|
|
@@ -3932,13 +3923,6 @@ const buildClipboardData = (board, selectedElements, startPoint) => {
|
|
|
3932
3923
|
});
|
|
3933
3924
|
return result;
|
|
3934
3925
|
};
|
|
3935
|
-
const setMindClipboardData = (data, elements) => {
|
|
3936
|
-
const text = elements.reduce((string, currentNode) => {
|
|
3937
|
-
return string + extractNodesText(currentNode);
|
|
3938
|
-
}, '');
|
|
3939
|
-
setClipboardData(data, elements);
|
|
3940
|
-
setClipboardDataByText(data, text);
|
|
3941
|
-
};
|
|
3942
3926
|
const insertClipboardData = (board, elements, targetPoint) => {
|
|
3943
3927
|
let newElement, path;
|
|
3944
3928
|
const selectedElements = getSelectedElements(board);
|
|
@@ -4012,32 +3996,40 @@ const withMindFragment = (baseBoard) => {
|
|
|
4012
3996
|
}
|
|
4013
3997
|
return getDeletedFragment(data);
|
|
4014
3998
|
};
|
|
4015
|
-
board.setFragment = (data, rectangle, type) => {
|
|
3999
|
+
board.setFragment = (data, clipboardContext, rectangle, type) => {
|
|
4016
4000
|
const targetMindElements = getSelectedMindElements(board);
|
|
4017
4001
|
const firstLevelElements = getFirstLevelElement(targetMindElements);
|
|
4018
4002
|
if (firstLevelElements.length) {
|
|
4019
4003
|
const elements = buildClipboardData(board, firstLevelElements, rectangle ? [rectangle.x, rectangle.y] : [0, 0]);
|
|
4020
|
-
|
|
4004
|
+
const text = getElementsText(targetMindElements);
|
|
4005
|
+
if (!clipboardContext) {
|
|
4006
|
+
clipboardContext = createClipboardContext(WritableClipboardType.elements, elements, text);
|
|
4007
|
+
}
|
|
4008
|
+
else {
|
|
4009
|
+
clipboardContext = addClipboardContext(clipboardContext, {
|
|
4010
|
+
text,
|
|
4011
|
+
type: WritableClipboardType.elements,
|
|
4012
|
+
data: elements
|
|
4013
|
+
});
|
|
4014
|
+
}
|
|
4021
4015
|
}
|
|
4022
|
-
setFragment(data, rectangle, type);
|
|
4016
|
+
setFragment(data, clipboardContext, rectangle, type);
|
|
4023
4017
|
};
|
|
4024
|
-
board.insertFragment = (data, targetPoint) => {
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4018
|
+
board.insertFragment = (data, clipboardData, targetPoint) => {
|
|
4019
|
+
if (clipboardData?.elements?.length) {
|
|
4020
|
+
const mindElements = clipboardData.elements?.filter(value => MindElement.isMindElement(board, value));
|
|
4021
|
+
if (mindElements && mindElements.length > 0) {
|
|
4022
|
+
insertClipboardData(board, mindElements, targetPoint);
|
|
4023
|
+
}
|
|
4029
4024
|
}
|
|
4030
|
-
|
|
4025
|
+
if (clipboardData?.text) {
|
|
4031
4026
|
const mindElements = getSelectedMindElements(board);
|
|
4032
4027
|
if (mindElements.length === 1) {
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
insertClipboardText(board, mindElements[0], buildText(text));
|
|
4036
|
-
return;
|
|
4037
|
-
}
|
|
4028
|
+
insertClipboardText(board, mindElements[0], buildText(clipboardData.text));
|
|
4029
|
+
return;
|
|
4038
4030
|
}
|
|
4039
4031
|
}
|
|
4040
|
-
insertFragment(data, targetPoint);
|
|
4032
|
+
insertFragment(data, clipboardData, targetPoint);
|
|
4041
4033
|
};
|
|
4042
4034
|
return board;
|
|
4043
4035
|
};
|
|
@@ -4212,5 +4204,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
|
|
|
4212
4204
|
* Generated bundle index. Do not edit.
|
|
4213
4205
|
*/
|
|
4214
4206
|
|
|
4215
|
-
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_FONT_FAMILY, BRANCH_WIDTH, BranchShape, DEFAULT_FONT_FAMILY, DEFAULT_MIND_IMAGE_WIDTH, DefaultAbstractNodeStyle, DefaultNodeStyle, ELEMENT_TO_NODE, EXTEND_DIAMETER, EXTEND_OFFSET, GRAY_COLOR, INHERIT_ATTRIBUTE_KEYS, IS_DRAGGING, 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, ROOT_TOPIC_HEIGHT, ROOT_TOPIC_WIDTH, STROKE_WIDTH, TOPIC_COLOR, TOPIC_DEFAULT_MAX_WORD_COUNT, TOPIC_FONT_SIZE, WithMindPluginKey, addActiveOnDragOrigin, addImageFocus, adjustAbstractToNode, adjustNodeToRoot, adjustRootToNode, canSetAbstract, copyNewNode, correctLayoutByDirection, createDefaultMind, createEmptyMind, createMindElement, deleteElementHandleAbstract, deleteElementsHandleRightNodeCount, detectDropTarget, directionCorrector, directionDetector, divideElementByParent, drawFakeDragNode, drawFakeDropNode, editTopic,
|
|
4207
|
+
export { ABSTRACT_HANDLE_COLOR, ABSTRACT_HANDLE_LENGTH, ABSTRACT_HANDLE_MASK_WIDTH, ABSTRACT_INCLUDED_OUTLINE_OFFSET, AbstractHandlePosition, AbstractResizeState, BASE, BRANCH_FONT_FAMILY, BRANCH_WIDTH, BranchShape, DEFAULT_FONT_FAMILY, DEFAULT_MIND_IMAGE_WIDTH, DefaultAbstractNodeStyle, DefaultNodeStyle, ELEMENT_TO_NODE, EXTEND_DIAMETER, EXTEND_OFFSET, GRAY_COLOR, INHERIT_ATTRIBUTE_KEYS, IS_DRAGGING, 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, ROOT_TOPIC_HEIGHT, ROOT_TOPIC_WIDTH, STROKE_WIDTH, TOPIC_COLOR, TOPIC_DEFAULT_MAX_WORD_COUNT, TOPIC_FONT_SIZE, WithMindPluginKey, addActiveOnDragOrigin, addImageFocus, adjustAbstractToNode, adjustNodeToRoot, adjustRootToNode, canSetAbstract, copyNewNode, correctLayoutByDirection, createDefaultMind, 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, 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, getStrokeByMindElement, getStrokeWidthByElement, getTopicRectangleByElement, getTopicRectangleByNode, getValidAbstractRefs, handleTouchedAbstract, hasPreviousOrNextOfDropPath, insertElementHandleAbstract, insertElementHandleRightNodeCount, insertMindElement, isChildElement, isChildOfAbstract, isChildRight, isChildUp, isCorrectLayout, isDragging, isDropStandardRight, isHitEmojis, isHitImage, isHitMindElement, isInRightBranchOfStandardLayout, isMixedLayout, isSetAbstract, isValidTarget, removeActiveOnDragOrigin, removeImageFocus, separateChildren, setIsDragging, withMind, withMindExtend };
|
|
4216
4208
|
//# sourceMappingURL=plait-mind.mjs.map
|