@payloadcms/richtext-lexical 3.0.0-alpha.53 → 3.0.0-alpha.55
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/dist/field/features/blocks/feature.server.d.ts +4 -2
- package/dist/field/features/blocks/feature.server.d.ts.map +1 -1
- package/dist/field/features/blocks/feature.server.js +1 -0
- package/dist/field/features/blocks/feature.server.js.map +1 -1
- package/dist/field/features/blocks/populationPromise.d.ts.map +1 -1
- package/dist/field/features/blocks/populationPromise.js +1 -0
- package/dist/field/features/blocks/populationPromise.js.map +1 -1
- package/dist/field/features/blocks/validate.d.ts.map +1 -1
- package/dist/field/features/blocks/validate.js +1 -0
- package/dist/field/features/blocks/validate.js.map +1 -1
- package/dist/field/features/link/feature.server.d.ts +3 -3
- package/dist/field/features/link/feature.server.d.ts.map +1 -1
- package/dist/field/features/link/feature.server.js.map +1 -1
- package/dist/field/features/upload/component/index.js +1 -1
- package/dist/field/features/upload/component/index.js.map +1 -1
- package/dist/field/features/upload/feature.server.d.ts +2 -2
- package/dist/field/features/upload/feature.server.d.ts.map +1 -1
- package/dist/field/features/upload/feature.server.js.map +1 -1
- package/dist/generateComponentMap.d.ts.map +1 -1
- package/dist/generateComponentMap.js +1 -0
- package/dist/generateComponentMap.js.map +1 -1
- package/dist/generateSchemaMap.d.ts.map +1 -1
- package/dist/generateSchemaMap.js +1 -0
- package/dist/generateSchemaMap.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { Block } from 'payload/types';
|
|
1
|
+
import type { Block, FieldWithRichTextRequiredEditor } from 'payload/types';
|
|
2
2
|
import type { FeatureProviderProviderServer } from '../types.js';
|
|
3
3
|
import type { BlocksFeatureClientProps } from './feature.client.js';
|
|
4
4
|
export type BlocksFeatureProps = {
|
|
5
|
-
blocks: Block
|
|
5
|
+
blocks: Array<Omit<Block, 'fields'> & {
|
|
6
|
+
fields: FieldWithRichTextRequiredEditor[];
|
|
7
|
+
}>;
|
|
6
8
|
};
|
|
7
9
|
export declare const BlocksFeature: FeatureProviderProviderServer<BlocksFeatureProps, BlocksFeatureClientProps>;
|
|
8
10
|
//# sourceMappingURL=feature.server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blocks/feature.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAqB,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blocks/feature.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAqB,+BAA+B,EAAE,MAAM,eAAe,CAAA;AAK9F,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAQnE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,KAAK,CACX,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG;QACtB,MAAM,EAAE,+BAA+B,EAAE,CAAA;KAC1C,CACF,CAAA;CACF,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,6BAA6B,CACvD,kBAAkB,EAClB,wBAAwB,CAwIzB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/features/blocks/feature.server.ts"],"sourcesContent":["import type { Block, BlockField, Field } from 'payload/types'\n\nimport { baseBlockFields, sanitizeFields } from 'payload/config'\nimport { fieldsToJSONSchema, formatLabels } from 'payload/utilities'\n\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { BlocksFeatureClientProps } from './feature.client.js'\n\nimport { cloneDeep } from '../../lexical/utils/cloneDeep.js'\nimport { BlocksFeatureClientComponent } from './feature.client.js'\nimport { BlockNode } from './nodes/BlocksNode.js'\nimport { blockPopulationPromiseHOC } from './populationPromise.js'\nimport { blockValidationHOC } from './validate.js'\n\nexport type BlocksFeatureProps = {\n blocks: Block[]\n}\n\nexport const BlocksFeature: FeatureProviderProviderServer<\n BlocksFeatureProps,\n BlocksFeatureClientProps\n> = (props) => {\n // Sanitization taken from payload/src/fields/config/sanitize.ts\n\n if (props?.blocks?.length) {\n props.blocks = props.blocks.map((block) => {\n const blockCopy = cloneDeep(block)\n\n return {\n ...blockCopy,\n fields: blockCopy.fields.concat(baseBlockFields),\n labels: !blockCopy.labels ? formatLabels(blockCopy.slug) : blockCopy.labels,\n }\n })\n // unSanitizedBlock.fields are sanitized in the React component and not here.\n // That's because we do not have access to the payload config here.\n }\n\n // Build clientProps\n const clientProps: BlocksFeatureClientProps = {\n reducedBlocks: [],\n }\n for (const block of props.blocks) {\n clientProps.reducedBlocks.push({\n slug: block.slug,\n fieldMap: [],\n imageAltText: block.imageAltText,\n imageURL: block.imageURL,\n labels: block.labels,\n })\n }\n\n return {\n feature: () => {\n return {\n ClientComponent: BlocksFeatureClientComponent,\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ config, props, schemaMap: schemaMapFromProps, schemaPath }) => {\n const schemaMap: {\n [key: string]: Field[]\n } = {}\n\n /**\n * Add sub-fields to the schemaMap. E.g. if you have an array field as part of the block and it runs addRow, it will request these\n * sub-fields from the component map. Thus we need to put them in the component map here.\n */\n const handleFields = (parentPath: string, fields: Field[]) => {\n for (const field of fields) {\n if ('name' in field && 'fields' in field) {\n schemaMap[parentPath + '.' + field.name] = field.fields\n handleFields(parentPath + '.' + field.name, field.fields)\n }\n if ('blocks' in field) {\n for (const block of field.blocks) {\n schemaMap[parentPath + '.' + field.name + '.' + block.slug] = block.fields || []\n handleFields(parentPath + '.' + field.name + '.' + block.slug, block.fields)\n }\n }\n if ('tabs' in field) {\n for (const tab of field.tabs) {\n if ('name' in tab) {\n schemaMap[parentPath + '.' + tab.name] = tab.fields || []\n handleFields(parentPath + '.' + tab.name, tab.fields)\n } else {\n handleFields(parentPath, tab.fields)\n }\n }\n }\n }\n }\n\n for (const block of props.blocks) {\n schemaMap[block.slug] = block.fields || []\n handleFields(block.slug, block.fields)\n }\n\n return schemaMap\n },\n generatedTypes: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n }) => {\n if (!props?.blocks?.length) {\n return currentSchema\n }\n\n // sanitize blocks\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n const sanitizedBlocks = props.blocks.map((block) => {\n const blockCopy = cloneDeep(block)\n return {\n ...blockCopy,\n fields: sanitizeFields({\n config,\n fields: blockCopy.fields,\n validRelationships,\n }),\n }\n })\n\n const blocksField: BlockField = {\n name: field?.name + '_lexical_blocks',\n type: 'blocks',\n blocks: sanitizedBlocks,\n }\n // This is only done so that interfaceNameDefinitions sets those block's interfaceNames.\n // we don't actually use the JSON Schema itself in the generated types yet.\n fieldsToJSONSchema(\n collectionIDFieldTypes,\n [blocksField],\n interfaceNameDefinitions,\n config,\n )\n\n return currentSchema\n },\n },\n nodes: [\n {\n node: BlockNode,\n populationPromises: [blockPopulationPromiseHOC(props)],\n validations: [blockValidationHOC(props)],\n },\n ],\n serverFeatureProps: props,\n }\n },\n key: 'blocks',\n serverFeatureProps: props,\n }\n}\n"],"names":["baseBlockFields","sanitizeFields","fieldsToJSONSchema","formatLabels","cloneDeep","BlocksFeatureClientComponent","BlockNode","blockPopulationPromiseHOC","blockValidationHOC","BlocksFeature","props","blocks","length","map","block","blockCopy","fields","concat","labels","slug","clientProps","reducedBlocks","push","fieldMap","imageAltText","imageURL","feature","ClientComponent","clientFeatureProps","generateSchemaMap","config","schemaMap","schemaMapFromProps","schemaPath","handleFields","parentPath","field","name","tab","tabs","generatedTypes","modifyOutputSchema","collectionIDFieldTypes","currentSchema","interfaceNameDefinitions","validRelationships","collections","c","sanitizedBlocks","blocksField","type","nodes","node","populationPromises","validations","serverFeatureProps","key"],"mappings":"AAEA,SAASA,eAAe,EAAEC,cAAc,QAAQ,iBAAgB;AAChE,SAASC,kBAAkB,EAAEC,YAAY,QAAQ,oBAAmB;AAKpE,SAASC,SAAS,QAAQ,mCAAkC;AAC5D,SAASC,4BAA4B,QAAQ,sBAAqB;AAClE,SAASC,SAAS,QAAQ,wBAAuB;AACjD,SAASC,yBAAyB,QAAQ,yBAAwB;AAClE,SAASC,kBAAkB,QAAQ,gBAAe;
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/blocks/feature.server.ts"],"sourcesContent":["import type { Block, BlockField, Field, FieldWithRichTextRequiredEditor } from 'payload/types'\n\nimport { baseBlockFields, sanitizeFields } from 'payload/config'\nimport { fieldsToJSONSchema, formatLabels } from 'payload/utilities'\n\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { BlocksFeatureClientProps } from './feature.client.js'\n\nimport { cloneDeep } from '../../lexical/utils/cloneDeep.js'\nimport { BlocksFeatureClientComponent } from './feature.client.js'\nimport { BlockNode } from './nodes/BlocksNode.js'\nimport { blockPopulationPromiseHOC } from './populationPromise.js'\nimport { blockValidationHOC } from './validate.js'\n\nexport type BlocksFeatureProps = {\n blocks: Array<\n Omit<Block, 'fields'> & {\n fields: FieldWithRichTextRequiredEditor[]\n }\n >\n}\n\nexport const BlocksFeature: FeatureProviderProviderServer<\n BlocksFeatureProps,\n BlocksFeatureClientProps\n> = (props) => {\n // Sanitization taken from payload/src/fields/config/sanitize.ts\n\n if (props?.blocks?.length) {\n props.blocks = props.blocks.map((block) => {\n const blockCopy = cloneDeep(block)\n\n return {\n ...blockCopy,\n fields: blockCopy.fields.concat(baseBlockFields),\n labels: !blockCopy.labels ? formatLabels(blockCopy.slug) : blockCopy.labels,\n }\n })\n // unSanitizedBlock.fields are sanitized in the React component and not here.\n // That's because we do not have access to the payload config here.\n }\n\n // Build clientProps\n const clientProps: BlocksFeatureClientProps = {\n reducedBlocks: [],\n }\n for (const block of props.blocks) {\n clientProps.reducedBlocks.push({\n slug: block.slug,\n fieldMap: [],\n imageAltText: block.imageAltText,\n imageURL: block.imageURL,\n labels: block.labels,\n })\n }\n\n return {\n feature: () => {\n return {\n ClientComponent: BlocksFeatureClientComponent,\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ config, props, schemaMap: schemaMapFromProps, schemaPath }) => {\n const schemaMap: {\n [key: string]: Field[]\n } = {}\n\n /**\n * Add sub-fields to the schemaMap. E.g. if you have an array field as part of the block and it runs addRow, it will request these\n * sub-fields from the component map. Thus we need to put them in the component map here.\n */\n const handleFields = (parentPath: string, fields: Field[]) => {\n for (const field of fields) {\n if ('name' in field && 'fields' in field) {\n schemaMap[parentPath + '.' + field.name] = field.fields\n handleFields(parentPath + '.' + field.name, field.fields)\n }\n if ('blocks' in field) {\n for (const block of field.blocks) {\n schemaMap[parentPath + '.' + field.name + '.' + block.slug] = block.fields || []\n handleFields(parentPath + '.' + field.name + '.' + block.slug, block.fields)\n }\n }\n if ('tabs' in field) {\n for (const tab of field.tabs) {\n if ('name' in tab) {\n schemaMap[parentPath + '.' + tab.name] = tab.fields || []\n handleFields(parentPath + '.' + tab.name, tab.fields)\n } else {\n handleFields(parentPath, tab.fields)\n }\n }\n }\n }\n }\n\n for (const block of props.blocks) {\n schemaMap[block.slug] = block.fields || []\n handleFields(block.slug, block.fields)\n }\n\n return schemaMap\n },\n generatedTypes: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n }) => {\n if (!props?.blocks?.length) {\n return currentSchema\n }\n\n // sanitize blocks\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n const sanitizedBlocks = props.blocks.map((block) => {\n const blockCopy = cloneDeep(block)\n return {\n ...blockCopy,\n fields: sanitizeFields({\n config,\n fields: blockCopy.fields,\n requireFieldLevelRichTextEditor: true,\n validRelationships,\n }),\n }\n })\n\n const blocksField: BlockField = {\n name: field?.name + '_lexical_blocks',\n type: 'blocks',\n blocks: sanitizedBlocks,\n }\n // This is only done so that interfaceNameDefinitions sets those block's interfaceNames.\n // we don't actually use the JSON Schema itself in the generated types yet.\n fieldsToJSONSchema(\n collectionIDFieldTypes,\n [blocksField],\n interfaceNameDefinitions,\n config,\n )\n\n return currentSchema\n },\n },\n nodes: [\n {\n node: BlockNode,\n populationPromises: [blockPopulationPromiseHOC(props)],\n validations: [blockValidationHOC(props)],\n },\n ],\n serverFeatureProps: props,\n }\n },\n key: 'blocks',\n serverFeatureProps: props,\n }\n}\n"],"names":["baseBlockFields","sanitizeFields","fieldsToJSONSchema","formatLabels","cloneDeep","BlocksFeatureClientComponent","BlockNode","blockPopulationPromiseHOC","blockValidationHOC","BlocksFeature","props","blocks","length","map","block","blockCopy","fields","concat","labels","slug","clientProps","reducedBlocks","push","fieldMap","imageAltText","imageURL","feature","ClientComponent","clientFeatureProps","generateSchemaMap","config","schemaMap","schemaMapFromProps","schemaPath","handleFields","parentPath","field","name","tab","tabs","generatedTypes","modifyOutputSchema","collectionIDFieldTypes","currentSchema","interfaceNameDefinitions","validRelationships","collections","c","sanitizedBlocks","requireFieldLevelRichTextEditor","blocksField","type","nodes","node","populationPromises","validations","serverFeatureProps","key"],"mappings":"AAEA,SAASA,eAAe,EAAEC,cAAc,QAAQ,iBAAgB;AAChE,SAASC,kBAAkB,EAAEC,YAAY,QAAQ,oBAAmB;AAKpE,SAASC,SAAS,QAAQ,mCAAkC;AAC5D,SAASC,4BAA4B,QAAQ,sBAAqB;AAClE,SAASC,SAAS,QAAQ,wBAAuB;AACjD,SAASC,yBAAyB,QAAQ,yBAAwB;AAClE,SAASC,kBAAkB,QAAQ,gBAAe;AAUlD,OAAO,MAAMC,gBAGT,CAACC;IACH,gEAAgE;IAEhE,IAAIA,OAAOC,QAAQC,QAAQ;QACzBF,MAAMC,MAAM,GAAGD,MAAMC,MAAM,CAACE,GAAG,CAAC,CAACC;YAC/B,MAAMC,YAAYX,UAAUU;YAE5B,OAAO;gBACL,GAAGC,SAAS;gBACZC,QAAQD,UAAUC,MAAM,CAACC,MAAM,CAACjB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wBACNgD,oBAAoB;4BAAC/C,0BAA0BG;yBAAO;wBACtD6C,aAAa;4BAAC/C,mBAAmBE;yBAAO;oBAC1C;iBACD;gBACD8C,oBAAoB9C;YACtB;QACF;QACA+C,KAAK;QACLD,oBAAoB9C;IACtB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"populationPromise.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blocks/populationPromise.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAIhE,eAAO,MAAM,yBAAyB,UAC7B,kBAAkB,KACxB,kBAAkB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"populationPromise.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blocks/populationPromise.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAIhE,eAAO,MAAM,yBAAyB,UAC7B,kBAAkB,KACxB,kBAAkB,mBAAmB,CA4DvC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/features/blocks/populationPromise.ts"],"sourcesContent":["import type { Block } from 'payload/types'\n\nimport { sanitizeFields } from 'payload/config'\n\nimport type { PopulationPromise } from '../types.js'\nimport type { BlocksFeatureProps } from './feature.server.js'\nimport type { SerializedBlockNode } from './nodes/BlocksNode.js'\n\nimport { recurseNestedFields } from '../../../populate/recurseNestedFields.js'\n\nexport const blockPopulationPromiseHOC = (\n props: BlocksFeatureProps,\n): PopulationPromise<SerializedBlockNode> => {\n const blockPopulationPromise: PopulationPromise<SerializedBlockNode> = ({\n context,\n currentDepth,\n depth,\n editorPopulationPromises,\n findMany,\n flattenLocales,\n node,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n }) => {\n const blocks: Block[] = props.blocks\n const blockFieldData = node.fields\n\n const promises: Promise<void>[] = []\n\n // Sanitize block's fields here. This is done here and not in the feature, because the payload config is available here\n const payloadConfig = req.payload.config\n const validRelationships = payloadConfig.collections.map((c) => c.slug) || []\n blocks.forEach((block) => {\n block.fields = sanitizeFields({\n config: payloadConfig,\n fields: block.fields,\n validRelationships,\n })\n })\n\n // find block used in this node\n const block = props.blocks.find((block) => block.slug === blockFieldData.blockType)\n if (!block || !block?.fields?.length || !blockFieldData) {\n return promises\n }\n\n recurseNestedFields({\n context,\n currentDepth,\n data: blockFieldData,\n depth,\n editorPopulationPromises,\n fields: block.fields,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n promises,\n req,\n showHiddenFields,\n // The afterReadPromise gets its data from looking for field.name inside the siblingDoc. Thus, here we cannot pass the whole document's siblingDoc, but only the siblingDoc (sibling fields) of the current field.\n siblingDoc: blockFieldData,\n })\n\n return promises\n }\n\n return blockPopulationPromise\n}\n"],"names":["sanitizeFields","recurseNestedFields","blockPopulationPromiseHOC","props","blockPopulationPromise","context","currentDepth","depth","editorPopulationPromises","findMany","flattenLocales","node","overrideAccess","populationPromises","req","showHiddenFields","siblingDoc","blocks","blockFieldData","fields","promises","payloadConfig","payload","config","validRelationships","collections","map","c","slug","forEach","block","find","blockType","length","data"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAM/C,SAASC,mBAAmB,QAAQ,2CAA0C;AAE9E,OAAO,MAAMC,4BAA4B,CACvCC;IAEA,MAAMC,yBAAiE,CAAC,EACtEC,OAAO,EACPC,YAAY,EACZC,KAAK,EACLC,wBAAwB,EACxBC,QAAQ,EACRC,cAAc,EACdC,IAAI,EACJC,cAAc,EACdC,kBAAkB,EAClBC,GAAG,EACHC,gBAAgB,EAChBC,UAAU,EACX;QACC,MAAMC,SAAkBd,MAAMc,MAAM;QACpC,MAAMC,iBAAiBP,KAAKQ,MAAM;QAElC,MAAMC,WAA4B,EAAE;QAEpC,uHAAuH;QACvH,MAAMC,gBAAgBP,IAAIQ,OAAO,CAACC,MAAM;QACxC,MAAMC,qBAAqBH,cAAcI,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;QAC7EX,OAAOY,OAAO,CAAC,CAACC;YACdA,MAAMX,MAAM,GAAGnB,eAAe;gBAC5BuB,QAAQF;gBACRF,QAAQW,MAAMX,MAAM;
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/blocks/populationPromise.ts"],"sourcesContent":["import type { Block } from 'payload/types'\n\nimport { sanitizeFields } from 'payload/config'\n\nimport type { PopulationPromise } from '../types.js'\nimport type { BlocksFeatureProps } from './feature.server.js'\nimport type { SerializedBlockNode } from './nodes/BlocksNode.js'\n\nimport { recurseNestedFields } from '../../../populate/recurseNestedFields.js'\n\nexport const blockPopulationPromiseHOC = (\n props: BlocksFeatureProps,\n): PopulationPromise<SerializedBlockNode> => {\n const blockPopulationPromise: PopulationPromise<SerializedBlockNode> = ({\n context,\n currentDepth,\n depth,\n editorPopulationPromises,\n findMany,\n flattenLocales,\n node,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n }) => {\n const blocks: Block[] = props.blocks\n const blockFieldData = node.fields\n\n const promises: Promise<void>[] = []\n\n // Sanitize block's fields here. This is done here and not in the feature, because the payload config is available here\n const payloadConfig = req.payload.config\n const validRelationships = payloadConfig.collections.map((c) => c.slug) || []\n blocks.forEach((block) => {\n block.fields = sanitizeFields({\n config: payloadConfig,\n fields: block.fields,\n requireFieldLevelRichTextEditor: true,\n validRelationships,\n })\n })\n\n // find block used in this node\n const block = props.blocks.find((block) => block.slug === blockFieldData.blockType)\n if (!block || !block?.fields?.length || !blockFieldData) {\n return promises\n }\n\n recurseNestedFields({\n context,\n currentDepth,\n data: blockFieldData,\n depth,\n editorPopulationPromises,\n fields: block.fields,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n promises,\n req,\n showHiddenFields,\n // The afterReadPromise gets its data from looking for field.name inside the siblingDoc. Thus, here we cannot pass the whole document's siblingDoc, but only the siblingDoc (sibling fields) of the current field.\n siblingDoc: blockFieldData,\n })\n\n return promises\n }\n\n return blockPopulationPromise\n}\n"],"names":["sanitizeFields","recurseNestedFields","blockPopulationPromiseHOC","props","blockPopulationPromise","context","currentDepth","depth","editorPopulationPromises","findMany","flattenLocales","node","overrideAccess","populationPromises","req","showHiddenFields","siblingDoc","blocks","blockFieldData","fields","promises","payloadConfig","payload","config","validRelationships","collections","map","c","slug","forEach","block","requireFieldLevelRichTextEditor","find","blockType","length","data"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAM/C,SAASC,mBAAmB,QAAQ,2CAA0C;AAE9E,OAAO,MAAMC,4BAA4B,CACvCC;IAEA,MAAMC,yBAAiE,CAAC,EACtEC,OAAO,EACPC,YAAY,EACZC,KAAK,EACLC,wBAAwB,EACxBC,QAAQ,EACRC,cAAc,EACdC,IAAI,EACJC,cAAc,EACdC,kBAAkB,EAClBC,GAAG,EACHC,gBAAgB,EAChBC,UAAU,EACX;QACC,MAAMC,SAAkBd,MAAMc,MAAM;QACpC,MAAMC,iBAAiBP,KAAKQ,MAAM;QAElC,MAAMC,WAA4B,EAAE;QAEpC,uHAAuH;QACvH,MAAMC,gBAAgBP,IAAIQ,OAAO,CAACC,MAAM;QACxC,MAAMC,qBAAqBH,cAAcI,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;QAC7EX,OAAOY,OAAO,CAAC,CAACC;YACdA,MAAMX,MAAM,GAAGnB,eAAe;gBAC5BuB,QAAQF;gBACRF,QAAQW,MAAMX,MAAM;gBACpBY,iCAAiC;gBACjCP;YACF;QACF;QAEA,+BAA+B;QAC/B,MAAMM,QAAQ3B,MAAMc,MAAM,CAACe,IAAI,CAAC,CAACF,QAAUA,MAAMF,IAAI,KAAKV,eAAee,SAAS;QAClF,IAAI,CAACH,SAAS,CAACA,OAAOX,QAAQe,UAAU,CAAChB,gBAAgB;YACvD,OAAOE;QACT;QAEAnB,oBAAoB;YAClBI;YACAC;YACA6B,MAAMjB;YACNX;YACAC;YACAW,QAAQW,MAAMX,MAAM;YACpBV;YACAC;YACAE;YACAC;YACAO;YACAN;YACAC;YACA,kNAAkN;YAClNC,YAAYE;QACd;QAEA,OAAOE;IACT;IAEA,OAAOhB;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blocks/validate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAEhE,eAAO,MAAM,kBAAkB,UACtB,kBAAkB,KACxB,eAAe,mBAAmB,
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/field/features/blocks/validate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAEhE,eAAO,MAAM,kBAAkB,UACtB,kBAAkB,KACxB,eAAe,mBAAmB,CAmEpC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/features/blocks/validate.ts"],"sourcesContent":["import type { Block } from 'payload/types'\n\nimport { sanitizeFields } from 'payload/config'\n\nimport type { NodeValidation } from '../types.js'\nimport type { BlocksFeatureProps } from './feature.server.js'\nimport type { SerializedBlockNode } from './nodes/BlocksNode.js'\n\nexport const blockValidationHOC = (\n props: BlocksFeatureProps,\n): NodeValidation<SerializedBlockNode> => {\n const blockValidation: NodeValidation<SerializedBlockNode> = async ({ node, validation }) => {\n const blockFieldData = node.fields\n const blocks: Block[] = props.blocks\n\n const {\n options: {\n req,\n req: {\n payload: { config },\n },\n },\n } = validation\n\n // Sanitize block's fields here. This is done here and not in the feature, because the payload config is available here\n const validRelationships = config.collections.map((c) => c.slug) || []\n blocks.forEach((block) => {\n block.fields = sanitizeFields({\n config,\n fields: block.fields,\n validRelationships,\n })\n })\n\n // find block\n const block = props.blocks.find((block) => block.slug === blockFieldData.blockType)\n\n // validate block\n if (!block) {\n return 'Block not found'\n }\n\n for (const field of block.fields) {\n if ('validate' in field && typeof field.validate === 'function' && field.validate) {\n const fieldValue = 'name' in field ? node.fields[field.name] : null\n\n const passesCondition = field.admin?.condition\n ? Boolean(\n field.admin.condition(fieldValue, node.fields, {\n user: req?.user,\n }),\n )\n : true\n if (!passesCondition) {\n continue // Fixes https://github.com/payloadcms/payload/issues/4000\n }\n\n const validationResult = await field.validate(fieldValue, {\n ...field,\n id: validation.options.id,\n data: fieldValue,\n operation: validation.options.operation,\n req,\n siblingData: validation.options.siblingData,\n })\n\n if (validationResult !== true) {\n return validationResult\n }\n }\n }\n\n return true\n }\n\n return blockValidation\n}\n"],"names":["sanitizeFields","blockValidationHOC","props","blockValidation","node","validation","blockFieldData","fields","blocks","options","req","payload","config","validRelationships","collections","map","c","slug","forEach","block","find","blockType","field","validate","fieldValue","name","passesCondition","admin","condition","Boolean","user","validationResult","id","data","operation","siblingData"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAM/C,OAAO,MAAMC,qBAAqB,CAChCC;IAEA,MAAMC,kBAAuD,OAAO,EAAEC,IAAI,EAAEC,UAAU,EAAE;QACtF,MAAMC,iBAAiBF,KAAKG,MAAM;QAClC,MAAMC,SAAkBN,MAAMM,MAAM;QAEpC,MAAM,EACJC,SAAS,EACPC,GAAG,EACHA,KAAK,EACHC,SAAS,EAAEC,MAAM,EAAE,EACpB,EACF,EACF,GAAGP;QAEJ,uHAAuH;QACvH,MAAMQ,qBAAqBD,OAAOE,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;QACtET,OAAOU,OAAO,CAAC,CAACC;YACdA,MAAMZ,MAAM,GAAGP,eAAe;gBAC5BY;gBACAL,QAAQY,MAAMZ,MAAM;
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/blocks/validate.ts"],"sourcesContent":["import type { Block } from 'payload/types'\n\nimport { sanitizeFields } from 'payload/config'\n\nimport type { NodeValidation } from '../types.js'\nimport type { BlocksFeatureProps } from './feature.server.js'\nimport type { SerializedBlockNode } from './nodes/BlocksNode.js'\n\nexport const blockValidationHOC = (\n props: BlocksFeatureProps,\n): NodeValidation<SerializedBlockNode> => {\n const blockValidation: NodeValidation<SerializedBlockNode> = async ({ node, validation }) => {\n const blockFieldData = node.fields\n const blocks: Block[] = props.blocks\n\n const {\n options: {\n req,\n req: {\n payload: { config },\n },\n },\n } = validation\n\n // Sanitize block's fields here. This is done here and not in the feature, because the payload config is available here\n const validRelationships = config.collections.map((c) => c.slug) || []\n blocks.forEach((block) => {\n block.fields = sanitizeFields({\n config,\n fields: block.fields,\n requireFieldLevelRichTextEditor: true,\n validRelationships,\n })\n })\n\n // find block\n const block = props.blocks.find((block) => block.slug === blockFieldData.blockType)\n\n // validate block\n if (!block) {\n return 'Block not found'\n }\n\n for (const field of block.fields) {\n if ('validate' in field && typeof field.validate === 'function' && field.validate) {\n const fieldValue = 'name' in field ? node.fields[field.name] : null\n\n const passesCondition = field.admin?.condition\n ? Boolean(\n field.admin.condition(fieldValue, node.fields, {\n user: req?.user,\n }),\n )\n : true\n if (!passesCondition) {\n continue // Fixes https://github.com/payloadcms/payload/issues/4000\n }\n\n const validationResult = await field.validate(fieldValue, {\n ...field,\n id: validation.options.id,\n data: fieldValue,\n operation: validation.options.operation,\n req,\n siblingData: validation.options.siblingData,\n })\n\n if (validationResult !== true) {\n return validationResult\n }\n }\n }\n\n return true\n }\n\n return blockValidation\n}\n"],"names":["sanitizeFields","blockValidationHOC","props","blockValidation","node","validation","blockFieldData","fields","blocks","options","req","payload","config","validRelationships","collections","map","c","slug","forEach","block","requireFieldLevelRichTextEditor","find","blockType","field","validate","fieldValue","name","passesCondition","admin","condition","Boolean","user","validationResult","id","data","operation","siblingData"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAM/C,OAAO,MAAMC,qBAAqB,CAChCC;IAEA,MAAMC,kBAAuD,OAAO,EAAEC,IAAI,EAAEC,UAAU,EAAE;QACtF,MAAMC,iBAAiBF,KAAKG,MAAM;QAClC,MAAMC,SAAkBN,MAAMM,MAAM;QAEpC,MAAM,EACJC,SAAS,EACPC,GAAG,EACHA,KAAK,EACHC,SAAS,EAAEC,MAAM,EAAE,EACpB,EACF,EACF,GAAGP;QAEJ,uHAAuH;QACvH,MAAMQ,qBAAqBD,OAAOE,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;QACtET,OAAOU,OAAO,CAAC,CAACC;YACdA,MAAMZ,MAAM,GAAGP,eAAe;gBAC5BY;gBACAL,QAAQY,MAAMZ,MAAM;gBACpBa,iCAAiC;gBACjCP;YACF;QACF;QAEA,aAAa;QACb,MAAMM,QAAQjB,MAAMM,MAAM,CAACa,IAAI,CAAC,CAACF,QAAUA,MAAMF,IAAI,KAAKX,eAAegB,SAAS;QAElF,iBAAiB;QACjB,IAAI,CAACH,OAAO;YACV,OAAO;QACT;QAEA,KAAK,MAAMI,SAASJ,MAAMZ,MAAM,CAAE;YAChC,IAAI,cAAcgB,SAAS,OAAOA,MAAMC,QAAQ,KAAK,cAAcD,MAAMC,QAAQ,EAAE;gBACjF,MAAMC,aAAa,UAAUF,QAAQnB,KAAKG,MAAM,CAACgB,MAAMG,IAAI,CAAC,GAAG;gBAE/D,MAAMC,kBAAkBJ,MAAMK,KAAK,EAAEC,YACjCC,QACEP,MAAMK,KAAK,CAACC,SAAS,CAACJ,YAAYrB,KAAKG,MAAM,EAAE;oBAC7CwB,MAAMrB,KAAKqB;gBACb,MAEF;gBACJ,IAAI,CAACJ,iBAAiB;oBACpB,UAAS,0DAA0D;gBACrE;gBAEA,MAAMK,mBAAmB,MAAMT,MAAMC,QAAQ,CAACC,YAAY;oBACxD,GAAGF,KAAK;oBACRU,IAAI5B,WAAWI,OAAO,CAACwB,EAAE;oBACzBC,MAAMT;oBACNU,WAAW9B,WAAWI,OAAO,CAAC0B,SAAS;oBACvCzB;oBACA0B,aAAa/B,WAAWI,OAAO,CAAC2B,WAAW;gBAC7C;gBAEA,IAAIJ,qBAAqB,MAAM;oBAC7B,OAAOA;gBACT;YACF;QACF;QAEA,OAAO;IACT;IAEA,OAAO7B;AACT,EAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { I18n } from '@payloadcms/translations';
|
|
2
2
|
import type { SanitizedConfig } from 'payload/config';
|
|
3
|
-
import type {
|
|
3
|
+
import type { FieldWithRichTextRequiredEditor } from 'payload/types';
|
|
4
4
|
import type { FeatureProviderProviderServer } from '../types.js';
|
|
5
5
|
import type { ClientProps } from './feature.client.js';
|
|
6
6
|
export type ExclusiveLinkCollectionsProps = {
|
|
@@ -25,9 +25,9 @@ export type LinkFeatureServerProps = ExclusiveLinkCollectionsProps & {
|
|
|
25
25
|
*/
|
|
26
26
|
fields?: ((args: {
|
|
27
27
|
config: SanitizedConfig;
|
|
28
|
-
defaultFields:
|
|
28
|
+
defaultFields: FieldWithRichTextRequiredEditor[];
|
|
29
29
|
i18n: I18n;
|
|
30
|
-
}) =>
|
|
30
|
+
}) => FieldWithRichTextRequiredEditor[]) | FieldWithRichTextRequiredEditor[];
|
|
31
31
|
};
|
|
32
32
|
export declare const LinkFeature: FeatureProviderProviderServer<LinkFeatureServerProps, ClientProps>;
|
|
33
33
|
//# sourceMappingURL=feature.server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/link/feature.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/link/feature.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAA;AAMpE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAUtD,MAAM,MAAM,6BAA6B,GACrC;IACE;;;QAGI;IACJ,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;IAG9B,kBAAkB,CAAC,EAAE,KAAK,CAAA;CAC3B,GACD;IAEE,mBAAmB,CAAC,EAAE,KAAK,CAAA;IAE3B;;;QAGI;IACJ,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC9B,CAAA;AAEL,MAAM,MAAM,sBAAsB,GAAG,6BAA6B,GAAG;IACnE;;;OAGG;IACH,MAAM,CAAC,EACH,CAAC,CAAC,IAAI,EAAE;QACN,MAAM,EAAE,eAAe,CAAA;QACvB,aAAa,EAAE,+BAA+B,EAAE,CAAA;QAChD,IAAI,EAAE,IAAI,CAAA;KACX,KAAK,+BAA+B,EAAE,CAAC,GACxC,+BAA+B,EAAE,CAAA;CACtC,CAAA;AAED,eAAO,MAAM,WAAW,EAAE,6BAA6B,CAAC,sBAAsB,EAAE,WAAW,CAgG1F,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/features/link/feature.server.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { SanitizedConfig } from 'payload/config'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/link/feature.server.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { SanitizedConfig } from 'payload/config'\nimport type { FieldWithRichTextRequiredEditor } from 'payload/types'\n\nimport { initI18n } from '@payloadcms/translations'\nimport { translations } from '@payloadcms/translations/client'\n\nimport type { HTMLConverter } from '../converters/html/converter/types.js'\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { ClientProps } from './feature.client.js'\nimport type { SerializedAutoLinkNode, SerializedLinkNode } from './nodes/types.js'\n\nimport { convertLexicalNodesToHTML } from '../converters/html/converter/index.js'\nimport { LinkFeatureClientComponent } from './feature.client.js'\nimport { AutoLinkNode } from './nodes/AutoLinkNode.js'\nimport { LinkNode } from './nodes/LinkNode.js'\nimport { transformExtraFields } from './plugins/floatingLinkEditor/utilities.js'\nimport { linkPopulationPromiseHOC } from './populationPromise.js'\n\nexport type ExclusiveLinkCollectionsProps =\n | {\n /**\n * The collections that should be disabled for internal linking. Overrides the `enableRichTextLink` property in the collection config.\n * When this property is set, `enabledCollections` will not be available.\n **/\n disabledCollections?: string[]\n\n // Ensures that enabledCollections is not available when disabledCollections is set\n enabledCollections?: never\n }\n | {\n // Ensures that disabledCollections is not available when enabledCollections is set\n disabledCollections?: never\n\n /**\n * The collections that should be enabled for internal linking. Overrides the `enableRichTextLink` property in the collection config\n * When this property is set, `disabledCollections` will not be available.\n **/\n enabledCollections?: string[]\n }\n\nexport type LinkFeatureServerProps = ExclusiveLinkCollectionsProps & {\n /**\n * A function or array defining additional fields for the link feature. These will be\n * displayed in the link editor drawer.\n */\n fields?:\n | ((args: {\n config: SanitizedConfig\n defaultFields: FieldWithRichTextRequiredEditor[]\n i18n: I18n\n }) => FieldWithRichTextRequiredEditor[])\n | FieldWithRichTextRequiredEditor[]\n}\n\nexport const LinkFeature: FeatureProviderProviderServer<LinkFeatureServerProps, ClientProps> = (\n props,\n) => {\n if (!props) {\n props = {}\n }\n return {\n feature: () => {\n return {\n ClientComponent: LinkFeatureClientComponent,\n clientFeatureProps: {\n disabledCollections: props.disabledCollections,\n enabledCollections: props.enabledCollections,\n } as ExclusiveLinkCollectionsProps,\n generateSchemaMap: ({ config, props }) => {\n const i18n = initI18n({ config: config.i18n, context: 'client', translations })\n\n return {\n fields: transformExtraFields(\n props.fields,\n config,\n i18n,\n props.enabledCollections,\n props.disabledCollections,\n ),\n }\n },\n nodes: [\n {\n converters: {\n html: {\n converter: async ({ converters, node, parent, payload }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n payload,\n })\n\n const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n\n let href: string = node.fields.url\n if (node.fields.linkType === 'internal') {\n href =\n typeof node.fields.doc?.value === 'string'\n ? node.fields.doc?.value\n : node.fields.doc?.value?.id\n }\n\n return `<a href=\"${href}\"${rel}>${childrenText}</a>`\n },\n nodeTypes: [AutoLinkNode.getType()],\n } as HTMLConverter<SerializedAutoLinkNode>,\n },\n node: AutoLinkNode,\n populationPromises: [linkPopulationPromiseHOC(props)],\n },\n {\n converters: {\n html: {\n converter: async ({ converters, node, parent, payload }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n payload,\n })\n\n const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n\n const href: string =\n node.fields.linkType === 'custom'\n ? node.fields.url\n : (node.fields.doc?.value as string)\n\n return `<a href=\"${href}\"${rel}>${childrenText}</a>`\n },\n nodeTypes: [LinkNode.getType()],\n } as HTMLConverter<SerializedLinkNode>,\n },\n node: LinkNode,\n populationPromises: [linkPopulationPromiseHOC(props)],\n },\n ],\n serverFeatureProps: props,\n }\n },\n key: 'link',\n serverFeatureProps: props,\n }\n}\n"],"names":["initI18n","translations","convertLexicalNodesToHTML","LinkFeatureClientComponent","AutoLinkNode","LinkNode","transformExtraFields","linkPopulationPromiseHOC","LinkFeature","props","feature","ClientComponent","clientFeatureProps","disabledCollections","enabledCollections","generateSchemaMap","config","i18n","context","fields","nodes","converters","html","converter","node","parent","payload","childrenText","lexicalNodes","children","rel","newTab","href","url","linkType","doc","value","id","nodeTypes","getType","populationPromises","serverFeatureProps","key"],"mappings":"AAIA,SAASA,QAAQ,QAAQ,2BAA0B;AACnD,SAASC,YAAY,QAAQ,kCAAiC;AAO9D,SAASC,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,0BAA0B,QAAQ,sBAAqB;AAChE,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,QAAQ,QAAQ,sBAAqB;AAC9C,SAASC,oBAAoB,QAAQ,4CAA2C;AAChF,SAASC,wBAAwB,QAAQ,yBAAwB;AAsCjE,OAAO,MAAMC,cAAkF,CAC7FC;IAEA,IAAI,CAACA,OAAO;QACVA,QAAQ,CAAC;IACX;IACA,OAAO;QACLC,SAAS;YACP,OAAO;gBACLC,iBAAiBR;gBACjBS,oBAAoB;oBAClBC,qBAAqBJ,MAAMI,mBAAmB;oBAC9CC,oBAAoBL,MAAMK,kBAAkB;gBAC9C;gBACAC,mBAAmB,CAAC,EAAEC,MAAM,EAAEP,KAAK,EAAE;oBACnC,MAAMQ,OAAOjB,SAAS;wBAAEgB,QAAQA,OAAOC,IAAI;wBAAEC,SAAS;wBAAUjB;oBAAa;oBAE7E,OAAO;wBACLkB,QAAQb,qBACNG,MAAMU,MAAM,EACZH,QACAC,MACAR,MAAMK,kBAAkB,EACxBL,MAAMI,mBAAmB;oBAE7B;gBACF;gBACAO,OAAO;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B,OAAO,CAAC,SAAS,EAAEJ,KAAK,CAAC,EAAEF,IAAI,CAAC,EAAEH,aAAa,IAAI,CAAC;gCACtD;gCACAW,WAAW;oCAACjC,SAASkC,OAAO;iCAAG;4BACjC;wBACF;wBACAf,MAAMnB;wBACNmC,oBAAoB;4BAACjC,yBAAyBE;yBAAO;oBACvD;iBACD;gBACDgC,oBAAoBhC;YACtB;QACF;QACAiC,KAAK;QACLD,oBAAoBhC;IACtB;AACF,EAAC"}
|
|
@@ -41,7 +41,7 @@ const Component = (props)=>{
|
|
|
41
41
|
const [{ data }, { setParams }] = usePayloadAPI(`${serverURL}${api}/${relatedCollection.slug}/${value?.id}`, {
|
|
42
42
|
initialParams
|
|
43
43
|
});
|
|
44
|
-
const thumbnailSRC = data?.thumbnailURL;
|
|
44
|
+
const thumbnailSRC = data?.thumbnailURL || data?.url;
|
|
45
45
|
const removeUpload = useCallback(()=>{
|
|
46
46
|
editor.update(()=>{
|
|
47
47
|
$getNodeByKey(nodeKey).remove();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/features/upload/component/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig } from 'payload/types'\n\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey } = lexicalImport\n\nimport { Button } from '@payloadcms/ui/elements/Button'\nimport { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer'\nimport { DrawerToggler } from '@payloadcms/ui/elements/Drawer'\nimport { useDrawerSlug } from '@payloadcms/ui/elements/Drawer'\nimport { File } from '@payloadcms/ui/graphics/File'\nimport usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback, useReducer, useState } from 'react'\n\nimport type { ClientComponentProps } from '../../types.js'\nimport type { UploadFeaturePropsClient } from '../feature.client.js'\nimport type { UploadData } from '../nodes/UploadNode.js'\n\nimport { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js'\nimport { EnabledRelationshipsCondition } from '../../relationship/utils/EnabledRelationshipsCondition.js'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport { ExtraFieldsUploadDrawer } from './ExtraFieldsDrawer/index.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\nexport type ElementProps = {\n data: UploadData\n nodeKey: string\n //uploadProps: UploadFeatureProps\n}\n\nconst Component: React.FC<ElementProps> = (props) => {\n const {\n data: { fields, relationTo, value },\n nodeKey,\n } = props\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { editorConfig, field } = useEditorConfigContext()\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection, setRelatedCollection] = useState<ClientCollectionConfig>(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const drawerSlug = useDrawerSlug('upload-drawer')\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value?.id,\n collectionSlug: relatedCollection.slug,\n })\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value?.id}`,\n { initialParams },\n )\n\n const thumbnailSRC = data?.thumbnailURL\n\n const removeUpload = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n const updateUpload = useCallback(\n (json) => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n dispatchCacheBust()\n closeDrawer()\n },\n [setParams, cacheBust, closeDrawer],\n )\n\n const hasExtraFields = (\n editorConfig?.resolvedFeatureMap?.get('upload')\n ?.clientFeatureProps as ClientComponentProps<UploadFeaturePropsClient>\n ).collections?.[relatedCollection.slug]?.hasExtraFields\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__topRow`}>\n {/* TODO: migrate to use @payloadcms/ui/elements/Thumbnail component */}\n <div className={`${baseClass}__thumbnail`}>\n {thumbnailSRC ? <img alt={data?.filename} src={thumbnailSRC} /> : <File />}\n </div>\n <div className={`${baseClass}__topRowRightPanel`}>\n <div className={`${baseClass}__collectionLabel`}>\n {getTranslation(relatedCollection.labels.singular, i18n)}\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n {hasExtraFields ? (\n <DrawerToggler\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={field?.readOnly}\n slug={drawerSlug}\n >\n <Button\n buttonStyle=\"icon-label\"\n el=\"div\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n }}\n round\n tooltip={t('fields:editRelationship')}\n />\n </DrawerToggler>\n ) : null}\n\n <Button\n buttonStyle=\"icon-label\"\n disabled={field?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_UPLOAD_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapUpload')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeUpload()\n }}\n round\n tooltip={t('fields:removeUpload')}\n />\n </div>\n )}\n </div>\n </div>\n <div className={`${baseClass}__bottomRow`}>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <strong>{data?.filename}</strong>\n </DocumentDrawerToggler>\n </div>\n </div>\n {value?.id && <DocumentDrawer onSave={updateUpload} />}\n <ExtraFieldsUploadDrawer\n drawerSlug={drawerSlug}\n relatedCollection={relatedCollection}\n {...props}\n />\n </div>\n )\n}\n\nexport const UploadComponent = (props: ElementProps): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <Component {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","useLexicalNodeSelection","getTranslation","lexicalImport","$getNodeByKey","Button","useDocumentDrawer","DrawerToggler","useDrawerSlug","File","usePayloadAPI","useConfig","useTranslation","React","useCallback","useReducer","useState","useEditorConfigContext","EnabledRelationshipsCondition","INSERT_UPLOAD_WITH_DRAWER_COMMAND","ExtraFieldsUploadDrawer","baseClass","initialParams","depth","Component","props","data","fields","relationTo","value","nodeKey","collections","routes","api","serverURL","editor","isSelected","setSelected","clearSelection","editorConfig","field","i18n","t","cacheBust","dispatchCacheBust","state","relatedCollection","setRelatedCollection","find","coll","slug","drawerSlug","DocumentDrawer","DocumentDrawerToggler","closeDrawer","id","collectionSlug","setParams","thumbnailSRC","thumbnailURL","removeUpload","update","remove","updateUpload","json","hasExtraFields","resolvedFeatureMap","get","clientFeatureProps","div","className","filter","Boolean","join","contentEditable","img","alt","filename","src","labels","singular","isEditable","disabled","readOnly","buttonStyle","el","icon","onClick","e","preventDefault","round","tooltip","dispatchCommand","replace","strong","onSave","UploadComponent","uploads"],"mappings":"AAAA;AAGA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,SAASE,uBAAuB,QAAQ,4CAA2C;AACnF,SAASC,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,SAASE,MAAM,QAAQ,iCAAgC;AACvD,SAASC,i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":["../../../../../src/field/features/upload/component/index.tsx"],"sourcesContent":["'use client'\nimport type { ClientCollectionConfig } from 'payload/types'\n\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport lexicalImport from 'lexical'\nconst { $getNodeByKey } = lexicalImport\n\nimport { Button } from '@payloadcms/ui/elements/Button'\nimport { useDocumentDrawer } from '@payloadcms/ui/elements/DocumentDrawer'\nimport { DrawerToggler } from '@payloadcms/ui/elements/Drawer'\nimport { useDrawerSlug } from '@payloadcms/ui/elements/Drawer'\nimport { File } from '@payloadcms/ui/graphics/File'\nimport usePayloadAPI from '@payloadcms/ui/hooks/usePayloadAPI'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport React, { useCallback, useReducer, useState } from 'react'\n\nimport type { ClientComponentProps } from '../../types.js'\nimport type { UploadFeaturePropsClient } from '../feature.client.js'\nimport type { UploadData } from '../nodes/UploadNode.js'\n\nimport { useEditorConfigContext } from '../../../lexical/config/client/EditorConfigProvider.js'\nimport { EnabledRelationshipsCondition } from '../../relationship/utils/EnabledRelationshipsCondition.js'\nimport { INSERT_UPLOAD_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\nimport { ExtraFieldsUploadDrawer } from './ExtraFieldsDrawer/index.js'\nimport './index.scss'\n\nconst baseClass = 'lexical-upload'\n\nconst initialParams = {\n depth: 0,\n}\n\nexport type ElementProps = {\n data: UploadData\n nodeKey: string\n //uploadProps: UploadFeatureProps\n}\n\nconst Component: React.FC<ElementProps> = (props) => {\n const {\n data: { fields, relationTo, value },\n nodeKey,\n } = props\n\n const {\n collections,\n routes: { api },\n serverURL,\n } = useConfig()\n\n const [editor] = useLexicalComposerContext()\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { editorConfig, field } = useEditorConfigContext()\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [relatedCollection, setRelatedCollection] = useState<ClientCollectionConfig>(() =>\n collections.find((coll) => coll.slug === relationTo),\n )\n\n const drawerSlug = useDrawerSlug('upload-drawer')\n\n const [DocumentDrawer, DocumentDrawerToggler, { closeDrawer }] = useDocumentDrawer({\n id: value?.id,\n collectionSlug: relatedCollection.slug,\n })\n\n // Get the referenced document\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value?.id}`,\n { initialParams },\n )\n\n const thumbnailSRC = data?.thumbnailURL || data?.url\n\n const removeUpload = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey).remove()\n })\n }, [editor, nodeKey])\n\n const updateUpload = useCallback(\n (json) => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n dispatchCacheBust()\n closeDrawer()\n },\n [setParams, cacheBust, closeDrawer],\n )\n\n const hasExtraFields = (\n editorConfig?.resolvedFeatureMap?.get('upload')\n ?.clientFeatureProps as ClientComponentProps<UploadFeaturePropsClient>\n ).collections?.[relatedCollection.slug]?.hasExtraFields\n\n return (\n <div\n className={[baseClass, isSelected && `${baseClass}--selected`].filter(Boolean).join(' ')}\n contentEditable={false}\n >\n <div className={`${baseClass}__card`}>\n <div className={`${baseClass}__topRow`}>\n {/* TODO: migrate to use @payloadcms/ui/elements/Thumbnail component */}\n <div className={`${baseClass}__thumbnail`}>\n {thumbnailSRC ? <img alt={data?.filename} src={thumbnailSRC} /> : <File />}\n </div>\n <div className={`${baseClass}__topRowRightPanel`}>\n <div className={`${baseClass}__collectionLabel`}>\n {getTranslation(relatedCollection.labels.singular, i18n)}\n </div>\n {editor.isEditable() && (\n <div className={`${baseClass}__actions`}>\n {hasExtraFields ? (\n <DrawerToggler\n className={`${baseClass}__upload-drawer-toggler`}\n disabled={field?.readOnly}\n slug={drawerSlug}\n >\n <Button\n buttonStyle=\"icon-label\"\n el=\"div\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n }}\n round\n tooltip={t('fields:editRelationship')}\n />\n </DrawerToggler>\n ) : null}\n\n <Button\n buttonStyle=\"icon-label\"\n disabled={field?.readOnly}\n el=\"div\"\n icon=\"swap\"\n onClick={() => {\n editor.dispatchCommand(INSERT_UPLOAD_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }}\n round\n tooltip={t('fields:swapUpload')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeUpload()\n }}\n round\n tooltip={t('fields:removeUpload')}\n />\n </div>\n )}\n </div>\n </div>\n <div className={`${baseClass}__bottomRow`}>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <strong>{data?.filename}</strong>\n </DocumentDrawerToggler>\n </div>\n </div>\n {value?.id && <DocumentDrawer onSave={updateUpload} />}\n <ExtraFieldsUploadDrawer\n drawerSlug={drawerSlug}\n relatedCollection={relatedCollection}\n {...props}\n />\n </div>\n )\n}\n\nexport const UploadComponent = (props: ElementProps): React.ReactNode => {\n return (\n <EnabledRelationshipsCondition {...props} uploads>\n <Component {...props} />\n </EnabledRelationshipsCondition>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","useLexicalNodeSelection","getTranslation","lexicalImport","$getNodeByKey","Button","useDocumentDrawer","DrawerToggler","useDrawerSlug","File","usePayloadAPI","useConfig","useTranslation","React","useCallback","useReducer","useState","useEditorConfigContext","EnabledRelationshipsCondition","INSERT_UPLOAD_WITH_DRAWER_COMMAND","ExtraFieldsUploadDrawer","baseClass","initialParams","depth","Component","props","data","fields","relationTo","value","nodeKey","collections","routes","api","serverURL","editor","isSelected","setSelected","clearSelection","editorConfig","field","i18n","t","cacheBust","dispatchCacheBust","state","relatedCollection","setRelatedCollection","find","coll","slug","drawerSlug","DocumentDrawer","DocumentDrawerToggler","closeDrawer","id","collectionSlug","setParams","thumbnailSRC","thumbnailURL","url","removeUpload","update","remove","updateUpload","json","hasExtraFields","resolvedFeatureMap","get","clientFeatureProps","div","className","filter","Boolean","join","contentEditable","img","alt","filename","src","labels","singular","isEditable","disabled","readOnly","buttonStyle","el","icon","onClick","e","preventDefault","round","tooltip","dispatchCommand","replace","strong","onSave","UploadComponent","uploads"],"mappings":"AAAA;AAGA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AACtC,SAASE,uBAAuB,QAAQ,4CAA2C;AACnF,SAASC,cAAc,QAAQ,2BAA0B;AACzD,OAAOC,mBAAmB,UAAS;AACnC,MAAM,EAAEC,aAAa,EAAE,GAAGD;AAE1B,SAASE,MAAM,QAAQ,iCAAgC;AACvD,SAASC,iBAAiB,QAAQ,yCAAwC;AAC1E,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,IAAI,QAAQ,+BAA8B;AACnD,OAAOC,mBAAmB,qCAAoC;AAC9D,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,cAAc,QAAQ,uCAAsC;AACrE,OAAOC,SAASC,WAAW,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,QAAO;AAMhE,SAASC,sBAAsB,QAAQ,yDAAwD;AAC/F,SAASC,6BAA6B,QAAQ,4DAA2D;AACzG,SAASC,iCAAiC,QAAQ,wBAAuB;AACzE,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,OAAO,eAAc;AAErB,MAAMC,YAAY;AAElB,MAAMC,gBAAgB;IACpBC,OAAO;AACT;AAQA,MAAMC,YAAoC,CAACC;IACzC,MAAM,EACJC,MAAM,EAAEC,MAAM,EAAEC,UAAU,EAAEC,KAAK,EAAE,EACnCC,OAAO,EACR,GAAGL;IAEJ,MAAM,EACJM,WA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UAAU,cAAc,CAAC;QACvC8D,UAAU3C,OAAO4C;QACjBG,MAAK;QACLC,SAAS,CAACC;YACRA,EAAEC,cAAc;YAChB7B;QACF;QACA8B,OAAAA;QACAC,SAASlD,EAAE;yBAMrB,oBAAC4B;QAAIC,WAAW,CAAC,EAAElD,UAAU,WAAW,CAAC;qBACvC,oBAACgC;QAAsBkB,WAAW,CAAC,EAAElD,UAAU,oBAAoB,CAAC;qBAClE,oBAAC0E,gBAAQrE,MAAMoD,cAIpBjD,OAAO0B,oBAAM,oBAACH;QAAe4C,QAAQhC;sBACtC,oBAAC5C;QACC+B,YAAYA;QACZL,mBAAmBA;QAClB,GAAGrB,KAAK;;AAIjB;AAEA,OAAO,MAAMwE,kBAAkB,CAACxE;IAC9B,qBACE,oBAACP;QAA+B,GAAGO,KAAK;QAAEyE,SAAAA;qBACxC,oBAAC1E,WAAcC;AAGrB,EAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FieldWithRichTextRequiredEditor } from 'payload/types';
|
|
2
2
|
import type { FeatureProviderProviderServer } from '../types.js';
|
|
3
3
|
import type { UploadFeaturePropsClient } from './feature.client.js';
|
|
4
4
|
export type UploadFeatureProps = {
|
|
5
5
|
collections: {
|
|
6
6
|
[collection: string]: {
|
|
7
|
-
fields:
|
|
7
|
+
fields: FieldWithRichTextRequiredEditor[];
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/upload/feature.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/field/features/upload/feature.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,+BAA+B,EAAW,MAAM,eAAe,CAAA;AAGpF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAA;AAOnE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE;QACX,CAAC,UAAU,EAAE,MAAM,GAAG;YACpB,MAAM,EAAE,+BAA+B,EAAE,CAAA;SAC1C,CAAA;KACF,CAAA;CACF,CAAA;AASD,eAAO,MAAM,aAAa,EAAE,6BAA6B,CACvD,kBAAkB,EAClB,wBAAwB,CA2GzB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/features/upload/feature.server.ts"],"sourcesContent":["import type { Field, Payload } from 'payload/types'\n\nimport type { HTMLConverter } from '../converters/html/converter/types.js'\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { UploadFeaturePropsClient } from './feature.client.js'\n\nimport { UploadFeatureClientComponent } from './feature.client.js'\nimport { type SerializedUploadNode, UploadNode } from './nodes/UploadNode.js'\nimport { uploadPopulationPromiseHOC } from './populationPromise.js'\nimport { uploadValidation } from './validate.js'\n\nexport type UploadFeatureProps = {\n collections: {\n [collection: string]: {\n fields:
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/upload/feature.server.ts"],"sourcesContent":["import type { Field, FieldWithRichTextRequiredEditor, Payload } from 'payload/types'\n\nimport type { HTMLConverter } from '../converters/html/converter/types.js'\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { UploadFeaturePropsClient } from './feature.client.js'\n\nimport { UploadFeatureClientComponent } from './feature.client.js'\nimport { type SerializedUploadNode, UploadNode } from './nodes/UploadNode.js'\nimport { uploadPopulationPromiseHOC } from './populationPromise.js'\nimport { uploadValidation } from './validate.js'\n\nexport type UploadFeatureProps = {\n collections: {\n [collection: string]: {\n fields: FieldWithRichTextRequiredEditor[]\n }\n }\n}\n\n/**\n * Get the absolute URL for an upload URL by potentially prepending the serverURL\n */\nfunction getAbsoluteURL(url: string, payload: Payload): string {\n return url?.startsWith('http') ? url : (payload?.config?.serverURL || '') + url\n}\n\nexport const UploadFeature: FeatureProviderProviderServer<\n UploadFeatureProps,\n UploadFeaturePropsClient\n> = (props) => {\n if (!props) {\n props = { collections: {} }\n }\n\n const clientProps: UploadFeaturePropsClient = { collections: {} }\n if (props.collections) {\n for (const collection in props.collections) {\n clientProps.collections[collection] = {\n hasExtraFields: props.collections[collection].fields.length >= 1,\n }\n }\n }\n\n return {\n feature: () => {\n return {\n ClientComponent: UploadFeatureClientComponent,\n clientFeatureProps: clientProps,\n generateSchemaMap: ({ props }) => {\n if (!props?.collections) return {}\n\n const map: {\n [key: string]: Field[]\n } = {}\n\n for (const collection in props.collections) {\n map[collection] = props.collections[collection].fields\n }\n\n return map\n },\n nodes: [\n {\n converters: {\n html: {\n converter: async ({ node, payload }) => {\n if (payload) {\n const uploadDocument: any = await payload.findByID({\n id: node.value.id,\n collection: node.relationTo,\n })\n\n const url: string = getAbsoluteURL(uploadDocument?.url as string, payload)\n\n /**\n * If the upload is not an image, return a link to the upload\n */\n if (!(uploadDocument?.mimeType as string)?.startsWith('image')) {\n return `<a href=\"${url}\" rel=\"noopener noreferrer\">${uploadDocument.filename}</a>`\n }\n\n /**\n * If the upload is a simple image with no different sizes, return a simple img tag\n */\n if (!uploadDocument?.sizes || !Object.keys(uploadDocument?.sizes).length) {\n return `<img src=\"${url}\" alt=\"${uploadDocument?.filename}\" width=\"${uploadDocument?.width}\" height=\"${uploadDocument?.height}\"/>`\n }\n\n /**\n * If the upload is an image with different sizes, return a picture element\n */\n let pictureHTML = '<picture>'\n\n // Iterate through each size in the data.sizes object\n for (const size in uploadDocument.sizes) {\n const imageSize = uploadDocument.sizes[size]\n\n // Skip if any property of the size object is null\n if (\n !imageSize.width ||\n !imageSize.height ||\n !imageSize.mimeType ||\n !imageSize.filesize ||\n !imageSize.filename ||\n !imageSize.url\n ) {\n continue\n }\n const imageSizeURL: string = getAbsoluteURL(imageSize?.url as string, payload)\n\n pictureHTML += `<source srcset=\"${imageSizeURL}\" media=\"(max-width: ${imageSize.width}px)\" type=\"${imageSize.mimeType}\">`\n }\n\n // Add the default img tag\n pictureHTML += `<img src=\"${url}\" alt=\"Image\" width=\"${uploadDocument.width}\" height=\"${uploadDocument.height}\">`\n pictureHTML += '</picture>'\n return pictureHTML\n } else {\n return `<img src=\"${node.value.id}\" />`\n }\n },\n nodeTypes: [UploadNode.getType()],\n } as HTMLConverter<SerializedUploadNode>,\n },\n node: UploadNode,\n populationPromises: [uploadPopulationPromiseHOC(props)],\n validations: [uploadValidation()],\n },\n ],\n serverFeatureProps: props,\n }\n },\n key: 'upload',\n serverFeatureProps: props,\n }\n}\n"],"names":["UploadFeatureClientComponent","UploadNode","uploadPopulationPromiseHOC","uploadValidation","getAbsoluteURL","url","payload","startsWith","config","serverURL","UploadFeature","props","collections","clientProps","collection","hasExtraFields","fields","length","feature","ClientComponent","clientFeatureProps","generateSchemaMap","map","nodes","converters","html","converter","node","uploadDocument","findByID","id","value","relationTo","mimeType","filename","sizes","Object","keys","width","height","pictureHTML","size","imageSize","filesize","imageSizeURL","nodeTypes","getType","populationPromises","validations","serverFeatureProps","key"],"mappings":"AAMA,SAASA,4BAA4B,QAAQ,sBAAqB;AAClE,SAAoCC,UAAU,QAAQ,wBAAuB;AAC7E,SAASC,0BAA0B,QAAQ,yBAAwB;AACnE,SAASC,gBAAgB,QAAQ,gBAAe;AAUhD;;CAEC,GACD,SAASC,eAAeC,GAAW,EAAEC,OAAgB;IACnD,OAAOD,KAAKE,WAAW,UAAUF,MAAM,AAACC,CAAAA,SAASE,QAAQC,aAAa,EAAC,IAAKJ;AAC9E;AAEA,OAAO,MAAMK,gBAGT,CAACC;IACH,IAAI,CAACA,OAAO;QACVA,QAAQ;YAAEC,aAAa,CAAC;QAAE;IAC5B;IAEA,MAAMC,cAAwC;QAAED,aAAa,CAAC;IAAE;IAChE,IAAID,MAAMC,WAAW,EAAE;QACrB,IAAK,MAAME,cAAcH,MAAMC,WAAW,CAAE;YAC1CC,YAAYD,W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AQb,eAAeO,KAAK,CAAE;4CACvC,MAAMO,YAAYd,eAAeO,KAAK,CAACM,KAAK;4CAE5C,kDAAkD;4CAClD,IACE,CAACC,UAAUJ,KAAK,IAChB,CAACI,UAAUH,MAAM,IACjB,CAACG,UAAUT,QAAQ,IACnB,CAACS,UAAUC,QAAQ,IACnB,CAACD,UAAUR,QAAQ,IACnB,CAACQ,UAAUrC,GAAG,EACd;gDACA;4CACF;4CACA,MAAMuC,eAAuBxC,eAAesC,WAAWrC,KAAeC;4CAEtEkC,eAAe,CAAC,gBAAgB,EAAEI,aAAa,qBAAqB,EAAEF,UAAUJ,KAAK,CAAC,WAAW,EAAEI,UAAUT,QAAQ,CAAC,EAAE,CAAC;wCAC3H;wCAEA,0BAA0B;wCAC1BO,eAAe,CAAC,UAAU,EAAEnC,IAAI,qBAAqB,EAAEuB,eAAeU,KAAK,CAAC,UAAU,EAAEV,eAAeW,MAAM,CAAC,EAAE,CAAC;wCACjHC,eAAe;wCACf,OAAOA;oCACT,OAAO;wCACL,OAAO,CAAC,UAAU,EAAEb,KAAKI,KAAK,CAACD,EAAE,CAAC,IAAI,CAAC;oCACzC;gCACF;gCACAe,WAAW;oCAAC5C,WAAW6C,OAAO;iCAAG;4BACnC;wBACF;wBACAnB,MAAM1B;wBACN8C,oBAAoB;4BAAC7C,2BAA2BS;yBAAO;wBACvDqC,aAAa;4BAAC7C;yBAAmB;oBACnC;iBACD;gBACD8C,oBAAoBtC;YACtB;QACF;QACAuC,KAAK;QACLD,oBAAoBtC;IACtB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateComponentMap.d.ts","sourceRoot":"","sources":["../src/generateComponentMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAMpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAKzE,eAAO,MAAM,uBAAuB,SAC3B;IACL,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,KAAG,eAAe,CAAC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"generateComponentMap.d.ts","sourceRoot":"","sources":["../src/generateComponentMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAMpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAKzE,eAAO,MAAM,uBAAuB,SAC3B;IACL,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,KAAG,eAAe,CAAC,sBAAsB,CA+GzC,CAAA"}
|
|
@@ -43,6 +43,7 @@ export const getGenerateComponentMap = (args)=>({ config, schemaPath })=>{
|
|
|
43
43
|
const sanitizedFields = sanitizeFields({
|
|
44
44
|
config,
|
|
45
45
|
fields: cloneDeep(fields),
|
|
46
|
+
requireFieldLevelRichTextEditor: true,
|
|
46
47
|
validRelationships
|
|
47
48
|
});
|
|
48
49
|
const mappedFields = mapFields({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generateComponentMap.tsx"],"sourcesContent":["import type { RichTextAdapter } from 'payload/types'\n\nimport { mapFields } from '@payloadcms/ui/utilities/buildComponentMap'\nimport { sanitizeFields } from 'payload/config'\nimport React from 'react'\n\nimport type { ResolvedServerFeatureMap } from './field/features/types.js'\nimport type { GeneratedFeatureProviderComponent } from './types.js'\n\nimport { cloneDeep } from './field/lexical/utils/cloneDeep.js'\n\nexport const getGenerateComponentMap =\n (args: {\n resolvedFeatureMap: ResolvedServerFeatureMap\n }): RichTextAdapter['generateComponentMap'] =>\n ({ config, schemaPath }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n const componentMap = new Map()\n\n // turn args.resolvedFeatureMap into an array of [key, value] pairs, ordered by value.order, lowest order first:\n const resolvedFeatureMapArray = Array.from(args.resolvedFeatureMap.entries()).sort(\n (a, b) => a[1].order - b[1].order,\n )\n\n componentMap.set(\n `features`,\n resolvedFeatureMapArray\n .map(([featureKey, resolvedFeature]) => {\n const ClientComponent = resolvedFeature.ClientComponent\n const clientComponentProps = resolvedFeature.clientFeatureProps\n\n /**\n * Handle Feature Component Maps\n */\n if (\n 'generateComponentMap' in resolvedFeature &&\n typeof resolvedFeature.generateComponentMap === 'function'\n ) {\n const components = resolvedFeature.generateComponentMap({\n config,\n props: resolvedFeature.serverFeatureProps,\n schemaPath,\n })\n\n for (const componentKey in components) {\n const Component = components[componentKey]\n\n if (Component) {\n componentMap.set(\n `feature.${featureKey}.components.${componentKey}`,\n <Component\n componentKey={componentKey}\n featureKey={resolvedFeature.key}\n key={`${resolvedFeature.key}-${componentKey}`}\n />,\n )\n }\n }\n }\n\n /**\n * Handle Feature Schema Maps (rendered fields)\n */\n if (\n 'generateSchemaMap' in resolvedFeature &&\n typeof resolvedFeature.generateSchemaMap === 'function'\n ) {\n const schemas = resolvedFeature.generateSchemaMap({\n config,\n props: resolvedFeature.serverFeatureProps,\n schemaMap: new Map(),\n schemaPath,\n })\n\n for (const schemaKey in schemas) {\n const fields = schemas[schemaKey]\n\n const sanitizedFields = sanitizeFields({\n config,\n fields: cloneDeep(fields),\n validRelationships,\n })\n\n const mappedFields = mapFields({\n config,\n disableAddingID: true,\n fieldSchema: sanitizedFields,\n parentPath: `${schemaPath}.feature.${featureKey}.fields.${schemaKey}`,\n readOnly: false,\n })\n\n componentMap.set(`feature.${featureKey}.fields.${schemaKey}`, mappedFields)\n }\n }\n\n if (!ClientComponent) {\n return null\n }\n\n return {\n ClientComponent:\n clientComponentProps && typeof clientComponentProps === 'object' ? (\n <ClientComponent\n {...clientComponentProps}\n featureKey={resolvedFeature.key}\n key={resolvedFeature.key}\n order={resolvedFeature.order}\n />\n ) : (\n <ClientComponent\n featureKey={resolvedFeature.key}\n key={resolvedFeature.key}\n order={resolvedFeature.order}\n />\n ),\n key: resolvedFeature.key,\n order: resolvedFeature.order,\n } as GeneratedFeatureProviderComponent\n })\n .filter((feature) => feature !== null),\n )\n\n return componentMap\n }\n"],"names":["mapFields","sanitizeFields","React","cloneDeep","getGenerateComponentMap","args","config","schemaPath","validRelationships","collections","map","c","slug","componentMap","Map","resolvedFeatureMapArray","Array","from","resolvedFeatureMap","entries","sort","a","b","order","set","featureKey","resolvedFeature","ClientComponent","clientComponentProps","clientFeatureProps","generateComponentMap","components","props","serverFeatureProps","componentKey","Component","key","generateSchemaMap","schemas","schemaMap","schemaKey","fields","sanitizedFields","mappedFields","disableAddingID","fieldSchema","parentPath","readOnly","filter","feature"],"mappings":"AAEA,SAASA,SAAS,QAAQ,6CAA4C;AACtE,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,WAAW,QAAO;AAKzB,SAASC,SAAS,QAAQ,qCAAoC;AAE9D,OAAO,MAAMC,0BACX,CAACC,OAGD,CAAC,EAAEC,MAAM,EAAEC,UAAU,EAAE;QACrB,MAAMC,qBAAqBF,OAAOG,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;QAEtE,MAAMC,eAAe,IAAIC;QAEzB,gHAAgH;QAChH,MAAMC,0BAA0BC,MAAMC,IAAI,CAACZ,KAAKa,kBAAkB,CAACC,OAAO,IAAIC,IAAI,CAChF,CAACC,GAAGC,IAAMD,CAAC,CAAC,EAAE,CAACE,KAAK,GAAGD,CAAC,CAAC,EAAE,CAACC,KAAK;QAGnCV,aAAaW,GAAG,CACd,CAAC,QAAQ,CAAC,EACVT,wBACGL,GAAG,CAAC,CAAC,CAACe,YAAYC,gBAAgB;YACjC,MAAMC,kBAAkBD,gBAAgBC,eAAe;YACvD,MAAMC,uBAAuBF,gBAAgBG,kBAAkB;YAE/D;;WAEC,GACD,IACE,0BAA0BH,mBAC1B,OAAOA,gBAAgBI,oBAAoB,KAAK,YAChD;gBACA,MAAMC,aAAaL,gBAAgBI,oBAAoB,CAAC;oBACtDxB;oBACA0B,OAAON,gBAAgBO,kBAAkB;oBACzC1B;gBACF;gBAEA,IAAK,MAAM2B,gBAAgBH,WAAY;oBACrC,MAAMI,YAAYJ,UAAU,CAACG,aAAa;oBAE1C,IAAIC,WAAW;wBACbtB,aAAaW,GAAG,CACd,CAAC,QAAQ,EAAEC,WAAW,YAAY,EAAES,aAAa,CAAC,gBAClD,oBAACC;4BACCD,cAAcA;4BACdT,YAAYC,gBAAgBU,GAAG;4BAC/BA,KAAK,CAAC,EAAEV,gBAAgBU,GAAG,CAAC,CAAC,EAAEF,aAAa,CAAC;;oBAGnD;gBACF;YACF;YAEA;;WAEC,GACD,IACE,uBAAuBR,mBACvB,OAAOA,gBAAgBW,iBAAiB,KAAK,YAC7C;gBACA,MAAMC,UAAUZ,gBAAgBW,iBAAiB,CAAC;oBAChD/B;oBACA0B,OAAON,gBAAgBO,kBAAkB;oBACzCM,WAAW,IAAIzB;oBACfP;gBACF;gBAEA,IAAK,MAAMiC,aAAaF,QAAS;oBAC/B,MAAMG,SAASH,OAAO,CAACE,UAAU;oBAEjC,MAAME,kBAAkBzC,eAAe;wBACrCK;wBACAmC,QAAQtC,UAAUsC;
|
|
1
|
+
{"version":3,"sources":["../src/generateComponentMap.tsx"],"sourcesContent":["import type { RichTextAdapter } from 'payload/types'\n\nimport { mapFields } from '@payloadcms/ui/utilities/buildComponentMap'\nimport { sanitizeFields } from 'payload/config'\nimport React from 'react'\n\nimport type { ResolvedServerFeatureMap } from './field/features/types.js'\nimport type { GeneratedFeatureProviderComponent } from './types.js'\n\nimport { cloneDeep } from './field/lexical/utils/cloneDeep.js'\n\nexport const getGenerateComponentMap =\n (args: {\n resolvedFeatureMap: ResolvedServerFeatureMap\n }): RichTextAdapter['generateComponentMap'] =>\n ({ config, schemaPath }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n const componentMap = new Map()\n\n // turn args.resolvedFeatureMap into an array of [key, value] pairs, ordered by value.order, lowest order first:\n const resolvedFeatureMapArray = Array.from(args.resolvedFeatureMap.entries()).sort(\n (a, b) => a[1].order - b[1].order,\n )\n\n componentMap.set(\n `features`,\n resolvedFeatureMapArray\n .map(([featureKey, resolvedFeature]) => {\n const ClientComponent = resolvedFeature.ClientComponent\n const clientComponentProps = resolvedFeature.clientFeatureProps\n\n /**\n * Handle Feature Component Maps\n */\n if (\n 'generateComponentMap' in resolvedFeature &&\n typeof resolvedFeature.generateComponentMap === 'function'\n ) {\n const components = resolvedFeature.generateComponentMap({\n config,\n props: resolvedFeature.serverFeatureProps,\n schemaPath,\n })\n\n for (const componentKey in components) {\n const Component = components[componentKey]\n\n if (Component) {\n componentMap.set(\n `feature.${featureKey}.components.${componentKey}`,\n <Component\n componentKey={componentKey}\n featureKey={resolvedFeature.key}\n key={`${resolvedFeature.key}-${componentKey}`}\n />,\n )\n }\n }\n }\n\n /**\n * Handle Feature Schema Maps (rendered fields)\n */\n if (\n 'generateSchemaMap' in resolvedFeature &&\n typeof resolvedFeature.generateSchemaMap === 'function'\n ) {\n const schemas = resolvedFeature.generateSchemaMap({\n config,\n props: resolvedFeature.serverFeatureProps,\n schemaMap: new Map(),\n schemaPath,\n })\n\n for (const schemaKey in schemas) {\n const fields = schemas[schemaKey]\n\n const sanitizedFields = sanitizeFields({\n config,\n fields: cloneDeep(fields),\n requireFieldLevelRichTextEditor: true,\n validRelationships,\n })\n\n const mappedFields = mapFields({\n config,\n disableAddingID: true,\n fieldSchema: sanitizedFields,\n parentPath: `${schemaPath}.feature.${featureKey}.fields.${schemaKey}`,\n readOnly: false,\n })\n\n componentMap.set(`feature.${featureKey}.fields.${schemaKey}`, mappedFields)\n }\n }\n\n if (!ClientComponent) {\n return null\n }\n\n return {\n ClientComponent:\n clientComponentProps && typeof clientComponentProps === 'object' ? (\n <ClientComponent\n {...clientComponentProps}\n featureKey={resolvedFeature.key}\n key={resolvedFeature.key}\n order={resolvedFeature.order}\n />\n ) : (\n <ClientComponent\n featureKey={resolvedFeature.key}\n key={resolvedFeature.key}\n order={resolvedFeature.order}\n />\n ),\n key: resolvedFeature.key,\n order: resolvedFeature.order,\n } as GeneratedFeatureProviderComponent\n })\n .filter((feature) => feature !== null),\n )\n\n return componentMap\n }\n"],"names":["mapFields","sanitizeFields","React","cloneDeep","getGenerateComponentMap","args","config","schemaPath","validRelationships","collections","map","c","slug","componentMap","Map","resolvedFeatureMapArray","Array","from","resolvedFeatureMap","entries","sort","a","b","order","set","featureKey","resolvedFeature","ClientComponent","clientComponentProps","clientFeatureProps","generateComponentMap","components","props","serverFeatureProps","componentKey","Component","key","generateSchemaMap","schemas","schemaMap","schemaKey","fields","sanitizedFields","requireFieldLevelRichTextEditor","mappedFields","disableAddingID","fieldSchema","parentPath","readOnly","filter","feature"],"mappings":"AAEA,SAASA,SAAS,QAAQ,6CAA4C;AACtE,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,WAAW,QAAO;AAKzB,SAASC,SAAS,QAAQ,qCAAoC;AAE9D,OAAO,MAAMC,0BACX,CAACC,OAGD,CAAC,EAAEC,MAAM,EAAEC,UAAU,EAAE;QACrB,MAAMC,qBAAqBF,OAAOG,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;QAEtE,MAAMC,eAAe,IAAIC;QAEzB,gHAAgH;QAChH,MAAMC,0BAA0BC,MAAMC,IAAI,CAACZ,KAAKa,kBAAkB,CAACC,OAAO,IAAIC,IAAI,CAChF,CAACC,GAAGC,IAAMD,CAAC,CAAC,EAAE,CAACE,KAAK,GAAGD,CAAC,CAAC,EAAE,CAACC,KAAK;QAGnCV,aAAaW,GAAG,CACd,CAAC,QAAQ,CAAC,EACVT,wBACGL,GAAG,CAAC,CAAC,CAACe,YAAYC,gBAAgB;YACjC,MAAMC,kBAAkBD,gBAAgBC,eAAe;YACvD,MAAMC,uBAAuBF,gBAAgBG,kBAAkB;YAE/D;;WAEC,GACD,IACE,0BAA0BH,mBAC1B,OAAOA,gBAAgBI,oBAAoB,KAAK,YAChD;gBACA,MAAMC,aAAaL,gBAAgBI,oBAAoB,CAAC;oBACtDxB;oBACA0B,OAAON,gB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BH,KAAK;mCAG9B,oBAACI;oBACCF,YAAYC,gBAAgBU,GAAG;oBAC/BA,KAAKV,gBAAgBU,GAAG;oBACxBb,OAAOG,gBAAgBH,KAAK;;gBAGlCa,KAAKV,gBAAgBU,GAAG;gBACxBb,OAAOG,gBAAgBH,KAAK;YAC9B;QACF,GACC0B,MAAM,CAAC,CAACC,UAAYA,YAAY;QAGrC,OAAOrC;IACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateSchemaMap.d.ts","sourceRoot":"","sources":["../src/generateSchemaMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAIpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAIzE,eAAO,MAAM,oBAAoB,SACxB;IAAE,kBAAkB,EAAE,wBAAwB,CAAA;CAAE,KAAG,eAAe,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"generateSchemaMap.d.ts","sourceRoot":"","sources":["../src/generateSchemaMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAIpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAIzE,eAAO,MAAM,oBAAoB,SACxB;IAAE,kBAAkB,EAAE,wBAAwB,CAAA;CAAE,KAAG,eAAe,CAAC,mBAAmB,CAiC5F,CAAA"}
|
|
@@ -17,6 +17,7 @@ export const getGenerateSchemaMap = (args)=>({ config, schemaMap, schemaPath })=
|
|
|
17
17
|
const sanitizedFields = sanitizeFields({
|
|
18
18
|
config,
|
|
19
19
|
fields: cloneDeep(fields),
|
|
20
|
+
requireFieldLevelRichTextEditor: true,
|
|
20
21
|
validRelationships
|
|
21
22
|
});
|
|
22
23
|
schemaMap.set(`${schemaPath}.feature.${featureKey}.${schemaKey}`, sanitizedFields);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generateSchemaMap.ts"],"sourcesContent":["import type { RichTextAdapter } from 'payload/types'\n\nimport { sanitizeFields } from 'payload/config'\n\nimport type { ResolvedServerFeatureMap } from './field/features/types.js'\n\nimport { cloneDeep } from './field/lexical/utils/cloneDeep.js'\n\nexport const getGenerateSchemaMap =\n (args: { resolvedFeatureMap: ResolvedServerFeatureMap }): RichTextAdapter['generateSchemaMap'] =>\n ({ config, schemaMap, schemaPath }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n for (const [featureKey, resolvedFeature] of args.resolvedFeatureMap.entries()) {\n if (\n !('generateSchemaMap' in resolvedFeature) ||\n typeof resolvedFeature.generateSchemaMap !== 'function'\n ) {\n continue\n }\n const schemas = resolvedFeature.generateSchemaMap({\n config,\n props: resolvedFeature.serverFeatureProps,\n schemaMap,\n schemaPath,\n })\n\n for (const schemaKey in schemas) {\n const fields = schemas[schemaKey]\n\n const sanitizedFields = sanitizeFields({\n config,\n fields: cloneDeep(fields),\n validRelationships,\n })\n\n schemaMap.set(`${schemaPath}.feature.${featureKey}.${schemaKey}`, sanitizedFields)\n }\n }\n\n return schemaMap\n }\n"],"names":["sanitizeFields","cloneDeep","getGenerateSchemaMap","args","config","schemaMap","schemaPath","validRelationships","collections","map","c","slug","featureKey","resolvedFeature","resolvedFeatureMap","entries","generateSchemaMap","schemas","props","serverFeatureProps","schemaKey","fields","sanitizedFields","set"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAI/C,SAASC,SAAS,QAAQ,qCAAoC;AAE9D,OAAO,MAAMC,uBACX,CAACC,OACD,CAAC,EAAEC,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAE;QAChC,MAAMC,qBAAqBH,OAAOI,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;QAEtE,KAAK,MAAM,CAACC,YAAYC,gBAAgB,IAAIV,KAAKW,kBAAkB,CAACC,OAAO,GAAI;YAC7E,IACE,CAAE,CAAA,uBAAuBF,eAAc,KACvC,OAAOA,gBAAgBG,iBAAiB,KAAK,YAC7C;gBACA;YACF;YACA,MAAMC,UAAUJ,gBAAgBG,iBAAiB,CAAC;gBAChDZ;gBACAc,OAAOL,gBAAgBM,kBAAkB;gBACzCd;gBACAC;YACF;YAEA,IAAK,MAAMc,aAAaH,QAAS;gBAC/B,MAAMI,SAASJ,OAAO,CAACG,UAAU;gBAEjC,MAAME,kBAAkBtB,eAAe;oBACrCI;oBACAiB,QAAQpB,UAAUoB;
|
|
1
|
+
{"version":3,"sources":["../src/generateSchemaMap.ts"],"sourcesContent":["import type { RichTextAdapter } from 'payload/types'\n\nimport { sanitizeFields } from 'payload/config'\n\nimport type { ResolvedServerFeatureMap } from './field/features/types.js'\n\nimport { cloneDeep } from './field/lexical/utils/cloneDeep.js'\n\nexport const getGenerateSchemaMap =\n (args: { resolvedFeatureMap: ResolvedServerFeatureMap }): RichTextAdapter['generateSchemaMap'] =>\n ({ config, schemaMap, schemaPath }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n for (const [featureKey, resolvedFeature] of args.resolvedFeatureMap.entries()) {\n if (\n !('generateSchemaMap' in resolvedFeature) ||\n typeof resolvedFeature.generateSchemaMap !== 'function'\n ) {\n continue\n }\n const schemas = resolvedFeature.generateSchemaMap({\n config,\n props: resolvedFeature.serverFeatureProps,\n schemaMap,\n schemaPath,\n })\n\n for (const schemaKey in schemas) {\n const fields = schemas[schemaKey]\n\n const sanitizedFields = sanitizeFields({\n config,\n fields: cloneDeep(fields),\n requireFieldLevelRichTextEditor: true,\n validRelationships,\n })\n\n schemaMap.set(`${schemaPath}.feature.${featureKey}.${schemaKey}`, sanitizedFields)\n }\n }\n\n return schemaMap\n }\n"],"names":["sanitizeFields","cloneDeep","getGenerateSchemaMap","args","config","schemaMap","schemaPath","validRelationships","collections","map","c","slug","featureKey","resolvedFeature","resolvedFeatureMap","entries","generateSchemaMap","schemas","props","serverFeatureProps","schemaKey","fields","sanitizedFields","requireFieldLevelRichTextEditor","set"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAI/C,SAASC,SAAS,QAAQ,qCAAoC;AAE9D,OAAO,MAAMC,uBACX,CAACC,OACD,CAAC,EAAEC,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAE;QAChC,MAAMC,qBAAqBH,OAAOI,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;QAEtE,KAAK,MAAM,CAACC,YAAYC,gBAAgB,IAAIV,KAAKW,kBAAkB,CAACC,OAAO,GAAI;YAC7E,IACE,CAAE,CAAA,uBAAuBF,eAAc,KACvC,OAAOA,gBAAgBG,iBAAiB,KAAK,YAC7C;gBACA;YACF;YACA,MAAMC,UAAUJ,gBAAgBG,iBAAiB,CAAC;gBAChDZ;gBACAc,OAAOL,gBAAgBM,kBAAkB;gBACzCd;gBACAC;YACF;YAEA,IAAK,MAAMc,aAAaH,QAAS;gBAC/B,MAAMI,SAASJ,OAAO,CAACG,UAAU;gBAEjC,MAAME,kBAAkBtB,eAAe;oBACrCI;oBACAiB,QAAQpB,UAAUoB;oBAClBE,iCAAiC;oBACjChB;gBACF;gBAEAF,UAAUmB,GAAG,CAAC,CAAC,EAAElB,WAAW,SAAS,EAAEM,WAAW,CAAC,EAAEQ,UAAU,CAAC,EAAEE;YACpE;QACF;QAEA,OAAOjB;IACT,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.55",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,17 +40,17 @@
|
|
|
40
40
|
"@types/node": "20.6.2",
|
|
41
41
|
"@types/react": "18.2.15",
|
|
42
42
|
"@types/react-dom": "18.2.7",
|
|
43
|
-
"@payloadcms/
|
|
44
|
-
"
|
|
45
|
-
"@payloadcms/next": "3.0.0-alpha.
|
|
43
|
+
"@payloadcms/translations": "3.0.0-alpha.54",
|
|
44
|
+
"payload": "3.0.0-alpha.55",
|
|
45
|
+
"@payloadcms/next": "3.0.0-alpha.55",
|
|
46
46
|
"@payloadcms/eslint-config": "1.1.1",
|
|
47
|
-
"
|
|
47
|
+
"@payloadcms/ui": "3.0.0-alpha.55"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@payloadcms/translations": "3.0.0-alpha.
|
|
51
|
-
"@payloadcms/
|
|
52
|
-
"
|
|
53
|
-
"
|
|
50
|
+
"@payloadcms/translations": "3.0.0-alpha.54",
|
|
51
|
+
"@payloadcms/next": "3.0.0-alpha.55",
|
|
52
|
+
"payload": "3.0.0-alpha.55",
|
|
53
|
+
"@payloadcms/ui": "3.0.0-alpha.55"
|
|
54
54
|
},
|
|
55
55
|
"exports": {
|
|
56
56
|
".": {
|