@wordpress/core-data 4.5.0 → 4.8.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 +11 -1
- package/README.md +175 -85
- package/build/entities.js +49 -46
- package/build/entities.js.map +1 -1
- package/build/entity-types/{navigation-area.js → entities.js} +1 -1
- package/build/entity-types/{navigation-area.js.map → entities.js.map} +0 -0
- package/build/hooks/constants.js +0 -2
- package/build/hooks/constants.js.map +1 -1
- package/build/hooks/index.js +38 -0
- package/build/hooks/index.js.map +1 -0
- package/build/hooks/use-entity-record.js +22 -8
- package/build/hooks/use-entity-record.js.map +1 -1
- package/build/hooks/use-entity-records.js +21 -8
- package/build/hooks/use-entity-records.js.map +1 -1
- package/build/index.js +17 -21
- package/build/index.js.map +1 -1
- package/build/queried-data/get-query-parts.js +4 -0
- package/build/queried-data/get-query-parts.js.map +1 -1
- package/build/selectors.js +163 -163
- package/build/selectors.js.map +1 -1
- package/build-module/entities.js +49 -46
- package/build-module/entities.js.map +1 -1
- package/build-module/entity-types/entities.js +2 -0
- package/build-module/entity-types/{navigation-area.js.map → entities.js.map} +0 -0
- package/build-module/hooks/constants.js +0 -1
- package/build-module/hooks/constants.js.map +1 -1
- package/build-module/hooks/index.js +3 -0
- package/build-module/hooks/index.js.map +1 -0
- package/build-module/hooks/use-entity-record.js +18 -7
- package/build-module/hooks/use-entity-record.js.map +1 -1
- package/build-module/hooks/use-entity-records.js +17 -7
- package/build-module/hooks/use-entity-records.js.map +1 -1
- package/build-module/index.js +2 -3
- package/build-module/index.js.map +1 -1
- package/build-module/queried-data/get-query-parts.js +4 -0
- package/build-module/queried-data/get-query-parts.js.map +1 -1
- package/build-module/selectors.js +164 -163
- package/build-module/selectors.js.map +1 -1
- package/package.json +12 -12
- package/src/entities.ts +342 -129
- package/src/entity-types/entities.ts +127 -0
- package/src/entity-types/index.ts +1 -3
- package/src/hooks/constants.ts +1 -2
- package/src/hooks/index.ts +8 -0
- package/src/hooks/test/use-entity-record.js +1 -0
- package/src/hooks/test/use-entity-records.js +1 -0
- package/src/hooks/test/use-query-select.js +1 -0
- package/src/hooks/use-entity-record.ts +32 -9
- package/src/hooks/use-entity-records.ts +28 -30
- package/src/index.js +2 -3
- package/src/queried-data/get-query-parts.js +3 -0
- package/src/queried-data/test/get-query-parts.js +4 -0
- package/src/selectors.ts +406 -216
- package/src/test/actions.js +30 -14
- package/src/test/entities.js +5 -0
- package/src/test/resolvers.js +11 -0
- package/build-module/entity-types/navigation-area.js +0 -2
- package/src/entity-types/navigation-area.ts +0 -29
|
@@ -18,6 +18,7 @@ import { STORE_NAME } from './name';
|
|
|
18
18
|
import { getQueriedItems } from './queried-data';
|
|
19
19
|
import { DEFAULT_ENTITY_KEY } from './entities';
|
|
20
20
|
import { getNormalizedCommaSeparable, isRawAttribute } from './utils';
|
|
21
|
+
|
|
21
22
|
/**
|
|
22
23
|
* Shared reference to an empty object for cases where it is important to avoid
|
|
23
24
|
* returning a new object reference on every invocation, as in a connected or
|
|
@@ -25,16 +26,15 @@ import { getNormalizedCommaSeparable, isRawAttribute } from './utils';
|
|
|
25
26
|
* This should be used as a last resort, since the normalized data should be
|
|
26
27
|
* maintained by the reducer result in state.
|
|
27
28
|
*/
|
|
28
|
-
|
|
29
29
|
const EMPTY_OBJECT = {};
|
|
30
30
|
/**
|
|
31
31
|
* Returns true if a request is in progress for embed preview data, or false
|
|
32
32
|
* otherwise.
|
|
33
33
|
*
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
34
|
+
* @param state Data state.
|
|
35
|
+
* @param url URL the preview would be for.
|
|
36
36
|
*
|
|
37
|
-
* @return
|
|
37
|
+
* @return Whether a request is in progress for an embed preview.
|
|
38
38
|
*/
|
|
39
39
|
|
|
40
40
|
export const isRequestingEmbedPreview = createRegistrySelector(select => (state, url) => {
|
|
@@ -45,10 +45,10 @@ export const isRequestingEmbedPreview = createRegistrySelector(select => (state,
|
|
|
45
45
|
*
|
|
46
46
|
* @deprecated since 11.3. Callers should use `select( 'core' ).getUsers({ who: 'authors' })` instead.
|
|
47
47
|
*
|
|
48
|
-
* @param
|
|
49
|
-
* @param
|
|
50
|
-
*
|
|
51
|
-
* @return
|
|
48
|
+
* @param state Data state.
|
|
49
|
+
* @param query Optional object of query parameters to
|
|
50
|
+
* include with request.
|
|
51
|
+
* @return Authors list.
|
|
52
52
|
*/
|
|
53
53
|
|
|
54
54
|
export function getAuthors(state, query) {
|
|
@@ -62,9 +62,9 @@ export function getAuthors(state, query) {
|
|
|
62
62
|
/**
|
|
63
63
|
* Returns the current user.
|
|
64
64
|
*
|
|
65
|
-
* @param
|
|
65
|
+
* @param state Data state.
|
|
66
66
|
*
|
|
67
|
-
* @return
|
|
67
|
+
* @return Current user object.
|
|
68
68
|
*/
|
|
69
69
|
|
|
70
70
|
export function getCurrentUser(state) {
|
|
@@ -73,10 +73,10 @@ export function getCurrentUser(state) {
|
|
|
73
73
|
/**
|
|
74
74
|
* Returns all the users returned by a query ID.
|
|
75
75
|
*
|
|
76
|
-
* @param
|
|
77
|
-
* @param
|
|
76
|
+
* @param state Data state.
|
|
77
|
+
* @param queryID Query ID.
|
|
78
78
|
*
|
|
79
|
-
* @return
|
|
79
|
+
* @return Users list.
|
|
80
80
|
*/
|
|
81
81
|
|
|
82
82
|
export const getUserQueryResults = createSelector((state, queryID) => {
|
|
@@ -87,10 +87,10 @@ export const getUserQueryResults = createSelector((state, queryID) => {
|
|
|
87
87
|
* Returns the loaded entities for the given kind.
|
|
88
88
|
*
|
|
89
89
|
* @deprecated since WordPress 6.0. Use getEntitiesConfig instead
|
|
90
|
-
* @param
|
|
91
|
-
* @param
|
|
90
|
+
* @param state Data state.
|
|
91
|
+
* @param kind Entity kind.
|
|
92
92
|
*
|
|
93
|
-
* @return
|
|
93
|
+
* @return Array of entities with config matching kind.
|
|
94
94
|
*/
|
|
95
95
|
|
|
96
96
|
export function getEntitiesByKind(state, kind) {
|
|
@@ -103,10 +103,10 @@ export function getEntitiesByKind(state, kind) {
|
|
|
103
103
|
/**
|
|
104
104
|
* Returns the loaded entities for the given kind.
|
|
105
105
|
*
|
|
106
|
-
* @param
|
|
107
|
-
* @param
|
|
106
|
+
* @param state Data state.
|
|
107
|
+
* @param kind Entity kind.
|
|
108
108
|
*
|
|
109
|
-
* @return
|
|
109
|
+
* @return Array of entities with config matching kind.
|
|
110
110
|
*/
|
|
111
111
|
|
|
112
112
|
export function getEntitiesConfig(state, kind) {
|
|
@@ -118,11 +118,11 @@ export function getEntitiesConfig(state, kind) {
|
|
|
118
118
|
* Returns the entity config given its kind and name.
|
|
119
119
|
*
|
|
120
120
|
* @deprecated since WordPress 6.0. Use getEntityConfig instead
|
|
121
|
-
* @param
|
|
122
|
-
* @param
|
|
123
|
-
* @param
|
|
121
|
+
* @param state Data state.
|
|
122
|
+
* @param kind Entity kind.
|
|
123
|
+
* @param name Entity name.
|
|
124
124
|
*
|
|
125
|
-
* @return
|
|
125
|
+
* @return Entity config
|
|
126
126
|
*/
|
|
127
127
|
|
|
128
128
|
export function getEntity(state, kind, name) {
|
|
@@ -135,11 +135,11 @@ export function getEntity(state, kind, name) {
|
|
|
135
135
|
/**
|
|
136
136
|
* Returns the entity config given its kind and name.
|
|
137
137
|
*
|
|
138
|
-
* @param
|
|
139
|
-
* @param
|
|
140
|
-
* @param
|
|
138
|
+
* @param state Data state.
|
|
139
|
+
* @param kind Entity kind.
|
|
140
|
+
* @param name Entity name.
|
|
141
141
|
*
|
|
142
|
-
* @return
|
|
142
|
+
* @return Entity config
|
|
143
143
|
*/
|
|
144
144
|
|
|
145
145
|
export function getEntityConfig(state, kind, name) {
|
|
@@ -153,13 +153,13 @@ export function getEntityConfig(state, kind, name) {
|
|
|
153
153
|
* yet received, undefined if the value entity is known to not exist, or the
|
|
154
154
|
* entity object if it exists and is received.
|
|
155
155
|
*
|
|
156
|
-
* @param
|
|
157
|
-
* @param
|
|
158
|
-
* @param
|
|
159
|
-
* @param
|
|
160
|
-
* @param
|
|
156
|
+
* @param state State tree
|
|
157
|
+
* @param kind Entity kind.
|
|
158
|
+
* @param name Entity name.
|
|
159
|
+
* @param key Record's key
|
|
160
|
+
* @param query Optional query.
|
|
161
161
|
*
|
|
162
|
-
* @return
|
|
162
|
+
* @return Record.
|
|
163
163
|
*/
|
|
164
164
|
|
|
165
165
|
export const getEntityRecord = createSelector((state, kind, name, key, query) => {
|
|
@@ -211,12 +211,12 @@ export const getEntityRecord = createSelector((state, kind, name, key, query) =>
|
|
|
211
211
|
/**
|
|
212
212
|
* Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity records from the API if the entity record isn't available in the local state.
|
|
213
213
|
*
|
|
214
|
-
* @param
|
|
215
|
-
* @param
|
|
216
|
-
* @param
|
|
217
|
-
* @param
|
|
214
|
+
* @param state State tree
|
|
215
|
+
* @param kind Entity kind.
|
|
216
|
+
* @param name Entity name.
|
|
217
|
+
* @param key Record's key
|
|
218
218
|
*
|
|
219
|
-
* @return
|
|
219
|
+
* @return Record.
|
|
220
220
|
*/
|
|
221
221
|
|
|
222
222
|
export function __experimentalGetEntityRecordNoResolver(state, kind, name, key) {
|
|
@@ -226,12 +226,12 @@ export function __experimentalGetEntityRecordNoResolver(state, kind, name, key)
|
|
|
226
226
|
* Returns the entity's record object by key,
|
|
227
227
|
* with its attributes mapped to their raw values.
|
|
228
228
|
*
|
|
229
|
-
* @param
|
|
230
|
-
* @param
|
|
231
|
-
* @param
|
|
232
|
-
* @param
|
|
229
|
+
* @param state State tree.
|
|
230
|
+
* @param kind Entity kind.
|
|
231
|
+
* @param name Entity name.
|
|
232
|
+
* @param key Record's key.
|
|
233
233
|
*
|
|
234
|
-
* @return
|
|
234
|
+
* @return Object with the entity's raw attributes.
|
|
235
235
|
*/
|
|
236
236
|
|
|
237
237
|
export const getRawEntityRecord = createSelector((state, kind, name, key) => {
|
|
@@ -258,12 +258,12 @@ export const getRawEntityRecord = createSelector((state, kind, name, key) => {
|
|
|
258
258
|
* Returns true if records have been received for the given set of parameters,
|
|
259
259
|
* or false otherwise.
|
|
260
260
|
*
|
|
261
|
-
* @param
|
|
262
|
-
* @param
|
|
263
|
-
* @param
|
|
264
|
-
* @param
|
|
261
|
+
* @param state State tree
|
|
262
|
+
* @param kind Entity kind.
|
|
263
|
+
* @param name Entity name.
|
|
264
|
+
* @param query Optional terms query.
|
|
265
265
|
*
|
|
266
|
-
* @return
|
|
266
|
+
* @return Whether entity records have been received.
|
|
267
267
|
*/
|
|
268
268
|
|
|
269
269
|
export function hasEntityRecords(state, kind, name, query) {
|
|
@@ -272,12 +272,12 @@ export function hasEntityRecords(state, kind, name, query) {
|
|
|
272
272
|
/**
|
|
273
273
|
* Returns the Entity's records.
|
|
274
274
|
*
|
|
275
|
-
* @param
|
|
276
|
-
* @param
|
|
277
|
-
* @param
|
|
278
|
-
* @param
|
|
275
|
+
* @param state State tree
|
|
276
|
+
* @param kind Entity kind.
|
|
277
|
+
* @param name Entity name.
|
|
278
|
+
* @param query Optional terms query.
|
|
279
279
|
*
|
|
280
|
-
* @return
|
|
280
|
+
* @return Records.
|
|
281
281
|
*/
|
|
282
282
|
|
|
283
283
|
export function getEntityRecords(state, kind, name, query) {
|
|
@@ -291,14 +291,14 @@ export function getEntityRecords(state, kind, name, query) {
|
|
|
291
291
|
|
|
292
292
|
return getQueriedItems(queriedState, query);
|
|
293
293
|
}
|
|
294
|
+
|
|
294
295
|
/**
|
|
295
|
-
* Returns the
|
|
296
|
+
* Returns the list of dirty entity records.
|
|
296
297
|
*
|
|
297
|
-
* @param
|
|
298
|
+
* @param state State tree.
|
|
298
299
|
*
|
|
299
|
-
* @return
|
|
300
|
+
* @return The list of updated records
|
|
300
301
|
*/
|
|
301
|
-
|
|
302
302
|
export const __experimentalGetDirtyEntityRecords = createSelector(state => {
|
|
303
303
|
const {
|
|
304
304
|
entities: {
|
|
@@ -335,9 +335,9 @@ export const __experimentalGetDirtyEntityRecords = createSelector(state => {
|
|
|
335
335
|
/**
|
|
336
336
|
* Returns the list of entities currently being saved.
|
|
337
337
|
*
|
|
338
|
-
* @param
|
|
338
|
+
* @param state State tree.
|
|
339
339
|
*
|
|
340
|
-
* @return
|
|
340
|
+
* @return The list of records being saved.
|
|
341
341
|
*/
|
|
342
342
|
|
|
343
343
|
export const __experimentalGetEntitiesBeingSaved = createSelector(state => {
|
|
@@ -374,12 +374,12 @@ export const __experimentalGetEntitiesBeingSaved = createSelector(state => {
|
|
|
374
374
|
/**
|
|
375
375
|
* Returns the specified entity record's edits.
|
|
376
376
|
*
|
|
377
|
-
* @param
|
|
378
|
-
* @param
|
|
379
|
-
* @param
|
|
380
|
-
* @param
|
|
377
|
+
* @param state State tree.
|
|
378
|
+
* @param kind Entity kind.
|
|
379
|
+
* @param name Entity name.
|
|
380
|
+
* @param recordId Record ID.
|
|
381
381
|
*
|
|
382
|
-
* @return
|
|
382
|
+
* @return The entity record's edits.
|
|
383
383
|
*/
|
|
384
384
|
|
|
385
385
|
export function getEntityRecordEdits(state, kind, name, recordId) {
|
|
@@ -392,12 +392,12 @@ export function getEntityRecordEdits(state, kind, name, recordId) {
|
|
|
392
392
|
* are not considered for change detection.
|
|
393
393
|
* They are defined in the entity's config.
|
|
394
394
|
*
|
|
395
|
-
* @param
|
|
396
|
-
* @param
|
|
397
|
-
* @param
|
|
398
|
-
* @param
|
|
395
|
+
* @param state State tree.
|
|
396
|
+
* @param kind Entity kind.
|
|
397
|
+
* @param name Entity name.
|
|
398
|
+
* @param recordId Record ID.
|
|
399
399
|
*
|
|
400
|
-
* @return
|
|
400
|
+
* @return The entity record's non transient edits.
|
|
401
401
|
*/
|
|
402
402
|
|
|
403
403
|
export const getEntityRecordNonTransientEdits = createSelector((state, kind, name, recordId) => {
|
|
@@ -422,12 +422,12 @@ export const getEntityRecordNonTransientEdits = createSelector((state, kind, nam
|
|
|
422
422
|
* Returns true if the specified entity record has edits,
|
|
423
423
|
* and false otherwise.
|
|
424
424
|
*
|
|
425
|
-
* @param
|
|
426
|
-
* @param
|
|
427
|
-
* @param
|
|
428
|
-
* @param
|
|
425
|
+
* @param state State tree.
|
|
426
|
+
* @param kind Entity kind.
|
|
427
|
+
* @param name Entity name.
|
|
428
|
+
* @param recordId Record ID.
|
|
429
429
|
*
|
|
430
|
-
* @return
|
|
430
|
+
* @return Whether the entity record has edits or not.
|
|
431
431
|
*/
|
|
432
432
|
|
|
433
433
|
export function hasEditsForEntityRecord(state, kind, name, recordId) {
|
|
@@ -436,12 +436,12 @@ export function hasEditsForEntityRecord(state, kind, name, recordId) {
|
|
|
436
436
|
/**
|
|
437
437
|
* Returns the specified entity record, merged with its edits.
|
|
438
438
|
*
|
|
439
|
-
* @param
|
|
440
|
-
* @param
|
|
441
|
-
* @param
|
|
442
|
-
* @param
|
|
439
|
+
* @param state State tree.
|
|
440
|
+
* @param kind Entity kind.
|
|
441
|
+
* @param name Entity name.
|
|
442
|
+
* @param recordId Record ID.
|
|
443
443
|
*
|
|
444
|
-
* @return
|
|
444
|
+
* @return The entity record, merged with its edits.
|
|
445
445
|
*/
|
|
446
446
|
|
|
447
447
|
export const getEditedEntityRecord = createSelector((state, kind, name, recordId) => ({ ...getRawEntityRecord(state, kind, name, recordId),
|
|
@@ -455,12 +455,12 @@ export const getEditedEntityRecord = createSelector((state, kind, name, recordId
|
|
|
455
455
|
/**
|
|
456
456
|
* Returns true if the specified entity record is autosaving, and false otherwise.
|
|
457
457
|
*
|
|
458
|
-
* @param
|
|
459
|
-
* @param
|
|
460
|
-
* @param
|
|
461
|
-
* @param
|
|
458
|
+
* @param state State tree.
|
|
459
|
+
* @param kind Entity kind.
|
|
460
|
+
* @param name Entity name.
|
|
461
|
+
* @param recordId Record ID.
|
|
462
462
|
*
|
|
463
|
-
* @return
|
|
463
|
+
* @return Whether the entity record is autosaving or not.
|
|
464
464
|
*/
|
|
465
465
|
|
|
466
466
|
export function isAutosavingEntityRecord(state, kind, name, recordId) {
|
|
@@ -473,12 +473,12 @@ export function isAutosavingEntityRecord(state, kind, name, recordId) {
|
|
|
473
473
|
/**
|
|
474
474
|
* Returns true if the specified entity record is saving, and false otherwise.
|
|
475
475
|
*
|
|
476
|
-
* @param
|
|
477
|
-
* @param
|
|
478
|
-
* @param
|
|
479
|
-
* @param
|
|
476
|
+
* @param state State tree.
|
|
477
|
+
* @param kind Entity kind.
|
|
478
|
+
* @param name Entity name.
|
|
479
|
+
* @param recordId Record ID.
|
|
480
480
|
*
|
|
481
|
-
* @return
|
|
481
|
+
* @return Whether the entity record is saving or not.
|
|
482
482
|
*/
|
|
483
483
|
|
|
484
484
|
export function isSavingEntityRecord(state, kind, name, recordId) {
|
|
@@ -487,12 +487,12 @@ export function isSavingEntityRecord(state, kind, name, recordId) {
|
|
|
487
487
|
/**
|
|
488
488
|
* Returns true if the specified entity record is deleting, and false otherwise.
|
|
489
489
|
*
|
|
490
|
-
* @param
|
|
491
|
-
* @param
|
|
492
|
-
* @param
|
|
493
|
-
* @param
|
|
490
|
+
* @param state State tree.
|
|
491
|
+
* @param kind Entity kind.
|
|
492
|
+
* @param name Entity name.
|
|
493
|
+
* @param recordId Record ID.
|
|
494
494
|
*
|
|
495
|
-
* @return
|
|
495
|
+
* @return Whether the entity record is deleting or not.
|
|
496
496
|
*/
|
|
497
497
|
|
|
498
498
|
export function isDeletingEntityRecord(state, kind, name, recordId) {
|
|
@@ -501,12 +501,12 @@ export function isDeletingEntityRecord(state, kind, name, recordId) {
|
|
|
501
501
|
/**
|
|
502
502
|
* Returns the specified entity record's last save error.
|
|
503
503
|
*
|
|
504
|
-
* @param
|
|
505
|
-
* @param
|
|
506
|
-
* @param
|
|
507
|
-
* @param
|
|
504
|
+
* @param state State tree.
|
|
505
|
+
* @param kind Entity kind.
|
|
506
|
+
* @param name Entity name.
|
|
507
|
+
* @param recordId Record ID.
|
|
508
508
|
*
|
|
509
|
-
* @return
|
|
509
|
+
* @return The entity record's save error.
|
|
510
510
|
*/
|
|
511
511
|
|
|
512
512
|
export function getLastEntitySaveError(state, kind, name, recordId) {
|
|
@@ -515,12 +515,12 @@ export function getLastEntitySaveError(state, kind, name, recordId) {
|
|
|
515
515
|
/**
|
|
516
516
|
* Returns the specified entity record's last delete error.
|
|
517
517
|
*
|
|
518
|
-
* @param
|
|
519
|
-
* @param
|
|
520
|
-
* @param
|
|
521
|
-
* @param
|
|
518
|
+
* @param state State tree.
|
|
519
|
+
* @param kind Entity kind.
|
|
520
|
+
* @param name Entity name.
|
|
521
|
+
* @param recordId Record ID.
|
|
522
522
|
*
|
|
523
|
-
* @return
|
|
523
|
+
* @return The entity record's save error.
|
|
524
524
|
*/
|
|
525
525
|
|
|
526
526
|
export function getLastEntityDeleteError(state, kind, name, recordId) {
|
|
@@ -533,9 +533,9 @@ export function getLastEntityDeleteError(state, kind, name, recordId) {
|
|
|
533
533
|
* of the history stack we are at. 0 is the
|
|
534
534
|
* last edit, -1 is the second last, and so on.
|
|
535
535
|
*
|
|
536
|
-
* @param
|
|
536
|
+
* @param state State tree.
|
|
537
537
|
*
|
|
538
|
-
* @return
|
|
538
|
+
* @return The current undo offset.
|
|
539
539
|
*/
|
|
540
540
|
|
|
541
541
|
function getCurrentUndoOffset(state) {
|
|
@@ -545,9 +545,9 @@ function getCurrentUndoOffset(state) {
|
|
|
545
545
|
* Returns the previous edit from the current undo offset
|
|
546
546
|
* for the entity records edits history, if any.
|
|
547
547
|
*
|
|
548
|
-
* @param
|
|
548
|
+
* @param state State tree.
|
|
549
549
|
*
|
|
550
|
-
* @return
|
|
550
|
+
* @return The edit.
|
|
551
551
|
*/
|
|
552
552
|
|
|
553
553
|
|
|
@@ -558,9 +558,9 @@ export function getUndoEdit(state) {
|
|
|
558
558
|
* Returns the next edit from the current undo offset
|
|
559
559
|
* for the entity records edits history, if any.
|
|
560
560
|
*
|
|
561
|
-
* @param
|
|
561
|
+
* @param state State tree.
|
|
562
562
|
*
|
|
563
|
-
* @return
|
|
563
|
+
* @return The edit.
|
|
564
564
|
*/
|
|
565
565
|
|
|
566
566
|
export function getRedoEdit(state) {
|
|
@@ -570,9 +570,9 @@ export function getRedoEdit(state) {
|
|
|
570
570
|
* Returns true if there is a previous edit from the current undo offset
|
|
571
571
|
* for the entity records edits history, and false otherwise.
|
|
572
572
|
*
|
|
573
|
-
* @param
|
|
573
|
+
* @param state State tree.
|
|
574
574
|
*
|
|
575
|
-
* @return
|
|
575
|
+
* @return Whether there is a previous edit or not.
|
|
576
576
|
*/
|
|
577
577
|
|
|
578
578
|
export function hasUndo(state) {
|
|
@@ -582,9 +582,9 @@ export function hasUndo(state) {
|
|
|
582
582
|
* Returns true if there is a next edit from the current undo offset
|
|
583
583
|
* for the entity records edits history, and false otherwise.
|
|
584
584
|
*
|
|
585
|
-
* @param
|
|
585
|
+
* @param state State tree.
|
|
586
586
|
*
|
|
587
|
-
* @return
|
|
587
|
+
* @return Whether there is a next edit or not.
|
|
588
588
|
*/
|
|
589
589
|
|
|
590
590
|
export function hasRedo(state) {
|
|
@@ -593,9 +593,9 @@ export function hasRedo(state) {
|
|
|
593
593
|
/**
|
|
594
594
|
* Return the current theme.
|
|
595
595
|
*
|
|
596
|
-
* @param
|
|
596
|
+
* @param state Data state.
|
|
597
597
|
*
|
|
598
|
-
* @return
|
|
598
|
+
* @return The current theme.
|
|
599
599
|
*/
|
|
600
600
|
|
|
601
601
|
export function getCurrentTheme(state) {
|
|
@@ -604,9 +604,9 @@ export function getCurrentTheme(state) {
|
|
|
604
604
|
/**
|
|
605
605
|
* Return the ID of the current global styles object.
|
|
606
606
|
*
|
|
607
|
-
* @param
|
|
607
|
+
* @param state Data state.
|
|
608
608
|
*
|
|
609
|
-
* @return
|
|
609
|
+
* @return The current global styles ID.
|
|
610
610
|
*/
|
|
611
611
|
|
|
612
612
|
export function __experimentalGetCurrentGlobalStylesId(state) {
|
|
@@ -615,9 +615,9 @@ export function __experimentalGetCurrentGlobalStylesId(state) {
|
|
|
615
615
|
/**
|
|
616
616
|
* Return theme supports data in the index.
|
|
617
617
|
*
|
|
618
|
-
* @param
|
|
618
|
+
* @param state Data state.
|
|
619
619
|
*
|
|
620
|
-
* @return
|
|
620
|
+
* @return Index data.
|
|
621
621
|
*/
|
|
622
622
|
|
|
623
623
|
export function getThemeSupports(state) {
|
|
@@ -628,10 +628,10 @@ export function getThemeSupports(state) {
|
|
|
628
628
|
/**
|
|
629
629
|
* Returns the embed preview for the given URL.
|
|
630
630
|
*
|
|
631
|
-
* @param
|
|
632
|
-
* @param
|
|
631
|
+
* @param state Data state.
|
|
632
|
+
* @param url Embedded URL.
|
|
633
633
|
*
|
|
634
|
-
* @return
|
|
634
|
+
* @return Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
|
|
635
635
|
*/
|
|
636
636
|
|
|
637
637
|
export function getEmbedPreview(state, url) {
|
|
@@ -644,10 +644,10 @@ export function getEmbedPreview(state, url) {
|
|
|
644
644
|
* We need to be able to determine if a URL is embeddable or not, based on what we
|
|
645
645
|
* get back from the oEmbed preview API.
|
|
646
646
|
*
|
|
647
|
-
* @param
|
|
648
|
-
* @param
|
|
647
|
+
* @param state Data state.
|
|
648
|
+
* @param url Embedded URL.
|
|
649
649
|
*
|
|
650
|
-
* @return
|
|
650
|
+
* @return Is the preview for the URL an oEmbed link fallback.
|
|
651
651
|
*/
|
|
652
652
|
|
|
653
653
|
export function isPreviewEmbedFallback(state, url) {
|
|
@@ -669,12 +669,12 @@ export function isPreviewEmbedFallback(state, url) {
|
|
|
669
669
|
*
|
|
670
670
|
* https://developer.wordpress.org/rest-api/reference/
|
|
671
671
|
*
|
|
672
|
-
* @param
|
|
673
|
-
* @param
|
|
674
|
-
* @param
|
|
675
|
-
* @param
|
|
672
|
+
* @param state Data state.
|
|
673
|
+
* @param action Action to check. One of: 'create', 'read', 'update', 'delete'.
|
|
674
|
+
* @param resource REST resource to check, e.g. 'media' or 'posts'.
|
|
675
|
+
* @param id Optional ID of the rest resource to check.
|
|
676
676
|
*
|
|
677
|
-
* @return
|
|
677
|
+
* @return Whether or not the user can perform the action,
|
|
678
678
|
* or `undefined` if the OPTIONS request is still being made.
|
|
679
679
|
*/
|
|
680
680
|
|
|
@@ -690,11 +690,11 @@ export function canUser(state, action, resource, id) {
|
|
|
690
690
|
*
|
|
691
691
|
* https://developer.wordpress.org/rest-api/reference/
|
|
692
692
|
*
|
|
693
|
-
* @param
|
|
694
|
-
* @param
|
|
695
|
-
* @param
|
|
696
|
-
* @param
|
|
697
|
-
* @return
|
|
693
|
+
* @param state Data state.
|
|
694
|
+
* @param kind Entity kind.
|
|
695
|
+
* @param name Entity name.
|
|
696
|
+
* @param recordId Record's id.
|
|
697
|
+
* @return Whether or not the user can edit,
|
|
698
698
|
* or `undefined` if the OPTIONS request is still being made.
|
|
699
699
|
*/
|
|
700
700
|
|
|
@@ -714,11 +714,11 @@ export function canUserEditEntityRecord(state, kind, name, recordId) {
|
|
|
714
714
|
* May return multiple autosaves since the backend stores one autosave per
|
|
715
715
|
* author for each post.
|
|
716
716
|
*
|
|
717
|
-
* @param
|
|
718
|
-
* @param
|
|
719
|
-
* @param
|
|
717
|
+
* @param state State tree.
|
|
718
|
+
* @param postType The type of the parent post.
|
|
719
|
+
* @param postId The id of the parent post.
|
|
720
720
|
*
|
|
721
|
-
* @return
|
|
721
|
+
* @return An array of autosaves for the post, or undefined if there is none.
|
|
722
722
|
*/
|
|
723
723
|
|
|
724
724
|
export function getAutosaves(state, postType, postId) {
|
|
@@ -727,12 +727,12 @@ export function getAutosaves(state, postType, postId) {
|
|
|
727
727
|
/**
|
|
728
728
|
* Returns the autosave for the post and author.
|
|
729
729
|
*
|
|
730
|
-
* @param
|
|
731
|
-
* @param
|
|
732
|
-
* @param
|
|
733
|
-
* @param
|
|
730
|
+
* @param state State tree.
|
|
731
|
+
* @param postType The type of the parent post.
|
|
732
|
+
* @param postId The id of the parent post.
|
|
733
|
+
* @param authorId The id of the author.
|
|
734
734
|
*
|
|
735
|
-
* @return
|
|
735
|
+
* @return The autosave for the post and author.
|
|
736
736
|
*/
|
|
737
737
|
|
|
738
738
|
export function getAutosave(state, postType, postId, authorId) {
|
|
@@ -748,11 +748,11 @@ export function getAutosave(state, postType, postId, authorId) {
|
|
|
748
748
|
/**
|
|
749
749
|
* Returns true if the REST request for autosaves has completed.
|
|
750
750
|
*
|
|
751
|
-
* @param
|
|
752
|
-
* @param
|
|
753
|
-
* @param
|
|
751
|
+
* @param state State tree.
|
|
752
|
+
* @param postType The type of the parent post.
|
|
753
|
+
* @param postId The id of the parent post.
|
|
754
754
|
*
|
|
755
|
-
* @return
|
|
755
|
+
* @return True if the REST request was completed. False otherwise.
|
|
756
756
|
*/
|
|
757
757
|
|
|
758
758
|
export const hasFetchedAutosaves = createRegistrySelector(select => (state, postType, postId) => {
|
|
@@ -772,19 +772,20 @@ export const hasFetchedAutosaves = createRegistrySelector(select => (state, post
|
|
|
772
772
|
* );
|
|
773
773
|
* ```
|
|
774
774
|
*
|
|
775
|
-
* @param
|
|
775
|
+
* @param state Editor state.
|
|
776
776
|
*
|
|
777
|
-
* @return
|
|
777
|
+
* @return A value whose reference will change only when an edit occurs.
|
|
778
778
|
*/
|
|
779
779
|
|
|
780
|
-
export const getReferenceByDistinctEdits = createSelector(
|
|
780
|
+
export const getReferenceByDistinctEdits = createSelector( // This unused state argument is listed here for the documentation generating tool (docgen).
|
|
781
|
+
state => [], state => [state.undo.length, state.undo.offset, state.undo.flattenedUndo]);
|
|
781
782
|
/**
|
|
782
783
|
* Retrieve the frontend template used for a given link.
|
|
783
784
|
*
|
|
784
|
-
* @param
|
|
785
|
-
* @param
|
|
785
|
+
* @param state Editor state.
|
|
786
|
+
* @param link Link.
|
|
786
787
|
*
|
|
787
|
-
* @return
|
|
788
|
+
* @return The template record.
|
|
788
789
|
*/
|
|
789
790
|
|
|
790
791
|
export function __experimentalGetTemplateForLink(state, link) {
|
|
@@ -802,9 +803,9 @@ export function __experimentalGetTemplateForLink(state, link) {
|
|
|
802
803
|
/**
|
|
803
804
|
* Retrieve the current theme's base global styles
|
|
804
805
|
*
|
|
805
|
-
* @param
|
|
806
|
+
* @param state Editor state.
|
|
806
807
|
*
|
|
807
|
-
* @return
|
|
808
|
+
* @return The Global Styles object.
|
|
808
809
|
*/
|
|
809
810
|
|
|
810
811
|
export function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
|
|
@@ -819,9 +820,9 @@ export function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
|
|
|
819
820
|
/**
|
|
820
821
|
* Return the ID of the current global styles object.
|
|
821
822
|
*
|
|
822
|
-
* @param
|
|
823
|
+
* @param state Data state.
|
|
823
824
|
*
|
|
824
|
-
* @return
|
|
825
|
+
* @return The current global styles ID.
|
|
825
826
|
*/
|
|
826
827
|
|
|
827
828
|
export function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
|
|
@@ -836,9 +837,9 @@ export function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
|
|
|
836
837
|
/**
|
|
837
838
|
* Retrieve the list of registered block patterns.
|
|
838
839
|
*
|
|
839
|
-
* @param
|
|
840
|
+
* @param state Data state.
|
|
840
841
|
*
|
|
841
|
-
* @return
|
|
842
|
+
* @return Block pattern list.
|
|
842
843
|
*/
|
|
843
844
|
|
|
844
845
|
export function getBlockPatterns(state) {
|
|
@@ -847,9 +848,9 @@ export function getBlockPatterns(state) {
|
|
|
847
848
|
/**
|
|
848
849
|
* Retrieve the list of registered block pattern categories.
|
|
849
850
|
*
|
|
850
|
-
* @param
|
|
851
|
+
* @param state Data state.
|
|
851
852
|
*
|
|
852
|
-
* @return
|
|
853
|
+
* @return Block pattern category list.
|
|
853
854
|
*/
|
|
854
855
|
|
|
855
856
|
export function getBlockPatternCategories(state) {
|