@codemirror/view 6.10.0 → 6.11.0
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 +12 -0
- package/dist/index.cjs +87 -46
- package/dist/index.d.ts +12 -3
- package/dist/index.js +87 -46
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
## 6.11.0 (2023-05-03)
|
|
2
|
+
|
|
3
|
+
### New features
|
|
4
|
+
|
|
5
|
+
Gutters now support a `widgetMarker` option that can be used to add markers next to block widgets.
|
|
6
|
+
|
|
7
|
+
## 6.10.1 (2023-05-01)
|
|
8
|
+
|
|
9
|
+
### Bug fixes
|
|
10
|
+
|
|
11
|
+
Limit cursor height in front of custom placeholder DOM elements.
|
|
12
|
+
|
|
1
13
|
## 6.10.0 (2023-04-25)
|
|
2
14
|
|
|
3
15
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -4337,15 +4337,34 @@ class BlockInfo {
|
|
|
4337
4337
|
*/
|
|
4338
4338
|
height,
|
|
4339
4339
|
/**
|
|
4340
|
-
|
|
4341
|
-
|
|
4340
|
+
@internal
|
|
4341
|
+
*/
|
|
4342
|
+
children,
|
|
4343
|
+
/**
|
|
4344
|
+
@internal
|
|
4342
4345
|
*/
|
|
4343
|
-
|
|
4346
|
+
deco) {
|
|
4344
4347
|
this.from = from;
|
|
4345
4348
|
this.length = length;
|
|
4346
4349
|
this.top = top;
|
|
4347
4350
|
this.height = height;
|
|
4348
|
-
this.
|
|
4351
|
+
this.children = children;
|
|
4352
|
+
this.deco = deco;
|
|
4353
|
+
}
|
|
4354
|
+
/**
|
|
4355
|
+
The type of element this is. When querying lines, this may be
|
|
4356
|
+
an array of all the blocks that make up the line.
|
|
4357
|
+
*/
|
|
4358
|
+
get type() {
|
|
4359
|
+
var _a, _b, _c;
|
|
4360
|
+
return (_c = (_a = this.children) !== null && _a !== void 0 ? _a : (_b = this.deco) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : exports.BlockType.Text;
|
|
4361
|
+
}
|
|
4362
|
+
/**
|
|
4363
|
+
If this is a widget block, this will return the widget
|
|
4364
|
+
associated with it.
|
|
4365
|
+
*/
|
|
4366
|
+
get widget() {
|
|
4367
|
+
return this.deco && this.deco.widget;
|
|
4349
4368
|
}
|
|
4350
4369
|
/**
|
|
4351
4370
|
The end of the element as a document position.
|
|
@@ -4359,9 +4378,8 @@ class BlockInfo {
|
|
|
4359
4378
|
@internal
|
|
4360
4379
|
*/
|
|
4361
4380
|
join(other) {
|
|
4362
|
-
let
|
|
4363
|
-
|
|
4364
|
-
return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, detail);
|
|
4381
|
+
let children = (this.children || [this]).concat(other.children || [other]);
|
|
4382
|
+
return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, children, null);
|
|
4365
4383
|
}
|
|
4366
4384
|
}
|
|
4367
4385
|
var QueryType;
|
|
@@ -4477,12 +4495,12 @@ class HeightMap {
|
|
|
4477
4495
|
}
|
|
4478
4496
|
HeightMap.prototype.size = 1;
|
|
4479
4497
|
class HeightMapBlock extends HeightMap {
|
|
4480
|
-
constructor(length, height,
|
|
4498
|
+
constructor(length, height, deco) {
|
|
4481
4499
|
super(length, height);
|
|
4482
|
-
this.
|
|
4500
|
+
this.deco = deco;
|
|
4483
4501
|
}
|
|
4484
4502
|
blockAt(_height, _oracle, top, offset) {
|
|
4485
|
-
return new BlockInfo(offset, this.length, top, this.height, this.
|
|
4503
|
+
return new BlockInfo(offset, this.length, top, this.height, null, this.deco);
|
|
4486
4504
|
}
|
|
4487
4505
|
lineAt(_value, _type, oracle, top, offset) {
|
|
4488
4506
|
return this.blockAt(0, oracle, top, offset);
|
|
@@ -4501,7 +4519,7 @@ class HeightMapBlock extends HeightMap {
|
|
|
4501
4519
|
}
|
|
4502
4520
|
class HeightMapText extends HeightMapBlock {
|
|
4503
4521
|
constructor(length, height) {
|
|
4504
|
-
super(length, height,
|
|
4522
|
+
super(length, height, null);
|
|
4505
4523
|
this.collapsed = 0; // Amount of collapsed content in the line
|
|
4506
4524
|
this.widgetHeight = 0; // Maximum inline widget height
|
|
4507
4525
|
}
|
|
@@ -4556,12 +4574,12 @@ class HeightMapGap extends HeightMap {
|
|
|
4556
4574
|
let guess = offset + Math.round(Math.max(0, Math.min(1, (height - top) / this.height)) * this.length);
|
|
4557
4575
|
let line = oracle.doc.lineAt(guess), lineHeight = perLine + line.length * perChar;
|
|
4558
4576
|
let lineTop = Math.max(top, height - lineHeight / 2);
|
|
4559
|
-
return new BlockInfo(line.from, line.length, lineTop, lineHeight,
|
|
4577
|
+
return new BlockInfo(line.from, line.length, lineTop, lineHeight, null, null);
|
|
4560
4578
|
}
|
|
4561
4579
|
else {
|
|
4562
4580
|
let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / perLine)));
|
|
4563
4581
|
let { from, length } = oracle.doc.line(firstLine + line);
|
|
4564
|
-
return new BlockInfo(from, length, top + perLine * line, perLine,
|
|
4582
|
+
return new BlockInfo(from, length, top + perLine * line, perLine, null, null);
|
|
4565
4583
|
}
|
|
4566
4584
|
}
|
|
4567
4585
|
lineAt(value, type, oracle, top, offset) {
|
|
@@ -4569,13 +4587,13 @@ class HeightMapGap extends HeightMap {
|
|
|
4569
4587
|
return this.blockAt(value, oracle, top, offset);
|
|
4570
4588
|
if (type == QueryType.ByPosNoHeight) {
|
|
4571
4589
|
let { from, to } = oracle.doc.lineAt(value);
|
|
4572
|
-
return new BlockInfo(from, to - from, 0, 0,
|
|
4590
|
+
return new BlockInfo(from, to - from, 0, 0, null, null);
|
|
4573
4591
|
}
|
|
4574
4592
|
let { firstLine, perLine, perChar } = this.heightMetrics(oracle, offset);
|
|
4575
4593
|
let line = oracle.doc.lineAt(value), lineHeight = perLine + line.length * perChar;
|
|
4576
4594
|
let linesAbove = line.number - firstLine;
|
|
4577
4595
|
let lineTop = top + perLine * linesAbove + perChar * (line.from - offset - linesAbove);
|
|
4578
|
-
return new BlockInfo(line.from, line.length, Math.max(top, Math.min(lineTop, top + this.height - lineHeight)), lineHeight,
|
|
4596
|
+
return new BlockInfo(line.from, line.length, Math.max(top, Math.min(lineTop, top + this.height - lineHeight)), lineHeight, null, null);
|
|
4579
4597
|
}
|
|
4580
4598
|
forEachLine(from, to, oracle, top, offset, f) {
|
|
4581
4599
|
from = Math.max(from, offset);
|
|
@@ -4588,7 +4606,7 @@ class HeightMapGap extends HeightMap {
|
|
|
4588
4606
|
lineTop += perLine * linesAbove + perChar * (from - offset - linesAbove);
|
|
4589
4607
|
}
|
|
4590
4608
|
let lineHeight = perLine + perChar * line.length;
|
|
4591
|
-
f(new BlockInfo(line.from, line.length, lineTop, lineHeight,
|
|
4609
|
+
f(new BlockInfo(line.from, line.length, lineTop, lineHeight, null, null));
|
|
4592
4610
|
lineTop += lineHeight;
|
|
4593
4611
|
pos = line.to + 1;
|
|
4594
4612
|
}
|
|
@@ -4818,7 +4836,7 @@ class NodeBuilder {
|
|
|
4818
4836
|
height = this.oracle.lineHeight;
|
|
4819
4837
|
let len = to - from;
|
|
4820
4838
|
if (deco.block) {
|
|
4821
|
-
this.addBlock(new HeightMapBlock(len, height, deco
|
|
4839
|
+
this.addBlock(new HeightMapBlock(len, height, deco));
|
|
4822
4840
|
}
|
|
4823
4841
|
else if (len || height >= relevantWidgetHeight) {
|
|
4824
4842
|
this.addLineDeco(height, len);
|
|
@@ -4861,12 +4879,14 @@ class NodeBuilder {
|
|
|
4861
4879
|
return line;
|
|
4862
4880
|
}
|
|
4863
4881
|
addBlock(block) {
|
|
4882
|
+
var _a;
|
|
4864
4883
|
this.enterLine();
|
|
4865
|
-
|
|
4884
|
+
let type = (_a = block.deco) === null || _a === void 0 ? void 0 : _a.type;
|
|
4885
|
+
if (type == exports.BlockType.WidgetAfter && !this.isCovered)
|
|
4866
4886
|
this.ensureLine();
|
|
4867
4887
|
this.nodes.push(block);
|
|
4868
4888
|
this.writtenTo = this.pos = this.pos + block.length;
|
|
4869
|
-
if (
|
|
4889
|
+
if (type != exports.BlockType.WidgetBefore)
|
|
4870
4890
|
this.covering = block;
|
|
4871
4891
|
}
|
|
4872
4892
|
addLineDeco(height, length) {
|
|
@@ -5469,7 +5489,7 @@ function scaleBlock(block, scaler) {
|
|
|
5469
5489
|
if (scaler.scale == 1)
|
|
5470
5490
|
return block;
|
|
5471
5491
|
let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);
|
|
5472
|
-
return new BlockInfo(block.from, block.length, bTop, bBottom - bTop,
|
|
5492
|
+
return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, block.children && block.children.map(b => scaleBlock(b, scaler)), block.deco);
|
|
5473
5493
|
}
|
|
5474
5494
|
|
|
5475
5495
|
const theme = state.Facet.define({ combine: strs => strs.join(" ") });
|
|
@@ -8352,7 +8372,14 @@ class Placeholder extends WidgetType {
|
|
|
8352
8372
|
}
|
|
8353
8373
|
coordsAt(dom) {
|
|
8354
8374
|
let rects = dom.firstChild ? clientRectsFor(dom.firstChild) : [];
|
|
8355
|
-
|
|
8375
|
+
if (!rects.length)
|
|
8376
|
+
return null;
|
|
8377
|
+
let style = window.getComputedStyle(dom.parentNode);
|
|
8378
|
+
let rect = flattenRect(rects[0], style.direction != "rtl");
|
|
8379
|
+
let lineHeight = parseInt(style.lineHeight);
|
|
8380
|
+
if (rect.bottom - rect.top > lineHeight * 1.5)
|
|
8381
|
+
return { left: rect.left, right: rect.right, top: rect.top, bottom: rect.top + lineHeight };
|
|
8382
|
+
return rect;
|
|
8356
8383
|
}
|
|
8357
8384
|
ignoreEvent() { return false; }
|
|
8358
8385
|
}
|
|
@@ -9292,6 +9319,7 @@ const defaults = {
|
|
|
9292
9319
|
elementStyle: "",
|
|
9293
9320
|
markers: () => state.RangeSet.empty,
|
|
9294
9321
|
lineMarker: () => null,
|
|
9322
|
+
widgetMarker: () => null,
|
|
9295
9323
|
lineMarkerChange: null,
|
|
9296
9324
|
initialSpacer: null,
|
|
9297
9325
|
updateSpacer: null,
|
|
@@ -9372,24 +9400,28 @@ const gutterView = ViewPlugin.fromClass(class {
|
|
|
9372
9400
|
let classSet = [];
|
|
9373
9401
|
let contexts = this.gutters.map(gutter => new UpdateContext(gutter, this.view.viewport, -this.view.documentPadding.top));
|
|
9374
9402
|
for (let line of this.view.viewportLineBlocks) {
|
|
9375
|
-
|
|
9403
|
+
if (classSet.length)
|
|
9404
|
+
classSet = [];
|
|
9376
9405
|
if (Array.isArray(line.type)) {
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9406
|
+
let first = true;
|
|
9407
|
+
for (let b of line.type) {
|
|
9408
|
+
if (b.type == exports.BlockType.Text && first) {
|
|
9409
|
+
advanceCursor(lineClasses, classSet, b.from);
|
|
9410
|
+
for (let cx of contexts)
|
|
9411
|
+
cx.line(this.view, b, classSet);
|
|
9412
|
+
first = false;
|
|
9413
|
+
}
|
|
9414
|
+
else if (b.widget) {
|
|
9415
|
+
for (let cx of contexts)
|
|
9416
|
+
cx.widget(this.view, b);
|
|
9381
9417
|
}
|
|
9418
|
+
}
|
|
9382
9419
|
}
|
|
9383
|
-
else {
|
|
9384
|
-
|
|
9420
|
+
else if (line.type == exports.BlockType.Text) {
|
|
9421
|
+
advanceCursor(lineClasses, classSet, line.from);
|
|
9422
|
+
for (let cx of contexts)
|
|
9423
|
+
cx.line(this.view, line, classSet);
|
|
9385
9424
|
}
|
|
9386
|
-
if (!text)
|
|
9387
|
-
continue;
|
|
9388
|
-
if (classSet.length)
|
|
9389
|
-
classSet = [];
|
|
9390
|
-
advanceCursor(lineClasses, classSet, line.from);
|
|
9391
|
-
for (let cx of contexts)
|
|
9392
|
-
cx.line(this.view, text, classSet);
|
|
9393
9425
|
}
|
|
9394
9426
|
for (let cx of contexts)
|
|
9395
9427
|
cx.finish();
|
|
@@ -9457,6 +9489,19 @@ class UpdateContext {
|
|
|
9457
9489
|
this.i = 0;
|
|
9458
9490
|
this.cursor = state.RangeSet.iter(gutter.markers, viewport.from);
|
|
9459
9491
|
}
|
|
9492
|
+
addElement(view, block, markers) {
|
|
9493
|
+
let { gutter } = this, above = block.top - this.height;
|
|
9494
|
+
if (this.i == gutter.elements.length) {
|
|
9495
|
+
let newElt = new GutterElement(view, block.height, above, markers);
|
|
9496
|
+
gutter.elements.push(newElt);
|
|
9497
|
+
gutter.dom.appendChild(newElt.dom);
|
|
9498
|
+
}
|
|
9499
|
+
else {
|
|
9500
|
+
gutter.elements[this.i].update(view, block.height, above, markers);
|
|
9501
|
+
}
|
|
9502
|
+
this.height = block.bottom;
|
|
9503
|
+
this.i++;
|
|
9504
|
+
}
|
|
9460
9505
|
line(view, line, extraMarkers) {
|
|
9461
9506
|
let localMarkers = [];
|
|
9462
9507
|
advanceCursor(this.cursor, localMarkers, line.from);
|
|
@@ -9468,17 +9513,12 @@ class UpdateContext {
|
|
|
9468
9513
|
let gutter = this.gutter;
|
|
9469
9514
|
if (localMarkers.length == 0 && !gutter.config.renderEmptyElements)
|
|
9470
9515
|
return;
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
else {
|
|
9478
|
-
gutter.elements[this.i].update(view, line.height, above, localMarkers);
|
|
9479
|
-
}
|
|
9480
|
-
this.height = line.bottom;
|
|
9481
|
-
this.i++;
|
|
9516
|
+
this.addElement(view, line, localMarkers);
|
|
9517
|
+
}
|
|
9518
|
+
widget(view, block) {
|
|
9519
|
+
let marker = this.gutter.config.widgetMarker(view, block.widget, block);
|
|
9520
|
+
if (marker)
|
|
9521
|
+
this.addElement(view, block, [marker]);
|
|
9482
9522
|
}
|
|
9483
9523
|
finish() {
|
|
9484
9524
|
let gutter = this.gutter;
|
|
@@ -9646,6 +9686,7 @@ const lineNumberGutter = activeGutters.compute([lineNumberConfig], state => ({
|
|
|
9646
9686
|
return null;
|
|
9647
9687
|
return new NumberMarker(formatNumber(view, view.state.doc.lineAt(line.from).number));
|
|
9648
9688
|
},
|
|
9689
|
+
widgetMarker: () => null,
|
|
9649
9690
|
lineMarkerChange: update => update.startState.facet(lineNumberConfig) != update.state.facet(lineNumberConfig),
|
|
9650
9691
|
initialSpacer(view) {
|
|
9651
9692
|
return new NumberMarker(formatNumber(view, maxLineNumber(view.state.doc.lines)));
|
package/dist/index.d.ts
CHANGED
|
@@ -516,7 +516,12 @@ declare class BlockInfo {
|
|
|
516
516
|
The type of element this is. When querying lines, this may be
|
|
517
517
|
an array of all the blocks that make up the line.
|
|
518
518
|
*/
|
|
519
|
-
|
|
519
|
+
get type(): BlockType | readonly BlockInfo[];
|
|
520
|
+
/**
|
|
521
|
+
If this is a widget block, this will return the widget
|
|
522
|
+
associated with it.
|
|
523
|
+
*/
|
|
524
|
+
get widget(): WidgetType | null;
|
|
520
525
|
/**
|
|
521
526
|
The end of the element as a document position.
|
|
522
527
|
*/
|
|
@@ -1864,8 +1869,12 @@ interface GutterConfig {
|
|
|
1864
1869
|
*/
|
|
1865
1870
|
lineMarker?: (view: EditorView, line: BlockInfo, otherMarkers: readonly GutterMarker[]) => GutterMarker | null;
|
|
1866
1871
|
/**
|
|
1867
|
-
|
|
1868
|
-
|
|
1872
|
+
Associate markers with block widgets in the document.
|
|
1873
|
+
*/
|
|
1874
|
+
widgetMarker?: (view: EditorView, widget: WidgetType, block: BlockInfo) => GutterMarker | null;
|
|
1875
|
+
/**
|
|
1876
|
+
If line or widget markers depend on additional state, and should
|
|
1877
|
+
be updated when that changes, pass a predicate here that checks
|
|
1869
1878
|
whether a given view update might change the line markers.
|
|
1870
1879
|
*/
|
|
1871
1880
|
lineMarkerChange?: null | ((update: ViewUpdate) => boolean);
|
package/dist/index.js
CHANGED
|
@@ -4331,15 +4331,34 @@ class BlockInfo {
|
|
|
4331
4331
|
*/
|
|
4332
4332
|
height,
|
|
4333
4333
|
/**
|
|
4334
|
-
|
|
4335
|
-
|
|
4334
|
+
@internal
|
|
4335
|
+
*/
|
|
4336
|
+
children,
|
|
4337
|
+
/**
|
|
4338
|
+
@internal
|
|
4336
4339
|
*/
|
|
4337
|
-
|
|
4340
|
+
deco) {
|
|
4338
4341
|
this.from = from;
|
|
4339
4342
|
this.length = length;
|
|
4340
4343
|
this.top = top;
|
|
4341
4344
|
this.height = height;
|
|
4342
|
-
this.
|
|
4345
|
+
this.children = children;
|
|
4346
|
+
this.deco = deco;
|
|
4347
|
+
}
|
|
4348
|
+
/**
|
|
4349
|
+
The type of element this is. When querying lines, this may be
|
|
4350
|
+
an array of all the blocks that make up the line.
|
|
4351
|
+
*/
|
|
4352
|
+
get type() {
|
|
4353
|
+
var _a, _b, _c;
|
|
4354
|
+
return (_c = (_a = this.children) !== null && _a !== void 0 ? _a : (_b = this.deco) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : BlockType.Text;
|
|
4355
|
+
}
|
|
4356
|
+
/**
|
|
4357
|
+
If this is a widget block, this will return the widget
|
|
4358
|
+
associated with it.
|
|
4359
|
+
*/
|
|
4360
|
+
get widget() {
|
|
4361
|
+
return this.deco && this.deco.widget;
|
|
4343
4362
|
}
|
|
4344
4363
|
/**
|
|
4345
4364
|
The end of the element as a document position.
|
|
@@ -4353,9 +4372,8 @@ class BlockInfo {
|
|
|
4353
4372
|
@internal
|
|
4354
4373
|
*/
|
|
4355
4374
|
join(other) {
|
|
4356
|
-
let
|
|
4357
|
-
|
|
4358
|
-
return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, detail);
|
|
4375
|
+
let children = (this.children || [this]).concat(other.children || [other]);
|
|
4376
|
+
return new BlockInfo(this.from, this.length + other.length, this.top, this.height + other.height, children, null);
|
|
4359
4377
|
}
|
|
4360
4378
|
}
|
|
4361
4379
|
var QueryType = /*@__PURE__*/(function (QueryType) {
|
|
@@ -4470,12 +4488,12 @@ class HeightMap {
|
|
|
4470
4488
|
}
|
|
4471
4489
|
HeightMap.prototype.size = 1;
|
|
4472
4490
|
class HeightMapBlock extends HeightMap {
|
|
4473
|
-
constructor(length, height,
|
|
4491
|
+
constructor(length, height, deco) {
|
|
4474
4492
|
super(length, height);
|
|
4475
|
-
this.
|
|
4493
|
+
this.deco = deco;
|
|
4476
4494
|
}
|
|
4477
4495
|
blockAt(_height, _oracle, top, offset) {
|
|
4478
|
-
return new BlockInfo(offset, this.length, top, this.height, this.
|
|
4496
|
+
return new BlockInfo(offset, this.length, top, this.height, null, this.deco);
|
|
4479
4497
|
}
|
|
4480
4498
|
lineAt(_value, _type, oracle, top, offset) {
|
|
4481
4499
|
return this.blockAt(0, oracle, top, offset);
|
|
@@ -4494,7 +4512,7 @@ class HeightMapBlock extends HeightMap {
|
|
|
4494
4512
|
}
|
|
4495
4513
|
class HeightMapText extends HeightMapBlock {
|
|
4496
4514
|
constructor(length, height) {
|
|
4497
|
-
super(length, height,
|
|
4515
|
+
super(length, height, null);
|
|
4498
4516
|
this.collapsed = 0; // Amount of collapsed content in the line
|
|
4499
4517
|
this.widgetHeight = 0; // Maximum inline widget height
|
|
4500
4518
|
}
|
|
@@ -4549,12 +4567,12 @@ class HeightMapGap extends HeightMap {
|
|
|
4549
4567
|
let guess = offset + Math.round(Math.max(0, Math.min(1, (height - top) / this.height)) * this.length);
|
|
4550
4568
|
let line = oracle.doc.lineAt(guess), lineHeight = perLine + line.length * perChar;
|
|
4551
4569
|
let lineTop = Math.max(top, height - lineHeight / 2);
|
|
4552
|
-
return new BlockInfo(line.from, line.length, lineTop, lineHeight,
|
|
4570
|
+
return new BlockInfo(line.from, line.length, lineTop, lineHeight, null, null);
|
|
4553
4571
|
}
|
|
4554
4572
|
else {
|
|
4555
4573
|
let line = Math.max(0, Math.min(lastLine - firstLine, Math.floor((height - top) / perLine)));
|
|
4556
4574
|
let { from, length } = oracle.doc.line(firstLine + line);
|
|
4557
|
-
return new BlockInfo(from, length, top + perLine * line, perLine,
|
|
4575
|
+
return new BlockInfo(from, length, top + perLine * line, perLine, null, null);
|
|
4558
4576
|
}
|
|
4559
4577
|
}
|
|
4560
4578
|
lineAt(value, type, oracle, top, offset) {
|
|
@@ -4562,13 +4580,13 @@ class HeightMapGap extends HeightMap {
|
|
|
4562
4580
|
return this.blockAt(value, oracle, top, offset);
|
|
4563
4581
|
if (type == QueryType.ByPosNoHeight) {
|
|
4564
4582
|
let { from, to } = oracle.doc.lineAt(value);
|
|
4565
|
-
return new BlockInfo(from, to - from, 0, 0,
|
|
4583
|
+
return new BlockInfo(from, to - from, 0, 0, null, null);
|
|
4566
4584
|
}
|
|
4567
4585
|
let { firstLine, perLine, perChar } = this.heightMetrics(oracle, offset);
|
|
4568
4586
|
let line = oracle.doc.lineAt(value), lineHeight = perLine + line.length * perChar;
|
|
4569
4587
|
let linesAbove = line.number - firstLine;
|
|
4570
4588
|
let lineTop = top + perLine * linesAbove + perChar * (line.from - offset - linesAbove);
|
|
4571
|
-
return new BlockInfo(line.from, line.length, Math.max(top, Math.min(lineTop, top + this.height - lineHeight)), lineHeight,
|
|
4589
|
+
return new BlockInfo(line.from, line.length, Math.max(top, Math.min(lineTop, top + this.height - lineHeight)), lineHeight, null, null);
|
|
4572
4590
|
}
|
|
4573
4591
|
forEachLine(from, to, oracle, top, offset, f) {
|
|
4574
4592
|
from = Math.max(from, offset);
|
|
@@ -4581,7 +4599,7 @@ class HeightMapGap extends HeightMap {
|
|
|
4581
4599
|
lineTop += perLine * linesAbove + perChar * (from - offset - linesAbove);
|
|
4582
4600
|
}
|
|
4583
4601
|
let lineHeight = perLine + perChar * line.length;
|
|
4584
|
-
f(new BlockInfo(line.from, line.length, lineTop, lineHeight,
|
|
4602
|
+
f(new BlockInfo(line.from, line.length, lineTop, lineHeight, null, null));
|
|
4585
4603
|
lineTop += lineHeight;
|
|
4586
4604
|
pos = line.to + 1;
|
|
4587
4605
|
}
|
|
@@ -4811,7 +4829,7 @@ class NodeBuilder {
|
|
|
4811
4829
|
height = this.oracle.lineHeight;
|
|
4812
4830
|
let len = to - from;
|
|
4813
4831
|
if (deco.block) {
|
|
4814
|
-
this.addBlock(new HeightMapBlock(len, height, deco
|
|
4832
|
+
this.addBlock(new HeightMapBlock(len, height, deco));
|
|
4815
4833
|
}
|
|
4816
4834
|
else if (len || height >= relevantWidgetHeight) {
|
|
4817
4835
|
this.addLineDeco(height, len);
|
|
@@ -4854,12 +4872,14 @@ class NodeBuilder {
|
|
|
4854
4872
|
return line;
|
|
4855
4873
|
}
|
|
4856
4874
|
addBlock(block) {
|
|
4875
|
+
var _a;
|
|
4857
4876
|
this.enterLine();
|
|
4858
|
-
|
|
4877
|
+
let type = (_a = block.deco) === null || _a === void 0 ? void 0 : _a.type;
|
|
4878
|
+
if (type == BlockType.WidgetAfter && !this.isCovered)
|
|
4859
4879
|
this.ensureLine();
|
|
4860
4880
|
this.nodes.push(block);
|
|
4861
4881
|
this.writtenTo = this.pos = this.pos + block.length;
|
|
4862
|
-
if (
|
|
4882
|
+
if (type != BlockType.WidgetBefore)
|
|
4863
4883
|
this.covering = block;
|
|
4864
4884
|
}
|
|
4865
4885
|
addLineDeco(height, length) {
|
|
@@ -5462,7 +5482,7 @@ function scaleBlock(block, scaler) {
|
|
|
5462
5482
|
if (scaler.scale == 1)
|
|
5463
5483
|
return block;
|
|
5464
5484
|
let bTop = scaler.toDOM(block.top), bBottom = scaler.toDOM(block.bottom);
|
|
5465
|
-
return new BlockInfo(block.from, block.length, bTop, bBottom - bTop,
|
|
5485
|
+
return new BlockInfo(block.from, block.length, bTop, bBottom - bTop, block.children && block.children.map(b => scaleBlock(b, scaler)), block.deco);
|
|
5466
5486
|
}
|
|
5467
5487
|
|
|
5468
5488
|
const theme = /*@__PURE__*/Facet.define({ combine: strs => strs.join(" ") });
|
|
@@ -8345,7 +8365,14 @@ class Placeholder extends WidgetType {
|
|
|
8345
8365
|
}
|
|
8346
8366
|
coordsAt(dom) {
|
|
8347
8367
|
let rects = dom.firstChild ? clientRectsFor(dom.firstChild) : [];
|
|
8348
|
-
|
|
8368
|
+
if (!rects.length)
|
|
8369
|
+
return null;
|
|
8370
|
+
let style = window.getComputedStyle(dom.parentNode);
|
|
8371
|
+
let rect = flattenRect(rects[0], style.direction != "rtl");
|
|
8372
|
+
let lineHeight = parseInt(style.lineHeight);
|
|
8373
|
+
if (rect.bottom - rect.top > lineHeight * 1.5)
|
|
8374
|
+
return { left: rect.left, right: rect.right, top: rect.top, bottom: rect.top + lineHeight };
|
|
8375
|
+
return rect;
|
|
8349
8376
|
}
|
|
8350
8377
|
ignoreEvent() { return false; }
|
|
8351
8378
|
}
|
|
@@ -9285,6 +9312,7 @@ const defaults = {
|
|
|
9285
9312
|
elementStyle: "",
|
|
9286
9313
|
markers: () => RangeSet.empty,
|
|
9287
9314
|
lineMarker: () => null,
|
|
9315
|
+
widgetMarker: () => null,
|
|
9288
9316
|
lineMarkerChange: null,
|
|
9289
9317
|
initialSpacer: null,
|
|
9290
9318
|
updateSpacer: null,
|
|
@@ -9365,24 +9393,28 @@ const gutterView = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
9365
9393
|
let classSet = [];
|
|
9366
9394
|
let contexts = this.gutters.map(gutter => new UpdateContext(gutter, this.view.viewport, -this.view.documentPadding.top));
|
|
9367
9395
|
for (let line of this.view.viewportLineBlocks) {
|
|
9368
|
-
|
|
9396
|
+
if (classSet.length)
|
|
9397
|
+
classSet = [];
|
|
9369
9398
|
if (Array.isArray(line.type)) {
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
|
|
9373
|
-
|
|
9399
|
+
let first = true;
|
|
9400
|
+
for (let b of line.type) {
|
|
9401
|
+
if (b.type == BlockType.Text && first) {
|
|
9402
|
+
advanceCursor(lineClasses, classSet, b.from);
|
|
9403
|
+
for (let cx of contexts)
|
|
9404
|
+
cx.line(this.view, b, classSet);
|
|
9405
|
+
first = false;
|
|
9406
|
+
}
|
|
9407
|
+
else if (b.widget) {
|
|
9408
|
+
for (let cx of contexts)
|
|
9409
|
+
cx.widget(this.view, b);
|
|
9374
9410
|
}
|
|
9411
|
+
}
|
|
9375
9412
|
}
|
|
9376
|
-
else {
|
|
9377
|
-
|
|
9413
|
+
else if (line.type == BlockType.Text) {
|
|
9414
|
+
advanceCursor(lineClasses, classSet, line.from);
|
|
9415
|
+
for (let cx of contexts)
|
|
9416
|
+
cx.line(this.view, line, classSet);
|
|
9378
9417
|
}
|
|
9379
|
-
if (!text)
|
|
9380
|
-
continue;
|
|
9381
|
-
if (classSet.length)
|
|
9382
|
-
classSet = [];
|
|
9383
|
-
advanceCursor(lineClasses, classSet, line.from);
|
|
9384
|
-
for (let cx of contexts)
|
|
9385
|
-
cx.line(this.view, text, classSet);
|
|
9386
9418
|
}
|
|
9387
9419
|
for (let cx of contexts)
|
|
9388
9420
|
cx.finish();
|
|
@@ -9450,6 +9482,19 @@ class UpdateContext {
|
|
|
9450
9482
|
this.i = 0;
|
|
9451
9483
|
this.cursor = RangeSet.iter(gutter.markers, viewport.from);
|
|
9452
9484
|
}
|
|
9485
|
+
addElement(view, block, markers) {
|
|
9486
|
+
let { gutter } = this, above = block.top - this.height;
|
|
9487
|
+
if (this.i == gutter.elements.length) {
|
|
9488
|
+
let newElt = new GutterElement(view, block.height, above, markers);
|
|
9489
|
+
gutter.elements.push(newElt);
|
|
9490
|
+
gutter.dom.appendChild(newElt.dom);
|
|
9491
|
+
}
|
|
9492
|
+
else {
|
|
9493
|
+
gutter.elements[this.i].update(view, block.height, above, markers);
|
|
9494
|
+
}
|
|
9495
|
+
this.height = block.bottom;
|
|
9496
|
+
this.i++;
|
|
9497
|
+
}
|
|
9453
9498
|
line(view, line, extraMarkers) {
|
|
9454
9499
|
let localMarkers = [];
|
|
9455
9500
|
advanceCursor(this.cursor, localMarkers, line.from);
|
|
@@ -9461,17 +9506,12 @@ class UpdateContext {
|
|
|
9461
9506
|
let gutter = this.gutter;
|
|
9462
9507
|
if (localMarkers.length == 0 && !gutter.config.renderEmptyElements)
|
|
9463
9508
|
return;
|
|
9464
|
-
|
|
9465
|
-
|
|
9466
|
-
|
|
9467
|
-
|
|
9468
|
-
|
|
9469
|
-
|
|
9470
|
-
else {
|
|
9471
|
-
gutter.elements[this.i].update(view, line.height, above, localMarkers);
|
|
9472
|
-
}
|
|
9473
|
-
this.height = line.bottom;
|
|
9474
|
-
this.i++;
|
|
9509
|
+
this.addElement(view, line, localMarkers);
|
|
9510
|
+
}
|
|
9511
|
+
widget(view, block) {
|
|
9512
|
+
let marker = this.gutter.config.widgetMarker(view, block.widget, block);
|
|
9513
|
+
if (marker)
|
|
9514
|
+
this.addElement(view, block, [marker]);
|
|
9475
9515
|
}
|
|
9476
9516
|
finish() {
|
|
9477
9517
|
let gutter = this.gutter;
|
|
@@ -9639,6 +9679,7 @@ const lineNumberGutter = /*@__PURE__*/activeGutters.compute([lineNumberConfig],
|
|
|
9639
9679
|
return null;
|
|
9640
9680
|
return new NumberMarker(formatNumber(view, view.state.doc.lineAt(line.from).number));
|
|
9641
9681
|
},
|
|
9682
|
+
widgetMarker: () => null,
|
|
9642
9683
|
lineMarkerChange: update => update.startState.facet(lineNumberConfig) != update.state.facet(lineNumberConfig),
|
|
9643
9684
|
initialSpacer(view) {
|
|
9644
9685
|
return new NumberMarker(formatNumber(view, maxLineNumber(view.state.doc.lines)));
|