@payloadcms/richtext-lexical 3.73.0-canary.4 → 3.73.0-internal.6ea481d

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/field/Diff/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAA;AAI/D,OAAO,cAAc,CAAA;AACrB,OAAO,gBAAgB,CAAA;AAgBvB,eAAO,MAAM,oBAAoB,EAAE,gCA0DlC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/field/Diff/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,SAAS,CAAA;AAI/D,OAAO,cAAc,CAAA;AACrB,OAAO,gBAAgB,CAAA;AAqBvB,eAAO,MAAM,oBAAoB,EAAE,gCAiGlC,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { FieldDiffContainer, getHTMLDiffComponents } from '@payloadcms/ui/rsc';
3
3
  import '../bundled.css';
4
+ import { formatAdminURL } from 'payload/shared';
4
5
  import React from 'react';
5
6
  import { convertLexicalToHTMLAsync } from '../../features/converters/lexicalToHtml/async/index.js';
6
7
  import { getPayloadPopulateFn } from '../../features/converters/utilities/payloadPopulateFn.js';
@@ -20,11 +21,45 @@ export const LexicalDiffComponent = async args => {
20
21
  req,
21
22
  versionValue: valueTo
22
23
  } = args;
24
+ const internalDocToHref = async ({
25
+ linkNode,
26
+ populate
27
+ }) => {
28
+ if (!linkNode.fields.doc) {
29
+ return '#';
30
+ }
31
+ const {
32
+ relationTo,
33
+ value
34
+ } = linkNode.fields.doc;
35
+ let docId;
36
+ if (typeof value === 'object' && value !== null) {
37
+ docId = value.id;
38
+ } else if (populate && typeof value !== 'object') {
39
+ const doc = await populate({
40
+ id: value,
41
+ collectionSlug: relationTo
42
+ });
43
+ if (!doc || !doc.id) {
44
+ return '#';
45
+ }
46
+ docId = doc.id;
47
+ } else {
48
+ docId = value;
49
+ }
50
+ return formatAdminURL({
51
+ adminRoute: req.payload.config.routes.admin,
52
+ path: `/collections/${relationTo}/${docId}`,
53
+ serverURL: req.payload.config.serverURL
54
+ });
55
+ };
23
56
  const converters = ({
24
57
  defaultConverters
25
58
  }) => ({
26
59
  ...defaultConverters,
27
- ...LinkDiffHTMLConverterAsync({}),
60
+ ...LinkDiffHTMLConverterAsync({
61
+ internalDocToHref
62
+ }),
28
63
  ...ListItemDiffHTMLConverterAsync,
29
64
  ...UploadDiffHTMLConverterAsync({
30
65
  i18n,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["FieldDiffContainer","getHTMLDiffComponents","React","convertLexicalToHTMLAsync","getPayloadPopulateFn","LinkDiffHTMLConverterAsync","ListItemDiffHTMLConverterAsync","RelationshipDiffHTMLConverterAsync","UnknownDiffHTMLConverterAsync","UploadDiffHTMLConverterAsync","baseClass","LexicalDiffComponent","args","comparisonValue","valueFrom","field","i18n","locale","nestingLevel","req","versionValue","valueTo","converters","defaultConverters","payloadPopulateFn","currentDepth","depth","fromHTML","data","disableContainer","populate","toHTML","From","To","length","_jsx","className","label"],"sources":["../../../src/field/Diff/index.tsx"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\nimport type { RichTextFieldDiffServerComponent } from 'payload'\n\nimport { FieldDiffContainer, getHTMLDiffComponents } from '@payloadcms/ui/rsc'\n\nimport './index.scss'\nimport '../bundled.css'\n\nimport React from 'react'\n\nimport type { HTMLConvertersFunctionAsync } from '../../features/converters/lexicalToHtml/async/types.js'\n\nimport { convertLexicalToHTMLAsync } from '../../features/converters/lexicalToHtml/async/index.js'\nimport { getPayloadPopulateFn } from '../../features/converters/utilities/payloadPopulateFn.js'\nimport { LinkDiffHTMLConverterAsync } from './converters/link.js'\nimport { ListItemDiffHTMLConverterAsync } from './converters/listitem/index.js'\nimport { RelationshipDiffHTMLConverterAsync } from './converters/relationship/index.js'\nimport { UnknownDiffHTMLConverterAsync } from './converters/unknown/index.js'\nimport { UploadDiffHTMLConverterAsync } from './converters/upload/index.js'\n\nconst baseClass = 'lexical-diff'\n\nexport const LexicalDiffComponent: RichTextFieldDiffServerComponent = async (args) => {\n const {\n comparisonValue: valueFrom,\n field,\n i18n,\n locale,\n nestingLevel,\n req,\n versionValue: valueTo,\n } = args\n\n const converters: HTMLConvertersFunctionAsync = ({ defaultConverters }) => ({\n ...defaultConverters,\n ...LinkDiffHTMLConverterAsync({}),\n ...ListItemDiffHTMLConverterAsync,\n ...UploadDiffHTMLConverterAsync({ i18n, req }),\n ...RelationshipDiffHTMLConverterAsync({ i18n, req }),\n ...UnknownDiffHTMLConverterAsync({ i18n, req }),\n })\n\n const payloadPopulateFn = await getPayloadPopulateFn({\n currentDepth: 0,\n depth: 1,\n req,\n })\n const fromHTML = await convertLexicalToHTMLAsync({\n converters,\n data: valueFrom as SerializedEditorState,\n disableContainer: true,\n populate: payloadPopulateFn,\n })\n\n const toHTML = await convertLexicalToHTMLAsync({\n converters,\n data: valueTo as SerializedEditorState,\n disableContainer: true,\n populate: payloadPopulateFn,\n })\n\n const { From, To } = getHTMLDiffComponents({\n // Ensure empty paragraph is displayed for empty rich text fields - otherwise, toHTML may be displayed in the wrong column\n fromHTML: fromHTML?.length ? fromHTML : '<p></p>',\n toHTML: toHTML?.length ? toHTML : '<p></p>',\n })\n\n return (\n <FieldDiffContainer\n className={baseClass}\n From={From}\n i18n={i18n}\n label={{\n label: field.label,\n locale,\n }}\n nestingLevel={nestingLevel}\n To={To}\n />\n )\n}\n"],"mappings":";AAGA,SAASA,kBAAkB,EAAEC,qBAAqB,QAAQ;AAG1D,OAAO;AAEP,OAAOC,KAAA,MAAW;AAIlB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,8BAA8B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,CAACnC,kBAAA;IACCoC,SAAA,EAAW1B,SAAA;IACXsB,IAAA,EAAMA,IAAA;IACNhB,IAAA,EAAMA,IAAA;IACNqB,KAAA,EAAO;MACLA,KAAA,EAAOtB,KAAA,CAAMsB,KAAK;MAClBpB;IACF;IACAC,YAAA,EAAcA,YAAA;IACde,EAAA,EAAIA;;AAGV","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["FieldDiffContainer","getHTMLDiffComponents","formatAdminURL","React","convertLexicalToHTMLAsync","getPayloadPopulateFn","LinkDiffHTMLConverterAsync","ListItemDiffHTMLConverterAsync","RelationshipDiffHTMLConverterAsync","UnknownDiffHTMLConverterAsync","UploadDiffHTMLConverterAsync","baseClass","LexicalDiffComponent","args","comparisonValue","valueFrom","field","i18n","locale","nestingLevel","req","versionValue","valueTo","internalDocToHref","linkNode","populate","fields","doc","relationTo","value","docId","id","collectionSlug","adminRoute","payload","config","routes","admin","path","serverURL","converters","defaultConverters","payloadPopulateFn","currentDepth","depth","fromHTML","data","disableContainer","toHTML","From","To","length","_jsx","className","label"],"sources":["../../../src/field/Diff/index.tsx"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\nimport type { RichTextFieldDiffServerComponent } from 'payload'\n\nimport { FieldDiffContainer, getHTMLDiffComponents } from '@payloadcms/ui/rsc'\n\nimport './index.scss'\nimport '../bundled.css'\n\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport type {\n HTMLConvertersFunctionAsync,\n HTMLPopulateFn,\n} from '../../features/converters/lexicalToHtml/async/types.js'\nimport type { SerializedLinkNode } from '../../nodeTypes.js'\n\nimport { convertLexicalToHTMLAsync } from '../../features/converters/lexicalToHtml/async/index.js'\nimport { getPayloadPopulateFn } from '../../features/converters/utilities/payloadPopulateFn.js'\nimport { LinkDiffHTMLConverterAsync } from './converters/link.js'\nimport { ListItemDiffHTMLConverterAsync } from './converters/listitem/index.js'\nimport { RelationshipDiffHTMLConverterAsync } from './converters/relationship/index.js'\nimport { UnknownDiffHTMLConverterAsync } from './converters/unknown/index.js'\nimport { UploadDiffHTMLConverterAsync } from './converters/upload/index.js'\n\nconst baseClass = 'lexical-diff'\n\nexport const LexicalDiffComponent: RichTextFieldDiffServerComponent = async (args) => {\n const {\n comparisonValue: valueFrom,\n field,\n i18n,\n locale,\n nestingLevel,\n req,\n versionValue: valueTo,\n } = args\n\n const internalDocToHref = async ({\n linkNode,\n populate,\n }: {\n linkNode: SerializedLinkNode\n populate?: HTMLPopulateFn\n }) => {\n if (!linkNode.fields.doc) {\n return '#'\n }\n\n const { relationTo, value } = linkNode.fields.doc\n\n let docId: number | string\n\n if (typeof value === 'object' && value !== null) {\n docId = value.id\n } else if (populate && typeof value !== 'object') {\n const doc = await populate({\n id: value,\n collectionSlug: relationTo,\n })\n\n if (!doc || !doc.id) {\n return '#'\n }\n\n docId = doc.id\n } else {\n docId = value\n }\n\n return formatAdminURL({\n adminRoute: req.payload.config.routes.admin,\n path: `/collections/${relationTo}/${docId}`,\n serverURL: req.payload.config.serverURL,\n })\n }\n\n const converters: HTMLConvertersFunctionAsync = ({ defaultConverters }) => ({\n ...defaultConverters,\n ...LinkDiffHTMLConverterAsync({ internalDocToHref }),\n ...ListItemDiffHTMLConverterAsync,\n ...UploadDiffHTMLConverterAsync({ i18n, req }),\n ...RelationshipDiffHTMLConverterAsync({ i18n, req }),\n ...UnknownDiffHTMLConverterAsync({ i18n, req }),\n })\n\n const payloadPopulateFn = await getPayloadPopulateFn({\n currentDepth: 0,\n depth: 1,\n req,\n })\n const fromHTML = await convertLexicalToHTMLAsync({\n converters,\n data: valueFrom as SerializedEditorState,\n disableContainer: true,\n populate: payloadPopulateFn,\n })\n\n const toHTML = await convertLexicalToHTMLAsync({\n converters,\n data: valueTo as SerializedEditorState,\n disableContainer: true,\n populate: payloadPopulateFn,\n })\n\n const { From, To } = getHTMLDiffComponents({\n // Ensure empty paragraph is displayed for empty rich text fields - otherwise, toHTML may be displayed in the wrong column\n fromHTML: fromHTML?.length ? fromHTML : '<p></p>',\n toHTML: toHTML?.length ? toHTML : '<p></p>',\n })\n\n return (\n <FieldDiffContainer\n className={baseClass}\n From={From}\n i18n={i18n}\n label={{\n label: field.label,\n locale,\n }}\n nestingLevel={nestingLevel}\n To={To}\n />\n )\n}\n"],"mappings":";AAGA,SAASA,kBAAkB,EAAEC,qBAAqB,QAAQ;AAG1D,OAAO;AAEP,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAQlB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,0BAA0B,QAAQ;AAC3C,SAASC,8BAA8B,QAAQ;AAC/C,SAASC,kCAAkC,QAAQ;AACnD,SAASC,6BAA6B,QAAQ;AAC9C,SAASC,4BAA4B,QAAQ;AAE7C,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,oBAAA,GAAyD,MAAOC,IAAA;EAC3E,MAAM;IACJC,eAAA,EAAiBC,SAAS;IAC1BC,KAAK;IACLC,IAAI;IACJC,MAAM;IACNC,YAAY;IACZC,GAAG;IACHC,YAAA,EAAcC;EAAO,CACtB,GAAGT,IAAA;EAEJ,MAAMU,iBAAA,GAAoB,MAAAA,CAAO;IAC/BC,QAAQ;IACRC;EAAQ,CAIT;IACC,IAAI,CAACD,QAAA,CAASE,MAAM,CAACC,GAAG,EAAE;MACxB,OAAO;IACT;IAEA,MAAM;MAAEC,UAAU;MAAEC;IAAK,CAAE,GAAGL,QAAA,CAASE,MAAM,CAACC,GAAG;IAEjD,IAAIG,KAAA;IAEJ,IAAI,OAAOD,KAAA,KAAU,YAAYA,KAAA,KAAU,MAAM;MAC/CC,KAAA,GAAQD,KAAA,CAAME,EAAE;IAClB,OAAO,IAAIN,QAAA,IAAY,OAAOI,KAAA,KAAU,UAAU;MAChD,MAAMF,GAAA,GAAM,MAAMF,QAAA,CAAS;QACzBM,EAAA,EAAIF,KAAA;QACJG,cAAA,EAAgBJ;MAClB;MAEA,IAAI,CAACD,G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AAA,EAAQA,MAAA,EAAQG,MAAA,GAASH,MAAA,GAAS;EACpC;EAEA,oBACEI,IAAA,CAACpD,kBAAA;IACCqD,SAAA,EAAW1C,SAAA;IACXsC,IAAA,EAAMA,IAAA;IACNhC,IAAA,EAAMA,IAAA;IACNqC,KAAA,EAAO;MACLA,KAAA,EAAOtC,KAAA,CAAMsC,KAAK;MAClBpC;IACF;IACAC,YAAA,EAAcA,YAAA;IACd+B,EAAA,EAAIA;;AAGV","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-lexical",
3
- "version": "3.73.0-canary.4",
3
+ "version": "3.73.0-internal.6ea481d",
4
4
  "description": "The officially supported Lexical richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -374,8 +374,8 @@
374
374
  "react-error-boundary": "4.1.2",
375
375
  "ts-essentials": "10.0.3",
376
376
  "uuid": "10.0.0",
377
- "@payloadcms/translations": "3.73.0-canary.4",
378
- "@payloadcms/ui": "3.73.0-canary.4"
377
+ "@payloadcms/translations": "3.73.0-internal.6ea481d",
378
+ "@payloadcms/ui": "3.73.0-internal.6ea481d"
379
379
  },
380
380
  "devDependencies": {
381
381
  "@babel/cli": "7.27.2",
@@ -395,15 +395,15 @@
395
395
  "esbuild-sass-plugin": "3.3.1",
396
396
  "swc-plugin-transform-remove-imports": "8.3.0",
397
397
  "@payloadcms/eslint-config": "3.28.0",
398
- "payload": "3.73.0-canary.4"
398
+ "payload": "3.73.0-internal.6ea481d"
399
399
  },
400
400
  "peerDependencies": {
401
401
  "@faceless-ui/modal": "3.0.0",
402
402
  "@faceless-ui/scroll-info": "2.0.0",
403
403
  "react": "^19.0.1 || ^19.1.2 || ^19.2.1",
404
404
  "react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
405
- "@payloadcms/next": "3.73.0-canary.4",
406
- "payload": "3.73.0-canary.4"
405
+ "@payloadcms/next": "3.73.0-internal.6ea481d",
406
+ "payload": "3.73.0-internal.6ea481d"
407
407
  },
408
408
  "engines": {
409
409
  "node": "^18.20.2 || >=20.9.0"