Skip to content

Commit

Permalink
Fix EditorState.toJSON to not get confused by what JSON.stringify pas…
Browse files Browse the repository at this point in the history
…ses it
  • Loading branch information
marijnh committed Mar 12, 2021
1 parent cd87a82 commit 8911705
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,11 @@ export class EditorState {
doc: this.sliceDoc(),
selection: this.selection.toJSON()
}
if (fields) for (let prop in fields)
result[prop] = fields[prop].spec.toJSON!(this.field(fields[prop]), this)
if (fields) for (let prop in fields) {
let value = fields[prop]
if (value instanceof StateField)
result[prop] = value.spec.toJSON!(this.field(fields[prop]), this)
}
return result
}

Expand Down

0 comments on commit 8911705

Please sign in to comment.