prosemirror-model
Advanced tools
Comparing version 0.18.0 to 0.19.0
@@ -98,3 +98,3 @@ var ref = require("./fragment"); | ||
ContentExpr.parse = function (nodeType, expr, specs) { | ||
ContentExpr.parse = function (nodeType, expr) { | ||
var this$1 = this; | ||
@@ -117,3 +117,3 @@ | ||
var nodeTypes = expandTypes(nodeType.schema, specs, types[1] ? [types[1]] : types[2].split(/\s*\|\s*/)) | ||
var nodeTypes = expandTypes(nodeType.schema, types[1] ? [types[1]] : types[2].split(/\s*\|\s*/)) | ||
for (var i = 0; i < nodeTypes.length; i++) { | ||
@@ -447,3 +447,3 @@ if (inline == null) { inline = nodeTypes[i].isInline } | ||
function expandTypes(schema, specs, types) { | ||
function expandTypes(schema, types) { | ||
var result = [] | ||
@@ -455,8 +455,7 @@ types.forEach(function (type) { | ||
} else { | ||
specs.forEach(function (name, spec) { | ||
if (spec.group && spec.group.split(" ").indexOf(type) > -1) { | ||
found = schema.nodes[name] | ||
if (result.indexOf(found) == -1) { result.push(found) } | ||
} | ||
}) | ||
for (var name in schema.nodes) { | ||
var nodeType = schema.nodes[name] | ||
if (nodeType.groups.indexOf(type) > -1 && result.indexOf(nodeType) == -1) | ||
{ found = result.push(nodeType) } | ||
} | ||
} | ||
@@ -463,0 +462,0 @@ if (!found) |
@@ -24,8 +24,8 @@ var ref = require("./fragment"); | ||
// parsed—matches this expression. Should contain one or more node | ||
// names followed by single or double slashes. For example | ||
// `"paragraph/"` means the rule only matches when the parent node | ||
// is a paragraph, `"blockquote/paragraph/"` restricts it to be in a | ||
// paragraph that is inside a blockquote, and `"section//"` matches | ||
// any position inside a section—a double slash matches any sequence | ||
// of ancestor nodes. | ||
// names or node group names followed by single or double slashes. | ||
// For example `"paragraph/"` means the rule only matches when the | ||
// parent node is a paragraph, `"blockquote/paragraph/"` restricts | ||
// it to be in a paragraph that is inside a blockquote, and | ||
// `"section//"` matches any position inside a section—a double | ||
// slash matches any sequence of ancestor nodes. | ||
// | ||
@@ -81,3 +81,3 @@ // node:: ?string | ||
// called, and its result used, instead of parsing the node's child | ||
// node. | ||
// nodes. | ||
// | ||
@@ -356,3 +356,3 @@ // preserveWhitespace:: ?bool | ||
var top = this.top | ||
if ((top.type && top.type.isTextblock) || /\S/.test(value)) { | ||
if ((top.type && top.type.inlineContent) || /\S/.test(value)) { | ||
if (!(top.options & OPT_PRESERVE_WS)) { | ||
@@ -440,6 +440,5 @@ value = value.replace(/\s+/g, " ") | ||
this.addAll(contentDOM, sync) | ||
if (sync) { this.sync(sync); this.open-- } | ||
else if (before) { this.marks = before } | ||
this.findAround(dom, contentDOM, true) | ||
} | ||
if (sync) { this.sync(sync); this.open-- } | ||
else if (before) { this.marks = before } | ||
return true | ||
@@ -629,6 +628,7 @@ }; | ||
} else { | ||
var name = depth > 0 || (depth == 0 && useRoot) ? this$1.nodes[depth].type.name | ||
: option && depth >= minDepth ? option.node(depth - minDepth).type.name | ||
var next = depth > 0 || (depth == 0 && useRoot) ? this$1.nodes[depth].type | ||
: option && depth >= minDepth ? option.node(depth - minDepth).type | ||
: null | ||
if (name != part) { return false } | ||
if (!next || (next.name != part && next.groups.indexOf(part) == -1)) | ||
{ return false } | ||
depth-- | ||
@@ -635,0 +635,0 @@ } |
@@ -26,3 +26,3 @@ var ref = require("./fragment"); | ||
// **Never** directly mutate the properties of a `Node` object. See | ||
// [this guide](guide/doc.html) for more information. | ||
// [this guide](/docs/guides/doc/) for more information. | ||
var Node = function(type, attrs, content, marks) { | ||
@@ -49,3 +49,3 @@ // :: NodeType | ||
var prototypeAccessors = { nodeSize: {},childCount: {},textContent: {},firstChild: {},lastChild: {},isBlock: {},isTextblock: {},isInline: {},isText: {},isLeaf: {},isAtom: {} }; | ||
var prototypeAccessors = { nodeSize: {},childCount: {},textContent: {},firstChild: {},lastChild: {},isBlock: {},isTextblock: {},inlineContent: {},isInline: {},isText: {},isLeaf: {},isAtom: {} }; | ||
@@ -57,3 +57,3 @@ // text:: ?string | ||
// The size of this node, as defined by the integer-based [indexing | ||
// scheme](guide/doc.html#indexing). For text nodes, this is the | ||
// scheme](/docs/guides/doc/#indexing). For text nodes, this is the | ||
// amount of characters. For other leaf nodes, it is one. And for | ||
@@ -267,2 +267,6 @@ // non-leaf nodes, it is the size of the content plus two (the start | ||
// :: bool | ||
// True when this node has inline content. | ||
prototypeAccessors.inlineContent.get = function () { return this.type.inlineContent }; | ||
// :: bool | ||
// True when this is an inline node (a text node or a node that can | ||
@@ -269,0 +273,0 @@ // appear among text). |
@@ -124,5 +124,5 @@ var ref = require("./mark"); | ||
// Get the marks at this position, factoring in the surrounding | ||
// marks' inclusiveRight property. If the position is at the start | ||
// of a non-empty node, or `after` is true, the marks of the node | ||
// after it (if any) are returned. | ||
// marks' [`inclusive`](##model.MarkSpec.inclusive) property. If the | ||
// position is at the start of a non-empty node, or `after` is true, | ||
// the marks of the node after it (if any) are returned. | ||
ResolvedPos.prototype.marks = function (after) { | ||
@@ -133,9 +133,18 @@ var parent = this.parent, index = this.index() | ||
if (parent.content.size == 0) { return Mark.none } | ||
// When inside a text node or at the start of the parent node, return the node's marks | ||
if ((after && index < parent.childCount) || index == 0 || this.textOffset) | ||
{ return parent.child(index).marks } | ||
var marks = parent.child(index - 1).marks | ||
for (var i = 0; i < marks.length; i++) { if (marks[i].type.spec.inclusiveRight === false) | ||
{ marks = marks[i--].removeFromSet(marks) } } | ||
// When inside a text node, just return the text node's marks | ||
if (this.textOffset) { return parent.child(index).marks } | ||
var main = parent.maybeChild(index - 1), other = parent.maybeChild(index) | ||
// If the `after` flag is true of there is no node before, make | ||
// the node after this position the main reference. | ||
if ((after && other) || !main) { var tmp = main; main = other; other = tmp } | ||
// Use all marks in the main node, except those that have | ||
// `inclusive` set to false and are not present in the other node. | ||
var marks = main.marks | ||
for (var i = 0; i < marks.length; i++) | ||
{ if (marks[i].type.spec.inclusive === false && (!other || !marks[i].isInSet(other.marks))) | ||
{ marks = marks[i--].removeFromSet(marks) } } | ||
return marks | ||
@@ -169,3 +178,3 @@ }; | ||
if (other.pos < this.pos) { return other.blockRange(this) } | ||
for (var d = this.depth - (this.parent.isTextblock || this.pos == other.pos ? 1 : 0); d >= 0; d--) | ||
for (var d = this.depth - (this.parent.inlineContent || this.pos == other.pos ? 1 : 0); d >= 0; d--) | ||
{ if (other.pos <= this$1.end(d) && (!pred || pred(this$1.node(d)))) | ||
@@ -172,0 +181,0 @@ { return new NodeRange(this$1, other, d) } } |
@@ -68,2 +68,3 @@ var OrderedMap = require("orderedmap") | ||
this.groups = spec.group ? spec.group.split(" ") : [] | ||
this.attrs = initAttrs(spec.attrs) | ||
@@ -83,3 +84,3 @@ | ||
var prototypeAccessors = { isInline: {},isTextblock: {},isLeaf: {},isAtom: {} }; | ||
var prototypeAccessors = { isInline: {},isTextblock: {},inlineContent: {},isLeaf: {},isAtom: {} }; | ||
@@ -96,2 +97,6 @@ // :: bool | ||
// :: bool | ||
// True if this node type has inline content. | ||
prototypeAccessors.inlineContent.get = function () { return this.contentExpr.inlineContent }; | ||
// :: bool | ||
// True for node types that allow no content. | ||
@@ -131,2 +136,3 @@ prototypeAccessors.isLeaf.get = function () { return this.contentExpr.isLeaf }; | ||
if (typeof content == "string") { throw new Error("Calling create with string") } | ||
if (this.isText) { throw new Error("NodeType.create can't construct text nodes") } | ||
return new Node(this, this.computeAttrs(attrs), Fragment.from(content), Mark.setFrom(marks)) | ||
@@ -206,2 +212,4 @@ }; | ||
var warnedAboutInclusive = false | ||
// ::- Like nodes, marks (which are associated with nodes to signify | ||
@@ -223,2 +231,10 @@ // 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) | ||
@@ -294,3 +310,3 @@ | ||
// The content expression for this node, as described in the [schema | ||
// guide](guide/schema.html). When not given, the node does not allow | ||
// guide](/docs/guides/schema/). When not given, the node does not allow | ||
// any content. | ||
@@ -320,8 +336,4 @@ // | ||
// draggable:: ?bool | ||
// Determines whether nodes of this type can be dragged. Enabling it | ||
// causes ProseMirror to set a `draggable` attribute on its DOM | ||
// representation, and to put its HTML serialization into the drag | ||
// event's [data | ||
// transfer](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer) | ||
// when dragged. Defaults to false. | ||
// Determines whether nodes of this type can be dragged without | ||
// being selected. Defaults to false. | ||
// | ||
@@ -345,3 +357,3 @@ // code:: ?bool | ||
// to DOM/HTML (as used by | ||
// [`DOMSerializer.fromSchema`](#model.DOMSerializer^fromSchema). | ||
// [`DOMSerializer.fromSchema`](#model.DOMSerializer^fromSchema)). | ||
// Should return an [array structure](#model.DOMOutputSpec) that | ||
@@ -352,2 +364,7 @@ // describes the resulting DOM structure, with an optional number | ||
// | ||
// For text nodes, the default is to create a text DOM node. Though | ||
// it is possible to create a serializer where text is rendered | ||
// differently, this is not supported inside the editor, so you | ||
// shouldn't override that in your text node spec. | ||
// | ||
// parseDOM:: ?[ParseRule] | ||
@@ -366,5 +383,5 @@ // Associates DOM parser information with this node, which can be | ||
// | ||
// inclusiveRight:: ?bool | ||
// inclusive:: ?bool | ||
// Whether this mark should be active when the cursor is positioned | ||
// at the end of the mark. Defaults to true. | ||
// at the start or end boundary of the mark. Defaults to true. | ||
// | ||
@@ -395,3 +412,3 @@ // excludes:: ?string | ||
// Associates DOM parser information with this mark (see the | ||
// corresponding [node spec field](#model.NodeSpec.parseDOM). The | ||
// corresponding [node spec field](#model.NodeSpec.parseDOM)). The | ||
// `mark` field in the rules is implied. | ||
@@ -441,3 +458,3 @@ | ||
var type = this$1.nodes[prop$1] | ||
type.contentExpr = ContentExpr.parse(type, this$1.spec.nodes.get(prop$1).content || "", this$1.spec.nodes) | ||
type.contentExpr = ContentExpr.parse(type, this$1.spec.nodes.get(prop$1).content || "") | ||
} | ||
@@ -465,14 +482,2 @@ for (var prop$2 in this$1.marks) { | ||
var prototypeAccessors$2 = { nodeSpec: {},markSpec: {} }; | ||
prototypeAccessors$2.nodeSpec.get = function () { | ||
warnAboutSpec() | ||
return this.spec.nodes | ||
}; | ||
prototypeAccessors$2.markSpec.get = function () { | ||
warnAboutSpec() | ||
return this.spec.marks | ||
}; | ||
// :: (union<string, NodeType>, ?Object, ?union<Fragment, Node, [Node]>, ?[Mark]) → Node | ||
@@ -528,12 +533,2 @@ // Create a node in this schema. The `type` may be a string or a | ||
}; | ||
Object.defineProperties( Schema.prototype, prototypeAccessors$2 ); | ||
exports.Schema = Schema | ||
var warnedAboutSpec = false | ||
function warnAboutSpec() { | ||
if (!warnedAboutSpec && typeof console != "undefined" && console.warn) { | ||
warnedAboutSpec = true | ||
console.warn("The Schema properties .nodeSpec and .markSpec are deprecated. Use .spec.nodes and .spec.marks instead") | ||
} | ||
} |
@@ -29,3 +29,3 @@ // DOMOutputSpec:: interface | ||
// not in the browser, the `document` option, containing a DOM | ||
// document, should be passed so that the serialize can create | ||
// document, should be passed so that the serializer can create | ||
// nodes. | ||
@@ -156,3 +156,5 @@ DOMSerializer.prototype.serializeFragment = function (fragment, options, target) { | ||
DOMSerializer.nodesFromSchema = function (schema) { | ||
return gatherToDOM(schema.nodes) | ||
var result = gatherToDOM(schema.nodes) | ||
if (!result.text) { result.text = function (node) { return node.text; } } | ||
return result | ||
}; | ||
@@ -159,0 +161,0 @@ |
{ | ||
"name": "prosemirror-model", | ||
"version": "0.18.0", | ||
"version": "0.19.0", | ||
"description": "ProseMirror's document model", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -83,3 +83,3 @@ const {Fragment} = require("./fragment") | ||
static parse(nodeType, expr, specs) { | ||
static parse(nodeType, expr) { | ||
let elements = [], pos = 0, inline = null | ||
@@ -100,3 +100,3 @@ for (;;) { | ||
let nodeTypes = expandTypes(nodeType.schema, specs, types[1] ? [types[1]] : types[2].split(/\s*\|\s*/)) | ||
let nodeTypes = expandTypes(nodeType.schema, types[1] ? [types[1]] : types[2].split(/\s*\|\s*/)) | ||
for (let i = 0; i < nodeTypes.length; i++) { | ||
@@ -405,3 +405,3 @@ if (inline == null) inline = nodeTypes[i].isInline | ||
function expandTypes(schema, specs, types) { | ||
function expandTypes(schema, types) { | ||
let result = [] | ||
@@ -413,8 +413,7 @@ types.forEach(type => { | ||
} else { | ||
specs.forEach((name, spec) => { | ||
if (spec.group && spec.group.split(" ").indexOf(type) > -1) { | ||
found = schema.nodes[name] | ||
if (result.indexOf(found) == -1) result.push(found) | ||
} | ||
}) | ||
for (let name in schema.nodes) { | ||
let nodeType = schema.nodes[name] | ||
if (nodeType.groups.indexOf(type) > -1 && result.indexOf(nodeType) == -1) | ||
found = result.push(nodeType) | ||
} | ||
} | ||
@@ -421,0 +420,0 @@ if (!found) |
@@ -21,8 +21,8 @@ const {Fragment} = require("./fragment") | ||
// parsed—matches this expression. Should contain one or more node | ||
// names followed by single or double slashes. For example | ||
// `"paragraph/"` means the rule only matches when the parent node | ||
// is a paragraph, `"blockquote/paragraph/"` restricts it to be in a | ||
// paragraph that is inside a blockquote, and `"section//"` matches | ||
// any position inside a section—a double slash matches any sequence | ||
// of ancestor nodes. | ||
// names or node group names followed by single or double slashes. | ||
// For example `"paragraph/"` means the rule only matches when the | ||
// parent node is a paragraph, `"blockquote/paragraph/"` restricts | ||
// it to be in a paragraph that is inside a blockquote, and | ||
// `"section//"` matches any position inside a section—a double | ||
// slash matches any sequence of ancestor nodes. | ||
// | ||
@@ -78,3 +78,3 @@ // node:: ?string | ||
// called, and its result used, instead of parsing the node's child | ||
// node. | ||
// nodes. | ||
// | ||
@@ -346,3 +346,3 @@ // preserveWhitespace:: ?bool | ||
let top = this.top | ||
if ((top.type && top.type.isTextblock) || /\S/.test(value)) { | ||
if ((top.type && top.type.inlineContent) || /\S/.test(value)) { | ||
if (!(top.options & OPT_PRESERVE_WS)) { | ||
@@ -426,6 +426,5 @@ value = value.replace(/\s+/g, " ") | ||
this.addAll(contentDOM, sync) | ||
if (sync) { this.sync(sync); this.open-- } | ||
else if (before) this.marks = before | ||
this.findAround(dom, contentDOM, true) | ||
} | ||
if (sync) { this.sync(sync); this.open-- } | ||
else if (before) this.marks = before | ||
return true | ||
@@ -595,6 +594,7 @@ } | ||
} else { | ||
let name = depth > 0 || (depth == 0 && useRoot) ? this.nodes[depth].type.name | ||
: option && depth >= minDepth ? option.node(depth - minDepth).type.name | ||
let next = depth > 0 || (depth == 0 && useRoot) ? this.nodes[depth].type | ||
: option && depth >= minDepth ? option.node(depth - minDepth).type | ||
: null | ||
if (name != part) return false | ||
if (!next || (next.name != part && next.groups.indexOf(part) == -1)) | ||
return false | ||
depth-- | ||
@@ -601,0 +601,0 @@ } |
@@ -20,3 +20,3 @@ const {Fragment} = require("./fragment") | ||
// **Never** directly mutate the properties of a `Node` object. See | ||
// [this guide](guide/doc.html) for more information. | ||
// [this guide](/docs/guides/doc/) for more information. | ||
class Node { | ||
@@ -49,3 +49,3 @@ constructor(type, attrs, content, marks) { | ||
// The size of this node, as defined by the integer-based [indexing | ||
// scheme](guide/doc.html#indexing). For text nodes, this is the | ||
// scheme](/docs/guides/doc/#indexing). For text nodes, this is the | ||
// amount of characters. For other leaf nodes, it is one. And for | ||
@@ -246,2 +246,6 @@ // non-leaf nodes, it is the size of the content plus two (the start | ||
// :: bool | ||
// True when this node has inline content. | ||
get inlineContent() { return this.type.inlineContent } | ||
// :: bool | ||
// True when this is an inline node (a text node or a node that can | ||
@@ -248,0 +252,0 @@ // appear among text). |
@@ -19,3 +19,3 @@ This module defines ProseMirror's content model, the data structures | ||
Positions in a document can be represented as integer | ||
[offsets](guide/doc.html#indexing). But you'll often want to use a | ||
[offsets](/docs/guides/doc/#indexing). But you'll often want to use a | ||
more convenient representation. | ||
@@ -22,0 +22,0 @@ |
@@ -122,5 +122,5 @@ const {Mark} = require("./mark") | ||
// Get the marks at this position, factoring in the surrounding | ||
// marks' inclusiveRight property. If the position is at the start | ||
// of a non-empty node, or `after` is true, the marks of the node | ||
// after it (if any) are returned. | ||
// marks' [`inclusive`](##model.MarkSpec.inclusive) property. If the | ||
// position is at the start of a non-empty node, or `after` is true, | ||
// the marks of the node after it (if any) are returned. | ||
marks(after) { | ||
@@ -131,9 +131,18 @@ let parent = this.parent, index = this.index() | ||
if (parent.content.size == 0) return Mark.none | ||
// When inside a text node or at the start of the parent node, return the node's marks | ||
if ((after && index < parent.childCount) || index == 0 || this.textOffset) | ||
return parent.child(index).marks | ||
let marks = parent.child(index - 1).marks | ||
for (var i = 0; i < marks.length; i++) if (marks[i].type.spec.inclusiveRight === false) | ||
marks = marks[i--].removeFromSet(marks) | ||
// When inside a text node, just return the text node's marks | ||
if (this.textOffset) return parent.child(index).marks | ||
let main = parent.maybeChild(index - 1), other = parent.maybeChild(index) | ||
// If the `after` flag is true of there is no node before, make | ||
// the node after this position the main reference. | ||
if ((after && other) || !main) { let tmp = main; main = other; other = tmp } | ||
// Use all marks in the main node, except those that have | ||
// `inclusive` set to false and are not present in the other node. | ||
let marks = main.marks | ||
for (var i = 0; i < marks.length; i++) | ||
if (marks[i].type.spec.inclusive === false && (!other || !marks[i].isInSet(other.marks))) | ||
marks = marks[i--].removeFromSet(marks) | ||
return marks | ||
@@ -162,3 +171,3 @@ } | ||
if (other.pos < this.pos) return other.blockRange(this) | ||
for (let d = this.depth - (this.parent.isTextblock || this.pos == other.pos ? 1 : 0); d >= 0; d--) | ||
for (let d = this.depth - (this.parent.inlineContent || this.pos == other.pos ? 1 : 0); d >= 0; d--) | ||
if (other.pos <= this.end(d) && (!pred || pred(this.node(d)))) | ||
@@ -165,0 +174,0 @@ return new NodeRange(this, other, d) |
@@ -64,2 +64,3 @@ const OrderedMap = require("orderedmap") | ||
this.groups = spec.group ? spec.group.split(" ") : [] | ||
this.attrs = initAttrs(spec.attrs) | ||
@@ -89,2 +90,6 @@ | ||
// :: bool | ||
// True if this node type has inline content. | ||
get inlineContent() { return this.contentExpr.inlineContent } | ||
// :: bool | ||
// True for node types that allow no content. | ||
@@ -122,2 +127,3 @@ get isLeaf() { return this.contentExpr.isLeaf } | ||
if (typeof content == "string") throw new Error("Calling create with string") | ||
if (this.isText) throw new Error("NodeType.create can't construct text nodes") | ||
return new Node(this, this.computeAttrs(attrs), Fragment.from(content), Mark.setFrom(marks)) | ||
@@ -194,2 +200,4 @@ } | ||
let warnedAboutInclusive = false | ||
// ::- Like nodes, marks (which are associated with nodes to signify | ||
@@ -212,2 +220,10 @@ // 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) | ||
@@ -280,3 +296,3 @@ | ||
// The content expression for this node, as described in the [schema | ||
// guide](guide/schema.html). When not given, the node does not allow | ||
// guide](/docs/guides/schema/). When not given, the node does not allow | ||
// any content. | ||
@@ -306,8 +322,4 @@ // | ||
// draggable:: ?bool | ||
// Determines whether nodes of this type can be dragged. Enabling it | ||
// causes ProseMirror to set a `draggable` attribute on its DOM | ||
// representation, and to put its HTML serialization into the drag | ||
// event's [data | ||
// transfer](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer) | ||
// when dragged. Defaults to false. | ||
// Determines whether nodes of this type can be dragged without | ||
// being selected. Defaults to false. | ||
// | ||
@@ -331,3 +343,3 @@ // code:: ?bool | ||
// to DOM/HTML (as used by | ||
// [`DOMSerializer.fromSchema`](#model.DOMSerializer^fromSchema). | ||
// [`DOMSerializer.fromSchema`](#model.DOMSerializer^fromSchema)). | ||
// Should return an [array structure](#model.DOMOutputSpec) that | ||
@@ -338,2 +350,7 @@ // describes the resulting DOM structure, with an optional number | ||
// | ||
// For text nodes, the default is to create a text DOM node. Though | ||
// it is possible to create a serializer where text is rendered | ||
// differently, this is not supported inside the editor, so you | ||
// shouldn't override that in your text node spec. | ||
// | ||
// parseDOM:: ?[ParseRule] | ||
@@ -352,5 +369,5 @@ // Associates DOM parser information with this node, which can be | ||
// | ||
// inclusiveRight:: ?bool | ||
// inclusive:: ?bool | ||
// Whether this mark should be active when the cursor is positioned | ||
// at the end of the mark. Defaults to true. | ||
// at the start or end boundary of the mark. Defaults to true. | ||
// | ||
@@ -381,3 +398,3 @@ // excludes:: ?string | ||
// Associates DOM parser information with this mark (see the | ||
// corresponding [node spec field](#model.NodeSpec.parseDOM). The | ||
// corresponding [node spec field](#model.NodeSpec.parseDOM)). The | ||
// `mark` field in the rules is implied. | ||
@@ -428,3 +445,3 @@ | ||
let type = this.nodes[prop] | ||
type.contentExpr = ContentExpr.parse(type, this.spec.nodes.get(prop).content || "", this.spec.nodes) | ||
type.contentExpr = ContentExpr.parse(type, this.spec.nodes.get(prop).content || "") | ||
} | ||
@@ -452,12 +469,2 @@ for (let prop in this.marks) { | ||
get nodeSpec() { | ||
warnAboutSpec() | ||
return this.spec.nodes | ||
} | ||
get markSpec() { | ||
warnAboutSpec() | ||
return this.spec.marks | ||
} | ||
// :: (union<string, NodeType>, ?Object, ?union<Fragment, Node, [Node]>, ?[Mark]) → Node | ||
@@ -515,9 +522,1 @@ // Create a node in this schema. The `type` may be a string or a | ||
exports.Schema = Schema | ||
let warnedAboutSpec = false | ||
function warnAboutSpec() { | ||
if (!warnedAboutSpec && typeof console != "undefined" && console.warn) { | ||
warnedAboutSpec = true | ||
console.warn("The Schema properties .nodeSpec and .markSpec are deprecated. Use .spec.nodes and .spec.marks instead") | ||
} | ||
} |
@@ -34,3 +34,3 @@ // DOMOutputSpec:: interface | ||
// not in the browser, the `document` option, containing a DOM | ||
// document, should be passed so that the serialize can create | ||
// document, should be passed so that the serializer can create | ||
// nodes. | ||
@@ -147,3 +147,5 @@ serializeFragment(fragment, options = {}, target) { | ||
static nodesFromSchema(schema) { | ||
return gatherToDOM(schema.nodes) | ||
let result = gatherToDOM(schema.nodes) | ||
if (!result.text) result.text = node => node.text | ||
return result | ||
} | ||
@@ -150,0 +152,0 @@ |
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
238368
5637