@plait/mind 0.22.0 → 0.23.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/esm2020/plugins/with-abstract-resize.mjs +3 -1
- package/esm2020/plugins/with-node-resize.mjs +10 -7
- package/esm2020/transforms/abstract-node.mjs +4 -2
- package/fesm2015/plait-mind.mjs +13 -6
- package/fesm2015/plait-mind.mjs.map +1 -1
- package/fesm2020/plait-mind.mjs +13 -6
- package/fesm2020/plait-mind.mjs.map +1 -1
- package/package.json +1 -1
- package/styles/styles.scss +5 -2
package/fesm2020/plait-mind.mjs
CHANGED
|
@@ -2298,6 +2298,8 @@ const insertAbstractNode = (board, path, start, end) => {
|
|
|
2298
2298
|
mindElement.start = start;
|
|
2299
2299
|
mindElement.end = end;
|
|
2300
2300
|
Transforms.insertNode(board, mindElement, path);
|
|
2301
|
+
clearSelectedElement(board);
|
|
2302
|
+
addSelectedElement(board, mindElement);
|
|
2301
2303
|
};
|
|
2302
2304
|
|
|
2303
2305
|
const setLayout = (board, layout, path) => {
|
|
@@ -3531,6 +3533,8 @@ const withAbstract = (board) => {
|
|
|
3531
3533
|
return abstractHandlePosition;
|
|
3532
3534
|
});
|
|
3533
3535
|
if (activeAbstractElement) {
|
|
3536
|
+
// prevent text from being selected
|
|
3537
|
+
event.preventDefault();
|
|
3534
3538
|
if (newBoard?.onAbstractResize) {
|
|
3535
3539
|
newBoard.onAbstractResize(AbstractResizeState.start);
|
|
3536
3540
|
}
|
|
@@ -3963,7 +3967,7 @@ const withNodeResize = (board) => {
|
|
|
3963
3967
|
let startPoint = null;
|
|
3964
3968
|
board.mousedown = (event) => {
|
|
3965
3969
|
if (targetElement) {
|
|
3966
|
-
startPoint =
|
|
3970
|
+
startPoint = [event.x, event.y];
|
|
3967
3971
|
// prevent text from being selected
|
|
3968
3972
|
event.preventDefault();
|
|
3969
3973
|
return;
|
|
@@ -3979,7 +3983,6 @@ const withNodeResize = (board) => {
|
|
|
3979
3983
|
const endPoint = transformPoint(board, toPoint(event.x, event.y, PlaitBoard.getHost(board)));
|
|
3980
3984
|
const distance = distanceBetweenPointAndPoint(startPoint[0], startPoint[1], endPoint[0], endPoint[1]);
|
|
3981
3985
|
if (distance > PRESS_AND_MOVE_BUFFER) {
|
|
3982
|
-
startPoint = endPoint;
|
|
3983
3986
|
addResizing(board, targetElement);
|
|
3984
3987
|
targetElementRef = {
|
|
3985
3988
|
minWidth: NodeSpace.getNodeResizableMinWidth(board, targetElement),
|
|
@@ -3992,17 +3995,21 @@ const withNodeResize = (board) => {
|
|
|
3992
3995
|
}
|
|
3993
3996
|
if (isMindNodeResizing(board) && startPoint && targetElementRef) {
|
|
3994
3997
|
throttleRAF(() => {
|
|
3995
|
-
|
|
3998
|
+
if (!startPoint) {
|
|
3999
|
+
return;
|
|
4000
|
+
}
|
|
4001
|
+
const endPoint = [event.x, event.y];
|
|
3996
4002
|
const offsetX = endPoint[0] - startPoint[0];
|
|
3997
|
-
|
|
4003
|
+
const zoom = board.viewport.zoom;
|
|
4004
|
+
let resizedWidth = targetElementRef.currentWidth + offsetX / zoom;
|
|
3998
4005
|
if (resizedWidth < targetElementRef.minWidth) {
|
|
3999
4006
|
resizedWidth = targetElementRef.minWidth;
|
|
4000
4007
|
}
|
|
4001
4008
|
const newTarget = PlaitNode.get(board, targetElementRef.path);
|
|
4002
4009
|
if (newTarget && NodeSpace.getNodeTopicMinWidth(board, newTarget) !== resizedWidth) {
|
|
4003
4010
|
targetElementRef.textManage.updateWidth(resizedWidth);
|
|
4004
|
-
const {
|
|
4005
|
-
MindTransforms.setNodeManualWidth(board, newTarget, resizedWidth, height);
|
|
4011
|
+
const { height } = targetElementRef.textManage.getSize();
|
|
4012
|
+
MindTransforms.setNodeManualWidth(board, newTarget, resizedWidth * zoom, height);
|
|
4006
4013
|
}
|
|
4007
4014
|
});
|
|
4008
4015
|
return;
|