UNPKG

1.31 kBJavaScriptView Raw
1export var defaultAttrs = {
2 width: { default: null },
3 layout: { default: 'center' },
4};
5export var mediaSingle = {
6 inline: false,
7 group: 'block',
8 selectable: true,
9 atom: true,
10 content: 'media',
11 attrs: defaultAttrs,
12 parseDOM: [
13 {
14 tag: 'div[data-node-type="mediaSingle"]',
15 getAttrs: function (dom) { return ({
16 layout: dom.getAttribute('data-layout') || 'center',
17 width: Number(dom.getAttribute('data-width')) || null,
18 }); },
19 },
20 ],
21 toDOM: function (node) {
22 var _a = node.attrs, layout = _a.layout, width = _a.width;
23 var attrs = {
24 'data-node-type': 'mediaSingle',
25 'data-layout': layout,
26 'data-width': '',
27 };
28 if (width) {
29 attrs['data-width'] =
30 isFinite(width) && Math.floor(width) === width
31 ? width
32 : width.toFixed(2);
33 }
34 return ['div', attrs, 0];
35 },
36};
37export var toJSON = function (node) { return ({
38 attrs: Object.keys(node.attrs).reduce(function (obj, key) {
39 if (node.attrs[key] !== null) {
40 obj[key] = node.attrs[key];
41 }
42 return obj;
43 }, {}),
44}); };
45//# sourceMappingURL=media-single.js.map
\No newline at end of file