Edit File by line
/home/zeestwma/richards.../wp-inclu.../js/dist
File: patterns.js
/******/ (() => { // webpackBootstrap
[0] Fix | Delete
/******/ "use strict";
[1] Fix | Delete
/******/ // The require scope
[2] Fix | Delete
/******/ var __webpack_require__ = {};
[3] Fix | Delete
/******/
[4] Fix | Delete
/************************************************************************/
[5] Fix | Delete
/******/ /* webpack/runtime/define property getters */
[6] Fix | Delete
/******/ (() => {
[7] Fix | Delete
/******/ // define getter functions for harmony exports
[8] Fix | Delete
/******/ __webpack_require__.d = (exports, definition) => {
[9] Fix | Delete
/******/ for(var key in definition) {
[10] Fix | Delete
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
[11] Fix | Delete
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
[12] Fix | Delete
/******/ }
[13] Fix | Delete
/******/ }
[14] Fix | Delete
/******/ };
[15] Fix | Delete
/******/ })();
[16] Fix | Delete
/******/
[17] Fix | Delete
/******/ /* webpack/runtime/hasOwnProperty shorthand */
[18] Fix | Delete
/******/ (() => {
[19] Fix | Delete
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
[20] Fix | Delete
/******/ })();
[21] Fix | Delete
/******/
[22] Fix | Delete
/******/ /* webpack/runtime/make namespace object */
[23] Fix | Delete
/******/ (() => {
[24] Fix | Delete
/******/ // define __esModule on exports
[25] Fix | Delete
/******/ __webpack_require__.r = (exports) => {
[26] Fix | Delete
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
[27] Fix | Delete
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
[28] Fix | Delete
/******/ }
[29] Fix | Delete
/******/ Object.defineProperty(exports, '__esModule', { value: true });
[30] Fix | Delete
/******/ };
[31] Fix | Delete
/******/ })();
[32] Fix | Delete
/******/
[33] Fix | Delete
/************************************************************************/
[34] Fix | Delete
var __webpack_exports__ = {};
[35] Fix | Delete
// ESM COMPAT FLAG
[36] Fix | Delete
__webpack_require__.r(__webpack_exports__);
[37] Fix | Delete
[38] Fix | Delete
// EXPORTS
[39] Fix | Delete
__webpack_require__.d(__webpack_exports__, {
[40] Fix | Delete
privateApis: () => (/* reexport */ privateApis),
[41] Fix | Delete
store: () => (/* reexport */ store)
[42] Fix | Delete
});
[43] Fix | Delete
[44] Fix | Delete
// NAMESPACE OBJECT: ./node_modules/@wordpress/patterns/build-module/store/actions.js
[45] Fix | Delete
var actions_namespaceObject = {};
[46] Fix | Delete
__webpack_require__.r(actions_namespaceObject);
[47] Fix | Delete
__webpack_require__.d(actions_namespaceObject, {
[48] Fix | Delete
convertSyncedPatternToStatic: () => (convertSyncedPatternToStatic),
[49] Fix | Delete
createPattern: () => (createPattern),
[50] Fix | Delete
createPatternFromFile: () => (createPatternFromFile),
[51] Fix | Delete
setEditingPattern: () => (setEditingPattern)
[52] Fix | Delete
});
[53] Fix | Delete
[54] Fix | Delete
// NAMESPACE OBJECT: ./node_modules/@wordpress/patterns/build-module/store/selectors.js
[55] Fix | Delete
var selectors_namespaceObject = {};
[56] Fix | Delete
__webpack_require__.r(selectors_namespaceObject);
[57] Fix | Delete
__webpack_require__.d(selectors_namespaceObject, {
[58] Fix | Delete
isEditingPattern: () => (selectors_isEditingPattern)
[59] Fix | Delete
});
[60] Fix | Delete
[61] Fix | Delete
;// external ["wp","data"]
[62] Fix | Delete
const external_wp_data_namespaceObject = window["wp"]["data"];
[63] Fix | Delete
;// ./node_modules/@wordpress/patterns/build-module/store/reducer.js
[64] Fix | Delete
/**
[65] Fix | Delete
* WordPress dependencies
[66] Fix | Delete
*/
[67] Fix | Delete
[68] Fix | Delete
function isEditingPattern(state = {}, action) {
[69] Fix | Delete
if (action?.type === 'SET_EDITING_PATTERN') {
[70] Fix | Delete
return {
[71] Fix | Delete
...state,
[72] Fix | Delete
[action.clientId]: action.isEditing
[73] Fix | Delete
};
[74] Fix | Delete
}
[75] Fix | Delete
return state;
[76] Fix | Delete
}
[77] Fix | Delete
/* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
[78] Fix | Delete
isEditingPattern
[79] Fix | Delete
}));
[80] Fix | Delete
[81] Fix | Delete
;// external ["wp","blocks"]
[82] Fix | Delete
const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
[83] Fix | Delete
;// external ["wp","coreData"]
[84] Fix | Delete
const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
[85] Fix | Delete
;// external ["wp","blockEditor"]
[86] Fix | Delete
const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
[87] Fix | Delete
;// ./node_modules/@wordpress/patterns/build-module/constants.js
[88] Fix | Delete
const PATTERN_TYPES = {
[89] Fix | Delete
theme: 'pattern',
[90] Fix | Delete
user: 'wp_block'
[91] Fix | Delete
};
[92] Fix | Delete
const PATTERN_DEFAULT_CATEGORY = 'all-patterns';
[93] Fix | Delete
const PATTERN_USER_CATEGORY = 'my-patterns';
[94] Fix | Delete
const EXCLUDED_PATTERN_SOURCES = ['core', 'pattern-directory/core', 'pattern-directory/featured'];
[95] Fix | Delete
const PATTERN_SYNC_TYPES = {
[96] Fix | Delete
full: 'fully',
[97] Fix | Delete
unsynced: 'unsynced'
[98] Fix | Delete
};
[99] Fix | Delete
[100] Fix | Delete
// TODO: This should not be hardcoded. Maybe there should be a config and/or an UI.
[101] Fix | Delete
const PARTIAL_SYNCING_SUPPORTED_BLOCKS = {
[102] Fix | Delete
'core/paragraph': ['content'],
[103] Fix | Delete
'core/heading': ['content'],
[104] Fix | Delete
'core/button': ['text', 'url', 'linkTarget', 'rel'],
[105] Fix | Delete
'core/image': ['id', 'url', 'title', 'alt']
[106] Fix | Delete
};
[107] Fix | Delete
const PATTERN_OVERRIDES_BINDING_SOURCE = 'core/pattern-overrides';
[108] Fix | Delete
[109] Fix | Delete
;// ./node_modules/@wordpress/patterns/build-module/store/actions.js
[110] Fix | Delete
/**
[111] Fix | Delete
* WordPress dependencies
[112] Fix | Delete
*/
[113] Fix | Delete
[114] Fix | Delete
[115] Fix | Delete
[116] Fix | Delete
[117] Fix | Delete
[118] Fix | Delete
/**
[119] Fix | Delete
* Internal dependencies
[120] Fix | Delete
*/
[121] Fix | Delete
[122] Fix | Delete
[123] Fix | Delete
/**
[124] Fix | Delete
* Returns a generator converting one or more static blocks into a pattern, or creating a new empty pattern.
[125] Fix | Delete
*
[126] Fix | Delete
* @param {string} title Pattern title.
[127] Fix | Delete
* @param {'full'|'unsynced'} syncType They way block is synced, 'full' or 'unsynced'.
[128] Fix | Delete
* @param {string|undefined} [content] Optional serialized content of blocks to convert to pattern.
[129] Fix | Delete
* @param {number[]|undefined} [categories] Ids of any selected categories.
[130] Fix | Delete
*/
[131] Fix | Delete
const createPattern = (title, syncType, content, categories) => async ({
[132] Fix | Delete
registry
[133] Fix | Delete
}) => {
[134] Fix | Delete
const meta = syncType === PATTERN_SYNC_TYPES.unsynced ? {
[135] Fix | Delete
wp_pattern_sync_status: syncType
[136] Fix | Delete
} : undefined;
[137] Fix | Delete
const reusableBlock = {
[138] Fix | Delete
title,
[139] Fix | Delete
content,
[140] Fix | Delete
status: 'publish',
[141] Fix | Delete
meta,
[142] Fix | Delete
wp_pattern_category: categories
[143] Fix | Delete
};
[144] Fix | Delete
const updatedRecord = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', 'wp_block', reusableBlock);
[145] Fix | Delete
return updatedRecord;
[146] Fix | Delete
};
[147] Fix | Delete
[148] Fix | Delete
/**
[149] Fix | Delete
* Create a pattern from a JSON file.
[150] Fix | Delete
* @param {File} file The JSON file instance of the pattern.
[151] Fix | Delete
* @param {number[]|undefined} [categories] Ids of any selected categories.
[152] Fix | Delete
*/
[153] Fix | Delete
const createPatternFromFile = (file, categories) => async ({
[154] Fix | Delete
dispatch
[155] Fix | Delete
}) => {
[156] Fix | Delete
const fileContent = await file.text();
[157] Fix | Delete
/** @type {import('./types').PatternJSON} */
[158] Fix | Delete
let parsedContent;
[159] Fix | Delete
try {
[160] Fix | Delete
parsedContent = JSON.parse(fileContent);
[161] Fix | Delete
} catch (e) {
[162] Fix | Delete
throw new Error('Invalid JSON file');
[163] Fix | Delete
}
[164] Fix | Delete
if (parsedContent.__file !== 'wp_block' || !parsedContent.title || !parsedContent.content || typeof parsedContent.title !== 'string' || typeof parsedContent.content !== 'string' || parsedContent.syncStatus && typeof parsedContent.syncStatus !== 'string') {
[165] Fix | Delete
throw new Error('Invalid pattern JSON file');
[166] Fix | Delete
}
[167] Fix | Delete
const pattern = await dispatch.createPattern(parsedContent.title, parsedContent.syncStatus, parsedContent.content, categories);
[168] Fix | Delete
return pattern;
[169] Fix | Delete
};
[170] Fix | Delete
[171] Fix | Delete
/**
[172] Fix | Delete
* Returns a generator converting a synced pattern block into a static block.
[173] Fix | Delete
*
[174] Fix | Delete
* @param {string} clientId The client ID of the block to attach.
[175] Fix | Delete
*/
[176] Fix | Delete
const convertSyncedPatternToStatic = clientId => ({
[177] Fix | Delete
registry
[178] Fix | Delete
}) => {
[179] Fix | Delete
const patternBlock = registry.select(external_wp_blockEditor_namespaceObject.store).getBlock(clientId);
[180] Fix | Delete
const existingOverrides = patternBlock.attributes?.content;
[181] Fix | Delete
function cloneBlocksAndRemoveBindings(blocks) {
[182] Fix | Delete
return blocks.map(block => {
[183] Fix | Delete
let metadata = block.attributes.metadata;
[184] Fix | Delete
if (metadata) {
[185] Fix | Delete
metadata = {
[186] Fix | Delete
...metadata
[187] Fix | Delete
};
[188] Fix | Delete
delete metadata.id;
[189] Fix | Delete
delete metadata.bindings;
[190] Fix | Delete
// Use overridden values of the pattern block if they exist.
[191] Fix | Delete
if (existingOverrides?.[metadata.name]) {
[192] Fix | Delete
// Iterate over each overridden attribute.
[193] Fix | Delete
for (const [attributeName, value] of Object.entries(existingOverrides[metadata.name])) {
[194] Fix | Delete
// Skip if the attribute does not exist in the block type.
[195] Fix | Delete
if (!(0,external_wp_blocks_namespaceObject.getBlockType)(block.name)?.attributes[attributeName]) {
[196] Fix | Delete
continue;
[197] Fix | Delete
}
[198] Fix | Delete
// Update the block attribute with the override value.
[199] Fix | Delete
block.attributes[attributeName] = value;
[200] Fix | Delete
}
[201] Fix | Delete
}
[202] Fix | Delete
}
[203] Fix | Delete
return (0,external_wp_blocks_namespaceObject.cloneBlock)(block, {
[204] Fix | Delete
metadata: metadata && Object.keys(metadata).length > 0 ? metadata : undefined
[205] Fix | Delete
}, cloneBlocksAndRemoveBindings(block.innerBlocks));
[206] Fix | Delete
});
[207] Fix | Delete
}
[208] Fix | Delete
const patternInnerBlocks = registry.select(external_wp_blockEditor_namespaceObject.store).getBlocks(patternBlock.clientId);
[209] Fix | Delete
registry.dispatch(external_wp_blockEditor_namespaceObject.store).replaceBlocks(patternBlock.clientId, cloneBlocksAndRemoveBindings(patternInnerBlocks));
[210] Fix | Delete
};
[211] Fix | Delete
[212] Fix | Delete
/**
[213] Fix | Delete
* Returns an action descriptor for SET_EDITING_PATTERN action.
[214] Fix | Delete
*
[215] Fix | Delete
* @param {string} clientId The clientID of the pattern to target.
[216] Fix | Delete
* @param {boolean} isEditing Whether the block should be in editing state.
[217] Fix | Delete
* @return {Object} Action descriptor.
[218] Fix | Delete
*/
[219] Fix | Delete
function setEditingPattern(clientId, isEditing) {
[220] Fix | Delete
return {
[221] Fix | Delete
type: 'SET_EDITING_PATTERN',
[222] Fix | Delete
clientId,
[223] Fix | Delete
isEditing
[224] Fix | Delete
};
[225] Fix | Delete
}
[226] Fix | Delete
[227] Fix | Delete
;// ./node_modules/@wordpress/patterns/build-module/store/constants.js
[228] Fix | Delete
/**
[229] Fix | Delete
* Module Constants
[230] Fix | Delete
*/
[231] Fix | Delete
const STORE_NAME = 'core/patterns';
[232] Fix | Delete
[233] Fix | Delete
;// ./node_modules/@wordpress/patterns/build-module/store/selectors.js
[234] Fix | Delete
/**
[235] Fix | Delete
* Returns true if pattern is in the editing state.
[236] Fix | Delete
*
[237] Fix | Delete
* @param {Object} state Global application state.
[238] Fix | Delete
* @param {number} clientId the clientID of the block.
[239] Fix | Delete
* @return {boolean} Whether the pattern is in the editing state.
[240] Fix | Delete
*/
[241] Fix | Delete
function selectors_isEditingPattern(state, clientId) {
[242] Fix | Delete
return state.isEditingPattern[clientId];
[243] Fix | Delete
}
[244] Fix | Delete
[245] Fix | Delete
;// external ["wp","privateApis"]
[246] Fix | Delete
const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
[247] Fix | Delete
;// ./node_modules/@wordpress/patterns/build-module/lock-unlock.js
[248] Fix | Delete
/**
[249] Fix | Delete
* WordPress dependencies
[250] Fix | Delete
*/
[251] Fix | Delete
[252] Fix | Delete
const {
[253] Fix | Delete
lock,
[254] Fix | Delete
unlock
[255] Fix | Delete
} = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/patterns');
[256] Fix | Delete
[257] Fix | Delete
;// ./node_modules/@wordpress/patterns/build-module/store/index.js
[258] Fix | Delete
/**
[259] Fix | Delete
* WordPress dependencies
[260] Fix | Delete
*/
[261] Fix | Delete
[262] Fix | Delete
[263] Fix | Delete
/**
[264] Fix | Delete
* Internal dependencies
[265] Fix | Delete
*/
[266] Fix | Delete
[267] Fix | Delete
[268] Fix | Delete
[269] Fix | Delete
[270] Fix | Delete
[271] Fix | Delete
[272] Fix | Delete
/**
[273] Fix | Delete
* Post editor data store configuration.
[274] Fix | Delete
*
[275] Fix | Delete
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
[276] Fix | Delete
*
[277] Fix | Delete
* @type {Object}
[278] Fix | Delete
*/
[279] Fix | Delete
const storeConfig = {
[280] Fix | Delete
reducer: reducer
[281] Fix | Delete
};
[282] Fix | Delete
[283] Fix | Delete
/**
[284] Fix | Delete
* Store definition for the editor namespace.
[285] Fix | Delete
*
[286] Fix | Delete
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
[287] Fix | Delete
*
[288] Fix | Delete
* @type {Object}
[289] Fix | Delete
*/
[290] Fix | Delete
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
[291] Fix | Delete
...storeConfig
[292] Fix | Delete
});
[293] Fix | Delete
(0,external_wp_data_namespaceObject.register)(store);
[294] Fix | Delete
unlock(store).registerPrivateActions(actions_namespaceObject);
[295] Fix | Delete
unlock(store).registerPrivateSelectors(selectors_namespaceObject);
[296] Fix | Delete
[297] Fix | Delete
;// external ["wp","components"]
[298] Fix | Delete
const external_wp_components_namespaceObject = window["wp"]["components"];
[299] Fix | Delete
;// external ["wp","element"]
[300] Fix | Delete
const external_wp_element_namespaceObject = window["wp"]["element"];
[301] Fix | Delete
;// external ["wp","i18n"]
[302] Fix | Delete
const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
[303] Fix | Delete
;// ./node_modules/@wordpress/patterns/build-module/api/index.js
[304] Fix | Delete
/**
[305] Fix | Delete
* Internal dependencies
[306] Fix | Delete
*/
[307] Fix | Delete
[308] Fix | Delete
[309] Fix | Delete
/**
[310] Fix | Delete
* Determines whether a block is overridable.
[311] Fix | Delete
*
[312] Fix | Delete
* @param {WPBlock} block The block to test.
[313] Fix | Delete
*
[314] Fix | Delete
* @return {boolean} `true` if a block is overridable, `false` otherwise.
[315] Fix | Delete
*/
[316] Fix | Delete
function isOverridableBlock(block) {
[317] Fix | Delete
return Object.keys(PARTIAL_SYNCING_SUPPORTED_BLOCKS).includes(block.name) && !!block.attributes.metadata?.name && !!block.attributes.metadata?.bindings && Object.values(block.attributes.metadata.bindings).some(binding => binding.source === 'core/pattern-overrides');
[318] Fix | Delete
}
[319] Fix | Delete
[320] Fix | Delete
/**
[321] Fix | Delete
* Determines whether the blocks list has overridable blocks.
[322] Fix | Delete
*
[323] Fix | Delete
* @param {WPBlock[]} blocks The blocks list.
[324] Fix | Delete
*
[325] Fix | Delete
* @return {boolean} `true` if the list has overridable blocks, `false` otherwise.
[326] Fix | Delete
*/
[327] Fix | Delete
function hasOverridableBlocks(blocks) {
[328] Fix | Delete
return blocks.some(block => {
[329] Fix | Delete
if (isOverridableBlock(block)) {
[330] Fix | Delete
return true;
[331] Fix | Delete
}
[332] Fix | Delete
return hasOverridableBlocks(block.innerBlocks);
[333] Fix | Delete
});
[334] Fix | Delete
}
[335] Fix | Delete
[336] Fix | Delete
;// external "ReactJSXRuntime"
[337] Fix | Delete
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
[338] Fix | Delete
;// ./node_modules/@wordpress/patterns/build-module/components/overrides-panel.js
[339] Fix | Delete
/**
[340] Fix | Delete
* WordPress dependencies
[341] Fix | Delete
*/
[342] Fix | Delete
[343] Fix | Delete
[344] Fix | Delete
[345] Fix | Delete
[346] Fix | Delete
[347] Fix | Delete
[348] Fix | Delete
/**
[349] Fix | Delete
* Internal dependencies
[350] Fix | Delete
*/
[351] Fix | Delete
[352] Fix | Delete
[353] Fix | Delete
[354] Fix | Delete
const {
[355] Fix | Delete
BlockQuickNavigation
[356] Fix | Delete
} = unlock(external_wp_blockEditor_namespaceObject.privateApis);
[357] Fix | Delete
function OverridesPanel() {
[358] Fix | Delete
const allClientIds = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getClientIdsWithDescendants(), []);
[359] Fix | Delete
const {
[360] Fix | Delete
getBlock
[361] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
[362] Fix | Delete
const clientIdsWithOverrides = (0,external_wp_element_namespaceObject.useMemo)(() => allClientIds.filter(clientId => {
[363] Fix | Delete
const block = getBlock(clientId);
[364] Fix | Delete
return isOverridableBlock(block);
[365] Fix | Delete
}), [allClientIds, getBlock]);
[366] Fix | Delete
if (!clientIdsWithOverrides?.length) {
[367] Fix | Delete
return null;
[368] Fix | Delete
}
[369] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
[370] Fix | Delete
title: (0,external_wp_i18n_namespaceObject.__)('Overrides'),
[371] Fix | Delete
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockQuickNavigation, {
[372] Fix | Delete
clientIds: clientIdsWithOverrides
[373] Fix | Delete
})
[374] Fix | Delete
});
[375] Fix | Delete
}
[376] Fix | Delete
[377] Fix | Delete
;// external ["wp","notices"]
[378] Fix | Delete
const external_wp_notices_namespaceObject = window["wp"]["notices"];
[379] Fix | Delete
;// external ["wp","compose"]
[380] Fix | Delete
const external_wp_compose_namespaceObject = window["wp"]["compose"];
[381] Fix | Delete
;// external ["wp","htmlEntities"]
[382] Fix | Delete
const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
[383] Fix | Delete
;// ./node_modules/@wordpress/patterns/build-module/components/category-selector.js
[384] Fix | Delete
/**
[385] Fix | Delete
* WordPress dependencies
[386] Fix | Delete
*/
[387] Fix | Delete
[388] Fix | Delete
[389] Fix | Delete
[390] Fix | Delete
[391] Fix | Delete
[392] Fix | Delete
[393] Fix | Delete
const unescapeString = arg => {
[394] Fix | Delete
return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(arg);
[395] Fix | Delete
};
[396] Fix | Delete
const CATEGORY_SLUG = 'wp_pattern_category';
[397] Fix | Delete
function CategorySelector({
[398] Fix | Delete
categoryTerms,
[399] Fix | Delete
onChange,
[400] Fix | Delete
categoryMap
[401] Fix | Delete
}) {
[402] Fix | Delete
const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)('');
[403] Fix | Delete
const debouncedSearch = (0,external_wp_compose_namespaceObject.useDebounce)(setSearch, 500);
[404] Fix | Delete
const suggestions = (0,external_wp_element_namespaceObject.useMemo)(() => {
[405] Fix | Delete
return Array.from(categoryMap.values()).map(category => unescapeString(category.label)).filter(category => {
[406] Fix | Delete
if (search !== '') {
[407] Fix | Delete
return category.toLowerCase().includes(search.toLowerCase());
[408] Fix | Delete
}
[409] Fix | Delete
return true;
[410] Fix | Delete
}).sort((a, b) => a.localeCompare(b));
[411] Fix | Delete
}, [search, categoryMap]);
[412] Fix | Delete
function handleChange(termNames) {
[413] Fix | Delete
const uniqueTerms = termNames.reduce((terms, newTerm) => {
[414] Fix | Delete
if (!terms.some(term => term.toLowerCase() === newTerm.toLowerCase())) {
[415] Fix | Delete
terms.push(newTerm);
[416] Fix | Delete
}
[417] Fix | Delete
return terms;
[418] Fix | Delete
}, []);
[419] Fix | Delete
onChange(uniqueTerms);
[420] Fix | Delete
}
[421] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FormTokenField, {
[422] Fix | Delete
className: "patterns-menu-items__convert-modal-categories",
[423] Fix | Delete
value: categoryTerms,
[424] Fix | Delete
suggestions: suggestions,
[425] Fix | Delete
onChange: handleChange,
[426] Fix | Delete
onInputChange: debouncedSearch,
[427] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Categories'),
[428] Fix | Delete
tokenizeOnBlur: true,
[429] Fix | Delete
__experimentalExpandOnFocus: true,
[430] Fix | Delete
__next40pxDefaultSize: true,
[431] Fix | Delete
__nextHasNoMarginBottom: true
[432] Fix | Delete
});
[433] Fix | Delete
}
[434] Fix | Delete
[435] Fix | Delete
;// ./node_modules/@wordpress/patterns/build-module/private-hooks.js
[436] Fix | Delete
/**
[437] Fix | Delete
* WordPress dependencies
[438] Fix | Delete
*/
[439] Fix | Delete
[440] Fix | Delete
[441] Fix | Delete
[442] Fix | Delete
[443] Fix | Delete
/**
[444] Fix | Delete
* Internal dependencies
[445] Fix | Delete
*/
[446] Fix | Delete
[447] Fix | Delete
[448] Fix | Delete
/**
[449] Fix | Delete
* Helper hook that creates a Map with the core and user patterns categories
[450] Fix | Delete
* and removes any duplicates. It's used when we need to create new user
[451] Fix | Delete
* categories when creating or importing patterns.
[452] Fix | Delete
* This hook also provides a function to find or create a pattern category.
[453] Fix | Delete
*
[454] Fix | Delete
* @return {Object} The merged categories map and the callback function to find or create a category.
[455] Fix | Delete
*/
[456] Fix | Delete
function useAddPatternCategory() {
[457] Fix | Delete
const {
[458] Fix | Delete
saveEntityRecord,
[459] Fix | Delete
invalidateResolution
[460] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
[461] Fix | Delete
const {
[462] Fix | Delete
corePatternCategories,
[463] Fix | Delete
userPatternCategories
[464] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
[465] Fix | Delete
const {
[466] Fix | Delete
getUserPatternCategories,
[467] Fix | Delete
getBlockPatternCategories
[468] Fix | Delete
} = select(external_wp_coreData_namespaceObject.store);
[469] Fix | Delete
return {
[470] Fix | Delete
corePatternCategories: getBlockPatternCategories(),
[471] Fix | Delete
userPatternCategories: getUserPatternCategories()
[472] Fix | Delete
};
[473] Fix | Delete
}, []);
[474] Fix | Delete
const categoryMap = (0,external_wp_element_namespaceObject.useMemo)(() => {
[475] Fix | Delete
// Merge the user and core pattern categories and remove any duplicates.
[476] Fix | Delete
const uniqueCategories = new Map();
[477] Fix | Delete
userPatternCategories.forEach(category => {
[478] Fix | Delete
uniqueCategories.set(category.label.toLowerCase(), {
[479] Fix | Delete
label: category.label,
[480] Fix | Delete
name: category.name,
[481] Fix | Delete
id: category.id
[482] Fix | Delete
});
[483] Fix | Delete
});
[484] Fix | Delete
corePatternCategories.forEach(category => {
[485] Fix | Delete
if (!uniqueCategories.has(category.label.toLowerCase()) &&
[486] Fix | Delete
// There are two core categories with `Post` label so explicitly remove the one with
[487] Fix | Delete
// the `query` slug to avoid any confusion.
[488] Fix | Delete
category.name !== 'query') {
[489] Fix | Delete
uniqueCategories.set(category.label.toLowerCase(), {
[490] Fix | Delete
label: category.label,
[491] Fix | Delete
name: category.name
[492] Fix | Delete
});
[493] Fix | Delete
}
[494] Fix | Delete
});
[495] Fix | Delete
return uniqueCategories;
[496] Fix | Delete
}, [userPatternCategories, corePatternCategories]);
[497] Fix | Delete
async function findOrCreateTerm(term) {
[498] Fix | Delete
try {
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function