@wordpress/block-editor 14.7.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/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-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-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/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/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/use-global-styles-output.js +1 -1
- package/build/components/global-styles/use-global-styles-output.js.map +1 -1
- package/build/components/iframe/index.js +140 -23
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +1 -5
- package/build/components/inserter/block-patterns-tab/pattern-category-previews.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-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 +29 -21
- package/build/components/media-placeholder/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/style.js +6 -6
- package/build/hooks/style.js.map +1 -1
- package/build/hooks/supports.js +1 -1
- package/build/hooks/supports.js.map +1 -1
- package/build/hooks/typography.js +1 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/hooks/utils.js +1 -1
- 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/private-apis.js +4 -4
- package/build/private-apis.js.map +1 -1
- package/build/store/private-selectors.js +1 -1
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js +3 -0
- package/build/store/selectors.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-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-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/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/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/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/index.js +141 -24
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +1 -5
- package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.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-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 +29 -21
- package/build-module/components/media-placeholder/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/style.js +6 -6
- package/build-module/hooks/style.js.map +1 -1
- package/build-module/hooks/supports.js +1 -1
- package/build-module/hooks/supports.js.map +1 -1
- package/build-module/hooks/typography.js +1 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/hooks/utils.js +1 -1
- 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/private-apis.js +6 -6
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/private-selectors.js +1 -1
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/selectors.js +3 -0
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/content-rtl.css +23 -9
- package/build-style/content.css +23 -9
- package/build-style/style-rtl.css +78 -0
- package/build-style/style.css +78 -0
- package/package.json +31 -31
- package/src/components/block-controls/slot.js +5 -3
- package/src/components/block-inspector/index.js +0 -2
- 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-settings-menu/block-settings-dropdown.js +2 -2
- package/src/components/block-settings-menu/index.js +2 -2
- package/src/components/block-toolbar/index.js +6 -0
- package/src/components/block-toolbar/switch-section-style.js +115 -0
- 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/font-family/index.js +13 -13
- 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/index.js +187 -44
- package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +7 -16
- package/src/components/inserter/category-tabs/index.js +8 -9
- 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 +37 -33
- package/src/components/provider/test/use-block-sync.js +3 -1
- package/src/components/rich-text/content.scss +15 -10
- package/src/hooks/border.js +3 -9
- package/src/hooks/color.js +1 -1
- package/src/hooks/dimensions.js +2 -2
- package/src/hooks/style.js +6 -12
- package/src/hooks/supports.js +1 -1
- package/src/hooks/test/style.js +1 -2
- package/src/hooks/typography.js +1 -1
- package/src/hooks/utils.js +1 -1
- package/src/layouts/flex.js +26 -18
- package/src/private-apis.js +6 -6
- package/src/store/private-selectors.js +1 -1
- package/src/store/selectors.js +3 -0
- package/src/store/test/selectors.js +87 -58
- package/src/style.scss +1 -0
- 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
|
@@ -9,7 +9,7 @@ import clsx from 'clsx';
|
|
|
9
9
|
*/
|
|
10
10
|
import { useState, createPortal, forwardRef, useMemo, useEffect, useRef } from '@wordpress/element';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
|
-
import { useResizeObserver, useMergeRefs, useRefEffect, useDisabled } from '@wordpress/compose';
|
|
12
|
+
import { useResizeObserver, useMergeRefs, useRefEffect, useDisabled, useReducedMotion } from '@wordpress/compose';
|
|
13
13
|
import { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';
|
|
14
14
|
import { useSelect } from '@wordpress/data';
|
|
15
15
|
|
|
@@ -117,6 +117,7 @@ function Iframe({
|
|
|
117
117
|
styles = '',
|
|
118
118
|
scripts = ''
|
|
119
119
|
} = resolvedAssets;
|
|
120
|
+
/** @type {[Document, import('react').Dispatch<Document>]} */
|
|
120
121
|
const [iframeDocument, setIframeDocument] = useState();
|
|
121
122
|
const initialContainerWidthRef = useRef(0);
|
|
122
123
|
const [bodyClasses, setBodyClasses] = useState([]);
|
|
@@ -128,6 +129,7 @@ function Iframe({
|
|
|
128
129
|
const [containerResizeListener, {
|
|
129
130
|
width: containerWidth
|
|
130
131
|
}] = useResizeObserver();
|
|
132
|
+
const prefersReducedMotion = useReducedMotion();
|
|
131
133
|
const setRef = useRefEffect(node => {
|
|
132
134
|
node._load = () => {
|
|
133
135
|
setIframeDocument(node.contentDocument);
|
|
@@ -221,6 +223,12 @@ function Iframe({
|
|
|
221
223
|
}
|
|
222
224
|
}, [containerWidth, isZoomedOut]);
|
|
223
225
|
const scaleContainerWidth = Math.max(initialContainerWidthRef.current, containerWidth);
|
|
226
|
+
const frameSizeValue = parseInt(frameSize);
|
|
227
|
+
const maxWidth = 750;
|
|
228
|
+
const scaleValue = scale === 'auto-scaled' ? (Math.min(containerWidth, maxWidth) - frameSizeValue * 2) / scaleContainerWidth : scale;
|
|
229
|
+
const prevScaleRef = useRef(scaleValue);
|
|
230
|
+
const prevFrameSizeRef = useRef(frameSizeValue);
|
|
231
|
+
const prevClientHeightRef = useRef(/* Initialized in the useEffect. */);
|
|
224
232
|
const disabledRef = useDisabled({
|
|
225
233
|
isDisabled: !readonly
|
|
226
234
|
});
|
|
@@ -266,37 +274,132 @@ function Iframe({
|
|
|
266
274
|
return [_src, () => URL.revokeObjectURL(_src)];
|
|
267
275
|
}, [html]);
|
|
268
276
|
useEffect(() => cleanup, [cleanup]);
|
|
269
|
-
|
|
277
|
+
useEffect(() => {
|
|
278
|
+
var _prevClientHeightRef$;
|
|
279
|
+
if (!iframeDocument ||
|
|
280
|
+
// HACK: Checking if isZoomedOut differs from prevIsZoomedOut here
|
|
281
|
+
// instead of the dependency array to appease the linter.
|
|
282
|
+
scaleValue === 1 === (prevScaleRef.current === 1)) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// Unscaled height of the current iframe container.
|
|
287
|
+
const clientHeight = iframeDocument.documentElement.clientHeight;
|
|
288
|
+
|
|
289
|
+
// Scaled height of the current iframe content.
|
|
290
|
+
const scrollHeight = iframeDocument.documentElement.scrollHeight;
|
|
291
|
+
|
|
292
|
+
// Previous scale value.
|
|
293
|
+
const prevScale = prevScaleRef.current;
|
|
294
|
+
|
|
295
|
+
// Unscaled size of the previous padding around the iframe content.
|
|
296
|
+
const prevFrameSize = prevFrameSizeRef.current;
|
|
297
|
+
|
|
298
|
+
// Unscaled height of the previous iframe container.
|
|
299
|
+
const prevClientHeight = (_prevClientHeightRef$ = prevClientHeightRef.current) !== null && _prevClientHeightRef$ !== void 0 ? _prevClientHeightRef$ : clientHeight;
|
|
300
|
+
|
|
301
|
+
// We can't trust the set value from contentHeight, as it was measured
|
|
302
|
+
// before the zoom out mode was changed. After zoom out mode is changed,
|
|
303
|
+
// appenders may appear or disappear, so we need to get the height from
|
|
304
|
+
// the iframe at this point when we're about to animate the zoom out.
|
|
305
|
+
// The iframe scrollTop, scrollHeight, and clientHeight will all be
|
|
306
|
+
// accurate. The client height also does change when the zoom out mode
|
|
307
|
+
// is toggled, as the bottom bar about selecting the template is
|
|
308
|
+
// added/removed when toggling zoom out mode.
|
|
309
|
+
const scrollTop = iframeDocument.documentElement.scrollTop;
|
|
310
|
+
|
|
311
|
+
// Step 0: Start with the current scrollTop.
|
|
312
|
+
let scrollTopNext = scrollTop;
|
|
313
|
+
|
|
314
|
+
// Step 1: Undo the effects of the previous scale and frame around the
|
|
315
|
+
// midpoint of the visible area.
|
|
316
|
+
scrollTopNext = (scrollTopNext + prevClientHeight / 2 - prevFrameSize) / prevScale - prevClientHeight / 2;
|
|
317
|
+
|
|
318
|
+
// Step 2: Apply the new scale and frame around the midpoint of the
|
|
319
|
+
// visible area.
|
|
320
|
+
scrollTopNext = (scrollTopNext + clientHeight / 2) * scaleValue + frameSizeValue - clientHeight / 2;
|
|
321
|
+
|
|
322
|
+
// Step 3: Handle an edge case so that you scroll to the top of the
|
|
323
|
+
// iframe if the top of the iframe content is visible in the container.
|
|
324
|
+
// The same edge case for the bottom is skipped because changing content
|
|
325
|
+
// makes calculating it impossible.
|
|
326
|
+
scrollTopNext = scrollTop <= prevFrameSize ? 0 : scrollTopNext;
|
|
327
|
+
|
|
328
|
+
// This is the scrollTop value if you are scrolled to the bottom of the
|
|
329
|
+
// iframe. We can't just let the browser handle it because we need to
|
|
330
|
+
// animate the scaling.
|
|
331
|
+
const maxScrollTop = scrollHeight * (scaleValue / prevScale) + frameSizeValue * 2 - clientHeight;
|
|
332
|
+
|
|
333
|
+
// Step 4: Clamp the scrollTopNext between the minimum and maximum
|
|
334
|
+
// possible scrollTop positions. Round the value to avoid subpixel
|
|
335
|
+
// truncation by the browser which sometimes causes a 1px error.
|
|
336
|
+
scrollTopNext = Math.round(Math.min(Math.max(0, scrollTopNext), Math.max(0, maxScrollTop)));
|
|
337
|
+
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-scroll-top', `${scrollTop}px`);
|
|
338
|
+
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-scroll-top-next', `${scrollTopNext}px`);
|
|
339
|
+
iframeDocument.documentElement.classList.add('zoom-out-animation');
|
|
340
|
+
function onZoomOutTransitionEnd() {
|
|
341
|
+
// Remove the position fixed for the animation.
|
|
342
|
+
iframeDocument.documentElement.classList.remove('zoom-out-animation');
|
|
343
|
+
|
|
344
|
+
// Update previous values.
|
|
345
|
+
prevClientHeightRef.current = clientHeight;
|
|
346
|
+
prevFrameSizeRef.current = frameSizeValue;
|
|
347
|
+
prevScaleRef.current = scaleValue;
|
|
348
|
+
|
|
349
|
+
// Set the final scroll position that was just animated to.
|
|
350
|
+
// Disable reason: Eslint isn't smart enough to know that this is a
|
|
351
|
+
// DOM element. https://github.com/facebook/react/issues/31483
|
|
352
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
353
|
+
iframeDocument.documentElement.scrollTop = scrollTopNext;
|
|
354
|
+
}
|
|
355
|
+
let raf;
|
|
356
|
+
if (prefersReducedMotion) {
|
|
357
|
+
// Hack: Wait for the window values to recalculate.
|
|
358
|
+
raf = iframeDocument.defaultView.requestAnimationFrame(onZoomOutTransitionEnd);
|
|
359
|
+
} else {
|
|
360
|
+
iframeDocument.documentElement.addEventListener('transitionend', onZoomOutTransitionEnd, {
|
|
361
|
+
once: true
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
return () => {
|
|
365
|
+
iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-scroll-top');
|
|
366
|
+
iframeDocument.documentElement.style.removeProperty('--wp-block-editor-iframe-zoom-out-scroll-top-next');
|
|
367
|
+
iframeDocument.documentElement.classList.remove('zoom-out-animation');
|
|
368
|
+
if (prefersReducedMotion) {
|
|
369
|
+
iframeDocument.defaultView.cancelAnimationFrame(raf);
|
|
370
|
+
} else {
|
|
371
|
+
iframeDocument.documentElement.removeEventListener('transitionend', onZoomOutTransitionEnd);
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
}, [iframeDocument, scaleValue, frameSizeValue, prefersReducedMotion]);
|
|
270
375
|
|
|
271
376
|
// Toggle zoom out CSS Classes only when zoom out mode changes. We could add these into the useEffect
|
|
272
377
|
// that controls settings the CSS variables, but then we would need to do more work to ensure we're
|
|
273
378
|
// only toggling these when the zoom out mode changes, as that useEffect is also triggered by a large
|
|
274
379
|
// number of dependencies.
|
|
275
380
|
useEffect(() => {
|
|
276
|
-
if (!iframeDocument
|
|
381
|
+
if (!iframeDocument) {
|
|
277
382
|
return;
|
|
278
383
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
iframeDocument.documentElement.classList.remove('zoom-out-animation');
|
|
284
|
-
}, 400); // 400ms should match the animation speed used in components/iframe/content.scss
|
|
285
|
-
};
|
|
286
|
-
handleZoomOutAnimationClassname();
|
|
287
|
-
iframeDocument.documentElement.classList.add('is-zoomed-out');
|
|
288
|
-
return () => {
|
|
289
|
-
handleZoomOutAnimationClassname();
|
|
384
|
+
if (isZoomedOut) {
|
|
385
|
+
iframeDocument.documentElement.classList.add('is-zoomed-out');
|
|
386
|
+
} else {
|
|
387
|
+
// HACK: Since we can't remove this in the cleanup, we need to do it here.
|
|
290
388
|
iframeDocument.documentElement.classList.remove('is-zoomed-out');
|
|
389
|
+
}
|
|
390
|
+
return () => {
|
|
391
|
+
// HACK: Skipping cleanup because it causes issues with the zoom out
|
|
392
|
+
// animation. More refactoring is needed to fix this properly.
|
|
393
|
+
// iframeDocument.documentElement.classList.remove( 'is-zoomed-out' );
|
|
291
394
|
};
|
|
292
395
|
}, [iframeDocument, isZoomedOut]);
|
|
293
396
|
|
|
294
397
|
// Calculate the scaling and CSS variables for the zoom out canvas
|
|
295
398
|
useEffect(() => {
|
|
296
|
-
if (!iframeDocument
|
|
399
|
+
if (!iframeDocument) {
|
|
297
400
|
return;
|
|
298
401
|
}
|
|
299
|
-
|
|
402
|
+
|
|
300
403
|
// Note: When we initialize the zoom out when the canvas is smaller (sidebars open),
|
|
301
404
|
// initialContainerWidthRef will be smaller than the full page, and reflow will happen
|
|
302
405
|
// when the canvas area becomes larger due to sidebars closing. This is a known but
|
|
@@ -305,7 +408,7 @@ function Iframe({
|
|
|
305
408
|
// This scaling calculation has to happen within the JS because CSS calc() can
|
|
306
409
|
// only divide and multiply by a unitless value. I.e. calc( 100px / 2 ) is valid
|
|
307
410
|
// but calc( 100px / 2px ) is not.
|
|
308
|
-
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-scale',
|
|
411
|
+
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-scale', scaleValue);
|
|
309
412
|
|
|
310
413
|
// frameSize has to be a px value for the scaling and frame size to be computed correctly.
|
|
311
414
|
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-frame-size', typeof frameSize === 'number' ? `${frameSize}px` : frameSize);
|
|
@@ -314,14 +417,28 @@ function Iframe({
|
|
|
314
417
|
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-container-width', `${containerWidth}px`);
|
|
315
418
|
iframeDocument.documentElement.style.setProperty('--wp-block-editor-iframe-zoom-out-scale-container-width', `${scaleContainerWidth}px`);
|
|
316
419
|
return () => {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
iframeDocument.documentElement.style.removeProperty(
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
iframeDocument.documentElement.style.removeProperty(
|
|
420
|
+
// HACK: Skipping cleanup because it causes issues with the zoom out
|
|
421
|
+
// animation. More refactoring is needed to fix this properly.
|
|
422
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
423
|
+
// '--wp-block-editor-iframe-zoom-out-scale'
|
|
424
|
+
// );
|
|
425
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
426
|
+
// '--wp-block-editor-iframe-zoom-out-frame-size'
|
|
427
|
+
// );
|
|
428
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
429
|
+
// '--wp-block-editor-iframe-zoom-out-content-height'
|
|
430
|
+
// );
|
|
431
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
432
|
+
// '--wp-block-editor-iframe-zoom-out-inner-height'
|
|
433
|
+
// );
|
|
434
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
435
|
+
// '--wp-block-editor-iframe-zoom-out-container-width'
|
|
436
|
+
// );
|
|
437
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
438
|
+
// '--wp-block-editor-iframe-zoom-out-scale-container-width'
|
|
439
|
+
// );
|
|
323
440
|
};
|
|
324
|
-
}, [
|
|
441
|
+
}, [scaleValue, frameSize, iframeDocument, iframeWindowInnerHeight, contentHeight, containerWidth, windowInnerWidth, isZoomedOut, scaleContainerWidth]);
|
|
325
442
|
|
|
326
443
|
// Make sure to not render the before and after focusable div elements in view
|
|
327
444
|
// mode. They're only needed to capture focus in edit mode.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","useState","createPortal","forwardRef","useMemo","useEffect","useRef","__","useResizeObserver","useMergeRefs","useRefEffect","useDisabled","__experimentalStyleProvider","StyleProvider","useSelect","useBlockSelectionClearer","useWritingFlow","getCompatibilityStyles","store","blockEditorStore","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","bubbleEvent","event","Constructor","frame","init","key","contentDocument","defaultView","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","defaultPrevented","preventDefault","cancelled","dispatchEvent","useBubbleEvents","iframeDocument","frameElement","html","documentElement","eventTypes","handlers","name","prototype","Object","getPrototypeOf","constructorName","constructor","window","addEventListener","removeEventListener","Iframe","contentRef","children","tabIndex","scale","frameSize","readonly","forwardedRef","ref","title","props","resolvedAssets","isPreviewMode","select","getSettings","settings","__unstableResolvedAssets","styles","scripts","setIframeDocument","initialContainerWidthRef","bodyClasses","setBodyClasses","clearerRef","before","writingFlowRef","after","contentResizeListener","height","contentHeight","containerResizeListener","width","containerWidth","setRef","node","_load","iFrameDocument","preventFileDropDefault","onLoad","ownerDocument","classList","add","Array","from","body","filter","startsWith","dir","compatStyle","getElementById","id","head","appendChild","cloneNode","console","warn","target","tagName","href","getAttribute","location","hash","slice","iframeWindowInnerHeight","setIframeWindowInnerHeight","iframeResizeRef","nodeWindow","innerHeight","onResize","windowInnerWidth","setWindowInnerWidth","windowResizeRef","innerWidth","isZoomedOut","current","scaleContainerWidth","Math","max","disabledRef","isDisabled","bodyRef","origin","src","cleanup","_src","URL","createObjectURL","Blob","revokeObjectURL","zoomOutAnimationClassnameRef","handleZoomOutAnimationClassname","clearTimeout","setTimeout","remove","maxWidth","style","setProperty","min","parseInt","removeProperty","shouldRenderFocusCaptureElements","iframe","border","onKeyDown","currentTarget","stopPropagation","nativeEvent","KeyboardEvent","className","document","IframeIfReady","isInitialised","__internalIsInitialized"],"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseEffect,\n\tuseRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\nimport { getCompatibilityStyles } from './get-compatibility-styles';\nimport { store as blockEditorStore } from '../../store';\n\nfunction bubbleEvent( event, Constructor, frame ) {\n\tconst init = {};\n\n\tfor ( const key in event ) {\n\t\tinit[ key ] = event[ key ];\n\t}\n\n\t// Check if the event is a MouseEvent generated within the iframe.\n\t// If so, adjust the coordinates to be relative to the position of\n\t// the iframe. This ensures that components such as Draggable\n\t// receive coordinates relative to the window, instead of relative\n\t// to the iframe. Without this, the Draggable event handler would\n\t// result in components \"jumping\" position as soon as the user\n\t// drags over the iframe.\n\tif ( event instanceof frame.contentDocument.defaultView.MouseEvent ) {\n\t\tconst rect = frame.getBoundingClientRect();\n\t\tinit.clientX += rect.left;\n\t\tinit.clientY += rect.top;\n\t}\n\n\tconst newEvent = new Constructor( event.type, init );\n\tif ( init.defaultPrevented ) {\n\t\tnewEvent.preventDefault();\n\t}\n\tconst cancelled = ! frame.dispatchEvent( newEvent );\n\n\tif ( cancelled ) {\n\t\tevent.preventDefault();\n\t}\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} iframeDocument Document to attach listeners to.\n */\nfunction useBubbleEvents( iframeDocument ) {\n\treturn useRefEffect( () => {\n\t\tconst { defaultView } = iframeDocument;\n\t\tif ( ! defaultView ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { frameElement } = defaultView;\n\t\tconst html = iframeDocument.documentElement;\n\t\tconst eventTypes = [ 'dragover', 'mousemove' ];\n\t\tconst handlers = {};\n\t\tfor ( const name of eventTypes ) {\n\t\t\thandlers[ name ] = ( event ) => {\n\t\t\t\tconst prototype = Object.getPrototypeOf( event );\n\t\t\t\tconst constructorName = prototype.constructor.name;\n\t\t\t\tconst Constructor = window[ constructorName ];\n\t\t\t\tbubbleEvent( event, Constructor, frameElement );\n\t\t\t};\n\t\t\thtml.addEventListener( name, handlers[ name ] );\n\t\t}\n\n\t\treturn () => {\n\t\t\tfor ( const name of eventTypes ) {\n\t\t\t\thtml.removeEventListener( name, handlers[ name ] );\n\t\t\t}\n\t\t};\n\t} );\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\ttabIndex = 0,\n\tscale = 1,\n\tframeSize = 0,\n\treadonly,\n\tforwardedRef: ref,\n\ttitle = __( 'Editor canvas' ),\n\t...props\n} ) {\n\tconst { resolvedAssets, isPreviewMode } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst settings = getSettings();\n\t\treturn {\n\t\t\tresolvedAssets: settings.__unstableResolvedAssets,\n\t\t\tisPreviewMode: settings.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\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 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\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":";AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SACCC,QAAQ,EACRC,YAAY,EACZC,UAAU,EACVC,OAAO,EACPC,SAAS,EACTC,MAAM,QACA,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,S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C,CAACkG,uBAAuB,EACjE,EACD,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA,IAAK,CAAED,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,oBAAOzJ,IAAA,CAAC0C,MAAM;IAAA,GAAMU,KAAK;IAAGH,YAAY,EAAGC;EAAK,CAAE,CAAC;AACpD;AAEA,eAAepE,UAAU,CAAE0K,aAAc,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","useState","createPortal","forwardRef","useMemo","useEffect","useRef","__","useResizeObserver","useMergeRefs","useRefEffect","useDisabled","useReducedMotion","__experimentalStyleProvider","StyleProvider","useSelect","useBlockSelectionClearer","useWritingFlow","getCompatibilityStyles","store","blockEditorStore","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","bubbleEvent","event","Constructor","frame","init","key","contentDocument","defaultView","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","defaultPrevented","preventDefault","cancelled","dispatchEvent","useBubbleEvents","iframeDocument","frameElement","html","documentElement","eventTypes","handlers","name","prototype","Object","getPrototypeOf","constructorName","constructor","window","addEventListener","removeEventListener","Iframe","contentRef","children","tabIndex","scale","frameSize","readonly","forwardedRef","ref","title","props","resolvedAssets","isPreviewMode","select","getSettings","settings","__unstableResolvedAssets","styles","scripts","setIframeDocument","initialContainerWidthRef","bodyClasses","setBodyClasses","clearerRef","before","writingFlowRef","after","contentResizeListener","height","contentHeight","containerResizeListener","width","containerWidth","prefersReducedMotion","setRef","node","_load","iFrameDocument","preventFileDropDefault","onLoad","ownerDocument","classList","add","Array","from","body","filter","startsWith","dir","compatStyle","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","current","scaleContainerWidth","Math","max","frameSizeValue","parseInt","maxWidth","scaleValue","min","prevScaleRef","prevFrameSizeRef","prevClientHeightRef","disabledRef","isDisabled","bodyRef","origin","src","cleanup","_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","border","onKeyDown","currentTarget","stopPropagation","nativeEvent","KeyboardEvent","className","document","IframeIfReady","isInitialised","__internalIsInitialized"],"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseEffect,\n\tuseRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n\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":";AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SACCC,QAAQ,EACRC,YAAY,EACZC,UAAU,EACVC,OAAO,EACPC,SAAS,EACTC,MAAM,QACA,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,iBAAiB,EACjBC,YAAY,EACZC,YAAY,EACZC,WAAW,EACXC,gBAAgB,QACV,oBAAoB;AAC3B,SAASC,2BAA2B,IAAIC,aAAa,QAAQ,uBAAuB;AACpF,SAASC,SAA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AAY;MAAA;MACX;MACA;MACA;MACAsB,KAAA;QACCgD,GAAG,EAAGiF,OAAS;QACfoC,SAAS,EAAG7L,IAAI,CACf,2BAA2B,EAC3B,uBAAuB,EACvB,GAAGqF,WACJ,CAAG;QAAAnB,QAAA,GAEDyB,qBAAqB,eACvBrE,IAAA,CAACR,aAAa;UAACgL,QAAQ,EAAG7I,cAAgB;UAAAiB,QAAA,EACvCA;QAAQ,CACI,CAAC;MAAA,CACX,CAAC,EACPjB,cAAc,CAACG,eAChB;IAAC,CACK,CAAC,EACPiI,gCAAgC,IAAI3F,KAAK;EAAA,CAC1C,CACF;EAED,oBACClE,KAAA;IAAKqK,SAAS,EAAC,gCAAgC;IAACrH,GAAG,EAAGgE,eAAiB;IAAAtE,QAAA,GACpE4B,uBAAuB,eACzBxE,IAAA;MACCuK,SAAS,EAAG7L,IAAI,CACf,sCAAsC,EACtC0I,WAAW,IAAI,eAChB,CAAG;MACHkC,KAAK,EAAG;QACP,yDAAyD,EACxDlC,WAAW,IAAI,GAAIE,mBAAmB;MACxC,CAAG;MAAA1E,QAAA,EAEDoH;IAAM,CACJ,CAAC;EAAA,CACF,CAAC;AAER;AAEA,SAASS,aAAaA,CAAErH,KAAK,EAAEF,GAAG,EAAG;EACpC,MAAMwH,aAAa,GAAGjL,SAAS,CAC5B8D,MAAM,IACPA,MAAM,CAAEzD,gBAAiB,CAAC,CAAC0D,WAAW,CAAC,CAAC,CAACmH,uBAAuB,EACjE,EACD,CAAC;;EAED;EACA;EACA;EACA;EACA;EACA,IAAK,CAAED,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,oBAAO1K,IAAA,CAAC0C,MAAM;IAAA,GAAMU,KAAK;IAAGH,YAAY,EAAGC;EAAK,CAAE,CAAC;AACpD;AAEA,eAAerE,UAAU,CAAE4L,aAAc,CAAC","ignoreList":[]}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { useMemo, useState, useCallback, useRef, useEffect } from '@wordpress/element';
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
import { __experimentalHStack as HStack, __experimentalVStack as VStack, __experimentalHeading as Heading, __experimentalText as Text, FlexBlock } from '@wordpress/components';
|
|
7
|
-
import { useSelect } from '@wordpress/data';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Internal dependencies
|
|
@@ -15,8 +14,6 @@ import usePatternsPaging from '../hooks/use-patterns-paging';
|
|
|
15
14
|
import { PatternsFilter } from './patterns-filter';
|
|
16
15
|
import { usePatternCategories } from './use-pattern-categories';
|
|
17
16
|
import { isPatternFiltered, allPatternsCategory, myPatternsCategory, starterPatternsCategory, INSERTER_PATTERN_TYPES } from './utils';
|
|
18
|
-
import { store as blockEditorStore } from '../../../store';
|
|
19
|
-
import { unlock } from '../../../lock-unlock';
|
|
20
17
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
21
18
|
const noop = () => {};
|
|
22
19
|
export function PatternCategoryPreviews({
|
|
@@ -26,7 +23,6 @@ export function PatternCategoryPreviews({
|
|
|
26
23
|
category,
|
|
27
24
|
showTitlesAsTooltip
|
|
28
25
|
}) {
|
|
29
|
-
const isZoomOutMode = useSelect(select => unlock(select(blockEditorStore)).isZoomOut(), []);
|
|
30
26
|
const [allPatterns,, onClickPattern] = usePatternsState(onInsert, rootClientId, category?.name);
|
|
31
27
|
const [patternSyncFilter, setPatternSyncFilter] = useState('all');
|
|
32
28
|
const [patternSourceFilter, setPatternSourceFilter] = useState('all');
|
|
@@ -98,7 +94,7 @@ export function PatternCategoryPreviews({
|
|
|
98
94
|
children: __('No results found')
|
|
99
95
|
})]
|
|
100
96
|
}), currentCategoryPatterns.length > 0 && /*#__PURE__*/_jsxs(_Fragment, {
|
|
101
|
-
children: [
|
|
97
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
102
98
|
size: "12",
|
|
103
99
|
as: "p",
|
|
104
100
|
className: "block-editor-inserter__help-text",
|
package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useState","useCallback","useRef","useEffect","__","__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalHeading","Heading","__experimentalText","Text","FlexBlock","useSelect","usePatternsState","BlockPatternsList","usePatternsPaging","PatternsFilter","usePatternCategories","isPatternFiltered","allPatternsCategory","myPatternsCategory","starterPatternsCategory","INSERTER_PATTERN_TYPES","store","blockEditorStore","unlock","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","noop","PatternCategoryPreviews","rootClientId","onInsert","onHover","category","showTitlesAsTooltip","isZoomOutMode","select","isZoomOut","allPatterns","onClickPattern","name","patternSyncFilter","setPatternSyncFilter","patternSourceFilter","setPatternSourceFilter","availableCategories","scrollContainerRef","currentCategoryPatterns","filter","pattern","type","user","blockTypes","includes","categories","some","catName","c","pagingProps","changePage","onSetPatternSyncFilter","value","onSetPatternSourceFilter","children","spacing","className","size","level","as","label","length","variant","ref","blockPatterns","categoryPatterns","orientation","isDraggable","patternFilter"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab/pattern-category-previews.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMemo,\n\tuseState,\n\tuseCallback,\n\tuseRef,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n\tFlexBlock,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport usePatternsState from '../hooks/use-patterns-state';\nimport BlockPatternsList from '../../block-patterns-list';\nimport usePatternsPaging from '../hooks/use-patterns-paging';\nimport { PatternsFilter } from './patterns-filter';\nimport { usePatternCategories } from './use-pattern-categories';\nimport {\n\tisPatternFiltered,\n\tallPatternsCategory,\n\tmyPatternsCategory,\n\tstarterPatternsCategory,\n\tINSERTER_PATTERN_TYPES,\n} from './utils';\nimport { store as blockEditorStore } from '../../../store';\nimport { unlock } from '../../../lock-unlock';\n\nconst noop = () => {};\n\nexport function PatternCategoryPreviews( {\n\trootClientId,\n\tonInsert,\n\tonHover = noop,\n\tcategory,\n\tshowTitlesAsTooltip,\n} ) {\n\tconst isZoomOutMode = useSelect(\n\t\t( select ) => unlock( select( blockEditorStore ) ).isZoomOut(),\n\t\t[]\n\t);\n\tconst [ allPatterns, , onClickPattern ] = usePatternsState(\n\t\tonInsert,\n\t\trootClientId,\n\t\tcategory?.name\n\t);\n\tconst [ patternSyncFilter, setPatternSyncFilter ] = useState( 'all' );\n\tconst [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );\n\n\tconst availableCategories = usePatternCategories(\n\t\trootClientId,\n\t\tpatternSourceFilter\n\t);\n\tconst scrollContainerRef = useRef();\n\tconst currentCategoryPatterns = useMemo(\n\t\t() =>\n\t\t\tallPatterns.filter( ( pattern ) => {\n\t\t\t\tif (\n\t\t\t\t\tisPatternFiltered(\n\t\t\t\t\t\tpattern,\n\t\t\t\t\t\tpatternSourceFilter,\n\t\t\t\t\t\tpatternSyncFilter\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif ( category.name === allPatternsCategory.name ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tcategory.name === myPatternsCategory.name &&\n\t\t\t\t\tpattern.type === INSERTER_PATTERN_TYPES.user\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tcategory.name === starterPatternsCategory.name &&\n\t\t\t\t\tpattern.blockTypes?.includes( 'core/post-content' )\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tif ( category.name === 'uncategorized' ) {\n\t\t\t\t\t// The uncategorized category should show all the patterns without any category...\n\t\t\t\t\tif ( ! pattern.categories ) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\n\t\t\t\t\t// ...or with no available category.\n\t\t\t\t\treturn ! pattern.categories.some( ( catName ) =>\n\t\t\t\t\t\tavailableCategories.some( ( c ) => c.name === catName )\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn pattern.categories?.includes( category.name );\n\t\t\t} ),\n\t\t[\n\t\t\tallPatterns,\n\t\t\tavailableCategories,\n\t\t\tcategory.name,\n\t\t\tpatternSourceFilter,\n\t\t\tpatternSyncFilter,\n\t\t]\n\t);\n\n\tconst pagingProps = usePatternsPaging(\n\t\tcurrentCategoryPatterns,\n\t\tcategory,\n\t\tscrollContainerRef\n\t);\n\tconst { changePage } = pagingProps;\n\n\t// Hide block pattern preview on unmount.\n\tuseEffect( () => () => onHover( null ), [] );\n\n\tconst onSetPatternSyncFilter = useCallback(\n\t\t( value ) => {\n\t\t\tsetPatternSyncFilter( value );\n\t\t\tchangePage( 1 );\n\t\t},\n\t\t[ setPatternSyncFilter, changePage ]\n\t);\n\tconst onSetPatternSourceFilter = useCallback(\n\t\t( value ) => {\n\t\t\tsetPatternSourceFilter( value );\n\t\t\tchangePage( 1 );\n\t\t},\n\t\t[ setPatternSourceFilter, changePage ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<VStack\n\t\t\t\tspacing={ 2 }\n\t\t\t\tclassName=\"block-editor-inserter__patterns-category-panel-header\"\n\t\t\t>\n\t\t\t\t<HStack>\n\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t<Heading\n\t\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-category-panel-title\"\n\t\t\t\t\t\t\tsize={ 13 }\n\t\t\t\t\t\t\tlevel={ 4 }\n\t\t\t\t\t\t\tas=\"div\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ category.label }\n\t\t\t\t\t\t</Heading>\n\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t<PatternsFilter\n\t\t\t\t\t\tpatternSyncFilter={ patternSyncFilter }\n\t\t\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t\t\t\tsetPatternSyncFilter={ onSetPatternSyncFilter }\n\t\t\t\t\t\tsetPatternSourceFilter={ onSetPatternSourceFilter }\n\t\t\t\t\t\tscrollContainerRef={ scrollContainerRef }\n\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t\t{ ! currentCategoryPatterns.length && (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tvariant=\"muted\"\n\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-category-no-results\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'No results found' ) }\n\t\t\t\t\t</Text>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t\t{ currentCategoryPatterns.length > 0 && (\n\t\t\t\t<>\n\t\t\t\t\t{ isZoomOutMode && (\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tsize=\"12\"\n\t\t\t\t\t\t\tas=\"p\"\n\t\t\t\t\t\t\tclassName=\"block-editor-inserter__help-text\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Drag and drop patterns into the canvas.' ) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t) }\n\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\tref={ scrollContainerRef }\n\t\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\tlabel={ category.label }\n\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\tcategory={ category.name }\n\t\t\t\t\t\tisDraggable\n\t\t\t\t\t\tshowTitlesAsTooltip={ showTitlesAsTooltip }\n\t\t\t\t\t\tpatternFilter={ patternSourceFilter }\n\t\t\t\t\t\tpagingProps={ pagingProps }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\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AAqB;UAC3CD,oBAAoB,EAAGkB,sBAAwB;UAC/ChB,sBAAsB,EAAGkB,wBAA0B;UACnDhB,kBAAkB,EAAGA,kBAAoB;UACzCb,QAAQ,EAAGA;QAAU,CACrB,CAAC;MAAA,CACK,CAAC,EACP,CAAEc,uBAAuB,CAACuB,MAAM,iBACjC/C,IAAA,CAACjB,IAAI;QACJiE,OAAO,EAAC,OAAO;QACfN,SAAS,EAAC,qDAAqD;QAAAF,QAAA,EAE7DjE,EAAE,CAAE,kBAAmB;MAAC,CACrB,CACN;IAAA,CACM,CAAC,EACPiD,uBAAuB,CAACuB,MAAM,GAAG,CAAC,iBACnC7C,KAAA,CAAAE,SAAA;MAAAoC,QAAA,GACG5B,aAAa,iBACdZ,IAAA,CAACjB,IAAI;QACJ4D,IAAI,EAAC,IAAI;QACTE,EAAE,EAAC,GAAG;QACNH,SAAS,EAAC,kCAAkC;QAAAF,QAAA,EAE1CjE,EAAE,CAAE,yCAA0C;MAAC,CAC5C,CACN,eACDyB,IAAA,CAACb,iBAAiB;QACjB8D,GAAG,EAAG1B,kBAAoB;QAC1B2B,aAAa,EAAGf,WAAW,CAACgB,gBAAkB;QAC9CnC,cAAc,EAAGA,cAAgB;QACjCP,OAAO,EAAGA,OAAS;QACnBqC,KAAK,EAAGpC,QAAQ,CAACoC,KAAO;QACxBM,WAAW,EAAC,UAAU;QACtB1C,QAAQ,EAAGA,QAAQ,CAACO,IAAM;QAC1BoC,WAAW;QACX1C,mBAAmB,EAAGA,mBAAqB;QAC3C2C,aAAa,EAAGlC,mBAAqB;QACrCe,WAAW,EAAGA;MAAa,CAC3B,CAAC;IAAA,CACD,CACF;EAAA,CACA,CAAC;AAEL","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useMemo","useState","useCallback","useRef","useEffect","__","__experimentalHStack","HStack","__experimentalVStack","VStack","__experimentalHeading","Heading","__experimentalText","Text","FlexBlock","usePatternsState","BlockPatternsList","usePatternsPaging","PatternsFilter","usePatternCategories","isPatternFiltered","allPatternsCategory","myPatternsCategory","starterPatternsCategory","INSERTER_PATTERN_TYPES","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","noop","PatternCategoryPreviews","rootClientId","onInsert","onHover","category","showTitlesAsTooltip","allPatterns","onClickPattern","name","patternSyncFilter","setPatternSyncFilter","patternSourceFilter","setPatternSourceFilter","availableCategories","scrollContainerRef","currentCategoryPatterns","filter","pattern","type","user","blockTypes","includes","categories","some","catName","c","pagingProps","changePage","onSetPatternSyncFilter","value","onSetPatternSourceFilter","children","spacing","className","size","level","as","label","length","variant","ref","blockPatterns","categoryPatterns","orientation","isDraggable","patternFilter"],"sources":["@wordpress/block-editor/src/components/inserter/block-patterns-tab/pattern-category-previews.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMemo,\n\tuseState,\n\tuseCallback,\n\tuseRef,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\nimport {\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n\t__experimentalHeading as Heading,\n\t__experimentalText as Text,\n\tFlexBlock,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport usePatternsState from '../hooks/use-patterns-state';\nimport BlockPatternsList from '../../block-patterns-list';\nimport usePatternsPaging from '../hooks/use-patterns-paging';\nimport { PatternsFilter } from './patterns-filter';\nimport { usePatternCategories } from './use-pattern-categories';\nimport {\n\tisPatternFiltered,\n\tallPatternsCategory,\n\tmyPatternsCategory,\n\tstarterPatternsCategory,\n\tINSERTER_PATTERN_TYPES,\n} from './utils';\n\nconst noop = () => {};\n\nexport function PatternCategoryPreviews( {\n\trootClientId,\n\tonInsert,\n\tonHover = noop,\n\tcategory,\n\tshowTitlesAsTooltip,\n} ) {\n\tconst [ allPatterns, , onClickPattern ] = usePatternsState(\n\t\tonInsert,\n\t\trootClientId,\n\t\tcategory?.name\n\t);\n\tconst [ patternSyncFilter, setPatternSyncFilter ] = useState( 'all' );\n\tconst [ patternSourceFilter, setPatternSourceFilter ] = useState( 'all' );\n\n\tconst availableCategories = usePatternCategories(\n\t\trootClientId,\n\t\tpatternSourceFilter\n\t);\n\tconst scrollContainerRef = useRef();\n\tconst currentCategoryPatterns = useMemo(\n\t\t() =>\n\t\t\tallPatterns.filter( ( pattern ) => {\n\t\t\t\tif (\n\t\t\t\t\tisPatternFiltered(\n\t\t\t\t\t\tpattern,\n\t\t\t\t\t\tpatternSourceFilter,\n\t\t\t\t\t\tpatternSyncFilter\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\tif ( category.name === allPatternsCategory.name ) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tcategory.name === myPatternsCategory.name &&\n\t\t\t\t\tpattern.type === INSERTER_PATTERN_TYPES.user\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tif (\n\t\t\t\t\tcategory.name === starterPatternsCategory.name &&\n\t\t\t\t\tpattern.blockTypes?.includes( 'core/post-content' )\n\t\t\t\t) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tif ( category.name === 'uncategorized' ) {\n\t\t\t\t\t// The uncategorized category should show all the patterns without any category...\n\t\t\t\t\tif ( ! pattern.categories ) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\n\t\t\t\t\t// ...or with no available category.\n\t\t\t\t\treturn ! pattern.categories.some( ( catName ) =>\n\t\t\t\t\t\tavailableCategories.some( ( c ) => c.name === catName )\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn pattern.categories?.includes( category.name );\n\t\t\t} ),\n\t\t[\n\t\t\tallPatterns,\n\t\t\tavailableCategories,\n\t\t\tcategory.name,\n\t\t\tpatternSourceFilter,\n\t\t\tpatternSyncFilter,\n\t\t]\n\t);\n\n\tconst pagingProps = usePatternsPaging(\n\t\tcurrentCategoryPatterns,\n\t\tcategory,\n\t\tscrollContainerRef\n\t);\n\tconst { changePage } = pagingProps;\n\n\t// Hide block pattern preview on unmount.\n\tuseEffect( () => () => onHover( null ), [] );\n\n\tconst onSetPatternSyncFilter = useCallback(\n\t\t( value ) => {\n\t\t\tsetPatternSyncFilter( value );\n\t\t\tchangePage( 1 );\n\t\t},\n\t\t[ setPatternSyncFilter, changePage ]\n\t);\n\tconst onSetPatternSourceFilter = useCallback(\n\t\t( value ) => {\n\t\t\tsetPatternSourceFilter( value );\n\t\t\tchangePage( 1 );\n\t\t},\n\t\t[ setPatternSourceFilter, changePage ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<VStack\n\t\t\t\tspacing={ 2 }\n\t\t\t\tclassName=\"block-editor-inserter__patterns-category-panel-header\"\n\t\t\t>\n\t\t\t\t<HStack>\n\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t<Heading\n\t\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-category-panel-title\"\n\t\t\t\t\t\t\tsize={ 13 }\n\t\t\t\t\t\t\tlevel={ 4 }\n\t\t\t\t\t\t\tas=\"div\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ category.label }\n\t\t\t\t\t\t</Heading>\n\t\t\t\t\t</FlexBlock>\n\t\t\t\t\t<PatternsFilter\n\t\t\t\t\t\tpatternSyncFilter={ patternSyncFilter }\n\t\t\t\t\t\tpatternSourceFilter={ patternSourceFilter }\n\t\t\t\t\t\tsetPatternSyncFilter={ onSetPatternSyncFilter }\n\t\t\t\t\t\tsetPatternSourceFilter={ onSetPatternSourceFilter }\n\t\t\t\t\t\tscrollContainerRef={ scrollContainerRef }\n\t\t\t\t\t\tcategory={ category }\n\t\t\t\t\t/>\n\t\t\t\t</HStack>\n\t\t\t\t{ ! currentCategoryPatterns.length && (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tvariant=\"muted\"\n\t\t\t\t\t\tclassName=\"block-editor-inserter__patterns-category-no-results\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'No results found' ) }\n\t\t\t\t\t</Text>\n\t\t\t\t) }\n\t\t\t</VStack>\n\t\t\t{ currentCategoryPatterns.length > 0 && (\n\t\t\t\t<>\n\t\t\t\t\t<Text\n\t\t\t\t\t\tsize=\"12\"\n\t\t\t\t\t\tas=\"p\"\n\t\t\t\t\t\tclassName=\"block-editor-inserter__help-text\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Drag and drop patterns into the canvas.' ) }\n\t\t\t\t\t</Text>\n\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\tref={ scrollContainerRef }\n\t\t\t\t\t\tblockPatterns={ pagingProps.categoryPatterns }\n\t\t\t\t\t\tonClickPattern={ onClickPattern }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\tlabel={ category.label }\n\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\tcategory={ category.name }\n\t\t\t\t\t\tisDraggable\n\t\t\t\t\t\tshowTitlesAsTooltip={ showTitlesAsTooltip }\n\t\t\t\t\t\tpatternFilter={ patternSourceFilter }\n\t\t\t\t\t\tpagingProps={ pagingProps }\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,OAAO,EACPC,QAAQ,EACRC,WAAW,EACXC,MAAM,EACNC,SAAS,QACH,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;AAEpC,SACCC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,qBAAqB,IAAIC,OAAO,EAChCC,kBAAkB,IAAIC,IAAI,EAC1BC,SAAS,QACH,uBAAuB;;AAE9B;AACA;AACA;AACA,OAAOC,gBAAgB,MAAM,6BAA6B;AAC1D,OAAOC,iBAAiB,MAAM,2BAA2B;AACzD,OAAOC,iBAAiB,MAAM,8BAA8B;AAC5D,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC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OAAS;QACnBkC,KAAK,EAAGjC,QAAQ,CAACiC,KAAO;QACxBM,WAAW,EAAC,UAAU;QACtBvC,QAAQ,EAAGA,QAAQ,CAACI,IAAM;QAC1BoC,WAAW;QACXvC,mBAAmB,EAAGA,mBAAqB;QAC3CwC,aAAa,EAAGlC,mBAAqB;QACrCe,WAAW,EAAGA;MAAa,CAC3B,CAAC;IAAA,CACD,CACF;EAAA,CACA,CAAC;AAEL","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { usePrevious, useReducedMotion } from '@wordpress/compose';
|
|
5
5
|
import { privateApis as componentsPrivateApis, __unstableMotion as motion } from '@wordpress/components';
|
|
6
|
-
import { useState
|
|
6
|
+
import { useState } from '@wordpress/element';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Internal dependencies
|
|
@@ -31,14 +31,13 @@ function CategoryTabs({
|
|
|
31
31
|
const selectedTabId = selectedCategory ? selectedCategory.name : null;
|
|
32
32
|
const [activeTabId, setActiveId] = useState();
|
|
33
33
|
const firstTabId = categories?.[0]?.name;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}, [selectedTabId, activeTabId, firstTabId, setActiveId]);
|
|
34
|
+
|
|
35
|
+
// If there is no active tab, make the first tab the active tab, so that
|
|
36
|
+
// when focus is moved to the tablist, the first tab will be focused
|
|
37
|
+
// despite not being selected
|
|
38
|
+
if (selectedTabId === null && !activeTabId && firstTabId) {
|
|
39
|
+
setActiveId(firstTabId);
|
|
40
|
+
}
|
|
42
41
|
return /*#__PURE__*/_jsxs(Tabs, {
|
|
43
42
|
selectOnMove: false,
|
|
44
43
|
selectedTabId: selectedTabId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["usePrevious","useReducedMotion","privateApis","componentsPrivateApis","__unstableMotion","motion","useState","
|
|
1
|
+
{"version":3,"names":["usePrevious","useReducedMotion","privateApis","componentsPrivateApis","__unstableMotion","motion","useState","unlock","jsx","_jsx","jsxs","_jsxs","Tabs","CategoryTabs","categories","selectedCategory","onSelectCategory","children","ANIMATION_DURATION","disableMotion","defaultTransition","type","duration","ease","previousSelectedCategory","selectedTabId","name","activeTabId","setActiveId","firstTabId","selectOnMove","orientation","onSelect","categoryId","find","category","onActiveTabIdChange","TabList","className","map","Tab","tabId","label","undefined","TabPanel","focusable","div","initial","animate","variants","open","transform","transitionEnd","zIndex","closed","transition"],"sources":["@wordpress/block-editor/src/components/inserter/category-tabs/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { usePrevious, useReducedMotion } from '@wordpress/compose';\nimport {\n\tprivateApis as componentsPrivateApis,\n\t__unstableMotion as motion,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nfunction CategoryTabs( {\n\tcategories,\n\tselectedCategory,\n\tonSelectCategory,\n\tchildren,\n} ) {\n\t// Copied from InterfaceSkeleton.\n\tconst ANIMATION_DURATION = 0.25;\n\tconst disableMotion = useReducedMotion();\n\tconst defaultTransition = {\n\t\ttype: 'tween',\n\t\tduration: disableMotion ? 0 : ANIMATION_DURATION,\n\t\tease: [ 0.6, 0, 0.4, 1 ],\n\t};\n\n\tconst previousSelectedCategory = usePrevious( selectedCategory );\n\n\tconst selectedTabId = selectedCategory ? selectedCategory.name : null;\n\tconst [ activeTabId, setActiveId ] = useState();\n\tconst firstTabId = categories?.[ 0 ]?.name;\n\n\t// If there is no active tab, make the first tab the active tab, so that\n\t// when focus is moved to the tablist, the first tab will be focused\n\t// despite not being selected\n\tif ( selectedTabId === null && ! activeTabId && firstTabId ) {\n\t\tsetActiveId( firstTabId );\n\t}\n\n\treturn (\n\t\t<Tabs\n\t\t\tselectOnMove={ false }\n\t\t\tselectedTabId={ selectedTabId }\n\t\t\torientation=\"vertical\"\n\t\t\tonSelect={ ( categoryId ) => {\n\t\t\t\t// Pass the full category object\n\t\t\t\tonSelectCategory(\n\t\t\t\t\tcategories.find(\n\t\t\t\t\t\t( category ) => category.name === categoryId\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t} }\n\t\t\tactiveTabId={ activeTabId }\n\t\t\tonActiveTabIdChange={ setActiveId }\n\t\t>\n\t\t\t<Tabs.TabList className=\"block-editor-inserter__category-tablist\">\n\t\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t\t<Tabs.Tab\n\t\t\t\t\t\tkey={ category.name }\n\t\t\t\t\t\ttabId={ category.name }\n\t\t\t\t\t\taria-label={ category.label }\n\t\t\t\t\t\taria-current={\n\t\t\t\t\t\t\tcategory === selectedCategory ? 'true' : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ category.label }\n\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t) ) }\n\t\t\t</Tabs.TabList>\n\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\tkey={ category.name }\n\t\t\t\t\ttabId={ category.name }\n\t\t\t\t\tfocusable={ false }\n\t\t\t\t>\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tclassName=\"block-editor-inserter__category-panel\"\n\t\t\t\t\t\tinitial={\n\t\t\t\t\t\t\t! previousSelectedCategory ? 'closed' : 'open'\n\t\t\t\t\t\t}\n\t\t\t\t\t\tanimate=\"open\"\n\t\t\t\t\t\tvariants={ {\n\t\t\t\t\t\t\topen: {\n\t\t\t\t\t\t\t\ttransform: 'translateX( 0 )',\n\t\t\t\t\t\t\t\ttransitionEnd: {\n\t\t\t\t\t\t\t\t\tzIndex: '1',\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tclosed: {\n\t\t\t\t\t\t\t\ttransform: 'translateX( -100% )',\n\t\t\t\t\t\t\t\tzIndex: '-1',\n\t\t\t\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;cACdC,MAAM,EAAE;YACT;UACD,CAAC;UACDC,MAAM,EAAE;YACPH,SAAS,EAAE,qBAAqB;YAChCE,MAAM,EAAE;UACT;QACD,CAAG;QACHE,UAAU,EAAGnC,iBAAmB;QAAAH,QAAA,EAE9BA;MAAQ,CACC;IAAC,GAzBPkB,QAAQ,CAACT,IA0BD,CACd,CAAC;EAAA,CACE,CAAC;AAET;AAEA,eAAeb,YAAY","ignoreList":[]}
|
|
@@ -24,6 +24,7 @@ const InserterDraggableBlocks = ({
|
|
|
24
24
|
type: 'inserter',
|
|
25
25
|
blocks
|
|
26
26
|
};
|
|
27
|
+
const blocksContainMedia = blocks.filter(block => (block.name === 'core/image' || block.name === 'core/audio' || block.name === 'core/video') && (block.attributes.url || block.attributes.src)).length > 0;
|
|
27
28
|
const blockTypeIcon = useSelect(select => {
|
|
28
29
|
const {
|
|
29
30
|
getBlockType
|
|
@@ -49,7 +50,7 @@ const InserterDraggableBlocks = ({
|
|
|
49
50
|
const parsedBlocks = pattern?.type === INSERTER_PATTERN_TYPES.user && pattern?.syncStatus !== 'unsynced' ? [createBlock('core/block', {
|
|
50
51
|
ref: pattern.id
|
|
51
52
|
})] : blocks;
|
|
52
|
-
event.dataTransfer.setData('text/html', serialize(parsedBlocks));
|
|
53
|
+
event.dataTransfer.setData(blocksContainMedia ? 'default' : 'text/html', serialize(parsedBlocks));
|
|
53
54
|
},
|
|
54
55
|
onDragEnd: () => {
|
|
55
56
|
stopDragging();
|