@wordpress/block-editor 12.3.6 → 12.3.8
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/README.md +0 -4
- package/build/components/block-draggable/index.js +6 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +15 -25
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/colors-gradients/control.js +4 -2
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +13 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/iframe/index.js +16 -3
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +5 -0
- package/build/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build/components/index.js +1 -10
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/reusable-block-rename-hint.js +23 -3
- package/build/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build/components/link-control/constants.js +1 -1
- package/build/components/link-control/constants.js.map +1 -1
- package/build/components/link-control/search-create-button.js +5 -21
- package/build/components/link-control/search-create-button.js.map +1 -1
- package/build/components/link-control/search-item.js +13 -30
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -2
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/rich-text/get-rich-text-values.js +7 -1
- package/build/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/build/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/axial.js +6 -2
- package/build/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build/components/spacing-sizes-control/input-controls/single.js +5 -1
- package/build/components/spacing-sizes-control/input-controls/single.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +1 -1
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/use-block-display-information/index.js +7 -3
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/hooks/margin.js +1 -1
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +1 -1
- package/build/hooks/padding.js.map +1 -1
- package/build/private-apis.js +5 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/index.js +10 -1
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +36 -36
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +16 -8
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-draggable/index.js +6 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +16 -23
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +3 -2
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +13 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/iframe/index.js +16 -3
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +5 -0
- package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build-module/components/index.js +0 -5
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/reusable-block-rename-hint.js +22 -3
- package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -1
- package/build-module/components/link-control/constants.js +1 -1
- package/build-module/components/link-control/constants.js.map +1 -1
- package/build-module/components/link-control/search-create-button.js +7 -20
- package/build-module/components/link-control/search-create-button.js.map +1 -1
- package/build-module/components/link-control/search-item.js +14 -28
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/link-control/search-results.js +3 -3
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/rich-text/get-rich-text-values.js +7 -1
- package/build-module/components/rich-text/get-rich-text-values.js.map +1 -1
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/axial.js +7 -3
- package/build-module/components/spacing-sizes-control/input-controls/axial.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/separated.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls/separated.js.map +1 -1
- package/build-module/components/spacing-sizes-control/input-controls/single.js +6 -2
- package/build-module/components/spacing-sizes-control/input-controls/single.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +1 -1
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +7 -3
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/hooks/margin.js +1 -1
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +1 -1
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/private-apis.js +4 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/index.js +10 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +35 -32
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +2 -2
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +16 -8
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +20 -83
- package/build-style/style.css +20 -83
- package/package.json +10 -10
- package/src/components/block-draggable/index.js +13 -4
- package/src/components/block-removal-warning-modal/index.js +13 -27
- package/src/components/colors-gradients/control.js +3 -2
- package/src/components/global-styles/dimensions-panel.js +8 -2
- package/src/components/iframe/index.js +15 -10
- package/src/components/iframe/use-compatibility-styles.js +5 -0
- package/src/components/index.js +0 -5
- package/src/components/inserter/reusable-block-rename-hint.js +18 -1
- package/src/components/link-control/constants.js +1 -1
- package/src/components/link-control/search-create-button.js +8 -26
- package/src/components/link-control/search-item.js +21 -43
- package/src/components/link-control/search-results.js +48 -46
- package/src/components/link-control/style.scss +25 -95
- package/src/components/link-control/test/index.js +6 -7
- package/src/components/rich-text/get-rich-text-values.js +11 -1
- package/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +1 -1
- package/src/components/spacing-sizes-control/input-controls/axial.js +17 -2
- package/src/components/spacing-sizes-control/input-controls/separated.js +17 -2
- package/src/components/spacing-sizes-control/input-controls/single.js +12 -2
- package/src/components/spacing-sizes-control/utils.js +1 -1
- package/src/components/use-block-display-information/index.js +12 -5
- package/src/hooks/margin.js +4 -1
- package/src/hooks/padding.js +4 -1
- package/src/private-apis.js +6 -0
- package/src/store/index.js +10 -0
- package/src/store/private-actions.js +33 -36
- package/src/store/private-selectors.js +2 -2
- package/src/store/reducer.js +16 -8
- package/src/store/selectors.js +1 -1
- package/src/store/test/actions.js +3 -0
- package/src/store/test/selectors.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/input-controls/separated.js"],"names":["SeparatedInputControls","minimumCustomValue","onChange","onMouseOut","onMouseOver","sides","spacingSizes","type","values","filteredSides","length","ALL_SIDES","filter","side","includes","createHandleOnChange","next","nextValues","map","ICONS","LABELS"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/input-controls/separated.js"],"names":["SeparatedInputControls","minimumCustomValue","onChange","onMouseOut","onMouseOver","sides","spacingSizes","type","values","filteredSides","length","ALL_SIDES","filter","side","includes","createHandleOnChange","next","nextValues","Object","keys","reduce","acc","key","map","ICONS","LABELS"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;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AAA,YAAY,EAAGP,YAThB;AAUC,MAAA,IAAI,EAAGC,IAVR;AAWC,MAAA,KAAK,EAAGC,MAAM,CAAEK,IAAF,CAXf;AAYC,MAAA,cAAc,EAAG;AAZlB,MADD;AAgBA,GAjBC,CADH,CADD;AAsBA","sourcesContent":["/**\n * Internal dependencies\n */\nimport SpacingInputControl from './spacing-input-control';\nimport {\n\tALL_SIDES,\n\tLABELS,\n\tICONS,\n\tgetPresetValueFromCustomValue,\n} from '../utils';\n\nexport default function SeparatedInputControls( {\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tsides,\n\tspacingSizes,\n\ttype,\n\tvalues,\n} ) {\n\t// Filter sides if custom configuration provided, maintaining default order.\n\tconst filteredSides = sides?.length\n\t\t? ALL_SIDES.filter( ( side ) => sides.includes( side ) )\n\t\t: ALL_SIDES;\n\n\tconst createHandleOnChange = ( side ) => ( next ) => {\n\t\t// Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.\n\t\tconst nextValues = {\n\t\t\t...Object.keys( values ).reduce( ( acc, key ) => {\n\t\t\t\tacc[ key ] = getPresetValueFromCustomValue(\n\t\t\t\t\tvalues[ key ],\n\t\t\t\t\tspacingSizes\n\t\t\t\t);\n\t\t\t\treturn acc;\n\t\t\t}, {} ),\n\t\t};\n\n\t\tnextValues[ side ] = next;\n\n\t\tonChange( nextValues );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t{ filteredSides.map( ( side ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<SpacingInputControl\n\t\t\t\t\t\tkey={ `spacing-sizes-control-${ side }` }\n\t\t\t\t\t\ticon={ ICONS[ side ] }\n\t\t\t\t\t\tlabel={ LABELS[ side ] }\n\t\t\t\t\t\tminimumCustomValue={ minimumCustomValue }\n\t\t\t\t\t\tonChange={ createHandleOnChange( side ) }\n\t\t\t\t\t\tonMouseOut={ onMouseOut }\n\t\t\t\t\t\tonMouseOver={ onMouseOver }\n\t\t\t\t\t\tside={ side }\n\t\t\t\t\t\tspacingSizes={ spacingSizes }\n\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\tvalue={ values[ side ] }\n\t\t\t\t\t\twithInputField={ false }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -28,7 +28,11 @@ function SingleInputControl({
|
|
|
28
28
|
values
|
|
29
29
|
}) {
|
|
30
30
|
const createHandleOnChange = currentSide => next => {
|
|
31
|
-
|
|
31
|
+
// Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.
|
|
32
|
+
const nextValues = { ...Object.keys(values).reduce((acc, key) => {
|
|
33
|
+
acc[key] = (0, _utils.getPresetValueFromCustomValue)(values[key], spacingSizes);
|
|
34
|
+
return acc;
|
|
35
|
+
}, {})
|
|
32
36
|
};
|
|
33
37
|
nextValues[currentSide] = next;
|
|
34
38
|
onChange(nextValues);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/input-controls/single.js"],"names":["SingleInputControl","minimumCustomValue","onChange","onMouseOut","onMouseOver","showSideInLabel","side","spacingSizes","type","values","createHandleOnChange","currentSide","next","nextValues","LABELS"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIe,SAASA,kBAAT,CAA6B;AAC3CC,EAAAA,kBAD2C;AAE3CC,EAAAA,QAF2C;AAG3CC,EAAAA,UAH2C;AAI3CC,EAAAA,WAJ2C;AAK3CC,EAAAA,eAL2C;AAM3CC,EAAAA,IAN2C;AAO3CC,EAAAA,YAP2C;AAQ3CC,EAAAA,IAR2C;AAS3CC,EAAAA;AAT2C,CAA7B,EAUX;AACH,QAAMC,oBAAoB,GAAKC,WAAF,IAAqBC,IAAF,IAAY;AAC3D,UAAMC,UAAU,GAAG,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/input-controls/single.js"],"names":["SingleInputControl","minimumCustomValue","onChange","onMouseOut","onMouseOver","showSideInLabel","side","spacingSizes","type","values","createHandleOnChange","currentSide","next","nextValues","Object","keys","reduce","acc","key","LABELS"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIe,SAASA,kBAAT,CAA6B;AAC3CC,EAAAA,kBAD2C;AAE3CC,EAAAA,QAF2C;AAG3CC,EAAAA,UAH2C;AAI3CC,EAAAA,WAJ2C;AAK3CC,EAAAA,eAL2C;AAM3CC,EAAAA,IAN2C;AAO3CC,EAAAA,YAP2C;AAQ3CC,EAAAA,IAR2C;AAS3CC,EAAAA;AAT2C,CAA7B,EAUX;AACH,QAAMC,oBAAoB,GAAKC,WAAF,IAAqBC,IAAF,IAAY;AAC3D;AACA,UAAMC,UAAU,GAAG,EAClB,GAAGC,MAAM,CAACC,IAAP,CAAaN,MAAb,EAAsBO,MAAtB,CAA8B,CAAEC,GAAF,EAAOC,GAAP,KAAgB;AAChDD,QAAAA,GAAG,CAAEC,GAAF,CAAH,GAAa,0CACZT,MAAM,CAAES,GAAF,CADM,EAEZX,YAFY,CAAb;AAIA,eAAOU,GAAP;AACA,OANE,EAMA,EANA;AADe,KAAnB;AAUAJ,IAAAA,UAAU,CAAEF,WAAF,CAAV,GAA4BC,IAA5B;AAEAV,IAAAA,QAAQ,CAAEW,UAAF,CAAR;AACA,GAfD;;AAiBA,SACC,4BAAC,4BAAD;AACC,IAAA,KAAK,EAAGM,cAAQb,IAAR,CADT;AAEC,IAAA,kBAAkB,EAAGL,kBAFtB;AAGC,IAAA,QAAQ,EAAGS,oBAAoB,CAAEJ,IAAF,CAHhC;AAIC,IAAA,UAAU,EAAGH,UAJd;AAKC,IAAA,WAAW,EAAGC,WALf;AAMC,IAAA,eAAe,EAAGC,eANnB;AAOC,IAAA,IAAI,EAAGC,IAPR;AAQC,IAAA,YAAY,EAAGC,YARhB;AASC,IAAA,IAAI,EAAGC,IATR;AAUC,IAAA,KAAK,EAAGC,MAAM,CAAEH,IAAF,CAVf;AAWC,IAAA,cAAc,EAAG;AAXlB,IADD;AAeA","sourcesContent":["/**\n * Internal dependencies\n */\nimport SpacingInputControl from './spacing-input-control';\nimport { LABELS, getPresetValueFromCustomValue } from '../utils';\n\nexport default function SingleInputControl( {\n\tminimumCustomValue,\n\tonChange,\n\tonMouseOut,\n\tonMouseOver,\n\tshowSideInLabel,\n\tside,\n\tspacingSizes,\n\ttype,\n\tvalues,\n} ) {\n\tconst createHandleOnChange = ( currentSide ) => ( next ) => {\n\t\t// Encode the existing value into the preset value if the passed in value matches the value of one of the spacingSizes.\n\t\tconst nextValues = {\n\t\t\t...Object.keys( values ).reduce( ( acc, key ) => {\n\t\t\t\tacc[ key ] = getPresetValueFromCustomValue(\n\t\t\t\t\tvalues[ key ],\n\t\t\t\t\tspacingSizes\n\t\t\t\t);\n\t\t\t\treturn acc;\n\t\t\t}, {} ),\n\t\t};\n\n\t\tnextValues[ currentSide ] = next;\n\n\t\tonChange( nextValues );\n\t};\n\n\treturn (\n\t\t<SpacingInputControl\n\t\t\tlabel={ LABELS[ side ] }\n\t\t\tminimumCustomValue={ minimumCustomValue }\n\t\t\tonChange={ createHandleOnChange( side ) }\n\t\t\tonMouseOut={ onMouseOut }\n\t\t\tonMouseOver={ onMouseOver }\n\t\t\tshowSideInLabel={ showSideInLabel }\n\t\t\tside={ side }\n\t\t\tspacingSizes={ spacingSizes }\n\t\t\ttype={ type }\n\t\t\tvalue={ values[ side ] }\n\t\t\twithInputField={ false }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -116,7 +116,7 @@ function getCustomValueFromPreset(value, spacingSizes) {
|
|
|
116
116
|
|
|
117
117
|
function getPresetValueFromCustomValue(value, spacingSizes) {
|
|
118
118
|
// Return value as-is if it is already a preset;
|
|
119
|
-
if (isValueSpacingPreset(value)) {
|
|
119
|
+
if (isValueSpacingPreset(value) || value === '0') {
|
|
120
120
|
return value;
|
|
121
121
|
}
|
|
122
122
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/utils.js"],"names":["ALL_SIDES","DEFAULT_VALUES","top","undefined","right","bottom","left","ICONS","custom","sidesAll","axial","sidesAxial","horizontal","sidesHorizontal","vertical","sidesVertical","sidesTop","sidesRight","sidesBottom","sidesLeft","LABELS","default","mixed","VIEWS","isValueSpacingPreset","value","includes","getCustomValueFromPreset","spacingSizes","slug","getSpacingPresetSlug","spacingSize","find","size","String","getPresetValueFromCustomValue","spacingMatch","getSpacingPresetCssVar","match","getSliderValueFromPreset","presetValue","parseFloat","sliderValue","findIndex","NaN","mode","arr","sort","a","b","filter","v","length","pop","getAllRawValue","values","Object","isValuesMixed","sides","Set","isValuesDefined","hasAxisSupport","axis","hasHorizontalSupport","hasVerticalSupport","getSupportedMenuItems","menuItems","label","icon","numberOfIndividualSides","forEach","side","hasBalancedSidesSupport","counts","getInitialView","sideValues","Boolean","hasMatchingAxialValues","hasNoValuesAndBalancedSides","entries","some","key"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAaO,MAAMA,SAAS,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,EAA4B,MAA5B,CAAlB;;AAEA,MAAMC,cAAc,GAAG;AAC7BC,EAAAA,GAAG,EAAEC,SADwB;AAE7BC,EAAAA,KAAK,EAAED,SAFsB;AAG7BE,EAAAA,MAAM,EAAEF,SAHqB;AAI7BG,EAAAA,IAAI,EAAEH;AAJuB,CAAvB;;AAOA,MAAMI,KAAK,GAAG;AACpBC,EAAAA,MAAM,EAAEC,eADY;AAEpBC,EAAAA,KAAK,EAAEC,iBAFa;AAGpBC,EAAAA,UAAU,EAAEC,sBAHQ;AAIpBC,EAAAA,QAAQ,EAAEC,oBAJU;AAKpBb,EAAAA,GAAG,EAAEc,eALe;AAMpBZ,EAAAA,KAAK,EAAEa,iBANa;AAOpBZ,EAAAA,MAAM,EAAEa,kBAPY;AAQpBZ,EAAAA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AI,KAAKF,KAA3B,KAAsC,CAAC,CAAEF,GAAH,IAAU,CAAC,CAAEI,IAAnD,CADD;AAEA,QAAMwE,2BAA2B,GAChC,CAAEH,UAAU,CAACvB,MAAb,IAAuBoB,uBAAuB,CAAEd,KAAF,CAD/C;;AAGA,MACCG,cAAc,CAAEH,KAAF,CAAd,KACEmB,sBAAsB,IAAIC,2BAD5B,CADD,EAGE;AACD,WAAOvD,KAAK,CAACb,KAAb;AACA,GAlBmD,CAoBpD;AACA;;;AACA,MAAKiE,UAAU,CAACvB,MAAX,KAAsB,CAA3B,EAA+B;AAC9B,QAAImB,IAAJ;AAEAf,IAAAA,MAAM,CAACuB,OAAP,CAAgBxB,MAAhB,EAAyByB,IAAzB,CAA+B,CAAE,CAAEC,GAAF,EAAOxD,KAAP,CAAF,KAAsB;AACpD8C,MAAAA,IAAI,GAAGU,GAAP;AACA,aAAOxD,KAAK,KAAKtB,SAAjB;AACA,KAHD;AAKA,WAAOoE,IAAP;AACA,GA/BmD,CAiCpD;;;AACA,MAAKb,KAAK,EAAEN,MAAP,KAAkB,CAAlB,IAAuB,CAAEuB,UAAU,CAACvB,MAAzC,EAAkD;AACjD,WAAOM,KAAK,CAAE,CAAF,CAAZ;AACA,GApCmD,CAsCpD;;;AACA,SAAOnC,KAAK,CAACf,MAAb;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tsidesAll,\n\tsidesAxial,\n\tsidesBottom,\n\tsidesHorizontal,\n\tsidesLeft,\n\tsidesRight,\n\tsidesTop,\n\tsidesVertical,\n} from '@wordpress/icons';\n\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\n\nexport const DEFAULT_VALUES = {\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nexport const ICONS = {\n\tcustom: sidesAll,\n\taxial: sidesAxial,\n\thorizontal: sidesHorizontal,\n\tvertical: sidesVertical,\n\ttop: sidesTop,\n\tright: sidesRight,\n\tbottom: sidesBottom,\n\tleft: sidesLeft,\n};\n\nexport const LABELS = {\n\tdefault: __( 'Spacing control' ),\n\ttop: __( 'Top' ),\n\tbottom: __( 'Bottom' ),\n\tleft: __( 'Left' ),\n\tright: __( 'Right' ),\n\tmixed: __( 'Mixed' ),\n\tvertical: __( 'Vertical' ),\n\thorizontal: __( 'Horizontal' ),\n\taxial: __( 'Horizontal & vertical' ),\n\tcustom: __( 'Custom' ),\n};\n\nexport const VIEWS = {\n\taxial: 'axial',\n\ttop: 'top',\n\tright: 'right',\n\tbottom: 'bottom',\n\tleft: 'left',\n\tcustom: 'custom',\n};\n\n/**\n * Checks is given value is a spacing preset.\n *\n * @param {string} value Value to check\n *\n * @return {boolean} Return true if value is string in format var:preset|spacing|.\n */\nexport function isValueSpacingPreset( value ) {\n\tif ( ! value?.includes ) {\n\t\treturn false;\n\t}\n\treturn value === '0' || value.includes( 'var:preset|spacing|' );\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} Mapping of the spacing preset to its equivalent custom value.\n */\nexport function getCustomValueFromPreset( value, spacingSizes ) {\n\tif ( ! isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst slug = getSpacingPresetSlug( value );\n\tconst spacingSize = spacingSizes.find(\n\t\t( size ) => String( size.slug ) === slug\n\t);\n\n\treturn spacingSize?.size;\n}\n\n/**\n * Converts a custom value to preset value if one can be found.\n *\n * Returns value as-is if no match is found.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} The preset value if it can be found.\n */\nexport function getPresetValueFromCustomValue( value, spacingSizes ) {\n\t// Return value as-is if it is already a preset;\n\tif ( isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst spacingMatch = spacingSizes.find(\n\t\t( size ) => String( size.size ) === String( value )\n\t);\n\n\tif ( spacingMatch?.slug ) {\n\t\treturn `var:preset|spacing|${ spacingMatch.slug }`;\n\t}\n\n\treturn value;\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert.\n *\n * @return {string | undefined} CSS var string for given spacing preset value.\n */\nexport function getSpacingPresetCssVar( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\tif ( ! slug ) {\n\t\treturn value;\n\t}\n\n\treturn `var(--wp--preset--spacing--${ slug[ 1 ] })`;\n}\n\n/**\n * Returns the slug section of the given spacing preset string.\n *\n * @param {string} value Value to extract slug from.\n *\n * @return {string|undefined} The int value of the slug from given spacing preset.\n */\nexport function getSpacingPresetSlug( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tif ( value === '0' || value === 'default' ) {\n\t\treturn value;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\treturn slug ? slug[ 1 ] : undefined;\n}\n\n/**\n * Converts spacing preset value into a Range component value .\n *\n * @param {string} presetValue Value to convert to Range value.\n * @param {Array} spacingSizes Array of current spacing preset value objects.\n *\n * @return {number} The int value for use in Range control.\n */\nexport function getSliderValueFromPreset( presetValue, spacingSizes ) {\n\tif ( presetValue === undefined ) {\n\t\treturn 0;\n\t}\n\tconst slug =\n\t\tparseFloat( presetValue, 10 ) === 0\n\t\t\t? '0'\n\t\t\t: getSpacingPresetSlug( presetValue );\n\tconst sliderValue = spacingSizes.findIndex( ( spacingSize ) => {\n\t\treturn String( spacingSize.slug ) === slug;\n\t} );\n\n\t// Returning NaN rather than undefined as undefined makes range control thumb sit in center\n\treturn sliderValue !== -1 ? sliderValue : NaN;\n}\n\n/**\n * Gets an items with the most occurrence within an array\n * https://stackoverflow.com/a/20762713\n *\n * @param {Array<any>} arr Array of items to check.\n * @return {any} The item with the most occurrences.\n */\nfunction mode( arr ) {\n\treturn arr\n\t\t.sort(\n\t\t\t( a, b ) =>\n\t\t\t\tarr.filter( ( v ) => v === a ).length -\n\t\t\t\tarr.filter( ( v ) => v === b ).length\n\t\t)\n\t\t.pop();\n}\n\n/**\n * Gets the 'all' input value from values data.\n *\n * @param {Object} values Box spacing values\n *\n * @return {string} The most common value from all sides of box.\n */\nexport function getAllRawValue( values = {} ) {\n\treturn mode( Object.values( values ) );\n}\n\n/**\n * Checks to determine if values are mixed.\n *\n * @param {Object} values Box values.\n * @param {Array} sides Sides that values relate to.\n *\n * @return {boolean} Whether values are mixed.\n */\nexport function isValuesMixed( values = {}, sides = ALL_SIDES ) {\n\treturn (\n\t\t( Object.values( values ).length >= 1 &&\n\t\t\tObject.values( values ).length < sides.length ) ||\n\t\tnew Set( Object.values( values ) ).size > 1\n\t);\n}\n\n/**\n * Checks to determine if values are defined.\n *\n * @param {Object} values Box values.\n *\n * @return {boolean} Whether values are defined.\n */\nexport function isValuesDefined( values ) {\n\tif ( values === undefined || values === null ) {\n\t\treturn false;\n\t}\n\treturn Object.values( values ).filter( ( value ) => !! value ).length > 0;\n}\n\n/**\n * Determines whether a particular axis has support. If no axis is\n * specified, this function checks if either axis is supported.\n *\n * @param {Array} sides Supported sides.\n * @param {string} axis Which axis to check.\n *\n * @return {boolean} Whether there is support for the specified axis or both axes.\n */\nexport function hasAxisSupport( sides, axis ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn false;\n\t}\n\n\tconst hasHorizontalSupport =\n\t\tsides.includes( 'horizontal' ) ||\n\t\t( sides.includes( 'left' ) && sides.includes( 'right' ) );\n\n\tconst hasVerticalSupport =\n\t\tsides.includes( 'vertical' ) ||\n\t\t( sides.includes( 'top' ) && sides.includes( 'bottom' ) );\n\n\tif ( axis === 'horizontal' ) {\n\t\treturn hasHorizontalSupport;\n\t}\n\n\tif ( axis === 'vertical' ) {\n\t\treturn hasVerticalSupport;\n\t}\n\n\treturn hasHorizontalSupport || hasVerticalSupport;\n}\n\n/**\n * Determines which menu options should be included in the SidePicker.\n *\n * @param {Array} sides Supported sides.\n *\n * @return {Object} Menu options with each option containing label & icon.\n */\nexport function getSupportedMenuItems( sides ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn {};\n\t}\n\n\tconst menuItems = {};\n\n\t// Determine the primary \"side\" menu options.\n\tconst hasHorizontalSupport = hasAxisSupport( sides, 'horizontal' );\n\tconst hasVerticalSupport = hasAxisSupport( sides, 'vertical' );\n\n\tif ( hasHorizontalSupport && hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.axial, icon: ICONS.axial };\n\t} else if ( hasHorizontalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.horizontal, icon: ICONS.horizontal };\n\t} else if ( hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.vertical, icon: ICONS.vertical };\n\t}\n\n\t// Track whether we have any individual sides so we can omit the custom\n\t// option if required.\n\tlet numberOfIndividualSides = 0;\n\n\tALL_SIDES.forEach( ( side ) => {\n\t\tif ( sides.includes( side ) ) {\n\t\t\tnumberOfIndividualSides += 1;\n\t\t\tmenuItems[ side ] = {\n\t\t\t\tlabel: LABELS[ side ],\n\t\t\t\ticon: ICONS[ side ],\n\t\t\t};\n\t\t}\n\t} );\n\n\t// Add custom item if there are enough sides to warrant a separated view.\n\tif ( numberOfIndividualSides > 1 ) {\n\t\tmenuItems.custom = { label: LABELS.custom, icon: ICONS.custom };\n\t}\n\n\treturn menuItems;\n}\n\n/**\n * Checks if the supported sides are balanced for each axis.\n * - Horizontal - both left and right sides are supported.\n * - Vertical - both top and bottom are supported.\n *\n * @param {Array} sides The supported sides which may be axes as well.\n *\n * @return {boolean} Whether or not the supported sides are balanced.\n */\nexport function hasBalancedSidesSupport( sides = [] ) {\n\tconst counts = { top: 0, right: 0, bottom: 0, left: 0 };\n\tsides.forEach( ( side ) => ( counts[ side ] += 1 ) );\n\n\treturn (\n\t\t( counts.top + counts.bottom ) % 2 === 0 &&\n\t\t( counts.left + counts.right ) % 2 === 0\n\t);\n}\n\n/**\n * Determines which view the SpacingSizesControl should default to on its\n * first render; Axial, Custom, or Single side.\n *\n * @param {Object} values Current side values.\n * @param {Array} sides Supported sides.\n *\n * @return {string} View to display.\n */\nexport function getInitialView( values = {}, sides ) {\n\tconst { top, right, bottom, left } = values;\n\tconst sideValues = [ top, right, bottom, left ].filter( Boolean );\n\n\t// Axial ( Horizontal & vertical ).\n\t// - Has axial side support\n\t// - Has axial side values which match\n\t// - Has no values and the supported sides are balanced\n\tconst hasMatchingAxialValues =\n\t\ttop === bottom && left === right && ( !! top || !! left );\n\tconst hasNoValuesAndBalancedSides =\n\t\t! sideValues.length && hasBalancedSidesSupport( sides );\n\n\tif (\n\t\thasAxisSupport( sides ) &&\n\t\t( hasMatchingAxialValues || hasNoValuesAndBalancedSides )\n\t) {\n\t\treturn VIEWS.axial;\n\t}\n\n\t// Single side.\n\t// - Ensure the side returned is the first side that has a value.\n\tif ( sideValues.length === 1 ) {\n\t\tlet side;\n\n\t\tObject.entries( values ).some( ( [ key, value ] ) => {\n\t\t\tside = key;\n\t\t\treturn value !== undefined;\n\t\t} );\n\n\t\treturn side;\n\t}\n\n\t// Only single side supported and no value defined.\n\tif ( sides?.length === 1 && ! sideValues.length ) {\n\t\treturn sides[ 0 ];\n\t}\n\n\t// Default to the Custom (separated sides) view.\n\treturn VIEWS.custom;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/spacing-sizes-control/utils.js"],"names":["ALL_SIDES","DEFAULT_VALUES","top","undefined","right","bottom","left","ICONS","custom","sidesAll","axial","sidesAxial","horizontal","sidesHorizontal","vertical","sidesVertical","sidesTop","sidesRight","sidesBottom","sidesLeft","LABELS","default","mixed","VIEWS","isValueSpacingPreset","value","includes","getCustomValueFromPreset","spacingSizes","slug","getSpacingPresetSlug","spacingSize","find","size","String","getPresetValueFromCustomValue","spacingMatch","getSpacingPresetCssVar","match","getSliderValueFromPreset","presetValue","parseFloat","sliderValue","findIndex","NaN","mode","arr","sort","a","b","filter","v","length","pop","getAllRawValue","values","Object","isValuesMixed","sides","Set","isValuesDefined","hasAxisSupport","axis","hasHorizontalSupport","hasVerticalSupport","getSupportedMenuItems","menuItems","label","icon","numberOfIndividualSides","forEach","side","hasBalancedSidesSupport","counts","getInitialView","sideValues","Boolean","hasMatchingAxialValues","hasNoValuesAndBalancedSides","entries","some","key"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAaO,MAAMA,SAAS,GAAG,CAAE,KAAF,EAAS,OAAT,EAAkB,QAAlB,EAA4B,MAA5B,CAAlB;;AAEA,MAAMC,cAAc,GAAG;AAC7BC,EAAAA,GAAG,EAAEC,SADwB;AAE7BC,EAAAA,KAAK,EAAED,SAFsB;AAG7BE,EAAAA,MAAM,EAAEF,SAHqB;AAI7BG,EAAAA,IAAI,EAAEH;AAJuB,CAAvB;;AAOA,MAAMI,KAAK,GAAG;AACpBC,EAAAA,MAAM,EAAEC,eADY;AAEpBC,EAAAA,KAAK,EAAEC,iBAFa;AAGpBC,EAAAA,UAAU,EAAEC,sBAHQ;AAIpBC,EAAAA,QAAQ,EAAEC,oBAJU;AAKpBb,EAAAA,GAAG,EAAEc,eALe;AAMpBZ,EAAAA,KAAK,EAAEa,iBANa;AAOpBZ,EAAAA,MAAM,EAAEa,kBAPY;AAQpBZ,EAAAA,IAAI,EAAEa;AARc,CAAd;;AAWA,MAAMC,MAAM,GAAG;AACrBC,EAAAA,OAAO,EAAE,cAAI,iBAAJ,CADY;AAErBnB,EAAAA,GAAG,EAAE,cAAI,KAAJ,CAFgB;AAGrBG,EAAAA,MAAM,EAAE,cAAI,QAAJ,CAHa;AAIrBC,EAAAA,IAAI,EAAE,cAAI,MAAJ,CAJe;AAKrBF,EAAAA,KAAK,EAAE,cAAI,OAAJ,CALc;AAMrBkB,EAAAA,KAAK,EAAE,cAAI,OAAJ,CANc;AAOrBR,EAAAA,QAAQ,EAAE,cAAI,UAAJ,CAPW;AAQrBF,EAAAA,UAAU,EAAE,cAAI,Y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EAf,IAAAA,MAAM,CAACuB,OAAP,CAAgBxB,MAAhB,EAAyByB,IAAzB,CAA+B,CAAE,CAAEC,GAAF,EAAOxD,KAAP,CAAF,KAAsB;AACpD8C,MAAAA,IAAI,GAAGU,GAAP;AACA,aAAOxD,KAAK,KAAKtB,SAAjB;AACA,KAHD;AAKA,WAAOoE,IAAP;AACA,GA/BmD,CAiCpD;;;AACA,MAAKb,KAAK,EAAEN,MAAP,KAAkB,CAAlB,IAAuB,CAAEuB,UAAU,CAACvB,MAAzC,EAAkD;AACjD,WAAOM,KAAK,CAAE,CAAF,CAAZ;AACA,GApCmD,CAsCpD;;;AACA,SAAOnC,KAAK,CAACf,MAAb;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tsidesAll,\n\tsidesAxial,\n\tsidesBottom,\n\tsidesHorizontal,\n\tsidesLeft,\n\tsidesRight,\n\tsidesTop,\n\tsidesVertical,\n} from '@wordpress/icons';\n\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\n\nexport const DEFAULT_VALUES = {\n\ttop: undefined,\n\tright: undefined,\n\tbottom: undefined,\n\tleft: undefined,\n};\n\nexport const ICONS = {\n\tcustom: sidesAll,\n\taxial: sidesAxial,\n\thorizontal: sidesHorizontal,\n\tvertical: sidesVertical,\n\ttop: sidesTop,\n\tright: sidesRight,\n\tbottom: sidesBottom,\n\tleft: sidesLeft,\n};\n\nexport const LABELS = {\n\tdefault: __( 'Spacing control' ),\n\ttop: __( 'Top' ),\n\tbottom: __( 'Bottom' ),\n\tleft: __( 'Left' ),\n\tright: __( 'Right' ),\n\tmixed: __( 'Mixed' ),\n\tvertical: __( 'Vertical' ),\n\thorizontal: __( 'Horizontal' ),\n\taxial: __( 'Horizontal & vertical' ),\n\tcustom: __( 'Custom' ),\n};\n\nexport const VIEWS = {\n\taxial: 'axial',\n\ttop: 'top',\n\tright: 'right',\n\tbottom: 'bottom',\n\tleft: 'left',\n\tcustom: 'custom',\n};\n\n/**\n * Checks is given value is a spacing preset.\n *\n * @param {string} value Value to check\n *\n * @return {boolean} Return true if value is string in format var:preset|spacing|.\n */\nexport function isValueSpacingPreset( value ) {\n\tif ( ! value?.includes ) {\n\t\treturn false;\n\t}\n\treturn value === '0' || value.includes( 'var:preset|spacing|' );\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} Mapping of the spacing preset to its equivalent custom value.\n */\nexport function getCustomValueFromPreset( value, spacingSizes ) {\n\tif ( ! isValueSpacingPreset( value ) ) {\n\t\treturn value;\n\t}\n\n\tconst slug = getSpacingPresetSlug( value );\n\tconst spacingSize = spacingSizes.find(\n\t\t( size ) => String( size.slug ) === slug\n\t);\n\n\treturn spacingSize?.size;\n}\n\n/**\n * Converts a custom value to preset value if one can be found.\n *\n * Returns value as-is if no match is found.\n *\n * @param {string} value Value to convert\n * @param {Array} spacingSizes Array of the current spacing preset objects\n *\n * @return {string} The preset value if it can be found.\n */\nexport function getPresetValueFromCustomValue( value, spacingSizes ) {\n\t// Return value as-is if it is already a preset;\n\tif ( isValueSpacingPreset( value ) || value === '0' ) {\n\t\treturn value;\n\t}\n\n\tconst spacingMatch = spacingSizes.find(\n\t\t( size ) => String( size.size ) === String( value )\n\t);\n\n\tif ( spacingMatch?.slug ) {\n\t\treturn `var:preset|spacing|${ spacingMatch.slug }`;\n\t}\n\n\treturn value;\n}\n\n/**\n * Converts a spacing preset into a custom value.\n *\n * @param {string} value Value to convert.\n *\n * @return {string | undefined} CSS var string for given spacing preset value.\n */\nexport function getSpacingPresetCssVar( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\tif ( ! slug ) {\n\t\treturn value;\n\t}\n\n\treturn `var(--wp--preset--spacing--${ slug[ 1 ] })`;\n}\n\n/**\n * Returns the slug section of the given spacing preset string.\n *\n * @param {string} value Value to extract slug from.\n *\n * @return {string|undefined} The int value of the slug from given spacing preset.\n */\nexport function getSpacingPresetSlug( value ) {\n\tif ( ! value ) {\n\t\treturn;\n\t}\n\n\tif ( value === '0' || value === 'default' ) {\n\t\treturn value;\n\t}\n\n\tconst slug = value.match( /var:preset\\|spacing\\|(.+)/ );\n\n\treturn slug ? slug[ 1 ] : undefined;\n}\n\n/**\n * Converts spacing preset value into a Range component value .\n *\n * @param {string} presetValue Value to convert to Range value.\n * @param {Array} spacingSizes Array of current spacing preset value objects.\n *\n * @return {number} The int value for use in Range control.\n */\nexport function getSliderValueFromPreset( presetValue, spacingSizes ) {\n\tif ( presetValue === undefined ) {\n\t\treturn 0;\n\t}\n\tconst slug =\n\t\tparseFloat( presetValue, 10 ) === 0\n\t\t\t? '0'\n\t\t\t: getSpacingPresetSlug( presetValue );\n\tconst sliderValue = spacingSizes.findIndex( ( spacingSize ) => {\n\t\treturn String( spacingSize.slug ) === slug;\n\t} );\n\n\t// Returning NaN rather than undefined as undefined makes range control thumb sit in center\n\treturn sliderValue !== -1 ? sliderValue : NaN;\n}\n\n/**\n * Gets an items with the most occurrence within an array\n * https://stackoverflow.com/a/20762713\n *\n * @param {Array<any>} arr Array of items to check.\n * @return {any} The item with the most occurrences.\n */\nfunction mode( arr ) {\n\treturn arr\n\t\t.sort(\n\t\t\t( a, b ) =>\n\t\t\t\tarr.filter( ( v ) => v === a ).length -\n\t\t\t\tarr.filter( ( v ) => v === b ).length\n\t\t)\n\t\t.pop();\n}\n\n/**\n * Gets the 'all' input value from values data.\n *\n * @param {Object} values Box spacing values\n *\n * @return {string} The most common value from all sides of box.\n */\nexport function getAllRawValue( values = {} ) {\n\treturn mode( Object.values( values ) );\n}\n\n/**\n * Checks to determine if values are mixed.\n *\n * @param {Object} values Box values.\n * @param {Array} sides Sides that values relate to.\n *\n * @return {boolean} Whether values are mixed.\n */\nexport function isValuesMixed( values = {}, sides = ALL_SIDES ) {\n\treturn (\n\t\t( Object.values( values ).length >= 1 &&\n\t\t\tObject.values( values ).length < sides.length ) ||\n\t\tnew Set( Object.values( values ) ).size > 1\n\t);\n}\n\n/**\n * Checks to determine if values are defined.\n *\n * @param {Object} values Box values.\n *\n * @return {boolean} Whether values are defined.\n */\nexport function isValuesDefined( values ) {\n\tif ( values === undefined || values === null ) {\n\t\treturn false;\n\t}\n\treturn Object.values( values ).filter( ( value ) => !! value ).length > 0;\n}\n\n/**\n * Determines whether a particular axis has support. If no axis is\n * specified, this function checks if either axis is supported.\n *\n * @param {Array} sides Supported sides.\n * @param {string} axis Which axis to check.\n *\n * @return {boolean} Whether there is support for the specified axis or both axes.\n */\nexport function hasAxisSupport( sides, axis ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn false;\n\t}\n\n\tconst hasHorizontalSupport =\n\t\tsides.includes( 'horizontal' ) ||\n\t\t( sides.includes( 'left' ) && sides.includes( 'right' ) );\n\n\tconst hasVerticalSupport =\n\t\tsides.includes( 'vertical' ) ||\n\t\t( sides.includes( 'top' ) && sides.includes( 'bottom' ) );\n\n\tif ( axis === 'horizontal' ) {\n\t\treturn hasHorizontalSupport;\n\t}\n\n\tif ( axis === 'vertical' ) {\n\t\treturn hasVerticalSupport;\n\t}\n\n\treturn hasHorizontalSupport || hasVerticalSupport;\n}\n\n/**\n * Determines which menu options should be included in the SidePicker.\n *\n * @param {Array} sides Supported sides.\n *\n * @return {Object} Menu options with each option containing label & icon.\n */\nexport function getSupportedMenuItems( sides ) {\n\tif ( ! sides || ! sides.length ) {\n\t\treturn {};\n\t}\n\n\tconst menuItems = {};\n\n\t// Determine the primary \"side\" menu options.\n\tconst hasHorizontalSupport = hasAxisSupport( sides, 'horizontal' );\n\tconst hasVerticalSupport = hasAxisSupport( sides, 'vertical' );\n\n\tif ( hasHorizontalSupport && hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.axial, icon: ICONS.axial };\n\t} else if ( hasHorizontalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.horizontal, icon: ICONS.horizontal };\n\t} else if ( hasVerticalSupport ) {\n\t\tmenuItems.axial = { label: LABELS.vertical, icon: ICONS.vertical };\n\t}\n\n\t// Track whether we have any individual sides so we can omit the custom\n\t// option if required.\n\tlet numberOfIndividualSides = 0;\n\n\tALL_SIDES.forEach( ( side ) => {\n\t\tif ( sides.includes( side ) ) {\n\t\t\tnumberOfIndividualSides += 1;\n\t\t\tmenuItems[ side ] = {\n\t\t\t\tlabel: LABELS[ side ],\n\t\t\t\ticon: ICONS[ side ],\n\t\t\t};\n\t\t}\n\t} );\n\n\t// Add custom item if there are enough sides to warrant a separated view.\n\tif ( numberOfIndividualSides > 1 ) {\n\t\tmenuItems.custom = { label: LABELS.custom, icon: ICONS.custom };\n\t}\n\n\treturn menuItems;\n}\n\n/**\n * Checks if the supported sides are balanced for each axis.\n * - Horizontal - both left and right sides are supported.\n * - Vertical - both top and bottom are supported.\n *\n * @param {Array} sides The supported sides which may be axes as well.\n *\n * @return {boolean} Whether or not the supported sides are balanced.\n */\nexport function hasBalancedSidesSupport( sides = [] ) {\n\tconst counts = { top: 0, right: 0, bottom: 0, left: 0 };\n\tsides.forEach( ( side ) => ( counts[ side ] += 1 ) );\n\n\treturn (\n\t\t( counts.top + counts.bottom ) % 2 === 0 &&\n\t\t( counts.left + counts.right ) % 2 === 0\n\t);\n}\n\n/**\n * Determines which view the SpacingSizesControl should default to on its\n * first render; Axial, Custom, or Single side.\n *\n * @param {Object} values Current side values.\n * @param {Array} sides Supported sides.\n *\n * @return {string} View to display.\n */\nexport function getInitialView( values = {}, sides ) {\n\tconst { top, right, bottom, left } = values;\n\tconst sideValues = [ top, right, bottom, left ].filter( Boolean );\n\n\t// Axial ( Horizontal & vertical ).\n\t// - Has axial side support\n\t// - Has axial side values which match\n\t// - Has no values and the supported sides are balanced\n\tconst hasMatchingAxialValues =\n\t\ttop === bottom && left === right && ( !! top || !! left );\n\tconst hasNoValuesAndBalancedSides =\n\t\t! sideValues.length && hasBalancedSidesSupport( sides );\n\n\tif (\n\t\thasAxisSupport( sides ) &&\n\t\t( hasMatchingAxialValues || hasNoValuesAndBalancedSides )\n\t) {\n\t\treturn VIEWS.axial;\n\t}\n\n\t// Single side.\n\t// - Ensure the side returned is the first side that has a value.\n\tif ( sideValues.length === 1 ) {\n\t\tlet side;\n\n\t\tObject.entries( values ).some( ( [ key, value ] ) => {\n\t\t\tside = key;\n\t\t\treturn value !== undefined;\n\t\t} );\n\n\t\treturn side;\n\t}\n\n\t// Only single side supported and no value defined.\n\tif ( sides?.length === 1 && ! sideValues.length ) {\n\t\treturn sides[ 0 ];\n\t}\n\n\t// Default to the Custom (separated sides) view.\n\treturn VIEWS.custom;\n}\n"]}
|
|
@@ -75,7 +75,8 @@ function useBlockDisplayInformation(clientId) {
|
|
|
75
75
|
if (!clientId) return null;
|
|
76
76
|
const {
|
|
77
77
|
getBlockName,
|
|
78
|
-
getBlockAttributes
|
|
78
|
+
getBlockAttributes,
|
|
79
|
+
__experimentalGetReusableBlockTitle
|
|
79
80
|
} = select(_store.store);
|
|
80
81
|
const {
|
|
81
82
|
getBlockType,
|
|
@@ -86,11 +87,14 @@ function useBlockDisplayInformation(clientId) {
|
|
|
86
87
|
if (!blockType) return null;
|
|
87
88
|
const attributes = getBlockAttributes(clientId);
|
|
88
89
|
const match = getActiveBlockVariation(blockName, attributes);
|
|
89
|
-
const
|
|
90
|
+
const isReusable = (0, _blocks.isReusableBlock)(blockType);
|
|
91
|
+
const resusableTitle = isReusable ? __experimentalGetReusableBlockTitle(attributes.ref) : undefined;
|
|
92
|
+
const title = resusableTitle || blockType.title;
|
|
93
|
+
const isSynced = isReusable || (0, _blocks.isTemplatePart)(blockType);
|
|
90
94
|
const positionLabel = getPositionTypeLabel(attributes);
|
|
91
95
|
const blockTypeInfo = {
|
|
92
96
|
isSynced,
|
|
93
|
-
title
|
|
97
|
+
title,
|
|
94
98
|
icon: blockType.icon,
|
|
95
99
|
description: blockType.description,
|
|
96
100
|
anchor: attributes?.anchor,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/use-block-display-information/index.js"],"names":["getPositionTypeLabel","attributes","positionType","style","position","type","useBlockDisplayInformation","clientId","select","getBlockName","getBlockAttributes","blockEditorStore","getBlockType","getActiveBlockVariation","blocksStore","blockName","blockType","match","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/use-block-display-information/index.js"],"names":["getPositionTypeLabel","attributes","positionType","style","position","type","useBlockDisplayInformation","clientId","select","getBlockName","getBlockAttributes","__experimentalGetReusableBlockTitle","blockEditorStore","getBlockType","getActiveBlockVariation","blocksStore","blockName","blockType","match","isReusable","resusableTitle","ref","undefined","title","isSynced","positionLabel","blockTypeInfo","icon","description","anchor"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AAKA;;AAdA;AACA;AACA;;AASA;AACA;AACA;;AAGA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,oBAAT,CAA+BC,UAA/B,EAA4C;AAC3C,QAAMC,YAAY,GAAGD,UAAU,EAAEE,KAAZ,EAAmBC,QAAnB,EAA6BC,IAAlD;;AAEA,MAAKH,YAAY,KAAK,QAAtB,EAAiC;AAChC,WAAO,cAAI,QAAJ,CAAP;AACA;;AAED,MAAKA,YAAY,KAAK,OAAtB,EAAgC;AAC/B,WAAO,cAAI,OAAJ,CAAP;AACA;;AAED,SAAO,IAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AAEe,SAASI,0BAAT,CAAqCC,QAArC,EAAgD;AAC9D,SAAO,qBACJC,MAAF,IAAc;AACb,QAAK,CAAED,QAAP,EAAkB,OAAO,IAAP;AAClB,UAAM;AACLE,MAAAA,YADK;AAELC,MAAAA,kBAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEI,YAAF,CAJV;AAKA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AAEV,KAAK,CAACU,WAAN,IAAqBX,SAAS,CAACW,WAJtC;AAKNC,MAAAA,MAAM,EAAE5B,UAAU,EAAE4B,MALd;AAMNJ,MAAAA,aANM;AAONvB,MAAAA,YAAY,EAAED,UAAU,EAAEE,KAAZ,EAAmBC,QAAnB,EAA6BC;AAPrC,KAAP;AASA,GA1CK,EA2CN,CAAEE,QAAF,CA3CM,CAAP;AA6CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tstore as blocksStore,\n\tisReusableBlock,\n\tisTemplatePart,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */\n\n/**\n * Contains basic block's information for display reasons.\n *\n * @typedef {Object} WPBlockDisplayInformation\n *\n * @property {boolean} isSynced True if is a reusable block or template part\n * @property {string} title Human-readable block type label.\n * @property {WPIcon} icon Block type icon.\n * @property {string} description A detailed block type description.\n * @property {string} anchor HTML anchor.\n */\n\n/**\n * Get the display label for a block's position type.\n *\n * @param {Object} attributes Block attributes.\n * @return {string} The position type label.\n */\nfunction getPositionTypeLabel( attributes ) {\n\tconst positionType = attributes?.style?.position?.type;\n\n\tif ( positionType === 'sticky' ) {\n\t\treturn __( 'Sticky' );\n\t}\n\n\tif ( positionType === 'fixed' ) {\n\t\treturn __( 'Fixed' );\n\t}\n\n\treturn null;\n}\n\n/**\n * Hook used to try to find a matching block variation and return\n * the appropriate information for display reasons. In order to\n * to try to find a match we need to things:\n * 1. Block's client id to extract it's current attributes.\n * 2. A block variation should have set `isActive` prop to a proper function.\n *\n * If for any reason a block variation match cannot be found,\n * the returned information come from the Block Type.\n * If no blockType is found with the provided clientId, returns null.\n *\n * @param {string} clientId Block's client id.\n * @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.\n */\n\nexport default function useBlockDisplayInformation( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) return null;\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\t__experimentalGetReusableBlockTitle,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\t\t\tif ( ! blockType ) return null;\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst match = getActiveBlockVariation( blockName, attributes );\n\t\t\tconst isReusable = isReusableBlock( blockType );\n\t\t\tconst resusableTitle = isReusable\n\t\t\t\t? __experimentalGetReusableBlockTitle( attributes.ref )\n\t\t\t\t: undefined;\n\t\t\tconst title = resusableTitle || blockType.title;\n\t\t\tconst isSynced = isReusable || isTemplatePart( blockType );\n\t\t\tconst positionLabel = getPositionTypeLabel( attributes );\n\t\t\tconst blockTypeInfo = {\n\t\t\t\tisSynced,\n\t\t\t\ttitle,\n\t\t\t\ticon: blockType.icon,\n\t\t\t\tdescription: blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t};\n\t\t\tif ( ! match ) return blockTypeInfo;\n\n\t\t\treturn {\n\t\t\t\tisSynced,\n\t\t\t\ttitle: match.title || blockType.title,\n\t\t\t\ticon: match.icon || blockType.icon,\n\t\t\t\tdescription: match.description || blockType.description,\n\t\t\t\tanchor: attributes?.anchor,\n\t\t\t\tpositionLabel,\n\t\t\t\tpositionType: attributes?.style?.position?.type,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"]}
|
package/build/hooks/margin.js
CHANGED
|
@@ -35,7 +35,7 @@ function MarginVisualizer({
|
|
|
35
35
|
const [style, setStyle] = (0, _element.useState)();
|
|
36
36
|
const margin = attributes?.style?.spacing?.margin;
|
|
37
37
|
(0, _element.useEffect)(() => {
|
|
38
|
-
if (!blockElement) {
|
|
38
|
+
if (!blockElement || null === blockElement.ownerDocument.defaultView) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/margin.js"],"names":["getComputedCSS","element","property","ownerDocument","defaultView","getComputedStyle","getPropertyValue","MarginVisualizer","clientId","attributes","forceShow","blockElement","style","setStyle","margin","spacing","top","right","bottom","left","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","isActive","setIsActive","valueRef","timeoutRef","clearTimer","current","window","clearTimeout","setTimeout"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIA,SAASA,cAAT,CAAyBC,OAAzB,EAAkCC,QAAlC,EAA6C;AAC5C,SAAOD,OAAO,CAACE,aAAR,CAAsBC,WAAtB,CACLC,gBADK,CACaJ,OADb,EAELK,gBAFK,CAEaJ,QAFb,CAAP;AAGA;;AAEM,SAASK,gBAAT,CAA2B;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,UAAZ;AAAwBC,EAAAA;AAAxB,CAA3B,EAAiE;AACvE,QAAMC,YAAY,GAAG,6CAAiBH,QAAjB,CAArB;AACA,QAAM,CAAEI,KAAF,EAASC,QAAT,IAAsB,wBAA5B;AAEA,QAAMC,MAAM,GAAGL,UAAU,EAAEG,KAAZ,EAAmBG,OAAnB,EAA4BD,MAA3C;AAEA,0BAAW,MAAM;AAChB,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/margin.js"],"names":["getComputedCSS","element","property","ownerDocument","defaultView","getComputedStyle","getPropertyValue","MarginVisualizer","clientId","attributes","forceShow","blockElement","style","setStyle","margin","spacing","top","right","bottom","left","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","isActive","setIsActive","valueRef","timeoutRef","clearTimer","current","window","clearTimeout","setTim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EAAG;AALT,KAOC;AAAK,IAAA,SAAS,EAAC,kCAAf;AAAkD,IAAA,KAAK,EAAGF;AAA1D,IAPD,CADD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useRef, useEffect } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport BlockPopover from '../components/block-popover';\nimport { __unstableUseBlockElement as useBlockElement } from '../components/block-list/use-block-props/use-block-refs';\n\nfunction getComputedCSS( element, property ) {\n\treturn element.ownerDocument.defaultView\n\t\t.getComputedStyle( element )\n\t\t.getPropertyValue( property );\n}\n\nexport function MarginVisualizer( { clientId, attributes, forceShow } ) {\n\tconst blockElement = useBlockElement( clientId );\n\tconst [ style, setStyle ] = useState();\n\n\tconst margin = attributes?.style?.spacing?.margin;\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! blockElement ||\n\t\t\tnull === blockElement.ownerDocument.defaultView\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst top = getComputedCSS( blockElement, 'margin-top' );\n\t\tconst right = getComputedCSS( blockElement, 'margin-right' );\n\t\tconst bottom = getComputedCSS( blockElement, 'margin-bottom' );\n\t\tconst left = getComputedCSS( blockElement, 'margin-left' );\n\n\t\tsetStyle( {\n\t\t\tborderTopWidth: top,\n\t\t\tborderRightWidth: right,\n\t\t\tborderBottomWidth: bottom,\n\t\t\tborderLeftWidth: left,\n\t\t\ttop: top ? `-${ top }` : 0,\n\t\t\tright: right ? `-${ right }` : 0,\n\t\t\tbottom: bottom ? `-${ bottom }` : 0,\n\t\t\tleft: left ? `-${ left }` : 0,\n\t\t} );\n\t}, [ blockElement, margin ] );\n\n\tconst [ isActive, setIsActive ] = useState( false );\n\tconst valueRef = useRef( margin );\n\tconst timeoutRef = useRef();\n\n\tconst clearTimer = () => {\n\t\tif ( timeoutRef.current ) {\n\t\t\twindow.clearTimeout( timeoutRef.current );\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! isShallowEqual( margin, valueRef.current ) && ! forceShow ) {\n\t\t\tsetIsActive( true );\n\t\t\tvalueRef.current = margin;\n\n\t\t\ttimeoutRef.current = setTimeout( () => {\n\t\t\t\tsetIsActive( false );\n\t\t\t}, 400 );\n\t\t}\n\n\t\treturn () => {\n\t\t\tsetIsActive( false );\n\t\t\tclearTimer();\n\t\t};\n\t}, [ margin, forceShow ] );\n\n\tif ( ! isActive && ! forceShow ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ clientId }\n\t\t\t__unstableCoverTarget\n\t\t\t__unstableRefreshSize={ margin }\n\t\t\t__unstablePopoverSlot=\"block-toolbar\"\n\t\t\tshift={ false }\n\t\t>\n\t\t\t<div className=\"block-editor__padding-visualizer\" style={ style } />\n\t\t</BlockPopover>\n\t);\n}\n"]}
|
package/build/hooks/padding.js
CHANGED
|
@@ -35,7 +35,7 @@ function PaddingVisualizer({
|
|
|
35
35
|
const [style, setStyle] = (0, _element.useState)();
|
|
36
36
|
const padding = attributes?.style?.spacing?.padding;
|
|
37
37
|
(0, _element.useEffect)(() => {
|
|
38
|
-
if (!blockElement) {
|
|
38
|
+
if (!blockElement || null === blockElement.ownerDocument.defaultView) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/padding.js"],"names":["getComputedCSS","element","property","ownerDocument","defaultView","getComputedStyle","getPropertyValue","PaddingVisualizer","clientId","attributes","forceShow","blockElement","style","setStyle","padding","spacing","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","isActive","setIsActive","valueRef","timeoutRef","clearTimer","current","window","clearTimeout","setTimeout"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIA,SAASA,cAAT,CAAyBC,OAAzB,EAAkCC,QAAlC,EAA6C;AAC5C,SAAOD,OAAO,CAACE,aAAR,CAAsBC,WAAtB,CACLC,gBADK,CACaJ,OADb,EAELK,gBAFK,CAEaJ,QAFb,CAAP;AAGA;;AAEM,SAASK,iBAAT,CAA4B;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,UAAZ;AAAwBC,EAAAA;AAAxB,CAA5B,EAAkE;AACxE,QAAMC,YAAY,GAAG,6CAAiBH,QAAjB,CAArB;AACA,QAAM,CAAEI,KAAF,EAASC,QAAT,IAAsB,wBAA5B;AAEA,QAAMC,OAAO,GAAGL,UAAU,EAAEG,KAAZ,EAAmBG,OAAnB,EAA4BD,OAA5C;AAEA,0BAAW,MAAM;AAChB,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/hooks/padding.js"],"names":["getComputedCSS","element","property","ownerDocument","defaultView","getComputedStyle","getPropertyValue","PaddingVisualizer","clientId","attributes","forceShow","blockElement","style","setStyle","padding","spacing","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","isActive","setIsActive","valueRef","timeoutRef","clearTimer","current","window","clearTimeout","setTimeout"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIA,SAASA,cAAT,CAAyBC,OAAzB,EAAkCC,QAAlC,EAA6C;AAC5C,SAAOD,OAAO,CAACE,aAAR,CAAsBC,WAAtB,CACLC,gBADK,CACaJ,OADb,EAELK,gBAFK,CAEaJ,QAFb,CAAP;AAGA;;AAEM,SAASK,iBAAT,CAA4B;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,UAAZ;AAAwBC,EAAAA;AAAxB,CAA5B,EAAkE;AACxE,QAAMC,YAAY,GAAG,6CAAiBH,QAAjB,CAArB;AACA,QAAM,CAAEI,KAAF,EAASC,QAAT,IAAsB,wBAA5B;AAEA,QAAMC,OAAO,GAAGL,UAAU,EAAEG,KAAZ,EAAmBG,OAAnB,EAA4BD,OAA5C;AAEA,0BAAW,MAAM;AAChB,QACC,CAAEH,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,CAAEU,QAAF,IAAc,CAAEV,SAArB,EAAiC;AAChC,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,qBAAD;AACC,IAAA,QAAQ,EAAGF,QADZ;AAEC,IAAA,qBAAqB,MAFtB;AAGC,IAAA,qBAAqB,EAAGM,OAHzB;AAIC,IAAA,qBAAqB,EAAC,eAJvB;AAKC,IAAA,KAAK,EAAG;AALT,KAOC;AAAK,IAAA,SAAS,EAAC,kCAAf;AAAkD,IAAA,KAAK,EAAGF;AAA1D,IAPD,CADD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useRef, useEffect } from '@wordpress/element';\nimport isShallowEqual from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport BlockPopover from '../components/block-popover';\nimport { __unstableUseBlockElement as useBlockElement } from '../components/block-list/use-block-props/use-block-refs';\n\nfunction getComputedCSS( element, property ) {\n\treturn element.ownerDocument.defaultView\n\t\t.getComputedStyle( element )\n\t\t.getPropertyValue( property );\n}\n\nexport function PaddingVisualizer( { clientId, attributes, forceShow } ) {\n\tconst blockElement = useBlockElement( clientId );\n\tconst [ style, setStyle ] = useState();\n\n\tconst padding = attributes?.style?.spacing?.padding;\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! blockElement ||\n\t\t\tnull === blockElement.ownerDocument.defaultView\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetStyle( {\n\t\t\tborderTopWidth: getComputedCSS( blockElement, 'padding-top' ),\n\t\t\tborderRightWidth: getComputedCSS( blockElement, 'padding-right' ),\n\t\t\tborderBottomWidth: getComputedCSS( blockElement, 'padding-bottom' ),\n\t\t\tborderLeftWidth: getComputedCSS( blockElement, 'padding-left' ),\n\t\t} );\n\t}, [ blockElement, padding ] );\n\n\tconst [ isActive, setIsActive ] = useState( false );\n\tconst valueRef = useRef( padding );\n\tconst timeoutRef = useRef();\n\n\tconst clearTimer = () => {\n\t\tif ( timeoutRef.current ) {\n\t\t\twindow.clearTimeout( timeoutRef.current );\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! isShallowEqual( padding, valueRef.current ) && ! forceShow ) {\n\t\t\tsetIsActive( true );\n\t\t\tvalueRef.current = padding;\n\n\t\t\ttimeoutRef.current = setTimeout( () => {\n\t\t\t\tsetIsActive( false );\n\t\t\t}, 400 );\n\t\t}\n\n\t\treturn () => {\n\t\t\tsetIsActive( false );\n\t\t\tclearTimer();\n\t\t};\n\t}, [ padding, forceShow ] );\n\n\tif ( ! isActive && ! forceShow ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ clientId }\n\t\t\t__unstableCoverTarget\n\t\t\t__unstableRefreshSize={ padding }\n\t\t\t__unstablePopoverSlot=\"block-toolbar\"\n\t\t\tshift={ false }\n\t\t>\n\t\t\t<div className=\"block-editor__padding-visualizer\" style={ style } />\n\t\t</BlockPopover>\n\t);\n}\n"]}
|
package/build/private-apis.js
CHANGED
|
@@ -41,6 +41,8 @@ var _dimensionsTool = _interopRequireDefault(require("./components/dimensions-to
|
|
|
41
41
|
|
|
42
42
|
var _resolutionTool = _interopRequireDefault(require("./components/resolution-tool"));
|
|
43
43
|
|
|
44
|
+
var _reusableBlockRenameHint = _interopRequireWildcard(require("./components/inserter/reusable-block-rename-hint"));
|
|
45
|
+
|
|
44
46
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
45
47
|
|
|
46
48
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -70,6 +72,8 @@ exports.privateApis = privateApis;
|
|
|
70
72
|
useLayoutClasses: _hooks.useLayoutClasses,
|
|
71
73
|
useLayoutStyles: _hooks.useLayoutStyles,
|
|
72
74
|
DimensionsTool: _dimensionsTool.default,
|
|
73
|
-
ResolutionTool: _resolutionTool.default
|
|
75
|
+
ResolutionTool: _resolutionTool.default,
|
|
76
|
+
ReusableBlocksRenameHint: _reusableBlockRenameHint.default,
|
|
77
|
+
useReusableBlocksRenameHint: _reusableBlockRenameHint.useReusableBlocksRenameHint
|
|
74
78
|
});
|
|
75
79
|
//# sourceMappingURL=private-apis.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/private-apis.js"],"names":["privateApis","globalStyles","ExperimentalBlockEditorProvider","getRichTextValues","PrivateInserter","PrivateListView","ResizableBoxPopover","BlockInfo","useShouldContextualToolbarShow","cleanEmptyObject","useBlockEditingMode","BlockQuickNavigation","LayoutStyle","BlockRemovalWarningModal","useLayoutClasses","useLayoutStyles","DimensionsTool","ResolutionTool"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/private-apis.js"],"names":["privateApis","globalStyles","ExperimentalBlockEditorProvider","getRichTextValues","PrivateInserter","PrivateListView","ResizableBoxPopover","BlockInfo","useShouldContextualToolbarShow","cleanEmptyObject","useBlockEditingMode","BlockQuickNavigation","LayoutStyle","BlockRemovalWarningModal","useLayoutClasses","useLayoutStyles","DimensionsTool","ResolutionTool","ReusableBlocksRenameHint","useReusableBlocksRenameHint"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AApBA;AACA;AACA;;AAuBA;AACA;AACA;AACO,MAAMA,WAAW,GAAG,EAApB;;AACP,sBAAMA,WAAN,EAAmB,EAClB,GAAGC,YADe;AAElBC,EAAAA,+BAA+B,EAA/BA,yCAFkB;AAGlBC,EAAAA,iBAAiB,EAAjBA,oCAHkB;AAIlBC,EAAAA,eAAe,EAAfA,iCAJkB;AAKlBC,EAAAA,eAAe,EAAfA,yBALkB;AAMlBC,EAAAA,mBAAmB,EAAnBA,4BANkB;AAOlBC,EAAAA,SAAS,EAATA,0BAPkB;AAQlBC,EAAAA,8BAA8B,EAA9BA,8DARkB;AASlBC,EAAAA,gBAAgB,EAAhBA,uBATkB;AAUlBC,EAAAA,mBAAmB,EAAnBA,qCAVkB;AAWlBC,EAAAA,oBAAoB,EAApBA,6BAXkB;AAYlBC,EAAAA,WAAW,EAAXA,mBAZkB;AAalBC,EAAAA,wBAAwB,EAAxBA,kDAbkB;AAclBC,EAAAA,gBAAgB,EAAhBA,uBAdkB;AAelBC,EAAAA,eAAe,EAAfA,sBAfkB;AAgBlBC,EAAAA,cAAc,EAAdA,uBAhBkB;AAiBlBC,EAAAA,cAAc,EAAdA,uBAjBkB;AAkBlBC,EAAAA,wBAAwB,EAAxBA,gCAlBkB;AAmBlBC,EAAAA,2BAA2B,EAA3BA;AAnBkB,CAAnB","sourcesContent":["/**\n * Internal dependencies\n */\nimport * as globalStyles from './components/global-styles';\nimport { ExperimentalBlockEditorProvider } from './components/provider';\nimport { lock } from './lock-unlock';\nimport { getRichTextValues } from './components/rich-text/get-rich-text-values';\nimport ResizableBoxPopover from './components/resizable-box-popover';\nimport { ComposedPrivateInserter as PrivateInserter } from './components/inserter';\nimport { PrivateListView } from './components/list-view';\nimport BlockInfo from './components/block-info-slot-fill';\nimport { useShouldContextualToolbarShow } from './utils/use-should-contextual-toolbar-show';\nimport { cleanEmptyObject } from './hooks/utils';\nimport { useBlockEditingMode } from './components/block-editing-mode';\nimport BlockQuickNavigation from './components/block-quick-navigation';\nimport { LayoutStyle } from './components/block-list/layout';\nimport { BlockRemovalWarningModal } from './components/block-removal-warning-modal';\nimport { useLayoutClasses, useLayoutStyles } from './hooks';\nimport DimensionsTool from './components/dimensions-tool';\nimport ResolutionTool from './components/resolution-tool';\nimport {\n\tdefault as ReusableBlocksRenameHint,\n\tuseReusableBlocksRenameHint,\n} from './components/inserter/reusable-block-rename-hint';\n\n/**\n * Private @wordpress/block-editor APIs.\n */\nexport const privateApis = {};\nlock( privateApis, {\n\t...globalStyles,\n\tExperimentalBlockEditorProvider,\n\tgetRichTextValues,\n\tPrivateInserter,\n\tPrivateListView,\n\tResizableBoxPopover,\n\tBlockInfo,\n\tuseShouldContextualToolbarShow,\n\tcleanEmptyObject,\n\tuseBlockEditingMode,\n\tBlockQuickNavigation,\n\tLayoutStyle,\n\tBlockRemovalWarningModal,\n\tuseLayoutClasses,\n\tuseLayoutStyles,\n\tDimensionsTool,\n\tResolutionTool,\n\tReusableBlocksRenameHint,\n\tuseReusableBlocksRenameHint,\n} );\n"]}
|
package/build/store/index.js
CHANGED
|
@@ -62,5 +62,14 @@ const registeredStore = (0, _data.registerStore)(_constants.STORE_NAME, { ...sto
|
|
|
62
62
|
persist: ['preferences']
|
|
63
63
|
});
|
|
64
64
|
(0, _lockUnlock.unlock)(registeredStore).registerPrivateActions(privateActions);
|
|
65
|
-
(0, _lockUnlock.unlock)(registeredStore).registerPrivateSelectors(privateSelectors);
|
|
65
|
+
(0, _lockUnlock.unlock)(registeredStore).registerPrivateSelectors(privateSelectors); // TODO: Remove once we switch to the `register` function (see above).
|
|
66
|
+
//
|
|
67
|
+
// Until then, private functions also need to be attached to the original
|
|
68
|
+
// `store` descriptor in order to avoid unit tests failing, which could happen
|
|
69
|
+
// when tests create new registries in which they register stores.
|
|
70
|
+
//
|
|
71
|
+
// @see https://github.com/WordPress/gutenberg/pull/51145#discussion_r1239999590
|
|
72
|
+
|
|
73
|
+
(0, _lockUnlock.unlock)(store).registerPrivateActions(privateActions);
|
|
74
|
+
(0, _lockUnlock.unlock)(store).registerPrivateSelectors(privateSelectors);
|
|
66
75
|
//# sourceMappingURL=index.js.map
|
package/build/store/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/store/index.js"],"names":["storeConfig","reducer","selectors","actions","store","STORE_NAME","persist","registeredStore","registerPrivateActions","privateActions","registerPrivateSelectors","privateSelectors"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAG;AAC1BC,EAAAA,OAAO,EAAPA,gBAD0B;AAE1BC,EAAAA,SAF0B;AAG1BC,EAAAA;AAH0B,CAApB;AAMP;AACA;AACA;AACA;AACA;;;AACO,MAAMC,KAAK,GAAG,4BAAkBC,qBAAlB,EAA8B,EAClD,GAAGL,WAD+C;AAElDM,EAAAA,OAAO,EAAE,CAAE,aAAF;AAFyC,CAA9B,CAAd,C,CAKP;AACA;;;AACA,MAAMC,eAAe,GAAG,yBAAeF,qBAAf,EAA2B,EAClD,GAAGL,WAD+C;AAElDM,EAAAA,OAAO,EAAE,CAAE,aAAF;AAFyC,CAA3B,CAAxB;AAIA,wBAAQC,eAAR,EAA0BC,sBAA1B,CAAkDC,cAAlD;AACA,wBAAQF,eAAR,EAA0BG,wBAA1B,CAAoDC,gBAApD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, registerStore } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as privateActions from './private-actions';\nimport * as privateSelectors from './private-selectors';\nimport * as actions from './actions';\nimport { STORE_NAME } from './constants';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Block editor data store configuration.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore\n */\nexport const storeConfig = {\n\treducer,\n\tselectors,\n\tactions,\n};\n\n/**\n * Store definition for the block editor namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n */\nexport const store = createReduxStore( STORE_NAME, {\n\t...storeConfig,\n\tpersist: [ 'preferences' ],\n} );\n\n// We will be able to use the `register` function once we switch\n// the \"preferences\" persistence to use the new preferences package.\nconst registeredStore = registerStore( STORE_NAME, {\n\t...storeConfig,\n\tpersist: [ 'preferences' ],\n} );\nunlock( registeredStore ).registerPrivateActions( privateActions );\nunlock( registeredStore ).registerPrivateSelectors( privateSelectors );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/store/index.js"],"names":["storeConfig","reducer","selectors","actions","store","STORE_NAME","persist","registeredStore","registerPrivateActions","privateActions","registerPrivateSelectors","privateSelectors"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACO,MAAMA,WAAW,GAAG;AAC1BC,EAAAA,OAAO,EAAPA,gBAD0B;AAE1BC,EAAAA,SAF0B;AAG1BC,EAAAA;AAH0B,CAApB;AAMP;AACA;AACA;AACA;AACA;;;AACO,MAAMC,KAAK,GAAG,4BAAkBC,qBAAlB,EAA8B,EAClD,GAAGL,WAD+C;AAElDM,EAAAA,OAAO,EAAE,CAAE,aAAF;AAFyC,CAA9B,CAAd,C,CAKP;AACA;;;AACA,MAAMC,eAAe,GAAG,yBAAeF,qBAAf,EAA2B,EAClD,GAAGL,WAD+C;AAElDM,EAAAA,OAAO,EAAE,CAAE,aAAF;AAFyC,CAA3B,CAAxB;AAIA,wBAAQC,eAAR,EAA0BC,sBAA1B,CAAkDC,cAAlD;AACA,wBAAQF,eAAR,EAA0BG,wBAA1B,CAAoDC,gBAApD,E,CAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,wBAAQP,KAAR,EAAgBI,sBAAhB,CAAwCC,cAAxC;AACA,wBAAQL,KAAR,EAAgBM,wBAAhB,CAA0CC,gBAA1C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, registerStore } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as privateActions from './private-actions';\nimport * as privateSelectors from './private-selectors';\nimport * as actions from './actions';\nimport { STORE_NAME } from './constants';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Block editor data store configuration.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore\n */\nexport const storeConfig = {\n\treducer,\n\tselectors,\n\tactions,\n};\n\n/**\n * Store definition for the block editor namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n */\nexport const store = createReduxStore( STORE_NAME, {\n\t...storeConfig,\n\tpersist: [ 'preferences' ],\n} );\n\n// We will be able to use the `register` function once we switch\n// the \"preferences\" persistence to use the new preferences package.\nconst registeredStore = registerStore( STORE_NAME, {\n\t...storeConfig,\n\tpersist: [ 'preferences' ],\n} );\nunlock( registeredStore ).registerPrivateActions( privateActions );\nunlock( registeredStore ).registerPrivateSelectors( privateSelectors );\n\n// TODO: Remove once we switch to the `register` function (see above).\n//\n// Until then, private functions also need to be attached to the original\n// `store` descriptor in order to avoid unit tests failing, which could happen\n// when tests create new registries in which they register stores.\n//\n// @see https://github.com/WordPress/gutenberg/pull/51145#discussion_r1239999590\nunlock( store ).registerPrivateActions( privateActions );\nunlock( store ).registerPrivateSelectors( privateSelectors );\n"]}
|
|
@@ -4,27 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.__experimentalUpdateSettings = __experimentalUpdateSettings;
|
|
7
|
-
exports.
|
|
8
|
-
exports.displayRemovalPrompt = displayRemovalPrompt;
|
|
7
|
+
exports.clearBlockRemovalPrompt = clearBlockRemovalPrompt;
|
|
9
8
|
exports.ensureDefaultBlock = void 0;
|
|
10
9
|
exports.hideBlockInterface = hideBlockInterface;
|
|
11
10
|
exports.privateRemoveBlocks = void 0;
|
|
12
11
|
exports.setBlockEditingMode = setBlockEditingMode;
|
|
12
|
+
exports.setBlockRemovalRules = setBlockRemovalRules;
|
|
13
13
|
exports.showBlockInterface = showBlockInterface;
|
|
14
|
-
exports.toggleRemovalPromptSupport = toggleRemovalPromptSupport;
|
|
15
14
|
exports.unsetBlockEditingMode = unsetBlockEditingMode;
|
|
16
15
|
|
|
17
16
|
var _element = require("@wordpress/element");
|
|
18
17
|
|
|
19
|
-
var _blockRemovalWarningModal = require("../components/block-removal-warning-modal");
|
|
20
|
-
|
|
21
18
|
/**
|
|
22
19
|
* WordPress dependencies
|
|
23
20
|
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Internal dependencies
|
|
27
|
-
*/
|
|
28
21
|
const castArray = maybeArray => Array.isArray(maybeArray) ? maybeArray : [maybeArray];
|
|
29
22
|
/**
|
|
30
23
|
* A list of private/experimental block editor settings that
|
|
@@ -169,26 +162,18 @@ const privateRemoveBlocks = (clientIds, selectPrevious = true, forceRemove = fal
|
|
|
169
162
|
// confirmation that they intended to remove such block(s). However,
|
|
170
163
|
// the editor instance is responsible for presenting those confirmation
|
|
171
164
|
// prompts to the user. Any instance opting into removal prompts must
|
|
172
|
-
// register using `
|
|
165
|
+
// register using `setBlockRemovalRules()`.
|
|
173
166
|
//
|
|
174
167
|
// @see https://github.com/WordPress/gutenberg/pull/51145
|
|
175
168
|
|
|
176
169
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
// the fact that the `registry` object passed to the thunk actions
|
|
181
|
-
// doesn't include this private action. This needs to be
|
|
182
|
-
// investigated to understand whether it's a real smell or if it's
|
|
183
|
-
// because not all store code has been updated to accommodate
|
|
184
|
-
// private selectors.
|
|
185
|
-
select.isRemovalPromptSupported && select.isRemovalPromptSupported()) {
|
|
170
|
+
const rules = !forceRemove && select.getBlockRemovalRules();
|
|
171
|
+
|
|
172
|
+
if (rules) {
|
|
186
173
|
const blockNamesForPrompt = new Set(); // Given a list of client IDs of blocks that the user intended to
|
|
187
174
|
// remove, perform a tree search (BFS) to find all block names
|
|
188
175
|
// corresponding to "important" blocks, i.e. blocks that require a
|
|
189
176
|
// removal prompt.
|
|
190
|
-
//
|
|
191
|
-
// @see blockTypePromptMessages
|
|
192
177
|
|
|
193
178
|
const queue = [...clientIds];
|
|
194
179
|
|
|
@@ -196,7 +181,7 @@ const privateRemoveBlocks = (clientIds, selectPrevious = true, forceRemove = fal
|
|
|
196
181
|
const clientId = queue.shift();
|
|
197
182
|
const blockName = select.getBlockName(clientId);
|
|
198
183
|
|
|
199
|
-
if (
|
|
184
|
+
if (rules[blockName]) {
|
|
200
185
|
blockNamesForPrompt.add(blockName);
|
|
201
186
|
}
|
|
202
187
|
|
|
@@ -207,7 +192,7 @@ const privateRemoveBlocks = (clientIds, selectPrevious = true, forceRemove = fal
|
|
|
207
192
|
|
|
208
193
|
|
|
209
194
|
if (blockNamesForPrompt.size) {
|
|
210
|
-
dispatch(
|
|
195
|
+
dispatch(displayBlockRemovalPrompt(clientIds, selectPrevious, Array.from(blockNamesForPrompt)));
|
|
211
196
|
return;
|
|
212
197
|
}
|
|
213
198
|
}
|
|
@@ -263,7 +248,7 @@ const ensureDefaultBlock = () => ({
|
|
|
263
248
|
* Returns an action object used in signalling that a block removal prompt must
|
|
264
249
|
* be displayed.
|
|
265
250
|
*
|
|
266
|
-
* Contrast with `
|
|
251
|
+
* Contrast with `setBlockRemovalRules`.
|
|
267
252
|
*
|
|
268
253
|
* @param {string|string[]} clientIds Client IDs of blocks to remove.
|
|
269
254
|
* @param {boolean} selectPrevious True if the previous block
|
|
@@ -271,16 +256,19 @@ const ensureDefaultBlock = () => ({
|
|
|
271
256
|
* (if no previous block exists)
|
|
272
257
|
* should be selected
|
|
273
258
|
* when a block is removed.
|
|
274
|
-
* @param {string[]} blockNamesForPrompt Names of blocks
|
|
259
|
+
* @param {string[]} blockNamesForPrompt Names of the blocks that
|
|
260
|
+
* triggered the need for
|
|
261
|
+
* confirmation before removal.
|
|
262
|
+
*
|
|
275
263
|
* @return {Object} Action object.
|
|
276
264
|
*/
|
|
277
265
|
|
|
278
266
|
|
|
279
267
|
exports.ensureDefaultBlock = ensureDefaultBlock;
|
|
280
268
|
|
|
281
|
-
function
|
|
269
|
+
function displayBlockRemovalPrompt(clientIds, selectPrevious, blockNamesForPrompt) {
|
|
282
270
|
return {
|
|
283
|
-
type: '
|
|
271
|
+
type: 'DISPLAY_BLOCK_REMOVAL_PROMPT',
|
|
284
272
|
clientIds,
|
|
285
273
|
selectPrevious,
|
|
286
274
|
blockNamesForPrompt
|
|
@@ -295,26 +283,38 @@ function displayRemovalPrompt(clientIds, selectPrevious, blockNamesForPrompt) {
|
|
|
295
283
|
*/
|
|
296
284
|
|
|
297
285
|
|
|
298
|
-
function
|
|
286
|
+
function clearBlockRemovalPrompt() {
|
|
299
287
|
return {
|
|
300
|
-
type: '
|
|
288
|
+
type: 'CLEAR_BLOCK_REMOVAL_PROMPT'
|
|
301
289
|
};
|
|
302
290
|
}
|
|
303
291
|
/**
|
|
304
|
-
* Returns an action object used
|
|
305
|
-
*
|
|
292
|
+
* Returns an action object used to set up any rules that a block editor may
|
|
293
|
+
* provide in order to prevent a user from accidentally removing certain
|
|
294
|
+
* blocks. These rules are then used to display a confirmation prompt to the
|
|
295
|
+
* user. For instance, in the Site Editor, the Query Loop block is important
|
|
296
|
+
* enough to warrant such confirmation.
|
|
297
|
+
*
|
|
298
|
+
* IMPORTANT: Registering rules implicitly signals to the `privateRemoveBlocks`
|
|
299
|
+
* action that the editor will be responsible for displaying block removal
|
|
300
|
+
* prompts and confirming deletions. This action is meant to be used by
|
|
301
|
+
* component `BlockRemovalWarningModal` only.
|
|
302
|
+
*
|
|
303
|
+
* The data is a record whose keys are block types (e.g. 'core/query') and
|
|
304
|
+
* whose values are the explanation to be shown to users (e.g. 'Query Loop
|
|
305
|
+
* displays a list of posts or pages.').
|
|
306
306
|
*
|
|
307
|
-
* Contrast with `
|
|
307
|
+
* Contrast with `displayBlockRemovalPrompt`.
|
|
308
308
|
*
|
|
309
|
-
* @param {
|
|
309
|
+
* @param {Record<string,string>|false} rules Block removal rules.
|
|
310
310
|
* @return {Object} Action object.
|
|
311
311
|
*/
|
|
312
312
|
|
|
313
313
|
|
|
314
|
-
function
|
|
314
|
+
function setBlockRemovalRules(rules = false) {
|
|
315
315
|
return {
|
|
316
|
-
type: '
|
|
317
|
-
|
|
316
|
+
type: 'SET_BLOCK_REMOVAL_RULES',
|
|
317
|
+
rules
|
|
318
318
|
};
|
|
319
319
|
}
|
|
320
320
|
//# sourceMappingURL=private-actions.js.map
|