@wordpress/block-editor 8.4.0 → 8.5.2
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 +2 -0
- package/README.md +56 -19
- package/build/components/alignment-control/index.js +13 -6
- package/build/components/alignment-control/index.js.map +1 -1
- package/build/components/block-alignment-control/index.js +13 -6
- package/build/components/block-alignment-control/index.js.map +1 -1
- package/build/components/block-alignment-control/ui.js +1 -1
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-content-overlay/index.js +13 -4
- package/build/components/block-content-overlay/index.js.map +1 -1
- package/build/components/block-draggable/index.js +2 -3
- package/build/components/block-draggable/index.js.map +1 -1
- package/build/components/block-icon/index.js +4 -0
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +6 -1
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +1 -6
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-first-element.js +14 -17
- package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build/components/block-list/use-block-props/use-focus-handler.js +7 -1
- package/build/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
- package/build/components/block-list-appender/index.js +6 -1
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-lock/index.js +8 -0
- package/build/components/block-lock/index.js.map +1 -1
- package/build/components/block-lock/menu-item.js +9 -15
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +35 -23
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +11 -16
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-lock/use-block-lock.js +50 -0
- package/build/components/block-lock/use-block-lock.js.map +1 -0
- package/build/components/block-mover/index.js +4 -0
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +37 -22
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-preview/auto.js +6 -3
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +4 -2
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +50 -5
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-switcher/index.js +8 -3
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-title/index.js +2 -2
- package/build/components/block-title/index.js.map +1 -1
- package/build/components/block-title/use-block-display-title.js +1 -1
- package/build/components/block-title/use-block-display-title.js.map +1 -1
- package/build/components/block-toolbar/block-name-context.js +17 -0
- package/build/components/block-toolbar/block-name-context.js.map +1 -0
- package/build/components/block-toolbar/block-toolbar-last-item.js +20 -0
- package/build/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
- package/build/components/block-toolbar/index.js +20 -5
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/index.js +0 -16
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +92 -47
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/block-vertical-alignment-control/index.js +13 -6
- package/build/components/block-vertical-alignment-control/index.js.map +1 -1
- package/build/components/contrast-checker/index.js +4 -0
- package/build/components/contrast-checker/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/index.js +8 -0
- package/build/components/convert-to-group-buttons/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +105 -0
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -0
- package/build/components/copy-handler/index.js +48 -9
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/font-sizes/font-size-picker.js +4 -0
- package/build/components/font-sizes/font-size-picker.js.map +1 -1
- package/build/components/iframe/index.js +6 -9
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +18 -0
- package/build/components/index.js.map +1 -1
- package/build/components/justify-content-control/index.js +13 -6
- package/build/components/justify-content-control/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/line-height-control/index.js +10 -3
- package/build/components/line-height-control/index.js.map +1 -1
- package/build/components/link-control/index.js +6 -7
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +19 -6
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +18 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/branch.js +1 -1
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/media-replace-flow/index.js +4 -0
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/multi-selection-inspector/index.js +1 -1
- package/build/components/multi-selection-inspector/index.js.map +1 -1
- package/build/components/rich-text/index.js +26 -4
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/split-value.js +12 -2
- package/build/components/rich-text/split-value.js.map +1 -1
- package/build/components/rich-text/use-firefox-compat.js +49 -0
- package/build/components/rich-text/use-firefox-compat.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +34 -2
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/skip-to-selected-block/index.js +4 -0
- package/build/components/skip-to-selected-block/index.js.map +1 -1
- package/build/components/writing-flow/index.js +9 -1
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +3 -44
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-click-selection.js +68 -0
- package/build/components/writing-flow/use-click-selection.js.map +1 -0
- package/build/components/writing-flow/use-drag-selection.js +134 -0
- package/build/components/writing-flow/use-drag-selection.js.map +1 -0
- package/build/components/writing-flow/use-input.js +116 -0
- package/build/components/writing-flow/use-input.js.map +1 -0
- package/build/components/writing-flow/use-multi-selection.js +18 -38
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +161 -0
- package/build/components/writing-flow/use-selection-observer.js.map +1 -0
- package/build/components/writing-flow/use-tab-nav.js +1 -8
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/border-color.js +3 -3
- package/build/hooks/border-color.js.map +1 -1
- package/build/hooks/border.js +0 -14
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +20 -17
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/font-family.js +5 -1
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +4 -2
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/gap.js +23 -16
- package/build/hooks/gap.js.map +1 -1
- package/build/hooks/layout.js +7 -2
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/style.js +34 -3
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +29 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/flex.js +76 -12
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +9 -4
- package/build/layouts/flow.js.map +1 -1
- package/build/store/actions.js +290 -51
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +5 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/reducer.js +25 -13
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +264 -21
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +27 -0
- package/build/store/utils.js.map +1 -0
- package/build/utils/dom.js +2 -1
- package/build/utils/dom.js.map +1 -1
- package/build-module/components/alignment-control/index.js +12 -4
- package/build-module/components/alignment-control/index.js.map +1 -1
- package/build-module/components/block-alignment-control/index.js +12 -4
- package/build-module/components/block-alignment-control/index.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.js +2 -2
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-content-overlay/index.js +13 -4
- package/build-module/components/block-content-overlay/index.js.map +1 -1
- package/build-module/components/block-draggable/index.js +2 -3
- package/build-module/components/block-draggable/index.js.map +1 -1
- package/build-module/components/block-icon/index.js +4 -0
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +6 -1
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +1 -4
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js +15 -17
- package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-focus-handler.js +7 -1
- package/build-module/components/block-list/use-block-props/use-focus-handler.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +6 -1
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-lock/index.js +1 -0
- package/build-module/components/block-lock/index.js.map +1 -1
- package/build-module/components/block-lock/menu-item.js +8 -13
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +34 -24
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +10 -14
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- package/build-module/components/block-lock/use-block-lock.js +41 -0
- package/build-module/components/block-lock/use-block-lock.js.map +1 -0
- package/build-module/components/block-mover/index.js +4 -0
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +39 -24
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-preview/auto.js +6 -3
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +4 -2
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +50 -7
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-switcher/index.js +9 -4
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-title/index.js +2 -2
- package/build-module/components/block-title/index.js.map +1 -1
- package/build-module/components/block-title/use-block-display-title.js +1 -1
- package/build-module/components/block-title/use-block-display-title.js.map +1 -1
- package/build-module/components/block-toolbar/block-name-context.js +9 -0
- package/build-module/components/block-toolbar/block-name-context.js.map +1 -0
- package/build-module/components/block-toolbar/block-toolbar-last-item.js +11 -0
- package/build-module/components/block-toolbar/block-toolbar-last-item.js.map +1 -0
- package/build-module/components/block-toolbar/index.js +16 -4
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/index.js +0 -16
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +95 -49
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/index.js +12 -4
- package/build-module/components/block-vertical-alignment-control/index.js.map +1 -1
- package/build-module/components/contrast-checker/index.js +4 -0
- package/build-module/components/contrast-checker/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.js +2 -1
- package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +90 -0
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -0
- package/build-module/components/copy-handler/index.js +48 -9
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/font-sizes/font-size-picker.js +4 -0
- package/build-module/components/font-sizes/font-size-picker.js.map +1 -1
- package/build-module/components/iframe/index.js +6 -9
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +2 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/justify-content-control/index.js +12 -4
- package/build-module/components/justify-content-control/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/line-height-control/index.js +9 -2
- package/build-module/components/line-height-control/index.js.map +1 -1
- package/build-module/components/link-control/index.js +6 -7
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +17 -6
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +18 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/branch.js +1 -1
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +4 -0
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/multi-selection-inspector/index.js +2 -2
- package/build-module/components/multi-selection-inspector/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +25 -4
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/split-value.js +12 -2
- package/build-module/components/rich-text/split-value.js.map +1 -1
- package/build-module/components/rich-text/use-firefox-compat.js +39 -0
- package/build-module/components/rich-text/use-firefox-compat.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +35 -4
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/skip-to-selected-block/index.js +4 -0
- package/build-module/components/skip-to-selected-block/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +5 -1
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +4 -45
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-click-selection.js +57 -0
- package/build-module/components/writing-flow/use-click-selection.js.map +1 -0
- package/build-module/components/writing-flow/use-drag-selection.js +124 -0
- package/build-module/components/writing-flow/use-drag-selection.js.map +1 -0
- package/build-module/components/writing-flow/use-input.js +104 -0
- package/build-module/components/writing-flow/use-input.js.map +1 -0
- package/build-module/components/writing-flow/use-multi-selection.js +18 -37
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +150 -0
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -0
- package/build-module/components/writing-flow/use-tab-nav.js +1 -9
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/border-color.js +5 -5
- package/build-module/hooks/border-color.js.map +1 -1
- package/build-module/hooks/border.js +0 -12
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +19 -18
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/font-family.js +3 -1
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +4 -3
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/gap.js +22 -15
- package/build-module/hooks/gap.js.map +1 -1
- package/build-module/hooks/layout.js +7 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/style.js +33 -3
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +26 -0
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/flex.js +76 -13
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +9 -5
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/store/actions.js +277 -49
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +5 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/reducer.js +25 -13
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +250 -21
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +20 -0
- package/build-module/store/utils.js.map +1 -0
- package/build-module/utils/dom.js +2 -1
- package/build-module/utils/dom.js.map +1 -1
- package/build-style/style-rtl.css +142 -101
- package/build-style/style.css +142 -101
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +28 -28
- package/src/components/alignment-control/index.js +9 -4
- package/src/components/block-alignment-control/index.js +9 -4
- package/src/components/block-alignment-control/ui.js +2 -2
- package/src/components/block-content-overlay/index.js +19 -2
- package/src/components/block-draggable/index.js +2 -5
- package/src/components/block-icon/index.js +3 -0
- package/src/components/block-inspector/index.js +4 -0
- package/src/components/block-list/style.scss +4 -5
- package/src/components/block-list/use-block-props/index.js +0 -5
- package/src/components/block-list/use-block-props/use-focus-first-element.js +19 -26
- package/src/components/block-list/use-block-props/use-focus-handler.js +8 -0
- package/src/components/block-list-appender/index.js +5 -0
- package/src/components/block-lock/index.js +1 -0
- package/src/components/block-lock/menu-item.js +6 -19
- package/src/components/block-lock/modal.js +52 -23
- package/src/components/block-lock/style.scss +7 -5
- package/src/components/block-lock/toolbar.js +7 -14
- package/src/components/block-lock/use-block-lock.js +45 -0
- package/src/components/block-mover/index.js +3 -0
- package/src/components/block-mover/style.scss +4 -0
- package/src/components/block-pattern-setup/index.js +84 -59
- package/src/components/block-pattern-setup/setup-toolbar.js +3 -1
- package/src/components/block-pattern-setup/style.scss +32 -26
- package/src/components/block-preview/auto.js +10 -1
- package/src/components/block-preview/index.js +2 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +62 -4
- package/src/components/block-switcher/index.js +15 -3
- package/src/components/block-switcher/style.scss +15 -4
- package/src/components/block-switcher/test/__snapshots__/index.js.snap +15 -13
- package/src/components/block-switcher/test/index.js +2 -2
- package/src/components/block-title/index.js +2 -2
- package/src/components/block-title/use-block-display-title.js +1 -1
- package/src/components/block-toolbar/block-name-context.js +8 -0
- package/src/components/block-toolbar/block-toolbar-last-item.js +12 -0
- package/src/components/block-toolbar/index.js +18 -2
- package/src/components/block-toolbar/style.scss +6 -0
- package/src/components/block-tools/index.js +0 -19
- package/src/components/block-tools/style.scss +3 -5
- package/src/components/block-variation-transforms/index.js +105 -36
- package/src/components/block-variation-transforms/style.scss +1 -1
- package/src/components/block-vertical-alignment-control/index.js +9 -4
- package/src/components/button-block-appender/style.scss +5 -1
- package/src/components/contrast-checker/index.js +3 -0
- package/src/components/convert-to-group-buttons/index.js +6 -1
- package/src/components/convert-to-group-buttons/toolbar.js +87 -0
- package/src/components/copy-handler/index.js +55 -10
- package/src/components/font-sizes/font-size-picker.js +3 -0
- package/src/components/iframe/index.js +5 -7
- package/src/components/index.js +2 -0
- package/src/components/justify-content-control/index.js +9 -4
- package/src/components/keyboard-shortcuts/index.js +1 -1
- package/src/components/line-height-control/index.js +8 -3
- package/src/components/link-control/index.js +5 -5
- package/src/components/list-view/block-select-button.js +13 -3
- package/src/components/list-view/block.js +24 -8
- package/src/components/list-view/branch.js +1 -1
- package/src/components/list-view/style.scss +56 -14
- package/src/components/media-placeholder/README.md +8 -0
- package/src/components/media-replace-flow/index.js +3 -0
- package/src/components/multi-selection-inspector/index.js +2 -2
- package/src/components/rich-text/index.js +24 -1
- package/src/components/rich-text/split-value.js +5 -1
- package/src/components/rich-text/use-firefox-compat.js +39 -0
- package/src/components/rich-text/use-input-rules.js +40 -3
- package/src/components/skip-to-selected-block/index.js +3 -0
- package/src/components/url-input/style.scss +3 -2
- package/src/components/writing-flow/index.js +8 -0
- package/src/components/writing-flow/readme.md +28 -0
- package/src/components/writing-flow/use-arrow-nav.js +4 -53
- package/src/components/writing-flow/use-click-selection.js +65 -0
- package/src/components/writing-flow/use-drag-selection.js +126 -0
- package/src/components/writing-flow/use-input.js +112 -0
- package/src/components/writing-flow/use-multi-selection.js +13 -36
- package/src/components/writing-flow/use-selection-observer.js +153 -0
- package/src/components/writing-flow/use-tab-nav.js +1 -11
- package/src/hooks/border-color.js +5 -5
- package/src/hooks/border.js +0 -13
- package/src/hooks/color.js +51 -24
- package/src/hooks/font-family.js +5 -2
- package/src/hooks/font-size.js +10 -7
- package/src/hooks/gap.js +25 -17
- package/src/hooks/layout.js +11 -1
- package/src/hooks/style.js +40 -4
- package/src/hooks/test/gap.js +25 -1
- package/src/hooks/test/style.js +94 -0
- package/src/hooks/test/utils.js +1 -1
- package/src/hooks/utils.js +26 -0
- package/src/layouts/flex.js +89 -5
- package/src/layouts/flow.js +15 -4
- package/src/store/actions.js +341 -32
- package/src/store/defaults.js +7 -2
- package/src/store/reducer.js +25 -10
- package/src/store/selectors.js +329 -26
- package/src/store/test/selectors.js +242 -5
- package/src/store/utils.js +19 -0
- package/src/utils/dom.js +2 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-list/use-block-props/use-multi-selection.js +0 -205
- package/build/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
- package/build/components/block-list/use-block-props/use-scroll-into-view.js +0 -77
- package/build/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-multi-selection.js +0 -192
- package/build-module/components/block-list/use-block-props/use-multi-selection.js.map +0 -1
- package/build-module/components/block-list/use-block-props/use-scroll-into-view.js +0 -63
- package/build-module/components/block-list/use-block-props/use-scroll-into-view.js.map +0 -1
- package/src/components/block-list/use-block-props/use-multi-selection.js +0 -227
- package/src/components/block-list/use-block-props/use-scroll-into-view.js +0 -73
|
@@ -25,6 +25,7 @@ export default function BlockContentOverlay( {
|
|
|
25
25
|
const [ isHovered, setIsHovered ] = useState( false );
|
|
26
26
|
|
|
27
27
|
const {
|
|
28
|
+
canEdit,
|
|
28
29
|
isParentSelected,
|
|
29
30
|
hasChildSelected,
|
|
30
31
|
isDraggingBlocks,
|
|
@@ -36,8 +37,10 @@ export default function BlockContentOverlay( {
|
|
|
36
37
|
hasSelectedInnerBlock,
|
|
37
38
|
isDraggingBlocks: _isDraggingBlocks,
|
|
38
39
|
isBlockHighlighted,
|
|
40
|
+
canEditBlock,
|
|
39
41
|
} = select( blockEditorStore );
|
|
40
42
|
return {
|
|
43
|
+
canEdit: canEditBlock( clientId ),
|
|
41
44
|
isParentSelected: isBlockSelected( clientId ),
|
|
42
45
|
hasChildSelected: hasSelectedInnerBlock( clientId, true ),
|
|
43
46
|
isDraggingBlocks: _isDraggingBlocks(),
|
|
@@ -59,6 +62,12 @@ export default function BlockContentOverlay( {
|
|
|
59
62
|
);
|
|
60
63
|
|
|
61
64
|
useEffect( () => {
|
|
65
|
+
// The overlay is always active when editing is locked.
|
|
66
|
+
if ( ! canEdit ) {
|
|
67
|
+
setIsOverlayActive( true );
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
62
71
|
// Reenable when blocks are not in use.
|
|
63
72
|
if ( ! isParentSelected && ! hasChildSelected && ! isOverlayActive ) {
|
|
64
73
|
setIsOverlayActive( true );
|
|
@@ -75,7 +84,13 @@ export default function BlockContentOverlay( {
|
|
|
75
84
|
if ( hasChildSelected && isOverlayActive ) {
|
|
76
85
|
setIsOverlayActive( false );
|
|
77
86
|
}
|
|
78
|
-
}, [
|
|
87
|
+
}, [
|
|
88
|
+
isParentSelected,
|
|
89
|
+
hasChildSelected,
|
|
90
|
+
isOverlayActive,
|
|
91
|
+
isHovered,
|
|
92
|
+
canEdit,
|
|
93
|
+
] );
|
|
79
94
|
|
|
80
95
|
// Disabled because the overlay div doesn't actually have a role or functionality
|
|
81
96
|
// as far as the a11y is concerned. We're just catching the first click so that
|
|
@@ -88,7 +103,9 @@ export default function BlockContentOverlay( {
|
|
|
88
103
|
onMouseEnter={ () => setIsHovered( true ) }
|
|
89
104
|
onMouseLeave={ () => setIsHovered( false ) }
|
|
90
105
|
onMouseUp={
|
|
91
|
-
isOverlayActive
|
|
106
|
+
isOverlayActive && canEdit
|
|
107
|
+
? () => setIsOverlayActive( false )
|
|
108
|
+
: undefined
|
|
92
109
|
}
|
|
93
110
|
>
|
|
94
111
|
{ wrapperProps?.children }
|
|
@@ -23,19 +23,16 @@ const BlockDraggable = ( {
|
|
|
23
23
|
const { srcRootClientId, isDraggable, icon } = useSelect(
|
|
24
24
|
( select ) => {
|
|
25
25
|
const {
|
|
26
|
+
canMoveBlocks,
|
|
26
27
|
getBlockRootClientId,
|
|
27
|
-
getTemplateLock,
|
|
28
28
|
getBlockName,
|
|
29
29
|
} = select( blockEditorStore );
|
|
30
30
|
const rootClientId = getBlockRootClientId( clientIds[ 0 ] );
|
|
31
|
-
const templateLock = rootClientId
|
|
32
|
-
? getTemplateLock( rootClientId )
|
|
33
|
-
: null;
|
|
34
31
|
const blockName = getBlockName( clientIds[ 0 ] );
|
|
35
32
|
|
|
36
33
|
return {
|
|
37
34
|
srcRootClientId: rootClientId,
|
|
38
|
-
isDraggable:
|
|
35
|
+
isDraggable: canMoveBlocks( clientIds, rootClientId ),
|
|
39
36
|
icon: getBlockType( blockName )?.icon,
|
|
40
37
|
};
|
|
41
38
|
},
|
|
@@ -70,6 +70,7 @@ const BlockInspector = ( { showNoBlockSelectedMessage = true } ) => {
|
|
|
70
70
|
<InspectorControls.Slot
|
|
71
71
|
__experimentalGroup="color"
|
|
72
72
|
label={ __( 'Color' ) }
|
|
73
|
+
className="color-block-support-panel__inner-wrapper"
|
|
73
74
|
/>
|
|
74
75
|
<InspectorControls.Slot
|
|
75
76
|
__experimentalGroup="typography"
|
|
@@ -187,4 +188,7 @@ const AdvancedControls = () => {
|
|
|
187
188
|
);
|
|
188
189
|
};
|
|
189
190
|
|
|
191
|
+
/**
|
|
192
|
+
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-inspector/README.md
|
|
193
|
+
*/
|
|
190
194
|
export default BlockInspector;
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
// When selecting multiple blocks, we provide an additional selection indicator.
|
|
27
27
|
&.is-navigate-mode .block-editor-block-list__block.is-selected,
|
|
28
28
|
&.is-navigate-mode .block-editor-block-list__block.is-hovered,
|
|
29
|
+
.block-editor-block-list__block.is-multi-selected:not([contenteditable]),
|
|
29
30
|
.block-editor-block-list__block.is-highlighted,
|
|
30
|
-
.block-editor-block-list__block.is-multi-selected {
|
|
31
|
-
|
|
31
|
+
.block-editor-block-list__block.is-highlighted ~ .is-multi-selected {
|
|
32
32
|
&::after {
|
|
33
33
|
// Show selection borders around every non-nested block's actual footprint.
|
|
34
34
|
position: absolute;
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
right: $border-width;
|
|
42
42
|
|
|
43
43
|
// Everything else.
|
|
44
|
-
box-shadow: 0 0 0
|
|
44
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
45
45
|
border-radius: $radius-block-ui - $border-width; // Border is outset, so subtract the width to achieve correct radius.
|
|
46
46
|
|
|
47
47
|
// Windows High Contrast mode will show this outline.
|
|
@@ -66,11 +66,10 @@
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
.block-editor-block-list__block.is-highlighted::after {
|
|
69
|
-
box-shadow: 0 0 0
|
|
69
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
70
70
|
outline: $border-width solid transparent;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
.block-editor-block-list__block.is-multi-selected::after,
|
|
74
73
|
&.is-navigate-mode .block-editor-block-list__block.is-selected::after,
|
|
75
74
|
& .is-block-moving-mode.block-editor-block-list__block.has-child-selected {
|
|
76
75
|
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
@@ -31,9 +31,7 @@ import { useBlockMovingModeClassNames } from './use-block-moving-mode-class-name
|
|
|
31
31
|
import { useFocusHandler } from './use-focus-handler';
|
|
32
32
|
import { useEventHandlers } from './use-selected-block-event-handlers';
|
|
33
33
|
import { useNavModeExit } from './use-nav-mode-exit';
|
|
34
|
-
import { useScrollIntoView } from './use-scroll-into-view';
|
|
35
34
|
import { useBlockRefProvider } from './use-block-refs';
|
|
36
|
-
import { useMultiSelection } from './use-multi-selection';
|
|
37
35
|
import { useIntersectionObserver } from './use-intersection-observer';
|
|
38
36
|
import { store as blockEditorStore } from '../../../store';
|
|
39
37
|
|
|
@@ -115,11 +113,8 @@ export function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {
|
|
|
115
113
|
const mergedRefs = useMergeRefs( [
|
|
116
114
|
props.ref,
|
|
117
115
|
useFocusFirstElement( clientId ),
|
|
118
|
-
// Must happen after focus because we check for focus in the block.
|
|
119
|
-
useScrollIntoView( clientId ),
|
|
120
116
|
useBlockRefProvider( clientId ),
|
|
121
117
|
useFocusHandler( clientId ),
|
|
122
|
-
useMultiSelection( clientId ),
|
|
123
118
|
useEventHandlers( clientId ),
|
|
124
119
|
useNavModeExit( clientId ),
|
|
125
120
|
useIsHovered(),
|
|
@@ -7,7 +7,12 @@ import { first, last } from 'lodash';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useEffect, useRef } from '@wordpress/element';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
focus,
|
|
12
|
+
isFormElement,
|
|
13
|
+
isTextField,
|
|
14
|
+
placeCaretAtHorizontalEdge,
|
|
15
|
+
} from '@wordpress/dom';
|
|
11
16
|
import { useSelect } from '@wordpress/data';
|
|
12
17
|
|
|
13
18
|
/**
|
|
@@ -15,7 +20,6 @@ import { useSelect } from '@wordpress/data';
|
|
|
15
20
|
*/
|
|
16
21
|
import { isInsideRootBlock } from '../../../utils/dom';
|
|
17
22
|
import { store as blockEditorStore } from '../../../store';
|
|
18
|
-
import { setContentEditableWrapper } from './use-multi-selection';
|
|
19
23
|
|
|
20
24
|
/** @typedef {import('@wordpress/element').RefObject} RefObject */
|
|
21
25
|
|
|
@@ -32,7 +36,6 @@ function useInitialPosition( clientId ) {
|
|
|
32
36
|
( select ) => {
|
|
33
37
|
const {
|
|
34
38
|
getSelectedBlocksInitialCaretPosition,
|
|
35
|
-
isMultiSelecting,
|
|
36
39
|
isNavigationMode,
|
|
37
40
|
isBlockSelected,
|
|
38
41
|
} = select( blockEditorStore );
|
|
@@ -41,7 +44,7 @@ function useInitialPosition( clientId ) {
|
|
|
41
44
|
return;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
if (
|
|
47
|
+
if ( isNavigationMode() ) {
|
|
45
48
|
return;
|
|
46
49
|
}
|
|
47
50
|
|
|
@@ -52,16 +55,6 @@ function useInitialPosition( clientId ) {
|
|
|
52
55
|
);
|
|
53
56
|
}
|
|
54
57
|
|
|
55
|
-
function isFormElement( element ) {
|
|
56
|
-
const { tagName } = element;
|
|
57
|
-
return (
|
|
58
|
-
tagName === 'INPUT' ||
|
|
59
|
-
tagName === 'BUTTON' ||
|
|
60
|
-
tagName === 'SELECT' ||
|
|
61
|
-
tagName === 'TEXTAREA'
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
58
|
/**
|
|
66
59
|
* Transitions focus to the block or inner tabbable when the block becomes
|
|
67
60
|
* selected and an initial position is set.
|
|
@@ -73,8 +66,14 @@ function isFormElement( element ) {
|
|
|
73
66
|
export function useFocusFirstElement( clientId ) {
|
|
74
67
|
const ref = useRef();
|
|
75
68
|
const initialPosition = useInitialPosition( clientId );
|
|
69
|
+
const { isBlockSelected, isMultiSelecting } = useSelect( blockEditorStore );
|
|
76
70
|
|
|
77
71
|
useEffect( () => {
|
|
72
|
+
// Check if the block is still selected at the time this effect runs.
|
|
73
|
+
if ( ! isBlockSelected( clientId ) || isMultiSelecting() ) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
78
77
|
if ( initialPosition === undefined || initialPosition === null ) {
|
|
79
78
|
return;
|
|
80
79
|
}
|
|
@@ -107,27 +106,21 @@ export function useFocusFirstElement( clientId ) {
|
|
|
107
106
|
}
|
|
108
107
|
|
|
109
108
|
// Check to see if element is focussable before a generic caret insert.
|
|
110
|
-
if ( !
|
|
111
|
-
const focusElement = focus.tabbable.findNext(
|
|
112
|
-
// Make sure focusElement is valid,
|
|
113
|
-
// Ensure is not block inserter trigger, don't want to focus that in the event of the group block which doesn't contain any other focussable elements.
|
|
109
|
+
if ( ! ref.current.getAttribute( 'contenteditable' ) ) {
|
|
110
|
+
const focusElement = focus.tabbable.findNext( ref.current );
|
|
111
|
+
// Make sure focusElement is valid, contained in the same block, and a form field.
|
|
114
112
|
if (
|
|
115
113
|
focusElement &&
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
! focusElement.classList.contains(
|
|
119
|
-
'block-editor-button-block-appender'
|
|
120
|
-
)
|
|
114
|
+
isInsideRootBlock( ref.current, focusElement ) &&
|
|
115
|
+
isFormElement( focusElement )
|
|
121
116
|
) {
|
|
122
117
|
focusElement.focus();
|
|
123
118
|
return;
|
|
124
119
|
}
|
|
125
120
|
}
|
|
126
121
|
|
|
127
|
-
setContentEditableWrapper( ref.current, false );
|
|
128
|
-
|
|
129
122
|
placeCaretAtHorizontalEdge( target, isReverse );
|
|
130
|
-
}, [ initialPosition ] );
|
|
123
|
+
}, [ initialPosition, clientId ] );
|
|
131
124
|
|
|
132
125
|
return ref;
|
|
133
126
|
}
|
|
@@ -30,6 +30,14 @@ export function useFocusHandler( clientId ) {
|
|
|
30
30
|
* @param {FocusEvent} event Focus event.
|
|
31
31
|
*/
|
|
32
32
|
function onFocus( event ) {
|
|
33
|
+
// When the whole editor is editable, let writing flow handle
|
|
34
|
+
// selection.
|
|
35
|
+
if (
|
|
36
|
+
node.parentElement.closest( '[contenteditable="true"]' )
|
|
37
|
+
) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
33
41
|
// Check synchronously because a non-selected block might be
|
|
34
42
|
// getting data through `useSelect` asynchronously.
|
|
35
43
|
if ( isBlockSelected( clientId ) ) {
|
|
@@ -73,6 +73,11 @@ function BlockListAppender( {
|
|
|
73
73
|
'block-list-appender wp-block',
|
|
74
74
|
className
|
|
75
75
|
) }
|
|
76
|
+
// Needed in case the whole editor is content editable (for multi
|
|
77
|
+
// selection). It fixes an edge case where ArrowDown and ArrowRight
|
|
78
|
+
// should collapse the selection to the end of that selection and
|
|
79
|
+
// not into the appender.
|
|
80
|
+
contentEditable={ false }
|
|
76
81
|
// The appender exists to let you add the first Paragraph before
|
|
77
82
|
// any is inserted. To that end, this appender should visually be
|
|
78
83
|
// presented as a block. That means theme CSS should style it as if
|
|
@@ -4,39 +4,26 @@
|
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { useReducer } from '@wordpress/element';
|
|
6
6
|
import { MenuItem } from '@wordpress/components';
|
|
7
|
-
import { useSelect } from '@wordpress/data';
|
|
8
7
|
import { lock, unlock } from '@wordpress/icons';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Internal dependencies
|
|
12
11
|
*/
|
|
12
|
+
import useBlockLock from './use-block-lock';
|
|
13
13
|
import BlockLockModal from './modal';
|
|
14
|
-
import { store as blockEditorStore } from '../../store';
|
|
15
14
|
|
|
16
15
|
export default function BlockLockMenuItem( { clientId } ) {
|
|
17
|
-
const { isLocked } =
|
|
18
|
-
( select ) => {
|
|
19
|
-
const {
|
|
20
|
-
canMoveBlock,
|
|
21
|
-
canRemoveBlock,
|
|
22
|
-
getBlockRootClientId,
|
|
23
|
-
} = select( blockEditorStore );
|
|
24
|
-
const rootClientId = getBlockRootClientId( clientId );
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
isLocked:
|
|
28
|
-
! canMoveBlock( clientId, rootClientId ) ||
|
|
29
|
-
! canRemoveBlock( clientId, rootClientId ),
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
|
-
[ clientId ]
|
|
33
|
-
);
|
|
16
|
+
const { canLock, isLocked } = useBlockLock( clientId );
|
|
34
17
|
|
|
35
18
|
const [ isModalOpen, toggleModal ] = useReducer(
|
|
36
19
|
( isActive ) => ! isActive,
|
|
37
20
|
false
|
|
38
21
|
);
|
|
39
22
|
|
|
23
|
+
if ( ! canLock ) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
40
27
|
const label = isLocked ? __( 'Unlock' ) : __( 'Lock' );
|
|
41
28
|
|
|
42
29
|
return (
|
|
@@ -11,30 +11,28 @@ import {
|
|
|
11
11
|
Icon,
|
|
12
12
|
Modal,
|
|
13
13
|
} from '@wordpress/components';
|
|
14
|
-
import {
|
|
14
|
+
import { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons';
|
|
15
15
|
import { useInstanceId } from '@wordpress/compose';
|
|
16
16
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
17
|
+
import { isReusableBlock, getBlockType } from '@wordpress/blocks';
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Internal dependencies
|
|
20
21
|
*/
|
|
22
|
+
import useBlockLock from './use-block-lock';
|
|
21
23
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
22
24
|
import { store as blockEditorStore } from '../../store';
|
|
23
25
|
|
|
24
26
|
export default function BlockLockModal( { clientId, onClose } ) {
|
|
25
27
|
const [ lock, setLock ] = useState( { move: false, remove: false } );
|
|
26
|
-
const { canMove, canRemove } =
|
|
28
|
+
const { canEdit, canMove, canRemove } = useBlockLock( clientId );
|
|
29
|
+
const { isReusable } = useSelect(
|
|
27
30
|
( select ) => {
|
|
28
|
-
const {
|
|
29
|
-
|
|
30
|
-
canRemoveBlock,
|
|
31
|
-
getBlockRootClientId,
|
|
32
|
-
} = select( blockEditorStore );
|
|
33
|
-
const rootClientId = getBlockRootClientId( clientId );
|
|
31
|
+
const { getBlockName } = select( blockEditorStore );
|
|
32
|
+
const blockName = getBlockName( clientId );
|
|
34
33
|
|
|
35
34
|
return {
|
|
36
|
-
|
|
37
|
-
canRemove: canRemoveBlock( clientId, rootClientId ),
|
|
35
|
+
isReusable: isReusableBlock( getBlockType( blockName ) ),
|
|
38
36
|
};
|
|
39
37
|
},
|
|
40
38
|
[ clientId ]
|
|
@@ -50,19 +48,12 @@ export default function BlockLockModal( { clientId, onClose } ) {
|
|
|
50
48
|
setLock( {
|
|
51
49
|
move: ! canMove,
|
|
52
50
|
remove: ! canRemove,
|
|
51
|
+
...( isReusable ? { edit: ! canEdit } : {} ),
|
|
53
52
|
} );
|
|
54
|
-
}, [ canMove, canRemove ] );
|
|
53
|
+
}, [ canEdit, canMove, canRemove, isReusable ] );
|
|
55
54
|
|
|
56
55
|
const isAllChecked = Object.values( lock ).every( Boolean );
|
|
57
|
-
|
|
58
|
-
let ariaChecked;
|
|
59
|
-
if ( isAllChecked ) {
|
|
60
|
-
ariaChecked = 'true';
|
|
61
|
-
} else if ( Object.values( lock ).some( Boolean ) ) {
|
|
62
|
-
ariaChecked = 'mixed';
|
|
63
|
-
} else {
|
|
64
|
-
ariaChecked = 'false';
|
|
65
|
-
}
|
|
56
|
+
const isMixed = Object.values( lock ).some( Boolean ) && ! isAllChecked;
|
|
66
57
|
|
|
67
58
|
return (
|
|
68
59
|
<Modal
|
|
@@ -98,21 +89,53 @@ export default function BlockLockModal( { clientId, onClose } ) {
|
|
|
98
89
|
<span id={ instanceId }>{ __( 'Lock all' ) }</span>
|
|
99
90
|
}
|
|
100
91
|
checked={ isAllChecked }
|
|
101
|
-
|
|
92
|
+
indeterminate={ isMixed }
|
|
102
93
|
onChange={ ( newValue ) =>
|
|
103
94
|
setLock( {
|
|
104
95
|
move: newValue,
|
|
105
96
|
remove: newValue,
|
|
97
|
+
...( isReusable ? { edit: newValue } : {} ),
|
|
106
98
|
} )
|
|
107
99
|
}
|
|
108
100
|
/>
|
|
109
101
|
<ul className="block-editor-block-lock-modal__checklist">
|
|
102
|
+
{ isReusable && (
|
|
103
|
+
<li className="block-editor-block-lock-modal__checklist-item">
|
|
104
|
+
<CheckboxControl
|
|
105
|
+
label={
|
|
106
|
+
<>
|
|
107
|
+
{ __( 'Restrict editing' ) }
|
|
108
|
+
<Icon
|
|
109
|
+
icon={
|
|
110
|
+
lock.edit
|
|
111
|
+
? lockIcon
|
|
112
|
+
: unlockIcon
|
|
113
|
+
}
|
|
114
|
+
/>
|
|
115
|
+
</>
|
|
116
|
+
}
|
|
117
|
+
checked={ !! lock.edit }
|
|
118
|
+
onChange={ ( edit ) =>
|
|
119
|
+
setLock( ( prevLock ) => ( {
|
|
120
|
+
...prevLock,
|
|
121
|
+
edit,
|
|
122
|
+
} ) )
|
|
123
|
+
}
|
|
124
|
+
/>
|
|
125
|
+
</li>
|
|
126
|
+
) }
|
|
110
127
|
<li className="block-editor-block-lock-modal__checklist-item">
|
|
111
128
|
<CheckboxControl
|
|
112
129
|
label={
|
|
113
130
|
<>
|
|
114
131
|
{ __( 'Disable movement' ) }
|
|
115
|
-
<Icon
|
|
132
|
+
<Icon
|
|
133
|
+
icon={
|
|
134
|
+
lock.move
|
|
135
|
+
? lockIcon
|
|
136
|
+
: unlockIcon
|
|
137
|
+
}
|
|
138
|
+
/>
|
|
116
139
|
</>
|
|
117
140
|
}
|
|
118
141
|
checked={ lock.move }
|
|
@@ -129,7 +152,13 @@ export default function BlockLockModal( { clientId, onClose } ) {
|
|
|
129
152
|
label={
|
|
130
153
|
<>
|
|
131
154
|
{ __( 'Prevent removal' ) }
|
|
132
|
-
<Icon
|
|
155
|
+
<Icon
|
|
156
|
+
icon={
|
|
157
|
+
lock.remove
|
|
158
|
+
? lockIcon
|
|
159
|
+
: unlockIcon
|
|
160
|
+
}
|
|
161
|
+
/>
|
|
133
162
|
</>
|
|
134
163
|
}
|
|
135
164
|
checked={ lock.remove }
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
.block-editor-block-lock-modal__options-title {
|
|
16
|
-
border-bottom: 1px solid $gray-300;
|
|
17
16
|
padding: $grid-unit-15 0;
|
|
18
17
|
|
|
19
18
|
.components-checkbox-control__label {
|
|
@@ -27,9 +26,8 @@
|
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
.block-editor-block-lock-modal__checklist-item {
|
|
30
|
-
border-bottom: 1px solid $gray-300;
|
|
31
29
|
margin-bottom: 0;
|
|
32
|
-
padding: $grid-unit-15 0 $grid-unit-15 $grid-unit-
|
|
30
|
+
padding: $grid-unit-15 0 $grid-unit-15 $grid-unit-40;
|
|
33
31
|
|
|
34
32
|
.components-base-control__field {
|
|
35
33
|
align-items: center;
|
|
@@ -48,6 +46,11 @@
|
|
|
48
46
|
fill: $gray-900;
|
|
49
47
|
}
|
|
50
48
|
}
|
|
49
|
+
|
|
50
|
+
&:hover {
|
|
51
|
+
background-color: $gray-100;
|
|
52
|
+
border-radius: $radius-block-ui;
|
|
53
|
+
}
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
.block-editor-block-lock-modal__actions {
|
|
@@ -60,8 +63,7 @@
|
|
|
60
63
|
padding-left: 0 !important;
|
|
61
64
|
|
|
62
65
|
&:focus::before {
|
|
63
|
-
|
|
64
|
-
right: $grid-unit-15 !important;
|
|
66
|
+
right: $grid-unit-10 !important;
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
}
|
|
@@ -5,35 +5,28 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
5
5
|
import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
|
|
6
6
|
import { useReducer } from '@wordpress/element';
|
|
7
7
|
import { lock } from '@wordpress/icons';
|
|
8
|
-
import { useSelect } from '@wordpress/data';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Internal dependencies
|
|
12
11
|
*/
|
|
13
12
|
import BlockLockModal from './modal';
|
|
13
|
+
import useBlockLock from './use-block-lock';
|
|
14
14
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
15
|
-
import { store as blockEditorStore } from '../../store';
|
|
16
15
|
|
|
17
16
|
export default function BlockLockToolbar( { clientId } ) {
|
|
18
17
|
const blockInformation = useBlockDisplayInformation( clientId );
|
|
19
|
-
const { canMove, canRemove } =
|
|
20
|
-
( select ) => {
|
|
21
|
-
const { canMoveBlock, canRemoveBlock } = select( blockEditorStore );
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
canMove: canMoveBlock( clientId ),
|
|
25
|
-
canRemove: canRemoveBlock( clientId ),
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
[ clientId ]
|
|
29
|
-
);
|
|
18
|
+
const { canEdit, canMove, canRemove, canLock } = useBlockLock( clientId );
|
|
30
19
|
|
|
31
20
|
const [ isModalOpen, toggleModal ] = useReducer(
|
|
32
21
|
( isActive ) => ! isActive,
|
|
33
22
|
false
|
|
34
23
|
);
|
|
35
24
|
|
|
36
|
-
if (
|
|
25
|
+
if ( ! canLock ) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if ( canEdit && canMove && canRemove ) {
|
|
37
30
|
return null;
|
|
38
31
|
}
|
|
39
32
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { store as blockEditorStore } from '../../store';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Return details about the block lock status.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} clientId The block client Id.
|
|
15
|
+
*
|
|
16
|
+
* @return {Object} Block lock status
|
|
17
|
+
*/
|
|
18
|
+
export default function useBlockLock( clientId ) {
|
|
19
|
+
return useSelect(
|
|
20
|
+
( select ) => {
|
|
21
|
+
const {
|
|
22
|
+
canEditBlock,
|
|
23
|
+
canMoveBlock,
|
|
24
|
+
canRemoveBlock,
|
|
25
|
+
canLockBlockType,
|
|
26
|
+
getBlockName,
|
|
27
|
+
getBlockRootClientId,
|
|
28
|
+
} = select( blockEditorStore );
|
|
29
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
30
|
+
|
|
31
|
+
const canEdit = canEditBlock( clientId );
|
|
32
|
+
const canMove = canMoveBlock( clientId, rootClientId );
|
|
33
|
+
const canRemove = canRemoveBlock( clientId, rootClientId );
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
canEdit,
|
|
37
|
+
canMove,
|
|
38
|
+
canRemove,
|
|
39
|
+
canLock: canLockBlockType( getBlockName( clientId ) ),
|
|
40
|
+
isLocked: ! canEdit || ! canMove || ! canRemove,
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
[ clientId ]
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -22,6 +22,10 @@
|
|
|
22
22
|
@include break-small() {
|
|
23
23
|
flex-direction: column;
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
// @todo: override toolbar group inherited paddings from components/block-tools/style.scss.
|
|
27
|
+
// This is best fixed by making the mover control area a proper single toolbar group.
|
|
28
|
+
padding: 0;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
&.is-horizontal .block-editor-block-mover__move-button-container,
|