|
@@ -96,6 +96,7 @@ export const getMarkupWithSelection: GetMarkupWithSelectionFunc = ({
|
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
|
|
// @ts-ignore
|
|
|
const textElements = [...textLayer.childNodes];
|
|
|
+ let inRange = false;
|
|
|
|
|
|
textElements.forEach((ele: HTMLElement) => {
|
|
|
const { height, width } = ele.getBoundingClientRect();
|
|
@@ -121,29 +122,15 @@ export const getMarkupWithSelection: GetMarkupWithSelectionFunc = ({
|
|
|
// in start element
|
|
|
coords.left = startX;
|
|
|
position.push(coords);
|
|
|
+ inRange = true;
|
|
|
} else if (endElement === ele) {
|
|
|
// in end element
|
|
|
coords.right = endX;
|
|
|
position.push(coords);
|
|
|
- } else if (top >= startY + height && bottom <= endY - height) {
|
|
|
- // in row
|
|
|
+ inRange = false;
|
|
|
+ } else if (inRange) {
|
|
|
+ // middle element
|
|
|
position.push(coords);
|
|
|
- } else if (
|
|
|
- left > startX &&
|
|
|
- right < endX &&
|
|
|
- top >= startY &&
|
|
|
- bottom <= endY
|
|
|
- ) {
|
|
|
- // in line
|
|
|
- position.push(coords);
|
|
|
- } else if (top >= startY - 3 && bottom <= endY + 3) {
|
|
|
- if (
|
|
|
- (left > startX && top >= startY - 3 && bottom < endY - height) ||
|
|
|
- (right < endX && bottom <= endY + 3 && top > startY + height)
|
|
|
- ) {
|
|
|
- // in first line and end line
|
|
|
- position.push(coords);
|
|
|
- }
|
|
|
}
|
|
|
});
|
|
|
|