@plait/draw 0.42.0 → 0.43.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/esm2022/geometry.component.mjs +1 -1
- package/esm2022/plugins/with-draw-fragment.mjs +3 -4
- package/esm2022/plugins/with-geometry-create.mjs +7 -7
- package/esm2022/transforms/geometry.mjs +8 -5
- package/esm2022/utils/geometry.mjs +12 -10
- package/fesm2022/plait-draw.mjs +22 -18
- package/fesm2022/plait-draw.mjs.map +1 -1
- package/package.json +1 -1
- package/transforms/geometry.d.ts +1 -1
- package/transforms/index.d.ts +1 -1
- package/utils/clipboard.d.ts +1 -1
- package/utils/geometry.d.ts +3 -4
package/fesm2022/plait-draw.mjs
CHANGED
|
@@ -1456,13 +1456,12 @@ const getDrawDefaultStrokeColor = (theme) => {
|
|
|
1456
1456
|
const getFlowchartDefaultFill = (theme) => {
|
|
1457
1457
|
return DrawThemeColors[theme].fill;
|
|
1458
1458
|
};
|
|
1459
|
-
const
|
|
1459
|
+
const getTextShapeProperty = (board, text = DefaultTextProperty.text, fontSize) => {
|
|
1460
1460
|
fontSize = fontSize ? Number(fontSize) : DEFAULT_FONT_SIZE;
|
|
1461
|
-
const textSize = getTextSize(board,
|
|
1461
|
+
const textSize = getTextSize(board, text, Infinity, { fontSize });
|
|
1462
1462
|
return {
|
|
1463
1463
|
width: textSize.width + ShapeDefaultSpace.rectangleAndText * 2,
|
|
1464
|
-
height: textSize.height
|
|
1465
|
-
text: '文本'
|
|
1464
|
+
height: textSize.height
|
|
1466
1465
|
};
|
|
1467
1466
|
};
|
|
1468
1467
|
const getDefaultGeometryPoints = (pointer, centerPoint) => {
|
|
@@ -1479,7 +1478,7 @@ const getDefaultGeometryProperty = (pointer) => {
|
|
|
1479
1478
|
}
|
|
1480
1479
|
};
|
|
1481
1480
|
const getDefaultTextPoints = (board, centerPoint, fontSize) => {
|
|
1482
|
-
const property =
|
|
1481
|
+
const property = getTextShapeProperty(board, DefaultTextProperty.text, fontSize);
|
|
1483
1482
|
return getPointsByCenterPoint(centerPoint, property.width, property.height);
|
|
1484
1483
|
};
|
|
1485
1484
|
const insertElement = (board, element) => {
|
|
@@ -1489,14 +1488,17 @@ const insertElement = (board, element) => {
|
|
|
1489
1488
|
addSelectedElement(board, element);
|
|
1490
1489
|
BoardTransforms.updatePointerType(board, PlaitPointerType.selection);
|
|
1491
1490
|
};
|
|
1492
|
-
const
|
|
1491
|
+
const createTextElement = (board, points, text = DefaultTextProperty.text, textHeight) => {
|
|
1493
1492
|
const memorizedLatest = getMemorizedLatestByPointer(BasicShapes.text);
|
|
1494
|
-
|
|
1495
|
-
return createGeometryElement(BasicShapes.text, points,
|
|
1493
|
+
textHeight = textHeight ? textHeight : getRectangleByPoints(points).height;
|
|
1494
|
+
return createGeometryElement(BasicShapes.text, points, text, memorizedLatest.geometryProperties, {
|
|
1495
|
+
...memorizedLatest.textProperties,
|
|
1496
|
+
textHeight
|
|
1497
|
+
});
|
|
1496
1498
|
};
|
|
1497
1499
|
const createDefaultGeometry = (board, points, shape) => {
|
|
1498
1500
|
const memorizedLatest = getMemorizedLatestByPointer(shape);
|
|
1499
|
-
const textHeight =
|
|
1501
|
+
const textHeight = getTextShapeProperty(board, DefaultTextProperty.text, memorizedLatest.textProperties['font-size']).height;
|
|
1500
1502
|
return createGeometryElement(shape, points, '', {
|
|
1501
1503
|
strokeWidth: DefaultBasicShapeProperty.strokeWidth,
|
|
1502
1504
|
...memorizedLatest.geometryProperties
|
|
@@ -2354,8 +2356,11 @@ const insertGeometryByVector = (board, point, shape, vector) => {
|
|
|
2354
2356
|
}
|
|
2355
2357
|
return null;
|
|
2356
2358
|
};
|
|
2357
|
-
const insertText = (board,
|
|
2358
|
-
const
|
|
2359
|
+
const insertText = (board, point, text) => {
|
|
2360
|
+
const memorizedLatest = getMemorizedLatestByPointer(BasicShapes.text);
|
|
2361
|
+
const property = getTextShapeProperty(board, text, memorizedLatest.textProperties['font-size']);
|
|
2362
|
+
const points = [point, [point[0] + property.width, point[1] + property.height]];
|
|
2363
|
+
const newElement = createTextElement(board, points, text);
|
|
2359
2364
|
insertElement(board, newElement);
|
|
2360
2365
|
};
|
|
2361
2366
|
const resizeGeometry = (board, points, textHeight, path) => {
|
|
@@ -2940,9 +2945,9 @@ const withGeometryCreateByDrag = (board) => {
|
|
|
2940
2945
|
if (dragMode) {
|
|
2941
2946
|
const memorizedLatest = getMemorizedLatestByPointer(pointer);
|
|
2942
2947
|
if (pointer === BasicShapes.text) {
|
|
2943
|
-
const property =
|
|
2948
|
+
const property = getTextShapeProperty(board, DefaultTextProperty.text, memorizedLatest.textProperties['font-size']);
|
|
2944
2949
|
const points = getPointsByCenterPoint(movingPoint, property.width, property.height);
|
|
2945
|
-
temporaryElement =
|
|
2950
|
+
temporaryElement = createTextElement(board, points);
|
|
2946
2951
|
if (!fakeCreateTextRef) {
|
|
2947
2952
|
const textManage = new TextManage(board, PlaitBoard.getComponent(board).viewContainerRef, {
|
|
2948
2953
|
getRectangle: () => {
|
|
@@ -3016,9 +3021,9 @@ const withGeometryCreateByDrawing = (board) => {
|
|
|
3016
3021
|
preventTouchMove(board, event, true);
|
|
3017
3022
|
if (pointer === BasicShapes.text) {
|
|
3018
3023
|
const memorizedLatest = getMemorizedLatestByPointer(pointer);
|
|
3019
|
-
const property =
|
|
3024
|
+
const property = getTextShapeProperty(board, DefaultTextProperty.text, memorizedLatest.textProperties['font-size']);
|
|
3020
3025
|
const points = getPointsByCenterPoint(point, property.width, property.height);
|
|
3021
|
-
const textElement =
|
|
3026
|
+
const textElement = createTextElement(board, points);
|
|
3022
3027
|
insertElement(board, textElement);
|
|
3023
3028
|
start = null;
|
|
3024
3029
|
}
|
|
@@ -3167,8 +3172,7 @@ const withDrawFragment = (baseBoard) => {
|
|
|
3167
3172
|
const insertAsChildren = selectedElements.length === 1 && selectedElements[0].children;
|
|
3168
3173
|
const insertAsFreeText = !insertAsChildren;
|
|
3169
3174
|
if (text && insertAsFreeText) {
|
|
3170
|
-
|
|
3171
|
-
DrawTransforms.insertText(board, [targetPoint, [targetPoint[0] + width, targetPoint[1] + height]], text);
|
|
3175
|
+
DrawTransforms.insertText(board, targetPoint, text);
|
|
3172
3176
|
return;
|
|
3173
3177
|
}
|
|
3174
3178
|
}
|
|
@@ -3837,5 +3841,5 @@ const withDraw = (board) => {
|
|
|
3837
3841
|
* Generated bundle index. Do not edit.
|
|
3838
3842
|
*/
|
|
3839
3843
|
|
|
3840
|
-
export { BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultBasicShapeProperty, DefaultConnectorProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultGeometryActiveStyle, DefaultGeometryStyle, DefaultManualInputProperty, DefaultMergeProperty, DefaultTextProperty, DrawThemeColors, DrawTransforms, FlowchartSymbols, GeometryComponent, GeometryThreshold, LineComponent, LineHandleKey, LineMarkerType, LineShape, MemorizeKey, PlaitDrawElement, PlaitGeometry, PlaitLine, Q2C, REACTION_MARGIN, ShapeDefaultSpace, StrokeStyle, WithLineAutoCompletePluginKey, alignPoints, createDefaultFlowchart, createDefaultGeometry,
|
|
3844
|
+
export { BasicShapes, DEFAULT_IMAGE_WIDTH, DefaultBasicShapeProperty, DefaultConnectorProperty, DefaultDataProperty, DefaultDecisionProperty, DefaultFlowchartProperty, DefaultFlowchartPropertyMap, DefaultGeometryActiveStyle, DefaultGeometryStyle, DefaultManualInputProperty, DefaultMergeProperty, DefaultTextProperty, DrawThemeColors, DrawTransforms, FlowchartSymbols, GeometryComponent, GeometryThreshold, LineComponent, LineHandleKey, LineMarkerType, LineShape, MemorizeKey, PlaitDrawElement, PlaitGeometry, PlaitLine, Q2C, REACTION_MARGIN, ShapeDefaultSpace, StrokeStyle, WithLineAutoCompletePluginKey, alignPoints, createDefaultFlowchart, createDefaultGeometry, createGeometryElement, createLineElement, createTextElement, drawBoundMask, drawGeometry, drawLine, getAutoCompletePoints, getBasicPointers, getBoardLines, getCenterPointsOnPolygon, getConnectionPoint, getCurvePoints, getDefaultFlowchartProperty, getDefaultGeometryPoints, getDefaultGeometryProperty, getDefaultTextPoints, getDrawDefaultStrokeColor, getEdgeOnPolygonByPoint, getElbowPoints, getFillByElement, getFlowchartDefaultFill, getFlowchartPointers, getGeometryPointers, getHitConnectorPoint, getHitIndexOfAutoCompletePoint, getHitLineTextIndex, getLineDashByElement, getLineHandleRefPair, getLineMemorizedLatest, getLinePointers, getLinePoints, getLineTextRectangle, getMemorizeKey, getMemorizedLatestByPointer, getMemorizedLatestShape, getNearestPoint, getPointsByCenterPoint, getSelectedDrawElements, getSelectedGeometryElements, getSelectedImageElements, getSelectedLineElements, getStrokeColorByElement, getStrokeStyleByElement, getStrokeWidthByElement, getTextRectangle, getTextShapeProperty, getVectorByConnection, handleLineCreating, insertElement, isHitDrawElement, isHitLineText, isHitPolyLine, isRectangleHitDrawElement, isTextExceedingBounds, memorizeLatestShape, memorizeLatestText, transformOpsToPoints, transformPointToConnection, withDraw, withLineAutoComplete };
|
|
3841
3845
|
//# sourceMappingURL=plait-draw.mjs.map
|