@contentful/field-editor-json 3.3.3 → 3.3.4
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/cjs/JsonEditor.js +1 -0
- package/dist/cjs/JsonEditorField.js +4 -1
- package/dist/cjs/utils.js +5 -1
- package/dist/esm/JsonEditor.js +2 -1
- package/dist/esm/JsonEditorField.js +4 -1
- package/dist/esm/utils.js +2 -1
- package/dist/types/JsonEditor.d.ts +5 -1
- package/dist/types/utils.d.ts +1 -0
- package/package.json +2 -2
package/dist/cjs/JsonEditor.js
CHANGED
|
@@ -10,10 +10,12 @@ Object.defineProperty(exports, "JsonEditorField", {
|
|
|
10
10
|
});
|
|
11
11
|
const _react = _interop_require_wildcard(require("react"));
|
|
12
12
|
const _langjson = require("@codemirror/lang-json");
|
|
13
|
+
const _language = require("@codemirror/language");
|
|
13
14
|
const _view = require("@codemirror/view");
|
|
14
15
|
const _f36tokens = _interop_require_default(require("@contentful/f36-tokens"));
|
|
15
16
|
const _reactcodemirror = _interop_require_default(require("@uiw/react-codemirror"));
|
|
16
17
|
const _emotion = require("emotion");
|
|
18
|
+
const _utils = require("./utils");
|
|
17
19
|
function _interop_require_default(obj) {
|
|
18
20
|
return obj && obj.__esModule ? obj : {
|
|
19
21
|
default: obj
|
|
@@ -108,7 +110,8 @@ function JsonEditorField(props) {
|
|
|
108
110
|
theme: "light",
|
|
109
111
|
extensions: [
|
|
110
112
|
(0, _langjson.json)(),
|
|
111
|
-
_view.EditorView.lineWrapping
|
|
113
|
+
_view.EditorView.lineWrapping,
|
|
114
|
+
_language.indentUnit.of(new Array(_utils.SPACE_INDENT_COUNT).fill(' ').join(''))
|
|
112
115
|
],
|
|
113
116
|
basicSetup: {
|
|
114
117
|
closeBrackets: false,
|
package/dist/cjs/utils.js
CHANGED
|
@@ -9,6 +9,9 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
+
SPACE_INDENT_COUNT: function() {
|
|
13
|
+
return SPACE_INDENT_COUNT;
|
|
14
|
+
},
|
|
12
15
|
stringifyJSON: function() {
|
|
13
16
|
return stringifyJSON;
|
|
14
17
|
},
|
|
@@ -19,11 +22,12 @@ _export(exports, {
|
|
|
19
22
|
return parseJSON;
|
|
20
23
|
}
|
|
21
24
|
});
|
|
25
|
+
const SPACE_INDENT_COUNT = 4;
|
|
22
26
|
function stringifyJSON(obj) {
|
|
23
27
|
if (obj === null || obj === undefined) {
|
|
24
28
|
return '';
|
|
25
29
|
} else {
|
|
26
|
-
return JSON.stringify(obj, null,
|
|
30
|
+
return JSON.stringify(obj, null, SPACE_INDENT_COUNT);
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
function isValidJson(str) {
|
package/dist/esm/JsonEditor.js
CHANGED
|
@@ -18,7 +18,7 @@ import throttle from 'lodash/throttle';
|
|
|
18
18
|
import { JsonEditorField } from './JsonEditorField';
|
|
19
19
|
import { JsonEditorToolbar } from './JsonEditorToolbar';
|
|
20
20
|
import { JsonInvalidStatus } from './JsonInvalidStatus';
|
|
21
|
-
import { stringifyJSON, parseJSON } from './utils';
|
|
21
|
+
import { stringifyJSON, parseJSON, SPACE_INDENT_COUNT } from './utils';
|
|
22
22
|
var _React_Component;
|
|
23
23
|
class ConnectedJsonEditor extends (_React_Component = React.Component) {
|
|
24
24
|
render() {
|
|
@@ -138,3 +138,4 @@ export default function JsonEditor(props) {
|
|
|
138
138
|
});
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
|
+
JsonEditor.tabWidth = SPACE_INDENT_COUNT;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { json } from '@codemirror/lang-json';
|
|
3
|
+
import { indentUnit } from '@codemirror/language';
|
|
3
4
|
import { EditorView } from '@codemirror/view';
|
|
4
5
|
import tokens from '@contentful/f36-tokens';
|
|
5
6
|
import CodeMirror from '@uiw/react-codemirror';
|
|
6
7
|
import { css, cx } from 'emotion';
|
|
8
|
+
import { SPACE_INDENT_COUNT } from './utils';
|
|
7
9
|
const styles = {
|
|
8
10
|
root: css({
|
|
9
11
|
cursor: 'text',
|
|
@@ -54,7 +56,8 @@ export function JsonEditorField(props) {
|
|
|
54
56
|
theme: "light",
|
|
55
57
|
extensions: [
|
|
56
58
|
json(),
|
|
57
|
-
EditorView.lineWrapping
|
|
59
|
+
EditorView.lineWrapping,
|
|
60
|
+
indentUnit.of(new Array(SPACE_INDENT_COUNT).fill(' ').join(''))
|
|
58
61
|
],
|
|
59
62
|
basicSetup: {
|
|
60
63
|
closeBrackets: false,
|
package/dist/esm/utils.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
export const SPACE_INDENT_COUNT = 4;
|
|
1
2
|
export function stringifyJSON(obj) {
|
|
2
3
|
if (obj === null || obj === undefined) {
|
|
3
4
|
return '';
|
|
4
5
|
} else {
|
|
5
|
-
return JSON.stringify(obj, null,
|
|
6
|
+
return JSON.stringify(obj, null, SPACE_INDENT_COUNT);
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
9
|
export function isValidJson(str) {
|
|
@@ -10,4 +10,8 @@ export interface JsonEditorProps {
|
|
|
10
10
|
*/
|
|
11
11
|
field: FieldAPI;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
declare function JsonEditor(props: JsonEditorProps): React.JSX.Element;
|
|
14
|
+
declare namespace JsonEditor {
|
|
15
|
+
var tabWidth: number;
|
|
16
|
+
}
|
|
17
|
+
export default JsonEditor;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { JSONObject } from './types';
|
|
2
|
+
export declare const SPACE_INDENT_COUNT = 4;
|
|
2
3
|
export declare function stringifyJSON(obj: JSONObject | null | undefined): string;
|
|
3
4
|
export declare function isValidJson(str: string): boolean;
|
|
4
5
|
export declare function parseJSON(str: string): {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/field-editor-json",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.4",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react": ">=16.8.0"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "622776505aed412439b203b0ebd17aa195e297ca"
|
|
54
54
|
}
|