0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
ghost/core/server/lib/mobiledoc/cards/embed.js
Kevin Ansfield 0c06a47b9b Koenig - Added rich-text caption support
refs https://github.com/TryGhost/Ghost/issues/9724
- captions can have HTML so we need to render as HTML rather than as a text node so special chars don't get escaped
2018-08-08 14:29:20 +01:00

25 lines
644 B
JavaScript

module.exports = {
name: 'embed',
type: 'dom',
render(opts) {
if (!opts.payload.html) {
return '';
}
let {payload, env: {dom}} = opts;
let figure = dom.createElement('figure');
figure.setAttribute('class', 'kg-embed-card');
let html = dom.createRawHTMLSection(payload.html);
figure.appendChild(html);
if (payload.caption) {
let figcaption = dom.createElement('figcaption');
figcaption.appendChild(dom.createRawHTMLSection(payload.caption));
figure.appendChild(figcaption);
}
return figure;
}
};