@wordpress/block-editor 15.21.1 → 15.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +2 -2
- package/build/components/block-card/index.cjs +4 -5
- package/build/components/block-card/index.cjs.map +2 -2
- package/build/components/block-editing-mode/index.cjs +13 -7
- package/build/components/block-editing-mode/index.cjs.map +2 -2
- package/build/components/block-inspector/index.cjs +35 -20
- package/build/components/block-inspector/index.cjs.map +2 -2
- package/build/components/block-mover/mover-description.cjs +6 -6
- package/build/components/block-mover/mover-description.cjs.map +1 -1
- package/build/components/block-patterns-list/index.cjs.map +2 -2
- package/build/components/block-patterns-paging/index.cjs +4 -4
- package/build/components/block-patterns-paging/index.cjs.map +2 -2
- package/build/components/block-popover/use-popover-scroll.cjs.map +1 -1
- package/build/components/block-quick-navigation/index.cjs +7 -5
- package/build/components/block-quick-navigation/index.cjs.map +2 -2
- package/build/components/block-rename/modal.cjs +0 -1
- package/build/components/block-rename/modal.cjs.map +2 -2
- package/build/components/block-toolbar/block-toolbar-icon.cjs +14 -6
- package/build/components/block-toolbar/block-toolbar-icon.cjs.map +2 -2
- package/build/components/block-toolbar/edit-section-button.cjs.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.cjs +10 -4
- package/build/components/block-tools/use-block-toolbar-popover-props.cjs.map +2 -2
- package/build/components/child-layout-control/index.cjs +51 -19
- package/build/components/child-layout-control/index.cjs.map +2 -2
- package/build/components/colors-gradients/control.cjs +25 -14
- package/build/components/colors-gradients/control.cjs.map +2 -2
- package/build/components/colors-gradients/dropdown.cjs +4 -1
- package/build/components/colors-gradients/dropdown.cjs.map +3 -3
- package/build/components/contrast-checker/index.cjs +22 -4
- package/build/components/contrast-checker/index.cjs.map +2 -2
- package/build/components/date-format-picker/index.cjs +0 -1
- package/build/components/date-format-picker/index.cjs.map +2 -2
- package/build/components/dimensions-tool/index.cjs +4 -5
- package/build/components/dimensions-tool/index.cjs.map +2 -2
- package/build/components/dimensions-tool/scale-tool.cjs +1 -1
- package/build/components/dimensions-tool/scale-tool.cjs.map +2 -2
- package/build/components/global-styles/background-panel.cjs +153 -25
- package/build/components/global-styles/background-panel.cjs.map +3 -3
- package/build/components/global-styles/color-gradient-dropdown-item.cjs +227 -0
- package/build/components/global-styles/color-gradient-dropdown-item.cjs.map +7 -0
- package/build/components/global-styles/color-panel.cjs +98 -375
- package/build/components/global-styles/color-panel.cjs.map +3 -3
- package/build/components/global-styles/dimensions-panel.cjs +1 -4
- package/build/components/global-styles/dimensions-panel.cjs.map +2 -2
- package/build/components/global-styles/hooks.cjs +34 -0
- package/build/components/global-styles/hooks.cjs.map +2 -2
- package/build/components/global-styles/shadow-panel-components.cjs.map +2 -2
- package/build/components/global-styles/typography-panel.cjs +82 -10
- package/build/components/global-styles/typography-panel.cjs.map +3 -3
- package/build/components/grid/grid-item-resizer.cjs.map +1 -1
- package/build/components/grid/grid-visualizer.cjs.map +1 -1
- package/build/components/iframe/index.cjs +6 -3
- package/build/components/iframe/index.cjs.map +3 -3
- package/build/components/image-editor/use-transform-image.cjs.map +1 -1
- package/build/components/inserter/get-appender-label.cjs.map +1 -1
- package/build/components/inserter/media-tab/media-preview.cjs.map +2 -2
- package/build/components/inserter/search-items.cjs.map +1 -1
- package/build/components/inspector-controls/fill.cjs +1 -3
- package/build/components/inspector-controls/fill.cjs.map +2 -2
- package/build/components/inspector-controls/groups.cjs +2 -0
- package/build/components/inspector-controls/groups.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/index.cjs.map +2 -2
- package/build/components/inspector-controls-tabs/styles-tab.cjs +76 -32
- package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
- package/build/components/keyboard-shortcuts/index.cjs.map +1 -1
- package/build/components/line-height-control/index.cjs.map +1 -1
- package/build/components/link-control/index.cjs +2 -3
- package/build/components/link-control/index.cjs.map +2 -2
- package/build/components/link-control/normalize-url.cjs.map +1 -1
- package/build/components/list-view/block-select-button.cjs +1 -10
- package/build/components/list-view/block-select-button.cjs.map +3 -3
- package/build/components/list-view/utils.cjs.map +1 -1
- package/build/components/preset-input-control/custom-value-controls.cjs.map +2 -2
- package/build/components/provider/index.cjs.map +1 -1
- package/build/components/provider/use-block-sync.cjs +3 -1
- package/build/components/provider/use-block-sync.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/before-input-rules.cjs +1 -1
- package/build/components/rich-text/event-listeners/before-input-rules.cjs.map +2 -2
- package/build/components/rich-text/event-listeners/paste-handler.cjs.map +1 -1
- package/build/components/rich-text/prevent-event-discovery.cjs +1 -1
- package/build/components/rich-text/prevent-event-discovery.cjs.map +1 -1
- package/build/components/url-popover/image-url-input-ui.cjs +0 -2
- package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
- package/build/components/use-block-display-information/index.cjs +10 -3
- package/build/components/use-block-display-information/index.cjs.map +2 -2
- package/build/components/writing-flow/use-tab-nav.cjs.map +1 -1
- package/build/hooks/anchor.cjs +1 -2
- package/build/hooks/anchor.cjs.map +2 -2
- package/build/hooks/background.cjs +124 -75
- package/build/hooks/background.cjs.map +3 -3
- package/build/hooks/block-fields/index.cjs +13 -2
- package/build/hooks/block-fields/index.cjs.map +2 -2
- package/build/hooks/color.cjs +0 -162
- package/build/hooks/color.cjs.map +3 -3
- package/build/hooks/contrast-checker.cjs +31 -28
- package/build/hooks/contrast-checker.cjs.map +3 -3
- package/build/hooks/custom-class-name.cjs +0 -1
- package/build/hooks/custom-class-name.cjs.map +2 -2
- package/build/hooks/dimensions.cjs +13 -2
- package/build/hooks/dimensions.cjs.map +2 -2
- package/build/hooks/elements.cjs +142 -0
- package/build/hooks/elements.cjs.map +7 -0
- package/build/hooks/grid-visualizer.cjs +21 -11
- package/build/hooks/grid-visualizer.cjs.map +2 -2
- package/build/hooks/layout-child.cjs +65 -10
- package/build/hooks/layout-child.cjs.map +2 -2
- package/build/hooks/layout.cjs +6 -3
- package/build/hooks/layout.cjs.map +2 -2
- package/build/hooks/list-view.cjs +10 -7
- package/build/hooks/list-view.cjs.map +2 -2
- package/build/hooks/spacing-visualizer.cjs.map +1 -1
- package/build/hooks/state-utils.cjs.map +1 -1
- package/build/hooks/states.cjs +2 -2
- package/build/hooks/states.cjs.map +2 -2
- package/build/hooks/style.cjs +50 -6
- package/build/hooks/style.cjs.map +2 -2
- package/build/hooks/typography.cjs +62 -10
- package/build/hooks/typography.cjs.map +3 -3
- package/build/layouts/flex.cjs +99 -6
- package/build/layouts/flex.cjs.map +2 -2
- package/build/private-apis.cjs +4 -0
- package/build/private-apis.cjs.map +2 -2
- package/build/store/actions.cjs.map +1 -1
- package/build/store/private-selectors.cjs +19 -2
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs.map +1 -1
- package/build/store/selectors.cjs.map +1 -1
- package/build/utils/block-bindings.cjs +9 -9
- package/build/utils/block-bindings.cjs.map +3 -3
- package/build/utils/color-values.cjs +10 -1
- package/build/utils/color-values.cjs.map +3 -3
- package/build/utils/dom.cjs +2 -5
- package/build/utils/dom.cjs.map +3 -3
- package/build/utils/fit-text-frontend.cjs +6 -2
- package/build/utils/fit-text-frontend.cjs.map +3 -3
- package/build/utils/fit-text-utils.cjs +1 -1
- package/build/utils/fit-text-utils.cjs.map +3 -3
- package/build/utils/format-font-style.cjs +1 -1
- package/build/utils/format-font-style.cjs.map +3 -3
- package/build/utils/format-font-weight.cjs +1 -1
- package/build/utils/format-font-weight.cjs.map +3 -3
- package/build/utils/get-editor-region.cjs +4 -2
- package/build/utils/get-editor-region.cjs.map +3 -3
- package/build/utils/get-font-styles-and-weights.cjs +8 -12
- package/build/utils/get-font-styles-and-weights.cjs.map +3 -3
- package/build/utils/get-px-from-css-unit.cjs +1 -1
- package/build/utils/get-px-from-css-unit.cjs.map +1 -1
- package/build/utils/index.cjs +1 -1
- package/build/utils/index.cjs.map +1 -1
- package/build/utils/math.cjs +1 -1
- package/build/utils/math.cjs.map +3 -3
- package/build/utils/object.cjs +8 -8
- package/build/utils/object.cjs.map +3 -3
- package/build/utils/order-inserter-block-items.cjs +1 -1
- package/build/utils/order-inserter-block-items.cjs.map +3 -3
- package/build/utils/pasting.cjs +4 -2
- package/build/utils/pasting.cjs.map +3 -3
- package/build/utils/selection.cjs +3 -2
- package/build/utils/selection.cjs.map +3 -3
- package/build/utils/sorting.cjs +9 -3
- package/build/utils/sorting.cjs.map +3 -3
- package/build/utils/transform-styles/index.cjs +3 -2
- package/build/utils/transform-styles/index.cjs.map +3 -3
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs +2 -0
- package/build/utils/transform-styles/postcss-urlrebase.d.cjs.map +7 -0
- package/build/utils/transform-styles/types.cjs +19 -0
- package/build/utils/transform-styles/types.cjs.map +7 -0
- package/build/utils/types.cjs +19 -0
- package/build/utils/types.cjs.map +7 -0
- package/build-module/components/block-card/index.mjs +5 -6
- package/build-module/components/block-card/index.mjs.map +2 -2
- package/build-module/components/block-editing-mode/index.mjs +14 -8
- package/build-module/components/block-editing-mode/index.mjs.map +2 -2
- package/build-module/components/block-inspector/index.mjs +35 -21
- package/build-module/components/block-inspector/index.mjs.map +2 -2
- package/build-module/components/block-mover/mover-description.mjs +6 -6
- package/build-module/components/block-mover/mover-description.mjs.map +1 -1
- package/build-module/components/block-patterns-list/index.mjs.map +2 -2
- package/build-module/components/block-patterns-paging/index.mjs +4 -4
- package/build-module/components/block-patterns-paging/index.mjs.map +2 -2
- package/build-module/components/block-popover/use-popover-scroll.mjs.map +1 -1
- package/build-module/components/block-quick-navigation/index.mjs +8 -6
- package/build-module/components/block-quick-navigation/index.mjs.map +2 -2
- package/build-module/components/block-rename/modal.mjs +0 -1
- package/build-module/components/block-rename/modal.mjs.map +2 -2
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs +14 -6
- package/build-module/components/block-toolbar/block-toolbar-icon.mjs.map +2 -2
- package/build-module/components/block-toolbar/edit-section-button.mjs.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs +10 -4
- package/build-module/components/block-tools/use-block-toolbar-popover-props.mjs.map +2 -2
- package/build-module/components/child-layout-control/index.mjs +51 -19
- package/build-module/components/child-layout-control/index.mjs.map +2 -2
- package/build-module/components/colors-gradients/control.mjs +27 -15
- package/build-module/components/colors-gradients/control.mjs.map +2 -2
- package/build-module/components/colors-gradients/dropdown.mjs +4 -1
- package/build-module/components/colors-gradients/dropdown.mjs.map +2 -2
- package/build-module/components/contrast-checker/index.mjs +18 -4
- package/build-module/components/contrast-checker/index.mjs.map +2 -2
- package/build-module/components/date-format-picker/index.mjs +0 -1
- package/build-module/components/date-format-picker/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/index.mjs +4 -5
- package/build-module/components/dimensions-tool/index.mjs.map +2 -2
- package/build-module/components/dimensions-tool/scale-tool.mjs +1 -1
- package/build-module/components/dimensions-tool/scale-tool.mjs.map +2 -2
- package/build-module/components/global-styles/background-panel.mjs +155 -27
- package/build-module/components/global-styles/background-panel.mjs.map +2 -2
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs +207 -0
- package/build-module/components/global-styles/color-gradient-dropdown-item.mjs.map +7 -0
- package/build-module/components/global-styles/color-panel.mjs +106 -387
- package/build-module/components/global-styles/color-panel.mjs.map +3 -3
- package/build-module/components/global-styles/dimensions-panel.mjs +1 -5
- package/build-module/components/global-styles/dimensions-panel.mjs.map +2 -2
- package/build-module/components/global-styles/hooks.mjs +33 -0
- package/build-module/components/global-styles/hooks.mjs.map +2 -2
- package/build-module/components/global-styles/shadow-panel-components.mjs.map +2 -2
- package/build-module/components/global-styles/typography-panel.mjs +84 -10
- package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
- package/build-module/components/grid/grid-item-resizer.mjs.map +1 -1
- package/build-module/components/grid/grid-visualizer.mjs.map +1 -1
- package/build-module/components/iframe/index.mjs +6 -3
- package/build-module/components/iframe/index.mjs.map +2 -2
- package/build-module/components/image-editor/use-transform-image.mjs.map +1 -1
- package/build-module/components/inserter/get-appender-label.mjs.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.mjs.map +2 -2
- package/build-module/components/inserter/search-items.mjs.map +1 -1
- package/build-module/components/inspector-controls/fill.mjs +1 -3
- package/build-module/components/inspector-controls/fill.mjs.map +2 -2
- package/build-module/components/inspector-controls/groups.mjs +2 -0
- package/build-module/components/inspector-controls/groups.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/index.mjs.map +2 -2
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs +76 -32
- package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
- package/build-module/components/keyboard-shortcuts/index.mjs.map +1 -1
- package/build-module/components/line-height-control/index.mjs.map +1 -1
- package/build-module/components/link-control/index.mjs +2 -3
- package/build-module/components/link-control/index.mjs.map +2 -2
- package/build-module/components/link-control/normalize-url.mjs.map +1 -1
- package/build-module/components/list-view/block-select-button.mjs +2 -17
- package/build-module/components/list-view/block-select-button.mjs.map +2 -2
- package/build-module/components/list-view/utils.mjs.map +1 -1
- package/build-module/components/preset-input-control/custom-value-controls.mjs.map +2 -2
- package/build-module/components/provider/index.mjs.map +1 -1
- package/build-module/components/provider/use-block-sync.mjs +3 -1
- package/build-module/components/provider/use-block-sync.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs +1 -1
- package/build-module/components/rich-text/event-listeners/before-input-rules.mjs.map +2 -2
- package/build-module/components/rich-text/event-listeners/paste-handler.mjs.map +1 -1
- package/build-module/components/rich-text/prevent-event-discovery.mjs +1 -1
- package/build-module/components/rich-text/prevent-event-discovery.mjs.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.mjs +0 -2
- package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
- package/build-module/components/use-block-display-information/index.mjs +10 -3
- package/build-module/components/use-block-display-information/index.mjs.map +2 -2
- package/build-module/components/writing-flow/use-tab-nav.mjs.map +1 -1
- package/build-module/hooks/anchor.mjs +1 -2
- package/build-module/hooks/anchor.mjs.map +2 -2
- package/build-module/hooks/background.mjs +123 -75
- package/build-module/hooks/background.mjs.map +2 -2
- package/build-module/hooks/block-fields/index.mjs +13 -2
- package/build-module/hooks/block-fields/index.mjs.map +2 -2
- package/build-module/hooks/color.mjs +2 -175
- package/build-module/hooks/color.mjs.map +2 -2
- package/build-module/hooks/contrast-checker.mjs +32 -19
- package/build-module/hooks/contrast-checker.mjs.map +2 -2
- package/build-module/hooks/custom-class-name.mjs +0 -1
- package/build-module/hooks/custom-class-name.mjs.map +2 -2
- package/build-module/hooks/dimensions.mjs +12 -2
- package/build-module/hooks/dimensions.mjs.map +2 -2
- package/build-module/hooks/elements.mjs +115 -0
- package/build-module/hooks/elements.mjs.map +7 -0
- package/build-module/hooks/grid-visualizer.mjs +21 -11
- package/build-module/hooks/grid-visualizer.mjs.map +2 -2
- package/build-module/hooks/layout-child.mjs +68 -10
- package/build-module/hooks/layout-child.mjs.map +2 -2
- package/build-module/hooks/layout.mjs +6 -3
- package/build-module/hooks/layout.mjs.map +2 -2
- package/build-module/hooks/list-view.mjs +10 -7
- package/build-module/hooks/list-view.mjs.map +2 -2
- package/build-module/hooks/spacing-visualizer.mjs.map +1 -1
- package/build-module/hooks/state-utils.mjs.map +1 -1
- package/build-module/hooks/states.mjs +2 -2
- package/build-module/hooks/states.mjs.map +2 -2
- package/build-module/hooks/style.mjs +53 -8
- package/build-module/hooks/style.mjs.map +2 -2
- package/build-module/hooks/typography.mjs +62 -10
- package/build-module/hooks/typography.mjs.map +2 -2
- package/build-module/layouts/flex.mjs +105 -7
- package/build-module/layouts/flex.mjs.map +2 -2
- package/build-module/private-apis.mjs +8 -0
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/store/actions.mjs.map +1 -1
- package/build-module/store/private-selectors.mjs +18 -1
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs.map +1 -1
- package/build-module/store/selectors.mjs.map +1 -1
- package/build-module/utils/block-bindings.mjs +9 -9
- package/build-module/utils/block-bindings.mjs.map +3 -3
- package/build-module/utils/color-values.mjs +9 -1
- package/build-module/utils/color-values.mjs.map +3 -3
- package/build-module/utils/dom.mjs +2 -5
- package/build-module/utils/dom.mjs.map +3 -3
- package/build-module/utils/fit-text-frontend.mjs +6 -2
- package/build-module/utils/fit-text-frontend.mjs.map +3 -3
- package/build-module/utils/fit-text-utils.mjs +1 -1
- package/build-module/utils/fit-text-utils.mjs.map +3 -3
- package/build-module/utils/format-font-style.mjs +1 -1
- package/build-module/utils/format-font-style.mjs.map +3 -3
- package/build-module/utils/format-font-weight.mjs +1 -1
- package/build-module/utils/format-font-weight.mjs.map +3 -3
- package/build-module/utils/get-editor-region.mjs +4 -2
- package/build-module/utils/get-editor-region.mjs.map +3 -3
- package/build-module/utils/get-font-styles-and-weights.mjs +8 -12
- package/build-module/utils/get-font-styles-and-weights.mjs.map +3 -3
- package/build-module/utils/get-px-from-css-unit.mjs +1 -1
- package/build-module/utils/get-px-from-css-unit.mjs.map +1 -1
- package/build-module/utils/index.mjs +1 -1
- package/build-module/utils/index.mjs.map +1 -1
- package/build-module/utils/math.mjs +1 -1
- package/build-module/utils/math.mjs.map +3 -3
- package/build-module/utils/object.mjs +8 -8
- package/build-module/utils/object.mjs.map +3 -3
- package/build-module/utils/order-inserter-block-items.mjs +1 -1
- package/build-module/utils/order-inserter-block-items.mjs.map +3 -3
- package/build-module/utils/pasting.mjs +4 -2
- package/build-module/utils/pasting.mjs.map +3 -3
- package/build-module/utils/selection.mjs +3 -2
- package/build-module/utils/selection.mjs.map +3 -3
- package/build-module/utils/sorting.mjs +9 -3
- package/build-module/utils/sorting.mjs.map +3 -3
- package/build-module/utils/transform-styles/index.mjs +3 -2
- package/build-module/utils/transform-styles/index.mjs.map +3 -3
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs +1 -0
- package/build-module/utils/transform-styles/postcss-urlrebase.d.mjs.map +7 -0
- package/build-module/utils/transform-styles/types.mjs +1 -0
- package/build-module/utils/transform-styles/types.mjs.map +7 -0
- package/build-module/utils/types.mjs +1 -0
- package/build-module/utils/types.mjs.map +7 -0
- package/build-style/content-rtl.css +2 -0
- package/build-style/content.css +2 -0
- package/build-style/style-rtl.css +34 -41
- package/build-style/style.css +34 -41
- package/build-types/utils/block-bindings.d.ts +27 -0
- package/build-types/utils/block-bindings.d.ts.map +1 -0
- package/build-types/utils/color-values.d.ts +40 -0
- package/build-types/utils/color-values.d.ts.map +1 -0
- package/build-types/utils/dom.d.ts +19 -19
- package/build-types/utils/dom.d.ts.map +1 -1
- package/build-types/utils/fit-text-frontend.d.ts +7 -0
- package/build-types/utils/fit-text-frontend.d.ts.map +1 -0
- package/build-types/utils/fit-text-utils.d.ts +15 -0
- package/build-types/utils/fit-text-utils.d.ts.map +1 -0
- package/build-types/utils/format-font-style.d.ts +12 -0
- package/build-types/utils/format-font-style.d.ts.map +1 -0
- package/build-types/utils/format-font-weight.d.ts +12 -0
- package/build-types/utils/format-font-weight.d.ts.map +1 -0
- package/build-types/utils/get-editor-region.d.ts +9 -0
- package/build-types/utils/get-editor-region.d.ts.map +1 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts +16 -0
- package/build-types/utils/get-font-styles-and-weights.d.ts.map +1 -0
- package/build-types/utils/get-px-from-css-unit.d.ts +10 -0
- package/build-types/utils/get-px-from-css-unit.d.ts.map +1 -0
- package/build-types/utils/index.d.ts +3 -0
- package/build-types/utils/index.d.ts.map +1 -0
- package/build-types/utils/math.d.ts +61 -0
- package/build-types/utils/math.d.ts.map +1 -0
- package/build-types/utils/object.d.ts +39 -0
- package/build-types/utils/object.d.ts.map +1 -0
- package/build-types/utils/order-inserter-block-items.d.ts +13 -0
- package/build-types/utils/order-inserter-block-items.d.ts.map +1 -0
- package/build-types/utils/pasting.d.ts +28 -0
- package/build-types/utils/pasting.d.ts.map +1 -0
- package/build-types/utils/selection.d.ts +21 -0
- package/build-types/utils/selection.d.ts.map +1 -0
- package/build-types/utils/sorting.d.ts +17 -0
- package/build-types/utils/sorting.d.ts.map +1 -0
- package/build-types/utils/transform-styles/index.d.ts +15 -0
- package/build-types/utils/transform-styles/index.d.ts.map +1 -0
- package/build-types/utils/transform-styles/types.d.ts +13 -0
- package/build-types/utils/transform-styles/types.d.ts.map +1 -0
- package/build-types/utils/types.d.ts +28 -0
- package/build-types/utils/types.d.ts.map +1 -0
- package/package.json +46 -40
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +6 -0
- package/src/components/block-alignment-control/test/__snapshots__/index.js.snap +5 -0
- package/src/components/block-card/index.js +7 -13
- package/src/components/block-editing-mode/index.js +17 -9
- package/src/components/block-icon/test/__snapshots__/index.js.snap +1 -0
- package/src/components/block-inspector/index.js +22 -20
- package/src/components/block-patterns-list/index.js +0 -1
- package/src/components/block-quick-navigation/index.js +7 -7
- package/src/components/block-rename/modal.js +0 -1
- package/src/components/block-toolbar/block-toolbar-icon.js +22 -6
- package/src/components/block-toolbar/test/block-toolbar-icon.js +99 -0
- package/src/components/block-tools/use-block-toolbar-popover-props.js +10 -4
- package/src/components/block-vertical-alignment-control/test/__snapshots__/index.js.snap +4 -0
- package/src/components/child-layout-control/index.js +65 -20
- package/src/components/child-layout-control/test/index.js +64 -0
- package/src/components/colors-gradients/control.js +29 -12
- package/src/components/colors-gradients/dropdown.js +4 -1
- package/src/components/colors-gradients/style.scss +39 -2
- package/src/components/contrast-checker/README.md +9 -0
- package/src/components/contrast-checker/index.js +42 -3
- package/src/components/date-format-picker/index.js +0 -1
- package/src/components/default-block-appender/content.scss +3 -0
- package/src/components/dimensions-tool/index.js +4 -9
- package/src/components/dimensions-tool/scale-tool.js +1 -2
- package/src/components/dimensions-tool/test/index.js +89 -11
- package/src/components/global-styles/background-panel.js +201 -34
- package/src/components/global-styles/color-gradient-dropdown-item.js +258 -0
- package/src/components/global-styles/color-panel.js +125 -487
- package/src/components/global-styles/dimensions-panel.js +1 -5
- package/src/components/global-styles/hooks.js +45 -0
- package/src/components/global-styles/shadow-panel-components.js +0 -1
- package/src/components/global-styles/test/background-panel.js +56 -0
- package/src/components/global-styles/test/color-panel.js +172 -118
- package/src/components/global-styles/test/typography-panel.js +167 -0
- package/src/components/global-styles/typography-panel.js +100 -11
- package/src/components/iframe/index.js +8 -3
- package/src/components/inserter/media-tab/media-preview.js +0 -1
- package/src/components/inspector-controls/README.md +0 -2
- package/src/components/inspector-controls/fill.js +6 -8
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/index.js +0 -1
- package/src/components/inspector-controls-tabs/styles-tab.js +78 -28
- package/src/components/link-control/index.js +0 -1
- package/src/components/link-control/test/index.js +2 -3
- package/src/components/list-view/block-select-button.js +2 -18
- package/src/components/preset-input-control/custom-value-controls.js +0 -1
- package/src/components/provider/use-block-sync.js +3 -1
- package/src/components/rich-text/content.scss +2 -0
- package/src/components/url-popover/image-url-input-ui.js +0 -2
- package/src/components/use-block-display-information/index.js +15 -2
- package/src/components/use-block-display-information/test/index.js +140 -0
- package/src/hooks/anchor.js +0 -1
- package/src/hooks/background.js +210 -133
- package/src/hooks/background.scss +0 -35
- package/src/hooks/block-fields/index.js +27 -2
- package/src/hooks/color.js +2 -205
- package/src/hooks/color.scss +3 -9
- package/src/hooks/contrast-checker.js +60 -17
- package/src/hooks/custom-class-name.js +0 -1
- package/src/hooks/dimensions.js +14 -3
- package/src/hooks/elements.js +140 -0
- package/src/hooks/elements.scss +8 -0
- package/src/hooks/grid-visualizer.js +59 -45
- package/src/hooks/layout-child.js +92 -14
- package/src/hooks/layout.js +6 -3
- package/src/hooks/list-view.js +10 -11
- package/src/hooks/states.js +2 -2
- package/src/hooks/style.js +91 -9
- package/src/hooks/test/background.js +59 -0
- package/src/hooks/test/block-style-state.js +14 -14
- package/src/hooks/test/dimensions.js +71 -0
- package/src/hooks/test/layout-child.js +165 -0
- package/src/hooks/test/layout.js +6 -6
- package/src/hooks/test/style.js +133 -11
- package/src/hooks/typography.js +70 -6
- package/src/layouts/flex.js +118 -15
- package/src/private-apis.js +8 -0
- package/src/store/private-selectors.js +47 -0
- package/src/store/test/private-selectors.js +166 -7
- package/src/store/test/reducer.js +61 -10
- package/src/style.scss +1 -0
- package/src/utils/block-bindings.ts +51 -0
- package/src/utils/color-values.ts +63 -0
- package/src/utils/{dom.js → dom.ts} +27 -27
- package/src/utils/{fit-text-frontend.js → fit-text-frontend.ts} +12 -4
- package/src/utils/{fit-text-utils.js → fit-text-utils.ts} +15 -7
- package/src/utils/{format-font-style.js → format-font-style.ts} +10 -3
- package/src/utils/{format-font-weight.js → format-font-weight.ts} +10 -3
- package/src/utils/{get-editor-region.js → get-editor-region.ts} +10 -6
- package/src/utils/{get-font-styles-and-weights.js → get-font-styles-and-weights.ts} +21 -17
- package/src/utils/{math.js → math.ts} +37 -30
- package/src/utils/object.ts +89 -0
- package/src/utils/{order-inserter-block-items.js → order-inserter-block-items.ts} +8 -5
- package/src/utils/{pasting.js → pasting.ts} +18 -11
- package/src/utils/{selection.js → selection.ts} +11 -4
- package/src/utils/sorting.ts +81 -0
- package/src/utils/test/color-values.js +44 -1
- package/src/utils/transform-styles/{index.js → index.ts} +25 -25
- package/src/utils/transform-styles/postcss-urlrebase.d.ts +15 -0
- package/src/utils/transform-styles/types.ts +13 -0
- package/src/utils/types.ts +29 -0
- package/src/utils/block-bindings.js +0 -46
- package/src/utils/color-values.js +0 -28
- package/src/utils/object.js +0 -67
- package/src/utils/sorting.js +0 -54
- /package/src/utils/{get-px-from-css-unit.js → get-px-from-css-unit.ts} +0 -0
- /package/src/utils/{index.js → index.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/contrast-checker.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useReducer } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { getBlockSelector } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["blocksStore"
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useEffect, useLayoutEffect, useReducer } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { getBlockSelector } from '@wordpress/global-styles-engine';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport { getContrastWarning } from '../components/contrast-checker';\n\nimport { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';\n\nfunction getComputedValue( node, property ) {\n\treturn node.ownerDocument.defaultView\n\t\t.getComputedStyle( node )\n\t\t.getPropertyValue( property );\n}\n\nfunction getBlockElementColors( blockEl, blockType ) {\n\tif ( ! blockEl || ! blockType ) {\n\t\treturn {};\n\t}\n\n\t// Get color-specific selectors.\n\tconst textSelector = getBlockSelector( blockType, 'color.text', {\n\t\tfallback: true,\n\t} );\n\tconst backgroundSelector = getBlockSelector(\n\t\tblockType,\n\t\t'color.background',\n\t\t{ fallback: true }\n\t);\n\n\t// Find target elements - querySelector handles all the complexity\n\tconst textElement = blockEl.querySelector( textSelector ) || blockEl;\n\tconst backgroundElement =\n\t\tblockEl.querySelector( backgroundSelector ) || blockEl;\n\tconst linkElement = blockEl.querySelector( 'a' );\n\n\t// Get computed colors from the appropriate elements\n\tconst textColor = getComputedValue( textElement, 'color' );\n\tconst linkColor =\n\t\tlinkElement && linkElement.textContent\n\t\t\t? getComputedValue( linkElement, 'color' )\n\t\t\t: undefined;\n\n\tlet backgroundColorNode = backgroundElement;\n\tlet backgroundColor = getComputedValue(\n\t\tbackgroundColorNode,\n\t\t'background-color'\n\t);\n\twhile (\n\t\tbackgroundColor === 'rgba(0, 0, 0, 0)' &&\n\t\tbackgroundColorNode.parentNode &&\n\t\tbackgroundColorNode.parentNode.nodeType ===\n\t\t\tbackgroundColorNode.parentNode.ELEMENT_NODE\n\t) {\n\t\tbackgroundColorNode = backgroundColorNode.parentNode;\n\t\tbackgroundColor = getComputedValue(\n\t\t\tbackgroundColorNode,\n\t\t\t'background-color'\n\t\t);\n\t}\n\n\treturn {\n\t\ttextColor,\n\t\tbackgroundColor,\n\t\tlinkColor,\n\t};\n}\n\nfunction reducer( prevColors, newColors ) {\n\tconst hasChanged = Object.keys( newColors ).some(\n\t\t( key ) => prevColors[ key ] !== newColors[ key ]\n\t);\n\n\t// Do not re-render if the colors have not changed.\n\treturn hasChanged ? newColors : prevColors;\n}\n\n/**\n * Returns a contrast warning message for a block's computed colors, or\n * `undefined` when contrast is sufficient or checking is disabled.\n *\n * Colors are read from the rendered block element so that inherited values\n * (e.g. from Global Styles or ancestor blocks) are taken into account.\n *\n * @param {Object} props\n * @param {string} props.clientId Block client ID.\n * @param {string} props.name Block name.\n * @param {boolean} [props.enabled] Whether contrast checking is active.\n * @param {boolean} [props.checkTextColor] Whether to evaluate the text/background pair.\n * @param {boolean} [props.checkLinkColor] Whether to evaluate the link/background pair.\n * @param {string} [props.messageOverride] Caller-provided copy used in place of the generic guidance.\n *\n * @return {?string} The warning message, if any.\n */\nexport default function useBlockColorContrastWarning( {\n\tclientId,\n\tname,\n\tenabled = true,\n\tcheckTextColor = true,\n\tcheckLinkColor = true,\n\tmessageOverride,\n} ) {\n\tconst blockEl = useBlockElement( clientId );\n\tconst [ colors, setColors ] = useReducer( reducer, {} );\n\n\tconst blockType = useSelect(\n\t\t( select ) => {\n\t\t\treturn name && enabled\n\t\t\t\t? select( blocksStore ).getBlockType( name )\n\t\t\t\t: undefined;\n\t\t},\n\t\t[ name, enabled ]\n\t);\n\n\t// There are so many things that can change the color of a block\n\t// So we perform this check on every render.\n\tuseLayoutEffect( () => {\n\t\tif ( ! enabled || ! blockEl || ! blockType ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Combine `useLayoutEffect` and two rAF calls to ensure that values are read\n\t\t// after the current paint but before the next paint.\n\t\twindow.requestAnimationFrame( () =>\n\t\t\twindow.requestAnimationFrame( () =>\n\t\t\t\tsetColors( getBlockElementColors( blockEl, blockType ) )\n\t\t\t)\n\t\t);\n\t} );\n\n\t// Runs in its own effect with dependencies so the observer is only\n\t// recreated when the block element or block type changes.\n\tuseLayoutEffect( () => {\n\t\tif ( ! enabled || ! blockEl || ! blockType ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst observer = new window.MutationObserver( () => {\n\t\t\tsetColors( getBlockElementColors( blockEl, blockType ) );\n\t\t} );\n\n\t\tobserver.observe( blockEl, {\n\t\t\tattributes: true,\n\t\t\tattributeFilter: [ 'class', 'style' ],\n\t\t\tsubtree: true,\n\t\t} );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ enabled, blockEl, blockType ] );\n\n\tconst warning = enabled\n\t\t? getContrastWarning( {\n\t\t\t\tbackgroundColor: colors.backgroundColor,\n\t\t\t\ttextColor: checkTextColor ? colors.textColor : undefined,\n\t\t\t\tlinkColor: checkLinkColor ? colors.linkColor : undefined,\n\t\t\t\tmessageOverride,\n\t\t\t\tenableAlphaChecker: true,\n\t\t } )\n\t\t: null;\n\n\t// The popover Notice that displays this warning is muted\n\t// (`spokenMessage={ null }`), so this hook is the single source of the\n\t// spoken announcement. Announce only when the warning message itself\n\t// appears or changes; keying off `speakMessage` rather than the raw\n\t// computed `colors` avoids re-announcing the same warning when colors\n\t// recompute without changing the outcome.\n\tconst speakMessage = warning?.speakMessage;\n\tuseEffect( () => {\n\t\tif ( speakMessage ) {\n\t\t\tspeak( speakMessage );\n\t\t}\n\t}, [ speakMessage ] );\n\n\treturn warning?.message;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAuD;AACvD,kBAA0B;AAC1B,oBAAqC;AACrC,kCAAiC;AACjC,kBAAsB;AAKtB,8BAAmC;AAEnC,4BAAgC;AAEhC,SAAS,iBAAkB,MAAM,UAAW;AAC3C,SAAO,KAAK,cAAc,YACxB,iBAAkB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/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components2.InspectorControls, { group: "advanced", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
64
64
|
import_components.TextControl,
|
|
65
65
|
{
|
|
66
|
-
__next40pxDefaultSize: true,
|
|
67
66
|
autoComplete: "off",
|
|
68
67
|
label: (0, import_i18n.__)("Additional CSS class(es)"),
|
|
69
68
|
value: className || "",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/custom-class-name.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Filters registered block settings, extending attributes to include `className`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( hasBlockSupport( settings, 'customClassName', true ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tclassName: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction CustomClassNameControlsPure( { className, setAttributes } ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<TextControl\n\t\t\t\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,mBAA0B;AAC1B,wBAA4B;AAC5B,kBAAmB;AACnB,oBAAgC;AAKhC,IAAAA,qBAAkC;AAClC,gCAAoC;AA+BjC;AAtBI,SAAS,aAAc,UAAW;AACxC,UAAK,+BAAiB,UAAU,mBAAmB,IAAK,GAAI;AAE3D,aAAS,aAAa;AAAA,MACrB,GAAG,SAAS;AAAA,MACZ,WAAW;AAAA,QACV,MAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;AAEA,SAAS,4BAA6B,EAAE,WAAW,cAAc,GAAI;AACpE,QAAM,uBAAmB,+CAAoB;AAC7C,MAAK,qBAAqB,WAAY;AACrC,WAAO;AAAA,EACR;AAEA,SACC,4CAAC,wCAAkB,OAAM,YACxB;AAAA,IAAC;AAAA;AAAA,MACA,
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { hasBlockSupport } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { InspectorControls } from '../components';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Filters registered block settings, extending attributes to include `className`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( hasBlockSupport( settings, 'customClassName', true ) ) {\n\t\t// Gracefully handle if settings.attributes is undefined.\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tclassName: {\n\t\t\t\ttype: 'string',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\nfunction CustomClassNameControlsPure( { className, setAttributes } ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<TextControl\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\tlabel={ __( 'Additional CSS class(es)' ) }\n\t\t\t\tvalue={ className || '' }\n\t\t\t\tonChange={ ( nextValue ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tclassName: nextValue !== '' ? nextValue : undefined,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\thelp={ __( 'Separate multiple classes with spaces.' ) }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nexport default {\n\tedit: CustomClassNameControlsPure,\n\taddSaveProps,\n\tattributeKeys: [ 'className' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'customClassName', true );\n\t},\n};\n\n/**\n * Override props assigned to save component to inject the className, if block\n * supports customClassName. This is only applied if the block's save result is an\n * element and not a markup string.\n *\n * @param {Object} extraProps Additional props applied to save element.\n * @param {Object} blockType Block type.\n * @param {Object} attributes Current block attributes.\n *\n * @return {Object} Filtered props applied to save element.\n */\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif (\n\t\thasBlockSupport( blockType, 'customClassName', true ) &&\n\t\tattributes.className\n\t) {\n\t\textraProps.className = clsx(\n\t\t\textraProps.className,\n\t\t\tattributes.className\n\t\t);\n\t}\n\n\treturn extraProps;\n}\n\nexport function addTransforms( result, source, index, results ) {\n\tif ( ! hasBlockSupport( result.name, 'customClassName', true ) ) {\n\t\treturn result;\n\t}\n\n\t// If the condition verifies we are probably in the presence of a wrapping transform\n\t// e.g: nesting paragraphs in a group or columns and in that case the class should not be kept.\n\tif ( results.length === 1 && result.innerBlocks.length === source.length ) {\n\t\treturn result;\n\t}\n\n\t// If we are transforming one block to multiple blocks or multiple blocks to one block,\n\t// we ignore the class during the transform.\n\tif (\n\t\t( results.length === 1 && source.length > 1 ) ||\n\t\t( results.length > 1 && source.length === 1 )\n\t) {\n\t\treturn result;\n\t}\n\n\t// If we are in presence of transform between one or more block in the source\n\t// that have one or more blocks in the result\n\t// we apply the class on source N to the result N,\n\t// if source N does not exists we do nothing.\n\tif ( source[ index ] ) {\n\t\tconst originClassName = source[ index ]?.attributes.className;\n\t\t// Avoid overriding classes if the transformed block already includes them.\n\t\tif ( originClassName && result.attributes.className === undefined ) {\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\tattributes: {\n\t\t\t\t\t...result.attributes,\n\t\t\t\t\tclassName: originClassName,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t}\n\treturn result;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/custom-class-name/attribute',\n\taddAttribute\n);\n\naddFilter(\n\t'blocks.switchToBlockType.transformedBlock',\n\t'core/customClassName/addTransforms',\n\taddTransforms\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,mBAA0B;AAC1B,wBAA4B;AAC5B,kBAAmB;AACnB,oBAAgC;AAKhC,IAAAA,qBAAkC;AAClC,gCAAoC;AA+BjC;AAtBI,SAAS,aAAc,UAAW;AACxC,UAAK,+BAAiB,UAAU,mBAAmB,IAAK,GAAI;AAE3D,aAAS,aAAa;AAAA,MACrB,GAAG,SAAS;AAAA,MACZ,WAAW;AAAA,QACV,MAAM;AAAA,MACP;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AACR;AAEA,SAAS,4BAA6B,EAAE,WAAW,cAAc,GAAI;AACpE,QAAM,uBAAmB,+CAAoB;AAC7C,MAAK,qBAAqB,WAAY;AACrC,WAAO;AAAA,EACR;AAEA,SACC,4CAAC,wCAAkB,OAAM,YACxB;AAAA,IAAC;AAAA;AAAA,MACA,cAAa;AAAA,MACb,WAAQ,gBAAI,0BAA2B;AAAA,MACvC,OAAQ,aAAa;AAAA,MACrB,UAAW,CAAE,cAAe;AAC3B,sBAAe;AAAA,UACd,WAAW,cAAc,KAAK,YAAY;AAAA,QAC3C,CAAE;AAAA,MACH;AAAA,MACA,UAAO,gBAAI,wCAAyC;AAAA;AAAA,EACrD,GACD;AAEF;AAEA,IAAO,4BAAQ;AAAA,EACd,MAAM;AAAA,EACN;AAAA,EACA,eAAe,CAAE,WAAY;AAAA,EAC7B,WAAY,MAAO;AAClB,eAAO,+BAAiB,MAAM,mBAAmB,IAAK;AAAA,EACvD;AACD;AAaO,SAAS,aAAc,YAAY,WAAW,YAAa;AACjE,UACC,+BAAiB,WAAW,mBAAmB,IAAK,KACpD,WAAW,WACV;AACD,eAAW,gBAAY,YAAAC;AAAA,MACtB,WAAW;AAAA,MACX,WAAW;AAAA,IACZ;AAAA,EACD;AAEA,SAAO;AACR;AAEO,SAAS,cAAe,QAAQ,QAAQ,OAAO,SAAU;AAC/D,MAAK,KAAE,+BAAiB,OAAO,MAAM,mBAAmB,IAAK,GAAI;AAChE,WAAO;AAAA,EACR;AAIA,MAAK,QAAQ,WAAW,KAAK,OAAO,YAAY,WAAW,OAAO,QAAS;AAC1E,WAAO;AAAA,EACR;AAIA,MACG,QAAQ,WAAW,KAAK,OAAO,SAAS,KACxC,QAAQ,SAAS,KAAK,OAAO,WAAW,GACzC;AACD,WAAO;AAAA,EACR;AAMA,MAAK,OAAQ,KAAM,GAAI;AACtB,UAAM,kBAAkB,OAAQ,KAAM,GAAG,WAAW;AAEpD,QAAK,mBAAmB,OAAO,WAAW,cAAc,QAAY;AACnE,aAAO;AAAA,QACN,GAAG;AAAA,QACH,YAAY;AAAA,UACX,GAAG,OAAO;AAAA,UACV,WAAW;AAAA,QACZ;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;AAAA,IAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;AAAA,IAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
|
|
6
6
|
"names": ["import_components", "clsx"]
|
|
7
7
|
}
|
|
@@ -37,6 +37,7 @@ __export(dimensions_exports, {
|
|
|
37
37
|
SPACING_SUPPORT_KEY: () => SPACING_SUPPORT_KEY,
|
|
38
38
|
default: () => dimensions_default,
|
|
39
39
|
hasDimensionsSupport: () => hasDimensionsSupport,
|
|
40
|
+
isExplicitAspectRatio: () => isExplicitAspectRatio,
|
|
40
41
|
useCustomSides: () => useCustomSides
|
|
41
42
|
});
|
|
42
43
|
module.exports = __toCommonJS(dimensions_exports);
|
|
@@ -177,6 +178,12 @@ function hasDimensionsSupport(blockName, feature = "any") {
|
|
|
177
178
|
}
|
|
178
179
|
return !!support?.[feature];
|
|
179
180
|
}
|
|
181
|
+
function isExplicitAspectRatio(aspectRatio) {
|
|
182
|
+
if (!aspectRatio) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
return `${aspectRatio}`.trim().toLowerCase() !== "auto";
|
|
186
|
+
}
|
|
180
187
|
var dimensions_default = {
|
|
181
188
|
useBlockProps,
|
|
182
189
|
attributeKeys: ["height", "minHeight", "width", "style"],
|
|
@@ -188,11 +195,14 @@ function useBlockProps({ name, height, minHeight, style }) {
|
|
|
188
195
|
if (!hasDimensionsSupport(name, "aspectRatio") || (0, import_utils.shouldSkipSerialization)(name, DIMENSIONS_SUPPORT_KEY, "aspectRatio")) {
|
|
189
196
|
return {};
|
|
190
197
|
}
|
|
198
|
+
const hasExplicitAspectRatio = isExplicitAspectRatio(
|
|
199
|
+
style?.dimensions?.aspectRatio
|
|
200
|
+
);
|
|
191
201
|
const className = (0, import_clsx.default)({
|
|
192
|
-
"has-aspect-ratio":
|
|
202
|
+
"has-aspect-ratio": hasExplicitAspectRatio
|
|
193
203
|
});
|
|
194
204
|
const inlineStyleOverrides = {};
|
|
195
|
-
if (
|
|
205
|
+
if (hasExplicitAspectRatio) {
|
|
196
206
|
inlineStyleOverrides.minHeight = "unset";
|
|
197
207
|
inlineStyleOverrides.height = "unset";
|
|
198
208
|
} else if (minHeight || style?.dimensions?.minHeight || height || style?.dimensions?.height) {
|
|
@@ -214,6 +224,7 @@ function useCustomSides() {
|
|
|
214
224
|
DimensionsPanel,
|
|
215
225
|
SPACING_SUPPORT_KEY,
|
|
216
226
|
hasDimensionsSupport,
|
|
227
|
+
isExplicitAspectRatio,
|
|
217
228
|
useCustomSides
|
|
218
229
|
});
|
|
219
230
|
//# sourceMappingURL=dimensions.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/dimensions.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tDimensionsPanel as StylesDimensionsPanel,\n\tuseHasDimensionsPanel,\n} from '../components/global-styles';\nimport { MarginVisualizer, PaddingVisualizer } from './spacing-visualizer';\nimport { store as blockEditorStore } from '../store';\nimport { unlock } from '../lock-unlock';\nimport { cleanEmptyObject, shouldSkipSerialization } from './utils';\nimport {\n\tgetStyleForState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n\tuseBlockStyleState,\n} from './block-style-state';\n\nexport const DIMENSIONS_SUPPORT_KEY = 'dimensions';\nexport const SPACING_SUPPORT_KEY = 'spacing';\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nexport const AXIAL_SIDES = [ 'vertical', 'horizontal' ];\n\nfunction useVisualizer() {\n\tconst [ property, setProperty ] = useState( false );\n\tconst { hideBlockInterface, showBlockInterface } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tuseEffect( () => {\n\t\tif ( ! property ) {\n\t\t\tshowBlockInterface();\n\t\t} else {\n\t\t\thideBlockInterface();\n\t\t}\n\t}, [ property, showBlockInterface, hideBlockInterface ] );\n\n\treturn [ property, setProperty ];\n}\n\nfunction DimensionsInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributes.style;\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\tstyle: updatedStyle,\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"dimensions\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function DimensionsPanel( { clientId, name, setAttributes, settings } ) {\n\tconst selectedState = useBlockStyleState();\n\tconst isStateSelected = ! isDefaultBlockStyleState( selectedState );\n\tconst isEnabled = useHasDimensionsPanel( settings, selectedState );\n\tconst style = useSelect(\n\t\t( select ) => {\n\t\t\t// Early return to avoid subscription when disabled\n\t\t\tif ( ! isEnabled ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\treturn select( blockEditorStore ).getBlockAttributes( clientId )\n\t\t\t\t?.style;\n\t\t},\n\t\t[ clientId, isEnabled ]\n\t);\n\tconst [ visualizedProperty, setVisualizedProperty ] = useVisualizer();\n\tconst value = isStateSelected\n\t\t? getStyleForState( style, selectedState )\n\t\t: style;\n\tconst onChange = isStateSelected\n\t\t? ( newStyle ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tstyle: setStyleForState( style, selectedState, newStyle ),\n\t\t\t\t} );\n\t\t }\n\t\t: ( newStyle ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\t} );\n\t\t };\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultDimensionsControls = getBlockSupport( name, [\n\t\tDIMENSIONS_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\tconst defaultSpacingControls = getBlockSupport( name, [\n\t\tSPACING_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\tconst defaultControls = {\n\t\t// In the block inspector, minHeight and minWidth should not\n\t\t// be shown by default unless the block explicitly opts in.\n\t\tminHeight: false,\n\t\tminWidth: false,\n\t\t...defaultDimensionsControls,\n\t\t...defaultSpacingControls,\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<StylesDimensionsPanel\n\t\t\t\tas={ DimensionsInspectorControl }\n\t\t\t\tpanelId={ clientId }\n\t\t\t\tsettings={ settings }\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tdefaultControls={ defaultControls }\n\t\t\t\tstyleState={ selectedState }\n\t\t\t\tonVisualize={\n\t\t\t\t\tisStateSelected ? undefined : setVisualizedProperty\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ ! isStateSelected &&\n\t\t\t\t!! settings?.spacing?.padding &&\n\t\t\t\tvisualizedProperty === 'padding' && (\n\t\t\t\t\t<PaddingVisualizer\n\t\t\t\t\t\tforceShow={ visualizedProperty === 'padding' }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t{ ! isStateSelected &&\n\t\t\t\t!! settings?.spacing?.margin &&\n\t\t\t\tvisualizedProperty === 'margin' && (\n\t\t\t\t\t<MarginVisualizer\n\t\t\t\t\t\tforceShow={ visualizedProperty === 'margin' }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t</>\n\t);\n}\n\n/**\n * Determine whether there is block support for dimensions.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasDimensionsSupport( blockName, feature = 'any' ) {\n\tconst support = getBlockSupport( blockName, DIMENSIONS_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! (\n\t\t\tsupport?.aspectRatio ||\n\t\t\t!! support?.height ||\n\t\t\t!! support?.minHeight ||\n\t\t\t!! support?.width ||\n\t\t\t!! support?.minWidth\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'height', 'minHeight', 'width', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasDimensionsSupport( name );\n\t},\n};\n\nfunction useBlockProps( { name, height, minHeight, style } ) {\n\tif (\n\t\t! hasDimensionsSupport( name, 'aspectRatio' ) ||\n\t\tshouldSkipSerialization( name, DIMENSIONS_SUPPORT_KEY, 'aspectRatio' )\n\t) {\n\t\treturn {};\n\t}\n\n\tconst className = clsx( {\n\t\t'has-aspect-ratio':
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,qBAAiD;AACjD,kBAAuC;AACvC,oBAAgC;AAChC,wBAAuB;AAKvB,gCAA8B;AAC9B,2BAGO;AACP,gCAAoD;AACpD,mBAA0C;AAC1C,yBAAuB;AACvB,mBAA0D;AAC1D,+BAKO;AAqCL;AAnCK,IAAM,yBAAyB;AAC/B,IAAM,sBAAsB;AAC5B,IAAM,YAAY,CAAE,OAAO,SAAS,UAAU,MAAO;AACrD,IAAM,cAAc,CAAE,YAAY,YAAa;AAEtD,SAAS,gBAAgB;AACxB,QAAM,CAAE,UAAU,WAAY,QAAI,yBAAU,KAAM;AAClD,QAAM,EAAE,oBAAoB,mBAAmB,QAAI;AAAA,QAClD,yBAAa,aAAAA,KAAiB;AAAA,EAC/B;AACA,gCAAW,MAAM;AAChB,QAAK,CAAE,UAAW;AACjB,yBAAmB;AAAA,IACpB,OAAO;AACN,yBAAmB;AAAA,IACpB;AAAA,EACD,GAAG,CAAE,UAAU,oBAAoB,kBAAmB,CAAE;AAExD,SAAO,CAAE,UAAU,WAAY;AAChC;AAEA,S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B,aAAc,GACpE;AACD,WAAO,CAAC;AAAA,EACT;AAEA,QAAM,gBAAY,YAAAC,SAAM;AAAA,IACvB,oBAAoB
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tDimensionsPanel as StylesDimensionsPanel,\n\tuseHasDimensionsPanel,\n} from '../components/global-styles';\nimport { MarginVisualizer, PaddingVisualizer } from './spacing-visualizer';\nimport { store as blockEditorStore } from '../store';\nimport { unlock } from '../lock-unlock';\nimport { cleanEmptyObject, shouldSkipSerialization } from './utils';\nimport {\n\tgetStyleForState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n\tuseBlockStyleState,\n} from './block-style-state';\n\nexport const DIMENSIONS_SUPPORT_KEY = 'dimensions';\nexport const SPACING_SUPPORT_KEY = 'spacing';\nexport const ALL_SIDES = [ 'top', 'right', 'bottom', 'left' ];\nexport const AXIAL_SIDES = [ 'vertical', 'horizontal' ];\n\nfunction useVisualizer() {\n\tconst [ property, setProperty ] = useState( false );\n\tconst { hideBlockInterface, showBlockInterface } = unlock(\n\t\tuseDispatch( blockEditorStore )\n\t);\n\tuseEffect( () => {\n\t\tif ( ! property ) {\n\t\t\tshowBlockInterface();\n\t\t} else {\n\t\t\thideBlockInterface();\n\t\t}\n\t}, [ property, showBlockInterface, hideBlockInterface ] );\n\n\treturn [ property, setProperty ];\n}\n\nfunction DimensionsInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst existingStyle = attributes.style;\n\t\t\tconst updatedStyle = resetAllFilter( existingStyle );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\tstyle: updatedStyle,\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"dimensions\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function DimensionsPanel( { clientId, name, setAttributes, settings } ) {\n\tconst selectedState = useBlockStyleState();\n\tconst isStateSelected = ! isDefaultBlockStyleState( selectedState );\n\tconst isEnabled = useHasDimensionsPanel( settings, selectedState );\n\tconst style = useSelect(\n\t\t( select ) => {\n\t\t\t// Early return to avoid subscription when disabled\n\t\t\tif ( ! isEnabled ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\treturn select( blockEditorStore ).getBlockAttributes( clientId )\n\t\t\t\t?.style;\n\t\t},\n\t\t[ clientId, isEnabled ]\n\t);\n\tconst [ visualizedProperty, setVisualizedProperty ] = useVisualizer();\n\tconst value = isStateSelected\n\t\t? getStyleForState( style, selectedState )\n\t\t: style;\n\tconst onChange = isStateSelected\n\t\t? ( newStyle ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tstyle: setStyleForState( style, selectedState, newStyle ),\n\t\t\t\t} );\n\t\t }\n\t\t: ( newStyle ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t\t\t} );\n\t\t };\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tconst defaultDimensionsControls = getBlockSupport( name, [\n\t\tDIMENSIONS_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\tconst defaultSpacingControls = getBlockSupport( name, [\n\t\tSPACING_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\tconst defaultControls = {\n\t\t// In the block inspector, minHeight and minWidth should not\n\t\t// be shown by default unless the block explicitly opts in.\n\t\tminHeight: false,\n\t\tminWidth: false,\n\t\t...defaultDimensionsControls,\n\t\t...defaultSpacingControls,\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<StylesDimensionsPanel\n\t\t\t\tas={ DimensionsInspectorControl }\n\t\t\t\tpanelId={ clientId }\n\t\t\t\tsettings={ settings }\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tdefaultControls={ defaultControls }\n\t\t\t\tstyleState={ selectedState }\n\t\t\t\tonVisualize={\n\t\t\t\t\tisStateSelected ? undefined : setVisualizedProperty\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ ! isStateSelected &&\n\t\t\t\t!! settings?.spacing?.padding &&\n\t\t\t\tvisualizedProperty === 'padding' && (\n\t\t\t\t\t<PaddingVisualizer\n\t\t\t\t\t\tforceShow={ visualizedProperty === 'padding' }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t{ ! isStateSelected &&\n\t\t\t\t!! settings?.spacing?.margin &&\n\t\t\t\tvisualizedProperty === 'margin' && (\n\t\t\t\t\t<MarginVisualizer\n\t\t\t\t\t\tforceShow={ visualizedProperty === 'margin' }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t</>\n\t);\n}\n\n/**\n * Determine whether there is block support for dimensions.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasDimensionsSupport( blockName, feature = 'any' ) {\n\tconst support = getBlockSupport( blockName, DIMENSIONS_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn !! (\n\t\t\tsupport?.aspectRatio ||\n\t\t\t!! support?.height ||\n\t\t\t!! support?.minHeight ||\n\t\t\t!! support?.width ||\n\t\t\t!! support?.minWidth\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nexport function isExplicitAspectRatio( aspectRatio ) {\n\tif ( ! aspectRatio ) {\n\t\treturn false;\n\t}\n\n\treturn `${ aspectRatio }`.trim().toLowerCase() !== 'auto';\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'height', 'minHeight', 'width', 'style' ],\n\thasSupport( name ) {\n\t\treturn hasDimensionsSupport( name );\n\t},\n};\n\nfunction useBlockProps( { name, height, minHeight, style } ) {\n\tif (\n\t\t! hasDimensionsSupport( name, 'aspectRatio' ) ||\n\t\tshouldSkipSerialization( name, DIMENSIONS_SUPPORT_KEY, 'aspectRatio' )\n\t) {\n\t\treturn {};\n\t}\n\n\tconst hasExplicitAspectRatio = isExplicitAspectRatio(\n\t\tstyle?.dimensions?.aspectRatio\n\t);\n\tconst className = clsx( {\n\t\t'has-aspect-ratio': hasExplicitAspectRatio,\n\t} );\n\n\t// Allow dimensions-based inline style overrides to override any global styles rules that\n\t// might be set for the block, and therefore affect the display of the aspect ratio.\n\tconst inlineStyleOverrides = {};\n\n\t// Apply rules to unset incompatible styles.\n\t// Note that an explicit `aspectRatio` will win out if both an aspect ratio and height-related properties are set.\n\t// This is because the aspect ratio is a newer block support, so (in theory) any aspect ratio\n\t// that is set should be intentional and should override any existing height properties. The Cover block\n\t// and dimensions controls have logic that will manually clear the aspect ratio if height properties\n\t// are set.\n\tif ( hasExplicitAspectRatio ) {\n\t\t// To ensure the aspect ratio does not get overridden by `minHeight` or `height` unset any existing rule.\n\t\tinlineStyleOverrides.minHeight = 'unset';\n\t\tinlineStyleOverrides.height = 'unset';\n\t} else if (\n\t\tminHeight ||\n\t\tstyle?.dimensions?.minHeight ||\n\t\theight ||\n\t\tstyle?.dimensions?.height\n\t) {\n\t\t// To ensure height properties do not get overridden by `aspectRatio` unset any existing rule.\n\t\tinlineStyleOverrides.aspectRatio = 'unset';\n\t}\n\n\treturn { className, style: inlineStyleOverrides };\n}\n\n/**\n * @deprecated\n */\nexport function useCustomSides() {\n\tdeprecated( 'wp.blockE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AAqB,YAAY;AACjC,yBAAqB,SAAS;AAAA,EAC/B,WACC,aACA,OAAO,YAAY,aACnB,UACA,OAAO,YAAY,QAClB;AAED,yBAAqB,cAAc;AAAA,EACpC;AAEA,SAAO,EAAE,WAAW,OAAO,qBAAqB;AACjD;AAKO,SAAS,iBAAiB;AAChC,wBAAAC,SAAY,+CAA+C;AAAA,IAC1D,OAAO;AAAA,IACP,SAAS;AAAA,EACV,CAAE;AACH;",
|
|
6
6
|
"names": ["blockEditorStore", "InspectorControls", "StylesDimensionsPanel", "clsx", "deprecated"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// packages/block-editor/src/hooks/elements.js
|
|
31
|
+
var elements_exports = {};
|
|
32
|
+
__export(elements_exports, {
|
|
33
|
+
ElementsEdit: () => ElementsEdit
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(elements_exports);
|
|
36
|
+
var import_blocks = require("@wordpress/blocks");
|
|
37
|
+
var import_element = require("@wordpress/element");
|
|
38
|
+
var import_data = require("@wordpress/data");
|
|
39
|
+
var import_i18n = require("@wordpress/i18n");
|
|
40
|
+
var import_inspector_controls = __toESM(require("../components/inspector-controls/index.cjs"));
|
|
41
|
+
var import_color_panel = __toESM(require("../components/global-styles/color-panel.cjs"));
|
|
42
|
+
var import_utils = require("./utils.cjs");
|
|
43
|
+
var import_store = require("../store/index.cjs");
|
|
44
|
+
var import_color = require("./color.cjs");
|
|
45
|
+
var import_contrast_checker = __toESM(require("./contrast-checker.cjs"));
|
|
46
|
+
var import_block_style_state = require("./block-style-state.cjs");
|
|
47
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
|
+
function ElementsInspectorControl({ children, resetAllFilter }) {
|
|
49
|
+
const attributesResetAllFilter = (0, import_element.useCallback)(
|
|
50
|
+
(attributes) => {
|
|
51
|
+
const updatedStyle = resetAllFilter(attributes.style);
|
|
52
|
+
return {
|
|
53
|
+
...attributes,
|
|
54
|
+
style: (0, import_utils.cleanEmptyObject)(updatedStyle)
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
[resetAllFilter]
|
|
58
|
+
);
|
|
59
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
60
|
+
import_inspector_controls.default,
|
|
61
|
+
{
|
|
62
|
+
group: "elements",
|
|
63
|
+
resetAllFilter: attributesResetAllFilter,
|
|
64
|
+
children
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
function ElementsEdit({
|
|
69
|
+
clientId,
|
|
70
|
+
name,
|
|
71
|
+
setAttributes,
|
|
72
|
+
settings,
|
|
73
|
+
asWrapper,
|
|
74
|
+
label,
|
|
75
|
+
defaultControls
|
|
76
|
+
}) {
|
|
77
|
+
const selectedState = (0, import_block_style_state.useBlockStyleState)();
|
|
78
|
+
const isEnabled = (0, import_color_panel.useHasColorPanel)(settings);
|
|
79
|
+
const style = (0, import_data.useSelect)(
|
|
80
|
+
(select) => {
|
|
81
|
+
if (!isEnabled) {
|
|
82
|
+
return void 0;
|
|
83
|
+
}
|
|
84
|
+
const attributes = select(import_store.store).getBlockAttributes(clientId);
|
|
85
|
+
return attributes?.style;
|
|
86
|
+
},
|
|
87
|
+
[clientId, isEnabled]
|
|
88
|
+
);
|
|
89
|
+
const isStateSelected = !(0, import_block_style_state.isDefaultBlockStyleState)(selectedState);
|
|
90
|
+
const value = (0, import_element.useMemo)(() => {
|
|
91
|
+
if (isStateSelected) {
|
|
92
|
+
return (0, import_block_style_state.getStyleForState)(style, selectedState);
|
|
93
|
+
}
|
|
94
|
+
return style;
|
|
95
|
+
}, [isStateSelected, selectedState, style]);
|
|
96
|
+
const onChange = isStateSelected ? (newStyle) => {
|
|
97
|
+
setAttributes({
|
|
98
|
+
style: (0, import_block_style_state.setStyleForState)(style, selectedState, newStyle)
|
|
99
|
+
});
|
|
100
|
+
} : (newStyle) => {
|
|
101
|
+
setAttributes({ style: (0, import_utils.cleanEmptyObject)(newStyle) });
|
|
102
|
+
};
|
|
103
|
+
const enableContrastChecking = !isStateSelected && !!value?.elements?.link?.color?.text && settings?.color?.link && false !== (0, import_blocks.getBlockSupport)(name, [
|
|
104
|
+
import_color.COLOR_SUPPORT_KEY,
|
|
105
|
+
"enableContrastChecker"
|
|
106
|
+
]);
|
|
107
|
+
const contrastWarning = (0, import_contrast_checker.default)({
|
|
108
|
+
clientId,
|
|
109
|
+
name,
|
|
110
|
+
enabled: !!enableContrastChecking,
|
|
111
|
+
checkTextColor: false,
|
|
112
|
+
messageOverride: (0, import_i18n.__)(
|
|
113
|
+
"This link color has poor contrast against the background. Consider increasing contrast."
|
|
114
|
+
)
|
|
115
|
+
});
|
|
116
|
+
if (!isEnabled) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
defaultControls = defaultControls ? defaultControls : (0, import_blocks.getBlockSupport)(name, [
|
|
120
|
+
import_color.COLOR_SUPPORT_KEY,
|
|
121
|
+
"__experimentalDefaultControls"
|
|
122
|
+
]);
|
|
123
|
+
const Wrapper = asWrapper || ElementsInspectorControl;
|
|
124
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
125
|
+
import_color_panel.default,
|
|
126
|
+
{
|
|
127
|
+
as: Wrapper,
|
|
128
|
+
panelId: clientId,
|
|
129
|
+
settings,
|
|
130
|
+
value,
|
|
131
|
+
onChange,
|
|
132
|
+
defaultControls,
|
|
133
|
+
label,
|
|
134
|
+
contrastWarning
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
139
|
+
0 && (module.exports = {
|
|
140
|
+
ElementsEdit
|
|
141
|
+
});
|
|
142
|
+
//# sourceMappingURL=elements.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/hooks/elements.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useMemo, useCallback } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport {\n\tuseHasColorPanel,\n\tdefault as StylesColorPanel,\n} from '../components/global-styles/color-panel';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\nimport { COLOR_SUPPORT_KEY } from './color';\nimport useBlockColorContrastWarning from './contrast-checker';\nimport {\n\tgetStyleForState,\n\tisDefaultBlockStyleState,\n\tsetStyleForState,\n\tuseBlockStyleState,\n} from './block-style-state';\n\nfunction ElementsInspectorControl( { children, resetAllFilter } ) {\n\tconst attributesResetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst updatedStyle = resetAllFilter( attributes.style );\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\tstyle: cleanEmptyObject( updatedStyle ),\n\t\t\t};\n\t\t},\n\t\t[ resetAllFilter ]\n\t);\n\n\treturn (\n\t\t<InspectorControls\n\t\t\tgroup=\"elements\"\n\t\t\tresetAllFilter={ attributesResetAllFilter }\n\t\t>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function ElementsEdit( {\n\tclientId,\n\tname,\n\tsetAttributes,\n\tsettings,\n\tasWrapper,\n\tlabel,\n\tdefaultControls,\n} ) {\n\tconst selectedState = useBlockStyleState();\n\tconst isEnabled = useHasColorPanel( settings );\n\n\tconst style = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isEnabled ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst attributes =\n\t\t\t\tselect( blockEditorStore ).getBlockAttributes( clientId );\n\t\t\treturn attributes?.style;\n\t\t},\n\t\t[ clientId, isEnabled ]\n\t);\n\n\tconst isStateSelected = ! isDefaultBlockStyleState( selectedState );\n\n\tconst value = useMemo( () => {\n\t\tif ( isStateSelected ) {\n\t\t\treturn getStyleForState( style, selectedState );\n\t\t}\n\t\treturn style;\n\t}, [ isStateSelected, selectedState, style ] );\n\n\tconst onChange = isStateSelected\n\t\t? ( newStyle ) => {\n\t\t\t\tsetAttributes( {\n\t\t\t\t\tstyle: setStyleForState( style, selectedState, newStyle ),\n\t\t\t\t} );\n\t\t }\n\t\t: ( newStyle ) => {\n\t\t\t\tsetAttributes( { style: cleanEmptyObject( newStyle ) } );\n\t\t };\n\n\t// Text and background color failures are reported by the Typography and\n\t// Background panels, which own those selections.\n\tconst enableContrastChecking =\n\t\t! isStateSelected &&\n\t\t!! value?.elements?.link?.color?.text &&\n\t\tsettings?.color?.link &&\n\t\tfalse !==\n\t\t\tgetBlockSupport( name, [\n\t\t\t\tCOLOR_SUPPORT_KEY,\n\t\t\t\t'enableContrastChecker',\n\t\t\t] );\n\n\tconst contrastWarning = useBlockColorContrastWarning( {\n\t\tclientId,\n\t\tname,\n\t\tenabled: !! enableContrastChecking,\n\t\tcheckTextColor: false,\n\t\tmessageOverride: __(\n\t\t\t'This link color has poor contrast against the background. Consider increasing contrast.'\n\t\t),\n\t} );\n\n\tif ( ! isEnabled ) {\n\t\treturn null;\n\t}\n\n\tdefaultControls = defaultControls\n\t\t? defaultControls\n\t\t: getBlockSupport( name, [\n\t\t\t\tCOLOR_SUPPORT_KEY,\n\t\t\t\t'__experimentalDefaultControls',\n\t\t ] );\n\n\tconst Wrapper = asWrapper || ElementsInspectorControl;\n\n\treturn (\n\t\t<StylesColorPanel\n\t\t\tas={ Wrapper }\n\t\t\tpanelId={ clientId }\n\t\t\tsettings={ settings }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t\tlabel={ label }\n\t\t\tcontrastWarning={ contrastWarning }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAgC;AAChC,qBAAqC;AACrC,kBAA0B;AAC1B,kBAAmB;AAKnB,gCAA8B;AAC9B,yBAGO;AACP,mBAAiC;AACjC,mBAA0C;AAC1C,mBAAkC;AAClC,8BAAyC;AACzC,+BAKO;AAeL;AAbF,SAAS,yBAA0B,EAAE,UAAU,eAAe,GAAI;AACjE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A;AAAA,EACD,CAAE;AAEJ,QAAM,sBAAkB,wBAAAC,SAA8B;AAAA,IACrD;AAAA,IACA;AAAA,IACA,SAAS,CAAC,CAAE;AAAA,IACZ,gBAAgB;AAAA,IAChB,qBAAiB;AAAA,MAChB;AAAA,IACD;AAAA,EACD,CAAE;AAEF,MAAK,CAAE,WAAY;AAClB,WAAO;AAAA,EACR;AAEA,oBAAkB,kBACf,sBACA,+BAAiB,MAAM;AAAA,IACvB;AAAA,IACA;AAAA,EACA,CAAE;AAEL,QAAM,UAAU,aAAa;AAE7B,SACC;AAAA,IAAC,mBAAAC;AAAA,IAAA;AAAA,MACA,IAAK;AAAA,MACL,SAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": ["InspectorControls", "blockEditorStore", "useBlockColorContrastWarning", "StylesColorPanel"]
|
|
7
|
+
}
|
|
@@ -29,6 +29,7 @@ var import_data = require("@wordpress/data");
|
|
|
29
29
|
var import_grid = require("../components/grid/index.cjs");
|
|
30
30
|
var import_store = require("../store/index.cjs");
|
|
31
31
|
var import_lock_unlock = require("../lock-unlock.cjs");
|
|
32
|
+
var import_use_block_refs = require("../components/block-list/use-block-props/use-block-refs.cjs");
|
|
32
33
|
var import_use_block_visibility = __toESM(require("../components/block-visibility/use-block-visibility.cjs"));
|
|
33
34
|
var import_private_keys = require("../store/private-keys.cjs");
|
|
34
35
|
var import_constants = require("../components/block-visibility/constants.cjs");
|
|
@@ -37,7 +38,7 @@ function GridLayoutSync(props) {
|
|
|
37
38
|
(0, import_grid.useGridLayoutSync)(props);
|
|
38
39
|
}
|
|
39
40
|
function GridTools({ clientId, layout }) {
|
|
40
|
-
const { isVisible, blockVisibility, deviceType
|
|
41
|
+
const { isVisible, blockVisibility, deviceType } = (0, import_data.useSelect)(
|
|
41
42
|
(select) => {
|
|
42
43
|
const {
|
|
43
44
|
isBlockSelected,
|
|
@@ -51,28 +52,37 @@ function GridTools({ clientId, layout }) {
|
|
|
51
52
|
if (!isDraggingBlocks() && !isBlockSelected(clientId) || getTemplateLock(clientId) || getBlockEditingMode(clientId) !== "default" || hasSelectedInnerBlock(clientId)) {
|
|
52
53
|
return { isVisible: false };
|
|
53
54
|
}
|
|
54
|
-
const { isBlockParentHiddenAtViewport } = (0, import_lock_unlock.unlock)(
|
|
55
|
-
select(import_store.store)
|
|
56
|
-
);
|
|
57
55
|
const attributes = getBlockAttributes(clientId);
|
|
58
56
|
const settings = getSettings();
|
|
59
57
|
const currentDeviceType = settings?.[import_private_keys.deviceTypeKey]?.toLowerCase() || import_constants.BLOCK_VISIBILITY_VIEWPORTS.desktop.key;
|
|
60
58
|
return {
|
|
61
59
|
isVisible: true,
|
|
62
60
|
blockVisibility: attributes?.metadata?.blockVisibility,
|
|
63
|
-
deviceType: currentDeviceType
|
|
64
|
-
isAnyAncestorHidden: isBlockParentHiddenAtViewport(
|
|
65
|
-
clientId,
|
|
66
|
-
currentDeviceType
|
|
67
|
-
)
|
|
61
|
+
deviceType: currentDeviceType
|
|
68
62
|
};
|
|
69
63
|
},
|
|
70
64
|
[clientId]
|
|
71
65
|
);
|
|
72
|
-
const
|
|
66
|
+
const blockElement = (0, import_use_block_refs.useBlockElement)(clientId);
|
|
67
|
+
const rawCanvasView = blockElement?.ownerDocument?.defaultView;
|
|
68
|
+
const canvasView = rawCanvasView === null ? void 0 : rawCanvasView;
|
|
69
|
+
const { isBlockCurrentlyHidden, currentViewport } = (0, import_use_block_visibility.default)({
|
|
73
70
|
blockVisibility,
|
|
74
|
-
deviceType
|
|
71
|
+
deviceType,
|
|
72
|
+
view: canvasView
|
|
75
73
|
});
|
|
74
|
+
const isAnyAncestorHidden = (0, import_data.useSelect)(
|
|
75
|
+
(select) => {
|
|
76
|
+
if (!isVisible) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
const { isBlockParentHiddenAtViewport } = (0, import_lock_unlock.unlock)(
|
|
80
|
+
select(import_store.store)
|
|
81
|
+
);
|
|
82
|
+
return isBlockParentHiddenAtViewport(clientId, currentViewport);
|
|
83
|
+
},
|
|
84
|
+
[clientId, currentViewport, isVisible]
|
|
85
|
+
);
|
|
76
86
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
77
87
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(GridLayoutSync, { clientId }),
|
|
78
88
|
isVisible && !isBlockCurrentlyHidden && !isAnyAncestorHidden && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/grid-visualizer.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { GridVisualizer, useGridLayoutSync } from '../components/grid';\nimport { store as blockEditorStore } from '../store';\nimport { unlock } from '../lock-unlock';\nimport useBlockVisibility from '../components/block-visibility/use-block-visibility';\nimport { deviceTypeKey } from '../store/private-keys';\nimport { BLOCK_VISIBILITY_VIEWPORTS } from '../components/block-visibility/constants';\n\nfunction GridLayoutSync( props ) {\n\tuseGridLayoutSync( props );\n}\n\nfunction GridTools( { clientId, layout } ) {\n\tconst { isVisible, blockVisibility, deviceType
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAGA,qBAA2C;AAC3C,mBAA0B;AAC1B,kBAA0B;AAK1B,kBAAkD;AAClD,mBAA0C;AAC1C,yBAAuB;AACvB,kCAA+B;AAC/B,0BAA8B;AAC9B,uBAA2C;
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { GridVisualizer, useGridLayoutSync } from '../components/grid';\nimport { store as blockEditorStore } from '../store';\nimport { unlock } from '../lock-unlock';\nimport { useBlockElement } from '../components/block-list/use-block-props/use-block-refs';\nimport useBlockVisibility from '../components/block-visibility/use-block-visibility';\nimport { deviceTypeKey } from '../store/private-keys';\nimport { BLOCK_VISIBILITY_VIEWPORTS } from '../components/block-visibility/constants';\n\nfunction GridLayoutSync( props ) {\n\tuseGridLayoutSync( props );\n}\n\nfunction GridTools( { clientId, layout } ) {\n\tconst { isVisible, blockVisibility, deviceType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockSelected,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tisDraggingBlocks,\n\t\t\t\tgetTemplateLock,\n\t\t\t\tgetBlockEditingMode,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetSettings,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\t// These calls are purposely ordered from least expensive to most expensive.\n\t\t\t// Hides the visualizer in cases where the user is not or cannot interact with it.\n\t\t\t// Also hide if a child block is selected, because layout-child.js will render\n\t\t\t// the visualizer in that case (with proper childGridClientId handling).\n\t\t\tif (\n\t\t\t\t( ! isDraggingBlocks() && ! isBlockSelected( clientId ) ) ||\n\t\t\t\tgetTemplateLock( clientId ) ||\n\t\t\t\tgetBlockEditingMode( clientId ) !== 'default' ||\n\t\t\t\thasSelectedInnerBlock( clientId )\n\t\t\t) {\n\t\t\t\treturn { isVisible: false };\n\t\t\t}\n\n\t\t\tconst attributes = getBlockAttributes( clientId );\n\t\t\tconst settings = getSettings();\n\t\t\tconst currentDeviceType =\n\t\t\t\tsettings?.[ deviceTypeKey ]?.toLowerCase() ||\n\t\t\t\tBLOCK_VISIBILITY_VIEWPORTS.desktop.key;\n\n\t\t\treturn {\n\t\t\t\tisVisible: true,\n\t\t\t\tblockVisibility: attributes?.metadata?.blockVisibility,\n\t\t\t\tdeviceType: currentDeviceType,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// Get the block's DOM element to derive the canvas iframe window,\n\t// so viewport detection matches the actual block rendering context\n\tconst blockElement = useBlockElement( clientId );\n\tconst rawCanvasView = blockElement?.ownerDocument?.defaultView;\n\tconst canvasView = rawCanvasView === null ? undefined : rawCanvasView;\n\n\tconst { isBlockCurrentlyHidden, currentViewport } = useBlockVisibility( {\n\t\tblockVisibility,\n\t\tdeviceType,\n\t\tview: canvasView,\n\t} );\n\n\t// Check whether any ancestor is hidden at the viewport actually detected\n\t// from the canvas, so it stays consistent with how blocks are hidden.\n\tconst isAnyAncestorHidden = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isVisible ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tconst { isBlockParentHiddenAtViewport } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn isBlockParentHiddenAtViewport( clientId, currentViewport );\n\t\t},\n\t\t[ clientId, currentViewport, isVisible ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<GridLayoutSync clientId={ clientId } />\n\t\t\t{ isVisible &&\n\t\t\t\t! isBlockCurrentlyHidden &&\n\t\t\t\t! isAnyAncestorHidden && (\n\t\t\t\t\t<GridVisualizer\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tparentLayout={ layout }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t</>\n\t);\n}\n\nconst addGridVisualizerToBlockEdit = createHigherOrderComponent(\n\t( BlockEdit ) =>\n\t\tfunction AddGridVisualizerToBlockEdit( props ) {\n\t\t\tif ( props.attributes.layout?.type !== 'grid' ) {\n\t\t\t\treturn <BlockEdit key=\"edit\" { ...props } />;\n\t\t\t}\n\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t<GridTools\n\t\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\t\tlayout={ props.attributes.layout }\n\t\t\t\t\t/>\n\t\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t\t</>\n\t\t\t);\n\t\t},\n\t'addGridVisualizerToBlockEdit'\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/grid-visualizer',\n\taddGridVisualizerToBlockEdit\n);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAGA,qBAA2C;AAC3C,mBAA0B;AAC1B,kBAA0B;AAK1B,kBAAkD;AAClD,mBAA0C;AAC1C,yBAAuB;AACvB,4BAAgC;AAChC,kCAA+B;AAC/B,0BAA8B;AAC9B,uBAA2C;AA2EzC;AAzEF,SAAS,eAAgB,OAAQ;AAChC,qCAAmB,KAAM;AAC1B;AAEA,SAAS,UAAW,EAAE,UAAU,OAAO,GAAI;AAC1C,QAAM,EAAE,WAAW,iBAAiB,WAAW,QAAI;AAAA,IAClD,CAAE,WAAY;AACb,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,IAAI,OAAQ,aAAAA,KAAiB;AAM7B,UACG,CAAE,iBAAiB,KAAK,CAAE,gBAAiB,QAAS,KACtD,gBAAiB,QAAS,KAC1B,oBAAqB,QAAS,MAAM,aACpC,sBAAuB,QAAS,GAC/B;AACD,eAAO,EAAE,WAAW,MAAM;AAAA,MAC3B;AAEA,YAAM,aAAa,mBAAoB,QAAS;AAChD,YAAM,WAAW,YAAY;AAC7B,YAAM,oBACL,WAAY,iCAAc,GAAG,YAAY,KACzC,4CAA2B,QAAQ;AAEpC,aAAO;AAAA,QACN,WAAW;AAAA,QACX,iBAAiB,YAAY,UAAU;AAAA,QACvC,YAAY;AAAA,MACb;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAIA,QAAM,mBAAe,uCAAiB,QAAS;AAC/C,QAAM,gBAAgB,cAAc,eAAe;AACnD,QAAM,aAAa,kBAAkB,OAAO,SAAY;AAExD,QAAM,EAAE,wBAAwB,gBAAgB,QAAI,4BAAAC,SAAoB;AAAA,IACvE;AAAA,IACA;AAAA,IACA,MAAM;AAAA,EACP,CAAE;AAIF,QAAM,0BAAsB;AAAA,IAC3B,CAAE,WAAY;AACb,UAAK,CAAE,WAAY;AAClB,eAAO;AAAA,MACR;AACA,YAAM,EAAE,8BAA8B,QAAI;AAAA,QACzC,OAAQ,aAAAD,KAAiB;AAAA,MAC1B;AACA,aAAO,8BAA+B,UAAU,eAAgB;AAAA,IACjE;AAAA,IACA,CAAE,UAAU,iBAAiB,SAAU;AAAA,EACxC;AAEA,SACC,4EACC;AAAA,gDAAC,kBAAe,UAAsB;AAAA,IACpC,aACD,CAAE,0BACF,CAAE,uBACD;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA,cAAe;AAAA;AAAA,IAChB;AAAA,KAEH;AAEF;AAEA,IAAM,mCAA+B;AAAA,EACpC,CAAE,cACD,SAAS,6BAA8B,OAAQ;AAC9C,QAAK,MAAM,WAAW,QAAQ,SAAS,QAAS;AAC/C,aAAO,4CAAC,aAAuB,GAAG,SAAZ,MAAoB;AAAA,IAC3C;AAEA,WACC,4EACC;AAAA;AAAA,QAAC;AAAA;AAAA,UACA,UAAW,MAAM;AAAA,UACjB,QAAS,MAAM,WAAW;AAAA;AAAA,MAC3B;AAAA,MACA,4CAAC,aAAuB,GAAG,SAAZ,MAAoB;AAAA,OACpC;AAAA,EAEF;AAAA,EACD;AACD;AAAA,IAEA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AACD;",
|
|
6
6
|
"names": ["blockEditorStore", "useBlockVisibility"]
|
|
7
7
|
}
|
|
@@ -40,18 +40,34 @@ var import_compose = require("@wordpress/compose");
|
|
|
40
40
|
var import_data = require("@wordpress/data");
|
|
41
41
|
var import_element = require("@wordpress/element");
|
|
42
42
|
var import_store = require("../store/index.cjs");
|
|
43
|
+
var import_lock_unlock = require("../lock-unlock.cjs");
|
|
43
44
|
var import_utils = require("./utils.cjs");
|
|
44
45
|
var import_layout = require("../components/block-list/layout.cjs");
|
|
45
46
|
var import_grid = require("../components/grid/index.cjs");
|
|
47
|
+
var import_use_block_refs = require("../components/block-list/use-block-props/use-block-refs.cjs");
|
|
46
48
|
var import_use_block_visibility = __toESM(require("../components/block-visibility/use-block-visibility.cjs"));
|
|
47
49
|
var import_private_keys = require("../store/private-keys.cjs");
|
|
48
50
|
var import_constants = require("../components/block-visibility/constants.cjs");
|
|
51
|
+
var import_block_style_state = require("./block-style-state.cjs");
|
|
49
52
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
50
53
|
var LAYOUT_CHILD_BLOCK_PROPS_REFERENCE = {};
|
|
51
54
|
var RESPONSIVE_BREAKPOINTS = {
|
|
52
|
-
mobile: "@media (width <= 480px)",
|
|
53
|
-
tablet: "@media (480px < width <= 782px)"
|
|
55
|
+
"@mobile": "@media (width <= 480px)",
|
|
56
|
+
"@tablet": "@media (480px < width <= 782px)"
|
|
54
57
|
};
|
|
58
|
+
var FLEX_CHILD_LAYOUT_VALUES = {
|
|
59
|
+
fit: "fit",
|
|
60
|
+
grow: "fill",
|
|
61
|
+
max: "fixed",
|
|
62
|
+
fixed: "fixedNoShrink"
|
|
63
|
+
};
|
|
64
|
+
var FLEX_SIZE_VALUES = [
|
|
65
|
+
FLEX_CHILD_LAYOUT_VALUES.max,
|
|
66
|
+
FLEX_CHILD_LAYOUT_VALUES.fixed
|
|
67
|
+
];
|
|
68
|
+
function isFlexSizeValue(value) {
|
|
69
|
+
return FLEX_SIZE_VALUES.includes(value);
|
|
70
|
+
}
|
|
55
71
|
function serializeRule({ selector, declarations }) {
|
|
56
72
|
return `${selector} {
|
|
57
73
|
${Object.entries(declarations).map(([property, value]) => `${property}: ${value}`).join("; ")};
|
|
@@ -78,14 +94,26 @@ function getChildLayoutStyleRules({
|
|
|
78
94
|
columnSpan,
|
|
79
95
|
rowSpan
|
|
80
96
|
} = effectiveLayout;
|
|
97
|
+
const baseSelfStretch = layout.selfStretch;
|
|
81
98
|
const { columnCount, minimumColumnWidth } = parentLayout;
|
|
82
99
|
const rules = [];
|
|
83
100
|
const declarations = {};
|
|
84
101
|
if (!hasViewportOverrides || hasViewportOverride("selfStretch") || hasViewportOverride("flexSize")) {
|
|
85
|
-
if (selfStretch ===
|
|
102
|
+
if (hasViewportOverrides && (selfStretch === FLEX_CHILD_LAYOUT_VALUES.fit || selfStretch === FLEX_CHILD_LAYOUT_VALUES.grow) && isFlexSizeValue(baseSelfStretch) && layout.flexSize) {
|
|
103
|
+
declarations["flex-basis"] = "unset";
|
|
104
|
+
if (baseSelfStretch === FLEX_CHILD_LAYOUT_VALUES.fixed) {
|
|
105
|
+
declarations["flex-shrink"] = "unset";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (isFlexSizeValue(selfStretch) && flexSize) {
|
|
86
109
|
declarations["flex-basis"] = flexSize;
|
|
110
|
+
if (selfStretch === FLEX_CHILD_LAYOUT_VALUES.fixed) {
|
|
111
|
+
declarations["flex-shrink"] = "0";
|
|
112
|
+
} else if (hasViewportOverrides && baseSelfStretch === FLEX_CHILD_LAYOUT_VALUES.fixed) {
|
|
113
|
+
declarations["flex-shrink"] = "unset";
|
|
114
|
+
}
|
|
87
115
|
declarations["box-sizing"] = "border-box";
|
|
88
|
-
} else if (selfStretch ===
|
|
116
|
+
} else if (selfStretch === FLEX_CHILD_LAYOUT_VALUES.grow) {
|
|
89
117
|
declarations["flex-grow"] = "1";
|
|
90
118
|
}
|
|
91
119
|
}
|
|
@@ -175,7 +203,10 @@ function getResponsiveChildLayoutStyles({
|
|
|
175
203
|
}) {
|
|
176
204
|
const baseLayout = style?.layout ?? {};
|
|
177
205
|
return Object.entries(RESPONSIVE_BREAKPOINTS).map(([viewport, mediaQuery]) => {
|
|
178
|
-
const viewportLayout = style
|
|
206
|
+
const viewportLayout = (0, import_block_style_state.getStyleForState)(style, {
|
|
207
|
+
viewport,
|
|
208
|
+
pseudo: import_block_style_state.DEFAULT_BLOCK_STYLE_STATE.pseudo
|
|
209
|
+
})?.layout;
|
|
179
210
|
if (!viewportLayout || !Object.keys(viewportLayout).length) {
|
|
180
211
|
return "";
|
|
181
212
|
}
|
|
@@ -290,29 +321,53 @@ function GridTools({
|
|
|
290
321
|
const parentAttributes = getBlockAttributes(_rootClientId);
|
|
291
322
|
const blockAttributes = getBlockAttributes(clientId);
|
|
292
323
|
const settings = getSettings();
|
|
324
|
+
const currentDeviceType = settings?.[import_private_keys.deviceTypeKey]?.toLowerCase() || import_constants.BLOCK_VISIBILITY_VIEWPORTS.desktop.key;
|
|
293
325
|
return {
|
|
294
326
|
rootClientId: _rootClientId,
|
|
295
327
|
isVisible: true,
|
|
296
328
|
parentBlockVisibility: parentAttributes?.metadata?.blockVisibility,
|
|
297
329
|
blockBlockVisibility: blockAttributes?.metadata?.blockVisibility,
|
|
298
|
-
deviceType:
|
|
330
|
+
deviceType: currentDeviceType,
|
|
299
331
|
// Check if the selected child block is itself a grid.
|
|
300
332
|
isChildBlockAGrid: blockAttributes?.layout?.type === "grid"
|
|
301
333
|
};
|
|
302
334
|
},
|
|
303
335
|
[clientId]
|
|
304
336
|
);
|
|
305
|
-
const
|
|
337
|
+
const blockElement = (0, import_use_block_refs.useBlockElement)(clientId);
|
|
338
|
+
const rawCanvasView = blockElement?.ownerDocument?.defaultView;
|
|
339
|
+
const canvasView = rawCanvasView === null ? void 0 : rawCanvasView;
|
|
340
|
+
const {
|
|
341
|
+
isBlockCurrentlyHidden: isParentBlockCurrentlyHidden,
|
|
342
|
+
currentViewport
|
|
343
|
+
} = (0, import_use_block_visibility.default)({
|
|
306
344
|
blockVisibility: parentBlockVisibility,
|
|
307
|
-
deviceType
|
|
345
|
+
deviceType,
|
|
346
|
+
view: canvasView
|
|
308
347
|
});
|
|
348
|
+
const isAnyAncestorHidden = (0, import_data.useSelect)(
|
|
349
|
+
(select) => {
|
|
350
|
+
if (!rootClientId) {
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
353
|
+
const { isBlockParentHiddenAtViewport } = (0, import_lock_unlock.unlock)(
|
|
354
|
+
select(import_store.store)
|
|
355
|
+
);
|
|
356
|
+
return isBlockParentHiddenAtViewport(
|
|
357
|
+
rootClientId,
|
|
358
|
+
currentViewport
|
|
359
|
+
);
|
|
360
|
+
},
|
|
361
|
+
[rootClientId, currentViewport]
|
|
362
|
+
);
|
|
309
363
|
const { isBlockCurrentlyHidden: isBlockItselfCurrentlyHidden } = (0, import_use_block_visibility.default)({
|
|
310
364
|
blockVisibility: blockBlockVisibility,
|
|
311
|
-
deviceType
|
|
365
|
+
deviceType,
|
|
366
|
+
view: canvasView
|
|
312
367
|
});
|
|
313
368
|
const [resizerBounds, setResizerBounds] = (0, import_element.useState)();
|
|
314
369
|
const childGridClientId = isChildBlockAGrid ? clientId : void 0;
|
|
315
|
-
if (!isVisible || isParentBlockCurrentlyHidden) {
|
|
370
|
+
if (!isVisible || isParentBlockCurrentlyHidden || isAnyAncestorHidden) {
|
|
316
371
|
return null;
|
|
317
372
|
}
|
|
318
373
|
const showResizer = allowSizingOnChildren && !isBlockItselfCurrentlyHidden;
|