@payloadcms/richtext-lexical 3.61.0-canary.4 → 3.61.0-canary.6
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/cell/rscEntry.d.ts +2 -10
- package/dist/cell/rscEntry.d.ts.map +1 -1
- package/dist/cell/rscEntry.js +1 -2
- package/dist/cell/rscEntry.js.map +1 -1
- package/dist/exports/client/Field-F2KOJLMQ.js +2 -0
- package/dist/exports/client/{Field-YYMTSGSP.js.map → Field-F2KOJLMQ.js.map} +3 -3
- package/dist/exports/client/RelationshipComponent-UCIWIEVD.js +2 -0
- package/dist/exports/client/RelationshipComponent-UCIWIEVD.js.map +7 -0
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-52JG5GGJ.js +2 -0
- package/dist/exports/client/chunk-52JG5GGJ.js.map +7 -0
- package/dist/exports/client/component-5YLBQB5B.js +2 -0
- package/dist/exports/client/component-5YLBQB5B.js.map +7 -0
- package/dist/exports/client/componentInline-QEXUNJU4.js +2 -0
- package/dist/exports/client/index.js +21 -21
- package/dist/exports/client/index.js.map +3 -3
- package/dist/features/blocks/client/component/BlockContent.js +1 -1
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts +1 -0
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +23 -20
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts +2 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +6 -6
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts +2 -2
- package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/BlocksNode.js +5 -3
- package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts +2 -2
- package/dist/features/blocks/client/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js +5 -3
- package/dist/features/blocks/client/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts +2 -1
- package/dist/features/blocks/server/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/BlocksNode.js +9 -2
- package/dist/features/blocks/server/nodes/BlocksNode.js.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.d.ts.map +1 -1
- package/dist/features/blocks/server/nodes/InlineBlocksNode.js +6 -5
- package/dist/features/blocks/server/nodes/InlineBlocksNode.js.map +1 -1
- package/dist/features/link/nodes/AutoLinkNode.js +1 -1
- package/dist/features/link/nodes/AutoLinkNode.js.map +1 -1
- package/dist/features/link/nodes/LinkNode.js +1 -1
- package/dist/features/link/nodes/LinkNode.js.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js +4 -4
- package/dist/features/migrations/lexicalPluginToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/migrations/slateToLexical/feature.server.d.ts +29 -0
- package/dist/features/migrations/slateToLexical/feature.server.d.ts.map +1 -1
- package/dist/features/migrations/slateToLexical/feature.server.js +18 -0
- package/dist/features/migrations/slateToLexical/feature.server.js.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.d.ts.map +1 -1
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js +4 -4
- package/dist/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.js.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/features/relationship/client/components/RelationshipComponent.js +2 -2
- package/dist/features/relationship/client/components/RelationshipComponent.js.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.d.ts +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/client/nodes/RelationshipNode.js +3 -2
- package/dist/features/relationship/client/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts +2 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/features/relationship/server/nodes/RelationshipNode.js +9 -2
- package/dist/features/relationship/server/nodes/RelationshipNode.js.map +1 -1
- package/dist/features/typesServer.d.ts +2 -2
- package/dist/features/typesServer.d.ts.map +1 -1
- package/dist/features/typesServer.js.map +1 -1
- package/dist/features/upload/client/component/index.d.ts +1 -0
- package/dist/features/upload/client/component/index.d.ts.map +1 -1
- package/dist/features/upload/client/component/index.js +2 -2
- package/dist/features/upload/client/component/index.js.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.d.ts +2 -2
- package/dist/features/upload/client/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/client/nodes/UploadNode.js +2 -1
- package/dist/features/upload/client/nodes/UploadNode.js.map +1 -1
- package/dist/features/upload/client/plugin/index.js +2 -2
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts +2 -1
- package/dist/features/upload/server/nodes/UploadNode.d.ts.map +1 -1
- package/dist/features/upload/server/nodes/UploadNode.js +6 -0
- package/dist/features/upload/server/nodes/UploadNode.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +48 -40
- package/dist/field/index.js.map +1 -1
- package/dist/field/rscEntry.d.ts +2 -3
- package/dist/field/rscEntry.d.ts.map +1 -1
- package/dist/field/rscEntry.js +3 -1
- package/dist/field/rscEntry.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -25
- package/dist/index.js.map +1 -1
- package/dist/lexical/config/client/loader.d.ts.map +1 -1
- package/dist/lexical/config/client/loader.js +2 -4
- package/dist/lexical/config/client/loader.js.map +1 -1
- package/dist/lexical/plugins/handles/utils/setHandlePosition.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/utils/setHandlePosition.js +1 -1
- package/dist/lexical/plugins/handles/utils/setHandlePosition.js.map +1 -1
- package/dist/lexical/theme/EditorTheme.d.ts.map +1 -1
- package/dist/lexical/theme/EditorTheme.js +3 -39
- package/dist/lexical/theme/EditorTheme.js.map +1 -1
- package/dist/lexical/ui/ContentEditable.d.ts.map +1 -1
- package/dist/lexical/ui/ContentEditable.js +16 -9
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utilities/editorConfigFactory.js +1 -1
- package/dist/utilities/editorConfigFactory.js.map +1 -1
- package/dist/utilities/generateImportMap.d.ts +2 -0
- package/dist/utilities/generateImportMap.d.ts.map +1 -1
- package/dist/utilities/generateImportMap.js +5 -13
- package/dist/utilities/generateImportMap.js.map +1 -1
- package/dist/{getDefaultSanitizedEditorConfig.d.ts → utilities/getDefaultSanitizedEditorConfig.d.ts} +1 -1
- package/dist/utilities/getDefaultSanitizedEditorConfig.d.ts.map +1 -0
- package/dist/{getDefaultSanitizedEditorConfig.js → utilities/getDefaultSanitizedEditorConfig.js} +2 -2
- package/dist/utilities/getDefaultSanitizedEditorConfig.js.map +1 -0
- package/dist/utilities/initLexicalFeatures.d.ts.map +1 -1
- package/dist/utilities/initLexicalFeatures.js +12 -13
- package/dist/utilities/initLexicalFeatures.js.map +1 -1
- package/package.json +6 -6
- package/dist/exports/client/Field-YYMTSGSP.js +0 -2
- package/dist/exports/client/RelationshipComponent-JXQOFHXF.js +0 -2
- package/dist/exports/client/RelationshipComponent-JXQOFHXF.js.map +0 -7
- package/dist/exports/client/chunk-ADWHGDDR.js +0 -2
- package/dist/exports/client/chunk-ADWHGDDR.js.map +0 -7
- package/dist/exports/client/component-WT25HAJA.js +0 -2
- package/dist/exports/client/component-WT25HAJA.js.map +0 -7
- package/dist/exports/client/componentInline-MIPTDFRK.js +0 -2
- package/dist/getDefaultSanitizedEditorConfig.d.ts.map +0 -1
- package/dist/getDefaultSanitizedEditorConfig.js.map +0 -1
- /package/dist/exports/client/{componentInline-MIPTDFRK.js.map → componentInline-QEXUNJU4.js.map} +0 -0
|
@@ -1,10 +1,39 @@
|
|
|
1
1
|
import type { SlateNodeConverter } from './converter/types.js';
|
|
2
2
|
export type SlateToLexicalFeatureProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Custom converters to transform Slate nodes to Lexical nodes.
|
|
5
|
+
* Can be an array of converters or a function that receives default converters and returns an array.
|
|
6
|
+
* @default defaultSlateConverters
|
|
7
|
+
*/
|
|
3
8
|
converters?: (({ defaultConverters }: {
|
|
4
9
|
defaultConverters: SlateNodeConverter[];
|
|
5
10
|
}) => SlateNodeConverter[]) | SlateNodeConverter[];
|
|
11
|
+
/**
|
|
12
|
+
* When true, disables the afterRead hook that converts Slate data on-the-fly.
|
|
13
|
+
* Set this to true when running the migration script. That way, this feature is only used
|
|
14
|
+
* to "pass through" the converters to the migration script.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
6
17
|
disableHooks?: boolean;
|
|
7
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Enables on-the-fly conversion of Slate data to Lexical format through an afterRead hook.
|
|
21
|
+
* Used for testing migrations before running the permanent migration script.
|
|
22
|
+
* Only converts data that is in Slate format (arrays); Lexical data passes through unchanged.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* lexicalEditor({
|
|
27
|
+
* features: ({ defaultFeatures }) => [
|
|
28
|
+
* ...defaultFeatures,
|
|
29
|
+
* SlateToLexicalFeature({
|
|
30
|
+
* converters: [...defaultSlateConverters, MyCustomConverter],
|
|
31
|
+
* disableHooks: false, // Set to true during migration script
|
|
32
|
+
* }),
|
|
33
|
+
* ],
|
|
34
|
+
* })
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
8
37
|
export declare const SlateToLexicalFeature: import("../../typesServer.js").FeatureProviderProviderServer<SlateToLexicalFeatureProps, {
|
|
9
38
|
converters?: SlateNodeConverter[];
|
|
10
39
|
}, undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/features/migrations/slateToLexical/feature.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAO9D,MAAM,MAAM,0BAA0B,GAAG;IACvC,UAAU,CAAC,EACP,CAAC,CAAC,EAAE,iBAAiB,EAAE,EAAE;QAAE,iBAAiB,EAAE,kBAAkB,EAAE,CAAA;KAAE,KAAK,kBAAkB,EAAE,CAAC,GAC9F,kBAAkB,EAAE,CAAA;IACxB,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,qBAAqB;iBAGjB,kBAAkB,EAAE;aAkDnC,CAAA"}
|
|
1
|
+
{"version":3,"file":"feature.server.d.ts","sourceRoot":"","sources":["../../../../src/features/migrations/slateToLexical/feature.server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAO9D,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;OAIG;IACH,UAAU,CAAC,EACP,CAAC,CAAC,EAAE,iBAAiB,EAAE,EAAE;QAAE,iBAAiB,EAAE,kBAAkB,EAAE,CAAA;KAAE,KAAK,kBAAkB,EAAE,CAAC,GAC9F,kBAAkB,EAAE,CAAA;IACxB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qBAAqB;iBAGjB,kBAAkB,EAAE;aAkDnC,CAAA"}
|
|
@@ -2,6 +2,24 @@ import { createServerFeature } from '../../../utilities/createServerFeature.js';
|
|
|
2
2
|
import { defaultSlateConverters } from './converter/defaultConverters.js';
|
|
3
3
|
import { convertSlateToLexical } from './converter/index.js';
|
|
4
4
|
import { UnknownConvertedNode } from './nodes/unknownConvertedNode/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Enables on-the-fly conversion of Slate data to Lexical format through an afterRead hook.
|
|
7
|
+
* Used for testing migrations before running the permanent migration script.
|
|
8
|
+
* Only converts data that is in Slate format (arrays); Lexical data passes through unchanged.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* lexicalEditor({
|
|
13
|
+
* features: ({ defaultFeatures }) => [
|
|
14
|
+
* ...defaultFeatures,
|
|
15
|
+
* SlateToLexicalFeature({
|
|
16
|
+
* converters: [...defaultSlateConverters, MyCustomConverter],
|
|
17
|
+
* disableHooks: false, // Set to true during migration script
|
|
18
|
+
* }),
|
|
19
|
+
* ],
|
|
20
|
+
* })
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
5
23
|
export const SlateToLexicalFeature = createServerFeature({
|
|
6
24
|
feature: ({
|
|
7
25
|
props
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.server.js","names":["createServerFeature","defaultSlateConverters","convertSlateToLexical","UnknownConvertedNode","SlateToLexicalFeature","feature","props","converters","defaultConverters","ClientFeature","hooks","disableHooks","undefined","afterRead","value","Array","isArray","slateData","nodes","node","sanitizedServerFeatureProps","key"],"sources":["../../../../src/features/migrations/slateToLexical/feature.server.ts"],"sourcesContent":["import type { SlateNodeConverter } from './converter/types.js'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { defaultSlateConverters } from './converter/defaultConverters.js'\nimport { convertSlateToLexical } from './converter/index.js'\nimport { UnknownConvertedNode } from './nodes/unknownConvertedNode/index.js'\n\nexport type SlateToLexicalFeatureProps = {\n converters?:\n | (({ defaultConverters }: { defaultConverters: SlateNodeConverter[] }) => SlateNodeConverter[])\n | SlateNodeConverter[]\n disableHooks?: boolean\n}\n\nexport const SlateToLexicalFeature = createServerFeature<\n SlateToLexicalFeatureProps,\n {\n converters?: SlateNodeConverter[]\n }\n>({\n feature: ({ props }) => {\n if (!props) {\n props = {}\n }\n\n let converters: SlateNodeConverter[] = []\n if (props?.converters && typeof props?.converters === 'function') {\n converters = props.converters({ defaultConverters: defaultSlateConverters })\n } else if (props.converters && typeof props?.converters !== 'function') {\n converters = props.converters\n } else {\n converters = defaultSlateConverters\n }\n\n props.converters = converters\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#SlateToLexicalFeatureClient',\n hooks: props.disableHooks\n ? undefined\n : {\n afterRead: [\n ({ value }) => {\n if (!value || !Array.isArray(value) || 'root' in value) {\n // incomingEditorState null or not from Slate\n return value\n }\n\n // Slate => convert to lexical\n return convertSlateToLexical({\n converters: props.converters as SlateNodeConverter[],\n slateData: value,\n })\n },\n ],\n },\n nodes: [\n {\n node: UnknownConvertedNode,\n },\n ],\n sanitizedServerFeatureProps: {\n converters,\n },\n }\n },\n key: 'slateToLexical',\n})\n"],"mappings":"AAEA,SAASA,mBAAmB,QAAQ;AACpC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,qBAAqB,QAAQ;AACtC,SAASC,oBAAoB,QAAQ;
|
|
1
|
+
{"version":3,"file":"feature.server.js","names":["createServerFeature","defaultSlateConverters","convertSlateToLexical","UnknownConvertedNode","SlateToLexicalFeature","feature","props","converters","defaultConverters","ClientFeature","hooks","disableHooks","undefined","afterRead","value","Array","isArray","slateData","nodes","node","sanitizedServerFeatureProps","key"],"sources":["../../../../src/features/migrations/slateToLexical/feature.server.ts"],"sourcesContent":["import type { SlateNodeConverter } from './converter/types.js'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { defaultSlateConverters } from './converter/defaultConverters.js'\nimport { convertSlateToLexical } from './converter/index.js'\nimport { UnknownConvertedNode } from './nodes/unknownConvertedNode/index.js'\n\nexport type SlateToLexicalFeatureProps = {\n /**\n * Custom converters to transform Slate nodes to Lexical nodes.\n * Can be an array of converters or a function that receives default converters and returns an array.\n * @default defaultSlateConverters\n */\n converters?:\n | (({ defaultConverters }: { defaultConverters: SlateNodeConverter[] }) => SlateNodeConverter[])\n | SlateNodeConverter[]\n /**\n * When true, disables the afterRead hook that converts Slate data on-the-fly.\n * Set this to true when running the migration script. That way, this feature is only used\n * to \"pass through\" the converters to the migration script.\n * @default false\n */\n disableHooks?: boolean\n}\n\n/**\n * Enables on-the-fly conversion of Slate data to Lexical format through an afterRead hook.\n * Used for testing migrations before running the permanent migration script.\n * Only converts data that is in Slate format (arrays); Lexical data passes through unchanged.\n *\n * @example\n * ```ts\n * lexicalEditor({\n * features: ({ defaultFeatures }) => [\n * ...defaultFeatures,\n * SlateToLexicalFeature({\n * converters: [...defaultSlateConverters, MyCustomConverter],\n * disableHooks: false, // Set to true during migration script\n * }),\n * ],\n * })\n * ```\n */\nexport const SlateToLexicalFeature = createServerFeature<\n SlateToLexicalFeatureProps,\n {\n converters?: SlateNodeConverter[]\n }\n>({\n feature: ({ props }) => {\n if (!props) {\n props = {}\n }\n\n let converters: SlateNodeConverter[] = []\n if (props?.converters && typeof props?.converters === 'function') {\n converters = props.converters({ defaultConverters: defaultSlateConverters })\n } else if (props.converters && typeof props?.converters !== 'function') {\n converters = props.converters\n } else {\n converters = defaultSlateConverters\n }\n\n props.converters = converters\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#SlateToLexicalFeatureClient',\n hooks: props.disableHooks\n ? undefined\n : {\n afterRead: [\n ({ value }) => {\n if (!value || !Array.isArray(value) || 'root' in value) {\n // incomingEditorState null or not from Slate\n return value\n }\n\n // Slate => convert to lexical\n return convertSlateToLexical({\n converters: props.converters as SlateNodeConverter[],\n slateData: value,\n })\n },\n ],\n },\n nodes: [\n {\n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b;MACF;IACF;EACF;EACAc,GAAA,EAAK;AACP","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChG,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAGhC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChG,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAGhC,OAAO,EAAyB,aAAa,EAAE,MAAM,SAAS,CAAA;AAG9D,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,8BAA8B,GAAG,MAAM,CACjD;IACE,IAAI,EAAE,wBAAwB,CAAA;CAC/B,EACD,qBAAqB,CACtB,CAAA;AAQD,oBAAoB;AACpB,qBAAa,oBAAqB,SAAQ,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC;IAClE,MAAM,EAAE,wBAAwB,CAAA;gBAEpB,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAAE,IAAI,EAAE,wBAAwB,CAAC;QAAC,GAAG,CAAC,EAAE,OAAO,CAAA;KAAE;WAK5D,KAAK,CAAC,IAAI,EAAE,oBAAoB,GAAG,oBAAoB;WAOvD,OAAO,IAAI,MAAM;WAIjB,UAAU,CAAC,cAAc,EAAE,8BAA8B,GAAG,oBAAoB;IAKhG,kBAAkB,IAAI,IAAI;IAI1B,mBAAmB,IAAI,IAAI;IAIlB,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW;IAM5C,QAAQ,IAAI,GAAG,CAAC,OAAO;IAIvB,UAAU,IAAI,8BAA8B;IAU5C,QAAQ,IAAI,OAAO;IAInB,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO;CAG9D;AAED,wBAAgB,2BAA2B,CAAC,EAC1C,IAAI,GACL,EAAE;IACD,IAAI,EAAE,wBAAwB,CAAA;CAC/B,GAAG,oBAAoB,CAMvB;AAED,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACnC,IAAI,IAAI,oBAAoB,CAE9B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { addClassNamesToElement } from '@lexical/utils';
|
|
3
|
-
import { DecoratorNode } from 'lexical';
|
|
3
|
+
import { $applyNodeReplacement, DecoratorNode } from 'lexical';
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
const Component = /*#__PURE__*/React.lazy(() => import('./Component.js').then(module => ({
|
|
6
6
|
default: module.UnknownConvertedNodeComponent
|
|
@@ -16,7 +16,7 @@ export class UnknownConvertedNode extends DecoratorNode {
|
|
|
16
16
|
this.__data = data;
|
|
17
17
|
}
|
|
18
18
|
static clone(node) {
|
|
19
|
-
return new
|
|
19
|
+
return new this({
|
|
20
20
|
data: node.__data,
|
|
21
21
|
key: node.__key
|
|
22
22
|
});
|
|
@@ -64,9 +64,9 @@ export class UnknownConvertedNode extends DecoratorNode {
|
|
|
64
64
|
export function $createUnknownConvertedNode({
|
|
65
65
|
data
|
|
66
66
|
}) {
|
|
67
|
-
return new UnknownConvertedNode({
|
|
67
|
+
return $applyNodeReplacement(new UnknownConvertedNode({
|
|
68
68
|
data
|
|
69
|
-
});
|
|
69
|
+
}));
|
|
70
70
|
}
|
|
71
71
|
export function $isUnknownConvertedNode(node) {
|
|
72
72
|
return node instanceof UnknownConvertedNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["addClassNamesToElement","DecoratorNode","React","Component","lazy","then","module","default","UnknownConvertedNodeComponent","UnknownConvertedNode","__data","constructor","data","key","clone","node","__key","getType","importJSON","serializedNode","$createUnknownConvertedNode","canInsertTextAfter","canInsertTextBefore","createDOM","config","element","document","createElement","decorate","_jsx","exportJSON","type","version","isInline","updateDOM","prevNode","dom","$isUnknownConvertedNode"],"sources":["../../../../../../src/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.tsx"],"sourcesContent":["import type { EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical'\nimport type { JSX } from 'react'\n\nimport { addClassNamesToElement } from '@lexical/utils'\nimport { DecoratorNode } from 'lexical'\nimport * as React from 'react'\n\nexport type UnknownConvertedNodeData = {\n nodeData: unknown\n nodeType: string\n}\n\nexport type SerializedUnknownConvertedNode = Spread<\n {\n data: UnknownConvertedNodeData\n },\n SerializedLexicalNode\n>\n\nconst Component = React.lazy(() =>\n import('./Component.js').then((module) => ({\n default: module.UnknownConvertedNodeComponent,\n })),\n)\n\n/** @noInheritDoc */\nexport class UnknownConvertedNode extends DecoratorNode<JSX.Element> {\n __data: UnknownConvertedNodeData\n\n constructor({ data, key }: { data: UnknownConvertedNodeData; key?: NodeKey }) {\n super(key)\n this.__data = data\n }\n\n static override clone(node: UnknownConvertedNode): UnknownConvertedNode {\n return new
|
|
1
|
+
{"version":3,"file":"index.js","names":["addClassNamesToElement","$applyNodeReplacement","DecoratorNode","React","Component","lazy","then","module","default","UnknownConvertedNodeComponent","UnknownConvertedNode","__data","constructor","data","key","clone","node","__key","getType","importJSON","serializedNode","$createUnknownConvertedNode","canInsertTextAfter","canInsertTextBefore","createDOM","config","element","document","createElement","decorate","_jsx","exportJSON","type","version","isInline","updateDOM","prevNode","dom","$isUnknownConvertedNode"],"sources":["../../../../../../src/features/migrations/slateToLexical/nodes/unknownConvertedNode/index.tsx"],"sourcesContent":["import type { EditorConfig, LexicalNode, NodeKey, SerializedLexicalNode, Spread } from 'lexical'\nimport type { JSX } from 'react'\n\nimport { addClassNamesToElement } from '@lexical/utils'\nimport { $applyNodeReplacement, DecoratorNode } from 'lexical'\nimport * as React from 'react'\n\nexport type UnknownConvertedNodeData = {\n nodeData: unknown\n nodeType: string\n}\n\nexport type SerializedUnknownConvertedNode = Spread<\n {\n data: UnknownConvertedNodeData\n },\n SerializedLexicalNode\n>\n\nconst Component = React.lazy(() =>\n import('./Component.js').then((module) => ({\n default: module.UnknownConvertedNodeComponent,\n })),\n)\n\n/** @noInheritDoc */\nexport class UnknownConvertedNode extends DecoratorNode<JSX.Element> {\n __data: UnknownConvertedNodeData\n\n constructor({ data, key }: { data: UnknownConvertedNodeData; key?: NodeKey }) {\n super(key)\n this.__data = data\n }\n\n static override clone(node: UnknownConvertedNode): UnknownConvertedNode {\n return new this({\n data: node.__data,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'unknownConverted'\n }\n\n static override importJSON(serializedNode: SerializedUnknownConvertedNode): UnknownConvertedNode {\n const node = $createUnknownConvertedNode({ data: serializedNode.data })\n return node\n }\n\n canInsertTextAfter(): true {\n return true\n }\n\n canInsertTextBefore(): true {\n return true\n }\n\n override createDOM(config: EditorConfig): HTMLElement {\n const element = document.createElement('span')\n addClassNamesToElement(element, 'unknownConverted')\n return element\n }\n\n override decorate(): JSX.Element {\n return <Component data={this.__data} />\n }\n\n override exportJSON(): SerializedUnknownConvertedNode {\n return {\n type: this.getType(),\n data: this.__data,\n version: 1,\n }\n }\n\n // Mutation\n\n override isInline(): boolean {\n return true\n }\n\n override updateDOM(prevNode: this, dom: HTMLElement): boolean {\n return false\n }\n}\n\nexport function $createUnknownConvertedNode({\n data,\n}: {\n data: UnknownConvertedNodeData\n}): UnknownConvertedNode {\n return $applyNodeReplacement(\n new UnknownConvertedNode({\n data,\n }),\n )\n}\n\nexport function $isUnknownConvertedNode(\n node: LexicalNode | null | undefined,\n): node is UnknownConvertedNode {\n return node instanceof UnknownConvertedNode\n}\n"],"mappings":";AAGA,SAASA,sBAAsB,QAAQ;AACvC,SAASC,qBAAqB,EAAEC,aAAa,QAAQ;AACrD,YAAYC,KAAA,MAAW;AAcvB,MAAMC,SAAA,gBAAYD,KAAA,CAAME,IAAI,CAAC,MAC3B,MAAM,CAAC,kBAAkBC,IAAI,CAAEC,MAAA,KAAY;EACzCC,OAAA,EAASD,MAAA,CAAOE;AAClB;AAGF;AACA,OAAO,MAAMC,oBAAA,SAA6BR,aAAA;EACxCS,MAAA;EAEAC,YAAY;IAAEC,IAAI;IAAEC;EAAG,CAAqD,EAAE;IAC5E,KAAK,CAACA,GAAA;IACN,IAAI,CAACH,MAAM,GAAGE,IAAA;EAChB;EAEA,OAAgBE,MAAMC,IAA0B,EAAwB;IACtE,OAAO,IAAI,IAAI,CAAC;MACdH,IAAA,EAAMG,IAAA,CAAKL,MAAM;MACjBG,GAAA,EAAKE,IAAA,CAAKC;IACZ;EACF;EAEA,OAAgBC,QAAA,EAAkB;IAChC,OAAO;EACT;EAEA,OAAgBC,WAAWC,cAA8C,EAAwB;IAC/F,MAAMJ,IAAA,GAAOK,2BAAA,CAA4B;MAAER,IAAA,EAAMO,cAAA,CAAeP;IAAK;IACrE,OAAOG,IAAA;EACT;EAEAM,mBAAA,EAA2B;IACzB,OAAO;EACT;EAEAC,oBAAA,EAA4B;IAC1B,OAAO;EACT;EAESC,UAAUC,MAAoB,EAAe;IACpD,MAAMC,OAAA,GAAUC,QAAA,CAASC,aAAa,CAAC;IACvC5B,sBAAA,CAAuB0B,OAAA,EAAS;IAChC,OAAOA,OAAA;EACT;EAESG,SAAA,EAAwB;IAC/B,oBAAOC,IAAA,CAAC1B,SAAA;MAAUS,IAAA,EAAM,IAAI,CAACF;;EAC/B;EAESoB,WAAA,EAA6C;IACpD,OAAO;MACLC,IAAA,EAAM,IAAI,CAACd,OAAO;MAClBL,IAAA,EAAM,IAAI,CAACF,MAAM;MACjBsB,OAAA,EAAS;IACX;EACF;EAEA;EAESC,SAAA,EAAoB;IAC3B,OAAO;EACT;EAESC,UAAUC,QAAc,EAAEC,GAAgB,EAAW;IAC5D,OAAO;EACT;AACF;AAEA,OAAO,SAAShB,4BAA4B;EAC1CR;AAAI,CAGL;EACC,OAAOZ,qBAAA,CACL,IAAIS,oBAAA,CAAqB;IACvBG;EACF;AAEJ;AAEA,OAAO,SAASyB,wBACdtB,IAAoC;EAEpC,OAAOA,IAAA,YAAgBN,oBAAA;AACzB","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import type { RelationshipData } from '../../server/nodes/RelationshipNode.js';
|
|
4
4
|
import './index.scss';
|
|
5
5
|
type Props = {
|
|
6
|
-
className
|
|
6
|
+
className: string;
|
|
7
7
|
data: RelationshipData;
|
|
8
8
|
format?: ElementFormatType;
|
|
9
9
|
nodeKey?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipComponent.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/client/components/RelationshipComponent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAOhD,OAAO,KAAoD,MAAM,OAAO,CAAA;AAExE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAG9E,OAAO,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"RelationshipComponent.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/client/components/RelationshipComponent.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAOhD,OAAO,KAAoD,MAAM,OAAO,CAAA;AAExE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAG9E,OAAO,cAAc,CAAA;AAOrB,KAAK,KAAK,GAAG;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,gBAAgB,CAAA;IACtB,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA2GjD,CAAA"}
|
|
@@ -9,12 +9,12 @@ import { $getNodeByKey } from 'lexical';
|
|
|
9
9
|
import React, { useCallback, useReducer, useRef, useState } from 'react';
|
|
10
10
|
import { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js';
|
|
11
11
|
import { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../drawer/commands.js';
|
|
12
|
-
const baseClass = 'lexical-relationship';
|
|
13
12
|
const initialParams = {
|
|
14
13
|
depth: 0
|
|
15
14
|
};
|
|
16
15
|
export const RelationshipComponent = props => {
|
|
17
16
|
const {
|
|
17
|
+
className: baseClass,
|
|
18
18
|
data: {
|
|
19
19
|
relationTo,
|
|
20
20
|
value
|
|
@@ -73,7 +73,7 @@ export const RelationshipComponent = props => {
|
|
|
73
73
|
dispatchCacheBust();
|
|
74
74
|
}, [cacheBust, setParams, closeDocumentDrawer]);
|
|
75
75
|
return /*#__PURE__*/_jsxs("div", {
|
|
76
|
-
className: baseClass
|
|
76
|
+
className: `${baseClass}__contents`,
|
|
77
77
|
contentEditable: false,
|
|
78
78
|
ref: relationshipElemRef,
|
|
79
79
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipComponent.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","useConfig","usePayloadAPI","useTranslation","$getNodeByKey","React","useCallback","useReducer","useRef","useState","useLexicalDocumentDrawer","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","
|
|
1
|
+
{"version":3,"file":"RelationshipComponent.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","useConfig","usePayloadAPI","useTranslation","$getNodeByKey","React","useCallback","useReducer","useRef","useState","useLexicalDocumentDrawer","INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND","initialParams","depth","RelationshipComponent","props","className","baseClass","data","relationTo","value","nodeKey","Error","relationshipElemRef","editor","isEditable","config","routes","api","serverURL","getEntityConfig","relatedCollection","collectionSlug","i18n","t","cacheBust","dispatchCacheBust","state","setParams","slug","closeDocumentDrawer","DocumentDrawer","DocumentDrawerToggler","id","removeRelationship","update","remove","updateRelationship","_jsxs","contentEditable","ref","_jsx","label","labels","singular","admin","useAsTitle","buttonStyle","disabled","el","icon","onClick","dispatchCommand","replace","round","tooltip","e","preventDefault","onSave"],"sources":["../../../../../src/features/relationship/client/components/RelationshipComponent.tsx"],"sourcesContent":["'use client'\nimport type { ElementFormatType } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport { Button, useConfig, usePayloadAPI, useTranslation } from '@payloadcms/ui'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback, useReducer, useRef, useState } from 'react'\n\nimport type { RelationshipData } from '../../server/nodes/RelationshipNode.js'\n\nimport { useLexicalDocumentDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDocumentDrawer.js'\nimport './index.scss'\nimport { INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND } from '../drawer/commands.js'\n\nconst initialParams = {\n depth: 0,\n}\n\ntype Props = {\n className: string\n data: RelationshipData\n format?: ElementFormatType\n nodeKey?: string\n}\n\nexport const RelationshipComponent: React.FC<Props> = (props) => {\n const {\n className: baseClass,\n data: { relationTo, value },\n nodeKey,\n } = props\n\n if (typeof value === 'object') {\n throw new Error(\n 'Relationship value should be a string or number. The Lexical Relationship component should not receive the populated value object.',\n )\n }\n\n const relationshipElemRef = useRef<HTMLDivElement | null>(null)\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const {\n config: {\n routes: { api },\n serverURL,\n },\n getEntityConfig,\n } = useConfig()\n\n const [relatedCollection] = useState(() => getEntityConfig({ collectionSlug: relationTo }))\n\n const { i18n, t } = useTranslation()\n const [cacheBust, dispatchCacheBust] = useReducer((state) => state + 1, 0)\n const [{ data }, { setParams }] = usePayloadAPI(\n `${serverURL}${api}/${relatedCollection.slug}/${value}`,\n { initialParams },\n )\n\n const { closeDocumentDrawer, DocumentDrawer, DocumentDrawerToggler } = useLexicalDocumentDrawer({\n id: value,\n collectionSlug: relatedCollection.slug,\n })\n\n const removeRelationship = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey!)?.remove()\n })\n }, [editor, nodeKey])\n\n const updateRelationship = React.useCallback(() => {\n setParams({\n ...initialParams,\n cacheBust, // do this to get the usePayloadAPI to re-fetch the data even though the URL string hasn't changed\n })\n\n closeDocumentDrawer()\n dispatchCacheBust()\n }, [cacheBust, setParams, closeDocumentDrawer])\n\n return (\n <div className={`${baseClass}__contents`} contentEditable={false} ref={relationshipElemRef}>\n <div className={`${baseClass}__wrap`}>\n <p className={`${baseClass}__label`}>\n {t('fields:labelRelationship', {\n label: relatedCollection.labels?.singular\n ? getTranslation(relatedCollection.labels?.singular, i18n)\n : relatedCollection.slug,\n })}\n </p>\n <DocumentDrawerToggler className={`${baseClass}__doc-drawer-toggler`}>\n <p className={`${baseClass}__title`}>\n {data ? data[relatedCollection?.admin?.useAsTitle || 'id'] : value}\n </p>\n </DocumentDrawerToggler>\n </div>\n {isEditable && (\n <div className={`${baseClass}__actions`}>\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__swapButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"swap\"\n onClick={() => {\n if (nodeKey) {\n editor.dispatchCommand(INSERT_RELATIONSHIP_WITH_DRAWER_COMMAND, {\n replace: { nodeKey },\n })\n }\n }}\n round\n tooltip={t('fields:swapRelationship')}\n />\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeRelationship()\n }}\n round\n tooltip={t('fields:removeRelationship')}\n />\n </div>\n )}\n\n {!!value && <DocumentDrawer onSave={updateRelationship} />}\n </div>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SAASC,MAAM,EAAEC,SAAS,EAAEC,aAAa,EAAEC,cAAc,QAAQ;AACjE,SAASC,aAAa,QAAQ;AAC9B,OAAOC,KAAA,IAASC,WAAW,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAIjE,SAASC,wBAAwB,QAAQ;AAEzC,SAASC,uCAAuC,QAAQ;AAExD,MAAMC,aAAA,GAAgB;EACpBC,KAAA,EAAO;AACT;AASA,OAAO,MAAMC,qBAAA,GAA0CC,KAAA;EACrD,MAAM;IACJC,SAAA,EAAWC,SAAS;IACpBC,IAAA,EAAM;MAAEC,UAAU;MAAEC;IAAK,CAAE;IAC3BC;EAAO,CACR,GAAGN,KAAA;EAEJ,IAAI,OAAOK,KAAA,KAAU,UAAU;IAC7B,MAAM,IAAIE,KAAA,CACR;EAEJ;EAEA,MAAMC,mBAAA,GAAsBf,MAAA,CAA8B;EAE1D,MAAM,CAACgB,MAAA,CAAO,GAAG3B,yBAAA;EACjB,MAAM4B,UAAA,GAAa3B,kBAAA;EACnB,MAAM;IACJ4B,MAAA,EAAQ;MACNC,MAAA,EAAQ;QAAEC;MAAG,CAAE;MACfC;IAAS,CACV;IACDC;EAAe,CAChB,GAAG7B,SAAA;EAEJ,MAAM,CAAC8B,iBAAA,CAAkB,GAAGtB,QAAA,CAAS,MAAMqB,eAAA,CAAgB;IAAEE,cAAA,EAAgBb;EAA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egC,iBAAA,CAAkBsB,MAAM,EAAEC,QAAA,EAAUrB,IAAA,IACnDF,iBAAA,CAAkBQ;QACxB;uBAEFY,IAAA,CAACT,qBAAA;QAAsB1B,SAAA,EAAW,GAAGC,SAAA,sBAA+B;kBAClE,aAAAkC,IAAA,CAAC;UAAEnC,SAAA,EAAW,GAAGC,SAAA,SAAkB;oBAChCC,IAAA,GAAOA,IAAI,CAACa,iBAAA,EAAmBwB,KAAA,EAAOC,UAAA,IAAc,KAAK,GAAGpC;;;QAIlEK,UAAA,iBACCuB,KAAA,CAAC;MAAIhC,SAAA,EAAW,GAAGC,SAAA,WAAoB;8BACrCkC,IAAA,CAACnD,MAAA;QACCyD,WAAA,EAAY;QACZzC,SAAA,EAAW,GAAGC,SAAA,cAAuB;QACrCyC,QAAA,EAAU,CAACjC,UAAA;QACXkC,EAAA,EAAG;QACHC,IAAA,EAAK;QACLC,OAAA,EAASA,CAAA;UACP,IAAIxC,OAAA,EAAS;YACXG,MAAA,CAAOsC,eAAe,CAACnD,uCAAA,EAAyC;cAC9DoD,OAAA,EAAS;gBAAE1C;cAAQ;YACrB;UACF;QACF;QACA2C,KAAK;QACLC,OAAA,EAAS/B,CAAA,CAAE;uBAEbiB,IAAA,CAACnD,MAAA;QACCyD,WAAA,EAAY;QACZzC,SAAA,EAAW,GAAGC,SAAA,gBAAyB;QACvCyC,QAAA,EAAU,CAACjC,UAAA;QACXmC,IAAA,EAAK;QACLC,OAAA,EAAUK,CAAA;UACRA,CAAA,CAAEC,cAAc;UAChBvB,kBAAA;QACF;QACAoB,KAAK;QACLC,OAAA,EAAS/B,CAAA,CAAE;;QAKhB,CAAC,CAACd,KAAA,iBAAS+B,IAAA,CAACV,cAAA;MAAe2B,MAAA,EAAQrB;;;AAG1C","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DOMConversionMap, EditorConfig, LexicalEditor, LexicalNode } from 'lexical';
|
|
2
1
|
import type { JSX } from 'react';
|
|
2
|
+
import { type DOMConversionMap, type EditorConfig, type LexicalEditor, type LexicalNode } from 'lexical';
|
|
3
3
|
import type { RelationshipData, SerializedRelationshipNode } from '../../server/nodes/RelationshipNode.js';
|
|
4
4
|
import { RelationshipServerNode } from '../../server/nodes/RelationshipNode.js';
|
|
5
5
|
export declare class RelationshipNode extends RelationshipServerNode {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/client/nodes/RelationshipNode.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"RelationshipNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/client/nodes/RelationshipNode.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,SAAS,CAAA;AAGhB,OAAO,KAAK,EACV,gBAAgB,EAChB,0BAA0B,EAC3B,MAAM,wCAAwC,CAAA;AAE/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAA;AAsB/E,qBAAa,gBAAiB,SAAQ,sBAAsB;WAC1C,KAAK,CAAC,IAAI,EAAE,sBAAsB,GAAG,sBAAsB;WAI3D,OAAO,IAAI,MAAM;WAIjB,SAAS,IAAI,gBAAgB,CAAC,cAAc,CAAC,GAAG,IAAI;WAiBpD,UAAU,CAAC,cAAc,EAAE,0BAA0B,GAAG,gBAAgB;IAc/E,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO;IAWlE,UAAU,IAAI,0BAA0B;CAGlD;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,gBAAgB,GAAG,gBAAgB,CAMhF;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,gBAAgB,GAAG,SAAS,GACtD,IAAI,IAAI,gBAAgB,CAE1B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import { $applyNodeReplacement } from 'lexical';
|
|
4
5
|
import * as React from 'react';
|
|
5
6
|
import { RelationshipServerNode } from '../../server/nodes/RelationshipNode.js';
|
|
6
7
|
const RelationshipComponent = /*#__PURE__*/React.lazy(() => import('../components/RelationshipComponent.js').then(module => ({
|
|
@@ -65,9 +66,9 @@ export class RelationshipNode extends RelationshipServerNode {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
export function $createRelationshipNode(data) {
|
|
68
|
-
return new RelationshipNode({
|
|
69
|
+
return $applyNodeReplacement(new RelationshipNode({
|
|
69
70
|
data
|
|
70
|
-
});
|
|
71
|
+
}));
|
|
71
72
|
}
|
|
72
73
|
export function $isRelationshipNode(node) {
|
|
73
74
|
return node instanceof RelationshipNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipNode.js","names":["React","RelationshipServerNode","RelationshipComponent","lazy","then","module","default","$relationshipElementToNode","domNode","id","getAttribute","relationTo","node","$createRelationshipNode","value","RelationshipNode","clone","getType","importDOM","div","hasAttribute","conversion","priority","importJSON","serializedNode","version","importedData","setFormat","format","decorate","editor","config","_jsx","className","theme","relationship","data","__data","__format","nodeKey","getKey","exportJSON","$isRelationshipNode"],"sources":["../../../../../src/features/relationship/client/nodes/RelationshipNode.tsx"],"sourcesContent":["'use client'\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n} from 'lexical'\nimport
|
|
1
|
+
{"version":3,"file":"RelationshipNode.js","names":["$applyNodeReplacement","React","RelationshipServerNode","RelationshipComponent","lazy","then","module","default","$relationshipElementToNode","domNode","id","getAttribute","relationTo","node","$createRelationshipNode","value","RelationshipNode","clone","getType","importDOM","div","hasAttribute","conversion","priority","importJSON","serializedNode","version","importedData","setFormat","format","decorate","editor","config","_jsx","className","theme","relationship","data","__data","__format","nodeKey","getKey","exportJSON","$isRelationshipNode"],"sources":["../../../../../src/features/relationship/client/nodes/RelationshipNode.tsx"],"sourcesContent":["'use client'\nimport type { JSX } from 'react'\n\nimport {\n $applyNodeReplacement,\n type DOMConversionMap,\n type DOMConversionOutput,\n type EditorConfig,\n type LexicalEditor,\n type LexicalNode,\n} from 'lexical'\nimport * as React from 'react'\n\nimport type {\n RelationshipData,\n SerializedRelationshipNode,\n} from '../../server/nodes/RelationshipNode.js'\n\nimport { RelationshipServerNode } from '../../server/nodes/RelationshipNode.js'\n\nconst RelationshipComponent = React.lazy(() =>\n import('../components/RelationshipComponent.js').then((module) => ({\n default: module.RelationshipComponent,\n })),\n)\n\nfunction $relationshipElementToNode(domNode: HTMLDivElement): DOMConversionOutput | null {\n const id = domNode.getAttribute('data-lexical-relationship-id')\n const relationTo = domNode.getAttribute('data-lexical-relationship-relationTo')\n\n if (id != null && relationTo != null) {\n const node = $createRelationshipNode({\n relationTo,\n value: id,\n })\n return { node }\n }\n return null\n}\n\nexport class RelationshipNode extends RelationshipServerNode {\n static override clone(node: RelationshipServerNode): RelationshipServerNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {\n div: (domNode: HTMLDivElement) => {\n if (\n !domNode.hasAttribute('data-lexical-relationship-relationTo') ||\n !domNode.hasAttribute('data-lexical-relationship-id')\n ) {\n return null\n }\n return {\n conversion: $relationshipElementToNode,\n priority: 2,\n }\n },\n }\n }\n\n static override importJSON(serializedNode: SerializedRelationshipNode): RelationshipNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n\n const importedData: RelationshipData = {\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n const node = $createRelationshipNode(importedData)\n node.setFormat(serializedNode.format)\n return node\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return (\n <RelationshipComponent\n className={config.theme.relationship ?? 'LexicalEditorTheme__relationship'}\n data={this.__data}\n format={this.__format}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedRelationshipNode {\n return super.exportJSON()\n }\n}\n\nexport function $createRelationshipNode(data: RelationshipData): RelationshipNode {\n return $applyNodeReplacement(\n new RelationshipNode({\n data,\n }),\n )\n}\n\nexport function $isRelationshipNode(\n node: LexicalNode | null | RelationshipNode | undefined,\n): node is RelationshipNode {\n return node instanceof RelationshipNode\n}\n"],"mappings":"AAAA;;;AAGA,SACEA,qBAAqB,QAMhB;AACP,YAAYC,KAAA,MAAW;AAOvB,SAASC,sBAAsB,QAAQ;AAEvC,MAAMC,qBAAA,gBAAwBF,KAAA,CAAMG,IAAI,CAAC,MACvC,MAAM,CAAC,0CAA0CC,IAAI,CAAEC,MAAA,KAAY;EACjEC,OAAA,EAASD,MAAA,CAAOH;AAClB;AAGF,SAASK,2BAA2BC,OAAuB;EACzD,MAAMC,EAAA,GAAKD,OAAA,CAAQE,YAAY,CAAC;EAChC,MAAMC,UAAA,GAAaH,OAAA,CAAQE,YAAY,CAAC;EAExC,IAAID,EAAA,IAAM,QAAQE,UAAA,IAAc,MAAM;IACpC,MAAMC,IAAA,GAAOC,uBAAA,CAAwB;MACnCF,UAAA;MACAG,KAAA,EAAOL;IACT;IACA,OAAO;MAAEG;IAAK;EAChB;EACA,OAAO;AACT;AAEA,OAAO,MAAMG,gBAAA,SAAyBd,sBAAA;EACpC,OAAgBe,MAAMJ,IAA4B,EAA0B;IAC1E,OAAO,KAAK,CAACI,KAAA,CAAMJ,IAAA;EACrB;EAEA,OAAgBK,QAAA,EAAkB;IAChC,OAAO,KAAK,CAACA,OAAA;EACf;EAEA,OAAgBC,UAAA,EAAqD;IACnE,OAAO;MACLC,G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js';
|
|
2
|
-
import type { DOMConversionMap, DOMExportOutput, EditorConfig, ElementFormatType, LexicalEditor, LexicalNode, NodeKey } from 'lexical';
|
|
3
2
|
import type { CollectionSlug, DataFromCollectionSlug } from 'payload';
|
|
4
3
|
import type { JSX } from 'react';
|
|
5
4
|
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
5
|
+
import { type DOMConversionMap, type DOMExportOutput, type EditorConfig, type ElementFormatType, type LexicalEditor, type LexicalNode, type NodeKey } from 'lexical';
|
|
6
6
|
import type { StronglyTypedLeafNode } from '../../../../nodeTypes.js';
|
|
7
7
|
export type RelationshipData = {
|
|
8
8
|
[TCollectionSlug in CollectionSlug]: {
|
|
@@ -23,6 +23,7 @@ export declare class RelationshipServerNode extends DecoratorBlockNode {
|
|
|
23
23
|
static importDOM(): DOMConversionMap<HTMLDivElement> | null;
|
|
24
24
|
static importJSON(serializedNode: SerializedRelationshipNode): RelationshipServerNode;
|
|
25
25
|
static isInline(): false;
|
|
26
|
+
createDOM(config?: EditorConfig): HTMLElement;
|
|
26
27
|
decorate(_editor: LexicalEditor, _config: EditorConfig): JSX.Element;
|
|
27
28
|
exportDOM(): DOMExportOutput;
|
|
28
29
|
exportJSON(): SerializedRelationshipNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/server/nodes/RelationshipNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"RelationshipNode.d.ts","sourceRoot":"","sources":["../../../../../src/features/relationship/server/nodes/RelationshipNode.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAA;AAC/F,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AACr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AAC,OAAO;IAIpE,SAAS,IAAI,eAAe;IAa5B,UAAU,IAAI,0BAA0B;IASjD,OAAO,IAAI,gBAAgB;IAIlB,cAAc,IAAI,MAAM;IAIjC,OAAO,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI;CAItC;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,gBAAgB,GAAG,sBAAsB,CAM5F;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,sBAAsB,GAAG,SAAS,GAC5D,IAAI,IAAI,sBAAsB,CAEhC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js';
|
|
2
|
+
import { addClassNamesToElement } from '@lexical/utils';
|
|
3
|
+
import { $applyNodeReplacement } from 'lexical';
|
|
2
4
|
function $relationshipElementToServerNode(domNode) {
|
|
3
5
|
const id = domNode.getAttribute('data-lexical-relationship-id');
|
|
4
6
|
const relationTo = domNode.getAttribute('data-lexical-relationship-relationTo');
|
|
@@ -61,6 +63,11 @@ export class RelationshipServerNode extends DecoratorBlockNode {
|
|
|
61
63
|
static isInline() {
|
|
62
64
|
return false;
|
|
63
65
|
}
|
|
66
|
+
createDOM(config) {
|
|
67
|
+
const element = document.createElement('div');
|
|
68
|
+
addClassNamesToElement(element, config?.theme?.relationship);
|
|
69
|
+
return element;
|
|
70
|
+
}
|
|
64
71
|
decorate(_editor, _config) {
|
|
65
72
|
return null;
|
|
66
73
|
}
|
|
@@ -94,9 +101,9 @@ export class RelationshipServerNode extends DecoratorBlockNode {
|
|
|
94
101
|
}
|
|
95
102
|
}
|
|
96
103
|
export function $createServerRelationshipNode(data) {
|
|
97
|
-
return new RelationshipServerNode({
|
|
104
|
+
return $applyNodeReplacement(new RelationshipServerNode({
|
|
98
105
|
data
|
|
99
|
-
});
|
|
106
|
+
}));
|
|
100
107
|
}
|
|
101
108
|
export function $isServerRelationshipNode(node) {
|
|
102
109
|
return node instanceof RelationshipServerNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RelationshipNode.js","names":["DecoratorBlockNode","$relationshipElementToServerNode","domNode","id","getAttribute","relationTo","node","$createServerRelationshipNode","value","RelationshipServerNode","__data","constructor","data","format","key","clone","__format","__key","getType","importDOM","div","hasAttribute","conversion","priority","importJSON","serializedNode","version","importedData","setFormat","isInline","
|
|
1
|
+
{"version":3,"file":"RelationshipNode.js","names":["DecoratorBlockNode","addClassNamesToElement","$applyNodeReplacement","$relationshipElementToServerNode","domNode","id","getAttribute","relationTo","node","$createServerRelationshipNode","value","RelationshipServerNode","__data","constructor","data","format","key","clone","__format","__key","getType","importDOM","div","hasAttribute","conversion","priority","importJSON","serializedNode","version","importedData","setFormat","isInline","createDOM","config","element","document","createElement","theme","relationship","decorate","_editor","_config","exportDOM","setAttribute","String","text","createTextNode","getTextContent","append","exportJSON","getData","type","getLatest","setData","writable","getWritable","$isServerRelationshipNode"],"sources":["../../../../../src/features/relationship/server/nodes/RelationshipNode.tsx"],"sourcesContent":["import type { SerializedDecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport type { CollectionSlug, DataFromCollectionSlug } from 'payload'\nimport type { JSX } from 'react'\n\nimport { DecoratorBlockNode } from '@lexical/react/LexicalDecoratorBlockNode.js'\nimport { addClassNamesToElement } from '@lexical/utils'\nimport {\n $applyNodeReplacement,\n type DOMConversionMap,\n type DOMConversionOutput,\n type DOMExportOutput,\n type EditorConfig,\n type ElementFormatType,\n type LexicalEditor,\n type LexicalNode,\n type NodeKey,\n} from 'lexical'\n\nimport type { StronglyTypedLeafNode } from '../../../../nodeTypes.js'\n\nexport type RelationshipData = {\n [TCollectionSlug in CollectionSlug]: {\n relationTo: TCollectionSlug\n value: DataFromCollectionSlug<TCollectionSlug> | number | string\n }\n}[CollectionSlug]\n\nexport type SerializedRelationshipNode = RelationshipData &\n StronglyTypedLeafNode<SerializedDecoratorBlockNode, 'relationship'>\n\nfunction $relationshipElementToServerNode(domNode: HTMLDivElement): DOMConversionOutput | null {\n const id = domNode.getAttribute('data-lexical-relationship-id')\n const relationTo = domNode.getAttribute('data-lexical-relationship-relationTo')\n\n if (id != null && relationTo != null) {\n const node = $createServerRelationshipNode({\n relationTo,\n value: id,\n })\n return { node }\n }\n return null\n}\n\nexport class RelationshipServerNode extends DecoratorBlockNode {\n __data: RelationshipData\n\n constructor({\n data,\n format,\n key,\n }: {\n data: RelationshipData\n format?: ElementFormatType\n key?: NodeKey\n }) {\n super(format, key)\n this.__data = data\n }\n\n static override clone(node: RelationshipServerNode): RelationshipServerNode {\n return new this({\n data: node.__data,\n format: node.__format,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'relationship'\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {\n div: (domNode: HTMLDivElement) => {\n if (\n !domNode.hasAttribute('data-lexical-relationship-relationTo') ||\n !domNode.hasAttribute('data-lexical-relationship-id')\n ) {\n return null\n }\n return {\n conversion: $relationshipElementToServerNode,\n priority: 2,\n }\n },\n }\n }\n\n static override importJSON(serializedNode: SerializedRelationshipNode): RelationshipServerNode {\n if (serializedNode.version === 1 && (serializedNode?.value as unknown as { id: string })?.id) {\n serializedNode.value = (serializedNode.value as unknown as { id: string }).id\n }\n\n const importedData: RelationshipData = {\n relationTo: serializedNode.relationTo,\n value: serializedNode.value,\n }\n const node = $createServerRelationshipNode(importedData)\n node.setFormat(serializedNode.format)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n override createDOM(config?: EditorConfig): HTMLElement {\n const element = document.createElement('div')\n addClassNamesToElement(element, config?.theme?.relationship)\n return element\n }\n\n override decorate(_editor: LexicalEditor, _config: EditorConfig): JSX.Element {\n return null as unknown as JSX.Element\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('div')\n element.setAttribute(\n 'data-lexical-relationship-id',\n String(typeof this.__data?.value === 'object' ? this.__data?.value?.id : this.__data?.value),\n )\n element.setAttribute('data-lexical-relationship-relationTo', this.__data?.relationTo)\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n override exportJSON(): SerializedRelationshipNode {\n return {\n ...super.exportJSON(),\n ...this.getData(),\n type: 'relationship',\n version: 2,\n }\n }\n\n getData(): RelationshipData {\n return this.getLatest().__data\n }\n\n override getTextContent(): string {\n return `${this.__data?.relationTo} relation to ${typeof this.__data?.value === 'object' ? this.__data?.value?.id : this.__data?.value}`\n }\n\n setData(data: RelationshipData): void {\n const writable = this.getWritable()\n writable.__data = data\n }\n}\n\nexport function $createServerRelationshipNode(data: RelationshipData): RelationshipServerNode {\n return $applyNodeReplacement(\n new RelationshipServerNode({\n data,\n }),\n )\n}\n\nexport function $isServerRelationshipNode(\n node: LexicalNode | null | RelationshipServerNode | undefined,\n): node is RelationshipServerNode {\n return node instanceof RelationshipServerNode\n}\n"],"mappings":"AAIA,SAASA,kBAAkB,QAAQ;AACnC,SAASC,sBAAsB,QAAQ;AACvC,SACEC,qBAAqB,QAShB;AAcP,SAASC,iCAAiCC,OAAuB;EAC/D,MAAMC,EAAA,GAAKD,OAAA,CAAQE,YAAY,CAAC;EAChC,MAAMC,UAAA,GAAaH,OAAA,CAAQE,YAAY,CAAC;EAExC,IAAID,EAAA,IAAM,QAAQE,UAAA,IAAc,MAAM;IACpC,MAAMC,IAAA,GAAOC,6BAAA,CAA8B;MACzCF,UAAA;MACAG,KAAA,EAAOL;IACT;IACA,OAAO;MAAEG;IAAK;EAChB;EACA,OAAO;AACT;AAEA,OAAO,MAAMG,sBAAA,SAA+BX,kBAAA;EAC1CY,MAAA;EAEAC,YAAY;IACVC,IAAI;IACJC,MAAM;IACNC;EAAG,CAKJ,EAAE;IACD,KAAK,CAACD,MAAA,EAAQC,GAAA;IACd,IAAI,CAACJ,MAAM,GAAGE,IAAA;EAChB;EAEA,OAAgBG,MAAMT,IAA4B,EAA0B;IAC1E,OAAO,IAAI,IAAI,CAAC;MACdM,IAAA,EAA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MAAA,CAAO,OAAO,IAAI,CAAChC,MAAM,EAAEF,KAAA,KAAU,WAAW,IAAI,CAACE,MAAM,EAAEF,KAAA,EAAOL,EAAA,GAAK,IAAI,CAACO,MAAM,EAAEF,KAAA;IAExFwB,OAAA,CAAQS,YAAY,CAAC,wCAAwC,IAAI,CAAC/B,MAAM,EAAEL,UAAA;IAE1E,MAAMsC,IAAA,GAAOV,QAAA,CAASW,cAAc,CAAC,IAAI,CAACC,cAAc;IACxDb,OAAA,CAAQc,MAAM,CAACH,IAAA;IACf,OAAO;MAAEX;IAAQ;EACnB;EAESe,WAAA,EAAyC;IAChD,OAAO;MACL,GAAG,KAAK,CAACA,UAAA,EAAY;MACrB,GAAG,IAAI,CAACC,OAAO,EAAE;MACjBC,IAAA,EAAM;MACNvB,OAAA,EAAS;IACX;EACF;EAEAsB,QAAA,EAA4B;IAC1B,OAAO,IAAI,CAACE,SAAS,GAAGxC,MAAM;EAChC;EAESmC,eAAA,EAAyB;IAChC,OAAO,GAAG,IAAI,CAACnC,MAAM,EAAEL,UAAA,gBAA0B,OAAO,IAAI,CAACK,MAAM,EAAEF,KAAA,KAAU,WAAW,IAAI,CAACE,MAAM,EAAEF,KAAA,EAAOL,EAAA,GAAK,IAAI,CAACO,MAAM,EAAEF,KAAA,EAAO;EACzI;EAEA2C,QAAQvC,IAAsB,EAAQ;IACpC,MAAMwC,QAAA,GAAW,IAAI,CAACC,WAAW;IACjCD,QAAA,CAAS1C,MAAM,GAAGE,IAAA;EACpB;AACF;AAEA,OAAO,SAASL,8BAA8BK,IAAsB;EAClE,OAAOZ,qBAAA,CACL,IAAIS,sBAAA,CAAuB;IACzBG;EACF;AAEJ;AAEA,OAAO,SAAS0C,0BACdhD,IAA6D;EAE7D,OAAOA,IAAA,YAAgBG,sBAAA;AACzB","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GenericLanguages, I18n, I18nClient } from '@payloadcms/translations';
|
|
2
2
|
import type { JSONSchema4 } from 'json-schema';
|
|
3
3
|
import type { Klass, LexicalNode, LexicalNodeReplacement, SerializedEditorState, SerializedLexicalNode } from 'lexical';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Field, FieldSchemaMap, ImportMapGenerators, JsonObject, PayloadComponent, PayloadRequest, PopulateType, ReplaceAny, RequestContext, RichTextField, RichTextHooks, SanitizedConfig, ValidateOptions, ValidationFieldError } from 'payload';
|
|
5
5
|
import type { ServerEditorConfig } from '../lexical/config/types.js';
|
|
6
6
|
import type { Transformer } from '../packages/@lexical/markdown/index.js';
|
|
7
7
|
import type { LexicalRichTextField } from '../types.js';
|
|
@@ -221,7 +221,7 @@ export type ServerFeature<ServerProps, ClientFeatureProps> = {
|
|
|
221
221
|
*/
|
|
222
222
|
componentImports?: {
|
|
223
223
|
[key: string]: PayloadComponent;
|
|
224
|
-
} |
|
|
224
|
+
} | ImportMapGenerators[0] | PayloadComponent[];
|
|
225
225
|
generatedTypes?: {
|
|
226
226
|
modifyOutputSchema: (args: {
|
|
227
227
|
collectionIDFieldTypes: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typesServer.d.ts","sourceRoot":"","sources":["../../src/features/typesServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EACX,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"typesServer.d.ts","sourceRoot":"","sources":["../../src/features/typesServer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM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ources":["../../src/features/typesServer.ts"],"sourcesContent":["import type { GenericLanguages, I18n, I18nClient } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type {\n Klass,\n LexicalNode,\n LexicalNodeReplacement,\n SerializedEditorState,\n SerializedLexicalNode,\n} from 'lexical'\nimport type {\n Config,\n Field,\n FieldSchemaMap,\n JsonObject,\n PayloadComponent,\n PayloadRequest,\n PopulateType,\n ReplaceAny,\n RequestContext,\n RichTextField,\n RichTextHooks,\n SanitizedConfig,\n ValidateOptions,\n ValidationFieldError,\n} from 'payload'\n\nimport type { ServerEditorConfig } from '../lexical/config/types.js'\nimport type { Transformer } from '../packages/@lexical/markdown/index.js'\nimport type { LexicalRichTextField } from '../types.js'\nimport type { HTMLConverter } from './converters/lexicalToHtml_deprecated/converter/types.js'\nimport type { BaseClientFeatureProps } from './typesClient.js'\n\nexport type PopulationPromise<T extends SerializedLexicalNode = SerializedLexicalNode> = (args: {\n context: RequestContext\n currentDepth: number\n depth: number\n draft: boolean\n /**\n * This maps all population promises to the node type\n */\n editorPopulationPromises: Map<string, Array<PopulationPromise>>\n field: LexicalRichTextField\n /**\n * fieldPromises are used for things like field hooks. They will be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n node: T\n overrideAccess: boolean\n parentIsLocalized: boolean\n populationPromises: Promise<void>[]\n req: PayloadRequest\n showHiddenFields: boolean\n siblingDoc: JsonObject\n}) => void\n\nexport type NodeValidation<T extends SerializedLexicalNode = SerializedLexicalNode> = ({\n node,\n nodeValidations,\n validation,\n}: {\n node: T\n nodeValidations: Map<string, Array<NodeValidation>>\n validation: {\n options: ValidateOptions<unknown, unknown, RichTextField, SerializedEditorState>\n value: SerializedEditorState\n }\n}) => Promise<string | true> | string | true\n\nexport type FeatureProviderProviderServer<\n UnSanitizedServerFeatureProps = undefined,\n ServerFeatureProps = UnSanitizedServerFeatureProps,\n ClientFeatureProps = undefined,\n> = (\n props?: UnSanitizedServerFeatureProps,\n) => FeatureProviderServer<UnSanitizedServerFeatureProps, ServerFeatureProps, ClientFeatureProps>\n\nexport type FeatureProviderServer<\n UnSanitizedServerFeatureProps = undefined,\n ServerFeatureProps = UnSanitizedServerFeatureProps,\n ClientFeatureProps = undefined,\n> = {\n /** Keys of dependencies needed for this feature. These dependencies do not have to be loaded first, but they have to exist, otherwise an error will be thrown. */\n dependencies?: string[]\n /** Keys of priority dependencies needed for this feature. These dependencies have to be loaded first AND have to exist, otherwise an error will be thrown. They will be available in the `feature` property. */\n dependenciesPriority?: string[]\n /** Keys of soft-dependencies needed for this feature. These are optional. Payload will attempt to load them before this feature, but doesn't throw an error if that's not possible. */\n dependenciesSoft?: string[]\n\n /**\n * This is being called during the payload sanitization process\n */\n feature:\n | ((props: {\n config: SanitizedConfig\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ServerFeatureProviderMap\n isRoot?: boolean\n parentIsLocalized: boolean\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedServerFeatureMap\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ServerEditorConfig\n }) =>\n | Promise<ServerFeature<ServerFeatureProps, ClientFeatureProps>>\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>)\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>\n key: string\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n serverFeatureProps: UnSanitizedServerFeatureProps\n}\n\nexport type AfterReadNodeHookArgs<T extends SerializedLexicalNode> = {\n /**\n * Only available in `afterRead` hooks.\n */\n currentDepth: number\n /**\n * Only available in `afterRead` hooks.\n */\n depth: number\n draft: boolean\n fallbackLocale: string | string[]\n /**\n * Only available in `afterRead` field hooks.\n */\n fieldPromises: Promise<void>[]\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany: boolean\n flattenLocales: boolean\n /**\n * The requested locale.\n */\n locale: string\n overrideAccess: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n populateArg?: PopulateType\n /**\n * Only available in `afterRead` field hooks.\n */\n populationPromises: Promise<void>[]\n /**\n * Only available in `afterRead` hooks.\n */\n showHiddenFields: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n triggerAccessControl: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n triggerHooks: boolean\n}\n\nexport type AfterChangeNodeHookArgs<T extends SerializedLexicalNode> = {\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n previousNode: T\n}\nexport type BeforeValidateNodeHookArgs<T extends SerializedLexicalNode> = {\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n overrideAccess: boolean\n}\n\nexport type BeforeChangeNodeHookArgs<T extends SerializedLexicalNode> = {\n /**\n * Only available in `beforeChange` hooks.\n */\n errors: ValidationFieldError[]\n mergeLocaleActions: (() => Promise<void> | void)[]\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n /**\n * The original node with locales (not modified by any hooks).\n */\n originalNodeWithLocales?: T\n previousNode: T\n\n skipValidation: boolean\n}\n\nexport type BaseNodeHookArgs<T extends SerializedLexicalNode> = {\n context: RequestContext\n /** The value of the node. */\n node: T\n parentRichTextFieldPath: (number | string)[]\n parentRichTextFieldSchemaPath: string[]\n /** The payload request object. It is mocked for Local API operations. */\n req: PayloadRequest\n}\n\nexport type AfterReadNodeHook<T extends SerializedLexicalNode> = (\n args: AfterReadNodeHookArgs<T> & BaseNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type AfterChangeNodeHook<T extends SerializedLexicalNode> = (\n args: AfterChangeNodeHookArgs<T> & BaseNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type BeforeChangeNodeHook<T extends SerializedLexicalNode> = (\n args: BaseNodeHookArgs<T> & BeforeChangeNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type BeforeValidateNodeHook<T extends SerializedLexicalNode> = (\n args: BaseNodeHookArgs<T> & BeforeValidateNodeHookArgs<T>,\n) => Promise<T> | T\n\n// Define the node with hooks that use the node's exportJSON return type\nexport type NodeWithHooks<T extends LexicalNode = any> = {\n /**\n * Allows you to define how a node can be serialized into different formats. Currently, only supports html.\n * Markdown converters are defined in `markdownTransformers` and not here.\n *\n * @deprecated - will be removed in 4.0\n */\n converters?: {\n /**\n * @deprecated - will be removed in 4.0\n */\n html?: HTMLConverter<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n }\n /**\n * If a node includes sub-fields (e.g. block and link nodes), passing those subFields here will make payload\n * automatically populate, run hooks, and generate component import maps for them\n */\n getSubFields?: (args: {\n /**\n * Optional. If not provided, all possible sub-fields should be returned.\n */\n node?: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>\n req?: PayloadRequest\n }) => Field[] | null\n /**\n * If a node includes sub-fields, the sub-fields data needs to be returned here, alongside `getSubFields` which returns their schema.\n */\n getSubFieldsData?: (args: {\n node: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>\n req: PayloadRequest\n }) => JsonObject\n /**\n * Allows you to run population logic when a node's data was requested from graphQL.\n * While `getSubFields` and `getSubFieldsData` automatically handle populating sub-fields (since they run hooks on them), those are only populated in the Rest API.\n * This is because the Rest API hooks do not have access to the 'depth' property provided by graphQL.\n * In order for them to be populated correctly in graphQL, the population logic needs to be provided here.\n */\n graphQLPopulationPromises?: Array<\n PopulationPromise<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n /**\n * Just like payload fields, you can provide hooks which are run for this specific node. These are called Node Hooks.\n */\n hooks?: {\n afterChange?: Array<AfterChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n afterRead?: Array<AfterReadNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeChange?: Array<BeforeChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeValidate?: Array<\n BeforeValidateNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n }\n /**\n * The actual lexical node needs to be provided here. This also supports [lexical node replacements](https://lexical.dev/docs/concepts/node-replacement).\n */\n node: Klass<T> | LexicalNodeReplacement\n /**\n * This allows you to provide node validations, which are run when your document is being validated, alongside other payload fields.\n * You can use it to throw a validation error for a specific node in case its data is incorrect.\n */\n validations?: Array<NodeValidation<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n}\n\nexport type ServerFeature<ServerProps, ClientFeatureProps> = {\n ClientFeature?: PayloadComponent<never, BaseClientFeatureProps<ClientFeatureProps>>\n /**\n * This determines what props will be available on the Client.\n */\n clientFeatureProps?: ClientFeatureProps\n /**\n * Adds payload components to the importMap.\n *\n * If an object is provided, the imported components will automatically be made available to the client feature, keyed by the object's keys.\n */\n componentImports?:\n | {\n [key: string]: PayloadComponent\n }\n // @ts-expect-error - TODO: fix this\n | Config['admin']['importMap']['generators'][0]\n | PayloadComponent[]\n generatedTypes?: {\n modifyOutputSchema: (args: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n /**\n * Current schema which will be modified by this function.\n */\n currentSchema: JSONSchema4\n field: LexicalRichTextField\n i18n?: I18n\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n }\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n field: RichTextField\n i18n: I18nClient\n props: ServerProps\n schemaMap: FieldSchemaMap\n schemaPath: string\n }) => FieldSchemaMap | null\n hooks?: RichTextHooks\n /**\n * Here you can provide i18n translations for your feature. These will only be available on the server and client.\n *\n * Translations here are automatically scoped to `lexical.featureKey.yourKey`\n *\n * @Example\n * ```ts\n * i18n: {\n * en: {\n * label: 'Horizontal Rule',\n * },\n * de: {\n * label: 'Trennlinie',\n * },\n * }\n * ```\n * In order to access these translations, you would use `i18n.t('lexical:horizontalRule:label')`.\n */\n i18n?: Partial<GenericLanguages>\n markdownTransformers?: (\n | ((props: { allNodes: Array<NodeWithHooks>; allTransformers: Transformer[] }) => Transformer)\n | Transformer\n )[]\n nodes?: Array<NodeWithHooks>\n\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n sanitizedServerFeatureProps?: ServerProps\n}\n\nexport type ResolvedServerFeature<ServerProps, ClientFeatureProps> = {\n order: number\n} & Required<\n Pick<\n FeatureProviderServer<ServerProps, ClientFeatureProps>,\n 'dependencies' | 'dependenciesPriority' | 'dependenciesSoft' | 'key'\n >\n> &\n ServerFeature<ServerProps, ClientFeatureProps>\n\nexport type ResolvedServerFeatureMap = Map<string, ResolvedServerFeature<any, any>>\n\nexport type ServerFeatureProviderMap = Map<string, FeatureProviderServer<any, any, any>>\n\nexport type SanitizedServerFeatures = {\n /** The node types mapped to their converters */\n converters: {\n html: HTMLConverter[]\n }\n /** The keys of all enabled features */\n enabledFeatures: string[]\n generatedTypes: {\n modifyOutputSchemas: Array<\n (args: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n /**\n * Current schema which will be modified by this function.\n */\n currentSchema: JSONSchema4\n field: LexicalRichTextField\n i18n?: I18n\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n >\n }\n /** The node types mapped to their hooks */\n\n getSubFields?: Map<\n string,\n (args: { node: SerializedLexicalNode; req: PayloadRequest }) => Field[] | null\n >\n getSubFieldsData?: Map<\n string,\n (args: { node: SerializedLexicalNode; req: PayloadRequest }) => JsonObject\n >\n graphQLPopulationPromises: Map<string, Array<PopulationPromise>>\n hooks: RichTextHooks\n markdownTransformers: Transformer[]\n nodeHooks?: {\n afterChange?: Map<string, Array<AfterChangeNodeHook<SerializedLexicalNode>>>\n afterRead?: Map<string, Array<AfterReadNodeHook<SerializedLexicalNode>>>\n beforeChange?: Map<string, Array<BeforeChangeNodeHook<SerializedLexicalNode>>>\n beforeValidate?: Map<string, Array<BeforeValidateNodeHook<SerializedLexicalNode>>>\n } /** The node types mapped to their populationPromises */\n /** The node types mapped to their validations */\n validations: Map<string, Array<NodeValidation>>\n} & Required<Pick<ResolvedServerFeature<any, any>, 'i18n' | 'nodes'>>\n"],"mappings":"AAgXA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"typesServer.js","names":[],"sources":["../../src/features/typesServer.ts"],"sourcesContent":["import type { GenericLanguages, I18n, I18nClient } from '@payloadcms/translations'\nimport type { JSONSchema4 } from 'json-schema'\nimport type {\n Klass,\n LexicalNode,\n LexicalNodeReplacement,\n SerializedEditorState,\n SerializedLexicalNode,\n} from 'lexical'\nimport type {\n Field,\n FieldSchemaMap,\n ImportMapGenerators,\n JsonObject,\n PayloadComponent,\n PayloadRequest,\n PopulateType,\n ReplaceAny,\n RequestContext,\n RichTextField,\n RichTextHooks,\n SanitizedConfig,\n ValidateOptions,\n ValidationFieldError,\n} from 'payload'\n\nimport type { ServerEditorConfig } from '../lexical/config/types.js'\nimport type { Transformer } from '../packages/@lexical/markdown/index.js'\nimport type { LexicalRichTextField } from '../types.js'\nimport type { HTMLConverter } from './converters/lexicalToHtml_deprecated/converter/types.js'\nimport type { BaseClientFeatureProps } from './typesClient.js'\n\nexport type PopulationPromise<T extends SerializedLexicalNode = SerializedLexicalNode> = (args: {\n context: RequestContext\n currentDepth: number\n depth: number\n draft: boolean\n /**\n * This maps all population promises to the node type\n */\n editorPopulationPromises: Map<string, Array<PopulationPromise>>\n field: LexicalRichTextField\n /**\n * fieldPromises are used for things like field hooks. They will be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n node: T\n overrideAccess: boolean\n parentIsLocalized: boolean\n populationPromises: Promise<void>[]\n req: PayloadRequest\n showHiddenFields: boolean\n siblingDoc: JsonObject\n}) => void\n\nexport type NodeValidation<T extends SerializedLexicalNode = SerializedLexicalNode> = ({\n node,\n nodeValidations,\n validation,\n}: {\n node: T\n nodeValidations: Map<string, Array<NodeValidation>>\n validation: {\n options: ValidateOptions<unknown, unknown, RichTextField, SerializedEditorState>\n value: SerializedEditorState\n }\n}) => Promise<string | true> | string | true\n\nexport type FeatureProviderProviderServer<\n UnSanitizedServerFeatureProps = undefined,\n ServerFeatureProps = UnSanitizedServerFeatureProps,\n ClientFeatureProps = undefined,\n> = (\n props?: UnSanitizedServerFeatureProps,\n) => FeatureProviderServer<UnSanitizedServerFeatureProps, ServerFeatureProps, ClientFeatureProps>\n\nexport type FeatureProviderServer<\n UnSanitizedServerFeatureProps = undefined,\n ServerFeatureProps = UnSanitizedServerFeatureProps,\n ClientFeatureProps = undefined,\n> = {\n /** Keys of dependencies needed for this feature. These dependencies do not have to be loaded first, but they have to exist, otherwise an error will be thrown. */\n dependencies?: string[]\n /** Keys of priority dependencies needed for this feature. These dependencies have to be loaded first AND have to exist, otherwise an error will be thrown. They will be available in the `feature` property. */\n dependenciesPriority?: string[]\n /** Keys of soft-dependencies needed for this feature. These are optional. Payload will attempt to load them before this feature, but doesn't throw an error if that's not possible. */\n dependenciesSoft?: string[]\n\n /**\n * This is being called during the payload sanitization process\n */\n feature:\n | ((props: {\n config: SanitizedConfig\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ServerFeatureProviderMap\n isRoot?: boolean\n parentIsLocalized: boolean\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedServerFeatureMap\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ServerEditorConfig\n }) =>\n | Promise<ServerFeature<ServerFeatureProps, ClientFeatureProps>>\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>)\n | ServerFeature<ServerFeatureProps, ClientFeatureProps>\n key: string\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n serverFeatureProps: UnSanitizedServerFeatureProps\n}\n\nexport type AfterReadNodeHookArgs<T extends SerializedLexicalNode> = {\n /**\n * Only available in `afterRead` hooks.\n */\n currentDepth: number\n /**\n * Only available in `afterRead` hooks.\n */\n depth: number\n draft: boolean\n fallbackLocale: string | string[]\n /**\n * Only available in `afterRead` field hooks.\n */\n fieldPromises: Promise<void>[]\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany: boolean\n flattenLocales: boolean\n /**\n * The requested locale.\n */\n locale: string\n overrideAccess: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n populateArg?: PopulateType\n /**\n * Only available in `afterRead` field hooks.\n */\n populationPromises: Promise<void>[]\n /**\n * Only available in `afterRead` hooks.\n */\n showHiddenFields: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n triggerAccessControl: boolean\n /**\n * Only available in `afterRead` hooks.\n */\n triggerHooks: boolean\n}\n\nexport type AfterChangeNodeHookArgs<T extends SerializedLexicalNode> = {\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n previousNode: T\n}\nexport type BeforeValidateNodeHookArgs<T extends SerializedLexicalNode> = {\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n overrideAccess: boolean\n}\n\nexport type BeforeChangeNodeHookArgs<T extends SerializedLexicalNode> = {\n /**\n * Only available in `beforeChange` hooks.\n */\n errors: ValidationFieldError[]\n mergeLocaleActions: (() => Promise<void> | void)[]\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation: 'create' | 'delete' | 'read' | 'update'\n /** The value of the node before any changes. Not available in afterRead hooks */\n originalNode: T\n /**\n * The original node with locales (not modified by any hooks).\n */\n originalNodeWithLocales?: T\n previousNode: T\n\n skipValidation: boolean\n}\n\nexport type BaseNodeHookArgs<T extends SerializedLexicalNode> = {\n context: RequestContext\n /** The value of the node. */\n node: T\n parentRichTextFieldPath: (number | string)[]\n parentRichTextFieldSchemaPath: string[]\n /** The payload request object. It is mocked for Local API operations. */\n req: PayloadRequest\n}\n\nexport type AfterReadNodeHook<T extends SerializedLexicalNode> = (\n args: AfterReadNodeHookArgs<T> & BaseNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type AfterChangeNodeHook<T extends SerializedLexicalNode> = (\n args: AfterChangeNodeHookArgs<T> & BaseNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type BeforeChangeNodeHook<T extends SerializedLexicalNode> = (\n args: BaseNodeHookArgs<T> & BeforeChangeNodeHookArgs<T>,\n) => Promise<T> | T\n\nexport type BeforeValidateNodeHook<T extends SerializedLexicalNode> = (\n args: BaseNodeHookArgs<T> & BeforeValidateNodeHookArgs<T>,\n) => Promise<T> | T\n\n// Define the node with hooks that use the node's exportJSON return type\nexport type NodeWithHooks<T extends LexicalNode = any> = {\n /**\n * Allows you to define how a node can be serialized into different formats. Currently, only supports html.\n * Markdown converters are defined in `markdownTransformers` and not here.\n *\n * @deprecated - will be removed in 4.0\n */\n converters?: {\n /**\n * @deprecated - will be removed in 4.0\n */\n html?: HTMLConverter<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n }\n /**\n * If a node includes sub-fields (e.g. block and link nodes), passing those subFields here will make payload\n * automatically populate, run hooks, and generate component import maps for them\n */\n getSubFields?: (args: {\n /**\n * Optional. If not provided, all possible sub-fields should be returned.\n */\n node?: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>\n req?: PayloadRequest\n }) => Field[] | null\n /**\n * If a node includes sub-fields, the sub-fields data needs to be returned here, alongside `getSubFields` which returns their schema.\n */\n getSubFieldsData?: (args: {\n node: ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>\n req: PayloadRequest\n }) => JsonObject\n /**\n * Allows you to run population logic when a node's data was requested from graphQL.\n * While `getSubFields` and `getSubFieldsData` automatically handle populating sub-fields (since they run hooks on them), those are only populated in the Rest API.\n * This is because the Rest API hooks do not have access to the 'depth' property provided by graphQL.\n * In order for them to be populated correctly in graphQL, the population logic needs to be provided here.\n */\n graphQLPopulationPromises?: Array<\n PopulationPromise<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n /**\n * Just like payload fields, you can provide hooks which are run for this specific node. These are called Node Hooks.\n */\n hooks?: {\n afterChange?: Array<AfterChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n afterRead?: Array<AfterReadNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeChange?: Array<BeforeChangeNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n beforeValidate?: Array<\n BeforeValidateNodeHook<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>\n >\n }\n /**\n * The actual lexical node needs to be provided here. This also supports [lexical node replacements](https://lexical.dev/docs/concepts/node-replacement).\n */\n node: Klass<T> | LexicalNodeReplacement\n /**\n * This allows you to provide node validations, which are run when your document is being validated, alongside other payload fields.\n * You can use it to throw a validation error for a specific node in case its data is incorrect.\n */\n validations?: Array<NodeValidation<ReturnType<ReplaceAny<T, LexicalNode>['exportJSON']>>>\n}\n\nexport type ServerFeature<ServerProps, ClientFeatureProps> = {\n ClientFeature?: PayloadComponent<never, BaseClientFeatureProps<ClientFeatureProps>>\n /**\n * This determines what props will be available on the Client.\n */\n clientFeatureProps?: ClientFeatureProps\n /**\n * Adds payload components to the importMap.\n *\n * If an object is provided, the imported components will automatically be made available to the client feature, keyed by the object's keys.\n */\n componentImports?:\n | {\n [key: string]: PayloadComponent\n }\n | ImportMapGenerators[0]\n | PayloadComponent[]\n generatedTypes?: {\n modifyOutputSchema: (args: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n /**\n * Current schema which will be modified by this function.\n */\n currentSchema: JSONSchema4\n field: LexicalRichTextField\n i18n?: I18n\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n }\n generateSchemaMap?: (args: {\n config: SanitizedConfig\n field: RichTextField\n i18n: I18nClient\n props: ServerProps\n schemaMap: FieldSchemaMap\n schemaPath: string\n }) => FieldSchemaMap | null\n hooks?: RichTextHooks\n /**\n * Here you can provide i18n translations for your feature. These will only be available on the server and client.\n *\n * Translations here are automatically scoped to `lexical.featureKey.yourKey`\n *\n * @Example\n * ```ts\n * i18n: {\n * en: {\n * label: 'Horizontal Rule',\n * },\n * de: {\n * label: 'Trennlinie',\n * },\n * }\n * ```\n * In order to access these translations, you would use `i18n.t('lexical:horizontalRule:label')`.\n */\n i18n?: Partial<GenericLanguages>\n markdownTransformers?: (\n | ((props: { allNodes: Array<NodeWithHooks>; allTransformers: Transformer[] }) => Transformer)\n | Transformer\n )[]\n nodes?: Array<NodeWithHooks>\n\n /** Props which were passed into your feature will have to be passed here. This will allow them to be used / read in other places of the code, e.g. wherever you can use useEditorConfigContext */\n sanitizedServerFeatureProps?: ServerProps\n}\n\nexport type ResolvedServerFeature<ServerProps, ClientFeatureProps> = {\n order: number\n} & Required<\n Pick<\n FeatureProviderServer<ServerProps, ClientFeatureProps>,\n 'dependencies' | 'dependenciesPriority' | 'dependenciesSoft' | 'key'\n >\n> &\n ServerFeature<ServerProps, ClientFeatureProps>\n\nexport type ResolvedServerFeatureMap = Map<string, ResolvedServerFeature<any, any>>\n\nexport type ServerFeatureProviderMap = Map<string, FeatureProviderServer<any, any, any>>\n\nexport type SanitizedServerFeatures = {\n /** The node types mapped to their converters */\n converters: {\n html: HTMLConverter[]\n }\n /** The keys of all enabled features */\n enabledFeatures: string[]\n generatedTypes: {\n modifyOutputSchemas: Array<\n (args: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config?: SanitizedConfig\n /**\n * Current schema which will be modified by this function.\n */\n currentSchema: JSONSchema4\n field: LexicalRichTextField\n i18n?: I18n\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>\n isRequired: boolean\n }) => JSONSchema4\n >\n }\n /** The node types mapped to their hooks */\n\n getSubFields?: Map<\n string,\n (args: { node: SerializedLexicalNode; req: PayloadRequest }) => Field[] | null\n >\n getSubFieldsData?: Map<\n string,\n (args: { node: SerializedLexicalNode; req: PayloadRequest }) => JsonObject\n >\n graphQLPopulationPromises: Map<string, Array<PopulationPromise>>\n hooks: RichTextHooks\n markdownTransformers: Transformer[]\n nodeHooks?: {\n afterChange?: Map<string, Array<AfterChangeNodeHook<SerializedLexicalNode>>>\n afterRead?: Map<string, Array<AfterReadNodeHook<SerializedLexicalNode>>>\n beforeChange?: Map<string, Array<BeforeChangeNodeHook<SerializedLexicalNode>>>\n beforeValidate?: Map<string, Array<BeforeValidateNodeHook<SerializedLexicalNode>>>\n } /** The node types mapped to their populationPromises */\n /** The node types mapped to their validations */\n validations: Map<string, Array<NodeValidation>>\n} & Required<Pick<ResolvedServerFeature<any, any>, 'i18n' | 'nodes'>>\n"],"mappings":"AA+WA","ignoreList":[]}
|