mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
Koenig - Grab image caption from <img><figcaption> when pasting
refs https://github.com/TryGhost/Ghost/issues/9623 - workaround to grab a `<figcaption>` for use in an image card in some cases - will only work when an `<img>` tag is immediately followed by a `<figcaption>` tag in the parsed html
This commit is contained in:
parent
631edbe60a
commit
ac870e43bd
@ -27,6 +27,16 @@ export function imgToCard(node, builder, {addSection, nodeFinished}) {
|
||||
}
|
||||
|
||||
let payload = {src: node.src};
|
||||
|
||||
// TODO: this is a workaround for grabbing a figure>img+figcaption until
|
||||
// https://github.com/bustle/mobiledoc-kit/issues/494 is resolved
|
||||
// NOTE: it will only work in a strict <figure><img><figcaption></figure> case
|
||||
let nextSibling = node.nextSibling;
|
||||
if (nextSibling && nextSibling.tagName === 'FIGCAPTION') {
|
||||
payload.caption = nextSibling.textContent;
|
||||
node.parentNode.removeChild(nextSibling);
|
||||
}
|
||||
|
||||
let cardSection = builder.createCardSection('image', payload);
|
||||
addSection(cardSection);
|
||||
nodeFinished();
|
||||
|
Loading…
Reference in New Issue
Block a user