Skip to content

Commit

Permalink
fix annotator selection, close #2433
Browse files Browse the repository at this point in the history
  • Loading branch information
jancimertel committed Nov 10, 2024
1 parent 14364ca commit 3f255cc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/annotator/src/lib/Annotator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,16 @@ export class Annotator {
*/
onMouseMove(e: MouseEvent) {
if (this.cursor.isSelecting()) {
// move the cursor to selected position, but dont allow to move over the line boundaries (x axis)
this.cursor.setPositionFromEvent(e, this.lineHeight, this.charWidth);
const segment = this.text.cursorToIndex(this.viewport, this.cursor);
if (segment) {
const line = this.text.getLineFromPosition(segment);
if (line.length < this.cursor.xLine) {
this.cursor.xLine = line.length;
}
}

this.cursor.selectArea(this.viewport.lineStart);
this.draw();
}
Expand Down Expand Up @@ -928,7 +937,6 @@ export class Annotator {
for (const tag of annotated) {
const hlSchema = this.onHighlightCb(tag);
if (hlSchema) {

// iterate over all tag occurrences
let occurence: IAbsCoordinates[];
let i = 1;
Expand Down

0 comments on commit 3f255cc

Please sign in to comment.