@plait/draw 0.81.3 → 0.82.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-draw.mjs +13 -13
- package/fesm2022/plait-draw.mjs.map +1 -1
- package/package.json +1 -1
- package/plugins/{with-arrow-line-auto-complete.d.ts → arrow-line/with-arrow-line-auto-complete.d.ts} +1 -1
- package/public-api.d.ts +1 -1
- /package/plugins/{with-arrow-line-auto-complete-reaction.d.ts → arrow-line/with-arrow-line-auto-complete-reaction.d.ts} +0 -0
- /package/plugins/{with-arrow-line-bound-reaction.d.ts → arrow-line/with-arrow-line-bound-reaction.d.ts} +0 -0
- /package/plugins/{with-arrow-line-create.d.ts → arrow-line/with-arrow-line-create.d.ts} +0 -0
- /package/plugins/{with-arrow-line-resize.d.ts → arrow-line/with-arrow-line-resize.d.ts} +0 -0
- /package/plugins/{with-arrow-line-text-move.d.ts → arrow-line/with-arrow-line-text-move.d.ts} +0 -0
- /package/plugins/{with-arrow-line-text.d.ts → arrow-line/with-arrow-line-text.d.ts} +0 -0
package/fesm2022/plait-draw.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ACTIVE_STROKE_WIDTH, DEFAULT_COLOR, ThemeColorMode, PlaitElement, RectangleClient, getSelectedElements, idCreator, createDebugGenerator, Point, createG, arrowPoints, createPath, distanceBetweenPointAndPoint, drawLinearPath, rotate, catmullRomFitting, PlaitBoard, setStrokeLinecap, findElements, createMask, createRect, getNearestPointBetweenPointAndArc, setPathStrokeLinecap, distanceBetweenPointAndSegments, HIT_DISTANCE_BUFFER, isPointInPolygon, isLineHitRectangle, rotatePointsByAngle, rotateAntiPointsByElement, getEllipseArcCenter, Transforms, clearSelectedElement, addSelectedElement, BoardTransforms, PlaitPointerType, depthFirstRecursion, getIsRecursionFunc, SNAPPING_STROKE_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, getI18nValue, toActiveRectangleFromViewBoxRectangle, getElementById, rotatePointsByElement, PlaitNode, hasValidAngle, toViewBoxPoint, toHostPoint, Direction, rotatePoints, getSelectionAngle, rotatedDataPoints, isAxisChangedByAngle, getRectangleByElements, isSelectionMoving, drawRectangle, getRectangleByAngle, getSnapRectangles, getTripleAxis, getMinPointDelta, SNAP_TOLERANCE, drawPointSnapLines, drawSolidLines, getNearestPointBetweenPointAndSegments, getEllipseTangentSlope, getVectorFromPointAndSlope, getNearestPointBetweenPointAndEllipse, isPointInEllipse, isPointInRoundRectangle, drawRoundRectangle, getCrossingPointsBetweenEllipseAndSegment, drawLine, getNearestPointBetweenPointAndDiscreteSegments, getNearestPointBetweenPointAndSegment, Path,
|
|
1
|
+
import { ACTIVE_STROKE_WIDTH, DEFAULT_COLOR, ThemeColorMode, PlaitElement, RectangleClient, getSelectedElements, idCreator, createDebugGenerator, Point, createG, arrowPoints, createPath, distanceBetweenPointAndPoint, drawLinearPath, rotate, catmullRomFitting, PlaitBoard, setStrokeLinecap, findElements, createMask, createRect, getNearestPointBetweenPointAndArc, setPathStrokeLinecap, distanceBetweenPointAndSegments, HIT_DISTANCE_BUFFER, isPointInPolygon, isLineHitRectangle, rotatePointsByAngle, rotateAntiPointsByElement, getEllipseArcCenter, Transforms, clearSelectedElement, addSelectedElement, BoardTransforms, PlaitPointerType, depthFirstRecursion, getIsRecursionFunc, SNAPPING_STROKE_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, drawCircle, getI18nValue, toActiveRectangleFromViewBoxRectangle, getElementById, rotatePointsByElement, PlaitNode, hasValidAngle, toViewBoxPoint, toHostPoint, Direction, rotatePoints, getSelectionAngle, rotatedDataPoints, isAxisChangedByAngle, getRectangleByElements, isSelectionMoving, drawRectangle, getRectangleByAngle, getSnapRectangles, getTripleAxis, getMinPointDelta, SNAP_TOLERANCE, drawPointSnapLines, drawSolidLines, getNearestPointBetweenPointAndSegments, getEllipseTangentSlope, getVectorFromPointAndSlope, getNearestPointBetweenPointAndEllipse, isPointInEllipse, isPointInRoundRectangle, drawRoundRectangle, getCrossingPointsBetweenEllipseAndSegment, drawLine, getNearestPointBetweenPointAndDiscreteSegments, getNearestPointBetweenPointAndSegment, Path, rgbaToHEX, SELECTION_RECTANGLE_CLASS_NAME, toActivePointFromViewBoxPoint, getHitElementByPoint, WritableClipboardOperationType, WritableClipboardType, addOrCreateClipboardContext, setAngleForG, CursorClass, toActivePoint, temporaryDisableSelection, toScreenPointFromActivePoint, PRESS_AND_MOVE_BUFFER, isMainPointer, throttleRAF, getAngleBetweenPoints, normalizeAngle, degreesToRadians, rotateElements, MERGING, ROTATE_HANDLE_CLASS_NAME, isSelectedElement, isDragging } from '@plait/core';
|
|
2
2
|
import { DEFAULT_FILL, Alignment, getMemorizedLatest, memorizeLatest, WithTextPluginKey, TextManage, StrokeStyle, removeDuplicatePoints, generateElbowLineRoute, simplifyOrthogonalPoints, getExtendPoint, getUnitVectorByPointAndPoint, Generator, getPointByVectorComponent, getStrokeLineDash, getPointOnPolyline, buildText, getCrossingPointsBetweenPointAndSegment, isPointOnSegment, getFirstTextEditor, sortElementsByArea, isFilled, getTextEditorsByElement, RESIZE_HANDLE_DIAMETER, measureElement, DEFAULT_FONT_FAMILY, getFirstTextManage, isSourceAndTargetIntersect, getPoints, DEFAULT_ROUTE_MARGIN, normalizeShapePoints, resetPointsAfterResize, getDirectionByVector, getRectangleResizeHandleRefs, getRotatedResizeCursorClassByAngle, ROTATE_HANDLE_SIZE, ROTATE_HANDLE_DISTANCE_TO_ELEMENT, isCornerHandle, getIndexByResizeHandle, withResize, getSymmetricHandleIndex, getResizeHandlePointByIndex, drawHandle, getDirectionFactorByDirectionComponent, buildClipboardData as buildClipboardData$1, insertClipboardData as insertClipboardData$1, getDirectionByPointOfRectangle, getDirectionFactor, rotateVector, getOppositeDirection, rotateVectorAnti90, getSourceAndTargetOuterRectangle, getNextPoint, PRIMARY_COLOR, CommonElementFlavour, createActiveGenerator, hasResizeHandle, ActiveGenerator, drawPrimaryHandle, drawFillPrimaryHandle, isVirtualKey, isDelete, isSpaceHotkey, isDndMode, isDrawingMode, getElementsText, acceptImageTypes, getElementOfFocusedImage, buildImage, isResizingByCondition, getRatioByPoint, getTextManages, ImageGenerator, ResizeHandle, addRotating, removeRotating, drawRotateHandle } from '@plait/common';
|
|
3
3
|
import { TEXT_DEFAULT_HEIGHT, DEFAULT_FONT_SIZE, AlignEditor } from '@plait/text-plugins';
|
|
4
4
|
import { pointsOnBezierCurves } from 'points-on-curve';
|
|
@@ -2421,7 +2421,7 @@ const getFlowchartDefaultFill = (theme) => {
|
|
|
2421
2421
|
};
|
|
2422
2422
|
const getTextShapeProperty = (board, text, fontSize) => {
|
|
2423
2423
|
fontSize = fontSize ? Number(fontSize) : DEFAULT_FONT_SIZE;
|
|
2424
|
-
const textSize = measureElement(buildText(text), { fontSize, fontFamily: DEFAULT_FONT_FAMILY });
|
|
2424
|
+
const textSize = measureElement(board, buildText(text), { fontSize, fontFamily: DEFAULT_FONT_FAMILY });
|
|
2425
2425
|
return {
|
|
2426
2426
|
width: textSize.width + ShapeDefaultSpace.rectangleAndText * 2,
|
|
2427
2427
|
height: textSize.height
|
|
@@ -7075,7 +7075,7 @@ class ArrowLineAutoCompleteGenerator extends Generator {
|
|
|
7075
7075
|
middlePoints.forEach((point, index) => {
|
|
7076
7076
|
const circle = drawCircle(PlaitBoard.getRoughSVG(this.board), point, LINE_AUTO_COMPLETE_DIAMETER, {
|
|
7077
7077
|
stroke: 'none',
|
|
7078
|
-
fill:
|
|
7078
|
+
fill: rgbaToHEX(PRIMARY_COLOR, LINE_AUTO_COMPLETE_OPACITY),
|
|
7079
7079
|
fillStyle: 'solid'
|
|
7080
7080
|
});
|
|
7081
7081
|
circle.classList.add(`line-auto-complete-${index}`);
|
|
@@ -7957,7 +7957,7 @@ const withArrowLineResize = (board) => {
|
|
|
7957
7957
|
const selectedLineElements = getSelectedArrowLineElements(board);
|
|
7958
7958
|
if (selectedLineElements.length > 0) {
|
|
7959
7959
|
let result = null;
|
|
7960
|
-
selectedLineElements.forEach(value => {
|
|
7960
|
+
selectedLineElements.forEach((value) => {
|
|
7961
7961
|
const handleRef = getHitLineResizeHandleRef(board, value, point);
|
|
7962
7962
|
if (handleRef) {
|
|
7963
7963
|
result = {
|
|
@@ -8160,7 +8160,7 @@ const withArrowLineText = (board) => {
|
|
|
8160
8160
|
const defaultLineText = getDefaultLineText(board);
|
|
8161
8161
|
const textMemory = getMemorizedLatest('arrow-line')?.text || {};
|
|
8162
8162
|
const textElement = buildText(defaultLineText, undefined, textMemory);
|
|
8163
|
-
const { width, height } = measureElement(textElement, {
|
|
8163
|
+
const { width, height } = measureElement(board, textElement, {
|
|
8164
8164
|
fontSize: DEFAULT_FONT_SIZE,
|
|
8165
8165
|
fontFamily: DEFAULT_FONT_FAMILY
|
|
8166
8166
|
});
|
|
@@ -8283,7 +8283,7 @@ const withArrowLineAutoCompleteReaction = (board) => {
|
|
|
8283
8283
|
lineAutoCompleteGenerator?.removeAutoCompleteG(hitIndex);
|
|
8284
8284
|
reactionG = drawCircle(PlaitBoard.getRoughSVG(board), hitPoint, LINE_AUTO_COMPLETE_HOVERED_DIAMETER, {
|
|
8285
8285
|
stroke: 'none',
|
|
8286
|
-
fill:
|
|
8286
|
+
fill: rgbaToHEX(PRIMARY_COLOR, LINE_AUTO_COMPLETE_HOVERED_OPACITY),
|
|
8287
8287
|
fillStyle: 'solid'
|
|
8288
8288
|
});
|
|
8289
8289
|
PlaitBoard.getActiveHost(board).append(reactionG);
|
|
@@ -9250,8 +9250,8 @@ const withDraw = (board) => {
|
|
|
9250
9250
|
}
|
|
9251
9251
|
return isHit(element, point, isStrict);
|
|
9252
9252
|
};
|
|
9253
|
-
board.getOneHitElement = elements => {
|
|
9254
|
-
const isAllDrawElements = elements.every(item => PlaitDrawElement.isDrawElement(item));
|
|
9253
|
+
board.getOneHitElement = (elements) => {
|
|
9254
|
+
const isAllDrawElements = elements.every((item) => PlaitDrawElement.isDrawElement(item));
|
|
9255
9255
|
if (isAllDrawElements) {
|
|
9256
9256
|
return getHitDrawElement(board, elements);
|
|
9257
9257
|
}
|
|
@@ -9277,7 +9277,7 @@ const withDraw = (board) => {
|
|
|
9277
9277
|
if (PlaitDrawElement.isArrowLine(element)) {
|
|
9278
9278
|
const selectedElements = getSelectedElements(board);
|
|
9279
9279
|
const isSelected = (boundId) => {
|
|
9280
|
-
return !!selectedElements.find(value => value.id === boundId);
|
|
9280
|
+
return !!selectedElements.find((value) => value.id === boundId);
|
|
9281
9281
|
};
|
|
9282
9282
|
if (!element.source.boundId && !element.target.boundId) {
|
|
9283
9283
|
return true;
|
|
@@ -9300,10 +9300,10 @@ const withDraw = (board) => {
|
|
|
9300
9300
|
};
|
|
9301
9301
|
board.getRelatedFragment = (elements, originData) => {
|
|
9302
9302
|
const selectedElements = originData?.length ? originData : getSelectedElements(board);
|
|
9303
|
-
const lineElements = board.children.filter(element => PlaitDrawElement.isArrowLine(element));
|
|
9304
|
-
const activeLines = lineElements.filter(line => {
|
|
9305
|
-
const source = selectedElements.find(element => element.id === line.source.boundId);
|
|
9306
|
-
const target = selectedElements.find(element => element.id === line.target.boundId);
|
|
9303
|
+
const lineElements = board.children.filter((element) => PlaitDrawElement.isArrowLine(element));
|
|
9304
|
+
const activeLines = lineElements.filter((line) => {
|
|
9305
|
+
const source = selectedElements.find((element) => element.id === line.source.boundId);
|
|
9306
|
+
const target = selectedElements.find((element) => element.id === line.target.boundId);
|
|
9307
9307
|
const isSelected = selectedElements.includes(line);
|
|
9308
9308
|
return source && target && !isSelected;
|
|
9309
9309
|
});
|