@wordpress/block-editor 9.3.0 → 9.6.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 +6 -0
- package/README.md +1 -8
- package/build/components/block-list/block-invalid-warning.native.js +54 -6
- package/build/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build/components/block-list/block.js +2 -2
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +2 -1
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.native.js +4 -3
- package/build/components/block-list/index.native.js.map +1 -1
- package/build/components/block-list/layout.js +20 -5
- package/build/components/block-list/layout.js.map +1 -1
- package/build/components/block-list/use-block-props/use-block-class-names.js +5 -2
- package/build/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build/components/block-lock/modal.js +37 -7
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mover/mover-description.js +95 -32
- package/build/components/block-mover/mover-description.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +8 -26
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/setup-toolbar.js +3 -8
- package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build/components/block-popover/inbetween.js +1 -1
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +1 -1
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/auto.js +21 -5
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings-menu/block-edit-visually-button.js +70 -0
- package/build/components/block-settings-menu/block-edit-visually-button.js.map +1 -0
- package/build/components/block-settings-menu/block-mode-toggle.js +1 -1
- package/build/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +5 -2
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu/index.js +6 -2
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +5 -2
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/preview.native.js.map +1 -1
- package/build/components/block-switcher/index.js +7 -1
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-title/index.js +8 -2
- package/build/components/block-title/index.js.map +1 -1
- package/build/components/block-title/use-block-display-title.js +15 -15
- package/build/components/block-title/use-block-display-title.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +1 -7
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +4 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-types-list/index.native.js +65 -23
- package/build/components/block-types-list/index.native.js.map +1 -1
- package/build/components/border-radius-control/index.js +2 -0
- package/build/components/border-radius-control/index.js.map +1 -1
- package/build/components/colors/with-colors.js +1 -1
- package/build/components/colors/with-colors.js.map +1 -1
- package/build/components/colors-gradients/control.js +46 -39
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +7 -3
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/date-format-picker/index.js +1 -1
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/duotone/components.js +145 -0
- package/build/components/duotone/components.js.map +1 -0
- package/build/components/duotone/index.js +40 -0
- package/build/components/duotone/index.js.map +1 -0
- package/build/components/duotone/utils.js +38 -0
- package/build/components/duotone/utils.js.map +1 -0
- package/build/components/duotone-control/index.js +17 -5
- package/build/components/duotone-control/index.js.map +1 -1
- package/build/components/iframe/index.js +19 -6
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/cropper.js +4 -3
- package/build/components/image-editor/cropper.js.map +1 -1
- package/build/components/image-editor/index.js +3 -1
- package/build/components/image-editor/index.js.map +1 -1
- package/build/components/index.js +14 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inserter/block-types-tab.native.js +30 -16
- package/build/components/inserter/block-types-tab.native.js.map +1 -1
- package/build/components/inserter/index.js +3 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/preview-panel.js +8 -8
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter/reusable-blocks-tab.native.js +5 -1
- package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build/components/inserter/search-results.native.js +5 -2
- package/build/components/inserter/search-results.native.js.map +1 -1
- package/build/components/inserter/utils.native.js +21 -0
- package/build/components/inserter/utils.native.js.map +1 -1
- package/build/components/inserter-list-item/index.js +5 -1
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/link-control/index.js +1 -1
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +15 -7
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/branch.js +1 -7
- package/build/components/list-view/branch.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +1 -1
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/media-placeholder/index.js +14 -2
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-placeholder/index.native.js +4 -4
- package/build/components/media-placeholder/index.native.js.map +1 -1
- package/build/components/media-replace-flow/index.js +6 -13
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/observe-typing/index.js +22 -8
- package/build/components/observe-typing/index.js.map +1 -1
- package/build/components/publish-date-time-picker/index.js +3 -0
- package/build/components/publish-date-time-picker/index.js.map +1 -1
- package/build/components/rich-text/format-toolbar-container.js +61 -12
- package/build/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build/components/rich-text/index.js +2 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-format-types.js +36 -16
- package/build/components/rich-text/use-format-types.js.map +1 -1
- package/build/components/rich-text/use-input-rules.js +4 -13
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +20 -5
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/url-popover/index.js +2 -1
- package/build/components/url-popover/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +34 -2
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +3 -47
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/components/writing-flow/use-selection-observer.js +1 -3
- package/build/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +1 -1
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/elements/index.js +11 -3
- package/build/elements/index.js.map +1 -1
- package/build/hooks/aria-label.js +71 -0
- package/build/hooks/aria-label.js.map +1 -0
- package/build/hooks/color.js +2 -4
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/duotone.js +33 -160
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/index.js +11 -7
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout.js +59 -18
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/style.js +41 -31
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +5 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +7 -7
- package/build/index.js.map +1 -1
- package/build/layouts/flex.js +42 -38
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +35 -37
- package/build/layouts/flow.js.map +1 -1
- package/build/layouts/utils.js +35 -3
- package/build/layouts/utils.js.map +1 -1
- package/build/store/actions.js +24 -31
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +0 -4
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +23 -12
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +3 -3
- package/build/store/selectors.js.map +1 -1
- package/build/utils/selection.js +34 -0
- package/build/utils/selection.js.map +1 -0
- package/build-module/components/block-list/block-invalid-warning.native.js +50 -6
- package/build-module/components/block-list/block-invalid-warning.native.js.map +1 -1
- package/build-module/components/block-list/block.js +2 -2
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -1
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.native.js +3 -1
- package/build-module/components/block-list/index.native.js.map +1 -1
- package/build-module/components/block-list/layout.js +19 -4
- package/build-module/components/block-list/layout.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-block-class-names.js +5 -2
- package/build-module/components/block-list/use-block-props/use-block-class-names.js.map +1 -1
- package/build-module/components/block-lock/modal.js +39 -8
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +2 -2
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mover/mover-description.js +97 -33
- package/build-module/components/block-mover/mover-description.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +9 -27
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/setup-toolbar.js +3 -8
- package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +1 -1
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +1 -1
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +20 -5
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings-menu/block-edit-visually-button.js +56 -0
- package/build-module/components/block-settings-menu/block-edit-visually-button.js.map +1 -0
- package/build-module/components/block-settings-menu/block-mode-toggle.js +1 -1
- package/build-module/components/block-settings-menu/block-mode-toggle.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +6 -5
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +6 -3
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +7 -4
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/preview.native.js.map +1 -1
- package/build-module/components/block-switcher/index.js +7 -1
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-title/index.js +8 -2
- package/build-module/components/block-title/index.js.map +1 -1
- package/build-module/components/block-title/use-block-display-title.js +15 -14
- package/build-module/components/block-title/use-block-display-title.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +1 -7
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +4 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-types-list/index.native.js +67 -25
- package/build-module/components/block-types-list/index.native.js.map +1 -1
- package/build-module/components/border-radius-control/index.js +2 -0
- package/build-module/components/border-radius-control/index.js.map +1 -1
- package/build-module/components/colors/with-colors.js +2 -2
- package/build-module/components/colors/with-colors.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +47 -40
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +8 -4
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +1 -1
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/duotone/components.js +130 -0
- package/build-module/components/duotone/components.js.map +1 -0
- package/build-module/components/duotone/index.js +3 -0
- package/build-module/components/duotone/index.js.map +1 -0
- package/build-module/components/duotone/utils.js +30 -0
- package/build-module/components/duotone/utils.js.map +1 -0
- package/build-module/components/duotone-control/index.js +18 -6
- package/build-module/components/duotone-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +19 -6
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/cropper.js +4 -3
- package/build-module/components/image-editor/cropper.js.map +1 -1
- package/build-module/components/image-editor/index.js +3 -1
- package/build-module/components/image-editor/index.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.native.js +31 -15
- package/build-module/components/inserter/block-types-tab.native.js.map +1 -1
- package/build-module/components/inserter/index.js +3 -2
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +9 -9
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter/reusable-blocks-tab.native.js +6 -2
- package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
- package/build-module/components/inserter/search-results.native.js +6 -3
- package/build-module/components/inserter/search-results.native.js.map +1 -1
- package/build-module/components/inserter/utils.native.js +19 -0
- package/build-module/components/inserter/utils.native.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +4 -1
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/link-control/index.js +1 -1
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +16 -8
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/branch.js +1 -6
- package/build-module/components/list-view/branch.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +1 -1
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +14 -2
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-placeholder/index.native.js +5 -3
- package/build-module/components/media-placeholder/index.native.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +7 -13
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/observe-typing/index.js +22 -8
- package/build-module/components/observe-typing/index.js.map +1 -1
- package/build-module/components/publish-date-time-picker/index.js +2 -0
- package/build-module/components/publish-date-time-picker/index.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar-container.js +58 -12
- package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
- package/build-module/components/rich-text/index.js +2 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-format-types.js +37 -18
- package/build-module/components/rich-text/use-format-types.js.map +1 -1
- package/build-module/components/rich-text/use-input-rules.js +3 -11
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +20 -5
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/url-popover/index.js +2 -1
- package/build-module/components/url-popover/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +35 -3
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +3 -45
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/components/writing-flow/use-selection-observer.js +1 -3
- package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/elements/index.js +7 -1
- package/build-module/elements/index.js.map +1 -1
- package/build-module/hooks/aria-label.js +59 -0
- package/build-module/hooks/aria-label.js.map +1 -0
- package/build-module/hooks/color.js +2 -3
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/duotone.js +22 -140
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/index.js +2 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout.js +60 -19
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/style.js +44 -35
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +5 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/flex.js +43 -35
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +35 -38
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/layouts/utils.js +33 -3
- package/build-module/layouts/utils.js.map +1 -1
- package/build-module/store/actions.js +14 -20
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +0 -4
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +23 -11
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +4 -4
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/selection.js +24 -0
- package/build-module/utils/selection.js.map +1 -0
- package/build-style/style-rtl.css +43 -13
- package/build-style/style.css +43 -13
- package/package.json +28 -28
- package/src/components/block-draggable/test/helpers.native.js +3 -3
- package/src/components/block-list/block-invalid-warning.native.js +42 -7
- package/src/components/block-list/block.js +2 -2
- package/src/components/block-list/block.native.js +1 -0
- package/src/components/block-list/index.native.js +1 -1
- package/src/components/block-list/layout.js +15 -3
- package/src/components/block-list/style.scss +2 -2
- package/src/components/block-list/use-block-props/use-block-class-names.js +5 -1
- package/src/components/block-lock/modal.js +47 -9
- package/src/components/block-lock/style.scss +10 -0
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +3 -3
- package/src/components/block-mover/mover-description.js +131 -48
- package/src/components/block-mover/test/mover-description.js +55 -3
- package/src/components/block-pattern-setup/index.js +5 -25
- package/src/components/block-pattern-setup/setup-toolbar.js +2 -9
- package/src/components/block-pattern-setup/style.scss +4 -2
- package/src/components/block-popover/inbetween.js +1 -1
- package/src/components/block-popover/index.js +1 -1
- package/src/components/block-preview/auto.js +17 -3
- package/src/components/block-settings-menu/block-edit-visually-button.js +52 -0
- package/src/components/block-settings-menu/block-mode-toggle.js +1 -0
- package/src/components/block-settings-menu/block-settings-dropdown.js +7 -3
- package/src/components/block-settings-menu/index.js +15 -11
- package/src/components/block-settings-menu-controls/index.js +5 -4
- package/src/components/block-styles/preview.native.js +1 -0
- package/src/components/block-switcher/index.js +7 -1
- package/src/components/block-title/index.js +3 -2
- package/src/components/block-title/use-block-display-title.js +20 -12
- package/src/components/block-tools/block-contextual-toolbar.js +3 -1
- package/src/components/block-tools/block-selection-button.js +0 -5
- package/src/components/block-tools/index.js +4 -1
- package/src/components/block-types-list/index.native.js +76 -24
- package/src/components/block-types-list/style.native.scss +18 -0
- package/src/components/border-radius-control/index.js +2 -0
- package/src/components/color-palette/test/__snapshots__/control.js.snap +0 -4
- package/src/components/colors/test/__snapshots__/with-colors.js.snap +1 -1
- package/src/components/colors/test/with-colors.js +1 -1
- package/src/components/colors/with-colors.js +2 -2
- package/src/components/colors-gradients/control.js +78 -65
- package/src/components/colors-gradients/dropdown.js +9 -2
- package/src/components/colors-gradients/style.scss +11 -8
- package/src/components/colors-gradients/test/control.js +16 -23
- package/src/components/date-format-picker/index.js +1 -0
- package/src/components/duotone/components.js +133 -0
- package/src/components/duotone/index.js +7 -0
- package/src/components/duotone/utils.js +25 -0
- package/src/components/duotone-control/index.js +12 -7
- package/src/components/duotone-control/style.scss +5 -0
- package/src/components/iframe/index.js +25 -6
- package/src/components/image-editor/cropper.js +9 -3
- package/src/components/image-editor/index.js +2 -0
- package/src/components/index.js +1 -0
- package/src/components/inserter/block-types-tab.native.js +42 -21
- package/src/components/inserter/index.js +3 -5
- package/src/components/inserter/preview-panel.js +6 -14
- package/src/components/inserter/reusable-blocks-tab.native.js +4 -2
- package/src/components/inserter/search-results.native.js +4 -2
- package/src/components/inserter/style.scss +1 -1
- package/src/components/inserter/test/block-types-tab.native.js +2 -0
- package/src/components/inserter/test/utils.native.js +37 -0
- package/src/components/inserter/utils.native.js +11 -0
- package/src/components/inserter-list-item/index.js +4 -1
- package/src/components/link-control/index.js +1 -0
- package/src/components/link-control/test/fixtures/index.js +3 -4
- package/src/components/link-control/test/index.js +64 -73
- package/src/components/list-view/block-select-button.js +29 -14
- package/src/components/list-view/branch.js +1 -6
- package/src/components/list-view/drop-indicator.js +1 -1
- package/src/components/list-view/style.scss +18 -4
- package/src/components/media-placeholder/index.js +20 -0
- package/src/components/media-placeholder/index.native.js +9 -5
- package/src/components/media-replace-flow/index.js +5 -14
- package/src/components/media-replace-flow/test/index.js +14 -4
- package/src/components/media-upload/README.md +8 -0
- package/src/components/observe-typing/index.js +17 -14
- package/src/components/publish-date-time-picker/index.js +2 -0
- package/src/components/responsive-block-control/README.md +3 -1
- package/src/components/responsive-block-control/test/index.js +1 -2
- package/src/components/rich-text/format-toolbar-container.js +63 -14
- package/src/components/rich-text/index.js +1 -0
- package/src/components/rich-text/use-format-types.js +38 -17
- package/src/components/rich-text/use-input-rules.js +6 -15
- package/src/components/rich-text/use-paste-handler.js +17 -5
- package/src/components/url-popover/index.js +1 -0
- package/src/components/url-popover/test/__snapshots__/index.js.snap +3 -0
- package/src/components/writing-flow/use-arrow-nav.js +32 -1
- package/src/components/writing-flow/use-multi-selection.js +1 -48
- package/src/components/writing-flow/use-selection-observer.js +2 -3
- package/src/components/writing-flow/use-tab-nav.js +1 -1
- package/src/elements/index.js +8 -1
- package/src/elements/test/index.js +18 -0
- package/src/hooks/aria-label.js +67 -0
- package/src/hooks/color.js +10 -3
- package/src/hooks/duotone.js +18 -139
- package/src/hooks/index.js +2 -1
- package/src/hooks/layout.js +77 -29
- package/src/hooks/style.js +46 -39
- package/src/hooks/utils.js +7 -3
- package/src/index.js +1 -1
- package/src/layouts/flex.js +49 -43
- package/src/layouts/flow.js +35 -34
- package/src/layouts/test/flex.js +21 -0
- package/src/layouts/test/flow.js +21 -0
- package/src/layouts/test/utils.js +138 -0
- package/src/layouts/utils.js +44 -3
- package/src/store/actions.js +17 -31
- package/src/store/index.js +0 -4
- package/src/store/reducer.js +24 -11
- package/src/store/selectors.js +3 -4
- package/src/store/test/reducer.js +138 -10
- package/src/store/test/selectors.js +3 -6
- package/src/utils/selection.js +26 -0
- package/src/utils/test/selection.js +39 -0
- package/tsconfig.json +2 -1
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { findKey } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -17,21 +12,17 @@ import { useDispatch } from '@wordpress/data';
|
|
|
17
12
|
*/
|
|
18
13
|
import { store as blockEditorStore } from '../../store';
|
|
19
14
|
import { preventEventDiscovery } from './prevent-event-discovery';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const START_OF_SELECTED_AREA = '\u0086';
|
|
15
|
+
import {
|
|
16
|
+
retrieveSelectedAttribute,
|
|
17
|
+
START_OF_SELECTED_AREA,
|
|
18
|
+
} from '../../utils/selection';
|
|
25
19
|
|
|
26
20
|
function findSelection( blocks ) {
|
|
27
21
|
let i = blocks.length;
|
|
28
22
|
|
|
29
23
|
while ( i-- ) {
|
|
30
|
-
const attributeKey =
|
|
31
|
-
blocks[ i ].attributes
|
|
32
|
-
( v ) =>
|
|
33
|
-
typeof v === 'string' &&
|
|
34
|
-
v.indexOf( START_OF_SELECTED_AREA ) !== -1
|
|
24
|
+
const attributeKey = retrieveSelectedAttribute(
|
|
25
|
+
blocks[ i ].attributes
|
|
35
26
|
);
|
|
36
27
|
|
|
37
28
|
if ( attributeKey ) {
|
|
@@ -254,17 +254,29 @@ export function usePasteHandler( props ) {
|
|
|
254
254
|
}
|
|
255
255
|
|
|
256
256
|
/**
|
|
257
|
-
* Normalizes a given string of HTML to remove the Windows
|
|
258
|
-
* and any preceeding and trailing
|
|
257
|
+
* Normalizes a given string of HTML to remove the Windows-specific "Fragment"
|
|
258
|
+
* comments and any preceeding and trailing content.
|
|
259
259
|
*
|
|
260
260
|
* @param {string} html the html to be normalized
|
|
261
261
|
* @return {string} the normalized html
|
|
262
262
|
*/
|
|
263
263
|
function removeWindowsFragments( html ) {
|
|
264
|
-
const
|
|
265
|
-
const
|
|
264
|
+
const startStr = '<!--StartFragment-->';
|
|
265
|
+
const startIdx = html.indexOf( startStr );
|
|
266
|
+
if ( startIdx > -1 ) {
|
|
267
|
+
html = html.substring( startIdx + startStr.length );
|
|
268
|
+
} else {
|
|
269
|
+
// No point looking for EndFragment
|
|
270
|
+
return html;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const endStr = '<!--EndFragment-->';
|
|
274
|
+
const endIdx = html.indexOf( endStr );
|
|
275
|
+
if ( endIdx > -1 ) {
|
|
276
|
+
html = html.substring( 0, endIdx );
|
|
277
|
+
}
|
|
266
278
|
|
|
267
|
-
return html
|
|
279
|
+
return html;
|
|
268
280
|
}
|
|
269
281
|
|
|
270
282
|
/**
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`URLPopover matches the snapshot in its default state 1`] = `
|
|
4
4
|
<ForwardRef(Popover)
|
|
5
|
+
__unstableShift={true}
|
|
5
6
|
className="block-editor-url-popover"
|
|
6
7
|
focusOnMount="firstElement"
|
|
7
8
|
position="bottom center"
|
|
@@ -38,6 +39,7 @@ exports[`URLPopover matches the snapshot in its default state 1`] = `
|
|
|
38
39
|
|
|
39
40
|
exports[`URLPopover matches the snapshot when the settings are toggled open 1`] = `
|
|
40
41
|
<ForwardRef(Popover)
|
|
42
|
+
__unstableShift={true}
|
|
41
43
|
className="block-editor-url-popover"
|
|
42
44
|
focusOnMount="firstElement"
|
|
43
45
|
position="bottom center"
|
|
@@ -81,6 +83,7 @@ exports[`URLPopover matches the snapshot when the settings are toggled open 1`]
|
|
|
81
83
|
|
|
82
84
|
exports[`URLPopover matches the snapshot when there are no settings 1`] = `
|
|
83
85
|
<ForwardRef(Popover)
|
|
86
|
+
__unstableShift={true}
|
|
84
87
|
className="block-editor-url-popover"
|
|
85
88
|
focusOnMount="firstElement"
|
|
86
89
|
position="bottom center"
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
isRTL,
|
|
12
12
|
} from '@wordpress/dom';
|
|
13
13
|
import { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';
|
|
14
|
-
import { useSelect } from '@wordpress/data';
|
|
14
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
15
15
|
import { useRefEffect } from '@wordpress/compose';
|
|
16
16
|
|
|
17
17
|
/**
|
|
@@ -131,12 +131,15 @@ export function getClosestTabbable(
|
|
|
131
131
|
export default function useArrowNav() {
|
|
132
132
|
const {
|
|
133
133
|
getSelectedBlockClientId,
|
|
134
|
+
getMultiSelectedBlocksStartClientId,
|
|
134
135
|
getMultiSelectedBlocksEndClientId,
|
|
135
136
|
getPreviousBlockClientId,
|
|
136
137
|
getNextBlockClientId,
|
|
137
138
|
getSettings,
|
|
138
139
|
hasMultiSelection,
|
|
140
|
+
__unstableIsFullySelected,
|
|
139
141
|
} = useSelect( blockEditorStore );
|
|
142
|
+
const { selectBlock } = useDispatch( blockEditorStore );
|
|
140
143
|
return useRefEffect( ( node ) => {
|
|
141
144
|
// Here a DOMRect is stored while moving the caret vertically so
|
|
142
145
|
// vertical position of the start position can be restored. This is to
|
|
@@ -186,7 +189,35 @@ export default function useArrowNav() {
|
|
|
186
189
|
const { ownerDocument } = node;
|
|
187
190
|
const { defaultView } = ownerDocument;
|
|
188
191
|
|
|
192
|
+
// If there is a multi-selection, the arrow keys should collapse the
|
|
193
|
+
// selection to the start or end of the selection.
|
|
189
194
|
if ( hasMultiSelection() ) {
|
|
195
|
+
// Only handle if we have a full selection (not a native partial
|
|
196
|
+
// selection).
|
|
197
|
+
if ( ! __unstableIsFullySelected() ) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if ( event.defaultPrevented ) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if ( ! isNav ) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if ( isShift ) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
event.preventDefault();
|
|
214
|
+
|
|
215
|
+
if ( isReverse ) {
|
|
216
|
+
selectBlock( getMultiSelectedBlocksStartClientId() );
|
|
217
|
+
} else {
|
|
218
|
+
selectBlock( getMultiSelectedBlocksEndClientId(), -1 );
|
|
219
|
+
}
|
|
220
|
+
|
|
190
221
|
return;
|
|
191
222
|
}
|
|
192
223
|
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { first, last } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -13,7 +8,6 @@ import { useSelect } from '@wordpress/data';
|
|
|
13
8
|
* Internal dependencies
|
|
14
9
|
*/
|
|
15
10
|
import { store as blockEditorStore } from '../../store';
|
|
16
|
-
import { __unstableUseBlockRef as useBlockRef } from '../block-list/use-block-props/use-block-refs';
|
|
17
11
|
|
|
18
12
|
function selector( select ) {
|
|
19
13
|
const {
|
|
@@ -44,10 +38,6 @@ export default function useMultiSelection() {
|
|
|
44
38
|
selectedBlockClientId,
|
|
45
39
|
isFullSelection,
|
|
46
40
|
} = useSelect( selector, [] );
|
|
47
|
-
const selectedRef = useBlockRef( selectedBlockClientId );
|
|
48
|
-
// These must be in the right DOM order.
|
|
49
|
-
const startRef = useBlockRef( first( multiSelectedBlockClientIds ) );
|
|
50
|
-
const endRef = useBlockRef( last( multiSelectedBlockClientIds ) );
|
|
51
41
|
|
|
52
42
|
/**
|
|
53
43
|
* When the component updates, and there is multi selection, we need to
|
|
@@ -66,26 +56,6 @@ export default function useMultiSelection() {
|
|
|
66
56
|
}
|
|
67
57
|
|
|
68
58
|
if ( ! hasMultiSelection || isMultiSelecting ) {
|
|
69
|
-
if ( ! selectedBlockClientId || isMultiSelecting ) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const selection = defaultView.getSelection();
|
|
74
|
-
|
|
75
|
-
if ( selection.rangeCount && ! selection.isCollapsed ) {
|
|
76
|
-
const blockNode = selectedRef.current;
|
|
77
|
-
const { startContainer, endContainer } =
|
|
78
|
-
selection.getRangeAt( 0 );
|
|
79
|
-
|
|
80
|
-
if (
|
|
81
|
-
!! blockNode &&
|
|
82
|
-
( ! blockNode.contains( startContainer ) ||
|
|
83
|
-
! blockNode.contains( endContainer ) )
|
|
84
|
-
) {
|
|
85
|
-
selection.removeAllRanges();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
59
|
return;
|
|
90
60
|
}
|
|
91
61
|
|
|
@@ -105,25 +75,8 @@ export default function useMultiSelection() {
|
|
|
105
75
|
// able to select across instances immediately.
|
|
106
76
|
node.contentEditable = true;
|
|
107
77
|
|
|
108
|
-
|
|
109
|
-
// BEFORE selection.
|
|
78
|
+
defaultView.getSelection().removeAllRanges();
|
|
110
79
|
node.focus();
|
|
111
|
-
|
|
112
|
-
// The block refs might not be immediately available
|
|
113
|
-
// when dragging blocks into another block.
|
|
114
|
-
if ( ! startRef.current || ! endRef.current ) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const selection = defaultView.getSelection();
|
|
119
|
-
const range = ownerDocument.createRange();
|
|
120
|
-
|
|
121
|
-
// These must be in the right DOM order.
|
|
122
|
-
range.setStartBefore( startRef.current );
|
|
123
|
-
range.setEndAfter( endRef.current );
|
|
124
|
-
|
|
125
|
-
selection.removeAllRanges();
|
|
126
|
-
selection.addRange( range );
|
|
127
80
|
},
|
|
128
81
|
[
|
|
129
82
|
hasMultiSelection,
|
|
@@ -84,12 +84,11 @@ export default function useSelectionObserver() {
|
|
|
84
84
|
|
|
85
85
|
function onSelectionChange( event ) {
|
|
86
86
|
const selection = defaultView.getSelection();
|
|
87
|
-
|
|
88
|
-
// contentEditable wrapper.
|
|
87
|
+
|
|
89
88
|
if ( ! selection.rangeCount ) {
|
|
90
|
-
setContentEditableWrapper( node, false );
|
|
91
89
|
return;
|
|
92
90
|
}
|
|
91
|
+
|
|
93
92
|
// If selection is collapsed and we haven't used `shift+click`,
|
|
94
93
|
// end multi selection and disable the contentEditable wrapper.
|
|
95
94
|
// We have to check about `shift+click` case because elements
|
package/src/elements/index.js
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
const ELEMENT_CLASS_NAMES = {
|
|
2
|
+
button: 'wp-element-button',
|
|
3
|
+
caption: 'wp-element-caption',
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export const __experimentalGetElementClassName = ( element ) => {
|
|
7
|
+
return ELEMENT_CLASS_NAMES[ element ] ? ELEMENT_CLASS_NAMES[ element ] : '';
|
|
8
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __experimentalGetElementClassName } from '@wordpress/block-editor';
|
|
5
|
+
|
|
6
|
+
describe( 'element class names', () => {
|
|
7
|
+
it( 'should return the correct class name for button', () => {
|
|
8
|
+
expect( __experimentalGetElementClassName( 'button' ) ).toEqual(
|
|
9
|
+
'wp-element-button'
|
|
10
|
+
);
|
|
11
|
+
} );
|
|
12
|
+
|
|
13
|
+
it( 'should return an empty string for an unknown element', () => {
|
|
14
|
+
expect(
|
|
15
|
+
__experimentalGetElementClassName( 'unknown-element' )
|
|
16
|
+
).toEqual( '' );
|
|
17
|
+
} );
|
|
18
|
+
} );
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { addFilter } from '@wordpress/hooks';
|
|
5
|
+
import { hasBlockSupport } from '@wordpress/blocks';
|
|
6
|
+
|
|
7
|
+
const ARIA_LABEL_SCHEMA = {
|
|
8
|
+
type: 'string',
|
|
9
|
+
source: 'attribute',
|
|
10
|
+
attribute: 'aria-label',
|
|
11
|
+
selector: '*',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Filters registered block settings, extending attributes with ariaLabel using aria-label
|
|
16
|
+
* of the first node.
|
|
17
|
+
*
|
|
18
|
+
* @param {Object} settings Original block settings.
|
|
19
|
+
*
|
|
20
|
+
* @return {Object} Filtered block settings.
|
|
21
|
+
*/
|
|
22
|
+
export function addAttribute( settings ) {
|
|
23
|
+
// Allow blocks to specify their own attribute definition with default values if needed.
|
|
24
|
+
if ( settings?.attributes?.ariaLabel?.type ) {
|
|
25
|
+
return settings;
|
|
26
|
+
}
|
|
27
|
+
if ( hasBlockSupport( settings, 'ariaLabel' ) ) {
|
|
28
|
+
// Gracefully handle if settings.attributes is undefined.
|
|
29
|
+
settings.attributes = {
|
|
30
|
+
...settings.attributes,
|
|
31
|
+
ariaLabel: ARIA_LABEL_SCHEMA,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return settings;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Override props assigned to save component to inject aria-label, if block
|
|
40
|
+
* supports ariaLabel. This is only applied if the block's save result is an
|
|
41
|
+
* element and not a markup string.
|
|
42
|
+
*
|
|
43
|
+
* @param {Object} extraProps Additional props applied to save element.
|
|
44
|
+
* @param {Object} blockType Block type.
|
|
45
|
+
* @param {Object} attributes Current block attributes.
|
|
46
|
+
*
|
|
47
|
+
* @return {Object} Filtered props applied to save element.
|
|
48
|
+
*/
|
|
49
|
+
export function addSaveProps( extraProps, blockType, attributes ) {
|
|
50
|
+
if ( hasBlockSupport( blockType, 'ariaLabel' ) ) {
|
|
51
|
+
extraProps[ 'aria-label' ] =
|
|
52
|
+
attributes.ariaLabel === '' ? null : attributes.ariaLabel;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return extraProps;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
addFilter(
|
|
59
|
+
'blocks.registerBlockType',
|
|
60
|
+
'core/ariaLabel/attribute',
|
|
61
|
+
addAttribute
|
|
62
|
+
);
|
|
63
|
+
addFilter(
|
|
64
|
+
'blocks.getSaveContent.extraProps',
|
|
65
|
+
'core/ariaLabel/save-props',
|
|
66
|
+
addSaveProps
|
|
67
|
+
);
|
package/src/hooks/color.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import { isObject } from 'lodash';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* WordPress dependencies
|
|
@@ -55,13 +54,21 @@ const hasLinkColorSupport = ( blockType ) => {
|
|
|
55
54
|
|
|
56
55
|
const colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );
|
|
57
56
|
|
|
58
|
-
return
|
|
57
|
+
return (
|
|
58
|
+
colorSupport !== null &&
|
|
59
|
+
typeof colorSupport === 'object' &&
|
|
60
|
+
!! colorSupport.link
|
|
61
|
+
);
|
|
59
62
|
};
|
|
60
63
|
|
|
61
64
|
const hasGradientSupport = ( blockType ) => {
|
|
62
65
|
const colorSupport = getBlockSupport( blockType, COLOR_SUPPORT_KEY );
|
|
63
66
|
|
|
64
|
-
return
|
|
67
|
+
return (
|
|
68
|
+
colorSupport !== null &&
|
|
69
|
+
typeof colorSupport === 'object' &&
|
|
70
|
+
!! colorSupport.gradients
|
|
71
|
+
);
|
|
65
72
|
};
|
|
66
73
|
|
|
67
74
|
const hasBackgroundColorSupport = ( blockType ) => {
|
package/src/hooks/duotone.js
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import {
|
|
5
|
+
import { extend } from 'colord';
|
|
6
6
|
import namesPlugin from 'colord/plugins/names';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* WordPress dependencies
|
|
10
10
|
*/
|
|
11
11
|
import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
|
|
12
|
-
import { SVG } from '@wordpress/components';
|
|
13
12
|
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
|
|
14
13
|
import { addFilter } from '@wordpress/hooks';
|
|
15
14
|
import { useMemo, useContext, createPortal } from '@wordpress/element';
|
|
@@ -23,145 +22,34 @@ import {
|
|
|
23
22
|
useSetting,
|
|
24
23
|
} from '../components';
|
|
25
24
|
import BlockList from '../components/block-list';
|
|
25
|
+
import {
|
|
26
|
+
__unstableDuotoneFilter as DuotoneFilter,
|
|
27
|
+
__unstableDuotoneStylesheet as DuotoneStylesheet,
|
|
28
|
+
__unstableDuotoneUnsetStylesheet as DuotoneUnsetStylesheet,
|
|
29
|
+
} from '../components/duotone';
|
|
26
30
|
|
|
27
31
|
const EMPTY_ARRAY = [];
|
|
28
32
|
|
|
29
33
|
extend( [ namesPlugin ] );
|
|
30
34
|
|
|
31
|
-
/**
|
|
32
|
-
* Convert a list of colors to an object of R, G, and B values.
|
|
33
|
-
*
|
|
34
|
-
* @param {string[]} colors Array of RBG color strings.
|
|
35
|
-
*
|
|
36
|
-
* @return {Object} R, G, and B values.
|
|
37
|
-
*/
|
|
38
|
-
export function getValuesFromColors( colors = [] ) {
|
|
39
|
-
const values = { r: [], g: [], b: [], a: [] };
|
|
40
|
-
|
|
41
|
-
colors.forEach( ( color ) => {
|
|
42
|
-
const rgbColor = colord( color ).toRgb();
|
|
43
|
-
values.r.push( rgbColor.r / 255 );
|
|
44
|
-
values.g.push( rgbColor.g / 255 );
|
|
45
|
-
values.b.push( rgbColor.b / 255 );
|
|
46
|
-
values.a.push( rgbColor.a );
|
|
47
|
-
} );
|
|
48
|
-
|
|
49
|
-
return values;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Values for the SVG `feComponentTransfer`.
|
|
54
|
-
*
|
|
55
|
-
* @typedef Values {Object}
|
|
56
|
-
* @property {number[]} r Red values.
|
|
57
|
-
* @property {number[]} g Green values.
|
|
58
|
-
* @property {number[]} b Blue values.
|
|
59
|
-
* @property {number[]} a Alpha values.
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Stylesheet for rendering the duotone filter.
|
|
64
|
-
*
|
|
65
|
-
* @param {Object} props Duotone props.
|
|
66
|
-
* @param {string} props.selector Selector to apply the filter to.
|
|
67
|
-
* @param {string} props.id Unique id for this duotone filter.
|
|
68
|
-
*
|
|
69
|
-
* @return {WPElement} Duotone element.
|
|
70
|
-
*/
|
|
71
|
-
function DuotoneStylesheet( { selector, id } ) {
|
|
72
|
-
const css = `
|
|
73
|
-
${ selector } {
|
|
74
|
-
filter: url( #${ id } );
|
|
75
|
-
}
|
|
76
|
-
`;
|
|
77
|
-
return <style>{ css }</style>;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* SVG for rendering the duotone filter.
|
|
82
|
-
*
|
|
83
|
-
* @param {Object} props Duotone props.
|
|
84
|
-
* @param {string} props.id Unique id for this duotone filter.
|
|
85
|
-
* @param {Values} props.values R, G, B, and A values to filter with.
|
|
86
|
-
*
|
|
87
|
-
* @return {WPElement} Duotone element.
|
|
88
|
-
*/
|
|
89
|
-
function DuotoneFilter( { id, values } ) {
|
|
90
|
-
return (
|
|
91
|
-
<SVG
|
|
92
|
-
xmlnsXlink="http://www.w3.org/1999/xlink"
|
|
93
|
-
viewBox="0 0 0 0"
|
|
94
|
-
width="0"
|
|
95
|
-
height="0"
|
|
96
|
-
focusable="false"
|
|
97
|
-
role="none"
|
|
98
|
-
style={ {
|
|
99
|
-
visibility: 'hidden',
|
|
100
|
-
position: 'absolute',
|
|
101
|
-
left: '-9999px',
|
|
102
|
-
overflow: 'hidden',
|
|
103
|
-
} }
|
|
104
|
-
>
|
|
105
|
-
<defs>
|
|
106
|
-
<filter id={ id }>
|
|
107
|
-
<feColorMatrix
|
|
108
|
-
// Use sRGB instead of linearRGB so transparency looks correct.
|
|
109
|
-
colorInterpolationFilters="sRGB"
|
|
110
|
-
type="matrix"
|
|
111
|
-
// Use perceptual brightness to convert to grayscale.
|
|
112
|
-
values="
|
|
113
|
-
.299 .587 .114 0 0
|
|
114
|
-
.299 .587 .114 0 0
|
|
115
|
-
.299 .587 .114 0 0
|
|
116
|
-
.299 .587 .114 0 0
|
|
117
|
-
"
|
|
118
|
-
/>
|
|
119
|
-
<feComponentTransfer
|
|
120
|
-
// Use sRGB instead of linearRGB to be consistent with how CSS gradients work.
|
|
121
|
-
colorInterpolationFilters="sRGB"
|
|
122
|
-
>
|
|
123
|
-
<feFuncR
|
|
124
|
-
type="table"
|
|
125
|
-
tableValues={ values.r.join( ' ' ) }
|
|
126
|
-
/>
|
|
127
|
-
<feFuncG
|
|
128
|
-
type="table"
|
|
129
|
-
tableValues={ values.g.join( ' ' ) }
|
|
130
|
-
/>
|
|
131
|
-
<feFuncB
|
|
132
|
-
type="table"
|
|
133
|
-
tableValues={ values.b.join( ' ' ) }
|
|
134
|
-
/>
|
|
135
|
-
<feFuncA
|
|
136
|
-
type="table"
|
|
137
|
-
tableValues={ values.a.join( ' ' ) }
|
|
138
|
-
/>
|
|
139
|
-
</feComponentTransfer>
|
|
140
|
-
<feComposite
|
|
141
|
-
// Re-mask the image with the original transparency since the feColorMatrix above loses that information.
|
|
142
|
-
in2="SourceGraphic"
|
|
143
|
-
operator="in"
|
|
144
|
-
/>
|
|
145
|
-
</filter>
|
|
146
|
-
</defs>
|
|
147
|
-
</SVG>
|
|
148
|
-
);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
35
|
/**
|
|
152
36
|
* SVG and stylesheet needed for rendering the duotone filter.
|
|
153
37
|
*
|
|
154
|
-
* @param {Object} props
|
|
38
|
+
* @param {Object} props Duotone props.
|
|
155
39
|
* @param {string} props.selector Selector to apply the filter to.
|
|
156
|
-
* @param {string} props.id
|
|
157
|
-
* @param {
|
|
40
|
+
* @param {string} props.id Unique id for this duotone filter.
|
|
41
|
+
* @param {string[]|"unset"} props.colors Array of RGB color strings ordered from dark to light.
|
|
158
42
|
*
|
|
159
43
|
* @return {WPElement} Duotone element.
|
|
160
44
|
*/
|
|
161
|
-
function InlineDuotone( { selector, id,
|
|
45
|
+
function InlineDuotone( { selector, id, colors } ) {
|
|
46
|
+
if ( colors === 'unset' ) {
|
|
47
|
+
return <DuotoneUnsetStylesheet selector={ selector } />;
|
|
48
|
+
}
|
|
49
|
+
|
|
162
50
|
return (
|
|
163
51
|
<>
|
|
164
|
-
<DuotoneFilter id={ id }
|
|
52
|
+
<DuotoneFilter id={ id } colors={ colors } />
|
|
165
53
|
<DuotoneStylesheet id={ id } selector={ selector } />
|
|
166
54
|
</>
|
|
167
55
|
);
|
|
@@ -324,9 +212,9 @@ const withDuotoneStyles = createHigherOrderComponent(
|
|
|
324
212
|
props.name,
|
|
325
213
|
'color.__experimentalDuotone'
|
|
326
214
|
);
|
|
327
|
-
const
|
|
215
|
+
const colors = props?.attributes?.style?.color?.duotone;
|
|
328
216
|
|
|
329
|
-
if ( ! duotoneSupport || !
|
|
217
|
+
if ( ! duotoneSupport || ! colors ) {
|
|
330
218
|
return <BlockListBlock { ...props } />;
|
|
331
219
|
}
|
|
332
220
|
|
|
@@ -351,7 +239,7 @@ const withDuotoneStyles = createHigherOrderComponent(
|
|
|
351
239
|
<InlineDuotone
|
|
352
240
|
selector={ selectorsGroup }
|
|
353
241
|
id={ id }
|
|
354
|
-
|
|
242
|
+
colors={ colors }
|
|
355
243
|
/>,
|
|
356
244
|
element
|
|
357
245
|
) }
|
|
@@ -362,15 +250,6 @@ const withDuotoneStyles = createHigherOrderComponent(
|
|
|
362
250
|
'withDuotoneStyles'
|
|
363
251
|
);
|
|
364
252
|
|
|
365
|
-
export function PresetDuotoneFilter( { preset } ) {
|
|
366
|
-
return (
|
|
367
|
-
<DuotoneFilter
|
|
368
|
-
id={ `wp-duotone-${ preset.slug }` }
|
|
369
|
-
values={ getValuesFromColors( preset.colors ) }
|
|
370
|
-
/>
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
253
|
addFilter(
|
|
375
254
|
'blocks.registerBlockType',
|
|
376
255
|
'core/editor/duotone/add-attributes',
|
package/src/hooks/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import './compat';
|
|
|
5
5
|
import './align';
|
|
6
6
|
import './lock';
|
|
7
7
|
import './anchor';
|
|
8
|
+
import './aria-label';
|
|
8
9
|
import './custom-class-name';
|
|
9
10
|
import './generated-class-name';
|
|
10
11
|
import './style';
|
|
@@ -19,5 +20,5 @@ export { useCustomSides } from './dimensions';
|
|
|
19
20
|
export { getBorderClassesAndStyles, useBorderProps } from './use-border-props';
|
|
20
21
|
export { getColorClassesAndStyles, useColorProps } from './use-color-props';
|
|
21
22
|
export { getSpacingClassesAndStyles } from './use-spacing-props';
|
|
23
|
+
export { getGapCSSValue } from './gap';
|
|
22
24
|
export { useCachedTruthy } from './use-cached-truthy';
|
|
23
|
-
export { PresetDuotoneFilter } from './duotone';
|