From 22d07c969219ef322a5124af115e4dc16e6909e3 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Mon, 13 Aug 2018 10:41:01 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Koenig=20-=20Fixed=20pasting=20o?= =?UTF-8?q?f=20rich-text=20image=20captions=20losing=20formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refs https://github.com/TryGhost/Ghost/issues/9724 - caption payload changed from `textContent` to a cleaned `innerHTML` in our `figureToImageCard` parser plugin --- .../admin/lib/koenig-editor/addon/options/parser-plugins.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ghost/admin/lib/koenig-editor/addon/options/parser-plugins.js b/ghost/admin/lib/koenig-editor/addon/options/parser-plugins.js index cd68cc55a9..a85f4de6d0 100644 --- a/ghost/admin/lib/koenig-editor/addon/options/parser-plugins.js +++ b/ghost/admin/lib/koenig-editor/addon/options/parser-plugins.js @@ -1,3 +1,5 @@ +import {cleanBasicHtml} from 'koenig-editor/helpers/clean-basic-html'; + // mobiledoc by default ignores
tags but we have a custom SoftReturn atom export function brToSoftBreakAtom(node, builder, {addMarkerable, nodeFinished}) { if (node.nodeType !== 1 || node.tagName !== 'BR') { @@ -40,8 +42,8 @@ export function figureToImageCard(node, builder, {addSection, nodeFinished}) { }; if (figcaption) { - // TODO: Allow rich text in captions - payload.caption = figcaption.textContent; + let cleanHtml = cleanBasicHtml(figcaption.innerHTML); + payload.caption = cleanHtml; } let cardSection = builder.createCardSection('image', payload);