@payloadcms/richtext-lexical 3.8.1-canary.84084b6 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/client/{Field-X3CJV3SY.js → Field-7XFZE2MU.js} +2 -2
- package/dist/exports/client/Field-7XFZE2MU.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/index.js +1 -1
- package/dist/exports/client/index.js.map +2 -2
- package/dist/exports/react/components/RichText/converter/converters/upload.js +1 -1
- package/dist/exports/react/components/RichText/converter/converters/upload.js.map +1 -1
- package/dist/features/blocks/server/index.d.ts.map +1 -1
- package/dist/features/blocks/server/index.js +2 -1
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/experimental_table/client/utils/debounce.js +13 -13
- package/dist/features/experimental_table/client/utils/debounce.js.map +1 -1
- package/dist/features/typesServer.d.ts +5 -3
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/field/Field.js +1 -0
- package/dist/field/Field.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/dist/exports/client/Field-X3CJV3SY.js.map +0 -7
|
@@ -39,7 +39,7 @@ export const UploadJSXConverter = {
|
|
|
39
39
|
}
|
|
40
40
|
const imageSizeURL = imageSize?.url;
|
|
41
41
|
pictureJSX.push(/*#__PURE__*/_jsx("source", {
|
|
42
|
-
media:
|
|
42
|
+
media: `(max-width: ${imageSize.width}px)`,
|
|
43
43
|
srcSet: imageSizeURL,
|
|
44
44
|
type: imageSize.mimeType
|
|
45
45
|
}, size));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","names":["UploadJSXConverter","upload","node","uploadDocument","url","value","mimeType","startsWith","_jsx","href","rel","filename","sizes","Object","keys","length","alt","height","src","width","pictureJSX","size","imageSize","filesize","imageSizeURL","push","media","srcSet","type"],"sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/upload.tsx"],"sourcesContent":["import type { FileData, FileSize, TypeWithID } from 'payload'\n\nimport type { SerializedUploadNode } from '../../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const UploadJSXConverter: JSXConverters<SerializedUploadNode> = {\n upload: ({ node }) => {\n const uploadDocument: {\n value?: FileData & TypeWithID\n } = node as any\n\n const url = uploadDocument?.value?.url\n\n /**\n * If the upload is not an image, return a link to the upload\n */\n if (!uploadDocument?.value?.mimeType?.startsWith('image')) {\n return (\n <a href={url} rel=\"noopener noreferrer\">\n {uploadDocument.value?.filename}\n </a>\n )\n }\n\n /**\n * If the upload is a simple image with no different sizes, return a simple img tag\n */\n if (!uploadDocument?.value?.sizes || !Object.keys(uploadDocument?.value?.sizes).length) {\n return (\n <img\n alt={uploadDocument?.value?.filename}\n height={uploadDocument?.value?.height}\n src={url}\n width={uploadDocument?.value?.width}\n />\n )\n }\n\n /**\n * If the upload is an image with different sizes, return a picture element\n */\n const pictureJSX: React.ReactNode[] = []\n\n // Iterate through each size in the data.sizes object\n for (const size in uploadDocument.value?.sizes) {\n const imageSize: {\n url?: string\n } & FileSize = uploadDocument.value?.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 = imageSize?.url\n\n pictureJSX.push(\n <source\n key={size}\n media
|
|
1
|
+
{"version":3,"file":"upload.js","names":["UploadJSXConverter","upload","node","uploadDocument","url","value","mimeType","startsWith","_jsx","href","rel","filename","sizes","Object","keys","length","alt","height","src","width","pictureJSX","size","imageSize","filesize","imageSizeURL","push","media","srcSet","type"],"sources":["../../../../../../../src/exports/react/components/RichText/converter/converters/upload.tsx"],"sourcesContent":["import type { FileData, FileSize, TypeWithID } from 'payload'\n\nimport type { SerializedUploadNode } from '../../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const UploadJSXConverter: JSXConverters<SerializedUploadNode> = {\n upload: ({ node }) => {\n const uploadDocument: {\n value?: FileData & TypeWithID\n } = node as any\n\n const url = uploadDocument?.value?.url\n\n /**\n * If the upload is not an image, return a link to the upload\n */\n if (!uploadDocument?.value?.mimeType?.startsWith('image')) {\n return (\n <a href={url} rel=\"noopener noreferrer\">\n {uploadDocument.value?.filename}\n </a>\n )\n }\n\n /**\n * If the upload is a simple image with no different sizes, return a simple img tag\n */\n if (!uploadDocument?.value?.sizes || !Object.keys(uploadDocument?.value?.sizes).length) {\n return (\n <img\n alt={uploadDocument?.value?.filename}\n height={uploadDocument?.value?.height}\n src={url}\n width={uploadDocument?.value?.width}\n />\n )\n }\n\n /**\n * If the upload is an image with different sizes, return a picture element\n */\n const pictureJSX: React.ReactNode[] = []\n\n // Iterate through each size in the data.sizes object\n for (const size in uploadDocument.value?.sizes) {\n const imageSize: {\n url?: string\n } & FileSize = uploadDocument.value?.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 = imageSize?.url\n\n pictureJSX.push(\n <source\n key={size}\n media={`(max-width: ${imageSize.width}px)`}\n srcSet={imageSizeURL}\n type={imageSize.mimeType}\n ></source>,\n )\n }\n\n // Add the default img tag\n pictureJSX.push(\n <img\n alt={uploadDocument.value?.filename}\n height={uploadDocument.value?.height}\n key={'image'}\n src={url}\n width={uploadDocument.value?.width}\n />,\n )\n return <picture>{pictureJSX}</picture>\n },\n}\n"],"mappings":";AAKA,OAAO,MAAMA,kBAAA,GAA0D;EACrEC,MAAA,EAAQA,CAAC;IAAEC;EAAI,CAAE;IACf,MAAMC,cAAA,GAEFD,IAAA;IAEJ,MAAME,GAAA,GAAMD,cAAA,EAAgBE,KAAA,EAAO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D,UAAA,CAAWK,IAAI,cACbjB,IAAA,CAAC;MACCQ,GAAA,EAAKb,cAAA,CAAeE,KAAK,EAAEM,QAAA;MAC3BM,MAAA,EAAQd,cAAA,CAAeE,KAAK,EAAEY,MAAA;MAE9BC,GAAA,EAAKd,GAAA;MACLe,KAAA,EAAOhB,cAAA,CAAeE,KAAK,EAAEc;OAFxB;IAKT,oBAAOX,IAAA,CAAC;gBAASY;;EACnB;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAA6D,MAAM,SAAS,CAAA;AAa/F,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,KAAK,EAAE,CAAA;IAChB,YAAY,CAAC,EAAE,KAAK,EAAE,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAA6D,MAAM,SAAS,CAAA;AAa/F,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,KAAK,EAAE,CAAA;IAChB,YAAY,CAAC,EAAE,KAAK,EAAE,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,aAAa,iHAqNxB,CAAA"}
|
|
@@ -40,6 +40,7 @@ export const BlocksFeature = createServerFeature({
|
|
|
40
40
|
config,
|
|
41
41
|
currentSchema,
|
|
42
42
|
field,
|
|
43
|
+
i18n,
|
|
43
44
|
interfaceNameDefinitions
|
|
44
45
|
}) => {
|
|
45
46
|
if (!props?.blocks?.length && !props?.inlineBlocks?.length) {
|
|
@@ -73,7 +74,7 @@ export const BlocksFeature = createServerFeature({
|
|
|
73
74
|
if (fields.length) {
|
|
74
75
|
// This is only done so that interfaceNameDefinitions sets those block's interfaceNames.
|
|
75
76
|
// we don't actually use the JSON Schema itself in the generated types yet.
|
|
76
|
-
fieldsToJSONSchema(collectionIDFieldTypes, fields, interfaceNameDefinitions, config);
|
|
77
|
+
fieldsToJSONSchema(collectionIDFieldTypes, fields, interfaceNameDefinitions, config, i18n);
|
|
77
78
|
}
|
|
78
79
|
return currentSchema;
|
|
79
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["fieldsToJSONSchema","flattenAllFields","sanitizeFields","createServerFeature","createNode","blockPopulationPromiseHOC","i18n","getBlockMarkdownTransformers","ServerBlockNode","ServerInlineBlockNode","blockValidationHOC","BlocksFeature","feature","config","_config","isRoot","parentIsLocalized","props","validRelationships","collections","map","c","slug","sanitized","fields","name","type","blocks","inlineBlocks","requireFieldLevelRichTextEditor","ClientFeature","generatedTypes","modifyOutputSchema","collectionIDFieldTypes","currentSchema","field","interfaceNameDefinitions","length","push","block","flattenedFields","generateSchemaMap","schemaMap","Map","blockFields","admin","components","unshift","Block","BlockLabel","Label","set","markdownTransformers","nodes","getSubFields","node","blockType","find","getSubFieldsData","graphQLPopulationPromises","validations","sanitizedServerFeatureProps","key"],"sources":["../../../../src/features/blocks/server/index.ts"],"sourcesContent":["import type { Block, BlocksField, Config, FieldSchemaMap, FlattenedBlocksField } from 'payload'\n\nimport { fieldsToJSONSchema, flattenAllFields, sanitizeFields } from 'payload'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { blockPopulationPromiseHOC } from './graphQLPopulationPromise.js'\nimport { i18n } from './i18n.js'\nimport { getBlockMarkdownTransformers } from './markdownTransformer.js'\nimport { ServerBlockNode } from './nodes/BlocksNode.js'\nimport { ServerInlineBlockNode } from './nodes/InlineBlocksNode.js'\nimport { blockValidationHOC } from './validate.js'\n\nexport type BlocksFeatureProps = {\n blocks?: Block[]\n inlineBlocks?: Block[]\n}\n\nexport const BlocksFeature = createServerFeature<BlocksFeatureProps, BlocksFeatureProps>({\n feature: async ({ config: _config, isRoot, parentIsLocalized, props }) => {\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n const sanitized = await sanitizeFields({\n config: _config as unknown as Config,\n fields: [\n {\n name: 'lexical_blocks',\n type: 'blocks',\n blocks: props.blocks ?? [],\n },\n {\n name: 'lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks ?? [],\n },\n ],\n parentIsLocalized,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n\n props.blocks = (sanitized[0] as BlocksField).blocks\n props.inlineBlocks = (sanitized[1] as BlocksField).blocks\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#BlocksFeatureClient',\n generatedTypes: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n }) => {\n if (!props?.blocks?.length && !props?.inlineBlocks?.length) {\n return currentSchema\n }\n\n const fields: FlattenedBlocksField[] = []\n\n if (props?.blocks?.length) {\n fields.push({\n name: field?.name + '_lexical_blocks',\n type: 'blocks',\n blocks: props.blocks.map((block) => ({\n ...block,\n flattenedFields: flattenAllFields({ fields: block.fields }),\n })),\n })\n }\n if (props?.inlineBlocks?.length) {\n fields.push({\n name: field?.name + '_lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks.map((block) => ({\n ...block,\n flattenedFields: flattenAllFields({ fields: block.fields }),\n })),\n })\n }\n\n if (fields.length) {\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(collectionIDFieldTypes, fields, interfaceNameDefinitions, config)\n }\n\n return currentSchema\n },\n },\n generateSchemaMap: ({ props }) => {\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 schemaMap: FieldSchemaMap = new Map()\n\n if (props?.blocks?.length) {\n for (const block of props.blocks) {\n const blockFields = [...block.fields]\n\n if (block?.admin?.components) {\n blockFields.unshift({\n name: `_components`,\n type: 'ui',\n admin: {\n components: {\n Block: block.admin?.components?.Block,\n BlockLabel: block.admin?.components?.Label,\n },\n },\n })\n }\n schemaMap.set(`lexical_blocks.${block.slug}.fields`, {\n fields: blockFields,\n })\n schemaMap.set(`lexical_blocks.${block.slug}`, {\n name: `lexical_blocks_${block.slug}`,\n type: 'blocks',\n blocks: [block],\n })\n }\n }\n\n if (props?.inlineBlocks?.length) {\n // To generate block schemaMap which generates things like the componentMap for admin.Label\n for (const block of props.inlineBlocks) {\n const blockFields = [...block.fields]\n\n if (block?.admin?.components) {\n blockFields.unshift({\n name: `_components`,\n type: 'ui',\n admin: {\n components: {\n Block: block.admin?.components?.Block,\n BlockLabel: block.admin?.components?.Label,\n },\n },\n })\n }\n\n schemaMap.set(`lexical_inline_blocks.${block.slug}.fields`, {\n fields: blockFields,\n })\n\n schemaMap.set(`lexical_inline_blocks.${block.slug}`, {\n name: `lexical_inline_blocks_${block.slug}`,\n type: 'blocks',\n blocks: [block],\n })\n }\n }\n\n return schemaMap\n },\n i18n,\n markdownTransformers: getBlockMarkdownTransformers({\n blocks: props.blocks,\n inlineBlocks: props.inlineBlocks,\n }),\n\n nodes: [\n createNode({\n // @ts-expect-error - TODO: fix this\n getSubFields: ({ node }) => {\n if (!node) {\n if (props?.blocks?.length) {\n return [\n {\n name: 'lexical_blocks',\n type: 'blocks',\n blocks: props.blocks,\n },\n ]\n }\n return []\n }\n\n const blockType = node.fields.blockType\n\n const block = props.blocks?.find((block) => block.slug === blockType)\n return block?.fields\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [blockPopulationPromiseHOC(props.blocks)],\n node: ServerBlockNode,\n validations: [blockValidationHOC(props.blocks)],\n }),\n createNode({\n // @ts-expect-error - TODO: fix this\n getSubFields: ({ node }) => {\n if (!node) {\n if (props?.inlineBlocks?.length) {\n return [\n {\n name: 'lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks,\n },\n ]\n }\n return []\n }\n\n const blockType = node.fields.blockType\n\n const block = props.inlineBlocks?.find((block) => block.slug === blockType)\n return block?.fields\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [blockPopulationPromiseHOC(props.inlineBlocks)],\n node: ServerInlineBlockNode,\n validations: [blockValidationHOC(props.inlineBlocks)],\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'blocks',\n})\n"],"mappings":"AAEA,SAASA,kBAAkB,EAAEC,gBAAgB,EAAEC,cAAc,QAAQ;AAErE,SAASC,mBAAmB,QAAQ;AACpC,SAASC,UAAU,QAAQ;AAC3B,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,IAAI,QAAQ;AACrB,SAASC,4BAA4B,QAAQ;AAC7C,SAASC,eAAe,QAAQ;AAChC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,kBAAkB,QAAQ;AAOnC,OAAO,MAAMC,aAAA,GAAgBR,mBAAA,CAA4D;EACvFS,OAAA,EAAS,MAAAA,CAAO;IAAEC,MAAA,EAAQC,OAAO;IAAEC,MAAM;IAAEC,iBAAiB;IAAEC;EAAK,CAAE;IACnE,MAAMC,kBAAA,GAAqBJ,OAAA,CAAQK,WAAW,CAACC,GAAG,CAAEC,CAAA,IAAMA,CAAA,CAAEC,IAAI,KAAK,EAAE;IAEvE,MAAMC,SAAA,GAAY,MAAMrB,cAAA,CAAe;MACrCW,MAAA,EAAQC,OAAA;MACRU,MAAA,EAAQ,CACN;QACEC,IAAA,EAAM;QACNC,IAAA,EAAM;QACNC,MAAA,EAAQV,KAAA,CAAMU,MAAM,IAAI;MAC1B,GACA;QACEF,IAAA,EAAM;QACNC,IAAA,EAAM;QACNC,MAAA,EAAQV,KAAA,CAAMW,YAAY,IAAI;MAChC,EACD;MACDZ,iBAAA;MACAa,+BAAA,EAAiCd,MAAA;MACjCG;IACF;IAEAD,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AE;UACzB,OAAOA,IAAA,EAAM/B,MAAA;QACf;QACAmC,yBAAA,EAA2B,CAACtD,yBAAA,CAA0BY,KAAA,CAAMU,MAAM,EAAE;QACpE4B,IAAA,EAAM/C,eAAA;QACNoD,WAAA,EAAa,CAAClD,kBAAA,CAAmBO,KAAA,CAAMU,MAAM;MAC/C,IACAvB,UAAA,CAAW;QACT;QACAkD,YAAA,EAAcA,CAAC;UAAEC;QAAI,CAAE;UACrB,IAAI,CAACA,IAAA,EAAM;YACT,IAAItC,KAAA,EAAOW,YAAA,EAAcS,MAAA,EAAQ;cAC/B,OAAO,CACL;gBACEZ,IAAA,EAAM;gBACNC,IAAA,EAAM;gBACNC,MAAA,EAAQV,KAAA,CAAMW;cAChB,EACD;YACH;YACA,OAAO,EAAE;UACX;UAEA,MAAM4B,SAAA,GAAYD,IAAA,CAAK/B,MAAM,CAACgC,SAAS;UAEvC,MAAMjB,KAAA,GAAQtB,KAAA,CAAMW,YAAY,EAAE6B,IAAA,CAAMlB,KAAA,IAAUA,KAAA,CAAMjB,IAAI,KAAKkC,SAAA;UACjE,OAAOjB,KAAA,EAAOf,MAAA;QAChB;QACAkC,gBAAA,EAAkBA,CAAC;UAAEH;QAAI,CAAE;UACzB,OAAOA,IAAA,EAAM/B,MAAA;QACf;QACAmC,yBAAA,EAA2B,CAACtD,yBAAA,CAA0BY,KAAA,CAAMW,YAAY,EAAE;QAC1E2B,IAAA,EAAM9C,qBAAA;QACNmD,WAAA,EAAa,CAAClD,kBAAA,CAAmBO,KAAA,CAAMW,YAAY;MACrD,GACD;MACDiC,2BAAA,EAA6B5C;IAC/B;EACF;EACA6C,GAAA,EAAK;AACP","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["fieldsToJSONSchema","flattenAllFields","sanitizeFields","createServerFeature","createNode","blockPopulationPromiseHOC","i18n","getBlockMarkdownTransformers","ServerBlockNode","ServerInlineBlockNode","blockValidationHOC","BlocksFeature","feature","config","_config","isRoot","parentIsLocalized","props","validRelationships","collections","map","c","slug","sanitized","fields","name","type","blocks","inlineBlocks","requireFieldLevelRichTextEditor","ClientFeature","generatedTypes","modifyOutputSchema","collectionIDFieldTypes","currentSchema","field","interfaceNameDefinitions","length","push","block","flattenedFields","generateSchemaMap","schemaMap","Map","blockFields","admin","components","unshift","Block","BlockLabel","Label","set","markdownTransformers","nodes","getSubFields","node","blockType","find","getSubFieldsData","graphQLPopulationPromises","validations","sanitizedServerFeatureProps","key"],"sources":["../../../../src/features/blocks/server/index.ts"],"sourcesContent":["import type { Block, BlocksField, Config, FieldSchemaMap, FlattenedBlocksField } from 'payload'\n\nimport { fieldsToJSONSchema, flattenAllFields, sanitizeFields } from 'payload'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { blockPopulationPromiseHOC } from './graphQLPopulationPromise.js'\nimport { i18n } from './i18n.js'\nimport { getBlockMarkdownTransformers } from './markdownTransformer.js'\nimport { ServerBlockNode } from './nodes/BlocksNode.js'\nimport { ServerInlineBlockNode } from './nodes/InlineBlocksNode.js'\nimport { blockValidationHOC } from './validate.js'\n\nexport type BlocksFeatureProps = {\n blocks?: Block[]\n inlineBlocks?: Block[]\n}\n\nexport const BlocksFeature = createServerFeature<BlocksFeatureProps, BlocksFeatureProps>({\n feature: async ({ config: _config, isRoot, parentIsLocalized, props }) => {\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n const sanitized = await sanitizeFields({\n config: _config as unknown as Config,\n fields: [\n {\n name: 'lexical_blocks',\n type: 'blocks',\n blocks: props.blocks ?? [],\n },\n {\n name: 'lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks ?? [],\n },\n ],\n parentIsLocalized,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n\n props.blocks = (sanitized[0] as BlocksField).blocks\n props.inlineBlocks = (sanitized[1] as BlocksField).blocks\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#BlocksFeatureClient',\n generatedTypes: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n i18n,\n interfaceNameDefinitions,\n }) => {\n if (!props?.blocks?.length && !props?.inlineBlocks?.length) {\n return currentSchema\n }\n\n const fields: FlattenedBlocksField[] = []\n\n if (props?.blocks?.length) {\n fields.push({\n name: field?.name + '_lexical_blocks',\n type: 'blocks',\n blocks: props.blocks.map((block) => ({\n ...block,\n flattenedFields: flattenAllFields({ fields: block.fields }),\n })),\n })\n }\n if (props?.inlineBlocks?.length) {\n fields.push({\n name: field?.name + '_lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks.map((block) => ({\n ...block,\n flattenedFields: flattenAllFields({ fields: block.fields }),\n })),\n })\n }\n\n if (fields.length) {\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 fields,\n interfaceNameDefinitions,\n config,\n i18n,\n )\n }\n\n return currentSchema\n },\n },\n generateSchemaMap: ({ props }) => {\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 schemaMap: FieldSchemaMap = new Map()\n\n if (props?.blocks?.length) {\n for (const block of props.blocks) {\n const blockFields = [...block.fields]\n\n if (block?.admin?.components) {\n blockFields.unshift({\n name: `_components`,\n type: 'ui',\n admin: {\n components: {\n Block: block.admin?.components?.Block,\n BlockLabel: block.admin?.components?.Label,\n },\n },\n })\n }\n schemaMap.set(`lexical_blocks.${block.slug}.fields`, {\n fields: blockFields,\n })\n schemaMap.set(`lexical_blocks.${block.slug}`, {\n name: `lexical_blocks_${block.slug}`,\n type: 'blocks',\n blocks: [block],\n })\n }\n }\n\n if (props?.inlineBlocks?.length) {\n // To generate block schemaMap which generates things like the componentMap for admin.Label\n for (const block of props.inlineBlocks) {\n const blockFields = [...block.fields]\n\n if (block?.admin?.components) {\n blockFields.unshift({\n name: `_components`,\n type: 'ui',\n admin: {\n components: {\n Block: block.admin?.components?.Block,\n BlockLabel: block.admin?.components?.Label,\n },\n },\n })\n }\n\n schemaMap.set(`lexical_inline_blocks.${block.slug}.fields`, {\n fields: blockFields,\n })\n\n schemaMap.set(`lexical_inline_blocks.${block.slug}`, {\n name: `lexical_inline_blocks_${block.slug}`,\n type: 'blocks',\n blocks: [block],\n })\n }\n }\n\n return schemaMap\n },\n i18n,\n markdownTransformers: getBlockMarkdownTransformers({\n blocks: props.blocks,\n inlineBlocks: props.inlineBlocks,\n }),\n\n nodes: [\n createNode({\n // @ts-expect-error - TODO: fix this\n getSubFields: ({ node }) => {\n if (!node) {\n if (props?.blocks?.length) {\n return [\n {\n name: 'lexical_blocks',\n type: 'blocks',\n blocks: props.blocks,\n },\n ]\n }\n return []\n }\n\n const blockType = node.fields.blockType\n\n const block = props.blocks?.find((block) => block.slug === blockType)\n return block?.fields\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [blockPopulationPromiseHOC(props.blocks)],\n node: ServerBlockNode,\n validations: [blockValidationHOC(props.blocks)],\n }),\n createNode({\n // @ts-expect-error - TODO: fix this\n getSubFields: ({ node }) => {\n if (!node) {\n if (props?.inlineBlocks?.length) {\n return [\n {\n name: 'lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks,\n },\n ]\n }\n return []\n }\n\n const blockType = node.fields.blockType\n\n const block = props.inlineBlocks?.find((block) => block.slug === blockType)\n return block?.fields\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [blockPopulationPromiseHOC(props.inlineBlocks)],\n node: ServerInlineBlockNode,\n validations: [blockValidationHOC(props.inlineBlocks)],\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'blocks',\n})\n"],"mappings":"AAEA,SAASA,kBAAkB,EAAEC,gBAAgB,EAAEC,cAAc,QAAQ;AAErE,SAASC,mBAAmB,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NC,IAAA,EAAM;gBACNC,MAAA,EAAQV,KAAA,CAAMW;cAChB,EACD;YACH;YACA,OAAO,EAAE;UACX;UAEA,MAAM4B,SAAA,GAAYD,IAAA,CAAK/B,MAAM,CAACgC,SAAS;UAEvC,MAAMjB,KAAA,GAAQtB,KAAA,CAAMW,YAAY,EAAE6B,IAAA,CAAMlB,KAAA,IAAUA,KAAA,CAAMjB,IAAI,KAAKkC,SAAA;UACjE,OAAOjB,KAAA,EAAOf,MAAA;QAChB;QACAkC,gBAAA,EAAkBA,CAAC;UAAEH;QAAI,CAAE;UACzB,OAAOA,IAAA,EAAM/B,MAAA;QACf;QACAmC,yBAAA,EAA2B,CAACtD,yBAAA,CAA0BY,KAAA,CAAMW,YAAY,EAAE;QAC1E2B,IAAA,EAAM9C,qBAAA;QACNmD,WAAA,EAAa,CAAClD,kBAAA,CAAmBO,KAAA,CAAMW,YAAY;MACrD,GACD;MACDiC,2BAAA,EAA6B5C;IAC/B;EACF;EACA6C,GAAA,EAAK;AACP","ignoreList":[]}
|
|
@@ -121,7 +121,7 @@ function debounce(func, wait, options) {
|
|
|
121
121
|
maxing = false,
|
|
122
122
|
maxWait,
|
|
123
123
|
result,
|
|
124
|
-
|
|
124
|
+
timerID,
|
|
125
125
|
trailing = true;
|
|
126
126
|
if (typeof func != 'function') {
|
|
127
127
|
throw new TypeError(FUNC_ERROR_TEXT);
|
|
@@ -145,7 +145,7 @@ function debounce(func, wait, options) {
|
|
|
145
145
|
// Reset any `maxWait` timer.
|
|
146
146
|
lastInvokeTime = time;
|
|
147
147
|
// Start the timer for the trailing edge.
|
|
148
|
-
|
|
148
|
+
timerID = setTimeout(timerExpired, wait);
|
|
149
149
|
// Invoke the leading edge.
|
|
150
150
|
return leading ? invokeFunc(time) : result;
|
|
151
151
|
}
|
|
@@ -169,10 +169,10 @@ function debounce(func, wait, options) {
|
|
|
169
169
|
return trailingEdge(time);
|
|
170
170
|
}
|
|
171
171
|
// Restart the timer.
|
|
172
|
-
|
|
172
|
+
timerID = setTimeout(timerExpired, remainingWait(time));
|
|
173
173
|
}
|
|
174
174
|
function trailingEdge(time) {
|
|
175
|
-
|
|
175
|
+
timerID = undefined;
|
|
176
176
|
// Only invoke if we have `lastArgs` which means `func` has been
|
|
177
177
|
// debounced at least once.
|
|
178
178
|
if (trailing && lastArgs) {
|
|
@@ -182,14 +182,14 @@ function debounce(func, wait, options) {
|
|
|
182
182
|
return result;
|
|
183
183
|
}
|
|
184
184
|
function cancel() {
|
|
185
|
-
if (
|
|
186
|
-
clearTimeout(
|
|
185
|
+
if (timerID !== undefined) {
|
|
186
|
+
clearTimeout(timerID);
|
|
187
187
|
}
|
|
188
188
|
lastInvokeTime = 0;
|
|
189
|
-
lastArgs = lastCallTime = lastThis =
|
|
189
|
+
lastArgs = lastCallTime = lastThis = timerID = undefined;
|
|
190
190
|
}
|
|
191
191
|
function flush() {
|
|
192
|
-
return
|
|
192
|
+
return timerID === undefined ? result : trailingEdge(Date.now());
|
|
193
193
|
}
|
|
194
194
|
function debounced() {
|
|
195
195
|
const time = Date.now(),
|
|
@@ -200,18 +200,18 @@ function debounce(func, wait, options) {
|
|
|
200
200
|
lastThis = this;
|
|
201
201
|
lastCallTime = time;
|
|
202
202
|
if (isInvoking) {
|
|
203
|
-
if (
|
|
203
|
+
if (timerID === undefined) {
|
|
204
204
|
return leadingEdge(lastCallTime);
|
|
205
205
|
}
|
|
206
206
|
if (maxing) {
|
|
207
207
|
// Handle invocations in a tight loop.
|
|
208
|
-
clearTimeout(
|
|
209
|
-
|
|
208
|
+
clearTimeout(timerID);
|
|
209
|
+
timerID = setTimeout(timerExpired, wait);
|
|
210
210
|
return invokeFunc(lastCallTime);
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
|
-
if (
|
|
214
|
-
|
|
213
|
+
if (timerID === undefined) {
|
|
214
|
+
timerID = setTimeout(timerExpired, wait);
|
|
215
215
|
}
|
|
216
216
|
return result;
|
|
217
217
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debounce.js","names":["FUNC_ERROR_TEXT","nativeMax","Math","max","nativeMin","min","debounce","func","wait","options","lastArgs","lastCallTime","lastInvokeTime","lastThis","leading","maxing","maxWait","result","timerId","trailing","TypeError","invokeFunc","time","args","thisArg","undefined","apply","leadingEdge","setTimeout","timerExpired","remainingWait","timeSinceLastCall","timeSinceLastInvoke","timeWaiting","shouldInvoke","Date","now","trailingEdge","cancel","clearTimeout","flush","debounced","isInvoking","arguments"],"sources":["../../../../../src/features/experimental_table/client/utils/debounce.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck - not worth it migrate jsdoc to tsdoc\n'use client'\n// Copied & modified from https://github.com/lodash/lodash/blob/main/src/debounce.ts\n/*\nThe MIT License\n\nCopyright JS Foundation and other contributors <https://js.foundation/>\n\nBased on Underscore.js, copyright Jeremy Ashkenas,\nDocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>\n\nThis software consists of voluntary contributions made by many\nindividuals. For exact contribution history, see the revision history\navailable at https://github.com/lodash/lodash\n\nThe following license applies to all parts of this software except as\ndocumented below:\n\n====\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n====\n\nCopyright and related rights for sample code are waived via CC0. Sample\ncode is defined as all source code displayed within the prose of the\ndocumentation.\n\nCC0: http://creativecommons.org/publicdomain/zero/1.0/\n\n====\n\nFiles located in the node_modules and vendor directories are externally\nmaintained libraries used by this software which have their own\nlicenses; we recommend you read them, as their terms may differ from the\nterms above.\n */\n\n/** Error message constants. */\nconst FUNC_ERROR_TEXT = 'Expected a function'\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nconst nativeMax = Math.max,\n nativeMin = Math.min\n\n/**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `func` invocations and a `flush` method to immediately invoke them.\n * Provide `options` to indicate whether `func` should be invoked on the\n * leading and/or trailing edge of the `wait` timeout. The `func` is invoked\n * with the last arguments provided to the debounced function. Subsequent\n * calls to the debounced function return the result of the last `func`\n * invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.debounce` and `_.throttle`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=false]\n * Specify invoking on the leading edge of the timeout.\n * @param {number} [options.maxWait]\n * The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * // Avoid costly calculations while the window size is in flux.\n * jQuery(window).on('resize', _.debounce(calculateLayout, 150));\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * jQuery(element).on('click', _.debounce(sendMail, 300, {\n * 'leading': true,\n * 'trailing': false\n * }));\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });\n * var source = new EventSource('/stream');\n * jQuery(source).on('message', debounced);\n *\n * // Cancel the trailing debounced invocation.\n * jQuery(window).on('popstate', debounced.cancel);\n */\nfunction debounce(func, wait, options) {\n let lastArgs,\n lastCallTime,\n lastInvokeTime = 0,\n lastThis,\n leading = false,\n maxing = false,\n maxWait,\n result,\n timerId,\n trailing = true\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT)\n }\n wait = wait || 0\n if (typeof options === 'object') {\n leading = !!options.leading\n maxing = 'maxWait' in options\n maxWait = maxing ? nativeMax(options.maxWait || 0, wait) : maxWait\n trailing = 'trailing' in options ? !!options.trailing : trailing\n }\n\n function invokeFunc(time) {\n const args = lastArgs,\n thisArg = lastThis\n\n lastArgs = lastThis = undefined\n lastInvokeTime = time\n result = func.apply(thisArg, args)\n return result\n }\n\n function leadingEdge(time) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait)\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result\n }\n\n function remainingWait(time) {\n const timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime,\n timeWaiting = wait - timeSinceLastCall\n\n return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting\n }\n\n function shouldInvoke(time) {\n const timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (\n lastCallTime === undefined ||\n timeSinceLastCall >= wait ||\n timeSinceLastCall < 0 ||\n (maxing && timeSinceLastInvoke >= maxWait)\n )\n }\n\n function timerExpired() {\n const time = Date.now()\n if (shouldInvoke(time)) {\n return trailingEdge(time)\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time))\n }\n\n function trailingEdge(time) {\n timerId = undefined\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time)\n }\n lastArgs = lastThis = undefined\n return result\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId)\n }\n lastInvokeTime = 0\n lastArgs = lastCallTime = lastThis = timerId = undefined\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(Date.now())\n }\n\n function debounced() {\n const time = Date.now(),\n isInvoking = shouldInvoke(time)\n\n // eslint-disable-next-line prefer-rest-params\n lastArgs = arguments\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n lastThis = this\n lastCallTime = time\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime)\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n clearTimeout(timerId)\n timerId = setTimeout(timerExpired, wait)\n return invokeFunc(lastCallTime)\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait)\n }\n return result\n }\n debounced.cancel = cancel\n debounced.flush = flush\n return debounced\n}\n\n// eslint-disable-next-line no-restricted-exports\nexport default debounce\n"],"mappings":"AAAA;AACA;AACA;;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAA,CAoDA;AACA,MAAMA,eAAA,GAAkB;AAExB;AACA,MAAMC,SAAA,GAAYC,IAAA,CAAKC,GAAG;EACxBC,SAAA,GAAYF,IAAA,CAAKG,GAAG;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAASC,SAASC,IAA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YAAA,GAAeW,IAAA;IAEf,IAAIoB,UAAA,EAAY;MACd,IAAIxB,OAAA,KAAYO,SAAA,EAAW;QACzB,OAAOE,WAAA,CAAYhB,YAAA;MACrB;MACA,IAAII,MAAA,EAAQ;QACV;QACAwB,YAAA,CAAarB,OAAA;QACbA,OAAA,GAAUU,UAAA,CAAWC,YAAA,EAAcrB,IAAA;QACnC,OAAOa,UAAA,CAAWV,YAAA;MACpB;IACF;IACA,IAAIO,OAAA,KAAYO,SAAA,EAAW;MACzBP,OAAA,GAAUU,UAAA,CAAWC,YAAA,EAAcrB,IAAA;IACrC;IACA,OAAOS,MAAA;EACT;EACAwB,SAAA,CAAUH,MAAM,GAAGA,MAAA;EACnBG,SAAA,CAAUD,KAAK,GAAGA,KAAA;EAClB,OAAOC,SAAA;AACT;AAEA;AACA,eAAenC,QAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"debounce.js","names":["FUNC_ERROR_TEXT","nativeMax","Math","max","nativeMin","min","debounce","func","wait","options","lastArgs","lastCallTime","lastInvokeTime","lastThis","leading","maxing","maxWait","result","timerID","trailing","TypeError","invokeFunc","time","args","thisArg","undefined","apply","leadingEdge","setTimeout","timerExpired","remainingWait","timeSinceLastCall","timeSinceLastInvoke","timeWaiting","shouldInvoke","Date","now","trailingEdge","cancel","clearTimeout","flush","debounced","isInvoking","arguments"],"sources":["../../../../../src/features/experimental_table/client/utils/debounce.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-nocheck - not worth it migrate jsdoc to tsdoc\n'use client'\n// Copied & modified from https://github.com/lodash/lodash/blob/main/src/debounce.ts\n/*\nThe MIT License\n\nCopyright JS Foundation and other contributors <https://js.foundation/>\n\nBased on Underscore.js, copyright Jeremy Ashkenas,\nDocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>\n\nThis software consists of voluntary contributions made by many\nindividuals. For exact contribution history, see the revision history\navailable at https://github.com/lodash/lodash\n\nThe following license applies to all parts of this software except as\ndocumented below:\n\n====\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n====\n\nCopyright and related rights for sample code are waived via CC0. Sample\ncode is defined as all source code displayed within the prose of the\ndocumentation.\n\nCC0: http://creativecommons.org/publicdomain/zero/1.0/\n\n====\n\nFiles located in the node_modules and vendor directories are externally\nmaintained libraries used by this software which have their own\nlicenses; we recommend you read them, as their terms may differ from the\nterms above.\n */\n\n/** Error message constants. */\nconst FUNC_ERROR_TEXT = 'Expected a function'\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nconst nativeMax = Math.max,\n nativeMin = Math.min\n\n/**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `func` invocations and a `flush` method to immediately invoke them.\n * Provide `options` to indicate whether `func` should be invoked on the\n * leading and/or trailing edge of the `wait` timeout. The `func` is invoked\n * with the last arguments provided to the debounced function. Subsequent\n * calls to the debounced function return the result of the last `func`\n * invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.debounce` and `_.throttle`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=false]\n * Specify invoking on the leading edge of the timeout.\n * @param {number} [options.maxWait]\n * The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * // Avoid costly calculations while the window size is in flux.\n * jQuery(window).on('resize', _.debounce(calculateLayout, 150));\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * jQuery(element).on('click', _.debounce(sendMail, 300, {\n * 'leading': true,\n * 'trailing': false\n * }));\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });\n * var source = new EventSource('/stream');\n * jQuery(source).on('message', debounced);\n *\n * // Cancel the trailing debounced invocation.\n * jQuery(window).on('popstate', debounced.cancel);\n */\nfunction debounce(func, wait, options) {\n let lastArgs,\n lastCallTime,\n lastInvokeTime = 0,\n lastThis,\n leading = false,\n maxing = false,\n maxWait,\n result,\n timerID,\n trailing = true\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT)\n }\n wait = wait || 0\n if (typeof options === 'object') {\n leading = !!options.leading\n maxing = 'maxWait' in options\n maxWait = maxing ? nativeMax(options.maxWait || 0, wait) : maxWait\n trailing = 'trailing' in options ? !!options.trailing : trailing\n }\n\n function invokeFunc(time) {\n const args = lastArgs,\n thisArg = lastThis\n\n lastArgs = lastThis = undefined\n lastInvokeTime = time\n result = func.apply(thisArg, args)\n return result\n }\n\n function leadingEdge(time) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time\n // Start the timer for the trailing edge.\n timerID = setTimeout(timerExpired, wait)\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result\n }\n\n function remainingWait(time) {\n const timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime,\n timeWaiting = wait - timeSinceLastCall\n\n return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting\n }\n\n function shouldInvoke(time) {\n const timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (\n lastCallTime === undefined ||\n timeSinceLastCall >= wait ||\n timeSinceLastCall < 0 ||\n (maxing && timeSinceLastInvoke >= maxWait)\n )\n }\n\n function timerExpired() {\n const time = Date.now()\n if (shouldInvoke(time)) {\n return trailingEdge(time)\n }\n // Restart the timer.\n timerID = setTimeout(timerExpired, remainingWait(time))\n }\n\n function trailingEdge(time) {\n timerID = undefined\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time)\n }\n lastArgs = lastThis = undefined\n return result\n }\n\n function cancel() {\n if (timerID !== undefined) {\n clearTimeout(timerID)\n }\n lastInvokeTime = 0\n lastArgs = lastCallTime = lastThis = timerID = undefined\n }\n\n function flush() {\n return timerID === undefined ? result : trailingEdge(Date.now())\n }\n\n function debounced() {\n const time = Date.now(),\n isInvoking = shouldInvoke(time)\n\n // eslint-disable-next-line prefer-rest-params\n lastArgs = arguments\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n lastThis = this\n lastCallTime = time\n\n if (isInvoking) {\n if (timerID === undefined) {\n return leadingEdge(lastCallTime)\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n clearTimeout(timerID)\n timerID = setTimeout(timerExpired, wait)\n return invokeFunc(lastCallTime)\n }\n }\n if (timerID === undefined) {\n timerID = setTimeout(timerExpired, wait)\n }\n return result\n }\n debounced.cancel = cancel\n debounced.flush = flush\n return debounced\n}\n\n// eslint-disable-next-line no-restricted-exports\nexport default debounce\n"],"mappings":"AAAA;AACA;AACA;;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAAA,CAoDA;AACA,MAAMA,eAAA,GAAkB;AAExB;AACA,MAAMC,SAAA,GAAYC,IAAA,CAAKC,GAAG;EACxBC,SAAA,GAAYF,IAAA,CAAKG,GAAG;AAEtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAASC,SAASC,IAAI,EAAEC,IAAI,EAAEC,OAAO;EACnC,IAAIC,QAAA;IACFC,YAAA;IACAC,cAAA,GAAiB;IACjBC,QAAA;IACAC,OAAA,GAAU;IACVC,MAAA,GAAS;IACTC,OAAA;IACAC,MAAA;IACAC,OAAA;IACAC,QAAA,GAAW;EAEb,IAAI,OAAOZ,IAAA,IAAQ,YAAY;IAC7B,MAAM,IAAIa,SAAA,CAAUpB,eAAA;EACtB;EACAQ,IAAA,GAAOA,IAAA,IAAQ;EACf,IAAI,OAAOC,OAAA,KAAY,UAAU;IAC/BK,OAAA,GAAU,CAAC,CAACL,OAAA,CAAQK,OAAO;IAC3BC,MAAA,GAAS,aAAaN,OAAA;IACtBO,OAAA,GAAUD,MAAA,GAASd,SAAA,CAAUQ,OAAA,CAAQO,OAAO,IAAI,GAAGR,IAAA,IAAQQ,OAAA;IAC3DG,QAAA,GAAW,cAAcV,OAAA,GAAU,CAAC,CAACA,OAAA,CAAQU,QAAQ,GAAGA,QAAA;EAC1D;EAEA,SAASE,WAAWC,IAAI;IACtB,MAAMC,IAAA,GAAOb,QAAA;MACXc,OAAA,GAAUX,Q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IACpB;IACAZ,QAAA,GAAWG,QAAA,GAAWY,SAAA;IACtB,OAAOR,MAAA;EACT;EAEA,SAASqB,OAAA;IACP,IAAIpB,OAAA,KAAYO,SAAA,EAAW;MACzBc,YAAA,CAAarB,OAAA;IACf;IACAN,cAAA,GAAiB;IACjBF,QAAA,GAAWC,YAAA,GAAeE,QAAA,GAAWK,OAAA,GAAUO,SAAA;EACjD;EAEA,SAASe,MAAA;IACP,OAAOtB,OAAA,KAAYO,SAAA,GAAYR,MAAA,GAASoB,YAAA,CAAaF,IAAA,CAAKC,GAAG;EAC/D;EAEA,SAASK,UAAA;IACP,MAAMnB,IAAA,GAAOa,IAAA,CAAKC,GAAG;MACnBM,UAAA,GAAaR,YAAA,CAAaZ,IAAA;IAE5B;IACAZ,QAAA,GAAWiC,SAAA;IACX;IACA9B,QAAA,GAAW,IAAI;IACfF,YAAA,GAAeW,IAAA;IAEf,IAAIoB,UAAA,EAAY;MACd,IAAIxB,OAAA,KAAYO,SAAA,EAAW;QACzB,OAAOE,WAAA,CAAYhB,YAAA;MACrB;MACA,IAAII,MAAA,EAAQ;QACV;QACAwB,YAAA,CAAarB,OAAA;QACbA,OAAA,GAAUU,UAAA,CAAWC,YAAA,EAAcrB,IAAA;QACnC,OAAOa,UAAA,CAAWV,YAAA;MACpB;IACF;IACA,IAAIO,OAAA,KAAYO,SAAA,EAAW;MACzBP,OAAA,GAAUU,UAAA,CAAWC,YAAA,EAAcrB,IAAA;IACrC;IACA,OAAOS,MAAA;EACT;EACAwB,SAAA,CAAUH,MAAM,GAAGA,MAAA;EACnBG,SAAA,CAAUD,KAAK,GAAGA,KAAA;EAClB,OAAOC,SAAA;AACT;AAEA;AACA,eAAenC,QAAA","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GenericLanguages, I18nClient } from '@payloadcms/translations';
|
|
1
|
+
import type { GenericLanguages, I18n, I18nClient } from '@payloadcms/translations';
|
|
2
2
|
import type { JSONSchema4 } from 'json-schema';
|
|
3
3
|
import type { Klass, LexicalNode, LexicalNodeReplacement, SerializedEditorState, SerializedLexicalNode } from 'lexical';
|
|
4
4
|
import type { Config, Field, FieldSchemaMap, JsonObject, PayloadComponent, PayloadRequest, PopulateType, ReplaceAny, RequestContext, RichTextField, RichTextHooks, SanitizedConfig, ValidateOptions, ValidationFieldError } from 'payload';
|
|
@@ -210,7 +210,7 @@ export type ServerFeature<ServerProps, ClientFeatureProps> = {
|
|
|
210
210
|
clientFeatureProps?: ClientFeatureProps;
|
|
211
211
|
componentImports?: Config['admin']['importMap']['generators'][0] | PayloadComponent[];
|
|
212
212
|
generatedTypes?: {
|
|
213
|
-
modifyOutputSchema: (
|
|
213
|
+
modifyOutputSchema: (args: {
|
|
214
214
|
collectionIDFieldTypes: {
|
|
215
215
|
[key: string]: 'number' | 'string';
|
|
216
216
|
};
|
|
@@ -220,6 +220,7 @@ export type ServerFeature<ServerProps, ClientFeatureProps> = {
|
|
|
220
220
|
*/
|
|
221
221
|
currentSchema: JSONSchema4;
|
|
222
222
|
field: RichTextField<SerializedEditorState, AdapterProps>;
|
|
223
|
+
i18n?: I18n;
|
|
223
224
|
/**
|
|
224
225
|
* Allows you to define new top-level interfaces that can be re-used in the output schema.
|
|
225
226
|
*/
|
|
@@ -276,7 +277,7 @@ export type SanitizedServerFeatures = {
|
|
|
276
277
|
/** The keys of all enabled features */
|
|
277
278
|
enabledFeatures: string[];
|
|
278
279
|
generatedTypes: {
|
|
279
|
-
modifyOutputSchemas: Array<(
|
|
280
|
+
modifyOutputSchemas: Array<(args: {
|
|
280
281
|
collectionIDFieldTypes: {
|
|
281
282
|
[key: string]: 'number' | 'string';
|
|
282
283
|
};
|
|
@@ -286,6 +287,7 @@ export type SanitizedServerFeatures = {
|
|
|
286
287
|
*/
|
|
287
288
|
currentSchema: JSONSchema4;
|
|
288
289
|
field: RichTextField<SerializedEditorState, AdapterProps>;
|
|
290
|
+
i18n?: I18n;
|
|
289
291
|
/**
|
|
290
292
|
* Allows you to define new top-level interfaces that can be re-used in the output schema.
|
|
291
293
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesServer.d.ts","sourceRoot":"","sources":["../../src/features/typesServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"typesServer.d.ts","sourceRoot":"","sources":["../../src/features/typesServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACX,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EACV,MAAM,EACN,KAAK,EACL,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,EACb,aAAa,EACb,eAAe,EACf,eAAe,EACf,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAA;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;AACzE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAA;AAE9D,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,IAAI,CAAC,EACxF,OAAO,EACP,YAAY,EACZ,KAAK,EACL,KAAK,EACL,wBAAwB,EACxB,KAAK,EACL,aAAa,EACb,QAAQ,EACR,cAAc,EACd,I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,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;QACxE,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;QAC9E,cAAc,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,sBAAsB,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAA;KACnF,CAAA,CAAC,yDAAyD;IAC3D,kDAAkD;IAClD,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAA;CAChD,GAAG,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesServer.js","names":[],"sources":["../../src/features/typesServer.ts"],"sourcesContent":["import type { GenericLanguages, I18nClient } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type {\n Klass,\n LexicalNode,\n LexicalNodeReplacement,\n SerializedEditorState,\n SerializedLexicalNode,\n} from 'lexical'\nimport type {\n Config,\n Field,\n FieldSchemaMap,\n JsonObject,\n PayloadComponent,\n PayloadRequest,\n PopulateType,\n ReplaceAny,\n RequestContext,\n RichTextField,\n RichTextHooks,\n SanitizedConfig,\n ValidateOptions,\n ValidationFieldError,\n} from 'payload'\n\nimport type { ServerEditorConfig } from '../lexical/config/types.js'\nimport type { Transformer } from '../packages/@lexical/markdown/index.js'\nimport type { AdapterProps } from '../types.js'\nimport type { HTMLConverter } from './converters/html/converter/types.js'\nimport type { BaseClientFeatureProps } from './typesClient.js'\n\nexport type PopulationPromise<T extends SerializedLexicalNode = SerializedLexicalNode> = ({\n context,\n currentDepth,\n depth,\n draft,\n editorPopulationPromises,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n node,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n}: {\n context: RequestContext\n currentDepth: number\n depth: number\n draft: boolean\n /**\n * This maps all population promises to the node type\n */\n editorPopulationPromises: Map<string, Array<PopulationPromise>>\n field: RichTextField<SerializedEditorState, AdapterProps>\n /**\n * fieldPromises are used for things like field hooks. They will be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n node: T\n overrideAccess: boolean\n populationPromises: Promise<void>[]\n req: PayloadRequest\n showHiddenFields: boolean\n siblingDoc: JsonObject\n}) => void\n\nexport type NodeValidation<T extends SerializedLexicalNode = SerializedLexicalNode> = ({\n node,\n nodeValidations,\n validation,\n}: {\n node: T\n nodeValidations: Map<string, Array<NodeValidation>>\n validation: {\n options: ValidateOptions<unknown, unknown, RichTextField, SerializedEditorState>\n value: SerializedEditorState\n }\n}) => Promise<string | true> | string | true\n\nexport type FeatureProviderProviderServer<\n UnSanitizedServerFeatureProps = undefined,\n ServerFeatureProps = UnSanitizedServerFeatureProps,\n ClientFeatureProps = undefined,\n> = (\n props?: UnSanitizedServerFeatureProps,\n) => FeatureProviderServer<UnSanitizedServerFeatureProps, ServerFeatureProps, ClientFeatureProps>\n\nexport type FeatureProviderServer<\n UnSanitizedServerFeatureProps = undefined,\n ServerFeatureProps = UnSanitizedServerFeatureProps,\n ClientFeatureProps = undefined,\n> = {\n /** Keys of dependencies needed for this feature. These dependencies do not have to be loaded first, but they have to exist, otherwise an error will be thrown. */\n dependencies?: string[]\n /** Keys of priority dependencies needed for this feature. These dependencies have to be loaded first AND have to exist, otherwise an error will be thrown. They will be available in the `feature` property. */\n dependenciesPriority?: string[]\n /** Keys of soft-dependencies needed for this feature. These are optional. Payload will attempt to load them before this feature, but doesn't throw an error if that's not possible. */\n dependenciesSoft?: string[]\n\n /**\n * This is being called during the payload sanitization process\n */\n feature:\n | ((props: {\n config: SanitizedConfig\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ServerFeatureProviderMap\n isRoot?: boolean\n parentIsLocalized: boolean\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedServerFeatureMap\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ServerEditorConfig\n }) =>\n | Promise<ServerFeature<ServerFeatureProps, ClientFeatureProps>>\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>)\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>\n key: string\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n serverFeatureProps: UnSanitizedServerFeatureProps\n}\n\nexport type AfterReadNodeHookArgs<T extends SerializedLexicalNode> = {\n /**\n * Only available in `afterRead` hooks.\n */\n currentDepth: number\n /**\n * Only available in `afterRead` hooks.\n */\n depth: number\n draft: boolean\n fallbackLocale: string\n /**\n * Only available in `afterRead` field hooks.\n */\n fieldPromises: Promise<void>[]\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany: boolean\n flattenLocales: boolean\n /**\n * The requested locale.\n */\n locale: string\n overrideAccess: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n populateArg?: PopulateType\n /**\n * Only available in `afterRead` field hooks.\n */\n populationPromises: Promise<void>[]\n /**\n * Only available in `afterRead` hooks.\n */\n showHiddenFields: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n triggerAccessControl: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n triggerHooks: boolean\n}\n\nexport type AfterChangeNodeHookArgs<T extends SerializedLexicalNode> = {\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n previousNode: T\n}\nexport type BeforeValidateNodeHookArgs<T extends SerializedLexicalNode> = {\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n overrideAccess: boolean\n}\n\nexport type BeforeChangeNodeHookArgs<T extends SerializedLexicalNode> = {\n /**\n * Only available in `beforeChange` hooks.\n */\n errors: ValidationFieldError[]\n mergeLocaleActions: (() => Promise<void>)[]\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n /**\n * The original node with locales (not modified by any hooks).\n */\n originalNodeWithLocales?: T\n previousNode: T\n\n skipValidation: boolean\n}\n\nexport type BaseNodeHookArgs<T extends SerializedLexicalNode> = {\n context: RequestContext\n /** The value of the node. */\n node: T\n parentRichTextFieldPath: (number | string)[]\n parentRichTextFieldSchemaPath: string[]\n /** The payload request object. It is mocked for Local API operations. */\n req: PayloadRequest\n}\n\nexport type AfterReadNodeHook<T extends SerializedLexicalNode> = (\n args: AfterReadNodeHookArgs<T> & BaseNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type AfterChangeNodeHook<T extends SerializedLexicalNode> = (\n args: AfterChangeNodeHookArgs<T> & BaseNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type BeforeChangeNodeHook<T extends SerializedLexicalNode> = (\n args: BaseNodeHookArgs<T> & BeforeChangeNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type BeforeValidateNodeHook<T extends SerializedLexicalNode> = (\n args: BaseNodeHookArgs<T> & BeforeValidateNodeHookArgs<T>,\n) => Promise<T> | T\n\n// Define the node with hooks that use the node's exportJSON return type\nexport type NodeWithHooks<T extends LexicalNode = any> = {\n /**\n * Allows you to define how a node can be serialized into different formats. Currently, only supports html.\n * Markdown converters are defined in `markdownTransformers` and not here.\n */\n converters?: {\n html?: HTMLConverter<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n }\n /**\n * If a node includes sub-fields (e.g. block and link nodes), passing those subFields here will make payload\n * automatically populate, run hooks, and generate component import maps for them\n */\n getSubFields?: (args: {\n /**\n * Optional. If not provided, all possible sub-fields should be returned.\n */\n node?: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>\n req?: PayloadRequest\n }) => Field[] | null\n /**\n * If a node includes sub-fields, the sub-fields data needs to be returned here, alongside `getSubFields` which returns their schema.\n */\n getSubFieldsData?: (args: {\n node: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>\n req: PayloadRequest\n }) => JsonObject\n /**\n * Allows you to run population logic when a node's data was requested from graphQL.\n * While `getSubFields` and `getSubFieldsData` automatically handle populating sub-fields (since they run hooks on them), those are only populated in the Rest API.\n * This is because the Rest API hooks do not have access to the 'depth' property provided by graphQL.\n * In order for them to be populated correctly in graphQL, the population logic needs to be provided here.\n */\n graphQLPopulationPromises?: Array<\n PopulationPromise<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n /**\n * Just like payload fields, you can provide hooks which are run for this specific node. These are called Node Hooks.\n */\n hooks?: {\n afterChange?: Array<AfterChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n afterRead?: Array<AfterReadNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeChange?: Array<BeforeChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeValidate?: Array<\n BeforeValidateNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n }\n /**\n * The actual lexical node needs to be provided here. This also supports [lexical node replacements](https://lexical.dev/docs/concepts/node-replacement).\n */\n node: Klass<T> | LexicalNodeReplacement\n /**\n * This allows you to provide node validations, which are run when your document is being validated, alongside other payload fields.\n * You can use it to throw a validation error for a specific node in case its data is incorrect.\n */\n validations?: Array<NodeValidation<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n}\n\nexport type ServerFeature<ServerProps, ClientFeatureProps> = {\n ClientFeature?: PayloadComponent<never, BaseClientFeatureProps<ClientFeatureProps>>\n /**\n * This determines what props will be available on the Client.\n */\n clientFeatureProps?: ClientFeatureProps\n // @ts-expect-error - TODO: fix this\n componentImports?: Config['admin']['importMap']['generators'][0] | PayloadComponent[]\n generatedTypes?: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n isRequired,\n }: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n /**\n * Current schema which will be modified by this function.\n */\n currentSchema: JSONSchema4\n field: RichTextField<SerializedEditorState, AdapterProps>\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n }\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n field: RichTextField\n i18n: I18nClient\n props: ServerProps\n schemaMap: FieldSchemaMap\n schemaPath: string\n }) => FieldSchemaMap | null\n hooks?: RichTextHooks\n /**\n * Here you can provide i18n translations for your feature. These will only be available on the server and client.\n *\n * Translations here are automatically scoped to `lexical.featureKey.yourKey`\n *\n * @Example\n * ```ts\n * i18n: {\n * en: {\n * label: 'Horizontal Rule',\n * },\n * de: {\n * label: 'Trennlinie',\n * },\n * }\n * ```\n * In order to access these translations, you would use `i18n.t('lexical:horizontalRule:label')`.\n */\n i18n?: Partial<GenericLanguages>\n markdownTransformers?: (\n | ((props: { allNodes: Array<NodeWithHooks>; allTransformers: Transformer[] }) => Transformer)\n | Transformer\n )[]\n nodes?: Array<NodeWithHooks>\n\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n sanitizedServerFeatureProps?: ServerProps\n}\n\nexport type ResolvedServerFeature<ServerProps, ClientFeatureProps> = {\n order: number\n} & Required<\n Pick<\n FeatureProviderServer<ServerProps, ClientFeatureProps>,\n 'dependencies' | 'dependenciesPriority' | 'dependenciesSoft' | 'key'\n >\n> &\n ServerFeature<ServerProps, ClientFeatureProps>\n\nexport type ResolvedServerFeatureMap = Map<string, ResolvedServerFeature<any, any>>\n\nexport type ServerFeatureProviderMap = Map<string, FeatureProviderServer<any, any, any>>\n\nexport type SanitizedServerFeatures = {\n /** The node types mapped to their converters */\n converters: {\n html: HTMLConverter[]\n }\n /** The keys of all enabled features */\n enabledFeatures: string[]\n generatedTypes: {\n modifyOutputSchemas: Array<\n ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n isRequired,\n }: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n /**\n * Current schema which will be modified by this function.\n */\n currentSchema: JSONSchema4\n field: RichTextField<SerializedEditorState, AdapterProps>\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n >\n }\n /** The node types mapped to their hooks */\n\n getSubFields?: Map<\n string,\n (args: { node: SerializedLexicalNode; req: PayloadRequest }) => Field[] | null\n >\n getSubFieldsData?: Map<\n string,\n (args: { node: SerializedLexicalNode; req: PayloadRequest }) => JsonObject\n >\n graphQLPopulationPromises: Map<string, Array<PopulationPromise>>\n hooks: RichTextHooks\n markdownTransformers: Transformer[]\n nodeHooks?: {\n afterChange?: Map<string, Array<AfterChangeNodeHook<SerializedLexicalNode>>>\n afterRead?: Map<string, Array<AfterReadNodeHook<SerializedLexicalNode>>>\n beforeChange?: Map<string, Array<BeforeChangeNodeHook<SerializedLexicalNode>>>\n beforeValidate?: Map<string, Array<BeforeValidateNodeHook<SerializedLexicalNode>>>\n } /** The node types mapped to their populationPromises */\n /** The node types mapped to their validations */\n validations: Map<string, Array<NodeValidation>>\n} & Required<Pick<ResolvedServerFeature<any, any>, 'i18n' | 'nodes'>>\n"],"mappings":"AAsXA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"typesServer.js","names":[],"sources":["../../src/features/typesServer.ts"],"sourcesContent":["import type { GenericLanguages, I18n, I18nClient } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type {\n Klass,\n LexicalNode,\n LexicalNodeReplacement,\n SerializedEditorState,\n SerializedLexicalNode,\n} from 'lexical'\nimport type {\n Config,\n Field,\n FieldSchemaMap,\n JsonObject,\n PayloadComponent,\n PayloadRequest,\n PopulateType,\n ReplaceAny,\n RequestContext,\n RichTextField,\n RichTextHooks,\n SanitizedConfig,\n ValidateOptions,\n ValidationFieldError,\n} from 'payload'\n\nimport type { ServerEditorConfig } from '../lexical/config/types.js'\nimport type { Transformer } from '../packages/@lexical/markdown/index.js'\nimport type { AdapterProps } from '../types.js'\nimport type { HTMLConverter } from './converters/html/converter/types.js'\nimport type { BaseClientFeatureProps } from './typesClient.js'\n\nexport type PopulationPromise<T extends SerializedLexicalNode = SerializedLexicalNode> = ({\n context,\n currentDepth,\n depth,\n draft,\n editorPopulationPromises,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n node,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n}: {\n context: RequestContext\n currentDepth: number\n depth: number\n draft: boolean\n /**\n * This maps all population promises to the node type\n */\n editorPopulationPromises: Map<string, Array<PopulationPromise>>\n field: RichTextField<SerializedEditorState, AdapterProps>\n /**\n * fieldPromises are used for things like field hooks. They will be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n node: T\n overrideAccess: boolean\n populationPromises: Promise<void>[]\n req: PayloadRequest\n showHiddenFields: boolean\n siblingDoc: JsonObject\n}) => void\n\nexport type NodeValidation<T extends SerializedLexicalNode = SerializedLexicalNode> = ({\n node,\n nodeValidations,\n validation,\n}: {\n node: T\n nodeValidations: Map<string, Array<NodeValidation>>\n validation: {\n options: ValidateOptions<unknown, unknown, RichTextField, SerializedEditorState>\n value: SerializedEditorState\n }\n}) => Promise<string | true> | string | true\n\nexport type FeatureProviderProviderServer<\n UnSanitizedServerFeatureProps = undefined,\n ServerFeatureProps = UnSanitizedServerFeatureProps,\n ClientFeatureProps = undefined,\n> = (\n props?: UnSanitizedServerFeatureProps,\n) => FeatureProviderServer<UnSanitizedServerFeatureProps, ServerFeatureProps, ClientFeatureProps>\n\nexport type FeatureProviderServer<\n UnSanitizedServerFeatureProps = undefined,\n ServerFeatureProps = UnSanitizedServerFeatureProps,\n ClientFeatureProps = undefined,\n> = {\n /** Keys of dependencies needed for this feature. These dependencies do not have to be loaded first, but they have to exist, otherwise an error will be thrown. */\n dependencies?: string[]\n /** Keys of priority dependencies needed for this feature. These dependencies have to be loaded first AND have to exist, otherwise an error will be thrown. They will be available in the `feature` property. */\n dependenciesPriority?: string[]\n /** Keys of soft-dependencies needed for this feature. These are optional. Payload will attempt to load them before this feature, but doesn't throw an error if that's not possible. */\n dependenciesSoft?: string[]\n\n /**\n * This is being called during the payload sanitization process\n */\n feature:\n | ((props: {\n config: SanitizedConfig\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ServerFeatureProviderMap\n isRoot?: boolean\n parentIsLocalized: boolean\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedServerFeatureMap\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ServerEditorConfig\n }) =>\n | Promise<ServerFeature<ServerFeatureProps, ClientFeatureProps>>\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>)\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>\n key: string\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n serverFeatureProps: UnSanitizedServerFeatureProps\n}\n\nexport type AfterReadNodeHookArgs<T extends SerializedLexicalNode> = {\n /**\n * Only available in `afterRead` hooks.\n */\n currentDepth: number\n /**\n * Only available in `afterRead` hooks.\n */\n depth: number\n draft: boolean\n fallbackLocale: string\n /**\n * Only available in `afterRead` field hooks.\n */\n fieldPromises: Promise<void>[]\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany: boolean\n flattenLocales: boolean\n /**\n * The requested locale.\n */\n locale: string\n overrideAccess: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n populateArg?: PopulateType\n /**\n * Only available in `afterRead` field hooks.\n */\n populationPromises: Promise<void>[]\n /**\n * Only available in `afterRead` hooks.\n */\n showHiddenFields: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n triggerAccessControl: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n triggerHooks: boolean\n}\n\nexport type AfterChangeNodeHookArgs<T extends SerializedLexicalNode> = {\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n previousNode: T\n}\nexport type BeforeValidateNodeHookArgs<T extends SerializedLexicalNode> = {\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n overrideAccess: boolean\n}\n\nexport type BeforeChangeNodeHookArgs<T extends SerializedLexicalNode> = {\n /**\n * Only available in `beforeChange` hooks.\n */\n errors: ValidationFieldError[]\n mergeLocaleActions: (() => Promise<void>)[]\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n /**\n * The original node with locales (not modified by any hooks).\n */\n originalNodeWithLocales?: T\n previousNode: T\n\n skipValidation: boolean\n}\n\nexport type BaseNodeHookArgs<T extends SerializedLexicalNode> = {\n context: RequestContext\n /** The value of the node. */\n node: T\n parentRichTextFieldPath: (number | string)[]\n parentRichTextFieldSchemaPath: string[]\n /** The payload request object. It is mocked for Local API operations. */\n req: PayloadRequest\n}\n\nexport type AfterReadNodeHook<T extends SerializedLexicalNode> = (\n args: AfterReadNodeHookArgs<T> & BaseNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type AfterChangeNodeHook<T extends SerializedLexicalNode> = (\n args: AfterChangeNodeHookArgs<T> & BaseNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type BeforeChangeNodeHook<T extends SerializedLexicalNode> = (\n args: BaseNodeHookArgs<T> & BeforeChangeNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type BeforeValidateNodeHook<T extends SerializedLexicalNode> = (\n args: BaseNodeHookArgs<T> & BeforeValidateNodeHookArgs<T>,\n) => Promise<T> | T\n\n// Define the node with hooks that use the node's exportJSON return type\nexport type NodeWithHooks<T extends LexicalNode = any> = {\n /**\n * Allows you to define how a node can be serialized into different formats. Currently, only supports html.\n * Markdown converters are defined in `markdownTransformers` and not here.\n */\n converters?: {\n html?: HTMLConverter<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n }\n /**\n * If a node includes sub-fields (e.g. block and link nodes), passing those subFields here will make payload\n * automatically populate, run hooks, and generate component import maps for them\n */\n getSubFields?: (args: {\n /**\n * Optional. If not provided, all possible sub-fields should be returned.\n */\n node?: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>\n req?: PayloadRequest\n }) => Field[] | null\n /**\n * If a node includes sub-fields, the sub-fields data needs to be returned here, alongside `getSubFields` which returns their schema.\n */\n getSubFieldsData?: (args: {\n node: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>\n req: PayloadRequest\n }) => JsonObject\n /**\n * Allows you to run population logic when a node's data was requested from graphQL.\n * While `getSubFields` and `getSubFieldsData` automatically handle populating sub-fields (since they run hooks on them), those are only populated in the Rest API.\n * This is because the Rest API hooks do not have access to the 'depth' property provided by graphQL.\n * In order for them to be populated correctly in graphQL, the population logic needs to be provided here.\n */\n graphQLPopulationPromises?: Array<\n PopulationPromise<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n /**\n * Just like payload fields, you can provide hooks which are run for this specific node. These are called Node Hooks.\n */\n hooks?: {\n afterChange?: Array<AfterChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n afterRead?: Array<AfterReadNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeChange?: Array<BeforeChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeValidate?: Array<\n BeforeValidateNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n }\n /**\n * The actual lexical node needs to be provided here. This also supports [lexical node replacements](https://lexical.dev/docs/concepts/node-replacement).\n */\n node: Klass<T> | LexicalNodeReplacement\n /**\n * This allows you to provide node validations, which are run when your document is being validated, alongside other payload fields.\n * You can use it to throw a validation error for a specific node in case its data is incorrect.\n */\n validations?: Array<NodeValidation<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n}\n\nexport type ServerFeature<ServerProps, ClientFeatureProps> = {\n ClientFeature?: PayloadComponent<never, BaseClientFeatureProps<ClientFeatureProps>>\n /**\n * This determines what props will be available on the Client.\n */\n clientFeatureProps?: ClientFeatureProps\n // @ts-expect-error - TODO: fix this\n componentImports?: Config['admin']['importMap']['generators'][0] | PayloadComponent[]\n generatedTypes?: {\n modifyOutputSchema: (args: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n /**\n * Current schema which will be modified by this function.\n */\n currentSchema: JSONSchema4\n field: RichTextField<SerializedEditorState, AdapterProps>\n i18n?: I18n\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n }\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n field: RichTextField\n i18n: I18nClient\n props: ServerProps\n schemaMap: FieldSchemaMap\n schemaPath: string\n }) => FieldSchemaMap | null\n hooks?: RichTextHooks\n /**\n * Here you can provide i18n translations for your feature. These will only be available on the server and client.\n *\n * Translations here are automatically scoped to `lexical.featureKey.yourKey`\n *\n * @Example\n * ```ts\n * i18n: {\n * en: {\n * label: 'Horizontal Rule',\n * },\n * de: {\n * label: 'Trennlinie',\n * },\n * }\n * ```\n * In order to access these translations, you would use `i18n.t('lexical:horizontalRule:label')`.\n */\n i18n?: Partial<GenericLanguages>\n markdownTransformers?: (\n | ((props: { allNodes: Array<NodeWithHooks>; allTransformers: Transformer[] }) => Transformer)\n | Transformer\n )[]\n nodes?: Array<NodeWithHooks>\n\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n sanitizedServerFeatureProps?: ServerProps\n}\n\nexport type ResolvedServerFeature<ServerProps, ClientFeatureProps> = {\n order: number\n} & Required<\n Pick<\n FeatureProviderServer<ServerProps, ClientFeatureProps>,\n 'dependencies' | 'dependenciesPriority' | 'dependenciesSoft' | 'key'\n >\n> &\n ServerFeature<ServerProps, ClientFeatureProps>\n\nexport type ResolvedServerFeatureMap = Map<string, ResolvedServerFeature<any, any>>\n\nexport type ServerFeatureProviderMap = Map<string, FeatureProviderServer<any, any, any>>\n\nexport type SanitizedServerFeatures = {\n /** The node types mapped to their converters */\n converters: {\n html: HTMLConverter[]\n }\n /** The keys of all enabled features */\n enabledFeatures: string[]\n generatedTypes: {\n modifyOutputSchemas: Array<\n (args: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n /**\n * Current schema which will be modified by this function.\n */\n currentSchema: JSONSchema4\n field: RichTextField<SerializedEditorState, AdapterProps>\n i18n?: I18n\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n >\n }\n /** The node types mapped to their hooks */\n\n getSubFields?: Map<\n string,\n (args: { node: SerializedLexicalNode; req: PayloadRequest }) => Field[] | null\n >\n getSubFieldsData?: Map<\n string,\n (args: { node: SerializedLexicalNode; req: PayloadRequest }) => JsonObject\n >\n graphQLPopulationPromises: Map<string, Array<PopulationPromise>>\n hooks: RichTextHooks\n markdownTransformers: Transformer[]\n nodeHooks?: {\n afterChange?: Map<string, Array<AfterChangeNodeHook<SerializedLexicalNode>>>\n afterRead?: Map<string, Array<AfterReadNodeHook<SerializedLexicalNode>>>\n beforeChange?: Map<string, Array<BeforeChangeNodeHook<SerializedLexicalNode>>>\n beforeValidate?: Map<string, Array<BeforeValidateNodeHook<SerializedLexicalNode>>>\n } /** The node types mapped to their populationPromises */\n /** The node types mapped to their validations */\n validations: Map<string, Array<NodeValidation>>\n} & Required<Pick<ResolvedServerFeature<any, any>, 'i18n' | 'nodes'>>\n"],"mappings":"AAgXA","ignoreList":[]}
|
package/dist/field/Field.js
CHANGED
package/dist/field/Field.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Field.js","names":["FieldDescription","FieldError","FieldLabel","RenderCustomComponent","useEditDepth","useField","mergeFieldStyles","React","useCallback","useMemo","ErrorBoundary","LexicalProvider","baseClass","RichTextComponent","props","editorConfig","field","name","admin","className","description","readOnly","readOnlyFromAdmin","label","localized","required","path","pathFromProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","editDepth","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","formInitializing","formProcessing","initialValue","setValue","showError","disabled","classes","hideGutter","filter","Boolean","join","pathWithEditDepth","handleChange","editorState","toJSON","styles","_jsxs","style","_jsx","CustomComponent","Fallback","fallbackRender","onReset","composerKey","fieldProps","onChange","JSON","stringify","error","role","color","message","RichText"],"sources":["../../src/field/Field.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\nimport type { Validate } from 'payload'\n\nimport {\n FieldDescription,\n FieldError,\n FieldLabel,\n RenderCustomComponent,\n useEditDepth,\n useField,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport React, { useCallback, useMemo } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\n\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport '../lexical/theme/EditorTheme.scss'\nimport './bundled.css'\nimport './index.scss'\nimport { LexicalProvider } from '../lexical/LexicalProvider.js'\n\nconst baseClass = 'rich-text-lexical'\n\nconst RichTextComponent: React.FC<\n {\n readonly editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n } & LexicalRichTextFieldProps\n> = (props) => {\n const {\n editorConfig,\n field,\n field: {\n name,\n admin: { className, description, readOnly: readOnlyFromAdmin } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly: readOnlyFromTopLevelProps,\n validate, // Users can pass in client side validation if they WANT to, but it's not required anymore\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n const path = pathFromProps ?? name\n\n const editDepth = useEditDepth()\n\n const memoizedValidate = useCallback<Validate>(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return validate(value, { ...validationOptions, required })\n }\n return true\n },\n // Important: do not add props to the dependencies array.\n // This would cause an infinite loop and endless re-rendering.\n // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n formInitializing,\n formProcessing,\n initialValue,\n setValue,\n showError,\n value,\n } = useField<SerializedEditorState>({\n path,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || formProcessing || formInitializing\n\n const classes = [\n baseClass,\n 'field-type',\n className,\n showError && 'error',\n disabled && `${baseClass}--read-only`,\n editorConfig?.admin?.hideGutter !== true ? `${baseClass}--show-gutter` : null,\n ]\n .filter(Boolean)\n .join(' ')\n\n const pathWithEditDepth = `${path}.${editDepth}`\n\n const handleChange = useCallback(\n (editorState: EditorState) => {\n setValue(editorState.toJSON())\n },\n [setValue],\n )\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div className={classes} key={pathWithEditDepth} style={styles}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {Label || <FieldLabel label={label} localized={localized} required={required} />}\n <div className={`${baseClass}__wrap`}>\n <ErrorBoundary fallbackRender={fallbackRender} onReset={() => {}}>\n {BeforeInput}\n <LexicalProvider\n composerKey={pathWithEditDepth}\n editorConfig={editorConfig}\n fieldProps={props}\n key={JSON.stringify({ initialValue, path })} // makes sure lexical is completely re-rendered when initialValue changes, bypassing the lexical-internal value memoization. That way, external changes to the form will update the editor. More infos in PR description (https://github.com/payloadcms/payload/pull/5010)\n onChange={handleChange}\n readOnly={disabled}\n value={value}\n />\n {AfterInput}\n </ErrorBoundary>\n {Description}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n\nfunction fallbackRender({ error }: { error: Error }) {\n // Call resetErrorBoundary() to reset the error boundary and retry the render.\n\n return (\n <div className=\"errorBoundary\" role=\"alert\">\n <p>Something went wrong:</p>\n <pre style={{ color: 'red' }}>{error.message}</pre>\n </div>\n )\n}\n\nexport const RichText: typeof RichTextComponent = RichTextComponent\n"],"mappings":"AAAA;;;AAIA,SACEA,gBAAgB,EAChBC,UAAU,EACVC,UAAU,EACVC,qBAAqB,EACrBC,YAAY,EACZC,QAAQ,QACH;AACP,SAASC,gBAAgB,QAAQ;AACjC,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,QAAQ;AAC5C,SAASC,aAAa,QAAQ;AAM9B,OAAO;AAEP,SAASC,eAAe,QAAQ;AAEhC,MAAMC,SAAA,GAAY;AAElB,MAAMC,iBAAA,GAIDC,KAAA;EACH,MAAM;IACJC,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AACC,OAAA,EACPC,IAAI,CAAC;EAER,MAAMC,iBAAA,GAAoB,GAAG1B,IAAA,IAAQK,SAAA,EAAW;EAEhD,MAAMsB,YAAA,GAAe7C,WAAA,CAClB8C,WAAA;IACCV,QAAA,CAASU,WAAA,CAAYC,MAAM;EAC7B,GACA,CAACX,QAAA,CAAS;EAGZ,MAAMY,MAAA,GAAS/C,OAAA,CAAQ,MAAMH,gBAAA,CAAiBU,KAAA,GAAQ,CAACA,KAAA,CAAM;EAE7D,oBACEyC,KAAA,CAAC;IAAItC,SAAA,EAAW4B,OAAA;IAAiCW,KAAA,EAAOF,MAAA;4BACtDG,IAAA,CAACxD,qBAAA;MACCyD,eAAA,EAAiBrB,KAAA;MACjBsB,QAAA,eAAUF,IAAA,CAAC1D,UAAA;QAAWyB,IAAA,EAAMA,IAAA;QAAMmB,SAAA,EAAWA;;QAE9CL,KAAA,iBAASmB,IAAA,CAACzD,UAAA;MAAWqB,KAAA,EAAOA,KAAA;MAAOC,SAAA,EAAWA,SAAA;
|
|
1
|
+
{"version":3,"file":"Field.js","names":["FieldDescription","FieldError","FieldLabel","RenderCustomComponent","useEditDepth","useField","mergeFieldStyles","React","useCallback","useMemo","ErrorBoundary","LexicalProvider","baseClass","RichTextComponent","props","editorConfig","field","name","admin","className","description","readOnly","readOnlyFromAdmin","label","localized","required","path","pathFromProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","editDepth","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","formInitializing","formProcessing","initialValue","setValue","showError","disabled","classes","hideGutter","filter","Boolean","join","pathWithEditDepth","handleChange","editorState","toJSON","styles","_jsxs","style","_jsx","CustomComponent","Fallback","fallbackRender","onReset","composerKey","fieldProps","onChange","JSON","stringify","error","role","color","message","RichText"],"sources":["../../src/field/Field.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\nimport type { Validate } from 'payload'\n\nimport {\n FieldDescription,\n FieldError,\n FieldLabel,\n RenderCustomComponent,\n useEditDepth,\n useField,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport React, { useCallback, useMemo } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\n\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport '../lexical/theme/EditorTheme.scss'\nimport './bundled.css'\nimport './index.scss'\nimport { LexicalProvider } from '../lexical/LexicalProvider.js'\n\nconst baseClass = 'rich-text-lexical'\n\nconst RichTextComponent: React.FC<\n {\n readonly editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n } & LexicalRichTextFieldProps\n> = (props) => {\n const {\n editorConfig,\n field,\n field: {\n name,\n admin: { className, description, readOnly: readOnlyFromAdmin } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly: readOnlyFromTopLevelProps,\n validate, // Users can pass in client side validation if they WANT to, but it's not required anymore\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n const path = pathFromProps ?? name\n\n const editDepth = useEditDepth()\n\n const memoizedValidate = useCallback<Validate>(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return validate(value, { ...validationOptions, required })\n }\n return true\n },\n // Important: do not add props to the dependencies array.\n // This would cause an infinite loop and endless re-rendering.\n // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n formInitializing,\n formProcessing,\n initialValue,\n setValue,\n showError,\n value,\n } = useField<SerializedEditorState>({\n path,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || formProcessing || formInitializing\n\n const classes = [\n baseClass,\n 'field-type',\n className,\n showError && 'error',\n disabled && `${baseClass}--read-only`,\n editorConfig?.admin?.hideGutter !== true ? `${baseClass}--show-gutter` : null,\n ]\n .filter(Boolean)\n .join(' ')\n\n const pathWithEditDepth = `${path}.${editDepth}`\n\n const handleChange = useCallback(\n (editorState: EditorState) => {\n setValue(editorState.toJSON())\n },\n [setValue],\n )\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n return (\n <div className={classes} key={pathWithEditDepth} style={styles}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {Label || <FieldLabel label={label} localized={localized} path={path} required={required} />}\n <div className={`${baseClass}__wrap`}>\n <ErrorBoundary fallbackRender={fallbackRender} onReset={() => {}}>\n {BeforeInput}\n <LexicalProvider\n composerKey={pathWithEditDepth}\n editorConfig={editorConfig}\n fieldProps={props}\n key={JSON.stringify({ initialValue, path })} // makes sure lexical is completely re-rendered when initialValue changes, bypassing the lexical-internal value memoization. That way, external changes to the form will update the editor. More infos in PR description (https://github.com/payloadcms/payload/pull/5010)\n onChange={handleChange}\n readOnly={disabled}\n value={value}\n />\n {AfterInput}\n </ErrorBoundary>\n {Description}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n\nfunction fallbackRender({ error }: { error: Error }) {\n // Call resetErrorBoundary() to reset the error boundary and retry the render.\n\n return (\n <div className=\"errorBoundary\" role=\"alert\">\n <p>Something went wrong:</p>\n <pre style={{ color: 'red' }}>{error.message}</pre>\n </div>\n )\n}\n\nexport const RichText: typeof RichTextComponent = RichTextComponent\n"],"mappings":"AAAA;;;AAIA,SACEA,gBAAgB,EAChBC,UAAU,EACVC,UAAU,EACVC,qBAAqB,EACrBC,YAAY,EACZC,QAAQ,QACH;AACP,SAASC,gBAAgB,QAAQ;AACjC,OAAOC,KAAA,IAASC,WAAW,EAAEC,OAAO,QAAQ;AAC5C,SAASC,aAAa,QAAQ;AAM9B,OAAO;AAEP,SAASC,eAAe,QAAQ;AAEhC,MAAMC,SAAA,GAAY;AAElB,MAAMC,iBAAA,GAIDC,K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