@wordpress/block-editor 11.1.0 → 11.3.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 +12 -0
- package/LICENSE.md +1 -1
- package/README.md +28 -4
- package/build/components/alignment-control/ui.js +1 -1
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/autocomplete/index.js +2 -7
- package/build/components/autocomplete/index.js.map +1 -1
- package/build/components/block-actions/index.js +9 -0
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-matrix-control/index.js +2 -2
- package/build/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build/components/block-card/index.js +2 -4
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-edit/index.js +8 -0
- package/build/components/block-edit/index.js.map +1 -1
- package/build/components/block-inspector/index.js +18 -15
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/use-in-between-inserter.js +5 -0
- package/build/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build/components/block-lock/modal.js +0 -1
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-mover/mover-description.js +2 -2
- package/build/components/block-mover/mover-description.js.map +1 -1
- package/build/components/block-navigation/dropdown.js +3 -1
- package/build/components/block-navigation/dropdown.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +1 -1
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-pattern-setup/use-patterns-setup.js +2 -2
- package/build/components/block-pattern-setup/use-patterns-setup.js.map +1 -1
- package/build/components/block-patterns-list/index.js +31 -3
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-preview/auto.js +9 -14
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +32 -8
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-selection-clearer/index.js +1 -1
- package/build/components/block-selection-clearer/index.js.map +1 -1
- package/build/components/block-settings/container.native.js +7 -33
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +12 -3
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +2 -8
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/index.js +3 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-switcher/utils.js +1 -1
- package/build/components/block-switcher/utils.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +55 -47
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +43 -10
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/block-vertical-alignment-control/icons.js +15 -1
- package/build/components/block-vertical-alignment-control/icons.js.map +1 -1
- package/build/components/block-vertical-alignment-control/ui.js +9 -4
- package/build/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build/components/color-style-selector/index.js +3 -1
- package/build/components/color-style-selector/index.js.map +1 -1
- package/build/components/date-format-picker/index.js +3 -4
- package/build/components/date-format-picker/index.js.map +1 -1
- package/build/components/default-style-picker/index.js +1 -0
- package/build/components/default-style-picker/index.js.map +1 -1
- package/build/components/font-family/index.js +1 -7
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +1 -1
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/utils.js +1 -1
- package/build/components/font-sizes/utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +5 -8
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/global-styles/context.js +22 -0
- package/build/components/global-styles/context.js.map +1 -0
- package/build/components/global-styles/hooks.js +142 -0
- package/build/components/global-styles/hooks.js.map +1 -0
- package/build/components/global-styles/index.js +42 -0
- package/build/components/global-styles/index.js.map +1 -0
- package/build/components/global-styles/typography-utils.js +92 -0
- package/build/components/global-styles/typography-utils.js.map +1 -0
- package/build/components/global-styles/use-global-styles-output.js +974 -0
- package/build/components/global-styles/use-global-styles-output.js.map +1 -0
- package/build/components/global-styles/utils.js +340 -0
- package/build/components/global-styles/utils.js.map +1 -0
- package/build/components/height-control/index.js +13 -1
- package/build/components/height-control/index.js.map +1 -1
- package/build/components/iframe/index.js +37 -8
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +6 -1
- package/build/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build/components/image-editor/constants.js +1 -1
- package/build/components/image-editor/constants.js.map +1 -1
- package/build/components/image-editor/context.js +1 -2
- package/build/components/image-editor/context.js.map +1 -1
- package/build/components/image-editor/cropper.js +3 -1
- package/build/components/image-editor/cropper.js.map +1 -1
- package/build/components/image-editor/index.js +13 -9
- package/build/components/image-editor/index.js.map +1 -1
- package/build/components/image-editor/use-transform-image.js +11 -35
- package/build/components/image-editor/use-transform-image.js.map +1 -1
- package/build/components/image-size-control/index.js +2 -7
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/index.js +8 -24
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +22 -32
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inner-blocks/index.native.js +8 -23
- package/build/components/inner-blocks/index.native.js.map +1 -1
- package/build/components/inner-blocks/use-block-context.js +53 -0
- package/build/components/inner-blocks/use-block-context.js.map +1 -0
- package/build/components/inserter/block-patterns-explorer/explorer.js +0 -1
- package/build/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +11 -5
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +2 -2
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js +1 -7
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/index.js +8 -6
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +142 -56
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/media-tab/media-list.js +74 -21
- package/build/components/inserter/media-tab/media-list.js.map +1 -1
- package/build/components/inserter/media-tab/media-panel.js +11 -13
- package/build/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build/components/inserter/media-tab/media-tab.js +6 -3
- package/build/components/inserter/media-tab/media-tab.js.map +1 -1
- package/build/components/inserter/media-tab/utils.js +26 -15
- package/build/components/inserter/media-tab/utils.js.map +1 -1
- package/build/components/inserter/menu.js +12 -5
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/preview-panel.js +5 -3
- package/build/components/inserter/preview-panel.js.map +1 -1
- package/build/components/inserter/search-results.js +2 -7
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter-list-item/index.js +1 -9
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/inspector-controls/fill.js +15 -2
- package/build/components/inspector-controls/fill.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +14 -1
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/inspector-controls/groups.js +7 -1
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls/index.js +2 -2
- package/build/components/inspector-controls/index.js.map +1 -1
- package/build/components/inspector-controls/slot.js +14 -1
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/inspector-controls/slot.native.js +14 -1
- package/build/components/inspector-controls/slot.native.js.map +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -1
- package/build/components/inspector-controls-tabs/index.js +2 -2
- package/build/components/inspector-controls-tabs/index.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +46 -0
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
- package/build/components/inspector-controls-tabs/settings-tab.js +3 -1
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/styles-tab.js +6 -4
- package/build/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +20 -22
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/justify-content-control/ui.js +8 -1
- package/build/components/justify-content-control/ui.js.map +1 -1
- package/build/components/link-control/index.js +45 -17
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -0
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block.js +1 -1
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js +1 -1
- package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build/components/media-upload/index.native.js +4 -1
- package/build/components/media-upload/index.native.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +49 -38
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +38 -5
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/block-select-button.js +10 -4
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build/components/off-canvas-editor/block.js +13 -52
- package/build/components/off-canvas-editor/block.js.map +1 -1
- package/build/components/off-canvas-editor/branch.js +25 -10
- package/build/components/off-canvas-editor/branch.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +15 -17
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/link-ui.js +2 -2
- package/build/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
- package/build/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -1
- package/build/components/provider/index.js +22 -8
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/index.native.js +5 -6
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/rich-text/use-before-input-rules.js +11 -3
- package/build/components/rich-text/use-before-input-rules.js.map +1 -1
- package/build/components/rich-text/use-enter.js +4 -5
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/rich-text/utils.js +1 -1
- package/build/components/rich-text/utils.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +2 -8
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/tool-selector/index.js +3 -1
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/components/url-input/button.js +1 -0
- package/build/components/url-input/button.js.map +1 -1
- package/build/components/url-input/index.js +15 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +7 -8
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/url-popover/link-editor.js +1 -0
- package/build/components/url-popover/link-editor.js.map +1 -1
- package/build/components/use-block-display-information/index.js +1 -1
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-paste-styles/index.js +188 -0
- package/build/components/use-paste-styles/index.js.map +1 -0
- package/build/components/writing-flow/use-arrow-nav.js +22 -29
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/experiments.js +45 -0
- package/build/experiments.js.map +1 -0
- package/build/experiments.native.js +40 -0
- package/build/experiments.native.js.map +1 -0
- package/build/hooks/anchor.js +2 -1
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/border.js +1 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/child-layout.js +5 -1
- package/build/hooks/child-layout.js.map +1 -1
- package/build/hooks/color-panel.js +1 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +3 -3
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/custom-class-name.js +2 -1
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/dimensions.js +7 -5
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/margin.js +1 -0
- package/build/hooks/margin.js.map +1 -1
- package/build/hooks/metadata.js +1 -1
- package/build/hooks/metadata.js.map +1 -1
- package/build/hooks/padding.js +1 -0
- package/build/hooks/padding.js.map +1 -1
- package/build/hooks/position.js +395 -0
- package/build/hooks/position.js.map +1 -0
- package/build/hooks/supports.js +328 -0
- package/build/hooks/supports.js.map +1 -0
- package/build/hooks/typography.js +1 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/use-color-props.js +3 -3
- package/build/hooks/use-color-props.js.map +1 -1
- package/build/hooks/utils.js +69 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/index.js +10 -1
- package/build/index.js.map +1 -1
- package/build/layouts/constrained.js +3 -0
- package/build/layouts/constrained.js.map +1 -1
- package/build/layouts/flex.js +59 -9
- package/build/layouts/flex.js.map +1 -1
- package/build/layouts/flow.js +0 -18
- package/build/layouts/flow.js.map +1 -1
- package/build/store/actions.js +3 -30
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +5 -2
- package/build/store/defaults.js.map +1 -1
- package/build/store/index.js +11 -2
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +78 -0
- package/build/store/private-actions.js.map +1 -0
- package/build/store/private-selectors.js +18 -0
- package/build/store/private-selectors.js.map +1 -0
- package/build/store/reducer.js +7 -3
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +68 -40
- package/build/store/selectors.js.map +1 -1
- package/build/utils/block-variation-transforms.js +1 -1
- package/build/utils/block-variation-transforms.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +1 -1
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build/utils/transform-styles/index.js +1 -7
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -1
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/autocomplete/index.js +2 -6
- package/build-module/components/autocomplete/index.js.map +1 -1
- package/build-module/components/block-actions/index.js +6 -0
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-matrix-control/index.js +2 -2
- package/build-module/components/block-alignment-matrix-control/index.js.map +1 -1
- package/build-module/components/block-card/index.js +2 -4
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-edit/index.js +7 -0
- package/build-module/components/block-edit/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +17 -15
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/use-in-between-inserter.js +5 -0
- package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
- package/build-module/components/block-lock/modal.js +0 -1
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-mover/mover-description.js +2 -2
- package/build-module/components/block-mover/mover-description.js.map +1 -1
- package/build-module/components/block-navigation/dropdown.js +3 -1
- package/build-module/components/block-navigation/dropdown.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +1 -1
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-pattern-setup/use-patterns-setup.js +2 -2
- package/build-module/components/block-pattern-setup/use-patterns-setup.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +32 -3
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +9 -14
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +31 -8
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-selection-clearer/index.js +1 -1
- package/build-module/components/block-selection-clearer/index.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +6 -30
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +12 -3
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +2 -7
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +2 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-switcher/utils.js +1 -1
- package/build-module/components/block-switcher/utils.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +55 -48
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +42 -11
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/icons.js +12 -0
- package/build-module/components/block-vertical-alignment-control/icons.js.map +1 -1
- package/build-module/components/block-vertical-alignment-control/ui.js +10 -5
- package/build-module/components/block-vertical-alignment-control/ui.js.map +1 -1
- package/build-module/components/color-style-selector/index.js +3 -1
- package/build-module/components/color-style-selector/index.js.map +1 -1
- package/build-module/components/date-format-picker/index.js +4 -5
- package/build-module/components/date-format-picker/index.js.map +1 -1
- package/build-module/components/default-style-picker/index.js +1 -0
- package/build-module/components/default-style-picker/index.js.map +1 -1
- package/build-module/components/font-family/index.js +1 -6
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +1 -1
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/utils.js +1 -1
- package/build-module/components/font-sizes/utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +5 -7
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/global-styles/context.js +12 -0
- package/build-module/components/global-styles/context.js.map +1 -0
- package/build-module/components/global-styles/hooks.js +121 -0
- package/build-module/components/global-styles/hooks.js.map +1 -0
- package/build-module/components/global-styles/index.js +4 -0
- package/build-module/components/global-styles/index.js.map +1 -0
- package/build-module/components/global-styles/typography-utils.js +84 -0
- package/build-module/components/global-styles/typography-utils.js.map +1 -0
- package/build-module/components/global-styles/use-global-styles-output.js +930 -0
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -0
- package/build-module/components/global-styles/utils.js +321 -0
- package/build-module/components/global-styles/utils.js.map +1 -0
- package/build-module/components/height-control/index.js +14 -1
- package/build-module/components/height-control/index.js.map +1 -1
- package/build-module/components/iframe/index.js +36 -9
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +6 -1
- package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
- package/build-module/components/image-editor/constants.js +1 -1
- package/build-module/components/image-editor/constants.js.map +1 -1
- package/build-module/components/image-editor/context.js +1 -2
- package/build-module/components/image-editor/context.js.map +1 -1
- package/build-module/components/image-editor/cropper.js +3 -1
- package/build-module/components/image-editor/cropper.js.map +1 -1
- package/build-module/components/image-editor/index.js +13 -3
- package/build-module/components/image-editor/index.js.map +1 -1
- package/build-module/components/image-editor/use-transform-image.js +12 -37
- package/build-module/components/image-editor/use-transform-image.js.map +1 -1
- package/build-module/components/image-size-control/index.js +2 -6
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/index.js +2 -3
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +21 -32
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.native.js +9 -22
- package/build-module/components/inner-blocks/index.native.js.map +1 -1
- package/build-module/components/inner-blocks/use-block-context.js +43 -0
- package/build-module/components/inner-blocks/use-block-context.js.map +1 -0
- package/build-module/components/inserter/block-patterns-explorer/explorer.js +0 -1
- package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +11 -5
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +3 -3
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js +1 -6
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/index.js +8 -6
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +145 -56
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-list.js +74 -24
- package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-panel.js +14 -14
- package/build-module/components/inserter/media-tab/media-panel.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-tab.js +7 -4
- package/build-module/components/inserter/media-tab/media-tab.js.map +1 -1
- package/build-module/components/inserter/media-tab/utils.js +27 -15
- package/build-module/components/inserter/media-tab/utils.js.map +1 -1
- package/build-module/components/inserter/menu.js +12 -5
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/preview-panel.js +5 -3
- package/build-module/components/inserter/preview-panel.js.map +1 -1
- package/build-module/components/inserter/search-results.js +2 -6
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +1 -9
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/inspector-controls/fill.js +14 -2
- package/build-module/components/inspector-controls/fill.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +13 -1
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +7 -1
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls/index.js +2 -2
- package/build-module/components/inspector-controls/index.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +13 -1
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/inspector-controls/slot.native.js +13 -1
- package/build-module/components/inspector-controls/slot.native.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/index.js +2 -2
- package/build-module/components/inspector-controls-tabs/index.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +33 -0
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js +2 -1
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/styles-tab.js +6 -4
- package/build-module/components/inspector-controls-tabs/styles-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +20 -22
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/justify-content-control/ui.js +9 -2
- package/build-module/components/justify-content-control/ui.js.map +1 -1
- package/build-module/components/link-control/index.js +45 -16
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -0
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block.js +1 -1
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js +1 -1
- package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/media-upload/index.native.js +4 -1
- package/build-module/components/media-upload/index.native.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +46 -36
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +37 -7
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-select-button.js +9 -4
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build-module/components/off-canvas-editor/block.js +15 -52
- package/build-module/components/off-canvas-editor/block.js.map +1 -1
- package/build-module/components/off-canvas-editor/branch.js +23 -11
- package/build-module/components/off-canvas-editor/branch.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +15 -16
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/link-ui.js +2 -2
- package/build-module/components/off-canvas-editor/link-ui.js.map +1 -1
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
- package/build-module/components/off-canvas-editor/use-list-view-drop-zone.js.map +1 -1
- package/build-module/components/provider/index.js +17 -8
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +4 -4
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/rich-text/use-before-input-rules.js +10 -2
- package/build-module/components/rich-text/use-before-input-rules.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +4 -5
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/rich-text/utils.js +1 -1
- package/build-module/components/rich-text/utils.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +2 -7
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/tool-selector/index.js +3 -1
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/components/url-input/button.js +1 -0
- package/build-module/components/url-input/button.js.map +1 -1
- package/build-module/components/url-input/index.js +14 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +8 -8
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/url-popover/link-editor.js +1 -0
- package/build-module/components/url-popover/link-editor.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +1 -1
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-paste-styles/index.js +174 -0
- package/build-module/components/use-paste-styles/index.js.map +1 -0
- package/build-module/components/writing-flow/use-arrow-nav.js +22 -29
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/experiments.js +25 -0
- package/build-module/experiments.js.map +1 -0
- package/build-module/experiments.native.js +23 -0
- package/build-module/experiments.native.js.map +1 -0
- package/build-module/hooks/anchor.js +2 -1
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/border.js +1 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/child-layout.js +5 -1
- package/build-module/hooks/child-layout.js.map +1 -1
- package/build-module/hooks/color-panel.js +1 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +3 -3
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +2 -1
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/dimensions.js +6 -5
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/margin.js +1 -0
- package/build-module/hooks/margin.js.map +1 -1
- package/build-module/hooks/metadata.js +1 -1
- package/build-module/hooks/metadata.js.map +1 -1
- package/build-module/hooks/padding.js +1 -0
- package/build-module/hooks/padding.js.map +1 -1
- package/build-module/hooks/position.js +354 -0
- package/build-module/hooks/position.js.map +1 -0
- package/build-module/hooks/supports.js +257 -0
- package/build-module/hooks/supports.js.map +1 -0
- package/build-module/hooks/typography.js +1 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/use-color-props.js +3 -3
- package/build-module/hooks/use-color-props.js.map +1 -1
- package/build-module/hooks/utils.js +70 -4
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/layouts/constrained.js +3 -0
- package/build-module/layouts/constrained.js.map +1 -1
- package/build-module/layouts/flex.js +60 -10
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/layouts/flow.js +0 -18
- package/build-module/layouts/flow.js.map +1 -1
- package/build-module/store/actions.js +2 -26
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +5 -2
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/index.js +8 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +66 -0
- package/build-module/store/private-actions.js.map +1 -0
- package/build-module/store/private-selectors.js +11 -0
- package/build-module/store/private-selectors.js.map +1 -0
- package/build-module/store/reducer.js +7 -3
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +55 -30
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/block-variation-transforms.js +1 -1
- package/build-module/utils/block-variation-transforms.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +1 -1
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +1 -6
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +340 -3
- package/build-style/content.css +340 -3
- package/build-style/style-rtl.css +125 -272
- package/build-style/style.css +125 -272
- package/package.json +30 -29
- package/src/components/alignment-control/test/__snapshots__/index.js.snap +3 -3
- package/src/components/alignment-control/test/index.js +5 -15
- package/src/components/alignment-control/ui.js +1 -1
- package/src/components/autocomplete/index.js +3 -6
- package/src/components/block-actions/index.js +5 -0
- package/src/components/block-alignment-control/test/index.js +3 -11
- package/src/components/block-alignment-matrix-control/index.js +1 -2
- package/src/components/block-card/index.js +1 -4
- package/src/components/block-content-overlay/content.scss +4 -4
- package/src/components/block-edit/index.js +15 -1
- package/src/components/block-icon/content.scss +31 -0
- package/src/components/block-inspector/index.js +15 -17
- package/src/components/block-list/use-in-between-inserter.js +5 -0
- package/src/components/block-lock/modal.js +0 -1
- package/src/components/block-mover/mover-description.js +2 -2
- package/src/components/block-mover/stories/index.js +3 -3
- package/src/components/block-navigation/dropdown.js +1 -1
- package/src/components/block-pattern-setup/index.js +1 -4
- package/src/components/block-pattern-setup/use-patterns-setup.js +2 -5
- package/src/components/block-patterns-list/index.js +29 -3
- package/src/components/block-preview/README.md +9 -9
- package/src/components/block-preview/auto.js +10 -14
- package/src/components/block-preview/content.scss +23 -0
- package/src/components/block-preview/index.js +40 -10
- package/src/components/block-preview/style.scss +0 -23
- package/src/components/block-selection-clearer/index.js +1 -1
- package/src/components/block-selection-clearer/test/index.js +6 -6
- package/src/components/block-settings/container.native.js +7 -26
- package/src/components/block-settings-menu/block-settings-dropdown.js +14 -2
- package/src/components/block-settings-menu-controls/index.js +2 -10
- package/src/components/block-styles/index.js +4 -1
- package/src/components/block-switcher/test/index.js +43 -44
- package/src/components/block-switcher/utils.js +1 -1
- package/src/components/block-tools/selected-block-popover.js +77 -80
- package/src/components/block-tools/style.scss +0 -1
- package/src/components/block-tools/use-block-toolbar-popover-props.js +68 -12
- package/src/components/block-variation-picker/{style.scss → content.scss} +0 -0
- package/src/components/block-vertical-alignment-control/icons.js +12 -0
- package/src/components/block-vertical-alignment-control/test/index.js +3 -11
- package/src/components/block-vertical-alignment-control/ui.js +16 -6
- package/src/components/button-block-appender/{style.scss → content.scss} +0 -0
- package/src/components/color-style-selector/index.js +1 -1
- package/src/components/colors/test/with-colors.js +2 -8
- package/src/components/date-format-picker/index.js +23 -24
- package/src/components/date-format-picker/style.scss +0 -6
- package/src/components/default-block-appender/content.scss +18 -0
- package/src/components/default-block-appender/test/index.js +2 -8
- package/src/components/default-style-picker/index.js +1 -0
- package/src/components/font-family/index.js +1 -6
- package/src/components/font-sizes/fluid-utils.js +1 -1
- package/src/components/font-sizes/utils.js +1 -1
- package/src/components/font-sizes/with-font-sizes.js +33 -33
- package/src/components/global-styles/README.md +77 -0
- package/src/components/global-styles/context.js +15 -0
- package/src/components/global-styles/hooks.js +145 -0
- package/src/components/global-styles/index.js +7 -0
- package/src/components/global-styles/test/typography-utils.js +393 -0
- package/src/components/global-styles/test/use-global-styles-output.js +814 -0
- package/src/components/global-styles/test/utils.js +206 -0
- package/src/components/global-styles/typography-utils.js +87 -0
- package/src/components/global-styles/use-global-styles-output.js +1088 -0
- package/src/components/global-styles/utils.js +373 -0
- package/src/components/height-control/README.md +55 -0
- package/src/components/height-control/index.js +13 -1
- package/src/components/iframe/index.js +52 -19
- package/src/components/iframe/use-compatibility-styles.js +6 -0
- package/src/components/image-editor/constants.js +1 -1
- package/src/components/image-editor/context.js +5 -9
- package/src/components/image-editor/cropper.js +3 -1
- package/src/components/image-editor/index.js +13 -4
- package/src/components/image-editor/use-transform-image.js +14 -55
- package/src/components/image-size-control/index.js +2 -6
- package/src/components/index.js +2 -6
- package/src/components/inner-blocks/index.js +29 -33
- package/src/components/inner-blocks/index.native.js +27 -47
- package/src/components/inner-blocks/use-block-context.js +47 -0
- package/src/components/inserter/block-patterns-explorer/explorer.js +0 -1
- package/src/components/inserter/block-patterns-tab.js +14 -4
- package/src/components/inserter/block-types-tab.js +3 -4
- package/src/components/inserter/hooks/use-patterns-state.js +1 -6
- package/src/components/inserter/index.js +46 -42
- package/src/components/inserter/media-tab/hooks.js +167 -65
- package/src/components/inserter/media-tab/media-list.js +94 -26
- package/src/components/inserter/media-tab/media-panel.js +9 -20
- package/src/components/inserter/media-tab/media-tab.js +12 -4
- package/src/components/inserter/media-tab/utils.js +20 -10
- package/src/components/inserter/menu.js +9 -4
- package/src/components/inserter/preview-panel.js +4 -2
- package/src/components/inserter/search-results.js +2 -6
- package/src/components/inserter/stories/index.js +9 -9
- package/src/components/inserter/style.scss +58 -11
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +117 -0
- package/src/components/inserter/test/index.native.js +255 -1
- package/src/components/inserter-list-item/index.js +0 -7
- package/src/components/inspector-controls/README.md +3 -7
- package/src/components/inspector-controls/fill.js +15 -1
- package/src/components/inspector-controls/fill.native.js +14 -1
- package/src/components/inspector-controls/groups.js +5 -0
- package/src/components/inspector-controls/index.js +2 -6
- package/src/components/inspector-controls/slot.js +14 -1
- package/src/components/inspector-controls/slot.native.js +14 -1
- package/src/components/inspector-controls-tabs/advanced-controls-panel.js +1 -1
- package/src/components/inspector-controls-tabs/index.js +2 -4
- package/src/components/inspector-controls-tabs/position-controls-panel.js +37 -0
- package/src/components/inspector-controls-tabs/settings-tab.js +2 -0
- package/src/components/inspector-controls-tabs/style.scss +15 -0
- package/src/components/inspector-controls-tabs/styles-tab.js +5 -7
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +24 -18
- package/src/components/justify-content-control/ui.js +9 -0
- package/src/components/link-control/index.js +59 -23
- package/src/components/link-control/search-input.js +1 -0
- package/src/components/link-control/style.scss +8 -24
- package/src/components/link-control/test/index.js +134 -5
- package/src/components/list-view/block.js +1 -1
- package/src/components/list-view/style.scss +13 -3
- package/src/components/list-view/use-list-view-drop-zone.js +1 -1
- package/src/components/media-replace-flow/test/index.js +4 -12
- package/src/components/media-upload/index.native.js +2 -2
- package/src/components/off-canvas-editor/README.md +2 -2
- package/src/components/off-canvas-editor/appender.js +82 -76
- package/src/components/off-canvas-editor/block-contents.js +84 -23
- package/src/components/off-canvas-editor/block-select-button.js +12 -1
- package/src/components/off-canvas-editor/block.js +31 -102
- package/src/components/off-canvas-editor/branch.js +32 -5
- package/src/components/off-canvas-editor/index.js +19 -24
- package/src/components/off-canvas-editor/link-ui.js +2 -2
- package/src/components/off-canvas-editor/style.scss +5 -1
- package/src/components/off-canvas-editor/use-list-view-drop-zone.js +1 -1
- package/src/components/provider/index.js +33 -11
- package/src/components/provider/index.native.js +4 -3
- package/src/components/provider/test/experimental-provider.js +94 -0
- package/src/components/provider/test/use-block-sync.js +10 -0
- package/src/components/responsive-block-control/test/index.js +1 -5
- package/src/components/rich-text/use-before-input-rules.js +10 -2
- package/src/components/rich-text/use-enter.js +4 -4
- package/src/components/rich-text/utils.js +1 -1
- package/src/components/spacing-sizes-control/utils.js +2 -7
- package/src/components/tool-selector/index.js +1 -1
- package/src/components/url-input/README.md +5 -0
- package/src/components/url-input/button.js +1 -0
- package/src/components/url-input/index.js +15 -1
- package/src/components/url-input/test/button.js +24 -24
- package/src/components/url-popover/image-url-input-ui.js +7 -8
- package/src/components/url-popover/link-editor.js +1 -0
- package/src/components/url-popover/style.scss +0 -10
- package/src/components/use-block-display-information/index.js +1 -1
- package/src/components/use-paste-styles/index.js +230 -0
- package/src/components/warning/{style.scss → content.scss} +0 -0
- package/src/components/warning/test/index.js +1 -5
- package/src/components/writing-flow/use-arrow-nav.js +20 -28
- package/src/content.scss +8 -0
- package/src/experiments.js +27 -0
- package/src/experiments.native.js +25 -0
- package/src/hooks/anchor.js +2 -1
- package/src/hooks/border.js +1 -1
- package/src/hooks/child-layout.js +6 -1
- package/src/hooks/color-panel.js +1 -1
- package/src/hooks/color.js +3 -3
- package/src/hooks/custom-class-name.js +2 -1
- package/src/hooks/dimensions.js +6 -6
- package/src/hooks/index.js +1 -0
- package/src/hooks/layout.scss +4 -0
- package/src/hooks/margin.js +1 -0
- package/src/hooks/metadata.js +1 -2
- package/src/hooks/padding.js +1 -0
- package/src/hooks/position.js +391 -0
- package/src/hooks/position.scss +18 -0
- package/src/hooks/supports.js +302 -0
- package/src/hooks/test/__snapshots__/align.native.js.snap +73 -0
- package/src/hooks/test/align.native.js +133 -0
- package/src/hooks/test/utils.js +104 -0
- package/src/hooks/typography.js +1 -1
- package/src/hooks/use-color-props.js +3 -3
- package/src/hooks/utils.js +68 -2
- package/src/index.js +1 -0
- package/src/layouts/constrained.js +3 -0
- package/src/layouts/flex.js +66 -14
- package/src/layouts/flow.js +0 -9
- package/src/store/actions.js +2 -26
- package/src/store/defaults.js +7 -2
- package/src/store/index.js +8 -2
- package/src/store/private-actions.js +65 -0
- package/src/store/private-selectors.js +10 -0
- package/src/store/reducer.js +8 -3
- package/src/store/selectors.js +108 -57
- package/src/store/test/actions.js +0 -18
- package/src/store/test/private-actions.js +22 -0
- package/src/store/test/private-selectors.js +24 -0
- package/src/store/test/reducer.js +45 -3
- package/src/store/test/selectors.js +64 -39
- package/src/style.scss +5 -6
- package/src/utils/block-variation-transforms.js +1 -1
- package/src/utils/parse-css-unit-to-px.js +3 -1
- package/src/utils/test/parse-css-unit-to-px.js +16 -24
- package/src/utils/transform-styles/index.js +1 -6
- package/build/components/inner-blocks/get-block-context.js +0 -45
- package/build/components/inner-blocks/get-block-context.js.map +0 -1
- package/build/components/off-canvas-editor/block-edit-button.js +0 -50
- package/build/components/off-canvas-editor/block-edit-button.js.map +0 -1
- package/build-module/components/inner-blocks/get-block-context.js +0 -37
- package/build-module/components/inner-blocks/get-block-context.js.map +0 -1
- package/build-module/components/off-canvas-editor/block-edit-button.js +0 -35
- package/build-module/components/off-canvas-editor/block-edit-button.js.map +0 -1
- package/src/components/inner-blocks/get-block-context.js +0 -39
- package/src/components/off-canvas-editor/block-edit-button.js +0 -27
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { get } from 'lodash';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { getTypographyFontSizeValue } from './typography-utils';
|
|
10
|
+
|
|
11
|
+
/* Supporting data. */
|
|
12
|
+
export const ROOT_BLOCK_NAME = 'root';
|
|
13
|
+
export const ROOT_BLOCK_SELECTOR = 'body';
|
|
14
|
+
export const ROOT_BLOCK_SUPPORTS = [
|
|
15
|
+
'background',
|
|
16
|
+
'backgroundColor',
|
|
17
|
+
'color',
|
|
18
|
+
'linkColor',
|
|
19
|
+
'buttonColor',
|
|
20
|
+
'fontFamily',
|
|
21
|
+
'fontSize',
|
|
22
|
+
'fontStyle',
|
|
23
|
+
'fontWeight',
|
|
24
|
+
'lineHeight',
|
|
25
|
+
'textDecoration',
|
|
26
|
+
'textTransform',
|
|
27
|
+
'padding',
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
export const PRESET_METADATA = [
|
|
31
|
+
{
|
|
32
|
+
path: [ 'color', 'palette' ],
|
|
33
|
+
valueKey: 'color',
|
|
34
|
+
cssVarInfix: 'color',
|
|
35
|
+
classes: [
|
|
36
|
+
{ classSuffix: 'color', propertyName: 'color' },
|
|
37
|
+
{
|
|
38
|
+
classSuffix: 'background-color',
|
|
39
|
+
propertyName: 'background-color',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
classSuffix: 'border-color',
|
|
43
|
+
propertyName: 'border-color',
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
path: [ 'color', 'gradients' ],
|
|
49
|
+
valueKey: 'gradient',
|
|
50
|
+
cssVarInfix: 'gradient',
|
|
51
|
+
classes: [
|
|
52
|
+
{
|
|
53
|
+
classSuffix: 'gradient-background',
|
|
54
|
+
propertyName: 'background',
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
path: [ 'color', 'duotone' ],
|
|
60
|
+
cssVarInfix: 'duotone',
|
|
61
|
+
valueFunc: ( { slug } ) => `url( '#wp-duotone-${ slug }' )`,
|
|
62
|
+
classes: [],
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
path: [ 'shadow', 'presets' ],
|
|
66
|
+
valueKey: 'shadow',
|
|
67
|
+
cssVarInfix: 'shadow',
|
|
68
|
+
classes: [],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
path: [ 'typography', 'fontSizes' ],
|
|
72
|
+
valueFunc: ( preset, { typography: typographySettings } ) =>
|
|
73
|
+
getTypographyFontSizeValue( preset, typographySettings ),
|
|
74
|
+
valueKey: 'size',
|
|
75
|
+
cssVarInfix: 'font-size',
|
|
76
|
+
classes: [ { classSuffix: 'font-size', propertyName: 'font-size' } ],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
path: [ 'typography', 'fontFamilies' ],
|
|
80
|
+
valueKey: 'fontFamily',
|
|
81
|
+
cssVarInfix: 'font-family',
|
|
82
|
+
classes: [
|
|
83
|
+
{ classSuffix: 'font-family', propertyName: 'font-family' },
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
path: [ 'spacing', 'spacingSizes' ],
|
|
88
|
+
valueKey: 'size',
|
|
89
|
+
cssVarInfix: 'spacing',
|
|
90
|
+
valueFunc: ( { size } ) => size,
|
|
91
|
+
classes: [],
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
export const STYLE_PATH_TO_CSS_VAR_INFIX = {
|
|
96
|
+
'color.background': 'color',
|
|
97
|
+
'color.text': 'color',
|
|
98
|
+
'elements.link.color.text': 'color',
|
|
99
|
+
'elements.link.:hover.color.text': 'color',
|
|
100
|
+
'elements.link.typography.fontFamily': 'font-family',
|
|
101
|
+
'elements.link.typography.fontSize': 'font-size',
|
|
102
|
+
'elements.button.color.text': 'color',
|
|
103
|
+
'elements.button.color.background': 'color',
|
|
104
|
+
'elements.button.typography.fontFamily': 'font-family',
|
|
105
|
+
'elements.button.typography.fontSize': 'font-size',
|
|
106
|
+
'elements.heading.color': 'color',
|
|
107
|
+
'elements.heading.color.background': 'color',
|
|
108
|
+
'elements.heading.typography.fontFamily': 'font-family',
|
|
109
|
+
'elements.heading.gradient': 'gradient',
|
|
110
|
+
'elements.heading.color.gradient': 'gradient',
|
|
111
|
+
'elements.h1.color': 'color',
|
|
112
|
+
'elements.h1.color.background': 'color',
|
|
113
|
+
'elements.h1.typography.fontFamily': 'font-family',
|
|
114
|
+
'elements.h1.color.gradient': 'gradient',
|
|
115
|
+
'elements.h2.color': 'color',
|
|
116
|
+
'elements.h2.color.background': 'color',
|
|
117
|
+
'elements.h2.typography.fontFamily': 'font-family',
|
|
118
|
+
'elements.h2.color.gradient': 'gradient',
|
|
119
|
+
'elements.h3.color': 'color',
|
|
120
|
+
'elements.h3.color.background': 'color',
|
|
121
|
+
'elements.h3.typography.fontFamily': 'font-family',
|
|
122
|
+
'elements.h3.color.gradient': 'gradient',
|
|
123
|
+
'elements.h4.color': 'color',
|
|
124
|
+
'elements.h4.color.background': 'color',
|
|
125
|
+
'elements.h4.typography.fontFamily': 'font-family',
|
|
126
|
+
'elements.h4.color.gradient': 'gradient',
|
|
127
|
+
'elements.h5.color': 'color',
|
|
128
|
+
'elements.h5.color.background': 'color',
|
|
129
|
+
'elements.h5.typography.fontFamily': 'font-family',
|
|
130
|
+
'elements.h5.color.gradient': 'gradient',
|
|
131
|
+
'elements.h6.color': 'color',
|
|
132
|
+
'elements.h6.color.background': 'color',
|
|
133
|
+
'elements.h6.typography.fontFamily': 'font-family',
|
|
134
|
+
'elements.h6.color.gradient': 'gradient',
|
|
135
|
+
'color.gradient': 'gradient',
|
|
136
|
+
shadow: 'shadow',
|
|
137
|
+
'typography.fontSize': 'font-size',
|
|
138
|
+
'typography.fontFamily': 'font-family',
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// A static list of block attributes that store global style preset slugs.
|
|
142
|
+
export const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
|
|
143
|
+
'color.background': 'backgroundColor',
|
|
144
|
+
'color.text': 'textColor',
|
|
145
|
+
'color.gradient': 'gradient',
|
|
146
|
+
'typography.fontSize': 'fontSize',
|
|
147
|
+
'typography.fontFamily': 'fontFamily',
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
function findInPresetsBy(
|
|
151
|
+
features,
|
|
152
|
+
blockName,
|
|
153
|
+
presetPath,
|
|
154
|
+
presetProperty,
|
|
155
|
+
presetValueValue
|
|
156
|
+
) {
|
|
157
|
+
// Block presets take priority above root level presets.
|
|
158
|
+
const orderedPresetsByOrigin = [
|
|
159
|
+
get( features, [ 'blocks', blockName, ...presetPath ] ),
|
|
160
|
+
get( features, presetPath ),
|
|
161
|
+
];
|
|
162
|
+
|
|
163
|
+
for ( const presetByOrigin of orderedPresetsByOrigin ) {
|
|
164
|
+
if ( presetByOrigin ) {
|
|
165
|
+
// Preset origins ordered by priority.
|
|
166
|
+
const origins = [ 'custom', 'theme', 'default' ];
|
|
167
|
+
for ( const origin of origins ) {
|
|
168
|
+
const presets = presetByOrigin[ origin ];
|
|
169
|
+
if ( presets ) {
|
|
170
|
+
const presetObject = presets.find(
|
|
171
|
+
( preset ) =>
|
|
172
|
+
preset[ presetProperty ] === presetValueValue
|
|
173
|
+
);
|
|
174
|
+
if ( presetObject ) {
|
|
175
|
+
if ( presetProperty === 'slug' ) {
|
|
176
|
+
return presetObject;
|
|
177
|
+
}
|
|
178
|
+
// If there is a highest priority preset with the same slug but different value the preset we found was overwritten and should be ignored.
|
|
179
|
+
const highestPresetObjectWithSameSlug = findInPresetsBy(
|
|
180
|
+
features,
|
|
181
|
+
blockName,
|
|
182
|
+
presetPath,
|
|
183
|
+
'slug',
|
|
184
|
+
presetObject.slug
|
|
185
|
+
);
|
|
186
|
+
if (
|
|
187
|
+
highestPresetObjectWithSameSlug[
|
|
188
|
+
presetProperty
|
|
189
|
+
] === presetObject[ presetProperty ]
|
|
190
|
+
) {
|
|
191
|
+
return presetObject;
|
|
192
|
+
}
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export function getPresetVariableFromValue(
|
|
202
|
+
features,
|
|
203
|
+
blockName,
|
|
204
|
+
variableStylePath,
|
|
205
|
+
presetPropertyValue
|
|
206
|
+
) {
|
|
207
|
+
if ( ! presetPropertyValue ) {
|
|
208
|
+
return presetPropertyValue;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const cssVarInfix = STYLE_PATH_TO_CSS_VAR_INFIX[ variableStylePath ];
|
|
212
|
+
|
|
213
|
+
const metadata = PRESET_METADATA.find(
|
|
214
|
+
( data ) => data.cssVarInfix === cssVarInfix
|
|
215
|
+
);
|
|
216
|
+
|
|
217
|
+
if ( ! metadata ) {
|
|
218
|
+
// The property doesn't have preset data
|
|
219
|
+
// so the value should be returned as it is.
|
|
220
|
+
return presetPropertyValue;
|
|
221
|
+
}
|
|
222
|
+
const { valueKey, path } = metadata;
|
|
223
|
+
|
|
224
|
+
const presetObject = findInPresetsBy(
|
|
225
|
+
features,
|
|
226
|
+
blockName,
|
|
227
|
+
path,
|
|
228
|
+
valueKey,
|
|
229
|
+
presetPropertyValue
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
if ( ! presetObject ) {
|
|
233
|
+
// Value wasn't found in the presets,
|
|
234
|
+
// so it must be a custom value.
|
|
235
|
+
return presetPropertyValue;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return `var:preset|${ cssVarInfix }|${ presetObject.slug }`;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function getValueFromPresetVariable(
|
|
242
|
+
features,
|
|
243
|
+
blockName,
|
|
244
|
+
variable,
|
|
245
|
+
[ presetType, slug ]
|
|
246
|
+
) {
|
|
247
|
+
const metadata = PRESET_METADATA.find(
|
|
248
|
+
( data ) => data.cssVarInfix === presetType
|
|
249
|
+
);
|
|
250
|
+
if ( ! metadata ) {
|
|
251
|
+
return variable;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const presetObject = findInPresetsBy(
|
|
255
|
+
features.settings,
|
|
256
|
+
blockName,
|
|
257
|
+
metadata.path,
|
|
258
|
+
'slug',
|
|
259
|
+
slug
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
if ( presetObject ) {
|
|
263
|
+
const { valueKey } = metadata;
|
|
264
|
+
const result = presetObject[ valueKey ];
|
|
265
|
+
return getValueFromVariable( features, blockName, result );
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return variable;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function getValueFromCustomVariable( features, blockName, variable, path ) {
|
|
272
|
+
const result =
|
|
273
|
+
get( features.settings, [ 'blocks', blockName, 'custom', ...path ] ) ??
|
|
274
|
+
get( features.settings, [ 'custom', ...path ] );
|
|
275
|
+
if ( ! result ) {
|
|
276
|
+
return variable;
|
|
277
|
+
}
|
|
278
|
+
// A variable may reference another variable so we need recursion until we find the value.
|
|
279
|
+
return getValueFromVariable( features, blockName, result );
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Attempts to fetch the value of a theme.json CSS variable.
|
|
284
|
+
*
|
|
285
|
+
* @param {Object} features GlobalStylesContext config, e.g., user, base or merged. Represents the theme.json tree.
|
|
286
|
+
* @param {string} blockName The name of a block as represented in the styles property. E.g., 'root' for root-level, and 'core/${blockName}' for blocks.
|
|
287
|
+
* @param {string|*} variable An incoming style value. A CSS var value is expected, but it could be any value.
|
|
288
|
+
* @return {string|*|{ref}} The value of the CSS var, if found. If not found, the passed variable argument.
|
|
289
|
+
*/
|
|
290
|
+
export function getValueFromVariable( features, blockName, variable ) {
|
|
291
|
+
if ( ! variable || typeof variable !== 'string' ) {
|
|
292
|
+
if ( variable?.ref && typeof variable?.ref === 'string' ) {
|
|
293
|
+
const refPath = variable.ref.split( '.' );
|
|
294
|
+
variable = get( features, refPath );
|
|
295
|
+
// Presence of another ref indicates a reference to another dynamic value.
|
|
296
|
+
// Pointing to another dynamic value is not supported.
|
|
297
|
+
if ( ! variable || !! variable?.ref ) {
|
|
298
|
+
return variable;
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
return variable;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
const USER_VALUE_PREFIX = 'var:';
|
|
305
|
+
const THEME_VALUE_PREFIX = 'var(--wp--';
|
|
306
|
+
const THEME_VALUE_SUFFIX = ')';
|
|
307
|
+
|
|
308
|
+
let parsedVar;
|
|
309
|
+
|
|
310
|
+
if ( variable.startsWith( USER_VALUE_PREFIX ) ) {
|
|
311
|
+
parsedVar = variable.slice( USER_VALUE_PREFIX.length ).split( '|' );
|
|
312
|
+
} else if (
|
|
313
|
+
variable.startsWith( THEME_VALUE_PREFIX ) &&
|
|
314
|
+
variable.endsWith( THEME_VALUE_SUFFIX )
|
|
315
|
+
) {
|
|
316
|
+
parsedVar = variable
|
|
317
|
+
.slice( THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length )
|
|
318
|
+
.split( '--' );
|
|
319
|
+
} else {
|
|
320
|
+
// We don't know how to parse the value: either is raw of uses complex CSS such as `calc(1px * var(--wp--variable) )`
|
|
321
|
+
return variable;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const [ type, ...path ] = parsedVar;
|
|
325
|
+
if ( type === 'preset' ) {
|
|
326
|
+
return getValueFromPresetVariable(
|
|
327
|
+
features,
|
|
328
|
+
blockName,
|
|
329
|
+
variable,
|
|
330
|
+
path
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
if ( type === 'custom' ) {
|
|
334
|
+
return getValueFromCustomVariable(
|
|
335
|
+
features,
|
|
336
|
+
blockName,
|
|
337
|
+
variable,
|
|
338
|
+
path
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
return variable;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Function that scopes a selector with another one. This works a bit like
|
|
346
|
+
* SCSS nesting except the `&` operator isn't supported.
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```js
|
|
350
|
+
* const scope = '.a, .b .c';
|
|
351
|
+
* const selector = '> .x, .y';
|
|
352
|
+
* const merged = scopeSelector( scope, selector );
|
|
353
|
+
* // merged is '.a > .x, .a .y, .b .c > .x, .b .c .y'
|
|
354
|
+
* ```
|
|
355
|
+
*
|
|
356
|
+
* @param {string} scope Selector to scope to.
|
|
357
|
+
* @param {string} selector Original selector.
|
|
358
|
+
*
|
|
359
|
+
* @return {string} Scoped selector.
|
|
360
|
+
*/
|
|
361
|
+
export function scopeSelector( scope, selector ) {
|
|
362
|
+
const scopes = scope.split( ',' );
|
|
363
|
+
const selectors = selector.split( ',' );
|
|
364
|
+
|
|
365
|
+
const selectorsScoped = [];
|
|
366
|
+
scopes.forEach( ( outer ) => {
|
|
367
|
+
selectors.forEach( ( inner ) => {
|
|
368
|
+
selectorsScoped.push( `${ outer.trim() } ${ inner.trim() }` );
|
|
369
|
+
} );
|
|
370
|
+
} );
|
|
371
|
+
|
|
372
|
+
return selectorsScoped.join( ', ' );
|
|
373
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Height Control
|
|
2
|
+
|
|
3
|
+
The `HeightControl` component adds a linked unit control and slider component for controlling the height of a block within the block editor. It supports passing a label, and is used for controlling the minimum height dimensions of Group blocks.
|
|
4
|
+
|
|
5
|
+
_Note:_ It is worth noting that the minimum height option is an opt-in feature. Themes need to declare support for it before it'll be available, and a convenient way to do that is via opting in to the [appearanceTools](/docs/how-to-guides/themes/theme-json/#opt-in-into-ui-controls) UI controls.
|
|
6
|
+
|
|
7
|
+
## Table of contents
|
|
8
|
+
|
|
9
|
+
1. [Development guidelines](#development-guidelines)
|
|
10
|
+
2. [Related components](#related-components)
|
|
11
|
+
|
|
12
|
+
## Development guidelines
|
|
13
|
+
|
|
14
|
+
### Usage
|
|
15
|
+
|
|
16
|
+
Renders the markup for height control component, to be used in the block inspector.
|
|
17
|
+
|
|
18
|
+
```jsx
|
|
19
|
+
import { HeightControl } from '@wordpress/block-editor';
|
|
20
|
+
import { useState } from '@wordpress/element';
|
|
21
|
+
|
|
22
|
+
const MyLineHeightControl = () => (
|
|
23
|
+
const [ value, setValue ] = useState();
|
|
24
|
+
<HeightControl
|
|
25
|
+
label={ 'My Height Control' }
|
|
26
|
+
onChange={ setValue }
|
|
27
|
+
value={ value }
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Props
|
|
33
|
+
|
|
34
|
+
#### `value`
|
|
35
|
+
|
|
36
|
+
- **Type:** `String` or `Number` or `Undefined`
|
|
37
|
+
|
|
38
|
+
The value of the current height.
|
|
39
|
+
|
|
40
|
+
#### `onChange`
|
|
41
|
+
|
|
42
|
+
- **Type:** `Function`
|
|
43
|
+
|
|
44
|
+
A callback function that handles the application of the height value.
|
|
45
|
+
|
|
46
|
+
#### `label`
|
|
47
|
+
|
|
48
|
+
- **Type:** `String`
|
|
49
|
+
- **Default:** `'Height'`
|
|
50
|
+
|
|
51
|
+
A label for the height control. This is useful when using the height control for a feature that is controlled in the same way as height, but requires a different label. For example, "Min. height".
|
|
52
|
+
|
|
53
|
+
## Related components
|
|
54
|
+
|
|
55
|
+
Block Editor components are components that can be used to compose the UI of your block editor. Thus, they can only be used under a [`BlockEditorProvider`](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/provider/README.md) in the components tree.
|
|
@@ -28,9 +28,21 @@ const RANGE_CONTROL_CUSTOM_SETTINGS = {
|
|
|
28
28
|
rem: { max: 50, step: 0.1 },
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* HeightControl renders a linked unit control and range control for adjusting the height of a block.
|
|
33
|
+
*
|
|
34
|
+
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/height-control/README.md
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} props
|
|
37
|
+
* @param {?string} props.label A label for the control.
|
|
38
|
+
* @param {( value: string ) => void } props.onChange Called when the height changes.
|
|
39
|
+
* @param {string} props.value The current height value.
|
|
40
|
+
*
|
|
41
|
+
* @return {WPComponent} The component to be rendered.
|
|
42
|
+
*/
|
|
31
43
|
export default function HeightControl( {
|
|
32
|
-
onChange,
|
|
33
44
|
label = __( 'Height' ),
|
|
45
|
+
onChange,
|
|
34
46
|
value,
|
|
35
47
|
} ) {
|
|
36
48
|
const customRangeValue = parseFloat( value );
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
forwardRef,
|
|
13
13
|
useMemo,
|
|
14
14
|
useReducer,
|
|
15
|
+
renderToString,
|
|
15
16
|
} from '@wordpress/element';
|
|
16
17
|
import { __ } from '@wordpress/i18n';
|
|
17
18
|
import {
|
|
@@ -20,6 +21,7 @@ import {
|
|
|
20
21
|
useRefEffect,
|
|
21
22
|
} from '@wordpress/compose';
|
|
22
23
|
import { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';
|
|
24
|
+
import { useSelect } from '@wordpress/data';
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Internal dependencies
|
|
@@ -27,6 +29,7 @@ import { __experimentalStyleProvider as StyleProvider } from '@wordpress/compone
|
|
|
27
29
|
import { useBlockSelectionClearer } from '../block-selection-clearer';
|
|
28
30
|
import { useWritingFlow } from '../writing-flow';
|
|
29
31
|
import { useCompatibilityStyles } from './use-compatibility-styles';
|
|
32
|
+
import { store as blockEditorStore } from '../../store';
|
|
30
33
|
|
|
31
34
|
/**
|
|
32
35
|
* Bubbles some event types (keydown, keypress, and dragover) to parent document
|
|
@@ -97,20 +100,22 @@ async function loadScript( head, { id, src } ) {
|
|
|
97
100
|
} );
|
|
98
101
|
}
|
|
99
102
|
|
|
100
|
-
function Iframe(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
)
|
|
103
|
+
function Iframe( {
|
|
104
|
+
contentRef,
|
|
105
|
+
children,
|
|
106
|
+
head,
|
|
107
|
+
tabIndex = 0,
|
|
108
|
+
scale = 1,
|
|
109
|
+
frameSize = 0,
|
|
110
|
+
readonly,
|
|
111
|
+
forwardedRef: ref,
|
|
112
|
+
...props
|
|
113
|
+
} ) {
|
|
114
|
+
const assets = useSelect(
|
|
115
|
+
( select ) =>
|
|
116
|
+
select( blockEditorStore ).getSettings().__unstableResolvedAssets,
|
|
117
|
+
[]
|
|
118
|
+
);
|
|
114
119
|
const [ , forceRender ] = useReducer( () => ( {} ) );
|
|
115
120
|
const [ iframeDocument, setIframeDocument ] = useState();
|
|
116
121
|
const [ bodyClasses, setBodyClasses ] = useState( [] );
|
|
@@ -204,7 +209,7 @@ function Iframe(
|
|
|
204
209
|
}, [] );
|
|
205
210
|
const bodyRef = useMergeRefs( [ contentRef, clearerRef, writingFlowRef ] );
|
|
206
211
|
|
|
207
|
-
|
|
212
|
+
const styleAssets = (
|
|
208
213
|
<>
|
|
209
214
|
<style>{ 'html{height:auto!important;}body{margin:0}' }</style>
|
|
210
215
|
{ [ ...styles, ...neededCompatStyles ].map(
|
|
@@ -224,10 +229,16 @@ function Iframe(
|
|
|
224
229
|
);
|
|
225
230
|
}
|
|
226
231
|
) }
|
|
227
|
-
{ head }
|
|
228
232
|
</>
|
|
229
233
|
);
|
|
230
234
|
|
|
235
|
+
// Correct doctype is required to enable rendering in standards
|
|
236
|
+
// mode. Also preload the styles to avoid a flash of unstyled
|
|
237
|
+
// content.
|
|
238
|
+
const srcDoc = useMemo( () => {
|
|
239
|
+
return '<!doctype html>' + renderToString( styleAssets );
|
|
240
|
+
}, [] );
|
|
241
|
+
|
|
231
242
|
return (
|
|
232
243
|
<>
|
|
233
244
|
{ tabIndex >= 0 && before }
|
|
@@ -235,14 +246,17 @@ function Iframe(
|
|
|
235
246
|
{ ...props }
|
|
236
247
|
ref={ useMergeRefs( [ ref, setRef ] ) }
|
|
237
248
|
tabIndex={ tabIndex }
|
|
238
|
-
// Correct doctype is required to enable rendering in standards
|
|
239
|
-
|
|
249
|
+
// Correct doctype is required to enable rendering in standards
|
|
250
|
+
// mode. Also preload the styles to avoid a flash of unstyled
|
|
251
|
+
// content.
|
|
252
|
+
srcDoc={ srcDoc }
|
|
240
253
|
title={ __( 'Editor canvas' ) }
|
|
241
254
|
>
|
|
242
255
|
{ iframeDocument &&
|
|
243
256
|
createPortal(
|
|
244
257
|
<>
|
|
245
258
|
<head ref={ headRef }>
|
|
259
|
+
{ styleAssets }
|
|
246
260
|
{ head }
|
|
247
261
|
<style>
|
|
248
262
|
{ `html { transition: background 5s; ${
|
|
@@ -286,4 +300,23 @@ function Iframe(
|
|
|
286
300
|
);
|
|
287
301
|
}
|
|
288
302
|
|
|
289
|
-
|
|
303
|
+
function IframeIfReady( props, ref ) {
|
|
304
|
+
const isInitialised = useSelect(
|
|
305
|
+
( select ) =>
|
|
306
|
+
select( blockEditorStore ).getSettings().__internalIsInitialized,
|
|
307
|
+
[]
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
// We shouldn't render the iframe until the editor settings are initialised.
|
|
311
|
+
// The initial settings are needed to get the styles for the srcDoc, which
|
|
312
|
+
// cannot be changed after the iframe is mounted. srcDoc is used to to set
|
|
313
|
+
// the initial iframe HTML, which is required to avoid a flash of unstyled
|
|
314
|
+
// content.
|
|
315
|
+
if ( ! isInitialised ) {
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return <Iframe { ...props } forwardedRef={ ref } />;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export default forwardRef( IframeIfReady );
|
|
@@ -28,6 +28,12 @@ export function useCompatibilityStyles() {
|
|
|
28
28
|
|
|
29
29
|
const { ownerNode, cssRules } = styleSheet;
|
|
30
30
|
|
|
31
|
+
// Stylesheet is added by another stylesheet. See
|
|
32
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/StyleSheet/ownerNode#notes.
|
|
33
|
+
if ( ownerNode === null ) {
|
|
34
|
+
return accumulator;
|
|
35
|
+
}
|
|
36
|
+
|
|
31
37
|
if ( ! cssRules ) {
|
|
32
38
|
return accumulator;
|
|
33
39
|
}
|
|
@@ -18,19 +18,15 @@ export default function ImageEditingProvider( {
|
|
|
18
18
|
url,
|
|
19
19
|
naturalWidth,
|
|
20
20
|
naturalHeight,
|
|
21
|
-
isEditing,
|
|
22
21
|
onFinishEditing,
|
|
23
22
|
onSaveImage,
|
|
24
23
|
children,
|
|
25
24
|
} ) {
|
|
26
|
-
const transformImage = useTransformImage(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
isEditing
|
|
33
|
-
);
|
|
25
|
+
const transformImage = useTransformImage( {
|
|
26
|
+
url,
|
|
27
|
+
naturalWidth,
|
|
28
|
+
naturalHeight,
|
|
29
|
+
} );
|
|
34
30
|
|
|
35
31
|
const saveImage = useSaveImage( {
|
|
36
32
|
id,
|
|
@@ -66,7 +66,9 @@ export default function ImageCropper( {
|
|
|
66
66
|
crop={ position }
|
|
67
67
|
zoom={ zoom / 100 }
|
|
68
68
|
aspect={ aspect }
|
|
69
|
-
onCropChange={
|
|
69
|
+
onCropChange={ ( pos ) => {
|
|
70
|
+
setPosition( pos );
|
|
71
|
+
} }
|
|
70
72
|
onCropComplete={ ( newCropPercent ) => {
|
|
71
73
|
setCrop( newCropPercent );
|
|
72
74
|
} }
|
|
@@ -7,6 +7,7 @@ import { ToolbarGroup, ToolbarItem } from '@wordpress/components';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import BlockControls from '../block-controls';
|
|
10
|
+
import ImageEditingProvider from './context';
|
|
10
11
|
import Cropper from './cropper';
|
|
11
12
|
import ZoomDropdown from './zoom-dropdown';
|
|
12
13
|
import AspectRatioDropdown from './aspect-ratio-dropdown';
|
|
@@ -14,16 +15,26 @@ import RotationButton from './rotation-button';
|
|
|
14
15
|
import FormControls from './form-controls';
|
|
15
16
|
|
|
16
17
|
export default function ImageEditor( {
|
|
18
|
+
id,
|
|
17
19
|
url,
|
|
18
20
|
width,
|
|
19
21
|
height,
|
|
20
22
|
clientWidth,
|
|
21
23
|
naturalHeight,
|
|
22
24
|
naturalWidth,
|
|
25
|
+
onSaveImage,
|
|
26
|
+
onFinishEditing,
|
|
23
27
|
borderProps,
|
|
24
28
|
} ) {
|
|
25
29
|
return (
|
|
26
|
-
|
|
30
|
+
<ImageEditingProvider
|
|
31
|
+
id={ id }
|
|
32
|
+
url={ url }
|
|
33
|
+
naturalWidth={ naturalWidth }
|
|
34
|
+
naturalHeight={ naturalHeight }
|
|
35
|
+
onSaveImage={ onSaveImage }
|
|
36
|
+
onFinishEditing={ onFinishEditing }
|
|
37
|
+
>
|
|
27
38
|
<Cropper
|
|
28
39
|
borderProps={ borderProps }
|
|
29
40
|
url={ url }
|
|
@@ -47,8 +58,6 @@ export default function ImageEditor( {
|
|
|
47
58
|
<FormControls />
|
|
48
59
|
</ToolbarGroup>
|
|
49
60
|
</BlockControls>
|
|
50
|
-
|
|
61
|
+
</ImageEditingProvider>
|
|
51
62
|
);
|
|
52
63
|
}
|
|
53
|
-
|
|
54
|
-
export { default as ImageEditingProvider } from './context';
|