@codemirror/view 6.7.0 → 6.7.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 +28 -0
- package/dist/index.cjs +109 -33
- package/dist/index.js +109 -33
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## 6.7.2 (2023-01-04)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix a regression where the cursor didn't restart its blink cycle when moving it with the pointer.
|
|
6
|
+
|
|
7
|
+
Even without a `key` property, measure request objects that are already scheduled will not be scheduled again by `requestMeasure`.
|
|
8
|
+
|
|
9
|
+
Fix an issue where keymaps incorrectly interpreted key events that used Ctrl+Alt modifiers to simulate AltGr on Windows.
|
|
10
|
+
|
|
11
|
+
Fix a bug where line decorations with a different `class` property would be treated as equal.
|
|
12
|
+
|
|
13
|
+
Fix a bug that caused `drawSelection` to not notice when it was reconfigured.
|
|
14
|
+
|
|
15
|
+
Fix a crash in the gutter extension caused by sharing of mutable arrays.
|
|
16
|
+
|
|
17
|
+
Fix a regression that caused touch selection on mobile platforms to not work in an uneditable editor.
|
|
18
|
+
|
|
19
|
+
Fix a bug where DOM events on the boundary between lines could get assigned to the wrong line.
|
|
20
|
+
|
|
21
|
+
## 6.7.1 (2022-12-12)
|
|
22
|
+
|
|
23
|
+
### Bug fixes
|
|
24
|
+
|
|
25
|
+
Make the editor properly scroll when moving the pointer out of it during drag selection.
|
|
26
|
+
|
|
27
|
+
Fix a regression where clicking below the content element in an editor with its own height didn't focus the editor.
|
|
28
|
+
|
|
1
29
|
## 6.7.0 (2022-12-07)
|
|
2
30
|
|
|
3
31
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -191,6 +191,26 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
+
function scrollableParent(dom) {
|
|
195
|
+
let doc = dom.ownerDocument;
|
|
196
|
+
for (let cur = dom.parentNode; cur;) {
|
|
197
|
+
if (cur == doc.body) {
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
else if (cur.nodeType == 1) {
|
|
201
|
+
if (cur.scrollHeight > cur.clientHeight || cur.scrollWidth > cur.clientWidth)
|
|
202
|
+
return cur;
|
|
203
|
+
cur = cur.assignedSlot || cur.parentNode;
|
|
204
|
+
}
|
|
205
|
+
else if (cur.nodeType == 11) {
|
|
206
|
+
cur = cur.host;
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
194
214
|
class DOMSelectionState {
|
|
195
215
|
constructor() {
|
|
196
216
|
this.anchorNode = null;
|
|
@@ -1328,7 +1348,9 @@ class LineDecoration extends Decoration {
|
|
|
1328
1348
|
super(-200000000 /* Side.Line */, -200000000 /* Side.Line */, null, spec);
|
|
1329
1349
|
}
|
|
1330
1350
|
eq(other) {
|
|
1331
|
-
return other instanceof LineDecoration &&
|
|
1351
|
+
return other instanceof LineDecoration &&
|
|
1352
|
+
this.spec.class == other.spec.class &&
|
|
1353
|
+
attrsEq(this.spec.attributes, other.spec.attributes);
|
|
1332
1354
|
}
|
|
1333
1355
|
range(from, to = from) {
|
|
1334
1356
|
if (to != from)
|
|
@@ -3391,22 +3413,30 @@ class InputState {
|
|
|
3391
3413
|
this.compositionFirstChange = null;
|
|
3392
3414
|
this.compositionEndedAt = 0;
|
|
3393
3415
|
this.mouseSelection = null;
|
|
3416
|
+
let handleEvent = (handler, event) => {
|
|
3417
|
+
if (this.ignoreDuringComposition(event))
|
|
3418
|
+
return;
|
|
3419
|
+
if (event.type == "keydown" && this.keydown(view, event))
|
|
3420
|
+
return;
|
|
3421
|
+
if (this.mustFlushObserver(event))
|
|
3422
|
+
view.observer.forceFlush();
|
|
3423
|
+
if (this.runCustomHandlers(event.type, view, event))
|
|
3424
|
+
event.preventDefault();
|
|
3425
|
+
else
|
|
3426
|
+
handler(view, event);
|
|
3427
|
+
};
|
|
3394
3428
|
for (let type in handlers) {
|
|
3395
3429
|
let handler = handlers[type];
|
|
3396
|
-
view.contentDOM.addEventListener(type,
|
|
3397
|
-
if (
|
|
3398
|
-
|
|
3399
|
-
if (type == "keydown" && this.keydown(view, event))
|
|
3400
|
-
return;
|
|
3401
|
-
if (this.mustFlushObserver(event))
|
|
3402
|
-
view.observer.forceFlush();
|
|
3403
|
-
if (this.runCustomHandlers(type, view, event))
|
|
3404
|
-
event.preventDefault();
|
|
3405
|
-
else
|
|
3406
|
-
handler(view, event);
|
|
3430
|
+
view.contentDOM.addEventListener(type, event => {
|
|
3431
|
+
if (eventBelongsToEditor(view, event))
|
|
3432
|
+
handleEvent(handler, event);
|
|
3407
3433
|
}, handlerOptions[type]);
|
|
3408
3434
|
this.registeredEvents.push(type);
|
|
3409
3435
|
}
|
|
3436
|
+
view.scrollDOM.addEventListener("mousedown", (event) => {
|
|
3437
|
+
if (event.target == view.scrollDOM)
|
|
3438
|
+
handleEvent(handlers.mousedown, event);
|
|
3439
|
+
});
|
|
3410
3440
|
if (browser.chrome && browser.chrome_version == 102) { // FIXME remove at some point
|
|
3411
3441
|
// On Chrome 102, viewport updates somehow stop wheel-based
|
|
3412
3442
|
// scrolling. Turning off pointer events during the scroll seems
|
|
@@ -3563,12 +3593,18 @@ const PendingKeys = [
|
|
|
3563
3593
|
const EmacsyPendingKeys = "dthko";
|
|
3564
3594
|
// Key codes for modifier keys
|
|
3565
3595
|
const modifierCodes = [16, 17, 18, 20, 91, 92, 224, 225];
|
|
3596
|
+
function dragScrollSpeed(dist) {
|
|
3597
|
+
return dist * 0.7 + 8;
|
|
3598
|
+
}
|
|
3566
3599
|
class MouseSelection {
|
|
3567
3600
|
constructor(view, startEvent, style, mustSelect) {
|
|
3568
3601
|
this.view = view;
|
|
3569
3602
|
this.style = style;
|
|
3570
3603
|
this.mustSelect = mustSelect;
|
|
3604
|
+
this.scrollSpeed = { x: 0, y: 0 };
|
|
3605
|
+
this.scrolling = -1;
|
|
3571
3606
|
this.lastEvent = startEvent;
|
|
3607
|
+
this.scrollParent = scrollableParent(view.contentDOM);
|
|
3572
3608
|
let doc = view.contentDOM.ownerDocument;
|
|
3573
3609
|
doc.addEventListener("mousemove", this.move = this.move.bind(this));
|
|
3574
3610
|
doc.addEventListener("mouseup", this.up = this.up.bind(this));
|
|
@@ -3584,11 +3620,24 @@ class MouseSelection {
|
|
|
3584
3620
|
}
|
|
3585
3621
|
}
|
|
3586
3622
|
move(event) {
|
|
3623
|
+
var _a;
|
|
3587
3624
|
if (event.buttons == 0)
|
|
3588
3625
|
return this.destroy();
|
|
3589
3626
|
if (this.dragging !== false)
|
|
3590
3627
|
return;
|
|
3591
3628
|
this.select(this.lastEvent = event);
|
|
3629
|
+
let sx = 0, sy = 0;
|
|
3630
|
+
let rect = ((_a = this.scrollParent) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect())
|
|
3631
|
+
|| { left: 0, top: 0, right: this.view.win.innerWidth, bottom: this.view.win.innerHeight };
|
|
3632
|
+
if (event.clientX <= rect.left)
|
|
3633
|
+
sx = -dragScrollSpeed(rect.left - event.clientX);
|
|
3634
|
+
else if (event.clientX >= rect.right)
|
|
3635
|
+
sx = dragScrollSpeed(event.clientX - rect.right);
|
|
3636
|
+
if (event.clientY <= rect.top)
|
|
3637
|
+
sy = -dragScrollSpeed(rect.top - event.clientY);
|
|
3638
|
+
else if (event.clientY >= rect.bottom)
|
|
3639
|
+
sy = dragScrollSpeed(event.clientY - rect.bottom);
|
|
3640
|
+
this.setScrollSpeed(sx, sy);
|
|
3592
3641
|
}
|
|
3593
3642
|
up(event) {
|
|
3594
3643
|
if (this.dragging == null)
|
|
@@ -3598,19 +3647,41 @@ class MouseSelection {
|
|
|
3598
3647
|
this.destroy();
|
|
3599
3648
|
}
|
|
3600
3649
|
destroy() {
|
|
3650
|
+
this.setScrollSpeed(0, 0);
|
|
3601
3651
|
let doc = this.view.contentDOM.ownerDocument;
|
|
3602
3652
|
doc.removeEventListener("mousemove", this.move);
|
|
3603
3653
|
doc.removeEventListener("mouseup", this.up);
|
|
3604
3654
|
this.view.inputState.mouseSelection = null;
|
|
3605
3655
|
}
|
|
3656
|
+
setScrollSpeed(sx, sy) {
|
|
3657
|
+
this.scrollSpeed = { x: sx, y: sy };
|
|
3658
|
+
if (sx || sy) {
|
|
3659
|
+
if (this.scrolling < 0)
|
|
3660
|
+
this.scrolling = setInterval(() => this.scroll(), 50);
|
|
3661
|
+
}
|
|
3662
|
+
else if (this.scrolling > -1) {
|
|
3663
|
+
clearInterval(this.scrolling);
|
|
3664
|
+
this.scrolling = -1;
|
|
3665
|
+
}
|
|
3666
|
+
}
|
|
3667
|
+
scroll() {
|
|
3668
|
+
if (this.scrollParent) {
|
|
3669
|
+
this.scrollParent.scrollLeft += this.scrollSpeed.x;
|
|
3670
|
+
this.scrollParent.scrollTop += this.scrollSpeed.y;
|
|
3671
|
+
}
|
|
3672
|
+
else {
|
|
3673
|
+
this.view.win.scrollBy(this.scrollSpeed.x, this.scrollSpeed.y);
|
|
3674
|
+
}
|
|
3675
|
+
if (this.dragging === false)
|
|
3676
|
+
this.select(this.lastEvent);
|
|
3677
|
+
}
|
|
3606
3678
|
select(event) {
|
|
3607
3679
|
let selection = this.style.get(event, this.extend, this.multiple);
|
|
3608
3680
|
if (this.mustSelect || !selection.eq(this.view.state.selection) ||
|
|
3609
3681
|
selection.main.assoc != this.view.state.selection.main.assoc)
|
|
3610
3682
|
this.view.dispatch({
|
|
3611
3683
|
selection,
|
|
3612
|
-
userEvent: "select.pointer"
|
|
3613
|
-
scrollIntoView: true
|
|
3684
|
+
userEvent: "select.pointer"
|
|
3614
3685
|
});
|
|
3615
3686
|
this.mustSelect = false;
|
|
3616
3687
|
}
|
|
@@ -3801,23 +3872,15 @@ function getClickType(event) {
|
|
|
3801
3872
|
function basicMouseSelection(view, event) {
|
|
3802
3873
|
let start = queryPos(view, event), type = getClickType(event);
|
|
3803
3874
|
let startSel = view.state.selection;
|
|
3804
|
-
let last = start, lastEvent = event;
|
|
3805
3875
|
return {
|
|
3806
3876
|
update(update) {
|
|
3807
3877
|
if (update.docChanged) {
|
|
3808
3878
|
start.pos = update.changes.mapPos(start.pos);
|
|
3809
3879
|
startSel = startSel.map(update.changes);
|
|
3810
|
-
lastEvent = null;
|
|
3811
3880
|
}
|
|
3812
3881
|
},
|
|
3813
3882
|
get(event, extend, multiple) {
|
|
3814
|
-
let cur;
|
|
3815
|
-
if (lastEvent && event.clientX == lastEvent.clientX && event.clientY == lastEvent.clientY)
|
|
3816
|
-
cur = last;
|
|
3817
|
-
else {
|
|
3818
|
-
cur = last = queryPos(view, event);
|
|
3819
|
-
lastEvent = event;
|
|
3820
|
-
}
|
|
3883
|
+
let cur = queryPos(view, event);
|
|
3821
3884
|
let range = rangeForClick(view, cur.pos, cur.bias, type);
|
|
3822
3885
|
if (start.pos != cur.pos && !extend) {
|
|
3823
3886
|
let startRange = rangeForClick(view, start.pos, start.bias, type);
|
|
@@ -5264,7 +5327,7 @@ function buildTheme(main, spec, scopes) {
|
|
|
5264
5327
|
});
|
|
5265
5328
|
}
|
|
5266
5329
|
const baseTheme$1 = buildTheme("." + baseThemeID, {
|
|
5267
|
-
"
|
|
5330
|
+
"&": {
|
|
5268
5331
|
position: "relative !important",
|
|
5269
5332
|
boxSizing: "border-box",
|
|
5270
5333
|
"&.cm-focused": {
|
|
@@ -5548,7 +5611,7 @@ function applyDOMChange(view, domChange) {
|
|
|
5548
5611
|
insert: state.Text.of(domChange.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder)) };
|
|
5549
5612
|
}
|
|
5550
5613
|
}
|
|
5551
|
-
else if (newSel && (!view.hasFocus
|
|
5614
|
+
else if (newSel && (!view.hasFocus && view.state.facet(editable) || newSel.main.eq(sel))) {
|
|
5552
5615
|
newSel = null;
|
|
5553
5616
|
}
|
|
5554
5617
|
if (!change && !newSel)
|
|
@@ -6612,6 +6675,8 @@ class EditorView {
|
|
|
6612
6675
|
if (this.measureScheduled < 0)
|
|
6613
6676
|
this.measureScheduled = this.win.requestAnimationFrame(() => this.measure());
|
|
6614
6677
|
if (request) {
|
|
6678
|
+
if (this.measureRequests.indexOf(request) > -1)
|
|
6679
|
+
return;
|
|
6615
6680
|
if (request.key != null)
|
|
6616
6681
|
for (let i = 0; i < this.measureRequests.length; i++) {
|
|
6617
6682
|
if (this.measureRequests[i].key === request.key) {
|
|
@@ -7295,6 +7360,8 @@ function runHandlers(map, event, view, scope) {
|
|
|
7295
7360
|
if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)]))
|
|
7296
7361
|
return true;
|
|
7297
7362
|
if (isChar && (event.altKey || event.metaKey || event.ctrlKey) &&
|
|
7363
|
+
// Ctrl-Alt may be used for AltGr on Windows
|
|
7364
|
+
!(browser.windows && event.ctrlKey && event.altKey) &&
|
|
7298
7365
|
(baseName = w3cKeyname.base[event.keyCode]) && baseName != name) {
|
|
7299
7366
|
if (runFor(scopeObj[prefix + modifiers(baseName, event, true)]))
|
|
7300
7367
|
return true;
|
|
@@ -7589,7 +7656,7 @@ function drawSelection(config = {}) {
|
|
|
7589
7656
|
];
|
|
7590
7657
|
}
|
|
7591
7658
|
function configChanged(update) {
|
|
7592
|
-
return update.startState.facet(selectionConfig) != update.
|
|
7659
|
+
return update.startState.facet(selectionConfig) != update.state.facet(selectionConfig);
|
|
7593
7660
|
}
|
|
7594
7661
|
const cursorLayer = layer({
|
|
7595
7662
|
above: true,
|
|
@@ -7608,7 +7675,7 @@ const cursorLayer = layer({
|
|
|
7608
7675
|
return cursors;
|
|
7609
7676
|
},
|
|
7610
7677
|
update(update, dom) {
|
|
7611
|
-
if (update.transactions.some(tr => tr.
|
|
7678
|
+
if (update.transactions.some(tr => tr.selection))
|
|
7612
7679
|
dom.style.animationName = dom.style.animationName == "cm-blink" ? "cm-blink2" : "cm-blink";
|
|
7613
7680
|
let confChange = configChanged(update);
|
|
7614
7681
|
if (confChange)
|
|
@@ -9174,15 +9241,14 @@ class UpdateContext {
|
|
|
9174
9241
|
constructor(gutter, viewport, height) {
|
|
9175
9242
|
this.gutter = gutter;
|
|
9176
9243
|
this.height = height;
|
|
9177
|
-
this.localMarkers = [];
|
|
9178
9244
|
this.i = 0;
|
|
9179
9245
|
this.cursor = state.RangeSet.iter(gutter.markers, viewport.from);
|
|
9180
9246
|
}
|
|
9181
9247
|
line(view, line, extraMarkers) {
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
|
|
9185
|
-
|
|
9248
|
+
let localMarkers = [];
|
|
9249
|
+
advanceCursor(this.cursor, localMarkers, line.from);
|
|
9250
|
+
if (extraMarkers.length)
|
|
9251
|
+
localMarkers = localMarkers.concat(extraMarkers);
|
|
9186
9252
|
let forLine = this.gutter.config.lineMarker(view, line, localMarkers);
|
|
9187
9253
|
if (forLine)
|
|
9188
9254
|
localMarkers.unshift(forLine);
|
|
@@ -9220,7 +9286,17 @@ class SingleGutterView {
|
|
|
9220
9286
|
this.dom.className = "cm-gutter" + (this.config.class ? " " + this.config.class : "");
|
|
9221
9287
|
for (let prop in config.domEventHandlers) {
|
|
9222
9288
|
this.dom.addEventListener(prop, (event) => {
|
|
9223
|
-
let
|
|
9289
|
+
let target = event.target, y;
|
|
9290
|
+
if (target != this.dom && this.dom.contains(target)) {
|
|
9291
|
+
while (target.parentNode != this.dom)
|
|
9292
|
+
target = target.parentNode;
|
|
9293
|
+
let rect = target.getBoundingClientRect();
|
|
9294
|
+
y = (rect.top + rect.bottom) / 2;
|
|
9295
|
+
}
|
|
9296
|
+
else {
|
|
9297
|
+
y = event.clientY;
|
|
9298
|
+
}
|
|
9299
|
+
let line = view.lineBlockAtHeight(y - view.documentTop);
|
|
9224
9300
|
if (config.domEventHandlers[prop](view, line, event))
|
|
9225
9301
|
event.preventDefault();
|
|
9226
9302
|
});
|
package/dist/index.js
CHANGED
|
@@ -187,6 +187,26 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
+
function scrollableParent(dom) {
|
|
191
|
+
let doc = dom.ownerDocument;
|
|
192
|
+
for (let cur = dom.parentNode; cur;) {
|
|
193
|
+
if (cur == doc.body) {
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
else if (cur.nodeType == 1) {
|
|
197
|
+
if (cur.scrollHeight > cur.clientHeight || cur.scrollWidth > cur.clientWidth)
|
|
198
|
+
return cur;
|
|
199
|
+
cur = cur.assignedSlot || cur.parentNode;
|
|
200
|
+
}
|
|
201
|
+
else if (cur.nodeType == 11) {
|
|
202
|
+
cur = cur.host;
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
190
210
|
class DOMSelectionState {
|
|
191
211
|
constructor() {
|
|
192
212
|
this.anchorNode = null;
|
|
@@ -1323,7 +1343,9 @@ class LineDecoration extends Decoration {
|
|
|
1323
1343
|
super(-200000000 /* Side.Line */, -200000000 /* Side.Line */, null, spec);
|
|
1324
1344
|
}
|
|
1325
1345
|
eq(other) {
|
|
1326
|
-
return other instanceof LineDecoration &&
|
|
1346
|
+
return other instanceof LineDecoration &&
|
|
1347
|
+
this.spec.class == other.spec.class &&
|
|
1348
|
+
attrsEq(this.spec.attributes, other.spec.attributes);
|
|
1327
1349
|
}
|
|
1328
1350
|
range(from, to = from) {
|
|
1329
1351
|
if (to != from)
|
|
@@ -3385,22 +3407,30 @@ class InputState {
|
|
|
3385
3407
|
this.compositionFirstChange = null;
|
|
3386
3408
|
this.compositionEndedAt = 0;
|
|
3387
3409
|
this.mouseSelection = null;
|
|
3410
|
+
let handleEvent = (handler, event) => {
|
|
3411
|
+
if (this.ignoreDuringComposition(event))
|
|
3412
|
+
return;
|
|
3413
|
+
if (event.type == "keydown" && this.keydown(view, event))
|
|
3414
|
+
return;
|
|
3415
|
+
if (this.mustFlushObserver(event))
|
|
3416
|
+
view.observer.forceFlush();
|
|
3417
|
+
if (this.runCustomHandlers(event.type, view, event))
|
|
3418
|
+
event.preventDefault();
|
|
3419
|
+
else
|
|
3420
|
+
handler(view, event);
|
|
3421
|
+
};
|
|
3388
3422
|
for (let type in handlers) {
|
|
3389
3423
|
let handler = handlers[type];
|
|
3390
|
-
view.contentDOM.addEventListener(type,
|
|
3391
|
-
if (
|
|
3392
|
-
|
|
3393
|
-
if (type == "keydown" && this.keydown(view, event))
|
|
3394
|
-
return;
|
|
3395
|
-
if (this.mustFlushObserver(event))
|
|
3396
|
-
view.observer.forceFlush();
|
|
3397
|
-
if (this.runCustomHandlers(type, view, event))
|
|
3398
|
-
event.preventDefault();
|
|
3399
|
-
else
|
|
3400
|
-
handler(view, event);
|
|
3424
|
+
view.contentDOM.addEventListener(type, event => {
|
|
3425
|
+
if (eventBelongsToEditor(view, event))
|
|
3426
|
+
handleEvent(handler, event);
|
|
3401
3427
|
}, handlerOptions[type]);
|
|
3402
3428
|
this.registeredEvents.push(type);
|
|
3403
3429
|
}
|
|
3430
|
+
view.scrollDOM.addEventListener("mousedown", (event) => {
|
|
3431
|
+
if (event.target == view.scrollDOM)
|
|
3432
|
+
handleEvent(handlers.mousedown, event);
|
|
3433
|
+
});
|
|
3404
3434
|
if (browser.chrome && browser.chrome_version == 102) { // FIXME remove at some point
|
|
3405
3435
|
// On Chrome 102, viewport updates somehow stop wheel-based
|
|
3406
3436
|
// scrolling. Turning off pointer events during the scroll seems
|
|
@@ -3557,12 +3587,18 @@ const PendingKeys = [
|
|
|
3557
3587
|
const EmacsyPendingKeys = "dthko";
|
|
3558
3588
|
// Key codes for modifier keys
|
|
3559
3589
|
const modifierCodes = [16, 17, 18, 20, 91, 92, 224, 225];
|
|
3590
|
+
function dragScrollSpeed(dist) {
|
|
3591
|
+
return dist * 0.7 + 8;
|
|
3592
|
+
}
|
|
3560
3593
|
class MouseSelection {
|
|
3561
3594
|
constructor(view, startEvent, style, mustSelect) {
|
|
3562
3595
|
this.view = view;
|
|
3563
3596
|
this.style = style;
|
|
3564
3597
|
this.mustSelect = mustSelect;
|
|
3598
|
+
this.scrollSpeed = { x: 0, y: 0 };
|
|
3599
|
+
this.scrolling = -1;
|
|
3565
3600
|
this.lastEvent = startEvent;
|
|
3601
|
+
this.scrollParent = scrollableParent(view.contentDOM);
|
|
3566
3602
|
let doc = view.contentDOM.ownerDocument;
|
|
3567
3603
|
doc.addEventListener("mousemove", this.move = this.move.bind(this));
|
|
3568
3604
|
doc.addEventListener("mouseup", this.up = this.up.bind(this));
|
|
@@ -3578,11 +3614,24 @@ class MouseSelection {
|
|
|
3578
3614
|
}
|
|
3579
3615
|
}
|
|
3580
3616
|
move(event) {
|
|
3617
|
+
var _a;
|
|
3581
3618
|
if (event.buttons == 0)
|
|
3582
3619
|
return this.destroy();
|
|
3583
3620
|
if (this.dragging !== false)
|
|
3584
3621
|
return;
|
|
3585
3622
|
this.select(this.lastEvent = event);
|
|
3623
|
+
let sx = 0, sy = 0;
|
|
3624
|
+
let rect = ((_a = this.scrollParent) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect())
|
|
3625
|
+
|| { left: 0, top: 0, right: this.view.win.innerWidth, bottom: this.view.win.innerHeight };
|
|
3626
|
+
if (event.clientX <= rect.left)
|
|
3627
|
+
sx = -dragScrollSpeed(rect.left - event.clientX);
|
|
3628
|
+
else if (event.clientX >= rect.right)
|
|
3629
|
+
sx = dragScrollSpeed(event.clientX - rect.right);
|
|
3630
|
+
if (event.clientY <= rect.top)
|
|
3631
|
+
sy = -dragScrollSpeed(rect.top - event.clientY);
|
|
3632
|
+
else if (event.clientY >= rect.bottom)
|
|
3633
|
+
sy = dragScrollSpeed(event.clientY - rect.bottom);
|
|
3634
|
+
this.setScrollSpeed(sx, sy);
|
|
3586
3635
|
}
|
|
3587
3636
|
up(event) {
|
|
3588
3637
|
if (this.dragging == null)
|
|
@@ -3592,19 +3641,41 @@ class MouseSelection {
|
|
|
3592
3641
|
this.destroy();
|
|
3593
3642
|
}
|
|
3594
3643
|
destroy() {
|
|
3644
|
+
this.setScrollSpeed(0, 0);
|
|
3595
3645
|
let doc = this.view.contentDOM.ownerDocument;
|
|
3596
3646
|
doc.removeEventListener("mousemove", this.move);
|
|
3597
3647
|
doc.removeEventListener("mouseup", this.up);
|
|
3598
3648
|
this.view.inputState.mouseSelection = null;
|
|
3599
3649
|
}
|
|
3650
|
+
setScrollSpeed(sx, sy) {
|
|
3651
|
+
this.scrollSpeed = { x: sx, y: sy };
|
|
3652
|
+
if (sx || sy) {
|
|
3653
|
+
if (this.scrolling < 0)
|
|
3654
|
+
this.scrolling = setInterval(() => this.scroll(), 50);
|
|
3655
|
+
}
|
|
3656
|
+
else if (this.scrolling > -1) {
|
|
3657
|
+
clearInterval(this.scrolling);
|
|
3658
|
+
this.scrolling = -1;
|
|
3659
|
+
}
|
|
3660
|
+
}
|
|
3661
|
+
scroll() {
|
|
3662
|
+
if (this.scrollParent) {
|
|
3663
|
+
this.scrollParent.scrollLeft += this.scrollSpeed.x;
|
|
3664
|
+
this.scrollParent.scrollTop += this.scrollSpeed.y;
|
|
3665
|
+
}
|
|
3666
|
+
else {
|
|
3667
|
+
this.view.win.scrollBy(this.scrollSpeed.x, this.scrollSpeed.y);
|
|
3668
|
+
}
|
|
3669
|
+
if (this.dragging === false)
|
|
3670
|
+
this.select(this.lastEvent);
|
|
3671
|
+
}
|
|
3600
3672
|
select(event) {
|
|
3601
3673
|
let selection = this.style.get(event, this.extend, this.multiple);
|
|
3602
3674
|
if (this.mustSelect || !selection.eq(this.view.state.selection) ||
|
|
3603
3675
|
selection.main.assoc != this.view.state.selection.main.assoc)
|
|
3604
3676
|
this.view.dispatch({
|
|
3605
3677
|
selection,
|
|
3606
|
-
userEvent: "select.pointer"
|
|
3607
|
-
scrollIntoView: true
|
|
3678
|
+
userEvent: "select.pointer"
|
|
3608
3679
|
});
|
|
3609
3680
|
this.mustSelect = false;
|
|
3610
3681
|
}
|
|
@@ -3795,23 +3866,15 @@ function getClickType(event) {
|
|
|
3795
3866
|
function basicMouseSelection(view, event) {
|
|
3796
3867
|
let start = queryPos(view, event), type = getClickType(event);
|
|
3797
3868
|
let startSel = view.state.selection;
|
|
3798
|
-
let last = start, lastEvent = event;
|
|
3799
3869
|
return {
|
|
3800
3870
|
update(update) {
|
|
3801
3871
|
if (update.docChanged) {
|
|
3802
3872
|
start.pos = update.changes.mapPos(start.pos);
|
|
3803
3873
|
startSel = startSel.map(update.changes);
|
|
3804
|
-
lastEvent = null;
|
|
3805
3874
|
}
|
|
3806
3875
|
},
|
|
3807
3876
|
get(event, extend, multiple) {
|
|
3808
|
-
let cur;
|
|
3809
|
-
if (lastEvent && event.clientX == lastEvent.clientX && event.clientY == lastEvent.clientY)
|
|
3810
|
-
cur = last;
|
|
3811
|
-
else {
|
|
3812
|
-
cur = last = queryPos(view, event);
|
|
3813
|
-
lastEvent = event;
|
|
3814
|
-
}
|
|
3877
|
+
let cur = queryPos(view, event);
|
|
3815
3878
|
let range = rangeForClick(view, cur.pos, cur.bias, type);
|
|
3816
3879
|
if (start.pos != cur.pos && !extend) {
|
|
3817
3880
|
let startRange = rangeForClick(view, start.pos, start.bias, type);
|
|
@@ -5257,7 +5320,7 @@ function buildTheme(main, spec, scopes) {
|
|
|
5257
5320
|
});
|
|
5258
5321
|
}
|
|
5259
5322
|
const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
|
|
5260
|
-
"
|
|
5323
|
+
"&": {
|
|
5261
5324
|
position: "relative !important",
|
|
5262
5325
|
boxSizing: "border-box",
|
|
5263
5326
|
"&.cm-focused": {
|
|
@@ -5541,7 +5604,7 @@ function applyDOMChange(view, domChange) {
|
|
|
5541
5604
|
insert: Text.of(domChange.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder)) };
|
|
5542
5605
|
}
|
|
5543
5606
|
}
|
|
5544
|
-
else if (newSel && (!view.hasFocus
|
|
5607
|
+
else if (newSel && (!view.hasFocus && view.state.facet(editable) || newSel.main.eq(sel))) {
|
|
5545
5608
|
newSel = null;
|
|
5546
5609
|
}
|
|
5547
5610
|
if (!change && !newSel)
|
|
@@ -6605,6 +6668,8 @@ class EditorView {
|
|
|
6605
6668
|
if (this.measureScheduled < 0)
|
|
6606
6669
|
this.measureScheduled = this.win.requestAnimationFrame(() => this.measure());
|
|
6607
6670
|
if (request) {
|
|
6671
|
+
if (this.measureRequests.indexOf(request) > -1)
|
|
6672
|
+
return;
|
|
6608
6673
|
if (request.key != null)
|
|
6609
6674
|
for (let i = 0; i < this.measureRequests.length; i++) {
|
|
6610
6675
|
if (this.measureRequests[i].key === request.key) {
|
|
@@ -7288,6 +7353,8 @@ function runHandlers(map, event, view, scope) {
|
|
|
7288
7353
|
if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)]))
|
|
7289
7354
|
return true;
|
|
7290
7355
|
if (isChar && (event.altKey || event.metaKey || event.ctrlKey) &&
|
|
7356
|
+
// Ctrl-Alt may be used for AltGr on Windows
|
|
7357
|
+
!(browser.windows && event.ctrlKey && event.altKey) &&
|
|
7291
7358
|
(baseName = base[event.keyCode]) && baseName != name) {
|
|
7292
7359
|
if (runFor(scopeObj[prefix + modifiers(baseName, event, true)]))
|
|
7293
7360
|
return true;
|
|
@@ -7582,7 +7649,7 @@ function drawSelection(config = {}) {
|
|
|
7582
7649
|
];
|
|
7583
7650
|
}
|
|
7584
7651
|
function configChanged(update) {
|
|
7585
|
-
return update.startState.facet(selectionConfig) != update.
|
|
7652
|
+
return update.startState.facet(selectionConfig) != update.state.facet(selectionConfig);
|
|
7586
7653
|
}
|
|
7587
7654
|
const cursorLayer = /*@__PURE__*/layer({
|
|
7588
7655
|
above: true,
|
|
@@ -7601,7 +7668,7 @@ const cursorLayer = /*@__PURE__*/layer({
|
|
|
7601
7668
|
return cursors;
|
|
7602
7669
|
},
|
|
7603
7670
|
update(update, dom) {
|
|
7604
|
-
if (update.transactions.some(tr => tr.
|
|
7671
|
+
if (update.transactions.some(tr => tr.selection))
|
|
7605
7672
|
dom.style.animationName = dom.style.animationName == "cm-blink" ? "cm-blink2" : "cm-blink";
|
|
7606
7673
|
let confChange = configChanged(update);
|
|
7607
7674
|
if (confChange)
|
|
@@ -9167,15 +9234,14 @@ class UpdateContext {
|
|
|
9167
9234
|
constructor(gutter, viewport, height) {
|
|
9168
9235
|
this.gutter = gutter;
|
|
9169
9236
|
this.height = height;
|
|
9170
|
-
this.localMarkers = [];
|
|
9171
9237
|
this.i = 0;
|
|
9172
9238
|
this.cursor = RangeSet.iter(gutter.markers, viewport.from);
|
|
9173
9239
|
}
|
|
9174
9240
|
line(view, line, extraMarkers) {
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
|
|
9178
|
-
|
|
9241
|
+
let localMarkers = [];
|
|
9242
|
+
advanceCursor(this.cursor, localMarkers, line.from);
|
|
9243
|
+
if (extraMarkers.length)
|
|
9244
|
+
localMarkers = localMarkers.concat(extraMarkers);
|
|
9179
9245
|
let forLine = this.gutter.config.lineMarker(view, line, localMarkers);
|
|
9180
9246
|
if (forLine)
|
|
9181
9247
|
localMarkers.unshift(forLine);
|
|
@@ -9213,7 +9279,17 @@ class SingleGutterView {
|
|
|
9213
9279
|
this.dom.className = "cm-gutter" + (this.config.class ? " " + this.config.class : "");
|
|
9214
9280
|
for (let prop in config.domEventHandlers) {
|
|
9215
9281
|
this.dom.addEventListener(prop, (event) => {
|
|
9216
|
-
let
|
|
9282
|
+
let target = event.target, y;
|
|
9283
|
+
if (target != this.dom && this.dom.contains(target)) {
|
|
9284
|
+
while (target.parentNode != this.dom)
|
|
9285
|
+
target = target.parentNode;
|
|
9286
|
+
let rect = target.getBoundingClientRect();
|
|
9287
|
+
y = (rect.top + rect.bottom) / 2;
|
|
9288
|
+
}
|
|
9289
|
+
else {
|
|
9290
|
+
y = event.clientY;
|
|
9291
|
+
}
|
|
9292
|
+
let line = view.lineBlockAtHeight(y - view.documentTop);
|
|
9217
9293
|
if (config.domEventHandlers[prop](view, line, event))
|
|
9218
9294
|
event.preventDefault();
|
|
9219
9295
|
});
|