prosemirror-transform 1.12.0 → 1.12.2
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 +12 -0
- package/CONTRIBUTING.md +19 -19
- package/README.md +3 -3
- package/dist/index.cjs +15 -5
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +18 -6
- package/package.json +2 -2
- package/src/attr_step.ts +1 -1
- package/src/map.ts +5 -2
- package/src/replace.ts +11 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 1.12.2 (2026-09-25)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix a bug that caused `StepMap.mapResult` to set deletion flags for insertions adjacent to the mapped position.
|
|
6
|
+
|
|
7
|
+
## 1.12.1 (2026-09-02)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Fix an issue where replace step fitting could create an invalid slice, and then crash or loop forever.
|
|
12
|
+
|
|
1
13
|
## 1.12.0 (2026-03-30)
|
|
2
14
|
|
|
3
15
|
### Bug fixes
|
package/CONTRIBUTING.md
CHANGED
|
@@ -12,7 +12,7 @@ Community discussion, questions, and informal bug reporting is done on the
|
|
|
12
12
|
## Submitting bug reports
|
|
13
13
|
|
|
14
14
|
Report bugs on the
|
|
15
|
-
[
|
|
15
|
+
[issue tracker](https://code.haverbeke.berlin/prosemirror/prosemirror/issues).
|
|
16
16
|
Before reporting a bug, please read these pointers.
|
|
17
17
|
|
|
18
18
|
- The issue tracker is for *bugs*, not requests for help. Questions
|
|
@@ -34,25 +34,28 @@ Before reporting a bug, please read these pointers.
|
|
|
34
34
|
|
|
35
35
|
## Contributing code
|
|
36
36
|
|
|
37
|
+
Code generated by a language model is not welcome in this project.
|
|
38
|
+
Please don't waste my time with it.
|
|
39
|
+
|
|
37
40
|
If you want to make a change that involves a significant overhaul of
|
|
38
41
|
the code or introduces a user-visible new feature, create an
|
|
39
|
-
[
|
|
42
|
+
[issue](https://code.haverbeke.berlin/prosemirror/prosemirror/issues/)
|
|
43
|
+
first with your proposal.
|
|
40
44
|
|
|
41
|
-
- Make sure you have a [
|
|
45
|
+
- Make sure you have a [Codeberg](https://codeberg.org/user/sign_up)
|
|
46
|
+
or [GitHub](https://github.com/signup/free) account.
|
|
47
|
+
|
|
48
|
+
- Use that to create a [code.haverbeke.berlin
|
|
49
|
+
account](https://code.haverbeke.berlin/user/login).
|
|
42
50
|
|
|
43
|
-
- Fork the relevant repository
|
|
44
|
-
([how to fork a repo](https://help.github.com/articles/fork-a-repo))
|
|
51
|
+
- Fork the relevant repository.
|
|
45
52
|
|
|
46
53
|
- Create a local checkout of the code. You can use the
|
|
47
|
-
[main repository](https://
|
|
54
|
+
[main repository](https://code.haverbeke.berlin/prosemirror/prosemirror) to
|
|
48
55
|
easily check out all core modules.
|
|
49
56
|
|
|
50
57
|
- Make your changes, and commit them
|
|
51
58
|
|
|
52
|
-
- Follow the code style of the rest of the project (see below). Run
|
|
53
|
-
`npm run lint` (in the main repository checkout) to make sure that
|
|
54
|
-
the linter is happy.
|
|
55
|
-
|
|
56
59
|
- If your changes are easy to test or likely to regress, add tests in
|
|
57
60
|
the relevant `test/` directory. Either put them in an existing
|
|
58
61
|
`test-*.js` file, if they fit there, or add a new file.
|
|
@@ -60,13 +63,13 @@ the code or introduces a user-visible new feature, create an
|
|
|
60
63
|
- Make sure all tests pass. Run `npm run test` to verify tests pass
|
|
61
64
|
(you will need Node.js v6+).
|
|
62
65
|
|
|
63
|
-
- Submit a pull request
|
|
64
|
-
|
|
66
|
+
- Submit a pull request. Don't put more than one feature/fix in a
|
|
67
|
+
single pull request.
|
|
65
68
|
|
|
66
69
|
By contributing code to ProseMirror you
|
|
67
70
|
|
|
68
71
|
- Agree to license the contributed code under the project's [MIT
|
|
69
|
-
license](https://
|
|
72
|
+
license](https://code.haverbeke.berlin/prosemirror/prosemirror/blob/main/LICENSE).
|
|
70
73
|
|
|
71
74
|
- Confirm that you have the right to contribute and license the code
|
|
72
75
|
in question. (Either you hold all rights on the code, or the rights
|
|
@@ -86,19 +89,16 @@ By contributing code to ProseMirror you
|
|
|
86
89
|
- Follow the surrounding code when it comes to spacing, brace
|
|
87
90
|
placement, etc.
|
|
88
91
|
|
|
89
|
-
- Brace-less single-statement bodies are encouraged
|
|
90
|
-
don't impact readability
|
|
92
|
+
- Brace-less single-statement bodies are encouraged whenever they
|
|
93
|
+
don't impact readability.
|
|
91
94
|
|
|
92
|
-
- [getdocs](https://
|
|
95
|
+
- [getdocs-ts](https://code.haverbeke.berlin/marijn/getdocs-ts)-style doc comments
|
|
93
96
|
above items that are part of the public API.
|
|
94
97
|
|
|
95
98
|
- When documenting non-public items, you can put the type after a
|
|
96
99
|
single colon, so that getdocs doesn't pick it up and add it to the
|
|
97
100
|
API reference.
|
|
98
101
|
|
|
99
|
-
- The linter (`npm run lint`) complains about unused variables and
|
|
100
|
-
functions. Prefix their names with an underscore to muffle it.
|
|
101
|
-
|
|
102
102
|
- ProseMirror does *not* follow JSHint or JSLint prescribed style.
|
|
103
103
|
Patches that try to 'fix' code to pass one of these linters will not
|
|
104
104
|
be accepted.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# prosemirror-transform
|
|
2
2
|
|
|
3
|
-
[ [**WEBSITE**](https://prosemirror.net) | [**ISSUES**](https://
|
|
3
|
+
[ [**WEBSITE**](https://prosemirror.net) | [**ISSUES**](https://code.haverbeke.berlin/prosemirror/prosemirror/issues) | [**FORUM**](https://discuss.prosemirror.net) | [**CHANGELOG**](https://code.haverbeke.berlin/prosemirror/prosemirror-transform/src/branch/main/CHANGELOG.md) ]
|
|
4
4
|
|
|
5
5
|
This is a [core module](https://prosemirror.net/docs/ref/#transform) of [ProseMirror](https://prosemirror.net).
|
|
6
6
|
ProseMirror is a well-behaved rich semantic content editor based on
|
|
@@ -17,10 +17,10 @@ number of [examples](https://prosemirror.net/examples/) and the
|
|
|
17
17
|
[documentation](https://prosemirror.net/docs/).
|
|
18
18
|
|
|
19
19
|
This code is released under an
|
|
20
|
-
[MIT license](https://
|
|
20
|
+
[MIT license](https://code.haverbeke.berlin/prosemirror/prosemirror/src/branch/main/LICENSE).
|
|
21
21
|
There's a [forum](http://discuss.prosemirror.net) for general
|
|
22
22
|
discussion and support requests, and the
|
|
23
|
-
[
|
|
23
|
+
[bug tracker](https://code.haverbeke.berlin/prosemirror/prosemirror/issues)
|
|
24
24
|
is the place to report issues.
|
|
25
25
|
|
|
26
26
|
We aim to be an inclusive, welcoming community. To make that explicit,
|
package/dist/index.cjs
CHANGED
|
@@ -107,8 +107,11 @@ var StepMap = function () {
|
|
|
107
107
|
var result = start + diff + (side < 0 ? 0 : newSize);
|
|
108
108
|
if (simple) return result;
|
|
109
109
|
var recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);
|
|
110
|
-
var del =
|
|
111
|
-
if (
|
|
110
|
+
var del = 0;
|
|
111
|
+
if (oldSize) {
|
|
112
|
+
del |= pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
|
|
113
|
+
if (assoc < 0 ? pos != start : pos != end) del |= DEL_SIDE;
|
|
114
|
+
}
|
|
112
115
|
return new MapResult(result, del, recover);
|
|
113
116
|
}
|
|
114
117
|
diff += newSize - oldSize;
|
|
@@ -1254,9 +1257,9 @@ var Fitter = function () {
|
|
|
1254
1257
|
content = _this$unplaced.content,
|
|
1255
1258
|
openStart = _this$unplaced.openStart,
|
|
1256
1259
|
openEnd = _this$unplaced.openEnd;
|
|
1257
|
-
|
|
1258
|
-
if (
|
|
1259
|
-
this.unplaced = new prosemirrorModel.Slice(content, openStart + 1,
|
|
1260
|
+
if (maxOpen(content, -1) <= openStart) return false;
|
|
1261
|
+
if (this.unplaced.size > 1 && maxOpen(content, 1) > openEnd) openEnd++;
|
|
1262
|
+
this.unplaced = new prosemirrorModel.Slice(content, openStart + 1, openEnd);
|
|
1260
1263
|
return true;
|
|
1261
1264
|
}
|
|
1262
1265
|
}, {
|
|
@@ -1432,6 +1435,13 @@ function invalidMarks(type, fragment, start) {
|
|
|
1432
1435
|
function definesContent(type) {
|
|
1433
1436
|
return type.spec.defining || type.spec.definingForContent;
|
|
1434
1437
|
}
|
|
1438
|
+
function maxOpen(frag, side) {
|
|
1439
|
+
for (var count = 0;; count++) {
|
|
1440
|
+
var ch = side < 0 ? frag.firstChild : frag.lastChild;
|
|
1441
|
+
if (!ch || ch.isAtom) return count;
|
|
1442
|
+
frag = ch.content;
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1435
1445
|
function _replaceRange(tr, from, to, slice) {
|
|
1436
1446
|
if (!slice.size) return tr.deleteRange(from, to);
|
|
1437
1447
|
var $from = tr.doc.resolve(from),
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Node,
|
|
1
|
+
import { Node, Slice, Schema, Fragment, NodeRange, NodeType, Attrs, Mark, MarkType, ContentMatch } from 'prosemirror-model';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
There are several things that positions can be mapped through.
|
|
@@ -853,4 +853,5 @@ would be a no-op (an empty slice over an empty range).
|
|
|
853
853
|
*/
|
|
854
854
|
declare function replaceStep(doc: Node, from: number, to?: number, slice?: Slice): Step | null;
|
|
855
855
|
|
|
856
|
-
export { AddMarkStep, AddNodeMarkStep, AttrStep, DocAttrStep, MapResult,
|
|
856
|
+
export { AddMarkStep, AddNodeMarkStep, AttrStep, DocAttrStep, MapResult, Mapping, RemoveMarkStep, RemoveNodeMarkStep, ReplaceAroundStep, ReplaceStep, Step, StepMap, StepResult, Transform, canJoin, canSplit, dropPoint, findWrapping, insertPoint, joinPoint, liftTarget, replaceStep };
|
|
857
|
+
export type { Mappable };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Node,
|
|
1
|
+
import { Node, Slice, Schema, Fragment, NodeRange, NodeType, Attrs, Mark, MarkType, ContentMatch } from 'prosemirror-model';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
There are several things that positions can be mapped through.
|
|
@@ -853,4 +853,5 @@ would be a no-op (an empty slice over an empty range).
|
|
|
853
853
|
*/
|
|
854
854
|
declare function replaceStep(doc: Node, from: number, to?: number, slice?: Slice): Step | null;
|
|
855
855
|
|
|
856
|
-
export { AddMarkStep, AddNodeMarkStep, AttrStep, DocAttrStep, MapResult,
|
|
856
|
+
export { AddMarkStep, AddNodeMarkStep, AttrStep, DocAttrStep, MapResult, Mapping, RemoveMarkStep, RemoveNodeMarkStep, ReplaceAroundStep, ReplaceStep, Step, StepMap, StepResult, Transform, canJoin, canSplit, dropPoint, findWrapping, insertPoint, joinPoint, liftTarget, replaceStep };
|
|
857
|
+
export type { Mappable };
|
package/dist/index.js
CHANGED
|
@@ -115,9 +115,12 @@ class StepMap {
|
|
|
115
115
|
if (simple)
|
|
116
116
|
return result;
|
|
117
117
|
let recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);
|
|
118
|
-
let del =
|
|
119
|
-
if (
|
|
120
|
-
del |=
|
|
118
|
+
let del = 0;
|
|
119
|
+
if (oldSize) {
|
|
120
|
+
del |= pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
|
|
121
|
+
if (assoc < 0 ? pos != start : pos != end)
|
|
122
|
+
del |= DEL_SIDE;
|
|
123
|
+
}
|
|
121
124
|
return new MapResult(result, del, recover);
|
|
122
125
|
}
|
|
123
126
|
diff += newSize - oldSize;
|
|
@@ -1474,10 +1477,11 @@ class Fitter {
|
|
|
1474
1477
|
}
|
|
1475
1478
|
openMore() {
|
|
1476
1479
|
let { content, openStart, openEnd } = this.unplaced;
|
|
1477
|
-
|
|
1478
|
-
if (!inner.childCount || inner.firstChild.isLeaf)
|
|
1480
|
+
if (maxOpen(content, -1) <= openStart)
|
|
1479
1481
|
return false;
|
|
1480
|
-
this.unplaced
|
|
1482
|
+
if (this.unplaced.size > 1 && maxOpen(content, 1) > openEnd)
|
|
1483
|
+
openEnd++;
|
|
1484
|
+
this.unplaced = new Slice(content, openStart + 1, openEnd);
|
|
1481
1485
|
return true;
|
|
1482
1486
|
}
|
|
1483
1487
|
dropNode() {
|
|
@@ -1647,6 +1651,14 @@ function invalidMarks(type, fragment, start) {
|
|
|
1647
1651
|
function definesContent(type) {
|
|
1648
1652
|
return type.spec.defining || type.spec.definingForContent;
|
|
1649
1653
|
}
|
|
1654
|
+
function maxOpen(frag, side) {
|
|
1655
|
+
for (let count = 0;; count++) {
|
|
1656
|
+
let ch = side < 0 ? frag.firstChild : frag.lastChild;
|
|
1657
|
+
if (!ch || ch.isAtom)
|
|
1658
|
+
return count;
|
|
1659
|
+
frag = ch.content;
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1650
1662
|
function replaceRange(tr, from, to, slice) {
|
|
1651
1663
|
if (!slice.size)
|
|
1652
1664
|
return tr.deleteRange(from, to);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prosemirror-transform",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.2",
|
|
4
4
|
"description": "ProseMirror document transformations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
],
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
24
|
-
"url": "git://
|
|
24
|
+
"url": "git+https://code.haverbeke.berlin/prosemirror/prosemirror-transform.git"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"prosemirror-model": "^1.21.0"
|
package/src/attr_step.ts
CHANGED
package/src/map.ts
CHANGED
|
@@ -106,8 +106,11 @@ export class StepMap implements Mappable {
|
|
|
106
106
|
let result = start + diff + (side < 0 ? 0 : newSize)
|
|
107
107
|
if (simple) return result
|
|
108
108
|
let recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start)
|
|
109
|
-
let del =
|
|
110
|
-
if (
|
|
109
|
+
let del = 0
|
|
110
|
+
if (oldSize) {
|
|
111
|
+
del |= pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS
|
|
112
|
+
if (assoc < 0 ? pos != start : pos != end) del |= DEL_SIDE
|
|
113
|
+
}
|
|
111
114
|
return new MapResult(result, del, recover)
|
|
112
115
|
}
|
|
113
116
|
diff += newSize - oldSize
|
package/src/replace.ts
CHANGED
|
@@ -155,10 +155,9 @@ class Fitter {
|
|
|
155
155
|
|
|
156
156
|
openMore() {
|
|
157
157
|
let {content, openStart, openEnd} = this.unplaced
|
|
158
|
-
|
|
159
|
-
if (
|
|
160
|
-
this.unplaced = new Slice(content, openStart + 1,
|
|
161
|
-
Math.max(openEnd, inner.size + openStart >= content.size - openEnd ? openStart + 1 : 0))
|
|
158
|
+
if (maxOpen(content, -1) <= openStart) return false
|
|
159
|
+
if (this.unplaced.size > 1 && maxOpen(content, 1) > openEnd) openEnd++
|
|
160
|
+
this.unplaced = new Slice(content, openStart + 1, openEnd)
|
|
162
161
|
return true
|
|
163
162
|
}
|
|
164
163
|
|
|
@@ -331,6 +330,14 @@ function definesContent(type: NodeType) {
|
|
|
331
330
|
return type.spec.defining || type.spec.definingForContent
|
|
332
331
|
}
|
|
333
332
|
|
|
333
|
+
function maxOpen(frag: Fragment, side: -1 | 1) {
|
|
334
|
+
for (let count = 0;; count++) {
|
|
335
|
+
let ch = side < 0 ? frag.firstChild : frag.lastChild
|
|
336
|
+
if (!ch || ch.isAtom) return count
|
|
337
|
+
frag = ch.content
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
334
341
|
export function replaceRange(tr: Transform, from: number, to: number, slice: Slice) {
|
|
335
342
|
if (!slice.size) return tr.deleteRange(from, to)
|
|
336
343
|
|