prosemirror-transform 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +7 -7
- package/dist/replace.js +15 -2
- package/package.json +4 -3
- package/src/replace.js +13 -0
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
;var assign;
|
|
2
|
-
((assign = require("./transform"), exports.Transform = assign.Transform, exports.TransformError = assign.TransformError))
|
|
2
|
+
((assign = require("./transform"), exports.Transform = assign.Transform, exports.TransformError = assign.TransformError, assign))
|
|
3
3
|
;var assign$1;
|
|
4
|
-
((assign$1 = require("./step"), exports.Step = assign$1.Step, exports.StepResult = assign$1.StepResult))
|
|
4
|
+
((assign$1 = require("./step"), exports.Step = assign$1.Step, exports.StepResult = assign$1.StepResult, assign$1))
|
|
5
5
|
;var assign$2;
|
|
6
|
-
((assign$2 = require("./structure"), exports.joinPoint = assign$2.joinPoint, exports.canJoin = assign$2.canJoin, exports.canSplit = assign$2.canSplit, exports.insertPoint = assign$2.insertPoint, exports.liftTarget = assign$2.liftTarget, exports.findWrapping = assign$2.findWrapping))
|
|
6
|
+
((assign$2 = require("./structure"), exports.joinPoint = assign$2.joinPoint, exports.canJoin = assign$2.canJoin, exports.canSplit = assign$2.canSplit, exports.insertPoint = assign$2.insertPoint, exports.liftTarget = assign$2.liftTarget, exports.findWrapping = assign$2.findWrapping, assign$2))
|
|
7
7
|
;var assign$3;
|
|
8
|
-
((assign$3 = require("./map"), exports.StepMap = assign$3.StepMap, exports.MapResult = assign$3.MapResult, exports.Mapping = assign$3.Mapping))
|
|
8
|
+
((assign$3 = require("./map"), exports.StepMap = assign$3.StepMap, exports.MapResult = assign$3.MapResult, exports.Mapping = assign$3.Mapping, assign$3))
|
|
9
9
|
;var assign$4;
|
|
10
|
-
((assign$4 = require("./mark_step"), exports.AddMarkStep = assign$4.AddMarkStep, exports.RemoveMarkStep = assign$4.RemoveMarkStep))
|
|
10
|
+
((assign$4 = require("./mark_step"), exports.AddMarkStep = assign$4.AddMarkStep, exports.RemoveMarkStep = assign$4.RemoveMarkStep, assign$4))
|
|
11
11
|
;var assign$5;
|
|
12
|
-
((assign$5 = require("./replace_step"), exports.ReplaceStep = assign$5.ReplaceStep, exports.ReplaceAroundStep = assign$5.ReplaceAroundStep))
|
|
12
|
+
((assign$5 = require("./replace_step"), exports.ReplaceStep = assign$5.ReplaceStep, exports.ReplaceAroundStep = assign$5.ReplaceAroundStep, assign$5))
|
|
13
13
|
require("./mark")
|
|
14
14
|
;var assign$6;
|
|
15
|
-
((assign$6 = require("./replace"), exports.replaceStep = assign$6.replaceStep))
|
|
15
|
+
((assign$6 = require("./replace"), exports.replaceStep = assign$6.replaceStep, assign$6))
|
package/dist/replace.js
CHANGED
|
@@ -384,7 +384,7 @@ function placeSlice($from, slice) {
|
|
|
384
384
|
if (dSlice >= 0) {
|
|
385
385
|
if (dSlice > 0) { // Inside slice
|
|
386
386
|
;var assign;
|
|
387
|
-
((assign = nodeLeft(slice.content, dSlice), curType = assign.type, curAttrs = assign.attrs, curFragment = assign.content))
|
|
387
|
+
((assign = nodeLeft(slice.content, dSlice), curType = assign.type, curAttrs = assign.attrs, curFragment = assign.content, assign))
|
|
388
388
|
} else if (dSlice == 0) { // Top of slice
|
|
389
389
|
curFragment = slice.content
|
|
390
390
|
}
|
|
@@ -404,6 +404,9 @@ function placeSlice($from, slice) {
|
|
|
404
404
|
// This will go through the positions in $from, down from dFrom,
|
|
405
405
|
// to find a fit
|
|
406
406
|
var found = findPlacement(curFragment, $from, dFrom, placed)
|
|
407
|
+
if (found && unneccesaryFallthrough($from, dFrom, found.depth, slice, dSlice))
|
|
408
|
+
{ found = null }
|
|
409
|
+
|
|
407
410
|
if (found) {
|
|
408
411
|
// If there was a fit, store it, and consider this content placed
|
|
409
412
|
if (found.fragment.size > 0) { placed[found.depth] = {
|
|
@@ -429,7 +432,7 @@ function placeSlice($from, slice) {
|
|
|
429
432
|
// Store the result for subsequent iterations.
|
|
430
433
|
parents = [{type: top.type, attrs: top.attrs}].concat(wrap)
|
|
431
434
|
;var assign$1;
|
|
432
|
-
((assign$1 = last, curType = assign$1.type, curAttrs = assign$1.attrs))
|
|
435
|
+
((assign$1 = last, curType = assign$1.type, curAttrs = assign$1.attrs, assign$1))
|
|
433
436
|
}
|
|
434
437
|
if (curFragment.size) {
|
|
435
438
|
curFragment = curType.contentExpr.start(curAttrs).fillBefore(curFragment, true).append(curFragment)
|
|
@@ -478,3 +481,13 @@ function matchStrippingMarks(match, fragment) {
|
|
|
478
481
|
}
|
|
479
482
|
return Fragment.from(newNodes)
|
|
480
483
|
}
|
|
484
|
+
|
|
485
|
+
function unneccesaryFallthrough($from, dFrom, dFound, slice, dSlice) {
|
|
486
|
+
if (dSlice < 1) { return false }
|
|
487
|
+
for (; dFrom > dFound; dFrom--) {
|
|
488
|
+
var here = $from.node(dFrom).contentMatchAt($from.indexAfter(dFrom))
|
|
489
|
+
for (var d = dSlice - 1; d >= 0; d--)
|
|
490
|
+
{ if (here.matchNode(nodeLeft(slice.content, d))) { return true } }
|
|
491
|
+
}
|
|
492
|
+
return false
|
|
493
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prosemirror-transform",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "ProseMirror document transformations",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
"url": "git://github.com/prosemirror/prosemirror-transform.git"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"prosemirror-model": "^0.
|
|
19
|
+
"prosemirror-model": "^0.20.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"buble": "^0.15.1",
|
|
23
23
|
"mocha": "^3.0.2",
|
|
24
24
|
"ist": "^1.0.0",
|
|
25
|
-
"rimraf": "^2.5.4"
|
|
25
|
+
"rimraf": "^2.5.4",
|
|
26
|
+
"prosemirror-test-builder": "^0.20.0"
|
|
26
27
|
},
|
|
27
28
|
"scripts": {
|
|
28
29
|
"test": "mocha test/test-*.js",
|
package/src/replace.js
CHANGED
|
@@ -387,6 +387,9 @@ function placeSlice($from, slice) {
|
|
|
387
387
|
// This will go through the positions in $from, down from dFrom,
|
|
388
388
|
// to find a fit
|
|
389
389
|
let found = findPlacement(curFragment, $from, dFrom, placed)
|
|
390
|
+
if (found && unneccesaryFallthrough($from, dFrom, found.depth, slice, dSlice))
|
|
391
|
+
found = null
|
|
392
|
+
|
|
390
393
|
if (found) {
|
|
391
394
|
// If there was a fit, store it, and consider this content placed
|
|
392
395
|
if (found.fragment.size > 0) placed[found.depth] = {
|
|
@@ -460,3 +463,13 @@ function matchStrippingMarks(match, fragment) {
|
|
|
460
463
|
}
|
|
461
464
|
return Fragment.from(newNodes)
|
|
462
465
|
}
|
|
466
|
+
|
|
467
|
+
function unneccesaryFallthrough($from, dFrom, dFound, slice, dSlice) {
|
|
468
|
+
if (dSlice < 1) return false
|
|
469
|
+
for (; dFrom > dFound; dFrom--) {
|
|
470
|
+
let here = $from.node(dFrom).contentMatchAt($from.indexAfter(dFrom))
|
|
471
|
+
for (let d = dSlice - 1; d >= 0; d--)
|
|
472
|
+
if (here.matchNode(nodeLeft(slice.content, d))) return true
|
|
473
|
+
}
|
|
474
|
+
return false
|
|
475
|
+
}
|