add onSelectionChange callback
This commit is contained in:
parent
7f0e98ea93
commit
55b2d7f68f
3 changed files with 14 additions and 4 deletions
|
|
@ -78,7 +78,7 @@ const highlightField = StateField.define({
|
|||
provide: (f) => EditorView.decorations.from(f),
|
||||
});
|
||||
|
||||
export default function CodeMirror({ value, onChange, onViewChanged, onCursor, options, editorDidMount }) {
|
||||
export default function CodeMirror({ value, onChange, onViewChanged, onSelectionChange, options, editorDidMount }) {
|
||||
return (
|
||||
<>
|
||||
<_CodeMirror
|
||||
|
|
@ -89,6 +89,11 @@ export default function CodeMirror({ value, onChange, onViewChanged, onCursor, o
|
|||
onCreateEditor={(view) => {
|
||||
onViewChanged(view);
|
||||
}}
|
||||
onUpdate={(viewUpdate) => {
|
||||
if (viewUpdate.selectionSet && onSelectionChange) {
|
||||
onSelectionChange(viewUpdate.state.selection);
|
||||
}
|
||||
}}
|
||||
extensions={[javascript(), strudelTheme, highlightField, flashField]}
|
||||
/>
|
||||
</>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue