@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { CustomSelectControl } from '@wordpress/components';
|
|
5
5
|
import deprecated from '@wordpress/deprecated';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
|
|
@@ -30,13 +30,15 @@ export default function FontFamilyControl( {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
const options = [
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
{
|
|
34
|
+
key: '',
|
|
35
|
+
name: __( 'Default' ),
|
|
36
|
+
},
|
|
37
|
+
...fontFamilies.map( ( { fontFamily, name } ) => ( {
|
|
38
|
+
key: fontFamily,
|
|
39
|
+
name: name || fontFamily,
|
|
40
|
+
style: { fontFamily },
|
|
41
|
+
} ) ),
|
|
40
42
|
];
|
|
41
43
|
|
|
42
44
|
if ( ! __nextHasNoMarginBottom ) {
|
|
@@ -51,14 +53,12 @@ export default function FontFamilyControl( {
|
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
return (
|
|
54
|
-
<
|
|
56
|
+
<CustomSelectControl
|
|
55
57
|
__next40pxDefaultSize={ __next40pxDefaultSize }
|
|
56
|
-
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
|
|
57
58
|
label={ __( 'Font' ) }
|
|
58
|
-
options={ options }
|
|
59
59
|
value={ value }
|
|
60
|
-
onChange={ onChange }
|
|
61
|
-
|
|
60
|
+
onChange={ ( { selectedItem } ) => onChange( selectedItem.key ) }
|
|
61
|
+
options={ options }
|
|
62
62
|
{ ...props }
|
|
63
63
|
/>
|
|
64
64
|
);
|
|
@@ -855,7 +855,7 @@ describe( 'global styles renderer', () => {
|
|
|
855
855
|
|
|
856
856
|
it( 'should return block selectors data with old experimental selectors', () => {
|
|
857
857
|
const imageSupports = {
|
|
858
|
-
|
|
858
|
+
border: {
|
|
859
859
|
radius: true,
|
|
860
860
|
__experimentalSelector: 'img, .crop-area',
|
|
861
861
|
},
|
|
@@ -47,7 +47,7 @@ const ELEMENT_CLASS_NAMES = {
|
|
|
47
47
|
// List of block support features that can have their related styles
|
|
48
48
|
// generated under their own feature level selector rather than the block's.
|
|
49
49
|
const BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = {
|
|
50
|
-
|
|
50
|
+
border: 'border',
|
|
51
51
|
color: 'color',
|
|
52
52
|
spacing: 'spacing',
|
|
53
53
|
typography: 'typography',
|
|
@@ -7,13 +7,26 @@
|
|
|
7
7
|
// We don't want to animate the transform of the translateX because it is used
|
|
8
8
|
// to "center" the canvas. Leaving it on causes the canvas to slide around in
|
|
9
9
|
// odd ways.
|
|
10
|
-
@include editor-canvas-resize-animation(transform 0s, scale 0s, padding 0s);
|
|
10
|
+
@include editor-canvas-resize-animation( transform 0s, scale 0s, padding 0s, translate 0s);
|
|
11
11
|
|
|
12
12
|
&.zoom-out-animation {
|
|
13
|
-
|
|
13
|
+
$scroll-top: var(--wp-block-editor-iframe-zoom-out-scroll-top, 0);
|
|
14
|
+
$scroll-top-next: var(--wp-block-editor-iframe-zoom-out-scroll-top-next, 0);
|
|
15
|
+
|
|
16
|
+
position: fixed;
|
|
17
|
+
left: 0;
|
|
18
|
+
right: 0;
|
|
19
|
+
top: calc(-1 * #{$scroll-top});
|
|
20
|
+
bottom: 0;
|
|
21
|
+
translate: 0 calc(#{$scroll-top} - #{$scroll-top-next});
|
|
22
|
+
// Force preserving a scrollbar gutter as scrollbar-gutter isn't supported in all browsers yet,
|
|
23
|
+
// and removing the scrollbar causes the content to shift.
|
|
24
|
+
overflow-y: scroll;
|
|
25
|
+
|
|
26
|
+
// We only want to animate the scaling when entering zoom out. When sidebars
|
|
14
27
|
// are toggled, the resizing of the iframe handles scaling the canvas as well,
|
|
15
28
|
// and the doubled animations cause very odd animations.
|
|
16
|
-
@include editor-canvas-resize-animation(transform 0s);
|
|
29
|
+
@include editor-canvas-resize-animation( transform 0s, top 0s, bottom 0s, right 0s, left 0s );
|
|
17
30
|
}
|
|
18
31
|
}
|
|
19
32
|
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
useMergeRefs,
|
|
21
21
|
useRefEffect,
|
|
22
22
|
useDisabled,
|
|
23
|
+
useReducedMotion,
|
|
23
24
|
} from '@wordpress/compose';
|
|
24
25
|
import { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';
|
|
25
26
|
import { useSelect } from '@wordpress/data';
|
|
@@ -121,6 +122,7 @@ function Iframe( {
|
|
|
121
122
|
};
|
|
122
123
|
}, [] );
|
|
123
124
|
const { styles = '', scripts = '' } = resolvedAssets;
|
|
125
|
+
/** @type {[Document, import('react').Dispatch<Document>]} */
|
|
124
126
|
const [ iframeDocument, setIframeDocument ] = useState();
|
|
125
127
|
const initialContainerWidthRef = useRef( 0 );
|
|
126
128
|
const [ bodyClasses, setBodyClasses ] = useState( [] );
|
|
@@ -130,6 +132,7 @@ function Iframe( {
|
|
|
130
132
|
useResizeObserver();
|
|
131
133
|
const [ containerResizeListener, { width: containerWidth } ] =
|
|
132
134
|
useResizeObserver();
|
|
135
|
+
const prefersReducedMotion = useReducedMotion();
|
|
133
136
|
|
|
134
137
|
const setRef = useRefEffect( ( node ) => {
|
|
135
138
|
node._load = () => {
|
|
@@ -268,6 +271,19 @@ function Iframe( {
|
|
|
268
271
|
containerWidth
|
|
269
272
|
);
|
|
270
273
|
|
|
274
|
+
const frameSizeValue = parseInt( frameSize );
|
|
275
|
+
|
|
276
|
+
const maxWidth = 750;
|
|
277
|
+
const scaleValue =
|
|
278
|
+
scale === 'auto-scaled'
|
|
279
|
+
? ( Math.min( containerWidth, maxWidth ) - frameSizeValue * 2 ) /
|
|
280
|
+
scaleContainerWidth
|
|
281
|
+
: scale;
|
|
282
|
+
|
|
283
|
+
const prevScaleRef = useRef( scaleValue );
|
|
284
|
+
const prevFrameSizeRef = useRef( frameSizeValue );
|
|
285
|
+
const prevClientHeightRef = useRef( /* Initialized in the useEffect. */ );
|
|
286
|
+
|
|
271
287
|
const disabledRef = useDisabled( { isDisabled: ! readonly } );
|
|
272
288
|
const bodyRef = useMergeRefs( [
|
|
273
289
|
useBubbleEvents( iframeDocument ),
|
|
@@ -320,47 +336,176 @@ function Iframe( {
|
|
|
320
336
|
|
|
321
337
|
useEffect( () => cleanup, [ cleanup ] );
|
|
322
338
|
|
|
323
|
-
const zoomOutAnimationClassnameRef = useRef( null );
|
|
324
|
-
|
|
325
|
-
// Toggle zoom out CSS Classes only when zoom out mode changes. We could add these into the useEffect
|
|
326
|
-
// that controls settings the CSS variables, but then we would need to do more work to ensure we're
|
|
327
|
-
// only toggling these when the zoom out mode changes, as that useEffect is also triggered by a large
|
|
328
|
-
// number of dependencies.
|
|
329
339
|
useEffect( () => {
|
|
330
|
-
if (
|
|
340
|
+
if (
|
|
341
|
+
! iframeDocument ||
|
|
342
|
+
// HACK: Checking if isZoomedOut differs from prevIsZoomedOut here
|
|
343
|
+
// instead of the dependency array to appease the linter.
|
|
344
|
+
( scaleValue === 1 ) === ( prevScaleRef.current === 1 )
|
|
345
|
+
) {
|
|
331
346
|
return;
|
|
332
347
|
}
|
|
333
348
|
|
|
334
|
-
|
|
335
|
-
|
|
349
|
+
// Unscaled height of the current iframe container.
|
|
350
|
+
const clientHeight = iframeDocument.documentElement.clientHeight;
|
|
351
|
+
|
|
352
|
+
// Scaled height of the current iframe content.
|
|
353
|
+
const scrollHeight = iframeDocument.documentElement.scrollHeight;
|
|
354
|
+
|
|
355
|
+
// Previous scale value.
|
|
356
|
+
const prevScale = prevScaleRef.current;
|
|
357
|
+
|
|
358
|
+
// Unscaled size of the previous padding around the iframe content.
|
|
359
|
+
const prevFrameSize = prevFrameSizeRef.current;
|
|
360
|
+
|
|
361
|
+
// Unscaled height of the previous iframe container.
|
|
362
|
+
const prevClientHeight = prevClientHeightRef.current ?? clientHeight;
|
|
363
|
+
|
|
364
|
+
// We can't trust the set value from contentHeight, as it was measured
|
|
365
|
+
// before the zoom out mode was changed. After zoom out mode is changed,
|
|
366
|
+
// appenders may appear or disappear, so we need to get the height from
|
|
367
|
+
// the iframe at this point when we're about to animate the zoom out.
|
|
368
|
+
// The iframe scrollTop, scrollHeight, and clientHeight will all be
|
|
369
|
+
// accurate. The client height also does change when the zoom out mode
|
|
370
|
+
// is toggled, as the bottom bar about selecting the template is
|
|
371
|
+
// added/removed when toggling zoom out mode.
|
|
372
|
+
const scrollTop = iframeDocument.documentElement.scrollTop;
|
|
373
|
+
|
|
374
|
+
// Step 0: Start with the current scrollTop.
|
|
375
|
+
let scrollTopNext = scrollTop;
|
|
376
|
+
|
|
377
|
+
// Step 1: Undo the effects of the previous scale and frame around the
|
|
378
|
+
// midpoint of the visible area.
|
|
379
|
+
scrollTopNext =
|
|
380
|
+
( scrollTopNext + prevClientHeight / 2 - prevFrameSize ) /
|
|
381
|
+
prevScale -
|
|
382
|
+
prevClientHeight / 2;
|
|
383
|
+
|
|
384
|
+
// Step 2: Apply the new scale and frame around the midpoint of the
|
|
385
|
+
// visible area.
|
|
386
|
+
scrollTopNext =
|
|
387
|
+
( scrollTopNext + clientHeight / 2 ) * scaleValue +
|
|
388
|
+
frameSizeValue -
|
|
389
|
+
clientHeight / 2;
|
|
390
|
+
|
|
391
|
+
// Step 3: Handle an edge case so that you scroll to the top of the
|
|
392
|
+
// iframe if the top of the iframe content is visible in the container.
|
|
393
|
+
// The same edge case for the bottom is skipped because changing content
|
|
394
|
+
// makes calculating it impossible.
|
|
395
|
+
scrollTopNext = scrollTop <= prevFrameSize ? 0 : scrollTopNext;
|
|
396
|
+
|
|
397
|
+
// This is the scrollTop value if you are scrolled to the bottom of the
|
|
398
|
+
// iframe. We can't just let the browser handle it because we need to
|
|
399
|
+
// animate the scaling.
|
|
400
|
+
const maxScrollTop =
|
|
401
|
+
scrollHeight * ( scaleValue / prevScale ) +
|
|
402
|
+
frameSizeValue * 2 -
|
|
403
|
+
clientHeight;
|
|
404
|
+
|
|
405
|
+
// Step 4: Clamp the scrollTopNext between the minimum and maximum
|
|
406
|
+
// possible scrollTop positions. Round the value to avoid subpixel
|
|
407
|
+
// truncation by the browser which sometimes causes a 1px error.
|
|
408
|
+
scrollTopNext = Math.round(
|
|
409
|
+
Math.min(
|
|
410
|
+
Math.max( 0, scrollTopNext ),
|
|
411
|
+
Math.max( 0, maxScrollTop )
|
|
412
|
+
)
|
|
413
|
+
);
|
|
336
414
|
|
|
337
|
-
|
|
415
|
+
iframeDocument.documentElement.style.setProperty(
|
|
416
|
+
'--wp-block-editor-iframe-zoom-out-scroll-top',
|
|
417
|
+
`${ scrollTop }px`
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
iframeDocument.documentElement.style.setProperty(
|
|
421
|
+
'--wp-block-editor-iframe-zoom-out-scroll-top-next',
|
|
422
|
+
`${ scrollTopNext }px`
|
|
423
|
+
);
|
|
424
|
+
|
|
425
|
+
iframeDocument.documentElement.classList.add( 'zoom-out-animation' );
|
|
426
|
+
|
|
427
|
+
function onZoomOutTransitionEnd() {
|
|
428
|
+
// Remove the position fixed for the animation.
|
|
429
|
+
iframeDocument.documentElement.classList.remove(
|
|
338
430
|
'zoom-out-animation'
|
|
339
431
|
);
|
|
340
432
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
433
|
+
// Update previous values.
|
|
434
|
+
prevClientHeightRef.current = clientHeight;
|
|
435
|
+
prevFrameSizeRef.current = frameSizeValue;
|
|
436
|
+
prevScaleRef.current = scaleValue;
|
|
437
|
+
|
|
438
|
+
// Set the final scroll position that was just animated to.
|
|
439
|
+
// Disable reason: Eslint isn't smart enough to know that this is a
|
|
440
|
+
// DOM element. https://github.com/facebook/react/issues/31483
|
|
441
|
+
// eslint-disable-next-line react-compiler/react-compiler
|
|
442
|
+
iframeDocument.documentElement.scrollTop = scrollTopNext;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
let raf;
|
|
446
|
+
if ( prefersReducedMotion ) {
|
|
447
|
+
// Hack: Wait for the window values to recalculate.
|
|
448
|
+
raf = iframeDocument.defaultView.requestAnimationFrame(
|
|
449
|
+
onZoomOutTransitionEnd
|
|
450
|
+
);
|
|
451
|
+
} else {
|
|
452
|
+
iframeDocument.documentElement.addEventListener(
|
|
453
|
+
'transitionend',
|
|
454
|
+
onZoomOutTransitionEnd,
|
|
455
|
+
{ once: true }
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
return () => {
|
|
460
|
+
iframeDocument.documentElement.style.removeProperty(
|
|
461
|
+
'--wp-block-editor-iframe-zoom-out-scroll-top'
|
|
462
|
+
);
|
|
463
|
+
iframeDocument.documentElement.style.removeProperty(
|
|
464
|
+
'--wp-block-editor-iframe-zoom-out-scroll-top-next'
|
|
465
|
+
);
|
|
466
|
+
iframeDocument.documentElement.classList.remove(
|
|
467
|
+
'zoom-out-animation'
|
|
468
|
+
);
|
|
469
|
+
if ( prefersReducedMotion ) {
|
|
470
|
+
iframeDocument.defaultView.cancelAnimationFrame( raf );
|
|
471
|
+
} else {
|
|
472
|
+
iframeDocument.documentElement.removeEventListener(
|
|
473
|
+
'transitionend',
|
|
474
|
+
onZoomOutTransitionEnd
|
|
344
475
|
);
|
|
345
|
-
}
|
|
476
|
+
}
|
|
346
477
|
};
|
|
478
|
+
}, [ iframeDocument, scaleValue, frameSizeValue, prefersReducedMotion ] );
|
|
347
479
|
|
|
348
|
-
|
|
349
|
-
|
|
480
|
+
// Toggle zoom out CSS Classes only when zoom out mode changes. We could add these into the useEffect
|
|
481
|
+
// that controls settings the CSS variables, but then we would need to do more work to ensure we're
|
|
482
|
+
// only toggling these when the zoom out mode changes, as that useEffect is also triggered by a large
|
|
483
|
+
// number of dependencies.
|
|
484
|
+
useEffect( () => {
|
|
485
|
+
if ( ! iframeDocument ) {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
350
488
|
|
|
351
|
-
|
|
352
|
-
|
|
489
|
+
if ( isZoomedOut ) {
|
|
490
|
+
iframeDocument.documentElement.classList.add( 'is-zoomed-out' );
|
|
491
|
+
} else {
|
|
492
|
+
// HACK: Since we can't remove this in the cleanup, we need to do it here.
|
|
353
493
|
iframeDocument.documentElement.classList.remove( 'is-zoomed-out' );
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return () => {
|
|
497
|
+
// HACK: Skipping cleanup because it causes issues with the zoom out
|
|
498
|
+
// animation. More refactoring is needed to fix this properly.
|
|
499
|
+
// iframeDocument.documentElement.classList.remove( 'is-zoomed-out' );
|
|
354
500
|
};
|
|
355
501
|
}, [ iframeDocument, isZoomedOut ] );
|
|
356
502
|
|
|
357
503
|
// Calculate the scaling and CSS variables for the zoom out canvas
|
|
358
504
|
useEffect( () => {
|
|
359
|
-
if ( ! iframeDocument
|
|
505
|
+
if ( ! iframeDocument ) {
|
|
360
506
|
return;
|
|
361
507
|
}
|
|
362
508
|
|
|
363
|
-
const maxWidth = 750;
|
|
364
509
|
// Note: When we initialize the zoom out when the canvas is smaller (sidebars open),
|
|
365
510
|
// initialContainerWidthRef will be smaller than the full page, and reflow will happen
|
|
366
511
|
// when the canvas area becomes larger due to sidebars closing. This is a known but
|
|
@@ -371,11 +516,7 @@ function Iframe( {
|
|
|
371
516
|
// but calc( 100px / 2px ) is not.
|
|
372
517
|
iframeDocument.documentElement.style.setProperty(
|
|
373
518
|
'--wp-block-editor-iframe-zoom-out-scale',
|
|
374
|
-
|
|
375
|
-
? ( Math.min( containerWidth, maxWidth ) -
|
|
376
|
-
parseInt( frameSize ) * 2 ) /
|
|
377
|
-
scaleContainerWidth
|
|
378
|
-
: scale
|
|
519
|
+
scaleValue
|
|
379
520
|
);
|
|
380
521
|
|
|
381
522
|
// frameSize has to be a px value for the scaling and frame size to be computed correctly.
|
|
@@ -401,27 +542,29 @@ function Iframe( {
|
|
|
401
542
|
);
|
|
402
543
|
|
|
403
544
|
return () => {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
545
|
+
// HACK: Skipping cleanup because it causes issues with the zoom out
|
|
546
|
+
// animation. More refactoring is needed to fix this properly.
|
|
547
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
548
|
+
// '--wp-block-editor-iframe-zoom-out-scale'
|
|
549
|
+
// );
|
|
550
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
551
|
+
// '--wp-block-editor-iframe-zoom-out-frame-size'
|
|
552
|
+
// );
|
|
553
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
554
|
+
// '--wp-block-editor-iframe-zoom-out-content-height'
|
|
555
|
+
// );
|
|
556
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
557
|
+
// '--wp-block-editor-iframe-zoom-out-inner-height'
|
|
558
|
+
// );
|
|
559
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
560
|
+
// '--wp-block-editor-iframe-zoom-out-container-width'
|
|
561
|
+
// );
|
|
562
|
+
// iframeDocument.documentElement.style.removeProperty(
|
|
563
|
+
// '--wp-block-editor-iframe-zoom-out-scale-container-width'
|
|
564
|
+
// );
|
|
422
565
|
};
|
|
423
566
|
}, [
|
|
424
|
-
|
|
567
|
+
scaleValue,
|
|
425
568
|
frameSize,
|
|
426
569
|
iframeDocument,
|
|
427
570
|
iframeWindowInnerHeight,
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
__experimentalText as Text,
|
|
18
18
|
FlexBlock,
|
|
19
19
|
} from '@wordpress/components';
|
|
20
|
-
import { useSelect } from '@wordpress/data';
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Internal dependencies
|
|
@@ -34,8 +33,6 @@ import {
|
|
|
34
33
|
starterPatternsCategory,
|
|
35
34
|
INSERTER_PATTERN_TYPES,
|
|
36
35
|
} from './utils';
|
|
37
|
-
import { store as blockEditorStore } from '../../../store';
|
|
38
|
-
import { unlock } from '../../../lock-unlock';
|
|
39
36
|
|
|
40
37
|
const noop = () => {};
|
|
41
38
|
|
|
@@ -46,10 +43,6 @@ export function PatternCategoryPreviews( {
|
|
|
46
43
|
category,
|
|
47
44
|
showTitlesAsTooltip,
|
|
48
45
|
} ) {
|
|
49
|
-
const isZoomOutMode = useSelect(
|
|
50
|
-
( select ) => unlock( select( blockEditorStore ) ).isZoomOut(),
|
|
51
|
-
[]
|
|
52
|
-
);
|
|
53
46
|
const [ allPatterns, , onClickPattern ] = usePatternsState(
|
|
54
47
|
onInsert,
|
|
55
48
|
rootClientId,
|
|
@@ -179,15 +172,13 @@ export function PatternCategoryPreviews( {
|
|
|
179
172
|
</VStack>
|
|
180
173
|
{ currentCategoryPatterns.length > 0 && (
|
|
181
174
|
<>
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
</Text>
|
|
190
|
-
) }
|
|
175
|
+
<Text
|
|
176
|
+
size="12"
|
|
177
|
+
as="p"
|
|
178
|
+
className="block-editor-inserter__help-text"
|
|
179
|
+
>
|
|
180
|
+
{ __( 'Drag and drop patterns into the canvas.' ) }
|
|
181
|
+
</Text>
|
|
191
182
|
<BlockPatternsList
|
|
192
183
|
ref={ scrollContainerRef }
|
|
193
184
|
blockPatterns={ pagingProps.categoryPatterns }
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
privateApis as componentsPrivateApis,
|
|
7
7
|
__unstableMotion as motion,
|
|
8
8
|
} from '@wordpress/components';
|
|
9
|
-
import { useState
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
@@ -35,14 +35,13 @@ function CategoryTabs( {
|
|
|
35
35
|
const selectedTabId = selectedCategory ? selectedCategory.name : null;
|
|
36
36
|
const [ activeTabId, setActiveId ] = useState();
|
|
37
37
|
const firstTabId = categories?.[ 0 ]?.name;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}, [ selectedTabId, activeTabId, firstTabId, setActiveId ] );
|
|
38
|
+
|
|
39
|
+
// If there is no active tab, make the first tab the active tab, so that
|
|
40
|
+
// when focus is moved to the tablist, the first tab will be focused
|
|
41
|
+
// despite not being selected
|
|
42
|
+
if ( selectedTabId === null && ! activeTabId && firstTabId ) {
|
|
43
|
+
setActiveId( firstTabId );
|
|
44
|
+
}
|
|
46
45
|
|
|
47
46
|
return (
|
|
48
47
|
<Tabs
|
|
@@ -29,6 +29,15 @@ const InserterDraggableBlocks = ( {
|
|
|
29
29
|
blocks,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
const blocksContainMedia =
|
|
33
|
+
blocks.filter(
|
|
34
|
+
( block ) =>
|
|
35
|
+
( block.name === 'core/image' ||
|
|
36
|
+
block.name === 'core/audio' ||
|
|
37
|
+
block.name === 'core/video' ) &&
|
|
38
|
+
( block.attributes.url || block.attributes.src )
|
|
39
|
+
).length > 0;
|
|
40
|
+
|
|
32
41
|
const blockTypeIcon = useSelect(
|
|
33
42
|
( select ) => {
|
|
34
43
|
const { getBlockType } = select( blocksStore );
|
|
@@ -63,7 +72,7 @@ const InserterDraggableBlocks = ( {
|
|
|
63
72
|
? [ createBlock( 'core/block', { ref: pattern.id } ) ]
|
|
64
73
|
: blocks;
|
|
65
74
|
event.dataTransfer.setData(
|
|
66
|
-
'text/html',
|
|
75
|
+
blocksContainMedia ? 'default' : 'text/html',
|
|
67
76
|
serialize( parsedBlocks )
|
|
68
77
|
);
|
|
69
78
|
} }
|
|
@@ -116,6 +116,7 @@ registerBlockType( 'my-plugin/inspector-controls-example', {
|
|
|
116
116
|
|
|
117
117
|
<TextControl
|
|
118
118
|
__nextHasNoMarginBottom
|
|
119
|
+
__next40pxDefaultSize
|
|
119
120
|
label="Text Field"
|
|
120
121
|
help="Additional help text"
|
|
121
122
|
value={ textField }
|
|
@@ -208,6 +209,7 @@ function MyBlockEdit( { attributes, setAttributes } ) {
|
|
|
208
209
|
<InspectorAdvancedControls>
|
|
209
210
|
<TextControl
|
|
210
211
|
__nextHasNoMarginBottom
|
|
212
|
+
__next40pxDefaultSize
|
|
211
213
|
label="HTML anchor"
|
|
212
214
|
value={ attributes.anchor }
|
|
213
215
|
onChange={ ( nextValue ) => {
|
|
@@ -34,14 +34,14 @@ export default function InspectorControlsSlot( {
|
|
|
34
34
|
);
|
|
35
35
|
group = __experimentalGroup;
|
|
36
36
|
}
|
|
37
|
-
const
|
|
38
|
-
const fills = useSlotFills(
|
|
37
|
+
const slotFill = groups[ group ];
|
|
38
|
+
const fills = useSlotFills( slotFill?.name );
|
|
39
39
|
|
|
40
40
|
const motionContextValue = useContext( MotionContext );
|
|
41
41
|
|
|
42
42
|
const computedFillProps = useMemo(
|
|
43
43
|
() => ( {
|
|
44
|
-
...
|
|
44
|
+
...fillProps,
|
|
45
45
|
forwardedContext: [
|
|
46
46
|
...( fillProps?.forwardedContext ?? [] ),
|
|
47
47
|
[ MotionContext.Provider, { value: motionContextValue } ],
|
|
@@ -50,7 +50,7 @@ export default function InspectorControlsSlot( {
|
|
|
50
50
|
[ motionContextValue, fillProps ]
|
|
51
51
|
);
|
|
52
52
|
|
|
53
|
-
if ( !
|
|
53
|
+
if ( ! slotFill ) {
|
|
54
54
|
warning( `Unknown InspectorControls group "${ group }" provided.` );
|
|
55
55
|
return null;
|
|
56
56
|
}
|
|
@@ -59,6 +59,8 @@ export default function InspectorControlsSlot( {
|
|
|
59
59
|
return null;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
const { Slot } = slotFill;
|
|
63
|
+
|
|
62
64
|
if ( label ) {
|
|
63
65
|
return (
|
|
64
66
|
<BlockSupportToolsPanel group={ group } label={ label }>
|
|
@@ -53,9 +53,7 @@ const PositionControlsPanel = () => {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
const PositionControls = () => {
|
|
56
|
-
const fills = useSlotFills(
|
|
57
|
-
InspectorControlsGroups.position.Slot.__unstableName
|
|
58
|
-
);
|
|
56
|
+
const fills = useSlotFills( InspectorControlsGroups.position.name );
|
|
59
57
|
const hasFills = Boolean( fills && fills.length );
|
|
60
58
|
|
|
61
59
|
if ( ! hasFills ) {
|
|
@@ -46,18 +46,18 @@ export default function useInspectorControlsTabs( blockName ) {
|
|
|
46
46
|
|
|
47
47
|
// List View Tab: If there are any fills for the list group add that tab.
|
|
48
48
|
const listViewDisabled = useIsListViewTabDisabled( blockName );
|
|
49
|
-
const listFills = useSlotFills( listGroup.
|
|
49
|
+
const listFills = useSlotFills( listGroup.name );
|
|
50
50
|
const hasListFills = ! listViewDisabled && !! listFills && listFills.length;
|
|
51
51
|
|
|
52
52
|
// Styles Tab: Add this tab if there are any fills for block supports
|
|
53
53
|
// e.g. border, color, spacing, typography, etc.
|
|
54
54
|
const styleFills = [
|
|
55
|
-
...( useSlotFills( borderGroup.
|
|
56
|
-
...( useSlotFills( colorGroup.
|
|
57
|
-
...( useSlotFills( dimensionsGroup.
|
|
58
|
-
...( useSlotFills( stylesGroup.
|
|
59
|
-
...( useSlotFills( typographyGroup.
|
|
60
|
-
...( useSlotFills( effectsGroup.
|
|
55
|
+
...( useSlotFills( borderGroup.name ) || [] ),
|
|
56
|
+
...( useSlotFills( colorGroup.name ) || [] ),
|
|
57
|
+
...( useSlotFills( dimensionsGroup.name ) || [] ),
|
|
58
|
+
...( useSlotFills( stylesGroup.name ) || [] ),
|
|
59
|
+
...( useSlotFills( typographyGroup.name ) || [] ),
|
|
60
|
+
...( useSlotFills( effectsGroup.name ) || [] ),
|
|
61
61
|
];
|
|
62
62
|
const hasStyleFills = styleFills.length;
|
|
63
63
|
|
|
@@ -67,12 +67,12 @@ export default function useInspectorControlsTabs( blockName ) {
|
|
|
67
67
|
// the advanced controls slot as well to ensure they are rendered.
|
|
68
68
|
const advancedFills = [
|
|
69
69
|
...( useSlotFills( InspectorAdvancedControls.slotName ) || [] ),
|
|
70
|
-
...( useSlotFills( bindingsGroup.
|
|
70
|
+
...( useSlotFills( bindingsGroup.name ) || [] ),
|
|
71
71
|
];
|
|
72
72
|
|
|
73
73
|
const settingsFills = [
|
|
74
|
-
...( useSlotFills( defaultGroup.
|
|
75
|
-
...( useSlotFills( positionGroup.
|
|
74
|
+
...( useSlotFills( defaultGroup.name ) || [] ),
|
|
75
|
+
...( useSlotFills( positionGroup.name ) || [] ),
|
|
76
76
|
...( hasListFills && hasStyleFills > 1 ? advancedFills : [] ),
|
|
77
77
|
];
|
|
78
78
|
|