prosemirror-model
Advanced tools
Comparing version 0.15.0 to 0.16.0
@@ -6,3 +6,3 @@ var ref = require("./fragment"); | ||
var ContentExpr = function ContentExpr(nodeType, elements, inlineContent) { | ||
var ContentExpr = function(nodeType, elements, inlineContent) { | ||
this.nodeType = nodeType | ||
@@ -21,3 +21,3 @@ this.elements = elements | ||
// The content match at the start of this expression. | ||
ContentExpr.prototype.start = function start (attrs) { | ||
ContentExpr.prototype.start = function (attrs) { | ||
return new ContentMatch(this, attrs, 0, 0) | ||
@@ -30,3 +30,3 @@ }; | ||
// open to the left.) | ||
ContentExpr.prototype.atType = function atType (parentAttrs, type, attrs, marks) { | ||
ContentExpr.prototype.atType = function (parentAttrs, type, attrs, marks) { | ||
var this$1 = this; | ||
@@ -40,3 +40,3 @@ if ( marks === void 0 ) marks = Mark.none; | ||
ContentExpr.prototype.matches = function matches (attrs, fragment, from, to) { | ||
ContentExpr.prototype.matches = function (attrs, fragment, from, to) { | ||
return this.start(attrs).matchToEnd(fragment, from, to) | ||
@@ -48,3 +48,3 @@ }; | ||
// and can simply skip to the position with count `index`. | ||
ContentExpr.prototype.getMatchAt = function getMatchAt (attrs, fragment, index) { | ||
ContentExpr.prototype.getMatchAt = function (attrs, fragment, index) { | ||
if ( index === void 0 ) index = fragment.childCount; | ||
@@ -58,3 +58,3 @@ | ||
ContentExpr.prototype.checkReplace = function checkReplace (attrs, content, from, to, replacement, start, end) { | ||
ContentExpr.prototype.checkReplace = function (attrs, content, from, to, replacement, start, end) { | ||
var this$1 = this; | ||
@@ -78,3 +78,3 @@ if ( replacement === void 0 ) replacement = Fragment.empty; | ||
ContentExpr.prototype.checkReplaceWith = function checkReplaceWith (attrs, content, from, to, type, typeAttrs, marks) { | ||
ContentExpr.prototype.checkReplaceWith = function (attrs, content, from, to, type, typeAttrs, marks) { | ||
if (this.elements.length == 1) { | ||
@@ -90,3 +90,3 @@ var elt = this.elements[0] | ||
ContentExpr.prototype.compatible = function compatible (other) { | ||
ContentExpr.prototype.compatible = function (other) { | ||
var this$1 = this; | ||
@@ -102,7 +102,7 @@ | ||
ContentExpr.prototype.generateContent = function generateContent (attrs) { | ||
ContentExpr.prototype.generateContent = function (attrs) { | ||
return this.start(attrs).fillBefore(Fragment.empty, true) | ||
}; | ||
ContentExpr.parse = function parse (nodeType, expr, specs) { | ||
ContentExpr.parse = function (nodeType, expr, specs) { | ||
var elements = [], pos = 0, inline = null | ||
@@ -152,3 +152,3 @@ for (;;) { | ||
var ContentElement = function ContentElement(nodeTypes, attrs, marks, min, max) { | ||
var ContentElement = function(nodeTypes, attrs, marks, min, max) { | ||
this.nodeTypes = nodeTypes | ||
@@ -161,3 +161,3 @@ this.attrs = attrs | ||
ContentElement.prototype.matchesType = function matchesType (type, attrs, marks, parentAttrs, parentExpr) { | ||
ContentElement.prototype.matchesType = function (type, attrs, marks, parentAttrs, parentExpr) { | ||
var this$1 = this; | ||
@@ -168,3 +168,3 @@ | ||
if (!attrs) { return false } | ||
for (var prop in this.attrs) | ||
for (var prop in this$1.attrs) | ||
{ if (attrs[prop] != resolveValue(this$1.attrs[prop], parentAttrs, parentExpr)) { return false } } | ||
@@ -179,7 +179,7 @@ } | ||
ContentElement.prototype.matches = function matches (node, parentAttrs, parentExpr) { | ||
ContentElement.prototype.matches = function (node, parentAttrs, parentExpr) { | ||
return this.matchesType(node.type, node.attrs, node.marks, parentAttrs, parentExpr) | ||
}; | ||
ContentElement.prototype.compatible = function compatible (other) { | ||
ContentElement.prototype.compatible = function (other) { | ||
var this$1 = this; | ||
@@ -192,3 +192,3 @@ | ||
ContentElement.prototype.constrainedAttrs = function constrainedAttrs (parentAttrs, expr) { | ||
ContentElement.prototype.constrainedAttrs = function (parentAttrs, expr) { | ||
var this$1 = this; | ||
@@ -198,3 +198,3 @@ | ||
var attrs = Object.create(null) | ||
for (var prop in this.attrs) | ||
for (var prop in this$1.attrs) | ||
{ attrs[prop] = resolveValue(this$1.attrs[prop], parentAttrs, expr) } | ||
@@ -204,3 +204,3 @@ return attrs | ||
ContentElement.prototype.createFiller = function createFiller (parentAttrs, expr) { | ||
ContentElement.prototype.createFiller = function (parentAttrs, expr) { | ||
var type = this.nodeTypes[0], attrs = type.computeAttrs(this.constrainedAttrs(parentAttrs, expr)) | ||
@@ -210,3 +210,3 @@ return type.create(attrs, type.contentExpr.generateContent(attrs)) | ||
ContentElement.prototype.defaultType = function defaultType () { | ||
ContentElement.prototype.defaultType = function () { | ||
var first = this.nodeTypes[0] | ||
@@ -216,7 +216,7 @@ if (!(first.hasRequiredAttrs() || first.isText)) { return first } | ||
ContentElement.prototype.overlaps = function overlaps (other) { | ||
ContentElement.prototype.overlaps = function (other) { | ||
return this.nodeTypes.some(function (t) { return other.nodeTypes.indexOf(t) > -1; }) | ||
}; | ||
ContentElement.prototype.allowsMark = function allowsMark (markType) { | ||
ContentElement.prototype.allowsMark = function (markType) { | ||
return this.marks === true || this.marks && this.marks.indexOf(markType) > -1 | ||
@@ -229,3 +229,3 @@ }; | ||
// of the parent node. | ||
var ContentMatch = function ContentMatch(expr, attrs, index, count) { | ||
var ContentMatch = function(expr, attrs, index, count) { | ||
this.expr = expr | ||
@@ -251,7 +251,7 @@ this.attrs = attrs | ||
ContentMatch.prototype.move = function move (index, count) { | ||
ContentMatch.prototype.move = function (index, count) { | ||
return new ContentMatch(this.expr, this.attrs, index, count) | ||
}; | ||
ContentMatch.prototype.resolveValue = function resolveValue$1 (value) { | ||
ContentMatch.prototype.resolveValue = function (value) { | ||
return value instanceof AttrValue ? resolveValue(value, this.attrs, this.expr) : value | ||
@@ -262,3 +262,3 @@ }; | ||
// Match a node, returning a new match after the node if successful. | ||
ContentMatch.prototype.matchNode = function matchNode (node) { | ||
ContentMatch.prototype.matchNode = function (node) { | ||
return this.matchType(node.type, node.attrs, node.marks) | ||
@@ -270,7 +270,6 @@ }; | ||
// if successful. | ||
ContentMatch.prototype.matchType = function matchType (type, attrs, marks) { | ||
ContentMatch.prototype.matchType = function (type, attrs, marks) { | ||
var this$1 = this; | ||
if ( marks === void 0 ) marks = Mark.none; | ||
// FIXME `var` to work around Babel bug T7293 | ||
for (var ref = this, index = ref.index, count = ref.count; index < this.expr.elements.length; index++, count = 0) { | ||
@@ -291,3 +290,3 @@ var elt = this$1.expr.elements[index], max = this$1.resolveValue(elt.max) | ||
// matching all nodes. | ||
ContentMatch.prototype.matchFragment = function matchFragment (fragment, from, to) { | ||
ContentMatch.prototype.matchFragment = function (fragment, from, to) { | ||
var this$1 = this; | ||
@@ -318,3 +317,3 @@ if ( from === void 0 ) from = 0; | ||
// the way to the end of the content expression. | ||
ContentMatch.prototype.matchToEnd = function matchToEnd (fragment, start, end) { | ||
ContentMatch.prototype.matchToEnd = function (fragment, start, end) { | ||
var matched = this.matchFragment(fragment, start, end) | ||
@@ -327,3 +326,3 @@ return matched && matched.validEnd() || false | ||
// expression (no required content follows after it). | ||
ContentMatch.prototype.validEnd = function validEnd () { | ||
ContentMatch.prototype.validEnd = function () { | ||
var this$1 = this; | ||
@@ -343,3 +342,3 @@ | ||
// content expression. | ||
ContentMatch.prototype.fillBefore = function fillBefore (after, toEnd, startIndex) { | ||
ContentMatch.prototype.fillBefore = function (after, toEnd, startIndex) { | ||
var this$1 = this; | ||
@@ -367,3 +366,3 @@ | ||
ContentMatch.prototype.possibleContent = function possibleContent () { | ||
ContentMatch.prototype.possibleContent = function () { | ||
var this$1 = this; | ||
@@ -386,3 +385,3 @@ | ||
// this position. | ||
ContentMatch.prototype.allowsMark = function allowsMark (markType) { | ||
ContentMatch.prototype.allowsMark = function (markType) { | ||
return this.element.allowsMark(markType) | ||
@@ -396,4 +395,3 @@ }; | ||
// will be null when no such wrapping exists. | ||
ContentMatch.prototype.findWrapping = function findWrapping (target, targetAttrs, targetMarks) { | ||
// FIXME find out how expensive this is. Try to reintroduce caching? | ||
ContentMatch.prototype.findWrapping = function (target, targetAttrs, targetMarks) { | ||
var seen = Object.create(null), first = {match: this, via: null}, active = [first] | ||
@@ -426,3 +424,3 @@ while (active.length) { | ||
// properties of the given node. | ||
ContentMatch.prototype.findWrappingFor = function findWrappingFor (node) { | ||
ContentMatch.prototype.findWrappingFor = function (node) { | ||
return this.findWrapping(node.type, node.attrs, node.marks) | ||
@@ -434,3 +432,3 @@ }; | ||
var AttrValue = function AttrValue(attr) { this.attr = attr }; | ||
var AttrValue = function(attr) { this.attr = attr }; | ||
@@ -437,0 +435,0 @@ function parseValue(nodeType, value) { |
@@ -11,3 +11,3 @@ var ref = require("./diff"); | ||
// whenever needed. The API tries to make this easy. | ||
var Fragment = function Fragment(content, size) { | ||
var Fragment = function(content, size) { | ||
var this$1 = this; | ||
@@ -23,3 +23,3 @@ | ||
Fragment.prototype.nodesBetween = function nodesBetween (from, to, f, nodeStart, parent) { | ||
Fragment.prototype.nodesBetween = function (from, to, f, nodeStart, parent) { | ||
var this$1 = this; | ||
@@ -40,3 +40,3 @@ | ||
// : (number, number, ?string, ?string) → string | ||
Fragment.prototype.textBetween = function textBetween (from, to, blockSeparator, leafText) { | ||
Fragment.prototype.textBetween = function (from, to, blockSeparator, leafText) { | ||
var text = "", separated = true | ||
@@ -61,3 +61,3 @@ this.nodesBetween(from, to, function (node, pos) { | ||
// `other`. | ||
Fragment.prototype.append = function append (other) { | ||
Fragment.prototype.append = function (other) { | ||
if (!other.size) { return this } | ||
@@ -76,3 +76,3 @@ if (!this.size) { return other } | ||
// Cut out the sub-fragment between the two given positions. | ||
Fragment.prototype.cut = function cut (from, to) { | ||
Fragment.prototype.cut = function (from, to) { | ||
var this$1 = this; | ||
@@ -100,3 +100,3 @@ | ||
Fragment.prototype.cutByIndex = function cutByIndex (from, to) { | ||
Fragment.prototype.cutByIndex = function (from, to) { | ||
if (from == to) { return Fragment.empty } | ||
@@ -110,3 +110,3 @@ if (from == 0 && to == this.content.length) { return this } | ||
// replaced by the given node. | ||
Fragment.prototype.replaceChild = function replaceChild (index, node) { | ||
Fragment.prototype.replaceChild = function (index, node) { | ||
var current = this.content[index] | ||
@@ -123,3 +123,3 @@ if (current == node) { return this } | ||
// fragment. | ||
Fragment.prototype.addToStart = function addToStart (node) { | ||
Fragment.prototype.addToStart = function (node) { | ||
return new Fragment([node].concat(this.content), this.size + node.nodeSize) | ||
@@ -131,3 +131,3 @@ }; | ||
// fragment. | ||
Fragment.prototype.addToEnd = function addToEnd (node) { | ||
Fragment.prototype.addToEnd = function (node) { | ||
return new Fragment(this.content.concat(node), this.size + node.nodeSize) | ||
@@ -138,3 +138,3 @@ }; | ||
// Compare this fragment to another one. | ||
Fragment.prototype.eq = function eq (other) { | ||
Fragment.prototype.eq = function (other) { | ||
var this$1 = this; | ||
@@ -163,3 +163,3 @@ | ||
// index is out of range. | ||
Fragment.prototype.child = function child (index) { | ||
Fragment.prototype.child = function (index) { | ||
var found = this.content[index] | ||
@@ -172,3 +172,3 @@ if (!found) { throw new RangeError("Index " + index + " out of range for " + this) } | ||
// Get the offset at (size of children before) the given index. | ||
Fragment.prototype.offsetAt = function offsetAt (index) { | ||
Fragment.prototype.offsetAt = function (index) { | ||
var this$1 = this; | ||
@@ -183,3 +183,3 @@ | ||
// Get the child node at the given index, if it exists. | ||
Fragment.prototype.maybeChild = function maybeChild (index) { | ||
Fragment.prototype.maybeChild = function (index) { | ||
return this.content[index] | ||
@@ -191,3 +191,3 @@ }; | ||
// into this parent node, and its index. | ||
Fragment.prototype.forEach = function forEach (f) { | ||
Fragment.prototype.forEach = function (f) { | ||
var this$1 = this; | ||
@@ -205,3 +205,3 @@ | ||
// fragment differ, or `null` if they are the same. | ||
Fragment.prototype.findDiffStart = function findDiffStart$1 (other, pos) { | ||
Fragment.prototype.findDiffStart = function (other, pos) { | ||
if ( pos === void 0 ) pos = 0; | ||
@@ -217,3 +217,3 @@ | ||
// object with two separate positions is returned. | ||
Fragment.prototype.findDiffEnd = function findDiffEnd$1 (other, pos, otherPos) { | ||
Fragment.prototype.findDiffEnd = function (other, pos, otherPos) { | ||
if ( pos === void 0 ) pos = this.size; | ||
@@ -229,3 +229,3 @@ if ( otherPos === void 0 ) otherPos = other.size; | ||
// (overwritten) the next time the function is called. (Not public.) | ||
Fragment.prototype.findIndex = function findIndex (pos, round) { | ||
Fragment.prototype.findIndex = function (pos, round) { | ||
var this$1 = this; | ||
@@ -249,9 +249,9 @@ if ( round === void 0 ) round = -1; | ||
// Return a debugging string that describes this fragment. | ||
Fragment.prototype.toString = function toString () { return "<" + this.toStringInner() + ">" }; | ||
Fragment.prototype.toString = function () { return "<" + this.toStringInner() + ">" }; | ||
Fragment.prototype.toStringInner = function toStringInner () { return this.content.join(", ") }; | ||
Fragment.prototype.toStringInner = function () { return this.content.join(", ") }; | ||
// :: () → ?Object | ||
// Create a JSON-serializeable representation of this fragment. | ||
Fragment.prototype.toJSON = function toJSON () { | ||
Fragment.prototype.toJSON = function () { | ||
return this.content.length ? this.content.map(function (n) { return n.toJSON(); }) : null | ||
@@ -262,3 +262,3 @@ }; | ||
// Deserialize a fragment from its JSON representation. | ||
Fragment.fromJSON = function fromJSON (schema, value) { | ||
Fragment.fromJSON = function (schema, value) { | ||
return value ? new Fragment(value.map(schema.nodeFromJSON)) : Fragment.empty | ||
@@ -270,3 +270,3 @@ }; | ||
// text nodes with the same style are joined together. | ||
Fragment.fromArray = function fromArray (array) { | ||
Fragment.fromArray = function (array) { | ||
if (!array.length) { return Fragment.empty } | ||
@@ -292,3 +292,3 @@ var joined, size = 0 | ||
// fragment containing those nodes. | ||
Fragment.from = function from (nodes) { | ||
Fragment.from = function (nodes) { | ||
if (!nodes) { return Fragment.empty } | ||
@@ -295,0 +295,0 @@ if (nodes instanceof Fragment) { return nodes } |
@@ -78,3 +78,3 @@ var ref = require("./fragment"); | ||
// is defined by an array of [rules](#model.ParseRule). | ||
var DOMParser = function DOMParser(schema, rules) { | ||
var DOMParser = function(schema, rules) { | ||
var this$1 = this; | ||
@@ -126,3 +126,3 @@ | ||
// `topNode`. | ||
DOMParser.prototype.parse = function parse (dom, options) { | ||
DOMParser.prototype.parse = function (dom, options) { | ||
if ( options === void 0 ) options = {}; | ||
@@ -142,3 +142,3 @@ | ||
// the left of the input and the end of nodes at the end. | ||
DOMParser.prototype.parseSlice = function parseSlice (dom, options) { | ||
DOMParser.prototype.parseSlice = function (dom, options) { | ||
if ( options === void 0 ) options = {}; | ||
@@ -151,3 +151,3 @@ | ||
DOMParser.prototype.matchTag = function matchTag (dom) { | ||
DOMParser.prototype.matchTag = function (dom) { | ||
var this$1 = this; | ||
@@ -168,3 +168,3 @@ | ||
DOMParser.prototype.matchStyle = function matchStyle (prop, value) { | ||
DOMParser.prototype.matchStyle = function (prop, value) { | ||
var this$1 = this; | ||
@@ -188,3 +188,3 @@ | ||
// specs](#model.NodeSpec.parseDOM). | ||
DOMParser.schemaRules = function schemaRules (schema) { | ||
DOMParser.schemaRules = function (schema) { | ||
var result = [] | ||
@@ -224,3 +224,3 @@ function insert(rule) { | ||
// schema's [node specs](#model.NodeSpec.parseDOM). | ||
DOMParser.fromSchema = function fromSchema (schema) { | ||
DOMParser.fromSchema = function (schema) { | ||
return schema.cached.domParser || | ||
@@ -251,3 +251,3 @@ (schema.cached.domParser = new DOMParser(schema, DOMParser.schemaRules(schema))) | ||
var NodeContext = function NodeContext(type, attrs, solid, match, options) { | ||
var NodeContext = function(type, attrs, solid, match, options) { | ||
this.type = type | ||
@@ -261,3 +261,3 @@ this.attrs = attrs | ||
NodeContext.prototype.findWrapping = function findWrapping (type, attrs) { | ||
NodeContext.prototype.findWrapping = function (type, attrs) { | ||
if (!this.match) { | ||
@@ -279,3 +279,3 @@ if (!this.type) { return [] } | ||
NodeContext.prototype.finish = function finish (openRight) { | ||
NodeContext.prototype.finish = function (openRight) { | ||
if (!(this.options & OPT_PRESERVE_WS)) { // Strip trailing whitespace | ||
@@ -294,3 +294,3 @@ var last = this.content[this.content.length - 1], m | ||
var ParseContext = function ParseContext(parser, options, open) { | ||
var ParseContext = function(parser, options, open) { | ||
// : DOMParser The parser we are using. | ||
@@ -325,3 +325,3 @@ this.parser = parser | ||
// Add a mark to the current set of marks, return the old set. | ||
ParseContext.prototype.addMark = function addMark (mark) { | ||
ParseContext.prototype.addMark = function (mark) { | ||
var old = this.marks | ||
@@ -336,3 +336,3 @@ this.marks = mark.addToSet(this.marks) | ||
// `style` attribute, `addElementWithStyles`. | ||
ParseContext.prototype.addDOM = function addDOM (dom) { | ||
ParseContext.prototype.addDOM = function (dom) { | ||
if (dom.nodeType == 3) { | ||
@@ -347,3 +347,3 @@ this.addTextNode(dom) | ||
ParseContext.prototype.addTextNode = function addTextNode (dom) { | ||
ParseContext.prototype.addTextNode = function (dom) { | ||
var value = dom.nodeValue | ||
@@ -373,3 +373,3 @@ var top = this.top | ||
// none is found, the element's content nodes are added directly. | ||
ParseContext.prototype.addElement = function addElement (dom) { | ||
ParseContext.prototype.addElement = function (dom) { | ||
var name = dom.nodeName.toLowerCase() | ||
@@ -393,3 +393,3 @@ if (listTags.hasOwnProperty(name)) { normalizeList(dom) } | ||
// through to `addElement`. | ||
ParseContext.prototype.addElementWithStyles = function addElementWithStyles (styles, dom) { | ||
ParseContext.prototype.addElementWithStyles = function (styles, dom) { | ||
var this$1 = this; | ||
@@ -412,3 +412,3 @@ | ||
// the node's content is wrapped, and return true. | ||
ParseContext.prototype.addElementByRule = function addElementByRule (dom, rule) { | ||
ParseContext.prototype.addElementByRule = function (dom, rule) { | ||
var this$1 = this; | ||
@@ -448,3 +448,3 @@ | ||
// synchronize after every block element. | ||
ParseContext.prototype.addAll = function addAll (parent, sync, startIndex, endIndex) { | ||
ParseContext.prototype.addAll = function (parent, sync, startIndex, endIndex) { | ||
var this$1 = this; | ||
@@ -467,3 +467,3 @@ | ||
// nodes that we're in. | ||
ParseContext.prototype.findPlace = function findPlace (type, attrs) { | ||
ParseContext.prototype.findPlace = function (type, attrs) { | ||
var this$1 = this; | ||
@@ -491,3 +491,3 @@ | ||
// Try to insert the given node, adjusting the context when needed. | ||
ParseContext.prototype.insertNode = function insertNode (node) { | ||
ParseContext.prototype.insertNode = function (node) { | ||
if (this.findPlace(node.type, node.attrs)) { | ||
@@ -511,3 +511,3 @@ this.closeExtra() | ||
// necessary. | ||
ParseContext.prototype.enter = function enter (type, attrs, preserveWS) { | ||
ParseContext.prototype.enter = function (type, attrs, preserveWS) { | ||
var ok = this.findPlace(type, attrs) | ||
@@ -519,3 +519,3 @@ if (ok) { this.enterInner(type, attrs, true, preserveWS) } | ||
// Open a node of the given type | ||
ParseContext.prototype.enterInner = function enterInner (type, attrs, solid, preserveWS) { | ||
ParseContext.prototype.enterInner = function (type, attrs, solid, preserveWS) { | ||
this.closeExtra() | ||
@@ -532,3 +532,3 @@ var top = this.top | ||
// their parents | ||
ParseContext.prototype.closeExtra = function closeExtra (openRight) { | ||
ParseContext.prototype.closeExtra = function (openRight) { | ||
var this$1 = this; | ||
@@ -544,3 +544,3 @@ | ||
ParseContext.prototype.finish = function finish () { | ||
ParseContext.prototype.finish = function () { | ||
this.open = 0 | ||
@@ -551,3 +551,3 @@ this.closeExtra(this.isOpen) | ||
ParseContext.prototype.sync = function sync (to) { | ||
ParseContext.prototype.sync = function (to) { | ||
var this$1 = this; | ||
@@ -575,3 +575,3 @@ | ||
ParseContext.prototype.findAtPoint = function findAtPoint (parent, offset) { | ||
ParseContext.prototype.findAtPoint = function (parent, offset) { | ||
var this$1 = this; | ||
@@ -585,3 +585,3 @@ | ||
ParseContext.prototype.findInside = function findInside (parent) { | ||
ParseContext.prototype.findInside = function (parent) { | ||
var this$1 = this; | ||
@@ -595,3 +595,3 @@ | ||
ParseContext.prototype.findAround = function findAround (parent, content, before) { | ||
ParseContext.prototype.findAround = function (parent, content, before) { | ||
var this$1 = this; | ||
@@ -608,3 +608,3 @@ | ||
ParseContext.prototype.findInText = function findInText (textNode) { | ||
ParseContext.prototype.findInText = function (textNode) { | ||
var this$1 = this; | ||
@@ -611,0 +611,0 @@ |
@@ -10,3 +10,3 @@ var ref = require("./comparedeep"); | ||
// attributes they have. | ||
var Mark = function Mark(type, attrs) { | ||
var Mark = function(type, attrs) { | ||
// :: MarkType | ||
@@ -26,3 +26,3 @@ // The type of this mark. | ||
// by this one is returned. | ||
Mark.prototype.addToSet = function addToSet (set) { | ||
Mark.prototype.addToSet = function (set) { | ||
var this$1 = this; | ||
@@ -47,3 +47,3 @@ | ||
// mark is not in the set, the set itself is returned. | ||
Mark.prototype.removeFromSet = function removeFromSet (set) { | ||
Mark.prototype.removeFromSet = function (set) { | ||
var this$1 = this; | ||
@@ -59,3 +59,3 @@ | ||
// Test whether this mark is in the given set of marks. | ||
Mark.prototype.isInSet = function isInSet (set) { | ||
Mark.prototype.isInSet = function (set) { | ||
var this$1 = this; | ||
@@ -71,3 +71,3 @@ | ||
// another mark. | ||
Mark.prototype.eq = function eq (other) { | ||
Mark.prototype.eq = function (other) { | ||
if (this == other) { return true } | ||
@@ -81,7 +81,7 @@ if (this.type != other.type) { return false } | ||
// Convert this mark to a JSON-serializeable representation. | ||
Mark.prototype.toJSON = function toJSON () { | ||
Mark.prototype.toJSON = function () { | ||
var this$1 = this; | ||
var obj = {type: this.type.name} | ||
for (var _ in this.attrs) { | ||
for (var _ in this$1.attrs) { | ||
obj.attrs = this$1.attrs | ||
@@ -94,3 +94,3 @@ break | ||
// :: (Schema, Object) → Mark | ||
Mark.fromJSON = function fromJSON (schema, json) { | ||
Mark.fromJSON = function (schema, json) { | ||
return schema.marks[json.type].create(json.attrs) | ||
@@ -101,3 +101,3 @@ }; | ||
// Test whether two sets of marks are identical. | ||
Mark.sameSet = function sameSet (a, b) { | ||
Mark.sameSet = function (a, b) { | ||
if (a == b) { return true } | ||
@@ -113,3 +113,3 @@ if (a.length != b.length) { return false } | ||
// unsorted array of marks. | ||
Mark.setFrom = function setFrom (marks) { | ||
Mark.setFrom = function (marks) { | ||
if (!marks || marks.length == 0) { return Mark.none } | ||
@@ -116,0 +116,0 @@ if (marks instanceof Mark) { return [marks] } |
@@ -27,3 +27,3 @@ var ref = require("./fragment"); | ||
// [this guide](guide/doc.html) for more information. | ||
var Node = function Node(type, attrs, content, marks) { | ||
var Node = function(type, attrs, content, marks) { | ||
// :: NodeType | ||
@@ -69,7 +69,7 @@ // The type of node that this is. | ||
// index is out of range. | ||
Node.prototype.child = function child (index) { return this.content.child(index) }; | ||
Node.prototype.child = function (index) { return this.content.child(index) }; | ||
// :: (number) → ?Node | ||
// Get the child node at the given index, if it exists. | ||
Node.prototype.maybeChild = function maybeChild (index) { return this.content.maybeChild(index) }; | ||
Node.prototype.maybeChild = function (index) { return this.content.maybeChild(index) }; | ||
@@ -79,3 +79,3 @@ // :: ((node: Node, offset: number, index: number)) | ||
// into this parent node, and its index. | ||
Node.prototype.forEach = function forEach (f) { this.content.forEach(f) }; | ||
Node.prototype.forEach = function (f) { this.content.forEach(f) }; | ||
@@ -88,3 +88,3 @@ // :: (?number, ?number, (node: Node, pos: number, parent: Node, index: number)) | ||
// the current node's children will not be recursed over. | ||
Node.prototype.nodesBetween = function nodesBetween (from, to, f, pos) { | ||
Node.prototype.nodesBetween = function (from, to, f, pos) { | ||
if ( pos === void 0 ) pos = 0; | ||
@@ -97,3 +97,3 @@ | ||
// Call the given callback for every descendant node. | ||
Node.prototype.descendants = function descendants (f) { | ||
Node.prototype.descendants = function (f) { | ||
this.nodesBetween(0, this.content.size, f) | ||
@@ -112,3 +112,3 @@ }; | ||
// inserted for every non-text leaf node encountered. | ||
Node.prototype.textBetween = function textBetween (from, to, blockSeparator, leafText) { | ||
Node.prototype.textBetween = function (from, to, blockSeparator, leafText) { | ||
return this.content.textBetween(from, to, blockSeparator, leafText) | ||
@@ -129,3 +129,3 @@ }; | ||
// Test whether two nodes represent the same content. | ||
Node.prototype.eq = function eq (other) { | ||
Node.prototype.eq = function (other) { | ||
return this == other || (this.sameMarkup(other) && this.content.eq(other.content)) | ||
@@ -137,3 +137,3 @@ }; | ||
// those of another. Returns `true` if both have the same markup. | ||
Node.prototype.sameMarkup = function sameMarkup (other) { | ||
Node.prototype.sameMarkup = function (other) { | ||
return this.hasMarkup(other.type, other.attrs, other.marks) | ||
@@ -145,3 +145,3 @@ }; | ||
// attributes, and marks. | ||
Node.prototype.hasMarkup = function hasMarkup (type, attrs, marks) { | ||
Node.prototype.hasMarkup = function (type, attrs, marks) { | ||
return this.type == type && | ||
@@ -155,3 +155,3 @@ compareDeep(this.attrs, attrs || type.defaultAttrs || emptyAttrs) && | ||
// the given content (or empty, if no content is given). | ||
Node.prototype.copy = function copy (content) { | ||
Node.prototype.copy = function (content) { | ||
if ( content === void 0 ) content = null; | ||
@@ -166,3 +166,3 @@ | ||
// of the node's own marks. | ||
Node.prototype.mark = function mark (marks) { | ||
Node.prototype.mark = function (marks) { | ||
return marks == this.marks ? this : new this.constructor(this.type, this.attrs, this.content, marks) | ||
@@ -175,3 +175,3 @@ }; | ||
// the node. | ||
Node.prototype.cut = function cut (from, to) { | ||
Node.prototype.cut = function (from, to) { | ||
if (from == 0 && to == this.content.size) { return this } | ||
@@ -184,3 +184,3 @@ return this.copy(this.content.cut(from, to)) | ||
// return it as a `Slice` object. | ||
Node.prototype.slice = function slice (from, to, includeParents) { | ||
Node.prototype.slice = function (from, to, includeParents) { | ||
if ( to === void 0 ) to = this.content.size; | ||
@@ -205,3 +205,3 @@ if ( includeParents === void 0 ) includeParents = false; | ||
// [`ReplaceError`](#model.ReplaceError) is thrown. | ||
Node.prototype.replace = function replace$1 (from, to, slice) { | ||
Node.prototype.replace = function (from, to, slice) { | ||
return replace(this.resolve(from), this.resolve(to), slice) | ||
@@ -212,3 +212,3 @@ }; | ||
// Find the node after the given position. | ||
Node.prototype.nodeAt = function nodeAt (pos) { | ||
Node.prototype.nodeAt = function (pos) { | ||
for (var node = this;;) { | ||
@@ -229,3 +229,3 @@ var ref = node.content.findIndex(pos); | ||
// node. | ||
Node.prototype.childAfter = function childAfter (pos) { | ||
Node.prototype.childAfter = function (pos) { | ||
var ref = this.content.findIndex(pos); | ||
@@ -241,3 +241,3 @@ var index = ref.index; | ||
// node. | ||
Node.prototype.childBefore = function childBefore (pos) { | ||
Node.prototype.childBefore = function (pos) { | ||
if (pos == 0) { return {node: null, index: 0, offset: 0} } | ||
@@ -255,5 +255,5 @@ var ref = this.content.findIndex(pos); | ||
// describing its path through the document. | ||
Node.prototype.resolve = function resolve (pos) { return ResolvedPos.resolveCached(this, pos) }; | ||
Node.prototype.resolve = function (pos) { return ResolvedPos.resolveCached(this, pos) }; | ||
Node.prototype.resolveNoCache = function resolveNoCache (pos) { return ResolvedPos.resolve(this, pos) }; | ||
Node.prototype.resolveNoCache = function (pos) { return ResolvedPos.resolve(this, pos) }; | ||
@@ -265,3 +265,3 @@ // :: (number, ?bool) → [Mark] | ||
// after it are returned. | ||
Node.prototype.marksAt = function marksAt (pos, useAfter) { | ||
Node.prototype.marksAt = function (pos, useAfter) { | ||
var $pos = this.resolve(pos), parent = $pos.parent, index = $pos.index() | ||
@@ -283,3 +283,3 @@ | ||
// between the two given positions. | ||
Node.prototype.rangeHasMark = function rangeHasMark (from, to, type) { | ||
Node.prototype.rangeHasMark = function (from, to, type) { | ||
var found = false | ||
@@ -318,3 +318,3 @@ this.nodesBetween(from, to, function (node) { | ||
// purposes. | ||
Node.prototype.toString = function toString () { | ||
Node.prototype.toString = function () { | ||
var name = this.type.name | ||
@@ -328,3 +328,3 @@ if (this.content.size) | ||
// Get the content match in this node at the given index. | ||
Node.prototype.contentMatchAt = function contentMatchAt (index) { | ||
Node.prototype.contentMatchAt = function (index) { | ||
return this.type.contentExpr.getMatchAt(this.attrs, this.content, index) | ||
@@ -339,3 +339,3 @@ }; | ||
// fragment. | ||
Node.prototype.canReplace = function canReplace (from, to, replacement, start, end) { | ||
Node.prototype.canReplace = function (from, to, replacement, start, end) { | ||
return this.type.contentExpr.checkReplace(this.attrs, this.content, from, to, replacement, start, end) | ||
@@ -348,3 +348,3 @@ }; | ||
// be valid. | ||
Node.prototype.canReplaceWith = function canReplaceWith (from, to, type, attrs, marks) { | ||
Node.prototype.canReplaceWith = function (from, to, type, attrs, marks) { | ||
return this.type.contentExpr.checkReplaceWith(this.attrs, this.content, from, to, type, attrs, marks || Mark.none) | ||
@@ -358,3 +358,3 @@ }; | ||
// merging completely incompatible nodes). | ||
Node.prototype.canAppend = function canAppend (other) { | ||
Node.prototype.canAppend = function (other) { | ||
if (other.content.size) { return this.canReplace(this.childCount, this.childCount, other.content) } | ||
@@ -364,3 +364,3 @@ else { return this.type.compatibleContent(other.type) } | ||
Node.prototype.defaultContentType = function defaultContentType (at) { | ||
Node.prototype.defaultContentType = function (at) { | ||
var elt = this.contentMatchAt(at).nextElement | ||
@@ -372,7 +372,7 @@ return elt && elt.defaultType() | ||
// Return a JSON-serializeable representation of this node. | ||
Node.prototype.toJSON = function toJSON () { | ||
Node.prototype.toJSON = function () { | ||
var this$1 = this; | ||
var obj = {type: this.type.name} | ||
for (var _ in this.attrs) { | ||
for (var _ in this$1.attrs) { | ||
obj.attrs = this$1.attrs | ||
@@ -390,3 +390,3 @@ break | ||
// Deserialize a node from its JSON representation. | ||
Node.fromJSON = function fromJSON (schema, json) { | ||
Node.fromJSON = function (schema, json) { | ||
var marks = json.marks && json.marks.map(schema.markFromJSON) | ||
@@ -415,15 +415,15 @@ if (json.type == "text") { return schema.text(json.text, marks) } | ||
TextNode.prototype.toString = function toString () { return wrapMarks(this.marks, JSON.stringify(this.text)) }; | ||
TextNode.prototype.toString = function () { return wrapMarks(this.marks, JSON.stringify(this.text)) }; | ||
prototypeAccessors$1.textContent.get = function () { return this.text }; | ||
TextNode.prototype.textBetween = function textBetween (from, to) { return this.text.slice(from, to) }; | ||
TextNode.prototype.textBetween = function (from, to) { return this.text.slice(from, to) }; | ||
prototypeAccessors$1.nodeSize.get = function () { return this.text.length }; | ||
TextNode.prototype.mark = function mark (marks) { | ||
TextNode.prototype.mark = function (marks) { | ||
return new TextNode(this.type, this.attrs, this.text, marks) | ||
}; | ||
TextNode.prototype.withText = function withText (text) { | ||
TextNode.prototype.withText = function (text) { | ||
if (text == this.text) { return this } | ||
@@ -433,3 +433,3 @@ return new TextNode(this.type, this.attrs, text, this.marks) | ||
TextNode.prototype.cut = function cut (from, to) { | ||
TextNode.prototype.cut = function (from, to) { | ||
if ( from === void 0 ) from = 0; | ||
@@ -442,7 +442,7 @@ if ( to === void 0 ) to = this.text.length; | ||
TextNode.prototype.eq = function eq (other) { | ||
TextNode.prototype.eq = function (other) { | ||
return this.sameMarkup(other) && this.text == other.text | ||
}; | ||
TextNode.prototype.toJSON = function toJSON () { | ||
TextNode.prototype.toJSON = function () { | ||
var base = Node.prototype.toJSON.call(this) | ||
@@ -449,0 +449,0 @@ base.text = this.text |
@@ -23,3 +23,3 @@ var ref = require("./fragment"); | ||
// both side are 'open' / cut through. | ||
var Slice = function Slice(content, openLeft, openRight) { | ||
var Slice = function(content, openLeft, openRight) { | ||
// :: Fragment The slice's content nodes. | ||
@@ -41,3 +41,3 @@ this.content = content | ||
Slice.prototype.insertAt = function insertAt (pos, fragment) { | ||
Slice.prototype.insertAt = function (pos, fragment) { | ||
var content = insertInto(this.content, pos + this.openLeft, fragment, null) | ||
@@ -47,11 +47,11 @@ return content && new Slice(content, this.openLeft, this.openRight) | ||
Slice.prototype.removeBetween = function removeBetween (from, to) { | ||
Slice.prototype.removeBetween = function (from, to) { | ||
return new Slice(removeRange(this.content, from + this.openLeft, to + this.openLeft), this.openLeft, this.openRight) | ||
}; | ||
Slice.prototype.eq = function eq (other) { | ||
Slice.prototype.eq = function (other) { | ||
return this.content.eq(other.content) && this.openLeft == other.openLeft && this.openRight == other.openRight | ||
}; | ||
Slice.prototype.toString = function toString () { | ||
Slice.prototype.toString = function () { | ||
return this.content + "(" + this.openLeft + "," + this.openRight + ")" | ||
@@ -62,3 +62,3 @@ }; | ||
// Convert a slice to a JSON-serializable representation. | ||
Slice.prototype.toJSON = function toJSON () { | ||
Slice.prototype.toJSON = function () { | ||
if (!this.content.size) { return null } | ||
@@ -72,3 +72,3 @@ return {content: this.content.toJSON(), | ||
// Deserialize a slice from its JSON representation. | ||
Slice.fromJSON = function fromJSON (schema, json) { | ||
Slice.fromJSON = function (schema, json) { | ||
if (!json) { return Slice.empty } | ||
@@ -81,3 +81,3 @@ return new Slice(Fragment.fromJSON(schema, json.content), json.openLeft, json.openRight) | ||
// open value on both side of the fragment. | ||
Slice.maxOpen = function maxOpen (fragment) { | ||
Slice.maxOpen = function (fragment) { | ||
var openLeft = 0, openRight = 0 | ||
@@ -84,0 +84,0 @@ for (var n = fragment.firstChild; n && !n.isLeaf; n = n.firstChild) { openLeft++ } |
@@ -1,3 +0,1 @@ | ||
var warnedAboutBoundary = false | ||
// ::- You'll often have to '[resolve](#model.Node.resolve)' a | ||
@@ -11,3 +9,3 @@ // position to get the context you need. Objects of this class | ||
// numbers as `this.depth + value`. | ||
var ResolvedPos = function ResolvedPos(pos, path, parentOffset) { | ||
var ResolvedPos = function(pos, path, parentOffset) { | ||
// :: number The position that was resolved. | ||
@@ -25,5 +23,5 @@ this.pos = pos | ||
var prototypeAccessors = { parent: {},atNodeBoundary: {},textOffset: {},nodeAfter: {},nodeBefore: {} }; | ||
var prototypeAccessors = { parent: {},textOffset: {},nodeAfter: {},nodeBefore: {} }; | ||
ResolvedPos.prototype.resolveDepth = function resolveDepth (val) { | ||
ResolvedPos.prototype.resolveDepth = function (val) { | ||
if (val == null) { return this.depth } | ||
@@ -43,3 +41,3 @@ if (val < 0) { return this.depth + val } | ||
// same as `p.parent`. | ||
ResolvedPos.prototype.node = function node (depth) { return this.path[this.resolveDepth(depth) * 3] }; | ||
ResolvedPos.prototype.node = function (depth) { return this.path[this.resolveDepth(depth) * 3] }; | ||
@@ -50,3 +48,3 @@ // :: (?number) → number | ||
// `p.index(0)` is 2 and `p.index(1)` is 3. | ||
ResolvedPos.prototype.index = function index (depth) { return this.path[this.resolveDepth(depth) * 3 + 1] }; | ||
ResolvedPos.prototype.index = function (depth) { return this.path[this.resolveDepth(depth) * 3 + 1] }; | ||
@@ -56,3 +54,3 @@ // :: (?number) → number | ||
// given level. | ||
ResolvedPos.prototype.indexAfter = function indexAfter (depth) { | ||
ResolvedPos.prototype.indexAfter = function (depth) { | ||
depth = this.resolveDepth(depth) | ||
@@ -65,3 +63,3 @@ return this.index(depth) + (depth == this.depth && !this.textOffset ? 0 : 1) | ||
// level. | ||
ResolvedPos.prototype.start = function start (depth) { | ||
ResolvedPos.prototype.start = function (depth) { | ||
depth = this.resolveDepth(depth) | ||
@@ -74,3 +72,3 @@ return depth == 0 ? 0 : this.path[depth * 3 - 1] + 1 | ||
// level. | ||
ResolvedPos.prototype.end = function end (depth) { | ||
ResolvedPos.prototype.end = function (depth) { | ||
depth = this.resolveDepth(depth) | ||
@@ -84,3 +82,3 @@ return this.start(depth) + this.node(depth).content.size | ||
// position. | ||
ResolvedPos.prototype.before = function before (depth) { | ||
ResolvedPos.prototype.before = function (depth) { | ||
depth = this.resolveDepth(depth) | ||
@@ -95,3 +93,3 @@ if (!depth) { throw new RangeError("There is no position before the top-level node") } | ||
// position. | ||
ResolvedPos.prototype.after = function after (depth) { | ||
ResolvedPos.prototype.after = function (depth) { | ||
depth = this.resolveDepth(depth) | ||
@@ -102,10 +100,2 @@ if (!depth) { throw new RangeError("There is no position after the top-level node") } | ||
prototypeAccessors.atNodeBoundary.get = function () { | ||
if (!warnedAboutBoundary && typeof console != "undefined") { | ||
warnedAboutBoundary = true | ||
console.warn("ResolvedPos.atNodeBoundary is deprecated. Use textOffset > 0 instead") | ||
} | ||
return !this.textOffset | ||
}; | ||
// :: number | ||
@@ -142,3 +132,3 @@ // When this position points into a text node, this returns the | ||
// position share the same parent nodes. | ||
ResolvedPos.prototype.sharedDepth = function sharedDepth (pos) { | ||
ResolvedPos.prototype.sharedDepth = function (pos) { | ||
var this$1 = this; | ||
@@ -160,3 +150,3 @@ | ||
// acceptable. | ||
ResolvedPos.prototype.blockRange = function blockRange (other, pred) { | ||
ResolvedPos.prototype.blockRange = function (other, pred) { | ||
var this$1 = this; | ||
@@ -173,7 +163,7 @@ if ( other === void 0 ) other = this; | ||
// Query whether the given position shares the same parent node. | ||
ResolvedPos.prototype.sameParent = function sameParent (other) { | ||
ResolvedPos.prototype.sameParent = function (other) { | ||
return this.pos - this.parentOffset == other.pos - other.parentOffset | ||
}; | ||
ResolvedPos.prototype.toString = function toString () { | ||
ResolvedPos.prototype.toString = function () { | ||
var this$1 = this; | ||
@@ -187,10 +177,3 @@ | ||
ResolvedPos.prototype.plusOne = function plusOne () { | ||
var copy = this.path.slice(), skip = this.nodeAfter.nodeSize | ||
copy[copy.length - 2] += 1 | ||
var pos = copy[copy.length - 1] = this.pos + skip | ||
return new ResolvedPos(pos, copy, this.parentOffset + skip) | ||
}; | ||
ResolvedPos.resolve = function resolve (doc, pos) { | ||
ResolvedPos.resolve = function (doc, pos) { | ||
if (!(pos >= 0 && pos <= doc.content.size)) { throw new RangeError("Position " + pos + " out of range") } | ||
@@ -214,3 +197,3 @@ var path = [] | ||
ResolvedPos.resolveCached = function resolveCached (doc, pos) { | ||
ResolvedPos.resolveCached = function (doc, pos) { | ||
for (var i = 0; i < resolveCache.length; i++) { | ||
@@ -231,3 +214,3 @@ var cached = resolveCache[i] | ||
// ::- Represents a flat range of content. | ||
var NodeRange = function NodeRange($from, $to, depth) { | ||
var NodeRange = function($from, $to, depth) { | ||
// :: ResolvedPos A resolved position along the start of the | ||
@@ -234,0 +217,0 @@ // content. May have a `depth` greater than this object's `depth` |
@@ -0,1 +1,3 @@ | ||
var OrderedMap = require("orderedmap") | ||
var ref = require("./node"); | ||
@@ -10,4 +12,2 @@ var Node = ref.Node; | ||
var ContentExpr = ref$3.ContentExpr; | ||
var ref$4 = require("./orderedmap"); | ||
var OrderedMap = ref$4.OrderedMap; | ||
@@ -56,3 +56,3 @@ // For node types where all attrs have a default value (or which don't | ||
// represents. | ||
var NodeType = function NodeType(name, schema, spec) { | ||
var NodeType = function(name, schema, spec) { | ||
// :: string | ||
@@ -99,6 +99,6 @@ // The name the node type has in this schema. | ||
NodeType.prototype.hasRequiredAttrs = function hasRequiredAttrs (ignore) { | ||
NodeType.prototype.hasRequiredAttrs = function (ignore) { | ||
var this$1 = this; | ||
for (var n in this.attrs) | ||
for (var n in this$1.attrs) | ||
{ if (this$1.attrs[n].isRequired && (!ignore || !(n in ignore))) { return true } } | ||
@@ -108,7 +108,7 @@ return false | ||
NodeType.prototype.compatibleContent = function compatibleContent (other) { | ||
NodeType.prototype.compatibleContent = function (other) { | ||
return this == other || this.contentExpr.compatible(other.contentExpr) | ||
}; | ||
NodeType.prototype.computeAttrs = function computeAttrs$1 (attrs) { | ||
NodeType.prototype.computeAttrs = function (attrs) { | ||
if (!attrs && this.defaultAttrs) { return this.defaultAttrs } | ||
@@ -125,3 +125,3 @@ else { return computeAttrs(this.attrs, attrs) } | ||
// set of marks. | ||
NodeType.prototype.create = function create (attrs, content, marks) { | ||
NodeType.prototype.create = function (attrs, content, marks) { | ||
if (typeof content == "string") { throw new Error("Calling create with string") } | ||
@@ -135,3 +135,3 @@ return new Node(this, this.computeAttrs(attrs), Fragment.from(content), Mark.setFrom(marks)) | ||
// if it doesn't match. | ||
NodeType.prototype.createChecked = function createChecked (attrs, content, marks) { | ||
NodeType.prototype.createChecked = function (attrs, content, marks) { | ||
attrs = this.computeAttrs(attrs) | ||
@@ -151,3 +151,3 @@ content = Fragment.from(content) | ||
// `Fragment.empty` as content. | ||
NodeType.prototype.createAndFill = function createAndFill (attrs, content, marks) { | ||
NodeType.prototype.createAndFill = function (attrs, content, marks) { | ||
attrs = this.computeAttrs(attrs) | ||
@@ -168,7 +168,7 @@ content = Fragment.from(content) | ||
// type with the given attributes. | ||
NodeType.prototype.validContent = function validContent (content, attrs) { | ||
NodeType.prototype.validContent = function (content, attrs) { | ||
return this.contentExpr.matches(attrs, content) | ||
}; | ||
NodeType.compile = function compile (nodes, schema) { | ||
NodeType.compile = function (nodes, schema) { | ||
var result = Object.create(null) | ||
@@ -188,3 +188,3 @@ nodes.forEach(function (name, spec) { return result[name] = new NodeType(name, schema, spec); }) | ||
var Attribute = function Attribute(options) { | ||
var Attribute = function(options) { | ||
this.default = options.default | ||
@@ -207,3 +207,3 @@ this.compute = options.compute | ||
// objects, which are instantiated once per `Schema`. | ||
var MarkType = function MarkType(name, rank, schema, spec) { | ||
var MarkType = function(name, rank, schema, spec) { | ||
// :: string | ||
@@ -232,3 +232,3 @@ // The name of the mark type. | ||
// they have defaults, will be added. | ||
MarkType.prototype.create = function create (attrs) { | ||
MarkType.prototype.create = function (attrs) { | ||
if (!attrs && this.instance) { return this.instance } | ||
@@ -238,3 +238,3 @@ return new Mark(this, computeAttrs(this.attrs, attrs)) | ||
MarkType.compile = function compile (marks, schema) { | ||
MarkType.compile = function (marks, schema) { | ||
var result = Object.create(null), rank = 0 | ||
@@ -248,3 +248,3 @@ marks.forEach(function (name, spec) { return result[name] = new MarkType(name, rank++, schema, spec); }) | ||
// without it is returned. Otherwise, the input set is returned. | ||
MarkType.prototype.removeFromSet = function removeFromSet (set) { | ||
MarkType.prototype.removeFromSet = function (set) { | ||
var this$1 = this; | ||
@@ -260,3 +260,3 @@ | ||
// Tests whether there is a mark of this type in the given set. | ||
MarkType.prototype.isInSet = function isInSet (set) { | ||
MarkType.prototype.isInSet = function (set) { | ||
var this$1 = this; | ||
@@ -377,3 +377,3 @@ | ||
// ::- A document schema. | ||
var Schema = function Schema(spec) { | ||
var Schema = function(spec) { | ||
var this$1 = this; | ||
@@ -394,3 +394,3 @@ | ||
for (var prop in this.nodes) { | ||
for (var prop in this$1.nodes) { | ||
if (prop in this$1.marks) | ||
@@ -418,3 +418,3 @@ { throw new RangeError(prop + " can not be both a node and a mark") } | ||
// `null`, a `Node`, or an array of nodes. | ||
Schema.prototype.node = function node (type, attrs, content, marks) { | ||
Schema.prototype.node = function (type, attrs, content, marks) { | ||
if (typeof type == "string") | ||
@@ -433,5 +433,5 @@ { type = this.nodeType(type) } | ||
// allowed. | ||
Schema.prototype.text = function text (text, marks) { | ||
Schema.prototype.text = function (text$1, marks) { | ||
var type = this.nodes.text | ||
return new TextNode(type, type.defaultAttrs, text, Mark.setFrom(marks)) | ||
return new TextNode(type, type.defaultAttrs, text$1, Mark.setFrom(marks)) | ||
}; | ||
@@ -441,3 +441,3 @@ | ||
// Create a mark with the given type and attributes. | ||
Schema.prototype.mark = function mark (type, attrs) { | ||
Schema.prototype.mark = function (type, attrs) { | ||
if (typeof type == "string") { type = this.marks[type] } | ||
@@ -450,3 +450,3 @@ return type.create(attrs) | ||
// bound. | ||
Schema.prototype.nodeFromJSON = function nodeFromJSON (json) { | ||
Schema.prototype.nodeFromJSON = function (json) { | ||
return Node.fromJSON(this, json) | ||
@@ -458,7 +458,7 @@ }; | ||
// bound. | ||
Schema.prototype.markFromJSON = function markFromJSON (json) { | ||
Schema.prototype.markFromJSON = function (json) { | ||
return Mark.fromJSON(this, json) | ||
}; | ||
Schema.prototype.nodeType = function nodeType (name) { | ||
Schema.prototype.nodeType = function (name) { | ||
var found = this.nodes[name] | ||
@@ -465,0 +465,0 @@ if (!found) { throw new RangeError("Unknown node type: " + name) } |
@@ -19,3 +19,3 @@ // DOMOutputSpec:: interface | ||
// marks of various types to DOM nodes. | ||
var DOMSerializer = function DOMSerializer(nodes, marks) { | ||
var DOMSerializer = function(nodes, marks) { | ||
// :: Object<(node: Node) → DOMOutputSpec> | ||
@@ -32,3 +32,3 @@ this.nodes = nodes || {} | ||
// nodes. | ||
DOMSerializer.prototype.serializeFragment = function serializeFragment (fragment, options, target) { | ||
DOMSerializer.prototype.serializeFragment = function (fragment, options, target) { | ||
var this$1 = this; | ||
@@ -68,3 +68,3 @@ if ( options === void 0 ) options = {}; | ||
// its [`content`](#model.Node.content). | ||
DOMSerializer.prototype.serializeNode = function serializeNode (node, options) { | ||
DOMSerializer.prototype.serializeNode = function (node, options) { | ||
if ( options === void 0 ) options = {}; | ||
@@ -75,3 +75,3 @@ | ||
DOMSerializer.prototype.serializeNodeAndMarks = function serializeNodeAndMarks (node, options) { | ||
DOMSerializer.prototype.serializeNodeAndMarks = function (node, options) { | ||
var this$1 = this; | ||
@@ -89,3 +89,3 @@ if ( options === void 0 ) options = {}; | ||
DOMSerializer.prototype.serializeMark = function serializeMark (mark, options) { | ||
DOMSerializer.prototype.serializeMark = function (mark, options) { | ||
if ( options === void 0 ) options = {}; | ||
@@ -98,3 +98,3 @@ | ||
// Render an [output spec](##model.DOMOutputSpec). | ||
DOMSerializer.renderSpec = function renderSpec (doc, structure) { | ||
DOMSerializer.renderSpec = function (doc, structure) { | ||
if (typeof structure == "string") | ||
@@ -133,3 +133,3 @@ { return {dom: doc.createTextNode(structure)} } | ||
DOMSerializer.prototype.renderStructure = function renderStructure (structure, node, options) { | ||
DOMSerializer.prototype.renderStructure = function (structure, node, options) { | ||
var ref = DOMSerializer.renderSpec(doc(options), structure); | ||
@@ -153,3 +153,3 @@ var dom = ref.dom; | ||
// properties in a schema's node and mark specs. | ||
DOMSerializer.fromSchema = function fromSchema (schema) { | ||
DOMSerializer.fromSchema = function (schema) { | ||
return schema.cached.domSerializer || | ||
@@ -162,3 +162,3 @@ (schema.cached.domSerializer = new DOMSerializer(this.nodesFromSchema(schema), this.marksFromSchema(schema))) | ||
// This can be useful as a base to build a custom serializer from. | ||
DOMSerializer.nodesFromSchema = function nodesFromSchema (schema) { | ||
DOMSerializer.nodesFromSchema = function (schema) { | ||
return gatherToDOM(schema.nodes) | ||
@@ -169,3 +169,3 @@ }; | ||
// Gather the serializers in a schema's mark specs into an object. | ||
DOMSerializer.marksFromSchema = function marksFromSchema (schema) { | ||
DOMSerializer.marksFromSchema = function (schema) { | ||
return gatherToDOM(schema.marks) | ||
@@ -172,0 +172,0 @@ }; |
{ | ||
"name": "prosemirror-model", | ||
"version": "0.15.0", | ||
"version": "0.16.0", | ||
"description": "ProseMirror's document model", | ||
@@ -18,4 +18,7 @@ "main": "dist/index.js", | ||
}, | ||
"dependencies": { | ||
"orderedmap": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"buble": "~0.14.0", | ||
"buble": "^0.15.1", | ||
"mocha": "^3.0.2", | ||
@@ -28,5 +31,5 @@ "ist": "1.0.0", | ||
"test": "mocha test/test-*.js", | ||
"build": "rimraf dist && buble -i src -o dist", | ||
"build": "rimraf dist && buble -i src -o dist --no-named-function-expr", | ||
"prepublish": "npm run build" | ||
} | ||
} |
@@ -225,4 +225,3 @@ const {Fragment} = require("./fragment") | ||
matchType(type, attrs, marks = Mark.none) { | ||
// FIXME `var` to work around Babel bug T7293 | ||
for (var {index, count} = this; index < this.expr.elements.length; index++, count = 0) { | ||
for (let {index, count} = this; index < this.expr.elements.length; index++, count = 0) { | ||
let elt = this.expr.elements[index], max = this.resolveValue(elt.max) | ||
@@ -332,3 +331,2 @@ if (count < max && elt.matchesType(type, attrs, marks, this.attrs, this.expr)) { | ||
findWrapping(target, targetAttrs, targetMarks) { | ||
// FIXME find out how expensive this is. Try to reintroduce caching? | ||
let seen = Object.create(null), first = {match: this, via: null}, active = [first] | ||
@@ -335,0 +333,0 @@ while (active.length) { |
@@ -44,4 +44,2 @@ This module defines ProseMirror's content model, the data structures | ||
@OrderedMap | ||
### DOM Representation | ||
@@ -48,0 +46,0 @@ |
@@ -1,3 +0,1 @@ | ||
let warnedAboutBoundary = false | ||
// ::- You'll often have to '[resolve](#model.Node.resolve)' a | ||
@@ -92,10 +90,2 @@ // position to get the context you need. Objects of this class | ||
get atNodeBoundary() { | ||
if (!warnedAboutBoundary && typeof console != "undefined") { | ||
warnedAboutBoundary = true | ||
console.warn("ResolvedPos.atNodeBoundary is deprecated. Use textOffset > 0 instead") | ||
} | ||
return !this.textOffset | ||
} | ||
// :: number | ||
@@ -167,9 +157,2 @@ // When this position points into a text node, this returns the | ||
plusOne() { | ||
let copy = this.path.slice(), skip = this.nodeAfter.nodeSize | ||
copy[copy.length - 2] += 1 | ||
let pos = copy[copy.length - 1] = this.pos + skip | ||
return new ResolvedPos(pos, copy, this.parentOffset + skip) | ||
} | ||
static resolve(doc, pos) { | ||
@@ -176,0 +159,0 @@ if (!(pos >= 0 && pos <= doc.content.size)) throw new RangeError("Position " + pos + " out of range") |
@@ -0,1 +1,3 @@ | ||
const OrderedMap = require("orderedmap") | ||
const {Node, TextNode} = require("./node") | ||
@@ -5,3 +7,2 @@ const {Fragment} = require("./fragment") | ||
const {ContentExpr} = require("./content") | ||
const {OrderedMap} = require("./orderedmap") | ||
@@ -8,0 +9,0 @@ // For node types where all attrs have a default value (or which don't |
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
223652
1
31
5318
+ Addedorderedmap@^1.0.0
+ Addedorderedmap@1.1.8(transitive)