UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

58 lines 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var isHeaderRow = function (row) { return row.child(0).type.name === 'tableHeader'; }; var isHeaderRowPresent = function (table) { var headerRowPresent = false; table.content.forEach(function (row, i) { if (isHeaderRow(row)) { headerRowPresent = true; } }); return headerRowPresent; }; var renderNode = function (state, node, index) { if (index > 0) { state.write(' '); } node.content.forEach(function (child, i) { if (child.isTextblock) { if (i > 0) { state.write(' '); } state.renderInline(child); } else { renderNode(state, child, i); } }); }; var renderInlineContent = function (state, node) { state.write('| '); renderNode(state, node, 0); state.write(' '); }; exports.default = { table: function (state, node) { if (isHeaderRowPresent(node)) { node.content.forEach(function (child, i) { return state.render(child, node, i); }); state.closeBlock(node); } }, tableRow: function (state, node) { node.content.forEach(function (child, i) { state.render(child, node, i); }); state.write('|'); state.ensureNewLine(); if (isHeaderRow(node)) { for (var i = 0; i < node.childCount; i++) { state.write('| --- '); } state.write('|'); state.ensureNewLine(); } }, tableHeader: renderInlineContent, tableCell: renderInlineContent, }; //# sourceMappingURL=tableSerializer.js.map