@wordpress/block-library 8.28.3 → 8.29.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/CHANGELOG.md +2 -0
- package/build/buttons/edit.js +1 -6
- package/build/buttons/edit.js.map +1 -1
- package/build/buttons/edit.native.js +1 -7
- package/build/buttons/edit.native.js.map +1 -1
- package/build/columns/edit.js +5 -0
- package/build/columns/edit.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +1 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/details/index.js +1 -0
- package/build/details/index.js.map +1 -1
- package/build/gallery/edit.js +5 -5
- package/build/gallery/edit.js.map +1 -1
- package/build/group/variations.js +12 -15
- package/build/group/variations.js.map +1 -1
- package/build/list/edit.js +5 -0
- package/build/list/edit.js.map +1 -1
- package/build/pattern/edit.js +12 -9
- package/build/pattern/edit.js.map +1 -1
- package/build-module/buttons/edit.js +2 -7
- package/build-module/buttons/edit.js.map +1 -1
- package/build-module/buttons/edit.native.js +1 -7
- package/build-module/buttons/edit.native.js.map +1 -1
- package/build-module/columns/edit.js +5 -0
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +1 -1
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/details/index.js +1 -0
- package/build-module/details/index.js.map +1 -1
- package/build-module/gallery/edit.js +5 -5
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/group/variations.js +12 -15
- package/build-module/group/variations.js.map +1 -1
- package/build-module/list/edit.js +5 -0
- package/build-module/list/edit.js.map +1 -1
- package/build-module/pattern/edit.js +13 -10
- package/build-module/pattern/edit.js.map +1 -1
- package/package.json +34 -34
- package/src/avatar/index.php +12 -1
- package/src/buttons/edit.js +3 -16
- package/src/buttons/edit.native.js +1 -17
- package/src/columns/edit.js +6 -0
- package/src/cover/edit/inspector-controls.js +5 -1
- package/src/details/block.json +1 -0
- package/src/gallery/edit.js +3 -9
- package/src/group/variations.js +3 -6
- package/src/list/edit.js +5 -0
- package/src/pattern/edit.js +13 -10
- package/src/post-author-biography/index.php +4 -3
- package/src/post-author-name/index.php +4 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BlockControls","useBlockProps","useInnerBlocksProps","store","blockEditorStore","ToolbarButton","useDispatch","useSelect","useRegistry","isRTL","__","formatListBullets","formatListBulletsRTL","formatListNumbered","formatListNumberedRTL","formatOutdent","formatOutdentRTL","createBlock","useCallback","useEffect","Platform","deprecated","OrderedListSettings","migrateToListV2","TagName","TEMPLATE","NATIVE_MARGIN_SPACING","useMigrateOnLoad","attributes","clientId","registry","updateBlockAttributes","replaceInnerBlocks","values","newAttributes","newInnerBlocks","since","version","alternative","batch","useOutdentList","replaceBlocks","selectionChange","getBlockRootClientId","getBlockAttributes","getBlock","parentBlockId","parentBlockAttributes","newParentBlock","innerBlocks","length","IndentUI","outdentList","canOutdent","select","getBlockName","createElement","Fragment","icon","title","describedBy","disabled","onClick","Edit","setAttributes","style","ordered","type","reversed","start","blockProps","isNative","listStyleType","undefined","innerBlocksProps","template","templateLock","templateInsertUpdatesSelection","marginVertical","marginHorizontal","renderAppender","__experimentalCaptureToolbars","controls","group","isActive"],"sources":["@wordpress/block-library/src/list/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ToolbarButton } from '@wordpress/components';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport {\n\tformatListBullets,\n\tformatListBulletsRTL,\n\tformatListNumbered,\n\tformatListNumberedRTL,\n\tformatOutdent,\n\tformatOutdentRTL,\n} from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\nimport { useCallback, useEffect, Platform } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport OrderedListSettings from './ordered-list-settings';\nimport { migrateToListV2 } from './utils';\nimport TagName from './tag-name';\n\nconst TEMPLATE = [ [ 'core/list-item' ] ];\nconst NATIVE_MARGIN_SPACING = 8;\n\n/**\n * At the moment, deprecations don't handle create blocks from attributes\n * (like when using CPT templates). For this reason, this hook is necessary\n * to avoid breaking templates using the old list block format.\n *\n * @param {Object} attributes Block attributes.\n * @param {string} clientId Block client ID.\n */\nfunction useMigrateOnLoad( attributes, clientId ) {\n\tconst registry = useRegistry();\n\tconst { updateBlockAttributes, replaceInnerBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\t// As soon as the block is loaded, migrate it to the new version.\n\n\t\tif ( ! attributes.values ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ newAttributes, newInnerBlocks ] = migrateToListV2( attributes );\n\n\t\tdeprecated( 'Value attribute on the list block', {\n\t\t\tsince: '6.0',\n\t\t\tversion: '6.5',\n\t\t\talternative: 'inner blocks',\n\t\t} );\n\n\t\tregistry.batch( () => {\n\t\t\tupdateBlockAttributes( clientId, newAttributes );\n\t\t\treplaceInnerBlocks( clientId, newInnerBlocks );\n\t\t} );\n\t}, [ attributes.values ] );\n}\n\nfunction useOutdentList( clientId ) {\n\tconst { replaceBlocks, selectionChange } = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockAttributes, getBlock } =\n\t\tuseSelect( blockEditorStore );\n\n\treturn useCallback( () => {\n\t\tconst parentBlockId = getBlockRootClientId( clientId );\n\t\tconst parentBlockAttributes = getBlockAttributes( parentBlockId );\n\t\t// Create a new parent block without the inner blocks.\n\t\tconst newParentBlock = createBlock(\n\t\t\t'core/list-item',\n\t\t\tparentBlockAttributes\n\t\t);\n\t\tconst { innerBlocks } = getBlock( clientId );\n\t\t// Replace the parent block with a new parent block without inner blocks,\n\t\t// and make the inner blocks siblings of the parent.\n\t\treplaceBlocks( [ parentBlockId ], [ newParentBlock, ...innerBlocks ] );\n\t\t// Select the last child of the list being outdent.\n\t\tselectionChange( innerBlocks[ innerBlocks.length - 1 ].clientId );\n\t}, [ clientId ] );\n}\n\nfunction IndentUI( { clientId } ) {\n\tconst outdentList = useOutdentList( clientId );\n\tconst canOutdent = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn (\n\t\t\t\tgetBlockName( getBlockRootClientId( clientId ) ) ===\n\t\t\t\t'core/list-item'\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatOutdentRTL : formatOutdent }\n\t\t\t\ttitle={ __( 'Outdent' ) }\n\t\t\t\tdescribedBy={ __( 'Outdent list item' ) }\n\t\t\t\tdisabled={ ! canOutdent }\n\t\t\t\tonClick={ outdentList }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default function Edit( { attributes, setAttributes, clientId, style } ) {\n\tconst { ordered, type, reversed, start } = attributes;\n\tconst blockProps = useBlockProps( {\n\t\tstyle: {\n\t\t\t...( Platform.isNative && style ),\n\t\t\tlistStyleType: ordered && type !== 'decimal' ? type : undefined,\n\t\t},\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t\ttemplateLock: false,\n\t\ttemplateInsertUpdatesSelection: true,\n\t\t...( Platform.isNative && {\n\t\t\tmarginVertical: NATIVE_MARGIN_SPACING,\n\t\t\tmarginHorizontal: NATIVE_MARGIN_SPACING,\n\t\t\trenderAppender: false,\n\t\t} ),\n\t\t__experimentalCaptureToolbars: true,\n\t} );\n\tuseMigrateOnLoad( attributes, clientId );\n\n\tconst controls = (\n\t\t<BlockControls group=\"block\">\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatListBulletsRTL : formatListBullets }\n\t\t\t\ttitle={ __( 'Unordered' ) }\n\t\t\t\tdescribedBy={ __( 'Convert to unordered list' ) }\n\t\t\t\tisActive={ ordered === false }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetAttributes( { ordered: false } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatListNumberedRTL : formatListNumbered }\n\t\t\t\ttitle={ __( 'Ordered' ) }\n\t\t\t\tdescribedBy={ __( 'Convert to ordered list' ) }\n\t\t\t\tisActive={ ordered === true }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetAttributes( { ordered: true } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<IndentUI clientId={ clientId } />\n\t\t</BlockControls>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<TagName\n\t\t\t\tordered={ ordered }\n\t\t\t\treversed={ reversed }\n\t\t\t\tstart={ start }\n\t\t\t\t{ ...innerBlocksProps }\n\t\t\t/>\n\t\t\t{ controls }\n\t\t\t{ ordered && (\n\t\t\t\t<OrderedListSettings\n\t\t\t\t\t{ ...{\n\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\treversed,\n\t\t\t\t\t\tstart,\n\t\t\t\t\t\ttype,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,aAAa,EACbC,mBAAmB,EACnBC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,WAAW,EAAEC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACrE,SAASC,KAAK,EAAEC,EAAE,QAAQ,iBAAiB;AAC3C,SACCC,iBAAiB,EACjBC,oBAAoB,EACpBC,kBAAkB,EAClBC,qBAAqB,EACrBC,aAAa,EACbC,gBAAgB,QACV,kBAAkB;AACzB,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAA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,kBAAoB;IAC7D8C,KAAK,EAAGjD,EAAE,CAAE,SAAU,CAAG;IACzBkD,WAAW,EAAGlD,EAAE,CAAE,yBAA0B,CAAG;IAC/C0E,QAAQ,EAAGlB,OAAO,KAAK,IAAM;IAC7BJ,OAAO,EAAGA,CAAA,KAAM;MACfE,aAAa,CAAE;QAAEE,OAAO,EAAE;MAAK,CAAE,CAAC;IACnC;EAAG,CACH,CAAC,EACFV,aAAA,CAACL,QAAQ;IAACtB,QAAQ,EAAGA;EAAU,CAAE,CACnB,CACf;EAED,OACC2B,aAAA,CAAAC,QAAA,QACCD,aAAA,CAAChC,OAAO;IACP0C,OAAO,EAAGA,OAAS;IACnBE,QAAQ,EAAGA,QAAU;IACrBC,KAAK,EAAGA,KAAO;IAAA,GACVK;EAAgB,CACrB,CAAC,EACAQ,QAAQ,EACRhB,OAAO,IACRV,aAAA,CAAClC,mBAAmB;IAElB0C,aAAa;IACbI,QAAQ;IACRC,KAAK;IACLF;EAAI,CAEL,CAED,CAAC;AAEL"}
|
|
1
|
+
{"version":3,"names":["BlockControls","useBlockProps","useInnerBlocksProps","store","blockEditorStore","ToolbarButton","useDispatch","useSelect","useRegistry","isRTL","__","formatListBullets","formatListBulletsRTL","formatListNumbered","formatListNumberedRTL","formatOutdent","formatOutdentRTL","createBlock","useCallback","useEffect","Platform","deprecated","OrderedListSettings","migrateToListV2","TagName","DEFAULT_BLOCK","name","TEMPLATE","NATIVE_MARGIN_SPACING","useMigrateOnLoad","attributes","clientId","registry","updateBlockAttributes","replaceInnerBlocks","values","newAttributes","newInnerBlocks","since","version","alternative","batch","useOutdentList","replaceBlocks","selectionChange","getBlockRootClientId","getBlockAttributes","getBlock","parentBlockId","parentBlockAttributes","newParentBlock","innerBlocks","length","IndentUI","outdentList","canOutdent","select","getBlockName","createElement","Fragment","icon","title","describedBy","disabled","onClick","Edit","setAttributes","style","ordered","type","reversed","start","blockProps","isNative","listStyleType","undefined","innerBlocksProps","defaultBlock","directInsert","template","templateLock","templateInsertUpdatesSelection","marginVertical","marginHorizontal","renderAppender","__experimentalCaptureToolbars","controls","group","isActive"],"sources":["@wordpress/block-library/src/list/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { ToolbarButton } from '@wordpress/components';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport {\n\tformatListBullets,\n\tformatListBulletsRTL,\n\tformatListNumbered,\n\tformatListNumberedRTL,\n\tformatOutdent,\n\tformatOutdentRTL,\n} from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\nimport { useCallback, useEffect, Platform } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport OrderedListSettings from './ordered-list-settings';\nimport { migrateToListV2 } from './utils';\nimport TagName from './tag-name';\n\nconst DEFAULT_BLOCK = {\n\tname: 'core/list-item',\n};\nconst TEMPLATE = [ [ 'core/list-item' ] ];\nconst NATIVE_MARGIN_SPACING = 8;\n\n/**\n * At the moment, deprecations don't handle create blocks from attributes\n * (like when using CPT templates). For this reason, this hook is necessary\n * to avoid breaking templates using the old list block format.\n *\n * @param {Object} attributes Block attributes.\n * @param {string} clientId Block client ID.\n */\nfunction useMigrateOnLoad( attributes, clientId ) {\n\tconst registry = useRegistry();\n\tconst { updateBlockAttributes, replaceInnerBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\t// As soon as the block is loaded, migrate it to the new version.\n\n\t\tif ( ! attributes.values ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ newAttributes, newInnerBlocks ] = migrateToListV2( attributes );\n\n\t\tdeprecated( 'Value attribute on the list block', {\n\t\t\tsince: '6.0',\n\t\t\tversion: '6.5',\n\t\t\talternative: 'inner blocks',\n\t\t} );\n\n\t\tregistry.batch( () => {\n\t\t\tupdateBlockAttributes( clientId, newAttributes );\n\t\t\treplaceInnerBlocks( clientId, newInnerBlocks );\n\t\t} );\n\t}, [ attributes.values ] );\n}\n\nfunction useOutdentList( clientId ) {\n\tconst { replaceBlocks, selectionChange } = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockAttributes, getBlock } =\n\t\tuseSelect( blockEditorStore );\n\n\treturn useCallback( () => {\n\t\tconst parentBlockId = getBlockRootClientId( clientId );\n\t\tconst parentBlockAttributes = getBlockAttributes( parentBlockId );\n\t\t// Create a new parent block without the inner blocks.\n\t\tconst newParentBlock = createBlock(\n\t\t\t'core/list-item',\n\t\t\tparentBlockAttributes\n\t\t);\n\t\tconst { innerBlocks } = getBlock( clientId );\n\t\t// Replace the parent block with a new parent block without inner blocks,\n\t\t// and make the inner blocks siblings of the parent.\n\t\treplaceBlocks( [ parentBlockId ], [ newParentBlock, ...innerBlocks ] );\n\t\t// Select the last child of the list being outdent.\n\t\tselectionChange( innerBlocks[ innerBlocks.length - 1 ].clientId );\n\t}, [ clientId ] );\n}\n\nfunction IndentUI( { clientId } ) {\n\tconst outdentList = useOutdentList( clientId );\n\tconst canOutdent = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn (\n\t\t\t\tgetBlockName( getBlockRootClientId( clientId ) ) ===\n\t\t\t\t'core/list-item'\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatOutdentRTL : formatOutdent }\n\t\t\t\ttitle={ __( 'Outdent' ) }\n\t\t\t\tdescribedBy={ __( 'Outdent list item' ) }\n\t\t\t\tdisabled={ ! canOutdent }\n\t\t\t\tonClick={ outdentList }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default function Edit( { attributes, setAttributes, clientId, style } ) {\n\tconst { ordered, type, reversed, start } = attributes;\n\tconst blockProps = useBlockProps( {\n\t\tstyle: {\n\t\t\t...( Platform.isNative && style ),\n\t\t\tlistStyleType: ordered && type !== 'decimal' ? type : undefined,\n\t\t},\n\t} );\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\tdirectInsert: true,\n\t\ttemplate: TEMPLATE,\n\t\ttemplateLock: false,\n\t\ttemplateInsertUpdatesSelection: true,\n\t\t...( Platform.isNative && {\n\t\t\tmarginVertical: NATIVE_MARGIN_SPACING,\n\t\t\tmarginHorizontal: NATIVE_MARGIN_SPACING,\n\t\t\trenderAppender: false,\n\t\t} ),\n\t\t__experimentalCaptureToolbars: true,\n\t} );\n\tuseMigrateOnLoad( attributes, clientId );\n\n\tconst controls = (\n\t\t<BlockControls group=\"block\">\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatListBulletsRTL : formatListBullets }\n\t\t\t\ttitle={ __( 'Unordered' ) }\n\t\t\t\tdescribedBy={ __( 'Convert to unordered list' ) }\n\t\t\t\tisActive={ ordered === false }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetAttributes( { ordered: false } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatListNumberedRTL : formatListNumbered }\n\t\t\t\ttitle={ __( 'Ordered' ) }\n\t\t\t\tdescribedBy={ __( 'Convert to ordered list' ) }\n\t\t\t\tisActive={ ordered === true }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetAttributes( { ordered: true } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t\t<IndentUI clientId={ clientId } />\n\t\t</BlockControls>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<TagName\n\t\t\t\tordered={ ordered }\n\t\t\t\treversed={ reversed }\n\t\t\t\tstart={ start }\n\t\t\t\t{ ...innerBlocksProps }\n\t\t\t/>\n\t\t\t{ controls }\n\t\t\t{ ordered && (\n\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K;EAAgB,CACrB,CAAC,EACAU,QAAQ,EACRlB,OAAO,IACRV,aAAA,CAACpC,mBAAmB;IAElB4C,aAAa;IACbI,QAAQ;IACRC,KAAK;IACLF;EAAI,CAEL,CAED,CAAC;AAEL"}
|
|
@@ -3,7 +3,7 @@ import { createElement } from "react";
|
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
5
|
import { cloneBlock } from '@wordpress/blocks';
|
|
6
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
6
|
+
import { useSelect, useDispatch, useRegistry } from '@wordpress/data';
|
|
7
7
|
import { useState, useEffect } from '@wordpress/element';
|
|
8
8
|
import { Warning, store as blockEditorStore, useBlockProps } from '@wordpress/block-editor';
|
|
9
9
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -17,6 +17,7 @@ const PatternEdit = ({
|
|
|
17
17
|
attributes,
|
|
18
18
|
clientId
|
|
19
19
|
}) => {
|
|
20
|
+
const registry = useRegistry();
|
|
20
21
|
const selectedPattern = useSelect(select => select(blockEditorStore).__experimentalGetParsedPattern(attributes.slug), [attributes.slug]);
|
|
21
22
|
const currentThemeStylesheet = useSelect(select => select(coreStore).getCurrentTheme()?.stylesheet, []);
|
|
22
23
|
const {
|
|
@@ -71,15 +72,17 @@ const PatternEdit = ({
|
|
|
71
72
|
// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.
|
|
72
73
|
const clonedBlocks = selectedPattern.blocks.map(block => cloneBlock(injectThemeAttributeInBlockTemplateContent(block)));
|
|
73
74
|
const rootEditingMode = getBlockEditingMode(rootClientId);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
75
|
+
registry.batch(() => {
|
|
76
|
+
// Temporarily set the root block to default mode to allow replacing the pattern.
|
|
77
|
+
// This could happen when the page is disabling edits of non-content blocks.
|
|
78
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
79
|
+
setBlockEditingMode(rootClientId, 'default');
|
|
80
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
81
|
+
replaceBlocks(clientId, clonedBlocks);
|
|
82
|
+
// Restore the root block's original mode.
|
|
83
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
84
|
+
setBlockEditingMode(rootClientId, rootEditingMode);
|
|
85
|
+
});
|
|
83
86
|
});
|
|
84
87
|
}
|
|
85
88
|
}, [clientId, hasRecursionError, selectedPattern, __unstableMarkNextChangeAsNotPersistent, replaceBlocks, getBlockEditingMode, setBlockEditingMode, getBlockRootClientId]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["cloneBlock","useSelect","useDispatch","useState","useEffect","Warning","store","blockEditorStore","useBlockProps","coreStore","__","sprintf","useParsePatternDependencies","PatternEdit","attributes","clientId","selectedPattern","select","__experimentalGetParsedPattern","slug","currentThemeStylesheet","getCurrentTheme","stylesheet","replaceBlocks","setBlockEditingMode","__unstableMarkNextChangeAsNotPersistent","getBlockRootClientId","getBlockEditingMode","hasRecursionError","setHasRecursionError","parsePatternDependencies","injectThemeAttributeInBlockTemplateContent","block","innerBlocks","find","innerBlock","name","map","theme","undefined","blocks","error","window","queueMicrotask","rootClientId","clonedBlocks","rootEditingMode","props","createElement"],"sources":["@wordpress/block-library/src/pattern/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useState, useEffect } from '@wordpress/element';\nimport {\n\tWarning,\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useParsePatternDependencies } from './recursion-detector';\n\nconst PatternEdit = ( { attributes, clientId } ) => {\n\tconst selectedPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).__experimentalGetParsedPattern(\n\t\t\t\tattributes.slug\n\t\t\t),\n\t\t[ attributes.slug ]\n\t);\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.stylesheet,\n\t\t[]\n\t);\n\n\tconst {\n\t\treplaceBlocks,\n\t\tsetBlockEditingMode,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockEditingMode } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst [ hasRecursionError, setHasRecursionError ] = useState( false );\n\tconst parsePatternDependencies = useParsePatternDependencies();\n\n\t// Duplicated in packages/edit-site/src/components/start-template-options/index.js.\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\t// Run this effect when the component loads.\n\t// This adds the Pattern's contents to the post.\n\t// This change won't be saved.\n\t// It will continue to pull from the pattern file unless changes are made to its respective template part.\n\tuseEffect( () => {\n\t\tif ( ! hasRecursionError && selectedPattern?.blocks ) {\n\t\t\ttry {\n\t\t\t\tparsePatternDependencies( selectedPattern );\n\t\t\t} catch ( error ) {\n\t\t\t\tsetHasRecursionError( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// We batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// Since the above uses microtasks, we need to use a microtask here as well,\n\t\t\t// because nested pattern blocks cannot be inserted if the parent block supports\n\t\t\t// inner blocks but doesn't have blockSettings in the state.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t// Clone blocks from the pattern before insertion to ensure they receive\n\t\t\t\t// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.\n\t\t\t\tconst clonedBlocks = selectedPattern.blocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock(\n\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tconst rootEditingMode = getBlockEditingMode( rootClientId );\n\t\t\t\t// Temporarily set the root block to default mode to allow replacing the pattern.\n\t\t\t\t// This could happen when the page is disabling edits of non-content blocks.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, 'default' );\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\treplaceBlocks( clientId, clonedBlocks );\n\t\t\t\t// Restore the root block's original mode.\n\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\tsetBlockEditingMode( rootClientId, rootEditingMode );\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\thasRecursionError,\n\t\tselectedPattern,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlocks,\n\t\tgetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t\tgetBlockRootClientId,\n\t] );\n\n\tconst props = useBlockProps();\n\n\tif ( hasRecursionError ) {\n\t\treturn (\n\t\t\t<div { ...props }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t// translators: A warning in which %s is the name of a pattern.\n\t\t\t\t\t\t__( 'Pattern \"%s\" cannot be rendered inside itself.' ),\n\t\t\t\t\t\tselectedPattern?.name\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn <div { ...props } />;\n};\n\nexport default PatternEdit;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;
|
|
1
|
+
{"version":3,"names":["cloneBlock","useSelect","useDispatch","useRegistry","useState","useEffect","Warning","store","blockEditorStore","useBlockProps","coreStore","__","sprintf","useParsePatternDependencies","PatternEdit","attributes","clientId","registry","selectedPattern","select","__experimentalGetParsedPattern","slug","currentThemeStylesheet","getCurrentTheme","stylesheet","replaceBlocks","setBlockEditingMode","__unstableMarkNextChangeAsNotPersistent","getBlockRootClientId","getBlockEditingMode","hasRecursionError","setHasRecursionError","parsePatternDependencies","injectThemeAttributeInBlockTemplateContent","block","innerBlocks","find","innerBlock","name","map","theme","undefined","blocks","error","window","queueMicrotask","rootClientId","clonedBlocks","rootEditingMode","batch","props","createElement"],"sources":["@wordpress/block-library/src/pattern/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { cloneBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport { useState, useEffect } from '@wordpress/element';\nimport {\n\tWarning,\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useParsePatternDependencies } from './recursion-detector';\n\nconst PatternEdit = ( { attributes, clientId } ) => {\n\tconst registry = useRegistry();\n\tconst selectedPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).__experimentalGetParsedPattern(\n\t\t\t\tattributes.slug\n\t\t\t),\n\t\t[ attributes.slug ]\n\t);\n\n\tconst currentThemeStylesheet = useSelect(\n\t\t( select ) => select( coreStore ).getCurrentTheme()?.stylesheet,\n\t\t[]\n\t);\n\n\tconst {\n\t\treplaceBlocks,\n\t\tsetBlockEditingMode,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t} = useDispatch( blockEditorStore );\n\tconst { getBlockRootClientId, getBlockEditingMode } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst [ hasRecursionError, setHasRecursionError ] = useState( false );\n\tconst parsePatternDependencies = useParsePatternDependencies();\n\n\t// Duplicated in packages/edit-site/src/components/start-template-options/index.js.\n\tfunction injectThemeAttributeInBlockTemplateContent( block ) {\n\t\tif (\n\t\t\tblock.innerBlocks.find(\n\t\t\t\t( innerBlock ) => innerBlock.name === 'core/template-part'\n\t\t\t)\n\t\t) {\n\t\t\tblock.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {\n\t\t\t\tif (\n\t\t\t\t\tinnerBlock.name === 'core/template-part' &&\n\t\t\t\t\tinnerBlock.attributes.theme === undefined\n\t\t\t\t) {\n\t\t\t\t\tinnerBlock.attributes.theme = currentThemeStylesheet;\n\t\t\t\t}\n\t\t\t\treturn innerBlock;\n\t\t\t} );\n\t\t}\n\n\t\tif (\n\t\t\tblock.name === 'core/template-part' &&\n\t\t\tblock.attributes.theme === undefined\n\t\t) {\n\t\t\tblock.attributes.theme = currentThemeStylesheet;\n\t\t}\n\t\treturn block;\n\t}\n\n\t// Run this effect when the component loads.\n\t// This adds the Pattern's contents to the post.\n\t// This change won't be saved.\n\t// It will continue to pull from the pattern file unless changes are made to its respective template part.\n\tuseEffect( () => {\n\t\tif ( ! hasRecursionError && selectedPattern?.blocks ) {\n\t\t\ttry {\n\t\t\t\tparsePatternDependencies( selectedPattern );\n\t\t\t} catch ( error ) {\n\t\t\t\tsetHasRecursionError( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// We batch updates to block list settings to avoid triggering cascading renders\n\t\t\t// for each container block included in a tree and optimize initial render.\n\t\t\t// Since the above uses microtasks, we need to use a microtask here as well,\n\t\t\t// because nested pattern blocks cannot be inserted if the parent block supports\n\t\t\t// inner blocks but doesn't have blockSettings in the state.\n\t\t\twindow.queueMicrotask( () => {\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\t\t// Clone blocks from the pattern before insertion to ensure they receive\n\t\t\t\t// distinct client ids. See https://github.com/WordPress/gutenberg/issues/50628.\n\t\t\t\tconst clonedBlocks = selectedPattern.blocks.map( ( block ) =>\n\t\t\t\t\tcloneBlock(\n\t\t\t\t\t\tinjectThemeAttributeInBlockTemplateContent( block )\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\tconst rootEditingMode = getBlockEditingMode( rootClientId );\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t// Temporarily set the root block to default mode to allow replacing the pattern.\n\t\t\t\t\t// This could happen when the page is disabling edits of non-content blocks.\n\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\tsetBlockEditingMode( rootClientId, 'default' );\n\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\treplaceBlocks( clientId, clonedBlocks );\n\t\t\t\t\t// Restore the root block's original mode.\n\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\tsetBlockEditingMode( rootClientId, rootEditingMode );\n\t\t\t\t} );\n\t\t\t} );\n\t\t}\n\t}, [\n\t\tclientId,\n\t\thasRecursionError,\n\t\tselectedPattern,\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlocks,\n\t\tgetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t\tgetBlockRootClientId,\n\t] );\n\n\tconst props = useBlockProps();\n\n\tif ( hasRecursionError ) {\n\t\treturn (\n\t\t\t<div { ...props }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t// translators: A warning in which %s is the name of a pattern.\n\t\t\t\t\t\t__( 'Pattern \"%s\" cannot be rendered inside itself.' ),\n\t\t\t\t\t\t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KAAK,CAAE,MAAM;UACrB;UACA;UACAtB,uCAAuC,CAAC,CAAC;UACzCD,mBAAmB,CAAEoB,YAAY,EAAE,SAAU,CAAC;UAC9CnB,uCAAuC,CAAC,CAAC;UACzCF,aAAa,CAAET,QAAQ,EAAE+B,YAAa,CAAC;UACvC;UACApB,uCAAuC,CAAC,CAAC;UACzCD,mBAAmB,CAAEoB,YAAY,EAAEE,eAAgB,CAAC;QACrD,CAAE,CAAC;MACJ,CAAE,CAAC;IACJ;EACD,CAAC,EAAE,CACFhC,QAAQ,EACRc,iBAAiB,EACjBZ,eAAe,EACfS,uCAAuC,EACvCF,aAAa,EACbI,mBAAmB,EACnBH,mBAAmB,EACnBE,oBAAoB,CACnB,CAAC;EAEH,MAAMsB,KAAK,GAAGzC,aAAa,CAAC,CAAC;EAE7B,IAAKqB,iBAAiB,EAAG;IACxB,OACCqB,aAAA;MAAA,GAAUD;IAAK,GACdC,aAAA,CAAC7C,OAAO,QACLM,OAAO;IACR;IACAD,EAAE,CAAE,gDAAiD,CAAC,EACtDO,eAAe,EAAEoB,IAClB,CACQ,CACL,CAAC;EAER;EAEA,OAAOa,aAAA;IAAA,GAAUD;EAAK,CAAI,CAAC;AAC5B,CAAC;AAED,eAAepC,WAAW"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-library",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.29.0",
|
|
4
4
|
"description": "Block library for the WordPress editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -31,38 +31,38 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.16.0",
|
|
34
|
-
"@wordpress/a11y": "^3.
|
|
35
|
-
"@wordpress/api-fetch": "^6.
|
|
36
|
-
"@wordpress/autop": "^3.
|
|
37
|
-
"@wordpress/blob": "^3.
|
|
38
|
-
"@wordpress/block-editor": "^12.
|
|
39
|
-
"@wordpress/blocks": "^12.
|
|
40
|
-
"@wordpress/components": "^
|
|
41
|
-
"@wordpress/compose": "^6.
|
|
42
|
-
"@wordpress/core-data": "^6.
|
|
43
|
-
"@wordpress/data": "^9.
|
|
44
|
-
"@wordpress/date": "^4.
|
|
45
|
-
"@wordpress/deprecated": "^3.
|
|
46
|
-
"@wordpress/dom": "^3.
|
|
47
|
-
"@wordpress/element": "^5.
|
|
48
|
-
"@wordpress/escape-html": "^2.
|
|
49
|
-
"@wordpress/hooks": "^3.
|
|
50
|
-
"@wordpress/html-entities": "^3.
|
|
51
|
-
"@wordpress/i18n": "^4.
|
|
52
|
-
"@wordpress/icons": "^9.
|
|
53
|
-
"@wordpress/interactivity": "^5.0
|
|
54
|
-
"@wordpress/interactivity-router": "^1.
|
|
55
|
-
"@wordpress/keycodes": "^3.
|
|
56
|
-
"@wordpress/notices": "^4.
|
|
57
|
-
"@wordpress/patterns": "^1.
|
|
58
|
-
"@wordpress/primitives": "^3.
|
|
59
|
-
"@wordpress/private-apis": "^0.
|
|
60
|
-
"@wordpress/reusable-blocks": "^4.
|
|
61
|
-
"@wordpress/rich-text": "^6.
|
|
62
|
-
"@wordpress/server-side-render": "^4.
|
|
63
|
-
"@wordpress/url": "^3.
|
|
64
|
-
"@wordpress/viewport": "^5.
|
|
65
|
-
"@wordpress/wordcount": "^3.
|
|
34
|
+
"@wordpress/a11y": "^3.52.0",
|
|
35
|
+
"@wordpress/api-fetch": "^6.49.0",
|
|
36
|
+
"@wordpress/autop": "^3.52.0",
|
|
37
|
+
"@wordpress/blob": "^3.52.0",
|
|
38
|
+
"@wordpress/block-editor": "^12.20.0",
|
|
39
|
+
"@wordpress/blocks": "^12.29.0",
|
|
40
|
+
"@wordpress/components": "^27.0.0",
|
|
41
|
+
"@wordpress/compose": "^6.29.0",
|
|
42
|
+
"@wordpress/core-data": "^6.29.0",
|
|
43
|
+
"@wordpress/data": "^9.22.0",
|
|
44
|
+
"@wordpress/date": "^4.52.0",
|
|
45
|
+
"@wordpress/deprecated": "^3.52.0",
|
|
46
|
+
"@wordpress/dom": "^3.52.0",
|
|
47
|
+
"@wordpress/element": "^5.29.0",
|
|
48
|
+
"@wordpress/escape-html": "^2.52.0",
|
|
49
|
+
"@wordpress/hooks": "^3.52.0",
|
|
50
|
+
"@wordpress/html-entities": "^3.52.0",
|
|
51
|
+
"@wordpress/i18n": "^4.52.0",
|
|
52
|
+
"@wordpress/icons": "^9.43.0",
|
|
53
|
+
"@wordpress/interactivity": "^5.1.0",
|
|
54
|
+
"@wordpress/interactivity-router": "^1.2.0",
|
|
55
|
+
"@wordpress/keycodes": "^3.52.0",
|
|
56
|
+
"@wordpress/notices": "^4.20.0",
|
|
57
|
+
"@wordpress/patterns": "^1.13.0",
|
|
58
|
+
"@wordpress/primitives": "^3.50.0",
|
|
59
|
+
"@wordpress/private-apis": "^0.34.0",
|
|
60
|
+
"@wordpress/reusable-blocks": "^4.29.0",
|
|
61
|
+
"@wordpress/rich-text": "^6.29.0",
|
|
62
|
+
"@wordpress/server-side-render": "^4.29.0",
|
|
63
|
+
"@wordpress/url": "^3.53.0",
|
|
64
|
+
"@wordpress/viewport": "^5.29.0",
|
|
65
|
+
"@wordpress/wordcount": "^3.52.0",
|
|
66
66
|
"change-case": "^4.1.2",
|
|
67
67
|
"classnames": "^2.3.1",
|
|
68
68
|
"colord": "^2.7.0",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"publishConfig": {
|
|
81
81
|
"access": "public"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "c139588f4c668b38bafbc5431f2f4e3903dbe683"
|
|
84
84
|
}
|
package/src/avatar/index.php
CHANGED
|
@@ -31,7 +31,18 @@ function render_block_core_avatar( $attributes, $content, $block ) {
|
|
|
31
31
|
: '';
|
|
32
32
|
|
|
33
33
|
if ( ! isset( $block->context['commentId'] ) ) {
|
|
34
|
-
|
|
34
|
+
if ( isset( $attributes['userId'] ) ) {
|
|
35
|
+
$author_id = $attributes['userId'];
|
|
36
|
+
} elseif ( isset( $block->context['postId'] ) ) {
|
|
37
|
+
$author_id = get_post_field( 'post_author', $block->context['postId'] );
|
|
38
|
+
} else {
|
|
39
|
+
$author_id = get_query_var( 'author' );
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if ( empty( $author_id ) ) {
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
45
|
+
|
|
35
46
|
$author_name = get_the_author_meta( 'display_name', $author_id );
|
|
36
47
|
// translators: %s is the Author name.
|
|
37
48
|
$alt = sprintf( __( '%s Avatar' ), $author_name );
|
package/src/buttons/edit.js
CHANGED
|
@@ -6,11 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
useBlockProps,
|
|
11
|
-
useInnerBlocksProps,
|
|
12
|
-
store as blockEditorStore,
|
|
13
|
-
} from '@wordpress/block-editor';
|
|
9
|
+
import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
|
|
14
10
|
import { useSelect } from '@wordpress/data';
|
|
15
11
|
import { store as blocksStore } from '@wordpress/blocks';
|
|
16
12
|
|
|
@@ -36,16 +32,12 @@ function ButtonsEdit( { attributes, className } ) {
|
|
|
36
32
|
'has-custom-font-size': fontSize || style?.typography?.fontSize,
|
|
37
33
|
} ),
|
|
38
34
|
} );
|
|
39
|
-
const {
|
|
40
|
-
const preferredStyleVariations =
|
|
41
|
-
select( blockEditorStore ).getSettings()
|
|
42
|
-
.__experimentalPreferredStyleVariations;
|
|
35
|
+
const { hasButtonVariations } = useSelect( ( select ) => {
|
|
43
36
|
const buttonVariations = select( blocksStore ).getBlockVariations(
|
|
44
37
|
'core/button',
|
|
45
38
|
'inserter'
|
|
46
39
|
);
|
|
47
40
|
return {
|
|
48
|
-
preferredStyle: preferredStyleVariations?.value?.[ 'core/button' ],
|
|
49
41
|
hasButtonVariations: buttonVariations.length > 0,
|
|
50
42
|
};
|
|
51
43
|
}, [] );
|
|
@@ -54,12 +46,7 @@ function ButtonsEdit( { attributes, className } ) {
|
|
|
54
46
|
defaultBlock: DEFAULT_BLOCK,
|
|
55
47
|
// This check should be handled by the `Inserter` internally to be consistent across all blocks that use it.
|
|
56
48
|
directInsert: ! hasButtonVariations,
|
|
57
|
-
template: [
|
|
58
|
-
[
|
|
59
|
-
'core/button',
|
|
60
|
-
{ className: preferredStyle && `is-style-${ preferredStyle }` },
|
|
61
|
-
],
|
|
62
|
-
],
|
|
49
|
+
template: [ [ 'core/button' ] ],
|
|
63
50
|
templateInsertUpdatesSelection: true,
|
|
64
51
|
orientation: layout?.orientation ?? 'horizontal',
|
|
65
52
|
} );
|
|
@@ -69,13 +69,6 @@ export default function ButtonsEdit( {
|
|
|
69
69
|
[ clientId ]
|
|
70
70
|
);
|
|
71
71
|
|
|
72
|
-
const preferredStyle = useSelect( ( select ) => {
|
|
73
|
-
const preferredStyleVariations =
|
|
74
|
-
select( blockEditorStore ).getSettings()
|
|
75
|
-
.__experimentalPreferredStyleVariations;
|
|
76
|
-
return preferredStyleVariations?.value?.[ 'core/button' ];
|
|
77
|
-
}, [] );
|
|
78
|
-
|
|
79
72
|
const { getBlockOrder } = useSelect( blockEditorStore );
|
|
80
73
|
const { insertBlock, removeBlock, selectBlock } =
|
|
81
74
|
useDispatch( blockEditorStore );
|
|
@@ -144,16 +137,7 @@ export default function ButtonsEdit( {
|
|
|
144
137
|
) }
|
|
145
138
|
{ resizeObserver }
|
|
146
139
|
<InnerBlocks
|
|
147
|
-
template={ [
|
|
148
|
-
[
|
|
149
|
-
'core/button',
|
|
150
|
-
{
|
|
151
|
-
className:
|
|
152
|
-
preferredStyle &&
|
|
153
|
-
`is-style-${ preferredStyle }`,
|
|
154
|
-
},
|
|
155
|
-
],
|
|
156
|
-
] }
|
|
140
|
+
template={ [ [ 'core/button' ] ] }
|
|
157
141
|
renderFooterAppender={
|
|
158
142
|
shouldRenderFooterAppender && renderFooterAppender.current
|
|
159
143
|
}
|
package/src/columns/edit.js
CHANGED
|
@@ -40,6 +40,10 @@ import {
|
|
|
40
40
|
toWidthPrecision,
|
|
41
41
|
} from './utils';
|
|
42
42
|
|
|
43
|
+
const DEFAULT_BLOCK = {
|
|
44
|
+
name: 'core/column',
|
|
45
|
+
};
|
|
46
|
+
|
|
43
47
|
function ColumnsEditContainer( { attributes, setAttributes, clientId } ) {
|
|
44
48
|
const { isStackedOnMobile, verticalAlignment, templateLock } = attributes;
|
|
45
49
|
const { count, canInsertColumnBlock, minCount } = useSelect(
|
|
@@ -90,6 +94,8 @@ function ColumnsEditContainer( { attributes, setAttributes, clientId } ) {
|
|
|
90
94
|
className: classes,
|
|
91
95
|
} );
|
|
92
96
|
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
97
|
+
defaultBlock: DEFAULT_BLOCK,
|
|
98
|
+
directInsert: true,
|
|
93
99
|
orientation: 'horizontal',
|
|
94
100
|
renderAppender: false,
|
|
95
101
|
templateLock,
|
|
@@ -308,7 +308,11 @@ export default function CoverInspectorControls( {
|
|
|
308
308
|
panelId={ clientId }
|
|
309
309
|
>
|
|
310
310
|
<CoverHeightInput
|
|
311
|
-
value={
|
|
311
|
+
value={
|
|
312
|
+
attributes?.style?.dimensions?.aspectRatio
|
|
313
|
+
? ''
|
|
314
|
+
: minHeight
|
|
315
|
+
}
|
|
312
316
|
unit={ minHeightUnit }
|
|
313
317
|
onChange={ ( newMinHeight ) =>
|
|
314
318
|
setAttributes( {
|
package/src/details/block.json
CHANGED
package/src/gallery/edit.js
CHANGED
|
@@ -73,6 +73,7 @@ const MOBILE_CONTROL_PROPS_RANGE_CONTROL = Platform.isNative
|
|
|
73
73
|
? { type: 'stepper' }
|
|
74
74
|
: {};
|
|
75
75
|
|
|
76
|
+
const DEFAULT_BLOCK = { name: 'core/image' };
|
|
76
77
|
const EMPTY_ARRAY = [];
|
|
77
78
|
|
|
78
79
|
function GalleryEdit( props ) {
|
|
@@ -102,7 +103,6 @@ function GalleryEdit( props ) {
|
|
|
102
103
|
const {
|
|
103
104
|
getBlock,
|
|
104
105
|
getSettings,
|
|
105
|
-
preferredStyle,
|
|
106
106
|
innerBlockImages,
|
|
107
107
|
blockWasJustInserted,
|
|
108
108
|
multiGallerySelection,
|
|
@@ -115,15 +115,11 @@ function GalleryEdit( props ) {
|
|
|
115
115
|
getBlock: _getBlock,
|
|
116
116
|
wasBlockJustInserted,
|
|
117
117
|
} = select( blockEditorStore );
|
|
118
|
-
const preferredStyleVariations =
|
|
119
|
-
_getSettings().__experimentalPreferredStyleVariations;
|
|
120
118
|
const multiSelectedClientIds = getMultiSelectedBlockClientIds();
|
|
121
119
|
|
|
122
120
|
return {
|
|
123
121
|
getBlock: _getBlock,
|
|
124
122
|
getSettings: _getSettings,
|
|
125
|
-
preferredStyle:
|
|
126
|
-
preferredStyleVariations?.value?.[ 'core/image' ],
|
|
127
123
|
innerBlockImages:
|
|
128
124
|
_getBlock( clientId )?.innerBlocks ?? EMPTY_ARRAY,
|
|
129
125
|
blockWasJustInserted: wasBlockJustInserted(
|
|
@@ -195,10 +191,6 @@ function GalleryEdit( props ) {
|
|
|
195
191
|
let newClassName;
|
|
196
192
|
if ( imageAttributes.className && imageAttributes.className !== '' ) {
|
|
197
193
|
newClassName = imageAttributes.className;
|
|
198
|
-
} else {
|
|
199
|
-
newClassName = preferredStyle
|
|
200
|
-
? `is-style-${ preferredStyle }`
|
|
201
|
-
: undefined;
|
|
202
194
|
}
|
|
203
195
|
|
|
204
196
|
let newLinkTarget;
|
|
@@ -505,6 +497,8 @@ function GalleryEdit( props ) {
|
|
|
505
497
|
};
|
|
506
498
|
|
|
507
499
|
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
500
|
+
defaultBlock: DEFAULT_BLOCK,
|
|
501
|
+
directInsert: true,
|
|
508
502
|
orientation: 'horizontal',
|
|
509
503
|
renderAppender: false,
|
|
510
504
|
...nativeInnerBlockProps,
|
package/src/group/variations.js
CHANGED
|
@@ -42,10 +42,7 @@ const variations = [
|
|
|
42
42
|
blockAttributes.layout?.orientation === 'vertical',
|
|
43
43
|
icon: stack,
|
|
44
44
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if ( window?.__experimentalEnableGroupGridVariation ) {
|
|
48
|
-
variations.push( {
|
|
45
|
+
{
|
|
49
46
|
name: 'group-grid',
|
|
50
47
|
title: __( 'Grid' ),
|
|
51
48
|
description: __( 'Arrange blocks in a grid.' ),
|
|
@@ -54,7 +51,7 @@ if ( window?.__experimentalEnableGroupGridVariation ) {
|
|
|
54
51
|
isActive: ( blockAttributes ) =>
|
|
55
52
|
blockAttributes.layout?.type === 'grid',
|
|
56
53
|
icon: grid,
|
|
57
|
-
}
|
|
58
|
-
|
|
54
|
+
},
|
|
55
|
+
];
|
|
59
56
|
|
|
60
57
|
export default variations;
|
package/src/list/edit.js
CHANGED
|
@@ -29,6 +29,9 @@ import OrderedListSettings from './ordered-list-settings';
|
|
|
29
29
|
import { migrateToListV2 } from './utils';
|
|
30
30
|
import TagName from './tag-name';
|
|
31
31
|
|
|
32
|
+
const DEFAULT_BLOCK = {
|
|
33
|
+
name: 'core/list-item',
|
|
34
|
+
};
|
|
32
35
|
const TEMPLATE = [ [ 'core/list-item' ] ];
|
|
33
36
|
const NATIVE_MARGIN_SPACING = 8;
|
|
34
37
|
|
|
@@ -125,6 +128,8 @@ export default function Edit( { attributes, setAttributes, clientId, style } ) {
|
|
|
125
128
|
} );
|
|
126
129
|
|
|
127
130
|
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
131
|
+
defaultBlock: DEFAULT_BLOCK,
|
|
132
|
+
directInsert: true,
|
|
128
133
|
template: TEMPLATE,
|
|
129
134
|
templateLock: false,
|
|
130
135
|
templateInsertUpdatesSelection: true,
|
package/src/pattern/edit.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { cloneBlock } from '@wordpress/blocks';
|
|
5
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
+
import { useSelect, useDispatch, useRegistry } from '@wordpress/data';
|
|
6
6
|
import { useState, useEffect } from '@wordpress/element';
|
|
7
7
|
import {
|
|
8
8
|
Warning,
|
|
@@ -18,6 +18,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
18
18
|
import { useParsePatternDependencies } from './recursion-detector';
|
|
19
19
|
|
|
20
20
|
const PatternEdit = ( { attributes, clientId } ) => {
|
|
21
|
+
const registry = useRegistry();
|
|
21
22
|
const selectedPattern = useSelect(
|
|
22
23
|
( select ) =>
|
|
23
24
|
select( blockEditorStore ).__experimentalGetParsedPattern(
|
|
@@ -97,15 +98,17 @@ const PatternEdit = ( { attributes, clientId } ) => {
|
|
|
97
98
|
)
|
|
98
99
|
);
|
|
99
100
|
const rootEditingMode = getBlockEditingMode( rootClientId );
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
registry.batch( () => {
|
|
102
|
+
// Temporarily set the root block to default mode to allow replacing the pattern.
|
|
103
|
+
// This could happen when the page is disabling edits of non-content blocks.
|
|
104
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
105
|
+
setBlockEditingMode( rootClientId, 'default' );
|
|
106
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
107
|
+
replaceBlocks( clientId, clonedBlocks );
|
|
108
|
+
// Restore the root block's original mode.
|
|
109
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
110
|
+
setBlockEditingMode( rootClientId, rootEditingMode );
|
|
111
|
+
} );
|
|
109
112
|
} );
|
|
110
113
|
}
|
|
111
114
|
}, [
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
* @return string Returns the rendered post author biography block.
|
|
15
15
|
*/
|
|
16
16
|
function render_block_core_post_author_biography( $attributes, $content, $block ) {
|
|
17
|
-
if (
|
|
18
|
-
|
|
17
|
+
if ( isset( $block->context['postId'] ) ) {
|
|
18
|
+
$author_id = get_post_field( 'post_author', $block->context['postId'] );
|
|
19
|
+
} else {
|
|
20
|
+
$author_id = get_query_var( 'author' );
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
$author_id = get_post_field( 'post_author', $block->context['postId'] );
|
|
22
23
|
if ( empty( $author_id ) ) {
|
|
23
24
|
return '';
|
|
24
25
|
}
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
* @return string Returns the rendered post author name block.
|
|
15
15
|
*/
|
|
16
16
|
function render_block_core_post_author_name( $attributes, $content, $block ) {
|
|
17
|
-
if (
|
|
18
|
-
|
|
17
|
+
if ( isset( $block->context['postId'] ) ) {
|
|
18
|
+
$author_id = get_post_field( 'post_author', $block->context['postId'] );
|
|
19
|
+
} else {
|
|
20
|
+
$author_id = get_query_var( 'author' );
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
$author_id = get_post_field( 'post_author', $block->context['postId'] );
|
|
22
23
|
if ( empty( $author_id ) ) {
|
|
23
24
|
return '';
|
|
24
25
|
}
|