@payloadcms/richtext-lexical 3.0.0-beta.20 → 3.0.0-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/field/features/blocks/feature.server.d.ts.map +1 -1
- package/dist/field/features/blocks/feature.server.js +28 -68
- package/dist/field/features/blocks/feature.server.js.map +1 -1
- package/dist/field/features/blocks/populationPromise.d.ts.map +1 -1
- package/dist/field/features/blocks/populationPromise.js +0 -13
- package/dist/field/features/blocks/populationPromise.js.map +1 -1
- package/dist/field/features/blocks/validate.d.ts.map +1 -1
- package/dist/field/features/blocks/validate.js +2 -14
- package/dist/field/features/blocks/validate.js.map +1 -1
- package/dist/field/features/link/drawer/baseFields.d.ts +3 -3
- package/dist/field/features/link/drawer/baseFields.d.ts.map +1 -1
- package/dist/field/features/link/drawer/baseFields.js +28 -42
- package/dist/field/features/link/drawer/baseFields.js.map +1 -1
- package/dist/field/features/link/drawer/types.d.ts +4 -2
- package/dist/field/features/link/drawer/types.d.ts.map +1 -1
- package/dist/field/features/link/drawer/types.js.map +1 -1
- package/dist/field/features/link/feature.server.d.ts +0 -2
- package/dist/field/features/link/feature.server.d.ts.map +1 -1
- package/dist/field/features/link/feature.server.js +22 -6
- package/dist/field/features/link/feature.server.js.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +38 -24
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/index.scss +9 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts +3 -5
- package/dist/field/features/link/plugins/floatingLinkEditor/utilities.d.ts.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js +11 -29
- package/dist/field/features/link/plugins/floatingLinkEditor/utilities.js.map +1 -1
- package/dist/field/features/link/plugins/link/index.d.ts.map +1 -1
- package/dist/field/features/link/plugins/link/index.js +0 -6
- package/dist/field/features/link/plugins/link/index.js.map +1 -1
- package/dist/field/features/link/populationPromise.d.ts.map +1 -1
- package/dist/field/features/link/populationPromise.js +5 -23
- package/dist/field/features/link/populationPromise.js.map +1 -1
- package/dist/field/features/link/validate.d.ts +5 -0
- package/dist/field/features/link/validate.d.ts.map +1 -0
- package/dist/field/features/link/validate.js +32 -0
- package/dist/field/features/link/validate.js.map +1 -0
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.js +51 -2
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
- package/dist/field/features/types.d.ts +5 -1
- package/dist/field/features/types.d.ts.map +1 -1
- package/dist/field/features/types.js.map +1 -1
- package/dist/field/features/upload/feature.server.d.ts.map +1 -1
- package/dist/field/features/upload/feature.server.js +14 -2
- package/dist/field/features/upload/feature.server.js.map +1 -1
- package/dist/field/features/upload/populationPromise.d.ts.map +1 -1
- package/dist/field/features/upload/populationPromise.js +2 -12
- package/dist/field/features/upload/populationPromise.js.map +1 -1
- package/dist/field/features/upload/validate.d.ts +2 -1
- package/dist/field/features/upload/validate.d.ts.map +1 -1
- package/dist/field/features/upload/validate.js +33 -11
- package/dist/field/features/upload/validate.js.map +1 -1
- package/dist/field/lexical/LexicalEditor.js +1 -1
- package/dist/field/lexical/LexicalEditor.js.map +1 -1
- package/dist/field/lexical/config/server/default.d.ts +1 -2
- package/dist/field/lexical/config/server/default.d.ts.map +1 -1
- package/dist/field/lexical/config/server/default.js +0 -2
- package/dist/field/lexical/config/server/default.js.map +1 -1
- package/dist/field/lexical/config/server/loader.d.ts +4 -2
- package/dist/field/lexical/config/server/loader.d.ts.map +1 -1
- package/dist/field/lexical/config/server/loader.js +3 -2
- package/dist/field/lexical/config/server/loader.js.map +1 -1
- package/dist/field/lexical/config/server/sanitize.d.ts +2 -1
- package/dist/field/lexical/config/server/sanitize.d.ts.map +1 -1
- package/dist/field/lexical/config/server/sanitize.js +3 -2
- package/dist/field/lexical/config/server/sanitize.js.map +1 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/index.d.ts.map +1 -1
- package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js +24 -23
- package/dist/field/lexical/plugins/FloatingSelectToolbar/index.js.map +1 -1
- package/dist/field/lexical/utils/setFloatingElemPosition.d.ts +1 -1
- package/dist/field/lexical/utils/setFloatingElemPosition.d.ts.map +1 -1
- package/dist/field/lexical/utils/setFloatingElemPosition.js +15 -13
- package/dist/field/lexical/utils/setFloatingElemPosition.js.map +1 -1
- package/dist/field/lexical/utils/url.d.ts.map +1 -1
- package/dist/field/lexical/utils/url.js +2 -0
- package/dist/field/lexical/utils/url.js.map +1 -1
- package/dist/generateComponentMap.d.ts.map +1 -1
- package/dist/generateComponentMap.js +1 -10
- package/dist/generateComponentMap.js.map +1 -1
- package/dist/generateSchemaMap.d.ts.map +1 -1
- package/dist/generateSchemaMap.js +1 -10
- package/dist/generateSchemaMap.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +241 -234
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/features/link/feature.server.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { SanitizedConfig } from 'payload/config'\nimport type { Field, FieldWithRichTextRequiredEditor } from 'payload/types'\n\nimport { traverseFields } from '@payloadcms/next/utilities'\nimport { deepCopyObject } from 'payload/utilities'\n\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { ClientProps } from './feature.client.js'\n\nimport { convertLexicalNodesToHTML } from '../converters/html/converter/index.js'\nimport { createNode } from '../typeUtilities.js'\nimport { LinkFeatureClientComponent } from './feature.client.js'\nimport { AutoLinkNode } from './nodes/AutoLinkNode.js'\nimport { LinkNode } from './nodes/LinkNode.js'\nimport { transformExtraFields } from './plugins/floatingLinkEditor/utilities.js'\nimport { linkPopulationPromiseHOC } from './populationPromise.js'\n\nexport type ExclusiveLinkCollectionsProps =\n | {\n /**\n * The collections that should be disabled for internal linking. Overrides the `enableRichTextLink` property in the collection config.\n * When this property is set, `enabledCollections` will not be available.\n **/\n disabledCollections?: string[]\n\n // Ensures that enabledCollections is not available when disabledCollections is set\n enabledCollections?: never\n }\n | {\n // Ensures that disabledCollections is not available when enabledCollections is set\n disabledCollections?: never\n\n /**\n * The collections that should be enabled for internal linking. Overrides the `enableRichTextLink` property in the collection config\n * When this property is set, `disabledCollections` will not be available.\n **/\n enabledCollections?: string[]\n }\n\nexport type LinkFeatureServerProps = ExclusiveLinkCollectionsProps & {\n /**\n * A function or array defining additional fields for the link feature. These will be\n * displayed in the link editor drawer.\n */\n fields?:\n | ((args: {\n config: SanitizedConfig\n defaultFields: FieldWithRichTextRequiredEditor[]\n i18n: I18n\n }) => FieldWithRichTextRequiredEditor[])\n | FieldWithRichTextRequiredEditor[]\n}\n\nexport const LinkFeature: FeatureProviderProviderServer<LinkFeatureServerProps, ClientProps> = (\n props,\n) => {\n if (!props) {\n props = {}\n }\n return {\n feature: () => {\n return {\n ClientComponent: LinkFeatureClientComponent,\n clientFeatureProps: {\n disabledCollections: props.disabledCollections,\n enabledCollections: props.enabledCollections,\n } as ExclusiveLinkCollectionsProps,\n generateSchemaMap: ({ config, i18n, props }) => {\n const transformedFields = transformExtraFields(\n deepCopyObject(props.fields),\n config,\n i18n,\n props.enabledCollections,\n props.disabledCollections,\n )\n\n if (\n !transformedFields ||\n !Array.isArray(transformedFields) ||\n transformedFields.length === 0\n ) {\n return null\n }\n\n const schemaMap = new Map<string, Field[]>()\n\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n schemaMap.set('fields', transformedFields)\n\n traverseFields({\n config,\n fields: transformedFields,\n i18n,\n schemaMap,\n schemaPath: 'fields',\n validRelationships,\n })\n\n return schemaMap\n },\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({ converters, node, parent, payload }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n payload,\n })\n\n const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n\n let href: string = node.fields.url\n if (node.fields.linkType === 'internal') {\n href =\n typeof node.fields.doc?.value === 'string'\n ? node.fields.doc?.value\n : node.fields.doc?.value?.id\n }\n\n return `<a href=\"${href}\"${rel}>${childrenText}</a>`\n },\n nodeTypes: [AutoLinkNode.getType()],\n },\n },\n hooks: {\n afterRead: [\n ({ node }) => {\n return node\n },\n ],\n },\n node: AutoLinkNode,\n populationPromises: [linkPopulationPromiseHOC(props)],\n }),\n createNode({\n converters: {\n html: {\n converter: async ({ converters, node, parent, payload }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n payload,\n })\n\n const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n\n const href: string =\n node.fields.linkType === 'custom'\n ? node.fields.url\n : (node.fields.doc?.value as string)\n\n return `<a href=\"${href}\"${rel}>${childrenText}</a>`\n },\n nodeTypes: [LinkNode.getType()],\n },\n },\n node: LinkNode,\n populationPromises: [linkPopulationPromiseHOC(props)],\n }),\n ],\n serverFeatureProps: props,\n }\n },\n key: 'link',\n serverFeatureProps: props,\n }\n}\n"],"names":["traverseFields","deepCopyObject","convertLexicalNodesToHTML","createNode","LinkFeatureClientComponent","AutoLinkNode","LinkNode","transformExtraFields","linkPopulationPromiseHOC","LinkFeature","props","feature","ClientComponent","clientFeatureProps","disabledCollections","enabledCollections","generateSchemaMap","config","i18n","transformedFields","fields","Array","isArray","length","schemaMap","Map","validRelationships","collections","map","c","slug","set","schemaPath","nodes","converters","html","converter","node","parent","payload","childrenText","lexicalNodes","children","rel","newTab","href","url","linkType","doc","value","id","nodeTypes","getType","hooks","afterRead","populationPromises","serverFeatureProps","key"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,cAAc,QAAQ,6BAA4B;AAC3D,SAASC,cAAc,QAAQ,oBAAmB;AAKlD,SAASC,yBAAyB,QAAQ,wCAAuC;AACjF,SAASC,UAAU,QAAQ,sBAAqB;AAChD,SAASC,0BAA0B,QAAQ,sBAAqB;AAChE,SAASC,YAAY,QAAQ,0BAAyB;AACtD,SAASC,QAAQ,QAAQ,sBAAqB;AAC9C,SAASC,oBAAoB,QAAQ,4CAA2C;AAChF,SAASC,wBAAwB,QAAQ,yBAAwB;AAsCjE,OAAO,MAAMC,cAAkF,CAC7FC;IAEA,IAAI,CAACA,OAAO;QACVA,QAAQ,CAAC;IACX;IACA,OAAO;QACLC,SAAS;YACP,OAAO;gBACLC,iBAAiBR;gBACjBS,oBAAoB;oBAClBC,qBAAqBJ,MAAMI,mBAAmB;oBAC9CC,oBAAoBL,MAAMK,kBAAkB;gBAC9C;gBACAC,mBAAmB,CAAC,EAAEC,MAAM,EAAEC,IAAI,EAAER,KAAK,EAAE;oBACzC,MAAMS,oBAAoBZ,qBACxBN,eAAeS,MAAMU,MAAM,GAC3BH,QACAC,MACAR,MAAMK,kBAAkB,EACxBL,MAAMI,mBAAmB;oBAG3B,IACE,CAACK,qBACD,CAACE,MAAMC,OAAO,CAACH,sBACfA,kBAAkBI,MAAM,KAAK,GAC7B;wBACA,OAAO;oBACT;oBAEA,MAAMC,YAAY,IAAIC;oBAEtB,MAAMC,qBAAqBT,OAAOU,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;oBAEtEN,UAAUO,GAAG,CAAC,UAAUZ;oBAExBnB,eAAe;wBACbi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AI;4CACPC;wCACF;wCACAC;oCACF;oCAEA,MAAMI,MAAcN,KAAKjB,MAAM,CAACwB,MAAM,GAAG,+BAA+B;oCAExE,MAAMC,OACJR,KAAKjB,MAAM,CAAC2B,QAAQ,KAAK,WACrBV,KAAKjB,MAAM,CAAC0B,GAAG,GACdT,KAAKjB,MAAM,CAAC4B,GAAG,EAAEC;oCAExB,OAAO,CAAC,SAAS,EAAEJ,KAAK,CAAC,EAAEF,IAAI,CAAC,EAAEH,aAAa,IAAI,CAAC;gCACtD;gCACAW,WAAW;oCAAC7C,SAAS8C,OAAO;iCAAG;4BACjC;wBACF;wBACAf,MAAM/B;wBACNiD,oBAAoB;4BAAC/C,yBAAyBE;yBAAO;oBACvD;iBACD;gBACD8C,oBAAoB9C;YACtB;QACF;QACA+C,KAAK;QACLD,oBAAoB9C;IACtB;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/link/feature.server.ts"],"sourcesContent":["import type { Config, SanitizedConfig } from 'payload/config'\nimport type { Field, FieldWithRichTextRequiredEditor } from 'payload/types'\n\nimport { traverseFields } from '@payloadcms/next/utilities'\nimport { sanitizeFields } from 'payload/config'\nimport { deepCopyObject } from 'payload/utilities'\n\nimport type { FeatureProviderProviderServer } from '../types.js'\nimport type { ClientProps } from './feature.client.js'\n\nimport { convertLexicalNodesToHTML } from '../converters/html/converter/index.js'\nimport { createNode } from '../typeUtilities.js'\nimport { LinkFeatureClientComponent } from './feature.client.js'\nimport { AutoLinkNode } from './nodes/AutoLinkNode.js'\nimport { LinkNode } from './nodes/LinkNode.js'\nimport { transformExtraFields } from './plugins/floatingLinkEditor/utilities.js'\nimport { linkPopulationPromiseHOC } from './populationPromise.js'\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?: string[]\n\n // Ensures that enabledCollections is not available when disabledCollections is set\n enabledCollections?: never\n }\n | {\n // Ensures that disabledCollections is not available when enabledCollections is set\n disabledCollections?: never\n\n /**\n * The collections that should be enabled for internal linking. Overrides the `enableRichTextLink` property in the collection config\n * When this property is set, `disabledCollections` will not be available.\n **/\n enabledCollections?: string[]\n }\n\nexport type LinkFeatureServerProps = ExclusiveLinkCollectionsProps & {\n /**\n * A function or array defining additional fields for the link feature. These will be\n * displayed in the link editor drawer.\n */\n fields?:\n | ((args: {\n config: SanitizedConfig\n defaultFields: FieldWithRichTextRequiredEditor[]\n }) => FieldWithRichTextRequiredEditor[])\n | FieldWithRichTextRequiredEditor[]\n}\n\nexport const LinkFeature: FeatureProviderProviderServer<LinkFeatureServerProps, ClientProps> = (\n props,\n) => {\n if (!props) {\n props = {}\n }\n return {\n feature: async ({ config: _config }) => {\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 )\n\n const sanitizedFields = (await sanitizeFields({\n config: _config as unknown as Config,\n fields: _transformedFields,\n requireFieldLevelRichTextEditor: true,\n validRelationships,\n })) as FieldWithRichTextRequiredEditor[]\n props.fields = sanitizedFields\n\n return {\n ClientComponent: LinkFeatureClientComponent,\n clientFeatureProps: {\n disabledCollections: props.disabledCollections,\n enabledCollections: props.enabledCollections,\n } as ExclusiveLinkCollectionsProps,\n generateSchemaMap: ({ config, i18n }) => {\n if (!sanitizedFields || !Array.isArray(sanitizedFields) || sanitizedFields.length === 0) {\n return null\n }\n\n const schemaMap = new Map<string, Field[]>()\n\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n schemaMap.set('fields', sanitizedFields)\n\n traverseFields({\n config,\n fields: sanitizedFields,\n i18n,\n schemaMap,\n schemaPath: 'fields',\n validRelationships,\n })\n\n return schemaMap\n },\n nodes: [\n createNode({\n converters: {\n html: {\n converter: async ({ converters, node, parent, payload }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n payload,\n })\n\n const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n\n let href: string = node.fields.url\n if (node.fields.linkType === 'internal') {\n href =\n typeof node.fields.doc?.value === 'string'\n ? node.fields.doc?.value\n : node.fields.doc?.value?.id\n }\n\n return `<a href=\"${href}\"${rel}>${childrenText}</a>`\n },\n nodeTypes: [AutoLinkNode.getType()],\n },\n },\n hooks: {\n afterRead: [\n ({ node }) => {\n return node\n },\n ],\n },\n node: AutoLinkNode,\n populationPromises: [linkPopulationPromiseHOC(props)],\n validations: [linkValidation(props)],\n }),\n createNode({\n converters: {\n html: {\n converter: async ({ converters, node, parent, payload }) => {\n const childrenText = await convertLexicalNodesToHTML({\n converters,\n lexicalNodes: node.children,\n parent: {\n ...node,\n parent,\n },\n payload,\n })\n\n const rel: string = node.fields.newTab ? ' rel=\"noopener noreferrer\"' : ''\n\n const href: string =\n node.fields.linkType === 'custom'\n ? node.fields.url\n : (node.fields.doc?.value as string)\n\n return `<a href=\"${href}\"${rel}>${childrenText}</a>`\n },\n nodeTypes: [LinkNode.getType()],\n },\n },\n node: LinkNode,\n populationPromises: [linkPopulationPromiseHOC(props)],\n validations: [linkValidation(props)],\n }),\n ],\n serverFeatureProps: props,\n }\n },\n key: 'link',\n serverFeatureProps: props,\n }\n}\n"],"names":["traverseFields","sanitizeFields","deepCopyObject","convertLexicalNodesToHTML","createNode","LinkFeatureClientComponent","AutoLinkNode","LinkNode","transformExtraFields","linkPopulationPromiseHOC","linkValidation","LinkFeature","props","feature","config","_config","validRelationships","collections","map","c","slug","_transformedFields","fields","enabledCollections","disabledCollections","sanitizedFields","requireFieldLevelRichTextEditor","ClientComponent","clientFeatureProps","generateSchemaMap","i18n","Array","isArray","length","schemaMap","Map","set","schemaPath","nodes","converters","html","converter","node","parent","payload","childrenText","lexicalNodes","children","rel","newTab","href","url","linkType","doc","value","id","nodeTypes","getType","hooks","after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AA,MAAMpC;wBACNsD,oBAAoB;4BAACnD,yBAAyBG;yBAAO;wBACrDiD,aAAa;4BAACnD,eAAeE;yBAAO;oBACtC;oBACAR,WAAW;wBACTmC,YAAY;4BACVC,MAAM;gCACJC,WAAW,OAAO,EAAEF,UAAU,EAAEG,IAAI,EAAEC,MAAM,EAAEC,OAAO,EAAE;oCACrD,MAAMC,eAAe,MAAM1C,0BAA0B;wCACnDoC;wCACAO,cAAcJ,KAAKK,QAAQ;wCAC3BJ,QAAQ;4CACN,GAAGD,IAAI;4CACPC;wCACF;wCACAC;oCACF;oCAEA,MAAMI,MAAcN,KAAKpB,MAAM,CAAC2B,MAAM,GAAG,+BAA+B;oCAExE,MAAMC,OACJR,KAAKpB,MAAM,CAAC8B,QAAQ,KAAK,WACrBV,KAAKpB,MAAM,CAAC6B,GAAG,GACdT,KAAKpB,MAAM,CAAC+B,GAAG,EAAEC;oCAExB,OAAO,CAAC,SAAS,EAAEJ,KAAK,CAAC,EAAEF,IAAI,CAAC,EAAEH,aAAa,IAAI,CAAC;gCACtD;gCACAW,WAAW;oCAACjD,SAASkD,OAAO;iCAAG;4BACjC;wBACF;wBACAf,MAAMnC;wBACNqD,oBAAoB;4BAACnD,yBAAyBG;yBAAO;wBACrDiD,aAAa;4BAACnD,eAAeE;yBAAO;oBACtC;iBACD;gBACDkD,oBAAoBlD;YACtB;QACF;QACAmD,KAAK;QACLD,oBAAoBlD;IACtB;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAmD,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.tsx"],"names":[],"mappings":"AAsBA,OAAO,KAAmD,MAAM,OAAO,CAAA;AAevE,wBAAgB,UAAU,CAAC,EAAE,UAAU,EAAE,EAAE;IAAE,UAAU,EAAE,WAAW,CAAA;CAAE,GAAG,KAAK,CAAC,SAAS,CAmUvF"}
|
|
@@ -22,8 +22,8 @@ export function LinkEditor({ anchorElem }) {
|
|
|
22
22
|
const { useModal } = facelessUIImport;
|
|
23
23
|
const [editor] = useLexicalComposerContext();
|
|
24
24
|
const editorRef = useRef(null);
|
|
25
|
-
const [linkUrl, setLinkUrl] = useState(
|
|
26
|
-
const [linkLabel, setLinkLabel] = useState(
|
|
25
|
+
const [linkUrl, setLinkUrl] = useState(null);
|
|
26
|
+
const [linkLabel, setLinkLabel] = useState(null);
|
|
27
27
|
const { uuid } = useEditorConfigContext();
|
|
28
28
|
const config = useConfig();
|
|
29
29
|
const { i18n, t } = useTranslation();
|
|
@@ -53,33 +53,38 @@ export function LinkEditor({ anchorElem }) {
|
|
|
53
53
|
if (focusLinkParent == null || badNode) {
|
|
54
54
|
setIsLink(false);
|
|
55
55
|
setIsAutoLink(false);
|
|
56
|
-
setLinkUrl(
|
|
57
|
-
setLinkLabel(
|
|
56
|
+
setLinkUrl(null);
|
|
57
|
+
setLinkLabel(null);
|
|
58
58
|
setSelectedNodes([]);
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
// Initial state:
|
|
62
62
|
const data = {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
...focusLinkParent.getFields()
|
|
69
|
-
},
|
|
63
|
+
doc: undefined,
|
|
64
|
+
linkType: undefined,
|
|
65
|
+
newTab: undefined,
|
|
66
|
+
url: '',
|
|
67
|
+
...focusLinkParent.getFields(),
|
|
70
68
|
text: focusLinkParent.getTextContent()
|
|
71
69
|
};
|
|
72
70
|
if (focusLinkParent.getFields()?.linkType === 'custom') {
|
|
73
|
-
setLinkUrl(focusLinkParent.getFields()?.url ??
|
|
74
|
-
setLinkLabel(
|
|
71
|
+
setLinkUrl(focusLinkParent.getFields()?.url ?? null);
|
|
72
|
+
setLinkLabel(null);
|
|
75
73
|
} else {
|
|
76
74
|
// internal link
|
|
77
75
|
setLinkUrl(`/admin/collections/${focusLinkParent.getFields()?.doc?.relationTo}/${focusLinkParent.getFields()?.doc?.value}`);
|
|
78
76
|
const relatedField = config.collections.find((coll)=>coll.slug === focusLinkParent.getFields()?.doc?.relationTo);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
if (!relatedField) {
|
|
78
|
+
// Usually happens if the user removed all default fields. In this case, we let them specify the label or do not display the label at all.
|
|
79
|
+
// label could be a virtual field the user added. This is useful if they want to use the link feature for things other than links.
|
|
80
|
+
setLinkLabel(focusLinkParent.getFields()?.label ? String(focusLinkParent.getFields()?.label) : null);
|
|
81
|
+
setLinkUrl(focusLinkParent.getFields()?.url ? String(focusLinkParent.getFields()?.url) : null);
|
|
82
|
+
} else {
|
|
83
|
+
const label = t('fields:linkedTo', {
|
|
84
|
+
label: getTranslation(relatedField.labels.singular, i18n)
|
|
85
|
+
}).replace(/<[^>]*>?/g, '');
|
|
86
|
+
setLinkLabel(label);
|
|
87
|
+
}
|
|
83
88
|
}
|
|
84
89
|
setStateData(data);
|
|
85
90
|
setIsLink(true);
|
|
@@ -111,8 +116,8 @@ export function LinkEditor({ anchorElem }) {
|
|
|
111
116
|
if (rootElement !== null) {
|
|
112
117
|
setFloatingElemPositionForLinkEditor(null, editorElem, anchorElem);
|
|
113
118
|
}
|
|
114
|
-
setLinkUrl(
|
|
115
|
-
setLinkLabel(
|
|
119
|
+
setLinkUrl(null);
|
|
120
|
+
setLinkLabel(null);
|
|
116
121
|
}
|
|
117
122
|
return true;
|
|
118
123
|
}, [
|
|
@@ -201,11 +206,13 @@ export function LinkEditor({ anchorElem }) {
|
|
|
201
206
|
ref: editorRef
|
|
202
207
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
203
208
|
className: "link-input"
|
|
204
|
-
}, /*#__PURE__*/ React.createElement("a", {
|
|
209
|
+
}, linkUrl && linkUrl.length > 0 ? /*#__PURE__*/ React.createElement("a", {
|
|
205
210
|
href: linkUrl,
|
|
206
211
|
rel: "noopener noreferrer",
|
|
207
212
|
target: "_blank"
|
|
208
|
-
}, linkLabel != null && linkLabel.length > 0 ? linkLabel : linkUrl)
|
|
213
|
+
}, linkLabel != null && linkLabel.length > 0 ? linkLabel : linkUrl) : linkLabel != null && linkLabel.length > 0 ? /*#__PURE__*/ React.createElement("span", {
|
|
214
|
+
className: "link-input__label-pure"
|
|
215
|
+
}, linkLabel) : null, editor.isEditable() && /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("button", {
|
|
209
216
|
"aria-label": "Edit link",
|
|
210
217
|
className: "link-edit",
|
|
211
218
|
onClick: ()=>{
|
|
@@ -232,7 +239,10 @@ export function LinkEditor({ anchorElem }) {
|
|
|
232
239
|
handleModalSubmit: (fields, data)=>{
|
|
233
240
|
closeModal(drawerSlug);
|
|
234
241
|
const newLinkPayload = data;
|
|
235
|
-
|
|
242
|
+
const bareLinkFields = {
|
|
243
|
+
...newLinkPayload
|
|
244
|
+
};
|
|
245
|
+
delete bareLinkFields.text;
|
|
236
246
|
// See: https://github.com/facebook/lexical/pull/5536. This updates autolink nodes to link nodes whenever a change was made (which is good!).
|
|
237
247
|
editor.update(()=>{
|
|
238
248
|
const selection = $getSelection();
|
|
@@ -246,14 +256,18 @@ export function LinkEditor({ anchorElem }) {
|
|
|
246
256
|
}
|
|
247
257
|
if (linkParent && $isAutoLinkNode(linkParent)) {
|
|
248
258
|
const linkNode = $createLinkNode({
|
|
249
|
-
fields:
|
|
259
|
+
fields: bareLinkFields
|
|
250
260
|
});
|
|
251
261
|
linkParent.replace(linkNode, true);
|
|
252
262
|
}
|
|
253
263
|
});
|
|
254
264
|
// Needs to happen AFTER a potential auto link => link node conversion, as otherwise, the updated text to display may be lost due to
|
|
255
265
|
// it being applied to the auto link node instead of the link node.
|
|
256
|
-
editor.dispatchCommand(TOGGLE_LINK_COMMAND,
|
|
266
|
+
editor.dispatchCommand(TOGGLE_LINK_COMMAND, {
|
|
267
|
+
fields: bareLinkFields,
|
|
268
|
+
selectedNodes,
|
|
269
|
+
text: newLinkPayload.text
|
|
270
|
+
});
|
|
257
271
|
},
|
|
258
272
|
stateData: stateData
|
|
259
273
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalNode } from 'lexical'\nimport type { FormState } from 'payload/types'\nimport type { Data } from 'payload/types'\n\nimport * as facelessUIImport from '@faceless-ui/modal'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $findMatchingParent, mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport { formatDrawerSlug } from '@payloadcms/ui/elements/Drawer'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useEditDepth } from '@payloadcms/ui/providers/EditDepth'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport { $isLineBreakNode } from 'lexical'\nimport {\n $getSelection,\n $isRangeSelection,\n COMMAND_PRIORITY_HIGH,\n COMMAND_PRIORITY_LOW,\n KEY_ESCAPE_COMMAND,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\n\nimport type { LinkNode } from '../../../nodes/LinkNode.js'\nimport type { LinkPayload } from '../types.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { getSelectedNode } from '../../../../../lexical/utils/getSelectedNode.js'\nimport { setFloatingElemPositionForLinkEditor } from '../../../../../lexical/utils/setFloatingElemPositionForLinkEditor.js'\nimport { LinkDrawer } from '../../../drawer/index.js'\nimport { $isAutoLinkNode } from '../../../nodes/AutoLinkNode.js'\nimport { $createLinkNode } from '../../../nodes/LinkNode.js'\nimport { $isLinkNode, TOGGLE_LINK_COMMAND } from '../../../nodes/LinkNode.js'\nimport { TOGGLE_LINK_WITH_MODAL_COMMAND } from './commands.js'\n\nexport function LinkEditor({ anchorElem }: { anchorElem: HTMLElement }): React.ReactNode {\n const { useModal } = facelessUIImport\n\n const [editor] = useLexicalComposerContext()\n\n const editorRef = useRef<HTMLDivElement | null>(null)\n const [linkUrl, setLinkUrl] = useState('')\n const [linkLabel, setLinkLabel] = useState('')\n\n const { uuid } = useEditorConfigContext()\n\n const config = useConfig()\n\n const { i18n, t } = useTranslation()\n\n const [stateData, setStateData] = useState<LinkPayload>(null)\n\n const { closeModal, toggleModal } = useModal()\n const editDepth = useEditDepth()\n const [isLink, setIsLink] = useState(false)\n const [selectedNodes, setSelectedNodes] = useState<LexicalNode[]>([])\n\n const [isAutoLink, setIsAutoLink] = useState(false)\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-rich-text-link-` + uuid,\n depth: editDepth,\n })\n\n const updateLinkEditor = useCallback(() => {\n const selection = $getSelection()\n let selectedNodeDomRect: DOMRect | undefined = null\n\n // Handle the data displayed in the floating link editor & drawer when you click on a link node\n if ($isRangeSelection(selection)) {\n const focusNode = getSelectedNode(selection)\n selectedNodeDomRect = editor.getElementByKey(focusNode.getKey())?.getBoundingClientRect()\n const focusLinkParent: LinkNode = $findMatchingParent(focusNode, $isLinkNode)\n\n // Prevent link modal from showing if selection spans further than the link: https://github.com/facebook/lexical/issues/4064\n const badNode = selection\n .getNodes()\n .filter((node) => !$isLineBreakNode(node))\n .find((node) => {\n const linkNode = $findMatchingParent(node, $isLinkNode)\n return (\n (focusLinkParent && !focusLinkParent.is(linkNode)) ||\n (linkNode && !linkNode.is(focusLinkParent))\n )\n })\n\n if (focusLinkParent == null || badNode) {\n setIsLink(false)\n setIsAutoLink(false)\n setLinkUrl('')\n setLinkLabel('')\n setSelectedNodes([])\n return\n }\n\n // Initial state:\n const data: LinkPayload = {\n fields: {\n doc: undefined,\n linkType: undefined,\n newTab: undefined,\n url: '',\n ...focusLinkParent.getFields(),\n },\n text: focusLinkParent.getTextContent(),\n }\n\n if (focusLinkParent.getFields()?.linkType === 'custom') {\n setLinkUrl(focusLinkParent.getFields()?.url ?? '')\n setLinkLabel('')\n } else {\n // internal link\n setLinkUrl(\n `/admin/collections/${focusLinkParent.getFields()?.doc?.relationTo}/${\n focusLinkParent.getFields()?.doc?.value\n }`,\n )\n\n const relatedField = config.collections.find(\n (coll) => coll.slug === focusLinkParent.getFields()?.doc?.relationTo,\n )\n const label = t('fields:linkedTo', {\n label: getTranslation(relatedField.labels.singular, i18n),\n }).replace(/<[^>]*>?/g, '')\n setLinkLabel(label)\n }\n\n setStateData(data)\n setIsLink(true)\n setSelectedNodes(selection ? selection?.getNodes() : [])\n\n if ($isAutoLinkNode(focusLinkParent)) {\n setIsAutoLink(true)\n } else {\n setIsAutoLink(false)\n }\n }\n\n const editorElem = editorRef.current\n const nativeSelection = window.getSelection()\n const { activeElement } = document\n\n if (editorElem === null) {\n return\n }\n\n const rootElement = editor.getRootElement()\n\n if (\n selection !== null &&\n nativeSelection !== null &&\n rootElement !== null &&\n rootElement.contains(nativeSelection.anchorNode)\n ) {\n if (!selectedNodeDomRect) {\n // Get the DOM rect of the selected node using the native selection. This sometimes produces the wrong\n // result, which is why we use lexical's selection preferably.\n selectedNodeDomRect = nativeSelection.getRangeAt(0).getBoundingClientRect()\n }\n\n if (selectedNodeDomRect != null) {\n selectedNodeDomRect.y += 40\n setFloatingElemPositionForLinkEditor(selectedNodeDomRect, editorElem, anchorElem)\n }\n } else if (activeElement == null || activeElement.className !== 'link-input') {\n if (rootElement !== null) {\n setFloatingElemPositionForLinkEditor(null, editorElem, anchorElem)\n }\n setLinkUrl('')\n setLinkLabel('')\n }\n\n return true\n }, [anchorElem, editor, config, t, i18n])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n TOGGLE_LINK_WITH_MODAL_COMMAND,\n (payload: LinkPayload) => {\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, payload)\n\n // Now, open the modal\n updateLinkEditor()\n toggleModal(drawerSlug)\n\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, updateLinkEditor, toggleModal, drawerSlug])\n\n useEffect(() => {\n if (!isLink && editorRef) {\n editorRef.current.style.opacity = '0'\n editorRef.current.style.transform = 'translate(-10000px, -10000px)'\n }\n }, [isLink])\n\n useEffect(() => {\n const scrollerElem = anchorElem.parentElement\n\n const update = (): void => {\n editor.getEditorState().read(() => {\n void updateLinkEditor()\n })\n }\n\n window.addEventListener('resize', update)\n\n if (scrollerElem != null) {\n scrollerElem.addEventListener('scroll', update)\n }\n\n return () => {\n window.removeEventListener('resize', update)\n\n if (scrollerElem != null) {\n scrollerElem.removeEventListener('scroll', update)\n }\n }\n }, [anchorElem.parentElement, editor, updateLinkEditor])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n void updateLinkEditor()\n })\n }),\n\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n void updateLinkEditor()\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ESCAPE_COMMAND,\n () => {\n if (isLink) {\n setIsLink(false)\n setIsAutoLink(false)\n return true\n }\n return false\n },\n COMMAND_PRIORITY_HIGH,\n ),\n )\n }, [editor, updateLinkEditor, setIsLink, isLink])\n\n useEffect(() => {\n editor.getEditorState().read(() => {\n void updateLinkEditor()\n })\n }, [editor, updateLinkEditor])\n\n return (\n <React.Fragment>\n <div className=\"link-editor\" ref={editorRef}>\n <div className=\"link-input\">\n <a href={linkUrl} rel=\"noopener noreferrer\" target=\"_blank\">\n {linkLabel != null && linkLabel.length > 0 ? linkLabel : linkUrl}\n </a>\n {editor.isEditable() && (\n <React.Fragment>\n <button\n aria-label=\"Edit link\"\n className=\"link-edit\"\n onClick={() => {\n toggleModal(drawerSlug)\n }}\n onMouseDown={(event) => {\n event.preventDefault()\n }}\n tabIndex={0}\n type=\"button\"\n />\n {!isAutoLink && (\n <button\n aria-label=\"Remove link\"\n className=\"link-trash\"\n onClick={() => {\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, null)\n }}\n onMouseDown={(event) => {\n event.preventDefault()\n }}\n tabIndex={0}\n type=\"button\"\n />\n )}\n </React.Fragment>\n )}\n </div>\n </div>\n <LinkDrawer\n drawerSlug={drawerSlug}\n handleModalSubmit={(fields: FormState, data: Data) => {\n closeModal(drawerSlug)\n\n const newLinkPayload: LinkPayload = data as LinkPayload\n\n newLinkPayload.selectedNodes = selectedNodes\n\n // See: https://github.com/facebook/lexical/pull/5536. This updates autolink nodes to link nodes whenever a change was made (which is good!).\n editor.update(() => {\n const selection = $getSelection()\n let linkParent = null\n if ($isRangeSelection(selection)) {\n linkParent = getSelectedNode(selection).getParent()\n } else {\n if (selectedNodes.length) {\n linkParent = selectedNodes[0].getParent()\n }\n }\n\n if (linkParent && $isAutoLinkNode(linkParent)) {\n const linkNode = $createLinkNode({\n fields: newLinkPayload.fields,\n })\n linkParent.replace(linkNode, true)\n }\n })\n\n // Needs to happen AFTER a potential auto link => link node conversion, as otherwise, the updated text to display may be lost due to\n // it being applied to the auto link node instead of the link node.\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, newLinkPayload)\n }}\n stateData={stateData}\n />\n </React.Fragment>\n )\n}\n"],"names":["facelessUIImport","useLexicalComposerContext","$findMatchingParent","mergeRegister","getTranslation","formatDrawerSlug","useConfig","useEditDepth","useTranslation","$isLineBreakNode","$getSelection","$isRangeSelection","COMMAND_PRIORITY_HIGH","COMMAND_PRIORITY_LOW","KEY_ESCAPE_COMMAND","SELECTION_CHANGE_COMMAND","React","useCallback","useEffect","useRef","useState","useEditorConfigContext","getSelectedNode","setFloatingElemPositionForLinkEditor","LinkDrawer","$isAutoLinkNode","$createLinkNode","$isLinkNode","TOGGLE_LINK_COMMAND","TOGGLE_LINK_WITH_MODAL_COMMAND","LinkEditor","anchorElem","useModal","editor","editorRef","linkUrl","setLinkUrl","linkLabel","setLinkLabel","uuid","config","i18n","t","stateData","setStateData","closeModal","toggleModal","editDepth","isLink","setIsLink","selectedNodes","setSelectedNodes","isAutoLink","setIsAutoLink","drawerSlug","slug","depth","updateLinkEditor","selection","selectedNodeDomRect","focusNode","getElementByKey","getKey","getBoundingClientRect","focusLinkParent","badNode","getNodes","filter","node","find","linkNode","is","data","fields","doc","undefined","linkType","newTab","url","getFields","text","getTextContent","relationTo","value","relatedField","collections","coll","label","labels","singular","replace","editorElem","current","nativeSelection","window","getSelection","activeElement","document","rootElement","getRootElement","contains","anchorNode","getRangeAt","y","className","registerCommand","payload","dispatchCommand","style","opacity","transform","scrollerElem","parentElement","update","getEditorState","read","addEventListener","removeEventListener","registerUpdateListener","editorState","Fragment","div","ref","a","href","rel","target","length","isEditable","button","aria-label","onClick","onMouseDown","event","preventDefault","tabIndex","type","handleModalSubmit","newLinkPayload","linkParent","getParent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAKA,YAAYA,sBAAsB,qBAAoB;AACtD,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,mBAAmB,EAAEC,aAAa,QAAQ,iBAAgB;AACnE,SAASC,cAAc,QAAQ,2BAA0B;AACzD,SAASC,gBAAgB,QAAQ,iCAAgC;AACjE,SAASC,SAAS,QAAQ,kCAAiC;AAC3D,SAASC,YAAY,QAAQ,qCAAoC;AACjE,SAASC,cAAc,QAAQ,uCAAsC;AACrE,SAASC,gBAAgB,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../../../../../src/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalNode } from 'lexical'\nimport type { FormState } from 'payload/types'\nimport type { Data } from 'payload/types'\n\nimport * as facelessUIImport from '@faceless-ui/modal'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $findMatchingParent, mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport { formatDrawerSlug } from '@payloadcms/ui/elements/Drawer'\nimport { useConfig } from '@payloadcms/ui/providers/Config'\nimport { useEditDepth } from '@payloadcms/ui/providers/EditDepth'\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport { $isLineBreakNode } from 'lexical'\nimport {\n $getSelection,\n $isRangeSelection,\n COMMAND_PRIORITY_HIGH,\n COMMAND_PRIORITY_LOW,\n KEY_ESCAPE_COMMAND,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\n\nimport type { LinkNode } from '../../../nodes/LinkNode.js'\nimport type { LinkFields } from '../../../nodes/types.js'\nimport type { LinkPayload } from '../types.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { getSelectedNode } from '../../../../../lexical/utils/getSelectedNode.js'\nimport { setFloatingElemPositionForLinkEditor } from '../../../../../lexical/utils/setFloatingElemPositionForLinkEditor.js'\nimport { LinkDrawer } from '../../../drawer/index.js'\nimport { $isAutoLinkNode } from '../../../nodes/AutoLinkNode.js'\nimport { $createLinkNode } from '../../../nodes/LinkNode.js'\nimport { $isLinkNode, TOGGLE_LINK_COMMAND } from '../../../nodes/LinkNode.js'\nimport { TOGGLE_LINK_WITH_MODAL_COMMAND } from './commands.js'\n\nexport function LinkEditor({ anchorElem }: { anchorElem: HTMLElement }): React.ReactNode {\n const { useModal } = facelessUIImport\n\n const [editor] = useLexicalComposerContext()\n\n const editorRef = useRef<HTMLDivElement | null>(null)\n const [linkUrl, setLinkUrl] = useState(null)\n const [linkLabel, setLinkLabel] = useState(null)\n\n const { uuid } = useEditorConfigContext()\n\n const config = useConfig()\n\n const { i18n, t } = useTranslation()\n\n const [stateData, setStateData] = useState<LinkFields & { text: string }>(null)\n\n const { closeModal, toggleModal } = useModal()\n const editDepth = useEditDepth()\n const [isLink, setIsLink] = useState(false)\n const [selectedNodes, setSelectedNodes] = useState<LexicalNode[]>([])\n\n const [isAutoLink, setIsAutoLink] = useState(false)\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-rich-text-link-` + uuid,\n depth: editDepth,\n })\n\n const updateLinkEditor = useCallback(() => {\n const selection = $getSelection()\n let selectedNodeDomRect: DOMRect | undefined = null\n\n // Handle the data displayed in the floating link editor & drawer when you click on a link node\n if ($isRangeSelection(selection)) {\n const focusNode = getSelectedNode(selection)\n selectedNodeDomRect = editor.getElementByKey(focusNode.getKey())?.getBoundingClientRect()\n const focusLinkParent: LinkNode = $findMatchingParent(focusNode, $isLinkNode)\n\n // Prevent link modal from showing if selection spans further than the link: https://github.com/facebook/lexical/issues/4064\n const badNode = selection\n .getNodes()\n .filter((node) => !$isLineBreakNode(node))\n .find((node) => {\n const linkNode = $findMatchingParent(node, $isLinkNode)\n return (\n (focusLinkParent && !focusLinkParent.is(linkNode)) ||\n (linkNode && !linkNode.is(focusLinkParent))\n )\n })\n\n if (focusLinkParent == null || badNode) {\n setIsLink(false)\n setIsAutoLink(false)\n setLinkUrl(null)\n setLinkLabel(null)\n setSelectedNodes([])\n return\n }\n\n // Initial state:\n const data: LinkFields & { text: string } = {\n doc: undefined,\n linkType: undefined,\n newTab: undefined,\n url: '',\n ...focusLinkParent.getFields(),\n text: focusLinkParent.getTextContent(),\n }\n\n if (focusLinkParent.getFields()?.linkType === 'custom') {\n setLinkUrl(focusLinkParent.getFields()?.url ?? null)\n setLinkLabel(null)\n } else {\n // internal link\n setLinkUrl(\n `/admin/collections/${focusLinkParent.getFields()?.doc?.relationTo}/${\n focusLinkParent.getFields()?.doc?.value\n }`,\n )\n\n const relatedField = config.collections.find(\n (coll) => coll.slug === focusLinkParent.getFields()?.doc?.relationTo,\n )\n if (!relatedField) {\n // Usually happens if the user removed all default fields. In this case, we let them specify the label or do not display the label at all.\n // label could be a virtual field the user added. This is useful if they want to use the link feature for things other than links.\n setLinkLabel(\n focusLinkParent.getFields()?.label ? String(focusLinkParent.getFields()?.label) : null,\n )\n setLinkUrl(\n focusLinkParent.getFields()?.url ? String(focusLinkParent.getFields()?.url) : null,\n )\n } else {\n const label = t('fields:linkedTo', {\n label: getTranslation(relatedField.labels.singular, i18n),\n }).replace(/<[^>]*>?/g, '')\n setLinkLabel(label)\n }\n }\n\n setStateData(data)\n setIsLink(true)\n setSelectedNodes(selection ? selection?.getNodes() : [])\n\n if ($isAutoLinkNode(focusLinkParent)) {\n setIsAutoLink(true)\n } else {\n setIsAutoLink(false)\n }\n }\n\n const editorElem = editorRef.current\n const nativeSelection = window.getSelection()\n const { activeElement } = document\n\n if (editorElem === null) {\n return\n }\n\n const rootElement = editor.getRootElement()\n\n if (\n selection !== null &&\n nativeSelection !== null &&\n rootElement !== null &&\n rootElement.contains(nativeSelection.anchorNode)\n ) {\n if (!selectedNodeDomRect) {\n // Get the DOM rect of the selected node using the native selection. This sometimes produces the wrong\n // result, which is why we use lexical's selection preferably.\n selectedNodeDomRect = nativeSelection.getRangeAt(0).getBoundingClientRect()\n }\n\n if (selectedNodeDomRect != null) {\n selectedNodeDomRect.y += 40\n setFloatingElemPositionForLinkEditor(selectedNodeDomRect, editorElem, anchorElem)\n }\n } else if (activeElement == null || activeElement.className !== 'link-input') {\n if (rootElement !== null) {\n setFloatingElemPositionForLinkEditor(null, editorElem, anchorElem)\n }\n setLinkUrl(null)\n setLinkLabel(null)\n }\n\n return true\n }, [anchorElem, editor, config, t, i18n])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n TOGGLE_LINK_WITH_MODAL_COMMAND,\n (payload: LinkPayload) => {\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, payload)\n\n // Now, open the modal\n updateLinkEditor()\n toggleModal(drawerSlug)\n\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, updateLinkEditor, toggleModal, drawerSlug])\n\n useEffect(() => {\n if (!isLink && editorRef) {\n editorRef.current.style.opacity = '0'\n editorRef.current.style.transform = 'translate(-10000px, -10000px)'\n }\n }, [isLink])\n\n useEffect(() => {\n const scrollerElem = anchorElem.parentElement\n\n const update = (): void => {\n editor.getEditorState().read(() => {\n void updateLinkEditor()\n })\n }\n\n window.addEventListener('resize', update)\n\n if (scrollerElem != null) {\n scrollerElem.addEventListener('scroll', update)\n }\n\n return () => {\n window.removeEventListener('resize', update)\n\n if (scrollerElem != null) {\n scrollerElem.removeEventListener('scroll', update)\n }\n }\n }, [anchorElem.parentElement, editor, updateLinkEditor])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n editorState.read(() => {\n void updateLinkEditor()\n })\n }),\n\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n () => {\n void updateLinkEditor()\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ESCAPE_COMMAND,\n () => {\n if (isLink) {\n setIsLink(false)\n setIsAutoLink(false)\n return true\n }\n return false\n },\n COMMAND_PRIORITY_HIGH,\n ),\n )\n }, [editor, updateLinkEditor, setIsLink, isLink])\n\n useEffect(() => {\n editor.getEditorState().read(() => {\n void updateLinkEditor()\n })\n }, [editor, updateLinkEditor])\n\n return (\n <React.Fragment>\n <div className=\"link-editor\" ref={editorRef}>\n <div className=\"link-input\">\n {linkUrl && linkUrl.length > 0 ? (\n <a href={linkUrl} rel=\"noopener noreferrer\" target=\"_blank\">\n {linkLabel != null && linkLabel.length > 0 ? linkLabel : linkUrl}\n </a>\n ) : linkLabel != null && linkLabel.length > 0 ? (\n <span className=\"link-input__label-pure\">{linkLabel}</span>\n ) : null}\n\n {editor.isEditable() && (\n <React.Fragment>\n <button\n aria-label=\"Edit link\"\n className=\"link-edit\"\n onClick={() => {\n toggleModal(drawerSlug)\n }}\n onMouseDown={(event) => {\n event.preventDefault()\n }}\n tabIndex={0}\n type=\"button\"\n />\n {!isAutoLink && (\n <button\n aria-label=\"Remove link\"\n className=\"link-trash\"\n onClick={() => {\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, null)\n }}\n onMouseDown={(event) => {\n event.preventDefault()\n }}\n tabIndex={0}\n type=\"button\"\n />\n )}\n </React.Fragment>\n )}\n </div>\n </div>\n <LinkDrawer\n drawerSlug={drawerSlug}\n handleModalSubmit={(fields: FormState, data: Data) => {\n closeModal(drawerSlug)\n\n const newLinkPayload = data as LinkFields & { text: string }\n\n const bareLinkFields: LinkFields = {\n ...newLinkPayload,\n }\n delete bareLinkFields.text\n\n // See: https://github.com/facebook/lexical/pull/5536. This updates autolink nodes to link nodes whenever a change was made (which is good!).\n editor.update(() => {\n const selection = $getSelection()\n let linkParent = null\n if ($isRangeSelection(selection)) {\n linkParent = getSelectedNode(selection).getParent()\n } else {\n if (selectedNodes.length) {\n linkParent = selectedNodes[0].getParent()\n }\n }\n\n if (linkParent && $isAutoLinkNode(linkParent)) {\n const linkNode = $createLinkNode({\n fields: bareLinkFields,\n })\n linkParent.replace(linkNode, true)\n }\n })\n\n // Needs to happen AFTER a potential auto link => link node conversion, as otherwise, the updated text to display may be lost due to\n // it being applied to the auto link node instead of the link node.\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, {\n fields: bareLinkFields,\n selectedNodes,\n text: newLinkPayload.text,\n })\n }}\n stateData={stateData}\n />\n </React.Fragment>\n )\n}\n"],"names":["facelessUIImport","useLexicalComposerContext","$findMatchingParent","mergeRegister","getTranslation","formatDrawerSlug","useConfig","useEditDepth","useTranslation","$isLineBreakNode","$getSelection","$isRangeSelection","COMMAND_PRIORITY_HIGH","COMMAND_PRIORITY_LOW","KEY_ESCAPE_COMMAND","SELECTION_CHANGE_COMMAND","React","useCallback","useEffect","useRef","useState","useEditorConfigContext","getSelectedNode","setFloatingElemPositionForLinkEditor","LinkDrawer","$isAutoLinkNode","$createLinkNode","$isLinkNode","TOGGLE_LINK_COMMAND","TOGGLE_LINK_WITH_MODAL_COMMAND","LinkEditor","anchorElem","useModal","editor","editorRef","linkUrl","setLinkUrl","linkLabel","setLinkLabel","uuid","config","i18n","t","stateData","setStateData","closeModal","toggleModal","editDepth","isLink","setIsLink","selectedNodes","setSelectedNodes","isAutoLink","setIsAutoLink","drawerSlug","slug","depth","updateLinkEditor","selection","selectedNodeDomRect","focusNode","getElementByKey","getKey","getBoundingClientRect","focusLinkParent","badNode","getNodes","filter","node","find","linkNode","is","data","doc","undefined","linkType","newTab","url","getFields","text","getTextContent","relationTo","value","relatedField","collections","coll","label","String","labels","singular","replace","editorElem","current","nativeSelection","window","getSelection","activeElement","document","rootElement","getRootElement","contains","anchorNode","getRangeAt","y","className","registerCommand","payload","dispatchCommand","style","opacity","transform","scrollerElem","parentElement","update","getEditorState","read","addEventListener","removeEventListener","registerUpdateListener","editorState","Fragment","div","ref","length","a","href","rel","target","span","isEditable","button","aria-label","onClick","onMouseDown","event","preventDefault","tabIndex","type","handleModalSubmit","fields","newLinkPayload","bareLinkFields","linkParent","getParent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AAKA,YAAYA,sBAAsB,qBAAoB;AACtD,SAASC,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,mBAAmB,EAAEC,aAAa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D,cAAc;YACnB;YACA,OAAOC,eAAe9D,IAAI;YAE1B,6IAA6I;YAC7I9C,OAAOgF,MAAM,CAAC;gBACZ,MAAMvD,YAAYhD;gBAClB,IAAIoI,aAAa;gBACjB,IAAInI,kBAAkB+C,YAAY;oBAChCoF,aAAaxH,gBAAgBoC,WAAWqF,SAAS;gBACnD,OAAO;oBACL,IAAI7F,cAAcyE,MAAM,EAAE;wBACxBmB,aAAa5F,aAAa,CAAC,EAAE,CAAC6F,SAAS;oBACzC;gBACF;gBAEA,IAAID,cAAcrH,gBAAgBqH,aAAa;oBAC7C,MAAMxE,WAAW5C,gBAAgB;wBAC/BiH,QAAQE;oBACV;oBACAC,WAAWpD,OAAO,CAACpB,UAAU;gBAC/B;YACF;YAEA,oIAAoI;YACpI,mEAAmE;YACnErC,OAAO0E,eAAe,CAAC/E,qBAAqB;gBAC1C+G,QAAQE;gBACR3F;gBACA6B,MAAM6D,eAAe7D,IAAI;YAC3B;QACF;QACApC,WAAWA;;AAInB"}
|
|
@@ -36,12 +36,20 @@ html[data-theme='light'] {
|
|
|
36
36
|
position: relative;
|
|
37
37
|
font-family: var(--font-body);
|
|
38
38
|
|
|
39
|
+
&__label-pure {
|
|
40
|
+
color: var(--color-base-1000);
|
|
41
|
+
margin-right: 15px;
|
|
42
|
+
display: block;
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
}
|
|
46
|
+
|
|
39
47
|
a {
|
|
40
48
|
text-decoration: none;
|
|
41
49
|
display: block;
|
|
42
50
|
white-space: nowrap;
|
|
43
51
|
overflow: hidden;
|
|
44
|
-
margin-right:
|
|
52
|
+
margin-right: 15px;
|
|
45
53
|
text-overflow: ellipsis;
|
|
46
54
|
color: var(--color-blue-600);
|
|
47
55
|
border-bottom: 1px dotted;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import type { I18n } from '@payloadcms/translations';
|
|
2
1
|
import type { SanitizedConfig } from 'payload/config';
|
|
3
|
-
import type {
|
|
2
|
+
import type { FieldWithRichTextRequiredEditor } from 'payload/types';
|
|
4
3
|
/**
|
|
5
4
|
* This function is run to enrich the basefields which every link has with potential, custom user-added fields.
|
|
6
5
|
*/
|
|
7
6
|
export declare function transformExtraFields(customFieldSchema: ((args: {
|
|
8
7
|
config: SanitizedConfig;
|
|
9
|
-
defaultFields:
|
|
10
|
-
|
|
11
|
-
}) => Field[]) | Field[], config: SanitizedConfig, i18n: I18n, enabledCollections?: false | string[], disabledCollections?: false | string[]): Field[];
|
|
8
|
+
defaultFields: FieldWithRichTextRequiredEditor[];
|
|
9
|
+
}) => FieldWithRichTextRequiredEditor[]) | FieldWithRichTextRequiredEditor[], config: SanitizedConfig, enabledCollections?: false | string[], disabledCollections?: false | string[]): FieldWithRichTextRequiredEditor[];
|
|
12
10
|
//# sourceMappingURL=utilities.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/link/plugins/floatingLinkEditor/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/link/plugins/floatingLinkEditor/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAA;AAIpE;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,iBAAiB,EACb,CAAC,CAAC,IAAI,EAAE;IACN,MAAM,EAAE,eAAe,CAAA;IACvB,aAAa,EAAE,+BAA+B,EAAE,CAAA;CACjD,KAAK,+BAA+B,EAAE,CAAC,GACxC,+BAA+B,EAAE,EACrC,MAAM,EAAE,eAAe,EACvB,kBAAkB,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,EACrC,mBAAmB,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,GACrC,+BAA+B,EAAE,CAkBnC"}
|
|
@@ -1,36 +1,18 @@
|
|
|
1
1
|
import { getBaseFields } from '../../drawer/baseFields.js';
|
|
2
2
|
/**
|
|
3
3
|
* This function is run to enrich the basefields which every link has with potential, custom user-added fields.
|
|
4
|
-
*/
|
|
5
|
-
export function transformExtraFields(customFieldSchema, config, i18n, enabledCollections, disabledCollections) {
|
|
4
|
+
*/ export function transformExtraFields(customFieldSchema, config, enabledCollections, disabledCollections) {
|
|
6
5
|
const baseFields = getBaseFields(config, enabledCollections, disabledCollections);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (!baseFields.find((baseField)=>!('name' in baseField) || baseField.name === field.name)) {
|
|
18
|
-
if (field.name !== 'fields' && field.type !== 'group') {
|
|
19
|
-
extraFields.push(field);
|
|
20
|
-
// Remove from fields from now, as they need to be part of the fields group below
|
|
21
|
-
fields.splice(fields.indexOf(field), 1);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (Array.isArray(customFieldSchema) || fields.length > 0) {
|
|
27
|
-
// find field with name 'fields' and add the extra fields to it
|
|
28
|
-
const fieldsField = fields.find((field)=>field.type === 'group' && field.name === 'fields');
|
|
29
|
-
if (!fieldsField) {
|
|
30
|
-
throw new Error('Could not find field with name "fields". This is required to add fields to the link field.');
|
|
31
|
-
}
|
|
32
|
-
fieldsField.fields = Array.isArray(fieldsField.fields) ? fieldsField.fields : [];
|
|
33
|
-
fieldsField.fields.push(...Array.isArray(customFieldSchema) ? customFieldSchema.concat(extraFields) : extraFields);
|
|
6
|
+
let fields;
|
|
7
|
+
if (typeof customFieldSchema === 'function') {
|
|
8
|
+
fields = customFieldSchema({
|
|
9
|
+
config,
|
|
10
|
+
defaultFields: baseFields
|
|
11
|
+
});
|
|
12
|
+
} else if (Array.isArray(customFieldSchema)) {
|
|
13
|
+
fields = customFieldSchema;
|
|
14
|
+
} else {
|
|
15
|
+
fields = baseFields;
|
|
34
16
|
}
|
|
35
17
|
return fields;
|
|
36
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/field/features/link/plugins/floatingLinkEditor/utilities.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/field/features/link/plugins/floatingLinkEditor/utilities.ts"],"sourcesContent":["import type { SanitizedConfig } from 'payload/config'\nimport type { FieldWithRichTextRequiredEditor } from 'payload/types'\n\nimport { getBaseFields } from '../../drawer/baseFields.js'\n\n/**\n * This function is run to enrich the basefields which every link has with potential, custom user-added fields.\n */\nexport function transformExtraFields(\n customFieldSchema:\n | ((args: {\n config: SanitizedConfig\n defaultFields: FieldWithRichTextRequiredEditor[]\n }) => FieldWithRichTextRequiredEditor[])\n | FieldWithRichTextRequiredEditor[],\n config: SanitizedConfig,\n enabledCollections?: false | string[],\n disabledCollections?: false | string[],\n): FieldWithRichTextRequiredEditor[] {\n const baseFields: FieldWithRichTextRequiredEditor[] = getBaseFields(\n config,\n enabledCollections,\n disabledCollections,\n )\n\n let fields: FieldWithRichTextRequiredEditor[]\n\n if (typeof customFieldSchema === 'function') {\n fields = customFieldSchema({ config, defaultFields: baseFields })\n } else if (Array.isArray(customFieldSchema)) {\n fields = customFieldSchema\n } else {\n fields = baseFields\n }\n\n return fields\n}\n"],"names":["getBaseFields","transformExtraFields","customFieldSchema","config","enabledCollections","disabledCollections","baseFields","fields","defaultFields","Array","isArray"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,aAAa,QAAQ,6BAA4B;AAE1D;;CAEC,GACD,OAAO,SAASC,qBACdC,iBAKqC,EACrCC,MAAuB,EACvBC,kBAAqC,EACrCC,mBAAsC;IAEtC,MAAMC,aAAgDN,cACpDG,QACAC,oBACAC;IAGF,IAAIE;IAEJ,IAAI,OAAOL,sBAAsB,YAAY;QAC3CK,SAASL,kBAAkB;YAAEC;YAAQK,eAAeF;QAAW;IACjE,OAAO,IAAIG,MAAMC,OAAO,CAACR,oBAAoB;QAC3CK,SAASL;IACX,OAAO;QACLK,SAASD;IACX;IAEA,OAAOC;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/link/plugins/link/index.tsx"],"names":[],"mappings":"AAkBA,wBAAgB,UAAU,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/link/plugins/link/index.tsx"],"names":[],"mappings":"AAkBA,wBAAgB,UAAU,IAAI,IAAI,CA2DjC"}
|
|
@@ -14,12 +14,6 @@ export function LinkPlugin() {
|
|
|
14
14
|
throw new Error('LinkPlugin: LinkNode not registered on editor');
|
|
15
15
|
}
|
|
16
16
|
return mergeRegister(editor.registerCommand(TOGGLE_LINK_COMMAND, (payload)=>{
|
|
17
|
-
// validate
|
|
18
|
-
if (payload?.fields.linkType === 'custom') {
|
|
19
|
-
if (!(validateUrl === undefined || validateUrl(payload?.fields.url))) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
17
|
toggleLink(payload);
|
|
24
18
|
return true;
|
|
25
19
|
}, COMMAND_PRIORITY_LOW), validateUrl !== undefined ? editor.registerCommand(PASTE_COMMAND, (event)=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/field/features/link/plugins/link/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isElementNode,\n $isRangeSelection,\n COMMAND_PRIORITY_LOW,\n PASTE_COMMAND,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { LinkFields } from '../../nodes/types.js'\nimport type { LinkPayload } from '../floatingLinkEditor/types.js'\n\nimport { validateUrl } from '../../../../lexical/utils/url.js'\nimport { LinkNode, TOGGLE_LINK_COMMAND, toggleLink } from '../../nodes/LinkNode.js'\n\nexport function LinkPlugin(): null {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n if (!editor.hasNodes([LinkNode])) {\n throw new Error('LinkPlugin: LinkNode not registered on editor')\n }\n return mergeRegister(\n editor.registerCommand(\n TOGGLE_LINK_COMMAND,\n (payload: LinkPayload) => {\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/field/features/link/plugins/link/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isElementNode,\n $isRangeSelection,\n COMMAND_PRIORITY_LOW,\n PASTE_COMMAND,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport type { LinkFields } from '../../nodes/types.js'\nimport type { LinkPayload } from '../floatingLinkEditor/types.js'\n\nimport { validateUrl } from '../../../../lexical/utils/url.js'\nimport { LinkNode, TOGGLE_LINK_COMMAND, toggleLink } from '../../nodes/LinkNode.js'\n\nexport function LinkPlugin(): null {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n if (!editor.hasNodes([LinkNode])) {\n throw new Error('LinkPlugin: LinkNode not registered on editor')\n }\n return mergeRegister(\n editor.registerCommand(\n TOGGLE_LINK_COMMAND,\n (payload: LinkPayload) => {\n toggleLink(payload)\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n validateUrl !== undefined\n ? editor.registerCommand(\n PASTE_COMMAND,\n (event) => {\n const selection = $getSelection()\n if (\n !$isRangeSelection(selection) ||\n selection.isCollapsed() ||\n !(event instanceof ClipboardEvent) ||\n event.clipboardData == null\n ) {\n return false\n }\n const clipboardText = event.clipboardData.getData('text')\n if (!validateUrl(clipboardText)) {\n return false\n }\n // If we select nodes that are elements then avoid applying the link.\n if (!selection.getNodes().some((node) => $isElementNode(node))) {\n const linkFields: LinkFields = {\n doc: null,\n linkType: 'custom',\n newTab: false,\n url: clipboardText,\n }\n editor.dispatchCommand(TOGGLE_LINK_COMMAND, {\n fields: linkFields,\n text: null,\n })\n event.preventDefault()\n return true\n }\n return false\n },\n COMMAND_PRIORITY_LOW,\n )\n : () => {\n // Don't paste arbitrary text as a link when there's no validate function\n },\n )\n }, [editor])\n\n return null\n}\n"],"names":["useLexicalComposerContext","mergeRegister","$getSelection","$isElementNode","$isRangeSelection","COMMAND_PRIORITY_LOW","PASTE_COMMAND","useEffect","validateUrl","LinkNode","TOGGLE_LINK_COMMAND","toggleLink","LinkPlugin","editor","hasNodes","Error","registerCommand","payload","undefined","event","selection","isCollapsed","ClipboardEvent","clipboardData","clipboardText","getData","getNodes","some","node","linkFields","doc","linkType","newTab","url","dispatchCommand","fields","text","preventDefault"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA;AACA,SAASA,yBAAyB,QAAQ,2CAA0C;AACpF,SAASC,aAAa,QAAQ,iBAAgB;AAC9C,SACEC,aAAa,EACbC,cAAc,EACdC,iBAAiB,EACjBC,oBAAoB,EACpBC,aAAa,QACR,UAAS;AAChB,SAASC,SAAS,QAAQ,QAAO;AAKjC,SAASC,WAAW,QAAQ,mCAAkC;AAC9D,SAASC,QAAQ,EAAEC,mBAAmB,EAAEC,UAAU,QAAQ,0BAAyB;AAEnF,OAAO,SAASC;IACd,MAAM,CAACC,OAAO,GAAGb;IAEjBO,UAAU;QACR,IAAI,CAACM,OAAOC,QAAQ,CAAC;YAACL;SAAS,GAAG;YAChC,MAAM,IAAIM,MAAM;QAClB;QACA,OAAOd,cACLY,OAAOG,eAAe,CACpBN,qBACA,CAACO;YACCN,WAAWM;YACX,OAAO;QACT,GACAZ,uBAEFG,gBAAgBU,YACZL,OAAOG,eAAe,CACpBV,eACA,CAACa;YACC,MAAMC,YAAYlB;YAClB,IACE,CAACE,kBAAkBgB,cACnBA,UAAUC,WAAW,MACrB,CAAEF,CAAAA,iBAAiBG,cAAa,KAChCH,MAAMI,aAAa,IAAI,MACvB;gBACA,OAAO;YACT;YACA,MAAMC,gBAAgBL,MAAMI,aAAa,CAACE,OAAO,CAAC;YAClD,IAAI,CAACjB,YAAYgB,gBAAgB;gBAC/B,OAAO;YACT;YACA,qEAAqE;YACrE,IAAI,CAACJ,UAAUM,QAAQ,GAAGC,IAAI,CAAC,CAACC,OAASzB,eAAeyB,QAAQ;gBAC9D,MAAMC,aAAyB;oBAC7BC,KAAK;oBACLC,UAAU;oBACVC,QAAQ;oBACRC,KAAKT;gBACP;gBACAX,OAAOqB,eAAe,CAACxB,qBAAqB;oBAC1CyB,QAAQN;oBACRO,MAAM;gBACR;gBACAjB,MAAMkB,cAAc;gBACpB,OAAO;YACT;YACA,OAAO;QACT,GACAhC,wBAEF;QACE,yEAAyE;QAC3E;IAER,GAAG;QAACQ;KAAO;IAEX,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"populationPromise.d.ts","sourceRoot":"","sources":["../../../../src/field/features/link/populationPromise.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"populationPromise.d.ts","sourceRoot":"","sources":["../../../../src/field/features/link/populationPromise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAI1D,eAAO,MAAM,wBAAwB,UAC5B,sBAAsB,KAC5B,kBAAkB,kBAAkB,CAyCtC,CAAA"}
|
|
@@ -1,45 +1,27 @@
|
|
|
1
|
-
import { sanitizeFields } from 'payload/config';
|
|
2
|
-
import { deepCopyObject } from 'payload/utilities';
|
|
3
1
|
import { recurseNestedFields } from '../../../populate/recurseNestedFields.js';
|
|
4
|
-
import { transformExtraFields } from './plugins/floatingLinkEditor/utilities.js';
|
|
5
2
|
export const linkPopulationPromiseHOC = (props)=>{
|
|
6
3
|
return ({ context, currentDepth, depth, editorPopulationPromises, fieldPromises, findMany, flattenLocales, node, overrideAccess, populationPromises, req, showHiddenFields })=>{
|
|
7
|
-
|
|
8
|
-
const payloadConfig = req.payload.config;
|
|
9
|
-
const validRelationships = payloadConfig.collections.map((c)=>c.slug) || [];
|
|
10
|
-
const transformedFields = transformExtraFields(deepCopyObject(props.fields), payloadConfig, req.i18n, props.enabledCollections, props.disabledCollections);
|
|
11
|
-
// TODO: Sanitize & transform ahead of time! On startup!
|
|
12
|
-
const sanitizedFields = sanitizeFields({
|
|
13
|
-
config: payloadConfig,
|
|
14
|
-
fields: transformedFields,
|
|
15
|
-
requireFieldLevelRichTextEditor: true,
|
|
16
|
-
validRelationships
|
|
17
|
-
});
|
|
18
|
-
if (!sanitizedFields?.length) {
|
|
4
|
+
if (!props.fields?.length) {
|
|
19
5
|
return;
|
|
20
6
|
}
|
|
21
7
|
/**
|
|
22
8
|
* Should populate all fields, including the doc field (for internal links), as it's treated like a normal field
|
|
23
|
-
*/ if (Array.isArray(
|
|
9
|
+
*/ if (Array.isArray(props.fields)) {
|
|
24
10
|
recurseNestedFields({
|
|
25
11
|
context,
|
|
26
12
|
currentDepth,
|
|
27
|
-
data:
|
|
28
|
-
fields: node.fields
|
|
29
|
-
},
|
|
13
|
+
data: node.fields,
|
|
30
14
|
depth,
|
|
31
15
|
editorPopulationPromises,
|
|
32
16
|
fieldPromises,
|
|
33
|
-
fields:
|
|
17
|
+
fields: props.fields,
|
|
34
18
|
findMany,
|
|
35
19
|
flattenLocales,
|
|
36
20
|
overrideAccess,
|
|
37
21
|
populationPromises,
|
|
38
22
|
req,
|
|
39
23
|
showHiddenFields,
|
|
40
|
-
siblingDoc:
|
|
41
|
-
fields: node.fields
|
|
42
|
-
}
|
|
24
|
+
siblingDoc: node.fields
|
|
43
25
|
});
|
|
44
26
|
}
|
|
45
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/field/features/link/populationPromise.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/link/populationPromise.ts"],"sourcesContent":["import type { PopulationPromise } from '../types.js'\nimport type { LinkFeatureServerProps } from './feature.server.js'\nimport type { SerializedLinkNode } from './nodes/types.js'\n\nimport { recurseNestedFields } from '../../../populate/recurseNestedFields.js'\n\nexport const linkPopulationPromiseHOC = (\n props: LinkFeatureServerProps,\n): PopulationPromise<SerializedLinkNode> => {\n return ({\n context,\n currentDepth,\n depth,\n editorPopulationPromises,\n fieldPromises,\n findMany,\n flattenLocales,\n node,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n }) => {\n if (!props.fields?.length) {\n return\n }\n\n /**\n * Should populate all fields, including the doc field (for internal links), as it's treated like a normal field\n */\n if (Array.isArray(props.fields)) {\n recurseNestedFields({\n context,\n currentDepth,\n data: node.fields,\n depth,\n editorPopulationPromises,\n fieldPromises,\n fields: props.fields,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc: node.fields,\n })\n }\n }\n}\n"],"names":["recurseNestedFields","linkPopulationPromiseHOC","props","context","currentDepth","depth","editorPopulationPromises","fieldPromises","findMany","flattenLocales","node","overrideAccess","populationPromises","req","showHiddenFields","fields","length","Array","isArray","data","siblingDoc"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,mBAAmB,QAAQ,2CAA0C;AAE9E,OAAO,MAAMC,2BAA2B,CACtCC;IAEA,OAAO,CAAC,EACNC,OAAO,EACPC,YAAY,EACZC,KAAK,EACLC,wBAAwB,EACxBC,aAAa,EACbC,QAAQ,EACRC,cAAc,EACdC,IAAI,EACJC,cAAc,EACdC,kBAAkB,EAClBC,GAAG,EACHC,gBAAgB,EACjB;QACC,IAAI,CAACZ,MAAMa,MAAM,EAAEC,QAAQ;YACzB;QACF;QAEA;;KAEC,GACD,IAAIC,MAAMC,OAAO,CAAChB,MAAMa,MAAM,GAAG;YAC/Bf,oBAAoB;gBAClBG;gBACAC;gBACAe,MAAMT,KAAKK,MAAM;gBACjBV;gBACAC;gBACAC;gBACAQ,QAAQb,MAAMa,MAAM;gBACpBP;gBACAC;gBACAE;gBACAC;gBACAC;gBACAC;gBACAM,YAAYV,KAAKK,MAAM;YACzB;QACF;IACF;AACF,EAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { NodeValidation } from '../types.js';
|
|
2
|
+
import type { LinkFeatureServerProps } from './feature.server.js';
|
|
3
|
+
import type { SerializedAutoLinkNode, SerializedLinkNode } from './nodes/types.js';
|
|
4
|
+
export declare const linkValidation: (props: LinkFeatureServerProps) => NodeValidation<SerializedAutoLinkNode | SerializedLinkNode>;
|
|
5
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../../src/field/features/link/validate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,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,KAE5B,eAAe,sBAAsB,GAAG,kBAAkB,CAuC5D,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema';
|
|
2
|
+
export const linkValidation = (props)=>{
|
|
3
|
+
return async ({ node, validation: { options: { id, operation, preferences, req } } })=>{
|
|
4
|
+
/**
|
|
5
|
+
* Run buildStateFromSchema as that properly validates link fields and link sub-fields
|
|
6
|
+
*/ const data = {
|
|
7
|
+
...node.fields,
|
|
8
|
+
text: 'ignored'
|
|
9
|
+
};
|
|
10
|
+
const result = await buildStateFromSchema({
|
|
11
|
+
id,
|
|
12
|
+
data,
|
|
13
|
+
fieldSchema: props.fields,
|
|
14
|
+
operation: operation === 'create' || operation === 'update' ? operation : 'update',
|
|
15
|
+
preferences,
|
|
16
|
+
req,
|
|
17
|
+
siblingData: data
|
|
18
|
+
});
|
|
19
|
+
let errorPaths = [];
|
|
20
|
+
for(const fieldKey in result){
|
|
21
|
+
if (result[fieldKey].errorPaths) {
|
|
22
|
+
errorPaths = errorPaths.concat(result[fieldKey].errorPaths);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (errorPaths.length) {
|
|
26
|
+
return 'Link fields validation failed: ' + errorPaths.join(', ');
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/field/features/link/validate.ts"],"sourcesContent":["import type { FieldWithRichTextRequiredEditor } from 'payload/types'\n\nimport { buildStateFromSchema } from '@payloadcms/ui/forms/buildStateFromSchema'\n\nimport type { NodeValidation } from '../types.js'\nimport type { LinkFeatureServerProps } from './feature.server.js'\nimport type { SerializedAutoLinkNode, SerializedLinkNode } from './nodes/types.js'\n\nexport const linkValidation = (\n props: LinkFeatureServerProps,\n // eslint-disable-next-line @typescript-eslint/no-duplicate-type-constituents\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 data = {\n ...node.fields,\n text: 'ignored',\n }\n\n const result = await buildStateFromSchema({\n id,\n data,\n fieldSchema: props.fields as FieldWithRichTextRequiredEditor[], // Sanitized in feature.server.ts\n operation: operation === 'create' || operation === 'update' ? operation : 'update',\n preferences,\n req,\n siblingData: data,\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 'Link fields validation failed: ' + errorPaths.join(', ')\n }\n\n return true\n }\n}\n"],"names":["buildStateFromSchema","linkValidation","props","node","validation","options","id","operation","preferences","req","data","fields","text","result","fieldSchema","siblingData","errorPaths","fieldKey","concat","length","join"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,oBAAoB,QAAQ,4CAA2C;AAMhF,OAAO,MAAMC,iBAAiB,CAC5BC;IAGA,OAAO,OAAO,EACZC,IAAI,EACJC,YAAY,EACVC,SAAS,EAAEC,EAAE,EAAEC,SAAS,EAAEC,WAAW,EAAEC,GAAG,EAAE,EAC7C,EACF;QACC;;KAEC,GAED,MAAMC,OAAO;YACX,GAAGP,KAAKQ,MAAM;YACdC,MAAM;QACR;QAEA,MAAMC,SAAS,MAAMb,qBAAqB;YACxCM;YACAI;YACAI,aAAaZ,MAAMS,MAAM;YACzBJ,WAAWA,cAAc,YAAYA,cAAc,WAAWA,YAAY;YAC1EC;YACAC;YACAM,aAAaL;QACf;QAEA,IAAIM,aAAa,EAAE;QACnB,IAAK,MAAMC,YAAYJ,OAAQ;YAC7B,IAAIA,MAAM,CAACI,SAAS,CAACD,UAAU,EAAE;gBAC/BA,aAAaA,WAAWE,MAAM,CAACL,MAAM,CAACI,SAAS,CAACD,UAAU;YAC5D;QACF;QAEA,IAAIA,WAAWG,MAAM,EAAE;YACrB,OAAO,oCAAoCH,WAAWI,IAAI,CAAC;QAC7D;QAEA,OAAO;IACT;AACF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/relationship/nodes/components/RelationshipComponent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"RelationshipComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/field/features/relationship/nodes/components/RelationshipComponent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAoBhD,OAAO,KAA+D,MAAM,OAAO,CAAA;AAEnF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAK9D,OAAO,cAAc,CAAA;AAQrB,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,gBAAgB,CAAA;IACtB,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AA4JD,eAAO,MAAM,qBAAqB,UAAW,KAAK,KAAG,MAAM,SAE1D,CAAA"}
|