@pareto-engineering/design-system 5.1.1 → 5.1.2

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.
@@ -77,7 +77,12 @@ const EditorInput = _ref2 => {
77
77
  } = (0, _formik.useFormikContext)();
78
78
  const setInitialValue = () => {
79
79
  try {
80
- JSON.parse(field.value);
80
+ const parsedValue = JSON.parse(field.value);
81
+ // A pure number value will break the editor, so we throw an error to return
82
+ // the default value in the catch block.
83
+ if (typeof parsedValue === 'number') {
84
+ throw new Error('Number');
85
+ }
81
86
  return field.value;
82
87
  } catch {
83
88
  const defaultValue = {
@@ -88,7 +93,7 @@ const EditorInput = _ref2 => {
88
93
  format: 0,
89
94
  mode: 'normal',
90
95
  style: '',
91
- text: '',
96
+ text: field.value,
92
97
  type: 'text',
93
98
  version: 1
94
99
  }],
@@ -105,7 +110,6 @@ const EditorInput = _ref2 => {
105
110
  version: 1
106
111
  }
107
112
  };
108
- defaultValue.root.children[0].children[0].text = field.value;
109
113
  return JSON.stringify(defaultValue);
110
114
  }
111
115
  };
@@ -66,7 +66,12 @@ const EditorInput = ({
66
66
  } = useFormikContext();
67
67
  const setInitialValue = () => {
68
68
  try {
69
- JSON.parse(field.value);
69
+ const parsedValue = JSON.parse(field.value);
70
+ // A pure number value will break the editor, so we throw an error to return
71
+ // the default value in the catch block.
72
+ if (typeof parsedValue === 'number') {
73
+ throw new Error('Number');
74
+ }
70
75
  return field.value;
71
76
  } catch {
72
77
  const defaultValue = {
@@ -77,7 +82,7 @@ const EditorInput = ({
77
82
  format: 0,
78
83
  mode: 'normal',
79
84
  style: '',
80
- text: '',
85
+ text: field.value,
81
86
  type: 'text',
82
87
  version: 1
83
88
  }],
@@ -94,7 +99,6 @@ const EditorInput = ({
94
99
  version: 1
95
100
  }
96
101
  };
97
- defaultValue.root.children[0].children[0].text = field.value;
98
102
  return JSON.stringify(defaultValue);
99
103
  }
100
104
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pareto-engineering/design-system",
3
- "version": "5.1.1",
3
+ "version": "5.1.2",
4
4
  "description": "",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",
@@ -87,5 +87,5 @@
87
87
  "remark-math": "^6.0.0"
88
88
  },
89
89
  "browserslist": "> 2%",
90
- "gitHead": "9af8ec028d247f108df8577a080c663edadc205b"
90
+ "gitHead": "4a9a1e6c37055bd9aba28e04c9d5a4dcc7dd7d93"
91
91
  }
@@ -73,7 +73,12 @@ const EditorInput = ({
73
73
 
74
74
  const setInitialValue = () => {
75
75
  try {
76
- JSON.parse(field.value)
76
+ const parsedValue = JSON.parse(field.value)
77
+ // A pure number value will break the editor, so we throw an error to return
78
+ // the default value in the catch block.
79
+ if (typeof parsedValue === 'number') {
80
+ throw new Error('Number')
81
+ }
77
82
  return field.value
78
83
  } catch {
79
84
  const defaultValue = {
@@ -86,7 +91,7 @@ const EditorInput = ({
86
91
  format :0,
87
92
  mode :'normal',
88
93
  style :'',
89
- text :'',
94
+ text :field.value,
90
95
  type :'text',
91
96
  version:1,
92
97
  },
@@ -105,7 +110,6 @@ const EditorInput = ({
105
110
  version :1,
106
111
  },
107
112
  }
108
- defaultValue.root.children[0].children[0].text = field.value
109
113
  return JSON.stringify(defaultValue)
110
114
  }
111
115
  }