Skip to content

Commit 53a331f

Browse files
pdanpdanrstoenescu
authored andcommitted
feat(QEditor): Fix link selection (and remove range restore on focus) (quasarframework#5870)
1 parent c9402b5 commit 53a331f

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

ui/src/components/editor/QEditor.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ export default Vue.extend({
312312
if (this.$refs.content !== void 0 && this.__offsetBottom !== void 0) {
313313
this.$refs.content.scrollTop = this.$refs.content.scrollHeight - this.__offsetBottom
314314
}
315-
this.caret.restore()
316315
})
317316
},
318317

ui/src/components/editor/editor-caret.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,7 @@ export class Caret {
227227
return
228228
}
229229
else if (cmd === 'link') {
230-
const
231-
link = this.getParentAttribute('href'),
232-
range = this.range
230+
const link = this.getParentAttribute('href')
233231

234232
if (link === null) {
235233
const selection = this.selectWord(this.selection)
@@ -241,15 +239,15 @@ export class Caret {
241239

242240
this.vm.editLinkUrl = urlRegex.test(url) ? url : 'https://'
243241
document.execCommand('createLink', false, this.vm.editLinkUrl)
242+
243+
this.save(selection.getRangeAt(0))
244244
}
245245
else {
246246
this.vm.editLinkUrl = link
247-
}
248247

249-
this.vm.$nextTick(() => {
250-
range.selectNodeContents(this.parent)
251-
this.save(range)
252-
})
248+
this.range.selectNodeContents(this.parent)
249+
this.save()
250+
}
253251

254252
return
255253
}

0 commit comments

Comments
 (0)