@wordpress/block-editor 14.6.0 → 14.7.1-next.082ed6819.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 +2 -0
- package/build/components/block-controls/slot.js +6 -3
- package/build/components/block-controls/slot.js.map +1 -1
- package/build/components/block-inspector/index.js +1 -2
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list/block.js +14 -28
- package/build/components/block-list/block.js.map +1 -1
- package/build/components/block-lock/modal.js +1 -1
- package/build/components/block-lock/modal.js.map +1 -1
- package/build/components/block-manager/category.js +79 -0
- package/build/components/block-manager/category.js.map +1 -0
- package/build/components/block-manager/checklist.js +40 -0
- package/build/components/block-manager/checklist.js.map +1 -0
- package/build/components/block-manager/index.js +108 -0
- package/build/components/block-manager/index.js.map +1 -0
- package/build/components/block-patterns-list/index.js +23 -26
- package/build/components/block-patterns-list/index.js.map +1 -1
- package/build/components/block-popover/index.js +1 -1
- package/build/components/block-popover/index.js.map +1 -1
- package/build/components/block-preview/async.js +51 -0
- package/build/components/block-preview/async.js.map +1 -0
- package/build/components/block-preview/index.js +4 -1
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build/components/block-settings-menu/index.js.map +1 -1
- package/build/components/block-toolbar/change-design.js +1 -4
- package/build/components/block-toolbar/change-design.js.map +1 -1
- package/build/components/block-toolbar/index.js +7 -2
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-toolbar/switch-section-style.js +105 -0
- package/build/components/block-toolbar/switch-section-style.js.map +1 -0
- package/build/components/block-tools/index.js +12 -9
- package/build/components/block-tools/index.js.map +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js +1 -1
- package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +4 -1
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/collab/block-comment-icon-slot.js +2 -6
- package/build/components/collab/block-comment-icon-slot.js.map +1 -1
- package/build/components/collab/block-comment-icon-toolbar-slot.js +2 -6
- package/build/components/collab/block-comment-icon-toolbar-slot.js.map +1 -1
- package/build/components/color-palette/with-color-context.js +4 -2
- package/build/components/color-palette/with-color-context.js.map +1 -1
- package/build/components/font-family/index.js +14 -13
- package/build/components/font-family/index.js.map +1 -1
- package/build/components/global-styles/dimensions-panel.js +26 -14
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/use-global-styles-output.js +1 -1
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/iframe/get-compatibility-styles.js +4 -4
- package/build/components/iframe/get-compatibility-styles.js.map +1 -1
- package/build/components/iframe/index.js +156 -23
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
- package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/index.js +1 -2
- package/build/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +4 -6
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +3 -0
- package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/utils.js +5 -1
- package/build/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build/components/inserter/category-tabs/index.js +7 -8
- package/build/components/inserter/category-tabs/index.js.map +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js +1 -1
- package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build/components/inserter/hooks/use-patterns-paging.js +0 -5
- package/build/components/inserter/hooks/use-patterns-paging.js.map +1 -1
- package/build/components/inserter/search-results.js +0 -2
- package/build/components/inserter/search-results.js.map +1 -1
- package/build/components/inserter-draggable-blocks/index.js +2 -1
- package/build/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build/components/inspector-controls/slot.js +7 -4
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js +1 -1
- package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -4
- package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build/components/media-placeholder/index.js +33 -25
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/rich-text/index.js +1 -1
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/tabbed-sidebar/index.js +1 -1
- package/build/components/tabbed-sidebar/index.js.map +1 -1
- package/build/components/url-input/index.js +3 -1
- package/build/components/url-input/index.js.map +1 -1
- package/build/components/use-block-commands/index.js +5 -6
- package/build/components/use-block-commands/index.js.map +1 -1
- package/build/hooks/border.js +3 -3
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/color.js +1 -1
- package/build/hooks/color.js.map +1 -1
- package/build/hooks/dimensions.js +2 -2
- package/build/hooks/dimensions.js.map +1 -1
- package/build/hooks/font-family.js +1 -1
- package/build/hooks/font-family.js.map +1 -1
- package/build/hooks/style.js +6 -6
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/supports.js +7 -7
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +6 -6
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +3 -3
- package/build/hooks/utils.js.map +1 -1
- package/build/layouts/flex.js +11 -9
- package/build/layouts/flex.js.map +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/private-apis.js +4 -4
- package/build/private-apis.js.map +1 -1
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js +12 -8
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +5 -4
- package/build/store/utils.js.map +1 -1
- package/build/utils/dom.js +27 -22
- package/build/utils/dom.js.map +1 -1
- package/build-module/components/block-controls/slot.js +6 -3
- package/build-module/components/block-controls/slot.js.map +1 -1
- package/build-module/components/block-inspector/index.js +1 -2
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list/block.js +15 -27
- package/build-module/components/block-list/block.js.map +1 -1
- package/build-module/components/block-lock/modal.js +1 -1
- package/build-module/components/block-lock/modal.js.map +1 -1
- package/build-module/components/block-manager/category.js +71 -0
- package/build-module/components/block-manager/category.js.map +1 -0
- package/build-module/components/block-manager/checklist.js +32 -0
- package/build-module/components/block-manager/checklist.js.map +1 -0
- package/build-module/components/block-manager/index.js +102 -0
- package/build-module/components/block-manager/index.js.map +1 -0
- package/build-module/components/block-patterns-list/index.js +23 -26
- package/build-module/components/block-patterns-list/index.js.map +1 -1
- package/build-module/components/block-popover/index.js +2 -2
- package/build-module/components/block-popover/index.js.map +1 -1
- package/build-module/components/block-preview/async.js +44 -0
- package/build-module/components/block-preview/async.js.map +1 -0
- package/build-module/components/block-preview/index.js +4 -1
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
- package/build-module/components/block-settings-menu/index.js +2 -2
- package/build-module/components/block-settings-menu/index.js.map +1 -1
- package/build-module/components/block-toolbar/change-design.js +1 -4
- package/build-module/components/block-toolbar/change-design.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +7 -2
- package/build-module/components/block-toolbar/index.js.map +1 -1
- package/build-module/components/block-toolbar/switch-section-style.js +97 -0
- package/build-module/components/block-toolbar/switch-section-style.js.map +1 -0
- package/build-module/components/block-tools/index.js +13 -10
- package/build-module/components/block-tools/index.js.map +1 -1
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js +2 -2
- package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js +4 -1
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/collab/block-comment-icon-slot.js +2 -6
- package/build-module/components/collab/block-comment-icon-slot.js.map +1 -1
- package/build-module/components/collab/block-comment-icon-toolbar-slot.js +2 -6
- package/build-module/components/collab/block-comment-icon-toolbar-slot.js.map +1 -1
- package/build-module/components/color-palette/with-color-context.js +4 -2
- package/build-module/components/color-palette/with-color-context.js.map +1 -1
- package/build-module/components/font-family/index.js +15 -14
- package/build-module/components/font-family/index.js.map +1 -1
- package/build-module/components/global-styles/dimensions-panel.js +26 -14
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js +1 -1
- package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build-module/components/iframe/get-compatibility-styles.js +4 -4
- package/build-module/components/iframe/get-compatibility-styles.js.map +1 -1
- package/build-module/components/iframe/index.js +157 -24
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +2 -2
- package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/index.js +1 -2
- package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +5 -7
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +4 -1
- package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/utils.js +4 -0
- package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -1
- package/build-module/components/inserter/category-tabs/index.js +8 -9
- package/build-module/components/inserter/category-tabs/index.js.map +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js +1 -1
- package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
- package/build-module/components/inserter/hooks/use-patterns-paging.js +1 -6
- package/build-module/components/inserter/hooks/use-patterns-paging.js.map +1 -1
- package/build-module/components/inserter/search-results.js +0 -2
- package/build-module/components/inserter/search-results.js.map +1 -1
- package/build-module/components/inserter-draggable-blocks/index.js +2 -1
- package/build-module/components/inserter-draggable-blocks/index.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +7 -4
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js +1 -1
- package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -1
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -4
- package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +33 -25
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/rich-text/index.js +1 -1
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/tabbed-sidebar/index.js +1 -1
- package/build-module/components/tabbed-sidebar/index.js.map +1 -1
- package/build-module/components/url-input/index.js +3 -1
- package/build-module/components/url-input/index.js.map +1 -1
- package/build-module/components/use-block-commands/index.js +4 -4
- package/build-module/components/use-block-commands/index.js.map +1 -1
- package/build-module/hooks/border.js +3 -3
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/color.js +1 -1
- package/build-module/hooks/color.js.map +1 -1
- package/build-module/hooks/dimensions.js +2 -2
- package/build-module/hooks/dimensions.js.map +1 -1
- package/build-module/hooks/font-family.js +1 -1
- package/build-module/hooks/font-family.js.map +1 -1
- package/build-module/hooks/style.js +6 -6
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/supports.js +7 -7
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +6 -6
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +3 -3
- package/build-module/hooks/utils.js.map +1 -1
- package/build-module/layouts/flex.js +11 -9
- package/build-module/layouts/flex.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/private-apis.js +6 -6
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-selectors.js +3 -3
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/selectors.js +12 -8
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +3 -3
- package/build-module/store/utils.js.map +1 -1
- package/build-module/utils/dom.js +25 -21
- package/build-module/utils/dom.js.map +1 -1
- package/build-style/content-rtl.css +30 -15
- package/build-style/content.css +30 -15
- package/build-style/style-rtl.css +92 -3
- package/build-style/style.css +92 -3
- package/build-types/utils/dom.d.ts +7 -9
- package/build-types/utils/dom.d.ts.map +1 -1
- package/package.json +32 -31
- package/src/components/block-canvas/style.scss +1 -1
- package/src/components/block-controls/slot.js +5 -3
- package/src/components/block-inspector/index.js +0 -2
- package/src/components/block-inspector/style.scss +2 -1
- package/src/components/block-list/block.js +28 -48
- package/src/components/block-lock/modal.js +1 -1
- package/src/components/block-manager/category.js +102 -0
- package/src/components/block-manager/checklist.js +34 -0
- package/src/components/block-manager/index.js +127 -0
- package/src/components/block-manager/style.scss +82 -0
- package/src/components/block-mover/README.md +15 -8
- package/src/components/block-mover/stories/index.story.js +73 -71
- package/src/components/block-mover/style.scss +3 -0
- package/src/components/block-patterns-list/README.md +8 -8
- package/src/components/block-patterns-list/index.js +35 -51
- package/src/components/block-patterns-list/stories/index.story.js +2 -19
- package/src/components/block-popover/index.js +4 -4
- package/src/components/block-preview/async.js +43 -0
- package/src/components/block-preview/index.js +6 -1
- package/src/components/block-settings-menu/block-settings-dropdown.js +2 -2
- package/src/components/block-settings-menu/index.js +2 -2
- package/src/components/block-toolbar/change-design.js +1 -7
- package/src/components/block-toolbar/index.js +6 -0
- package/src/components/block-toolbar/switch-section-style.js +115 -0
- package/src/components/block-tools/index.js +26 -10
- package/src/components/block-tools/style.scss +12 -0
- package/src/components/block-tools/use-block-toolbar-popover-props.js +2 -2
- package/src/components/block-tools/use-show-block-tools.js +3 -1
- package/src/components/collab/block-comment-icon-slot.js +2 -6
- package/src/components/collab/block-comment-icon-toolbar-slot.js +3 -5
- package/src/components/color-palette/with-color-context.js +25 -7
- package/src/components/default-block-appender/content.scss +13 -19
- package/src/components/font-family/index.js +13 -13
- package/src/components/global-styles/dimensions-panel.js +22 -16
- package/src/components/global-styles/test/use-global-styles-output.js +1 -1
- package/src/components/global-styles/use-global-styles-output.js +1 -1
- package/src/components/iframe/content.scss +16 -3
- package/src/components/iframe/get-compatibility-styles.js +4 -9
- package/src/components/iframe/index.js +204 -44
- package/src/components/inserter/block-patterns-explorer/pattern-list.js +3 -6
- package/src/components/inserter/block-patterns-tab/index.js +0 -1
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +15 -17
- package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +8 -0
- package/src/components/inserter/block-patterns-tab/utils.js +5 -0
- package/src/components/inserter/category-tabs/index.js +8 -9
- package/src/components/inserter/hooks/use-block-types-state.js +6 -1
- package/src/components/inserter/hooks/use-patterns-paging.js +1 -6
- package/src/components/inserter/search-results.js +0 -6
- package/src/components/inserter-draggable-blocks/index.js +10 -1
- package/src/components/inspector-controls/README.md +2 -0
- package/src/components/inspector-controls/slot.js +6 -4
- package/src/components/inspector-controls-tabs/position-controls-panel.js +1 -3
- package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +10 -10
- package/src/components/media-placeholder/index.js +41 -37
- package/src/components/provider/test/use-block-sync.js +3 -1
- package/src/components/rich-text/content.scss +15 -10
- package/src/components/rich-text/index.js +8 -1
- package/src/components/tabbed-sidebar/index.js +1 -1
- package/src/components/tabbed-sidebar/style.scss +1 -1
- package/src/components/url-input/index.js +3 -4
- package/src/components/use-block-commands/index.js +245 -234
- package/src/hooks/border.js +3 -9
- package/src/hooks/color.js +1 -1
- package/src/hooks/dimensions.js +2 -2
- package/src/hooks/font-family.js +1 -1
- package/src/hooks/style.js +6 -12
- package/src/hooks/supports.js +7 -7
- package/src/hooks/test/style.js +1 -2
- package/src/hooks/typography.js +6 -6
- package/src/hooks/utils.js +8 -3
- package/src/layouts/flex.js +26 -18
- package/src/private-apis.js +6 -6
- package/src/store/private-selectors.js +6 -7
- package/src/store/selectors.js +60 -45
- package/src/store/test/private-selectors.js +5 -0
- package/src/store/test/selectors.js +87 -58
- package/src/store/utils.js +12 -11
- package/src/style.scss +1 -0
- package/src/utils/dom.js +26 -21
- package/src/utils/test/dom.js +224 -0
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-info-slot-fill/index.js +0 -39
- package/build/components/block-info-slot-fill/index.js.map +0 -1
- package/build-module/components/block-info-slot-fill/index.js +0 -32
- package/build-module/components/block-info-slot-fill/index.js.map +0 -1
- package/src/components/block-info-slot-fill/index.js +0 -27
- /package/src/{lock-unlock.js → lock-unlock.ts} +0 -0
|
@@ -125,6 +125,7 @@ function Iframe({
|
|
|
125
125
|
styles = '',
|
|
126
126
|
scripts = ''
|
|
127
127
|
} = resolvedAssets;
|
|
128
|
+
/** @type {[Document, import('react').Dispatch<Document>]} */
|
|
128
129
|
const [iframeDocument, setIframeDocument] = (0, _element.useState)();
|
|
129
130
|
const initialContainerWidthRef = (0, _element.useRef)(0);
|
|
130
131
|
const [bodyClasses, setBodyClasses] = (0, _element.useState)([]);
|
|
@@ -136,6 +137,7 @@ function Iframe({
|
|
|
136
137
|
const [containerResizeListener, {
|
|
137
138
|
width: containerWidth
|
|
138
139
|
}] = (0, _compose.useResizeObserver)();
|
|
140
|
+
const prefersReducedMotion = (0, _compose.useReducedMotion)();
|
|
139
141
|
const setRef = (0, _compose.useRefEffect)(node => {
|
|
140
142
|
node._load = () => {
|
|
141
143
|
setIframeDocument(node.contentDocument);
|
|
@@ -174,6 +176,21 @@ function Iframe({
|
|
|
174
176
|
}
|
|
175
177
|
iFrameDocument.addEventListener('dragover', preventFileDropDefault, false);
|
|
176
178
|
iFrameDocument.addEventListener('drop', preventFileDropDefault, false);
|
|
179
|
+
// Prevent clicks on links from navigating away. Note that links
|
|
180
|
+
// inside `contenteditable` are already disabled by the browser, so
|
|
181
|
+
// this is for links in blocks outside of `contenteditable`.
|
|
182
|
+
iFrameDocument.addEventListener('click', event => {
|
|
183
|
+
if (event.target.tagName === 'A') {
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
|
|
186
|
+
// Appending a hash to the current URL will not reload the
|
|
187
|
+
// page. This is useful for e.g. footnotes.
|
|
188
|
+
const href = event.target.getAttribute('href');
|
|
189
|
+
if (href.startsWith('#')) {
|
|
190
|
+
iFrameDocument.defaultView.location.hash = href.slice(1);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
});
|
|
177
194
|
}
|
|
178
195
|
node.addEventListener('load', onLoad);
|
|
179
196
|
return () => {
|
|
@@ -214,6 +231,12 @@ function Iframe({
|
|
|
214
231
|
}
|
|
215
232
|
}, [containerWidth, isZoomedOut]);
|
|
216
233
|
const scaleContainerWidth = Math.max(initialContainerWidthRef.current, containerWidth);
|
|
234
|
+
const frameSizeValue = parseInt(frameSize);
|
|
235
|
+
const maxWidth = 750;
|
|
236
|
+
const scaleValue = scale === 'auto-scaled' ? (Math.min(containerWidth, maxWidth) - frameSizeValue * 2) / scaleContainerWidth : scale;
|
|
237
|
+
const prevScaleRef = (0, _element.useRef)(scaleValue);
|
|
238
|
+
const prevFrameSizeRef = (0, _element.useRef)(frameSizeValue);
|
|
239
|
+
const prevClientHeightRef = (0, _element.useRef)(/* Initialized in the useEffect. */);
|
|
217
240
|
const disabledRef = (0, _compose.useDisabled)({
|
|
218
241
|
isDisabled: !readonly
|
|
219
242
|
});
|
|
@@ -230,6 +253,7 @@ function Iframe({
|
|
|
230
253
|
<html>
|
|
231
254
|
<head>
|
|
232
255
|
<meta charset="utf-8">
|
|
256
|
+
<base href="${window.location.origin}">
|
|
233
257
|
<script>window.frameElement._load()</script>
|
|
234
258
|
<style>
|
|
235
259
|
html{
|
|
@@ -258,37 +282,132 @@ function Iframe({
|
|
|
258
282
|
return [_src, () => URL.revokeObjectURL(_src)];
|
|
259
283
|
}, [html]);
|
|
260
284
|
(0, _element.useEffect)(() => cleanup, [cleanup]);
|
|
261
|
-
|
|
285
|
+
(0, _element.useEffect)(() => {
|
|
286
|
+
var _prevClientHeightRef$;
|
|
287
|
+
if (!iframeDocument ||
|
|
288
|
+
// HACK: Checking if isZoomedOut differs from prevIsZoomedOut here
|
|
289
|
+
// instead of the dependency array to appease the linter.
|
|
290
|
+
scaleValue === 1 === (prevScaleRef.current === 1)) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Unscaled height of the current iframe container.
|
|
295
|
+
const clientHeight = iframeDocument.documentElement.clientHeight;
|
|
296
|
+
|
|
297
|
+
// Scaled height of the current iframe content.
|
|
298
|
+
const scrollHeight = iframeDocument.documentElement.scrollHeight;
|
|
299
|
+
|
|
300
|
+
// Previous scale value.
|
|
301
|
+
const prevScale = prevScaleRef.current;
|
|
302
|
+
|
|
303
|
+
// Unscaled size of the previous padding around the iframe content.
|
|
304
|
+
const prevFrameSize = prevFrameSizeRef.current;
|
|
305
|
+
|
|
306
|
+
// Unscaled height of the previous iframe container.
|
|
307
|
+
const prevClientHeight = (_prevClientHeightRef$ = prevClientHeightRef.current) !== null && _prevClientHeightRef$ !== void 0 ? _prevClientHeightRef$ : clientHeight;
|
|
308
|
+
|
|
309
|
+
// We can't trust the set value from contentHeight, as it was measured
|
|
310
|
+
// before the zoom out mode was changed. After zoom out mode is changed,
|
|
311
|
+
// appenders may appear or disappear, so we need to get the height from
|
|
312
|
+
// the iframe at this point when we're about to animate the zoom out.
|
|
313
|
+
// The iframe scrollTop, scrollHeight, and clientHeight will all be
|
|
314
|
+
// accurate. The client height also does change when the zoom out mode
|
|
315
|
+
// is toggled, as the bottom bar about selecting the template is
|
|
316
|
+
// added/removed when toggling zoom out mode.
|
|
317
|
+
const scrollTop = iframeDocument.documentElement.scrollTop;
|
|
318
|
+
|
|
319
|
+
// Step 0: Start with the current scrollTop.
|
|
320
|
+
let scrollTopNext = scrollTop;
|
|
321
|
+
|
|
322
|
+
// Step 1: Undo the effects of the previous scale and frame around the
|
|
323
|
+
// midpoint of the visible area.
|
|
324
|
+
scrollTopNext = (scrollTopNext + prevClientHeight / 2 - prevFrameSize) / prevScale - prevClientHeight / 2;
|
|
325
|
+
|
|
326
|
+
// Step 2: Apply the new scale and frame around the midpoint of the
|
|
327
|
+
// visible area.
|
|
328
|
+
scrollTopNext = (scrollTopNext + clientHeight / 2) * scaleValue + frameSizeValue - clientHeight / 2;
|
|
329
|
+
|
|
330
|
+
// Step 3: Handle an edge case so that you scroll to the top of the
|
|
331
|
+
// iframe if the top of the iframe content is visible in the container.
|
|
332
|
+
// The same edge case for the bottom is skipped because changing content
|
|
333
|
+
// makes calculating it impossible.
|
|
334
|
+
scrollTopNext = scrollTop <= prevFrameSize ? 0 : scrollTopNext;
|
|
335
|
+
|
|
336
|
+
// This is the scrollTop value if you are scrolled to the bottom of the
|
|
337
|
+
// iframe. We can't just let the browser handle it because we need to
|
|
338
|
+
// animate the scaling.
|
|
339
|
+
const maxScrollTop = scrollHeight * (scaleValue / prevScale) + frameSizeValue * 2 - clientHeight;
|
|
340
|
+
|
|
341
|
+
// Step 4: Clamp the scrollTopNext between the minimum and maximum
|
|
342
|
+
// possible scrollTop positions. Round the value to avoid subpixel
|
|
343
|
+
// truncation by the browser which sometimes causes a 1px error.
|
|
344
|
+
scrollTopNext = Math.round(Math.min(Math.max(0, scrollTopNext), Math.max(0, maxScrollTop)));
|
|
345
|
+
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-scroll-top', `${scrollTop}px`);
|
|
346
|
+
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-scroll-top-next', `${scrollTopNext}px`);
|
|
347
|
+
iframeDocument.documentElement.classList.add('zoom-out-animation');
|
|
348
|
+
function onZoomOutTransitionEnd() {
|
|
349
|
+
// Remove the position fixed for the animation.
|
|
350
|
+
iframeDocument.documentElement.classList.remove('zoom-out-animation');
|
|
351
|
+
|
|
352
|
+
// Update previous values.
|
|
353
|
+
prevClientHeightRef.current = clientHeight;
|
|
354
|
+
prevFrameSizeRef.current = frameSizeValue;
|
|
355
|
+
prevScaleRef.current = scaleValue;
|
|
356
|
+
|
|
357
|
+
// Set the final scroll position that was just animated to.
|
|
358
|
+
// Disable reason: Eslint isn't smart enough to know that this is a
|
|
359
|
+
// DOM element. https://github.com/facebook/react/issues/31483
|
|
360
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
361
|
+
iframeDocument.documentElement.scrollTop = scrollTopNext;
|
|
362
|
+
}
|
|
363
|
+
let raf;
|
|
364
|
+
if (prefersReducedMotion) {
|
|
365
|
+
// Hack: Wait for the window values to recalculate.
|
|
366
|
+
raf = iframeDocument.defaultView.requestAnimationFrame(onZoomOutTransitionEnd);
|
|
367
|
+
} else {
|
|
368
|
+
iframeDocument.documentElement.addEventListener('transitionend', onZoomOutTransitionEnd, {
|
|
369
|
+
once: true
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
return () => {
|
|
373
|
+
iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-scroll-top');
|
|
374
|
+
iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-scroll-top-next');
|
|
375
|
+
iframeDocument.documentElement.classList.remove('zoom-out-animation');
|
|
376
|
+
if (prefersReducedMotion) {
|
|
377
|
+
iframeDocument.defaultView.cancelAnimationFrame(raf);
|
|
378
|
+
} else {
|
|
379
|
+
iframeDocument.documentElement.removeEventListener('transitionend', onZoomOutTransitionEnd);
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
}, [iframeDocument, scaleValue, frameSizeValue, prefersReducedMotion]);
|
|
262
383
|
|
|
263
384
|
// Toggle zoom out CSS Classes only when zoom out mode changes. We could add these into the useEffect
|
|
264
385
|
// that controls settings the CSS variables, but then we would need to do more work to ensure we're
|
|
265
386
|
// only toggling these when the zoom out mode changes, as that useEffect is also triggered by a large
|
|
266
387
|
// number of dependencies.
|
|
267
388
|
(0, _element.useEffect)(() => {
|
|
268
|
-
if (!iframeDocument
|
|
389
|
+
if (!iframeDocument) {
|
|
269
390
|
return;
|
|
270
391
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
iframeDocument.documentElement.classList.remove('zoom-out-animation');
|
|
276
|
-
}, 400); // 400ms should match the animation speed used in components/iframe/content.scss
|
|
277
|
-
};
|
|
278
|
-
handleZoomOutAnimationClassname();
|
|
279
|
-
iframeDocument.documentElement.classList.add('is-zoomed-out');
|
|
280
|
-
return () => {
|
|
281
|
-
handleZoomOutAnimationClassname();
|
|
392
|
+
if (isZoomedOut) {
|
|
393
|
+
iframeDocument.documentElement.classList.add('is-zoomed-out');
|
|
394
|
+
} else {
|
|
395
|
+
// HACK: Since we can't remove this in the cleanup, we need to do it here.
|
|
282
396
|
iframeDocument.documentElement.classList.remove('is-zoomed-out');
|
|
397
|
+
}
|
|
398
|
+
return () => {
|
|
399
|
+
// HACK: Skipping cleanup because it causes issues with the zoom out
|
|
400
|
+
// animation. More refactoring is needed to fix this properly.
|
|
401
|
+
// iframeDocument.documentElement.classList.remove( 'is-zoomed-out' );
|
|
283
402
|
};
|
|
284
403
|
}, [iframeDocument, isZoomedOut]);
|
|
285
404
|
|
|
286
405
|
// Calculate the scaling and CSS variables for the zoom out canvas
|
|
287
406
|
(0, _element.useEffect)(() => {
|
|
288
|
-
if (!iframeDocument
|
|
407
|
+
if (!iframeDocument) {
|
|
289
408
|
return;
|
|
290
409
|
}
|
|
291
|
-
|
|
410
|
+
|
|
292
411
|
// Note: When we initialize the zoom out when the canvas is smaller (sidebars open),
|
|
293
412
|
// initialContainerWidthRef will be smaller than the full page, and reflow will happen
|
|
294
413
|
// when the canvas area becomes larger due to sidebars closing. This is a known but
|
|
@@ -297,7 +416,7 @@ function Iframe({
|
|
|
297
416
|
// This scaling calculation has to happen within the JS because CSS calc() can
|
|
298
417
|
// only divide and multiply by a unitless value. I.e. calc( 100px / 2 ) is valid
|
|
299
418
|
// but calc( 100px / 2px ) is not.
|
|
300
|
-
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-scale',
|
|
419
|
+
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-scale', scaleValue);
|
|
301
420
|
|
|
302
421
|
// frameSize has to be a px value for the scaling and frame size to be computed correctly.
|
|
303
422
|
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-frame-size', typeof frameSize === 'number' ? `${frameSize}px` : frameSize);
|
|
@@ -306,14 +425,28 @@ function Iframe({
|
|
|
306
425
|
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-container-width', `${containerWidth}px`);
|
|
307
426
|
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-scale-container-width', `${scaleContainerWidth}px`);
|
|
308
427
|
return () => {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
iframeDocument.documentElement.style.removeProperty(
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
iframeDocument.documentElement.style.removeProperty(
|
|
428
|
+
// HACK: Skipping cleanup because it causes issues with the zoom out
|
|
429
|
+
// animation. More refactoring is needed to fix this properly.
|
|
430
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
431
|
+
// '--wp-block-editor-iframe-zoom-out-scale'
|
|
432
|
+
// );
|
|
433
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
434
|
+
// '--wp-block-editor-iframe-zoom-out-frame-size'
|
|
435
|
+
// );
|
|
436
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
437
|
+
// '--wp-block-editor-iframe-zoom-out-content-height'
|
|
438
|
+
// );
|
|
439
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
440
|
+
// '--wp-block-editor-iframe-zoom-out-inner-height'
|
|
441
|
+
// );
|
|
442
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
443
|
+
// '--wp-block-editor-iframe-zoom-out-container-width'
|
|
444
|
+
// );
|
|
445
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
446
|
+
// '--wp-block-editor-iframe-zoom-out-scale-container-width'
|
|
447
|
+
// );
|
|
315
448
|
};
|
|
316
|
-
}, [
|
|
449
|
+
}, [scaleValue, frameSize, iframeDocument, iframeWindowInnerHeight, contentHeight, containerWidth, windowInnerWidth, isZoomedOut, scaleContainerWidth]);
|
|
317
450
|
|
|
318
451
|
// Make sure to not render the before and after focusable div elements in view
|
|
319
452
|
// mode. They're only needed to capture focus in edit mode.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_element","_i18n","_compose","_components","_data","_blockSelectionClearer","_writingFlow","_getCompatibilityStyles","_store","_jsxRuntime","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","styles","scripts","setIframeDocument","useState","initialContainerWidthRef","useRef","bodyClasses","setBodyClasses","clearerRef","useBlockSelectionClearer","before","writingFlowRef","after","useWritingFlow","contentResizeListener","height","contentHeight","useResizeObserver","containerResizeListener","width","containerWidth","setRef","node","_load","iFrameDocument","preventFileDropDefault","onLoad","ownerDocument","classList","add","Array","from","body","filter","startsWith","dir","compatStyle","getCompatibilityStyles","getElementById","id","head","appendChild","cloneNode","console","warn","iframeWindowInnerHeight","setIframeWindowInnerHeight","iframeResizeRef","nodeWindow","innerHeight","onResize","windowInnerWidth","setWindowInnerWidth","windowResizeRef","innerWidth","isZoomedOut","useEffect","current","scaleContainerWidth","Math","max","disabledRef","useDisabled","isDisabled","bodyRef","useMergeRefs","src","cleanup","useMemo","_src","URL","createObjectURL","Blob","revokeObjectURL","zoomOutAnimationClassnameRef","handleZoomOutAnimationClassname","clearTimeout","setTimeout","remove","maxWidth","style","setProperty","min","parseInt","removeProperty","shouldRenderFocusCaptureElements","iframe","jsxs","Fragment","jsx","border","onKeyDown","currentTarget","target","stopPropagation","nativeEvent","KeyboardEvent","createPortal","className","clsx","__experimentalStyleProvider","document","IframeIfReady","isInitialised","__internalIsInitialized","_default","exports","default","forwardRef"],"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseEffect,\n\tuseRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\nimport { getCompatibilityStyles } from './get-compatibility-styles';\nimport { store as blockEditorStore } from '../../store';\n\nfunction bubbleEvent( event, Constructor, frame ) {\n\tconst init = {};\n\n\tfor ( const key in event ) {\n\t\tinit[ key ] = event[ key ];\n\t}\n\n\t// Check if the event is a MouseEvent generated within the iframe.\n\t// If so, adjust the coordinates to be relative to the position of\n\t// the iframe. This ensures that components such as Draggable\n\t// receive coordinates relative to the window, instead of relative\n\t// to the iframe. Without this, the Draggable event handler would\n\t// result in components \"jumping\" position as soon as the user\n\t// drags over the iframe.\n\tif ( event instanceof frame.contentDocument.defaultView.MouseEvent ) {\n\t\tconst rect = frame.getBoundingClientRect();\n\t\tinit.clientX += rect.left;\n\t\tinit.clientY += rect.top;\n\t}\n\n\tconst newEvent = new Constructor( event.type, init );\n\tif ( init.defaultPrevented ) {\n\t\tnewEvent.preventDefault();\n\t}\n\tconst cancelled = ! frame.dispatchEvent( newEvent );\n\n\tif ( cancelled ) {\n\t\tevent.preventDefault();\n\t}\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} iframeDocument Document to attach listeners to.\n */\nfunction useBubbleEvents( iframeDocument ) {\n\treturn useRefEffect( () => {\n\t\tconst { defaultView } = iframeDocument;\n\t\tif ( ! defaultView ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { frameElement } = defaultView;\n\t\tconst html = iframeDocument.documentElement;\n\t\tconst eventTypes = [ 'dragover', 'mousemove' ];\n\t\tconst handlers = {};\n\t\tfor ( const name of eventTypes ) {\n\t\t\thandlers[ name ] = ( event ) => {\n\t\t\t\tconst prototype = Object.getPrototypeOf( event );\n\t\t\t\tconst constructorName = prototype.constructor.name;\n\t\t\t\tconst Constructor = window[ constructorName ];\n\t\t\t\tbubbleEvent( event, Constructor, frameElement );\n\t\t\t};\n\t\t\thtml.addEventListener( name, handlers[ name ] );\n\t\t}\n\n\t\treturn () => {\n\t\t\tfor ( const name of eventTypes ) {\n\t\t\t\thtml.removeEventListener( name, handlers[ name ] );\n\t\t\t}\n\t\t};\n\t} );\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\ttabIndex = 0,\n\tscale = 1,\n\tframeSize = 0,\n\treadonly,\n\tforwardedRef: ref,\n\ttitle = __( 'Editor canvas' ),\n\t...props\n} ) {\n\tconst { resolvedAssets, isPreviewMode } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\t\treturn {\n\t\t\tresolvedAssets: settings.__unstableResolvedAssets,\n\t\t\tisPreviewMode: settings.isPreviewMode,\n\t\t};\n\t}, [] );\n\tconst { styles = '', scripts = '' } = resolvedAssets;\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst initialContainerWidthRef = useRef( 0 );\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst [ containerResizeListener, { width: containerWidth } ] =\n\t\tuseResizeObserver();\n\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tnode._load = () => {\n\t\t\tsetIframeDocument( node.contentDocument );\n\t\t};\n\t\tlet iFrameDocument;\n\t\t// Prevent the default browser action for files dropped outside of dropzones.\n\t\tfunction preventFileDropDefault( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tfunction onLoad() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tdocumentElement.classList.add( 'block-editor-iframe__html' );\n\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\n\t\t\tfor ( const compatStyle of getCompatibilityStyles() ) {\n\t\t\t\tif ( contentDocument.getElementById( compatStyle.id ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcontentDocument.head.appendChild(\n\t\t\t\t\tcompatStyle.cloneNode( true )\n\t\t\t\t);\n\n\t\t\t\tif ( ! isPreviewMode ) {\n\t\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`${ compatStyle.id } was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.`,\n\t\t\t\t\t\tcompatStyle\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'load', onLoad );\n\n\t\treturn () => {\n\t\t\tdelete node._load;\n\t\t\tnode.removeEventListener( 'load', onLoad );\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst [ iframeWindowInnerHeight, setIframeWindowInnerHeight ] = useState();\n\n\tconst iframeResizeRef = useRefEffect( ( node ) => {\n\t\tconst nodeWindow = node.ownerDocument.defaultView;\n\n\t\tsetIframeWindowInnerHeight( nodeWindow.innerHeight );\n\t\tconst onResize = () => {\n\t\t\tsetIframeWindowInnerHeight( nodeWindow.innerHeight );\n\t\t};\n\t\tnodeWindow.addEventListener( 'resize', onResize );\n\t\treturn () => {\n\t\t\tnodeWindow.removeEventListener( 'resize', onResize );\n\t\t};\n\t}, [] );\n\n\tconst [ windowInnerWidth, setWindowInnerWidth ] = useState();\n\n\tconst windowResizeRef = useRefEffect( ( node ) => {\n\t\tconst nodeWindow = node.ownerDocument.defaultView;\n\n\t\tsetWindowInnerWidth( nodeWindow.innerWidth );\n\t\tconst onResize = () => {\n\t\t\tsetWindowInnerWidth( nodeWindow.innerWidth );\n\t\t};\n\t\tnodeWindow.addEventListener( 'resize', onResize );\n\t\treturn () => {\n\t\t\tnodeWindow.removeEventListener( 'resize', onResize );\n\t\t};\n\t}, [] );\n\n\tconst isZoomedOut = scale !== 1;\n\n\tuseEffect( () => {\n\t\tif ( ! isZoomedOut ) {\n\t\t\tinitialContainerWidthRef.current = containerWidth;\n\t\t}\n\t}, [ containerWidth, isZoomedOut ] );\n\n\tconst scaleContainerWidth = Math.max(\n\t\tinitialContainerWidthRef.current,\n\t\tcontainerWidth\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\t// Avoid resize listeners when not needed, these will trigger\n\t\t// unnecessary re-renders when animating the iframe width, or when\n\t\t// expanding preview iframes.\n\t\tisZoomedOut ? iframeResizeRef : null,\n\t] );\n\n\t// Correct doctype is required to enable rendering in standards\n\t// mode. Also preload the styles to avoid a flash of unstyled\n\t// content.\n\tconst html = `<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset=\"utf-8\">\n\t\t<script>window.frameElement._load()</script>\n\t\t<style>\n\t\t\thtml{\n\t\t\t\theight: auto !important;\n\t\t\t\tmin-height: 100%;\n\t\t\t}\n\t\t\t/* Lowest specificity to not override global styles */\n\t\t\t:where(body) {\n\t\t\t\tmargin: 0;\n\t\t\t\t/* Default background color in case zoom out mode background\n\t\t\t\tcolors the html element */\n\t\t\t\tbackground-color: white;\n\t\t\t}\n\t\t</style>\n\t\t${ styles }\n\t\t${ scripts }\n\t</head>\n\t<body>\n\t\t<script>document.currentScript.parentElement.remove()</script>\n\t</body>\n</html>`;\n\n\tconst [ src, cleanup ] = useMemo( () => {\n\t\tconst _src = URL.createObjectURL(\n\t\t\tnew window.Blob( [ html ], { type: 'text/html' } )\n\t\t);\n\t\treturn [ _src, () => URL.revokeObjectURL( _src ) ];\n\t}, [ html ] );\n\n\tuseEffect( () => cleanup, [ cleanup ] );\n\n\tconst zoomOutAnimationClassnameRef = useRef( null );\n\n\t// Toggle zoom out CSS Classes only when zoom out mode changes. We could add these into the useEffect\n\t// that controls settings the CSS variables, but then we would need to do more work to ensure we're\n\t// only toggling these when the zoom out mode changes, as that useEffect is also triggered by a large\n\t// number of dependencies.\n\tuseEffect( () => {\n\t\tif ( ! iframeDocument || ! isZoomedOut ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst handleZoomOutAnimationClassname = () => {\n\t\t\tclearTimeout( zoomOutAnimationClassnameRef.current );\n\n\t\t\tiframeDocument.documentElement.classList.add(\n\t\t\t\t'zoom-out-animation'\n\t\t\t);\n\n\t\t\tzoomOutAnimationClassnameRef.current = setTimeout( () => {\n\t\t\t\tiframeDocument.documentElement.classList.remove(\n\t\t\t\t\t'zoom-out-animation'\n\t\t\t\t);\n\t\t\t}, 400 ); // 400ms should match the animation speed used in components/iframe/content.scss\n\t\t};\n\n\t\thandleZoomOutAnimationClassname();\n\t\tiframeDocument.documentElement.classList.add( 'is-zoomed-out' );\n\n\t\treturn () => {\n\t\t\thandleZoomOutAnimationClassname();\n\t\t\tiframeDocument.documentElement.classList.remove( 'is-zoomed-out' );\n\t\t};\n\t}, [ iframeDocument, isZoomedOut ] );\n\n\t// Calculate the scaling and CSS variables for the zoom out canvas\n\tuseEffect( () => {\n\t\tif ( ! iframeDocument || ! isZoomedOut ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst maxWidth = 750;\n\t\t// Note: When we initialize the zoom out when the canvas is smaller (sidebars open),\n\t\t// initialContainerWidthRef will be smaller than the full page, and reflow will happen\n\t\t// when the canvas area becomes larger due to sidebars closing. This is a known but\n\t\t// minor divergence for now.\n\n\t\t// This scaling calculation has to happen within the JS because CSS calc() can\n\t\t// only divide and multiply by a unitless value. I.e. calc( 100px / 2 ) is valid\n\t\t// but calc( 100px / 2px ) is not.\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scale',\n\t\t\tscale === 'auto-scaled'\n\t\t\t\t? ( Math.min( containerWidth, maxWidth ) -\n\t\t\t\t\t\tparseInt( frameSize ) * 2 ) /\n\t\t\t\t\t\tscaleContainerWidth\n\t\t\t\t: scale\n\t\t);\n\n\t\t// frameSize has to be a px value for the scaling and frame size to be computed correctly.\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-frame-size',\n\t\t\ttypeof frameSize === 'number' ? `${ frameSize }px` : frameSize\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-content-height',\n\t\t\t`${ contentHeight }px`\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-inner-height',\n\t\t\t`${ iframeWindowInnerHeight }px`\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-container-width',\n\t\t\t`${ containerWidth }px`\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scale-container-width',\n\t\t\t`${ scaleContainerWidth }px`\n\t\t);\n\n\t\treturn () => {\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-frame-size'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-content-height'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-inner-height'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-container-width'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale-container-width'\n\t\t\t);\n\t\t};\n\t}, [\n\t\tscale,\n\t\tframeSize,\n\t\tiframeDocument,\n\t\tiframeWindowInnerHeight,\n\t\tcontentHeight,\n\t\tcontainerWidth,\n\t\twindowInnerWidth,\n\t\tisZoomedOut,\n\t\tscaleContainerWidth,\n\t] );\n\n\t// Make sure to not render the before and after focusable div elements in view\n\t// mode. They're only needed to capture focus in edit mode.\n\tconst shouldRenderFocusCaptureElements = tabIndex >= 0 && ! isPreviewMode;\n\n\tconst iframe = (\n\t\t<>\n\t\t\t{ shouldRenderFocusCaptureElements && before }\n\t\t\t{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tstyle={ {\n\t\t\t\t\t...props.style,\n\t\t\t\t\theight: props.style?.height,\n\t\t\t\t\tborder: 0,\n\t\t\t\t} }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards\n\t\t\t\t// mode. Also preload the styles to avoid a flash of unstyled\n\t\t\t\t// content.\n\t\t\t\tsrc={ src }\n\t\t\t\ttitle={ title }\n\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\tif ( props.onKeyDown ) {\n\t\t\t\t\t\tprops.onKeyDown( event );\n\t\t\t\t\t}\n\t\t\t\t\t// If the event originates from inside the iframe, it means\n\t\t\t\t\t// it bubbled through the portal, but only with React\n\t\t\t\t\t// events. We need to to bubble native events as well,\n\t\t\t\t\t// though by doing so we also trigger another React event,\n\t\t\t\t\t// so we need to stop the propagation of this event to avoid\n\t\t\t\t\t// duplication.\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.currentTarget.ownerDocument !==\n\t\t\t\t\t\tevent.target.ownerDocument\n\t\t\t\t\t) {\n\t\t\t\t\t\t// We should only stop propagation of the React event,\n\t\t\t\t\t\t// the native event should further bubble inside the\n\t\t\t\t\t\t// iframe to the document and window.\n\t\t\t\t\t\t// Alternatively, we could consider redispatching the\n\t\t\t\t\t\t// native event in the iframe.\n\t\t\t\t\t\tconst { stopPropagation } = event.nativeEvent;\n\t\t\t\t\t\tevent.nativeEvent.stopPropagation = () => {};\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tevent.nativeEvent.stopPropagation = stopPropagation;\n\t\t\t\t\t\tbubbleEvent(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\twindow.KeyboardEvent,\n\t\t\t\t\t\t\tevent.currentTarget\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t// We want to prevent React events from bubbling throught the iframe\n\t\t\t\t\t\t// we bubble these manually.\n\t\t\t\t\t\t/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */\n\t\t\t\t\t\t<body\n\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t'editor-styles-wrapper',\n\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t</body>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ shouldRenderFocusCaptureElements && after }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-iframe__container\" ref={ windowResizeRef }>\n\t\t\t{ containerResizeListener }\n\t\t\t<div\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-editor-iframe__scale-container',\n\t\t\t\t\tisZoomedOut && 'is-zoomed-out'\n\t\t\t\t) }\n\t\t\t\tstyle={ {\n\t\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale-container-width':\n\t\t\t\t\t\tisZoomedOut && `${ scaleContainerWidth }px`,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ iframe }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nfunction IframeIfReady( props, ref ) {\n\tconst isInitialised = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__internalIsInitialized,\n\t\t[]\n\t);\n\n\t// We shouldn't render the iframe until the editor settings are initialised.\n\t// The initial settings are needed to get the styles for the srcDoc, which\n\t// cannot be changed after the iframe is mounted. srcDoc is used to to set\n\t// the initial iframe HTML, which is required to avoid a flash of unstyled\n\t// content.\n\tif ( ! isInitialised ) {\n\t\treturn null;\n\t}\n\n\treturn <Iframe { ...props } forwardedRef={ ref } />;\n}\n\nexport default forwardRef( IframeIfReady );\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAQA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAMA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,sBAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,uBAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AAAwD,IAAAU,WAAA,GAAAV,OAAA;AAhCxD;AACA;AACA;;AAGA;AACA;AACA;;AAmBA;AACA;AACA;;AAMA,SAASW,WAAWA,CAAEC,KAAK,EAAEC,WAAW,EAAEC,KAAK,EAAG;EACjD,MAAMC,IAAI,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;EAAA,CAC1C,CACF;EAED,oBACC,IAAAvE,WAAA,CAAAkJ,IAAA;IAAKW,SAAS,EAAC,gCAAgC;IAAC9G,GAAG,EAAGiE,eAAiB;IAAAvE,QAAA,GACpEoC,uBAAuB,eACzB,IAAA7E,WAAA,CAAAoJ,GAAA;MACCS,SAAS,EAAG,IAAAC,aAAI,EACf,sCAAsC,EACtC5C,WAAW,IAAI,eAChB,CAAG;MACHyB,KAAK,EAAG;QACP,yDAAyD,EACxDzB,WAAW,IAAI,GAAIG,mBAAmB;MACxC,CAAG;MAAA5E,QAAA,EAEDwG;IAAM,CACJ,CAAC;EAAA,CACF,CAAC;AAER;AAEA,SAASgB,aAAaA,CAAE/G,KAAK,EAAEH,GAAG,EAAG;EACpC,MAAMmH,aAAa,GAAG,IAAA7G,eAAS,EAC5BC,MAAM,IACPA,MAAM,CAAEE,YAAiB,CAAC,CAACD,WAAW,CAAC,CAAC,CAAC4G,uBAAuB,EACjE,EACD,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA,IAAK,CAAED,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,oBAAO,IAAAlK,WAAA,CAAAoJ,GAAA,EAAC7G,MAAM;IAAA,GAAMW,KAAK;IAAGJ,YAAY,EAAGC;EAAK,CAAE,CAAC;AACpD;AAAC,IAAAqH,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,mBAAU,EAAEN,aAAc,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_element","_i18n","_compose","_components","_data","_blockSelectionClearer","_writingFlow","_getCompatibilityStyles","_store","_jsxRuntime","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","styles","scripts","setIframeDocument","useState","initialContainerWidthRef","useRef","bodyClasses","setBodyClasses","clearerRef","useBlockSelectionClearer","before","writingFlowRef","after","useWritingFlow","contentResizeListener","height","contentHeight","useResizeObserver","containerResizeListener","width","containerWidth","prefersReducedMotion","useReducedMotion","setRef","node","_load","iFrameDocument","preventFileDropDefault","onLoad","ownerDocument","classList","add","Array","from","body","filter","startsWith","dir","compatStyle","getCompatibilityStyles","getElementById","id","head","appendChild","cloneNode","console","warn","target","tagName","href","getAttribute","location","hash","slice","iframeWindowInnerHeight","setIframeWindowInnerHeight","iframeResizeRef","nodeWindow","innerHeight","onResize","windowInnerWidth","setWindowInnerWidth","windowResizeRef","innerWidth","isZoomedOut","useEffect","current","scaleContainerWidth","Math","max","frameSizeValue","parseInt","maxWidth","scaleValue","min","prevScaleRef","prevFrameSizeRef","prevClientHeightRef","disabledRef","useDisabled","isDisabled","bodyRef","useMergeRefs","origin","src","cleanup","useMemo","_src","URL","createObjectURL","Blob","revokeObjectURL","_prevClientHeightRef$","clientHeight","scrollHeight","prevScale","prevFrameSize","prevClientHeight","scrollTop","scrollTopNext","maxScrollTop","round","style","setProperty","onZoomOutTransitionEnd","remove","raf","requestAnimationFrame","once","removeProperty","cancelAnimationFrame","shouldRenderFocusCaptureElements","iframe","jsxs","Fragment","jsx","border","onKeyDown","currentTarget","stopPropagation","nativeEvent","KeyboardEvent","createPortal","className","clsx","__experimentalStyleProvider","document","IframeIfReady","isInitialised","__internalIsInitialized","_default","exports","default","forwardRef"],"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseEffect,\n\tuseRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n\tuseReducedMotion,\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.isPreviewMode,\n\t\t};\n\t}, [] );\n\tconst { styles = '', scripts = '' } = resolvedAssets;\n\t/** @type {[Document, import('react').Dispatch<Document>]} */\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst initialContainerWidthRef = useRef( 0 );\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst [ containerResizeListener, { width: containerWidth } ] =\n\t\tuseResizeObserver();\n\tconst prefersReducedMotion = useReducedMotion();\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\t// Prevent clicks on links from navigating away. Note that links\n\t\t\t// inside `contenteditable` are already disabled by the browser, so\n\t\t\t// this is for links in blocks outside of `contenteditable`.\n\t\t\tiFrameDocument.addEventListener( 'click', ( event ) => {\n\t\t\t\tif ( event.target.tagName === 'A' ) {\n\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t// Appending a hash to the current URL will not reload the\n\t\t\t\t\t// page. This is useful for e.g. footnotes.\n\t\t\t\t\tconst href = event.target.getAttribute( 'href' );\n\t\t\t\t\tif ( href.startsWith( '#' ) ) {\n\t\t\t\t\t\tiFrameDocument.defaultView.location.hash =\n\t\t\t\t\t\t\thref.slice( 1 );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\tnode.addEventListener( 'load', onLoad );\n\n\t\treturn () => {\n\t\t\tdelete node._load;\n\t\t\tnode.removeEventListener( 'load', onLoad );\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst [ iframeWindowInnerHeight, setIframeWindowInnerHeight ] = useState();\n\n\tconst iframeResizeRef = useRefEffect( ( node ) => {\n\t\tconst nodeWindow = node.ownerDocument.defaultView;\n\n\t\tsetIframeWindowInnerHeight( nodeWindow.innerHeight );\n\t\tconst onResize = () => {\n\t\t\tsetIframeWindowInnerHeight( nodeWindow.innerHeight );\n\t\t};\n\t\tnodeWindow.addEventListener( 'resize', onResize );\n\t\treturn () => {\n\t\t\tnodeWindow.removeEventListener( 'resize', onResize );\n\t\t};\n\t}, [] );\n\n\tconst [ windowInnerWidth, setWindowInnerWidth ] = useState();\n\n\tconst windowResizeRef = useRefEffect( ( node ) => {\n\t\tconst nodeWindow = node.ownerDocument.defaultView;\n\n\t\tsetWindowInnerWidth( nodeWindow.innerWidth );\n\t\tconst onResize = () => {\n\t\t\tsetWindowInnerWidth( nodeWindow.innerWidth );\n\t\t};\n\t\tnodeWindow.addEventListener( 'resize', onResize );\n\t\treturn () => {\n\t\t\tnodeWindow.removeEventListener( 'resize', onResize );\n\t\t};\n\t}, [] );\n\n\tconst isZoomedOut = scale !== 1;\n\n\tuseEffect( () => {\n\t\tif ( ! isZoomedOut ) {\n\t\t\tinitialContainerWidthRef.current = containerWidth;\n\t\t}\n\t}, [ containerWidth, isZoomedOut ] );\n\n\tconst scaleContainerWidth = Math.max(\n\t\tinitialContainerWidthRef.current,\n\t\tcontainerWidth\n\t);\n\n\tconst frameSizeValue = parseInt( frameSize );\n\n\tconst maxWidth = 750;\n\tconst scaleValue =\n\t\tscale === 'auto-scaled'\n\t\t\t? ( Math.min( containerWidth, maxWidth ) - frameSizeValue * 2 ) /\n\t\t\t scaleContainerWidth\n\t\t\t: scale;\n\n\tconst prevScaleRef = useRef( scaleValue );\n\tconst prevFrameSizeRef = useRef( frameSizeValue );\n\tconst prevClientHeightRef = useRef( /* Initialized in the useEffect. */ );\n\n\tconst disabledRef = useDisabled( { isDisabled: ! readonly } );\n\tconst bodyRef = useMergeRefs( [\n\t\tuseBubbleEvents( iframeDocument ),\n\t\tcontentRef,\n\t\tclearerRef,\n\t\twritingFlowRef,\n\t\tdisabledRef,\n\t\t// Avoid resize listeners when not needed, these will trigger\n\t\t// unnecessary re-renders when animating the iframe width, or when\n\t\t// expanding preview iframes.\n\t\tisZoomedOut ? iframeResizeRef : null,\n\t] );\n\n\t// Correct doctype is required to enable rendering in standards\n\t// mode. Also preload the styles to avoid a flash of unstyled\n\t// content.\n\tconst html = `<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset=\"utf-8\">\n\t\t<base href=\"${ window.location.origin }\">\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 (\n\t\t\t! iframeDocument ||\n\t\t\t// HACK: Checking if isZoomedOut differs from prevIsZoomedOut here\n\t\t\t// instead of the dependency array to appease the linter.\n\t\t\t( scaleValue === 1 ) === ( prevScaleRef.current === 1 )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Unscaled height of the current iframe container.\n\t\tconst clientHeight = iframeDocument.documentElement.clientHeight;\n\n\t\t// Scaled height of the current iframe content.\n\t\tconst scrollHeight = iframeDocument.documentElement.scrollHeight;\n\n\t\t// Previous scale value.\n\t\tconst prevScale = prevScaleRef.current;\n\n\t\t// Unscaled size of the previous padding around the iframe content.\n\t\tconst prevFrameSize = prevFrameSizeRef.current;\n\n\t\t// Unscaled height of the previous iframe container.\n\t\tconst prevClientHeight = prevClientHeightRef.current ?? clientHeight;\n\n\t\t// We can't trust the set value from contentHeight, as it was measured\n\t\t// before the zoom out mode was changed. After zoom out mode is changed,\n\t\t// appenders may appear or disappear, so we need to get the height from\n\t\t// the iframe at this point when we're about to animate the zoom out.\n\t\t// The iframe scrollTop, scrollHeight, and clientHeight will all be\n\t\t// accurate. The client height also does change when the zoom out mode\n\t\t// is toggled, as the bottom bar about selecting the template is\n\t\t// added/removed when toggling zoom out mode.\n\t\tconst scrollTop = iframeDocument.documentElement.scrollTop;\n\n\t\t// Step 0: Start with the current scrollTop.\n\t\tlet scrollTopNext = scrollTop;\n\n\t\t// Step 1: Undo the effects of the previous scale and frame around the\n\t\t// midpoint of the visible area.\n\t\tscrollTopNext =\n\t\t\t( scrollTopNext + prevClientHeight / 2 - prevFrameSize ) /\n\t\t\t\tprevScale -\n\t\t\tprevClientHeight / 2;\n\n\t\t// Step 2: Apply the new scale and frame around the midpoint of the\n\t\t// visible area.\n\t\tscrollTopNext =\n\t\t\t( scrollTopNext + clientHeight / 2 ) * scaleValue +\n\t\t\tframeSizeValue -\n\t\t\tclientHeight / 2;\n\n\t\t// Step 3: Handle an edge case so that you scroll to the top of the\n\t\t// iframe if the top of the iframe content is visible in the container.\n\t\t// The same edge case for the bottom is skipped because changing content\n\t\t// makes calculating it impossible.\n\t\tscrollTopNext = scrollTop <= prevFrameSize ? 0 : scrollTopNext;\n\n\t\t// This is the scrollTop value if you are scrolled to the bottom of the\n\t\t// iframe. We can't just let the browser handle it because we need to\n\t\t// animate the scaling.\n\t\tconst maxScrollTop =\n\t\t\tscrollHeight * ( scaleValue / prevScale ) +\n\t\t\tframeSizeValue * 2 -\n\t\t\tclientHeight;\n\n\t\t// Step 4: Clamp the scrollTopNext between the minimum and maximum\n\t\t// possible scrollTop positions. Round the value to avoid subpixel\n\t\t// truncation by the browser which sometimes causes a 1px error.\n\t\tscrollTopNext = Math.round(\n\t\t\tMath.min(\n\t\t\t\tMath.max( 0, scrollTopNext ),\n\t\t\t\tMath.max( 0, maxScrollTop )\n\t\t\t)\n\t\t);\n\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scroll-top',\n\t\t\t`${ scrollTop }px`\n\t\t);\n\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scroll-top-next',\n\t\t\t`${ scrollTopNext }px`\n\t\t);\n\n\t\tiframeDocument.documentElement.classList.add( 'zoom-out-animation' );\n\n\t\tfunction onZoomOutTransitionEnd() {\n\t\t\t// Remove the position fixed for the animation.\n\t\t\tiframeDocument.documentElement.classList.remove(\n\t\t\t\t'zoom-out-animation'\n\t\t\t);\n\n\t\t\t// Update previous values.\n\t\t\tprevClientHeightRef.current = clientHeight;\n\t\t\tprevFrameSizeRef.current = frameSizeValue;\n\t\t\tprevScaleRef.current = scaleValue;\n\n\t\t\t// Set the final scroll position that was just animated to.\n\t\t\t// Disable reason: Eslint isn't smart enough to know that this is a\n\t\t\t// DOM element. https://github.com/facebook/react/issues/31483\n\t\t\t// eslint-disable-next-line react-compiler/react-compiler\n\t\t\tiframeDocument.documentElement.scrollTop = scrollTopNext;\n\t\t}\n\n\t\tlet raf;\n\t\tif ( prefersReducedMotion ) {\n\t\t\t// Hack: Wait for the window values to recalculate.\n\t\t\traf = iframeDocument.defaultView.requestAnimationFrame(\n\t\t\t\tonZoomOutTransitionEnd\n\t\t\t);\n\t\t} else {\n\t\t\tiframeDocument.documentElement.addEventListener(\n\t\t\t\t'transitionend',\n\t\t\t\tonZoomOutTransitionEnd,\n\t\t\t\t{ once: true }\n\t\t\t);\n\t\t}\n\n\t\treturn () => {\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-scroll-top'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.style.removeProperty(\n\t\t\t\t'--wp-block-editor-iframe-zoom-out-scroll-top-next'\n\t\t\t);\n\t\t\tiframeDocument.documentElement.classList.remove(\n\t\t\t\t'zoom-out-animation'\n\t\t\t);\n\t\t\tif ( prefersReducedMotion ) {\n\t\t\t\tiframeDocument.defaultView.cancelAnimationFrame( raf );\n\t\t\t} else {\n\t\t\t\tiframeDocument.documentElement.removeEventListener(\n\t\t\t\t\t'transitionend',\n\t\t\t\t\tonZoomOutTransitionEnd\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t}, [ iframeDocument, scaleValue, frameSizeValue, prefersReducedMotion ] );\n\n\t// Toggle zoom out CSS Classes only when zoom out mode changes. We could add these into the useEffect\n\t// that controls settings the CSS variables, but then we would need to do more work to ensure we're\n\t// only toggling these when the zoom out mode changes, as that useEffect is also triggered by a large\n\t// number of dependencies.\n\tuseEffect( () => {\n\t\tif ( ! iframeDocument ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isZoomedOut ) {\n\t\t\tiframeDocument.documentElement.classList.add( 'is-zoomed-out' );\n\t\t} else {\n\t\t\t// HACK: Since we can't remove this in the cleanup, we need to do it here.\n\t\t\tiframeDocument.documentElement.classList.remove( 'is-zoomed-out' );\n\t\t}\n\n\t\treturn () => {\n\t\t\t// HACK: Skipping cleanup because it causes issues with the zoom out\n\t\t\t// animation. More refactoring is needed to fix this properly.\n\t\t\t// iframeDocument.documentElement.classList.remove( 'is-zoomed-out' );\n\t\t};\n\t}, [ iframeDocument, isZoomedOut ] );\n\n\t// Calculate the scaling and CSS variables for the zoom out canvas\n\tuseEffect( () => {\n\t\tif ( ! iframeDocument ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Note: When we initialize the zoom out when the canvas is smaller (sidebars open),\n\t\t// initialContainerWidthRef will be smaller than the full page, and reflow will happen\n\t\t// when the canvas area becomes larger due to sidebars closing. This is a known but\n\t\t// minor divergence for now.\n\n\t\t// This scaling calculation has to happen within the JS because CSS calc() can\n\t\t// only divide and multiply by a unitless value. I.e. calc( 100px / 2 ) is valid\n\t\t// but calc( 100px / 2px ) is not.\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scale',\n\t\t\tscaleValue\n\t\t);\n\n\t\t// frameSize has to be a px value for the scaling and frame size to be computed correctly.\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-frame-size',\n\t\t\ttypeof frameSize === 'number' ? `${ frameSize }px` : frameSize\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-content-height',\n\t\t\t`${ contentHeight }px`\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-inner-height',\n\t\t\t`${ iframeWindowInnerHeight }px`\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-container-width',\n\t\t\t`${ containerWidth }px`\n\t\t);\n\t\tiframeDocument.documentElement.style.setProperty(\n\t\t\t'--wp-block-editor-iframe-zoom-out-scale-container-width',\n\t\t\t`${ scaleContainerWidth }px`\n\t\t);\n\n\t\treturn () => {\n\t\t\t// HACK: Skipping cleanup because it causes issues with the zoom out\n\t\t\t// animation. More refactoring is needed to fix this properly.\n\t\t\t// iframeDocument.documentElement.style.removeProperty(\n\t\t\t// \t'--wp-block-editor-iframe-zoom-out-scale'\n\t\t\t// );\n\t\t\t// iframeDocument.documentElement.style.removeProperty(\n\t\t\t// \t'--wp-block-editor-iframe-zoom-out-frame-size'\n\t\t\t// );\n\t\t\t// iframeDocument.documentElement.style.removeProperty(\n\t\t\t// \t'--wp-block-editor-iframe-zoom-out-content-height'\n\t\t\t// );\n\t\t\t// iframeDocument.documentElement.style.removeProperty(\n\t\t\t// \t'--wp-block-editor-iframe-zoom-out-inner-height'\n\t\t\t// );\n\t\t\t// iframeDocument.documentElement.style.removeProperty(\n\t\t\t// \t'--wp-block-editor-iframe-zoom-out-container-width'\n\t\t\t// );\n\t\t\t// iframeDocument.documentElement.style.removeProperty(\n\t\t\t// \t'--wp-block-editor-iframe-zoom-out-scale-container-width'\n\t\t\t// );\n\t\t};\n\t}, [\n\t\tscaleValue,\n\t\tframeSize,\n\t\tiframeDocument,\n\t\tiframeWindowInnerHeight,\n\t\tcontentHeight,\n\t\tcontainerWidth,\n\t\twindowInnerWidth,\n\t\tisZoomedOut,\n\t\tscaleContainerWidth,\n\t] );\n\n\t// Make sure to not render the before and after focusable div elements in view\n\t// mode. They're only needed to capture focus in edit mode.\n\tconst shouldRenderFocusCaptureElements = tabIndex >= 0 && ! isPreviewMode;\n\n\tconst iframe = (\n\t\t<>\n\t\t\t{ shouldRenderFocusCaptureElements && before }\n\t\t\t{ /* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */ }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tstyle={ {\n\t\t\t\t\t...props.style,\n\t\t\t\t\theight: props.style?.height,\n\t\t\t\t\tborder: 0,\n\t\t\t\t} }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards\n\t\t\t\t// mode. Also preload the styles to avoid a flash of unstyled\n\t\t\t\t// content.\n\t\t\t\tsrc={ src }\n\t\t\t\ttitle={ title }\n\t\t\t\tonKeyDown={ ( event ) => {\n\t\t\t\t\tif ( props.onKeyDown ) {\n\t\t\t\t\t\tprops.onKeyDown( event );\n\t\t\t\t\t}\n\t\t\t\t\t// If the event originates from inside the iframe, it means\n\t\t\t\t\t// it bubbled through the portal, but only with React\n\t\t\t\t\t// events. We need to to bubble native events as well,\n\t\t\t\t\t// though by doing so we also trigger another React event,\n\t\t\t\t\t// so we need to stop the propagation of this event to avoid\n\t\t\t\t\t// duplication.\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.currentTarget.ownerDocument !==\n\t\t\t\t\t\tevent.target.ownerDocument\n\t\t\t\t\t) {\n\t\t\t\t\t\t// We should only stop propagation of the React event,\n\t\t\t\t\t\t// the native event should further bubble inside the\n\t\t\t\t\t\t// iframe to the document and window.\n\t\t\t\t\t\t// Alternatively, we could consider redispatching the\n\t\t\t\t\t\t// native event in the iframe.\n\t\t\t\t\t\tconst { stopPropagation } = event.nativeEvent;\n\t\t\t\t\t\tevent.nativeEvent.stopPropagation = () => {};\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tevent.nativeEvent.stopPropagation = stopPropagation;\n\t\t\t\t\t\tbubbleEvent(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\twindow.KeyboardEvent,\n\t\t\t\t\t\t\tevent.currentTarget\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t// We want to prevent React events from bubbling throught the iframe\n\t\t\t\t\t\t// we bubble these manually.\n\t\t\t\t\t\t/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions */\n\t\t\t\t\t\t<body\n\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\tclassName={ clsx(\n\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t'editor-styles-wrapper',\n\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t</body>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ shouldRenderFocusCaptureElements && after }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-iframe__container\" ref={ windowResizeRef }>\n\t\t\t{ containerResizeListener }\n\t\t\t<div\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-editor-iframe__scale-container',\n\t\t\t\t\tisZoomedOut && 'is-zoomed-out'\n\t\t\t\t) }\n\t\t\t\tstyle={ {\n\t\t\t\t\t'--wp-block-editor-iframe-zoom-out-scale-container-width':\n\t\t\t\t\t\tisZoomedOut && `${ scaleContainerWidth }px`,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ iframe }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nfunction IframeIfReady( props, ref ) {\n\tconst isInitialised = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__internalIsInitialized,\n\t\t[]\n\t);\n\n\t// We shouldn't render the iframe until the editor settings are initialised.\n\t// The initial settings are needed to get the styles for the srcDoc, which\n\t// cannot be changed after the iframe is mounted. srcDoc is used to to set\n\t// the initial iframe HTML, which is required to avoid a flash of unstyled\n\t// content.\n\tif ( ! isInitialised ) {\n\t\treturn null;\n\t}\n\n\treturn <Iframe { ...props } forwardedRef={ ref } />;\n}\n\nexport default forwardRef( IframeIfReady );\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAQA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAOA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,sBAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,uBAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AAAwD,IAAAU,WAAA,GAAAV,OAAA;AAjCxD;AACA;AACA;;AAGA;AACA;AACA;;AAoBA;AACA;AACA;;AAMA,SAASW,WAAWA,CAAEC,KAAK,EAAEC,WAAW,EAAEC,KAAK,EAAG;EACjD,MAAMC,IAAI,GAAG,CAAC,CAAC;EAEf,KAAM,MAAMC,GAAG,IAAIJ,KAAK,EAAG;IAC1BG,IAAI,CAAEC,GAAG,CAAE,GAAGJ,KAAK,CAAEI,GAAG,CAAE;EAC3B;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAKJ,KAAK,YAAYE,KAAK,CAACG,eAAe,CAACC,WAAW,CAACC,UAAU,EAAG;IACpE,MAAMC,IAAI,GAAGN,KAAK,CAACO,qBAAqB,CAAC,CAAC;IAC1CN,IAAI,CAACO,OAAO,IAAIF,IAA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AAKU,SAAS,EAAC,gCAAgC;IAACvI,GAAG,EAAG0E,eAAiB;IAAAhF,QAAA,GACpEoC,uBAAuB,eACzB,IAAA7E,WAAA,CAAA8K,GAAA;MACCQ,SAAS,EAAG,IAAAC,aAAI,EACf,sCAAsC,EACtC5D,WAAW,IAAI,eAChB,CAAG;MACHsC,KAAK,EAAG;QACP,yDAAyD,EACxDtC,WAAW,IAAI,GAAIG,mBAAmB;MACxC,CAAG;MAAArF,QAAA,EAEDkI;IAAM,CACJ,CAAC;EAAA,CACF,CAAC;AAER;AAEA,SAASe,aAAaA,CAAExI,KAAK,EAAEH,GAAG,EAAG;EACpC,MAAM4I,aAAa,GAAG,IAAAtI,eAAS,EAC5BC,MAAM,IACPA,MAAM,CAAEE,YAAiB,CAAC,CAACD,WAAW,CAAC,CAAC,CAACqI,uBAAuB,EACjE,EACD,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA,IAAK,CAAED,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,oBAAO,IAAA3L,WAAA,CAAA8K,GAAA,EAACvI,MAAM;IAAA,GAAMW,KAAK;IAAGJ,YAAY,EAAGC;EAAK,CAAE,CAAC;AACpD;AAAC,IAAA8I,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc,IAAAC,mBAAU,EAAEN,aAAc,CAAC","ignoreList":[]}
|
|
@@ -65,7 +65,8 @@ function PatternList({
|
|
|
65
65
|
return true;
|
|
66
66
|
}
|
|
67
67
|
if (selectedCategory === 'uncategorized') {
|
|
68
|
-
|
|
68
|
+
var _pattern$categories$s;
|
|
69
|
+
const hasKnownCategory = (_pattern$categories$s = pattern.categories?.some(category => registeredPatternCategories.includes(category))) !== null && _pattern$categories$s !== void 0 ? _pattern$categories$s : false;
|
|
69
70
|
return !pattern.categories?.length || !hasKnownCategory;
|
|
70
71
|
}
|
|
71
72
|
return pattern.categories?.includes(selectedCategory);
|
|
@@ -104,7 +105,6 @@ function PatternList({
|
|
|
104
105
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_inserterListbox.default, {
|
|
105
106
|
children: hasItems && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
106
107
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockPatternsList.default, {
|
|
107
|
-
shownPatterns: pagingProps.categoryPatternsAsyncList,
|
|
108
108
|
blockPatterns: pagingProps.categoryPatterns,
|
|
109
109
|
onClickPattern: onClickPattern,
|
|
110
110
|
isDraggable: false
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_i18n","_compose","_components","_a11y","_blockPatternsList","_interopRequireDefault","_useInsertionPoint","_usePatternsState","_inserterListbox","_searchItems","_blockPatternsPaging","_usePatternsPaging","_utils","_jsxRuntime","PatternsListHeader","filterValue","filteredBlockPatternsLength","jsx","__experimentalHeading","level","lineHeight","className","children","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","jsxs","ref","default","Fragment","
|
|
1
|
+
{"version":3,"names":["_element","require","_i18n","_compose","_components","_a11y","_blockPatternsList","_interopRequireDefault","_useInsertionPoint","_usePatternsState","_inserterListbox","_searchItems","_blockPatternsPaging","_usePatternsPaging","_utils","_jsxRuntime","PatternsListHeader","filterValue","filteredBlockPatternsLength","jsx","__experimentalHeading","level","lineHeight","className","children","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","_pattern$categories$s","hasKnownCategory","categories","some","category","includes","length","searchItems","useEffect","count","resultsFoundMessage","pagingProps","usePatternsPaging","previousSearchValue","setPreviousSearchValue","useState","changePage","hasItems","jsxs","ref","default","Fragment","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\tselectedCategory\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 =\n\t\t\t\t\tpattern.categories?.some( ( category ) =>\n\t\t\t\t\t\tregisteredPatternCategories.includes( category )\n\t\t\t\t\t) ?? false;\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\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,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,kBA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wC,WAAW,EAAG;QAAO,CACrB,CAAC,eACF,IAAAnE,WAAA,CAAAI,GAAA,EAACP,oBAAA,CAAAkE,OAAmB;UAAA,GAAMT;QAAW,CAAI,CAAC;MAAA,CACzC;IACF,CACe,CAAC;EAAA,CACd,CAAC;AAER;AAAC,IAAAc,QAAA,GAAAC,OAAA,CAAAN,OAAA,GAEcnD,WAAW","ignoreList":[]}
|
|
@@ -69,8 +69,7 @@ function BlockPatternsTab({
|
|
|
69
69
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_patternCategoryPreviews.PatternCategoryPreviews, {
|
|
70
70
|
onInsert: onInsert,
|
|
71
71
|
rootClientId: rootClientId,
|
|
72
|
-
category: category
|
|
73
|
-
showTitlesAsTooltip: false
|
|
72
|
+
category: category
|
|
74
73
|
}, category.name)
|
|
75
74
|
})
|
|
76
75
|
}), showPatternsExplorer && /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockPatternsExplorer.default, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_compose","_components","_i18n","_data","_blockPatternsExplorer","_interopRequireDefault","_mobileTabNavigation","_patternCategoryPreviews","_usePatternCategories","_categoryTabs","_noResults","_store","_lockUnlock","_jsxRuntime","BlockPatternsTab","onSelectCategory","selectedCategory","onInsert","rootClientId","children","showPatternsExplorer","setShowPatternsExplorer","useState","categories","usePatternCategories","isMobile","useViewportMatch","isResolvingPatterns","useSelect","select","unlock","blockEditorStore","jsx","className","Spinner","length","default","jsxs","Fragment","Button","__next40pxDefaultSize","onClick","variant","__","category","PatternCategoryPreviews","
|
|
1
|
+
{"version":3,"names":["_element","require","_compose","_components","_i18n","_data","_blockPatternsExplorer","_interopRequireDefault","_mobileTabNavigation","_patternCategoryPreviews","_usePatternCategories","_categoryTabs","_noResults","_store","_lockUnlock","_jsxRuntime","BlockPatternsTab","onSelectCategory","selectedCategory","onInsert","rootClientId","children","showPatternsExplorer","setShowPatternsExplorer","useState","categories","usePatternCategories","isMobile","useViewportMatch","isResolvingPatterns","useSelect","select","unlock","blockEditorStore","jsx","className","Spinner","length","default","jsxs","Fragment","Button","__next40pxDefaultSize","onClick","variant","__","category","PatternCategoryPreviews","name","initialCategory","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 { useViewportMatch } from '@wordpress/compose';\nimport { Button, Spinner } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\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';\nimport CategoryTabs from '../category-tabs';\nimport InserterNoResults from '../no-results';\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nfunction BlockPatternsTab( {\n\tonSelectCategory,\n\tselectedCategory,\n\tonInsert,\n\trootClientId,\n\tchildren,\n} ) {\n\tconst [ showPatternsExplorer, setShowPatternsExplorer ] = useState( false );\n\n\tconst categories = usePatternCategories( rootClientId );\n\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\tconst isResolvingPatterns = useSelect(\n\t\t( select ) =>\n\t\t\tunlock( select( blockEditorStore ) ).isResolvingPatterns(),\n\t\t[]\n\t);\n\n\tif ( isResolvingPatterns ) {\n\t\treturn (\n\t\t\t<div className=\"block-editor-inserter__patterns-loading\">\n\t\t\t\t<Spinner />\n\t\t\t</div>\n\t\t);\n\t}\n\n\tif ( ! categories.length ) {\n\t\treturn <InserterNoResults />;\n\t}\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<CategoryTabs\n\t\t\t\t\t\tcategories={ categories }\n\t\t\t\t\t\tselectedCategory={ selectedCategory }\n\t\t\t\t\t\tonSelectCategory={ onSelectCategory }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</CategoryTabs>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-explore-button\"\n\t\t\t\t\t\tonClick={ () => setShowPatternsExplorer( true ) }\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Explore all patterns' ) }\n\t\t\t\t\t</Button>\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<div className=\"block-editor-inserter__category-panel\">\n\t\t\t\t\t\t\t<PatternCategoryPreviews\n\t\t\t\t\t\t\t\tkey={ category.name }\n\t\t\t\t\t\t\t\tonInsert={ onInsert }\n\t\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\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={ selectedCategory || categories[ 0 ] }\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,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAKA,IAAAK,sBAAA,GAAAC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AuB,CAAE,KAAM,CAAG;MACvDH,YAAY,EAAGA;IAAc,CAC7B,CACD;EAAA,CACA,CAAC;AAEL;AAAC,IAAAgC,QAAA,GAAAC,OAAA,CAAAf,OAAA,GAEctB,gBAAgB","ignoreList":[]}
|
|
@@ -8,15 +8,12 @@ exports.PatternCategoryPreviews = PatternCategoryPreviews;
|
|
|
8
8
|
var _element = require("@wordpress/element");
|
|
9
9
|
var _i18n = require("@wordpress/i18n");
|
|
10
10
|
var _components = require("@wordpress/components");
|
|
11
|
-
var _data = require("@wordpress/data");
|
|
12
11
|
var _usePatternsState = _interopRequireDefault(require("../hooks/use-patterns-state"));
|
|
13
12
|
var _blockPatternsList = _interopRequireDefault(require("../../block-patterns-list"));
|
|
14
13
|
var _usePatternsPaging = _interopRequireDefault(require("../hooks/use-patterns-paging"));
|
|
15
14
|
var _patternsFilter = require("./patterns-filter");
|
|
16
15
|
var _usePatternCategories = require("./use-pattern-categories");
|
|
17
16
|
var _utils = require("./utils");
|
|
18
|
-
var _store = require("../../../store");
|
|
19
|
-
var _lockUnlock = require("../../../lock-unlock");
|
|
20
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
18
|
/**
|
|
22
19
|
* WordPress dependencies
|
|
@@ -34,7 +31,6 @@ function PatternCategoryPreviews({
|
|
|
34
31
|
category,
|
|
35
32
|
showTitlesAsTooltip
|
|
36
33
|
}) {
|
|
37
|
-
const isZoomOutMode = (0, _data.useSelect)(select => (0, _lockUnlock.unlock)(select(_store.store)).isZoomOut(), []);
|
|
38
34
|
const [allPatterns,, onClickPattern] = (0, _usePatternsState.default)(onInsert, rootClientId, category?.name);
|
|
39
35
|
const [patternSyncFilter, setPatternSyncFilter] = (0, _element.useState)('all');
|
|
40
36
|
const [patternSourceFilter, setPatternSourceFilter] = (0, _element.useState)('all');
|
|
@@ -50,6 +46,9 @@ function PatternCategoryPreviews({
|
|
|
50
46
|
if (category.name === _utils.myPatternsCategory.name && pattern.type === _utils.INSERTER_PATTERN_TYPES.user) {
|
|
51
47
|
return true;
|
|
52
48
|
}
|
|
49
|
+
if (category.name === _utils.starterPatternsCategory.name && pattern.blockTypes?.includes('core/post-content')) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
53
52
|
if (category.name === 'uncategorized') {
|
|
54
53
|
// The uncategorized category should show all the patterns without any category...
|
|
55
54
|
if (!pattern.categories) {
|
|
@@ -103,14 +102,13 @@ function PatternCategoryPreviews({
|
|
|
103
102
|
children: (0, _i18n.__)('No results found')
|
|
104
103
|
})]
|
|
105
104
|
}), currentCategoryPatterns.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
106
|
-
children: [
|
|
105
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalText, {
|
|
107
106
|
size: "12",
|
|
108
107
|
as: "p",
|
|
109
108
|
className: "block-editor-inserter__help-text",
|
|
110
109
|
children: (0, _i18n.__)('Drag and drop patterns into the canvas.')
|
|
111
110
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockPatternsList.default, {
|
|
112
111
|
ref: scrollContainerRef,
|
|
113
|
-
shownPatterns: pagingProps.categoryPatternsAsyncList,
|
|
114
112
|
blockPatterns: pagingProps.categoryPatterns,
|
|
115
113
|
onClickPattern: onClickPattern,
|
|
116
114
|
onHover: onHover,
|