(editor: CustomEditor)
| 174 | |
| 175 | // @see: https://stackoverflow.com/a/74102147 |
| 176 | export const resetEditor = (editor: CustomEditor) => { |
| 177 | const point = { path: [0, 0], offset: 0 } |
| 178 | editor.selection = { anchor: point, focus: point }; |
| 179 | clearEditorHistory(editor); |
| 180 | editor.children = [{ |
| 181 | type: "paragraph", |
| 182 | children: [{ text: "" }] |
| 183 | }]; |
| 184 | } |
| 185 | |
| 186 | export const addLineNumbers = (source: string, lineOffset = 1) => { |
| 187 | return source.split('\n').map((line, index) => `${index + lineOffset}: ${line}`).join('\n'); |
no test coverage detected