@wordpress/block-editor 8.4.0 → 8.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +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-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/menu-item.js +9 -0
- package/build/components/block-lock/menu-item.js.map +1 -1
- package/build/components/block-lock/modal.js +4 -13
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-lock/toolbar.js +11 -3
- package/build/components/block-lock/toolbar.js.map +1 -1
- package/build/components/block-mover/index.js +4 -0
- package/build/components/block-mover/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 +1 -1
- 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 +4 -0
- 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/list-view/block-select-button.js +25 -6
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +5 -1
- 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 +297 -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 +142 -18
- package/build/store/selectors.js.map +1 -1
- 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-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/menu-item.js +9 -0
- package/build-module/components/block-lock/menu-item.js.map +1 -1
- package/build-module/components/block-lock/modal.js +5 -14
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-lock/toolbar.js +11 -3
- package/build-module/components/block-lock/toolbar.js.map +1 -1
- 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-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 +2 -2
- 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 +4 -0
- 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/list-view/block-select-button.js +22 -6
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +5 -1
- 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 +286 -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 +138 -19
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/dom.js +2 -1
- package/build-module/utils/dom.js.map +1 -1
- package/build-style/style-rtl.css +107 -74
- package/build-style/style.css +107 -74
- 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-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/menu-item.js +8 -1
- package/src/components/block-lock/modal.js +18 -13
- package/src/components/block-lock/style.scss +6 -3
- package/src/components/block-lock/toolbar.js +12 -2
- package/src/components/block-mover/index.js +3 -0
- package/src/components/block-mover/style.scss +4 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +62 -4
- package/src/components/block-switcher/index.js +2 -2
- package/src/components/block-switcher/style.scss +8 -1
- 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 +3 -0
- 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/list-view/block-select-button.js +21 -3
- package/src/components/list-view/block.js +8 -1
- 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 +349 -32
- package/src/store/defaults.js +7 -2
- package/src/store/reducer.js +25 -10
- package/src/store/selectors.js +181 -24
- package/src/store/test/selectors.js +242 -5
- 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
|
@@ -2,47 +2,63 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { store as blocksStore } from '@wordpress/blocks';
|
|
5
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
6
6
|
import {
|
|
7
|
+
Button,
|
|
7
8
|
DropdownMenu,
|
|
8
9
|
MenuGroup,
|
|
9
10
|
MenuItemsChoice,
|
|
11
|
+
VisuallyHidden,
|
|
10
12
|
} from '@wordpress/components';
|
|
11
13
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
12
|
-
import {
|
|
14
|
+
import { useMemo } from '@wordpress/element';
|
|
13
15
|
import { chevronDown } from '@wordpress/icons';
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Internal dependencies
|
|
17
19
|
*/
|
|
18
|
-
import { __experimentalGetMatchingVariation as getMatchingVariation } from '../../utils';
|
|
19
20
|
import { store as blockEditorStore } from '../../store';
|
|
20
21
|
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
22
|
+
function VariationsButtons( {
|
|
23
|
+
className,
|
|
24
|
+
onSelectVariation,
|
|
25
|
+
selectedValue,
|
|
26
|
+
variations,
|
|
27
|
+
} ) {
|
|
28
|
+
return (
|
|
29
|
+
<fieldset className={ className }>
|
|
30
|
+
<VisuallyHidden as="legend">
|
|
31
|
+
{ __( 'Transform to variation' ) }
|
|
32
|
+
</VisuallyHidden>
|
|
33
|
+
{ variations.map( ( variation ) => (
|
|
34
|
+
<Button
|
|
35
|
+
key={ variation.name }
|
|
36
|
+
icon={ variation.icon }
|
|
37
|
+
isPressed={ selectedValue === variation.name }
|
|
38
|
+
label={
|
|
39
|
+
selectedValue === variation.name
|
|
40
|
+
? variation.title
|
|
41
|
+
: sprintf(
|
|
42
|
+
/* translators: %s: Name of the block variation */
|
|
43
|
+
__( 'Transform to %s' ),
|
|
44
|
+
variation.title
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
onClick={ () => onSelectVariation( variation.name ) }
|
|
48
|
+
aria-label={ variation.title }
|
|
49
|
+
showTooltip
|
|
50
|
+
/>
|
|
51
|
+
) ) }
|
|
52
|
+
</fieldset>
|
|
38
53
|
);
|
|
39
|
-
|
|
40
|
-
setSelectedValue(
|
|
41
|
-
getMatchingVariation( blockAttributes, variations )?.name
|
|
42
|
-
);
|
|
43
|
-
}, [ blockAttributes, variations ] );
|
|
44
|
-
if ( ! variations?.length ) return null;
|
|
54
|
+
}
|
|
45
55
|
|
|
56
|
+
function VariationsDropdown( {
|
|
57
|
+
className,
|
|
58
|
+
onSelectVariation,
|
|
59
|
+
selectedValue,
|
|
60
|
+
variations,
|
|
61
|
+
} ) {
|
|
46
62
|
const selectOptions = variations.map(
|
|
47
63
|
( { name, title, description } ) => ( {
|
|
48
64
|
value: name,
|
|
@@ -50,27 +66,21 @@ function __experimentalBlockVariationTransforms( { blockClientId } ) {
|
|
|
50
66
|
info: description,
|
|
51
67
|
} )
|
|
52
68
|
);
|
|
53
|
-
|
|
54
|
-
updateBlockAttributes( blockClientId, {
|
|
55
|
-
...variations.find( ( { name } ) => name === variationName )
|
|
56
|
-
.attributes,
|
|
57
|
-
} );
|
|
58
|
-
};
|
|
59
|
-
const baseClass = 'block-editor-block-variation-transforms';
|
|
69
|
+
|
|
60
70
|
return (
|
|
61
71
|
<DropdownMenu
|
|
62
|
-
className={
|
|
72
|
+
className={ className }
|
|
63
73
|
label={ __( 'Transform to variation' ) }
|
|
64
74
|
text={ __( 'Transform to variation' ) }
|
|
65
75
|
popoverProps={ {
|
|
66
76
|
position: 'bottom center',
|
|
67
|
-
className: `${
|
|
77
|
+
className: `${ className }__popover`,
|
|
68
78
|
} }
|
|
69
79
|
icon={ chevronDown }
|
|
70
80
|
toggleProps={ { iconPosition: 'right' } }
|
|
71
81
|
>
|
|
72
82
|
{ () => (
|
|
73
|
-
<div className={ `${
|
|
83
|
+
<div className={ `${ className }__container` }>
|
|
74
84
|
<MenuGroup>
|
|
75
85
|
<MenuItemsChoice
|
|
76
86
|
choices={ selectOptions }
|
|
@@ -84,4 +94,63 @@ function __experimentalBlockVariationTransforms( { blockClientId } ) {
|
|
|
84
94
|
);
|
|
85
95
|
}
|
|
86
96
|
|
|
97
|
+
function __experimentalBlockVariationTransforms( { blockClientId } ) {
|
|
98
|
+
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
99
|
+
const { activeBlockVariation, variations } = useSelect(
|
|
100
|
+
( select ) => {
|
|
101
|
+
const { getActiveBlockVariation, getBlockVariations } = select(
|
|
102
|
+
blocksStore
|
|
103
|
+
);
|
|
104
|
+
const { getBlockName, getBlockAttributes } = select(
|
|
105
|
+
blockEditorStore
|
|
106
|
+
);
|
|
107
|
+
const name = blockClientId && getBlockName( blockClientId );
|
|
108
|
+
return {
|
|
109
|
+
activeBlockVariation: getActiveBlockVariation(
|
|
110
|
+
name,
|
|
111
|
+
getBlockAttributes( blockClientId )
|
|
112
|
+
),
|
|
113
|
+
variations: name && getBlockVariations( name, 'transform' ),
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
[ blockClientId ]
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
const selectedValue = activeBlockVariation?.name;
|
|
120
|
+
|
|
121
|
+
// Check if each variation has a unique icon.
|
|
122
|
+
const hasUniqueIcons = useMemo( () => {
|
|
123
|
+
const variationIcons = new Set();
|
|
124
|
+
variations.forEach( ( variation ) => {
|
|
125
|
+
if ( variation.icon ) {
|
|
126
|
+
variationIcons.add( variation.icon );
|
|
127
|
+
}
|
|
128
|
+
} );
|
|
129
|
+
return variationIcons.size === variations.length;
|
|
130
|
+
}, [ variations ] );
|
|
131
|
+
|
|
132
|
+
const onSelectVariation = ( variationName ) => {
|
|
133
|
+
updateBlockAttributes( blockClientId, {
|
|
134
|
+
...variations.find( ( { name } ) => name === variationName )
|
|
135
|
+
.attributes,
|
|
136
|
+
} );
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const baseClass = 'block-editor-block-variation-transforms';
|
|
140
|
+
|
|
141
|
+
// Skip rendering if there are no variations
|
|
142
|
+
if ( ! variations?.length ) return null;
|
|
143
|
+
|
|
144
|
+
const Component = hasUniqueIcons ? VariationsButtons : VariationsDropdown;
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<Component
|
|
148
|
+
className={ baseClass }
|
|
149
|
+
onSelectVariation={ onSelectVariation }
|
|
150
|
+
selectedValue={ selectedValue }
|
|
151
|
+
variations={ variations }
|
|
152
|
+
/>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
87
156
|
export default __experimentalBlockVariationTransforms;
|
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import BlockVerticalAlignmentUI from './ui';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const BlockVerticalAlignmentControl = ( props ) => {
|
|
7
7
|
return <BlockVerticalAlignmentUI { ...props } isToolbar={ false } />;
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const BlockVerticalAlignmentToolbar = ( props ) => {
|
|
11
11
|
return <BlockVerticalAlignmentUI { ...props } isToolbar />;
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-vertical-alignment-control/README.md
|
|
16
|
+
*/
|
|
17
|
+
export { BlockVerticalAlignmentControl, BlockVerticalAlignmentToolbar };
|
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
align-items: center;
|
|
5
5
|
justify-content: center;
|
|
6
|
-
padding: $grid-unit-10;
|
|
7
6
|
width: 100%;
|
|
8
7
|
height: auto;
|
|
9
8
|
color: $gray-900;
|
|
10
9
|
box-shadow: inset 0 0 0 $border-width $gray-900;
|
|
11
10
|
|
|
11
|
+
// Needs specificity to override button styles.
|
|
12
|
+
&.components-button.components-button {
|
|
13
|
+
padding: $grid-unit-15;
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
.is-dark-theme & {
|
|
13
17
|
color: $light-gray-placeholder;
|
|
14
18
|
box-shadow: inset 0 0 0 $border-width $light-gray-placeholder;
|
|
@@ -11,6 +11,7 @@ import { useDispatch } from '@wordpress/data';
|
|
|
11
11
|
*/
|
|
12
12
|
import { store as blockEditorStore } from '../../store';
|
|
13
13
|
import useConvertToGroupButtonProps from './use-convert-to-group-button-props';
|
|
14
|
+
import BlockGroupToolbar from './toolbar';
|
|
14
15
|
|
|
15
16
|
function ConvertToGroupButton( {
|
|
16
17
|
clientIds,
|
|
@@ -73,4 +74,8 @@ function ConvertToGroupButton( {
|
|
|
73
74
|
);
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
export {
|
|
77
|
+
export {
|
|
78
|
+
BlockGroupToolbar,
|
|
79
|
+
ConvertToGroupButton,
|
|
80
|
+
useConvertToGroupButtonProps,
|
|
81
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
5
|
+
import { switchToBlockType } from '@wordpress/blocks';
|
|
6
|
+
import { ToolbarButton, ToolbarGroup } from '@wordpress/components';
|
|
7
|
+
import { group, row, stack } from '@wordpress/icons';
|
|
8
|
+
import { _x } from '@wordpress/i18n';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { useConvertToGroupButtonProps } from '../convert-to-group-buttons';
|
|
14
|
+
import { store as blockEditorStore } from '../../store';
|
|
15
|
+
|
|
16
|
+
const layouts = {
|
|
17
|
+
group: undefined,
|
|
18
|
+
row: { type: 'flex', flexWrap: 'nowrap' },
|
|
19
|
+
stack: { type: 'flex', orientation: 'vertical' },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function BlockGroupToolbar() {
|
|
23
|
+
const {
|
|
24
|
+
blocksSelection,
|
|
25
|
+
clientIds,
|
|
26
|
+
groupingBlockName,
|
|
27
|
+
isGroupable,
|
|
28
|
+
} = useConvertToGroupButtonProps();
|
|
29
|
+
const { replaceBlocks } = useDispatch( blockEditorStore );
|
|
30
|
+
|
|
31
|
+
const { canRemove } = useSelect(
|
|
32
|
+
( select ) => {
|
|
33
|
+
const { canRemoveBlocks } = select( blockEditorStore );
|
|
34
|
+
return {
|
|
35
|
+
canRemove: canRemoveBlocks( clientIds ),
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
[ clientIds ]
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const onConvertToGroup = ( layout = 'group' ) => {
|
|
42
|
+
const newBlocks = switchToBlockType(
|
|
43
|
+
blocksSelection,
|
|
44
|
+
groupingBlockName
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
if ( newBlocks && newBlocks.length > 0 ) {
|
|
48
|
+
// Because the block is not in the store yet we can't use
|
|
49
|
+
// updateBlockAttributes so need to manually update attributes.
|
|
50
|
+
newBlocks[ 0 ].attributes.layout = layouts[ layout ];
|
|
51
|
+
replaceBlocks( clientIds, newBlocks );
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const onConvertToRow = () => onConvertToGroup( 'row' );
|
|
56
|
+
const onConvertToStack = () => onConvertToGroup( 'stack' );
|
|
57
|
+
|
|
58
|
+
// Don't render the button if the current selection cannot be grouped.
|
|
59
|
+
// A good example is selecting multiple button blocks within a Buttons block:
|
|
60
|
+
// The group block is not a valid child of Buttons, so we should not show the button.
|
|
61
|
+
// Any blocks that are locked against removal also cannot be grouped.
|
|
62
|
+
if ( ! isGroupable || ! canRemove ) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<ToolbarGroup>
|
|
68
|
+
<ToolbarButton
|
|
69
|
+
icon={ group }
|
|
70
|
+
label={ _x( 'Group', 'verb' ) }
|
|
71
|
+
onClick={ onConvertToGroup }
|
|
72
|
+
/>
|
|
73
|
+
<ToolbarButton
|
|
74
|
+
icon={ row }
|
|
75
|
+
label={ _x( 'Row', 'single horizontal line' ) }
|
|
76
|
+
onClick={ onConvertToRow }
|
|
77
|
+
/>
|
|
78
|
+
<ToolbarButton
|
|
79
|
+
icon={ stack }
|
|
80
|
+
label={ _x( 'Stack', 'verb' ) }
|
|
81
|
+
onClick={ onConvertToStack }
|
|
82
|
+
/>
|
|
83
|
+
</ToolbarGroup>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export default BlockGroupToolbar;
|
|
@@ -171,4 +171,7 @@ function CopyHandler( { children } ) {
|
|
|
171
171
|
return <div ref={ useClipboardHandler() }>{ children }</div>;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
+
/**
|
|
175
|
+
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/copy-handler/README.md
|
|
176
|
+
*/
|
|
174
177
|
export default CopyHandler;
|
|
@@ -203,14 +203,10 @@ function Iframe(
|
|
|
203
203
|
return true;
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
206
|
+
// Document set with srcDoc is not immediately ready.
|
|
207
|
+
node.addEventListener( 'load', setDocumentIfReady );
|
|
209
208
|
|
|
210
|
-
|
|
211
|
-
node.addEventListener( 'load', () => {
|
|
212
|
-
setDocumentIfReady();
|
|
213
|
-
} );
|
|
209
|
+
return () => node.removeEventListener( 'load', setDocumentIfReady );
|
|
214
210
|
}, [] );
|
|
215
211
|
const headRef = useRefEffect( ( element ) => {
|
|
216
212
|
scripts
|
|
@@ -264,6 +260,8 @@ function Iframe(
|
|
|
264
260
|
{ ...props }
|
|
265
261
|
ref={ useMergeRefs( [ ref, setRef ] ) }
|
|
266
262
|
tabIndex={ tabIndex }
|
|
263
|
+
// Correct doctype is required to enable rendering in standards mode
|
|
264
|
+
srcDoc="<!doctype html>"
|
|
267
265
|
title={ __( 'Editor canvas' ) }
|
|
268
266
|
>
|
|
269
267
|
{ iframeDocument &&
|
package/src/components/index.js
CHANGED
|
@@ -99,6 +99,8 @@ export { default as withColorContext } from './color-palette/with-color-context'
|
|
|
99
99
|
*/
|
|
100
100
|
|
|
101
101
|
export { default as __unstableBlockSettingsMenuFirstItem } from './block-settings-menu/block-settings-menu-first-item';
|
|
102
|
+
export { default as __unstableBlockToolbarLastItem } from './block-toolbar/block-toolbar-last-item';
|
|
103
|
+
export { default as __unstableBlockNameContext } from './block-toolbar/block-name-context';
|
|
102
104
|
export { default as __unstableInserterMenuExtension } from './inserter-menu-extension';
|
|
103
105
|
export { default as __experimentalPreviewOptions } from './preview-options';
|
|
104
106
|
export { default as __experimentalUseResizeCanvas } from './use-resize-canvas';
|
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import JustifyContentUI from './ui';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const JustifyContentControl = ( props ) => {
|
|
7
7
|
return <JustifyContentUI { ...props } isToolbar={ false } />;
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const JustifyToolbar = ( props ) => {
|
|
11
11
|
return <JustifyContentUI { ...props } isToolbar />;
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/justify-content-control/README.md
|
|
16
|
+
*/
|
|
17
|
+
export { JustifyContentControl, JustifyToolbar };
|
|
@@ -61,7 +61,7 @@ function KeyboardShortcutsRegister() {
|
|
|
61
61
|
registerShortcut( {
|
|
62
62
|
name: 'core/block-editor/delete-multi-selection',
|
|
63
63
|
category: 'block',
|
|
64
|
-
description: __( '
|
|
64
|
+
description: __( 'Delete selection.' ),
|
|
65
65
|
keyCombination: {
|
|
66
66
|
character: 'del',
|
|
67
67
|
},
|
|
@@ -15,13 +15,13 @@ import {
|
|
|
15
15
|
isLineHeightDefined,
|
|
16
16
|
} from './utils';
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
const LineHeightControl = ( {
|
|
19
19
|
value: lineHeight,
|
|
20
20
|
onChange,
|
|
21
21
|
/** Start opting into the new margin-free styles that will become the default in a future version. */
|
|
22
22
|
__nextHasNoMarginBottom = false,
|
|
23
23
|
__unstableInputWidth = '60px',
|
|
24
|
-
} ) {
|
|
24
|
+
} ) => {
|
|
25
25
|
const isDefined = isLineHeightDefined( lineHeight );
|
|
26
26
|
|
|
27
27
|
const adjustNextValue = ( nextValue, wasTypedOrPasted ) => {
|
|
@@ -101,4 +101,9 @@ export default function LineHeightControl( {
|
|
|
101
101
|
/>
|
|
102
102
|
</div>
|
|
103
103
|
);
|
|
104
|
-
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/line-height-control/README.md
|
|
108
|
+
*/
|
|
109
|
+
export default LineHeightControl;
|
|
@@ -8,6 +8,9 @@ import classnames from 'classnames';
|
|
|
8
8
|
*/
|
|
9
9
|
import { Button } from '@wordpress/components';
|
|
10
10
|
import { forwardRef } from '@wordpress/element';
|
|
11
|
+
import { useSelect } from '@wordpress/data';
|
|
12
|
+
import { Icon, lock } from '@wordpress/icons';
|
|
13
|
+
import { SPACE, ENTER } from '@wordpress/keycodes';
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* Internal dependencies
|
|
@@ -16,7 +19,7 @@ import BlockIcon from '../block-icon';
|
|
|
16
19
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
17
20
|
import BlockTitle from '../block-title';
|
|
18
21
|
import ListViewExpander from './expander';
|
|
19
|
-
import {
|
|
22
|
+
import { store as blockEditorStore } from '../../store';
|
|
20
23
|
|
|
21
24
|
function ListViewBlockSelectButton(
|
|
22
25
|
{
|
|
@@ -33,6 +36,14 @@ function ListViewBlockSelectButton(
|
|
|
33
36
|
ref
|
|
34
37
|
) {
|
|
35
38
|
const blockInformation = useBlockDisplayInformation( clientId );
|
|
39
|
+
const isLocked = useSelect(
|
|
40
|
+
( select ) => {
|
|
41
|
+
const { canMoveBlock, canRemoveBlock } = select( blockEditorStore );
|
|
42
|
+
|
|
43
|
+
return ! canMoveBlock( clientId ) || ! canRemoveBlock( clientId );
|
|
44
|
+
},
|
|
45
|
+
[ clientId ]
|
|
46
|
+
);
|
|
36
47
|
|
|
37
48
|
// The `href` attribute triggers the browser's native HTML drag operations.
|
|
38
49
|
// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.
|
|
@@ -40,7 +51,7 @@ function ListViewBlockSelectButton(
|
|
|
40
51
|
// inside the `useOnBlockDrop` hook.
|
|
41
52
|
const onDragStartHandler = ( event ) => {
|
|
42
53
|
event.dataTransfer.clearData();
|
|
43
|
-
onDragStart( event );
|
|
54
|
+
onDragStart?.( event );
|
|
44
55
|
};
|
|
45
56
|
|
|
46
57
|
function onKeyDownHandler( event ) {
|
|
@@ -69,12 +80,19 @@ function ListViewBlockSelectButton(
|
|
|
69
80
|
>
|
|
70
81
|
<ListViewExpander onClick={ onToggleExpanded } />
|
|
71
82
|
<BlockIcon icon={ blockInformation?.icon } showColors />
|
|
72
|
-
<
|
|
83
|
+
<span className="block-editor-list-view-block-select-button__title">
|
|
84
|
+
<BlockTitle clientId={ clientId } maximumLength={ 35 } />
|
|
85
|
+
</span>
|
|
73
86
|
{ blockInformation?.anchor && (
|
|
74
87
|
<span className="block-editor-list-view-block-select-button__anchor">
|
|
75
88
|
{ blockInformation.anchor }
|
|
76
89
|
</span>
|
|
77
90
|
) }
|
|
91
|
+
{ isLocked && (
|
|
92
|
+
<span className="block-editor-list-view-block-select-button__lock">
|
|
93
|
+
<Icon icon={ lock } />
|
|
94
|
+
</span>
|
|
95
|
+
) }
|
|
78
96
|
</Button>
|
|
79
97
|
</>
|
|
80
98
|
);
|
|
@@ -56,6 +56,11 @@ function ListViewBlock( {
|
|
|
56
56
|
const cellRef = useRef( null );
|
|
57
57
|
const [ isHovered, setIsHovered ] = useState( false );
|
|
58
58
|
const { clientId } = block;
|
|
59
|
+
const isFirstSelectedBlock =
|
|
60
|
+
isSelected && selectedClientIds[ 0 ] === clientId;
|
|
61
|
+
const isLastSelectedBlock =
|
|
62
|
+
isSelected &&
|
|
63
|
+
selectedClientIds[ selectedClientIds.length - 1 ] === clientId;
|
|
59
64
|
|
|
60
65
|
const { toggleBlockHighlight } = useDispatch( blockEditorStore );
|
|
61
66
|
|
|
@@ -102,7 +107,7 @@ function ListViewBlock( {
|
|
|
102
107
|
|
|
103
108
|
const listViewBlockSettingsClassName = classnames(
|
|
104
109
|
'block-editor-list-view-block__menu-cell',
|
|
105
|
-
{ 'is-visible': isHovered ||
|
|
110
|
+
{ 'is-visible': isHovered || isFirstSelectedBlock }
|
|
106
111
|
);
|
|
107
112
|
|
|
108
113
|
// If ListView has experimental features related to the Persistent List View,
|
|
@@ -177,6 +182,8 @@ function ListViewBlock( {
|
|
|
177
182
|
|
|
178
183
|
const classes = classnames( {
|
|
179
184
|
'is-selected': isSelected,
|
|
185
|
+
'is-first-selected': isFirstSelectedBlock,
|
|
186
|
+
'is-last-selected': isLastSelectedBlock,
|
|
180
187
|
'is-branch-selected':
|
|
181
188
|
withExperimentalPersistentListViewFeatures && isBranchSelected,
|
|
182
189
|
'is-dragging': isDragged,
|