diff --git a/src-web/components/core/Editor/Editor.tsx b/src-web/components/core/Editor/Editor.tsx index f551cb71..1b51fba7 100644 --- a/src-web/components/core/Editor/Editor.tsx +++ b/src-web/components/core/Editor/Editor.tsx @@ -316,7 +316,12 @@ function getExtensions({ undefined; return [ - ...baseExtensions, + // NOTE: These *must* be anonymous functions so the references update properly + EditorView.domEventHandlers({ + focus: () => onFocus.current?.(), + blur: () => onBlur.current?.(), + keydown: (e) => onKeyDown.current?.(e), + }), tooltips({ parent }), keymap.of(singleLine ? defaultKeymap.filter((k) => k.key !== 'Enter') : defaultKeymap), ...(singleLine ? [singleLineExt()] : []), @@ -325,20 +330,14 @@ function getExtensions({ ? [EditorState.readOnly.of(true), EditorView.contentAttributes.of({ tabindex: '-1' })] : []), - // Handle onFocus - // NOTE: These *must* be anonymous functions so the references update properly - EditorView.domEventHandlers({ - focus: () => onFocus.current?.(), - blur: () => onBlur.current?.(), - keydown: (e) => onKeyDown.current?.(e), - }), - // Handle onChange EditorView.updateListener.of((update) => { if (onChange && update.docChanged) { onChange.current?.(update.state.doc.toString()); } }), + + ...baseExtensions, ]; }