@wordpress/block-editor 11.4.0 → 11.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/build/components/block-inspector/index.js +11 -10
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-inspector/useBlockInspectorAnimationSettings.js +46 -0
- package/build/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
- package/build/components/block-lock/modal.js +1 -0
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/index.js +2 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/child-layout-control/index.js +107 -0
- package/build/components/child-layout-control/index.js.map +1 -0
- package/build/components/date-format-picker/index.js +3 -3
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +594 -0
- package/build/components/global-styles/dimensions-panel.js.map +1 -0
- package/build/components/global-styles/hooks.js +72 -36
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +20 -6
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +25 -12
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +1 -1
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -0
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/index.native.js +23 -0
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +10 -11
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/media-tab/media-list.js +5 -108
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +242 -0
- package/build/components/inserter/media-tab/media-preview.js.map +1 -0
- package/build/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build/components/inspector-controls/fill.js +38 -9
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/link-control/settings-drawer.js +1 -1
- package/build/components/link-control/settings-drawer.js.map +1 -1
- package/build/components/link-control/settings.js +1 -0
- package/build/components/link-control/settings.js.map +1 -1
- package/build/components/list-view/block.js +17 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +2 -2
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/expander.js +2 -1
- package/build/components/list-view/expander.js.map +1 -1
- package/build/components/list-view/leaf.js +10 -6
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-list-view-scroll-into-view.js +51 -0
- package/build/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
- package/build/components/off-canvas-editor/appender.js +5 -10
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +1 -0
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +7 -3
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/leaf-more-menu.js +34 -4
- package/build/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +1 -0
- package/build/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build/components/responsive-block-control/index.js +1 -0
- package/build/components/responsive-block-control/index.js.map +1 -1
- package/build/components/rich-text/index.js +9 -43
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-delete.js +73 -0
- package/build/components/rich-text/use-delete.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +14 -6
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +4 -1
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/hooks/align.js +3 -1
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/dimensions.js +72 -190
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/duotone.js +94 -25
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/gap.js +0 -202
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/layout.js +14 -5
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/margin.js +7 -163
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/padding.js +7 -163
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/typography.js +50 -65
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +75 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/flex.js +1 -0
- package/build/layouts/flex.js.map +1 -1
- package/build/store/actions.js +24 -12
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +28 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +53 -47
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +5 -1
- package/build/store/selectors.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +36 -3
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-inspector/index.js +9 -9
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js +37 -0
- package/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js.map +1 -0
- package/build-module/components/block-lock/modal.js +1 -0
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/index.js +2 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +98 -0
- package/build-module/components/child-layout-control/index.js.map +1 -0
- package/build-module/components/date-format-picker/index.js +4 -4
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +574 -0
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +71 -33
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +2 -1
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +26 -11
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +2 -0
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/index.native.js +2 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +10 -11
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-list.js +6 -105
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +222 -0
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -0
- package/build-module/components/inspector-controls/block-support-tools-panel.js +1 -1
- package/build-module/components/inspector-controls/block-support-tools-panel.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +39 -9
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/link-control/settings-drawer.js +1 -1
- package/build-module/components/link-control/settings-drawer.js.map +1 -1
- package/build-module/components/link-control/settings.js +1 -0
- package/build-module/components/link-control/settings.js.map +1 -1
- package/build-module/components/list-view/block.js +16 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +2 -2
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/expander.js +2 -1
- package/build-module/components/list-view/expander.js.map +1 -1
- package/build-module/components/list-view/leaf.js +8 -4
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-list-view-scroll-into-view.js +42 -0
- package/build-module/components/list-view/use-list-view-scroll-into-view.js.map +1 -0
- package/build-module/components/off-canvas-editor/appender.js +5 -10
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +1 -0
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +7 -3
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/leaf-more-menu.js +36 -7
- package/build-module/components/off-canvas-editor/leaf-more-menu.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +1 -0
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build-module/components/responsive-block-control/index.js +1 -0
- package/build-module/components/responsive-block-control/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +9 -43
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-delete.js +62 -0
- package/build-module/components/rich-text/use-delete.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +14 -6
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +4 -1
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/hooks/align.js +3 -1
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/dimensions.js +75 -187
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/duotone.js +86 -24
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/gap.js +0 -183
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/layout.js +14 -5
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/margin.js +4 -143
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/padding.js +4 -143
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/typography.js +52 -65
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +70 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/flex.js +1 -0
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/store/actions.js +24 -12
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +28 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +53 -45
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +5 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +36 -3
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +33 -21
- package/build-style/style.css +33 -21
- package/package.json +31 -31
- package/src/components/block-draggable/test/__snapshots__/index.native.js.snap +24 -24
- package/src/components/block-inspector/index.js +11 -14
- package/src/components/block-inspector/useBlockInspectorAnimationSettings.js +53 -0
- package/src/components/block-lock/modal.js +1 -0
- package/src/components/block-lock/style.scss +0 -9
- package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +20 -20
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +15 -15
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/src/components/block-styles/index.js +5 -1
- package/src/components/child-layout-control/index.js +106 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/date-format-picker/index.js +6 -8
- package/src/components/date-format-picker/style.scss +0 -5
- package/src/components/global-styles/dimensions-panel.js +627 -0
- package/src/components/global-styles/hooks.js +88 -45
- package/src/components/global-styles/index.js +5 -1
- package/src/components/global-styles/typography-panel.js +33 -8
- package/src/components/global-styles/use-global-styles-output.js +4 -3
- package/src/components/global-styles/utils.js +2 -0
- package/src/components/index.native.js +5 -0
- package/src/components/inner-blocks/test/__snapshots__/index.js.snap +1 -1
- package/src/components/inserter/media-tab/hooks.js +9 -8
- package/src/components/inserter/media-tab/media-list.js +3 -122
- package/src/components/inserter/media-tab/media-preview.js +268 -0
- package/src/components/inserter/style.scss +22 -0
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +15 -15
- package/src/components/inspector-controls/block-support-tools-panel.js +0 -1
- package/src/components/inspector-controls/fill.js +32 -8
- package/src/components/link-control/settings-drawer.js +2 -1
- package/src/components/link-control/settings.js +1 -0
- package/src/components/link-control/style.scss +18 -8
- package/src/components/link-control/test/index.js +3 -3
- package/src/components/list-view/block.js +19 -1
- package/src/components/list-view/branch.js +1 -2
- package/src/components/list-view/expander.js +1 -0
- package/src/components/list-view/leaf.js +43 -29
- package/src/components/list-view/use-list-view-scroll-into-view.js +48 -0
- package/src/components/media-replace-flow/style.scss +7 -9
- package/src/components/off-canvas-editor/appender.js +13 -16
- package/src/components/off-canvas-editor/branch.js +1 -0
- package/src/components/off-canvas-editor/index.js +8 -2
- package/src/components/off-canvas-editor/leaf-more-menu.js +57 -15
- package/src/components/off-canvas-editor/link-ui.js +1 -0
- package/src/components/responsive-block-control/index.js +1 -0
- package/src/components/rich-text/index.js +8 -44
- package/src/components/rich-text/use-delete.js +59 -0
- package/src/components/rich-text/use-input-rules.js +13 -5
- package/src/components/spacing-sizes-control/style.scss +1 -1
- package/src/components/url-popover/stories/index.js +1 -0
- package/src/components/writing-flow/use-selection-observer.js +5 -1
- package/src/hooks/align.js +1 -1
- package/src/hooks/dimensions.js +85 -269
- package/src/hooks/duotone.js +100 -30
- package/src/hooks/gap.js +0 -208
- package/src/hooks/layout.js +19 -6
- package/src/hooks/margin.js +1 -164
- package/src/hooks/padding.js +1 -163
- package/src/hooks/test/__snapshots__/align.native.js.snap +24 -24
- package/src/hooks/test/duotone.js +102 -0
- package/src/hooks/typography.js +66 -88
- package/src/hooks/utils.js +90 -0
- package/src/layouts/flex.js +1 -0
- package/src/store/actions.js +12 -4
- package/src/store/defaults.js +14 -1
- package/src/store/reducer.js +68 -43
- package/src/store/selectors.js +8 -1
- package/src/store/test/actions.js +4 -2
- package/src/utils/parse-css-unit-to-px.js +35 -5
- package/src/utils/test/parse-css-unit-to-px.js +12 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/child-layout.js +0 -213
- package/build/hooks/child-layout.js.map +0 -1
- package/build/hooks/min-height.js +0 -139
- package/build/hooks/min-height.js.map +0 -1
- package/build-module/hooks/child-layout.js +0 -193
- package/build-module/hooks/child-layout.js.map +0 -1
- package/build-module/hooks/min-height.js +0 -116
- package/build-module/hooks/min-height.js.map +0 -1
- package/src/hooks/child-layout.js +0 -195
- package/src/hooks/min-height.js +0 -104
package/src/store/reducer.js
CHANGED
|
@@ -1416,9 +1416,19 @@ export function selection( state = {}, action ) {
|
|
|
1416
1416
|
}
|
|
1417
1417
|
}
|
|
1418
1418
|
|
|
1419
|
+
const selectionStart = selectionHelper( state.selectionStart, action );
|
|
1420
|
+
const selectionEnd = selectionHelper( state.selectionEnd, action );
|
|
1421
|
+
|
|
1422
|
+
if (
|
|
1423
|
+
selectionStart === state.selectionStart &&
|
|
1424
|
+
selectionEnd === state.selectionEnd
|
|
1425
|
+
) {
|
|
1426
|
+
return state;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1419
1429
|
return {
|
|
1420
|
-
selectionStart
|
|
1421
|
-
selectionEnd
|
|
1430
|
+
selectionStart,
|
|
1431
|
+
selectionEnd,
|
|
1422
1432
|
};
|
|
1423
1433
|
}
|
|
1424
1434
|
|
|
@@ -1750,45 +1760,6 @@ export function lastBlockAttributesChange( state = null, action ) {
|
|
|
1750
1760
|
return state;
|
|
1751
1761
|
}
|
|
1752
1762
|
|
|
1753
|
-
/**
|
|
1754
|
-
* Reducer returning automatic change state.
|
|
1755
|
-
*
|
|
1756
|
-
* @param {?string} state Current state.
|
|
1757
|
-
* @param {Object} action Dispatched action.
|
|
1758
|
-
*
|
|
1759
|
-
* @return {string | undefined} Updated state.
|
|
1760
|
-
*/
|
|
1761
|
-
export function automaticChangeStatus( state, action ) {
|
|
1762
|
-
switch ( action.type ) {
|
|
1763
|
-
case 'MARK_AUTOMATIC_CHANGE':
|
|
1764
|
-
return 'pending';
|
|
1765
|
-
case 'MARK_AUTOMATIC_CHANGE_FINAL':
|
|
1766
|
-
if ( state === 'pending' ) {
|
|
1767
|
-
return 'final';
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
return;
|
|
1771
|
-
case 'SELECTION_CHANGE':
|
|
1772
|
-
// As long as the state is not final, ignore any selection changes.
|
|
1773
|
-
if ( state !== 'final' ) {
|
|
1774
|
-
return state;
|
|
1775
|
-
}
|
|
1776
|
-
|
|
1777
|
-
return;
|
|
1778
|
-
// Undoing an automatic change should still be possible after mouse
|
|
1779
|
-
// move or after visibility change.
|
|
1780
|
-
case 'SET_BLOCK_VISIBILITY':
|
|
1781
|
-
case 'START_TYPING':
|
|
1782
|
-
case 'STOP_TYPING':
|
|
1783
|
-
case 'UPDATE_BLOCK_LIST_SETTINGS':
|
|
1784
|
-
return state;
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1787
|
-
// TODO: This is a source of bug, as each time there's a change in timing,
|
|
1788
|
-
// or a new action is added, this could break.
|
|
1789
|
-
// Reset the state by default (for any action not handled).
|
|
1790
|
-
}
|
|
1791
|
-
|
|
1792
1763
|
/**
|
|
1793
1764
|
* Reducer returning current highlighted block.
|
|
1794
1765
|
*
|
|
@@ -1863,7 +1834,7 @@ export function temporarilyEditingAsBlocks( state = '', action ) {
|
|
|
1863
1834
|
return state;
|
|
1864
1835
|
}
|
|
1865
1836
|
|
|
1866
|
-
|
|
1837
|
+
const combinedReducers = combineReducers( {
|
|
1867
1838
|
blocks,
|
|
1868
1839
|
isTyping,
|
|
1869
1840
|
isBlockInterfaceHidden,
|
|
@@ -1881,9 +1852,63 @@ export default combineReducers( {
|
|
|
1881
1852
|
lastBlockAttributesChange,
|
|
1882
1853
|
editorMode,
|
|
1883
1854
|
hasBlockMovingClientId,
|
|
1884
|
-
automaticChangeStatus,
|
|
1885
1855
|
highlightedBlock,
|
|
1886
1856
|
lastBlockInserted,
|
|
1887
1857
|
temporarilyEditingAsBlocks,
|
|
1888
1858
|
blockVisibility,
|
|
1889
1859
|
} );
|
|
1860
|
+
|
|
1861
|
+
function withAutomaticChangeReset( reducer ) {
|
|
1862
|
+
return ( state, action ) => {
|
|
1863
|
+
const nextState = reducer( state, action );
|
|
1864
|
+
|
|
1865
|
+
if ( ! state ) {
|
|
1866
|
+
return nextState;
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
// Take over the last value without creating a new reference.
|
|
1870
|
+
nextState.automaticChangeStatus = state.automaticChangeStatus;
|
|
1871
|
+
|
|
1872
|
+
if ( action.type === 'MARK_AUTOMATIC_CHANGE' ) {
|
|
1873
|
+
return {
|
|
1874
|
+
...nextState,
|
|
1875
|
+
automaticChangeStatus: 'pending',
|
|
1876
|
+
};
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1879
|
+
if (
|
|
1880
|
+
action.type === 'MARK_AUTOMATIC_CHANGE_FINAL' &&
|
|
1881
|
+
state.automaticChangeStatus === 'pending'
|
|
1882
|
+
) {
|
|
1883
|
+
return {
|
|
1884
|
+
...nextState,
|
|
1885
|
+
automaticChangeStatus: 'final',
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
// If there's a change that doesn't affect blocks or selection, maintain
|
|
1890
|
+
// the current status.
|
|
1891
|
+
if (
|
|
1892
|
+
nextState.blocks === state.blocks &&
|
|
1893
|
+
nextState.selection === state.selection
|
|
1894
|
+
) {
|
|
1895
|
+
return nextState;
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
// As long as the state is not final, ignore any selection changes.
|
|
1899
|
+
if (
|
|
1900
|
+
nextState.automaticChangeStatus !== 'final' &&
|
|
1901
|
+
nextState.selection !== state.selection
|
|
1902
|
+
) {
|
|
1903
|
+
return nextState;
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
// Reset the status if blocks change or selection changes (when status is final).
|
|
1907
|
+
return {
|
|
1908
|
+
...nextState,
|
|
1909
|
+
automaticChangeStatus: undefined,
|
|
1910
|
+
};
|
|
1911
|
+
};
|
|
1912
|
+
}
|
|
1913
|
+
|
|
1914
|
+
export default withAutomaticChangeReset( combinedReducers );
|
package/src/store/selectors.js
CHANGED
|
@@ -510,6 +510,10 @@ export const getBlockParents = createSelector(
|
|
|
510
510
|
parents.push( current );
|
|
511
511
|
}
|
|
512
512
|
|
|
513
|
+
if ( ! parents.length ) {
|
|
514
|
+
return EMPTY_ARRAY;
|
|
515
|
+
}
|
|
516
|
+
|
|
513
517
|
return ascending ? parents : parents.reverse();
|
|
514
518
|
},
|
|
515
519
|
( state ) => [ state.blocks.parents ]
|
|
@@ -2757,7 +2761,10 @@ export const __unstableGetContentLockingParent = createSelector(
|
|
|
2757
2761
|
let result;
|
|
2758
2762
|
while ( state.blocks.parents.has( current ) ) {
|
|
2759
2763
|
current = state.blocks.parents.get( current );
|
|
2760
|
-
if (
|
|
2764
|
+
if (
|
|
2765
|
+
current &&
|
|
2766
|
+
getTemplateLock( state, current ) === 'contentOnly'
|
|
2767
|
+
) {
|
|
2761
2768
|
result = current;
|
|
2762
2769
|
}
|
|
2763
2770
|
}
|
|
@@ -625,7 +625,8 @@ describe( 'actions', () => {
|
|
|
625
625
|
removeBlocks( clientIds )( { select, dispatch } );
|
|
626
626
|
|
|
627
627
|
expect( dispatch.selectPreviousBlock ).toHaveBeenCalledWith(
|
|
628
|
-
clientId
|
|
628
|
+
clientId,
|
|
629
|
+
true
|
|
629
630
|
);
|
|
630
631
|
|
|
631
632
|
expect( dispatch ).toHaveBeenCalledWith( {
|
|
@@ -734,7 +735,8 @@ describe( 'actions', () => {
|
|
|
734
735
|
removeBlock( clientId )( { select, dispatch } );
|
|
735
736
|
|
|
736
737
|
expect( dispatch.selectPreviousBlock ).toHaveBeenCalledWith(
|
|
737
|
-
clientId
|
|
738
|
+
clientId,
|
|
739
|
+
true
|
|
738
740
|
);
|
|
739
741
|
|
|
740
742
|
expect( dispatch ).toHaveBeenCalledWith( {
|
|
@@ -24,7 +24,11 @@ function parseUnit( cssUnit ) {
|
|
|
24
24
|
* @return {number} evaluated expression.
|
|
25
25
|
*/
|
|
26
26
|
function calculate( expression ) {
|
|
27
|
-
|
|
27
|
+
try {
|
|
28
|
+
return Function( `'use strict'; return (${ expression })` )();
|
|
29
|
+
} catch ( err ) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
/**
|
|
@@ -117,9 +121,9 @@ function isMathExpression( cssUnit ) {
|
|
|
117
121
|
function evalMathExpression( cssUnit ) {
|
|
118
122
|
let errorFound = false;
|
|
119
123
|
// Convert every part of the expression to px values.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
124
|
+
// The following regex matches numbers that have a following unit
|
|
125
|
+
// E.g. 5.25rem, 1vw
|
|
126
|
+
const cssUnitsBits = cssUnit.match( /\d+\.?\d*[a-zA-Z]+|\.\d+[a-zA-Z]+/g );
|
|
123
127
|
for ( const unit of cssUnitsBits ) {
|
|
124
128
|
// Standardize the unit to px and extract the value.
|
|
125
129
|
const parsedUnit = parseUnit( getPxFromCssUnit( unit ) );
|
|
@@ -131,7 +135,33 @@ function evalMathExpression( cssUnit ) {
|
|
|
131
135
|
cssUnit = cssUnit.replace( unit, parsedUnit.value );
|
|
132
136
|
}
|
|
133
137
|
|
|
134
|
-
|
|
138
|
+
// For mixed math expressions wrapped within CSS expressions
|
|
139
|
+
if ( ! errorFound && cssUnit.match( /(max|min|clamp)/g ) ) {
|
|
140
|
+
const values = cssUnit.split( ',' );
|
|
141
|
+
for ( const currentValue of values ) {
|
|
142
|
+
// Check for nested calc() and remove them to calculate the value.
|
|
143
|
+
const rawCurrentValue = currentValue.replace( /\s|calc/g, '' );
|
|
144
|
+
|
|
145
|
+
if ( isMathExpression( rawCurrentValue ) ) {
|
|
146
|
+
const calculatedExpression = calculate( rawCurrentValue );
|
|
147
|
+
|
|
148
|
+
if ( calculatedExpression ) {
|
|
149
|
+
const calculatedValue =
|
|
150
|
+
calculatedExpression.toFixed( 0 ) + 'px';
|
|
151
|
+
cssUnit = cssUnit.replace( currentValue, calculatedValue );
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const parsedValue = parseUnitFunction( cssUnit );
|
|
156
|
+
return ! parsedValue ? null : parsedValue.value + parsedValue.unit;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if ( errorFound ) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const calculatedResult = calculate( cssUnit );
|
|
164
|
+
return calculatedResult ? calculatedResult.toFixed( 0 ) + 'px' : null;
|
|
135
165
|
}
|
|
136
166
|
|
|
137
167
|
/**
|
|
@@ -116,6 +116,18 @@ describe( 'getPxFromCssUnit', () => {
|
|
|
116
116
|
[ 'console.log("howdy"); + 10px', null ],
|
|
117
117
|
[ 'calc(12vw * 10px', null ], // Missing closing bracket.
|
|
118
118
|
[ 'calc( 1em + 0.875rem )', '30px' ], // Decimals
|
|
119
|
+
[
|
|
120
|
+
'clamp(1.8rem, 1.8rem + ((1vw / 0.48rem + 1rem) * 2.885), 3rem)',
|
|
121
|
+
'48px',
|
|
122
|
+
],
|
|
123
|
+
[
|
|
124
|
+
'clamp(5rem, 5.25rem + ((1vw - 0.48rem) * 9.096), 8rem)',
|
|
125
|
+
'80px',
|
|
126
|
+
],
|
|
127
|
+
[
|
|
128
|
+
'clamp(2.625rem, calc(2.625rem + ((1vw - 0.48rem) * 8.4135)), 3.25rem)',
|
|
129
|
+
'42px',
|
|
130
|
+
],
|
|
119
131
|
];
|
|
120
132
|
|
|
121
133
|
test.each( testData )( 'getPxFromCssUnit( %s )', ( unit, expected ) => {
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../element/node_modules/@types/react/global.d.ts","../../node_modules/csstype/index.d.ts","../../node_modules/@types/prop-types/index.d.ts","../../node_modules/@types/scheduler/tracing.d.ts","../element/node_modules/@types/react/index.d.ts","../element/build-types/react.d.ts","../element/build-types/create-interpolate-element.d.ts","../../node_modules/@types/react/index.d.ts","../../node_modules/@types/react-dom/index.d.ts","../../node_modules/@types/react-dom/client.d.ts","../element/build-types/react-platform.d.ts","../element/build-types/utils.d.ts","../element/build-types/platform.d.ts","../element/build-types/serialize.d.ts","../element/build-types/raw-html.d.ts","../element/build-types/index.d.ts","./src/components/block-context/index.js","./src/utils/dom.js","../../node_modules/@types/react/global.d.ts"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},{"version":"bbdf156fea2fabed31a569445835aeedcc33643d404fcbaa54541f06c109df3f","affectsGlobalScope":true},"381899b8d1d4c1be716f18cb5242ba39f66f4b1e31d45af62a32a99f8edcb39d","f7b46d22a307739c145e5fddf537818038fdfffd580d79ed717f4d4d37249380","f5a8b384f182b3851cec3596ccc96cb7464f8d3469f48c74bf2befb782a19de5",{"version":"5917af4ff931b050dba49a1dedd9c00f15f7b3dc4345ad8491bfacd2ec68ed32","affectsGlobalScope":true},"6fb72c65c5af8c4ed7d41afecd1ebb463d1e074291ae5e8a187d0922fd40f59b","e47b8ec56eb49bc1c53c9012daa9874de14ad0c5da442485aec333571c74b526",{"version":"5917af4ff931b050dba49a1dedd9c00f15f7b3dc4345ad8491bfacd2ec68ed32","affectsGlobalScope":true},"e4dd91dd4789a109aab51d8a0569a282369fcda9ba6f2b2297bc61bacfb1a042","83e27bbd7304ea67f9afa1535f1d4fdb15866089f0d893c784cbb5b1c6fb3386","
|
|
1
|
+
{"program":{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.es2020.d.ts","../../node_modules/typescript/lib/lib.es2021.d.ts","../../node_modules/typescript/lib/lib.esnext.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../node_modules/typescript/lib/lib.es2021.promise.d.ts","../../node_modules/typescript/lib/lib.es2021.string.d.ts","../../node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../node_modules/typescript/lib/lib.esnext.intl.d.ts","../element/node_modules/@types/react/global.d.ts","../../node_modules/csstype/index.d.ts","../../node_modules/@types/prop-types/index.d.ts","../../node_modules/@types/scheduler/tracing.d.ts","../element/node_modules/@types/react/index.d.ts","../element/build-types/react.d.ts","../element/build-types/create-interpolate-element.d.ts","../../node_modules/@types/react/index.d.ts","../../node_modules/@types/react-dom/index.d.ts","../../node_modules/@types/react-dom/client.d.ts","../element/build-types/react-platform.d.ts","../element/build-types/utils.d.ts","../element/build-types/platform.d.ts","../element/build-types/serialize.d.ts","../element/build-types/raw-html.d.ts","../element/build-types/index.d.ts","./src/components/block-context/index.js","./src/utils/dom.js","../../node_modules/@types/react/global.d.ts"],"fileInfos":[{"version":"aa9fb4c70f369237c2f45f9d969c9a59e0eae9a192962eb48581fe864aa609db","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84","e21c071ca3e1b4a815d5f04a7475adcaeea5d64367e840dd0154096d705c3940","eb75e89d63b3b72dd9ca8b0cac801cecae5be352307c004adeaa60bc9d6df51f","2cc028cd0bdb35b1b5eb723d84666a255933fffbea607f72cbd0c7c7b4bee144",{"version":"e54c8715a4954cfdc66cd69489f2b725c09ebf37492dbd91cff0a1688b1159e8","affectsGlobalScope":true},{"version":"51b8b27c21c066bf877646e320bf6a722b80d1ade65e686923cd9d4494aef1ca","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"2c8c5ee58f30e7c944e04ab1fb5506fdbb4dd507c9efa6972cf4b91cec90c503","affectsGlobalScope":true},{"version":"2bb4b3927299434052b37851a47bf5c39764f2ba88a888a107b32262e9292b7c","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"62d80405c46c3f4c527ee657ae9d43fda65a0bf582292429aea1e69144a522a6","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"df9c8a72ca8b0ed62f5470b41208a0587f0f73f0a7db28e5a1272cf92537518e","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"93544ca2f26a48716c1b6c5091842cad63129daac422dfa4bc52460465f22bb1","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"1b3fe904465430e030c93239a348f05e1be80640d91f2f004c3512c2c2c89f34","affectsGlobalScope":true},{"version":"7435b75fdf3509622e79622dbe5091cf4b09688410ee2034e4fc17d0c99d0862","affectsGlobalScope":true},{"version":"e7e8e1d368290e9295ef18ca23f405cf40d5456fa9f20db6373a61ca45f75f40","affectsGlobalScope":true},{"version":"faf0221ae0465363c842ce6aa8a0cbda5d9296940a8e26c86e04cc4081eea21e","affectsGlobalScope":true},{"version":"06393d13ea207a1bfe08ec8d7be562549c5e2da8983f2ee074e00002629d1871","affectsGlobalScope":true},{"version":"9f1817f7c3f02f6d56e0f403b927e90bb133f371dcebc36fa7d6d208ef6899da","affectsGlobalScope":true},{"version":"cd6efb9467a8b6338ece2e2855e37765700f2cd061ca54b01b33878cf5c7677e","affectsGlobalScope":true},{"version":"fb4416144c1bf0323ccbc9afb0ab289c07312214e8820ad17d709498c865a3fe","affectsGlobalScope":true},{"version":"5b0ca94ec819d68d33da516306c15297acec88efeb0ae9e2b39f71dbd9685ef7","affectsGlobalScope":true},{"version":"4632665b87204bb1caa8b44d165bce0c50dfab177df5b561b345a567cabacf9a","affectsGlobalScope":true},{"version":"bbdf156fea2fabed31a569445835aeedcc33643d404fcbaa54541f06c109df3f","affectsGlobalScope":true},"381899b8d1d4c1be716f18cb5242ba39f66f4b1e31d45af62a32a99f8edcb39d","f7b46d22a307739c145e5fddf537818038fdfffd580d79ed717f4d4d37249380","f5a8b384f182b3851cec3596ccc96cb7464f8d3469f48c74bf2befb782a19de5",{"version":"5917af4ff931b050dba49a1dedd9c00f15f7b3dc4345ad8491bfacd2ec68ed32","affectsGlobalScope":true},"6fb72c65c5af8c4ed7d41afecd1ebb463d1e074291ae5e8a187d0922fd40f59b","e47b8ec56eb49bc1c53c9012daa9874de14ad0c5da442485aec333571c74b526",{"version":"5917af4ff931b050dba49a1dedd9c00f15f7b3dc4345ad8491bfacd2ec68ed32","affectsGlobalScope":true},"e4dd91dd4789a109aab51d8a0569a282369fcda9ba6f2b2297bc61bacfb1a042","83e27bbd7304ea67f9afa1535f1d4fdb15866089f0d893c784cbb5b1c6fb3386","c4b39848e2fb237507a7acae0b83a34271c9d72714faae6a6b9075527205111b","d2d9e98a2b167079474768593e1e7125fc3db055add8fbdb5977e3d05a8a3696","6462da67490105ba7d98cf312c2faf8794c425781128b161ea8394d66502eec8","62359da52b6c8d00c50c2e50738fac82e902f916fdf458d8159e7edb1c60c3a8","1e0ac21bc775686383ea8c8e48bd98b385e6195b25c85525a7affd08a2cd38b9","0449615e1ed03c7d54fc435a63b7ef0cb4e5cea5ac40c9a63280a46f7eeae0ff","0a41b61ddcb640fa2a07cb7a04ecddf540b8199f70d3cf5f2d8903be722529eb","4e8c59b6c243b9148b72d7428c71592176a520225ee91b718f4a655a5baf6624"],"options":{"allowSyntheticDefaultImports":true,"composite":true,"declaration":true,"declarationDir":"./build-types","declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":false,"importsNotUsedAsValues":2,"jsx":1,"module":99,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"rootDir":"./src","strict":true,"target":99},"fileIdsList":[[49],[46,47,48,63],[49,60],[50],[50,51,55,56,57,58,59],[53,54],[49,50],[45,46,47,48]],"referencedMap":[[54,1],[53,1],[52,2],[61,3],[51,4],[60,5],[59,1],[55,6],[50,1],[58,7],[49,8]],"exportedModulesMap":[[54,1],[53,1],[52,2],[61,3],[51,4],[60,5],[59,1],[55,6],[50,1],[58,7],[49,8]],"semanticDiagnosticsPerFile":[47,54,53,52,48,46,10,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,32,33,34,35,7,40,36,37,38,39,8,41,42,43,1,9,44,61,62,51,60,57,59,55,50,58,56,45,49]},"version":"4.4.2"}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.ChildLayoutEdit = ChildLayoutEdit;
|
|
9
|
-
exports.childLayoutOrientation = childLayoutOrientation;
|
|
10
|
-
exports.hasChildLayoutSupport = hasChildLayoutSupport;
|
|
11
|
-
exports.hasChildLayoutValue = hasChildLayoutValue;
|
|
12
|
-
exports.resetChildLayout = resetChildLayout;
|
|
13
|
-
exports.useIsChildLayoutDisabled = useIsChildLayoutDisabled;
|
|
14
|
-
|
|
15
|
-
var _element = require("@wordpress/element");
|
|
16
|
-
|
|
17
|
-
var _components = require("@wordpress/components");
|
|
18
|
-
|
|
19
|
-
var _i18n = require("@wordpress/i18n");
|
|
20
|
-
|
|
21
|
-
var _useSetting = _interopRequireDefault(require("../components/use-setting"));
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* WordPress dependencies
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Internal dependencies
|
|
29
|
-
*/
|
|
30
|
-
function helpText(selfStretch, parentLayout) {
|
|
31
|
-
const {
|
|
32
|
-
orientation = 'horizontal'
|
|
33
|
-
} = parentLayout;
|
|
34
|
-
|
|
35
|
-
if (selfStretch === 'fill') {
|
|
36
|
-
return (0, _i18n.__)('Stretch to fill available space.');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (selfStretch === 'fixed') {
|
|
40
|
-
if (orientation === 'horizontal') {
|
|
41
|
-
return (0, _i18n.__)('Specify a fixed width.');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return (0, _i18n.__)('Specify a fixed height.');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return (0, _i18n.__)('Fit contents.');
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Inspector controls containing the child layout related configuration.
|
|
51
|
-
*
|
|
52
|
-
* @param {Object} props Block props.
|
|
53
|
-
* @param {Object} props.attributes Block attributes.
|
|
54
|
-
* @param {Object} props.setAttributes Function to set block attributes.
|
|
55
|
-
* @param {Object} props.__unstableParentLayout
|
|
56
|
-
*
|
|
57
|
-
* @return {WPElement} child layout edit element.
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
function ChildLayoutEdit(_ref) {
|
|
62
|
-
let {
|
|
63
|
-
attributes,
|
|
64
|
-
setAttributes,
|
|
65
|
-
__unstableParentLayout: parentLayout
|
|
66
|
-
} = _ref;
|
|
67
|
-
const {
|
|
68
|
-
style = {}
|
|
69
|
-
} = attributes;
|
|
70
|
-
const {
|
|
71
|
-
layout: childLayout = {}
|
|
72
|
-
} = style;
|
|
73
|
-
const {
|
|
74
|
-
selfStretch,
|
|
75
|
-
flexSize
|
|
76
|
-
} = childLayout;
|
|
77
|
-
(0, _element.useEffect)(() => {
|
|
78
|
-
if (selfStretch === 'fixed' && !flexSize) {
|
|
79
|
-
setAttributes({
|
|
80
|
-
style: { ...style,
|
|
81
|
-
layout: { ...childLayout,
|
|
82
|
-
selfStretch: 'fit'
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}, []);
|
|
88
|
-
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.__experimentalToggleGroupControl, {
|
|
89
|
-
__nextHasNoMarginBottom: true,
|
|
90
|
-
size: '__unstable-large',
|
|
91
|
-
label: childLayoutOrientation(parentLayout),
|
|
92
|
-
value: selfStretch || 'fit',
|
|
93
|
-
help: helpText(selfStretch, parentLayout),
|
|
94
|
-
onChange: value => {
|
|
95
|
-
const newFlexSize = value !== 'fixed' ? null : flexSize;
|
|
96
|
-
setAttributes({
|
|
97
|
-
style: { ...style,
|
|
98
|
-
layout: { ...childLayout,
|
|
99
|
-
selfStretch: value,
|
|
100
|
-
flexSize: newFlexSize
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
|
-
isBlock: true
|
|
106
|
-
}, (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
|
|
107
|
-
key: 'fit',
|
|
108
|
-
value: 'fit',
|
|
109
|
-
label: (0, _i18n.__)('Fit')
|
|
110
|
-
}), (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
|
|
111
|
-
key: 'fill',
|
|
112
|
-
value: 'fill',
|
|
113
|
-
label: (0, _i18n.__)('Fill')
|
|
114
|
-
}), (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
|
|
115
|
-
key: 'fixed',
|
|
116
|
-
value: 'fixed',
|
|
117
|
-
label: (0, _i18n.__)('Fixed')
|
|
118
|
-
})), selfStretch === 'fixed' && (0, _element.createElement)(_components.__experimentalUnitControl, {
|
|
119
|
-
size: '__unstable-large',
|
|
120
|
-
onChange: value => {
|
|
121
|
-
setAttributes({
|
|
122
|
-
style: { ...style,
|
|
123
|
-
layout: { ...childLayout,
|
|
124
|
-
flexSize: value
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
},
|
|
129
|
-
value: flexSize
|
|
130
|
-
}));
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Determines if there is child layout support.
|
|
134
|
-
*
|
|
135
|
-
* @param {Object} props Block Props object.
|
|
136
|
-
* @param {Object} props.__unstableParentLayout Parent layout.
|
|
137
|
-
*
|
|
138
|
-
* @return {boolean} Whether there is support.
|
|
139
|
-
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
function hasChildLayoutSupport(_ref2) {
|
|
143
|
-
let {
|
|
144
|
-
__unstableParentLayout: parentLayout = {}
|
|
145
|
-
} = _ref2;
|
|
146
|
-
const {
|
|
147
|
-
type: parentLayoutType = 'default',
|
|
148
|
-
default: {
|
|
149
|
-
type: defaultParentLayoutType = 'default'
|
|
150
|
-
} = {},
|
|
151
|
-
allowSizingOnChildren = false
|
|
152
|
-
} = parentLayout;
|
|
153
|
-
const support = (defaultParentLayoutType === 'flex' || parentLayoutType === 'flex') && allowSizingOnChildren;
|
|
154
|
-
return support;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Checks if there is a current value in the child layout attributes.
|
|
158
|
-
*
|
|
159
|
-
* @param {Object} props Block props.
|
|
160
|
-
* @return {boolean} Whether or not the block has a child layout value set.
|
|
161
|
-
*/
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
function hasChildLayoutValue(props) {
|
|
165
|
-
var _props$attributes$sty;
|
|
166
|
-
|
|
167
|
-
return ((_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.layout) !== undefined;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Resets the child layout attribute. This can be used when disabling
|
|
171
|
-
* child layout controls for a block via a progressive discovery panel.
|
|
172
|
-
*
|
|
173
|
-
* @param {Object} props Block props.
|
|
174
|
-
* @param {Object} props.attributes Block attributes.
|
|
175
|
-
* @param {Object} props.setAttributes Function to set block attributes.
|
|
176
|
-
*/
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
function resetChildLayout(_ref3) {
|
|
180
|
-
let {
|
|
181
|
-
attributes = {},
|
|
182
|
-
setAttributes
|
|
183
|
-
} = _ref3;
|
|
184
|
-
const {
|
|
185
|
-
style
|
|
186
|
-
} = attributes;
|
|
187
|
-
setAttributes({
|
|
188
|
-
style: { ...style,
|
|
189
|
-
layout: undefined
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Custom hook that checks if child layout settings have been disabled.
|
|
195
|
-
*
|
|
196
|
-
* @param {Object} props Block props.
|
|
197
|
-
*
|
|
198
|
-
* @return {boolean} Whether the child layout setting is disabled.
|
|
199
|
-
*/
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
function useIsChildLayoutDisabled(props) {
|
|
203
|
-
const isDisabled = !(0, _useSetting.default)('layout');
|
|
204
|
-
return !hasChildLayoutSupport(props) || isDisabled;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function childLayoutOrientation(parentLayout) {
|
|
208
|
-
const {
|
|
209
|
-
orientation = 'horizontal'
|
|
210
|
-
} = parentLayout;
|
|
211
|
-
return orientation === 'horizontal' ? (0, _i18n.__)('Width') : (0, _i18n.__)('Height');
|
|
212
|
-
}
|
|
213
|
-
//# sourceMappingURL=child-layout.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/hooks/child-layout.js"],"names":["helpText","selfStretch","parentLayout","orientation","ChildLayoutEdit","attributes","setAttributes","__unstableParentLayout","style","layout","childLayout","flexSize","childLayoutOrientation","value","newFlexSize","hasChildLayoutSupport","type","parentLayoutType","default","defaultParentLayoutType","allowSizingOnChildren","support","hasChildLayoutValue","props","undefined","resetChildLayout","useIsChildLayoutDisabled","isDisabled"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useSetting from '../components/use-setting';\n\nfunction helpText( selfStretch, parentLayout ) {\n\tconst { orientation = 'horizontal' } = parentLayout;\n\n\tif ( selfStretch === 'fill' ) {\n\t\treturn __( 'Stretch to fill available space.' );\n\t}\n\tif ( selfStretch === 'fixed' ) {\n\t\tif ( orientation === 'horizontal' ) {\n\t\t\treturn __( 'Specify a fixed width.' );\n\t\t}\n\t\treturn __( 'Specify a fixed height.' );\n\t}\n\treturn __( 'Fit contents.' );\n}\n\n/**\n * Inspector controls containing the child layout related configuration.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block attributes.\n * @param {Object} props.setAttributes Function to set block attributes.\n * @param {Object} props.__unstableParentLayout\n *\n * @return {WPElement} child layout edit element.\n */\nexport function ChildLayoutEdit( {\n\tattributes,\n\tsetAttributes,\n\t__unstableParentLayout: parentLayout,\n} ) {\n\tconst { style = {} } = attributes;\n\tconst { layout: childLayout = {} } = style;\n\tconst { selfStretch, flexSize } = childLayout;\n\n\tuseEffect( () => {\n\t\tif ( selfStretch === 'fixed' && ! flexSize ) {\n\t\t\tsetAttributes( {\n\t\t\t\tstyle: {\n\t\t\t\t\t...style,\n\t\t\t\t\tlayout: {\n\t\t\t\t\t\t...childLayout,\n\t\t\t\t\t\tselfStretch: 'fit',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t<ToggleGroupControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\tlabel={ childLayoutOrientation( parentLayout ) }\n\t\t\t\tvalue={ selfStretch || 'fit' }\n\t\t\t\thelp={ helpText( selfStretch, parentLayout ) }\n\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\tconst newFlexSize = value !== 'fixed' ? null : flexSize;\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t...childLayout,\n\t\t\t\t\t\t\t\tselfStretch: value,\n\t\t\t\t\t\t\t\tflexSize: newFlexSize,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tisBlock={ true }\n\t\t\t>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'fit' }\n\t\t\t\t\tvalue={ 'fit' }\n\t\t\t\t\tlabel={ __( 'Fit' ) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'fill' }\n\t\t\t\t\tvalue={ 'fill' }\n\t\t\t\t\tlabel={ __( 'Fill' ) }\n\t\t\t\t/>\n\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\tkey={ 'fixed' }\n\t\t\t\t\tvalue={ 'fixed' }\n\t\t\t\t\tlabel={ __( 'Fixed' ) }\n\t\t\t\t/>\n\t\t\t</ToggleGroupControl>\n\t\t\t{ selfStretch === 'fixed' && (\n\t\t\t\t<UnitControl\n\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t\t...style,\n\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t...childLayout,\n\t\t\t\t\t\t\t\t\tflexSize: value,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ flexSize }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\n/**\n * Determines if there is child layout support.\n *\n * @param {Object} props Block Props object.\n * @param {Object} props.__unstableParentLayout Parent layout.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasChildLayoutSupport( {\n\t__unstableParentLayout: parentLayout = {},\n} ) {\n\tconst {\n\t\ttype: parentLayoutType = 'default',\n\t\tdefault: { type: defaultParentLayoutType = 'default' } = {},\n\t\tallowSizingOnChildren = false,\n\t} = parentLayout;\n\n\tconst support =\n\t\t( defaultParentLayoutType === 'flex' || parentLayoutType === 'flex' ) &&\n\t\tallowSizingOnChildren;\n\n\treturn support;\n}\n\n/**\n * Checks if there is a current value in the child layout attributes.\n *\n * @param {Object} props Block props.\n * @return {boolean} Whether or not the block has a child layout value set.\n */\nexport function hasChildLayoutValue( props ) {\n\treturn props.attributes.style?.layout !== undefined;\n}\n\n/**\n * Resets the child layout attribute. This can be used when disabling\n * child layout controls for a block via a progressive discovery panel.\n *\n * @param {Object} props Block props.\n * @param {Object} props.attributes Block attributes.\n * @param {Object} props.setAttributes Function to set block attributes.\n */\nexport function resetChildLayout( { attributes = {}, setAttributes } ) {\n\tconst { style } = attributes;\n\n\tsetAttributes( {\n\t\tstyle: {\n\t\t\t...style,\n\t\t\tlayout: undefined,\n\t\t},\n\t} );\n}\n\n/**\n * Custom hook that checks if child layout settings have been disabled.\n *\n * @param {Object} props Block props.\n *\n * @return {boolean} Whether the child layout setting is disabled.\n */\nexport function useIsChildLayoutDisabled( props ) {\n\tconst isDisabled = ! useSetting( 'layout' );\n\n\treturn ! hasChildLayoutSupport( props ) || isDisabled;\n}\n\nexport function childLayoutOrientation( parentLayout ) {\n\tconst { orientation = 'horizontal' } = parentLayout;\n\n\treturn orientation === 'horizontal' ? __( 'Width' ) : __( 'Height' );\n}\n"]}
|