prosemirror-view 1.32.0 → 1.32.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 +8 -0
- package/dist/index.cjs +17 -11
- package/dist/index.js +8 -3
- package/package.json +1 -1
- package/src/capturekeys.ts +6 -2
- package/style/prosemirror.css +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 1.32.1 (2023-10-13)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Work around a Chrome issue where it didn't draw a selection for inline leaf nodes when selecting across them.
|
|
6
|
+
|
|
7
|
+
Override the native behavior when shift-selecting horizontally across non-text inline nodes, since most browsers behave poorly here.
|
|
8
|
+
|
|
1
9
|
## 1.32.0 (2023-09-27)
|
|
2
10
|
|
|
3
11
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -2746,24 +2746,31 @@ function selectHorizontally(view, dir, mods) {
|
|
|
2746
2746
|
var sel = view.state.selection;
|
|
2747
2747
|
|
|
2748
2748
|
if (sel instanceof prosemirrorState.TextSelection) {
|
|
2749
|
-
if (
|
|
2749
|
+
if (mods.indexOf("s") > -1) {
|
|
2750
|
+
var $head = sel.$head,
|
|
2751
|
+
node = $head.textOffset ? null : dir < 0 ? $head.nodeBefore : $head.nodeAfter;
|
|
2752
|
+
if (!node || node.isText || !node.isLeaf) return false;
|
|
2753
|
+
var $newHead = view.state.doc.resolve($head.pos + node.nodeSize * (dir < 0 ? -1 : 1));
|
|
2754
|
+
return apply(view, new prosemirrorState.TextSelection(sel.$anchor, $newHead));
|
|
2755
|
+
} else if (!sel.empty) {
|
|
2750
2756
|
return false;
|
|
2751
2757
|
} else if (view.endOfTextblock(dir > 0 ? "forward" : "backward")) {
|
|
2752
2758
|
var next = moveSelectionBlock(view.state, dir);
|
|
2753
2759
|
if (next && next instanceof prosemirrorState.NodeSelection) return apply(view, next);
|
|
2754
2760
|
return false;
|
|
2755
2761
|
} else if (!(mac && mods.indexOf("m") > -1)) {
|
|
2756
|
-
var $head = sel.$head,
|
|
2757
|
-
|
|
2762
|
+
var _$head = sel.$head,
|
|
2763
|
+
_node = _$head.textOffset ? null : dir < 0 ? _$head.nodeBefore : _$head.nodeAfter,
|
|
2758
2764
|
desc;
|
|
2759
|
-
if (!node || node.isText) return false;
|
|
2760
|
-
var nodePos = dir < 0 ? $head.pos - node.nodeSize : $head.pos;
|
|
2761
|
-
if (!(node.isAtom || (desc = view.docView.descAt(nodePos)) && !desc.contentDOM)) return false;
|
|
2762
2765
|
|
|
2763
|
-
if (
|
|
2764
|
-
|
|
2766
|
+
if (!_node || _node.isText) return false;
|
|
2767
|
+
var nodePos = dir < 0 ? _$head.pos - _node.nodeSize : _$head.pos;
|
|
2768
|
+
if (!(_node.isAtom || (desc = view.docView.descAt(nodePos)) && !desc.contentDOM)) return false;
|
|
2769
|
+
|
|
2770
|
+
if (prosemirrorState.NodeSelection.isSelectable(_node)) {
|
|
2771
|
+
return apply(view, new prosemirrorState.NodeSelection(dir < 0 ? view.state.doc.resolve(_$head.pos - _node.nodeSize) : _$head));
|
|
2765
2772
|
} else if (webkit) {
|
|
2766
|
-
return apply(view, new prosemirrorState.TextSelection(view.state.doc.resolve(dir < 0 ? nodePos : nodePos +
|
|
2773
|
+
return apply(view, new prosemirrorState.TextSelection(view.state.doc.resolve(dir < 0 ? nodePos : nodePos + _node.nodeSize)));
|
|
2767
2774
|
} else {
|
|
2768
2775
|
return false;
|
|
2769
2776
|
}
|
|
@@ -2783,7 +2790,6 @@ function nodeLen(node) {
|
|
|
2783
2790
|
}
|
|
2784
2791
|
|
|
2785
2792
|
function isIgnorable(dom, dir) {
|
|
2786
|
-
if (dom.contentEditable == "false") return true;
|
|
2787
2793
|
var desc = dom.pmViewDesc;
|
|
2788
2794
|
return desc && desc.size == 0 && (dir < 0 || dom.nextSibling || dom.nodeName != "BR");
|
|
2789
2795
|
}
|
|
@@ -3206,7 +3212,7 @@ function parseFromClipboard(view, text, html, plainText, $context) {
|
|
|
3206
3212
|
|
|
3207
3213
|
for (var node = slice.content.firstChild; openStart < slice.openStart && !node.type.spec.isolating; openStart++, node = node.firstChild) {}
|
|
3208
3214
|
|
|
3209
|
-
for (var
|
|
3215
|
+
for (var _node2 = slice.content.lastChild; openEnd < slice.openEnd && !_node2.type.spec.isolating; openEnd++, _node2 = _node2.lastChild) {}
|
|
3210
3216
|
|
|
3211
3217
|
slice = closeSlice(slice, openStart, openEnd);
|
|
3212
3218
|
}
|
package/dist/index.js
CHANGED
|
@@ -2328,7 +2328,14 @@ function apply(view, sel) {
|
|
|
2328
2328
|
function selectHorizontally(view, dir, mods) {
|
|
2329
2329
|
let sel = view.state.selection;
|
|
2330
2330
|
if (sel instanceof TextSelection) {
|
|
2331
|
-
if (
|
|
2331
|
+
if (mods.indexOf("s") > -1) {
|
|
2332
|
+
let { $head } = sel, node = $head.textOffset ? null : dir < 0 ? $head.nodeBefore : $head.nodeAfter;
|
|
2333
|
+
if (!node || node.isText || !node.isLeaf)
|
|
2334
|
+
return false;
|
|
2335
|
+
let $newHead = view.state.doc.resolve($head.pos + node.nodeSize * (dir < 0 ? -1 : 1));
|
|
2336
|
+
return apply(view, new TextSelection(sel.$anchor, $newHead));
|
|
2337
|
+
}
|
|
2338
|
+
else if (!sel.empty) {
|
|
2332
2339
|
return false;
|
|
2333
2340
|
}
|
|
2334
2341
|
else if (view.endOfTextblock(dir > 0 ? "forward" : "backward")) {
|
|
@@ -2372,8 +2379,6 @@ function nodeLen(node) {
|
|
|
2372
2379
|
return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
|
|
2373
2380
|
}
|
|
2374
2381
|
function isIgnorable(dom, dir) {
|
|
2375
|
-
if (dom.contentEditable == "false")
|
|
2376
|
-
return true;
|
|
2377
2382
|
let desc = dom.pmViewDesc;
|
|
2378
2383
|
return desc && desc.size == 0 && (dir < 0 || dom.nextSibling || dom.nodeName != "BR");
|
|
2379
2384
|
}
|
package/package.json
CHANGED
package/src/capturekeys.ts
CHANGED
|
@@ -19,7 +19,12 @@ function apply(view: EditorView, sel: Selection) {
|
|
|
19
19
|
function selectHorizontally(view: EditorView, dir: number, mods: string) {
|
|
20
20
|
let sel = view.state.selection
|
|
21
21
|
if (sel instanceof TextSelection) {
|
|
22
|
-
if (
|
|
22
|
+
if (mods.indexOf("s") > -1) {
|
|
23
|
+
let {$head} = sel, node = $head.textOffset ? null : dir < 0 ? $head.nodeBefore : $head.nodeAfter
|
|
24
|
+
if (!node || node.isText || !node.isLeaf) return false
|
|
25
|
+
let $newHead = view.state.doc.resolve($head.pos + node.nodeSize * (dir < 0 ? -1 : 1))
|
|
26
|
+
return apply(view, new TextSelection(sel.$anchor, $newHead))
|
|
27
|
+
} else if (!sel.empty) {
|
|
23
28
|
return false
|
|
24
29
|
} else if (view.endOfTextblock(dir > 0 ? "forward" : "backward")) {
|
|
25
30
|
let next = moveSelectionBlock(view.state, dir)
|
|
@@ -55,7 +60,6 @@ function nodeLen(node: Node) {
|
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
function isIgnorable(dom: Node, dir: number) {
|
|
58
|
-
if ((dom as HTMLElement).contentEditable == "false") return true
|
|
59
63
|
let desc = dom.pmViewDesc
|
|
60
64
|
return desc && desc.size == 0 && (dir < 0 || dom.nextSibling || dom.nodeName != "BR")
|
|
61
65
|
}
|
package/style/prosemirror.css
CHANGED
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
.ProseMirror-hideselection *::-moz-selection { background: transparent; }
|
|
24
24
|
.ProseMirror-hideselection { caret-color: transparent; }
|
|
25
25
|
|
|
26
|
+
/* See https://github.com/ProseMirror/prosemirror/issues/1421#issuecomment-1759320191 */
|
|
27
|
+
.ProseMirror [draggable][contenteditable=false] { user-select: text }
|
|
28
|
+
|
|
26
29
|
.ProseMirror-selectednode {
|
|
27
30
|
outline: 2px solid #8cf;
|
|
28
31
|
}
|