Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit 1f3d77d

Browse files
committed
šŸ› Koenig - Fixed pasting of rich-text image captions losing formatting
refs TryGhost/Ghost#9724 - caption payload changed from `textContent` to a cleaned `innerHTML` in our `figureToImageCard` parser plugin
1 parent c345019 commit 1f3d77d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

ā€Žlib/koenig-editor/addon/options/parser-plugins.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import {cleanBasicHtml} from 'koenig-editor/helpers/clean-basic-html';
2+
13
// mobiledoc by default ignores <BR> tags but we have a custom SoftReturn atom
24
export function brToSoftBreakAtom(node, builder, {addMarkerable, nodeFinished}) {
35
if (node.nodeType !== 1 || node.tagName !== 'BR') {
@@ -40,8 +42,8 @@ export function figureToImageCard(node, builder, {addSection, nodeFinished}) {
4042
};
4143

4244
if (figcaption) {
43-
// TODO: Allow rich text in captions
44-
payload.caption = figcaption.textContent;
45+
let cleanHtml = cleanBasicHtml(figcaption.innerHTML);
46+
payload.caption = cleanHtml;
4547
}
4648

4749
let cardSection = builder.createCardSection('image', payload);

0 commit comments

Comments
Ā (0)