(
editor: Editor,
{
chars,
offset = 0,
}: {
chars: number;
offset?: number;
}
)
| 1 | import { Editor } from "@tiptap/core"; |
| 2 | |
| 3 | export const getPrevText = ( |
| 4 | editor: Editor, |
| 5 | { |
| 6 | chars, |
| 7 | offset = 0, |
| 8 | }: { |
| 9 | chars: number; |
| 10 | offset?: number; |
| 11 | } |
| 12 | ) => { |
| 13 | // for now, we're using textBetween for now until we can figure out a way to stream markdown text |
| 14 | // with proper formatting: https://github.com/steven-tey/novel/discussions/7 |
| 15 | return editor.state.doc.textBetween( |
| 16 | Math.max(0, editor.state.selection.from - chars), |
| 17 | editor.state.selection.from - offset, |
| 18 | "\n" |
| 19 | ); |
| 20 | // complete(editor.storage.markdown.getMarkdown()); |
| 21 | }; |
no outgoing calls
no test coverage detected