prosemirror-view 1.42.4 → 1.42.5
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 +8 -0
- package/dist/index.cjs +10 -3
- package/dist/index.js +12 -5
- package/package.json +2 -2
- package/src/clipboard.ts +5 -3
- package/src/domchange.ts +12 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 1.42.5 (2026-09-21)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix an issue where some kinds of deletions on Chrome Android were interpreted as Enter presses.
|
|
6
|
+
|
|
7
|
+
Fix a regression where some types of Enter presses on Android would not go through the Enter key handling.
|
|
8
|
+
|
|
1
9
|
## 1.42.4 (2026-09-18)
|
|
2
10
|
|
|
3
11
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -2913,11 +2913,10 @@ function addContext(slice, context) {
|
|
|
2913
2913
|
var type = schema.nodes[array[i]];
|
|
2914
2914
|
if (!type || type.hasRequiredAttrs()) break;
|
|
2915
2915
|
try {
|
|
2916
|
-
type.
|
|
2916
|
+
content = prosemirrorModel.Fragment.from(type.create(array[i + 1], content));
|
|
2917
2917
|
} catch (e) {
|
|
2918
2918
|
break;
|
|
2919
2919
|
}
|
|
2920
|
-
content = prosemirrorModel.Fragment.from(type.create(array[i + 1], content));
|
|
2921
2920
|
openStart++;
|
|
2922
2921
|
openEnd++;
|
|
2923
2922
|
}
|
|
@@ -4891,7 +4890,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
|
|
|
4891
4890
|
var inlineChange = $from.sameParent($to) && $from.parent.inlineContent && $fromA.end() >= change.endA;
|
|
4892
4891
|
if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some(function (n) {
|
|
4893
4892
|
return n.nodeName == "DIV" || n.nodeName == "P";
|
|
4894
|
-
})) || !inlineChange &&
|
|
4893
|
+
})) || !inlineChange && looksLikeEnter(parse.doc, $from.pos, $to.pos)) && view.someProp("handleKeyDown", function (f) {
|
|
4895
4894
|
return f(view, keyEvent(13, "Enter"));
|
|
4896
4895
|
})) {
|
|
4897
4896
|
view.input.lastIOSEnter = 0;
|
|
@@ -5004,6 +5003,14 @@ function looksLikeBackspace(old, start, end, $newStart, $newEnd) {
|
|
|
5004
5003
|
if (!$next.parent.isTextblock || $next.pos > end || skipClosingAndOpening($next, true, false) < end) return false;
|
|
5005
5004
|
return $newStart.parent.content.cut($newStart.parentOffset).eq($next.parent.content);
|
|
5006
5005
|
}
|
|
5006
|
+
function looksLikeEnter(content, from, to) {
|
|
5007
|
+
var newTextlines = 0,
|
|
5008
|
+
newLeaves = 0;
|
|
5009
|
+
content.nodesBetween(from, to, function (node, pos) {
|
|
5010
|
+
if (node.isTextblock && pos >= from && pos < to) newTextlines++;else if (node.isText ? /\S/.test(node.text.slice(Math.max(0, from - pos), Math.min(node.nodeSize, to - pos))) : node.isLeaf) newLeaves++;
|
|
5011
|
+
});
|
|
5012
|
+
return newLeaves == 0 && newTextlines == 1;
|
|
5013
|
+
}
|
|
5007
5014
|
function skipClosingAndOpening($pos, fromEnd, mayOpen) {
|
|
5008
5015
|
var depth = $pos.depth,
|
|
5009
5016
|
end = fromEnd ? $pos.end() : $pos.pos;
|
package/dist/index.js
CHANGED
|
@@ -3084,12 +3084,11 @@ function addContext(slice, context) {
|
|
|
3084
3084
|
if (!type || type.hasRequiredAttrs())
|
|
3085
3085
|
break;
|
|
3086
3086
|
try {
|
|
3087
|
-
type.
|
|
3087
|
+
content = Fragment.from(type.create(array[i + 1], content));
|
|
3088
3088
|
}
|
|
3089
3089
|
catch (e) {
|
|
3090
3090
|
break;
|
|
3091
3091
|
}
|
|
3092
|
-
content = Fragment.from(type.create(array[i + 1], content));
|
|
3093
3092
|
openStart++;
|
|
3094
3093
|
openEnd++;
|
|
3095
3094
|
}
|
|
@@ -5207,9 +5206,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
|
|
|
5207
5206
|
// as being an iOS enter press), just dispatch an Enter key instead.
|
|
5208
5207
|
if (((ios && view.input.lastIOSEnter > Date.now() - 225 &&
|
|
5209
5208
|
(!inlineChange || addedNodes.some(n => n.nodeName == "DIV" || n.nodeName == "P"))) ||
|
|
5210
|
-
(!inlineChange && $from.pos
|
|
5211
|
-
(!$from.sameParent($to) || !$from.parent.inlineContent) &&
|
|
5212
|
-
$from.pos < $to.pos && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", "")))) &&
|
|
5209
|
+
(!inlineChange && looksLikeEnter(parse.doc, $from.pos, $to.pos))) &&
|
|
5213
5210
|
view.someProp("handleKeyDown", f => f(view, keyEvent(13, "Enter")))) {
|
|
5214
5211
|
view.input.lastIOSEnter = 0;
|
|
5215
5212
|
return;
|
|
@@ -5360,6 +5357,16 @@ function looksLikeBackspace(old, start, end, $newStart, $newEnd) {
|
|
|
5360
5357
|
// The fragments after the join point must match
|
|
5361
5358
|
return $newStart.parent.content.cut($newStart.parentOffset).eq($next.parent.content);
|
|
5362
5359
|
}
|
|
5360
|
+
function looksLikeEnter(content, from, to) {
|
|
5361
|
+
let newTextlines = 0, newLeaves = 0;
|
|
5362
|
+
content.nodesBetween(from, to, (node, pos) => {
|
|
5363
|
+
if (node.isTextblock && pos >= from && pos < to)
|
|
5364
|
+
newTextlines++;
|
|
5365
|
+
else if (node.isText ? /\S/.test(node.text.slice(Math.max(0, from - pos), Math.min(node.nodeSize, to - pos))) : node.isLeaf)
|
|
5366
|
+
newLeaves++;
|
|
5367
|
+
});
|
|
5368
|
+
return newLeaves == 0 && newTextlines == 1;
|
|
5369
|
+
}
|
|
5363
5370
|
function skipClosingAndOpening($pos, fromEnd, mayOpen) {
|
|
5364
5371
|
let depth = $pos.depth, end = fromEnd ? $pos.end() : $pos.pos;
|
|
5365
5372
|
while (depth > 0 && (fromEnd || $pos.indexAfter(depth) == $pos.node(depth).childCount)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prosemirror-view",
|
|
3
|
-
"version": "1.42.
|
|
3
|
+
"version": "1.42.5",
|
|
4
4
|
"description": "ProseMirror's view component",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"url": "git+https://code.haverbeke.berlin/prosemirror/prosemirror-view.git"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"prosemirror-model": "^1.25.
|
|
31
|
+
"prosemirror-model": "^1.25.12",
|
|
32
32
|
"prosemirror-state": "^1.0.0",
|
|
33
33
|
"prosemirror-transform": "^1.1.0"
|
|
34
34
|
},
|
package/src/clipboard.ts
CHANGED
|
@@ -270,9 +270,11 @@ function addContext(slice: Slice, context: string) {
|
|
|
270
270
|
for (let i = array.length - 2; i >= 0; i -= 2) {
|
|
271
271
|
let type = schema.nodes[array[i]]
|
|
272
272
|
if (!type || type.hasRequiredAttrs()) break
|
|
273
|
-
try {
|
|
274
|
-
|
|
275
|
-
|
|
273
|
+
try {
|
|
274
|
+
content = Fragment.from(type.create(array[i + 1], content))
|
|
275
|
+
} catch(e) {
|
|
276
|
+
break
|
|
277
|
+
}
|
|
276
278
|
openStart++; openEnd++
|
|
277
279
|
}
|
|
278
280
|
return new Slice(content, openStart, openEnd)
|
package/src/domchange.ts
CHANGED
|
@@ -180,9 +180,7 @@ export function readDOMChange(view: EditorView, from: number, to: number, typeOv
|
|
|
180
180
|
// as being an iOS enter press), just dispatch an Enter key instead.
|
|
181
181
|
if (((browser.ios && view.input.lastIOSEnter > Date.now() - 225 &&
|
|
182
182
|
(!inlineChange || addedNodes.some(n => n.nodeName == "DIV" || n.nodeName == "P"))) ||
|
|
183
|
-
(!inlineChange && $from.pos
|
|
184
|
-
(!$from.sameParent($to) || !$from.parent.inlineContent) &&
|
|
185
|
-
$from.pos < $to.pos && !/\S/.test(parse.doc.textBetween($from.pos, $to.pos, "", "")))) &&
|
|
183
|
+
(!inlineChange && looksLikeEnter(parse.doc, $from.pos, $to.pos))) &&
|
|
186
184
|
view.someProp("handleKeyDown", f => f(view, keyEvent(13, "Enter")))) {
|
|
187
185
|
view.input.lastIOSEnter = 0
|
|
188
186
|
return
|
|
@@ -333,6 +331,17 @@ function looksLikeBackspace(old: Node, start: number, end: number, $newStart: Re
|
|
|
333
331
|
return $newStart.parent.content.cut($newStart.parentOffset).eq($next.parent.content)
|
|
334
332
|
}
|
|
335
333
|
|
|
334
|
+
function looksLikeEnter(content: Node, from: number, to: number) {
|
|
335
|
+
let newTextlines = 0, newLeaves = 0
|
|
336
|
+
content.nodesBetween(from, to, (node, pos) => {
|
|
337
|
+
if (node.isTextblock && pos >= from && pos < to)
|
|
338
|
+
newTextlines++
|
|
339
|
+
else if (node.isText ? /\S/.test(node.text!.slice(Math.max(0, from - pos), Math.min(node.nodeSize, to - pos))) : node.isLeaf)
|
|
340
|
+
newLeaves++
|
|
341
|
+
})
|
|
342
|
+
return newLeaves == 0 && newTextlines == 1
|
|
343
|
+
}
|
|
344
|
+
|
|
336
345
|
function skipClosingAndOpening($pos: ResolvedPos, fromEnd: boolean, mayOpen: boolean) {
|
|
337
346
|
let depth = $pos.depth, end = fromEnd ? $pos.end() : $pos.pos
|
|
338
347
|
while (depth > 0 && (fromEnd || $pos.indexAfter(depth) == $pos.node(depth).childCount)) {
|