From 5f5ad4d5dd4c2002ef50658e872f4f17b9eefda2 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Wed, 30 Aug 2023 16:54:03 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Added=20automatic=20conversion=20of?= =?UTF-8?q?=20old=20content=20when=20opening=20in=20beta=20editor=20(#1787?= =?UTF-8?q?6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue Previously the beta editor only worked for newly created posts/pages, any older content would open with the original editor. This change enables automatic conversion of old content to the new content format when a post/page is opened in the admin interface allowing new features like signup and advanced header cards to be used on existing content. - removed `convertToLexical` feature flag - where necessary switched to using just the `lexicalEditor` feature flag in its place - moved the "L"/"M" indicators on the posts list to a new `lexicalIndicators` feature flag to make debugging/development easier - added a redirect to the original editor route so that any route to opening the editor (such as the `/edit` front-end shortcut, or other areas of Admin) will open in the beta editor - avoids confusing/inconsistent behavior --- .../components/settings/advanced/labs/AlphaFeatures.tsx | 4 ---- ghost/admin/app/components/posts-list/list-item.hbs | 9 ++++----- ghost/admin/app/components/posts-list/list-item.js | 2 -- ghost/admin/app/routes/editor.js | 8 ++++++++ ghost/admin/app/routes/lexical-editor/edit.js | 4 ++-- ghost/admin/app/services/feature.js | 2 +- ghost/admin/app/templates/lexical-editor.hbs | 3 --- ghost/admin/app/templates/settings/labs.hbs | 6 +++--- ghost/admin/tests/acceptance/editor/lexical-test.js | 4 ++-- ghost/core/core/server/models/post.js | 2 +- ghost/core/core/shared/labs.js | 4 ++-- 11 files changed, 23 insertions(+), 25 deletions(-) diff --git a/apps/admin-x-settings/src/components/settings/advanced/labs/AlphaFeatures.tsx b/apps/admin-x-settings/src/components/settings/advanced/labs/AlphaFeatures.tsx index 349d86a115..150d88098c 100644 --- a/apps/admin-x-settings/src/components/settings/advanced/labs/AlphaFeatures.tsx +++ b/apps/admin-x-settings/src/components/settings/advanced/labs/AlphaFeatures.tsx @@ -43,10 +43,6 @@ const features = [{ title: 'Mail Events', description: 'Enables processing of mail events', flag: 'mailEvents' -},{ - title: 'Convert to Lexical', - description: 'Convert mobiledoc posts to lexical upon opening in the editor.', - flag: 'convertToLexical' },{ title: 'Import Member Tier', description: 'Enables tier to be specified when importing members', diff --git a/ghost/admin/app/components/posts-list/list-item.hbs b/ghost/admin/app/components/posts-list/list-item.hbs index 42f5077b76..25b221eadd 100644 --- a/ghost/admin/app/components/posts-list/list-item.hbs +++ b/ghost/admin/app/components/posts-list/list-item.hbs @@ -45,7 +45,7 @@ {{/unless}} {{else}} - +

{{#if @post.featured}} {{svg-jar "star-fill" class="gh-featured-post"}} @@ -53,15 +53,14 @@ {{@post.title}} {{! Display lexical/mobiledoc indicators for easier testing of the feature --}} - {{#if (feature 'convertToLexical')}} + {{#if (feature 'lexicalIndicators')}} {{#if @post.lexical}} L - {{/if}} - {{#if @post.mobiledoc}} + {{else if @post.mobiledoc}} M {{/if}} {{/if}} - +

{{#unless @hideAuthor }}
{{gh-pluralize this.wordCount "word"}}
- {{#if (feature 'convertToLexical')}} - Lexical - {{/if}} {{svg-jar "help"}} diff --git a/ghost/admin/app/templates/settings/labs.hbs b/ghost/admin/app/templates/settings/labs.hbs index 8818ddacf5..57220edaca 100644 --- a/ghost/admin/app/templates/settings/labs.hbs +++ b/ghost/admin/app/templates/settings/labs.hbs @@ -328,13 +328,13 @@
-

Convert to Lexical

+

Lexical indicators

- Convert mobiledoc posts to lexical upon opening in the editor. + Show L/M indicator on posts list for easier debugging

- +
diff --git a/ghost/admin/tests/acceptance/editor/lexical-test.js b/ghost/admin/tests/acceptance/editor/lexical-test.js index 769ec38f57..663199b77d 100644 --- a/ghost/admin/tests/acceptance/editor/lexical-test.js +++ b/ghost/admin/tests/acceptance/editor/lexical-test.js @@ -70,7 +70,7 @@ describe('Acceptance: Lexical editor', function () { expect(currentURL()).to.equal(`/editor-beta/post/${post.id}`); }); - it('redirects lexical editor to mobiledoc editor when post.mobiledoc is present', async function () { + it('does not redirect to mobiledoc editor when post.mobiledoc is present', async function () { const post = this.server.create('post', { mobiledoc: JSON.stringify(BLANK_DOC) }); @@ -78,6 +78,6 @@ describe('Acceptance: Lexical editor', function () { await loginAsRole('Administrator', this.server); await visit(`/editor-beta/post/${post.id}`); - expect(currentURL()).to.equal(`/editor/post/${post.id}`); + expect(currentURL()).to.equal(`/editor-beta/post/${post.id}`); }); }); diff --git a/ghost/core/core/server/models/post.js b/ghost/core/core/server/models/post.js index 5996ab88af..1d6cebdaf6 100644 --- a/ghost/core/core/server/models/post.js +++ b/ghost/core/core/server/models/post.js @@ -916,7 +916,7 @@ Post = ghostBookshelf.Model.extend({ } // CASE: Convert post to lexical on the fly - if (labs.isSet('convertToLexical') && labs.isSet('lexicalEditor') && options.convert_to_lexical) { + if (labs.isSet('lexicalEditor') && options.convert_to_lexical) { ops.push(async function convertToLexical() { const mobiledoc = model.get('mobiledoc'); const lexical = mobiledocToLexical(mobiledoc); diff --git a/ghost/core/core/shared/labs.js b/ghost/core/core/shared/labs.js index aa57e0dc46..25dd712dea 100644 --- a/ghost/core/core/shared/labs.js +++ b/ghost/core/core/shared/labs.js @@ -42,8 +42,8 @@ const ALPHA_FEATURES = [ 'collectionsCard', 'tipsAndDonations', 'importMemberTier', - 'convertToLexical', - 'recommendations' + 'recommendations', + 'lexicalIndicators' ]; module.exports.GA_KEYS = [...GA_FEATURES];