prosemirror-transform
Advanced tools
Comparing version
@@ -0,1 +1,9 @@ | ||
## 1.7.1 (2023-01-20) | ||
### Bug fixes | ||
Keep content in isolating nodes inside their parent when fitting a replace step. | ||
`Transform.setNodeMarkup` will no longer clear the node's marks when it isn't given an array of marks. | ||
## 1.7.0 (2022-08-16) | ||
@@ -2,0 +10,0 @@ |
{ | ||
"name": "prosemirror-transform", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"description": "ProseMirror document transformations", | ||
@@ -5,0 +5,0 @@ "type": "module", |
# prosemirror-transform | ||
[ [**WEBSITE**](https://prosemirror.net) | [**ISSUES**](https://github.com/prosemirror/prosemirror/issues) | [**FORUM**](https://discuss.prosemirror.net) | [**GITTER**](https://gitter.im/ProseMirror/prosemirror) | [**CHANGELOG**](https://github.com/ProseMirror/prosemirror-transform/blob/master/CHANGELOG.md) ] | ||
[ [**WEBSITE**](https://prosemirror.net) | [**ISSUES**](https://github.com/prosemirror/prosemirror/issues) | [**FORUM**](https://discuss.prosemirror.net) | [**CHANGELOG**](https://github.com/ProseMirror/prosemirror-transform/blob/master/CHANGELOG.md) ] | ||
@@ -5,0 +5,0 @@ This is a [core module](https://prosemirror.net/docs/ref/#transform) of [ProseMirror](https://prosemirror.net). |
@@ -113,6 +113,17 @@ import {Fragment, Slice, Node, ResolvedPos, NodeType, ContentMatch, Attrs} from "prosemirror-model" | ||
findFittable(): Fittable | undefined { | ||
let startDepth = this.unplaced.openStart | ||
for (let cur = this.unplaced.content, d = 0, openEnd = this.unplaced.openEnd; d < startDepth; d++) { | ||
let node = cur.firstChild! | ||
if (cur.childCount > 1) openEnd = 0 | ||
if (node.type.spec.isolating && openEnd <= d) { | ||
startDepth = d | ||
break | ||
} | ||
cur = node.content | ||
} | ||
// Only try wrapping nodes (pass 2) after finding a place without | ||
// wrapping failed. | ||
for (let pass = 1; pass <= 2; pass++) { | ||
for (let sliceDepth = this.unplaced.openStart; sliceDepth >= 0; sliceDepth--) { | ||
for (let sliceDepth = pass == 1 ? startDepth : this.unplaced.openStart; sliceDepth >= 0; sliceDepth--) { | ||
let fragment, parent = null | ||
@@ -119,0 +130,0 @@ if (sliceDepth) { |
@@ -138,3 +138,3 @@ import {Slice, Fragment, NodeRange, NodeType, Node, Mark, Attrs, ContentMatch} from "prosemirror-model" | ||
export function setNodeMarkup(tr: Transform, pos: number, type: NodeType | undefined | null, | ||
attrs: Attrs | null, marks: readonly Mark[]) { | ||
attrs: Attrs | null, marks: readonly Mark[] | undefined) { | ||
let node = tr.doc.nodeAt(pos) | ||
@@ -141,0 +141,0 @@ if (!node) throw new RangeError("No node at given position") |
@@ -176,3 +176,3 @@ import {Node, NodeType, Mark, MarkType, ContentMatch, Slice, Fragment, NodeRange, Attrs} from "prosemirror-model" | ||
/// When `type` isn't given, the existing node type is preserved, | ||
setNodeMarkup(pos: number, type?: NodeType | null, attrs: Attrs | null = null, marks: readonly Mark[] = []): this { | ||
setNodeMarkup(pos: number, type?: NodeType | null, attrs: Attrs | null = null, marks?: readonly Mark[]): this { | ||
setNodeMarkup(this, pos, type, attrs, marks) | ||
@@ -179,0 +179,0 @@ return this |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
270880
0.52%6250
0.5%