0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-26 00:52:48 +00:00

Use cm.replaceSelection instead of split/join text

This commit is contained in:
G.Ambatte
2022-09-24 13:34:26 +12:00
parent 6ade9925d7
commit 56fde5a448
2 changed files with 5 additions and 13 deletions

View File

@@ -229,6 +229,10 @@ const CodeEditor = createClass({
this.codeMirror.replaceSelection('\n\\page\n\n', 'end');
},
injectText : function(injectText) {
this.codeMirror.replaceSelection(injectText, 'around');
},
makeUnderline : function() {
const selection = this.codeMirror.getSelection(), t = selection.slice(0, 3) === '<u>' && selection.slice(-4) === '</u>';
this.codeMirror.replaceSelection(t ? selection.slice(3, -4) : `<u>${selection}</u>`, 'around');