: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
function createNextpage(doc) {
const node = doc.createElement('wp-block');
node.dataset.block = 'core/nextpage';
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/list-reducer.js
return node.nodeName === 'OL' || node.nodeName === 'UL';
function shallowTextContent(element) {
return Array.from(element.childNodes).map(({
}) => nodeValue).join('');
function listReducer(node) {
const prevElement = node.previousElementSibling;
// Merge with previous list if:
// * There is a previous list of the same type.
// * There is only one list item.
if (prevElement && prevElement.nodeName === node.nodeName && list.children.length === 1) {
// Move all child nodes, including any text nodes, if any.
while (list.firstChild) {
prevElement.appendChild(list.firstChild);
list.parentNode.removeChild(list);
const parentElement = node.parentNode;
// Nested list with empty parent item.
if (parentElement && parentElement.nodeName === 'LI' && parentElement.children.length === 1 && !/\S/.test(shallowTextContent(parentElement))) {
const parentListItem = parentElement;
const prevListItem = parentListItem.previousElementSibling;
const parentList = parentListItem.parentNode;
prevListItem.appendChild(list);
parentList.removeChild(parentListItem);
// Invalid: OL/UL > OL/UL.
if (parentElement && isList(parentElement)) {
const prevListItem = node.previousElementSibling;
prevListItem.appendChild(node);
(0,external_wp_dom_namespaceObject.unwrap)(node);
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/blockquote-normaliser.js
function blockquoteNormaliser(options) {
if (node.nodeName !== 'BLOCKQUOTE') {
node.innerHTML = normaliseBlocks(node.innerHTML, options);
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/figure-content-reducer.js
* Whether or not the given node is figure content.
* @param {Node} node The node to check.
* @param {Object} schema The schema to use.
* @return {boolean} True if figure content, false if not.
function isFigureContent(node, schema) {
var _schema$figure$childr;
const tag = node.nodeName.toLowerCase();
// We are looking for tags that can be a child of the figure tag, excluding
// `figcaption` and any phrasing content.
if (tag === 'figcaption' || (0,external_wp_dom_namespaceObject.isTextContent)(node)) {
return tag in ((_schema$figure$childr = schema?.figure?.children) !== null && _schema$figure$childr !== void 0 ? _schema$figure$childr : {});
* Whether or not the given node can have an anchor.
* @param {Node} node The node to check.
* @param {Object} schema The schema to use.
* @return {boolean} True if it can, false if not.
function canHaveAnchor(node, schema) {
var _schema$figure$childr2;
const tag = node.nodeName.toLowerCase();
return tag in ((_schema$figure$childr2 = schema?.figure?.children?.a?.children) !== null && _schema$figure$childr2 !== void 0 ? _schema$figure$childr2 : {});
* Wraps the given element in a figure element.
* @param {Element} element The element to wrap.
* @param {Element} beforeElement The element before which to place the figure.
function wrapFigureContent(element, beforeElement = element) {
const figure = element.ownerDocument.createElement('figure');
beforeElement.parentNode.insertBefore(figure, beforeElement);
figure.appendChild(element);
* This filter takes figure content out of paragraphs, wraps it in a figure
* element, and moves any anchors with it if needed.
* @param {Node} node The node to filter.
* @param {Document} doc The document of the node.
* @param {Object} schema The schema to use.
function figureContentReducer(node, doc, schema) {
if (!isFigureContent(node, schema)) {
const parentNode = node.parentNode;
// If the figure content can have an anchor and its parent is an anchor with
// only the figure content, take the anchor out instead of just the content.
if (canHaveAnchor(node, schema) && parentNode.nodeName === 'A' && parentNode.childNodes.length === 1) {
nodeToInsert = node.parentNode;
const wrapper = nodeToInsert.closest('p,div');
// If wrapped in a paragraph or div, only extract if it's aligned or if
// there is no text content.
// Otherwise, if directly at the root, wrap in a figure element.
// In jsdom-jscore, 'node.classList' can be undefined.
// In this case, default to extract as it offers a better UI experience on mobile.
wrapFigureContent(nodeToInsert, wrapper);
} else if (node.classList.contains('alignright') || node.classList.contains('alignleft') || node.classList.contains('aligncenter') || !wrapper.textContent.trim()) {
wrapFigureContent(nodeToInsert, wrapper);
} else if (nodeToInsert.parentNode.nodeName === 'BODY') {
wrapFigureContent(nodeToInsert);
;// CONCATENATED MODULE: external ["wp","shortcode"]
const external_wp_shortcode_namespaceObject = window["wp"]["shortcode"];
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/shortcode-converter.js
const castArray = maybeArray => Array.isArray(maybeArray) ? maybeArray : [maybeArray];
const beforeLineRegexp = /(\n|<p>)\s*$/;
const afterLineRegexp = /^\s*(\n|<\/p>)/;
function segmentHTMLToShortcodeBlock(HTML, lastIndex = 0, excludedBlockNames = []) {
const transformsFrom = getBlockTransforms('from');
const transformation = findTransform(transformsFrom, transform => excludedBlockNames.indexOf(transform.blockName) === -1 && transform.type === 'shortcode' && castArray(transform.tag).some(tag => (0,external_wp_shortcode_namespaceObject.regexp)(tag).test(HTML)));
const transformTags = castArray(transformation.tag);
const transformTag = transformTags.find(tag => (0,external_wp_shortcode_namespaceObject.regexp)(tag).test(HTML));
const previousIndex = lastIndex;
if (match = (0,external_wp_shortcode_namespaceObject.next)(transformTag, HTML, lastIndex)) {
lastIndex = match.index + match.content.length;
const beforeHTML = HTML.substr(0, match.index);
const afterHTML = HTML.substr(lastIndex);
// If the shortcode content does not contain HTML and the shortcode is
// not on a new line (or in paragraph from Markdown converter),
// consider the shortcode as inline text, and thus skip conversion for
if (!match.shortcode.content?.includes('<') && !(beforeLineRegexp.test(beforeHTML) && afterLineRegexp.test(afterHTML))) {
return segmentHTMLToShortcodeBlock(HTML, lastIndex);
// If a transformation's `isMatch` predicate fails for the inbound
// shortcode, try again by excluding the current block type.
// This is the only call to `segmentHTMLToShortcodeBlock` that should
// ever carry over `excludedBlockNames`. Other calls in the module
// should skip that argument as a way to reset the exclusion state, so
// that one `isMatch` fail in an HTML fragment doesn't prevent any
// valid matches in subsequent fragments.
if (transformation.isMatch && !transformation.isMatch(match.shortcode.attrs)) {
return segmentHTMLToShortcodeBlock(HTML, previousIndex, [...excludedBlockNames, transformation.blockName]);
if (typeof transformation.transform === 'function') {
// Passing all of `match` as second argument is intentionally broad
// but shouldn't be too relied upon.
// See: https://github.com/WordPress/gutenberg/pull/3610#discussion_r152546926
blocks = [].concat(transformation.transform(match.shortcode.attrs, match));
// Applying the built-in fixes can enhance the attributes with missing content like "className".
blocks = blocks.map(block => {
block.originalContent = match.shortcode.content;
return applyBuiltInValidationFixes(block, getBlockType(block.name));
const attributes = Object.fromEntries(Object.entries(transformation.attributes).filter(([, schema]) => schema.shortcode)
// Passing all of `match` as second argument is intentionally broad
// but shouldn't be too relied upon.
// See: https://github.com/WordPress/gutenberg/pull/3610#discussion_r152546926
.map(([key, schema]) => [key, schema.shortcode(match.shortcode.attrs, match)]));
const blockType = getBlockType(transformation.blockName);
const transformationBlockType = {
attributes: transformation.attributes
let block = createBlock(transformation.blockName, getBlockAttributes(transformationBlockType, match.shortcode.content, attributes));
// Applying the built-in fixes can enhance the attributes with missing content like "className".
block.originalContent = match.shortcode.content;
block = applyBuiltInValidationFixes(block, transformationBlockType);
return [...segmentHTMLToShortcodeBlock(beforeHTML.replace(beforeLineRegexp, '')), ...blocks, ...segmentHTMLToShortcodeBlock(afterHTML.replace(afterLineRegexp, ''))];
/* harmony default export */ const shortcode_converter = (segmentHTMLToShortcodeBlock);
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/utils.js
function getBlockContentSchemaFromTransforms(transforms, context) {
const phrasingContentSchema = (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)(context);
isPaste: context === 'paste'
const schemas = transforms.map(({
const hasAnchorSupport = hasBlockSupport(blockName, 'anchor');
schema = typeof schema === 'function' ? schema(schemaArgs) : schema;
// If the block does not has anchor support and the transform does not
// provides an isMatch we can return the schema right away.
if (!hasAnchorSupport && !isMatch) {
return Object.fromEntries(Object.entries(schema).map(([key, value]) => {
let attributes = value.attributes || [];
// If the block supports the "anchor" functionality, it needs to keep its ID attribute.
attributes = [...attributes, 'id'];
isMatch: isMatch ? isMatch : undefined
function mergeTagNameSchemaProperties(objValue, srcValue, key) {
if (objValue === '*' || srcValue === '*') {
return [...(objValue || []), ...(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(...args) || srcValue(...args);
// A tagName schema is an object with children, attributes, require, and
function mergeTagNameSchemas(a, b) {
a[key] = a[key] ? mergeTagNameSchemaProperties(a[key], b[key], key) : {
// A schema is an object with tagName schemas by tag name.
function mergeSchemas(a, b) {
a[key] = a[key] ? mergeTagNameSchemas(a[key], b[key]) : {
return schemas.reduce(mergeSchemas, {});
* 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(node => {
deepFilterNodeList(node.childNodes, filters, doc, schema);
filters.forEach(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, filters = [], schema) {
const 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) {
const sibling = node[`${which}Sibling`];
if (sibling && (0,external_wp_dom_namespaceObject.isPhrasingContent)(sibling)) {
if (!parentNode || !(0,external_wp_dom_namespaceObject.isPhrasingContent)(parentNode)) {
return getSibling(parentNode, which);
;// 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 (0,external_wp_dom_namespaceObject.getPhrasingContentSchema)(context);
* Converts an HTML string to known blocks.
* @param {string} $1.HTML The HTML to convert.
* @return {Array} A list of blocks.
// If we detect block delimiters, parse entirely as blocks.
if (HTML.indexOf('<!-- wp:') !== -1) {
const parseResult = parser_parse(HTML);
const isSingleFreeFormBlock = parseResult.length === 1 && parseResult[0].name === 'core/freeform';
if (!isSingleFreeFormBlock) {
// An array of HTML strings and block objects. The blocks replace matched
const pieces = shortcode_converter(HTML);
const blockContentSchema = getBlockContentSchema();