mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-16 08:08:34 +00:00
add onSelectionChange callback
This commit is contained in:
parent
7f0e98ea93
commit
55b2d7f68f
4
packages/react/dist/index.cjs.js
vendored
4
packages/react/dist/index.cjs.js
vendored
File diff suppressed because one or more lines are too long
7
packages/react/dist/index.es.js
vendored
7
packages/react/dist/index.es.js
vendored
@ -109,7 +109,7 @@ const highlightField = StateField.define({
|
||||
},
|
||||
provide: (f) => EditorView.decorations.from(f)
|
||||
});
|
||||
function CodeMirror({ value, onChange, onViewChanged, onCursor, options, editorDidMount }) {
|
||||
function CodeMirror({ value, onChange, onViewChanged, onSelectionChange, options, editorDidMount }) {
|
||||
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(_CodeMirror, {
|
||||
value,
|
||||
onChange: (value2) => {
|
||||
@ -118,6 +118,11 @@ function CodeMirror({ value, onChange, onViewChanged, onCursor, options, editorD
|
||||
onCreateEditor: (view) => {
|
||||
onViewChanged(view);
|
||||
},
|
||||
onUpdate: (viewUpdate) => {
|
||||
if (viewUpdate.selectionSet && onSelectionChange) {
|
||||
onSelectionChange(viewUpdate.state.selection);
|
||||
}
|
||||
},
|
||||
extensions: [javascript(), strudelTheme, highlightField, flashField]
|
||||
}));
|
||||
}
|
||||
|
||||
@ -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…
x
Reference in New Issue
Block a user