From c9dc56841badbd2b755184f97f8c1c4a71a4b25a Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Wed, 17 Feb 2021 15:29:31 +0000 Subject: [PATCH] Added === text expansion for paywall card refs https://github.com/TryGhost/Team/issues/466 --- .../addon/options/text-expansions.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ghost/admin/lib/koenig-editor/addon/options/text-expansions.js b/ghost/admin/lib/koenig-editor/addon/options/text-expansions.js index 35783c6e17..273b7d4212 100644 --- a/ghost/admin/lib/koenig-editor/addon/options/text-expansions.js +++ b/ghost/admin/lib/koenig-editor/addon/options/text-expansions.js @@ -449,6 +449,28 @@ export default function (mobiledocEditor, koenig) { } }); + /* non-markdown expansions -----------------------------------------------*/ + + mobiledocEditor.onTextInput({ + name: 'paywall', + match: /^===$/, + run(editor) { + let {range: {head, head: {section}}} = editor; + + // Skip if cursor is not at end of section + if (!head.isTail()) { + return; + } + + // Skip if section is a list item + if (section.isListItem) { + return; + } + + koenig.send('replaceWithCardSection', 'paywall', section.toRange()); + } + }); + /* inline markdown -------------------------------------------------------*/ // must come after block expansions so that the smart hyphens expansion