@wordpress/block-editor 12.25.0 → 12.26.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 +9 -3
- package/README.md +6 -0
- package/build/components/block-actions/index.js +4 -2
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-control/ui.js +2 -2
- package/build/components/block-alignment-control/ui.js.map +1 -1
- package/build/components/block-card/index.js +2 -2
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-compare/index.js +2 -2
- package/build/components/block-compare/index.js.map +1 -1
- package/build/components/block-edit/edit.js +2 -2
- package/build/components/block-edit/edit.js.map +1 -1
- package/build/components/block-icon/index.js +2 -2
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +1 -1
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.js +4 -4
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +2 -2
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-list/index.js +2 -2
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-list/use-block-props/index.js +5 -2
- package/build/components/block-list/use-block-props/index.js.map +1 -1
- package/build/components/block-list/use-block-props/use-scroll-into-view.js +44 -0
- package/build/components/block-list/use-block-props/use-scroll-into-view.js.map +1 -0
- package/build/components/block-list-appender/index.js +2 -2
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-mover/button.js +2 -2
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +2 -2
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +26 -5
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-popover/cover.js +9 -6
- package/build/components/block-popover/cover.js.map +1 -1
- package/build/components/block-popover/inbetween.js +2 -2
- package/build/components/block-popover/inbetween.js.map +1 -1
- package/build/components/block-popover/index.js +22 -4
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/index.js +2 -2
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +8 -5
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +10 -7
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-styles/index.js +2 -2
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +3 -3
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +2 -2
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/block-toolbar-breadcrumb.js +4 -4
- package/build/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
- package/build/components/block-tools/block-toolbar-popover.js +2 -2
- package/build/components/block-tools/block-toolbar-popover.js.map +1 -1
- package/build/components/block-tools/empty-block-inserter.js +2 -2
- package/build/components/block-tools/empty-block-inserter.js.map +1 -1
- package/build/components/block-tools/index.js +20 -1
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +4 -4
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/zoom-out-mode-inserters.js +66 -22
- package/build/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build/components/block-variation-picker/index.js +2 -2
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/button-block-appender/index.js +2 -2
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/child-layout-control/index.js +2 -2
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/colors-gradients/control.js +3 -3
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +2 -2
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -2
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/convert-to-group-buttons/index.js +6 -0
- package/build/components/convert-to-group-buttons/index.js.map +1 -1
- package/build/components/default-block-appender/index.js +2 -2
- package/build/components/default-block-appender/index.js.map +1 -1
- package/build/components/dimensions-tool/aspect-ratio-tool.js +30 -36
- package/build/components/dimensions-tool/aspect-ratio-tool.js.map +1 -1
- package/build/components/global-styles/background-panel.js +3 -3
- package/build/components/global-styles/background-panel.js.map +1 -1
- package/build/components/global-styles/color-panel.js +3 -3
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +4 -4
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/filters-panel.js +2 -2
- package/build/components/global-styles/filters-panel.js.map +1 -1
- package/build/components/global-styles/shadow-panel-components.js +4 -4
- package/build/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +1 -1
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/grid-visualizer/grid-item-resizer.js +141 -24
- package/build/components/grid-visualizer/grid-item-resizer.js.map +1 -1
- package/build/components/grid-visualizer/grid-visualizer.js +11 -5
- package/build/components/grid-visualizer/grid-visualizer.js.map +1 -1
- package/build/components/iframe/index.js +69 -30
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/image-editor/aspect-ratio-dropdown.js +53 -36
- package/build/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build/components/image-editor/cropper.js +2 -2
- package/build/components/image-editor/cropper.js.map +1 -1
- package/build/components/image-editor/index.js +1 -1
- package/build/components/image-editor/index.js.map +1 -1
- package/build/components/index.js +8 -0
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/button-block-appender.js +2 -2
- package/build/components/inner-blocks/button-block-appender.js.map +1 -1
- package/build/components/inner-blocks/index.js +22 -21
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/index.js +9 -0
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build/components/inserter/block-types-tab.js +5 -3
- package/build/components/inserter/block-types-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +11 -2
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-state.js +12 -5
- package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build/components/inserter/index.js +2 -2
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/library.js +8 -2
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +2 -2
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/inserter/menu.js +72 -56
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +2 -2
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/tabs.js +17 -5
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inserter-list-item/index.js +3 -3
- package/build/components/inserter-list-item/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +9 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/link-control/index.js +2 -2
- package/build/components/link-control/index.js.map +1 -1
- package/build/components/link-control/link-preview.js +3 -3
- package/build/components/link-control/link-preview.js.map +1 -1
- package/build/components/link-control/search-results.js +2 -2
- package/build/components/link-control/search-results.js.map +1 -1
- package/build/components/list-view/block-contents.js +2 -2
- package/build/components/list-view/block-contents.js.map +1 -1
- package/build/components/list-view/block-select-button.js +11 -3
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +35 -12
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/drop-indicator.js +3 -3
- package/build/components/list-view/drop-indicator.js.map +1 -1
- package/build/components/list-view/index.js +2 -2
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/leaf.js +2 -2
- package/build/components/list-view/leaf.js.map +1 -1
- package/build/components/media-placeholder/index.js +4 -4
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +2 -2
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/plain-text/index.js +2 -2
- package/build/components/plain-text/index.js.map +1 -1
- package/build/components/provider/use-block-sync.js +18 -0
- package/build/components/provider/use-block-sync.js.map +1 -1
- package/build/components/responsive-block-control/index.js +2 -2
- package/build/components/responsive-block-control/index.js.map +1 -1
- package/build/components/rich-text/event-listeners/enter.js +33 -42
- package/build/components/rich-text/event-listeners/enter.js.map +1 -1
- package/build/components/rich-text/event-listeners/paste-handler.js +22 -42
- package/build/components/rich-text/event-listeners/paste-handler.js.map +1 -1
- package/build/components/rich-text/format-toolbar/index.js +2 -2
- package/build/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build/components/rich-text/index.js +9 -2
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +2 -2
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/multiline.js +30 -2
- package/build/components/rich-text/multiline.js.map +1 -1
- package/build/components/segmented-text-control/index.js +2 -2
- package/build/components/segmented-text-control/index.js.map +1 -1
- package/build/components/text-alignment-control/index.js +2 -2
- package/build/components/text-alignment-control/index.js.map +1 -1
- package/build/components/text-decoration-control/index.js +2 -2
- package/build/components/text-decoration-control/index.js.map +1 -1
- package/build/components/text-transform-control/index.js +2 -2
- package/build/components/text-transform-control/index.js.map +1 -1
- package/build/components/url-input/index.js +4 -4
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/link-editor.js +2 -2
- package/build/components/url-popover/link-editor.js.map +1 -1
- package/build/components/url-popover/link-viewer-url.js +2 -2
- package/build/components/url-popover/link-viewer-url.js.map +1 -1
- package/build/components/url-popover/link-viewer.js +2 -2
- package/build/components/url-popover/link-viewer.js.map +1 -1
- package/build/components/warning/index.js +2 -2
- package/build/components/warning/index.js.map +1 -1
- package/build/components/writing-flow/index.js +2 -2
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-clipboard-handler.js +77 -30
- package/build/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build/components/writing-flow/use-input.js +44 -2
- package/build/components/writing-flow/use-input.js.map +1 -1
- package/build/components/writing-flow/use-tab-nav.js +6 -1
- package/build/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build/components/writing-mode-control/index.js +2 -2
- package/build/components/writing-mode-control/index.js.map +1 -1
- package/build/hooks/align.js +2 -2
- package/build/hooks/align.js.map +1 -1
- package/build/hooks/background.js +1 -1
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/border.js +3 -3
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +3 -3
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/content-lock-ui.js +5 -28
- package/build/hooks/content-lock-ui.js.map +1 -1
- package/build/hooks/custom-class-name.js +2 -2
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/custom-class-name.native.js +2 -2
- package/build/hooks/custom-class-name.native.js.map +1 -1
- package/build/hooks/dimensions.js +2 -2
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/layout-child.js +16 -8
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/layout.js +2 -2
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +2 -2
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/text-align.js +3 -3
- package/build/hooks/text-align.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +39 -13
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/use-color-props.js +2 -2
- package/build/hooks/use-color-props.js.map +1 -1
- package/build/hooks/use-typography-props.js +2 -2
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/hooks/utils.js +2 -2
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/grid.js +7 -6
- package/build/layouts/grid.js.map +1 -1
- package/build/private-apis.js +4 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +134 -40
- package/build/store/actions.js.map +1 -1
- package/build/store/private-actions.js +26 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-keys.js +2 -1
- package/build/store/private-keys.js.map +1 -1
- package/build/store/private-selectors.js +6 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js +4 -1
- package/build/store/selectors.js.map +1 -1
- package/build/utils/selection.js +8 -0
- package/build/utils/selection.js.map +1 -1
- package/build/utils/transform-styles/index.js +12 -7
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/block-actions/index.js +4 -2
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-control/ui.js +2 -2
- package/build-module/components/block-alignment-control/ui.js.map +1 -1
- package/build-module/components/block-card/index.js +2 -2
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-compare/index.js +2 -2
- package/build-module/components/block-compare/index.js.map +1 -1
- package/build-module/components/block-edit/edit.js +2 -2
- package/build-module/components/block-edit/edit.js.map +1 -1
- package/build-module/components/block-icon/index.js +2 -2
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +1 -1
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.js +4 -4
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +2 -2
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-list/index.js +2 -2
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/index.js +5 -2
- package/build-module/components/block-list/use-block-props/index.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-scroll-into-view.js +37 -0
- package/build-module/components/block-list/use-block-props/use-scroll-into-view.js.map +1 -0
- package/build-module/components/block-list-appender/index.js +2 -2
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-mover/button.js +2 -2
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +2 -2
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +27 -6
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-popover/cover.js +9 -5
- package/build-module/components/block-popover/cover.js.map +1 -1
- package/build-module/components/block-popover/inbetween.js +2 -2
- package/build-module/components/block-popover/inbetween.js.map +1 -1
- package/build-module/components/block-popover/index.js +21 -3
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/index.js +2 -2
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +8 -5
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +10 -7
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-styles/index.js +2 -2
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +3 -3
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +2 -2
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js +4 -4
- package/build-module/components/block-tools/block-toolbar-breadcrumb.js.map +1 -1
- package/build-module/components/block-tools/block-toolbar-popover.js +2 -2
- package/build-module/components/block-tools/block-toolbar-popover.js.map +1 -1
- package/build-module/components/block-tools/empty-block-inserter.js +2 -2
- package/build-module/components/block-tools/empty-block-inserter.js.map +1 -1
- package/build-module/components/block-tools/index.js +20 -1
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +4 -4
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-mode-inserters.js +67 -23
- package/build-module/components/block-tools/zoom-out-mode-inserters.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +2 -2
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/button-block-appender/index.js +2 -2
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +2 -2
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +3 -3
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +2 -2
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +2 -2
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/index.js +7 -1
- package/build-module/components/convert-to-group-buttons/index.js.map +1 -1
- package/build-module/components/default-block-appender/index.js +2 -2
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/dimensions-tool/aspect-ratio-tool.js +30 -36
- package/build-module/components/dimensions-tool/aspect-ratio-tool.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +3 -3
- package/build-module/components/global-styles/background-panel.js.map +1 -1
- package/build-module/components/global-styles/color-panel.js +3 -3
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +4 -4
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/filters-panel.js +2 -2
- package/build-module/components/global-styles/filters-panel.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel-components.js +4 -4
- package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/grid-visualizer/grid-item-resizer.js +141 -24
- package/build-module/components/grid-visualizer/grid-item-resizer.js.map +1 -1
- package/build-module/components/grid-visualizer/grid-visualizer.js +12 -6
- package/build-module/components/grid-visualizer/grid-visualizer.js.map +1 -1
- package/build-module/components/iframe/index.js +70 -31
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/image-editor/aspect-ratio-dropdown.js +52 -36
- package/build-module/components/image-editor/aspect-ratio-dropdown.js.map +1 -1
- package/build-module/components/image-editor/cropper.js +2 -2
- package/build-module/components/image-editor/cropper.js.map +1 -1
- package/build-module/components/image-editor/index.js +1 -1
- package/build-module/components/image-editor/index.js.map +1 -1
- package/build-module/components/index.js +1 -0
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/button-block-appender.js +2 -2
- package/build-module/components/inner-blocks/button-block-appender.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +22 -21
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/index.js +10 -1
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build-module/components/inserter/block-types-tab.js +6 -4
- package/build-module/components/inserter/block-types-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +11 -2
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-state.js +12 -5
- package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
- package/build-module/components/inserter/index.js +2 -2
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/library.js +8 -2
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +2 -2
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/inserter/menu.js +72 -56
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +2 -2
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/tabs.js +18 -6
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inserter-list-item/index.js +3 -3
- package/build-module/components/inserter-list-item/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +9 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/link-control/index.js +2 -2
- package/build-module/components/link-control/index.js.map +1 -1
- package/build-module/components/link-control/link-preview.js +3 -3
- package/build-module/components/link-control/link-preview.js.map +1 -1
- package/build-module/components/link-control/search-results.js +2 -2
- package/build-module/components/link-control/search-results.js.map +1 -1
- package/build-module/components/list-view/block-contents.js +2 -2
- package/build-module/components/list-view/block-contents.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +11 -3
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +36 -13
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/drop-indicator.js +3 -3
- package/build-module/components/list-view/drop-indicator.js.map +1 -1
- package/build-module/components/list-view/index.js +2 -2
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/leaf.js +2 -2
- package/build-module/components/list-view/leaf.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +4 -4
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +2 -2
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/plain-text/index.js +2 -2
- package/build-module/components/plain-text/index.js.map +1 -1
- package/build-module/components/provider/use-block-sync.js +19 -1
- package/build-module/components/provider/use-block-sync.js.map +1 -1
- package/build-module/components/responsive-block-control/index.js +2 -2
- package/build-module/components/responsive-block-control/index.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/enter.js +33 -43
- package/build-module/components/rich-text/event-listeners/enter.js.map +1 -1
- package/build-module/components/rich-text/event-listeners/paste-handler.js +23 -43
- package/build-module/components/rich-text/event-listeners/paste-handler.js.map +1 -1
- package/build-module/components/rich-text/format-toolbar/index.js +2 -2
- package/build-module/components/rich-text/format-toolbar/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +9 -2
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +2 -2
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/multiline.js +31 -3
- package/build-module/components/rich-text/multiline.js.map +1 -1
- package/build-module/components/segmented-text-control/index.js +2 -2
- package/build-module/components/segmented-text-control/index.js.map +1 -1
- package/build-module/components/text-alignment-control/index.js +2 -2
- package/build-module/components/text-alignment-control/index.js.map +1 -1
- package/build-module/components/text-decoration-control/index.js +2 -2
- package/build-module/components/text-decoration-control/index.js.map +1 -1
- package/build-module/components/text-transform-control/index.js +2 -2
- package/build-module/components/text-transform-control/index.js.map +1 -1
- package/build-module/components/url-input/index.js +4 -4
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/link-editor.js +2 -2
- package/build-module/components/url-popover/link-editor.js.map +1 -1
- package/build-module/components/url-popover/link-viewer-url.js +2 -2
- package/build-module/components/url-popover/link-viewer-url.js.map +1 -1
- package/build-module/components/url-popover/link-viewer.js +2 -2
- package/build-module/components/url-popover/link-viewer.js.map +1 -1
- package/build-module/components/warning/index.js +2 -2
- package/build-module/components/warning/index.js.map +1 -1
- package/build-module/components/writing-flow/index.js +2 -2
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-clipboard-handler.js +78 -31
- package/build-module/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build-module/components/writing-flow/use-input.js +45 -3
- package/build-module/components/writing-flow/use-input.js.map +1 -1
- package/build-module/components/writing-flow/use-tab-nav.js +6 -1
- package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
- package/build-module/components/writing-mode-control/index.js +2 -2
- package/build-module/components/writing-mode-control/index.js.map +1 -1
- package/build-module/hooks/align.js +2 -2
- package/build-module/hooks/align.js.map +1 -1
- package/build-module/hooks/background.js +1 -1
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/border.js +3 -3
- package/build-module/hooks/border.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/content-lock-ui.js +5 -28
- package/build-module/hooks/content-lock-ui.js.map +1 -1
- package/build-module/hooks/custom-class-name.js +2 -2
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/custom-class-name.native.js +2 -2
- package/build-module/hooks/custom-class-name.native.js.map +1 -1
- package/build-module/hooks/dimensions.js +2 -2
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/layout-child.js +16 -8
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/layout.js +2 -2
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +2 -2
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/text-align.js +3 -3
- package/build-module/hooks/text-align.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +39 -13
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/use-color-props.js +2 -2
- package/build-module/hooks/use-color-props.js.map +1 -1
- package/build-module/hooks/use-typography-props.js +2 -2
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/hooks/utils.js +2 -2
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/grid.js +7 -6
- package/build-module/layouts/grid.js.map +1 -1
- package/build-module/private-apis.js +5 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +136 -42
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-actions.js +24 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-keys.js +1 -0
- package/build-module/store/private-keys.js.map +1 -1
- package/build-module/store/private-selectors.js +5 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/selectors.js +4 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/selection.js +7 -0
- package/build-module/utils/selection.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +12 -7
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +89 -96
- package/build-style/content.css +89 -96
- package/build-style/style-rtl.css +14 -4
- package/build-style/style.css +14 -4
- package/build-types/components/block-context/index.d.ts +1 -1
- package/build-types/components/block-context/index.d.ts.map +1 -1
- package/package.json +32 -32
- package/src/components/block-actions/index.js +5 -1
- package/src/components/block-alignment-control/ui.js +2 -2
- package/src/components/block-card/index.js +2 -2
- package/src/components/block-compare/index.js +2 -2
- package/src/components/block-content-overlay/content.scss +4 -37
- package/src/components/block-draggable/test/helpers.native.js +8 -8
- package/src/components/block-edit/edit.js +2 -2
- package/src/components/block-icon/index.js +2 -2
- package/src/components/block-inspector/index.js +2 -1
- package/src/components/block-list/block.js +4 -4
- package/src/components/block-list/block.native.js +2 -2
- package/src/components/block-list/content.scss +46 -73
- package/src/components/block-list/index.js +2 -2
- package/src/components/block-list/use-block-props/index.js +4 -2
- package/src/components/block-list/use-block-props/use-scroll-into-view.js +38 -0
- package/src/components/block-list-appender/index.js +2 -2
- package/src/components/block-mover/button.js +2 -2
- package/src/components/block-mover/index.js +2 -2
- package/src/components/block-patterns-list/index.js +29 -4
- package/src/components/block-popover/README.md +1 -1
- package/src/components/block-popover/cover.js +22 -7
- package/src/components/block-popover/inbetween.js +2 -2
- package/src/components/block-popover/index.js +24 -6
- package/src/components/block-preview/index.js +2 -2
- package/src/components/block-settings-menu/block-settings-dropdown.js +14 -6
- package/src/components/block-settings-menu-controls/index.js +25 -16
- package/src/components/block-styles/index.js +2 -2
- package/src/components/block-toolbar/index.js +3 -3
- package/src/components/block-tools/block-selection-button.js +2 -2
- package/src/components/block-tools/block-toolbar-breadcrumb.js +5 -5
- package/src/components/block-tools/block-toolbar-popover.js +4 -7
- package/src/components/block-tools/empty-block-inserter.js +2 -2
- package/src/components/block-tools/index.js +24 -3
- package/src/components/block-tools/insertion-point.js +4 -4
- package/src/components/block-tools/style.scss +8 -0
- package/src/components/block-tools/zoom-out-mode-inserters.js +73 -21
- package/src/components/block-variation-picker/index.js +2 -2
- package/src/components/button-block-appender/index.js +2 -2
- package/src/components/child-layout-control/index.js +14 -2
- package/src/components/colors-gradients/control.js +3 -3
- package/src/components/colors-gradients/dropdown.js +2 -2
- package/src/components/colors-gradients/panel-color-gradient-settings.js +2 -2
- package/src/components/colors-gradients/test/control.js +3 -3
- package/src/components/convert-to-group-buttons/index.js +10 -1
- package/src/components/default-block-appender/index.js +2 -2
- package/src/components/dimensions-tool/aspect-ratio-tool.js +40 -67
- package/src/components/dimensions-tool/test/index.js +10 -0
- package/src/components/editable-text/README.md +0 -4
- package/src/components/global-styles/background-panel.js +3 -3
- package/src/components/global-styles/color-panel.js +3 -3
- package/src/components/global-styles/dimensions-panel.js +4 -4
- package/src/components/global-styles/filters-panel.js +2 -2
- package/src/components/global-styles/shadow-panel-components.js +6 -9
- package/src/components/global-styles/test/get-global-styles-changes.js +0 -2
- package/src/components/global-styles/test/use-global-styles-output.js +5 -5
- package/src/components/global-styles/use-global-styles-output.js +1 -1
- package/src/components/grid-visualizer/grid-item-resizer.js +169 -40
- package/src/components/grid-visualizer/grid-visualizer.js +19 -6
- package/src/components/iframe/content.scss +63 -0
- package/src/components/iframe/index.js +119 -39
- package/src/components/image-editor/aspect-ratio-dropdown.js +91 -59
- package/src/components/image-editor/cropper.js +2 -2
- package/src/components/image-editor/index.js +1 -1
- package/src/components/image-editor/test/index.js +22 -0
- package/src/components/index.js +1 -0
- package/src/components/inner-blocks/button-block-appender.js +2 -2
- package/src/components/inner-blocks/index.js +19 -17
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +2 -1
- package/src/components/inserter/block-patterns-tab/index.js +17 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +2 -1
- package/src/components/inserter/block-types-tab.js +7 -9
- package/src/components/inserter/hooks/use-insertion-point.js +15 -1
- package/src/components/inserter/hooks/use-patterns-state.js +18 -5
- package/src/components/inserter/index.js +4 -5
- package/src/components/inserter/library.js +6 -0
- package/src/components/inserter/media-tab/media-preview.js +2 -2
- package/src/components/inserter/menu.js +113 -107
- package/src/components/inserter/quick-inserter.js +2 -2
- package/src/components/inserter/style.scss +6 -8
- package/src/components/inserter/tabs.js +29 -15
- package/src/components/inserter-list-item/index.js +3 -3
- package/src/components/keyboard-shortcuts/index.js +12 -0
- package/src/components/line-height-control/test/index.js +16 -14
- package/src/components/link-control/index.js +2 -2
- package/src/components/link-control/link-preview.js +3 -3
- package/src/components/link-control/search-results.js +2 -2
- package/src/components/list-view/block-contents.js +2 -2
- package/src/components/list-view/block-select-button.js +14 -3
- package/src/components/list-view/block.js +54 -30
- package/src/components/list-view/drop-indicator.js +3 -3
- package/src/components/list-view/index.js +2 -2
- package/src/components/list-view/leaf.js +2 -5
- package/src/components/media-placeholder/index.js +4 -4
- package/src/components/media-replace-flow/index.js +2 -2
- package/src/components/plain-text/index.js +2 -2
- package/src/components/provider/use-block-sync.js +27 -1
- package/src/components/responsive-block-control/index.js +2 -2
- package/src/components/rich-text/README.md +0 -8
- package/src/components/rich-text/event-listeners/enter.js +28 -48
- package/src/components/rich-text/event-listeners/paste-handler.js +21 -58
- package/src/components/rich-text/format-toolbar/index.js +2 -2
- package/src/components/rich-text/index.js +10 -3
- package/src/components/rich-text/index.native.js +2 -2
- package/src/components/rich-text/multiline.js +31 -3
- package/src/components/segmented-text-control/index.js +2 -2
- package/src/components/text-alignment-control/index.js +2 -2
- package/src/components/text-decoration-control/index.js +2 -2
- package/src/components/text-transform-control/index.js +2 -2
- package/src/components/url-input/index.js +4 -4
- package/src/components/url-popover/link-editor.js +2 -2
- package/src/components/url-popover/link-viewer-url.js +2 -2
- package/src/components/url-popover/link-viewer.js +2 -2
- package/src/components/warning/index.js +2 -2
- package/src/components/writing-flow/index.js +2 -2
- package/src/components/writing-flow/use-clipboard-handler.js +107 -47
- package/src/components/writing-flow/use-input.js +75 -1
- package/src/components/writing-flow/use-tab-nav.js +10 -1
- package/src/components/writing-mode-control/index.js +2 -5
- package/src/content.scss +1 -0
- package/src/hooks/align.js +2 -2
- package/src/hooks/background.js +1 -1
- package/src/hooks/border.js +3 -3
- package/src/hooks/color.js +12 -19
- package/src/hooks/color.scss +1 -0
- package/src/hooks/content-lock-ui.js +16 -33
- package/src/hooks/custom-class-name.js +2 -2
- package/src/hooks/custom-class-name.native.js +2 -2
- package/src/hooks/dimensions.js +2 -2
- package/src/hooks/layout-child.js +34 -20
- package/src/hooks/layout.js +2 -2
- package/src/hooks/position.js +2 -2
- package/src/hooks/text-align.js +3 -3
- package/src/hooks/use-bindings-attributes.js +48 -16
- package/src/hooks/use-color-props.js +2 -2
- package/src/hooks/use-typography-props.js +2 -2
- package/src/hooks/utils.js +2 -2
- package/src/layouts/grid.js +3 -7
- package/src/private-apis.js +4 -0
- package/src/store/actions.js +225 -70
- package/src/store/private-actions.js +24 -0
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +15 -0
- package/src/store/selectors.js +4 -2
- package/src/utils/selection.js +8 -0
- package/src/utils/test/__snapshots__/transform-styles.js.snap +6 -0
- package/src/utils/test/transform-styles.js +14 -0
- package/src/utils/transform-styles/index.js +12 -9
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/rich-text/split-value.js +0 -81
- package/build/components/rich-text/split-value.js.map +0 -1
- package/build-module/components/rich-text/split-value.js +0 -75
- package/build-module/components/rich-text/split-value.js.map +0 -1
- package/src/components/rich-text/split-value.js +0 -64
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ResizableBox","__unstableUseBlockElement","useBlockElement","BlockPopoverCover","getComputedCSS","GridItemResizer","clientId","onChange","blockElement","createElement","className","__unstablePopoverSlot","size","width","height","enable","bottom","bottomLeft","bottomRight","left","right","top","topLeft","topRight","onResizeStop","event","direction","boxElement","gridElement","parentElement","columnGap","parseFloat","rowGap","gridColumnLines","getGridLines","gridRowLines","columnStart","getClosestLine","offsetLeft","rowStart","offsetTop","columnEnd","offsetWidth","rowEnd","offsetHeight","columnSpan","Math","max","rowSpan","template","gap","lines","split","line","push","length","position","reduce","closest","index","abs"],"sources":["@wordpress/block-editor/src/components/grid-visualizer/grid-item-resizer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ResizableBox } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport BlockPopoverCover from '../block-popover/cover';\nimport { getComputedCSS } from './utils';\n\nexport function GridItemResizer( { clientId, onChange } ) {\n\tconst blockElement = useBlockElement( clientId );\n\tif ( ! blockElement ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<BlockPopoverCover\n\t\t\tclassName=\"block-editor-grid-item-resizer\"\n\t\t\tclientId={ clientId }\n\t\t\t__unstablePopoverSlot=\"block-toolbar\"\n\t\t>\n\t\t\t<ResizableBox\n\t\t\t\tclassName=\"block-editor-grid-item-resizer__box\"\n\t\t\t\tsize={ {\n\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '100%',\n\t\t\t\t} }\n\t\t\t\tenable={ {\n\t\t\t\t\tbottom: true,\n\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\tbottomRight: false,\n\t\t\t\t\tleft: false,\n\t\t\t\t\tright: true,\n\t\t\t\t\ttop: false,\n\t\t\t\t\ttopLeft: false,\n\t\t\t\t\ttopRight: false,\n\t\t\t\t} }\n\t\t\t\tonResizeStop={ ( event, direction, boxElement ) => {\n\t\t\t\t\tconst gridElement = blockElement.parentElement;\n\t\t\t\t\tconst columnGap = parseFloat(\n\t\t\t\t\t\tgetComputedCSS( gridElement, 'column-gap' )\n\t\t\t\t\t);\n\t\t\t\t\tconst rowGap = parseFloat(\n\t\t\t\t\t\tgetComputedCSS( gridElement, 'row-gap' )\n\t\t\t\t\t);\n\t\t\t\t\tconst gridColumnLines = getGridLines(\n\t\t\t\t\t\tgetComputedCSS( gridElement, 'grid-template-columns' ),\n\t\t\t\t\t\tcolumnGap\n\t\t\t\t\t);\n\t\t\t\t\tconst gridRowLines = getGridLines(\n\t\t\t\t\t\tgetComputedCSS( gridElement, 'grid-template-rows' ),\n\t\t\t\t\t\trowGap\n\t\t\t\t\t);\n\t\t\t\t\tconst columnStart = getClosestLine(\n\t\t\t\t\t\tgridColumnLines,\n\t\t\t\t\t\tblockElement.offsetLeft\n\t\t\t\t\t);\n\t\t\t\t\tconst rowStart = getClosestLine(\n\t\t\t\t\t\tgridRowLines,\n\t\t\t\t\t\tblockElement.offsetTop\n\t\t\t\t\t);\n\t\t\t\t\tconst columnEnd = getClosestLine(\n\t\t\t\t\t\tgridColumnLines,\n\t\t\t\t\t\tblockElement.offsetLeft + boxElement.offsetWidth\n\t\t\t\t\t);\n\t\t\t\t\tconst rowEnd = getClosestLine(\n\t\t\t\t\t\tgridRowLines,\n\t\t\t\t\t\tblockElement.offsetTop + boxElement.offsetHeight\n\t\t\t\t\t);\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\tcolumnSpan: Math.max( columnEnd - columnStart, 1 ),\n\t\t\t\t\t\trowSpan: Math.max( rowEnd - rowStart, 1 ),\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockPopoverCover>\n\t);\n}\n\nfunction getGridLines( template, gap ) {\n\tconst lines = [ 0 ];\n\tfor ( const size of template.split( ' ' ) ) {\n\t\tconst line = parseFloat( size );\n\t\tlines.push( lines[ lines.length - 1 ] + line + gap );\n\t}\n\treturn lines;\n}\n\nfunction getClosestLine( lines, position ) {\n\treturn lines.reduce(\n\t\t( closest, line, index ) =>\n\t\t\tMath.abs( line - position ) <\n\t\t\tMath.abs( lines[ closest ] - position )\n\t\t\t\t? index\n\t\t\t\t: closest,\n\t\t0\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,uBAAuB;;AAEpD;AACA;AACA;AACA,SAASC,yBAAyB,IAAIC,eAAe,QAAQ,8CAA8C;AAC3G,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,SAASC,cAAc,QAAQ,SAAS;AAEx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ffect","__unstableUseBlockElement","useBlockElement","BlockPopoverCover","getComputedCSS","GridItemResizer","clientId","bounds","onChange","blockElement","rootBlockElement","parentElement","createElement","GridItemResizerInner","resizeDirection","setResizeDirection","enableSide","setEnableSide","top","bottom","left","right","observer","window","ResizeObserver","blockClientRect","getBoundingClientRect","rootBlockClientRect","observe","disconnect","justification","alignment","styles","display","justifyContent","alignItems","className","__unstablePopoverSlot","additionalStyles","size","width","height","enable","bottomLeft","bottomRight","topLeft","topRight","boundsByDirection","onResizeStart","event","direction","ownerDocument","addEventListener","target","dispatchEvent","Event","bubbles","once","onResizeStop","boxElement","columnGap","parseFloat","rowGap","gridColumnTracks","getGridTracks","gridRowTracks","rect","DOMRect","offsetLeft","offsetTop","offsetWidth","offsetHeight","columnStart","getClosestTrack","rowStart","columnEnd","rowEnd","columnSpan","rowSpan","template","gap","tracks","split","previousTrack","length","start","end","push","position","edge","reduce","closest","track","index","Math","abs"],"sources":["@wordpress/block-editor/src/components/grid-visualizer/grid-item-resizer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ResizableBox } from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport BlockPopoverCover from '../block-popover/cover';\nimport { getComputedCSS } from './utils';\n\nexport function GridItemResizer( { clientId, bounds, onChange } ) {\n\tconst blockElement = useBlockElement( clientId );\n\tconst rootBlockElement = blockElement?.parentElement;\n\n\tif ( ! blockElement || ! rootBlockElement ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<GridItemResizerInner\n\t\t\tclientId={ clientId }\n\t\t\tbounds={ bounds }\n\t\t\tblockElement={ blockElement }\n\t\t\trootBlockElement={ rootBlockElement }\n\t\t\tonChange={ onChange }\n\t\t/>\n\t);\n}\n\nfunction GridItemResizerInner( {\n\tclientId,\n\tbounds,\n\tblockElement,\n\trootBlockElement,\n\tonChange,\n} ) {\n\tconst [ resizeDirection, setResizeDirection ] = useState( null );\n\tconst [ enableSide, setEnableSide ] = useState( {\n\t\ttop: false,\n\t\tbottom: false,\n\t\tleft: false,\n\t\tright: false,\n\t} );\n\n\tuseEffect( () => {\n\t\tconst observer = new window.ResizeObserver( () => {\n\t\t\tconst blockClientRect = blockElement.getBoundingClientRect();\n\t\t\tconst rootBlockClientRect =\n\t\t\t\trootBlockElement.getBoundingClientRect();\n\t\t\tsetEnableSide( {\n\t\t\t\ttop: blockClientRect.top > rootBlockClientRect.top,\n\t\t\t\tbottom: blockClientRect.bottom < rootBlockClientRect.bottom,\n\t\t\t\tleft: blockClientRect.left > rootBlockClientRect.left,\n\t\t\t\tright: blockClientRect.right < rootBlockClientRect.right,\n\t\t\t} );\n\t\t} );\n\t\tobserver.observe( blockElement );\n\t\treturn () => observer.disconnect();\n\t}, [ blockElement, rootBlockElement ] );\n\n\tconst justification = {\n\t\tright: 'flex-start',\n\t\tleft: 'flex-end',\n\t};\n\n\tconst alignment = {\n\t\ttop: 'flex-end',\n\t\tbottom: 'flex-start',\n\t};\n\n\tconst styles = {\n\t\tdisplay: 'flex',\n\t\tjustifyContent: 'center',\n\t\talignItems: 'center',\n\t\t...( justification[ resizeDirection ] && {\n\t\t\tjustifyContent: justification[ resizeDirection ],\n\t\t} ),\n\t\t...( alignment[ resizeDirection ] && {\n\t\t\talignItems: alignment[ resizeDirection ],\n\t\t} ),\n\t};\n\n\treturn (\n\t\t<BlockPopoverCover\n\t\t\tclassName=\"block-editor-grid-item-resizer\"\n\t\t\tclientId={ clientId }\n\t\t\t__unstablePopoverSlot=\"block-toolbar\"\n\t\t\tadditionalStyles={ styles }\n\t\t>\n\t\t\t<ResizableBox\n\t\t\t\tclassName=\"block-editor-grid-item-resizer__box\"\n\t\t\t\tsize={ {\n\t\t\t\t\twidth: '100%',\n\t\t\t\t\theight: '100%',\n\t\t\t\t} }\n\t\t\t\tenable={ {\n\t\t\t\t\tbottom: enableSide.bottom,\n\t\t\t\t\tbottomLeft: false,\n\t\t\t\t\tbottomRight: false,\n\t\t\t\t\tleft: enableSide.left,\n\t\t\t\t\tright: enableSide.right,\n\t\t\t\t\ttop: enableSide.top,\n\t\t\t\t\ttopLeft: false,\n\t\t\t\t\ttopRight: false,\n\t\t\t\t} }\n\t\t\t\tbounds={ bounds }\n\t\t\t\tboundsByDirection\n\t\t\t\tonResizeStart={ ( event, direction ) => {\n\t\t\t\t\t/*\n\t\t\t\t\t * The container justification and alignment need to be set\n\t\t\t\t\t * according to the direction the resizer is being dragged in,\n\t\t\t\t\t * so that it resizes in the right direction.\n\t\t\t\t\t */\n\t\t\t\t\tsetResizeDirection( direction );\n\n\t\t\t\t\t/*\n\t\t\t\t\t * The mouseup event on the resize handle doesn't trigger if the mouse\n\t\t\t\t\t * isn't directly above the handle, so we try to detect if it happens\n\t\t\t\t\t * outside the grid and dispatch a mouseup event on the handle.\n\t\t\t\t\t */\n\t\t\t\t\tblockElement.ownerDocument.addEventListener(\n\t\t\t\t\t\t'mouseup',\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\tevent.target.dispatchEvent(\n\t\t\t\t\t\t\t\tnew Event( 'mouseup', { bubbles: true } )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{ once: true }\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t\tonResizeStop={ ( event, direction, boxElement ) => {\n\t\t\t\t\tconst columnGap = parseFloat(\n\t\t\t\t\t\tgetComputedCSS( rootBlockElement, 'column-gap' )\n\t\t\t\t\t);\n\t\t\t\t\tconst rowGap = parseFloat(\n\t\t\t\t\t\tgetComputedCSS( rootBlockElement, 'row-gap' )\n\t\t\t\t\t);\n\t\t\t\t\tconst gridColumnTracks = getGridTracks(\n\t\t\t\t\t\tgetComputedCSS(\n\t\t\t\t\t\t\trootBlockElement,\n\t\t\t\t\t\t\t'grid-template-columns'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcolumnGap\n\t\t\t\t\t);\n\t\t\t\t\tconst gridRowTracks = getGridTracks(\n\t\t\t\t\t\tgetComputedCSS(\n\t\t\t\t\t\t\trootBlockElement,\n\t\t\t\t\t\t\t'grid-template-rows'\n\t\t\t\t\t\t),\n\t\t\t\t\t\trowGap\n\t\t\t\t\t);\n\t\t\t\t\tconst rect = new window.DOMRect(\n\t\t\t\t\t\tblockElement.offsetLeft + boxElement.offsetLeft,\n\t\t\t\t\t\tblockElement.offsetTop + boxElement.offsetTop,\n\t\t\t\t\t\tboxElement.offsetWidth,\n\t\t\t\t\t\tboxElement.offsetHeight\n\t\t\t\t\t);\n\t\t\t\t\tconst columnStart =\n\t\t\t\t\t\tgetClosestTrack( gridColumnTracks, rect.left ) + 1;\n\t\t\t\t\tconst rowStart =\n\t\t\t\t\t\tgetClosestTrack( gridRowTracks, rect.top ) + 1;\n\t\t\t\t\tconst columnEnd =\n\t\t\t\t\t\tgetClosestTrack( gridColumnTracks, rect.right, 'end' ) +\n\t\t\t\t\t\t1;\n\t\t\t\t\tconst rowEnd =\n\t\t\t\t\t\tgetClosestTrack( gridRowTracks, rect.bottom, 'end' ) +\n\t\t\t\t\t\t1;\n\t\t\t\t\tonChange( {\n\t\t\t\t\t\tcolumnSpan: columnEnd - columnStart + 1,\n\t\t\t\t\t\trowSpan: rowEnd - rowStart + 1,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockPopoverCover>\n\t);\n}\n\n/**\n * Given a grid-template-columns or grid-template-rows CSS property value, gets the start and end\n * position in pixels of each grid track.\n *\n * https://css-tricks.com/snippets/css/complete-guide-grid/#aa-grid-track\n *\n * @param {string} template The grid-template-columns or grid-template-rows CSS property value.\n * Only supports fixed sizes in pixels.\n * @param {number} gap The gap between grid tracks in pixels.\n *\n * @return {Array<{start: number, end: number}>} An array of objects with the start and end\n * position in pixels of each grid track.\n */\nfunction getGridTracks( template, gap ) {\n\tconst tracks = [];\n\tfor ( const size of template.split( ' ' ) ) {\n\t\tconst previousTrack = tracks[ tracks.length - 1 ];\n\t\tconst start = previousTrack ? previousTrack.end + gap : 0;\n\t\tconst end = start + parseFloat( size );\n\t\ttracks.push( { start, end } );\n\t}\n\treturn tracks;\n}\n\n/**\n * Given an array of grid tracks and a position in pixels, gets the index of the closest track to\n * that position.\n *\n * https://css-tricks.com/snippets/css/complete-guide-grid/#aa-grid-track\n *\n * @param {Array<{start: number, end: number}>} tracks An array of objects with the start and end\n * position in pixels of each grid track.\n * @param {number} position The position in pixels.\n * @param {string} edge The edge of the track to compare the\n * position to. Either 'start' or 'end'.\n *\n * @return {number} The index of the closest track to the position. 0-based, unlike CSS grid which\n * is 1-based.\n */\nfunction getClosestTrack( tracks, position, edge = 'start' ) {\n\treturn tracks.reduce(\n\t\t( closest, track, index ) =>\n\t\t\tMath.abs( track[ edge ] - position ) <\n\t\t\tMath.abs( tracks[ closest ][ edge ] - position )\n\t\t\t\t? index\n\t\t\t\t: closest,\n\t\t0\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,uBAAuB;AACpD,SAASC,QAAQ,EAAEC,SAAS,QAAQ,oBAAoB;;AAExD;AACA;AACA;AACA,SAASC,yBAAyB,IAAIC,eAAe,QAAQ,8CAA8C;AAC3G,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,SAASC,cAAc,QAAQ,SAAS;AAExC,OAAO,SAASC,eAAeA,CAAE;EAAEC,QAAQ;EAAEC,MAAM;EAAEC;AAAS,CAAC,EAAG;EACjE,MAAMC,YAAY,GAAGP,eAAe,CAAEI,QAAS,CAAC;EAChD,MAAMI,gBAAgB,GAAGD,YAAY,EAAEE,aAAa;EAEpD,IAAK,CAAEF,YAAY,IAAI,CAAEC,gBAAgB,EAAG;IAC3C,OAAO,IAAI;EACZ;EAEA,OACCE,aAAA,CAACC,oBAAoB;IACpBP,QAAQ,EAAGA,QAAU;IACrBC,MAAM,EAAGA,MAAQ;IACjBE,YAAY,EAAGA,YAAc;IAC7BC,gBAAgB,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W,GAAG,CAAC;QACvCM,OAAO,EAAEF,MAAM,GAAGF,QAAQ,GAAG;MAC9B,CAAE,CAAC;IACJ;EAAG,CACH,CACiB,CAAC;AAEtB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASV,aAAaA,CAAEe,QAAQ,EAAEC,GAAG,EAAG;EACvC,MAAMC,MAAM,GAAG,EAAE;EACjB,KAAM,MAAM1C,IAAI,IAAIwC,QAAQ,CAACG,KAAK,CAAE,GAAI,CAAC,EAAG;IAC3C,MAAMC,aAAa,GAAGF,MAAM,CAAEA,MAAM,CAACG,MAAM,GAAG,CAAC,CAAE;IACjD,MAAMC,KAAK,GAAGF,aAAa,GAAGA,aAAa,CAACG,GAAG,GAAGN,GAAG,GAAG,CAAC;IACzD,MAAMM,GAAG,GAAGD,KAAK,GAAGxB,UAAU,CAAEtB,IAAK,CAAC;IACtC0C,MAAM,CAACM,IAAI,CAAE;MAAEF,KAAK;MAAEC;IAAI,CAAE,CAAC;EAC9B;EACA,OAAOL,MAAM;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASR,eAAeA,CAAEQ,MAAM,EAAEO,QAAQ,EAAEC,IAAI,GAAG,OAAO,EAAG;EAC5D,OAAOR,MAAM,CAACS,MAAM,CACnB,CAAEC,OAAO,EAAEC,KAAK,EAAEC,KAAK,KACtBC,IAAI,CAACC,GAAG,CAAEH,KAAK,CAAEH,IAAI,CAAE,GAAGD,QAAS,CAAC,GACpCM,IAAI,CAACC,GAAG,CAAEd,MAAM,CAAEU,OAAO,CAAE,CAAEF,IAAI,CAAE,GAAGD,QAAS,CAAC,GAC7CK,KAAK,GACLF,OAAO,EACX,CACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -2,19 +2,23 @@ import { createElement } from "react";
|
|
|
2
2
|
/**
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
|
-
import { useState, useEffect } from '@wordpress/element';
|
|
5
|
+
import { useState, useEffect, forwardRef } from '@wordpress/element';
|
|
6
|
+
import { useSelect } from '@wordpress/data';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Internal dependencies
|
|
9
10
|
*/
|
|
10
11
|
import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
|
|
11
12
|
import BlockPopoverCover from '../block-popover/cover';
|
|
13
|
+
import { store as blockEditorStore } from '../../store';
|
|
12
14
|
import { getComputedCSS } from './utils';
|
|
13
15
|
export function GridVisualizer({
|
|
14
|
-
clientId
|
|
16
|
+
clientId,
|
|
17
|
+
contentRef
|
|
15
18
|
}) {
|
|
19
|
+
const isDistractionFree = useSelect(select => select(blockEditorStore).getSettings().isDistractionFree, []);
|
|
16
20
|
const blockElement = useBlockElement(clientId);
|
|
17
|
-
if (!blockElement) {
|
|
21
|
+
if (isDistractionFree || !blockElement) {
|
|
18
22
|
return null;
|
|
19
23
|
}
|
|
20
24
|
return createElement(BlockPopoverCover, {
|
|
@@ -22,12 +26,13 @@ export function GridVisualizer({
|
|
|
22
26
|
clientId: clientId,
|
|
23
27
|
__unstablePopoverSlot: "block-toolbar"
|
|
24
28
|
}, createElement(GridVisualizerGrid, {
|
|
29
|
+
ref: contentRef,
|
|
25
30
|
blockElement: blockElement
|
|
26
31
|
}));
|
|
27
32
|
}
|
|
28
|
-
|
|
33
|
+
const GridVisualizerGrid = forwardRef(({
|
|
29
34
|
blockElement
|
|
30
|
-
}) {
|
|
35
|
+
}, ref) => {
|
|
31
36
|
const [gridInfo, setGridInfo] = useState(() => getGridInfo(blockElement));
|
|
32
37
|
useEffect(() => {
|
|
33
38
|
const observers = [];
|
|
@@ -45,6 +50,7 @@ function GridVisualizerGrid({
|
|
|
45
50
|
};
|
|
46
51
|
}, [blockElement]);
|
|
47
52
|
return createElement("div", {
|
|
53
|
+
ref: ref,
|
|
48
54
|
className: "block-editor-grid-visualizer__grid",
|
|
49
55
|
style: gridInfo.style
|
|
50
56
|
}, Array.from({
|
|
@@ -53,7 +59,7 @@ function GridVisualizerGrid({
|
|
|
53
59
|
key: i,
|
|
54
60
|
className: "block-editor-grid-visualizer__item"
|
|
55
61
|
})));
|
|
56
|
-
}
|
|
62
|
+
});
|
|
57
63
|
function getGridInfo(blockElement) {
|
|
58
64
|
const gridTemplateColumns = getComputedCSS(blockElement, 'grid-template-columns');
|
|
59
65
|
const gridTemplateRows = getComputedCSS(blockElement, 'grid-template-rows');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useState","useEffect","__unstableUseBlockElement","useBlockElement","BlockPopoverCover","getComputedCSS","GridVisualizer","clientId","blockElement","createElement","className","__unstablePopoverSlot","GridVisualizerGrid","gridInfo","setGridInfo","getGridInfo","observers","element","children","observer","window","ResizeObserver","observe","push","disconnect","style","Array","from","length","numItems","_","i","key","gridTemplateColumns","gridTemplateRows","numColumns","split","numRows","gap","padding"],"sources":["@wordpress/block-editor/src/components/grid-visualizer/grid-visualizer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport BlockPopoverCover from '../block-popover/cover';\nimport { getComputedCSS } from './utils';\n\nexport function GridVisualizer( { clientId } ) {\n\tconst blockElement = useBlockElement( clientId );\n\tif ( ! blockElement ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<BlockPopoverCover\n\t\t\tclassName=\"block-editor-grid-visualizer\"\n\t\t\tclientId={ clientId }\n\t\t\t__unstablePopoverSlot=\"block-toolbar\"\n\t\t>\n\t\t\t<GridVisualizerGrid
|
|
1
|
+
{"version":3,"names":["useState","useEffect","forwardRef","useSelect","__unstableUseBlockElement","useBlockElement","BlockPopoverCover","store","blockEditorStore","getComputedCSS","GridVisualizer","clientId","contentRef","isDistractionFree","select","getSettings","blockElement","createElement","className","__unstablePopoverSlot","GridVisualizerGrid","ref","gridInfo","setGridInfo","getGridInfo","observers","element","children","observer","window","ResizeObserver","observe","push","disconnect","style","Array","from","length","numItems","_","i","key","gridTemplateColumns","gridTemplateRows","numColumns","split","numRows","gap","padding"],"sources":["@wordpress/block-editor/src/components/grid-visualizer/grid-visualizer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, forwardRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport BlockPopoverCover from '../block-popover/cover';\nimport { store as blockEditorStore } from '../../store';\nimport { getComputedCSS } from './utils';\n\nexport function GridVisualizer( { clientId, contentRef } ) {\n\tconst isDistractionFree = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().isDistractionFree,\n\t\t[]\n\t);\n\tconst blockElement = useBlockElement( clientId );\n\n\tif ( isDistractionFree || ! blockElement ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopoverCover\n\t\t\tclassName=\"block-editor-grid-visualizer\"\n\t\t\tclientId={ clientId }\n\t\t\t__unstablePopoverSlot=\"block-toolbar\"\n\t\t>\n\t\t\t<GridVisualizerGrid\n\t\t\t\tref={ contentRef }\n\t\t\t\tblockElement={ blockElement }\n\t\t\t/>\n\t\t</BlockPopoverCover>\n\t);\n}\n\nconst GridVisualizerGrid = forwardRef( ( { blockElement }, ref ) => {\n\tconst [ gridInfo, setGridInfo ] = useState( () =>\n\t\tgetGridInfo( blockElement )\n\t);\n\tuseEffect( () => {\n\t\tconst observers = [];\n\t\tfor ( const element of [ blockElement, ...blockElement.children ] ) {\n\t\t\tconst observer = new window.ResizeObserver( () => {\n\t\t\t\tsetGridInfo( getGridInfo( blockElement ) );\n\t\t\t} );\n\t\t\tobserver.observe( element );\n\t\t\tobservers.push( observer );\n\t\t}\n\t\treturn () => {\n\t\t\tfor ( const observer of observers ) {\n\t\t\t\tobserver.disconnect();\n\t\t\t}\n\t\t};\n\t}, [ blockElement ] );\n\treturn (\n\t\t<div\n\t\t\tref={ ref }\n\t\t\tclassName=\"block-editor-grid-visualizer__grid\"\n\t\t\tstyle={ gridInfo.style }\n\t\t>\n\t\t\t{ Array.from( { length: gridInfo.numItems }, ( _, i ) => (\n\t\t\t\t<div key={ i } className=\"block-editor-grid-visualizer__item\" />\n\t\t\t) ) }\n\t\t</div>\n\t);\n} );\n\nfunction getGridInfo( blockElement ) {\n\tconst gridTemplateColumns = getComputedCSS(\n\t\tblockElement,\n\t\t'grid-template-columns'\n\t);\n\tconst gridTemplateRows = getComputedCSS(\n\t\tblockElement,\n\t\t'grid-template-rows'\n\t);\n\tconst numColumns = gridTemplateColumns.split( ' ' ).length;\n\tconst numRows = gridTemplateRows.split( ' ' ).length;\n\tconst numItems = numColumns * numRows;\n\treturn {\n\t\tnumItems,\n\t\tstyle: {\n\t\t\tgridTemplateColumns,\n\t\t\tgridTemplateRows,\n\t\t\tgap: getComputedCSS( blockElement, 'gap' ),\n\t\t\tpadding: getComputedCSS( blockElement, 'padding' ),\n\t\t},\n\t};\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,SAAS,EAAEC,UAAU,QAAQ,oBAAoB;AACpE,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,yBAAyB,IAAIC,eAAe,QAAQ,8CAA8C;AAC3G,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,cAAc,QAAQ,SAAS;AAExC,OAAO,SAASC,cAAcA,CAAE;EAAEC,QAAQ;EAAEC;AAAW,CAAC,EAAG;EAC1D,MAAMC,iBAAiB,GAAGV,SAAS,CAChCW,MAAM,IACPA,MAAM,CAAEN,gBAAiB,CAAC,CAACO,WAAW,CAAC,CAAC,CAACF,iBAAiB,EAC3D,EACD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AE;IAAEC,MAAM,EAAEf,QAAQ,CAACgB;EAAS,CAAC,EAAE,CAAEC,CAAC,EAAEC,CAAC,KAClDvB,aAAA;IAAKwB,GAAG,EAAGD,CAAG;IAACtB,SAAS,EAAC;EAAoC,CAAE,CAC9D,CACE,CAAC;AAER,CAAE,CAAC;AAEH,SAASM,WAAWA,CAAER,YAAY,EAAG;EACpC,MAAM0B,mBAAmB,GAAGjC,cAAc,CACzCO,YAAY,EACZ,uBACD,CAAC;EACD,MAAM2B,gBAAgB,GAAGlC,cAAc,CACtCO,YAAY,EACZ,oBACD,CAAC;EACD,MAAM4B,UAAU,GAAGF,mBAAmB,CAACG,KAAK,CAAE,GAAI,CAAC,CAACR,MAAM;EAC1D,MAAMS,OAAO,GAAGH,gBAAgB,CAACE,KAAK,CAAE,GAAI,CAAC,CAACR,MAAM;EACpD,MAAMC,QAAQ,GAAGM,UAAU,GAAGE,OAAO;EACrC,OAAO;IACNR,QAAQ;IACRJ,KAAK,EAAE;MACNQ,mBAAmB;MACnBC,gBAAgB;MAChBI,GAAG,EAAEtC,cAAc,CAAEO,YAAY,EAAE,KAAM,CAAC;MAC1CgC,OAAO,EAAEvC,cAAc,CAAEO,YAAY,EAAE,SAAU;IAClD;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -2,12 +2,12 @@ import { createElement, Fragment } from "react";
|
|
|
2
2
|
/**
|
|
3
3
|
* External dependencies
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import clsx from 'clsx';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import { useState, createPortal, forwardRef, useMemo, useEffect } from '@wordpress/element';
|
|
10
|
+
import { useState, createPortal, forwardRef, useMemo, useEffect, useRef } from '@wordpress/element';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
import { useResizeObserver, useMergeRefs, useRefEffect, useDisabled } from '@wordpress/compose';
|
|
13
13
|
import { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';
|
|
@@ -117,12 +117,15 @@ function Iframe({
|
|
|
117
117
|
scripts = ''
|
|
118
118
|
} = resolvedAssets;
|
|
119
119
|
const [iframeDocument, setIframeDocument] = useState();
|
|
120
|
+
const prevContainerWidth = useRef();
|
|
120
121
|
const [bodyClasses, setBodyClasses] = useState([]);
|
|
121
122
|
const clearerRef = useBlockSelectionClearer();
|
|
122
123
|
const [before, writingFlowRef, after] = useWritingFlow();
|
|
123
124
|
const [contentResizeListener, {
|
|
124
|
-
height: contentHeight
|
|
125
|
-
|
|
125
|
+
height: contentHeight
|
|
126
|
+
}] = useResizeObserver();
|
|
127
|
+
const [containerResizeListener, {
|
|
128
|
+
width: containerWidth
|
|
126
129
|
}] = useResizeObserver();
|
|
127
130
|
const setRef = useRefEffect(node => {
|
|
128
131
|
node._load = () => {
|
|
@@ -171,8 +174,10 @@ function Iframe({
|
|
|
171
174
|
iFrameDocument?.removeEventListener('drop', preventFileDropDefault);
|
|
172
175
|
};
|
|
173
176
|
}, []);
|
|
174
|
-
const
|
|
177
|
+
const [iframeWindowInnerHeight, setIframeWindowInnerHeight] = useState();
|
|
178
|
+
const iframeResizeRef = useRefEffect(node => {
|
|
175
179
|
const nodeWindow = node.ownerDocument.defaultView;
|
|
180
|
+
setIframeWindowInnerHeight(nodeWindow.innerHeight);
|
|
176
181
|
const onResize = () => {
|
|
177
182
|
setIframeWindowInnerHeight(nodeWindow.innerHeight);
|
|
178
183
|
};
|
|
@@ -181,7 +186,24 @@ function Iframe({
|
|
|
181
186
|
nodeWindow.removeEventListener('resize', onResize);
|
|
182
187
|
};
|
|
183
188
|
}, []);
|
|
184
|
-
const [
|
|
189
|
+
const [windowInnerWidth, setWindowInnerWidth] = useState();
|
|
190
|
+
const windowResizeRef = useRefEffect(node => {
|
|
191
|
+
const nodeWindow = node.ownerDocument.defaultView;
|
|
192
|
+
setWindowInnerWidth(nodeWindow.innerWidth);
|
|
193
|
+
const onResize = () => {
|
|
194
|
+
setWindowInnerWidth(nodeWindow.innerWidth);
|
|
195
|
+
};
|
|
196
|
+
nodeWindow.addEventListener('resize', onResize);
|
|
197
|
+
return () => {
|
|
198
|
+
nodeWindow.removeEventListener('resize', onResize);
|
|
199
|
+
};
|
|
200
|
+
}, []);
|
|
201
|
+
const isZoomedOut = scale !== 1;
|
|
202
|
+
useEffect(() => {
|
|
203
|
+
if (!isZoomedOut) {
|
|
204
|
+
prevContainerWidth.current = containerWidth;
|
|
205
|
+
}
|
|
206
|
+
}, [containerWidth, isZoomedOut]);
|
|
185
207
|
const disabledRef = useDisabled({
|
|
186
208
|
isDisabled: !readonly
|
|
187
209
|
});
|
|
@@ -189,7 +211,7 @@ function Iframe({
|
|
|
189
211
|
// Avoid resize listeners when not needed, these will trigger
|
|
190
212
|
// unnecessary re-renders when animating the iframe width, or when
|
|
191
213
|
// expanding preview iframes.
|
|
192
|
-
|
|
214
|
+
isZoomedOut ? iframeResizeRef : null]);
|
|
193
215
|
|
|
194
216
|
// Correct doctype is required to enable rendering in standards
|
|
195
217
|
// mode. Also preload the styles to avoid a flash of unstyled
|
|
@@ -226,36 +248,33 @@ function Iframe({
|
|
|
226
248
|
return [_src, () => URL.revokeObjectURL(_src)];
|
|
227
249
|
}, [html]);
|
|
228
250
|
useEffect(() => cleanup, [cleanup]);
|
|
229
|
-
scale = typeof scale === 'function' ? scale(contentWidth, contentHeight) : scale;
|
|
230
251
|
useEffect(() => {
|
|
231
|
-
if (!iframeDocument) {
|
|
252
|
+
if (!iframeDocument || !isZoomedOut) {
|
|
232
253
|
return;
|
|
233
254
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
}, [scale, frameSize, iframeDocument, contentHeight, iframeWindowInnerHeight, contentWidth]);
|
|
255
|
+
iframeDocument.documentElement.classList.add('is-zoomed-out');
|
|
256
|
+
const maxWidth = 800;
|
|
257
|
+
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-scale', scale === 'default' ? Math.min(containerWidth, maxWidth) / prevContainerWidth.current : scale);
|
|
258
|
+
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-frame-size', typeof frameSize === 'number' ? `${frameSize}px` : frameSize);
|
|
259
|
+
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-content-height', `${contentHeight}px`);
|
|
260
|
+
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-inner-height', `${iframeWindowInnerHeight}px`);
|
|
261
|
+
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-container-width', `${containerWidth}px`);
|
|
262
|
+
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-prev-container-width', `${prevContainerWidth.current}px`);
|
|
263
|
+
return () => {
|
|
264
|
+
iframeDocument.documentElement.classList.remove('is-zoomed-out');
|
|
265
|
+
iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-scale');
|
|
266
|
+
iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-frame-size');
|
|
267
|
+
iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-content-height');
|
|
268
|
+
iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-inner-height');
|
|
269
|
+
iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-container-width');
|
|
270
|
+
iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-prev-container-width');
|
|
271
|
+
};
|
|
272
|
+
}, [scale, frameSize, iframeDocument, iframeWindowInnerHeight, contentHeight, containerWidth, windowInnerWidth, isZoomedOut]);
|
|
254
273
|
|
|
255
274
|
// Make sure to not render the before and after focusable div elements in view
|
|
256
275
|
// mode. They're only needed to capture focus in edit mode.
|
|
257
276
|
const shouldRenderFocusCaptureElements = tabIndex >= 0 && !isPreviewMode;
|
|
258
|
-
|
|
277
|
+
const iframe = createElement(Fragment, null, shouldRenderFocusCaptureElements && before, createElement("iframe", {
|
|
259
278
|
...props,
|
|
260
279
|
style: {
|
|
261
280
|
border: 0,
|
|
@@ -282,7 +301,17 @@ function Iframe({
|
|
|
282
301
|
// so we need to stop the propagation of this event to avoid
|
|
283
302
|
// duplication.
|
|
284
303
|
if (event.currentTarget.ownerDocument !== event.target.ownerDocument) {
|
|
304
|
+
// We should only stop propagation of the React event,
|
|
305
|
+
// the native event should further bubble inside the
|
|
306
|
+
// iframe to the document and window.
|
|
307
|
+
// Alternatively, we could consider redispatching the
|
|
308
|
+
// native event in the iframe.
|
|
309
|
+
const {
|
|
310
|
+
stopPropagation
|
|
311
|
+
} = event.nativeEvent;
|
|
312
|
+
event.nativeEvent.stopPropagation = () => {};
|
|
285
313
|
event.stopPropagation();
|
|
314
|
+
event.nativeEvent.stopPropagation = stopPropagation;
|
|
286
315
|
bubbleEvent(event, window.KeyboardEvent, event.currentTarget);
|
|
287
316
|
}
|
|
288
317
|
}
|
|
@@ -292,10 +321,20 @@ function Iframe({
|
|
|
292
321
|
/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */
|
|
293
322
|
createElement("body", {
|
|
294
323
|
ref: bodyRef,
|
|
295
|
-
className:
|
|
324
|
+
className: clsx('block-editor-iframe__body', 'editor-styles-wrapper', ...bodyClasses)
|
|
296
325
|
}, contentResizeListener, createElement(StyleProvider, {
|
|
297
326
|
document: iframeDocument
|
|
298
327
|
}, children)), iframeDocument.documentElement)), shouldRenderFocusCaptureElements && after);
|
|
328
|
+
return createElement("div", {
|
|
329
|
+
className: "block-editor-iframe__container",
|
|
330
|
+
ref: windowResizeRef
|
|
331
|
+
}, containerResizeListener, createElement("div", {
|
|
332
|
+
className: clsx('block-editor-iframe__scale-container', isZoomedOut && 'is-zoomed-out'),
|
|
333
|
+
style: {
|
|
334
|
+
'--wp-block-editor-iframe-zoom-out-container-width': isZoomedOut && `${containerWidth}px`,
|
|
335
|
+
'--wp-block-editor-iframe-zoom-out-prev-container-width': isZoomedOut && `${prevContainerWidth.current}px`
|
|
336
|
+
}
|
|
337
|
+
}, iframe));
|
|
299
338
|
}
|
|
300
339
|
function IframeIfReady(props, ref) {
|
|
301
340
|
const isInitialised = useSelect(select => select(blockEditorStore).getSettings().__internalIsInitialized, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","useState","createPortal","forwardRef","useMemo","useEffect","__","useResizeObserver","useMergeRefs","useRefEffect","useDisabled","__experimentalStyleProvider","StyleProvider","useSelect","useBlockSelectionClearer","useWritingFlow","getCompatibilityStyles","store","blockEditorStore","bubbleEvent","event","Constructor","frame","init","key","contentDocument","defaultView","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","defaultPrevented","preventDefault","cancelled","dispatchEvent","useBubbleEvents","iframeDocument","frameElement","html","documentElement","eventTypes","handlers","name","prototype","Object","getPrototypeOf","constructorName","constructor","window","addEventListener","removeEventListener","Iframe","contentRef","children","tabIndex","scale","frameSize","readonly","forwardedRef","ref","title","props","resolvedAssets","isPreviewMode","select","getSettings","settings","__unstableResolvedAssets","__unstableIsPreviewMode","styles","scripts","setIframeDocument","bodyClasses","setBodyClasses","clearerRef","before","writingFlowRef","after","contentResizeListener","height","contentHeight","width","contentWidth","setRef","node","_load","iFrameDocument","preventFileDropDefault","onLoad","ownerDocument","classList","add","Array","from","body","filter","startsWith","dir","compatStyle","getElementById","id","head","appendChild","cloneNode","console","warn","windowResizeRef","nodeWindow","onResize","setIframeWindowInnerHeight","innerHeight","iframeWindowInnerHeight","disabledRef","isDisabled","bodyRef","src","cleanup","_src","URL","createObjectURL","Blob","revokeObjectURL","bottomFrameSize","style","transform","marginTop","marginBottom","minHeight","Math","floor","remove","shouldRenderFocusCaptureElements","createElement","Fragment","border","transition","onKeyDown","currentTarget","target","stopPropagation","KeyboardEvent","className","document","IframeIfReady","isInitialised","__internalIsInitialized"],"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\nimport { getCompatibilityStyles } from './get-compatibility-styles';\nimport { store as blockEditorStore } from '../../store';\n\nfunction bubbleEvent( event, Constructor, frame ) {\n\tconst init = {};\n\n\tfor ( const key in event ) {\n\t\tinit[ key ] = event[ key ];\n\t}\n\n\t// Check if the event is a MouseEvent generated within the iframe.\n\t// If so, adjust the coordinates to be relative to the position of\n\t// the iframe. This ensures that components such as Draggable\n\t// receive coordinates relative to the window, instead of relative\n\t// to the iframe. Without this, the Draggable event handler would\n\t// result in components \"jumping\" position as soon as the user\n\t// drags over the iframe.\n\tif ( event instanceof frame.contentDocument.defaultView.MouseEvent ) {\n\t\tconst rect = frame.getBoundingClientRect();\n\t\tinit.clientX += rect.left;\n\t\tinit.clientY += rect.top;\n\t}\n\n\tconst newEvent = new Constructor( event.type, init );\n\tif ( init.defaultPrevented ) {\n\t\tnewEvent.preventDefault();\n\t}\n\tconst cancelled = ! frame.dispatchEvent( newEvent );\n\n\tif ( cancelled ) {\n\t\tevent.preventDefault();\n\t}\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} iframeDocument Document to attach listeners to.\n */\nfunction useBubbleEvents( iframeDocument ) {\n\treturn useRefEffect( () => {\n\t\tconst { defaultView } = iframeDocument;\n\t\tif ( ! defaultView ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { frameElement } = defaultView;\n\t\tconst html = iframeDocument.documentElement;\n\t\tconst eventTypes = [ 'dragover', 'mousemove' ];\n\t\tconst handlers = {};\n\t\tfor ( const name of eventTypes ) {\n\t\t\thandlers[ name ] = ( event ) => {\n\t\t\t\tconst prototype = Object.getPrototypeOf( event );\n\t\t\t\tconst constructorName = prototype.constructor.name;\n\t\t\t\tconst Constructor = window[ constructorName ];\n\t\t\t\tbubbleEvent( event, Constructor, frameElement );\n\t\t\t};\n\t\t\thtml.addEventListener( name, handlers[ name ] );\n\t\t}\n\n\t\treturn () => {\n\t\t\tfor ( const name of eventTypes ) {\n\t\t\t\thtml.removeEventListener( name, handlers[ name ] );\n\t\t\t}\n\t\t};\n\t} );\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\ttabIndex = 0,\n\tscale = 1,\n\tframeSize = 0,\n\treadonly,\n\tforwardedRef: ref,\n\ttitle = __( 'Editor canvas' ),\n\t...props\n} ) {\n\tconst { resolvedAssets, isPreviewMode } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\t\treturn {\n\t\t\tresolvedAssets: settings.__unstableResolvedAssets,\n\t\t\tisPreviewMode: settings.__unstableIsPreviewMode,\n\t\t};\n\t}, [] );\n\tconst { styles = '', scripts = '' } = resolvedAssets;\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [\n\t\tcontentResizeListener,\n\t\t{ height: contentHeight, width: contentWidth },\n\t] = useResizeObserver();\n\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tnode._load = () => {\n\t\t\tsetIframeDocument( node.contentDocument );\n\t\t};\n\t\tlet iFrameDocument;\n\t\t// Prevent the default browser action for files dropped outside of dropzones.\n\t\tfunction preventFileDropDefault( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tfunction onLoad() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tdocumentElement.classList.add( 'block-editor-iframe__html' );\n\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\n\t\t\tfor ( const compatStyle of getCompatibilityStyles() ) {\n\t\t\t\tif ( contentDocument.getElementById( compatStyle.id ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcontentDocument.head.appendChild(\n\t\t\t\t\tcompatStyle.cloneNode( true )\n\t\t\t\t);\n\n\t\t\t\tif ( ! isPreviewMode ) {\n\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`${ compatStyle.id } was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.`,\n\t\t\t\t\t\tcompatStyle\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'load', onLoad );\n\n\t\treturn () => {\n\t\t\tdelete node._load;\n\t\t\tnode.removeEventListener( 'load', onLoad );\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst windowResizeRef = useRefEffect( ( node ) => {\n\t\tconst nodeWindow = node.ownerDocument.defaultView;\n\n\t\tconst onResize = () => {\n\t\t\tsetIframeWindowInnerHeight( nodeWindow.innerHeight );\n\t\t};\n\t\tnodeWindow.addEventListener( 'resize', onResize );\n\t\treturn () => {\n\t\t\tnodeWindow.removeEventListener( 'resize', onResize );\n\t\t};\n\t}, [] );\n\n\tconst [ iframeWindowInnerHeight, setIframeWindowInnerHeight ] = useState();\n\n\tconst disabledRef = useDisabled( { isDisabled: ! readonly } );\n\tconst bodyRef = useMergeRefs( [\n\t\tuseBubbleEvents( iframeDocument ),\n\t\tcontentRef,\n\t\tclearerRef,\n\t\twritingFlowRef,\n\t\tdisabledRef,\n\t\t// Avoid resize listeners when not needed, these will trigger\n\t\t// unnecessary re-renders when animating the iframe width, or when\n\t\t// expanding preview iframes.\n\t\tscale === 1 ? null : windowResizeRef,\n\t] );\n\n\t// Correct doctype is required to enable rendering in standards\n\t// mode. Also preload the styles to avoid a flash of unstyled\n\t// content.\n\tconst html = `<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset=\"utf-8\">\n\t\t<script>window.frameElement._load()</script>\n\t\t<style>\n\t\t\thtml{\n\t\t\t\theight: auto !important;\n\t\t\t\tmin-height: 100%;\n\t\t\t}\n\t\t\t/* Lowest specificity to not override global styles */\n\t\t\t:where(body) {\n\t\t\t\tmargin: 0;\n\t\t\t\t/* Default background color in case zoom out mode background\n\t\t\t\tcolors the html element */\n\t\t\t\tbackground-color: white;\n\t\t\t}\n\t\t</style>\n\t\t${ styles }\n\t\t${ scripts }\n\t</head>\n\t<body>\n\t\t<script>document.currentScript.parentElement.remove()</script>\n\t</body>\n</html>`;\n\n\tconst [ src, cleanup ] = useMemo( () => {\n\t\tconst _src = URL.createObjectURL(\n\t\t\tnew window.Blob( [ html ], { type: 'text/html' } )\n\t\t);\n\t\treturn [ _src, () => URL.revokeObjectURL( _src ) ];\n\t}, [ html ] );\n\n\tuseEffect( () => cleanup, [ cleanup ] );\n\n\tscale =\n\t\ttypeof scale === 'function'\n\t\t\t? scale( contentWidth, contentHeight )\n\t\t\t: scale;\n\n\tuseEffect( () => {\n\t\tif ( ! iframeDocument ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( scale !== 1 ) {\n\t\t\t// Hack to get proper margins when scaling the iframe document.\n\t\t\tconst bottomFrameSize = frameSize - contentHeight * ( 1 - scale );\n\n\t\t\tiframeDocument.body.classList.add( 'is-zoomed-out' );\n\n\t\t\tiframeDocument.documentElement.style.transform = `scale( ${ scale } )`;\n\t\t\tiframeDocument.documentElement.style.marginTop = `${ frameSize }px`;\n\t\t\t// TODO: `marginBottom` doesn't work in Firefox. We need another way to do this.\n\t\t\tiframeDocument.documentElement.style.marginBottom = `${ bottomFrameSize }px`;\n\t\t\tif ( iframeWindowInnerHeight > contentHeight * scale ) {\n\t\t\t\tiframeDocument.body.style.minHeight = `${ Math.floor(\n\t\t\t\t\t( iframeWindowInnerHeight - 2 * frameSize ) / scale\n\t\t\t\t) }px`;\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\tiframeDocument.body.classList.remove( 'is-zoomed-out' );\n\t\t\t\tiframeDocument.documentElement.style.transform = '';\n\t\t\t\tiframeDocument.documentElement.style.marginTop = '';\n\t\t\t\tiframeDocument.documentElement.style.marginBottom = '';\n\t\t\t\tiframeDocument.body.style.minHeight = '';\n\t\t\t};\n\t\t}\n\t}, [\n\t\tscale,\n\t\tframeSize,\n\t\tiframeDocument,\n\t\tcontentHeight,\n\t\tiframeWindowInnerHeight,\n\t\tcontentWidth,\n\t] );\n\n\t// Make sure to not render the before and after focusable div elements in view\n\t// mode. They're only needed to capture focus in edit mode.\n\tconst shouldRenderFocusCaptureElements = tabIndex >= 0 && ! isPreviewMode;\n\n\treturn (\n\t\t<>\n\t\t\t{ shouldRenderFocusCaptureElements && before }\n\t\t\t{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tstyle={ {\n\t\t\t\t\tborder: 0,\n\t\t\t\t\t...props.style,\n\t\t\t\t\theight: props.style?.height,\n\t\t\t\t\ttransition: 'all .3s',\n\t\t\t\t} }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards\n\t\t\t\t// mode. Also preload the styles to avoid a flash of unstyled\n\t\t\t\t// content.\n\t\t\t\tsrc={ src }\n\t\t\t\ttitle={ title }\n\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\tif ( props.onKeyDown ) {\n\t\t\t\t\t\tprops.onKeyDown( event );\n\t\t\t\t\t}\n\t\t\t\t\t// If the event originates from inside the iframe, it means\n\t\t\t\t\t// it bubbled through the portal, but only with React\n\t\t\t\t\t// events. We need to to bubble native events as well,\n\t\t\t\t\t// though by doing so we also trigger another React event,\n\t\t\t\t\t// so we need to stop the propagation of this event to avoid\n\t\t\t\t\t// duplication.\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.currentTarget.ownerDocument !==\n\t\t\t\t\t\tevent.target.ownerDocument\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tbubbleEvent(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\twindow.KeyboardEvent,\n\t\t\t\t\t\t\tevent.currentTarget\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t// We want to prevent React events from bubbling throught the iframe\n\t\t\t\t\t\t// we bubble these manually.\n\t\t\t\t\t\t/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */\n\t\t\t\t\t\t<body\n\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t'editor-styles-wrapper',\n\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t</body>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ shouldRenderFocusCaptureElements && after }\n\t\t</>\n\t);\n}\n\nfunction IframeIfReady( props, ref ) {\n\tconst isInitialised = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__internalIsInitialized,\n\t\t[]\n\t);\n\n\t// We shouldn't render the iframe until the editor settings are initialised.\n\t// The initial settings are needed to get the styles for the srcDoc, which\n\t// cannot be changed after the iframe is mounted. srcDoc is used to to set\n\t// the initial iframe HTML, which is required to avoid a flash of unstyled\n\t// content.\n\tif ( ! isInitialised ) {\n\t\treturn null;\n\t}\n\n\treturn <Iframe { ...props } forwardedRef={ ref } />;\n}\n\nexport default forwardRef( IframeIfReady );\n"],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;QACvB7H,WAAW,CACVC,KAAK,EACLiC,MAAM,CAAC4F,aAAa,EACpB7H,KAAK,CAAC0H,aACP,CAAC;MACF;IACD;EAAG,GAEDrG,cAAc,IACfvC,YAAY;EACX;EACA;EACA;EACAuI,aAAA;IACCzE,GAAG,EAAGuD,OAAS;IACf2B,SAAS,EAAGlJ,UAAU,CACrB,2BAA2B,EAC3B,uBAAuB,EACvB,GAAG6E,WACJ;EAAG,GAEDM,qBAAqB,EACvBsD,aAAA,CAAC7H,aAAa;IAACuI,QAAQ,EAAG1G;EAAgB,GACvCiB,QACY,CACV,CAAC,EACPjB,cAAc,CAACG,eAChB,CACM,CAAC,EACP4F,gCAAgC,IAAItD,KACrC,CAAC;AAEL;AAEA,SAASkE,aAAaA,CAAElF,KAAK,EAAEF,GAAG,EAAG;EACpC,MAAMqF,aAAa,GAAGxI,SAAS,CAC5BwD,MAAM,IACPA,MAAM,CAAEnD,gBAAiB,CAAC,CAACoD,WAAW,CAAC,CAAC,CAACgF,uBAAuB,EACjE,EACD,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA,IAAK,CAAED,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,OAAOZ,aAAA,CAACjF,MAAM;IAAA,GAAMU,KAAK;IAAGH,YAAY,EAAGC;EAAK,CAAE,CAAC;AACpD;AAEA,eAAe7D,UAAU,CAAEiJ,aAAc,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","useState","createPortal","forwardRef","useMemo","useEffect","useRef","__","useResizeObserver","useMergeRefs","useRefEffect","useDisabled","__experimentalStyleProvider","StyleProvider","useSelect","useBlockSelectionClearer","useWritingFlow","getCompatibilityStyles","store","blockEditorStore","bubbleEvent","event","Constructor","frame","init","key","contentDocument","defaultView","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","defaultPrevented","preventDefault","cancelled","dispatchEvent","useBubbleEvents","iframeDocument","frameElement","html","documentElement","eventTypes","handlers","name","prototype","Object","getPrototypeOf","constructorName","constructor","window","addEventListener","removeEventListener","Iframe","contentRef","children","tabIndex","scale","frameSize","readonly","forwardedRef","ref","title","props","resolvedAssets","isPreviewMode","select","getSettings","settings","__unstableResolvedAssets","__unstableIsPreviewMode","styles","scripts","setIframeDocument","prevContainerWidth","bodyClasses","setBodyClasses","clearerRef","before","writingFlowRef","after","contentResizeListener","height","contentHeight","containerResizeListener","width","containerWidth","setRef","node","_load","iFrameDocument","preventFileDropDefault","onLoad","ownerDocument","classList","add","Array","from","body","filter","startsWith","dir","compatStyle","getElementById","id","head","appendChild","cloneNode","console","warn","iframeWindowInnerHeight","setIframeWindowInnerHeight","iframeResizeRef","nodeWindow","innerHeight","onResize","windowInnerWidth","setWindowInnerWidth","windowResizeRef","innerWidth","isZoomedOut","current","disabledRef","isDisabled","bodyRef","src","cleanup","_src","URL","createObjectURL","Blob","revokeObjectURL","maxWidth","style","setProperty","Math","min","remove","removeProperty","shouldRenderFocusCaptureElements","iframe","createElement","Fragment","border","transition","onKeyDown","currentTarget","target","stopPropagation","nativeEvent","KeyboardEvent","className","document","IframeIfReady","isInitialised","__internalIsInitialized"],"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseEffect,\n\tuseRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\nimport { getCompatibilityStyles } from './get-compatibility-styles';\nimport { store as blockEditorStore } from '../../store';\n\nfunction bubbleEvent( event, Constructor, frame ) {\n\tconst init = {};\n\n\tfor ( const key in event ) {\n\t\tinit[ key ] = event[ key ];\n\t}\n\n\t// Check if the event is a MouseEvent generated within the iframe.\n\t// If so, adjust the coordinates to be relative to the position of\n\t// the iframe. This ensures that components such as Draggable\n\t// receive coordinates relative to the window, instead of relative\n\t// to the iframe. Without this, the Draggable event handler would\n\t// result in components \"jumping\" position as soon as the user\n\t// drags over the iframe.\n\tif ( event instanceof frame.contentDocument.defaultView.MouseEvent ) {\n\t\tconst rect = frame.getBoundingClientRect();\n\t\tinit.clientX += rect.left;\n\t\tinit.clientY += rect.top;\n\t}\n\n\tconst newEvent = new Constructor( event.type, init );\n\tif ( init.defaultPrevented ) {\n\t\tnewEvent.preventDefault();\n\t}\n\tconst cancelled = ! frame.dispatchEvent( newEvent );\n\n\tif ( cancelled ) {\n\t\tevent.preventDefault();\n\t}\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} iframeDocument Document to attach listeners to.\n */\nfunction useBubbleEvents( iframeDocument ) {\n\treturn useRefEffect( () => {\n\t\tconst { defaultView } = iframeDocument;\n\t\tif ( ! defaultView ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { frameElement } = defaultView;\n\t\tconst html = iframeDocument.documentElement;\n\t\tconst eventTypes = [ 'dragover', 'mousemove' ];\n\t\tconst handlers = {};\n\t\tfor ( const name of eventTypes ) {\n\t\t\thandlers[ name ] = ( event ) => {\n\t\t\t\tconst prototype = Object.getPrototypeOf( event );\n\t\t\t\tconst constructorName = prototype.constructor.name;\n\t\t\t\tconst Constructor = window[ constructorName ];\n\t\t\t\tbubbleEvent( event, Constructor, frameElement );\n\t\t\t};\n\t\t\thtml.addEventListener( name, handlers[ name ] );\n\t\t}\n\n\t\treturn () => {\n\t\t\tfor ( const name of eventTypes ) {\n\t\t\t\thtml.removeEventListener( name, handlers[ name ] );\n\t\t\t}\n\t\t};\n\t} );\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\ttabIndex = 0,\n\tscale = 1,\n\tframeSize = 0,\n\treadonly,\n\tforwardedRef: ref,\n\ttitle = __( 'Editor canvas' ),\n\t...props\n} ) {\n\tconst { resolvedAssets, isPreviewMode } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\t\treturn {\n\t\t\tresolvedAssets: settings.__unstableResolvedAssets,\n\t\t\tisPreviewMode: settings.__unstableIsPreviewMode,\n\t\t};\n\t}, [] );\n\tconst { styles = '', scripts = '' } = resolvedAssets;\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst prevContainerWidth = useRef();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst [ containerResizeListener, { width: containerWidth } ] =\n\t\tuseResizeObserver();\n\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tnode._load = () => {\n\t\t\tsetIframeDocument( node.contentDocument );\n\t\t};\n\t\tlet iFrameDocument;\n\t\t// Prevent the default browser action for files dropped outside of dropzones.\n\t\tfunction preventFileDropDefault( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tfunction onLoad() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tdocumentElement.classList.add( 'block-editor-iframe__html' );\n\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\n\t\t\tfor ( const compatStyle of getCompatibilityStyles() ) {\n\t\t\t\tif ( contentDocument.getElementById( compatStyle.id ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcontentDocument.head.appendChild(\n\t\t\t\t\tcompatStyle.cloneNode( true )\n\t\t\t\t);\n\n\t\t\t\tif ( ! isPreviewMode ) {\n\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`${ compatStyle.id } was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.`,\n\t\t\t\t\t\tcompatStyle\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'load', onLoad );\n\n\t\treturn () => {\n\t\t\tdelete node._load;\n\t\t\tnode.removeEventListener( 'load', onLoad );\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst [ iframeWindowInnerHeight, setIframeWindowInnerHeight ] = useState();\n\n\tconst iframeResizeRef = useRefEffect( ( node ) => {\n\t\tconst nodeWindow = node.ownerDocument.defaultView;\n\n\t\tsetIframeWindowInnerHeight( nodeWindow.innerHeight );\n\t\tconst onResize = () => {\n\t\t\tsetIframeWindowInnerHeight( nodeWindow.innerHeight );\n\t\t};\n\t\tnodeWindow.addEventListener( 'resize', onResize );\n\t\treturn () => {\n\t\t\tnodeWindow.removeEventListener( 'resize', onResize );\n\t\t};\n\t}, [] );\n\n\tconst [ windowInnerWidth, setWindowInnerWidth ] = useState();\n\n\tconst windowResizeRef = useRefEffect( ( node ) => {\n\t\tconst nodeWindow = node.ownerDocument.defaultView;\n\n\t\tsetWindowInnerWidth( nodeWindow.innerWidth );\n\t\tconst onResize = () => {\n\t\t\tsetWindowInnerWidth( nodeWindow.innerWidth );\n\t\t};\n\t\tnodeWindow.addEventListener( 'resize', onResize );\n\t\treturn () => {\n\t\t\tnodeWindow.removeEventListener( 'resize', onResize );\n\t\t};\n\t}, [] );\n\n\tconst isZoomedOut = scale !== 1;\n\n\tuseEffect( () => {\n\t\tif ( ! isZoomedOut ) {\n\t\t\tprevContainerWidth.current = containerWidth;\n\t\t}\n\t}, [ containerWidth, isZoomedOut ] );\n\n\tconst disabledRef = useDisabled( { isDisabled: ! readonly } );\n\tconst bodyRef = useMergeRefs( [\n\t\tuseBubbleEvents( iframeDocument ),\n\t\tcontentRef,\n\t\tclearerRef,\n\t\twritingFlowRef,\n\t\tdisabledRef,\n\t\t// Avoid resize listeners when not needed, these will trigger\n\t\t// unnecessary re-renders when animating the iframe width, or when\n\t\t// expanding preview iframes.\n\t\tisZoomedOut ? iframeResizeRef : null,\n\t] );\n\n\t// Correct doctype is required to enable rendering in standards\n\t// mode. Also preload the styles to avoid a flash of unstyled\n\t// content.\n\tconst html = `<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset=\"utf-8\">\n\t\t<script>window.frameElement._load()</script>\n\t\t<style>\n\t\t\thtml{\n\t\t\t\theight: auto !important;\n\t\t\t\tmin-height: 100%;\n\t\t\t}\n\t\t\t/* Lowest specificity to not override global styles */\n\t\t\t:where(body) {\n\t\t\t\tmargin: 0;\n\t\t\t\t/* Default background color in case zoom out mode background\n\t\t\t\tcolors the html element */\n\t\t\t\tbackground-color: white;\n\t\t\t}\n\t\t</style>\n\t\t${ styles }\n\t\t${ scripts }\n\t</head>\n\t<body>\n\t\t<script>document.currentScript.parentElement.remove()</script>\n\t</body>\n</html>`;\n\n\tconst [ src, cleanup ] = useMemo( () => {\n\t\tconst _src = URL.createObjectURL(\n\t\t\tnew window.Blob( [ html ], { type: 'text/html' } )\n\t\t);\n\t\treturn [ _src, () => URL.revokeObjectURL( _src ) ];\n\t}, [ html ] );\n\n\tuseEffect( () => cleanup, [ cleanup ] );\n\n\tuseEffect( () => {\n\t\tif ( ! iframeDocument || ! isZoomedOut ) {\n\t\t\treturn;\n\t\t}\n\n\t\tiframeDocument.documentElement.classList.add( 'is-zoomed-out' );\n\n\t\tconst maxWidth = 800;\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scale',\n\t\t\tscale === 'default'\n\t\t\t\t? Math.min( containerWidth, maxWidth ) /\n\t\t\t\t\t\tprevContainerWidth.current\n\t\t\t\t: scale\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-frame-size',\n\t\t\ttypeof frameSize === 'number' ? `${ frameSize }px` : frameSize\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-content-height',\n\t\t\t`${ contentHeight }px`\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-inner-height',\n\t\t\t`${ iframeWindowInnerHeight }px`\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-container-width',\n\t\t\t`${ containerWidth }px`\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-prev-container-width',\n\t\t\t`${ prevContainerWidth.current }px`\n\t\t);\n\n\t\treturn () => {\n\t\t\tiframeDocument.documentElement.classList.remove( 'is-zoomed-out' );\n\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-frame-size'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-content-height'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-inner-height'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-container-width'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-prev-container-width'\n\t\t\t);\n\t\t};\n\t}, [\n\t\tscale,\n\t\tframeSize,\n\t\tiframeDocument,\n\t\tiframeWindowInnerHeight,\n\t\tcontentHeight,\n\t\tcontainerWidth,\n\t\twindowInnerWidth,\n\t\tisZoomedOut,\n\t] );\n\n\t// Make sure to not render the before and after focusable div elements in view\n\t// mode. They're only needed to capture focus in edit mode.\n\tconst shouldRenderFocusCaptureElements = tabIndex >= 0 && ! isPreviewMode;\n\n\tconst iframe = (\n\t\t<>\n\t\t\t{ shouldRenderFocusCaptureElements && before }\n\t\t\t{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tstyle={ {\n\t\t\t\t\tborder: 0,\n\t\t\t\t\t...props.style,\n\t\t\t\t\theight: props.style?.height,\n\t\t\t\t\ttransition: 'all .3s',\n\t\t\t\t} }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards\n\t\t\t\t// mode. Also preload the styles to avoid a flash of unstyled\n\t\t\t\t// content.\n\t\t\t\tsrc={ src }\n\t\t\t\ttitle={ title }\n\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\tif ( props.onKeyDown ) {\n\t\t\t\t\t\tprops.onKeyDown( event );\n\t\t\t\t\t}\n\t\t\t\t\t// If the event originates from inside the iframe, it means\n\t\t\t\t\t// it bubbled through the portal, but only with React\n\t\t\t\t\t// events. We need to to bubble native events as well,\n\t\t\t\t\t// though by doing so we also trigger another React event,\n\t\t\t\t\t// so we need to stop the propagation of this event to avoid\n\t\t\t\t\t// duplication.\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.currentTarget.ownerDocument !==\n\t\t\t\t\t\tevent.target.ownerDocument\n\t\t\t\t\t) {\n\t\t\t\t\t\t// We should only stop propagation of the React event,\n\t\t\t\t\t\t// the native event should further bubble inside the\n\t\t\t\t\t\t// iframe to the document and window.\n\t\t\t\t\t\t// Alternatively, we could consider redispatching the\n\t\t\t\t\t\t// native event in the iframe.\n\t\t\t\t\t\tconst { stopPropagation } = event.nativeEvent;\n\t\t\t\t\t\tevent.nativeEvent.stopPropagation = () => {};\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tevent.nativeEvent.stopPropagation = stopPropagation;\n\t\t\t\t\t\tbubbleEvent(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\twindow.KeyboardEvent,\n\t\t\t\t\t\t\tevent.currentTarget\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t// We want to prevent React events from bubbling throught the iframe\n\t\t\t\t\t\t// we bubble these manually.\n\t\t\t\t\t\t/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */\n\t\t\t\t\t\t<body\n\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t'editor-styles-wrapper',\n\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t</body>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ shouldRenderFocusCaptureElements && after }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-iframe__container\" ref={ windowResizeRef }>\n\t\t\t{ containerResizeListener }\n\t\t\t<div\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-editor-iframe__scale-container',\n\t\t\t\t\tisZoomedOut && 'is-zoomed-out'\n\t\t\t\t) }\n\t\t\t\tstyle={ {\n\t\t\t\t\t'--wp-block-editor-iframe-zoom-out-container-width':\n\t\t\t\t\t\tisZoomedOut && `${ containerWidth }px`,\n\t\t\t\t\t'--wp-block-editor-iframe-zoom-out-prev-container-width':\n\t\t\t\t\t\tisZoomedOut && `${ prevContainerWidth.current }px`,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ iframe }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nfunction IframeIfReady( props, ref ) {\n\tconst isInitialised = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__internalIsInitialized,\n\t\t[]\n\t);\n\n\t// We shouldn't render the iframe until the editor settings are initialised.\n\t// The initial settings are needed to get the styles for the srcDoc, which\n\t// cannot be changed after the iframe is mounted. srcDoc is used to to set\n\t// the initial iframe HTML, which is required to avoid a flash of unstyled\n\t// content.\n\tif ( ! isInitialised ) {\n\t\treturn null;\n\t}\n\n\treturn <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,CAACwF,uBAAuB,EACjE,EACD,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA,IAAK,CAAED,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,OAAOb,aAAA,CAACxF,MAAM;IAAA,GAAMU,KAAK;IAAGH,YAAY,EAAGC;EAAK,CAAE,CAAC;AACpD;AAEA,eAAe9D,UAAU,CAAE0J,aAAc,CAAC","ignoreList":[]}
|
|
@@ -9,9 +9,10 @@ import { __ } from '@wordpress/i18n';
|
|
|
9
9
|
/**
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
|
+
import { useSettings } from '../use-settings';
|
|
12
13
|
import { POPOVER_PROPS } from './constants';
|
|
13
14
|
import { useImageEditingContext } from './context';
|
|
14
|
-
function
|
|
15
|
+
function AspectRatioGroup({
|
|
15
16
|
aspectRatios,
|
|
16
17
|
isDisabled,
|
|
17
18
|
label,
|
|
@@ -21,18 +22,37 @@ function AspectGroup({
|
|
|
21
22
|
return createElement(MenuGroup, {
|
|
22
23
|
label: label
|
|
23
24
|
}, aspectRatios.map(({
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
name,
|
|
26
|
+
slug,
|
|
27
|
+
ratio
|
|
26
28
|
}) => createElement(MenuItem, {
|
|
27
|
-
key:
|
|
29
|
+
key: slug,
|
|
28
30
|
disabled: isDisabled,
|
|
29
31
|
onClick: () => {
|
|
30
|
-
onClick(
|
|
32
|
+
onClick(ratio);
|
|
31
33
|
},
|
|
32
34
|
role: "menuitemradio",
|
|
33
|
-
isSelected:
|
|
34
|
-
icon:
|
|
35
|
-
},
|
|
35
|
+
isSelected: ratio === value,
|
|
36
|
+
icon: ratio === value ? check : undefined
|
|
37
|
+
}, name)));
|
|
38
|
+
}
|
|
39
|
+
export function ratioToNumber(str) {
|
|
40
|
+
// TODO: support two-value aspect ratio?
|
|
41
|
+
// https://css-tricks.com/almanac/properties/a/aspect-ratio/#aa-it-can-take-two-values
|
|
42
|
+
const [a, b, ...rest] = str.split('/').map(Number);
|
|
43
|
+
if (a <= 0 || b <= 0 || Number.isNaN(a) || Number.isNaN(b) || rest.length) {
|
|
44
|
+
return NaN;
|
|
45
|
+
}
|
|
46
|
+
return b ? a / b : a;
|
|
47
|
+
}
|
|
48
|
+
function presetRatioAsNumber({
|
|
49
|
+
ratio,
|
|
50
|
+
...rest
|
|
51
|
+
}) {
|
|
52
|
+
return {
|
|
53
|
+
ratio: ratioToNumber(ratio),
|
|
54
|
+
...rest
|
|
55
|
+
};
|
|
36
56
|
}
|
|
37
57
|
export default function AspectRatioDropdown({
|
|
38
58
|
toggleProps
|
|
@@ -43,6 +63,7 @@ export default function AspectRatioDropdown({
|
|
|
43
63
|
setAspect,
|
|
44
64
|
defaultAspect
|
|
45
65
|
} = useImageEditingContext();
|
|
66
|
+
const [defaultRatios, themeRatios, showDefaultRatios] = useSettings('dimensions.aspectRatios.default', 'dimensions.aspectRatios.theme', 'dimensions.defaultAspectRatios');
|
|
46
67
|
return createElement(DropdownMenu, {
|
|
47
68
|
icon: aspectRatioIcon,
|
|
48
69
|
label: __('Aspect Ratio'),
|
|
@@ -51,7 +72,7 @@ export default function AspectRatioDropdown({
|
|
|
51
72
|
className: "wp-block-image__aspect-ratio"
|
|
52
73
|
}, ({
|
|
53
74
|
onClose
|
|
54
|
-
}) => createElement(Fragment, null, createElement(
|
|
75
|
+
}) => createElement(Fragment, null, createElement(AspectRatioGroup, {
|
|
55
76
|
isDisabled: isInProgress,
|
|
56
77
|
onClick: newAspect => {
|
|
57
78
|
setAspect(newAspect);
|
|
@@ -61,13 +82,22 @@ export default function AspectRatioDropdown({
|
|
|
61
82
|
aspectRatios: [
|
|
62
83
|
// All ratios should be mirrored in AspectRatioTool in @wordpress/block-editor.
|
|
63
84
|
{
|
|
64
|
-
|
|
85
|
+
slug: 'original',
|
|
86
|
+
name: __('Original'),
|
|
65
87
|
aspect: defaultAspect
|
|
66
|
-
}, {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
88
|
+
}, ...(showDefaultRatios ? defaultRatios.map(presetRatioAsNumber).filter(({
|
|
89
|
+
ratio
|
|
90
|
+
}) => ratio === 1) : [])]
|
|
91
|
+
}), themeRatios?.length > 0 && createElement(AspectRatioGroup, {
|
|
92
|
+
label: __('Theme'),
|
|
93
|
+
isDisabled: isInProgress,
|
|
94
|
+
onClick: newAspect => {
|
|
95
|
+
setAspect(newAspect);
|
|
96
|
+
onClose();
|
|
97
|
+
},
|
|
98
|
+
value: aspect,
|
|
99
|
+
aspectRatios: themeRatios
|
|
100
|
+
}), showDefaultRatios && createElement(AspectRatioGroup, {
|
|
71
101
|
label: __('Landscape'),
|
|
72
102
|
isDisabled: isInProgress,
|
|
73
103
|
onClick: newAspect => {
|
|
@@ -75,17 +105,10 @@ export default function AspectRatioDropdown({
|
|
|
75
105
|
onClose();
|
|
76
106
|
},
|
|
77
107
|
value: aspect,
|
|
78
|
-
aspectRatios:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
title: __('4:3'),
|
|
83
|
-
aspect: 4 / 3
|
|
84
|
-
}, {
|
|
85
|
-
title: __('3:2'),
|
|
86
|
-
aspect: 3 / 2
|
|
87
|
-
}]
|
|
88
|
-
}), createElement(AspectGroup, {
|
|
108
|
+
aspectRatios: defaultRatios.map(presetRatioAsNumber).filter(({
|
|
109
|
+
ratio
|
|
110
|
+
}) => ratio > 1)
|
|
111
|
+
}), showDefaultRatios && createElement(AspectRatioGroup, {
|
|
89
112
|
label: __('Portrait'),
|
|
90
113
|
isDisabled: isInProgress,
|
|
91
114
|
onClick: newAspect => {
|
|
@@ -93,16 +116,9 @@ export default function AspectRatioDropdown({
|
|
|
93
116
|
onClose();
|
|
94
117
|
},
|
|
95
118
|
value: aspect,
|
|
96
|
-
aspectRatios:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}, {
|
|
100
|
-
title: __('3:4'),
|
|
101
|
-
aspect: 3 / 4
|
|
102
|
-
}, {
|
|
103
|
-
title: __('2:3'),
|
|
104
|
-
aspect: 2 / 3
|
|
105
|
-
}]
|
|
119
|
+
aspectRatios: defaultRatios.map(presetRatioAsNumber).filter(({
|
|
120
|
+
ratio
|
|
121
|
+
}) => ratio < 1)
|
|
106
122
|
})));
|
|
107
123
|
}
|
|
108
124
|
//# sourceMappingURL=aspect-ratio-dropdown.js.map
|