@payloadcms/richtext-slate 3.0.0-beta.11 → 3.0.0-beta.12
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/data/validation.js +3 -3
- package/dist/data/validation.js.map +1 -1
- package/package.json +7 -7
- package/src/index.tsx +0 -82
package/dist/data/validation.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { defaultRichTextValue } from './defaultValue.js';
|
|
2
|
-
export const richTextValidate = (value, { required })=>{
|
|
2
|
+
export const richTextValidate = (value, { req, required })=>{
|
|
3
|
+
const { t } = req;
|
|
3
4
|
if (required) {
|
|
4
5
|
const stringifiedDefaultValue = JSON.stringify(defaultRichTextValue);
|
|
5
6
|
if (value && JSON.stringify(value) !== stringifiedDefaultValue) return true;
|
|
6
|
-
|
|
7
|
-
return 'This field is required.';
|
|
7
|
+
return t('validation:required');
|
|
8
8
|
}
|
|
9
9
|
return true;
|
|
10
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/data/validation.ts"],"sourcesContent":["import type { RichTextField, Validate } from 'payload/types'\n\nimport type { AdapterArguments } from '../types.js'\n\nimport { defaultRichTextValue } from './defaultValue.js'\n\nexport const richTextValidate: Validate<\n unknown[],\n unknown,\n RichTextField<any[], AdapterArguments>,\n RichTextField<any[], AdapterArguments>\n> = (value, { required }) => {\n if (required) {\n const stringifiedDefaultValue = JSON.stringify(defaultRichTextValue)\n if (value && JSON.stringify(value) !== stringifiedDefaultValue) return true\n
|
|
1
|
+
{"version":3,"sources":["../../src/data/validation.ts"],"sourcesContent":["import type { RichTextField, Validate } from 'payload/types'\n\nimport type { AdapterArguments } from '../types.js'\n\nimport { defaultRichTextValue } from './defaultValue.js'\n\nexport const richTextValidate: Validate<\n unknown[],\n unknown,\n RichTextField<any[], AdapterArguments>,\n RichTextField<any[], AdapterArguments>\n> = (value, { req, required }) => {\n const { t } = req\n if (required) {\n const stringifiedDefaultValue = JSON.stringify(defaultRichTextValue)\n if (value && JSON.stringify(value) !== stringifiedDefaultValue) return true\n return t('validation:required')\n }\n\n return true\n}\n"],"names":["defaultRichTextValue","richTextValidate","value","req","required","t","stringifiedDefaultValue","JSON","stringify"],"rangeMappings":";;;;;;;;;","mappings":"AAIA,SAASA,oBAAoB,QAAQ,oBAAmB;AAExD,OAAO,MAAMC,mBAKT,CAACC,OAAO,EAAEC,GAAG,EAAEC,QAAQ,EAAE;IAC3B,MAAM,EAAEC,CAAC,EAAE,GAAGF;IACd,IAAIC,UAAU;QACZ,MAAME,0BAA0BC,KAAKC,SAAS,CAACR;QAC/C,IAAIE,SAASK,KAAKC,SAAS,CAACN,WAAWI,yBAAyB,OAAO;QACvE,OAAOD,EAAE;IACX;IAEA,OAAO;AACT,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-slate",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.12",
|
|
4
4
|
"description": "The officially supported Slate richtext adapter for Payload",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "20.12.5",
|
|
27
27
|
"@types/react": "18.2.74",
|
|
28
|
-
"@payloadcms/ui": "3.0.0-beta.
|
|
29
|
-
"
|
|
30
|
-
"
|
|
28
|
+
"@payloadcms/ui": "3.0.0-beta.12",
|
|
29
|
+
"@payloadcms/eslint-config": "1.1.1",
|
|
30
|
+
"payload": "3.0.0-beta.12"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"@payloadcms/
|
|
33
|
+
"payload": "3.0.0-beta.12",
|
|
34
|
+
"@payloadcms/translations": "3.0.0-beta.12",
|
|
35
|
+
"@payloadcms/ui": "3.0.0-beta.12"
|
|
36
36
|
},
|
|
37
37
|
"exports": {
|
|
38
38
|
".": {
|
package/src/index.tsx
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { RichTextAdapter } from 'payload/types'
|
|
2
|
-
|
|
3
|
-
import { withNullableJSONSchemaType } from 'payload/utilities'
|
|
4
|
-
|
|
5
|
-
import type { AdapterArguments } from './types.js'
|
|
6
|
-
|
|
7
|
-
import { RichTextCell } from './cell/index.js'
|
|
8
|
-
import { richTextRelationshipPromise } from './data/richTextRelationshipPromise.js'
|
|
9
|
-
import { richTextValidate } from './data/validation.js'
|
|
10
|
-
import { RichTextField } from './field/index.js'
|
|
11
|
-
import { getGenerateComponentMap } from './generateComponentMap.js'
|
|
12
|
-
import { getGenerateSchemaMap } from './generateSchemaMap.js'
|
|
13
|
-
|
|
14
|
-
export function slateEditor(args: AdapterArguments): RichTextAdapter<any[], AdapterArguments, any> {
|
|
15
|
-
return {
|
|
16
|
-
CellComponent: RichTextCell,
|
|
17
|
-
FieldComponent: RichTextField,
|
|
18
|
-
generateComponentMap: getGenerateComponentMap(args),
|
|
19
|
-
generateSchemaMap: getGenerateSchemaMap(args),
|
|
20
|
-
outputSchema: ({ isRequired }) => {
|
|
21
|
-
return {
|
|
22
|
-
type: withNullableJSONSchemaType('array', isRequired),
|
|
23
|
-
items: {
|
|
24
|
-
type: 'object',
|
|
25
|
-
},
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
populationPromise({
|
|
29
|
-
context,
|
|
30
|
-
currentDepth,
|
|
31
|
-
depth,
|
|
32
|
-
field,
|
|
33
|
-
findMany,
|
|
34
|
-
flattenLocales,
|
|
35
|
-
overrideAccess,
|
|
36
|
-
populationPromises,
|
|
37
|
-
req,
|
|
38
|
-
showHiddenFields,
|
|
39
|
-
siblingDoc,
|
|
40
|
-
}) {
|
|
41
|
-
if (
|
|
42
|
-
field.admin?.elements?.includes('relationship') ||
|
|
43
|
-
field.admin?.elements?.includes('upload') ||
|
|
44
|
-
field.admin?.elements?.includes('link') ||
|
|
45
|
-
!field?.admin?.elements
|
|
46
|
-
) {
|
|
47
|
-
return richTextRelationshipPromise({
|
|
48
|
-
context,
|
|
49
|
-
currentDepth,
|
|
50
|
-
depth,
|
|
51
|
-
field,
|
|
52
|
-
findMany,
|
|
53
|
-
flattenLocales,
|
|
54
|
-
overrideAccess,
|
|
55
|
-
populationPromises,
|
|
56
|
-
req,
|
|
57
|
-
showHiddenFields,
|
|
58
|
-
siblingDoc,
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
return null
|
|
62
|
-
},
|
|
63
|
-
validate: richTextValidate,
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export { ElementButton } from './field/elements/Button.js'
|
|
68
|
-
|
|
69
|
-
export { toggleElement } from './field/elements/toggle.js'
|
|
70
|
-
export { LeafButton } from './field/leaves/Button.js'
|
|
71
|
-
export type {
|
|
72
|
-
AdapterArguments,
|
|
73
|
-
ElementNode,
|
|
74
|
-
FieldProps,
|
|
75
|
-
RichTextCustomElement,
|
|
76
|
-
RichTextCustomLeaf,
|
|
77
|
-
RichTextElement,
|
|
78
|
-
RichTextLeaf,
|
|
79
|
-
TextNode,
|
|
80
|
-
} from './types.js'
|
|
81
|
-
|
|
82
|
-
export { nodeIsTextNode } from './types.js'
|