export class Step {
  constructor(name, from, to, pos, param = null) {
    this.name = name
    this.from = from
    this.to = to
    this.pos = pos
    this.param = param
  }
}

const steps = Object.create(null)

export function defineStep(name, impl) { steps[name] = impl }

export function applyStep(doc, step) {
  if (!(step.name in steps))
    throw new Error("Undefined transform " + step.name)

  return steps[step.name].apply(doc, step)
}

export function invertStep(step, oldDoc, map) {
  return steps[step.name].invert(step, oldDoc, map)
}


@@ -1,12 +1,48 @@
+import %7BPos, Node%7D from %22../model%22%0A%0A
 export class
@@ -204,16 +204,985 @@
 aram%0A  %7D
+%0A%0A  toJSON() %7B%0A    return %7B%0A      name: this.name,%0A      from: this.from,%0A      to: this.to,%0A      pos: this.pos,%0A      param: objectToJSON(this.param)%0A    %7D%0A  %7D%0A%0A  static fromJSON(json) %7B%0A    return new Step(%0A      json.name,%0A      json.from && Pos.fromJSON(json.from),%0A      json.to && Pos.fromJSON(json.to),%0A      json.pos && Pos.fromJSON(json.pos),%0A      objectFromJSON(json.param))%0A  %7D%0A%7D%0A%0Afunction objectToJSON(obj) %7B%0A  if (!obj %7C%7C typeof obj != %22object%22) return obj%0A  if (Array.isArray(obj)) return obj.map(objectToJSON)%0A  if (obj.toJSON) return obj.toJSON()%0A  let result = %7B%7D%0A  for (let prop in obj) result%5Bprop%5D = objectToJSON(obj%5Bprop%5D)%0A  return result%0A%7D%0A%0Afunction objectFromJSON(json) %7B%0A  if (!json %7C%7C typeof json != %22object%22) return json%0A  if (Array.isArray(json)) return json.map(objectFromJSON)%0A  if (json.attrs && json.content) return Node.fromJSON(json)%0A  let result = %7B%7D%0A  for (let prop in json) result%5Bprop%5D = objectFromJSON(json%5Bprop%5D)%0A  return result
 %0A%7D%0A%0Acons

Move Step jsonification into Step class, collab code into index.js file