Skip to content

Commit

Permalink
implement "inverted" insert
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Nüsse <felix.nuesse@t-online.de>
  • Loading branch information
newhinton committed May 28, 2022
1 parent f55049d commit d21b965
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/EditorEasyMDE.vue
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,15 @@ export default {
if (originalText === '') {
originalText = ifCenterEmpty
}
doc.replaceRange(front + originalText + back, cursorStart, cursorEnd)
if(originalText.startsWith(front) && originalText.endsWith(back)) {
let insertText = originalText.replace(front, "")
insertText = this.reverseString(insertText)
insertText = insertText.replace(this.reverseString(back), "")
doc.replaceSelection(this.reverseString(insertText), "around")
} else {
doc.replaceSelection(front + originalText + back, "around")
}
},
insertLink() {
Expand Down Expand Up @@ -345,6 +353,10 @@ export default {
if (this.mde.codemirror.historySize().redo > 0) {
this.mde.codemirror.redo()
}
},
reverseString(string) {
return string.split('').reverse().join('')
}
},
}
Expand Down

0 comments on commit d21b965

Please sign in to comment.