@plait/mind 0.82.0 → 0.83.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,6 +1,6 @@
|
|
|
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, getFirstTextEditor, RESIZE_HANDLE_DIAMETER, getRectangleResizeHandleRefs, addElementOfFocusedImage, ImageGenerator, removeElementOfFocusedImage, getStrokeLineDash, 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';
|
|
3
|
+
import { StrokeStyle, getFirstTextManage, DEFAULT_FONT_FAMILY, measureElement, buildText, getFirstTextEditor, 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
4
|
import { TEXT_DEFAULT_HEIGHT, PlaitMarkEditor, MarkTypes, DEFAULT_FONT_SIZE, 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';
|
|
@@ -1395,14 +1395,6 @@ const getPointByPlacement = (client, placement) => {
|
|
|
1395
1395
|
}
|
|
1396
1396
|
return [x, y];
|
|
1397
1397
|
};
|
|
1398
|
-
const getXDistanceBetweenPoint = (point1, point2, isHorizontalLayout) => {
|
|
1399
|
-
if (isHorizontalLayout) {
|
|
1400
|
-
return Math.abs(point1[0] - point2[0]);
|
|
1401
|
-
}
|
|
1402
|
-
else {
|
|
1403
|
-
return Math.abs(point1[1] - point2[1]);
|
|
1404
|
-
}
|
|
1405
|
-
};
|
|
1406
1398
|
const getYDistanceBetweenPoint = (point1, point2, isHorizontalLayout) => {
|
|
1407
1399
|
getXDistanceBetweenPoint(point1, point2, !isHorizontalLayout);
|
|
1408
1400
|
};
|
|
@@ -1424,37 +1416,6 @@ const getLayoutDirection = (node, isHorizontal) => {
|
|
|
1424
1416
|
}
|
|
1425
1417
|
}
|
|
1426
1418
|
};
|
|
1427
|
-
// Based on right
|
|
1428
|
-
// Right -> Left:
|
|
1429
|
-
// 1. End point -> starting point/start point -> end point
|
|
1430
|
-
// 2. Add -> Subtract
|
|
1431
|
-
// Horizontal -> Vertical:
|
|
1432
|
-
// 1. Starting point/end point -> vertical axis
|
|
1433
|
-
// 2. Addition and subtraction -> vertical axis
|
|
1434
|
-
// Bottom -> Top:
|
|
1435
|
-
// 1. End point -> starting point/end point -> starting point
|
|
1436
|
-
// 2. Add -> Subtract
|
|
1437
|
-
const moveXOfPoint = (point, distance, direction = LayoutDirection.right) => {
|
|
1438
|
-
if (direction === LayoutDirection.left) {
|
|
1439
|
-
return [point[0] - distance, point[1]];
|
|
1440
|
-
}
|
|
1441
|
-
if (direction === LayoutDirection.bottom) {
|
|
1442
|
-
return [point[0], point[1] + distance];
|
|
1443
|
-
}
|
|
1444
|
-
if (direction === LayoutDirection.top) {
|
|
1445
|
-
return [point[0], point[1] - distance];
|
|
1446
|
-
}
|
|
1447
|
-
return [point[0] + distance, point[1]];
|
|
1448
|
-
};
|
|
1449
|
-
const moveYOfPoint = (point, distance, direction = LayoutDirection.right) => {
|
|
1450
|
-
if (direction === LayoutDirection.bottom) {
|
|
1451
|
-
return [point[0] + distance, point[1]];
|
|
1452
|
-
}
|
|
1453
|
-
if (direction === LayoutDirection.top) {
|
|
1454
|
-
return [point[0] + distance, point[1]];
|
|
1455
|
-
}
|
|
1456
|
-
return [point[0], point[1] + distance];
|
|
1457
|
-
};
|
|
1458
1419
|
const transformPlacement = (placement, direction) => {
|
|
1459
1420
|
// to left
|
|
1460
1421
|
if (direction === LayoutDirection.left) {
|
|
@@ -1565,7 +1526,9 @@ function drawLogicLink(board, parent, node, isHorizontal, defaultStrokeColor = n
|
|
|
1565
1526
|
let endPoint = getPointByPlacement(nodeClient, endPlacement);
|
|
1566
1527
|
// ② Determine the convex straight line
|
|
1567
1528
|
const straightLineDistance = 8;
|
|
1568
|
-
const beginPoint2 = hasStraightLine
|
|
1529
|
+
const beginPoint2 = hasStraightLine
|
|
1530
|
+
? moveXOfPoint(beginPoint, straightLineDistance, linkDirection)
|
|
1531
|
+
: beginPoint;
|
|
1569
1532
|
let straightLine = hasStraightLine ? [beginPoint, beginPoint2, beginPoint2] : [];
|
|
1570
1533
|
// ③ Determine the curve
|
|
1571
1534
|
const beginBufferDistance = (parent.hGap + node.hGap) / 3;
|