@wordpress/block-editor 12.21.0 → 12.23.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 +4 -0
- package/README.md +4 -0
- package/build/components/block-actions/index.js +2 -4
- package/build/components/block-actions/index.js.map +1 -1
- package/build/components/block-heading-level-dropdown/index.js +5 -5
- package/build/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build/components/block-heading-level-dropdown/index.native.js +5 -4
- package/build/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build/components/block-list/block-crash-boundary.native.js +49 -0
- package/build/components/block-list/block-crash-boundary.native.js.map +1 -0
- package/build/components/block-list/block-crash-warning.native.js +24 -0
- package/build/components/block-list/block-crash-warning.native.js.map +1 -0
- package/build/components/block-list/block.js +11 -3
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-list/block.native.js +7 -2
- package/build/components/block-list/block.native.js.map +1 -1
- package/build/components/block-mover/button.js +4 -1
- package/build/components/block-mover/button.js.map +1 -1
- package/build/components/block-mover/index.js +5 -1
- package/build/components/block-mover/index.js.map +1 -1
- package/build/components/block-patterns-list/index.js +4 -1
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-settings/container.native.js +2 -1
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js +36 -32
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu-controls/index.js +1 -3
- package/build/components/block-settings-menu-controls/index.js.map +1 -1
- package/build/components/block-switcher/index.js +4 -3
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +8 -5
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/shuffle.js +19 -10
- package/build/components/block-toolbar/shuffle.js.map +1 -1
- package/build/components/block-tools/block-selection-button.js +48 -8
- package/build/components/block-tools/block-selection-button.js.map +1 -1
- package/build/components/block-tools/index.js +14 -2
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/child-layout-control/index.js +108 -11
- package/build/components/child-layout-control/index.js.map +1 -1
- package/build/components/convert-to-group-buttons/toolbar.js +11 -0
- package/build/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build/components/global-styles/advanced-panel.js +9 -2
- package/build/components/global-styles/advanced-panel.js.map +1 -1
- package/build/components/global-styles/background-panel.js +444 -0
- package/build/components/global-styles/background-panel.js.map +1 -0
- package/build/components/global-styles/color-panel.js +2 -1
- package/build/components/global-styles/color-panel.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +8 -33
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/get-global-styles-changes.js +3 -0
- package/build/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build/components/global-styles/hooks.js +1 -1
- package/build/components/global-styles/hooks.js.map +1 -1
- package/build/components/global-styles/index.js +13 -0
- package/build/components/global-styles/index.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +16 -15
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/global-styles/utils.js +2 -3
- package/build/components/global-styles/utils.js.map +1 -1
- package/build/components/iframe/index.js +43 -34
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/index.js +3 -6
- package/build/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +5 -0
- package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build/components/inserter/library.js +2 -0
- package/build/components/inserter/library.js.map +1 -1
- package/build/components/inserter/menu.js +11 -11
- package/build/components/inserter/menu.js.map +1 -1
- package/build/components/inserter/mobile-tab-navigation.js +1 -1
- package/build/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build/components/inserter/search-items.js +36 -15
- package/build/components/inserter/search-items.js.map +1 -1
- package/build/components/inserter/search-results.js +2 -3
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter/tabs.js +1 -2
- package/build/components/inserter/tabs.js.map +1 -1
- package/build/components/inspector-controls-tabs/advanced-controls-panel.native.js +36 -0
- package/build/components/inspector-controls-tabs/advanced-controls-panel.native.js.map +1 -0
- package/build/components/keyboard-shortcuts/index.js +11 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +18 -12
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/list-view/block.js +4 -11
- package/build/components/list-view/block.js.map +1 -1
- package/build/components/list-view/index.js +17 -2
- package/build/components/list-view/index.js.map +1 -1
- package/build/components/list-view/use-list-view-collapse-items.js +47 -0
- package/build/components/list-view/use-list-view-collapse-items.js.map +1 -0
- package/build/components/list-view/utils.js +5 -3
- package/build/components/list-view/utils.js.map +1 -1
- package/build/components/rich-text/index.js +14 -11
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/index.native.js +17 -11
- package/build/components/rich-text/index.native.js.map +1 -1
- package/build/components/rich-text/native/get-format-colors.native.js +1 -1
- package/build/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build/components/rich-text/native/index.native.js +2 -2
- package/build/components/rich-text/native/index.native.js.map +1 -1
- package/build/components/rich-text/with-deprecations.js +0 -3
- package/build/components/rich-text/with-deprecations.js.map +1 -1
- package/build/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/build/components/spacing-sizes-control/sides-dropdown/index.js.map +1 -1
- package/build/components/url-popover/image-url-input-ui.js +50 -36
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/use-block-display-information/index.js +4 -6
- package/build/components/use-block-display-information/index.js.map +1 -1
- package/build/components/use-moving-animation/index.js +4 -0
- package/build/components/use-moving-animation/index.js.map +1 -1
- package/build/components/warning/index.native.js +9 -4
- package/build/components/warning/index.native.js.map +1 -1
- package/build/hooks/anchor.js +9 -10
- package/build/hooks/anchor.js.map +1 -1
- package/build/hooks/background.js +85 -402
- package/build/hooks/background.js.map +1 -1
- package/build/hooks/index.js +9 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/layout-child.js +28 -6
- package/build/hooks/layout-child.js.map +1 -1
- package/build/hooks/layout.js +21 -10
- package/build/hooks/layout.js.map +1 -1
- package/build/hooks/position.js +1 -1
- package/build/hooks/position.js.map +1 -1
- package/build/hooks/use-zoom-out.js +47 -0
- package/build/hooks/use-zoom-out.js.map +1 -0
- package/build/index.js +7 -0
- package/build/index.js.map +1 -1
- package/build/private-apis.js +6 -1
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +5 -1
- package/build/private-apis.native.js.map +1 -1
- package/build/store/private-actions.js +13 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-keys.js +2 -1
- package/build/store/private-keys.js.map +1 -1
- package/build/store/private-selectors.js +24 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +53 -26
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +34 -32
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +7 -1
- package/build/store/utils.js.map +1 -1
- package/build/utils/transform-styles/index.js +2 -1
- package/build/utils/transform-styles/index.js.map +1 -1
- package/build-module/components/block-actions/index.js +2 -4
- package/build-module/components/block-actions/index.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.js +5 -5
- package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
- package/build-module/components/block-heading-level-dropdown/index.native.js +5 -4
- package/build-module/components/block-heading-level-dropdown/index.native.js.map +1 -1
- package/build-module/components/block-list/block-crash-boundary.native.js +42 -0
- package/build-module/components/block-list/block-crash-boundary.native.js.map +1 -0
- package/build-module/components/block-list/block-crash-warning.native.js +15 -0
- package/build-module/components/block-list/block-crash-warning.native.js.map +1 -0
- package/build-module/components/block-list/block.js +11 -3
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-list/block.native.js +7 -2
- package/build-module/components/block-list/block.native.js.map +1 -1
- package/build-module/components/block-mover/button.js +4 -1
- package/build-module/components/block-mover/button.js.map +1 -1
- package/build-module/components/block-mover/index.js +5 -1
- package/build-module/components/block-mover/index.js.map +1 -1
- package/build-module/components/block-patterns-list/index.js +4 -1
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +3 -2
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +37 -33
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu-controls/index.js +1 -3
- package/build-module/components/block-settings-menu-controls/index.js.map +1 -1
- package/build-module/components/block-switcher/index.js +4 -3
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +8 -5
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/shuffle.js +19 -10
- package/build-module/components/block-toolbar/shuffle.js.map +1 -1
- package/build-module/components/block-tools/block-selection-button.js +50 -10
- package/build-module/components/block-tools/block-selection-button.js.map +1 -1
- package/build-module/components/block-tools/index.js +14 -2
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/child-layout-control/index.js +109 -12
- package/build-module/components/child-layout-control/index.js.map +1 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js +12 -1
- package/build-module/components/convert-to-group-buttons/toolbar.js.map +1 -1
- package/build-module/components/global-styles/advanced-panel.js +9 -2
- package/build-module/components/global-styles/advanced-panel.js.map +1 -1
- package/build-module/components/global-styles/background-panel.js +430 -0
- package/build-module/components/global-styles/background-panel.js.map +1 -0
- package/build-module/components/global-styles/color-panel.js +2 -1
- package/build-module/components/global-styles/color-panel.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +9 -34
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/get-global-styles-changes.js +3 -0
- package/build-module/components/global-styles/get-global-styles-changes.js.map +1 -1
- package/build-module/components/global-styles/hooks.js +1 -1
- package/build-module/components/global-styles/hooks.js.map +1 -1
- package/build-module/components/global-styles/index.js +1 -0
- package/build-module/components/global-styles/index.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +17 -16
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/global-styles/utils.js +1 -2
- package/build-module/components/global-styles/utils.js.map +1 -1
- package/build-module/components/iframe/index.js +43 -34
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/index.js +3 -6
- package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +3 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +5 -0
- package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -1
- package/build-module/components/inserter/library.js +2 -0
- package/build-module/components/inserter/library.js.map +1 -1
- package/build-module/components/inserter/menu.js +11 -11
- package/build-module/components/inserter/menu.js.map +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js +1 -1
- package/build-module/components/inserter/mobile-tab-navigation.js.map +1 -1
- package/build-module/components/inserter/search-items.js +33 -15
- package/build-module/components/inserter/search-items.js.map +1 -1
- package/build-module/components/inserter/search-results.js +2 -3
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter/tabs.js +1 -2
- package/build-module/components/inserter/tabs.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.native.js +28 -0
- package/build-module/components/inspector-controls-tabs/advanced-controls-panel.native.js.map +1 -0
- package/build-module/components/keyboard-shortcuts/index.js +11 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +19 -13
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/list-view/block.js +6 -13
- package/build-module/components/list-view/block.js.map +1 -1
- package/build-module/components/list-view/index.js +17 -2
- package/build-module/components/list-view/index.js.map +1 -1
- package/build-module/components/list-view/use-list-view-collapse-items.js +40 -0
- package/build-module/components/list-view/use-list-view-collapse-items.js.map +1 -0
- package/build-module/components/list-view/utils.js +2 -1
- package/build-module/components/list-view/utils.js.map +1 -1
- package/build-module/components/rich-text/index.js +15 -12
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/index.native.js +16 -11
- package/build-module/components/rich-text/index.native.js.map +1 -1
- package/build-module/components/rich-text/native/get-format-colors.native.js +1 -1
- package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -1
- package/build-module/components/rich-text/native/index.native.js +2 -2
- package/build-module/components/rich-text/native/index.native.js.map +1 -1
- package/build-module/components/rich-text/with-deprecations.js +0 -3
- package/build-module/components/rich-text/with-deprecations.js.map +1 -1
- package/build-module/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/build-module/components/spacing-sizes-control/sides-dropdown/index.js.map +1 -1
- package/build-module/components/url-popover/image-url-input-ui.js +50 -36
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/use-block-display-information/index.js +5 -7
- package/build-module/components/use-block-display-information/index.js.map +1 -1
- package/build-module/components/use-moving-animation/index.js +4 -0
- package/build-module/components/use-moving-animation/index.js.map +1 -1
- package/build-module/components/warning/index.native.js +9 -4
- package/build-module/components/warning/index.native.js.map +1 -1
- package/build-module/hooks/anchor.js +10 -11
- package/build-module/hooks/anchor.js.map +1 -1
- package/build-module/hooks/background.js +82 -397
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/hooks/index.js +3 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/layout-child.js +28 -6
- package/build-module/hooks/layout-child.js.map +1 -1
- package/build-module/hooks/layout.js +21 -10
- package/build-module/hooks/layout.js.map +1 -1
- package/build-module/hooks/position.js +1 -1
- package/build-module/hooks/position.js.map +1 -1
- package/build-module/hooks/use-zoom-out.js +41 -0
- package/build-module/hooks/use-zoom-out.js.map +1 -0
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/private-apis.js +7 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +5 -1
- package/build-module/private-apis.native.js.map +1 -1
- package/build-module/store/private-actions.js +12 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-keys.js +1 -0
- package/build-module/store/private-keys.js.map +1 -1
- package/build-module/store/private-selectors.js +22 -4
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +52 -26
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +35 -33
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +6 -1
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/transform-styles/index.js +2 -1
- package/build-module/utils/transform-styles/index.js.map +1 -1
- package/build-style/content-rtl.css +18 -1
- package/build-style/content.css +18 -1
- package/build-style/style-rtl.css +92 -99
- package/build-style/style.css +92 -99
- package/package.json +31 -31
- package/src/components/block-actions/index.js +2 -8
- package/src/components/block-bindings-toolbar-indicator/style.scss +10 -8
- package/src/components/block-heading-level-dropdown/README.md +5 -5
- package/src/components/block-heading-level-dropdown/index.js +5 -5
- package/src/components/block-heading-level-dropdown/index.native.js +5 -4
- package/src/components/block-list/block-crash-boundary.native.js +43 -0
- package/src/components/block-list/block-crash-warning.native.js +19 -0
- package/src/components/block-list/block.js +19 -3
- package/src/components/block-list/block.native.js +14 -7
- package/src/components/block-list/content.scss +16 -0
- package/src/components/block-mover/button.js +4 -1
- package/src/components/block-mover/index.js +8 -1
- package/src/components/block-patterns-list/index.js +22 -17
- package/src/components/block-preview/style.scss +28 -0
- package/src/components/block-settings/container.native.js +5 -1
- package/src/components/block-settings-menu/block-settings-dropdown.js +49 -58
- package/src/components/block-settings-menu-controls/README.md +0 -9
- package/src/components/block-settings-menu-controls/index.js +1 -6
- package/src/components/block-switcher/index.js +5 -3
- package/src/components/block-switcher/style.scss +1 -1
- package/src/components/block-toolbar/index.js +25 -20
- package/src/components/block-toolbar/shuffle.js +20 -14
- package/src/components/block-toolbar/style.scss +1 -1
- package/src/components/block-toolbar/test/index.native.js +1 -7
- package/src/components/block-tools/block-selection-button.js +66 -9
- package/src/components/block-tools/index.js +18 -1
- package/src/components/button-block-appender/content.scss +5 -1
- package/src/components/child-layout-control/index.js +147 -35
- package/src/components/convert-to-group-buttons/toolbar.js +13 -1
- package/src/components/default-block-appender/content.scss +2 -2
- package/src/components/global-styles/advanced-panel.js +8 -2
- package/src/components/global-styles/background-panel.js +591 -0
- package/src/components/global-styles/color-panel.js +2 -1
- package/src/components/global-styles/dimensions-panel.js +9 -34
- package/src/components/global-styles/get-global-styles-changes.js +3 -0
- package/src/components/global-styles/hooks.js +1 -0
- package/src/components/global-styles/index.js +4 -0
- package/src/components/global-styles/style.scss +78 -1
- package/src/{hooks/test/background.js → components/global-styles/test/background-panel.js} +36 -1
- package/src/components/global-styles/test/get-global-styles-changes.js +22 -3
- package/src/components/global-styles/test/use-global-styles-output.js +40 -9
- package/src/components/global-styles/use-global-styles-output.js +30 -17
- package/src/components/global-styles/utils.js +1 -18
- package/src/components/iframe/index.js +79 -53
- package/src/components/inserter/block-patterns-explorer/index.js +2 -9
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +7 -1
- package/src/components/inserter/block-patterns-tab/index.js +1 -0
- package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +5 -0
- package/src/components/inserter/library.js +4 -0
- package/src/components/inserter/menu.js +12 -11
- package/src/components/inserter/mobile-tab-navigation.js +1 -1
- package/src/components/inserter/search-items.js +37 -15
- package/src/components/inserter/search-results.js +1 -2
- package/src/components/inserter/style.scss +6 -12
- package/src/components/inserter/tabs.js +1 -2
- package/src/components/inspector-controls-tabs/advanced-controls-panel.native.js +31 -0
- package/src/components/keyboard-shortcuts/index.js +11 -0
- package/src/components/link-control/style.scss +0 -5
- package/src/components/list-view/block-select-button.js +15 -19
- package/src/components/list-view/block.js +12 -21
- package/src/components/list-view/index.js +18 -1
- package/src/components/list-view/style.scss +38 -28
- package/src/components/list-view/use-list-view-collapse-items.js +33 -0
- package/src/components/list-view/utils.js +4 -1
- package/src/components/rich-text/README.md +6 -0
- package/src/components/rich-text/index.js +30 -13
- package/src/components/rich-text/index.native.js +14 -11
- package/src/components/rich-text/native/get-format-colors.native.js +1 -1
- package/src/components/rich-text/native/index.native.js +2 -2
- package/src/components/rich-text/with-deprecations.js +0 -3
- package/src/components/spacing-sizes-control/sides-dropdown/index.js +1 -1
- package/src/components/url-popover/image-url-input-ui.js +68 -51
- package/src/components/use-block-display-information/index.js +8 -10
- package/src/components/use-moving-animation/index.js +1 -0
- package/src/components/warning/index.native.js +19 -15
- package/src/hooks/anchor.js +43 -61
- package/src/hooks/background.js +100 -516
- package/src/hooks/index.js +3 -0
- package/src/hooks/layout-child.js +44 -8
- package/src/hooks/layout.js +22 -18
- package/src/hooks/position.js +1 -1
- package/src/hooks/test/__snapshots__/anchor.native.js.snap +7 -0
- package/src/hooks/test/anchor.native.js +32 -0
- package/src/hooks/use-zoom-out.js +36 -0
- package/src/index.js +1 -0
- package/src/private-apis.js +13 -1
- package/src/private-apis.native.js +4 -0
- package/src/store/private-actions.js +12 -0
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +54 -27
- package/src/store/reducer.js +63 -41
- package/src/store/selectors.js +195 -180
- package/src/store/test/private-actions.js +10 -0
- package/src/store/test/private-selectors.js +13 -0
- package/src/store/test/reducer.js +26 -0
- package/src/store/test/selectors.js +90 -199
- package/src/store/utils.js +13 -0
- package/src/style.scss +0 -2
- package/src/utils/transform-styles/index.js +2 -1
- package/tsconfig.json +1 -0
- package/build/utils/calculate-scale.js +0 -17
- package/build/utils/calculate-scale.js.map +0 -1
- package/build-module/utils/calculate-scale.js +0 -11
- package/build-module/utils/calculate-scale.js.map +0 -1
- package/src/hooks/anchor.scss +0 -4
- package/src/hooks/background.scss +0 -75
- package/src/utils/calculate-scale.js +0 -20
|
@@ -20,7 +20,6 @@ import { useBlockSelectionClearer } from '../block-selection-clearer';
|
|
|
20
20
|
import { useWritingFlow } from '../writing-flow';
|
|
21
21
|
import { getCompatibilityStyles } from './get-compatibility-styles';
|
|
22
22
|
import { store as blockEditorStore } from '../../store';
|
|
23
|
-
import calculateScale from '../../utils/calculate-scale';
|
|
24
23
|
function bubbleEvent(event, Constructor, frame) {
|
|
25
24
|
const init = {};
|
|
26
25
|
for (const key in event) {
|
|
@@ -93,7 +92,8 @@ function Iframe({
|
|
|
93
92
|
contentRef,
|
|
94
93
|
children,
|
|
95
94
|
tabIndex = 0,
|
|
96
|
-
|
|
95
|
+
scale = 1,
|
|
96
|
+
frameSize = 0,
|
|
97
97
|
readonly,
|
|
98
98
|
forwardedRef: ref,
|
|
99
99
|
title = __('Editor canvas'),
|
|
@@ -101,18 +101,15 @@ function Iframe({
|
|
|
101
101
|
}) {
|
|
102
102
|
const {
|
|
103
103
|
resolvedAssets,
|
|
104
|
-
isPreviewMode
|
|
105
|
-
isZoomOutMode
|
|
104
|
+
isPreviewMode
|
|
106
105
|
} = useSelect(select => {
|
|
107
106
|
const {
|
|
108
|
-
getSettings
|
|
109
|
-
__unstableGetEditorMode
|
|
107
|
+
getSettings
|
|
110
108
|
} = select(blockEditorStore);
|
|
111
109
|
const settings = getSettings();
|
|
112
110
|
return {
|
|
113
111
|
resolvedAssets: settings.__unstableResolvedAssets,
|
|
114
|
-
isPreviewMode: settings.__unstableIsPreviewMode
|
|
115
|
-
isZoomOutMode: __unstableGetEditorMode() === 'zoom-out'
|
|
112
|
+
isPreviewMode: settings.__unstableIsPreviewMode
|
|
116
113
|
};
|
|
117
114
|
}, []);
|
|
118
115
|
const {
|
|
@@ -127,18 +124,6 @@ function Iframe({
|
|
|
127
124
|
height: contentHeight,
|
|
128
125
|
width: contentWidth
|
|
129
126
|
}] = useResizeObserver();
|
|
130
|
-
|
|
131
|
-
// When zoom-out mode is enabled, the iframe is scaled down to fit the
|
|
132
|
-
// content within the viewport.
|
|
133
|
-
// At 1000px wide, the iframe is scaled to 45%.
|
|
134
|
-
// At 400px wide, the iframe is scaled to 90%.
|
|
135
|
-
const scale = isZoomOutMode && shouldZoom ? calculateScale({
|
|
136
|
-
maxWidth: 1000,
|
|
137
|
-
minWidth: 400,
|
|
138
|
-
maxScale: 0.45,
|
|
139
|
-
minScale: 0.9
|
|
140
|
-
}, contentWidth) : 1;
|
|
141
|
-
const frameSize = isZoomOutMode ? 100 : 0;
|
|
142
127
|
const setRef = useRefEffect(node => {
|
|
143
128
|
node._load = () => {
|
|
144
129
|
setIframeDocument(node.contentDocument);
|
|
@@ -156,6 +141,11 @@ function Iframe({
|
|
|
156
141
|
const {
|
|
157
142
|
documentElement
|
|
158
143
|
} = contentDocument;
|
|
144
|
+
// Get any CSS classes the iframe document body may initially have
|
|
145
|
+
// to re-apply them later together with the ones of the main document
|
|
146
|
+
// body. This is necessary for some CSS classes for example the
|
|
147
|
+
// `is-dark-theme` class added by useDarkThemeBodyClassName.
|
|
148
|
+
const initialIframeBodyClasses = Array.from(contentDocument.body.classList);
|
|
159
149
|
iFrameDocument = contentDocument;
|
|
160
150
|
documentElement.classList.add('block-editor-iframe__html');
|
|
161
151
|
clearerRef(documentElement);
|
|
@@ -163,7 +153,7 @@ function Iframe({
|
|
|
163
153
|
// Ideally ALL classes that are added through get_body_class should
|
|
164
154
|
// be added in the editor too, which we'll somehow have to get from
|
|
165
155
|
// the server in the future (which will run the PHP filters).
|
|
166
|
-
setBodyClasses(Array.from(ownerDocument.body.classList).filter(name => name.startsWith('admin-color-') || name.startsWith('post-type-') || name === 'wp-embed-responsive'));
|
|
156
|
+
setBodyClasses(Array.from(ownerDocument.body.classList).concat(initialIframeBodyClasses).filter(name => name.startsWith('admin-color-') || name.startsWith('post-type-') || name === 'wp-embed-responsive' || name === 'is-dark-theme'));
|
|
167
157
|
contentDocument.dir = ownerDocument.dir;
|
|
168
158
|
for (const compatStyle of getCompatibilityStyles()) {
|
|
169
159
|
if (contentDocument.getElementById(compatStyle.id)) {
|
|
@@ -186,10 +176,21 @@ function Iframe({
|
|
|
186
176
|
iFrameDocument?.removeEventListener('drop', preventFileDropDefault);
|
|
187
177
|
};
|
|
188
178
|
}, []);
|
|
179
|
+
const windowResizeRef = useRefEffect(node => {
|
|
180
|
+
const nodeWindow = node.ownerDocument.defaultView;
|
|
181
|
+
const onResize = () => {
|
|
182
|
+
setIframeWindowInnerHeight(nodeWindow.innerHeight);
|
|
183
|
+
};
|
|
184
|
+
nodeWindow.addEventListener('resize', onResize);
|
|
185
|
+
return () => {
|
|
186
|
+
nodeWindow.removeEventListener('resize', onResize);
|
|
187
|
+
};
|
|
188
|
+
}, []);
|
|
189
|
+
const [iframeWindowInnerHeight, setIframeWindowInnerHeight] = useState();
|
|
189
190
|
const disabledRef = useDisabled({
|
|
190
191
|
isDisabled: !readonly
|
|
191
192
|
});
|
|
192
|
-
const bodyRef = useMergeRefs([useBubbleEvents(iframeDocument), contentRef, clearerRef, writingFlowRef, disabledRef]);
|
|
193
|
+
const bodyRef = useMergeRefs([useBubbleEvents(iframeDocument), contentRef, clearerRef, writingFlowRef, disabledRef, windowResizeRef]);
|
|
193
194
|
|
|
194
195
|
// Correct doctype is required to enable rendering in standards
|
|
195
196
|
// mode. Also preload the styles to avoid a flash of unstyled
|
|
@@ -204,12 +205,12 @@ function Iframe({
|
|
|
204
205
|
height: auto !important;
|
|
205
206
|
min-height: 100%;
|
|
206
207
|
}
|
|
207
|
-
|
|
208
|
-
body {
|
|
208
|
+
/* Lowest specificity to not override global styles */
|
|
209
|
+
:where(body) {
|
|
209
210
|
margin: 0;
|
|
210
211
|
/* Default background color in case zoom out mode background
|
|
211
212
|
colors the html element */
|
|
212
|
-
background: white;
|
|
213
|
+
background-color: white;
|
|
213
214
|
}
|
|
214
215
|
</style>
|
|
215
216
|
${styles}
|
|
@@ -226,23 +227,31 @@ function Iframe({
|
|
|
226
227
|
return [_src, () => URL.revokeObjectURL(_src)];
|
|
227
228
|
}, [html]);
|
|
228
229
|
useEffect(() => cleanup, [cleanup]);
|
|
229
|
-
|
|
230
|
-
// We need to counter the margin created by scaling the iframe. If the scale
|
|
231
|
-
// is e.g. 0.45, then the top + bottom margin is 0.55 (1 - scale). Just the
|
|
232
|
-
// top or bottom margin is 0.55 / 2 ((1 - scale) / 2).
|
|
233
|
-
const marginFromScaling = contentHeight * (1 - scale) / 2;
|
|
234
230
|
useEffect(() => {
|
|
235
|
-
if (iframeDocument
|
|
236
|
-
|
|
231
|
+
if (!iframeDocument) {
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const _scale = typeof scale === 'function' ? scale(contentWidth, contentHeight) : scale;
|
|
235
|
+
if (_scale !== 1) {
|
|
236
|
+
// Hack to get proper margins when scaling the iframe document.
|
|
237
|
+
const bottomFrameSize = frameSize - contentHeight * (1 - _scale);
|
|
238
|
+
iframeDocument.body.classList.add('is-zoomed-out');
|
|
239
|
+
iframeDocument.documentElement.style.transform = `scale( ${_scale} )`;
|
|
237
240
|
iframeDocument.documentElement.style.marginTop = `${frameSize}px`;
|
|
238
|
-
|
|
241
|
+
// TODO: `marginBottom` doesn't work in Firefox. We need another way to do this.
|
|
242
|
+
iframeDocument.documentElement.style.marginBottom = `${bottomFrameSize}px`;
|
|
243
|
+
if (iframeWindowInnerHeight > contentHeight * _scale) {
|
|
244
|
+
iframeDocument.body.style.minHeight = `${Math.floor((iframeWindowInnerHeight - 2 * frameSize) / _scale)}px`;
|
|
245
|
+
}
|
|
239
246
|
return () => {
|
|
247
|
+
iframeDocument.body.classList.remove('is-zoomed-out');
|
|
240
248
|
iframeDocument.documentElement.style.transform = '';
|
|
241
249
|
iframeDocument.documentElement.style.marginTop = '';
|
|
242
250
|
iframeDocument.documentElement.style.marginBottom = '';
|
|
251
|
+
iframeDocument.body.style.minHeight = '';
|
|
243
252
|
};
|
|
244
253
|
}
|
|
245
|
-
}, [scale, frameSize,
|
|
254
|
+
}, [scale, frameSize, iframeDocument, contentHeight, iframeWindowInnerHeight, contentWidth]);
|
|
246
255
|
|
|
247
256
|
// Make sure to not render the before and after focusable div elements in view
|
|
248
257
|
// mode. They're only needed to capture focus in edit mode.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","useState","createPortal","forwardRef","useMemo","useEffect","__","useResizeObserver","useMergeRefs","useRefEffect","useDisabled","__experimentalStyleProvider","StyleProvider","useSelect","useBlockSelectionClearer","useWritingFlow","getCompatibilityStyles","store","blockEditorStore","calculateScale","bubbleEvent","event","Constructor","frame","init","key","contentDocument","defaultView","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","defaultPrevented","preventDefault","cancelled","dispatchEvent","useBubbleEvents","iframeDocument","frameElement","html","documentElement","eventTypes","handlers","name","prototype","Object","getPrototypeOf","constructorName","constructor","window","addEventListener","removeEventListener","Iframe","contentRef","children","tabIndex","shouldZoom","readonly","forwardedRef","ref","title","props","resolvedAssets","isPreviewMode","isZoomOutMode","select","getSettings","__unstableGetEditorMode","settings","__unstableResolvedAssets","__unstableIsPreviewMode","styles","scripts","setIframeDocument","bodyClasses","setBodyClasses","clearerRef","before","writingFlowRef","after","contentResizeListener","height","contentHeight","width","contentWidth","scale","maxWidth","minWidth","maxScale","minScale","frameSize","setRef","node","_load","iFrameDocument","preventFileDropDefault","onLoad","ownerDocument","classList","add","Array","from","body","filter","startsWith","dir","compatStyle","getElementById","id","head","appendChild","cloneNode","console","warn","disabledRef","isDisabled","bodyRef","src","cleanup","_src","URL","createObjectURL","Blob","revokeObjectURL","marginFromScaling","style","transform","marginTop","marginBottom","shouldRenderFocusCaptureElements","createElement","Fragment","border","transition","onKeyDown","currentTarget","target","stopPropagation","KeyboardEvent","className","document","IframeIfReady","isInitialised","__internalIsInitialized"],"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\nimport { getCompatibilityStyles } from './get-compatibility-styles';\nimport { store as blockEditorStore } from '../../store';\nimport calculateScale from '../../utils/calculate-scale';\nfunction bubbleEvent( event, Constructor, frame ) {\n\tconst init = {};\n\n\tfor ( const key in event ) {\n\t\tinit[ key ] = event[ key ];\n\t}\n\n\t// Check if the event is a MouseEvent generated within the iframe.\n\t// If so, adjust the coordinates to be relative to the position of\n\t// the iframe. This ensures that components such as Draggable\n\t// receive coordinates relative to the window, instead of relative\n\t// to the iframe. Without this, the Draggable event handler would\n\t// result in components \"jumping\" position as soon as the user\n\t// drags over the iframe.\n\tif ( event instanceof frame.contentDocument.defaultView.MouseEvent ) {\n\t\tconst rect = frame.getBoundingClientRect();\n\t\tinit.clientX += rect.left;\n\t\tinit.clientY += rect.top;\n\t}\n\n\tconst newEvent = new Constructor( event.type, init );\n\tif ( init.defaultPrevented ) {\n\t\tnewEvent.preventDefault();\n\t}\n\tconst cancelled = ! frame.dispatchEvent( newEvent );\n\n\tif ( cancelled ) {\n\t\tevent.preventDefault();\n\t}\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} iframeDocument Document to attach listeners to.\n */\nfunction useBubbleEvents( iframeDocument ) {\n\treturn useRefEffect( () => {\n\t\tconst { defaultView } = iframeDocument;\n\t\tif ( ! defaultView ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { frameElement } = defaultView;\n\t\tconst html = iframeDocument.documentElement;\n\t\tconst eventTypes = [ 'dragover', 'mousemove' ];\n\t\tconst handlers = {};\n\t\tfor ( const name of eventTypes ) {\n\t\t\thandlers[ name ] = ( event ) => {\n\t\t\t\tconst prototype = Object.getPrototypeOf( event );\n\t\t\t\tconst constructorName = prototype.constructor.name;\n\t\t\t\tconst Constructor = window[ constructorName ];\n\t\t\t\tbubbleEvent( event, Constructor, frameElement );\n\t\t\t};\n\t\t\thtml.addEventListener( name, handlers[ name ] );\n\t\t}\n\n\t\treturn () => {\n\t\t\tfor ( const name of eventTypes ) {\n\t\t\t\thtml.removeEventListener( name, handlers[ name ] );\n\t\t\t}\n\t\t};\n\t} );\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\ttabIndex = 0,\n\tshouldZoom = false,\n\treadonly,\n\tforwardedRef: ref,\n\ttitle = __( 'Editor canvas' ),\n\t...props\n} ) {\n\tconst { resolvedAssets, isPreviewMode, isZoomOutMode } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, __unstableGetEditorMode } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst settings = getSettings();\n\t\t\treturn {\n\t\t\t\tresolvedAssets: settings.__unstableResolvedAssets,\n\t\t\t\tisPreviewMode: settings.__unstableIsPreviewMode,\n\t\t\t\tisZoomOutMode: __unstableGetEditorMode() === 'zoom-out',\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { styles = '', scripts = '' } = resolvedAssets;\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [\n\t\tcontentResizeListener,\n\t\t{ height: contentHeight, width: contentWidth },\n\t] = useResizeObserver();\n\n\t// When zoom-out mode is enabled, the iframe is scaled down to fit the\n\t// content within the viewport.\n\t// At 1000px wide, the iframe is scaled to 45%.\n\t// At 400px wide, the iframe is scaled to 90%.\n\tconst scale =\n\t\tisZoomOutMode && shouldZoom\n\t\t\t? calculateScale(\n\t\t\t\t\t{\n\t\t\t\t\t\tmaxWidth: 1000,\n\t\t\t\t\t\tminWidth: 400,\n\t\t\t\t\t\tmaxScale: 0.45,\n\t\t\t\t\t\tminScale: 0.9,\n\t\t\t\t\t},\n\t\t\t\t\tcontentWidth\n\t\t\t )\n\t\t\t: 1;\n\tconst frameSize = isZoomOutMode ? 100 : 0;\n\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tnode._load = () => {\n\t\t\tsetIframeDocument( node.contentDocument );\n\t\t};\n\t\tlet iFrameDocument;\n\t\t// Prevent the default browser action for files dropped outside of dropzones.\n\t\tfunction preventFileDropDefault( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tfunction onLoad() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tdocumentElement.classList.add( 'block-editor-iframe__html' );\n\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\n\t\t\tfor ( const compatStyle of getCompatibilityStyles() ) {\n\t\t\t\tif ( contentDocument.getElementById( compatStyle.id ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcontentDocument.head.appendChild(\n\t\t\t\t\tcompatStyle.cloneNode( true )\n\t\t\t\t);\n\n\t\t\t\tif ( ! isPreviewMode ) {\n\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`${ compatStyle.id } was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.`,\n\t\t\t\t\t\tcompatStyle\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'load', onLoad );\n\n\t\treturn () => {\n\t\t\tdelete node._load;\n\t\t\tnode.removeEventListener( 'load', onLoad );\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst disabledRef = useDisabled( { isDisabled: ! readonly } );\n\tconst bodyRef = useMergeRefs( [\n\t\tuseBubbleEvents( iframeDocument ),\n\t\tcontentRef,\n\t\tclearerRef,\n\t\twritingFlowRef,\n\t\tdisabledRef,\n\t] );\n\n\t// Correct doctype is required to enable rendering in standards\n\t// mode. Also preload the styles to avoid a flash of unstyled\n\t// content.\n\tconst html = `<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset=\"utf-8\">\n\t\t<script>window.frameElement._load()</script>\n\t\t<style>\n\t\t\thtml{\n\t\t\t\theight: auto !important;\n\t\t\t\tmin-height: 100%;\n\t\t\t}\n\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t\t/* Default background color in case zoom out mode background\n\t\t\t\tcolors the html element */\n\t\t\t\tbackground: white;\n\t\t\t}\n\t\t</style>\n\t\t${ styles }\n\t\t${ scripts }\n\t</head>\n\t<body>\n\t\t<script>document.currentScript.parentElement.remove()</script>\n\t</body>\n</html>`;\n\n\tconst [ src, cleanup ] = useMemo( () => {\n\t\tconst _src = URL.createObjectURL(\n\t\t\tnew window.Blob( [ html ], { type: 'text/html' } )\n\t\t);\n\t\treturn [ _src, () => URL.revokeObjectURL( _src ) ];\n\t}, [ html ] );\n\n\tuseEffect( () => cleanup, [ cleanup ] );\n\n\t// We need to counter the margin created by scaling the iframe. If the scale\n\t// is e.g. 0.45, then the top + bottom margin is 0.55 (1 - scale). Just the\n\t// top or bottom margin is 0.55 / 2 ((1 - scale) / 2).\n\tconst marginFromScaling = ( contentHeight * ( 1 - scale ) ) / 2;\n\n\tuseEffect( () => {\n\t\tif ( iframeDocument && scale !== 1 ) {\n\t\t\tiframeDocument.documentElement.style.transform = `scale( ${ scale } )`;\n\t\t\tiframeDocument.documentElement.style.marginTop = `${ frameSize }px`;\n\t\t\tiframeDocument.documentElement.style.marginBottom = `${\n\t\t\t\t-marginFromScaling * 2 + frameSize\n\t\t\t}px`;\n\t\t\treturn () => {\n\t\t\t\tiframeDocument.documentElement.style.transform = '';\n\t\t\t\tiframeDocument.documentElement.style.marginTop = '';\n\t\t\t\tiframeDocument.documentElement.style.marginBottom = '';\n\t\t\t};\n\t\t}\n\t}, [ scale, frameSize, marginFromScaling, iframeDocument ] );\n\n\t// Make sure to not render the before and after focusable div elements in view\n\t// mode. They're only needed to capture focus in edit mode.\n\tconst shouldRenderFocusCaptureElements = tabIndex >= 0 && ! isPreviewMode;\n\n\treturn (\n\t\t<>\n\t\t\t{ shouldRenderFocusCaptureElements && before }\n\t\t\t{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tstyle={ {\n\t\t\t\t\tborder: 0,\n\t\t\t\t\t...props.style,\n\t\t\t\t\theight: props.style?.height,\n\t\t\t\t\ttransition: 'all .3s',\n\t\t\t\t} }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards\n\t\t\t\t// mode. Also preload the styles to avoid a flash of unstyled\n\t\t\t\t// content.\n\t\t\t\tsrc={ src }\n\t\t\t\ttitle={ title }\n\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\tif ( props.onKeyDown ) {\n\t\t\t\t\t\tprops.onKeyDown( event );\n\t\t\t\t\t}\n\t\t\t\t\t// If the event originates from inside the iframe, it means\n\t\t\t\t\t// it bubbled through the portal, but only with React\n\t\t\t\t\t// events. We need to to bubble native events as well,\n\t\t\t\t\t// though by doing so we also trigger another React event,\n\t\t\t\t\t// so we need to stop the propagation of this event to avoid\n\t\t\t\t\t// duplication.\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.currentTarget.ownerDocument !==\n\t\t\t\t\t\tevent.target.ownerDocument\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tbubbleEvent(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\twindow.KeyboardEvent,\n\t\t\t\t\t\t\tevent.currentTarget\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t// We want to prevent React events from bubbling throught the iframe\n\t\t\t\t\t\t// we bubble these manually.\n\t\t\t\t\t\t/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */\n\t\t\t\t\t\t<body\n\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t'editor-styles-wrapper',\n\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t</body>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ shouldRenderFocusCaptureElements && after }\n\t\t</>\n\t);\n}\n\nfunction IframeIfReady( props, ref ) {\n\tconst isInitialised = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__internalIsInitialized,\n\t\t[]\n\t);\n\n\t// We shouldn't render the iframe until the editor settings are initialised.\n\t// The initial settings are needed to get the styles for the srcDoc, which\n\t// cannot be changed after the iframe is mounted. srcDoc is used to to set\n\t// the initial iframe HTML, which is required to avoid a flash of unstyled\n\t// content.\n\tif ( ! isInitialised ) {\n\t\treturn null;\n\t}\n\n\treturn <Iframe { ...props } forwardedRef={ ref } />;\n}\n\nexport default forwardRef( IframeIfReady );\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,QAAQ,EACRC,YAAY,EACZC,UAAU,EACVC,OAAO,EACPC,SAAS,QACH,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,iBAAiB,EACjBC,YAAY,EACZC,YAAY,EACZC,WAAW,QACL,oBAAoB;AAC3B,SAASC,2BAA2B,IAAIC,aAAa,QAAQ,uBAAuB;AACpF,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,cAAc,QAAQ,iBAAiB;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jCjF,KAAK,CAACwH,MAAM,CAACvC,aAAa,EACzB;QACDjF,KAAK,CAACyH,eAAe,CAAC,CAAC;QACvB1H,WAAW,CACVC,KAAK,EACLiC,MAAM,CAACyF,aAAa,EACpB1H,KAAK,CAACuH,aACP,CAAC;MACF;IACD;EAAG,GAEDlG,cAAc,IACfxC,YAAY;EACX;EACA;EACA;EACAqI,aAAA;IACCvE,GAAG,EAAGyD,OAAS;IACfuB,SAAS,EAAGhJ,UAAU,CACrB,2BAA2B,EAC3B,uBAAuB,EACvB,GAAG+E,WACJ;EAAG,GAEDM,qBAAqB,EACvBkD,aAAA,CAAC3H,aAAa;IAACqI,QAAQ,EAAGvG;EAAgB,GACvCiB,QACY,CACV,CAAC,EACPjB,cAAc,CAACG,eAChB,CACM,CAAC,EACPyF,gCAAgC,IAAIlD,KACrC,CAAC;AAEL;AAEA,SAAS8D,aAAaA,CAAEhF,KAAK,EAAEF,GAAG,EAAG;EACpC,MAAMmF,aAAa,GAAGtI,SAAS,CAC5ByD,MAAM,IACPA,MAAM,CAAEpD,gBAAiB,CAAC,CAACqD,WAAW,CAAC,CAAC,CAAC6E,uBAAuB,EACjE,EACD,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA,IAAK,CAAED,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,OAAOZ,aAAA,CAAC9E,MAAM;IAAA,GAAMS,KAAK;IAAGH,YAAY,EAAGC;EAAK,CAAE,CAAC;AACpD;AAEA,eAAe7D,UAAU,CAAE+I,aAAc,CAAC"}
|
|
1
|
+
{"version":3,"names":["classnames","useState","createPortal","forwardRef","useMemo","useEffect","__","useResizeObserver","useMergeRefs","useRefEffect","useDisabled","__experimentalStyleProvider","StyleProvider","useSelect","useBlockSelectionClearer","useWritingFlow","getCompatibilityStyles","store","blockEditorStore","bubbleEvent","event","Constructor","frame","init","key","contentDocument","defaultView","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","defaultPrevented","preventDefault","cancelled","dispatchEvent","useBubbleEvents","iframeDocument","frameElement","html","documentElement","eventTypes","handlers","name","prototype","Object","getPrototypeOf","constructorName","constructor","window","addEventListener","removeEventListener","Iframe","contentRef","children","tabIndex","scale","frameSize","readonly","forwardedRef","ref","title","props","resolvedAssets","isPreviewMode","select","getSettings","settings","__unstableResolvedAssets","__unstableIsPreviewMode","styles","scripts","setIframeDocument","bodyClasses","setBodyClasses","clearerRef","before","writingFlowRef","after","contentResizeListener","height","contentHeight","width","contentWidth","setRef","node","_load","iFrameDocument","preventFileDropDefault","onLoad","ownerDocument","initialIframeBodyClasses","Array","from","body","classList","add","concat","filter","startsWith","dir","compatStyle","getElementById","id","head","appendChild","cloneNode","console","warn","windowResizeRef","nodeWindow","onResize","setIframeWindowInnerHeight","innerHeight","iframeWindowInnerHeight","disabledRef","isDisabled","bodyRef","src","cleanup","_src","URL","createObjectURL","Blob","revokeObjectURL","_scale","bottomFrameSize","style","transform","marginTop","marginBottom","minHeight","Math","floor","remove","shouldRenderFocusCaptureElements","createElement","Fragment","border","transition","onKeyDown","currentTarget","target","stopPropagation","KeyboardEvent","className","document","IframeIfReady","isInitialised","__internalIsInitialized"],"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\nimport { getCompatibilityStyles } from './get-compatibility-styles';\nimport { store as blockEditorStore } from '../../store';\n\nfunction bubbleEvent( event, Constructor, frame ) {\n\tconst init = {};\n\n\tfor ( const key in event ) {\n\t\tinit[ key ] = event[ key ];\n\t}\n\n\t// Check if the event is a MouseEvent generated within the iframe.\n\t// If so, adjust the coordinates to be relative to the position of\n\t// the iframe. This ensures that components such as Draggable\n\t// receive coordinates relative to the window, instead of relative\n\t// to the iframe. Without this, the Draggable event handler would\n\t// result in components \"jumping\" position as soon as the user\n\t// drags over the iframe.\n\tif ( event instanceof frame.contentDocument.defaultView.MouseEvent ) {\n\t\tconst rect = frame.getBoundingClientRect();\n\t\tinit.clientX += rect.left;\n\t\tinit.clientY += rect.top;\n\t}\n\n\tconst newEvent = new Constructor( event.type, init );\n\tif ( init.defaultPrevented ) {\n\t\tnewEvent.preventDefault();\n\t}\n\tconst cancelled = ! frame.dispatchEvent( newEvent );\n\n\tif ( cancelled ) {\n\t\tevent.preventDefault();\n\t}\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} iframeDocument Document to attach listeners to.\n */\nfunction useBubbleEvents( iframeDocument ) {\n\treturn useRefEffect( () => {\n\t\tconst { defaultView } = iframeDocument;\n\t\tif ( ! defaultView ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { frameElement } = defaultView;\n\t\tconst html = iframeDocument.documentElement;\n\t\tconst eventTypes = [ 'dragover', 'mousemove' ];\n\t\tconst handlers = {};\n\t\tfor ( const name of eventTypes ) {\n\t\t\thandlers[ name ] = ( event ) => {\n\t\t\t\tconst prototype = Object.getPrototypeOf( event );\n\t\t\t\tconst constructorName = prototype.constructor.name;\n\t\t\t\tconst Constructor = window[ constructorName ];\n\t\t\t\tbubbleEvent( event, Constructor, frameElement );\n\t\t\t};\n\t\t\thtml.addEventListener( name, handlers[ name ] );\n\t\t}\n\n\t\treturn () => {\n\t\t\tfor ( const name of eventTypes ) {\n\t\t\t\thtml.removeEventListener( name, handlers[ name ] );\n\t\t\t}\n\t\t};\n\t} );\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\ttabIndex = 0,\n\tscale = 1,\n\tframeSize = 0,\n\treadonly,\n\tforwardedRef: ref,\n\ttitle = __( 'Editor canvas' ),\n\t...props\n} ) {\n\tconst { resolvedAssets, isPreviewMode } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\t\treturn {\n\t\t\tresolvedAssets: settings.__unstableResolvedAssets,\n\t\t\tisPreviewMode: settings.__unstableIsPreviewMode,\n\t\t};\n\t}, [] );\n\tconst { styles = '', scripts = '' } = resolvedAssets;\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [\n\t\tcontentResizeListener,\n\t\t{ height: contentHeight, width: contentWidth },\n\t] = useResizeObserver();\n\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tnode._load = () => {\n\t\t\tsetIframeDocument( node.contentDocument );\n\t\t};\n\t\tlet iFrameDocument;\n\t\t// Prevent the default browser action for files dropped outside of dropzones.\n\t\tfunction preventFileDropDefault( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tfunction onLoad() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { documentElement } = contentDocument;\n\t\t\t// Get any CSS classes the iframe document body may initially have\n\t\t\t// to re-apply them later together with the ones of the main document\n\t\t\t// body. This is necessary for some CSS classes for example the\n\t\t\t// `is-dark-theme` class added by useDarkThemeBodyClassName.\n\t\t\tconst initialIframeBodyClasses = Array.from(\n\t\t\t\tcontentDocument.body.classList\n\t\t\t);\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tdocumentElement.classList.add( 'block-editor-iframe__html' );\n\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList )\n\t\t\t\t\t.concat( initialIframeBodyClasses )\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t( name ) =>\n\t\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\t\tname === 'wp-embed-responsive' ||\n\t\t\t\t\t\t\tname === 'is-dark-theme'\n\t\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\n\t\t\tfor ( const compatStyle of getCompatibilityStyles() ) {\n\t\t\t\tif ( contentDocument.getElementById( compatStyle.id ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcontentDocument.head.appendChild(\n\t\t\t\t\tcompatStyle.cloneNode( true )\n\t\t\t\t);\n\n\t\t\t\tif ( ! isPreviewMode ) {\n\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`${ compatStyle.id } was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.`,\n\t\t\t\t\t\tcompatStyle\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'load', onLoad );\n\n\t\treturn () => {\n\t\t\tdelete node._load;\n\t\t\tnode.removeEventListener( 'load', onLoad );\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst windowResizeRef = useRefEffect( ( node ) => {\n\t\tconst nodeWindow = node.ownerDocument.defaultView;\n\n\t\tconst onResize = () => {\n\t\t\tsetIframeWindowInnerHeight( nodeWindow.innerHeight );\n\t\t};\n\t\tnodeWindow.addEventListener( 'resize', onResize );\n\t\treturn () => {\n\t\t\tnodeWindow.removeEventListener( 'resize', onResize );\n\t\t};\n\t}, [] );\n\n\tconst [ iframeWindowInnerHeight, setIframeWindowInnerHeight ] = useState();\n\n\tconst disabledRef = useDisabled( { isDisabled: ! readonly } );\n\tconst bodyRef = useMergeRefs( [\n\t\tuseBubbleEvents( iframeDocument ),\n\t\tcontentRef,\n\t\tclearerRef,\n\t\twritingFlowRef,\n\t\tdisabledRef,\n\t\twindowResizeRef,\n\t] );\n\n\t// Correct doctype is required to enable rendering in standards\n\t// mode. Also preload the styles to avoid a flash of unstyled\n\t// content.\n\tconst html = `<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset=\"utf-8\">\n\t\t<script>window.frameElement._load()</script>\n\t\t<style>\n\t\t\thtml{\n\t\t\t\theight: auto !important;\n\t\t\t\tmin-height: 100%;\n\t\t\t}\n\t\t\t/* Lowest specificity to not override global styles */\n\t\t\t:where(body) {\n\t\t\t\tmargin: 0;\n\t\t\t\t/* Default background color in case zoom out mode background\n\t\t\t\tcolors the html element */\n\t\t\t\tbackground-color: white;\n\t\t\t}\n\t\t</style>\n\t\t${ styles }\n\t\t${ scripts }\n\t</head>\n\t<body>\n\t\t<script>document.currentScript.parentElement.remove()</script>\n\t</body>\n</html>`;\n\n\tconst [ src, cleanup ] = useMemo( () => {\n\t\tconst _src = URL.createObjectURL(\n\t\t\tnew window.Blob( [ html ], { type: 'text/html' } )\n\t\t);\n\t\treturn [ _src, () => URL.revokeObjectURL( _src ) ];\n\t}, [ html ] );\n\n\tuseEffect( () => cleanup, [ cleanup ] );\n\n\tuseEffect( () => {\n\t\tif ( ! iframeDocument ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst _scale =\n\t\t\ttypeof scale === 'function'\n\t\t\t\t? scale( contentWidth, contentHeight )\n\t\t\t\t: scale;\n\n\t\tif ( _scale !== 1 ) {\n\t\t\t// Hack to get proper margins when scaling the iframe document.\n\t\t\tconst bottomFrameSize = frameSize - contentHeight * ( 1 - _scale );\n\n\t\t\tiframeDocument.body.classList.add( 'is-zoomed-out' );\n\n\t\t\tiframeDocument.documentElement.style.transform = `scale( ${ _scale } )`;\n\t\t\tiframeDocument.documentElement.style.marginTop = `${ frameSize }px`;\n\t\t\t// TODO: `marginBottom` doesn't work in Firefox. We need another way to do this.\n\t\t\tiframeDocument.documentElement.style.marginBottom = `${ bottomFrameSize }px`;\n\t\t\tif ( iframeWindowInnerHeight > contentHeight * _scale ) {\n\t\t\t\tiframeDocument.body.style.minHeight = `${ Math.floor(\n\t\t\t\t\t( iframeWindowInnerHeight - 2 * frameSize ) / _scale\n\t\t\t\t) }px`;\n\t\t\t}\n\n\t\t\treturn () => {\n\t\t\t\tiframeDocument.body.classList.remove( 'is-zoomed-out' );\n\t\t\t\tiframeDocument.documentElement.style.transform = '';\n\t\t\t\tiframeDocument.documentElement.style.marginTop = '';\n\t\t\t\tiframeDocument.documentElement.style.marginBottom = '';\n\t\t\t\tiframeDocument.body.style.minHeight = '';\n\t\t\t};\n\t\t}\n\t}, [\n\t\tscale,\n\t\tframeSize,\n\t\tiframeDocument,\n\t\tcontentHeight,\n\t\tiframeWindowInnerHeight,\n\t\tcontentWidth,\n\t] );\n\n\t// Make sure to not render the before and after focusable div elements in view\n\t// mode. They're only needed to capture focus in edit mode.\n\tconst shouldRenderFocusCaptureElements = tabIndex >= 0 && ! isPreviewMode;\n\n\treturn (\n\t\t<>\n\t\t\t{ shouldRenderFocusCaptureElements && before }\n\t\t\t{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tstyle={ {\n\t\t\t\t\tborder: 0,\n\t\t\t\t\t...props.style,\n\t\t\t\t\theight: props.style?.height,\n\t\t\t\t\ttransition: 'all .3s',\n\t\t\t\t} }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards\n\t\t\t\t// mode. Also preload the styles to avoid a flash of unstyled\n\t\t\t\t// content.\n\t\t\t\tsrc={ src }\n\t\t\t\ttitle={ title }\n\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\tif ( props.onKeyDown ) {\n\t\t\t\t\t\tprops.onKeyDown( event );\n\t\t\t\t\t}\n\t\t\t\t\t// If the event originates from inside the iframe, it means\n\t\t\t\t\t// it bubbled through the portal, but only with React\n\t\t\t\t\t// events. We need to to bubble native events as well,\n\t\t\t\t\t// though by doing so we also trigger another React event,\n\t\t\t\t\t// so we need to stop the propagation of this event to avoid\n\t\t\t\t\t// duplication.\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.currentTarget.ownerDocument !==\n\t\t\t\t\t\tevent.target.ownerDocument\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tbubbleEvent(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\twindow.KeyboardEvent,\n\t\t\t\t\t\t\tevent.currentTarget\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t// We want to prevent React events from bubbling throught the iframe\n\t\t\t\t\t\t// we bubble these manually.\n\t\t\t\t\t\t/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */\n\t\t\t\t\t\t<body\n\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t'editor-styles-wrapper',\n\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t</body>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ shouldRenderFocusCaptureElements && after }\n\t\t</>\n\t);\n}\n\nfunction IframeIfReady( props, ref ) {\n\tconst isInitialised = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__internalIsInitialized,\n\t\t[]\n\t);\n\n\t// We shouldn't render the iframe until the editor settings are initialised.\n\t// The initial settings are needed to get the styles for the srcDoc, which\n\t// cannot be changed after the iframe is mounted. srcDoc is used to to set\n\t// the initial iframe HTML, which is required to avoid a flash of unstyled\n\t// content.\n\tif ( ! isInitialised ) {\n\t\treturn null;\n\t}\n\n\treturn <Iframe { ...props } forwardedRef={ ref } />;\n}\n\nexport default forwardRef( IframeIfReady );\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,QAAQ,EACRC,YAAY,EACZC,UAAU,EACVC,OAAO,EACPC,SAAS,QACH,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,iBAAiB,EACjBC,YAAY,EACZC,YAAY,EACZC,WAAW,QACL,oBAAoB;AAC3B,SAASC,2BAA2B,IAAIC,aAAa,QAAQ,uBAAuB;AACpF,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,cAAc,QA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AChI,aAAa;IAAC0I,QAAQ,EAAG7G;EAAgB,GACvCiB,QACY,CACV,CAAC,EACPjB,cAAc,CAACG,eAChB,CACM,CAAC,EACP+F,gCAAgC,IAAIzD,KACrC,CAAC;AAEL;AAEA,SAASqE,aAAaA,CAAErF,KAAK,EAAEF,GAAG,EAAG;EACpC,MAAMwF,aAAa,GAAG3I,SAAS,CAC5BwD,MAAM,IACPA,MAAM,CAAEnD,gBAAiB,CAAC,CAACoD,WAAW,CAAC,CAAC,CAACmF,uBAAuB,EACjE,EACD,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA,IAAK,CAAED,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,OAAOZ,aAAA,CAACpF,MAAM;IAAA,GAAMU,KAAK;IAAGH,YAAY,EAAGC;EAAK,CAAE,CAAC;AACpD;AAEA,eAAe7D,UAAU,CAAEoJ,aAAc,CAAC"}
|
|
@@ -17,9 +17,8 @@ function PatternsExplorer({
|
|
|
17
17
|
rootClientId
|
|
18
18
|
}) {
|
|
19
19
|
const [searchValue, setSearchValue] = useState('');
|
|
20
|
-
const [patternSourceFilter, setPatternSourceFilter] = useState('all');
|
|
21
20
|
const [selectedCategory, setSelectedCategory] = useState(initialCategory?.name);
|
|
22
|
-
const patternCategories = usePatternCategories(rootClientId
|
|
21
|
+
const patternCategories = usePatternCategories(rootClientId);
|
|
23
22
|
return createElement("div", {
|
|
24
23
|
className: "block-editor-block-patterns-explorer"
|
|
25
24
|
}, createElement(PatternExplorerSidebar, {
|
|
@@ -27,14 +26,12 @@ function PatternsExplorer({
|
|
|
27
26
|
patternCategories: patternCategories,
|
|
28
27
|
onClickCategory: setSelectedCategory,
|
|
29
28
|
searchValue: searchValue,
|
|
30
|
-
setSearchValue: setSearchValue
|
|
31
|
-
patternSourceFilter: patternSourceFilter,
|
|
32
|
-
setPatternSourceFilter: setPatternSourceFilter
|
|
29
|
+
setSearchValue: setSearchValue
|
|
33
30
|
}), createElement(PatternList, {
|
|
34
31
|
searchValue: searchValue,
|
|
35
32
|
selectedCategory: selectedCategory,
|
|
36
33
|
patternCategories: patternCategories,
|
|
37
|
-
|
|
34
|
+
rootClientId: rootClientId
|
|
38
35
|
}));
|
|
39
36
|
}
|
|
40
37
|
function PatternsExplorerModal({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Modal","useState","__","PatternExplorerSidebar","PatternList","usePatternCategories","PatternsExplorer","initialCategory","rootClientId","searchValue","setSearchValue","
|
|
1
|
+
{"version":3,"names":["Modal","useState","__","PatternExplorerSidebar","PatternList","usePatternCategories","PatternsExplorer","initialCategory","rootClientId","searchValue","setSearchValue","selectedCategory","setSelectedCategory","name","patternCategories","createElement","className","onClickCategory","PatternsExplorerModal","onModalClose","restProps","title","onRequestClose","isFullScreen"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport PatternExplorerSidebar from './pattern-explorer-sidebar';\nimport PatternList from './pattern-list';\nimport { usePatternCategories } from '../block-patterns-tab/use-pattern-categories';\n\nfunction PatternsExplorer( { initialCategory, rootClientId } ) {\n\tconst [ searchValue, setSearchValue ] = useState( '' );\n\tconst [ selectedCategory, setSelectedCategory ] = useState(\n\t\tinitialCategory?.name\n\t);\n\n\tconst patternCategories = usePatternCategories( rootClientId );\n\n\treturn (\n\t\t<div className=\"block-editor-block-patterns-explorer\">\n\t\t\t<PatternExplorerSidebar\n\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\tonClickCategory={ setSelectedCategory }\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tsetSearchValue={ setSearchValue }\n\t\t\t/>\n\t\t\t<PatternList\n\t\t\t\tsearchValue={ searchValue }\n\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\tpatternCategories={ patternCategories }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nfunction PatternsExplorerModal( { onModalClose, ...restProps } ) {\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Patterns' ) }\n\t\t\tonRequestClose={ onModalClose }\n\t\t\tisFullScreen\n\t\t>\n\t\t\t<PatternsExplorer { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\nexport default PatternsExplorerModal;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,sBAAsB,MAAM,4BAA4B;AAC/D,OAAOC,WAAW,MAAM,gBAAgB;AACxC,SAASC,oBAAoB,QAAQ,8CAA8C;AAEnF,SAASC,gBAAgBA,CAAE;EAAEC,eAAe;EAAEC;AAAa,CAAC,EAAG;EAC9D,MAAM,CAAEC,WAAW,EAAEC,cAAc,CAAE,GAAGT,QAAQ,CAAE,EAAG,CAAC;EACtD,MAAM,CAAEU,gBAAgB,EAAEC,mBAAmB,CAAE,GAAGX,QAAQ,CACzDM,eAAe,EAAEM,IAClB,CAAC;EAED,MAAMC,iBAAiB,GAAGT,oBAAoB,CAAEG,YAAa,CAAC;EAE9D,OACCO,aAAA;IAAKC,SAAS,EAAC;EAAsC,GACpDD,aAAA,CAACZ,sBAAsB;IACtBQ,gBAAgB,EAAGA,gBAAkB;IACrCG,iBAAiB,EAAGA,iBAAmB;IACvCG,eAAe,EAAGL,mBAAqB;IACvCH,WAAW,EAAGA,WAAa;IAC3BC,cAAc,EAAGA;EAAgB,CACjC,CAAC,EACFK,aAAA,CAACX,WAAW;IACXK,WAAW,EAAGA,WAAa;IAC3BE,gBAAgB,EAAGA,gBAAkB;IACrCG,iBAAiB,EAAGA,iBAAmB;IACvCN,YAAY,EAAGA;EAAc,CAC7B,CACG,CAAC;AAER;AAEA,SAASU,qBAAqBA,CAAE;EAAEC,YAAY;EAAE,GAAGC;AAAU,CAAC,EAAG;EAChE,OACCL,aAAA,CAACf,KAAK;IACLqB,KAAK,EAAGnB,EAAE,CAAE,UAAW,CAAG;IAC1BoB,cAAc,EAAGH,YAAc;IAC/BI,YAAY;EAAA,GAEZR,aAAA,CAACT,gBAAgB;IAAA,GAAMc;EAAS,CAAI,CAC9B,CAAC;AAEV;AAEA,eAAeF,qBAAqB"}
|
|
@@ -36,11 +36,13 @@ function PatternsListHeader({
|
|
|
36
36
|
function PatternList({
|
|
37
37
|
searchValue,
|
|
38
38
|
selectedCategory,
|
|
39
|
-
patternCategories
|
|
39
|
+
patternCategories,
|
|
40
|
+
rootClientId
|
|
40
41
|
}) {
|
|
41
42
|
const container = useRef();
|
|
42
43
|
const debouncedSpeak = useDebounce(speak, 500);
|
|
43
44
|
const [destinationRootClientId, onInsertBlocks] = useInsertionPoint({
|
|
45
|
+
rootClientId,
|
|
44
46
|
shouldFocusBlock: true
|
|
45
47
|
});
|
|
46
48
|
const [patterns,, onClickPattern] = usePatternsState(onInsertBlocks, destinationRootClientId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useEffect","useRef","useState","_n","sprintf","useDebounce","__experimentalHeading","Heading","speak","BlockPatternsList","useInsertionPoint","usePatternsState","InserterListbox","searchItems","BlockPatternsPaging","usePatternsPaging","INSERTER_PATTERN_TYPES","allPatternsCategory","myPatternsCategory","PatternsListHeader","filterValue","filteredBlockPatternsLength","createElement","level","lineHeight","className","PatternList","searchValue","selectedCategory","patternCategories","container","debouncedSpeak","destinationRootClientId","onInsertBlocks","shouldFocusBlock","patterns","onClickPattern","registeredPatternCategories","map","patternCategory","name","filteredBlockPatterns","filteredPatterns","filter","pattern","type","user","hasKnownCategory","categories","some","category","includes","length","count","resultsFoundMessage","pagingProps","previousSearchValue","setPreviousSearchValue","changePage","hasItems","ref","Fragment","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","isDraggable"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/pattern-list.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect, useRef, useState } from '@wordpress/element';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useDebounce } from '@wordpress/compose';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport BlockPatternsList from '../../block-patterns-list';\nimport useInsertionPoint from '../hooks/use-insertion-point';\nimport usePatternsState from '../hooks/use-patterns-state';\nimport InserterListbox from '../../inserter-listbox';\nimport { searchItems } from '../search-items';\nimport BlockPatternsPaging from '../../block-patterns-paging';\nimport usePatternsPaging from '../hooks/use-patterns-paging';\nimport {\n\tINSERTER_PATTERN_TYPES,\n\tallPatternsCategory,\n\tmyPatternsCategory,\n} from '../block-patterns-tab/utils';\n\nfunction PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {\n\tif ( ! filterValue ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Heading\n\t\t\tlevel={ 2 }\n\t\t\tlineHeight={ '48px' }\n\t\t\tclassName=\"block-editor-block-patterns-explorer__search-results-count\"\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %d: number of patterns. */\n\t\t\t\t_n(\n\t\t\t\t\t'%d pattern found',\n\t\t\t\t\t'%d patterns found',\n\t\t\t\t\tfilteredBlockPatternsLength\n\t\t\t\t),\n\t\t\t\tfilteredBlockPatternsLength\n\t\t\t) }\n\t\t</Heading>\n\t);\n}\n\nfunction PatternList( {
|
|
1
|
+
{"version":3,"names":["useMemo","useEffect","useRef","useState","_n","sprintf","useDebounce","__experimentalHeading","Heading","speak","BlockPatternsList","useInsertionPoint","usePatternsState","InserterListbox","searchItems","BlockPatternsPaging","usePatternsPaging","INSERTER_PATTERN_TYPES","allPatternsCategory","myPatternsCategory","PatternsListHeader","filterValue","filteredBlockPatternsLength","createElement","level","lineHeight","className","PatternList","searchValue","selectedCategory","patternCategories","rootClientId","container","debouncedSpeak","destinationRootClientId","onInsertBlocks","shouldFocusBlock","patterns","onClickPattern","registeredPatternCategories","map","patternCategory","name","filteredBlockPatterns","filteredPatterns","filter","pattern","type","user","hasKnownCategory","categories","some","category","includes","length","count","resultsFoundMessage","pagingProps","previousSearchValue","setPreviousSearchValue","changePage","hasItems","ref","Fragment","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","isDraggable"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-explorer/pattern-list.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useEffect, useRef, useState } from '@wordpress/element';\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useDebounce } from '@wordpress/compose';\nimport { __experimentalHeading as Heading } from '@wordpress/components';\nimport { speak } from '@wordpress/a11y';\n\n/**\n * Internal dependencies\n */\nimport BlockPatternsList from '../../block-patterns-list';\nimport useInsertionPoint from '../hooks/use-insertion-point';\nimport usePatternsState from '../hooks/use-patterns-state';\nimport InserterListbox from '../../inserter-listbox';\nimport { searchItems } from '../search-items';\nimport BlockPatternsPaging from '../../block-patterns-paging';\nimport usePatternsPaging from '../hooks/use-patterns-paging';\nimport {\n\tINSERTER_PATTERN_TYPES,\n\tallPatternsCategory,\n\tmyPatternsCategory,\n} from '../block-patterns-tab/utils';\n\nfunction PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {\n\tif ( ! filterValue ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Heading\n\t\t\tlevel={ 2 }\n\t\t\tlineHeight={ '48px' }\n\t\t\tclassName=\"block-editor-block-patterns-explorer__search-results-count\"\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %d: number of patterns. */\n\t\t\t\t_n(\n\t\t\t\t\t'%d pattern found',\n\t\t\t\t\t'%d patterns found',\n\t\t\t\t\tfilteredBlockPatternsLength\n\t\t\t\t),\n\t\t\t\tfilteredBlockPatternsLength\n\t\t\t) }\n\t\t</Heading>\n\t);\n}\n\nfunction PatternList( {\n\tsearchValue,\n\tselectedCategory,\n\tpatternCategories,\n\trootClientId,\n} ) {\n\tconst container = useRef();\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ destinationRootClientId, onInsertBlocks ] = useInsertionPoint( {\n\t\trootClientId,\n\t\tshouldFocusBlock: true,\n\t} );\n\tconst [ patterns, , onClickPattern ] = usePatternsState(\n\t\tonInsertBlocks,\n\t\tdestinationRootClientId\n\t);\n\n\tconst registeredPatternCategories = useMemo(\n\t\t() =>\n\t\t\tpatternCategories.map(\n\t\t\t\t( patternCategory ) => patternCategory.name\n\t\t\t),\n\t\t[ patternCategories ]\n\t);\n\n\tconst filteredBlockPatterns = useMemo( () => {\n\t\tconst filteredPatterns = patterns.filter( ( pattern ) => {\n\t\t\tif ( selectedCategory === allPatternsCategory.name ) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tselectedCategory === myPatternsCategory.name &&\n\t\t\t\tpattern.type === INSERTER_PATTERN_TYPES.user\n\t\t\t) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif ( selectedCategory === 'uncategorized' ) {\n\t\t\t\tconst hasKnownCategory = pattern.categories.some(\n\t\t\t\t\t( category ) =>\n\t\t\t\t\t\tregisteredPatternCategories.includes( category )\n\t\t\t\t);\n\n\t\t\t\treturn ! pattern.categories?.length || ! hasKnownCategory;\n\t\t\t}\n\n\t\t\treturn pattern.categories?.includes( selectedCategory );\n\t\t} );\n\n\t\tif ( ! searchValue ) {\n\t\t\treturn filteredPatterns;\n\t\t}\n\n\t\treturn searchItems( filteredPatterns, searchValue );\n\t}, [\n\t\tsearchValue,\n\t\tpatterns,\n\t\tselectedCategory,\n\t\tregisteredPatternCategories,\n\t] );\n\n\t// Announce search results on change.\n\tuseEffect( () => {\n\t\tif ( ! searchValue ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockPatterns.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ searchValue, debouncedSpeak, filteredBlockPatterns.length ] );\n\n\tconst pagingProps = usePatternsPaging(\n\t\tfilteredBlockPatterns,\n\t\tselectedCategory,\n\t\tcontainer\n\t);\n\n\t// Reset page when search value changes.\n\tconst [ previousSearchValue, setPreviousSearchValue ] =\n\t\tuseState( searchValue );\n\tif ( searchValue !== previousSearchValue ) {\n\t\tsetPreviousSearchValue( searchValue );\n\t\tpagingProps.changePage( 1 );\n\t}\n\n\tconst hasItems = !! filteredBlockPatterns?.length;\n\treturn (\n\t\t<div\n\t\t\tclassName=\"block-editor-block-patterns-explorer__list\"\n\t\t\tref={ container }\n\t\t>\n\t\t\t<PatternsListHeader\n\t\t\t\tfilterValue={ searchValue }\n\t\t\t\tfilteredBlockPatternsLength={ filteredBlockPatterns.length }\n\t\t\t/>\n\n\t\t\t<InserterListbox>\n\t\t\t\t{ hasItems && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tshownPatterns={\n\t\t\t\t\t\t\t\tpagingProps.categoryPatternsAsyncList\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\t\t\tisDraggable={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BlockPatternsPaging { ...pagingProps } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</InserterListbox>\n\t\t</div>\n\t);\n}\n\nexport default PatternList;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AACzE,SAASC,EAAE,EAAEC,OA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EAAEmD,KAAM,CAAC,EACpDA,KACD,CAAC;IACDtB,cAAc,CAAEuB,mBAAoB,CAAC;EACtC,CAAC,EAAE,CAAE5B,WAAW,EAAEK,cAAc,EAAEU,qBAAqB,CAACW,MAAM,CAAG,CAAC;EAElE,MAAMG,WAAW,GAAGzC,iBAAiB,CACpC2B,qBAAqB,EACrBd,gBAAgB,EAChBG,SACD,CAAC;;EAED;EACA,MAAM,CAAE0B,mBAAmB,EAAEC,sBAAsB,CAAE,GACpDxD,QAAQ,CAAEyB,WAAY,CAAC;EACxB,IAAKA,WAAW,KAAK8B,mBAAmB,EAAG;IAC1CC,sBAAsB,CAAE/B,WAAY,CAAC;IACrC6B,WAAW,CAACG,UAAU,CAAE,CAAE,CAAC;EAC5B;EAEA,MAAMC,QAAQ,GAAG,CAAC,CAAElB,qBAAqB,EAAEW,MAAM;EACjD,OACC/B,aAAA;IACCG,SAAS,EAAC,4CAA4C;IACtDoC,GAAG,EAAG9B;EAAW,GAEjBT,aAAA,CAACH,kBAAkB;IAClBC,WAAW,EAAGO,WAAa;IAC3BN,2BAA2B,EAAGqB,qBAAqB,CAACW;EAAQ,CAC5D,CAAC,EAEF/B,aAAA,CAACV,eAAe,QACbgD,QAAQ,IACTtC,aAAA,CAAAwC,QAAA,QACCxC,aAAA,CAACb,iBAAiB;IACjBsD,aAAa,EACZP,WAAW,CAACQ,yBACZ;IACDC,aAAa,EAAGT,WAAW,CAACU,gBAAkB;IAC9C7B,cAAc,EAAGA,cAAgB;IACjC8B,WAAW,EAAG;EAAO,CACrB,CAAC,EACF7C,aAAA,CAACR,mBAAmB;IAAA,GAAM0C;EAAW,CAAI,CACxC,CAEa,CACb,CAAC;AAER;AAEA,eAAe9B,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useState","__","isRTL","useViewportMatch","__experimentalItemGroup","ItemGroup","__experimentalItem","Item","__experimentalHStack","HStack","FlexBlock","Button","Icon","chevronRight","chevronLeft","PatternsExplorerModal","MobileTabNavigation","PatternCategoryPreviews","usePatternCategories","BlockPatternsTab","onSelectCategory","selectedCategory","onInsert","rootClientId","showPatternsExplorer","setShowPatternsExplorer","categories","initialCategory","isMobile","createElement","Fragment","className","role","map","category","key","name","onClick","label","undefined","icon","variant","showTitlesAsTooltip","patternCategories","onModalClose"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalHStack as HStack,\n\tFlexBlock,\n\tButton,\n} from '@wordpress/components';\nimport { Icon, chevronRight, chevronLeft } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport PatternsExplorerModal from '../block-patterns-explorer';\nimport MobileTabNavigation from '../mobile-tab-navigation';\nimport { PatternCategoryPreviews } from './pattern-category-previews';\nimport { usePatternCategories } from './use-pattern-categories';\n\nfunction BlockPatternsTab( {\n\tonSelectCategory,\n\tselectedCategory,\n\tonInsert,\n\trootClientId,\n} ) {\n\tconst [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );\n\n\tconst categories = usePatternCategories( rootClientId );\n\n\tconst initialCategory = selectedCategory || categories[ 0 ];\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\treturn (\n\t\t<>\n\t\t\t{ ! isMobile && (\n\t\t\t\t<div className=\"block-editor-inserter__block-patterns-tabs-container\">\n\t\t\t\t\t<nav\n\t\t\t\t\t\taria-label={ __( 'Block pattern categories' ) }\n\t\t\t\t\t\tclassName=\"block-editor-inserter__block-patterns-tabs\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<ItemGroup role=\"list\">\n\t\t\t\t\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t\t\t\t\t<Item\n\t\t\t\t\t\t\t\t\trole=\"listitem\"\n\t\t\t\t\t\t\t\t\tkey={ category.name }\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tonSelectCategory( category )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\tcategory === selectedCategory\n\t\t\t\t\t\t\t\t\t\t\t? 'block-editor-inserter__patterns-category block-editor-inserter__patterns-selected-category'\n\t\t\t\t\t\t\t\t\t\t\t: 'block-editor-inserter__patterns-category'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\taria-label={ category.label }\n\t\t\t\t\t\t\t\t\taria-current={\n\t\t\t\t\t\t\t\t\t\tcategory === selectedCategory\n\t\t\t\t\t\t\t\t\t\t\t? 'true'\n\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<HStack>\n\t\t\t\t\t\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t\t\t\t\t\t{ category.label }\n\t\t\t\t\t\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tisRTL()\n\t\t\t\t\t\t\t\t\t\t\t\t\t? chevronLeft\n\t\t\t\t\t\t\t\t\t\t\t\t\t: chevronRight\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</HStack>\n\t\t\t\t\t\t\t\t</Item>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t<div role=\"listitem\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-explore-button\"\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tsetShowPatternsExplorer( true )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Explore all patterns' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t</nav>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ isMobile && (\n\t\t\t\t<MobileTabNavigation categories={ categories }>\n\t\t\t\t\t{ ( category ) => (\n\t\t\t\t\t\t<PatternCategoryPreviews\n\t\t\t\t\t\t\tkey={ category.name }\n\t\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t\t\tshowTitlesAsTooltip={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</MobileTabNavigation>\n\t\t\t) }\n\t\t\t{ showPatternsExplorer && (\n\t\t\t\t<PatternsExplorerModal\n\t\t\t\t\tinitialCategory={ initialCategory }\n\t\t\t\t\tpatternCategories={ categories }\n\t\t\t\t\tonModalClose={ () => setShowPatternsExplorer( false ) }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default BlockPatternsTab;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SACCC,uBAAuB,IAAIC,SAAS,EACpCC,kBAAkB,IAAIC,IAAI,EAC1BC,oBAAoB,IAAIC,MAAM,EAC9BC,SAAS,EACTC,MAAM,QACA,uBAAuB;AAC9B,SAASC,IAAI,EAAEC,YAAY,EAAEC,WAAW,QAAQ,kBAAkB;;AAElE;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,mBAAmB,MAAM,0BAA0B;AAC1D,SAASC,uBAAuB,QAAQ,6BAA6B;AACrE,SAASC,oBAAoB,QAAQ,0BAA0B;AAE/D,SAASC,gBAAgBA,CAAE;EAC1BC,gBAAgB;EAChBC,gBAAgB;EAChBC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,MAAM,CAAEC,oBAAoB,EAAEC,uBAAuB,CAAE,GAAGzB,QAAQ,CAAE,KAAM,CAAC;EAE3E,MAAM0B,UAAU,GAAGR,oBAAoB,CAAEK,YAAa,CAAC;EAEvD,MAAMI,eAAe,GAAGN,gBAAgB,IAAIK,UAAU,CAAE,CAAC,CAAE;EAC3D,MAAME,QAAQ,GAAGzB,gBAAgB,CAAE,QAAQ,EAAE,GAAI,CAAC;
|
|
1
|
+
{"version":3,"names":["useState","__","isRTL","useViewportMatch","__experimentalItemGroup","ItemGroup","__experimentalItem","Item","__experimentalHStack","HStack","FlexBlock","Button","Icon","chevronRight","chevronLeft","PatternsExplorerModal","MobileTabNavigation","PatternCategoryPreviews","usePatternCategories","BlockPatternsTab","onSelectCategory","selectedCategory","onInsert","rootClientId","showPatternsExplorer","setShowPatternsExplorer","categories","initialCategory","isMobile","createElement","Fragment","className","role","map","category","key","name","onClick","label","undefined","icon","variant","showTitlesAsTooltip","patternCategories","onModalClose"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\t__experimentalItemGroup as ItemGroup,\n\t__experimentalItem as Item,\n\t__experimentalHStack as HStack,\n\tFlexBlock,\n\tButton,\n} from '@wordpress/components';\nimport { Icon, chevronRight, chevronLeft } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport PatternsExplorerModal from '../block-patterns-explorer';\nimport MobileTabNavigation from '../mobile-tab-navigation';\nimport { PatternCategoryPreviews } from './pattern-category-previews';\nimport { usePatternCategories } from './use-pattern-categories';\n\nfunction BlockPatternsTab( {\n\tonSelectCategory,\n\tselectedCategory,\n\tonInsert,\n\trootClientId,\n} ) {\n\tconst [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );\n\n\tconst categories = usePatternCategories( rootClientId );\n\n\tconst initialCategory = selectedCategory || categories[ 0 ];\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\n\treturn (\n\t\t<>\n\t\t\t{ ! isMobile && (\n\t\t\t\t<div className=\"block-editor-inserter__block-patterns-tabs-container\">\n\t\t\t\t\t<nav\n\t\t\t\t\t\taria-label={ __( 'Block pattern categories' ) }\n\t\t\t\t\t\tclassName=\"block-editor-inserter__block-patterns-tabs\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<ItemGroup role=\"list\">\n\t\t\t\t\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t\t\t\t\t<Item\n\t\t\t\t\t\t\t\t\trole=\"listitem\"\n\t\t\t\t\t\t\t\t\tkey={ category.name }\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tonSelectCategory( category )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\t\tcategory === selectedCategory\n\t\t\t\t\t\t\t\t\t\t\t? 'block-editor-inserter__patterns-category block-editor-inserter__patterns-selected-category'\n\t\t\t\t\t\t\t\t\t\t\t: 'block-editor-inserter__patterns-category'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\taria-label={ category.label }\n\t\t\t\t\t\t\t\t\taria-current={\n\t\t\t\t\t\t\t\t\t\tcategory === selectedCategory\n\t\t\t\t\t\t\t\t\t\t\t? 'true'\n\t\t\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<HStack>\n\t\t\t\t\t\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t\t\t\t\t\t{ category.label }\n\t\t\t\t\t\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\t\t\t\t\t\tisRTL()\n\t\t\t\t\t\t\t\t\t\t\t\t\t? chevronLeft\n\t\t\t\t\t\t\t\t\t\t\t\t\t: chevronRight\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</HStack>\n\t\t\t\t\t\t\t\t</Item>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t<div role=\"listitem\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-explore-button\"\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\tsetShowPatternsExplorer( true )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Explore all patterns' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</ItemGroup>\n\t\t\t\t\t</nav>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ isMobile && (\n\t\t\t\t<MobileTabNavigation categories={ categories }>\n\t\t\t\t\t{ ( category ) => (\n\t\t\t\t\t\t<PatternCategoryPreviews\n\t\t\t\t\t\t\tkey={ category.name }\n\t\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t\t\tshowTitlesAsTooltip={ false }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</MobileTabNavigation>\n\t\t\t) }\n\t\t\t{ showPatternsExplorer && (\n\t\t\t\t<PatternsExplorerModal\n\t\t\t\t\tinitialCategory={ initialCategory }\n\t\t\t\t\tpatternCategories={ categories }\n\t\t\t\t\tonModalClose={ () => setShowPatternsExplorer( false ) }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default BlockPatternsTab;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SACCC,uBAAuB,IAAIC,SAAS,EACpCC,kBAAkB,IAAIC,IAAI,EAC1BC,oBAAoB,IAAIC,MAAM,EAC9BC,SAAS,EACTC,MAAM,QACA,uBAAuB;AAC9B,SAASC,IAAI,EAAEC,YAAY,EAAEC,WAAW,QAAQ,kBAAkB;;AAElE;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,mBAAmB,MAAM,0BAA0B;AAC1D,SAASC,uBAAuB,QAAQ,6BAA6B;AACrE,SAASC,oBAAoB,QAAQ,0BAA0B;AAE/D,SAASC,gBAAgBA,CAAE;EAC1BC,gBAAgB;EAChBC,gBAAgB;EAChBC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,MAAM,CAAEC,oBAAoB,EAAEC,uBAAuB,CAAE,GAAGzB,QAAQ,CAAE,KAAM,CAAC;EAE3E,MAAM0B,UAAU,GAAGR,oBAAoB,CAAEK,YAAa,CAAC;EAEvD,MAAMI,eAAe,GAAGN,gBAAgB,IAAIK,UAAU,CAAE,CAAC,CAAE;EAC3D,MAAME,QAAQ,GAAGzB,gBAAgB,CAAE,QAAQ,EAAE,GAAI,CAAC;EAElD,OACC0B,aAAA,CAAAC,QAAA,QACG,CAAEF,QAAQ,IACXC,aAAA;IAAKE,SAAS,EAAC;EAAsD,GACpEF,aAAA;IACC,cAAa5B,EAAE,CAAE,0BAA2B,CAAG;IAC/C8B,SAAS,EAAC;EAA4C,GAEt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AChCkB,YAAY,EAAGA,CAAA,KAAMnB,uBAAuB,CAAE,KAAM,CAAG;IACvDF,YAAY,EAAGA;EAAc,CAC7B,CAED,CAAC;AAEL;AAEA,eAAeJ,gBAAgB"}
|
package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js
CHANGED
|
@@ -10,6 +10,7 @@ import { focus } from '@wordpress/dom';
|
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
import { PatternCategoryPreviews } from './pattern-category-previews';
|
|
13
|
+
import { useZoomOut } from '../../../hooks/use-zoom-out';
|
|
13
14
|
export function PatternCategoryPreviewPanel({
|
|
14
15
|
rootClientId,
|
|
15
16
|
onInsert,
|
|
@@ -26,6 +27,10 @@ export function PatternCategoryPreviewPanel({
|
|
|
26
27
|
});
|
|
27
28
|
return () => clearTimeout(timeout);
|
|
28
29
|
}, [category]);
|
|
30
|
+
|
|
31
|
+
// Move to zoom out mode when this component is mounted
|
|
32
|
+
// and back to the previous mode when unmounted.
|
|
33
|
+
useZoomOut();
|
|
29
34
|
return createElement("div", {
|
|
30
35
|
ref: container,
|
|
31
36
|
className: "block-editor-inserter__patterns-category-dialog"
|
package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useRef","useEffect","focus","PatternCategoryPreviews","PatternCategoryPreviewPanel","rootClientId","onInsert","onHover","category","showTitlesAsTooltip","patternFilter","container","timeout","setTimeout","firstTabbable","tabbable","find","current","clearTimeout","createElement","ref","className","key","name"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\n\nimport { focus } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\n\nimport { PatternCategoryPreviews } from './pattern-category-previews';\n\nexport function PatternCategoryPreviewPanel( {\n\trootClientId,\n\tonInsert,\n\tonHover,\n\tcategory,\n\tshowTitlesAsTooltip,\n\tpatternFilter,\n} ) {\n\tconst container = useRef();\n\n\tuseEffect( () => {\n\t\tconst timeout = setTimeout( () => {\n\t\t\tconst [ firstTabbable ] = focus.tabbable.find( container.current );\n\t\t\tfirstTabbable?.focus();\n\t\t} );\n\t\treturn () => clearTimeout( timeout );\n\t}, [ category ] );\n\n\treturn (\n\t\t<div\n\t\t\tref={ container }\n\t\t\tclassName=\"block-editor-inserter__patterns-category-dialog\"\n\t\t>\n\t\t\t<PatternCategoryPreviews\n\t\t\t\tkey={ category.name }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tonInsert={ onInsert }\n\t\t\t\tonHover={ onHover }\n\t\t\t\tcategory={ category }\n\t\t\t\tshowTitlesAsTooltip={ showTitlesAsTooltip }\n\t\t\t\tpatternFilter={ patternFilter }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,SAAS,QAAQ,oBAAoB;AAEtD,SAASC,KAAK,QAAQ,gBAAgB;;AAEtC;AACA;AACA;;AAEA,SAASC,uBAAuB,QAAQ,6BAA6B;
|
|
1
|
+
{"version":3,"names":["useRef","useEffect","focus","PatternCategoryPreviews","useZoomOut","PatternCategoryPreviewPanel","rootClientId","onInsert","onHover","category","showTitlesAsTooltip","patternFilter","container","timeout","setTimeout","firstTabbable","tabbable","find","current","clearTimeout","createElement","ref","className","key","name"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\n\nimport { focus } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\n\nimport { PatternCategoryPreviews } from './pattern-category-previews';\nimport { useZoomOut } from '../../../hooks/use-zoom-out';\n\nexport function PatternCategoryPreviewPanel( {\n\trootClientId,\n\tonInsert,\n\tonHover,\n\tcategory,\n\tshowTitlesAsTooltip,\n\tpatternFilter,\n} ) {\n\tconst container = useRef();\n\n\tuseEffect( () => {\n\t\tconst timeout = setTimeout( () => {\n\t\t\tconst [ firstTabbable ] = focus.tabbable.find( container.current );\n\t\t\tfirstTabbable?.focus();\n\t\t} );\n\t\treturn () => clearTimeout( timeout );\n\t}, [ category ] );\n\n\t// Move to zoom out mode when this component is mounted\n\t// and back to the previous mode when unmounted.\n\tuseZoomOut();\n\n\treturn (\n\t\t<div\n\t\t\tref={ container }\n\t\t\tclassName=\"block-editor-inserter__patterns-category-dialog\"\n\t\t>\n\t\t\t<PatternCategoryPreviews\n\t\t\t\tkey={ category.name }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\tonInsert={ onInsert }\n\t\t\t\tonHover={ onHover }\n\t\t\t\tcategory={ category }\n\t\t\t\tshowTitlesAsTooltip={ showTitlesAsTooltip }\n\t\t\t\tpatternFilter={ patternFilter }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,SAAS,QAAQ,oBAAoB;AAEtD,SAASC,KAAK,QAAQ,gBAAgB;;AAEtC;AACA;AACA;;AAEA,SAASC,uBAAuB,QAAQ,6BAA6B;AACrE,SAASC,UAAU,QAAQ,6BAA6B;AAExD,OAAO,SAASC,2BAA2BA,CAAE;EAC5CC,YAAY;EACZC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,mBAAmB;EACnBC;AACD,CAAC,EAAG;EACH,MAAMC,SAAS,GAAGZ,MAAM,CAAC,CAAC;EAE1BC,SAAS,CAAE,MAAM;IAChB,MAAMY,OAAO,GAAGC,UAAU,CAAE,MAAM;MACjC,MAAM,CAAEC,aAAa,CAAE,GAAGb,KAAK,CAACc,QAAQ,CAACC,IAAI,CAAEL,SAAS,CAACM,OAAQ,CAAC;MAClEH,aAAa,EAAEb,KAAK,CAAC,CAAC;IACvB,CAAE,CAAC;IACH,OAAO,MAAMiB,YAAY,CAAEN,OAAQ,CAAC;EACrC,CAAC,EAAE,CAAEJ,QAAQ,CAAG,CAAC;;EAEjB;EACA;EACAL,UAAU,CAAC,CAAC;EAEZ,OACCgB,aAAA;IACCC,GAAG,EAAGT,SAAW;IACjBU,SAAS,EAAC;EAAiD,GAE3DF,aAAA,CAACjB,uBAAuB;IACvBoB,GAAG,EAAGd,QAAQ,CAACe,IAAM;IACrBlB,YAAY,EAAGA,YAAc;IAC7BC,QAAQ,EAAGA,QAAU;IACrBC,OAAO,EAAGA,OAAS;IACnBC,QAAQ,EAAGA,QAAU;IACrBC,mBAAmB,EAAGA,mBAAqB;IAC3CC,aAAa,EAAGA;EAAe,CAC/B,CACG,CAAC;AAER"}
|
|
@@ -19,6 +19,7 @@ function InserterLibrary({
|
|
|
19
19
|
showMostUsedBlocks = false,
|
|
20
20
|
__experimentalInsertionIndex,
|
|
21
21
|
__experimentalFilterValue,
|
|
22
|
+
__experimentalOnPatternCategorySelection,
|
|
22
23
|
onSelect = noop,
|
|
23
24
|
shouldFocusBlock = false
|
|
24
25
|
}, ref) {
|
|
@@ -42,6 +43,7 @@ function InserterLibrary({
|
|
|
42
43
|
showMostUsedBlocks: showMostUsedBlocks,
|
|
43
44
|
__experimentalInsertionIndex: __experimentalInsertionIndex,
|
|
44
45
|
__experimentalFilterValue: __experimentalFilterValue,
|
|
46
|
+
__experimentalOnPatternCategorySelection: __experimentalOnPatternCategorySelection,
|
|
45
47
|
shouldFocusBlock: shouldFocusBlock,
|
|
46
48
|
ref: ref
|
|
47
49
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","forwardRef","InserterMenu","store","blockEditorStore","noop","InserterLibrary","rootClientId","clientId","isAppender","showInserterHelpPanel","showMostUsedBlocks","__experimentalInsertionIndex","__experimentalFilterValue","onSelect","shouldFocusBlock","ref","destinationRootClientId","select","getBlockRootClientId","_rootClientId","undefined","createElement"],"sources":["@wordpress/block-editor/src/components/inserter/library.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\n\nfunction InserterLibrary(\n\t{\n\t\trootClientId,\n\t\tclientId,\n\t\tisAppender,\n\t\tshowInserterHelpPanel,\n\t\tshowMostUsedBlocks = false,\n\t\t__experimentalInsertionIndex,\n\t\t__experimentalFilterValue,\n\t\tonSelect = noop,\n\t\tshouldFocusBlock = false,\n\t},\n\tref\n) {\n\tconst { destinationRootClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId } = select( blockEditorStore );\n\t\t\tconst _rootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\t\t\treturn {\n\t\t\t\tdestinationRootClientId: _rootClientId,\n\t\t\t};\n\t\t},\n\t\t[ clientId, rootClientId ]\n\t);\n\n\treturn (\n\t\t<InserterMenu\n\t\t\tonSelect={ onSelect }\n\t\t\trootClientId={ destinationRootClientId }\n\t\t\tclientId={ clientId }\n\t\t\tisAppender={ isAppender }\n\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\tshowMostUsedBlocks={ showMostUsedBlocks }\n\t\t\t__experimentalInsertionIndex={ __experimentalInsertionIndex }\n\t\t\t__experimentalFilterValue={ __experimentalFilterValue }\n\t\t\tshouldFocusBlock={ shouldFocusBlock }\n\t\t\tref={ ref }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( InserterLibrary );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,UAAU,QAAQ,oBAAoB;;AAE/C;AACA;AACA;AACA,OAAOC,YAAY,MAAM,QAAQ;AACjC,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAEvD,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,SAASC,eAAeA,CACvB;EACCC,YAAY;EACZC,QAAQ;EACRC,UAAU;EACVC,qBAAqB;EACrBC,kBAAkB,GAAG,KAAK;EAC1BC,4BAA4B;EAC5BC,yBAAyB;EACzBC,QAAQ,
|
|
1
|
+
{"version":3,"names":["useSelect","forwardRef","InserterMenu","store","blockEditorStore","noop","InserterLibrary","rootClientId","clientId","isAppender","showInserterHelpPanel","showMostUsedBlocks","__experimentalInsertionIndex","__experimentalFilterValue","__experimentalOnPatternCategorySelection","onSelect","shouldFocusBlock","ref","destinationRootClientId","select","getBlockRootClientId","_rootClientId","undefined","createElement"],"sources":["@wordpress/block-editor/src/components/inserter/library.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InserterMenu from './menu';\nimport { store as blockEditorStore } from '../../store';\n\nconst noop = () => {};\n\nfunction InserterLibrary(\n\t{\n\t\trootClientId,\n\t\tclientId,\n\t\tisAppender,\n\t\tshowInserterHelpPanel,\n\t\tshowMostUsedBlocks = false,\n\t\t__experimentalInsertionIndex,\n\t\t__experimentalFilterValue,\n\t\t__experimentalOnPatternCategorySelection,\n\t\tonSelect = noop,\n\t\tshouldFocusBlock = false,\n\t},\n\tref\n) {\n\tconst { destinationRootClientId } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId } = select( blockEditorStore );\n\t\t\tconst _rootClientId =\n\t\t\t\trootClientId || getBlockRootClientId( clientId ) || undefined;\n\t\t\treturn {\n\t\t\t\tdestinationRootClientId: _rootClientId,\n\t\t\t};\n\t\t},\n\t\t[ clientId, rootClientId ]\n\t);\n\n\treturn (\n\t\t<InserterMenu\n\t\t\tonSelect={ onSelect }\n\t\t\trootClientId={ destinationRootClientId }\n\t\t\tclientId={ clientId }\n\t\t\tisAppender={ isAppender }\n\t\t\tshowInserterHelpPanel={ showInserterHelpPanel }\n\t\t\tshowMostUsedBlocks={ showMostUsedBlocks }\n\t\t\t__experimentalInsertionIndex={ __experimentalInsertionIndex }\n\t\t\t__experimentalFilterValue={ __experimentalFilterValue }\n\t\t\t__experimentalOnPatternCategorySelection={\n\t\t\t\t__experimentalOnPatternCategorySelection\n\t\t\t}\n\t\t\tshouldFocusBlock={ shouldFocusBlock }\n\t\t\tref={ ref }\n\t\t/>\n\t);\n}\n\nexport default forwardRef( InserterLibrary );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,UAAU,QAAQ,oBAAoB;;AAE/C;AACA;AACA;AACA,OAAOC,YAAY,MAAM,QAAQ;AACjC,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AAEvD,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,SAASC,eAAeA,CACvB;EACCC,YAAY;EACZC,QAAQ;EACRC,UAAU;EACVC,qBAAqB;EACrBC,kBAAkB,GAAG,KAAK;EAC1BC,4BAA4B;EAC5BC,yBAAyB;EACzBC,wCAAwC;EACxCC,QAAQ,GAAGV,IAAI;EACfW,gBAAgB,GAAG;AACpB,CAAC,EACDC,GAAG,EACF;EACD,MAAM;IAAEC;EAAwB,CAAC,GAAGlB,SAAS,CAC1CmB,MAAM,IAAM;IACb,MAAM;MAAEC;IAAqB,CAAC,GAAGD,MAAM,CAAEf,gBAAiB,CAAC;IAC3D,MAAMiB,aAAa,GAClBd,YAAY,IAAIa,oBAAoB,CAAEZ,QAAS,CAAC,IAAIc,SAAS;IAC9D,OAAO;MACNJ,uBAAuB,EAAEG;IAC1B,CAAC;EACF,CAAC,EACD,CAAEb,QAAQ,EAAED,YAAY,CACzB,CAAC;EAED,OACCgB,aAAA,CAACrB,YAAY;IACZa,QAAQ,EAAGA,QAAU;IACrBR,YAAY,EAAGW,uBAAyB;IACxCV,QAAQ,EAAGA,QAAU;IACrBC,UAAU,EAAGA,UAAY;IACzBC,qBAAqB,EAAGA,qBAAuB;IAC/CC,kBAAkB,EAAGA,kBAAoB;IACzCC,4BAA4B,EAAGA,4BAA8B;IAC7DC,yBAAyB,EAAGA,yBAA2B;IACvDC,wCAAwC,EACvCA,wCACA;IACDE,gBAAgB,EAAGA,gBAAkB;IACrCC,GAAG,EAAGA;EAAK,CACX,CAAC;AAEJ;AAEA,eAAehB,UAAU,CAAEK,eAAgB,CAAC"}
|
|
@@ -27,6 +27,7 @@ import InserterSearchResults from './search-results';
|
|
|
27
27
|
import useInsertionPoint from './hooks/use-insertion-point';
|
|
28
28
|
import InserterTabs from './tabs';
|
|
29
29
|
import { store as blockEditorStore } from '../../store';
|
|
30
|
+
const NOOP = () => {};
|
|
30
31
|
function InserterMenu({
|
|
31
32
|
rootClientId,
|
|
32
33
|
clientId,
|
|
@@ -36,7 +37,8 @@ function InserterMenu({
|
|
|
36
37
|
showInserterHelpPanel,
|
|
37
38
|
showMostUsedBlocks,
|
|
38
39
|
__experimentalFilterValue = '',
|
|
39
|
-
shouldFocusBlock = true
|
|
40
|
+
shouldFocusBlock = true,
|
|
41
|
+
__experimentalOnPatternCategorySelection = NOOP
|
|
40
42
|
}, ref) {
|
|
41
43
|
const [filterValue, setFilterValue, delayedFilterValue] = useDebouncedInput(__experimentalFilterValue);
|
|
42
44
|
const [hoveredItem, setHoveredItem] = useState(null);
|
|
@@ -52,21 +54,17 @@ function InserterMenu({
|
|
|
52
54
|
shouldFocusBlock
|
|
53
55
|
});
|
|
54
56
|
const {
|
|
55
|
-
isZoomOutMode,
|
|
56
57
|
showPatterns
|
|
57
58
|
} = useSelect(select => {
|
|
58
59
|
const {
|
|
59
|
-
hasAllowedPatterns
|
|
60
|
-
__unstableGetEditorMode
|
|
60
|
+
hasAllowedPatterns
|
|
61
61
|
} = unlock(select(blockEditorStore));
|
|
62
62
|
return {
|
|
63
|
-
isZoomOutMode: __unstableGetEditorMode() === 'zoom-out',
|
|
64
63
|
showPatterns: hasAllowedPatterns(destinationRootClientId)
|
|
65
64
|
};
|
|
66
65
|
}, [destinationRootClientId]);
|
|
67
66
|
const mediaCategories = useMediaCategories(destinationRootClientId);
|
|
68
|
-
const showMedia = mediaCategories.length > 0
|
|
69
|
-
const showBlocks = !isZoomOutMode;
|
|
67
|
+
const showMedia = mediaCategories.length > 0;
|
|
70
68
|
const onInsert = useCallback((blocks, meta, shouldForceFocusBlock) => {
|
|
71
69
|
onInsertBlocks(blocks, meta, shouldForceFocusBlock);
|
|
72
70
|
onSelect();
|
|
@@ -84,10 +82,14 @@ function InserterMenu({
|
|
|
84
82
|
const onHoverPattern = useCallback(item => {
|
|
85
83
|
onToggleInsertionPoint(!!item);
|
|
86
84
|
}, [onToggleInsertionPoint]);
|
|
85
|
+
const isZoomedOutViewExperimentEnabled = window?.__experimentalEnableZoomedOutView;
|
|
87
86
|
const onClickPatternCategory = useCallback((patternCategory, filter) => {
|
|
88
87
|
setSelectedPatternCategory(patternCategory);
|
|
89
88
|
setPatternFilter(filter);
|
|
90
|
-
|
|
89
|
+
if (isZoomedOutViewExperimentEnabled) {
|
|
90
|
+
__experimentalOnPatternCategorySelection();
|
|
91
|
+
}
|
|
92
|
+
}, [setSelectedPatternCategory, __experimentalOnPatternCategorySelection]);
|
|
91
93
|
const blocksTab = useMemo(() => createElement(Fragment, null, createElement("div", {
|
|
92
94
|
className: "block-editor-inserter__block-list"
|
|
93
95
|
}, createElement(BlockTypesTab, {
|
|
@@ -162,15 +164,13 @@ function InserterMenu({
|
|
|
162
164
|
isAppender: isAppender,
|
|
163
165
|
__experimentalInsertionIndex: __experimentalInsertionIndex,
|
|
164
166
|
showBlockDirectory: true,
|
|
165
|
-
showBlocks: showBlocks,
|
|
166
167
|
shouldFocusBlock: shouldFocusBlock
|
|
167
168
|
})), showAsTabs && createElement(InserterTabs, {
|
|
168
|
-
showBlocks: showBlocks,
|
|
169
169
|
showPatterns: showPatterns,
|
|
170
170
|
showMedia: showMedia,
|
|
171
171
|
onSelect: handleSetSelectedTab,
|
|
172
172
|
tabsContents: inserterTabsContents
|
|
173
|
-
}), !delayedFilterValue && !showAsTabs &&
|
|
173
|
+
}), !delayedFilterValue && !showAsTabs && createElement("div", {
|
|
174
174
|
className: "block-editor-inserter__no-tab-container"
|
|
175
175
|
}, blocksTab)), showMediaPanel && createElement(MediaCategoryDialog, {
|
|
176
176
|
rootClientId: destinationRootClientId,
|