@wordpress/block-editor 12.13.0 → 12.14.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/build/components/block-heading-level-dropdown/index.js +1 -1
- package/build/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build/components/block-list/index.js +2 -9
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list-appender/index.js +16 -3
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +6 -4
- package/build/components/block-quick-navigation/index.js.map +1 -1
- package/build/components/block-styles/index.js +0 -8
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/pattern-transformations-menu.js +18 -14
- package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -2
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/block-contextual-toolbar.js +11 -81
- package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build/components/block-tools/empty-block-inserter.js +56 -0
- package/build/components/block-tools/empty-block-inserter.js.map +1 -0
- package/build/components/block-tools/index.js +48 -9
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/selected-block-tools.js +113 -0
- package/build/components/block-tools/selected-block-tools.js.map +1 -0
- package/build/components/block-tools/use-selected-block-tool-props.js +56 -0
- package/build/components/block-tools/use-selected-block-tool-props.js.map +1 -0
- package/build/components/editable-text/index.js +1 -2
- package/build/components/editable-text/index.js.map +1 -1
- package/build/components/iframe/index.js +4 -3
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/{explorer.js → index.js} +7 -7
- package/build/components/inserter/block-patterns-explorer/index.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -4
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/index.js +75 -0
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +108 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
- package/build/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +18 -34
- package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +55 -0
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
- package/build/components/inserter/block-patterns-tab/utils.js +70 -0
- package/build/components/inserter/block-patterns-tab/utils.js.map +1 -0
- package/build/components/inserter/media-tab/media-list.js +9 -5
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +15 -12
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/menu.js +3 -4
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/link-control/index.js +6 -5
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +39 -0
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +16 -3
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/index.js +3 -2
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/navigable-toolbar/index.js +69 -18
- package/build/components/navigable-toolbar/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +1 -14
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/rich-text/index.js +0 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +3 -1
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/format-edit.js +45 -0
- package/build/components/rich-text/native/format-edit.js.map +1 -0
- package/build/components/rich-text/native/get-format-colors.native.js +41 -0
- package/build/components/rich-text/native/get-format-colors.native.js.map +1 -0
- package/build/components/rich-text/native/index.js +9 -0
- package/build/components/rich-text/native/index.js.map +1 -0
- package/build/components/rich-text/native/index.native.js +1158 -0
- package/build/components/rich-text/native/index.native.js.map +1 -0
- package/build/components/rich-text/native/toolbar-button-with-options.native.js +58 -0
- package/build/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
- package/build/components/rich-text/native/use-format-types.js +111 -0
- package/build/components/rich-text/native/use-format-types.js.map +1 -0
- package/build/components/rich-text/use-paste-handler.js +2 -5
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +2 -1
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +7 -3
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/hooks/align.js +10 -10
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/align.native.js +2 -2
- package/build/hooks/align.native.js.map +1 -1
- package/build/hooks/anchor.js +7 -6
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +16 -4
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/block-hooks.js +7 -8
- package/build/hooks/block-hooks.js.map +1 -1
- package/build/hooks/block-rename-ui.js +7 -5
- package/build/hooks/block-rename-ui.js.map +1 -1
- package/build/hooks/content-lock-ui.js +5 -5
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/custom-class-name.js +8 -7
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-fields.js +4 -4
- package/build/hooks/custom-fields.js.map +1 -1
- package/build/hooks/duotone.js +9 -20
- package/build/hooks/duotone.js.map +1 -1
- package/build/hooks/layout.js +90 -86
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +10 -9
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/style.js +10 -13
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/utils.js +30 -0
- package/build/hooks/utils.js.map +1 -1
- package/build/private-apis.js +3 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +30 -37
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +18 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +16 -13
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build-module/components/block-list/index.js +3 -10
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +16 -3
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +7 -5
- package/build-module/components/block-quick-navigation/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +0 -8
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/pattern-transformations-menu.js +17 -13
- package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +1 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/block-contextual-toolbar.js +11 -80
- package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
- package/build-module/components/block-tools/empty-block-inserter.js +48 -0
- package/build-module/components/block-tools/empty-block-inserter.js.map +1 -0
- package/build-module/components/block-tools/index.js +48 -9
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/selected-block-tools.js +105 -0
- package/build-module/components/block-tools/selected-block-tools.js.map +1 -0
- package/build-module/components/block-tools/use-selected-block-tool-props.js +50 -0
- package/build-module/components/block-tools/use-selected-block-tool-props.js.map +1 -0
- package/build-module/components/editable-text/index.js +1 -2
- package/build-module/components/editable-text/index.js.map +1 -1
- package/build-module/components/iframe/index.js +4 -3
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/{explorer.js → index.js} +5 -5
- package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/index.js +66 -0
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +42 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +100 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
- package/build-module/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +7 -20
- package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +47 -0
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
- package/build-module/components/inserter/block-patterns-tab/utils.js +58 -0
- package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -0
- package/build-module/components/inserter/media-tab/media-list.js +9 -5
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +15 -12
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/menu.js +4 -3
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/link-control/index.js +7 -6
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +39 -0
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +16 -3
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/index.js +3 -2
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/navigable-toolbar/index.js +69 -17
- package/build-module/components/navigable-toolbar/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +1 -14
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/rich-text/index.js +0 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +3 -1
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/format-edit.js +38 -0
- package/build-module/components/rich-text/native/format-edit.js.map +1 -0
- package/build-module/components/rich-text/native/get-format-colors.native.js +34 -0
- package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -0
- package/build-module/components/rich-text/native/index.js +2 -0
- package/build-module/components/rich-text/native/index.js.map +1 -0
- package/build-module/components/rich-text/native/index.native.js +1148 -0
- package/build-module/components/rich-text/native/index.native.js.map +1 -0
- package/build-module/components/rich-text/native/toolbar-button-with-options.native.js +51 -0
- package/build-module/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
- package/build-module/components/rich-text/native/use-format-types.js +104 -0
- package/build-module/components/rich-text/native/use-format-types.js.map +1 -0
- package/build-module/components/rich-text/use-paste-handler.js +2 -5
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +2 -1
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +7 -3
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/hooks/align.js +8 -8
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/align.native.js +2 -2
- package/build-module/hooks/align.native.js.map +1 -1
- package/build-module/hooks/anchor.js +5 -4
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +17 -5
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/block-hooks.js +5 -6
- package/build-module/hooks/block-hooks.js.map +1 -1
- package/build-module/hooks/block-rename-ui.js +5 -3
- package/build-module/hooks/block-rename-ui.js.map +1 -1
- package/build-module/hooks/content-lock-ui.js +3 -3
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +6 -5
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-fields.js +4 -4
- package/build-module/hooks/custom-fields.js.map +1 -1
- package/build-module/hooks/duotone.js +10 -21
- package/build-module/hooks/duotone.js.map +1 -1
- package/build-module/hooks/layout.js +90 -86
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +11 -10
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/style.js +10 -13
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/utils.js +30 -1
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/private-apis.js +4 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +29 -37
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +17 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +15 -13
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +16 -15
- package/build-style/style.css +16 -15
- package/package.json +31 -31
- package/src/components/block-heading-level-dropdown/index.js +1 -1
- package/src/components/block-list/index.js +4 -18
- package/src/components/block-list-appender/index.js +20 -4
- package/src/components/block-quick-navigation/index.js +11 -5
- package/src/components/block-styles/index.js +0 -10
- package/src/components/block-switcher/pattern-transformations-menu.js +20 -14
- package/src/components/block-toolbar/style.scss +8 -0
- package/src/components/block-tools/back-compat.js +1 -1
- package/src/components/block-tools/block-contextual-toolbar.js +11 -134
- package/src/components/block-tools/empty-block-inserter.js +56 -0
- package/src/components/block-tools/index.js +72 -16
- package/src/components/block-tools/selected-block-tools.js +127 -0
- package/src/components/block-tools/style.scss +0 -10
- package/src/components/block-tools/use-selected-block-tool-props.js +66 -0
- package/src/components/editable-text/index.js +1 -8
- package/src/components/iframe/index.js +4 -3
- package/src/components/inserter/block-patterns-explorer/{explorer.js → index.js} +4 -4
- package/src/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -1
- package/src/components/inserter/block-patterns-tab/index.js +118 -0
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +175 -0
- package/src/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +15 -21
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +96 -0
- package/src/components/inserter/block-patterns-tab/utils.js +76 -0
- package/src/components/inserter/media-tab/media-list.js +7 -7
- package/src/components/inserter/media-tab/media-preview.js +27 -22
- package/src/components/inserter/menu.js +4 -5
- package/src/components/link-control/README.md +2 -2
- package/src/components/link-control/index.js +15 -6
- package/src/components/link-control/style.scss +8 -5
- package/src/components/list-view/block-select-button.js +44 -1
- package/src/components/list-view/block.js +11 -11
- package/src/components/list-view/index.js +2 -0
- package/src/components/media-replace-flow/style.scss +2 -2
- package/src/components/navigable-toolbar/index.js +71 -25
- package/src/components/plain-text/README.md +3 -3
- package/src/components/provider/use-block-sync.js +2 -21
- package/src/components/rich-text/README.md +9 -8
- package/src/components/rich-text/index.js +0 -1
- package/src/components/rich-text/index.native.js +3 -1
- package/src/components/rich-text/native/format-edit.js +44 -0
- package/src/components/rich-text/native/get-format-colors.native.js +54 -0
- package/src/components/rich-text/native/index.js +1 -0
- package/src/components/rich-text/native/index.native.js +1363 -0
- package/src/components/rich-text/native/style.native.scss +28 -0
- package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +79 -0
- package/src/components/rich-text/native/test/index.native.js +278 -0
- package/src/components/rich-text/native/test/performance/rich-text.native.js +44 -0
- package/src/components/rich-text/native/toolbar-button-with-options.native.js +61 -0
- package/src/components/rich-text/native/use-format-types.js +146 -0
- package/src/components/rich-text/use-paste-handler.js +1 -6
- package/src/components/url-popover/image-url-input-ui.js +1 -0
- package/src/components/writing-flow/use-tab-nav.js +8 -3
- package/src/hooks/align.js +8 -8
- package/src/hooks/align.native.js +2 -2
- package/src/hooks/anchor.js +21 -23
- package/src/hooks/background.js +28 -6
- package/src/hooks/block-hooks.js +20 -16
- package/src/hooks/block-rename-ui.js +6 -4
- package/src/hooks/content-lock-ui.js +3 -3
- package/src/hooks/custom-class-name.js +7 -6
- package/src/hooks/custom-fields.js +5 -5
- package/src/hooks/duotone.js +23 -33
- package/src/hooks/layout.js +114 -105
- package/src/hooks/position.js +8 -21
- package/src/hooks/style.js +17 -31
- package/src/hooks/test/align.js +4 -4
- package/src/hooks/utils.js +33 -1
- package/src/private-apis.js +4 -1
- package/src/store/actions.js +26 -72
- package/src/store/reducer.js +19 -0
- package/src/store/selectors.js +13 -19
- package/build/components/block-tools/selected-block-popover.js +0 -221
- package/build/components/block-tools/selected-block-popover.js.map +0 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
- package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
- package/build/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
- package/build/components/inserter/block-patterns-filter.js.map +0 -1
- package/build/components/inserter/block-patterns-tab.js +0 -270
- package/build/components/inserter/block-patterns-tab.js.map +0 -1
- package/build/store/utils.js +0 -22
- package/build/store/utils.js.map +0 -1
- package/build-module/components/block-tools/selected-block-popover.js +0 -213
- package/build-module/components/block-tools/selected-block-popover.js.map +0 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
- package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
- package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
- package/build-module/components/inserter/block-patterns-filter.js.map +0 -1
- package/build-module/components/inserter/block-patterns-tab.js +0 -254
- package/build-module/components/inserter/block-patterns-tab.js.map +0 -1
- package/build-module/store/utils.js +0 -16
- package/build-module/store/utils.js.map +0 -1
- package/src/components/block-tools/selected-block-popover.js +0 -265
- package/src/components/inserter/block-patterns-tab.js +0 -448
- package/src/store/utils.js +0 -12
- /package/src/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +0 -0
|
@@ -19,6 +19,7 @@ import { SPACE, ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';
|
|
|
19
19
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
20
20
|
import { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';
|
|
21
21
|
import { __, sprintf } from '@wordpress/i18n';
|
|
22
|
+
import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Internal dependencies
|
|
@@ -30,6 +31,7 @@ import ListViewExpander from './expander';
|
|
|
30
31
|
import { useBlockLock } from '../block-lock';
|
|
31
32
|
import { store as blockEditorStore } from '../../store';
|
|
32
33
|
import useListViewImages from './use-list-view-images';
|
|
34
|
+
import { useListViewContext } from './context';
|
|
33
35
|
|
|
34
36
|
function ListViewBlockSelectButton(
|
|
35
37
|
{
|
|
@@ -64,10 +66,12 @@ function ListViewBlockSelectButton(
|
|
|
64
66
|
getBlocksByClientId,
|
|
65
67
|
canRemoveBlocks,
|
|
66
68
|
} = useSelect( blockEditorStore );
|
|
67
|
-
const { duplicateBlocks, removeBlocks } =
|
|
69
|
+
const { duplicateBlocks, multiSelect, removeBlocks } =
|
|
70
|
+
useDispatch( blockEditorStore );
|
|
68
71
|
const isMatch = useShortcutEventMatch();
|
|
69
72
|
const isSticky = blockInformation?.positionType === 'sticky';
|
|
70
73
|
const images = useListViewImages( { clientId, isExpanded } );
|
|
74
|
+
const { rootClientId } = useListViewContext();
|
|
71
75
|
|
|
72
76
|
const positionLabel = blockInformation?.positionLabel
|
|
73
77
|
? sprintf(
|
|
@@ -183,6 +187,45 @@ function ListViewBlockSelectButton(
|
|
|
183
187
|
updateFocusAndSelection( updatedBlocks[ 0 ], false );
|
|
184
188
|
}
|
|
185
189
|
}
|
|
190
|
+
} else if ( isMatch( 'core/block-editor/select-all', event ) ) {
|
|
191
|
+
if ( event.defaultPrevented ) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
event.preventDefault();
|
|
195
|
+
|
|
196
|
+
const { firstBlockRootClientId, selectedBlockClientIds } =
|
|
197
|
+
getBlocksToUpdate();
|
|
198
|
+
const blockClientIds = getBlockOrder( firstBlockRootClientId );
|
|
199
|
+
if ( ! blockClientIds.length ) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// If we have selected all sibling nested blocks, try selecting up a level.
|
|
204
|
+
// This is a similar implementation to that used by `useSelectAll`.
|
|
205
|
+
// `isShallowEqual` is used for the list view instead of a length check,
|
|
206
|
+
// as the array of siblings of the currently focused block may be a different
|
|
207
|
+
// set of blocks from the current block selection if the user is focused
|
|
208
|
+
// on a different part of the list view from the block selection.
|
|
209
|
+
if ( isShallowEqual( selectedBlockClientIds, blockClientIds ) ) {
|
|
210
|
+
// Only select up a level if the first block is not the root block.
|
|
211
|
+
// This ensures that the block selection can't break out of the root block
|
|
212
|
+
// used by the list view, if the list view is only showing a partial hierarchy.
|
|
213
|
+
if (
|
|
214
|
+
firstBlockRootClientId &&
|
|
215
|
+
firstBlockRootClientId !== rootClientId
|
|
216
|
+
) {
|
|
217
|
+
updateFocusAndSelection( firstBlockRootClientId, true );
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Select all while passing `null` to skip focusing to the editor canvas,
|
|
223
|
+
// and retain focus within the list view.
|
|
224
|
+
multiSelect(
|
|
225
|
+
blockClientIds[ 0 ],
|
|
226
|
+
blockClientIds[ blockClientIds.length - 1 ],
|
|
227
|
+
null
|
|
228
|
+
);
|
|
186
229
|
}
|
|
187
230
|
}
|
|
188
231
|
|
|
@@ -69,17 +69,17 @@ function ListViewBlock( {
|
|
|
69
69
|
const blockTitle =
|
|
70
70
|
blockInformation?.name || blockInformation?.title || __( 'Untitled' );
|
|
71
71
|
|
|
72
|
-
const block = useSelect(
|
|
73
|
-
( select ) =>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
72
|
+
const { block, blockName, blockEditingMode } = useSelect(
|
|
73
|
+
( select ) => {
|
|
74
|
+
const { getBlock, getBlockName, getBlockEditingMode } =
|
|
75
|
+
select( blockEditorStore );
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
block: getBlock( clientId ),
|
|
79
|
+
blockName: getBlockName( clientId ),
|
|
80
|
+
blockEditingMode: getBlockEditingMode( clientId ),
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
83
|
[ clientId ]
|
|
84
84
|
);
|
|
85
85
|
|
|
@@ -222,6 +222,7 @@ function ListViewComponent(
|
|
|
222
222
|
insertedBlock,
|
|
223
223
|
setInsertedBlock,
|
|
224
224
|
treeGridElementRef: elementRef,
|
|
225
|
+
rootClientId,
|
|
225
226
|
} ),
|
|
226
227
|
[
|
|
227
228
|
draggedClientIds,
|
|
@@ -233,6 +234,7 @@ function ListViewComponent(
|
|
|
233
234
|
AdditionalBlockContent,
|
|
234
235
|
insertedBlock,
|
|
235
236
|
setInsertedBlock,
|
|
237
|
+
rootClientId,
|
|
236
238
|
]
|
|
237
239
|
);
|
|
238
240
|
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
&.has-siblings {
|
|
18
18
|
border-top: $border-width solid $gray-900;
|
|
19
19
|
margin-top: $grid-unit-10;
|
|
20
|
+
padding-bottom: $grid-unit-10;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
.block-editor-media-replace-flow__image-url-label {
|
|
@@ -55,8 +56,7 @@
|
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
.block-editor-link-control__search-actions {
|
|
58
|
-
|
|
59
|
-
right: 4px;
|
|
59
|
+
padding: $grid-unit-10 0 0;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -9,9 +9,16 @@ import {
|
|
|
9
9
|
useEffect,
|
|
10
10
|
useCallback,
|
|
11
11
|
} from '@wordpress/element';
|
|
12
|
+
import { useSelect } from '@wordpress/data';
|
|
12
13
|
import deprecated from '@wordpress/deprecated';
|
|
13
14
|
import { focus } from '@wordpress/dom';
|
|
14
15
|
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
16
|
+
import { ESCAPE } from '@wordpress/keycodes';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Internal dependencies
|
|
20
|
+
*/
|
|
21
|
+
import { store as blockEditorStore } from '../../store';
|
|
15
22
|
|
|
16
23
|
function hasOnlyToolbarItem( elements ) {
|
|
17
24
|
const dataProp = 'toolbarItem';
|
|
@@ -28,6 +35,7 @@ function hasFocusWithin( container ) {
|
|
|
28
35
|
|
|
29
36
|
function focusFirstTabbableIn( container ) {
|
|
30
37
|
const [ firstTabbable ] = focus.tabbable.find( container );
|
|
38
|
+
|
|
31
39
|
if ( firstTabbable ) {
|
|
32
40
|
firstTabbable.focus( {
|
|
33
41
|
// When focusing newly mounted toolbars,
|
|
@@ -38,7 +46,7 @@ function focusFirstTabbableIn( container ) {
|
|
|
38
46
|
}
|
|
39
47
|
}
|
|
40
48
|
|
|
41
|
-
function useIsAccessibleToolbar(
|
|
49
|
+
function useIsAccessibleToolbar( toolbarRef ) {
|
|
42
50
|
/*
|
|
43
51
|
* By default, we'll assume the starting accessible state of the Toolbar
|
|
44
52
|
* is true, as it seems to be the most common case.
|
|
@@ -62,7 +70,7 @@ function useIsAccessibleToolbar( ref ) {
|
|
|
62
70
|
);
|
|
63
71
|
|
|
64
72
|
const determineIsAccessibleToolbar = useCallback( () => {
|
|
65
|
-
const tabbables = focus.tabbable.find(
|
|
73
|
+
const tabbables = focus.tabbable.find( toolbarRef.current );
|
|
66
74
|
const onlyToolbarItem = hasOnlyToolbarItem( tabbables );
|
|
67
75
|
if ( ! onlyToolbarItem ) {
|
|
68
76
|
deprecated( 'Using custom components as toolbar controls', {
|
|
@@ -73,7 +81,7 @@ function useIsAccessibleToolbar( ref ) {
|
|
|
73
81
|
} );
|
|
74
82
|
}
|
|
75
83
|
setIsAccessibleToolbar( onlyToolbarItem );
|
|
76
|
-
}, [] );
|
|
84
|
+
}, [ toolbarRef ] );
|
|
77
85
|
|
|
78
86
|
useLayoutEffect( () => {
|
|
79
87
|
// Toolbar buttons may be rendered asynchronously, so we use
|
|
@@ -81,28 +89,32 @@ function useIsAccessibleToolbar( ref ) {
|
|
|
81
89
|
const observer = new window.MutationObserver(
|
|
82
90
|
determineIsAccessibleToolbar
|
|
83
91
|
);
|
|
84
|
-
observer.observe(
|
|
92
|
+
observer.observe( toolbarRef.current, {
|
|
93
|
+
childList: true,
|
|
94
|
+
subtree: true,
|
|
95
|
+
} );
|
|
85
96
|
return () => observer.disconnect();
|
|
86
|
-
}, [ isAccessibleToolbar ] );
|
|
97
|
+
}, [ determineIsAccessibleToolbar, isAccessibleToolbar, toolbarRef ] );
|
|
87
98
|
|
|
88
99
|
return isAccessibleToolbar;
|
|
89
100
|
}
|
|
90
101
|
|
|
91
|
-
function useToolbarFocus(
|
|
92
|
-
|
|
102
|
+
function useToolbarFocus( {
|
|
103
|
+
toolbarRef,
|
|
93
104
|
focusOnMount,
|
|
94
105
|
isAccessibleToolbar,
|
|
95
106
|
defaultIndex,
|
|
96
107
|
onIndexChange,
|
|
97
|
-
shouldUseKeyboardFocusShortcut
|
|
98
|
-
|
|
108
|
+
shouldUseKeyboardFocusShortcut,
|
|
109
|
+
focusEditorOnEscape,
|
|
110
|
+
} ) {
|
|
99
111
|
// Make sure we don't use modified versions of this prop.
|
|
100
112
|
const [ initialFocusOnMount ] = useState( focusOnMount );
|
|
101
113
|
const [ initialIndex ] = useState( defaultIndex );
|
|
102
114
|
|
|
103
115
|
const focusToolbar = useCallback( () => {
|
|
104
|
-
focusFirstTabbableIn(
|
|
105
|
-
}, [] );
|
|
116
|
+
focusFirstTabbableIn( toolbarRef.current );
|
|
117
|
+
}, [ toolbarRef ] );
|
|
106
118
|
|
|
107
119
|
const focusToolbarViaShortcut = () => {
|
|
108
120
|
if ( shouldUseKeyboardFocusShortcut ) {
|
|
@@ -121,7 +133,7 @@ function useToolbarFocus(
|
|
|
121
133
|
|
|
122
134
|
useEffect( () => {
|
|
123
135
|
// Store ref so we have access on useEffect cleanup: https://legacy.reactjs.org/blog/2020/08/10/react-v17-rc.html#effect-cleanup-timing
|
|
124
|
-
const navigableToolbarRef =
|
|
136
|
+
const navigableToolbarRef = toolbarRef.current;
|
|
125
137
|
// If initialIndex is passed, we focus on that toolbar item when the
|
|
126
138
|
// toolbar gets mounted and initial focus is not forced.
|
|
127
139
|
// We have to wait for the next browser paint because block controls aren't
|
|
@@ -150,32 +162,68 @@ function useToolbarFocus(
|
|
|
150
162
|
const index = items.findIndex( ( item ) => item.tabIndex === 0 );
|
|
151
163
|
onIndexChange( index );
|
|
152
164
|
};
|
|
153
|
-
}, [ initialIndex, initialFocusOnMount ] );
|
|
165
|
+
}, [ initialIndex, initialFocusOnMount, toolbarRef ] );
|
|
166
|
+
|
|
167
|
+
const { lastFocus } = useSelect( ( select ) => {
|
|
168
|
+
const { getLastFocus } = select( blockEditorStore );
|
|
169
|
+
return {
|
|
170
|
+
lastFocus: getLastFocus(),
|
|
171
|
+
};
|
|
172
|
+
}, [] );
|
|
173
|
+
/**
|
|
174
|
+
* Handles returning focus to the block editor canvas when pressing escape.
|
|
175
|
+
*/
|
|
176
|
+
useEffect( () => {
|
|
177
|
+
const navigableToolbarRef = toolbarRef.current;
|
|
178
|
+
|
|
179
|
+
if ( focusEditorOnEscape ) {
|
|
180
|
+
const handleKeyDown = ( event ) => {
|
|
181
|
+
if ( event.keyCode === ESCAPE && lastFocus?.current ) {
|
|
182
|
+
// Focus the last focused element when pressing escape.
|
|
183
|
+
event.preventDefault();
|
|
184
|
+
lastFocus.current.focus();
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
navigableToolbarRef.addEventListener( 'keydown', handleKeyDown );
|
|
188
|
+
return () => {
|
|
189
|
+
navigableToolbarRef.removeEventListener(
|
|
190
|
+
'keydown',
|
|
191
|
+
handleKeyDown
|
|
192
|
+
);
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
}, [ focusEditorOnEscape, lastFocus, toolbarRef ] );
|
|
154
196
|
}
|
|
155
197
|
|
|
156
|
-
function NavigableToolbar( {
|
|
198
|
+
export default function NavigableToolbar( {
|
|
157
199
|
children,
|
|
158
200
|
focusOnMount,
|
|
201
|
+
focusEditorOnEscape = false,
|
|
159
202
|
shouldUseKeyboardFocusShortcut = true,
|
|
160
203
|
__experimentalInitialIndex: initialIndex,
|
|
161
204
|
__experimentalOnIndexChange: onIndexChange,
|
|
162
205
|
...props
|
|
163
206
|
} ) {
|
|
164
|
-
const
|
|
165
|
-
const isAccessibleToolbar = useIsAccessibleToolbar(
|
|
207
|
+
const toolbarRef = useRef();
|
|
208
|
+
const isAccessibleToolbar = useIsAccessibleToolbar( toolbarRef );
|
|
166
209
|
|
|
167
|
-
useToolbarFocus(
|
|
168
|
-
|
|
210
|
+
useToolbarFocus( {
|
|
211
|
+
toolbarRef,
|
|
169
212
|
focusOnMount,
|
|
170
213
|
isAccessibleToolbar,
|
|
171
|
-
initialIndex,
|
|
214
|
+
defaultIndex: initialIndex,
|
|
172
215
|
onIndexChange,
|
|
173
|
-
shouldUseKeyboardFocusShortcut
|
|
174
|
-
|
|
216
|
+
shouldUseKeyboardFocusShortcut,
|
|
217
|
+
focusEditorOnEscape,
|
|
218
|
+
} );
|
|
175
219
|
|
|
176
220
|
if ( isAccessibleToolbar ) {
|
|
177
221
|
return (
|
|
178
|
-
<Toolbar
|
|
222
|
+
<Toolbar
|
|
223
|
+
label={ props[ 'aria-label' ] }
|
|
224
|
+
ref={ toolbarRef }
|
|
225
|
+
{ ...props }
|
|
226
|
+
>
|
|
179
227
|
{ children }
|
|
180
228
|
</Toolbar>
|
|
181
229
|
);
|
|
@@ -185,12 +233,10 @@ function NavigableToolbar( {
|
|
|
185
233
|
<NavigableMenu
|
|
186
234
|
orientation="horizontal"
|
|
187
235
|
role="toolbar"
|
|
188
|
-
ref={
|
|
236
|
+
ref={ toolbarRef }
|
|
189
237
|
{ ...props }
|
|
190
238
|
>
|
|
191
239
|
{ children }
|
|
192
240
|
</NavigableMenu>
|
|
193
241
|
);
|
|
194
242
|
}
|
|
195
|
-
|
|
196
|
-
export default NavigableToolbar;
|
|
@@ -34,7 +34,7 @@ wp.blocks.registerBlockType( /* ... */, {
|
|
|
34
34
|
},
|
|
35
35
|
|
|
36
36
|
edit: function( props ) {
|
|
37
|
-
return React.createElement( wp.
|
|
37
|
+
return React.createElement( wp.blockEditor.PlainText, {
|
|
38
38
|
className: props.className,
|
|
39
39
|
value: props.attributes.content,
|
|
40
40
|
onChange: function( content ) {
|
|
@@ -48,8 +48,8 @@ wp.blocks.registerBlockType( /* ... */, {
|
|
|
48
48
|
{% ESNext %}
|
|
49
49
|
|
|
50
50
|
```js
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
import { registerBlockType } from '@wordpress/blocks';
|
|
52
|
+
import { PlainText } from '@wordpress/block-editor';
|
|
53
53
|
|
|
54
54
|
registerBlockType( /* ... */, {
|
|
55
55
|
// ...
|
|
@@ -76,18 +76,11 @@ export default function useBlockSync( {
|
|
|
76
76
|
resetBlocks,
|
|
77
77
|
resetSelection,
|
|
78
78
|
replaceInnerBlocks,
|
|
79
|
-
selectBlock,
|
|
80
79
|
setHasControlledInnerBlocks,
|
|
81
80
|
__unstableMarkNextChangeAsNotPersistent,
|
|
82
81
|
} = registry.dispatch( blockEditorStore );
|
|
83
|
-
const {
|
|
84
|
-
|
|
85
|
-
getBlockName,
|
|
86
|
-
getBlocks,
|
|
87
|
-
getSelectionStart,
|
|
88
|
-
getSelectionEnd,
|
|
89
|
-
getBlock,
|
|
90
|
-
} = registry.select( blockEditorStore );
|
|
82
|
+
const { getBlockName, getBlocks, getSelectionStart, getSelectionEnd } =
|
|
83
|
+
registry.select( blockEditorStore );
|
|
91
84
|
const isControlled = useSelect(
|
|
92
85
|
( select ) => {
|
|
93
86
|
return (
|
|
@@ -180,9 +173,6 @@ export default function useBlockSync( {
|
|
|
180
173
|
// bound sync, unset the outbound value to avoid considering it in
|
|
181
174
|
// subsequent renders.
|
|
182
175
|
pendingChanges.current.outgoing = [];
|
|
183
|
-
const hadSelection = hasSelectedBlock();
|
|
184
|
-
const selectionAnchor = getSelectionStart();
|
|
185
|
-
const selectionFocus = getSelectionEnd();
|
|
186
176
|
setControlledBlocks();
|
|
187
177
|
|
|
188
178
|
if ( controlledSelection ) {
|
|
@@ -191,15 +181,6 @@ export default function useBlockSync( {
|
|
|
191
181
|
controlledSelection.selectionEnd,
|
|
192
182
|
controlledSelection.initialPosition
|
|
193
183
|
);
|
|
194
|
-
} else {
|
|
195
|
-
const selectionStillExists = getBlock(
|
|
196
|
-
selectionAnchor.clientId
|
|
197
|
-
);
|
|
198
|
-
if ( hadSelection && ! selectionStillExists ) {
|
|
199
|
-
selectBlock( clientId );
|
|
200
|
-
} else {
|
|
201
|
-
resetSelection( selectionAnchor, selectionFocus );
|
|
202
|
-
}
|
|
203
184
|
}
|
|
204
185
|
}
|
|
205
186
|
}, [ controlledBlocks, clientId ] );
|
|
@@ -71,7 +71,8 @@ _Optional._ A list of autocompleters to use instead of the default.
|
|
|
71
71
|
|
|
72
72
|
### `preserveWhiteSpace: Boolean`
|
|
73
73
|
|
|
74
|
-
_Optional._ Whether or not to preserve white space characters in the `value`. Normally tab, newline and space characters are collapsed to a single space
|
|
74
|
+
_Optional._ Whether or not to preserve white space characters in the `value`. Normally tab, newline and space characters are collapsed to a single space or
|
|
75
|
+
trimmed.
|
|
75
76
|
|
|
76
77
|
## RichText.Content
|
|
77
78
|
|
|
@@ -94,7 +95,7 @@ wp.blocks.registerBlockType( /* ... */, {
|
|
|
94
95
|
},
|
|
95
96
|
|
|
96
97
|
edit: function( props ) {
|
|
97
|
-
return React.createElement( wp.
|
|
98
|
+
return React.createElement( wp.blockEditor.RichText, {
|
|
98
99
|
tagName: 'h2',
|
|
99
100
|
className: props.className,
|
|
100
101
|
value: props.attributes.content,
|
|
@@ -105,7 +106,7 @@ wp.blocks.registerBlockType( /* ... */, {
|
|
|
105
106
|
},
|
|
106
107
|
|
|
107
108
|
save: function( props ) {
|
|
108
|
-
return React.createElement( wp.
|
|
109
|
+
return React.createElement( wp.blockEditor.RichText.Content, {
|
|
109
110
|
tagName: 'h2', value: props.attributes.content
|
|
110
111
|
} );
|
|
111
112
|
}
|
|
@@ -115,8 +116,8 @@ wp.blocks.registerBlockType( /* ... */, {
|
|
|
115
116
|
{% ESNext %}
|
|
116
117
|
|
|
117
118
|
```js
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
import { registerBlockType } from '@wordpress/blocks';
|
|
120
|
+
import { RichText } from '@wordpress/block-editor';
|
|
120
121
|
|
|
121
122
|
registerBlockType( /* ... */, {
|
|
122
123
|
// ...
|
|
@@ -161,7 +162,7 @@ wp.richText.registerFormatType( /* ... */, {
|
|
|
161
162
|
/* ... */
|
|
162
163
|
edit: function( props ) {
|
|
163
164
|
return React.createElement(
|
|
164
|
-
wp.
|
|
165
|
+
wp.blockEditor.RichTextToolbarButton, {
|
|
165
166
|
icon: 'editor-code',
|
|
166
167
|
title: 'My formatting button',
|
|
167
168
|
onClick: function() { /* ... */ }
|
|
@@ -175,8 +176,8 @@ wp.richText.registerFormatType( /* ... */, {
|
|
|
175
176
|
{% ESNext %}
|
|
176
177
|
|
|
177
178
|
```js
|
|
178
|
-
import { registerFormatType } from '
|
|
179
|
-
import {
|
|
179
|
+
import { registerFormatType } from '@wordpress/rich-text';
|
|
180
|
+
import { RichTextToolbarButton } from '@wordpress/block-editor';
|
|
180
181
|
|
|
181
182
|
registerFormatType( /* ... */, {
|
|
182
183
|
/* ... */
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
} from '@wordpress/blocks';
|
|
18
18
|
import { useInstanceId, useMergeRefs } from '@wordpress/compose';
|
|
19
19
|
import {
|
|
20
|
-
__experimentalRichText as RichText,
|
|
21
20
|
__unstableCreateElement,
|
|
22
21
|
isEmpty,
|
|
23
22
|
insert,
|
|
@@ -46,6 +45,7 @@ import {
|
|
|
46
45
|
} from './utils';
|
|
47
46
|
import EmbedHandlerPicker from './embed-handler-picker';
|
|
48
47
|
import { Content } from './content';
|
|
48
|
+
import RichText from './native';
|
|
49
49
|
|
|
50
50
|
const classes = 'block-editor-rich-text__editable';
|
|
51
51
|
|
|
@@ -688,6 +688,8 @@ ForwardedRichTextContainer.Content.defaultProps = {
|
|
|
688
688
|
value: '',
|
|
689
689
|
};
|
|
690
690
|
|
|
691
|
+
ForwardedRichTextContainer.Raw = RichText;
|
|
692
|
+
|
|
691
693
|
/**
|
|
692
694
|
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md
|
|
693
695
|
*/
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getActiveFormat, getActiveObject } from '@wordpress/rich-text';
|
|
5
|
+
|
|
6
|
+
export default function FormatEdit( {
|
|
7
|
+
formatTypes,
|
|
8
|
+
onChange,
|
|
9
|
+
onFocus,
|
|
10
|
+
value,
|
|
11
|
+
forwardedRef,
|
|
12
|
+
} ) {
|
|
13
|
+
return formatTypes.map( ( settings ) => {
|
|
14
|
+
const { name, edit: Edit } = settings;
|
|
15
|
+
|
|
16
|
+
if ( ! Edit ) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const activeFormat = getActiveFormat( value, name );
|
|
21
|
+
const isActive = activeFormat !== undefined;
|
|
22
|
+
const activeObject = getActiveObject( value );
|
|
23
|
+
const isObjectActive =
|
|
24
|
+
activeObject !== undefined && activeObject.type === name;
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Edit
|
|
28
|
+
key={ name }
|
|
29
|
+
isActive={ isActive }
|
|
30
|
+
activeAttributes={
|
|
31
|
+
isActive ? activeFormat.attributes || {} : {}
|
|
32
|
+
}
|
|
33
|
+
isObjectActive={ isObjectActive }
|
|
34
|
+
activeObjectAttributes={
|
|
35
|
+
isObjectActive ? activeObject.attributes || {} : {}
|
|
36
|
+
}
|
|
37
|
+
value={ value }
|
|
38
|
+
onChange={ onChange }
|
|
39
|
+
onFocus={ onFocus }
|
|
40
|
+
contentRef={ forwardedRef }
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
} );
|
|
44
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getColorObjectByAttributeValues } from '../../../components/colors';
|
|
5
|
+
|
|
6
|
+
const FORMAT_TYPE = 'core/text-color';
|
|
7
|
+
const REGEX_TO_MATCH = /^has-(.*)-color$/;
|
|
8
|
+
const TAGS_TO_SEARCH = /\<mark/;
|
|
9
|
+
|
|
10
|
+
export function getFormatColors( value, formats, colors ) {
|
|
11
|
+
if ( value?.search( TAGS_TO_SEARCH ) !== -1 ) {
|
|
12
|
+
const newFormats = formats.slice();
|
|
13
|
+
|
|
14
|
+
newFormats.forEach( ( format ) => {
|
|
15
|
+
format.forEach( ( currentFormat ) => {
|
|
16
|
+
if ( currentFormat?.type === FORMAT_TYPE ) {
|
|
17
|
+
const className = currentFormat?.attributes?.class;
|
|
18
|
+
currentFormat.attributes.style =
|
|
19
|
+
currentFormat.attributes.style.replace( / /g, '' );
|
|
20
|
+
|
|
21
|
+
className?.split( ' ' ).forEach( ( currentClass ) => {
|
|
22
|
+
const match = currentClass.match( REGEX_TO_MATCH );
|
|
23
|
+
if ( match ) {
|
|
24
|
+
const [ , colorSlug ] =
|
|
25
|
+
currentClass.match( REGEX_TO_MATCH );
|
|
26
|
+
const colorObject = getColorObjectByAttributeValues(
|
|
27
|
+
colors,
|
|
28
|
+
colorSlug
|
|
29
|
+
);
|
|
30
|
+
const currentStyles =
|
|
31
|
+
currentFormat?.attributes?.style;
|
|
32
|
+
if (
|
|
33
|
+
colorObject &&
|
|
34
|
+
( ! currentStyles ||
|
|
35
|
+
currentStyles?.indexOf(
|
|
36
|
+
colorObject.color
|
|
37
|
+
) === -1 )
|
|
38
|
+
) {
|
|
39
|
+
currentFormat.attributes.style = [
|
|
40
|
+
`color: ${ colorObject.color }`,
|
|
41
|
+
currentStyles,
|
|
42
|
+
].join( ';' );
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} );
|
|
46
|
+
}
|
|
47
|
+
} );
|
|
48
|
+
} );
|
|
49
|
+
|
|
50
|
+
return newFormats;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return formats;
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default () => {};
|