@wordpress/patterns 2.41.0 → 2.41.1-next.v.202603102151.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/index.cjs +2 -1
- package/build/components/index.cjs.map +2 -2
- package/build/components/pattern-convert-button.cjs +2 -1
- package/build/components/pattern-convert-button.cjs.map +2 -2
- package/build/components/patterns-manage-button.cjs +2 -1
- package/build/components/patterns-manage-button.cjs.map +2 -2
- package/build-module/components/index.mjs +2 -1
- package/build-module/components/index.mjs.map +2 -2
- package/build-module/components/pattern-convert-button.mjs +2 -1
- package/build-module/components/pattern-convert-button.mjs.map +2 -2
- package/build-module/components/patterns-manage-button.mjs +2 -1
- package/build-module/components/patterns-manage-button.mjs.map +2 -2
- package/package.json +17 -17
- package/src/components/index.js +1 -0
- package/src/components/pattern-convert-button.js +2 -1
- package/src/components/patterns-manage-button.js +2 -1
|
@@ -49,7 +49,8 @@ function PatternsMenuItems({ rootClientId }) {
|
|
|
49
49
|
selectedClientIds.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
50
50
|
import_patterns_manage_button.default,
|
|
51
51
|
{
|
|
52
|
-
clientId: selectedClientIds[0]
|
|
52
|
+
clientId: selectedClientIds[0],
|
|
53
|
+
onClose
|
|
53
54
|
}
|
|
54
55
|
)
|
|
55
56
|
] }) });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/components/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { BlockSettingsMenuControls } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport PatternConvertButton from './pattern-convert-button';\nimport PatternsManageButton from './patterns-manage-button';\n\nexport default function PatternsMenuItems( { rootClientId } ) {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<PatternConvertButton\n\t\t\t\t\t\tclientIds={ selectedClientIds }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tcloseBlockSettingsMenu={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t\t{ selectedClientIds.length === 1 && (\n\t\t\t\t\t\t<PatternsManageButton\n\t\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAA0C;AAK1C,oCAAiC;AACjC,oCAAiC;AAM7B;AAJW,SAAR,kBAAoC,EAAE,aAAa,GAAI;AAC7D,SACC,4CAAC,iDACE,WAAE,EAAE,mBAAmB,QAAQ,MAChC,4EACC;AAAA;AAAA,MAAC,8BAAAA;AAAA,MAAA;AAAA,QACA,WAAY;AAAA,QACZ;AAAA,QACA,wBAAyB;AAAA;AAAA,IAC1B;AAAA,IACE,kBAAkB,WAAW,KAC9B;AAAA,MAAC,8BAAAC;AAAA,MAAA;AAAA,QACA,UAAW,kBAAmB,CAAE;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { BlockSettingsMenuControls } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport PatternConvertButton from './pattern-convert-button';\nimport PatternsManageButton from './patterns-manage-button';\n\nexport default function PatternsMenuItems( { rootClientId } ) {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<PatternConvertButton\n\t\t\t\t\t\tclientIds={ selectedClientIds }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tcloseBlockSettingsMenu={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t\t{ selectedClientIds.length === 1 && (\n\t\t\t\t\t\t<PatternsManageButton\n\t\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAA0C;AAK1C,oCAAiC;AACjC,oCAAiC;AAM7B;AAJW,SAAR,kBAAoC,EAAE,aAAa,GAAI;AAC7D,SACC,4CAAC,iDACE,WAAE,EAAE,mBAAmB,QAAQ,MAChC,4EACC;AAAA;AAAA,MAAC,8BAAAA;AAAA,MAAA;AAAA,QACA,WAAY;AAAA,QACZ;AAAA,QACA,wBAAyB;AAAA;AAAA,IAC1B;AAAA,IACE,kBAAkB,WAAW,KAC9B;AAAA,MAAC,8BAAAC;AAAA,MAAA;AAAA,QACA,UAAW,kBAAmB,CAAE;AAAA,QAChC;AAAA;AAAA,IACD;AAAA,KAEF,GAEF;AAEF;",
|
|
6
6
|
"names": ["PatternConvertButton", "PatternsManageButton"]
|
|
7
7
|
}
|
|
@@ -124,7 +124,6 @@ function PatternConvertButton({
|
|
|
124
124
|
});
|
|
125
125
|
replaceBlocks(clientIds, newBlock);
|
|
126
126
|
setEditingPattern(newBlock.clientId, true);
|
|
127
|
-
closeBlockSettingsMenu();
|
|
128
127
|
}
|
|
129
128
|
createSuccessNotice(
|
|
130
129
|
pattern.wp_pattern_sync_status === import_constants.PATTERN_SYNC_TYPES.unsynced ? (0, import_i18n.sprintf)(
|
|
@@ -142,6 +141,7 @@ function PatternConvertButton({
|
|
|
142
141
|
}
|
|
143
142
|
);
|
|
144
143
|
setIsModalOpen(false);
|
|
144
|
+
closeBlockSettingsMenu();
|
|
145
145
|
};
|
|
146
146
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
147
147
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -166,6 +166,7 @@ function PatternConvertButton({
|
|
|
166
166
|
},
|
|
167
167
|
onClose: () => {
|
|
168
168
|
setIsModalOpen(false);
|
|
169
|
+
closeBlockSettingsMenu();
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
172
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/components/pattern-convert-button.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\thasBlockSupport,\n\tisReusableBlock,\n\tcreateBlock,\n\tserialize,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useState, useCallback } from '@wordpress/element';\nimport { MenuItem } from '@wordpress/components';\nimport { symbol } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n/**\n * Internal dependencies\n */\nimport { store as patternsStore } from '../store';\nimport CreatePatternModal from './create-pattern-modal';\nimport { unlock } from '../lock-unlock';\nimport { PATTERN_SYNC_TYPES } from '../constants';\n\n/**\n * Menu control to convert block(s) to a pattern block.\n *\n * @param {Object} props Component props.\n * @param {string[]} props.clientIds Client ids of selected blocks.\n * @param {string} props.rootClientId ID of the currently selected top-level block.\n * @param {()=>void} props.closeBlockSettingsMenu Callback to close the block settings menu dropdown.\n * @return {React.ComponentType} The menu control or null.\n */\nexport default function PatternConvertButton( {\n\tclientIds,\n\trootClientId,\n\tcloseBlockSettingsMenu,\n} ) {\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { replaceBlocks, updateBlockAttributes } =\n\t\tuseDispatch( blockEditorStore );\n\t// Ignore reason: false positive of the lint rule.\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { setEditingPattern } = unlock( useDispatch( patternsStore ) );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { getBlockAttributes } = useSelect( blockEditorStore );\n\tconst canConvert = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst {\n\t\t\t\tgetBlocksByClientId,\n\t\t\t\tcanInsertBlockType,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst rootId =\n\t\t\t\trootClientId ||\n\t\t\t\t( clientIds.length > 0\n\t\t\t\t\t? getBlockRootClientId( clientIds[ 0 ] )\n\t\t\t\t\t: undefined );\n\n\t\t\tconst blocks = getBlocksByClientId( clientIds ) ?? [];\n\n\t\t\t// Check if the block has reusable support defined.\n\t\t\tconst hasReusableBlockSupport = ( blockName ) => {\n\t\t\t\tconst blockType = getBlockType( blockName );\n\t\t\t\tconst hasParent = blockType && 'parent' in blockType;\n\n\t\t\t\t// If the block has a parent, check with false as default, otherwise with true.\n\t\t\t\treturn hasBlockSupport( blockName, 'reusable', ! hasParent );\n\t\t\t};\n\n\t\t\tconst isSyncedPattern =\n\t\t\t\tblocks.length === 1 &&\n\t\t\t\tblocks[ 0 ] &&\n\t\t\t\tisReusableBlock( blocks[ 0 ] ) &&\n\t\t\t\t!! select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tblocks[ 0 ].attributes.ref\n\t\t\t\t);\n\n\t\t\tconst isUnsyncedPattern =\n\t\t\t\tblocks.length === 1 &&\n\t\t\t\tblocks?.[ 0 ]?.attributes?.metadata?.patternName;\n\n\t\t\tconst _canConvert =\n\t\t\t\t// Hide when this is already a pattern.\n\t\t\t\t! isUnsyncedPattern &&\n\t\t\t\t! isSyncedPattern &&\n\t\t\t\t// Hide when patterns are disabled.\n\t\t\t\tcanInsertBlockType( 'core/block', rootId ) &&\n\t\t\t\tblocks.every(\n\t\t\t\t\t( block ) =>\n\t\t\t\t\t\t// Guard against the case where a regular block has *just* been converted.\n\t\t\t\t\t\t!! block &&\n\t\t\t\t\t\t// Hide on invalid blocks.\n\t\t\t\t\t\tblock.isValid &&\n\t\t\t\t\t\t// Hide when block doesn't support being made into a pattern.\n\t\t\t\t\t\thasReusableBlockSupport( block.name )\n\t\t\t\t) &&\n\t\t\t\t// Hide when current doesn't have permission to do that.\n\t\t\t\t// Blocks refers to the wp_block post type, this checks the ability to create a post of that type.\n\t\t\t\t!! canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_block',\n\t\t\t\t} );\n\n\t\t\treturn _canConvert;\n\t\t},\n\t\t[ clientIds, rootClientId ]\n\t);\n\tconst { getBlocksByClientId } = useSelect( blockEditorStore );\n\tconst getContent = useCallback(\n\t\t() => serialize( getBlocksByClientId( clientIds ) ),\n\t\t[ getBlocksByClientId, clientIds ]\n\t);\n\n\tif ( ! canConvert ) {\n\t\treturn null;\n\t}\n\n\tconst handleSuccess = ( { pattern } ) => {\n\t\tif ( pattern.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced ) {\n\t\t\tif ( clientIds?.length === 1 ) {\n\t\t\t\tconst existingAttributes = getBlockAttributes( clientIds[ 0 ] );\n\t\t\t\tupdateBlockAttributes( clientIds[ 0 ], {\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t...( existingAttributes?.metadata\n\t\t\t\t\t\t\t? existingAttributes.metadata\n\t\t\t\t\t\t\t: {} ),\n\t\t\t\t\t\tpatternName: `core/block/${ pattern.id }`,\n\t\t\t\t\t\tname: pattern.title.raw,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t} else {\n\t\t\tconst newBlock = createBlock( 'core/block', {\n\t\t\t\tref: pattern.id,\n\t\t\t} );\n\n\t\t\treplaceBlocks( clientIds, newBlock );\n\t\t\tsetEditingPattern( newBlock.clientId, true );\n\t\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AAS,UAAU,IAAK;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\thasBlockSupport,\n\tisReusableBlock,\n\tcreateBlock,\n\tserialize,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useState, useCallback } from '@wordpress/element';\nimport { MenuItem } from '@wordpress/components';\nimport { symbol } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n/**\n * Internal dependencies\n */\nimport { store as patternsStore } from '../store';\nimport CreatePatternModal from './create-pattern-modal';\nimport { unlock } from '../lock-unlock';\nimport { PATTERN_SYNC_TYPES } from '../constants';\n\n/**\n * Menu control to convert block(s) to a pattern block.\n *\n * @param {Object} props Component props.\n * @param {string[]} props.clientIds Client ids of selected blocks.\n * @param {string} props.rootClientId ID of the currently selected top-level block.\n * @param {()=>void} props.closeBlockSettingsMenu Callback to close the block settings menu dropdown.\n * @return {React.ComponentType} The menu control or null.\n */\nexport default function PatternConvertButton( {\n\tclientIds,\n\trootClientId,\n\tcloseBlockSettingsMenu,\n} ) {\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { replaceBlocks, updateBlockAttributes } =\n\t\tuseDispatch( blockEditorStore );\n\t// Ignore reason: false positive of the lint rule.\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { setEditingPattern } = unlock( useDispatch( patternsStore ) );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { getBlockAttributes } = useSelect( blockEditorStore );\n\tconst canConvert = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst {\n\t\t\t\tgetBlocksByClientId,\n\t\t\t\tcanInsertBlockType,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst rootId =\n\t\t\t\trootClientId ||\n\t\t\t\t( clientIds.length > 0\n\t\t\t\t\t? getBlockRootClientId( clientIds[ 0 ] )\n\t\t\t\t\t: undefined );\n\n\t\t\tconst blocks = getBlocksByClientId( clientIds ) ?? [];\n\n\t\t\t// Check if the block has reusable support defined.\n\t\t\tconst hasReusableBlockSupport = ( blockName ) => {\n\t\t\t\tconst blockType = getBlockType( blockName );\n\t\t\t\tconst hasParent = blockType && 'parent' in blockType;\n\n\t\t\t\t// If the block has a parent, check with false as default, otherwise with true.\n\t\t\t\treturn hasBlockSupport( blockName, 'reusable', ! hasParent );\n\t\t\t};\n\n\t\t\tconst isSyncedPattern =\n\t\t\t\tblocks.length === 1 &&\n\t\t\t\tblocks[ 0 ] &&\n\t\t\t\tisReusableBlock( blocks[ 0 ] ) &&\n\t\t\t\t!! select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tblocks[ 0 ].attributes.ref\n\t\t\t\t);\n\n\t\t\tconst isUnsyncedPattern =\n\t\t\t\tblocks.length === 1 &&\n\t\t\t\tblocks?.[ 0 ]?.attributes?.metadata?.patternName;\n\n\t\t\tconst _canConvert =\n\t\t\t\t// Hide when this is already a pattern.\n\t\t\t\t! isUnsyncedPattern &&\n\t\t\t\t! isSyncedPattern &&\n\t\t\t\t// Hide when patterns are disabled.\n\t\t\t\tcanInsertBlockType( 'core/block', rootId ) &&\n\t\t\t\tblocks.every(\n\t\t\t\t\t( block ) =>\n\t\t\t\t\t\t// Guard against the case where a regular block has *just* been converted.\n\t\t\t\t\t\t!! block &&\n\t\t\t\t\t\t// Hide on invalid blocks.\n\t\t\t\t\t\tblock.isValid &&\n\t\t\t\t\t\t// Hide when block doesn't support being made into a pattern.\n\t\t\t\t\t\thasReusableBlockSupport( block.name )\n\t\t\t\t) &&\n\t\t\t\t// Hide when current doesn't have permission to do that.\n\t\t\t\t// Blocks refers to the wp_block post type, this checks the ability to create a post of that type.\n\t\t\t\t!! canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_block',\n\t\t\t\t} );\n\n\t\t\treturn _canConvert;\n\t\t},\n\t\t[ clientIds, rootClientId ]\n\t);\n\tconst { getBlocksByClientId } = useSelect( blockEditorStore );\n\tconst getContent = useCallback(\n\t\t() => serialize( getBlocksByClientId( clientIds ) ),\n\t\t[ getBlocksByClientId, clientIds ]\n\t);\n\n\tif ( ! canConvert ) {\n\t\treturn null;\n\t}\n\n\tconst handleSuccess = ( { pattern } ) => {\n\t\tif ( pattern.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced ) {\n\t\t\tif ( clientIds?.length === 1 ) {\n\t\t\t\tconst existingAttributes = getBlockAttributes( clientIds[ 0 ] );\n\t\t\t\tupdateBlockAttributes( clientIds[ 0 ], {\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t...( existingAttributes?.metadata\n\t\t\t\t\t\t\t? existingAttributes.metadata\n\t\t\t\t\t\t\t: {} ),\n\t\t\t\t\t\tpatternName: `core/block/${ pattern.id }`,\n\t\t\t\t\t\tname: pattern.title.raw,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t} else {\n\t\t\tconst newBlock = createBlock( 'core/block', {\n\t\t\t\tref: pattern.id,\n\t\t\t} );\n\n\t\t\treplaceBlocks( clientIds, newBlock );\n\t\t\tsetEditingPattern( newBlock.clientId, true );\n\t\t}\n\n\t\tcreateSuccessNotice(\n\t\t\tpattern.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %s: the name the user has given to the pattern.\n\t\t\t\t\t\t__( 'Unsynced pattern created: %s' ),\n\t\t\t\t\t\tpattern.title.raw\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t// translators: %s: the name the user has given to the pattern.\n\t\t\t\t\t\t__( 'Synced pattern created: %s' ),\n\t\t\t\t\t\tpattern.title.raw\n\t\t\t\t ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'convert-to-pattern-success',\n\t\t\t}\n\t\t);\n\t\tsetIsModalOpen( false );\n\t\tcloseBlockSettingsMenu();\n\t};\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\ticon={ symbol }\n\t\t\t\tonClick={ () => setIsModalOpen( true ) }\n\t\t\t\taria-expanded={ isModalOpen }\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t>\n\t\t\t\t{ __( 'Create pattern' ) }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreatePatternModal\n\t\t\t\t\tcontent={ getContent }\n\t\t\t\t\tonSuccess={ ( pattern ) => {\n\t\t\t\t\t\thandleSuccess( pattern );\n\t\t\t\t\t} }\n\t\t\t\t\tonError={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\tcloseBlockSettingsMenu();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAMO;AACP,0BAA0C;AAC1C,qBAAsC;AACtC,wBAAyB;AACzB,mBAAuB;AACvB,kBAAuC;AACvC,uBAAmC;AACnC,kBAA4B;AAC5B,qBAAsC;AAItC,mBAAuC;AACvC,kCAA+B;AAC/B,yBAAuB;AACvB,uBAAmC;AAgJjC;AArIa,SAAR,qBAAuC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,QAAM,EAAE,oBAAoB,QAAI,yBAAa,eAAAA,KAAa;AAC1D,QAAM,EAAE,eAAe,sBAAsB,QAC5C,yBAAa,oBAAAC,KAAiB;AAG/B,QAAM,EAAE,kBAAkB,QAAI,+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AAAA,IACxB;AAAA,IACE,eACD;AAAA,MAAC,4BAAAI;AAAA,MAAA;AAAA,QACA,SAAU;AAAA,QACV,WAAY,CAAE,YAAa;AAC1B,wBAAe,OAAQ;AAAA,QACxB;AAAA,QACA,SAAU,MAAM;AACf,yBAAgB,KAAM;AAAA,QACvB;AAAA,QACA,SAAU,MAAM;AACf,yBAAgB,KAAM;AACtB,iCAAuB;AAAA,QACxB;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;",
|
|
6
6
|
"names": ["noticesStore", "blockEditorStore", "patternsStore", "coreStore", "getBlocksByClientId", "CreatePatternModal"]
|
|
7
7
|
}
|
|
@@ -32,7 +32,7 @@ var import_core_data = require("@wordpress/core-data");
|
|
|
32
32
|
var import_store = require("../store/index.cjs");
|
|
33
33
|
var import_lock_unlock = require("../lock-unlock.cjs");
|
|
34
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
-
function PatternsManageButton({ clientId }) {
|
|
35
|
+
function PatternsManageButton({ clientId, onClose }) {
|
|
36
36
|
const {
|
|
37
37
|
attributes,
|
|
38
38
|
canDetach,
|
|
@@ -101,6 +101,7 @@ function PatternsManageButton({ clientId }) {
|
|
|
101
101
|
metadata: attributesWithoutPatternName
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
|
+
onClose?.();
|
|
104
105
|
},
|
|
105
106
|
children: isSyncedPattern ? (0, import_i18n.__)("Disconnect pattern") : (0, import_i18n.__)("Detach pattern")
|
|
106
107
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/components/patterns-manage-button.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { isReusableBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as patternsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nfunction PatternsManageButton( { clientId } ) {\n\tconst {\n\t\tattributes,\n\t\tcanDetach,\n\t\tisVisible,\n\t\tmanagePatternsUrl,\n\t\tisSyncedPattern,\n\t\tisUnsyncedPattern,\n\t\tcanEdit,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canRemoveBlock, getBlock, canEditBlock } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst block = getBlock( clientId );\n\n\t\t\tconst _isUnsyncedPattern =\n\t\t\t\t!! block?.attributes?.metadata?.patternName;\n\n\t\t\tconst _isSyncedPattern =\n\t\t\t\t!! block &&\n\t\t\t\tisReusableBlock( block ) &&\n\t\t\t\t!! canUser( 'update', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\tid: block.attributes.ref,\n\t\t\t\t} );\n\n\t\t\treturn {\n\t\t\t\tattributes: block.attributes,\n\t\t\t\tcanEdit: canEditBlock( clientId ),\n\t\t\t\t// For unsynced patterns, detaching is simply removing the `patternName` attribute.\n\t\t\t\t// For synced patterns, the `core:block` block is replaced with its inner blocks,\n\t\t\t\t// so checking whether `canRemoveBlock` is possible is required.\n\t\t\t\tcanDetach:\n\t\t\t\t\t_isUnsyncedPattern ||\n\t\t\t\t\t( _isSyncedPattern && canRemoveBlock( clientId ) ),\n\t\t\t\tisUnsyncedPattern: _isUnsyncedPattern,\n\t\t\t\tisSyncedPattern: _isSyncedPattern,\n\t\t\t\tisVisible: _isUnsyncedPattern || _isSyncedPattern,\n\t\t\t\t// The site editor and templates both check whether the user\n\t\t\t\t// has edit_theme_options capabilities. We can leverage that here\n\t\t\t\t// and omit the manage patterns link if the user can't access it.\n\t\t\t\tmanagePatternsUrl: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template',\n\t\t\t\t} )\n\t\t\t\t\t? addQueryArgs( 'site-editor.php', {\n\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t } )\n\t\t\t\t\t: addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\tpost_type: 'wp_block',\n\t\t\t\t\t } ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\t// Ignore reason: false positive of the lint rule.\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { convertSyncedPatternToStatic } = unlock(\n\t\tuseDispatch( patternsStore )\n\t);\n\n\tif ( ! isVisible || ! canEdit ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ canDetach && (\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tif ( isSyncedPattern ) {\n\t\t\t\t\t\t\tconvertSyncedPatternToStatic( clientId );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( isUnsyncedPattern ) {\n\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\tpatternName,\n\t\t\t\t\t\t\t\t...attributesWithoutPatternName\n\t\t\t\t\t\t\t} = attributes?.metadata ?? {};\n\t\t\t\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\t\t\t\tmetadata: attributesWithoutPatternName,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ isSyncedPattern\n\t\t\t\t\t\t? __( 'Disconnect pattern' )\n\t\t\t\t\t\t: __( 'Detach pattern' ) }\n\t\t\t\t</MenuItem>\n\t\t\t) }\n\t\t\t<MenuItem href={ managePatternsUrl }>\n\t\t\t\t{ __( 'Manage patterns' ) }\n\t\t\t</MenuItem>\n\t\t</>\n\t);\n}\n\nexport default PatternsManageButton;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAyB;AACzB,kBAAmB;AACnB,oBAAgC;AAChC,kBAAuC;AACvC,0BAA0C;AAC1C,iBAA6B;AAC7B,uBAAmC;AAKnC,mBAAuC;AACvC,yBAAuB;AAyErB;AAvEF,SAAS,qBAAsB,EAAE,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { isReusableBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as patternsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nfunction PatternsManageButton( { clientId, onClose } ) {\n\tconst {\n\t\tattributes,\n\t\tcanDetach,\n\t\tisVisible,\n\t\tmanagePatternsUrl,\n\t\tisSyncedPattern,\n\t\tisUnsyncedPattern,\n\t\tcanEdit,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canRemoveBlock, getBlock, canEditBlock } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst block = getBlock( clientId );\n\n\t\t\tconst _isUnsyncedPattern =\n\t\t\t\t!! block?.attributes?.metadata?.patternName;\n\n\t\t\tconst _isSyncedPattern =\n\t\t\t\t!! block &&\n\t\t\t\tisReusableBlock( block ) &&\n\t\t\t\t!! canUser( 'update', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\tid: block.attributes.ref,\n\t\t\t\t} );\n\n\t\t\treturn {\n\t\t\t\tattributes: block.attributes,\n\t\t\t\tcanEdit: canEditBlock( clientId ),\n\t\t\t\t// For unsynced patterns, detaching is simply removing the `patternName` attribute.\n\t\t\t\t// For synced patterns, the `core:block` block is replaced with its inner blocks,\n\t\t\t\t// so checking whether `canRemoveBlock` is possible is required.\n\t\t\t\tcanDetach:\n\t\t\t\t\t_isUnsyncedPattern ||\n\t\t\t\t\t( _isSyncedPattern && canRemoveBlock( clientId ) ),\n\t\t\t\tisUnsyncedPattern: _isUnsyncedPattern,\n\t\t\t\tisSyncedPattern: _isSyncedPattern,\n\t\t\t\tisVisible: _isUnsyncedPattern || _isSyncedPattern,\n\t\t\t\t// The site editor and templates both check whether the user\n\t\t\t\t// has edit_theme_options capabilities. We can leverage that here\n\t\t\t\t// and omit the manage patterns link if the user can't access it.\n\t\t\t\tmanagePatternsUrl: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template',\n\t\t\t\t} )\n\t\t\t\t\t? addQueryArgs( 'site-editor.php', {\n\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t } )\n\t\t\t\t\t: addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\tpost_type: 'wp_block',\n\t\t\t\t\t } ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\t// Ignore reason: false positive of the lint rule.\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { convertSyncedPatternToStatic } = unlock(\n\t\tuseDispatch( patternsStore )\n\t);\n\n\tif ( ! isVisible || ! canEdit ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ canDetach && (\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tif ( isSyncedPattern ) {\n\t\t\t\t\t\t\tconvertSyncedPatternToStatic( clientId );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( isUnsyncedPattern ) {\n\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\tpatternName,\n\t\t\t\t\t\t\t\t...attributesWithoutPatternName\n\t\t\t\t\t\t\t} = attributes?.metadata ?? {};\n\t\t\t\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\t\t\t\tmetadata: attributesWithoutPatternName,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClose?.();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ isSyncedPattern\n\t\t\t\t\t\t? __( 'Disconnect pattern' )\n\t\t\t\t\t\t: __( 'Detach pattern' ) }\n\t\t\t\t</MenuItem>\n\t\t\t) }\n\t\t\t<MenuItem href={ managePatternsUrl }>\n\t\t\t\t{ __( 'Manage patterns' ) }\n\t\t\t</MenuItem>\n\t\t</>\n\t);\n}\n\nexport default PatternsManageButton;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAyB;AACzB,kBAAmB;AACnB,oBAAgC;AAChC,kBAAuC;AACvC,0BAA0C;AAC1C,iBAA6B;AAC7B,uBAAmC;AAKnC,mBAAuC;AACvC,yBAAuB;AAyErB;AAvEF,SAAS,qBAAsB,EAAE,UAAU,QAAQ,GAAI;AACtD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,QAAI;AAAA,IACH,CAAE,WAAY;AACb,YAAM,EAAE,gBAAgB,UAAU,aAAa,IAC9C,OAAQ,oBAAAA,KAAiB;AAC1B,YAAM,EAAE,QAAQ,IAAI,OAAQ,iBAAAC,KAAU;AACtC,YAAM,QAAQ,SAAU,QAAS;AAEjC,YAAM,qBACL,CAAC,CAAE,OAAO,YAAY,UAAU;AAEjC,YAAM,mBACL,CAAC,CAAE,aACH,+BAAiB,KAAM,KACvB,CAAC,CAAE,QAAS,UAAU;AAAA,QACrB,MAAM;AAAA,QACN,MAAM;AAAA,QACN,IAAI,MAAM,WAAW;AAAA,MACtB,CAAE;AAEH,aAAO;AAAA,QACN,YAAY,MAAM;AAAA,QAClB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ources": ["../../src/components/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { BlockSettingsMenuControls } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport PatternConvertButton from './pattern-convert-button';\nimport PatternsManageButton from './patterns-manage-button';\n\nexport default function PatternsMenuItems( { rootClientId } ) {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<PatternConvertButton\n\t\t\t\t\t\tclientIds={ selectedClientIds }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tcloseBlockSettingsMenu={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t\t{ selectedClientIds.length === 1 && (\n\t\t\t\t\t\t<PatternsManageButton\n\t\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,iCAAiC;AAK1C,OAAO,0BAA0B;AACjC,OAAO,0BAA0B;AAM7B,mBACC,KADD;AAJW,SAAR,kBAAoC,EAAE,aAAa,GAAI;AAC7D,SACC,oBAAC,6BACE,WAAE,EAAE,mBAAmB,QAAQ,MAChC,iCACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,WAAY;AAAA,QACZ;AAAA,QACA,wBAAyB;AAAA;AAAA,IAC1B;AAAA,IACE,kBAAkB,WAAW,KAC9B;AAAA,MAAC;AAAA;AAAA,QACA,UAAW,kBAAmB,CAAE;AAAA;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { BlockSettingsMenuControls } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport PatternConvertButton from './pattern-convert-button';\nimport PatternsManageButton from './patterns-manage-button';\n\nexport default function PatternsMenuItems( { rootClientId } ) {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<PatternConvertButton\n\t\t\t\t\t\tclientIds={ selectedClientIds }\n\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\tcloseBlockSettingsMenu={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t\t{ selectedClientIds.length === 1 && (\n\t\t\t\t\t\t<PatternsManageButton\n\t\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,iCAAiC;AAK1C,OAAO,0BAA0B;AACjC,OAAO,0BAA0B;AAM7B,mBACC,KADD;AAJW,SAAR,kBAAoC,EAAE,aAAa,GAAI;AAC7D,SACC,oBAAC,6BACE,WAAE,EAAE,mBAAmB,QAAQ,MAChC,iCACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,WAAY;AAAA,QACZ;AAAA,QACA,wBAAyB;AAAA;AAAA,IAC1B;AAAA,IACE,kBAAkB,WAAW,KAC9B;AAAA,MAAC;AAAA;AAAA,QACA,UAAW,kBAAmB,CAAE;AAAA,QAChC;AAAA;AAAA,IACD;AAAA,KAEF,GAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -97,7 +97,6 @@ function PatternConvertButton({
|
|
|
97
97
|
});
|
|
98
98
|
replaceBlocks(clientIds, newBlock);
|
|
99
99
|
setEditingPattern(newBlock.clientId, true);
|
|
100
|
-
closeBlockSettingsMenu();
|
|
101
100
|
}
|
|
102
101
|
createSuccessNotice(
|
|
103
102
|
pattern.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced ? sprintf(
|
|
@@ -115,6 +114,7 @@ function PatternConvertButton({
|
|
|
115
114
|
}
|
|
116
115
|
);
|
|
117
116
|
setIsModalOpen(false);
|
|
117
|
+
closeBlockSettingsMenu();
|
|
118
118
|
};
|
|
119
119
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
120
120
|
/* @__PURE__ */ jsx(
|
|
@@ -139,6 +139,7 @@ function PatternConvertButton({
|
|
|
139
139
|
},
|
|
140
140
|
onClose: () => {
|
|
141
141
|
setIsModalOpen(false);
|
|
142
|
+
closeBlockSettingsMenu();
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/components/pattern-convert-button.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\thasBlockSupport,\n\tisReusableBlock,\n\tcreateBlock,\n\tserialize,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useState, useCallback } from '@wordpress/element';\nimport { MenuItem } from '@wordpress/components';\nimport { symbol } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n/**\n * Internal dependencies\n */\nimport { store as patternsStore } from '../store';\nimport CreatePatternModal from './create-pattern-modal';\nimport { unlock } from '../lock-unlock';\nimport { PATTERN_SYNC_TYPES } from '../constants';\n\n/**\n * Menu control to convert block(s) to a pattern block.\n *\n * @param {Object} props Component props.\n * @param {string[]} props.clientIds Client ids of selected blocks.\n * @param {string} props.rootClientId ID of the currently selected top-level block.\n * @param {()=>void} props.closeBlockSettingsMenu Callback to close the block settings menu dropdown.\n * @return {React.ComponentType} The menu control or null.\n */\nexport default function PatternConvertButton( {\n\tclientIds,\n\trootClientId,\n\tcloseBlockSettingsMenu,\n} ) {\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { replaceBlocks, updateBlockAttributes } =\n\t\tuseDispatch( blockEditorStore );\n\t// Ignore reason: false positive of the lint rule.\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { setEditingPattern } = unlock( useDispatch( patternsStore ) );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { getBlockAttributes } = useSelect( blockEditorStore );\n\tconst canConvert = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst {\n\t\t\t\tgetBlocksByClientId,\n\t\t\t\tcanInsertBlockType,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst rootId =\n\t\t\t\trootClientId ||\n\t\t\t\t( clientIds.length > 0\n\t\t\t\t\t? getBlockRootClientId( clientIds[ 0 ] )\n\t\t\t\t\t: undefined );\n\n\t\t\tconst blocks = getBlocksByClientId( clientIds ) ?? [];\n\n\t\t\t// Check if the block has reusable support defined.\n\t\t\tconst hasReusableBlockSupport = ( blockName ) => {\n\t\t\t\tconst blockType = getBlockType( blockName );\n\t\t\t\tconst hasParent = blockType && 'parent' in blockType;\n\n\t\t\t\t// If the block has a parent, check with false as default, otherwise with true.\n\t\t\t\treturn hasBlockSupport( blockName, 'reusable', ! hasParent );\n\t\t\t};\n\n\t\t\tconst isSyncedPattern =\n\t\t\t\tblocks.length === 1 &&\n\t\t\t\tblocks[ 0 ] &&\n\t\t\t\tisReusableBlock( blocks[ 0 ] ) &&\n\t\t\t\t!! select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tblocks[ 0 ].attributes.ref\n\t\t\t\t);\n\n\t\t\tconst isUnsyncedPattern =\n\t\t\t\tblocks.length === 1 &&\n\t\t\t\tblocks?.[ 0 ]?.attributes?.metadata?.patternName;\n\n\t\t\tconst _canConvert =\n\t\t\t\t// Hide when this is already a pattern.\n\t\t\t\t! isUnsyncedPattern &&\n\t\t\t\t! isSyncedPattern &&\n\t\t\t\t// Hide when patterns are disabled.\n\t\t\t\tcanInsertBlockType( 'core/block', rootId ) &&\n\t\t\t\tblocks.every(\n\t\t\t\t\t( block ) =>\n\t\t\t\t\t\t// Guard against the case where a regular block has *just* been converted.\n\t\t\t\t\t\t!! block &&\n\t\t\t\t\t\t// Hide on invalid blocks.\n\t\t\t\t\t\tblock.isValid &&\n\t\t\t\t\t\t// Hide when block doesn't support being made into a pattern.\n\t\t\t\t\t\thasReusableBlockSupport( block.name )\n\t\t\t\t) &&\n\t\t\t\t// Hide when current doesn't have permission to do that.\n\t\t\t\t// Blocks refers to the wp_block post type, this checks the ability to create a post of that type.\n\t\t\t\t!! canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_block',\n\t\t\t\t} );\n\n\t\t\treturn _canConvert;\n\t\t},\n\t\t[ clientIds, rootClientId ]\n\t);\n\tconst { getBlocksByClientId } = useSelect( blockEditorStore );\n\tconst getContent = useCallback(\n\t\t() => serialize( getBlocksByClientId( clientIds ) ),\n\t\t[ getBlocksByClientId, clientIds ]\n\t);\n\n\tif ( ! canConvert ) {\n\t\treturn null;\n\t}\n\n\tconst handleSuccess = ( { pattern } ) => {\n\t\tif ( pattern.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced ) {\n\t\t\tif ( clientIds?.length === 1 ) {\n\t\t\t\tconst existingAttributes = getBlockAttributes( clientIds[ 0 ] );\n\t\t\t\tupdateBlockAttributes( clientIds[ 0 ], {\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t...( existingAttributes?.metadata\n\t\t\t\t\t\t\t? existingAttributes.metadata\n\t\t\t\t\t\t\t: {} ),\n\t\t\t\t\t\tpatternName: `core/block/${ pattern.id }`,\n\t\t\t\t\t\tname: pattern.title.raw,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t} else {\n\t\t\tconst newBlock = createBlock( 'core/block', {\n\t\t\t\tref: pattern.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ACD,OAAO;AACN,YAAM,WAAW,YAAa,cAAc;AAAA,QAC3C,KAAK,QAAQ;AAAA,MACd,CAAE;AAEF,oBAAe,WAAW,QAAS;AACnC,wBAAmB,SAAS,UAAU,IAAK;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\thasBlockSupport,\n\tisReusableBlock,\n\tcreateBlock,\n\tserialize,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useState, useCallback } from '@wordpress/element';\nimport { MenuItem } from '@wordpress/components';\nimport { symbol } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\n/**\n * Internal dependencies\n */\nimport { store as patternsStore } from '../store';\nimport CreatePatternModal from './create-pattern-modal';\nimport { unlock } from '../lock-unlock';\nimport { PATTERN_SYNC_TYPES } from '../constants';\n\n/**\n * Menu control to convert block(s) to a pattern block.\n *\n * @param {Object} props Component props.\n * @param {string[]} props.clientIds Client ids of selected blocks.\n * @param {string} props.rootClientId ID of the currently selected top-level block.\n * @param {()=>void} props.closeBlockSettingsMenu Callback to close the block settings menu dropdown.\n * @return {React.ComponentType} The menu control or null.\n */\nexport default function PatternConvertButton( {\n\tclientIds,\n\trootClientId,\n\tcloseBlockSettingsMenu,\n} ) {\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst { replaceBlocks, updateBlockAttributes } =\n\t\tuseDispatch( blockEditorStore );\n\t// Ignore reason: false positive of the lint rule.\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { setEditingPattern } = unlock( useDispatch( patternsStore ) );\n\tconst [ isModalOpen, setIsModalOpen ] = useState( false );\n\tconst { getBlockAttributes } = useSelect( blockEditorStore );\n\tconst canConvert = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst {\n\t\t\t\tgetBlocksByClientId,\n\t\t\t\tcanInsertBlockType,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst rootId =\n\t\t\t\trootClientId ||\n\t\t\t\t( clientIds.length > 0\n\t\t\t\t\t? getBlockRootClientId( clientIds[ 0 ] )\n\t\t\t\t\t: undefined );\n\n\t\t\tconst blocks = getBlocksByClientId( clientIds ) ?? [];\n\n\t\t\t// Check if the block has reusable support defined.\n\t\t\tconst hasReusableBlockSupport = ( blockName ) => {\n\t\t\t\tconst blockType = getBlockType( blockName );\n\t\t\t\tconst hasParent = blockType && 'parent' in blockType;\n\n\t\t\t\t// If the block has a parent, check with false as default, otherwise with true.\n\t\t\t\treturn hasBlockSupport( blockName, 'reusable', ! hasParent );\n\t\t\t};\n\n\t\t\tconst isSyncedPattern =\n\t\t\t\tblocks.length === 1 &&\n\t\t\t\tblocks[ 0 ] &&\n\t\t\t\tisReusableBlock( blocks[ 0 ] ) &&\n\t\t\t\t!! select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tblocks[ 0 ].attributes.ref\n\t\t\t\t);\n\n\t\t\tconst isUnsyncedPattern =\n\t\t\t\tblocks.length === 1 &&\n\t\t\t\tblocks?.[ 0 ]?.attributes?.metadata?.patternName;\n\n\t\t\tconst _canConvert =\n\t\t\t\t// Hide when this is already a pattern.\n\t\t\t\t! isUnsyncedPattern &&\n\t\t\t\t! isSyncedPattern &&\n\t\t\t\t// Hide when patterns are disabled.\n\t\t\t\tcanInsertBlockType( 'core/block', rootId ) &&\n\t\t\t\tblocks.every(\n\t\t\t\t\t( block ) =>\n\t\t\t\t\t\t// Guard against the case where a regular block has *just* been converted.\n\t\t\t\t\t\t!! block &&\n\t\t\t\t\t\t// Hide on invalid blocks.\n\t\t\t\t\t\tblock.isValid &&\n\t\t\t\t\t\t// Hide when block doesn't support being made into a pattern.\n\t\t\t\t\t\thasReusableBlockSupport( block.name )\n\t\t\t\t) &&\n\t\t\t\t// Hide when current doesn't have permission to do that.\n\t\t\t\t// Blocks refers to the wp_block post type, this checks the ability to create a post of that type.\n\t\t\t\t!! canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_block',\n\t\t\t\t} );\n\n\t\t\treturn _canConvert;\n\t\t},\n\t\t[ clientIds, rootClientId ]\n\t);\n\tconst { getBlocksByClientId } = useSelect( blockEditorStore );\n\tconst getContent = useCallback(\n\t\t() => serialize( getBlocksByClientId( clientIds ) ),\n\t\t[ getBlocksByClientId, clientIds ]\n\t);\n\n\tif ( ! canConvert ) {\n\t\treturn null;\n\t}\n\n\tconst handleSuccess = ( { pattern } ) => {\n\t\tif ( pattern.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced ) {\n\t\t\tif ( clientIds?.length === 1 ) {\n\t\t\t\tconst existingAttributes = getBlockAttributes( clientIds[ 0 ] );\n\t\t\t\tupdateBlockAttributes( clientIds[ 0 ], {\n\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t...( existingAttributes?.metadata\n\t\t\t\t\t\t\t? existingAttributes.metadata\n\t\t\t\t\t\t\t: {} ),\n\t\t\t\t\t\tpatternName: `core/block/${ pattern.id }`,\n\t\t\t\t\t\tname: pattern.title.raw,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t} else {\n\t\t\tconst newBlock = createBlock( 'core/block', {\n\t\t\t\tref: pattern.id,\n\t\t\t} );\n\n\t\t\treplaceBlocks( clientIds, newBlock );\n\t\t\tsetEditingPattern( newBlock.clientId, true );\n\t\t}\n\n\t\tcreateSuccessNotice(\n\t\t\tpattern.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced\n\t\t\t\t? sprintf(\n\t\t\t\t\t\t// translators: %s: the name the user has given to the pattern.\n\t\t\t\t\t\t__( 'Unsynced pattern created: %s' ),\n\t\t\t\t\t\tpattern.title.raw\n\t\t\t\t )\n\t\t\t\t: sprintf(\n\t\t\t\t\t\t// translators: %s: the name the user has given to the pattern.\n\t\t\t\t\t\t__( 'Synced pattern created: %s' ),\n\t\t\t\t\t\tpattern.title.raw\n\t\t\t\t ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tid: 'convert-to-pattern-success',\n\t\t\t}\n\t\t);\n\t\tsetIsModalOpen( false );\n\t\tcloseBlockSettingsMenu();\n\t};\n\treturn (\n\t\t<>\n\t\t\t<MenuItem\n\t\t\t\ticon={ symbol }\n\t\t\t\tonClick={ () => setIsModalOpen( true ) }\n\t\t\t\taria-expanded={ isModalOpen }\n\t\t\t\taria-haspopup=\"dialog\"\n\t\t\t>\n\t\t\t\t{ __( 'Create pattern' ) }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<CreatePatternModal\n\t\t\t\t\tcontent={ getContent }\n\t\t\t\t\tonSuccess={ ( pattern ) => {\n\t\t\t\t\t\thandleSuccess( pattern );\n\t\t\t\t\t} }\n\t\t\t\t\tonError={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t} }\n\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\tsetIsModalOpen( false );\n\t\t\t\t\t\tcloseBlockSettingsMenu();\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,SAAS,wBAAwB;AAC1C,SAAS,UAAU,mBAAmB;AACtC,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,WAAW,mBAAmB;AACvC,SAAS,SAAS,iBAAiB;AACnC,SAAS,IAAI,eAAe;AAC5B,SAAS,SAAS,oBAAoB;AAItC,SAAS,SAAS,qBAAqB;AACvC,OAAO,wBAAwB;AAC/B,SAAS,cAAc;AACvB,SAAS,0BAA0B;A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ACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,MAAO;AAAA,QACP,SAAU,MAAM,eAAgB,IAAK;AAAA,QACrC,iBAAgB;AAAA,QAChB,iBAAc;AAAA,QAEZ,aAAI,gBAAiB;AAAA;AAAA,IACxB;AAAA,IACE,eACD;AAAA,MAAC;AAAA;AAAA,QACA,SAAU;AAAA,QACV,WAAY,CAAE,YAAa;AAC1B,wBAAe,OAAQ;AAAA,QACxB;AAAA,QACA,SAAU,MAAM;AACf,yBAAgB,KAAM;AAAA,QACvB;AAAA,QACA,SAAU,MAAM;AACf,yBAAgB,KAAM;AACtB,iCAAuB;AAAA,QACxB;AAAA;AAAA,IACD;AAAA,KAEF;AAEF;",
|
|
6
6
|
"names": ["getBlocksByClientId"]
|
|
7
7
|
}
|
|
@@ -9,7 +9,7 @@ import { store as coreStore } from "@wordpress/core-data";
|
|
|
9
9
|
import { store as patternsStore } from "../store/index.mjs";
|
|
10
10
|
import { unlock } from "../lock-unlock.mjs";
|
|
11
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
function PatternsManageButton({ clientId }) {
|
|
12
|
+
function PatternsManageButton({ clientId, onClose }) {
|
|
13
13
|
const {
|
|
14
14
|
attributes,
|
|
15
15
|
canDetach,
|
|
@@ -78,6 +78,7 @@ function PatternsManageButton({ clientId }) {
|
|
|
78
78
|
metadata: attributesWithoutPatternName
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
+
onClose?.();
|
|
81
82
|
},
|
|
82
83
|
children: isSyncedPattern ? __("Disconnect pattern") : __("Detach pattern")
|
|
83
84
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/components/patterns-manage-button.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { isReusableBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as patternsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nfunction PatternsManageButton( { clientId } ) {\n\tconst {\n\t\tattributes,\n\t\tcanDetach,\n\t\tisVisible,\n\t\tmanagePatternsUrl,\n\t\tisSyncedPattern,\n\t\tisUnsyncedPattern,\n\t\tcanEdit,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canRemoveBlock, getBlock, canEditBlock } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst block = getBlock( clientId );\n\n\t\t\tconst _isUnsyncedPattern =\n\t\t\t\t!! block?.attributes?.metadata?.patternName;\n\n\t\t\tconst _isSyncedPattern =\n\t\t\t\t!! block &&\n\t\t\t\tisReusableBlock( block ) &&\n\t\t\t\t!! canUser( 'update', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\tid: block.attributes.ref,\n\t\t\t\t} );\n\n\t\t\treturn {\n\t\t\t\tattributes: block.attributes,\n\t\t\t\tcanEdit: canEditBlock( clientId ),\n\t\t\t\t// For unsynced patterns, detaching is simply removing the `patternName` attribute.\n\t\t\t\t// For synced patterns, the `core:block` block is replaced with its inner blocks,\n\t\t\t\t// so checking whether `canRemoveBlock` is possible is required.\n\t\t\t\tcanDetach:\n\t\t\t\t\t_isUnsyncedPattern ||\n\t\t\t\t\t( _isSyncedPattern && canRemoveBlock( clientId ) ),\n\t\t\t\tisUnsyncedPattern: _isUnsyncedPattern,\n\t\t\t\tisSyncedPattern: _isSyncedPattern,\n\t\t\t\tisVisible: _isUnsyncedPattern || _isSyncedPattern,\n\t\t\t\t// The site editor and templates both check whether the user\n\t\t\t\t// has edit_theme_options capabilities. We can leverage that here\n\t\t\t\t// and omit the manage patterns link if the user can't access it.\n\t\t\t\tmanagePatternsUrl: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template',\n\t\t\t\t} )\n\t\t\t\t\t? addQueryArgs( 'site-editor.php', {\n\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t } )\n\t\t\t\t\t: addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\tpost_type: 'wp_block',\n\t\t\t\t\t } ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\t// Ignore reason: false positive of the lint rule.\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { convertSyncedPatternToStatic } = unlock(\n\t\tuseDispatch( patternsStore )\n\t);\n\n\tif ( ! isVisible || ! canEdit ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ canDetach && (\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tif ( isSyncedPattern ) {\n\t\t\t\t\t\t\tconvertSyncedPatternToStatic( clientId );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( isUnsyncedPattern ) {\n\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\tpatternName,\n\t\t\t\t\t\t\t\t...attributesWithoutPatternName\n\t\t\t\t\t\t\t} = attributes?.metadata ?? {};\n\t\t\t\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\t\t\t\tmetadata: attributesWithoutPatternName,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ isSyncedPattern\n\t\t\t\t\t\t? __( 'Disconnect pattern' )\n\t\t\t\t\t\t: __( 'Detach pattern' ) }\n\t\t\t\t</MenuItem>\n\t\t\t) }\n\t\t\t<MenuItem href={ managePatternsUrl }>\n\t\t\t\t{ __( 'Manage patterns' ) }\n\t\t\t</MenuItem>\n\t\t</>\n\t);\n}\n\nexport default PatternsManageButton;\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,gBAAgB;AACzB,SAAS,UAAU;AACnB,SAAS,uBAAuB;AAChC,SAAS,WAAW,mBAAmB;AACvC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,oBAAoB;AAC7B,SAAS,SAAS,iBAAiB;AAKnC,SAAS,SAAS,qBAAqB;AACvC,SAAS,cAAc;AAyErB,mBAEE,KAFF;AAvEF,SAAS,qBAAsB,EAAE,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { isReusableBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as patternsStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nfunction PatternsManageButton( { clientId, onClose } ) {\n\tconst {\n\t\tattributes,\n\t\tcanDetach,\n\t\tisVisible,\n\t\tmanagePatternsUrl,\n\t\tisSyncedPattern,\n\t\tisUnsyncedPattern,\n\t\tcanEdit,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canRemoveBlock, getBlock, canEditBlock } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst block = getBlock( clientId );\n\n\t\t\tconst _isUnsyncedPattern =\n\t\t\t\t!! block?.attributes?.metadata?.patternName;\n\n\t\t\tconst _isSyncedPattern =\n\t\t\t\t!! block &&\n\t\t\t\tisReusableBlock( block ) &&\n\t\t\t\t!! canUser( 'update', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\tid: block.attributes.ref,\n\t\t\t\t} );\n\n\t\t\treturn {\n\t\t\t\tattributes: block.attributes,\n\t\t\t\tcanEdit: canEditBlock( clientId ),\n\t\t\t\t// For unsynced patterns, detaching is simply removing the `patternName` attribute.\n\t\t\t\t// For synced patterns, the `core:block` block is replaced with its inner blocks,\n\t\t\t\t// so checking whether `canRemoveBlock` is possible is required.\n\t\t\t\tcanDetach:\n\t\t\t\t\t_isUnsyncedPattern ||\n\t\t\t\t\t( _isSyncedPattern && canRemoveBlock( clientId ) ),\n\t\t\t\tisUnsyncedPattern: _isUnsyncedPattern,\n\t\t\t\tisSyncedPattern: _isSyncedPattern,\n\t\t\t\tisVisible: _isUnsyncedPattern || _isSyncedPattern,\n\t\t\t\t// The site editor and templates both check whether the user\n\t\t\t\t// has edit_theme_options capabilities. We can leverage that here\n\t\t\t\t// and omit the manage patterns link if the user can't access it.\n\t\t\t\tmanagePatternsUrl: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template',\n\t\t\t\t} )\n\t\t\t\t\t? addQueryArgs( 'site-editor.php', {\n\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t } )\n\t\t\t\t\t: addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\tpost_type: 'wp_block',\n\t\t\t\t\t } ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\t// Ignore reason: false positive of the lint rule.\n\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\tconst { convertSyncedPatternToStatic } = unlock(\n\t\tuseDispatch( patternsStore )\n\t);\n\n\tif ( ! isVisible || ! canEdit ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ canDetach && (\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tif ( isSyncedPattern ) {\n\t\t\t\t\t\t\tconvertSyncedPatternToStatic( clientId );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif ( isUnsyncedPattern ) {\n\t\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\t\tpatternName,\n\t\t\t\t\t\t\t\t...attributesWithoutPatternName\n\t\t\t\t\t\t\t} = attributes?.metadata ?? {};\n\t\t\t\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\t\t\t\tmetadata: attributesWithoutPatternName,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClose?.();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ isSyncedPattern\n\t\t\t\t\t\t? __( 'Disconnect pattern' )\n\t\t\t\t\t\t: __( 'Detach pattern' ) }\n\t\t\t\t</MenuItem>\n\t\t\t) }\n\t\t\t<MenuItem href={ managePatternsUrl }>\n\t\t\t\t{ __( 'Manage patterns' ) }\n\t\t\t</MenuItem>\n\t\t</>\n\t);\n}\n\nexport default PatternsManageButton;\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,gBAAgB;AACzB,SAAS,UAAU;AACnB,SAAS,uBAAuB;AAChC,SAAS,WAAW,mBAAmB;AACvC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,oBAAoB;AAC7B,SAAS,SAAS,iBAAiB;AAKnC,SAAS,SAAS,qBAAqB;AACvC,SAAS,cAAc;AAyErB,mBAEE,KAFF;AAvEF,SAAS,qBAAsB,EAAE,UAAU,QAAQ,GAAI;AACtD,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAAA,IACH,CAAE,WAAY;AACb,YAAM,EAAE,gBAAgB,UAAU,aAAa,IAC9C,OAAQ,gBAAiB;AAC1B,YAAM,EAAE,QAAQ,IAAI,OAAQ,SAAU;AACtC,YAAM,QAAQ,SAAU,QAAS;AAEjC,YAAM,qBACL,CAAC,CAAE,OAAO,YAAY,UAAU;AAEjC,YAAM,mBACL,CAAC,CAAE,SACH,gBAAiB,KAAM,KACvB,CAAC,CAAE,QAAS,U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|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/patterns",
|
|
3
|
-
"version": "2.41.0",
|
|
3
|
+
"version": "2.41.1-next.v.202603102151.0+59e17f9ec",
|
|
4
4
|
"description": "Management of user pattern editing.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -52,21 +52,21 @@
|
|
|
52
52
|
"build-module/store/index.mjs"
|
|
53
53
|
],
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@wordpress/a11y": "^4.41.0",
|
|
56
|
-
"@wordpress/base-styles": "^6.17.0",
|
|
57
|
-
"@wordpress/block-editor": "^15.14.0",
|
|
58
|
-
"@wordpress/blocks": "^15.14.0",
|
|
59
|
-
"@wordpress/components": "^32.
|
|
60
|
-
"@wordpress/compose": "^7.41.0",
|
|
61
|
-
"@wordpress/core-data": "^7.41.0",
|
|
62
|
-
"@wordpress/data": "^10.41.0",
|
|
63
|
-
"@wordpress/element": "^6.41.0",
|
|
64
|
-
"@wordpress/html-entities": "^4.41.0",
|
|
65
|
-
"@wordpress/i18n": "^6.14.0",
|
|
66
|
-
"@wordpress/icons": "^
|
|
67
|
-
"@wordpress/notices": "^5.41.0",
|
|
68
|
-
"@wordpress/private-apis": "^1.41.0",
|
|
69
|
-
"@wordpress/url": "^4.41.0"
|
|
55
|
+
"@wordpress/a11y": "^4.41.1-next.v.202603102151.0+59e17f9ec",
|
|
56
|
+
"@wordpress/base-styles": "^6.17.1-next.v.202603102151.0+59e17f9ec",
|
|
57
|
+
"@wordpress/block-editor": "^15.14.1-next.v.202603102151.0+59e17f9ec",
|
|
58
|
+
"@wordpress/blocks": "^15.14.1-next.v.202603102151.0+59e17f9ec",
|
|
59
|
+
"@wordpress/components": "^32.4.1-next.v.202603102151.0+59e17f9ec",
|
|
60
|
+
"@wordpress/compose": "^7.41.1-next.v.202603102151.0+59e17f9ec",
|
|
61
|
+
"@wordpress/core-data": "^7.41.2-next.v.202603102151.0+59e17f9ec",
|
|
62
|
+
"@wordpress/data": "^10.41.1-next.v.202603102151.0+59e17f9ec",
|
|
63
|
+
"@wordpress/element": "^6.41.1-next.v.202603102151.0+59e17f9ec",
|
|
64
|
+
"@wordpress/html-entities": "^4.41.1-next.v.202603102151.0+59e17f9ec",
|
|
65
|
+
"@wordpress/i18n": "^6.14.1-next.v.202603102151.0+59e17f9ec",
|
|
66
|
+
"@wordpress/icons": "^12.0.1-next.v.202603102151.0+59e17f9ec",
|
|
67
|
+
"@wordpress/notices": "^5.41.1-next.v.202603102151.0+59e17f9ec",
|
|
68
|
+
"@wordpress/private-apis": "^1.41.1-next.v.202603102151.0+59e17f9ec",
|
|
69
|
+
"@wordpress/url": "^4.41.1-next.v.202603102151.0+59e17f9ec"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"react": "^18.0.0",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"publishConfig": {
|
|
76
76
|
"access": "public"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "86db21e727d89e8f0dbba9300d2f97fd22b08693"
|
|
79
79
|
}
|
package/src/components/index.js
CHANGED
|
@@ -143,7 +143,6 @@ export default function PatternConvertButton( {
|
|
|
143
143
|
|
|
144
144
|
replaceBlocks( clientIds, newBlock );
|
|
145
145
|
setEditingPattern( newBlock.clientId, true );
|
|
146
|
-
closeBlockSettingsMenu();
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
createSuccessNotice(
|
|
@@ -164,6 +163,7 @@ export default function PatternConvertButton( {
|
|
|
164
163
|
}
|
|
165
164
|
);
|
|
166
165
|
setIsModalOpen( false );
|
|
166
|
+
closeBlockSettingsMenu();
|
|
167
167
|
};
|
|
168
168
|
return (
|
|
169
169
|
<>
|
|
@@ -186,6 +186,7 @@ export default function PatternConvertButton( {
|
|
|
186
186
|
} }
|
|
187
187
|
onClose={ () => {
|
|
188
188
|
setIsModalOpen( false );
|
|
189
|
+
closeBlockSettingsMenu();
|
|
189
190
|
} }
|
|
190
191
|
/>
|
|
191
192
|
) }
|
|
@@ -15,7 +15,7 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
15
15
|
import { store as patternsStore } from '../store';
|
|
16
16
|
import { unlock } from '../lock-unlock';
|
|
17
17
|
|
|
18
|
-
function PatternsManageButton( { clientId } ) {
|
|
18
|
+
function PatternsManageButton( { clientId, onClose } ) {
|
|
19
19
|
const {
|
|
20
20
|
attributes,
|
|
21
21
|
canDetach,
|
|
@@ -103,6 +103,7 @@ function PatternsManageButton( { clientId } ) {
|
|
|
103
103
|
metadata: attributesWithoutPatternName,
|
|
104
104
|
} );
|
|
105
105
|
}
|
|
106
|
+
onClose?.();
|
|
106
107
|
} }
|
|
107
108
|
>
|
|
108
109
|
{ isSyncedPattern
|