Skip to content

Commit 8f22bd9

Browse files
Implemented review comments
1 parent e0415c3 commit 8f22bd9

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

web/pgadmin/static/js/components/ReactCodeMirror/CustomEditorView.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ export default class CustomEditorView extends EditorView {
205205
return this.state.selection.ranges.map((range)=>this.state.sliceDoc(range.from, range.to)).join(lineSep) ?? '';
206206
}
207207

208+
static getSelectionFromState(state) {
209+
// function to get selection from EditorState
210+
const lineSep = state.facet(eol);
211+
return state.selection.ranges.map((range)=>state.sliceDoc(range.from, range.to)).join(lineSep) ?? '';
212+
}
213+
208214
replaceSelection(newValue) {
209215
this.dispatch(this.state.changeByRange(range => ({
210216
changes: { from: range.from, to: range.to, insert: newValue },

web/pgadmin/static/js/components/ReactCodeMirror/components/Editor.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,7 @@ const defaultExtensions = [
157157
}),
158158
autoCompleteCompartment.of([]),
159159
EditorView.clipboardOutputFilter.of((text, state)=>{
160-
const lineSep = state.facet(eol);
161-
// Fetch the selection range from the editor's current state.
162-
return state.selection.ranges.map((range)=>state.sliceDoc(range.from, range.to)).join(lineSep) ?? '';
160+
return CustomEditorView.getSelectionFromState(state);
163161
})
164162
];
165163

0 commit comments

Comments
 (0)