58 __webpack_require__.r(selectors_namespaceObject); |
58 __webpack_require__.r(selectors_namespaceObject); |
59 __webpack_require__.d(selectors_namespaceObject, { |
59 __webpack_require__.d(selectors_namespaceObject, { |
60 isEditingPattern: () => (selectors_isEditingPattern) |
60 isEditingPattern: () => (selectors_isEditingPattern) |
61 }); |
61 }); |
62 |
62 |
63 ;// CONCATENATED MODULE: external ["wp","data"] |
63 ;// external ["wp","data"] |
64 const external_wp_data_namespaceObject = window["wp"]["data"]; |
64 const external_wp_data_namespaceObject = window["wp"]["data"]; |
65 ;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/store/reducer.js |
65 ;// ./node_modules/@wordpress/patterns/build-module/store/reducer.js |
66 /** |
66 /** |
67 * WordPress dependencies |
67 * WordPress dependencies |
68 */ |
68 */ |
69 |
69 |
70 function isEditingPattern(state = {}, action) { |
70 function isEditingPattern(state = {}, action) { |
78 } |
78 } |
79 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ |
79 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ |
80 isEditingPattern |
80 isEditingPattern |
81 })); |
81 })); |
82 |
82 |
83 ;// CONCATENATED MODULE: external ["wp","blocks"] |
83 ;// external ["wp","blocks"] |
84 const external_wp_blocks_namespaceObject = window["wp"]["blocks"]; |
84 const external_wp_blocks_namespaceObject = window["wp"]["blocks"]; |
85 ;// CONCATENATED MODULE: external ["wp","coreData"] |
85 ;// external ["wp","coreData"] |
86 const external_wp_coreData_namespaceObject = window["wp"]["coreData"]; |
86 const external_wp_coreData_namespaceObject = window["wp"]["coreData"]; |
87 ;// CONCATENATED MODULE: external ["wp","blockEditor"] |
87 ;// external ["wp","blockEditor"] |
88 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; |
88 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; |
89 ;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/constants.js |
89 ;// ./node_modules/@wordpress/patterns/build-module/constants.js |
90 const PATTERN_TYPES = { |
90 const PATTERN_TYPES = { |
91 theme: 'pattern', |
91 theme: 'pattern', |
92 user: 'wp_block' |
92 user: 'wp_block' |
93 }; |
93 }; |
94 const PATTERN_DEFAULT_CATEGORY = 'all-patterns'; |
94 const PATTERN_DEFAULT_CATEGORY = 'all-patterns'; |
106 'core/button': ['text', 'url', 'linkTarget', 'rel'], |
106 'core/button': ['text', 'url', 'linkTarget', 'rel'], |
107 'core/image': ['id', 'url', 'title', 'alt'] |
107 'core/image': ['id', 'url', 'title', 'alt'] |
108 }; |
108 }; |
109 const PATTERN_OVERRIDES_BINDING_SOURCE = 'core/pattern-overrides'; |
109 const PATTERN_OVERRIDES_BINDING_SOURCE = 'core/pattern-overrides'; |
110 |
110 |
111 ;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/store/actions.js |
111 ;// ./node_modules/@wordpress/patterns/build-module/store/actions.js |
112 /** |
112 /** |
113 * WordPress dependencies |
113 * WordPress dependencies |
114 */ |
114 */ |
115 |
115 |
116 |
116 |
189 }; |
189 }; |
190 delete metadata.id; |
190 delete metadata.id; |
191 delete metadata.bindings; |
191 delete metadata.bindings; |
192 // Use overridden values of the pattern block if they exist. |
192 // Use overridden values of the pattern block if they exist. |
193 if (existingOverrides?.[metadata.name]) { |
193 if (existingOverrides?.[metadata.name]) { |
194 // Iterate over each overriden attribute. |
194 // Iterate over each overridden attribute. |
195 for (const [attributeName, value] of Object.entries(existingOverrides[metadata.name])) { |
195 for (const [attributeName, value] of Object.entries(existingOverrides[metadata.name])) { |
196 // Skip if the attribute does not exist in the block type. |
196 // Skip if the attribute does not exist in the block type. |
197 if (!(0,external_wp_blocks_namespaceObject.getBlockType)(block.name)?.attributes[attributeName]) { |
197 if (!(0,external_wp_blocks_namespaceObject.getBlockType)(block.name)?.attributes[attributeName]) { |
198 continue; |
198 continue; |
199 } |
199 } |
224 clientId, |
224 clientId, |
225 isEditing |
225 isEditing |
226 }; |
226 }; |
227 } |
227 } |
228 |
228 |
229 ;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/store/constants.js |
229 ;// ./node_modules/@wordpress/patterns/build-module/store/constants.js |
230 /** |
230 /** |
231 * Module Constants |
231 * Module Constants |
232 */ |
232 */ |
233 const STORE_NAME = 'core/patterns'; |
233 const STORE_NAME = 'core/patterns'; |
234 |
234 |
235 ;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/store/selectors.js |
235 ;// ./node_modules/@wordpress/patterns/build-module/store/selectors.js |
236 /** |
236 /** |
237 * Returns true if pattern is in the editing state. |
237 * Returns true if pattern is in the editing state. |
238 * |
238 * |
239 * @param {Object} state Global application state. |
239 * @param {Object} state Global application state. |
240 * @param {number} clientId the clientID of the block. |
240 * @param {number} clientId the clientID of the block. |
242 */ |
242 */ |
243 function selectors_isEditingPattern(state, clientId) { |
243 function selectors_isEditingPattern(state, clientId) { |
244 return state.isEditingPattern[clientId]; |
244 return state.isEditingPattern[clientId]; |
245 } |
245 } |
246 |
246 |
247 ;// CONCATENATED MODULE: external ["wp","privateApis"] |
247 ;// external ["wp","privateApis"] |
248 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; |
248 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; |
249 ;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/lock-unlock.js |
249 ;// ./node_modules/@wordpress/patterns/build-module/lock-unlock.js |
250 /** |
250 /** |
251 * WordPress dependencies |
251 * WordPress dependencies |
252 */ |
252 */ |
253 |
253 |
254 const { |
254 const { |
255 lock, |
255 lock, |
256 unlock |
256 unlock |
257 } = (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'); |
257 } = (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'); |
258 |
258 |
259 ;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/store/index.js |
259 ;// ./node_modules/@wordpress/patterns/build-module/store/index.js |
260 /** |
260 /** |
261 * WordPress dependencies |
261 * WordPress dependencies |
262 */ |
262 */ |
263 |
263 |
264 |
264 |
294 }); |
294 }); |
295 (0,external_wp_data_namespaceObject.register)(store); |
295 (0,external_wp_data_namespaceObject.register)(store); |
296 unlock(store).registerPrivateActions(actions_namespaceObject); |
296 unlock(store).registerPrivateActions(actions_namespaceObject); |
297 unlock(store).registerPrivateSelectors(selectors_namespaceObject); |
297 unlock(store).registerPrivateSelectors(selectors_namespaceObject); |
298 |
298 |
299 ;// CONCATENATED MODULE: external ["wp","components"] |
299 ;// external ["wp","components"] |
300 const external_wp_components_namespaceObject = window["wp"]["components"]; |
300 const external_wp_components_namespaceObject = window["wp"]["components"]; |
301 ;// CONCATENATED MODULE: external ["wp","element"] |
301 ;// external ["wp","element"] |
302 const external_wp_element_namespaceObject = window["wp"]["element"]; |
302 const external_wp_element_namespaceObject = window["wp"]["element"]; |
303 ;// CONCATENATED MODULE: external ["wp","i18n"] |
303 ;// external ["wp","i18n"] |
304 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
304 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
305 ;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/api/index.js |
305 ;// ./node_modules/@wordpress/patterns/build-module/api/index.js |
306 /** |
306 /** |
307 * Internal dependencies |
307 * Internal dependencies |
308 */ |
308 */ |
309 |
309 |
310 |
310 |
333 } |
333 } |
334 return hasOverridableBlocks(block.innerBlocks); |
334 return hasOverridableBlocks(block.innerBlocks); |
335 }); |
335 }); |
336 } |
336 } |
337 |
337 |
338 ;// CONCATENATED MODULE: external "ReactJSXRuntime" |
338 ;// external "ReactJSXRuntime" |
339 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; |
339 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; |
340 ;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/components/overrides-panel.js |
340 ;// ./node_modules/@wordpress/patterns/build-module/components/overrides-panel.js |
341 /** |
341 /** |
342 * WordPress dependencies |
342 * WordPress dependencies |
343 */ |
343 */ |
344 |
344 |
345 |
345 |
374 clientIds: clientIdsWithOverrides |
374 clientIds: clientIdsWithOverrides |
375 }) |
375 }) |
376 }); |
376 }); |
377 } |
377 } |
378 |
378 |
379 ;// CONCATENATED MODULE: external ["wp","notices"] |
379 ;// external ["wp","notices"] |
380 const external_wp_notices_namespaceObject = window["wp"]["notices"]; |
380 const external_wp_notices_namespaceObject = window["wp"]["notices"]; |
381 ;// CONCATENATED MODULE: external ["wp","compose"] |
381 ;// external ["wp","compose"] |
382 const external_wp_compose_namespaceObject = window["wp"]["compose"]; |
382 const external_wp_compose_namespaceObject = window["wp"]["compose"]; |
383 ;// CONCATENATED MODULE: external ["wp","htmlEntities"] |
383 ;// external ["wp","htmlEntities"] |
384 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; |
384 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; |
385 ;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/components/category-selector.js |
385 ;// ./node_modules/@wordpress/patterns/build-module/components/category-selector.js |
386 /** |
386 /** |
387 * WordPress dependencies |
387 * WordPress dependencies |
388 */ |
388 */ |
389 |
389 |
390 |
390 |
558 const defaultModalTitle = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(PATTERN_TYPES.user)?.labels?.add_new_item, []); |
557 const defaultModalTitle = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(PATTERN_TYPES.user)?.labels?.add_new_item, []); |
559 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, { |
558 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, { |
560 title: modalTitle || defaultModalTitle, |
559 title: modalTitle || defaultModalTitle, |
561 onRequestClose: restProps.onClose, |
560 onRequestClose: restProps.onClose, |
562 overlayClassName: className, |
561 overlayClassName: className, |
|
562 focusOnMount: "firstContentElement", |
|
563 size: "small", |
563 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreatePatternModalContents, { |
564 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreatePatternModalContents, { |
564 ...restProps |
565 ...restProps |
565 }) |
566 }) |
566 }); |
567 }); |
567 } |
568 } |
631 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CategorySelector, { |
632 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CategorySelector, { |
632 categoryTerms: categoryTerms, |
633 categoryTerms: categoryTerms, |
633 onChange: setCategoryTerms, |
634 onChange: setCategoryTerms, |
634 categoryMap: categoryMap |
635 categoryMap: categoryMap |
635 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToggleControl, { |
636 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToggleControl, { |
|
637 __nextHasNoMarginBottom: true, |
636 label: (0,external_wp_i18n_namespaceObject._x)('Synced', 'pattern (singular)'), |
638 label: (0,external_wp_i18n_namespaceObject._x)('Synced', 'pattern (singular)'), |
637 help: (0,external_wp_i18n_namespaceObject.__)('Sync this pattern across multiple locations.'), |
639 help: (0,external_wp_i18n_namespaceObject.__)('Sync this pattern across multiple locations.'), |
638 checked: syncType === PATTERN_SYNC_TYPES.full, |
640 checked: syncType === PATTERN_SYNC_TYPES.full, |
639 onChange: () => { |
641 onChange: () => { |
640 setSyncType(syncType === PATTERN_SYNC_TYPES.full ? PATTERN_SYNC_TYPES.unsynced : PATTERN_SYNC_TYPES.full); |
642 setSyncType(syncType === PATTERN_SYNC_TYPES.full ? PATTERN_SYNC_TYPES.unsynced : PATTERN_SYNC_TYPES.full); |
678 |
680 |
679 |
681 |
680 function getTermLabels(pattern, categories) { |
682 function getTermLabels(pattern, categories) { |
681 // Theme patterns rely on core pattern categories. |
683 // Theme patterns rely on core pattern categories. |
682 if (pattern.type !== PATTERN_TYPES.user) { |
684 if (pattern.type !== PATTERN_TYPES.user) { |
683 return categories.core?.filter(category => pattern.categories.includes(category.name)).map(category => category.label); |
685 return categories.core?.filter(category => pattern.categories?.includes(category.name)).map(category => category.label); |
684 } |
686 } |
685 return categories.user?.filter(category => pattern.wp_pattern_category.includes(category.id)).map(category => category.label); |
687 return categories.user?.filter(category => pattern.wp_pattern_category?.includes(category.id)).map(category => category.label); |
686 } |
688 } |
687 function useDuplicatePatternProps({ |
689 function useDuplicatePatternProps({ |
688 pattern, |
690 pattern, |
689 onSuccess |
691 onSuccess |
690 }) { |
692 }) { |
707 return { |
709 return { |
708 content: pattern.content, |
710 content: pattern.content, |
709 defaultCategories: getTermLabels(pattern, categories), |
711 defaultCategories: getTermLabels(pattern, categories), |
710 defaultSyncType: pattern.type !== PATTERN_TYPES.user // Theme patterns are unsynced by default. |
712 defaultSyncType: pattern.type !== PATTERN_TYPES.user // Theme patterns are unsynced by default. |
711 ? PATTERN_SYNC_TYPES.unsynced : pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full, |
713 ? PATTERN_SYNC_TYPES.unsynced : pattern.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full, |
712 defaultTitle: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Existing pattern title */ |
714 defaultTitle: (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: Existing pattern title */ |
713 (0,external_wp_i18n_namespaceObject.__)('%s (Copy)'), typeof pattern.title === 'string' ? pattern.title : pattern.title.raw), |
715 (0,external_wp_i18n_namespaceObject._x)('%s (Copy)', 'pattern'), typeof pattern.title === 'string' ? pattern.title : pattern.title.raw), |
714 onSuccess: ({ |
716 onSuccess: ({ |
715 pattern: newPattern |
717 pattern: newPattern |
716 }) => { |
718 }) => { |
717 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( |
719 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( |
718 // translators: %s: The new pattern's title e.g. 'Call to action (copy)'. |
720 // translators: %s: The new pattern's title e.g. 'Call to action (copy)'. |
719 (0,external_wp_i18n_namespaceObject.__)('"%s" duplicated.'), newPattern.title.raw), { |
721 (0,external_wp_i18n_namespaceObject._x)('"%s" duplicated.', 'pattern'), newPattern.title.raw), { |
720 type: 'snackbar', |
722 type: 'snackbar', |
721 id: 'patterns-create' |
723 id: 'patterns-create' |
722 }); |
724 }); |
723 onSuccess?.({ |
725 onSuccess?.({ |
724 pattern: newPattern |
726 pattern: newPattern |
816 }; |
817 }; |
817 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, { |
818 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, { |
818 title: (0,external_wp_i18n_namespaceObject.__)('Rename'), |
819 title: (0,external_wp_i18n_namespaceObject.__)('Rename'), |
819 ...props, |
820 ...props, |
820 onRequestClose: onClose, |
821 onRequestClose: onClose, |
|
822 focusOnMount: "firstContentElement", |
|
823 size: "small", |
821 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", { |
824 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", { |
822 onSubmit: onRename, |
825 onSubmit: onRename, |
823 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, { |
826 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, { |
824 spacing: "5", |
827 spacing: "5", |
825 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, { |
828 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, { |
863 d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" |
866 d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" |
864 }) |
867 }) |
865 }); |
868 }); |
866 /* harmony default export */ const library_symbol = (symbol); |
869 /* harmony default export */ const library_symbol = (symbol); |
867 |
870 |
868 ;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/components/pattern-convert-button.js |
871 ;// ./node_modules/@wordpress/patterns/build-module/components/pattern-convert-button.js |
869 /** |
872 /** |
870 * WordPress dependencies |
873 * WordPress dependencies |
871 */ |
874 */ |
872 |
875 |
873 |
876 |
893 * @param {string[]} props.clientIds Client ids of selected blocks. |
896 * @param {string[]} props.clientIds Client ids of selected blocks. |
894 * @param {string} props.rootClientId ID of the currently selected top-level block. |
897 * @param {string} props.rootClientId ID of the currently selected top-level block. |
895 * @param {()=>void} props.closeBlockSettingsMenu Callback to close the block settings menu dropdown. |
898 * @param {()=>void} props.closeBlockSettingsMenu Callback to close the block settings menu dropdown. |
896 * @return {import('react').ComponentType} The menu control or null. |
899 * @return {import('react').ComponentType} The menu control or null. |
897 */ |
900 */ |
898 |
|
899 |
|
900 |
901 |
901 function PatternConvertButton({ |
902 function PatternConvertButton({ |
902 clientIds, |
903 clientIds, |
903 rootClientId, |
904 rootClientId, |
904 closeBlockSettingsMenu |
905 closeBlockSettingsMenu |
925 canInsertBlockType, |
926 canInsertBlockType, |
926 getBlockRootClientId |
927 getBlockRootClientId |
927 } = select(external_wp_blockEditor_namespaceObject.store); |
928 } = select(external_wp_blockEditor_namespaceObject.store); |
928 const rootId = rootClientId || (clientIds.length > 0 ? getBlockRootClientId(clientIds[0]) : undefined); |
929 const rootId = rootClientId || (clientIds.length > 0 ? getBlockRootClientId(clientIds[0]) : undefined); |
929 const blocks = (_getBlocksByClientId = getBlocksByClientId(clientIds)) !== null && _getBlocksByClientId !== void 0 ? _getBlocksByClientId : []; |
930 const blocks = (_getBlocksByClientId = getBlocksByClientId(clientIds)) !== null && _getBlocksByClientId !== void 0 ? _getBlocksByClientId : []; |
|
931 |
|
932 // Check if the block has reusable support defined. |
|
933 const hasReusableBlockSupport = blockName => { |
|
934 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(blockName); |
|
935 const hasParent = blockType && 'parent' in blockType; |
|
936 |
|
937 // If the block has a parent, check with false as default, otherwise with true. |
|
938 return (0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, 'reusable', !hasParent); |
|
939 }; |
930 const isReusable = blocks.length === 1 && blocks[0] && (0,external_wp_blocks_namespaceObject.isReusableBlock)(blocks[0]) && !!select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_block', blocks[0].attributes.ref); |
940 const isReusable = blocks.length === 1 && blocks[0] && (0,external_wp_blocks_namespaceObject.isReusableBlock)(blocks[0]) && !!select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_block', blocks[0].attributes.ref); |
931 const _canConvert = |
941 const _canConvert = |
932 // Hide when this is already a synced pattern. |
942 // Hide when this is already a synced pattern. |
933 !isReusable && |
943 !isReusable && |
934 // Hide when patterns are disabled. |
944 // Hide when patterns are disabled. |
936 // Guard against the case where a regular block has *just* been converted. |
946 // Guard against the case where a regular block has *just* been converted. |
937 !!block && |
947 !!block && |
938 // Hide on invalid blocks. |
948 // Hide on invalid blocks. |
939 block.isValid && |
949 block.isValid && |
940 // Hide when block doesn't support being made into a pattern. |
950 // Hide when block doesn't support being made into a pattern. |
941 (0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'reusable', true)) && |
951 hasReusableBlockSupport(block.name)) && |
942 // Hide when current doesn't have permission to do that. |
952 // Hide when current doesn't have permission to do that. |
943 !!canUser('create', 'blocks'); |
953 // Blocks refers to the wp_block post type, this checks the ability to create a post of that type. |
|
954 !!canUser('create', { |
|
955 kind: 'postType', |
|
956 name: 'wp_block' |
|
957 }); |
944 return _canConvert; |
958 return _canConvert; |
945 }, [clientIds, rootClientId]); |
959 }, [clientIds, rootClientId]); |
946 const { |
960 const { |
947 getBlocksByClientId |
961 getBlocksByClientId |
948 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store); |
962 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store); |
1032 canUser |
1044 canUser |
1033 } = select(external_wp_coreData_namespaceObject.store); |
1045 } = select(external_wp_coreData_namespaceObject.store); |
1034 const reusableBlock = getBlock(clientId); |
1046 const reusableBlock = getBlock(clientId); |
1035 return { |
1047 return { |
1036 canRemove: canRemoveBlock(clientId), |
1048 canRemove: canRemoveBlock(clientId), |
1037 isVisible: !!reusableBlock && (0,external_wp_blocks_namespaceObject.isReusableBlock)(reusableBlock) && !!canUser('update', 'blocks', reusableBlock.attributes.ref), |
1049 isVisible: !!reusableBlock && (0,external_wp_blocks_namespaceObject.isReusableBlock)(reusableBlock) && !!canUser('update', { |
|
1050 kind: 'postType', |
|
1051 name: 'wp_block', |
|
1052 id: reusableBlock.attributes.ref |
|
1053 }), |
1038 innerBlockCount: getBlockCount(clientId), |
1054 innerBlockCount: getBlockCount(clientId), |
1039 // The site editor and templates both check whether the user |
1055 // The site editor and templates both check whether the user |
1040 // has edit_theme_options capabilities. We can leverage that here |
1056 // has edit_theme_options capabilities. We can leverage that here |
1041 // and omit the manage patterns link if the user can't access it. |
1057 // and omit the manage patterns link if the user can't access it. |
1042 managePatternsUrl: canUser('create', 'templates') ? (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', { |
1058 managePatternsUrl: canUser('create', { |
|
1059 kind: 'postType', |
|
1060 name: 'wp_template' |
|
1061 }) ? (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', { |
1043 path: '/patterns' |
1062 path: '/patterns' |
1044 }) : (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', { |
1063 }) : (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', { |
1045 post_type: 'wp_block' |
1064 post_type: 'wp_block' |
1046 }) |
1065 }) |
1047 }; |
1066 }; |
1272 const [editedBlockName, setEditedBlockName] = (0,external_wp_element_namespaceObject.useState)(initialName); |
1287 const [editedBlockName, setEditedBlockName] = (0,external_wp_element_namespaceObject.useState)(initialName); |
1273 const descriptionId = (0,external_wp_element_namespaceObject.useId)(); |
1288 const descriptionId = (0,external_wp_element_namespaceObject.useId)(); |
1274 const isNameValid = !!editedBlockName.trim(); |
1289 const isNameValid = !!editedBlockName.trim(); |
1275 const handleSubmit = () => { |
1290 const handleSubmit = () => { |
1276 if (editedBlockName !== initialName) { |
1291 if (editedBlockName !== initialName) { |
1277 const message = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: new name/label for the block */ |
1292 const message = (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: new name/label for the block */ |
1278 (0,external_wp_i18n_namespaceObject.__)('Block name changed to: "%s".'), editedBlockName); |
1293 (0,external_wp_i18n_namespaceObject.__)('Block name changed to: "%s".'), editedBlockName); |
1279 |
1294 |
1280 // Must be assertive to immediately announce change. |
1295 // Must be assertive to immediately announce change. |
1281 (0,external_wp_a11y_namespaceObject.speak)(message, 'assertive'); |
1296 (0,external_wp_a11y_namespaceObject.speak)(message, 'assertive'); |
1282 } |
1297 } |
1388 * Internal dependencies |
1403 * Internal dependencies |
1389 */ |
1404 */ |
1390 |
1405 |
1391 |
1406 |
1392 |
1407 |
1393 |
|
1394 |
|
1395 function removeBindings(bindings) { |
|
1396 let updatedBindings = { |
|
1397 ...bindings |
|
1398 }; |
|
1399 delete updatedBindings.__default; |
|
1400 if (!Object.keys(updatedBindings).length) { |
|
1401 updatedBindings = undefined; |
|
1402 } |
|
1403 return updatedBindings; |
|
1404 } |
|
1405 function addBindings(bindings) { |
|
1406 return { |
|
1407 ...bindings, |
|
1408 __default: { |
|
1409 source: PATTERN_OVERRIDES_BINDING_SOURCE |
|
1410 } |
|
1411 }; |
|
1412 } |
|
1413 function PatternOverridesControls({ |
1408 function PatternOverridesControls({ |
1414 attributes, |
1409 attributes, |
1415 setAttributes, |
1410 setAttributes, |
1416 name: blockName |
1411 name: blockName |
1417 }) { |
1412 }) { |
1420 const [showDisallowOverridesModal, setShowDisallowOverridesModal] = (0,external_wp_element_namespaceObject.useState)(false); |
1415 const [showDisallowOverridesModal, setShowDisallowOverridesModal] = (0,external_wp_element_namespaceObject.useState)(false); |
1421 const hasName = !!attributes.metadata?.name; |
1416 const hasName = !!attributes.metadata?.name; |
1422 const defaultBindings = attributes.metadata?.bindings?.__default; |
1417 const defaultBindings = attributes.metadata?.bindings?.__default; |
1423 const hasOverrides = hasName && defaultBindings?.source === PATTERN_OVERRIDES_BINDING_SOURCE; |
1418 const hasOverrides = hasName && defaultBindings?.source === PATTERN_OVERRIDES_BINDING_SOURCE; |
1424 const isConnectedToOtherSources = defaultBindings?.source && defaultBindings.source !== PATTERN_OVERRIDES_BINDING_SOURCE; |
1419 const isConnectedToOtherSources = defaultBindings?.source && defaultBindings.source !== PATTERN_OVERRIDES_BINDING_SOURCE; |
|
1420 const { |
|
1421 updateBlockBindings |
|
1422 } = (0,external_wp_blockEditor_namespaceObject.useBlockBindingsUtils)(); |
1425 function updateBindings(isChecked, customName) { |
1423 function updateBindings(isChecked, customName) { |
1426 const prevBindings = attributes?.metadata?.bindings; |
|
1427 const updatedBindings = isChecked ? addBindings(prevBindings) : removeBindings(prevBindings); |
|
1428 const updatedMetadata = { |
|
1429 ...attributes.metadata, |
|
1430 bindings: updatedBindings |
|
1431 }; |
|
1432 if (customName) { |
1424 if (customName) { |
1433 updatedMetadata.name = customName; |
1425 setAttributes({ |
1434 } |
1426 metadata: { |
1435 setAttributes({ |
1427 ...attributes.metadata, |
1436 metadata: updatedMetadata |
1428 name: customName |
|
1429 } |
|
1430 }); |
|
1431 } |
|
1432 updateBlockBindings({ |
|
1433 __default: isChecked ? { |
|
1434 source: PATTERN_OVERRIDES_BINDING_SOURCE |
|
1435 } : undefined |
1437 }); |
1436 }); |
1438 } |
1437 } |
1439 |
1438 |
1440 // Avoid overwriting other (e.g. meta) bindings. |
1439 // Avoid overwriting other (e.g. meta) bindings. |
1441 if (isConnectedToOtherSources) { |
1440 if (isConnectedToOtherSources) { |
1445 const helpText = !hasOverrides && hasUnsupportedImageAttributes ? (0,external_wp_i18n_namespaceObject.__)(`Overrides currently don't support image captions or links. Remove the caption or link first before enabling overrides.`) : (0,external_wp_i18n_namespaceObject.__)('Allow changes to this block throughout instances of this pattern.'); |
1444 const helpText = !hasOverrides && hasUnsupportedImageAttributes ? (0,external_wp_i18n_namespaceObject.__)(`Overrides currently don't support image captions or links. Remove the caption or link first before enabling overrides.`) : (0,external_wp_i18n_namespaceObject.__)('Allow changes to this block throughout instances of this pattern.'); |
1446 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { |
1445 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { |
1447 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.InspectorControls, { |
1446 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.InspectorControls, { |
1448 group: "advanced", |
1447 group: "advanced", |
1449 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.BaseControl, { |
1448 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.BaseControl, { |
|
1449 __nextHasNoMarginBottom: true, |
1450 id: controlId, |
1450 id: controlId, |
1451 label: (0,external_wp_i18n_namespaceObject.__)('Overrides'), |
1451 label: (0,external_wp_i18n_namespaceObject.__)('Overrides'), |
1452 help: helpText, |
1452 help: helpText, |
1453 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, { |
1453 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, { |
1454 __next40pxDefaultSize: true, |
1454 __next40pxDefaultSize: true, |
1461 } else { |
1461 } else { |
1462 setShowAllowOverridesModal(true); |
1462 setShowAllowOverridesModal(true); |
1463 } |
1463 } |
1464 }, |
1464 }, |
1465 disabled: !hasOverrides && hasUnsupportedImageAttributes, |
1465 disabled: !hasOverrides && hasUnsupportedImageAttributes, |
1466 __experimentalIsFocusable: true, |
1466 accessibleWhenDisabled: true, |
1467 children: hasOverrides ? (0,external_wp_i18n_namespaceObject.__)('Disable overrides') : (0,external_wp_i18n_namespaceObject.__)('Enable overrides') |
1467 children: hasOverrides ? (0,external_wp_i18n_namespaceObject.__)('Disable overrides') : (0,external_wp_i18n_namespaceObject.__)('Enable overrides') |
1468 }) |
1468 }) |
1469 }) |
1469 }) |
1470 }), showAllowOverridesModal && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(AllowOverridesModal, { |
1470 }), showAllowOverridesModal && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(AllowOverridesModal, { |
1471 initialName: attributes.metadata?.name, |
1471 initialName: attributes.metadata?.name, |
1492 |
1492 |
1493 const CONTENT = 'content'; |
1493 const CONTENT = 'content'; |
1494 function ResetOverridesControl(props) { |
1494 function ResetOverridesControl(props) { |
1495 const name = props.attributes.metadata?.name; |
1495 const name = props.attributes.metadata?.name; |
1496 const registry = (0,external_wp_data_namespaceObject.useRegistry)(); |
1496 const registry = (0,external_wp_data_namespaceObject.useRegistry)(); |
1497 const isOverriden = (0,external_wp_data_namespaceObject.useSelect)(select => { |
1497 const isOverridden = (0,external_wp_data_namespaceObject.useSelect)(select => { |
1498 if (!name) { |
1498 if (!name) { |
1499 return; |
1499 return; |
1500 } |
1500 } |
1501 const { |
1501 const { |
1502 getBlockAttributes, |
1502 getBlockAttributes, |
1543 } |
1543 } |
1544 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__unstableBlockToolbarLastItem, { |
1544 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__unstableBlockToolbarLastItem, { |
1545 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarGroup, { |
1545 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarGroup, { |
1546 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarButton, { |
1546 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarButton, { |
1547 onClick: onClick, |
1547 onClick: onClick, |
1548 disabled: !isOverriden, |
1548 disabled: !isOverridden, |
1549 __experimentalIsFocusable: true, |
|
1550 children: (0,external_wp_i18n_namespaceObject.__)('Reset') |
1549 children: (0,external_wp_i18n_namespaceObject.__)('Reset') |
1551 }) |
1550 }) |
1552 }) |
1551 }) |
1553 }); |
1552 }); |
1554 } |
1553 } |
1555 |
1554 |
1556 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/copy.js |
1555 ;// ./node_modules/@wordpress/icons/build-module/library/copy.js |
1557 /** |
1556 /** |
1558 * WordPress dependencies |
1557 * WordPress dependencies |
1559 */ |
1558 */ |
1560 |
1559 |
1561 |
1560 |
1568 d: "M5 4.5h11a.5.5 0 0 1 .5.5v11a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V5a.5.5 0 0 1 .5-.5ZM3 5a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm17 3v10.75c0 .69-.56 1.25-1.25 1.25H6v1.5h12.75a2.75 2.75 0 0 0 2.75-2.75V8H20Z" |
1567 d: "M5 4.5h11a.5.5 0 0 1 .5.5v11a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V5a.5.5 0 0 1 .5-.5ZM3 5a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm17 3v10.75c0 .69-.56 1.25-1.25 1.25H6v1.5h12.75a2.75 2.75 0 0 0 2.75-2.75V8H20Z" |
1569 }) |
1568 }) |
1570 }); |
1569 }); |
1571 /* harmony default export */ const library_copy = (copy); |
1570 /* harmony default export */ const library_copy = (copy); |
1572 |
1571 |
1573 ;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/components/pattern-overrides-block-controls.js |
1572 ;// ./node_modules/@wordpress/patterns/build-module/components/pattern-overrides-block-controls.js |
1574 /** |
1573 /** |
1575 * WordPress dependencies |
1574 * WordPress dependencies |
1576 */ |
1575 */ |
1577 |
1576 |
1578 |
1577 |
1629 }, [clientIds, isSingleBlockSelected]); |
1627 }, [clientIds, isSingleBlockSelected]); |
1630 const firstBlockTitle = useBlockDisplayTitle({ |
1628 const firstBlockTitle = useBlockDisplayTitle({ |
1631 clientId: clientIds[0], |
1629 clientId: clientIds[0], |
1632 maximumLength: 35 |
1630 maximumLength: 35 |
1633 }); |
1631 }); |
1634 const blockDescription = isSingleBlockSelected ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %1s: The block type's name; %2s: The block's user-provided name (the same as the override name). */ |
1632 const blockDescription = isSingleBlockSelected ? (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: 1: The block type's name. 2: The block's user-provided name (the same as the override name). */ |
1635 (0,external_wp_i18n_namespaceObject.__)('This %1$s is editable using the "%2$s" override.'), firstBlockTitle.toLowerCase(), firstBlockName) : (0,external_wp_i18n_namespaceObject.__)('These blocks are editable using overrides.'); |
1633 (0,external_wp_i18n_namespaceObject.__)('This %1$s is editable using the "%2$s" override.'), firstBlockTitle.toLowerCase(), firstBlockName) : (0,external_wp_i18n_namespaceObject.__)('These blocks are editable using overrides.'); |
1636 const descriptionId = (0,external_wp_element_namespaceObject.useId)(); |
1634 const descriptionId = (0,external_wp_element_namespaceObject.useId)(); |
1637 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, { |
1635 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, { |
1638 children: toggleProps => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, { |
1636 children: toggleProps => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, { |
1639 className: "patterns-pattern-overrides-toolbar-indicator", |
1637 className: "patterns-pattern-overrides-toolbar-indicator", |
1648 className: "patterns-pattern-overrides-toolbar-indicator-icon", |
1646 className: "patterns-pattern-overrides-toolbar-indicator-icon", |
1649 showColors: true |
1647 showColors: true |
1650 }) |
1648 }) |
1651 }), |
1649 }), |
1652 toggleProps: { |
1650 toggleProps: { |
1653 describedBy: blockDescription, |
1651 description: blockDescription, |
1654 ...toggleProps |
1652 ...toggleProps |
1655 }, |
1653 }, |
1656 menuProps: { |
1654 menuProps: { |
1657 orientation: 'both', |
1655 orientation: 'both', |
1658 'aria-describedby': descriptionId |
1656 'aria-describedby': descriptionId |
1734 EXCLUDED_PATTERN_SOURCES: EXCLUDED_PATTERN_SOURCES, |
1732 EXCLUDED_PATTERN_SOURCES: EXCLUDED_PATTERN_SOURCES, |
1735 PATTERN_SYNC_TYPES: PATTERN_SYNC_TYPES, |
1733 PATTERN_SYNC_TYPES: PATTERN_SYNC_TYPES, |
1736 PARTIAL_SYNCING_SUPPORTED_BLOCKS: PARTIAL_SYNCING_SUPPORTED_BLOCKS |
1734 PARTIAL_SYNCING_SUPPORTED_BLOCKS: PARTIAL_SYNCING_SUPPORTED_BLOCKS |
1737 }); |
1735 }); |
1738 |
1736 |
1739 ;// CONCATENATED MODULE: ./node_modules/@wordpress/patterns/build-module/index.js |
1737 ;// ./node_modules/@wordpress/patterns/build-module/index.js |
1740 /** |
1738 /** |
1741 * Internal dependencies |
1739 * Internal dependencies |
1742 */ |
1740 */ |
1743 |
1741 |
1744 |
1742 |