@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/index.js"],"names":["BLOCK_ANIMATION_THRESHOLD","useBlockProps","props","__unstableIsHtml","clientId","className","wrapperProps","isAligned","BlockListBlockContext","index","mode","name","blockApiVersion","blockTitle","isPartOfSelection","adjustScrolling","enableAnimation","select","getBlockIndex","getBlockMode","getBlockName","isTyping","getGlobalBlockCount","isBlockSelected","isBlockMultiSelected","isAncestorMultiSelected","isFirstMultiSelectedBlock","blockEditorStore","isSelected","isPartOfMultiSelection","blockName","blockType","apiVersion","title","blockLabel","htmlSuffix","mergedRefs","ref","triggerAnimationOnChange","blockEditContext","id","tabIndex","role","style","save","getBlockProps"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AArCA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;AAmBA;AACA;AACA;AACA;AACA,MAAMA,yBAAyB,GAAG,GAAlC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,aAAT,GAA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jC;AAKNM,IAAAA,QAAQ,EAAE,CALJ;AAMNC,IAAAA,IAAI,EAAE,UANA;AAON,kBAAcR,UAPR;AAQN,kBAAc9B,QARR;AASN,iBAAaO,IATP;AAUN,kBAAcE,UAVR;AAWNR,IAAAA,SAAS,EAAE,0BACV;AACA,6BAAY,gCAAZ,EAA8C;AAC7C,kBAAY,CAAEE;AAD+B,KAA9C,CAFU,EAKVF,SALU,EAMVH,KAAK,CAACG,SANI,EAOVC,YAAY,CAACD,SAPH,EAQV,4CAAoBD,QAApB,CARU,EASV,wDAA0BA,QAA1B,CATU,EAUV,sDAAyBA,QAAzB,CAVU,EAWV,gEAA8BA,QAA9B,CAXU,CAXL;AAwBNuC,IAAAA,KAAK,EAAE,EAAE,GAAGrC,YAAY,CAACqC,KAAlB;AAAyB,SAAGzC,KAAK,CAACyC;AAAlC;AAxBD,GAAP;AA0BA;AAED;AACA;AACA;AACA;AACA;;;AACA1C,aAAa,CAAC2C,IAAd,GAAqBC,+BAArB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__unstableGetBlockProps as getBlockProps,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../../use-moving-animation';\nimport { BlockListBlockContext } from '../block';\nimport { useFocusFirstElement } from './use-focus-first-element';\nimport { useIsHovered } from './use-is-hovered';\nimport { useBlockEditContext } from '../../block-edit/context';\nimport { useBlockClassNames } from './use-block-class-names';\nimport { useBlockDefaultClassName } from './use-block-default-class-name';\nimport { useBlockCustomClassName } from './use-block-custom-class-name';\nimport { useBlockMovingModeClassNames } from './use-block-moving-mode-class-names';\nimport { useFocusHandler } from './use-focus-handler';\nimport { useEventHandlers } from './use-selected-block-event-handlers';\nimport { useNavModeExit } from './use-nav-mode-exit';\nimport { useScrollIntoView } from './use-scroll-into-view';\nimport { useBlockRefProvider } from './use-block-refs';\nimport { useMultiSelection } from './use-multi-selection';\nimport { useIntersectionObserver } from './use-intersection-observer';\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * If the block count exceeds the threshold, we disable the reordering animation\n * to avoid laginess.\n */\nconst BLOCK_ANIMATION_THRESHOLD = 200;\n\n/**\n * This hook is used to lightly mark an element as a block element. The element\n * should be the outermost element of a block. Call this hook and pass the\n * returned props to the element to mark as a block. If you define a ref for the\n * element, it is important to pass the ref to this hook, which the hook in turn\n * will pass to the component through the props it returns. Optionally, you can\n * also pass any other props through this hook, and they will be merged and\n * returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Options for internal use only.\n * @param {boolean} options.__unstableIsHtml\n *\n * @return {Object} Props to pass to the element to mark as a block.\n */\nexport function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {\n\tconst { clientId, className, wrapperProps = {}, isAligned } = useContext(\n\t\tBlockListBlockContext\n\t);\n\tconst {\n\t\tindex,\n\t\tmode,\n\t\tname,\n\t\tblockApiVersion,\n\t\tblockTitle,\n\t\tisPartOfSelection,\n\t\tadjustScrolling,\n\t\tenableAnimation,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockMode,\n\t\t\t\tgetBlockName,\n\t\t\t\tisTyping,\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tisBlockSelected,\n\t\t\t\tisBlockMultiSelected,\n\t\t\t\tisAncestorMultiSelected,\n\t\t\t\tisFirstMultiSelectedBlock,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst isSelected = isBlockSelected( clientId );\n\t\t\tconst isPartOfMultiSelection =\n\t\t\t\tisBlockMultiSelected( clientId ) ||\n\t\t\t\tisAncestorMultiSelected( clientId );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\n\t\t\treturn {\n\t\t\t\tindex: getBlockIndex( clientId ),\n\t\t\t\tmode: getBlockMode( clientId ),\n\t\t\t\tname: blockName,\n\t\t\t\tblockApiVersion: blockType?.apiVersion || 1,\n\t\t\t\tblockTitle: blockType?.title,\n\t\t\t\tisPartOfSelection: isSelected || isPartOfMultiSelection,\n\t\t\t\tadjustScrolling:\n\t\t\t\t\tisSelected || isFirstMultiSelectedBlock( clientId ),\n\t\t\t\tenableAnimation:\n\t\t\t\t\t! isTyping() &&\n\t\t\t\t\tgetGlobalBlockCount() <= BLOCK_ANIMATION_THRESHOLD,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// translators: %s: Type of block (i.e. Text, Image etc)\n\tconst blockLabel = sprintf( __( 'Block: %s' ), blockTitle );\n\tconst htmlSuffix = mode === 'html' && ! __unstableIsHtml ? '-visual' : '';\n\tconst mergedRefs = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseFocusFirstElement( clientId ),\n\t\t// Must happen after focus because we check for focus in the block.\n\t\tuseScrollIntoView( clientId ),\n\t\tuseBlockRefProvider( clientId ),\n\t\tuseFocusHandler( clientId ),\n\t\tuseMultiSelection( clientId ),\n\t\tuseEventHandlers( clientId ),\n\t\tuseNavModeExit( clientId ),\n\t\tuseIsHovered(),\n\t\tuseIntersectionObserver(),\n\t\tuseMovingAnimation( {\n\t\t\tisSelected: isPartOfSelection,\n\t\t\tadjustScrolling,\n\t\t\tenableAnimation,\n\t\t\ttriggerAnimationOnChange: index,\n\t\t} ),\n\t] );\n\n\tconst blockEditContext = useBlockEditContext();\n\t// Ensures it warns only inside the `edit` implementation for the block.\n\tif ( blockApiVersion < 2 && clientId === blockEditContext.clientId ) {\n\t\twarning(\n\t\t\t`Block type \"${ name }\" must support API version 2 or higher to work correctly with \"useBlockProps\" method.`\n\t\t);\n\t}\n\n\treturn {\n\t\t...wrapperProps,\n\t\t...props,\n\t\tref: mergedRefs,\n\t\tid: `block-${ clientId }${ htmlSuffix }`,\n\t\ttabIndex: 0,\n\t\trole: 'document',\n\t\t'aria-label': blockLabel,\n\t\t'data-block': clientId,\n\t\t'data-type': name,\n\t\t'data-title': blockTitle,\n\t\tclassName: classnames(\n\t\t\t// The wp-block className is important for editor styles.\n\t\t\tclassnames( 'block-editor-block-list__block', {\n\t\t\t\t'wp-block': ! isAligned,\n\t\t\t} ),\n\t\t\tclassName,\n\t\t\tprops.className,\n\t\t\twrapperProps.className,\n\t\t\tuseBlockClassNames( clientId ),\n\t\t\tuseBlockDefaultClassName( clientId ),\n\t\t\tuseBlockCustomClassName( clientId ),\n\t\t\tuseBlockMovingModeClassNames( clientId )\n\t\t),\n\t\tstyle: { ...wrapperProps.style, ...props.style },\n\t};\n}\n\n/**\n * Call within a save function to get the props for the block wrapper.\n *\n * @param {Object} props Optional. Props to pass to the element.\n */\nuseBlockProps.save = getBlockProps;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/index.js"],"names":["BLOCK_ANIMATION_THRESHOLD","useBlockProps","props","__unstableIsHtml","clientId","className","wrapperProps","isAligned","BlockListBlockContext","index","mode","name","blockApiVersion","blockTitle","isPartOfSelection","adjustScrolling","enableAnimation","select","getBlockIndex","getBlockMode","getBlockName","isTyping","getGlobalBlockCount","isBlockSelected","isBlockMultiSelected","isAncestorMultiSelected","isFirstMultiSelectedBlock","blockEditorStore","isSelected","isPartOfMultiSelection","blockName","blockType","apiVersion","title","blockLabel","htmlSuffix","mergedRefs","ref","triggerAnimationOnChange","blockEditContext","id","tabIndex","role","style","save","getBlockProps"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAnCA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;;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GNmC,IAAAA,GAAG,EAAED,UAHC;AAINI,IAAAA,EAAE,EAAG,SAASpC,QAAU,GAAG+B,UAAY,EAJjC;AAKNM,IAAAA,QAAQ,EAAE,CALJ;AAMNC,IAAAA,IAAI,EAAE,UANA;AAON,kBAAcR,UAPR;AAQN,kBAAc9B,QARR;AASN,iBAAaO,IATP;AAUN,kBAAcE,UAVR;AAWNR,IAAAA,SAAS,EAAE,0BACV;AACA,6BAAY,gCAAZ,EAA8C;AAC7C,kBAAY,CAAEE;AAD+B,KAA9C,CAFU,EAKVF,SALU,EAMVH,KAAK,CAACG,SANI,EAOVC,YAAY,CAACD,SAPH,EAQV,4CAAoBD,QAApB,CARU,EASV,wDAA0BA,QAA1B,CATU,EAUV,sDAAyBA,QAAzB,CAVU,EAWV,gEAA8BA,QAA9B,CAXU,CAXL;AAwBNuC,IAAAA,KAAK,EAAE,EAAE,GAAGrC,YAAY,CAACqC,KAAlB;AAAyB,SAAGzC,KAAK,CAACyC;AAAlC;AAxBD,GAAP;AA0BA;AAED;AACA;AACA;AACA;AACA;;;AACA1C,aAAa,CAAC2C,IAAd,GAAqBC,+BAArB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__unstableGetBlockProps as getBlockProps,\n\tgetBlockType,\n} from '@wordpress/blocks';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../../use-moving-animation';\nimport { BlockListBlockContext } from '../block';\nimport { useFocusFirstElement } from './use-focus-first-element';\nimport { useIsHovered } from './use-is-hovered';\nimport { useBlockEditContext } from '../../block-edit/context';\nimport { useBlockClassNames } from './use-block-class-names';\nimport { useBlockDefaultClassName } from './use-block-default-class-name';\nimport { useBlockCustomClassName } from './use-block-custom-class-name';\nimport { useBlockMovingModeClassNames } from './use-block-moving-mode-class-names';\nimport { useFocusHandler } from './use-focus-handler';\nimport { useEventHandlers } from './use-selected-block-event-handlers';\nimport { useNavModeExit } from './use-nav-mode-exit';\nimport { useBlockRefProvider } from './use-block-refs';\nimport { useIntersectionObserver } from './use-intersection-observer';\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * If the block count exceeds the threshold, we disable the reordering animation\n * to avoid laginess.\n */\nconst BLOCK_ANIMATION_THRESHOLD = 200;\n\n/**\n * This hook is used to lightly mark an element as a block element. The element\n * should be the outermost element of a block. Call this hook and pass the\n * returned props to the element to mark as a block. If you define a ref for the\n * element, it is important to pass the ref to this hook, which the hook in turn\n * will pass to the component through the props it returns. Optionally, you can\n * also pass any other props through this hook, and they will be merged and\n * returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Options for internal use only.\n * @param {boolean} options.__unstableIsHtml\n *\n * @return {Object} Props to pass to the element to mark as a block.\n */\nexport function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {\n\tconst { clientId, className, wrapperProps = {}, isAligned } = useContext(\n\t\tBlockListBlockContext\n\t);\n\tconst {\n\t\tindex,\n\t\tmode,\n\t\tname,\n\t\tblockApiVersion,\n\t\tblockTitle,\n\t\tisPartOfSelection,\n\t\tadjustScrolling,\n\t\tenableAnimation,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockIndex,\n\t\t\t\tgetBlockMode,\n\t\t\t\tgetBlockName,\n\t\t\t\tisTyping,\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tisBlockSelected,\n\t\t\t\tisBlockMultiSelected,\n\t\t\t\tisAncestorMultiSelected,\n\t\t\t\tisFirstMultiSelectedBlock,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst isSelected = isBlockSelected( clientId );\n\t\t\tconst isPartOfMultiSelection =\n\t\t\t\tisBlockMultiSelected( clientId ) ||\n\t\t\t\tisAncestorMultiSelected( clientId );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst blockType = getBlockType( blockName );\n\n\t\t\treturn {\n\t\t\t\tindex: getBlockIndex( clientId ),\n\t\t\t\tmode: getBlockMode( clientId ),\n\t\t\t\tname: blockName,\n\t\t\t\tblockApiVersion: blockType?.apiVersion || 1,\n\t\t\t\tblockTitle: blockType?.title,\n\t\t\t\tisPartOfSelection: isSelected || isPartOfMultiSelection,\n\t\t\t\tadjustScrolling:\n\t\t\t\t\tisSelected || isFirstMultiSelectedBlock( clientId ),\n\t\t\t\tenableAnimation:\n\t\t\t\t\t! isTyping() &&\n\t\t\t\t\tgetGlobalBlockCount() <= BLOCK_ANIMATION_THRESHOLD,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// translators: %s: Type of block (i.e. Text, Image etc)\n\tconst blockLabel = sprintf( __( 'Block: %s' ), blockTitle );\n\tconst htmlSuffix = mode === 'html' && ! __unstableIsHtml ? '-visual' : '';\n\tconst mergedRefs = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseFocusFirstElement( clientId ),\n\t\tuseBlockRefProvider( clientId ),\n\t\tuseFocusHandler( clientId ),\n\t\tuseEventHandlers( clientId ),\n\t\tuseNavModeExit( clientId ),\n\t\tuseIsHovered(),\n\t\tuseIntersectionObserver(),\n\t\tuseMovingAnimation( {\n\t\t\tisSelected: isPartOfSelection,\n\t\t\tadjustScrolling,\n\t\t\tenableAnimation,\n\t\t\ttriggerAnimationOnChange: index,\n\t\t} ),\n\t] );\n\n\tconst blockEditContext = useBlockEditContext();\n\t// Ensures it warns only inside the `edit` implementation for the block.\n\tif ( blockApiVersion < 2 && clientId === blockEditContext.clientId ) {\n\t\twarning(\n\t\t\t`Block type \"${ name }\" must support API version 2 or higher to work correctly with \"useBlockProps\" method.`\n\t\t);\n\t}\n\n\treturn {\n\t\t...wrapperProps,\n\t\t...props,\n\t\tref: mergedRefs,\n\t\tid: `block-${ clientId }${ htmlSuffix }`,\n\t\ttabIndex: 0,\n\t\trole: 'document',\n\t\t'aria-label': blockLabel,\n\t\t'data-block': clientId,\n\t\t'data-type': name,\n\t\t'data-title': blockTitle,\n\t\tclassName: classnames(\n\t\t\t// The wp-block className is important for editor styles.\n\t\t\tclassnames( 'block-editor-block-list__block', {\n\t\t\t\t'wp-block': ! isAligned,\n\t\t\t} ),\n\t\t\tclassName,\n\t\t\tprops.className,\n\t\t\twrapperProps.className,\n\t\t\tuseBlockClassNames( clientId ),\n\t\t\tuseBlockDefaultClassName( clientId ),\n\t\t\tuseBlockCustomClassName( clientId ),\n\t\t\tuseBlockMovingModeClassNames( clientId )\n\t\t),\n\t\tstyle: { ...wrapperProps.style, ...props.style },\n\t};\n}\n\n/**\n * Call within a save function to get the props for the block wrapper.\n *\n * @param {Object} props Optional. Props to pass to the element.\n */\nuseBlockProps.save = getBlockProps;\n"]}
|
|
@@ -17,8 +17,6 @@ var _dom2 = require("../../../utils/dom");
|
|
|
17
17
|
|
|
18
18
|
var _store = require("../../../store");
|
|
19
19
|
|
|
20
|
-
var _useMultiSelection = require("./use-multi-selection");
|
|
21
|
-
|
|
22
20
|
/**
|
|
23
21
|
* External dependencies
|
|
24
22
|
*/
|
|
@@ -45,7 +43,6 @@ function useInitialPosition(clientId) {
|
|
|
45
43
|
return (0, _data.useSelect)(select => {
|
|
46
44
|
const {
|
|
47
45
|
getSelectedBlocksInitialCaretPosition,
|
|
48
|
-
isMultiSelecting,
|
|
49
46
|
isNavigationMode,
|
|
50
47
|
isBlockSelected
|
|
51
48
|
} = select(_store.store);
|
|
@@ -54,7 +51,7 @@ function useInitialPosition(clientId) {
|
|
|
54
51
|
return;
|
|
55
52
|
}
|
|
56
53
|
|
|
57
|
-
if (
|
|
54
|
+
if (isNavigationMode()) {
|
|
58
55
|
return;
|
|
59
56
|
} // If there's no initial position, return 0 to focus the start.
|
|
60
57
|
|
|
@@ -62,13 +59,6 @@ function useInitialPosition(clientId) {
|
|
|
62
59
|
return getSelectedBlocksInitialCaretPosition();
|
|
63
60
|
}, [clientId]);
|
|
64
61
|
}
|
|
65
|
-
|
|
66
|
-
function isFormElement(element) {
|
|
67
|
-
const {
|
|
68
|
-
tagName
|
|
69
|
-
} = element;
|
|
70
|
-
return tagName === 'INPUT' || tagName === 'BUTTON' || tagName === 'SELECT' || tagName === 'TEXTAREA';
|
|
71
|
-
}
|
|
72
62
|
/**
|
|
73
63
|
* Transitions focus to the block or inner tabbable when the block becomes
|
|
74
64
|
* selected and an initial position is set.
|
|
@@ -82,7 +72,16 @@ function isFormElement(element) {
|
|
|
82
72
|
function useFocusFirstElement(clientId) {
|
|
83
73
|
const ref = (0, _element.useRef)();
|
|
84
74
|
const initialPosition = useInitialPosition(clientId);
|
|
75
|
+
const {
|
|
76
|
+
isBlockSelected,
|
|
77
|
+
isMultiSelecting
|
|
78
|
+
} = (0, _data.useSelect)(_store.store);
|
|
85
79
|
(0, _element.useEffect)(() => {
|
|
80
|
+
// Check if the block is still selected at the time this effect runs.
|
|
81
|
+
if (!isBlockSelected(clientId) || isMultiSelecting()) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
86
85
|
if (initialPosition === undefined || initialPosition === null) {
|
|
87
86
|
return;
|
|
88
87
|
}
|
|
@@ -113,20 +112,18 @@ function useFocusFirstElement(clientId) {
|
|
|
113
112
|
} // Check to see if element is focussable before a generic caret insert.
|
|
114
113
|
|
|
115
114
|
|
|
116
|
-
if (!
|
|
117
|
-
const focusElement = _dom.focus.tabbable.findNext(
|
|
118
|
-
// 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.
|
|
115
|
+
if (!ref.current.getAttribute('contenteditable')) {
|
|
116
|
+
const focusElement = _dom.focus.tabbable.findNext(ref.current); // Make sure focusElement is valid, contained in the same block, and a form field.
|
|
119
117
|
|
|
120
118
|
|
|
121
|
-
if (focusElement &&
|
|
119
|
+
if (focusElement && (0, _dom2.isInsideRootBlock)(ref.current, focusElement) && (0, _dom.isFormElement)(focusElement)) {
|
|
122
120
|
focusElement.focus();
|
|
123
121
|
return;
|
|
124
122
|
}
|
|
125
123
|
}
|
|
126
124
|
|
|
127
|
-
(0, _useMultiSelection.setContentEditableWrapper)(ref.current, false);
|
|
128
125
|
(0, _dom.placeCaretAtHorizontalEdge)(target, isReverse);
|
|
129
|
-
}, [initialPosition]);
|
|
126
|
+
}, [initialPosition, clientId]);
|
|
130
127
|
return ref;
|
|
131
128
|
}
|
|
132
129
|
//# sourceMappingURL=use-focus-first-element.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-focus-first-element.js"],"names":["useInitialPosition","clientId","select","getSelectedBlocksInitialCaretPosition","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-focus-first-element.js"],"names":["useInitialPosition","clientId","select","getSelectedBlocksInitialCaretPosition","isNavigationMode","isBlockSelected","blockEditorStore","useFocusFirstElement","ref","initialPosition","isMultiSelecting","undefined","current","ownerDocument","contains","activeElement","textInputs","focus","tabbable","find","filter","node","isReverse","target","last","first","getAttribute","focusElement","findNext"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AAMA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,kBAAT,CAA6BC,QAA7B,EAAwC;AACvC,SAAO,qBACJC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,qCADK;AAELC,MAAAA,gBAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEI,YAAF,CAJV;;AAMA,QAAK,CAAED,eAAe,CAAEJ,QAAF,CAAtB,EAAqC;AACpC;AACA;;AAED,QAAKG,gBAAgB,EAArB,EAA0B;AACzB;AACA,KAbY,CAeb;;;AACA,WAAOD,qCAAqC,EAA5C;AACA,GAlBK,EAmBN,CAAEF,Q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AAZ,CAA0B,iBAA1B,CAAP,EAAuD;AACtD,YAAMC,YAAY,GAAGV,WAAMC,QAAN,CAAeU,QAAf,CAAyBpB,GAAG,CAACI,OAA7B,CAArB,CADsD,CAEtD;;;AACA,UACCe,YAAY,IACZ,6BAAmBnB,GAAG,CAACI,OAAvB,EAAgCe,YAAhC,CADA,IAEA,wBAAeA,YAAf,CAHD,EAIE;AACDA,QAAAA,YAAY,CAACV,KAAb;AACA;AACA;AACD;;AAED,yCAA4BM,MAA5B,EAAoCD,SAApC;AACA,GApDD,EAoDG,CAAEb,eAAF,EAAmBR,QAAnB,CApDH;AAsDA,SAAOO,GAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { first, last } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\nimport {\n\tfocus,\n\tisFormElement,\n\tisTextField,\n\tplaceCaretAtHorizontalEdge,\n} from '@wordpress/dom';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { isInsideRootBlock } from '../../../utils/dom';\nimport { store as blockEditorStore } from '../../../store';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\n/**\n * Returns the initial position if the block needs to be focussed, `undefined`\n * otherwise. The initial position is either 0 (start) or -1 (end).\n *\n * @param {string} clientId Block client ID.\n *\n * @return {number} The initial position, either 0 (start) or -1 (end).\n */\nfunction useInitialPosition( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetSelectedBlocksInitialCaretPosition,\n\t\t\t\tisNavigationMode,\n\t\t\t\tisBlockSelected,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockSelected( clientId ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( isNavigationMode() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If there's no initial position, return 0 to focus the start.\n\t\t\treturn getSelectedBlocksInitialCaretPosition();\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n\n/**\n * Transitions focus to the block or inner tabbable when the block becomes\n * selected and an initial position is set.\n *\n * @param {string} clientId Block client ID.\n *\n * @return {RefObject} React ref with the block element.\n */\nexport function useFocusFirstElement( clientId ) {\n\tconst ref = useRef();\n\tconst initialPosition = useInitialPosition( clientId );\n\tconst { isBlockSelected, isMultiSelecting } = useSelect( blockEditorStore );\n\n\tuseEffect( () => {\n\t\t// Check if the block is still selected at the time this effect runs.\n\t\tif ( ! isBlockSelected( clientId ) || isMultiSelecting() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( initialPosition === undefined || initialPosition === null ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerDocument } = ref.current;\n\n\t\t// Do not focus the block if it already contains the active element.\n\t\tif ( ref.current.contains( ownerDocument.activeElement ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Find all tabbables within node.\n\t\tconst textInputs = focus.tabbable\n\t\t\t.find( ref.current )\n\t\t\t.filter( ( node ) => isTextField( node ) );\n\n\t\t// If reversed (e.g. merge via backspace), use the last in the set of\n\t\t// tabbables.\n\t\tconst isReverse = -1 === initialPosition;\n\t\tconst target =\n\t\t\t( isReverse ? last : first )( textInputs ) || ref.current;\n\n\t\tif ( ! isInsideRootBlock( ref.current, target ) ) {\n\t\t\tref.current.focus();\n\t\t\treturn;\n\t\t}\n\n\t\t// Check to see if element is focussable before a generic caret insert.\n\t\tif ( ! ref.current.getAttribute( 'contenteditable' ) ) {\n\t\t\tconst focusElement = focus.tabbable.findNext( ref.current );\n\t\t\t// Make sure focusElement is valid, contained in the same block, and a form field.\n\t\t\tif (\n\t\t\t\tfocusElement &&\n\t\t\t\tisInsideRootBlock( ref.current, focusElement ) &&\n\t\t\t\tisFormElement( focusElement )\n\t\t\t) {\n\t\t\t\tfocusElement.focus();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\tplaceCaretAtHorizontalEdge( target, isReverse );\n\t}, [ initialPosition, clientId ] );\n\n\treturn ref;\n}\n"]}
|
|
@@ -44,8 +44,14 @@ function useFocusHandler(clientId) {
|
|
|
44
44
|
* @param {FocusEvent} event Focus event.
|
|
45
45
|
*/
|
|
46
46
|
function onFocus(event) {
|
|
47
|
-
//
|
|
47
|
+
// When the whole editor is editable, let writing flow handle
|
|
48
|
+
// selection.
|
|
49
|
+
if (node.parentElement.closest('[contenteditable="true"]')) {
|
|
50
|
+
return;
|
|
51
|
+
} // Check synchronously because a non-selected block might be
|
|
48
52
|
// getting data through `useSelect` asynchronously.
|
|
53
|
+
|
|
54
|
+
|
|
49
55
|
if (isBlockSelected(clientId)) {
|
|
50
56
|
// Potentially change selection away from rich text.
|
|
51
57
|
if (!event.target.isContentEditable) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-focus-handler.js"],"names":["useFocusHandler","clientId","isBlockSelected","blockEditorStore","selectBlock","selectionChange","node","onFocus","event","target","isContentEditable","addEventListener","removeEventListener"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,CAA0BC,QAA1B,EAAqC;AAC3C,QAAM;AAAEC,IAAAA;AAAF,MAAsB,qBAAWC,YAAX,CAA5B;AACA,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAAmC,uBAAaF,YAAb,CAAzC;AAEA,SAAO,2BACJG,IAAF,IAAY;AACX;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACG,aAASC,OAAT,CAAkBC,KAAlB,EAA0B;AACzB;AACA;AACA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-list/use-block-props/use-focus-handler.js"],"names":["useFocusHandler","clientId","isBlockSelected","blockEditorStore","selectBlock","selectionChange","node","onFocus","event","parentElement","closest","target","isContentEditable","addEventListener","removeEventListener"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAT,CAA0BC,QAA1B,EAAqC;AAC3C,QAAM;AAAEC,IAAAA;AAAF,MAAsB,qBAAWC,YAAX,CAA5B;AACA,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAAmC,uBAAaF,YAAb,CAAzC;AAEA,SAAO,2BACJG,IAAF,IAAY;AACX;AACH;AACA;AACA;AACA;AACA;AACA;AACA;AACG,aAASC,OAAT,CAAkBC,KAAlB,EAA0B;AACzB;AACA;AACA,UACCF,IAAI,CAACG,aAAL,CAAmBC,OAAnB,CAA4B,0BAA5B,CADD,EAEE;AACD;AACA,OAPwB,CASzB;AACA;;;AACA,UAAKR,eAAe,CAAED,QAAF,CAApB,EAAmC;AAClC;AACA,YAAK,CAAEO,KAAK,CAACG,MAAN,CAAaC,iBAApB,EAAwC;AACvCP,UAAAA,eAAe,CAAEJ,QAAF,CAAf;AACA;;AACD;AACA,OAjBwB,CAmBzB;AACA;;;AACA,UAAK,CAAE,4BAAmBK,IAAnB,EAAyBE,KAAK,CAACG,MAA/B,CAAP,EAAiD;AAChD;AACA;;AAEDP,MAAAA,WAAW,CAAEH,QAAF,CAAX;AACA;;AAEDK,IAAAA,IAAI,CAACO,gBAAL,CAAuB,SAAvB,EAAkCN,OAAlC;AAEA,WAAO,MAAM;AACZD,MAAAA,IAAI,CAACQ,mBAAL,CAA0B,SAA1B,EAAqCP,OAArC;AACA,KAFD;AAGA,GA3CK,EA4CN,CAAEL,eAAF,EAAmBE,WAAnB,CA5CM,CAAP;AA8CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { isInsideRootBlock } from '../../../utils/dom';\nimport { store as blockEditorStore } from '../../../store';\n\n/**\n * Selects the block if it receives focus.\n *\n * @param {string} clientId Block client ID.\n */\nexport function useFocusHandler( clientId ) {\n\tconst { isBlockSelected } = useSelect( blockEditorStore );\n\tconst { selectBlock, selectionChange } = useDispatch( blockEditorStore );\n\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\t/**\n\t\t\t * Marks the block as selected when focused and not already\n\t\t\t * selected. This specifically handles the case where block does not\n\t\t\t * set focus on its own (via `setFocus`), typically if there is no\n\t\t\t * focusable input in the block.\n\t\t\t *\n\t\t\t * @param {FocusEvent} event Focus event.\n\t\t\t */\n\t\t\tfunction onFocus( event ) {\n\t\t\t\t// When the whole editor is editable, let writing flow handle\n\t\t\t\t// selection.\n\t\t\t\tif (\n\t\t\t\t\tnode.parentElement.closest( '[contenteditable=\"true\"]' )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Check synchronously because a non-selected block might be\n\t\t\t\t// getting data through `useSelect` asynchronously.\n\t\t\t\tif ( isBlockSelected( clientId ) ) {\n\t\t\t\t\t// Potentially change selection away from rich text.\n\t\t\t\t\tif ( ! event.target.isContentEditable ) {\n\t\t\t\t\t\tselectionChange( clientId );\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If an inner block is focussed, that block is resposible for\n\t\t\t\t// setting the selected block.\n\t\t\t\tif ( ! isInsideRootBlock( node, event.target ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselectBlock( clientId );\n\t\t\t}\n\n\t\t\tnode.addEventListener( 'focusin', onFocus );\n\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'focusin', onFocus );\n\t\t\t};\n\t\t},\n\t\t[ isBlockSelected, selectBlock ]\n\t);\n}\n"]}
|
|
@@ -85,7 +85,12 @@ function BlockListAppender(_ref) {
|
|
|
85
85
|
// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
|
|
86
86
|
, {
|
|
87
87
|
tabIndex: -1,
|
|
88
|
-
className: (0, _classnames.default)('block-list-appender wp-block', className) //
|
|
88
|
+
className: (0, _classnames.default)('block-list-appender wp-block', className) // Needed in case the whole editor is content editable (for multi
|
|
89
|
+
// selection). It fixes an edge case where ArrowDown and ArrowRight
|
|
90
|
+
// should collapse the selection to the end of that selection and
|
|
91
|
+
// not into the appender.
|
|
92
|
+
,
|
|
93
|
+
contentEditable: false // The appender exists to let you add the first Paragraph before
|
|
89
94
|
// any is inserted. To that end, this appender should visually be
|
|
90
95
|
// presented as a block. That means theme CSS should style it as if
|
|
91
96
|
// it were an empty paragraph block. That means a `wp-block` class to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-list-appender/index.js"],"names":["BlockListAppender","rootClientId","canInsertDefaultBlock","isLocked","renderAppender","CustomAppender","className","selectedBlockClientId","tagName","TagName","appender","isParentSelected","select","canInsertBlockType","getTemplateLock","getSelectedBlockClientId","blockEditorStore"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAKA,SAASA,iBAAT,OAQI;AAAA,MARwB;AAC3BC,IAAAA,YAD2B;AAE3BC,IAAAA,qBAF2B;AAG3BC,IAAAA,QAH2B;AAI3BC,IAAAA,cAAc,EAAEC,cAJW;AAK3BC,IAAAA,SAL2B;AAM3BC,IAAAA,qBAN2B;AAO3BC,IAAAA,OAAO,EAAEC,OAAO,GAAG;AAPQ,GAQxB;;AACH,MAAKN,QAAQ,IAAIE,cAAc,KAAK,KAApC,EAA4C;AAC3C,WAAO,IAAP;AACA;;AAED,MAAIK,QAAJ;;AACA,MAAKL,cAAL,EAAsB;AACrB;AACAK,IAAAA,QAAQ,GAAG,4BAAC,cAAD,OAAX;AACA,GAHD,MAGO;AACN,UAAMC,gBAAgB,GACrBJ,qBAAqB,KAAKN,YAA1B,IACE,CAAEA,YAAF,IAAkB,CAAEM,qBAFvB;;AAIA,QAAK,CAAEI,gBAAP,EAA0B;AACzB,aAAO,IAAP;AACA;;AAED,QAAKT,qBAAL,EAA6B;AAC5B;AACA;AACAQ,MAAAA,QAAQ,GAAG,4BAAC,6BAAD;AAAsB,QAAA,YAAY,EAAGT;AAArC,QAAX;AACA,KAJD,MAIO;AACN;AACA;AACAS,MAAAA,QAAQ,GACP,4BAAC,4BAAD;AACC,QAAA,YAAY,EAAGT,YADhB;AAEC,QAAA,SAAS,EAAC;AAFX,QADD;AAMA;AACD;;AAED,SACC,4BAAC,OAAD,CACC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AARD;AASC,IAAA,QAAQ,EAAG,CAAC,CATb;AAUC,IAAA,SAAS,EAAG,yBACX,8BADW,EAEXK,SAFW,CAVb,CAcC;AACA;AACA;AACA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-list-appender/index.js"],"names":["BlockListAppender","rootClientId","canInsertDefaultBlock","isLocked","renderAppender","CustomAppender","className","selectedBlockClientId","tagName","TagName","appender","isParentSelected","select","canInsertBlockType","getTemplateLock","getSelectedBlockClientId","blockEditorStore"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAKA,SAASA,iBAAT,OAQI;AAAA,MARwB;AAC3BC,IAAAA,YAD2B;AAE3BC,IAAAA,qBAF2B;AAG3BC,IAAAA,QAH2B;AAI3BC,IAAAA,cAAc,EAAEC,cAJW;AAK3BC,IAAAA,SAL2B;AAM3BC,IAAAA,qBAN2B;AAO3BC,IAAAA,OAAO,EAAEC,OAAO,GAAG;AAPQ,GAQxB;;AACH,MAAKN,QAAQ,IAAIE,cAAc,KAAK,KAApC,EAA4C;AAC3C,WAAO,IAAP;AACA;;AAED,MAAIK,QAAJ;;AACA,MAAKL,cAAL,E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port classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { withSelect } from '@wordpress/data';\nimport { getDefaultBlockName } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport DefaultBlockAppender from '../default-block-appender';\nimport ButtonBlockAppender from '../button-block-appender';\nimport { store as blockEditorStore } from '../../store';\n\nfunction BlockListAppender( {\n\trootClientId,\n\tcanInsertDefaultBlock,\n\tisLocked,\n\trenderAppender: CustomAppender,\n\tclassName,\n\tselectedBlockClientId,\n\ttagName: TagName = 'div',\n} ) {\n\tif ( isLocked || CustomAppender === false ) {\n\t\treturn null;\n\t}\n\n\tlet appender;\n\tif ( CustomAppender ) {\n\t\t// Prefer custom render prop if provided.\n\t\tappender = <CustomAppender />;\n\t} else {\n\t\tconst isParentSelected =\n\t\t\tselectedBlockClientId === rootClientId ||\n\t\t\t( ! rootClientId && ! selectedBlockClientId );\n\n\t\tif ( ! isParentSelected ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif ( canInsertDefaultBlock ) {\n\t\t\t// Render the default block appender when renderAppender has not been\n\t\t\t// provided and the context supports use of the default appender.\n\t\t\tappender = <DefaultBlockAppender rootClientId={ rootClientId } />;\n\t\t} else {\n\t\t\t// Fallback in the case no renderAppender has been provided and the\n\t\t\t// default block can't be inserted.\n\t\t\tappender = (\n\t\t\t\t<ButtonBlockAppender\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\tclassName=\"block-list-appender__toggle\"\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\t}\n\n\treturn (\n\t\t<TagName\n\t\t\t// A `tabIndex` is used on the wrapping `div` element in order to\n\t\t\t// force a focus event to occur when an appender `button` element\n\t\t\t// is clicked. In some browsers (Firefox, Safari), button clicks do\n\t\t\t// not emit a focus event, which could cause this event to propagate\n\t\t\t// unexpectedly. The `tabIndex` ensures that the interaction is\n\t\t\t// captured as a focus, without also adding an extra tab stop.\n\t\t\t//\n\t\t\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\t\t\ttabIndex={ -1 }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-list-appender wp-block',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\t// Needed in case the whole editor is content editable (for multi\n\t\t\t// selection). It fixes an edge case where ArrowDown and ArrowRight\n\t\t\t// should collapse the selection to the end of that selection and\n\t\t\t// not into the appender.\n\t\t\tcontentEditable={ false }\n\t\t\t// The appender exists to let you add the first Paragraph before\n\t\t\t// any is inserted. To that end, this appender should visually be\n\t\t\t// presented as a block. That means theme CSS should style it as if\n\t\t\t// it were an empty paragraph block. That means a `wp-block` class to\n\t\t\t// ensure the width is correct, and a [data-block] attribute to ensure\n\t\t\t// the correct margin is applied, especially for classic themes which\n\t\t\t// have commonly targeted that attribute for margins.\n\t\t\tdata-block\n\t\t>\n\t\t\t{ appender }\n\t\t</TagName>\n\t);\n}\n\nexport default withSelect( ( select, { rootClientId } ) => {\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetTemplateLock,\n\t\tgetSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\n\treturn {\n\t\tisLocked: !! getTemplateLock( rootClientId ),\n\t\tcanInsertDefaultBlock: canInsertBlockType(\n\t\t\tgetDefaultBlockName(),\n\t\t\trootClientId\n\t\t),\n\t\tselectedBlockClientId: getSelectedBlockClientId(),\n\t};\n} )( BlockListAppender );\n"]}
|
|
@@ -23,10 +23,18 @@ Object.defineProperty(exports, "BlockLockToolbar", {
|
|
|
23
23
|
return _toolbar.default;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
+
Object.defineProperty(exports, "useBlockLock", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () {
|
|
29
|
+
return _useBlockLock.default;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
26
32
|
|
|
27
33
|
var _menuItem = _interopRequireDefault(require("./menu-item"));
|
|
28
34
|
|
|
29
35
|
var _modal = _interopRequireDefault(require("./modal"));
|
|
30
36
|
|
|
31
37
|
var _toolbar = _interopRequireDefault(require("./toolbar"));
|
|
38
|
+
|
|
39
|
+
var _useBlockLock = _interopRequireDefault(require("./use-block-lock"));
|
|
32
40
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA","sourcesContent":["export { default as BlockLockMenuItem } from './menu-item';\nexport { default as BlockLockModal } from './modal';\nexport { default as BlockLockToolbar } from './toolbar';\nexport { default as useBlockLock } from './use-block-lock';\n"]}
|
|
@@ -13,13 +13,11 @@ var _i18n = require("@wordpress/i18n");
|
|
|
13
13
|
|
|
14
14
|
var _components = require("@wordpress/components");
|
|
15
15
|
|
|
16
|
-
var _data = require("@wordpress/data");
|
|
17
|
-
|
|
18
16
|
var _icons = require("@wordpress/icons");
|
|
19
17
|
|
|
20
|
-
var
|
|
18
|
+
var _useBlockLock = _interopRequireDefault(require("./use-block-lock"));
|
|
21
19
|
|
|
22
|
-
var
|
|
20
|
+
var _modal = _interopRequireDefault(require("./modal"));
|
|
23
21
|
|
|
24
22
|
/**
|
|
25
23
|
* WordPress dependencies
|
|
@@ -33,19 +31,15 @@ function BlockLockMenuItem(_ref) {
|
|
|
33
31
|
clientId
|
|
34
32
|
} = _ref;
|
|
35
33
|
const {
|
|
34
|
+
canLock,
|
|
36
35
|
isLocked
|
|
37
|
-
} = (0,
|
|
38
|
-
const {
|
|
39
|
-
canMoveBlock,
|
|
40
|
-
canRemoveBlock,
|
|
41
|
-
getBlockRootClientId
|
|
42
|
-
} = select(_store.store);
|
|
43
|
-
const rootClientId = getBlockRootClientId(clientId);
|
|
44
|
-
return {
|
|
45
|
-
isLocked: !canMoveBlock(clientId, rootClientId) || !canRemoveBlock(clientId, rootClientId)
|
|
46
|
-
};
|
|
47
|
-
}, [clientId]);
|
|
36
|
+
} = (0, _useBlockLock.default)(clientId);
|
|
48
37
|
const [isModalOpen, toggleModal] = (0, _element.useReducer)(isActive => !isActive, false);
|
|
38
|
+
|
|
39
|
+
if (!canLock) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
49
43
|
const label = isLocked ? (0, _i18n.__)('Unlock') : (0, _i18n.__)('Lock');
|
|
50
44
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.MenuItem, {
|
|
51
45
|
icon: isLocked ? _icons.unlock : _icons.lock,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/menu-item.js"],"names":["BlockLockMenuItem","clientId","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/menu-item.js"],"names":["BlockLockMenuItem","clientId","canLock","isLocked","isModalOpen","toggleModal","isActive","label","unlock","lock"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AAKA;;AACA;;AAZA;AACA;AACA;;AAMA;AACA;AACA;AAIe,SAASA,iBAAT,OAA2C;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACzD,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,MAAwB,2BAAcF,QAAd,CAA9B;AAEA,QAAM,CAAEG,WAAF,EAAeC,WAAf,IAA+B,yBAClCC,QAAF,IAAgB,CAAEA,QADkB,EAEpC,KAFoC,CAArC;;AAKA,MAAK,CAAEJ,OAAP,EAAiB;AAChB,WAAO,IAAP;AACA;;AAED,QAAMK,KAAK,GAAGJ,QAAQ,GAAG,cAAI,QAAJ,CAAH,GAAoB,cAAI,MAAJ,CAA1C;AAEA,SACC,qDACC,4BAAC,oBAAD;AAAU,IAAA,IAAI,EAAGA,QAAQ,GAAGK,aAAH,GAAYC,WAArC;AAA4C,IAAA,OAAO,EAAGJ;AAAtD,KACGE,KADH,CADD,EAIGH,WAAW,IACZ,4BAAC,cAAD;AAAgB,IAAA,QAAQ,EAAGH,QAA3B;AAAsC,IAAA,OAAO,EAAGI;AAAhD,IALF,CADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useReducer } from '@wordpress/element';\nimport { MenuItem } from '@wordpress/components';\nimport { lock, unlock } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport useBlockLock from './use-block-lock';\nimport BlockLockModal from './modal';\n\nexport default function BlockLockMenuItem( { clientId } ) {\n\tconst { canLock, isLocked } = useBlockLock( clientId );\n\n\tconst [ isModalOpen, toggleModal ] = useReducer(\n\t\t( isActive ) => ! isActive,\n\t\tfalse\n\t);\n\n\tif ( ! canLock ) {\n\t\treturn null;\n\t}\n\n\tconst label = isLocked ? __( 'Unlock' ) : __( 'Lock' );\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem icon={ isLocked ? unlock : lock } onClick={ toggleModal }>\n\t\t\t\t{ label }\n\t\t\t</MenuItem>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<BlockLockModal clientId={ clientId } onClose={ toggleModal } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -19,6 +19,10 @@ var _compose = require("@wordpress/compose");
|
|
|
19
19
|
|
|
20
20
|
var _data = require("@wordpress/data");
|
|
21
21
|
|
|
22
|
+
var _blocks = require("@wordpress/blocks");
|
|
23
|
+
|
|
24
|
+
var _useBlockLock = _interopRequireDefault(require("./use-block-lock"));
|
|
25
|
+
|
|
22
26
|
var _useBlockDisplayInformation = _interopRequireDefault(require("../use-block-display-information"));
|
|
23
27
|
|
|
24
28
|
var _store = require("../../store");
|
|
@@ -40,18 +44,19 @@ function BlockLockModal(_ref) {
|
|
|
40
44
|
remove: false
|
|
41
45
|
});
|
|
42
46
|
const {
|
|
47
|
+
canEdit,
|
|
43
48
|
canMove,
|
|
44
49
|
canRemove
|
|
50
|
+
} = (0, _useBlockLock.default)(clientId);
|
|
51
|
+
const {
|
|
52
|
+
isReusable
|
|
45
53
|
} = (0, _data.useSelect)(select => {
|
|
46
54
|
const {
|
|
47
|
-
|
|
48
|
-
canRemoveBlock,
|
|
49
|
-
getBlockRootClientId
|
|
55
|
+
getBlockName
|
|
50
56
|
} = select(_store.store);
|
|
51
|
-
const
|
|
57
|
+
const blockName = getBlockName(clientId);
|
|
52
58
|
return {
|
|
53
|
-
|
|
54
|
-
canRemove: canRemoveBlock(clientId, rootClientId)
|
|
59
|
+
isReusable: (0, _blocks.isReusableBlock)((0, _blocks.getBlockType)(blockName))
|
|
55
60
|
};
|
|
56
61
|
}, [clientId]);
|
|
57
62
|
const {
|
|
@@ -62,20 +67,14 @@ function BlockLockModal(_ref) {
|
|
|
62
67
|
(0, _element.useEffect)(() => {
|
|
63
68
|
setLock({
|
|
64
69
|
move: !canMove,
|
|
65
|
-
remove: !canRemove
|
|
70
|
+
remove: !canRemove,
|
|
71
|
+
...(isReusable ? {
|
|
72
|
+
edit: !canEdit
|
|
73
|
+
} : {})
|
|
66
74
|
});
|
|
67
|
-
}, [canMove, canRemove]);
|
|
75
|
+
}, [canEdit, canMove, canRemove, isReusable]);
|
|
68
76
|
const isAllChecked = Object.values(lock).every(Boolean);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (isAllChecked) {
|
|
72
|
-
ariaChecked = 'true';
|
|
73
|
-
} else if (Object.values(lock).some(Boolean)) {
|
|
74
|
-
ariaChecked = 'mixed';
|
|
75
|
-
} else {
|
|
76
|
-
ariaChecked = 'false';
|
|
77
|
-
}
|
|
78
|
-
|
|
77
|
+
const isMixed = Object.values(lock).some(Boolean) && !isAllChecked;
|
|
79
78
|
return (0, _element.createElement)(_components.Modal, {
|
|
80
79
|
title: (0, _i18n.sprintf)(
|
|
81
80
|
/* translators: %s: Name of the block. */
|
|
@@ -101,18 +100,31 @@ function BlockLockModal(_ref) {
|
|
|
101
100
|
id: instanceId
|
|
102
101
|
}, (0, _i18n.__)('Lock all')),
|
|
103
102
|
checked: isAllChecked,
|
|
104
|
-
|
|
103
|
+
indeterminate: isMixed,
|
|
105
104
|
onChange: newValue => setLock({
|
|
106
105
|
move: newValue,
|
|
107
|
-
remove: newValue
|
|
106
|
+
remove: newValue,
|
|
107
|
+
...(isReusable ? {
|
|
108
|
+
edit: newValue
|
|
109
|
+
} : {})
|
|
108
110
|
})
|
|
109
111
|
}), (0, _element.createElement)("ul", {
|
|
110
112
|
className: "block-editor-block-lock-modal__checklist"
|
|
111
|
-
}, (0, _element.createElement)("li", {
|
|
113
|
+
}, isReusable && (0, _element.createElement)("li", {
|
|
114
|
+
className: "block-editor-block-lock-modal__checklist-item"
|
|
115
|
+
}, (0, _element.createElement)(_components.CheckboxControl, {
|
|
116
|
+
label: (0, _element.createElement)(_element.Fragment, null, (0, _i18n.__)('Restrict editing'), (0, _element.createElement)(_components.Icon, {
|
|
117
|
+
icon: lock.edit ? _icons.lock : _icons.unlock
|
|
118
|
+
})),
|
|
119
|
+
checked: !!lock.edit,
|
|
120
|
+
onChange: edit => setLock(prevLock => ({ ...prevLock,
|
|
121
|
+
edit
|
|
122
|
+
}))
|
|
123
|
+
})), (0, _element.createElement)("li", {
|
|
112
124
|
className: "block-editor-block-lock-modal__checklist-item"
|
|
113
125
|
}, (0, _element.createElement)(_components.CheckboxControl, {
|
|
114
126
|
label: (0, _element.createElement)(_element.Fragment, null, (0, _i18n.__)('Disable movement'), (0, _element.createElement)(_components.Icon, {
|
|
115
|
-
icon: _icons.
|
|
127
|
+
icon: lock.move ? _icons.lock : _icons.unlock
|
|
116
128
|
})),
|
|
117
129
|
checked: lock.move,
|
|
118
130
|
onChange: move => setLock(prevLock => ({ ...prevLock,
|
|
@@ -122,7 +134,7 @@ function BlockLockModal(_ref) {
|
|
|
122
134
|
className: "block-editor-block-lock-modal__checklist-item"
|
|
123
135
|
}, (0, _element.createElement)(_components.CheckboxControl, {
|
|
124
136
|
label: (0, _element.createElement)(_element.Fragment, null, (0, _i18n.__)('Prevent removal'), (0, _element.createElement)(_components.Icon, {
|
|
125
|
-
icon: _icons.
|
|
137
|
+
icon: lock.remove ? _icons.lock : _icons.unlock
|
|
126
138
|
})),
|
|
127
139
|
checked: lock.remove,
|
|
128
140
|
onChange: remove => setLock(prevLock => ({ ...prevLock,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/modal.js"],"names":["BlockLockModal","clientId","onClose","lock","setLock","move","remove","canMove","canRemove","select","canMoveBlock","canRemoveBlock","getBlockRootClientId","blockEditorStore","rootClientId","updateBlockAttributes","blockInformation","instanceId","isAllChecked","Object","values","every","Boolean","ariaChecked","some","title","event","preventDefault","newValue","dragHandle","prevLock","trash"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AAQA;;AACA;;AACA;;AAKA;;AACA;;AArBA;AACA;AACA;;AAeA;AACA;AACA;AAIe,SAASA,cAAT,OAAiD;AAAA,MAAxB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAwB;AAC/D,QAAM,CAAEC,IAAF,EAAQC,OAAR,IAAoB,uBAAU;AAAEC,IAAAA,IAAI,EAAE,KAAR;AAAeC,IAAAA,MAAM,EAAE;AAAvB,GAAV,CAA1B;AACA,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,MAAyB,qBAC5BC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,YADK;AAELC,MAAAA,cAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEI,YAAF,CAJV;AAKA,UAAMC,YAAY,GAAGF,oBAAoB,CAAEX,QAAF,CAAzC;AAEA,WAAO;AACNM,MAAAA,OAAO,EAAEG,YAAY,CAAET,QAAF,EAAYa,YAAZ,CADf;AAENN,MAAAA,SAAS,EAAEG,cAAc,CAAEV,QAAF,EAAYa,YAAZ;AAFnB,KAAP;AAIA,GAb6B,EAc9B,CAAEb,QAAF,CAd8B,CAA/B;AAgB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QACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,OAAO,EAAGJ;AAArC,KACG,cAAI,QAAJ,CADH,CADD,CALD,EAUC,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAC;AAA/B,KACG,cAAI,OAAJ,CADH,CADD,CAVD,CApED,CAVD,CADD;AAkGA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useEffect, useState } from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tFlex,\n\tFlexItem,\n\tIcon,\n\tModal,\n} from '@wordpress/components';\nimport { dragHandle, trash } from '@wordpress/icons';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { store as blockEditorStore } from '../../store';\n\nexport default function BlockLockModal( { clientId, onClose } ) {\n\tconst [ lock, setLock ] = useState( { move: false, remove: false } );\n\tconst { canMove, canRemove } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanMoveBlock,\n\t\t\t\tcanRemoveBlock,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn {\n\t\t\t\tcanMove: canMoveBlock( clientId, rootClientId ),\n\t\t\t\tcanRemove: canRemoveBlock( clientId, rootClientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst instanceId = useInstanceId(\n\t\tBlockLockModal,\n\t\t'block-editor-block-lock-modal__options-title'\n\t);\n\n\tuseEffect( () => {\n\t\tsetLock( {\n\t\t\tmove: ! canMove,\n\t\t\tremove: ! canRemove,\n\t\t} );\n\t}, [ canMove, canRemove ] );\n\n\tconst isAllChecked = Object.values( lock ).every( Boolean );\n\n\tlet ariaChecked;\n\tif ( isAllChecked ) {\n\t\tariaChecked = 'true';\n\t} else if ( Object.values( lock ).some( Boolean ) ) {\n\t\tariaChecked = 'mixed';\n\t} else {\n\t\tariaChecked = 'false';\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ sprintf(\n\t\t\t\t/* translators: %s: Name of the block. */\n\t\t\t\t__( 'Lock %s' ),\n\t\t\t\tblockInformation.title\n\t\t\t) }\n\t\t\toverlayClassName=\"block-editor-block-lock-modal\"\n\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tupdateBlockAttributes( [ clientId ], { lock } );\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Choose specific attributes to restrict or lock all available options.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t\t<div\n\t\t\t\t\trole=\"group\"\n\t\t\t\t\taria-labelledby={ instanceId }\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options\"\n\t\t\t\t>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options-title\"\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t<span id={ instanceId }>{ __( 'Lock all' ) }</span>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchecked={ isAllChecked }\n\t\t\t\t\t\taria-checked={ ariaChecked }\n\t\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\t\tsetLock( {\n\t\t\t\t\t\t\t\tmove: newValue,\n\t\t\t\t\t\t\t\tremove: newValue,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<ul className=\"block-editor-block-lock-modal__checklist\">\n\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Disable movement' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ dragHandle } />\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ lock.move }\n\t\t\t\t\t\t\t\tonChange={ ( move ) =>\n\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\tmove,\n\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Prevent removal' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ trash } />\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ lock.remove }\n\t\t\t\t\t\t\t\tonChange={ ( remove ) =>\n\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\tremove,\n\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t</div>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/modal.js"],"names":["BlockLockModal","clientId","onClose","lock","setLock","move","remove","canEdit","canMove","canRemove","isReusable","select","getBlockName","blockEditorStore","blockName","updateBlockAttributes","blockInformation","instanceId","edit","isAllChecked","Object","values","every","Boolean","isMixed","some","title","event","preventDefault","newValue","lockIcon","unlockIcon","prevLock"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AAQA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAgBA;AACA;AACA;AAKe,SAASA,cAAT,OAAiD;AAAA,MAAxB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAwB;AAC/D,QAAM,CAAEC,IAAF,EAAQC,OAAR,IAAoB,uBAAU;AAAEC,IAAAA,IAAI,EAAE,KAAR;AAAeC,IAAAA,MAAM,EAAE;AAAvB,GAAV,CAA1B;AACA,QAAM;AAAEC,IAAAA,OAAF;AAAWC,IAAAA,OAAX;AAAoBC,IAAAA;AAApB,MAAkC,2BAAcR,QAAd,CAAxC;AACA,QAAM;AAAES,IAAAA;AAAF,MAAiB,qBACpBC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAmBD,MAAM,CAAEE,YAAF,CAA/B;AACA,UAAMC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AaC,IAAA,OAAO,EAAG5B,IAAI,CAACE,IAbhB;AAcC,IAAA,QAAQ,EAAKA,IAAF,IACVD,OAAO,CAAI4B,QAAF,KAAkB,EAC1B,GAAGA,QADuB;AAE1B3B,MAAAA;AAF0B,KAAlB,CAAF;AAfT,IADD,CA1BD,EAiDC;AAAI,IAAA,SAAS,EAAC;AAAd,KACC,4BAAC,2BAAD;AACC,IAAA,KAAK,EACJ,qDACG,cAAI,iBAAJ,CADH,EAEC,4BAAC,gBAAD;AACC,MAAA,IAAI,EACHF,IAAI,CAACG,MAAL,GACGwB,WADH,GAEGC;AAJL,MAFD,CAFF;AAaC,IAAA,OAAO,EAAG5B,IAAI,CAACG,MAbhB;AAcC,IAAA,QAAQ,EAAKA,MAAF,IACVF,OAAO,CAAI4B,QAAF,KAAkB,EAC1B,GAAGA,QADuB;AAE1B1B,MAAAA;AAF0B,KAAlB,CAAF;AAfT,IADD,CAjDD,CApBD,CAZD,EA0GC,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAC,wCADX;AAEC,IAAA,OAAO,EAAC,UAFT;AAGC,IAAA,QAAQ,EAAG;AAHZ,KAKC,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,OAAO,EAAGJ;AAArC,KACG,cAAI,QAAJ,CADH,CADD,CALD,EAUC,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,IAAI,EAAC;AAA/B,KACG,cAAI,OAAJ,CADH,CADD,CAVD,CA1GD,CAVD,CADD;AAwIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useEffect, useState } from '@wordpress/element';\nimport {\n\tButton,\n\tCheckboxControl,\n\tFlex,\n\tFlexItem,\n\tIcon,\n\tModal,\n} from '@wordpress/components';\nimport { lock as lockIcon, unlock as unlockIcon } from '@wordpress/icons';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { isReusableBlock, getBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport useBlockLock from './use-block-lock';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { store as blockEditorStore } from '../../store';\n\nexport default function BlockLockModal( { clientId, onClose } ) {\n\tconst [ lock, setLock ] = useState( { move: false, remove: false } );\n\tconst { canEdit, canMove, canRemove } = useBlockLock( clientId );\n\tconst { isReusable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockName } = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\n\t\t\treturn {\n\t\t\t\tisReusable: isReusableBlock( getBlockType( blockName ) ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst instanceId = useInstanceId(\n\t\tBlockLockModal,\n\t\t'block-editor-block-lock-modal__options-title'\n\t);\n\n\tuseEffect( () => {\n\t\tsetLock( {\n\t\t\tmove: ! canMove,\n\t\t\tremove: ! canRemove,\n\t\t\t...( isReusable ? { edit: ! canEdit } : {} ),\n\t\t} );\n\t}, [ canEdit, canMove, canRemove, isReusable ] );\n\n\tconst isAllChecked = Object.values( lock ).every( Boolean );\n\tconst isMixed = Object.values( lock ).some( Boolean ) && ! isAllChecked;\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ sprintf(\n\t\t\t\t/* translators: %s: Name of the block. */\n\t\t\t\t__( 'Lock %s' ),\n\t\t\t\tblockInformation.title\n\t\t\t) }\n\t\t\toverlayClassName=\"block-editor-block-lock-modal\"\n\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<form\n\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tupdateBlockAttributes( [ clientId ], { lock } );\n\t\t\t\t\tonClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<p>\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Choose specific attributes to restrict or lock all available options.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t\t<div\n\t\t\t\t\trole=\"group\"\n\t\t\t\t\taria-labelledby={ instanceId }\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options\"\n\t\t\t\t>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\tclassName=\"block-editor-block-lock-modal__options-title\"\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t<span id={ instanceId }>{ __( 'Lock all' ) }</span>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchecked={ isAllChecked }\n\t\t\t\t\t\tindeterminate={ isMixed }\n\t\t\t\t\t\tonChange={ ( newValue ) =>\n\t\t\t\t\t\t\tsetLock( {\n\t\t\t\t\t\t\t\tmove: newValue,\n\t\t\t\t\t\t\t\tremove: newValue,\n\t\t\t\t\t\t\t\t...( isReusable ? { edit: newValue } : {} ),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<ul className=\"block-editor-block-lock-modal__checklist\">\n\t\t\t\t\t\t{ isReusable && (\n\t\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Restrict editing' ) }\n\t\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\t\tlock.edit\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t? lockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t: unlockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tchecked={ !! lock.edit }\n\t\t\t\t\t\t\t\t\tonChange={ ( edit ) =>\n\t\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\t\tedit,\n\t\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</li>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Disable movement' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tlock.move\n\t\t\t\t\t\t\t\t\t\t\t\t\t? lockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t: unlockIcon\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ lock.move }\n\t\t\t\t\t\t\t\tonChange={ ( move ) =>\n\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\tmove,\n\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t\t<li className=\"block-editor-block-lock-modal__checklist-item\">\n\t\t\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Prevent removal' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tlock.remove\n\t\t\t\t\t\t\t\t\t\t\t\t\t? lockIcon\n\t\t\t\t\t\t\t\t\t\t\t\t\t: unlockIcon\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ lock.remove }\n\t\t\t\t\t\t\t\tonChange={ ( remove ) =>\n\t\t\t\t\t\t\t\t\tsetLock( ( prevLock ) => ( {\n\t\t\t\t\t\t\t\t\t\t...prevLock,\n\t\t\t\t\t\t\t\t\t\tremove,\n\t\t\t\t\t\t\t\t\t} ) )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t</ul>\n\t\t\t\t</div>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"block-editor-block-lock-modal__actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\texpanded={ false }\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ onClose }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"primary\" type=\"submit\">\n\t\t\t\t\t\t\t{ __( 'Apply' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
@@ -15,13 +15,11 @@ var _components = require("@wordpress/components");
|
|
|
15
15
|
|
|
16
16
|
var _icons = require("@wordpress/icons");
|
|
17
17
|
|
|
18
|
-
var _data = require("@wordpress/data");
|
|
19
|
-
|
|
20
18
|
var _modal = _interopRequireDefault(require("./modal"));
|
|
21
19
|
|
|
22
|
-
var
|
|
20
|
+
var _useBlockLock = _interopRequireDefault(require("./use-block-lock"));
|
|
23
21
|
|
|
24
|
-
var
|
|
22
|
+
var _useBlockDisplayInformation = _interopRequireDefault(require("../use-block-display-information"));
|
|
25
23
|
|
|
26
24
|
/**
|
|
27
25
|
* WordPress dependencies
|
|
@@ -36,21 +34,18 @@ function BlockLockToolbar(_ref) {
|
|
|
36
34
|
} = _ref;
|
|
37
35
|
const blockInformation = (0, _useBlockDisplayInformation.default)(clientId);
|
|
38
36
|
const {
|
|
37
|
+
canEdit,
|
|
39
38
|
canMove,
|
|
40
|
-
canRemove
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
canMoveBlock,
|
|
44
|
-
canRemoveBlock
|
|
45
|
-
} = select(_store.store);
|
|
46
|
-
return {
|
|
47
|
-
canMove: canMoveBlock(clientId),
|
|
48
|
-
canRemove: canRemoveBlock(clientId)
|
|
49
|
-
};
|
|
50
|
-
}, [clientId]);
|
|
39
|
+
canRemove,
|
|
40
|
+
canLock
|
|
41
|
+
} = (0, _useBlockLock.default)(clientId);
|
|
51
42
|
const [isModalOpen, toggleModal] = (0, _element.useReducer)(isActive => !isActive, false);
|
|
52
43
|
|
|
53
|
-
if (
|
|
44
|
+
if (!canLock) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (canEdit && canMove && canRemove) {
|
|
54
49
|
return null;
|
|
55
50
|
}
|
|
56
51
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/toolbar.js"],"names":["BlockLockToolbar","clientId","blockInformation","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/toolbar.js"],"names":["BlockLockToolbar","clientId","blockInformation","canEdit","canMove","canRemove","canLock","isModalOpen","toggleModal","isActive","lock","title"],"mappings":";;;;;;;;;AAKA;;AAFA;;AACA;;AAEA;;AAKA;;AACA;;AACA;;AAbA;AACA;AACA;;AAMA;AACA;AACA;AAKe,SAASA,gBAAT,OAA0C;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACxD,QAAMC,gBAAgB,GAAG,yCAA4BD,QAA5B,CAAzB;AACA,QAAM;AAAEE,IAAAA,OAAF;AAAWC,IAAAA,OAAX;AAAoBC,IAAAA,SAApB;AAA+BC,IAAAA;AAA/B,MAA2C,2BAAcL,QAAd,CAAjD;AAEA,QAAM,CAAEM,WAAF,EAAeC,WAAf,IAA+B,yBAClCC,QAAF,IAAgB,CAAEA,QADkB,EAEpC,KAFoC,CAArC;;AAKA,MAAK,CAAEH,OAAP,EAAiB;AAChB,WAAO,IAAP;AACA;;AAED,MAAKH,OAAO,IAAIC,OAAX,IAAsBC,SAA3B,EAAuC;AACtC,WAAO,IAAP;AACA;;AAED,SACC,qDACC,4BAAC,wBAAD;AAAc,IAAA,SAAS,EAAC;AAAxB,KACC,4BAAC,yBAAD;AACC,IAAA,IAAI,EAAGK,WADR;AAEC,IAAA,KAAK,EAAG;AACP;AACA,kBAAI,WAAJ,CAFO,EAGPR,gBAAgB,CAACS,KAHV,CAFT;AAOC,IAAA,OAAO,EAAGH;AAPX,IADD,CADD,EAYGD,WAAW,IACZ,4BAAC,cAAD;AAAgB,IAAA,QAAQ,EAAGN,QAA3B;AAAsC,IAAA,OAAO,EAAGO;AAAhD,IAbF,CADD;AAkBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { useReducer } from '@wordpress/element';\nimport { lock } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport BlockLockModal from './modal';\nimport useBlockLock from './use-block-lock';\nimport useBlockDisplayInformation from '../use-block-display-information';\n\nexport default function BlockLockToolbar( { clientId } ) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst { canEdit, canMove, canRemove, canLock } = useBlockLock( clientId );\n\n\tconst [ isModalOpen, toggleModal ] = useReducer(\n\t\t( isActive ) => ! isActive,\n\t\tfalse\n\t);\n\n\tif ( ! canLock ) {\n\t\treturn null;\n\t}\n\n\tif ( canEdit && canMove && canRemove ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarGroup className=\"block-editor-block-lock-toolbar\">\n\t\t\t\t<ToolbarButton\n\t\t\t\t\ticon={ lock }\n\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t/* translators: %s: block name */\n\t\t\t\t\t\t__( 'Unlock %s' ),\n\t\t\t\t\t\tblockInformation.title\n\t\t\t\t\t) }\n\t\t\t\t\tonClick={ toggleModal }\n\t\t\t\t/>\n\t\t\t</ToolbarGroup>\n\t\t\t{ isModalOpen && (\n\t\t\t\t<BlockLockModal clientId={ clientId } onClose={ toggleModal } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = useBlockLock;
|
|
7
|
+
|
|
8
|
+
var _data = require("@wordpress/data");
|
|
9
|
+
|
|
10
|
+
var _store = require("../../store");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* WordPress dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Return details about the block lock status.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} clientId The block client Id.
|
|
24
|
+
*
|
|
25
|
+
* @return {Object} Block lock status
|
|
26
|
+
*/
|
|
27
|
+
function useBlockLock(clientId) {
|
|
28
|
+
return (0, _data.useSelect)(select => {
|
|
29
|
+
const {
|
|
30
|
+
canEditBlock,
|
|
31
|
+
canMoveBlock,
|
|
32
|
+
canRemoveBlock,
|
|
33
|
+
canLockBlockType,
|
|
34
|
+
getBlockName,
|
|
35
|
+
getBlockRootClientId
|
|
36
|
+
} = select(_store.store);
|
|
37
|
+
const rootClientId = getBlockRootClientId(clientId);
|
|
38
|
+
const canEdit = canEditBlock(clientId);
|
|
39
|
+
const canMove = canMoveBlock(clientId, rootClientId);
|
|
40
|
+
const canRemove = canRemoveBlock(clientId, rootClientId);
|
|
41
|
+
return {
|
|
42
|
+
canEdit,
|
|
43
|
+
canMove,
|
|
44
|
+
canRemove,
|
|
45
|
+
canLock: canLockBlockType(getBlockName(clientId)),
|
|
46
|
+
isLocked: !canEdit || !canMove || !canRemove
|
|
47
|
+
};
|
|
48
|
+
}, [clientId]);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=use-block-lock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/block-lock/use-block-lock.js"],"names":["useBlockLock","clientId","select","canEditBlock","canMoveBlock","canRemoveBlock","canLockBlockType","getBlockName","getBlockRootClientId","blockEditorStore","rootClientId","canEdit","canMove","canRemove","canLock","isLocked"],"mappings":";;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,YAAT,CAAuBC,QAAvB,EAAkC;AAChD,SAAO,qBACJC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,YADK;AAELC,MAAAA,YAFK;AAGLC,MAAAA,cAHK;AAILC,MAAAA,gBAJK;AAKLC,MAAAA,YALK;AAMLC,MAAAA;AANK,QAOFN,MAAM,CAAEO,YAAF,CAPV;AAQA,UAAMC,YAAY,GAAGF,oBAAoB,CAAEP,QAAF,CAAzC;AAEA,UAAMU,OAAO,GAAGR,YAAY,CAAEF,QAAF,CAA5B;AACA,UAAMW,OAAO,GAAGR,YAAY,CAAEH,QAAF,EAAYS,YAAZ,CAA5B;AACA,UAAMG,SAAS,GAAGR,cAAc,CAAEJ,QAAF,EAAYS,YAAZ,CAAhC;AAEA,WAAO;AACNC,MAAAA,OADM;AAENC,MAAAA,OAFM;AAGNC,MAAAA,SAHM;AAINC,MAAAA,OAAO,EAAER,gBAAgB,CAAEC,YAAY,CAAEN,QAAF,CAAd,CAJnB;AAKNc,MAAAA,QAAQ,EAAE,CAAEJ,OAAF,IAAa,CAAEC,OAAf,IAA0B,CAAEC;AALhC,KAAP;AAOA,GAvBK,EAwBN,CAAEZ,QAAF,CAxBM,CAAP;AA0BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Return details about the block lock status.\n *\n * @param {string} clientId The block client Id.\n *\n * @return {Object} Block lock status\n */\nexport default function useBlockLock( clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanEditBlock,\n\t\t\t\tcanMoveBlock,\n\t\t\t\tcanRemoveBlock,\n\t\t\t\tcanLockBlockType,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\tconst canEdit = canEditBlock( clientId );\n\t\t\tconst canMove = canMoveBlock( clientId, rootClientId );\n\t\t\tconst canRemove = canRemoveBlock( clientId, rootClientId );\n\n\t\t\treturn {\n\t\t\t\tcanEdit,\n\t\t\t\tcanMove,\n\t\t\t\tcanRemove,\n\t\t\t\tcanLock: canLockBlockType( getBlockName( clientId ) ),\n\t\t\t\tisLocked: ! canEdit || ! canMove || ! canRemove,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n}\n"]}
|