From 7a9435d524a1f4406fc61a4852122bf17054a4a7 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Wed, 27 Jul 2022 11:57:40 +0100 Subject: [PATCH] Hooked up editor registration in react editor experiment no issue - use the `didCreateEditor` hook to register the editor instance as we do with our Ember version of Koenig - allows for initial handling of focus control for moving cursor between title and body inputs - disabled card cleanup call because the react editor does not yet have cards or the custom `cleanup()` method --- ghost/admin/app/components/gh-koenig-editor-react.hbs | 1 + ghost/admin/app/components/gh-koenig-editor-react.js | 2 +- ghost/admin/app/components/koenig-react-editor.js | 1 + ghost/admin/app/components/react-mobiledoc-editor.js | 1 + ghost/admin/app/controllers/react-editor.js | 7 ++++--- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ghost/admin/app/components/gh-koenig-editor-react.hbs b/ghost/admin/app/components/gh-koenig-editor-react.hbs index 9045252db3..93c97bf7a7 100644 --- a/ghost/admin/app/components/gh-koenig-editor-react.hbs +++ b/ghost/admin/app/components/gh-koenig-editor-react.hbs @@ -37,6 +37,7 @@ diff --git a/ghost/admin/app/components/gh-koenig-editor-react.js b/ghost/admin/app/components/gh-koenig-editor-react.js index 30cf3684f6..ff6005e415 100644 --- a/ghost/admin/app/components/gh-koenig-editor-react.js +++ b/ghost/admin/app/components/gh-koenig-editor-react.js @@ -119,7 +119,7 @@ export default class GhKoenigEditorReactComponent extends Component { _setupEditor(koenig) { let component = this; - this.koenigEditor = koenig.editor; + this.koenigEditor = koenig; // focus the title when pressing SHIFT+TAB this.koenigEditor.registerKeyCommand({ diff --git a/ghost/admin/app/components/koenig-react-editor.js b/ghost/admin/app/components/koenig-react-editor.js index 2d724b0085..4e68749735 100644 --- a/ghost/admin/app/components/koenig-react-editor.js +++ b/ghost/admin/app/components/koenig-react-editor.js @@ -9,6 +9,7 @@ export default class KoenigReactEditor extends ReactComponent { element, ); diff --git a/ghost/admin/app/components/react-mobiledoc-editor.js b/ghost/admin/app/components/react-mobiledoc-editor.js index 411eb563da..c7b4f64ca2 100644 --- a/ghost/admin/app/components/react-mobiledoc-editor.js +++ b/ghost/admin/app/components/react-mobiledoc-editor.js @@ -77,6 +77,7 @@ const ReactMobiledocEditor = (props) => { Loading editor...

}>
diff --git a/ghost/admin/app/controllers/react-editor.js b/ghost/admin/app/controllers/react-editor.js index 014aaaa035..ac539cb8c0 100644 --- a/ghost/admin/app/controllers/react-editor.js +++ b/ghost/admin/app/controllers/react-editor.js @@ -290,9 +290,10 @@ export default class ReactEditorController extends Controller { // - empty cards may be left in draft posts due to autosave occuring // whilst an empty card is present then the user closing the browser // or refreshing the page - if (this.post.isDraft) { - this._koenig.cleanup(); - } + // TODO: not yet implemented in react editor + // if (this.post.isDraft) { + // this._koenig.cleanup(); + // } } @action