Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../js/dist
File: blocks.js
[13500] Fix | Delete
[13501] Fix | Delete
[13502] Fix | Delete
/**
[13503] Fix | Delete
* Internal dependencies
[13504] Fix | Delete
*/
[13505] Fix | Delete
[13506] Fix | Delete
[13507] Fix | Delete
[13508] Fix | Delete
[13509] Fix | Delete
[13510] Fix | Delete
[13511] Fix | Delete
[13512] Fix | Delete
[13513] Fix | Delete
[13514] Fix | Delete
[13515] Fix | Delete
/**
[13516] Fix | Delete
* The raw structure of a block includes its attributes, inner
[13517] Fix | Delete
* blocks, and inner HTML. It is important to distinguish inner blocks from
[13518] Fix | Delete
* the HTML content of the block as only the latter is relevant for block
[13519] Fix | Delete
* validation and edit operations.
[13520] Fix | Delete
*
[13521] Fix | Delete
* @typedef WPRawBlock
[13522] Fix | Delete
*
[13523] Fix | Delete
* @property {string=} blockName Block name
[13524] Fix | Delete
* @property {Object=} attrs Block raw or comment attributes.
[13525] Fix | Delete
* @property {string} innerHTML HTML content of the block.
[13526] Fix | Delete
* @property {(string|null)[]} innerContent Content without inner blocks.
[13527] Fix | Delete
* @property {WPRawBlock[]} innerBlocks Inner Blocks.
[13528] Fix | Delete
*/
[13529] Fix | Delete
[13530] Fix | Delete
/**
[13531] Fix | Delete
* Fully parsed block object.
[13532] Fix | Delete
*
[13533] Fix | Delete
* @typedef WPBlock
[13534] Fix | Delete
*
[13535] Fix | Delete
* @property {string} name Block name
[13536] Fix | Delete
* @property {Object} attributes Block raw or comment attributes.
[13537] Fix | Delete
* @property {WPBlock[]} innerBlocks Inner Blocks.
[13538] Fix | Delete
* @property {string} originalContent Original content of the block before validation fixes.
[13539] Fix | Delete
* @property {boolean} isValid Whether the block is valid.
[13540] Fix | Delete
* @property {Object[]} validationIssues Validation issues.
[13541] Fix | Delete
* @property {WPRawBlock} [__unstableBlockSource] Un-processed original copy of block if created through parser.
[13542] Fix | Delete
*/
[13543] Fix | Delete
[13544] Fix | Delete
/**
[13545] Fix | Delete
* @typedef {Object} ParseOptions
[13546] Fix | Delete
* @property {boolean?} __unstableSkipMigrationLogs If a block is migrated from a deprecated version, skip logging the migration details.
[13547] Fix | Delete
* @property {boolean?} __unstableSkipAutop Whether to skip autop when processing freeform content.
[13548] Fix | Delete
*/
[13549] Fix | Delete
[13550] Fix | Delete
/**
[13551] Fix | Delete
* Convert legacy blocks to their canonical form. This function is used
[13552] Fix | Delete
* both in the parser level for previous content and to convert such blocks
[13553] Fix | Delete
* used in Custom Post Types templates.
[13554] Fix | Delete
*
[13555] Fix | Delete
* @param {WPRawBlock} rawBlock
[13556] Fix | Delete
*
[13557] Fix | Delete
* @return {WPRawBlock} The block's name and attributes, changed accordingly if a match was found
[13558] Fix | Delete
*/
[13559] Fix | Delete
function convertLegacyBlocks(rawBlock) {
[13560] Fix | Delete
const [correctName, correctedAttributes] = convertLegacyBlockNameAndAttributes(rawBlock.blockName, rawBlock.attrs);
[13561] Fix | Delete
return {
[13562] Fix | Delete
...rawBlock,
[13563] Fix | Delete
blockName: correctName,
[13564] Fix | Delete
attrs: correctedAttributes
[13565] Fix | Delete
};
[13566] Fix | Delete
}
[13567] Fix | Delete
[13568] Fix | Delete
/**
[13569] Fix | Delete
* Normalize the raw block by applying the fallback block name if none given,
[13570] Fix | Delete
* sanitize the parsed HTML...
[13571] Fix | Delete
*
[13572] Fix | Delete
* @param {WPRawBlock} rawBlock The raw block object.
[13573] Fix | Delete
* @param {ParseOptions?} options Extra options for handling block parsing.
[13574] Fix | Delete
*
[13575] Fix | Delete
* @return {WPRawBlock} The normalized block object.
[13576] Fix | Delete
*/
[13577] Fix | Delete
function normalizeRawBlock(rawBlock, options) {
[13578] Fix | Delete
const fallbackBlockName = getFreeformContentHandlerName();
[13579] Fix | Delete
[13580] Fix | Delete
// If the grammar parsing don't produce any block name, use the freeform block.
[13581] Fix | Delete
const rawBlockName = rawBlock.blockName || getFreeformContentHandlerName();
[13582] Fix | Delete
const rawAttributes = rawBlock.attrs || {};
[13583] Fix | Delete
const rawInnerBlocks = rawBlock.innerBlocks || [];
[13584] Fix | Delete
let rawInnerHTML = rawBlock.innerHTML.trim();
[13585] Fix | Delete
[13586] Fix | Delete
// Fallback content may be upgraded from classic content expecting implicit
[13587] Fix | Delete
// automatic paragraphs, so preserve them. Assumes wpautop is idempotent,
[13588] Fix | Delete
// meaning there are no negative consequences to repeated autop calls.
[13589] Fix | Delete
if (rawBlockName === fallbackBlockName && rawBlockName === 'core/freeform' && !options?.__unstableSkipAutop) {
[13590] Fix | Delete
rawInnerHTML = (0,external_wp_autop_namespaceObject.autop)(rawInnerHTML).trim();
[13591] Fix | Delete
}
[13592] Fix | Delete
return {
[13593] Fix | Delete
...rawBlock,
[13594] Fix | Delete
blockName: rawBlockName,
[13595] Fix | Delete
attrs: rawAttributes,
[13596] Fix | Delete
innerHTML: rawInnerHTML,
[13597] Fix | Delete
innerBlocks: rawInnerBlocks
[13598] Fix | Delete
};
[13599] Fix | Delete
}
[13600] Fix | Delete
[13601] Fix | Delete
/**
[13602] Fix | Delete
* Uses the "unregistered blockType" to create a block object.
[13603] Fix | Delete
*
[13604] Fix | Delete
* @param {WPRawBlock} rawBlock block.
[13605] Fix | Delete
*
[13606] Fix | Delete
* @return {WPRawBlock} The unregistered block object.
[13607] Fix | Delete
*/
[13608] Fix | Delete
function createMissingBlockType(rawBlock) {
[13609] Fix | Delete
const unregisteredFallbackBlock = getUnregisteredTypeHandlerName() || getFreeformContentHandlerName();
[13610] Fix | Delete
[13611] Fix | Delete
// Preserve undelimited content for use by the unregistered type
[13612] Fix | Delete
// handler. A block node's `innerHTML` isn't enough, as that field only
[13613] Fix | Delete
// carries the block's own HTML and not its nested blocks.
[13614] Fix | Delete
const originalUndelimitedContent = serializeRawBlock(rawBlock, {
[13615] Fix | Delete
isCommentDelimited: false
[13616] Fix | Delete
});
[13617] Fix | Delete
[13618] Fix | Delete
// Preserve full block content for use by the unregistered type
[13619] Fix | Delete
// handler, block boundaries included.
[13620] Fix | Delete
const originalContent = serializeRawBlock(rawBlock, {
[13621] Fix | Delete
isCommentDelimited: true
[13622] Fix | Delete
});
[13623] Fix | Delete
return {
[13624] Fix | Delete
blockName: unregisteredFallbackBlock,
[13625] Fix | Delete
attrs: {
[13626] Fix | Delete
originalName: rawBlock.blockName,
[13627] Fix | Delete
originalContent,
[13628] Fix | Delete
originalUndelimitedContent
[13629] Fix | Delete
},
[13630] Fix | Delete
innerHTML: rawBlock.blockName ? originalContent : rawBlock.innerHTML,
[13631] Fix | Delete
innerBlocks: rawBlock.innerBlocks,
[13632] Fix | Delete
innerContent: rawBlock.innerContent
[13633] Fix | Delete
};
[13634] Fix | Delete
}
[13635] Fix | Delete
[13636] Fix | Delete
/**
[13637] Fix | Delete
* Validates a block and wraps with validation meta.
[13638] Fix | Delete
*
[13639] Fix | Delete
* The name here is regrettable but `validateBlock` is already taken.
[13640] Fix | Delete
*
[13641] Fix | Delete
* @param {WPBlock} unvalidatedBlock
[13642] Fix | Delete
* @param {import('../registration').WPBlockType} blockType
[13643] Fix | Delete
* @return {WPBlock} validated block, with auto-fixes if initially invalid
[13644] Fix | Delete
*/
[13645] Fix | Delete
function applyBlockValidation(unvalidatedBlock, blockType) {
[13646] Fix | Delete
// Attempt to validate the block.
[13647] Fix | Delete
const [isValid] = validateBlock(unvalidatedBlock, blockType);
[13648] Fix | Delete
if (isValid) {
[13649] Fix | Delete
return {
[13650] Fix | Delete
...unvalidatedBlock,
[13651] Fix | Delete
isValid,
[13652] Fix | Delete
validationIssues: []
[13653] Fix | Delete
};
[13654] Fix | Delete
}
[13655] Fix | Delete
[13656] Fix | Delete
// If the block is invalid, attempt some built-in fixes
[13657] Fix | Delete
// like custom classNames handling.
[13658] Fix | Delete
const fixedBlock = applyBuiltInValidationFixes(unvalidatedBlock, blockType);
[13659] Fix | Delete
// Attempt to validate the block once again after the built-in fixes.
[13660] Fix | Delete
const [isFixedValid, validationIssues] = validateBlock(unvalidatedBlock, blockType);
[13661] Fix | Delete
return {
[13662] Fix | Delete
...fixedBlock,
[13663] Fix | Delete
isValid: isFixedValid,
[13664] Fix | Delete
validationIssues
[13665] Fix | Delete
};
[13666] Fix | Delete
}
[13667] Fix | Delete
[13668] Fix | Delete
/**
[13669] Fix | Delete
* Given a raw block returned by grammar parsing, returns a fully parsed block.
[13670] Fix | Delete
*
[13671] Fix | Delete
* @param {WPRawBlock} rawBlock The raw block object.
[13672] Fix | Delete
* @param {ParseOptions} options Extra options for handling block parsing.
[13673] Fix | Delete
*
[13674] Fix | Delete
* @return {WPBlock | undefined} Fully parsed block.
[13675] Fix | Delete
*/
[13676] Fix | Delete
function parseRawBlock(rawBlock, options) {
[13677] Fix | Delete
let normalizedBlock = normalizeRawBlock(rawBlock, options);
[13678] Fix | Delete
[13679] Fix | Delete
// During the lifecycle of the project, we renamed some old blocks
[13680] Fix | Delete
// and transformed others to new blocks. To avoid breaking existing content,
[13681] Fix | Delete
// we added this function to properly parse the old content.
[13682] Fix | Delete
normalizedBlock = convertLegacyBlocks(normalizedBlock);
[13683] Fix | Delete
[13684] Fix | Delete
// Try finding the type for known block name.
[13685] Fix | Delete
let blockType = getBlockType(normalizedBlock.blockName);
[13686] Fix | Delete
[13687] Fix | Delete
// If not blockType is found for the specified name, fallback to the "unregistedBlockType".
[13688] Fix | Delete
if (!blockType) {
[13689] Fix | Delete
normalizedBlock = createMissingBlockType(normalizedBlock);
[13690] Fix | Delete
blockType = getBlockType(normalizedBlock.blockName);
[13691] Fix | Delete
}
[13692] Fix | Delete
[13693] Fix | Delete
// If it's an empty freeform block or there's no blockType (no missing block handler)
[13694] Fix | Delete
// Then, just ignore the block.
[13695] Fix | Delete
// It might be a good idea to throw a warning here.
[13696] Fix | Delete
// TODO: I'm unsure about the unregisteredFallbackBlock check,
[13697] Fix | Delete
// it might ignore some dynamic unregistered third party blocks wrongly.
[13698] Fix | Delete
const isFallbackBlock = normalizedBlock.blockName === getFreeformContentHandlerName() || normalizedBlock.blockName === getUnregisteredTypeHandlerName();
[13699] Fix | Delete
if (!blockType || !normalizedBlock.innerHTML && isFallbackBlock) {
[13700] Fix | Delete
return;
[13701] Fix | Delete
}
[13702] Fix | Delete
[13703] Fix | Delete
// Parse inner blocks recursively.
[13704] Fix | Delete
const parsedInnerBlocks = normalizedBlock.innerBlocks.map(innerBlock => parseRawBlock(innerBlock, options))
[13705] Fix | Delete
// See https://github.com/WordPress/gutenberg/pull/17164.
[13706] Fix | Delete
.filter(innerBlock => !!innerBlock);
[13707] Fix | Delete
[13708] Fix | Delete
// Get the fully parsed block.
[13709] Fix | Delete
const parsedBlock = createBlock(normalizedBlock.blockName, getBlockAttributes(blockType, normalizedBlock.innerHTML, normalizedBlock.attrs), parsedInnerBlocks);
[13710] Fix | Delete
parsedBlock.originalContent = normalizedBlock.innerHTML;
[13711] Fix | Delete
const validatedBlock = applyBlockValidation(parsedBlock, blockType);
[13712] Fix | Delete
const {
[13713] Fix | Delete
validationIssues
[13714] Fix | Delete
} = validatedBlock;
[13715] Fix | Delete
[13716] Fix | Delete
// Run the block deprecation and migrations.
[13717] Fix | Delete
// This is performed on both invalid and valid blocks because
[13718] Fix | Delete
// migration using the `migrate` functions should run even
[13719] Fix | Delete
// if the output is deemed valid.
[13720] Fix | Delete
const updatedBlock = applyBlockDeprecatedVersions(validatedBlock, normalizedBlock, blockType);
[13721] Fix | Delete
if (!updatedBlock.isValid) {
[13722] Fix | Delete
// Preserve the original unprocessed version of the block
[13723] Fix | Delete
// that we received (no fixes, no deprecations) so that
[13724] Fix | Delete
// we can save it as close to exactly the same way as
[13725] Fix | Delete
// we loaded it. This is important to avoid corruption
[13726] Fix | Delete
// and data loss caused by block implementations trying
[13727] Fix | Delete
// to process data that isn't fully recognized.
[13728] Fix | Delete
updatedBlock.__unstableBlockSource = rawBlock;
[13729] Fix | Delete
}
[13730] Fix | Delete
if (!validatedBlock.isValid && updatedBlock.isValid && !options?.__unstableSkipMigrationLogs) {
[13731] Fix | Delete
/* eslint-disable no-console */
[13732] Fix | Delete
console.groupCollapsed('Updated Block: %s', blockType.name);
[13733] Fix | Delete
console.info('Block successfully updated for `%s` (%o).\n\nNew content generated by `save` function:\n\n%s\n\nContent retrieved from post body:\n\n%s', blockType.name, blockType, getSaveContent(blockType, updatedBlock.attributes), updatedBlock.originalContent);
[13734] Fix | Delete
console.groupEnd();
[13735] Fix | Delete
/* eslint-enable no-console */
[13736] Fix | Delete
} else if (!validatedBlock.isValid && !updatedBlock.isValid) {
[13737] Fix | Delete
validationIssues.forEach(({
[13738] Fix | Delete
log,
[13739] Fix | Delete
args
[13740] Fix | Delete
}) => log(...args));
[13741] Fix | Delete
}
[13742] Fix | Delete
return updatedBlock;
[13743] Fix | Delete
}
[13744] Fix | Delete
[13745] Fix | Delete
/**
[13746] Fix | Delete
* Utilizes an optimized token-driven parser based on the Gutenberg grammar spec
[13747] Fix | Delete
* defined through a parsing expression grammar to take advantage of the regular
[13748] Fix | Delete
* cadence provided by block delimiters -- composed syntactically through HTML
[13749] Fix | Delete
* comments -- which, given a general HTML document as an input, returns a block
[13750] Fix | Delete
* list array representation.
[13751] Fix | Delete
*
[13752] Fix | Delete
* This is a recursive-descent parser that scans linearly once through the input
[13753] Fix | Delete
* document. Instead of directly recursing it utilizes a trampoline mechanism to
[13754] Fix | Delete
* prevent stack overflow. This initial pass is mainly interested in separating
[13755] Fix | Delete
* and isolating the blocks serialized in the document and manifestly not in the
[13756] Fix | Delete
* content within the blocks.
[13757] Fix | Delete
*
[13758] Fix | Delete
* @see
[13759] Fix | Delete
* https://developer.wordpress.org/block-editor/packages/packages-block-serialization-default-parser/
[13760] Fix | Delete
*
[13761] Fix | Delete
* @param {string} content The post content.
[13762] Fix | Delete
* @param {ParseOptions} options Extra options for handling block parsing.
[13763] Fix | Delete
*
[13764] Fix | Delete
* @return {Array} Block list.
[13765] Fix | Delete
*/
[13766] Fix | Delete
function parser_parse(content, options) {
[13767] Fix | Delete
return (0,external_wp_blockSerializationDefaultParser_namespaceObject.parse)(content).reduce((accumulator, rawBlock) => {
[13768] Fix | Delete
const block = parseRawBlock(rawBlock, options);
[13769] Fix | Delete
if (block) {
[13770] Fix | Delete
accumulator.push(block);
[13771] Fix | Delete
}
[13772] Fix | Delete
return accumulator;
[13773] Fix | Delete
}, []);
[13774] Fix | Delete
}
[13775] Fix | Delete
[13776] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/get-raw-transforms.js
[13777] Fix | Delete
/**
[13778] Fix | Delete
* Internal dependencies
[13779] Fix | Delete
*/
[13780] Fix | Delete
[13781] Fix | Delete
function getRawTransforms() {
[13782] Fix | Delete
return getBlockTransforms('from').filter(({
[13783] Fix | Delete
type
[13784] Fix | Delete
}) => type === 'raw').map(transform => {
[13785] Fix | Delete
return transform.isMatch ? transform : {
[13786] Fix | Delete
...transform,
[13787] Fix | Delete
isMatch: node => transform.selector && node.matches(transform.selector)
[13788] Fix | Delete
};
[13789] Fix | Delete
});
[13790] Fix | Delete
}
[13791] Fix | Delete
[13792] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/html-to-blocks.js
[13793] Fix | Delete
/**
[13794] Fix | Delete
* WordPress dependencies
[13795] Fix | Delete
*/
[13796] Fix | Delete
[13797] Fix | Delete
[13798] Fix | Delete
/**
[13799] Fix | Delete
* Internal dependencies
[13800] Fix | Delete
*/
[13801] Fix | Delete
[13802] Fix | Delete
[13803] Fix | Delete
[13804] Fix | Delete
[13805] Fix | Delete
[13806] Fix | Delete
/**
[13807] Fix | Delete
* Converts HTML directly to blocks. Looks for a matching transform for each
[13808] Fix | Delete
* top-level tag. The HTML should be filtered to not have any text between
[13809] Fix | Delete
* top-level tags and formatted in a way that blocks can handle the HTML.
[13810] Fix | Delete
*
[13811] Fix | Delete
* @param {string} html HTML to convert.
[13812] Fix | Delete
* @param {Function} handler The handler calling htmlToBlocks: either rawHandler
[13813] Fix | Delete
* or pasteHandler.
[13814] Fix | Delete
*
[13815] Fix | Delete
* @return {Array} An array of blocks.
[13816] Fix | Delete
*/
[13817] Fix | Delete
function htmlToBlocks(html, handler) {
[13818] Fix | Delete
const doc = document.implementation.createHTMLDocument('');
[13819] Fix | Delete
doc.body.innerHTML = html;
[13820] Fix | Delete
return Array.from(doc.body.children).flatMap(node => {
[13821] Fix | Delete
const rawTransform = findTransform(getRawTransforms(), ({
[13822] Fix | Delete
isMatch
[13823] Fix | Delete
}) => isMatch(node));
[13824] Fix | Delete
if (!rawTransform) {
[13825] Fix | Delete
// Until the HTML block is supported in the native version, we'll parse it
[13826] Fix | Delete
// instead of creating the block to generate it as an unsupported block.
[13827] Fix | Delete
if (external_wp_element_namespaceObject.Platform.isNative) {
[13828] Fix | Delete
return parser_parse(`<!-- wp:html -->${node.outerHTML}<!-- /wp:html -->`);
[13829] Fix | Delete
}
[13830] Fix | Delete
return createBlock(
[13831] Fix | Delete
// Should not be hardcoded.
[13832] Fix | Delete
'core/html', getBlockAttributes('core/html', node.outerHTML));
[13833] Fix | Delete
}
[13834] Fix | Delete
const {
[13835] Fix | Delete
transform,
[13836] Fix | Delete
blockName
[13837] Fix | Delete
} = rawTransform;
[13838] Fix | Delete
if (transform) {
[13839] Fix | Delete
const block = transform(node, handler);
[13840] Fix | Delete
if (node.hasAttribute('class')) {
[13841] Fix | Delete
block.attributes.className = node.getAttribute('class');
[13842] Fix | Delete
}
[13843] Fix | Delete
return block;
[13844] Fix | Delete
}
[13845] Fix | Delete
return createBlock(blockName, getBlockAttributes(blockName, node.outerHTML));
[13846] Fix | Delete
});
[13847] Fix | Delete
}
[13848] Fix | Delete
[13849] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/normalise-blocks.js
[13850] Fix | Delete
/**
[13851] Fix | Delete
* WordPress dependencies
[13852] Fix | Delete
*/
[13853] Fix | Delete
[13854] Fix | Delete
function normaliseBlocks(HTML, options = {}) {
[13855] Fix | Delete
const decuDoc = document.implementation.createHTMLDocument('');
[13856] Fix | Delete
const accuDoc = document.implementation.createHTMLDocument('');
[13857] Fix | Delete
const decu = decuDoc.body;
[13858] Fix | Delete
const accu = accuDoc.body;
[13859] Fix | Delete
decu.innerHTML = HTML;
[13860] Fix | Delete
while (decu.firstChild) {
[13861] Fix | Delete
const node = decu.firstChild;
[13862] Fix | Delete
[13863] Fix | Delete
// Text nodes: wrap in a paragraph, or append to previous.
[13864] Fix | Delete
if (node.nodeType === node.TEXT_NODE) {
[13865] Fix | Delete
if ((0,external_wp_dom_namespaceObject.isEmpty)(node)) {
[13866] Fix | Delete
decu.removeChild(node);
[13867] Fix | Delete
} else {
[13868] Fix | Delete
if (!accu.lastChild || accu.lastChild.nodeName !== 'P') {
[13869] Fix | Delete
accu.appendChild(accuDoc.createElement('P'));
[13870] Fix | Delete
}
[13871] Fix | Delete
accu.lastChild.appendChild(node);
[13872] Fix | Delete
}
[13873] Fix | Delete
// Element nodes.
[13874] Fix | Delete
} else if (node.nodeType === node.ELEMENT_NODE) {
[13875] Fix | Delete
// BR nodes: create a new paragraph on double, or append to previous.
[13876] Fix | Delete
if (node.nodeName === 'BR') {
[13877] Fix | Delete
if (node.nextSibling && node.nextSibling.nodeName === 'BR') {
[13878] Fix | Delete
accu.appendChild(accuDoc.createElement('P'));
[13879] Fix | Delete
decu.removeChild(node.nextSibling);
[13880] Fix | Delete
}
[13881] Fix | Delete
[13882] Fix | Delete
// Don't append to an empty paragraph.
[13883] Fix | Delete
if (accu.lastChild && accu.lastChild.nodeName === 'P' && accu.lastChild.hasChildNodes()) {
[13884] Fix | Delete
accu.lastChild.appendChild(node);
[13885] Fix | Delete
} else {
[13886] Fix | Delete
decu.removeChild(node);
[13887] Fix | Delete
}
[13888] Fix | Delete
} else if (node.nodeName === 'P') {
[13889] Fix | Delete
// Only append non-empty paragraph nodes.
[13890] Fix | Delete
if ((0,external_wp_dom_namespaceObject.isEmpty)(node) && !options.raw) {
[13891] Fix | Delete
decu.removeChild(node);
[13892] Fix | Delete
} else {
[13893] Fix | Delete
accu.appendChild(node);
[13894] Fix | Delete
}
[13895] Fix | Delete
} else if ((0,external_wp_dom_namespaceObject.isPhrasingContent)(node)) {
[13896] Fix | Delete
if (!accu.lastChild || accu.lastChild.nodeName !== 'P') {
[13897] Fix | Delete
accu.appendChild(accuDoc.createElement('P'));
[13898] Fix | Delete
}
[13899] Fix | Delete
accu.lastChild.appendChild(node);
[13900] Fix | Delete
} else {
[13901] Fix | Delete
accu.appendChild(node);
[13902] Fix | Delete
}
[13903] Fix | Delete
} else {
[13904] Fix | Delete
decu.removeChild(node);
[13905] Fix | Delete
}
[13906] Fix | Delete
}
[13907] Fix | Delete
return accu.innerHTML;
[13908] Fix | Delete
}
[13909] Fix | Delete
[13910] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/raw-handling/special-comment-converter.js
[13911] Fix | Delete
/**
[13912] Fix | Delete
* WordPress dependencies
[13913] Fix | Delete
*/
[13914] Fix | Delete
[13915] Fix | Delete
[13916] Fix | Delete
/**
[13917] Fix | Delete
* Looks for `<!--nextpage-->` and `<!--more-->` comments and
[13918] Fix | Delete
* replaces them with a custom element representing a future block.
[13919] Fix | Delete
*
[13920] Fix | Delete
* The custom element is a way to bypass the rest of the `raw-handling`
[13921] Fix | Delete
* transforms, which would eliminate other kinds of node with which to carry
[13922] Fix | Delete
* `<!--more-->`'s data: nodes with `data` attributes, empty paragraphs, etc.
[13923] Fix | Delete
*
[13924] Fix | Delete
* The custom element is then expected to be recognized by any registered
[13925] Fix | Delete
* block's `raw` transform.
[13926] Fix | Delete
*
[13927] Fix | Delete
* @param {Node} node The node to be processed.
[13928] Fix | Delete
* @param {Document} doc The document of the node.
[13929] Fix | Delete
* @return {void}
[13930] Fix | Delete
*/
[13931] Fix | Delete
function specialCommentConverter(node, doc) {
[13932] Fix | Delete
if (node.nodeType !== node.COMMENT_NODE) {
[13933] Fix | Delete
return;
[13934] Fix | Delete
}
[13935] Fix | Delete
if (node.nodeValue !== 'nextpage' && node.nodeValue.indexOf('more') !== 0) {
[13936] Fix | Delete
return;
[13937] Fix | Delete
}
[13938] Fix | Delete
const block = special_comment_converter_createBlock(node, doc);
[13939] Fix | Delete
[13940] Fix | Delete
// If our `<!--more-->` comment is in the middle of a paragraph, we should
[13941] Fix | Delete
// split the paragraph in two and insert the more block in between. If it's
[13942] Fix | Delete
// inside an empty paragraph, we should still move it out of the paragraph
[13943] Fix | Delete
// and remove the paragraph. If there's no paragraph, fall back to simply
[13944] Fix | Delete
// replacing the comment.
[13945] Fix | Delete
if (!node.parentNode || node.parentNode.nodeName !== 'P') {
[13946] Fix | Delete
(0,external_wp_dom_namespaceObject.replace)(node, block);
[13947] Fix | Delete
} else {
[13948] Fix | Delete
const childNodes = Array.from(node.parentNode.childNodes);
[13949] Fix | Delete
const nodeIndex = childNodes.indexOf(node);
[13950] Fix | Delete
const wrapperNode = node.parentNode.parentNode || doc.body;
[13951] Fix | Delete
const paragraphBuilder = (acc, child) => {
[13952] Fix | Delete
if (!acc) {
[13953] Fix | Delete
acc = doc.createElement('p');
[13954] Fix | Delete
}
[13955] Fix | Delete
acc.appendChild(child);
[13956] Fix | Delete
return acc;
[13957] Fix | Delete
};
[13958] Fix | Delete
[13959] Fix | Delete
// Split the original parent node and insert our more block
[13960] Fix | Delete
[childNodes.slice(0, nodeIndex).reduce(paragraphBuilder, null), block, childNodes.slice(nodeIndex + 1).reduce(paragraphBuilder, null)].forEach(element => element && wrapperNode.insertBefore(element, node.parentNode));
[13961] Fix | Delete
[13962] Fix | Delete
// Remove the old parent paragraph
[13963] Fix | Delete
(0,external_wp_dom_namespaceObject.remove)(node.parentNode);
[13964] Fix | Delete
}
[13965] Fix | Delete
}
[13966] Fix | Delete
function special_comment_converter_createBlock(commentNode, doc) {
[13967] Fix | Delete
if (commentNode.nodeValue === 'nextpage') {
[13968] Fix | Delete
return createNextpage(doc);
[13969] Fix | Delete
}
[13970] Fix | Delete
[13971] Fix | Delete
// Grab any custom text in the comment.
[13972] Fix | Delete
const customText = commentNode.nodeValue.slice(4).trim();
[13973] Fix | Delete
[13974] Fix | Delete
/*
[13975] Fix | Delete
* When a `<!--more-->` comment is found, we need to look for any
[13976] Fix | Delete
* `<!--noteaser-->` sibling, but it may not be a direct sibling
[13977] Fix | Delete
* (whitespace typically lies in between)
[13978] Fix | Delete
*/
[13979] Fix | Delete
let sibling = commentNode;
[13980] Fix | Delete
let noTeaser = false;
[13981] Fix | Delete
while (sibling = sibling.nextSibling) {
[13982] Fix | Delete
if (sibling.nodeType === sibling.COMMENT_NODE && sibling.nodeValue === 'noteaser') {
[13983] Fix | Delete
noTeaser = true;
[13984] Fix | Delete
(0,external_wp_dom_namespaceObject.remove)(sibling);
[13985] Fix | Delete
break;
[13986] Fix | Delete
}
[13987] Fix | Delete
}
[13988] Fix | Delete
return createMore(customText, noTeaser, doc);
[13989] Fix | Delete
}
[13990] Fix | Delete
function createMore(customText, noTeaser, doc) {
[13991] Fix | Delete
const node = doc.createElement('wp-block');
[13992] Fix | Delete
node.dataset.block = 'core/more';
[13993] Fix | Delete
if (customText) {
[13994] Fix | Delete
node.dataset.customText = customText;
[13995] Fix | Delete
}
[13996] Fix | Delete
if (noTeaser) {
[13997] Fix | Delete
// "Boolean" data attribute.
[13998] Fix | Delete
node.dataset.noTeaser = '';
[13999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function