prosemirror-transform
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -0,1 +1,7 @@ | ||
## 1.0.6 (2018-03-15) | ||
### Bug fixes | ||
Throw errors, rather than constructing invalid objects, when deserializing from invalid JSON data. | ||
## 1.0.5 (2018-03-14) | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "prosemirror-transform", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "ProseMirror document transformations", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -59,2 +59,4 @@ import {Fragment, Slice} from "prosemirror-model" | ||
static fromJSON(schema, json) { | ||
if (typeof json.from != "number" || typeof json.to != "number") | ||
throw new RangeError("Invalid input for AddMarkStep.fromJSON") | ||
return new AddMarkStep(json.from, json.to, schema.markFromJSON(json.mark)) | ||
@@ -108,2 +110,4 @@ } | ||
static fromJSON(schema, json) { | ||
if (typeof json.from != "number" || typeof json.to != "number") | ||
throw new RangeError("Invalid input for RemoveMarkStep.fromJSON") | ||
return new RemoveMarkStep(json.from, json.to, schema.markFromJSON(json.mark)) | ||
@@ -110,0 +114,0 @@ } |
@@ -68,2 +68,4 @@ import {Slice} from "prosemirror-model" | ||
static fromJSON(schema, json) { | ||
if (typeof json.from != "number" || typeof json.to != "number") | ||
throw new RangeError("Invalid input for ReplaceStep.fromJSON") | ||
return new ReplaceStep(json.from, json.to, Slice.fromJSON(schema, json.slice), !!json.structure) | ||
@@ -137,2 +139,5 @@ } | ||
static fromJSON(schema, json) { | ||
if (typeof json.from != "number" || typeof json.to != "number" || | ||
typeof json.gapFrom != "number" || typeof json.gapTo != "number" || typeof json.insert != "number") | ||
throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON") | ||
return new ReplaceAroundStep(json.from, json.to, json.gapFrom, json.gapTo, | ||
@@ -139,0 +144,0 @@ Slice.fromJSON(schema, json.slice), json.insert, !!json.structure) |
@@ -60,3 +60,6 @@ import {ReplaceError} from "prosemirror-model" | ||
static fromJSON(schema, json) { | ||
return stepsByID[json.stepType].fromJSON(schema, json) | ||
if (!json || !json.stepType) throw new RangeError("Invalid input for Step.fromJSON") | ||
let type = stepsByID[json.stepType] | ||
if (!type) throw new RangeError(`No step type ${json.stepType} defined`) | ||
return type.fromJSON(schema, json) | ||
} | ||
@@ -63,0 +66,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
275883
2949