prosemirror-model
Advanced tools
Comparing version 1.15.0 to 1.16.0
@@ -0,1 +1,7 @@ | ||
## 1.16.0 (2021-12-27) | ||
### New features | ||
A new `NodeSpec` property, `whitespace`, allows more control over the way whitespace in the content of the node is parsed. | ||
## 1.15.0 (2021-10-25) | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "prosemirror-model", | ||
"version": "1.15.0", | ||
"version": "1.16.0", | ||
"description": "ProseMirror's document model", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -43,3 +43,3 @@ import {findDiffStart, findDiffEnd} from "./diff" | ||
// :: (number, number, ?string, ?string | ?(leafNode: Node) -> string) → string | ||
// :: (number, number, ?string, ?union<string, (leafNode: Node) → string>) → string | ||
// Extract the text between `from` and `to`. See the same method on | ||
@@ -46,0 +46,0 @@ // [`Node`](#model.Node.textBetween). |
@@ -295,4 +295,5 @@ import {Fragment} from "./fragment" | ||
function wsOptionsFor(preserveWhitespace) { | ||
return (preserveWhitespace ? OPT_PRESERVE_WS : 0) | (preserveWhitespace === "full" ? OPT_PRESERVE_WS_FULL : 0) | ||
function wsOptionsFor(type, preserveWhitespace) { | ||
return (preserveWhitespace ? OPT_PRESERVE_WS : 0) | | ||
(preserveWhitespace === "full" || (preserveWhitespace == null && type && type.whitespace == "pre") ? OPT_PRESERVE_WS_FULL : 0) | ||
} | ||
@@ -383,3 +384,3 @@ | ||
let topNode = options.topNode, topContext | ||
let topOptions = wsOptionsFor(options.preserveWhitespace) | (open ? OPT_OPEN_LEFT : 0) | ||
let topOptions = wsOptionsFor(null, options.preserveWhitespace) | (open ? OPT_OPEN_LEFT : 0) | ||
if (topNode) | ||
@@ -626,3 +627,3 @@ topContext = new NodeContext(topNode.type, topNode.attrs, Mark.none, Mark.none, true, | ||
top.match = top.match && top.match.matchType(type, attrs) | ||
let options = preserveWS == null ? top.options & ~OPT_OPEN_LEFT : wsOptionsFor(preserveWS) | ||
let options = preserveWS == null ? top.options & ~OPT_OPEN_LEFT : wsOptionsFor(type, preserveWS) | ||
if ((top.options & OPT_OPEN_LEFT) && top.content.length == 0) options |= OPT_OPEN_LEFT | ||
@@ -629,0 +630,0 @@ this.nodes.push(new NodeContext(type, attrs, top.activeMarks, top.pendingMarks, solid, null, options)) |
@@ -84,3 +84,3 @@ import {Fragment} from "./fragment" | ||
// :: ((node: Node, pos: number, parent: Node) → ?bool) | ||
// :: ((node: Node, pos: number, parent: Node, index: number) → ?bool) | ||
// Call the given callback for every descendant node. Doesn't | ||
@@ -97,6 +97,6 @@ // descend into a node when the callback returns `false`. | ||
// :: (number, number, ?string, ?string | ?(leafNode: Node) -> string) → string | ||
// :: (number, number, ?string, ?union<string, ?(leafNode: Node) -> string>) → string | ||
// Get all text between positions `from` and `to`. When | ||
// `blockSeparator` is given, it will be inserted whenever a new | ||
// block node is started. When `leafText` is given, it'll be | ||
// `blockSeparator` is given, it will be inserted to separate text | ||
// from different block nodes. When `leafText` is given, it'll be | ||
// inserted for every non-text leaf node encountered. | ||
@@ -103,0 +103,0 @@ textBetween(from, to, blockSeparator, leafText) { |
@@ -105,2 +105,6 @@ import OrderedMap from "orderedmap" | ||
// :: union<"pre", "normal"> | ||
// The node type's [whitespace](#view.NodeSpec.whitespace) option. | ||
get whitespace() { return this.spec.whitespace || (this.spec.code ? "pre" : "normal") } | ||
// :: () → bool | ||
@@ -365,2 +369,13 @@ // Tells you whether this node type has any required attributes. | ||
// | ||
// whitespace:: ?union<"pre", "normal"> | ||
// Controls way whitespace in this a node is parsed. The default is | ||
// `"normal"`, which causes the [DOM parser](#model.DOMParser) to | ||
// collapse whitespace in normal mode, and normalize it (replacing | ||
// newlines and such with spaces) otherwise. `"pre"` causes the | ||
// parser to preserve spaces inside the node. When this option isn't | ||
// given, but [`code`](#model.NodeSpec.code) is true, `whitespace` | ||
// will default to `"pre"`. Note that this option doesn't influence | ||
// the way the node is rendered—that should be handled by `toDOM` | ||
// and/or styling. | ||
// | ||
// defining:: ?bool | ||
@@ -367,0 +382,0 @@ // Determines whether this node is considered an important parent |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
906570
9291