mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-17 14:29:46 +02:00
Fix editor key events
This commit is contained in:
@@ -316,7 +316,12 @@ function getExtensions({
|
|||||||
undefined;
|
undefined;
|
||||||
|
|
||||||
return [
|
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 }),
|
tooltips({ parent }),
|
||||||
keymap.of(singleLine ? defaultKeymap.filter((k) => k.key !== 'Enter') : defaultKeymap),
|
keymap.of(singleLine ? defaultKeymap.filter((k) => k.key !== 'Enter') : defaultKeymap),
|
||||||
...(singleLine ? [singleLineExt()] : []),
|
...(singleLine ? [singleLineExt()] : []),
|
||||||
@@ -325,20 +330,14 @@ function getExtensions({
|
|||||||
? [EditorState.readOnly.of(true), EditorView.contentAttributes.of({ tabindex: '-1' })]
|
? [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
|
// Handle onChange
|
||||||
EditorView.updateListener.of((update) => {
|
EditorView.updateListener.of((update) => {
|
||||||
if (onChange && update.docChanged) {
|
if (onChange && update.docChanged) {
|
||||||
onChange.current?.(update.state.doc.toString());
|
onChange.current?.(update.state.doc.toString());
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
...baseExtensions,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user