@wordpress/edit-post 8.45.1-next.v.202605131032.0 → 8.47.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/back-button/fullscreen-mode-close.cjs +10 -3
- package/build/components/back-button/fullscreen-mode-close.cjs.map +3 -3
- package/build/components/layout/index.cjs +34 -21
- package/build/components/layout/index.cjs.map +3 -3
- package/build/components/meta-boxes/meta-boxes-area/index.cjs +1 -1
- package/build/components/meta-boxes/meta-boxes-area/index.cjs.map +2 -2
- package/build/components/meta-boxes/use-meta-box-initialization.cjs +21 -7
- package/build/components/meta-boxes/use-meta-box-initialization.cjs.map +2 -2
- package/build/index.cjs +120 -9
- package/build/index.cjs.map +3 -3
- package/build-module/components/back-button/fullscreen-mode-close.mjs +21 -8
- package/build-module/components/back-button/fullscreen-mode-close.mjs.map +2 -2
- package/build-module/components/layout/index.mjs +37 -25
- package/build-module/components/layout/index.mjs.map +2 -2
- package/build-module/components/meta-boxes/meta-boxes-area/index.mjs +1 -1
- package/build-module/components/meta-boxes/meta-boxes-area/index.mjs.map +2 -2
- package/build-module/components/meta-boxes/use-meta-box-initialization.mjs +21 -7
- package/build-module/components/meta-boxes/use-meta-box-initialization.mjs.map +2 -2
- package/build-module/index.mjs +121 -10
- package/build-module/index.mjs.map +2 -2
- package/build-style/experimental-admin-bar-in-editor-rtl.css +50 -0
- package/build-style/experimental-admin-bar-in-editor.css +50 -0
- package/build-style/style-rtl.css +53 -2
- package/build-style/style.css +53 -2
- package/package.json +36 -36
- package/src/components/back-button/fullscreen-mode-close.js +39 -21
- package/src/components/layout/index.js +75 -66
- package/src/components/layout/index.native.js +3 -3
- package/src/components/meta-boxes/meta-boxes-area/index.js +3 -1
- package/src/components/meta-boxes/meta-boxes-area/style.scss +4 -4
- package/src/components/meta-boxes/test/use-meta-box-initialization.js +31 -0
- package/src/components/meta-boxes/use-meta-box-initialization.js +30 -11
- package/src/experimental-admin-bar-in-editor.scss +67 -0
- package/src/index.js +155 -11
- package/src/style.scss +1 -0
package/src/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from '@wordpress/block-library';
|
|
9
9
|
import deprecated from '@wordpress/deprecated';
|
|
10
10
|
import { createRoot, StrictMode } from '@wordpress/element';
|
|
11
|
-
import { dispatch, select } from '@wordpress/data';
|
|
11
|
+
import { dispatch, resolveSelect, select } from '@wordpress/data';
|
|
12
12
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
13
13
|
import {
|
|
14
14
|
registerLegacyWidgetBlock,
|
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
store as editorStore,
|
|
19
19
|
privateApis as editorPrivateApis,
|
|
20
20
|
} from '@wordpress/editor';
|
|
21
|
+
import { store as coreDataStore } from '@wordpress/core-data';
|
|
22
|
+
import apiFetch from '@wordpress/api-fetch';
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
25
|
* Internal dependencies
|
|
@@ -30,6 +32,10 @@ const {
|
|
|
30
32
|
registerCoreBlockBindingsSources,
|
|
31
33
|
} = unlock( editorPrivateApis );
|
|
32
34
|
|
|
35
|
+
const { enablePreloadMultiUse, clearPreloadedData } = unlock(
|
|
36
|
+
apiFetch.privateApis
|
|
37
|
+
);
|
|
38
|
+
|
|
33
39
|
/**
|
|
34
40
|
* Initializes and returns an instance of Editor.
|
|
35
41
|
*
|
|
@@ -150,20 +156,158 @@ export function initializeEditor(
|
|
|
150
156
|
window.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );
|
|
151
157
|
window.addEventListener( 'drop', ( e ) => e.preventDefault(), false );
|
|
152
158
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
)
|
|
159
|
+
// Drive the resolvers whose data `createPreloadingMiddleware`
|
|
160
|
+
// already has cached so every metadata entry they touch is
|
|
161
|
+
// `finished` by the time React mounts — no `setTimeout(0)`
|
|
162
|
+
// resolution dance on first render. Multi-use lets a single
|
|
163
|
+
// preloaded URL back several selectors (e.g. /wp/v2/settings GET +
|
|
164
|
+
// OPTIONS serves `getEntitiesConfig`, `canUser`, `getEntityRecord`).
|
|
165
|
+
enablePreloadMultiUse();
|
|
166
|
+
const preloadedResolutions = preloadResolutions( postType, postId );
|
|
167
|
+
|
|
168
|
+
preloadedResolutions.finally( () => {
|
|
169
|
+
// Anything not consumed by the kickoff falls through to a real
|
|
170
|
+
// network request from here on. `clearPreloadedData` logs which
|
|
171
|
+
// preload entries (if any) were never served.
|
|
172
|
+
clearPreloadedData();
|
|
173
|
+
if ( postType && postId ) {
|
|
174
|
+
const post = select( coreDataStore ).getEntityRecord(
|
|
175
|
+
'postType',
|
|
176
|
+
postType,
|
|
177
|
+
postId
|
|
178
|
+
);
|
|
179
|
+
if ( post ) {
|
|
180
|
+
dispatch( editorStore ).setupEditor(
|
|
181
|
+
post,
|
|
182
|
+
initialEdits,
|
|
183
|
+
settings.template
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
root.render(
|
|
188
|
+
<StrictMode>
|
|
189
|
+
<Layout
|
|
190
|
+
settings={ settings }
|
|
191
|
+
postId={ postId }
|
|
192
|
+
postType={ postType }
|
|
193
|
+
initialEdits={ initialEdits }
|
|
194
|
+
/>
|
|
195
|
+
</StrictMode>
|
|
196
|
+
);
|
|
197
|
+
} );
|
|
163
198
|
|
|
164
199
|
return root;
|
|
165
200
|
}
|
|
166
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Drive resolvers to completion against the preload cache before React
|
|
204
|
+
* mounts. Two phases: known-up-front args (post id + type), then args
|
|
205
|
+
* derived from phase-1 state (post slug → template, current global
|
|
206
|
+
* styles id → record + canUser).
|
|
207
|
+
*
|
|
208
|
+
* @param {string} postType Current post type.
|
|
209
|
+
* @param {number} postId Current post id.
|
|
210
|
+
* @return {Promise<void>} Resolves when the kickoff resolvers settle.
|
|
211
|
+
*/
|
|
212
|
+
async function preloadResolutions( postType, postId ) {
|
|
213
|
+
const core = resolveSelect( coreDataStore );
|
|
214
|
+
const coreSelect = select( coreDataStore );
|
|
215
|
+
|
|
216
|
+
try {
|
|
217
|
+
await Promise.all( [
|
|
218
|
+
core.getCurrentUser(),
|
|
219
|
+
core.getEntitiesConfig( 'postType' ),
|
|
220
|
+
core.getEntitiesConfig( 'taxonomy' ),
|
|
221
|
+
core.getEntitiesConfig( 'root' ),
|
|
222
|
+
core.getEntityRecords( 'root', 'taxonomy' ),
|
|
223
|
+
core.getCurrentTheme(),
|
|
224
|
+
// Forward-resolver alias of `getCurrentTheme` with its own
|
|
225
|
+
// resolution metadata, so it needs a separate kick.
|
|
226
|
+
core.getThemeSupports(),
|
|
227
|
+
core.getBlockPatternCategories(),
|
|
228
|
+
core.__experimentalGetCurrentGlobalStylesId(),
|
|
229
|
+
core.__experimentalGetCurrentThemeBaseGlobalStyles(),
|
|
230
|
+
core.__experimentalGetCurrentThemeGlobalStylesVariations(),
|
|
231
|
+
core.getEntityRecord( 'root', '__unstableBase' ),
|
|
232
|
+
core.getEntityRecord( 'root', 'site' ),
|
|
233
|
+
core.canUser( 'read', { kind: 'root', name: 'site' } ),
|
|
234
|
+
core.canUser( 'create', { kind: 'postType', name: 'attachment' } ),
|
|
235
|
+
core.canUser( 'create', { kind: 'postType', name: 'page' } ),
|
|
236
|
+
core.canUser( 'create', { kind: 'postType', name: 'wp_block' } ),
|
|
237
|
+
core.canUser( 'create', {
|
|
238
|
+
kind: 'postType',
|
|
239
|
+
name: 'wp_template',
|
|
240
|
+
} ),
|
|
241
|
+
// Per-post resolvers. `getPostType` and `getEditedEntityRecord`
|
|
242
|
+
// are shorthand/forward-resolver aliases with their own
|
|
243
|
+
// resolution metadata, so they need separate kicks.
|
|
244
|
+
...( postType && postId
|
|
245
|
+
? [
|
|
246
|
+
core.getPostType( postType ),
|
|
247
|
+
core.getEntityRecord( 'postType', postType, postId ),
|
|
248
|
+
core.getEditedEntityRecord(
|
|
249
|
+
'postType',
|
|
250
|
+
postType,
|
|
251
|
+
postId
|
|
252
|
+
),
|
|
253
|
+
core.getAutosaves( postType, postId ),
|
|
254
|
+
core.getDefaultTemplateId( { slug: 'front-page' } ),
|
|
255
|
+
core.canUser( 'create', {
|
|
256
|
+
kind: 'postType',
|
|
257
|
+
name: postType,
|
|
258
|
+
} ),
|
|
259
|
+
]
|
|
260
|
+
: [] ),
|
|
261
|
+
] );
|
|
262
|
+
|
|
263
|
+
// Phase 2: read derived data out of state.
|
|
264
|
+
const tasks = [];
|
|
265
|
+
const globalStylesId =
|
|
266
|
+
coreSelect.__experimentalGetCurrentGlobalStylesId();
|
|
267
|
+
if ( globalStylesId ) {
|
|
268
|
+
tasks.push(
|
|
269
|
+
core.getEntityRecord( 'root', 'globalStyles', globalStylesId ),
|
|
270
|
+
core.canUser( 'read', {
|
|
271
|
+
kind: 'root',
|
|
272
|
+
name: 'globalStyles',
|
|
273
|
+
id: globalStylesId,
|
|
274
|
+
} )
|
|
275
|
+
);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if ( postType && postId ) {
|
|
279
|
+
const post = coreSelect.getEntityRecord(
|
|
280
|
+
'postType',
|
|
281
|
+
postType,
|
|
282
|
+
postId
|
|
283
|
+
);
|
|
284
|
+
if ( post ) {
|
|
285
|
+
// Mirrors core-data's `getDefaultTemplate` slug formula.
|
|
286
|
+
let slug = 'page' === postType ? 'page' : 'single-' + postType;
|
|
287
|
+
if ( post.slug ) {
|
|
288
|
+
slug += '-' + post.slug;
|
|
289
|
+
}
|
|
290
|
+
tasks.push( core.getDefaultTemplateId( { slug } ) );
|
|
291
|
+
|
|
292
|
+
if ( post.author ) {
|
|
293
|
+
tasks.push(
|
|
294
|
+
core.getUser( post.author, {
|
|
295
|
+
context: 'view',
|
|
296
|
+
_fields: 'id,name',
|
|
297
|
+
} )
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if ( tasks.length ) {
|
|
304
|
+
await Promise.all( tasks );
|
|
305
|
+
}
|
|
306
|
+
} catch {
|
|
307
|
+
// Resolver failures here would also surface on demand; don't block render.
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
167
311
|
/**
|
|
168
312
|
* Used to reinitialize the editor after an error. Now it's a deprecated noop function.
|
|
169
313
|
*/
|
package/src/style.scss
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
@use "./components/layout/style.scss" as *;
|
|
6
6
|
@use "./components/meta-boxes/meta-boxes-area/style.scss" as *;
|
|
7
7
|
@use "./components/welcome-guide/style.scss" as *;
|
|
8
|
+
@use "./experimental-admin-bar-in-editor.scss" as *;
|
|
8
9
|
|
|
9
10
|
body.js.block-editor-page {
|
|
10
11
|
@include wp-admin-reset( ".block-editor" );
|