@payloadcms/richtext-lexical 0.1.1 → 0.1.2
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/package.json +2 -2
- package/src/index.ts +0 -193
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"repository": "https://github.com/payloadcms/payload",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/node": "20.6.2",
|
|
45
45
|
"@types/react": "18.2.15",
|
|
46
|
-
"payload": "2.0.
|
|
46
|
+
"payload": "2.0.2",
|
|
47
47
|
"@payloadcms/eslint-config": "0.0.1"
|
|
48
48
|
},
|
|
49
49
|
"exports": null,
|
package/src/index.ts
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor'
|
|
2
|
-
import type { RichTextAdapter } from 'payload/types'
|
|
3
|
-
|
|
4
|
-
import { withMergedProps } from 'payload/components/utilities'
|
|
5
|
-
|
|
6
|
-
import type { FeatureProvider } from './field/features/types'
|
|
7
|
-
import type { EditorConfig, SanitizedEditorConfig } from './field/lexical/config/types'
|
|
8
|
-
import type { AdapterProps } from './types'
|
|
9
|
-
|
|
10
|
-
import { RichTextCell } from './cell'
|
|
11
|
-
import { RichTextField } from './field'
|
|
12
|
-
import {
|
|
13
|
-
defaultEditorFeatures,
|
|
14
|
-
defaultEditorLexicalConfig,
|
|
15
|
-
defaultSanitizedEditorConfig,
|
|
16
|
-
} from './field/lexical/config/default'
|
|
17
|
-
import { sanitizeEditorConfig } from './field/lexical/config/sanitize'
|
|
18
|
-
import { cloneDeep } from './field/lexical/utils/cloneDeep'
|
|
19
|
-
import { richTextRelationshipPromise } from './populate/richTextRelationshipPromise'
|
|
20
|
-
import { richTextValidateHOC } from './validate'
|
|
21
|
-
|
|
22
|
-
export type LexicalEditorProps = {
|
|
23
|
-
features?:
|
|
24
|
-
| (({ defaultFeatures }: { defaultFeatures: FeatureProvider[] }) => FeatureProvider[])
|
|
25
|
-
| FeatureProvider[]
|
|
26
|
-
lexical?: LexicalEditorConfig
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function lexicalEditor(props?: LexicalEditorProps): RichTextAdapter<AdapterProps> {
|
|
30
|
-
let finalSanitizedEditorConfig: SanitizedEditorConfig = null
|
|
31
|
-
if (!props || (!props.features && !props.lexical)) {
|
|
32
|
-
finalSanitizedEditorConfig = cloneDeep(defaultSanitizedEditorConfig)
|
|
33
|
-
} else {
|
|
34
|
-
let features: FeatureProvider[] =
|
|
35
|
-
props.features && typeof props.features === 'function'
|
|
36
|
-
? props.features({ defaultFeatures: cloneDeep(defaultEditorFeatures) })
|
|
37
|
-
: (props.features as FeatureProvider[])
|
|
38
|
-
if (!features) {
|
|
39
|
-
features = cloneDeep(defaultEditorFeatures)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const lexical: LexicalEditorConfig = props.lexical || cloneDeep(defaultEditorLexicalConfig)
|
|
43
|
-
|
|
44
|
-
finalSanitizedEditorConfig = sanitizeEditorConfig({
|
|
45
|
-
features,
|
|
46
|
-
lexical,
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
CellComponent: withMergedProps({
|
|
52
|
-
Component: RichTextCell,
|
|
53
|
-
toMergeIntoProps: { editorConfig: finalSanitizedEditorConfig },
|
|
54
|
-
}),
|
|
55
|
-
FieldComponent: withMergedProps({
|
|
56
|
-
Component: RichTextField,
|
|
57
|
-
toMergeIntoProps: { editorConfig: finalSanitizedEditorConfig },
|
|
58
|
-
}),
|
|
59
|
-
afterReadPromise({
|
|
60
|
-
currentDepth,
|
|
61
|
-
depth,
|
|
62
|
-
field,
|
|
63
|
-
overrideAccess,
|
|
64
|
-
req,
|
|
65
|
-
showHiddenFields,
|
|
66
|
-
siblingDoc,
|
|
67
|
-
}) {
|
|
68
|
-
// check if there are any features with nodes which have afterReadPromises for this field
|
|
69
|
-
if (finalSanitizedEditorConfig?.features?.afterReadPromises?.size) {
|
|
70
|
-
return richTextRelationshipPromise({
|
|
71
|
-
afterReadPromises: finalSanitizedEditorConfig.features.afterReadPromises,
|
|
72
|
-
currentDepth,
|
|
73
|
-
depth,
|
|
74
|
-
field,
|
|
75
|
-
overrideAccess,
|
|
76
|
-
req,
|
|
77
|
-
showHiddenFields,
|
|
78
|
-
siblingDoc,
|
|
79
|
-
})
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return null
|
|
83
|
-
},
|
|
84
|
-
validate: richTextValidateHOC({
|
|
85
|
-
editorConfig: finalSanitizedEditorConfig,
|
|
86
|
-
}),
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export { BlockQuoteFeature } from './field/features/BlockQuote'
|
|
91
|
-
export { BlocksFeature } from './field/features/Blocks'
|
|
92
|
-
export {
|
|
93
|
-
$createBlockNode,
|
|
94
|
-
$isBlockNode,
|
|
95
|
-
type BlockFields,
|
|
96
|
-
BlockNode,
|
|
97
|
-
type SerializedBlockNode,
|
|
98
|
-
} from './field/features/Blocks/nodes/BlocksNode'
|
|
99
|
-
|
|
100
|
-
export { HeadingFeature } from './field/features/Heading'
|
|
101
|
-
export { LinkFeature } from './field/features/Link'
|
|
102
|
-
export type { LinkFeatureProps } from './field/features/Link'
|
|
103
|
-
export {
|
|
104
|
-
$createAutoLinkNode,
|
|
105
|
-
$isAutoLinkNode,
|
|
106
|
-
AutoLinkNode,
|
|
107
|
-
type SerializedAutoLinkNode,
|
|
108
|
-
} from './field/features/Link/nodes/AutoLinkNode'
|
|
109
|
-
|
|
110
|
-
export {
|
|
111
|
-
$createLinkNode,
|
|
112
|
-
$isLinkNode,
|
|
113
|
-
type LinkFields,
|
|
114
|
-
LinkNode,
|
|
115
|
-
type SerializedLinkNode,
|
|
116
|
-
TOGGLE_LINK_COMMAND,
|
|
117
|
-
} from './field/features/Link/nodes/LinkNode'
|
|
118
|
-
export { ParagraphFeature } from './field/features/Paragraph'
|
|
119
|
-
export { RelationshipFeature } from './field/features/Relationship'
|
|
120
|
-
export {
|
|
121
|
-
$createRelationshipNode,
|
|
122
|
-
$isRelationshipNode,
|
|
123
|
-
type RelationshipData,
|
|
124
|
-
RelationshipNode,
|
|
125
|
-
type SerializedRelationshipNode,
|
|
126
|
-
} from './field/features/Relationship/nodes/RelationshipNode'
|
|
127
|
-
export { UploadFeature } from './field/features/Upload'
|
|
128
|
-
export type { UploadFeatureProps } from './field/features/Upload'
|
|
129
|
-
export {
|
|
130
|
-
$createUploadNode,
|
|
131
|
-
$isUploadNode,
|
|
132
|
-
RawUploadPayload,
|
|
133
|
-
type SerializedUploadNode,
|
|
134
|
-
type UploadData,
|
|
135
|
-
UploadNode,
|
|
136
|
-
} from './field/features/Upload/nodes/UploadNode'
|
|
137
|
-
export { AlignFeature } from './field/features/align'
|
|
138
|
-
export { TextDropdownSectionWithEntries } from './field/features/common/floatingSelectToolbarTextDropdownSection'
|
|
139
|
-
export { TreeviewFeature } from './field/features/debug/TreeView'
|
|
140
|
-
|
|
141
|
-
export { BoldTextFeature } from './field/features/format/Bold'
|
|
142
|
-
export { InlineCodeTextFeature } from './field/features/format/InlineCode'
|
|
143
|
-
export { ItalicTextFeature } from './field/features/format/Italic'
|
|
144
|
-
export { SectionWithEntries as FormatSectionWithEntries } from './field/features/format/common/floatingSelectToolbarSection'
|
|
145
|
-
export { StrikethroughTextFeature } from './field/features/format/strikethrough'
|
|
146
|
-
export { SubscriptTextFeature } from './field/features/format/subscript'
|
|
147
|
-
export { SuperscriptTextFeature } from './field/features/format/superscript'
|
|
148
|
-
export { UnderlineTextFeature } from './field/features/format/underline'
|
|
149
|
-
export { IndentFeature } from './field/features/indent'
|
|
150
|
-
export { CheckListFeature } from './field/features/lists/CheckList'
|
|
151
|
-
export { OrderedListFeature } from './field/features/lists/OrderedList'
|
|
152
|
-
export { UnoderedListFeature } from './field/features/lists/UnorderedList'
|
|
153
|
-
export type {
|
|
154
|
-
AfterReadPromise,
|
|
155
|
-
Feature,
|
|
156
|
-
FeatureProvider,
|
|
157
|
-
FeatureProviderMap,
|
|
158
|
-
NodeValidation,
|
|
159
|
-
ResolvedFeature,
|
|
160
|
-
ResolvedFeatureMap,
|
|
161
|
-
SanitizedFeatures,
|
|
162
|
-
} from './field/features/types'
|
|
163
|
-
export {
|
|
164
|
-
EditorConfigProvider,
|
|
165
|
-
useEditorConfigContext,
|
|
166
|
-
} from './field/lexical/config/EditorConfigProvider'
|
|
167
|
-
export {
|
|
168
|
-
defaultEditorConfig,
|
|
169
|
-
defaultEditorFeatures,
|
|
170
|
-
defaultEditorLexicalConfig,
|
|
171
|
-
defaultSanitizedEditorConfig,
|
|
172
|
-
} from './field/lexical/config/default'
|
|
173
|
-
export { loadFeatures, sortFeaturesForOptimalLoading } from './field/lexical/config/loader'
|
|
174
|
-
export { sanitizeEditorConfig, sanitizeFeatures } from './field/lexical/config/sanitize'
|
|
175
|
-
export { getEnabledNodes } from './field/lexical/nodes'
|
|
176
|
-
|
|
177
|
-
export { ToolbarButton } from './field/lexical/plugins/FloatingSelectToolbar/ToolbarButton'
|
|
178
|
-
export { ToolbarDropdown } from './field/lexical/plugins/FloatingSelectToolbar/ToolbarDropdown/index'
|
|
179
|
-
export {
|
|
180
|
-
type FloatingToolbarSection,
|
|
181
|
-
type FloatingToolbarSectionEntry,
|
|
182
|
-
} from './field/lexical/plugins/FloatingSelectToolbar/types'
|
|
183
|
-
export {
|
|
184
|
-
SlashMenuGroup,
|
|
185
|
-
SlashMenuOption,
|
|
186
|
-
} from './field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu'
|
|
187
|
-
// export SanitizedEditorConfig
|
|
188
|
-
export type { EditorConfig, SanitizedEditorConfig }
|
|
189
|
-
export type { AdapterProps }
|
|
190
|
-
export { RichTextCell }
|
|
191
|
-
export { RichTextField }
|
|
192
|
-
export { ENABLE_SLASH_MENU_COMMAND } from './field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index'
|
|
193
|
-
export { defaultRichTextValue } from './populate/defaultValue'
|