prosemirror-transform 1.2.12 → 1.3.3
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/CHANGELOG.md +26 -0
- package/dist/index.es.js +44 -5
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +44 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/mark_step.js +12 -0
- package/src/replace.js +5 -2
- package/src/replace_step.js +19 -0
- package/src/structure.js +8 -3
package/package.json
CHANGED
package/src/mark_step.js
CHANGED
|
@@ -17,8 +17,14 @@ export class AddMarkStep extends Step {
|
|
|
17
17
|
// :: (number, number, Mark)
|
|
18
18
|
constructor(from, to, mark) {
|
|
19
19
|
super()
|
|
20
|
+
// :: number
|
|
21
|
+
// The start of the marked range.
|
|
20
22
|
this.from = from
|
|
23
|
+
// :: number
|
|
24
|
+
// The end of the marked range.
|
|
21
25
|
this.to = to
|
|
26
|
+
// :: Mark
|
|
27
|
+
// The mark to add.
|
|
22
28
|
this.mark = mark
|
|
23
29
|
}
|
|
24
30
|
|
|
@@ -69,8 +75,14 @@ export class RemoveMarkStep extends Step {
|
|
|
69
75
|
// :: (number, number, Mark)
|
|
70
76
|
constructor(from, to, mark) {
|
|
71
77
|
super()
|
|
78
|
+
// :: number
|
|
79
|
+
// The start of the unmarked range.
|
|
72
80
|
this.from = from
|
|
81
|
+
// :: number
|
|
82
|
+
// The end of the unmarked range.
|
|
73
83
|
this.to = to
|
|
84
|
+
// :: Mark
|
|
85
|
+
// The mark to remove.
|
|
74
86
|
this.mark = mark
|
|
75
87
|
}
|
|
76
88
|
|
package/src/replace.js
CHANGED
|
@@ -417,7 +417,7 @@ Transform.prototype.replaceRange = function(from, to, slice) {
|
|
|
417
417
|
this.replace(from, to, slice)
|
|
418
418
|
if (this.steps.length > startSteps) break
|
|
419
419
|
let depth = targetDepths[i]
|
|
420
|
-
if (
|
|
420
|
+
if (depth < 0) continue
|
|
421
421
|
from = $from.before(depth); to = $to.after(depth)
|
|
422
422
|
}
|
|
423
423
|
return this
|
|
@@ -483,7 +483,10 @@ function coveredDepths($from, $to) {
|
|
|
483
483
|
$to.end(d) > $to.pos + ($to.depth - d) ||
|
|
484
484
|
$from.node(d).type.spec.isolating ||
|
|
485
485
|
$to.node(d).type.spec.isolating) break
|
|
486
|
-
if (start == $to.start(d)
|
|
486
|
+
if (start == $to.start(d) ||
|
|
487
|
+
(d == $from.depth && d == $to.depth && $from.parent.inlineContent && $to.parent.inlineContent &&
|
|
488
|
+
d && $to.start(d - 1) == start - 1))
|
|
489
|
+
result.push(d)
|
|
487
490
|
}
|
|
488
491
|
return result
|
|
489
492
|
}
|
package/src/replace_step.js
CHANGED
|
@@ -15,8 +15,14 @@ export class ReplaceStep extends Step {
|
|
|
15
15
|
// overwriting something they weren't supposed to).
|
|
16
16
|
constructor(from, to, slice, structure) {
|
|
17
17
|
super()
|
|
18
|
+
// :: number
|
|
19
|
+
// The start position of the replaced range.
|
|
18
20
|
this.from = from
|
|
21
|
+
// :: number
|
|
22
|
+
// The end position of the replaced range.
|
|
19
23
|
this.to = to
|
|
24
|
+
// :: Slice
|
|
25
|
+
// The slice to insert.
|
|
20
26
|
this.slice = slice
|
|
21
27
|
this.structure = !!structure
|
|
22
28
|
}
|
|
@@ -84,11 +90,24 @@ export class ReplaceAroundStep extends Step {
|
|
|
84
90
|
// it has in the [`ReplaceStep`](#transform.ReplaceStep) class.
|
|
85
91
|
constructor(from, to, gapFrom, gapTo, slice, insert, structure) {
|
|
86
92
|
super()
|
|
93
|
+
// :: number
|
|
94
|
+
// The start position of the replaced range.
|
|
87
95
|
this.from = from
|
|
96
|
+
// :: number
|
|
97
|
+
// The end position of the replaced range.
|
|
88
98
|
this.to = to
|
|
99
|
+
// :: number
|
|
100
|
+
// The start of preserved range.
|
|
89
101
|
this.gapFrom = gapFrom
|
|
102
|
+
// :: number
|
|
103
|
+
// The end of preserved range.
|
|
90
104
|
this.gapTo = gapTo
|
|
105
|
+
// :: Slice
|
|
106
|
+
// The slice to insert.
|
|
91
107
|
this.slice = slice
|
|
108
|
+
// :: number
|
|
109
|
+
// The position in the slice where the preserved range should be
|
|
110
|
+
// inserted.
|
|
92
111
|
this.insert = insert
|
|
93
112
|
this.structure = !!structure
|
|
94
113
|
}
|
package/src/structure.js
CHANGED
|
@@ -276,9 +276,14 @@ export function dropPoint(doc, pos, slice) {
|
|
|
276
276
|
for (let d = $pos.depth; d >= 0; d--) {
|
|
277
277
|
let bias = d == $pos.depth ? 0 : $pos.pos <= ($pos.start(d + 1) + $pos.end(d + 1)) / 2 ? -1 : 1
|
|
278
278
|
let insertPos = $pos.index(d) + (bias > 0 ? 1 : 0)
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
279
|
+
let parent = $pos.node(d), fits = false
|
|
280
|
+
if (pass == 1) {
|
|
281
|
+
fits = parent.canReplace(insertPos, insertPos, content)
|
|
282
|
+
} else {
|
|
283
|
+
let wrapping = parent.contentMatchAt(insertPos).findWrapping(content.firstChild.type)
|
|
284
|
+
fits = wrapping && parent.canReplaceWith(insertPos, insertPos, wrapping[0])
|
|
285
|
+
}
|
|
286
|
+
if (fits)
|
|
282
287
|
return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d + 1) : $pos.after(d + 1)
|
|
283
288
|
}
|
|
284
289
|
}
|