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

Changed url for react editor module to use Ghost/config-provided url (#2428)

reqs https://github.com/TryGhost/Ghost/pull/15045

- accesses the Ember registry via the `GhostAdmin` global to grab the editor component url that Admin fetches from the config endpoint
- `ember-auto-import` does not allow dynamic imports unless it can see it's an absolute URL, to work around that we strip the `https://` part of the provided URL and manually include it in the template string so it's detectable as an absolute URL when building
- added redirect to posts screen if no editor url is provided in config
This commit is contained in:
Kevin Ansfield 2022-07-19 14:24:07 +01:00 committed by GitHub
parent 896cd4888f
commit f00bdbf43c
2 changed files with 15 additions and 1 deletions

View file

@ -1,3 +1,4 @@
/* global GhostAdmin */
import React, {Suspense} from 'react';
class ErrorHandler extends React.Component {
@ -29,7 +30,12 @@ const fetchMobiledocEditor = function () {
return window.ReactMobiledocEditor;
}
await import('https://unpkg.com/kevinansfield-react-mobiledoc-editor@~0.13.2/dist/main.js');
// the removal of `https://` and it's manual addition to the import template string is
// required to work around ember-auto-import complaining about an unknown dynamic import
// during the build step
const url = GhostAdmin.__container__.lookup('service:config').get('editor.url').replace('https://', '');
await import(`https://${url}`);
return window.ReactMobiledocEditor;
};

View file

@ -4,12 +4,20 @@ import {run} from '@ember/runloop';
import {inject as service} from '@ember/service';
export default AuthenticatedRoute.extend({
config: service(),
feature: service(),
notifications: service(),
router: service(),
ui: service(),
classNames: ['editor'],
beforeModel() {
if (!this.config.get('editor.url')) {
return this.router.transitionTo('posts');
}
},
activate() {
this._super(...arguments);
this.ui.set('isFullScreen', true);