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 0.19.0 to 0.20.0

10

dist/fragment.js

@@ -22,4 +22,8 @@ var ref = require("./diff");

// :: (number, number, (node: Node, start: number, parent: Node, index: number) → ?bool)
// Invoke a callback for all descendant nodes between the given two
// positions (relative to start of this fragment).
Fragment.prototype.nodesBetween = function (from, to, f, nodeStart, parent) {
var this$1 = this;
if ( nodeStart === void 0 ) nodeStart = 0;

@@ -38,2 +42,8 @@ for (var i = 0, pos = 0; pos < to; i++) {

// :: ((node: Node, pos: number, parent: Node))
// Call the given callback for every descendant node.
Fragment.prototype.descendants = function (f) {
this.nodesBetween(0, this.size, f)
};
// : (number, number, ?string, ?string) → string

@@ -40,0 +50,0 @@ Fragment.prototype.textBetween = function (from, to, blockSeparator, leafText) {

30

dist/from_dom.js

@@ -82,5 +82,8 @@ var ref = require("./fragment");

//
// preserveWhitespace:: ?bool
// preserveWhitespace:: ?union<bool, "full">
// Controls whether whitespace should be preserved when parsing the
// content inside the matched element.
// content inside the matched element. `false` means whitespace may
// be collapsed, `true` means that whitespace should be preserved
// but newlines normalized to spaces, and `"full"` means that
// newlines should also be preserved.

@@ -111,5 +114,6 @@ // ::- A DOM parser represents a strategy for parsing DOM content into

//
// preserveWhitespace:: ?bool
// preserveWhitespace:: ?union<bool, "full">
// By default, whitespace is collapsed as per HTML's rules. Pass
// true here to prevent the parser from doing that.
// `true` to preserve whitespace, but normalize newlines to
// spaces, and `"full"` to preserve whitespace entirely.
//

@@ -141,3 +145,3 @@ // findPositions:: ?[{node: dom.Node, offset: number}]

// context:: ?ResolvedPos
// A set of additional node names to cound as
// A set of additional node names to count as
// [context](#model.ParseRule.context) when parsing, above the

@@ -262,4 +266,8 @@ // given [top node](#model.DOMParser.parse^options.topNode).

// Using a bitfield for node context options
var OPT_PRESERVE_WS = 1, OPT_OPEN_LEFT = 2
var OPT_PRESERVE_WS = 1, OPT_PRESERVE_WS_FULL = 2, OPT_OPEN_LEFT = 4
function wsOptionsFor(preserveWhitespace) {
return (preserveWhitespace ? OPT_PRESERVE_WS : 0) | (preserveWhitespace === "full" ? OPT_PRESERVE_WS_FULL : 0)
}
var NodeContext = function(type, attrs, solid, match, options) {

@@ -312,3 +320,3 @@ this.type = type

var topNode = options.topNode, topContext
var topOptions = (options.preserveWhitespace ? OPT_PRESERVE_WS : 0) | (open ? OPT_OPEN_LEFT : 0)
var topOptions = wsOptionsFor(options.preserveWhitespace) | (open ? OPT_OPEN_LEFT : 0)
if (topNode)

@@ -370,2 +378,4 @@ { topContext = new NodeContext(topNode.type, topNode.attrs, true,

}
} else if (!(top.options & OPT_PRESERVE_WS_FULL)) {
value = value.replace(/\r?\n|\r/g, " ")
}

@@ -524,3 +534,3 @@ if (value) { this.insertNode(this.parser.schema.text(value, this.marks)) }

top.match = top.match && top.match.matchType(type, attrs)
var options = preserveWS == null ? top.options & OPT_PRESERVE_WS : preserveWS ? OPT_PRESERVE_WS : 0
var options = preserveWS == null ? top.options & ~OPT_OPEN_LEFT : wsOptionsFor(preserveWS)
if ((top.options & OPT_OPEN_LEFT) && top.content.length == 0) { options |= OPT_OPEN_LEFT }

@@ -586,3 +596,3 @@ this.nodes.push(new NodeContext(type, attrs, solid, null, options))

if (this.find) { for (var i = 0; i < this.find.length; i++) {
if (this$1.find[i].pos == null && parent.contains(this$1.find[i].node))
if (this$1.find[i].pos == null && parent.nodeType == 1 && parent.contains(this$1.find[i].node))
{ this$1.find[i].pos = this$1.currentPos }

@@ -596,3 +606,3 @@ } }

if (parent != content && this.find) { for (var i = 0; i < this.find.length; i++) {
if (this$1.find[i].pos == null && parent.contains(this$1.find[i].node)) {
if (this$1.find[i].pos == null && parent.nodeType == 1 && parent.contains(this$1.find[i].node)) {
var pos = content.compareDocumentPosition(this$1.find[i].node)

@@ -599,0 +609,0 @@ if (pos & (before ? 2 : 4))

exports.Node = require("./node").Node
;var assign;
((assign = require("./resolvedpos"), exports.ResolvedPos = assign.ResolvedPos, exports.NodeRange = assign.NodeRange))
((assign = require("./resolvedpos"), exports.ResolvedPos = assign.ResolvedPos, exports.NodeRange = assign.NodeRange, assign))
exports.Fragment = require("./fragment").Fragment
;var assign$1;
((assign$1 = require("./replace"), exports.Slice = assign$1.Slice, exports.ReplaceError = assign$1.ReplaceError))
((assign$1 = require("./replace"), exports.Slice = assign$1.Slice, exports.ReplaceError = assign$1.ReplaceError, assign$1))
exports.Mark = require("./mark").Mark
;var assign$2;
((assign$2 = require("./schema"), exports.Schema = assign$2.Schema, exports.NodeType = assign$2.NodeType, exports.MarkType = assign$2.MarkType))
((assign$2 = require("./schema"), exports.Schema = assign$2.Schema, exports.NodeType = assign$2.NodeType, exports.MarkType = assign$2.MarkType, assign$2))
;var assign$3;
((assign$3 = require("./content"), exports.ContentMatch = assign$3.ContentMatch))
((assign$3 = require("./content"), exports.ContentMatch = assign$3.ContentMatch, assign$3))
exports.DOMParser = require("./from_dom").DOMParser
exports.DOMSerializer = require("./to_dom").DOMSerializer

@@ -54,2 +54,4 @@ var ref = require("./fragment");

// :: (Slice) → bool
// Tests whether this slice is equal to another slice.
Slice.prototype.eq = function (other) {

@@ -56,0 +58,0 @@ return this.content.eq(other.content) && this.openLeft == other.openLeft && this.openRight == other.openRight

@@ -187,2 +187,14 @@ var ref = require("./mark");

// :: (ResolvedPos) → ResolvedPos
// Return the greater of this and the given position.
ResolvedPos.prototype.max = function (other) {
return other.pos > this.pos ? other : this
};
// :: (ResolvedPos) → ResolvedPos
// Return the smaller of this and the given position.
ResolvedPos.prototype.min = function (other) {
return other.pos < this.pos ? other : this
};
ResolvedPos.prototype.toString = function () {

@@ -189,0 +201,0 @@ var this$1 = this;

@@ -208,4 +208,2 @@ var OrderedMap = require("orderedmap")

var warnedAboutInclusive = false
// ::- Like nodes, marks (which are associated with nodes to signify

@@ -227,10 +225,2 @@ // things like emphasis or being part of a link) are tagged with type

if (spec.inclusiveRight === false && spec.inclusive == null) {
spec.inclusive = false
if (!warnedAboutInclusive && typeof console != "undefined" && console.warn) {
warnedAboutInclusive = true
console.warn("MarkSpec.inclusiveRight is now called MarkSpec.inclusive")
}
}
this.attrs = initAttrs(spec.attrs)

@@ -237,0 +227,0 @@

@@ -131,4 +131,5 @@ // DOMOutputSpec:: interface

var contentDOM = ref.contentDOM;
if (node && !node.isLeaf) {
if (!contentDOM) { throw new RangeError("No content hole in template for non-leaf node") }
if (contentDOM) {
if (!node || node.isLeaf)
{ throw new RangeError("Content hole not allowed in a mark or leaf node spec") }
if (options.onContent)

@@ -138,4 +139,2 @@ { options.onContent(node, contentDOM, options) }

{ this.serializeFragment(node.content, options, contentDOM) }
} else if (contentDOM) {
throw new RangeError("Content hole not allowed in a mark or leaf node spec")
}

@@ -142,0 +141,0 @@ return dom

{
"name": "prosemirror-model",
"version": "0.19.0",
"version": "0.20.0",
"description": "ProseMirror's document model",

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

"mocha": "^3.0.2",
"ist": "1.0.0",
"ist": "^1.0.0",
"jsdom": "^8.0.4",
"rimraf": "^2.5.4"
"rimraf": "^2.5.4",
"prosemirror-test-builder": "^0.20.0"
},

@@ -29,0 +30,0 @@ "scripts": {

@@ -17,3 +17,6 @@ const {findDiffStart, findDiffEnd} = require("./diff")

nodesBetween(from, to, f, nodeStart, parent) {
// :: (number, number, (node: Node, start: number, parent: Node, index: number) → ?bool)
// Invoke a callback for all descendant nodes between the given two
// positions (relative to start of this fragment).
nodesBetween(from, to, f, nodeStart = 0, parent) {
for (let i = 0, pos = 0; pos < to; i++) {

@@ -31,2 +34,8 @@ let child = this.content[i], end = pos + child.nodeSize

// :: ((node: Node, pos: number, parent: Node))
// Call the given callback for every descendant node.
descendants(f) {
this.nodesBetween(0, this.size, f)
}
// : (number, number, ?string, ?string) → string

@@ -33,0 +42,0 @@ textBetween(from, to, blockSeparator, leafText) {

@@ -79,5 +79,8 @@ const {Fragment} = require("./fragment")

//
// preserveWhitespace:: ?bool
// preserveWhitespace:: ?union<bool, "full">
// Controls whether whitespace should be preserved when parsing the
// content inside the matched element.
// content inside the matched element. `false` means whitespace may
// be collapsed, `true` means that whitespace should be preserved
// but newlines normalized to spaces, and `"full"` means that
// newlines should also be preserved.

@@ -110,5 +113,6 @@ // ::- A DOM parser represents a strategy for parsing DOM content into

//
// preserveWhitespace:: ?bool
// preserveWhitespace:: ?union<bool, "full">
// By default, whitespace is collapsed as per HTML's rules. Pass
// true here to prevent the parser from doing that.
// `true` to preserve whitespace, but normalize newlines to
// spaces, and `"full"` to preserve whitespace entirely.
//

@@ -140,3 +144,3 @@ // findPositions:: ?[{node: dom.Node, offset: number}]

// context:: ?ResolvedPos
// A set of additional node names to cound as
// A set of additional node names to count as
// [context](#model.ParseRule.context) when parsing, above the

@@ -250,4 +254,8 @@ // given [top node](#model.DOMParser.parse^options.topNode).

// Using a bitfield for node context options
const OPT_PRESERVE_WS = 1, OPT_OPEN_LEFT = 2
const OPT_PRESERVE_WS = 1, OPT_PRESERVE_WS_FULL = 2, OPT_OPEN_LEFT = 4
function wsOptionsFor(preserveWhitespace) {
return (preserveWhitespace ? OPT_PRESERVE_WS : 0) | (preserveWhitespace === "full" ? OPT_PRESERVE_WS_FULL : 0)
}
class NodeContext {

@@ -304,3 +312,3 @@ constructor(type, attrs, solid, match, options) {

let topNode = options.topNode, topContext
let topOptions = (options.preserveWhitespace ? OPT_PRESERVE_WS : 0) | (open ? OPT_OPEN_LEFT : 0)
let topOptions = wsOptionsFor(options.preserveWhitespace) | (open ? OPT_OPEN_LEFT : 0)
if (topNode)

@@ -360,2 +368,4 @@ topContext = new NodeContext(topNode.type, topNode.attrs, true,

}
} else if (!(top.options & OPT_PRESERVE_WS_FULL)) {
value = value.replace(/\r?\n|\r/g, " ")
}

@@ -506,3 +516,3 @@ if (value) this.insertNode(this.parser.schema.text(value, this.marks))

top.match = top.match && top.match.matchType(type, attrs)
let options = preserveWS == null ? top.options & OPT_PRESERVE_WS : preserveWS ? OPT_PRESERVE_WS : 0
let options = preserveWS == null ? top.options & ~OPT_OPEN_LEFT : wsOptionsFor(preserveWS)
if ((top.options & OPT_OPEN_LEFT) && top.content.length == 0) options |= OPT_OPEN_LEFT

@@ -558,3 +568,3 @@ this.nodes.push(new NodeContext(type, attrs, solid, null, options))

if (this.find) for (let i = 0; i < this.find.length; i++) {
if (this.find[i].pos == null && parent.contains(this.find[i].node))
if (this.find[i].pos == null && parent.nodeType == 1 && parent.contains(this.find[i].node))
this.find[i].pos = this.currentPos

@@ -566,3 +576,3 @@ }

if (parent != content && this.find) for (let i = 0; i < this.find.length; i++) {
if (this.find[i].pos == null && parent.contains(this.find[i].node)) {
if (this.find[i].pos == null && parent.nodeType == 1 && parent.contains(this.find[i].node)) {
let pos = content.compareDocumentPosition(this.find[i].node)

@@ -569,0 +579,0 @@ if (pos & (before ? 2 : 4))

@@ -43,2 +43,4 @@ const {Fragment} = require("./fragment")

// :: (Slice) → bool
// Tests whether this slice is equal to another slice.
eq(other) {

@@ -45,0 +47,0 @@ return this.content.eq(other.content) && this.openLeft == other.openLeft && this.openRight == other.openRight

@@ -180,2 +180,14 @@ const {Mark} = require("./mark")

// :: (ResolvedPos) → ResolvedPos
// Return the greater of this and the given position.
max(other) {
return other.pos > this.pos ? other : this
}
// :: (ResolvedPos) → ResolvedPos
// Return the smaller of this and the given position.
min(other) {
return other.pos < this.pos ? other : this
}
toString() {

@@ -182,0 +194,0 @@ let str = ""

@@ -197,4 +197,2 @@ const OrderedMap = require("orderedmap")

let warnedAboutInclusive = false
// ::- Like nodes, marks (which are associated with nodes to signify

@@ -217,10 +215,2 @@ // things like emphasis or being part of a link) are tagged with type

if (spec.inclusiveRight === false && spec.inclusive == null) {
spec.inclusive = false
if (!warnedAboutInclusive && typeof console != "undefined" && console.warn) {
warnedAboutInclusive = true
console.warn("MarkSpec.inclusiveRight is now called MarkSpec.inclusive")
}
}
this.attrs = initAttrs(spec.attrs)

@@ -227,0 +217,0 @@

@@ -122,4 +122,5 @@ // DOMOutputSpec:: interface

let {dom, contentDOM} = DOMSerializer.renderSpec(doc(options), structure)
if (node && !node.isLeaf) {
if (!contentDOM) throw new RangeError("No content hole in template for non-leaf node")
if (contentDOM) {
if (!node || node.isLeaf)
throw new RangeError("Content hole not allowed in a mark or leaf node spec")
if (options.onContent)

@@ -129,4 +130,2 @@ options.onContent(node, contentDOM, options)

this.serializeFragment(node.content, options, contentDOM)
} else if (contentDOM) {
throw new RangeError("Content hole not allowed in a mark or leaf node spec")
}

@@ -133,0 +132,0 @@ return dom

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