@wordpress/block-editor 12.21.0 → 12.23.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 +4 -0
- package/README.md +4 -0
- package/build/components/block-actions/index.js +2 -4
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-heading-level-dropdown/index.js +5 -5
- package/build/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build/components/block-heading-level-dropdown/index.native.js +5 -4
- package/build/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build/components/block-list/block-crash-boundary.native.js +49 -0
- package/build/components/block-list/block-crash-boundary.native.js.map +1 -0
- package/build/components/block-list/block-crash-warning.native.js +24 -0
- package/build/components/block-list/block-crash-warning.native.js.map +1 -0
- package/build/components/block-list/block.js +11 -3
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +7 -2
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-mover/button.js +4 -1
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +5 -1
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +4 -1
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-settings/container.native.js +2 -1
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +36 -32
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -3
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-switcher/index.js +4 -3
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +8 -5
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +19 -10
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +48 -8
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +14 -2
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/child-layout-control/index.js +108 -11
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +11 -0
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build/components/global-styles/advanced-panel.js +9 -2
- package/build/components/global-styles/advanced-panel.js.map +1 -1
- package/build/components/global-styles/background-panel.js +444 -0
- package/build/components/global-styles/background-panel.js.map +1 -0
- package/build/components/global-styles/color-panel.js +2 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +8 -33
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/get-global-styles-changes.js +3 -0
- package/build/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build/components/global-styles/hooks.js +1 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +13 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +16 -15
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -3
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +43 -34
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/index.js +3 -6
- package/build/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +5 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build/components/inserter/library.js +2 -0
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/menu.js +11 -11
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +1 -1
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build/components/inserter/search-items.js +36 -15
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter/search-results.js +2 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +1 -2
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.native.js +36 -0
- package/build/components/inspector-controls-tabs/advanced-controls-panel.native.js.map +1 -0
- package/build/components/keyboard-shortcuts/index.js +11 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +18 -12
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +4 -11
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/index.js +17 -2
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-list-view-collapse-items.js +47 -0
- package/build/components/list-view/use-list-view-collapse-items.js.map +1 -0
- package/build/components/list-view/utils.js +5 -3
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/rich-text/index.js +14 -11
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +17 -11
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/get-format-colors.native.js +1 -1
- package/build/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +2 -2
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/rich-text/with-deprecations.js +0 -3
- package/build/components/rich-text/with-deprecations.js.map +1 -1
- package/build/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/build/components/spacing-sizes-control/sides-dropdown/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +50 -36
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/use-block-display-information/index.js +4 -6
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +4 -0
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/warning/index.native.js +9 -4
- package/build/components/warning/index.native.js.map +1 -1
- package/build/hooks/anchor.js +9 -10
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +85 -402
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/index.js +9 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout-child.js +28 -6
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/layout.js +21 -10
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +1 -1
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/use-zoom-out.js +47 -0
- package/build/hooks/use-zoom-out.js.map +1 -0
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/private-apis.js +6 -1
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +5 -1
- package/build/private-apis.native.js.map +1 -1
- package/build/store/private-actions.js +13 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-keys.js +2 -1
- package/build/store/private-keys.js.map +1 -1
- package/build/store/private-selectors.js +24 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +53 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +34 -32
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +7 -1
- package/build/store/utils.js.map +1 -1
- package/build/utils/transform-styles/index.js +2 -1
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/block-actions/index.js +2 -4
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js +5 -5
- package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.native.js +5 -4
- package/build-module/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build-module/components/block-list/block-crash-boundary.native.js +42 -0
- package/build-module/components/block-list/block-crash-boundary.native.js.map +1 -0
- package/build-module/components/block-list/block-crash-warning.native.js +15 -0
- package/build-module/components/block-list/block-crash-warning.native.js.map +1 -0
- package/build-module/components/block-list/block.js +11 -3
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +7 -2
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-mover/button.js +4 -1
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +5 -1
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +4 -1
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +3 -2
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +37 -33
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +1 -3
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +4 -3
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +8 -5
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +19 -10
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +50 -10
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +14 -2
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +109 -12
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +12 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build-module/components/global-styles/advanced-panel.js +9 -2
- package/build-module/components/global-styles/advanced-panel.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +430 -0
- package/build-module/components/global-styles/background-panel.js.map +1 -0
- package/build-module/components/global-styles/color-panel.js +2 -1
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +9 -34
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/get-global-styles-changes.js +3 -0
- package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +1 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +1 -0
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +17 -16
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +1 -2
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +43 -34
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/index.js +3 -6
- package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +5 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build-module/components/inserter/library.js +2 -0
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/menu.js +11 -11
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build-module/components/inserter/search-items.js +33 -15
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter/search-results.js +2 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +1 -2
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.native.js +28 -0
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.native.js.map +1 -0
- package/build-module/components/keyboard-shortcuts/index.js +11 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +19 -13
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +6 -13
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/index.js +17 -2
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-list-view-collapse-items.js +40 -0
- package/build-module/components/list-view/use-list-view-collapse-items.js.map +1 -0
- package/build-module/components/list-view/utils.js +2 -1
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/rich-text/index.js +15 -12
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +16 -11
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/get-format-colors.native.js +1 -1
- package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +2 -2
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/rich-text/with-deprecations.js +0 -3
- package/build-module/components/rich-text/with-deprecations.js.map +1 -1
- package/build-module/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/build-module/components/spacing-sizes-control/sides-dropdown/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +50 -36
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +5 -7
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +4 -0
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/warning/index.native.js +9 -4
- package/build-module/components/warning/index.native.js.map +1 -1
- package/build-module/hooks/anchor.js +10 -11
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +82 -397
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/index.js +3 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout-child.js +28 -6
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/layout.js +21 -10
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +1 -1
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/use-zoom-out.js +41 -0
- package/build-module/hooks/use-zoom-out.js.map +1 -0
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/private-apis.js +7 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +5 -1
- package/build-module/private-apis.native.js.map +1 -1
- package/build-module/store/private-actions.js +12 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-keys.js +1 -0
- package/build-module/store/private-keys.js.map +1 -1
- package/build-module/store/private-selectors.js +22 -4
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +52 -26
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +35 -33
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +6 -1
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +2 -1
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +18 -1
- package/build-style/content.css +18 -1
- package/build-style/style-rtl.css +92 -99
- package/build-style/style.css +92 -99
- package/package.json +31 -31
- package/src/components/block-actions/index.js +2 -8
- package/src/components/block-bindings-toolbar-indicator/style.scss +10 -8
- package/src/components/block-heading-level-dropdown/README.md +5 -5
- package/src/components/block-heading-level-dropdown/index.js +5 -5
- package/src/components/block-heading-level-dropdown/index.native.js +5 -4
- package/src/components/block-list/block-crash-boundary.native.js +43 -0
- package/src/components/block-list/block-crash-warning.native.js +19 -0
- package/src/components/block-list/block.js +19 -3
- package/src/components/block-list/block.native.js +14 -7
- package/src/components/block-list/content.scss +16 -0
- package/src/components/block-mover/button.js +4 -1
- package/src/components/block-mover/index.js +8 -1
- package/src/components/block-patterns-list/index.js +22 -17
- package/src/components/block-preview/style.scss +28 -0
- package/src/components/block-settings/container.native.js +5 -1
- package/src/components/block-settings-menu/block-settings-dropdown.js +49 -58
- package/src/components/block-settings-menu-controls/README.md +0 -9
- package/src/components/block-settings-menu-controls/index.js +1 -6
- package/src/components/block-switcher/index.js +5 -3
- package/src/components/block-switcher/style.scss +1 -1
- package/src/components/block-toolbar/index.js +25 -20
- package/src/components/block-toolbar/shuffle.js +20 -14
- package/src/components/block-toolbar/style.scss +1 -1
- package/src/components/block-toolbar/test/index.native.js +1 -7
- package/src/components/block-tools/block-selection-button.js +66 -9
- package/src/components/block-tools/index.js +18 -1
- package/src/components/button-block-appender/content.scss +5 -1
- package/src/components/child-layout-control/index.js +147 -35
- package/src/components/convert-to-group-buttons/toolbar.js +13 -1
- package/src/components/default-block-appender/content.scss +2 -2
- package/src/components/global-styles/advanced-panel.js +8 -2
- package/src/components/global-styles/background-panel.js +591 -0
- package/src/components/global-styles/color-panel.js +2 -1
- package/src/components/global-styles/dimensions-panel.js +9 -34
- package/src/components/global-styles/get-global-styles-changes.js +3 -0
- package/src/components/global-styles/hooks.js +1 -0
- package/src/components/global-styles/index.js +4 -0
- package/src/components/global-styles/style.scss +78 -1
- package/src/{hooks/test/background.js → components/global-styles/test/background-panel.js} +36 -1
- package/src/components/global-styles/test/get-global-styles-changes.js +22 -3
- package/src/components/global-styles/test/use-global-styles-output.js +40 -9
- package/src/components/global-styles/use-global-styles-output.js +30 -17
- package/src/components/global-styles/utils.js +1 -18
- package/src/components/iframe/index.js +79 -53
- package/src/components/inserter/block-patterns-explorer/index.js +2 -9
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +7 -1
- package/src/components/inserter/block-patterns-tab/index.js +1 -0
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +5 -0
- package/src/components/inserter/library.js +4 -0
- package/src/components/inserter/menu.js +12 -11
- package/src/components/inserter/mobile-tab-navigation.js +1 -1
- package/src/components/inserter/search-items.js +37 -15
- package/src/components/inserter/search-results.js +1 -2
- package/src/components/inserter/style.scss +6 -12
- package/src/components/inserter/tabs.js +1 -2
- package/src/components/inspector-controls-tabs/advanced-controls-panel.native.js +31 -0
- package/src/components/keyboard-shortcuts/index.js +11 -0
- package/src/components/link-control/style.scss +0 -5
- package/src/components/list-view/block-select-button.js +15 -19
- package/src/components/list-view/block.js +12 -21
- package/src/components/list-view/index.js +18 -1
- package/src/components/list-view/style.scss +38 -28
- package/src/components/list-view/use-list-view-collapse-items.js +33 -0
- package/src/components/list-view/utils.js +4 -1
- package/src/components/rich-text/README.md +6 -0
- package/src/components/rich-text/index.js +30 -13
- package/src/components/rich-text/index.native.js +14 -11
- package/src/components/rich-text/native/get-format-colors.native.js +1 -1
- package/src/components/rich-text/native/index.native.js +2 -2
- package/src/components/rich-text/with-deprecations.js +0 -3
- package/src/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/src/components/url-popover/image-url-input-ui.js +68 -51
- package/src/components/use-block-display-information/index.js +8 -10
- package/src/components/use-moving-animation/index.js +1 -0
- package/src/components/warning/index.native.js +19 -15
- package/src/hooks/anchor.js +43 -61
- package/src/hooks/background.js +100 -516
- package/src/hooks/index.js +3 -0
- package/src/hooks/layout-child.js +44 -8
- package/src/hooks/layout.js +22 -18
- package/src/hooks/position.js +1 -1
- package/src/hooks/test/__snapshots__/anchor.native.js.snap +7 -0
- package/src/hooks/test/anchor.native.js +32 -0
- package/src/hooks/use-zoom-out.js +36 -0
- package/src/index.js +1 -0
- package/src/private-apis.js +13 -1
- package/src/private-apis.native.js +4 -0
- package/src/store/private-actions.js +12 -0
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +54 -27
- package/src/store/reducer.js +63 -41
- package/src/store/selectors.js +195 -180
- package/src/store/test/private-actions.js +10 -0
- package/src/store/test/private-selectors.js +13 -0
- package/src/store/test/reducer.js +26 -0
- package/src/store/test/selectors.js +90 -199
- package/src/store/utils.js +13 -0
- package/src/style.scss +0 -2
- package/src/utils/transform-styles/index.js +2 -1
- package/tsconfig.json +1 -0
- package/build/utils/calculate-scale.js +0 -17
- package/build/utils/calculate-scale.js.map +0 -1
- package/build-module/utils/calculate-scale.js +0 -11
- package/build-module/utils/calculate-scale.js.map +0 -1
- package/src/hooks/anchor.scss +0 -4
- package/src/hooks/background.scss +0 -75
- package/src/utils/calculate-scale.js +0 -20
|
@@ -14,12 +14,7 @@ import {
|
|
|
14
14
|
Tooltip,
|
|
15
15
|
} from '@wordpress/components';
|
|
16
16
|
import { forwardRef } from '@wordpress/element';
|
|
17
|
-
import {
|
|
18
|
-
Icon,
|
|
19
|
-
connection,
|
|
20
|
-
lockSmall as lock,
|
|
21
|
-
pinSmall,
|
|
22
|
-
} from '@wordpress/icons';
|
|
17
|
+
import { Icon, lockSmall as lock, pinSmall } from '@wordpress/icons';
|
|
23
18
|
import { SPACE, ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';
|
|
24
19
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
25
20
|
import { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';
|
|
@@ -37,12 +32,11 @@ import { useBlockLock } from '../block-lock';
|
|
|
37
32
|
import { store as blockEditorStore } from '../../store';
|
|
38
33
|
import useListViewImages from './use-list-view-images';
|
|
39
34
|
import { useListViewContext } from './context';
|
|
40
|
-
import { canBindBlock } from '../../hooks/use-bindings-attributes';
|
|
41
35
|
|
|
42
36
|
function ListViewBlockSelectButton(
|
|
43
37
|
{
|
|
44
38
|
className,
|
|
45
|
-
block: { clientId
|
|
39
|
+
block: { clientId },
|
|
46
40
|
onClick,
|
|
47
41
|
onContextMenu,
|
|
48
42
|
onMouseDown,
|
|
@@ -53,7 +47,6 @@ function ListViewBlockSelectButton(
|
|
|
53
47
|
onDragEnd,
|
|
54
48
|
draggable,
|
|
55
49
|
isExpanded,
|
|
56
|
-
ariaLabel,
|
|
57
50
|
ariaDescribedBy,
|
|
58
51
|
updateFocusAndSelection,
|
|
59
52
|
},
|
|
@@ -71,8 +64,8 @@ function ListViewBlockSelectButton(
|
|
|
71
64
|
getPreviousBlockClientId,
|
|
72
65
|
getBlockRootClientId,
|
|
73
66
|
getBlockOrder,
|
|
67
|
+
getBlockParents,
|
|
74
68
|
getBlocksByClientId,
|
|
75
|
-
getBlockAttributes,
|
|
76
69
|
canRemoveBlocks,
|
|
77
70
|
} = useSelect( blockEditorStore );
|
|
78
71
|
const { duplicateBlocks, multiSelect, removeBlocks } =
|
|
@@ -80,9 +73,7 @@ function ListViewBlockSelectButton(
|
|
|
80
73
|
const isMatch = useShortcutEventMatch();
|
|
81
74
|
const isSticky = blockInformation?.positionType === 'sticky';
|
|
82
75
|
const images = useListViewImages( { clientId, isExpanded } );
|
|
83
|
-
const { rootClientId } = useListViewContext();
|
|
84
|
-
|
|
85
|
-
const isConnected = getBlockAttributes( clientId )?.metadata?.bindings;
|
|
76
|
+
const { collapseAll, expand, rootClientId } = useListViewContext();
|
|
86
77
|
|
|
87
78
|
const positionLabel = blockInformation?.positionLabel
|
|
88
79
|
? sprintf(
|
|
@@ -237,6 +228,17 @@ function ListViewBlockSelectButton(
|
|
|
237
228
|
blockClientIds[ blockClientIds.length - 1 ],
|
|
238
229
|
null
|
|
239
230
|
);
|
|
231
|
+
} else if ( isMatch( 'core/block-editor/collapse-list-view', event ) ) {
|
|
232
|
+
if ( event.defaultPrevented ) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
event.preventDefault();
|
|
236
|
+
const { firstBlockClientId } = getBlocksToUpdate();
|
|
237
|
+
const blockParents = getBlockParents( firstBlockClientId, false );
|
|
238
|
+
// Collapse all blocks.
|
|
239
|
+
collapseAll();
|
|
240
|
+
// Expand all parents of the current block.
|
|
241
|
+
expand( blockParents );
|
|
240
242
|
}
|
|
241
243
|
}
|
|
242
244
|
|
|
@@ -258,7 +260,6 @@ function ListViewBlockSelectButton(
|
|
|
258
260
|
onDragEnd={ onDragEnd }
|
|
259
261
|
draggable={ draggable }
|
|
260
262
|
href={ `#block-${ clientId }` }
|
|
261
|
-
aria-label={ ariaLabel }
|
|
262
263
|
aria-describedby={ ariaDescribedBy }
|
|
263
264
|
aria-expanded={ isExpanded }
|
|
264
265
|
>
|
|
@@ -287,11 +288,6 @@ function ListViewBlockSelectButton(
|
|
|
287
288
|
</Truncate>
|
|
288
289
|
</span>
|
|
289
290
|
) }
|
|
290
|
-
{ isConnected && canBindBlock( blockName ) && (
|
|
291
|
-
<span className="block-editor-list-view-block-select-button__bindings">
|
|
292
|
-
<Icon icon={ connection } />
|
|
293
|
-
</span>
|
|
294
|
-
) }
|
|
295
291
|
{ positionLabel && isSticky && (
|
|
296
292
|
<Tooltip text={ positionLabel }>
|
|
297
293
|
<Icon icon={ pinSmall } />
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
memo,
|
|
22
22
|
} from '@wordpress/element';
|
|
23
23
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
24
|
-
import {
|
|
24
|
+
import { __ } from '@wordpress/i18n';
|
|
25
25
|
import { ESCAPE } from '@wordpress/keycodes';
|
|
26
26
|
|
|
27
27
|
/**
|
|
@@ -35,7 +35,11 @@ import {
|
|
|
35
35
|
} from '../block-mover/button';
|
|
36
36
|
import ListViewBlockContents from './block-contents';
|
|
37
37
|
import { useListViewContext } from './context';
|
|
38
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
getBlockPositionDescription,
|
|
40
|
+
getBlockPropertiesDescription,
|
|
41
|
+
focusListItem,
|
|
42
|
+
} from './utils';
|
|
39
43
|
import { store as blockEditorStore } from '../../store';
|
|
40
44
|
import useBlockDisplayInformation from '../use-block-display-information';
|
|
41
45
|
import { useBlockLock } from '../block-lock';
|
|
@@ -77,8 +81,6 @@ function ListViewBlock( {
|
|
|
77
81
|
const { toggleBlockHighlight } = useDispatch( blockEditorStore );
|
|
78
82
|
|
|
79
83
|
const blockInformation = useBlockDisplayInformation( clientId );
|
|
80
|
-
const blockTitle =
|
|
81
|
-
blockInformation?.name || blockInformation?.title || __( 'Untitled' );
|
|
82
84
|
|
|
83
85
|
const { block, blockName, blockEditingMode } = useSelect(
|
|
84
86
|
( select ) => {
|
|
@@ -93,6 +95,7 @@ function ListViewBlock( {
|
|
|
93
95
|
},
|
|
94
96
|
[ clientId ]
|
|
95
97
|
);
|
|
98
|
+
|
|
96
99
|
const allowRightClickOverrides = useSelect(
|
|
97
100
|
( select ) =>
|
|
98
101
|
select( blockEditorStore ).getSettings().allowRightClickOverrides,
|
|
@@ -107,7 +110,7 @@ function ListViewBlock( {
|
|
|
107
110
|
// Don't show the settings menu if block is disabled or content only.
|
|
108
111
|
blockEditingMode === 'default';
|
|
109
112
|
const instanceId = useInstanceId( ListViewBlock );
|
|
110
|
-
const descriptionId = `list-view-block-select-
|
|
113
|
+
const descriptionId = `list-view-block-select-button__description-${ instanceId }`;
|
|
111
114
|
|
|
112
115
|
const {
|
|
113
116
|
expand,
|
|
@@ -247,19 +250,8 @@ function ListViewBlock( {
|
|
|
247
250
|
level
|
|
248
251
|
);
|
|
249
252
|
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
// translators: %s: The title of the block. This string indicates a link to select the locked block.
|
|
253
|
-
__( '%s (locked)' ),
|
|
254
|
-
blockTitle
|
|
255
|
-
)
|
|
256
|
-
: blockTitle;
|
|
257
|
-
|
|
258
|
-
const settingsAriaLabel = sprintf(
|
|
259
|
-
// translators: %s: The title of the block.
|
|
260
|
-
__( 'Options for %s' ),
|
|
261
|
-
blockTitle
|
|
262
|
-
);
|
|
253
|
+
const blockPropertiesDescription =
|
|
254
|
+
getBlockPropertiesDescription( isLocked );
|
|
263
255
|
|
|
264
256
|
const hasSiblings = siblingBlockCount > 0;
|
|
265
257
|
const hasRenderedMovers = showBlockMovers && hasSiblings;
|
|
@@ -352,12 +344,11 @@ function ListViewBlock( {
|
|
|
352
344
|
onFocus={ onFocus }
|
|
353
345
|
isExpanded={ canEdit ? isExpanded : undefined }
|
|
354
346
|
selectedClientIds={ selectedClientIds }
|
|
355
|
-
ariaLabel={ blockAriaLabel }
|
|
356
347
|
ariaDescribedBy={ descriptionId }
|
|
357
348
|
updateFocusAndSelection={ updateFocusAndSelection }
|
|
358
349
|
/>
|
|
359
350
|
<AriaReferencedText id={ descriptionId }>
|
|
360
|
-
{ blockPositionDescription }
|
|
351
|
+
{ `${ blockPositionDescription } ${ blockPropertiesDescription }` }
|
|
361
352
|
</AriaReferencedText>
|
|
362
353
|
</div>
|
|
363
354
|
) }
|
|
@@ -405,7 +396,7 @@ function ListViewBlock( {
|
|
|
405
396
|
clientIds={ dropdownClientIds }
|
|
406
397
|
block={ block }
|
|
407
398
|
icon={ moreVertical }
|
|
408
|
-
label={
|
|
399
|
+
label={ __( 'Options' ) }
|
|
409
400
|
popoverProps={ {
|
|
410
401
|
anchor: settingsPopoverAnchor, // Used to position the settings at the cursor on right-click.
|
|
411
402
|
} }
|
|
@@ -37,6 +37,7 @@ import ListViewDropIndicatorPreview from './drop-indicator';
|
|
|
37
37
|
import useBlockSelection from './use-block-selection';
|
|
38
38
|
import useListViewBlockIndexes from './use-list-view-block-indexes';
|
|
39
39
|
import useListViewClientIds from './use-list-view-client-ids';
|
|
40
|
+
import useListViewCollapseItems from './use-list-view-collapse-items';
|
|
40
41
|
import useListViewDropZone from './use-list-view-drop-zone';
|
|
41
42
|
import useListViewExpandSelectedItem from './use-list-view-expand-selected-item';
|
|
42
43
|
import { store as blockEditorStore } from '../../store';
|
|
@@ -45,6 +46,9 @@ import { focusListItem } from './utils';
|
|
|
45
46
|
import useClipboardHandler from './use-clipboard-handler';
|
|
46
47
|
|
|
47
48
|
const expanded = ( state, action ) => {
|
|
49
|
+
if ( action.type === 'clear' ) {
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
48
52
|
if ( Array.isArray( action.clientIds ) ) {
|
|
49
53
|
return {
|
|
50
54
|
...state,
|
|
@@ -194,7 +198,10 @@ function ListViewComponent(
|
|
|
194
198
|
if ( ! clientId ) {
|
|
195
199
|
return;
|
|
196
200
|
}
|
|
197
|
-
|
|
201
|
+
const clientIds = Array.isArray( clientId )
|
|
202
|
+
? clientId
|
|
203
|
+
: [ clientId ];
|
|
204
|
+
setExpandedState( { type: 'expand', clientIds } );
|
|
198
205
|
},
|
|
199
206
|
[ setExpandedState ]
|
|
200
207
|
);
|
|
@@ -207,6 +214,9 @@ function ListViewComponent(
|
|
|
207
214
|
},
|
|
208
215
|
[ setExpandedState ]
|
|
209
216
|
);
|
|
217
|
+
const collapseAll = useCallback( () => {
|
|
218
|
+
setExpandedState( { type: 'clear' } );
|
|
219
|
+
}, [ setExpandedState ] );
|
|
210
220
|
const expandRow = useCallback(
|
|
211
221
|
( row ) => {
|
|
212
222
|
expand( row?.dataset?.block );
|
|
@@ -232,6 +242,11 @@ function ListViewComponent(
|
|
|
232
242
|
[ updateBlockSelection ]
|
|
233
243
|
);
|
|
234
244
|
|
|
245
|
+
useListViewCollapseItems( {
|
|
246
|
+
collapseAll,
|
|
247
|
+
expand,
|
|
248
|
+
} );
|
|
249
|
+
|
|
235
250
|
const firstDraggedBlockClientId = draggedClientIds?.[ 0 ];
|
|
236
251
|
|
|
237
252
|
// Convert a blockDropTarget into indexes relative to the blocks in the list view.
|
|
@@ -282,6 +297,7 @@ function ListViewComponent(
|
|
|
282
297
|
expand,
|
|
283
298
|
firstDraggedBlockIndex,
|
|
284
299
|
collapse,
|
|
300
|
+
collapseAll,
|
|
285
301
|
BlockSettingsMenu,
|
|
286
302
|
listViewInstanceId: instanceId,
|
|
287
303
|
AdditionalBlockContent,
|
|
@@ -299,6 +315,7 @@ function ListViewComponent(
|
|
|
299
315
|
expand,
|
|
300
316
|
firstDraggedBlockIndex,
|
|
301
317
|
collapse,
|
|
318
|
+
collapseAll,
|
|
302
319
|
BlockSettingsMenu,
|
|
303
320
|
instanceId,
|
|
304
321
|
AdditionalBlockContent,
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
// Move upwards when in modal.
|
|
8
8
|
.components-modal__content & {
|
|
9
9
|
margin: (-$grid-unit-15) (-$grid-unit-15 * 0.5) 0;
|
|
10
|
-
width: calc(100% + #{
|
|
10
|
+
width: calc(100% + #{$grid-unit-15});
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
// Without setting `pointer-events: none`, when dragging over list view items,
|
|
@@ -71,7 +71,8 @@
|
|
|
71
71
|
&:focus::after {
|
|
72
72
|
box-shadow:
|
|
73
73
|
inset 0 0 0 1px $white,
|
|
74
|
-
0 0 0 var(--wp-admin-border-width-focus)
|
|
74
|
+
0 0 0 var(--wp-admin-border-width-focus)
|
|
75
|
+
var(--wp-block-synced-color);
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
&.is-selected .block-editor-list-view-block-contents,
|
|
@@ -82,14 +83,16 @@
|
|
|
82
83
|
&::after {
|
|
83
84
|
box-shadow:
|
|
84
85
|
inset 0 0 0 1px $white,
|
|
85
|
-
0 0 0 var(--wp-admin-border-width-focus)
|
|
86
|
+
0 0 0 var(--wp-admin-border-width-focus)
|
|
87
|
+
var(--wp-admin-theme-color);
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
90
|
&.is-selected.is-synced .block-editor-list-view-block-contents:focus {
|
|
89
91
|
&::after {
|
|
90
92
|
box-shadow:
|
|
91
93
|
inset 0 0 0 1px $white,
|
|
92
|
-
0 0 0 var(--wp-admin-border-width-focus)
|
|
94
|
+
0 0 0 var(--wp-admin-border-width-focus)
|
|
95
|
+
var(--wp-block-synced-color);
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
98
|
&.is-selected .block-editor-list-view-block__menu:focus {
|
|
@@ -181,7 +184,9 @@
|
|
|
181
184
|
|
|
182
185
|
&.is-after-dragged-blocks.is-displacement-down {
|
|
183
186
|
transition: transform 0.2s;
|
|
184
|
-
transform:
|
|
187
|
+
transform:
|
|
188
|
+
translateY(calc(36px + var(--wp-admin--list-view-dragged-items-height, 36px) *
|
|
189
|
+
-1));
|
|
185
190
|
@include reduce-motion("transition");
|
|
186
191
|
}
|
|
187
192
|
|
|
@@ -207,7 +212,7 @@
|
|
|
207
212
|
align-items: center;
|
|
208
213
|
width: 100%;
|
|
209
214
|
height: auto;
|
|
210
|
-
padding: ($grid-unit-15 * 0.5) $grid-unit-
|
|
215
|
+
padding: ($grid-unit-15 * 0.5) ($grid-unit-15 * 0.5) ($grid-unit-15 * 0.5) 0;
|
|
211
216
|
text-align: left;
|
|
212
217
|
border-radius: $radius-block-ui;
|
|
213
218
|
position: relative;
|
|
@@ -217,7 +222,10 @@
|
|
|
217
222
|
content: "";
|
|
218
223
|
position: absolute;
|
|
219
224
|
pointer-events: none;
|
|
220
|
-
transition:
|
|
225
|
+
transition:
|
|
226
|
+
border-color 0.1s linear,
|
|
227
|
+
border-style 0.1s linear,
|
|
228
|
+
box-shadow 0.1s linear;
|
|
221
229
|
top: -2px;
|
|
222
230
|
right: 0;
|
|
223
231
|
left: 0;
|
|
@@ -242,7 +250,9 @@
|
|
|
242
250
|
bottom: 0;
|
|
243
251
|
left: 0;
|
|
244
252
|
border-radius: inherit;
|
|
245
|
-
box-shadow:
|
|
253
|
+
box-shadow:
|
|
254
|
+
inset 0 0 0 var(--wp-admin-border-width-focus)
|
|
255
|
+
var(--wp-admin-theme-color);
|
|
246
256
|
z-index: 2;
|
|
247
257
|
pointer-events: none;
|
|
248
258
|
}
|
|
@@ -255,7 +265,9 @@
|
|
|
255
265
|
|
|
256
266
|
&.is-nesting .block-editor-list-view__menu,
|
|
257
267
|
.block-editor-list-view-block__menu:focus {
|
|
258
|
-
box-shadow:
|
|
268
|
+
box-shadow:
|
|
269
|
+
inset 0 0 0 var(--wp-admin-border-width-focus)
|
|
270
|
+
var(--wp-admin-theme-color);
|
|
259
271
|
z-index: 1;
|
|
260
272
|
}
|
|
261
273
|
|
|
@@ -297,14 +309,14 @@
|
|
|
297
309
|
|
|
298
310
|
&,
|
|
299
311
|
.components-button.has-icon {
|
|
300
|
-
width:
|
|
301
|
-
min-width:
|
|
312
|
+
width: $button-size-small;
|
|
313
|
+
min-width: $button-size-small;
|
|
302
314
|
padding: 0;
|
|
303
315
|
}
|
|
304
316
|
}
|
|
305
317
|
|
|
306
318
|
.block-editor-list-view-block__menu-cell {
|
|
307
|
-
padding-right: $grid-unit-
|
|
319
|
+
padding-right: $grid-unit-15 * 0.5; // 6px.
|
|
308
320
|
|
|
309
321
|
.components-button.has-icon {
|
|
310
322
|
height: 24px;
|
|
@@ -458,7 +470,9 @@ $block-navigation-max-indent: 8;
|
|
|
458
470
|
}
|
|
459
471
|
|
|
460
472
|
.block-editor-list-view-leaf[aria-level] .block-editor-list-view__expander {
|
|
461
|
-
margin-left:
|
|
473
|
+
margin-left:
|
|
474
|
+
($icon-size) * $block-navigation-max-indent + 4 *
|
|
475
|
+
($block-navigation-max-indent - 1);
|
|
462
476
|
}
|
|
463
477
|
|
|
464
478
|
.block-editor-list-view-leaf:not([aria-level="1"]) {
|
|
@@ -471,12 +485,12 @@ $block-navigation-max-indent: 8;
|
|
|
471
485
|
// indentation in `use-list-view-drop-zone.js` must be updated as well
|
|
472
486
|
// to ensure the drop zone is aligned with the indentation.
|
|
473
487
|
@for $i from 0 to $block-navigation-max-indent {
|
|
474
|
-
.block-editor-list-view-leaf[aria-level="#{ $i + 1 }"]
|
|
488
|
+
.block-editor-list-view-leaf[aria-level="#{ $i + 1 }"]
|
|
489
|
+
.block-editor-list-view__expander {
|
|
475
490
|
@if $i - 1 >= 0 {
|
|
476
|
-
margin-left: (
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
margin-left: ( $icon-size * $i );
|
|
491
|
+
margin-left: ($icon-size * $i) + 4 * ($i - 1);
|
|
492
|
+
} @else {
|
|
493
|
+
margin-left: ($icon-size * $i);
|
|
480
494
|
}
|
|
481
495
|
}
|
|
482
496
|
}
|
|
@@ -486,7 +500,9 @@ $block-navigation-max-indent: 8;
|
|
|
486
500
|
}
|
|
487
501
|
|
|
488
502
|
// Point downwards when open.
|
|
489
|
-
.block-editor-list-view-leaf[data-expanded="true"]
|
|
503
|
+
.block-editor-list-view-leaf[data-expanded="true"]
|
|
504
|
+
.block-editor-list-view__expander
|
|
505
|
+
svg {
|
|
490
506
|
visibility: visible;
|
|
491
507
|
transition: transform 0.2s ease;
|
|
492
508
|
transform: rotate(90deg);
|
|
@@ -494,7 +510,9 @@ $block-navigation-max-indent: 8;
|
|
|
494
510
|
}
|
|
495
511
|
|
|
496
512
|
// Point rightwards when closed
|
|
497
|
-
.block-editor-list-view-leaf[data-expanded="false"]
|
|
513
|
+
.block-editor-list-view-leaf[data-expanded="false"]
|
|
514
|
+
.block-editor-list-view__expander
|
|
515
|
+
svg {
|
|
498
516
|
visibility: visible;
|
|
499
517
|
transform: rotate(0deg);
|
|
500
518
|
transition: transform 0.2s ease;
|
|
@@ -557,11 +575,3 @@ $block-navigation-max-indent: 8;
|
|
|
557
575
|
.list-view-appender__description {
|
|
558
576
|
display: none;
|
|
559
577
|
}
|
|
560
|
-
|
|
561
|
-
.block-editor-list-view-block-select-button__bindings svg g {
|
|
562
|
-
stroke: var(--wp-bound-block-color);
|
|
563
|
-
fill: transparent;
|
|
564
|
-
stroke-width: 1.5;
|
|
565
|
-
stroke-linecap: round;
|
|
566
|
-
stroke-linejoin: round;
|
|
567
|
-
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useEffect } from '@wordpress/element';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { store as blockEditorStore } from '../../store';
|
|
11
|
+
import { unlock } from '../../lock-unlock';
|
|
12
|
+
|
|
13
|
+
export default function useListViewCollapseItems( { collapseAll, expand } ) {
|
|
14
|
+
const { expandedBlock, getBlockParents } = useSelect( ( select ) => {
|
|
15
|
+
const { getBlockParents: _getBlockParents, getExpandedBlock } = unlock(
|
|
16
|
+
select( blockEditorStore )
|
|
17
|
+
);
|
|
18
|
+
return {
|
|
19
|
+
expandedBlock: getExpandedBlock(),
|
|
20
|
+
getBlockParents: _getBlockParents,
|
|
21
|
+
};
|
|
22
|
+
}, [] );
|
|
23
|
+
|
|
24
|
+
// Collapse all but the specified block when the expanded block client Id changes.
|
|
25
|
+
useEffect( () => {
|
|
26
|
+
if ( expandedBlock ) {
|
|
27
|
+
const blockParents = getBlockParents( expandedBlock, false );
|
|
28
|
+
// Collapse all blocks and expand the block's parents.
|
|
29
|
+
collapseAll();
|
|
30
|
+
expand( blockParents );
|
|
31
|
+
}
|
|
32
|
+
}, [ collapseAll, expand, expandedBlock, getBlockParents ] );
|
|
33
|
+
}
|
|
@@ -7,12 +7,15 @@ import { focus } from '@wordpress/dom';
|
|
|
7
7
|
export const getBlockPositionDescription = ( position, siblingCount, level ) =>
|
|
8
8
|
sprintf(
|
|
9
9
|
/* translators: 1: The numerical position of the block. 2: The total number of blocks. 3. The level of nesting for the block. */
|
|
10
|
-
__( 'Block %1$d of %2$d, Level %3$d' ),
|
|
10
|
+
__( 'Block %1$d of %2$d, Level %3$d.' ),
|
|
11
11
|
position,
|
|
12
12
|
siblingCount,
|
|
13
13
|
level
|
|
14
14
|
);
|
|
15
15
|
|
|
16
|
+
export const getBlockPropertiesDescription = ( isLocked ) =>
|
|
17
|
+
isLocked ? __( 'This block is locked.' ) : '';
|
|
18
|
+
|
|
16
19
|
/**
|
|
17
20
|
* Returns true if the client ID occurs within the block selection or multi-selection,
|
|
18
21
|
* or false otherwise.
|
|
@@ -12,6 +12,10 @@ _Required._ HTML string to make editable. The HTML should be valid, and valid in
|
|
|
12
12
|
|
|
13
13
|
_Required._ Called when the value changes.
|
|
14
14
|
|
|
15
|
+
### `identifier: String`
|
|
16
|
+
|
|
17
|
+
_Optional._ If the editable field is bound to a block attribute (through the `value` and `onChange` props) then this prop should specify the attribute name. The field will use this value to set the block editor selection correctly, specifying in which attribute and at what offset does the selection start or end.
|
|
18
|
+
|
|
15
19
|
### `tagName: String`
|
|
16
20
|
|
|
17
21
|
_Default: `div`._ The [tag name](https://www.w3.org/TR/html51/syntax.html#tag-name) of the editable element.
|
|
@@ -50,6 +54,7 @@ _Optional._ By default, all registered formats are allowed. This setting can be
|
|
|
50
54
|
```js
|
|
51
55
|
<RichText
|
|
52
56
|
tagName="h2"
|
|
57
|
+
identifier="content"
|
|
53
58
|
value={ attributes.content }
|
|
54
59
|
allowedFormats={ [ 'core/bold', 'core/italic' ] } // Allow the content to be made bold or italic, but do not allow othe formatting options
|
|
55
60
|
onChange={ ( content ) => setAttributes( { content } ) }
|
|
@@ -99,6 +104,7 @@ registerBlockType( /* ... */, {
|
|
|
99
104
|
<RichText
|
|
100
105
|
tagName="h2"
|
|
101
106
|
className={ className }
|
|
107
|
+
identifier="content"
|
|
102
108
|
value={ attributes.content }
|
|
103
109
|
onChange={ ( content ) => setAttributes( { content } ) }
|
|
104
110
|
/>
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
createContext,
|
|
14
14
|
} from '@wordpress/element';
|
|
15
15
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
16
|
-
import { useMergeRefs } from '@wordpress/compose';
|
|
16
|
+
import { useMergeRefs, useInstanceId } from '@wordpress/compose';
|
|
17
17
|
import {
|
|
18
18
|
__unstableUseRichText as useRichText,
|
|
19
19
|
removeFormat,
|
|
@@ -52,6 +52,8 @@ import { canBindBlock } from '../../hooks/use-bindings-attributes';
|
|
|
52
52
|
export const keyboardShortcutContext = createContext();
|
|
53
53
|
export const inputEventContext = createContext();
|
|
54
54
|
|
|
55
|
+
const instanceIdKey = Symbol( 'instanceId' );
|
|
56
|
+
|
|
55
57
|
/**
|
|
56
58
|
* Removes props used for the native version of RichText so that they are not
|
|
57
59
|
* passed to the DOM element and log warnings.
|
|
@@ -75,7 +77,6 @@ function removeNativeProps( props ) {
|
|
|
75
77
|
fontStyle,
|
|
76
78
|
minWidth,
|
|
77
79
|
maxWidth,
|
|
78
|
-
setRef,
|
|
79
80
|
disableSuggestions,
|
|
80
81
|
disableAutocorrection,
|
|
81
82
|
...restProps
|
|
@@ -110,13 +111,15 @@ export function RichTextWrapper(
|
|
|
110
111
|
__unstableDisableFormats: disableFormats,
|
|
111
112
|
disableLineBreaks,
|
|
112
113
|
__unstableAllowPrefixTransformations,
|
|
113
|
-
|
|
114
|
+
readOnly,
|
|
114
115
|
...props
|
|
115
116
|
},
|
|
116
117
|
forwardedRef
|
|
117
118
|
) {
|
|
118
119
|
props = removeNativeProps( props );
|
|
119
120
|
|
|
121
|
+
const instanceId = useInstanceId( RichTextWrapper );
|
|
122
|
+
|
|
120
123
|
const anchorRef = useRef();
|
|
121
124
|
const context = useBlockEditContext();
|
|
122
125
|
const { clientId, isSelected: isBlockSelected, name: blockName } = context;
|
|
@@ -139,7 +142,9 @@ export function RichTextWrapper(
|
|
|
139
142
|
isSelected =
|
|
140
143
|
selectionStart.clientId === clientId &&
|
|
141
144
|
selectionEnd.clientId === clientId &&
|
|
142
|
-
|
|
145
|
+
( identifier
|
|
146
|
+
? selectionStart.attributeKey === identifier
|
|
147
|
+
: selectionStart[ instanceIdKey ] === instanceId );
|
|
143
148
|
} else if ( originalIsSelected ) {
|
|
144
149
|
isSelected = selectionStart.clientId === clientId;
|
|
145
150
|
}
|
|
@@ -153,6 +158,7 @@ export function RichTextWrapper(
|
|
|
153
158
|
const { selectionStart, selectionEnd, isSelected } = useSelect( selector, [
|
|
154
159
|
clientId,
|
|
155
160
|
identifier,
|
|
161
|
+
instanceId,
|
|
156
162
|
originalIsSelected,
|
|
157
163
|
isBlockSelected,
|
|
158
164
|
] );
|
|
@@ -196,7 +202,7 @@ export function RichTextWrapper(
|
|
|
196
202
|
[ blockBindings, blockName ]
|
|
197
203
|
);
|
|
198
204
|
|
|
199
|
-
const shouldDisableEditing =
|
|
205
|
+
const shouldDisableEditing = readOnly || disableBoundBlocks;
|
|
200
206
|
|
|
201
207
|
const { getSelectionStart, getSelectionEnd, getBlockRootClientId } =
|
|
202
208
|
useSelect( blockEditorStore );
|
|
@@ -213,6 +219,13 @@ export function RichTextWrapper(
|
|
|
213
219
|
const selection = {};
|
|
214
220
|
const unset = start === undefined && end === undefined;
|
|
215
221
|
|
|
222
|
+
const baseSelection = {
|
|
223
|
+
clientId,
|
|
224
|
+
[ identifier ? 'attributeKey' : instanceIdKey ]: identifier
|
|
225
|
+
? identifier
|
|
226
|
+
: instanceId,
|
|
227
|
+
};
|
|
228
|
+
|
|
216
229
|
if ( typeof start === 'number' || unset ) {
|
|
217
230
|
// If we are only setting the start (or the end below), which
|
|
218
231
|
// means a partial selection, and we're not updating a selection
|
|
@@ -227,8 +240,7 @@ export function RichTextWrapper(
|
|
|
227
240
|
}
|
|
228
241
|
|
|
229
242
|
selection.start = {
|
|
230
|
-
|
|
231
|
-
attributeKey: identifier,
|
|
243
|
+
...baseSelection,
|
|
232
244
|
offset: start,
|
|
233
245
|
};
|
|
234
246
|
}
|
|
@@ -243,15 +255,22 @@ export function RichTextWrapper(
|
|
|
243
255
|
}
|
|
244
256
|
|
|
245
257
|
selection.end = {
|
|
246
|
-
|
|
247
|
-
attributeKey: identifier,
|
|
258
|
+
...baseSelection,
|
|
248
259
|
offset: end,
|
|
249
260
|
};
|
|
250
261
|
}
|
|
251
262
|
|
|
252
263
|
selectionChange( selection );
|
|
253
264
|
},
|
|
254
|
-
[
|
|
265
|
+
[
|
|
266
|
+
clientId,
|
|
267
|
+
getBlockRootClientId,
|
|
268
|
+
getSelectionEnd,
|
|
269
|
+
getSelectionStart,
|
|
270
|
+
identifier,
|
|
271
|
+
instanceId,
|
|
272
|
+
selectionChange,
|
|
273
|
+
]
|
|
255
274
|
);
|
|
256
275
|
|
|
257
276
|
const {
|
|
@@ -466,9 +485,7 @@ PrivateRichText.isEmpty = ( value ) => {
|
|
|
466
485
|
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md
|
|
467
486
|
*/
|
|
468
487
|
const PublicForwardedRichTextContainer = forwardRef( ( props, ref ) => {
|
|
469
|
-
return
|
|
470
|
-
<PrivateRichText ref={ ref } { ...props } disableEditing={ false } />
|
|
471
|
-
);
|
|
488
|
+
return <PrivateRichText ref={ ref } { ...props } readOnly={ false } />;
|
|
472
489
|
} );
|
|
473
490
|
|
|
474
491
|
PublicForwardedRichTextContainer.Content = Content;
|