UNPKG

@wordpress/blocks

Version:
91 lines (87 loc) 1.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "attr", { enumerable: true, get: function () { return _hpq.attr; } }); Object.defineProperty(exports, "children", { enumerable: true, get: function () { return _children.matcher; } }); exports.html = html; Object.defineProperty(exports, "node", { enumerable: true, get: function () { return _node.matcher; } }); Object.defineProperty(exports, "prop", { enumerable: true, get: function () { return _hpq.prop; } }); Object.defineProperty(exports, "query", { enumerable: true, get: function () { return _hpq.query; } }); exports.richText = void 0; Object.defineProperty(exports, "text", { enumerable: true, get: function () { return _hpq.text; } }); var _hpq = require("hpq"); var _richText = require("@wordpress/rich-text"); var _node = require("./node"); var _children = require("./children"); /** * External dependencies */ /** * WordPress dependencies */ /** * Internal dependencies */ function html(selector, multilineTag) { return domNode => { let match = domNode; if (selector) { match = domNode.querySelector(selector); } if (!match) { return ''; } if (multilineTag) { let value = ''; const length = match.children.length; for (let index = 0; index < length; index++) { const child = match.children[index]; if (child.nodeName.toLowerCase() !== multilineTag) { continue; } value += child.outerHTML; } return value; } return match.innerHTML; }; } const richText = (selector, preserveWhiteSpace) => el => { const target = selector ? el.querySelector(selector) : el; return target ? _richText.RichTextData.fromHTMLElement(target, { preserveWhiteSpace }) : _richText.RichTextData.empty(); }; exports.richText = richText; //# sourceMappingURL=matchers.js.map