@wordpress/block-editor 12.19.1 → 12.19.3
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/block-tools/insertion-point.js +4 -1
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/global-styles/advanced-panel.js +5 -10
- package/build/components/global-styles/advanced-panel.js.map +1 -1
- 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/shadow-panel-components.js +3 -3
- package/build/components/global-styles/shadow-panel-components.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/inserter/media-tab/media-preview.js +1 -1
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/rich-text/index.js +7 -3
- package/build/components/rich-text/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/components/rich-text/use-paste-handler.js +25 -26
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/hooks/background.js +4 -2
- package/build/hooks/background.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/private-apis.js +3 -1
- package/build/private-apis.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/index.js +0 -2
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +5 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-keys.js +8 -0
- package/build/store/private-keys.js.map +1 -0
- package/build/store/private-selectors.js +6 -9
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +1 -9
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +7 -12
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +7 -2
- package/build/store/utils.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +4 -1
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/global-styles/advanced-panel.js +6 -11
- package/build-module/components/global-styles/advanced-panel.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/shadow-panel-components.js +3 -3
- package/build-module/components/global-styles/shadow-panel-components.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/inserter/media-tab/media-preview.js +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/rich-text/index.js +7 -3
- package/build-module/components/rich-text/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/components/rich-text/use-paste-handler.js +25 -26
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/hooks/background.js +4 -2
- package/build-module/hooks/background.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/private-apis.js +3 -1
- package/build-module/private-apis.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/index.js +0 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +5 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-keys.js +2 -0
- package/build-module/store/private-keys.js.map +1 -0
- package/build-module/store/private-selectors.js +5 -6
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +1 -9
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +8 -13
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +6 -2
- package/build-module/store/utils.js.map +1 -1
- package/build-style/style-rtl.css +0 -10
- package/build-style/style.css +0 -10
- package/package.json +31 -31
- package/src/components/block-tools/insertion-point.js +6 -1
- package/src/components/global-styles/advanced-panel.js +6 -12
- 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/shadow-panel-components.js +3 -3
- package/src/components/global-styles/style.scss +0 -10
- 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/inserter/media-tab/media-preview.js +6 -1
- package/src/components/rich-text/index.js +12 -5
- package/src/components/rich-text/index.native.js +1 -0
- package/src/components/rich-text/use-enter.js +1 -0
- package/src/components/rich-text/use-paste-handler.js +26 -25
- package/src/hooks/background.js +5 -2
- package/src/hooks/use-bindings-attributes.js +0 -21
- package/src/hooks/utils.js +24 -8
- package/src/private-apis.js +2 -0
- package/src/store/get-block-settings.js +15 -4
- package/src/store/index.js +0 -2
- package/src/store/private-actions.js +9 -0
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +4 -7
- package/src/store/reducer.js +0 -10
- package/src/store/selectors.js +7 -15
- package/src/store/utils.js +7 -2
- package/build/store/resolvers.js +0 -27
- package/build/store/resolvers.js.map +0 -1
- package/build-module/store/resolvers.js +0 -20
- package/build-module/store/resolvers.js.map +0 -1
- package/src/store/resolvers.js +0 -17
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { selectBlockPatternsKey } from './private-keys';
|
|
1
5
|
export const checkAllowList = (list, item, defaultResult = null) => {
|
|
2
6
|
if (typeof list === 'boolean') {
|
|
3
7
|
return list;
|
|
@@ -30,7 +34,7 @@ export const checkAllowListRecursive = (blocks, allowedBlockTypes) => {
|
|
|
30
34
|
}
|
|
31
35
|
return true;
|
|
32
36
|
};
|
|
33
|
-
export const getAllPatternsDependants = state => {
|
|
34
|
-
return [state.settings.__experimentalBlockPatterns, state.settings.__experimentalUserPatternCategories, state.settings.__experimentalReusableBlocks, state.settings
|
|
37
|
+
export const getAllPatternsDependants = select => state => {
|
|
38
|
+
return [state.settings.__experimentalBlockPatterns, state.settings.__experimentalUserPatternCategories, state.settings.__experimentalReusableBlocks, state.settings[selectBlockPatternsKey]?.(select), state.blockPatterns];
|
|
35
39
|
};
|
|
36
40
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["checkAllowList","list","item","defaultResult","Array","isArray","includes","checkAllowListRecursive","blocks","allowedBlockTypes","blocksQueue","length","block","shift","isAllowed","name","blockName","innerBlocks","forEach","innerBlock","push","getAllPatternsDependants","state","settings","__experimentalBlockPatterns","__experimentalUserPatternCategories","__experimentalReusableBlocks","
|
|
1
|
+
{"version":3,"names":["selectBlockPatternsKey","checkAllowList","list","item","defaultResult","Array","isArray","includes","checkAllowListRecursive","blocks","allowedBlockTypes","blocksQueue","length","block","shift","isAllowed","name","blockName","innerBlocks","forEach","innerBlock","push","getAllPatternsDependants","select","state","settings","__experimentalBlockPatterns","__experimentalUserPatternCategories","__experimentalReusableBlocks","blockPatterns"],"sources":["@wordpress/block-editor/src/store/utils.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { selectBlockPatternsKey } from './private-keys';\n\nexport const checkAllowList = ( list, item, defaultResult = null ) => {\n\tif ( typeof list === 'boolean' ) {\n\t\treturn list;\n\t}\n\tif ( Array.isArray( list ) ) {\n\t\t// TODO: when there is a canonical way to detect that we are editing a post\n\t\t// the following check should be changed to something like:\n\t\t// if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )\n\t\tif ( list.includes( 'core/post-content' ) && item === null ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn list.includes( item );\n\t}\n\treturn defaultResult;\n};\n\nexport const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {\n\tif ( typeof allowedBlockTypes === 'boolean' ) {\n\t\treturn allowedBlockTypes;\n\t}\n\n\tconst blocksQueue = [ ...blocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\n\t\tconst isAllowed = checkAllowList(\n\t\t\tallowedBlockTypes,\n\t\t\tblock.name || block.blockName,\n\t\t\ttrue\n\t\t);\n\t\tif ( ! isAllowed ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\n\treturn true;\n};\n\nexport const getAllPatternsDependants = ( select ) => ( state ) => {\n\treturn [\n\t\tstate.settings.__experimentalBlockPatterns,\n\t\tstate.settings.__experimentalUserPatternCategories,\n\t\tstate.settings.__experimentalReusableBlocks,\n\t\tstate.settings[ selectBlockPatternsKey ]?.( select ),\n\t\tstate.blockPatterns,\n\t];\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAsB,QAAQ,gBAAgB;AAEvD,OAAO,MAAMC,cAAc,GAAGA,CAAEC,IAAI,EAAEC,IAAI,EAAEC,aAAa,GAAG,IAAI,KAAM;EACrE,IAAK,OAAOF,IAAI,KAAK,SAAS,EAAG;IAChC,OAAOA,IAAI;EACZ;EACA,IAAKG,KAAK,CAACC,OAAO,CAAEJ,IAAK,CAAC,EAAG;IAC5B;IACA;IACA;IACA,IAAKA,IAAI,CAACK,QAAQ,CAAE,mBAAoB,CAAC,IAAIJ,IAAI,KAAK,IAAI,EAAG;MAC5D,OAAO,IAAI;IACZ;IACA,OAAOD,IAAI,CAACK,QAAQ,CAAEJ,IAAK,CAAC;EAC7B;EACA,OAAOC,aAAa;AACrB,CAAC;AAED,OAAO,MAAMI,uBAAuB,GAAGA,CAAEC,MAAM,EAAEC,iBAAiB,KAAM;EACvE,IAAK,OAAOA,iBAAiB,KAAK,SAAS,EAAG;IAC7C,OAAOA,iBAAiB;EACzB;EAEA,MAAMC,WAAW,GAAG,CAAE,GAAGF,MAAM,CAAE;EACjC,OAAQE,WAAW,CAACC,MAAM,GAAG,CAAC,EAAG;IAChC,MAAMC,KAAK,GAAGF,WAAW,CAACG,KAAK,CAAC,CAAC;IAEjC,MAAMC,SAAS,GAAGd,cAAc,CAC/BS,iBAAiB,EACjBG,KAAK,CAACG,IAAI,IAAIH,KAAK,CAACI,SAAS,EAC7B,IACD,CAAC;IACD,IAAK,CAAEF,SAAS,EAAG;MAClB,OAAO,KAAK;IACb;IAEAF,KAAK,CAACK,WAAW,EAAEC,OAAO,CAAIC,UAAU,IAAM;MAC7CT,WAAW,CAACU,IAAI,CAAED,UAAW,CAAC;IAC/B,CAAE,CAAC;EACJ;EAEA,OAAO,IAAI;AACZ,CAAC;AAED,OAAO,MAAME,wBAAwB,GAAKC,MAAM,IAAQC,KAAK,IAAM;EAClE,OAAO,CACNA,KAAK,CAACC,QAAQ,CAACC,2BAA2B,EAC1CF,KAAK,CAACC,QAAQ,CAACE,mCAAmC,EAClDH,KAAK,CAACC,QAAQ,CAACG,4BAA4B,EAC3CJ,KAAK,CAACC,QAAQ,CAAEzB,sBAAsB,CAAE,GAAIuB,MAAO,CAAC,EACpDC,KAAK,CAACK,aAAa,CACnB;AACF,CAAC"}
|
|
@@ -1587,16 +1587,6 @@ iframe[name=editor-canvas].has-editor-padding {
|
|
|
1587
1587
|
direction: ltr;
|
|
1588
1588
|
}
|
|
1589
1589
|
|
|
1590
|
-
.block-editor-global-styles-advanced-panel__custom-css-validation-wrapper {
|
|
1591
|
-
position: absolute;
|
|
1592
|
-
bottom: 16px;
|
|
1593
|
-
left: 24px;
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
.block-editor-global-styles-advanced-panel__custom-css-validation-icon {
|
|
1597
|
-
fill: #cc1818;
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
1590
|
.block-editor-height-control {
|
|
1601
1591
|
border: 0;
|
|
1602
1592
|
margin: 0;
|
package/build-style/style.css
CHANGED
|
@@ -1588,16 +1588,6 @@ iframe[name=editor-canvas].has-editor-padding {
|
|
|
1588
1588
|
direction: ltr;
|
|
1589
1589
|
}
|
|
1590
1590
|
|
|
1591
|
-
.block-editor-global-styles-advanced-panel__custom-css-validation-wrapper {
|
|
1592
|
-
position: absolute;
|
|
1593
|
-
bottom: 16px;
|
|
1594
|
-
right: 24px;
|
|
1595
|
-
}
|
|
1596
|
-
|
|
1597
|
-
.block-editor-global-styles-advanced-panel__custom-css-validation-icon {
|
|
1598
|
-
fill: #cc1818;
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
1591
|
.block-editor-height-control {
|
|
1602
1592
|
border: 0;
|
|
1603
1593
|
margin: 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "12.19.
|
|
3
|
+
"version": "12.19.3",
|
|
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.3",
|
|
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": "b12d75c5c5256fda2a0509bb432e20ddd3354d5e"
|
|
91
91
|
}
|
|
@@ -81,11 +81,16 @@ function InbetweenInsertionPointPopover( {
|
|
|
81
81
|
isInserterShown: insertionPoint?.__unstableWithInserter,
|
|
82
82
|
};
|
|
83
83
|
}, [] );
|
|
84
|
+
const { getBlockEditingMode } = useSelect( blockEditorStore );
|
|
84
85
|
|
|
85
86
|
const disableMotion = useReducedMotion();
|
|
86
87
|
|
|
87
88
|
function onClick( event ) {
|
|
88
|
-
if (
|
|
89
|
+
if (
|
|
90
|
+
event.target === ref.current &&
|
|
91
|
+
nextClientId &&
|
|
92
|
+
getBlockEditingMode( nextClientId ) !== 'disabled'
|
|
93
|
+
) {
|
|
89
94
|
selectBlock( nextClientId, -1 );
|
|
90
95
|
}
|
|
91
96
|
}
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
5
|
TextareaControl,
|
|
6
|
-
|
|
6
|
+
Notice,
|
|
7
7
|
__experimentalVStack as VStack,
|
|
8
8
|
} from '@wordpress/components';
|
|
9
9
|
import { useState } from '@wordpress/element';
|
|
10
10
|
import { __ } from '@wordpress/i18n';
|
|
11
|
-
import { Icon, info } from '@wordpress/icons';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Internal dependencies
|
|
@@ -58,6 +57,11 @@ export default function AdvancedPanel( {
|
|
|
58
57
|
|
|
59
58
|
return (
|
|
60
59
|
<VStack spacing={ 3 }>
|
|
60
|
+
{ cssError && (
|
|
61
|
+
<Notice status="error" onRemove={ () => setCSSError( null ) }>
|
|
62
|
+
{ cssError }
|
|
63
|
+
</Notice>
|
|
64
|
+
) }
|
|
61
65
|
<TextareaControl
|
|
62
66
|
label={ __( 'Additional CSS' ) }
|
|
63
67
|
__nextHasNoMarginBottom
|
|
@@ -67,16 +71,6 @@ export default function AdvancedPanel( {
|
|
|
67
71
|
className="block-editor-global-styles-advanced-panel__custom-css-input"
|
|
68
72
|
spellCheck={ false }
|
|
69
73
|
/>
|
|
70
|
-
{ cssError && (
|
|
71
|
-
<Tooltip text={ cssError }>
|
|
72
|
-
<div className="block-editor-global-styles-advanced-panel__custom-css-validation-wrapper">
|
|
73
|
-
<Icon
|
|
74
|
-
icon={ info }
|
|
75
|
-
className="block-editor-global-styles-advanced-panel__custom-css-validation-icon"
|
|
76
|
-
/>
|
|
77
|
-
</div>
|
|
78
|
-
</Tooltip>
|
|
79
|
-
) }
|
|
80
74
|
</VStack>
|
|
81
75
|
);
|
|
82
76
|
}
|
|
@@ -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
|
}
|
|
@@ -19,13 +19,13 @@ import { shadow as shadowIcon, Icon, check } from '@wordpress/icons';
|
|
|
19
19
|
import classNames from 'classnames';
|
|
20
20
|
|
|
21
21
|
export function ShadowPopoverContainer( { shadow, onShadowChange, settings } ) {
|
|
22
|
-
const defaultShadows = settings?.shadow?.presets?.default;
|
|
23
|
-
const themeShadows = settings?.shadow?.presets?.theme;
|
|
22
|
+
const defaultShadows = settings?.shadow?.presets?.default || [];
|
|
23
|
+
const themeShadows = settings?.shadow?.presets?.theme || [];
|
|
24
24
|
const defaultPresetsEnabled = settings?.shadow?.defaultPresets;
|
|
25
25
|
|
|
26
26
|
const shadows = [
|
|
27
27
|
...( defaultPresetsEnabled ? defaultShadows : [] ),
|
|
28
|
-
...
|
|
28
|
+
...themeShadows,
|
|
29
29
|
];
|
|
30
30
|
|
|
31
31
|
return (
|
|
@@ -47,13 +47,3 @@
|
|
|
47
47
|
/*rtl:ignore*/
|
|
48
48
|
direction: ltr;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
.block-editor-global-styles-advanced-panel__custom-css-validation-wrapper {
|
|
52
|
-
position: absolute;
|
|
53
|
-
bottom: $grid-unit-20;
|
|
54
|
-
right: $grid-unit * 3;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.block-editor-global-styles-advanced-panel__custom-css-validation-icon {
|
|
58
|
-
fill: $alert-red;
|
|
59
|
-
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import getGlobalStylesChanges
|
|
4
|
+
import getGlobalStylesChanges, {
|
|
5
|
+
getGlobalStylesChangelist,
|
|
6
|
+
} from '../get-global-styles-changes';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* WordPress dependencies
|
|
@@ -12,24 +14,8 @@ import {
|
|
|
12
14
|
getBlockTypes,
|
|
13
15
|
} from '@wordpress/blocks';
|
|
14
16
|
|
|
15
|
-
describe( 'getGlobalStylesChanges', () => {
|
|
16
|
-
|
|
17
|
-
registerBlockType( 'core/test-fiori-di-zucca', {
|
|
18
|
-
save: () => {},
|
|
19
|
-
category: 'text',
|
|
20
|
-
title: 'Test pumpkin flowers',
|
|
21
|
-
edit: () => {},
|
|
22
|
-
} );
|
|
23
|
-
} );
|
|
24
|
-
|
|
25
|
-
afterEach( () => {
|
|
26
|
-
getBlockTypes().forEach( ( block ) => {
|
|
27
|
-
unregisterBlockType( block.name );
|
|
28
|
-
} );
|
|
29
|
-
} );
|
|
30
|
-
|
|
31
|
-
const revision = {
|
|
32
|
-
id: 10,
|
|
17
|
+
describe( 'getGlobalStylesChanges and utils', () => {
|
|
18
|
+
const next = {
|
|
33
19
|
styles: {
|
|
34
20
|
typography: {
|
|
35
21
|
fontSize: 'var(--wp--preset--font-size--potato)',
|
|
@@ -85,11 +71,18 @@ describe( 'getGlobalStylesChanges', () => {
|
|
|
85
71
|
},
|
|
86
72
|
],
|
|
87
73
|
},
|
|
74
|
+
gradients: [
|
|
75
|
+
{
|
|
76
|
+
name: 'Something something',
|
|
77
|
+
gradient:
|
|
78
|
+
'linear-gradient(105deg,rgba(6,147,100,1) 0%,rgb(155,81,100) 100%)',
|
|
79
|
+
slug: 'something-something',
|
|
80
|
+
},
|
|
81
|
+
],
|
|
88
82
|
},
|
|
89
83
|
},
|
|
90
84
|
};
|
|
91
|
-
const
|
|
92
|
-
id: 9,
|
|
85
|
+
const previous = {
|
|
93
86
|
styles: {
|
|
94
87
|
typography: {
|
|
95
88
|
fontSize: 'var(--wp--preset--font-size--fungus)',
|
|
@@ -161,74 +154,120 @@ describe( 'getGlobalStylesChanges', () => {
|
|
|
161
154
|
color: 'blue',
|
|
162
155
|
},
|
|
163
156
|
],
|
|
157
|
+
custom: [
|
|
158
|
+
{
|
|
159
|
+
slug: 'one',
|
|
160
|
+
color: 'tomato',
|
|
161
|
+
},
|
|
162
|
+
],
|
|
164
163
|
},
|
|
164
|
+
gradients: [
|
|
165
|
+
{
|
|
166
|
+
name: 'Vivid cyan blue to vivid purple',
|
|
167
|
+
gradient:
|
|
168
|
+
'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
|
|
169
|
+
slug: 'vivid-cyan-blue-to-vivid-purple',
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
typography: {
|
|
174
|
+
fluid: true,
|
|
165
175
|
},
|
|
166
176
|
},
|
|
167
177
|
};
|
|
168
178
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
'
|
|
173
|
-
'
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
'Caption element',
|
|
177
|
-
'H6 element',
|
|
178
|
-
'Link element',
|
|
179
|
-
'Color settings',
|
|
180
|
-
] );
|
|
181
|
-
|
|
182
|
-
const resultB = getGlobalStylesChanges( revision, previousRevision );
|
|
183
|
-
|
|
184
|
-
expect( resultA ).toBe( resultB );
|
|
179
|
+
beforeEach( () => {
|
|
180
|
+
registerBlockType( 'core/test-fiori-di-zucca', {
|
|
181
|
+
save: () => {},
|
|
182
|
+
category: 'text',
|
|
183
|
+
title: 'Test pumpkin flowers',
|
|
184
|
+
edit: () => {},
|
|
185
|
+
} );
|
|
185
186
|
} );
|
|
186
187
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
afterEach( () => {
|
|
189
|
+
getBlockTypes().forEach( ( block ) => {
|
|
190
|
+
unregisterBlockType( block.name );
|
|
190
191
|
} );
|
|
191
|
-
expect( resultA ).toEqual( [
|
|
192
|
-
'Colors',
|
|
193
|
-
'Typography',
|
|
194
|
-
'Test pumpkin flowers',
|
|
195
|
-
'…and 5 more changes',
|
|
196
|
-
] );
|
|
197
192
|
} );
|
|
198
193
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
194
|
+
describe( 'getGlobalStylesChanges()', () => {
|
|
195
|
+
it( 'returns a list of changes', () => {
|
|
196
|
+
const result = getGlobalStylesChanges( next, previous );
|
|
197
|
+
expect( result ).toEqual( [
|
|
198
|
+
'Colors, Typography styles.',
|
|
199
|
+
'Test pumpkin flowers block.',
|
|
200
|
+
'H3, Caption, H6, Link elements.',
|
|
201
|
+
'Color, Typography settings.',
|
|
202
|
+
] );
|
|
203
|
+
} );
|
|
204
|
+
|
|
205
|
+
it( 'returns a list of truncated changes', () => {
|
|
206
|
+
const resultA = getGlobalStylesChanges( next, previous, {
|
|
207
|
+
maxResults: 3,
|
|
208
|
+
} );
|
|
209
|
+
expect( resultA ).toEqual( [
|
|
210
|
+
'Colors, Typography styles.',
|
|
211
|
+
'Test pumpkin flowers block.',
|
|
212
|
+
] );
|
|
213
|
+
} );
|
|
214
|
+
|
|
215
|
+
it( 'skips unknown and unchanged keys', () => {
|
|
216
|
+
const result = getGlobalStylesChanges(
|
|
217
|
+
{
|
|
218
|
+
styles: {
|
|
219
|
+
frogs: {
|
|
220
|
+
legs: 'green',
|
|
221
|
+
},
|
|
222
|
+
typography: {
|
|
223
|
+
fontSize: '1rem',
|
|
224
|
+
},
|
|
225
|
+
settings: {
|
|
226
|
+
'': {
|
|
227
|
+
'': 'foo',
|
|
228
|
+
},
|
|
212
229
|
},
|
|
213
230
|
},
|
|
214
231
|
},
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
232
|
+
{
|
|
233
|
+
styles: {
|
|
234
|
+
frogs: {
|
|
235
|
+
legs: 'yellow',
|
|
236
|
+
},
|
|
237
|
+
typography: {
|
|
238
|
+
fontSize: '1rem',
|
|
239
|
+
},
|
|
240
|
+
settings: {
|
|
241
|
+
'': {
|
|
242
|
+
'': 'bar',
|
|
243
|
+
},
|
|
227
244
|
},
|
|
228
245
|
},
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
expect( result ).toEqual( [] );
|
|
249
|
+
} );
|
|
250
|
+
} );
|
|
251
|
+
|
|
252
|
+
describe( 'getGlobalStylesChangelist()', () => {
|
|
253
|
+
it( 'compares two objects and returns a cached list of changed keys', () => {
|
|
254
|
+
const resultA = getGlobalStylesChangelist( next, previous );
|
|
255
|
+
|
|
256
|
+
expect( resultA ).toEqual( [
|
|
257
|
+
[ 'styles', 'Colors' ],
|
|
258
|
+
[ 'styles', 'Typography' ],
|
|
259
|
+
[ 'blocks', 'Test pumpkin flowers' ],
|
|
260
|
+
[ 'elements', 'H3' ],
|
|
261
|
+
[ 'elements', 'Caption' ],
|
|
262
|
+
[ 'elements', 'H6' ],
|
|
263
|
+
[ 'elements', 'Link' ],
|
|
264
|
+
[ 'settings', 'Color' ],
|
|
265
|
+
[ 'settings', 'Typography' ],
|
|
266
|
+
] );
|
|
267
|
+
|
|
268
|
+
const resultB = getGlobalStylesChangelist( next, previous );
|
|
269
|
+
|
|
270
|
+
expect( resultB ).toEqual( resultA );
|
|
271
|
+
} );
|
|
233
272
|
} );
|
|
234
273
|
} );
|