@payloadcms/richtext-lexical 3.0.0-beta.133 → 3.0.0-beta.134

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.
Files changed (119) hide show
  1. package/dist/exports/client/Field-S5G27AVI.js +2 -0
  2. package/dist/exports/client/Field-S5G27AVI.js.map +7 -0
  3. package/dist/exports/client/bundled.css +1 -1
  4. package/dist/exports/client/chunk-2CYU43GM.js +2 -0
  5. package/dist/exports/client/chunk-2CYU43GM.js.map +7 -0
  6. package/dist/exports/client/chunk-C7S3V4EB.js +2 -0
  7. package/dist/exports/client/chunk-C7S3V4EB.js.map +7 -0
  8. package/dist/exports/client/chunk-U7O7EYCP.js +2 -0
  9. package/dist/exports/client/chunk-U7O7EYCP.js.map +7 -0
  10. package/dist/exports/client/component-H3EYQ5KG.js +2 -0
  11. package/dist/exports/client/{component-YICNYPTU.js.map → component-H3EYQ5KG.js.map} +1 -1
  12. package/dist/exports/client/componentInline-ZGO3K4TA.js +2 -0
  13. package/dist/exports/client/componentInline-ZGO3K4TA.js.map +7 -0
  14. package/dist/exports/client/index.d.ts +7 -0
  15. package/dist/exports/client/index.d.ts.map +1 -1
  16. package/dist/exports/client/index.js +7 -7
  17. package/dist/exports/client/index.js.map +4 -4
  18. package/dist/features/blocks/client/component/BlockContent.d.ts +34 -9
  19. package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
  20. package/dist/features/blocks/client/component/BlockContent.js +63 -158
  21. package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
  22. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts +11 -0
  23. package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts.map +1 -0
  24. package/dist/features/blocks/client/component/components/BlockCollapsible.js +37 -0
  25. package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -0
  26. package/dist/features/blocks/client/component/components/BlockEditButton.d.ts +3 -0
  27. package/dist/features/blocks/client/component/components/BlockEditButton.d.ts.map +1 -0
  28. package/dist/features/blocks/client/component/components/BlockEditButton.js +22 -0
  29. package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -0
  30. package/dist/features/blocks/client/component/components/BlockRemoveButton.d.ts +3 -0
  31. package/dist/features/blocks/client/component/components/BlockRemoveButton.d.ts.map +1 -0
  32. package/dist/features/blocks/client/component/components/BlockRemoveButton.js +22 -0
  33. package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -0
  34. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  35. package/dist/features/blocks/client/component/index.js +242 -63
  36. package/dist/features/blocks/client/component/index.js.map +1 -1
  37. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts +5 -0
  38. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.d.ts.map +1 -0
  39. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js +28 -0
  40. package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -0
  41. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.d.ts +3 -0
  42. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.d.ts.map +1 -0
  43. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js +22 -0
  44. package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -0
  45. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.d.ts +3 -0
  46. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.d.ts.map +1 -0
  47. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js +22 -0
  48. package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -0
  49. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.d.ts +3 -0
  50. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.d.ts.map +1 -0
  51. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js +22 -0
  52. package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -0
  53. package/dist/features/blocks/client/componentInline/index.d.ts +13 -1
  54. package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
  55. package/dist/features/blocks/client/componentInline/index.js +219 -43
  56. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  57. package/dist/features/blocks/client/index.d.ts.map +1 -1
  58. package/dist/features/blocks/client/index.js +7 -10
  59. package/dist/features/blocks/client/index.js.map +1 -1
  60. package/dist/features/blocks/client/nodes/BlocksNode.d.ts.map +1 -1
  61. package/dist/features/blocks/client/nodes/BlocksNode.js +1 -3
  62. package/dist/features/blocks/client/nodes/BlocksNode.js.map +1 -1
  63. package/dist/features/blocks/client/plugin/commands.d.ts +0 -4
  64. package/dist/features/blocks/client/plugin/commands.d.ts.map +1 -1
  65. package/dist/features/blocks/client/plugin/commands.js +0 -1
  66. package/dist/features/blocks/client/plugin/commands.js.map +1 -1
  67. package/dist/features/blocks/client/plugin/index.d.ts.map +1 -1
  68. package/dist/features/blocks/client/plugin/index.js +28 -135
  69. package/dist/features/blocks/client/plugin/index.js.map +1 -1
  70. package/dist/features/blocks/server/index.d.ts.map +1 -1
  71. package/dist/features/blocks/server/index.js +28 -2
  72. package/dist/features/blocks/server/index.js.map +1 -1
  73. package/dist/features/typesClient.d.ts +1 -17
  74. package/dist/features/typesClient.d.ts.map +1 -1
  75. package/dist/features/typesClient.js.map +1 -1
  76. package/dist/field/Field.d.ts.map +1 -1
  77. package/dist/field/Field.js +163 -78
  78. package/dist/field/Field.js.map +1 -1
  79. package/dist/field/bundled.css +1 -1
  80. package/dist/field/rscEntry.d.ts.map +1 -1
  81. package/dist/field/rscEntry.js +23 -1
  82. package/dist/field/rscEntry.js.map +1 -1
  83. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  84. package/dist/lexical/LexicalProvider.js +9 -18
  85. package/dist/lexical/LexicalProvider.js.map +1 -1
  86. package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
  87. package/dist/lexical/config/client/sanitize.js +0 -12
  88. package/dist/lexical/config/client/sanitize.js.map +1 -1
  89. package/dist/types.d.ts +2 -0
  90. package/dist/types.d.ts.map +1 -1
  91. package/dist/types.js.map +1 -1
  92. package/dist/utilities/buildInitialState.d.ts +27 -0
  93. package/dist/utilities/buildInitialState.d.ts.map +1 -0
  94. package/dist/utilities/buildInitialState.js +53 -0
  95. package/dist/utilities/buildInitialState.js.map +1 -0
  96. package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
  97. package/dist/utilities/fieldsDrawer/DrawerContent.js +8 -5
  98. package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
  99. package/dist/utilities/fieldsDrawer/useLexicalDrawer.d.ts.map +1 -1
  100. package/dist/utilities/fieldsDrawer/useLexicalDrawer.js +8 -8
  101. package/dist/utilities/fieldsDrawer/useLexicalDrawer.js.map +1 -1
  102. package/package.json +6 -6
  103. package/dist/exports/client/Field-GWJ72IYP.js +0 -2
  104. package/dist/exports/client/Field-GWJ72IYP.js.map +0 -7
  105. package/dist/exports/client/chunk-D7PD5DUW.js +0 -2
  106. package/dist/exports/client/chunk-D7PD5DUW.js.map +0 -7
  107. package/dist/exports/client/chunk-XDEGE6I5.js +0 -2
  108. package/dist/exports/client/chunk-XDEGE6I5.js.map +0 -7
  109. package/dist/exports/client/chunk-YGRKYSDC.js +0 -2
  110. package/dist/exports/client/chunk-YGRKYSDC.js.map +0 -7
  111. package/dist/exports/client/component-KLNTKKNE.js +0 -2
  112. package/dist/exports/client/component-KLNTKKNE.js.map +0 -7
  113. package/dist/exports/client/component-YICNYPTU.js +0 -2
  114. package/dist/exports/client/componentInline-6RPSMLNJ.js +0 -2
  115. package/dist/exports/client/componentInline-6RPSMLNJ.js.map +0 -7
  116. package/dist/features/blocks/client/component/FormSavePlugin.d.ts +0 -11
  117. package/dist/features/blocks/client/component/FormSavePlugin.d.ts.map +0 -1
  118. package/dist/features/blocks/client/component/FormSavePlugin.js +0 -53
  119. package/dist/features/blocks/client/component/FormSavePlugin.js.map +0 -1
@@ -1,61 +1,44 @@
1
1
  'use client';
2
2
 
3
3
  import { c as _c } from "react/compiler-runtime";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
4
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
6
5
  import { $insertNodeToNearestRoot, $wrapNodeInElement, mergeRegister } from '@lexical/utils';
7
- import { getTranslation } from '@payloadcms/translations';
8
- import { formatDrawerSlug, useEditDepth, useTranslation } from '@payloadcms/ui';
6
+ import { formatDrawerSlug, useEditDepth } from '@payloadcms/ui';
9
7
  import { $createParagraphNode, $getNodeByKey, $getPreviousSelection, $getSelection, $insertNodes, $isParagraphNode, $isRangeSelection, $isRootOrShadowRoot, COMMAND_PRIORITY_EDITOR } from 'lexical';
10
- import React, { useEffect, useState } from 'react';
8
+ import { useEffect, useState } from 'react';
11
9
  import { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js';
12
- import { FieldsDrawer } from '../../../../utilities/fieldsDrawer/Drawer.js';
13
10
  import { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js';
14
11
  import { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js';
15
12
  import { $createInlineBlockNode, $isInlineBlockNode } from '../nodes/InlineBlocksNode.js';
16
- import { INSERT_BLOCK_COMMAND, INSERT_INLINE_BLOCK_COMMAND, OPEN_INLINE_BLOCK_DRAWER_COMMAND } from './commands.js';
13
+ import { INSERT_BLOCK_COMMAND, INSERT_INLINE_BLOCK_COMMAND } from './commands.js';
17
14
  export const BlocksPlugin = () => {
18
- const $ = _c(27);
15
+ const $ = _c(10);
19
16
  const [editor] = useLexicalComposerContext();
20
- const [blockFields, setBlockFields] = useState(null);
21
- const [blockType, setBlockType] = useState("");
22
17
  const [targetNodeKey, setTargetNodeKey] = useState(null);
23
- const {
24
- i18n,
25
- t
26
- } = useTranslation();
27
- const {
28
- fieldProps: t0
29
- } = useEditorConfigContext();
30
- const {
31
- featureClientSchemaMap,
32
- schemaPath
33
- } = t0;
34
18
  const {
35
19
  uuid
36
20
  } = useEditorConfigContext();
37
21
  const editDepth = useEditDepth();
38
- const t1 = `lexical-inlineBlocks-create-` + uuid;
39
- let t2;
40
- if ($[0] !== t1 || $[1] !== editDepth) {
41
- t2 = formatDrawerSlug({
42
- slug: t1,
22
+ const t0 = `lexical-inlineBlocks-create-` + uuid;
23
+ let t1;
24
+ if ($[0] !== t0 || $[1] !== editDepth) {
25
+ t1 = formatDrawerSlug({
26
+ slug: t0,
43
27
  depth: editDepth
44
28
  });
45
- $[0] = t1;
29
+ $[0] = t0;
46
30
  $[1] = editDepth;
47
- $[2] = t2;
31
+ $[2] = t1;
48
32
  } else {
49
- t2 = $[2];
33
+ t1 = $[2];
50
34
  }
51
- const drawerSlug = t2;
35
+ const drawerSlug = t1;
52
36
  const {
53
37
  toggleDrawer
54
38
  } = useLexicalDrawer(drawerSlug, true);
55
- let t3;
56
- let t4;
57
- if ($[3] !== editor || $[4] !== targetNodeKey || $[5] !== toggleDrawer) {
58
- t3 = () => {
39
+ let t2;
40
+ if ($[3] !== editor || $[4] !== targetNodeKey) {
41
+ t2 = () => {
59
42
  if (!editor.hasNodes([BlockNode])) {
60
43
  throw new Error("BlocksPlugin: BlocksNode not registered on editor");
61
44
  }
@@ -91,115 +74,25 @@ export const BlocksPlugin = () => {
91
74
  $wrapNodeInElement(inlineBlockNode, $createParagraphNode).selectEnd();
92
75
  }
93
76
  return true;
94
- }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(OPEN_INLINE_BLOCK_DRAWER_COMMAND, t5 => {
95
- const {
96
- fields: fields_0,
97
- nodeKey
98
- } = t5;
99
- setBlockFields(fields_0 ?? null);
100
- setTargetNodeKey(nodeKey ?? null);
101
- setBlockType(fields_0?.blockType ?? "");
102
- if (nodeKey) {
103
- toggleDrawer();
104
- return true;
105
- }
106
- let rangeSelection;
107
- rangeSelection = null;
108
- editor.getEditorState().read(() => {
109
- const selection_0 = $getSelection();
110
- if ($isRangeSelection(selection_0)) {
111
- rangeSelection = selection_0;
112
- }
113
- });
114
- if (rangeSelection) {
115
- toggleDrawer();
116
- }
117
- return true;
118
77
  }, COMMAND_PRIORITY_EDITOR));
119
78
  };
120
- t4 = [editor, targetNodeKey, toggleDrawer];
121
79
  $[3] = editor;
122
80
  $[4] = targetNodeKey;
123
- $[5] = toggleDrawer;
124
- $[6] = t3;
125
- $[7] = t4;
126
- } else {
127
- t3 = $[6];
128
- t4 = $[7];
129
- }
130
- useEffect(t3, t4);
131
- if (!blockFields) {
132
- return null;
133
- }
134
- const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockFields?.blockType}`;
135
- const clientSchemaMap = featureClientSchemaMap.blocks;
136
- const blocksField = clientSchemaMap[schemaFieldsPath][0];
137
- const clientBlock = blocksField.blocks[0];
138
- if (!blocksField) {
139
- return null;
140
- }
141
- let t5;
142
- if ($[8] !== clientBlock || $[9] !== i18n) {
143
- t5 = clientBlock?.labels?.singular ? getTranslation(clientBlock?.labels?.singular, i18n) : clientBlock?.slug;
144
- $[8] = clientBlock;
145
- $[9] = i18n;
146
- $[10] = t5;
81
+ $[5] = t2;
147
82
  } else {
148
- t5 = $[10];
83
+ t2 = $[5];
149
84
  }
150
- const blockDisplayName = t5;
151
- const t6 = `lexical:blocks:inlineBlocks:${blockFields?.id ? "edit" : "create"}`;
152
- let t7;
153
- if ($[11] !== blockDisplayName || $[12] !== t) {
154
- t7 = blockDisplayName ?? t("lexical:blocks:inlineBlocks:label");
155
- $[11] = blockDisplayName;
156
- $[12] = t;
157
- $[13] = t7;
158
- } else {
159
- t7 = $[13];
160
- }
161
- let t8;
162
- if ($[14] !== t7 || $[15] !== t || $[16] !== t6 || $[17] !== clientBlock?.fields || $[18] !== blockType || $[19] !== editor || $[20] !== blockFields || $[21] !== drawerSlug || $[22] !== schemaPath) {
163
- let t9;
164
- if ($[24] !== blockType || $[25] !== editor) {
165
- t9 = (_fields, data) => {
166
- if (!data) {
167
- return;
168
- }
169
- data.blockType = blockType;
170
- editor.dispatchCommand(INSERT_INLINE_BLOCK_COMMAND, data);
171
- };
172
- $[24] = blockType;
173
- $[25] = editor;
174
- $[26] = t9;
175
- } else {
176
- t9 = $[26];
177
- }
178
- t8 = _jsx(FieldsDrawer, {
179
- data: blockFields,
180
- drawerSlug,
181
- drawerTitle: t(t6, {
182
- label: t7
183
- }),
184
- featureKey: "blocks",
185
- fieldMapOverride: clientBlock?.fields,
186
- handleDrawerSubmit: t9,
187
- schemaPath,
188
- schemaPathSuffix: `lexical_inline_blocks.${blockFields?.blockType}.fields`
189
- });
190
- $[14] = t7;
191
- $[15] = t;
192
- $[16] = t6;
193
- $[17] = clientBlock?.fields;
194
- $[18] = blockType;
195
- $[19] = editor;
196
- $[20] = blockFields;
197
- $[21] = drawerSlug;
198
- $[22] = schemaPath;
199
- $[23] = t8;
85
+ let t3;
86
+ if ($[6] !== editor || $[7] !== targetNodeKey || $[8] !== toggleDrawer) {
87
+ t3 = [editor, targetNodeKey, toggleDrawer];
88
+ $[6] = editor;
89
+ $[7] = targetNodeKey;
90
+ $[8] = toggleDrawer;
91
+ $[9] = t3;
200
92
  } else {
201
- t8 = $[23];
93
+ t3 = $[9];
202
94
  }
203
- return t8;
95
+ useEffect(t2, t3);
96
+ return null;
204
97
  };
205
98
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","$wrapNodeInElement","mergeRegister","getTranslation","formatDrawerSlug","useEditDepth","useTranslation","$createParagraphNode","$getNodeByKey","$getPreviousSelection","$getSelection","$insertNodes","$isParagraphNode","$isRangeSelection","$isRootOrShadowRoot","COMMAND_PRIORITY_EDITOR","React","useEffect","useState","useEditorConfigContext","FieldsDrawer","useLexicalDrawer","$createBlockNode","BlockNode","$createInlineBlockNode","$isInlineBlockNode","INSERT_BLOCK_COMMAND","INSERT_INLINE_BLOCK_COMMAND","OPEN_INLINE_BLOCK_DRAWER_COMMAND","BlocksPlugin","$","editor","blockFields","setBlockFields","blockType","setBlockType","targetNodeKey","setTargetNodeKey","i18n","t","fieldProps","t0","featureClientSchemaMap","schemaPath","uuid","editDepth","t1","t2","slug","depth","drawerSlug","toggleDrawer","t3","t4","hasNodes","Error","registerCommand","payload","update","selection","blockNode","focus","focusNode","getNode","getTextContentSize","getParentOrThrow","getChildren","filter","node","length","remove","fields","node_0","setFields","inlineBlockNode","selectEnd","t5","fields_0","nodeKey","rangeSelection","getEditorState","read","selection_0","schemaFieldsPath","clientSchemaMap","blocks","blocksField","clientBlock","labels","singular","blockDisplayName","t6","id","t7","t8","t9","_fields","data","dispatchCommand","_jsx","drawerTitle","label","featureKey","fieldMapOverride","handleDrawerSubmit","schemaPathSuffix"],"sources":["../../../../../src/features/blocks/client/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { BlocksFieldClient } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot, $wrapNodeInElement, mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport { formatDrawerSlug, useEditDepth, useTranslation } from '@payloadcms/ui'\nimport {\n $createParagraphNode,\n $getNodeByKey,\n $getPreviousSelection,\n $getSelection,\n $insertNodes,\n $isParagraphNode,\n $isRangeSelection,\n $isRootOrShadowRoot,\n COMMAND_PRIORITY_EDITOR,\n type RangeSelection,\n} from 'lexical'\nimport React, { useEffect, useState } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { BlockFields, BlockFieldsOptionalID } from '../../server/nodes/BlocksNode.js'\nimport type { BlocksFeatureClientProps } from '../index.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { FieldsDrawer } from '../../../../utilities/fieldsDrawer/Drawer.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js'\nimport { $createInlineBlockNode, $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\nimport {\n INSERT_BLOCK_COMMAND,\n INSERT_INLINE_BLOCK_COMMAND,\n OPEN_INLINE_BLOCK_DRAWER_COMMAND,\n} from './commands.js'\n\nexport type InsertBlockPayload = BlockFieldsOptionalID\n\nexport const BlocksPlugin: PluginComponent<BlocksFeatureClientProps> = () => {\n const [editor] = useLexicalComposerContext()\n const [blockFields, setBlockFields] = useState<BlockFields | null>(null)\n const [blockType, setBlockType] = useState<string>('' as any)\n const [targetNodeKey, setTargetNodeKey] = useState<null | string>(null)\n const { i18n, t } = useTranslation<string, any>()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n const { uuid } = useEditorConfigContext()\n const editDepth = useEditDepth()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-` + uuid,\n depth: editDepth,\n })\n\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n useEffect(() => {\n if (!editor.hasNodes([BlockNode])) {\n throw new Error('BlocksPlugin: BlocksNode not registered on editor')\n }\n\n return mergeRegister(\n editor.registerCommand<InsertBlockPayload>(\n INSERT_BLOCK_COMMAND,\n (payload: InsertBlockPayload) => {\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const blockNode = $createBlockNode(payload)\n // Insert blocks node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(blockNode)\n\n const { focus } = selection\n const focusNode = focus.getNode()\n\n // First, delete currently selected node if it's an empty paragraph and if there are sufficient\n // paragraph nodes (more than 1) left in the parent node, so that we don't \"trap\" the user\n if (\n $isParagraphNode(focusNode) &&\n focusNode.getTextContentSize() === 0 &&\n focusNode\n .getParentOrThrow()\n .getChildren()\n .filter((node) => $isParagraphNode(node)).length > 1\n ) {\n focusNode.remove()\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n INSERT_INLINE_BLOCK_COMMAND,\n (fields) => {\n if (targetNodeKey) {\n const node = $getNodeByKey(targetNodeKey)\n\n if (!node || !$isInlineBlockNode(node)) {\n return false\n }\n\n node.setFields(fields as BlockFields)\n\n setTargetNodeKey(null)\n return true\n }\n\n const inlineBlockNode = $createInlineBlockNode(fields as BlockFields)\n $insertNodes([inlineBlockNode])\n if ($isRootOrShadowRoot(inlineBlockNode.getParentOrThrow())) {\n $wrapNodeInElement(inlineBlockNode, $createParagraphNode).selectEnd()\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n OPEN_INLINE_BLOCK_DRAWER_COMMAND,\n ({ fields, nodeKey }) => {\n setBlockFields((fields as BlockFields) ?? null)\n setTargetNodeKey(nodeKey ?? null)\n setBlockType(fields?.blockType ?? ('' as any))\n\n if (nodeKey) {\n toggleDrawer()\n return true\n }\n\n let rangeSelection: null | RangeSelection = null\n\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n rangeSelection = selection\n }\n })\n\n if (rangeSelection) {\n //setLastSelection(rangeSelection)\n toggleDrawer()\n }\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor, targetNodeKey, toggleDrawer])\n\n if (!blockFields) {\n return null\n }\n\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${blockFields?.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap[schemaFieldsPath][0] as BlocksFieldClient\n\n const clientBlock = blocksField.blocks[0]\n\n if (!blocksField) {\n return null\n }\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock?.labels?.singular, i18n)\n : clientBlock?.slug\n\n return (\n <FieldsDrawer\n data={blockFields}\n drawerSlug={drawerSlug}\n drawerTitle={t(`lexical:blocks:inlineBlocks:${blockFields?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n featureKey=\"blocks\"\n fieldMapOverride={clientBlock?.fields}\n handleDrawerSubmit={(_fields, data) => {\n if (!data) {\n return\n }\n\n data.blockType = blockType\n\n editor.dispatchCommand(INSERT_INLINE_BLOCK_COMMAND, data)\n }}\n schemaPath={schemaPath}\n schemaPathSuffix={`lexical_inline_blocks.${blockFields?.blockType}.fields`}\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAIA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,wBAAwB,EAAEC,kBAAkB,EAAEC,aAAa,QAAQ;AAC5E,SAASC,cAAc,QAAQ;AAC/B,SAASC,gBAAgB,EAAEC,YAAY,EAAEC,cAAc,QAAQ;AAC/D,SACEC,oBAAoB,EACpBC,aAAa,EACbC,qBAAqB,EACrBC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,iBAAiB,EACjBC,mBAAmB,EACnBC,uBAAuB,QAElB;AACP,OAAOC,KAAA,IAASC,SAAS,EAAEC,QAAQ,QAAQ;AAM3C,SAASC,sBAAsB,QAAQ;AACvC,SAASC,YAAY,QAAQ;AAC7B,SAASC,gBAAgB,QAAQ;AACjC,SAASC,gBAAgB,EAAEC,SAAS,QAAQ;AAC5C,SAASC,sBAAsB,EAAEC,kBAAkB,QAAQ;AAC3D,SACEC,oBAAoB,EACpBC,2BAA2B,EAC3BC,gCAAgC,QAC3B;AAIP,OAAO,MAAMC,YAAA,GAA0DA,CAAA;EAAA,MAAAC,CAAA,GAAAhC,EAAA;EACrE,OAAAiC,MAAA,IAAiBhC,yBAAA;EACjB,OAAAiC,WAAA,EAAAC,cAAA,IAAsCf,QAAA,KAA6B;EACnE,OAAAgB,SAAA,EAAAC,YAAA,IAAkCjB,QAAA,CAAiB;EACnD,OAAAkB,aAAA,EAAAC,gBAAA,IAA0CnB,QAAA,KAAwB;EAClE;IAAAoB,IAAA;I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kB,yBAAyBzE,WAAA,EAAAE,SAAA;IAA+B,C;;;;;;;;;;;;;;SAlB5E4D,E;CAqBJ","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$insertNodeToNearestRoot","$wrapNodeInElement","mergeRegister","formatDrawerSlug","useEditDepth","$createParagraphNode","$getNodeByKey","$getPreviousSelection","$getSelection","$insertNodes","$isParagraphNode","$isRangeSelection","$isRootOrShadowRoot","COMMAND_PRIORITY_EDITOR","useEffect","useState","useEditorConfigContext","useLexicalDrawer","$createBlockNode","BlockNode","$createInlineBlockNode","$isInlineBlockNode","INSERT_BLOCK_COMMAND","INSERT_INLINE_BLOCK_COMMAND","BlocksPlugin","$","editor","targetNodeKey","setTargetNodeKey","uuid","editDepth","t0","t1","slug","depth","drawerSlug","toggleDrawer","t2","hasNodes","Error","registerCommand","payload","update","selection","blockNode","focus","focusNode","getNode","getTextContentSize","getParentOrThrow","getChildren","filter","node","length","remove","fields","node_0","setFields","inlineBlockNode","selectEnd","t3"],"sources":["../../../../../src/features/blocks/client/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $insertNodeToNearestRoot, $wrapNodeInElement, mergeRegister } from '@lexical/utils'\nimport { formatDrawerSlug, useEditDepth } from '@payloadcms/ui'\nimport {\n $createParagraphNode,\n $getNodeByKey,\n $getPreviousSelection,\n $getSelection,\n $insertNodes,\n $isParagraphNode,\n $isRangeSelection,\n $isRootOrShadowRoot,\n COMMAND_PRIORITY_EDITOR,\n} from 'lexical'\nimport { useEffect, useState } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\nimport type { BlockFields, BlockFieldsOptionalID } from '../../server/nodes/BlocksNode.js'\nimport type { BlocksFeatureClientProps } from '../index.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $createBlockNode, BlockNode } from '../nodes/BlocksNode.js'\nimport { $createInlineBlockNode, $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\nimport { INSERT_BLOCK_COMMAND, INSERT_INLINE_BLOCK_COMMAND } from './commands.js'\n\nexport type InsertBlockPayload = BlockFieldsOptionalID\n\nexport const BlocksPlugin: PluginComponent<BlocksFeatureClientProps> = () => {\n const [editor] = useLexicalComposerContext()\n\n const [targetNodeKey, setTargetNodeKey] = useState<null | string>(null)\n\n const { uuid } = useEditorConfigContext()\n const editDepth = useEditDepth()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-` + uuid,\n depth: editDepth,\n })\n\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n useEffect(() => {\n if (!editor.hasNodes([BlockNode])) {\n throw new Error('BlocksPlugin: BlocksNode not registered on editor')\n }\n\n return mergeRegister(\n editor.registerCommand<InsertBlockPayload>(\n INSERT_BLOCK_COMMAND,\n (payload: InsertBlockPayload) => {\n editor.update(() => {\n const selection = $getSelection() || $getPreviousSelection()\n\n if ($isRangeSelection(selection)) {\n const blockNode = $createBlockNode(payload)\n // Insert blocks node BEFORE potentially removing focusNode, as $insertNodeToNearestRoot errors if the focusNode doesn't exist\n $insertNodeToNearestRoot(blockNode)\n\n const { focus } = selection\n const focusNode = focus.getNode()\n\n // First, delete currently selected node if it's an empty paragraph and if there are sufficient\n // paragraph nodes (more than 1) left in the parent node, so that we don't \"trap\" the user\n if (\n $isParagraphNode(focusNode) &&\n focusNode.getTextContentSize() === 0 &&\n focusNode\n .getParentOrThrow()\n .getChildren()\n .filter((node) => $isParagraphNode(node)).length > 1\n ) {\n focusNode.remove()\n }\n }\n })\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n editor.registerCommand(\n INSERT_INLINE_BLOCK_COMMAND,\n (fields) => {\n if (targetNodeKey) {\n const node = $getNodeByKey(targetNodeKey)\n\n if (!node || !$isInlineBlockNode(node)) {\n return false\n }\n\n node.setFields(fields as BlockFields)\n\n setTargetNodeKey(null)\n return true\n }\n\n const inlineBlockNode = $createInlineBlockNode(fields as BlockFields)\n $insertNodes([inlineBlockNode])\n if ($isRootOrShadowRoot(inlineBlockNode.getParentOrThrow())) {\n $wrapNodeInElement(inlineBlockNode, $createParagraphNode).selectEnd()\n }\n\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [editor, targetNodeKey, toggleDrawer])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,wBAAwB,EAAEC,kBAAkB,EAAEC,aAAa,QAAQ;AAC5E,SAASC,gBAAgB,EAAEC,YAAY,QAAQ;AAC/C,SACEC,oBAAoB,EACpBC,aAAa,EACbC,qBAAqB,EACrBC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,iBAAiB,EACjBC,mBAAmB,EACnBC,uBAAuB,QAClB;AACP,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAMpC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,gBAAgB,EAAEC,SAAS,QAAQ;AAC5C,SAASC,sBAAsB,EAAEC,kBAAkB,QAAQ;AAC3D,SAASC,oBAAoB,EAAEC,2BAA2B,QAAQ;AAIlE,OAAO,MAAMC,YAAA,GAA0DA,CAAA;EAAA,MAAAC,CAAA,GAAA3B,EAAA;EACrE,OAAA4B,MAAA,IAAiB3B,yBAAA;EAEjB,OAAA4B,aAAA,EAAAC,gBAAA,IAA0Cb,QAAA,KAAwB;EAElE;IAAAc;EAAA,IAAiBb,sBAAA;EACjB,MAAAc,SAAA,GAAkB1B,YAAA;EAGV,MAAA2B,EAAA,iCAA8B,GAAGF,IAAA;EAAA,IAAAG,EAAA;EAAA,IAAAP,CAAA,QAAAM,EAAA,IAAAN,CAAA,QAAAK,SAAA;IADtBE,EAAA,GAAA7B,gBAAA;MAAA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AAE,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,aAAa,gIAmLxB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/blocks/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAA8C,MAAM,SAAS,CAAA;AAIhF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAUlE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,KAAK,EAAE,CAAA;IAChB,YAAY,CAAC,EAAE,KAAK,EAAE,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,aAAa,gIAgNxB,CAAA"}
@@ -85,8 +85,21 @@ export const BlocksFeature = createServerFeature({
85
85
  const schemaMap = new Map();
86
86
  if (props?.blocks?.length) {
87
87
  for (const block of props.blocks) {
88
+ const blockFields = [...block.fields];
89
+ if (block?.admin?.components) {
90
+ blockFields.unshift({
91
+ name: `_components`,
92
+ type: 'ui',
93
+ admin: {
94
+ components: {
95
+ Block: block.admin?.components?.Block,
96
+ BlockLabel: block.admin?.components?.Label
97
+ }
98
+ }
99
+ });
100
+ }
88
101
  schemaMap.set(`lexical_blocks.${block.slug}.fields`, {
89
- fields: block.fields
102
+ fields: blockFields
90
103
  });
91
104
  schemaMap.set(`lexical_blocks.${block.slug}`, {
92
105
  name: `lexical_blocks_${block.slug}`,
@@ -98,8 +111,21 @@ export const BlocksFeature = createServerFeature({
98
111
  if (props?.inlineBlocks?.length) {
99
112
  // To generate block schemaMap which generates things like the componentMap for admin.Label
100
113
  for (const block of props.inlineBlocks) {
114
+ const blockFields = [...block.fields];
115
+ if (block?.admin?.components) {
116
+ blockFields.unshift({
117
+ name: `_components`,
118
+ type: 'ui',
119
+ admin: {
120
+ components: {
121
+ Block: block.admin?.components?.Block,
122
+ BlockLabel: block.admin?.components?.Label
123
+ }
124
+ }
125
+ });
126
+ }
101
127
  schemaMap.set(`lexical_inline_blocks.${block.slug}.fields`, {
102
- fields: block.fields
128
+ fields: blockFields
103
129
  });
104
130
  schemaMap.set(`lexical_inline_blocks.${block.slug}`, {
105
131
  name: `lexical_inline_blocks_${block.slug}`,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["fieldsToJSONSchema","sanitizeFields","createServerFeature","createNode","blockPopulationPromiseHOC","i18n","ServerBlockNode","ServerInlineBlockNode","blockValidationHOC","BlocksFeature","feature","config","_config","isRoot","parentIsLocalized","props","clientProps","clientBlockSlugs","clientInlineBlockSlugs","validRelationships","collections","map","c","slug","sanitized","fields","name","type","blocks","inlineBlocks","requireFieldLevelRichTextEditor","block","ClientFeature","clientFeatureProps","generatedTypes","modifyOutputSchema","collectionIDFieldTypes","currentSchema","field","interfaceNameDefinitions","length","push","generateSchemaMap","schemaMap","Map","set","nodes","getSubFields","node","blockType","find","getSubFieldsData","graphQLPopulationPromises","validations","sanitizedServerFeatureProps","key"],"sources":["../../../../src/features/blocks/server/index.ts"],"sourcesContent":["import type { Block, BlocksField, Config, Field, FieldSchemaMap } from 'payload'\n\nimport { fieldsToJSONSchema, sanitizeFields } from 'payload'\n\nimport type { BlocksFeatureClientProps } from '../client/index.js'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { blockPopulationPromiseHOC } from './graphQLPopulationPromise.js'\nimport { i18n } from './i18n.js'\nimport { ServerBlockNode } from './nodes/BlocksNode.js'\nimport { ServerInlineBlockNode } from './nodes/InlineBlocksNode.js'\nimport { blockValidationHOC } from './validate.js'\n\nexport type BlocksFeatureProps = {\n blocks?: Block[]\n inlineBlocks?: Block[]\n}\n\nexport const BlocksFeature = createServerFeature<\n BlocksFeatureProps,\n BlocksFeatureProps,\n BlocksFeatureClientProps\n>({\n feature: async ({ config: _config, isRoot, parentIsLocalized, props }) => {\n // Build clientProps\n const clientProps: BlocksFeatureClientProps = {\n clientBlockSlugs: [],\n clientInlineBlockSlugs: [],\n }\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n const sanitized = await sanitizeFields({\n config: _config as unknown as Config,\n fields: [\n {\n name: 'lexical_blocks',\n type: 'blocks',\n blocks: props.blocks ?? [],\n },\n {\n name: 'lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks ?? [],\n },\n ],\n parentIsLocalized,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n\n props.blocks = (sanitized[0] as BlocksField).blocks\n props.inlineBlocks = (sanitized[1] as BlocksField).blocks\n\n clientProps.clientBlockSlugs = props.blocks.map((block) => block.slug)\n clientProps.clientInlineBlockSlugs = props.inlineBlocks.map((block) => block.slug)\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#BlocksFeatureClient',\n clientFeatureProps: clientProps,\n generatedTypes: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n }) => {\n if (!props?.blocks?.length && !props?.inlineBlocks?.length) {\n return currentSchema\n }\n\n const fields: BlocksField[] = []\n\n if (props?.blocks?.length) {\n fields.push({\n name: field?.name + '_lexical_blocks',\n type: 'blocks',\n blocks: props.blocks,\n })\n }\n if (props?.inlineBlocks?.length) {\n fields.push({\n name: field?.name + '_lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks,\n })\n }\n\n if (fields.length) {\n // This is only done so that interfaceNameDefinitions sets those block's interfaceNames.\n // we don't actually use the JSON Schema itself in the generated types yet.\n fieldsToJSONSchema(collectionIDFieldTypes, fields, interfaceNameDefinitions, config)\n }\n\n return currentSchema\n },\n },\n generateSchemaMap: ({ props }) => {\n /**\n * Add sub-fields to the schemaMap. E.g. if you have an array field as part of the block, and it runs addRow, it will request these\n * sub-fields from the component map. Thus, we need to put them in the component map here.\n */\n const schemaMap: FieldSchemaMap = new Map()\n\n if (props?.blocks?.length) {\n for (const block of props.blocks) {\n schemaMap.set(`lexical_blocks.${block.slug}.fields`, {\n fields: block.fields,\n })\n schemaMap.set(`lexical_blocks.${block.slug}`, {\n name: `lexical_blocks_${block.slug}`,\n type: 'blocks',\n blocks: [block],\n })\n }\n }\n\n if (props?.inlineBlocks?.length) {\n // To generate block schemaMap which generates things like the componentMap for admin.Label\n for (const block of props.inlineBlocks) {\n schemaMap.set(`lexical_inline_blocks.${block.slug}.fields`, {\n fields: block.fields,\n })\n\n schemaMap.set(`lexical_inline_blocks.${block.slug}`, {\n name: `lexical_inline_blocks_${block.slug}`,\n type: 'blocks',\n blocks: [block],\n })\n }\n }\n\n return schemaMap\n },\n i18n,\n nodes: [\n createNode({\n // @ts-expect-error - TODO: fix this\n getSubFields: ({ node }) => {\n if (!node) {\n if (props?.blocks?.length) {\n return [\n {\n name: 'lexical_blocks',\n type: 'blocks',\n blocks: props.blocks,\n },\n ]\n }\n return []\n }\n\n const blockType = node.fields.blockType\n\n const block = props.blocks?.find((block) => block.slug === blockType)\n return block?.fields\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [blockPopulationPromiseHOC(props.blocks)],\n node: ServerBlockNode,\n validations: [blockValidationHOC(props.blocks)],\n }),\n createNode({\n // @ts-expect-error - TODO: fix this\n getSubFields: ({ node }) => {\n if (!node) {\n if (props?.inlineBlocks?.length) {\n return [\n {\n name: 'lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks,\n },\n ]\n }\n return []\n }\n\n const blockType = node.fields.blockType\n\n const block = props.inlineBlocks?.find((block) => block.slug === blockType)\n return block?.fields\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [blockPopulationPromiseHOC(props.inlineBlocks)],\n node: ServerInlineBlockNode,\n validations: [blockValidationHOC(props.inlineBlocks)],\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'blocks',\n})\n"],"mappings":"AAEA,SAASA,kBAAkB,EAAEC,cAAc,QAAQ;AAInD,SAASC,mBAAmB,QAAQ;AACpC,SAASC,UAAU,QAAQ;AAC3B,SAASC,yBA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0BW,KAAA,CAAMa,MAAM,EAAE;QACpEoB,IAAA,EAAM1C,eAAA;QACN+C,WAAA,EAAa,CAAC7C,kBAAA,CAAmBO,KAAA,CAAMa,MAAM;MAC/C,IACAzB,UAAA,CAAW;QACT;QACA4C,YAAA,EAAcA,CAAC;UAAEC;QAAI,CAAE;UACrB,IAAI,CAACA,IAAA,EAAM;YACT,IAAIjC,KAAA,EAAOc,YAAA,EAAcW,MAAA,EAAQ;cAC/B,OAAO,CACL;gBACEd,IAAA,EAAM;gBACNC,IAAA,EAAM;gBACNC,MAAA,EAAQb,KAAA,CAAMc;cAChB,EACD;YACH;YACA,OAAO,EAAE;UACX;UAEA,MAAMoB,SAAA,GAAYD,IAAA,CAAKvB,MAAM,CAACwB,SAAS;UAEvC,MAAMlB,KAAA,GAAQhB,KAAA,CAAMc,YAAY,EAAEqB,IAAA,CAAMnB,KAAA,IAAUA,KAAA,CAAMR,IAAI,KAAK0B,SAAA;UACjE,OAAOlB,KAAA,EAAON,MAAA;QAChB;QACA0B,gBAAA,EAAkBA,CAAC;UAAEH;QAAI,CAAE;UACzB,OAAOA,IAAA,EAAMvB,MAAA;QACf;QACA2B,yBAAA,EAA2B,CAAChD,yBAAA,CAA0BW,KAAA,CAAMc,YAAY,EAAE;QAC1EmB,IAAA,EAAMzC,qBAAA;QACN8C,WAAA,EAAa,CAAC7C,kBAAA,CAAmBO,KAAA,CAAMc,YAAY;MACrD,GACD;MACDyB,2BAAA,EAA6BvC;IAC/B;EACF;EACAwC,GAAA,EAAK;AACP","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["fieldsToJSONSchema","sanitizeFields","createServerFeature","createNode","blockPopulationPromiseHOC","i18n","ServerBlockNode","ServerInlineBlockNode","blockValidationHOC","BlocksFeature","feature","config","_config","isRoot","parentIsLocalized","props","clientProps","clientBlockSlugs","clientInlineBlockSlugs","validRelationships","collections","map","c","slug","sanitized","fields","name","type","blocks","inlineBlocks","requireFieldLevelRichTextEditor","block","ClientFeature","clientFeatureProps","generatedTypes","modifyOutputSchema","collectionIDFieldTypes","currentSchema","field","interfaceNameDefinitions","length","push","generateSchemaMap","schemaMap","Map","blockFields","admin","components","unshift","Block","BlockLabel","Label","set","nodes","getSubFields","node","blockType","find","getSubFieldsData","graphQLPopulationPromises","validations","sanitizedServerFeatureProps","key"],"sources":["../../../../src/features/blocks/server/index.ts"],"sourcesContent":["import type { Block, BlocksField, Config, Field, FieldSchemaMap } from 'payload'\n\nimport { fieldsToJSONSchema, sanitizeFields } from 'payload'\n\nimport type { BlocksFeatureClientProps } from '../client/index.js'\n\nimport { createServerFeature } from '../../../utilities/createServerFeature.js'\nimport { createNode } from '../../typeUtilities.js'\nimport { blockPopulationPromiseHOC } from './graphQLPopulationPromise.js'\nimport { i18n } from './i18n.js'\nimport { ServerBlockNode } from './nodes/BlocksNode.js'\nimport { ServerInlineBlockNode } from './nodes/InlineBlocksNode.js'\nimport { blockValidationHOC } from './validate.js'\n\nexport type BlocksFeatureProps = {\n blocks?: Block[]\n inlineBlocks?: Block[]\n}\n\nexport const BlocksFeature = createServerFeature<\n BlocksFeatureProps,\n BlocksFeatureProps,\n BlocksFeatureClientProps\n>({\n feature: async ({ config: _config, isRoot, parentIsLocalized, props }) => {\n // Build clientProps\n const clientProps: BlocksFeatureClientProps = {\n clientBlockSlugs: [],\n clientInlineBlockSlugs: [],\n }\n const validRelationships = _config.collections.map((c) => c.slug) || []\n\n const sanitized = await sanitizeFields({\n config: _config as unknown as Config,\n fields: [\n {\n name: 'lexical_blocks',\n type: 'blocks',\n blocks: props.blocks ?? [],\n },\n {\n name: 'lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks ?? [],\n },\n ],\n parentIsLocalized,\n requireFieldLevelRichTextEditor: isRoot,\n validRelationships,\n })\n\n props.blocks = (sanitized[0] as BlocksField).blocks\n props.inlineBlocks = (sanitized[1] as BlocksField).blocks\n\n clientProps.clientBlockSlugs = props.blocks.map((block) => block.slug)\n clientProps.clientInlineBlockSlugs = props.inlineBlocks.map((block) => block.slug)\n\n return {\n ClientFeature: '@payloadcms/richtext-lexical/client#BlocksFeatureClient',\n clientFeatureProps: clientProps,\n generatedTypes: {\n modifyOutputSchema: ({\n collectionIDFieldTypes,\n config,\n currentSchema,\n field,\n interfaceNameDefinitions,\n }) => {\n if (!props?.blocks?.length && !props?.inlineBlocks?.length) {\n return currentSchema\n }\n\n const fields: BlocksField[] = []\n\n if (props?.blocks?.length) {\n fields.push({\n name: field?.name + '_lexical_blocks',\n type: 'blocks',\n blocks: props.blocks,\n })\n }\n if (props?.inlineBlocks?.length) {\n fields.push({\n name: field?.name + '_lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks,\n })\n }\n\n if (fields.length) {\n // This is only done so that interfaceNameDefinitions sets those block's interfaceNames.\n // we don't actually use the JSON Schema itself in the generated types yet.\n fieldsToJSONSchema(collectionIDFieldTypes, fields, interfaceNameDefinitions, config)\n }\n\n return currentSchema\n },\n },\n generateSchemaMap: ({ props }) => {\n /**\n * Add sub-fields to the schemaMap. E.g. if you have an array field as part of the block, and it runs addRow, it will request these\n * sub-fields from the component map. Thus, we need to put them in the component map here.\n */\n const schemaMap: FieldSchemaMap = new Map()\n\n if (props?.blocks?.length) {\n for (const block of props.blocks) {\n const blockFields = [...block.fields]\n\n if (block?.admin?.components) {\n blockFields.unshift({\n name: `_components`,\n type: 'ui',\n admin: {\n components: {\n Block: block.admin?.components?.Block,\n BlockLabel: block.admin?.components?.Label,\n },\n },\n })\n }\n schemaMap.set(`lexical_blocks.${block.slug}.fields`, {\n fields: blockFields,\n })\n schemaMap.set(`lexical_blocks.${block.slug}`, {\n name: `lexical_blocks_${block.slug}`,\n type: 'blocks',\n blocks: [block],\n })\n }\n }\n\n if (props?.inlineBlocks?.length) {\n // To generate block schemaMap which generates things like the componentMap for admin.Label\n for (const block of props.inlineBlocks) {\n const blockFields = [...block.fields]\n\n if (block?.admin?.components) {\n blockFields.unshift({\n name: `_components`,\n type: 'ui',\n admin: {\n components: {\n Block: block.admin?.components?.Block,\n BlockLabel: block.admin?.components?.Label,\n },\n },\n })\n }\n\n schemaMap.set(`lexical_inline_blocks.${block.slug}.fields`, {\n fields: blockFields,\n })\n\n schemaMap.set(`lexical_inline_blocks.${block.slug}`, {\n name: `lexical_inline_blocks_${block.slug}`,\n type: 'blocks',\n blocks: [block],\n })\n }\n }\n\n return schemaMap\n },\n i18n,\n nodes: [\n createNode({\n // @ts-expect-error - TODO: fix this\n getSubFields: ({ node }) => {\n if (!node) {\n if (props?.blocks?.length) {\n return [\n {\n name: 'lexical_blocks',\n type: 'blocks',\n blocks: props.blocks,\n },\n ]\n }\n return []\n }\n\n const blockType = node.fields.blockType\n\n const block = props.blocks?.find((block) => block.slug === blockType)\n return block?.fields\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [blockPopulationPromiseHOC(props.blocks)],\n node: ServerBlockNode,\n validations: [blockValidationHOC(props.blocks)],\n }),\n createNode({\n // @ts-expect-error - TODO: fix this\n getSubFields: ({ node }) => {\n if (!node) {\n if (props?.inlineBlocks?.length) {\n return [\n {\n name: 'lexical_inline_blocks',\n type: 'blocks',\n blocks: props.inlineBlocks,\n },\n ]\n }\n return []\n }\n\n const blockType = node.fields.blockType\n\n const block = props.inlineBlocks?.find((block) => block.slug === blockType)\n return block?.fields\n },\n getSubFieldsData: ({ node }) => {\n return node?.fields\n },\n graphQLPopulationPromises: [blockPopulationPromiseHOC(props.inlineBlocks)],\n node: ServerInlineBlockNode,\n validations: [blockValidationHOC(props.inlineBlocks)],\n }),\n ],\n sanitizedServerFeatureProps: props,\n }\n },\n key: 'blocks',\n})\n"],"mappings":"AAEA,SAASA,kBAAkB,EAAEC,cAAc,QAAQ;AAInD,SAASC,mBAAmB,QAAQ;AACpC,SAASC,UAAU,QAAQ;AAC3B,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,IAAI,QAAQ;AACrB,SAASC,eAAe,QAAQ;AAChC,SAASC,q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,CAAMR,IAAI,KAAKiC,SAAA;UACjE,OAAOzB,KAAA,EAAON,MAAA;QAChB;QACAiC,gBAAA,EAAkBA,CAAC;UAAEH;QAAI,CAAE;UACzB,OAAOA,IAAA,EAAM9B,MAAA;QACf;QACAkC,yBAAA,EAA2B,CAACvD,yBAAA,CAA0BW,KAAA,CAAMc,YAAY,EAAE;QAC1E0B,IAAA,EAAMhD,qBAAA;QACNqD,WAAA,EAAa,CAACpD,kBAAA,CAAmBO,KAAA,CAAMc,YAAY;MACrD,GACD;MACDgC,2BAAA,EAA6B9C;IAC/B;EACF;EACA+C,GAAA,EAAK;AACP","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import type { Transformer } from '@lexical/markdown';
2
- import type { Klass, LexicalEditor, LexicalNode, LexicalNodeReplacement, SerializedEditorState } from 'lexical';
2
+ import type { Klass, LexicalEditor, LexicalNode, LexicalNodeReplacement } from 'lexical';
3
3
  import type React from 'react';
4
4
  import type { ClientEditorConfig } from '../lexical/config/types.js';
5
5
  import type { SlashMenuGroup } from '../lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js';
@@ -28,14 +28,6 @@ export type PluginComponentWithAnchor<ClientFeatureProps = any> = React.FC<{
28
28
  clientProps: ClientFeatureProps;
29
29
  }>;
30
30
  export type ClientFeature<ClientFeatureProps> = {
31
- hooks?: {
32
- load?: ({ incomingEditorState, }: {
33
- incomingEditorState: SerializedEditorState;
34
- }) => SerializedEditorState;
35
- save?: ({ incomingEditorState, }: {
36
- incomingEditorState: SerializedEditorState;
37
- }) => SerializedEditorState;
38
- };
39
31
  markdownTransformers?: Transformer[];
40
32
  nodes?: Array<Klass<LexicalNode> | LexicalNodeReplacement>;
41
33
  /**
@@ -152,14 +144,6 @@ export type SanitizedPlugin = {
152
144
  export type SanitizedClientFeatures = {
153
145
  /** The keys of all enabled features */
154
146
  enabledFeatures: string[];
155
- hooks: {
156
- load: Array<({ incomingEditorState, }: {
157
- incomingEditorState: SerializedEditorState;
158
- }) => SerializedEditorState>;
159
- save: Array<({ incomingEditorState, }: {
160
- incomingEditorState: SerializedEditorState;
161
- }) => SerializedEditorState>;
162
- };
163
147
  /**
164
148
  * Plugins are react components which get added to the editor. You can use them to interact with lexical, e.g. to create a command which creates a node, or opens a modal, or some other more "outside" functionality
165
149
  */
@@ -1 +1 @@
1
- {"version":3,"file":"typesClient.d.ts","sourceRoot":"","sources":["../../src/features/typesClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EACV,KAAK,EACL,aAAa,EACb,WAAW,EACX,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kEAAkE,CAAA;AACtG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD,MAAM,MAAM,6BAA6B,CACvC,6BAA6B,GAAG,SAAS,EACzC,kBAAkB,GAAG,6BAA6B,IAChD,CAAC,KAAK,EAAE,sBAAsB,CAAC,kBAAkB,CAAC,KAAK,qBAAqB,CAAC,kBAAkB,CAAC,CAAA;AAEpG;;GAEG;AACH,MAAM,MAAM,qBAAqB,CAC/B,6BAA6B,GAAG,SAAS,EACzC,kBAAkB,GAAG,6BAA6B,IAChD;IACF;;OAEG;IACH,kBAAkB,EAAE,sBAAsB,CAAC,6BAA6B,CAAC,CAAA;IACzE,OAAO,EACH,CAAC,CAAC,KAAK,EAAE;QACP,mDAAmD;QACnD,kBAAkB,EAAE,wBAAwB,CAAA;QAE5C,gBAAgB,EAAE,wBAAwB,CAAA;QAE1C,uBAAuB,EAAE,kBAAkB,CAAA;KAC5C,KAAK,aAAa,CAAC,kBAAkB,CAAC,CAAC,GACxC,aAAa,CAAC,kBA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,KAAK,CAAC,eAAe,CAAC,CAAA;IAChC,SAAS,EAAE;QACT;;;;;WAKG;QACH,aAAa,EAAE,KAAK,CAClB,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE;YAAE,MAAM,EAAE,aAAa,CAAC;YAAC,WAAW,EAAE,MAAM,CAAA;SAAE,KAAK,cAAc,EAAE,CAC9F,CAAA;QACD;;;WAGG;QACH,MAAM,EAAE,cAAc,EAAE,CAAA;KACzB,CAAA;CACF,GAAG,QAAQ,CACV,IAAI,CACF,qBAAqB,CAAC,OAAO,CAAC,EAC9B,sBAAsB,GAAG,OAAO,GAAG,WAAW,GAAG,cAAc,GAAG,eAAe,CAClF,CACF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"typesClient.js","names":[],"sources":["../../src/features/typesClient.ts"],"sourcesContent":["import type { Transformer } from '@lexical/markdown'\nimport type {\n Klass,\n LexicalEditor,\n LexicalNode,\n LexicalNodeReplacement,\n SerializedEditorState,\n} from 'lexical'\nimport type React from 'react'\n\nimport type { ClientEditorConfig } from '../lexical/config/types.js'\nimport type { SlashMenuGroup } from '../lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\nimport type { ToolbarGroup } from './toolbars/types.js'\n\nexport type FeatureProviderProviderClient<\n UnSanitizedClientFeatureProps = undefined,\n ClientFeatureProps = UnSanitizedClientFeatureProps,\n> = (props: BaseClientFeatureProps<ClientFeatureProps>) => FeatureProviderClient<ClientFeatureProps>\n\n/**\n * No dependencies => Features need to be sorted on the server first, then sent to client in right order\n */\nexport type FeatureProviderClient<\n UnSanitizedClientFeatureProps = undefined,\n ClientFeatureProps = UnSanitizedClientFeatureProps,\n> = {\n /**\n * Return props, to make it easy to retrieve passed in props to this Feature for the client if anyone wants to\n */\n clientFeatureProps: BaseClientFeatureProps<UnSanitizedClientFeatureProps>\n feature:\n | ((props: {\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ClientFeatureProviderMap\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedClientFeatureMap\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ClientEditorConfig\n }) => ClientFeature<ClientFeatureProps>)\n | ClientFeature<ClientFeatureProps>\n}\n\nexport type PluginComponent<ClientFeatureProps = any> = React.FC<{\n clientProps: ClientFeatureProps\n}>\nexport type PluginComponentWithAnchor<ClientFeatureProps = any> = React.FC<{\n anchorElem: HTMLElement\n clientProps: ClientFeatureProps\n}>\n\nexport type ClientFeature<ClientFeatureProps> = {\n hooks?: {\n load?: ({\n incomingEditorState,\n }: {\n incomingEditorState: SerializedEditorState\n }) => SerializedEditorState\n save?: ({\n incomingEditorState,\n }: {\n incomingEditorState: SerializedEditorState\n }) => SerializedEditorState\n }\n markdownTransformers?: Transformer[]\n nodes?: Array<Klass<LexicalNode> | LexicalNodeReplacement>\n /**\n * Plugins are react components which get added to the editor. You can use them to interact with lexical, e.g. to create a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n */\n plugins?: Array<\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent<ClientFeatureProps>\n position: 'aboveContainer' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent<ClientFeatureProps>\n position: 'bottom' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent<ClientFeatureProps>\n position: 'normal' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent<ClientFeatureProps>\n position: 'top' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponentWithAnchor<ClientFeatureProps>\n position: 'floatingAnchorElem' // Determines at which position the Component will be added.\n }\n | {\n Component: PluginComponent<ClientFeatureProps>\n position: 'belowContainer' // Determines at which position the Component will be added.\n }\n >\n /**\n * Client Features can register their own providers, which will be nested below the EditorConfigProvider\n */\n providers?: Array<React.FC>\n /**\n * Return props, to make it easy to retrieve passed in props to this Feature for the client if anyone wants to\n */\n sanitizedClientFeatureProps?: BaseClientFeatureProps<ClientFeatureProps>\n slashMenu?: {\n /**\n * Dynamic groups allow you to add different groups depending on the query string (so, the text after the slash).\n * Thus, to re-calculate the available groups, this function will be called every time you type after the /.\n *\n * The groups provided by dynamicGroups will be merged with the static groups provided by the groups property.\n */\n dynamicGroups?: ({\n editor,\n queryString,\n }: {\n editor: LexicalEditor\n queryString: string\n }) => SlashMenuGroup[]\n /**\n * Static array of groups together with the items in them. These will always be present.\n * While typing after the /, they will be filtered by the query string and the keywords, key and display name of the items.\n */\n groups?: SlashMenuGroup[]\n }\n /**\n * An opt-in, classic fixed toolbar which stays at the top of the editor\n */\n toolbarFixed?: {\n groups: ToolbarGroup[]\n }\n /**\n * The default, floating toolbar which appears when you select text.\n */\n toolbarInline?: {\n /**\n * Array of toolbar groups / sections. Each section can contain multiple toolbar items.\n */\n groups: ToolbarGroup[]\n }\n}\n\nexport type BaseClientFeatureProps<ClientFeatureProps> = ClientFeatureProps extends undefined\n ? {\n featureKey: string\n order: number\n }\n : {\n featureKey: string\n order: number\n } & ClientFeatureProps\n\nexport type ResolvedClientFeature<ClientFeatureProps> = {\n key: string\n order: number\n} & ClientFeature<ClientFeatureProps>\n\nexport type ResolvedClientFeatureMap = Map<string, ResolvedClientFeature<any>>\n\nexport type ClientFeatureProviderMap = Map<string, FeatureProviderClient<any, any>>\n\n/**\n * Plugins are react components which get added to the editor. You can use them to interact with lexical, e.g. to create a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n */\nexport type SanitizedPlugin =\n | {\n clientProps: any\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent\n key: string\n position: 'bottom' // Determines at which position the Component will be added.\n }\n | {\n clientProps: any\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent\n key: string\n position: 'normal' // Determines at which position the Component will be added.\n }\n | {\n clientProps: any\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent\n key: string\n position: 'top' // Determines at which position the Component will be added.\n }\n | {\n clientProps: any\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponentWithAnchor\n desktopOnly?: boolean\n key: string\n position: 'floatingAnchorElem' // Determines at which position the Component will be added.\n }\n | {\n clientProps: any\n Component: PluginComponent\n key: string\n position: 'aboveContainer'\n }\n | {\n clientProps: any\n Component: PluginComponent\n key: string\n position: 'belowContainer'\n }\n\nexport type SanitizedClientFeatures = {\n /** The keys of all enabled features */\n enabledFeatures: string[]\n hooks: {\n load: Array<\n ({\n incomingEditorState,\n }: {\n incomingEditorState: SerializedEditorState\n }) => SerializedEditorState\n >\n save: Array<\n ({\n incomingEditorState,\n }: {\n incomingEditorState: SerializedEditorState\n }) => SerializedEditorState\n >\n }\n /**\n * Plugins are react components which get added to the editor. You can use them to interact with lexical, e.g. to create a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n */\n plugins?: Array<SanitizedPlugin>\n slashMenu: {\n /**\n * Dynamic groups allow you to add different groups depending on the query string (so, the text after the slash).\n * Thus, to re-calculate the available groups, this function will be called every time you type after the /.\n *\n * The groups provided by dynamicGroups will be merged with the static groups provided by the groups property.\n */\n dynamicGroups: Array<\n ({ editor, queryString }: { editor: LexicalEditor; queryString: string }) => SlashMenuGroup[]\n >\n /**\n * Static array of groups together with the items in them. These will always be present.\n * While typing after the /, they will be filtered by the query string and the keywords, key and display name of the items.\n */\n groups: SlashMenuGroup[]\n }\n} & Required<\n Pick<\n ResolvedClientFeature<unknown>,\n 'markdownTransformers' | 'nodes' | 'providers' | 'toolbarFixed' | 'toolbarInline'\n >\n>\n"],"mappings":"AAiNA","ignoreList":[]}
1
+ {"version":3,"file":"typesClient.js","names":[],"sources":["../../src/features/typesClient.ts"],"sourcesContent":["import type { Transformer } from '@lexical/markdown'\nimport type {\n Klass,\n LexicalEditor,\n LexicalNode,\n LexicalNodeReplacement,\n SerializedEditorState,\n} from 'lexical'\nimport type React from 'react'\n\nimport type { ClientEditorConfig } from '../lexical/config/types.js'\nimport type { SlashMenuGroup } from '../lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\nimport type { ToolbarGroup } from './toolbars/types.js'\n\nexport type FeatureProviderProviderClient<\n UnSanitizedClientFeatureProps = undefined,\n ClientFeatureProps = UnSanitizedClientFeatureProps,\n> = (props: BaseClientFeatureProps<ClientFeatureProps>) => FeatureProviderClient<ClientFeatureProps>\n\n/**\n * No dependencies => Features need to be sorted on the server first, then sent to client in right order\n */\nexport type FeatureProviderClient<\n UnSanitizedClientFeatureProps = undefined,\n ClientFeatureProps = UnSanitizedClientFeatureProps,\n> = {\n /**\n * Return props, to make it easy to retrieve passed in props to this Feature for the client if anyone wants to\n */\n clientFeatureProps: BaseClientFeatureProps<UnSanitizedClientFeatureProps>\n feature:\n | ((props: {\n /** unSanitizedEditorConfig.features, but mapped */\n featureProviderMap: ClientFeatureProviderMap\n // other resolved features, which have been loaded before this one. All features declared in 'dependencies' should be available here\n resolvedFeatures: ResolvedClientFeatureMap\n // unSanitized EditorConfig,\n unSanitizedEditorConfig: ClientEditorConfig\n }) => ClientFeature<ClientFeatureProps>)\n | ClientFeature<ClientFeatureProps>\n}\n\nexport type PluginComponent<ClientFeatureProps = any> = React.FC<{\n clientProps: ClientFeatureProps\n}>\nexport type PluginComponentWithAnchor<ClientFeatureProps = any> = React.FC<{\n anchorElem: HTMLElement\n clientProps: ClientFeatureProps\n}>\n\nexport type ClientFeature<ClientFeatureProps> = {\n markdownTransformers?: Transformer[]\n nodes?: Array<Klass<LexicalNode> | LexicalNodeReplacement>\n /**\n * Plugins are react components which get added to the editor. You can use them to interact with lexical, e.g. to create a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n */\n plugins?: Array<\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent<ClientFeatureProps>\n position: 'aboveContainer' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent<ClientFeatureProps>\n position: 'bottom' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent<ClientFeatureProps>\n position: 'normal' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent<ClientFeatureProps>\n position: 'top' // Determines at which position the Component will be added.\n }\n | {\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponentWithAnchor<ClientFeatureProps>\n position: 'floatingAnchorElem' // Determines at which position the Component will be added.\n }\n | {\n Component: PluginComponent<ClientFeatureProps>\n position: 'belowContainer' // Determines at which position the Component will be added.\n }\n >\n /**\n * Client Features can register their own providers, which will be nested below the EditorConfigProvider\n */\n providers?: Array<React.FC>\n /**\n * Return props, to make it easy to retrieve passed in props to this Feature for the client if anyone wants to\n */\n sanitizedClientFeatureProps?: BaseClientFeatureProps<ClientFeatureProps>\n slashMenu?: {\n /**\n * Dynamic groups allow you to add different groups depending on the query string (so, the text after the slash).\n * Thus, to re-calculate the available groups, this function will be called every time you type after the /.\n *\n * The groups provided by dynamicGroups will be merged with the static groups provided by the groups property.\n */\n dynamicGroups?: ({\n editor,\n queryString,\n }: {\n editor: LexicalEditor\n queryString: string\n }) => SlashMenuGroup[]\n /**\n * Static array of groups together with the items in them. These will always be present.\n * While typing after the /, they will be filtered by the query string and the keywords, key and display name of the items.\n */\n groups?: SlashMenuGroup[]\n }\n /**\n * An opt-in, classic fixed toolbar which stays at the top of the editor\n */\n toolbarFixed?: {\n groups: ToolbarGroup[]\n }\n /**\n * The default, floating toolbar which appears when you select text.\n */\n toolbarInline?: {\n /**\n * Array of toolbar groups / sections. Each section can contain multiple toolbar items.\n */\n groups: ToolbarGroup[]\n }\n}\n\nexport type BaseClientFeatureProps<ClientFeatureProps> = ClientFeatureProps extends undefined\n ? {\n featureKey: string\n order: number\n }\n : {\n featureKey: string\n order: number\n } & ClientFeatureProps\n\nexport type ResolvedClientFeature<ClientFeatureProps> = {\n key: string\n order: number\n} & ClientFeature<ClientFeatureProps>\n\nexport type ResolvedClientFeatureMap = Map<string, ResolvedClientFeature<any>>\n\nexport type ClientFeatureProviderMap = Map<string, FeatureProviderClient<any, any>>\n\n/**\n * Plugins are react components which get added to the editor. You can use them to interact with lexical, e.g. to create a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n */\nexport type SanitizedPlugin =\n | {\n clientProps: any\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent\n key: string\n position: 'bottom' // Determines at which position the Component will be added.\n }\n | {\n clientProps: any\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent\n key: string\n position: 'normal' // Determines at which position the Component will be added.\n }\n | {\n clientProps: any\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponent\n key: string\n position: 'top' // Determines at which position the Component will be added.\n }\n | {\n clientProps: any\n // plugins are anything which is not directly part of the editor. Like, creating a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n Component: PluginComponentWithAnchor\n desktopOnly?: boolean\n key: string\n position: 'floatingAnchorElem' // Determines at which position the Component will be added.\n }\n | {\n clientProps: any\n Component: PluginComponent\n key: string\n position: 'aboveContainer'\n }\n | {\n clientProps: any\n Component: PluginComponent\n key: string\n position: 'belowContainer'\n }\n\nexport type SanitizedClientFeatures = {\n /** The keys of all enabled features */\n enabledFeatures: string[]\n /**\n * Plugins are react components which get added to the editor. You can use them to interact with lexical, e.g. to create a command which creates a node, or opens a modal, or some other more \"outside\" functionality\n */\n plugins?: Array<SanitizedPlugin>\n slashMenu: {\n /**\n * Dynamic groups allow you to add different groups depending on the query string (so, the text after the slash).\n * Thus, to re-calculate the available groups, this function will be called every time you type after the /.\n *\n * The groups provided by dynamicGroups will be merged with the static groups provided by the groups property.\n */\n dynamicGroups: Array<\n ({ editor, queryString }: { editor: LexicalEditor; queryString: string }) => SlashMenuGroup[]\n >\n /**\n * Static array of groups together with the items in them. These will always be present.\n * While typing after the /, they will be filtered by the query string and the keywords, key and display name of the items.\n */\n groups: SlashMenuGroup[]\n }\n} & Required<\n Pick<\n ResolvedClientFeature<unknown>,\n 'markdownTransformers' | 'nodes' | 'providers' | 'toolbarFixed' | 'toolbarInline'\n >\n>\n"],"mappings":"AAqMA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/field/Field.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAG1C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAG5D,OAAO,eAAe,CAAA;AACtB,OAAO,cAAc,CAAA;AACrB,OAAO,mCAAmC,CAAA;AAI1C,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAC/B;IACE,QAAQ,CAAC,YAAY,EAAE,2BAA2B,CAAA;CACnD,GAAG,yBAAyB,CAsG9B,CAAA;AAaD,eAAO,MAAM,QAAQ,EAAE,OAAO,iBAAoD,CAAA"}
1
+ {"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/field/Field.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAsB,MAAM,OAAO,CAAA;AAG1C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAG5D,OAAO,eAAe,CAAA;AACtB,OAAO,cAAc,CAAA;AACrB,OAAO,mCAAmC,CAAA;AAI1C,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAC/B;IACE,QAAQ,CAAC,YAAY,EAAE,2BAA2B,CAAA;CACnD,GAAG,yBAAyB,CAkG9B,CAAA;AAaD,eAAO,MAAM,QAAQ,EAAE,OAAO,iBAAoD,CAAA"}