Skip to content

Commit

Permalink
fix(draw): hide middlePoints on line when edit text #WIK-15244
Browse files Browse the repository at this point in the history
  • Loading branch information
huanhuanwa authored and pubuzhixing8 committed Apr 26, 2024
1 parent f854a64 commit 94cc6da
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-beers-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@plait/draw': patch
---

hide middlePoints on line when edit text
32 changes: 20 additions & 12 deletions packages/draw/src/generators/line-active.generator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Point, createG, drawRectangle, getSelectedElements } from '@plait/core';
import { PlaitBoard, Point, createG, drawRectangle, getSelectedElements } from '@plait/core';
import { LineShape, PlaitLine } from '../interfaces';
import { Generator, PRIMARY_COLOR, drawFillPrimaryHandle, drawPrimaryHandle } from '@plait/common';
import { getMiddlePoints } from '../utils/line/line-basic';
Expand Down Expand Up @@ -42,19 +42,27 @@ export class LineActiveGenerator extends Generator<PlaitLine, ActiveData> {
activeG.appendChild(updateHandle);
});
const middlePoints = getMiddlePoints(this.board, element);
for (let i = 0; i < middlePoints.length; i++) {
const point = middlePoints[i];
if (element.shape === LineShape.elbow && elbowNextRenderPoints.length) {
const handleIndex = getHitPointIndex(middlePoints, point);
const isUpdateHandleIndex = isUpdatedHandleIndex(this.board, element, [...points], elbowNextRenderPoints, handleIndex);
if (isUpdateHandleIndex) {
const updateHandle = drawPrimaryHandle(this.board, point);
activeG.appendChild(updateHandle);
continue;
if (!PlaitBoard.hasBeenTextEditing(this.board)) {
for (let i = 0; i < middlePoints.length; i++) {
const point = middlePoints[i];
if (element.shape === LineShape.elbow && elbowNextRenderPoints.length) {
const handleIndex = getHitPointIndex(middlePoints, point);
const isUpdateHandleIndex = isUpdatedHandleIndex(
this.board,
element,
[...points],
elbowNextRenderPoints,
handleIndex
);
if (isUpdateHandleIndex) {
const updateHandle = drawPrimaryHandle(this.board, point);
activeG.appendChild(updateHandle);
continue;
}
}
const circle = drawFillPrimaryHandle(this.board, point);
activeG.appendChild(circle);
}
const circle = drawFillPrimaryHandle(this.board, point);
activeG.appendChild(circle);
}
} else {
const activeRectangle = this.board.getRectangle(element);
Expand Down

0 comments on commit 94cc6da

Please sign in to comment.