@wordpress/block-editor 15.11.0 → 15.12.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-breadcrumb/index.cjs +10 -2
- package/build/components/block-breadcrumb/index.cjs.map +2 -2
- package/build/components/block-controls/index.cjs +1 -1
- package/build/components/block-controls/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +8 -21
- package/build/components/block-inspector/index.cjs.map +3 -3
- package/build/components/block-list/block.cjs +6 -3
- package/build/components/block-list/block.cjs.map +3 -3
- package/build/components/block-list/index.cjs +26 -18
- package/build/components/block-list/index.cjs.map +2 -2
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs +39 -19
- package/build/components/block-list/use-block-props/use-selected-block-event-handlers.cjs.map +2 -2
- package/build/components/block-list/use-in-between-inserter.cjs +4 -4
- package/build/components/block-list/use-in-between-inserter.cjs.map +2 -2
- package/build/components/block-settings-menu/block-settings-dropdown.cjs +10 -7
- package/build/components/block-settings-menu/block-settings-dropdown.cjs.map +2 -2
- package/build/components/block-settings-menu-controls/edit-section-menu-item.cjs +1 -1
- package/build/components/block-settings-menu-controls/edit-section-menu-item.cjs.map +2 -2
- package/build/components/block-settings-menu-controls/index.cjs +11 -16
- package/build/components/block-settings-menu-controls/index.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +6 -4
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/block-toolbar/index.cjs +2 -2
- package/build/components/block-toolbar/index.cjs.map +2 -2
- package/build/components/block-tools/index.cjs +2 -26
- package/build/components/block-tools/index.cjs.map +2 -2
- package/build/components/block-variation-transforms/index.cjs +1 -2
- package/build/components/block-variation-transforms/index.cjs.map +2 -2
- package/build/components/block-visibility/index.cjs +7 -9
- package/build/components/block-visibility/index.cjs.map +3 -3
- package/build/components/block-visibility/modal.cjs +18 -103
- package/build/components/block-visibility/modal.cjs.map +2 -2
- package/build/components/block-visibility/use-block-visibility.cjs +1 -1
- package/build/components/block-visibility/use-block-visibility.cjs.map +2 -2
- package/build/components/block-visibility/utils.cjs +5 -1
- package/build/components/block-visibility/utils.cjs.map +2 -2
- package/build/components/block-visibility/viewport-menu-item.cjs +11 -4
- package/build/components/block-visibility/viewport-menu-item.cjs.map +2 -2
- package/build/components/block-visibility/viewport-toolbar.cjs +4 -6
- package/build/components/block-visibility/viewport-toolbar.cjs.map +2 -2
- package/build/components/block-visibility/viewport-visibility-info.cjs +121 -0
- package/build/components/block-visibility/viewport-visibility-info.cjs.map +7 -0
- package/build/components/color-palette/with-color-context.cjs +1 -1
- package/build/components/color-palette/with-color-context.cjs.map +2 -2
- package/build/components/color-style-selector/index.cjs +1 -1
- package/build/components/color-style-selector/index.cjs.map +2 -2
- package/build/components/colors/with-colors.cjs +5 -3
- package/build/components/colors/with-colors.cjs.map +2 -2
- package/build/components/colors-gradients/dropdown.cjs +1 -1
- package/build/components/colors-gradients/dropdown.cjs.map +2 -2
- package/build/components/editable-text/index.cjs +5 -1
- package/build/components/editable-text/index.cjs.map +2 -2
- package/build/components/font-sizes/with-font-sizes.cjs +5 -3
- package/build/components/font-sizes/with-font-sizes.cjs.map +2 -2
- package/build/components/global-styles/advanced-panel.cjs +26 -13
- package/build/components/global-styles/advanced-panel.cjs.map +2 -2
- package/build/components/global-styles/filters-panel.cjs +1 -1
- package/build/components/global-styles/filters-panel.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs +1 -1
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/gradients/with-gradient.cjs +1 -1
- package/build/components/gradients/with-gradient.cjs.map +2 -2
- package/build/components/inserter/index.cjs +1 -0
- package/build/components/inserter/index.cjs.map +2 -2
- package/build/components/inspector-controls/fill.cjs +12 -2
- package/build/components/inspector-controls/fill.cjs.map +2 -2
- package/build/components/inspector-controls/index.cjs +1 -1
- package/build/components/inspector-controls/index.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/index.cjs +3 -3
- package/build/components/inspector-controls-tabs/index.cjs.map +3 -3
- package/build/components/inspector-controls-tabs/styles-tab.cjs +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs +2 -2
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.cjs.map +2 -2
- package/build/components/list-view/block-select-button.cjs +8 -16
- package/build/components/list-view/block-select-button.cjs.map +2 -2
- package/build/components/list-view/block.cjs +29 -34
- package/build/components/list-view/block.cjs.map +3 -3
- package/build/components/list-view/utils.cjs +3 -1
- package/build/components/list-view/utils.cjs.map +2 -2
- package/build/components/media-replace-flow/index.cjs +2 -2
- package/build/components/media-replace-flow/index.cjs.map +2 -2
- package/build/components/provider/index.cjs +7 -8
- package/build/components/provider/index.cjs.map +2 -2
- package/build/components/provider/with-registry-provider.cjs +1 -1
- package/build/components/provider/with-registry-provider.cjs.map +2 -2
- package/build/components/rich-text/index.cjs +1 -1
- package/build/components/rich-text/index.cjs.map +2 -2
- package/build/components/use-block-commands/index.cjs +2 -34
- package/build/components/use-block-commands/index.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +1 -1
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/components/writing-flow/index.cjs +2 -0
- package/build/components/writing-flow/index.cjs.map +2 -2
- package/build/components/writing-flow/use-arrow-nav.cjs +3 -0
- package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
- package/build/components/writing-flow/use-drag-selection.cjs +2 -1
- package/build/components/writing-flow/use-drag-selection.cjs.map +2 -2
- package/build/components/writing-flow/use-preview-mode-nav.cjs +92 -0
- package/build/components/writing-flow/use-preview-mode-nav.cjs.map +7 -0
- package/build/hooks/block-renaming.cjs +1 -1
- package/build/hooks/block-renaming.cjs.map +2 -2
- package/build/hooks/cross-origin-isolation.cjs +1 -1
- package/build/hooks/cross-origin-isolation.cjs.map +2 -2
- package/build/hooks/custom-css.cjs +141 -0
- package/build/hooks/custom-css.cjs.map +7 -0
- package/build/hooks/fit-text.cjs +14 -7
- package/build/hooks/fit-text.cjs.map +2 -2
- package/build/hooks/grid-visualizer.cjs +1 -1
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/index.cjs +4 -2
- package/build/hooks/index.cjs.map +3 -3
- package/build/hooks/layout.cjs +10 -4
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/list-view.cjs +9 -5
- package/build/hooks/list-view.cjs.map +3 -3
- package/build/hooks/utils.cjs +2 -2
- package/build/hooks/utils.cjs.map +2 -2
- package/build/layouts/grid.cjs +12 -1
- package/build/layouts/grid.cjs.map +2 -2
- package/build/store/actions.cjs +5 -0
- package/build/store/actions.cjs.map +2 -2
- package/build/store/defaults.cjs +3 -0
- package/build/store/defaults.cjs.map +2 -2
- package/build/store/private-selectors.cjs +46 -38
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +5 -7
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +15 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/fit-text-utils.cjs +18 -4
- package/build/utils/fit-text-utils.cjs.map +2 -2
- package/build-module/components/block-breadcrumb/index.mjs +10 -2
- package/build-module/components/block-breadcrumb/index.mjs.map +2 -2
- package/build-module/components/block-controls/index.mjs +1 -1
- package/build-module/components/block-controls/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +8 -21
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-list/block.mjs +6 -3
- package/build-module/components/block-list/block.mjs.map +3 -3
- package/build-module/components/block-list/index.mjs +26 -18
- package/build-module/components/block-list/index.mjs.map +2 -2
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs +39 -19
- package/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.mjs.map +2 -2
- package/build-module/components/block-list/use-in-between-inserter.mjs +4 -4
- package/build-module/components/block-list/use-in-between-inserter.mjs.map +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.mjs +10 -7
- package/build-module/components/block-settings-menu/block-settings-dropdown.mjs.map +2 -2
- package/build-module/components/block-settings-menu-controls/edit-section-menu-item.mjs +1 -1
- package/build-module/components/block-settings-menu-controls/edit-section-menu-item.mjs.map +2 -2
- package/build-module/components/block-settings-menu-controls/index.mjs +12 -17
- package/build-module/components/block-settings-menu-controls/index.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +6 -4
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/block-toolbar/index.mjs +3 -3
- package/build-module/components/block-toolbar/index.mjs.map +2 -2
- package/build-module/components/block-tools/index.mjs +2 -26
- package/build-module/components/block-tools/index.mjs.map +2 -2
- package/build-module/components/block-variation-transforms/index.mjs +1 -2
- package/build-module/components/block-variation-transforms/index.mjs.map +2 -2
- package/build-module/components/block-visibility/index.mjs +6 -9
- package/build-module/components/block-visibility/index.mjs.map +2 -2
- package/build-module/components/block-visibility/modal.mjs +18 -103
- package/build-module/components/block-visibility/modal.mjs.map +2 -2
- package/build-module/components/block-visibility/use-block-visibility.mjs +1 -1
- package/build-module/components/block-visibility/use-block-visibility.mjs.map +2 -2
- package/build-module/components/block-visibility/utils.mjs +5 -1
- package/build-module/components/block-visibility/utils.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-menu-item.mjs +11 -4
- package/build-module/components/block-visibility/viewport-menu-item.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-toolbar.mjs +4 -6
- package/build-module/components/block-visibility/viewport-toolbar.mjs.map +2 -2
- package/build-module/components/block-visibility/viewport-visibility-info.mjs +95 -0
- package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +7 -0
- package/build-module/components/color-palette/with-color-context.mjs +1 -1
- package/build-module/components/color-palette/with-color-context.mjs.map +2 -2
- package/build-module/components/color-style-selector/index.mjs +1 -1
- package/build-module/components/color-style-selector/index.mjs.map +2 -2
- package/build-module/components/colors/with-colors.mjs +5 -3
- package/build-module/components/colors/with-colors.mjs.map +2 -2
- package/build-module/components/colors-gradients/dropdown.mjs +1 -1
- package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
- package/build-module/components/editable-text/index.mjs +5 -1
- package/build-module/components/editable-text/index.mjs.map +2 -2
- package/build-module/components/font-sizes/with-font-sizes.mjs +5 -3
- package/build-module/components/font-sizes/with-font-sizes.mjs.map +2 -2
- package/build-module/components/global-styles/advanced-panel.mjs +22 -13
- package/build-module/components/global-styles/advanced-panel.mjs.map +2 -2
- package/build-module/components/global-styles/filters-panel.mjs +1 -1
- package/build-module/components/global-styles/filters-panel.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs +1 -1
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/gradients/with-gradient.mjs +1 -1
- package/build-module/components/gradients/with-gradient.mjs.map +2 -2
- package/build-module/components/inserter/index.mjs +1 -0
- package/build-module/components/inserter/index.mjs.map +2 -2
- package/build-module/components/inspector-controls/fill.mjs +12 -2
- package/build-module/components/inspector-controls/fill.mjs.map +2 -2
- package/build-module/components/inspector-controls/index.mjs +1 -1
- package/build-module/components/inspector-controls/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.mjs +3 -3
- package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs +2 -2
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.mjs.map +2 -2
- package/build-module/components/list-view/block-select-button.mjs +8 -16
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/block.mjs +31 -36
- package/build-module/components/list-view/block.mjs.map +2 -2
- package/build-module/components/list-view/utils.mjs +3 -1
- package/build-module/components/list-view/utils.mjs.map +2 -2
- package/build-module/components/media-replace-flow/index.mjs +2 -2
- package/build-module/components/media-replace-flow/index.mjs.map +2 -2
- package/build-module/components/provider/index.mjs +7 -8
- package/build-module/components/provider/index.mjs.map +2 -2
- package/build-module/components/provider/with-registry-provider.mjs +1 -1
- package/build-module/components/provider/with-registry-provider.mjs.map +2 -2
- package/build-module/components/rich-text/index.mjs +1 -1
- package/build-module/components/rich-text/index.mjs.map +2 -2
- package/build-module/components/use-block-commands/index.mjs +3 -37
- package/build-module/components/use-block-commands/index.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +1 -1
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/components/writing-flow/index.mjs +2 -0
- package/build-module/components/writing-flow/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-arrow-nav.mjs +3 -0
- package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
- package/build-module/components/writing-flow/use-drag-selection.mjs +2 -1
- package/build-module/components/writing-flow/use-drag-selection.mjs.map +2 -2
- package/build-module/components/writing-flow/use-preview-mode-nav.mjs +67 -0
- package/build-module/components/writing-flow/use-preview-mode-nav.mjs.map +7 -0
- package/build-module/hooks/block-renaming.mjs +1 -1
- package/build-module/hooks/block-renaming.mjs.map +2 -2
- package/build-module/hooks/cross-origin-isolation.mjs +1 -1
- package/build-module/hooks/cross-origin-isolation.mjs.map +2 -2
- package/build-module/hooks/custom-css.mjs +112 -0
- package/build-module/hooks/custom-css.mjs.map +7 -0
- package/build-module/hooks/fit-text.mjs +14 -7
- package/build-module/hooks/fit-text.mjs.map +2 -2
- package/build-module/hooks/grid-visualizer.mjs +1 -1
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/index.mjs +4 -2
- package/build-module/hooks/index.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +10 -4
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/list-view.mjs +10 -6
- package/build-module/hooks/list-view.mjs.map +2 -2
- package/build-module/hooks/utils.mjs +2 -2
- package/build-module/hooks/utils.mjs.map +2 -2
- package/build-module/layouts/grid.mjs +12 -1
- package/build-module/layouts/grid.mjs.map +2 -2
- package/build-module/store/actions.mjs +5 -0
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/defaults.mjs +3 -0
- package/build-module/store/defaults.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +43 -41
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +5 -7
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +15 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/fit-text-utils.mjs +18 -4
- package/build-module/utils/fit-text-utils.mjs.map +2 -2
- package/build-style/content-rtl.css +10 -0
- package/build-style/content.css +10 -0
- package/build-style/style-rtl.css +3 -0
- package/build-style/style.css +3 -0
- package/package.json +39 -39
- package/src/components/block-breadcrumb/index.js +6 -1
- package/src/components/block-controls/index.js +1 -1
- package/src/components/block-controls/test/index.js +1 -0
- package/src/components/block-edit/test/edit.js +10 -0
- package/src/components/block-inspector/index.js +15 -36
- package/src/components/block-list/block.js +5 -2
- package/src/components/block-list/content.scss +11 -0
- package/src/components/block-list/index.js +25 -17
- package/src/components/block-list/use-block-props/use-selected-block-event-handlers.js +51 -36
- package/src/components/block-list/use-in-between-inserter.js +8 -6
- package/src/components/block-preview/test/index.js +11 -7
- package/src/components/block-settings-menu/block-settings-dropdown.js +11 -6
- package/src/components/block-settings-menu-controls/edit-section-menu-item.js +1 -7
- package/src/components/block-settings-menu-controls/index.js +16 -18
- package/src/components/block-switcher/test/index.js +2 -0
- package/src/components/block-switcher/test/use-transformed.patterns.js +2 -0
- package/src/components/block-switcher/test/utils.js +2 -0
- package/src/components/block-toolbar/block-toolbar-icon.js +6 -10
- package/src/components/block-toolbar/index.js +3 -9
- package/src/components/block-tools/index.js +2 -29
- package/src/components/block-variation-transforms/index.js +1 -4
- package/src/components/block-visibility/index.js +3 -19
- package/src/components/block-visibility/modal.js +16 -14
- package/src/components/block-visibility/test/use-block-visibility.js +27 -25
- package/src/components/block-visibility/test/utils.js +24 -8
- package/src/components/block-visibility/use-block-visibility.js +1 -4
- package/src/components/block-visibility/utils.js +9 -1
- package/src/components/block-visibility/viewport-menu-item.js +11 -5
- package/src/components/block-visibility/viewport-toolbar.js +5 -6
- package/src/components/block-visibility/viewport-visibility-info.js +131 -0
- package/src/components/color-palette/with-color-context.js +1 -1
- package/src/components/color-style-selector/index.js +2 -3
- package/src/components/colors/with-colors.js +23 -20
- package/src/components/colors-gradients/dropdown.js +2 -3
- package/src/components/editable-text/index.js +5 -1
- package/src/components/font-sizes/with-font-sizes.js +13 -10
- package/src/components/global-styles/advanced-panel.js +35 -16
- package/src/components/global-styles/filters-panel.js +2 -3
- package/src/components/global-styles/shadow-panel-components.js +1 -1
- package/src/components/global-styles/style.scss +9 -5
- package/src/components/gradients/with-gradient.js +7 -4
- package/src/components/inner-blocks/test/index.js +2 -0
- package/src/components/inserter/index.js +1 -0
- package/src/components/inserter/stories/index.story.jsx +31 -24
- package/src/components/inspector-controls/fill.js +25 -5
- package/src/components/inspector-controls/index.js +1 -1
- package/src/components/inspector-controls-tabs/index.js +6 -2
- package/src/components/inspector-controls-tabs/styles-tab.js +7 -8
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -4
- package/src/components/link-control/test/index.js +6 -1
- package/src/components/list-view/block-select-button.js +16 -25
- package/src/components/list-view/block.js +38 -43
- package/src/components/list-view/utils.js +4 -2
- package/src/components/media-replace-flow/index.js +3 -3
- package/src/components/media-replace-flow/test/index.js +13 -11
- package/src/components/provider/index.js +11 -10
- package/src/components/provider/test/use-block-sync.js +1 -0
- package/src/components/provider/with-registry-provider.js +1 -1
- package/src/components/rich-text/index.js +1 -1
- package/src/components/use-block-commands/index.js +0 -41
- package/src/components/use-block-display-information/index.js +1 -5
- package/src/components/writing-flow/index.js +2 -0
- package/src/components/writing-flow/use-arrow-nav.js +5 -0
- package/src/components/writing-flow/use-drag-selection.js +7 -1
- package/src/components/writing-flow/use-preview-mode-nav.js +102 -0
- package/src/hooks/block-renaming.js +5 -2
- package/src/hooks/cross-origin-isolation.js +19 -18
- package/src/hooks/custom-css.js +176 -0
- package/src/hooks/fit-text.js +20 -5
- package/src/hooks/grid-visualizer.js +15 -14
- package/src/hooks/index.js +4 -2
- package/src/hooks/layout.js +55 -43
- package/src/hooks/list-view.js +10 -6
- package/src/hooks/test/align.js +1 -0
- package/src/hooks/test/allowed-blocks.js +8 -0
- package/src/hooks/test/auto-inspector-controls.js +4 -0
- package/src/hooks/test/font-size.js +1 -0
- package/src/hooks/test/metadata.js +4 -0
- package/src/hooks/test/text-align.js +1 -0
- package/src/hooks/utils.js +123 -119
- package/src/layouts/grid.js +19 -3
- package/src/layouts/test/grid.js +1 -1
- package/src/store/actions.js +7 -0
- package/src/store/defaults.js +4 -0
- package/src/store/private-selectors.js +94 -64
- package/src/store/reducer.js +11 -18
- package/src/store/selectors.js +25 -0
- package/src/store/test/actions.js +7 -0
- package/src/store/test/private-selectors.js +116 -119
- package/src/store/test/reducer.js +262 -266
- package/src/store/test/registry-selectors.js +2 -0
- package/src/store/test/selectors.js +19 -0
- package/src/utils/fit-text-utils.js +31 -5
- package/build/components/block-visibility/block-visibility-info.cjs +0 -63
- package/build/components/block-visibility/block-visibility-info.cjs.map +0 -7
- package/build/components/block-visibility/menu-item.cjs +0 -109
- package/build/components/block-visibility/menu-item.cjs.map +0 -7
- package/build/components/block-visibility/toolbar.cjs +0 -92
- package/build/components/block-visibility/toolbar.cjs.map +0 -7
- package/build/components/content-lock/index.cjs +0 -31
- package/build/components/content-lock/index.cjs.map +0 -7
- package/build/components/content-lock/modify-content-lock-menu-item.cjs +0 -70
- package/build/components/content-lock/modify-content-lock-menu-item.cjs.map +0 -7
- package/build/hooks/content-lock-ui.cjs +0 -68
- package/build/hooks/content-lock-ui.cjs.map +0 -7
- package/build-module/components/block-visibility/block-visibility-info.mjs +0 -47
- package/build-module/components/block-visibility/block-visibility-info.mjs.map +0 -7
- package/build-module/components/block-visibility/menu-item.mjs +0 -88
- package/build-module/components/block-visibility/menu-item.mjs.map +0 -7
- package/build-module/components/block-visibility/toolbar.mjs +0 -71
- package/build-module/components/block-visibility/toolbar.mjs.map +0 -7
- package/build-module/components/content-lock/index.mjs +0 -6
- package/build-module/components/content-lock/index.mjs.map +0 -7
- package/build-module/components/content-lock/modify-content-lock-menu-item.mjs +0 -45
- package/build-module/components/content-lock/modify-content-lock-menu-item.mjs.map +0 -7
- package/build-module/hooks/content-lock-ui.mjs +0 -47
- package/build-module/hooks/content-lock-ui.mjs.map +0 -7
- package/src/components/block-visibility/block-visibility-info.js +0 -62
- package/src/components/block-visibility/menu-item.js +0 -96
- package/src/components/block-visibility/toolbar.js +0 -88
- package/src/components/content-lock/index.js +0 -1
- package/src/components/content-lock/modify-content-lock-menu-item.js +0 -67
- package/src/hooks/content-lock-ui.js +0 -76
|
@@ -38,12 +38,6 @@ describe( 'useBlockVisibility', () => {
|
|
|
38
38
|
beforeEach( () => {
|
|
39
39
|
// Reset all mocks before each test
|
|
40
40
|
jest.clearAllMocks();
|
|
41
|
-
// Enable experimental flag
|
|
42
|
-
window.__experimentalHideBlocksBasedOnScreenSize = true;
|
|
43
|
-
} );
|
|
44
|
-
|
|
45
|
-
afterEach( () => {
|
|
46
|
-
delete window.__experimentalHideBlocksBasedOnScreenSize;
|
|
47
41
|
} );
|
|
48
42
|
|
|
49
43
|
describe( 'Device type overrides', () => {
|
|
@@ -52,7 +46,7 @@ describe( 'useBlockVisibility', () => {
|
|
|
52
46
|
|
|
53
47
|
const { result } = renderHook( () =>
|
|
54
48
|
useBlockVisibility( {
|
|
55
|
-
blockVisibility: { mobile: false },
|
|
49
|
+
blockVisibility: { viewport: { mobile: false } },
|
|
56
50
|
deviceType: 'mobile',
|
|
57
51
|
} )
|
|
58
52
|
);
|
|
@@ -66,9 +60,11 @@ describe( 'useBlockVisibility', () => {
|
|
|
66
60
|
const { result } = renderHook( () =>
|
|
67
61
|
useBlockVisibility( {
|
|
68
62
|
blockVisibility: {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
viewport: {
|
|
64
|
+
mobile: true,
|
|
65
|
+
tablet: false,
|
|
66
|
+
desktop: false,
|
|
67
|
+
},
|
|
72
68
|
},
|
|
73
69
|
deviceType: 'mobile',
|
|
74
70
|
} )
|
|
@@ -82,7 +78,7 @@ describe( 'useBlockVisibility', () => {
|
|
|
82
78
|
|
|
83
79
|
const { result } = renderHook( () =>
|
|
84
80
|
useBlockVisibility( {
|
|
85
|
-
blockVisibility: { tablet: false },
|
|
81
|
+
blockVisibility: { viewport: { tablet: false } },
|
|
86
82
|
deviceType: 'tablet',
|
|
87
83
|
} )
|
|
88
84
|
);
|
|
@@ -98,7 +94,7 @@ describe( 'useBlockVisibility', () => {
|
|
|
98
94
|
|
|
99
95
|
const { result } = renderHook( () =>
|
|
100
96
|
useBlockVisibility( {
|
|
101
|
-
blockVisibility: { desktop: false },
|
|
97
|
+
blockVisibility: { viewport: { desktop: false } },
|
|
102
98
|
deviceType: 'desktop',
|
|
103
99
|
} )
|
|
104
100
|
);
|
|
@@ -116,7 +112,7 @@ describe( 'useBlockVisibility', () => {
|
|
|
116
112
|
|
|
117
113
|
const { result } = renderHook( () =>
|
|
118
114
|
useBlockVisibility( {
|
|
119
|
-
blockVisibility: { mobile: false },
|
|
115
|
+
blockVisibility: { viewport: { mobile: false } },
|
|
120
116
|
deviceType: 'desktop',
|
|
121
117
|
} )
|
|
122
118
|
);
|
|
@@ -133,9 +129,11 @@ describe( 'useBlockVisibility', () => {
|
|
|
133
129
|
const { result } = renderHook( () =>
|
|
134
130
|
useBlockVisibility( {
|
|
135
131
|
blockVisibility: {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
132
|
+
viewport: {
|
|
133
|
+
mobile: true,
|
|
134
|
+
tablet: false,
|
|
135
|
+
desktop: false,
|
|
136
|
+
},
|
|
139
137
|
},
|
|
140
138
|
deviceType: 'desktop',
|
|
141
139
|
} )
|
|
@@ -152,7 +150,7 @@ describe( 'useBlockVisibility', () => {
|
|
|
152
150
|
|
|
153
151
|
const { result } = renderHook( () =>
|
|
154
152
|
useBlockVisibility( {
|
|
155
|
-
blockVisibility: { tablet: false },
|
|
153
|
+
blockVisibility: { viewport: { tablet: false } },
|
|
156
154
|
deviceType: 'desktop',
|
|
157
155
|
} )
|
|
158
156
|
);
|
|
@@ -169,9 +167,11 @@ describe( 'useBlockVisibility', () => {
|
|
|
169
167
|
const { result } = renderHook( () =>
|
|
170
168
|
useBlockVisibility( {
|
|
171
169
|
blockVisibility: {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
viewport: {
|
|
171
|
+
mobile: false,
|
|
172
|
+
tablet: true,
|
|
173
|
+
desktop: false,
|
|
174
|
+
},
|
|
175
175
|
},
|
|
176
176
|
deviceType: 'desktop',
|
|
177
177
|
} )
|
|
@@ -188,7 +188,7 @@ describe( 'useBlockVisibility', () => {
|
|
|
188
188
|
|
|
189
189
|
const { result } = renderHook( () =>
|
|
190
190
|
useBlockVisibility( {
|
|
191
|
-
blockVisibility: { desktop: false },
|
|
191
|
+
blockVisibility: { viewport: { desktop: false } },
|
|
192
192
|
deviceType: 'desktop',
|
|
193
193
|
} )
|
|
194
194
|
);
|
|
@@ -205,9 +205,11 @@ describe( 'useBlockVisibility', () => {
|
|
|
205
205
|
const { result } = renderHook( () =>
|
|
206
206
|
useBlockVisibility( {
|
|
207
207
|
blockVisibility: {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
208
|
+
viewport: {
|
|
209
|
+
mobile: false,
|
|
210
|
+
tablet: false,
|
|
211
|
+
desktop: true,
|
|
212
|
+
},
|
|
211
213
|
},
|
|
212
214
|
deviceType: 'desktop',
|
|
213
215
|
} )
|
|
@@ -306,7 +308,7 @@ describe( 'useBlockVisibility', () => {
|
|
|
306
308
|
|
|
307
309
|
const { result } = renderHook( () =>
|
|
308
310
|
useBlockVisibility( {
|
|
309
|
-
blockVisibility: { desktop: false },
|
|
311
|
+
blockVisibility: { viewport: { desktop: false } },
|
|
310
312
|
} )
|
|
311
313
|
);
|
|
312
314
|
|
|
@@ -21,7 +21,9 @@ describe( 'block-visibility utils', () => {
|
|
|
21
21
|
{
|
|
22
22
|
attributes: {
|
|
23
23
|
metadata: {
|
|
24
|
-
blockVisibility: {
|
|
24
|
+
blockVisibility: {
|
|
25
|
+
viewport: {},
|
|
26
|
+
},
|
|
25
27
|
},
|
|
26
28
|
},
|
|
27
29
|
},
|
|
@@ -75,7 +77,9 @@ describe( 'block-visibility utils', () => {
|
|
|
75
77
|
attributes: {
|
|
76
78
|
metadata: {
|
|
77
79
|
blockVisibility: {
|
|
78
|
-
|
|
80
|
+
viewport: {
|
|
81
|
+
mobile: false,
|
|
82
|
+
},
|
|
79
83
|
},
|
|
80
84
|
},
|
|
81
85
|
},
|
|
@@ -83,7 +87,9 @@ describe( 'block-visibility utils', () => {
|
|
|
83
87
|
{
|
|
84
88
|
attributes: {
|
|
85
89
|
metadata: {
|
|
86
|
-
blockVisibility: {
|
|
90
|
+
blockVisibility: {
|
|
91
|
+
viewport: {},
|
|
92
|
+
},
|
|
87
93
|
},
|
|
88
94
|
},
|
|
89
95
|
},
|
|
@@ -105,7 +111,9 @@ describe( 'block-visibility utils', () => {
|
|
|
105
111
|
{
|
|
106
112
|
attributes: {
|
|
107
113
|
metadata: {
|
|
108
|
-
blockVisibility: {
|
|
114
|
+
blockVisibility: {
|
|
115
|
+
viewport: {},
|
|
116
|
+
},
|
|
109
117
|
},
|
|
110
118
|
},
|
|
111
119
|
},
|
|
@@ -122,7 +130,9 @@ describe( 'block-visibility utils', () => {
|
|
|
122
130
|
attributes: {
|
|
123
131
|
metadata: {
|
|
124
132
|
blockVisibility: {
|
|
125
|
-
|
|
133
|
+
viewport: {
|
|
134
|
+
mobile: false,
|
|
135
|
+
},
|
|
126
136
|
},
|
|
127
137
|
},
|
|
128
138
|
},
|
|
@@ -188,7 +198,9 @@ describe( 'block-visibility utils', () => {
|
|
|
188
198
|
{
|
|
189
199
|
attributes: {
|
|
190
200
|
metadata: {
|
|
191
|
-
blockVisibility: {
|
|
201
|
+
blockVisibility: {
|
|
202
|
+
viewport: {},
|
|
203
|
+
},
|
|
192
204
|
},
|
|
193
205
|
},
|
|
194
206
|
},
|
|
@@ -245,7 +257,9 @@ describe( 'block-visibility utils', () => {
|
|
|
245
257
|
attributes: {
|
|
246
258
|
metadata: {
|
|
247
259
|
blockVisibility: {
|
|
248
|
-
|
|
260
|
+
viewport: {
|
|
261
|
+
mobile: false,
|
|
262
|
+
},
|
|
249
263
|
},
|
|
250
264
|
},
|
|
251
265
|
},
|
|
@@ -254,7 +268,9 @@ describe( 'block-visibility utils', () => {
|
|
|
254
268
|
attributes: {
|
|
255
269
|
metadata: {
|
|
256
270
|
blockVisibility: {
|
|
257
|
-
|
|
271
|
+
viewport: {
|
|
272
|
+
tablet: false,
|
|
273
|
+
},
|
|
258
274
|
},
|
|
259
275
|
},
|
|
260
276
|
},
|
|
@@ -53,10 +53,7 @@ export default function useBlockVisibility( options = {} ) {
|
|
|
53
53
|
return true;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
if (
|
|
57
|
-
window.__experimentalHideBlocksBasedOnScreenSize &&
|
|
58
|
-
blockVisibility?.[ currentViewport ] === false
|
|
59
|
-
) {
|
|
56
|
+
if ( blockVisibility?.viewport?.[ currentViewport ] === false ) {
|
|
60
57
|
return true;
|
|
61
58
|
}
|
|
62
59
|
|
|
@@ -27,6 +27,14 @@ function isBlockHiddenForViewport( block, viewport ) {
|
|
|
27
27
|
return false;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
// Get viewport configuration from nested structure.
|
|
31
|
+
const viewportConfig = blockVisibility.viewport;
|
|
32
|
+
|
|
33
|
+
// If no viewport config, block is not hidden for any specific viewport.
|
|
34
|
+
if ( ! viewportConfig || 'object' !== typeof viewportConfig ) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
// Check if the viewport is valid.
|
|
31
39
|
if (
|
|
32
40
|
! BLOCK_VISIBILITY_VIEWPORT_ENTRIES.some(
|
|
@@ -37,7 +45,7 @@ function isBlockHiddenForViewport( block, viewport ) {
|
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
// Check if the specific viewport is hidden.
|
|
40
|
-
return
|
|
48
|
+
return viewportConfig[ viewport ] === false;
|
|
41
49
|
}
|
|
42
50
|
|
|
43
51
|
/**
|
|
@@ -16,11 +16,17 @@ import { unlock } from '../../lock-unlock';
|
|
|
16
16
|
|
|
17
17
|
export default function BlockVisibilityViewportMenuItem( { clientIds } ) {
|
|
18
18
|
const [ isModalOpen, setIsModalOpen ] = useState( false );
|
|
19
|
-
const areBlocksHiddenAnywhere = useSelect(
|
|
20
|
-
( select ) =>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
)
|
|
19
|
+
const { areBlocksHiddenAnywhere } = useSelect(
|
|
20
|
+
( select ) => {
|
|
21
|
+
const { isBlockHiddenAnywhere } = unlock(
|
|
22
|
+
select( blockEditorStore )
|
|
23
|
+
);
|
|
24
|
+
return {
|
|
25
|
+
areBlocksHiddenAnywhere: clientIds?.every( ( clientId ) =>
|
|
26
|
+
isBlockHiddenAnywhere( clientId )
|
|
27
|
+
),
|
|
28
|
+
};
|
|
29
|
+
},
|
|
24
30
|
[ clientIds ]
|
|
25
31
|
);
|
|
26
32
|
return (
|
|
@@ -20,11 +20,8 @@ export default function BlockVisibilityViewportToolbar( { clientIds } ) {
|
|
|
20
20
|
const [ isModalOpen, setIsModalOpen ] = useState( false );
|
|
21
21
|
const { canToggleBlockVisibility, areBlocksHiddenAnywhere } = useSelect(
|
|
22
22
|
( select ) => {
|
|
23
|
-
const {
|
|
24
|
-
|
|
25
|
-
getBlockName,
|
|
26
|
-
areBlocksHiddenAnywhere: _areBlocksHiddenAnywhere,
|
|
27
|
-
} = unlock( select( blockEditorStore ) );
|
|
23
|
+
const { getBlocksByClientId, getBlockName, isBlockHiddenAnywhere } =
|
|
24
|
+
unlock( select( blockEditorStore ) );
|
|
28
25
|
const _blocks = getBlocksByClientId( clientIds );
|
|
29
26
|
return {
|
|
30
27
|
canToggleBlockVisibility: _blocks.every( ( { clientId } ) =>
|
|
@@ -34,7 +31,9 @@ export default function BlockVisibilityViewportToolbar( { clientIds } ) {
|
|
|
34
31
|
true
|
|
35
32
|
)
|
|
36
33
|
),
|
|
37
|
-
areBlocksHiddenAnywhere:
|
|
34
|
+
areBlocksHiddenAnywhere: clientIds?.every( ( clientId ) =>
|
|
35
|
+
isBlockHiddenAnywhere( clientId )
|
|
36
|
+
),
|
|
38
37
|
};
|
|
39
38
|
},
|
|
40
39
|
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
Icon,
|
|
6
|
+
__experimentalText as Text,
|
|
7
|
+
__experimentalHStack as HStack,
|
|
8
|
+
privateApis as componentsPrivateApis,
|
|
9
|
+
} from '@wordpress/components';
|
|
10
|
+
import { useSelect } from '@wordpress/data';
|
|
11
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
12
|
+
import { unseen } from '@wordpress/icons';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
import { unlock } from '../../lock-unlock';
|
|
18
|
+
import { store as blockEditorStore } from '../../store';
|
|
19
|
+
import useBlockVisibility from './use-block-visibility';
|
|
20
|
+
import { deviceTypeKey } from '../../store/private-keys';
|
|
21
|
+
import { BLOCK_VISIBILITY_VIEWPORTS } from './constants';
|
|
22
|
+
|
|
23
|
+
const { Badge } = unlock( componentsPrivateApis );
|
|
24
|
+
const DEFAULT_VISIBILITY_STATE = {
|
|
25
|
+
currentBlockVisibility: undefined,
|
|
26
|
+
hasParentHiddenEverywhere: false,
|
|
27
|
+
selectedDeviceType: BLOCK_VISIBILITY_VIEWPORTS.desktop.value,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default function ViewportVisibilityInfo( { clientId } ) {
|
|
31
|
+
const {
|
|
32
|
+
currentBlockVisibility,
|
|
33
|
+
selectedDeviceType,
|
|
34
|
+
hasParentHiddenEverywhere,
|
|
35
|
+
} = useSelect(
|
|
36
|
+
( select ) => {
|
|
37
|
+
if ( ! clientId ) {
|
|
38
|
+
return DEFAULT_VISIBILITY_STATE;
|
|
39
|
+
}
|
|
40
|
+
const {
|
|
41
|
+
getBlockAttributes,
|
|
42
|
+
isBlockParentHiddenEverywhere,
|
|
43
|
+
getSettings,
|
|
44
|
+
} = unlock( select( blockEditorStore ) );
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
currentBlockVisibility:
|
|
48
|
+
getBlockAttributes( clientId )?.metadata?.blockVisibility,
|
|
49
|
+
selectedDeviceType:
|
|
50
|
+
getSettings()?.[ deviceTypeKey ]?.toLowerCase() ||
|
|
51
|
+
BLOCK_VISIBILITY_VIEWPORTS.desktop.value,
|
|
52
|
+
hasParentHiddenEverywhere:
|
|
53
|
+
isBlockParentHiddenEverywhere( clientId ),
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
[ clientId ]
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
// Use hook to get current viewport and if block is currently hidden (accurate viewport detection)
|
|
60
|
+
const { isBlockCurrentlyHidden, currentViewport } = useBlockVisibility( {
|
|
61
|
+
blockVisibility: currentBlockVisibility,
|
|
62
|
+
deviceType: selectedDeviceType,
|
|
63
|
+
} );
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
* Selector to check if any parent (immediate or further up the chain) is hidden at current viewport.
|
|
67
|
+
* Separated because it depends on currentViewport from the hook above.
|
|
68
|
+
*/
|
|
69
|
+
const isBlockParentHiddenAtViewport = useSelect(
|
|
70
|
+
( select ) => {
|
|
71
|
+
if ( ! clientId || ! currentViewport ) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return unlock(
|
|
75
|
+
select( blockEditorStore )
|
|
76
|
+
).isBlockParentHiddenAtViewport( clientId, currentViewport );
|
|
77
|
+
},
|
|
78
|
+
[ clientId, currentViewport ]
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
if (
|
|
82
|
+
! (
|
|
83
|
+
isBlockCurrentlyHidden ||
|
|
84
|
+
hasParentHiddenEverywhere ||
|
|
85
|
+
isBlockParentHiddenAtViewport
|
|
86
|
+
)
|
|
87
|
+
) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Determine label based on whether block or parent is hidden
|
|
92
|
+
let label;
|
|
93
|
+
if ( isBlockCurrentlyHidden ) {
|
|
94
|
+
// Block is currently hidden - check if hidden everywhere or at specific viewport
|
|
95
|
+
if ( currentBlockVisibility === false ) {
|
|
96
|
+
label = __( 'Block is hidden' );
|
|
97
|
+
} else {
|
|
98
|
+
const viewportLabel =
|
|
99
|
+
BLOCK_VISIBILITY_VIEWPORTS[ currentViewport ]?.label ||
|
|
100
|
+
currentViewport;
|
|
101
|
+
label = sprintf(
|
|
102
|
+
/* translators: %s: viewport name (Desktop, Tablet, Mobile) */
|
|
103
|
+
__( 'Block is hidden on %s' ),
|
|
104
|
+
viewportLabel
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Parent is hidden - check if hidden everywhere or at specific viewport
|
|
110
|
+
if ( hasParentHiddenEverywhere ) {
|
|
111
|
+
label = __( 'Parent block is hidden' );
|
|
112
|
+
} else if ( isBlockParentHiddenAtViewport ) {
|
|
113
|
+
const viewportLabel =
|
|
114
|
+
BLOCK_VISIBILITY_VIEWPORTS[ currentViewport ]?.label ||
|
|
115
|
+
currentViewport;
|
|
116
|
+
label = sprintf(
|
|
117
|
+
/* translators: %s: viewport name (Desktop, Tablet, Mobile) */
|
|
118
|
+
__( 'Parent block is hidden on %s' ),
|
|
119
|
+
viewportLabel
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<Badge className="block-editor-block-visibility-info">
|
|
125
|
+
<HStack spacing={ 2 } justify="start">
|
|
126
|
+
<Icon icon={ unseen } />
|
|
127
|
+
<Text>{ label }</Text>
|
|
128
|
+
</HStack>
|
|
129
|
+
</Badge>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
@@ -9,7 +9,7 @@ import { createHigherOrderComponent } from '@wordpress/compose';
|
|
|
9
9
|
import { useSettings } from '../use-settings';
|
|
10
10
|
|
|
11
11
|
export default createHigherOrderComponent( ( WrappedComponent ) => {
|
|
12
|
-
return ( props )
|
|
12
|
+
return function WithColorContext( props ) {
|
|
13
13
|
// Get the default colors, theme colors, and custom colors
|
|
14
14
|
const [
|
|
15
15
|
defaultColors,
|
|
@@ -49,9 +49,8 @@ const ColorSelectorIcon = ( { style, className } ) => {
|
|
|
49
49
|
*
|
|
50
50
|
* @return {*} React toggle button component.
|
|
51
51
|
*/
|
|
52
|
-
const renderToggleComponent =
|
|
53
|
-
( {
|
|
54
|
-
( { onToggle, isOpen } ) => {
|
|
52
|
+
const renderToggleComponent = ( { TextColor, BackgroundColor } ) =>
|
|
53
|
+
function ToggleComponent( { onToggle, isOpen } ) {
|
|
55
54
|
const openOnArrowDown = ( event ) => {
|
|
56
55
|
if ( ! isOpen && event.keyCode === DOWN ) {
|
|
57
56
|
event.preventDefault();
|
|
@@ -39,9 +39,10 @@ const upperFirst = ( [ firstLetter, ...rest ] ) =>
|
|
|
39
39
|
*/
|
|
40
40
|
const withCustomColorPalette = ( colorsArray ) =>
|
|
41
41
|
createHigherOrderComponent(
|
|
42
|
-
( WrappedComponent ) =>
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
( WrappedComponent ) =>
|
|
43
|
+
function WithCustomColorPalette( props ) {
|
|
44
|
+
return <WrappedComponent { ...props } colors={ colorsArray } />;
|
|
45
|
+
},
|
|
45
46
|
'withCustomColorPalette'
|
|
46
47
|
);
|
|
47
48
|
|
|
@@ -53,22 +54,24 @@ const withCustomColorPalette = ( colorsArray ) =>
|
|
|
53
54
|
*/
|
|
54
55
|
const withEditorColorPalette = () =>
|
|
55
56
|
createHigherOrderComponent(
|
|
56
|
-
( WrappedComponent ) =>
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
57
|
+
( WrappedComponent ) =>
|
|
58
|
+
function WithEditorColorPalette( props ) {
|
|
59
|
+
const [ userPalette, themePalette, defaultPalette ] =
|
|
60
|
+
useSettings(
|
|
61
|
+
'color.palette.custom',
|
|
62
|
+
'color.palette.theme',
|
|
63
|
+
'color.palette.default'
|
|
64
|
+
);
|
|
65
|
+
const allColors = useMemo(
|
|
66
|
+
() => [
|
|
67
|
+
...( userPalette || [] ),
|
|
68
|
+
...( themePalette || [] ),
|
|
69
|
+
...( defaultPalette || [] ),
|
|
70
|
+
],
|
|
71
|
+
[ userPalette, themePalette, defaultPalette ]
|
|
72
|
+
);
|
|
73
|
+
return <WrappedComponent { ...props } colors={ allColors } />;
|
|
74
|
+
},
|
|
72
75
|
'withEditorColorPalette'
|
|
73
76
|
);
|
|
74
77
|
|
|
@@ -94,7 +97,7 @@ function createColorHOC( colorTypes, withColorPalette ) {
|
|
|
94
97
|
return compose( [
|
|
95
98
|
withColorPalette,
|
|
96
99
|
( WrappedComponent ) => {
|
|
97
|
-
return class extends Component {
|
|
100
|
+
return class WithColors extends Component {
|
|
98
101
|
constructor( props ) {
|
|
99
102
|
super( props );
|
|
100
103
|
|
|
@@ -80,9 +80,8 @@ const LabeledColorIndicator = ( { colorValue, label } ) => (
|
|
|
80
80
|
// Renders a color dropdown's toggle as an `Item` if it is within an `ItemGroup`
|
|
81
81
|
// or as a `Button` if it isn't e.g. the controls are being rendered in
|
|
82
82
|
// a `ToolsPanel`.
|
|
83
|
-
const renderToggle =
|
|
84
|
-
(
|
|
85
|
-
( { onToggle, isOpen } ) => {
|
|
83
|
+
const renderToggle = ( settings ) =>
|
|
84
|
+
function Toggle( { onToggle, isOpen } ) {
|
|
86
85
|
const {
|
|
87
86
|
clearable,
|
|
88
87
|
colorValue,
|
|
@@ -12,7 +12,11 @@ const EditableText = forwardRef( ( props, ref ) => {
|
|
|
12
12
|
return <RichText ref={ ref } { ...props } __unstableDisableFormats />;
|
|
13
13
|
} );
|
|
14
14
|
|
|
15
|
-
EditableText.Content = ( {
|
|
15
|
+
EditableText.Content = function Content( {
|
|
16
|
+
value = '',
|
|
17
|
+
tagName: Tag = 'div',
|
|
18
|
+
...props
|
|
19
|
+
} ) {
|
|
16
20
|
return <Tag { ...props }>{ value }</Tag>;
|
|
17
21
|
};
|
|
18
22
|
|
|
@@ -51,19 +51,22 @@ export default ( ...fontSizeNames ) => {
|
|
|
51
51
|
return createHigherOrderComponent(
|
|
52
52
|
compose( [
|
|
53
53
|
createHigherOrderComponent(
|
|
54
|
-
( WrappedComponent ) =>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
( WrappedComponent ) =>
|
|
55
|
+
function WithFontSizesInner( props ) {
|
|
56
|
+
const [ fontSizes ] = useSettings(
|
|
57
|
+
'typography.fontSizes'
|
|
58
|
+
);
|
|
59
|
+
return (
|
|
60
|
+
<WrappedComponent
|
|
61
|
+
{ ...props }
|
|
62
|
+
fontSizes={ fontSizes || DEFAULT_FONT_SIZES }
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
},
|
|
63
66
|
'withFontSizes'
|
|
64
67
|
),
|
|
65
68
|
( WrappedComponent ) => {
|
|
66
|
-
return class extends Component {
|
|
69
|
+
return class WithFontSizes extends Component {
|
|
67
70
|
constructor( props ) {
|
|
68
71
|
super( props );
|
|
69
72
|
|
|
@@ -14,10 +14,26 @@ import { __ } from '@wordpress/i18n';
|
|
|
14
14
|
*/
|
|
15
15
|
import { default as transformStyles } from '../../utils/transform-styles';
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Validates that a CSS string doesn't contain HTML markup.
|
|
19
|
+
* Uses the same validation as the PHP/global styles REST API.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} css The CSS string to validate.
|
|
22
|
+
* @return {boolean} True if the CSS is valid, false otherwise.
|
|
23
|
+
*/
|
|
24
|
+
export function validateCSS( css ) {
|
|
25
|
+
// Check for HTML markup.
|
|
26
|
+
if ( typeof css === 'string' && /<\/?\w/.test( css ) ) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
|
|
17
32
|
export default function AdvancedPanel( {
|
|
18
33
|
value,
|
|
19
34
|
onChange,
|
|
20
35
|
inheritedValue = value,
|
|
36
|
+
help,
|
|
21
37
|
} ) {
|
|
22
38
|
// Custom CSS
|
|
23
39
|
const [ cssError, setCSSError ] = useState( null );
|
|
@@ -27,30 +43,32 @@ export default function AdvancedPanel( {
|
|
|
27
43
|
...value,
|
|
28
44
|
css: newValue,
|
|
29
45
|
} );
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
[ { css: newValue } ],
|
|
36
|
-
'.for-validation-only'
|
|
46
|
+
|
|
47
|
+
// Validate immediately on change for quick feedback.
|
|
48
|
+
if ( ! validateCSS( newValue ) ) {
|
|
49
|
+
setCSSError(
|
|
50
|
+
__( 'The custom CSS is invalid. Do not use <> markup.' )
|
|
37
51
|
);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Clear HTML markup error if CSS is now valid.
|
|
56
|
+
if ( cssError ) {
|
|
57
|
+
setCSSError( null );
|
|
41
58
|
}
|
|
42
59
|
}
|
|
43
60
|
function handleOnBlur( event ) {
|
|
44
|
-
|
|
45
|
-
|
|
61
|
+
const cssValue = event?.target?.value;
|
|
62
|
+
|
|
63
|
+
if ( ! cssValue || ! validateCSS( cssValue ) ) {
|
|
46
64
|
return;
|
|
47
65
|
}
|
|
48
66
|
|
|
49
|
-
// Check if the
|
|
50
|
-
// to ensure that `transformStyles` validates the CSS.
|
|
51
|
-
// wrapping selector here is not used in the actual output of any styles.
|
|
67
|
+
// Check if the value is valid CSS structure on blur (more expensive check).
|
|
68
|
+
// Pass a wrapping selector to ensure that `transformStyles` validates the CSS.
|
|
69
|
+
// Note that the wrapping selector here is not used in the actual output of any styles.
|
|
52
70
|
const [ transformed ] = transformStyles(
|
|
53
|
-
[ { css:
|
|
71
|
+
[ { css: cssValue } ],
|
|
54
72
|
'.for-validation-only'
|
|
55
73
|
);
|
|
56
74
|
|
|
@@ -75,6 +93,7 @@ export default function AdvancedPanel( {
|
|
|
75
93
|
onBlur={ handleOnBlur }
|
|
76
94
|
className="block-editor-global-styles-advanced-panel__custom-css-input"
|
|
77
95
|
spellCheck={ false }
|
|
96
|
+
help={ help }
|
|
78
97
|
/>
|
|
79
98
|
</VStack>
|
|
80
99
|
);
|
|
@@ -118,9 +118,8 @@ const LabeledColorIndicator = ( { indicator, label } ) => (
|
|
|
118
118
|
</HStack>
|
|
119
119
|
);
|
|
120
120
|
|
|
121
|
-
const renderToggle =
|
|
122
|
-
(
|
|
123
|
-
( { onToggle, isOpen } ) => {
|
|
121
|
+
const renderToggle = ( duotone, resetDuotone ) =>
|
|
122
|
+
function Toggle( { onToggle, isOpen } ) {
|
|
124
123
|
const duotoneButtonRef = useRef( undefined );
|
|
125
124
|
|
|
126
125
|
const toggleProps = {
|