0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

🐛 Koenig - Fixed /-menu not working after the editor is reloaded

refs https://github.com/TryGhost/Ghost/issues/9724
- if the editor was reloaded by changing the post model either through clicking "New story" or using the search from the editor screen the /-menu would stop working
- keep track of the last seen `editor` instance inside `{{koenig-slash-menu}}` and register the `/` text input handler on the new editor instance if it changes
This commit is contained in:
Kevin Ansfield 2018-07-11 15:08:51 +01:00
parent 68ce5571f4
commit beab7a7a4f

View file

@ -58,28 +58,27 @@ export default Component.extend({
return map;
}),
init() {
this._super(...arguments);
let editor = this.editor;
// register `/` text input for positioning & showing the menu
editor.onTextInput({
name: 'slash_menu',
text: '/',
run: run.bind(this, this._showMenu)
});
},
didReceiveAttrs() {
this._super(...arguments);
let editorRange = this.editorRange;
// re-register the / text input handler if the editor changes such as
// when a "New story" is clicked from the sidebar or a different post
// is loaded via search
if (this.editor !== this._lastEditor) {
this.editor.onTextInput({
name: 'slash_menu',
text: '/',
run: run.bind(this, this._showMenu)
});
}
this._lastEditor = this.editor;
// re-position the menu and update the query if necessary when the
// cursor position changes
let editorRange = this.editorRange;
if (editorRange !== this._lastEditorRange) {
this._handleCursorChange(editorRange);
}
this._lastEditorRange = editorRange;
},