@kids-reporter/cms-core 0.4.31 → 0.4.33
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.
|
@@ -15,7 +15,6 @@ const richTextEditor = ({
|
|
|
15
15
|
if (config.isIndexed === 'unique') {
|
|
16
16
|
throw Error("isIndexed: 'unique' is not a supported option for field type textEditor");
|
|
17
17
|
}
|
|
18
|
-
const resolve = val => val === null && meta.provider === 'postgresql' ? 'DbNull' : val;
|
|
19
18
|
return (0, _types.jsonFieldTypePolyfilledForSQLite)(meta.provider, {
|
|
20
19
|
...config,
|
|
21
20
|
input: {
|
|
@@ -24,14 +23,13 @@ const richTextEditor = ({
|
|
|
24
23
|
type: _core.graphql.JSON
|
|
25
24
|
}),
|
|
26
25
|
resolve(val) {
|
|
27
|
-
return
|
|
26
|
+
return val === undefined ? defaultValue : val;
|
|
28
27
|
}
|
|
29
28
|
},
|
|
30
29
|
update: {
|
|
31
30
|
arg: _core.graphql.arg({
|
|
32
31
|
type: _core.graphql.JSON
|
|
33
|
-
})
|
|
34
|
-
resolve
|
|
32
|
+
})
|
|
35
33
|
}
|
|
36
34
|
},
|
|
37
35
|
output: _core.graphql.field({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kids-reporter/cms-core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.33",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@keystone-ui/fields": "^7.2.0",
|
|
34
34
|
"@keystone-ui/modals": "^6.0.3",
|
|
35
35
|
"@twreporter/errors": "^1.1.1",
|
|
36
|
-
"@kids-reporter/draft-editor": "^0.4.
|
|
36
|
+
"@kids-reporter/draft-editor": "^0.4.32",
|
|
37
37
|
"axios": "^0.26.0",
|
|
38
38
|
"draft-convert": "^2.1.12",
|
|
39
39
|
"draft-js": "^0.11.7",
|
|
@@ -7,56 +7,52 @@ import {
|
|
|
7
7
|
} from '@keystone-6/core/types'
|
|
8
8
|
import { graphql } from '@keystone-6/core'
|
|
9
9
|
|
|
10
|
-
export type JsonFieldConfig<
|
|
11
|
-
ListTypeInfo
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
disabledButtons: string[]
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const richTextEditor = <ListTypeInfo extends BaseListTypeInfo>({
|
|
19
|
-
defaultValue = null,
|
|
20
|
-
disabledButtons = [],
|
|
21
|
-
...config
|
|
22
|
-
}: JsonFieldConfig<ListTypeInfo> = {}): FieldTypeFunc<ListTypeInfo> => (
|
|
23
|
-
meta
|
|
24
|
-
) => {
|
|
25
|
-
if ((config as any).isIndexed === 'unique') {
|
|
26
|
-
throw Error(
|
|
27
|
-
"isIndexed: 'unique' is not a supported option for field type textEditor"
|
|
28
|
-
)
|
|
10
|
+
export type JsonFieldConfig<ListTypeInfo extends BaseListTypeInfo> =
|
|
11
|
+
CommonFieldConfig<ListTypeInfo> & {
|
|
12
|
+
defaultValue?: JSONValue
|
|
13
|
+
db?: { map?: string }
|
|
14
|
+
disabledButtons: string[]
|
|
29
15
|
}
|
|
30
16
|
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
export const richTextEditor =
|
|
18
|
+
<ListTypeInfo extends BaseListTypeInfo>({
|
|
19
|
+
defaultValue = null,
|
|
20
|
+
disabledButtons = [],
|
|
21
|
+
...config
|
|
22
|
+
}: JsonFieldConfig<ListTypeInfo> = {}): FieldTypeFunc<ListTypeInfo> =>
|
|
23
|
+
(meta) => {
|
|
24
|
+
if ((config as any).isIndexed === 'unique') {
|
|
25
|
+
throw Error(
|
|
26
|
+
"isIndexed: 'unique' is not a supported option for field type textEditor"
|
|
27
|
+
)
|
|
28
|
+
}
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
30
|
+
return jsonFieldTypePolyfilledForSQLite(
|
|
31
|
+
meta.provider,
|
|
32
|
+
{
|
|
33
|
+
...config,
|
|
34
|
+
input: {
|
|
35
|
+
create: {
|
|
36
|
+
arg: graphql.arg({ type: graphql.JSON }),
|
|
37
|
+
resolve(val) {
|
|
38
|
+
return val === undefined ? defaultValue : val
|
|
39
|
+
},
|
|
43
40
|
},
|
|
41
|
+
update: { arg: graphql.arg({ type: graphql.JSON }) },
|
|
44
42
|
},
|
|
45
|
-
|
|
43
|
+
output: graphql.field({ type: graphql.JSON }),
|
|
44
|
+
views: `@kids-reporter/cms-core/lib/custom-fields/rich-text-editor/views/index`,
|
|
45
|
+
getAdminMeta: () => ({ defaultValue, disabledButtons }),
|
|
46
46
|
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
map: config.db?.map,
|
|
60
|
-
}
|
|
61
|
-
)
|
|
62
|
-
}
|
|
47
|
+
{
|
|
48
|
+
default:
|
|
49
|
+
defaultValue === null
|
|
50
|
+
? undefined
|
|
51
|
+
: {
|
|
52
|
+
kind: 'literal',
|
|
53
|
+
value: JSON.stringify(defaultValue),
|
|
54
|
+
},
|
|
55
|
+
map: config.db?.map,
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
}
|