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
*
[13000] Fix | Delete
* @return {string} String HTML representation of block node.
[13001] Fix | Delete
*/
[13002] Fix | Delete
function children_toHTML(children) {
[13003] Fix | Delete
external_wp_deprecated_default()('wp.blocks.children.toHTML', {
[13004] Fix | Delete
since: '6.1',
[13005] Fix | Delete
version: '6.3',
[13006] Fix | Delete
alternative: 'wp.richText.toHTMLString',
[13007] Fix | Delete
link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
[13008] Fix | Delete
});
[13009] Fix | Delete
const element = getSerializeCapableElement(children);
[13010] Fix | Delete
return (0,external_wp_element_namespaceObject.renderToString)(element);
[13011] Fix | Delete
}
[13012] Fix | Delete
[13013] Fix | Delete
/**
[13014] Fix | Delete
* Given a selector, returns an hpq matcher generating a WPBlockChildren value
[13015] Fix | Delete
* matching the selector result.
[13016] Fix | Delete
*
[13017] Fix | Delete
* @param {string} selector DOM selector.
[13018] Fix | Delete
*
[13019] Fix | Delete
* @return {Function} hpq matcher.
[13020] Fix | Delete
*/
[13021] Fix | Delete
function children_matcher(selector) {
[13022] Fix | Delete
external_wp_deprecated_default()('wp.blocks.children.matcher', {
[13023] Fix | Delete
since: '6.1',
[13024] Fix | Delete
version: '6.3',
[13025] Fix | Delete
alternative: 'html source',
[13026] Fix | Delete
link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
[13027] Fix | Delete
});
[13028] Fix | Delete
return domNode => {
[13029] Fix | Delete
let match = domNode;
[13030] Fix | Delete
if (selector) {
[13031] Fix | Delete
match = domNode.querySelector(selector);
[13032] Fix | Delete
}
[13033] Fix | Delete
if (match) {
[13034] Fix | Delete
return children_fromDOM(match.childNodes);
[13035] Fix | Delete
}
[13036] Fix | Delete
return [];
[13037] Fix | Delete
};
[13038] Fix | Delete
}
[13039] Fix | Delete
[13040] Fix | Delete
/**
[13041] Fix | Delete
* Object of utility functions used in managing block attribute values of
[13042] Fix | Delete
* source `children`.
[13043] Fix | Delete
*
[13044] Fix | Delete
* @see https://github.com/WordPress/gutenberg/pull/10439
[13045] Fix | Delete
*
[13046] Fix | Delete
* @deprecated since 4.0. The `children` source should not be used, and can be
[13047] Fix | Delete
* replaced by the `html` source.
[13048] Fix | Delete
*
[13049] Fix | Delete
* @private
[13050] Fix | Delete
*/
[13051] Fix | Delete
/* harmony default export */ const children = ({
[13052] Fix | Delete
concat,
[13053] Fix | Delete
getChildrenArray,
[13054] Fix | Delete
fromDOM: children_fromDOM,
[13055] Fix | Delete
toHTML: children_toHTML,
[13056] Fix | Delete
matcher: children_matcher
[13057] Fix | Delete
});
[13058] Fix | Delete
[13059] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/get-block-attributes.js
[13060] Fix | Delete
/**
[13061] Fix | Delete
* External dependencies
[13062] Fix | Delete
*/
[13063] Fix | Delete
[13064] Fix | Delete
[13065] Fix | Delete
[13066] Fix | Delete
/**
[13067] Fix | Delete
* WordPress dependencies
[13068] Fix | Delete
*/
[13069] Fix | Delete
[13070] Fix | Delete
[13071] Fix | Delete
[13072] Fix | Delete
/**
[13073] Fix | Delete
* Internal dependencies
[13074] Fix | Delete
*/
[13075] Fix | Delete
[13076] Fix | Delete
[13077] Fix | Delete
[13078] Fix | Delete
/**
[13079] Fix | Delete
* Higher-order hpq matcher which enhances an attribute matcher to return true
[13080] Fix | Delete
* or false depending on whether the original matcher returns undefined. This
[13081] Fix | Delete
* is useful for boolean attributes (e.g. disabled) whose attribute values may
[13082] Fix | Delete
* be technically falsey (empty string), though their mere presence should be
[13083] Fix | Delete
* enough to infer as true.
[13084] Fix | Delete
*
[13085] Fix | Delete
* @param {Function} matcher Original hpq matcher.
[13086] Fix | Delete
*
[13087] Fix | Delete
* @return {Function} Enhanced hpq matcher.
[13088] Fix | Delete
*/
[13089] Fix | Delete
const toBooleanAttributeMatcher = matcher => value => matcher(value) !== undefined;
[13090] Fix | Delete
[13091] Fix | Delete
/**
[13092] Fix | Delete
* Returns true if value is of the given JSON schema type, or false otherwise.
[13093] Fix | Delete
*
[13094] Fix | Delete
* @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25
[13095] Fix | Delete
*
[13096] Fix | Delete
* @param {*} value Value to test.
[13097] Fix | Delete
* @param {string} type Type to test.
[13098] Fix | Delete
*
[13099] Fix | Delete
* @return {boolean} Whether value is of type.
[13100] Fix | Delete
*/
[13101] Fix | Delete
function isOfType(value, type) {
[13102] Fix | Delete
switch (type) {
[13103] Fix | Delete
case 'rich-text':
[13104] Fix | Delete
return value instanceof external_wp_richText_namespaceObject.RichTextData;
[13105] Fix | Delete
case 'string':
[13106] Fix | Delete
return typeof value === 'string';
[13107] Fix | Delete
case 'boolean':
[13108] Fix | Delete
return typeof value === 'boolean';
[13109] Fix | Delete
case 'object':
[13110] Fix | Delete
return !!value && value.constructor === Object;
[13111] Fix | Delete
case 'null':
[13112] Fix | Delete
return value === null;
[13113] Fix | Delete
case 'array':
[13114] Fix | Delete
return Array.isArray(value);
[13115] Fix | Delete
case 'integer':
[13116] Fix | Delete
case 'number':
[13117] Fix | Delete
return typeof value === 'number';
[13118] Fix | Delete
}
[13119] Fix | Delete
return true;
[13120] Fix | Delete
}
[13121] Fix | Delete
[13122] Fix | Delete
/**
[13123] Fix | Delete
* Returns true if value is of an array of given JSON schema types, or false
[13124] Fix | Delete
* otherwise.
[13125] Fix | Delete
*
[13126] Fix | Delete
* @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25
[13127] Fix | Delete
*
[13128] Fix | Delete
* @param {*} value Value to test.
[13129] Fix | Delete
* @param {string[]} types Types to test.
[13130] Fix | Delete
*
[13131] Fix | Delete
* @return {boolean} Whether value is of types.
[13132] Fix | Delete
*/
[13133] Fix | Delete
function isOfTypes(value, types) {
[13134] Fix | Delete
return types.some(type => isOfType(value, type));
[13135] Fix | Delete
}
[13136] Fix | Delete
[13137] Fix | Delete
/**
[13138] Fix | Delete
* Given an attribute key, an attribute's schema, a block's raw content and the
[13139] Fix | Delete
* commentAttributes returns the attribute value depending on its source
[13140] Fix | Delete
* definition of the given attribute key.
[13141] Fix | Delete
*
[13142] Fix | Delete
* @param {string} attributeKey Attribute key.
[13143] Fix | Delete
* @param {Object} attributeSchema Attribute's schema.
[13144] Fix | Delete
* @param {Node} innerDOM Parsed DOM of block's inner HTML.
[13145] Fix | Delete
* @param {Object} commentAttributes Block's comment attributes.
[13146] Fix | Delete
* @param {string} innerHTML Raw HTML from block node's innerHTML property.
[13147] Fix | Delete
*
[13148] Fix | Delete
* @return {*} Attribute value.
[13149] Fix | Delete
*/
[13150] Fix | Delete
function getBlockAttribute(attributeKey, attributeSchema, innerDOM, commentAttributes, innerHTML) {
[13151] Fix | Delete
let value;
[13152] Fix | Delete
switch (attributeSchema.source) {
[13153] Fix | Delete
// An undefined source means that it's an attribute serialized to the
[13154] Fix | Delete
// block's "comment".
[13155] Fix | Delete
case undefined:
[13156] Fix | Delete
value = commentAttributes ? commentAttributes[attributeKey] : undefined;
[13157] Fix | Delete
break;
[13158] Fix | Delete
// raw source means that it's the original raw block content.
[13159] Fix | Delete
case 'raw':
[13160] Fix | Delete
value = innerHTML;
[13161] Fix | Delete
break;
[13162] Fix | Delete
case 'attribute':
[13163] Fix | Delete
case 'property':
[13164] Fix | Delete
case 'html':
[13165] Fix | Delete
case 'text':
[13166] Fix | Delete
case 'rich-text':
[13167] Fix | Delete
case 'children':
[13168] Fix | Delete
case 'node':
[13169] Fix | Delete
case 'query':
[13170] Fix | Delete
case 'tag':
[13171] Fix | Delete
value = parseWithAttributeSchema(innerDOM, attributeSchema);
[13172] Fix | Delete
break;
[13173] Fix | Delete
}
[13174] Fix | Delete
if (!isValidByType(value, attributeSchema.type) || !isValidByEnum(value, attributeSchema.enum)) {
[13175] Fix | Delete
// Reject the value if it is not valid. Reverting to the undefined
[13176] Fix | Delete
// value ensures the default is respected, if applicable.
[13177] Fix | Delete
value = undefined;
[13178] Fix | Delete
}
[13179] Fix | Delete
if (value === undefined) {
[13180] Fix | Delete
value = getDefault(attributeSchema);
[13181] Fix | Delete
}
[13182] Fix | Delete
return value;
[13183] Fix | Delete
}
[13184] Fix | Delete
[13185] Fix | Delete
/**
[13186] Fix | Delete
* Returns true if value is valid per the given block attribute schema type
[13187] Fix | Delete
* definition, or false otherwise.
[13188] Fix | Delete
*
[13189] Fix | Delete
* @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.1
[13190] Fix | Delete
*
[13191] Fix | Delete
* @param {*} value Value to test.
[13192] Fix | Delete
* @param {?(Array<string>|string)} type Block attribute schema type.
[13193] Fix | Delete
*
[13194] Fix | Delete
* @return {boolean} Whether value is valid.
[13195] Fix | Delete
*/
[13196] Fix | Delete
function isValidByType(value, type) {
[13197] Fix | Delete
return type === undefined || isOfTypes(value, Array.isArray(type) ? type : [type]);
[13198] Fix | Delete
}
[13199] Fix | Delete
[13200] Fix | Delete
/**
[13201] Fix | Delete
* Returns true if value is valid per the given block attribute schema enum
[13202] Fix | Delete
* definition, or false otherwise.
[13203] Fix | Delete
*
[13204] Fix | Delete
* @see https://json-schema.org/latest/json-schema-validation.html#rfc.section.6.1.2
[13205] Fix | Delete
*
[13206] Fix | Delete
* @param {*} value Value to test.
[13207] Fix | Delete
* @param {?Array} enumSet Block attribute schema enum.
[13208] Fix | Delete
*
[13209] Fix | Delete
* @return {boolean} Whether value is valid.
[13210] Fix | Delete
*/
[13211] Fix | Delete
function isValidByEnum(value, enumSet) {
[13212] Fix | Delete
return !Array.isArray(enumSet) || enumSet.includes(value);
[13213] Fix | Delete
}
[13214] Fix | Delete
[13215] Fix | Delete
/**
[13216] Fix | Delete
* Returns an hpq matcher given a source object.
[13217] Fix | Delete
*
[13218] Fix | Delete
* @param {Object} sourceConfig Attribute Source object.
[13219] Fix | Delete
*
[13220] Fix | Delete
* @return {Function} A hpq Matcher.
[13221] Fix | Delete
*/
[13222] Fix | Delete
const matcherFromSource = memize(sourceConfig => {
[13223] Fix | Delete
switch (sourceConfig.source) {
[13224] Fix | Delete
case 'attribute':
[13225] Fix | Delete
{
[13226] Fix | Delete
let matcher = attr(sourceConfig.selector, sourceConfig.attribute);
[13227] Fix | Delete
if (sourceConfig.type === 'boolean') {
[13228] Fix | Delete
matcher = toBooleanAttributeMatcher(matcher);
[13229] Fix | Delete
}
[13230] Fix | Delete
return matcher;
[13231] Fix | Delete
}
[13232] Fix | Delete
case 'html':
[13233] Fix | Delete
return matchers_html(sourceConfig.selector, sourceConfig.multiline);
[13234] Fix | Delete
case 'text':
[13235] Fix | Delete
return es_text(sourceConfig.selector);
[13236] Fix | Delete
case 'rich-text':
[13237] Fix | Delete
return richText(sourceConfig.selector, sourceConfig.__unstablePreserveWhiteSpace);
[13238] Fix | Delete
case 'children':
[13239] Fix | Delete
return children_matcher(sourceConfig.selector);
[13240] Fix | Delete
case 'node':
[13241] Fix | Delete
return matcher(sourceConfig.selector);
[13242] Fix | Delete
case 'query':
[13243] Fix | Delete
const subMatchers = Object.fromEntries(Object.entries(sourceConfig.query).map(([key, subSourceConfig]) => [key, matcherFromSource(subSourceConfig)]));
[13244] Fix | Delete
return query(sourceConfig.selector, subMatchers);
[13245] Fix | Delete
case 'tag':
[13246] Fix | Delete
{
[13247] Fix | Delete
const matcher = prop(sourceConfig.selector, 'nodeName');
[13248] Fix | Delete
return domNode => matcher(domNode)?.toLowerCase();
[13249] Fix | Delete
}
[13250] Fix | Delete
default:
[13251] Fix | Delete
// eslint-disable-next-line no-console
[13252] Fix | Delete
console.error(`Unknown source type "${sourceConfig.source}"`);
[13253] Fix | Delete
}
[13254] Fix | Delete
});
[13255] Fix | Delete
[13256] Fix | Delete
/**
[13257] Fix | Delete
* Parse a HTML string into DOM tree.
[13258] Fix | Delete
*
[13259] Fix | Delete
* @param {string|Node} innerHTML HTML string or already parsed DOM node.
[13260] Fix | Delete
*
[13261] Fix | Delete
* @return {Node} Parsed DOM node.
[13262] Fix | Delete
*/
[13263] Fix | Delete
function parseHtml(innerHTML) {
[13264] Fix | Delete
return parse(innerHTML, h => h);
[13265] Fix | Delete
}
[13266] Fix | Delete
[13267] Fix | Delete
/**
[13268] Fix | Delete
* Given a block's raw content and an attribute's schema returns the attribute's
[13269] Fix | Delete
* value depending on its source.
[13270] Fix | Delete
*
[13271] Fix | Delete
* @param {string|Node} innerHTML Block's raw content.
[13272] Fix | Delete
* @param {Object} attributeSchema Attribute's schema.
[13273] Fix | Delete
*
[13274] Fix | Delete
* @return {*} Attribute value.
[13275] Fix | Delete
*/
[13276] Fix | Delete
function parseWithAttributeSchema(innerHTML, attributeSchema) {
[13277] Fix | Delete
return matcherFromSource(attributeSchema)(parseHtml(innerHTML));
[13278] Fix | Delete
}
[13279] Fix | Delete
[13280] Fix | Delete
/**
[13281] Fix | Delete
* Returns the block attributes of a registered block node given its type.
[13282] Fix | Delete
*
[13283] Fix | Delete
* @param {string|Object} blockTypeOrName Block type or name.
[13284] Fix | Delete
* @param {string|Node} innerHTML Raw block content.
[13285] Fix | Delete
* @param {?Object} attributes Known block attributes (from delimiters).
[13286] Fix | Delete
*
[13287] Fix | Delete
* @return {Object} All block attributes.
[13288] Fix | Delete
*/
[13289] Fix | Delete
function getBlockAttributes(blockTypeOrName, innerHTML, attributes = {}) {
[13290] Fix | Delete
var _blockType$attributes;
[13291] Fix | Delete
const doc = parseHtml(innerHTML);
[13292] Fix | Delete
const blockType = normalizeBlockType(blockTypeOrName);
[13293] Fix | Delete
const blockAttributes = Object.fromEntries(Object.entries((_blockType$attributes = blockType.attributes) !== null && _blockType$attributes !== void 0 ? _blockType$attributes : {}).map(([key, schema]) => [key, getBlockAttribute(key, schema, doc, attributes, innerHTML)]));
[13294] Fix | Delete
return (0,external_wp_hooks_namespaceObject.applyFilters)('blocks.getBlockAttributes', blockAttributes, blockType, innerHTML, attributes);
[13295] Fix | Delete
}
[13296] Fix | Delete
[13297] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/fix-custom-classname.js
[13298] Fix | Delete
/**
[13299] Fix | Delete
* Internal dependencies
[13300] Fix | Delete
*/
[13301] Fix | Delete
[13302] Fix | Delete
[13303] Fix | Delete
[13304] Fix | Delete
const CLASS_ATTR_SCHEMA = {
[13305] Fix | Delete
type: 'string',
[13306] Fix | Delete
source: 'attribute',
[13307] Fix | Delete
selector: '[data-custom-class-name] > *',
[13308] Fix | Delete
attribute: 'class'
[13309] Fix | Delete
};
[13310] Fix | Delete
[13311] Fix | Delete
/**
[13312] Fix | Delete
* Given an HTML string, returns an array of class names assigned to the root
[13313] Fix | Delete
* element in the markup.
[13314] Fix | Delete
*
[13315] Fix | Delete
* @param {string} innerHTML Markup string from which to extract classes.
[13316] Fix | Delete
*
[13317] Fix | Delete
* @return {string[]} Array of class names assigned to the root element.
[13318] Fix | Delete
*/
[13319] Fix | Delete
function getHTMLRootElementClasses(innerHTML) {
[13320] Fix | Delete
const parsed = parseWithAttributeSchema(`<div data-custom-class-name>${innerHTML}</div>`, CLASS_ATTR_SCHEMA);
[13321] Fix | Delete
return parsed ? parsed.trim().split(/\s+/) : [];
[13322] Fix | Delete
}
[13323] Fix | Delete
[13324] Fix | Delete
/**
[13325] Fix | Delete
* Given a parsed set of block attributes, if the block supports custom class
[13326] Fix | Delete
* names and an unknown class (per the block's serialization behavior) is
[13327] Fix | Delete
* found, the unknown classes are treated as custom classes. This prevents the
[13328] Fix | Delete
* block from being considered as invalid.
[13329] Fix | Delete
*
[13330] Fix | Delete
* @param {Object} blockAttributes Original block attributes.
[13331] Fix | Delete
* @param {Object} blockType Block type settings.
[13332] Fix | Delete
* @param {string} innerHTML Original block markup.
[13333] Fix | Delete
*
[13334] Fix | Delete
* @return {Object} Filtered block attributes.
[13335] Fix | Delete
*/
[13336] Fix | Delete
function fixCustomClassname(blockAttributes, blockType, innerHTML) {
[13337] Fix | Delete
if (hasBlockSupport(blockType, 'customClassName', true)) {
[13338] Fix | Delete
// To determine difference, serialize block given the known set of
[13339] Fix | Delete
// attributes, with the exception of `className`. This will determine
[13340] Fix | Delete
// the default set of classes. From there, any difference in innerHTML
[13341] Fix | Delete
// can be considered as custom classes.
[13342] Fix | Delete
const {
[13343] Fix | Delete
className: omittedClassName,
[13344] Fix | Delete
...attributesSansClassName
[13345] Fix | Delete
} = blockAttributes;
[13346] Fix | Delete
const serialized = getSaveContent(blockType, attributesSansClassName);
[13347] Fix | Delete
const defaultClasses = getHTMLRootElementClasses(serialized);
[13348] Fix | Delete
const actualClasses = getHTMLRootElementClasses(innerHTML);
[13349] Fix | Delete
const customClasses = actualClasses.filter(className => !defaultClasses.includes(className));
[13350] Fix | Delete
if (customClasses.length) {
[13351] Fix | Delete
blockAttributes.className = customClasses.join(' ');
[13352] Fix | Delete
} else if (serialized) {
[13353] Fix | Delete
delete blockAttributes.className;
[13354] Fix | Delete
}
[13355] Fix | Delete
}
[13356] Fix | Delete
return blockAttributes;
[13357] Fix | Delete
}
[13358] Fix | Delete
[13359] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/apply-built-in-validation-fixes.js
[13360] Fix | Delete
/**
[13361] Fix | Delete
* Internal dependencies
[13362] Fix | Delete
*/
[13363] Fix | Delete
[13364] Fix | Delete
[13365] Fix | Delete
/**
[13366] Fix | Delete
* Attempts to fix block invalidation by applying build-in validation fixes
[13367] Fix | Delete
* like moving all extra classNames to the className attribute.
[13368] Fix | Delete
*
[13369] Fix | Delete
* @param {WPBlock} block block object.
[13370] Fix | Delete
* @param {import('../registration').WPBlockType} blockType Block type. This is normalize not necessary and
[13371] Fix | Delete
* can be inferred from the block name,
[13372] Fix | Delete
* but it's here for performance reasons.
[13373] Fix | Delete
*
[13374] Fix | Delete
* @return {WPBlock} Fixed block object
[13375] Fix | Delete
*/
[13376] Fix | Delete
function applyBuiltInValidationFixes(block, blockType) {
[13377] Fix | Delete
const updatedBlockAttributes = fixCustomClassname(block.attributes, blockType, block.originalContent);
[13378] Fix | Delete
return {
[13379] Fix | Delete
...block,
[13380] Fix | Delete
attributes: updatedBlockAttributes
[13381] Fix | Delete
};
[13382] Fix | Delete
}
[13383] Fix | Delete
[13384] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/apply-block-deprecated-versions.js
[13385] Fix | Delete
/**
[13386] Fix | Delete
* Internal dependencies
[13387] Fix | Delete
*/
[13388] Fix | Delete
[13389] Fix | Delete
[13390] Fix | Delete
[13391] Fix | Delete
[13392] Fix | Delete
[13393] Fix | Delete
[13394] Fix | Delete
/**
[13395] Fix | Delete
* Function that takes no arguments and always returns false.
[13396] Fix | Delete
*
[13397] Fix | Delete
* @return {boolean} Always returns false.
[13398] Fix | Delete
*/
[13399] Fix | Delete
function stubFalse() {
[13400] Fix | Delete
return false;
[13401] Fix | Delete
}
[13402] Fix | Delete
[13403] Fix | Delete
/**
[13404] Fix | Delete
* Given a block object, returns a new copy of the block with any applicable
[13405] Fix | Delete
* deprecated migrations applied, or the original block if it was both valid
[13406] Fix | Delete
* and no eligible migrations exist.
[13407] Fix | Delete
*
[13408] Fix | Delete
* @param {import(".").WPBlock} block Parsed and invalid block object.
[13409] Fix | Delete
* @param {import(".").WPRawBlock} rawBlock Raw block object.
[13410] Fix | Delete
* @param {import('../registration').WPBlockType} blockType Block type. This is normalize not necessary and
[13411] Fix | Delete
* can be inferred from the block name,
[13412] Fix | Delete
* but it's here for performance reasons.
[13413] Fix | Delete
*
[13414] Fix | Delete
* @return {import(".").WPBlock} Migrated block object.
[13415] Fix | Delete
*/
[13416] Fix | Delete
function applyBlockDeprecatedVersions(block, rawBlock, blockType) {
[13417] Fix | Delete
const parsedAttributes = rawBlock.attrs;
[13418] Fix | Delete
const {
[13419] Fix | Delete
deprecated: deprecatedDefinitions
[13420] Fix | Delete
} = blockType;
[13421] Fix | Delete
// Bail early if there are no registered deprecations to be handled.
[13422] Fix | Delete
if (!deprecatedDefinitions || !deprecatedDefinitions.length) {
[13423] Fix | Delete
return block;
[13424] Fix | Delete
}
[13425] Fix | Delete
[13426] Fix | Delete
// By design, blocks lack any sort of version tracking. Instead, to process
[13427] Fix | Delete
// outdated content the system operates a queue out of all the defined
[13428] Fix | Delete
// attribute shapes and tries each definition until the input produces a
[13429] Fix | Delete
// valid result. This mechanism seeks to avoid polluting the user-space with
[13430] Fix | Delete
// machine-specific code. An invalid block is thus a block that could not be
[13431] Fix | Delete
// matched successfully with any of the registered deprecation definitions.
[13432] Fix | Delete
for (let i = 0; i < deprecatedDefinitions.length; i++) {
[13433] Fix | Delete
// A block can opt into a migration even if the block is valid by
[13434] Fix | Delete
// defining `isEligible` on its deprecation. If the block is both valid
[13435] Fix | Delete
// and does not opt to migrate, skip.
[13436] Fix | Delete
const {
[13437] Fix | Delete
isEligible = stubFalse
[13438] Fix | Delete
} = deprecatedDefinitions[i];
[13439] Fix | Delete
if (block.isValid && !isEligible(parsedAttributes, block.innerBlocks, {
[13440] Fix | Delete
blockNode: rawBlock,
[13441] Fix | Delete
block
[13442] Fix | Delete
})) {
[13443] Fix | Delete
continue;
[13444] Fix | Delete
}
[13445] Fix | Delete
[13446] Fix | Delete
// Block type properties which could impact either serialization or
[13447] Fix | Delete
// parsing are not considered in the deprecated block type by default,
[13448] Fix | Delete
// and must be explicitly provided.
[13449] Fix | Delete
const deprecatedBlockType = Object.assign(omit(blockType, DEPRECATED_ENTRY_KEYS), deprecatedDefinitions[i]);
[13450] Fix | Delete
let migratedBlock = {
[13451] Fix | Delete
...block,
[13452] Fix | Delete
attributes: getBlockAttributes(deprecatedBlockType, block.originalContent, parsedAttributes)
[13453] Fix | Delete
};
[13454] Fix | Delete
[13455] Fix | Delete
// Ignore the deprecation if it produces a block which is not valid.
[13456] Fix | Delete
let [isValid] = validateBlock(migratedBlock, deprecatedBlockType);
[13457] Fix | Delete
[13458] Fix | Delete
// If the migrated block is not valid initially, try the built-in fixes.
[13459] Fix | Delete
if (!isValid) {
[13460] Fix | Delete
migratedBlock = applyBuiltInValidationFixes(migratedBlock, deprecatedBlockType);
[13461] Fix | Delete
[isValid] = validateBlock(migratedBlock, deprecatedBlockType);
[13462] Fix | Delete
}
[13463] Fix | Delete
[13464] Fix | Delete
// An invalid block does not imply incorrect HTML but the fact block
[13465] Fix | Delete
// source information could be lost on re-serialization.
[13466] Fix | Delete
if (!isValid) {
[13467] Fix | Delete
continue;
[13468] Fix | Delete
}
[13469] Fix | Delete
let migratedInnerBlocks = migratedBlock.innerBlocks;
[13470] Fix | Delete
let migratedAttributes = migratedBlock.attributes;
[13471] Fix | Delete
[13472] Fix | Delete
// A block may provide custom behavior to assign new attributes and/or
[13473] Fix | Delete
// inner blocks.
[13474] Fix | Delete
const {
[13475] Fix | Delete
migrate
[13476] Fix | Delete
} = deprecatedBlockType;
[13477] Fix | Delete
if (migrate) {
[13478] Fix | Delete
let migrated = migrate(migratedAttributes, block.innerBlocks);
[13479] Fix | Delete
if (!Array.isArray(migrated)) {
[13480] Fix | Delete
migrated = [migrated];
[13481] Fix | Delete
}
[13482] Fix | Delete
[migratedAttributes = parsedAttributes, migratedInnerBlocks = block.innerBlocks] = migrated;
[13483] Fix | Delete
}
[13484] Fix | Delete
block = {
[13485] Fix | Delete
...block,
[13486] Fix | Delete
attributes: migratedAttributes,
[13487] Fix | Delete
innerBlocks: migratedInnerBlocks,
[13488] Fix | Delete
isValid: true,
[13489] Fix | Delete
validationIssues: []
[13490] Fix | Delete
};
[13491] Fix | Delete
}
[13492] Fix | Delete
return block;
[13493] Fix | Delete
}
[13494] Fix | Delete
[13495] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/parser/index.js
[13496] Fix | Delete
/**
[13497] Fix | Delete
* WordPress dependencies
[13498] Fix | Delete
*/
[13499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function