@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
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { useSelect
|
|
5
|
-
import { forwardRef
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { forwardRef } from '@wordpress/element';
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { store as blockEditorStore } from '../../store';
|
|
10
10
|
import Inserter from '../inserter';
|
|
11
|
-
import { LinkUI } from './link-ui';
|
|
12
|
-
import { updateAttributes } from './update-attributes';
|
|
13
11
|
|
|
14
12
|
export const Appender = forwardRef( ( props, ref ) => {
|
|
15
|
-
const [ insertedBlock, setInsertedBlock ] = useState();
|
|
16
|
-
|
|
17
13
|
const { hideInserter, clientId } = useSelect( ( select ) => {
|
|
18
14
|
const {
|
|
19
15
|
getTemplateLock,
|
|
@@ -31,61 +27,20 @@ export const Appender = forwardRef( ( props, ref ) => {
|
|
|
31
27
|
};
|
|
32
28
|
}, [] );
|
|
33
29
|
|
|
34
|
-
const { insertedBlockAttributes } = useSelect(
|
|
35
|
-
( select ) => {
|
|
36
|
-
const { getBlockAttributes } = select( blockEditorStore );
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
insertedBlockAttributes: getBlockAttributes( insertedBlock ),
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
[ insertedBlock ]
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
46
|
-
|
|
47
|
-
const setAttributes =
|
|
48
|
-
( insertedBlockClientId ) => ( _updatedAttributes ) => {
|
|
49
|
-
updateBlockAttributes( insertedBlockClientId, _updatedAttributes );
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
let maybeLinkUI;
|
|
53
|
-
|
|
54
|
-
if ( insertedBlock ) {
|
|
55
|
-
maybeLinkUI = (
|
|
56
|
-
<LinkUI
|
|
57
|
-
clientId={ insertedBlock }
|
|
58
|
-
link={ insertedBlockAttributes }
|
|
59
|
-
onClose={ () => setInsertedBlock( null ) }
|
|
60
|
-
hasCreateSuggestion={ false }
|
|
61
|
-
onChange={ ( updatedValue ) => {
|
|
62
|
-
updateAttributes(
|
|
63
|
-
updatedValue,
|
|
64
|
-
setAttributes( insertedBlock ),
|
|
65
|
-
insertedBlockAttributes
|
|
66
|
-
);
|
|
67
|
-
setInsertedBlock( null );
|
|
68
|
-
} }
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
30
|
if ( hideInserter ) {
|
|
74
31
|
return null;
|
|
75
32
|
}
|
|
76
33
|
|
|
77
34
|
return (
|
|
78
35
|
<div className="offcanvas-editor__appender">
|
|
79
|
-
{ maybeLinkUI }
|
|
80
36
|
<Inserter
|
|
81
37
|
ref={ ref }
|
|
82
38
|
rootClientId={ clientId }
|
|
83
39
|
position="bottom right"
|
|
84
40
|
isAppender={ true }
|
|
85
41
|
selectBlockOnInsert={ false }
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
} }
|
|
42
|
+
shouldDirectInsert={ false }
|
|
43
|
+
__experimentalIsQuick
|
|
89
44
|
{ ...props }
|
|
90
45
|
/>
|
|
91
46
|
</div>
|
|
@@ -7,7 +7,7 @@ import classnames from 'classnames';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useSelect } from '@wordpress/data';
|
|
10
|
-
import { forwardRef } from '@wordpress/element';
|
|
10
|
+
import { forwardRef, useEffect, useState } from '@wordpress/element';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
@@ -15,6 +15,14 @@ import { forwardRef } from '@wordpress/element';
|
|
|
15
15
|
import ListViewBlockSelectButton from './block-select-button';
|
|
16
16
|
import BlockDraggable from '../block-draggable';
|
|
17
17
|
import { store as blockEditorStore } from '../../store';
|
|
18
|
+
import { updateAttributes } from './update-attributes';
|
|
19
|
+
import { LinkUI } from './link-ui';
|
|
20
|
+
import { useInsertedBlock } from './use-inserted-block';
|
|
21
|
+
|
|
22
|
+
const BLOCKS_WITH_LINK_UI_SUPPORT = [
|
|
23
|
+
'core/navigation-link',
|
|
24
|
+
'core/navigation-submenu',
|
|
25
|
+
];
|
|
18
26
|
|
|
19
27
|
const ListViewBlockContents = forwardRef(
|
|
20
28
|
(
|
|
@@ -33,19 +41,54 @@ const ListViewBlockContents = forwardRef(
|
|
|
33
41
|
ref
|
|
34
42
|
) => {
|
|
35
43
|
const { clientId } = block;
|
|
36
|
-
|
|
37
|
-
const {
|
|
44
|
+
const [ isLinkUIOpen, setIsLinkUIOpen ] = useState();
|
|
45
|
+
const {
|
|
46
|
+
blockMovingClientId,
|
|
47
|
+
selectedBlockInBlockEditor,
|
|
48
|
+
lastInsertedBlockClientId,
|
|
49
|
+
} = useSelect(
|
|
38
50
|
( select ) => {
|
|
39
|
-
const {
|
|
40
|
-
|
|
51
|
+
const {
|
|
52
|
+
hasBlockMovingClientId,
|
|
53
|
+
getSelectedBlockClientId,
|
|
54
|
+
getLastInsertedBlocksClientIds,
|
|
55
|
+
} = select( blockEditorStore );
|
|
56
|
+
const lastInsertedBlocksClientIds =
|
|
57
|
+
getLastInsertedBlocksClientIds();
|
|
41
58
|
return {
|
|
42
59
|
blockMovingClientId: hasBlockMovingClientId(),
|
|
43
60
|
selectedBlockInBlockEditor: getSelectedBlockClientId(),
|
|
61
|
+
lastInsertedBlockClientId:
|
|
62
|
+
lastInsertedBlocksClientIds &&
|
|
63
|
+
lastInsertedBlocksClientIds[ 0 ],
|
|
44
64
|
};
|
|
45
65
|
},
|
|
46
66
|
[ clientId ]
|
|
47
67
|
);
|
|
48
68
|
|
|
69
|
+
const {
|
|
70
|
+
insertedBlockAttributes,
|
|
71
|
+
insertedBlockName,
|
|
72
|
+
setInsertedBlockAttributes,
|
|
73
|
+
} = useInsertedBlock( lastInsertedBlockClientId );
|
|
74
|
+
|
|
75
|
+
const hasExistingLinkValue = insertedBlockAttributes?.id;
|
|
76
|
+
|
|
77
|
+
useEffect( () => {
|
|
78
|
+
if (
|
|
79
|
+
clientId === lastInsertedBlockClientId &&
|
|
80
|
+
BLOCKS_WITH_LINK_UI_SUPPORT?.includes( insertedBlockName ) &&
|
|
81
|
+
! hasExistingLinkValue // don't re-show the Link UI if the block already has a link value.
|
|
82
|
+
) {
|
|
83
|
+
setIsLinkUIOpen( true );
|
|
84
|
+
}
|
|
85
|
+
}, [
|
|
86
|
+
lastInsertedBlockClientId,
|
|
87
|
+
clientId,
|
|
88
|
+
insertedBlockName,
|
|
89
|
+
hasExistingLinkValue,
|
|
90
|
+
] );
|
|
91
|
+
|
|
49
92
|
const isBlockMoveTarget =
|
|
50
93
|
blockMovingClientId && selectedBlockInBlockEditor === clientId;
|
|
51
94
|
|
|
@@ -62,26 +105,44 @@ const ListViewBlockContents = forwardRef(
|
|
|
62
105
|
: [ clientId ];
|
|
63
106
|
|
|
64
107
|
return (
|
|
65
|
-
|
|
66
|
-
{
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
isExpanded={ isExpanded }
|
|
81
|
-
{ ...props }
|
|
108
|
+
<>
|
|
109
|
+
{ isLinkUIOpen && (
|
|
110
|
+
<LinkUI
|
|
111
|
+
clientId={ lastInsertedBlockClientId }
|
|
112
|
+
link={ insertedBlockAttributes }
|
|
113
|
+
onClose={ () => setIsLinkUIOpen( false ) }
|
|
114
|
+
hasCreateSuggestion={ false }
|
|
115
|
+
onChange={ ( updatedValue ) => {
|
|
116
|
+
updateAttributes(
|
|
117
|
+
updatedValue,
|
|
118
|
+
setInsertedBlockAttributes,
|
|
119
|
+
insertedBlockAttributes
|
|
120
|
+
);
|
|
121
|
+
setIsLinkUIOpen( false );
|
|
122
|
+
} }
|
|
82
123
|
/>
|
|
83
124
|
) }
|
|
84
|
-
|
|
125
|
+
<BlockDraggable clientIds={ draggableClientIds }>
|
|
126
|
+
{ ( { draggable, onDragStart, onDragEnd } ) => (
|
|
127
|
+
<ListViewBlockSelectButton
|
|
128
|
+
ref={ ref }
|
|
129
|
+
className={ className }
|
|
130
|
+
block={ block }
|
|
131
|
+
onClick={ onClick }
|
|
132
|
+
onToggleExpanded={ onToggleExpanded }
|
|
133
|
+
isSelected={ isSelected }
|
|
134
|
+
position={ position }
|
|
135
|
+
siblingBlockCount={ siblingBlockCount }
|
|
136
|
+
level={ level }
|
|
137
|
+
draggable={ draggable }
|
|
138
|
+
onDragStart={ onDragStart }
|
|
139
|
+
onDragEnd={ onDragEnd }
|
|
140
|
+
isExpanded={ isExpanded }
|
|
141
|
+
{ ...props }
|
|
142
|
+
/>
|
|
143
|
+
) }
|
|
144
|
+
</BlockDraggable>
|
|
145
|
+
</>
|
|
85
146
|
);
|
|
86
147
|
}
|
|
87
148
|
);
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
__experimentalTruncate as Truncate,
|
|
13
13
|
} from '@wordpress/components';
|
|
14
14
|
import { forwardRef } from '@wordpress/element';
|
|
15
|
-
import { Icon, lock } from '@wordpress/icons';
|
|
15
|
+
import { Icon, lockSmall as lock } from '@wordpress/icons';
|
|
16
16
|
import { SPACE, ENTER } from '@wordpress/keycodes';
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -79,7 +79,11 @@ function ListViewBlockSelectButton(
|
|
|
79
79
|
aria-hidden={ true }
|
|
80
80
|
>
|
|
81
81
|
<ListViewExpander onClick={ onToggleExpanded } />
|
|
82
|
-
<BlockIcon
|
|
82
|
+
<BlockIcon
|
|
83
|
+
icon={ blockInformation?.icon }
|
|
84
|
+
showColors
|
|
85
|
+
context="list-view"
|
|
86
|
+
/>
|
|
83
87
|
<HStack
|
|
84
88
|
alignment="center"
|
|
85
89
|
className="block-editor-list-view-block-select-button__label-wrapper"
|
|
@@ -6,11 +6,10 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { hasBlockSupport } from '@wordpress/blocks';
|
|
10
10
|
import {
|
|
11
11
|
__experimentalTreeGridCell as TreeGridCell,
|
|
12
12
|
__experimentalTreeGridItem as TreeGridItem,
|
|
13
|
-
MenuItem,
|
|
14
13
|
} from '@wordpress/components';
|
|
15
14
|
import { useInstanceId } from '@wordpress/compose';
|
|
16
15
|
import { moreVertical } from '@wordpress/icons';
|
|
@@ -42,7 +41,7 @@ import useBlockDisplayInformation from '../use-block-display-information';
|
|
|
42
41
|
import { useBlockLock } from '../block-lock';
|
|
43
42
|
|
|
44
43
|
function ListViewBlock( {
|
|
45
|
-
block,
|
|
44
|
+
block: { clientId },
|
|
46
45
|
isDragged,
|
|
47
46
|
isSelected,
|
|
48
47
|
isBranchSelected,
|
|
@@ -60,7 +59,6 @@ function ListViewBlock( {
|
|
|
60
59
|
} ) {
|
|
61
60
|
const cellRef = useRef( null );
|
|
62
61
|
const [ isHovered, setIsHovered ] = useState( false );
|
|
63
|
-
const { clientId, attributes } = block;
|
|
64
62
|
|
|
65
63
|
const { isLocked, isContentLocked } = useBlockLock( clientId );
|
|
66
64
|
const forceSelectionContentLock = useSelect(
|
|
@@ -87,24 +85,77 @@ function ListViewBlock( {
|
|
|
87
85
|
( isSelected &&
|
|
88
86
|
selectedClientIds[ selectedClientIds.length - 1 ] === clientId );
|
|
89
87
|
|
|
90
|
-
const {
|
|
91
|
-
useDispatch( blockEditorStore );
|
|
88
|
+
const { toggleBlockHighlight } = useDispatch( blockEditorStore );
|
|
92
89
|
|
|
93
90
|
const blockInformation = useBlockDisplayInformation( clientId );
|
|
94
|
-
const
|
|
95
|
-
( select ) => select( blockEditorStore ).
|
|
91
|
+
const block = useSelect(
|
|
92
|
+
( select ) => select( blockEditorStore ).getBlock( clientId ),
|
|
96
93
|
[ clientId ]
|
|
97
94
|
);
|
|
98
95
|
|
|
96
|
+
// If ListView has experimental features related to the Persistent List View,
|
|
97
|
+
// only focus the selected list item on mount; otherwise the list would always
|
|
98
|
+
// try to steal the focus from the editor canvas.
|
|
99
|
+
useEffect( () => {
|
|
100
|
+
if ( ! isTreeGridMounted && isSelected ) {
|
|
101
|
+
cellRef.current.focus();
|
|
102
|
+
}
|
|
103
|
+
}, [] );
|
|
104
|
+
|
|
105
|
+
const onMouseEnter = useCallback( () => {
|
|
106
|
+
setIsHovered( true );
|
|
107
|
+
toggleBlockHighlight( clientId, true );
|
|
108
|
+
}, [ clientId, setIsHovered, toggleBlockHighlight ] );
|
|
109
|
+
const onMouseLeave = useCallback( () => {
|
|
110
|
+
setIsHovered( false );
|
|
111
|
+
toggleBlockHighlight( clientId, false );
|
|
112
|
+
}, [ clientId, setIsHovered, toggleBlockHighlight ] );
|
|
113
|
+
|
|
114
|
+
const selectEditorBlock = useCallback(
|
|
115
|
+
( event ) => {
|
|
116
|
+
selectBlock( event, clientId );
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
},
|
|
119
|
+
[ clientId, selectBlock ]
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const updateSelection = useCallback(
|
|
123
|
+
( newClientId ) => {
|
|
124
|
+
selectBlock( undefined, newClientId );
|
|
125
|
+
},
|
|
126
|
+
[ selectBlock ]
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const { isTreeGridMounted, expand, collapse, LeafMoreMenu } =
|
|
130
|
+
useListViewContext();
|
|
131
|
+
|
|
132
|
+
const toggleExpanded = useCallback(
|
|
133
|
+
( event ) => {
|
|
134
|
+
// Prevent shift+click from opening link in a new window when toggling.
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
event.stopPropagation();
|
|
137
|
+
if ( isExpanded === true ) {
|
|
138
|
+
collapse( clientId );
|
|
139
|
+
} else if ( isExpanded === false ) {
|
|
140
|
+
expand( clientId );
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
[ clientId, expand, collapse, isExpanded ]
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
const instanceId = useInstanceId( ListViewBlock );
|
|
147
|
+
|
|
148
|
+
if ( ! block ) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
|
|
99
152
|
// When a block hides its toolbar it also hides the block settings menu,
|
|
100
153
|
// since that menu is part of the toolbar in the editor canvas.
|
|
101
154
|
// List View respects this by also hiding the block settings menu.
|
|
102
|
-
const showBlockActions =
|
|
103
|
-
|
|
104
|
-
'__experimentalToolbar',
|
|
105
|
-
|
|
106
|
-
);
|
|
107
|
-
const instanceId = useInstanceId( ListViewBlock );
|
|
155
|
+
const showBlockActions =
|
|
156
|
+
!! block &&
|
|
157
|
+
hasBlockSupport( block.name, '__experimentalToolbar', true );
|
|
158
|
+
|
|
108
159
|
const descriptionId = `list-view-block-select-button__${ instanceId }`;
|
|
109
160
|
const blockPositionDescription = getBlockPositionDescription(
|
|
110
161
|
position,
|
|
@@ -143,9 +194,7 @@ function ListViewBlock( {
|
|
|
143
194
|
)
|
|
144
195
|
: __( 'Edit' );
|
|
145
196
|
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
const isEditable = block.name !== 'core/page-list-item';
|
|
197
|
+
const isEditable = !! block && block.name !== 'core/page-list-item';
|
|
149
198
|
const hasSiblings = siblingBlockCount > 0;
|
|
150
199
|
const hasRenderedMovers = showBlockMovers && hasSiblings;
|
|
151
200
|
const moverCellClassName = classnames(
|
|
@@ -163,53 +212,6 @@ function ListViewBlock( {
|
|
|
163
212
|
{ 'is-visible': isHovered || isFirstSelectedBlock }
|
|
164
213
|
);
|
|
165
214
|
|
|
166
|
-
// If ListView has experimental features related to the Persistent List View,
|
|
167
|
-
// only focus the selected list item on mount; otherwise the list would always
|
|
168
|
-
// try to steal the focus from the editor canvas.
|
|
169
|
-
useEffect( () => {
|
|
170
|
-
if ( ! isTreeGridMounted && isSelected ) {
|
|
171
|
-
cellRef.current.focus();
|
|
172
|
-
}
|
|
173
|
-
}, [] );
|
|
174
|
-
|
|
175
|
-
const onMouseEnter = useCallback( () => {
|
|
176
|
-
setIsHovered( true );
|
|
177
|
-
toggleBlockHighlight( clientId, true );
|
|
178
|
-
}, [ clientId, setIsHovered, toggleBlockHighlight ] );
|
|
179
|
-
const onMouseLeave = useCallback( () => {
|
|
180
|
-
setIsHovered( false );
|
|
181
|
-
toggleBlockHighlight( clientId, false );
|
|
182
|
-
}, [ clientId, setIsHovered, toggleBlockHighlight ] );
|
|
183
|
-
|
|
184
|
-
const selectEditorBlock = useCallback(
|
|
185
|
-
( event ) => {
|
|
186
|
-
selectBlock( event, clientId );
|
|
187
|
-
event.preventDefault();
|
|
188
|
-
},
|
|
189
|
-
[ clientId, selectBlock ]
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
const updateSelection = useCallback(
|
|
193
|
-
( newClientId ) => {
|
|
194
|
-
selectBlock( undefined, newClientId );
|
|
195
|
-
},
|
|
196
|
-
[ selectBlock ]
|
|
197
|
-
);
|
|
198
|
-
|
|
199
|
-
const toggleExpanded = useCallback(
|
|
200
|
-
( event ) => {
|
|
201
|
-
// Prevent shift+click from opening link in a new window when toggling.
|
|
202
|
-
event.preventDefault();
|
|
203
|
-
event.stopPropagation();
|
|
204
|
-
if ( isExpanded === true ) {
|
|
205
|
-
collapse( clientId );
|
|
206
|
-
} else if ( isExpanded === false ) {
|
|
207
|
-
expand( clientId );
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
[ clientId, expand, collapse, isExpanded ]
|
|
211
|
-
);
|
|
212
|
-
|
|
213
215
|
let colSpan;
|
|
214
216
|
if ( hasRenderedMovers ) {
|
|
215
217
|
colSpan = 2;
|
|
@@ -234,6 +236,10 @@ function ListViewBlock( {
|
|
|
234
236
|
? selectedClientIds
|
|
235
237
|
: [ clientId ];
|
|
236
238
|
|
|
239
|
+
const MoreMenuComponent = LeafMoreMenu
|
|
240
|
+
? LeafMoreMenu
|
|
241
|
+
: BlockSettingsDropdown;
|
|
242
|
+
|
|
237
243
|
return (
|
|
238
244
|
<ListViewLeaf
|
|
239
245
|
className={ classes }
|
|
@@ -349,47 +355,26 @@ function ListViewBlock( {
|
|
|
349
355
|
colSpan={ isEditable ? 1 : 2 } // When an item is not editable then we don't output the cell for the edit button, so we need to adjust the colspan so that the HTML is valid.
|
|
350
356
|
>
|
|
351
357
|
{ ( { ref, tabIndex, onFocus } ) => (
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
const newSubmenu = createBlock(
|
|
373
|
-
'core/navigation-submenu',
|
|
374
|
-
attributes,
|
|
375
|
-
block.innerBlocks
|
|
376
|
-
? [
|
|
377
|
-
...block.innerBlocks,
|
|
378
|
-
newLink,
|
|
379
|
-
]
|
|
380
|
-
: [ newLink ]
|
|
381
|
-
);
|
|
382
|
-
replaceBlock(
|
|
383
|
-
clientId,
|
|
384
|
-
newSubmenu
|
|
385
|
-
);
|
|
386
|
-
onClose();
|
|
387
|
-
} }
|
|
388
|
-
>
|
|
389
|
-
{ __( 'Add a submenu item' ) }
|
|
390
|
-
</MenuItem>
|
|
391
|
-
) }
|
|
392
|
-
</BlockSettingsDropdown>
|
|
358
|
+
<>
|
|
359
|
+
<MoreMenuComponent
|
|
360
|
+
clientIds={ dropdownClientIds }
|
|
361
|
+
block={ block }
|
|
362
|
+
clientId={ clientId }
|
|
363
|
+
icon={ moreVertical }
|
|
364
|
+
label={ settingsAriaLabel }
|
|
365
|
+
toggleProps={ {
|
|
366
|
+
ref,
|
|
367
|
+
className:
|
|
368
|
+
'block-editor-list-view-block__menu',
|
|
369
|
+
tabIndex,
|
|
370
|
+
onFocus,
|
|
371
|
+
} }
|
|
372
|
+
disableOpenOnArrowDown
|
|
373
|
+
__experimentalSelectBlock={
|
|
374
|
+
updateSelection
|
|
375
|
+
}
|
|
376
|
+
/>
|
|
377
|
+
</>
|
|
393
378
|
) }
|
|
394
379
|
</TreeGridCell>
|
|
395
380
|
</>
|
|
@@ -60,7 +60,8 @@ export const BLOCK_LIST_ITEM_HEIGHT = 36;
|
|
|
60
60
|
* @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.
|
|
61
61
|
* @param {boolean} props.showBlockMovers Flag to enable block movers
|
|
62
62
|
* @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.
|
|
63
|
-
* @param {boolean} props.selectBlockInCanvas Flag to determine whether the list view should be a block selection mechanism
|
|
63
|
+
* @param {boolean} props.selectBlockInCanvas Flag to determine whether the list view should be a block selection mechanism.
|
|
64
|
+
* @param {Object} props.LeafMoreMenu Optional more menu substitution.
|
|
64
65
|
* @param {Object} ref Forwarded ref
|
|
65
66
|
*/
|
|
66
67
|
function __ExperimentalOffCanvasEditor(
|
|
@@ -70,6 +71,7 @@ function __ExperimentalOffCanvasEditor(
|
|
|
70
71
|
showBlockMovers = false,
|
|
71
72
|
isExpanded = false,
|
|
72
73
|
selectBlockInCanvas = true,
|
|
74
|
+
LeafMoreMenu,
|
|
73
75
|
},
|
|
74
76
|
ref
|
|
75
77
|
) {
|
|
@@ -188,8 +190,16 @@ function __ExperimentalOffCanvasEditor(
|
|
|
188
190
|
expandedState,
|
|
189
191
|
expand,
|
|
190
192
|
collapse,
|
|
193
|
+
LeafMoreMenu,
|
|
191
194
|
} ),
|
|
192
|
-
[
|
|
195
|
+
[
|
|
196
|
+
isMounted.current,
|
|
197
|
+
draggedClientIds,
|
|
198
|
+
expandedState,
|
|
199
|
+
expand,
|
|
200
|
+
collapse,
|
|
201
|
+
LeafMoreMenu,
|
|
202
|
+
]
|
|
193
203
|
);
|
|
194
204
|
|
|
195
205
|
return (
|
|
@@ -231,6 +241,15 @@ function __ExperimentalOffCanvasEditor(
|
|
|
231
241
|
<Appender { ...treeGridCellProps } />
|
|
232
242
|
) }
|
|
233
243
|
</TreeGridCell>
|
|
244
|
+
{ ! clientIdsTree.length && (
|
|
245
|
+
<TreeGridCell withoutGridItem>
|
|
246
|
+
<div className="offcanvas-editor-list-view-is-empty">
|
|
247
|
+
{ __(
|
|
248
|
+
'Your menu is currently empty. Add your first menu item to get started.'
|
|
249
|
+
) }
|
|
250
|
+
</div>
|
|
251
|
+
</TreeGridCell>
|
|
252
|
+
) }
|
|
234
253
|
</TreeGridRow>
|
|
235
254
|
</ListViewContext.Provider>
|
|
236
255
|
</TreeGrid>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.offcanvas-editor__appender .block-editor-inserter__toggle {
|
|
2
2
|
background-color: #1e1e1e;
|
|
3
3
|
color: #fff;
|
|
4
|
-
margin: $grid-unit-10 0 0
|
|
4
|
+
margin: $grid-unit-10 0 0 24px;
|
|
5
5
|
border-radius: 2px;
|
|
6
6
|
height: 24px;
|
|
7
7
|
min-width: 24px;
|
|
@@ -24,3 +24,7 @@
|
|
|
24
24
|
// sidebar width - tab panel padding
|
|
25
25
|
max-width: $sidebar-width - (2 * $grid-unit-20);
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
.offcanvas-editor-list-view-is-empty {
|
|
29
|
+
margin-left: $grid-unit-20;
|
|
30
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useInsertedBlock } from '../use-inserted-block';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* External dependencies
|
|
13
|
+
*/
|
|
14
|
+
import { act, renderHook } from '@testing-library/react';
|
|
15
|
+
|
|
16
|
+
jest.mock( '@wordpress/data/src/components/use-select', () => {
|
|
17
|
+
// This allows us to tweak the returned value on each test.
|
|
18
|
+
const mock = jest.fn();
|
|
19
|
+
return mock;
|
|
20
|
+
} );
|
|
21
|
+
|
|
22
|
+
jest.mock( '@wordpress/data/src/components/use-dispatch', () => ( {
|
|
23
|
+
useDispatch: jest.fn(),
|
|
24
|
+
} ) );
|
|
25
|
+
|
|
26
|
+
describe( 'useInsertedBlock', () => {
|
|
27
|
+
const mockUpdateBlockAttributes = jest.fn();
|
|
28
|
+
|
|
29
|
+
it( 'returns undefined values when called without a block clientId', () => {
|
|
30
|
+
useSelect.mockImplementation( () => ( {
|
|
31
|
+
insertedBlockAttributes: {
|
|
32
|
+
'some-attribute': 'some-value',
|
|
33
|
+
},
|
|
34
|
+
insertedBlockName: 'core/navigation-link',
|
|
35
|
+
} ) );
|
|
36
|
+
|
|
37
|
+
useDispatch.mockImplementation( () => ( {
|
|
38
|
+
updateBlockAttributes: mockUpdateBlockAttributes,
|
|
39
|
+
} ) );
|
|
40
|
+
|
|
41
|
+
const { result } = renderHook( () => useInsertedBlock() );
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
insertedBlockName,
|
|
45
|
+
insertedBlockAttributes,
|
|
46
|
+
setInsertedBlockAttributes,
|
|
47
|
+
} = result.current;
|
|
48
|
+
|
|
49
|
+
expect( insertedBlockName ).toBeUndefined();
|
|
50
|
+
expect( insertedBlockAttributes ).toBeUndefined();
|
|
51
|
+
expect(
|
|
52
|
+
setInsertedBlockAttributes( { 'some-attribute': 'new-value' } )
|
|
53
|
+
).toBeUndefined();
|
|
54
|
+
} );
|
|
55
|
+
|
|
56
|
+
it( 'returns name and attributes when called with a block clientId', () => {
|
|
57
|
+
useSelect.mockImplementation( () => ( {
|
|
58
|
+
insertedBlockAttributes: {
|
|
59
|
+
'some-attribute': 'some-value',
|
|
60
|
+
},
|
|
61
|
+
insertedBlockName: 'core/navigation-link',
|
|
62
|
+
} ) );
|
|
63
|
+
|
|
64
|
+
useDispatch.mockImplementation( () => ( {
|
|
65
|
+
updateBlockAttributes: mockUpdateBlockAttributes,
|
|
66
|
+
} ) );
|
|
67
|
+
|
|
68
|
+
const { result } = renderHook( () =>
|
|
69
|
+
useInsertedBlock( 'some-client-id-here' )
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const { insertedBlockName, insertedBlockAttributes } = result.current;
|
|
73
|
+
|
|
74
|
+
expect( insertedBlockName ).toBe( 'core/navigation-link' );
|
|
75
|
+
expect( insertedBlockAttributes ).toEqual( {
|
|
76
|
+
'some-attribute': 'some-value',
|
|
77
|
+
} );
|
|
78
|
+
} );
|
|
79
|
+
|
|
80
|
+
it( 'dispatches updateBlockAttributes on provided client ID with new attributes when setInsertedBlockAttributes is called', () => {
|
|
81
|
+
useSelect.mockImplementation( () => ( {
|
|
82
|
+
insertedBlockAttributes: {
|
|
83
|
+
'some-attribute': 'some-value',
|
|
84
|
+
},
|
|
85
|
+
insertedBlockName: 'core/navigation-link',
|
|
86
|
+
} ) );
|
|
87
|
+
|
|
88
|
+
useDispatch.mockImplementation( () => ( {
|
|
89
|
+
updateBlockAttributes: mockUpdateBlockAttributes,
|
|
90
|
+
} ) );
|
|
91
|
+
|
|
92
|
+
const clientId = '123456789';
|
|
93
|
+
|
|
94
|
+
const { result } = renderHook( () => useInsertedBlock( clientId ) );
|
|
95
|
+
|
|
96
|
+
const { setInsertedBlockAttributes } = result.current;
|
|
97
|
+
|
|
98
|
+
act( () => {
|
|
99
|
+
setInsertedBlockAttributes( {
|
|
100
|
+
'some-attribute': 'new-value',
|
|
101
|
+
} );
|
|
102
|
+
} );
|
|
103
|
+
|
|
104
|
+
expect( mockUpdateBlockAttributes ).toHaveBeenCalledWith( clientId, {
|
|
105
|
+
'some-attribute': 'new-value',
|
|
106
|
+
} );
|
|
107
|
+
} );
|
|
108
|
+
} );
|