@plait/mind 0.27.0-next.5 → 0.27.0-next.6
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/base/image-base.component.mjs +1 -4
- package/esm2022/interfaces/element.mjs +9 -2
- package/esm2022/interfaces/index.mjs +2 -1
- package/esm2022/interfaces/options.mjs +1 -1
- package/esm2022/mind-node.component.mjs +9 -5
- package/esm2022/plugins/with-node-resize.mjs +5 -5
- package/esm2022/utils/draw/node-dnd.mjs +2 -2
- package/esm2022/utils/node/dynamic-width.mjs +3 -3
- package/fesm2022/plait-mind.mjs +22 -14
- package/fesm2022/plait-mind.mjs.map +1 -1
- package/interfaces/element.d.ts +1 -0
- package/interfaces/index.d.ts +1 -0
- package/mind-node.component.d.ts +4 -3
- package/package.json +1 -1
package/fesm2022/plait-mind.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Component, ChangeDetectionStrategy, NgModule, NgZone, Directive, Input, HostListener } from '@angular/core';
|
|
3
3
|
import * as i2 from '@plait/core';
|
|
4
|
-
import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, RectangleClient, PlaitElement, PlaitPluginKey, getSelectedElements, idCreator, isNullOrUndefined, Transforms, clearSelectedElement, addSelectedElement, PlaitBoard, Path, PlaitNode, PlaitContextService, depthFirstRecursion, getIsRecursionFunc, drawLinearPath, drawBezierPath, createG, updateForeignObject, drawRoundRectangle, getRectangleByElements, NODE_TO_PARENT, distanceBetweenPointAndRectangle, createForeignObject, setStrokeLinecap, createText, PlaitPointerType,
|
|
4
|
+
import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, RectangleClient, PlaitElement, PlaitPluginKey, getSelectedElements, idCreator, isNullOrUndefined, Transforms, clearSelectedElement, addSelectedElement, PlaitBoard, Path, PlaitNode, PlaitContextService, depthFirstRecursion, getIsRecursionFunc, drawLinearPath, drawBezierPath, createG, updateForeignObject, drawRoundRectangle, getRectangleByElements, NODE_TO_PARENT, distanceBetweenPointAndRectangle, createForeignObject, setStrokeLinecap, createText, PlaitPointerType, NODE_TO_INDEX, PlaitModule, isMainPointer, transformPoint, toPoint, getHitElements, distanceBetweenPointAndPoint, CoreTransforms, BOARD_TO_HOST, BoardTransforms, throttleRAF, removeSelectedElement, PlaitHistoryBoard, hotkeys, setClipboardDataByMedia, getClipboardDataByMedia, ResizeCursorClass, preventTouchMove, PRESS_AND_MOVE_BUFFER, MERGING, setClipboardData, setClipboardDataByText, getDataFromClipboard } from '@plait/core';
|
|
5
5
|
import { MindLayoutType, isIndentedLayout, isHorizontalLayout, isHorizontalLogicLayout, ConnectingPosition, AbstractNode, isStandardLayout, isVerticalLogicLayout, getNonAbstractChildren, isLeftLayout, isRightLayout, isTopLayout, isBottomLayout, getCorrectStartEnd, getAbstractLayout, GlobalLayout } from '@plait/layouts';
|
|
6
6
|
import { PlaitMarkEditor, MarkTypes, DEFAULT_FONT_SIZE, TEXT_DEFAULT_HEIGHT, buildText, getTextSize, TextManage, ExitOrigin, TextModule, getTextFromClipboard } from '@plait/text';
|
|
7
7
|
import { fromEvent, Subject } from 'rxjs';
|
|
8
|
-
import { RESIZE_HANDLE_DIAMETER, getRectangleResizeHandleRefs, WithTextPluginKey, isDrawingMode, isDndMode, setCreationMode, BoardCreationMode, isExpandHotkey, isTabHotkey, isEnterHotkey, isVirtualKey, isDelete, isSpaceHotkey, MediaKeys, ResizeHandle, withResize, ActiveGenerator } from '@plait/common';
|
|
8
|
+
import { RESIZE_HANDLE_DIAMETER, getRectangleResizeHandleRefs, CommonPluginElement, WithTextPluginKey, isDrawingMode, isDndMode, setCreationMode, BoardCreationMode, isExpandHotkey, isTabHotkey, isEnterHotkey, isVirtualKey, isDelete, isSpaceHotkey, MediaKeys, ResizeHandle, withResize, ActiveGenerator } from '@plait/common';
|
|
9
9
|
import { Node as Node$1, Path as Path$1 } from 'slate';
|
|
10
10
|
import { pointsOnBezierCurves } from 'points-on-curve';
|
|
11
11
|
import { take, filter } from 'rxjs/operators';
|
|
@@ -1179,7 +1179,7 @@ const replaceEmoji = (board, element, oldEmoji, newEmoji) => {
|
|
|
1179
1179
|
* 2. new height is effected by zoom
|
|
1180
1180
|
*/
|
|
1181
1181
|
const getNewNodeHeight = (board, element, newNodeDynamicWidth) => {
|
|
1182
|
-
const textManage =
|
|
1182
|
+
const textManage = MindElement.getTextManage(element);
|
|
1183
1183
|
const { height } = textManage.getSize();
|
|
1184
1184
|
textManage.updateRectangleWidth(newNodeDynamicWidth);
|
|
1185
1185
|
const { height: newHeight } = textManage.getSize();
|
|
@@ -1873,7 +1873,7 @@ const drawFakeDragNode = (board, element, offsetX, offsetY) => {
|
|
|
1873
1873
|
};
|
|
1874
1874
|
const textRectangle = getTopicRectangleByNode(board, activeComponent.node);
|
|
1875
1875
|
const fakeNodeG = drawRoundRectangleByNode(board, fakeDraggingNode);
|
|
1876
|
-
const richtextG =
|
|
1876
|
+
const richtextG = MindElement.getTextManage(element).g.cloneNode(true);
|
|
1877
1877
|
updateForeignObject(richtextG, textRectangle.width, textRectangle.height, textRectangle.x + offsetX, textRectangle.y + offsetY);
|
|
1878
1878
|
dragFakeNodeG?.append(fakeNodeG);
|
|
1879
1879
|
dragFakeNodeG?.append(richtextG);
|
|
@@ -2436,7 +2436,14 @@ const MindElement = {
|
|
|
2436
2436
|
getTextEditor(element) {
|
|
2437
2437
|
const component = PlaitElement.getComponent(element);
|
|
2438
2438
|
if (component) {
|
|
2439
|
-
return
|
|
2439
|
+
return MindElement.getTextManage(element).componentRef.instance.editor;
|
|
2440
|
+
}
|
|
2441
|
+
throw new Error('can not get correctly component in get text editor');
|
|
2442
|
+
},
|
|
2443
|
+
getTextManage(element) {
|
|
2444
|
+
const component = PlaitElement.getComponent(element);
|
|
2445
|
+
if (component) {
|
|
2446
|
+
return component.textManage;
|
|
2440
2447
|
}
|
|
2441
2448
|
throw new Error('can not get correctly component in get text editor');
|
|
2442
2449
|
}
|
|
@@ -3030,7 +3037,10 @@ class NodeImageDrawer {
|
|
|
3030
3037
|
}
|
|
3031
3038
|
}
|
|
3032
3039
|
|
|
3033
|
-
class MindNodeComponent extends
|
|
3040
|
+
class MindNodeComponent extends CommonPluginElement {
|
|
3041
|
+
get textManage() {
|
|
3042
|
+
return this.getTextManages()[0];
|
|
3043
|
+
}
|
|
3034
3044
|
constructor(viewContainerRef, cdr) {
|
|
3035
3045
|
super(cdr);
|
|
3036
3046
|
this.viewContainerRef = viewContainerRef;
|
|
@@ -3048,7 +3058,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
3048
3058
|
this.collapseDrawer = new CollapseDrawer(this.board);
|
|
3049
3059
|
this.imageDrawer = new NodeImageDrawer(this.board, this.viewContainerRef);
|
|
3050
3060
|
const plugins = this.board.getPluginOptions(WithTextPluginKey).textPlugins;
|
|
3051
|
-
|
|
3061
|
+
const textManage = new TextManage(this.board, this.viewContainerRef, {
|
|
3052
3062
|
getRectangle: () => {
|
|
3053
3063
|
const rect = getTopicRectangleByNode(this.board, this.node);
|
|
3054
3064
|
return rect;
|
|
@@ -3073,6 +3083,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
3073
3083
|
}
|
|
3074
3084
|
}
|
|
3075
3085
|
});
|
|
3086
|
+
this.initializeTextManages([textManage]);
|
|
3076
3087
|
}
|
|
3077
3088
|
ngOnInit() {
|
|
3078
3089
|
super.ngOnInit();
|
|
@@ -3907,6 +3918,7 @@ const withNodeResize = (board) => {
|
|
|
3907
3918
|
PlaitBoard.getBoardContainer(board).classList.add(ResizeCursorClass['ew-resize']);
|
|
3908
3919
|
targetElement = newTargetElement;
|
|
3909
3920
|
startPoint = [event.x, event.y];
|
|
3921
|
+
preventTouchMove(board, event, true);
|
|
3910
3922
|
return;
|
|
3911
3923
|
}
|
|
3912
3924
|
pointerDown(event);
|
|
@@ -3919,7 +3931,6 @@ const withNodeResize = (board) => {
|
|
|
3919
3931
|
if (startPoint && targetElement && !isMindNodeResizing(board)) {
|
|
3920
3932
|
// prevent text from being selected
|
|
3921
3933
|
event.preventDefault();
|
|
3922
|
-
preventTouchMove(board, true);
|
|
3923
3934
|
const endPoint = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3924
3935
|
const distance = distanceBetweenPointAndPoint(startPoint[0], startPoint[1], endPoint[0], endPoint[1]);
|
|
3925
3936
|
if (distance > PRESS_AND_MOVE_BUFFER) {
|
|
@@ -3928,7 +3939,7 @@ const withNodeResize = (board) => {
|
|
|
3928
3939
|
minWidth: NodeSpace.getNodeResizableMinWidth(board, targetElement),
|
|
3929
3940
|
currentWidth: NodeSpace.getNodeDynamicWidth(board, targetElement),
|
|
3930
3941
|
path: PlaitBoard.findPath(board, targetElement),
|
|
3931
|
-
textManage:
|
|
3942
|
+
textManage: MindElement.getTextManage(targetElement)
|
|
3932
3943
|
};
|
|
3933
3944
|
MERGING.set(board, true);
|
|
3934
3945
|
}
|
|
@@ -3936,7 +3947,7 @@ const withNodeResize = (board) => {
|
|
|
3936
3947
|
if (isMindNodeResizing(board) && startPoint && targetElementRef) {
|
|
3937
3948
|
// prevent text from being selected
|
|
3938
3949
|
event.preventDefault();
|
|
3939
|
-
preventTouchMove(board, true);
|
|
3950
|
+
preventTouchMove(board, event, true);
|
|
3940
3951
|
throttleRAF(() => {
|
|
3941
3952
|
if (!startPoint) {
|
|
3942
3953
|
return;
|
|
@@ -3980,7 +3991,7 @@ const withNodeResize = (board) => {
|
|
|
3980
3991
|
targetElement = null;
|
|
3981
3992
|
startPoint = null;
|
|
3982
3993
|
MERGING.set(board, false);
|
|
3983
|
-
preventTouchMove(board, false);
|
|
3994
|
+
preventTouchMove(board, event, false);
|
|
3984
3995
|
}
|
|
3985
3996
|
};
|
|
3986
3997
|
return board;
|
|
@@ -4390,9 +4401,6 @@ class MindImageBaseComponent {
|
|
|
4390
4401
|
getRectangle: (element) => {
|
|
4391
4402
|
return getImageForeignRectangle(this.board, this.element);
|
|
4392
4403
|
},
|
|
4393
|
-
getStrokeWidthByElement: () => {
|
|
4394
|
-
return 0;
|
|
4395
|
-
},
|
|
4396
4404
|
hasResizeHandle: () => true
|
|
4397
4405
|
});
|
|
4398
4406
|
this.initialized = true;
|