This commit is contained in:
@@ -106,12 +106,16 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateSelectedRange() {
|
||||
getSelectedRange() {
|
||||
let bodyTextArea = this.$refs.editArea.$el.querySelector("textarea");
|
||||
this.selection.start = bodyTextArea.selectionStart;
|
||||
this.selection.end = bodyTextArea.selectionEnd;
|
||||
this.selection.hasSelection = this.selection.start != this.selection.end;
|
||||
},
|
||||
setSelectedRange(start, end) {
|
||||
let bodyTextArea = this.$refs.editArea.$el.querySelector("textarea");
|
||||
bodyTextArea.setSelectionRange(start, end);
|
||||
},
|
||||
getSelectedText() {
|
||||
let selectedText = "";
|
||||
if (this.selection.hasSelection) {
|
||||
@@ -142,21 +146,22 @@ export default {
|
||||
);
|
||||
},
|
||||
clickBold() {
|
||||
this.updateSelectedRange();
|
||||
this.getSelectedRange();
|
||||
this.replaceSelectedText("**" + this.getSelectedText() + "**");
|
||||
//console.log("BOLD CLICK, selection:", this.getSelectedText());
|
||||
},
|
||||
|
||||
handleDoubleClick(i) {
|
||||
//the purpose of this is only to change the selection if it's got an extra space to the right
|
||||
//becuase double clicking on a word with another word after it causes the space to be included
|
||||
this.updateSelectedRange();
|
||||
//because double clicking on a word with another word after it causes the space to be included
|
||||
this.getSelectedRange();
|
||||
let temp = this.getSelectedText();
|
||||
let tempTrimmed = temp.trimEnd();
|
||||
let diff = temp.length - tempTrimmed.length;
|
||||
if (diff != 0) {
|
||||
//there were some spaces so update the selection range
|
||||
//force selection to be shorter by diff
|
||||
this.setSelectedRange(this.selection.start, this.selection.end - diff);
|
||||
}
|
||||
},
|
||||
handleInput(val) {
|
||||
|
||||
Reference in New Issue
Block a user