@wordpress/core-data 6.24.0 → 6.25.1-next.79a6196f.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 +2 -0
- package/LICENSE.md +1 -1
- package/build/entities.js +38 -14
- package/build/entities.js.map +1 -1
- package/build/entity-provider.js +8 -4
- package/build/entity-provider.js.map +1 -1
- package/build/footnotes/get-footnotes-order.js +2 -9
- package/build/footnotes/get-footnotes-order.js.map +1 -1
- package/build/footnotes/index.js +11 -10
- package/build/footnotes/index.js.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/reducer.js +23 -26
- package/build/reducer.js.map +1 -1
- package/build/resolvers.js +60 -47
- package/build/resolvers.js.map +1 -1
- package/build-module/entities.js +37 -13
- package/build-module/entities.js.map +1 -1
- package/build-module/entity-provider.js +8 -4
- package/build-module/entity-provider.js.map +1 -1
- package/build-module/footnotes/get-footnotes-order.js +2 -9
- package/build-module/footnotes/get-footnotes-order.js.map +1 -1
- package/build-module/footnotes/index.js +12 -11
- package/build-module/footnotes/index.js.map +1 -1
- package/build-module/index.js +2 -2
- package/build-module/index.js.map +1 -1
- package/build-module/reducer.js +23 -26
- package/build-module/reducer.js.map +1 -1
- package/build-module/resolvers.js +60 -47
- package/build-module/resolvers.js.map +1 -1
- package/build-types/entities.d.ts +0 -12
- package/build-types/entities.d.ts.map +1 -1
- package/build-types/entity-provider.d.ts.map +1 -1
- package/build-types/footnotes/get-footnotes-order.d.ts.map +1 -1
- package/build-types/footnotes/index.d.ts.map +1 -1
- package/build-types/reducer.d.ts.map +1 -1
- package/build-types/resolvers.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/entities.js +40 -25
- package/src/entity-provider.js +10 -4
- package/src/footnotes/get-footnotes-order.js +5 -12
- package/src/footnotes/index.js +22 -8
- package/src/hooks/test/use-query-select.js +8 -10
- package/src/index.js +4 -4
- package/src/reducer.js +29 -43
- package/src/resolvers.js +77 -60
- package/tsconfig.tsbuildinfo +1 -1
package/build-module/entities.js
CHANGED
|
@@ -8,6 +8,7 @@ import { capitalCase, pascalCase } from 'change-case';
|
|
|
8
8
|
*/
|
|
9
9
|
import apiFetch from '@wordpress/api-fetch';
|
|
10
10
|
import { __ } from '@wordpress/i18n';
|
|
11
|
+
import { RichTextData } from '@wordpress/rich-text';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Internal dependencies
|
|
@@ -16,11 +17,6 @@ import { addEntities } from './actions';
|
|
|
16
17
|
import { getSyncProvider } from './sync';
|
|
17
18
|
export const DEFAULT_ENTITY_KEY = 'id';
|
|
18
19
|
const POST_RAW_ATTRIBUTES = ['title', 'excerpt', 'content'];
|
|
19
|
-
|
|
20
|
-
// A hardcoded list of post types that support revisions.
|
|
21
|
-
// Reflects post types in Core's src/wp-includes/post.php.
|
|
22
|
-
// @TODO: Ideally this should be fetched from the `/types` REST API's view context.
|
|
23
|
-
const POST_TYPE_ENTITIES_WITH_REVISIONS_SUPPORT = ['post', 'page', 'wp_block', 'wp_navigation', 'wp_template', 'wp_template_part'];
|
|
24
20
|
export const rootEntitiesConfig = [{
|
|
25
21
|
label: __('Base'),
|
|
26
22
|
kind: 'root',
|
|
@@ -220,9 +216,6 @@ export const rootEntitiesConfig = [{
|
|
|
220
216
|
// Should be different from name.
|
|
221
217
|
getTitle: record => record?.title?.rendered || record?.title,
|
|
222
218
|
getRevisionsUrl: (parentId, revisionId) => `/wp/v2/global-styles/${parentId}/revisions${revisionId ? '/' + revisionId : ''}`,
|
|
223
|
-
supports: {
|
|
224
|
-
revisions: true
|
|
225
|
-
},
|
|
226
219
|
supportsPagination: true
|
|
227
220
|
}, {
|
|
228
221
|
label: __('Themes'),
|
|
@@ -283,6 +276,32 @@ export const prePersistPostType = (persistedRecord, edits) => {
|
|
|
283
276
|
}
|
|
284
277
|
return newEdits;
|
|
285
278
|
};
|
|
279
|
+
const serialisableBlocksCache = new WeakMap();
|
|
280
|
+
function makeBlockAttributesSerializable(attributes) {
|
|
281
|
+
const newAttributes = {
|
|
282
|
+
...attributes
|
|
283
|
+
};
|
|
284
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
285
|
+
if (value instanceof RichTextData) {
|
|
286
|
+
newAttributes[key] = value.valueOf();
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return newAttributes;
|
|
290
|
+
}
|
|
291
|
+
function makeBlocksSerializable(blocks) {
|
|
292
|
+
return blocks.map(block => {
|
|
293
|
+
const {
|
|
294
|
+
innerBlocks,
|
|
295
|
+
attributes,
|
|
296
|
+
...rest
|
|
297
|
+
} = block;
|
|
298
|
+
return {
|
|
299
|
+
...rest,
|
|
300
|
+
attributes: makeBlockAttributesSerializable(attributes),
|
|
301
|
+
innerBlocks: makeBlocksSerializable(innerBlocks)
|
|
302
|
+
};
|
|
303
|
+
});
|
|
304
|
+
}
|
|
286
305
|
|
|
287
306
|
/**
|
|
288
307
|
* Returns the list of post type entities.
|
|
@@ -312,9 +331,6 @@ async function loadPostTypeEntities() {
|
|
|
312
331
|
mergedEdits: {
|
|
313
332
|
meta: true
|
|
314
333
|
},
|
|
315
|
-
supports: {
|
|
316
|
-
revisions: POST_TYPE_ENTITIES_WITH_REVISIONS_SUPPORT.includes(postType?.slug)
|
|
317
|
-
},
|
|
318
334
|
rawAttributes: POST_RAW_ATTRIBUTES,
|
|
319
335
|
getTitle: record => {
|
|
320
336
|
var _record$slug;
|
|
@@ -331,8 +347,16 @@ async function loadPostTypeEntities() {
|
|
|
331
347
|
applyChangesToDoc: (doc, changes) => {
|
|
332
348
|
const document = doc.getMap('document');
|
|
333
349
|
Object.entries(changes).forEach(([key, value]) => {
|
|
334
|
-
if (
|
|
335
|
-
|
|
350
|
+
if (typeof value !== 'function') {
|
|
351
|
+
if (key === 'blocks') {
|
|
352
|
+
if (!serialisableBlocksCache.has(value)) {
|
|
353
|
+
serialisableBlocksCache.set(value, makeBlocksSerializable(value));
|
|
354
|
+
}
|
|
355
|
+
value = serialisableBlocksCache.get(value);
|
|
356
|
+
}
|
|
357
|
+
if (document.get(key) !== value) {
|
|
358
|
+
document.set(key, value);
|
|
359
|
+
}
|
|
336
360
|
}
|
|
337
361
|
});
|
|
338
362
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["capitalCase","pascalCase","apiFetch","__","addEntities","getSyncProvider","DEFAULT_ENTITY_KEY","POST_RAW_ATTRIBUTES","POST_TYPE_ENTITIES_WITH_REVISIONS_SUPPORT","rootEntitiesConfig","label","kind","name","baseURL","baseURLParams","_fields","join","syncConfig","fetch","path","applyChangesToDoc","doc","changes","document","getMap","Object","entries","forEach","key","value","get","set","fromCRDTDoc","toJSON","syncObjectType","getSyncObjectId","getTitle","record","_record$title","title","context","id","plural","rawAttributes","supportsPagination","transientEdits","blocks","rendered","getRevisionsUrl","parentId","revisionId","supports","revisions","additionalEntityConfigLoaders","loadEntities","loadPostTypeEntities","loadTaxonomyEntities","prePersistPostType","persistedRecord","edits","newEdits","status","postTypes","map","postType","_postType$rest_namesp","isTemplate","includes","namespace","rest_namespace","rest_base","selection","mergedEdits","meta","slug","_record$slug","String","__unstablePrePersist","undefined","__unstable_rest_base","revisionKey","taxonomies","taxonomy","_taxonomy$rest_namesp","getMethodName","prefix","usePlural","entityConfig","find","config","kindPrefix","nameSuffix","suffix","registerSyncConfigs","configs","register","editSyncConfig","getOrLoadEntitiesConfig","select","dispatch","getEntitiesConfig","length","window","__experimentalEnableSync","process","env","IS_GUTENBERG_PLUGIN","loader","l"],"sources":["@wordpress/core-data/src/entities.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { capitalCase, pascalCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { addEntities } from './actions';\nimport { getSyncProvider } from './sync';\n\nexport const DEFAULT_ENTITY_KEY = 'id';\n\nconst POST_RAW_ATTRIBUTES = [ 'title', 'excerpt', 'content' ];\n\n// A hardcoded list of post types that support revisions.\n// Reflects post types in Core's src/wp-includes/post.php.\n// @TODO: Ideally this should be fetched from the `/types` REST API's view context.\nconst POST_TYPE_ENTITIES_WITH_REVISIONS_SUPPORT = [\n\t'post',\n\t'page',\n\t'wp_block',\n\t'wp_navigation',\n\t'wp_template',\n\t'wp_template_part',\n];\n\nexport const rootEntitiesConfig = [\n\t{\n\t\tlabel: __( 'Base' ),\n\t\tkind: 'root',\n\t\tname: '__unstableBase',\n\t\tbaseURL: '/',\n\t\tbaseURLParams: {\n\t\t\t_fields: [\n\t\t\t\t'description',\n\t\t\t\t'gmt_offset',\n\t\t\t\t'home',\n\t\t\t\t'name',\n\t\t\t\t'site_icon',\n\t\t\t\t'site_icon_url',\n\t\t\t\t'site_logo',\n\t\t\t\t'timezone_string',\n\t\t\t\t'url',\n\t\t\t].join( ',' ),\n\t\t},\n\t\tsyncConfig: {\n\t\t\tfetch: async () => {\n\t\t\t\treturn apiFetch( { path: '/' } );\n\t\t\t},\n\t\t\tapplyChangesToDoc: ( doc, changes ) => {\n\t\t\t\tconst document = doc.getMap( 'document' );\n\t\t\t\tObject.entries( changes ).forEach( ( [ key, value ] ) => {\n\t\t\t\t\tif ( document.get( key ) !== value ) {\n\t\t\t\t\t\tdocument.set( key, value );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\tfromCRDTDoc: ( doc ) => {\n\t\t\t\treturn doc.getMap( 'document' ).toJSON();\n\t\t\t},\n\t\t},\n\t\tsyncObjectType: 'root/base',\n\t\tgetSyncObjectId: () => 'index',\n\t},\n\t{\n\t\tlabel: __( 'Site' ),\n\t\tname: 'site',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/settings',\n\t\tgetTitle: ( record ) => {\n\t\t\treturn record?.title ?? __( 'Site Title' );\n\t\t},\n\t\tsyncConfig: {\n\t\t\tfetch: async () => {\n\t\t\t\treturn apiFetch( { path: '/wp/v2/settings' } );\n\t\t\t},\n\t\t\tapplyChangesToDoc: ( doc, changes ) => {\n\t\t\t\tconst document = doc.getMap( 'document' );\n\t\t\t\tObject.entries( changes ).forEach( ( [ key, value ] ) => {\n\t\t\t\t\tif ( document.get( key ) !== value ) {\n\t\t\t\t\t\tdocument.set( key, value );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\tfromCRDTDoc: ( doc ) => {\n\t\t\t\treturn doc.getMap( 'document' ).toJSON();\n\t\t\t},\n\t\t},\n\t\tsyncObjectType: 'root/site',\n\t\tgetSyncObjectId: () => 'index',\n\t},\n\t{\n\t\tlabel: __( 'Post Type' ),\n\t\tname: 'postType',\n\t\tkind: 'root',\n\t\tkey: 'slug',\n\t\tbaseURL: '/wp/v2/types',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tsyncConfig: {\n\t\t\tfetch: async ( id ) => {\n\t\t\t\treturn apiFetch( {\n\t\t\t\t\tpath: `/wp/v2/types/${ id }?context=edit`,\n\t\t\t\t} );\n\t\t\t},\n\t\t\tapplyChangesToDoc: ( doc, changes ) => {\n\t\t\t\tconst document = doc.getMap( 'document' );\n\t\t\t\tObject.entries( changes ).forEach( ( [ key, value ] ) => {\n\t\t\t\t\tif ( document.get( key ) !== value ) {\n\t\t\t\t\t\tdocument.set( key, value );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\tfromCRDTDoc: ( doc ) => {\n\t\t\t\treturn doc.getMap( 'document' ).toJSON();\n\t\t\t},\n\t\t},\n\t\tsyncObjectType: 'root/postType',\n\t\tgetSyncObjectId: ( id ) => id,\n\t},\n\t{\n\t\tname: 'media',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/media',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'mediaItems',\n\t\tlabel: __( 'Media' ),\n\t\trawAttributes: [ 'caption', 'title', 'description' ],\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'taxonomy',\n\t\tkind: 'root',\n\t\tkey: 'slug',\n\t\tbaseURL: '/wp/v2/taxonomies',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'taxonomies',\n\t\tlabel: __( 'Taxonomy' ),\n\t},\n\t{\n\t\tname: 'sidebar',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/sidebars',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'sidebars',\n\t\ttransientEdits: { blocks: true },\n\t\tlabel: __( 'Widget areas' ),\n\t},\n\t{\n\t\tname: 'widget',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/widgets',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'widgets',\n\t\ttransientEdits: { blocks: true },\n\t\tlabel: __( 'Widgets' ),\n\t},\n\t{\n\t\tname: 'widgetType',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/widget-types',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'widgetTypes',\n\t\tlabel: __( 'Widget types' ),\n\t},\n\t{\n\t\tlabel: __( 'User' ),\n\t\tname: 'user',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/users',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'users',\n\t},\n\t{\n\t\tname: 'comment',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/comments',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'comments',\n\t\tlabel: __( 'Comment' ),\n\t},\n\t{\n\t\tname: 'menu',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menus',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menus',\n\t\tlabel: __( 'Menu' ),\n\t},\n\t{\n\t\tname: 'menuItem',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menu-items',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menuItems',\n\t\tlabel: __( 'Menu Item' ),\n\t\trawAttributes: [ 'title' ],\n\t},\n\t{\n\t\tname: 'menuLocation',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menu-locations',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menuLocations',\n\t\tlabel: __( 'Menu Location' ),\n\t\tkey: 'name',\n\t},\n\t{\n\t\tlabel: __( 'Global Styles' ),\n\t\tname: 'globalStyles',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/global-styles',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'globalStylesVariations', // Should be different from name.\n\t\tgetTitle: ( record ) => record?.title?.rendered || record?.title,\n\t\tgetRevisionsUrl: ( parentId, revisionId ) =>\n\t\t\t`/wp/v2/global-styles/${ parentId }/revisions${\n\t\t\t\trevisionId ? '/' + revisionId : ''\n\t\t\t}`,\n\t\tsupports: {\n\t\t\trevisions: true,\n\t\t},\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tlabel: __( 'Themes' ),\n\t\tname: 'theme',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/themes',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tkey: 'stylesheet',\n\t},\n\t{\n\t\tlabel: __( 'Plugins' ),\n\t\tname: 'plugin',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/plugins',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tkey: 'plugin',\n\t},\n\t{\n\t\tlabel: __( 'Status' ),\n\t\tname: 'status',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/statuses',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'statuses',\n\t\tkey: 'slug',\n\t},\n];\n\nexport const additionalEntityConfigLoaders = [\n\t{ kind: 'postType', loadEntities: loadPostTypeEntities },\n\t{ kind: 'taxonomy', loadEntities: loadTaxonomyEntities },\n];\n\n/**\n * Returns a function to be used to retrieve extra edits to apply before persisting a post type.\n *\n * @param {Object} persistedRecord Already persisted Post\n * @param {Object} edits Edits.\n * @return {Object} Updated edits.\n */\nexport const prePersistPostType = ( persistedRecord, edits ) => {\n\tconst newEdits = {};\n\n\tif ( persistedRecord?.status === 'auto-draft' ) {\n\t\t// Saving an auto-draft should create a draft by default.\n\t\tif ( ! edits.status && ! newEdits.status ) {\n\t\t\tnewEdits.status = 'draft';\n\t\t}\n\n\t\t// Fix the auto-draft default title.\n\t\tif (\n\t\t\t( ! edits.title || edits.title === 'Auto Draft' ) &&\n\t\t\t! newEdits.title &&\n\t\t\t( ! persistedRecord?.title ||\n\t\t\t\tpersistedRecord?.title === 'Auto Draft' )\n\t\t) {\n\t\t\tnewEdits.title = '';\n\t\t}\n\t}\n\n\treturn newEdits;\n};\n\n/**\n * Returns the list of post type entities.\n *\n * @return {Promise} Entities promise\n */\nasync function loadPostTypeEntities() {\n\tconst postTypes = await apiFetch( {\n\t\tpath: '/wp/v2/types?context=view',\n\t} );\n\treturn Object.entries( postTypes ?? {} ).map( ( [ name, postType ] ) => {\n\t\tconst isTemplate = [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\tname\n\t\t);\n\t\tconst namespace = postType?.rest_namespace ?? 'wp/v2';\n\t\treturn {\n\t\t\tkind: 'postType',\n\t\t\tbaseURL: `/${ namespace }/${ postType.rest_base }`,\n\t\t\tbaseURLParams: { context: 'edit' },\n\t\t\tname,\n\t\t\tlabel: postType.name,\n\t\t\ttransientEdits: {\n\t\t\t\tblocks: true,\n\t\t\t\tselection: true,\n\t\t\t},\n\t\t\tmergedEdits: { meta: true },\n\t\t\tsupports: {\n\t\t\t\trevisions: POST_TYPE_ENTITIES_WITH_REVISIONS_SUPPORT.includes(\n\t\t\t\t\tpostType?.slug\n\t\t\t\t),\n\t\t\t},\n\t\t\trawAttributes: POST_RAW_ATTRIBUTES,\n\t\t\tgetTitle: ( record ) =>\n\t\t\t\trecord?.title?.rendered ||\n\t\t\t\trecord?.title ||\n\t\t\t\t( isTemplate\n\t\t\t\t\t? capitalCase( record.slug ?? '' )\n\t\t\t\t\t: String( record.id ) ),\n\t\t\t__unstablePrePersist: isTemplate ? undefined : prePersistPostType,\n\t\t\t__unstable_rest_base: postType.rest_base,\n\t\t\tsyncConfig: {\n\t\t\t\tfetch: async ( id ) => {\n\t\t\t\t\treturn apiFetch( {\n\t\t\t\t\t\tpath: `/${ namespace }/${ postType.rest_base }/${ id }?context=edit`,\n\t\t\t\t\t} );\n\t\t\t\t},\n\t\t\t\tapplyChangesToDoc: ( doc, changes ) => {\n\t\t\t\t\tconst document = doc.getMap( 'document' );\n\t\t\t\t\tObject.entries( changes ).forEach( ( [ key, value ] ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tdocument.get( key ) !== value &&\n\t\t\t\t\t\t\ttypeof value !== 'function'\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tdocument.set( key, value );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t},\n\t\t\t\tfromCRDTDoc: ( doc ) => {\n\t\t\t\t\treturn doc.getMap( 'document' ).toJSON();\n\t\t\t\t},\n\t\t\t},\n\t\t\tsyncObjectType: 'postType/' + postType.name,\n\t\t\tgetSyncObjectId: ( id ) => id,\n\t\t\tsupportsPagination: true,\n\t\t\tgetRevisionsUrl: ( parentId, revisionId ) =>\n\t\t\t\t`/${ namespace }/${\n\t\t\t\t\tpostType.rest_base\n\t\t\t\t}/${ parentId }/revisions${\n\t\t\t\t\trevisionId ? '/' + revisionId : ''\n\t\t\t\t}`,\n\t\t\trevisionKey: isTemplate ? 'wp_id' : DEFAULT_ENTITY_KEY,\n\t\t};\n\t} );\n}\n\n/**\n * Returns the list of the taxonomies entities.\n *\n * @return {Promise} Entities promise\n */\nasync function loadTaxonomyEntities() {\n\tconst taxonomies = await apiFetch( {\n\t\tpath: '/wp/v2/taxonomies?context=view',\n\t} );\n\treturn Object.entries( taxonomies ?? {} ).map( ( [ name, taxonomy ] ) => {\n\t\tconst namespace = taxonomy?.rest_namespace ?? 'wp/v2';\n\t\treturn {\n\t\t\tkind: 'taxonomy',\n\t\t\tbaseURL: `/${ namespace }/${ taxonomy.rest_base }`,\n\t\t\tbaseURLParams: { context: 'edit' },\n\t\t\tname,\n\t\t\tlabel: taxonomy.name,\n\t\t};\n\t} );\n}\n\n/**\n * Returns the entity's getter method name given its kind and name.\n *\n * @example\n * ```js\n * const nameSingular = getMethodName( 'root', 'theme', 'get' );\n * // nameSingular is getRootTheme\n *\n * const namePlural = getMethodName( 'root', 'theme', 'set' );\n * // namePlural is setRootThemes\n * ```\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {string} prefix Function prefix.\n * @param {boolean} usePlural Whether to use the plural form or not.\n *\n * @return {string} Method name\n */\nexport const getMethodName = (\n\tkind,\n\tname,\n\tprefix = 'get',\n\tusePlural = false\n) => {\n\tconst entityConfig = rootEntitiesConfig.find(\n\t\t( config ) => config.kind === kind && config.name === name\n\t);\n\tconst kindPrefix = kind === 'root' ? '' : pascalCase( kind );\n\tconst nameSuffix = pascalCase( name ) + ( usePlural ? 's' : '' );\n\tconst suffix =\n\t\tusePlural && 'plural' in entityConfig && entityConfig?.plural\n\t\t\t? pascalCase( entityConfig.plural )\n\t\t\t: nameSuffix;\n\treturn `${ prefix }${ kindPrefix }${ suffix }`;\n};\n\nfunction registerSyncConfigs( configs ) {\n\tconfigs.forEach( ( { syncObjectType, syncConfig } ) => {\n\t\tgetSyncProvider().register( syncObjectType, syncConfig );\n\t\tconst editSyncConfig = { ...syncConfig };\n\t\tdelete editSyncConfig.fetch;\n\t\tgetSyncProvider().register( syncObjectType + '--edit', editSyncConfig );\n\t} );\n}\n\n/**\n * Loads the kind entities into the store.\n *\n * @param {string} kind Kind\n *\n * @return {(thunkArgs: object) => Promise<Array>} Entities\n */\nexport const getOrLoadEntitiesConfig =\n\t( kind ) =>\n\tasync ( { select, dispatch } ) => {\n\t\tlet configs = select.getEntitiesConfig( kind );\n\t\tif ( configs && configs.length !== 0 ) {\n\t\t\tif ( window.__experimentalEnableSync ) {\n\t\t\t\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t\t\t\tregisterSyncConfigs( configs );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn configs;\n\t\t}\n\n\t\tconst loader = additionalEntityConfigLoaders.find(\n\t\t\t( l ) => l.kind === kind\n\t\t);\n\t\tif ( ! loader ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconfigs = await loader.loadEntities();\n\t\tif ( window.__experimentalEnableSync ) {\n\t\t\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t\t\tregisterSyncConfigs( configs );\n\t\t\t}\n\t\t}\n\n\t\tdispatch( addEntities( configs ) );\n\n\t\treturn configs;\n\t};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,UAAU,QAAQ,aAAa;;AAErD;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,sBAAsB;AAC3C,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,WAAW,QAAQ,WAAW;AACvC,SAASC,eAAe,QAAQ,QAAQ;AAExC,OAAO,MAAMC,kBAAkB,GAAG,IAAI;AAEtC,MAAMC,mBAAmB,GAAG,CAAE,OAAO,EAAE,SAAS,EAAE,SAAS,CAAE;;AAE7D;AACA;AACA;AACA,MAAMC,yCAAyC,GAAG,CACjD,MAAM,EACN,MAAM,EACN,UAAU,EACV,eAAe,EACf,aAAa,EACb,kBAAkB,CAClB;AAED,OAAO,MAAMC,kBAAkB,GAAG,CACjC;EACCC,KAAK,EAAEP,EAAE,CAAE,MAAO,CAAC;EACnBQ,IAAI,EAAE,MAAM;EACZC,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAE,GAAG;EACZC,aAAa,EAAE;IACdC,OAAO,EAAE,CACR,aAAa,EACb,YAAY,EACZ,MAAM,EACN,MAAM,EACN,WAAW,EACX,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,KAAK,CACL,CAACC,IAAI,CAAE,GAAI;EACb,CAAC;EACDC,UAAU,EAAE;IACXC,KAAK,EAAE,MAAAA,CAAA,KAAY;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EjB,UAAW,CAAC;IACxD,MAAM+E,cAAc,GAAG;MAAE,GAAG/E;IAAW,CAAC;IACxC,OAAO+E,cAAc,CAAC9E,KAAK;IAC3Bb,eAAe,CAAC,CAAC,CAAC0F,QAAQ,CAAE7D,cAAc,GAAG,QAAQ,EAAE8D,cAAe,CAAC;EACxE,CAAE,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,GACjCtF,IAAI,IACN,OAAQ;EAAEuF,MAAM;EAAEC;AAAS,CAAC,KAAM;EACjC,IAAIL,OAAO,GAAGI,MAAM,CAACE,iBAAiB,CAAEzF,IAAK,CAAC;EAC9C,IAAKmF,OAAO,IAAIA,OAAO,CAACO,MAAM,KAAK,CAAC,EAAG;IACtC,IAAKC,MAAM,CAACC,wBAAwB,EAAG;MACtC,IAAKC,OAAO,CAACC,GAAG,CAACC,mBAAmB,EAAG;QACtCb,mBAAmB,CAAEC,OAAQ,CAAC;MAC/B;IACD;IAEA,OAAOA,OAAO;EACf;EAEA,MAAMa,MAAM,GAAGtD,6BAA6B,CAACmC,IAAI,CAC9CoB,CAAC,IAAMA,CAAC,CAACjG,IAAI,KAAKA,IACrB,CAAC;EACD,IAAK,CAAEgG,MAAM,EAAG;IACf,OAAO,EAAE;EACV;EAEAb,OAAO,GAAG,MAAMa,MAAM,CAACrD,YAAY,CAAC,CAAC;EACrC,IAAKgD,MAAM,CAACC,wBAAwB,EAAG;IACtC,IAAKC,OAAO,CAACC,GAAG,CAACC,mBAAmB,EAAG;MACtCb,mBAAmB,CAAEC,OAAQ,CAAC;IAC/B;EACD;EAEAK,QAAQ,CAAE/F,WAAW,CAAE0F,OAAQ,CAAE,CAAC;EAElC,OAAOA,OAAO;AACf,CAAC"}
|
|
1
|
+
{"version":3,"names":["capitalCase","pascalCase","apiFetch","__","RichTextData","addEntities","getSyncProvider","DEFAULT_ENTITY_KEY","POST_RAW_ATTRIBUTES","rootEntitiesConfig","label","kind","name","baseURL","baseURLParams","_fields","join","syncConfig","fetch","path","applyChangesToDoc","doc","changes","document","getMap","Object","entries","forEach","key","value","get","set","fromCRDTDoc","toJSON","syncObjectType","getSyncObjectId","getTitle","record","_record$title","title","context","id","plural","rawAttributes","supportsPagination","transientEdits","blocks","rendered","getRevisionsUrl","parentId","revisionId","additionalEntityConfigLoaders","loadEntities","loadPostTypeEntities","loadTaxonomyEntities","prePersistPostType","persistedRecord","edits","newEdits","status","serialisableBlocksCache","WeakMap","makeBlockAttributesSerializable","attributes","newAttributes","valueOf","makeBlocksSerializable","map","block","innerBlocks","rest","postTypes","postType","_postType$rest_namesp","isTemplate","includes","namespace","rest_namespace","rest_base","selection","mergedEdits","meta","_record$slug","slug","String","__unstablePrePersist","undefined","__unstable_rest_base","has","revisionKey","taxonomies","taxonomy","_taxonomy$rest_namesp","getMethodName","prefix","usePlural","entityConfig","find","config","kindPrefix","nameSuffix","suffix","registerSyncConfigs","configs","register","editSyncConfig","getOrLoadEntitiesConfig","select","dispatch","getEntitiesConfig","length","window","__experimentalEnableSync","process","env","IS_GUTENBERG_PLUGIN","loader","l"],"sources":["@wordpress/core-data/src/entities.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { capitalCase, pascalCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { __ } from '@wordpress/i18n';\nimport { RichTextData } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { addEntities } from './actions';\nimport { getSyncProvider } from './sync';\n\nexport const DEFAULT_ENTITY_KEY = 'id';\n\nconst POST_RAW_ATTRIBUTES = [ 'title', 'excerpt', 'content' ];\n\nexport const rootEntitiesConfig = [\n\t{\n\t\tlabel: __( 'Base' ),\n\t\tkind: 'root',\n\t\tname: '__unstableBase',\n\t\tbaseURL: '/',\n\t\tbaseURLParams: {\n\t\t\t_fields: [\n\t\t\t\t'description',\n\t\t\t\t'gmt_offset',\n\t\t\t\t'home',\n\t\t\t\t'name',\n\t\t\t\t'site_icon',\n\t\t\t\t'site_icon_url',\n\t\t\t\t'site_logo',\n\t\t\t\t'timezone_string',\n\t\t\t\t'url',\n\t\t\t].join( ',' ),\n\t\t},\n\t\tsyncConfig: {\n\t\t\tfetch: async () => {\n\t\t\t\treturn apiFetch( { path: '/' } );\n\t\t\t},\n\t\t\tapplyChangesToDoc: ( doc, changes ) => {\n\t\t\t\tconst document = doc.getMap( 'document' );\n\t\t\t\tObject.entries( changes ).forEach( ( [ key, value ] ) => {\n\t\t\t\t\tif ( document.get( key ) !== value ) {\n\t\t\t\t\t\tdocument.set( key, value );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\tfromCRDTDoc: ( doc ) => {\n\t\t\t\treturn doc.getMap( 'document' ).toJSON();\n\t\t\t},\n\t\t},\n\t\tsyncObjectType: 'root/base',\n\t\tgetSyncObjectId: () => 'index',\n\t},\n\t{\n\t\tlabel: __( 'Site' ),\n\t\tname: 'site',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/settings',\n\t\tgetTitle: ( record ) => {\n\t\t\treturn record?.title ?? __( 'Site Title' );\n\t\t},\n\t\tsyncConfig: {\n\t\t\tfetch: async () => {\n\t\t\t\treturn apiFetch( { path: '/wp/v2/settings' } );\n\t\t\t},\n\t\t\tapplyChangesToDoc: ( doc, changes ) => {\n\t\t\t\tconst document = doc.getMap( 'document' );\n\t\t\t\tObject.entries( changes ).forEach( ( [ key, value ] ) => {\n\t\t\t\t\tif ( document.get( key ) !== value ) {\n\t\t\t\t\t\tdocument.set( key, value );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\tfromCRDTDoc: ( doc ) => {\n\t\t\t\treturn doc.getMap( 'document' ).toJSON();\n\t\t\t},\n\t\t},\n\t\tsyncObjectType: 'root/site',\n\t\tgetSyncObjectId: () => 'index',\n\t},\n\t{\n\t\tlabel: __( 'Post Type' ),\n\t\tname: 'postType',\n\t\tkind: 'root',\n\t\tkey: 'slug',\n\t\tbaseURL: '/wp/v2/types',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tsyncConfig: {\n\t\t\tfetch: async ( id ) => {\n\t\t\t\treturn apiFetch( {\n\t\t\t\t\tpath: `/wp/v2/types/${ id }?context=edit`,\n\t\t\t\t} );\n\t\t\t},\n\t\t\tapplyChangesToDoc: ( doc, changes ) => {\n\t\t\t\tconst document = doc.getMap( 'document' );\n\t\t\t\tObject.entries( changes ).forEach( ( [ key, value ] ) => {\n\t\t\t\t\tif ( document.get( key ) !== value ) {\n\t\t\t\t\t\tdocument.set( key, value );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\tfromCRDTDoc: ( doc ) => {\n\t\t\t\treturn doc.getMap( 'document' ).toJSON();\n\t\t\t},\n\t\t},\n\t\tsyncObjectType: 'root/postType',\n\t\tgetSyncObjectId: ( id ) => id,\n\t},\n\t{\n\t\tname: 'media',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/media',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'mediaItems',\n\t\tlabel: __( 'Media' ),\n\t\trawAttributes: [ 'caption', 'title', 'description' ],\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tname: 'taxonomy',\n\t\tkind: 'root',\n\t\tkey: 'slug',\n\t\tbaseURL: '/wp/v2/taxonomies',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'taxonomies',\n\t\tlabel: __( 'Taxonomy' ),\n\t},\n\t{\n\t\tname: 'sidebar',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/sidebars',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'sidebars',\n\t\ttransientEdits: { blocks: true },\n\t\tlabel: __( 'Widget areas' ),\n\t},\n\t{\n\t\tname: 'widget',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/widgets',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'widgets',\n\t\ttransientEdits: { blocks: true },\n\t\tlabel: __( 'Widgets' ),\n\t},\n\t{\n\t\tname: 'widgetType',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/widget-types',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'widgetTypes',\n\t\tlabel: __( 'Widget types' ),\n\t},\n\t{\n\t\tlabel: __( 'User' ),\n\t\tname: 'user',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/users',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'users',\n\t},\n\t{\n\t\tname: 'comment',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/comments',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'comments',\n\t\tlabel: __( 'Comment' ),\n\t},\n\t{\n\t\tname: 'menu',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menus',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menus',\n\t\tlabel: __( 'Menu' ),\n\t},\n\t{\n\t\tname: 'menuItem',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menu-items',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menuItems',\n\t\tlabel: __( 'Menu Item' ),\n\t\trawAttributes: [ 'title' ],\n\t},\n\t{\n\t\tname: 'menuLocation',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/menu-locations',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'menuLocations',\n\t\tlabel: __( 'Menu Location' ),\n\t\tkey: 'name',\n\t},\n\t{\n\t\tlabel: __( 'Global Styles' ),\n\t\tname: 'globalStyles',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/global-styles',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'globalStylesVariations', // Should be different from name.\n\t\tgetTitle: ( record ) => record?.title?.rendered || record?.title,\n\t\tgetRevisionsUrl: ( parentId, revisionId ) =>\n\t\t\t`/wp/v2/global-styles/${ parentId }/revisions${\n\t\t\t\trevisionId ? '/' + revisionId : ''\n\t\t\t}`,\n\t\tsupportsPagination: true,\n\t},\n\t{\n\t\tlabel: __( 'Themes' ),\n\t\tname: 'theme',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/themes',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tkey: 'stylesheet',\n\t},\n\t{\n\t\tlabel: __( 'Plugins' ),\n\t\tname: 'plugin',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/plugins',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tkey: 'plugin',\n\t},\n\t{\n\t\tlabel: __( 'Status' ),\n\t\tname: 'status',\n\t\tkind: 'root',\n\t\tbaseURL: '/wp/v2/statuses',\n\t\tbaseURLParams: { context: 'edit' },\n\t\tplural: 'statuses',\n\t\tkey: 'slug',\n\t},\n];\n\nexport const additionalEntityConfigLoaders = [\n\t{ kind: 'postType', loadEntities: loadPostTypeEntities },\n\t{ kind: 'taxonomy', loadEntities: loadTaxonomyEntities },\n];\n\n/**\n * Returns a function to be used to retrieve extra edits to apply before persisting a post type.\n *\n * @param {Object} persistedRecord Already persisted Post\n * @param {Object} edits Edits.\n * @return {Object} Updated edits.\n */\nexport const prePersistPostType = ( persistedRecord, edits ) => {\n\tconst newEdits = {};\n\n\tif ( persistedRecord?.status === 'auto-draft' ) {\n\t\t// Saving an auto-draft should create a draft by default.\n\t\tif ( ! edits.status && ! newEdits.status ) {\n\t\t\tnewEdits.status = 'draft';\n\t\t}\n\n\t\t// Fix the auto-draft default title.\n\t\tif (\n\t\t\t( ! edits.title || edits.title === 'Auto Draft' ) &&\n\t\t\t! newEdits.title &&\n\t\t\t( ! persistedRecord?.title ||\n\t\t\t\tpersistedRecord?.title === 'Auto Draft' )\n\t\t) {\n\t\t\tnewEdits.title = '';\n\t\t}\n\t}\n\n\treturn newEdits;\n};\n\nconst serialisableBlocksCache = new WeakMap();\n\nfunction makeBlockAttributesSerializable( attributes ) {\n\tconst newAttributes = { ...attributes };\n\tfor ( const [ key, value ] of Object.entries( attributes ) ) {\n\t\tif ( value instanceof RichTextData ) {\n\t\t\tnewAttributes[ key ] = value.valueOf();\n\t\t}\n\t}\n\treturn newAttributes;\n}\n\nfunction makeBlocksSerializable( blocks ) {\n\treturn blocks.map( ( block ) => {\n\t\tconst { innerBlocks, attributes, ...rest } = block;\n\t\treturn {\n\t\t\t...rest,\n\t\t\tattributes: makeBlockAttributesSerializable( attributes ),\n\t\t\tinnerBlocks: makeBlocksSerializable( innerBlocks ),\n\t\t};\n\t} );\n}\n\n/**\n * Returns the list of post type entities.\n *\n * @return {Promise} Entities promise\n */\nasync function loadPostTypeEntities() {\n\tconst postTypes = await apiFetch( {\n\t\tpath: '/wp/v2/types?context=view',\n\t} );\n\treturn Object.entries( postTypes ?? {} ).map( ( [ name, postType ] ) => {\n\t\tconst isTemplate = [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\tname\n\t\t);\n\t\tconst namespace = postType?.rest_namespace ?? 'wp/v2';\n\t\treturn {\n\t\t\tkind: 'postType',\n\t\t\tbaseURL: `/${ namespace }/${ postType.rest_base }`,\n\t\t\tbaseURLParams: { context: 'edit' },\n\t\t\tname,\n\t\t\tlabel: postType.name,\n\t\t\ttransientEdits: {\n\t\t\t\tblocks: true,\n\t\t\t\tselection: true,\n\t\t\t},\n\t\t\tmergedEdits: { meta: true },\n\t\t\trawAttributes: POST_RAW_ATTRIBUTES,\n\t\t\tgetTitle: ( record ) =>\n\t\t\t\trecord?.title?.rendered ||\n\t\t\t\trecord?.title ||\n\t\t\t\t( isTemplate\n\t\t\t\t\t? capitalCase( record.slug ?? '' )\n\t\t\t\t\t: String( record.id ) ),\n\t\t\t__unstablePrePersist: isTemplate ? undefined : prePersistPostType,\n\t\t\t__unstable_rest_base: postType.rest_base,\n\t\t\tsyncConfig: {\n\t\t\t\tfetch: async ( id ) => {\n\t\t\t\t\treturn apiFetch( {\n\t\t\t\t\t\tpath: `/${ namespace }/${ postType.rest_base }/${ id }?context=edit`,\n\t\t\t\t\t} );\n\t\t\t\t},\n\t\t\t\tapplyChangesToDoc: ( doc, changes ) => {\n\t\t\t\t\tconst document = doc.getMap( 'document' );\n\n\t\t\t\t\tObject.entries( changes ).forEach( ( [ key, value ] ) => {\n\t\t\t\t\t\tif ( typeof value !== 'function' ) {\n\t\t\t\t\t\t\tif ( key === 'blocks' ) {\n\t\t\t\t\t\t\t\tif ( ! serialisableBlocksCache.has( value ) ) {\n\t\t\t\t\t\t\t\t\tserialisableBlocksCache.set(\n\t\t\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t\t\t\tmakeBlocksSerializable( value )\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tvalue = serialisableBlocksCache.get( value );\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif ( document.get( key ) !== value ) {\n\t\t\t\t\t\t\t\tdocument.set( key, value );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t\t},\n\t\t\t\tfromCRDTDoc: ( doc ) => {\n\t\t\t\t\treturn doc.getMap( 'document' ).toJSON();\n\t\t\t\t},\n\t\t\t},\n\t\t\tsyncObjectType: 'postType/' + postType.name,\n\t\t\tgetSyncObjectId: ( id ) => id,\n\t\t\tsupportsPagination: true,\n\t\t\tgetRevisionsUrl: ( parentId, revisionId ) =>\n\t\t\t\t`/${ namespace }/${\n\t\t\t\t\tpostType.rest_base\n\t\t\t\t}/${ parentId }/revisions${\n\t\t\t\t\trevisionId ? '/' + revisionId : ''\n\t\t\t\t}`,\n\t\t\trevisionKey: isTemplate ? 'wp_id' : DEFAULT_ENTITY_KEY,\n\t\t};\n\t} );\n}\n\n/**\n * Returns the list of the taxonomies entities.\n *\n * @return {Promise} Entities promise\n */\nasync function loadTaxonomyEntities() {\n\tconst taxonomies = await apiFetch( {\n\t\tpath: '/wp/v2/taxonomies?context=view',\n\t} );\n\treturn Object.entries( taxonomies ?? {} ).map( ( [ name, taxonomy ] ) => {\n\t\tconst namespace = taxonomy?.rest_namespace ?? 'wp/v2';\n\t\treturn {\n\t\t\tkind: 'taxonomy',\n\t\t\tbaseURL: `/${ namespace }/${ taxonomy.rest_base }`,\n\t\t\tbaseURLParams: { context: 'edit' },\n\t\t\tname,\n\t\t\tlabel: taxonomy.name,\n\t\t};\n\t} );\n}\n\n/**\n * Returns the entity's getter method name given its kind and name.\n *\n * @example\n * ```js\n * const nameSingular = getMethodName( 'root', 'theme', 'get' );\n * // nameSingular is getRootTheme\n *\n * const namePlural = getMethodName( 'root', 'theme', 'set' );\n * // namePlural is setRootThemes\n * ```\n *\n * @param {string} kind Entity kind.\n * @param {string} name Entity name.\n * @param {string} prefix Function prefix.\n * @param {boolean} usePlural Whether to use the plural form or not.\n *\n * @return {string} Method name\n */\nexport const getMethodName = (\n\tkind,\n\tname,\n\tprefix = 'get',\n\tusePlural = false\n) => {\n\tconst entityConfig = rootEntitiesConfig.find(\n\t\t( config ) => config.kind === kind && config.name === name\n\t);\n\tconst kindPrefix = kind === 'root' ? '' : pascalCase( kind );\n\tconst nameSuffix = pascalCase( name ) + ( usePlural ? 's' : '' );\n\tconst suffix =\n\t\tusePlural && 'plural' in entityConfig && entityConfig?.plural\n\t\t\t? pascalCase( entityConfig.plural )\n\t\t\t: nameSuffix;\n\treturn `${ prefix }${ kindPrefix }${ suffix }`;\n};\n\nfunction registerSyncConfigs( configs ) {\n\tconfigs.forEach( ( { syncObjectType, syncConfig } ) => {\n\t\tgetSyncProvider().register( syncObjectType, syncConfig );\n\t\tconst editSyncConfig = { ...syncConfig };\n\t\tdelete editSyncConfig.fetch;\n\t\tgetSyncProvider().register( syncObjectType + '--edit', editSyncConfig );\n\t} );\n}\n\n/**\n * Loads the kind entities into the store.\n *\n * @param {string} kind Kind\n *\n * @return {(thunkArgs: object) => Promise<Array>} Entities\n */\nexport const getOrLoadEntitiesConfig =\n\t( kind ) =>\n\tasync ( { select, dispatch } ) => {\n\t\tlet configs = select.getEntitiesConfig( kind );\n\t\tif ( configs && configs.length !== 0 ) {\n\t\t\tif ( window.__experimentalEnableSync ) {\n\t\t\t\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t\t\t\tregisterSyncConfigs( configs );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn configs;\n\t\t}\n\n\t\tconst loader = additionalEntityConfigLoaders.find(\n\t\t\t( l ) => l.kind === kind\n\t\t);\n\t\tif ( ! loader ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconfigs = await loader.loadEntities();\n\t\tif ( window.__experimentalEnableSync ) {\n\t\t\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t\t\tregisterSyncConfigs( configs );\n\t\t\t}\n\t\t}\n\n\t\tdispatch( addEntities( configs ) );\n\n\t\treturn configs;\n\t};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,UAAU,QAAQ,aAAa;;AAErD;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,sBAAsB;AAC3C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,QAAQ,sBAAsB;;AAEnD;AACA;AACA;AACA,SAASC,WAAW,QAAQ,WAAW;AACvC,SAASC,eAAe,QAAQ,QAAQ;AAExC,OAAO,MAAMC,kBAAkB,GAAG,IAAI;AAEtC,MAAMC,mBAAmB,GAAG,CAAE,OAAO,EAAE,SAAS,EAAE,SAAS,CAAE;AAE7D,OAAO,MAAMC,kBAAkB,GAAG,CACjC;EACCC,KAAK,EAAEP,EAAE,CAAE,MAAO,CAAC;EACnBQ,IAAI,EAAE,MAAM;EACZC,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAE,GAAG;EACZC,aAAa,EAAE;IACdC,OAAO,EAAE,CACR,aAAa,EACb,YAAY,EACZ,MAAM,EACN,MAAM,EACN,WAAW,EACX,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,KAAK,CACL,CAACC,IAAI,CAAE,GAAI;EACb,CAAC;EACDC,UAAU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AM;EAAEC;AAAS,CAAC,KAAM;EACjC,IAAIL,OAAO,GAAGI,MAAM,CAACE,iBAAiB,CAAElG,IAAK,CAAC;EAC9C,IAAK4F,OAAO,IAAIA,OAAO,CAACO,MAAM,KAAK,CAAC,EAAG;IACtC,IAAKC,MAAM,CAACC,wBAAwB,EAAG;MACtC,IAAKC,OAAO,CAACC,GAAG,CAACC,mBAAmB,EAAG;QACtCb,mBAAmB,CAAEC,OAAQ,CAAC;MAC/B;IACD;IAEA,OAAOA,OAAO;EACf;EAEA,MAAMa,MAAM,GAAGjE,6BAA6B,CAAC8C,IAAI,CAC9CoB,CAAC,IAAMA,CAAC,CAAC1G,IAAI,KAAKA,IACrB,CAAC;EACD,IAAK,CAAEyG,MAAM,EAAG;IACf,OAAO,EAAE;EACV;EAEAb,OAAO,GAAG,MAAMa,MAAM,CAAChE,YAAY,CAAC,CAAC;EACrC,IAAK2D,MAAM,CAACC,wBAAwB,EAAG;IACtC,IAAKC,OAAO,CAACC,GAAG,CAACC,mBAAmB,EAAG;MACtCb,mBAAmB,CAAEC,OAAQ,CAAC;IAC/B;EACD;EAEAK,QAAQ,CAAEvG,WAAW,CAAEkG,OAAQ,CAAE,CAAC;EAElC,OAAOA,OAAO;AACf,CAAC"}
|
|
@@ -190,7 +190,8 @@ export function useEntityBlockEditor(kind, name, {
|
|
|
190
190
|
return __unstableCreateUndoLevel(kind, name, id);
|
|
191
191
|
}
|
|
192
192
|
const {
|
|
193
|
-
selection
|
|
193
|
+
selection,
|
|
194
|
+
...rest
|
|
194
195
|
} = options;
|
|
195
196
|
|
|
196
197
|
// We create a new function here on every persistent edit
|
|
@@ -204,12 +205,14 @@ export function useEntityBlockEditor(kind, name, {
|
|
|
204
205
|
...updateFootnotes(newBlocks)
|
|
205
206
|
};
|
|
206
207
|
editEntityRecord(kind, name, id, edits, {
|
|
207
|
-
isCached: false
|
|
208
|
+
isCached: false,
|
|
209
|
+
...rest
|
|
208
210
|
});
|
|
209
211
|
}, [kind, name, id, blocks, updateFootnotes, __unstableCreateUndoLevel, editEntityRecord]);
|
|
210
212
|
const onInput = useCallback((newBlocks, options) => {
|
|
211
213
|
const {
|
|
212
|
-
selection
|
|
214
|
+
selection,
|
|
215
|
+
...rest
|
|
213
216
|
} = options;
|
|
214
217
|
const footnotesChanges = updateFootnotes(newBlocks);
|
|
215
218
|
const edits = {
|
|
@@ -217,7 +220,8 @@ export function useEntityBlockEditor(kind, name, {
|
|
|
217
220
|
...footnotesChanges
|
|
218
221
|
};
|
|
219
222
|
editEntityRecord(kind, name, id, edits, {
|
|
220
|
-
isCached: true
|
|
223
|
+
isCached: true,
|
|
224
|
+
...rest
|
|
221
225
|
});
|
|
222
226
|
}, [kind, name, id, updateFootnotes, editEntityRecord]);
|
|
223
227
|
return [blocks, onInput, onChange];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","useContext","useCallback","useMemo","useSelect","useDispatch","parse","__unstableSerializeAndClean","STORE_NAME","updateFootnotesFromMeta","EMPTY_ARRAY","rootEntitiesConfig","additionalEntityConfigLoaders","entityContexts","reduce","acc","loader","kind","name","context","undefined","getEntityContext","Error","EntityProvider","type","id","children","Provider","createElement","value","useEntityId","useEntityProp","prop","_id","providerId","fullValue","select","getEntityRecord","getEditedEntityRecord","record","editedRecord","editEntityRecord","setValue","newValue","useEntityBlockEditor","content","editedBlocks","meta","blocks","__unstableCreateUndoLevel","updateFootnotes","_blocks","onChange","newBlocks","options","noChange","selection","edits","blocksForSerialization","isCached","onInput","footnotesChanges"],"sources":["@wordpress/core-data/src/entity-provider.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseCallback,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { updateFootnotesFromMeta } from './footnotes';\n\n/** @typedef {import('@wordpress/blocks').WPBlock} WPBlock */\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Internal dependencies\n */\nimport { rootEntitiesConfig, additionalEntityConfigLoaders } from './entities';\n\nconst entityContexts = {\n\t...rootEntitiesConfig.reduce( ( acc, loader ) => {\n\t\tif ( ! acc[ loader.kind ] ) {\n\t\t\tacc[ loader.kind ] = {};\n\t\t}\n\t\tacc[ loader.kind ][ loader.name ] = {\n\t\t\tcontext: createContext( undefined ),\n\t\t};\n\t\treturn acc;\n\t}, {} ),\n\t...additionalEntityConfigLoaders.reduce( ( acc, loader ) => {\n\t\tacc[ loader.kind ] = {};\n\t\treturn acc;\n\t}, {} ),\n};\nconst getEntityContext = ( kind, name ) => {\n\tif ( ! entityContexts[ kind ] ) {\n\t\tthrow new Error( `Missing entity config for kind: ${ kind }.` );\n\t}\n\n\tif ( ! entityContexts[ kind ][ name ] ) {\n\t\tentityContexts[ kind ][ name ] = {\n\t\t\tcontext: createContext( undefined ),\n\t\t};\n\t}\n\n\treturn entityContexts[ kind ][ name ].context;\n};\n\n/**\n * Context provider component for providing\n * an entity for a specific entity.\n *\n * @param {Object} props The component's props.\n * @param {string} props.kind The entity kind.\n * @param {string} props.type The entity name.\n * @param {number} props.id The entity ID.\n * @param {*} props.children The children to wrap.\n *\n * @return {Object} The provided children, wrapped with\n * the entity's context provider.\n */\nexport default function EntityProvider( { kind, type: name, id, children } ) {\n\tconst Provider = getEntityContext( kind, name ).Provider;\n\treturn <Provider value={ id }>{ children }</Provider>;\n}\n\n/**\n * Hook that returns the ID for the nearest\n * provided entity of the specified type.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n */\nexport function useEntityId( kind, name ) {\n\treturn useContext( getEntityContext( kind, name ) );\n}\n\n/**\n * Hook that returns the value and a setter for the\n * specified property of the nearest provided\n * entity of the specified type.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n * @param {string} prop The property name.\n * @param {string} [_id] An entity ID to use instead of the context-provided one.\n *\n * @return {[*, Function, *]} An array where the first item is the\n * property value, the second is the\n * setter and the third is the full value\n * \t\t\t\t\t\t\t object from REST API containing more\n * \t\t\t\t\t\t\t information like `raw`, `rendered` and\n * \t\t\t\t\t\t\t `protected` props.\n */\nexport function useEntityProp( kind, name, prop, _id ) {\n\tconst providerId = useEntityId( kind, name );\n\tconst id = _id ?? providerId;\n\n\tconst { value, fullValue } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getEditedEntityRecord } =\n\t\t\t\tselect( STORE_NAME );\n\t\t\tconst record = getEntityRecord( kind, name, id ); // Trigger resolver.\n\t\t\tconst editedRecord = getEditedEntityRecord( kind, name, id );\n\t\t\treturn record && editedRecord\n\t\t\t\t? {\n\t\t\t\t\t\tvalue: editedRecord[ prop ],\n\t\t\t\t\t\tfullValue: record[ prop ],\n\t\t\t\t }\n\t\t\t\t: {};\n\t\t},\n\t\t[ kind, name, id, prop ]\n\t);\n\tconst { editEntityRecord } = useDispatch( STORE_NAME );\n\tconst setValue = useCallback(\n\t\t( newValue ) => {\n\t\t\teditEntityRecord( kind, name, id, {\n\t\t\t\t[ prop ]: newValue,\n\t\t\t} );\n\t\t},\n\t\t[ editEntityRecord, kind, name, id, prop ]\n\t);\n\n\treturn [ value, setValue, fullValue ];\n}\n\n/**\n * Hook that returns block content getters and setters for\n * the nearest provided entity of the specified type.\n *\n * The return value has the shape `[ blocks, onInput, onChange ]`.\n * `onInput` is for block changes that don't create undo levels\n * or dirty the post, non-persistent changes, and `onChange` is for\n * persistent changes. They map directly to the props of a\n * `BlockEditorProvider` and are intended to be used with it,\n * or similar components or hooks.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n * @param {Object} options\n * @param {string} [options.id] An entity ID to use instead of the context-provided one.\n *\n * @return {[WPBlock[], Function, Function]} The block array and setters.\n */\nexport function useEntityBlockEditor( kind, name, { id: _id } = {} ) {\n\tconst providerId = useEntityId( kind, name );\n\tconst id = _id ?? providerId;\n\tconst { content, editedBlocks, meta } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! id ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst { getEditedEntityRecord } = select( STORE_NAME );\n\t\t\tconst editedRecord = getEditedEntityRecord( kind, name, id );\n\t\t\treturn {\n\t\t\t\teditedBlocks: editedRecord.blocks,\n\t\t\t\tcontent: editedRecord.content,\n\t\t\t\tmeta: editedRecord.meta,\n\t\t\t};\n\t\t},\n\t\t[ kind, name, id ]\n\t);\n\tconst { __unstableCreateUndoLevel, editEntityRecord } =\n\t\tuseDispatch( STORE_NAME );\n\n\tconst blocks = useMemo( () => {\n\t\tif ( ! id ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif ( editedBlocks ) {\n\t\t\treturn editedBlocks;\n\t\t}\n\n\t\treturn content && typeof content !== 'function'\n\t\t\t? parse( content )\n\t\t\t: EMPTY_ARRAY;\n\t}, [ id, editedBlocks, content ] );\n\n\tconst updateFootnotes = useCallback(\n\t\t( _blocks ) => updateFootnotesFromMeta( _blocks, meta ),\n\t\t[ meta ]\n\t);\n\n\tconst onChange = useCallback(\n\t\t( newBlocks, options ) => {\n\t\t\tconst noChange = blocks === newBlocks;\n\t\t\tif ( noChange ) {\n\t\t\t\treturn __unstableCreateUndoLevel( kind, name, id );\n\t\t\t}\n\t\t\tconst { selection } = options;\n\n\t\t\t// We create a new function here on every persistent edit\n\t\t\t// to make sure the edit makes the post dirty and creates\n\t\t\t// a new undo level.\n\t\t\tconst edits = {\n\t\t\t\tselection,\n\t\t\t\tcontent: ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t\t\t__unstableSerializeAndClean( blocksForSerialization ),\n\t\t\t\t...updateFootnotes( newBlocks ),\n\t\t\t};\n\n\t\t\teditEntityRecord( kind, name, id, edits, { isCached: false } );\n\t\t},\n\t\t[\n\t\t\tkind,\n\t\t\tname,\n\t\t\tid,\n\t\t\tblocks,\n\t\t\tupdateFootnotes,\n\t\t\t__unstableCreateUndoLevel,\n\t\t\teditEntityRecord,\n\t\t]\n\t);\n\n\tconst onInput = useCallback(\n\t\t( newBlocks, options ) => {\n\t\t\tconst { selection } = options;\n\t\t\tconst footnotesChanges = updateFootnotes( newBlocks );\n\t\t\tconst edits = { selection, ...footnotesChanges };\n\n\t\t\teditEntityRecord( kind, name, id, edits, { isCached: true } );\n\t\t},\n\t\t[ kind, name, id, updateFootnotes, editEntityRecord ]\n\t);\n\n\treturn [ blocks, onInput, onChange ];\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,UAAU,EACVC,WAAW,EACXC,OAAO,QACD,oBAAoB;AAC3B,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,EAAEC,2BAA2B,QAAQ,mBAAmB;;AAEtE;AACA;AACA;AACA,SAASC,UAAU,QAAQ,QAAQ;AACnC,SAASC,uBAAuB,QAAQ,aAAa;;AAErD;;AAEA,MAAMC,WAAW,GAAG,EAAE;;AAEtB;AACA;AACA;AACA,SAASC,kBAAkB,EAAEC,6BAA6B,QAAQ,YAAY;AAE9E,MAAMC,cAAc,GAAG;EACtB,GAAGF,kBAAkB,CAACG,MAAM,CAAE,CAAEC,GAAG,EAAEC,MAAM,KAAM;IAChD,IAAK,CAAED,GAAG,CAAEC,MAAM,CAACC,IAAI,CAAE,EAAG;MAC3BF,GAAG,CAAEC,MAAM,CAACC,IAAI,CAAE,GAAG,CAAC,CAAC;IACxB;IACAF,GAAG,CAAEC,MAAM,CAACC,IAAI,CAAE,CAAED,MAAM,CAACE,IAAI,CAAE,GAAG;MACnCC,OAAO,EAAEnB,aAAa,CAAEoB,SAAU;IACnC,CAAC;IACD,OAAOL,GAAG;EACX,CAAC,EAAE,CAAC,CAAE,CAAC;EACP,GAAGH,6BAA6B,CAACE,MAAM,CAAE,CAAEC,GAAG,EAAEC,MAAM,KAAM;IAC3DD,GAAG,CAAEC,MAAM,CAACC,IAAI,CAAE,GAAG,CAAC,CAAC;IACv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,"names":["createContext","useContext","useCallback","useMemo","useSelect","useDispatch","parse","__unstableSerializeAndClean","STORE_NAME","updateFootnotesFromMeta","EMPTY_ARRAY","rootEntitiesConfig","additionalEntityConfigLoaders","entityContexts","reduce","acc","loader","kind","name","context","undefined","getEntityContext","Error","EntityProvider","type","id","children","Provider","createElement","value","useEntityId","useEntityProp","prop","_id","providerId","fullValue","select","getEntityRecord","getEditedEntityRecord","record","editedRecord","editEntityRecord","setValue","newValue","useEntityBlockEditor","content","editedBlocks","meta","blocks","__unstableCreateUndoLevel","updateFootnotes","_blocks","onChange","newBlocks","options","noChange","selection","rest","edits","blocksForSerialization","isCached","onInput","footnotesChanges"],"sources":["@wordpress/core-data/src/entity-provider.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcreateContext,\n\tuseContext,\n\tuseCallback,\n\tuseMemo,\n} from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { updateFootnotesFromMeta } from './footnotes';\n\n/** @typedef {import('@wordpress/blocks').WPBlock} WPBlock */\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Internal dependencies\n */\nimport { rootEntitiesConfig, additionalEntityConfigLoaders } from './entities';\n\nconst entityContexts = {\n\t...rootEntitiesConfig.reduce( ( acc, loader ) => {\n\t\tif ( ! acc[ loader.kind ] ) {\n\t\t\tacc[ loader.kind ] = {};\n\t\t}\n\t\tacc[ loader.kind ][ loader.name ] = {\n\t\t\tcontext: createContext( undefined ),\n\t\t};\n\t\treturn acc;\n\t}, {} ),\n\t...additionalEntityConfigLoaders.reduce( ( acc, loader ) => {\n\t\tacc[ loader.kind ] = {};\n\t\treturn acc;\n\t}, {} ),\n};\nconst getEntityContext = ( kind, name ) => {\n\tif ( ! entityContexts[ kind ] ) {\n\t\tthrow new Error( `Missing entity config for kind: ${ kind }.` );\n\t}\n\n\tif ( ! entityContexts[ kind ][ name ] ) {\n\t\tentityContexts[ kind ][ name ] = {\n\t\t\tcontext: createContext( undefined ),\n\t\t};\n\t}\n\n\treturn entityContexts[ kind ][ name ].context;\n};\n\n/**\n * Context provider component for providing\n * an entity for a specific entity.\n *\n * @param {Object} props The component's props.\n * @param {string} props.kind The entity kind.\n * @param {string} props.type The entity name.\n * @param {number} props.id The entity ID.\n * @param {*} props.children The children to wrap.\n *\n * @return {Object} The provided children, wrapped with\n * the entity's context provider.\n */\nexport default function EntityProvider( { kind, type: name, id, children } ) {\n\tconst Provider = getEntityContext( kind, name ).Provider;\n\treturn <Provider value={ id }>{ children }</Provider>;\n}\n\n/**\n * Hook that returns the ID for the nearest\n * provided entity of the specified type.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n */\nexport function useEntityId( kind, name ) {\n\treturn useContext( getEntityContext( kind, name ) );\n}\n\n/**\n * Hook that returns the value and a setter for the\n * specified property of the nearest provided\n * entity of the specified type.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n * @param {string} prop The property name.\n * @param {string} [_id] An entity ID to use instead of the context-provided one.\n *\n * @return {[*, Function, *]} An array where the first item is the\n * property value, the second is the\n * setter and the third is the full value\n * \t\t\t\t\t\t\t object from REST API containing more\n * \t\t\t\t\t\t\t information like `raw`, `rendered` and\n * \t\t\t\t\t\t\t `protected` props.\n */\nexport function useEntityProp( kind, name, prop, _id ) {\n\tconst providerId = useEntityId( kind, name );\n\tconst id = _id ?? providerId;\n\n\tconst { value, fullValue } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord, getEditedEntityRecord } =\n\t\t\t\tselect( STORE_NAME );\n\t\t\tconst record = getEntityRecord( kind, name, id ); // Trigger resolver.\n\t\t\tconst editedRecord = getEditedEntityRecord( kind, name, id );\n\t\t\treturn record && editedRecord\n\t\t\t\t? {\n\t\t\t\t\t\tvalue: editedRecord[ prop ],\n\t\t\t\t\t\tfullValue: record[ prop ],\n\t\t\t\t }\n\t\t\t\t: {};\n\t\t},\n\t\t[ kind, name, id, prop ]\n\t);\n\tconst { editEntityRecord } = useDispatch( STORE_NAME );\n\tconst setValue = useCallback(\n\t\t( newValue ) => {\n\t\t\teditEntityRecord( kind, name, id, {\n\t\t\t\t[ prop ]: newValue,\n\t\t\t} );\n\t\t},\n\t\t[ editEntityRecord, kind, name, id, prop ]\n\t);\n\n\treturn [ value, setValue, fullValue ];\n}\n\n/**\n * Hook that returns block content getters and setters for\n * the nearest provided entity of the specified type.\n *\n * The return value has the shape `[ blocks, onInput, onChange ]`.\n * `onInput` is for block changes that don't create undo levels\n * or dirty the post, non-persistent changes, and `onChange` is for\n * persistent changes. They map directly to the props of a\n * `BlockEditorProvider` and are intended to be used with it,\n * or similar components or hooks.\n *\n * @param {string} kind The entity kind.\n * @param {string} name The entity name.\n * @param {Object} options\n * @param {string} [options.id] An entity ID to use instead of the context-provided one.\n *\n * @return {[WPBlock[], Function, Function]} The block array and setters.\n */\nexport function useEntityBlockEditor( kind, name, { id: _id } = {} ) {\n\tconst providerId = useEntityId( kind, name );\n\tconst id = _id ?? providerId;\n\tconst { content, editedBlocks, meta } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! id ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst { getEditedEntityRecord } = select( STORE_NAME );\n\t\t\tconst editedRecord = getEditedEntityRecord( kind, name, id );\n\t\t\treturn {\n\t\t\t\teditedBlocks: editedRecord.blocks,\n\t\t\t\tcontent: editedRecord.content,\n\t\t\t\tmeta: editedRecord.meta,\n\t\t\t};\n\t\t},\n\t\t[ kind, name, id ]\n\t);\n\tconst { __unstableCreateUndoLevel, editEntityRecord } =\n\t\tuseDispatch( STORE_NAME );\n\n\tconst blocks = useMemo( () => {\n\t\tif ( ! id ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif ( editedBlocks ) {\n\t\t\treturn editedBlocks;\n\t\t}\n\n\t\treturn content && typeof content !== 'function'\n\t\t\t? parse( content )\n\t\t\t: EMPTY_ARRAY;\n\t}, [ id, editedBlocks, content ] );\n\n\tconst updateFootnotes = useCallback(\n\t\t( _blocks ) => updateFootnotesFromMeta( _blocks, meta ),\n\t\t[ meta ]\n\t);\n\n\tconst onChange = useCallback(\n\t\t( newBlocks, options ) => {\n\t\t\tconst noChange = blocks === newBlocks;\n\t\t\tif ( noChange ) {\n\t\t\t\treturn __unstableCreateUndoLevel( kind, name, id );\n\t\t\t}\n\t\t\tconst { selection, ...rest } = options;\n\n\t\t\t// We create a new function here on every persistent edit\n\t\t\t// to make sure the edit makes the post dirty and creates\n\t\t\t// a new undo level.\n\t\t\tconst edits = {\n\t\t\t\tselection,\n\t\t\t\tcontent: ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t\t\t__unstableSerializeAndClean( blocksForSerialization ),\n\t\t\t\t...updateFootnotes( newBlocks ),\n\t\t\t};\n\n\t\t\teditEntityRecord( kind, name, id, edits, {\n\t\t\t\tisCached: false,\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t},\n\t\t[\n\t\t\tkind,\n\t\t\tname,\n\t\t\tid,\n\t\t\tblocks,\n\t\t\tupdateFootnotes,\n\t\t\t__unstableCreateUndoLevel,\n\t\t\teditEntityRecord,\n\t\t]\n\t);\n\n\tconst onInput = useCallback(\n\t\t( newBlocks, options ) => {\n\t\t\tconst { selection, ...rest } = options;\n\t\t\tconst footnotesChanges = updateFootnotes( newBlocks );\n\t\t\tconst edits = { selection, ...footnotesChanges };\n\n\t\t\teditEntityRecord( kind, name, id, edits, {\n\t\t\t\tisCached: true,\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t},\n\t\t[ kind, name, id, updateFootnotes, editEntityRecord ]\n\t);\n\n\treturn [ blocks, onInput, onChange ];\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,UAAU,EACVC,WAAW,EACXC,OAAO,QACD,oBAAoB;AAC3B,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AAC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,eAAe,CAAEG,SAAU;IAC/B,CAAC;IAEDZ,gBAAgB,CAAExB,IAAI,EAAEC,IAAI,EAAEO,EAAE,EAAEiC,KAAK,EAAE;MACxCE,QAAQ,EAAE,KAAK;MACf,GAAGH;IACJ,CAAE,CAAC;EACJ,CAAC,EACD,CACCxC,IAAI,EACJC,IAAI,EACJO,EAAE,EACFuB,MAAM,EACNE,eAAe,EACfD,yBAAyB,EACzBR,gBAAgB,CAElB,CAAC;EAED,MAAMoB,OAAO,GAAG3D,WAAW,CAC1B,CAAEmD,SAAS,EAAEC,OAAO,KAAM;IACzB,MAAM;MAAEE,SAAS;MAAE,GAAGC;IAAK,CAAC,GAAGH,OAAO;IACtC,MAAMQ,gBAAgB,GAAGZ,eAAe,CAAEG,SAAU,CAAC;IACrD,MAAMK,KAAK,GAAG;MAAEF,SAAS;MAAE,GAAGM;IAAiB,CAAC;IAEhDrB,gBAAgB,CAAExB,IAAI,EAAEC,IAAI,EAAEO,EAAE,EAAEiC,KAAK,EAAE;MACxCE,QAAQ,EAAE,IAAI;MACd,GAAGH;IACJ,CAAE,CAAC;EACJ,CAAC,EACD,CAAExC,IAAI,EAAEC,IAAI,EAAEO,EAAE,EAAEyB,eAAe,EAAET,gBAAgB,CACpD,CAAC;EAED,OAAO,CAAEO,MAAM,EAAEa,OAAO,EAAET,QAAQ,CAAE;AACrC"}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { create } from '@wordpress/rich-text';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* Internal dependencies
|
|
8
3
|
*/
|
|
@@ -12,14 +7,12 @@ function getBlockFootnotesOrder(block) {
|
|
|
12
7
|
if (!cache.has(block)) {
|
|
13
8
|
const order = [];
|
|
14
9
|
for (const value of getRichTextValuesCached(block)) {
|
|
15
|
-
if (!value
|
|
10
|
+
if (!value) {
|
|
16
11
|
continue;
|
|
17
12
|
}
|
|
18
13
|
|
|
19
14
|
// replacements is a sparse array, use forEach to skip empty slots.
|
|
20
|
-
|
|
21
|
-
html: value
|
|
22
|
-
}).replacements.forEach(({
|
|
15
|
+
value.replacements.forEach(({
|
|
23
16
|
type,
|
|
24
17
|
attributes
|
|
25
18
|
}) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["getRichTextValuesCached","cache","WeakMap","getBlockFootnotesOrder","block","has","order","value","replacements","forEach","type","attributes","push","set","get","getFootnotesOrder","blocks","flatMap"],"sources":["@wordpress/core-data/src/footnotes/get-footnotes-order.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport getRichTextValuesCached from './get-rich-text-values-cached';\n\nconst cache = new WeakMap();\n\nfunction getBlockFootnotesOrder( block ) {\n\tif ( ! cache.has( block ) ) {\n\t\tconst order = [];\n\t\tfor ( const value of getRichTextValuesCached( block ) ) {\n\t\t\tif ( ! value ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// replacements is a sparse array, use forEach to skip empty slots.\n\t\t\tvalue.replacements.forEach( ( { type, attributes } ) => {\n\t\t\t\tif ( type === 'core/footnote' ) {\n\t\t\t\t\torder.push( attributes[ 'data-fn' ] );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t\tcache.set( block, order );\n\t}\n\n\treturn cache.get( block );\n}\n\nexport default function getFootnotesOrder( blocks ) {\n\t// We can only separate getting order from blocks at the root level. For\n\t// deeper inner blocks, this will not work since it's possible to have both\n\t// inner blocks and block attributes, so order needs to be computed from the\n\t// Edit functions as a whole.\n\treturn blocks.flatMap( getBlockFootnotesOrder );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,uBAAuB,MAAM,+BAA+B;AAEnE,MAAMC,KAAK,GAAG,IAAIC,OAAO,CAAC,CAAC;AAE3B,SAASC,sBAAsBA,CAAEC,KAAK,EAAG;EACxC,IAAK,CAAEH,KAAK,CAACI,GAAG,CAAED,KAAM,CAAC,EAAG;IAC3B,MAAME,KAAK,GAAG,EAAE;IAChB,KAAM,MAAMC,KAAK,IAAIP,uBAAuB,CAAEI,KAAM,CAAC,EAAG;MACvD,IAAK,CAAEG,KAAK,EAAG;QACd;MACD;;MAEA;MACAA,KAAK,CAACC,YAAY,CAACC,OAAO,CAAE,CAAE;QAAEC,IAAI;QAAEC;MAAW,CAAC,KAAM;QACvD,IAAKD,IAAI,KAAK,eAAe,EAAG;UAC/BJ,KAAK,CAACM,IAAI,CAAED,UAAU,CAAE,SAAS,CAAG,CAAC;QACtC;MACD,CAAE,CAAC;IACJ;IACAV,KAAK,CAACY,GAAG,CAAET,KAAK,EAAEE,KAAM,CAAC;EAC1B;EAEA,OAAOL,KAAK,CAACa,GAAG,CAAEV,KAAM,CAAC;AAC1B;AAEA,eAAe,SAASW,iBAAiBA,CAAEC,MAAM,EAAG;EACnD;EACA;EACA;EACA;EACA,OAAOA,MAAM,CAACC,OAAO,CAAEd,sBAAuB,CAAC;AAChD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { create, toHTMLString } from '@wordpress/rich-text';
|
|
4
|
+
import { RichTextData, create, toHTMLString } from '@wordpress/rich-text';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -38,15 +38,12 @@ export function updateFootnotesFromMeta(blocks, meta) {
|
|
|
38
38
|
attributes[key] = value.map(updateAttributes);
|
|
39
39
|
continue;
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (value.indexOf('data-fn') === -1) {
|
|
41
|
+
|
|
42
|
+
// To do, remove support for string values?
|
|
43
|
+
if (typeof value !== 'string' && !(value instanceof RichTextData)) {
|
|
45
44
|
continue;
|
|
46
45
|
}
|
|
47
|
-
const richTextValue =
|
|
48
|
-
html: value
|
|
49
|
-
});
|
|
46
|
+
const richTextValue = typeof value === 'string' ? RichTextData.fromHTMLString(value) : value;
|
|
50
47
|
richTextValue.replacements.forEach(replacement => {
|
|
51
48
|
if (replacement.type === 'core/footnote') {
|
|
52
49
|
const id = replacement.attributes['data-fn'];
|
|
@@ -56,14 +53,18 @@ export function updateFootnotesFromMeta(blocks, meta) {
|
|
|
56
53
|
html: replacement.innerHTML
|
|
57
54
|
});
|
|
58
55
|
countValue.text = String(index + 1);
|
|
56
|
+
countValue.formats = Array.from({
|
|
57
|
+
length: countValue.text.length
|
|
58
|
+
}, () => countValue.formats[0]);
|
|
59
|
+
countValue.replacements = Array.from({
|
|
60
|
+
length: countValue.text.length
|
|
61
|
+
}, () => countValue.replacements[0]);
|
|
59
62
|
replacement.innerHTML = toHTMLString({
|
|
60
63
|
value: countValue
|
|
61
64
|
});
|
|
62
65
|
}
|
|
63
66
|
});
|
|
64
|
-
attributes[key] = toHTMLString(
|
|
65
|
-
value: richTextValue
|
|
66
|
-
});
|
|
67
|
+
attributes[key] = typeof value === 'string' ? richTextValue.toHTMLString() : richTextValue;
|
|
67
68
|
}
|
|
68
69
|
return attributes;
|
|
69
70
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["create","toHTMLString","getFootnotesOrder","oldFootnotes","updateFootnotesFromMeta","blocks","meta","output","footnotes","undefined","newOrder","JSON","parse","currentOrder","map","fn","id","join","newFootnotes","fnId","find","content","updateAttributes","attributes","Array","isArray","key","value","
|
|
1
|
+
{"version":3,"names":["RichTextData","create","toHTMLString","getFootnotesOrder","oldFootnotes","updateFootnotesFromMeta","blocks","meta","output","footnotes","undefined","newOrder","JSON","parse","currentOrder","map","fn","id","join","newFootnotes","fnId","find","content","updateAttributes","attributes","Array","isArray","key","value","richTextValue","fromHTMLString","replacements","forEach","replacement","type","index","indexOf","countValue","html","innerHTML","text","String","formats","from","length","updateBlocksAttributes","__blocks","block","innerBlocks","newBlocks","reduce","acc","includes","stringify"],"sources":["@wordpress/core-data/src/footnotes/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { RichTextData, create, toHTMLString } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport getFootnotesOrder from './get-footnotes-order';\n\nlet oldFootnotes = {};\n\nexport function updateFootnotesFromMeta( blocks, meta ) {\n\tconst output = { blocks };\n\tif ( ! meta ) return output;\n\n\t// If meta.footnotes is empty, it means the meta is not registered.\n\tif ( meta.footnotes === undefined ) return output;\n\n\tconst newOrder = getFootnotesOrder( blocks );\n\n\tconst footnotes = meta.footnotes ? JSON.parse( meta.footnotes ) : [];\n\tconst currentOrder = footnotes.map( ( fn ) => fn.id );\n\n\tif ( currentOrder.join( '' ) === newOrder.join( '' ) ) return output;\n\n\tconst newFootnotes = newOrder.map(\n\t\t( fnId ) =>\n\t\t\tfootnotes.find( ( fn ) => fn.id === fnId ) ||\n\t\t\toldFootnotes[ fnId ] || {\n\t\t\t\tid: fnId,\n\t\t\t\tcontent: '',\n\t\t\t}\n\t);\n\n\tfunction updateAttributes( attributes ) {\n\t\t// Only attempt to update attributes, if attributes is an object.\n\t\tif (\n\t\t\t! attributes ||\n\t\t\tArray.isArray( attributes ) ||\n\t\t\ttypeof attributes !== 'object'\n\t\t) {\n\t\t\treturn attributes;\n\t\t}\n\n\t\tattributes = { ...attributes };\n\n\t\tfor ( const key in attributes ) {\n\t\t\tconst value = attributes[ key ];\n\n\t\t\tif ( Array.isArray( value ) ) {\n\t\t\t\tattributes[ key ] = value.map( updateAttributes );\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// To do, remove support for string values?\n\t\t\tif (\n\t\t\t\ttypeof value !== 'string' &&\n\t\t\t\t! ( value instanceof RichTextData )\n\t\t\t) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst richTextValue =\n\t\t\t\ttypeof value === 'string'\n\t\t\t\t\t? RichTextData.fromHTMLString( value )\n\t\t\t\t\t: value;\n\n\t\t\trichTextValue.replacements.forEach( ( replacement ) => {\n\t\t\t\tif ( replacement.type === 'core/footnote' ) {\n\t\t\t\t\tconst id = replacement.attributes[ 'data-fn' ];\n\t\t\t\t\tconst index = newOrder.indexOf( id );\n\t\t\t\t\t// The innerHTML contains the count wrapped in a link.\n\t\t\t\t\tconst countValue = create( {\n\t\t\t\t\t\thtml: replacement.innerHTML,\n\t\t\t\t\t} );\n\t\t\t\t\tcountValue.text = String( index + 1 );\n\t\t\t\t\tcountValue.formats = Array.from(\n\t\t\t\t\t\t{ length: countValue.text.length },\n\t\t\t\t\t\t() => countValue.formats[ 0 ]\n\t\t\t\t\t);\n\t\t\t\t\tcountValue.replacements = Array.from(\n\t\t\t\t\t\t{ length: countValue.text.length },\n\t\t\t\t\t\t() => countValue.replacements[ 0 ]\n\t\t\t\t\t);\n\t\t\t\t\treplacement.innerHTML = toHTMLString( {\n\t\t\t\t\t\tvalue: countValue,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\tattributes[ key ] =\n\t\t\t\ttypeof value === 'string'\n\t\t\t\t\t? richTextValue.toHTMLString()\n\t\t\t\t\t: richTextValue;\n\t\t}\n\n\t\treturn attributes;\n\t}\n\n\tfunction updateBlocksAttributes( __blocks ) {\n\t\treturn __blocks.map( ( block ) => {\n\t\t\treturn {\n\t\t\t\t...block,\n\t\t\t\tattributes: updateAttributes( block.attributes ),\n\t\t\t\tinnerBlocks: updateBlocksAttributes( block.innerBlocks ),\n\t\t\t};\n\t\t} );\n\t}\n\n\t// We need to go through all block attributes deeply and update the\n\t// footnote anchor numbering (textContent) to match the new order.\n\tconst newBlocks = updateBlocksAttributes( blocks );\n\n\toldFootnotes = {\n\t\t...oldFootnotes,\n\t\t...footnotes.reduce( ( acc, fn ) => {\n\t\t\tif ( ! newOrder.includes( fn.id ) ) {\n\t\t\t\tacc[ fn.id ] = fn;\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, {} ),\n\t};\n\n\treturn {\n\t\tmeta: {\n\t\t\t...meta,\n\t\t\tfootnotes: JSON.stringify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AACN,YAAY,CAAE,CAAC,CACjC,CAAC;UACDE,WAAW,CAACM,SAAS,GAAGrC,YAAY,CAAE;YACrC0B,KAAK,EAAES;UACR,CAAE,CAAC;QACJ;MACD,CAAE,CAAC;MAEHb,UAAU,CAAEG,GAAG,CAAE,GAChB,OAAOC,KAAK,KAAK,QAAQ,GACtBC,aAAa,CAAC3B,YAAY,CAAC,CAAC,GAC5B2B,aAAa;IAClB;IAEA,OAAOL,UAAU;EAClB;EAEA,SAASqB,sBAAsBA,CAAEC,QAAQ,EAAG;IAC3C,OAAOA,QAAQ,CAAC/B,GAAG,CAAIgC,KAAK,IAAM;MACjC,OAAO;QACN,GAAGA,KAAK;QACRvB,UAAU,EAAED,gBAAgB,CAAEwB,KAAK,CAACvB,UAAW,CAAC;QAChDwB,WAAW,EAAEH,sBAAsB,CAAEE,KAAK,CAACC,WAAY;MACxD,CAAC;IACF,CAAE,CAAC;EACJ;;EAEA;EACA;EACA,MAAMC,SAAS,GAAGJ,sBAAsB,CAAEvC,MAAO,CAAC;EAElDF,YAAY,GAAG;IACd,GAAGA,YAAY;IACf,GAAGK,SAAS,CAACyC,MAAM,CAAE,CAAEC,GAAG,EAAEnC,EAAE,KAAM;MACnC,IAAK,CAAEL,QAAQ,CAACyC,QAAQ,CAAEpC,EAAE,CAACC,EAAG,CAAC,EAAG;QACnCkC,GAAG,CAAEnC,EAAE,CAACC,EAAE,CAAE,GAAGD,EAAE;MAClB;MACA,OAAOmC,GAAG;IACX,CAAC,EAAE,CAAC,CAAE;EACP,CAAC;EAED,OAAO;IACN5C,IAAI,EAAE;MACL,GAAGA,IAAI;MACPE,SAAS,EAAEG,IAAI,CAACyC,SAAS,CAAElC,YAAa;IACzC,CAAC;IACDb,MAAM,EAAE2C;EACT,CAAC;AACF"}
|
package/build-module/index.js
CHANGED
|
@@ -46,8 +46,8 @@ const entityActions = rootEntitiesConfig.reduce((result, entity) => {
|
|
|
46
46
|
kind,
|
|
47
47
|
name
|
|
48
48
|
} = entity;
|
|
49
|
-
result[getMethodName(kind, name, 'save')] =
|
|
50
|
-
result[getMethodName(kind, name, 'delete')] = (key, query) => actions.deleteEntityRecord(kind, name, key, query);
|
|
49
|
+
result[getMethodName(kind, name, 'save')] = (record, options) => actions.saveEntityRecord(kind, name, record, options);
|
|
50
|
+
result[getMethodName(kind, name, 'delete')] = (key, query, options) => actions.deleteEntityRecord(kind, name, key, query, options);
|
|
51
51
|
return result;
|
|
52
52
|
}, {});
|
|
53
53
|
const storeConfig = () => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createReduxStore","register","reducer","selectors","privateSelectors","actions","resolvers","createLocksActions","rootEntitiesConfig","getMethodName","STORE_NAME","unlock","entitySelectors","reduce","result","entity","kind","name","state","key","query","getEntityRecord","getEntityRecords","entityResolvers","pluralMethodName","args","shouldInvalidate","action","entityActions","saveEntityRecord","deleteEntityRecord","storeConfig","store","registerPrivateSelectors","default","EntityProvider"],"sources":["@wordpress/core-data/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as privateSelectors from './private-selectors';\nimport * as actions from './actions';\nimport * as resolvers from './resolvers';\nimport createLocksActions from './locks/actions';\nimport { rootEntitiesConfig, getMethodName } from './entities';\nimport { STORE_NAME } from './name';\nimport { unlock } from './private-apis';\n\n// The entity selectors/resolvers and actions are shortcuts to their generic equivalents\n// (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecords)\n// Instead of getEntityRecord, the consumer could use more user-friendly named selector: getPostType, getTaxonomy...\n// The \"kind\" and the \"name\" of the entity are combined to generate these shortcuts.\n\nconst entitySelectors = rootEntitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name ) ] = ( state, key, query ) =>\n\t\tselectors.getEntityRecord( state, kind, name, key, query );\n\tresult[ getMethodName( kind, name, 'get', true ) ] = ( state, query ) =>\n\t\tselectors.getEntityRecords( state, kind, name, query );\n\treturn result;\n}, {} );\n\nconst entityResolvers = rootEntitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name ) ] = ( key, query ) =>\n\t\tresolvers.getEntityRecord( kind, name, key, query );\n\tconst pluralMethodName = getMethodName( kind, name, 'get', true );\n\tresult[ pluralMethodName ] = ( ...args ) =>\n\t\tresolvers.getEntityRecords( kind, name, ...args );\n\tresult[ pluralMethodName ].shouldInvalidate = ( action ) =>\n\t\tresolvers.getEntityRecords.shouldInvalidate( action, kind, name );\n\treturn result;\n}, {} );\n\nconst entityActions = rootEntitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name, 'save' ) ] = (
|
|
1
|
+
{"version":3,"names":["createReduxStore","register","reducer","selectors","privateSelectors","actions","resolvers","createLocksActions","rootEntitiesConfig","getMethodName","STORE_NAME","unlock","entitySelectors","reduce","result","entity","kind","name","state","key","query","getEntityRecord","getEntityRecords","entityResolvers","pluralMethodName","args","shouldInvalidate","action","entityActions","record","options","saveEntityRecord","deleteEntityRecord","storeConfig","store","registerPrivateSelectors","default","EntityProvider"],"sources":["@wordpress/core-data/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport reducer from './reducer';\nimport * as selectors from './selectors';\nimport * as privateSelectors from './private-selectors';\nimport * as actions from './actions';\nimport * as resolvers from './resolvers';\nimport createLocksActions from './locks/actions';\nimport { rootEntitiesConfig, getMethodName } from './entities';\nimport { STORE_NAME } from './name';\nimport { unlock } from './private-apis';\n\n// The entity selectors/resolvers and actions are shortcuts to their generic equivalents\n// (getEntityRecord, getEntityRecords, updateEntityRecord, updateEntityRecords)\n// Instead of getEntityRecord, the consumer could use more user-friendly named selector: getPostType, getTaxonomy...\n// The \"kind\" and the \"name\" of the entity are combined to generate these shortcuts.\n\nconst entitySelectors = rootEntitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name ) ] = ( state, key, query ) =>\n\t\tselectors.getEntityRecord( state, kind, name, key, query );\n\tresult[ getMethodName( kind, name, 'get', true ) ] = ( state, query ) =>\n\t\tselectors.getEntityRecords( state, kind, name, query );\n\treturn result;\n}, {} );\n\nconst entityResolvers = rootEntitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name ) ] = ( key, query ) =>\n\t\tresolvers.getEntityRecord( kind, name, key, query );\n\tconst pluralMethodName = getMethodName( kind, name, 'get', true );\n\tresult[ pluralMethodName ] = ( ...args ) =>\n\t\tresolvers.getEntityRecords( kind, name, ...args );\n\tresult[ pluralMethodName ].shouldInvalidate = ( action ) =>\n\t\tresolvers.getEntityRecords.shouldInvalidate( action, kind, name );\n\treturn result;\n}, {} );\n\nconst entityActions = rootEntitiesConfig.reduce( ( result, entity ) => {\n\tconst { kind, name } = entity;\n\tresult[ getMethodName( kind, name, 'save' ) ] = ( record, options ) =>\n\t\tactions.saveEntityRecord( kind, name, record, options );\n\tresult[ getMethodName( kind, name, 'delete' ) ] = ( key, query, options ) =>\n\t\tactions.deleteEntityRecord( kind, name, key, query, options );\n\treturn result;\n}, {} );\n\nconst storeConfig = () => ( {\n\treducer,\n\tactions: { ...actions, ...entityActions, ...createLocksActions() },\n\tselectors: { ...selectors, ...entitySelectors },\n\tresolvers: { ...resolvers, ...entityResolvers },\n} );\n\n/**\n * Store definition for the code data namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n */\nexport const store = createReduxStore( STORE_NAME, storeConfig() );\nunlock( store ).registerPrivateSelectors( privateSelectors );\nregister( store ); // Register store after unlocking private selectors to allow resolvers to use them.\n\nexport { default as EntityProvider } from './entity-provider';\nexport * from './entity-provider';\nexport * from './entity-types';\nexport * from './fetch';\nex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EAAE,CAAC,CAAE,CAAC;AAEP,MAAMmB,WAAW,GAAGA,CAAA,MAAQ;EAC3B/B,OAAO;EACPG,OAAO,EAAE;IAAE,GAAGA,OAAO;IAAE,GAAGuB,aAAa;IAAE,GAAGrB,kBAAkB,CAAC;EAAE,CAAC;EAClEJ,SAAS,EAAE;IAAE,GAAGA,SAAS;IAAE,GAAGS;EAAgB,CAAC;EAC/CN,SAAS,EAAE;IAAE,GAAGA,SAAS;IAAE,GAAGiB;EAAgB;AAC/C,CAAC,CAAE;;AAEH;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMW,KAAK,GAAGlC,gBAAgB,CAAEU,UAAU,EAAEuB,WAAW,CAAC,CAAE,CAAC;AAClEtB,MAAM,CAAEuB,KAAM,CAAC,CAACC,wBAAwB,CAAE/B,gBAAiB,CAAC;AAC5DH,QAAQ,CAAEiC,KAAM,CAAC,CAAC,CAAC;;AAEnB,SAASE,OAAO,IAAIC,cAAc,QAAQ,mBAAmB;AAC7D,cAAc,mBAAmB;AACjC,cAAc,gBAAgB;AAC9B,cAAc,SAAS;AACvB,cAAc,SAAS"}
|
package/build-module/reducer.js
CHANGED
|
@@ -316,33 +316,30 @@ function entity(entityConfig) {
|
|
|
316
316
|
}
|
|
317
317
|
return state;
|
|
318
318
|
},
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
[recordKey]: newState
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
if (action.type === 'REMOVE_ITEMS') {
|
|
336
|
-
return Object.fromEntries(Object.entries(state).filter(([id]) => !action.itemIds.some(itemId => {
|
|
337
|
-
if (Number.isInteger(itemId)) {
|
|
338
|
-
return itemId === +id;
|
|
339
|
-
}
|
|
340
|
-
return itemId === id;
|
|
341
|
-
})));
|
|
342
|
-
}
|
|
343
|
-
return state;
|
|
319
|
+
revisions: (state = {}, action) => {
|
|
320
|
+
// Use the same queriedDataReducer shape for revisions.
|
|
321
|
+
if (action.type === 'RECEIVE_ITEM_REVISIONS') {
|
|
322
|
+
const recordKey = action.recordKey;
|
|
323
|
+
delete action.recordKey;
|
|
324
|
+
const newState = queriedDataReducer(state[recordKey], {
|
|
325
|
+
...action,
|
|
326
|
+
type: 'RECEIVE_ITEMS'
|
|
327
|
+
});
|
|
328
|
+
return {
|
|
329
|
+
...state,
|
|
330
|
+
[recordKey]: newState
|
|
331
|
+
};
|
|
344
332
|
}
|
|
345
|
-
|
|
333
|
+
if (action.type === 'REMOVE_ITEMS') {
|
|
334
|
+
return Object.fromEntries(Object.entries(state).filter(([id]) => !action.itemIds.some(itemId => {
|
|
335
|
+
if (Number.isInteger(itemId)) {
|
|
336
|
+
return itemId === +id;
|
|
337
|
+
}
|
|
338
|
+
return itemId === id;
|
|
339
|
+
})));
|
|
340
|
+
}
|
|
341
|
+
return state;
|
|
342
|
+
}
|
|
346
343
|
}));
|
|
347
344
|
}
|
|
348
345
|
|