From 5e9c1ce57774012cb1903c2e97ac87ff42d1e245 Mon Sep 17 00:00:00 2001 From: Hufe921 Date: Fri, 23 Dec 2022 19:48:48 +0800 Subject: [PATCH] feat:add isPointInRange function to Range --- src/editor/core/range/RangeManager.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/editor/core/range/RangeManager.ts b/src/editor/core/range/RangeManager.ts index 2e49f10..684d138 100644 --- a/src/editor/core/range/RangeManager.ts +++ b/src/editor/core/range/RangeManager.ts @@ -61,6 +61,18 @@ export class RangeManager { return rangeRow } + public getIsPointInRange(x: number, y: number): boolean { + const { startIndex, endIndex } = this.range + const positionList = this.position.getPositionList() + for (let p = startIndex + 1; p <= endIndex; p++) { + const { coordinate: { leftTop, rightBottom } } = positionList[p] + if (x >= leftTop[0] && x <= rightBottom[0] && y >= leftTop[1] && y <= rightBottom[1]) { + return true + } + } + return false + } + public setRange( startIndex: number, endIndex: number,