API Reference
@univerjs
@univerjs/core
namespaces
JSON1
type-aliases
Jsonop

@univerjs/core v0.1.17Docs


Type Alias: JSONOp

type JSONOp: null | JSONOpList;

A JSON operation.

There's some aspects of valid operations which aren't captured by the type:

  • The last element of any list must be an object (the op component)
  • Except at the root, every inner list must have a length at least 2, and the first element must be a number or string.
  • Operation components cannot be empty
  • No two adjacent list elements can be operation components.
  • If a component has listy children (it descends), those descenders are sorted and come after any local op component. So, [, , <descent 1>, <descent 2>, ...]
  • Picks and drops must be matched, and use low numbers (0, 1, 2, ....)

noop is represented by 'null'.

Valid operations: null, [{i:5}], ['a', {i:5}], [['a', {p:0}], ['b', {d:0}]], [10, {i:5}, 'b', {r:true}]

Not valid: [], ['a', [{i:5}]], [[{i:5}]], [{}], ['a', {}], ['a', ['b', {i:5}], {r:true}]

Many 'invalid' operations can be cleaned up into their canonical form by the normalize() function.

If you want some examples, take a look at the test suite.

Defined in

submodules/univer/node_modules/.pnpm/ot-json1@1.0.2/node_modules/ot-json1/dist/types.d.ts:50


Copyright © 2021-2024 DreamNum Co,Ltd. All Rights Reserved.