@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
|
@@ -12,6 +12,7 @@ import { privateApis as blockEditorPrivateApis, store as blockEditorStore } from
|
|
|
12
12
|
import { PluginArea } from '@wordpress/plugins';
|
|
13
13
|
import { __, sprintf } from '@wordpress/i18n';
|
|
14
14
|
import { useCallback, useMemo, useId, useRef, useState } from '@wordpress/element';
|
|
15
|
+
import { chevronDown, chevronUp } from '@wordpress/icons';
|
|
15
16
|
import { store as noticesStore } from '@wordpress/notices';
|
|
16
17
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
17
18
|
import { CommandMenu, privateApis as commandsPrivateApis } from '@wordpress/commands';
|
|
@@ -20,7 +21,7 @@ import { privateApis as blockLibraryPrivateApis } from '@wordpress/block-library
|
|
|
20
21
|
import { addQueryArgs } from '@wordpress/url';
|
|
21
22
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
22
23
|
import { store as coreStore } from '@wordpress/core-data';
|
|
23
|
-
import { ResizableBox, SlotFillProvider, Tooltip, VisuallyHidden } from '@wordpress/components';
|
|
24
|
+
import { Icon, ResizableBox, SlotFillProvider, Tooltip, VisuallyHidden, __unstableUseNavigateRegions as useNavigateRegions } from '@wordpress/components';
|
|
24
25
|
import { useMediaQuery, useRefEffect, useViewportMatch } from '@wordpress/compose';
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -40,9 +41,7 @@ import useEditPostCommands from '../../commands/use-commands';
|
|
|
40
41
|
import { usePaddingAppender } from './use-padding-appender';
|
|
41
42
|
import { useShouldIframe } from './use-should-iframe';
|
|
42
43
|
import useNavigateToEntityRecord from '../../hooks/use-navigate-to-entity-record';
|
|
43
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
44
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
45
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
44
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
46
45
|
const {
|
|
47
46
|
getLayoutStyles
|
|
48
47
|
} = unlock(blockEditorPrivateApis);
|
|
@@ -54,36 +53,24 @@ const {
|
|
|
54
53
|
} = unlock(commandsPrivateApis);
|
|
55
54
|
const {
|
|
56
55
|
Editor,
|
|
57
|
-
FullscreenMode
|
|
56
|
+
FullscreenMode,
|
|
57
|
+
NavigableRegion
|
|
58
58
|
} = unlock(editorPrivateApis);
|
|
59
59
|
const {
|
|
60
60
|
BlockKeyboardShortcuts
|
|
61
61
|
} = unlock(blockLibraryPrivateApis);
|
|
62
62
|
const DESIGN_POST_TYPES = ['wp_template', 'wp_template_part', 'wp_block', 'wp_navigation'];
|
|
63
|
-
function useEditorStyles() {
|
|
63
|
+
function useEditorStyles(...additionalStyles) {
|
|
64
64
|
const {
|
|
65
65
|
hasThemeStyleSupport,
|
|
66
|
-
editorSettings
|
|
67
|
-
isZoomedOutView,
|
|
68
|
-
renderingMode,
|
|
69
|
-
postType
|
|
66
|
+
editorSettings
|
|
70
67
|
} = useSelect(select => {
|
|
71
|
-
const {
|
|
72
|
-
__unstableGetEditorMode
|
|
73
|
-
} = select(blockEditorStore);
|
|
74
|
-
const {
|
|
75
|
-
getCurrentPostType,
|
|
76
|
-
getRenderingMode
|
|
77
|
-
} = select(editorStore);
|
|
78
|
-
const _postType = getCurrentPostType();
|
|
79
68
|
return {
|
|
80
69
|
hasThemeStyleSupport: select(editPostStore).isFeatureActive('themeStyles'),
|
|
81
|
-
editorSettings: select(editorStore).getEditorSettings()
|
|
82
|
-
isZoomedOutView: __unstableGetEditorMode() === 'zoom-out',
|
|
83
|
-
renderingMode: getRenderingMode(),
|
|
84
|
-
postType: _postType
|
|
70
|
+
editorSettings: select(editorStore).getEditorSettings()
|
|
85
71
|
};
|
|
86
72
|
}, []);
|
|
73
|
+
const addedStyles = additionalStyles.join('\n');
|
|
87
74
|
|
|
88
75
|
// Compute the default styles.
|
|
89
76
|
return useMemo(() => {
|
|
@@ -108,16 +95,13 @@ function useEditorStyles() {
|
|
|
108
95
|
});
|
|
109
96
|
}
|
|
110
97
|
const baseStyles = hasThemeStyles ? (_editorSettings$style3 = editorSettings.styles) !== null && _editorSettings$style3 !== void 0 ? _editorSettings$style3 : [] : defaultEditorStyles;
|
|
111
|
-
|
|
112
|
-
// Add a space for the typewriter effect. When typing in the last block,
|
|
113
|
-
// there needs to be room to scroll up.
|
|
114
|
-
if (!isZoomedOutView && renderingMode === 'post-only' && !DESIGN_POST_TYPES.includes(postType)) {
|
|
98
|
+
if (addedStyles) {
|
|
115
99
|
return [...baseStyles, {
|
|
116
|
-
css:
|
|
100
|
+
css: addedStyles
|
|
117
101
|
}];
|
|
118
102
|
}
|
|
119
103
|
return baseStyles;
|
|
120
|
-
}, [editorSettings.defaultEditorStyles, editorSettings.disableLayoutStyles, editorSettings.styles, hasThemeStyleSupport,
|
|
104
|
+
}, [editorSettings.defaultEditorStyles, editorSettings.disableLayoutStyles, editorSettings.styles, hasThemeStyleSupport, addedStyles]);
|
|
121
105
|
}
|
|
122
106
|
|
|
123
107
|
/**
|
|
@@ -139,7 +123,7 @@ function MetaBoxesMain({
|
|
|
139
123
|
const {
|
|
140
124
|
set: setPreference
|
|
141
125
|
} = useDispatch(preferencesStore);
|
|
142
|
-
const
|
|
126
|
+
const metaBoxesMainRef = useRef();
|
|
143
127
|
const isShort = useMediaQuery('(max-height: 549px)');
|
|
144
128
|
const [{
|
|
145
129
|
min,
|
|
@@ -151,8 +135,8 @@ function MetaBoxesMain({
|
|
|
151
135
|
const effectSizeConstraints = useRefEffect(node => {
|
|
152
136
|
const container = node.closest('.interface-interface-skeleton__content');
|
|
153
137
|
const noticeLists = container.querySelectorAll(':scope > .components-notice-list');
|
|
154
|
-
const resizeHandle = container.querySelector('.edit-post-meta-boxes-
|
|
155
|
-
const
|
|
138
|
+
const resizeHandle = container.querySelector('.edit-post-meta-boxes-main__presenter');
|
|
139
|
+
const deriveConstraints = () => {
|
|
156
140
|
const fullHeight = container.offsetHeight;
|
|
157
141
|
let nextMax = fullHeight;
|
|
158
142
|
for (const element of noticeLists) {
|
|
@@ -164,7 +148,7 @@ function MetaBoxesMain({
|
|
|
164
148
|
max: nextMax
|
|
165
149
|
});
|
|
166
150
|
};
|
|
167
|
-
const observer = new window.ResizeObserver(
|
|
151
|
+
const observer = new window.ResizeObserver(deriveConstraints);
|
|
168
152
|
observer.observe(container);
|
|
169
153
|
for (const element of noticeLists) {
|
|
170
154
|
observer.observe(element);
|
|
@@ -174,14 +158,32 @@ function MetaBoxesMain({
|
|
|
174
158
|
const separatorRef = useRef();
|
|
175
159
|
const separatorHelpId = useId();
|
|
176
160
|
const [isUntouched, setIsUntouched] = useState(true);
|
|
161
|
+
const applyHeight = (candidateHeight, isPersistent, isInstant) => {
|
|
162
|
+
const nextHeight = Math.min(max, Math.max(min, candidateHeight));
|
|
163
|
+
if (isPersistent) {
|
|
164
|
+
setPreference('core/edit-post', 'metaBoxesMainOpenHeight', nextHeight);
|
|
165
|
+
} else {
|
|
166
|
+
separatorRef.current.ariaValueNow = getAriaValueNow(nextHeight);
|
|
167
|
+
}
|
|
168
|
+
if (isInstant) {
|
|
169
|
+
metaBoxesMainRef.current.updateSize({
|
|
170
|
+
height: nextHeight,
|
|
171
|
+
// Oddly, when the event that triggered this was not from the mouse (e.g. keydown),
|
|
172
|
+
// if `width` is left unspecified a subsequent drag gesture applies a fixed
|
|
173
|
+
// width and the pane fails to widen/narrow with parent width changes from
|
|
174
|
+
// sidebars opening/closing or window resizes.
|
|
175
|
+
width: 'auto'
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
};
|
|
177
179
|
if (!hasAnyVisible) {
|
|
178
180
|
return;
|
|
179
181
|
}
|
|
180
|
-
const className = 'edit-post-meta-boxes-main';
|
|
181
182
|
const contents = /*#__PURE__*/_jsxs("div", {
|
|
182
183
|
className: clsx(
|
|
183
184
|
// The class name 'edit-post-layout__metaboxes' is retained because some plugins use it.
|
|
184
185
|
'edit-post-layout__metaboxes', !isLegacy && 'edit-post-meta-boxes-main__liner'),
|
|
186
|
+
hidden: !isLegacy && isShort && !isOpen,
|
|
185
187
|
children: [/*#__PURE__*/_jsx(MetaBoxes, {
|
|
186
188
|
location: "normal"
|
|
187
189
|
}), /*#__PURE__*/_jsx(MetaBoxes, {
|
|
@@ -199,20 +201,7 @@ function MetaBoxesMain({
|
|
|
199
201
|
}
|
|
200
202
|
const getAriaValueNow = height => Math.round((height - min) / (max - min) * 100);
|
|
201
203
|
const usedAriaValueNow = max === undefined || isAutoHeight ? 50 : getAriaValueNow(openHeight);
|
|
202
|
-
|
|
203
|
-
return /*#__PURE__*/_jsxs("details", {
|
|
204
|
-
className: className,
|
|
205
|
-
open: isOpen,
|
|
206
|
-
onToggle: ({
|
|
207
|
-
target
|
|
208
|
-
}) => {
|
|
209
|
-
setPreference('core/edit-post', 'metaBoxesMainIsOpen', target.open);
|
|
210
|
-
},
|
|
211
|
-
children: [/*#__PURE__*/_jsx("summary", {
|
|
212
|
-
children: __('Meta Boxes')
|
|
213
|
-
}), contents]
|
|
214
|
-
});
|
|
215
|
-
}
|
|
204
|
+
const toggle = () => setPreference('core/edit-post', 'metaBoxesMainIsOpen', !isOpen);
|
|
216
205
|
|
|
217
206
|
// TODO: Support more/all keyboard interactions from the window splitter pattern:
|
|
218
207
|
// https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/
|
|
@@ -222,99 +211,97 @@ function MetaBoxesMain({
|
|
|
222
211
|
ArrowDown: -20
|
|
223
212
|
}[event.key];
|
|
224
213
|
if (delta) {
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
resizableBoxRef.current.updateSize({
|
|
231
|
-
height: nextHeight,
|
|
232
|
-
// Oddly, if left unspecified a subsequent drag gesture applies a fixed
|
|
233
|
-
// width and the pane fails to shrink/grow with parent width changes from
|
|
234
|
-
// sidebars opening/closing or window resizes.
|
|
235
|
-
width: 'auto'
|
|
236
|
-
});
|
|
237
|
-
setPreference('core/edit-post', 'metaBoxesMainOpenHeight', nextHeight);
|
|
214
|
+
const pane = metaBoxesMainRef.current.resizable;
|
|
215
|
+
const fromHeight = isAutoHeight ? pane.offsetHeight : openHeight;
|
|
216
|
+
const nextHeight = delta + fromHeight;
|
|
217
|
+
applyHeight(nextHeight, true, true);
|
|
218
|
+
event.preventDefault();
|
|
238
219
|
}
|
|
239
220
|
};
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
221
|
+
const className = 'edit-post-meta-boxes-main';
|
|
222
|
+
const paneLabel = __('Meta Boxes');
|
|
223
|
+
let Pane, paneProps;
|
|
224
|
+
if (isShort) {
|
|
225
|
+
Pane = NavigableRegion;
|
|
226
|
+
paneProps = {
|
|
227
|
+
className: clsx(className, 'is-toggle-only')
|
|
228
|
+
};
|
|
229
|
+
} else {
|
|
230
|
+
Pane = ResizableBox;
|
|
231
|
+
paneProps = /** @type {Parameters<typeof ResizableBox>[0]} */{
|
|
232
|
+
as: NavigableRegion,
|
|
233
|
+
ref: metaBoxesMainRef,
|
|
234
|
+
className: clsx(className, 'is-resizable'),
|
|
235
|
+
defaultSize: {
|
|
236
|
+
height: openHeight
|
|
237
|
+
},
|
|
238
|
+
minHeight: min,
|
|
239
|
+
maxHeight: usedMax,
|
|
240
|
+
enable: {
|
|
241
|
+
top: true,
|
|
242
|
+
right: false,
|
|
243
|
+
bottom: false,
|
|
244
|
+
left: false,
|
|
245
|
+
topLeft: false,
|
|
246
|
+
topRight: false,
|
|
247
|
+
bottomRight: false,
|
|
248
|
+
bottomLeft: false
|
|
249
|
+
},
|
|
250
|
+
handleClasses: {
|
|
251
|
+
top: 'edit-post-meta-boxes-main__presenter'
|
|
252
|
+
},
|
|
253
|
+
handleComponent: {
|
|
254
|
+
top: /*#__PURE__*/_jsxs(_Fragment, {
|
|
255
|
+
children: [/*#__PURE__*/_jsx(Tooltip, {
|
|
256
|
+
text: __('Drag to resize'),
|
|
257
|
+
children: /*#__PURE__*/_jsx("button", {
|
|
258
|
+
// eslint-disable-line jsx-a11y/role-supports-aria-props
|
|
259
|
+
ref: separatorRef,
|
|
260
|
+
role: "separator" // eslint-disable-line jsx-a11y/no-interactive-element-to-noninteractive-role
|
|
261
|
+
,
|
|
262
|
+
"aria-valuenow": usedAriaValueNow,
|
|
263
|
+
"aria-label": __('Drag to resize'),
|
|
264
|
+
"aria-describedby": separatorHelpId,
|
|
265
|
+
onKeyDown: onSeparatorKeyDown
|
|
266
|
+
})
|
|
267
|
+
}), /*#__PURE__*/_jsx(VisuallyHidden, {
|
|
268
|
+
id: separatorHelpId,
|
|
269
|
+
children: __('Use up and down arrow keys to resize the meta box panel.')
|
|
270
|
+
})]
|
|
271
|
+
})
|
|
272
|
+
},
|
|
273
|
+
// Avoids hiccups while dragging over objects like iframes and ensures that
|
|
274
|
+
// the event to end the drag is captured by the target (resize handle)
|
|
275
|
+
// whether or not it’s under the pointer.
|
|
276
|
+
onPointerDown: ({
|
|
277
|
+
pointerId,
|
|
278
|
+
target
|
|
279
|
+
}) => {
|
|
280
|
+
target.setPointerCapture(pointerId);
|
|
281
|
+
},
|
|
282
|
+
onResizeStart: (event, direction, elementRef) => {
|
|
283
|
+
if (isAutoHeight) {
|
|
284
|
+
// Sets the starting height to avoid visual jumps in height and
|
|
285
|
+
// aria-valuenow being `NaN` for the first (few) resize events.
|
|
286
|
+
applyHeight(elementRef.offsetHeight, false, true);
|
|
287
|
+
setIsUntouched(false);
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
onResize: () => applyHeight(metaBoxesMainRef.current.state.height),
|
|
291
|
+
onResizeStop: () => applyHeight(metaBoxesMainRef.current.state.height, true)
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
return /*#__PURE__*/_jsxs(Pane, {
|
|
295
|
+
"aria-label": paneLabel,
|
|
296
|
+
...paneProps,
|
|
297
|
+
children: [isShort ? /*#__PURE__*/_jsxs("button", {
|
|
298
|
+
"aria-expanded": isOpen,
|
|
299
|
+
className: "edit-post-meta-boxes-main__presenter",
|
|
300
|
+
onClick: toggle,
|
|
301
|
+
children: [paneLabel, /*#__PURE__*/_jsx(Icon, {
|
|
302
|
+
icon: isOpen ? chevronUp : chevronDown
|
|
303
|
+
})]
|
|
304
|
+
}) : /*#__PURE__*/_jsx("meta", {
|
|
318
305
|
ref: effectSizeConstraints
|
|
319
306
|
}), contents]
|
|
320
307
|
});
|
|
@@ -327,7 +314,6 @@ function Layout({
|
|
|
327
314
|
}) {
|
|
328
315
|
useCommands();
|
|
329
316
|
useEditPostCommands();
|
|
330
|
-
const paddingAppenderRef = usePaddingAppender();
|
|
331
317
|
const shouldIframe = useShouldIframe();
|
|
332
318
|
const {
|
|
333
319
|
createErrorNotice
|
|
@@ -351,7 +337,8 @@ function Layout({
|
|
|
351
337
|
showMetaBoxes,
|
|
352
338
|
hasHistory,
|
|
353
339
|
isWelcomeGuideVisible,
|
|
354
|
-
templateId
|
|
340
|
+
templateId,
|
|
341
|
+
enablePaddingAppender
|
|
355
342
|
} = useSelect(select => {
|
|
356
343
|
var _getPostType$viewable;
|
|
357
344
|
const {
|
|
@@ -371,18 +358,28 @@ function Layout({
|
|
|
371
358
|
kind: 'postType',
|
|
372
359
|
name: 'wp_template'
|
|
373
360
|
});
|
|
361
|
+
const {
|
|
362
|
+
isZoomOut
|
|
363
|
+
} = unlock(select(blockEditorStore));
|
|
364
|
+
const {
|
|
365
|
+
getEditorMode,
|
|
366
|
+
getRenderingMode
|
|
367
|
+
} = select(editorStore);
|
|
368
|
+
const isRenderingPostOnly = getRenderingMode() === 'post-only';
|
|
374
369
|
return {
|
|
375
|
-
mode:
|
|
370
|
+
mode: getEditorMode(),
|
|
376
371
|
isFullscreenActive: select(editPostStore).isFeatureActive('fullscreenMode'),
|
|
377
372
|
hasActiveMetaboxes: select(editPostStore).hasMetaBoxes(),
|
|
378
373
|
hasBlockSelected: !!select(blockEditorStore).getBlockSelectionStart(),
|
|
379
374
|
showIconLabels: get('core', 'showIconLabels'),
|
|
380
375
|
isDistractionFree: get('core', 'distractionFree'),
|
|
381
|
-
showMetaBoxes: !DESIGN_POST_TYPES.includes(currentPostType) &&
|
|
376
|
+
showMetaBoxes: !DESIGN_POST_TYPES.includes(currentPostType) && isRenderingPostOnly,
|
|
382
377
|
isWelcomeGuideVisible: isFeatureActive('welcomeGuide'),
|
|
383
|
-
templateId: supportsTemplateMode && isViewable && canViewTemplate && !isEditingTemplate ? getEditedPostTemplateId() : null
|
|
378
|
+
templateId: supportsTemplateMode && isViewable && canViewTemplate && !isEditingTemplate ? getEditedPostTemplateId() : null,
|
|
379
|
+
enablePaddingAppender: !isZoomOut() && isRenderingPostOnly && !DESIGN_POST_TYPES.includes(currentPostType)
|
|
384
380
|
};
|
|
385
381
|
}, [currentPostType, isEditingTemplate, settings.supportsTemplateMode]);
|
|
382
|
+
const [paddingAppenderRef, paddingStyle] = usePaddingAppender(enablePaddingAppender);
|
|
386
383
|
|
|
387
384
|
// Set the right context for the command palette
|
|
388
385
|
const commandContext = hasBlockSelected ? 'block-selection-edit' : 'entity-edit';
|
|
@@ -393,7 +390,7 @@ function Layout({
|
|
|
393
390
|
onNavigateToPreviousEntityRecord,
|
|
394
391
|
defaultRenderingMode: 'post-only'
|
|
395
392
|
}), [settings, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord]);
|
|
396
|
-
const styles = useEditorStyles();
|
|
393
|
+
const styles = useEditorStyles(paddingStyle);
|
|
397
394
|
|
|
398
395
|
// We need to add the show-icon-labels class to the body element so it is applied to modals.
|
|
399
396
|
if (showIconLabels) {
|
|
@@ -401,11 +398,12 @@ function Layout({
|
|
|
401
398
|
} else {
|
|
402
399
|
document.body.classList.remove('show-icon-labels');
|
|
403
400
|
}
|
|
401
|
+
const navigateRegionsProps = useNavigateRegions();
|
|
404
402
|
const className = clsx('edit-post-layout', 'is-mode-' + mode, {
|
|
405
403
|
'has-metaboxes': hasActiveMetaboxes
|
|
406
404
|
});
|
|
407
405
|
function onPluginAreaError(name) {
|
|
408
|
-
createErrorNotice(sprintf(
|
|
406
|
+
createErrorNotice(sprintf(/* translators: %s: plugin name */
|
|
409
407
|
__('The "%s" plugin has encountered an error and cannot be rendered.'), name));
|
|
410
408
|
}
|
|
411
409
|
const {
|
|
@@ -427,7 +425,7 @@ function Layout({
|
|
|
427
425
|
const newItem = items[0];
|
|
428
426
|
const title = typeof newItem.title === 'string' ? newItem.title : newItem.title?.rendered;
|
|
429
427
|
createSuccessNotice(sprintf(
|
|
430
|
-
// translators: %s: Title of the created post e.g: "
|
|
428
|
+
// translators: %s: Title of the created post or template, e.g: "Hello world".
|
|
431
429
|
__('"%s" successfully created.'), decodeEntities(title)), {
|
|
432
430
|
type: 'snackbar',
|
|
433
431
|
id: 'duplicate-post-action',
|
|
@@ -459,35 +457,40 @@ function Layout({
|
|
|
459
457
|
children: /*#__PURE__*/_jsxs(ErrorBoundary, {
|
|
460
458
|
children: [/*#__PURE__*/_jsx(CommandMenu, {}), /*#__PURE__*/_jsx(WelcomeGuide, {
|
|
461
459
|
postType: currentPostType
|
|
462
|
-
}), /*#__PURE__*/
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
460
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
461
|
+
className: navigateRegionsProps.className,
|
|
462
|
+
...navigateRegionsProps,
|
|
463
|
+
ref: navigateRegionsProps.ref,
|
|
464
|
+
children: /*#__PURE__*/_jsxs(Editor, {
|
|
465
|
+
settings: editorSettings,
|
|
466
|
+
initialEdits: initialEdits,
|
|
467
|
+
postType: currentPostType,
|
|
468
|
+
postId: currentPostId,
|
|
469
|
+
templateId: templateId,
|
|
470
|
+
className: className,
|
|
471
|
+
styles: styles,
|
|
472
|
+
forceIsDirty: hasActiveMetaboxes,
|
|
473
|
+
contentRef: paddingAppenderRef,
|
|
474
|
+
disableIframe: !shouldIframe
|
|
475
|
+
// We should auto-focus the canvas (title) on load.
|
|
476
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
477
|
+
,
|
|
478
|
+
autoFocus: !isWelcomeGuideVisible,
|
|
479
|
+
onActionPerformed: onActionPerformed,
|
|
480
|
+
extraSidebarPanels: showMetaBoxes && /*#__PURE__*/_jsx(MetaBoxes, {
|
|
481
|
+
location: "side"
|
|
482
|
+
}),
|
|
483
|
+
extraContent: !isDistractionFree && showMetaBoxes && /*#__PURE__*/_jsx(MetaBoxesMain, {
|
|
484
|
+
isLegacy: !shouldIframe
|
|
485
|
+
}),
|
|
486
|
+
children: [/*#__PURE__*/_jsx(PostLockedModal, {}), /*#__PURE__*/_jsx(EditorInitialization, {}), /*#__PURE__*/_jsx(FullscreenMode, {
|
|
487
|
+
isActive: isFullscreenActive
|
|
488
|
+
}), /*#__PURE__*/_jsx(BrowserURL, {
|
|
489
|
+
hasHistory: hasHistory
|
|
490
|
+
}), /*#__PURE__*/_jsx(UnsavedChangesWarning, {}), /*#__PURE__*/_jsx(AutosaveMonitor, {}), /*#__PURE__*/_jsx(LocalAutosaveMonitor, {}), /*#__PURE__*/_jsx(EditPostKeyboardShortcuts, {}), /*#__PURE__*/_jsx(EditorKeyboardShortcutsRegister, {}), /*#__PURE__*/_jsx(BlockKeyboardShortcuts, {}), /*#__PURE__*/_jsx(InitPatternModal, {}), /*#__PURE__*/_jsx(PluginArea, {
|
|
491
|
+
onError: onPluginAreaError
|
|
492
|
+
}), /*#__PURE__*/_jsx(PostEditorMoreMenu, {}), backButton, /*#__PURE__*/_jsx(EditorSnackbars, {})]
|
|
493
|
+
})
|
|
491
494
|
})]
|
|
492
495
|
})
|
|
493
496
|
});
|