From 428e10f147b9f5d343f63d85f8a9943e13b09461 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Mon, 17 Jun 2024 11:43:04 +0100 Subject: [PATCH] Updated data-generator to create lexical rather than mobiledoc posts closes https://linear.app/tryghost/issue/ONC-96 - better matches Ghost's current usage - avoids mismatch in expected data when `post_revisions` is populated in future --- .../lib/importers/PostsImporter.js | 45 ++++++++++++------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/ghost/data-generator/lib/importers/PostsImporter.js b/ghost/data-generator/lib/importers/PostsImporter.js index 81d9453740..1f615a2fdc 100644 --- a/ghost/data-generator/lib/importers/PostsImporter.js +++ b/ghost/data-generator/lib/importers/PostsImporter.js @@ -62,23 +62,34 @@ class PostsImporter extends TableImporter { slug: `${slugify(title)}-${faker.random.numeric(3)}`, status, visibility, - mobiledoc: JSON.stringify({ - version: '0.3.1', - atoms: [], - cards: [], - markups: [['em']], - sections: content.map(paragraph => [ - 1, - 'p', - [ - [ - 0, - [], - 0, - paragraph - ] - ] - ]) + lexical: JSON.stringify({ + root: { + children: content.map(paragraph => ( + { + children: [ + { + detail: 0, + format: 0, + mode: 'normal', + style: '', + text: paragraph, + type: 'extended-text', + version: 1 + } + ], + direction: 'ltr', + format: '', + indent: 0, + type: 'paragraph', + version: 1 + } + )), + direction: 'ltr', + format: '', + indent: 0, + type: 'root', + version: 1 + } }), html: content.map(paragraph => `

${paragraph}

`).join(''), plaintext: content.join('\n\n'),