@wordpress/core-data 6.19.6 → 6.20.1
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/README.md +1 -1
- package/build/entity-provider.js +2 -1
- package/build/entity-provider.js.map +1 -1
- package/build/fetch/__experimental-fetch-link-suggestions.js +12 -3
- package/build/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
- package/build/footnotes/get-footnotes-order.js +26 -11
- package/build/footnotes/get-footnotes-order.js.map +1 -1
- package/build/footnotes/index.js +23 -11
- package/build/footnotes/index.js.map +1 -1
- package/build/hooks/use-entity-record.js +1 -1
- package/build/hooks/use-entity-record.js.map +1 -1
- package/build/private-apis.js +1 -1
- package/build/private-apis.js.map +1 -1
- package/build/selectors.js +3 -0
- package/build/selectors.js.map +1 -1
- package/build-module/entity-provider.js +1 -1
- package/build-module/fetch/__experimental-fetch-link-suggestions.js +12 -3
- package/build-module/fetch/__experimental-fetch-link-suggestions.js.map +1 -1
- package/build-module/footnotes/get-footnotes-order.js +26 -11
- package/build-module/footnotes/get-footnotes-order.js.map +1 -1
- package/build-module/footnotes/index.js +23 -11
- package/build-module/footnotes/index.js.map +1 -1
- package/build-module/hooks/use-entity-record.js +1 -1
- package/build-module/hooks/use-entity-record.js.map +1 -1
- package/build-module/private-apis.js +1 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/selectors.js +3 -0
- package/build-module/selectors.js.map +1 -1
- package/build-types/fetch/__experimental-fetch-link-suggestions.d.ts.map +1 -1
- package/build-types/footnotes/get-footnotes-order.d.ts.map +1 -1
- package/build-types/footnotes/index.d.ts.map +1 -1
- package/build-types/hooks/use-entity-record.d.ts +1 -1
- package/build-types/selectors.d.ts.map +1 -1
- package/package.json +17 -16
- package/src/fetch/__experimental-fetch-link-suggestions.js +13 -2
- package/src/fetch/test/__experimental-fetch-link-suggestions.js +66 -15
- package/src/footnotes/get-footnotes-order.js +23 -11
- package/src/footnotes/index.js +21 -22
- package/src/hooks/use-entity-record.ts +1 -1
- package/src/private-apis.js +1 -1
- package/src/selectors.ts +3 -0
- package/src/test/entity-provider.js +3 -2
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
package/build/selectors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_rememo","_interopRequireDefault","require","_data","_url","_deprecated","_name","_queriedData","_entities","_utils","EMPTY_OBJECT","isRequestingEmbedPreview","createRegistrySelector","select","state","url","STORE_NAME","isResolving","exports","getAuthors","query","deprecated","since","alternative","path","addQueryArgs","getUserQueryResults","getCurrentUser","currentUser","createSelector","queryID","_state$users$queries$","queryResults","users","queries","map","id","byId","getEntitiesByKind","kind","getEntitiesConfig","entities","config","filter","entity","getEntity","name","getEntityConfig","find","getEntityRecord","key","_query$context","queriedState","records","queriedData","undefined","context","itemIsComplete","items","item","_fields","_getNormalizedCommaSe","filteredItem","fields","getNormalizedCommaSeparable","f","length","field","split","value","forEach","fieldName","setNestedValue","recordId","_query$context2","__experimentalGetEntityRecordNoResolver","getRawEntityRecord","record","Object","keys","reduce","accumulator","_key","isRawAttribute","_record$_key$raw","raw","_query$context3","hasEntityRecords","Array","isArray","getEntityRecords","getQueriedItems","__experimentalGetDirtyEntityRecords","dirtyRecords","primaryKeys","edits","primaryKey","hasEditsForEntityRecord","entityConfig","entityRecord","getEditedEntityRecord","push","DEFAULT_ENTITY_KEY","title","getTitle","__experimentalGetEntitiesBeingSaved","recordsBeingSaved","saving","isSavingEntityRecord","getEntityRecordEdits","getEntityRecordNonTransientEdits","transientEdits","acc","_query$context4","isAutosavingEntityRecord","_state$entities$recor","pending","isAutosave","Boolean","_state$entities$recor2","isDeletingEntityRecord","_state$entities$recor3","deleting","getLastEntitySaveError","error","getLastEntityDeleteError","getUndoEdit","getRedoEdit","hasUndo","undoManager","hasRedo","getCurrentTheme","currentTheme","__experimentalGetCurrentGlobalStylesId","currentGlobalStylesId","getThemeSupports","_getCurrentTheme$them","theme_supports","getEmbedPreview","embedPreviews","isPreviewEmbedFallback","preview","oEmbedLinkCheck","html","canUser","action","resource","join","userPermissions","canUserEditEntityRecord","__unstable_rest_base","getAutosaves","postType","postId","autosaves","getAutosave","authorId","autosave","author","hasFetchedAutosaves","hasFinishedResolution","getReferenceByDistinctEdits","editsReference","__experimentalGetTemplateForLink","link","__experimentalGetCurrentThemeBaseGlobalStyles","themeBaseGlobalStyles","stylesheet","__experimentalGetCurrentThemeGlobalStylesVariations","themeGlobalStyleVariations","getBlockPatterns","blockPatterns","getBlockPatternCategories","blockPatternCategories","getUserPatternCategories","userPatternCategories","getCurrentThemeGlobalStylesRevisions","themeGlobalStyleRevisions"],"sources":["@wordpress/core-data/src/selectors.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { addQueryArgs } from '@wordpress/url';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { getQueriedItems } from './queried-data';\nimport { DEFAULT_ENTITY_KEY } from './entities';\nimport {\n\tgetNormalizedCommaSeparable,\n\tisRawAttribute,\n\tsetNestedValue,\n} from './utils';\nimport type * as ET from './entity-types';\nimport type { UndoManager } from '@wordpress/undo-manager';\n\n// This is an incomplete, high-level approximation of the State type.\n// It makes the selectors slightly more safe, but is intended to evolve\n// into a more detailed representation over time.\n// See https://github.com/WordPress/gutenberg/pull/40025#discussion_r865410589 for more context.\nexport interface State {\n\tautosaves: Record< string | number, Array< unknown > >;\n\tblockPatterns: Array< unknown >;\n\tblockPatternCategories: Array< unknown >;\n\tcurrentGlobalStylesId: string;\n\tcurrentTheme: string;\n\tcurrentUser: ET.User< 'edit' >;\n\tembedPreviews: Record< string, { html: string } >;\n\tentities: EntitiesState;\n\tthemeBaseGlobalStyles: Record< string, Object >;\n\tthemeGlobalStyleVariations: Record< string, string >;\n\tthemeGlobalStyleRevisions: Record< number, Object >;\n\tundoManager: UndoManager;\n\tuserPermissions: Record< string, boolean >;\n\tusers: UserState;\n\tnavigationFallbackId: EntityRecordKey;\n\tuserPatternCategories: Array< UserPatternCategory >;\n}\n\ntype EntityRecordKey = string | number;\n\ninterface EntitiesState {\n\tconfig: EntityConfig[];\n\trecords: Record< string, Record< string, EntityState< ET.EntityRecord > > >;\n}\n\ninterface QueriedData {\n\titems: Record< ET.Context, Record< number, ET.EntityRecord > >;\n\titemIsComplete: Record< ET.Context, Record< number, boolean > >;\n\tqueries: Record< ET.Context, Record< string, Array< number > > >;\n}\n\ninterface EntityState< EntityRecord extends ET.EntityRecord > {\n\tedits: Record< string, Partial< EntityRecord > >;\n\tsaving: Record<\n\t\tstring,\n\t\tPartial< { pending: boolean; isAutosave: boolean; error: Error } >\n\t>;\n\tdeleting: Record< string, Partial< { pending: boolean; error: Error } > >;\n\tqueriedData: QueriedData;\n}\n\ninterface EntityConfig {\n\tname: string;\n\tkind: string;\n}\n\ninterface UserState {\n\tqueries: Record< string, EntityRecordKey[] >;\n\tbyId: Record< EntityRecordKey, ET.User< 'edit' > >;\n}\n\nexport interface UserPatternCategory {\n\tid: number;\n\tname: string;\n\tlabel: string;\n\tslug: string;\n\tdescription: string;\n}\n\ntype Optional< T > = T | undefined;\n\n/**\n * HTTP Query parameters sent with the API request to fetch the entity records.\n */\ntype GetRecordsHttpQuery = Record< string, any >;\n\n/**\n * Shared reference to an empty object for cases where it is important to avoid\n * returning a new object reference on every invocation, as in a connected or\n * other pure component which performs `shouldComponentUpdate` check on props.\n * This should be used as a last resort, since the normalized data should be\n * maintained by the reducer result in state.\n */\nconst EMPTY_OBJECT = {};\n\n/**\n * Returns true if a request is in progress for embed preview data, or false\n * otherwise.\n *\n * @param state Data state.\n * @param url URL the preview would be for.\n *\n * @return Whether a request is in progress for an embed preview.\n */\nexport const isRequestingEmbedPreview = createRegistrySelector(\n\t( select: any ) =>\n\t\t( state: State, url: string ): boolean => {\n\t\t\treturn select( STORE_NAME ).isResolving( 'getEmbedPreview', [\n\t\t\t\turl,\n\t\t\t] );\n\t\t}\n);\n\n/**\n * Returns all available authors.\n *\n * @deprecated since 11.3. Callers should use `select( 'core' ).getUsers({ who: 'authors' })` instead.\n *\n * @param state Data state.\n * @param query Optional object of query parameters to\n * include with request. For valid query parameters see the [Users page](https://developer.wordpress.org/rest-api/reference/users/) in the REST API Handbook and see the arguments for [List Users](https://developer.wordpress.org/rest-api/reference/users/#list-users) and [Retrieve a User](https://developer.wordpress.org/rest-api/reference/users/#retrieve-a-user).\n * @return Authors list.\n */\nexport function getAuthors(\n\tstate: State,\n\tquery?: GetRecordsHttpQuery\n): ET.User[] {\n\tdeprecated( \"select( 'core' ).getAuthors()\", {\n\t\tsince: '5.9',\n\t\talternative: \"select( 'core' ).getUsers({ who: 'authors' })\",\n\t} );\n\n\tconst path = addQueryArgs(\n\t\t'/wp/v2/users/?who=authors&per_page=100',\n\t\tquery\n\t);\n\treturn getUserQueryResults( state, path );\n}\n\n/**\n * Returns the current user.\n *\n * @param state Data state.\n *\n * @return Current user object.\n */\nexport function getCurrentUser( state: State ): ET.User< 'edit' > {\n\treturn state.currentUser;\n}\n\n/**\n * Returns all the users returned by a query ID.\n *\n * @param state Data state.\n * @param queryID Query ID.\n *\n * @return Users list.\n */\nexport const getUserQueryResults = createSelector(\n\t( state: State, queryID: string ): ET.User< 'edit' >[] => {\n\t\tconst queryResults = state.users.queries[ queryID ] ?? [];\n\n\t\treturn queryResults.map( ( id ) => state.users.byId[ id ] );\n\t},\n\t( state: State, queryID: string ) => [\n\t\tstate.users.queries[ queryID ],\n\t\tstate.users.byId,\n\t]\n);\n\n/**\n * Returns the loaded entities for the given kind.\n *\n * @deprecated since WordPress 6.0. Use getEntitiesConfig instead\n * @param state Data state.\n * @param kind Entity kind.\n *\n * @return Array of entities with config matching kind.\n */\nexport function getEntitiesByKind( state: State, kind: string ): Array< any > {\n\tdeprecated( \"wp.data.select( 'core' ).getEntitiesByKind()\", {\n\t\tsince: '6.0',\n\t\talternative: \"wp.data.select( 'core' ).getEntitiesConfig()\",\n\t} );\n\treturn getEntitiesConfig( state, kind );\n}\n\n/**\n * Returns the loaded entities for the given kind.\n *\n * @param state Data state.\n * @param kind Entity kind.\n *\n * @return Array of entities with config matching kind.\n */\nexport function getEntitiesConfig( state: State, kind: string ): Array< any > {\n\treturn state.entities.config.filter( ( entity ) => entity.kind === kind );\n}\n\n/**\n * Returns the entity config given its kind and name.\n *\n * @deprecated since WordPress 6.0. Use getEntityConfig instead\n * @param state Data state.\n * @param kind Entity kind.\n * @param name Entity name.\n *\n * @return Entity config\n */\nexport function getEntity( state: State, kind: string, name: string ): any {\n\tdeprecated( \"wp.data.select( 'core' ).getEntity()\", {\n\t\tsince: '6.0',\n\t\talternative: \"wp.data.select( 'core' ).getEntityConfig()\",\n\t} );\n\treturn getEntityConfig( state, kind, name );\n}\n\n/**\n * Returns the entity config given its kind and name.\n *\n * @param state Data state.\n * @param kind Entity kind.\n * @param name Entity name.\n *\n * @return Entity config\n */\nexport function getEntityConfig(\n\tstate: State,\n\tkind: string,\n\tname: string\n): any {\n\treturn state.entities.config?.find(\n\t\t( config ) => config.kind === kind && config.name === name\n\t);\n}\n\n/**\n * GetEntityRecord is declared as a *callable interface* with\n * two signatures to work around the fact that TypeScript doesn't\n * allow currying generic functions:\n *\n * ```ts\n * \t\ttype CurriedState = F extends ( state: any, ...args: infer P ) => infer R\n * \t\t\t? ( ...args: P ) => R\n * \t\t\t: F;\n * \t\ttype Selector = <K extends string | number>(\n * state: any,\n * kind: K,\n * key: K extends string ? 'string value' : false\n * ) => K;\n * \t\ttype BadlyInferredSignature = CurriedState< Selector >\n * // BadlyInferredSignature evaluates to:\n * // (kind: string number, key: false | \"string value\") => string number\n * ```\n *\n * The signature without the state parameter shipped as CurriedSignature\n * is used in the return value of `select( coreStore )`.\n *\n * See https://github.com/WordPress/gutenberg/pull/41578 for more details.\n */\nexport interface GetEntityRecord {\n\t<\n\t\tEntityRecord extends\n\t\t\t| ET.EntityRecord< any >\n\t\t\t| Partial< ET.EntityRecord< any > >,\n\t>(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\tkey: EntityRecordKey,\n\t\tquery?: GetRecordsHttpQuery\n\t): EntityRecord | undefined;\n\n\tCurriedSignature: <\n\t\tEntityRecord extends\n\t\t\t| ET.EntityRecord< any >\n\t\t\t| Partial< ET.EntityRecord< any > >,\n\t>(\n\t\tkind: string,\n\t\tname: string,\n\t\tkey: EntityRecordKey,\n\t\tquery?: GetRecordsHttpQuery\n\t) => EntityRecord | undefined;\n}\n\n/**\n * Returns the Entity's record object by key. Returns `null` if the value is not\n * yet received, undefined if the value entity is known to not exist, or the\n * entity object if it exists and is received.\n *\n * @param state State tree\n * @param kind Entity kind.\n * @param name Entity name.\n * @param key Record's key\n * @param query Optional query. If requesting specific\n * fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available \"Retrieve a [Entity kind]\".\n *\n * @return Record.\n */\nexport const getEntityRecord = createSelector(\n\t( <\n\t\tEntityRecord extends\n\t\t\t| ET.EntityRecord< any >\n\t\t\t| Partial< ET.EntityRecord< any > >,\n\t>(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\tkey: EntityRecordKey,\n\t\tquery?: GetRecordsHttpQuery\n\t): EntityRecord | undefined => {\n\t\tconst queriedState =\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData;\n\t\tif ( ! queriedState ) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst context = query?.context ?? 'default';\n\n\t\tif ( query === undefined ) {\n\t\t\t// If expecting a complete item, validate that completeness.\n\t\t\tif ( ! queriedState.itemIsComplete[ context ]?.[ key ] ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn queriedState.items[ context ][ key ];\n\t\t}\n\n\t\tconst item = queriedState.items[ context ]?.[ key ];\n\t\tif ( item && query._fields ) {\n\t\t\tconst filteredItem = {};\n\t\t\tconst fields = getNormalizedCommaSeparable( query._fields ) ?? [];\n\t\t\tfor ( let f = 0; f < fields.length; f++ ) {\n\t\t\t\tconst field = fields[ f ].split( '.' );\n\t\t\t\tlet value = item;\n\t\t\t\tfield.forEach( ( fieldName ) => {\n\t\t\t\t\tvalue = value?.[ fieldName ];\n\t\t\t\t} );\n\t\t\t\tsetNestedValue( filteredItem, field, value );\n\t\t\t}\n\t\t\treturn filteredItem as EntityRecord;\n\t\t}\n\n\t\treturn item;\n\t} ) as GetEntityRecord,\n\t( state: State, kind, name, recordId, query ) => {\n\t\tconst context = query?.context ?? 'default';\n\t\treturn [\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData?.items[\n\t\t\t\tcontext\n\t\t\t]?.[ recordId ],\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData\n\t\t\t\t?.itemIsComplete[ context ]?.[ recordId ],\n\t\t];\n\t}\n) as GetEntityRecord;\n\n/**\n * Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity records from the API if the entity record isn't available in the local state.\n *\n * @param state State tree\n * @param kind Entity kind.\n * @param name Entity name.\n * @param key Record's key\n *\n * @return Record.\n */\nexport function __experimentalGetEntityRecordNoResolver<\n\tEntityRecord extends ET.EntityRecord< any >,\n>( state: State, kind: string, name: string, key: EntityRecordKey ) {\n\treturn getEntityRecord< EntityRecord >( state, kind, name, key );\n}\n\n/**\n * Returns the entity's record object by key,\n * with its attributes mapped to their raw values.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param key Record's key.\n *\n * @return Object with the entity's raw attributes.\n */\nexport const getRawEntityRecord = createSelector(\n\t< EntityRecord extends ET.EntityRecord< any > >(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\tkey: EntityRecordKey\n\t): EntityRecord | undefined => {\n\t\tconst record = getEntityRecord< EntityRecord >(\n\t\t\tstate,\n\t\t\tkind,\n\t\t\tname,\n\t\t\tkey\n\t\t);\n\t\treturn (\n\t\t\trecord &&\n\t\t\tObject.keys( record ).reduce( ( accumulator, _key ) => {\n\t\t\t\tif (\n\t\t\t\t\tisRawAttribute( getEntityConfig( state, kind, name ), _key )\n\t\t\t\t) {\n\t\t\t\t\t// Because edits are the \"raw\" attribute values,\n\t\t\t\t\t// we return those from record selectors to make rendering,\n\t\t\t\t\t// comparisons, and joins with edits easier.\n\t\t\t\t\taccumulator[ _key ] = record[ _key ]?.raw ?? record[ _key ];\n\t\t\t\t} else {\n\t\t\t\t\taccumulator[ _key ] = record[ _key ];\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, {} as any )\n\t\t);\n\t},\n\t(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\trecordId: EntityRecordKey,\n\t\tquery?: GetRecordsHttpQuery\n\t) => {\n\t\tconst context = query?.context ?? 'default';\n\t\treturn [\n\t\t\tstate.entities.config,\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData?.items[\n\t\t\t\tcontext\n\t\t\t]?.[ recordId ],\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData\n\t\t\t\t?.itemIsComplete[ context ]?.[ recordId ],\n\t\t];\n\t}\n);\n\n/**\n * Returns true if records have been received for the given set of parameters,\n * or false otherwise.\n *\n * @param state State tree\n * @param kind Entity kind.\n * @param name Entity name.\n * @param query Optional terms query. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for \"List [Entity kind]s\".\n *\n * @return Whether entity records have been received.\n */\nexport function hasEntityRecords(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\tquery?: GetRecordsHttpQuery\n): boolean {\n\treturn Array.isArray( getEntityRecords( state, kind, name, query ) );\n}\n\n/**\n * GetEntityRecord is declared as a *callable interface* with\n * two signatures to work around the fact that TypeScript doesn't\n * allow currying generic functions.\n *\n * @see GetEntityRecord\n * @see https://github.com/WordPress/gutenberg/pull/41578\n */\nexport interface GetEntityRecords {\n\t<\n\t\tEntityRecord extends\n\t\t\t| ET.EntityRecord< any >\n\t\t\t| Partial< ET.EntityRecord< any > >,\n\t>(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\tquery?: GetRecordsHttpQuery\n\t): EntityRecord[] | null;\n\n\tCurriedSignature: <\n\t\tEntityRecord extends\n\t\t\t| ET.EntityRecord< any >\n\t\t\t| Partial< ET.EntityRecord< any > >,\n\t>(\n\t\tkind: string,\n\t\tname: string,\n\t\tquery?: GetRecordsHttpQuery\n\t) => EntityRecord[] | null;\n}\n\n/**\n * Returns the Entity's records.\n *\n * @param state State tree\n * @param kind Entity kind.\n * @param name Entity name.\n * @param query Optional terms query. If requesting specific\n * fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for \"List [Entity kind]s\".\n *\n * @return Records.\n */\nexport const getEntityRecords = ( <\n\tEntityRecord extends\n\t\t| ET.EntityRecord< any >\n\t\t| Partial< ET.EntityRecord< any > >,\n>(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\tquery: GetRecordsHttpQuery\n): EntityRecord[] | null => {\n\t// Queried data state is prepopulated for all known entities. If this is not\n\t// assigned for the given parameters, then it is known to not exist.\n\tconst queriedState =\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData;\n\tif ( ! queriedState ) {\n\t\treturn null;\n\t}\n\treturn getQueriedItems( queriedState, query );\n} ) as GetEntityRecords;\n\ntype DirtyEntityRecord = {\n\ttitle: string;\n\tkey: EntityRecordKey;\n\tname: string;\n\tkind: string;\n};\n/**\n * Returns the list of dirty entity records.\n *\n * @param state State tree.\n *\n * @return The list of updated records\n */\nexport const __experimentalGetDirtyEntityRecords = createSelector(\n\t( state: State ): Array< DirtyEntityRecord > => {\n\t\tconst {\n\t\t\tentities: { records },\n\t\t} = state;\n\t\tconst dirtyRecords: DirtyEntityRecord[] = [];\n\t\tObject.keys( records ).forEach( ( kind ) => {\n\t\t\tObject.keys( records[ kind ] ).forEach( ( name ) => {\n\t\t\t\tconst primaryKeys = (\n\t\t\t\t\tObject.keys( records[ kind ][ name ].edits ) as string[]\n\t\t\t\t ).filter(\n\t\t\t\t\t( primaryKey ) =>\n\t\t\t\t\t\t// The entity record must exist (not be deleted),\n\t\t\t\t\t\t// and it must have edits.\n\t\t\t\t\t\tgetEntityRecord( state, kind, name, primaryKey ) &&\n\t\t\t\t\t\thasEditsForEntityRecord( state, kind, name, primaryKey )\n\t\t\t\t);\n\n\t\t\t\tif ( primaryKeys.length ) {\n\t\t\t\t\tconst entityConfig = getEntityConfig( state, kind, name );\n\t\t\t\t\tprimaryKeys.forEach( ( primaryKey ) => {\n\t\t\t\t\t\tconst entityRecord = getEditedEntityRecord(\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tprimaryKey\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdirtyRecords.push( {\n\t\t\t\t\t\t\t// We avoid using primaryKey because it's transformed into a string\n\t\t\t\t\t\t\t// when it's used as an object key.\n\t\t\t\t\t\t\tkey: entityRecord\n\t\t\t\t\t\t\t\t? entityRecord[\n\t\t\t\t\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY\n\t\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tentityConfig?.getTitle?.( entityRecord ) || '',\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t} );\n\n\t\treturn dirtyRecords;\n\t},\n\t( state ) => [ state.entities.records ]\n);\n\n/**\n * Returns the list of entities currently being saved.\n *\n * @param state State tree.\n *\n * @return The list of records being saved.\n */\nexport const __experimentalGetEntitiesBeingSaved = createSelector(\n\t( state: State ): Array< DirtyEntityRecord > => {\n\t\tconst {\n\t\t\tentities: { records },\n\t\t} = state;\n\t\tconst recordsBeingSaved: DirtyEntityRecord[] = [];\n\t\tObject.keys( records ).forEach( ( kind ) => {\n\t\t\tObject.keys( records[ kind ] ).forEach( ( name ) => {\n\t\t\t\tconst primaryKeys = (\n\t\t\t\t\tObject.keys( records[ kind ][ name ].saving ) as string[]\n\t\t\t\t ).filter( ( primaryKey ) =>\n\t\t\t\t\tisSavingEntityRecord( state, kind, name, primaryKey )\n\t\t\t\t);\n\n\t\t\t\tif ( primaryKeys.length ) {\n\t\t\t\t\tconst entityConfig = getEntityConfig( state, kind, name );\n\t\t\t\t\tprimaryKeys.forEach( ( primaryKey ) => {\n\t\t\t\t\t\tconst entityRecord = getEditedEntityRecord(\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tprimaryKey\n\t\t\t\t\t\t);\n\t\t\t\t\t\trecordsBeingSaved.push( {\n\t\t\t\t\t\t\t// We avoid using primaryKey because it's transformed into a string\n\t\t\t\t\t\t\t// when it's used as an object key.\n\t\t\t\t\t\t\tkey: entityRecord\n\t\t\t\t\t\t\t\t? entityRecord[\n\t\t\t\t\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY\n\t\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tentityConfig?.getTitle?.( entityRecord ) || '',\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t} );\n\t\treturn recordsBeingSaved;\n\t},\n\t( state ) => [ state.entities.records ]\n);\n\n/**\n * Returns the specified entity record's edits.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return The entity record's edits.\n */\nexport function getEntityRecordEdits(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): Optional< any > {\n\treturn state.entities.records?.[ kind ]?.[ name ]?.edits?.[\n\t\trecordId as string | number\n\t];\n}\n\n/**\n * Returns the specified entity record's non transient edits.\n *\n * Transient edits don't create an undo level, and\n * are not considered for change detection.\n * They are defined in the entity's config.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return The entity record's non transient edits.\n */\nexport const getEntityRecordNonTransientEdits = createSelector(\n\t(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\trecordId: EntityRecordKey\n\t): Optional< any > => {\n\t\tconst { transientEdits } = getEntityConfig( state, kind, name ) || {};\n\t\tconst edits = getEntityRecordEdits( state, kind, name, recordId ) || {};\n\t\tif ( ! transientEdits ) {\n\t\t\treturn edits;\n\t\t}\n\t\treturn Object.keys( edits ).reduce( ( acc, key ) => {\n\t\t\tif ( ! transientEdits[ key ] ) {\n\t\t\t\tacc[ key ] = edits[ key ];\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, {} );\n\t},\n\t( state: State, kind: string, name: string, recordId: EntityRecordKey ) => [\n\t\tstate.entities.config,\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.edits?.[ recordId ],\n\t]\n);\n\n/**\n * Returns true if the specified entity record has edits,\n * and false otherwise.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return Whether the entity record has edits or not.\n */\nexport function hasEditsForEntityRecord(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): boolean {\n\treturn (\n\t\tisSavingEntityRecord( state, kind, name, recordId ) ||\n\t\tObject.keys(\n\t\t\tgetEntityRecordNonTransientEdits( state, kind, name, recordId )\n\t\t).length > 0\n\t);\n}\n\n/**\n * Returns the specified entity record, merged with its edits.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return The entity record, merged with its edits.\n */\nexport const getEditedEntityRecord = createSelector(\n\t< EntityRecord extends ET.EntityRecord< any > >(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\trecordId: EntityRecordKey\n\t): ET.Updatable< EntityRecord > | undefined => ( {\n\t\t...getRawEntityRecord( state, kind, name, recordId ),\n\t\t...getEntityRecordEdits( state, kind, name, recordId ),\n\t} ),\n\t(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\trecordId: EntityRecordKey,\n\t\tquery?: GetRecordsHttpQuery\n\t) => {\n\t\tconst context = query?.context ?? 'default';\n\t\treturn [\n\t\t\tstate.entities.config,\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData.items[\n\t\t\t\tcontext\n\t\t\t]?.[ recordId ],\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData\n\t\t\t\t.itemIsComplete[ context ]?.[ recordId ],\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.edits?.[ recordId ],\n\t\t];\n\t}\n);\n\n/**\n * Returns true if the specified entity record is autosaving, and false otherwise.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return Whether the entity record is autosaving or not.\n */\nexport function isAutosavingEntityRecord(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): boolean {\n\tconst { pending, isAutosave } =\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.saving?.[ recordId ] ?? {};\n\treturn Boolean( pending && isAutosave );\n}\n\n/**\n * Returns true if the specified entity record is saving, and false otherwise.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return Whether the entity record is saving or not.\n */\nexport function isSavingEntityRecord(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): boolean {\n\treturn (\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.saving?.[\n\t\t\trecordId as EntityRecordKey\n\t\t]?.pending ?? false\n\t);\n}\n\n/**\n * Returns true if the specified entity record is deleting, and false otherwise.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return Whether the entity record is deleting or not.\n */\nexport function isDeletingEntityRecord(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): boolean {\n\treturn (\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.deleting?.[\n\t\t\trecordId as EntityRecordKey\n\t\t]?.pending ?? false\n\t);\n}\n\n/**\n * Returns the specified entity record's last save error.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return The entity record's save error.\n */\nexport function getLastEntitySaveError(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): any {\n\treturn state.entities.records?.[ kind ]?.[ name ]?.saving?.[ recordId ]\n\t\t?.error;\n}\n\n/**\n * Returns the specified entity record's last delete error.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return The entity record's save error.\n */\nexport function getLastEntityDeleteError(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): any {\n\treturn state.entities.records?.[ kind ]?.[ name ]?.deleting?.[ recordId ]\n\t\t?.error;\n}\n\n/**\n * Returns the previous edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * @deprecated since 6.3\n *\n * @param state State tree.\n *\n * @return The edit.\n */\nexport function getUndoEdit( state: State ): Optional< any > {\n\tdeprecated( \"select( 'core' ).getUndoEdit()\", {\n\t\tsince: '6.3',\n\t} );\n\treturn undefined;\n}\n\n/**\n * Returns the next edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * @deprecated since 6.3\n *\n * @param state State tree.\n *\n * @return The edit.\n */\nexport function getRedoEdit( state: State ): Optional< any > {\n\tdeprecated( \"select( 'core' ).getRedoEdit()\", {\n\t\tsince: '6.3',\n\t} );\n\treturn undefined;\n}\n\n/**\n * Returns true if there is a previous edit from the current undo offset\n * for the entity records edits history, and false otherwise.\n *\n * @param state State tree.\n *\n * @return Whether there is a previous edit or not.\n */\nexport function hasUndo( state: State ): boolean {\n\treturn state.undoManager.hasUndo();\n}\n\n/**\n * Returns true if there is a next edit from the current undo offset\n * for the entity records edits history, and false otherwise.\n *\n * @param state State tree.\n *\n * @return Whether there is a next edit or not.\n */\nexport function hasRedo( state: State ): boolean {\n\treturn state.undoManager.hasRedo();\n}\n\n/**\n * Return the current theme.\n *\n * @param state Data state.\n *\n * @return The current theme.\n */\nexport function getCurrentTheme( state: State ): any {\n\treturn getEntityRecord( state, 'root', 'theme', state.currentTheme );\n}\n\n/**\n * Return the ID of the current global styles object.\n *\n * @param state Data state.\n *\n * @return The current global styles ID.\n */\nexport function __experimentalGetCurrentGlobalStylesId( state: State ): string {\n\treturn state.currentGlobalStylesId;\n}\n\n/**\n * Return theme supports data in the index.\n *\n * @param state Data state.\n *\n * @return Index data.\n */\nexport function getThemeSupports( state: State ): any {\n\treturn getCurrentTheme( state )?.theme_supports ?? EMPTY_OBJECT;\n}\n\n/**\n * Returns the embed preview for the given URL.\n *\n * @param state Data state.\n * @param url Embedded URL.\n *\n * @return Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.\n */\nexport function getEmbedPreview( state: State, url: string ): any {\n\treturn state.embedPreviews[ url ];\n}\n\n/**\n * Determines if the returned preview is an oEmbed link fallback.\n *\n * WordPress can be configured to return a simple link to a URL if it is not embeddable.\n * We need to be able to determine if a URL is embeddable or not, based on what we\n * get back from the oEmbed preview API.\n *\n * @param state Data state.\n * @param url Embedded URL.\n *\n * @return Is the preview for the URL an oEmbed link fallback.\n */\nexport function isPreviewEmbedFallback( state: State, url: string ): boolean {\n\tconst preview = state.embedPreviews[ url ];\n\tconst oEmbedLinkCheck = '<a href=\"' + url + '\">' + url + '</a>';\n\tif ( ! preview ) {\n\t\treturn false;\n\t}\n\treturn preview.html === oEmbedLinkCheck;\n}\n\n/**\n * Returns whether the current user can perform the given action on the given\n * REST resource.\n *\n * Calling this may trigger an OPTIONS request to the REST API via the\n * `canUser()` resolver.\n *\n * https://developer.wordpress.org/rest-api/reference/\n *\n * @param state Data state.\n * @param action Action to check. One of: 'create', 'read', 'update', 'delete'.\n * @param resource REST resource to check, e.g. 'media' or 'posts'.\n * @param id Optional ID of the rest resource to check.\n *\n * @return Whether or not the user can perform the action,\n * or `undefined` if the OPTIONS request is still being made.\n */\nexport function canUser(\n\tstate: State,\n\taction: string,\n\tresource: string,\n\tid?: EntityRecordKey\n): boolean | undefined {\n\tconst key = [ action, resource, id ].filter( Boolean ).join( '/' );\n\treturn state.userPermissions[ key ];\n}\n\n/**\n * Returns whether the current user can edit the given entity.\n *\n * Calling this may trigger an OPTIONS request to the REST API via the\n * `canUser()` resolver.\n *\n * https://developer.wordpress.org/rest-api/reference/\n *\n * @param state Data state.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record's id.\n * @return Whether or not the user can edit,\n * or `undefined` if the OPTIONS request is still being made.\n */\nexport function canUserEditEntityRecord(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): boolean | undefined {\n\tconst entityConfig = getEntityConfig( state, kind, name );\n\tif ( ! entityConfig ) {\n\t\treturn false;\n\t}\n\tconst resource = entityConfig.__unstable_rest_base;\n\n\treturn canUser( state, 'update', resource, recordId );\n}\n\n/**\n * Returns the latest autosaves for the post.\n *\n * May return multiple autosaves since the backend stores one autosave per\n * author for each post.\n *\n * @param state State tree.\n * @param postType The type of the parent post.\n * @param postId The id of the parent post.\n *\n * @return An array of autosaves for the post, or undefined if there is none.\n */\nexport function getAutosaves(\n\tstate: State,\n\tpostType: string,\n\tpostId: EntityRecordKey\n): Array< any > | undefined {\n\treturn state.autosaves[ postId ];\n}\n\n/**\n * Returns the autosave for the post and author.\n *\n * @param state State tree.\n * @param postType The type of the parent post.\n * @param postId The id of the parent post.\n * @param authorId The id of the author.\n *\n * @return The autosave for the post and author.\n */\nexport function getAutosave< EntityRecord extends ET.EntityRecord< any > >(\n\tstate: State,\n\tpostType: string,\n\tpostId: EntityRecordKey,\n\tauthorId: EntityRecordKey\n): EntityRecord | undefined {\n\tif ( authorId === undefined ) {\n\t\treturn;\n\t}\n\n\tconst autosaves = state.autosaves[ postId ];\n\n\treturn autosaves?.find(\n\t\t( autosave: any ) => autosave.author === authorId\n\t) as EntityRecord | undefined;\n}\n\n/**\n * Returns true if the REST request for autosaves has completed.\n *\n * @param state State tree.\n * @param postType The type of the parent post.\n * @param postId The id of the parent post.\n *\n * @return True if the REST request was completed. False otherwise.\n */\nexport const hasFetchedAutosaves = createRegistrySelector(\n\t( select ) =>\n\t\t(\n\t\t\tstate: State,\n\t\t\tpostType: string,\n\t\t\tpostId: EntityRecordKey\n\t\t): boolean => {\n\t\t\treturn select( STORE_NAME ).hasFinishedResolution( 'getAutosaves', [\n\t\t\t\tpostType,\n\t\t\t\tpostId,\n\t\t\t] );\n\t\t}\n);\n\n/**\n * Returns a new reference when edited values have changed. This is useful in\n * inferring where an edit has been made between states by comparison of the\n * return values using strict equality.\n *\n * @example\n *\n * ```\n * const hasEditOccurred = (\n * getReferenceByDistinctEdits( beforeState ) !==\n * getReferenceByDistinctEdits( afterState )\n * );\n * ```\n *\n * @param state Editor state.\n *\n * @return A value whose reference will change only when an edit occurs.\n */\nexport function getReferenceByDistinctEdits( state ) {\n\treturn state.editsReference;\n}\n\n/**\n * Retrieve the frontend template used for a given link.\n *\n * @param state Editor state.\n * @param link Link.\n *\n * @return The template record.\n */\nexport function __experimentalGetTemplateForLink(\n\tstate: State,\n\tlink: string\n): Optional< ET.Updatable< ET.WpTemplate > > | null {\n\tconst records = getEntityRecords< ET.WpTemplate >(\n\t\tstate,\n\t\t'postType',\n\t\t'wp_template',\n\t\t{\n\t\t\t'find-template': link,\n\t\t}\n\t);\n\n\tif ( records?.length ) {\n\t\treturn getEditedEntityRecord< ET.WpTemplate >(\n\t\t\tstate,\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\trecords[ 0 ].id\n\t\t);\n\t}\n\treturn null;\n}\n\n/**\n * Retrieve the current theme's base global styles\n *\n * @param state Editor state.\n *\n * @return The Global Styles object.\n */\nexport function __experimentalGetCurrentThemeBaseGlobalStyles(\n\tstate: State\n): any {\n\tconst currentTheme = getCurrentTheme( state );\n\tif ( ! currentTheme ) {\n\t\treturn null;\n\t}\n\treturn state.themeBaseGlobalStyles[ currentTheme.stylesheet ];\n}\n\n/**\n * Return the ID of the current global styles object.\n *\n * @param state Data state.\n *\n * @return The current global styles ID.\n */\nexport function __experimentalGetCurrentThemeGlobalStylesVariations(\n\tstate: State\n): string | null {\n\tconst currentTheme = getCurrentTheme( state );\n\tif ( ! currentTheme ) {\n\t\treturn null;\n\t}\n\treturn state.themeGlobalStyleVariations[ currentTheme.stylesheet ];\n}\n\n/**\n * Retrieve the list of registered block patterns.\n *\n * @param state Data state.\n *\n * @return Block pattern list.\n */\nexport function getBlockPatterns( state: State ): Array< any > {\n\treturn state.blockPatterns;\n}\n\n/**\n * Retrieve the list of registered block pattern categories.\n *\n * @param state Data state.\n *\n * @return Block pattern category list.\n */\nexport function getBlockPatternCategories( state: State ): Array< any > {\n\treturn state.blockPatternCategories;\n}\n\n/**\n * Retrieve the registered user pattern categories.\n *\n * @param state Data state.\n *\n * @return User patterns category array.\n */\n\nexport function getUserPatternCategories(\n\tstate: State\n): Array< UserPatternCategory > {\n\treturn state.userPatternCategories;\n}\n\n/**\n * Returns the revisions of the current global styles theme.\n *\n * @param state Data state.\n *\n * @return The current global styles.\n */\nexport function getCurrentThemeGlobalStylesRevisions(\n\tstate: State\n): Array< object > | null {\n\tconst currentGlobalStylesId =\n\t\t__experimentalGetCurrentGlobalStylesId( state );\n\n\tif ( ! currentGlobalStylesId ) {\n\t\treturn null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EwH,qBAAqB,EAAG;IAC9B,OAAO,IAAI;EACZ;EAEA,OAAOxH,KAAK,CAACmK,yBAAyB,CAAE3C,qBAAqB,CAAE;AAChE"}
|
|
1
|
+
{"version":3,"names":["_rememo","_interopRequireDefault","require","_data","_url","_deprecated","_name","_queriedData","_entities","_utils","EMPTY_OBJECT","isRequestingEmbedPreview","createRegistrySelector","select","state","url","STORE_NAME","isResolving","exports","getAuthors","query","deprecated","since","alternative","path","addQueryArgs","getUserQueryResults","getCurrentUser","currentUser","createSelector","queryID","_state$users$queries$","queryResults","users","queries","map","id","byId","getEntitiesByKind","kind","getEntitiesConfig","entities","config","filter","entity","getEntity","name","getEntityConfig","find","getEntityRecord","key","_query$context","queriedState","records","queriedData","undefined","context","itemIsComplete","items","item","_fields","_getNormalizedCommaSe","filteredItem","fields","getNormalizedCommaSeparable","f","length","field","split","value","forEach","fieldName","setNestedValue","recordId","_query$context2","__experimentalGetEntityRecordNoResolver","getRawEntityRecord","record","Object","keys","reduce","accumulator","_key","isRawAttribute","_record$_key$raw","raw","_query$context3","hasEntityRecords","Array","isArray","getEntityRecords","getQueriedItems","__experimentalGetDirtyEntityRecords","dirtyRecords","primaryKeys","edits","primaryKey","hasEditsForEntityRecord","entityConfig","entityRecord","getEditedEntityRecord","push","DEFAULT_ENTITY_KEY","title","getTitle","__experimentalGetEntitiesBeingSaved","recordsBeingSaved","saving","isSavingEntityRecord","getEntityRecordEdits","getEntityRecordNonTransientEdits","transientEdits","acc","_query$context4","isAutosavingEntityRecord","_state$entities$recor","pending","isAutosave","Boolean","_state$entities$recor2","isDeletingEntityRecord","_state$entities$recor3","deleting","getLastEntitySaveError","error","getLastEntityDeleteError","getUndoEdit","getRedoEdit","hasUndo","undoManager","hasRedo","getCurrentTheme","currentTheme","__experimentalGetCurrentGlobalStylesId","currentGlobalStylesId","getThemeSupports","_getCurrentTheme$them","theme_supports","getEmbedPreview","embedPreviews","isPreviewEmbedFallback","preview","oEmbedLinkCheck","html","canUser","action","resource","join","userPermissions","canUserEditEntityRecord","__unstable_rest_base","getAutosaves","postType","postId","autosaves","getAutosave","authorId","autosave","author","hasFetchedAutosaves","hasFinishedResolution","getReferenceByDistinctEdits","editsReference","__experimentalGetTemplateForLink","link","__experimentalGetCurrentThemeBaseGlobalStyles","themeBaseGlobalStyles","stylesheet","__experimentalGetCurrentThemeGlobalStylesVariations","themeGlobalStyleVariations","getBlockPatterns","blockPatterns","getBlockPatternCategories","blockPatternCategories","getUserPatternCategories","userPatternCategories","getCurrentThemeGlobalStylesRevisions","themeGlobalStyleRevisions"],"sources":["@wordpress/core-data/src/selectors.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { addQueryArgs } from '@wordpress/url';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { STORE_NAME } from './name';\nimport { getQueriedItems } from './queried-data';\nimport { DEFAULT_ENTITY_KEY } from './entities';\nimport {\n\tgetNormalizedCommaSeparable,\n\tisRawAttribute,\n\tsetNestedValue,\n} from './utils';\nimport type * as ET from './entity-types';\nimport type { UndoManager } from '@wordpress/undo-manager';\n\n// This is an incomplete, high-level approximation of the State type.\n// It makes the selectors slightly more safe, but is intended to evolve\n// into a more detailed representation over time.\n// See https://github.com/WordPress/gutenberg/pull/40025#discussion_r865410589 for more context.\nexport interface State {\n\tautosaves: Record< string | number, Array< unknown > >;\n\tblockPatterns: Array< unknown >;\n\tblockPatternCategories: Array< unknown >;\n\tcurrentGlobalStylesId: string;\n\tcurrentTheme: string;\n\tcurrentUser: ET.User< 'edit' >;\n\tembedPreviews: Record< string, { html: string } >;\n\tentities: EntitiesState;\n\tthemeBaseGlobalStyles: Record< string, Object >;\n\tthemeGlobalStyleVariations: Record< string, string >;\n\tthemeGlobalStyleRevisions: Record< number, Object >;\n\tundoManager: UndoManager;\n\tuserPermissions: Record< string, boolean >;\n\tusers: UserState;\n\tnavigationFallbackId: EntityRecordKey;\n\tuserPatternCategories: Array< UserPatternCategory >;\n}\n\ntype EntityRecordKey = string | number;\n\ninterface EntitiesState {\n\tconfig: EntityConfig[];\n\trecords: Record< string, Record< string, EntityState< ET.EntityRecord > > >;\n}\n\ninterface QueriedData {\n\titems: Record< ET.Context, Record< number, ET.EntityRecord > >;\n\titemIsComplete: Record< ET.Context, Record< number, boolean > >;\n\tqueries: Record< ET.Context, Record< string, Array< number > > >;\n}\n\ninterface EntityState< EntityRecord extends ET.EntityRecord > {\n\tedits: Record< string, Partial< EntityRecord > >;\n\tsaving: Record<\n\t\tstring,\n\t\tPartial< { pending: boolean; isAutosave: boolean; error: Error } >\n\t>;\n\tdeleting: Record< string, Partial< { pending: boolean; error: Error } > >;\n\tqueriedData: QueriedData;\n}\n\ninterface EntityConfig {\n\tname: string;\n\tkind: string;\n}\n\ninterface UserState {\n\tqueries: Record< string, EntityRecordKey[] >;\n\tbyId: Record< EntityRecordKey, ET.User< 'edit' > >;\n}\n\nexport interface UserPatternCategory {\n\tid: number;\n\tname: string;\n\tlabel: string;\n\tslug: string;\n\tdescription: string;\n}\n\ntype Optional< T > = T | undefined;\n\n/**\n * HTTP Query parameters sent with the API request to fetch the entity records.\n */\ntype GetRecordsHttpQuery = Record< string, any >;\n\n/**\n * Shared reference to an empty object for cases where it is important to avoid\n * returning a new object reference on every invocation, as in a connected or\n * other pure component which performs `shouldComponentUpdate` check on props.\n * This should be used as a last resort, since the normalized data should be\n * maintained by the reducer result in state.\n */\nconst EMPTY_OBJECT = {};\n\n/**\n * Returns true if a request is in progress for embed preview data, or false\n * otherwise.\n *\n * @param state Data state.\n * @param url URL the preview would be for.\n *\n * @return Whether a request is in progress for an embed preview.\n */\nexport const isRequestingEmbedPreview = createRegistrySelector(\n\t( select: any ) =>\n\t\t( state: State, url: string ): boolean => {\n\t\t\treturn select( STORE_NAME ).isResolving( 'getEmbedPreview', [\n\t\t\t\turl,\n\t\t\t] );\n\t\t}\n);\n\n/**\n * Returns all available authors.\n *\n * @deprecated since 11.3. Callers should use `select( 'core' ).getUsers({ who: 'authors' })` instead.\n *\n * @param state Data state.\n * @param query Optional object of query parameters to\n * include with request. For valid query parameters see the [Users page](https://developer.wordpress.org/rest-api/reference/users/) in the REST API Handbook and see the arguments for [List Users](https://developer.wordpress.org/rest-api/reference/users/#list-users) and [Retrieve a User](https://developer.wordpress.org/rest-api/reference/users/#retrieve-a-user).\n * @return Authors list.\n */\nexport function getAuthors(\n\tstate: State,\n\tquery?: GetRecordsHttpQuery\n): ET.User[] {\n\tdeprecated( \"select( 'core' ).getAuthors()\", {\n\t\tsince: '5.9',\n\t\talternative: \"select( 'core' ).getUsers({ who: 'authors' })\",\n\t} );\n\n\tconst path = addQueryArgs(\n\t\t'/wp/v2/users/?who=authors&per_page=100',\n\t\tquery\n\t);\n\treturn getUserQueryResults( state, path );\n}\n\n/**\n * Returns the current user.\n *\n * @param state Data state.\n *\n * @return Current user object.\n */\nexport function getCurrentUser( state: State ): ET.User< 'edit' > {\n\treturn state.currentUser;\n}\n\n/**\n * Returns all the users returned by a query ID.\n *\n * @param state Data state.\n * @param queryID Query ID.\n *\n * @return Users list.\n */\nexport const getUserQueryResults = createSelector(\n\t( state: State, queryID: string ): ET.User< 'edit' >[] => {\n\t\tconst queryResults = state.users.queries[ queryID ] ?? [];\n\n\t\treturn queryResults.map( ( id ) => state.users.byId[ id ] );\n\t},\n\t( state: State, queryID: string ) => [\n\t\tstate.users.queries[ queryID ],\n\t\tstate.users.byId,\n\t]\n);\n\n/**\n * Returns the loaded entities for the given kind.\n *\n * @deprecated since WordPress 6.0. Use getEntitiesConfig instead\n * @param state Data state.\n * @param kind Entity kind.\n *\n * @return Array of entities with config matching kind.\n */\nexport function getEntitiesByKind( state: State, kind: string ): Array< any > {\n\tdeprecated( \"wp.data.select( 'core' ).getEntitiesByKind()\", {\n\t\tsince: '6.0',\n\t\talternative: \"wp.data.select( 'core' ).getEntitiesConfig()\",\n\t} );\n\treturn getEntitiesConfig( state, kind );\n}\n\n/**\n * Returns the loaded entities for the given kind.\n *\n * @param state Data state.\n * @param kind Entity kind.\n *\n * @return Array of entities with config matching kind.\n */\nexport function getEntitiesConfig( state: State, kind: string ): Array< any > {\n\treturn state.entities.config.filter( ( entity ) => entity.kind === kind );\n}\n\n/**\n * Returns the entity config given its kind and name.\n *\n * @deprecated since WordPress 6.0. Use getEntityConfig instead\n * @param state Data state.\n * @param kind Entity kind.\n * @param name Entity name.\n *\n * @return Entity config\n */\nexport function getEntity( state: State, kind: string, name: string ): any {\n\tdeprecated( \"wp.data.select( 'core' ).getEntity()\", {\n\t\tsince: '6.0',\n\t\talternative: \"wp.data.select( 'core' ).getEntityConfig()\",\n\t} );\n\treturn getEntityConfig( state, kind, name );\n}\n\n/**\n * Returns the entity config given its kind and name.\n *\n * @param state Data state.\n * @param kind Entity kind.\n * @param name Entity name.\n *\n * @return Entity config\n */\nexport function getEntityConfig(\n\tstate: State,\n\tkind: string,\n\tname: string\n): any {\n\treturn state.entities.config?.find(\n\t\t( config ) => config.kind === kind && config.name === name\n\t);\n}\n\n/**\n * GetEntityRecord is declared as a *callable interface* with\n * two signatures to work around the fact that TypeScript doesn't\n * allow currying generic functions:\n *\n * ```ts\n * \t\ttype CurriedState = F extends ( state: any, ...args: infer P ) => infer R\n * \t\t\t? ( ...args: P ) => R\n * \t\t\t: F;\n * \t\ttype Selector = <K extends string | number>(\n * state: any,\n * kind: K,\n * key: K extends string ? 'string value' : false\n * ) => K;\n * \t\ttype BadlyInferredSignature = CurriedState< Selector >\n * // BadlyInferredSignature evaluates to:\n * // (kind: string number, key: false | \"string value\") => string number\n * ```\n *\n * The signature without the state parameter shipped as CurriedSignature\n * is used in the return value of `select( coreStore )`.\n *\n * See https://github.com/WordPress/gutenberg/pull/41578 for more details.\n */\nexport interface GetEntityRecord {\n\t<\n\t\tEntityRecord extends\n\t\t\t| ET.EntityRecord< any >\n\t\t\t| Partial< ET.EntityRecord< any > >,\n\t>(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\tkey: EntityRecordKey,\n\t\tquery?: GetRecordsHttpQuery\n\t): EntityRecord | undefined;\n\n\tCurriedSignature: <\n\t\tEntityRecord extends\n\t\t\t| ET.EntityRecord< any >\n\t\t\t| Partial< ET.EntityRecord< any > >,\n\t>(\n\t\tkind: string,\n\t\tname: string,\n\t\tkey: EntityRecordKey,\n\t\tquery?: GetRecordsHttpQuery\n\t) => EntityRecord | undefined;\n}\n\n/**\n * Returns the Entity's record object by key. Returns `null` if the value is not\n * yet received, undefined if the value entity is known to not exist, or the\n * entity object if it exists and is received.\n *\n * @param state State tree\n * @param kind Entity kind.\n * @param name Entity name.\n * @param key Record's key\n * @param query Optional query. If requesting specific\n * fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available \"Retrieve a [Entity kind]\".\n *\n * @return Record.\n */\nexport const getEntityRecord = createSelector(\n\t( <\n\t\tEntityRecord extends\n\t\t\t| ET.EntityRecord< any >\n\t\t\t| Partial< ET.EntityRecord< any > >,\n\t>(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\tkey: EntityRecordKey,\n\t\tquery?: GetRecordsHttpQuery\n\t): EntityRecord | undefined => {\n\t\tconst queriedState =\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData;\n\t\tif ( ! queriedState ) {\n\t\t\treturn undefined;\n\t\t}\n\t\tconst context = query?.context ?? 'default';\n\n\t\tif ( query === undefined ) {\n\t\t\t// If expecting a complete item, validate that completeness.\n\t\t\tif ( ! queriedState.itemIsComplete[ context ]?.[ key ] ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\treturn queriedState.items[ context ][ key ];\n\t\t}\n\n\t\tconst item = queriedState.items[ context ]?.[ key ];\n\t\tif ( item && query._fields ) {\n\t\t\tconst filteredItem = {};\n\t\t\tconst fields = getNormalizedCommaSeparable( query._fields ) ?? [];\n\t\t\tfor ( let f = 0; f < fields.length; f++ ) {\n\t\t\t\tconst field = fields[ f ].split( '.' );\n\t\t\t\tlet value = item;\n\t\t\t\tfield.forEach( ( fieldName ) => {\n\t\t\t\t\tvalue = value?.[ fieldName ];\n\t\t\t\t} );\n\t\t\t\tsetNestedValue( filteredItem, field, value );\n\t\t\t}\n\t\t\treturn filteredItem as EntityRecord;\n\t\t}\n\n\t\treturn item;\n\t} ) as GetEntityRecord,\n\t( state: State, kind, name, recordId, query ) => {\n\t\tconst context = query?.context ?? 'default';\n\t\treturn [\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData?.items[\n\t\t\t\tcontext\n\t\t\t]?.[ recordId ],\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData\n\t\t\t\t?.itemIsComplete[ context ]?.[ recordId ],\n\t\t];\n\t}\n) as GetEntityRecord;\n\n/**\n * Returns the Entity's record object by key. Doesn't trigger a resolver nor requests the entity records from the API if the entity record isn't available in the local state.\n *\n * @param state State tree\n * @param kind Entity kind.\n * @param name Entity name.\n * @param key Record's key\n *\n * @return Record.\n */\nexport function __experimentalGetEntityRecordNoResolver<\n\tEntityRecord extends ET.EntityRecord< any >,\n>( state: State, kind: string, name: string, key: EntityRecordKey ) {\n\treturn getEntityRecord< EntityRecord >( state, kind, name, key );\n}\n\n/**\n * Returns the entity's record object by key,\n * with its attributes mapped to their raw values.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param key Record's key.\n *\n * @return Object with the entity's raw attributes.\n */\nexport const getRawEntityRecord = createSelector(\n\t< EntityRecord extends ET.EntityRecord< any > >(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\tkey: EntityRecordKey\n\t): EntityRecord | undefined => {\n\t\tconst record = getEntityRecord< EntityRecord >(\n\t\t\tstate,\n\t\t\tkind,\n\t\t\tname,\n\t\t\tkey\n\t\t);\n\t\treturn (\n\t\t\trecord &&\n\t\t\tObject.keys( record ).reduce( ( accumulator, _key ) => {\n\t\t\t\tif (\n\t\t\t\t\tisRawAttribute( getEntityConfig( state, kind, name ), _key )\n\t\t\t\t) {\n\t\t\t\t\t// Because edits are the \"raw\" attribute values,\n\t\t\t\t\t// we return those from record selectors to make rendering,\n\t\t\t\t\t// comparisons, and joins with edits easier.\n\t\t\t\t\taccumulator[ _key ] = record[ _key ]?.raw ?? record[ _key ];\n\t\t\t\t} else {\n\t\t\t\t\taccumulator[ _key ] = record[ _key ];\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, {} as any )\n\t\t);\n\t},\n\t(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\trecordId: EntityRecordKey,\n\t\tquery?: GetRecordsHttpQuery\n\t) => {\n\t\tconst context = query?.context ?? 'default';\n\t\treturn [\n\t\t\tstate.entities.config,\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData?.items[\n\t\t\t\tcontext\n\t\t\t]?.[ recordId ],\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData\n\t\t\t\t?.itemIsComplete[ context ]?.[ recordId ],\n\t\t];\n\t}\n);\n\n/**\n * Returns true if records have been received for the given set of parameters,\n * or false otherwise.\n *\n * @param state State tree\n * @param kind Entity kind.\n * @param name Entity name.\n * @param query Optional terms query. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for \"List [Entity kind]s\".\n *\n * @return Whether entity records have been received.\n */\nexport function hasEntityRecords(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\tquery?: GetRecordsHttpQuery\n): boolean {\n\treturn Array.isArray( getEntityRecords( state, kind, name, query ) );\n}\n\n/**\n * GetEntityRecord is declared as a *callable interface* with\n * two signatures to work around the fact that TypeScript doesn't\n * allow currying generic functions.\n *\n * @see GetEntityRecord\n * @see https://github.com/WordPress/gutenberg/pull/41578\n */\nexport interface GetEntityRecords {\n\t<\n\t\tEntityRecord extends\n\t\t\t| ET.EntityRecord< any >\n\t\t\t| Partial< ET.EntityRecord< any > >,\n\t>(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\tquery?: GetRecordsHttpQuery\n\t): EntityRecord[] | null;\n\n\tCurriedSignature: <\n\t\tEntityRecord extends\n\t\t\t| ET.EntityRecord< any >\n\t\t\t| Partial< ET.EntityRecord< any > >,\n\t>(\n\t\tkind: string,\n\t\tname: string,\n\t\tquery?: GetRecordsHttpQuery\n\t) => EntityRecord[] | null;\n}\n\n/**\n * Returns the Entity's records.\n *\n * @param state State tree\n * @param kind Entity kind.\n * @param name Entity name.\n * @param query Optional terms query. If requesting specific\n * fields, fields must always include the ID. For valid query parameters see the [Reference](https://developer.wordpress.org/rest-api/reference/) in the REST API Handbook and select the entity kind. Then see the arguments available for \"List [Entity kind]s\".\n *\n * @return Records.\n */\nexport const getEntityRecords = ( <\n\tEntityRecord extends\n\t\t| ET.EntityRecord< any >\n\t\t| Partial< ET.EntityRecord< any > >,\n>(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\tquery: GetRecordsHttpQuery\n): EntityRecord[] | null => {\n\t// Queried data state is prepopulated for all known entities. If this is not\n\t// assigned for the given parameters, then it is known to not exist.\n\tconst queriedState =\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData;\n\tif ( ! queriedState ) {\n\t\treturn null;\n\t}\n\treturn getQueriedItems( queriedState, query );\n} ) as GetEntityRecords;\n\ntype DirtyEntityRecord = {\n\ttitle: string;\n\tkey: EntityRecordKey;\n\tname: string;\n\tkind: string;\n};\n/**\n * Returns the list of dirty entity records.\n *\n * @param state State tree.\n *\n * @return The list of updated records\n */\nexport const __experimentalGetDirtyEntityRecords = createSelector(\n\t( state: State ): Array< DirtyEntityRecord > => {\n\t\tconst {\n\t\t\tentities: { records },\n\t\t} = state;\n\t\tconst dirtyRecords: DirtyEntityRecord[] = [];\n\t\tObject.keys( records ).forEach( ( kind ) => {\n\t\t\tObject.keys( records[ kind ] ).forEach( ( name ) => {\n\t\t\t\tconst primaryKeys = (\n\t\t\t\t\tObject.keys( records[ kind ][ name ].edits ) as string[]\n\t\t\t\t ).filter(\n\t\t\t\t\t( primaryKey ) =>\n\t\t\t\t\t\t// The entity record must exist (not be deleted),\n\t\t\t\t\t\t// and it must have edits.\n\t\t\t\t\t\tgetEntityRecord( state, kind, name, primaryKey ) &&\n\t\t\t\t\t\thasEditsForEntityRecord( state, kind, name, primaryKey )\n\t\t\t\t);\n\n\t\t\t\tif ( primaryKeys.length ) {\n\t\t\t\t\tconst entityConfig = getEntityConfig( state, kind, name );\n\t\t\t\t\tprimaryKeys.forEach( ( primaryKey ) => {\n\t\t\t\t\t\tconst entityRecord = getEditedEntityRecord(\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tprimaryKey\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdirtyRecords.push( {\n\t\t\t\t\t\t\t// We avoid using primaryKey because it's transformed into a string\n\t\t\t\t\t\t\t// when it's used as an object key.\n\t\t\t\t\t\t\tkey: entityRecord\n\t\t\t\t\t\t\t\t? entityRecord[\n\t\t\t\t\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY\n\t\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tentityConfig?.getTitle?.( entityRecord ) || '',\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t} );\n\n\t\treturn dirtyRecords;\n\t},\n\t( state ) => [ state.entities.records ]\n);\n\n/**\n * Returns the list of entities currently being saved.\n *\n * @param state State tree.\n *\n * @return The list of records being saved.\n */\nexport const __experimentalGetEntitiesBeingSaved = createSelector(\n\t( state: State ): Array< DirtyEntityRecord > => {\n\t\tconst {\n\t\t\tentities: { records },\n\t\t} = state;\n\t\tconst recordsBeingSaved: DirtyEntityRecord[] = [];\n\t\tObject.keys( records ).forEach( ( kind ) => {\n\t\t\tObject.keys( records[ kind ] ).forEach( ( name ) => {\n\t\t\t\tconst primaryKeys = (\n\t\t\t\t\tObject.keys( records[ kind ][ name ].saving ) as string[]\n\t\t\t\t ).filter( ( primaryKey ) =>\n\t\t\t\t\tisSavingEntityRecord( state, kind, name, primaryKey )\n\t\t\t\t);\n\n\t\t\t\tif ( primaryKeys.length ) {\n\t\t\t\t\tconst entityConfig = getEntityConfig( state, kind, name );\n\t\t\t\t\tprimaryKeys.forEach( ( primaryKey ) => {\n\t\t\t\t\t\tconst entityRecord = getEditedEntityRecord(\n\t\t\t\t\t\t\tstate,\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tprimaryKey\n\t\t\t\t\t\t);\n\t\t\t\t\t\trecordsBeingSaved.push( {\n\t\t\t\t\t\t\t// We avoid using primaryKey because it's transformed into a string\n\t\t\t\t\t\t\t// when it's used as an object key.\n\t\t\t\t\t\t\tkey: entityRecord\n\t\t\t\t\t\t\t\t? entityRecord[\n\t\t\t\t\t\t\t\t\t\tentityConfig.key || DEFAULT_ENTITY_KEY\n\t\t\t\t\t\t\t\t ]\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\t\ttitle:\n\t\t\t\t\t\t\t\tentityConfig?.getTitle?.( entityRecord ) || '',\n\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\tkind,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t} );\n\t\treturn recordsBeingSaved;\n\t},\n\t( state ) => [ state.entities.records ]\n);\n\n/**\n * Returns the specified entity record's edits.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return The entity record's edits.\n */\nexport function getEntityRecordEdits(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): Optional< any > {\n\treturn state.entities.records?.[ kind ]?.[ name ]?.edits?.[\n\t\trecordId as string | number\n\t];\n}\n\n/**\n * Returns the specified entity record's non transient edits.\n *\n * Transient edits don't create an undo level, and\n * are not considered for change detection.\n * They are defined in the entity's config.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return The entity record's non transient edits.\n */\nexport const getEntityRecordNonTransientEdits = createSelector(\n\t(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\trecordId: EntityRecordKey\n\t): Optional< any > => {\n\t\tconst { transientEdits } = getEntityConfig( state, kind, name ) || {};\n\t\tconst edits = getEntityRecordEdits( state, kind, name, recordId ) || {};\n\t\tif ( ! transientEdits ) {\n\t\t\treturn edits;\n\t\t}\n\t\treturn Object.keys( edits ).reduce( ( acc, key ) => {\n\t\t\tif ( ! transientEdits[ key ] ) {\n\t\t\t\tacc[ key ] = edits[ key ];\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, {} );\n\t},\n\t( state: State, kind: string, name: string, recordId: EntityRecordKey ) => [\n\t\tstate.entities.config,\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.edits?.[ recordId ],\n\t]\n);\n\n/**\n * Returns true if the specified entity record has edits,\n * and false otherwise.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return Whether the entity record has edits or not.\n */\nexport function hasEditsForEntityRecord(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): boolean {\n\treturn (\n\t\tisSavingEntityRecord( state, kind, name, recordId ) ||\n\t\tObject.keys(\n\t\t\tgetEntityRecordNonTransientEdits( state, kind, name, recordId )\n\t\t).length > 0\n\t);\n}\n\n/**\n * Returns the specified entity record, merged with its edits.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return The entity record, merged with its edits.\n */\nexport const getEditedEntityRecord = createSelector(\n\t< EntityRecord extends ET.EntityRecord< any > >(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\trecordId: EntityRecordKey\n\t): ET.Updatable< EntityRecord > | undefined => ( {\n\t\t...getRawEntityRecord( state, kind, name, recordId ),\n\t\t...getEntityRecordEdits( state, kind, name, recordId ),\n\t} ),\n\t(\n\t\tstate: State,\n\t\tkind: string,\n\t\tname: string,\n\t\trecordId: EntityRecordKey,\n\t\tquery?: GetRecordsHttpQuery\n\t) => {\n\t\tconst context = query?.context ?? 'default';\n\t\treturn [\n\t\t\tstate.entities.config,\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData.items[\n\t\t\t\tcontext\n\t\t\t]?.[ recordId ],\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.queriedData\n\t\t\t\t.itemIsComplete[ context ]?.[ recordId ],\n\t\t\tstate.entities.records?.[ kind ]?.[ name ]?.edits?.[ recordId ],\n\t\t];\n\t}\n);\n\n/**\n * Returns true if the specified entity record is autosaving, and false otherwise.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return Whether the entity record is autosaving or not.\n */\nexport function isAutosavingEntityRecord(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): boolean {\n\tconst { pending, isAutosave } =\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.saving?.[ recordId ] ?? {};\n\treturn Boolean( pending && isAutosave );\n}\n\n/**\n * Returns true if the specified entity record is saving, and false otherwise.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return Whether the entity record is saving or not.\n */\nexport function isSavingEntityRecord(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): boolean {\n\treturn (\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.saving?.[\n\t\t\trecordId as EntityRecordKey\n\t\t]?.pending ?? false\n\t);\n}\n\n/**\n * Returns true if the specified entity record is deleting, and false otherwise.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return Whether the entity record is deleting or not.\n */\nexport function isDeletingEntityRecord(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): boolean {\n\treturn (\n\t\tstate.entities.records?.[ kind ]?.[ name ]?.deleting?.[\n\t\t\trecordId as EntityRecordKey\n\t\t]?.pending ?? false\n\t);\n}\n\n/**\n * Returns the specified entity record's last save error.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return The entity record's save error.\n */\nexport function getLastEntitySaveError(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): any {\n\treturn state.entities.records?.[ kind ]?.[ name ]?.saving?.[ recordId ]\n\t\t?.error;\n}\n\n/**\n * Returns the specified entity record's last delete error.\n *\n * @param state State tree.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record ID.\n *\n * @return The entity record's save error.\n */\nexport function getLastEntityDeleteError(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): any {\n\treturn state.entities.records?.[ kind ]?.[ name ]?.deleting?.[ recordId ]\n\t\t?.error;\n}\n\n/**\n * Returns the previous edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * @deprecated since 6.3\n *\n * @param state State tree.\n *\n * @return The edit.\n */\nexport function getUndoEdit( state: State ): Optional< any > {\n\tdeprecated( \"select( 'core' ).getUndoEdit()\", {\n\t\tsince: '6.3',\n\t} );\n\treturn undefined;\n}\n\n/**\n * Returns the next edit from the current undo offset\n * for the entity records edits history, if any.\n *\n * @deprecated since 6.3\n *\n * @param state State tree.\n *\n * @return The edit.\n */\nexport function getRedoEdit( state: State ): Optional< any > {\n\tdeprecated( \"select( 'core' ).getRedoEdit()\", {\n\t\tsince: '6.3',\n\t} );\n\treturn undefined;\n}\n\n/**\n * Returns true if there is a previous edit from the current undo offset\n * for the entity records edits history, and false otherwise.\n *\n * @param state State tree.\n *\n * @return Whether there is a previous edit or not.\n */\nexport function hasUndo( state: State ): boolean {\n\treturn state.undoManager.hasUndo();\n}\n\n/**\n * Returns true if there is a next edit from the current undo offset\n * for the entity records edits history, and false otherwise.\n *\n * @param state State tree.\n *\n * @return Whether there is a next edit or not.\n */\nexport function hasRedo( state: State ): boolean {\n\treturn state.undoManager.hasRedo();\n}\n\n/**\n * Return the current theme.\n *\n * @param state Data state.\n *\n * @return The current theme.\n */\nexport function getCurrentTheme( state: State ): any {\n\tif ( ! state.currentTheme ) {\n\t\treturn null;\n\t}\n\treturn getEntityRecord( state, 'root', 'theme', state.currentTheme );\n}\n\n/**\n * Return the ID of the current global styles object.\n *\n * @param state Data state.\n *\n * @return The current global styles ID.\n */\nexport function __experimentalGetCurrentGlobalStylesId( state: State ): string {\n\treturn state.currentGlobalStylesId;\n}\n\n/**\n * Return theme supports data in the index.\n *\n * @param state Data state.\n *\n * @return Index data.\n */\nexport function getThemeSupports( state: State ): any {\n\treturn getCurrentTheme( state )?.theme_supports ?? EMPTY_OBJECT;\n}\n\n/**\n * Returns the embed preview for the given URL.\n *\n * @param state Data state.\n * @param url Embedded URL.\n *\n * @return Undefined if the preview has not been fetched, otherwise, the preview fetched from the embed preview API.\n */\nexport function getEmbedPreview( state: State, url: string ): any {\n\treturn state.embedPreviews[ url ];\n}\n\n/**\n * Determines if the returned preview is an oEmbed link fallback.\n *\n * WordPress can be configured to return a simple link to a URL if it is not embeddable.\n * We need to be able to determine if a URL is embeddable or not, based on what we\n * get back from the oEmbed preview API.\n *\n * @param state Data state.\n * @param url Embedded URL.\n *\n * @return Is the preview for the URL an oEmbed link fallback.\n */\nexport function isPreviewEmbedFallback( state: State, url: string ): boolean {\n\tconst preview = state.embedPreviews[ url ];\n\tconst oEmbedLinkCheck = '<a href=\"' + url + '\">' + url + '</a>';\n\tif ( ! preview ) {\n\t\treturn false;\n\t}\n\treturn preview.html === oEmbedLinkCheck;\n}\n\n/**\n * Returns whether the current user can perform the given action on the given\n * REST resource.\n *\n * Calling this may trigger an OPTIONS request to the REST API via the\n * `canUser()` resolver.\n *\n * https://developer.wordpress.org/rest-api/reference/\n *\n * @param state Data state.\n * @param action Action to check. One of: 'create', 'read', 'update', 'delete'.\n * @param resource REST resource to check, e.g. 'media' or 'posts'.\n * @param id Optional ID of the rest resource to check.\n *\n * @return Whether or not the user can perform the action,\n * or `undefined` if the OPTIONS request is still being made.\n */\nexport function canUser(\n\tstate: State,\n\taction: string,\n\tresource: string,\n\tid?: EntityRecordKey\n): boolean | undefined {\n\tconst key = [ action, resource, id ].filter( Boolean ).join( '/' );\n\treturn state.userPermissions[ key ];\n}\n\n/**\n * Returns whether the current user can edit the given entity.\n *\n * Calling this may trigger an OPTIONS request to the REST API via the\n * `canUser()` resolver.\n *\n * https://developer.wordpress.org/rest-api/reference/\n *\n * @param state Data state.\n * @param kind Entity kind.\n * @param name Entity name.\n * @param recordId Record's id.\n * @return Whether or not the user can edit,\n * or `undefined` if the OPTIONS request is still being made.\n */\nexport function canUserEditEntityRecord(\n\tstate: State,\n\tkind: string,\n\tname: string,\n\trecordId: EntityRecordKey\n): boolean | undefined {\n\tconst entityConfig = getEntityConfig( state, kind, name );\n\tif ( ! entityConfig ) {\n\t\treturn false;\n\t}\n\tconst resource = entityConfig.__unstable_rest_base;\n\n\treturn canUser( state, 'update', resource, recordId );\n}\n\n/**\n * Returns the latest autosaves for the post.\n *\n * May return multiple autosaves since the backend stores one autosave per\n * author for each post.\n *\n * @param state State tree.\n * @param postType The type of the parent post.\n * @param postId The id of the parent post.\n *\n * @return An array of autosaves for the post, or undefined if there is none.\n */\nexport function getAutosaves(\n\tstate: State,\n\tpostType: string,\n\tpostId: EntityRecordKey\n): Array< any > | undefined {\n\treturn state.autosaves[ postId ];\n}\n\n/**\n * Returns the autosave for the post and author.\n *\n * @param state State tree.\n * @param postType The type of the parent post.\n * @param postId The id of the parent post.\n * @param authorId The id of the author.\n *\n * @return The autosave for the post and author.\n */\nexport function getAutosave< EntityRecord extends ET.EntityRecord< any > >(\n\tstate: State,\n\tpostType: string,\n\tpostId: EntityRecordKey,\n\tauthorId: EntityRecordKey\n): EntityRecord | undefined {\n\tif ( authorId === undefined ) {\n\t\treturn;\n\t}\n\n\tconst autosaves = state.autosaves[ postId ];\n\n\treturn autosaves?.find(\n\t\t( autosave: any ) => autosave.author === authorId\n\t) as EntityRecord | undefined;\n}\n\n/**\n * Returns true if the REST request for autosaves has completed.\n *\n * @param state State tree.\n * @param postType The type of the parent post.\n * @param postId The id of the parent post.\n *\n * @return True if the REST request was completed. False otherwise.\n */\nexport const hasFetchedAutosaves = createRegistrySelector(\n\t( select ) =>\n\t\t(\n\t\t\tstate: State,\n\t\t\tpostType: string,\n\t\t\tpostId: EntityRecordKey\n\t\t): boolean => {\n\t\t\treturn select( STORE_NAME ).hasFinishedResolution( 'getAutosaves', [\n\t\t\t\tpostType,\n\t\t\t\tpostId,\n\t\t\t] );\n\t\t}\n);\n\n/**\n * Returns a new reference when edited values have changed. This is useful in\n * inferring where an edit has been made between states by comparison of the\n * return values using strict equality.\n *\n * @example\n *\n * ```\n * const hasEditOccurred = (\n * getReferenceByDistinctEdits( beforeState ) !==\n * getReferenceByDistinctEdits( afterState )\n * );\n * ```\n *\n * @param state Editor state.\n *\n * @return A value whose reference will change only when an edit occurs.\n */\nexport function getReferenceByDistinctEdits( state ) {\n\treturn state.editsReference;\n}\n\n/**\n * Retrieve the frontend template used for a given link.\n *\n * @param state Editor state.\n * @param link Link.\n *\n * @return The template record.\n */\nexport function __experimentalGetTemplateForLink(\n\tstate: State,\n\tlink: string\n): Optional< ET.Updatable< ET.WpTemplate > > | null {\n\tconst records = getEntityRecords< ET.WpTemplate >(\n\t\tstate,\n\t\t'postType',\n\t\t'wp_template',\n\t\t{\n\t\t\t'find-template': link,\n\t\t}\n\t);\n\n\tif ( records?.length ) {\n\t\treturn getEditedEntityRecord< ET.WpTemplate >(\n\t\t\tstate,\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\trecords[ 0 ].id\n\t\t);\n\t}\n\treturn null;\n}\n\n/**\n * Retrieve the current theme's base global styles\n *\n * @param state Editor state.\n *\n * @return The Global Styles object.\n */\nexport function __experimentalGetCurrentThemeBaseGlobalStyles(\n\tstate: State\n): any {\n\tconst currentTheme = getCurrentTheme( state );\n\tif ( ! currentTheme ) {\n\t\treturn null;\n\t}\n\treturn state.themeBaseGlobalStyles[ currentTheme.stylesheet ];\n}\n\n/**\n * Return the ID of the current global styles object.\n *\n * @param state Data state.\n *\n * @return The current global styles ID.\n */\nexport function __experimentalGetCurrentThemeGlobalStylesVariations(\n\tstate: State\n): string | null {\n\tconst currentTheme = getCurrentTheme( state );\n\tif ( ! currentTheme ) {\n\t\treturn null;\n\t}\n\treturn state.themeGlobalStyleVariations[ currentTheme.stylesheet ];\n}\n\n/**\n * Retrieve the list of registered block patterns.\n *\n * @param state Data state.\n *\n * @return Block pattern list.\n */\nexport function getBlockPatterns( state: State ): Array< any > {\n\treturn state.blockPatterns;\n}\n\n/**\n * Retrieve the list of registered block pattern categories.\n *\n * @param state Data state.\n *\n * @return Block pattern category list.\n */\nexport function getBlockPatternCategories( state: State ): Array< any > {\n\treturn state.blockPatternCategories;\n}\n\n/**\n * Retrieve the registered user pattern categories.\n *\n * @param state Data state.\n *\n * @return User patterns category array.\n */\n\nexport function getUserPatternCategories(\n\tstate: State\n): Array< UserPatternCategory > {\n\treturn state.userPatternCategories;\n}\n\n/**\n * Returns the revisions of the current global styles theme.\n *\n * @param state Data state.\n *\n * @return The current global styles.\n */\nexport function getCurrentThemeGlobalStylesRevisions(\n\tstate: State\n): Array< object > | null {\n\tconst currentGlobalStylesId =\n\t\t__experimentalGetCurrentGlobalStylesId( state );\n\n\tif ( ! currentGlobalStylesId ) {\n\t\treturn null;\n\t}\n\n\treturn state.themeGlobalStyleRevisions[ current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KAAM,CAAC;EAEhD,IAAK,CAAEwH,qBAAqB,EAAG;IAC9B,OAAO,IAAI;EACZ;EAEA,OAAOxH,KAAK,CAACmK,yBAAyB,CAAE3C,qBAAqB,CAAE;AAChE"}
|
|
@@ -81,17 +81,26 @@ import { __ } from '@wordpress/i18n';
|
|
|
81
81
|
const fetchLinkSuggestions = async (search, searchOptions = {}, settings = {}) => {
|
|
82
82
|
const {
|
|
83
83
|
isInitialSuggestions = false,
|
|
84
|
+
initialSuggestionsSearchOptions = undefined
|
|
85
|
+
} = searchOptions;
|
|
86
|
+
const {
|
|
87
|
+
disablePostFormats = false
|
|
88
|
+
} = settings;
|
|
89
|
+
let {
|
|
84
90
|
type = undefined,
|
|
85
91
|
subtype = undefined,
|
|
86
92
|
page = undefined,
|
|
87
93
|
perPage = isInitialSuggestions ? 3 : 20
|
|
88
94
|
} = searchOptions;
|
|
89
|
-
const {
|
|
90
|
-
disablePostFormats = false
|
|
91
|
-
} = settings;
|
|
92
95
|
|
|
93
96
|
/** @type {Promise<WPLinkSearchResult>[]} */
|
|
94
97
|
const queries = [];
|
|
98
|
+
if (isInitialSuggestions && initialSuggestionsSearchOptions) {
|
|
99
|
+
type = initialSuggestionsSearchOptions.type || type;
|
|
100
|
+
subtype = initialSuggestionsSearchOptions.subtype || subtype;
|
|
101
|
+
page = initialSuggestionsSearchOptions.page || page;
|
|
102
|
+
perPage = initialSuggestionsSearchOptions.perPage || perPage;
|
|
103
|
+
}
|
|
95
104
|
if (!type || type === 'post') {
|
|
96
105
|
queries.push(apiFetch({
|
|
97
106
|
path: addQueryArgs('/wp/v2/search', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["apiFetch","addQueryArgs","decodeEntities","__","fetchLinkSuggestions","search","searchOptions","settings","isInitialSuggestions","type","undefined","subtype","page","perPage","disablePostFormats","queries","push","path","per_page","then","results","map","result","meta","kind","catch","Promise","all","reduce","accumulator","current","concat","filter","id","slice","isMedia","url","source_url","title","rendered"],"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\ttype = undefined,\n\t\tsubtype = undefined,\n\t\tpage = undefined,\n\t\tperPage = isInitialSuggestions ? 3 : 20,\n\t} = searchOptions;\n\n\tconst { disablePostFormats = false } = settings;\n\n\t/** @type {Promise<WPLinkSearchResult>[]} */\n\tconst queries = [];\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":"AAAA;AACA;AACA;AACA,OAAOA,QAAQ,MAAM,sBAAsB;AAC3C,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;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,MAAMC,oBAAoB,GAAG,MAAAA,CAC5BC,MAAM,EACNC,aAAa,GAAG,CAAC,CAAC,EAClBC,QAAQ,GAAG,CAAC,CAAC,KACT;EACJ,MAAM;IACLC,oBAAoB,GAAG,KAAK;IAC5BC,IAAI,GAAGC,SAAS;IAChBC,OAAO,GAAGD,SAAS;IACn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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,EAAErB,OAAQ,CAAC,CACnBQ,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,EACJpC,cAAc,CACbiC,OAAO;QACJ;QACAb,MAAM,CAACgB,KAAK,CAACC,QAAQ,GACrBjB,MAAM,CAACgB,KAAK,IAAI,EACpB,CAAC,IAAInC,EAAE,CAAE,YAAa,CAAC;QACxBM,IAAI,EAAEa,MAAM,CAACX,OAAO,IAAIW,MAAM,CAACb,IAAI;QACnCe,IAAI,EAAEF,MAAM,EAAEC,IAAI,EAAEC;MACrB,CAAC;IACF,CAAE,CAAC;EACL,CAAE,CAAC;AACJ,CAAC;AAED,eAAepB,oBAAoB"}
|
|
1
|
+
{"version":3,"names":["apiFetch","addQueryArgs","decodeEntities","__","fetchLinkSuggestions","search","searchOptions","settings","isInitialSuggestions","initialSuggestionsSearchOptions","undefined","disablePostFormats","type","subtype","page","perPage","queries","push","path","per_page","then","results","map","result","meta","kind","catch","Promise","all","reduce","accumulator","current","concat","filter","id","slice","isMedia","url","source_url","title","rendered"],"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":"AAAA;AACA;AACA;AACA,OAAOA,QAAQ,MAAM,sBAAsB;AAC3C,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;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,MAAMC,oBAAoB,GAAG,MAAAA,CAC5BC,MAAM,EACNC,aAAa,GAAG,CAAC,CAAC,EAClBC,QAAQ,GAAG,CAAC,CAAC,KACT;EACJ,MAAM;IACLC,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B"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { create } from '@wordpress/rich-text';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Internal dependencies
|
|
3
8
|
*/
|
|
@@ -5,23 +10,33 @@ import getRichTextValuesCached from './get-rich-text-values-cached';
|
|
|
5
10
|
const cache = new WeakMap();
|
|
6
11
|
function getBlockFootnotesOrder(block) {
|
|
7
12
|
if (!cache.has(block)) {
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// get the order directly from the rich text values.
|
|
13
|
-
if (content.indexOf('data-fn') !== -1) {
|
|
14
|
-
const regex = /data-fn="([^"]+)"/g;
|
|
15
|
-
let match;
|
|
16
|
-
while ((match = regex.exec(content)) !== null) {
|
|
17
|
-
newOrder.push(match[1]);
|
|
13
|
+
const order = [];
|
|
14
|
+
for (const value of getRichTextValuesCached(block)) {
|
|
15
|
+
if (!value || !value.includes('data-fn')) {
|
|
16
|
+
continue;
|
|
18
17
|
}
|
|
18
|
+
|
|
19
|
+
// replacements is a sparse array, use forEach to skip empty slots.
|
|
20
|
+
create({
|
|
21
|
+
html: value
|
|
22
|
+
}).replacements.forEach(({
|
|
23
|
+
type,
|
|
24
|
+
attributes
|
|
25
|
+
}) => {
|
|
26
|
+
if (type === 'core/footnote') {
|
|
27
|
+
order.push(attributes['data-fn']);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
19
30
|
}
|
|
20
|
-
cache.set(block,
|
|
31
|
+
cache.set(block, order);
|
|
21
32
|
}
|
|
22
33
|
return cache.get(block);
|
|
23
34
|
}
|
|
24
35
|
export default function getFootnotesOrder(blocks) {
|
|
36
|
+
// We can only separate getting order from blocks at the root level. For
|
|
37
|
+
// deeper inner blocks, this will not work since it's possible to have both
|
|
38
|
+
// inner blocks and block attributes, so order needs to be computed from the
|
|
39
|
+
// Edit functions as a whole.
|
|
25
40
|
return blocks.flatMap(getBlockFootnotesOrder);
|
|
26
41
|
}
|
|
27
42
|
//# sourceMappingURL=get-footnotes-order.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getRichTextValuesCached","cache","WeakMap","getBlockFootnotesOrder","block","has","
|
|
1
|
+
{"version":3,"names":["create","getRichTextValuesCached","cache","WeakMap","getBlockFootnotesOrder","block","has","order","value","includes","html","replacements","forEach","type","attributes","push","set","get","getFootnotesOrder","blocks","flatMap"],"sources":["@wordpress/core-data/src/footnotes/get-footnotes-order.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { create } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport getRichTextValuesCached from './get-rich-text-values-cached';\n\nconst cache = new WeakMap();\n\nfunction getBlockFootnotesOrder( block ) {\n\tif ( ! cache.has( block ) ) {\n\t\tconst order = [];\n\t\tfor ( const value of getRichTextValuesCached( block ) ) {\n\t\t\tif ( ! value || ! value.includes( 'data-fn' ) ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// replacements is a sparse array, use forEach to skip empty slots.\n\t\t\tcreate( { html: value } ).replacements.forEach(\n\t\t\t\t( { type, attributes } ) => {\n\t\t\t\t\tif ( type === 'core/footnote' ) {\n\t\t\t\t\t\torder.push( attributes[ 'data-fn' ] );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t\tcache.set( block, order );\n\t}\n\n\treturn cache.get( block );\n}\n\nexport default function getFootnotesOrder( blocks ) {\n\t// We can only separate getting order from blocks at the root level. For\n\t// deeper inner blocks, this will not work since it's possible to have both\n\t// inner blocks and block attributes, so order needs to be computed from the\n\t// Edit functions as a whole.\n\treturn blocks.flatMap( getBlockFootnotesOrder );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,sBAAsB;;AAE7C;AACA;AACA;AACA,OAAOC,uBAAuB,MAAM,+BAA+B;AAEnE,MAAMC,KAAK,GAAG,IAAIC,OAAO,CAAC,CAAC;AAE3B,SAASC,sBAAsBA,CAAEC,KAAK,EAAG;EACxC,IAAK,CAAEH,KAAK,CAACI,GAAG,CAAED,KAAM,CAAC,EAAG;IAC3B,MAAME,KAAK,GAAG,EAAE;IAChB,KAAM,MAAMC,KAAK,IAAIP,uBAAuB,CAAEI,KAAM,CAAC,EAAG;MACvD,IAAK,CAAEG,KAAK,IAAI,CAAEA,KAAK,CAACC,QAAQ,CAAE,SAAU,CAAC,EAAG;QAC/C;MACD;;MAEA;MACAT,MAAM,CAAE;QAAEU,IAAI,EAAEF;MAAM,CAAE,CAAC,CAACG,YAAY,CAACC,OAAO,CAC7C,CAAE;QAAEC,IAAI;QAAEC;MAAW,CAAC,KAAM;QAC3B,IAAKD,IAAI,KAAK,eAAe,EAAG;UAC/BN,KAAK,CAACQ,IAAI,CAAED,UAAU,CAAE,SAAS,CAAG,CAAC;QACtC;MACD,CACD,CAAC;IACF;IACAZ,KAAK,CAACc,GAAG,CAAEX,KAAK,EAAEE,KAAM,CAAC;EAC1B;EAEA,OAAOL,KAAK,CAACe,GAAG,CAAEZ,KAAM,CAAC;AAC1B;AAEA,eAAe,SAASa,iBAAiBA,CAAEC,MAAM,EAAG;EACnD;EACA;EACA;EACA;EACA,OAAOA,MAAM,CAACC,OAAO,CAAEhB,sBAAuB,CAAC;AAChD"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { create, toHTMLString } from '@wordpress/rich-text';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Internal dependencies
|
|
3
8
|
*/
|
|
@@ -39,18 +44,25 @@ export function updateFootnotesFromMeta(blocks, meta) {
|
|
|
39
44
|
if (value.indexOf('data-fn') === -1) {
|
|
40
45
|
continue;
|
|
41
46
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
const richTextValue = create({
|
|
48
|
+
html: value
|
|
49
|
+
});
|
|
50
|
+
richTextValue.replacements.forEach(replacement => {
|
|
51
|
+
if (replacement.type === 'core/footnote') {
|
|
52
|
+
const id = replacement.attributes['data-fn'];
|
|
53
|
+
const index = newOrder.indexOf(id);
|
|
54
|
+
// The innerHTML contains the count wrapped in a link.
|
|
55
|
+
const countValue = create({
|
|
56
|
+
html: replacement.innerHTML
|
|
57
|
+
});
|
|
58
|
+
countValue.text = String(index + 1);
|
|
59
|
+
replacement.innerHTML = toHTMLString({
|
|
60
|
+
value: countValue
|
|
61
|
+
});
|
|
62
|
+
}
|
|
49
63
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const index = newOrder.indexOf(fnId);
|
|
53
|
-
return `<sup data-fn="${fnId}" class="fn"><a href="#${fnId}" id="${fnId}-link">${index + 1}</a></sup>`;
|
|
64
|
+
attributes[key] = toHTMLString({
|
|
65
|
+
value: richTextValue
|
|
54
66
|
});
|
|
55
67
|
}
|
|
56
68
|
return attributes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getFootnotesOrder","oldFootnotes","updateFootnotesFromMeta","blocks","meta","output","footnotes","undefined","newOrder","JSON","parse","currentOrder","map","fn","id","join","newFootnotes","fnId","find","content","updateAttributes","attributes","Array","isArray","key","value","indexOf","
|
|
1
|
+
{"version":3,"names":["create","toHTMLString","getFootnotesOrder","oldFootnotes","updateFootnotesFromMeta","blocks","meta","output","footnotes","undefined","newOrder","JSON","parse","currentOrder","map","fn","id","join","newFootnotes","fnId","find","content","updateAttributes","attributes","Array","isArray","key","value","indexOf","richTextValue","html","replacements","forEach","replacement","type","index","countValue","innerHTML","text","String","updateBlocksAttributes","__blocks","block","innerBlocks","newBlocks","reduce","acc","includes","stringify"],"sources":["@wordpress/core-data/src/footnotes/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { 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\tif ( typeof value !== 'string' ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif ( value.indexOf( 'data-fn' ) === -1 ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst richTextValue = create( { html: 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\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 ] = toHTMLString( { value: 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":"AAAA;AACA;AACA;AACA,SAASA,MAAM,EAAEC,YAAY,QAAQ,sBAAsB;;AAE3D;AACA;AACA;AACA,OAAOC,iBAAiB,MAAM,uBAAuB;AAErD,IAAIC,YAAY,GAAG,CAAC,CAAC;AAErB,OAAO,SAASC,uBAAuBA,CAAEC,MAAM,EAAEC,IAAI,EAAG;EACvD,MAAMC,MAAM,GAAG;IAAEF;EAAO,CAAC;EACzB,IAAK,CAAEC,IAAI,EAAG,OAAOC,MAAM;;EAE3B;EACA,IAAKD,IAAI,CAACE,SAAS,KAAKC,SAAS,EAAG,OAAOF,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EAAE,CAACC,EAAG,CAAC,EAAG;QACnC8B,GAAG,CAAE/B,EAAE,CAACC,EAAE,CAAE,GAAGD,EAAE;MAClB;MACA,OAAO+B,GAAG;IACX,CAAC,EAAE,CAAC,CAAE;EACP,CAAC;EAED,OAAO;IACNxC,IAAI,EAAE;MACL,GAAGA,IAAI;MACPE,SAAS,EAAEG,IAAI,CAACqC,SAAS,CAAE9B,YAAa;IACzC,CAAC;IACDb,MAAM,EAAEuC;EACT,CAAC;AACF"}
|
|
@@ -43,8 +43,8 @@ import { store as coreStore } from '../';
|
|
|
43
43
|
*
|
|
44
44
|
* @example
|
|
45
45
|
* ```js
|
|
46
|
+
* import { useCallback } from 'react';
|
|
46
47
|
* import { useDispatch } from '@wordpress/data';
|
|
47
|
-
* import { useCallback } from '@wordpress/element';
|
|
48
48
|
* import { __ } from '@wordpress/i18n';
|
|
49
49
|
* import { TextControl } from '@wordpress/components';
|
|
50
50
|
* import { store as noticeStore } from '@wordpress/notices';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useDispatch","useSelect","deprecated","useMemo","useQuerySelect","store","coreStore","useEntityRecord","kind","name","recordId","options","enabled","editEntityRecord","saveEditedEntityRecord","mutations","edit","record","editOptions","save","saveOptions","throwOnError","editedRecord","hasEdits","edits","select","getEditedEntityRecord","hasEditsForEntityRecord","getEntityRecordNonTransientEdits","data","querySelectRest","query","getEntityRecord","__experimentalUseEntityRecord","alternative","since"],"sources":["@wordpress/core-data/src/hooks/use-entity-record.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useQuerySelect from './use-query-select';\nimport { store as coreStore } from '../';\nimport type { Status } from './constants';\n\nexport interface EntityRecordResolution< RecordType > {\n\t/** The requested entity record */\n\trecord: RecordType | null;\n\n\t/** The edited entity record */\n\teditedRecord: Partial< RecordType >;\n\n\t/** The edits to the edited entity record */\n\tedits: Partial< RecordType >;\n\n\t/** Apply local (in-browser) edits to the edited entity record */\n\tedit: ( diff: Partial< RecordType > ) => void;\n\n\t/** Persist the edits to the server */\n\tsave: () => Promise< void >;\n\n\t/**\n\t * Is the record still being resolved?\n\t */\n\tisResolving: boolean;\n\n\t/**\n\t * Does the record have any local edits?\n\t */\n\thasEdits: boolean;\n\n\t/**\n\t * Is the record resolved by now?\n\t */\n\thasResolved: boolean;\n\n\t/** Resolution status */\n\tstatus: Status;\n}\n\nexport interface Options {\n\t/**\n\t * Whether to run the query or short-circuit and return null.\n\t *\n\t * @default true\n\t */\n\tenabled: boolean;\n}\n\n/**\n * Resolves the specified entity record.\n *\n * @since 6.1.0 Introduced in WordPress core.\n *\n * @param kind Kind of the entity, e.g. `root` or a `postType`. See rootEntitiesConfig in ../entities.ts for a list of available kinds.\n * @param name Name of the entity, e.g. `plugin` or a `post`. See rootEntitiesConfig in ../entities.ts for a list of available names.\n * @param recordId ID of the requested entity record.\n * @param options Optional hook options.\n * @example\n * ```js\n * import { useEntityRecord } from '@wordpress/core-data';\n *\n * function PageTitleDisplay( { id } ) {\n * const { record, isResolving } = useEntityRecord( 'postType', 'page', id );\n *\n * if ( isResolving ) {\n * return 'Loading...';\n * }\n *\n * return record.title;\n * }\n *\n * // Rendered in the application:\n * // <PageTitleDisplay id={ 1 } />\n * ```\n *\n * In the above example, when `PageTitleDisplay` is rendered into an\n * application, the page and the resolution details will be retrieved from\n * the store state using `getEntityRecord()`, or resolved if missing.\n *\n * @example\n * ```js\n * import {
|
|
1
|
+
{"version":3,"names":["useDispatch","useSelect","deprecated","useMemo","useQuerySelect","store","coreStore","useEntityRecord","kind","name","recordId","options","enabled","editEntityRecord","saveEditedEntityRecord","mutations","edit","record","editOptions","save","saveOptions","throwOnError","editedRecord","hasEdits","edits","select","getEditedEntityRecord","hasEditsForEntityRecord","getEntityRecordNonTransientEdits","data","querySelectRest","query","getEntityRecord","__experimentalUseEntityRecord","alternative","since"],"sources":["@wordpress/core-data/src/hooks/use-entity-record.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useQuerySelect from './use-query-select';\nimport { store as coreStore } from '../';\nimport type { Status } from './constants';\n\nexport interface EntityRecordResolution< RecordType > {\n\t/** The requested entity record */\n\trecord: RecordType | null;\n\n\t/** The edited entity record */\n\teditedRecord: Partial< RecordType >;\n\n\t/** The edits to the edited entity record */\n\tedits: Partial< RecordType >;\n\n\t/** Apply local (in-browser) edits to the edited entity record */\n\tedit: ( diff: Partial< RecordType > ) => void;\n\n\t/** Persist the edits to the server */\n\tsave: () => Promise< void >;\n\n\t/**\n\t * Is the record still being resolved?\n\t */\n\tisResolving: boolean;\n\n\t/**\n\t * Does the record have any local edits?\n\t */\n\thasEdits: boolean;\n\n\t/**\n\t * Is the record resolved by now?\n\t */\n\thasResolved: boolean;\n\n\t/** Resolution status */\n\tstatus: Status;\n}\n\nexport interface Options {\n\t/**\n\t * Whether to run the query or short-circuit and return null.\n\t *\n\t * @default true\n\t */\n\tenabled: boolean;\n}\n\n/**\n * Resolves the specified entity record.\n *\n * @since 6.1.0 Introduced in WordPress core.\n *\n * @param kind Kind of the entity, e.g. `root` or a `postType`. See rootEntitiesConfig in ../entities.ts for a list of available kinds.\n * @param name Name of the entity, e.g. `plugin` or a `post`. See rootEntitiesConfig in ../entities.ts for a list of available names.\n * @param recordId ID of the requested entity record.\n * @param options Optional hook options.\n * @example\n * ```js\n * import { useEntityRecord } from '@wordpress/core-data';\n *\n * function PageTitleDisplay( { id } ) {\n * const { record, isResolving } = useEntityRecord( 'postType', 'page', id );\n *\n * if ( isResolving ) {\n * return 'Loading...';\n * }\n *\n * return record.title;\n * }\n *\n * // Rendered in the application:\n * // <PageTitleDisplay id={ 1 } />\n * ```\n *\n * In the above example, when `PageTitleDisplay` is rendered into an\n * application, the page and the resolution details will be retrieved from\n * the store state using `getEntityRecord()`, or resolved if missing.\n *\n * @example\n * ```js\n * import { useCallback } from 'react';\n * import { useDispatch } from '@wordpress/data';\n * import { __ } from '@wordpress/i18n';\n * import { TextControl } from '@wordpress/components';\n * import { store as noticeStore } from '@wordpress/notices';\n * import { useEntityRecord } from '@wordpress/core-data';\n *\n * function PageRenameForm( { id } ) {\n * \tconst page = useEntityRecord( 'postType', 'page', id );\n * \tconst { createSuccessNotice, createErrorNotice } =\n * \t\tuseDispatch( noticeStore );\n *\n * \tconst setTitle = useCallback( ( title ) => {\n * \t\tpage.edit( { title } );\n * \t}, [ page.edit ] );\n *\n * \tif ( page.isResolving ) {\n * \t\treturn 'Loading...';\n * \t}\n *\n * \tasync function onRename( event ) {\n * \t\tevent.preventDefault();\n * \t\ttry {\n * \t\t\tawait page.save();\n * \t\t\tcreateSuccessNotice( __( 'Page renamed.' ), {\n * \t\t\t\ttype: 'snackbar',\n * \t\t\t} );\n * \t\t} catch ( error ) {\n * \t\t\tcreateErrorNotice( error.message, { type: 'snackbar' } );\n * \t\t}\n * \t}\n *\n * \treturn (\n * \t\t<form onSubmit={ onRename }>\n * \t\t\t<TextControl\n * \t\t\t\tlabel={ __( 'Name' ) }\n * \t\t\t\tvalue={ page.editedRecord.title }\n * \t\t\t\tonChange={ setTitle }\n * \t\t\t/>\n * \t\t\t<button type=\"submit\">{ __( 'Save' ) }</button>\n * \t\t</form>\n * \t);\n * }\n *\n * // Rendered in the application:\n * // <PageRenameForm id={ 1 } />\n * ```\n *\n * In the above example, updating and saving the page title is handled\n * via the `edit()` and `save()` mutation helpers provided by\n * `useEntityRecord()`;\n *\n * @return Entity record data.\n * @template RecordType\n */\nexport default function useEntityRecord< RecordType >(\n\tkind: string,\n\tname: string,\n\trecordId: string | number,\n\toptions: Options = { enabled: true }\n): EntityRecordResolution< RecordType > {\n\tconst { editEntityRecord, saveEditedEntityRecord } =\n\t\tuseDispatch( coreStore );\n\n\tconst mutations = useMemo(\n\t\t() => ( {\n\t\t\tedit: ( record, editOptions: any = {} ) =>\n\t\t\t\teditEntityRecord( kind, name, recordId, record, editOptions ),\n\t\t\tsave: ( saveOptions: any = {} ) =>\n\t\t\t\tsaveEditedEntityRecord( kind, name, recordId, {\n\t\t\t\t\tthrowOnError: true,\n\t\t\t\t\t...saveOptions,\n\t\t\t\t} ),\n\t\t} ),\n\t\t[ editEntityRecord, kind, name, recordId, saveEditedEntityRecord ]\n\t);\n\n\tconst { editedRecord, hasEdits, edits } = useSelect(\n\t\t( select ) => ( {\n\t\t\teditedRecord: select( coreStore ).getEditedEntityRecord(\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId\n\t\t\t),\n\t\t\thasEdits: select( coreStore ).hasEditsForEntityRecord(\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId\n\t\t\t),\n\t\t\tedits: select( coreStore ).getEntityRecordNonTransientEdits(\n\t\t\t\tkind,\n\t\t\t\tname,\n\t\t\t\trecordId\n\t\t\t),\n\t\t} ),\n\t\t[ kind, name, recordId ]\n\t);\n\n\tconst { data: record, ...querySelectRest } = useQuerySelect(\n\t\t( query ) => {\n\t\t\tif ( ! options.enabled ) {\n\t\t\t\treturn {\n\t\t\t\t\tdata: null,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn query( coreStore ).getEntityRecord( kind, name, recordId );\n\t\t},\n\t\t[ kind, name, recordId, options.enabled ]\n\t);\n\n\treturn {\n\t\trecord,\n\t\teditedRecord,\n\t\thasEdits,\n\t\tedits,\n\t\t...querySelectRest,\n\t\t...mutations,\n\t};\n}\n\nexport function __experimentalUseEntityRecord(\n\tkind: string,\n\tname: string,\n\trecordId: any,\n\toptions: any\n) {\n\tdeprecated( `wp.data.__experimentalUseEntityRecord`, {\n\t\talternative: 'wp.data.useEntityRecord',\n\t\tsince: '6.1',\n\t} );\n\treturn useEntityRecord( kind, name, recordId, options );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,OAAOC,UAAU,MAAM,uBAAuB;AAC9C,SAASC,OAAO,QAAQ,oBAAoB;;AAE5C;AACA;AACA;AACA,OAAOC,cAAc,MAAM,oBAAoB;AAC/C,SAASC,KAAK,IAAIC,SAAS,QAAQ,KAAK;AA+CxC;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;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,eAAeA,CACtCC,IAAY,EACZC,IAAY,EACZC,QAAyB,EACzBC,OAAgB,GAAG;EAAEC,OAAO,EAAE;AAAK,CAAC,EACG;EACvC,MAAM;IAAEC,gBAAgB;IAAEC;EAAuB,CAAC,GACjDd,WAAW,CAAEM,SAAU,CAAC;EAEzB,MAAMS,SAAS,GAAGZ,OAAO,CACxB,OAAQ;IACPa,IAAI,EAAEA,CAAEC,MAAM,EAAEC,WAAgB,GAAG,CAAC,CAAC,KACpCL,gBAAgB,CAAEL,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAEO,MAAM,EAAEC,WAAY,CAAC;IAC9DC,IAAI,EAAEA,CAAEC,WAAgB,GAAG,CAAC,CAAC,KAC5BN,sBAAsB,CAAEN,IAAI,EAAEC,IAAI,EAAEC,QAAQ,EAAE;MAC7CW,YAAY,EAAE,IAAI;MAClB,GAAGD;IACJ,CAAE;EACJ,CAAC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