@codemirror/view 6.10.1 → 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 +6 -0
- package/dist/index.cjs +79 -45
- package/dist/index.d.ts +12 -3
- package/dist/index.js +79 -45
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
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(" ") });
|
|
@@ -9299,6 +9319,7 @@ const defaults = {
|
|
|
9299
9319
|
elementStyle: "",
|
|
9300
9320
|
markers: () => state.RangeSet.empty,
|
|
9301
9321
|
lineMarker: () => null,
|
|
9322
|
+
widgetMarker: () => null,
|
|
9302
9323
|
lineMarkerChange: null,
|
|
9303
9324
|
initialSpacer: null,
|
|
9304
9325
|
updateSpacer: null,
|
|
@@ -9379,24 +9400,28 @@ const gutterView = ViewPlugin.fromClass(class {
|
|
|
9379
9400
|
let classSet = [];
|
|
9380
9401
|
let contexts = this.gutters.map(gutter => new UpdateContext(gutter, this.view.viewport, -this.view.documentPadding.top));
|
|
9381
9402
|
for (let line of this.view.viewportLineBlocks) {
|
|
9382
|
-
|
|
9403
|
+
if (classSet.length)
|
|
9404
|
+
classSet = [];
|
|
9383
9405
|
if (Array.isArray(line.type)) {
|
|
9384
|
-
|
|
9385
|
-
|
|
9386
|
-
|
|
9387
|
-
|
|
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;
|
|
9388
9413
|
}
|
|
9414
|
+
else if (b.widget) {
|
|
9415
|
+
for (let cx of contexts)
|
|
9416
|
+
cx.widget(this.view, b);
|
|
9417
|
+
}
|
|
9418
|
+
}
|
|
9389
9419
|
}
|
|
9390
|
-
else {
|
|
9391
|
-
|
|
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);
|
|
9392
9424
|
}
|
|
9393
|
-
if (!text)
|
|
9394
|
-
continue;
|
|
9395
|
-
if (classSet.length)
|
|
9396
|
-
classSet = [];
|
|
9397
|
-
advanceCursor(lineClasses, classSet, line.from);
|
|
9398
|
-
for (let cx of contexts)
|
|
9399
|
-
cx.line(this.view, text, classSet);
|
|
9400
9425
|
}
|
|
9401
9426
|
for (let cx of contexts)
|
|
9402
9427
|
cx.finish();
|
|
@@ -9464,6 +9489,19 @@ class UpdateContext {
|
|
|
9464
9489
|
this.i = 0;
|
|
9465
9490
|
this.cursor = state.RangeSet.iter(gutter.markers, viewport.from);
|
|
9466
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
|
+
}
|
|
9467
9505
|
line(view, line, extraMarkers) {
|
|
9468
9506
|
let localMarkers = [];
|
|
9469
9507
|
advanceCursor(this.cursor, localMarkers, line.from);
|
|
@@ -9475,17 +9513,12 @@ class UpdateContext {
|
|
|
9475
9513
|
let gutter = this.gutter;
|
|
9476
9514
|
if (localMarkers.length == 0 && !gutter.config.renderEmptyElements)
|
|
9477
9515
|
return;
|
|
9478
|
-
|
|
9479
|
-
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
else {
|
|
9485
|
-
gutter.elements[this.i].update(view, line.height, above, localMarkers);
|
|
9486
|
-
}
|
|
9487
|
-
this.height = line.bottom;
|
|
9488
|
-
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]);
|
|
9489
9522
|
}
|
|
9490
9523
|
finish() {
|
|
9491
9524
|
let gutter = this.gutter;
|
|
@@ -9653,6 +9686,7 @@ const lineNumberGutter = activeGutters.compute([lineNumberConfig], state => ({
|
|
|
9653
9686
|
return null;
|
|
9654
9687
|
return new NumberMarker(formatNumber(view, view.state.doc.lineAt(line.from).number));
|
|
9655
9688
|
},
|
|
9689
|
+
widgetMarker: () => null,
|
|
9656
9690
|
lineMarkerChange: update => update.startState.facet(lineNumberConfig) != update.state.facet(lineNumberConfig),
|
|
9657
9691
|
initialSpacer(view) {
|
|
9658
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(" ") });
|
|
@@ -9292,6 +9312,7 @@ const defaults = {
|
|
|
9292
9312
|
elementStyle: "",
|
|
9293
9313
|
markers: () => RangeSet.empty,
|
|
9294
9314
|
lineMarker: () => null,
|
|
9315
|
+
widgetMarker: () => null,
|
|
9295
9316
|
lineMarkerChange: null,
|
|
9296
9317
|
initialSpacer: null,
|
|
9297
9318
|
updateSpacer: null,
|
|
@@ -9372,24 +9393,28 @@ const gutterView = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
9372
9393
|
let classSet = [];
|
|
9373
9394
|
let contexts = this.gutters.map(gutter => new UpdateContext(gutter, this.view.viewport, -this.view.documentPadding.top));
|
|
9374
9395
|
for (let line of this.view.viewportLineBlocks) {
|
|
9375
|
-
|
|
9396
|
+
if (classSet.length)
|
|
9397
|
+
classSet = [];
|
|
9376
9398
|
if (Array.isArray(line.type)) {
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
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;
|
|
9381
9406
|
}
|
|
9407
|
+
else if (b.widget) {
|
|
9408
|
+
for (let cx of contexts)
|
|
9409
|
+
cx.widget(this.view, b);
|
|
9410
|
+
}
|
|
9411
|
+
}
|
|
9382
9412
|
}
|
|
9383
|
-
else {
|
|
9384
|
-
|
|
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);
|
|
9385
9417
|
}
|
|
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
9418
|
}
|
|
9394
9419
|
for (let cx of contexts)
|
|
9395
9420
|
cx.finish();
|
|
@@ -9457,6 +9482,19 @@ class UpdateContext {
|
|
|
9457
9482
|
this.i = 0;
|
|
9458
9483
|
this.cursor = RangeSet.iter(gutter.markers, viewport.from);
|
|
9459
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
|
+
}
|
|
9460
9498
|
line(view, line, extraMarkers) {
|
|
9461
9499
|
let localMarkers = [];
|
|
9462
9500
|
advanceCursor(this.cursor, localMarkers, line.from);
|
|
@@ -9468,17 +9506,12 @@ class UpdateContext {
|
|
|
9468
9506
|
let gutter = this.gutter;
|
|
9469
9507
|
if (localMarkers.length == 0 && !gutter.config.renderEmptyElements)
|
|
9470
9508
|
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++;
|
|
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]);
|
|
9482
9515
|
}
|
|
9483
9516
|
finish() {
|
|
9484
9517
|
let gutter = this.gutter;
|
|
@@ -9646,6 +9679,7 @@ const lineNumberGutter = /*@__PURE__*/activeGutters.compute([lineNumberConfig],
|
|
|
9646
9679
|
return null;
|
|
9647
9680
|
return new NumberMarker(formatNumber(view, view.state.doc.lineAt(line.from).number));
|
|
9648
9681
|
},
|
|
9682
|
+
widgetMarker: () => null,
|
|
9649
9683
|
lineMarkerChange: update => update.startState.facet(lineNumberConfig) != update.state.facet(lineNumberConfig),
|
|
9650
9684
|
initialSpacer(view) {
|
|
9651
9685
|
return new NumberMarker(formatNumber(view, maxLineNumber(view.state.doc.lines)));
|