@payloadcms/richtext-lexical 3.33.0-internal.d1efdd8 → 3.34.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/index.d.ts +1 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +10 -10
- package/dist/exports/client/index.js.map +4 -4
- package/dist/exports/server/rsc.d.ts +1 -0
- package/dist/exports/server/rsc.d.ts.map +1 -1
- package/dist/exports/server/rsc.js +1 -0
- package/dist/exports/server/rsc.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/types.d.ts +1 -0
- package/dist/features/converters/lexicalToHtml/async/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/types.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.js +3 -3
- package/dist/features/converters/lexicalToHtml/shared/findConverterForNode.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/types.d.ts +1 -0
- package/dist/features/converters/lexicalToHtml/sync/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/types.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/index.js +3 -3
- package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts +1 -0
- package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/index.d.ts +2 -0
- package/dist/features/debug/jsxConverter/client/index.d.ts.map +1 -0
- package/dist/features/debug/jsxConverter/client/index.js +11 -0
- package/dist/features/debug/jsxConverter/client/index.js.map +1 -0
- package/dist/features/debug/jsxConverter/client/plugin/index.d.ts +2 -0
- package/dist/features/debug/jsxConverter/client/plugin/index.d.ts.map +1 -0
- package/dist/features/debug/jsxConverter/client/plugin/index.js +52 -0
- package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -0
- package/dist/features/debug/jsxConverter/server/index.d.ts +2 -0
- package/dist/features/debug/jsxConverter/server/index.d.ts.map +1 -0
- package/dist/features/debug/jsxConverter/server/index.js +8 -0
- package/dist/features/debug/jsxConverter/server/index.js.map +1 -0
- package/dist/features/upload/server/validate.d.ts.map +1 -1
- package/dist/features/upload/server/validate.js.map +1 -1
- package/dist/field/Diff/converters/link.d.ts +9 -0
- package/dist/field/Diff/converters/link.d.ts.map +1 -0
- package/dist/field/Diff/converters/link.js +48 -0
- package/dist/field/Diff/converters/link.js.map +1 -0
- package/dist/field/Diff/converters/listitem/index.d.ts +5 -0
- package/dist/field/Diff/converters/listitem/index.d.ts.map +1 -0
- package/dist/field/Diff/converters/listitem/index.js +65 -0
- package/dist/field/Diff/converters/listitem/index.js.map +1 -0
- package/dist/field/Diff/converters/relationship/index.d.ts +10 -0
- package/dist/field/Diff/converters/relationship/index.d.ts.map +1 -0
- package/dist/field/Diff/converters/relationship/index.js +63 -0
- package/dist/field/Diff/converters/relationship/index.js.map +1 -0
- package/dist/field/Diff/converters/unknown/index.d.ts +10 -0
- package/dist/field/Diff/converters/unknown/index.d.ts.map +1 -0
- package/dist/field/Diff/converters/unknown/index.js +45 -0
- package/dist/field/Diff/converters/unknown/index.js.map +1 -0
- package/dist/field/Diff/converters/upload/index.d.ts +10 -0
- package/dist/field/Diff/converters/upload/index.d.ts.map +1 -0
- package/dist/field/Diff/converters/upload/index.js +76 -0
- package/dist/field/Diff/converters/upload/index.js.map +1 -0
- package/dist/field/Diff/htmlDiff/index.d.ts +63 -0
- package/dist/field/Diff/htmlDiff/index.d.ts.map +1 -0
- package/dist/field/Diff/htmlDiff/index.js +501 -0
- package/dist/field/Diff/htmlDiff/index.js.map +1 -0
- package/dist/field/Diff/index.d.ts +5 -0
- package/dist/field/Diff/index.d.ts.map +1 -0
- package/dist/field/Diff/index.js +81 -0
- package/dist/field/Diff/index.js.map +1 -0
- package/dist/field/bundled.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +1 -0
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
3
|
+
import { FieldDiffLabel } from '@payloadcms/ui/rsc';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { convertLexicalToHTMLAsync } from '../../features/converters/lexicalToHtml/async/index.js';
|
|
6
|
+
import { getPayloadPopulateFn } from '../../features/converters/utilities/payloadPopulateFn.js';
|
|
7
|
+
import { LinkDiffHTMLConverterAsync } from './converters/link.js';
|
|
8
|
+
import { ListItemDiffHTMLConverterAsync } from './converters/listitem/index.js';
|
|
9
|
+
import { RelationshipDiffHTMLConverterAsync } from './converters/relationship/index.js';
|
|
10
|
+
import { UnknownDiffHTMLConverterAsync } from './converters/unknown/index.js';
|
|
11
|
+
import { UploadDiffHTMLConverterAsync } from './converters/upload/index.js';
|
|
12
|
+
import { HtmlDiff } from './htmlDiff/index.js';
|
|
13
|
+
const baseClass = 'lexical-diff';
|
|
14
|
+
export const LexicalDiffComponent = async args => {
|
|
15
|
+
const {
|
|
16
|
+
comparisonValue,
|
|
17
|
+
field,
|
|
18
|
+
i18n,
|
|
19
|
+
locale,
|
|
20
|
+
versionValue
|
|
21
|
+
} = args;
|
|
22
|
+
const converters = ({
|
|
23
|
+
defaultConverters
|
|
24
|
+
}) => ({
|
|
25
|
+
...defaultConverters,
|
|
26
|
+
...LinkDiffHTMLConverterAsync({}),
|
|
27
|
+
...ListItemDiffHTMLConverterAsync,
|
|
28
|
+
...UploadDiffHTMLConverterAsync({
|
|
29
|
+
i18n: args.i18n,
|
|
30
|
+
req: args.req
|
|
31
|
+
}),
|
|
32
|
+
...RelationshipDiffHTMLConverterAsync({
|
|
33
|
+
i18n: args.i18n,
|
|
34
|
+
req: args.req
|
|
35
|
+
}),
|
|
36
|
+
...UnknownDiffHTMLConverterAsync({
|
|
37
|
+
i18n: args.i18n,
|
|
38
|
+
req: args.req
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
const payloadPopulateFn = await getPayloadPopulateFn({
|
|
42
|
+
currentDepth: 0,
|
|
43
|
+
depth: 1,
|
|
44
|
+
req: args.req
|
|
45
|
+
});
|
|
46
|
+
const comparisonHTML = await convertLexicalToHTMLAsync({
|
|
47
|
+
converters,
|
|
48
|
+
data: comparisonValue,
|
|
49
|
+
populate: payloadPopulateFn
|
|
50
|
+
});
|
|
51
|
+
const versionHTML = await convertLexicalToHTMLAsync({
|
|
52
|
+
converters,
|
|
53
|
+
data: versionValue,
|
|
54
|
+
populate: payloadPopulateFn
|
|
55
|
+
});
|
|
56
|
+
const diffHTML = new HtmlDiff(comparisonHTML, versionHTML);
|
|
57
|
+
const [oldHTML, newHTML] = diffHTML.getSideBySideContents();
|
|
58
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
59
|
+
className: baseClass,
|
|
60
|
+
children: [/*#__PURE__*/_jsxs(FieldDiffLabel, {
|
|
61
|
+
children: [locale && /*#__PURE__*/_jsx("span", {
|
|
62
|
+
className: `${baseClass}__locale-label`,
|
|
63
|
+
children: locale
|
|
64
|
+
}), 'label' in field && typeof field.label !== 'function' && getTranslation(field.label || '', i18n)]
|
|
65
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
66
|
+
className: `${baseClass}__diff-container`,
|
|
67
|
+
children: [oldHTML && /*#__PURE__*/_jsx("div", {
|
|
68
|
+
className: `${baseClass}__diff-old`,
|
|
69
|
+
dangerouslySetInnerHTML: {
|
|
70
|
+
__html: oldHTML
|
|
71
|
+
}
|
|
72
|
+
}), newHTML && /*#__PURE__*/_jsx("div", {
|
|
73
|
+
className: `${baseClass}__diff-new`,
|
|
74
|
+
dangerouslySetInnerHTML: {
|
|
75
|
+
__html: newHTML
|
|
76
|
+
}
|
|
77
|
+
})]
|
|
78
|
+
})]
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["getTranslation","FieldDiffLabel","React","convertLexicalToHTMLAsync","getPayloadPopulateFn","LinkDiffHTMLConverterAsync","ListItemDiffHTMLConverterAsync","RelationshipDiffHTMLConverterAsync","UnknownDiffHTMLConverterAsync","UploadDiffHTMLConverterAsync","HtmlDiff","baseClass","LexicalDiffComponent","args","comparisonValue","field","i18n","locale","versionValue","converters","defaultConverters","req","payloadPopulateFn","currentDepth","depth","comparisonHTML","data","populate","versionHTML","diffHTML","oldHTML","newHTML","getSideBySideContents","_jsxs","className","_jsx","label","dangerouslySetInnerHTML","__html"],"sources":["../../../src/field/Diff/index.tsx"],"sourcesContent":["import type { SerializedEditorState } from 'lexical'\nimport type { RichTextFieldDiffServerComponent } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { FieldDiffLabel } from '@payloadcms/ui/rsc'\nimport React from 'react'\n\nimport './htmlDiff/index.scss'\nimport './index.scss'\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'\nimport { HtmlDiff } from './htmlDiff/index.js'\nconst baseClass = 'lexical-diff'\n\nexport const LexicalDiffComponent: RichTextFieldDiffServerComponent = async (args) => {\n const { comparisonValue, field, i18n, locale, versionValue } = args\n\n const converters: HTMLConvertersFunctionAsync = ({ defaultConverters }) => ({\n ...defaultConverters,\n ...LinkDiffHTMLConverterAsync({}),\n ...ListItemDiffHTMLConverterAsync,\n ...UploadDiffHTMLConverterAsync({ i18n: args.i18n, req: args.req }),\n ...RelationshipDiffHTMLConverterAsync({ i18n: args.i18n, req: args.req }),\n ...UnknownDiffHTMLConverterAsync({ i18n: args.i18n, req: args.req }),\n })\n\n const payloadPopulateFn = await getPayloadPopulateFn({\n currentDepth: 0,\n depth: 1,\n req: args.req,\n })\n const comparisonHTML = await convertLexicalToHTMLAsync({\n converters,\n data: comparisonValue as SerializedEditorState,\n populate: payloadPopulateFn,\n })\n\n const versionHTML = await convertLexicalToHTMLAsync({\n converters,\n data: versionValue as SerializedEditorState,\n populate: payloadPopulateFn,\n })\n\n const diffHTML = new HtmlDiff(comparisonHTML, versionHTML)\n\n const [oldHTML, newHTML] = diffHTML.getSideBySideContents()\n\n return (\n <div className={baseClass}>\n <FieldDiffLabel>\n {locale && <span className={`${baseClass}__locale-label`}>{locale}</span>}\n {'label' in field &&\n typeof field.label !== 'function' &&\n getTranslation(field.label || '', i18n)}\n </FieldDiffLabel>\n <div className={`${baseClass}__diff-container`}>\n {oldHTML && (\n <div className={`${baseClass}__diff-old`} dangerouslySetInnerHTML={{ __html: oldHTML }} />\n )}\n {newHTML && (\n <div className={`${baseClass}__diff-new`} dangerouslySetInnerHTML={{ __html: newHTML }} />\n )}\n </div>\n </div>\n )\n}\n"],"mappings":";AAGA,SAASA,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,OAAOC,KAAA,MAAW;AAOlB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,0BA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