while (node.firstChild) {
listItem.appendChild(node.firstChild);
} // Change pointer depending on indentation level.
receivingNode = receivingNode.lastElementChild || receivingNode; // If it's a list, move pointer to the last item.
if (isList(receivingNode)) {
receivingNode = receivingNode.lastElementChild || receivingNode;
} // Make sure we append to a list.
if (!isList(receivingNode)) {
receivingNode = receivingNode.appendChild(doc.createElement(listType));
} // Append the list item to the list.
receivingNode.appendChild(listItem); // Remove the wrapper paragraph.
node.parentNode.removeChild(node);
// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/list-reducer.js
function list_reducer_isList(node) {
return node.nodeName === 'OL' || node.nodeName === 'UL';
function shallowTextContent(element) {
return Array.from(element.childNodes).map(function (_ref) {
var _ref$nodeValue = _ref.nodeValue,
nodeValue = _ref$nodeValue === void 0 ? '' : _ref$nodeValue;
function listReducer(node) {
if (!list_reducer_isList(node)) {
var 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);
var parentElement = node.parentNode; // Nested list with empty parent item.
if (parentElement && parentElement.nodeName === 'LI' && parentElement.children.length === 1 && !/\S/.test(shallowTextContent(parentElement))) {
var parentListItem = parentElement;
var prevListItem = parentListItem.previousElementSibling;
var parentList = parentListItem.parentNode;
prevListItem.appendChild(list);
parentList.removeChild(parentListItem);
parentList.parentNode.insertBefore(list, parentList);
parentList.parentNode.removeChild(parentList);
} // Invalid: OL/UL > OL/UL.
if (parentElement && list_reducer_isList(parentElement)) {
var _prevListItem = node.previousElementSibling;
_prevListItem.appendChild(node);
Object(external_wp_dom_["unwrap"])(node);
// EXTERNAL MODULE: external ["wp","blob"]
var external_wp_blob_ = __webpack_require__("xTGt");
// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/image-corrector.js
var image_corrector_window = window,
atob = image_corrector_window.atob,
File = image_corrector_window.File;
function imageCorrector(node) {
if (node.nodeName !== 'IMG') {
if (node.src.indexOf('file:') === 0) {
} // This piece cannot be tested outside a browser env.
if (node.src.indexOf('data:') === 0) {
var _node$src$split = node.src.split(','),
_node$src$split2 = Object(slicedToArray["a" /* default */])(_node$src$split, 2),
properties = _node$src$split2[0],
data = _node$src$split2[1];
var _properties$slice$spl = properties.slice(5).split(';'),
_properties$slice$spl2 = Object(slicedToArray["a" /* default */])(_properties$slice$spl, 1),
type = _properties$slice$spl2[0];
var decoded; // Can throw DOMException!
var uint8Array = new Uint8Array(decoded.length);
for (var i = 0; i < uint8Array.length; i++) {
uint8Array[i] = decoded.charCodeAt(i);
var name = type.replace('/', '.');
var file = new File([uint8Array], name, {
node.src = Object(external_wp_blob_["createBlobURL"])(file);
} // Remove trackers and hardly visible images.
if (node.height === 1 || node.width === 1) {
node.parentNode.removeChild(node);
// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/blockquote-normaliser.js
function blockquoteNormaliser(node) {
if (node.nodeName !== 'BLOCKQUOTE') {
node.innerHTML = normaliseBlocks(node.innerHTML);
// 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 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' || Object(external_wp_dom_["isTextContent"])(node)) {
return Object(external_lodash_["has"])(schema, ['figure', 'children', tag]);
* 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 tag = node.nodeName.toLowerCase();
return Object(external_lodash_["has"])(schema, ['figure', 'children', 'a', 'children', tag]);
* 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) {
var beforeElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : element;
var 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)) {
var 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;
var 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);
// EXTERNAL MODULE: external ["wp","shortcode"]
var external_wp_shortcode_ = __webpack_require__("SVSp");
// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/shortcode-converter.js
function shortcode_converter_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 shortcode_converter_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { shortcode_converter_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 { shortcode_converter_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function segmentHTMLToShortcodeBlock(HTML) {
var lastIndex = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var excludedBlockNames = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
var transformsFrom = getBlockTransforms('from');
var transformation = findTransform(transformsFrom, function (transform) {
return excludedBlockNames.indexOf(transform.blockName) === -1 && transform.type === 'shortcode' && Object(external_lodash_["some"])(Object(external_lodash_["castArray"])(transform.tag), function (tag) {
return Object(external_wp_shortcode_["regexp"])(tag).test(HTML);
var transformTags = Object(external_lodash_["castArray"])(transformation.tag);
var transformTag = Object(external_lodash_["find"])(transformTags, function (tag) {
return Object(external_wp_shortcode_["regexp"])(tag).test(HTML);
var previousIndex = lastIndex;
if (match = Object(external_wp_shortcode_["next"])(transformTag, HTML, lastIndex)) {
lastIndex = match.index + match.content.length;
var beforeHTML = HTML.substr(0, match.index);
var 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 (!Object(external_lodash_["includes"])(match.shortcode.content || '', '<') && !(/(\n|<p>)\s*$/.test(beforeHTML) && /^\s*(\n|<\/p>)/.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, [].concat(Object(toConsumableArray["a" /* default */])(excludedBlockNames), [transformation.blockName]));
var attributes = Object(external_lodash_["mapValues"])(Object(external_lodash_["pickBy"])(transformation.attributes, function (schema) {
}), // 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
return schema.shortcode(match.shortcode.attrs, match);
var block = createBlock(transformation.blockName, getBlockAttributes(shortcode_converter_objectSpread(shortcode_converter_objectSpread({}, registration_getBlockType(transformation.blockName)), {}, {
attributes: transformation.attributes
}), match.shortcode.content, attributes));
return [].concat(Object(toConsumableArray["a" /* default */])(segmentHTMLToShortcodeBlock(beforeHTML)), [block], Object(toConsumableArray["a" /* default */])(segmentHTMLToShortcodeBlock(afterHTML)));
/* harmony default export */ var shortcode_converter = (segmentHTMLToShortcodeBlock);
// EXTERNAL MODULE: ./node_modules/showdown/dist/showdown.js
var showdown = __webpack_require__("M55E");
var showdown_default = /*#__PURE__*/__webpack_require__.n(showdown);
// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/markdown-converter.js
// Reuse the same showdown converter.
var converter = new showdown_default.a.Converter({
literalMidWordUnderscores: true,
omitExtraWLInCodeBlocks: true,
* Corrects the Slack Markdown variant of the code block.
* If uncorrected, it will be converted to inline code.
* @see https://get.slack.help/hc/en-us/articles/202288908-how-can-i-add-formatting-to-my-messages-#code-blocks
* @param {string} text The potential Markdown text to correct.
* @return {string} The corrected Markdown.
function slackMarkdownVariantCorrector(text) {
return text.replace(/((?:^|\n)```)([^\n`]+)(```(?:$|\n))/, function (match, p1, p2, p3) {
return "".concat(p1, "\n").concat(p2, "\n").concat(p3);
* Converts a piece of text into HTML based on any Markdown present.
* Also decodes any encoded HTML.
* @param {string} text The plain text to convert.
function markdownConverter(text) {
return converter.makeHtml(slackMarkdownVariantCorrector(text));
// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/iframe-remover.js
* @param {Node} node The node to check.
function iframeRemover(node) {
if (node.nodeName === 'IFRAME') {
var text = node.ownerDocument.createTextNode(node.src);
node.parentNode.replaceChild(text, node);
// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/google-docs-uid-remover.js
function googleDocsUIdRemover(node) {
if (!node.id || node.id.indexOf('docs-internal-guid-') !== 0) {
Object(external_wp_dom_["unwrap"])(node);
// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/utils.js
function raw_handling_utils_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 raw_handling_utils_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { raw_handling_utils_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 { raw_handling_utils_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function getBlockContentSchemaFromTransforms(transforms, context) {
var phrasingContentSchema = Object(external_wp_dom_["getPhrasingContentSchema"])(context);
phrasingContentSchema: phrasingContentSchema,
isPaste: context === 'paste'
var schemas = transforms.map(function (_ref) {
var isMatch = _ref.isMatch,
blockName = _ref.blockName,
var hasAnchorSupport = registration_hasBlockSupport(blockName, 'anchor');
schema = Object(external_lodash_["isFunction"])(schema) ? 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(external_lodash_["mapValues"])(schema, function (value) {
var attributes = value.attributes || []; // If the block supports the "anchor" functionality, it needs to keep its ID attribute.
attributes = [].concat(Object(toConsumableArray["a" /* default */])(attributes), ['id']);
return raw_handling_utils_objectSpread(raw_handling_utils_objectSpread({}, value), {}, {
isMatch: isMatch ? isMatch : undefined
return external_lodash_["mergeWith"].apply(void 0, [{}].concat(Object(toConsumableArray["a" /* default */])(schemas), [function (objValue, srcValue, key) {
if (objValue === '*' || srcValue === '*') {