You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/API_REFERENCE.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -381,6 +381,38 @@ interface StyleState {
381
381
}
382
382
```
383
383
384
+
### `onCaretRectChange`
385
+
386
+
Fires when the caret's pixel position changes (typing, selection change, content reflow). The rect is relative to the input's top-left corner, in density-independent pixels. The native side diffs the rect before emitting, so redundant events are suppressed.
All values are in density-independent pixels, relative to the input's top-left corner.
404
+
405
+
**Example:**
406
+
407
+
```tsx
408
+
<EnrichedMarkdownInput
409
+
scrollEnabled={false}
410
+
onCaretRectChange={(rect) => {
411
+
console.log('Caret at:', rect.x, rect.y);
412
+
}}
413
+
/>
414
+
```
415
+
384
416
### `onFocus`
385
417
386
418
Fires when the input gains focus.
@@ -474,6 +506,10 @@ Sets the input content from a Markdown string. Parses the Markdown and applies f
474
506
475
507
Returns a Promise that resolves with the current Markdown content. The async nature is due to the native bridge — the request is sent to the native side and the result is returned via an event.
476
508
509
+
### `getCaretRect(): Promise<CaretRect>`
510
+
511
+
Returns a Promise that resolves with the current caret's pixel position relative to the input. Useful for one-off queries; for continuous tracking, prefer `onCaretRectChange`.
Copy file name to clipboardExpand all lines: docs/INPUT.md
+25Lines changed: 25 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -121,6 +121,31 @@ The callback fires only for newly detected links — not for links that were alr
121
121
122
122
When a manual link is applied (via `setLink` or `insertLink`) over an auto-detected link, the auto-detected link is replaced by the manual one. Auto-link detection skips ranges that already contain a manual link.
123
123
124
+
## Caret Position Tracking
125
+
126
+
`EnrichedMarkdownInput` can report the caret's pixel position relative to the input, which is useful when the input is embedded in a scrollable container with `scrollEnabled={false}` and you need to keep the caret visible.
127
+
128
+
### `onCaretRectChange`
129
+
130
+
A push-based callback that fires whenever the caret moves (typing, selection change, content reflow). The native side diffs the caret rect before emitting, so redundant events are suppressed automatically.
131
+
132
+
```tsx
133
+
<EnrichedMarkdownInput
134
+
scrollEnabled={false}
135
+
onCaretRectChange={(rect) => {
136
+
console.log(rect);
137
+
}}
138
+
/>
139
+
```
140
+
141
+
### `getCaretRect()`
142
+
143
+
An imperative, pull-based method for one-off queries. Returns a Promise that resolves with the current caret rect.
144
+
145
+
```tsx
146
+
const rect =awaitref.current?.getCaretRect();
147
+
```
148
+
124
149
## Style Detection
125
150
126
151
All of the above styles can be detected with the use of [onChangeState](API_REFERENCE.md#onchangestate) callback payload.
0 commit comments