@payloadcms/richtext-lexical 3.69.0-internal.2883df2 → 3.69.0-internal.35bf893

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":"rscEntry.d.ts","sourceRoot":"","sources":["../../src/cell/rscEntry.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAuB3D,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA0ElE,CAAA"}
1
+ {"version":3,"file":"rscEntry.d.ts","sourceRoot":"","sources":["../../src/cell/rscEntry.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAuB3D,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA4ElE,CAAA"}
@@ -39,6 +39,7 @@ export const RscEntryLexicalCell = props => {
39
39
  const classNameFromConfigContext = admin && 'className' in admin ? admin.className : undefined;
40
40
  const className = classNameFromProps || (field.admin && 'className' in field.admin ? field.admin.className : null) || classNameFromConfigContext;
41
41
  const adminRoute = payload.config.routes.admin;
42
+ const serverURL = payload.config.serverURL;
42
43
  const onClick = onClickFromProps;
43
44
  let WrapElement = 'span';
44
45
  const wrapElementProps = {
@@ -49,7 +50,8 @@ export const RscEntryLexicalCell = props => {
49
50
  WrapElement = Link;
50
51
  wrapElementProps.href = collectionConfig?.slug ? formatAdminURL({
51
52
  adminRoute,
52
- path: `/collections/${collectionConfig?.slug}/${rowData.id}`
53
+ path: `/collections/${collectionConfig?.slug}/${rowData.id}`,
54
+ serverURL
53
55
  }) : '';
54
56
  }
55
57
  if (typeof onClick === 'function') {
@@ -1 +1 @@
1
- {"version":3,"file":"rscEntry.js","names":["getTranslation","Link","formatAdminURL","React","recurseEditorState","editorState","textContent","i","node","text","push","_jsxs","type","children","RscEntryLexicalCell","props","cellData","className","classNameFromProps","collectionConfig","field","admin","i18n","link","onClick","onClickFromProps","payload","rowData","classNameFromConfigContext","undefined","adminRoute","config","routes","WrapElement","wrapElementProps","prefetch","href","slug","path","id","collectionSlug","root","length","t","label","_jsx"],"sources":["../../src/cell/rscEntry.tsx"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { Link } from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport type { LexicalRichTextCellProps } from '../types.js'\n\nfunction recurseEditorState(\n editorState: SerializedLexicalNode[],\n textContent: React.ReactNode[],\n i: number = 0,\n): React.ReactNode[] {\n for (const node of editorState) {\n i++\n if ('text' in node && node.text) {\n textContent.push(node.text as string)\n } else {\n if (!('children' in node)) {\n textContent.push(<code key={i}>&#32;[{node.type}]</code>)\n }\n }\n if ('children' in node && node.children) {\n textContent = recurseEditorState(node.children as SerializedLexicalNode[], textContent, i)\n }\n }\n return textContent\n}\n\nexport const RscEntryLexicalCell: React.FC<LexicalRichTextCellProps> = (props) => {\n const {\n cellData,\n className: classNameFromProps,\n collectionConfig,\n field: { admin },\n field,\n i18n,\n link,\n onClick: onClickFromProps,\n payload,\n rowData,\n } = props\n\n const classNameFromConfigContext = admin && 'className' in admin ? admin.className : undefined\n\n const className =\n classNameFromProps ||\n (field.admin && 'className' in field.admin ? field.admin.className : null) ||\n classNameFromConfigContext\n const adminRoute = payload.config.routes.admin\n\n const onClick = onClickFromProps\n\n let WrapElement: React.ComponentType<any> | string = 'span'\n\n const wrapElementProps: {\n className?: string\n href?: string\n onClick?: () => void\n prefetch?: false\n type?: 'button'\n } = {\n className,\n }\n\n if (link) {\n wrapElementProps.prefetch = false\n WrapElement = Link\n wrapElementProps.href = collectionConfig?.slug\n ? formatAdminURL({\n adminRoute,\n path: `/collections/${collectionConfig?.slug}/${rowData.id}`,\n })\n : ''\n }\n\n if (typeof onClick === 'function') {\n WrapElement = 'button'\n wrapElementProps.type = 'button'\n wrapElementProps.onClick = () => {\n onClick({\n cellData,\n collectionSlug: collectionConfig?.slug,\n rowData,\n })\n }\n }\n\n let textContent: React.ReactNode[] = []\n\n if (cellData?.root?.children) {\n textContent = recurseEditorState(cellData?.root?.children, textContent)\n }\n\n if (!textContent?.length) {\n textContent = [\n i18n.t('general:noLabel', {\n label: getTranslation(('label' in field ? field.label : null) || 'data', i18n),\n }),\n ]\n }\n\n return <WrapElement {...wrapElementProps}>{textContent}</WrapElement>\n}\n"],"mappings":";AAEA,SAASA,cAAc,QAAQ;AAC/B,SAASC,IAAI,QAAQ;AACrB,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAIlB,SAASC,mBACPC,WAAoC,EACpCC,WAA8B,EAC9BC,CAAA,GAAY,CAAC;EAEb,KAAK,MAAMC,IAAA,IAAQH,WAAA,EAAa;IAC9BE,CAAA;IACA,IAAI,UAAUC,IAAA,IAAQA,IAAA,CAAKC,IAAI,EAAE;MAC/BH,WAAA,CAAYI,IAAI,CAACF,IAAA,CAAKC,IAAI;IAC5B,OAAO;MACL,IAAI,EAAE,cAAcD,IAAG,GAAI;QACzBF,WAAA,CAAYI,IAAI,cAACC,KAAA,CAAC;qBAAa,MAAOH,IAAA,CAAKI,IAAI,EAAC;WAApBL,CAAA;MAC9B;IACF;IACA,IAAI,cAAcC,IAAA,IAAQA,IAAA,CAAKK,QAAQ,EAAE;MACvCP,WAAA,GAAcF,kBAAA,CAAmBI,IAAA,CAAKK,QAAQ,EAA6BP,WAAA,EAAaC,CAAA;IAC1F;EACF;EACA,OAAOD,WAAA;AACT;AAEA,OAAO,MAAMQ,mBAAA,GAA2DC,KAAA;EACtE,MAAM;IACJC,QAAQ;IACRC,SAAA,EAAWC,kBAAkB;IAC7BC,gBAAgB;IAChBC,KAAA,EAAO;MAAEC;IAAK,CA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AI,CAACA,WAAA,EAAaoC,MAAA,EAAQ;IACxBpC,WAAA,GAAc,CACZgB,IAAA,CAAKqB,CAAC,CAAC,mBAAmB;MACxBC,KAAA,EAAO5C,cAAA,CAAe,CAAC,WAAWoB,KAAA,GAAQA,KAAA,CAAMwB,KAAK,GAAG,IAAG,KAAM,QAAQtB,IAAA;IAC3E,GACD;EACH;EAEA,oBAAOuB,IAAA,CAACZ,WAAA;IAAa,GAAGC,gBAAgB;cAAG5B;;AAC7C","ignoreList":[]}
1
+ {"version":3,"file":"rscEntry.js","names":["getTranslation","Link","formatAdminURL","React","recurseEditorState","editorState","textContent","i","node","text","push","_jsxs","type","children","RscEntryLexicalCell","props","cellData","className","classNameFromProps","collectionConfig","field","admin","i18n","link","onClick","onClickFromProps","payload","rowData","classNameFromConfigContext","undefined","adminRoute","config","routes","serverURL","WrapElement","wrapElementProps","prefetch","href","slug","path","id","collectionSlug","root","length","t","label","_jsx"],"sources":["../../src/cell/rscEntry.tsx"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { Link } from '@payloadcms/ui'\nimport { formatAdminURL } from 'payload/shared'\nimport React from 'react'\n\nimport type { LexicalRichTextCellProps } from '../types.js'\n\nfunction recurseEditorState(\n editorState: SerializedLexicalNode[],\n textContent: React.ReactNode[],\n i: number = 0,\n): React.ReactNode[] {\n for (const node of editorState) {\n i++\n if ('text' in node && node.text) {\n textContent.push(node.text as string)\n } else {\n if (!('children' in node)) {\n textContent.push(<code key={i}>&#32;[{node.type}]</code>)\n }\n }\n if ('children' in node && node.children) {\n textContent = recurseEditorState(node.children as SerializedLexicalNode[], textContent, i)\n }\n }\n return textContent\n}\n\nexport const RscEntryLexicalCell: React.FC<LexicalRichTextCellProps> = (props) => {\n const {\n cellData,\n className: classNameFromProps,\n collectionConfig,\n field: { admin },\n field,\n i18n,\n link,\n onClick: onClickFromProps,\n payload,\n rowData,\n } = props\n\n const classNameFromConfigContext = admin && 'className' in admin ? admin.className : undefined\n\n const className =\n classNameFromProps ||\n (field.admin && 'className' in field.admin ? field.admin.className : null) ||\n classNameFromConfigContext\n const adminRoute = payload.config.routes.admin\n const serverURL = payload.config.serverURL\n\n const onClick = onClickFromProps\n\n let WrapElement: React.ComponentType<any> | string = 'span'\n\n const wrapElementProps: {\n className?: string\n href?: string\n onClick?: () => void\n prefetch?: false\n type?: 'button'\n } = {\n className,\n }\n\n if (link) {\n wrapElementProps.prefetch = false\n WrapElement = Link\n wrapElementProps.href = collectionConfig?.slug\n ? formatAdminURL({\n adminRoute,\n path: `/collections/${collectionConfig?.slug}/${rowData.id}`,\n serverURL,\n })\n : ''\n }\n\n if (typeof onClick === 'function') {\n WrapElement = 'button'\n wrapElementProps.type = 'button'\n wrapElementProps.onClick = () => {\n onClick({\n cellData,\n collectionSlug: collectionConfig?.slug,\n rowData,\n })\n }\n }\n\n let textContent: React.ReactNode[] = []\n\n if (cellData?.root?.children) {\n textContent = recurseEditorState(cellData?.root?.children, textContent)\n }\n\n if (!textContent?.length) {\n textContent = [\n i18n.t('general:noLabel', {\n label: getTranslation(('label' in field ? field.label : null) || 'data', i18n),\n }),\n ]\n }\n\n return <WrapElement {...wrapElementProps}>{textContent}</WrapElement>\n}\n"],"mappings":";AAEA,SAASA,cAAc,QAAQ;AAC/B,SAASC,IAAI,QAAQ;AACrB,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAIlB,SAASC,mBACPC,WAAoC,EACpCC,WAA8B,EAC9BC,CAAA,GAAY,CAAC;EAEb,KAAK,MAAMC,IAAA,IAAQH,WAAA,EAAa;IAC9BE,CAAA;IACA,IAAI,UAAUC,IAAA,IAAQA,IAAA,CAAKC,IAAI,EAAE;MAC/BH,WAAA,CAAYI,IAAI,CAACF,IAAA,CAAKC,IAAI;IAC5B,OAAO;MACL,IAAI,EAAE,cAAcD,IAAG,GAAI;QACzBF,WAAA,CAAYI,IAAI,cAACC,KAAA,CAAC;qBAAa,MA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