@wordpress/block-editor 14.3.1 → 14.3.2
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/README.md +2 -2
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js +9 -4
- package/build/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -1
- package/build/components/block-tools/zoom-out-toolbar.js +5 -2
- package/build/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +10 -7
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/tool-selector/index.js +2 -1
- package/build/components/tool-selector/index.js.map +1 -1
- package/build/hooks/use-bindings-attributes.js +2 -2
- package/build/hooks/use-bindings-attributes.js.map +1 -1
- package/build/hooks/use-zoom-out.js +20 -23
- package/build/hooks/use-zoom-out.js.map +1 -1
- package/build/store/private-actions.js +25 -0
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +22 -0
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +21 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +6 -2
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js +9 -4
- package/build-module/components/block-list/use-block-props/use-zoom-out-mode-exit.js.map +1 -1
- package/build-module/components/block-tools/zoom-out-toolbar.js +5 -2
- package/build-module/components/block-tools/zoom-out-toolbar.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +10 -7
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/tool-selector/index.js +2 -1
- package/build-module/components/tool-selector/index.js.map +1 -1
- package/build-module/hooks/use-bindings-attributes.js +2 -2
- package/build-module/hooks/use-bindings-attributes.js.map +1 -1
- package/build-module/hooks/use-zoom-out.js +20 -23
- package/build-module/hooks/use-zoom-out.js.map +1 -1
- package/build-module/store/private-actions.js +23 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +20 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +20 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +6 -2
- package/build-module/store/selectors.js.map +1 -1
- package/package.json +11 -11
- package/src/components/block-list/use-block-props/use-zoom-out-mode-exit.js +7 -3
- package/src/components/block-tools/zoom-out-toolbar.js +5 -2
- package/src/components/block-variation-transforms/index.js +16 -6
- package/src/components/tool-selector/index.js +4 -1
- package/src/hooks/use-bindings-attributes.js +2 -3
- package/src/hooks/use-zoom-out.js +21 -27
- package/src/store/private-actions.js +23 -0
- package/src/store/private-selectors.js +20 -0
- package/src/store/reducer.js +20 -0
- package/src/store/selectors.js +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "14.3.
|
|
3
|
+
"version": "14.3.2",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"@wordpress/api-fetch": "^7.8.1",
|
|
41
41
|
"@wordpress/blob": "^4.8.1",
|
|
42
42
|
"@wordpress/block-serialization-default-parser": "^5.8.1",
|
|
43
|
-
"@wordpress/blocks": "^13.8.
|
|
44
|
-
"@wordpress/commands": "^1.8.
|
|
45
|
-
"@wordpress/components": "^28.8.
|
|
46
|
-
"@wordpress/compose": "^7.8.
|
|
47
|
-
"@wordpress/data": "^10.8.
|
|
43
|
+
"@wordpress/blocks": "^13.8.2",
|
|
44
|
+
"@wordpress/commands": "^1.8.2",
|
|
45
|
+
"@wordpress/components": "^28.8.2",
|
|
46
|
+
"@wordpress/compose": "^7.8.2",
|
|
47
|
+
"@wordpress/data": "^10.8.2",
|
|
48
48
|
"@wordpress/date": "^5.8.1",
|
|
49
49
|
"@wordpress/deprecated": "^4.8.1",
|
|
50
50
|
"@wordpress/dom": "^4.8.1",
|
|
@@ -55,12 +55,12 @@
|
|
|
55
55
|
"@wordpress/i18n": "^5.8.1",
|
|
56
56
|
"@wordpress/icons": "^10.8.1",
|
|
57
57
|
"@wordpress/is-shallow-equal": "^5.8.1",
|
|
58
|
-
"@wordpress/keyboard-shortcuts": "^5.8.
|
|
58
|
+
"@wordpress/keyboard-shortcuts": "^5.8.2",
|
|
59
59
|
"@wordpress/keycodes": "^4.8.1",
|
|
60
|
-
"@wordpress/notices": "^5.8.
|
|
61
|
-
"@wordpress/preferences": "^4.8.
|
|
60
|
+
"@wordpress/notices": "^5.8.2",
|
|
61
|
+
"@wordpress/preferences": "^4.8.2",
|
|
62
62
|
"@wordpress/private-apis": "^1.8.1",
|
|
63
|
-
"@wordpress/rich-text": "^7.8.
|
|
63
|
+
"@wordpress/rich-text": "^7.8.2",
|
|
64
64
|
"@wordpress/style-engine": "^2.8.1",
|
|
65
65
|
"@wordpress/token-list": "^3.8.1",
|
|
66
66
|
"@wordpress/url": "^4.8.1",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "51204ac9382d0551d8fdebd3c8d4623dabfa9f3c"
|
|
92
92
|
}
|
|
@@ -16,14 +16,17 @@ import { unlock } from '../../../lock-unlock';
|
|
|
16
16
|
* @param {string} clientId Block client ID.
|
|
17
17
|
*/
|
|
18
18
|
export function useZoomOutModeExit( { editorMode } ) {
|
|
19
|
-
const { getSettings } = useSelect( blockEditorStore );
|
|
20
|
-
const { __unstableSetEditorMode } = unlock(
|
|
19
|
+
const { getSettings, isZoomOut } = unlock( useSelect( blockEditorStore ) );
|
|
20
|
+
const { __unstableSetEditorMode, resetZoomLevel } = unlock(
|
|
21
21
|
useDispatch( blockEditorStore )
|
|
22
22
|
);
|
|
23
23
|
|
|
24
24
|
return useRefEffect(
|
|
25
25
|
( node ) => {
|
|
26
|
-
|
|
26
|
+
// In "compose" mode.
|
|
27
|
+
const composeMode = editorMode === 'zoom-out' && isZoomOut();
|
|
28
|
+
|
|
29
|
+
if ( ! composeMode ) {
|
|
27
30
|
return;
|
|
28
31
|
}
|
|
29
32
|
|
|
@@ -39,6 +42,7 @@ export function useZoomOutModeExit( { editorMode } ) {
|
|
|
39
42
|
__experimentalSetIsInserterOpened( false );
|
|
40
43
|
}
|
|
41
44
|
__unstableSetEditorMode( 'edit' );
|
|
45
|
+
resetZoomLevel();
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
48
|
|
|
@@ -20,6 +20,7 @@ import BlockDraggable from '../block-draggable';
|
|
|
20
20
|
import BlockMover from '../block-mover';
|
|
21
21
|
import Shuffle from '../block-toolbar/shuffle';
|
|
22
22
|
import NavigableToolbar from '../navigable-toolbar';
|
|
23
|
+
import { unlock } from '../../lock-unlock';
|
|
23
24
|
|
|
24
25
|
export default function ZoomOutToolbar( { clientId, __unstableContentRef } ) {
|
|
25
26
|
const selected = useSelect(
|
|
@@ -84,8 +85,9 @@ export default function ZoomOutToolbar( { clientId, __unstableContentRef } ) {
|
|
|
84
85
|
setIsInserterOpened,
|
|
85
86
|
} = selected;
|
|
86
87
|
|
|
87
|
-
const { removeBlock, __unstableSetEditorMode } =
|
|
88
|
-
useDispatch( blockEditorStore )
|
|
88
|
+
const { removeBlock, __unstableSetEditorMode, resetZoomLevel } = unlock(
|
|
89
|
+
useDispatch( blockEditorStore )
|
|
90
|
+
);
|
|
89
91
|
|
|
90
92
|
const classNames = clsx( 'zoom-out-toolbar', {
|
|
91
93
|
'is-block-moving-mode': !! blockMovingMode,
|
|
@@ -144,6 +146,7 @@ export default function ZoomOutToolbar( { clientId, __unstableContentRef } ) {
|
|
|
144
146
|
setIsInserterOpened( false );
|
|
145
147
|
}
|
|
146
148
|
__unstableSetEditorMode( 'edit' );
|
|
149
|
+
resetZoomLevel();
|
|
147
150
|
__unstableContentRef.current?.focus();
|
|
148
151
|
} }
|
|
149
152
|
/>
|
|
@@ -140,19 +140,30 @@ function VariationsToggleGroupControl( {
|
|
|
140
140
|
|
|
141
141
|
function __experimentalBlockVariationTransforms( { blockClientId } ) {
|
|
142
142
|
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
143
|
-
const { activeBlockVariation, variations } = useSelect(
|
|
143
|
+
const { activeBlockVariation, variations, isContentOnly } = useSelect(
|
|
144
144
|
( select ) => {
|
|
145
|
-
const {
|
|
146
|
-
|
|
147
|
-
|
|
145
|
+
const {
|
|
146
|
+
getActiveBlockVariation,
|
|
147
|
+
getBlockVariations,
|
|
148
|
+
__experimentalHasContentRoleAttribute,
|
|
149
|
+
} = select( blocksStore );
|
|
150
|
+
const { getBlockName, getBlockAttributes, getBlockEditingMode } =
|
|
148
151
|
select( blockEditorStore );
|
|
152
|
+
|
|
149
153
|
const name = blockClientId && getBlockName( blockClientId );
|
|
154
|
+
|
|
155
|
+
const isContentBlock =
|
|
156
|
+
__experimentalHasContentRoleAttribute( name );
|
|
157
|
+
|
|
150
158
|
return {
|
|
151
159
|
activeBlockVariation: getActiveBlockVariation(
|
|
152
160
|
name,
|
|
153
161
|
getBlockAttributes( blockClientId )
|
|
154
162
|
),
|
|
155
163
|
variations: name && getBlockVariations( name, 'transform' ),
|
|
164
|
+
isContentOnly:
|
|
165
|
+
getBlockEditingMode( blockClientId ) === 'contentOnly' &&
|
|
166
|
+
! isContentBlock,
|
|
156
167
|
};
|
|
157
168
|
},
|
|
158
169
|
[ blockClientId ]
|
|
@@ -181,8 +192,7 @@ function __experimentalBlockVariationTransforms( { blockClientId } ) {
|
|
|
181
192
|
} );
|
|
182
193
|
};
|
|
183
194
|
|
|
184
|
-
|
|
185
|
-
if ( ! variations?.length ) {
|
|
195
|
+
if ( ! variations?.length || isContentOnly ) {
|
|
186
196
|
return null;
|
|
187
197
|
}
|
|
188
198
|
|
|
@@ -18,6 +18,7 @@ import { Icon, edit as editIcon } from '@wordpress/icons';
|
|
|
18
18
|
* Internal dependencies
|
|
19
19
|
*/
|
|
20
20
|
import { store as blockEditorStore } from '../../store';
|
|
21
|
+
import { unlock } from '../../lock-unlock';
|
|
21
22
|
|
|
22
23
|
const selectIcon = (
|
|
23
24
|
<SVG
|
|
@@ -35,7 +36,9 @@ function ToolSelector( props, ref ) {
|
|
|
35
36
|
( select ) => select( blockEditorStore ).__unstableGetEditorMode(),
|
|
36
37
|
[]
|
|
37
38
|
);
|
|
38
|
-
const { __unstableSetEditorMode } =
|
|
39
|
+
const { __unstableSetEditorMode } = unlock(
|
|
40
|
+
useDispatch( blockEditorStore )
|
|
41
|
+
);
|
|
39
42
|
|
|
40
43
|
return (
|
|
41
44
|
<Dropdown
|
|
@@ -162,9 +162,8 @@ export const withBlockBindingSupport = createHigherOrderComponent(
|
|
|
162
162
|
let values = {};
|
|
163
163
|
if ( ! source.getValues ) {
|
|
164
164
|
Object.keys( bindings ).forEach( ( attr ) => {
|
|
165
|
-
// Default to the
|
|
166
|
-
values[ attr ] =
|
|
167
|
-
bindings[ attr ].args?.key || source.label;
|
|
165
|
+
// Default to the the source label when `getValues` doesn't exist.
|
|
166
|
+
values[ attr ] = source.label;
|
|
168
167
|
} );
|
|
169
168
|
} else {
|
|
170
169
|
values = source.getValues( {
|
|
@@ -8,46 +8,40 @@ import { useEffect, useRef } from '@wordpress/element';
|
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { store as blockEditorStore } from '../store';
|
|
11
|
+
import { unlock } from '../lock-unlock';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
|
-
* A hook used to set the
|
|
14
|
+
* A hook used to set the zoomed out view, invoking the hook sets the mode.
|
|
14
15
|
*
|
|
15
|
-
* @param {boolean} zoomOut If we should
|
|
16
|
+
* @param {boolean} zoomOut If we should zoom out or not.
|
|
16
17
|
*/
|
|
17
18
|
export function useZoomOut( zoomOut = true ) {
|
|
18
|
-
const {
|
|
19
|
-
const {
|
|
19
|
+
const { setZoomLevel } = unlock( useDispatch( blockEditorStore ) );
|
|
20
|
+
const { isZoomOut } = unlock( useSelect( blockEditorStore ) );
|
|
20
21
|
|
|
21
|
-
const
|
|
22
|
-
const mode = __unstableGetEditorMode();
|
|
22
|
+
const originalIsZoomOutRef = useRef( null );
|
|
23
23
|
|
|
24
24
|
useEffect( () => {
|
|
25
25
|
// Only set this on mount so we know what to return to when we unmount.
|
|
26
|
-
if ( !
|
|
27
|
-
|
|
26
|
+
if ( ! originalIsZoomOutRef.current ) {
|
|
27
|
+
originalIsZoomOutRef.current = isZoomOut();
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
__unstableGetEditorMode() === 'zoom-out' &&
|
|
34
|
-
__unstableGetEditorMode() !== originalEditingModeRef.current
|
|
35
|
-
) {
|
|
36
|
-
__unstableSetEditorMode( originalEditingModeRef.current );
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}, [] );
|
|
40
|
-
|
|
41
|
-
// The effect opens the zoom-out view if we want it open and it's not currently in zoom-out mode.
|
|
42
|
-
useEffect( () => {
|
|
43
|
-
if ( zoomOut && mode !== 'zoom-out' ) {
|
|
44
|
-
__unstableSetEditorMode( 'zoom-out' );
|
|
30
|
+
// The effect opens the zoom-out view if we want it open and the canvas is not currently zoomed-out.
|
|
31
|
+
if ( zoomOut && isZoomOut() === false ) {
|
|
32
|
+
setZoomLevel( 50 );
|
|
45
33
|
} else if (
|
|
46
34
|
! zoomOut &&
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
isZoomOut() &&
|
|
36
|
+
originalIsZoomOutRef.current !== isZoomOut()
|
|
49
37
|
) {
|
|
50
|
-
|
|
38
|
+
setZoomLevel( originalIsZoomOutRef.current ? 50 : 100 );
|
|
51
39
|
}
|
|
52
|
-
|
|
40
|
+
|
|
41
|
+
return () => {
|
|
42
|
+
if ( isZoomOut() && isZoomOut() !== originalIsZoomOutRef.current ) {
|
|
43
|
+
setZoomLevel( originalIsZoomOutRef.current ? 50 : 100 );
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}, [ isZoomOut, setZoomLevel, zoomOut ] );
|
|
53
47
|
}
|
|
@@ -383,3 +383,26 @@ export const modifyContentLockBlock =
|
|
|
383
383
|
focusModeToRevert
|
|
384
384
|
);
|
|
385
385
|
};
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Sets the zoom level.
|
|
389
|
+
*
|
|
390
|
+
* @param {number} zoom the new zoom level
|
|
391
|
+
* @return {Object} Action object.
|
|
392
|
+
*/
|
|
393
|
+
export function setZoomLevel( zoom = 100 ) {
|
|
394
|
+
return {
|
|
395
|
+
type: 'SET_ZOOM_LEVEL',
|
|
396
|
+
zoom,
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Resets the Zoom state.
|
|
402
|
+
* @return {Object} Action object.
|
|
403
|
+
*/
|
|
404
|
+
export function resetZoomLevel() {
|
|
405
|
+
return {
|
|
406
|
+
type: 'RESET_ZOOM_LEVEL',
|
|
407
|
+
};
|
|
408
|
+
}
|
|
@@ -560,3 +560,23 @@ export function isZoomOutMode( state ) {
|
|
|
560
560
|
export function getSectionRootClientId( state ) {
|
|
561
561
|
return state.settings?.[ sectionRootClientIdKey ];
|
|
562
562
|
}
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Returns the zoom out state.
|
|
566
|
+
*
|
|
567
|
+
* @param {Object} state Global application state.
|
|
568
|
+
* @return {boolean} The zoom out state.
|
|
569
|
+
*/
|
|
570
|
+
export function getZoomLevel( state ) {
|
|
571
|
+
return state.zoomLevel;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Returns whether the editor is considered zoomed out.
|
|
576
|
+
*
|
|
577
|
+
* @param {Object} state Global application state.
|
|
578
|
+
* @return {boolean} Whether the editor is zoomed.
|
|
579
|
+
*/
|
|
580
|
+
export function isZoomOut( state ) {
|
|
581
|
+
return getZoomLevel( state ) < 100;
|
|
582
|
+
}
|
package/src/store/reducer.js
CHANGED
|
@@ -2085,6 +2085,25 @@ export function hoveredBlockClientId( state = false, action ) {
|
|
|
2085
2085
|
return state;
|
|
2086
2086
|
}
|
|
2087
2087
|
|
|
2088
|
+
/**
|
|
2089
|
+
* Reducer setting zoom out state.
|
|
2090
|
+
*
|
|
2091
|
+
* @param {boolean} state Current state.
|
|
2092
|
+
* @param {Object} action Dispatched action.
|
|
2093
|
+
*
|
|
2094
|
+
* @return {boolean} Updated state.
|
|
2095
|
+
*/
|
|
2096
|
+
export function zoomLevel( state = 100, action ) {
|
|
2097
|
+
switch ( action.type ) {
|
|
2098
|
+
case 'SET_ZOOM_LEVEL':
|
|
2099
|
+
return action.zoom;
|
|
2100
|
+
case 'RESET_ZOOM_LEVEL':
|
|
2101
|
+
return 100;
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
return state;
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2088
2107
|
const combinedReducers = combineReducers( {
|
|
2089
2108
|
blocks,
|
|
2090
2109
|
isDragging,
|
|
@@ -2118,6 +2137,7 @@ const combinedReducers = combineReducers( {
|
|
|
2118
2137
|
openedBlockSettingsMenu,
|
|
2119
2138
|
registeredInserterMediaCategories,
|
|
2120
2139
|
hoveredBlockClientId,
|
|
2140
|
+
zoomLevel,
|
|
2121
2141
|
} );
|
|
2122
2142
|
|
|
2123
2143
|
function withAutomaticChangeReset( reducer ) {
|
package/src/store/selectors.js
CHANGED
|
@@ -2926,6 +2926,7 @@ export const getBlockEditingMode = createRegistrySelector(
|
|
|
2926
2926
|
if ( clientId === null ) {
|
|
2927
2927
|
clientId = '';
|
|
2928
2928
|
}
|
|
2929
|
+
|
|
2929
2930
|
// In zoom-out mode, override the behavior set by
|
|
2930
2931
|
// __unstableSetBlockEditingMode to only allow editing the top-level
|
|
2931
2932
|
// sections.
|
|
@@ -2943,9 +2944,13 @@ export const getBlockEditingMode = createRegistrySelector(
|
|
|
2943
2944
|
state,
|
|
2944
2945
|
sectionRootClientId
|
|
2945
2946
|
);
|
|
2946
|
-
|
|
2947
|
-
|
|
2947
|
+
|
|
2948
|
+
// Sections are always contentOnly.
|
|
2949
|
+
if ( sectionsClientIds?.includes( clientId ) ) {
|
|
2950
|
+
return 'contentOnly';
|
|
2948
2951
|
}
|
|
2952
|
+
|
|
2953
|
+
return 'disabled';
|
|
2949
2954
|
}
|
|
2950
2955
|
|
|
2951
2956
|
const blockEditingMode = state.blockEditingModes.get( clientId );
|