mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
🐝 Fix editor toolbar link focus issues. (#599)
closes https://github.com/TryGhost/Ghost/issues/8195 When the toolbar is toggled into link mode the link input field should always focus, however this only happens on the first time which leads to issues with mobiledoc having focus but not the range. This fix means that the toolbar always focuses.
This commit is contained in:
parent
5b44886412
commit
c412d6e6f9
2 changed files with 12 additions and 8 deletions
|
@ -101,14 +101,18 @@ export default Component.extend({
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
closeLink() {
|
|
||||||
this.set('isLink', false);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
doLink(range) {
|
doLink(range) {
|
||||||
this.set('isLink', true);
|
this.set('isLink', true);
|
||||||
this.set('linkRange', range);
|
this.set('linkRange', range);
|
||||||
|
run.schedule('afterRender', this,
|
||||||
|
() => {
|
||||||
|
this.$('input').focus();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
closeLink() {
|
||||||
|
this.set('isLink', false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -140,7 +144,7 @@ function updateToolbarToRange(self, $holder, $editor, isMouseDown) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
self.set('isLink', false);
|
self.send('closeLink');
|
||||||
|
|
||||||
self.tools.forEach((tool) => {
|
self.tools.forEach((tool) => {
|
||||||
if (tool.hasOwnProperty('checkElements')) {
|
if (tool.hasOwnProperty('checkElements')) {
|
||||||
|
@ -152,7 +156,7 @@ function updateToolbarToRange(self, $holder, $editor, isMouseDown) {
|
||||||
} else {
|
} else {
|
||||||
if (self.isVisible) {
|
if (self.isVisible) {
|
||||||
self.set('isVisible', false);
|
self.set('isVisible', false);
|
||||||
self.set('isLink', false);
|
self.send('closeLink');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,7 @@ export default function (editor, toolbar) {
|
||||||
type: 'markup',
|
type: 'markup',
|
||||||
visibility: 'primary',
|
visibility: 'primary',
|
||||||
onClick: (editor) => {
|
onClick: (editor) => {
|
||||||
toolbar.doLink(editor.range);
|
toolbar.send('doLink', editor.range);
|
||||||
},
|
},
|
||||||
checkElements(elements) {
|
checkElements(elements) {
|
||||||
set(this, 'selected', elements.filter((element) => element.tagName === 'a').length > 0);
|
set(this, 'selected', elements.filter((element) => element.tagName === 'a').length > 0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue