@wordpress/edit-post 8.9.0 → 8.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/components/init-pattern-modal/index.js +1 -1
- package/build/components/init-pattern-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +176 -171
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/use-padding-appender.js +19 -16
- package/build/components/layout/use-padding-appender.js.map +1 -1
- package/build/components/layout/use-should-iframe.js +16 -8
- package/build/components/layout/use-should-iframe.js.map +1 -1
- package/build/components/meta-boxes/meta-box-visibility.js.map +1 -1
- package/build/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
- package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build/deprecated.js.map +1 -1
- package/build/index.js +2 -4
- package/build/index.js.map +1 -1
- package/build/store/actions.js +1 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build/utils/meta-boxes.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js +1 -2
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/init-pattern-modal/index.js +2 -4
- package/build-module/components/init-pattern-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +178 -175
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js +1 -3
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/layout/use-padding-appender.js +20 -16
- package/build-module/components/layout/use-padding-appender.js.map +1 -1
- package/build-module/components/layout/use-should-iframe.js +16 -8
- package/build-module/components/layout/use-should-iframe.js.map +1 -1
- package/build-module/components/meta-boxes/index.js +1 -3
- package/build-module/components/meta-boxes/index.js.map +1 -1
- package/build-module/components/meta-boxes/meta-box-visibility.js.map +1 -1
- package/build-module/components/meta-boxes/meta-boxes-area/index.js +1 -2
- package/build-module/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
- package/build-module/components/more-menu/index.js +1 -3
- package/build-module/components/more-menu/index.js.map +1 -1
- package/build-module/components/preferences-modal/enable-custom-fields.js +1 -3
- package/build-module/components/preferences-modal/enable-custom-fields.js.map +1 -1
- package/build-module/components/preferences-modal/meta-boxes-section.js +1 -2
- package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build-module/components/welcome-guide/default.js +1 -3
- package/build-module/components/welcome-guide/default.js.map +1 -1
- package/build-module/components/welcome-guide/image.js +1 -2
- package/build-module/components/welcome-guide/image.js.map +1 -1
- package/build-module/components/welcome-guide/template.js +1 -3
- package/build-module/components/welcome-guide/template.js.map +1 -1
- package/build-module/deprecated.js.map +1 -1
- package/build-module/index.js +2 -4
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/meta-boxes.js.map +1 -1
- package/build-style/style-rtl.css +65 -29
- package/build-style/style.css +65 -29
- package/package.json +33 -32
- package/src/components/init-pattern-modal/index.js +2 -2
- package/src/components/keyboard-shortcuts/index.js +1 -1
- package/src/components/layout/index.js +170 -174
- package/src/components/layout/style.scss +83 -43
- package/src/components/layout/use-padding-appender.js +21 -18
- package/src/components/layout/use-should-iframe.js +18 -7
- package/src/index.js +0 -2
- package/src/store/actions.js +1 -1
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
useRef,
|
|
32
32
|
useState,
|
|
33
33
|
} from '@wordpress/element';
|
|
34
|
+
import { chevronDown, chevronUp } from '@wordpress/icons';
|
|
34
35
|
import { store as noticesStore } from '@wordpress/notices';
|
|
35
36
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
36
37
|
import {
|
|
@@ -43,10 +44,12 @@ import { addQueryArgs } from '@wordpress/url';
|
|
|
43
44
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
44
45
|
import { store as coreStore } from '@wordpress/core-data';
|
|
45
46
|
import {
|
|
47
|
+
Icon,
|
|
46
48
|
ResizableBox,
|
|
47
49
|
SlotFillProvider,
|
|
48
50
|
Tooltip,
|
|
49
51
|
VisuallyHidden,
|
|
52
|
+
__unstableUseNavigateRegions as useNavigateRegions,
|
|
50
53
|
} from '@wordpress/components';
|
|
51
54
|
import {
|
|
52
55
|
useMediaQuery,
|
|
@@ -75,7 +78,7 @@ import useNavigateToEntityRecord from '../../hooks/use-navigate-to-entity-record
|
|
|
75
78
|
const { getLayoutStyles } = unlock( blockEditorPrivateApis );
|
|
76
79
|
const { useCommands } = unlock( coreCommandsPrivateApis );
|
|
77
80
|
const { useCommandContext } = unlock( commandsPrivateApis );
|
|
78
|
-
const { Editor, FullscreenMode } = unlock( editorPrivateApis );
|
|
81
|
+
const { Editor, FullscreenMode, NavigableRegion } = unlock( editorPrivateApis );
|
|
79
82
|
const { BlockKeyboardShortcuts } = unlock( blockLibraryPrivateApis );
|
|
80
83
|
const DESIGN_POST_TYPES = [
|
|
81
84
|
'wp_template',
|
|
@@ -84,27 +87,17 @@ const DESIGN_POST_TYPES = [
|
|
|
84
87
|
'wp_navigation',
|
|
85
88
|
];
|
|
86
89
|
|
|
87
|
-
function useEditorStyles() {
|
|
88
|
-
const {
|
|
89
|
-
hasThemeStyleSupport,
|
|
90
|
-
editorSettings,
|
|
91
|
-
isZoomedOutView,
|
|
92
|
-
renderingMode,
|
|
93
|
-
postType,
|
|
94
|
-
} = useSelect( ( select ) => {
|
|
95
|
-
const { __unstableGetEditorMode } = select( blockEditorStore );
|
|
96
|
-
const { getCurrentPostType, getRenderingMode } = select( editorStore );
|
|
97
|
-
const _postType = getCurrentPostType();
|
|
90
|
+
function useEditorStyles( ...additionalStyles ) {
|
|
91
|
+
const { hasThemeStyleSupport, editorSettings } = useSelect( ( select ) => {
|
|
98
92
|
return {
|
|
99
93
|
hasThemeStyleSupport:
|
|
100
94
|
select( editPostStore ).isFeatureActive( 'themeStyles' ),
|
|
101
95
|
editorSettings: select( editorStore ).getEditorSettings(),
|
|
102
|
-
isZoomedOutView: __unstableGetEditorMode() === 'zoom-out',
|
|
103
|
-
renderingMode: getRenderingMode(),
|
|
104
|
-
postType: _postType,
|
|
105
96
|
};
|
|
106
97
|
}, [] );
|
|
107
98
|
|
|
99
|
+
const addedStyles = additionalStyles.join( '\n' );
|
|
100
|
+
|
|
108
101
|
// Compute the default styles.
|
|
109
102
|
return useMemo( () => {
|
|
110
103
|
const presetStyles =
|
|
@@ -141,19 +134,8 @@ function useEditorStyles() {
|
|
|
141
134
|
? editorSettings.styles ?? []
|
|
142
135
|
: defaultEditorStyles;
|
|
143
136
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
! isZoomedOutView &&
|
|
148
|
-
renderingMode === 'post-only' &&
|
|
149
|
-
! DESIGN_POST_TYPES.includes( postType )
|
|
150
|
-
) {
|
|
151
|
-
return [
|
|
152
|
-
...baseStyles,
|
|
153
|
-
{
|
|
154
|
-
css: ':root :where(.editor-styles-wrapper)::after {content: ""; display: block; height: 40vh;}',
|
|
155
|
-
},
|
|
156
|
-
];
|
|
137
|
+
if ( addedStyles ) {
|
|
138
|
+
return [ ...baseStyles, { css: addedStyles } ];
|
|
157
139
|
}
|
|
158
140
|
|
|
159
141
|
return baseStyles;
|
|
@@ -162,7 +144,7 @@ function useEditorStyles() {
|
|
|
162
144
|
editorSettings.disableLayoutStyles,
|
|
163
145
|
editorSettings.styles,
|
|
164
146
|
hasThemeStyleSupport,
|
|
165
|
-
|
|
147
|
+
addedStyles,
|
|
166
148
|
] );
|
|
167
149
|
}
|
|
168
150
|
|
|
@@ -183,7 +165,7 @@ function MetaBoxesMain( { isLegacy } ) {
|
|
|
183
165
|
];
|
|
184
166
|
}, [] );
|
|
185
167
|
const { set: setPreference } = useDispatch( preferencesStore );
|
|
186
|
-
const
|
|
168
|
+
const metaBoxesMainRef = useRef();
|
|
187
169
|
const isShort = useMediaQuery( '(max-height: 549px)' );
|
|
188
170
|
|
|
189
171
|
const [ { min, max }, setHeightConstraints ] = useState( () => ( {} ) );
|
|
@@ -198,9 +180,9 @@ function MetaBoxesMain( { isLegacy } ) {
|
|
|
198
180
|
':scope > .components-notice-list'
|
|
199
181
|
);
|
|
200
182
|
const resizeHandle = container.querySelector(
|
|
201
|
-
'.edit-post-meta-boxes-
|
|
183
|
+
'.edit-post-meta-boxes-main__presenter'
|
|
202
184
|
);
|
|
203
|
-
const
|
|
185
|
+
const deriveConstraints = () => {
|
|
204
186
|
const fullHeight = container.offsetHeight;
|
|
205
187
|
let nextMax = fullHeight;
|
|
206
188
|
for ( const element of noticeLists ) {
|
|
@@ -209,7 +191,7 @@ function MetaBoxesMain( { isLegacy } ) {
|
|
|
209
191
|
const nextMin = resizeHandle.offsetHeight;
|
|
210
192
|
setHeightConstraints( { min: nextMin, max: nextMax } );
|
|
211
193
|
};
|
|
212
|
-
const observer = new window.ResizeObserver(
|
|
194
|
+
const observer = new window.ResizeObserver( deriveConstraints );
|
|
213
195
|
observer.observe( container );
|
|
214
196
|
for ( const element of noticeLists ) {
|
|
215
197
|
observer.observe( element );
|
|
@@ -221,12 +203,33 @@ function MetaBoxesMain( { isLegacy } ) {
|
|
|
221
203
|
const separatorHelpId = useId();
|
|
222
204
|
|
|
223
205
|
const [ isUntouched, setIsUntouched ] = useState( true );
|
|
206
|
+
const applyHeight = ( candidateHeight, isPersistent, isInstant ) => {
|
|
207
|
+
const nextHeight = Math.min( max, Math.max( min, candidateHeight ) );
|
|
208
|
+
if ( isPersistent ) {
|
|
209
|
+
setPreference(
|
|
210
|
+
'core/edit-post',
|
|
211
|
+
'metaBoxesMainOpenHeight',
|
|
212
|
+
nextHeight
|
|
213
|
+
);
|
|
214
|
+
} else {
|
|
215
|
+
separatorRef.current.ariaValueNow = getAriaValueNow( nextHeight );
|
|
216
|
+
}
|
|
217
|
+
if ( isInstant ) {
|
|
218
|
+
metaBoxesMainRef.current.updateSize( {
|
|
219
|
+
height: nextHeight,
|
|
220
|
+
// Oddly, when the event that triggered this was not from the mouse (e.g. keydown),
|
|
221
|
+
// if `width` is left unspecified a subsequent drag gesture applies a fixed
|
|
222
|
+
// width and the pane fails to widen/narrow with parent width changes from
|
|
223
|
+
// sidebars opening/closing or window resizes.
|
|
224
|
+
width: 'auto',
|
|
225
|
+
} );
|
|
226
|
+
}
|
|
227
|
+
};
|
|
224
228
|
|
|
225
229
|
if ( ! hasAnyVisible ) {
|
|
226
230
|
return;
|
|
227
231
|
}
|
|
228
232
|
|
|
229
|
-
const className = 'edit-post-meta-boxes-main';
|
|
230
233
|
const contents = (
|
|
231
234
|
<div
|
|
232
235
|
className={ clsx(
|
|
@@ -234,6 +237,7 @@ function MetaBoxesMain( { isLegacy } ) {
|
|
|
234
237
|
'edit-post-layout__metaboxes',
|
|
235
238
|
! isLegacy && 'edit-post-meta-boxes-main__liner'
|
|
236
239
|
) }
|
|
240
|
+
hidden={ ! isLegacy && isShort && ! isOpen }
|
|
237
241
|
>
|
|
238
242
|
<MetaBoxes location="normal" />
|
|
239
243
|
<MetaBoxes location="advanced" />
|
|
@@ -256,59 +260,39 @@ function MetaBoxesMain( { isLegacy } ) {
|
|
|
256
260
|
const usedAriaValueNow =
|
|
257
261
|
max === undefined || isAutoHeight ? 50 : getAriaValueNow( openHeight );
|
|
258
262
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
<details
|
|
262
|
-
className={ className }
|
|
263
|
-
open={ isOpen }
|
|
264
|
-
onToggle={ ( { target } ) => {
|
|
265
|
-
setPreference(
|
|
266
|
-
'core/edit-post',
|
|
267
|
-
'metaBoxesMainIsOpen',
|
|
268
|
-
target.open
|
|
269
|
-
);
|
|
270
|
-
} }
|
|
271
|
-
>
|
|
272
|
-
<summary>{ __( 'Meta Boxes' ) }</summary>
|
|
273
|
-
{ contents }
|
|
274
|
-
</details>
|
|
275
|
-
);
|
|
276
|
-
}
|
|
263
|
+
const toggle = () =>
|
|
264
|
+
setPreference( 'core/edit-post', 'metaBoxesMainIsOpen', ! isOpen );
|
|
277
265
|
|
|
278
266
|
// TODO: Support more/all keyboard interactions from the window splitter pattern:
|
|
279
267
|
// https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/
|
|
280
268
|
const onSeparatorKeyDown = ( event ) => {
|
|
281
269
|
const delta = { ArrowUp: 20, ArrowDown: -20 }[ event.key ];
|
|
282
270
|
if ( delta ) {
|
|
283
|
-
const
|
|
284
|
-
const fromHeight = isAutoHeight
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
max,
|
|
289
|
-
Math.max( min, delta + fromHeight )
|
|
290
|
-
);
|
|
291
|
-
resizableBoxRef.current.updateSize( {
|
|
292
|
-
height: nextHeight,
|
|
293
|
-
// Oddly, if left unspecified a subsequent drag gesture applies a fixed
|
|
294
|
-
// width and the pane fails to shrink/grow with parent width changes from
|
|
295
|
-
// sidebars opening/closing or window resizes.
|
|
296
|
-
width: 'auto',
|
|
297
|
-
} );
|
|
298
|
-
setPreference(
|
|
299
|
-
'core/edit-post',
|
|
300
|
-
'metaBoxesMainOpenHeight',
|
|
301
|
-
nextHeight
|
|
302
|
-
);
|
|
271
|
+
const pane = metaBoxesMainRef.current.resizable;
|
|
272
|
+
const fromHeight = isAutoHeight ? pane.offsetHeight : openHeight;
|
|
273
|
+
const nextHeight = delta + fromHeight;
|
|
274
|
+
applyHeight( nextHeight, true, true );
|
|
275
|
+
event.preventDefault();
|
|
303
276
|
}
|
|
304
277
|
};
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
278
|
+
const className = 'edit-post-meta-boxes-main';
|
|
279
|
+
const paneLabel = __( 'Meta Boxes' );
|
|
280
|
+
let Pane, paneProps;
|
|
281
|
+
if ( isShort ) {
|
|
282
|
+
Pane = NavigableRegion;
|
|
283
|
+
paneProps = {
|
|
284
|
+
className: clsx( className, 'is-toggle-only' ),
|
|
285
|
+
};
|
|
286
|
+
} else {
|
|
287
|
+
Pane = ResizableBox;
|
|
288
|
+
paneProps = /** @type {Parameters<typeof ResizableBox>[0]} */ ( {
|
|
289
|
+
as: NavigableRegion,
|
|
290
|
+
ref: metaBoxesMainRef,
|
|
291
|
+
className: clsx( className, 'is-resizable' ),
|
|
292
|
+
defaultSize: { height: openHeight },
|
|
293
|
+
minHeight: min,
|
|
294
|
+
maxHeight: usedMax,
|
|
295
|
+
enable: {
|
|
312
296
|
top: true,
|
|
313
297
|
right: false,
|
|
314
298
|
bottom: false,
|
|
@@ -317,72 +301,66 @@ function MetaBoxesMain( { isLegacy } ) {
|
|
|
317
301
|
topRight: false,
|
|
318
302
|
bottomRight: false,
|
|
319
303
|
bottomLeft: false,
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
bounds="parent"
|
|
324
|
-
boundsByDirection
|
|
325
|
-
// Avoids hiccups while dragging over objects like iframes and ensures that
|
|
326
|
-
// the event to end the drag is captured by the target (resize handle)
|
|
327
|
-
// whether or not it’s under the pointer.
|
|
328
|
-
onPointerDown={ ( { pointerId, target } ) => {
|
|
329
|
-
target.setPointerCapture( pointerId );
|
|
330
|
-
} }
|
|
331
|
-
onResizeStart={ ( event, direction, elementRef ) => {
|
|
332
|
-
if ( isAutoHeight ) {
|
|
333
|
-
const heightNow = elementRef.offsetHeight;
|
|
334
|
-
// Sets the starting height to avoid visual jumps in height and
|
|
335
|
-
// aria-valuenow being `NaN` for the first (few) resize events.
|
|
336
|
-
resizableBoxRef.current.updateSize( { height: heightNow } );
|
|
337
|
-
// Causes `maxHeight` to update to full `max` value instead of half.
|
|
338
|
-
setIsUntouched( false );
|
|
339
|
-
}
|
|
340
|
-
} }
|
|
341
|
-
onResize={ () => {
|
|
342
|
-
const { height } = resizableBoxRef.current.state;
|
|
343
|
-
const separator = separatorRef.current;
|
|
344
|
-
separator.ariaValueNow = getAriaValueNow( height );
|
|
345
|
-
} }
|
|
346
|
-
onResizeStop={ () => {
|
|
347
|
-
const nextHeight = resizableBoxRef.current.state.height;
|
|
348
|
-
setPreference(
|
|
349
|
-
'core/edit-post',
|
|
350
|
-
'metaBoxesMainOpenHeight',
|
|
351
|
-
nextHeight
|
|
352
|
-
);
|
|
353
|
-
} }
|
|
354
|
-
handleClasses={ {
|
|
355
|
-
top: 'edit-post-meta-boxes-main__resize-handle',
|
|
356
|
-
} }
|
|
357
|
-
handleComponent={ {
|
|
304
|
+
},
|
|
305
|
+
handleClasses: { top: 'edit-post-meta-boxes-main__presenter' },
|
|
306
|
+
handleComponent: {
|
|
358
307
|
top: (
|
|
359
308
|
<>
|
|
360
309
|
<Tooltip text={ __( 'Drag to resize' ) }>
|
|
361
|
-
|
|
362
|
-
{ /* eslint-disable-next-line jsx-a11y/role-supports-aria-props */ }
|
|
363
|
-
<button
|
|
310
|
+
<button // eslint-disable-line jsx-a11y/role-supports-aria-props
|
|
364
311
|
ref={ separatorRef }
|
|
312
|
+
role="separator" // eslint-disable-line jsx-a11y/no-interactive-element-to-noninteractive-role
|
|
313
|
+
aria-valuenow={ usedAriaValueNow }
|
|
365
314
|
aria-label={ __( 'Drag to resize' ) }
|
|
366
315
|
aria-describedby={ separatorHelpId }
|
|
367
316
|
onKeyDown={ onSeparatorKeyDown }
|
|
368
|
-
// Disable reason: buttons are allowed to be separator role.
|
|
369
|
-
// eslint-disable-next-line jsx-a11y/no-interactive-element-to-noninteractive-role
|
|
370
|
-
role="separator"
|
|
371
|
-
aria-valuenow={ usedAriaValueNow }
|
|
372
317
|
/>
|
|
373
318
|
</Tooltip>
|
|
374
319
|
<VisuallyHidden id={ separatorHelpId }>
|
|
375
320
|
{ __(
|
|
376
|
-
'Use up and down arrow keys to resize the
|
|
321
|
+
'Use up and down arrow keys to resize the meta box panel.'
|
|
377
322
|
) }
|
|
378
323
|
</VisuallyHidden>
|
|
379
324
|
</>
|
|
380
325
|
),
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
|
|
326
|
+
},
|
|
327
|
+
// Avoids hiccups while dragging over objects like iframes and ensures that
|
|
328
|
+
// the event to end the drag is captured by the target (resize handle)
|
|
329
|
+
// whether or not it’s under the pointer.
|
|
330
|
+
onPointerDown: ( { pointerId, target } ) => {
|
|
331
|
+
target.setPointerCapture( pointerId );
|
|
332
|
+
},
|
|
333
|
+
onResizeStart: ( event, direction, elementRef ) => {
|
|
334
|
+
if ( isAutoHeight ) {
|
|
335
|
+
// Sets the starting height to avoid visual jumps in height and
|
|
336
|
+
// aria-valuenow being `NaN` for the first (few) resize events.
|
|
337
|
+
applyHeight( elementRef.offsetHeight, false, true );
|
|
338
|
+
setIsUntouched( false );
|
|
339
|
+
}
|
|
340
|
+
},
|
|
341
|
+
onResize: () =>
|
|
342
|
+
applyHeight( metaBoxesMainRef.current.state.height ),
|
|
343
|
+
onResizeStop: () =>
|
|
344
|
+
applyHeight( metaBoxesMainRef.current.state.height, true ),
|
|
345
|
+
} );
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return (
|
|
349
|
+
<Pane aria-label={ paneLabel } { ...paneProps }>
|
|
350
|
+
{ isShort ? (
|
|
351
|
+
<button
|
|
352
|
+
aria-expanded={ isOpen }
|
|
353
|
+
className="edit-post-meta-boxes-main__presenter"
|
|
354
|
+
onClick={ toggle }
|
|
355
|
+
>
|
|
356
|
+
{ paneLabel }
|
|
357
|
+
<Icon icon={ isOpen ? chevronUp : chevronDown } />
|
|
358
|
+
</button>
|
|
359
|
+
) : (
|
|
360
|
+
<meta ref={ effectSizeConstraints } />
|
|
361
|
+
) }
|
|
384
362
|
{ contents }
|
|
385
|
-
</
|
|
363
|
+
</Pane>
|
|
386
364
|
);
|
|
387
365
|
}
|
|
388
366
|
|
|
@@ -394,7 +372,6 @@ function Layout( {
|
|
|
394
372
|
} ) {
|
|
395
373
|
useCommands();
|
|
396
374
|
useEditPostCommands();
|
|
397
|
-
const paddingAppenderRef = usePaddingAppender();
|
|
398
375
|
const shouldIframe = useShouldIframe();
|
|
399
376
|
const { createErrorNotice } = useDispatch( noticesStore );
|
|
400
377
|
const {
|
|
@@ -418,6 +395,7 @@ function Layout( {
|
|
|
418
395
|
hasHistory,
|
|
419
396
|
isWelcomeGuideVisible,
|
|
420
397
|
templateId,
|
|
398
|
+
enablePaddingAppender,
|
|
421
399
|
} = useSelect(
|
|
422
400
|
( select ) => {
|
|
423
401
|
const { get } = select( preferencesStore );
|
|
@@ -433,9 +411,12 @@ function Layout( {
|
|
|
433
411
|
kind: 'postType',
|
|
434
412
|
name: 'wp_template',
|
|
435
413
|
} );
|
|
414
|
+
const { isZoomOut } = unlock( select( blockEditorStore ) );
|
|
415
|
+
const { getEditorMode, getRenderingMode } = select( editorStore );
|
|
416
|
+
const isRenderingPostOnly = getRenderingMode() === 'post-only';
|
|
436
417
|
|
|
437
418
|
return {
|
|
438
|
-
mode:
|
|
419
|
+
mode: getEditorMode(),
|
|
439
420
|
isFullscreenActive:
|
|
440
421
|
select( editPostStore ).isFeatureActive( 'fullscreenMode' ),
|
|
441
422
|
hasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),
|
|
@@ -445,7 +426,7 @@ function Layout( {
|
|
|
445
426
|
isDistractionFree: get( 'core', 'distractionFree' ),
|
|
446
427
|
showMetaBoxes:
|
|
447
428
|
! DESIGN_POST_TYPES.includes( currentPostType ) &&
|
|
448
|
-
|
|
429
|
+
isRenderingPostOnly,
|
|
449
430
|
isWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),
|
|
450
431
|
templateId:
|
|
451
432
|
supportsTemplateMode &&
|
|
@@ -454,10 +435,17 @@ function Layout( {
|
|
|
454
435
|
! isEditingTemplate
|
|
455
436
|
? getEditedPostTemplateId()
|
|
456
437
|
: null,
|
|
438
|
+
enablePaddingAppender:
|
|
439
|
+
! isZoomOut() &&
|
|
440
|
+
isRenderingPostOnly &&
|
|
441
|
+
! DESIGN_POST_TYPES.includes( currentPostType ),
|
|
457
442
|
};
|
|
458
443
|
},
|
|
459
444
|
[ currentPostType, isEditingTemplate, settings.supportsTemplateMode ]
|
|
460
445
|
);
|
|
446
|
+
const [ paddingAppenderRef, paddingStyle ] = usePaddingAppender(
|
|
447
|
+
enablePaddingAppender
|
|
448
|
+
);
|
|
461
449
|
|
|
462
450
|
// Set the right context for the command palette
|
|
463
451
|
const commandContext = hasBlockSelected
|
|
@@ -473,7 +461,7 @@ function Layout( {
|
|
|
473
461
|
} ),
|
|
474
462
|
[ settings, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord ]
|
|
475
463
|
);
|
|
476
|
-
const styles = useEditorStyles();
|
|
464
|
+
const styles = useEditorStyles( paddingStyle );
|
|
477
465
|
|
|
478
466
|
// We need to add the show-icon-labels class to the body element so it is applied to modals.
|
|
479
467
|
if ( showIconLabels ) {
|
|
@@ -482,6 +470,8 @@ function Layout( {
|
|
|
482
470
|
document.body.classList.remove( 'show-icon-labels' );
|
|
483
471
|
}
|
|
484
472
|
|
|
473
|
+
const navigateRegionsProps = useNavigateRegions();
|
|
474
|
+
|
|
485
475
|
const className = clsx( 'edit-post-layout', 'is-mode-' + mode, {
|
|
486
476
|
'has-metaboxes': hasActiveMetaboxes,
|
|
487
477
|
} );
|
|
@@ -521,7 +511,7 @@ function Layout( {
|
|
|
521
511
|
: newItem.title?.rendered;
|
|
522
512
|
createSuccessNotice(
|
|
523
513
|
sprintf(
|
|
524
|
-
// translators: %s: Title of the created post e.g: "
|
|
514
|
+
// translators: %s: Title of the created post or template, e.g: "Hello world".
|
|
525
515
|
__( '"%s" successfully created.' ),
|
|
526
516
|
decodeEntities( title )
|
|
527
517
|
),
|
|
@@ -567,47 +557,53 @@ function Layout( {
|
|
|
567
557
|
<ErrorBoundary>
|
|
568
558
|
<CommandMenu />
|
|
569
559
|
<WelcomeGuide postType={ currentPostType } />
|
|
570
|
-
<
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
postId={ currentPostId }
|
|
575
|
-
templateId={ templateId }
|
|
576
|
-
className={ className }
|
|
577
|
-
styles={ styles }
|
|
578
|
-
forceIsDirty={ hasActiveMetaboxes }
|
|
579
|
-
contentRef={ paddingAppenderRef }
|
|
580
|
-
disableIframe={ ! shouldIframe }
|
|
581
|
-
// We should auto-focus the canvas (title) on load.
|
|
582
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
583
|
-
autoFocus={ ! isWelcomeGuideVisible }
|
|
584
|
-
onActionPerformed={ onActionPerformed }
|
|
585
|
-
extraSidebarPanels={
|
|
586
|
-
showMetaBoxes && <MetaBoxes location="side" />
|
|
587
|
-
}
|
|
588
|
-
extraContent={
|
|
589
|
-
! isDistractionFree &&
|
|
590
|
-
showMetaBoxes && (
|
|
591
|
-
<MetaBoxesMain isLegacy={ ! shouldIframe } />
|
|
592
|
-
)
|
|
593
|
-
}
|
|
560
|
+
<div
|
|
561
|
+
className={ navigateRegionsProps.className }
|
|
562
|
+
{ ...navigateRegionsProps }
|
|
563
|
+
ref={ navigateRegionsProps.ref }
|
|
594
564
|
>
|
|
595
|
-
<
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
565
|
+
<Editor
|
|
566
|
+
settings={ editorSettings }
|
|
567
|
+
initialEdits={ initialEdits }
|
|
568
|
+
postType={ currentPostType }
|
|
569
|
+
postId={ currentPostId }
|
|
570
|
+
templateId={ templateId }
|
|
571
|
+
className={ className }
|
|
572
|
+
styles={ styles }
|
|
573
|
+
forceIsDirty={ hasActiveMetaboxes }
|
|
574
|
+
contentRef={ paddingAppenderRef }
|
|
575
|
+
disableIframe={ ! shouldIframe }
|
|
576
|
+
// We should auto-focus the canvas (title) on load.
|
|
577
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
578
|
+
autoFocus={ ! isWelcomeGuideVisible }
|
|
579
|
+
onActionPerformed={ onActionPerformed }
|
|
580
|
+
extraSidebarPanels={
|
|
581
|
+
showMetaBoxes && <MetaBoxes location="side" />
|
|
582
|
+
}
|
|
583
|
+
extraContent={
|
|
584
|
+
! isDistractionFree &&
|
|
585
|
+
showMetaBoxes && (
|
|
586
|
+
<MetaBoxesMain isLegacy={ ! shouldIframe } />
|
|
587
|
+
)
|
|
588
|
+
}
|
|
589
|
+
>
|
|
590
|
+
<PostLockedModal />
|
|
591
|
+
<EditorInitialization />
|
|
592
|
+
<FullscreenMode isActive={ isFullscreenActive } />
|
|
593
|
+
<BrowserURL hasHistory={ hasHistory } />
|
|
594
|
+
<UnsavedChangesWarning />
|
|
595
|
+
<AutosaveMonitor />
|
|
596
|
+
<LocalAutosaveMonitor />
|
|
597
|
+
<EditPostKeyboardShortcuts />
|
|
598
|
+
<EditorKeyboardShortcutsRegister />
|
|
599
|
+
<BlockKeyboardShortcuts />
|
|
600
|
+
<InitPatternModal />
|
|
601
|
+
<PluginArea onError={ onPluginAreaError } />
|
|
602
|
+
<PostEditorMoreMenu />
|
|
603
|
+
{ backButton }
|
|
604
|
+
<EditorSnackbars />
|
|
605
|
+
</Editor>
|
|
606
|
+
</div>
|
|
611
607
|
</ErrorBoundary>
|
|
612
608
|
</SlotFillProvider>
|
|
613
609
|
);
|
|
@@ -1,71 +1,111 @@
|
|
|
1
|
-
$resize-handle-height: $grid-unit-30;
|
|
2
|
-
|
|
3
1
|
.edit-post-meta-boxes-main {
|
|
4
2
|
filter: drop-shadow(0 -1px rgba($color: #000, $alpha: 0.133)); // 0.133 = $gray-200 but with alpha.
|
|
3
|
+
// Windows High Contrast mode will show this outline, but not the shadow.
|
|
4
|
+
outline: 1px solid transparent;
|
|
5
5
|
background-color: $white;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
padding-top: $resize-handle-height;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// The component renders as a details element in short viewports.
|
|
13
|
-
&:is(details) {
|
|
14
|
-
& > summary {
|
|
15
|
-
cursor: pointer;
|
|
16
|
-
color: $gray-900;
|
|
17
|
-
background-color: $white;
|
|
18
|
-
height: $button-size-compact;
|
|
19
|
-
line-height: $button-size-compact;
|
|
20
|
-
font-size: 13px;
|
|
21
|
-
padding-left: $grid-unit-30;
|
|
22
|
-
box-shadow: 0 $border-width $gray-300;
|
|
23
|
-
}
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
overflow: hidden;
|
|
24
9
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
top: 0;
|
|
28
|
-
z-index: 1;
|
|
29
|
-
}
|
|
10
|
+
&.is-resizable {
|
|
11
|
+
padding-block-start: $grid-unit-30;
|
|
30
12
|
}
|
|
31
13
|
}
|
|
32
14
|
|
|
33
|
-
.edit-post-meta-boxes-
|
|
15
|
+
.edit-post-meta-boxes-main__presenter {
|
|
34
16
|
display: flex;
|
|
35
|
-
// The position is absolute by default inline style of ResizableBox.
|
|
36
|
-
inset: 0 0 auto 0;
|
|
37
|
-
height: $resize-handle-height;
|
|
38
17
|
box-shadow: 0 $border-width $gray-300;
|
|
18
|
+
// Windows High Contrast mode will show this outline, but not the shadow.
|
|
19
|
+
outline: 1px solid transparent;
|
|
20
|
+
position: relative;
|
|
21
|
+
z-index: 1;
|
|
39
22
|
|
|
40
|
-
|
|
23
|
+
// Button style reset for both toggle or resizable.
|
|
24
|
+
.is-toggle-only > &,
|
|
25
|
+
.is-resizable.edit-post-meta-boxes-main & > button {
|
|
41
26
|
appearance: none;
|
|
42
|
-
cursor: inherit;
|
|
43
|
-
margin: auto;
|
|
44
27
|
padding: 0;
|
|
45
28
|
border: none;
|
|
46
29
|
outline: none;
|
|
47
|
-
background-color:
|
|
48
|
-
width: $grid-unit-80;
|
|
49
|
-
height: $grid-unit-05;
|
|
50
|
-
border-radius: $radius-small;
|
|
51
|
-
transition: width 0.3s ease-out;
|
|
52
|
-
@include reduce-motion("transition");
|
|
30
|
+
background-color: transparent;
|
|
53
31
|
}
|
|
54
32
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
33
|
+
.is-toggle-only > & {
|
|
34
|
+
flex-shrink: 0;
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
height: $button-size-compact;
|
|
37
|
+
justify-content: space-between;
|
|
38
|
+
align-items: center;
|
|
39
|
+
padding-inline: $grid-unit-30 $grid-unit-15;
|
|
40
|
+
|
|
41
|
+
&:is(:hover, :focus-visible) {
|
|
42
|
+
color: var(--wp-admin-theme-color);
|
|
43
|
+
}
|
|
44
|
+
&:focus-visible::after {
|
|
45
|
+
content: "";
|
|
46
|
+
position: absolute;
|
|
47
|
+
inset: var(--wp-admin-border-width-focus);
|
|
48
|
+
@include button-style__focus();
|
|
49
|
+
}
|
|
50
|
+
> svg {
|
|
51
|
+
fill: currentColor;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.is-resizable.edit-post-meta-boxes-main & {
|
|
56
|
+
inset: 0 0 auto;
|
|
57
|
+
|
|
58
|
+
> button {
|
|
59
|
+
cursor: inherit;
|
|
60
|
+
width: $grid-unit-80;
|
|
61
|
+
height: $grid-unit-30;
|
|
62
|
+
margin: auto;
|
|
63
|
+
|
|
64
|
+
&::before {
|
|
65
|
+
content: "";
|
|
66
|
+
background-color: $gray-300;
|
|
67
|
+
// Windows High Contrast mode will show this outline, but not the background-color.
|
|
68
|
+
outline: 2px solid transparent;
|
|
69
|
+
outline-offset: -2px;
|
|
70
|
+
position: absolute;
|
|
71
|
+
inset-block: calc(50% - #{$grid-unit-05} / 2) auto;
|
|
72
|
+
transform: translateX(-50%);
|
|
73
|
+
width: inherit;
|
|
74
|
+
height: $grid-unit-05;
|
|
75
|
+
border-radius: $radius-small;
|
|
76
|
+
transition: width 0.3s ease-out;
|
|
77
|
+
@include reduce-motion("transition");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&:is(:hover, :focus-within) > button::before {
|
|
82
|
+
background-color: var(--wp-admin-theme-color);
|
|
83
|
+
width: $grid-unit-80 + $grid-unit-20;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@media (pointer: coarse) {
|
|
89
|
+
.is-resizable.edit-post-meta-boxes-main {
|
|
90
|
+
padding-block-start: $button-size-compact;
|
|
91
|
+
|
|
92
|
+
.edit-post-meta-boxes-main__presenter > button {
|
|
93
|
+
height: $button-size-compact;
|
|
94
|
+
}
|
|
59
95
|
}
|
|
60
96
|
}
|
|
61
97
|
|
|
62
98
|
.edit-post-meta-boxes-main__liner {
|
|
63
99
|
overflow: auto;
|
|
64
|
-
max-height: 100%;
|
|
65
100
|
// Keep the contents behind the resize handle or details summary.
|
|
66
101
|
isolation: isolate;
|
|
67
102
|
}
|
|
68
103
|
|
|
104
|
+
// In case the canvas is not iframe’d.
|
|
105
|
+
.edit-post-layout__metaboxes {
|
|
106
|
+
clear: both;
|
|
107
|
+
}
|
|
108
|
+
|
|
69
109
|
.has-metaboxes .editor-visual-editor {
|
|
70
110
|
flex: 1;
|
|
71
111
|
|