UX: skip leading spaces in selection when adding a link.

This commit is contained in:
Vinoth Kannan 2019-11-30 20:14:22 +05:30
parent 57f108899a
commit 580b289861
2 changed files with 5 additions and 5 deletions

View File

@ -99,6 +99,7 @@ class Toolbar {
id: "link",
group: "insertions",
shortcut: "K",
trimLeading: true,
sendAction: event => this.context.send("showLinkModal", event)
});
}
@ -956,15 +957,14 @@ export default Component.extend({
}
let linkText = "";
this._lastSel = this._getSelected();
this._lastSel = toolbarEvent.selected;
if (this._lastSel) {
linkText = this._lastSel.value.trim();
linkText = this._lastSel.value;
}
showModal("insert-hyperlink").setProperties({
linkText: linkText,
_lastSel: this._lastSel,
linkText,
toolbarEvent
});
},

View File

@ -147,7 +147,7 @@ export default Controller.extend(ModalFunctionality, {
const origLink = this.linkUrl;
const linkUrl =
origLink.indexOf("://") === -1 ? `http://${origLink}` : origLink;
const sel = this._lastSel;
const sel = this.toolbarEvent.selected;
if (isEmpty(linkUrl)) {
return;