prosemirror-view 1.41.6 → 1.41.8
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 +18 -2
- package/CONTRIBUTING.md +19 -19
- package/README.md +3 -3
- package/dist/index.cjs +14 -7
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +16 -10
- package/package.json +2 -2
- package/src/domobserver.ts +7 -2
- package/src/index.ts +3 -3
- package/src/input.ts +6 -5
- package/src/viewdesc.ts +8 -8
- package/style/prosemirror.css +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## 1.41.8 (2026-04-02)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Make the types reflect that mark and node views should render elements, not any DOM node.
|
|
6
|
+
|
|
7
|
+
Fix a bug causing `dragCopies` to be ignored when it returned false.
|
|
8
|
+
|
|
9
|
+
## 1.41.7 (2026-03-18)
|
|
10
|
+
|
|
11
|
+
### Bug fixes
|
|
12
|
+
|
|
13
|
+
Work around a Chrome bug where it sometimes inserts a random `<br>` node when you press backspace before a widget.
|
|
14
|
+
|
|
15
|
+
Fix a crash that could happen when deleting content during a node drag.
|
|
16
|
+
|
|
1
17
|
## 1.41.6 (2026-02-06)
|
|
2
18
|
|
|
3
19
|
### Bug fixes
|
|
@@ -2068,7 +2084,7 @@ Fixes a problem where triple-clicking the editor would sometimes cause the scrol
|
|
|
2068
2084
|
|
|
2069
2085
|
The `inclusiveLeft` and `inclusiveRight` options to inline decorations were renamed to [`inclusiveStart`](https://prosemirror.net/docs/ref/version/0.20.0.html#view.Decoration^inline^spec.inclusiveStart) and [`inclusiveEnd`](https://prosemirror.net/docs/ref/version/0.20.0.html#view.Decoration^inline^spec.inclusiveEnd) so that they also make sense in right-to-left text. The old names work with a warning until the next release.
|
|
2070
2086
|
|
|
2071
|
-
The default styling for lists and blockquotes was removed from `prosemirror.css`. (They were moved to the [`example-setup`](https://
|
|
2087
|
+
The default styling for lists and blockquotes was removed from `prosemirror.css`. (They were moved to the [`example-setup`](https://code.haverbeke.berlin/prosemirror/prosemirror-example-setup) module.)
|
|
2072
2088
|
|
|
2073
2089
|
### Bug fixes
|
|
2074
2090
|
|
|
@@ -2242,7 +2258,7 @@ Fix DOM parsing for decorated text nodes.
|
|
|
2242
2258
|
|
|
2243
2259
|
The editor view no longer wraps its editable DOM element in a wrapper element. The `ProseMirror` CSS class now applies directly to the editable element. The `ProseMirror-content` CSS class is still present for ease of upgrading but will be dropped in the next release.
|
|
2244
2260
|
|
|
2245
|
-
The editor view no longer draws a drop cursor when dragging content over the editor. The new [`prosemirror-dropcursor`](https://
|
|
2261
|
+
The editor view no longer draws a drop cursor when dragging content over the editor. The new [`prosemirror-dropcursor`](https://code.haverbeke.berlin/prosemirror/prosemirror-dropcursor) module implements this as a plugin.
|
|
2246
2262
|
|
|
2247
2263
|
### Bug fixes
|
|
2248
2264
|
|
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-view
|
|
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-view/src/branch/main/CHANGELOG.md) ]
|
|
4
4
|
|
|
5
5
|
This is a [core module](https://prosemirror.net/docs/ref/#view) of [ProseMirror](https://prosemirror.net).
|
|
6
6
|
ProseMirror is a well-behaved rich semantic content editor based on
|
|
@@ -16,10 +16,10 @@ number of [examples](https://prosemirror.net/examples/) and the
|
|
|
16
16
|
[documentation](https://prosemirror.net/docs/).
|
|
17
17
|
|
|
18
18
|
This code is released under an
|
|
19
|
-
[MIT license](https://
|
|
19
|
+
[MIT license](https://code.haverbeke.berlin/prosemirror/prosemirror/src/branch/main/LICENSE).
|
|
20
20
|
There's a [forum](http://discuss.prosemirror.net) for general
|
|
21
21
|
discussion and support requests, and the
|
|
22
|
-
[
|
|
22
|
+
[bug tracker](https://code.haverbeke.berlin/prosemirror/prosemirror/issues)
|
|
23
23
|
is the place to report issues.
|
|
24
24
|
|
|
25
25
|
We aim to be an inclusive, welcoming community. To make that explicit,
|
package/dist/index.cjs
CHANGED
|
@@ -3183,7 +3183,7 @@ var MouseDown = function () {
|
|
|
3183
3183
|
var targetDesc = target ? view.docView.nearestDesc(target, true) : null;
|
|
3184
3184
|
this.target = targetDesc && targetDesc.nodeDOM.nodeType == 1 ? targetDesc.nodeDOM : null;
|
|
3185
3185
|
var selection = view.state.selection;
|
|
3186
|
-
if (event.button == 0 && targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof prosemirrorState.NodeSelection && selection.from <= targetPos && selection.to > targetPos) this.mightDrag = {
|
|
3186
|
+
if (event.button == 0 && (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof prosemirrorState.NodeSelection && selection.from <= targetPos && selection.to > targetPos)) this.mightDrag = {
|
|
3187
3187
|
node: targetNode,
|
|
3188
3188
|
pos: targetPos,
|
|
3189
3189
|
addAttr: !!(this.target && !this.target.draggable),
|
|
@@ -3462,10 +3462,11 @@ var Dragging = _createClass(function Dragging(slice, move, node) {
|
|
|
3462
3462
|
});
|
|
3463
3463
|
var dragCopyModifier = mac ? "altKey" : "ctrlKey";
|
|
3464
3464
|
function dragMoves(view, event) {
|
|
3465
|
-
var
|
|
3466
|
-
|
|
3465
|
+
var copy;
|
|
3466
|
+
view.someProp("dragCopies", function (test) {
|
|
3467
|
+
copy = copy || test(event);
|
|
3467
3468
|
});
|
|
3468
|
-
return
|
|
3469
|
+
return copy != null ? !copy : !event[dragCopyModifier];
|
|
3469
3470
|
}
|
|
3470
3471
|
handlers.dragstart = function (view, _event) {
|
|
3471
3472
|
var event = _event;
|
|
@@ -4413,7 +4414,13 @@ var DOMObserver = function () {
|
|
|
4413
4414
|
var node = _step3.value;
|
|
4414
4415
|
if (node.nodeName == "BR" && node.parentNode) {
|
|
4415
4416
|
var after = node.nextSibling;
|
|
4416
|
-
|
|
4417
|
+
while (after && after.nodeType == 1) {
|
|
4418
|
+
if (after.contentEditable == "false") {
|
|
4419
|
+
node.parentNode.removeChild(node);
|
|
4420
|
+
break;
|
|
4421
|
+
}
|
|
4422
|
+
after = after.firstChild;
|
|
4423
|
+
}
|
|
4417
4424
|
}
|
|
4418
4425
|
}
|
|
4419
4426
|
} catch (err) {
|
|
@@ -5129,11 +5136,11 @@ var EditorView = function () {
|
|
|
5129
5136
|
value: function updateDraggedNode(dragging, prev) {
|
|
5130
5137
|
var sel = dragging.node,
|
|
5131
5138
|
found = -1;
|
|
5132
|
-
if (this.state.doc.nodeAt(sel.from) == sel.node) {
|
|
5139
|
+
if (sel.from < this.state.doc.content.size && this.state.doc.nodeAt(sel.from) == sel.node) {
|
|
5133
5140
|
found = sel.from;
|
|
5134
5141
|
} else {
|
|
5135
5142
|
var movedPos = sel.from + (this.state.doc.content.size - prev.doc.content.size);
|
|
5136
|
-
var moved = movedPos > 0 && this.state.doc.nodeAt(movedPos);
|
|
5143
|
+
var moved = movedPos > 0 && movedPos < this.state.doc.content.size && this.state.doc.nodeAt(movedPos);
|
|
5137
5144
|
if (moved == sel.node) found = movedPos;
|
|
5138
5145
|
}
|
|
5139
5146
|
this.dragging = new Dragging(dragging.slice, dragging.move, found < 0 ? undefined : prosemirrorState.NodeSelection.create(this.state.doc, found));
|
package/dist/index.d.cts
CHANGED
|
@@ -275,7 +275,7 @@ interface NodeView {
|
|
|
275
275
|
/**
|
|
276
276
|
The outer DOM node that represents the document node.
|
|
277
277
|
*/
|
|
278
|
-
dom:
|
|
278
|
+
dom: HTMLElement;
|
|
279
279
|
/**
|
|
280
280
|
The DOM node that should hold the node's content. Only meaningful
|
|
281
281
|
if the node view also defines a `dom` property and if its node
|
|
@@ -356,7 +356,7 @@ interface MarkView {
|
|
|
356
356
|
/**
|
|
357
357
|
The outer DOM node that represents the document node.
|
|
358
358
|
*/
|
|
359
|
-
dom:
|
|
359
|
+
dom: HTMLElement;
|
|
360
360
|
/**
|
|
361
361
|
The DOM node that should hold the mark's content. When this is not
|
|
362
362
|
present, the `dom` property is used as the content DOM.
|
package/dist/index.d.ts
CHANGED
|
@@ -275,7 +275,7 @@ interface NodeView {
|
|
|
275
275
|
/**
|
|
276
276
|
The outer DOM node that represents the document node.
|
|
277
277
|
*/
|
|
278
|
-
dom:
|
|
278
|
+
dom: HTMLElement;
|
|
279
279
|
/**
|
|
280
280
|
The DOM node that should hold the node's content. Only meaningful
|
|
281
281
|
if the node view also defines a `dom` property and if its node
|
|
@@ -356,7 +356,7 @@ interface MarkView {
|
|
|
356
356
|
/**
|
|
357
357
|
The outer DOM node that represents the document node.
|
|
358
358
|
*/
|
|
359
|
-
dom:
|
|
359
|
+
dom: HTMLElement;
|
|
360
360
|
/**
|
|
361
361
|
The DOM node that should hold the mark's content. When this is not
|
|
362
362
|
present, the `dom` property is used as the content DOM.
|
package/dist/index.js
CHANGED
|
@@ -3353,8 +3353,8 @@ class MouseDown {
|
|
|
3353
3353
|
this.target = targetDesc && targetDesc.nodeDOM.nodeType == 1 ? targetDesc.nodeDOM : null;
|
|
3354
3354
|
let { selection } = view.state;
|
|
3355
3355
|
if (event.button == 0 &&
|
|
3356
|
-
targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||
|
|
3357
|
-
|
|
3356
|
+
(targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||
|
|
3357
|
+
selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos))
|
|
3358
3358
|
this.mightDrag = {
|
|
3359
3359
|
node: targetNode,
|
|
3360
3360
|
pos: targetPos,
|
|
@@ -3703,8 +3703,9 @@ class Dragging {
|
|
|
3703
3703
|
}
|
|
3704
3704
|
const dragCopyModifier = mac ? "altKey" : "ctrlKey";
|
|
3705
3705
|
function dragMoves(view, event) {
|
|
3706
|
-
let
|
|
3707
|
-
|
|
3706
|
+
let copy;
|
|
3707
|
+
view.someProp("dragCopies", test => { copy = copy || test(event); });
|
|
3708
|
+
return copy != null ? !copy : !event[dragCopyModifier];
|
|
3708
3709
|
}
|
|
3709
3710
|
handlers.dragstart = (view, _event) => {
|
|
3710
3711
|
let event = _event;
|
|
@@ -3731,7 +3732,7 @@ handlers.dragstart = (view, _event) => {
|
|
|
3731
3732
|
if (!event.dataTransfer.files.length || !chrome || chrome_version > 120)
|
|
3732
3733
|
event.dataTransfer.clearData();
|
|
3733
3734
|
event.dataTransfer.setData(brokenClipboardAPI ? "Text" : "text/html", dom.innerHTML);
|
|
3734
|
-
// See https://
|
|
3735
|
+
// See https://code.haverbeke.berlin/prosemirror/prosemirror/issues/1156
|
|
3735
3736
|
event.dataTransfer.effectAllowed = "copyMove";
|
|
3736
3737
|
if (!brokenClipboardAPI)
|
|
3737
3738
|
event.dataTransfer.setData("text/plain", text);
|
|
@@ -4730,8 +4731,13 @@ class DOMObserver {
|
|
|
4730
4731
|
for (let node of added)
|
|
4731
4732
|
if (node.nodeName == "BR" && node.parentNode) {
|
|
4732
4733
|
let after = node.nextSibling;
|
|
4733
|
-
|
|
4734
|
-
|
|
4734
|
+
while (after && after.nodeType == 1) {
|
|
4735
|
+
if (after.contentEditable == "false") {
|
|
4736
|
+
node.parentNode.removeChild(node);
|
|
4737
|
+
break;
|
|
4738
|
+
}
|
|
4739
|
+
after = after.firstChild;
|
|
4740
|
+
}
|
|
4735
4741
|
}
|
|
4736
4742
|
}
|
|
4737
4743
|
else if (gecko && added.length) {
|
|
@@ -5360,7 +5366,7 @@ class EditorView {
|
|
|
5360
5366
|
this.pluginViews = [];
|
|
5361
5367
|
/**
|
|
5362
5368
|
Holds `true` when a hack node is needed in Firefox to prevent the
|
|
5363
|
-
[space is eaten issue](https://
|
|
5369
|
+
[space is eaten issue](https://code.haverbeke.berlin/prosemirror/prosemirror/issues/651)
|
|
5364
5370
|
@internal
|
|
5365
5371
|
*/
|
|
5366
5372
|
this.requiresGeckoHackNode = false;
|
|
@@ -5578,12 +5584,12 @@ class EditorView {
|
|
|
5578
5584
|
}
|
|
5579
5585
|
updateDraggedNode(dragging, prev) {
|
|
5580
5586
|
let sel = dragging.node, found = -1;
|
|
5581
|
-
if (this.state.doc.nodeAt(sel.from) == sel.node) {
|
|
5587
|
+
if (sel.from < this.state.doc.content.size && this.state.doc.nodeAt(sel.from) == sel.node) {
|
|
5582
5588
|
found = sel.from;
|
|
5583
5589
|
}
|
|
5584
5590
|
else {
|
|
5585
5591
|
let movedPos = sel.from + (this.state.doc.content.size - prev.doc.content.size);
|
|
5586
|
-
let moved = movedPos > 0 && this.state.doc.nodeAt(movedPos);
|
|
5592
|
+
let moved = movedPos > 0 && movedPos < this.state.doc.content.size && this.state.doc.nodeAt(movedPos);
|
|
5587
5593
|
if (moved == sel.node)
|
|
5588
5594
|
found = movedPos;
|
|
5589
5595
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prosemirror-view",
|
|
3
|
-
"version": "1.41.
|
|
3
|
+
"version": "1.41.8",
|
|
4
4
|
"description": "ProseMirror's view component",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
],
|
|
26
26
|
"repository": {
|
|
27
27
|
"type": "git",
|
|
28
|
-
"url": "git://
|
|
28
|
+
"url": "git+https://code.haverbeke.berlin/prosemirror/prosemirror-view.git"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"prosemirror-model": "^1.20.0",
|
package/src/domobserver.ts
CHANGED
|
@@ -197,8 +197,13 @@ export class DOMObserver {
|
|
|
197
197
|
// backspace out the last bit of text before an inline-flex node (#1552)
|
|
198
198
|
for (let node of added) if (node.nodeName == "BR" && node.parentNode) {
|
|
199
199
|
let after = node.nextSibling
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
while (after && after.nodeType == 1) {
|
|
201
|
+
if ((after as HTMLElement).contentEditable == "false") {
|
|
202
|
+
node.parentNode.removeChild(node)
|
|
203
|
+
break
|
|
204
|
+
}
|
|
205
|
+
after = after.firstChild
|
|
206
|
+
}
|
|
202
207
|
}
|
|
203
208
|
} else if (browser.gecko && added.length) {
|
|
204
209
|
let brs = added.filter(n => n.nodeName == "BR") as HTMLElement[]
|
package/src/index.ts
CHANGED
|
@@ -54,7 +54,7 @@ export class EditorView {
|
|
|
54
54
|
/// @internal
|
|
55
55
|
declare domObserver: DOMObserver
|
|
56
56
|
/// Holds `true` when a hack node is needed in Firefox to prevent the
|
|
57
|
-
/// [space is eaten issue](https://
|
|
57
|
+
/// [space is eaten issue](https://code.haverbeke.berlin/prosemirror/prosemirror/issues/651)
|
|
58
58
|
/// @internal
|
|
59
59
|
requiresGeckoHackNode: boolean = false
|
|
60
60
|
|
|
@@ -274,11 +274,11 @@ export class EditorView {
|
|
|
274
274
|
|
|
275
275
|
private updateDraggedNode(dragging: Dragging, prev: EditorState) {
|
|
276
276
|
let sel = dragging.node!, found = -1
|
|
277
|
-
if (this.state.doc.nodeAt(sel.from) == sel.node) {
|
|
277
|
+
if (sel.from < this.state.doc.content.size && this.state.doc.nodeAt(sel.from) == sel.node) {
|
|
278
278
|
found = sel.from
|
|
279
279
|
} else {
|
|
280
280
|
let movedPos = sel.from + (this.state.doc.content.size - prev.doc.content.size)
|
|
281
|
-
let moved = movedPos > 0 && this.state.doc.nodeAt(movedPos)
|
|
281
|
+
let moved = movedPos > 0 && movedPos < this.state.doc.content.size && this.state.doc.nodeAt(movedPos)
|
|
282
282
|
if (moved == sel.node) found = movedPos
|
|
283
283
|
}
|
|
284
284
|
this.dragging = new Dragging(dragging.slice, dragging.move,
|
package/src/input.ts
CHANGED
|
@@ -334,8 +334,8 @@ class MouseDown {
|
|
|
334
334
|
|
|
335
335
|
let {selection} = view.state
|
|
336
336
|
if (event.button == 0 &&
|
|
337
|
-
targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||
|
|
338
|
-
|
|
337
|
+
(targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false ||
|
|
338
|
+
selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos))
|
|
339
339
|
this.mightDrag = {
|
|
340
340
|
node: targetNode,
|
|
341
341
|
pos: targetPos,
|
|
@@ -673,8 +673,9 @@ export class Dragging {
|
|
|
673
673
|
const dragCopyModifier: keyof DragEvent = browser.mac ? "altKey" : "ctrlKey"
|
|
674
674
|
|
|
675
675
|
function dragMoves(view: EditorView, event: DragEvent) {
|
|
676
|
-
let
|
|
677
|
-
|
|
676
|
+
let copy: boolean | undefined
|
|
677
|
+
view.someProp("dragCopies", test => { copy = copy || test(event) })
|
|
678
|
+
return copy != null ? !copy : !event[dragCopyModifier]
|
|
678
679
|
}
|
|
679
680
|
|
|
680
681
|
handlers.dragstart = (view, _event) => {
|
|
@@ -701,7 +702,7 @@ handlers.dragstart = (view, _event) => {
|
|
|
701
702
|
if (!event.dataTransfer.files.length || !browser.chrome || browser.chrome_version > 120)
|
|
702
703
|
event.dataTransfer.clearData()
|
|
703
704
|
event.dataTransfer.setData(brokenClipboardAPI ? "Text" : "text/html", dom.innerHTML)
|
|
704
|
-
// See https://
|
|
705
|
+
// See https://code.haverbeke.berlin/prosemirror/prosemirror/issues/1156
|
|
705
706
|
event.dataTransfer.effectAllowed = "copyMove"
|
|
706
707
|
if (!brokenClipboardAPI) event.dataTransfer.setData("text/plain", text)
|
|
707
708
|
view.dragging = new Dragging(slice, dragMoves(view, event), node)
|
package/src/viewdesc.ts
CHANGED
|
@@ -30,7 +30,7 @@ export type ViewMutationRecord = MutationRecord | { type: "selection", target: D
|
|
|
30
30
|
/// Objects returned as node views must conform to this interface.
|
|
31
31
|
export interface NodeView {
|
|
32
32
|
/// The outer DOM node that represents the document node.
|
|
33
|
-
dom:
|
|
33
|
+
dom: HTMLElement
|
|
34
34
|
|
|
35
35
|
/// The DOM node that should hold the node's content. Only meaningful
|
|
36
36
|
/// if the node view also defines a `dom` property and if its node
|
|
@@ -99,7 +99,7 @@ export interface NodeView {
|
|
|
99
99
|
/// Objects returned as mark views must conform to this interface.
|
|
100
100
|
export interface MarkView {
|
|
101
101
|
/// The outer DOM node that represents the document node.
|
|
102
|
-
dom:
|
|
102
|
+
dom: HTMLElement
|
|
103
103
|
|
|
104
104
|
/// The DOM node that should hold the mark's content. When this is not
|
|
105
105
|
/// present, the `dom` property is used as the content DOM.
|
|
@@ -610,7 +610,7 @@ class CompositionViewDesc extends ViewDesc {
|
|
|
610
610
|
// some cases they will be split more often than would appear
|
|
611
611
|
// necessary.
|
|
612
612
|
class MarkViewDesc extends ViewDesc {
|
|
613
|
-
constructor(parent: ViewDesc, readonly mark: Mark, dom:
|
|
613
|
+
constructor(parent: ViewDesc, readonly mark: Mark, dom: HTMLElement, contentDOM: HTMLElement, readonly spec: MarkView) {
|
|
614
614
|
super(parent, [], dom, contentDOM)
|
|
615
615
|
}
|
|
616
616
|
|
|
@@ -697,13 +697,13 @@ export class NodeViewDesc extends ViewDesc {
|
|
|
697
697
|
if (descObj.parent) return descObj.parent.posBeforeChild(descObj)
|
|
698
698
|
}, outerDeco, innerDeco)
|
|
699
699
|
|
|
700
|
-
let dom = spec && spec.dom, contentDOM = spec && spec.contentDOM
|
|
700
|
+
let dom: DOMNode | undefined = spec && spec.dom, contentDOM = spec && spec.contentDOM
|
|
701
701
|
if (node.isText) {
|
|
702
702
|
if (!dom) dom = document.createTextNode(node.text!)
|
|
703
703
|
else if (dom.nodeType != 3) throw new RangeError("Text must be rendered as a DOM text node")
|
|
704
704
|
} else if (!dom) {
|
|
705
705
|
let spec = (DOMSerializer.renderSpec as any)(document, node.type.spec.toDOM!(node), null, node.attrs)
|
|
706
|
-
;({dom, contentDOM} = spec as {dom:
|
|
706
|
+
;({dom, contentDOM} = spec as {dom: HTMLElement, contentDOM?: HTMLElement})
|
|
707
707
|
}
|
|
708
708
|
if (!contentDOM && !node.isText && dom.nodeName != "BR") { // Chrome gets confused by <br contenteditable=false>
|
|
709
709
|
if (!(dom as HTMLElement).hasAttribute("contenteditable")) (dom as HTMLElement).contentEditable = "false"
|
|
@@ -714,8 +714,8 @@ export class NodeViewDesc extends ViewDesc {
|
|
|
714
714
|
dom = applyOuterDeco(dom, outerDeco, node)
|
|
715
715
|
|
|
716
716
|
if (spec)
|
|
717
|
-
return descObj = new CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM || null,
|
|
718
|
-
spec, view, pos + 1)
|
|
717
|
+
return descObj = new CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom as HTMLElement, contentDOM || null,
|
|
718
|
+
nodeDOM as HTMLElement, spec, view, pos + 1)
|
|
719
719
|
else if (node.isText)
|
|
720
720
|
return new TextViewDesc(parent, node, outerDeco, innerDeco, dom, nodeDOM, view)
|
|
721
721
|
else
|
|
@@ -985,7 +985,7 @@ class TrailingHackViewDesc extends ViewDesc {
|
|
|
985
985
|
// customized.
|
|
986
986
|
class CustomNodeViewDesc extends NodeViewDesc {
|
|
987
987
|
constructor(parent: ViewDesc | undefined, node: Node, outerDeco: readonly Decoration[], innerDeco: DecorationSource,
|
|
988
|
-
dom:
|
|
988
|
+
dom: HTMLElement, contentDOM: HTMLElement | null, nodeDOM: HTMLElement, readonly spec: NodeView,
|
|
989
989
|
view: EditorView, pos: number) {
|
|
990
990
|
super(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view, pos)
|
|
991
991
|
}
|
package/style/prosemirror.css
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
.ProseMirror-hideselection *::-moz-selection { background: transparent; }
|
|
24
24
|
.ProseMirror-hideselection { caret-color: transparent; }
|
|
25
25
|
|
|
26
|
-
/* See https://
|
|
26
|
+
/* See https://code.haverbeke.berlin/prosemirror/prosemirror/issues/1421#issuecomment-1759320191 */
|
|
27
27
|
.ProseMirror [draggable][contenteditable=false] { user-select: text }
|
|
28
28
|
|
|
29
29
|
.ProseMirror-selectednode {
|