prosemirror-transform
Advanced tools
Comparing version 0.13.0 to 0.14.0
@@ -403,6 +403,6 @@ var ref = require("prosemirror-model"); | ||
// to find a fit | ||
var found = findPlacement(curFragment, $from, dFrom) | ||
if (found && (found.depth || noMoreContent(slice, dSlice))) { | ||
var found = findPlacement(curFragment, $from, dFrom, placed) | ||
if (found) { | ||
// If there was a fit, store it, and consider this content placed | ||
if (curFragment.size > 0) { placed[found.depth] = { | ||
if (found.fragment.size > 0) { placed[found.depth] = { | ||
content: found.fragment, | ||
@@ -415,3 +415,3 @@ openRight: dSlice > 0 ? 0 : slice.openRight - dSlice, | ||
unplaced = null | ||
dFrom = Math.max(0, found.depth - 1) | ||
dFrom = found.depth - (curType == $from.node(found.depth).type ? 1 : 0) | ||
} else { | ||
@@ -445,3 +445,3 @@ if (dSlice == 0) { | ||
function findPlacement(fragment, $from, start) { | ||
function findPlacement(fragment, $from, start, placed) { | ||
var hasMarks = false | ||
@@ -452,7 +452,9 @@ for (var i = 0; i < fragment.childCount; i++) | ||
var startMatch = $from.node(d).contentMatchAt($from.indexAfter(d)) | ||
var existing = placed[d] | ||
if (existing) { startMatch = startMatch.matchFragment(existing.content) } | ||
var match = startMatch.fillBefore(fragment) | ||
if (match) { return {depth: d, fragment: match.append(fragment)} } | ||
if (match) { return {depth: d, fragment: (existing ? existing.content.append(match) : match).append(fragment)} } | ||
if (hasMarks) { | ||
var stripped = matchStrippingMarks(startMatch, fragment) | ||
if (stripped) { return {depth: d, fragment: stripped} } | ||
if (stripped) { return {depth: d, fragment: existing ? existing.content.append(stripped) : stripped} } | ||
} | ||
@@ -472,10 +474,1 @@ } | ||
} | ||
function noMoreContent(slice, depth) { | ||
if (depth <= 0) { return true } | ||
for (var i = 0, content = slice.content;; i++) { | ||
var next = content.firstChild | ||
if (i == depth - 1) { return 2 * i + next.nodeSize == slice.content.size } | ||
content = next.content | ||
} | ||
} |
{ | ||
"name": "prosemirror-transform", | ||
"version": "0.13.0", | ||
"version": "0.14.0", | ||
"description": "ProseMirror document transformations", | ||
@@ -19,3 +19,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"prosemirror-model": "^0.13.0" | ||
"prosemirror-model": "^0.14.0" | ||
}, | ||
@@ -22,0 +22,0 @@ "devDependencies": { |
@@ -386,6 +386,6 @@ const {Fragment, Slice} = require("prosemirror-model") | ||
// to find a fit | ||
let found = findPlacement(curFragment, $from, dFrom) | ||
if (found && (found.depth || noMoreContent(slice, dSlice))) { | ||
let found = findPlacement(curFragment, $from, dFrom, placed) | ||
if (found) { | ||
// If there was a fit, store it, and consider this content placed | ||
if (curFragment.size > 0) placed[found.depth] = { | ||
if (found.fragment.size > 0) placed[found.depth] = { | ||
content: found.fragment, | ||
@@ -398,3 +398,3 @@ openRight: dSlice > 0 ? 0 : slice.openRight - dSlice, | ||
unplaced = null | ||
dFrom = Math.max(0, found.depth - 1) | ||
dFrom = found.depth - (curType == $from.node(found.depth).type ? 1 : 0) | ||
} else { | ||
@@ -427,3 +427,3 @@ if (dSlice == 0) { | ||
function findPlacement(fragment, $from, start) { | ||
function findPlacement(fragment, $from, start, placed) { | ||
let hasMarks = false | ||
@@ -434,7 +434,9 @@ for (let i = 0; i < fragment.childCount; i++) | ||
let startMatch = $from.node(d).contentMatchAt($from.indexAfter(d)) | ||
let existing = placed[d] | ||
if (existing) startMatch = startMatch.matchFragment(existing.content) | ||
let match = startMatch.fillBefore(fragment) | ||
if (match) return {depth: d, fragment: match.append(fragment)} | ||
if (match) return {depth: d, fragment: (existing ? existing.content.append(match) : match).append(fragment)} | ||
if (hasMarks) { | ||
let stripped = matchStrippingMarks(startMatch, fragment) | ||
if (stripped) return {depth: d, fragment: stripped} | ||
if (stripped) return {depth: d, fragment: existing ? existing.content.append(stripped) : stripped} | ||
} | ||
@@ -454,10 +456,1 @@ } | ||
} | ||
function noMoreContent(slice, depth) { | ||
if (depth <= 0) return true | ||
for (let i = 0, content = slice.content;; i++) { | ||
let next = content.firstChild | ||
if (i == depth - 1) return 2 * i + next.nodeSize == slice.content.size | ||
content = next.content | ||
} | ||
} |
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
130021
2757
+ Addedprosemirror-model@0.14.1(transitive)
- Removedprosemirror-model@0.13.0(transitive)
Updatedprosemirror-model@^0.14.0