@wordpress/block-editor 12.19.1 → 12.19.2
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/global-styles/border-panel.js +4 -3
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/get-global-styles-changes.js +61 -24
- package/build/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +8 -6
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/iframe/index.js +4 -1
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +1 -0
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/use-enter.js +1 -0
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +0 -17
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/utils.js +8 -4
- package/build/hooks/utils.js.map +1 -1
- package/build/store/get-block-settings.js +17 -4
- package/build/store/get-block-settings.js.map +1 -1
- package/build/store/private-actions.js +5 -0
- package/build/store/private-actions.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +5 -4
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/get-global-styles-changes.js +61 -25
- package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +9 -7
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/iframe/index.js +4 -1
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +1 -0
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +1 -0
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +0 -17
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/utils.js +8 -4
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/store/get-block-settings.js +16 -4
- package/build-module/store/get-block-settings.js.map +1 -1
- package/build-module/store/private-actions.js +5 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/package.json +31 -31
- package/src/components/global-styles/border-panel.js +4 -6
- package/src/components/global-styles/get-global-styles-changes.js +68 -28
- package/src/components/global-styles/test/get-global-styles-changes.js +114 -75
- package/src/components/global-styles/typography-panel.js +11 -7
- package/src/components/iframe/index.js +4 -1
- package/src/components/rich-text/index.native.js +1 -0
- package/src/components/rich-text/use-enter.js +1 -0
- package/src/hooks/use-bindings-attributes.js +0 -21
- package/src/hooks/utils.js +24 -8
- package/src/store/get-block-settings.js +15 -4
- package/src/store/private-actions.js +9 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__EXPERIMENTAL_PATHS_WITH_MERGE","PATHS_WITH_MERGE","hasBlockSupport","applyFilters","getValueFromObjectPath","getBlockName","getSettings","getBlockAttributes","blockedPaths","deprecatedFlags","settings","colors","gradients","disableCustomColors","undefined","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","mergeOrigins","value","result","mergeCache","get","flatMap","key","_value$key","set","WeakMap","hasMergedOrigins","some","length","getBlockSettings","state","clientId","paths","blockName","candidates","id","name","push","blocks","parents","map","includes","console","warn","normalizedPath","candidateClientId","_getValueFromObjectPa","candidateAtts","__experimentalFeatures","deprecatedSettingsValue"],"sources":["@wordpress/block-editor/src/store/get-block-settings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__EXPERIMENTAL_PATHS_WITH_MERGE as PATHS_WITH_MERGE,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { applyFilters } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { getValueFromObjectPath } from '../utils/object';\nimport { getBlockName, getSettings, getBlockAttributes } from './selectors';\n\nconst blockedPaths = [\n\t'color',\n\t'border',\n\t'dimensions',\n\t'typography',\n\t'spacing',\n];\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) => settings.colors,\n\t'color.gradients': ( settings ) => settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) => settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.padding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst prefixedFlags = {\n\t/*\n\t * These were only available in the plugin\n\t * and can be removed when the minimum WordPress version\n\t * for the plugin is 5.9.\n\t */\n\t'border.customColor': 'border.color',\n\t'border.customStyle': 'border.style',\n\t'border.customWidth': 'border.width',\n\t'typography.customFontStyle': 'typography.fontStyle',\n\t'typography.customFontWeight': 'typography.fontWeight',\n\t'typography.customLetterSpacing': 'typography.letterSpacing',\n\t'typography.customTextDecorations': 'typography.textDecoration',\n\t'typography.customTextTransforms': 'typography.textTransform',\n\t/*\n\t * These were part of WordPress 5.8 and we need to keep them.\n\t */\n\t'border.customRadius': 'border.radius',\n\t'spacing.customMargin': 'spacing.margin',\n\t'spacing.customPadding': 'spacing.padding',\n\t'typography.customLineHeight': 'typography.lineHeight',\n};\n\n/**\n * Remove `custom` prefixes for flags that did not land in 5.8.\n *\n * This provides continued support for `custom` prefixed properties. It will\n * be removed once third party devs have had sufficient time to update themes,\n * plugins, etc.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34485\n *\n * @param {string} path Path to desired value in settings.\n * @return {string} The value for defined setting.\n */\nconst removeCustomPrefixes = ( path ) => {\n\treturn prefixedFlags[ path ] || path;\n};\n\n/**\n * For settings like `color.palette`, which have a value that is an object\n * with `default`, `theme`, `custom`, with field values that are arrays of\n * items, merge these three arrays into one and return it. The calculation\n * is memoized so that identical input values produce identical output.\n * @param {Object} value Object to merge\n * @return {Array} Array of merged items\n */\nexport function mergeOrigins( value ) {\n\tlet result = mergeCache.get( value );\n\tif ( ! result ) {\n\t\tresult = [ 'default', 'theme', 'custom' ].flatMap(\n\t\t\t( key ) => value[ key ] ?? []\n\t\t);\n\t\tmergeCache.set( value, result );\n\t}\n\treturn result;\n}\nconst mergeCache = new WeakMap();\n\n/**\n * For settings like `color.palette`, which have a value that is an object\n * with `default`, `theme`, `custom`, with field values that are arrays of\n * items, see if any of the three origins have values.\n *\n * @param {Object} value Object to check\n * @return {boolean} Whether the object has values in any of the three origins\n */\nexport function hasMergedOrigins( value ) {\n\treturn [ 'default', 'theme', 'custom' ].some(\n\t\t( key ) => value?.[ key ]?.length\n\t);\n}\n\nexport function getBlockSettings( state, clientId, ...paths ) {\n\tconst blockName = getBlockName( state, clientId );\n\tconst candidates = [];\n\n\tif ( clientId ) {\n\t\tlet id = clientId;\n\t\tdo {\n\t\t\tconst name = getBlockName( state, id );\n\t\t\tif ( hasBlockSupport( name, '__experimentalSettings', false ) ) {\n\t\t\t\tcandidates.push( id );\n\t\t\t}\n\t\t} while ( ( id = state.blocks.parents.get( id ) ) );\n\t}\n\n\treturn paths.map( ( path ) => {\n\t\tif ( blockedPaths.includes( path ) ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t'Top level useSetting paths are disabled. Please use a subpath to query the information needed.'\n\t\t\t);\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// 0. Allow third parties to filter the block's settings at runtime.\n\t\tlet result = applyFilters(\n\t\t\t'blockEditor.useSetting.before',\n\t\t\tundefined,\n\t\t\tpath,\n\t\t\tclientId,\n\t\t\tblockName\n\t\t);\n\n\t\tif ( undefined !== result ) {\n\t\t\treturn result;\n\t\t}\n\n\t\tconst normalizedPath = removeCustomPrefixes( path );\n\n\t\t// 1. Take settings from the block instance or its ancestors.\n\t\t// Start from the current block and work our way up the ancestors.\n\t\tfor ( const candidateClientId of candidates ) {\n\t\t\tconst candidateAtts = getBlockAttributes(\n\t\t\t\tstate,\n\t\t\t\tcandidateClientId\n\t\t\t);\n\t\t\tresult =\n\t\t\t\tgetValueFromObjectPath(\n\t\t\t\t\tcandidateAtts.settings?.blocks?.[ blockName ],\n\t\t\t\t\tnormalizedPath\n\t\t\t\t) ??\n\t\t\t\tgetValueFromObjectPath(\n\t\t\t\t\tcandidateAtts.settings,\n\t\t\t\t\tnormalizedPath\n\t\t\t\t);\n\t\t\tif ( result !== undefined ) {\n\t\t\t\t// Stop the search for more distant ancestors and move on.\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// 2. Fall back to the settings from the block editor store (__experimentalFeatures).\n\t\tconst settings = getSettings( state );\n\t\tif ( result === undefined && blockName ) {\n\t\t\tresult = getValueFromObjectPath(\n\t\t\t\tsettings.__experimentalFeatures?.blocks?.[ blockName ],\n\t\t\t\tnormalizedPath\n\t\t\t);\n\t\t}\n\n\t\tif ( result === undefined ) {\n\t\t\tresult = getValueFromObjectPath(\n\t\t\t\tsettings.__experimentalFeatures,\n\t\t\t\tnormalizedPath\n\t\t\t);\n\t\t}\n\n\t\t// Return if the setting was found in either the block instance or the store.\n\t\tif ( result !== undefined ) {\n\t\t\tif ( PATHS_WITH_MERGE[ normalizedPath ] ) {\n\t\t\t\treturn mergeOrigins( result );\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\n\t\t// 3. Otherwise, use deprecated settings.\n\t\tconst deprecatedSettingsValue =\n\t\t\tdeprecatedFlags[ normalizedPath ]?.( settings );\n\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\treturn deprecatedSettingsValue;\n\t\t}\n\n\t\t// 4. Fallback for typography.dropCap:\n\t\t// This is only necessary to support typography.dropCap.\n\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t// To remove when __experimentalFeatures are ported to core.\n\t\treturn normalizedPath === 'typography.dropCap' ? true : undefined;\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,+BAA+B,IAAIC,gBAAgB,EACnDC,eAAe,QACT,mBAAmB;AAC1B,SAASC,YAAY,QAAQ,kBAAkB;;AAE/C;AACA;AACA;AACA,SAASC,sBAAsB,QAAQ,iBAAiB;AACxD,SAASC,YAAY,EAAEC,WAAW,EAAEC,kBAAkB,QAAQ,aAAa;AAE3E,MAAMC,YAAY,GAAG,CACpB,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,SAAS,CACT;AAED,MAAMC,eAAe,GAAG;EACvB,eAAe,EAAIC,QAAQ,IAAMA,QAAQ,CAACC,MAAM;EAChD,iBAAiB,EAAID,QAAQ,IAAMA,QAAQ,CAACE,SAAS;EACrD,cAAc,EAAIF,QAAQ,IACzBA,QAAQ,CAACG,mBAAmB,KAAKC,SAAS,GACvCA,SAAS,GACT,CAAEJ,QAAQ,CAACG,mBAAmB;EAClC,sBAAsB,EAAIH,QAAQ,IACjCA,QAAQ,CAACK,sBAAsB,KAAKD,SAAS,GAC1CA,SAAS,GACT,CAAEJ,QAAQ,CAACK,sBAAsB;EACrC,sBAAsB,EAAIL,QAAQ,IAAMA,QAAQ,CAACM,SAAS;EAC1D,2BAA2B,EAAIN,QAAQ,IACtCA,QAAQ,CAACO,sBAAsB,KAAKH,SAAS,GAC1CA,SAAS,GACT,CAAEJ,QAAQ,CAACO,sBAAsB;EACrC,uBAAuB,EAAIP,QAAQ,IAAMA,QAAQ,CAACQ,sBAAsB;EACxE,eAAe,EAAIR,QAAQ,IAAM;IAChC,IAAKA,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MAC5C,OAAO2C,uBAAuB;IAC/B;;IAEA;IACA;IACA;IACA;IACA,OAAOL,cAAc,KAAK,oBAAoB,GAAG,IAAI,GAAGtC,SAAS;EAClE,CAAE,CAAC;AACJ"}
|
|
1
|
+
{"version":3,"names":["__EXPERIMENTAL_PATHS_WITH_OVERRIDE","PATHS_WITH_OVERRIDE","hasBlockSupport","applyFilters","getValueFromObjectPath","getBlockName","getSettings","getBlockAttributes","blockedPaths","deprecatedFlags","settings","colors","gradients","disableCustomColors","undefined","disableCustomGradients","fontSizes","disableCustomFontSizes","enableCustomLineHeight","enableCustomUnits","enableCustomSpacing","prefixedFlags","removeCustomPrefixes","path","mergeOrigins","value","result","mergeCache","get","flatMap","key","_value$key","set","WeakMap","overrideOrigins","_ref","_value$custom","custom","theme","default","hasOriginValue","some","length","getBlockSettings","state","clientId","paths","blockName","candidates","id","name","push","blocks","parents","map","includes","console","warn","normalizedPath","candidateClientId","_getValueFromObjectPa","candidateAtts","__experimentalFeatures","deprecatedSettingsValue"],"sources":["@wordpress/block-editor/src/store/get-block-settings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__EXPERIMENTAL_PATHS_WITH_OVERRIDE as PATHS_WITH_OVERRIDE,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { applyFilters } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport { getValueFromObjectPath } from '../utils/object';\nimport { getBlockName, getSettings, getBlockAttributes } from './selectors';\n\nconst blockedPaths = [\n\t'color',\n\t'border',\n\t'dimensions',\n\t'typography',\n\t'spacing',\n];\n\nconst deprecatedFlags = {\n\t'color.palette': ( settings ) => settings.colors,\n\t'color.gradients': ( settings ) => settings.gradients,\n\t'color.custom': ( settings ) =>\n\t\tsettings.disableCustomColors === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomColors,\n\t'color.customGradient': ( settings ) =>\n\t\tsettings.disableCustomGradients === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomGradients,\n\t'typography.fontSizes': ( settings ) => settings.fontSizes,\n\t'typography.customFontSize': ( settings ) =>\n\t\tsettings.disableCustomFontSizes === undefined\n\t\t\t? undefined\n\t\t\t: ! settings.disableCustomFontSizes,\n\t'typography.lineHeight': ( settings ) => settings.enableCustomLineHeight,\n\t'spacing.units': ( settings ) => {\n\t\tif ( settings.enableCustomUnits === undefined ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( settings.enableCustomUnits === true ) {\n\t\t\treturn [ 'px', 'em', 'rem', 'vh', 'vw', '%' ];\n\t\t}\n\n\t\treturn settings.enableCustomUnits;\n\t},\n\t'spacing.padding': ( settings ) => settings.enableCustomSpacing,\n};\n\nconst prefixedFlags = {\n\t/*\n\t * These were only available in the plugin\n\t * and can be removed when the minimum WordPress version\n\t * for the plugin is 5.9.\n\t */\n\t'border.customColor': 'border.color',\n\t'border.customStyle': 'border.style',\n\t'border.customWidth': 'border.width',\n\t'typography.customFontStyle': 'typography.fontStyle',\n\t'typography.customFontWeight': 'typography.fontWeight',\n\t'typography.customLetterSpacing': 'typography.letterSpacing',\n\t'typography.customTextDecorations': 'typography.textDecoration',\n\t'typography.customTextTransforms': 'typography.textTransform',\n\t/*\n\t * These were part of WordPress 5.8 and we need to keep them.\n\t */\n\t'border.customRadius': 'border.radius',\n\t'spacing.customMargin': 'spacing.margin',\n\t'spacing.customPadding': 'spacing.padding',\n\t'typography.customLineHeight': 'typography.lineHeight',\n};\n\n/**\n * Remove `custom` prefixes for flags that did not land in 5.8.\n *\n * This provides continued support for `custom` prefixed properties. It will\n * be removed once third party devs have had sufficient time to update themes,\n * plugins, etc.\n *\n * @see https://github.com/WordPress/gutenberg/pull/34485\n *\n * @param {string} path Path to desired value in settings.\n * @return {string} The value for defined setting.\n */\nconst removeCustomPrefixes = ( path ) => {\n\treturn prefixedFlags[ path ] || path;\n};\n\n/**\n * For settings like `color.palette`, which have a value that is an object\n * with `default`, `theme`, `custom`, with field values that are arrays of\n * items, merge these three arrays into one and return it. The calculation\n * is memoized so that identical input values produce identical output.\n * @param {Object} value Object to merge\n * @return {Array} Array of merged items\n */\nexport function mergeOrigins( value ) {\n\tlet result = mergeCache.get( value );\n\tif ( ! result ) {\n\t\tresult = [ 'default', 'theme', 'custom' ].flatMap(\n\t\t\t( key ) => value[ key ] ?? []\n\t\t);\n\t\tmergeCache.set( value, result );\n\t}\n\treturn result;\n}\nconst mergeCache = new WeakMap();\n\n/**\n * For settings like `color.palette`, which have a value that is an object\n * with `default`, `theme`, `custom`, with field values that are arrays of\n * items, returns the one with the highest priority among these three arrays.\n * @param {Object} value Object to extract from\n * @return {Array} Array of items extracted from the three origins\n */\nexport function overrideOrigins( value ) {\n\treturn value.custom ?? value.theme ?? value.default;\n}\n\n/**\n * For settings like `color.palette`, which have a value that is an object\n * with `default`, `theme`, `custom`, with field values that are arrays of\n * items, see if any of the three origins have values.\n *\n * @param {Object} value Object to check\n * @return {boolean} Whether the object has values in any of the three origins\n */\nexport function hasOriginValue( value ) {\n\treturn [ 'default', 'theme', 'custom' ].some(\n\t\t( key ) => value?.[ key ]?.length\n\t);\n}\n\nexport function getBlockSettings( state, clientId, ...paths ) {\n\tconst blockName = getBlockName( state, clientId );\n\tconst candidates = [];\n\n\tif ( clientId ) {\n\t\tlet id = clientId;\n\t\tdo {\n\t\t\tconst name = getBlockName( state, id );\n\t\t\tif ( hasBlockSupport( name, '__experimentalSettings', false ) ) {\n\t\t\t\tcandidates.push( id );\n\t\t\t}\n\t\t} while ( ( id = state.blocks.parents.get( id ) ) );\n\t}\n\n\treturn paths.map( ( path ) => {\n\t\tif ( blockedPaths.includes( path ) ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t'Top level useSetting paths are disabled. Please use a subpath to query the information needed.'\n\t\t\t);\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// 0. Allow third parties to filter the block's settings at runtime.\n\t\tlet result = applyFilters(\n\t\t\t'blockEditor.useSetting.before',\n\t\t\tundefined,\n\t\t\tpath,\n\t\t\tclientId,\n\t\t\tblockName\n\t\t);\n\n\t\tif ( undefined !== result ) {\n\t\t\treturn result;\n\t\t}\n\n\t\tconst normalizedPath = removeCustomPrefixes( path );\n\n\t\t// 1. Take settings from the block instance or its ancestors.\n\t\t// Start from the current block and work our way up the ancestors.\n\t\tfor ( const candidateClientId of candidates ) {\n\t\t\tconst candidateAtts = getBlockAttributes(\n\t\t\t\tstate,\n\t\t\t\tcandidateClientId\n\t\t\t);\n\t\t\tresult =\n\t\t\t\tgetValueFromObjectPath(\n\t\t\t\t\tcandidateAtts.settings?.blocks?.[ blockName ],\n\t\t\t\t\tnormalizedPath\n\t\t\t\t) ??\n\t\t\t\tgetValueFromObjectPath(\n\t\t\t\t\tcandidateAtts.settings,\n\t\t\t\t\tnormalizedPath\n\t\t\t\t);\n\t\t\tif ( result !== undefined ) {\n\t\t\t\t// Stop the search for more distant ancestors and move on.\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// 2. Fall back to the settings from the block editor store (__experimentalFeatures).\n\t\tconst settings = getSettings( state );\n\t\tif ( result === undefined && blockName ) {\n\t\t\tresult = getValueFromObjectPath(\n\t\t\t\tsettings.__experimentalFeatures?.blocks?.[ blockName ],\n\t\t\t\tnormalizedPath\n\t\t\t);\n\t\t}\n\n\t\tif ( result === undefined ) {\n\t\t\tresult = getValueFromObjectPath(\n\t\t\t\tsettings.__experimentalFeatures,\n\t\t\t\tnormalizedPath\n\t\t\t);\n\t\t}\n\n\t\t// Return if the setting was found in either the block instance or the store.\n\t\tif ( result !== undefined ) {\n\t\t\tif ( PATHS_WITH_OVERRIDE[ normalizedPath ] ) {\n\t\t\t\treturn overrideOrigins( result );\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\n\t\t// 3. Otherwise, use deprecated settings.\n\t\tconst deprecatedSettingsValue =\n\t\t\tdeprecatedFlags[ normalizedPath ]?.( settings );\n\t\tif ( deprecatedSettingsValue !== undefined ) {\n\t\t\treturn deprecatedSettingsValue;\n\t\t}\n\n\t\t// 4. Fallback for typography.dropCap:\n\t\t// This is only necessary to support typography.dropCap.\n\t\t// when __experimentalFeatures are not present (core without plugin).\n\t\t// To remove when __experimentalFeatures are ported to core.\n\t\treturn normalizedPath === 'typography.dropCap' ? true : undefined;\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,kCAAkC,IAAIC,mBAAmB,EACzDC,eAAe,QACT,mBAAmB;AAC1B,SAASC,YAAY,QAAQ,kBAAkB;;AAE/C;AACA;AACA;AACA,SAASC,sBAAsB,QAAQ,iBAAiB;AACxD,SAASC,YAAY,EAAEC,WAAW,EAAEC,kBAAkB,QAAQ,aAAa;AAE3E,MAAMC,YAAY,GAAG,CACpB,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,SAAS,CACT;AAED,MAAMC,eAAe,GAAG;EACvB,eAAe,EAAIC,QAAQ,IAAMA,QAAQ,CAACC,MAAM;EAChD,iBAAiB,EAAID,QAAQ,IAAMA,QAAQ,CAACE,SAAS;EACrD,cAAc,EAAIF,QAAQ,IACzBA,QAAQ,CAACG,mBAAmB,KAAKC,SAAS,GACvCA,SAAS,GACT,CAAEJ,QAAQ,CAACG,mBAAmB;EAClC,sBAAsB,EAAIH,QAAQ,IACjCA,QAAQ,CAACK,sBAAsB,KAAKD,SAAS,GAC1CA,SAAS,GACT,CAAEJ,QAAQ,CAACK,sBAAsB;EACrC,sBAAsB,EAAIL,QAAQ,IAAMA,QAAQ,CAACM,SAAS;EAC1D,2BAA2B,EAAIN,QAAQ,IACtCA,QAAQ,CAACO,sBAAsB,KAAKH,SAAS,GAC1CA,SAAS,GACT,CAAEJ,QAAQ,CAACO,sBAAsB;EACrC,uBAAuB,EAAIP,QAAQ,IAAMA,QAAQ,CAACQ,sBAAsB;EACxE,eAAe,EAAIR,QAAQ,IAAM;IAChC,IAAKA,QAAQ,CAACS,iBAAiB,KAAKL,SAAS,EAAG;MAC/C;IACD;IA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D,cAAc,CAAE,EAAG;QAC5C,OAAOxB,eAAe,CAAER,MAAO,CAAC;MACjC;MACA,OAAOA,MAAM;IACd;;IAEA;IACA,MAAMqC,uBAAuB,GAC5BtD,eAAe,CAAEiD,cAAc,CAAE,GAAIhD,QAAS,CAAC;IAChD,IAAKqD,uBAAuB,KAAKjD,SAAS,EAAG;MAC5C,OAAOiD,uBAAuB;IAC/B;;IAEA;IACA;IACA;IACA;IACA,OAAOL,cAAc,KAAK,oBAAoB,GAAG,IAAI,GAAG5C,SAAS;EAClE,CAAE,CAAC;AACJ"}
|
|
@@ -131,6 +131,11 @@ export const privateRemoveBlocks = (clientIds, selectPrevious = true, forceRemov
|
|
|
131
131
|
blockNamesForPrompt.add(blockName);
|
|
132
132
|
}
|
|
133
133
|
if (rules['bindings/core/pattern-overrides']) {
|
|
134
|
+
const parentPatternBlocks = select.getBlockParentsByBlockName(clientId, 'core/block');
|
|
135
|
+
// We only need to run this check when editing the original pattern, not pattern instances.
|
|
136
|
+
if (parentPatternBlocks?.length > 0) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
134
139
|
const blockAttributes = select.getBlockAttributes(clientId);
|
|
135
140
|
if (blockAttributes?.metadata?.bindings && JSON.stringify(blockAttributes.metadata.bindings).includes('core/pattern-overrides')) {
|
|
136
141
|
blockNamesForPrompt.add(blockName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","undoIgnoreBlocks","castArray","maybeArray","Array","isArray","privateSettings","__experimentalUpdateSettings","settings","stripExperimentalSettings","reset","cleanSettings","OS","key","includes","type","hideBlockInterface","showBlockInterface","privateRemoveBlocks","clientIds","selectPrevious","forceRemove","select","dispatch","registry","length","rootClientId","getBlockRootClientId","canRemoveBlocks","rules","getBlockRemovalRules","blockNamesForPrompt","Set","queue","messageType","clientId","shift","blockName","getBlockName","add","blockAttributes","getBlockAttributes","metadata","bindings","JSON","stringify","innerBlocks","getBlockOrder","push","size","displayBlockRemovalPrompt","from","selectPreviousBlock","batch","ensureDefaultBlock","count","getBlockCount","__unstableHasCustomAppender","getSettings","insertDefaultBlock","clearBlockRemovalPrompt","setBlockRemovalRules","setOpenedBlockSettingsMenu","setStyleOverride","id","style","deleteStyleOverride","syncDerivedUpdates","callback","isPersistentChange","undefined","updatedBlocks","getBlocks","setLastFocus","lastFocus","stopEditingAsBlocks","focusModeToRevert","__unstableGetTemporarilyEditingFocusModeToRevert","__unstableMarkNextChangeAsNotPersistent","updateBlockAttributes","templateLock","updateBlockListSettings","getBlockListSettings","updateSettings","focusMode","__unstableSetTemporarilyEditingAsBlocks","registerBlockBindingsSource","source","sourceName","name","sourceLabel","label","useSource","lockAttributesEditing","startDragging","stopDragging"],"sources":["@wordpress/block-editor/src/store/private-actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { undoIgnoreBlocks } from './undo-ignore';\n\nconst castArray = ( maybeArray ) =>\n\tArray.isArray( maybeArray ) ? maybeArray : [ maybeArray ];\n\n/**\n * A list of private/experimental block editor settings that\n * should not become a part of the WordPress public API.\n * BlockEditorProvider will remove these settings from the\n * settings object it receives.\n *\n * @see https://github.com/WordPress/gutenberg/pull/46131\n */\nconst privateSettings = [\n\t'inserterMediaCategories',\n\t'blockInspectorAnimation',\n];\n\n/**\n * Action that updates the block editor settings and\n * conditionally preserves the experimental ones.\n *\n * @param {Object} settings Updated settings\n * @param {Object} options Options object.\n * @param {boolean} options.stripExperimentalSettings Whether to strip experimental settings.\n * @param {boolean} options.reset Whether to reset the settings.\n * @return {Object} Action object\n */\nexport function __experimentalUpdateSettings(\n\tsettings,\n\t{ stripExperimentalSettings = false, reset = false } = {}\n) {\n\tlet cleanSettings = settings;\n\t// There are no plugins in the mobile apps, so there is no\n\t// need to strip the experimental settings:\n\tif ( stripExperimentalSettings && Platform.OS === 'web' ) {\n\t\tcleanSettings = {};\n\t\tfor ( const key in settings ) {\n\t\t\tif ( ! privateSettings.includes( key ) ) {\n\t\t\t\tcleanSettings[ key ] = settings[ key ];\n\t\t\t}\n\t\t}\n\t}\n\treturn {\n\t\ttype: 'UPDATE_SETTINGS',\n\t\tsettings: cleanSettings,\n\t\treset,\n\t};\n}\n\n/**\n * Hides the block interface (eg. toolbar, outline, etc.)\n *\n * @return {Object} Action object.\n */\nexport function hideBlockInterface() {\n\treturn {\n\t\ttype: 'HIDE_BLOCK_INTERFACE',\n\t};\n}\n\n/**\n * Shows the block interface (eg. toolbar, outline, etc.)\n *\n * @return {Object} Action object.\n */\nexport function showBlockInterface() {\n\treturn {\n\t\ttype: 'SHOW_BLOCK_INTERFACE',\n\t};\n}\n\n/**\n * Yields action objects used in signalling that the blocks corresponding to\n * the set of specified client IDs are to be removed.\n *\n * Compared to `removeBlocks`, this private interface exposes an additional\n * parameter; see `forceRemove`.\n *\n * @param {string|string[]} clientIds Client IDs of blocks to remove.\n * @param {boolean} selectPrevious True if the previous block\n * or the immediate parent\n * (if no previous block exists)\n * should be selected\n * when a block is removed.\n * @param {boolean} forceRemove Whether to force the operation,\n * bypassing any checks for certain\n * block types.\n */\nexport const privateRemoveBlocks =\n\t( clientIds, selectPrevious = true, forceRemove = false ) =>\n\t( { select, dispatch, registry } ) => {\n\t\tif ( ! clientIds || ! clientIds.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tclientIds = castArray( clientIds );\n\t\tconst rootClientId = select.getBlockRootClientId( clientIds[ 0 ] );\n\t\tconst canRemoveBlocks = select.canRemoveBlocks(\n\t\t\tclientIds,\n\t\t\trootClientId\n\t\t);\n\n\t\tif ( ! canRemoveBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// In certain editing contexts, we'd like to prevent accidental removal\n\t\t// of important blocks. For example, in the site editor, the Query Loop\n\t\t// block is deemed important. In such cases, we'll ask the user for\n\t\t// confirmation that they intended to remove such block(s). However,\n\t\t// the editor instance is responsible for presenting those confirmation\n\t\t// prompts to the user. Any instance opting into removal prompts must\n\t\t// register using `setBlockRemovalRules()`.\n\t\t//\n\t\t// @see https://github.com/WordPress/gutenberg/pull/51145\n\t\tconst rules = ! forceRemove && select.getBlockRemovalRules();\n\t\tif ( rules ) {\n\t\t\tconst blockNamesForPrompt = new Set();\n\n\t\t\t// Given a list of client IDs of blocks that the user intended to\n\t\t\t// remove, perform a tree search (BFS) to find all block names\n\t\t\t// corresponding to \"important\" blocks, i.e. blocks that require a\n\t\t\t// removal prompt.\n\t\t\tconst queue = [ ...clientIds ];\n\t\t\tlet messageType = 'templates';\n\t\t\twhile ( queue.length ) {\n\t\t\t\tconst clientId = queue.shift();\n\t\t\t\tconst blockName = select.getBlockName( clientId );\n\t\t\t\tif ( rules[ blockName ] ) {\n\t\t\t\t\tblockNamesForPrompt.add( blockName );\n\t\t\t\t}\n\n\t\t\t\tif ( rules[ 'bindings/core/pattern-overrides' ] ) {\n\t\t\t\t\tconst blockAttributes =\n\t\t\t\t\t\tselect.getBlockAttributes( clientId );\n\t\t\t\t\tif (\n\t\t\t\t\t\tblockAttributes?.metadata?.bindings &&\n\t\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t\tblockAttributes.metadata.bindings\n\t\t\t\t\t\t).includes( 'core/pattern-overrides' )\n\t\t\t\t\t) {\n\t\t\t\t\t\tblockNamesForPrompt.add( blockName );\n\t\t\t\t\t\tmessageType = 'patternOverrides';\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst innerBlocks = select.getBlockOrder( clientId );\n\t\t\t\tqueue.push( ...innerBlocks );\n\t\t\t}\n\n\t\t\t// If any such blocks were found, trigger the removal prompt and\n\t\t\t// skip any other steps (thus postponing actual removal).\n\t\t\tif ( blockNamesForPrompt.size ) {\n\t\t\t\tdispatch(\n\t\t\t\t\tdisplayBlockRemovalPrompt(\n\t\t\t\t\t\tclientIds,\n\t\t\t\t\t\tselectPrevious,\n\t\t\t\t\t\tArray.from( blockNamesForPrompt ),\n\t\t\t\t\t\tmessageType\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif ( selectPrevious ) {\n\t\t\tdispatch.selectPreviousBlock( clientIds[ 0 ], selectPrevious );\n\t\t}\n\n\t\t// We're batching these two actions because an extra `undo/redo` step can\n\t\t// be created, based on whether we insert a default block or not.\n\t\tregistry.batch( () => {\n\t\t\tdispatch( { type: 'REMOVE_BLOCKS', clientIds } );\n\t\t\t// To avoid a focus loss when removing the last block, assure there is\n\t\t\t// always a default block if the last of the blocks have been removed.\n\t\t\tdispatch( ensureDefaultBlock() );\n\t\t} );\n\t};\n\n/**\n * Action which will insert a default block insert action if there\n * are no other blocks at the root of the editor. This action should be used\n * in actions which may result in no blocks remaining in the editor (removal,\n * replacement, etc).\n */\nexport const ensureDefaultBlock =\n\t() =>\n\t( { select, dispatch } ) => {\n\t\t// To avoid a focus loss when removing the last block, assure there is\n\t\t// always a default block if the last of the blocks have been removed.\n\t\tconst count = select.getBlockCount();\n\t\tif ( count > 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If there's an custom appender, don't insert default block.\n\t\t// We have to remember to manually move the focus elsewhere to\n\t\t// prevent it from being lost though.\n\t\tconst { __unstableHasCustomAppender } = select.getSettings();\n\t\tif ( __unstableHasCustomAppender ) {\n\t\t\treturn;\n\t\t}\n\n\t\tdispatch.insertDefaultBlock();\n\t};\n\n/**\n * Returns an action object used in signalling that a block removal prompt must\n * be displayed.\n *\n * Contrast with `setBlockRemovalRules`.\n *\n * @param {string|string[]} clientIds Client IDs of blocks to remove.\n * @param {boolean} selectPrevious True if the previous block\n * or the immediate parent\n * (if no previous block exists)\n * should be selected\n * when a block is removed.\n * @param {string[]} blockNamesForPrompt Names of the blocks that\n * triggered the need for\n * confirmation before removal.\n * @param {string} messageType The type of message to display.\n *\n * @return {Object} Action object.\n */\nfunction displayBlockRemovalPrompt(\n\tclientIds,\n\tselectPrevious,\n\tblockNamesForPrompt,\n\tmessageType\n) {\n\treturn {\n\t\ttype: 'DISPLAY_BLOCK_REMOVAL_PROMPT',\n\t\tclientIds,\n\t\tselectPrevious,\n\t\tblockNamesForPrompt,\n\t\tmessageType,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a block removal prompt must\n * be cleared, either be cause the user has confirmed or canceled the request\n * for removal.\n *\n * @return {Object} Action object.\n */\nexport function clearBlockRemovalPrompt() {\n\treturn {\n\t\ttype: 'CLEAR_BLOCK_REMOVAL_PROMPT',\n\t};\n}\n\n/**\n * Returns an action object used to set up any rules that a block editor may\n * provide in order to prevent a user from accidentally removing certain\n * blocks. These rules are then used to display a confirmation prompt to the\n * user. For instance, in the Site Editor, the Query Loop block is important\n * enough to warrant such confirmation.\n *\n * IMPORTANT: Registering rules implicitly signals to the `privateRemoveBlocks`\n * action that the editor will be responsible for displaying block removal\n * prompts and confirming deletions. This action is meant to be used by\n * component `BlockRemovalWarningModal` only.\n *\n * The data is a record whose keys are block types (e.g. 'core/query') and\n * whose values are the explanation to be shown to users (e.g. 'Query Loop\n * displays a list of posts or pages.').\n *\n * Contrast with `displayBlockRemovalPrompt`.\n *\n * @param {Record<string,string>|false} rules Block removal rules.\n * @return {Object} Action object.\n */\nexport function setBlockRemovalRules( rules = false ) {\n\treturn {\n\t\ttype: 'SET_BLOCK_REMOVAL_RULES',\n\t\trules,\n\t};\n}\n\n/**\n * Sets the client ID of the block settings menu that is currently open.\n *\n * @param {?string} clientId The block client ID.\n * @return {Object} Action object.\n */\nexport function setOpenedBlockSettingsMenu( clientId ) {\n\treturn {\n\t\ttype: 'SET_OPENED_BLOCK_SETTINGS_MENU',\n\t\tclientId,\n\t};\n}\n\nexport function setStyleOverride( id, style ) {\n\treturn {\n\t\ttype: 'SET_STYLE_OVERRIDE',\n\t\tid,\n\t\tstyle,\n\t};\n}\n\nexport function deleteStyleOverride( id ) {\n\treturn {\n\t\ttype: 'DELETE_STYLE_OVERRIDE',\n\t\tid,\n\t};\n}\n\n/**\n * A higher-order action that mark every change inside a callback as \"non-persistent\"\n * and ignore pushing to the undo history stack. It's primarily used for synchronized\n * derived updates from the block editor without affecting the undo history.\n *\n * @param {() => void} callback The synchronous callback to derive updates.\n */\nexport function syncDerivedUpdates( callback ) {\n\treturn ( { dispatch, select, registry } ) => {\n\t\tregistry.batch( () => {\n\t\t\t// Mark every change in the `callback` as non-persistent.\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SET_EXPLICIT_PERSISTENT',\n\t\t\t\tisPersistentChange: false,\n\t\t\t} );\n\t\t\tcallback();\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SET_EXPLICIT_PERSISTENT',\n\t\t\t\tisPersistentChange: undefined,\n\t\t\t} );\n\n\t\t\t// Ignore pushing undo stack for the updated blocks.\n\t\t\tconst updatedBlocks = select.getBlocks();\n\t\t\tundoIgnoreBlocks.add( updatedBlocks );\n\t\t} );\n\t};\n}\n\n/**\n * Action that sets the element that had focus when focus leaves the editor canvas.\n *\n * @param {Object} lastFocus The last focused element.\n *\n *\n * @return {Object} Action object.\n */\nexport function setLastFocus( lastFocus = null ) {\n\treturn {\n\t\ttype: 'LAST_FOCUS',\n\t\tlastFocus,\n\t};\n}\n\n/**\n * Action that stops temporarily editing as blocks.\n *\n * @param {string} clientId The block's clientId.\n */\nexport function stopEditingAsBlocks( clientId ) {\n\treturn ( { select, dispatch } ) => {\n\t\tconst focusModeToRevert =\n\t\t\tselect.__unstableGetTemporarilyEditingFocusModeToRevert();\n\t\tdispatch.__unstableMarkNextChangeAsNotPersistent();\n\t\tdispatch.updateBlockAttributes( clientId, {\n\t\t\ttemplateLock: 'contentOnly',\n\t\t} );\n\t\tdispatch.updateBlockListSettings( clientId, {\n\t\t\t...select.getBlockListSettings( clientId ),\n\t\t\ttemplateLock: 'contentOnly',\n\t\t} );\n\t\tdispatch.updateSettings( { focusMode: focusModeToRevert } );\n\t\tdispatch.__unstableSetTemporarilyEditingAsBlocks();\n\t};\n}\n\nexport function registerBlockBindingsSource( source ) {\n\treturn {\n\t\ttype: 'REGISTER_BLOCK_BINDINGS_SOURCE',\n\t\tsourceName: source.name,\n\t\tsourceLabel: source.label,\n\t\tuseSource: source.useSource,\n\t\tlockAttributesEditing: source.lockAttributesEditing,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user has begun to drag.\n *\n * @return {Object} Action object.\n */\nexport function startDragging() {\n\treturn {\n\t\ttype: 'START_DRAGGING',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user has stopped dragging.\n *\n * @return {Object} Action object.\n */\nexport function stopDragging() {\n\treturn {\n\t\ttype: 'STOP_DRAGGING',\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,eAAe;AAEhD,MAAMC,SAAS,GAAKC,UAAU,IAC7BC,KAAK,CAACC,OAAO,CAAEF,UAAW,CAAC,GAAGA,UAAU,GAAG,CAAEA,UAAU,CAAE;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,eAAe,GAAG,CACvB,yBAAyB,EACzB,yBAAyB,CACzB;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAC3CC,QAAQ,EACR;EAAEC,yBAAyB,GAAG,KAAK;EAAEC,KAAK,GAAG;AAAM,CAAC,GAAG,CAAC,CAAC,EACxD;EACD,IAAIC,aAAa,GAAGH,QAAQ;EAC5B;EACA;EACA,IAAKC,yBAAyB,IAAIT,QAAQ,CAACY,EAAE,KAAK,KAAK,EAAG;IACzDD,aAAa,GAAG,CAAC,CAAC;IAClB,KAAM,MAAME,GAAG,IAAIL,QAAQ,EAAG;MAC7B,IAAK,CAAEF,eAAe,CAACQ,QAAQ,CAAED,GAAI,CAAC,EAAG;QACxCF,aAAa,CAAEE,GAAG,CAAE,GAAGL,QAAQ,CAAEK,GAAG,CAAE;MACvC;IACD;EACD;EACA,OAAO;IACNE,IAAI,EAAE,iBAAiB;IACvB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C0D,uBAAuB,CAAE9C,QAAQ,EAAE;MAC3C,GAAGb,MAAM,CAAC4D,oBAAoB,CAAE/C,QAAS,CAAC;MAC1C6C,YAAY,EAAE;IACf,CAAE,CAAC;IACHzD,QAAQ,CAAC4D,cAAc,CAAE;MAAEC,SAAS,EAAER;IAAkB,CAAE,CAAC;IAC3DrD,QAAQ,CAAC8D,uCAAuC,CAAC,CAAC;EACnD,CAAC;AACF;AAEA,OAAO,SAASC,2BAA2BA,CAAEC,MAAM,EAAG;EACrD,OAAO;IACNxE,IAAI,EAAE,gCAAgC;IACtCyE,UAAU,EAAED,MAAM,CAACE,IAAI;IACvBC,WAAW,EAAEH,MAAM,CAACI,KAAK;IACzBC,SAAS,EAAEL,MAAM,CAACK,SAAS;IAC3BC,qBAAqB,EAAEN,MAAM,CAACM;EAC/B,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAAA,EAAG;EAC/B,OAAO;IACN/E,IAAI,EAAE;EACP,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASgF,YAAYA,CAAA,EAAG;EAC9B,OAAO;IACNhF,IAAI,EAAE;EACP,CAAC;AACF"}
|
|
1
|
+
{"version":3,"names":["Platform","undoIgnoreBlocks","castArray","maybeArray","Array","isArray","privateSettings","__experimentalUpdateSettings","settings","stripExperimentalSettings","reset","cleanSettings","OS","key","includes","type","hideBlockInterface","showBlockInterface","privateRemoveBlocks","clientIds","selectPrevious","forceRemove","select","dispatch","registry","length","rootClientId","getBlockRootClientId","canRemoveBlocks","rules","getBlockRemovalRules","blockNamesForPrompt","Set","queue","messageType","clientId","shift","blockName","getBlockName","add","parentPatternBlocks","getBlockParentsByBlockName","blockAttributes","getBlockAttributes","metadata","bindings","JSON","stringify","innerBlocks","getBlockOrder","push","size","displayBlockRemovalPrompt","from","selectPreviousBlock","batch","ensureDefaultBlock","count","getBlockCount","__unstableHasCustomAppender","getSettings","insertDefaultBlock","clearBlockRemovalPrompt","setBlockRemovalRules","setOpenedBlockSettingsMenu","setStyleOverride","id","style","deleteStyleOverride","syncDerivedUpdates","callback","isPersistentChange","undefined","updatedBlocks","getBlocks","setLastFocus","lastFocus","stopEditingAsBlocks","focusModeToRevert","__unstableGetTemporarilyEditingFocusModeToRevert","__unstableMarkNextChangeAsNotPersistent","updateBlockAttributes","templateLock","updateBlockListSettings","getBlockListSettings","updateSettings","focusMode","__unstableSetTemporarilyEditingAsBlocks","registerBlockBindingsSource","source","sourceName","name","sourceLabel","label","useSource","lockAttributesEditing","startDragging","stopDragging"],"sources":["@wordpress/block-editor/src/store/private-actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Platform } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { undoIgnoreBlocks } from './undo-ignore';\n\nconst castArray = ( maybeArray ) =>\n\tArray.isArray( maybeArray ) ? maybeArray : [ maybeArray ];\n\n/**\n * A list of private/experimental block editor settings that\n * should not become a part of the WordPress public API.\n * BlockEditorProvider will remove these settings from the\n * settings object it receives.\n *\n * @see https://github.com/WordPress/gutenberg/pull/46131\n */\nconst privateSettings = [\n\t'inserterMediaCategories',\n\t'blockInspectorAnimation',\n];\n\n/**\n * Action that updates the block editor settings and\n * conditionally preserves the experimental ones.\n *\n * @param {Object} settings Updated settings\n * @param {Object} options Options object.\n * @param {boolean} options.stripExperimentalSettings Whether to strip experimental settings.\n * @param {boolean} options.reset Whether to reset the settings.\n * @return {Object} Action object\n */\nexport function __experimentalUpdateSettings(\n\tsettings,\n\t{ stripExperimentalSettings = false, reset = false } = {}\n) {\n\tlet cleanSettings = settings;\n\t// There are no plugins in the mobile apps, so there is no\n\t// need to strip the experimental settings:\n\tif ( stripExperimentalSettings && Platform.OS === 'web' ) {\n\t\tcleanSettings = {};\n\t\tfor ( const key in settings ) {\n\t\t\tif ( ! privateSettings.includes( key ) ) {\n\t\t\t\tcleanSettings[ key ] = settings[ key ];\n\t\t\t}\n\t\t}\n\t}\n\treturn {\n\t\ttype: 'UPDATE_SETTINGS',\n\t\tsettings: cleanSettings,\n\t\treset,\n\t};\n}\n\n/**\n * Hides the block interface (eg. toolbar, outline, etc.)\n *\n * @return {Object} Action object.\n */\nexport function hideBlockInterface() {\n\treturn {\n\t\ttype: 'HIDE_BLOCK_INTERFACE',\n\t};\n}\n\n/**\n * Shows the block interface (eg. toolbar, outline, etc.)\n *\n * @return {Object} Action object.\n */\nexport function showBlockInterface() {\n\treturn {\n\t\ttype: 'SHOW_BLOCK_INTERFACE',\n\t};\n}\n\n/**\n * Yields action objects used in signalling that the blocks corresponding to\n * the set of specified client IDs are to be removed.\n *\n * Compared to `removeBlocks`, this private interface exposes an additional\n * parameter; see `forceRemove`.\n *\n * @param {string|string[]} clientIds Client IDs of blocks to remove.\n * @param {boolean} selectPrevious True if the previous block\n * or the immediate parent\n * (if no previous block exists)\n * should be selected\n * when a block is removed.\n * @param {boolean} forceRemove Whether to force the operation,\n * bypassing any checks for certain\n * block types.\n */\nexport const privateRemoveBlocks =\n\t( clientIds, selectPrevious = true, forceRemove = false ) =>\n\t( { select, dispatch, registry } ) => {\n\t\tif ( ! clientIds || ! clientIds.length ) {\n\t\t\treturn;\n\t\t}\n\n\t\tclientIds = castArray( clientIds );\n\t\tconst rootClientId = select.getBlockRootClientId( clientIds[ 0 ] );\n\t\tconst canRemoveBlocks = select.canRemoveBlocks(\n\t\t\tclientIds,\n\t\t\trootClientId\n\t\t);\n\n\t\tif ( ! canRemoveBlocks ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// In certain editing contexts, we'd like to prevent accidental removal\n\t\t// of important blocks. For example, in the site editor, the Query Loop\n\t\t// block is deemed important. In such cases, we'll ask the user for\n\t\t// confirmation that they intended to remove such block(s). However,\n\t\t// the editor instance is responsible for presenting those confirmation\n\t\t// prompts to the user. Any instance opting into removal prompts must\n\t\t// register using `setBlockRemovalRules()`.\n\t\t//\n\t\t// @see https://github.com/WordPress/gutenberg/pull/51145\n\t\tconst rules = ! forceRemove && select.getBlockRemovalRules();\n\t\tif ( rules ) {\n\t\t\tconst blockNamesForPrompt = new Set();\n\n\t\t\t// Given a list of client IDs of blocks that the user intended to\n\t\t\t// remove, perform a tree search (BFS) to find all block names\n\t\t\t// corresponding to \"important\" blocks, i.e. blocks that require a\n\t\t\t// removal prompt.\n\t\t\tconst queue = [ ...clientIds ];\n\t\t\tlet messageType = 'templates';\n\t\t\twhile ( queue.length ) {\n\t\t\t\tconst clientId = queue.shift();\n\t\t\t\tconst blockName = select.getBlockName( clientId );\n\t\t\t\tif ( rules[ blockName ] ) {\n\t\t\t\t\tblockNamesForPrompt.add( blockName );\n\t\t\t\t}\n\n\t\t\t\tif ( rules[ 'bindings/core/pattern-overrides' ] ) {\n\t\t\t\t\tconst parentPatternBlocks =\n\t\t\t\t\t\tselect.getBlockParentsByBlockName(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t'core/block'\n\t\t\t\t\t\t);\n\t\t\t\t\t// We only need to run this check when editing the original pattern, not pattern instances.\n\t\t\t\t\tif ( parentPatternBlocks?.length > 0 ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tconst blockAttributes =\n\t\t\t\t\t\tselect.getBlockAttributes( clientId );\n\t\t\t\t\tif (\n\t\t\t\t\t\tblockAttributes?.metadata?.bindings &&\n\t\t\t\t\t\tJSON.stringify(\n\t\t\t\t\t\t\tblockAttributes.metadata.bindings\n\t\t\t\t\t\t).includes( 'core/pattern-overrides' )\n\t\t\t\t\t) {\n\t\t\t\t\t\tblockNamesForPrompt.add( blockName );\n\t\t\t\t\t\tmessageType = 'patternOverrides';\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst innerBlocks = select.getBlockOrder( clientId );\n\t\t\t\tqueue.push( ...innerBlocks );\n\t\t\t}\n\n\t\t\t// If any such blocks were found, trigger the removal prompt and\n\t\t\t// skip any other steps (thus postponing actual removal).\n\t\t\tif ( blockNamesForPrompt.size ) {\n\t\t\t\tdispatch(\n\t\t\t\t\tdisplayBlockRemovalPrompt(\n\t\t\t\t\t\tclientIds,\n\t\t\t\t\t\tselectPrevious,\n\t\t\t\t\t\tArray.from( blockNamesForPrompt ),\n\t\t\t\t\t\tmessageType\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tif ( selectPrevious ) {\n\t\t\tdispatch.selectPreviousBlock( clientIds[ 0 ], selectPrevious );\n\t\t}\n\n\t\t// We're batching these two actions because an extra `undo/redo` step can\n\t\t// be created, based on whether we insert a default block or not.\n\t\tregistry.batch( () => {\n\t\t\tdispatch( { type: 'REMOVE_BLOCKS', clientIds } );\n\t\t\t// To avoid a focus loss when removing the last block, assure there is\n\t\t\t// always a default block if the last of the blocks have been removed.\n\t\t\tdispatch( ensureDefaultBlock() );\n\t\t} );\n\t};\n\n/**\n * Action which will insert a default block insert action if there\n * are no other blocks at the root of the editor. This action should be used\n * in actions which may result in no blocks remaining in the editor (removal,\n * replacement, etc).\n */\nexport const ensureDefaultBlock =\n\t() =>\n\t( { select, dispatch } ) => {\n\t\t// To avoid a focus loss when removing the last block, assure there is\n\t\t// always a default block if the last of the blocks have been removed.\n\t\tconst count = select.getBlockCount();\n\t\tif ( count > 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If there's an custom appender, don't insert default block.\n\t\t// We have to remember to manually move the focus elsewhere to\n\t\t// prevent it from being lost though.\n\t\tconst { __unstableHasCustomAppender } = select.getSettings();\n\t\tif ( __unstableHasCustomAppender ) {\n\t\t\treturn;\n\t\t}\n\n\t\tdispatch.insertDefaultBlock();\n\t};\n\n/**\n * Returns an action object used in signalling that a block removal prompt must\n * be displayed.\n *\n * Contrast with `setBlockRemovalRules`.\n *\n * @param {string|string[]} clientIds Client IDs of blocks to remove.\n * @param {boolean} selectPrevious True if the previous block\n * or the immediate parent\n * (if no previous block exists)\n * should be selected\n * when a block is removed.\n * @param {string[]} blockNamesForPrompt Names of the blocks that\n * triggered the need for\n * confirmation before removal.\n * @param {string} messageType The type of message to display.\n *\n * @return {Object} Action object.\n */\nfunction displayBlockRemovalPrompt(\n\tclientIds,\n\tselectPrevious,\n\tblockNamesForPrompt,\n\tmessageType\n) {\n\treturn {\n\t\ttype: 'DISPLAY_BLOCK_REMOVAL_PROMPT',\n\t\tclientIds,\n\t\tselectPrevious,\n\t\tblockNamesForPrompt,\n\t\tmessageType,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that a block removal prompt must\n * be cleared, either be cause the user has confirmed or canceled the request\n * for removal.\n *\n * @return {Object} Action object.\n */\nexport function clearBlockRemovalPrompt() {\n\treturn {\n\t\ttype: 'CLEAR_BLOCK_REMOVAL_PROMPT',\n\t};\n}\n\n/**\n * Returns an action object used to set up any rules that a block editor may\n * provide in order to prevent a user from accidentally removing certain\n * blocks. These rules are then used to display a confirmation prompt to the\n * user. For instance, in the Site Editor, the Query Loop block is important\n * enough to warrant such confirmation.\n *\n * IMPORTANT: Registering rules implicitly signals to the `privateRemoveBlocks`\n * action that the editor will be responsible for displaying block removal\n * prompts and confirming deletions. This action is meant to be used by\n * component `BlockRemovalWarningModal` only.\n *\n * The data is a record whose keys are block types (e.g. 'core/query') and\n * whose values are the explanation to be shown to users (e.g. 'Query Loop\n * displays a list of posts or pages.').\n *\n * Contrast with `displayBlockRemovalPrompt`.\n *\n * @param {Record<string,string>|false} rules Block removal rules.\n * @return {Object} Action object.\n */\nexport function setBlockRemovalRules( rules = false ) {\n\treturn {\n\t\ttype: 'SET_BLOCK_REMOVAL_RULES',\n\t\trules,\n\t};\n}\n\n/**\n * Sets the client ID of the block settings menu that is currently open.\n *\n * @param {?string} clientId The block client ID.\n * @return {Object} Action object.\n */\nexport function setOpenedBlockSettingsMenu( clientId ) {\n\treturn {\n\t\ttype: 'SET_OPENED_BLOCK_SETTINGS_MENU',\n\t\tclientId,\n\t};\n}\n\nexport function setStyleOverride( id, style ) {\n\treturn {\n\t\ttype: 'SET_STYLE_OVERRIDE',\n\t\tid,\n\t\tstyle,\n\t};\n}\n\nexport function deleteStyleOverride( id ) {\n\treturn {\n\t\ttype: 'DELETE_STYLE_OVERRIDE',\n\t\tid,\n\t};\n}\n\n/**\n * A higher-order action that mark every change inside a callback as \"non-persistent\"\n * and ignore pushing to the undo history stack. It's primarily used for synchronized\n * derived updates from the block editor without affecting the undo history.\n *\n * @param {() => void} callback The synchronous callback to derive updates.\n */\nexport function syncDerivedUpdates( callback ) {\n\treturn ( { dispatch, select, registry } ) => {\n\t\tregistry.batch( () => {\n\t\t\t// Mark every change in the `callback` as non-persistent.\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SET_EXPLICIT_PERSISTENT',\n\t\t\t\tisPersistentChange: false,\n\t\t\t} );\n\t\t\tcallback();\n\t\t\tdispatch( {\n\t\t\t\ttype: 'SET_EXPLICIT_PERSISTENT',\n\t\t\t\tisPersistentChange: undefined,\n\t\t\t} );\n\n\t\t\t// Ignore pushing undo stack for the updated blocks.\n\t\t\tconst updatedBlocks = select.getBlocks();\n\t\t\tundoIgnoreBlocks.add( updatedBlocks );\n\t\t} );\n\t};\n}\n\n/**\n * Action that sets the element that had focus when focus leaves the editor canvas.\n *\n * @param {Object} lastFocus The last focused element.\n *\n *\n * @return {Object} Action object.\n */\nexport function setLastFocus( lastFocus = null ) {\n\treturn {\n\t\ttype: 'LAST_FOCUS',\n\t\tlastFocus,\n\t};\n}\n\n/**\n * Action that stops temporarily editing as blocks.\n *\n * @param {string} clientId The block's clientId.\n */\nexport function stopEditingAsBlocks( clientId ) {\n\treturn ( { select, dispatch } ) => {\n\t\tconst focusModeToRevert =\n\t\t\tselect.__unstableGetTemporarilyEditingFocusModeToRevert();\n\t\tdispatch.__unstableMarkNextChangeAsNotPersistent();\n\t\tdispatch.updateBlockAttributes( clientId, {\n\t\t\ttemplateLock: 'contentOnly',\n\t\t} );\n\t\tdispatch.updateBlockListSettings( clientId, {\n\t\t\t...select.getBlockListSettings( clientId ),\n\t\t\ttemplateLock: 'contentOnly',\n\t\t} );\n\t\tdispatch.updateSettings( { focusMode: focusModeToRevert } );\n\t\tdispatch.__unstableSetTemporarilyEditingAsBlocks();\n\t};\n}\n\nexport function registerBlockBindingsSource( source ) {\n\treturn {\n\t\ttype: 'REGISTER_BLOCK_BINDINGS_SOURCE',\n\t\tsourceName: source.name,\n\t\tsourceLabel: source.label,\n\t\tuseSource: source.useSource,\n\t\tlockAttributesEditing: source.lockAttributesEditing,\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user has begun to drag.\n *\n * @return {Object} Action object.\n */\nexport function startDragging() {\n\treturn {\n\t\ttype: 'START_DRAGGING',\n\t};\n}\n\n/**\n * Returns an action object used in signalling that the user has stopped dragging.\n *\n * @return {Object} Action object.\n */\nexport function stopDragging() {\n\treturn {\n\t\ttype: 'STOP_DRAGGING',\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;;AAE7C;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,eAAe;AAEhD,MAAMC,SAAS,GAAKC,UAAU,IAC7BC,KAAK,CAACC,OAAO,CAAEF,UAAW,CAAC,GAAGA,UAAU,GAAG,CAAEA,UAAU,CAAE;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,eAAe,GAAG,CACvB,yBAAyB,EACzB,yBAAyB,CACzB;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,4BAA4BA,CAC3CC,QAAQ,EACR;EAAEC,yBAAyB,GAAG,KAAK;EAAEC,KAAK,GAAG;AAAM,CAAC,GAAG,CAAC,CAAC,EACxD;EACD,IAAIC,aAAa,GAAGH,QAAQ;EAC5B;EACA;EACA,IAAKC,yBAAyB,IAAIT,QAAQ,CAACY,EAAE,KAAK,KAAK,EAAG;IACzDD,aAAa,GAAG,CAAC,CAAC;IAClB,KAAM,MAAME,GAAG,IAAIL,QAAQ,EAAG;MAC7B,IAAK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ACA,OAAO,SAASC,mBAAmBA,CAAE1C,QAAQ,EAAG;EAC/C,OAAO,CAAE;IAAEb,MAAM;IAAEC;EAAS,CAAC,KAAM;IAClC,MAAMuD,iBAAiB,GACtBxD,MAAM,CAACyD,gDAAgD,CAAC,CAAC;IAC1DxD,QAAQ,CAACyD,uCAAuC,CAAC,CAAC;IAClDzD,QAAQ,CAAC0D,qBAAqB,CAAE9C,QAAQ,EAAE;MACzC+C,YAAY,EAAE;IACf,CAAE,CAAC;IACH3D,QAAQ,CAAC4D,uBAAuB,CAAEhD,QAAQ,EAAE;MAC3C,GAAGb,MAAM,CAAC8D,oBAAoB,CAAEjD,QAAS,CAAC;MAC1C+C,YAAY,EAAE;IACf,CAAE,CAAC;IACH3D,QAAQ,CAAC8D,cAAc,CAAE;MAAEC,SAAS,EAAER;IAAkB,CAAE,CAAC;IAC3DvD,QAAQ,CAACgE,uCAAuC,CAAC,CAAC;EACnD,CAAC;AACF;AAEA,OAAO,SAASC,2BAA2BA,CAAEC,MAAM,EAAG;EACrD,OAAO;IACN1E,IAAI,EAAE,gCAAgC;IACtC2E,UAAU,EAAED,MAAM,CAACE,IAAI;IACvBC,WAAW,EAAEH,MAAM,CAACI,KAAK;IACzBC,SAAS,EAAEL,MAAM,CAACK,SAAS;IAC3BC,qBAAqB,EAAEN,MAAM,CAACM;EAC/B,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAAA,EAAG;EAC/B,OAAO;IACNjF,IAAI,EAAE;EACP,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASkF,YAAYA,CAAA,EAAG;EAC9B,OAAO;IACNlF,IAAI,EAAE;EACP,CAAC;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "12.19.
|
|
3
|
+
"version": "12.19.2",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -35,35 +35,35 @@
|
|
|
35
35
|
"@emotion/react": "^11.7.1",
|
|
36
36
|
"@emotion/styled": "^11.6.0",
|
|
37
37
|
"@react-spring/web": "^9.4.5",
|
|
38
|
-
"@wordpress/a11y": "^3.51.
|
|
39
|
-
"@wordpress/api-fetch": "^6.48.
|
|
40
|
-
"@wordpress/blob": "^3.51.
|
|
41
|
-
"@wordpress/blocks": "^12.28.
|
|
42
|
-
"@wordpress/commands": "^0.22.
|
|
43
|
-
"@wordpress/components": "^26.0.
|
|
44
|
-
"@wordpress/compose": "^6.28.
|
|
45
|
-
"@wordpress/data": "^9.21.
|
|
46
|
-
"@wordpress/date": "^4.51.
|
|
47
|
-
"@wordpress/deprecated": "^3.51.
|
|
48
|
-
"@wordpress/dom": "^3.51.
|
|
49
|
-
"@wordpress/element": "^5.28.
|
|
50
|
-
"@wordpress/escape-html": "^2.51.
|
|
51
|
-
"@wordpress/hooks": "^3.51.
|
|
52
|
-
"@wordpress/html-entities": "^3.51.
|
|
53
|
-
"@wordpress/i18n": "^4.51.
|
|
54
|
-
"@wordpress/icons": "^9.42.
|
|
55
|
-
"@wordpress/is-shallow-equal": "^4.51.
|
|
56
|
-
"@wordpress/keyboard-shortcuts": "^4.28.
|
|
57
|
-
"@wordpress/keycodes": "^3.51.
|
|
58
|
-
"@wordpress/notices": "^4.19.
|
|
59
|
-
"@wordpress/preferences": "^3.28.
|
|
60
|
-
"@wordpress/private-apis": "^0.33.
|
|
61
|
-
"@wordpress/rich-text": "^6.28.
|
|
62
|
-
"@wordpress/style-engine": "^1.34.
|
|
63
|
-
"@wordpress/token-list": "^2.51.
|
|
64
|
-
"@wordpress/url": "^3.52.
|
|
65
|
-
"@wordpress/warning": "^2.51.
|
|
66
|
-
"@wordpress/wordcount": "^3.51.
|
|
38
|
+
"@wordpress/a11y": "^3.51.1",
|
|
39
|
+
"@wordpress/api-fetch": "^6.48.1",
|
|
40
|
+
"@wordpress/blob": "^3.51.1",
|
|
41
|
+
"@wordpress/blocks": "^12.28.2",
|
|
42
|
+
"@wordpress/commands": "^0.22.2",
|
|
43
|
+
"@wordpress/components": "^26.0.2",
|
|
44
|
+
"@wordpress/compose": "^6.28.1",
|
|
45
|
+
"@wordpress/data": "^9.21.1",
|
|
46
|
+
"@wordpress/date": "^4.51.1",
|
|
47
|
+
"@wordpress/deprecated": "^3.51.1",
|
|
48
|
+
"@wordpress/dom": "^3.51.1",
|
|
49
|
+
"@wordpress/element": "^5.28.1",
|
|
50
|
+
"@wordpress/escape-html": "^2.51.1",
|
|
51
|
+
"@wordpress/hooks": "^3.51.1",
|
|
52
|
+
"@wordpress/html-entities": "^3.51.1",
|
|
53
|
+
"@wordpress/i18n": "^4.51.1",
|
|
54
|
+
"@wordpress/icons": "^9.42.1",
|
|
55
|
+
"@wordpress/is-shallow-equal": "^4.51.1",
|
|
56
|
+
"@wordpress/keyboard-shortcuts": "^4.28.1",
|
|
57
|
+
"@wordpress/keycodes": "^3.51.1",
|
|
58
|
+
"@wordpress/notices": "^4.19.1",
|
|
59
|
+
"@wordpress/preferences": "^3.28.2",
|
|
60
|
+
"@wordpress/private-apis": "^0.33.1",
|
|
61
|
+
"@wordpress/rich-text": "^6.28.2",
|
|
62
|
+
"@wordpress/style-engine": "^1.34.1",
|
|
63
|
+
"@wordpress/token-list": "^2.51.1",
|
|
64
|
+
"@wordpress/url": "^3.52.1",
|
|
65
|
+
"@wordpress/warning": "^2.51.1",
|
|
66
|
+
"@wordpress/wordcount": "^3.51.1",
|
|
67
67
|
"change-case": "^4.1.2",
|
|
68
68
|
"classnames": "^2.3.1",
|
|
69
69
|
"colord": "^2.7.0",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"publishConfig": {
|
|
88
88
|
"access": "public"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "730beb7fd33d3382d6032c3f33e451625a0fcf36"
|
|
91
91
|
}
|
|
@@ -19,7 +19,7 @@ import { __ } from '@wordpress/i18n';
|
|
|
19
19
|
import BorderRadiusControl from '../border-radius-control';
|
|
20
20
|
import { useColorsPerOrigin } from './hooks';
|
|
21
21
|
import { getValueFromVariable, TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';
|
|
22
|
-
import {
|
|
22
|
+
import { overrideOrigins } from '../../store/get-block-settings';
|
|
23
23
|
import { setImmutably } from '../../utils/object';
|
|
24
24
|
import { getBorderPanelLabel } from '../../hooks/border';
|
|
25
25
|
import { ShadowPopover } from './shadow-panel-components';
|
|
@@ -154,12 +154,10 @@ export default function BorderPanel( {
|
|
|
154
154
|
|
|
155
155
|
// Shadow
|
|
156
156
|
const shadow = decodeValue( inheritedValue?.shadow );
|
|
157
|
-
const shadowPresets = settings?.shadow?.presets;
|
|
158
|
-
const
|
|
159
|
-
? mergeOrigins( shadowPresets )
|
|
160
|
-
: [];
|
|
157
|
+
const shadowPresets = settings?.shadow?.presets ?? {};
|
|
158
|
+
const overriddenShadowPresets = overrideOrigins( shadowPresets ) ?? [];
|
|
161
159
|
const setShadow = ( newValue ) => {
|
|
162
|
-
const slug =
|
|
160
|
+
const slug = overriddenShadowPresets?.find(
|
|
163
161
|
( { shadow: shadowName } ) => shadowName === newValue
|
|
164
162
|
)?.slug;
|
|
165
163
|
|
|
@@ -22,8 +22,8 @@ const translationMap = {
|
|
|
22
22
|
h4: __( 'H4' ),
|
|
23
23
|
h5: __( 'H5' ),
|
|
24
24
|
h6: __( 'H6' ),
|
|
25
|
-
'settings.color': __( 'Color
|
|
26
|
-
'settings.typography': __( 'Typography
|
|
25
|
+
'settings.color': __( 'Color' ),
|
|
26
|
+
'settings.typography': __( 'Typography' ),
|
|
27
27
|
'styles.color': __( 'Colors' ),
|
|
28
28
|
'styles.spacing': __( 'Spacing' ),
|
|
29
29
|
'styles.typography': __( 'Typography' ),
|
|
@@ -54,12 +54,7 @@ function getTranslation( key ) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
if ( keyArray?.[ 0 ] === 'elements' ) {
|
|
57
|
-
|
|
58
|
-
return sprintf(
|
|
59
|
-
// translators: %s: element name, e.g., heading button, link, caption.
|
|
60
|
-
__( '%s element' ),
|
|
61
|
-
elementName
|
|
62
|
-
);
|
|
57
|
+
return translationMap[ keyArray[ 1 ] ] || keyArray[ 1 ];
|
|
63
58
|
}
|
|
64
59
|
|
|
65
60
|
return undefined;
|
|
@@ -114,9 +109,9 @@ function deepCompare( changedObject, originalObject, parentPath = '' ) {
|
|
|
114
109
|
*
|
|
115
110
|
* @param {Object} next The changed object to compare.
|
|
116
111
|
* @param {Object} previous The original object to compare against.
|
|
117
|
-
* @return {
|
|
112
|
+
* @return {Array[]} A 2-dimensional array of tuples: [ "group", "translated change" ].
|
|
118
113
|
*/
|
|
119
|
-
function getGlobalStylesChangelist( next, previous ) {
|
|
114
|
+
export function getGlobalStylesChangelist( next, previous ) {
|
|
120
115
|
const cacheKey = JSON.stringify( { next, previous } );
|
|
121
116
|
|
|
122
117
|
if ( globalStylesChangesCache.has( cacheKey ) ) {
|
|
@@ -160,12 +155,12 @@ function getGlobalStylesChangelist( next, previous ) {
|
|
|
160
155
|
const result = [ ...new Set( changedValueTree ) ]
|
|
161
156
|
/*
|
|
162
157
|
* Translate the keys.
|
|
163
|
-
* Remove
|
|
158
|
+
* Remove empty translations.
|
|
164
159
|
*/
|
|
165
160
|
.reduce( ( acc, curr ) => {
|
|
166
161
|
const translation = getTranslation( curr );
|
|
167
|
-
if ( translation
|
|
168
|
-
acc.push( translation );
|
|
162
|
+
if ( translation ) {
|
|
163
|
+
acc.push( [ curr.split( '.' )[ 0 ], translation ] );
|
|
169
164
|
}
|
|
170
165
|
return acc;
|
|
171
166
|
}, [] );
|
|
@@ -176,29 +171,74 @@ function getGlobalStylesChangelist( next, previous ) {
|
|
|
176
171
|
}
|
|
177
172
|
|
|
178
173
|
/**
|
|
179
|
-
* From a getGlobalStylesChangelist() result, returns
|
|
180
|
-
*
|
|
174
|
+
* From a getGlobalStylesChangelist() result, returns an array of translated global styles changes, grouped by type.
|
|
175
|
+
* The types are 'blocks', 'elements', 'settings', and 'styles'.
|
|
181
176
|
*
|
|
182
177
|
* @param {Object} next The changed object to compare.
|
|
183
178
|
* @param {Object} previous The original object to compare against.
|
|
184
179
|
* @param {{maxResults:number}} options Options. maxResults: results to return before truncating.
|
|
185
|
-
* @return {string[]}
|
|
180
|
+
* @return {string[]} An array of translated changes.
|
|
186
181
|
*/
|
|
187
182
|
export default function getGlobalStylesChanges( next, previous, options = {} ) {
|
|
188
|
-
|
|
189
|
-
const changesLength =
|
|
183
|
+
let changeList = getGlobalStylesChangelist( next, previous );
|
|
184
|
+
const changesLength = changeList.length;
|
|
190
185
|
const { maxResults } = options;
|
|
191
186
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
187
|
+
if ( changesLength ) {
|
|
188
|
+
// Truncate to `n` results if necessary.
|
|
189
|
+
if ( !! maxResults && changesLength > maxResults ) {
|
|
190
|
+
changeList = changeList.slice( 0, maxResults );
|
|
191
|
+
}
|
|
192
|
+
return Object.entries(
|
|
193
|
+
changeList.reduce( ( acc, curr ) => {
|
|
194
|
+
const group = acc[ curr[ 0 ] ] || [];
|
|
195
|
+
if ( ! group.includes( curr[ 1 ] ) ) {
|
|
196
|
+
acc[ curr[ 0 ] ] = [ ...group, curr[ 1 ] ];
|
|
197
|
+
}
|
|
198
|
+
return acc;
|
|
199
|
+
}, {} )
|
|
200
|
+
).map( ( [ key, changeValues ] ) => {
|
|
201
|
+
const changeValuesLength = changeValues.length;
|
|
202
|
+
const joinedChangesValue = changeValues.join( __( ', ' ) );
|
|
203
|
+
switch ( key ) {
|
|
204
|
+
case 'blocks': {
|
|
205
|
+
return sprintf(
|
|
206
|
+
// translators: %s: a list of block names separated by a comma.
|
|
207
|
+
_n( '%s block.', '%s blocks.', changeValuesLength ),
|
|
208
|
+
joinedChangesValue
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
case 'elements': {
|
|
212
|
+
return sprintf(
|
|
213
|
+
// translators: %s: a list of element names separated by a comma.
|
|
214
|
+
_n( '%s element.', '%s elements.', changeValuesLength ),
|
|
215
|
+
joinedChangesValue
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
case 'settings': {
|
|
219
|
+
return sprintf(
|
|
220
|
+
// translators: %s: a list of theme.json setting labels separated by a comma.
|
|
221
|
+
__( '%s settings.' ),
|
|
222
|
+
joinedChangesValue
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
case 'styles': {
|
|
226
|
+
return sprintf(
|
|
227
|
+
// translators: %s: a list of theme.json top-level styles labels separated by a comma.
|
|
228
|
+
__( '%s styles.' ),
|
|
229
|
+
joinedChangesValue
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
default: {
|
|
233
|
+
return sprintf(
|
|
234
|
+
// translators: %s: a list of global styles changes separated by a comma.
|
|
235
|
+
__( '%s.' ),
|
|
236
|
+
joinedChangesValue
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
} );
|
|
201
241
|
}
|
|
202
242
|
|
|
203
|
-
return
|
|
243
|
+
return EMPTY_ARRAY;
|
|
204
244
|
}
|