@wordpress/block-editor 12.17.0 → 12.18.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 +4 -0
- package/README.md +32 -0
- package/build/components/block-draggable/index.js +11 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-edit/context.js +3 -1
- package/build/components/block-edit/context.js.map +1 -1
- package/build/components/block-edit/index.js +4 -2
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-editing-mode/index.js +6 -3
- package/build/components/block-editing-mode/index.js.map +1 -1
- package/build/components/block-inspector/index.js +5 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.js +4 -3
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +9 -5
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +30 -4
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/private-block-context.js +1 -1
- package/build/components/block-list/private-block-context.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +1 -1
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/toolbar.js +8 -2
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-popover/inbetween.js +15 -3
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-preview/auto.js +1 -1
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-removal-warning-modal/index.js +3 -2
- package/build/components/block-removal-warning-modal/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +2 -4
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-switcher/block-transformations-menu.js +12 -1
- package/build/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build/components/block-switcher/index.js +119 -90
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +10 -3
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +7 -1
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +5 -14
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/effects-panel.js +7 -1
- package/build/components/global-styles/effects-panel.js.map +1 -1
- package/build/components/global-styles/hooks.js +3 -2
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/typography-panel.js +31 -14
- package/build/components/global-styles/typography-panel.js.map +1 -1
- package/build/components/iframe/get-compatibility-styles.js +99 -0
- package/build/components/iframe/get-compatibility-styles.js.map +1 -0
- package/build/components/iframe/index.js +2 -3
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +16 -2
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +16 -2
- package/build/components/index.native.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +3 -0
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/link-control/link-preview.js +30 -26
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -9
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block-contents.js +3 -1
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block.js +10 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +29 -8
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +100 -32
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +52 -4
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +2 -2
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/list-view/use-list-view-block-indexes.js +30 -0
- package/build/components/list-view/use-list-view-block-indexes.js.map +1 -0
- package/build/components/list-view/use-list-view-drop-zone.js +56 -5
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/list-view/utils.js +92 -0
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/provider/index.js +1 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/recursion-provider/index.js +21 -0
- package/build/components/recursion-provider/index.js.map +1 -1
- package/build/components/rich-text/index.js +30 -6
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +9 -9
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/use-block-drop-zone/index.js +30 -7
- package/build/components/use-block-drop-zone/index.js.map +1 -1
- package/build/components/use-on-block-drop/index.js +50 -8
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/hooks/block-hooks.js +5 -14
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/content-lock-ui.js +17 -42
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/effects.js +66 -0
- package/build/hooks/effects.js.map +1 -0
- package/build/hooks/index.js +15 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/index.native.js +13 -0
- package/build/hooks/index.native.js.map +1 -1
- package/build/hooks/style.js +6 -2
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/supports.js +2 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.native.js +2 -2
- package/build/hooks/typography.native.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +115 -0
- package/build/hooks/use-bindings-attributes.js.map +1 -0
- package/build/hooks/use-shadow-props.js +46 -0
- package/build/hooks/use-shadow-props.js.map +1 -0
- package/build/hooks/utils.js +11 -7
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +14 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +10 -6
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +2 -0
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +37 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +60 -9
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +44 -3
- package/build/store/reducer.js.map +1 -1
- package/build/store/resolvers.js +27 -0
- package/build/store/resolvers.js.map +1 -0
- package/build/store/selectors.js +94 -56
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +5 -26
- package/build/store/utils.js.map +1 -1
- package/build/utils/index.js +0 -16
- package/build/utils/index.js.map +1 -1
- package/build/utils/math.js +13 -0
- package/build/utils/math.js.map +1 -1
- package/build/utils/object.js +17 -0
- package/build/utils/object.js.map +1 -1
- package/build/utils/transform-styles/index.js +37 -27
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +11 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-edit/context.js +1 -0
- package/build-module/components/block-edit/context.js.map +1 -1
- package/build-module/components/block-edit/index.js +5 -3
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-editing-mode/index.js +7 -4
- package/build-module/components/block-editing-mode/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +5 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.js +6 -5
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +11 -7
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +31 -5
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/private-block-context.js +1 -1
- package/build-module/components/block-list/private-block-context.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +8 -2
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +15 -3
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-preview/auto.js +3 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-removal-warning-modal/index.js +3 -2
- package/build-module/components/block-removal-warning-modal/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -4
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-switcher/block-transformations-menu.js +12 -1
- package/build-module/components/block-switcher/block-transformations-menu.js.map +1 -1
- package/build-module/components/block-switcher/index.js +116 -86
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +10 -3
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +7 -1
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +5 -14
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/effects-panel.js +7 -1
- package/build-module/components/global-styles/effects-panel.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +3 -2
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/typography-panel.js +32 -15
- package/build-module/components/global-styles/typography-panel.js.map +1 -1
- package/build-module/components/iframe/get-compatibility-styles.js +93 -0
- package/build-module/components/iframe/get-compatibility-styles.js.map +1 -0
- package/build-module/components/iframe/index.js +2 -3
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -1
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +3 -0
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +32 -28
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -8
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +3 -1
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block.js +10 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +30 -9
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +99 -32
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +54 -6
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +2 -2
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/list-view/use-list-view-block-indexes.js +23 -0
- package/build-module/components/list-view/use-list-view-block-indexes.js.map +1 -0
- package/build-module/components/list-view/use-list-view-drop-zone.js +58 -7
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/list-view/utils.js +91 -0
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/provider/index.js +1 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/recursion-provider/index.js +17 -0
- package/build-module/components/recursion-provider/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +30 -6
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +9 -9
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/use-block-drop-zone/index.js +31 -8
- package/build-module/components/use-block-drop-zone/index.js.map +1 -1
- package/build-module/components/use-on-block-drop/index.js +51 -9
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/hooks/block-hooks.js +5 -14
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +19 -43
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/effects.js +51 -0
- package/build-module/hooks/effects.js.map +1 -0
- package/build-module/hooks/index.js +3 -2
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/index.native.js +1 -0
- package/build-module/hooks/index.native.js.map +1 -1
- package/build-module/hooks/style.js +6 -2
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/supports.js +2 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.native.js +2 -2
- package/build-module/hooks/typography.native.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +112 -0
- package/build-module/hooks/use-bindings-attributes.js.map +1 -0
- package/build-module/hooks/use-shadow-props.js +39 -0
- package/build-module/hooks/use-shadow-props.js.map +1 -0
- package/build-module/hooks/utils.js +13 -9
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +10 -6
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +2 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +35 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +53 -8
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +43 -3
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/resolvers.js +20 -0
- package/build-module/store/resolvers.js.map +1 -0
- package/build-module/store/selectors.js +89 -52
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +3 -23
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/index.js +0 -1
- package/build-module/utils/index.js.map +1 -1
- package/build-module/utils/math.js +12 -0
- package/build-module/utils/math.js.map +1 -1
- package/build-module/utils/object.js +16 -0
- package/build-module/utils/object.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +36 -27
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +33 -16
- package/build-style/content.css +33 -16
- package/build-style/default-editor-styles-rtl.css +1 -1
- package/build-style/default-editor-styles.css +1 -1
- package/build-style/style-rtl.css +169 -114
- package/build-style/style.css +169 -114
- package/package.json +31 -31
- package/src/components/block-canvas/style.scss +8 -1
- package/src/components/block-draggable/index.js +16 -5
- package/src/components/block-edit/context.js +1 -0
- package/src/components/block-edit/index.js +4 -0
- package/src/components/block-editing-mode/index.js +12 -7
- package/src/components/block-inspector/index.js +5 -2
- package/src/components/block-list/block.js +5 -4
- package/src/components/block-list/block.native.js +13 -3
- package/src/components/block-list/content.scss +34 -5
- package/src/components/block-list/index.js +52 -16
- package/src/components/block-list/private-block-context.js +1 -1
- package/src/components/block-list/use-in-between-inserter.js +1 -2
- package/src/components/block-lock/toolbar.js +10 -2
- package/src/components/block-popover/inbetween.js +22 -2
- package/src/components/block-preview/auto.js +3 -3
- package/src/components/block-removal-warning-modal/index.js +3 -2
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -7
- package/src/components/block-switcher/block-transformations-menu.js +18 -1
- package/src/components/block-switcher/index.js +133 -111
- package/src/components/block-switcher/style.scss +6 -4
- package/src/components/block-switcher/test/index.js +113 -230
- package/src/components/block-toolbar/style.scss +22 -18
- package/src/components/block-tools/insertion-point.js +15 -2
- package/src/components/block-tools/style.scss +8 -7
- package/src/components/font-sizes/fluid-utils.js +8 -2
- package/src/components/font-sizes/test/fluid-utils.js +9 -0
- package/src/components/global-styles/border-panel.js +7 -17
- package/src/components/global-styles/effects-panel.js +16 -1
- package/src/components/global-styles/hooks.js +2 -0
- package/src/components/global-styles/typography-panel.js +45 -13
- package/src/components/iframe/get-compatibility-styles.js +120 -0
- package/src/components/iframe/index.js +2 -3
- package/src/components/index.js +4 -2
- package/src/components/index.native.js +4 -2
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +2 -0
- package/src/components/link-control/link-preview.js +31 -55
- package/src/components/link-control/search-input.js +1 -9
- package/src/components/link-control/style.scss +31 -85
- package/src/components/link-control/test/index.js +2 -1
- package/src/components/list-view/block-contents.js +5 -1
- package/src/components/list-view/block.js +9 -0
- package/src/components/list-view/branch.js +30 -10
- package/src/components/list-view/drop-indicator.js +139 -46
- package/src/components/list-view/index.js +74 -3
- package/src/components/list-view/leaf.js +2 -2
- package/src/components/list-view/style.scss +102 -13
- package/src/components/list-view/test/use-list-view-drop-zone.js +4 -0
- package/src/components/list-view/test/utils.js +218 -1
- package/src/components/list-view/use-list-view-block-indexes.js +29 -0
- package/src/components/list-view/use-list-view-drop-zone.js +78 -6
- package/src/components/list-view/utils.js +116 -0
- package/src/components/provider/index.js +3 -1
- package/src/components/recursion-provider/README.md +2 -2
- package/src/components/recursion-provider/index.js +17 -0
- package/src/components/rich-text/index.js +48 -10
- package/src/components/rich-text/native/index.native.js +10 -10
- package/src/components/use-block-drop-zone/index.js +60 -19
- package/src/components/use-block-drop-zone/test/index.js +32 -61
- package/src/components/use-on-block-drop/index.js +92 -11
- package/src/hooks/block-hooks.js +5 -17
- package/src/hooks/content-lock-ui.js +15 -55
- package/src/hooks/effects.js +57 -0
- package/src/hooks/index.js +2 -2
- package/src/hooks/index.native.js +1 -0
- package/src/hooks/style.js +8 -0
- package/src/hooks/supports.js +2 -0
- package/src/hooks/test/effects.js +39 -0
- package/src/hooks/typography.native.js +2 -2
- package/src/hooks/use-bindings-attributes.js +148 -0
- package/src/hooks/use-shadow-props.js +37 -0
- package/src/hooks/utils.js +26 -10
- package/src/index.js +2 -0
- package/src/store/actions.js +9 -4
- package/src/store/index.js +2 -0
- package/src/store/private-actions.js +32 -0
- package/src/store/private-selectors.js +78 -21
- package/src/store/reducer.js +49 -2
- package/src/store/resolvers.js +17 -0
- package/src/store/selectors.js +169 -161
- package/src/store/test/registry-selectors.js +431 -0
- package/src/store/test/selectors.js +14 -400
- package/src/store/utils.js +10 -33
- package/src/style.scss +0 -1
- package/src/utils/index.js +0 -1
- package/src/utils/math.js +12 -0
- package/src/utils/object.js +16 -0
- package/src/utils/transform-styles/index.js +52 -37
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/iframe/use-compatibility-styles.js +0 -100
- package/build/components/iframe/use-compatibility-styles.js.map +0 -1
- package/build/hooks/custom-fields.js +0 -106
- package/build/hooks/custom-fields.js.map +0 -1
- package/build/utils/block-variation-transforms.js +0 -42
- package/build/utils/block-variation-transforms.js.map +0 -1
- package/build-module/components/iframe/use-compatibility-styles.js +0 -94
- package/build-module/components/iframe/use-compatibility-styles.js.map +0 -1
- package/build-module/hooks/custom-fields.js +0 -99
- package/build-module/hooks/custom-fields.js.map +0 -1
- package/build-module/utils/block-variation-transforms.js +0 -35
- package/build-module/utils/block-variation-transforms.js.map +0 -1
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +0 -116
- package/src/components/contrast-checker/style.scss +0 -3
- package/src/components/iframe/use-compatibility-styles.js +0 -122
- package/src/hooks/custom-fields.js +0 -115
- package/src/utils/block-variation-transforms.js +0 -38
- package/src/utils/test/block-variation-transforms.js +0 -94
|
@@ -28,6 +28,7 @@ createBlockSaveFilter( [
|
|
|
28
28
|
] );
|
|
29
29
|
|
|
30
30
|
export { getBorderClassesAndStyles, useBorderProps } from './use-border-props';
|
|
31
|
+
export { getShadowClassesAndStyles, useShadowProps } from './use-shadow-props';
|
|
31
32
|
export { getColorClassesAndStyles, useColorProps } from './use-color-props';
|
|
32
33
|
export { getSpacingClassesAndStyles } from './use-spacing-props';
|
|
33
34
|
export { useCachedTruthy } from './use-cached-truthy';
|
package/src/hooks/style.js
CHANGED
|
@@ -27,6 +27,11 @@ import {
|
|
|
27
27
|
SPACING_SUPPORT_KEY,
|
|
28
28
|
DimensionsPanel,
|
|
29
29
|
} from './dimensions';
|
|
30
|
+
import {
|
|
31
|
+
EFFECTS_SUPPORT_KEYS,
|
|
32
|
+
SHADOW_SUPPORT_KEY,
|
|
33
|
+
EffectsPanel,
|
|
34
|
+
} from './effects';
|
|
30
35
|
import {
|
|
31
36
|
shouldSkipSerialization,
|
|
32
37
|
useStyleOverride,
|
|
@@ -37,6 +42,7 @@ import { useBlockEditingMode } from '../components/block-editing-mode';
|
|
|
37
42
|
|
|
38
43
|
const styleSupportKeys = [
|
|
39
44
|
...TYPOGRAPHY_SUPPORT_KEYS,
|
|
45
|
+
...EFFECTS_SUPPORT_KEYS,
|
|
40
46
|
BORDER_SUPPORT_KEY,
|
|
41
47
|
COLOR_SUPPORT_KEY,
|
|
42
48
|
DIMENSIONS_SUPPORT_KEY,
|
|
@@ -110,6 +116,7 @@ const skipSerializationPathsEdit = {
|
|
|
110
116
|
[ `${ SPACING_SUPPORT_KEY }.__experimentalSkipSerialization` ]: [
|
|
111
117
|
SPACING_SUPPORT_KEY,
|
|
112
118
|
],
|
|
119
|
+
[ `${ SHADOW_SUPPORT_KEY }` ]: [ SHADOW_SUPPORT_KEY ],
|
|
113
120
|
};
|
|
114
121
|
|
|
115
122
|
/**
|
|
@@ -336,6 +343,7 @@ function BlockStyleControls( {
|
|
|
336
343
|
<TypographyPanel { ...passedProps } />
|
|
337
344
|
<BorderPanel { ...passedProps } />
|
|
338
345
|
<DimensionsPanel { ...passedProps } />
|
|
346
|
+
<EffectsPanel { ...passedProps } />
|
|
339
347
|
</>
|
|
340
348
|
);
|
|
341
349
|
}
|
package/src/hooks/supports.js
CHANGED
|
@@ -59,8 +59,10 @@ const TYPOGRAPHY_SUPPORT_KEYS = [
|
|
|
59
59
|
WRITING_MODE_SUPPORT_KEY,
|
|
60
60
|
LETTER_SPACING_SUPPORT_KEY,
|
|
61
61
|
];
|
|
62
|
+
const EFFECTS_SUPPORT_KEYS = [ 'shadow' ];
|
|
62
63
|
const SPACING_SUPPORT_KEY = 'spacing';
|
|
63
64
|
const styleSupportKeys = [
|
|
65
|
+
...EFFECTS_SUPPORT_KEYS,
|
|
64
66
|
...TYPOGRAPHY_SUPPORT_KEYS,
|
|
65
67
|
BORDER_SUPPORT_KEY,
|
|
66
68
|
COLOR_SUPPORT_KEY,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { hasEffectsSupport } from '../effects';
|
|
5
|
+
|
|
6
|
+
describe( 'effects', () => {
|
|
7
|
+
describe( 'hasEffectsSupport', () => {
|
|
8
|
+
it( 'should return false if the block does not support effects', () => {
|
|
9
|
+
const settings = {
|
|
10
|
+
supports: {
|
|
11
|
+
shadow: false,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
expect( hasEffectsSupport( settings ) ).toBe( false );
|
|
16
|
+
} );
|
|
17
|
+
|
|
18
|
+
it( 'should return true if the block supports effects', () => {
|
|
19
|
+
const settings = {
|
|
20
|
+
supports: {
|
|
21
|
+
shadow: true,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
expect( hasEffectsSupport( settings ) ).toBe( true );
|
|
26
|
+
} );
|
|
27
|
+
|
|
28
|
+
it( 'should return true if the block supports effects and other features', () => {
|
|
29
|
+
const settings = {
|
|
30
|
+
supports: {
|
|
31
|
+
shadow: true,
|
|
32
|
+
align: true,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
expect( hasEffectsSupport( settings ) ).toBe( true );
|
|
37
|
+
} );
|
|
38
|
+
} );
|
|
39
|
+
} );
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
|
-
import {
|
|
5
|
+
import { memo } from '@wordpress/element';
|
|
6
6
|
import { PanelBody } from '@wordpress/components';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
|
|
@@ -57,4 +57,4 @@ function TypographyPanelPure( { clientId, setAttributes, settings } ) {
|
|
|
57
57
|
// We don't want block controls to re-render when typing inside a block. `pure`
|
|
58
58
|
// will prevent re-renders unless props change, so only pass the needed props
|
|
59
59
|
// and not the whole attributes object.
|
|
60
|
-
export const TypographyPanel =
|
|
60
|
+
export const TypographyPanel = memo( TypographyPanelPure );
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getBlockType } from '@wordpress/blocks';
|
|
5
|
+
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
6
|
+
import { useRegistry, useSelect } from '@wordpress/data';
|
|
7
|
+
import { addFilter } from '@wordpress/hooks';
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { store as blockEditorStore } from '../store';
|
|
12
|
+
import { useBlockEditContext } from '../components/block-edit/context';
|
|
13
|
+
import { unlock } from '../lock-unlock';
|
|
14
|
+
|
|
15
|
+
/** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */
|
|
16
|
+
/** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Given a binding of block attributes, returns a higher order component that
|
|
20
|
+
* overrides its `attributes` and `setAttributes` props to sync any changes needed.
|
|
21
|
+
*
|
|
22
|
+
* @return {WPHigherOrderComponent} Higher-order component.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const BLOCK_BINDINGS_ALLOWED_BLOCKS = {
|
|
26
|
+
'core/paragraph': [ 'content' ],
|
|
27
|
+
'core/heading': [ 'content' ],
|
|
28
|
+
'core/image': [ 'url', 'title', 'alt' ],
|
|
29
|
+
'core/button': [ 'url', 'text', 'linkTarget' ],
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const createEditFunctionWithBindingsAttribute = () =>
|
|
33
|
+
createHigherOrderComponent(
|
|
34
|
+
( BlockEdit ) => ( props ) => {
|
|
35
|
+
const { clientId, name: blockName } = useBlockEditContext();
|
|
36
|
+
const { getBlockBindingsSource } = unlock(
|
|
37
|
+
useSelect( blockEditorStore )
|
|
38
|
+
);
|
|
39
|
+
const { getBlockAttributes, updateBlockAttributes } =
|
|
40
|
+
useSelect( blockEditorStore );
|
|
41
|
+
|
|
42
|
+
const updatedAttributes = getBlockAttributes( clientId );
|
|
43
|
+
if ( updatedAttributes?.metadata?.bindings ) {
|
|
44
|
+
Object.entries( updatedAttributes.metadata.bindings ).forEach(
|
|
45
|
+
( [ attributeName, settings ] ) => {
|
|
46
|
+
const source = getBlockBindingsSource(
|
|
47
|
+
settings.source.name
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
if ( source ) {
|
|
51
|
+
// Second argument (`updateMetaValue`) will be used to update the value in the future.
|
|
52
|
+
const {
|
|
53
|
+
placeholder,
|
|
54
|
+
useValue: [ metaValue = null ] = [],
|
|
55
|
+
} = source.useSource(
|
|
56
|
+
props,
|
|
57
|
+
settings.source.attributes
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
if ( placeholder && ! metaValue ) {
|
|
61
|
+
// If the attribute is `src` or `href`, a placeholder can't be used because it is not a valid url.
|
|
62
|
+
// Adding this workaround until attributes and metadata fields types are improved and include `url`.
|
|
63
|
+
const htmlAttribute =
|
|
64
|
+
getBlockType( blockName ).attributes[
|
|
65
|
+
attributeName
|
|
66
|
+
].attribute;
|
|
67
|
+
if (
|
|
68
|
+
htmlAttribute === 'src' ||
|
|
69
|
+
htmlAttribute === 'href'
|
|
70
|
+
) {
|
|
71
|
+
updatedAttributes[ attributeName ] = null;
|
|
72
|
+
} else {
|
|
73
|
+
updatedAttributes[ attributeName ] =
|
|
74
|
+
placeholder;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if ( metaValue ) {
|
|
79
|
+
updatedAttributes[ attributeName ] = metaValue;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const registry = useRegistry();
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<>
|
|
90
|
+
<BlockEdit
|
|
91
|
+
key="edit"
|
|
92
|
+
attributes={ updatedAttributes }
|
|
93
|
+
setAttributes={ ( newAttributes, blockId ) =>
|
|
94
|
+
registry.batch( () =>
|
|
95
|
+
updateBlockAttributes( blockId, newAttributes )
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
{ ...props }
|
|
99
|
+
/>
|
|
100
|
+
</>
|
|
101
|
+
);
|
|
102
|
+
},
|
|
103
|
+
'useBoundAttributes'
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Filters a registered block's settings to enhance a block's `edit` component
|
|
108
|
+
* to upgrade bound attributes.
|
|
109
|
+
*
|
|
110
|
+
* @param {WPBlockSettings} settings Registered block settings.
|
|
111
|
+
*
|
|
112
|
+
* @return {WPBlockSettings} Filtered block settings.
|
|
113
|
+
*/
|
|
114
|
+
function shimAttributeSource( settings ) {
|
|
115
|
+
if ( ! ( settings.name in BLOCK_BINDINGS_ALLOWED_BLOCKS ) ) {
|
|
116
|
+
return settings;
|
|
117
|
+
}
|
|
118
|
+
settings.edit = createEditFunctionWithBindingsAttribute()( settings.edit );
|
|
119
|
+
|
|
120
|
+
return settings;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
addFilter(
|
|
124
|
+
'blocks.registerBlockType',
|
|
125
|
+
'core/editor/custom-sources-backwards-compatibility/shim-attribute-source',
|
|
126
|
+
shimAttributeSource
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
// Add the context to all blocks.
|
|
130
|
+
addFilter(
|
|
131
|
+
'blocks.registerBlockType',
|
|
132
|
+
'core/block-bindings-ui',
|
|
133
|
+
( settings, name ) => {
|
|
134
|
+
if ( ! ( name in BLOCK_BINDINGS_ALLOWED_BLOCKS ) ) {
|
|
135
|
+
return settings;
|
|
136
|
+
}
|
|
137
|
+
const contextItems = [ 'postId', 'postType', 'queryId' ];
|
|
138
|
+
const usesContextArray = settings.usesContext;
|
|
139
|
+
const oldUsesContextArray = new Set( usesContextArray );
|
|
140
|
+
contextItems.forEach( ( item ) => {
|
|
141
|
+
if ( ! oldUsesContextArray.has( item ) ) {
|
|
142
|
+
usesContextArray.push( item );
|
|
143
|
+
}
|
|
144
|
+
} );
|
|
145
|
+
settings.usesContext = usesContextArray;
|
|
146
|
+
return settings;
|
|
147
|
+
}
|
|
148
|
+
);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getInlineStyles } from './style';
|
|
5
|
+
|
|
6
|
+
// This utility is intended to assist where the serialization of the shadow
|
|
7
|
+
// block support is being skipped for a block but the shadow related CSS classes
|
|
8
|
+
// & styles still need to be generated so they can be applied to inner elements.
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Provides the CSS class names and inline styles for a block's shadow support
|
|
12
|
+
* attributes.
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} attributes Block attributes.
|
|
15
|
+
* @return {Object} Shadow block support derived CSS classes & styles.
|
|
16
|
+
*/
|
|
17
|
+
export function getShadowClassesAndStyles( attributes ) {
|
|
18
|
+
const shadow = attributes.style?.shadow || '';
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
className: undefined,
|
|
22
|
+
style: getInlineStyles( { shadow } ),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Derives the shadow related props for a block from its shadow block support
|
|
28
|
+
* attributes.
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} attributes Block attributes.
|
|
31
|
+
*
|
|
32
|
+
* @return {Object} ClassName & style props from shadow block support.
|
|
33
|
+
*/
|
|
34
|
+
export function useShadowProps( attributes ) {
|
|
35
|
+
const shadowProps = getShadowClassesAndStyles( attributes );
|
|
36
|
+
return shadowProps;
|
|
37
|
+
}
|
package/src/hooks/utils.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { getBlockSupport } from '@wordpress/blocks';
|
|
5
|
-
import { useMemo, useEffect, useId, useState } from '@wordpress/element';
|
|
5
|
+
import { memo, useMemo, useEffect, useId, useState } from '@wordpress/element';
|
|
6
6
|
import { useDispatch } from '@wordpress/data';
|
|
7
|
-
import { createHigherOrderComponent
|
|
7
|
+
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
8
8
|
import { addFilter } from '@wordpress/hooks';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -177,7 +177,10 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
177
177
|
backgroundImage,
|
|
178
178
|
backgroundSize,
|
|
179
179
|
fontFamilies,
|
|
180
|
-
|
|
180
|
+
userFontSizes,
|
|
181
|
+
themeFontSizes,
|
|
182
|
+
defaultFontSizes,
|
|
183
|
+
defaultFontSizesEnabled,
|
|
181
184
|
customFontSize,
|
|
182
185
|
fontStyle,
|
|
183
186
|
fontWeight,
|
|
@@ -218,11 +221,15 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
218
221
|
isTextEnabled,
|
|
219
222
|
isHeadingEnabled,
|
|
220
223
|
isButtonEnabled,
|
|
224
|
+
shadow,
|
|
221
225
|
] = useSettings(
|
|
222
226
|
'background.backgroundImage',
|
|
223
227
|
'background.backgroundSize',
|
|
224
228
|
'typography.fontFamilies',
|
|
225
|
-
'typography.fontSizes',
|
|
229
|
+
'typography.fontSizes.custom',
|
|
230
|
+
'typography.fontSizes.theme',
|
|
231
|
+
'typography.fontSizes.default',
|
|
232
|
+
'typography.defaultFontSizes',
|
|
226
233
|
'typography.customFontSize',
|
|
227
234
|
'typography.fontStyle',
|
|
228
235
|
'typography.fontWeight',
|
|
@@ -262,7 +269,8 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
262
269
|
'color.link',
|
|
263
270
|
'color.text',
|
|
264
271
|
'color.heading',
|
|
265
|
-
'color.button'
|
|
272
|
+
'color.button',
|
|
273
|
+
'shadow'
|
|
266
274
|
);
|
|
267
275
|
|
|
268
276
|
const rawSettings = useMemo( () => {
|
|
@@ -304,9 +312,12 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
304
312
|
custom: fontFamilies,
|
|
305
313
|
},
|
|
306
314
|
fontSizes: {
|
|
307
|
-
custom:
|
|
315
|
+
custom: userFontSizes,
|
|
316
|
+
theme: themeFontSizes,
|
|
317
|
+
default: defaultFontSizes,
|
|
308
318
|
},
|
|
309
319
|
customFontSize,
|
|
320
|
+
defaultFontSizes: defaultFontSizesEnabled,
|
|
310
321
|
fontStyle,
|
|
311
322
|
fontWeight,
|
|
312
323
|
lineHeight,
|
|
@@ -336,12 +347,16 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
336
347
|
},
|
|
337
348
|
layout,
|
|
338
349
|
parentLayout,
|
|
350
|
+
shadow,
|
|
339
351
|
};
|
|
340
352
|
}, [
|
|
341
353
|
backgroundImage,
|
|
342
354
|
backgroundSize,
|
|
343
355
|
fontFamilies,
|
|
344
|
-
|
|
356
|
+
userFontSizes,
|
|
357
|
+
themeFontSizes,
|
|
358
|
+
defaultFontSizes,
|
|
359
|
+
defaultFontSizesEnabled,
|
|
345
360
|
customFontSize,
|
|
346
361
|
fontStyle,
|
|
347
362
|
fontWeight,
|
|
@@ -383,6 +398,7 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
383
398
|
isTextEnabled,
|
|
384
399
|
isHeadingEnabled,
|
|
385
400
|
isButtonEnabled,
|
|
401
|
+
shadow,
|
|
386
402
|
] );
|
|
387
403
|
|
|
388
404
|
return useSettingsForBlockElement( rawSettings, name );
|
|
@@ -390,10 +406,10 @@ export function useBlockSettings( name, parentLayout ) {
|
|
|
390
406
|
|
|
391
407
|
export function createBlockEditFilter( features ) {
|
|
392
408
|
// We don't want block controls to re-render when typing inside a block.
|
|
393
|
-
// `
|
|
409
|
+
// `memo` will prevent re-renders unless props change, so only pass the
|
|
394
410
|
// needed props and not the whole attributes object.
|
|
395
411
|
features = features.map( ( settings ) => {
|
|
396
|
-
return { ...settings, Edit:
|
|
412
|
+
return { ...settings, Edit: memo( settings.edit ) };
|
|
397
413
|
} );
|
|
398
414
|
const withBlockEditHooks = createHigherOrderComponent(
|
|
399
415
|
( OriginalBlockEdit ) => ( props ) => {
|
|
@@ -476,7 +492,7 @@ function BlockProps( { index, useBlockProps, setAllWrapperProps, ...props } ) {
|
|
|
476
492
|
return null;
|
|
477
493
|
}
|
|
478
494
|
|
|
479
|
-
const BlockPropsPure =
|
|
495
|
+
const BlockPropsPure = memo( BlockProps );
|
|
480
496
|
|
|
481
497
|
export function createBlockListBlockFilter( features ) {
|
|
482
498
|
const withBlockListBlockHooks = createHigherOrderComponent(
|
package/src/index.js
CHANGED
|
@@ -11,6 +11,8 @@ export {
|
|
|
11
11
|
useCustomSides as __experimentalUseCustomSides,
|
|
12
12
|
getSpacingClassesAndStyles as __experimentalGetSpacingClassesAndStyles,
|
|
13
13
|
getGapCSSValue as __experimentalGetGapCSSValue,
|
|
14
|
+
getShadowClassesAndStyles as __experimentalGetShadowClassesAndStyles,
|
|
15
|
+
useShadowProps as __experimentalUseShadowProps,
|
|
14
16
|
useCachedTruthy,
|
|
15
17
|
} from './hooks';
|
|
16
18
|
export * from './components';
|
package/src/store/actions.js
CHANGED
|
@@ -640,13 +640,15 @@ export function showInsertionPoint(
|
|
|
640
640
|
index,
|
|
641
641
|
__unstableOptions = {}
|
|
642
642
|
) {
|
|
643
|
-
const { __unstableWithInserter, operation } =
|
|
643
|
+
const { __unstableWithInserter, operation, nearestSide } =
|
|
644
|
+
__unstableOptions;
|
|
644
645
|
return {
|
|
645
646
|
type: 'SHOW_INSERTION_POINT',
|
|
646
647
|
rootClientId,
|
|
647
648
|
index,
|
|
648
649
|
__unstableWithInserter,
|
|
649
650
|
operation,
|
|
651
|
+
nearestSide,
|
|
650
652
|
};
|
|
651
653
|
}
|
|
652
654
|
/**
|
|
@@ -1679,20 +1681,23 @@ export function setBlockVisibility( updates ) {
|
|
|
1679
1681
|
}
|
|
1680
1682
|
|
|
1681
1683
|
/**
|
|
1682
|
-
* Action that sets whether a block is being
|
|
1684
|
+
* Action that sets whether a block is being temporarily edited as blocks.
|
|
1683
1685
|
*
|
|
1684
1686
|
* DO-NOT-USE in production.
|
|
1685
1687
|
* This action is created for internal/experimental only usage and may be
|
|
1686
1688
|
* removed anytime without any warning, causing breakage on any plugin or theme invoking it.
|
|
1687
1689
|
*
|
|
1688
|
-
* @param {?string} temporarilyEditingAsBlocks The block's clientId being
|
|
1690
|
+
* @param {?string} temporarilyEditingAsBlocks The block's clientId being temporarily edited as blocks.
|
|
1691
|
+
* @param {?string} focusModeToRevert The focus mode to revert after temporarily edit as blocks finishes.
|
|
1689
1692
|
*/
|
|
1690
1693
|
export function __unstableSetTemporarilyEditingAsBlocks(
|
|
1691
|
-
temporarilyEditingAsBlocks
|
|
1694
|
+
temporarilyEditingAsBlocks,
|
|
1695
|
+
focusModeToRevert
|
|
1692
1696
|
) {
|
|
1693
1697
|
return {
|
|
1694
1698
|
type: 'SET_TEMPORARILY_EDITING_AS_BLOCKS',
|
|
1695
1699
|
temporarilyEditingAsBlocks,
|
|
1700
|
+
focusModeToRevert,
|
|
1696
1701
|
};
|
|
1697
1702
|
}
|
|
1698
1703
|
|
package/src/store/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import reducer from './reducer';
|
|
|
10
10
|
import * as selectors from './selectors';
|
|
11
11
|
import * as privateActions from './private-actions';
|
|
12
12
|
import * as privateSelectors from './private-selectors';
|
|
13
|
+
import * as resolvers from './resolvers';
|
|
13
14
|
import * as actions from './actions';
|
|
14
15
|
import { STORE_NAME } from './constants';
|
|
15
16
|
import { unlock } from '../lock-unlock';
|
|
@@ -22,6 +23,7 @@ import { unlock } from '../lock-unlock';
|
|
|
22
23
|
export const storeConfig = {
|
|
23
24
|
reducer,
|
|
24
25
|
selectors,
|
|
26
|
+
resolvers,
|
|
25
27
|
actions,
|
|
26
28
|
};
|
|
27
29
|
|
|
@@ -338,3 +338,35 @@ export function setLastFocus( lastFocus = null ) {
|
|
|
338
338
|
lastFocus,
|
|
339
339
|
};
|
|
340
340
|
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Action that stops temporarily editing as blocks.
|
|
344
|
+
*
|
|
345
|
+
* @param {string} clientId The block's clientId.
|
|
346
|
+
*/
|
|
347
|
+
export function stopEditingAsBlocks( clientId ) {
|
|
348
|
+
return ( { select, dispatch } ) => {
|
|
349
|
+
const focusModeToRevert =
|
|
350
|
+
select.__unstableGetTemporarilyEditingFocusModeToRevert();
|
|
351
|
+
dispatch.__unstableMarkNextChangeAsNotPersistent();
|
|
352
|
+
dispatch.updateBlockAttributes( clientId, {
|
|
353
|
+
templateLock: 'contentOnly',
|
|
354
|
+
} );
|
|
355
|
+
dispatch.updateBlockListSettings( clientId, {
|
|
356
|
+
...select.getBlockListSettings( clientId ),
|
|
357
|
+
templateLock: 'contentOnly',
|
|
358
|
+
} );
|
|
359
|
+
dispatch.updateSettings( { focusMode: focusModeToRevert } );
|
|
360
|
+
dispatch.__unstableSetTemporarilyEditingAsBlocks();
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export function registerBlockBindingsSource( source ) {
|
|
365
|
+
return {
|
|
366
|
+
type: 'REGISTER_BLOCK_BINDINGS_SOURCE',
|
|
367
|
+
sourceName: source.name,
|
|
368
|
+
sourceLabel: source.label,
|
|
369
|
+
useSource: source.useSource,
|
|
370
|
+
lockAttributesEditing: source.lockAttributesEditing,
|
|
371
|
+
};
|
|
372
|
+
}
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import createSelector from 'rememo';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { createRegistrySelector } from '@wordpress/data';
|
|
10
|
+
|
|
6
11
|
/**
|
|
7
12
|
* Internal dependencies
|
|
8
13
|
*/
|
|
@@ -11,11 +16,12 @@ import {
|
|
|
11
16
|
getBlockParents,
|
|
12
17
|
getBlockEditingMode,
|
|
13
18
|
getSettings,
|
|
14
|
-
__experimentalGetParsedPattern,
|
|
15
19
|
canInsertBlockType,
|
|
16
|
-
__experimentalGetAllowedPatterns,
|
|
17
20
|
} from './selectors';
|
|
18
|
-
import {
|
|
21
|
+
import { checkAllowListRecursive, getAllPatternsDependants } from './utils';
|
|
22
|
+
import { INSERTER_PATTERN_TYPES } from '../components/inserter/block-patterns-tab/utils';
|
|
23
|
+
import { store } from './';
|
|
24
|
+
import { unlock } from '../lock-unlock';
|
|
19
25
|
|
|
20
26
|
/**
|
|
21
27
|
* Returns true if the block interface is hidden, or false otherwise.
|
|
@@ -242,6 +248,10 @@ export const getInserterMediaCategories = createSelector(
|
|
|
242
248
|
]
|
|
243
249
|
);
|
|
244
250
|
|
|
251
|
+
export function getFetchedPatterns( state ) {
|
|
252
|
+
return state.blockPatterns;
|
|
253
|
+
}
|
|
254
|
+
|
|
245
255
|
/**
|
|
246
256
|
* Returns whether there is at least one allowed pattern for inner blocks children.
|
|
247
257
|
* This is useful for deferring the parsing of all patterns until needed.
|
|
@@ -251,35 +261,74 @@ export const getInserterMediaCategories = createSelector(
|
|
|
251
261
|
*
|
|
252
262
|
* @return {boolean} If there is at least one allowed pattern.
|
|
253
263
|
*/
|
|
254
|
-
export const hasAllowedPatterns =
|
|
255
|
-
(
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
264
|
+
export const hasAllowedPatterns = createRegistrySelector( ( select ) =>
|
|
265
|
+
createSelector(
|
|
266
|
+
( state, rootClientId = null ) => {
|
|
267
|
+
const { getAllPatterns, __experimentalGetParsedPattern } = unlock(
|
|
268
|
+
select( store )
|
|
269
|
+
);
|
|
270
|
+
const patterns = getAllPatterns();
|
|
271
|
+
const { allowedBlockTypes } = getSettings( state );
|
|
272
|
+
return patterns.some( ( { name, inserter = true } ) => {
|
|
261
273
|
if ( ! inserter ) {
|
|
262
274
|
return false;
|
|
263
275
|
}
|
|
264
|
-
const { blocks } = __experimentalGetParsedPattern(
|
|
265
|
-
state,
|
|
266
|
-
name
|
|
267
|
-
);
|
|
276
|
+
const { blocks } = __experimentalGetParsedPattern( name );
|
|
268
277
|
return (
|
|
269
278
|
checkAllowListRecursive( blocks, allowedBlockTypes ) &&
|
|
270
279
|
blocks.every( ( { name: blockName } ) =>
|
|
271
280
|
canInsertBlockType( state, blockName, rootClientId )
|
|
272
281
|
)
|
|
273
282
|
);
|
|
283
|
+
} );
|
|
284
|
+
},
|
|
285
|
+
( state, rootClientId ) => [
|
|
286
|
+
getAllPatternsDependants( state ),
|
|
287
|
+
state.settings.allowedBlockTypes,
|
|
288
|
+
state.settings.templateLock,
|
|
289
|
+
state.blockListSettings[ rootClientId ],
|
|
290
|
+
state.blocks.byClientId.get( rootClientId ),
|
|
291
|
+
]
|
|
292
|
+
)
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
export const getAllPatterns = createRegistrySelector( ( select ) =>
|
|
296
|
+
createSelector( ( state ) => {
|
|
297
|
+
// This setting is left for back compat.
|
|
298
|
+
const {
|
|
299
|
+
__experimentalBlockPatterns = [],
|
|
300
|
+
__experimentalUserPatternCategories = [],
|
|
301
|
+
__experimentalReusableBlocks = [],
|
|
302
|
+
} = state.settings;
|
|
303
|
+
const userPatterns = ( __experimentalReusableBlocks ?? [] ).map(
|
|
304
|
+
( userPattern ) => {
|
|
305
|
+
return {
|
|
306
|
+
name: `core/block/${ userPattern.id }`,
|
|
307
|
+
id: userPattern.id,
|
|
308
|
+
type: INSERTER_PATTERN_TYPES.user,
|
|
309
|
+
title: userPattern.title.raw,
|
|
310
|
+
categories: userPattern.wp_pattern_category.map(
|
|
311
|
+
( catId ) => {
|
|
312
|
+
const category = (
|
|
313
|
+
__experimentalUserPatternCategories ?? []
|
|
314
|
+
).find( ( { id } ) => id === catId );
|
|
315
|
+
return category ? category.slug : catId;
|
|
316
|
+
}
|
|
317
|
+
),
|
|
318
|
+
content: userPattern.content.raw,
|
|
319
|
+
syncStatus: userPattern.wp_pattern_sync_status,
|
|
320
|
+
};
|
|
274
321
|
}
|
|
275
322
|
);
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
323
|
+
return [
|
|
324
|
+
...userPatterns,
|
|
325
|
+
...__experimentalBlockPatterns,
|
|
326
|
+
...unlock( select( store ) ).getFetchedPatterns(),
|
|
327
|
+
].filter(
|
|
328
|
+
( x, index, arr ) =>
|
|
329
|
+
index === arr.findIndex( ( y ) => x.name === y.name )
|
|
330
|
+
);
|
|
331
|
+
}, getAllPatternsDependants )
|
|
283
332
|
);
|
|
284
333
|
|
|
285
334
|
/**
|
|
@@ -292,3 +341,11 @@ export const hasAllowedPatterns = createSelector(
|
|
|
292
341
|
export function getLastFocus( state ) {
|
|
293
342
|
return state.lastFocus;
|
|
294
343
|
}
|
|
344
|
+
|
|
345
|
+
export function getAllBlockBindingsSources( state ) {
|
|
346
|
+
return state.blockBindingsSources;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
export function getBlockBindingsSource( state, sourceName ) {
|
|
350
|
+
return state.blockBindingsSources[ sourceName ];
|
|
351
|
+
}
|