@wordpress/core-data 4.6.0 → 4.7.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 +7 -1
- package/README.md +175 -85
- 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/selectors.js +162 -162
- package/build/selectors.js.map +1 -1
- 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/selectors.js +163 -162
- package/build-module/selectors.js.map +1 -1
- package/package.json +11 -11
- package/src/hooks/constants.ts +1 -2
- package/src/hooks/index.ts +8 -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/selectors.ts +405 -215
package/build/selectors.js
CHANGED
|
@@ -91,10 +91,10 @@ const EMPTY_OBJECT = {};
|
|
|
91
91
|
* Returns true if a request is in progress for embed preview data, or false
|
|
92
92
|
* otherwise.
|
|
93
93
|
*
|
|
94
|
-
* @param
|
|
95
|
-
* @param
|
|
94
|
+
* @param state Data state.
|
|
95
|
+
* @param url URL the preview would be for.
|
|
96
96
|
*
|
|
97
|
-
* @return
|
|
97
|
+
* @return Whether a request is in progress for an embed preview.
|
|
98
98
|
*/
|
|
99
99
|
|
|
100
100
|
const isRequestingEmbedPreview = (0, _data.createRegistrySelector)(select => (state, url) => {
|
|
@@ -105,10 +105,10 @@ const isRequestingEmbedPreview = (0, _data.createRegistrySelector)(select => (st
|
|
|
105
105
|
*
|
|
106
106
|
* @deprecated since 11.3. Callers should use `select( 'core' ).getUsers({ who: 'authors' })` instead.
|
|
107
107
|
*
|
|
108
|
-
* @param
|
|
109
|
-
* @param
|
|
110
|
-
*
|
|
111
|
-
* @return
|
|
108
|
+
* @param state Data state.
|
|
109
|
+
* @param query Optional object of query parameters to
|
|
110
|
+
* include with request.
|
|
111
|
+
* @return Authors list.
|
|
112
112
|
*/
|
|
113
113
|
|
|
114
114
|
exports.isRequestingEmbedPreview = isRequestingEmbedPreview;
|
|
@@ -124,9 +124,9 @@ function getAuthors(state, query) {
|
|
|
124
124
|
/**
|
|
125
125
|
* Returns the current user.
|
|
126
126
|
*
|
|
127
|
-
* @param
|
|
127
|
+
* @param state Data state.
|
|
128
128
|
*
|
|
129
|
-
* @return
|
|
129
|
+
* @return Current user object.
|
|
130
130
|
*/
|
|
131
131
|
|
|
132
132
|
|
|
@@ -136,10 +136,10 @@ function getCurrentUser(state) {
|
|
|
136
136
|
/**
|
|
137
137
|
* Returns all the users returned by a query ID.
|
|
138
138
|
*
|
|
139
|
-
* @param
|
|
140
|
-
* @param
|
|
139
|
+
* @param state Data state.
|
|
140
|
+
* @param queryID Query ID.
|
|
141
141
|
*
|
|
142
|
-
* @return
|
|
142
|
+
* @return Users list.
|
|
143
143
|
*/
|
|
144
144
|
|
|
145
145
|
|
|
@@ -151,10 +151,10 @@ const getUserQueryResults = (0, _rememo.default)((state, queryID) => {
|
|
|
151
151
|
* Returns the loaded entities for the given kind.
|
|
152
152
|
*
|
|
153
153
|
* @deprecated since WordPress 6.0. Use getEntitiesConfig instead
|
|
154
|
-
* @param
|
|
155
|
-
* @param
|
|
154
|
+
* @param state Data state.
|
|
155
|
+
* @param kind Entity kind.
|
|
156
156
|
*
|
|
157
|
-
* @return
|
|
157
|
+
* @return Array of entities with config matching kind.
|
|
158
158
|
*/
|
|
159
159
|
|
|
160
160
|
exports.getUserQueryResults = getUserQueryResults;
|
|
@@ -169,10 +169,10 @@ function getEntitiesByKind(state, kind) {
|
|
|
169
169
|
/**
|
|
170
170
|
* Returns the loaded entities for the given kind.
|
|
171
171
|
*
|
|
172
|
-
* @param
|
|
173
|
-
* @param
|
|
172
|
+
* @param state Data state.
|
|
173
|
+
* @param kind Entity kind.
|
|
174
174
|
*
|
|
175
|
-
* @return
|
|
175
|
+
* @return Array of entities with config matching kind.
|
|
176
176
|
*/
|
|
177
177
|
|
|
178
178
|
|
|
@@ -185,11 +185,11 @@ function getEntitiesConfig(state, kind) {
|
|
|
185
185
|
* Returns the entity config given its kind and name.
|
|
186
186
|
*
|
|
187
187
|
* @deprecated since WordPress 6.0. Use getEntityConfig instead
|
|
188
|
-
* @param
|
|
189
|
-
* @param
|
|
190
|
-
* @param
|
|
188
|
+
* @param state Data state.
|
|
189
|
+
* @param kind Entity kind.
|
|
190
|
+
* @param name Entity name.
|
|
191
191
|
*
|
|
192
|
-
* @return
|
|
192
|
+
* @return Entity config
|
|
193
193
|
*/
|
|
194
194
|
|
|
195
195
|
|
|
@@ -203,11 +203,11 @@ function getEntity(state, kind, name) {
|
|
|
203
203
|
/**
|
|
204
204
|
* Returns the entity config given its kind and name.
|
|
205
205
|
*
|
|
206
|
-
* @param
|
|
207
|
-
* @param
|
|
208
|
-
* @param
|
|
206
|
+
* @param state Data state.
|
|
207
|
+
* @param kind Entity kind.
|
|
208
|
+
* @param name Entity name.
|
|
209
209
|
*
|
|
210
|
-
* @return
|
|
210
|
+
* @return Entity config
|
|
211
211
|
*/
|
|
212
212
|
|
|
213
213
|
|
|
@@ -222,13 +222,13 @@ function getEntityConfig(state, kind, name) {
|
|
|
222
222
|
* yet received, undefined if the value entity is known to not exist, or the
|
|
223
223
|
* entity object if it exists and is received.
|
|
224
224
|
*
|
|
225
|
-
* @param
|
|
226
|
-
* @param
|
|
227
|
-
* @param
|
|
228
|
-
* @param
|
|
229
|
-
* @param
|
|
225
|
+
* @param state State tree
|
|
226
|
+
* @param kind Entity kind.
|
|
227
|
+
* @param name Entity name.
|
|
228
|
+
* @param key Record's key
|
|
229
|
+
* @param query Optional query.
|
|
230
230
|
*
|
|
231
|
-
* @return
|
|
231
|
+
* @return Record.
|
|
232
232
|
*/
|
|
233
233
|
|
|
234
234
|
|
|
@@ -281,12 +281,12 @@ const getEntityRecord = (0, _rememo.default)((state, kind, name, key, query) =>
|
|
|
281
281
|
/**
|
|
282
282
|
* 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.
|
|
283
283
|
*
|
|
284
|
-
* @param
|
|
285
|
-
* @param
|
|
286
|
-
* @param
|
|
287
|
-
* @param
|
|
284
|
+
* @param state State tree
|
|
285
|
+
* @param kind Entity kind.
|
|
286
|
+
* @param name Entity name.
|
|
287
|
+
* @param key Record's key
|
|
288
288
|
*
|
|
289
|
-
* @return
|
|
289
|
+
* @return Record.
|
|
290
290
|
*/
|
|
291
291
|
|
|
292
292
|
exports.getEntityRecord = getEntityRecord;
|
|
@@ -298,12 +298,12 @@ function __experimentalGetEntityRecordNoResolver(state, kind, name, key) {
|
|
|
298
298
|
* Returns the entity's record object by key,
|
|
299
299
|
* with its attributes mapped to their raw values.
|
|
300
300
|
*
|
|
301
|
-
* @param
|
|
302
|
-
* @param
|
|
303
|
-
* @param
|
|
304
|
-
* @param
|
|
301
|
+
* @param state State tree.
|
|
302
|
+
* @param kind Entity kind.
|
|
303
|
+
* @param name Entity name.
|
|
304
|
+
* @param key Record's key.
|
|
305
305
|
*
|
|
306
|
-
* @return
|
|
306
|
+
* @return Object with the entity's raw attributes.
|
|
307
307
|
*/
|
|
308
308
|
|
|
309
309
|
|
|
@@ -331,12 +331,12 @@ const getRawEntityRecord = (0, _rememo.default)((state, kind, name, key) => {
|
|
|
331
331
|
* Returns true if records have been received for the given set of parameters,
|
|
332
332
|
* or false otherwise.
|
|
333
333
|
*
|
|
334
|
-
* @param
|
|
335
|
-
* @param
|
|
336
|
-
* @param
|
|
337
|
-
* @param
|
|
334
|
+
* @param state State tree
|
|
335
|
+
* @param kind Entity kind.
|
|
336
|
+
* @param name Entity name.
|
|
337
|
+
* @param query Optional terms query.
|
|
338
338
|
*
|
|
339
|
-
* @return
|
|
339
|
+
* @return Whether entity records have been received.
|
|
340
340
|
*/
|
|
341
341
|
|
|
342
342
|
exports.getRawEntityRecord = getRawEntityRecord;
|
|
@@ -347,12 +347,12 @@ function hasEntityRecords(state, kind, name, query) {
|
|
|
347
347
|
/**
|
|
348
348
|
* Returns the Entity's records.
|
|
349
349
|
*
|
|
350
|
-
* @param
|
|
351
|
-
* @param
|
|
352
|
-
* @param
|
|
353
|
-
* @param
|
|
350
|
+
* @param state State tree
|
|
351
|
+
* @param kind Entity kind.
|
|
352
|
+
* @param name Entity name.
|
|
353
|
+
* @param query Optional terms query.
|
|
354
354
|
*
|
|
355
|
-
* @return
|
|
355
|
+
* @return Records.
|
|
356
356
|
*/
|
|
357
357
|
|
|
358
358
|
|
|
@@ -367,15 +367,14 @@ function getEntityRecords(state, kind, name, query) {
|
|
|
367
367
|
|
|
368
368
|
return (0, _queriedData.getQueriedItems)(queriedState, query);
|
|
369
369
|
}
|
|
370
|
+
|
|
370
371
|
/**
|
|
371
372
|
* Returns the list of dirty entity records.
|
|
372
373
|
*
|
|
373
|
-
* @param
|
|
374
|
+
* @param state State tree.
|
|
374
375
|
*
|
|
375
|
-
* @return
|
|
376
|
+
* @return The list of updated records
|
|
376
377
|
*/
|
|
377
|
-
|
|
378
|
-
|
|
379
378
|
const __experimentalGetDirtyEntityRecords = (0, _rememo.default)(state => {
|
|
380
379
|
const {
|
|
381
380
|
entities: {
|
|
@@ -412,9 +411,9 @@ const __experimentalGetDirtyEntityRecords = (0, _rememo.default)(state => {
|
|
|
412
411
|
/**
|
|
413
412
|
* Returns the list of entities currently being saved.
|
|
414
413
|
*
|
|
415
|
-
* @param
|
|
414
|
+
* @param state State tree.
|
|
416
415
|
*
|
|
417
|
-
* @return
|
|
416
|
+
* @return The list of records being saved.
|
|
418
417
|
*/
|
|
419
418
|
|
|
420
419
|
|
|
@@ -454,12 +453,12 @@ const __experimentalGetEntitiesBeingSaved = (0, _rememo.default)(state => {
|
|
|
454
453
|
/**
|
|
455
454
|
* Returns the specified entity record's edits.
|
|
456
455
|
*
|
|
457
|
-
* @param
|
|
458
|
-
* @param
|
|
459
|
-
* @param
|
|
460
|
-
* @param
|
|
456
|
+
* @param state State tree.
|
|
457
|
+
* @param kind Entity kind.
|
|
458
|
+
* @param name Entity name.
|
|
459
|
+
* @param recordId Record ID.
|
|
461
460
|
*
|
|
462
|
-
* @return
|
|
461
|
+
* @return The entity record's edits.
|
|
463
462
|
*/
|
|
464
463
|
|
|
465
464
|
|
|
@@ -475,12 +474,12 @@ function getEntityRecordEdits(state, kind, name, recordId) {
|
|
|
475
474
|
* are not considered for change detection.
|
|
476
475
|
* They are defined in the entity's config.
|
|
477
476
|
*
|
|
478
|
-
* @param
|
|
479
|
-
* @param
|
|
480
|
-
* @param
|
|
481
|
-
* @param
|
|
477
|
+
* @param state State tree.
|
|
478
|
+
* @param kind Entity kind.
|
|
479
|
+
* @param name Entity name.
|
|
480
|
+
* @param recordId Record ID.
|
|
482
481
|
*
|
|
483
|
-
* @return
|
|
482
|
+
* @return The entity record's non transient edits.
|
|
484
483
|
*/
|
|
485
484
|
|
|
486
485
|
|
|
@@ -506,12 +505,12 @@ const getEntityRecordNonTransientEdits = (0, _rememo.default)((state, kind, name
|
|
|
506
505
|
* Returns true if the specified entity record has edits,
|
|
507
506
|
* and false otherwise.
|
|
508
507
|
*
|
|
509
|
-
* @param
|
|
510
|
-
* @param
|
|
511
|
-
* @param
|
|
512
|
-
* @param
|
|
508
|
+
* @param state State tree.
|
|
509
|
+
* @param kind Entity kind.
|
|
510
|
+
* @param name Entity name.
|
|
511
|
+
* @param recordId Record ID.
|
|
513
512
|
*
|
|
514
|
-
* @return
|
|
513
|
+
* @return Whether the entity record has edits or not.
|
|
515
514
|
*/
|
|
516
515
|
|
|
517
516
|
exports.getEntityRecordNonTransientEdits = getEntityRecordNonTransientEdits;
|
|
@@ -522,12 +521,12 @@ function hasEditsForEntityRecord(state, kind, name, recordId) {
|
|
|
522
521
|
/**
|
|
523
522
|
* Returns the specified entity record, merged with its edits.
|
|
524
523
|
*
|
|
525
|
-
* @param
|
|
526
|
-
* @param
|
|
527
|
-
* @param
|
|
528
|
-
* @param
|
|
524
|
+
* @param state State tree.
|
|
525
|
+
* @param kind Entity kind.
|
|
526
|
+
* @param name Entity name.
|
|
527
|
+
* @param recordId Record ID.
|
|
529
528
|
*
|
|
530
|
-
* @return
|
|
529
|
+
* @return The entity record, merged with its edits.
|
|
531
530
|
*/
|
|
532
531
|
|
|
533
532
|
|
|
@@ -542,12 +541,12 @@ const getEditedEntityRecord = (0, _rememo.default)((state, kind, name, recordId)
|
|
|
542
541
|
/**
|
|
543
542
|
* Returns true if the specified entity record is autosaving, and false otherwise.
|
|
544
543
|
*
|
|
545
|
-
* @param
|
|
546
|
-
* @param
|
|
547
|
-
* @param
|
|
548
|
-
* @param
|
|
544
|
+
* @param state State tree.
|
|
545
|
+
* @param kind Entity kind.
|
|
546
|
+
* @param name Entity name.
|
|
547
|
+
* @param recordId Record ID.
|
|
549
548
|
*
|
|
550
|
-
* @return
|
|
549
|
+
* @return Whether the entity record is autosaving or not.
|
|
551
550
|
*/
|
|
552
551
|
|
|
553
552
|
exports.getEditedEntityRecord = getEditedEntityRecord;
|
|
@@ -562,12 +561,12 @@ function isAutosavingEntityRecord(state, kind, name, recordId) {
|
|
|
562
561
|
/**
|
|
563
562
|
* Returns true if the specified entity record is saving, and false otherwise.
|
|
564
563
|
*
|
|
565
|
-
* @param
|
|
566
|
-
* @param
|
|
567
|
-
* @param
|
|
568
|
-
* @param
|
|
564
|
+
* @param state State tree.
|
|
565
|
+
* @param kind Entity kind.
|
|
566
|
+
* @param name Entity name.
|
|
567
|
+
* @param recordId Record ID.
|
|
569
568
|
*
|
|
570
|
-
* @return
|
|
569
|
+
* @return Whether the entity record is saving or not.
|
|
571
570
|
*/
|
|
572
571
|
|
|
573
572
|
|
|
@@ -577,12 +576,12 @@ function isSavingEntityRecord(state, kind, name, recordId) {
|
|
|
577
576
|
/**
|
|
578
577
|
* Returns true if the specified entity record is deleting, and false otherwise.
|
|
579
578
|
*
|
|
580
|
-
* @param
|
|
581
|
-
* @param
|
|
582
|
-
* @param
|
|
583
|
-
* @param
|
|
579
|
+
* @param state State tree.
|
|
580
|
+
* @param kind Entity kind.
|
|
581
|
+
* @param name Entity name.
|
|
582
|
+
* @param recordId Record ID.
|
|
584
583
|
*
|
|
585
|
-
* @return
|
|
584
|
+
* @return Whether the entity record is deleting or not.
|
|
586
585
|
*/
|
|
587
586
|
|
|
588
587
|
|
|
@@ -592,12 +591,12 @@ function isDeletingEntityRecord(state, kind, name, recordId) {
|
|
|
592
591
|
/**
|
|
593
592
|
* Returns the specified entity record's last save error.
|
|
594
593
|
*
|
|
595
|
-
* @param
|
|
596
|
-
* @param
|
|
597
|
-
* @param
|
|
598
|
-
* @param
|
|
594
|
+
* @param state State tree.
|
|
595
|
+
* @param kind Entity kind.
|
|
596
|
+
* @param name Entity name.
|
|
597
|
+
* @param recordId Record ID.
|
|
599
598
|
*
|
|
600
|
-
* @return
|
|
599
|
+
* @return The entity record's save error.
|
|
601
600
|
*/
|
|
602
601
|
|
|
603
602
|
|
|
@@ -607,12 +606,12 @@ function getLastEntitySaveError(state, kind, name, recordId) {
|
|
|
607
606
|
/**
|
|
608
607
|
* Returns the specified entity record's last delete error.
|
|
609
608
|
*
|
|
610
|
-
* @param
|
|
611
|
-
* @param
|
|
612
|
-
* @param
|
|
613
|
-
* @param
|
|
609
|
+
* @param state State tree.
|
|
610
|
+
* @param kind Entity kind.
|
|
611
|
+
* @param name Entity name.
|
|
612
|
+
* @param recordId Record ID.
|
|
614
613
|
*
|
|
615
|
-
* @return
|
|
614
|
+
* @return The entity record's save error.
|
|
616
615
|
*/
|
|
617
616
|
|
|
618
617
|
|
|
@@ -626,9 +625,9 @@ function getLastEntityDeleteError(state, kind, name, recordId) {
|
|
|
626
625
|
* of the history stack we are at. 0 is the
|
|
627
626
|
* last edit, -1 is the second last, and so on.
|
|
628
627
|
*
|
|
629
|
-
* @param
|
|
628
|
+
* @param state State tree.
|
|
630
629
|
*
|
|
631
|
-
* @return
|
|
630
|
+
* @return The current undo offset.
|
|
632
631
|
*/
|
|
633
632
|
|
|
634
633
|
|
|
@@ -639,9 +638,9 @@ function getCurrentUndoOffset(state) {
|
|
|
639
638
|
* Returns the previous edit from the current undo offset
|
|
640
639
|
* for the entity records edits history, if any.
|
|
641
640
|
*
|
|
642
|
-
* @param
|
|
641
|
+
* @param state State tree.
|
|
643
642
|
*
|
|
644
|
-
* @return
|
|
643
|
+
* @return The edit.
|
|
645
644
|
*/
|
|
646
645
|
|
|
647
646
|
|
|
@@ -652,9 +651,9 @@ function getUndoEdit(state) {
|
|
|
652
651
|
* Returns the next edit from the current undo offset
|
|
653
652
|
* for the entity records edits history, if any.
|
|
654
653
|
*
|
|
655
|
-
* @param
|
|
654
|
+
* @param state State tree.
|
|
656
655
|
*
|
|
657
|
-
* @return
|
|
656
|
+
* @return The edit.
|
|
658
657
|
*/
|
|
659
658
|
|
|
660
659
|
|
|
@@ -665,9 +664,9 @@ function getRedoEdit(state) {
|
|
|
665
664
|
* Returns true if there is a previous edit from the current undo offset
|
|
666
665
|
* for the entity records edits history, and false otherwise.
|
|
667
666
|
*
|
|
668
|
-
* @param
|
|
667
|
+
* @param state State tree.
|
|
669
668
|
*
|
|
670
|
-
* @return
|
|
669
|
+
* @return Whether there is a previous edit or not.
|
|
671
670
|
*/
|
|
672
671
|
|
|
673
672
|
|
|
@@ -678,9 +677,9 @@ function hasUndo(state) {
|
|
|
678
677
|
* Returns true if there is a next edit from the current undo offset
|
|
679
678
|
* for the entity records edits history, and false otherwise.
|
|
680
679
|
*
|
|
681
|
-
* @param
|
|
680
|
+
* @param state State tree.
|
|
682
681
|
*
|
|
683
|
-
* @return
|
|
682
|
+
* @return Whether there is a next edit or not.
|
|
684
683
|
*/
|
|
685
684
|
|
|
686
685
|
|
|
@@ -690,9 +689,9 @@ function hasRedo(state) {
|
|
|
690
689
|
/**
|
|
691
690
|
* Return the current theme.
|
|
692
691
|
*
|
|
693
|
-
* @param
|
|
692
|
+
* @param state Data state.
|
|
694
693
|
*
|
|
695
|
-
* @return
|
|
694
|
+
* @return The current theme.
|
|
696
695
|
*/
|
|
697
696
|
|
|
698
697
|
|
|
@@ -702,9 +701,9 @@ function getCurrentTheme(state) {
|
|
|
702
701
|
/**
|
|
703
702
|
* Return the ID of the current global styles object.
|
|
704
703
|
*
|
|
705
|
-
* @param
|
|
704
|
+
* @param state Data state.
|
|
706
705
|
*
|
|
707
|
-
* @return
|
|
706
|
+
* @return The current global styles ID.
|
|
708
707
|
*/
|
|
709
708
|
|
|
710
709
|
|
|
@@ -714,9 +713,9 @@ function __experimentalGetCurrentGlobalStylesId(state) {
|
|
|
714
713
|
/**
|
|
715
714
|
* Return theme supports data in the index.
|
|
716
715
|
*
|
|
717
|
-
* @param
|
|
716
|
+
* @param state Data state.
|
|
718
717
|
*
|
|
719
|
-
* @return
|
|
718
|
+
* @return Index data.
|
|
720
719
|
*/
|
|
721
720
|
|
|
722
721
|
|
|
@@ -728,10 +727,10 @@ function getThemeSupports(state) {
|
|
|
728
727
|
/**
|
|
729
728
|
* Returns the embed preview for the given URL.
|
|
730
729
|
*
|
|
731
|
-
* @param
|
|
732
|
-
* @param
|
|
730
|
+
* @param state Data state.
|
|
731
|
+
* @param url Embedded URL.
|
|
733
732
|
*
|
|
734
|
-
* @return
|
|
733
|
+
* @return Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.
|
|
735
734
|
*/
|
|
736
735
|
|
|
737
736
|
|
|
@@ -745,10 +744,10 @@ function getEmbedPreview(state, url) {
|
|
|
745
744
|
* We need to be able to determine if a URL is embeddable or not, based on what we
|
|
746
745
|
* get back from the oEmbed preview API.
|
|
747
746
|
*
|
|
748
|
-
* @param
|
|
749
|
-
* @param
|
|
747
|
+
* @param state Data state.
|
|
748
|
+
* @param url Embedded URL.
|
|
750
749
|
*
|
|
751
|
-
* @return
|
|
750
|
+
* @return Is the preview for the URL an oEmbed link fallback.
|
|
752
751
|
*/
|
|
753
752
|
|
|
754
753
|
|
|
@@ -771,12 +770,12 @@ function isPreviewEmbedFallback(state, url) {
|
|
|
771
770
|
*
|
|
772
771
|
* https://developer.wordpress.org/rest-api/reference/
|
|
773
772
|
*
|
|
774
|
-
* @param
|
|
775
|
-
* @param
|
|
776
|
-
* @param
|
|
777
|
-
* @param
|
|
773
|
+
* @param state Data state.
|
|
774
|
+
* @param action Action to check. One of: 'create', 'read', 'update', 'delete'.
|
|
775
|
+
* @param resource REST resource to check, e.g. 'media' or 'posts'.
|
|
776
|
+
* @param id Optional ID of the rest resource to check.
|
|
778
777
|
*
|
|
779
|
-
* @return
|
|
778
|
+
* @return Whether or not the user can perform the action,
|
|
780
779
|
* or `undefined` if the OPTIONS request is still being made.
|
|
781
780
|
*/
|
|
782
781
|
|
|
@@ -793,11 +792,11 @@ function canUser(state, action, resource, id) {
|
|
|
793
792
|
*
|
|
794
793
|
* https://developer.wordpress.org/rest-api/reference/
|
|
795
794
|
*
|
|
796
|
-
* @param
|
|
797
|
-
* @param
|
|
798
|
-
* @param
|
|
799
|
-
* @param
|
|
800
|
-
* @return
|
|
795
|
+
* @param state Data state.
|
|
796
|
+
* @param kind Entity kind.
|
|
797
|
+
* @param name Entity name.
|
|
798
|
+
* @param recordId Record's id.
|
|
799
|
+
* @return Whether or not the user can edit,
|
|
801
800
|
* or `undefined` if the OPTIONS request is still being made.
|
|
802
801
|
*/
|
|
803
802
|
|
|
@@ -818,11 +817,11 @@ function canUserEditEntityRecord(state, kind, name, recordId) {
|
|
|
818
817
|
* May return multiple autosaves since the backend stores one autosave per
|
|
819
818
|
* author for each post.
|
|
820
819
|
*
|
|
821
|
-
* @param
|
|
822
|
-
* @param
|
|
823
|
-
* @param
|
|
820
|
+
* @param state State tree.
|
|
821
|
+
* @param postType The type of the parent post.
|
|
822
|
+
* @param postId The id of the parent post.
|
|
824
823
|
*
|
|
825
|
-
* @return
|
|
824
|
+
* @return An array of autosaves for the post, or undefined if there is none.
|
|
826
825
|
*/
|
|
827
826
|
|
|
828
827
|
|
|
@@ -832,12 +831,12 @@ function getAutosaves(state, postType, postId) {
|
|
|
832
831
|
/**
|
|
833
832
|
* Returns the autosave for the post and author.
|
|
834
833
|
*
|
|
835
|
-
* @param
|
|
836
|
-
* @param
|
|
837
|
-
* @param
|
|
838
|
-
* @param
|
|
834
|
+
* @param state State tree.
|
|
835
|
+
* @param postType The type of the parent post.
|
|
836
|
+
* @param postId The id of the parent post.
|
|
837
|
+
* @param authorId The id of the author.
|
|
839
838
|
*
|
|
840
|
-
* @return
|
|
839
|
+
* @return The autosave for the post and author.
|
|
841
840
|
*/
|
|
842
841
|
|
|
843
842
|
|
|
@@ -854,11 +853,11 @@ function getAutosave(state, postType, postId, authorId) {
|
|
|
854
853
|
/**
|
|
855
854
|
* Returns true if the REST request for autosaves has completed.
|
|
856
855
|
*
|
|
857
|
-
* @param
|
|
858
|
-
* @param
|
|
859
|
-
* @param
|
|
856
|
+
* @param state State tree.
|
|
857
|
+
* @param postType The type of the parent post.
|
|
858
|
+
* @param postId The id of the parent post.
|
|
860
859
|
*
|
|
861
|
-
* @return
|
|
860
|
+
* @return True if the REST request was completed. False otherwise.
|
|
862
861
|
*/
|
|
863
862
|
|
|
864
863
|
|
|
@@ -879,20 +878,21 @@ const hasFetchedAutosaves = (0, _data.createRegistrySelector)(select => (state,
|
|
|
879
878
|
* );
|
|
880
879
|
* ```
|
|
881
880
|
*
|
|
882
|
-
* @param
|
|
881
|
+
* @param state Editor state.
|
|
883
882
|
*
|
|
884
|
-
* @return
|
|
883
|
+
* @return A value whose reference will change only when an edit occurs.
|
|
885
884
|
*/
|
|
886
885
|
|
|
887
886
|
exports.hasFetchedAutosaves = hasFetchedAutosaves;
|
|
888
|
-
const getReferenceByDistinctEdits = (0, _rememo.default)(
|
|
887
|
+
const getReferenceByDistinctEdits = (0, _rememo.default)( // This unused state argument is listed here for the documentation generating tool (docgen).
|
|
888
|
+
state => [], state => [state.undo.length, state.undo.offset, state.undo.flattenedUndo]);
|
|
889
889
|
/**
|
|
890
890
|
* Retrieve the frontend template used for a given link.
|
|
891
891
|
*
|
|
892
|
-
* @param
|
|
893
|
-
* @param
|
|
892
|
+
* @param state Editor state.
|
|
893
|
+
* @param link Link.
|
|
894
894
|
*
|
|
895
|
-
* @return
|
|
895
|
+
* @return The template record.
|
|
896
896
|
*/
|
|
897
897
|
|
|
898
898
|
exports.getReferenceByDistinctEdits = getReferenceByDistinctEdits;
|
|
@@ -912,9 +912,9 @@ function __experimentalGetTemplateForLink(state, link) {
|
|
|
912
912
|
/**
|
|
913
913
|
* Retrieve the current theme's base global styles
|
|
914
914
|
*
|
|
915
|
-
* @param
|
|
915
|
+
* @param state Editor state.
|
|
916
916
|
*
|
|
917
|
-
* @return
|
|
917
|
+
* @return The Global Styles object.
|
|
918
918
|
*/
|
|
919
919
|
|
|
920
920
|
|
|
@@ -930,9 +930,9 @@ function __experimentalGetCurrentThemeBaseGlobalStyles(state) {
|
|
|
930
930
|
/**
|
|
931
931
|
* Return the ID of the current global styles object.
|
|
932
932
|
*
|
|
933
|
-
* @param
|
|
933
|
+
* @param state Data state.
|
|
934
934
|
*
|
|
935
|
-
* @return
|
|
935
|
+
* @return The current global styles ID.
|
|
936
936
|
*/
|
|
937
937
|
|
|
938
938
|
|
|
@@ -948,9 +948,9 @@ function __experimentalGetCurrentThemeGlobalStylesVariations(state) {
|
|
|
948
948
|
/**
|
|
949
949
|
* Retrieve the list of registered block patterns.
|
|
950
950
|
*
|
|
951
|
-
* @param
|
|
951
|
+
* @param state Data state.
|
|
952
952
|
*
|
|
953
|
-
* @return
|
|
953
|
+
* @return Block pattern list.
|
|
954
954
|
*/
|
|
955
955
|
|
|
956
956
|
|
|
@@ -960,9 +960,9 @@ function getBlockPatterns(state) {
|
|
|
960
960
|
/**
|
|
961
961
|
* Retrieve the list of registered block pattern categories.
|
|
962
962
|
*
|
|
963
|
-
* @param
|
|
963
|
+
* @param state Data state.
|
|
964
964
|
*
|
|
965
|
-
* @return
|
|
965
|
+
* @return Block pattern category list.
|
|
966
966
|
*/
|
|
967
967
|
|
|
968
968
|
|