0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/server/lib/mobiledoc/cards/html.js
Kevin Ansfield fa4e68ba13 Added transformer methods to mobiledoc cards
no issue

- adds abolsute->relative and relative->absolute transformer methods to card definitions
- allows for each card to tailor it's transformation to the specific needs of it's payload so that the `mobiledoc` field can be transformed successfully during API serialization/deserialization
2019-10-07 22:59:19 +01:00

25 lines
784 B
JavaScript

const createCard = require('../create-card');
module.exports = createCard({
name: 'html',
type: 'dom',
render(opts) {
if (!opts.payload.html) {
return '';
}
// use the SimpleDOM document to create a raw HTML section.
// avoids parsing/rendering of potentially broken or unsupported HTML
return opts.env.dom.createRawHTMLSection(opts.payload.html);
},
absoluteToRelative(urlUtils, payload, options) {
payload.html = payload.html && urlUtils.htmlAbsoluteToRelative(payload.html, options);
return payload;
},
relativeToAbsolute(urlUtils, payload, options) {
payload.html = payload.html && urlUtils.htmlRelativeToAbsolute(payload.html, options);
return payload;
}
});