@payloadcms/richtext-lexical 3.0.0-beta.73 → 3.0.0-beta.75
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-5GGTGCKC.js +2 -0
- package/dist/exports/client/Field-5GGTGCKC.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/index.js +7 -7
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blockquote/feature.server.d.ts.map +1 -1
- package/dist/features/blockquote/feature.server.js +5 -2
- package/dist/features/blockquote/feature.server.js.map +1 -1
- package/dist/features/blocks/validate.d.ts.map +1 -1
- package/dist/features/blocks/validate.js +2 -1
- package/dist/features/blocks/validate.js.map +1 -1
- package/dist/features/converters/html/converter/converters/paragraph.d.ts.map +1 -1
- package/dist/features/converters/html/converter/converters/paragraph.js +5 -2
- package/dist/features/converters/html/converter/converters/paragraph.js.map +1 -1
- package/dist/features/converters/html/converter/index.d.ts +8 -2
- package/dist/features/converters/html/converter/index.d.ts.map +1 -1
- package/dist/features/converters/html/converter/index.js +14 -5
- package/dist/features/converters/html/converter/index.js.map +1 -1
- package/dist/features/converters/html/converter/types.d.ts +5 -2
- package/dist/features/converters/html/converter/types.d.ts.map +1 -1
- package/dist/features/converters/html/converter/types.js.map +1 -1
- package/dist/features/converters/html/feature.server.d.ts +2 -2
- package/dist/features/converters/html/feature.server.d.ts.map +1 -1
- package/dist/features/converters/html/feature.server.js.map +1 -1
- package/dist/features/converters/html/field/index.d.ts.map +1 -1
- package/dist/features/converters/html/field/index.js +5 -2
- package/dist/features/converters/html/field/index.js.map +1 -1
- package/dist/features/experimental_table/feature.client.d.ts.map +1 -1
- package/dist/features/experimental_table/feature.client.js +5 -0
- package/dist/features/experimental_table/feature.client.js.map +1 -1
- package/dist/features/experimental_table/feature.server.d.ts +11 -0
- package/dist/features/experimental_table/feature.server.d.ts.map +1 -1
- package/dist/features/experimental_table/feature.server.js +79 -6
- package/dist/features/experimental_table/feature.server.js.map +1 -1
- package/dist/features/experimental_table/plugins/TableActionMenuPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/plugins/TableActionMenuPlugin/index.js +2 -0
- package/dist/features/experimental_table/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/plugins/TableCellResizerPlugin/index.d.ts +0 -1
- package/dist/features/experimental_table/plugins/TableCellResizerPlugin/index.d.ts.map +1 -1
- package/dist/features/experimental_table/plugins/TableCellResizerPlugin/index.js +13 -8
- package/dist/features/experimental_table/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/experimental_table/plugins/TableHoverActionsPlugin/index.d.ts +12 -0
- package/dist/features/experimental_table/plugins/TableHoverActionsPlugin/index.d.ts.map +1 -0
- package/dist/features/experimental_table/plugins/TableHoverActionsPlugin/index.js +181 -0
- package/dist/features/experimental_table/plugins/TableHoverActionsPlugin/index.js.map +1 -0
- package/dist/features/experimental_table/utils/debounce.d.ts +61 -0
- package/dist/features/experimental_table/utils/debounce.d.ts.map +1 -0
- package/dist/features/experimental_table/utils/debounce.js +202 -0
- package/dist/features/experimental_table/utils/debounce.js.map +1 -0
- package/dist/features/experimental_table/utils/useDebounce.d.ts +6 -0
- package/dist/features/experimental_table/utils/useDebounce.d.ts.map +1 -0
- package/dist/features/experimental_table/utils/useDebounce.js +18 -0
- package/dist/features/experimental_table/utils/useDebounce.js.map +1 -0
- package/dist/features/heading/feature.server.d.ts.map +1 -1
- package/dist/features/heading/feature.server.js +5 -2
- package/dist/features/heading/feature.server.js.map +1 -1
- package/dist/features/link/feature.server.d.ts.map +1 -1
- package/dist/features/link/feature.server.js +10 -4
- package/dist/features/link/feature.server.js.map +1 -1
- package/dist/features/link/plugins/autoLink/index.d.ts.map +1 -1
- package/dist/features/link/plugins/autoLink/index.js +19 -6
- package/dist/features/link/plugins/autoLink/index.js.map +1 -1
- package/dist/features/link/validate.d.ts.map +1 -1
- package/dist/features/link/validate.js +2 -1
- package/dist/features/link/validate.js.map +1 -1
- package/dist/features/lists/htmlConverter.d.ts.map +1 -1
- package/dist/features/lists/htmlConverter.js +10 -4
- package/dist/features/lists/htmlConverter.js.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/index.d.ts.map +1 -1
- package/dist/features/migrations/slateToLexical/converter/index.js +1 -0
- package/dist/features/migrations/slateToLexical/converter/index.js.map +1 -1
- package/dist/features/typesServer.d.ts +2 -1
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/feature.server.js +4 -4
- package/dist/features/upload/feature.server.js.map +1 -1
- package/dist/features/upload/validate.d.ts.map +1 -1
- package/dist/features/upload/validate.js +1 -0
- package/dist/features/upload/validate.js.map +1 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +8 -7
- package/dist/field/Field.js.map +1 -1
- package/dist/field/index.js +8 -8
- package/dist/lexical/LexicalEditor.d.ts.map +1 -1
- package/dist/lexical/LexicalEditor.js +0 -6
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
- package/dist/lexical/ui/ContentEditable.js +8 -1
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/lexical/ui/icons/Table/index.d.ts.map +1 -1
- package/dist/lexical/ui/icons/Table/index.js +1 -0
- package/dist/lexical/ui/icons/Table/index.js.map +1 -1
- package/dist/lexical/ui/icons/Upload/index.js +1 -1
- package/dist/lexical/ui/icons/Upload/index.js.map +1 -1
- package/dist/nodeTypes.d.ts +3 -1
- package/dist/nodeTypes.d.ts.map +1 -1
- package/dist/nodeTypes.js.map +1 -1
- package/dist/populateGraphQL/defaultValue.d.ts.map +1 -1
- package/dist/populateGraphQL/defaultValue.js +1 -0
- package/dist/populateGraphQL/defaultValue.js.map +1 -1
- package/dist/utilities/generateComponentMap.d.ts.map +1 -1
- package/dist/utilities/generateComponentMap.js +3 -1
- package/dist/utilities/generateComponentMap.js.map +1 -1
- package/package.json +33 -33
- package/dist/exports/client/Field-YNHIDK3D.js +0 -2
- package/dist/exports/client/Field-YNHIDK3D.js.map +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/link/feature.server.ts"],"sourcesContent":["import type { CollectionSlug, Config, Field, FieldAffectingData, SanitizedConfig } from 'payload'\n\nimport { sanitizeFields } from 'payload'\nimport { deepCopyObject } from 'payload/shared'\n\nimport type { ClientProps } from './feature.client.js'\n\n// eslint-disable-next-line payload/no-imports-from-exports-dir\nimport { LinkFeatureClient } from '../../exports/client/index.js'\nimport { createServerFeature } from '../../utilities/createServerFeature.js'\nimport { convertLexicalNodesToHTML } from '../converters/html/converter/index.js'\nimport { createNode } from '../typeUtilities.js'\nimport { linkPopulationPromiseHOC } from './graphQLPopulationPromise.js'\nimport { i18n } from './i18n.js'\nimport { LinkMarkdownTransformer } from './markdownTransformer.js'\nimport { AutoLinkNode } from './nodes/AutoLinkNode.js'\nimport { LinkNode } from './nodes/LinkNode.js'\nimport { transformExtraFields } from './plugins/floatingLinkEditor/utilities.js'\nimport { linkValidation } from './validate.js'\n\nexport type ExclusiveLinkCollectionsProps =\n | {\n /**\n * The collections that should be disabled for internal linking. Overrides the `enableRichTextLink` property in the collection config.\n * When this property is set, `enabledCollections` will not be available.\n **/\n disabledCollections?: CollectionSlug[]\n\n // Ensures that enabledCollections is not available when disabledCollections is set\n enabledCollections?: never\n }\n | {\n // Ensures that disabledCollections is not available when enabledCollections is set\n disabledCollections?: never\n\n /**\n * The collections that should be enabled for internal linking. Overrides the `enableRichTextLink` property in the collection config\n * When this property is set, `disabledCollections` will not be available.\n **/\n enabledCollections?: CollectionSlug[]\n }\n\nexport type LinkFeatureServerProps = {\n /**\n * A function or array defining additional fields for the link feature. These will be\n * displayed in the link editor drawer.\n */\n fields?:\n | ((args: {\n config: SanitizedConfig\n defaultFields: FieldAffectingData[]\n }) => (Field | FieldAffectingData)[])\n | Field[]\n /**\n * Sets a maximum population depth for the internal doc default field of link, regardless of the remaining depth when the field is reached.\n * This behaves exactly like the maxDepth properties of relationship and upload fields.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n} & ExclusiveLinkCollectionsProps\n\nexport const LinkFeature = createServerFeature<\n LinkFeatureServerProps,\n LinkFeatureServerProps,\n ClientProps\n>({\n feature: async ({ config: _config, isRoot, props }) => {\n if (!props) {\n props = {}\n }\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n const _transformedFields = transformExtraFields(\n deepCopyObject(props.fields),\n _config,\n props.enabledCollections,\n props.disabledCollections,\n props.maxDepth,\n )\n\n const sanitizedFields = await sanitizeFields({\n config: _config as unknown as Config,\n fields: _transformedFields,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n props.fields = sanitizedFields\n\n // the text field is not included in the node data.\n // Thus, for tasks like validation, we do not want to pass it a text field in the schema which will never have data.\n // Otherwise, it will cause a validation error (field is required).\n const sanitizedFieldsWithoutText = deepCopyObject(sanitizedFields).filter(\n (field) => !('name' in field) || field.name !== 'text',\n )\n\n return {\n ClientFeature: LinkFeatureClient,\n clientFeatureProps: {\n disabledCollections: props.disabledCollections,\n enabledCollections: props.enabledCollections,\n } as ExclusiveLinkCollectionsProps,\n generateSchemaMap: () => {\n if (!sanitizedFields || !Array.isArray(sanitizedFields) || sanitizedFields.length === 0) {\n return null\n }\n\n const schemaMap = new Map<string, Field[]>()\n schemaMap.set('fields', sanitizedFields)\n\n return schemaMap\n },\n i18n,\n markdownTransformers: [LinkMarkdownTransformer],\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({ converters, node, parent, req }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n req,\n })\n\n const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n const target: string = node.fields.newTab ? ' target=\"_blank\"' : ''\n\n let href: string = node.fields.url\n if (node.fields.linkType === 'internal') {\n href =\n typeof node.fields.doc?.value === 'string'\n ? node.fields.doc?.value\n : node.fields.doc?.value?.id\n }\n\n return `<a href=\"${href}\"${target}${rel}>${childrenText}</a>`\n },\n nodeTypes: [AutoLinkNode.getType()],\n },\n },\n node: AutoLinkNode,\n // Since AutoLinkNodes are just internal links, they need no hooks or graphQL population promises\n validations: [linkValidation(props, sanitizedFieldsWithoutText)],\n }),\n createNode({\n converters: {\n html: {\n converter: async ({ converters, node, parent, req }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n req,\n })\n\n const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n const target: string = node.fields.newTab ? ' target=\"_blank\"' : ''\n\n const href: string =\n node.fields.linkType === 'custom'\n ? node.fields.url\n : (node.fields.doc?.value as string)\n\n return `<a href=\"${href}\"${target}${rel}>${childrenText}</a>`\n },\n nodeTypes: [LinkNode.getType()],\n },\n },\n getSubFields: () => {\n return sanitizedFieldsWithoutText\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [linkPopulationPromiseHOC(props)],\n node: LinkNode,\n validations: [linkValidation(props, sanitizedFieldsWithoutText)],\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'link',\n})\n"],"names":["sanitizeFields","deepCopyObject","LinkFeatureClient","createServerFeature","convertLexicalNodesToHTML","createNode","linkPopulationPromiseHOC","i18n","LinkMarkdownTransformer","AutoLinkNode","LinkNode","transformExtraFields","linkValidation","LinkFeature","feature","config","_config","isRoot","props","validRelationships","collections","map","c","slug","_transformedFields","fields","enabledCollections","disabledCollections","maxDepth","sanitizedFields","requireFieldLevelRichTextEditor","sanitizedFieldsWithoutText","filter","field","name","ClientFeature","clientFeatureProps","generateSchemaMap","Array","isArray","length","schemaMap","Map","set","markdownTransformers","nodes","converters","html","converter","node","parent","req","childrenText","lexicalNodes","children","rel","newTab","target","href","url","linkType","doc","value","id","nodeTypes","getType","validations","getSubFields","getSubFieldsData","graphQLPopulationPromises","sanitizedServerFeatureProps","key"],"mappings":"AAEA,SAASA,cAAc,QAAQ,UAAS;AACxC,SAASC,cAAc,QAAQ,iBAAgB;AAI/C,+DAA+D;AAC/D,SAASC,iBAAiB,QAAQ,gCAA+B;AACjE,SAASC,mBAAmB,QAAQ,yCAAwC;AAC5E,SAASC,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,UAAU,QAAQ,sBAAqB;AAChD,SAASC,wBAAwB,QAAQ,gCAA+B;AACxE,SAASC,IAAI,QAAQ,YAAW;AAChC,SAASC,uBAAuB,QAAQ,2BAA0B;AAClE,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,QAAQ,QAAQ,sBAAqB;AAC9C,SAASC,oBAAoB,QAAQ,4CAA2C;AAChF,SAASC,cAAc,QAAQ,gBAAe;AA4C9C,OAAO,MAAMC,cAAcV,oBAIzB;IACAW,SAAS,OAAO,EAAEC,QAAQC,OAAO,EAAEC,MAAM,EAAEC,KAAK,EAAE;QAChD,IAAI,CAACA,OAAO;YACVA,QAAQ,CAAC;QACX;QACA,MAAMC,qBAAqBH,QAAQI,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;QAEvE,MAAMC,qBAAqBb,qBACzBV,eAAeiB,MAAMO,MAAM,GAC3BT,SACAE,MAAMQ,kBAAkB,EACxBR,MAAMS,mBAAmB,EACzBT,MAAMU,QAAQ;QAGhB,MAAMC,kBAAkB,MAAM7B,eAAe;YAC3Ce,QAAQC;YACRS,QAAQD;YACRM,iCAAiCb;YACjCE;QACF;QACAD,MAAMO,MAAM,GAAGI;QAEf,mDAAmD;QACnD,oHAAoH;QACpH,mEAAmE;QACnE,MAAME,6BAA6B9B,eAAe4B,iBAAiBG,MAAM,CACvE,CAACC,QAAU,CAAE,CAAA,UAAUA,KAAI,KAAMA,MAAMC,IAAI,KAAK;QAGlD,OAAO;YACLC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;wBAACtD,eAAeM,OAAOa;qBAA4B;gBAClE;gBACA1B,WAAW;oBACTyC,YAAY;wBACVC,MAAM;4BACJC,WAAW,OAAO,EAAEF,UAAU,EAAEG,IAAI,EAAEC,MAAM,EAAEC,GAAG,EAAE;gCACjD,MAAMC,eAAe,MAAMhD,0BAA0B;oCACnD0C;oCACAO,cAAcJ,KAAKK,QAAQ;oCAC3BJ,QAAQ;wCACN,GAAGD,IAAI;wCACPC;oCACF;oCACAC;gCACF;gCAEA,MAAMI,MAAcN,KAAKxB,MAAM,CAAC+B,MAAM,GAAG,+BAA+B;gCACxE,MAAMC,SAAiBR,KAAKxB,MAAM,CAAC+B,MAAM,GAAG,qBAAqB;gCAEjE,MAAME,OACJT,KAAKxB,MAAM,CAACmC,QAAQ,KAAK,WACrBX,KAAKxB,MAAM,CAACkC,GAAG,GACdV,KAAKxB,MAAM,CAACoC,GAAG,EAAEC;gCAExB,OAAO,CAAC,SAAS,EAAEJ,KAAK,CAAC,EAAED,OAAO,EAAEF,IAAI,CAAC,EAAEH,aAAa,IAAI,CAAC;4BAC/D;4BACAY,WAAW;gCAACtD,SAASuD,OAAO;6BAAG;wBACjC;oBACF;oBACAE,cAAc;wBACZ,OAAOpC;oBACT;oBACAqC,kBAAkB,CAAC,EAAEnB,IAAI,EAAE;wBACzB,OAAOA,MAAMxB;oBACf;oBACA4C,2BAA2B;wBAAC/D,yBAAyBY;qBAAO;oBAC5D+B,MAAMvC;oBACNwD,aAAa;wBAACtD,eAAeM,OAAOa;qBAA4B;gBAClE;aACD;YACDuC,6BAA6BpD;QAC/B;IACF;IACAqD,KAAK;AACP,GAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/features/link/feature.server.ts"],"sourcesContent":["import type { CollectionSlug, Config, Field, FieldAffectingData, SanitizedConfig } from 'payload'\n\nimport { sanitizeFields } from 'payload'\nimport { deepCopyObject } from 'payload/shared'\n\nimport type { ClientProps } from './feature.client.js'\n\n// eslint-disable-next-line payload/no-imports-from-exports-dir\nimport { LinkFeatureClient } from '../../exports/client/index.js'\nimport { createServerFeature } from '../../utilities/createServerFeature.js'\nimport { convertLexicalNodesToHTML } from '../converters/html/converter/index.js'\nimport { createNode } from '../typeUtilities.js'\nimport { linkPopulationPromiseHOC } from './graphQLPopulationPromise.js'\nimport { i18n } from './i18n.js'\nimport { LinkMarkdownTransformer } from './markdownTransformer.js'\nimport { AutoLinkNode } from './nodes/AutoLinkNode.js'\nimport { LinkNode } from './nodes/LinkNode.js'\nimport { transformExtraFields } from './plugins/floatingLinkEditor/utilities.js'\nimport { linkValidation } from './validate.js'\n\nexport type ExclusiveLinkCollectionsProps =\n | {\n /**\n * The collections that should be disabled for internal linking. Overrides the `enableRichTextLink` property in the collection config.\n * When this property is set, `enabledCollections` will not be available.\n **/\n disabledCollections?: CollectionSlug[]\n\n // Ensures that enabledCollections is not available when disabledCollections is set\n enabledCollections?: never\n }\n | {\n // Ensures that disabledCollections is not available when enabledCollections is set\n disabledCollections?: never\n\n /**\n * The collections that should be enabled for internal linking. Overrides the `enableRichTextLink` property in the collection config\n * When this property is set, `disabledCollections` will not be available.\n **/\n enabledCollections?: CollectionSlug[]\n }\n\nexport type LinkFeatureServerProps = {\n /**\n * A function or array defining additional fields for the link feature. These will be\n * displayed in the link editor drawer.\n */\n fields?:\n | ((args: {\n config: SanitizedConfig\n defaultFields: FieldAffectingData[]\n }) => (Field | FieldAffectingData)[])\n | Field[]\n /**\n * Sets a maximum population depth for the internal doc default field of link, regardless of the remaining depth when the field is reached.\n * This behaves exactly like the maxDepth properties of relationship and upload fields.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n} & ExclusiveLinkCollectionsProps\n\nexport const LinkFeature = createServerFeature<\n LinkFeatureServerProps,\n LinkFeatureServerProps,\n ClientProps\n>({\n feature: async ({ config: _config, isRoot, props }) => {\n if (!props) {\n props = {}\n }\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n const _transformedFields = transformExtraFields(\n deepCopyObject(props.fields),\n _config,\n props.enabledCollections,\n props.disabledCollections,\n props.maxDepth,\n )\n\n const sanitizedFields = await sanitizeFields({\n config: _config as unknown as Config,\n fields: _transformedFields,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n props.fields = sanitizedFields\n\n // the text field is not included in the node data.\n // Thus, for tasks like validation, we do not want to pass it a text field in the schema which will never have data.\n // Otherwise, it will cause a validation error (field is required).\n const sanitizedFieldsWithoutText = deepCopyObject(sanitizedFields).filter(\n (field) => !('name' in field) || field.name !== 'text',\n )\n\n return {\n ClientFeature: LinkFeatureClient,\n clientFeatureProps: {\n disabledCollections: props.disabledCollections,\n enabledCollections: props.enabledCollections,\n } as ExclusiveLinkCollectionsProps,\n generateSchemaMap: () => {\n if (!sanitizedFields || !Array.isArray(sanitizedFields) || sanitizedFields.length === 0) {\n return null\n }\n\n const schemaMap = new Map<string, Field[]>()\n schemaMap.set('fields', sanitizedFields)\n\n return schemaMap\n },\n i18n,\n markdownTransformers: [LinkMarkdownTransformer],\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({\n converters,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n\n const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n const target: string = node.fields.newTab ? ' target=\"_blank\"' : ''\n\n let href: string = node.fields.url\n if (node.fields.linkType === 'internal') {\n href =\n typeof node.fields.doc?.value === 'string'\n ? node.fields.doc?.value\n : node.fields.doc?.value?.id\n }\n\n return `<a href=\"${href}\"${target}${rel}>${childrenText}</a>`\n },\n nodeTypes: [AutoLinkNode.getType()],\n },\n },\n node: AutoLinkNode,\n // Since AutoLinkNodes are just internal links, they need no hooks or graphQL population promises\n validations: [linkValidation(props, sanitizedFieldsWithoutText)],\n }),\n createNode({\n converters: {\n html: {\n converter: async ({\n converters,\n draft,\n node,\n overrideAccess,\n parent,\n req,\n showHiddenFields,\n }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n\n const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n const target: string = node.fields.newTab ? ' target=\"_blank\"' : ''\n\n const href: string =\n node.fields.linkType === 'custom'\n ? node.fields.url\n : (node.fields.doc?.value as string)\n\n return `<a href=\"${href}\"${target}${rel}>${childrenText}</a>`\n },\n nodeTypes: [LinkNode.getType()],\n },\n },\n getSubFields: () => {\n return sanitizedFieldsWithoutText\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [linkPopulationPromiseHOC(props)],\n node: LinkNode,\n validations: [linkValidation(props, sanitizedFieldsWithoutText)],\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'link',\n})\n"],"names":["sanitizeFields","deepCopyObject","LinkFeatureClient","createServerFeature","convertLexicalNodesToHTML","createNode","linkPopulationPromiseHOC","i18n","LinkMarkdownTransformer","AutoLinkNode","LinkNode","transformExtraFields","linkValidation","LinkFeature","feature","config","_config","isRoot","props","validRelationships","collections","map","c","slug","_transformedFields","fields","enabledCollections","disabledCollections","maxDepth","sanitizedFields","requireFieldLevelRichTextEditor","sanitizedFieldsWithoutText","filter","field","name","ClientFeature","clientFeatureProps","generateSchemaMap","Array","isArray","length","schemaMap","Map","set","markdownTransformers","nodes","converters","html","converter","draft","node","overrideAccess","parent","req","showHiddenFields","childrenText","lexicalNodes","children","rel","newTab","target","href","url","linkType","doc","value","id","nodeTypes","getType","validations","getSubFields","getSubFieldsData","graphQLPopulationPromises","sanitizedServerFeatureProps","key"],"mappings":"AAEA,SAASA,cAAc,QAAQ,UAAS;AACxC,SAASC,cAAc,QAAQ,iBAAgB;AAI/C,+DAA+D;A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ACVG,KAAK,EACLC,IAAI,EACJC,cAAc,EACdC,MAAM,EACNC,GAAG,EACHC,gBAAgB,EACjB;gCACC,MAAMC,eAAe,MAAMnD,0BAA0B;oCACnD0C;oCACAG;oCACAO,cAAcN,KAAKO,QAAQ;oCAC3BN;oCACAC,QAAQ;wCACN,GAAGF,IAAI;wCACPE;oCACF;oCACAC;oCACAC;gCACF;gCAEA,MAAMI,MAAcR,KAAKzB,MAAM,CAACkC,MAAM,GAAG,+BAA+B;gCACxE,MAAMC,SAAiBV,KAAKzB,MAAM,CAACkC,MAAM,GAAG,qBAAqB;gCAEjE,MAAME,OACJX,KAAKzB,MAAM,CAACsC,QAAQ,KAAK,WACrBb,KAAKzB,MAAM,CAACqC,GAAG,GACdZ,KAAKzB,MAAM,CAACuC,GAAG,EAAEC;gCAExB,OAAO,CAAC,SAAS,EAAEJ,KAAK,CAAC,EAAED,OAAO,EAAEF,IAAI,CAAC,EAAEH,aAAa,IAAI,CAAC;4BAC/D;4BACAY,WAAW;gCAACzD,SAAS0D,OAAO;6BAAG;wBACjC;oBACF;oBACAE,cAAc;wBACZ,OAAOvC;oBACT;oBACAwC,kBAAkB,CAAC,EAAErB,IAAI,EAAE;wBACzB,OAAOA,MAAMzB;oBACf;oBACA+C,2BAA2B;wBAAClE,yBAAyBY;qBAAO;oBAC5DgC,MAAMxC;oBACN2D,aAAa;wBAACzD,eAAeM,OAAOa;qBAA4B;gBAClE;aACD;YACD0C,6BAA6BvD;QAC/B;IACF;IACAwD,KAAK;AACP,GAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/link/plugins/autoLink/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAQtD,UAAU,iBAAiB;IACzB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,iBAAiB,GAAG,IAAI,CAAA;AAEpE,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,cAAc,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAuB,UAE3C,MAAM;;;;;EAUrB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/link/plugins/autoLink/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAQtD,UAAU,iBAAiB;IACzB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,iBAAiB,GAAG,IAAI,CAAA;AAEpE,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,cAAc,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAuB,UAE3C,MAAM;;;;;EAUrB;AAkZD,eAAO,MAAM,cAAc,EAAE,eAAe,CAAC,WAAW,CAMvD,CAAA"}
|
|
@@ -37,8 +37,18 @@ function endsWithSeparator(textContent) {
|
|
|
37
37
|
function startsWithSeparator(textContent) {
|
|
38
38
|
return isSeparator(textContent[0]);
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Check if the text content starts with a fullstop followed by a top-level domain.
|
|
42
|
+
* Meaning if the text content can be a beginning of a top level domain.
|
|
43
|
+
* @param textContent
|
|
44
|
+
* @param isEmail
|
|
45
|
+
* @returns boolean
|
|
46
|
+
*/ function startsWithTLD(textContent, isEmail) {
|
|
47
|
+
if (isEmail) {
|
|
48
|
+
return /^\.[a-z]{2,}/i.test(textContent);
|
|
49
|
+
} else {
|
|
50
|
+
return /^\.[a-z0-9]+/i.test(textContent);
|
|
51
|
+
}
|
|
42
52
|
}
|
|
43
53
|
function isPreviousNodeValid(node) {
|
|
44
54
|
let previousNode = node.getPreviousSibling();
|
|
@@ -238,10 +248,13 @@ function handleBadNeighbors(textNode, matchers, onChange) {
|
|
|
238
248
|
const previousSibling = textNode.getPreviousSibling();
|
|
239
249
|
const nextSibling = textNode.getNextSibling();
|
|
240
250
|
const text = textNode.getTextContent();
|
|
241
|
-
if ($isAutoLinkNode(previousSibling)
|
|
242
|
-
previousSibling.
|
|
243
|
-
|
|
244
|
-
|
|
251
|
+
if ($isAutoLinkNode(previousSibling)) {
|
|
252
|
+
const isEmailURI = previousSibling.getFields()?.url ? previousSibling.getFields()?.url?.startsWith('mailto:') : false;
|
|
253
|
+
if (!startsWithSeparator(text) || startsWithTLD(text, isEmailURI)) {
|
|
254
|
+
previousSibling.append(textNode);
|
|
255
|
+
handleLinkEdit(previousSibling, matchers, onChange);
|
|
256
|
+
onChange(null, previousSibling.getFields()?.url ?? null);
|
|
257
|
+
}
|
|
245
258
|
}
|
|
246
259
|
if ($isAutoLinkNode(nextSibling) && !endsWithSeparator(text)) {
|
|
247
260
|
replaceWithChildren(nextSibling);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/features/link/plugins/autoLink/index.tsx"],"sourcesContent":["'use client'\nimport type { ElementNode, LexicalEditor, LexicalNode, TextNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $createTextNode,\n $getSelection,\n $isElementNode,\n $isLineBreakNode,\n $isNodeSelection,\n $isRangeSelection,\n $isTextNode,\n TextNode as TextNodeValue,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { ClientProps } from '../../feature.client.js'\nimport type { LinkFields } from '../../nodes/types.js'\n\nimport { invariant } from '../../../../lexical/utils/invariant.js'\nimport { $createAutoLinkNode, $isAutoLinkNode, AutoLinkNode } from '../../nodes/AutoLinkNode.js'\nimport { $isLinkNode } from '../../nodes/LinkNode.js'\n\ntype ChangeHandler = (url: null | string, prevUrl: null | string) => void\n\ninterface LinkMatcherResult {\n fields?: LinkFields\n index: number\n length: number\n text: string\n url: string\n}\n\nexport type LinkMatcher = (text: string) => LinkMatcherResult | null\n\nexport function createLinkMatcherWithRegExp(\n regExp: RegExp,\n urlTransformer: (text: string) => string = (text) => text,\n) {\n return (text: string) => {\n const match = regExp.exec(text)\n if (match === null) return null\n return {\n index: match.index,\n length: match[0].length,\n text: match[0],\n url: urlTransformer(match[0]),\n }\n }\n}\n\nfunction findFirstMatch(text: string, matchers: LinkMatcher[]): LinkMatcherResult | null {\n for (let i = 0; i < matchers.length; i++) {\n const match = matchers[i](text)\n\n if (match != null) {\n return match\n }\n }\n\n return null\n}\n\nconst PUNCTUATION_OR_SPACE = /[.,;\\s]/\n\nfunction isSeparator(char: string): boolean {\n return PUNCTUATION_OR_SPACE.test(char)\n}\n\nfunction endsWithSeparator(textContent: string): boolean {\n return isSeparator(textContent[textContent.length - 1])\n}\n\nfunction startsWithSeparator(textContent: string): boolean {\n return isSeparator(textContent[0])\n}\n\nfunction startsWithFullStop(textContent: string): boolean {\n return /^\\.[a-z\\d]+/i.test(textContent)\n}\n\nfunction isPreviousNodeValid(node: LexicalNode): boolean {\n let previousNode = node.getPreviousSibling()\n if ($isElementNode(previousNode)) {\n previousNode = previousNode.getLastDescendant()\n }\n return (\n previousNode === null ||\n $isLineBreakNode(previousNode) ||\n ($isTextNode(previousNode) && endsWithSeparator(previousNode.getTextContent()))\n )\n}\n\nfunction isNextNodeValid(node: LexicalNode): boolean {\n let nextNode = node.getNextSibling()\n if ($isElementNode(nextNode)) {\n nextNode = nextNode.getFirstDescendant()\n }\n return (\n nextNode === null ||\n $isLineBreakNode(nextNode) ||\n ($isTextNode(nextNode) && startsWithSeparator(nextNode.getTextContent()))\n )\n}\n\nfunction isContentAroundIsValid(\n matchStart: number,\n matchEnd: number,\n text: string,\n nodes: TextNode[],\n): boolean {\n const contentBeforeIsValid =\n matchStart > 0 ? isSeparator(text[matchStart - 1]) : isPreviousNodeValid(nodes[0])\n if (!contentBeforeIsValid) {\n return false\n }\n\n const contentAfterIsValid =\n matchEnd < text.length ? isSeparator(text[matchEnd]) : isNextNodeValid(nodes[nodes.length - 1])\n return contentAfterIsValid\n}\n\nfunction extractMatchingNodes(\n nodes: TextNode[],\n startIndex: number,\n endIndex: number,\n): [\n matchingOffset: number,\n unmodifiedBeforeNodes: TextNode[],\n matchingNodes: TextNode[],\n unmodifiedAfterNodes: TextNode[],\n] {\n const unmodifiedBeforeNodes: TextNode[] = []\n const matchingNodes: TextNode[] = []\n const unmodifiedAfterNodes: TextNode[] = []\n let matchingOffset = 0\n\n let currentOffset = 0\n const currentNodes = [...nodes]\n\n while (currentNodes.length > 0) {\n const currentNode = currentNodes[0]\n const currentNodeText = currentNode.getTextContent()\n const currentNodeLength = currentNodeText.length\n const currentNodeStart = currentOffset\n const currentNodeEnd = currentOffset + currentNodeLength\n\n if (currentNodeEnd <= startIndex) {\n unmodifiedBeforeNodes.push(currentNode)\n matchingOffset += currentNodeLength\n } else if (currentNodeStart >= endIndex) {\n unmodifiedAfterNodes.push(currentNode)\n } else {\n matchingNodes.push(currentNode)\n }\n currentOffset += currentNodeLength\n currentNodes.shift()\n }\n return [matchingOffset, unmodifiedBeforeNodes, matchingNodes, unmodifiedAfterNodes]\n}\n\nfunction $createAutoLinkNode_(\n nodes: TextNode[],\n startIndex: number,\n endIndex: number,\n match: LinkMatcherResult,\n): TextNode | undefined {\n const fields: LinkFields = {\n linkType: 'custom',\n url: match.url,\n ...match.fields,\n }\n\n const linkNode = $createAutoLinkNode({ fields })\n if (nodes.length === 1) {\n let remainingTextNode = nodes[0]\n let linkTextNode\n if (startIndex === 0) {\n ;[linkTextNode, remainingTextNode] = remainingTextNode.splitText(endIndex)\n } else {\n ;[, linkTextNode, remainingTextNode] = remainingTextNode.splitText(startIndex, endIndex)\n }\n const textNode = $createTextNode(match.text)\n textNode.setFormat(linkTextNode.getFormat())\n textNode.setDetail(linkTextNode.getDetail())\n textNode.setStyle(linkTextNode.getStyle())\n linkNode.append(textNode)\n linkTextNode.replace(linkNode)\n return remainingTextNode\n } else if (nodes.length > 1) {\n const firstTextNode = nodes[0]\n let offset = firstTextNode.getTextContent().length\n let firstLinkTextNode\n if (startIndex === 0) {\n firstLinkTextNode = firstTextNode\n } else {\n ;[, firstLinkTextNode] = firstTextNode.splitText(startIndex)\n }\n const linkNodes = []\n let remainingTextNode\n for (let i = 1; i < nodes.length; i++) {\n const currentNode = nodes[i]\n const currentNodeText = currentNode.getTextContent()\n const currentNodeLength = currentNodeText.length\n const currentNodeStart = offset\n const currentNodeEnd = offset + currentNodeLength\n if (currentNodeStart < endIndex) {\n if (currentNodeEnd <= endIndex) {\n linkNodes.push(currentNode)\n } else {\n const [linkTextNode, endNode] = currentNode.splitText(endIndex - currentNodeStart)\n linkNodes.push(linkTextNode)\n remainingTextNode = endNode\n }\n }\n offset += currentNodeLength\n }\n const selection = $getSelection()\n const selectedTextNode = selection ? selection.getNodes().find($isTextNode) : undefined\n const textNode = $createTextNode(firstLinkTextNode.getTextContent())\n textNode.setFormat(firstLinkTextNode.getFormat())\n textNode.setDetail(firstLinkTextNode.getDetail())\n textNode.setStyle(firstLinkTextNode.getStyle())\n linkNode.append(textNode, ...linkNodes)\n // it does not preserve caret position if caret was at the first text node\n // so we need to restore caret position\n if (selectedTextNode && selectedTextNode === firstLinkTextNode) {\n if ($isRangeSelection(selection)) {\n textNode.select(selection.anchor.offset, selection.focus.offset)\n } else if ($isNodeSelection(selection)) {\n textNode.select(0, textNode.getTextContent().length)\n }\n }\n firstLinkTextNode.replace(linkNode)\n return remainingTextNode\n }\n return undefined\n}\n\nfunction $handleLinkCreation(\n nodes: TextNode[],\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n let currentNodes = [...nodes]\n const initialText = currentNodes.map((node) => node.getTextContent()).join('')\n let text = initialText\n\n let match\n let invalidMatchEnd = 0\n\n while ((match = findFirstMatch(text, matchers)) != null && match !== null) {\n const matchStart: number = match.index\n const matchLength: number = match.length\n const matchEnd = matchStart + matchLength\n const isValid = isContentAroundIsValid(\n invalidMatchEnd + matchStart,\n invalidMatchEnd + matchEnd,\n initialText,\n currentNodes,\n )\n\n if (isValid) {\n const [matchingOffset, , matchingNodes, unmodifiedAfterNodes] = extractMatchingNodes(\n currentNodes,\n invalidMatchEnd + matchStart,\n invalidMatchEnd + matchEnd,\n )\n\n const actualMatchStart = invalidMatchEnd + matchStart - matchingOffset\n const actualMatchEnd = invalidMatchEnd + matchEnd - matchingOffset\n const remainingTextNode = $createAutoLinkNode_(\n matchingNodes,\n actualMatchStart,\n actualMatchEnd,\n match,\n )\n currentNodes = remainingTextNode\n ? [remainingTextNode, ...unmodifiedAfterNodes]\n : unmodifiedAfterNodes\n onChange(match.url, null)\n invalidMatchEnd = 0\n } else {\n invalidMatchEnd += matchEnd\n }\n\n text = text.substring(matchEnd)\n }\n}\n\nfunction handleLinkEdit(\n linkNode: AutoLinkNode,\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n // Check children are simple text\n const children = linkNode.getChildren()\n const childrenLength = children.length\n for (let i = 0; i < childrenLength; i++) {\n const child = children[i]\n if (!$isTextNode(child) || !child.isSimpleText()) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n }\n\n // Check text content fully matches\n const text = linkNode.getTextContent()\n const match = findFirstMatch(text, matchers)\n if (match === null || match.text !== text) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n\n // Check neighbors\n if (!isPreviousNodeValid(linkNode) || !isNextNodeValid(linkNode)) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n\n const url = linkNode.getFields()?.url\n if (url !== match?.url) {\n const flds = linkNode.getFields()\n flds.url = match?.url\n linkNode.setFields(flds)\n onChange(match.url, url ?? null)\n }\n}\n\n// Bad neighbors are edits in neighbor nodes that make AutoLinks incompatible.\n// Given the creation preconditions, these can only be simple text nodes.\nfunction handleBadNeighbors(\n textNode: TextNode,\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n const previousSibling = textNode.getPreviousSibling()\n const nextSibling = textNode.getNextSibling()\n const text = textNode.getTextContent()\n\n if (\n $isAutoLinkNode(previousSibling) &&\n (!startsWithSeparator(text) || startsWithFullStop(text))\n ) {\n previousSibling.append(textNode)\n handleLinkEdit(previousSibling, matchers, onChange)\n onChange(null, previousSibling.getFields()?.url ?? null)\n }\n\n if ($isAutoLinkNode(nextSibling) && !endsWithSeparator(text)) {\n replaceWithChildren(nextSibling)\n handleLinkEdit(nextSibling, matchers, onChange)\n onChange(null, nextSibling.getFields()?.url ?? null)\n }\n}\n\nfunction replaceWithChildren(node: ElementNode): LexicalNode[] {\n const children = node.getChildren()\n const childrenLength = children.length\n\n for (let j = childrenLength - 1; j >= 0; j--) {\n node.insertAfter(children[j])\n }\n\n node.remove()\n return children.map((child) => child.getLatest())\n}\n\nfunction getTextNodesToMatch(textNode: TextNode): TextNode[] {\n // check if next siblings are simple text nodes till a node contains a space separator\n const textNodesToMatch = [textNode]\n let nextSibling = textNode.getNextSibling()\n while (nextSibling !== null && $isTextNode(nextSibling) && nextSibling.isSimpleText()) {\n textNodesToMatch.push(nextSibling)\n if (/\\s/.test(nextSibling.getTextContent())) {\n break\n }\n nextSibling = nextSibling.getNextSibling()\n }\n return textNodesToMatch\n}\n\nfunction useAutoLink(\n editor: LexicalEditor,\n matchers: LinkMatcher[],\n onChange?: ChangeHandler,\n): void {\n useEffect(() => {\n if (!editor.hasNodes([AutoLinkNode])) {\n invariant(false, 'LexicalAutoLinkPlugin: AutoLinkNode not registered on editor')\n }\n\n const onChangeWrapped = (url: null | string, prevUrl: null | string): void => {\n if (onChange != null) {\n onChange(url, prevUrl)\n }\n }\n\n return mergeRegister(\n editor.registerNodeTransform(TextNodeValue, (textNode: TextNode) => {\n const parent = textNode.getParentOrThrow()\n const previous = textNode.getPreviousSibling()\n if ($isAutoLinkNode(parent)) {\n handleLinkEdit(parent, matchers, onChangeWrapped)\n } else if (!$isLinkNode(parent)) {\n if (\n textNode.isSimpleText() &&\n (startsWithSeparator(textNode.getTextContent()) || !$isAutoLinkNode(previous))\n ) {\n const textNodesToMatch = getTextNodesToMatch(textNode)\n $handleLinkCreation(textNodesToMatch, matchers, onChangeWrapped)\n }\n\n handleBadNeighbors(textNode, matchers, onChangeWrapped)\n }\n }),\n )\n }, [editor, matchers, onChange])\n}\n\nconst URL_REGEX =\n /((https?:\\/\\/(www\\.)?)|(www\\.))[-\\w@:%.+~#=]{1,256}\\.[a-zA-Z\\d()]{1,6}\\b([-\\w()@:%+.~#?&/=]*)(?<![-.+():%])/\n\nconst EMAIL_REGEX =\n /(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\])|(([a-z\\-\\d]+\\.)+[a-z]{2,}))/i\n\nconst MATCHERS = [\n createLinkMatcherWithRegExp(URL_REGEX, (text) => {\n return text.startsWith('http') ? text : `https://${text}`\n }),\n createLinkMatcherWithRegExp(EMAIL_REGEX, (text) => {\n return `mailto:${text}`\n }),\n]\n\nexport const AutoLinkPlugin: PluginComponent<ClientProps> = () => {\n const [editor] = useLexicalComposerContext()\n\n useAutoLink(editor, MATCHERS)\n\n return null\n}\n"],"names":["useLexicalComposerContext","mergeRegister","$createTextNode","$getSelection","$isElementNode","$isLineBreakNode","$isNodeSelection","$isRangeSelection","$isTextNode","TextNode","TextNodeValue","useEffect","invariant","$createAutoLinkNode","$isAutoLinkNode","AutoLinkNode","$isLinkNode","createLinkMatcherWithRegExp","regExp","urlTransformer","text","match","exec","index","length","url","findFirstMatch","matchers","i","PUNCTUATION_OR_SPACE","isSeparator","char","test","endsWithSeparator","textContent","startsWithSeparator","startsWithFullStop","isPreviousNodeValid","node","previousNode","getPreviousSibling","getLastDescendant","getTextContent","isNextNodeValid","nextNode","getNextSibling","getFirstDescendant","isContentAroundIsValid","matchStart","matchEnd","nodes","contentBeforeIsValid","contentAfterIsValid","extractMatchingNodes","startIndex","endIndex","unmodifiedBeforeNodes","matchingNodes","unmodifiedAfterNodes","matchingOffset","currentOffset","currentNodes","currentNode","currentNodeText","currentNodeLength","currentNodeStart","currentNodeEnd","push","shift","$createAutoLinkNode_","fields","linkType","linkNode","remainingTextNode","linkTextNode","splitText","textNode","setFormat","getFormat","setDetail","getDetail","setStyle","getStyle","append","replace","firstTextNode","offset","firstLinkTextNode","linkNodes","endNode","selection","selectedTextNode","getNodes","find","undefined","select","anchor","focus","$handleLinkCreation","onChange","initialText","map","join","invalidMatchEnd","matchLength","isValid","actualMatchStart","actualMatchEnd","substring","handleLinkEdit","children","getChildren","childrenLength","child","isSimpleText","replaceWithChildren","getFields","flds","setFields","handleBadNeighbors","previousSibling","nextSibling","j","insertAfter","remove","getLatest","getTextNodesToMatch","textNodesToMatch","useAutoLink","editor","hasNodes","onChangeWrapped","prevUrl","registerNodeTransform","parent","getParentOrThrow","previous","URL_REGEX","EMAIL_REGEX","MATCHERS","startsWith","AutoLinkPlugin"],"mappings":"AAAA;AAGA,SAASA,yBAAyB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UwG;YACnC,OAAO,IAAI,CAACnH,YAAYsH,SAAS;gBAC/B,IACE1D,SAASsC,YAAY,MACpB/E,CAAAA,oBAAoByC,SAASlC,cAAc,OAAO,CAAC5B,gBAAgB0H,SAAQ,GAC5E;oBACA,MAAMT,mBAAmBD,oBAAoBlD;oBAC7CsB,oBAAoB6B,kBAAkBpG,UAAUwG;gBAClD;gBAEAZ,mBAAmB3C,UAAUjD,UAAUwG;YACzC;QACF;IAEJ,GAAG;QAACF;QAAQtG;QAAUwE;KAAS;AACjC;AAEA,MAAMsC,YACJ;AAEF,MAAMC,cACJ;AAEF,MAAMC,WAAW;IACf1H,4BAA4BwH,WAAW,CAACrH;QACtC,OAAOA,KAAKwH,UAAU,CAAC,UAAUxH,OAAO,CAAC,QAAQ,EAAEA,KAAK,CAAC;IAC3D;IACAH,4BAA4ByH,aAAa,CAACtH;QACxC,OAAO,CAAC,OAAO,EAAEA,KAAK,CAAC;IACzB;CACD;AAED,OAAO,MAAMyH,iBAA+C;IAC1D,MAAM,CAACZ,OAAO,GAAGjI;IAEjBgI,YAAYC,QAAQU;IAEpB,OAAO;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/features/link/plugins/autoLink/index.tsx"],"sourcesContent":["'use client'\nimport type { ElementNode, LexicalEditor, LexicalNode, TextNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $createTextNode,\n $getSelection,\n $isElementNode,\n $isLineBreakNode,\n $isNodeSelection,\n $isRangeSelection,\n $isTextNode,\n TextNode as TextNodeValue,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { ClientProps } from '../../feature.client.js'\nimport type { LinkFields } from '../../nodes/types.js'\n\nimport { invariant } from '../../../../lexical/utils/invariant.js'\nimport { $createAutoLinkNode, $isAutoLinkNode, AutoLinkNode } from '../../nodes/AutoLinkNode.js'\nimport { $isLinkNode } from '../../nodes/LinkNode.js'\n\ntype ChangeHandler = (url: null | string, prevUrl: null | string) => void\n\ninterface LinkMatcherResult {\n fields?: LinkFields\n index: number\n length: number\n text: string\n url: string\n}\n\nexport type LinkMatcher = (text: string) => LinkMatcherResult | null\n\nexport function createLinkMatcherWithRegExp(\n regExp: RegExp,\n urlTransformer: (text: string) => string = (text) => text,\n) {\n return (text: string) => {\n const match = regExp.exec(text)\n if (match === null) return null\n return {\n index: match.index,\n length: match[0].length,\n text: match[0],\n url: urlTransformer(match[0]),\n }\n }\n}\n\nfunction findFirstMatch(text: string, matchers: LinkMatcher[]): LinkMatcherResult | null {\n for (let i = 0; i < matchers.length; i++) {\n const match = matchers[i](text)\n\n if (match != null) {\n return match\n }\n }\n\n return null\n}\n\nconst PUNCTUATION_OR_SPACE = /[.,;\\s]/\n\nfunction isSeparator(char: string): boolean {\n return PUNCTUATION_OR_SPACE.test(char)\n}\n\nfunction endsWithSeparator(textContent: string): boolean {\n return isSeparator(textContent[textContent.length - 1])\n}\n\nfunction startsWithSeparator(textContent: string): boolean {\n return isSeparator(textContent[0])\n}\n\n/**\n * Check if the text content starts with a fullstop followed by a top-level domain.\n * Meaning if the text content can be a beginning of a top level domain.\n * @param textContent\n * @param isEmail\n * @returns boolean\n */\nfunction startsWithTLD(textContent: string, isEmail: boolean): boolean {\n if (isEmail) {\n return /^\\.[a-z]{2,}/i.test(textContent)\n } else {\n return /^\\.[a-z0-9]+/i.test(textContent)\n }\n}\n\nfunction isPreviousNodeValid(node: LexicalNode): boolean {\n let previousNode = node.getPreviousSibling()\n if ($isElementNode(previousNode)) {\n previousNode = previousNode.getLastDescendant()\n }\n return (\n previousNode === null ||\n $isLineBreakNode(previousNode) ||\n ($isTextNode(previousNode) && endsWithSeparator(previousNode.getTextContent()))\n )\n}\n\nfunction isNextNodeValid(node: LexicalNode): boolean {\n let nextNode = node.getNextSibling()\n if ($isElementNode(nextNode)) {\n nextNode = nextNode.getFirstDescendant()\n }\n return (\n nextNode === null ||\n $isLineBreakNode(nextNode) ||\n ($isTextNode(nextNode) && startsWithSeparator(nextNode.getTextContent()))\n )\n}\n\nfunction isContentAroundIsValid(\n matchStart: number,\n matchEnd: number,\n text: string,\n nodes: TextNode[],\n): boolean {\n const contentBeforeIsValid =\n matchStart > 0 ? isSeparator(text[matchStart - 1]) : isPreviousNodeValid(nodes[0])\n if (!contentBeforeIsValid) {\n return false\n }\n\n const contentAfterIsValid =\n matchEnd < text.length ? isSeparator(text[matchEnd]) : isNextNodeValid(nodes[nodes.length - 1])\n return contentAfterIsValid\n}\n\nfunction extractMatchingNodes(\n nodes: TextNode[],\n startIndex: number,\n endIndex: number,\n): [\n matchingOffset: number,\n unmodifiedBeforeNodes: TextNode[],\n matchingNodes: TextNode[],\n unmodifiedAfterNodes: TextNode[],\n] {\n const unmodifiedBeforeNodes: TextNode[] = []\n const matchingNodes: TextNode[] = []\n const unmodifiedAfterNodes: TextNode[] = []\n let matchingOffset = 0\n\n let currentOffset = 0\n const currentNodes = [...nodes]\n\n while (currentNodes.length > 0) {\n const currentNode = currentNodes[0]\n const currentNodeText = currentNode.getTextContent()\n const currentNodeLength = currentNodeText.length\n const currentNodeStart = currentOffset\n const currentNodeEnd = currentOffset + currentNodeLength\n\n if (currentNodeEnd <= startIndex) {\n unmodifiedBeforeNodes.push(currentNode)\n matchingOffset += currentNodeLength\n } else if (currentNodeStart >= endIndex) {\n unmodifiedAfterNodes.push(currentNode)\n } else {\n matchingNodes.push(currentNode)\n }\n currentOffset += currentNodeLength\n currentNodes.shift()\n }\n return [matchingOffset, unmodifiedBeforeNodes, matchingNodes, unmodifiedAfterNodes]\n}\n\nfunction $createAutoLinkNode_(\n nodes: TextNode[],\n startIndex: number,\n endIndex: number,\n match: LinkMatcherResult,\n): TextNode | undefined {\n const fields: LinkFields = {\n linkType: 'custom',\n url: match.url,\n ...match.fields,\n }\n\n const linkNode = $createAutoLinkNode({ fields })\n if (nodes.length === 1) {\n let remainingTextNode = nodes[0]\n let linkTextNode\n if (startIndex === 0) {\n ;[linkTextNode, remainingTextNode] = remainingTextNode.splitText(endIndex)\n } else {\n ;[, linkTextNode, remainingTextNode] = remainingTextNode.splitText(startIndex, endIndex)\n }\n const textNode = $createTextNode(match.text)\n textNode.setFormat(linkTextNode.getFormat())\n textNode.setDetail(linkTextNode.getDetail())\n textNode.setStyle(linkTextNode.getStyle())\n linkNode.append(textNode)\n linkTextNode.replace(linkNode)\n return remainingTextNode\n } else if (nodes.length > 1) {\n const firstTextNode = nodes[0]\n let offset = firstTextNode.getTextContent().length\n let firstLinkTextNode\n if (startIndex === 0) {\n firstLinkTextNode = firstTextNode\n } else {\n ;[, firstLinkTextNode] = firstTextNode.splitText(startIndex)\n }\n const linkNodes = []\n let remainingTextNode\n for (let i = 1; i < nodes.length; i++) {\n const currentNode = nodes[i]\n const currentNodeText = currentNode.getTextContent()\n const currentNodeLength = currentNodeText.length\n const currentNodeStart = offset\n const currentNodeEnd = offset + currentNodeLength\n if (currentNodeStart < endIndex) {\n if (currentNodeEnd <= endIndex) {\n linkNodes.push(currentNode)\n } else {\n const [linkTextNode, endNode] = currentNode.splitText(endIndex - currentNodeStart)\n linkNodes.push(linkTextNode)\n remainingTextNode = endNode\n }\n }\n offset += currentNodeLength\n }\n const selection = $getSelection()\n const selectedTextNode = selection ? selection.getNodes().find($isTextNode) : undefined\n const textNode = $createTextNode(firstLinkTextNode.getTextContent())\n textNode.setFormat(firstLinkTextNode.getFormat())\n textNode.setDetail(firstLinkTextNode.getDetail())\n textNode.setStyle(firstLinkTextNode.getStyle())\n linkNode.append(textNode, ...linkNodes)\n // it does not preserve caret position if caret was at the first text node\n // so we need to restore caret position\n if (selectedTextNode && selectedTextNode === firstLinkTextNode) {\n if ($isRangeSelection(selection)) {\n textNode.select(selection.anchor.offset, selection.focus.offset)\n } else if ($isNodeSelection(selection)) {\n textNode.select(0, textNode.getTextContent().length)\n }\n }\n firstLinkTextNode.replace(linkNode)\n return remainingTextNode\n }\n return undefined\n}\n\nfunction $handleLinkCreation(\n nodes: TextNode[],\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n let currentNodes = [...nodes]\n const initialText = currentNodes.map((node) => node.getTextContent()).join('')\n let text = initialText\n\n let match\n let invalidMatchEnd = 0\n\n while ((match = findFirstMatch(text, matchers)) != null && match !== null) {\n const matchStart: number = match.index\n const matchLength: number = match.length\n const matchEnd = matchStart + matchLength\n const isValid = isContentAroundIsValid(\n invalidMatchEnd + matchStart,\n invalidMatchEnd + matchEnd,\n initialText,\n currentNodes,\n )\n\n if (isValid) {\n const [matchingOffset, , matchingNodes, unmodifiedAfterNodes] = extractMatchingNodes(\n currentNodes,\n invalidMatchEnd + matchStart,\n invalidMatchEnd + matchEnd,\n )\n\n const actualMatchStart = invalidMatchEnd + matchStart - matchingOffset\n const actualMatchEnd = invalidMatchEnd + matchEnd - matchingOffset\n const remainingTextNode = $createAutoLinkNode_(\n matchingNodes,\n actualMatchStart,\n actualMatchEnd,\n match,\n )\n currentNodes = remainingTextNode\n ? [remainingTextNode, ...unmodifiedAfterNodes]\n : unmodifiedAfterNodes\n onChange(match.url, null)\n invalidMatchEnd = 0\n } else {\n invalidMatchEnd += matchEnd\n }\n\n text = text.substring(matchEnd)\n }\n}\n\nfunction handleLinkEdit(\n linkNode: AutoLinkNode,\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n // Check children are simple text\n const children = linkNode.getChildren()\n const childrenLength = children.length\n for (let i = 0; i < childrenLength; i++) {\n const child = children[i]\n if (!$isTextNode(child) || !child.isSimpleText()) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n }\n\n // Check text content fully matches\n const text = linkNode.getTextContent()\n const match = findFirstMatch(text, matchers)\n if (match === null || match.text !== text) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n\n // Check neighbors\n if (!isPreviousNodeValid(linkNode) || !isNextNodeValid(linkNode)) {\n replaceWithChildren(linkNode)\n onChange(null, linkNode.getFields()?.url ?? null)\n return\n }\n\n const url = linkNode.getFields()?.url\n if (url !== match?.url) {\n const flds = linkNode.getFields()\n flds.url = match?.url\n linkNode.setFields(flds)\n onChange(match.url, url ?? null)\n }\n}\n\n// Bad neighbors are edits in neighbor nodes that make AutoLinks incompatible.\n// Given the creation preconditions, these can only be simple text nodes.\nfunction handleBadNeighbors(\n textNode: TextNode,\n matchers: LinkMatcher[],\n onChange: ChangeHandler,\n): void {\n const previousSibling = textNode.getPreviousSibling()\n const nextSibling = textNode.getNextSibling()\n const text = textNode.getTextContent()\n\n if ($isAutoLinkNode(previousSibling)) {\n const isEmailURI = previousSibling.getFields()?.url\n ? previousSibling.getFields()?.url?.startsWith('mailto:')\n : false\n if (!startsWithSeparator(text) || startsWithTLD(text, isEmailURI)) {\n previousSibling.append(textNode)\n handleLinkEdit(previousSibling, matchers, onChange)\n onChange(null, previousSibling.getFields()?.url ?? null)\n }\n }\n\n if ($isAutoLinkNode(nextSibling) && !endsWithSeparator(text)) {\n replaceWithChildren(nextSibling)\n handleLinkEdit(nextSibling, matchers, onChange)\n onChange(null, nextSibling.getFields()?.url ?? null)\n }\n}\n\nfunction replaceWithChildren(node: ElementNode): LexicalNode[] {\n const children = node.getChildren()\n const childrenLength = children.length\n\n for (let j = childrenLength - 1; j >= 0; j--) {\n node.insertAfter(children[j])\n }\n\n node.remove()\n return children.map((child) => child.getLatest())\n}\n\nfunction getTextNodesToMatch(textNode: TextNode): TextNode[] {\n // check if next siblings are simple text nodes till a node contains a space separator\n const textNodesToMatch = [textNode]\n let nextSibling = textNode.getNextSibling()\n while (nextSibling !== null && $isTextNode(nextSibling) && nextSibling.isSimpleText()) {\n textNodesToMatch.push(nextSibling)\n if (/\\s/.test(nextSibling.getTextContent())) {\n break\n }\n nextSibling = nextSibling.getNextSibling()\n }\n return textNodesToMatch\n}\n\nfunction useAutoLink(\n editor: LexicalEditor,\n matchers: LinkMatcher[],\n onChange?: ChangeHandler,\n): void {\n useEffect(() => {\n if (!editor.hasNodes([AutoLinkNode])) {\n invariant(false, 'LexicalAutoLinkPlugin: AutoLinkNode not registered on editor')\n }\n\n const onChangeWrapped = (url: null | string, prevUrl: null | string): void => {\n if (onChange != null) {\n onChange(url, prevUrl)\n }\n }\n\n return mergeRegister(\n editor.registerNodeTransform(TextNodeValue, (textNode: TextNode) => {\n const parent = textNode.getParentOrThrow()\n const previous = textNode.getPreviousSibling()\n if ($isAutoLinkNode(parent)) {\n handleLinkEdit(parent, matchers, onChangeWrapped)\n } else if (!$isLinkNode(parent)) {\n if (\n textNode.isSimpleText() &&\n (startsWithSeparator(textNode.getTextContent()) || !$isAutoLinkNode(previous))\n ) {\n const textNodesToMatch = getTextNodesToMatch(textNode)\n $handleLinkCreation(textNodesToMatch, matchers, onChangeWrapped)\n }\n\n handleBadNeighbors(textNode, matchers, onChangeWrapped)\n }\n }),\n )\n }, [editor, matchers, onChange])\n}\n\nconst URL_REGEX =\n /((https?:\\/\\/(www\\.)?)|(www\\.))[-\\w@:%.+~#=]{1,256}\\.[a-zA-Z\\d()]{1,6}\\b([-\\w()@:%+.~#?&/=]*)(?<![-.+():%])/\n\nconst EMAIL_REGEX =\n /(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\])|(([a-z\\-\\d]+\\.)+[a-z]{2,}))/i\n\nconst MATCHERS = [\n createLinkMatcherWithRegExp(URL_REGEX, (text) => {\n return text.startsWith('http') ? text : `https://${text}`\n }),\n createLinkMatcherWithRegExp(EMAIL_REGEX, (text) => {\n return `mailto:${text}`\n }),\n]\n\nexport const AutoLinkPlugin: PluginComponent<ClientProps> = () => {\n const [editor] = useLexicalComposerContext()\n\n useAutoLink(editor, MATCHERS)\n\n return null\n}\n"],"names":["useLexicalComposerContext","mergeRegister","$createTextNode","$getSelection","$isElementNode","$isLineBreakNode","$isNodeSelection","$isRangeSelection","$isTextNode","TextNode","TextNodeValue","useEffect","invariant","$createAutoLinkNode","$isAutoLinkNode","AutoLinkNode","$isLinkNode","createLinkMatcherWithRegExp","regExp","urlTransformer","text","match","exec","index","length","url","findFirstMatch","matchers","i","PUNCTUATION_OR_SPACE","isSeparator","char","test","endsWithSeparator","textContent","startsWithSeparator","startsWithTLD","isEmail","isPreviousNodeValid","node","previousNode","getPreviousSibling","getLastDescendant","getTextContent","isNextNodeValid","nextNode","getNextSibling","getFirstDescendant","isContentAroundIsValid","matchStart","matchEnd","nodes","contentBeforeIsValid","contentAfterIsValid","extractMatchingNodes","startIndex","endIndex","unmodifiedBeforeNodes","matchingNodes","unmodifiedAfterNodes","matchingOffset","currentOffset","currentNodes","currentNode","currentNodeText","currentNodeLength","currentNodeStart","currentNodeEnd","push","shift","$createAutoLinkNode_","fields","linkType","linkNode","remainingTextNode","linkTextNode","splitText","textNode","setFormat","getFormat","setDetail","getDetail","setStyle","getStyle","append","replace","firstTextNode","offset","firstLinkTextNode","linkNodes","endNode","selection","selectedTextNode","getNodes","find","undefined","select","anchor","focus","$handleLinkCreation","onChange","initialText","map","join","invalidMatchEnd","matchLength","isValid","actualMatchStart","actualMatchEnd","substring","handleLinkEdit","children","getChildren","childrenLength","child","isSimpleText","replaceWithChildren","getFields","flds","setFields","handleBadNeighbors","previousSibling","nextSibling","isEmailURI","startsWith","j","insertAfter","remove","getLatest","getTextNodesToMatch","textNodesToMatch","useAutoLink","editor","hasNodes","onChangeWrapped","prevUrl","registerNodeTransform","parent","getParentOrThrow","previous","URL_REGEX","EMAIL_REGEX","MATCHERS","AutoLinkPlugin"],"mappings":"AAAA;AAGA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SACEC,eAAe,EACfC,aAAa,EACbC,cAAc,EACdC,gBAAgB,EAChBC,gBAAgB,EAChBC,iBAAiB,EACjBC,WAAW,EAC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IAAI3B,gBAAgB2H,SAAS;gBAC3B3B,eAAe2B,QAAQ9G,UAAU2G;YACnC,OAAO,IAAI,CAACtH,YAAYyH,SAAS;gBAC/B,IACE5D,SAASsC,YAAY,MACpBhF,CAAAA,oBAAoB0C,SAASlC,cAAc,OAAO,CAAC7B,gBAAgB6H,SAAQ,GAC5E;oBACA,MAAMT,mBAAmBD,oBAAoBpD;oBAC7CsB,oBAAoB+B,kBAAkBvG,UAAU2G;gBAClD;gBAEAd,mBAAmB3C,UAAUlD,UAAU2G;YACzC;QACF;IAEJ,GAAG;QAACF;QAAQzG;QAAUyE;KAAS;AACjC;AAEA,MAAMwC,YACJ;AAEF,MAAMC,cACJ;AAEF,MAAMC,WAAW;IACf7H,4BAA4B2H,WAAW,CAACxH;QACtC,OAAOA,KAAKwG,UAAU,CAAC,UAAUxG,OAAO,CAAC,QAAQ,EAAEA,KAAK,CAAC;IAC3D;IACAH,4BAA4B4H,aAAa,CAACzH;QACxC,OAAO,CAAC,OAAO,EAAEA,KAAK,CAAC;IACzB;CACD;AAED,OAAO,MAAM2H,iBAA+C;IAC1D,MAAM,CAACX,OAAO,GAAGpI;IAEjBmI,YAAYC,QAAQU;IAEpB,OAAO;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/features/link/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAIpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAElF,eAAO,MAAM,cAAc,UAClB,sBAAsB,8BACD,KAAK,EAAE,KAClC,cAAc,CAAC,sBAAsB,GAAG,kBAAkB,
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/features/link/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAIpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAElF,eAAO,MAAM,cAAc,UAClB,sBAAsB,8BACD,KAAK,EAAE,KAClC,cAAc,CAAC,sBAAsB,GAAG,kBAAkB,CAmC5D,CAAA"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema';
|
|
2
2
|
export const linkValidation = (props, sanitizedFieldsWithoutText)=>{
|
|
3
|
-
return async ({ node, validation: { options: { id, operation, preferences, req } } })=>{
|
|
3
|
+
return async ({ node, validation: { options: { id, collectionSlug, operation, preferences, req } } })=>{
|
|
4
4
|
/**
|
|
5
5
|
* Run buildStateFromSchema as that properly validates link fields and link sub-fields
|
|
6
6
|
*/ const result = await buildStateFromSchema({
|
|
7
7
|
id,
|
|
8
|
+
collectionSlug,
|
|
8
9
|
data: node.fields,
|
|
9
10
|
fieldSchema: sanitizedFieldsWithoutText,
|
|
10
11
|
operation: operation === 'create' || operation === 'update' ? operation : 'update',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/link/validate.ts"],"sourcesContent":["import type { Field } from 'payload'\n\nimport { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema'\n\nimport type { NodeValidation } from '../typesServer.js'\nimport type { LinkFeatureServerProps } from './feature.server.js'\nimport type { SerializedAutoLinkNode, SerializedLinkNode } from './nodes/types.js'\n\nexport const linkValidation = (\n props: LinkFeatureServerProps,\n sanitizedFieldsWithoutText: Field[],\n): NodeValidation<SerializedAutoLinkNode | SerializedLinkNode> => {\n return async ({\n node,\n validation: {\n options: { id, operation, preferences, req },\n },\n }) => {\n /**\n * Run buildStateFromSchema as that properly validates link fields and link sub-fields\n */\n\n const result = await buildStateFromSchema({\n id,\n data: node.fields,\n fieldSchema: sanitizedFieldsWithoutText, // Sanitized in feature.server.ts\n operation: operation === 'create' || operation === 'update' ? operation : 'update',\n preferences,\n req,\n siblingData: node.fields,\n })\n\n let errorPaths = []\n for (const fieldKey in result) {\n if (result[fieldKey].errorPaths) {\n errorPaths = errorPaths.concat(result[fieldKey].errorPaths)\n }\n }\n\n if (errorPaths.length) {\n return 'The following fields are invalid: ' + errorPaths.join(', ')\n }\n\n return true\n }\n}\n"],"names":["buildStateFromSchema","linkValidation","props","sanitizedFieldsWithoutText","node","validation","options","id","operation","preferences","req","result","data","fields","fieldSchema","siblingData","errorPaths","fieldKey","concat","length","join"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,4CAA2C;AAMhF,OAAO,MAAMC,iBAAiB,CAC5BC,OACAC;IAEA,OAAO,OAAO,EACZC,IAAI,EACJC,YAAY,EACVC,SAAS,EAAEC,EAAE,EAAEC,SAAS,EAAEC,WAAW,EAAEC,GAAG,EAAE,
|
|
1
|
+
{"version":3,"sources":["../../../src/features/link/validate.ts"],"sourcesContent":["import type { Field } from 'payload'\n\nimport { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema'\n\nimport type { NodeValidation } from '../typesServer.js'\nimport type { LinkFeatureServerProps } from './feature.server.js'\nimport type { SerializedAutoLinkNode, SerializedLinkNode } from './nodes/types.js'\n\nexport const linkValidation = (\n props: LinkFeatureServerProps,\n sanitizedFieldsWithoutText: Field[],\n): NodeValidation<SerializedAutoLinkNode | SerializedLinkNode> => {\n return async ({\n node,\n validation: {\n options: { id, collectionSlug, operation, preferences, req },\n },\n }) => {\n /**\n * Run buildStateFromSchema as that properly validates link fields and link sub-fields\n */\n\n const result = await buildStateFromSchema({\n id,\n collectionSlug,\n data: node.fields,\n fieldSchema: sanitizedFieldsWithoutText, // Sanitized in feature.server.ts\n operation: operation === 'create' || operation === 'update' ? operation : 'update',\n preferences,\n req,\n siblingData: node.fields,\n })\n\n let errorPaths = []\n for (const fieldKey in result) {\n if (result[fieldKey].errorPaths) {\n errorPaths = errorPaths.concat(result[fieldKey].errorPaths)\n }\n }\n\n if (errorPaths.length) {\n return 'The following fields are invalid: ' + errorPaths.join(', ')\n }\n\n return true\n }\n}\n"],"names":["buildStateFromSchema","linkValidation","props","sanitizedFieldsWithoutText","node","validation","options","id","collectionSlug","operation","preferences","req","result","data","fields","fieldSchema","siblingData","errorPaths","fieldKey","concat","length","join"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ,4CAA2C;AAMhF,OAAO,MAAMC,iBAAiB,CAC5BC,OACAC;IAEA,OAAO,OAAO,EACZC,IAAI,EACJC,YAAY,EACVC,SAAS,EAAEC,EAAE,EAAEC,cAAc,EAAEC,SAAS,EAAEC,WAAW,EAAEC,GAAG,EAAE,EAC7D,EACF;QACC;;KAEC,GAED,MAAMC,SAAS,MAAMZ,qBAAqB;YACxCO;YACAC;YACAK,MAAMT,KAAKU,MAAM;YACjBC,aAAaZ;YACbM,WAAWA,cAAc,YAAYA,cAAc,WAAWA,YAAY;YAC1EC;YACAC;YACAK,aAAaZ,KAAKU,MAAM;QAC1B;QAEA,IAAIG,aAAa,EAAE;QACnB,IAAK,MAAMC,YAAYN,OAAQ;YAC7B,IAAIA,MAAM,CAACM,SAAS,CAACD,UAAU,EAAE;gBAC/BA,aAAaA,WAAWE,MAAM,CAACP,MAAM,CAACM,SAAS,CAACD,UAAU;YAC5D;QACF;QAEA,IAAIA,WAAWG,MAAM,EAAE;YACrB,OAAO,uCAAuCH,WAAWI,IAAI,CAAC;QAChE;QAEA,OAAO;IACT;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"htmlConverter.d.ts","sourceRoot":"","sources":["../../../src/features/lists/htmlConverter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAInF,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"htmlConverter.d.ts","sourceRoot":"","sources":["../../../src/features/lists/htmlConverter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAInF,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAAC,kBAAkB,CAkB/D,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC,sBAAsB,CA6CvE,CAAA"}
|
|
@@ -2,15 +2,18 @@ import { ListItemNode, ListNode } from '@lexical/list';
|
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
3
|
import { convertLexicalNodesToHTML } from '../converters/html/converter/index.js';
|
|
4
4
|
export const ListHTMLConverter = {
|
|
5
|
-
converter: async ({ converters, node, parent, req })=>{
|
|
5
|
+
converter: async ({ converters, draft, node, overrideAccess, parent, req, showHiddenFields })=>{
|
|
6
6
|
const childrenText = await convertLexicalNodesToHTML({
|
|
7
7
|
converters,
|
|
8
|
+
draft,
|
|
8
9
|
lexicalNodes: node.children,
|
|
10
|
+
overrideAccess,
|
|
9
11
|
parent: {
|
|
10
12
|
...node,
|
|
11
13
|
parent
|
|
12
14
|
},
|
|
13
|
-
req
|
|
15
|
+
req,
|
|
16
|
+
showHiddenFields
|
|
14
17
|
});
|
|
15
18
|
return `<${node?.tag} class="list-${node?.listType}">${childrenText}</${node?.tag}>`;
|
|
16
19
|
},
|
|
@@ -19,16 +22,19 @@ export const ListHTMLConverter = {
|
|
|
19
22
|
]
|
|
20
23
|
};
|
|
21
24
|
export const ListItemHTMLConverter = {
|
|
22
|
-
converter: async ({ converters, node, parent, req })=>{
|
|
25
|
+
converter: async ({ converters, draft, node, overrideAccess, parent, req, showHiddenFields })=>{
|
|
23
26
|
const hasSubLists = node.children.some((child)=>child.type === 'list');
|
|
24
27
|
const childrenText = await convertLexicalNodesToHTML({
|
|
25
28
|
converters,
|
|
29
|
+
draft,
|
|
26
30
|
lexicalNodes: node.children,
|
|
31
|
+
overrideAccess,
|
|
27
32
|
parent: {
|
|
28
33
|
...node,
|
|
29
34
|
parent
|
|
30
35
|
},
|
|
31
|
-
req
|
|
36
|
+
req,
|
|
37
|
+
showHiddenFields
|
|
32
38
|
});
|
|
33
39
|
if ('listType' in parent && parent?.listType === 'check') {
|
|
34
40
|
const uuid = uuidv4();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/features/lists/htmlConverter.ts"],"sourcesContent":["import { ListItemNode, ListNode } from '@lexical/list'\nimport { v4 as uuidv4 } from 'uuid'\n\nimport type { HTMLConverter } from '../converters/html/converter/types.js'\nimport type { SerializedListItemNode, SerializedListNode } from './plugin/index.js'\n\nimport { convertLexicalNodesToHTML } from '../converters/html/converter/index.js'\n\nexport const ListHTMLConverter: HTMLConverter<SerializedListNode> = {\n converter: async ({ converters, node, parent, req }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n req,\n })\n\n return `<${node?.tag} class=\"list-${node?.listType}\">${childrenText}</${node?.tag}>`\n },\n nodeTypes: [ListNode.getType()],\n}\n\nexport const ListItemHTMLConverter: HTMLConverter<SerializedListItemNode> = {\n converter: async ({ converters, node, parent, req }) => {\n const hasSubLists = node.children.some((child) => child.type === 'list')\n\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n req,\n })\n\n if ('listType' in parent && parent?.listType === 'check') {\n const uuid = uuidv4()\n\n return `<li aria-checked=${node.checked ? 'true' : 'false'} class=\"${\n 'list-item-checkbox' +\n (node.checked ? ' list-item-checkbox-checked' : ' list-item-checkbox-unchecked') +\n (hasSubLists ? ' nestedListItem' : '')\n }\"\n role=\"checkbox\"\n tabIndex=${-1}\n value=${node?.value}\n >\n ${\n hasSubLists\n ? childrenText\n : `\n <input type=\"checkbox\" id=\"${uuid}\"${node.checked ? ' checked' : ''}>\n <label for=\"${uuid}\">${childrenText}</label><br>\n `\n }\n\n\n </li>`\n } else {\n return `<li ${hasSubLists ? `class=\"nestedListItem\" ` : ''}value=${node?.value}>${childrenText}</li>`\n }\n },\n nodeTypes: [ListItemNode.getType()],\n}\n"],"names":["ListItemNode","ListNode","v4","uuidv4","convertLexicalNodesToHTML","ListHTMLConverter","converter","converters","node","parent","req","childrenText","lexicalNodes","children","tag","listType","nodeTypes","getType","ListItemHTMLConverter","hasSubLists","some","child","type","uuid","checked","value"],"mappings":"AAAA,SAASA,YAAY,EAAEC,QAAQ,QAAQ,gBAAe;AACtD,SAASC,MAAMC,MAAM,QAAQ,OAAM;AAKnC,SAASC,yBAAyB,QAAQ,wCAAuC;AAEjF,OAAO,MAAMC,oBAAuD;IAClEC,WAAW,OAAO,EAAEC,UAAU,EAAEC,IAAI,EAAEC,MAAM,EAAEC,GAAG,EAAE;
|
|
1
|
+
{"version":3,"sources":["../../../src/features/lists/htmlConverter.ts"],"sourcesContent":["import { ListItemNode, ListNode } from '@lexical/list'\nimport { v4 as uuidv4 } from 'uuid'\n\nimport type { HTMLConverter } from '../converters/html/converter/types.js'\nimport type { SerializedListItemNode, SerializedListNode } from './plugin/index.js'\n\nimport { convertLexicalNodesToHTML } from '../converters/html/converter/index.js'\n\nexport const ListHTMLConverter: HTMLConverter<SerializedListNode> = {\n converter: async ({ converters, draft, node, overrideAccess, parent, req, showHiddenFields }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n\n return `<${node?.tag} class=\"list-${node?.listType}\">${childrenText}</${node?.tag}>`\n },\n nodeTypes: [ListNode.getType()],\n}\n\nexport const ListItemHTMLConverter: HTMLConverter<SerializedListItemNode> = {\n converter: async ({ converters, draft, node, overrideAccess, parent, req, showHiddenFields }) => {\n const hasSubLists = node.children.some((child) => child.type === 'list')\n\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n draft,\n lexicalNodes: node.children,\n overrideAccess,\n parent: {\n ...node,\n parent,\n },\n req,\n showHiddenFields,\n })\n\n if ('listType' in parent && parent?.listType === 'check') {\n const uuid = uuidv4()\n\n return `<li aria-checked=${node.checked ? 'true' : 'false'} class=\"${\n 'list-item-checkbox' +\n (node.checked ? ' list-item-checkbox-checked' : ' list-item-checkbox-unchecked') +\n (hasSubLists ? ' nestedListItem' : '')\n }\"\n role=\"checkbox\"\n tabIndex=${-1}\n value=${node?.value}\n >\n ${\n hasSubLists\n ? childrenText\n : `\n <input type=\"checkbox\" id=\"${uuid}\"${node.checked ? ' checked' : ''}>\n <label for=\"${uuid}\">${childrenText}</label><br>\n `\n }\n\n\n </li>`\n } else {\n return `<li ${hasSubLists ? `class=\"nestedListItem\" ` : ''}value=${node?.value}>${childrenText}</li>`\n }\n },\n nodeTypes: [ListItemNode.getType()],\n}\n"],"names":["ListItemNode","ListNode","v4","uuidv4","convertLexicalNodesToHTML","ListHTMLConverter","converter","converters","draft","node","overrideAccess","parent","req","showHiddenFields","childrenText","lexicalNodes","children","tag","listType","nodeTypes","getType","ListItemHTMLConverter","hasSubLists","some","child","type","uuid","checked","value"],"mappings":"AAAA,SAASA,YAAY,EAAEC,QAAQ,QAAQ,gBAAe;AACtD,SAASC,MAAMC,MAAM,QAAQ,OAAM;AAKnC,SAASC,yBAAyB,QAAQ,wCAAuC;AAEjF,OAAO,MAAMC,oBAAuD;IAClEC,WAAW,OAAO,EAAEC,UAAU,EAAEC,KAAK,EAAEC,IAAI,EAAEC,cAAc,EAAEC,MAAM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;YACL,OAAO,CAAC,IAAI,EAAEQ,cAAc,CAAC,uBAAuB,CAAC,GAAG,GAAG,MAAM,EAAEb,MAAMmB,MAAM,CAAC,EAAEd,aAAa,KAAK,CAAC;QACvG;IACF;IACAK,WAAW;QAACnB,aAAaoB,OAAO;KAAG;AACrC,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/migrations/slateToLexical/converter/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAI/D,wBAAgB,qBAAqB,CAAC,EACpC,UAAU,EACV,SAAS,GACV,EAAE;IACD,UAAU,EAAE,kBAAkB,EAAE,CAAA;IAChC,SAAS,EAAE,SAAS,EAAE,CAAA;CACvB,GAAG,qBAAqB,CAgBxB;AAED,wBAAgB,0BAA0B,CAAC,EACzC,oBAAoB,EACpB,UAAU,EACV,cAAc,EACd,UAAU,GACX,EAAE;IACD,oBAAoB,EAAE,OAAO,CAAA;IAC7B,UAAU,EAAE,kBAAkB,EAAE,GAAG,SAAS,CAAA;IAC5C;;OAEG;IACH,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,SAAS,EAAE,CAAA;CACxB,GAAG,qBAAqB,EAAE,CAmC1B;AAED,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,kBAAkB,EAAE,EAChC,IAAI,EAAE,SAAS,GACd,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/migrations/slateToLexical/converter/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAI/D,wBAAgB,qBAAqB,CAAC,EACpC,UAAU,EACV,SAAS,GACV,EAAE;IACD,UAAU,EAAE,kBAAkB,EAAE,CAAA;IAChC,SAAS,EAAE,SAAS,EAAE,CAAA;CACvB,GAAG,qBAAqB,CAgBxB;AAED,wBAAgB,0BAA0B,CAAC,EACzC,oBAAoB,EACpB,UAAU,EACV,cAAc,EACd,UAAU,GACX,EAAE;IACD,oBAAoB,EAAE,OAAO,CAAA;IAC7B,UAAU,EAAE,kBAAkB,EAAE,GAAG,SAAS,CAAA;IAC5C;;OAEG;IACH,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,SAAS,EAAE,CAAA;CACxB,GAAG,qBAAqB,EAAE,CAmC1B;AAED,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,kBAAkB,EAAE,EAChC,IAAI,EAAE,SAAS,GACd,uBAAuB,CAgBzB;AACD,wBAAgB,eAAe,CAAC,IAAI,EAAE,SAAS,GAAG,kBAAkB,CAUnE;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAwB3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/features/migrations/slateToLexical/converter/index.ts"],"sourcesContent":["import type {\n SerializedEditorState,\n SerializedLexicalNode,\n SerializedParagraphNode,\n SerializedTextNode,\n} from 'lexical'\n\nimport type { SlateNode, SlateNodeConverter } from './types.js'\n\nimport { NodeFormat } from '../../../../lexical/utils/nodeFormat.js'\n\nexport function convertSlateToLexical({\n converters,\n slateData,\n}: {\n converters: SlateNodeConverter[]\n slateData: SlateNode[]\n}): SerializedEditorState {\n return {\n root: {\n type: 'root',\n children: convertSlateNodesToLexical({\n canContainParagraphs: true,\n converters,\n parentNodeType: 'root',\n slateNodes: slateData,\n }),\n direction: 'ltr',\n format: '',\n indent: 0,\n version: 1,\n },\n }\n}\n\nexport function convertSlateNodesToLexical({\n canContainParagraphs,\n converters,\n parentNodeType,\n slateNodes,\n}: {\n canContainParagraphs: boolean\n converters: SlateNodeConverter[] | undefined\n /**\n * Type of the parent lexical node (not the type of the original, parent slate type)\n */\n parentNodeType: string\n slateNodes: SlateNode[]\n}): SerializedLexicalNode[] {\n if (!converters?.length) {\n return []\n }\n const unknownConverter = converters.find((converter) => converter.nodeTypes.includes('unknown'))\n return (\n slateNodes.map((slateNode, i) => {\n if (!('type' in slateNode)) {\n if (canContainParagraphs) {\n // This is a paragraph node. They do not have a type property in Slate\n return convertParagraphNode(converters, slateNode)\n } else {\n // This is a simple text node. canContainParagraphs may be false if this is nested inside a paragraph already, since paragraphs cannot contain paragraphs\n return convertTextNode(slateNode)\n }\n }\n if (slateNode.type === 'p') {\n return convertParagraphNode(converters, slateNode)\n }\n\n const converter = converters.find((converter) => converter.nodeTypes.includes(slateNode.type))\n\n if (converter) {\n return converter.converter({ childIndex: i, converters, parentNodeType, slateNode })\n }\n\n console.warn('slateToLexical > No converter found for node type: ' + slateNode.type)\n return unknownConverter?.converter({\n childIndex: i,\n converters,\n parentNodeType,\n slateNode,\n })\n }) || []\n )\n}\n\nexport function convertParagraphNode(\n converters: SlateNodeConverter[],\n node: SlateNode,\n): SerializedParagraphNode {\n return {\n type: 'paragraph',\n children: convertSlateNodesToLexical({\n canContainParagraphs: false,\n converters,\n parentNodeType: 'paragraph',\n slateNodes: node.children || [],\n }),\n direction: 'ltr',\n format: '',\n indent: 0,\n textFormat: 0,\n version: 1,\n }\n}\nexport function convertTextNode(node: SlateNode): SerializedTextNode {\n return {\n type: 'text',\n detail: 0,\n format: convertNodeToFormat(node),\n mode: 'normal',\n style: '',\n text: node.text,\n version: 1,\n }\n}\n\nexport function convertNodeToFormat(node: SlateNode): number {\n let format = 0\n if (node.bold) {\n format = format | NodeFormat.IS_BOLD\n }\n if (node.italic) {\n format = format | NodeFormat.IS_ITALIC\n }\n if (node.strikethrough) {\n format = format | NodeFormat.IS_STRIKETHROUGH\n }\n if (node.underline) {\n format = format | NodeFormat.IS_UNDERLINE\n }\n if (node.subscript) {\n format = format | NodeFormat.IS_SUBSCRIPT\n }\n if (node.superscript) {\n format = format | NodeFormat.IS_SUPERSCRIPT\n }\n if (node.code) {\n format = format | NodeFormat.IS_CODE\n }\n return format\n}\n"],"names":["NodeFormat","convertSlateToLexical","converters","slateData","root","type","children","convertSlateNodesToLexical","canContainParagraphs","parentNodeType","slateNodes","direction","format","indent","version","length","unknownConverter","find","converter","nodeTypes","includes","map","slateNode","i","convertParagraphNode","convertTextNode","childIndex","console","warn","node","textFormat","detail","convertNodeToFormat","mode","style","text","bold","IS_BOLD","italic","IS_ITALIC","strikethrough","IS_STRIKETHROUGH","underline","IS_UNDERLINE","subscript","IS_SUBSCRIPT","superscript","IS_SUPERSCRIPT","code","IS_CODE"],"mappings":"AASA,SAASA,UAAU,QAAQ,0CAAyC;AAEpE,OAAO,SAASC,sBAAsB,EACpCC,UAAU,EACVC,SAAS,EAIV;IACC,OAAO;QACLC,MAAM;YACJC,MAAM;YACNC,UAAUC,2BAA2B;gBACnCC,sBAAsB;gBACtBN;gBACAO,gBAAgB;gBAChBC,YAAYP;YACd;YACAQ,WAAW;YACXC,QAAQ;YACRC,QAAQ;YACRC,SAAS;QACX;IACF;AACF;AAEA,OAAO,SAASP,2BAA2B,EACzCC,oBAAoB,EACpBN,UAAU,EACVO,cAAc,EACdC,UAAU,EASX;IACC,IAAI,CAACR,YAAYa,QAAQ;QACvB,OAAO,EAAE;IACX;IACA,MAAMC,mBAAmBd,WAAWe,IAAI,CAAC,CAACC,YAAcA,UAAUC,SAAS,CAACC,QAAQ,CAAC;IACrF,OACEV,WAAWW,GAAG,CAAC,CAACC,WAAWC;QACzB,IAAI,CAAE,CAAA,UAAUD,SAAQ,GAAI;YAC1B,IAAId,sBAAsB;gBACxB,sEAAsE;gBACtE,OAAOgB,qBAAqBtB,YAAYoB;YAC1C,OAAO;gBACL,yJAAyJ;gBACzJ,OAAOG,gBAAgBH;YACzB;QACF;QACA,IAAIA,UAAUjB,IAAI,KAAK,KAAK;YAC1B,OAAOmB,qBAAqBtB,YAAYoB;QAC1C;QAEA,MAAMJ,YAAYhB,WAAWe,IAAI,CAAC,CAACC,YAAcA,UAAUC,SAAS,CAACC,QAAQ,CAACE,UAAUjB,IAAI;QAE5F,IAAIa,WAAW;YACb,OAAOA,UAAUA,SAAS,CAAC;gBAAEQ,YAAYH;gBAAGrB;gBAAYO;gBAAgBa;YAAU;QACpF;QAEAK,QAAQC,IAAI,CAAC,wDAAwDN,UAAUjB,IAAI;QACnF,OAAOW,kBAAkBE,UAAU;YACjCQ,YAAYH;YACZrB;YACAO;YACAa;QACF;IACF,MAAM,EAAE;AAEZ;AAEA,OAAO,SAASE,qBACdtB,UAAgC,EAChC2B,IAAe;IAEf,OAAO;QACLxB,MAAM;QACNC,UAAUC,2BAA2B;YACnCC,sBAAsB;YACtBN;YACAO,gBAAgB;YAChBC,YAAYmB,KAAKvB,QAAQ,IAAI,EAAE;QACjC;QACAK,WAAW;QACXC,QAAQ;QACRC,QAAQ;QACRiB,YAAY;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/features/migrations/slateToLexical/converter/index.ts"],"sourcesContent":["import type {\n SerializedEditorState,\n SerializedLexicalNode,\n SerializedParagraphNode,\n SerializedTextNode,\n} from 'lexical'\n\nimport type { SlateNode, SlateNodeConverter } from './types.js'\n\nimport { NodeFormat } from '../../../../lexical/utils/nodeFormat.js'\n\nexport function convertSlateToLexical({\n converters,\n slateData,\n}: {\n converters: SlateNodeConverter[]\n slateData: SlateNode[]\n}): SerializedEditorState {\n return {\n root: {\n type: 'root',\n children: convertSlateNodesToLexical({\n canContainParagraphs: true,\n converters,\n parentNodeType: 'root',\n slateNodes: slateData,\n }),\n direction: 'ltr',\n format: '',\n indent: 0,\n version: 1,\n },\n }\n}\n\nexport function convertSlateNodesToLexical({\n canContainParagraphs,\n converters,\n parentNodeType,\n slateNodes,\n}: {\n canContainParagraphs: boolean\n converters: SlateNodeConverter[] | undefined\n /**\n * Type of the parent lexical node (not the type of the original, parent slate type)\n */\n parentNodeType: string\n slateNodes: SlateNode[]\n}): SerializedLexicalNode[] {\n if (!converters?.length) {\n return []\n }\n const unknownConverter = converters.find((converter) => converter.nodeTypes.includes('unknown'))\n return (\n slateNodes.map((slateNode, i) => {\n if (!('type' in slateNode)) {\n if (canContainParagraphs) {\n // This is a paragraph node. They do not have a type property in Slate\n return convertParagraphNode(converters, slateNode)\n } else {\n // This is a simple text node. canContainParagraphs may be false if this is nested inside a paragraph already, since paragraphs cannot contain paragraphs\n return convertTextNode(slateNode)\n }\n }\n if (slateNode.type === 'p') {\n return convertParagraphNode(converters, slateNode)\n }\n\n const converter = converters.find((converter) => converter.nodeTypes.includes(slateNode.type))\n\n if (converter) {\n return converter.converter({ childIndex: i, converters, parentNodeType, slateNode })\n }\n\n console.warn('slateToLexical > No converter found for node type: ' + slateNode.type)\n return unknownConverter?.converter({\n childIndex: i,\n converters,\n parentNodeType,\n slateNode,\n })\n }) || []\n )\n}\n\nexport function convertParagraphNode(\n converters: SlateNodeConverter[],\n node: SlateNode,\n): SerializedParagraphNode {\n return {\n type: 'paragraph',\n children: convertSlateNodesToLexical({\n canContainParagraphs: false,\n converters,\n parentNodeType: 'paragraph',\n slateNodes: node.children || [],\n }),\n direction: 'ltr',\n format: '',\n indent: 0,\n textFormat: 0,\n textStyle: '',\n version: 1,\n }\n}\nexport function convertTextNode(node: SlateNode): SerializedTextNode {\n return {\n type: 'text',\n detail: 0,\n format: convertNodeToFormat(node),\n mode: 'normal',\n style: '',\n text: node.text,\n version: 1,\n }\n}\n\nexport function convertNodeToFormat(node: SlateNode): number {\n let format = 0\n if (node.bold) {\n format = format | NodeFormat.IS_BOLD\n }\n if (node.italic) {\n format = format | NodeFormat.IS_ITALIC\n }\n if (node.strikethrough) {\n format = format | NodeFormat.IS_STRIKETHROUGH\n }\n if (node.underline) {\n format = format | NodeFormat.IS_UNDERLINE\n }\n if (node.subscript) {\n format = format | NodeFormat.IS_SUBSCRIPT\n }\n if (node.superscript) {\n format = format | NodeFormat.IS_SUPERSCRIPT\n }\n if (node.code) {\n format = format | NodeFormat.IS_CODE\n }\n return format\n}\n"],"names":["NodeFormat","convertSlateToLexical","converters","slateData","root","type","children","convertSlateNodesToLexical","canContainParagraphs","parentNodeType","slateNodes","direction","format","indent","version","length","unknownConverter","find","converter","nodeTypes","includes","map","slateNode","i","convertParagraphNode","convertTextNode","childIndex","console","warn","node","textFormat","textStyle","detail","convertNodeToFormat","mode","style","text","bold","IS_BOLD","italic","IS_ITALIC","strikethrough","IS_STRIKETHROUGH","underline","IS_UNDERLINE","subscript","IS_SUBSCRIPT","superscript","IS_SUPERSCRIPT","code","IS_CODE"],"mappings":"AASA,SAASA,UAAU,QAAQ,0CAAyC;AAEpE,OAAO,SAASC,sBAAsB,EACpCC,UAAU,EACVC,SAAS,EAIV;IACC,OAAO;QACLC,MAAM;YACJC,MAAM;YACNC,UAAUC,2BAA2B;gBACnCC,sBAAsB;gBACtBN;gBACAO,gBAAgB;gBAChBC,YAAYP;YACd;YACAQ,WAAW;YACXC,QAAQ;YACRC,QAAQ;YACRC,SAAS;QACX;IACF;AACF;AAEA,OAAO,SAASP,2BAA2B,EACzCC,oBAAoB,EACpBN,UAAU,EACVO,cAAc,EACdC,UAAU,EASX;IACC,IAAI,CAACR,YAAYa,QAAQ;QACvB,OAAO,EAAE;IACX;IACA,MAAMC,mBAAmBd,WAAWe,IAAI,CAAC,CAACC,YAAcA,UAAUC,SAAS,CAACC,QAAQ,CAAC;IACrF,OACEV,WAAWW,GAAG,CAAC,CAACC,WAAWC;QACzB,IAAI,CAAE,CAAA,UAAUD,SAAQ,GAAI;YAC1B,IAAId,sBAAsB;gBACxB,sEAAsE;gBACtE,OAAOgB,qBAAqBtB,YAAYoB;YAC1C,OAAO;gBACL,yJAAyJ;gBACzJ,OAAOG,gBAAgBH;YACzB;QACF;QACA,IAAIA,UAAUjB,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SAAS,EAAE;QAClBjC,SAASA,SAASZ,WAAW8C,YAAY;IAC3C;IACA,IAAIjB,KAAKkB,WAAW,EAAE;QACpBnC,SAASA,SAASZ,WAAWgD,cAAc;IAC7C;IACA,IAAInB,KAAKoB,IAAI,EAAE;QACbrC,SAASA,SAASZ,WAAWkD,OAAO;IACtC;IACA,OAAOtC;AACT"}
|
|
@@ -2,7 +2,7 @@ import type { Transformer } from '@lexical/markdown';
|
|
|
2
2
|
import type { GenericLanguages, I18nClient } from '@payloadcms/translations';
|
|
3
3
|
import type { JSONSchema4 } from 'json-schema';
|
|
4
4
|
import type { Klass, LexicalNode, LexicalNodeReplacement, SerializedEditorState, SerializedLexicalNode } from 'lexical';
|
|
5
|
-
import type { Field, JsonObject, PayloadRequest, ReplaceAny, RequestContext, RichTextField, SanitizedConfig, ValidateOptions } from 'payload';
|
|
5
|
+
import type { Field, JsonObject, Payload, PayloadRequest, ReplaceAny, RequestContext, RichTextField, SanitizedConfig, ValidateOptions } from 'payload';
|
|
6
6
|
import type React from 'react';
|
|
7
7
|
import type { ServerEditorConfig } from '../lexical/config/types.js';
|
|
8
8
|
import type { AdapterProps } from '../types.js';
|
|
@@ -206,6 +206,7 @@ export type ServerFeature<ServerProps, ClientFeatureProps> = {
|
|
|
206
206
|
generateComponentMap?: (args: {
|
|
207
207
|
config: SanitizedConfig;
|
|
208
208
|
i18n: I18nClient;
|
|
209
|
+
payload: Payload;
|
|
209
210
|
props: ServerProps;
|
|
210
211
|
schemaPath: string;
|
|
211
212
|
}) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesServer.d.ts","sourceRoot":"","sources":["../../src/features/typesServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,C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+
{"version":3,"file":"typesServer.d.ts","sourceRoot":"","sources":["../../src/features/typesServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAC5E,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,KAAK,EACL,UAAU,EACV,OAAO,EACP,cAAc,EACd,UAAU,EACV,cAAc,EACd,aAAa,EACb,eAAe,EACf,eAAe,EAChB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAE5D,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,IAAI,EACJ,cAAc,EACd,kBAAkB,EAClB,GAAG,EACH,gBAAgB,EAChB,UAAU,GACX,EAAE;IACD,OAAO,EAAE,cAAc,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;IACd;;OAEG;IACH,wBAAwB,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,i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qB,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,sBAAsB,GAAG,OAAO,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/features/typesServer.ts"],"sourcesContent":["import type { Transformer } from '@lexical/markdown'\nimport 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 Field,\n JsonObject,\n PayloadRequest,\n ReplaceAny,\n RequestContext,\n RichTextField,\n SanitizedConfig,\n ValidateOptions,\n} from 'payload'\nimport type React from 'react'\n\nimport type { ServerEditorConfig } from '../lexical/config/types.js'\nimport type { AdapterProps } from '../types.js'\nimport type { HTMLConverter } from './converters/html/converter/types.js'\nimport type { ClientComponentProps } 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 // 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` 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}\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 duplicate: boolean\n /**\n * Only available in `beforeChange` hooks.\n */\n errors: { field: string; message: string }[]\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 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 for them\n */\n getSubFields?: (args: {\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?: React.FC<ClientComponentProps<ClientFeatureProps>>\n /**\n * This determines what props will be available on the Client.\n */\n clientFeatureProps?: ClientFeatureProps\n generateComponentMap?: (args: {\n config: SanitizedConfig\n i18n: I18nClient\n props: ServerProps\n schemaPath: string\n }) => {\n [key: string]: React.FC<{ componentKey: string; featureKey: string }>\n }\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n i18n: I18nClient\n props: ServerProps\n schemaMap: Map<string, Field[]>\n schemaPath: string\n }) => Map<string, Field[]> | null\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 /**\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?: Transformer[]\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?: {\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' | 'markdownTransformers' | 'nodes'>>\n"],"names":[],"mappings":"AAwWA,WAmD8F"}
|
|
1
|
+
{"version":3,"sources":["../../src/features/typesServer.ts"],"sourcesContent":["import type { Transformer } from '@lexical/markdown'\nimport 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 Field,\n JsonObject,\n Payload,\n PayloadRequest,\n ReplaceAny,\n RequestContext,\n RichTextField,\n SanitizedConfig,\n ValidateOptions,\n} from 'payload'\nimport type React from 'react'\n\nimport type { ServerEditorConfig } from '../lexical/config/types.js'\nimport type { AdapterProps } from '../types.js'\nimport type { HTMLConverter } from './converters/html/converter/types.js'\nimport type { ClientComponentProps } 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 // 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` 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}\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 duplicate: boolean\n /**\n * Only available in `beforeChange` hooks.\n */\n errors: { field: string; message: string }[]\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 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 for them\n */\n getSubFields?: (args: {\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?: React.FC<ClientComponentProps<ClientFeatureProps>>\n /**\n * This determines what props will be available on the Client.\n */\n clientFeatureProps?: ClientFeatureProps\n generateComponentMap?: (args: {\n config: SanitizedConfig\n i18n: I18nClient\n payload: Payload\n props: ServerProps\n schemaPath: string\n }) => {\n [key: string]: React.FC<{ componentKey: string; featureKey: string }>\n }\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n i18n: I18nClient\n props: ServerProps\n schemaMap: Map<string, Field[]>\n schemaPath: string\n }) => Map<string, Field[]> | null\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 /**\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?: Transformer[]\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?: {\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' | 'markdownTransformers' | 'nodes'>>\n"],"names":[],"mappings":"AA0WA,WAmD8F"}
|
|
@@ -59,7 +59,7 @@ export const UploadFeature = createServerFeature({
|
|
|
59
59
|
createNode({
|
|
60
60
|
converters: {
|
|
61
61
|
html: {
|
|
62
|
-
converter: async ({ node, req })=>{
|
|
62
|
+
converter: async ({ draft, node, overrideAccess, req, showHiddenFields })=>{
|
|
63
63
|
// @ts-expect-error
|
|
64
64
|
const id = node?.value?.id || node?.value // for backwards-compatibility
|
|
65
65
|
;
|
|
@@ -72,11 +72,11 @@ export const UploadFeature = createServerFeature({
|
|
|
72
72
|
currentDepth: 0,
|
|
73
73
|
data: uploadDocument,
|
|
74
74
|
depth: 1,
|
|
75
|
-
draft
|
|
75
|
+
draft,
|
|
76
76
|
key: 'value',
|
|
77
|
-
overrideAccess
|
|
77
|
+
overrideAccess,
|
|
78
78
|
req,
|
|
79
|
-
showHiddenFields
|
|
79
|
+
showHiddenFields
|
|
80
80
|
});
|
|
81
81
|
} catch (ignored) {
|
|
82
82
|
// eslint-disable-next-line no-console
|