0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-06 03:32:40 +00:00

Add optional overwrite protection

This commit is contained in:
G.Ambatte
2022-09-24 13:50:26 +12:00
parent 22896470e3
commit db174c9655
2 changed files with 7 additions and 3 deletions

View File

@@ -75,7 +75,7 @@ const Editor = createClass({
}, },
handleInject : function(injectText){ handleInject : function(injectText){
this.refs.codeEditor?.injectText(injectText); this.refs.codeEditor?.injectText(injectText, false);
}, },
handleViewChange : function(newView){ handleViewChange : function(newView){

View File

@@ -229,8 +229,12 @@ const CodeEditor = createClass({
this.codeMirror.replaceSelection('\n\\page\n\n', 'end'); this.codeMirror.replaceSelection('\n\\page\n\n', 'end');
}, },
injectText : function(injectText) { injectText : function(injectText, overwrite=true) {
this.codeMirror.replaceSelection(injectText, 'around'); const cm = this.codeMirror;
if(!overwrite) {
cm.setCursor(cm.getCursor('from'));
}
cm.replaceSelection(injectText, 'around');
}, },
makeUnderline : function() { makeUnderline : function() {