@payloadcms/richtext-lexical 0.1.0-beta.2 → 0.1.0-beta.4
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/README.md +28 -0
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +19 -4
- package/dist/field/features/Blocks/afterReadPromise.d.ts.map +1 -1
- package/dist/field/features/Blocks/afterReadPromise.js +4 -3
- package/dist/field/features/Blocks/component/BlockContent.d.ts.map +1 -1
- package/dist/field/features/Blocks/component/BlockContent.js +49 -23
- package/dist/field/features/Blocks/component/FormSavePlugin.d.ts +3 -2
- package/dist/field/features/Blocks/component/FormSavePlugin.d.ts.map +1 -1
- package/dist/field/features/Blocks/component/FormSavePlugin.js +4 -2
- package/dist/field/features/Blocks/component/index.d.ts.map +1 -1
- package/dist/field/features/Blocks/component/index.js +6 -3
- package/dist/field/features/Blocks/component/index.scss +5 -0
- package/dist/field/features/Blocks/drawer/index.d.ts.map +1 -1
- package/dist/field/features/Blocks/drawer/index.js +1 -3
- package/dist/field/features/Blocks/index.d.ts.map +1 -1
- package/dist/field/features/Blocks/index.js +6 -3
- package/dist/field/features/Blocks/nodes/BlocksNode.d.ts +2 -2
- package/dist/field/features/Blocks/nodes/BlocksNode.d.ts.map +1 -1
- package/dist/field/features/Blocks/nodes/BlocksNode.js +9 -2
- package/dist/field/features/Blocks/validate.d.ts +5 -0
- package/dist/field/features/Blocks/validate.d.ts.map +1 -0
- package/dist/field/features/Blocks/validate.js +53 -0
- package/dist/field/features/Link/afterReadPromise.d.ts.map +1 -1
- package/dist/field/features/Link/afterReadPromise.js +6 -5
- package/dist/field/features/Link/index.d.ts.map +1 -1
- package/dist/field/features/Link/index.js +1 -1
- package/dist/field/features/Link/nodes/LinkNode.d.ts +4 -2
- package/dist/field/features/Link/nodes/LinkNode.d.ts.map +1 -1
- package/dist/field/features/Link/nodes/LinkNode.js +1 -41
- package/dist/field/features/Link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/field/features/Link/plugins/floatingLinkEditor/LinkEditor/index.js +24 -6
- package/dist/field/features/Relationship/afterReadPromise.js +6 -6
- package/dist/field/features/Relationship/drawer/index.d.ts.map +1 -1
- package/dist/field/features/Relationship/drawer/index.js +9 -7
- package/dist/field/features/Relationship/index.d.ts.map +1 -1
- package/dist/field/features/Relationship/index.js +1 -1
- package/dist/field/features/Relationship/nodes/RelationshipNode.d.ts +12 -12
- package/dist/field/features/Relationship/nodes/RelationshipNode.d.ts.map +1 -1
- package/dist/field/features/Relationship/nodes/RelationshipNode.js +25 -20
- package/dist/field/features/Relationship/nodes/components/RelationshipComponent.d.ts +2 -2
- package/dist/field/features/Relationship/nodes/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/field/features/Relationship/nodes/components/RelationshipComponent.js +2 -2
- package/dist/field/features/Relationship/plugins/index.d.ts +2 -2
- package/dist/field/features/Relationship/plugins/index.d.ts.map +1 -1
- package/dist/field/features/Relationship/plugins/index.js +1 -1
- package/dist/field/features/Upload/afterReadPromise.d.ts.map +1 -1
- package/dist/field/features/Upload/afterReadPromise.js +10 -9
- package/dist/field/features/Upload/component/ExtraFieldsDrawer/index.d.ts.map +1 -1
- package/dist/field/features/Upload/component/ExtraFieldsDrawer/index.js +25 -8
- package/dist/field/features/Upload/component/index.d.ts +2 -2
- package/dist/field/features/Upload/component/index.d.ts.map +1 -1
- package/dist/field/features/Upload/component/index.js +2 -2
- package/dist/field/features/Upload/drawer/index.d.ts.map +1 -1
- package/dist/field/features/Upload/drawer/index.js +4 -2
- package/dist/field/features/Upload/index.d.ts.map +1 -1
- package/dist/field/features/Upload/index.js +6 -2
- package/dist/field/features/Upload/nodes/UploadNode.d.ts +15 -12
- package/dist/field/features/Upload/nodes/UploadNode.d.ts.map +1 -1
- package/dist/field/features/Upload/nodes/UploadNode.js +19 -14
- package/dist/field/features/Upload/plugin/index.d.ts.map +1 -1
- package/dist/field/features/Upload/plugin/index.js +3 -2
- package/dist/field/features/Upload/validate.d.ts +4 -0
- package/dist/field/features/Upload/validate.d.ts.map +1 -0
- package/dist/field/features/Upload/validate.js +29 -0
- package/dist/field/features/types.d.ts +17 -3
- package/dist/field/features/types.d.ts.map +1 -1
- package/dist/field/index.scss +38 -0
- package/dist/field/lexical/LexicalEditor.scss +28 -26
- package/dist/field/lexical/config/default.d.ts +4 -0
- package/dist/field/lexical/config/default.d.ts.map +1 -1
- package/dist/field/lexical/config/default.js +33 -25
- package/dist/field/lexical/config/sanitize.d.ts.map +1 -1
- package/dist/field/lexical/config/sanitize.js +6 -2
- package/dist/field/lexical/ui/ContentEditable.scss +5 -0
- package/dist/field/lexical/utils/cloneDeep.d.ts +1 -1
- package/dist/field/lexical/utils/cloneDeep.d.ts.map +1 -1
- package/dist/field/lexical/utils/cloneDeep.js +27 -9
- package/dist/index.d.ts +11 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +29 -4
- package/dist/populate/defaultValue.d.ts +17 -0
- package/dist/populate/defaultValue.d.ts.map +1 -1
- package/dist/populate/defaultValue.js +31 -4
- package/dist/populate/recurseNestedFields.d.ts +2 -1
- package/dist/populate/recurseNestedFields.d.ts.map +1 -1
- package/dist/populate/recurseNestedFields.js +28 -25
- package/dist/populate/richTextRelationshipPromise.d.ts +2 -1
- package/dist/populate/richTextRelationshipPromise.d.ts.map +1 -1
- package/dist/populate/richTextRelationshipPromise.js +8 -5
- package/dist/validate/index.d.ts +7 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +40 -0
- package/dist/validate/validateNodes.d.ts +14 -0
- package/dist/validate/validateNodes.d.ts.map +1 -0
- package/dist/validate/validateNodes.js +44 -0
- package/package.json +3 -2
- package/src/index.ts +46 -11
- package/dist/populate/validation.d.ts +0 -4
- package/dist/populate/validation.d.ts.map +0 -1
- package/dist/populate/validation.js +0 -21
package/src/index.ts
CHANGED
|
@@ -1,26 +1,51 @@
|
|
|
1
|
+
import type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor'
|
|
1
2
|
import type { RichTextAdapter } from 'payload/types'
|
|
2
3
|
|
|
3
4
|
import { withMergedProps } from 'payload/components/utilities'
|
|
4
5
|
|
|
6
|
+
import type { FeatureProvider } from './field/features/types'
|
|
5
7
|
import type { EditorConfig, SanitizedEditorConfig } from './field/lexical/config/types'
|
|
6
8
|
import type { AdapterProps } from './types'
|
|
7
9
|
|
|
8
10
|
import { RichTextCell } from './cell'
|
|
9
11
|
import { RichTextField } from './field'
|
|
10
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
defaultEditorFeatures,
|
|
14
|
+
defaultEditorLexicalConfig,
|
|
15
|
+
defaultSanitizedEditorConfig,
|
|
16
|
+
} from './field/lexical/config/default'
|
|
11
17
|
import { sanitizeEditorConfig } from './field/lexical/config/sanitize'
|
|
12
18
|
import { cloneDeep } from './field/lexical/utils/cloneDeep'
|
|
13
19
|
import { richTextRelationshipPromise } from './populate/richTextRelationshipPromise'
|
|
20
|
+
import { richTextValidateHOC } from './validate'
|
|
14
21
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
}: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
+
}
|
|
24
49
|
|
|
25
50
|
return {
|
|
26
51
|
CellComponent: withMergedProps({
|
|
@@ -56,6 +81,9 @@ export function lexicalEditor({
|
|
|
56
81
|
|
|
57
82
|
return null
|
|
58
83
|
},
|
|
84
|
+
validate: richTextValidateHOC({
|
|
85
|
+
editorConfig: finalSanitizedEditorConfig,
|
|
86
|
+
}),
|
|
59
87
|
}
|
|
60
88
|
}
|
|
61
89
|
|
|
@@ -84,9 +112,11 @@ export { CheckListFeature } from './field/features/lists/CheckList'
|
|
|
84
112
|
export { OrderedListFeature } from './field/features/lists/OrderedList'
|
|
85
113
|
export { UnoderedListFeature } from './field/features/lists/UnorderedList'
|
|
86
114
|
export type {
|
|
115
|
+
AfterReadPromise,
|
|
87
116
|
Feature,
|
|
88
117
|
FeatureProvider,
|
|
89
118
|
FeatureProviderMap,
|
|
119
|
+
NodeValidation,
|
|
90
120
|
ResolvedFeature,
|
|
91
121
|
ResolvedFeatureMap,
|
|
92
122
|
SanitizedFeatures,
|
|
@@ -96,7 +126,12 @@ export {
|
|
|
96
126
|
EditorConfigProvider,
|
|
97
127
|
useEditorConfigContext,
|
|
98
128
|
} from './field/lexical/config/EditorConfigProvider'
|
|
99
|
-
export {
|
|
129
|
+
export {
|
|
130
|
+
defaultEditorConfig,
|
|
131
|
+
defaultEditorFeatures,
|
|
132
|
+
defaultEditorLexicalConfig,
|
|
133
|
+
defaultSanitizedEditorConfig,
|
|
134
|
+
} from './field/lexical/config/default'
|
|
100
135
|
export { loadFeatures, sortFeaturesForOptimalLoading } from './field/lexical/config/loader'
|
|
101
136
|
export { sanitizeEditorConfig, sanitizeFeatures } from './field/lexical/config/sanitize'
|
|
102
137
|
// export SanitizedEditorConfig
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/populate/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAI5C,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAWpF,CAAA"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "richTextValidate", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return richTextValidate;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _defaultValue = require("./defaultValue");
|
|
12
|
-
const richTextValidate = (value, { required, t })=>{
|
|
13
|
-
if (required) {
|
|
14
|
-
const stringifiedDefaultValue = JSON.stringify(_defaultValue.defaultRichTextValue);
|
|
15
|
-
if (value && JSON.stringify(value) !== stringifiedDefaultValue) return true;
|
|
16
|
-
return t('validation:required');
|
|
17
|
-
}
|
|
18
|
-
return true;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wb3B1bGF0ZS92YWxpZGF0aW9uLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgUmljaFRleH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