@wordpress/block-editor 11.0.0 → 11.2.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 +16 -1
- package/LICENSE.md +1 -1
- package/README.md +2 -1
- package/build/components/alignment-control/ui.js +1 -7
- package/build/components/alignment-control/ui.js.map +1 -1
- package/build/components/block-actions/index.js +9 -0
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-alignment-control/use-available-alignments.js +4 -3
- package/build/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build/components/block-icon/index.js +4 -2
- package/build/components/block-icon/index.js.map +1 -1
- package/build/components/block-inspector/index.js +58 -5
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list-appender/index.js +46 -34
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-list-appender/index.native.js +39 -34
- package/build/components/block-list-appender/index.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js +18 -18
- package/build/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build/components/block-mobile-toolbar/index.native.js +1 -1
- package/build/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build/components/block-pattern-setup/index.js +14 -7
- package/build/components/block-pattern-setup/index.js.map +1 -1
- package/build/components/block-preview/auto.js +1 -4
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-styles/index.js +3 -1
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/index.native.js +1 -3
- package/build/components/block-styles/index.native.js.map +1 -1
- package/build/components/block-styles/utils.js +7 -10
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-toolbar/index.native.js +6 -8
- package/build/components/block-toolbar/index.native.js.map +1 -1
- package/build/components/block-tools/selected-block-popover.js +1 -3
- package/build/components/block-tools/selected-block-popover.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +43 -10
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/block-variation-picker/index.js +1 -1
- package/build/components/block-variation-picker/index.js.map +1 -1
- package/build/components/colors/utils.js +2 -6
- package/build/components/colors/utils.js.map +1 -1
- package/build/components/colors-gradients/control.js +0 -3
- package/build/components/colors-gradients/control.js.map +1 -1
- package/build/components/colors-gradients/dropdown.js +0 -2
- package/build/components/colors-gradients/dropdown.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +2 -19
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -3
- package/build/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build/components/copy-handler/index.js +37 -9
- package/build/components/copy-handler/index.js.map +1 -1
- package/build/components/default-style-picker/index.js +1 -0
- package/build/components/default-style-picker/index.js.map +1 -1
- package/build/components/font-sizes/fluid-utils.js +5 -2
- package/build/components/font-sizes/fluid-utils.js.map +1 -1
- package/build/components/font-sizes/utils.js +10 -4
- package/build/components/font-sizes/utils.js.map +1 -1
- package/build/components/font-sizes/with-font-sizes.js +14 -12
- package/build/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build/components/gradients/use-gradient.js +2 -8
- package/build/components/gradients/use-gradient.js.map +1 -1
- package/build/components/iframe/index.js +48 -101
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/iframe/use-compatibility-styles.js +98 -0
- package/build/components/iframe/use-compatibility-styles.js.map +1 -0
- package/build/components/image-size-control/index.js +1 -0
- package/build/components/image-size-control/index.js.map +1 -1
- package/build/components/inner-blocks/index.js +6 -2
- package/build/components/inner-blocks/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab.js +4 -4
- package/build/components/inserter/block-patterns-tab.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +4 -3
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/index.js +16 -6
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/inserter/media-tab/hooks.js +8 -5
- package/build/components/inserter/media-tab/hooks.js.map +1 -1
- package/build/components/inserter/menu.js +11 -5
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/quick-inserter.js +6 -3
- package/build/components/inserter/quick-inserter.js.map +1 -1
- package/build/components/inserter/search-items.js +15 -14
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter/search-results.js +4 -2
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inspector-controls/groups.js +3 -1
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +46 -0
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
- package/build/components/inspector-controls-tabs/settings-tab.js +3 -1
- package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -11
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/link-control/search-input.js +1 -0
- package/build/components/link-control/search-input.js.map +1 -1
- package/build/components/list-view/block-select-button.js +1 -1
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/off-canvas-editor/appender.js +3 -44
- package/build/components/off-canvas-editor/appender.js.map +1 -1
- package/build/components/off-canvas-editor/block-contents.js +38 -5
- package/build/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build/components/off-canvas-editor/block-select-button.js +3 -2
- package/build/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build/components/off-canvas-editor/block.js +51 -57
- package/build/components/off-canvas-editor/block.js.map +1 -1
- package/build/components/off-canvas-editor/index.js +12 -5
- package/build/components/off-canvas-editor/index.js.map +1 -1
- package/build/components/off-canvas-editor/use-inserted-block.js +58 -0
- package/build/components/off-canvas-editor/use-inserted-block.js.map +1 -0
- package/build/components/provider/index.js +3 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/responsive-block-control/label.js.map +1 -1
- package/build/components/rich-text/format-edit.js +12 -10
- package/build/components/rich-text/format-edit.js.map +1 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-enter.js +4 -5
- package/build/components/rich-text/use-enter.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +21 -12
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/components/spacing-sizes-control/index.js +0 -1
- package/build/components/spacing-sizes-control/index.js.map +1 -1
- package/build/components/spacing-sizes-control/utils.js +1 -1
- package/build/components/spacing-sizes-control/utils.js.map +1 -1
- package/build/components/typewriter/index.js +1 -1
- package/build/components/typewriter/index.js.map +1 -1
- package/build/components/url-input/button.js +1 -0
- package/build/components/url-input/button.js.map +1 -1
- package/build/components/url-input/index.js +15 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +2 -2
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/url-popover/link-editor.js +1 -0
- package/build/components/url-popover/link-editor.js.map +1 -1
- package/build/components/use-paste-styles/index.js +188 -0
- package/build/components/use-paste-styles/index.js.map +1 -0
- package/build/components/writing-flow/index.js +1 -1
- package/build/components/writing-flow/index.js.map +1 -1
- package/build/components/writing-flow/use-arrow-nav.js +22 -29
- package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build/hooks/border.js +0 -1
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color-panel.js +0 -1
- package/build/hooks/color-panel.js.map +1 -1
- package/build/hooks/color.js +1 -2
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/font-family.js +4 -4
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/font-size.js +5 -3
- package/build/hooks/font-size.js.map +1 -1
- package/build/hooks/index.js +2 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/metadata.js +1 -1
- package/build/hooks/metadata.js.map +1 -1
- package/build/hooks/position.js +376 -0
- package/build/hooks/position.js.map +1 -0
- package/build/hooks/supports.js +328 -0
- package/build/hooks/supports.js.map +1 -0
- package/build/hooks/use-typography-props.js +11 -8
- package/build/hooks/use-typography-props.js.map +1 -1
- package/build/store/reducer.js +27 -9
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +9 -7
- package/build/store/selectors.js.map +1 -1
- package/build/utils/pasting.js +6 -11
- package/build/utils/pasting.js.map +1 -1
- package/build-module/components/alignment-control/ui.js +1 -6
- package/build-module/components/alignment-control/ui.js.map +1 -1
- package/build-module/components/block-actions/index.js +6 -0
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-alignment-control/use-available-alignments.js +4 -3
- package/build-module/components/block-alignment-control/use-available-alignments.js.map +1 -1
- package/build-module/components/block-icon/index.js +4 -2
- package/build-module/components/block-icon/index.js.map +1 -1
- package/build-module/components/block-inspector/index.js +58 -6
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +46 -34
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.native.js +39 -32
- package/build-module/components/block-list-appender/index.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js +18 -18
- package/build-module/components/block-mobile-toolbar/block-actions-menu.native.js.map +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js +1 -1
- package/build-module/components/block-mobile-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-pattern-setup/index.js +14 -7
- package/build-module/components/block-pattern-setup/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +1 -4
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-styles/index.js +2 -1
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/index.native.js +1 -2
- package/build-module/components/block-styles/index.native.js.map +1 -1
- package/build-module/components/block-styles/utils.js +7 -9
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-toolbar/index.native.js +6 -8
- package/build-module/components/block-toolbar/index.native.js.map +1 -1
- package/build-module/components/block-tools/selected-block-popover.js +1 -2
- package/build-module/components/block-tools/selected-block-popover.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +42 -11
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/block-variation-picker/index.js +1 -1
- package/build-module/components/block-variation-picker/index.js.map +1 -1
- package/build-module/components/colors/utils.js +3 -7
- package/build-module/components/colors/utils.js.map +1 -1
- package/build-module/components/colors-gradients/control.js +0 -3
- package/build-module/components/colors-gradients/control.js.map +1 -1
- package/build-module/components/colors-gradients/dropdown.js +0 -2
- package/build-module/components/colors-gradients/dropdown.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +4 -19
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
- package/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js.map +1 -1
- package/build-module/components/copy-handler/index.js +38 -10
- package/build-module/components/copy-handler/index.js.map +1 -1
- package/build-module/components/default-style-picker/index.js +1 -0
- package/build-module/components/default-style-picker/index.js.map +1 -1
- package/build-module/components/font-sizes/fluid-utils.js +5 -2
- package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
- package/build-module/components/font-sizes/utils.js +11 -5
- package/build-module/components/font-sizes/utils.js.map +1 -1
- package/build-module/components/font-sizes/with-font-sizes.js +14 -11
- package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
- package/build-module/components/gradients/use-gradient.js +2 -7
- package/build-module/components/gradients/use-gradient.js.map +1 -1
- package/build-module/components/iframe/index.js +46 -102
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/iframe/use-compatibility-styles.js +90 -0
- package/build-module/components/iframe/use-compatibility-styles.js.map +1 -0
- package/build-module/components/image-size-control/index.js +1 -0
- package/build-module/components/image-size-control/index.js.map +1 -1
- package/build-module/components/inner-blocks/index.js +6 -2
- package/build-module/components/inner-blocks/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab.js +4 -4
- package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +4 -3
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/index.js +16 -6
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/inserter/media-tab/hooks.js +8 -5
- package/build-module/components/inserter/media-tab/hooks.js.map +1 -1
- package/build-module/components/inserter/menu.js +11 -5
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/quick-inserter.js +6 -3
- package/build-module/components/inserter/quick-inserter.js.map +1 -1
- package/build-module/components/inserter/search-items.js +15 -13
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter/search-results.js +4 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +3 -1
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +33 -0
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
- package/build-module/components/inspector-controls-tabs/settings-tab.js +2 -1
- package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -11
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/link-control/search-input.js +1 -0
- package/build-module/components/link-control/search-input.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +1 -1
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/off-canvas-editor/appender.js +5 -44
- package/build-module/components/off-canvas-editor/appender.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-contents.js +37 -7
- package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
- package/build-module/components/off-canvas-editor/block-select-button.js +3 -2
- package/build-module/components/off-canvas-editor/block-select-button.js.map +1 -1
- package/build-module/components/off-canvas-editor/block.js +54 -60
- package/build-module/components/off-canvas-editor/block.js.map +1 -1
- package/build-module/components/off-canvas-editor/index.js +12 -5
- package/build-module/components/off-canvas-editor/index.js.map +1 -1
- package/build-module/components/off-canvas-editor/use-inserted-block.js +47 -0
- package/build-module/components/off-canvas-editor/use-inserted-block.js.map +1 -0
- package/build-module/components/provider/index.js +3 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/responsive-block-control/label.js +1 -2
- package/build-module/components/responsive-block-control/label.js.map +1 -1
- package/build-module/components/rich-text/format-edit.js +12 -9
- package/build-module/components/rich-text/format-edit.js.map +1 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-enter.js +4 -5
- package/build-module/components/rich-text/use-enter.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +22 -12
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/components/spacing-sizes-control/index.js +0 -1
- package/build-module/components/spacing-sizes-control/index.js.map +1 -1
- package/build-module/components/spacing-sizes-control/utils.js +1 -1
- package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
- package/build-module/components/typewriter/index.js +1 -1
- package/build-module/components/typewriter/index.js.map +1 -1
- package/build-module/components/url-input/button.js +1 -0
- package/build-module/components/url-input/button.js.map +1 -1
- package/build-module/components/url-input/index.js +14 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +3 -3
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/url-popover/link-editor.js +1 -0
- package/build-module/components/url-popover/link-editor.js.map +1 -1
- package/build-module/components/use-paste-styles/index.js +174 -0
- package/build-module/components/use-paste-styles/index.js.map +1 -0
- package/build-module/components/writing-flow/index.js +1 -1
- package/build-module/components/writing-flow/index.js.map +1 -1
- package/build-module/components/writing-flow/use-arrow-nav.js +22 -29
- package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
- package/build-module/hooks/border.js +0 -1
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color-panel.js +0 -1
- package/build-module/hooks/color-panel.js.map +1 -1
- package/build-module/hooks/color.js +1 -2
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/font-family.js +5 -5
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/font-size.js +5 -3
- package/build-module/hooks/font-size.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/metadata.js +1 -1
- package/build-module/hooks/metadata.js.map +1 -1
- package/build-module/hooks/position.js +337 -0
- package/build-module/hooks/position.js.map +1 -0
- package/build-module/hooks/supports.js +257 -0
- package/build-module/hooks/supports.js.map +1 -0
- package/build-module/hooks/use-typography-props.js +11 -8
- package/build-module/hooks/use-typography-props.js.map +1 -1
- package/build-module/store/reducer.js +27 -8
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +9 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/pasting.js +6 -10
- package/build-module/utils/pasting.js.map +1 -1
- package/build-style/content-rtl.css +60 -3
- package/build-style/content.css +60 -3
- package/build-style/default-editor-styles-rtl.css +3 -3
- package/build-style/default-editor-styles.css +3 -3
- package/build-style/style-rtl.css +62 -69
- package/build-style/style.css +62 -69
- package/package.json +29 -29
- package/src/components/alignment-control/test/index.js +2 -0
- package/src/components/alignment-control/ui.js +1 -7
- package/src/components/block-actions/index.js +5 -0
- package/src/components/block-alignment-control/test/index.js +2 -0
- package/src/components/block-alignment-control/use-available-alignments.js +4 -3
- package/src/components/block-icon/index.js +4 -2
- package/src/components/block-icon/test/index.js +9 -5
- package/src/components/block-inspector/index.js +79 -4
- package/src/components/block-inspector/style.scss +7 -0
- package/src/components/block-list-appender/index.js +65 -54
- package/src/components/block-list-appender/index.native.js +45 -34
- package/src/components/block-mobile-toolbar/block-actions-menu.native.js +18 -22
- package/src/components/block-mobile-toolbar/index.native.js +1 -1
- package/src/components/block-mobile-toolbar/test/__snapshots__/block-actions-menu.native.js.snap +125 -0
- package/src/components/block-mobile-toolbar/test/block-actions-menu.native.js +439 -0
- package/src/components/block-mover/test/__snapshots__/index.native.js.snap +42 -0
- package/src/components/block-mover/test/index.native.js +157 -1
- package/src/components/block-pattern-setup/index.js +15 -6
- package/src/components/block-pattern-setup/style.scss +29 -1
- package/src/components/block-preview/auto.js +2 -4
- package/src/components/block-settings-menu/block-settings-dropdown.js +4 -0
- package/src/components/block-styles/index.js +4 -1
- package/src/components/block-styles/index.native.js +1 -2
- package/src/components/block-styles/utils.js +5 -7
- package/src/components/block-switcher/test/index.js +3 -2
- package/src/components/block-toolbar/index.native.js +8 -11
- package/src/components/block-tools/selected-block-popover.js +1 -3
- package/src/components/block-tools/use-block-toolbar-popover-props.js +68 -12
- package/src/components/block-variation-picker/index.js +5 -1
- package/src/components/block-vertical-alignment-control/test/index.js +2 -0
- package/src/components/button-block-appender/{style.scss → content.scss} +0 -0
- package/src/components/colors/test/with-colors.js +2 -0
- package/src/components/colors/utils.js +5 -3
- package/src/components/colors-gradients/control.js +0 -7
- package/src/components/colors-gradients/dropdown.js +0 -2
- package/src/components/colors-gradients/panel-color-gradient-settings.js +4 -22
- package/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js +4 -2
- package/src/components/copy-handler/index.js +53 -7
- package/src/components/default-block-appender/test/index.js +2 -0
- package/src/components/default-style-picker/index.js +1 -0
- package/src/components/font-sizes/fluid-utils.js +7 -1
- package/src/components/font-sizes/utils.js +5 -3
- package/src/components/font-sizes/with-font-sizes.js +36 -36
- package/src/components/gradients/use-gradient.js +2 -7
- package/src/components/iframe/index.js +60 -122
- package/src/components/iframe/use-compatibility-styles.js +101 -0
- package/src/components/image-size-control/index.js +1 -0
- package/src/components/image-size-control/test/index.js +147 -79
- package/src/components/inner-blocks/index.js +4 -2
- package/src/components/inserter/block-patterns-tab.js +7 -4
- package/src/components/inserter/hooks/use-insertion-point.js +3 -2
- package/src/components/inserter/index.js +61 -43
- package/src/components/inserter/media-tab/hooks.js +5 -4
- package/src/components/inserter/menu.js +8 -4
- package/src/components/inserter/quick-inserter.js +3 -0
- package/src/components/inserter/search-items.js +1 -2
- package/src/components/inserter/search-results.js +2 -0
- package/src/components/inserter/test/__snapshots__/index.native.js.snap +117 -0
- package/src/components/inserter/test/index.native.js +255 -1
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls-tabs/position-controls-panel.js +37 -0
- package/src/components/inspector-controls-tabs/settings-tab.js +2 -0
- package/src/components/inspector-controls-tabs/style.scss +15 -0
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -8
- package/src/components/link-control/search-input.js +1 -0
- package/src/components/link-control/style.scss +1 -0
- package/src/components/link-control/test/index.js +18 -4
- package/src/components/list-view/block-select-button.js +1 -1
- package/src/components/list-view/style.scss +14 -10
- package/src/components/media-replace-flow/test/index.js +2 -0
- package/src/components/off-canvas-editor/appender.js +4 -49
- package/src/components/off-canvas-editor/block-contents.js +84 -23
- package/src/components/off-canvas-editor/block-select-button.js +6 -2
- package/src/components/off-canvas-editor/block.js +90 -105
- package/src/components/off-canvas-editor/index.js +21 -2
- package/src/components/off-canvas-editor/style.scss +5 -1
- package/src/components/off-canvas-editor/test/use-inserted-block.js +108 -0
- package/src/components/off-canvas-editor/use-inserted-block.js +47 -0
- package/src/components/provider/index.js +4 -1
- package/src/components/responsive-block-control/label.js +2 -3
- package/src/components/responsive-block-control/test/index.js +4 -2
- package/src/components/rich-text/format-edit.js +6 -10
- package/src/components/rich-text/index.js +1 -0
- package/src/components/rich-text/use-enter.js +4 -4
- package/src/components/rich-text/use-paste-handler.js +33 -14
- package/src/components/spacing-sizes-control/index.js +0 -1
- package/src/components/spacing-sizes-control/utils.js +1 -1
- package/src/components/typewriter/index.js +3 -1
- package/src/components/url-input/README.md +5 -0
- package/src/components/url-input/button.js +1 -0
- package/src/components/url-input/index.js +15 -1
- package/src/components/url-input/test/button.js +2 -0
- package/src/components/url-popover/image-url-input-ui.js +5 -4
- package/src/components/url-popover/link-editor.js +1 -0
- package/src/components/url-popover/test/index.js +21 -5
- package/src/components/use-paste-styles/index.js +230 -0
- package/src/components/warning/test/index.js +2 -0
- package/src/components/writing-flow/index.js +1 -1
- package/src/components/writing-flow/use-arrow-nav.js +20 -28
- package/src/content.scss +1 -0
- package/src/hooks/border.js +0 -1
- package/src/hooks/color-panel.js +0 -1
- package/src/hooks/color.js +0 -2
- package/src/hooks/font-family.js +3 -5
- package/src/hooks/font-size.js +13 -4
- package/src/hooks/index.js +1 -0
- package/src/hooks/metadata.js +1 -2
- package/src/hooks/position.js +375 -0
- package/src/hooks/position.scss +18 -0
- package/src/hooks/supports.js +302 -0
- package/src/hooks/test/__snapshots__/align.native.js.snap +73 -0
- package/src/hooks/test/align.native.js +133 -0
- package/src/hooks/test/use-typography-props.js +26 -0
- package/src/hooks/use-typography-props.js +15 -7
- package/src/store/reducer.js +20 -8
- package/src/store/selectors.js +7 -8
- package/src/store/test/reducer.js +45 -3
- package/src/store/test/selectors.js +12 -9
- package/src/style.scss +2 -1
- package/src/utils/pasting.js +3 -9
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/colors-gradients/use-common-single-multiple-selects.js +0 -21
- package/build/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
- package/build/components/rich-text/file-paste-handler.js +0 -21
- package/build/components/rich-text/file-paste-handler.js.map +0 -1
- package/build-module/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
- package/build-module/components/colors-gradients/use-common-single-multiple-selects.js.map +0 -1
- package/build-module/components/rich-text/file-paste-handler.js +0 -13
- package/build-module/components/rich-text/file-paste-handler.js.map +0 -1
- package/src/components/colors-gradients/use-common-single-multiple-selects.js +0 -11
- package/src/components/rich-text/file-paste-handler.js +0 -13
|
@@ -9,96 +9,19 @@ import classnames from 'classnames';
|
|
|
9
9
|
* WordPress dependencies
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { useState, createPortal, forwardRef, useMemo, useReducer } from '@wordpress/element';
|
|
12
|
+
import { useState, createPortal, forwardRef, useMemo, useReducer, renderToString } from '@wordpress/element';
|
|
13
13
|
import { __ } from '@wordpress/i18n';
|
|
14
14
|
import { useResizeObserver, useMergeRefs, useRefEffect } from '@wordpress/compose';
|
|
15
15
|
import { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';
|
|
16
|
+
import { useSelect } from '@wordpress/data';
|
|
16
17
|
/**
|
|
17
18
|
* Internal dependencies
|
|
18
19
|
*/
|
|
19
20
|
|
|
20
21
|
import { useBlockSelectionClearer } from '../block-selection-clearer';
|
|
21
22
|
import { useWritingFlow } from '../writing-flow';
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Clones stylesheets targetting the editor canvas to the given document. A
|
|
26
|
-
* stylesheet is considered targetting the editor a canvas if it contains the
|
|
27
|
-
* `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.
|
|
28
|
-
*
|
|
29
|
-
* Ideally, this hook should be removed in the future and styles should be added
|
|
30
|
-
* explicitly as editor styles.
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
function useStylesCompatibility() {
|
|
34
|
-
return useRefEffect(node => {
|
|
35
|
-
// Search the document for stylesheets targetting the editor canvas.
|
|
36
|
-
Array.from(document.styleSheets).forEach(styleSheet => {
|
|
37
|
-
try {
|
|
38
|
-
// May fail for external styles.
|
|
39
|
-
// eslint-disable-next-line no-unused-expressions
|
|
40
|
-
styleSheet.cssRules;
|
|
41
|
-
} catch (e) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const {
|
|
46
|
-
ownerNode,
|
|
47
|
-
cssRules
|
|
48
|
-
} = styleSheet;
|
|
49
|
-
|
|
50
|
-
if (!cssRules) {
|
|
51
|
-
return;
|
|
52
|
-
} // Generally, ignore inline styles. We add inline styles belonging to a
|
|
53
|
-
// stylesheet later, which may or may not match the selectors.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (ownerNode.tagName !== 'LINK') {
|
|
57
|
-
return;
|
|
58
|
-
} // Don't try to add the reset styles, which were removed as a dependency
|
|
59
|
-
// from `edit-blocks` for the iframe since we don't need to reset admin
|
|
60
|
-
// styles.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (ownerNode.id === 'wp-reset-editor-styles-css') {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function matchFromRules(_cssRules) {
|
|
68
|
-
return Array.from(_cssRules).find(_ref => {
|
|
69
|
-
let {
|
|
70
|
-
selectorText,
|
|
71
|
-
conditionText,
|
|
72
|
-
cssRules: __cssRules
|
|
73
|
-
} = _ref;
|
|
74
|
-
|
|
75
|
-
// If the rule is conditional then it will not have selector text.
|
|
76
|
-
// Recurse into child CSS ruleset to determine selector eligibility.
|
|
77
|
-
if (conditionText) {
|
|
78
|
-
return matchFromRules(__cssRules);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return selectorText && (selectorText.includes(`.${BODY_CLASS_NAME}`) || selectorText.includes(`.${BLOCK_PREFIX}`));
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const isMatch = matchFromRules(cssRules);
|
|
86
|
-
|
|
87
|
-
if (isMatch && !node.ownerDocument.getElementById(ownerNode.id)) {
|
|
88
|
-
// Display warning once we have a way to add style dependencies to the editor.
|
|
89
|
-
// See: https://github.com/WordPress/gutenberg/pull/37466.
|
|
90
|
-
node.appendChild(ownerNode.cloneNode(true)); // Add inline styles belonging to the stylesheet.
|
|
91
|
-
|
|
92
|
-
const inlineCssId = ownerNode.id.replace('-css', '-inline-css');
|
|
93
|
-
const inlineCssElement = document.getElementById(inlineCssId);
|
|
94
|
-
|
|
95
|
-
if (inlineCssElement) {
|
|
96
|
-
node.appendChild(inlineCssElement.cloneNode(true));
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}, []);
|
|
101
|
-
}
|
|
23
|
+
import { useCompatibilityStyles } from './use-compatibility-styles';
|
|
24
|
+
import { store as blockEditorStore } from '../../store';
|
|
102
25
|
/**
|
|
103
26
|
* Bubbles some event types (keydown, keypress, and dragover) to parent document
|
|
104
27
|
* document to ensure that the keyboard shortcuts and drag and drop work.
|
|
@@ -110,7 +33,6 @@ function useStylesCompatibility() {
|
|
|
110
33
|
* @param {Document} doc Document to attach listeners to.
|
|
111
34
|
*/
|
|
112
35
|
|
|
113
|
-
|
|
114
36
|
function bubbleEvents(doc) {
|
|
115
37
|
const {
|
|
116
38
|
defaultView
|
|
@@ -158,11 +80,11 @@ function useParsedAssets(html) {
|
|
|
158
80
|
}, [html]);
|
|
159
81
|
}
|
|
160
82
|
|
|
161
|
-
async function loadScript(head,
|
|
83
|
+
async function loadScript(head, _ref) {
|
|
162
84
|
let {
|
|
163
85
|
id,
|
|
164
86
|
src
|
|
165
|
-
} =
|
|
87
|
+
} = _ref;
|
|
166
88
|
return new Promise((resolve, reject) => {
|
|
167
89
|
const script = head.ownerDocument.createElement('script');
|
|
168
90
|
script.id = id;
|
|
@@ -181,22 +103,26 @@ async function loadScript(head, _ref2) {
|
|
|
181
103
|
});
|
|
182
104
|
}
|
|
183
105
|
|
|
184
|
-
function Iframe(
|
|
106
|
+
function Iframe(_ref2) {
|
|
185
107
|
let {
|
|
186
108
|
contentRef,
|
|
187
109
|
children,
|
|
188
110
|
head,
|
|
189
111
|
tabIndex = 0,
|
|
190
|
-
assets,
|
|
191
112
|
scale = 1,
|
|
192
113
|
frameSize = 0,
|
|
193
114
|
readonly,
|
|
115
|
+
forwardedRef: ref,
|
|
194
116
|
...props
|
|
195
|
-
} =
|
|
117
|
+
} = _ref2;
|
|
118
|
+
const assets = useSelect(select => select(blockEditorStore).getSettings().__unstableResolvedAssets, []);
|
|
196
119
|
const [, forceRender] = useReducer(() => ({}));
|
|
197
120
|
const [iframeDocument, setIframeDocument] = useState();
|
|
198
121
|
const [bodyClasses, setBodyClasses] = useState([]);
|
|
199
122
|
const styles = useParsedAssets(assets === null || assets === void 0 ? void 0 : assets.styles);
|
|
123
|
+
const styleIds = styles.map(style => style.id);
|
|
124
|
+
const compatStyles = useCompatibilityStyles();
|
|
125
|
+
const neededCompatStyles = compatStyles.filter(style => !styleIds.includes(style.id));
|
|
200
126
|
const scripts = useParsedAssets(assets === null || assets === void 0 ? void 0 : assets.scripts);
|
|
201
127
|
const clearerRef = useBlockSelectionClearer();
|
|
202
128
|
const [before, writingFlowRef, after] = useWritingFlow();
|
|
@@ -258,8 +184,7 @@ function Iframe(_ref3, ref) {
|
|
|
258
184
|
});
|
|
259
185
|
}, []);
|
|
260
186
|
const bodyRef = useMergeRefs([contentRef, clearerRef, writingFlowRef]);
|
|
261
|
-
const
|
|
262
|
-
head = createElement(Fragment, null, createElement("style", null, 'html{height:auto!important;}body{margin:0}'), styles.map(_ref4 => {
|
|
187
|
+
const styleAssets = createElement(Fragment, null, createElement("style", null, 'html{height:auto!important;}body{margin:0}'), [...styles, ...neededCompatStyles].map(_ref3 => {
|
|
263
188
|
let {
|
|
264
189
|
tagName,
|
|
265
190
|
href,
|
|
@@ -267,7 +192,7 @@ function Iframe(_ref3, ref) {
|
|
|
267
192
|
rel,
|
|
268
193
|
media,
|
|
269
194
|
textContent
|
|
270
|
-
} =
|
|
195
|
+
} = _ref3;
|
|
271
196
|
const TagName = tagName.toLowerCase();
|
|
272
197
|
|
|
273
198
|
if (TagName === 'style') {
|
|
@@ -284,18 +209,26 @@ function Iframe(_ref3, ref) {
|
|
|
284
209
|
media,
|
|
285
210
|
key: id
|
|
286
211
|
});
|
|
287
|
-
})
|
|
212
|
+
})); // Correct doctype is required to enable rendering in standards
|
|
213
|
+
// mode. Also preload the styles to avoid a flash of unstyled
|
|
214
|
+
// content.
|
|
215
|
+
|
|
216
|
+
const srcDoc = useMemo(() => {
|
|
217
|
+
return '<!doctype html>' + renderToString(styleAssets);
|
|
218
|
+
}, []);
|
|
288
219
|
return createElement(Fragment, null, tabIndex >= 0 && before, createElement("iframe", _extends({}, props, {
|
|
289
220
|
ref: useMergeRefs([ref, setRef]),
|
|
290
|
-
tabIndex: tabIndex // Correct doctype is required to enable rendering in standards
|
|
221
|
+
tabIndex: tabIndex // Correct doctype is required to enable rendering in standards
|
|
222
|
+
// mode. Also preload the styles to avoid a flash of unstyled
|
|
223
|
+
// content.
|
|
291
224
|
,
|
|
292
|
-
srcDoc:
|
|
225
|
+
srcDoc: srcDoc,
|
|
293
226
|
title: __('Editor canvas')
|
|
294
227
|
}), iframeDocument && createPortal(createElement(Fragment, null, createElement("head", {
|
|
295
228
|
ref: headRef
|
|
296
|
-
}, head, createElement("style", null, `html { transition: background 5s; ${frameSize ? 'background: #2f2f2f; transition: background 0s;' : ''} }`)), createElement("body", {
|
|
229
|
+
}, styleAssets, head, createElement("style", null, `html { transition: background 5s; ${frameSize ? 'background: #2f2f2f; transition: background 0s;' : ''} }`)), createElement("body", {
|
|
297
230
|
ref: bodyRef,
|
|
298
|
-
className: classnames('block-editor-iframe__body',
|
|
231
|
+
className: classnames('block-editor-iframe__body', 'editor-styles-wrapper', ...bodyClasses),
|
|
299
232
|
style: {
|
|
300
233
|
// This is the remaining percentage from the scaling down
|
|
301
234
|
// of the iframe body(`scale(0.45)`). We also need to subtract
|
|
@@ -305,15 +238,26 @@ function Iframe(_ref3, ref) {
|
|
|
305
238
|
transform: `scale( ${scale} )`
|
|
306
239
|
},
|
|
307
240
|
inert: readonly ? 'true' : undefined
|
|
308
|
-
}, contentResizeListener, createElement(
|
|
309
|
-
style: {
|
|
310
|
-
display: 'none'
|
|
311
|
-
},
|
|
312
|
-
ref: styleCompatibilityRef
|
|
313
|
-
}), createElement(StyleProvider, {
|
|
241
|
+
}, contentResizeListener, createElement(StyleProvider, {
|
|
314
242
|
document: iframeDocument
|
|
315
243
|
}, children))), iframeDocument.documentElement)), tabIndex >= 0 && after);
|
|
316
244
|
}
|
|
317
245
|
|
|
318
|
-
|
|
246
|
+
function IframeIfReady(props, ref) {
|
|
247
|
+
const isInitialised = useSelect(select => select(blockEditorStore).getSettings().__internalIsInitialized, []); // We shouldn't render the iframe until the editor settings are initialised.
|
|
248
|
+
// The initial settings are needed to get the styles for the srcDoc, which
|
|
249
|
+
// cannot be changed after the iframe is mounted. srcDoc is used to to set
|
|
250
|
+
// the initial iframe HTML, which is required to avoid a flash of unstyled
|
|
251
|
+
// content.
|
|
252
|
+
|
|
253
|
+
if (!isInitialised) {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return createElement(Iframe, _extends({}, props, {
|
|
258
|
+
forwardedRef: ref
|
|
259
|
+
}));
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export default forwardRef(IframeIfReady);
|
|
319
263
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"names":["classnames","useState","createPortal","forwardRef","useMemo","useReducer","__","useResizeObserver","useMergeRefs","useRefEffect","__experimentalStyleProvider","StyleProvider","useBlockSelectionClearer","useWritingFlow","BODY_CLASS_NAME","BLOCK_PREFIX","useStylesCompatibility","node","Array","from","document","styleSheets","forEach","styleSheet","cssRules","e","ownerNode","tagName","id","matchFromRules","_cssRules","find","selectorText","conditionText","__cssRules","includes","isMatch","ownerDocument","getElementById","appendChild","cloneNode","inlineCssId","replace","inlineCssElement","bubbleEvents","doc","defaultView","frameElement","bubbleEvent","event","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","window","init","key","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","cancelled","dispatchEvent","preventDefault","eventTypes","addEventListener","useParsedAssets","html","implementation","createHTMLDocument","body","innerHTML","children","loadScript","head","src","Promise","resolve","reject","script","createElement","onload","onerror","Iframe","ref","contentRef","tabIndex","assets","scale","frameSize","readonly","props","forceRender","iframeDocument","setIframeDocument","bodyClasses","setBodyClasses","styles","scripts","clearerRef","before","writingFlowRef","after","contentResizeListener","height","contentHeight","setRef","iFrameDocument","preventFileDropDefault","setDocumentIfReady","contentDocument","readyState","documentElement","classList","filter","startsWith","dir","removeChild","removeEventListener","headRef","element","reduce","promise","then","finally","bodyRef","styleCompatibilityRef","map","href","rel","media","textContent","TagName","toLowerCase","marginBottom","marginTop","transform","undefined","display"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,QADD,EAECC,YAFD,EAGCC,UAHD,EAICC,OAJD,EAKCC,UALD,QAMO,oBANP;AAOA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,iBADD,EAECC,YAFD,EAGCC,YAHD,QAIO,oBAJP;AAKA,SAASC,2BAA2B,IAAIC,aAAxC,QAA6D,uBAA7D;AAEA;AACA;AACA;;AACA,SAASC,wBAAT,QAAyC,4BAAzC;AACA,SAASC,cAAT,QAA+B,iBAA/B;AAEA,MAAMC,eAAe,GAAG,uBAAxB;AACA,MAAMC,YAAY,GAAG,UAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,sBAAT,GAAkC;AACjC,SAAOP,YAAY,CAAIQ,IAAF,IAAY;AAChC;AACAC,IAAAA,KAAK,CAACC,IAAN,CAAYC,QAAQ,CAACC,WAArB,EAAmCC,OAAnC,CAA8CC,UAAF,IAAkB;AAC7D,UAAI;AACH;AACA;AACAA,QAAAA,UAAU,CAACC,QAAX;AACA,OAJD,CAIE,OAAQC,CAAR,EAAY;AACb;AACA;;AAED,YAAM;AAAEC,QAAAA,SAAF;AAAaF,QAAAA;AAAb,UAA0BD,UAAhC;;AAEA,UAAK,CAAEC,QAAP,EAAkB;AACjB;AACA,OAb4D,CAe7D;AACA;;;AACA,UAAKE,SAAS,CAACC,OAAV,KAAsB,MAA3B,EAAoC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AGoC,OADP;AAEC,IAAA,SAAS,EAAGrI,UAAU,CACrB,2BADqB,EAErBc,eAFqB,EAGrB,GAAGyF,WAHkB,CAFvB;AAOC,IAAA,KAAK,EAAG;AACP;AACA;AACA;AACAuC,MAAAA,YAAY,EAAG,IACd7B,aAAa,IAAK,IAAIjB,KAAT,CAAb,GACAC,SACA,IAPM;AAQP8C,MAAAA,SAAS,EAAE9C,SARJ;AASP+C,MAAAA,SAAS,EAAG,UAAUhD,KAAO;AATtB,KAPT;AAkBC,IAAA,KAAK,EAAGE,QAAQ,GAAG,MAAH,GAAY+C;AAlB7B,KAoBGlC,qBApBH,EA0BC;AACC,IAAA,KAAK,EAAG;AAAEmC,MAAAA,OAAO,EAAE;AAAX,KADT;AAEC,IAAA,GAAG,EAAGZ;AAFP,IA1BD,EA8BC,cAAC,aAAD;AAAe,IAAA,QAAQ,EAAGjC;AAA1B,KACGrB,QADH,CA9BD,CAXD,CADW,EA+CXqB,cAAc,CAACmB,eA/CJ,CATd,CAFD,EA6DG1B,QAAQ,IAAI,CAAZ,IAAiBgB,KA7DpB,CADD;AAiEA;;AAED,eAAe3G,UAAU,CAAEwF,MAAF,CAAzB","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\tuseReducer,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\n\nconst BODY_CLASS_NAME = 'editor-styles-wrapper';\nconst BLOCK_PREFIX = 'wp-block';\n\n/**\n * Clones stylesheets targetting the editor canvas to the given document. A\n * stylesheet is considered targetting the editor a canvas if it contains the\n * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.\n *\n * Ideally, this hook should be removed in the future and styles should be added\n * explicitly as editor styles.\n */\nfunction useStylesCompatibility() {\n\treturn useRefEffect( ( node ) => {\n\t\t// Search the document for stylesheets targetting the editor canvas.\n\t\tArray.from( document.styleSheets ).forEach( ( styleSheet ) => {\n\t\t\ttry {\n\t\t\t\t// May fail for external styles.\n\t\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\t\tstyleSheet.cssRules;\n\t\t\t} catch ( e ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerNode, cssRules } = styleSheet;\n\n\t\t\tif ( ! cssRules ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Generally, ignore inline styles. We add inline styles belonging to a\n\t\t\t// stylesheet later, which may or may not match the selectors.\n\t\t\tif ( ownerNode.tagName !== 'LINK' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Don't try to add the reset styles, which were removed as a dependency\n\t\t\t// from `edit-blocks` for the iframe since we don't need to reset admin\n\t\t\t// styles.\n\t\t\tif ( ownerNode.id === 'wp-reset-editor-styles-css' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfunction matchFromRules( _cssRules ) {\n\t\t\t\treturn Array.from( _cssRules ).find(\n\t\t\t\t\t( {\n\t\t\t\t\t\tselectorText,\n\t\t\t\t\t\tconditionText,\n\t\t\t\t\t\tcssRules: __cssRules,\n\t\t\t\t\t} ) => {\n\t\t\t\t\t\t// If the rule is conditional then it will not have selector text.\n\t\t\t\t\t\t// Recurse into child CSS ruleset to determine selector eligibility.\n\t\t\t\t\t\tif ( conditionText ) {\n\t\t\t\t\t\t\treturn matchFromRules( __cssRules );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tselectorText &&\n\t\t\t\t\t\t\t( selectorText.includes(\n\t\t\t\t\t\t\t\t`.${ BODY_CLASS_NAME }`\n\t\t\t\t\t\t\t) ||\n\t\t\t\t\t\t\t\tselectorText.includes( `.${ BLOCK_PREFIX }` ) )\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst isMatch = matchFromRules( cssRules );\n\n\t\t\tif (\n\t\t\t\tisMatch &&\n\t\t\t\t! node.ownerDocument.getElementById( ownerNode.id )\n\t\t\t) {\n\t\t\t\t// Display warning once we have a way to add style dependencies to the editor.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/37466.\n\t\t\t\tnode.appendChild( ownerNode.cloneNode( true ) );\n\n\t\t\t\t// Add inline styles belonging to the stylesheet.\n\t\t\t\tconst inlineCssId = ownerNode.id.replace(\n\t\t\t\t\t'-css',\n\t\t\t\t\t'-inline-css'\n\t\t\t\t);\n\t\t\t\tconst inlineCssElement = document.getElementById( inlineCssId );\n\n\t\t\t\tif ( inlineCssElement ) {\n\t\t\t\t\tnode.appendChild( inlineCssElement.cloneNode( true ) );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\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} doc Document to attach listeners to.\n */\nfunction bubbleEvents( doc ) {\n\tconst { defaultView } = doc;\n\tconst { frameElement } = defaultView;\n\n\tfunction bubbleEvent( event ) {\n\t\tconst prototype = Object.getPrototypeOf( event );\n\t\tconst constructorName = prototype.constructor.name;\n\t\tconst Constructor = window[ constructorName ];\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tif ( event instanceof defaultView.MouseEvent ) {\n\t\t\tconst rect = frameElement.getBoundingClientRect();\n\t\t\tinit.clientX += rect.left;\n\t\t\tinit.clientY += rect.top;\n\t\t}\n\n\t\tconst newEvent = new Constructor( event.type, init );\n\t\tconst cancelled = ! frameElement.dispatchEvent( newEvent );\n\n\t\tif ( cancelled ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\tconst eventTypes = [ 'dragover' ];\n\n\tfor ( const name of eventTypes ) {\n\t\tdoc.addEventListener( name, bubbleEvent );\n\t}\n}\n\nfunction useParsedAssets( html ) {\n\treturn useMemo( () => {\n\t\tconst doc = document.implementation.createHTMLDocument( '' );\n\t\tdoc.body.innerHTML = html;\n\t\treturn Array.from( doc.body.children );\n\t}, [ html ] );\n}\n\nasync function loadScript( head, { id, src } ) {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tconst script = head.ownerDocument.createElement( 'script' );\n\t\tscript.id = id;\n\t\tif ( src ) {\n\t\t\tscript.src = src;\n\t\t\tscript.onload = () => resolve();\n\t\t\tscript.onerror = () => reject();\n\t\t} else {\n\t\t\tresolve();\n\t\t}\n\t\thead.appendChild( script );\n\t} );\n}\n\nfunction Iframe(\n\t{\n\t\tcontentRef,\n\t\tchildren,\n\t\thead,\n\t\ttabIndex = 0,\n\t\tassets,\n\t\tscale = 1,\n\t\tframeSize = 0,\n\t\treadonly,\n\t\t...props\n\t},\n\tref\n) {\n\tconst [ , forceRender ] = useReducer( () => ( {} ) );\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst styles = useParsedAssets( assets?.styles );\n\tconst scripts = useParsedAssets( assets?.scripts );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst setRef = useRefEffect( ( node ) => {\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 setDocumentIfReady() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { readyState, documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tif ( readyState !== 'interactive' && readyState !== 'complete' ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tbubbleEvents( contentDocument );\n\t\t\tsetIframeDocument( contentDocument );\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\t\t\tdocumentElement.removeChild( contentDocument.head );\n\t\t\tdocumentElement.removeChild( contentDocument.body );\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\treturn true;\n\t\t}\n\n\t\t// Document set with srcDoc is not immediately ready.\n\t\tnode.addEventListener( 'load', setDocumentIfReady );\n\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'load', setDocumentIfReady );\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 headRef = useRefEffect( ( element ) => {\n\t\tscripts\n\t\t\t.reduce(\n\t\t\t\t( promise, script ) =>\n\t\t\t\t\tpromise.then( () => loadScript( element, script ) ),\n\t\t\t\tPromise.resolve()\n\t\t\t)\n\t\t\t.finally( () => {\n\t\t\t\t// When script are loaded, re-render blocks to allow them\n\t\t\t\t// to initialise.\n\t\t\t\tforceRender();\n\t\t\t} );\n\t}, [] );\n\tconst bodyRef = useMergeRefs( [ contentRef, clearerRef, writingFlowRef ] );\n\tconst styleCompatibilityRef = useStylesCompatibility();\n\n\thead = (\n\t\t<>\n\t\t\t<style>{ 'html{height:auto!important;}body{margin:0}' }</style>\n\t\t\t{ styles.map(\n\t\t\t\t( { tagName, href, id, rel, media, textContent } ) => {\n\t\t\t\t\tconst TagName = tagName.toLowerCase();\n\n\t\t\t\t\tif ( TagName === 'style' ) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<TagName { ...{ id } } key={ id }>\n\t\t\t\t\t\t\t\t{ textContent }\n\t\t\t\t\t\t\t</TagName>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TagName { ...{ href, id, rel, media } } key={ id } />\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t) }\n\t\t\t{ head }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ tabIndex >= 0 && before }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\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 mode\n\t\t\t\tsrcDoc=\"<!doctype html>\"\n\t\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<head ref={ headRef }>\n\t\t\t\t\t\t\t\t{ head }\n\t\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t\t{ `html { transition: background 5s; ${\n\t\t\t\t\t\t\t\t\t\tframeSize\n\t\t\t\t\t\t\t\t\t\t\t? 'background: #2f2f2f; transition: background 0s;'\n\t\t\t\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t\t\t} }` }\n\t\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t\t</head>\n\t\t\t\t\t\t\t<body\n\t\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t\tBODY_CLASS_NAME,\n\t\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t// This is the remaining percentage from the scaling down\n\t\t\t\t\t\t\t\t\t// of the iframe body(`scale(0.45)`). We also need to subtract\n\t\t\t\t\t\t\t\t\t// the body's bottom margin.\n\t\t\t\t\t\t\t\t\tmarginBottom: `-${\n\t\t\t\t\t\t\t\t\t\tcontentHeight * ( 1 - scale ) -\n\t\t\t\t\t\t\t\t\t\tframeSize\n\t\t\t\t\t\t\t\t\t}px`,\n\t\t\t\t\t\t\t\t\tmarginTop: frameSize,\n\t\t\t\t\t\t\t\t\ttransform: `scale( ${ scale } )`,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tinert={ readonly ? 'true' : undefined }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t\t\t * This is a wrapper for the extra styles and scripts\n\t\t\t\t\t\t\t\t * rendered imperatively by cloning the parent,\n\t\t\t\t\t\t\t\t * it's important that this div's content remains uncontrolled.\n\t\t\t\t\t\t\t\t */ }\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tstyle={ { display: 'none' } }\n\t\t\t\t\t\t\t\t\tref={ styleCompatibilityRef }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t\t</body>\n\t\t\t\t\t\t</>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ tabIndex >= 0 && after }\n\t\t</>\n\t);\n}\n\nexport default forwardRef( Iframe );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"names":["classnames","useState","createPortal","forwardRef","useMemo","useReducer","renderToString","__","useResizeObserver","useMergeRefs","useRefEffect","__experimentalStyleProvider","StyleProvider","useSelect","useBlockSelectionClearer","useWritingFlow","useCompatibilityStyles","store","blockEditorStore","bubbleEvents","doc","defaultView","frameElement","bubbleEvent","event","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","window","init","key","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","cancelled","dispatchEvent","preventDefault","eventTypes","addEventListener","useParsedAssets","html","document","implementation","createHTMLDocument","body","innerHTML","Array","from","children","loadScript","head","id","src","Promise","resolve","reject","script","ownerDocument","createElement","onload","onerror","appendChild","Iframe","contentRef","tabIndex","scale","frameSize","readonly","forwardedRef","ref","props","assets","select","getSettings","__unstableResolvedAssets","forceRender","iframeDocument","setIframeDocument","bodyClasses","setBodyClasses","styles","styleIds","map","style","compatStyles","neededCompatStyles","filter","includes","scripts","clearerRef","before","writingFlowRef","after","contentResizeListener","height","contentHeight","setRef","node","iFrameDocument","preventFileDropDefault","setDocumentIfReady","contentDocument","readyState","documentElement","classList","startsWith","dir","removeChild","removeEventListener","headRef","element","reduce","promise","then","finally","bodyRef","styleAssets","tagName","href","rel","media","textContent","TagName","toLowerCase","srcDoc","marginBottom","marginTop","transform","undefined","IframeIfReady","isInitialised","__internalIsInitialized"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AAC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IAAK,IAAI9B,KAAT,CAAb,GACAC,SACA,IAPM;AAQP4D,MAAAA,SAAS,EAAE5D,SARJ;AASP6D,MAAAA,SAAS,EAAG,UAAU9D,KAAO;AATtB,KAPT;AAkBC,IAAA,KAAK,EAAGE,QAAQ,GAAG,MAAH,GAAY6D;AAlB7B,KAoBGnC,qBApBH,EAqBC,cAAC,aAAD;AAAe,IAAA,QAAQ,EAAGjB;AAA1B,KACG5B,QADH,CArBD,CAZD,CADW,EAuCX4B,cAAc,CAAC2B,eAvCJ,CAXd,CAFD,EAuDGvC,QAAQ,IAAI,CAAZ,IAAiB4B,KAvDpB,CADD;AA2DA;;AAED,SAASqC,aAAT,CAAwB3D,KAAxB,EAA+BD,GAA/B,EAAqC;AACpC,QAAM6D,aAAa,GAAG/H,SAAS,CAC5BqE,MAAF,IACCA,MAAM,CAAEhE,gBAAF,CAAN,CAA2BiE,WAA3B,GAAyC0D,uBAFZ,EAG9B,EAH8B,CAA/B,CADoC,CAOpC;AACA;AACA;AACA;AACA;;AACA,MAAK,CAAED,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AAED,SAAO,cAAC,MAAD,eAAa5D,KAAb;AAAqB,IAAA,YAAY,EAAGD;AAApC,KAAP;AACA;;AAED,eAAe5E,UAAU,CAAEwI,aAAF,CAAzB","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\tuseReducer,\n\trenderToString,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\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 { useCompatibilityStyles } from './use-compatibility-styles';\nimport { store as blockEditorStore } from '../../store';\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} doc Document to attach listeners to.\n */\nfunction bubbleEvents( doc ) {\n\tconst { defaultView } = doc;\n\tconst { frameElement } = defaultView;\n\n\tfunction bubbleEvent( event ) {\n\t\tconst prototype = Object.getPrototypeOf( event );\n\t\tconst constructorName = prototype.constructor.name;\n\t\tconst Constructor = window[ constructorName ];\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tif ( event instanceof defaultView.MouseEvent ) {\n\t\t\tconst rect = frameElement.getBoundingClientRect();\n\t\t\tinit.clientX += rect.left;\n\t\t\tinit.clientY += rect.top;\n\t\t}\n\n\t\tconst newEvent = new Constructor( event.type, init );\n\t\tconst cancelled = ! frameElement.dispatchEvent( newEvent );\n\n\t\tif ( cancelled ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\tconst eventTypes = [ 'dragover' ];\n\n\tfor ( const name of eventTypes ) {\n\t\tdoc.addEventListener( name, bubbleEvent );\n\t}\n}\n\nfunction useParsedAssets( html ) {\n\treturn useMemo( () => {\n\t\tconst doc = document.implementation.createHTMLDocument( '' );\n\t\tdoc.body.innerHTML = html;\n\t\treturn Array.from( doc.body.children );\n\t}, [ html ] );\n}\n\nasync function loadScript( head, { id, src } ) {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tconst script = head.ownerDocument.createElement( 'script' );\n\t\tscript.id = id;\n\t\tif ( src ) {\n\t\t\tscript.src = src;\n\t\t\tscript.onload = () => resolve();\n\t\t\tscript.onerror = () => reject();\n\t\t} else {\n\t\t\tresolve();\n\t\t}\n\t\thead.appendChild( script );\n\t} );\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\thead,\n\ttabIndex = 0,\n\tscale = 1,\n\tframeSize = 0,\n\treadonly,\n\tforwardedRef: ref,\n\t...props\n} ) {\n\tconst assets = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__unstableResolvedAssets,\n\t\t[]\n\t);\n\tconst [ , forceRender ] = useReducer( () => ( {} ) );\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst styles = useParsedAssets( assets?.styles );\n\tconst styleIds = styles.map( ( style ) => style.id );\n\tconst compatStyles = useCompatibilityStyles();\n\tconst neededCompatStyles = compatStyles.filter(\n\t\t( style ) => ! styleIds.includes( style.id )\n\t);\n\tconst scripts = useParsedAssets( assets?.scripts );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst setRef = useRefEffect( ( node ) => {\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 setDocumentIfReady() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { readyState, documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tif ( readyState !== 'interactive' && readyState !== 'complete' ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tbubbleEvents( contentDocument );\n\t\t\tsetIframeDocument( contentDocument );\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\t\t\tdocumentElement.removeChild( contentDocument.head );\n\t\t\tdocumentElement.removeChild( contentDocument.body );\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\treturn true;\n\t\t}\n\n\t\t// Document set with srcDoc is not immediately ready.\n\t\tnode.addEventListener( 'load', setDocumentIfReady );\n\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'load', setDocumentIfReady );\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 headRef = useRefEffect( ( element ) => {\n\t\tscripts\n\t\t\t.reduce(\n\t\t\t\t( promise, script ) =>\n\t\t\t\t\tpromise.then( () => loadScript( element, script ) ),\n\t\t\t\tPromise.resolve()\n\t\t\t)\n\t\t\t.finally( () => {\n\t\t\t\t// When script are loaded, re-render blocks to allow them\n\t\t\t\t// to initialise.\n\t\t\t\tforceRender();\n\t\t\t} );\n\t}, [] );\n\tconst bodyRef = useMergeRefs( [ contentRef, clearerRef, writingFlowRef ] );\n\n\tconst styleAssets = (\n\t\t<>\n\t\t\t<style>{ 'html{height:auto!important;}body{margin:0}' }</style>\n\t\t\t{ [ ...styles, ...neededCompatStyles ].map(\n\t\t\t\t( { tagName, href, id, rel, media, textContent } ) => {\n\t\t\t\t\tconst TagName = tagName.toLowerCase();\n\n\t\t\t\t\tif ( TagName === 'style' ) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<TagName { ...{ id } } key={ id }>\n\t\t\t\t\t\t\t\t{ textContent }\n\t\t\t\t\t\t\t</TagName>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TagName { ...{ href, id, rel, media } } key={ id } />\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t) }\n\t\t</>\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 srcDoc = useMemo( () => {\n\t\treturn '<!doctype html>' + renderToString( styleAssets );\n\t}, [] );\n\n\treturn (\n\t\t<>\n\t\t\t{ tabIndex >= 0 && before }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\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\tsrcDoc={ srcDoc }\n\t\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<head ref={ headRef }>\n\t\t\t\t\t\t\t\t{ styleAssets }\n\t\t\t\t\t\t\t\t{ head }\n\t\t\t\t\t\t\t\t<style>\n\t\t\t\t\t\t\t\t\t{ `html { transition: background 5s; ${\n\t\t\t\t\t\t\t\t\t\tframeSize\n\t\t\t\t\t\t\t\t\t\t\t? 'background: #2f2f2f; transition: background 0s;'\n\t\t\t\t\t\t\t\t\t\t\t: ''\n\t\t\t\t\t\t\t\t\t} }` }\n\t\t\t\t\t\t\t\t</style>\n\t\t\t\t\t\t\t</head>\n\t\t\t\t\t\t\t<body\n\t\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t\t'editor-styles-wrapper',\n\t\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t// This is the remaining percentage from the scaling down\n\t\t\t\t\t\t\t\t\t// of the iframe body(`scale(0.45)`). We also need to subtract\n\t\t\t\t\t\t\t\t\t// the body's bottom margin.\n\t\t\t\t\t\t\t\t\tmarginBottom: `-${\n\t\t\t\t\t\t\t\t\t\tcontentHeight * ( 1 - scale ) -\n\t\t\t\t\t\t\t\t\t\tframeSize\n\t\t\t\t\t\t\t\t\t}px`,\n\t\t\t\t\t\t\t\t\tmarginTop: frameSize,\n\t\t\t\t\t\t\t\t\ttransform: `scale( ${ scale } )`,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tinert={ readonly ? 'true' : undefined }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t\t</body>\n\t\t\t\t\t\t</>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ tabIndex >= 0 && 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"]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useMemo } from '@wordpress/element';
|
|
5
|
+
/**
|
|
6
|
+
* Returns a list of stylesheets that target the editor canvas. A stylesheet is
|
|
7
|
+
* considered targetting the editor a canvas if it contains the
|
|
8
|
+
* `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.
|
|
9
|
+
*
|
|
10
|
+
* Ideally, this hook should be removed in the future and styles should be added
|
|
11
|
+
* explicitly as editor styles.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export function useCompatibilityStyles() {
|
|
15
|
+
// Only memoize the result once on load, since these stylesheets should not
|
|
16
|
+
// change.
|
|
17
|
+
return useMemo(() => {
|
|
18
|
+
// Search the document for stylesheets targetting the editor canvas.
|
|
19
|
+
return Array.from(document.styleSheets).reduce((accumulator, styleSheet) => {
|
|
20
|
+
try {
|
|
21
|
+
// May fail for external styles.
|
|
22
|
+
// eslint-disable-next-line no-unused-expressions
|
|
23
|
+
styleSheet.cssRules;
|
|
24
|
+
} catch (e) {
|
|
25
|
+
return accumulator;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
ownerNode,
|
|
30
|
+
cssRules
|
|
31
|
+
} = styleSheet; // Stylesheet is added by another stylesheet. See
|
|
32
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/StyleSheet/ownerNode#notes.
|
|
33
|
+
|
|
34
|
+
if (ownerNode === null) {
|
|
35
|
+
return accumulator;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!cssRules) {
|
|
39
|
+
return accumulator;
|
|
40
|
+
} // Generally, ignore inline styles. We add inline styles belonging to a
|
|
41
|
+
// stylesheet later, which may or may not match the selectors.
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
if (ownerNode.tagName !== 'LINK') {
|
|
45
|
+
return accumulator;
|
|
46
|
+
} // Don't try to add the reset styles, which were removed as a dependency
|
|
47
|
+
// from `edit-blocks` for the iframe since we don't need to reset admin
|
|
48
|
+
// styles.
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
if (ownerNode.id === 'wp-reset-editor-styles-css') {
|
|
52
|
+
return accumulator;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function matchFromRules(_cssRules) {
|
|
56
|
+
return Array.from(_cssRules).find(_ref => {
|
|
57
|
+
let {
|
|
58
|
+
selectorText,
|
|
59
|
+
conditionText,
|
|
60
|
+
cssRules: __cssRules
|
|
61
|
+
} = _ref;
|
|
62
|
+
|
|
63
|
+
// If the rule is conditional then it will not have selector text.
|
|
64
|
+
// Recurse into child CSS ruleset to determine selector eligibility.
|
|
65
|
+
if (conditionText) {
|
|
66
|
+
return matchFromRules(__cssRules);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return selectorText && (selectorText.includes('.editor-styles-wrapper') || selectorText.includes('.wp-block'));
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (matchFromRules(cssRules)) {
|
|
74
|
+
// Display warning once we have a way to add style dependencies to the editor.
|
|
75
|
+
// See: https://github.com/WordPress/gutenberg/pull/37466.
|
|
76
|
+
accumulator.push(ownerNode.cloneNode(true)); // Add inline styles belonging to the stylesheet.
|
|
77
|
+
|
|
78
|
+
const inlineCssId = ownerNode.id.replace('-css', '-inline-css');
|
|
79
|
+
const inlineCssElement = document.getElementById(inlineCssId);
|
|
80
|
+
|
|
81
|
+
if (inlineCssElement) {
|
|
82
|
+
accumulator.push(inlineCssElement.cloneNode(true));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return accumulator;
|
|
87
|
+
}, []);
|
|
88
|
+
}, []);
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=use-compatibility-styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/iframe/use-compatibility-styles.js"],"names":["useMemo","useCompatibilityStyles","Array","from","document","styleSheets","reduce","accumulator","styleSheet","cssRules","e","ownerNode","tagName","id","matchFromRules","_cssRules","find","selectorText","conditionText","__cssRules","includes","push","cloneNode","inlineCssId","replace","inlineCssElement","getElementById"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,sBAAT,GAAkC;AACxC;AACA;AACA,SAAOD,OAAO,CAAE,MAAM;AACrB;AACA,WAAOE,KAAK,CAACC,IAAN,CAAYC,QAAQ,CAACC,WAArB,EAAmCC,MAAnC,CACN,CAAEC,WAAF,EAAeC,UAAf,KAA+B;AAC9B,UAAI;AACH;AACA;AACAA,QAAAA,UAAU,CAACC,QAAX;AACA,OAJD,CAIE,OAAQC,CAAR,EAAY;AACb,eAAOH,WAAP;AACA;;AAED,YAAM;AAAEI,QAAAA,SAAF;AAAaF,QAAAA;AAAb,UAA0BD,UAAhC,CAT8B,CAW9B;AACA;;AACA,UAAKG,SAAS,KAAK,IAAnB,EAA0B;AACzB,eAAOJ,WAAP;AACA;;AAED,UAAK,CAAEE,QAAP,EAAkB;AACjB,eAAOF,WAAP;AACA,OAnB6B,CAqB9B;AACA;;;AACA,UAAKI,SAAS,CAACC,OAAV,KAAsB,MAA3B,EAAoC;AACnC,eAAOL,WAAP;AACA,OAzB6B,CA2B9B;AACA;AACA;;;AACA,UAAKI,SAAS,CAACE,EAAV,KAAiB,4BAAtB,EAAqD;AACpD,eAAON,WAAP;AACA;;AAED,eAASO,cAAT,CAAyBC,SAAzB,EAAqC;AACpC,eAAOb,KAAK,CAACC,IAAN,CAAYY,SAAZ,EAAwBC,IAAxB,CACN,QAIO;AAAA,cAJL;AACDC,YAAAA,YADC;AAEDC,YAAAA,aAFC;AAGDT,YAAAA,QAAQ,EAAEU;AAHT,WAIK;;AACN;AACA;AACA,cAAKD,aAAL,EAAqB;AACpB,mBAAOJ,cAAc,CAAEK,UAAF,CAArB;AACA;;AAED,iBACCF,YAAY,KACVA,YAAY,CAACG,QAAb,CACD,wBADC,KAGDH,YAAY,CAACG,QAAb,CAAuB,WAAvB,CAJW,CADb;AAOA,SAnBK,CAAP;AAqBA;;AAED,UAAKN,cAAc,CAAEL,QAAF,CAAnB,EAAkC;AACjC;AACA;AACAF,QAAAA,WAAW,CAACc,IAAZ,CAAkBV,SAAS,CAACW,SAAV,CAAqB,IAArB,CAAlB,EAHiC,CAKjC;;AACA,cAAMC,WAAW,GAAGZ,SAAS,CAACE,EAAV,CAAaW,OAAb,CACnB,MADmB,EAEnB,aAFmB,CAApB;AAIA,cAAMC,gBAAgB,GACrBrB,QAAQ,CAACsB,cAAT,CAAyBH,WAAzB,CADD;;AAGA,YAAKE,gBAAL,EAAwB;AACvBlB,UAAAA,WAAW,CAACc,IAAZ,CAAkBI,gBAAgB,CAACH,SAAjB,CAA4B,IAA5B,CAAlB;AACA;AACD;;AAED,aAAOf,WAAP;AACA,KA9EK,EA+EN,EA/EM,CAAP;AAiFA,GAnFa,EAmFX,EAnFW,CAAd;AAoFA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Returns a list of stylesheets that target the editor canvas. A stylesheet is\n * considered targetting the editor a canvas if it contains the\n * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.\n *\n * Ideally, this hook should be removed in the future and styles should be added\n * explicitly as editor styles.\n */\nexport function useCompatibilityStyles() {\n\t// Only memoize the result once on load, since these stylesheets should not\n\t// change.\n\treturn useMemo( () => {\n\t\t// Search the document for stylesheets targetting the editor canvas.\n\t\treturn Array.from( document.styleSheets ).reduce(\n\t\t\t( accumulator, styleSheet ) => {\n\t\t\t\ttry {\n\t\t\t\t\t// May fail for external styles.\n\t\t\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\t\t\tstyleSheet.cssRules;\n\t\t\t\t} catch ( e ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\tconst { ownerNode, cssRules } = styleSheet;\n\n\t\t\t\t// Stylesheet is added by another stylesheet. See\n\t\t\t\t// https://developer.mozilla.org/en-US/docs/Web/API/StyleSheet/ownerNode#notes.\n\t\t\t\tif ( ownerNode === null ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\tif ( ! cssRules ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\t// Generally, ignore inline styles. We add inline styles belonging to a\n\t\t\t\t// stylesheet later, which may or may not match the selectors.\n\t\t\t\tif ( ownerNode.tagName !== 'LINK' ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\t// Don't try to add the reset styles, which were removed as a dependency\n\t\t\t\t// from `edit-blocks` for the iframe since we don't need to reset admin\n\t\t\t\t// styles.\n\t\t\t\tif ( ownerNode.id === 'wp-reset-editor-styles-css' ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\tfunction matchFromRules( _cssRules ) {\n\t\t\t\t\treturn Array.from( _cssRules ).find(\n\t\t\t\t\t\t( {\n\t\t\t\t\t\t\tselectorText,\n\t\t\t\t\t\t\tconditionText,\n\t\t\t\t\t\t\tcssRules: __cssRules,\n\t\t\t\t\t\t} ) => {\n\t\t\t\t\t\t\t// If the rule is conditional then it will not have selector text.\n\t\t\t\t\t\t\t// Recurse into child CSS ruleset to determine selector eligibility.\n\t\t\t\t\t\t\tif ( conditionText ) {\n\t\t\t\t\t\t\t\treturn matchFromRules( __cssRules );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\tselectorText &&\n\t\t\t\t\t\t\t\t( selectorText.includes(\n\t\t\t\t\t\t\t\t\t'.editor-styles-wrapper'\n\t\t\t\t\t\t\t\t) ||\n\t\t\t\t\t\t\t\t\tselectorText.includes( '.wp-block' ) )\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif ( matchFromRules( cssRules ) ) {\n\t\t\t\t\t// Display warning once we have a way to add style dependencies to the editor.\n\t\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/37466.\n\t\t\t\t\taccumulator.push( ownerNode.cloneNode( true ) );\n\n\t\t\t\t\t// Add inline styles belonging to the stylesheet.\n\t\t\t\t\tconst inlineCssId = ownerNode.id.replace(\n\t\t\t\t\t\t'-css',\n\t\t\t\t\t\t'-inline-css'\n\t\t\t\t\t);\n\t\t\t\t\tconst inlineCssElement =\n\t\t\t\t\t\tdocument.getElementById( inlineCssId );\n\n\t\t\t\t\tif ( inlineCssElement ) {\n\t\t\t\t\t\taccumulator.push( inlineCssElement.cloneNode( true ) );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t}, [] );\n}\n"]}
|
|
@@ -39,6 +39,7 @@ export default function ImageSizeControl(_ref) {
|
|
|
39
39
|
updateDimensions
|
|
40
40
|
} = useDimensionHandler(height, width, imageHeight, imageWidth, onChange);
|
|
41
41
|
return createElement(Fragment, null, !isEmpty(imageSizeOptions) && createElement(SelectControl, {
|
|
42
|
+
__nextHasNoMarginBottom: true,
|
|
42
43
|
label: __('Image size'),
|
|
43
44
|
value: slug,
|
|
44
45
|
options: imageSizeOptions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/image-size-control/index.js"],"names":["isEmpty","Button","ButtonGroup","SelectControl","TextControl","__","useDimensionHandler","IMAGE_SIZE_PRESETS","noop","ImageSizeControl","imageSizeHelp","imageWidth","imageHeight","imageSizeOptions","isResizable","slug","width","height","onChange","onChangeImage","currentHeight","currentWidth","updateDimension","updateDimensions","value","map","scale","scaledWidth","Math","round","scaledHeight","isCurrent","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SACCC,MADD,EAECC,WAFD,EAGCC,aAHD,EAICC,WAJD,QAKO,uBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AAEA,MAAMC,kBAAkB,GAAG,CAAE,EAAF,EAAM,EAAN,EAAU,EAAV,EAAc,GAAd,CAA3B;;AACA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,eAAe,SAASC,gBAAT,OAWX;AAAA,MAXsC;AACzCC,IAAAA,aADyC;AAEzCC,IAAAA,UAFyC;AAGzCC,IAAAA,WAHyC;AAIzCC,IAAAA,gBAAgB,GAAG,EAJsB;AAKzCC,IAAAA,WAAW,GAAG,IAL2B;AAMzCC,IAAAA,IANyC;AAOzCC,IAAAA,KAPyC;AAQzCC,IAAAA,MARyC;AASzCC,IAAAA,QATyC;AAUzCC,IAAAA,aAAa,GAAGX;AAVyB,GAWtC;AACH,QAAM;AAAEY,IAAAA,aAAF;AAAiBC,IAAAA,YAAjB;AAA+BC,IAAAA,eAA/B;AAAgDC,IAAAA;AAAhD,MACLjB,mBAAmB,CAAEW,MAAF,EAAUD,KAAV,EAAiBJ,WAAjB,EAA8BD,UAA9B,EAA0CO,QAA1C,CADpB;AAGA,SACC,8BACG,CAAElB,OAAO,CAAEa,gBAAF,CAAT,IACD,cAAC,aAAD;AACC,IAAA,KAAK,EAAGR,EAAE,CAAE,YAAF,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/image-size-control/index.js"],"names":["isEmpty","Button","ButtonGroup","SelectControl","TextControl","__","useDimensionHandler","IMAGE_SIZE_PRESETS","noop","ImageSizeControl","imageSizeHelp","imageWidth","imageHeight","imageSizeOptions","isResizable","slug","width","height","onChange","onChangeImage","currentHeight","currentWidth","updateDimension","updateDimensions","value","map","scale","scaledWidth","Math","round","sc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,CACfO,YADe,EAEfH,WAFe;AARlB,OAcGD,KAdH,MADD;AAkBA,GA9BC,CADH,CADD,EAkCC,cAAC,MAAD;AAAQ,IAAA,OAAO,MAAf;AAAgB,IAAA,OAAO,EAAG,MAAMH,gBAAgB;AAAhD,KACGlB,EAAE,CAAE,OAAF,CADL,CAlCD,CA1BD,CAZF,CADD;AAiFA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\tButtonGroup,\n\tSelectControl,\n\tTextControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport useDimensionHandler from './use-dimension-handler';\n\nconst IMAGE_SIZE_PRESETS = [ 25, 50, 75, 100 ];\nconst noop = () => {};\n\nexport default function ImageSizeControl( {\n\timageSizeHelp,\n\timageWidth,\n\timageHeight,\n\timageSizeOptions = [],\n\tisResizable = true,\n\tslug,\n\twidth,\n\theight,\n\tonChange,\n\tonChangeImage = noop,\n} ) {\n\tconst { currentHeight, currentWidth, updateDimension, updateDimensions } =\n\t\tuseDimensionHandler( height, width, imageHeight, imageWidth, onChange );\n\n\treturn (\n\t\t<>\n\t\t\t{ ! isEmpty( imageSizeOptions ) && (\n\t\t\t\t<SelectControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Image size' ) }\n\t\t\t\t\tvalue={ slug }\n\t\t\t\t\toptions={ imageSizeOptions }\n\t\t\t\t\tonChange={ onChangeImage }\n\t\t\t\t\thelp={ imageSizeHelp }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isResizable && (\n\t\t\t\t<div className=\"block-editor-image-size-control\">\n\t\t\t\t\t<p className=\"block-editor-image-size-control__row\">\n\t\t\t\t\t\t{ __( 'Image dimensions' ) }\n\t\t\t\t\t</p>\n\t\t\t\t\t<div className=\"block-editor-image-size-control__row\">\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tclassName=\"block-editor-image-size-control__width\"\n\t\t\t\t\t\t\tlabel={ __( 'Width' ) }\n\t\t\t\t\t\t\tvalue={ currentWidth }\n\t\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tupdateDimension( 'width', value )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\ttype=\"number\"\n\t\t\t\t\t\t\tclassName=\"block-editor-image-size-control__height\"\n\t\t\t\t\t\t\tlabel={ __( 'Height' ) }\n\t\t\t\t\t\t\tvalue={ currentHeight }\n\t\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tupdateDimension( 'height', value )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"block-editor-image-size-control__row\">\n\t\t\t\t\t\t<ButtonGroup aria-label={ __( 'Image size presets' ) }>\n\t\t\t\t\t\t\t{ IMAGE_SIZE_PRESETS.map( ( scale ) => {\n\t\t\t\t\t\t\t\tconst scaledWidth = Math.round(\n\t\t\t\t\t\t\t\t\timageWidth * ( scale / 100 )\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tconst scaledHeight = Math.round(\n\t\t\t\t\t\t\t\t\timageHeight * ( scale / 100 )\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\tconst isCurrent =\n\t\t\t\t\t\t\t\t\tcurrentWidth === scaledWidth &&\n\t\t\t\t\t\t\t\t\tcurrentHeight === scaledHeight;\n\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tkey={ scale }\n\t\t\t\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\t\tisCurrent ? 'primary' : undefined\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tisPressed={ isCurrent }\n\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\tupdateDimensions(\n\t\t\t\t\t\t\t\t\t\t\t\tscaledHeight,\n\t\t\t\t\t\t\t\t\t\t\t\tscaledWidth\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ scale }%\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t</ButtonGroup>\n\t\t\t\t\t\t<Button isSmall onClick={ () => updateDimensions() }>\n\t\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -60,6 +60,8 @@ function UncontrolledInnerBlocks(props) {
|
|
|
60
60
|
context,
|
|
61
61
|
name
|
|
62
62
|
} = useSelect(select => {
|
|
63
|
+
var _blockType$providesCo;
|
|
64
|
+
|
|
63
65
|
const block = select(blockEditorStore).getBlock(clientId); // This check is here to avoid the Redux zombie bug where a child subscription
|
|
64
66
|
// is called before a parent, causing potential JS errors when the child has been removed.
|
|
65
67
|
|
|
@@ -69,8 +71,10 @@ function UncontrolledInnerBlocks(props) {
|
|
|
69
71
|
|
|
70
72
|
const blockType = getBlockType(block.name);
|
|
71
73
|
|
|
72
|
-
if (
|
|
73
|
-
return {
|
|
74
|
+
if (Object.keys((_blockType$providesCo = blockType === null || blockType === void 0 ? void 0 : blockType.providesContext) !== null && _blockType$providesCo !== void 0 ? _blockType$providesCo : {}).length === 0) {
|
|
75
|
+
return {
|
|
76
|
+
name: block.name
|
|
77
|
+
};
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/index.js"],"names":["classnames","useViewportMatch","useMergeRefs","forwardRef","useMemo","useSelect","getBlockSupport","getBlockType","store","blocksStore","__unstableGetInnerBlocksProps","getInnerBlocksProps","ButtonBlockAppender","DefaultBlockAppender","useNestedSettingsUpdate","useInnerBlockTemplateSync","getBlockContext","BlockListItems","BlockContextProvider","useBlockEditContext","useBlockSync","blockEditorStore","useBlockDropZone","UncontrolledInnerBlocks","props","clientId","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","wrapperRef","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","__experimentalAppenderTagName","renderAppender","orientation","placeholder","__experimentalLayout","context","name","select","block","getBlock","blockType","providesContext","attributes","allowSizingOnChildren","layout","ControlledInnerBlocks","ForwardedInnerBlocks","ref","innerBlocksProps","useInnerBlocksProps","options","__unstableDisableLayoutClassNames","__unstableDisableDropZone","__unstableLayoutClassNames","layoutClassNames","isSmallScreen","hasOverlay","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","blockName","enableClickThrough","hasBlockSupport","blockDropZoneRef","rootClientId","InnerBlocks","value","onChange","className","children","save","Content"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,YAA3B,QAA+C,oBAA/C;AACA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,oBAApC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,eADD,EAECC,YAFD,EAGCC,KAAK,IAAIC,WAHV,EAICC,6BAA6B,IAAIC,mBAJlC,QAKO,mBALP;AAOA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,OAAO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AAZK,KAAP;AAcA,GA7B6D,EA8B9D,CAAE1C,QAAF,EAAYmC,aAAZ,CA9B8D,CAA/D;AAiCA,QAAMS,gBAAgB,GAAG/C,gBAAgB,CAAE;AAC1CgD,IAAAA,YAAY,EAAE7C;AAD4B,GAAF,CAAzC;AAIA,QAAM2B,GAAG,GAAGlD,YAAY,CAAE,CACzBsB,KAAK,CAAC4B,GADmB,EAEzBK,yBAAyB,GAAG,IAAH,GAAUY,gBAFV,CAAF,CAAxB;AAKA,QAAMhB,gBAAgB,GAAG;AACxBpB,IAAAA,6BADwB;AAExB,OAAGsB;AAFqB,GAAzB;AAIA,QAAMgB,WAAW,GAChBlB,gBAAgB,CAACmB,KAAjB,IAA0BnB,gBAAgB,CAACoB,QAA3C,GACGvB,qBADH,GAEG3B,uBAHJ;AAKA,SAAO,EACN,GAAGC,KADG;AAEN4B,IAAAA,GAFM;AAGNsB,IAAAA,SAAS,EAAE1E,UAAU,CACpBwB,KAAK,CAACkD,SADc,EAEpB,iCAFoB,EAGpBlB,iCAAiC,GAAG,EAAH,GAAQG,gBAHrB,EAIpB;AACC,qBAAeE;AADhB,KAJoB,CAHf;AAWNc,IAAAA,QAAQ,EAAElD,QAAQ,GACjB,cAAC,WAAD,eAAkB4B,gBAAlB;AAAqC,MAAA,QAAQ,EAAG5B;AAAhD,OADiB,GAGjB,cAAC,cAAD,EAAqB8B,OAArB;AAdK,GAAP;AAiBA;AAEDD,mBAAmB,CAACsB,IAApB,GAA2BjE,mBAA3B,C,CAEA;;AACAwC,oBAAoB,CAACtC,oBAArB,GAA4CA,oBAA5C;AACAsC,oBAAoB,CAACvC,mBAArB,GAA2CA,mBAA3C;;AAEAuC,oBAAoB,CAAC0B,OAArB,GAA+B,MAAMvB,mBAAmB,CAACsB,IAApB,GAA2BD,QAAhE;AAEA;AACA;AACA;;;AACA,eAAexB,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\tstore as blocksStore,\n\t__unstableGetInnerBlocksProps as getInnerBlocksProps,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport getBlockContext from './get-block-context';\nimport { BlockListItems } from '../block-list';\nimport { BlockContextProvider } from '../block-context';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDropZone from '../use-block-drop-zone';\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\twrapperRef,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\t__experimentalAppenderTagName,\n\t\trenderAppender,\n\t\torientation,\n\t\tplaceholder,\n\t\t__experimentalLayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\t__experimentalLayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst { context, name } = useSelect(\n\t\t( select ) => {\n\t\t\tconst block = select( blockEditorStore ).getBlock( clientId );\n\n\t\t\t// This check is here to avoid the Redux zombie bug where a child subscription\n\t\t\t// is called before a parent, causing potential JS errors when the child has been removed.\n\t\t\tif ( ! block ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst blockType = getBlockType( block.name );\n\n\t\t\tif ( ! blockType || ! blockType.providesContext ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcontext: getBlockContext( block.attributes, blockType ),\n\t\t\t\tname: block.name,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { allowSizingOnChildren = false } =\n\t\tgetBlockSupport( name, '__experimentalLayout' ) || {};\n\n\tconst layout = useMemo(\n\t\t() => ( {\n\t\t\t...__experimentalLayout,\n\t\t\t...( allowSizingOnChildren && {\n\t\t\t\tallowSizingOnChildren: true,\n\t\t\t} ),\n\t\t} ),\n\t\t[ __experimentalLayout, allowSizingOnChildren ]\n\t);\n\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t<BlockListItems\n\t\t\t\trootClientId={ clientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\t\t__experimentalLayout={ layout }\n\t\t\t\twrapperRef={ wrapperRef }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t/>\n\t\t</BlockContextProvider>\n\t);\n}\n\n/**\n * The controlled inner blocks component wraps the uncontrolled inner blocks\n * component with the blockSync hook. This keeps the innerBlocks of the block in\n * the block-editor store in sync with the blocks of the controlling entity. An\n * example of an inner block controller is a template part block, which provides\n * its own blocks from the template part entity data source.\n *\n * @param {Object} props The component props.\n */\nfunction ControlledInnerBlocks( props ) {\n\tuseBlockSync( props );\n\treturn <UncontrolledInnerBlocks { ...props } />;\n}\n\nconst ForwardedInnerBlocks = forwardRef( ( props, ref ) => {\n\tconst innerBlocksProps = useInnerBlocksProps( { ref }, props );\n\treturn (\n\t\t<div className=\"block-editor-inner-blocks\">\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n} );\n\n/**\n * This hook is used to lightly mark an element as an inner blocks wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * an inner blocks wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Optional. Inner blocks options.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst { __unstableDisableLayoutClassNames, __unstableDisableDropZone } =\n\t\toptions;\n\tconst { clientId, __unstableLayoutClassNames: layoutClassNames = '' } =\n\t\tuseBlockEditContext();\n\tconst isSmallScreen = useViewportMatch( 'medium', '<' );\n\tconst { __experimentalCaptureToolbars, hasOverlay } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tisBlockSelected,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst enableClickThrough =\n\t\t\t\t__unstableGetEditorMode() === 'navigation' || isSmallScreen;\n\t\t\treturn {\n\t\t\t\t__experimentalCaptureToolbars: select(\n\t\t\t\t\tblocksStore\n\t\t\t\t).hasBlockSupport(\n\t\t\t\t\tblockName,\n\t\t\t\t\t'__experimentalExposeControlsToChildren',\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasOverlay:\n\t\t\t\t\tblockName !== 'core/template' &&\n\t\t\t\t\t! isBlockSelected( clientId ) &&\n\t\t\t\t\t! hasSelectedInnerBlock( clientId, true ) &&\n\t\t\t\t\tenableClickThrough,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isSmallScreen ]\n\t);\n\n\tconst blockDropZoneRef = useBlockDropZone( {\n\t\trootClientId: clientId,\n\t} );\n\n\tconst ref = useMergeRefs( [\n\t\tprops.ref,\n\t\t__unstableDisableDropZone ? null : blockDropZoneRef,\n\t] );\n\n\tconst innerBlocksProps = {\n\t\t__experimentalCaptureToolbars,\n\t\t...options,\n\t};\n\tconst InnerBlocks =\n\t\tinnerBlocksProps.value && innerBlocksProps.onChange\n\t\t\t? ControlledInnerBlocks\n\t\t\t: UncontrolledInnerBlocks;\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-list__layout',\n\t\t\t__unstableDisableLayoutClassNames ? '' : layoutClassNames,\n\t\t\t{\n\t\t\t\t'has-overlay': hasOverlay,\n\t\t\t}\n\t\t),\n\t\tchildren: clientId ? (\n\t\t\t<InnerBlocks { ...innerBlocksProps } clientId={ clientId } />\n\t\t) : (\n\t\t\t<BlockListItems { ...options } />\n\t\t),\n\t};\n}\n\nuseInnerBlocksProps.save = getInnerBlocksProps;\n\n// Expose default appender placeholders as components.\nForwardedInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;\nForwardedInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;\n\nForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport default ForwardedInnerBlocks;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-editor/src/components/inner-blocks/index.js"],"names":["classnames","useViewportMatch","useMergeRefs","forwardRef","useMemo","useSelect","getBlockSupport","getBlockType","store","blocksStore","__unstableGetInnerBlocksProps","getInnerBlocksProps","ButtonBlockAppender","DefaultBlockAppender","useNestedSettingsUpdate","useInnerBlockTemplateSync","getBlockContext","BlockListItems","BlockContextProvider","useBlockEditContext","useBlockSync","blockEditorStore","useBlockDropZone","UncontrolledInnerBlocks","props","clientId","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","template","templateLock","wrapperRef","templateInsertUpdatesSelection","__experimentalCaptureToolbars","captureToolbars","__experimentalAppenderTagName","renderAppender","orientation","placeholder","__experimentalLayout","context","name","select","block","getBlock","blockType","Object","keys","providesContext","length","attributes","allowSizingOnChildren","layout","ControlledInnerBlocks","ForwardedInnerBlocks","ref","innerBlocksProps","useInnerBlocksProps","options","__unstableDisableLayoutClassNames","__unstableDisableDropZone","__unstableLayoutClassNames","layoutClassNames","isSmallScreen","hasOverlay","getBlockName","isBlockSelected","hasSelectedInnerBlock","__unstableGetEditorMode","blockName","enableClickThrough","hasBlockSupport","blockDropZoneRef","rootClientId","InnerBlocks","value","onChange","className","children","save","Content"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,YAA3B,QAA+C,oBAA/C;AACA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,oBAApC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,eADD,EAECC,YAFD,EAGCC,KAAK,IAAIC,WAHV,EAICC,6BAA6B,IAAIC,mBAJlC,QAKO,mBALP;AAOA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,yBAAhC;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,OAAOC,yBAAP,MAAsC,iCAAtC;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,SAASC,cAAT,QAA+B,eAA/B;AACA,SAASC,oBAAT,QAAqC,kBAArC;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,OAAOC,YAAP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AAF,EAAYsC,aAAZ,CA9B8D,CAA/D;AAiCA,QAAMS,gBAAgB,GAAGlD,gBAAgB,CAAE;AAC1CmD,IAAAA,YAAY,EAAEhD;AAD4B,GAAF,CAAzC;AAIA,QAAM8B,GAAG,GAAGrD,YAAY,CAAE,CACzBsB,KAAK,CAAC+B,GADmB,EAEzBK,yBAAyB,GAAG,IAAH,GAAUY,gBAFV,CAAF,CAAxB;AAKA,QAAMhB,gBAAgB,GAAG;AACxBvB,IAAAA,6BADwB;AAExB,OAAGyB;AAFqB,GAAzB;AAIA,QAAMgB,WAAW,GAChBlB,gBAAgB,CAACmB,KAAjB,IAA0BnB,gBAAgB,CAACoB,QAA3C,GACGvB,qBADH,GAEG9B,uBAHJ;AAKA,SAAO,EACN,GAAGC,KADG;AAEN+B,IAAAA,GAFM;AAGNsB,IAAAA,SAAS,EAAE7E,UAAU,CACpBwB,KAAK,CAACqD,SADc,EAEpB,iCAFoB,EAGpBlB,iCAAiC,GAAG,EAAH,GAAQG,gBAHrB,EAIpB;AACC,qBAAeE;AADhB,KAJoB,CAHf;AAWNc,IAAAA,QAAQ,EAAErD,QAAQ,GACjB,cAAC,WAAD,eAAkB+B,gBAAlB;AAAqC,MAAA,QAAQ,EAAG/B;AAAhD,OADiB,GAGjB,cAAC,cAAD,EAAqBiC,OAArB;AAdK,GAAP;AAiBA;AAEDD,mBAAmB,CAACsB,IAApB,GAA2BpE,mBAA3B,C,CAEA;;AACA2C,oBAAoB,CAACzC,oBAArB,GAA4CA,oBAA5C;AACAyC,oBAAoB,CAAC1C,mBAArB,GAA2CA,mBAA3C;;AAEA0C,oBAAoB,CAAC0B,OAArB,GAA+B,MAAMvB,mBAAmB,CAACsB,IAApB,GAA2BD,QAAhE;AAEA;AACA;AACA;;;AACA,eAAexB,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { forwardRef, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tgetBlockSupport,\n\tgetBlockType,\n\tstore as blocksStore,\n\t__unstableGetInnerBlocksProps as getInnerBlocksProps,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport ButtonBlockAppender from './button-block-appender';\nimport DefaultBlockAppender from './default-block-appender';\nimport useNestedSettingsUpdate from './use-nested-settings-update';\nimport useInnerBlockTemplateSync from './use-inner-block-template-sync';\nimport getBlockContext from './get-block-context';\nimport { BlockListItems } from '../block-list';\nimport { BlockContextProvider } from '../block-context';\nimport { useBlockEditContext } from '../block-edit/context';\nimport useBlockSync from '../provider/use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDropZone from '../use-block-drop-zone';\n\n/**\n * InnerBlocks is a component which allows a single block to have multiple blocks\n * as children. The UncontrolledInnerBlocks component is used whenever the inner\n * blocks are not controlled by another entity. In other words, it is normally\n * used for inner blocks in the post editor\n *\n * @param {Object} props The component props.\n */\nfunction UncontrolledInnerBlocks( props ) {\n\tconst {\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\twrapperRef,\n\t\ttemplateInsertUpdatesSelection,\n\t\t__experimentalCaptureToolbars: captureToolbars,\n\t\t__experimentalAppenderTagName,\n\t\trenderAppender,\n\t\torientation,\n\t\tplaceholder,\n\t\t__experimentalLayout,\n\t} = props;\n\n\tuseNestedSettingsUpdate(\n\t\tclientId,\n\t\tallowedBlocks,\n\t\t__experimentalDefaultBlock,\n\t\t__experimentalDirectInsert,\n\t\ttemplateLock,\n\t\tcaptureToolbars,\n\t\torientation,\n\t\t__experimentalLayout\n\t);\n\n\tuseInnerBlockTemplateSync(\n\t\tclientId,\n\t\ttemplate,\n\t\ttemplateLock,\n\t\ttemplateInsertUpdatesSelection\n\t);\n\n\tconst { context, name } = useSelect(\n\t\t( select ) => {\n\t\t\tconst block = select( blockEditorStore ).getBlock( clientId );\n\n\t\t\t// This check is here to avoid the Redux zombie bug where a child subscription\n\t\t\t// is called before a parent, causing potential JS errors when the child has been removed.\n\t\t\tif ( ! block ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst blockType = getBlockType( block.name );\n\n\t\t\tif (\n\t\t\t\tObject.keys( blockType?.providesContext ?? {} ).length === 0\n\t\t\t) {\n\t\t\t\treturn { name: block.name };\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tcontext: getBlockContext( block.attributes, blockType ),\n\t\t\t\tname: block.name,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { allowSizingOnChildren = false } =\n\t\tgetBlockSupport( name, '__experimentalLayout' ) || {};\n\n\tconst layout = useMemo(\n\t\t() => ( {\n\t\t\t...__experimentalLayout,\n\t\t\t...( allowSizingOnChildren && {\n\t\t\t\tallowSizingOnChildren: true,\n\t\t\t} ),\n\t\t} ),\n\t\t[ __experimentalLayout, allowSizingOnChildren ]\n\t);\n\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<BlockContextProvider value={ context }>\n\t\t\t<BlockListItems\n\t\t\t\trootClientId={ clientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t\t__experimentalAppenderTagName={ __experimentalAppenderTagName }\n\t\t\t\t__experimentalLayout={ layout }\n\t\t\t\twrapperRef={ wrapperRef }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t/>\n\t\t</BlockContextProvider>\n\t);\n}\n\n/**\n * The controlled inner blocks component wraps the uncontrolled inner blocks\n * component with the blockSync hook. This keeps the innerBlocks of the block in\n * the block-editor store in sync with the blocks of the controlling entity. An\n * example of an inner block controller is a template part block, which provides\n * its own blocks from the template part entity data source.\n *\n * @param {Object} props The component props.\n */\nfunction ControlledInnerBlocks( props ) {\n\tuseBlockSync( props );\n\treturn <UncontrolledInnerBlocks { ...props } />;\n}\n\nconst ForwardedInnerBlocks = forwardRef( ( props, ref ) => {\n\tconst innerBlocksProps = useInnerBlocksProps( { ref }, props );\n\treturn (\n\t\t<div className=\"block-editor-inner-blocks\">\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n} );\n\n/**\n * This hook is used to lightly mark an element as an inner blocks wrapper\n * element. Call this hook and pass the returned props to the element to mark as\n * an inner blocks wrapper, automatically rendering inner blocks as children. If\n * you define a ref for the element, it is important to pass the ref to this\n * hook, which the hook in turn will pass to the component through the props it\n * returns. Optionally, you can also pass any other props through this hook, and\n * they will be merged and returned.\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Optional. Inner blocks options.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport function useInnerBlocksProps( props = {}, options = {} ) {\n\tconst { __unstableDisableLayoutClassNames, __unstableDisableDropZone } =\n\t\toptions;\n\tconst { clientId, __unstableLayoutClassNames: layoutClassNames = '' } =\n\t\tuseBlockEditContext();\n\tconst isSmallScreen = useViewportMatch( 'medium', '<' );\n\tconst { __experimentalCaptureToolbars, hasOverlay } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst {\n\t\t\t\tgetBlockName,\n\t\t\t\tisBlockSelected,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst blockName = getBlockName( clientId );\n\t\t\tconst enableClickThrough =\n\t\t\t\t__unstableGetEditorMode() === 'navigation' || isSmallScreen;\n\t\t\treturn {\n\t\t\t\t__experimentalCaptureToolbars: select(\n\t\t\t\t\tblocksStore\n\t\t\t\t).hasBlockSupport(\n\t\t\t\t\tblockName,\n\t\t\t\t\t'__experimentalExposeControlsToChildren',\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasOverlay:\n\t\t\t\t\tblockName !== 'core/template' &&\n\t\t\t\t\t! isBlockSelected( clientId ) &&\n\t\t\t\t\t! hasSelectedInnerBlock( clientId, true ) &&\n\t\t\t\t\tenableClickThrough,\n\t\t\t};\n\t\t},\n\t\t[ clientId, isSmallScreen ]\n\t);\n\n\tconst blockDropZoneRef = useBlockDropZone( {\n\t\trootClientId: clientId,\n\t} );\n\n\tconst ref = useMergeRefs( [\n\t\tprops.ref,\n\t\t__unstableDisableDropZone ? null : blockDropZoneRef,\n\t] );\n\n\tconst innerBlocksProps = {\n\t\t__experimentalCaptureToolbars,\n\t\t...options,\n\t};\n\tconst InnerBlocks =\n\t\tinnerBlocksProps.value && innerBlocksProps.onChange\n\t\t\t? ControlledInnerBlocks\n\t\t\t: UncontrolledInnerBlocks;\n\n\treturn {\n\t\t...props,\n\t\tref,\n\t\tclassName: classnames(\n\t\t\tprops.className,\n\t\t\t'block-editor-block-list__layout',\n\t\t\t__unstableDisableLayoutClassNames ? '' : layoutClassNames,\n\t\t\t{\n\t\t\t\t'has-overlay': hasOverlay,\n\t\t\t}\n\t\t),\n\t\tchildren: clientId ? (\n\t\t\t<InnerBlocks { ...innerBlocksProps } clientId={ clientId } />\n\t\t) : (\n\t\t\t<BlockListItems { ...options } />\n\t\t),\n\t};\n}\n\nuseInnerBlocksProps.save = getInnerBlocksProps;\n\n// Expose default appender placeholders as components.\nForwardedInnerBlocks.DefaultBlockAppender = DefaultBlockAppender;\nForwardedInnerBlocks.ButtonBlockAppender = ButtonBlockAppender;\n\nForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children;\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md\n */\nexport default ForwardedInnerBlocks;\n"]}
|
|
@@ -18,8 +18,8 @@ import BlockPatternList from '../block-patterns-list';
|
|
|
18
18
|
import PatternsExplorerModal from './block-patterns-explorer/explorer';
|
|
19
19
|
import MobileTabNavigation from './mobile-tab-navigation';
|
|
20
20
|
|
|
21
|
-
function usePatternsCategories() {
|
|
22
|
-
const [allPatterns, allCategories] = usePatternsState();
|
|
21
|
+
function usePatternsCategories(rootClientId) {
|
|
22
|
+
const [allPatterns, allCategories] = usePatternsState(undefined, rootClientId);
|
|
23
23
|
const hasRegisteredCategory = useCallback(pattern => {
|
|
24
24
|
if (!pattern.categories || !pattern.categories.length) {
|
|
25
25
|
return false;
|
|
@@ -94,7 +94,7 @@ export function BlockPatternsCategoryPanel(_ref4) {
|
|
|
94
94
|
showTitlesAsTooltip
|
|
95
95
|
} = _ref4;
|
|
96
96
|
const [allPatterns,, onClick] = usePatternsState(onInsert, rootClientId);
|
|
97
|
-
const availableCategories = usePatternsCategories();
|
|
97
|
+
const availableCategories = usePatternsCategories(rootClientId);
|
|
98
98
|
const currentCategoryPatterns = useMemo(() => allPatterns.filter(pattern => {
|
|
99
99
|
var _pattern$categories$f, _pattern$categories3;
|
|
100
100
|
|
|
@@ -139,7 +139,7 @@ function BlockPatternsTabs(_ref5) {
|
|
|
139
139
|
rootClientId
|
|
140
140
|
} = _ref5;
|
|
141
141
|
const [showPatternsExplorer, setShowPatternsExplorer] = useState(false);
|
|
142
|
-
const categories = usePatternsCategories();
|
|
142
|
+
const categories = usePatternsCategories(rootClientId);
|
|
143
143
|
const isMobile = useViewportMatch('medium', '<');
|
|
144
144
|
return createElement(Fragment, null, !isMobile && createElement("div", {
|
|
145
145
|
className: "block-editor-inserter__block-patterns-tabs-container"
|