@wordpress/core-data 6.27.1 → 6.28.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/build/entities.js +3 -6
- package/build/entities.js.map +1 -1
- package/build/entity-provider.js +21 -2
- package/build/entity-provider.js.map +1 -1
- package/build/entity-types/base-entity-records.js +1 -2
- package/build/entity-types/base-entity-records.js.map +1 -1
- package/build/fetch/__experimental-fetch-link-suggestions.js +1 -6
- package/build/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
- package/build/fetch/__experimental-fetch-url-data.js +1 -2
- package/build/fetch/__experimental-fetch-url-data.js.map +1 -1
- package/build/footnotes/index.js +1 -1
- package/build/footnotes/index.js.map +1 -1
- package/build/hooks/constants.js +1 -2
- package/build/hooks/constants.js.map +1 -1
- package/build/hooks/index.js +2 -2
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/memoize.js +1 -2
- package/build/hooks/memoize.js.map +1 -1
- package/build/hooks/use-query-select.js +1 -2
- package/build/hooks/use-query-select.js.map +1 -1
- package/build/index.js +3 -4
- package/build/index.js.map +1 -1
- package/build/name.js +1 -2
- package/build/name.js.map +1 -1
- package/build/queried-data/get-query-parts.js +1 -2
- package/build/queried-data/get-query-parts.js.map +1 -1
- package/build/queried-data/reducer.js +1 -2
- package/build/queried-data/reducer.js.map +1 -1
- package/build/queried-data/selectors.js +1 -2
- package/build/queried-data/selectors.js.map +1 -1
- package/build/reducer.js +1 -2
- package/build/reducer.js.map +1 -1
- package/build/resolvers.js +3 -6
- package/build/resolvers.js.map +1 -1
- package/build/selectors.js +12 -25
- package/build/selectors.js.map +1 -1
- package/build/utils/forward-resolver.js +1 -2
- package/build/utils/forward-resolver.js.map +1 -1
- package/build/utils/get-normalized-comma-separable.js +1 -2
- package/build/utils/get-normalized-comma-separable.js.map +1 -1
- package/build/utils/if-matching-action.js +1 -2
- package/build/utils/if-matching-action.js.map +1 -1
- package/build/utils/on-sub-key.js +1 -2
- package/build/utils/on-sub-key.js.map +1 -1
- package/build/utils/replace-action.js +1 -2
- package/build/utils/replace-action.js.map +1 -1
- package/build/utils/with-weak-map-cache.js +1 -2
- package/build/utils/with-weak-map-cache.js.map +1 -1
- package/build-module/entity-provider.js +21 -2
- package/build-module/entity-provider.js.map +1 -1
- package/build-module/fetch/__experimental-fetch-link-suggestions.js +0 -4
- package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
- package/build-module/footnotes/index.js +1 -1
- package/build-module/footnotes/index.js.map +1 -1
- package/build-module/selectors.js +1 -4
- package/build-module/selectors.js.map +1 -1
- package/build-types/entity-provider.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -1
- package/build-types/selectors.d.ts +1 -1
- package/build-types/selectors.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/entity-provider.js +29 -4
- package/src/footnotes/index.js +1 -1
- package/src/selectors.ts +5 -4
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
package/build/entities.js
CHANGED
|
@@ -23,10 +23,9 @@ var _sync = require("./sync");
|
|
|
23
23
|
* Internal dependencies
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
const DEFAULT_ENTITY_KEY = 'id';
|
|
27
|
-
exports.DEFAULT_ENTITY_KEY = DEFAULT_ENTITY_KEY;
|
|
26
|
+
const DEFAULT_ENTITY_KEY = exports.DEFAULT_ENTITY_KEY = 'id';
|
|
28
27
|
const POST_RAW_ATTRIBUTES = ['title', 'excerpt', 'content'];
|
|
29
|
-
const rootEntitiesConfig = [{
|
|
28
|
+
const rootEntitiesConfig = exports.rootEntitiesConfig = [{
|
|
30
29
|
label: (0, _i18n.__)('Base'),
|
|
31
30
|
kind: 'root',
|
|
32
31
|
name: '__unstableBase',
|
|
@@ -255,8 +254,7 @@ const rootEntitiesConfig = [{
|
|
|
255
254
|
plural: 'statuses',
|
|
256
255
|
key: 'slug'
|
|
257
256
|
}];
|
|
258
|
-
exports.
|
|
259
|
-
const additionalEntityConfigLoaders = [{
|
|
257
|
+
const additionalEntityConfigLoaders = exports.additionalEntityConfigLoaders = [{
|
|
260
258
|
kind: 'postType',
|
|
261
259
|
loadEntities: loadPostTypeEntities
|
|
262
260
|
}, {
|
|
@@ -271,7 +269,6 @@ const additionalEntityConfigLoaders = [{
|
|
|
271
269
|
* @param {Object} edits Edits.
|
|
272
270
|
* @return {Object} Updated edits.
|
|
273
271
|
*/
|
|
274
|
-
exports.additionalEntityConfigLoaders = additionalEntityConfigLoaders;
|
|
275
272
|
const prePersistPostType = (persistedRecord, edits) => {
|
|
276
273
|
const newEdits = {};
|
|
277
274
|
if (persistedRecord?.status === 'auto-draft') {
|
package/build/entities.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_changeCase","require","_apiFetch","_interopRequireDefault","_i18n","_richText","_actions","_sync","DEFAULT_ENTITY_KEY","exports","POST_RAW_ATTRIBUTES","rootEntitiesConfig","label","__","kind","name","baseURL","baseURLParams","_fields","join","syncConfig","fetch","apiFetch","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","RichTextData","valueOf","makeBlocksSerializable","map","block","innerBlocks","rest","postTypes","postType","_postType$rest_namesp","isTemplate","includes","namespace","rest_namespace","rest_base","selection","mergedEdits","meta","_record$slug","capitalCase","slug","String","__unstablePrePersist","undefined","__unstable_rest_base","has","revisionKey","taxonomies","taxonomy","_taxonomy$rest_namesp","getMethodName","prefix","usePlural","entityConfig","find","config","kindPrefix","pascalCase","nameSuffix","suffix","registerSyncConfigs","configs","getSyncProvider","register","editSyncConfig","getOrLoadEntitiesConfig","select","dispatch","getEntitiesConfig","length","window","__experimentalEnableSync","process","env","IS_GUTENBERG_PLUGIN","loader","l","addEntities"],"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":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,SAAA,GA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B,EAAG;MACtC,IAAKC,OAAO,CAACC,GAAG,CAACC,mBAAmB,EAAG;QACtCd,mBAAmB,CAAEC,OAAQ,CAAC;MAC/B;IACD;IAEA,OAAOA,OAAO;EACf;EAEA,MAAMc,MAAM,GAAGrE,6BAA6B,CAACgD,IAAI,CAC9CsB,CAAC,IAAMA,CAAC,CAAC/G,IAAI,KAAKA,IACrB,CAAC;EACD,IAAK,CAAE8G,MAAM,EAAG;IACf,OAAO,EAAE;EACV;EAEAd,OAAO,GAAG,MAAMc,MAAM,CAACpE,YAAY,CAAC,CAAC;EACrC,IAAK+D,MAAM,CAACC,wBAAwB,EAAG;IACtC,IAAKC,OAAO,CAACC,GAAG,CAACC,mBAAmB,EAAG;MACtCd,mBAAmB,CAAEC,OAAQ,CAAC;IAC/B;EACD;EAEAM,QAAQ,CAAE,IAAAU,oBAAW,EAAEhB,OAAQ,CAAE,CAAC;EAElC,OAAOA,OAAO;AACf,CAAC;AAACrG,OAAA,CAAAyG,uBAAA,GAAAA,uBAAA"}
|
|
1
|
+
{"version":3,"names":["_changeCase","require","_apiFetch","_interopRequireDefault","_i18n","_richText","_actions","_sync","DEFAULT_ENTITY_KEY","exports","POST_RAW_ATTRIBUTES","rootEntitiesConfig","label","__","kind","name","baseURL","baseURLParams","_fields","join","syncConfig","fetch","apiFetch","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","RichTextData","valueOf","makeBlocksSerializable","map","block","innerBlocks","rest","postTypes","postType","_postType$rest_namesp","isTemplate","includes","namespace","rest_namespace","rest_base","selection","mergedEdits","meta","_record$slug","capitalCase","slug","String","__unstablePrePersist","undefined","__unstable_rest_base","has","revisionKey","taxonomies","taxonomy","_taxonomy$rest_namesp","getMethodName","prefix","usePlural","entityConfig","find","config","kindPrefix","pascalCase","nameSuffix","suffix","registerSyncConfigs","configs","getSyncProvider","register","editSyncConfig","getOrLoadEntitiesConfig","select","dispatch","getEntitiesConfig","length","window","__experimentalEnableSync","process","env","IS_GUTENBERG_PLUGIN","loader","l","addEntities"],"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\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AiB,CAAEvG,IAAK,CAAC;EAC9C,IAAKgG,OAAO,IAAIA,OAAO,CAACQ,MAAM,KAAK,CAAC,EAAG;IACtC,IAAKC,MAAM,CAACC,wBAAwB,EAAG;MACtC,IAAKC,OAAO,CAACC,GAAG,CAACC,mBAAmB,EAAG;QACtCd,mBAAmB,CAAEC,OAAQ,CAAC;MAC/B;IACD;IAEA,OAAOA,OAAO;EACf;EAEA,MAAMc,MAAM,GAAGrE,6BAA6B,CAACgD,IAAI,CAC9CsB,CAAC,IAAMA,CAAC,CAAC/G,IAAI,KAAKA,IACrB,CAAC;EACD,IAAK,CAAE8G,MAAM,EAAG;IACf,OAAO,EAAE;EACV;EAEAd,OAAO,GAAG,MAAMc,MAAM,CAACpE,YAAY,CAAC,CAAC;EACrC,IAAK+D,MAAM,CAACC,wBAAwB,EAAG;IACtC,IAAKC,OAAO,CAACC,GAAG,CAACC,mBAAmB,EAAG;MACtCd,mBAAmB,CAAEC,OAAQ,CAAC;IAC/B;EACD;EAEAM,QAAQ,CAAE,IAAAU,oBAAW,EAAEhB,OAAQ,CAAE,CAAC;EAElC,OAAOA,OAAO;AACf,CAAC;AAACrG,OAAA,CAAAyG,uBAAA,GAAAA,uBAAA"}
|
package/build/entity-provider.js
CHANGED
|
@@ -138,6 +138,7 @@ function useEntityProp(kind, name, prop, _id) {
|
|
|
138
138
|
}, [editEntityRecord, kind, name, id, prop]);
|
|
139
139
|
return [value, setValue, fullValue];
|
|
140
140
|
}
|
|
141
|
+
const parsedBlocksCache = new WeakMap();
|
|
141
142
|
|
|
142
143
|
/**
|
|
143
144
|
* Hook that returns block content getters and setters for
|
|
@@ -162,6 +163,10 @@ function useEntityBlockEditor(kind, name, {
|
|
|
162
163
|
} = {}) {
|
|
163
164
|
const providerId = useEntityId(kind, name);
|
|
164
165
|
const id = _id !== null && _id !== void 0 ? _id : providerId;
|
|
166
|
+
const {
|
|
167
|
+
getEntityRecord,
|
|
168
|
+
getEntityRecordEdits
|
|
169
|
+
} = (0, _data.useSelect)(_name.STORE_NAME);
|
|
165
170
|
const {
|
|
166
171
|
content,
|
|
167
172
|
editedBlocks,
|
|
@@ -191,8 +196,22 @@ function useEntityBlockEditor(kind, name, {
|
|
|
191
196
|
if (editedBlocks) {
|
|
192
197
|
return editedBlocks;
|
|
193
198
|
}
|
|
194
|
-
|
|
195
|
-
|
|
199
|
+
if (!content || typeof content === 'function') {
|
|
200
|
+
return EMPTY_ARRAY;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// If there's an edit, cache the parsed blocks by the edit.
|
|
204
|
+
// If not, cache by the original enity record.
|
|
205
|
+
const edits = getEntityRecordEdits(kind, name, id);
|
|
206
|
+
const isUnedited = !edits || !Object.keys(edits).length;
|
|
207
|
+
const cackeKey = isUnedited ? getEntityRecord(kind, name, id) : edits;
|
|
208
|
+
let _blocks = parsedBlocksCache.get(cackeKey);
|
|
209
|
+
if (!_blocks) {
|
|
210
|
+
_blocks = (0, _blocks2.parse)(content);
|
|
211
|
+
parsedBlocksCache.set(cackeKey, _blocks);
|
|
212
|
+
}
|
|
213
|
+
return _blocks;
|
|
214
|
+
}, [kind, name, id, editedBlocks, content, getEntityRecord, getEntityRecordEdits]);
|
|
196
215
|
const updateFootnotes = (0, _element.useCallback)(_blocks => (0, _footnotes.updateFootnotesFromMeta)(_blocks, meta), [meta]);
|
|
197
216
|
const onChange = (0, _element.useCallback)((newBlocks, options) => {
|
|
198
217
|
const noChange = blocks === newBlocks;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_data","_blocks2","_name","_footnotes","_entities","EMPTY_ARRAY","entityContexts","rootEntitiesConfig","reduce","acc","loader","kind","name","context","createContext","undefined","additionalEntityConfigLoaders","getEntityContext","Error","EntityProvider","type","id","children","Provider","_react","createElement","value","useEntityId","useContext","useEntityProp","prop","_id","providerId","fullValue","useSelect","select","getEntityRecord","getEditedEntityRecord","STORE_NAME","record","editedRecord","editEntityRecord","useDispatch","setValue","useCallback","newValue","useEntityBlockEditor","content","editedBlocks","meta","blocks","__unstableCreateUndoLevel","useMemo","parse","updateFootnotes","_blocks","updateFootnotesFromMeta","onChange","newBlocks","options","noChange","selection","rest","edits","blocksForSerialization","__unstableSerializeAndClean","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":";;;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AASA,IAAAK,SAAA,GAAAL,OAAA;AAzBA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;;AAEA,MAAMM,WAAW,GAAG,EAAE;;AAEtB;AACA;AACA;;AAGA,MAAMC,cAAc,GAAG;EACtB,GAAGC,4BAAkB,CAACC,MAAM,CAAE,CAAEC,GAAG,EAA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BAAgB,CAElB,CAAC;EAED,MAAM0B,OAAO,GAAG,IAAAvB,oBAAW,EAC1B,CAAEc,SAAS,EAAEC,OAAO,KAAM;IACzB,MAAM;MAAEE,SAAS;MAAE,GAAGC;IAAK,CAAC,GAAGH,OAAO;IACtC,MAAMS,gBAAgB,GAAGd,eAAe,CAAEI,SAAU,CAAC;IACrD,MAAMK,KAAK,GAAG;MAAEF,SAAS;MAAE,GAAGO;IAAiB,CAAC;IAEhD3B,gBAAgB,CAAE9B,IAAI,EAAEC,IAAI,EAAES,EAAE,EAAE0C,KAAK,EAAE;MACxCG,QAAQ,EAAE,IAAI;MACd,GAAGJ;IACJ,CAAE,CAAC;EACJ,CAAC,EACD,CAAEnD,IAAI,EAAEC,IAAI,EAAES,EAAE,EAAEiC,eAAe,EAAEb,gBAAgB,CACpD,CAAC;EAED,OAAO,CAAES,MAAM,EAAEiB,OAAO,EAAEV,QAAQ,CAAE;AACrC"}
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_blocks2","_name","_footnotes","_entities","EMPTY_ARRAY","entityContexts","rootEntitiesConfig","reduce","acc","loader","kind","name","context","createContext","undefined","additionalEntityConfigLoaders","getEntityContext","Error","EntityProvider","type","id","children","Provider","_react","createElement","value","useEntityId","useContext","useEntityProp","prop","_id","providerId","fullValue","useSelect","select","getEntityRecord","getEditedEntityRecord","STORE_NAME","record","editedRecord","editEntityRecord","useDispatch","setValue","useCallback","newValue","parsedBlocksCache","WeakMap","useEntityBlockEditor","getEntityRecordEdits","content","editedBlocks","meta","blocks","__unstableCreateUndoLevel","useMemo","edits","isUnedited","Object","keys","length","cackeKey","_blocks","get","parse","set","updateFootnotes","updateFootnotesFromMeta","onChange","newBlocks","options","noChange","selection","rest","blocksForSerialization","__unstableSerializeAndClean","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\nconst parsedBlocksCache = new WeakMap();\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 { getEntityRecord, getEntityRecordEdits } = useSelect( STORE_NAME );\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\tif ( ! content || typeof content === 'function' ) {\n\t\t\treturn EMPTY_ARRAY;\n\t\t}\n\n\t\t// If there's an edit, cache the parsed blocks by the edit.\n\t\t// If not, cache by the original enity record.\n\t\tconst edits = getEntityRecordEdits( kind, name, id );\n\t\tconst isUnedited = ! edits || ! Object.keys( edits ).length;\n\t\tconst cackeKey = isUnedited ? getEntityRecord( kind, name, id ) : edits;\n\t\tlet _blocks = parsedBlocksCache.get( cackeKey );\n\n\t\tif ( ! _blocks ) {\n\t\t\t_blocks = parse( content );\n\t\t\tparsedBlocksCache.set( cackeKey, _blocks );\n\t\t}\n\n\t\treturn _blocks;\n\t}, [\n\t\tkind,\n\t\tname,\n\t\tid,\n\t\teditedBlocks,\n\t\tcontent,\n\t\tgetEntityRecord,\n\t\tgetEntityRecordEdits,\n\t] );\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":";;;;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAMA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAKA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;A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AEhDrC,gBAAgB,CAAE9B,IAAI,EAAEC,IAAI,EAAES,EAAE,EAAEmC,KAAK,EAAE;MACxCoB,QAAQ,EAAE,IAAI;MACd,GAAGH;IACJ,CAAE,CAAC;EACJ,CAAC,EACD,CAAE9D,IAAI,EAAEC,IAAI,EAAES,EAAE,EAAE6C,eAAe,EAAEzB,gBAAgB,CACpD,CAAC;EAED,OAAO,CAAEY,MAAM,EAAEwB,OAAO,EAAET,QAAQ,CAAE;AACrC"}
|
|
@@ -39,6 +39,5 @@ exports.BaseEntityRecords = void 0;
|
|
|
39
39
|
* // c.id is still present
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
|
-
let BaseEntityRecords;
|
|
43
|
-
exports.BaseEntityRecords = BaseEntityRecords;
|
|
42
|
+
let BaseEntityRecords = exports.BaseEntityRecords = void 0;
|
|
44
43
|
//# sourceMappingURL=base-entity-records.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BaseEntityRecords","exports"],"sources":["@wordpress/core-data/src/entity-types/base-entity-records.ts"],"sourcesContent":["/**\n * This module exists solely to make the BaseEntityRecords namespace extensible\n * with declaration merging:\n *\n * ```ts\n * declare module './base-entity-records' {\n * export namespace BaseEntityRecords {\n * \t\t export interface Comment< C extends Context > {\n * \t\t id: number;\n * \t\t // ...\n * \t }\n * \t }\n * }\n * ```\n *\n * The huge upside is that consumers of @wordpress/core-data may extend the\n * exported data types using interface merging as follows:\n *\n * ```ts\n * import type { Context } from '@wordpress/core-data';\n * declare module '@wordpress/core-data' {\n * export namespace BaseEntityRecords {\n * export interface Comment< C extends Context > {\n * numberOfViews: number;\n * }\n * }\n * }\n *\n * import type { Comment } from '@wordpress/core-data';\n * const c : Comment< 'view' > = ...;\n *\n * // c.numberOfViews is a number\n * // c.id is still present\n * ```\n */\nexport namespace BaseEntityRecords {}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAlCA,IAmCiBA,iBAAiB
|
|
1
|
+
{"version":3,"names":["BaseEntityRecords","exports"],"sources":["@wordpress/core-data/src/entity-types/base-entity-records.ts"],"sourcesContent":["/**\n * This module exists solely to make the BaseEntityRecords namespace extensible\n * with declaration merging:\n *\n * ```ts\n * declare module './base-entity-records' {\n * export namespace BaseEntityRecords {\n * \t\t export interface Comment< C extends Context > {\n * \t\t id: number;\n * \t\t // ...\n * \t }\n * \t }\n * }\n * ```\n *\n * The huge upside is that consumers of @wordpress/core-data may extend the\n * exported data types using interface merging as follows:\n *\n * ```ts\n * import type { Context } from '@wordpress/core-data';\n * declare module '@wordpress/core-data' {\n * export namespace BaseEntityRecords {\n * export interface Comment< C extends Context > {\n * numberOfViews: number;\n * }\n * }\n * }\n *\n * import type { Comment } from '@wordpress/core-data';\n * const c : Comment< 'view' > = ...;\n *\n * // c.numberOfViews is a number\n * // c.id is still present\n * ```\n */\nexport namespace BaseEntityRecords {}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAlCA,IAmCiBA,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA"}
|
|
@@ -130,7 +130,6 @@ const fetchLinkSuggestions = async (search, searchOptions = {}, settings = {}) =
|
|
|
130
130
|
}).catch(() => []) // Fail by returning no results.
|
|
131
131
|
);
|
|
132
132
|
}
|
|
133
|
-
|
|
134
133
|
if (!type || type === 'term') {
|
|
135
134
|
queries.push((0, _apiFetch.default)({
|
|
136
135
|
path: (0, _url.addQueryArgs)('/wp/v2/search', {
|
|
@@ -153,7 +152,6 @@ const fetchLinkSuggestions = async (search, searchOptions = {}, settings = {}) =
|
|
|
153
152
|
}).catch(() => []) // Fail by returning no results.
|
|
154
153
|
);
|
|
155
154
|
}
|
|
156
|
-
|
|
157
155
|
if (!disablePostFormats && (!type || type === 'post-format')) {
|
|
158
156
|
queries.push((0, _apiFetch.default)({
|
|
159
157
|
path: (0, _url.addQueryArgs)('/wp/v2/search', {
|
|
@@ -176,7 +174,6 @@ const fetchLinkSuggestions = async (search, searchOptions = {}, settings = {}) =
|
|
|
176
174
|
}).catch(() => []) // Fail by returning no results.
|
|
177
175
|
);
|
|
178
176
|
}
|
|
179
|
-
|
|
180
177
|
if (!type || type === 'attachment') {
|
|
181
178
|
queries.push((0, _apiFetch.default)({
|
|
182
179
|
path: (0, _url.addQueryArgs)('/wp/v2/media', {
|
|
@@ -196,7 +193,6 @@ const fetchLinkSuggestions = async (search, searchOptions = {}, settings = {}) =
|
|
|
196
193
|
}).catch(() => []) // Fail by returning no results.
|
|
197
194
|
);
|
|
198
195
|
}
|
|
199
|
-
|
|
200
196
|
return Promise.all(queries).then(results => {
|
|
201
197
|
return results.reduce(( /** @type {WPLinkSearchResult[]} */accumulator, current) => accumulator.concat(current),
|
|
202
198
|
// Flatten list.
|
|
@@ -221,6 +217,5 @@ const fetchLinkSuggestions = async (search, searchOptions = {}, settings = {}) =
|
|
|
221
217
|
});
|
|
222
218
|
});
|
|
223
219
|
};
|
|
224
|
-
var _default = fetchLinkSuggestions;
|
|
225
|
-
exports.default = _default;
|
|
220
|
+
var _default = exports.default = fetchLinkSuggestions;
|
|
226
221
|
//# sourceMappingURL=__experimental-fetch-link-suggestions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_apiFetch","_interopRequireDefault","require","_url","_htmlEntities","_i18n","fetchLinkSuggestions","search","searchOptions","settings","isInitialSuggestions","initialSuggestionsSearchOptions","undefined","disablePostFormats","type","subtype","page","perPage","queries","push","apiFetch","path","addQueryArgs","per_page","then","results","map","result","meta","kind","catch","Promise","all","reduce","accumulator","current","concat","filter","id","slice","isMedia","url","source_url","title","decodeEntities","rendered","__","_default","exports","default"],"sources":["@wordpress/core-data/src/fetch/__experimental-fetch-link-suggestions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Filters the search by type\n *\n * @typedef { 'attachment' | 'post' | 'term' | 'post-format' } WPLinkSearchType\n */\n\n/**\n * A link with an id may be of kind post-type or taxonomy\n *\n * @typedef { 'post-type' | 'taxonomy' } WPKind\n */\n\n/**\n * @typedef WPLinkSearchOptions\n *\n * @property {boolean} [isInitialSuggestions] Displays initial search suggestions, when true.\n * @property {WPLinkSearchType} [type] Filters by search type.\n * @property {string} [subtype] Slug of the post-type or taxonomy.\n * @property {number} [page] Which page of results to return.\n * @property {number} [perPage] Search results per page.\n */\n\n/**\n * @typedef WPLinkSearchResult\n *\n * @property {number} id Post or term id.\n * @property {string} url Link url.\n * @property {string} title Title of the link.\n * @property {string} type The taxonomy or post type slug or type URL.\n * @property {WPKind} [kind] Link kind of post-type or taxonomy\n */\n\n/**\n * @typedef WPLinkSearchResultAugments\n *\n * @property {{kind: WPKind}} [meta] Contains kind information.\n * @property {WPKind} [subtype] Optional subtype if it exists.\n */\n\n/**\n * @typedef {WPLinkSearchResult & WPLinkSearchResultAugments} WPLinkSearchResultAugmented\n */\n\n/**\n * @typedef WPEditorSettings\n *\n * @property {boolean} [ disablePostFormats ] Disables post formats, when true.\n */\n\n/**\n * Fetches link suggestions from the API.\n *\n * @async\n * @param {string} search\n * @param {WPLinkSearchOptions} [searchOptions]\n * @param {WPEditorSettings} [settings]\n *\n * @example\n * ```js\n * import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';\n *\n * //...\n *\n * export function initialize( id, settings ) {\n *\n * settings.__experimentalFetchLinkSuggestions = (\n * search,\n * searchOptions\n * ) => fetchLinkSuggestions( search, searchOptions, settings );\n * ```\n * @return {Promise< WPLinkSearchResult[] >} List of search suggestions\n */\nconst fetchLinkSuggestions = async (\n\tsearch,\n\tsearchOptions = {},\n\tsettings = {}\n) => {\n\tconst {\n\t\tisInitialSuggestions = false,\n\t\tinitialSuggestionsSearchOptions = undefined,\n\t} = searchOptions;\n\n\tconst { disablePostFormats = false } = settings;\n\n\tlet {\n\t\ttype = undefined,\n\t\tsubtype = undefined,\n\t\tpage = undefined,\n\t\tperPage = isInitialSuggestions ? 3 : 20,\n\t} = searchOptions;\n\n\t/** @type {Promise<WPLinkSearchResult>[]} */\n\tconst queries = [];\n\n\tif ( isInitialSuggestions && initialSuggestionsSearchOptions ) {\n\t\ttype = initialSuggestionsSearchOptions.type || type;\n\t\tsubtype = initialSuggestionsSearchOptions.subtype || subtype;\n\t\tpage = initialSuggestionsSearchOptions.page || page;\n\t\tperPage = initialSuggestionsSearchOptions.perPage || perPage;\n\t}\n\n\tif ( ! type || type === 'post' ) {\n\t\tqueries.push(\n\t\t\tapiFetch( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tmeta: { kind: 'post-type', subtype },\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! type || type === 'term' ) {\n\t\tqueries.push(\n\t\t\tapiFetch( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'term',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tmeta: { kind: 'taxonomy', subtype },\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! disablePostFormats && ( ! type || type === 'post-format' ) ) {\n\t\tqueries.push(\n\t\t\tapiFetch( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'post-format',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tmeta: { kind: 'taxonomy', subtype },\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! type || type === 'attachment' ) {\n\t\tqueries.push(\n\t\t\tapiFetch( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/media', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tmeta: { kind: 'media' },\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\treturn Promise.all( queries ).then( ( results ) => {\n\t\treturn results\n\t\t\t.reduce(\n\t\t\t\t( /** @type {WPLinkSearchResult[]} */ accumulator, current ) =>\n\t\t\t\t\taccumulator.concat( current ), // Flatten list.\n\t\t\t\t[]\n\t\t\t)\n\t\t\t.filter(\n\t\t\t\t/**\n\t\t\t\t * @param {{ id: number }} result\n\t\t\t\t */\n\t\t\t\t( result ) => {\n\t\t\t\t\treturn !! result.id;\n\t\t\t\t}\n\t\t\t)\n\t\t\t.slice( 0, perPage )\n\t\t\t.map( ( /** @type {WPLinkSearchResultAugmented} */ result ) => {\n\t\t\t\tconst isMedia = result.type === 'attachment';\n\n\t\t\t\treturn {\n\t\t\t\t\tid: result.id,\n\t\t\t\t\t// @ts-ignore fix when we make this a TS file\n\t\t\t\t\turl: isMedia ? result.source_url : result.url,\n\t\t\t\t\ttitle:\n\t\t\t\t\t\tdecodeEntities(\n\t\t\t\t\t\t\tisMedia\n\t\t\t\t\t\t\t\t? // @ts-ignore fix when we make this a TS file\n\t\t\t\t\t\t\t\t result.title.rendered\n\t\t\t\t\t\t\t\t: result.title || ''\n\t\t\t\t\t\t) || __( '(no title)' ),\n\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\tkind: result?.meta?.kind,\n\t\t\t\t};\n\t\t\t} );\n\t} );\n};\n\nexport default fetchLinkSuggestions;\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AANA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;A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AM,CAACgB,KAAK,CAACE,QAAQ,GACrBlB,MAAM,CAACgB,KAAK,IAAI,EACpB,CAAC,IAAI,IAAAG,QAAE,EAAE,YAAa,CAAC;QACxBhC,IAAI,EAAEa,MAAM,CAACZ,OAAO,IAAIY,MAAM,CAACb,IAAI;QACnCe,IAAI,EAAEF,MAAM,EAAEC,IAAI,EAAEC;MACrB,CAAC;IACF,CAAE,CAAC;EACL,CAAE,CAAC;AACJ,CAAC;AAAC,IAAAkB,QAAA,GAEazC,oBAAoB;AAAA0C,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
1
|
+
{"version":3,"names":["_apiFetch","_interopRequireDefault","require","_url","_htmlEntities","_i18n","fetchLinkSuggestions","search","searchOptions","settings","isInitialSuggestions","initialSuggestionsSearchOptions","undefined","disablePostFormats","type","subtype","page","perPage","queries","push","apiFetch","path","addQueryArgs","per_page","then","results","map","result","meta","kind","catch","Promise","all","reduce","accumulator","current","concat","filter","id","slice","isMedia","url","source_url","title","decodeEntities","rendered","__","_default","exports","default"],"sources":["@wordpress/core-data/src/fetch/__experimental-fetch-link-suggestions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Filters the search by type\n *\n * @typedef { 'attachment' | 'post' | 'term' | 'post-format' } WPLinkSearchType\n */\n\n/**\n * A link with an id may be of kind post-type or taxonomy\n *\n * @typedef { 'post-type' | 'taxonomy' } WPKind\n */\n\n/**\n * @typedef WPLinkSearchOptions\n *\n * @property {boolean} [isInitialSuggestions] Displays initial search suggestions, when true.\n * @property {WPLinkSearchType} [type] Filters by search type.\n * @property {string} [subtype] Slug of the post-type or taxonomy.\n * @property {number} [page] Which page of results to return.\n * @property {number} [perPage] Search results per page.\n */\n\n/**\n * @typedef WPLinkSearchResult\n *\n * @property {number} id Post or term id.\n * @property {string} url Link url.\n * @property {string} title Title of the link.\n * @property {string} type The taxonomy or post type slug or type URL.\n * @property {WPKind} [kind] Link kind of post-type or taxonomy\n */\n\n/**\n * @typedef WPLinkSearchResultAugments\n *\n * @property {{kind: WPKind}} [meta] Contains kind information.\n * @property {WPKind} [subtype] Optional subtype if it exists.\n */\n\n/**\n * @typedef {WPLinkSearchResult & WPLinkSearchResultAugments} WPLinkSearchResultAugmented\n */\n\n/**\n * @typedef WPEditorSettings\n *\n * @property {boolean} [ disablePostFormats ] Disables post formats, when true.\n */\n\n/**\n * Fetches link suggestions from the API.\n *\n * @async\n * @param {string} search\n * @param {WPLinkSearchOptions} [searchOptions]\n * @param {WPEditorSettings} [settings]\n *\n * @example\n * ```js\n * import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';\n *\n * //...\n *\n * export function initialize( id, settings ) {\n *\n * settings.__experimentalFetchLinkSuggestions = (\n * search,\n * searchOptions\n * ) => fetchLinkSuggestions( search, searchOptions, settings );\n * ```\n * @return {Promise< WPLinkSearchResult[] >} List of search suggestions\n */\nconst fetchLinkSuggestions = async (\n\tsearch,\n\tsearchOptions = {},\n\tsettings = {}\n) => {\n\tconst {\n\t\tisInitialSuggestions = false,\n\t\tinitialSuggestionsSearchOptions = undefined,\n\t} = searchOptions;\n\n\tconst { disablePostFormats = false } = settings;\n\n\tlet {\n\t\ttype = undefined,\n\t\tsubtype = undefined,\n\t\tpage = undefined,\n\t\tperPage = isInitialSuggestions ? 3 : 20,\n\t} = searchOptions;\n\n\t/** @type {Promise<WPLinkSearchResult>[]} */\n\tconst queries = [];\n\n\tif ( isInitialSuggestions && initialSuggestionsSearchOptions ) {\n\t\ttype = initialSuggestionsSearchOptions.type || type;\n\t\tsubtype = initialSuggestionsSearchOptions.subtype || subtype;\n\t\tpage = initialSuggestionsSearchOptions.page || page;\n\t\tperPage = initialSuggestionsSearchOptions.perPage || perPage;\n\t}\n\n\tif ( ! type || type === 'post' ) {\n\t\tqueries.push(\n\t\t\tapiFetch( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tmeta: { kind: 'post-type', subtype },\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! type || type === 'term' ) {\n\t\tqueries.push(\n\t\t\tapiFetch( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'term',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tmeta: { kind: 'taxonomy', subtype },\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! disablePostFormats && ( ! type || type === 'post-format' ) ) {\n\t\tqueries.push(\n\t\t\tapiFetch( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/search', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\ttype: 'post-format',\n\t\t\t\t\tsubtype,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tmeta: { kind: 'taxonomy', subtype },\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\tif ( ! type || type === 'attachment' ) {\n\t\tqueries.push(\n\t\t\tapiFetch( {\n\t\t\t\tpath: addQueryArgs( '/wp/v2/media', {\n\t\t\t\t\tsearch,\n\t\t\t\t\tpage,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t.then( ( results ) => {\n\t\t\t\t\treturn results.map( ( result ) => {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\tmeta: { kind: 'media' },\n\t\t\t\t\t\t};\n\t\t\t\t\t} );\n\t\t\t\t} )\n\t\t\t\t.catch( () => [] ) // Fail by returning no results.\n\t\t);\n\t}\n\n\treturn Promise.all( queries ).then( ( results ) => {\n\t\treturn results\n\t\t\t.reduce(\n\t\t\t\t( /** @type {WPLinkSearchResult[]} */ accumulator, current ) =>\n\t\t\t\t\taccumulator.concat( current ), // Flatten list.\n\t\t\t\t[]\n\t\t\t)\n\t\t\t.filter(\n\t\t\t\t/**\n\t\t\t\t * @param {{ id: number }} result\n\t\t\t\t */\n\t\t\t\t( result ) => {\n\t\t\t\t\treturn !! result.id;\n\t\t\t\t}\n\t\t\t)\n\t\t\t.slice( 0, perPage )\n\t\t\t.map( ( /** @type {WPLinkSearchResultAugmented} */ result ) => {\n\t\t\t\tconst isMedia = result.type === 'attachment';\n\n\t\t\t\treturn {\n\t\t\t\t\tid: result.id,\n\t\t\t\t\t// @ts-ignore fix when we make this a TS file\n\t\t\t\t\turl: isMedia ? result.source_url : result.url,\n\t\t\t\t\ttitle:\n\t\t\t\t\t\tdecodeEntities(\n\t\t\t\t\t\t\tisMedia\n\t\t\t\t\t\t\t\t? // @ts-ignore fix when we make this a TS file\n\t\t\t\t\t\t\t\t result.title.rendered\n\t\t\t\t\t\t\t\t: result.title || ''\n\t\t\t\t\t\t) || __( '(no title)' ),\n\t\t\t\t\ttype: result.subtype || result.type,\n\t\t\t\t\tkind: result?.meta?.kind,\n\t\t\t\t};\n\t\t\t} );\n\t} );\n};\n\nexport default fetchLinkSuggestions;\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AANA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,oBAAoB,GAAG,MAAAA,CAC5BC,MAAM,EACNC,aAAa,GAAG,CAAC,CAAC,EAClBC,QAAQ,GAAG,CAAC,CAAC,KACT;EACJ,MAAM;IACLC,oBAAoB,GAAG,KAAK;IAC5BC,+BAA+B,GAAGC;EACnC,CAAC,GAAGJ,aAAa;EAEjB,MAAM;IAAEK,kBAAkB,GAAG;EAAM,CAAC,GAAGJ,QAAQ;EAE/C,IAAI;IACHK,IAAI,GAAGF,SAAS;IAChBG,OAAO,GAAGH,SAAS;IACnBI,IAAI,GAAGJ,SAAS;IAChBK,OAAO,GAAGP,oBAAoB,GAAG,CAAC,GAAG;EACtC,CAAC,GAAGF,aAAa;;EAEjB;EACA,MAAMU,OAAO,GAAG,EAAE;EAElB,IAAKR,oBAAoB,IAAIC,+BAA+B,EAAG;IAC9DG,IAAI,GAAGH,+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AAO,CACZQ,MAAM,CACN,EAAE,mCAAoCC,WAAW,EAAEC,OAAO,KACzDD,WAAW,CAACE,MAAM,CAAED,OAAQ,CAAC;IAAE;IAChC,EACD,CAAC,CACAE,MAAM;IACN;AACJ;AACA;IACMV,MAAM,IAAM;MACb,OAAO,CAAC,CAAEA,MAAM,CAACW,EAAE;IACpB,CACD,CAAC,CACAC,KAAK,CAAE,CAAC,EAAEtB,OAAQ,CAAC,CACnBS,GAAG,CAAE,EAAE,0CAA2CC,MAAM,KAAM;MAC9D,MAAMa,OAAO,GAAGb,MAAM,CAACb,IAAI,KAAK,YAAY;MAE5C,OAAO;QACNwB,EAAE,EAAEX,MAAM,CAACW,EAAE;QACb;QACAG,GAAG,EAAED,OAAO,GAAGb,MAAM,CAACe,UAAU,GAAGf,MAAM,CAACc,GAAG;QAC7CE,KAAK,EACJ,IAAAC,4BAAc,EACbJ,OAAO;QACJ;QACAb,MAAM,CAACgB,KAAK,CAACE,QAAQ,GACrBlB,MAAM,CAACgB,KAAK,IAAI,EACpB,CAAC,IAAI,IAAAG,QAAE,EAAE,YAAa,CAAC;QACxBhC,IAAI,EAAEa,MAAM,CAACZ,OAAO,IAAIY,MAAM,CAACb,IAAI;QACnCe,IAAI,EAAEF,MAAM,EAAEC,IAAI,EAAEC;MACrB,CAAC;IACF,CAAE,CAAC;EACL,CAAE,CAAC;AACJ,CAAC;AAAC,IAAAkB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa3C,oBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_apiFetch","_interopRequireDefault","require","_url","CACHE","Map","fetchUrlData","url","options","endpoint","args","prependHTTP","isURL","Promise","reject","protocol","getProtocol","isValidProtocol","startsWith","test","has","get","apiFetch","path","addQueryArgs","then","res","set","_default","exports","default"],"sources":["@wordpress/core-data/src/fetch/__experimental-fetch-url-data.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport {\n\taddQueryArgs,\n\tprependHTTP,\n\tisURL,\n\tgetProtocol,\n\tisValidProtocol,\n} from '@wordpress/url';\n\n/**\n * A simple in-memory cache for requests.\n * This avoids repeat HTTP requests which may be beneficial\n * for those wishing to preserve low-bandwidth.\n */\nconst CACHE = new Map();\n\n/**\n * @typedef WPRemoteUrlData\n *\n * @property {string} title contents of the remote URL's `<title>` tag.\n */\n\n/**\n * Fetches data about a remote URL.\n * eg: <title> tag, favicon...etc.\n *\n * @async\n * @param {string} url the URL to request details from.\n * @param {Object?} options any options to pass to the underlying fetch.\n * @example\n * ```js\n * import { __experimentalFetchUrlData as fetchUrlData } from '@wordpress/core-data';\n *\n * //...\n *\n * export function initialize( id, settings ) {\n *\n * settings.__experimentalFetchUrlData = (\n * url\n * ) => fetchUrlData( url );\n * ```\n * @return {Promise< WPRemoteUrlData[] >} Remote URL data.\n */\nconst fetchUrlData = async ( url, options = {} ) => {\n\tconst endpoint = '/wp-block-editor/v1/url-details';\n\n\tconst args = {\n\t\turl: prependHTTP( url ),\n\t};\n\n\tif ( ! isURL( url ) ) {\n\t\treturn Promise.reject( `${ url } is not a valid URL.` );\n\t}\n\n\t// Test for \"http\" based URL as it is possible for valid\n\t// yet unusable URLs such as `tel:123456` to be passed.\n\tconst protocol = getProtocol( url );\n\n\tif (\n\t\t! protocol ||\n\t\t! isValidProtocol( protocol ) ||\n\t\t! protocol.startsWith( 'http' ) ||\n\t\t! /^https?:\\/\\/[^\\/\\s]/i.test( url )\n\t) {\n\t\treturn Promise.reject(\n\t\t\t`${ url } does not have a valid protocol. URLs must be \"http\" based`\n\t\t);\n\t}\n\n\tif ( CACHE.has( url ) ) {\n\t\treturn CACHE.get( url );\n\t}\n\n\treturn apiFetch( {\n\t\tpath: addQueryArgs( endpoint, args ),\n\t\t...options,\n\t} ).then( ( res ) => {\n\t\tCACHE.set( url, res );\n\t\treturn res;\n\t} );\n};\n\nexport default fetchUrlData;\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,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AAG,CAAEpB,GAAG,EAAEmB,GAAI,CAAC;IACrB,OAAOA,GAAG;EACX,CAAE,CAAC;AACJ,CAAC;AAAC,IAAAE,QAAA,
|
|
1
|
+
{"version":3,"names":["_apiFetch","_interopRequireDefault","require","_url","CACHE","Map","fetchUrlData","url","options","endpoint","args","prependHTTP","isURL","Promise","reject","protocol","getProtocol","isValidProtocol","startsWith","test","has","get","apiFetch","path","addQueryArgs","then","res","set","_default","exports","default"],"sources":["@wordpress/core-data/src/fetch/__experimental-fetch-url-data.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport {\n\taddQueryArgs,\n\tprependHTTP,\n\tisURL,\n\tgetProtocol,\n\tisValidProtocol,\n} from '@wordpress/url';\n\n/**\n * A simple in-memory cache for requests.\n * This avoids repeat HTTP requests which may be beneficial\n * for those wishing to preserve low-bandwidth.\n */\nconst CACHE = new Map();\n\n/**\n * @typedef WPRemoteUrlData\n *\n * @property {string} title contents of the remote URL's `<title>` tag.\n */\n\n/**\n * Fetches data about a remote URL.\n * eg: <title> tag, favicon...etc.\n *\n * @async\n * @param {string} url the URL to request details from.\n * @param {Object?} options any options to pass to the underlying fetch.\n * @example\n * ```js\n * import { __experimentalFetchUrlData as fetchUrlData } from '@wordpress/core-data';\n *\n * //...\n *\n * export function initialize( id, settings ) {\n *\n * settings.__experimentalFetchUrlData = (\n * url\n * ) => fetchUrlData( url );\n * ```\n * @return {Promise< WPRemoteUrlData[] >} Remote URL data.\n */\nconst fetchUrlData = async ( url, options = {} ) => {\n\tconst endpoint = '/wp-block-editor/v1/url-details';\n\n\tconst args = {\n\t\turl: prependHTTP( url ),\n\t};\n\n\tif ( ! isURL( url ) ) {\n\t\treturn Promise.reject( `${ url } is not a valid URL.` );\n\t}\n\n\t// Test for \"http\" based URL as it is possible for valid\n\t// yet unusable URLs such as `tel:123456` to be passed.\n\tconst protocol = getProtocol( url );\n\n\tif (\n\t\t! protocol ||\n\t\t! isValidProtocol( protocol ) ||\n\t\t! protocol.startsWith( 'http' ) ||\n\t\t! /^https?:\\/\\/[^\\/\\s]/i.test( url )\n\t) {\n\t\treturn Promise.reject(\n\t\t\t`${ url } does not have a valid protocol. URLs must be \"http\" based`\n\t\t);\n\t}\n\n\tif ( CACHE.has( url ) ) {\n\t\treturn CACHE.get( url );\n\t}\n\n\treturn apiFetch( {\n\t\tpath: addQueryArgs( endpoint, args ),\n\t\t...options,\n\t} ).then( ( res ) => {\n\t\tCACHE.set( url, res );\n\t\treturn res;\n\t} );\n};\n\nexport default fetchUrlData;\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AAJA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA,MAAME,KAAK,GAAG,IAAIC,GAAG,CAAC,CAAC;;AAEvB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAG,MAAAA,CAAQC,GAAG,EAAEC,OAAO,GAAG,CAAC,CAAC,KAAM;EACnD,MAAMC,QAAQ,GAAG,iCAAiC;EAElD,MAAMC,IAAI,GAAG;IACZH,GAAG,EAAE,IAAAI,gBAAW,EAAEJ,GAAI;EACvB,CAAC;EAED,IAAK,CAAE,IAAAK,UAAK,EAAEL,GAAI,CAAC,EAAG;IACrB,OAAOM,OAAO,CAACC,MAAM,CAAG,GAAGP,GAAK,sBAAsB,CAAC;EACxD;;EAEA;EACA;EACA,MAAMQ,QAAQ,GAAG,IAAAC,gBAAW,EAAET,GAAI,CAAC;EAEnC,IACC,CAAEQ,QAAQ,IACV,CAAE,IAAAE,oBAAe,EAAEF,QAAS,CAAC,IAC7B,CAAEA,QAAQ,CAACG,UAAU,CAAE,MAAO,CAAC,IAC/B,CAAE,sBAAsB,CAACC,IAAI,CAAEZ,GAAI,CAAC,EACnC;IACD,OAAOM,OAAO,CAACC,MAAM,CACnB,GAAGP,GAAK,4DACV,CAAC;EACF;EAEA,IAAKH,KAAK,CAACgB,GAAG,CAAEb,GAAI,CAAC,EAAG;IACvB,OAAOH,KAAK,CAACiB,GAAG,CAAEd,GAAI,CAAC;EACxB;EAEA,OAAO,IAAAe,iBAAQ,EAAE;IAChBC,IAAI,EAAE,IAAAC,iBAAY,EAAEf,QAAQ,EAAEC,IAAK,CAAC;IACpC,GAAGF;EACJ,CAAE,CAAC,CAACiB,IAAI,CAAIC,GAAG,IAAM;IACpBtB,KAAK,CAACuB,GAAG,CAAEpB,GAAG,EAAEmB,GAAI,CAAC;IACrB,OAAOA,GAAG;EACX,CAAE,CAAC;AACJ,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaxB,YAAY"}
|
package/build/footnotes/index.js
CHANGED
|
@@ -51,7 +51,7 @@ function updateFootnotesFromMeta(blocks, meta) {
|
|
|
51
51
|
if (typeof value !== 'string' && !(value instanceof _richText.RichTextData)) {
|
|
52
52
|
continue;
|
|
53
53
|
}
|
|
54
|
-
const richTextValue = typeof value === 'string' ? _richText.RichTextData.fromHTMLString(value) : value;
|
|
54
|
+
const richTextValue = typeof value === 'string' ? _richText.RichTextData.fromHTMLString(value) : new _richText.RichTextData(value);
|
|
55
55
|
richTextValue.replacements.forEach(replacement => {
|
|
56
56
|
if (replacement.type === 'core/footnote') {
|
|
57
57
|
const id = replacement.attributes['data-fn'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_richText","require","_getFootnotesOrder","_interopRequireDefault","oldFootnotes","updateFootnotesFromMeta","blocks","meta","output","footnotes","undefined","newOrder","getFootnotesOrder","JSON","parse","currentOrder","map","fn","id","join","newFootnotes","fnId","find","content","updateAttributes","attributes","Array","isArray","key","value","RichTextData","richTextValue","fromHTMLString","replacements","forEach","replacement","type","index","indexOf","countValue","create","html","innerHTML","text","String","formats","from","length","toHTMLString","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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,IACZC,KAAK,CAACC,OAAO,CAAEF,UAAW,CAAC,IAC3B,OAAOA,UAAU,KAAK,QAAQ,EAC7B;MACD,OAAOA,UAAU;IAClB;IAEAA,UAAU,GAAG;MAAE,GAAGA;IAAW,CAAC;IAE9B,KAAM,MAAMG,GAAG,IAAIH,UAAU,EAAG;MAC/B,MAAMI,KAAK,GAAGJ,UAAU,CAAEG,GAAG,CAAE;MAE/B,IAAKF,KAAK,CAACC,OAAO,CAAEE,KAAM,CAAC,EAAG;QAC7BJ,UAAU,CAAEG,GAAG,CAAE,GAAGC,KAAK,CAACb,GAAG,CAAEQ,gBAAiB,CAAC;QACjD;MACD;;MAEA;MACA,IACC,OAAOK,KAAK,KAAK,QAAQ,IACzB,EAAIA,KAAK,YAAYC,sBAAY,CAAE,EAClC;QACD;MACD;MAEA,MAAMC,aAAa,GAClB,OAAOF,KAAK,KAAK,QAAQ,GACtBC,sBAAY,CAACE,cAAc,CAAEH,KAAM,CAAC,
|
|
1
|
+
{"version":3,"names":["_richText","require","_getFootnotesOrder","_interopRequireDefault","oldFootnotes","updateFootnotesFromMeta","blocks","meta","output","footnotes","undefined","newOrder","getFootnotesOrder","JSON","parse","currentOrder","map","fn","id","join","newFootnotes","fnId","find","content","updateAttributes","attributes","Array","isArray","key","value","RichTextData","richTextValue","fromHTMLString","replacements","forEach","replacement","type","index","indexOf","countValue","create","html","innerHTML","text","String","formats","from","length","toHTMLString","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: new RichTextData( 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( newFootnotes ),\n\t\t},\n\t\tblocks: newBlocks,\n\t};\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAKA,IAAAC,kBAAA,GAAAC,sBAAA,CAAAF,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,IAAIG,YAAY,GAAG,CAAC,CAAC;AAEd,SAASC,uBAAuBA,CAAEC,MAAM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iB,YAAY,CAAC,CAAC,GAC5BjB,aAAa;IAClB;IAEA,OAAON,UAAU;EAClB;EAEA,SAASwB,sBAAsBA,CAAEC,QAAQ,EAAG;IAC3C,OAAOA,QAAQ,CAAClC,GAAG,CAAImC,KAAK,IAAM;MACjC,OAAO;QACN,GAAGA,KAAK;QACR1B,UAAU,EAAED,gBAAgB,CAAE2B,KAAK,CAAC1B,UAAW,CAAC;QAChD2B,WAAW,EAAEH,sBAAsB,CAAEE,KAAK,CAACC,WAAY;MACxD,CAAC;IACF,CAAE,CAAC;EACJ;;EAEA;EACA;EACA,MAAMC,SAAS,GAAGJ,sBAAsB,CAAE3C,MAAO,CAAC;EAElDF,YAAY,GAAG;IACd,GAAGA,YAAY;IACf,GAAGK,SAAS,CAAC6C,MAAM,CAAE,CAAEC,GAAG,EAAEtC,EAAE,KAAM;MACnC,IAAK,CAAEN,QAAQ,CAAC6C,QAAQ,CAAEvC,EAAE,CAACC,EAAG,CAAC,EAAG;QACnCqC,GAAG,CAAEtC,EAAE,CAACC,EAAE,CAAE,GAAGD,EAAE;MAClB;MACA,OAAOsC,GAAG;IACX,CAAC,EAAE,CAAC,CAAE;EACP,CAAC;EAED,OAAO;IACNhD,IAAI,EAAE;MACL,GAAGA,IAAI;MACPE,SAAS,EAAEI,IAAI,CAAC4C,SAAS,CAAErC,YAAa;IACzC,CAAC;IACDd,MAAM,EAAE+C;EACT,CAAC;AACF"}
|
package/build/hooks/constants.js
CHANGED
|
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Status = void 0;
|
|
7
|
-
let Status = /*#__PURE__*/function (Status) {
|
|
7
|
+
let Status = exports.Status = /*#__PURE__*/function (Status) {
|
|
8
8
|
Status["Idle"] = "IDLE";
|
|
9
9
|
Status["Resolving"] = "RESOLVING";
|
|
10
10
|
Status["Error"] = "ERROR";
|
|
11
11
|
Status["Success"] = "SUCCESS";
|
|
12
12
|
return Status;
|
|
13
13
|
}({});
|
|
14
|
-
exports.Status = Status;
|
|
15
14
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Status","exports"],"sources":["@wordpress/core-data/src/hooks/constants.ts"],"sourcesContent":["export const enum Status {\n\tIdle = 'IDLE',\n\tResolving = 'RESOLVING',\n\tError = 'ERROR',\n\tSuccess = 'SUCCESS',\n}\n"],"mappings":";;;;;;IAAkBA,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA
|
|
1
|
+
{"version":3,"names":["Status","exports"],"sources":["@wordpress/core-data/src/hooks/constants.ts"],"sourcesContent":["export const enum Status {\n\tIdle = 'IDLE',\n\tResolving = 'RESOLVING',\n\tError = 'ERROR',\n\tSuccess = 'SUCCESS',\n}\n"],"mappings":";;;;;;IAAkBA,MAAM,GAAAC,OAAA,CAAAD,MAAA,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA"}
|
package/build/hooks/index.js
CHANGED
|
@@ -42,6 +42,6 @@ Object.defineProperty(exports, "useResourcePermissions", {
|
|
|
42
42
|
var _useEntityRecord = _interopRequireWildcard(require("./use-entity-record"));
|
|
43
43
|
var _useEntityRecords = _interopRequireWildcard(require("./use-entity-records"));
|
|
44
44
|
var _useResourcePermissions = _interopRequireWildcard(require("./use-resource-permissions"));
|
|
45
|
-
function _getRequireWildcardCache(
|
|
46
|
-
function _interopRequireWildcard(
|
|
45
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
47
47
|
//# sourceMappingURL=index.js.map
|
package/build/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_useEntityRecord","_interopRequireWildcard","require","_useEntityRecords","_useResourcePermissions","_getRequireWildcardCache","
|
|
1
|
+
{"version":3,"names":["_useEntityRecord","_interopRequireWildcard","require","_useEntityRecords","_useResourcePermissions","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set"],"sources":["@wordpress/core-data/src/hooks/index.ts"],"sourcesContent":["export {\n\tdefault as useEntityRecord,\n\t__experimentalUseEntityRecord,\n} from './use-entity-record';\nexport {\n\tdefault as useEntityRecords,\n\t__experimentalUseEntityRecords,\n} from './use-entity-records';\nexport {\n\tdefault as useResourcePermissions,\n\t__experimentalUseResourcePermissions,\n} from './use-resource-permissions';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAIA,IAAAC,iBAAA,GAAAF,uBAAA,CAAAC,OAAA;AAIA,IAAAE,uBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAGoC,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAc,CAAA,SAAAI,CAAA,GAAAR,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAI,CAAA,KAAAA,CAAA,CAAAX,GAAA,IAAAW,CAAA,CAAAC,GAAA,IAAAR,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAI,CAAA,IAAAV,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAgB,GAAA,CAAAnB,CAAA,EAAAQ,CAAA,GAAAA,CAAA"}
|
package/build/hooks/memoize.js
CHANGED
|
@@ -10,6 +10,5 @@ var _memize = _interopRequireDefault(require("memize"));
|
|
|
10
10
|
* External dependencies
|
|
11
11
|
*/
|
|
12
12
|
// re-export due to restrictive esModuleInterop setting
|
|
13
|
-
var _default = _memize.default;
|
|
14
|
-
exports.default = _default;
|
|
13
|
+
var _default = exports.default = _memize.default;
|
|
15
14
|
//# sourceMappingURL=memoize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_memize","_interopRequireDefault","require","_default","
|
|
1
|
+
{"version":3,"names":["_memize","_interopRequireDefault","require","_default","exports","default","memoize"],"sources":["@wordpress/core-data/src/hooks/memoize.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport memoize from 'memize';\n\n// re-export due to restrictive esModuleInterop setting\nexport default memoize;\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAHA;AACA;AACA;AAGA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACeC,eAAO"}
|
|
@@ -17,8 +17,7 @@ var _constants = require("./constants");
|
|
|
17
17
|
* Internal dependencies
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
const META_SELECTORS = ['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'];
|
|
21
|
-
exports.META_SELECTORS = META_SELECTORS;
|
|
20
|
+
const META_SELECTORS = exports.META_SELECTORS = ['getIsResolving', 'hasStartedResolution', 'hasFinishedResolution', 'isResolving', 'getCachedResolvers'];
|
|
22
21
|
/**
|
|
23
22
|
* Like useSelect, but the selectors return objects containing
|
|
24
23
|
* both the original data AND the resolution info.
|