@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
|
@@ -16,7 +16,6 @@ var _blockSelectionClearer = require("../block-selection-clearer");
|
|
|
16
16
|
var _writingFlow = require("../writing-flow");
|
|
17
17
|
var _getCompatibilityStyles = require("./get-compatibility-styles");
|
|
18
18
|
var _store = require("../../store");
|
|
19
|
-
var _calculateScale = _interopRequireDefault(require("../../utils/calculate-scale"));
|
|
20
19
|
/**
|
|
21
20
|
* External dependencies
|
|
22
21
|
*/
|
|
@@ -101,7 +100,8 @@ function Iframe({
|
|
|
101
100
|
contentRef,
|
|
102
101
|
children,
|
|
103
102
|
tabIndex = 0,
|
|
104
|
-
|
|
103
|
+
scale = 1,
|
|
104
|
+
frameSize = 0,
|
|
105
105
|
readonly,
|
|
106
106
|
forwardedRef: ref,
|
|
107
107
|
title = (0, _i18n.__)('Editor canvas'),
|
|
@@ -109,18 +109,15 @@ function Iframe({
|
|
|
109
109
|
}) {
|
|
110
110
|
const {
|
|
111
111
|
resolvedAssets,
|
|
112
|
-
isPreviewMode
|
|
113
|
-
isZoomOutMode
|
|
112
|
+
isPreviewMode
|
|
114
113
|
} = (0, _data.useSelect)(select => {
|
|
115
114
|
const {
|
|
116
|
-
getSettings
|
|
117
|
-
__unstableGetEditorMode
|
|
115
|
+
getSettings
|
|
118
116
|
} = select(_store.store);
|
|
119
117
|
const settings = getSettings();
|
|
120
118
|
return {
|
|
121
119
|
resolvedAssets: settings.__unstableResolvedAssets,
|
|
122
|
-
isPreviewMode: settings.__unstableIsPreviewMode
|
|
123
|
-
isZoomOutMode: __unstableGetEditorMode() === 'zoom-out'
|
|
120
|
+
isPreviewMode: settings.__unstableIsPreviewMode
|
|
124
121
|
};
|
|
125
122
|
}, []);
|
|
126
123
|
const {
|
|
@@ -135,18 +132,6 @@ function Iframe({
|
|
|
135
132
|
height: contentHeight,
|
|
136
133
|
width: contentWidth
|
|
137
134
|
}] = (0, _compose.useResizeObserver)();
|
|
138
|
-
|
|
139
|
-
// When zoom-out mode is enabled, the iframe is scaled down to fit the
|
|
140
|
-
// content within the viewport.
|
|
141
|
-
// At 1000px wide, the iframe is scaled to 45%.
|
|
142
|
-
// At 400px wide, the iframe is scaled to 90%.
|
|
143
|
-
const scale = isZoomOutMode && shouldZoom ? (0, _calculateScale.default)({
|
|
144
|
-
maxWidth: 1000,
|
|
145
|
-
minWidth: 400,
|
|
146
|
-
maxScale: 0.45,
|
|
147
|
-
minScale: 0.9
|
|
148
|
-
}, contentWidth) : 1;
|
|
149
|
-
const frameSize = isZoomOutMode ? 100 : 0;
|
|
150
135
|
const setRef = (0, _compose.useRefEffect)(node => {
|
|
151
136
|
node._load = () => {
|
|
152
137
|
setIframeDocument(node.contentDocument);
|
|
@@ -164,6 +149,11 @@ function Iframe({
|
|
|
164
149
|
const {
|
|
165
150
|
documentElement
|
|
166
151
|
} = contentDocument;
|
|
152
|
+
// Get any CSS classes the iframe document body may initially have
|
|
153
|
+
// to re-apply them later together with the ones of the main document
|
|
154
|
+
// body. This is necessary for some CSS classes for example the
|
|
155
|
+
// `is-dark-theme` class added by useDarkThemeBodyClassName.
|
|
156
|
+
const initialIframeBodyClasses = Array.from(contentDocument.body.classList);
|
|
167
157
|
iFrameDocument = contentDocument;
|
|
168
158
|
documentElement.classList.add('block-editor-iframe__html');
|
|
169
159
|
clearerRef(documentElement);
|
|
@@ -171,7 +161,7 @@ function Iframe({
|
|
|
171
161
|
// Ideally ALL classes that are added through get_body_class should
|
|
172
162
|
// be added in the editor too, which we'll somehow have to get from
|
|
173
163
|
// the server in the future (which will run the PHP filters).
|
|
174
|
-
setBodyClasses(Array.from(ownerDocument.body.classList).filter(name => name.startsWith('admin-color-') || name.startsWith('post-type-') || name === 'wp-embed-responsive'));
|
|
164
|
+
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'));
|
|
175
165
|
contentDocument.dir = ownerDocument.dir;
|
|
176
166
|
for (const compatStyle of (0, _getCompatibilityStyles.getCompatibilityStyles)()) {
|
|
177
167
|
if (contentDocument.getElementById(compatStyle.id)) {
|
|
@@ -194,10 +184,21 @@ function Iframe({
|
|
|
194
184
|
iFrameDocument?.removeEventListener('drop', preventFileDropDefault);
|
|
195
185
|
};
|
|
196
186
|
}, []);
|
|
187
|
+
const windowResizeRef = (0, _compose.useRefEffect)(node => {
|
|
188
|
+
const nodeWindow = node.ownerDocument.defaultView;
|
|
189
|
+
const onResize = () => {
|
|
190
|
+
setIframeWindowInnerHeight(nodeWindow.innerHeight);
|
|
191
|
+
};
|
|
192
|
+
nodeWindow.addEventListener('resize', onResize);
|
|
193
|
+
return () => {
|
|
194
|
+
nodeWindow.removeEventListener('resize', onResize);
|
|
195
|
+
};
|
|
196
|
+
}, []);
|
|
197
|
+
const [iframeWindowInnerHeight, setIframeWindowInnerHeight] = (0, _element.useState)();
|
|
197
198
|
const disabledRef = (0, _compose.useDisabled)({
|
|
198
199
|
isDisabled: !readonly
|
|
199
200
|
});
|
|
200
|
-
const bodyRef = (0, _compose.useMergeRefs)([useBubbleEvents(iframeDocument), contentRef, clearerRef, writingFlowRef, disabledRef]);
|
|
201
|
+
const bodyRef = (0, _compose.useMergeRefs)([useBubbleEvents(iframeDocument), contentRef, clearerRef, writingFlowRef, disabledRef, windowResizeRef]);
|
|
201
202
|
|
|
202
203
|
// Correct doctype is required to enable rendering in standards
|
|
203
204
|
// mode. Also preload the styles to avoid a flash of unstyled
|
|
@@ -212,12 +213,12 @@ function Iframe({
|
|
|
212
213
|
height: auto !important;
|
|
213
214
|
min-height: 100%;
|
|
214
215
|
}
|
|
215
|
-
|
|
216
|
-
body {
|
|
216
|
+
/* Lowest specificity to not override global styles */
|
|
217
|
+
:where(body) {
|
|
217
218
|
margin: 0;
|
|
218
219
|
/* Default background color in case zoom out mode background
|
|
219
220
|
colors the html element */
|
|
220
|
-
background: white;
|
|
221
|
+
background-color: white;
|
|
221
222
|
}
|
|
222
223
|
</style>
|
|
223
224
|
${styles}
|
|
@@ -234,23 +235,31 @@ function Iframe({
|
|
|
234
235
|
return [_src, () => URL.revokeObjectURL(_src)];
|
|
235
236
|
}, [html]);
|
|
236
237
|
(0, _element.useEffect)(() => cleanup, [cleanup]);
|
|
237
|
-
|
|
238
|
-
// We need to counter the margin created by scaling the iframe. If the scale
|
|
239
|
-
// is e.g. 0.45, then the top + bottom margin is 0.55 (1 - scale). Just the
|
|
240
|
-
// top or bottom margin is 0.55 / 2 ((1 - scale) / 2).
|
|
241
|
-
const marginFromScaling = contentHeight * (1 - scale) / 2;
|
|
242
238
|
(0, _element.useEffect)(() => {
|
|
243
|
-
if (iframeDocument
|
|
244
|
-
|
|
239
|
+
if (!iframeDocument) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
const _scale = typeof scale === 'function' ? scale(contentWidth, contentHeight) : scale;
|
|
243
|
+
if (_scale !== 1) {
|
|
244
|
+
// Hack to get proper margins when scaling the iframe document.
|
|
245
|
+
const bottomFrameSize = frameSize - contentHeight * (1 - _scale);
|
|
246
|
+
iframeDocument.body.classList.add('is-zoomed-out');
|
|
247
|
+
iframeDocument.documentElement.style.transform = `scale( ${_scale} )`;
|
|
245
248
|
iframeDocument.documentElement.style.marginTop = `${frameSize}px`;
|
|
246
|
-
|
|
249
|
+
// TODO: `marginBottom` doesn't work in Firefox. We need another way to do this.
|
|
250
|
+
iframeDocument.documentElement.style.marginBottom = `${bottomFrameSize}px`;
|
|
251
|
+
if (iframeWindowInnerHeight > contentHeight * _scale) {
|
|
252
|
+
iframeDocument.body.style.minHeight = `${Math.floor((iframeWindowInnerHeight - 2 * frameSize) / _scale)}px`;
|
|
253
|
+
}
|
|
247
254
|
return () => {
|
|
255
|
+
iframeDocument.body.classList.remove('is-zoomed-out');
|
|
248
256
|
iframeDocument.documentElement.style.transform = '';
|
|
249
257
|
iframeDocument.documentElement.style.marginTop = '';
|
|
250
258
|
iframeDocument.documentElement.style.marginBottom = '';
|
|
259
|
+
iframeDocument.body.style.minHeight = '';
|
|
251
260
|
};
|
|
252
261
|
}
|
|
253
|
-
}, [scale, frameSize,
|
|
262
|
+
}, [scale, frameSize, iframeDocument, contentHeight, iframeWindowInnerHeight, contentWidth]);
|
|
254
263
|
|
|
255
264
|
// Make sure to not render the before and after focusable div elements in view
|
|
256
265
|
// mode. They're only needed to capture focus in edit mode.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_element","_i18n","_compose","_components","_data","_blockSelectionClearer","_writingFlow","_getCompatibilityStyles","_store","_calculateScale","bubbleEvent","event","Constructor","frame","init","key","contentDocument","defaultView","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","defaultPrevented","preventDefault","cancelled","dispatchEvent","useBubbleEvents","iframeDocument","useRefEffect","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","useSelect","select","getSettings","__unstableGetEditorMode","blockEditorStore","settings","__unstableResolvedAssets","__unstableIsPreviewMode","styles","scripts","setIframeDocument","useState","bodyClasses","setBodyClasses","clearerRef","useBlockSelectionClearer","before","writingFlowRef","after","useWritingFlow","contentResizeListener","height","contentHeight","width","contentWidth","useResizeObserver","scale","calculateScale","maxWidth","minWidth","maxScale","minScale","frameSize","setRef","node","_load","iFrameDocument","preventFileDropDefault","onLoad","ownerDocument","classList","add","Array","from","body","filter","startsWith","dir","compatStyle","getCompatibilityStyles","getElementById","id","head","appendChild","cloneNode","console","warn","disabledRef","useDisabled","isDisabled","bodyRef","useMergeRefs","src","cleanup","useMemo","_src","URL","createObjectURL","Blob","revokeObjectURL","useEffect","marginFromScaling","style","transform","marginTop","marginBottom","shouldRenderFocusCaptureElements","_react","createElement","Fragment","border","transition","onKeyDown","currentTarget","target","stopPropagation","KeyboardEvent","createPortal","className","classnames","__experimentalStyleProvider","document","IframeIfReady","isInitialised","__internalIsInitialized","_default","exports","default","forwardRef"],"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":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAOA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAMA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAA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AC,IAAAsG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,mBAAU,EAAEN,aAAc,CAAC"}
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_element","_i18n","_compose","_components","_data","_blockSelectionClearer","_writingFlow","_getCompatibilityStyles","_store","bubbleEvent","event","Constructor","frame","init","key","contentDocument","defaultView","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","defaultPrevented","preventDefault","cancelled","dispatchEvent","useBubbleEvents","iframeDocument","useRefEffect","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","useSelect","select","getSettings","blockEditorStore","settings","__unstableResolvedAssets","__unstableIsPreviewMode","styles","scripts","setIframeDocument","useState","bodyClasses","setBodyClasses","clearerRef","useBlockSelectionClearer","before","writingFlowRef","after","useWritingFlow","contentResizeListener","height","contentHeight","width","contentWidth","useResizeObserver","setRef","node","_load","iFrameDocument","preventFileDropDefault","onLoad","ownerDocument","initialIframeBodyClasses","Array","from","body","classList","add","concat","filter","startsWith","dir","compatStyle","getCompatibilityStyles","getElementById","id","head","appendChild","cloneNode","console","warn","windowResizeRef","nodeWindow","onResize","setIframeWindowInnerHeight","innerHeight","iframeWindowInnerHeight","disabledRef","useDisabled","isDisabled","bodyRef","useMergeRefs","src","cleanup","useMemo","_src","URL","createObjectURL","Blob","revokeObjectURL","useEffect","_scale","bottomFrameSize","style","transform","marginTop","marginBottom","minHeight","Math","floor","remove","shouldRenderFocusCaptureElements","_react","createElement","Fragment","border","transition","onKeyDown","currentTarget","target","stopPropagation","KeyboardEvent","createPortal","className","classnames","__experimentalStyleProvider","document","IframeIfReady","isInitialised","__internalIsInitialized","_default","exports","default","forwardRef"],"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={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PatternsExplorer({
|
|
|
25
25
|
rootClientId
|
|
26
26
|
}) {
|
|
27
27
|
const [searchValue, setSearchValue] = (0, _element.useState)('');
|
|
28
|
-
const [patternSourceFilter, setPatternSourceFilter] = (0, _element.useState)('all');
|
|
29
28
|
const [selectedCategory, setSelectedCategory] = (0, _element.useState)(initialCategory?.name);
|
|
30
|
-
const patternCategories = (0, _usePatternCategories.usePatternCategories)(rootClientId
|
|
29
|
+
const patternCategories = (0, _usePatternCategories.usePatternCategories)(rootClientId);
|
|
31
30
|
return (0, _react.createElement)("div", {
|
|
32
31
|
className: "block-editor-block-patterns-explorer"
|
|
33
32
|
}, (0, _react.createElement)(_patternExplorerSidebar.default, {
|
|
@@ -35,14 +34,12 @@ function PatternsExplorer({
|
|
|
35
34
|
patternCategories: patternCategories,
|
|
36
35
|
onClickCategory: setSelectedCategory,
|
|
37
36
|
searchValue: searchValue,
|
|
38
|
-
setSearchValue: setSearchValue
|
|
39
|
-
patternSourceFilter: patternSourceFilter,
|
|
40
|
-
setPatternSourceFilter: setPatternSourceFilter
|
|
37
|
+
setSearchValue: setSearchValue
|
|
41
38
|
}), (0, _react.createElement)(_patternList.default, {
|
|
42
39
|
searchValue: searchValue,
|
|
43
40
|
selectedCategory: selectedCategory,
|
|
44
41
|
patternCategories: patternCategories,
|
|
45
|
-
|
|
42
|
+
rootClientId: rootClientId
|
|
46
43
|
}));
|
|
47
44
|
}
|
|
48
45
|
function PatternsExplorerModal({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_element","_i18n","_patternExplorerSidebar","_interopRequireDefault","_patternList","_usePatternCategories","PatternsExplorer","initialCategory","rootClientId","searchValue","setSearchValue","useState","
|
|
1
|
+
{"version":3,"names":["_components","require","_element","_i18n","_patternExplorerSidebar","_interopRequireDefault","_patternList","_usePatternCategories","PatternsExplorer","initialCategory","rootClientId","searchValue","setSearchValue","useState","selectedCategory","setSelectedCategory","name","patternCategories","usePatternCategories","_react","createElement","className","default","onClickCategory","PatternsExplorerModal","onModalClose","restProps","Modal","title","__","onRequestClose","isFullScreen","_default","exports"],"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":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAKA,IAAAG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gB;IAAA,GAAMkB;EAAS,CAAI,CAC9B,CAAC;AAEV;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAX,OAAA,GAEcE,qBAAqB"}
|
|
@@ -44,11 +44,13 @@ function PatternsListHeader({
|
|
|
44
44
|
function PatternList({
|
|
45
45
|
searchValue,
|
|
46
46
|
selectedCategory,
|
|
47
|
-
patternCategories
|
|
47
|
+
patternCategories,
|
|
48
|
+
rootClientId
|
|
48
49
|
}) {
|
|
49
50
|
const container = (0, _element.useRef)();
|
|
50
51
|
const debouncedSpeak = (0, _compose.useDebounce)(_a11y.speak, 500);
|
|
51
52
|
const [destinationRootClientId, onInsertBlocks] = (0, _useInsertionPoint.default)({
|
|
53
|
+
rootClientId,
|
|
52
54
|
shouldFocusBlock: true
|
|
53
55
|
});
|
|
54
56
|
const [patterns,, onClickPattern] = (0, _usePatternsState.default)(onInsertBlocks, destinationRootClientId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_i18n","_compose","_components","_a11y","_blockPatternsList","_interopRequireDefault","_useInsertionPoint","_usePatternsState","_inserterListbox","_searchItems","_blockPatternsPaging","_usePatternsPaging","_utils","PatternsListHeader","filterValue","filteredBlockPatternsLength","_react","createElement","__experimentalHeading","level","lineHeight","className","sprintf","_n","PatternList","searchValue","selectedCategory","patternCategories","container","useRef","debouncedSpeak","useDebounce","speak","destinationRootClientId","onInsertBlocks","useInsertionPoint","shouldFocusBlock","patterns","onClickPattern","usePatternsState","registeredPatternCategories","useMemo","map","patternCategory","name","filteredBlockPatterns","filteredPatterns","filter","pattern","allPatternsCategory","myPatternsCategory","type","INSERTER_PATTERN_TYPES","user","hasKnownCategory","categories","some","category","includes","length","searchItems","useEffect","count","resultsFoundMessage","pagingProps","usePatternsPaging","previousSearchValue","setPreviousSearchValue","useState","changePage","hasItems","ref","default","Fragment","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","isDraggable","_default","exports"],"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":["_element","require","_i18n","_compose","_components","_a11y","_blockPatternsList","_interopRequireDefault","_useInsertionPoint","_usePatternsState","_inserterListbox","_searchItems","_blockPatternsPaging","_usePatternsPaging","_utils","PatternsListHeader","filterValue","filteredBlockPatternsLength","_react","createElement","__experimentalHeading","level","lineHeight","className","sprintf","_n","PatternList","searchValue","selectedCategory","patternCategories","rootClientId","container","useRef","debouncedSpeak","useDebounce","speak","destinationRootClientId","onInsertBlocks","useInsertionPoint","shouldFocusBlock","patterns","onClickPattern","usePatternsState","registeredPatternCategories","useMemo","map","patternCategory","name","filteredBlockPatterns","filteredPatterns","filter","pattern","allPatternsCategory","myPatternsCategory","type","INSERTER_PATTERN_TYPES","user","hasKnownCategory","categories","some","category","includes","length","searchItems","useEffect","count","resultsFoundMessage","pagingProps","usePatternsPaging","previousSearchValue","setPreviousSearchValue","useState","changePage","hasItems","ref","default","Fragment","shownPatterns","categoryPatternsAsyncList","blockPatterns","categoryPatterns","isDraggable","_default","exports"],"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":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,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,EAACP,oBAAA,CAAA+D,OAAmB;IAAA,GAAMR;EAAW,CAAI,CACxC,CAEa,CACb,CAAC;AAER;AAAC,IAAAe,QAAA,GAAAC,OAAA,CAAAR,OAAA,GAEcjD,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_i18n","_compose","_components","_icons","_blockPatternsExplorer","_interopRequireDefault","_mobileTabNavigation","_patternCategoryPreviews","_usePatternCategories","BlockPatternsTab","onSelectCategory","selectedCategory","onInsert","rootClientId","showPatternsExplorer","setShowPatternsExplorer","useState","categories","usePatternCategories","initialCategory","isMobile","useViewportMatch","_react","createElement","Fragment","className","__","__experimentalItemGroup","role","map","category","__experimentalItem","key","name","onClick","label","undefined","__experimentalHStack","FlexBlock","Icon","icon","isRTL","chevronLeft","chevronRight","Button","variant","default","PatternCategoryPreviews","showTitlesAsTooltip","patternCategories","onModalClose","_default","exports"],"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":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAOA,IAAAI,MAAA,GAAAJ,OAAA;AAKA,IAAAK,sBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,oBAAA,GAAAD,sBAAA,CAAAN,OAAA;AACA,IAAAQ,wBAAA,GAAAR,OAAA;AACA,IAAAS,qBAAA,GAAAT,OAAA;AArBA;AACA;AACA;;AAaA;AACA;AACA;;AAMA,SAASU,gBAAgBA,CAAE;EAC1BC,gBAAgB;EAChBC,gBAAgB;EAChBC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,MAAM,CAAEC,oBAAoB,EAAEC,uBAAuB,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EAE3E,MAAMC,UAAU,GAAG,IAAAC,0CAAoB,EAAEL,YAAa,CAAC;EAEvD,MAAMM,eAAe,GAAGR,gBAAgB,IAAIM,UAAU,CAAE,CAAC,CAAE;EAC3D,MAAMG,QAAQ,GAAG,IAAAC,yBAAgB,EAAE,QAAQ,EAAE,GAAI,CAAC;
|
|
1
|
+
{"version":3,"names":["_element","require","_i18n","_compose","_components","_icons","_blockPatternsExplorer","_interopRequireDefault","_mobileTabNavigation","_patternCategoryPreviews","_usePatternCategories","BlockPatternsTab","onSelectCategory","selectedCategory","onInsert","rootClientId","showPatternsExplorer","setShowPatternsExplorer","useState","categories","usePatternCategories","initialCategory","isMobile","useViewportMatch","_react","createElement","Fragment","className","__","__experimentalItemGroup","role","map","category","__experimentalItem","key","name","onClick","label","undefined","__experimentalHStack","FlexBlock","Icon","icon","isRTL","chevronLeft","chevronRight","Button","variant","default","PatternCategoryPreviews","showTitlesAsTooltip","patternCategories","onModalClose","_default","exports"],"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":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAOA,IAAAI,MAAA,GAAAJ,OAAA;AAKA,IAAAK,sBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,oBAAA,GAAAD,sBAAA,CAAAN,OAAA;AACA,IAAAQ,wBAAA,GAAAR,OAAA;AACA,IAAAS,qBAAA,GAAAT,OAAA;AArBA;AACA;AACA;;AAaA;AACA;AACA;;AAMA,SAASU,gBAAgBA,CAAE;EAC1BC,gBAAgB;EAChBC,gBAAgB;EAChBC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,MAAM,CAAEC,oBAAoB,EAAEC,uBAAuB,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EAE3E,MAAMC,UAAU,GAAG,IAAAC,0CAAoB,EAAEL,YAAa,CAAC;EAEvD,MAAMM,eAAe,GAAGR,gBAAgB,IAAIM,UAAU,CAAE,CAAC,CAAE;EAC3D,MAAMG,QAAQ,GAAG,IAAAC,yBAAgB,EA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TnB,uBAAuB,CAAE,IAAK,CAC9B;IACD8B,OAAO,EAAC;EAAW,GAEjB,IAAAnB,QAAE,EAAE,sBAAuB,CACtB,CACJ,CACK,CACP,CACD,CACL,EACCN,QAAQ,IACT,IAAAE,MAAA,CAAAC,aAAA,EAACjB,oBAAA,CAAAwC,OAAmB;IAAC7B,UAAU,EAAGA;EAAY,GACzCa,QAAQ,IACX,IAAAR,MAAA,CAAAC,aAAA,EAAChB,wBAAA,CAAAwC,uBAAuB;IACvBf,GAAG,EAAGF,QAAQ,CAACG,IAAM;IACrBrB,QAAQ,EAAGA,QAAU;IACrBC,YAAY,EAAGA,YAAc;IAC7BiB,QAAQ,EAAGA,QAAU;IACrBkB,mBAAmB,EAAG;EAAO,CAC7B,CAEkB,CACrB,EACClC,oBAAoB,IACrB,IAAAQ,MAAA,CAAAC,aAAA,EAACnB,sBAAA,CAAA0C,OAAqB;IACrB3B,eAAe,EAAGA,eAAiB;IACnC8B,iBAAiB,EAAGhC,UAAY;IAChCiC,YAAY,EAAGA,CAAA,KAAMnC,uBAAuB,CAAE,KAAM,CAAG;IACvDF,YAAY,EAAGA;EAAc,CAC7B,CAED,CAAC;AAEL;AAAC,IAAAsC,QAAA,GAAAC,OAAA,CAAAN,OAAA,GAEcrC,gBAAgB"}
|
|
@@ -8,6 +8,7 @@ var _react = require("react");
|
|
|
8
8
|
var _element = require("@wordpress/element");
|
|
9
9
|
var _dom = require("@wordpress/dom");
|
|
10
10
|
var _patternCategoryPreviews = require("./pattern-category-previews");
|
|
11
|
+
var _useZoomOut = require("../../../hooks/use-zoom-out");
|
|
11
12
|
/**
|
|
12
13
|
* WordPress dependencies
|
|
13
14
|
*/
|
|
@@ -32,6 +33,10 @@ function PatternCategoryPreviewPanel({
|
|
|
32
33
|
});
|
|
33
34
|
return () => clearTimeout(timeout);
|
|
34
35
|
}, [category]);
|
|
36
|
+
|
|
37
|
+
// Move to zoom out mode when this component is mounted
|
|
38
|
+
// and back to the previous mode when unmounted.
|
|
39
|
+
(0, _useZoomOut.useZoomOut)();
|
|
35
40
|
return (0, _react.createElement)("div", {
|
|
36
41
|
ref: container,
|
|
37
42
|
className: "block-editor-inserter__patterns-category-dialog"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_dom","_patternCategoryPreviews","PatternCategoryPreviewPanel","rootClientId","onInsert","onHover","category","showTitlesAsTooltip","patternFilter","container","useRef","useEffect","timeout","setTimeout","firstTabbable","focus","tabbable","find","current","clearTimeout","_react","createElement","ref","className","PatternCategoryPreviews","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":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AAMA,IAAAE,wBAAA,GAAAF,OAAA;
|
|
1
|
+
{"version":3,"names":["_element","require","_dom","_patternCategoryPreviews","_useZoomOut","PatternCategoryPreviewPanel","rootClientId","onInsert","onHover","category","showTitlesAsTooltip","patternFilter","container","useRef","useEffect","timeout","setTimeout","firstTabbable","focus","tabbable","find","current","clearTimeout","useZoomOut","_react","createElement","ref","className","PatternCategoryPreviews","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":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AAMA,IAAAE,wBAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAZA;AACA;AACA;;AAKA;AACA;AACA;;AAKO,SAASI,2BAA2BA,CAAE;EAC5CC,YAAY;EACZC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,mBAAmB;EACnBC;AACD,CAAC,EAAG;EACH,MAAMC,SAAS,GAAG,IAAAC,eAAM,EAAC,CAAC;EAE1B,IAAAC,kBAAS,EAAE,MAAM;IAChB,MAAMC,OAAO,GAAGC,UAAU,CAAE,MAAM;MACjC,MAAM,CAAEC,aAAa,CAAE,GAAGC,UAAK,CAACC,QAAQ,CAACC,IAAI,CAAER,SAAS,CAACS,OAAQ,CAAC;MAClEJ,aAAa,EAAEC,KAAK,CAAC,CAAC;IACvB,CAAE,CAAC;IACH,OAAO,MAAMI,YAAY,CAAEP,OAAQ,CAAC;EACrC,CAAC,EAAE,CAAEN,QAAQ,CAAG,CAAC;;EAEjB;EACA;EACA,IAAAc,sBAAU,EAAC,CAAC;EAEZ,OACC,IAAAC,MAAA,CAAAC,aAAA;IACCC,GAAG,EAAGd,SAAW;IACjBe,SAAS,EAAC;EAAiD,GAE3D,IAAAH,MAAA,CAAAC,aAAA,EAACtB,wBAAA,CAAAyB,uBAAuB;IACvBC,GAAG,EAAGpB,QAAQ,CAACqB,IAAM;IACrBxB,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"}
|
|
@@ -27,6 +27,7 @@ function InserterLibrary({
|
|
|
27
27
|
showMostUsedBlocks = false,
|
|
28
28
|
__experimentalInsertionIndex,
|
|
29
29
|
__experimentalFilterValue,
|
|
30
|
+
__experimentalOnPatternCategorySelection,
|
|
30
31
|
onSelect = noop,
|
|
31
32
|
shouldFocusBlock = false
|
|
32
33
|
}, ref) {
|
|
@@ -50,6 +51,7 @@ function InserterLibrary({
|
|
|
50
51
|
showMostUsedBlocks: showMostUsedBlocks,
|
|
51
52
|
__experimentalInsertionIndex: __experimentalInsertionIndex,
|
|
52
53
|
__experimentalFilterValue: __experimentalFilterValue,
|
|
54
|
+
__experimentalOnPatternCategorySelection: __experimentalOnPatternCategorySelection,
|
|
53
55
|
shouldFocusBlock: shouldFocusBlock,
|
|
54
56
|
ref: ref
|
|
55
57
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_element","_menu","_interopRequireDefault","_store","noop","InserterLibrary","rootClientId","clientId","isAppender","showInserterHelpPanel","showMostUsedBlocks","__experimentalInsertionIndex","__experimentalFilterValue","onSelect","shouldFocusBlock","ref","destinationRootClientId","useSelect","select","getBlockRootClientId","blockEditorStore","_rootClientId","undefined","_react","createElement","default","_default","exports","forwardRef"],"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":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,KAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA,MAAMK,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":["_data","require","_element","_menu","_interopRequireDefault","_store","noop","InserterLibrary","rootClientId","clientId","isAppender","showInserterHelpPanel","showMostUsedBlocks","__experimentalInsertionIndex","__experimentalFilterValue","__experimentalOnPatternCategorySelection","onSelect","shouldFocusBlock","ref","destinationRootClientId","useSelect","select","getBlockRootClientId","blockEditorStore","_rootClientId","undefined","_react","createElement","default","_default","exports","forwardRef"],"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":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,KAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA,MAAMK,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,GAAG,IAAAC,eAAS,EAC1CC,MAAM,IAAM;IACb,MAAM;MAAEC;IAAqB,CAAC,GAAGD,MAAM,CAAEE,YAAiB,CAAC;IAC3D,MAAMC,aAAa,GAClBhB,YAAY,IAAIc,oBAAoB,CAAEb,QAAS,CAAC,IAAIgB,SAAS;IAC9D,OAAO;MACNN,uBAAuB,EAAEK;IAC1B,CAAC;EACF,CAAC,EACD,CAAEf,QAAQ,EAAED,YAAY,CACzB,CAAC;EAED,OACC,IAAAkB,MAAA,CAAAC,aAAA,EAACxB,KAAA,CAAAyB,OAAY;IACZZ,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;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAEc,IAAAG,mBAAU,EAAExB,eAAgB,CAAC"}
|
|
@@ -35,6 +35,7 @@ var _store = require("../../store");
|
|
|
35
35
|
* Internal dependencies
|
|
36
36
|
*/
|
|
37
37
|
|
|
38
|
+
const NOOP = () => {};
|
|
38
39
|
function InserterMenu({
|
|
39
40
|
rootClientId,
|
|
40
41
|
clientId,
|
|
@@ -44,7 +45,8 @@ function InserterMenu({
|
|
|
44
45
|
showInserterHelpPanel,
|
|
45
46
|
showMostUsedBlocks,
|
|
46
47
|
__experimentalFilterValue = '',
|
|
47
|
-
shouldFocusBlock = true
|
|
48
|
+
shouldFocusBlock = true,
|
|
49
|
+
__experimentalOnPatternCategorySelection = NOOP
|
|
48
50
|
}, ref) {
|
|
49
51
|
const [filterValue, setFilterValue, delayedFilterValue] = (0, _compose.useDebouncedInput)(__experimentalFilterValue);
|
|
50
52
|
const [hoveredItem, setHoveredItem] = (0, _element.useState)(null);
|
|
@@ -60,21 +62,17 @@ function InserterMenu({
|
|
|
60
62
|
shouldFocusBlock
|
|
61
63
|
});
|
|
62
64
|
const {
|
|
63
|
-
isZoomOutMode,
|
|
64
65
|
showPatterns
|
|
65
66
|
} = (0, _data.useSelect)(select => {
|
|
66
67
|
const {
|
|
67
|
-
hasAllowedPatterns
|
|
68
|
-
__unstableGetEditorMode
|
|
68
|
+
hasAllowedPatterns
|
|
69
69
|
} = (0, _lockUnlock.unlock)(select(_store.store));
|
|
70
70
|
return {
|
|
71
|
-
isZoomOutMode: __unstableGetEditorMode() === 'zoom-out',
|
|
72
71
|
showPatterns: hasAllowedPatterns(destinationRootClientId)
|
|
73
72
|
};
|
|
74
73
|
}, [destinationRootClientId]);
|
|
75
74
|
const mediaCategories = (0, _mediaTab.useMediaCategories)(destinationRootClientId);
|
|
76
|
-
const showMedia = mediaCategories.length > 0
|
|
77
|
-
const showBlocks = !isZoomOutMode;
|
|
75
|
+
const showMedia = mediaCategories.length > 0;
|
|
78
76
|
const onInsert = (0, _element.useCallback)((blocks, meta, shouldForceFocusBlock) => {
|
|
79
77
|
onInsertBlocks(blocks, meta, shouldForceFocusBlock);
|
|
80
78
|
onSelect();
|
|
@@ -92,10 +90,14 @@ function InserterMenu({
|
|
|
92
90
|
const onHoverPattern = (0, _element.useCallback)(item => {
|
|
93
91
|
onToggleInsertionPoint(!!item);
|
|
94
92
|
}, [onToggleInsertionPoint]);
|
|
93
|
+
const isZoomedOutViewExperimentEnabled = window?.__experimentalEnableZoomedOutView;
|
|
95
94
|
const onClickPatternCategory = (0, _element.useCallback)((patternCategory, filter) => {
|
|
96
95
|
setSelectedPatternCategory(patternCategory);
|
|
97
96
|
setPatternFilter(filter);
|
|
98
|
-
|
|
97
|
+
if (isZoomedOutViewExperimentEnabled) {
|
|
98
|
+
__experimentalOnPatternCategorySelection();
|
|
99
|
+
}
|
|
100
|
+
}, [setSelectedPatternCategory, __experimentalOnPatternCategorySelection]);
|
|
99
101
|
const blocksTab = (0, _element.useMemo)(() => (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)("div", {
|
|
100
102
|
className: "block-editor-inserter__block-list"
|
|
101
103
|
}, (0, _react.createElement)(_blockTypesTab.default, {
|
|
@@ -170,15 +172,13 @@ function InserterMenu({
|
|
|
170
172
|
isAppender: isAppender,
|
|
171
173
|
__experimentalInsertionIndex: __experimentalInsertionIndex,
|
|
172
174
|
showBlockDirectory: true,
|
|
173
|
-
showBlocks: showBlocks,
|
|
174
175
|
shouldFocusBlock: shouldFocusBlock
|
|
175
176
|
})), showAsTabs && (0, _react.createElement)(_tabs.default, {
|
|
176
|
-
showBlocks: showBlocks,
|
|
177
177
|
showPatterns: showPatterns,
|
|
178
178
|
showMedia: showMedia,
|
|
179
179
|
onSelect: handleSetSelectedTab,
|
|
180
180
|
tabsContents: inserterTabsContents
|
|
181
|
-
}), !delayedFilterValue && !showAsTabs &&
|
|
181
|
+
}), !delayedFilterValue && !showAsTabs && (0, _react.createElement)("div", {
|
|
182
182
|
className: "block-editor-inserter__no-tab-container"
|
|
183
183
|
}, blocksTab)), showMediaPanel && (0, _react.createElement)(_mediaTab.MediaCategoryDialog, {
|
|
184
184
|
rootClientId: destinationRootClientId,
|