You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: change the type of json from JSONValue to unknown (#371)
BREAKING CHANGE:
The type `Content` is changed from `{ json: JSONValue} | { text: string }` into
`{ json: unknown } | { text: string }`, and all other types having `JSONValue` changed
to `unknown`. The return type of `JSONParser.stringify` changed from `string` to
`string | undefined`.
@@ -225,7 +225,7 @@ const editor = new JSONEditor({
225
225
-`escapeControlCharacters: boolean`. False by default. When `true`, control characters like newline and tab are rendered as escaped characters `\n` and `\t`. Only applicable for `'tree'` mode, in `'text'` mode control characters are always escaped.
226
226
-`escapeUnicodeCharacters: boolean`. False by default. When `true`, unicode characters like ☎ and 😀 are rendered escaped like `\u260e` and `\ud83d\ude00`.
227
227
-`flattenColumns: boolean`. True by default. Only applicable to `'table'` mode. When `true`, nested object properties will be displayed each in their own column, with the nested path as column name. When `false`, nested objects will be rendered inline, and double-clicking them will open them in a popup.
228
-
-`validator: function (json: JSONValue): ValidationError[]`. Validate the JSON document.
228
+
-`validator: function (json: unknown): ValidationError[]`. Validate the JSON document.
229
229
For example use the built-in JSON Schema validator powered by Ajv:
230
230
231
231
```js
@@ -438,7 +438,7 @@ Note that most methods are asynchronous and will resolve after the editor is re-
438
438
-`editor.expand(path => true)` expand all
439
439
-`editor.expand(path => false)` collapse all
440
440
-`editor.expand(path => path.length < 2)` expand all paths up to 2 levels deep
441
-
-`transform({ id?: string, rootPath?: [], onTransform: ({ operations: JSONPatchDocument, json: JSONValue, transformedJson: JSONValue }) => void, onClose: () => void })` programmatically trigger clicking of the transform button in the main menu, opening the transform model. If a callback `onTransform` is provided, it will replace the build-in logic to apply a transform, allowing you to process the transform operations in an alternative way. If provided, `onClose` callback will trigger when the transform modal closes, both after the user clicked apply or cancel. If an `id` is provided, the transform modal will load the previous status of this `id` instead of the status of the editors transform modal.
441
+
-`transform({ id?: string, rootPath?: [], onTransform: ({ operations: JSONPatchDocument, json: unknown, transformedJson: unknown }) => void, onClose: () => void })` programmatically trigger clicking of the transform button in the main menu, opening the transform model. If a callback `onTransform` is provided, it will replace the build-in logic to apply a transform, allowing you to process the transform operations in an alternative way. If provided, `onClose` callback will trigger when the transform modal closes, both after the user clicked apply or cancel. If an `id` is provided, the transform modal will load the previous status of this `id` instead of the status of the editors transform modal.
442
442
-`scrollTo(path: Path): Promise<void>` Scroll the editor vertically such that the specified path comes into view. Only applicable to modes `tree` and `table`. The path will be expanded when needed. The returned Promise is resolved after scrolling is finished.
443
443
-`findElement(path: Path)` Find the DOM element of a given path. Returns `null` when not found.
444
444
-`acceptAutoRepair(): Promise<Content>` In tree mode, invalid JSON is automatically repaired when loaded. When the repair was successful, the repaired contents are rendered but not yet applied to the document itself until the user clicks "Ok" or starts editing the data. Instead of accepting the repair, the user can also click "Repair manually instead". Invoking `.acceptAutoRepair()` will programmatically accept the repair. This will trigger an update, and the method itself also returns the updated contents. In case of `text` mode or when the editor is not in an "accept auto repair" status, nothing will happen, and the contents will be returned as is.
0 commit comments