@vuu-ui/vuu-codemirror 0.8.7-debug → 0.8.8-debug
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/cjs/index.js +421 -418
- package/cjs/index.js.map +3 -3
- package/esm/index.js +421 -418
- package/esm/index.js.map +3 -3
- package/package.json +1 -1
package/esm/index.js
CHANGED
|
@@ -3686,12 +3686,14 @@ function windowRect(win) {
|
|
|
3686
3686
|
}
|
|
3687
3687
|
function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
|
|
3688
3688
|
let doc2 = dom.ownerDocument, win = doc2.defaultView || window;
|
|
3689
|
-
for (let cur2 = dom; cur2; ) {
|
|
3689
|
+
for (let cur2 = dom, stop = false; cur2 && !stop; ) {
|
|
3690
3690
|
if (cur2.nodeType == 1) {
|
|
3691
3691
|
let bounding, top2 = cur2 == doc2.body;
|
|
3692
3692
|
if (top2) {
|
|
3693
3693
|
bounding = windowRect(win);
|
|
3694
3694
|
} else {
|
|
3695
|
+
if (/^(fixed|sticky)$/.test(getComputedStyle(cur2).position))
|
|
3696
|
+
stop = true;
|
|
3695
3697
|
if (cur2.scrollHeight <= cur2.clientHeight && cur2.scrollWidth <= cur2.clientWidth) {
|
|
3696
3698
|
cur2 = cur2.assignedSlot || cur2.parentNode;
|
|
3697
3699
|
continue;
|
|
@@ -3912,7 +3914,7 @@ var ContentView = class {
|
|
|
3912
3914
|
constructor() {
|
|
3913
3915
|
this.parent = null;
|
|
3914
3916
|
this.dom = null;
|
|
3915
|
-
this.
|
|
3917
|
+
this.flags = 2;
|
|
3916
3918
|
}
|
|
3917
3919
|
get overrideDOMText() {
|
|
3918
3920
|
return null;
|
|
@@ -3936,18 +3938,18 @@ var ContentView = class {
|
|
|
3936
3938
|
return this.posBefore(view) + view.length;
|
|
3937
3939
|
}
|
|
3938
3940
|
sync(view, track) {
|
|
3939
|
-
if (this.
|
|
3941
|
+
if (this.flags & 2) {
|
|
3940
3942
|
let parent = this.dom;
|
|
3941
3943
|
let prev = null, next;
|
|
3942
3944
|
for (let child of this.children) {
|
|
3943
|
-
if (child.
|
|
3944
|
-
if (!child.dom && (next = prev ? prev.nextSibling : parent.firstChild)
|
|
3945
|
+
if (child.flags & 7) {
|
|
3946
|
+
if (!child.dom && (next = prev ? prev.nextSibling : parent.firstChild)) {
|
|
3945
3947
|
let contentView = ContentView.get(next);
|
|
3946
3948
|
if (!contentView || !contentView.parent && contentView.canReuseDOM(child))
|
|
3947
3949
|
child.reuseDOM(next);
|
|
3948
3950
|
}
|
|
3949
3951
|
child.sync(view, track);
|
|
3950
|
-
child.
|
|
3952
|
+
child.flags &= ~7;
|
|
3951
3953
|
}
|
|
3952
3954
|
next = prev ? prev.nextSibling : parent.firstChild;
|
|
3953
3955
|
if (track && !track.written && track.node == parent && next != child.dom)
|
|
@@ -3965,11 +3967,11 @@ var ContentView = class {
|
|
|
3965
3967
|
track.written = true;
|
|
3966
3968
|
while (next)
|
|
3967
3969
|
next = rm$1(next);
|
|
3968
|
-
} else if (this.
|
|
3970
|
+
} else if (this.flags & 1) {
|
|
3969
3971
|
for (let child of this.children)
|
|
3970
|
-
if (child.
|
|
3972
|
+
if (child.flags & 7) {
|
|
3971
3973
|
child.sync(view, track);
|
|
3972
|
-
child.
|
|
3974
|
+
child.flags &= ~7;
|
|
3973
3975
|
}
|
|
3974
3976
|
}
|
|
3975
3977
|
}
|
|
@@ -4037,23 +4039,23 @@ var ContentView = class {
|
|
|
4037
4039
|
};
|
|
4038
4040
|
}
|
|
4039
4041
|
markDirty(andParent = false) {
|
|
4040
|
-
this.
|
|
4042
|
+
this.flags |= 2;
|
|
4041
4043
|
this.markParentsDirty(andParent);
|
|
4042
4044
|
}
|
|
4043
4045
|
markParentsDirty(childList) {
|
|
4044
4046
|
for (let parent = this.parent; parent; parent = parent.parent) {
|
|
4045
4047
|
if (childList)
|
|
4046
|
-
parent.
|
|
4047
|
-
if (parent.
|
|
4048
|
+
parent.flags |= 2;
|
|
4049
|
+
if (parent.flags & 1)
|
|
4048
4050
|
return;
|
|
4049
|
-
parent.
|
|
4051
|
+
parent.flags |= 1;
|
|
4050
4052
|
childList = false;
|
|
4051
4053
|
}
|
|
4052
4054
|
}
|
|
4053
4055
|
setParent(parent) {
|
|
4054
4056
|
if (this.parent != parent) {
|
|
4055
4057
|
this.parent = parent;
|
|
4056
|
-
if (this.
|
|
4058
|
+
if (this.flags & 7)
|
|
4057
4059
|
this.markParentsDirty(true);
|
|
4058
4060
|
}
|
|
4059
4061
|
}
|
|
@@ -4117,7 +4119,7 @@ var ContentView = class {
|
|
|
4117
4119
|
return false;
|
|
4118
4120
|
}
|
|
4119
4121
|
canReuseDOM(other) {
|
|
4120
|
-
return other.constructor == this.constructor;
|
|
4122
|
+
return other.constructor == this.constructor && !((this.flags | other.flags) & 8);
|
|
4121
4123
|
}
|
|
4122
4124
|
// When this is a zero-length view with a side, this should return a
|
|
4123
4125
|
// number <= 0 to indicate it is before its position, or a
|
|
@@ -4221,6 +4223,107 @@ function mergeChildrenInto(parent, from, to, insert2, openStart, openEnd) {
|
|
|
4221
4223
|
parent.length += dLen;
|
|
4222
4224
|
replaceRange(parent, fromI, fromOff, toI, toOff, insert2, 0, openStart, openEnd);
|
|
4223
4225
|
}
|
|
4226
|
+
var LineBreakPlaceholder = "\uFFFF";
|
|
4227
|
+
var DOMReader = class {
|
|
4228
|
+
constructor(points, state) {
|
|
4229
|
+
this.points = points;
|
|
4230
|
+
this.text = "";
|
|
4231
|
+
this.lineSeparator = state.facet(EditorState.lineSeparator);
|
|
4232
|
+
}
|
|
4233
|
+
append(text) {
|
|
4234
|
+
this.text += text;
|
|
4235
|
+
}
|
|
4236
|
+
lineBreak() {
|
|
4237
|
+
this.text += LineBreakPlaceholder;
|
|
4238
|
+
}
|
|
4239
|
+
readRange(start, end) {
|
|
4240
|
+
if (!start)
|
|
4241
|
+
return this;
|
|
4242
|
+
let parent = start.parentNode;
|
|
4243
|
+
for (let cur2 = start; ; ) {
|
|
4244
|
+
this.findPointBefore(parent, cur2);
|
|
4245
|
+
let oldLen = this.text.length;
|
|
4246
|
+
this.readNode(cur2);
|
|
4247
|
+
let next = cur2.nextSibling;
|
|
4248
|
+
if (next == end)
|
|
4249
|
+
break;
|
|
4250
|
+
let view = ContentView.get(cur2), nextView = ContentView.get(next);
|
|
4251
|
+
if (view && nextView ? view.breakAfter : (view ? view.breakAfter : isBlockElement(cur2)) || isBlockElement(next) && (cur2.nodeName != "BR" || cur2.cmIgnore) && this.text.length > oldLen)
|
|
4252
|
+
this.lineBreak();
|
|
4253
|
+
cur2 = next;
|
|
4254
|
+
}
|
|
4255
|
+
this.findPointBefore(parent, end);
|
|
4256
|
+
return this;
|
|
4257
|
+
}
|
|
4258
|
+
readTextNode(node) {
|
|
4259
|
+
let text = node.nodeValue;
|
|
4260
|
+
for (let point of this.points)
|
|
4261
|
+
if (point.node == node)
|
|
4262
|
+
point.pos = this.text.length + Math.min(point.offset, text.length);
|
|
4263
|
+
for (let off = 0, re = this.lineSeparator ? null : /\r\n?|\n/g; ; ) {
|
|
4264
|
+
let nextBreak = -1, breakSize = 1, m;
|
|
4265
|
+
if (this.lineSeparator) {
|
|
4266
|
+
nextBreak = text.indexOf(this.lineSeparator, off);
|
|
4267
|
+
breakSize = this.lineSeparator.length;
|
|
4268
|
+
} else if (m = re.exec(text)) {
|
|
4269
|
+
nextBreak = m.index;
|
|
4270
|
+
breakSize = m[0].length;
|
|
4271
|
+
}
|
|
4272
|
+
this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));
|
|
4273
|
+
if (nextBreak < 0)
|
|
4274
|
+
break;
|
|
4275
|
+
this.lineBreak();
|
|
4276
|
+
if (breakSize > 1) {
|
|
4277
|
+
for (let point of this.points)
|
|
4278
|
+
if (point.node == node && point.pos > this.text.length)
|
|
4279
|
+
point.pos -= breakSize - 1;
|
|
4280
|
+
}
|
|
4281
|
+
off = nextBreak + breakSize;
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4284
|
+
readNode(node) {
|
|
4285
|
+
if (node.cmIgnore)
|
|
4286
|
+
return;
|
|
4287
|
+
let view = ContentView.get(node);
|
|
4288
|
+
let fromView = view && view.overrideDOMText;
|
|
4289
|
+
if (fromView != null) {
|
|
4290
|
+
this.findPointInside(node, fromView.length);
|
|
4291
|
+
for (let i = fromView.iter(); !i.next().done; ) {
|
|
4292
|
+
if (i.lineBreak)
|
|
4293
|
+
this.lineBreak();
|
|
4294
|
+
else
|
|
4295
|
+
this.append(i.value);
|
|
4296
|
+
}
|
|
4297
|
+
} else if (node.nodeType == 3) {
|
|
4298
|
+
this.readTextNode(node);
|
|
4299
|
+
} else if (node.nodeName == "BR") {
|
|
4300
|
+
if (node.nextSibling)
|
|
4301
|
+
this.lineBreak();
|
|
4302
|
+
} else if (node.nodeType == 1) {
|
|
4303
|
+
this.readRange(node.firstChild, null);
|
|
4304
|
+
}
|
|
4305
|
+
}
|
|
4306
|
+
findPointBefore(node, next) {
|
|
4307
|
+
for (let point of this.points)
|
|
4308
|
+
if (point.node == node && node.childNodes[point.offset] == next)
|
|
4309
|
+
point.pos = this.text.length;
|
|
4310
|
+
}
|
|
4311
|
+
findPointInside(node, maxLen) {
|
|
4312
|
+
for (let point of this.points)
|
|
4313
|
+
if (node.nodeType == 3 ? point.node == node : node.contains(point.node))
|
|
4314
|
+
point.pos = this.text.length + Math.min(maxLen, point.offset);
|
|
4315
|
+
}
|
|
4316
|
+
};
|
|
4317
|
+
function isBlockElement(node) {
|
|
4318
|
+
return node.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);
|
|
4319
|
+
}
|
|
4320
|
+
var DOMPoint = class {
|
|
4321
|
+
constructor(node, offset) {
|
|
4322
|
+
this.node = node;
|
|
4323
|
+
this.offset = offset;
|
|
4324
|
+
this.pos = -1;
|
|
4325
|
+
}
|
|
4326
|
+
};
|
|
4224
4327
|
var nav = typeof navigator != "undefined" ? navigator : { userAgent: "", vendor: "", platform: "" };
|
|
4225
4328
|
var doc = typeof document != "undefined" ? document : { documentElement: { style: {} } };
|
|
4226
4329
|
var ie_edge = /* @__PURE__ */ /Edge\/(\d+)/.exec(nav.userAgent);
|
|
@@ -4275,7 +4378,7 @@ var TextView = class extends ContentView {
|
|
|
4275
4378
|
this.createDOM(dom);
|
|
4276
4379
|
}
|
|
4277
4380
|
merge(from, to, source) {
|
|
4278
|
-
if (source && (!(source instanceof TextView) || this.length - (to - from) + source.length > MaxJoinLen))
|
|
4381
|
+
if (this.flags & 8 || source && (!(source instanceof TextView) || this.length - (to - from) + source.length > MaxJoinLen || source.flags & 8))
|
|
4279
4382
|
return false;
|
|
4280
4383
|
this.text = this.text.slice(0, from) + (source ? source.text : "") + this.text.slice(to);
|
|
4281
4384
|
this.markDirty();
|
|
@@ -4285,6 +4388,7 @@ var TextView = class extends ContentView {
|
|
|
4285
4388
|
let result = new TextView(this.text.slice(from));
|
|
4286
4389
|
this.text = this.text.slice(0, from);
|
|
4287
4390
|
this.markDirty();
|
|
4391
|
+
result.flags |= this.flags & 8;
|
|
4288
4392
|
return result;
|
|
4289
4393
|
}
|
|
4290
4394
|
localPosFromDOM(node, offset) {
|
|
@@ -4318,16 +4422,19 @@ var MarkView = class extends ContentView {
|
|
|
4318
4422
|
dom.setAttribute(name, this.mark.attrs[name]);
|
|
4319
4423
|
return dom;
|
|
4320
4424
|
}
|
|
4425
|
+
canReuseDOM(other) {
|
|
4426
|
+
return super.canReuseDOM(other) && !((this.flags | other.flags) & 8);
|
|
4427
|
+
}
|
|
4321
4428
|
reuseDOM(node) {
|
|
4322
4429
|
if (node.nodeName == this.mark.tagName.toUpperCase()) {
|
|
4323
4430
|
this.setDOM(node);
|
|
4324
|
-
this.
|
|
4431
|
+
this.flags |= 4 | 2;
|
|
4325
4432
|
}
|
|
4326
4433
|
}
|
|
4327
4434
|
sync(view, track) {
|
|
4328
4435
|
if (!this.dom)
|
|
4329
4436
|
this.setDOM(this.setAttrs(document.createElement(this.mark.tagName)));
|
|
4330
|
-
else if (this.
|
|
4437
|
+
else if (this.flags & 4)
|
|
4331
4438
|
this.setAttrs(this.dom);
|
|
4332
4439
|
super.sync(view, track);
|
|
4333
4440
|
}
|
|
@@ -4402,7 +4509,7 @@ var WidgetView = class extends ContentView {
|
|
|
4402
4509
|
this.prevWidget = null;
|
|
4403
4510
|
}
|
|
4404
4511
|
static create(widget, length2, side) {
|
|
4405
|
-
return new
|
|
4512
|
+
return new WidgetView(widget, length2, side);
|
|
4406
4513
|
}
|
|
4407
4514
|
split(from) {
|
|
4408
4515
|
let result = WidgetView.create(this.widget, this.length - from, this.side);
|
|
@@ -4490,127 +4597,6 @@ var WidgetView = class extends ContentView {
|
|
|
4490
4597
|
this.widget.destroy(this.dom);
|
|
4491
4598
|
}
|
|
4492
4599
|
};
|
|
4493
|
-
var CompositionView = class extends WidgetView {
|
|
4494
|
-
domAtPos(pos) {
|
|
4495
|
-
let { topView, text } = this.widget;
|
|
4496
|
-
if (!topView)
|
|
4497
|
-
return new DOMPos(text, Math.min(pos, text.nodeValue.length));
|
|
4498
|
-
return scanCompositionTree(pos, 0, topView, text, this.length - topView.length, (v, p) => v.domAtPos(p), (text2, p) => new DOMPos(text2, Math.min(p, text2.nodeValue.length)));
|
|
4499
|
-
}
|
|
4500
|
-
sync() {
|
|
4501
|
-
this.setDOM(this.widget.toDOM());
|
|
4502
|
-
}
|
|
4503
|
-
localPosFromDOM(node, offset) {
|
|
4504
|
-
let { topView, text } = this.widget;
|
|
4505
|
-
if (!topView)
|
|
4506
|
-
return Math.min(offset, this.length);
|
|
4507
|
-
return posFromDOMInCompositionTree(node, offset, topView, text, this.length - topView.length);
|
|
4508
|
-
}
|
|
4509
|
-
ignoreMutation() {
|
|
4510
|
-
return false;
|
|
4511
|
-
}
|
|
4512
|
-
get overrideDOMText() {
|
|
4513
|
-
return null;
|
|
4514
|
-
}
|
|
4515
|
-
coordsAt(pos, side) {
|
|
4516
|
-
let { topView, text } = this.widget;
|
|
4517
|
-
if (!topView)
|
|
4518
|
-
return textCoords(text, pos, side);
|
|
4519
|
-
return scanCompositionTree(pos, side, topView, text, this.length - topView.length, (v, pos2, side2) => v.coordsAt(pos2, side2), (text2, pos2, side2) => textCoords(text2, pos2, side2));
|
|
4520
|
-
}
|
|
4521
|
-
destroy() {
|
|
4522
|
-
var _a2;
|
|
4523
|
-
super.destroy();
|
|
4524
|
-
(_a2 = this.widget.topView) === null || _a2 === void 0 ? void 0 : _a2.destroy();
|
|
4525
|
-
}
|
|
4526
|
-
get isEditable() {
|
|
4527
|
-
return true;
|
|
4528
|
-
}
|
|
4529
|
-
canReuseDOM() {
|
|
4530
|
-
return true;
|
|
4531
|
-
}
|
|
4532
|
-
};
|
|
4533
|
-
function scanCompositionTree(pos, side, view, text, dLen, enterView, fromText) {
|
|
4534
|
-
if (view instanceof MarkView) {
|
|
4535
|
-
for (let child = view.dom.firstChild; child; child = child.nextSibling) {
|
|
4536
|
-
let desc = ContentView.get(child);
|
|
4537
|
-
if (!desc) {
|
|
4538
|
-
let inner = scanCompositionNode(pos, side, child, fromText);
|
|
4539
|
-
if (typeof inner != "number")
|
|
4540
|
-
return inner;
|
|
4541
|
-
pos = inner;
|
|
4542
|
-
} else {
|
|
4543
|
-
let hasComp = contains(child, text);
|
|
4544
|
-
let len = desc.length + (hasComp ? dLen : 0);
|
|
4545
|
-
if (pos < len || pos == len && desc.getSide() <= 0)
|
|
4546
|
-
return hasComp ? scanCompositionTree(pos, side, desc, text, dLen, enterView, fromText) : enterView(desc, pos, side);
|
|
4547
|
-
pos -= len;
|
|
4548
|
-
}
|
|
4549
|
-
}
|
|
4550
|
-
return enterView(view, view.length, -1);
|
|
4551
|
-
} else if (view.dom == text) {
|
|
4552
|
-
return fromText(text, pos, side);
|
|
4553
|
-
} else {
|
|
4554
|
-
return enterView(view, pos, side);
|
|
4555
|
-
}
|
|
4556
|
-
}
|
|
4557
|
-
function scanCompositionNode(pos, side, node, fromText) {
|
|
4558
|
-
if (node.nodeType == 3) {
|
|
4559
|
-
let len = node.nodeValue.length;
|
|
4560
|
-
if (pos <= len)
|
|
4561
|
-
return fromText(node, pos, side);
|
|
4562
|
-
pos -= len;
|
|
4563
|
-
} else if (node.nodeType == 1 && node.contentEditable != "false") {
|
|
4564
|
-
for (let child = node.firstChild; child; child = child.nextSibling) {
|
|
4565
|
-
let inner = scanCompositionNode(pos, side, child, fromText);
|
|
4566
|
-
if (typeof inner != "number")
|
|
4567
|
-
return inner;
|
|
4568
|
-
pos = inner;
|
|
4569
|
-
}
|
|
4570
|
-
}
|
|
4571
|
-
return pos;
|
|
4572
|
-
}
|
|
4573
|
-
function posFromDOMInCompositionTree(node, offset, view, text, dLen) {
|
|
4574
|
-
if (view instanceof MarkView) {
|
|
4575
|
-
let pos = 0;
|
|
4576
|
-
for (let child = view.dom.firstChild; child; child = child.nextSibling) {
|
|
4577
|
-
let childView = ContentView.get(child);
|
|
4578
|
-
if (childView) {
|
|
4579
|
-
let hasComp = contains(child, text);
|
|
4580
|
-
if (contains(child, node))
|
|
4581
|
-
return pos + (hasComp ? posFromDOMInCompositionTree(node, offset, childView, text, dLen) : childView.localPosFromDOM(node, offset));
|
|
4582
|
-
pos += childView.length + (hasComp ? dLen : 0);
|
|
4583
|
-
} else {
|
|
4584
|
-
let inner = posFromDOMInOpaqueNode(node, offset, child);
|
|
4585
|
-
if (inner.result != null)
|
|
4586
|
-
return pos + inner.result;
|
|
4587
|
-
pos += inner.size;
|
|
4588
|
-
}
|
|
4589
|
-
}
|
|
4590
|
-
} else if (view.dom == text) {
|
|
4591
|
-
return Math.min(offset, text.nodeValue.length);
|
|
4592
|
-
}
|
|
4593
|
-
return view.localPosFromDOM(node, offset);
|
|
4594
|
-
}
|
|
4595
|
-
function posFromDOMInOpaqueNode(node, offset, target) {
|
|
4596
|
-
if (target.nodeType == 3) {
|
|
4597
|
-
return node == target ? { result: offset } : { size: target.nodeValue.length };
|
|
4598
|
-
} else if (target.nodeType == 1 && target.contentEditable != "false") {
|
|
4599
|
-
let pos = 0;
|
|
4600
|
-
for (let child = target.firstChild, i = 0; ; child = child.nextSibling, i++) {
|
|
4601
|
-
if (node == target && i == offset)
|
|
4602
|
-
return { result: pos };
|
|
4603
|
-
if (!child)
|
|
4604
|
-
return { size: pos };
|
|
4605
|
-
let inner = posFromDOMInOpaqueNode(node, offset, child);
|
|
4606
|
-
if (inner.result != null)
|
|
4607
|
-
return { result: offset + inner.result };
|
|
4608
|
-
pos += inner.size;
|
|
4609
|
-
}
|
|
4610
|
-
} else {
|
|
4611
|
-
return target.contains(node) ? { result: 0 } : { size: 0 };
|
|
4612
|
-
}
|
|
4613
|
-
}
|
|
4614
4600
|
var WidgetBufferView = class extends ContentView {
|
|
4615
4601
|
constructor(side) {
|
|
4616
4602
|
super();
|
|
@@ -4736,16 +4722,19 @@ function combineAttrs(source, target) {
|
|
|
4736
4722
|
}
|
|
4737
4723
|
return target;
|
|
4738
4724
|
}
|
|
4739
|
-
|
|
4725
|
+
var noAttrs = /* @__PURE__ */ Object.create(null);
|
|
4726
|
+
function attrsEq(a, b, ignore) {
|
|
4740
4727
|
if (a == b)
|
|
4741
4728
|
return true;
|
|
4742
|
-
if (!a
|
|
4743
|
-
|
|
4729
|
+
if (!a)
|
|
4730
|
+
a = noAttrs;
|
|
4731
|
+
if (!b)
|
|
4732
|
+
b = noAttrs;
|
|
4744
4733
|
let keysA = Object.keys(a), keysB = Object.keys(b);
|
|
4745
|
-
if (keysA.length != keysB.length)
|
|
4734
|
+
if (keysA.length - (ignore && keysA.indexOf(ignore) > -1 ? 1 : 0) != keysB.length - (ignore && keysB.indexOf(ignore) > -1 ? 1 : 0))
|
|
4746
4735
|
return false;
|
|
4747
4736
|
for (let key of keysA) {
|
|
4748
|
-
if (keysB.indexOf(key) == -1 || a[key] !== b[key])
|
|
4737
|
+
if (key != ignore && (keysB.indexOf(key) == -1 || a[key] !== b[key]))
|
|
4749
4738
|
return false;
|
|
4750
4739
|
}
|
|
4751
4740
|
return true;
|
|
@@ -4764,6 +4753,14 @@ function updateAttrs(dom, prev, attrs) {
|
|
|
4764
4753
|
}
|
|
4765
4754
|
return !!changed;
|
|
4766
4755
|
}
|
|
4756
|
+
function getAttrs(dom) {
|
|
4757
|
+
let attrs = /* @__PURE__ */ Object.create(null);
|
|
4758
|
+
for (let i = 0; i < dom.attributes.length; i++) {
|
|
4759
|
+
let attr = dom.attributes[i];
|
|
4760
|
+
attrs[attr.name] = attr.value;
|
|
4761
|
+
}
|
|
4762
|
+
return attrs;
|
|
4763
|
+
}
|
|
4767
4764
|
var WidgetType = class {
|
|
4768
4765
|
/**
|
|
4769
4766
|
Compare this instance to another instance of the same type.
|
|
@@ -4832,12 +4829,6 @@ var WidgetType = class {
|
|
|
4832
4829
|
/**
|
|
4833
4830
|
@internal
|
|
4834
4831
|
*/
|
|
4835
|
-
get customView() {
|
|
4836
|
-
return null;
|
|
4837
|
-
}
|
|
4838
|
-
/**
|
|
4839
|
-
@internal
|
|
4840
|
-
*/
|
|
4841
4832
|
get isHidden() {
|
|
4842
4833
|
return false;
|
|
4843
4834
|
}
|
|
@@ -4938,7 +4929,8 @@ var MarkDecoration = class extends Decoration {
|
|
|
4938
4929
|
this.attrs = spec.attributes || null;
|
|
4939
4930
|
}
|
|
4940
4931
|
eq(other) {
|
|
4941
|
-
|
|
4932
|
+
var _a2, _b;
|
|
4933
|
+
return this == other || other instanceof MarkDecoration && this.tagName == other.tagName && (this.class || ((_a2 = this.attrs) === null || _a2 === void 0 ? void 0 : _a2.class)) == (other.class || ((_b = other.attrs) === null || _b === void 0 ? void 0 : _b.class)) && attrsEq(this.attrs, other.attrs, "class");
|
|
4942
4934
|
}
|
|
4943
4935
|
range(from, to = from) {
|
|
4944
4936
|
if (from >= to)
|
|
@@ -5083,7 +5075,7 @@ var LineView = class extends ContentView {
|
|
|
5083
5075
|
reuseDOM(node) {
|
|
5084
5076
|
if (node.nodeName == "DIV") {
|
|
5085
5077
|
this.setDOM(node);
|
|
5086
|
-
this.
|
|
5078
|
+
this.flags |= 4 | 2;
|
|
5087
5079
|
}
|
|
5088
5080
|
}
|
|
5089
5081
|
sync(view, track) {
|
|
@@ -5092,7 +5084,7 @@ var LineView = class extends ContentView {
|
|
|
5092
5084
|
this.setDOM(document.createElement("div"));
|
|
5093
5085
|
this.dom.className = "cm-line";
|
|
5094
5086
|
this.prevAttrs = this.attrs ? null : void 0;
|
|
5095
|
-
} else if (this.
|
|
5087
|
+
} else if (this.flags & 4) {
|
|
5096
5088
|
clearAttributes(this.dom);
|
|
5097
5089
|
this.dom.className = "cm-line";
|
|
5098
5090
|
this.prevAttrs = this.attrs ? null : void 0;
|
|
@@ -5136,8 +5128,8 @@ var LineView = class extends ContentView {
|
|
|
5136
5128
|
if (!this.children.length && rect && this.parent) {
|
|
5137
5129
|
let { heightOracle } = this.parent.view.viewState, height = rect.bottom - rect.top;
|
|
5138
5130
|
if (Math.abs(height - heightOracle.lineHeight) < 2 && heightOracle.textHeight < height) {
|
|
5139
|
-
let
|
|
5140
|
-
return { top: rect.top +
|
|
5131
|
+
let dist2 = (height - heightOracle.textHeight) / 2;
|
|
5132
|
+
return { top: rect.top + dist2, bottom: rect.bottom - dist2, left: rect.left, right: rect.left };
|
|
5141
5133
|
}
|
|
5142
5134
|
}
|
|
5143
5135
|
return rect;
|
|
@@ -5899,115 +5891,14 @@ function moveVisually(line, order, dir, start, forward) {
|
|
|
5899
5891
|
return EditorSelection.cursor(nextSpan.side(!forward, dir) + line.from, forward ? 1 : -1, nextSpan.level);
|
|
5900
5892
|
return EditorSelection.cursor(nextIndex + line.from, forward ? -1 : 1, span.level);
|
|
5901
5893
|
}
|
|
5902
|
-
var LineBreakPlaceholder = "\uFFFF";
|
|
5903
|
-
var DOMReader = class {
|
|
5904
|
-
constructor(points, state) {
|
|
5905
|
-
this.points = points;
|
|
5906
|
-
this.text = "";
|
|
5907
|
-
this.lineSeparator = state.facet(EditorState.lineSeparator);
|
|
5908
|
-
}
|
|
5909
|
-
append(text) {
|
|
5910
|
-
this.text += text;
|
|
5911
|
-
}
|
|
5912
|
-
lineBreak() {
|
|
5913
|
-
this.text += LineBreakPlaceholder;
|
|
5914
|
-
}
|
|
5915
|
-
readRange(start, end) {
|
|
5916
|
-
if (!start)
|
|
5917
|
-
return this;
|
|
5918
|
-
let parent = start.parentNode;
|
|
5919
|
-
for (let cur2 = start; ; ) {
|
|
5920
|
-
this.findPointBefore(parent, cur2);
|
|
5921
|
-
let oldLen = this.text.length;
|
|
5922
|
-
this.readNode(cur2);
|
|
5923
|
-
let next = cur2.nextSibling;
|
|
5924
|
-
if (next == end)
|
|
5925
|
-
break;
|
|
5926
|
-
let view = ContentView.get(cur2), nextView = ContentView.get(next);
|
|
5927
|
-
if (view && nextView ? view.breakAfter : (view ? view.breakAfter : isBlockElement(cur2)) || isBlockElement(next) && (cur2.nodeName != "BR" || cur2.cmIgnore) && this.text.length > oldLen)
|
|
5928
|
-
this.lineBreak();
|
|
5929
|
-
cur2 = next;
|
|
5930
|
-
}
|
|
5931
|
-
this.findPointBefore(parent, end);
|
|
5932
|
-
return this;
|
|
5933
|
-
}
|
|
5934
|
-
readTextNode(node) {
|
|
5935
|
-
let text = node.nodeValue;
|
|
5936
|
-
for (let point of this.points)
|
|
5937
|
-
if (point.node == node)
|
|
5938
|
-
point.pos = this.text.length + Math.min(point.offset, text.length);
|
|
5939
|
-
for (let off = 0, re = this.lineSeparator ? null : /\r\n?|\n/g; ; ) {
|
|
5940
|
-
let nextBreak = -1, breakSize = 1, m;
|
|
5941
|
-
if (this.lineSeparator) {
|
|
5942
|
-
nextBreak = text.indexOf(this.lineSeparator, off);
|
|
5943
|
-
breakSize = this.lineSeparator.length;
|
|
5944
|
-
} else if (m = re.exec(text)) {
|
|
5945
|
-
nextBreak = m.index;
|
|
5946
|
-
breakSize = m[0].length;
|
|
5947
|
-
}
|
|
5948
|
-
this.append(text.slice(off, nextBreak < 0 ? text.length : nextBreak));
|
|
5949
|
-
if (nextBreak < 0)
|
|
5950
|
-
break;
|
|
5951
|
-
this.lineBreak();
|
|
5952
|
-
if (breakSize > 1) {
|
|
5953
|
-
for (let point of this.points)
|
|
5954
|
-
if (point.node == node && point.pos > this.text.length)
|
|
5955
|
-
point.pos -= breakSize - 1;
|
|
5956
|
-
}
|
|
5957
|
-
off = nextBreak + breakSize;
|
|
5958
|
-
}
|
|
5959
|
-
}
|
|
5960
|
-
readNode(node) {
|
|
5961
|
-
if (node.cmIgnore)
|
|
5962
|
-
return;
|
|
5963
|
-
let view = ContentView.get(node);
|
|
5964
|
-
let fromView = view && view.overrideDOMText;
|
|
5965
|
-
if (fromView != null) {
|
|
5966
|
-
this.findPointInside(node, fromView.length);
|
|
5967
|
-
for (let i = fromView.iter(); !i.next().done; ) {
|
|
5968
|
-
if (i.lineBreak)
|
|
5969
|
-
this.lineBreak();
|
|
5970
|
-
else
|
|
5971
|
-
this.append(i.value);
|
|
5972
|
-
}
|
|
5973
|
-
} else if (node.nodeType == 3) {
|
|
5974
|
-
this.readTextNode(node);
|
|
5975
|
-
} else if (node.nodeName == "BR") {
|
|
5976
|
-
if (node.nextSibling)
|
|
5977
|
-
this.lineBreak();
|
|
5978
|
-
} else if (node.nodeType == 1) {
|
|
5979
|
-
this.readRange(node.firstChild, null);
|
|
5980
|
-
}
|
|
5981
|
-
}
|
|
5982
|
-
findPointBefore(node, next) {
|
|
5983
|
-
for (let point of this.points)
|
|
5984
|
-
if (point.node == node && node.childNodes[point.offset] == next)
|
|
5985
|
-
point.pos = this.text.length;
|
|
5986
|
-
}
|
|
5987
|
-
findPointInside(node, maxLen) {
|
|
5988
|
-
for (let point of this.points)
|
|
5989
|
-
if (node.nodeType == 3 ? point.node == node : node.contains(point.node))
|
|
5990
|
-
point.pos = this.text.length + Math.min(maxLen, point.offset);
|
|
5991
|
-
}
|
|
5992
|
-
};
|
|
5993
|
-
function isBlockElement(node) {
|
|
5994
|
-
return node.nodeType == 1 && /^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(node.nodeName);
|
|
5995
|
-
}
|
|
5996
|
-
var DOMPoint = class {
|
|
5997
|
-
constructor(node, offset) {
|
|
5998
|
-
this.node = node;
|
|
5999
|
-
this.offset = offset;
|
|
6000
|
-
this.pos = -1;
|
|
6001
|
-
}
|
|
6002
|
-
};
|
|
6003
5894
|
var DocView = class extends ContentView {
|
|
6004
5895
|
constructor(view) {
|
|
6005
5896
|
super();
|
|
6006
5897
|
this.view = view;
|
|
6007
|
-
this.compositionDeco = Decoration.none;
|
|
6008
|
-
this.compositionNode = null;
|
|
6009
5898
|
this.decorations = [];
|
|
6010
5899
|
this.dynamicDecorationMap = [];
|
|
5900
|
+
this.hasComposition = null;
|
|
5901
|
+
this.markedForComposition = /* @__PURE__ */ new Set();
|
|
6011
5902
|
this.minWidth = 0;
|
|
6012
5903
|
this.minWidthFrom = 0;
|
|
6013
5904
|
this.minWidthTo = 0;
|
|
@@ -6019,7 +5910,7 @@ var DocView = class extends ContentView {
|
|
|
6019
5910
|
this.children = [new LineView()];
|
|
6020
5911
|
this.children[0].setParent(this);
|
|
6021
5912
|
this.updateDeco();
|
|
6022
|
-
this.updateInner([new ChangedRange(0, 0, 0, view.state.doc.length)], 0);
|
|
5913
|
+
this.updateInner([new ChangedRange(0, 0, 0, view.state.doc.length)], 0, null);
|
|
6023
5914
|
}
|
|
6024
5915
|
get length() {
|
|
6025
5916
|
return this.view.state.doc.length;
|
|
@@ -6035,16 +5926,22 @@ var DocView = class extends ContentView {
|
|
|
6035
5926
|
this.minWidthTo = update.changes.mapPos(this.minWidthTo, 1);
|
|
6036
5927
|
}
|
|
6037
5928
|
}
|
|
6038
|
-
|
|
6039
|
-
if (
|
|
5929
|
+
let composition = this.view.inputState.composing < 0 ? null : findCompositionRange(this.view, update.changes);
|
|
5930
|
+
if (this.hasComposition) {
|
|
5931
|
+
this.markedForComposition.clear();
|
|
5932
|
+
let { from, to } = this.hasComposition;
|
|
5933
|
+
changedRanges = new ChangedRange(from, to, update.changes.mapPos(from, -1), update.changes.mapPos(to, 1)).addToSet(changedRanges.slice());
|
|
5934
|
+
}
|
|
5935
|
+
this.hasComposition = composition ? { from: composition.range.fromB, to: composition.range.toB } : null;
|
|
5936
|
+
if ((browser.ie || browser.chrome) && !composition && update && update.state.doc.lines != update.startState.doc.lines)
|
|
6040
5937
|
this.forceSelection = true;
|
|
6041
5938
|
let prevDeco = this.decorations, deco = this.updateDeco();
|
|
6042
5939
|
let decoDiff = findChangedDeco(prevDeco, deco, update.changes);
|
|
6043
5940
|
changedRanges = ChangedRange.extendWithRanges(changedRanges, decoDiff);
|
|
6044
|
-
if (this.
|
|
5941
|
+
if (!(this.flags & 7) && changedRanges.length == 0) {
|
|
6045
5942
|
return false;
|
|
6046
5943
|
} else {
|
|
6047
|
-
this.updateInner(changedRanges, update.startState.doc.length);
|
|
5944
|
+
this.updateInner(changedRanges, update.startState.doc.length, composition);
|
|
6048
5945
|
if (update.transactions.length)
|
|
6049
5946
|
this.lastUpdate = Date.now();
|
|
6050
5947
|
return true;
|
|
@@ -6052,20 +5949,24 @@ var DocView = class extends ContentView {
|
|
|
6052
5949
|
}
|
|
6053
5950
|
// Used by update and the constructor do perform the actual DOM
|
|
6054
5951
|
// update
|
|
6055
|
-
updateInner(changes, oldLength) {
|
|
5952
|
+
updateInner(changes, oldLength, composition) {
|
|
6056
5953
|
this.view.viewState.mustMeasureContent = true;
|
|
6057
|
-
this.updateChildren(changes, oldLength);
|
|
5954
|
+
this.updateChildren(changes, oldLength, composition);
|
|
6058
5955
|
let { observer } = this.view;
|
|
6059
5956
|
observer.ignore(() => {
|
|
6060
5957
|
this.dom.style.height = this.view.viewState.contentHeight + "px";
|
|
6061
5958
|
this.dom.style.flexBasis = this.minWidth ? this.minWidth + "px" : "";
|
|
6062
5959
|
let track = browser.chrome || browser.ios ? { node: observer.selectionRange.focusNode, written: false } : void 0;
|
|
6063
5960
|
this.sync(this.view, track);
|
|
6064
|
-
this.
|
|
5961
|
+
this.flags &= ~7;
|
|
6065
5962
|
if (track && (track.written || observer.selectionRange.focusNode != track.node))
|
|
6066
5963
|
this.forceSelection = true;
|
|
6067
5964
|
this.dom.style.height = "";
|
|
6068
5965
|
});
|
|
5966
|
+
this.markedForComposition.forEach(
|
|
5967
|
+
(cView) => cView.flags &= ~8
|
|
5968
|
+
/* Composition */
|
|
5969
|
+
);
|
|
6069
5970
|
let gaps = [];
|
|
6070
5971
|
if (this.view.viewport.from || this.view.viewport.to < this.view.state.doc.length) {
|
|
6071
5972
|
for (let child of this.children)
|
|
@@ -6074,18 +5975,69 @@ var DocView = class extends ContentView {
|
|
|
6074
5975
|
}
|
|
6075
5976
|
observer.updateGaps(gaps);
|
|
6076
5977
|
}
|
|
6077
|
-
updateChildren(changes, oldLength) {
|
|
5978
|
+
updateChildren(changes, oldLength, composition) {
|
|
5979
|
+
let ranges = composition ? composition.range.addToSet(changes.slice()) : changes;
|
|
6078
5980
|
let cursor = this.childCursor(oldLength);
|
|
6079
|
-
for (let i =
|
|
6080
|
-
let next = i >= 0 ?
|
|
5981
|
+
for (let i = ranges.length - 1; ; i--) {
|
|
5982
|
+
let next = i >= 0 ? ranges[i] : null;
|
|
6081
5983
|
if (!next)
|
|
6082
5984
|
break;
|
|
6083
|
-
let { fromA, toA, fromB, toB } = next;
|
|
6084
|
-
|
|
5985
|
+
let { fromA, toA, fromB, toB } = next, content, breakAtStart, openStart, openEnd;
|
|
5986
|
+
if (composition && composition.range.fromB < toB && composition.range.toB > fromB) {
|
|
5987
|
+
let before = ContentBuilder.build(this.view.state.doc, fromB, composition.range.fromB, this.decorations, this.dynamicDecorationMap);
|
|
5988
|
+
let after = ContentBuilder.build(this.view.state.doc, composition.range.toB, toB, this.decorations, this.dynamicDecorationMap);
|
|
5989
|
+
breakAtStart = before.breakAtStart;
|
|
5990
|
+
openStart = before.openStart;
|
|
5991
|
+
openEnd = after.openEnd;
|
|
5992
|
+
let compLine = this.compositionView(composition);
|
|
5993
|
+
if (after.breakAtStart) {
|
|
5994
|
+
compLine.breakAfter = 1;
|
|
5995
|
+
} else if (after.content.length && compLine.merge(compLine.length, compLine.length, after.content[0], false, after.openStart, 0)) {
|
|
5996
|
+
compLine.breakAfter = after.content[0].breakAfter;
|
|
5997
|
+
after.content.shift();
|
|
5998
|
+
}
|
|
5999
|
+
if (before.content.length && compLine.merge(0, 0, before.content[before.content.length - 1], true, 0, before.openEnd)) {
|
|
6000
|
+
before.content.pop();
|
|
6001
|
+
}
|
|
6002
|
+
content = before.content.concat(compLine).concat(after.content);
|
|
6003
|
+
} else {
|
|
6004
|
+
({ content, breakAtStart, openStart, openEnd } = ContentBuilder.build(this.view.state.doc, fromB, toB, this.decorations, this.dynamicDecorationMap));
|
|
6005
|
+
}
|
|
6085
6006
|
let { i: toI, off: toOff } = cursor.findPos(toA, 1);
|
|
6086
6007
|
let { i: fromI, off: fromOff } = cursor.findPos(fromA, -1);
|
|
6087
6008
|
replaceRange(this, fromI, fromOff, toI, toOff, content, breakAtStart, openStart, openEnd);
|
|
6088
6009
|
}
|
|
6010
|
+
if (composition)
|
|
6011
|
+
this.fixCompositionDOM(composition);
|
|
6012
|
+
}
|
|
6013
|
+
compositionView(composition) {
|
|
6014
|
+
let cur2 = new TextView(composition.text.nodeValue);
|
|
6015
|
+
cur2.flags |= 8;
|
|
6016
|
+
for (let { deco } of composition.marks)
|
|
6017
|
+
cur2 = new MarkView(deco, [cur2], cur2.length);
|
|
6018
|
+
let line = new LineView();
|
|
6019
|
+
line.append(cur2, 0);
|
|
6020
|
+
return line;
|
|
6021
|
+
}
|
|
6022
|
+
fixCompositionDOM(composition) {
|
|
6023
|
+
let fix = (dom, cView2) => {
|
|
6024
|
+
cView2.flags |= 8;
|
|
6025
|
+
this.markedForComposition.add(cView2);
|
|
6026
|
+
let prev = ContentView.get(dom);
|
|
6027
|
+
if (prev != cView2) {
|
|
6028
|
+
if (prev)
|
|
6029
|
+
prev.dom = null;
|
|
6030
|
+
cView2.setDOM(dom);
|
|
6031
|
+
}
|
|
6032
|
+
};
|
|
6033
|
+
let pos = this.childPos(composition.range.fromB, 1);
|
|
6034
|
+
let cView = this.children[pos.i];
|
|
6035
|
+
fix(composition.line, cView);
|
|
6036
|
+
for (let i = composition.marks.length - 1; i >= -1; i--) {
|
|
6037
|
+
pos = cView.childPos(pos.off, 1);
|
|
6038
|
+
cView = cView.children[pos.i];
|
|
6039
|
+
fix(i >= 0 ? composition.marks[i].node : composition.text, cView);
|
|
6040
|
+
}
|
|
6089
6041
|
}
|
|
6090
6042
|
// Sync the DOM selection to this.state.selection
|
|
6091
6043
|
updateSelection(mustRead = false, fromPointer = false) {
|
|
@@ -6100,7 +6052,7 @@ var DocView = class extends ContentView {
|
|
|
6100
6052
|
let main = this.view.state.selection.main;
|
|
6101
6053
|
let anchor = this.domAtPos(main.anchor);
|
|
6102
6054
|
let head = main.empty ? anchor : this.domAtPos(main.head);
|
|
6103
|
-
if (browser.gecko && main.empty && !this.
|
|
6055
|
+
if (browser.gecko && main.empty && !this.hasComposition && betweenUneditable(anchor)) {
|
|
6104
6056
|
let dummy = document.createTextNode("");
|
|
6105
6057
|
this.view.observer.ignore(() => anchor.node.insertBefore(dummy, anchor.node.childNodes[anchor.offset] || null));
|
|
6106
6058
|
anchor = head = new DOMPos(dummy, 0);
|
|
@@ -6155,7 +6107,7 @@ var DocView = class extends ContentView {
|
|
|
6155
6107
|
this.impreciseHead = head.precise ? null : new DOMPos(domSel.focusNode, domSel.focusOffset);
|
|
6156
6108
|
}
|
|
6157
6109
|
enforceCursorAssoc() {
|
|
6158
|
-
if (this.
|
|
6110
|
+
if (this.hasComposition)
|
|
6159
6111
|
return;
|
|
6160
6112
|
let { view } = this, cursor = view.state.selection.main;
|
|
6161
6113
|
let sel = getSelection(view.root);
|
|
@@ -6213,6 +6165,28 @@ var DocView = class extends ContentView {
|
|
|
6213
6165
|
off = start;
|
|
6214
6166
|
}
|
|
6215
6167
|
}
|
|
6168
|
+
coordsForChar(pos) {
|
|
6169
|
+
let { i, off } = this.childPos(pos, 1), child = this.children[i];
|
|
6170
|
+
if (!(child instanceof LineView))
|
|
6171
|
+
return null;
|
|
6172
|
+
while (child.children.length) {
|
|
6173
|
+
let { i: i2, off: childOff } = child.childPos(off, 1);
|
|
6174
|
+
for (; ; i2++) {
|
|
6175
|
+
if (i2 == child.children.length)
|
|
6176
|
+
return null;
|
|
6177
|
+
if ((child = child.children[i2]).length)
|
|
6178
|
+
break;
|
|
6179
|
+
}
|
|
6180
|
+
off = childOff;
|
|
6181
|
+
}
|
|
6182
|
+
if (!(child instanceof TextView))
|
|
6183
|
+
return null;
|
|
6184
|
+
let end = findClusterBreak(child.text, off);
|
|
6185
|
+
if (end == off)
|
|
6186
|
+
return null;
|
|
6187
|
+
let rects = textRange(child.dom, off, end).getClientRects();
|
|
6188
|
+
return !rects.length || rects[0].top >= rects[0].bottom ? null : rects[0];
|
|
6189
|
+
}
|
|
6216
6190
|
measureVisibleLineHeights(viewport) {
|
|
6217
6191
|
let result = [], { from, to } = viewport;
|
|
6218
6192
|
let contentWidth = this.view.contentDOM.clientWidth;
|
|
@@ -6259,6 +6233,7 @@ var DocView = class extends ContentView {
|
|
|
6259
6233
|
let dummy = document.createElement("div"), lineHeight, charWidth, textHeight;
|
|
6260
6234
|
dummy.className = "cm-line";
|
|
6261
6235
|
dummy.style.width = "99999px";
|
|
6236
|
+
dummy.style.position = "absolute";
|
|
6262
6237
|
dummy.textContent = "abc def ghi jkl mno pqr stu";
|
|
6263
6238
|
this.view.observer.ignore(() => {
|
|
6264
6239
|
this.dom.appendChild(dummy);
|
|
@@ -6305,7 +6280,6 @@ var DocView = class extends ContentView {
|
|
|
6305
6280
|
this.dynamicDecorationMap[i] = false;
|
|
6306
6281
|
return this.decorations = [
|
|
6307
6282
|
...allDeco,
|
|
6308
|
-
this.compositionDeco,
|
|
6309
6283
|
this.computeBlockGapDeco(),
|
|
6310
6284
|
this.view.viewState.lineGapDeco
|
|
6311
6285
|
];
|
|
@@ -6356,89 +6330,83 @@ var BlockGapWidget = class extends WidgetType {
|
|
|
6356
6330
|
return this.height;
|
|
6357
6331
|
}
|
|
6358
6332
|
};
|
|
6359
|
-
function
|
|
6333
|
+
function findCompositionNode(view) {
|
|
6360
6334
|
let sel = view.observer.selectionRange;
|
|
6361
6335
|
let textNode = sel.focusNode && nearbyTextNode(sel.focusNode, sel.focusOffset, 0);
|
|
6362
6336
|
if (!textNode)
|
|
6363
6337
|
return null;
|
|
6364
|
-
let cView =
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
while (topNode.parentNode != cView.dom)
|
|
6370
|
-
topNode = topNode.parentNode;
|
|
6371
|
-
let prev = topNode.previousSibling;
|
|
6372
|
-
while (prev && !ContentView.get(prev))
|
|
6373
|
-
prev = prev.previousSibling;
|
|
6374
|
-
let pos = prev ? ContentView.get(prev).posAtEnd : cView.posAtStart;
|
|
6375
|
-
return { from: pos, to: pos, node: topNode, text: textNode };
|
|
6338
|
+
let cView = ContentView.get(textNode);
|
|
6339
|
+
let from, to;
|
|
6340
|
+
if (cView instanceof TextView) {
|
|
6341
|
+
from = cView.posAtStart;
|
|
6342
|
+
to = from + cView.length;
|
|
6376
6343
|
} else {
|
|
6377
|
-
|
|
6378
|
-
let
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
else
|
|
6400
|
-
reader.readRange(node.firstChild, null);
|
|
6401
|
-
let { text } = reader;
|
|
6402
|
-
if (text.indexOf(LineBreakPlaceholder) > -1)
|
|
6403
|
-
return noComp;
|
|
6404
|
-
if (newTo - newFrom < text.length) {
|
|
6405
|
-
if (state.doc.sliceString(newFrom, Math.min(state.doc.length, newFrom + text.length)) == text)
|
|
6406
|
-
newTo = newFrom + text.length;
|
|
6407
|
-
else if (state.doc.sliceString(Math.max(0, newTo - text.length), newTo) == text)
|
|
6408
|
-
newFrom = newTo - text.length;
|
|
6409
|
-
else
|
|
6410
|
-
return noComp;
|
|
6411
|
-
} else if (state.doc.sliceString(newFrom, newTo) != text) {
|
|
6412
|
-
return noComp;
|
|
6413
|
-
}
|
|
6414
|
-
let topView = ContentView.get(node);
|
|
6415
|
-
if (topView instanceof CompositionView)
|
|
6416
|
-
topView = topView.widget.topView;
|
|
6417
|
-
else if (topView)
|
|
6418
|
-
topView.parent = null;
|
|
6419
|
-
let deco = Decoration.set(Decoration.replace({ widget: new CompositionWidget(node, textNode, topView), inclusive: true }).range(newFrom, newTo));
|
|
6420
|
-
return { deco, node };
|
|
6421
|
-
}
|
|
6422
|
-
var CompositionWidget = class extends WidgetType {
|
|
6423
|
-
constructor(top2, text, topView) {
|
|
6424
|
-
super();
|
|
6425
|
-
this.top = top2;
|
|
6426
|
-
this.text = text;
|
|
6427
|
-
this.topView = topView;
|
|
6428
|
-
}
|
|
6429
|
-
eq(other) {
|
|
6430
|
-
return this.top == other.top && this.text == other.text;
|
|
6431
|
-
}
|
|
6432
|
-
toDOM() {
|
|
6433
|
-
return this.top;
|
|
6344
|
+
up:
|
|
6345
|
+
for (let offset = 0, node = textNode; ; ) {
|
|
6346
|
+
for (let sibling = node.previousSibling, cView2; sibling; sibling = sibling.previousSibling) {
|
|
6347
|
+
if (cView2 = ContentView.get(sibling)) {
|
|
6348
|
+
from = to = cView2.posAtEnd + offset;
|
|
6349
|
+
break up;
|
|
6350
|
+
}
|
|
6351
|
+
let reader = new DOMReader([], view.state);
|
|
6352
|
+
reader.readNode(sibling);
|
|
6353
|
+
if (reader.text.indexOf(LineBreakPlaceholder) > -1)
|
|
6354
|
+
return null;
|
|
6355
|
+
offset += reader.text.length;
|
|
6356
|
+
}
|
|
6357
|
+
node = node.parentNode;
|
|
6358
|
+
if (!node)
|
|
6359
|
+
return null;
|
|
6360
|
+
let parentView = ContentView.get(node);
|
|
6361
|
+
if (parentView) {
|
|
6362
|
+
from = to = parentView.posAtStart + offset;
|
|
6363
|
+
break;
|
|
6364
|
+
}
|
|
6365
|
+
}
|
|
6434
6366
|
}
|
|
6435
|
-
|
|
6436
|
-
|
|
6367
|
+
return { from, to, node: textNode };
|
|
6368
|
+
}
|
|
6369
|
+
function findCompositionRange(view, changes) {
|
|
6370
|
+
let found = findCompositionNode(view);
|
|
6371
|
+
if (!found)
|
|
6372
|
+
return null;
|
|
6373
|
+
let { from: fromA, to: toA, node: textNode } = found;
|
|
6374
|
+
let fromB = changes.mapPos(fromA, -1), toB = changes.mapPos(toA, 1);
|
|
6375
|
+
let text = textNode.nodeValue;
|
|
6376
|
+
if (/[\n\r]/.test(text))
|
|
6377
|
+
return null;
|
|
6378
|
+
if (toB - fromB != text.length) {
|
|
6379
|
+
let fromB2 = changes.mapPos(fromA, 1), toB2 = changes.mapPos(toA, -1);
|
|
6380
|
+
if (toB2 - fromB2 == text.length)
|
|
6381
|
+
fromB = fromB2, toB = toB2;
|
|
6382
|
+
else if (view.state.doc.sliceString(toB - text.length, toB) == text)
|
|
6383
|
+
fromB = toB - text.length;
|
|
6384
|
+
else if (view.state.doc.sliceString(fromB, fromB + text.length) == text)
|
|
6385
|
+
toB = fromB + text.length;
|
|
6386
|
+
else
|
|
6387
|
+
return null;
|
|
6437
6388
|
}
|
|
6438
|
-
|
|
6439
|
-
|
|
6389
|
+
let { main } = view.state.selection;
|
|
6390
|
+
if (view.state.doc.sliceString(fromB, toB) != text || fromB > main.head || toB < main.head)
|
|
6391
|
+
return null;
|
|
6392
|
+
let marks = [];
|
|
6393
|
+
let range = new ChangedRange(fromA, toA, fromB, toB);
|
|
6394
|
+
for (let parent = textNode.parentNode; ; parent = parent.parentNode) {
|
|
6395
|
+
let parentView = ContentView.get(parent);
|
|
6396
|
+
if (parentView instanceof MarkView)
|
|
6397
|
+
marks.push({ node: parent, deco: parentView.mark });
|
|
6398
|
+
else if (parentView instanceof LineView || parent.nodeName == "DIV" && parent.parentNode == view.contentDOM)
|
|
6399
|
+
return { range, text: textNode, marks, line: parent };
|
|
6400
|
+
else if (parent != view.contentDOM)
|
|
6401
|
+
marks.push({ node: parent, deco: new MarkDecoration({
|
|
6402
|
+
inclusive: true,
|
|
6403
|
+
attributes: getAttrs(parent),
|
|
6404
|
+
tagName: parent.tagName.toLowerCase()
|
|
6405
|
+
}) });
|
|
6406
|
+
else
|
|
6407
|
+
return null;
|
|
6440
6408
|
}
|
|
6441
|
-
}
|
|
6409
|
+
}
|
|
6442
6410
|
function nearbyTextNode(startNode, startOffset, side) {
|
|
6443
6411
|
if (side <= 0)
|
|
6444
6412
|
for (let node = startNode, offset = startOffset; ; ) {
|
|
@@ -6796,9 +6764,9 @@ function moveVertically(view, start, forward, distance) {
|
|
|
6796
6764
|
startY = (dir < 0 ? line.top : line.bottom) + docTop;
|
|
6797
6765
|
}
|
|
6798
6766
|
let resolvedGoal = rect.left + goal;
|
|
6799
|
-
let
|
|
6767
|
+
let dist2 = distance !== null && distance !== void 0 ? distance : view.viewState.heightOracle.textHeight >> 1;
|
|
6800
6768
|
for (let extra = 0; ; extra += 10) {
|
|
6801
|
-
let curY = startY + (
|
|
6769
|
+
let curY = startY + (dist2 + extra) * dir;
|
|
6802
6770
|
let pos = posAtCoords(view, { x: resolvedGoal, y: curY }, false, dir);
|
|
6803
6771
|
if (curY < rect.top || curY > rect.bottom || (dir < 0 ? pos < startPos : pos > startPos))
|
|
6804
6772
|
return EditorSelection.cursor(pos, start.assoc, void 0, goal);
|
|
@@ -7013,12 +6981,16 @@ var PendingKeys = [
|
|
|
7013
6981
|
var EmacsyPendingKeys = "dthko";
|
|
7014
6982
|
var modifierCodes = [16, 17, 18, 20, 91, 92, 224, 225];
|
|
7015
6983
|
var dragScrollMargin = 6;
|
|
7016
|
-
function dragScrollSpeed(
|
|
7017
|
-
return Math.max(0,
|
|
6984
|
+
function dragScrollSpeed(dist2) {
|
|
6985
|
+
return Math.max(0, dist2) * 0.7 + 8;
|
|
6986
|
+
}
|
|
6987
|
+
function dist(a, b) {
|
|
6988
|
+
return Math.max(Math.abs(a.clientX - b.clientX), Math.abs(a.clientY - b.clientY));
|
|
7018
6989
|
}
|
|
7019
6990
|
var MouseSelection = class {
|
|
7020
6991
|
constructor(view, startEvent, style, mustSelect) {
|
|
7021
6992
|
this.view = view;
|
|
6993
|
+
this.startEvent = startEvent;
|
|
7022
6994
|
this.style = style;
|
|
7023
6995
|
this.mustSelect = mustSelect;
|
|
7024
6996
|
this.scrollSpeed = { x: 0, y: 0 };
|
|
@@ -7043,7 +7015,7 @@ var MouseSelection = class {
|
|
|
7043
7015
|
var _a2;
|
|
7044
7016
|
if (event.buttons == 0)
|
|
7045
7017
|
return this.destroy();
|
|
7046
|
-
if (this.dragging
|
|
7018
|
+
if (this.dragging || this.dragging == null && dist(this.startEvent, event) < 10)
|
|
7047
7019
|
return;
|
|
7048
7020
|
this.select(this.lastEvent = event);
|
|
7049
7021
|
let sx = 0, sy = 0;
|
|
@@ -7117,7 +7089,7 @@ var MouseSelection = class {
|
|
|
7117
7089
|
}
|
|
7118
7090
|
select(event) {
|
|
7119
7091
|
let { view } = this, selection = this.skipAtoms(this.style.get(event, this.extend, this.multiple));
|
|
7120
|
-
if (this.mustSelect || !selection.eq(view.state.selection) || selection.main.assoc != view.state.selection.main.assoc)
|
|
7092
|
+
if (this.mustSelect || !selection.eq(view.state.selection) || selection.main.assoc != view.state.selection.main.assoc && this.dragging === false)
|
|
7121
7093
|
this.view.dispatch({
|
|
7122
7094
|
selection,
|
|
7123
7095
|
userEvent: "select.pointer"
|
|
@@ -7507,7 +7479,7 @@ handlers.compositionend = (view) => {
|
|
|
7507
7479
|
Promise.resolve().then(() => view.observer.flush());
|
|
7508
7480
|
} else {
|
|
7509
7481
|
setTimeout(() => {
|
|
7510
|
-
if (view.inputState.composing < 0 && view.docView.
|
|
7482
|
+
if (view.inputState.composing < 0 && view.docView.hasComposition)
|
|
7511
7483
|
view.update([]);
|
|
7512
7484
|
}, 50);
|
|
7513
7485
|
}
|
|
@@ -8688,12 +8660,12 @@ function findPosition({ total, ranges }, ratio) {
|
|
|
8688
8660
|
return ranges[0].from;
|
|
8689
8661
|
if (ratio >= 1)
|
|
8690
8662
|
return ranges[ranges.length - 1].to;
|
|
8691
|
-
let
|
|
8663
|
+
let dist2 = Math.floor(total * ratio);
|
|
8692
8664
|
for (let i = 0; ; i++) {
|
|
8693
8665
|
let { from, to } = ranges[i], size = to - from;
|
|
8694
|
-
if (
|
|
8695
|
-
return from +
|
|
8696
|
-
|
|
8666
|
+
if (dist2 <= size)
|
|
8667
|
+
return from + dist2;
|
|
8668
|
+
dist2 -= size;
|
|
8697
8669
|
}
|
|
8698
8670
|
}
|
|
8699
8671
|
function findFraction(structure, pos) {
|
|
@@ -8899,7 +8871,7 @@ var baseTheme$1 = /* @__PURE__ */ buildTheme("." + baseThemeID, {
|
|
|
8899
8871
|
display: "flex",
|
|
8900
8872
|
height: "100%",
|
|
8901
8873
|
boxSizing: "border-box",
|
|
8902
|
-
|
|
8874
|
+
insetInlineStart: 0,
|
|
8903
8875
|
zIndex: 200
|
|
8904
8876
|
},
|
|
8905
8877
|
"&light .cm-gutters": {
|
|
@@ -9107,7 +9079,7 @@ function applyDOMChange(view, domChange) {
|
|
|
9107
9079
|
let mainSel = newSel && newSel.main.to <= changes.newLength ? newSel.main : void 0;
|
|
9108
9080
|
if (startState.selection.ranges.length > 1 && view.inputState.composing >= 0 && change.to <= sel.to && change.to >= sel.to - 10) {
|
|
9109
9081
|
let replaced = view.state.sliceDoc(change.from, change.to);
|
|
9110
|
-
let
|
|
9082
|
+
let composition = findCompositionNode(view) || view.state.doc.lineAt(sel.head);
|
|
9111
9083
|
let offset = sel.to - change.to, size = sel.to - sel.from;
|
|
9112
9084
|
tr = startState.changeByRange((range) => {
|
|
9113
9085
|
if (range.from == sel.from && range.to == sel.to)
|
|
@@ -9117,7 +9089,7 @@ function applyDOMChange(view, domChange) {
|
|
|
9117
9089
|
// changes in the same node work without aborting
|
|
9118
9090
|
// composition, so cursors in the composition range are
|
|
9119
9091
|
// ignored.
|
|
9120
|
-
|
|
9092
|
+
composition && range.to >= composition.from && range.from <= composition.to)
|
|
9121
9093
|
return { range };
|
|
9122
9094
|
let rangeChanges = startState.changes({ from, to, insert: change.insert }), selOff = range.to - sel.to;
|
|
9123
9095
|
return {
|
|
@@ -9530,7 +9502,7 @@ var DOMObserver = class {
|
|
|
9530
9502
|
return null;
|
|
9531
9503
|
cView.markDirty(rec.type == "attributes");
|
|
9532
9504
|
if (rec.type == "attributes")
|
|
9533
|
-
cView.
|
|
9505
|
+
cView.flags |= 4;
|
|
9534
9506
|
if (rec.type == "childList") {
|
|
9535
9507
|
let childBefore = findChild(cView, rec.previousSibling || rec.target.previousSibling, -1);
|
|
9536
9508
|
let childAfter = findChild(cView, rec.nextSibling || rec.target.nextSibling, 1);
|
|
@@ -10220,6 +10192,17 @@ var EditorView = class {
|
|
|
10220
10192
|
return flattenRect(rect, span.dir == Direction.LTR == side > 0);
|
|
10221
10193
|
}
|
|
10222
10194
|
/**
|
|
10195
|
+
Return the rectangle around a given character. If `pos` does not
|
|
10196
|
+
point in front of a character that is in the viewport and
|
|
10197
|
+
rendered (i.e. not replaced, not a line break), this will return
|
|
10198
|
+
null. For space characters that are a line wrap point, this will
|
|
10199
|
+
return the position before the line break.
|
|
10200
|
+
*/
|
|
10201
|
+
coordsForChar(pos) {
|
|
10202
|
+
this.readMeasured();
|
|
10203
|
+
return this.docView.coordsForChar(pos);
|
|
10204
|
+
}
|
|
10205
|
+
/**
|
|
10223
10206
|
The default width of a character in the editor. May not
|
|
10224
10207
|
accurately reflect the width of all characters (given variable
|
|
10225
10208
|
width fonts or styling of invididual ranges).
|
|
@@ -10518,7 +10501,7 @@ function buildKeymap(bindings, platform = currentPlatform) {
|
|
|
10518
10501
|
else if (current != is)
|
|
10519
10502
|
throw new Error("Key binding " + name + " is used both as a regular binding and as a multi-stroke prefix");
|
|
10520
10503
|
};
|
|
10521
|
-
let add = (scope, key, command2, preventDefault) => {
|
|
10504
|
+
let add = (scope, key, command2, preventDefault, stopPropagation) => {
|
|
10522
10505
|
var _a2, _b;
|
|
10523
10506
|
let scopeObj = bound[scope] || (bound[scope] = /* @__PURE__ */ Object.create(null));
|
|
10524
10507
|
let parts = key.split(/ (?!$)/).map((k) => normalizeKeyName(k, platform));
|
|
@@ -10528,6 +10511,7 @@ function buildKeymap(bindings, platform = currentPlatform) {
|
|
|
10528
10511
|
if (!scopeObj[prefix])
|
|
10529
10512
|
scopeObj[prefix] = {
|
|
10530
10513
|
preventDefault: true,
|
|
10514
|
+
stopPropagation: false,
|
|
10531
10515
|
run: [(view) => {
|
|
10532
10516
|
let ourObj = storedPrefix = { view, prefix, scope };
|
|
10533
10517
|
setTimeout(() => {
|
|
@@ -10540,11 +10524,17 @@ function buildKeymap(bindings, platform = currentPlatform) {
|
|
|
10540
10524
|
}
|
|
10541
10525
|
let full = parts.join(" ");
|
|
10542
10526
|
checkPrefix(full, false);
|
|
10543
|
-
let binding = scopeObj[full] || (scopeObj[full] = {
|
|
10527
|
+
let binding = scopeObj[full] || (scopeObj[full] = {
|
|
10528
|
+
preventDefault: false,
|
|
10529
|
+
stopPropagation: false,
|
|
10530
|
+
run: ((_b = (_a2 = scopeObj._any) === null || _a2 === void 0 ? void 0 : _a2.run) === null || _b === void 0 ? void 0 : _b.slice()) || []
|
|
10531
|
+
});
|
|
10544
10532
|
if (command2)
|
|
10545
10533
|
binding.run.push(command2);
|
|
10546
10534
|
if (preventDefault)
|
|
10547
10535
|
binding.preventDefault = true;
|
|
10536
|
+
if (stopPropagation)
|
|
10537
|
+
binding.stopPropagation = true;
|
|
10548
10538
|
};
|
|
10549
10539
|
for (let b of bindings) {
|
|
10550
10540
|
let scopes = b.scope ? b.scope.split(" ") : ["editor"];
|
|
@@ -10552,7 +10542,7 @@ function buildKeymap(bindings, platform = currentPlatform) {
|
|
|
10552
10542
|
for (let scope of scopes) {
|
|
10553
10543
|
let scopeObj = bound[scope] || (bound[scope] = /* @__PURE__ */ Object.create(null));
|
|
10554
10544
|
if (!scopeObj._any)
|
|
10555
|
-
scopeObj._any = { preventDefault: false, run: [] };
|
|
10545
|
+
scopeObj._any = { preventDefault: false, stopPropagation: false, run: [] };
|
|
10556
10546
|
for (let key in scopeObj)
|
|
10557
10547
|
scopeObj[key].run.push(b.any);
|
|
10558
10548
|
}
|
|
@@ -10560,9 +10550,9 @@ function buildKeymap(bindings, platform = currentPlatform) {
|
|
|
10560
10550
|
if (!name)
|
|
10561
10551
|
continue;
|
|
10562
10552
|
for (let scope of scopes) {
|
|
10563
|
-
add(scope, name, b.run, b.preventDefault);
|
|
10553
|
+
add(scope, name, b.run, b.preventDefault, b.stopPropagation);
|
|
10564
10554
|
if (b.shift)
|
|
10565
|
-
add(scope, "Shift-" + name, b.shift, b.preventDefault);
|
|
10555
|
+
add(scope, "Shift-" + name, b.shift, b.preventDefault, b.stopPropagation);
|
|
10566
10556
|
}
|
|
10567
10557
|
}
|
|
10568
10558
|
return bound;
|
|
@@ -10570,11 +10560,13 @@ function buildKeymap(bindings, platform = currentPlatform) {
|
|
|
10570
10560
|
function runHandlers(map, event, view, scope) {
|
|
10571
10561
|
let name = keyName(event);
|
|
10572
10562
|
let charCode = codePointAt(name, 0), isChar = codePointSize(charCode) == name.length && name != " ";
|
|
10573
|
-
let prefix = "",
|
|
10563
|
+
let prefix = "", handled = false, prevented = false, stopPropagation = false;
|
|
10574
10564
|
if (storedPrefix && storedPrefix.view == view && storedPrefix.scope == scope) {
|
|
10575
10565
|
prefix = storedPrefix.prefix + " ";
|
|
10576
|
-
if (
|
|
10566
|
+
if (modifierCodes.indexOf(event.keyCode) < 0) {
|
|
10567
|
+
prevented = true;
|
|
10577
10568
|
storedPrefix = null;
|
|
10569
|
+
}
|
|
10578
10570
|
}
|
|
10579
10571
|
let ran = /* @__PURE__ */ new Set();
|
|
10580
10572
|
let runFor = (binding) => {
|
|
@@ -10582,32 +10574,42 @@ function runHandlers(map, event, view, scope) {
|
|
|
10582
10574
|
for (let cmd2 of binding.run)
|
|
10583
10575
|
if (!ran.has(cmd2)) {
|
|
10584
10576
|
ran.add(cmd2);
|
|
10585
|
-
if (cmd2(view, event))
|
|
10577
|
+
if (cmd2(view, event)) {
|
|
10578
|
+
if (binding.stopPropagation)
|
|
10579
|
+
stopPropagation = true;
|
|
10586
10580
|
return true;
|
|
10581
|
+
}
|
|
10587
10582
|
}
|
|
10588
|
-
if (binding.preventDefault)
|
|
10589
|
-
|
|
10583
|
+
if (binding.preventDefault) {
|
|
10584
|
+
if (binding.stopPropagation)
|
|
10585
|
+
stopPropagation = true;
|
|
10586
|
+
prevented = true;
|
|
10587
|
+
}
|
|
10590
10588
|
}
|
|
10591
10589
|
return false;
|
|
10592
10590
|
};
|
|
10593
10591
|
let scopeObj = map[scope], baseName, shiftName;
|
|
10594
10592
|
if (scopeObj) {
|
|
10595
|
-
if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)]))
|
|
10596
|
-
|
|
10597
|
-
if (isChar && (event.altKey || event.metaKey || event.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows
|
|
10593
|
+
if (runFor(scopeObj[prefix + modifiers(name, event, !isChar)])) {
|
|
10594
|
+
handled = true;
|
|
10595
|
+
} else if (isChar && (event.altKey || event.metaKey || event.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows
|
|
10598
10596
|
!(browser.windows && event.ctrlKey && event.altKey) && (baseName = base[event.keyCode]) && baseName != name) {
|
|
10599
|
-
if (runFor(scopeObj[prefix + modifiers(baseName, event, true)]))
|
|
10600
|
-
|
|
10601
|
-
else if (event.shiftKey && (shiftName = shift[event.keyCode]) != name && shiftName != baseName && runFor(scopeObj[prefix + modifiers(shiftName, event, false)]))
|
|
10602
|
-
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10597
|
+
if (runFor(scopeObj[prefix + modifiers(baseName, event, true)])) {
|
|
10598
|
+
handled = true;
|
|
10599
|
+
} else if (event.shiftKey && (shiftName = shift[event.keyCode]) != name && shiftName != baseName && runFor(scopeObj[prefix + modifiers(shiftName, event, false)])) {
|
|
10600
|
+
handled = true;
|
|
10601
|
+
}
|
|
10602
|
+
} else if (isChar && event.shiftKey && runFor(scopeObj[prefix + modifiers(name, event, true)])) {
|
|
10603
|
+
handled = true;
|
|
10606
10604
|
}
|
|
10607
|
-
if (runFor(scopeObj._any))
|
|
10608
|
-
|
|
10605
|
+
if (!handled && runFor(scopeObj._any))
|
|
10606
|
+
handled = true;
|
|
10609
10607
|
}
|
|
10610
|
-
|
|
10608
|
+
if (prevented)
|
|
10609
|
+
handled = true;
|
|
10610
|
+
if (handled && stopPropagation)
|
|
10611
|
+
event.stopPropagation();
|
|
10612
|
+
return handled;
|
|
10611
10613
|
}
|
|
10612
10614
|
var RectangleMarker = class {
|
|
10613
10615
|
/**
|
|
@@ -12731,6 +12733,8 @@ var FuzzyMatcher = class {
|
|
|
12731
12733
|
this.any = [];
|
|
12732
12734
|
this.precise = [];
|
|
12733
12735
|
this.byWord = [];
|
|
12736
|
+
this.score = 0;
|
|
12737
|
+
this.matched = [];
|
|
12734
12738
|
for (let p = 0; p < pattern.length; ) {
|
|
12735
12739
|
let char = codePointAt(pattern, p), size = codePointSize(char);
|
|
12736
12740
|
this.chars.push(char);
|
|
@@ -12740,21 +12744,23 @@ var FuzzyMatcher = class {
|
|
|
12740
12744
|
}
|
|
12741
12745
|
this.astral = pattern.length != this.chars.length;
|
|
12742
12746
|
}
|
|
12747
|
+
ret(score2, matched) {
|
|
12748
|
+
this.score = score2;
|
|
12749
|
+
this.matched = matched;
|
|
12750
|
+
return true;
|
|
12751
|
+
}
|
|
12743
12752
|
// Matches a given word (completion) against the pattern (input).
|
|
12744
|
-
// Will return
|
|
12745
|
-
//
|
|
12746
|
-
// indicating the matched parts of `word`.
|
|
12753
|
+
// Will return a boolean indicating whether there was a match and,
|
|
12754
|
+
// on success, set `this.score` to the score, `this.matched` to an
|
|
12755
|
+
// array of `from, to` pairs indicating the matched parts of `word`.
|
|
12747
12756
|
//
|
|
12748
12757
|
// The score is a number that is more negative the worse the match
|
|
12749
12758
|
// is. See `Penalty` above.
|
|
12750
12759
|
match(word) {
|
|
12751
12760
|
if (this.pattern.length == 0)
|
|
12752
|
-
return [
|
|
12753
|
-
-100
|
|
12754
|
-
/* NotFull */
|
|
12755
|
-
];
|
|
12761
|
+
return this.ret(-100, []);
|
|
12756
12762
|
if (word.length < this.pattern.length)
|
|
12757
|
-
return
|
|
12763
|
+
return false;
|
|
12758
12764
|
let { chars, folded, any, precise, byWord } = this;
|
|
12759
12765
|
if (chars.length == 1) {
|
|
12760
12766
|
let first = codePointAt(word, 0), firstSize = codePointSize(first);
|
|
@@ -12764,12 +12770,12 @@ var FuzzyMatcher = class {
|
|
|
12764
12770
|
else if (first == folded[0])
|
|
12765
12771
|
score2 += -200;
|
|
12766
12772
|
else
|
|
12767
|
-
return
|
|
12768
|
-
return
|
|
12773
|
+
return false;
|
|
12774
|
+
return this.ret(score2, [0, firstSize]);
|
|
12769
12775
|
}
|
|
12770
12776
|
let direct = word.indexOf(this.pattern);
|
|
12771
12777
|
if (direct == 0)
|
|
12772
|
-
return
|
|
12778
|
+
return this.ret(word.length == this.pattern.length ? 0 : -100, [0, this.pattern.length]);
|
|
12773
12779
|
let len = chars.length, anyTo = 0;
|
|
12774
12780
|
if (direct < 0) {
|
|
12775
12781
|
for (let i = 0, e = Math.min(word.length, 200); i < e && anyTo < len; ) {
|
|
@@ -12779,7 +12785,7 @@ var FuzzyMatcher = class {
|
|
|
12779
12785
|
i += codePointSize(next);
|
|
12780
12786
|
}
|
|
12781
12787
|
if (anyTo < len)
|
|
12782
|
-
return
|
|
12788
|
+
return false;
|
|
12783
12789
|
}
|
|
12784
12790
|
let preciseTo = 0;
|
|
12785
12791
|
let byWordTo = 0, byWordFolded = false;
|
|
@@ -12814,27 +12820,27 @@ var FuzzyMatcher = class {
|
|
|
12814
12820
|
if (byWordTo == len && byWord[0] == 0 && wordAdjacent)
|
|
12815
12821
|
return this.result(-100 + (byWordFolded ? -200 : 0), byWord, word);
|
|
12816
12822
|
if (adjacentTo == len && adjacentStart == 0)
|
|
12817
|
-
return
|
|
12823
|
+
return this.ret(-200 - word.length + (adjacentEnd == word.length ? 0 : -100), [0, adjacentEnd]);
|
|
12818
12824
|
if (direct > -1)
|
|
12819
|
-
return
|
|
12825
|
+
return this.ret(-700 - word.length, [direct, direct + this.pattern.length]);
|
|
12820
12826
|
if (adjacentTo == len)
|
|
12821
|
-
return
|
|
12827
|
+
return this.ret(-200 + -700 - word.length, [adjacentStart, adjacentEnd]);
|
|
12822
12828
|
if (byWordTo == len)
|
|
12823
12829
|
return this.result(-100 + (byWordFolded ? -200 : 0) + -700 + (wordAdjacent ? 0 : -1100), byWord, word);
|
|
12824
|
-
return chars.length == 2 ?
|
|
12830
|
+
return chars.length == 2 ? false : this.result((any[0] ? -700 : 0) + -200 + -1100, any, word);
|
|
12825
12831
|
}
|
|
12826
12832
|
result(score2, positions, word) {
|
|
12827
|
-
let result = [
|
|
12833
|
+
let result = [], i = 0;
|
|
12828
12834
|
for (let pos of positions) {
|
|
12829
12835
|
let to = pos + (this.astral ? codePointSize(codePointAt(word, pos)) : 1);
|
|
12830
|
-
if (i
|
|
12836
|
+
if (i && result[i - 1] == pos)
|
|
12831
12837
|
result[i - 1] = to;
|
|
12832
12838
|
else {
|
|
12833
12839
|
result[i++] = pos;
|
|
12834
12840
|
result[i++] = to;
|
|
12835
12841
|
}
|
|
12836
12842
|
}
|
|
12837
|
-
return result;
|
|
12843
|
+
return this.ret(score2 - word.length, result);
|
|
12838
12844
|
}
|
|
12839
12845
|
};
|
|
12840
12846
|
var completionConfig = /* @__PURE__ */ Facet.define({
|
|
@@ -12917,8 +12923,8 @@ function optionContent(config2) {
|
|
|
12917
12923
|
render(completion, _s, match) {
|
|
12918
12924
|
let labelElt = document.createElement("span");
|
|
12919
12925
|
labelElt.className = "cm-completionLabel";
|
|
12920
|
-
let
|
|
12921
|
-
for (let j =
|
|
12926
|
+
let label = completion.displayLabel || completion.label, off = 0;
|
|
12927
|
+
for (let j = 0; j < match.length; ) {
|
|
12922
12928
|
let from = match[j++], to = match[j++];
|
|
12923
12929
|
if (from > off)
|
|
12924
12930
|
labelElt.appendChild(document.createTextNode(label.slice(off, from)));
|
|
@@ -13204,20 +13210,17 @@ function sortOptions(active, state) {
|
|
|
13204
13210
|
};
|
|
13205
13211
|
for (let a of active)
|
|
13206
13212
|
if (a.hasResult()) {
|
|
13213
|
+
let getMatch = a.result.getMatch;
|
|
13207
13214
|
if (a.result.filter === false) {
|
|
13208
|
-
let getMatch = a.result.getMatch;
|
|
13209
13215
|
for (let option of a.result.options) {
|
|
13210
|
-
|
|
13211
|
-
if (getMatch)
|
|
13212
|
-
for (let n of getMatch(option))
|
|
13213
|
-
match.push(n);
|
|
13214
|
-
addOption(new Option(option, a.source, match, match[0]));
|
|
13216
|
+
addOption(new Option(option, a.source, getMatch ? getMatch(option) : [], 1e9 - options.length));
|
|
13215
13217
|
}
|
|
13216
13218
|
} else {
|
|
13217
|
-
let matcher = new FuzzyMatcher(state.sliceDoc(a.from, a.to))
|
|
13219
|
+
let matcher = new FuzzyMatcher(state.sliceDoc(a.from, a.to));
|
|
13218
13220
|
for (let option of a.result.options)
|
|
13219
|
-
if (
|
|
13220
|
-
|
|
13221
|
+
if (matcher.match(option.label)) {
|
|
13222
|
+
let matched = !option.displayLabel ? matcher.matched : getMatch ? getMatch(option, matcher.matched) : [];
|
|
13223
|
+
addOption(new Option(option, a.source, matched, matcher.score + (option.boost || 0)));
|
|
13221
13224
|
}
|
|
13222
13225
|
}
|
|
13223
13226
|
}
|