@kids-reporter/cms-core 0.4.30 → 0.4.32

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,7 @@ 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;
18
+ const resolve = val => val === undefined ? defaultValue : val;
19
19
  return (0, _types.jsonFieldTypePolyfilledForSQLite)(meta.provider, {
20
20
  ...config,
21
21
  input: {
@@ -24,7 +24,7 @@ const richTextEditor = ({
24
24
  type: _core.graphql.JSON
25
25
  }),
26
26
  resolve(val) {
27
- return resolve(val === undefined ? defaultValue : val);
27
+ return resolve(val);
28
28
  }
29
29
  },
30
30
  update: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kids-reporter/cms-core",
3
- "version": "0.4.30",
3
+ "version": "0.4.32",
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.30",
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,55 @@ import {
7
7
  } from '@keystone-6/core/types'
8
8
  import { graphql } from '@keystone-6/core'
9
9
 
10
- export type JsonFieldConfig<
11
- ListTypeInfo extends BaseListTypeInfo
12
- > = CommonFieldConfig<ListTypeInfo> & {
13
- defaultValue?: JSONValue
14
- db?: { map?: string }
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
- const resolve = (val: JSONValue | undefined) =>
32
- val === null && meta.provider === 'postgresql' ? 'DbNull' : val
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
- return jsonFieldTypePolyfilledForSQLite(
35
- meta.provider,
36
- {
37
- ...config,
38
- input: {
39
- create: {
40
- arg: graphql.arg({ type: graphql.JSON }),
41
- resolve(val) {
42
- return resolve(val === undefined ? defaultValue : val)
30
+ const resolve = (val: JSONValue | undefined) =>
31
+ val === undefined ? defaultValue : val
32
+
33
+ return jsonFieldTypePolyfilledForSQLite(
34
+ meta.provider,
35
+ {
36
+ ...config,
37
+ input: {
38
+ create: {
39
+ arg: graphql.arg({ type: graphql.JSON }),
40
+ resolve(val) {
41
+ return resolve(val)
42
+ },
43
43
  },
44
+ update: { arg: graphql.arg({ type: graphql.JSON }), resolve },
44
45
  },
45
- update: { arg: graphql.arg({ type: graphql.JSON }), resolve },
46
+ output: graphql.field({ type: graphql.JSON }),
47
+ views: `@kids-reporter/cms-core/lib/custom-fields/rich-text-editor/views/index`,
48
+ getAdminMeta: () => ({ defaultValue, disabledButtons }),
46
49
  },
47
- output: graphql.field({ type: graphql.JSON }),
48
- views: `@kids-reporter/cms-core/lib/custom-fields/rich-text-editor/views/index`,
49
- getAdminMeta: () => ({ defaultValue, disabledButtons }),
50
- },
51
- {
52
- default:
53
- defaultValue === null
54
- ? undefined
55
- : {
56
- kind: 'literal',
57
- value: JSON.stringify(defaultValue),
58
- },
59
- map: config.db?.map,
60
- }
61
- )
62
- }
50
+ {
51
+ default:
52
+ defaultValue === null
53
+ ? undefined
54
+ : {
55
+ kind: 'literal',
56
+ value: JSON.stringify(defaultValue),
57
+ },
58
+ map: config.db?.map,
59
+ }
60
+ )
61
+ }