@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 resolve(val === undefined ? defaultValue : val);
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.31",
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.31",
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 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
+ 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
- update: { arg: graphql.arg({ type: graphql.JSON }), resolve },
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
- 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
- }
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
+ }