mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-05-07 18:48:39 +00:00
fix snippets
This commit is contained in:
@@ -355,21 +355,11 @@ const CodeEditor = forwardRef(
|
|||||||
|
|
||||||
injectText : (text)=>{
|
injectText : (text)=>{
|
||||||
const view = viewRef.current;
|
const view = viewRef.current;
|
||||||
const changes = view.state.selection.ranges.map((range)=>({
|
|
||||||
from : range.from,
|
|
||||||
to : range.to,
|
|
||||||
insert : text
|
|
||||||
}));
|
|
||||||
|
|
||||||
const newRanges = view.state.selection.ranges.map((range)=>({
|
|
||||||
anchor : range.from + text.length
|
|
||||||
}));
|
|
||||||
|
|
||||||
view.dispatch({
|
|
||||||
changes,
|
|
||||||
selection : { ranges: newRanges }
|
|
||||||
});
|
|
||||||
|
|
||||||
|
view.dispatch(
|
||||||
|
view.state.replaceSelection(text)
|
||||||
|
);
|
||||||
view.focus();
|
view.focus();
|
||||||
},
|
},
|
||||||
getCursorPosition : ()=>viewRef.current.state.selection.main.head,
|
getCursorPosition : ()=>viewRef.current.state.selection.main.head,
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ const Editor = createReactClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
handleInject : function(injectText){
|
handleInject : function(injectText){
|
||||||
this.codeEditor.current?.injectText(injectText, false);
|
this.codeEditor.current?.injectText(injectText);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleViewChange : function(newView){
|
handleViewChange : function(newView){
|
||||||
|
|||||||
Reference in New Issue
Block a user