@plait/mind 0.22.0 → 0.23.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/esm2020/node.component.mjs +20 -17
- package/esm2020/plugins/with-abstract-resize.mjs +3 -1
- package/esm2020/plugins/with-node-image.mjs +1 -2
- package/esm2020/plugins/with-node-resize.mjs +10 -7
- package/esm2020/transforms/abstract-node.mjs +4 -2
- package/esm2020/transforms/emoji.mjs +3 -3
- package/esm2020/transforms/image.mjs +3 -1
- package/esm2020/utils/clipboard.mjs +5 -2
- package/esm2020/utils/node/adjust-node.mjs +3 -2
- package/fesm2015/plait-mind.mjs +38 -27
- package/fesm2015/plait-mind.mjs.map +1 -1
- package/fesm2020/plait-mind.mjs +41 -27
- package/fesm2020/plait-mind.mjs.map +1 -1
- package/node.component.d.ts +3 -2
- package/package.json +1 -1
- package/styles/styles.scss +5 -2
package/fesm2020/plait-mind.mjs
CHANGED
|
@@ -691,7 +691,8 @@ const adjustNodeToRoot = (board, node) => {
|
|
|
691
691
|
delete newElement?.isCollapsed;
|
|
692
692
|
const { width, height } = getTextSize(board, newElement.data.topic, TOPIC_DEFAULT_MAX_WORD_COUNT, {
|
|
693
693
|
fontSize: ROOT_TOPIC_FONT_SIZE,
|
|
694
|
-
fontFamily: BRANCH_FONT_FAMILY
|
|
694
|
+
fontFamily: BRANCH_FONT_FAMILY,
|
|
695
|
+
width: node.manualWidth ? node.manualWidth : undefined
|
|
695
696
|
});
|
|
696
697
|
newElement.width = Math.max(width, getNodeDefaultFontSize(true));
|
|
697
698
|
newElement.height = height;
|
|
@@ -2298,6 +2299,8 @@ const insertAbstractNode = (board, path, start, end) => {
|
|
|
2298
2299
|
mindElement.start = start;
|
|
2299
2300
|
mindElement.end = end;
|
|
2300
2301
|
Transforms.insertNode(board, mindElement, path);
|
|
2302
|
+
clearSelectedElement(board);
|
|
2303
|
+
addSelectedElement(board, mindElement);
|
|
2301
2304
|
};
|
|
2302
2305
|
|
|
2303
2306
|
const setLayout = (board, layout, path) => {
|
|
@@ -2407,7 +2410,7 @@ const addEmoji = (board, element, emojiItem) => {
|
|
|
2407
2410
|
const newEmojis = [...emojis];
|
|
2408
2411
|
newEmojis.push(emojiItem);
|
|
2409
2412
|
const newElement = {
|
|
2410
|
-
data: {
|
|
2413
|
+
data: { ...element.data, emojis: newEmojis }
|
|
2411
2414
|
};
|
|
2412
2415
|
const path = PlaitBoard.findPath(board, element);
|
|
2413
2416
|
Transforms.setNode(board, newElement, path);
|
|
@@ -2415,7 +2418,7 @@ const addEmoji = (board, element, emojiItem) => {
|
|
|
2415
2418
|
const removeEmoji = (board, element, emojiItem) => {
|
|
2416
2419
|
const emojis = element.data.emojis.filter(value => value !== emojiItem);
|
|
2417
2420
|
const newElement = {
|
|
2418
|
-
data: {
|
|
2421
|
+
data: { ...element.data }
|
|
2419
2422
|
};
|
|
2420
2423
|
if (emojis.length > 0) {
|
|
2421
2424
|
newElement.data.emojis = emojis;
|
|
@@ -2439,6 +2442,7 @@ const replaceEmoji = (board, element, oldEmoji, newEmoji) => {
|
|
|
2439
2442
|
};
|
|
2440
2443
|
|
|
2441
2444
|
const removeImage = (board, element) => {
|
|
2445
|
+
setImageFocus(board, element, false);
|
|
2442
2446
|
const newElement = {
|
|
2443
2447
|
data: { ...element.data }
|
|
2444
2448
|
};
|
|
@@ -2949,7 +2953,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2949
2953
|
this.parentG = PlaitElement.getComponent(MindElement.getRoot(this.board, this.element)).rootG;
|
|
2950
2954
|
this.drawShape();
|
|
2951
2955
|
this.drawLink();
|
|
2952
|
-
this.
|
|
2956
|
+
this.drawTopic();
|
|
2953
2957
|
this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: this.textManage.isEditing });
|
|
2954
2958
|
this.drawEmojis();
|
|
2955
2959
|
this.drawExtend();
|
|
@@ -2958,18 +2962,6 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2958
2962
|
this.g.classList.add('branch');
|
|
2959
2963
|
}
|
|
2960
2964
|
}
|
|
2961
|
-
editTopic() {
|
|
2962
|
-
this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: true });
|
|
2963
|
-
if (this.element.manualWidth) {
|
|
2964
|
-
const width = NodeSpace.getNodeResizableWidth(this.board, this.element);
|
|
2965
|
-
this.textManage.updateWidth(width);
|
|
2966
|
-
}
|
|
2967
|
-
this.textManage.edit((origin) => {
|
|
2968
|
-
if (origin === ExitOrigin.default) {
|
|
2969
|
-
this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: false });
|
|
2970
|
-
}
|
|
2971
|
-
});
|
|
2972
|
-
}
|
|
2973
2965
|
onContextChanged(value, previous) {
|
|
2974
2966
|
const newNode = MindElement.getNode(value.element);
|
|
2975
2967
|
const isEqualNode = RectangleClient.isEqual(this.node, newNode);
|
|
@@ -2982,8 +2974,7 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
2982
2974
|
this.drawEmojis();
|
|
2983
2975
|
this.drawExtend();
|
|
2984
2976
|
this.imageDrawer.updateImage(this.g, previous.element, value.element);
|
|
2985
|
-
this.
|
|
2986
|
-
this.textManage.updateRectangle();
|
|
2977
|
+
this.updateTopic();
|
|
2987
2978
|
}
|
|
2988
2979
|
else {
|
|
2989
2980
|
const hasSameSelected = value.selected === previous.selected;
|
|
@@ -3062,9 +3053,25 @@ class MindNodeComponent extends PlaitPluginElementComponent {
|
|
|
3062
3053
|
this.extendG.remove();
|
|
3063
3054
|
}
|
|
3064
3055
|
}
|
|
3065
|
-
|
|
3056
|
+
drawTopic() {
|
|
3066
3057
|
this.textManage.draw(this.element.data.topic);
|
|
3067
3058
|
this.g.append(this.textManage.g);
|
|
3059
|
+
if (this.element.manualWidth) {
|
|
3060
|
+
const width = NodeSpace.getNodeResizableWidth(this.board, this.element);
|
|
3061
|
+
this.textManage.updateWidth(width);
|
|
3062
|
+
}
|
|
3063
|
+
}
|
|
3064
|
+
updateTopic() {
|
|
3065
|
+
this.textManage.updateText(this.element.data.topic);
|
|
3066
|
+
this.textManage.updateRectangle();
|
|
3067
|
+
}
|
|
3068
|
+
editTopic() {
|
|
3069
|
+
this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: true });
|
|
3070
|
+
this.textManage.edit((origin) => {
|
|
3071
|
+
if (origin === ExitOrigin.default) {
|
|
3072
|
+
this.activeDrawer.draw(this.element, this.g, { selected: this.selected, isEditing: false });
|
|
3073
|
+
}
|
|
3074
|
+
});
|
|
3068
3075
|
}
|
|
3069
3076
|
ngOnDestroy() {
|
|
3070
3077
|
super.ngOnDestroy();
|
|
@@ -3474,7 +3481,10 @@ const insertClipboardData = (board, elements, targetPoint) => {
|
|
|
3474
3481
|
if (item.isRoot) {
|
|
3475
3482
|
newElement = adjustRootToNode(board, newElement);
|
|
3476
3483
|
const styles = PlaitMind.isMind(targetParent) ? { fontFamily: BRANCH_FONT_FAMILY } : { fontFamily: DEFAULT_FONT_FAMILY };
|
|
3477
|
-
const { width, height } = getTextSize(board, newElement.data.topic, TOPIC_DEFAULT_MAX_WORD_COUNT,
|
|
3484
|
+
const { width, height } = getTextSize(board, newElement.data.topic, TOPIC_DEFAULT_MAX_WORD_COUNT, {
|
|
3485
|
+
...styles,
|
|
3486
|
+
width: newElement.manualWidth ? newElement.manualWidth : undefined
|
|
3487
|
+
});
|
|
3478
3488
|
newElement.width = Math.max(width, getNodeDefaultFontSize());
|
|
3479
3489
|
newElement.height = height;
|
|
3480
3490
|
}
|
|
@@ -3531,6 +3541,8 @@ const withAbstract = (board) => {
|
|
|
3531
3541
|
return abstractHandlePosition;
|
|
3532
3542
|
});
|
|
3533
3543
|
if (activeAbstractElement) {
|
|
3544
|
+
// prevent text from being selected
|
|
3545
|
+
event.preventDefault();
|
|
3534
3546
|
if (newBoard?.onAbstractResize) {
|
|
3535
3547
|
newBoard.onAbstractResize(AbstractResizeState.start);
|
|
3536
3548
|
}
|
|
@@ -3936,7 +3948,6 @@ const withNodeImage = (board) => {
|
|
|
3936
3948
|
const selectedImageElement = getSelectedImageElement(board);
|
|
3937
3949
|
if (!PlaitBoard.isReadonly(board) && selectedImageElement && (hotkeys.isDeleteBackward(event) || hotkeys.isDeleteForward(event))) {
|
|
3938
3950
|
addSelectedElement(board, selectedImageElement);
|
|
3939
|
-
setImageFocus(board, selectedImageElement, false);
|
|
3940
3951
|
MindTransforms.removeImage(board, selectedImageElement);
|
|
3941
3952
|
return;
|
|
3942
3953
|
}
|
|
@@ -3963,7 +3974,7 @@ const withNodeResize = (board) => {
|
|
|
3963
3974
|
let startPoint = null;
|
|
3964
3975
|
board.mousedown = (event) => {
|
|
3965
3976
|
if (targetElement) {
|
|
3966
|
-
startPoint =
|
|
3977
|
+
startPoint = [event.x, event.y];
|
|
3967
3978
|
// prevent text from being selected
|
|
3968
3979
|
event.preventDefault();
|
|
3969
3980
|
return;
|
|
@@ -3979,7 +3990,6 @@ const withNodeResize = (board) => {
|
|
|
3979
3990
|
const endPoint = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3980
3991
|
const distance = distanceBetweenPointAndPoint(startPoint[0], startPoint[1], endPoint[0], endPoint[1]);
|
|
3981
3992
|
if (distance > PRESS_AND_MOVE_BUFFER) {
|
|
3982
|
-
startPoint = endPoint;
|
|
3983
3993
|
addResizing(board, targetElement);
|
|
3984
3994
|
targetElementRef = {
|
|
3985
3995
|
minWidth: NodeSpace.getNodeResizableMinWidth(board, targetElement),
|
|
@@ -3992,17 +4002,21 @@ const withNodeResize = (board) => {
|
|
|
3992
4002
|
}
|
|
3993
4003
|
if (isMindNodeResizing(board) && startPoint && targetElementRef) {
|
|
3994
4004
|
throttleRAF(() => {
|
|
3995
|
-
|
|
4005
|
+
if (!startPoint) {
|
|
4006
|
+
return;
|
|
4007
|
+
}
|
|
4008
|
+
const endPoint = [event.x, event.y];
|
|
3996
4009
|
const offsetX = endPoint[0] - startPoint[0];
|
|
3997
|
-
|
|
4010
|
+
const zoom = board.viewport.zoom;
|
|
4011
|
+
let resizedWidth = targetElementRef.currentWidth + offsetX / zoom;
|
|
3998
4012
|
if (resizedWidth < targetElementRef.minWidth) {
|
|
3999
4013
|
resizedWidth = targetElementRef.minWidth;
|
|
4000
4014
|
}
|
|
4001
4015
|
const newTarget = PlaitNode.get(board, targetElementRef.path);
|
|
4002
4016
|
if (newTarget && NodeSpace.getNodeTopicMinWidth(board, newTarget) !== resizedWidth) {
|
|
4003
4017
|
targetElementRef.textManage.updateWidth(resizedWidth);
|
|
4004
|
-
const {
|
|
4005
|
-
MindTransforms.setNodeManualWidth(board, newTarget, resizedWidth, height);
|
|
4018
|
+
const { height } = targetElementRef.textManage.getSize();
|
|
4019
|
+
MindTransforms.setNodeManualWidth(board, newTarget, resizedWidth * zoom, height);
|
|
4006
4020
|
}
|
|
4007
4021
|
});
|
|
4008
4022
|
return;
|