UNPKG

@wordpress/blocks

Version:
48 lines (46 loc) 1.85 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // packages/blocks/src/api/parser/serialize-raw-block.js var serialize_raw_block_exports = {}; __export(serialize_raw_block_exports, { serializeRawBlock: () => serializeRawBlock }); module.exports = __toCommonJS(serialize_raw_block_exports); var import_serializer = require("../serializer"); function serializeRawBlock(rawBlock, options = {}) { const { isCommentDelimited = true } = options; const { blockName, attrs = {}, innerBlocks = [], innerContent = [] } = rawBlock; let childIndex = 0; const content = innerContent.map( (item) => ( // `null` denotes a nested block, otherwise we have an HTML fragment. item !== null ? item : serializeRawBlock(innerBlocks[childIndex++], options) ) ).join("\n").replace(/\n+/g, "\n").trim(); return isCommentDelimited ? (0, import_serializer.getCommentDelimitedContent)(blockName, attrs, content) : content; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { serializeRawBlock }); //# sourceMappingURL=serialize-raw-block.js.map