MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / alertEditorError

Function alertEditorError

packages/app-core/src/components/Editor.tsx:302–321  ·  view source on GitHub ↗

* Report an ex-command error as a non-blocking, in-editor notification — the * same red bottom-of-editor message codemirror-vim uses for its own errors * (e.g. an unknown `:command`). The previous native `window.alert` blurred * CodeMirror, leaving Vim users unable to type until the editor was re

(message: string)

Source from the content-addressed store, hash-verified

300 * unavailable. (#173)
301 */
302function alertEditorError(message: string): void {
303 const view = useStore.getState().editorViewRef
304 const cm = view ? getCM(view) : null
305 const openNotification = (
306 cm as unknown as {
307 openNotification?: (node: Node, opts: { bottom?: boolean; duration?: number }) => void
308 } | null
309 )?.openNotification
310 if (cm && typeof openNotification === 'function') {
311 const el = document.createElement('div')
312 el.className = 'cm-vim-message'
313 el.style.color = 'red'
314 el.style.whiteSpace = 'pre'
315 el.textContent = message
316 openNotification.call(cm, el, { bottom: true, duration: 4000 })
317 return
318 }
319 window.alert(message)
320 focusEditorNormalMode()
321}
322
323// Minimal shape of the CodeMirror-Vim adapter + state the display-line motion
324// touches (the package's own types don't surface these helpers).

Callers 3

registerVimCommandsFunction · 0.85
openOrCreateByPathFunction · 0.85
moveActiveNoteFunction · 0.85

Calls 1

focusEditorNormalModeFunction · 0.90

Tested by

no test coverage detected