mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 21:21:21 +02:00
@@ -179,16 +179,15 @@ class Block extends Record(DEFAULTS) {
|
|||||||
|
|
||||||
toJSON(options = {}) {
|
toJSON(options = {}) {
|
||||||
const object = {
|
const object = {
|
||||||
data: this.data.toJSON(),
|
|
||||||
key: this.key,
|
|
||||||
kind: this.kind,
|
kind: this.kind,
|
||||||
isVoid: this.isVoid,
|
|
||||||
type: this.type,
|
type: this.type,
|
||||||
|
isVoid: this.isVoid,
|
||||||
|
data: this.data.toJSON(),
|
||||||
nodes: this.nodes.toArray().map(n => n.toJSON(options)),
|
nodes: this.nodes.toArray().map(n => n.toJSON(options)),
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.preserveKeys) {
|
if (options.preserveKeys) {
|
||||||
delete object.key
|
object.key = this.key
|
||||||
}
|
}
|
||||||
|
|
||||||
return object
|
return object
|
||||||
|
@@ -148,8 +148,8 @@ class Character extends Record(DEFAULTS) {
|
|||||||
toJSON() {
|
toJSON() {
|
||||||
const object = {
|
const object = {
|
||||||
kind: this.kind,
|
kind: this.kind,
|
||||||
marks: this.marks.toArray().map(m => m.toJSON()),
|
|
||||||
text: this.text,
|
text: this.text,
|
||||||
|
marks: this.marks.toArray().map(m => m.toJSON()),
|
||||||
}
|
}
|
||||||
|
|
||||||
return object
|
return object
|
||||||
|
@@ -143,14 +143,13 @@ class Document extends Record(DEFAULTS) {
|
|||||||
|
|
||||||
toJSON(options = {}) {
|
toJSON(options = {}) {
|
||||||
const object = {
|
const object = {
|
||||||
data: this.data.toJSON(),
|
|
||||||
key: this.key,
|
|
||||||
kind: this.kind,
|
kind: this.kind,
|
||||||
|
data: this.data.toJSON(),
|
||||||
nodes: this.nodes.toArray().map(n => n.toJSON(options)),
|
nodes: this.nodes.toArray().map(n => n.toJSON(options)),
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.preserveKeys) {
|
if (options.preserveKeys) {
|
||||||
delete object.key
|
object.key = this.key
|
||||||
}
|
}
|
||||||
|
|
||||||
return object
|
return object
|
||||||
|
@@ -179,16 +179,15 @@ class Inline extends Record(DEFAULTS) {
|
|||||||
|
|
||||||
toJSON(options = {}) {
|
toJSON(options = {}) {
|
||||||
const object = {
|
const object = {
|
||||||
data: this.data.toJSON(),
|
|
||||||
key: this.key,
|
|
||||||
kind: this.kind,
|
kind: this.kind,
|
||||||
isVoid: this.isVoid,
|
|
||||||
type: this.type,
|
type: this.type,
|
||||||
|
isVoid: this.isVoid,
|
||||||
|
data: this.data.toJSON(),
|
||||||
nodes: this.nodes.toArray().map(n => n.toJSON(options)),
|
nodes: this.nodes.toArray().map(n => n.toJSON(options)),
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.preserveKeys) {
|
if (options.preserveKeys) {
|
||||||
delete object.key
|
object.key = this.key
|
||||||
}
|
}
|
||||||
|
|
||||||
return object
|
return object
|
||||||
|
@@ -152,8 +152,8 @@ class Leaf extends Record(DEFAULTS) {
|
|||||||
toJSON() {
|
toJSON() {
|
||||||
const object = {
|
const object = {
|
||||||
kind: this.kind,
|
kind: this.kind,
|
||||||
marks: this.marks.toArray().map(m => m.toJSON()),
|
|
||||||
text: this.text,
|
text: this.text,
|
||||||
|
marks: this.marks.toArray().map(m => m.toJSON()),
|
||||||
}
|
}
|
||||||
|
|
||||||
return object
|
return object
|
||||||
|
@@ -177,9 +177,9 @@ class Mark extends Record(DEFAULTS) {
|
|||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
const object = {
|
const object = {
|
||||||
data: this.data.toJSON(),
|
|
||||||
kind: this.kind,
|
kind: this.kind,
|
||||||
type: this.type,
|
type: this.type,
|
||||||
|
data: this.data.toJSON(),
|
||||||
}
|
}
|
||||||
|
|
||||||
return object
|
return object
|
||||||
|
@@ -740,13 +740,13 @@ class Range extends Record(DEFAULTS) {
|
|||||||
|
|
||||||
toJSON() {
|
toJSON() {
|
||||||
const object = {
|
const object = {
|
||||||
|
kind: this.kind,
|
||||||
anchorKey: this.anchorKey,
|
anchorKey: this.anchorKey,
|
||||||
anchorOffset: this.anchorOffset,
|
anchorOffset: this.anchorOffset,
|
||||||
focusKey: this.focusKey,
|
focusKey: this.focusKey,
|
||||||
focusOffset: this.focusOffset,
|
focusOffset: this.focusOffset,
|
||||||
isBackward: this.isBackward,
|
isBackward: this.isBackward,
|
||||||
isFocused: this.isFocused,
|
isFocused: this.isFocused,
|
||||||
kind: this.kind,
|
|
||||||
marks: this.marks == null ? null : this.marks.toArray().map(m => m.toJSON()),
|
marks: this.marks == null ? null : this.marks.toArray().map(m => m.toJSON()),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -641,12 +641,7 @@ class State extends Record(DEFAULTS) {
|
|||||||
toJSON(options = {}) {
|
toJSON(options = {}) {
|
||||||
const object = {
|
const object = {
|
||||||
kind: this.kind,
|
kind: this.kind,
|
||||||
data: this.data.toJSON(),
|
|
||||||
decorations: this.decorations ? this.decorations.toArray().map(d => d.toJSON()) : null,
|
|
||||||
document: this.document.toJSON(options),
|
document: this.document.toJSON(options),
|
||||||
history: this.history.toJSON(),
|
|
||||||
selection: this.selection.toJSON(),
|
|
||||||
schema: this.schema.toJSON(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('preserveStateData' in options) {
|
if ('preserveStateData' in options) {
|
||||||
@@ -654,24 +649,24 @@ class State extends Record(DEFAULTS) {
|
|||||||
options.preserveData = options.preserveStateData
|
options.preserveData = options.preserveStateData
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.preserveData) {
|
if (options.preserveData) {
|
||||||
delete object.data
|
object.data = this.data.toJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.preserveDecorations) {
|
if (options.preserveDecorations) {
|
||||||
delete object.decorations
|
object.decorations = this.decorations ? this.decorations.toArray().map(d => d.toJSON()) : null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.preserveHistory) {
|
if (options.preserveHistory) {
|
||||||
delete object.history
|
object.history = this.history.toJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.preserveSelection) {
|
if (options.preserveSelection) {
|
||||||
delete object.selection
|
object.selection = this.selection.toJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.preserveSchema) {
|
if (options.preserveSchema) {
|
||||||
delete object.schema
|
object.schema = this.schema.toJSON()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.preserveSelection && !options.preserveKeys) {
|
if (options.preserveSelection && !options.preserveKeys) {
|
||||||
|
@@ -459,13 +459,12 @@ class Text extends Record(DEFAULTS) {
|
|||||||
|
|
||||||
toJSON(options = {}) {
|
toJSON(options = {}) {
|
||||||
const object = {
|
const object = {
|
||||||
key: this.key,
|
|
||||||
kind: this.kind,
|
kind: this.kind,
|
||||||
leaves: this.getLeaves().toArray().map(r => r.toJSON()),
|
leaves: this.getLeaves().toArray().map(r => r.toJSON()),
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.preserveKeys) {
|
if (options.preserveKeys) {
|
||||||
delete object.key
|
object.key = this.key
|
||||||
}
|
}
|
||||||
|
|
||||||
return object
|
return object
|
||||||
|
Reference in New Issue
Block a user