@wordpress/block-editor 11.0.0 → 11.2.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 +16 -1
- package/LICENSE.md +1 -1
- package/README.md +2 -1
- package/build/components/alignment-control/ui.js +1 -7
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-actions/index.js +9 -0
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js +4 -3
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-icon/index.js +4 -2
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +58 -5
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list-appender/index.js +46 -34
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-list-appender/index.native.js +39 -34
- package/build/components/block-list-appender/index.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +18 -18
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +1 -1
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +14 -7
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-preview/auto.js +1 -4
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/index.js +3 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/index.native.js +1 -3
- package/build/components/block-styles/index.native.js.map +1 -1
- package/build/components/block-styles/utils.js +7 -10
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-toolbar/index.native.js +6 -8
- package/build/components/block-toolbar/index.native.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +1 -3
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +43 -10
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/block-variation-picker/index.js +1 -1
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/colors/utils.js +2 -6
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors-gradients/control.js +0 -3
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +0 -2
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -19
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -3
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build/components/copy-handler/index.js +37 -9
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/default-style-picker/index.js +1 -0
- package/build/components/default-style-picker/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +5 -2
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/utils.js +10 -4
- package/build/components/font-sizes/utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +14 -12
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/gradients/use-gradient.js +2 -8
- package/build/components/gradients/use-gradient.js.map +1 -1
- package/build/components/iframe/index.js +48 -101
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +98 -0
- package/build/components/iframe/use-compatibility-styles.js.map +1 -0
- package/build/components/image-size-control/index.js +1 -0
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +6 -2
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +4 -4
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +4 -3
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/index.js +16 -6
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +8 -5
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/menu.js +11 -5
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +6 -3
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-items.js +15 -14
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter/search-results.js +4 -2
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inspector-controls/groups.js +3 -1
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +46 -0
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
- package/build/components/inspector-controls-tabs/settings-tab.js +3 -1
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -11
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -0
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block-select-button.js +1 -1
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +3 -44
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +38 -5
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/block-select-button.js +3 -2
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build/components/off-canvas-editor/block.js +51 -57
- package/build/components/off-canvas-editor/block.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +12 -5
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/use-inserted-block.js +58 -0
- package/build/components/off-canvas-editor/use-inserted-block.js.map +1 -0
- package/build/components/provider/index.js +3 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/responsive-block-control/label.js.map +1 -1
- package/build/components/rich-text/format-edit.js +12 -10
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-enter.js +4 -5
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +21 -12
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +0 -1
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +1 -1
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/typewriter/index.js +1 -1
- package/build/components/typewriter/index.js.map +1 -1
- package/build/components/url-input/button.js +1 -0
- package/build/components/url-input/button.js.map +1 -1
- package/build/components/url-input/index.js +15 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +2 -2
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/url-popover/link-editor.js +1 -0
- package/build/components/url-popover/link-editor.js.map +1 -1
- package/build/components/use-paste-styles/index.js +188 -0
- package/build/components/use-paste-styles/index.js.map +1 -0
- package/build/components/writing-flow/index.js +1 -1
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +22 -29
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/hooks/border.js +0 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +0 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -2
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/font-family.js +4 -4
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +5 -3
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/metadata.js +1 -1
- package/build/hooks/metadata.js.map +1 -1
- package/build/hooks/position.js +376 -0
- package/build/hooks/position.js.map +1 -0
- package/build/hooks/supports.js +328 -0
- package/build/hooks/supports.js.map +1 -0
- package/build/hooks/use-typography-props.js +11 -8
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/store/reducer.js +27 -9
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +9 -7
- package/build/store/selectors.js.map +1 -1
- package/build/utils/pasting.js +6 -11
- package/build/utils/pasting.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -6
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-actions/index.js +6 -0
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +4 -3
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-icon/index.js +4 -2
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +58 -6
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +46 -34
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.native.js +39 -32
- package/build-module/components/block-list-appender/index.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +18 -18
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +14 -7
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +1 -4
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -1
- 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/block-styles/index.native.js +1 -2
- package/build-module/components/block-styles/index.native.js.map +1 -1
- package/build-module/components/block-styles/utils.js +7 -9
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-toolbar/index.native.js +6 -8
- package/build-module/components/block-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +1 -2
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +42 -11
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +1 -1
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/colors/utils.js +3 -7
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +0 -3
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +0 -2
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +4 -19
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build-module/components/copy-handler/index.js +38 -10
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/default-style-picker/index.js +1 -0
- package/build-module/components/default-style-picker/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +5 -2
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/utils.js +11 -5
- package/build-module/components/font-sizes/utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +14 -11
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/gradients/use-gradient.js +2 -7
- package/build-module/components/gradients/use-gradient.js.map +1 -1
- package/build-module/components/iframe/index.js +46 -102
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +90 -0
- package/build-module/components/iframe/use-compatibility-styles.js.map +1 -0
- package/build-module/components/image-size-control/index.js +1 -0
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +6 -2
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +4 -4
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +4 -3
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/index.js +16 -6
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +8 -5
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/menu.js +11 -5
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +6 -3
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-items.js +15 -13
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter/search-results.js +4 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +3 -1
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +33 -0
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js +2 -1
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -11
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -0
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +1 -1
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +5 -44
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +37 -7
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-select-button.js +3 -2
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build-module/components/off-canvas-editor/block.js +54 -60
- package/build-module/components/off-canvas-editor/block.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +12 -5
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/use-inserted-block.js +47 -0
- package/build-module/components/off-canvas-editor/use-inserted-block.js.map +1 -0
- package/build-module/components/provider/index.js +3 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/responsive-block-control/label.js +1 -2
- package/build-module/components/responsive-block-control/label.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +12 -9
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +4 -5
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +22 -12
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +0 -1
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +1 -1
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/typewriter/index.js +1 -1
- package/build-module/components/typewriter/index.js.map +1 -1
- package/build-module/components/url-input/button.js +1 -0
- package/build-module/components/url-input/button.js.map +1 -1
- package/build-module/components/url-input/index.js +14 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +3 -3
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/url-popover/link-editor.js +1 -0
- package/build-module/components/url-popover/link-editor.js.map +1 -1
- package/build-module/components/use-paste-styles/index.js +174 -0
- package/build-module/components/use-paste-styles/index.js.map +1 -0
- package/build-module/components/writing-flow/index.js +1 -1
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +22 -29
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/hooks/border.js +0 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +0 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -2
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/font-family.js +5 -5
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +5 -3
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/metadata.js +1 -1
- package/build-module/hooks/metadata.js.map +1 -1
- package/build-module/hooks/position.js +337 -0
- package/build-module/hooks/position.js.map +1 -0
- package/build-module/hooks/supports.js +257 -0
- package/build-module/hooks/supports.js.map +1 -0
- package/build-module/hooks/use-typography-props.js +11 -8
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/store/reducer.js +27 -8
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +9 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/pasting.js +6 -10
- package/build-module/utils/pasting.js.map +1 -1
- package/build-style/content-rtl.css +60 -3
- package/build-style/content.css +60 -3
- package/build-style/default-editor-styles-rtl.css +3 -3
- package/build-style/default-editor-styles.css +3 -3
- package/build-style/style-rtl.css +62 -69
- package/build-style/style.css +62 -69
- package/package.json +29 -29
- package/src/components/alignment-control/test/index.js +2 -0
- package/src/components/alignment-control/ui.js +1 -7
- package/src/components/block-actions/index.js +5 -0
- package/src/components/block-alignment-control/test/index.js +2 -0
- package/src/components/block-alignment-control/use-available-alignments.js +4 -3
- package/src/components/block-icon/index.js +4 -2
- package/src/components/block-icon/test/index.js +9 -5
- package/src/components/block-inspector/index.js +79 -4
- package/src/components/block-inspector/style.scss +7 -0
- package/src/components/block-list-appender/index.js +65 -54
- package/src/components/block-list-appender/index.native.js +45 -34
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +18 -22
- package/src/components/block-mobile-toolbar/index.native.js +1 -1
- package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +125 -0
- package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +439 -0
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +42 -0
- package/src/components/block-mover/test/index.native.js +157 -1
- package/src/components/block-pattern-setup/index.js +15 -6
- package/src/components/block-pattern-setup/style.scss +29 -1
- package/src/components/block-preview/auto.js +2 -4
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -0
- package/src/components/block-styles/index.js +4 -1
- package/src/components/block-styles/index.native.js +1 -2
- package/src/components/block-styles/utils.js +5 -7
- package/src/components/block-switcher/test/index.js +3 -2
- package/src/components/block-toolbar/index.native.js +8 -11
- package/src/components/block-tools/selected-block-popover.js +1 -3
- package/src/components/block-tools/use-block-toolbar-popover-props.js +68 -12
- package/src/components/block-variation-picker/index.js +5 -1
- package/src/components/block-vertical-alignment-control/test/index.js +2 -0
- package/src/components/button-block-appender/{style.scss → content.scss} +0 -0
- package/src/components/colors/test/with-colors.js +2 -0
- package/src/components/colors/utils.js +5 -3
- package/src/components/colors-gradients/control.js +0 -7
- package/src/components/colors-gradients/dropdown.js +0 -2
- package/src/components/colors-gradients/panel-color-gradient-settings.js +4 -22
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
- package/src/components/copy-handler/index.js +53 -7
- package/src/components/default-block-appender/test/index.js +2 -0
- package/src/components/default-style-picker/index.js +1 -0
- package/src/components/font-sizes/fluid-utils.js +7 -1
- package/src/components/font-sizes/utils.js +5 -3
- package/src/components/font-sizes/with-font-sizes.js +36 -36
- package/src/components/gradients/use-gradient.js +2 -7
- package/src/components/iframe/index.js +60 -122
- package/src/components/iframe/use-compatibility-styles.js +101 -0
- package/src/components/image-size-control/index.js +1 -0
- package/src/components/image-size-control/test/index.js +147 -79
- package/src/components/inner-blocks/index.js +4 -2
- package/src/components/inserter/block-patterns-tab.js +7 -4
- package/src/components/inserter/hooks/use-insertion-point.js +3 -2
- package/src/components/inserter/index.js +61 -43
- package/src/components/inserter/media-tab/hooks.js +5 -4
- package/src/components/inserter/menu.js +8 -4
- package/src/components/inserter/quick-inserter.js +3 -0
- package/src/components/inserter/search-items.js +1 -2
- package/src/components/inserter/search-results.js +2 -0
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +117 -0
- package/src/components/inserter/test/index.native.js +255 -1
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/position-controls-panel.js +37 -0
- package/src/components/inspector-controls-tabs/settings-tab.js +2 -0
- package/src/components/inspector-controls-tabs/style.scss +15 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -8
- package/src/components/link-control/search-input.js +1 -0
- package/src/components/link-control/style.scss +1 -0
- package/src/components/link-control/test/index.js +18 -4
- package/src/components/list-view/block-select-button.js +1 -1
- package/src/components/list-view/style.scss +14 -10
- package/src/components/media-replace-flow/test/index.js +2 -0
- package/src/components/off-canvas-editor/appender.js +4 -49
- package/src/components/off-canvas-editor/block-contents.js +84 -23
- package/src/components/off-canvas-editor/block-select-button.js +6 -2
- package/src/components/off-canvas-editor/block.js +90 -105
- package/src/components/off-canvas-editor/index.js +21 -2
- package/src/components/off-canvas-editor/style.scss +5 -1
- package/src/components/off-canvas-editor/test/use-inserted-block.js +108 -0
- package/src/components/off-canvas-editor/use-inserted-block.js +47 -0
- package/src/components/provider/index.js +4 -1
- package/src/components/responsive-block-control/label.js +2 -3
- package/src/components/responsive-block-control/test/index.js +4 -2
- package/src/components/rich-text/format-edit.js +6 -10
- package/src/components/rich-text/index.js +1 -0
- package/src/components/rich-text/use-enter.js +4 -4
- package/src/components/rich-text/use-paste-handler.js +33 -14
- package/src/components/spacing-sizes-control/index.js +0 -1
- package/src/components/spacing-sizes-control/utils.js +1 -1
- package/src/components/typewriter/index.js +3 -1
- package/src/components/url-input/README.md +5 -0
- package/src/components/url-input/button.js +1 -0
- package/src/components/url-input/index.js +15 -1
- package/src/components/url-input/test/button.js +2 -0
- package/src/components/url-popover/image-url-input-ui.js +5 -4
- package/src/components/url-popover/link-editor.js +1 -0
- package/src/components/url-popover/test/index.js +21 -5
- package/src/components/use-paste-styles/index.js +230 -0
- package/src/components/warning/test/index.js +2 -0
- package/src/components/writing-flow/index.js +1 -1
- package/src/components/writing-flow/use-arrow-nav.js +20 -28
- package/src/content.scss +1 -0
- package/src/hooks/border.js +0 -1
- package/src/hooks/color-panel.js +0 -1
- package/src/hooks/color.js +0 -2
- package/src/hooks/font-family.js +3 -5
- package/src/hooks/font-size.js +13 -4
- package/src/hooks/index.js +1 -0
- package/src/hooks/metadata.js +1 -2
- package/src/hooks/position.js +375 -0
- package/src/hooks/position.scss +18 -0
- package/src/hooks/supports.js +302 -0
- package/src/hooks/test/__snapshots__/align.native.js.snap +73 -0
- package/src/hooks/test/align.native.js +133 -0
- package/src/hooks/test/use-typography-props.js +26 -0
- package/src/hooks/use-typography-props.js +15 -7
- package/src/store/reducer.js +20 -8
- package/src/store/selectors.js +7 -8
- package/src/store/test/reducer.js +45 -3
- package/src/store/test/selectors.js +12 -9
- package/src/style.scss +2 -1
- package/src/utils/pasting.js +3 -9
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/colors-gradients/use-common-single-multiple-selects.js +0 -21
- package/build/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
- package/build/components/rich-text/file-paste-handler.js +0 -21
- package/build/components/rich-text/file-paste-handler.js.map +0 -1
- package/build-module/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
- package/build-module/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
- package/build-module/components/rich-text/file-paste-handler.js +0 -13
- package/build-module/components/rich-text/file-paste-handler.js.map +0 -1
- package/src/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
- package/src/components/rich-text/file-paste-handler.js +0 -13
|
@@ -167,6 +167,12 @@ export default function useArrowNav() {
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
function onKeyDown( event ) {
|
|
170
|
+
// Abort if navigation has already been handled (e.g. RichText
|
|
171
|
+
// inline boundaries).
|
|
172
|
+
if ( event.defaultPrevented ) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
|
|
170
176
|
const { keyCode, target, shiftKey, ctrlKey, altKey, metaKey } =
|
|
171
177
|
event;
|
|
172
178
|
const isUp = keyCode === UP;
|
|
@@ -182,24 +188,20 @@ export default function useArrowNav() {
|
|
|
182
188
|
const { ownerDocument } = node;
|
|
183
189
|
const { defaultView } = ownerDocument;
|
|
184
190
|
|
|
191
|
+
if ( ! isNav ) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
185
195
|
// If there is a multi-selection, the arrow keys should collapse the
|
|
186
196
|
// selection to the start or end of the selection.
|
|
187
197
|
if ( hasMultiSelection() ) {
|
|
188
|
-
|
|
189
|
-
// selection).
|
|
190
|
-
if ( ! __unstableIsFullySelected() ) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
if ( event.defaultPrevented ) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
if ( ! isNav ) {
|
|
198
|
+
if ( shiftKey ) {
|
|
199
199
|
return;
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
if (
|
|
202
|
+
// Only handle if we have a full selection (not a native partial
|
|
203
|
+
// selection).
|
|
204
|
+
if ( ! __unstableIsFullySelected() ) {
|
|
203
205
|
return;
|
|
204
206
|
}
|
|
205
207
|
|
|
@@ -214,6 +216,12 @@ export default function useArrowNav() {
|
|
|
214
216
|
return;
|
|
215
217
|
}
|
|
216
218
|
|
|
219
|
+
// Abort if our current target is not a candidate for navigation
|
|
220
|
+
// (e.g. preserve native input behaviors).
|
|
221
|
+
if ( ! isNavigationCandidate( target, keyCode, hasModifier ) ) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
217
225
|
// When presing any key other than up or down, the initial vertical
|
|
218
226
|
// position must ALWAYS be reset. The vertical position is saved so
|
|
219
227
|
// it can be restored as well as possible on sebsequent vertical
|
|
@@ -227,22 +235,6 @@ export default function useArrowNav() {
|
|
|
227
235
|
verticalRect = computeCaretRect( defaultView );
|
|
228
236
|
}
|
|
229
237
|
|
|
230
|
-
// Abort if navigation has already been handled (e.g. RichText
|
|
231
|
-
// inline boundaries).
|
|
232
|
-
if ( event.defaultPrevented ) {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
if ( ! isNav ) {
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// Abort if our current target is not a candidate for navigation
|
|
241
|
-
// (e.g. preserve native input behaviors).
|
|
242
|
-
if ( ! isNavigationCandidate( target, keyCode, hasModifier ) ) {
|
|
243
|
-
return;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
238
|
// In the case of RTL scripts, right means previous and left means
|
|
247
239
|
// next, which is the exact reverse of LTR.
|
|
248
240
|
const isReverseDir = isRTL( target ) ? ! isReverse : isReverse;
|
package/src/content.scss
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
@import "./components/block-content-overlay/content.scss";
|
|
4
4
|
@import "./components/block-draggable/content.scss";
|
|
5
5
|
@import "./components/block-preview/content.scss";
|
|
6
|
+
@import "./components/button-block-appender/content.scss";
|
|
6
7
|
@import "./components/default-block-appender/content.scss";
|
|
7
8
|
@import "./components/inner-blocks/content.scss";
|
|
8
9
|
@import "./components/media-placeholder/content.scss";
|
package/src/hooks/border.js
CHANGED
package/src/hooks/color-panel.js
CHANGED
package/src/hooks/color.js
CHANGED
|
@@ -522,8 +522,6 @@ export function ColorEdit( props ) {
|
|
|
522
522
|
allSolids,
|
|
523
523
|
style?.elements?.link?.color?.text
|
|
524
524
|
),
|
|
525
|
-
clearable:
|
|
526
|
-
!! style?.elements?.link?.color?.text,
|
|
527
525
|
isShownByDefault: defaultColorControls?.link,
|
|
528
526
|
resetAllFilter: resetAllLinkFilter,
|
|
529
527
|
},
|
package/src/hooks/font-family.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { kebabCase } from 'lodash';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -111,14 +111,12 @@ export function FontFamilyEdit( {
|
|
|
111
111
|
} ) {
|
|
112
112
|
const fontFamilies = useSetting( 'typography.fontFamilies' );
|
|
113
113
|
|
|
114
|
-
const value = find(
|
|
115
|
-
fontFamilies,
|
|
114
|
+
const value = fontFamilies?.find(
|
|
116
115
|
( { slug } ) => fontFamily === slug
|
|
117
116
|
)?.fontFamily;
|
|
118
117
|
|
|
119
118
|
function onChange( newValue ) {
|
|
120
|
-
const predefinedFontFamily = find(
|
|
121
|
-
fontFamilies,
|
|
119
|
+
const predefinedFontFamily = fontFamilies?.find(
|
|
122
120
|
( { fontFamily: f } ) => f === newValue
|
|
123
121
|
);
|
|
124
122
|
setAttributes( {
|
package/src/hooks/font-size.js
CHANGED
|
@@ -324,13 +324,22 @@ function addEditPropsForFluidCustomFontSizes( blockType ) {
|
|
|
324
324
|
// BlockListContext.Provider. If we set fontSize using editor.
|
|
325
325
|
// BlockListBlock instead of using getEditWrapperProps then the value is
|
|
326
326
|
// clobbered when the core/style/addEditProps filter runs.
|
|
327
|
-
const
|
|
328
|
-
|
|
327
|
+
const fluidTypographyConfig =
|
|
328
|
+
select( blockEditorStore ).getSettings().__experimentalFeatures
|
|
329
329
|
?.typography?.fluid;
|
|
330
330
|
|
|
331
|
+
const fluidTypographySettings =
|
|
332
|
+
typeof fluidTypographyConfig === 'object'
|
|
333
|
+
? fluidTypographyConfig
|
|
334
|
+
: {};
|
|
335
|
+
|
|
331
336
|
const newFontSize =
|
|
332
|
-
fontSize &&
|
|
333
|
-
? getComputedFluidTypographyValue( {
|
|
337
|
+
fontSize && !! fluidTypographyConfig
|
|
338
|
+
? getComputedFluidTypographyValue( {
|
|
339
|
+
fontSize,
|
|
340
|
+
minimumFontSizeLimit:
|
|
341
|
+
fluidTypographySettings?.minFontSize,
|
|
342
|
+
} )
|
|
334
343
|
: null;
|
|
335
344
|
|
|
336
345
|
if ( newFontSize === null ) {
|
package/src/hooks/index.js
CHANGED
package/src/hooks/metadata.js
CHANGED
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
10
|
+
import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
|
|
11
|
+
import { BaseControl, CustomSelectControl } from '@wordpress/components';
|
|
12
|
+
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
|
|
13
|
+
import {
|
|
14
|
+
useContext,
|
|
15
|
+
useMemo,
|
|
16
|
+
createPortal,
|
|
17
|
+
Platform,
|
|
18
|
+
} from '@wordpress/element';
|
|
19
|
+
import { addFilter } from '@wordpress/hooks';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Internal dependencies
|
|
23
|
+
*/
|
|
24
|
+
import BlockList from '../components/block-list';
|
|
25
|
+
import useSetting from '../components/use-setting';
|
|
26
|
+
import InspectorControls from '../components/inspector-controls';
|
|
27
|
+
import { cleanEmptyObject } from './utils';
|
|
28
|
+
|
|
29
|
+
const POSITION_SUPPORT_KEY = 'position';
|
|
30
|
+
|
|
31
|
+
const OPTION_CLASSNAME =
|
|
32
|
+
'block-editor-hooks__position-selection__select-control__option';
|
|
33
|
+
|
|
34
|
+
const DEFAULT_OPTION = {
|
|
35
|
+
key: 'default',
|
|
36
|
+
value: '',
|
|
37
|
+
name: __( 'Default' ),
|
|
38
|
+
className: OPTION_CLASSNAME,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const STICKY_OPTION = {
|
|
42
|
+
key: 'sticky',
|
|
43
|
+
value: 'sticky',
|
|
44
|
+
name: __( 'Sticky' ),
|
|
45
|
+
className: OPTION_CLASSNAME,
|
|
46
|
+
__experimentalHint: __(
|
|
47
|
+
'The block will stick to the top of the window instead of scrolling.'
|
|
48
|
+
),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const FIXED_OPTION = {
|
|
52
|
+
key: 'fixed',
|
|
53
|
+
value: 'fixed',
|
|
54
|
+
name: __( 'Fixed' ),
|
|
55
|
+
className: OPTION_CLASSNAME,
|
|
56
|
+
__experimentalHint: __(
|
|
57
|
+
'The block will not move when the page is scrolled.'
|
|
58
|
+
),
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const POSITION_SIDES = [ 'top', 'right', 'bottom', 'left' ];
|
|
62
|
+
const VALID_POSITION_TYPES = [ 'sticky', 'fixed' ];
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get calculated position CSS.
|
|
66
|
+
*
|
|
67
|
+
* @param {Object} props Component props.
|
|
68
|
+
* @param {string} props.selector Selector to use.
|
|
69
|
+
* @param {Object} props.style Style object.
|
|
70
|
+
* @return {string} The generated CSS rules.
|
|
71
|
+
*/
|
|
72
|
+
export function getPositionCSS( { selector, style } ) {
|
|
73
|
+
let output = '';
|
|
74
|
+
|
|
75
|
+
const { type: positionType } = style?.position || {};
|
|
76
|
+
|
|
77
|
+
if ( ! VALID_POSITION_TYPES.includes( positionType ) ) {
|
|
78
|
+
return output;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
output += `${ selector } {`;
|
|
82
|
+
output += `position: ${ positionType };`;
|
|
83
|
+
|
|
84
|
+
POSITION_SIDES.forEach( ( side ) => {
|
|
85
|
+
if ( style?.position?.[ side ] !== undefined ) {
|
|
86
|
+
output += `${ side }: ${ style.position[ side ] };`;
|
|
87
|
+
}
|
|
88
|
+
} );
|
|
89
|
+
|
|
90
|
+
if ( positionType === 'sticky' || positionType === 'fixed' ) {
|
|
91
|
+
// TODO: Replace hard-coded z-index value with a z-index preset approach in theme.json.
|
|
92
|
+
output += `z-index: 10`;
|
|
93
|
+
}
|
|
94
|
+
output += `}`;
|
|
95
|
+
|
|
96
|
+
return output;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Determines if there is sticky position support.
|
|
101
|
+
*
|
|
102
|
+
* @param {string|Object} blockType Block name or Block Type object.
|
|
103
|
+
*
|
|
104
|
+
* @return {boolean} Whether there is support.
|
|
105
|
+
*/
|
|
106
|
+
export function hasStickyPositionSupport( blockType ) {
|
|
107
|
+
const support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );
|
|
108
|
+
return !! ( true === support || support?.sticky );
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Determines if there is fixed position support.
|
|
113
|
+
*
|
|
114
|
+
* @param {string|Object} blockType Block name or Block Type object.
|
|
115
|
+
*
|
|
116
|
+
* @return {boolean} Whether there is support.
|
|
117
|
+
*/
|
|
118
|
+
export function hasFixedPositionSupport( blockType ) {
|
|
119
|
+
const support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );
|
|
120
|
+
return !! ( true === support || support?.fixed );
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Determines if there is position support.
|
|
125
|
+
*
|
|
126
|
+
* @param {string|Object} blockType Block name or Block Type object.
|
|
127
|
+
*
|
|
128
|
+
* @return {boolean} Whether there is support.
|
|
129
|
+
*/
|
|
130
|
+
export function hasPositionSupport( blockType ) {
|
|
131
|
+
const support = getBlockSupport( blockType, POSITION_SUPPORT_KEY );
|
|
132
|
+
return !! support;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Checks if there is a current value in the position block support attributes.
|
|
137
|
+
*
|
|
138
|
+
* @param {Object} props Block props.
|
|
139
|
+
* @return {boolean} Whether or not the block has a position value set.
|
|
140
|
+
*/
|
|
141
|
+
export function hasPositionValue( props ) {
|
|
142
|
+
return props.attributes.style?.position?.type !== undefined;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Checks if the block is currently set to a sticky or fixed position.
|
|
147
|
+
* This check is helpful for determining how to position block toolbars or other elements.
|
|
148
|
+
*
|
|
149
|
+
* @param {Object} attributes Block attributes.
|
|
150
|
+
* @return {boolean} Whether or not the block is set to a sticky or fixed position.
|
|
151
|
+
*/
|
|
152
|
+
export function hasStickyOrFixedPositionValue( attributes ) {
|
|
153
|
+
const positionType = attributes.style?.position?.type;
|
|
154
|
+
return positionType === 'sticky' || positionType === 'fixed';
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Resets the position block support attributes. This can be used when disabling
|
|
159
|
+
* the position support controls for a block via a `ToolsPanel`.
|
|
160
|
+
*
|
|
161
|
+
* @param {Object} props Block props.
|
|
162
|
+
* @param {Object} props.attributes Block's attributes.
|
|
163
|
+
* @param {Object} props.setAttributes Function to set block's attributes.
|
|
164
|
+
*/
|
|
165
|
+
export function resetPosition( { attributes = {}, setAttributes } ) {
|
|
166
|
+
const { style = {} } = attributes;
|
|
167
|
+
|
|
168
|
+
setAttributes( {
|
|
169
|
+
style: cleanEmptyObject( {
|
|
170
|
+
...style,
|
|
171
|
+
position: {
|
|
172
|
+
...style?.position,
|
|
173
|
+
type: undefined,
|
|
174
|
+
top: undefined,
|
|
175
|
+
right: undefined,
|
|
176
|
+
bottom: undefined,
|
|
177
|
+
left: undefined,
|
|
178
|
+
},
|
|
179
|
+
} ),
|
|
180
|
+
} );
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Custom hook that checks if position settings have been disabled.
|
|
185
|
+
*
|
|
186
|
+
* @param {string} name The name of the block.
|
|
187
|
+
*
|
|
188
|
+
* @return {boolean} Whether padding setting is disabled.
|
|
189
|
+
*/
|
|
190
|
+
export function useIsPositionDisabled( { name: blockName } = {} ) {
|
|
191
|
+
const allowFixed = useSetting( 'position.fixed' );
|
|
192
|
+
const allowSticky = useSetting( 'position.sticky' );
|
|
193
|
+
const isDisabled = ! allowFixed && ! allowSticky;
|
|
194
|
+
|
|
195
|
+
return ! hasPositionSupport( blockName ) || isDisabled;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/*
|
|
199
|
+
* Position controls to be rendered in an inspector control panel.
|
|
200
|
+
*
|
|
201
|
+
* @param {Object} props
|
|
202
|
+
*
|
|
203
|
+
* @return {WPElement} Padding edit element.
|
|
204
|
+
*/
|
|
205
|
+
export function PositionEdit( props ) {
|
|
206
|
+
const {
|
|
207
|
+
attributes: { style = {} },
|
|
208
|
+
name: blockName,
|
|
209
|
+
setAttributes,
|
|
210
|
+
} = props;
|
|
211
|
+
|
|
212
|
+
const allowFixed = hasFixedPositionSupport( blockName );
|
|
213
|
+
const allowSticky = hasStickyPositionSupport( blockName );
|
|
214
|
+
const value = style?.position?.type;
|
|
215
|
+
|
|
216
|
+
const options = useMemo( () => {
|
|
217
|
+
const availableOptions = [ DEFAULT_OPTION ];
|
|
218
|
+
if ( allowSticky || value === STICKY_OPTION.value ) {
|
|
219
|
+
availableOptions.push( STICKY_OPTION );
|
|
220
|
+
}
|
|
221
|
+
if ( allowFixed || value === FIXED_OPTION.value ) {
|
|
222
|
+
availableOptions.push( FIXED_OPTION );
|
|
223
|
+
}
|
|
224
|
+
return availableOptions;
|
|
225
|
+
}, [ allowFixed, allowSticky, value ] );
|
|
226
|
+
|
|
227
|
+
const onChangeType = ( next ) => {
|
|
228
|
+
// For now, use a hard-coded `0px` value for the position.
|
|
229
|
+
// `0px` is preferred over `0` as it can be used in `calc()` functions.
|
|
230
|
+
// In the future, it could be useful to allow for an offset value.
|
|
231
|
+
const placementValue = '0px';
|
|
232
|
+
|
|
233
|
+
const newStyle = {
|
|
234
|
+
...style,
|
|
235
|
+
position: {
|
|
236
|
+
...style?.position,
|
|
237
|
+
type: next,
|
|
238
|
+
top:
|
|
239
|
+
next === 'sticky' || next === 'fixed'
|
|
240
|
+
? placementValue
|
|
241
|
+
: undefined,
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
setAttributes( {
|
|
246
|
+
style: cleanEmptyObject( newStyle ),
|
|
247
|
+
} );
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const selectedOption = value
|
|
251
|
+
? options.find( ( option ) => option.value === value ) || DEFAULT_OPTION
|
|
252
|
+
: DEFAULT_OPTION;
|
|
253
|
+
|
|
254
|
+
return Platform.select( {
|
|
255
|
+
web: (
|
|
256
|
+
<>
|
|
257
|
+
<BaseControl className="block-editor-hooks__position-selection">
|
|
258
|
+
<CustomSelectControl
|
|
259
|
+
__nextUnconstrainedWidth
|
|
260
|
+
__next36pxDefaultSize
|
|
261
|
+
className="block-editor-hooks__position-selection__select-control"
|
|
262
|
+
label={ __( 'Position' ) }
|
|
263
|
+
hideLabelFromVision
|
|
264
|
+
describedBy={ sprintf(
|
|
265
|
+
// translators: %s: Currently selected font size.
|
|
266
|
+
__( 'Currently selected position: %s' ),
|
|
267
|
+
selectedOption.name
|
|
268
|
+
) }
|
|
269
|
+
options={ options }
|
|
270
|
+
value={ selectedOption }
|
|
271
|
+
__experimentalShowSelectedHint
|
|
272
|
+
onChange={ ( { selectedItem } ) => {
|
|
273
|
+
onChangeType( selectedItem.value );
|
|
274
|
+
} }
|
|
275
|
+
size={ '__unstable-large' }
|
|
276
|
+
/>
|
|
277
|
+
</BaseControl>
|
|
278
|
+
</>
|
|
279
|
+
),
|
|
280
|
+
native: null,
|
|
281
|
+
} );
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Override the default edit UI to include position controls.
|
|
286
|
+
*
|
|
287
|
+
* @param {Function} BlockEdit Original component.
|
|
288
|
+
*
|
|
289
|
+
* @return {Function} Wrapped component.
|
|
290
|
+
*/
|
|
291
|
+
export const withInspectorControls = createHigherOrderComponent(
|
|
292
|
+
( BlockEdit ) => ( props ) => {
|
|
293
|
+
const { name: blockName } = props;
|
|
294
|
+
const positionSupport = hasBlockSupport(
|
|
295
|
+
blockName,
|
|
296
|
+
POSITION_SUPPORT_KEY
|
|
297
|
+
);
|
|
298
|
+
const showPositionControls =
|
|
299
|
+
positionSupport && ! useIsPositionDisabled( props );
|
|
300
|
+
|
|
301
|
+
return [
|
|
302
|
+
showPositionControls && (
|
|
303
|
+
<InspectorControls
|
|
304
|
+
key="position"
|
|
305
|
+
__experimentalGroup="position"
|
|
306
|
+
>
|
|
307
|
+
<PositionEdit { ...props } />
|
|
308
|
+
</InspectorControls>
|
|
309
|
+
),
|
|
310
|
+
<BlockEdit key="edit" { ...props } />,
|
|
311
|
+
];
|
|
312
|
+
},
|
|
313
|
+
'withInspectorControls'
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Override the default block element to add the position styles.
|
|
318
|
+
*
|
|
319
|
+
* @param {Function} BlockListBlock Original component.
|
|
320
|
+
*
|
|
321
|
+
* @return {Function} Wrapped component.
|
|
322
|
+
*/
|
|
323
|
+
export const withPositionStyles = createHigherOrderComponent(
|
|
324
|
+
( BlockListBlock ) => ( props ) => {
|
|
325
|
+
const { name, attributes } = props;
|
|
326
|
+
const hasPositionBlockSupport = hasBlockSupport(
|
|
327
|
+
name,
|
|
328
|
+
POSITION_SUPPORT_KEY
|
|
329
|
+
);
|
|
330
|
+
const allowPositionStyles =
|
|
331
|
+
hasPositionBlockSupport && ! useIsPositionDisabled( props );
|
|
332
|
+
|
|
333
|
+
const id = useInstanceId( BlockListBlock );
|
|
334
|
+
const element = useContext( BlockList.__unstableElementContext );
|
|
335
|
+
|
|
336
|
+
// Higher specificity to override defaults in editor UI.
|
|
337
|
+
const positionSelector = `.wp-container-${ id }.wp-container-${ id }`;
|
|
338
|
+
|
|
339
|
+
// Get CSS string for the current position values.
|
|
340
|
+
let css;
|
|
341
|
+
if ( allowPositionStyles ) {
|
|
342
|
+
css =
|
|
343
|
+
getPositionCSS( {
|
|
344
|
+
selector: positionSelector,
|
|
345
|
+
style: attributes?.style,
|
|
346
|
+
} ) || '';
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// Attach a `wp-container-` id-based class name.
|
|
350
|
+
const className = classnames( props?.className, {
|
|
351
|
+
[ `wp-container-${ id }` ]: allowPositionStyles && !! css, // Only attach a container class if there is generated CSS to be attached.
|
|
352
|
+
} );
|
|
353
|
+
|
|
354
|
+
return (
|
|
355
|
+
<>
|
|
356
|
+
{ allowPositionStyles &&
|
|
357
|
+
element &&
|
|
358
|
+
!! css &&
|
|
359
|
+
createPortal( <style>{ css }</style>, element ) }
|
|
360
|
+
<BlockListBlock { ...props } className={ className } />
|
|
361
|
+
</>
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
);
|
|
365
|
+
|
|
366
|
+
addFilter(
|
|
367
|
+
'editor.BlockListBlock',
|
|
368
|
+
'core/editor/position/with-position-styles',
|
|
369
|
+
withPositionStyles
|
|
370
|
+
);
|
|
371
|
+
addFilter(
|
|
372
|
+
'editor.BlockEdit',
|
|
373
|
+
'core/editor/position/with-inspector-controls',
|
|
374
|
+
withInspectorControls
|
|
375
|
+
);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.block-editor-hooks__position-selection__select-control {
|
|
2
|
+
.components-custom-select-control__hint {
|
|
3
|
+
display: none;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.block-editor-hooks__position-selection__select-control__option {
|
|
8
|
+
&.has-hint {
|
|
9
|
+
grid-template-columns: auto 30px;
|
|
10
|
+
line-height: $default-line-height;
|
|
11
|
+
margin-bottom: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.components-custom-select-control__item-hint {
|
|
15
|
+
grid-row: 2;
|
|
16
|
+
text-align: left;
|
|
17
|
+
}
|
|
18
|
+
}
|