return raw_handling_utils_objectSpread(raw_handling_utils_objectSpread({}, objValue), srcValue);
return [].concat(Object(toConsumableArray["a" /* default */])(objValue || []), Object(toConsumableArray["a" /* default */])(srcValue || []));
// If one of the values being merge is undefined (matches everything),
// the result of the merge will be undefined.
if (!objValue || !srcValue) {
} // When merging two isMatch functions, the result is a new function
// that returns if one of the source functions returns true.
return objValue.apply(void 0, arguments) || srcValue.apply(void 0, arguments);
* Gets the block content schema, which is extracted and merged from all
* registered blocks with raw transfroms.
* @param {string} context Set to "paste" when in paste context, where the
* @return {Object} A complete block content schema.
function getBlockContentSchema(context) {
return getBlockContentSchemaFromTransforms(getRawTransforms(), context);
* Checks whether HTML can be considered plain text. That is, it does not contain
* any elements that are not line breaks.
* @param {string} HTML The HTML to check.
* @return {boolean} Whether the HTML can be considered plain text.
return !/<(?!br[ />])/i.test(HTML);
* Given node filters, deeply filters and mutates a NodeList.
* @param {NodeList} nodeList The nodeList to filter.
* @param {Array} filters An array of functions that can mutate with the provided node.
* @param {Document} doc The document of the nodeList.
* @param {Object} schema The schema to use.
function deepFilterNodeList(nodeList, filters, doc, schema) {
Array.from(nodeList).forEach(function (node) {
deepFilterNodeList(node.childNodes, filters, doc, schema);
filters.forEach(function (item) {
// Make sure the node is still attached to the document.
if (!doc.contains(node)) {
* Given node filters, deeply filters HTML tags.
* Filters from the deepest nodes to the top.
* @param {string} HTML The HTML to filter.
* @param {Array} filters An array of functions that can mutate with the provided node.
* @param {Object} schema The schema to use.
* @return {string} The filtered HTML.
function deepFilterHTML(HTML) {
var filters = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var schema = arguments.length > 2 ? arguments[2] : undefined;
var doc = document.implementation.createHTMLDocument('');
doc.body.innerHTML = HTML;
deepFilterNodeList(doc.body.childNodes, filters, doc, schema);
return doc.body.innerHTML;
* Gets a sibling within text-level context.
* @param {Element} node The subject node.
* @param {string} which "next" or "previous".
function getSibling(node, which) {
var sibling = node["".concat(which, "Sibling")];
if (sibling && Object(external_wp_dom_["isPhrasingContent"])(sibling)) {
var parentNode = node.parentNode;
if (!parentNode || !Object(external_wp_dom_["isPhrasingContent"])(parentNode)) {
return getSibling(parentNode, which);
// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-formatting-remover.js
function isFormattingSpace(character) {
return character === ' ' || character === '\r' || character === '\n' || character === '\t';
* Removes spacing that formats HTML.
* @see https://www.w3.org/TR/css-text-3/#white-space-processing
* @param {Node} node The node to be processed.
function htmlFormattingRemover(node) {
if (node.nodeType !== node.TEXT_NODE) {
} // Ignore pre content. Note that this does not use Element#closest due to
// a combination of (a) node may not be Element and (b) node.parentElement
// does not have full support in all browsers (Internet Exporer).
// See: https://developer.mozilla.org/en-US/docs/Web/API/Node/parentElement#Browser_compatibility
while (parent = parent.parentNode) {
if (parent.nodeType === parent.ELEMENT_NODE && parent.nodeName === 'PRE') {
} // First, replace any sequence of HTML formatting space with a single space.
var newData = node.data.replace(/[ \r\n\t]+/g, ' '); // Remove the leading space if the text element is at the start of a block,
// is preceded by a line break element, or has a space in the previous
if (newData[0] === ' ') {
var previousSibling = getSibling(node, 'previous');
if (!previousSibling || previousSibling.nodeName === 'BR' || previousSibling.textContent.slice(-1) === ' ') {
newData = newData.slice(1);
} // Remove the trailing space if the text element is at the end of a block,
// is succeded by a line break element, or has a space in the next text
if (newData[newData.length - 1] === ' ') {
var nextSibling = getSibling(node, 'next');
if (!nextSibling || nextSibling.nodeName === 'BR' || nextSibling.nodeType === nextSibling.TEXT_NODE && isFormattingSpace(nextSibling.textContent[0])) {
newData = newData.slice(0, -1);
} // If there's no data left, remove the node, so `previousSibling` stays
// accurate. Otherwise, update the node data.
node.parentNode.removeChild(node);
// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/br-remover.js
* Removes trailing br elements from text-level content.
* @param {Element} node Node to check.
function brRemover(node) {
if (node.nodeName !== 'BR') {
if (getSibling(node, 'next')) {
node.parentNode.removeChild(node);
// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/empty-paragraph-remover.js
* Removes empty paragraph elements.
* @param {Element} node Node to check.
function emptyParagraphRemover(node) {
if (node.nodeName !== 'P') {
if (node.hasChildNodes()) {
node.parentNode.removeChild(node);
// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/paste-handler.js
function paste_handler_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function paste_handler_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { paste_handler_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { paste_handler_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var paste_handler_window = window,
paste_handler_console = paste_handler_window.console;
* Filters HTML to only contain phrasing content.
* @param {string} HTML The HTML to filter.
* @param {boolean} preserveWhiteSpace Whether or not to preserve consequent white space.
* @return {string} HTML only containing phrasing content.
function filterInlineHTML(HTML, preserveWhiteSpace) {
HTML = deepFilterHTML(HTML, [googleDocsUIdRemover, phrasingContentReducer, commentRemover]);
HTML = Object(external_wp_dom_["removeInvalidHTML"])(HTML, Object(external_wp_dom_["getPhrasingContentSchema"])('paste'), {
if (!preserveWhiteSpace) {
HTML = deepFilterHTML(HTML, [htmlFormattingRemover, brRemover]);
} // Allows us to ask for this information when we get a report.
paste_handler_console.log('Processed inline HTML:\n\n', HTML);
* Converts an HTML string to known blocks. Strips everything else.
* @param {Object} options
* @param {string} [options.HTML] The HTML to convert.
* @param {string} [options.plainText] Plain text version.
* @param {string} [options.mode] Handle content as blocks or inline content.
* * 'AUTO': Decide based on the content passed.
* * 'INLINE': Always handle as inline content, and return string.
* * 'BLOCKS': Always handle as blocks, and return array of blocks.
* @param {Array} [options.tagName] The tag into which content will be inserted.
* @param {boolean} [options.preserveWhiteSpace] Whether or not to preserve consequent white space.
* @return {Array|string} A list of blocks or a string, depending on `handlerMode`.
function pasteHandler(_ref) {
var _ref$HTML = _ref.HTML,
HTML = _ref$HTML === void 0 ? '' : _ref$HTML,
_ref$plainText = _ref.plainText,
plainText = _ref$plainText === void 0 ? '' : _ref$plainText,
mode = _ref$mode === void 0 ? 'AUTO' : _ref$mode,
preserveWhiteSpace = _ref.preserveWhiteSpace;
// First of all, strip any meta tags.
HTML = HTML.replace(/<meta[^>]+>/g, ''); // Strip Windows markers.
HTML = HTML.replace(/^\s*<html[^>]*>\s*<body[^>]*>(?:\s*<!--\s*StartFragment\s*-->)?/i, '');
HTML = HTML.replace(/(?:<!--\s*EndFragment\s*-->\s*)?<\/body>\s*<\/html>\s*$/i, ''); // If we detect block delimiters in HTML, parse entirely as blocks.
// Check plain text if there is no HTML.
var content = HTML ? HTML : plainText;
if (content.indexOf('<!-- wp:') !== -1) {
return parseWithGrammar(content);
} // Normalize unicode to use composed characters.
// This is unsupported in IE 11 but it's a nice-to-have feature, not mandatory.
// Not normalizing the content will only affect older browsers and won't
// entirely break the app.
// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
// See: https://core.trac.wordpress.org/ticket/30130
// See: https://github.com/WordPress/gutenberg/pull/6983#pullrequestreview-125151075
if (String.prototype.normalize) {
} // Parse Markdown (and encoded HTML) if:
// * There is a plain text version.
// * There is no HTML version, or it has no formatting.
if (plainText && (!HTML || isPlain(HTML))) {
HTML = markdownConverter(plainText); // Switch to inline mode if:
// * The current mode is AUTO.
// * The original plain text had no line breaks.
// * The original plain text was not an HTML paragraph.
// * The converted text is just a paragraph.
if (mode === 'AUTO' && plainText.indexOf('\n') === -1 && plainText.indexOf('<p>') !== 0 && HTML.indexOf('<p>') === 0) {
return filterInlineHTML(HTML, preserveWhiteSpace);
} // An array of HTML strings and block objects. The blocks replace matched
var pieces = shortcode_converter(HTML); // The call to shortcodeConverter will always return more than one element
// if shortcodes are matched. The reason is when shortcodes are matched
// empty HTML strings are included.
var hasShortcodes = pieces.length > 1;
if (mode === 'AUTO' && !hasShortcodes && isInlineContent(HTML, tagName)) {
return filterInlineHTML(HTML, preserveWhiteSpace);
var phrasingContentSchema = Object(external_wp_dom_["getPhrasingContentSchema"])('paste');
var blockContentSchema = getBlockContentSchema('paste');
var blocks = Object(external_lodash_["compact"])(Object(external_lodash_["flatMap"])(pieces, function (piece) {
// Already a block from shortcode.
if (typeof piece !== 'string') {
var filters = [googleDocsUIdRemover, msListConverter, headRemover, listReducer, imageCorrector, phrasingContentReducer, specialCommentConverter, commentRemover, iframeRemover, figureContentReducer, blockquoteNormaliser];
var schema = paste_handler_objectSpread(paste_handler_objectSpread({}, blockContentSchema), phrasingContentSchema);
piece = deepFilterHTML(piece, filters, blockContentSchema);
piece = Object(external_wp_dom_["removeInvalidHTML"])(piece, schema);
piece = normaliseBlocks(piece);
piece = deepFilterHTML(piece, [htmlFormattingRemover, brRemover, emptyParagraphRemover], blockContentSchema); // Allows us to ask for this information when we get a report.
paste_handler_console.log('Processed HTML piece:\n\n', piece);
return htmlToBlocks(piece);
})); // If we're allowed to return inline content, and there is only one inlineable block,
// and the original plain text content does not have any line breaks, then
// treat it as inline paste.
if (mode === 'AUTO' && blocks.length === 1 && registration_hasBlockSupport(blocks[0].name, '__unstablePasteTextInline', false)) {
var trimmedPlainText = plainText.trim();
if (trimmedPlainText !== '' && trimmedPlainText.indexOf('\n') === -1) {
return Object(external_wp_dom_["removeInvalidHTML"])(getBlockContent(blocks[0]), phrasingContentSchema);
// EXTERNAL MODULE: external ["wp","deprecated"]
var external_wp_deprecated_ = __webpack_require__("NMb1");
var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_);
// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/index.js
function deprecatedGetPhrasingContentSchema(context) {
external_wp_deprecated_default()('wp.blocks.getPhrasingContentSchema', {
alternative: 'wp.dom.getPhrasingContentSchema'
return Object(external_wp_dom_["getPhrasingContentSchema"])(context);
* Converts an HTML string to known blocks.
* @param {string} $1.HTML The HTML to convert.
* @return {Array} A list of blocks.
function rawHandler(_ref) {
var _ref$HTML = _ref.HTML,
HTML = _ref$HTML === void 0 ? '' : _ref$HTML;
// If we detect block delimiters, parse entirely as blocks.
if (HTML.indexOf('<!-- wp:') !== -1) {
return parseWithGrammar(HTML);
} // An array of HTML strings and block objects. The blocks replace matched
var pieces = shortcode_converter(HTML);
var blockContentSchema = getBlockContentSchema();
return Object(external_lodash_["compact"])(Object(external_lodash_["flatMap"])(pieces, function (piece) {
// Already a block from shortcode.
if (typeof piece !== 'string') {
} // These filters are essential for some blocks to be able to transform
// from raw HTML. These filters move around some content or add
// additional tags, they do not remove any content.
var filters = [// Needed to adjust invalid lists.
listReducer, // Needed to create more and nextpage blocks.
specialCommentConverter, // Needed to create media blocks.
figureContentReducer, // Needed to create the quote block, which cannot handle text
// without wrapper paragraphs.
piece = deepFilterHTML(piece, filters, blockContentSchema);
piece = normaliseBlocks(piece);
return htmlToBlocks(piece);
// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/categories.js