prosemirror-transform 1.12.0 → 1.12.1
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 +6 -0
- package/CONTRIBUTING.md +19 -19
- package/README.md +3 -3
- package/dist/index.cjs +10 -3
- package/dist/index.js +12 -3
- package/package.json +2 -2
- package/src/replace.ts +11 -4
package/CHANGELOG.md
CHANGED
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
|
@@ -1254,9 +1254,9 @@ var Fitter = function () {
|
|
|
1254
1254
|
content = _this$unplaced.content,
|
|
1255
1255
|
openStart = _this$unplaced.openStart,
|
|
1256
1256
|
openEnd = _this$unplaced.openEnd;
|
|
1257
|
-
|
|
1258
|
-
if (
|
|
1259
|
-
this.unplaced = new prosemirrorModel.Slice(content, openStart + 1,
|
|
1257
|
+
if (maxOpen(content, -1) <= openStart) return false;
|
|
1258
|
+
if (this.unplaced.size > 1 && maxOpen(content, 1) > openEnd) openEnd++;
|
|
1259
|
+
this.unplaced = new prosemirrorModel.Slice(content, openStart + 1, openEnd);
|
|
1260
1260
|
return true;
|
|
1261
1261
|
}
|
|
1262
1262
|
}, {
|
|
@@ -1432,6 +1432,13 @@ function invalidMarks(type, fragment, start) {
|
|
|
1432
1432
|
function definesContent(type) {
|
|
1433
1433
|
return type.spec.defining || type.spec.definingForContent;
|
|
1434
1434
|
}
|
|
1435
|
+
function maxOpen(frag, side) {
|
|
1436
|
+
for (var count = 0;; count++) {
|
|
1437
|
+
var ch = side < 0 ? frag.firstChild : frag.lastChild;
|
|
1438
|
+
if (!ch || ch.isAtom) return count;
|
|
1439
|
+
frag = ch.content;
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1435
1442
|
function _replaceRange(tr, from, to, slice) {
|
|
1436
1443
|
if (!slice.size) return tr.deleteRange(from, to);
|
|
1437
1444
|
var $from = tr.doc.resolve(from),
|
package/dist/index.js
CHANGED
|
@@ -1474,10 +1474,11 @@ class Fitter {
|
|
|
1474
1474
|
}
|
|
1475
1475
|
openMore() {
|
|
1476
1476
|
let { content, openStart, openEnd } = this.unplaced;
|
|
1477
|
-
|
|
1478
|
-
if (!inner.childCount || inner.firstChild.isLeaf)
|
|
1477
|
+
if (maxOpen(content, -1) <= openStart)
|
|
1479
1478
|
return false;
|
|
1480
|
-
this.unplaced
|
|
1479
|
+
if (this.unplaced.size > 1 && maxOpen(content, 1) > openEnd)
|
|
1480
|
+
openEnd++;
|
|
1481
|
+
this.unplaced = new Slice(content, openStart + 1, openEnd);
|
|
1481
1482
|
return true;
|
|
1482
1483
|
}
|
|
1483
1484
|
dropNode() {
|
|
@@ -1647,6 +1648,14 @@ function invalidMarks(type, fragment, start) {
|
|
|
1647
1648
|
function definesContent(type) {
|
|
1648
1649
|
return type.spec.defining || type.spec.definingForContent;
|
|
1649
1650
|
}
|
|
1651
|
+
function maxOpen(frag, side) {
|
|
1652
|
+
for (let count = 0;; count++) {
|
|
1653
|
+
let ch = side < 0 ? frag.firstChild : frag.lastChild;
|
|
1654
|
+
if (!ch || ch.isAtom)
|
|
1655
|
+
return count;
|
|
1656
|
+
frag = ch.content;
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1650
1659
|
function replaceRange(tr, from, to, slice) {
|
|
1651
1660
|
if (!slice.size)
|
|
1652
1661
|
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.1",
|
|
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/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
|
|