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.1.0 to 1.2.0

CHANGELOG.md

2

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

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

@@ -27,4 +27,4 @@ import {Fragment} from "./fragment"

// :: (NodeType) → ?ContentMatch
// Match a node type and marks, returning a match after that node
// if successful.
// Match a node type, returning a match after that node if
// successful.
matchType(type) {

@@ -31,0 +31,0 @@ for (let i = 0; i < this.next.length; i += 2)

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

// :: (number, number, (node: Node, start: number, parent: Node, index: number) → ?bool)
// :: (number, number, (node: Node, start: number, parent: Node, index: number) → ?bool, ?number)
// Invoke a callback for all descendant nodes between the given two

@@ -22,0 +22,0 @@ // positions (relative to start of this fragment). Doesn't descend

@@ -72,3 +72,3 @@ import {Fragment} from "./fragment"

// :: (number, number, (node: Node, pos: number, parent: Node, index: number) → ?bool)
// :: (number, number, (node: Node, pos: number, parent: Node, index: number) → ?bool, ?number)
// Invoke a callback for all descendant nodes recursively between

@@ -79,5 +79,6 @@ // the given two positions that are relative to start of this node's

// When the callback returns false for a given node, that node's
// children will not be recursed over.
nodesBetween(from, to, f, pos = 0) {
this.content.nodesBetween(from, to, f, pos, this)
// children will not be recursed over. The last parameter can be
// used to specify a starting position to count from.
nodesBetween(from, to, f, startPos = 0) {
this.content.nodesBetween(from, to, f, startPos, this)
}

@@ -231,3 +232,3 @@

let found = false
this.nodesBetween(from, to, node => {
if (to > from) this.nodesBetween(from, to, node => {
if (type.isInSet(node.marks)) found = true

@@ -305,3 +306,3 @@ return !found

// Test whether replacing the range `from` to `to` (by index) with a
// node of the given type.
// node of the given type would leave the node's content valid.
canReplaceWith(from, to, type, marks) {

@@ -308,0 +309,0 @@ if (marks && !this.type.allowsMarks(marks)) return false

@@ -19,3 +19,3 @@ This module defines ProseMirror's content model, the data structures

Positions in a document can be represented as integer
[offsets](/docs/guides/doc/#indexing). But you'll often want to use a
[offsets](/docs/guide/#doc.indexing). But you'll often want to use a
more convenient representation.

@@ -22,0 +22,0 @@

@@ -239,3 +239,3 @@ import {Mark} from "./mark"

let cached = resolveCache[i]
if (cached.pos == pos && cached.node(0) == doc) return cached
if (cached.pos == pos && cached.doc == doc) return cached
}

@@ -248,3 +248,3 @@ let result = resolveCache[resolveCachePos] = ResolvedPos.resolve(doc, pos)

let resolveCache = [], resolveCachePos = 0, resolveCacheSize = 6
let resolveCache = [], resolveCachePos = 0, resolveCacheSize = 12

@@ -251,0 +251,0 @@ // ::- Represents a flat range of content, i.e. one that starts and

@@ -431,3 +431,5 @@ import OrderedMap from "orderedmap"

// Defines the default way marks of this type should be serialized
// to DOM/HTML.
// to DOM/HTML. When the resulting spec contains a hole, that is
// where the marked content is placed. Otherwise, it is appended to
// the top node.
//

@@ -434,0 +436,0 @@ // parseDOM:: ?[ParseRule]

@@ -8,7 +8,7 @@ // DOMOutputSpec:: interface

// should be a string—the name of the DOM element. If the second
// element is plain object object, it is interpreted as an set of
// attributes for the element. Any elements after that (including the
// 2nd if it's not an attribute object) are interpreted as children of
// the DOM elements, and must either be valid `DOMOutputSpec` values,
// or the number zero.
// element is plain object, it is interpreted as a set of attributes
// for the element. Any elements after that (including the 2nd if it's
// not an attribute object) are interpreted as children of the DOM
// elements, and must either be valid `DOMOutputSpec` values, or the
// number zero.
//

@@ -52,14 +52,21 @@ // The number zero (pronounced “hole”) is used to indicate the place

if (!active) active = []
let keep = 0
for (; keep < Math.min(active.length, node.marks.length); ++keep)
if (!node.marks[keep].eq(active[keep])) break
let keep = 0, rendered = 0
while (keep < active.length && rendered < node.marks.length) {
let next = node.marks[rendered]
if (!this.marks[next.type.name]) { rendered++; continue }
if (!next.eq(active[keep])) break
keep += 2; rendered++
}
while (keep < active.length) {
let removed = active.pop()
if (this.marks[removed.type.name]) top = top.parentNode
top = active.pop()
active.pop()
}
while (active.length < node.marks.length) {
let add = node.marks[active.length]
active.push(add)
while (rendered < node.marks.length) {
let add = node.marks[rendered++]
let markDOM = this.serializeMark(add, node.isInline, options)
if (markDOM) top = top.appendChild(markDOM)
if (markDOM) {
active.push(add, top)
top.appendChild(markDOM.dom)
top = markDOM.contentDOM || markDOM.dom
}
}

@@ -80,3 +87,13 @@ }

serializeNode(node, options = {}) {
return this.renderStructure(this.nodes[node.type.name](node), node, options)
let {dom, contentDOM} =
DOMSerializer.renderSpec(doc(options), this.nodes[node.type.name](node))
if (contentDOM) {
if (node.isLeaf)
throw new RangeError("Content hole not allowed in a leaf node spec")
if (options.onContent)
options.onContent(node, contentDOM, options)
else
this.serializeFragment(node.content, options, contentDOM)
}
return dom
}

@@ -89,4 +106,4 @@

if (wrap) {
wrap.appendChild(dom)
dom = wrap
;(wrap.contentDOM || wrap.dom).appendChild(dom)
dom = wrap.dom
}

@@ -99,3 +116,3 @@ }

let toDOM = this.marks[mark.type.name]
return toDOM && this.renderStructure(toDOM(mark, inline), null, options)
return toDOM && DOMSerializer.renderSpec(doc(options), toDOM(mark, inline))
}

@@ -139,15 +156,2 @@

renderStructure(structure, node, options) {
let {dom, contentDOM} = DOMSerializer.renderSpec(doc(options), structure)
if (contentDOM) {
if (!node || node.isLeaf)
throw new RangeError("Content hole not allowed in a mark or leaf node spec")
if (options.onContent)
options.onContent(node, contentDOM, options)
else
this.serializeFragment(node.content, options, contentDOM)
}
return dom
}
// :: (Schema) → DOMSerializer

@@ -154,0 +158,0 @@ // Build a serializer using the [`toDOM`](#model.NodeSpec.toDOM)

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