prosemirror-transform
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -0,1 +1,11 @@ | ||
## 1.1.4 (2019-08-26) | ||
### Bug fixes | ||
[`Mapping.invert`](https://prosemirror.net/docs/ref/#transform.Mapping.invert) is now part of the documented API (it was intented to be public from the start, but a typo prevented it from showing up in the docs). | ||
Fix an issue where a replace could needlessly drop content when the first node of the slice didn't fit the target context. | ||
`replaceRange` now more aggressively expands the replaced region if `replace` fails to place the slice. | ||
## 1.1.3 (2018-07-03) | ||
@@ -2,0 +12,0 @@ |
{ | ||
"name": "prosemirror-transform", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "ProseMirror document transformations", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
# prosemirror-transform | ||
[ [**WEBSITE**](http://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/blob/master/CHANGELOG.md) ] | ||
[ [**WEBSITE**](http://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) ] | ||
@@ -5,0 +5,0 @@ This is a [core module](http://prosemirror.net/docs/ref/#transform) of [ProseMirror](http://prosemirror.net). |
@@ -219,3 +219,3 @@ // Mappable:: interface | ||
// () → Mapping | ||
// :: () → Mapping | ||
// Create an inverted version of this mapping. | ||
@@ -222,0 +222,0 @@ invert() { |
@@ -227,4 +227,7 @@ import {Fragment, Slice} from "prosemirror-model" | ||
let frontier = new Frontier($from) | ||
for (let pass = 1; slice.size && pass <= 3; pass++) | ||
slice = frontier.placeSlice(slice.content, slice.openStart, slice.openEnd, pass) | ||
for (let pass = 1; slice.size && pass <= 3; pass++) { | ||
let value = frontier.placeSlice(slice.content, slice.openStart, slice.openEnd, pass) | ||
if (pass == 3 && value != slice && value.size) pass = 0 // Restart if the 3rd pass made progress but left content | ||
slice = value | ||
} | ||
while (frontier.open.length) frontier.closeNode() | ||
@@ -274,9 +277,5 @@ return frontier.placed | ||
if (pass > 2 && result.size && openStart == 0) { | ||
for (let i = 0; i < result.content.childCount; i++) { | ||
let child = result.content.child(i) | ||
this.placeContent(child.content, 0, | ||
openEnd && i == result.content.childCount.length - 1 ? openEnd - 1 : 0, | ||
pass, child) | ||
} | ||
result = Fragment.empty | ||
let child = result.content.firstChild, single = result.content.childCount == 1 | ||
this.placeContent(child.content, 0, openEnd && single ? openEnd - 1 : 0, pass, child) | ||
result = single ? Fragment.empty : new Slice(result.content.cutByIndex(1), 0, openEnd) | ||
} | ||
@@ -296,3 +295,3 @@ return result | ||
// If pass > 1, it is allowed to wrap the node to help find a | ||
// fit, so if findWrappeing returns something, we add open | ||
// fit, so if findWrapping returns something, we add open | ||
// nodes to the frontier for that wrapping. | ||
@@ -480,3 +479,11 @@ if (pass > 1 && (wrap = open.match.findWrapping(child.type)) && | ||
return this.replace(from, to, slice) | ||
let startSteps = this.steps.length | ||
for (let i = targetDepths.length - 1; i >= 0; i--) { | ||
this.replace(from, to, slice) | ||
if (this.steps.length > startSteps) break | ||
let depth = targetDepths[i] | ||
if (i < 0) continue | ||
from = $from.before(depth); to = $to.after(depth) | ||
} | ||
return this | ||
} | ||
@@ -483,0 +490,0 @@ |
@@ -192,3 +192,3 @@ import {Slice, Fragment} from "prosemirror-model" | ||
} | ||
return this.step(new ReplaceStep(pos, pos, new Slice(before.append(after), depth, depth, true))) | ||
return this.step(new ReplaceStep(pos, pos, new Slice(before.append(after), depth, depth), true)) | ||
} | ||
@@ -195,0 +195,0 @@ |
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
287800
3020