Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prosemirror-model

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-model - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## 1.2.2 (2018-03-15)
### Bug fixes
Throw errors, rather than constructing invalid objects, when deserializing from invalid JSON data.
## 1.2.1 (2018-03-15)

@@ -2,0 +8,0 @@

2

package.json
{
"name": "prosemirror-model",
"version": "1.2.1",
"version": "1.2.2",
"description": "ProseMirror's document model",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -227,3 +227,5 @@ import {findDiffStart, findDiffEnd} from "./diff"

static fromJSON(schema, value) {
return value ? new Fragment(value.map(schema.nodeFromJSON)) : Fragment.empty
if (!value) return Fragment.empty
if (!Array.isArray(value)) throw new RangeError("Invalid input for Fragment.fromJSON")
return new Fragment(value.map(schema.nodeFromJSON))
}

@@ -230,0 +232,0 @@

@@ -87,2 +87,3 @@ import {compareDeep} from "./comparedeep"

static fromJSON(schema, json) {
if (!json) throw new RangeError("Invalid input for Mark.fromJSON")
let type = schema.marks[json.type]

@@ -89,0 +90,0 @@ if (!type) throw new RangeError(`There is no mark type ${json.type} in this schema`)

@@ -352,7 +352,14 @@ import {Fragment} from "./fragment"

static fromJSON(schema, json) {
let marks = json.marks && json.marks.map(schema.markFromJSON)
if (json.type == "text") return schema.text(json.text, marks)
let type = schema.nodeType(json.type)
if (!type) throw new RangeError(`There is no node type ${json.type} in this schema`)
return type.create(json.attrs, Fragment.fromJSON(schema, json.content), marks)
if (!json) throw new RangeError("Invalid input for Node.fromJSON")
let marks = null
if (json.marks) {
if (!Array.isArray(json.marks)) throw new RangeError("Invalid mark data for Node.fromJSON")
marks = json.marks.map(schema.markFromJSON)
}
if (json.type == "text") {
if (typeof json.text != "string") throw new RangeError("Invalid text node in JSON")
return schema.text(json.text, marks)
}
let content = Fragment.fromJSON(schema, json.content)
return schema.nodeType(json.type).create(json.attrs, content, marks)
}

@@ -359,0 +366,0 @@ }

@@ -79,2 +79,5 @@ import {Fragment} from "./fragment"

if (!json) return Slice.empty
let openStart = json.openStart || 0, openEnd = json.openEnd || 0
if (typeof openStart != "number" || typeof openEnd != "number")
throw new RangeError("Invalid input for Slice.fromJSON")
return new Slice(Fragment.fromJSON(schema, json.content), json.openStart || 0, json.openEnd || 0)

@@ -81,0 +84,0 @@ }

@@ -128,3 +128,2 @@ import OrderedMap from "orderedmap"

create(attrs, content, marks) {
if (typeof content == "string") throw new Error("Calling create with string")
if (this.isText) throw new Error("NodeType.create can't construct text nodes")

@@ -131,0 +130,0 @@ return new Node(this, this.computeAttrs(attrs), Fragment.from(content), Mark.setFrom(marks))

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc