Skip to content

Commit

Permalink
fix(draw): fix resize geometry without text error #WIK-15876
Browse files Browse the repository at this point in the history
  • Loading branch information
MissLixf committed Jul 2, 2024
1 parent ccdc351 commit 09d1ab7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions packages/draw/src/plugins/with-draw-resize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
getSymmetricHandleIndex,
isCornerHandle,
withResize,
resetPointsAfterResize
resetPointsAfterResize,
normalizeShapePoints
} from '@plait/common';
import {
PlaitBoard,
Expand All @@ -28,12 +29,14 @@ import {
isAxisChangedByAngle,
drawRectangle,
ACTIVE_STROKE_WIDTH,
SELECTION_BORDER_COLOR
SELECTION_BORDER_COLOR,
Path
} from '@plait/core';
import { PlaitDrawElement } from '../interfaces';
import { DrawTransforms } from '../transforms';
import { getHitRectangleResizeHandleRef } from '../utils/position/geometry';
import { getSnapResizingRefOptions, getSnapResizingRef } from '../utils/snap-resizing';
import { isGeometryIncludeText } from '../utils';

const debugKey = 'debug:plait:resize-for-rotation';
const debugGenerator = createDebugGenerator(debugKey);
Expand Down Expand Up @@ -176,8 +179,13 @@ export function withDrawResize(board: PlaitBoard) {
}

if (PlaitDrawElement.isGeometry(target)) {
const textHeight = getFirstTextManage(target)?.getSize()?.height || 0;
DrawTransforms.resizeGeometry(board, points as [Point, Point], textHeight, path);
if (isGeometryIncludeText(target)) {
const { height: textHeight } = getFirstTextManage(target).getSize();
DrawTransforms.resizeGeometry(board, points as [Point, Point], textHeight, path);
} else {
points = normalizeShapePoints(points as [Point, Point]);
Transforms.setNode(board, { points }, path);
}
} else if (PlaitDrawElement.isArrowLine(target)) {
Transforms.setNode(board, { points }, path);
} else if (PlaitDrawElement.isImage(target)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/draw/src/plugins/with-geometry-resize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const withGeometryResize = (board: PlaitBoard) => {
PlaitBoard.getElementActiveHost(board).append(snapG);
let points = resizeSnapRef.activePoints as [Point, Point];
if (PlaitDrawElement.isGeometry(resizeRef.element) && isGeometryIncludeText(resizeRef.element)) {
const textHeight = getFirstTextManage(resizeRef.element)?.getSize()?.height || 0;
const { height: textHeight } = getFirstTextManage(resizeRef.element).getSize();
DrawTransforms.resizeGeometry(board, points, textHeight, resizeRef.path as Path);
} else {
points = normalizeShapePoints(points);
Expand Down

0 comments on commit 09d1ab7

Please sign in to comment.