@@ -5,7 +5,7 @@ import {ValueSyncStore} from '../../util/events/sync-store';
5
5
import type { Printable } from 'tree-dump' ;
6
6
import type { KeyController } from './KeyController' ;
7
7
import type { PeritextEventTarget } from '../events/PeritextEventTarget' ;
8
- import type { Rect , UiLifeCycles } from './types' ;
8
+ import type { UiLifeCycles } from './types' ;
9
9
import type { Peritext } from '../../json-crdt-extensions/peritext' ;
10
10
import type { Inline } from '../../json-crdt-extensions/peritext/block/Inline' ;
11
11
@@ -55,46 +55,6 @@ export class CursorController implements UiLifeCycles, Printable {
55
55
return - 1 ;
56
56
}
57
57
58
- public caretRect ( ) : Rect | undefined {
59
- const el = document . getElementById ( this . caretId ) ;
60
- if ( ! el ) return ;
61
- const rect = el . getBoundingClientRect ( ) ;
62
- return rect ;
63
- }
64
-
65
- /**
66
- * Find text position at similar x coordinate on the next line.
67
- *
68
- * @param direction 1 for next line, -1 for previous line.
69
- * @returns The position at similar x coordinate on the next line, or
70
- * undefined if not found.
71
- *
72
- * @todo Implement similar functionality for finding soft line breaks (end
73
- * and start of lines). Or use `.getClientRects()` trick with `Range`
74
- * object, see: https://www.bennadel.com/blog/4310-detecting-rendered-line-breaks-in-a-text-node-in-javascript.htm
75
- */
76
- public getNextLinePos ( direction : 1 | - 1 = 1 ) : number | undefined {
77
- // TODO: this works only for the main cursor, make it work for all cursors.
78
- const rect = this . caretRect ( ) ;
79
- if ( ! rect ) return ;
80
- const { x, y, width, height} = rect ;
81
- const halfWidth = width / 2 ;
82
- const halfHeight = height / 2 ;
83
- const currentPos = this . opts . txt . editor . cursor . focus ( ) . viewPos ( ) ;
84
- const caretPos = this . posAtPoint ( x + halfWidth , y + halfHeight ) ;
85
- if ( currentPos !== caretPos ) return ;
86
- for ( let i = 1 ; i < 16 ; i ++ ) {
87
- const dy = i * direction * halfHeight ;
88
- const pos = this . posAtPoint ( x + halfWidth , y + dy ) ;
89
- if ( pos !== - 1 && pos !== caretPos ) {
90
- if ( direction < 0 ) {
91
- if ( pos < caretPos ) return pos ;
92
- } else if ( pos > caretPos ) return pos ;
93
- }
94
- }
95
- return undefined ;
96
- }
97
-
98
58
/** -------------------------------------------------- {@link UiLifeCycles} */
99
59
100
60
public start ( ) : void {
0 commit comments