prosemirror-transform
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "prosemirror-transform", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "ProseMirror document transformations", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -30,3 +30,3 @@ import {Fragment, Slice} from "prosemirror-model" | ||
} | ||
return new ReplaceStep(from, to, fitted) | ||
return fitted.size || from != to ? new ReplaceStep(from, to, fitted) : null | ||
} | ||
@@ -437,2 +437,5 @@ | ||
} | ||
// Try to fit each possible depth of the slice into each possible | ||
// target depth, starting with the preferred depths. | ||
let preferredTargetIndex = targetDepths.indexOf(preferredTarget) | ||
@@ -448,10 +451,9 @@ let leftNodes = [], preferredDepth = slice.openStart | ||
// that separated only by a non-defining textblock node, is defining. | ||
if (preferredDepth > 0 && leftNodes[preferredDepth - 1].type.spec.defining) | ||
if (preferredDepth > 0 && leftNodes[preferredDepth - 1].type.spec.defining && | ||
$from.node(preferredTargetIndex).type != leftNodes[preferredDepth - 1].type) | ||
preferredDepth -= 1 | ||
else if (preferredDepth >= 2 && leftNodes[preferredDepth - 1].isTextblock && leftNodes[preferredDepth - 2].type.spec.defining) | ||
else if (preferredDepth >= 2 && leftNodes[preferredDepth - 1].isTextblock && leftNodes[preferredDepth - 2].type.spec.defining && | ||
$from.node(preferredTargetIndex).type != leftNodes[preferredDepth - 2].type) | ||
preferredDepth -= 2 | ||
// Try to fit each possible depth of the slice into each possible | ||
// target depth, starting with the preferred depths. | ||
let preferredTargetIndex = targetDepths.indexOf(preferredTarget) | ||
for (let j = slice.openStart; j >= 0; j--) { | ||
@@ -458,0 +460,0 @@ let openDepth = (j + preferredDepth + 1) % (slice.openStart + 1) |
@@ -63,7 +63,9 @@ import {Slice, Fragment} from "prosemirror-model" | ||
// :: (NodeRange, NodeType, ?Object) → ?[{type: NodeType, attrs: ?Object}] | ||
// :: (NodeRange, NodeType, ?Object, ?NodeRange) → ?[{type: NodeType, attrs: ?Object}] | ||
// Try to find a valid way to wrap the content in the given range in a | ||
// node of the given type. May introduce extra nodes around and inside | ||
// the wrapper node, if necessary. Returns null if no valid wrapping | ||
// could be found. | ||
// could be found. When `innerRange` is given, that range's content is | ||
// used as the content to fit into the wrapping, instead of the | ||
// content of `range`. | ||
export function findWrapping(range, nodeType, attrs, innerRange = range) { | ||
@@ -70,0 +72,0 @@ let around = findWrappingOutside(range, nodeType) |
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
272297
19
2925