@codemirror/view 6.20.1 → 6.21.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 +18 -0
- package/dist/index.cjs +37 -11
- package/dist/index.d.cts +33 -5
- package/dist/index.d.ts +33 -5
- package/dist/index.js +37 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## 6.21.0 (2023-09-29)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix a bug that could cause zero-length widgets at the start of a line to be left in the view even after they were removed.
|
|
6
|
+
|
|
7
|
+
### New features
|
|
8
|
+
|
|
9
|
+
`RectangleMarker`'s dimension properties are now public.
|
|
10
|
+
|
|
11
|
+
## 6.20.2 (2023-09-25)
|
|
12
|
+
|
|
13
|
+
### Bug fixes
|
|
14
|
+
|
|
15
|
+
Fix an issue in the way the DOM selection is being read that could break backspacing of widgets on Android.
|
|
16
|
+
|
|
17
|
+
Fix a bug where the editor could incorrectly computate its transform scale when it was small.
|
|
18
|
+
|
|
1
19
|
## 6.20.1 (2023-09-22)
|
|
2
20
|
|
|
3
21
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -596,7 +596,7 @@ function replaceRange(parent, fromI, fromOff, toI, toOff, insert, breakAtStart,
|
|
|
596
596
|
else {
|
|
597
597
|
// Remove the start of the after element, if necessary, and
|
|
598
598
|
// add it to `content`.
|
|
599
|
-
if (toOff)
|
|
599
|
+
if (toOff || after.children.length && !after.children[0].length)
|
|
600
600
|
after.merge(0, toOff, null, false, 0, openEnd);
|
|
601
601
|
insert.push(after);
|
|
602
602
|
}
|
|
@@ -5335,9 +5335,9 @@ class ViewState {
|
|
|
5335
5335
|
if (domRect.width && domRect.height) {
|
|
5336
5336
|
let scaleX = domRect.width / dom.offsetWidth;
|
|
5337
5337
|
let scaleY = domRect.height / dom.offsetHeight;
|
|
5338
|
-
if (scaleX > 0.995 && scaleX < 1.005 || !isFinite(scaleX))
|
|
5338
|
+
if (scaleX > 0.995 && scaleX < 1.005 || !isFinite(scaleX) || Math.abs(domRect.width - dom.offsetWidth) < 1)
|
|
5339
5339
|
scaleX = 1;
|
|
5340
|
-
if (scaleY > 0.995 && scaleY < 1.005 || !isFinite(scaleY))
|
|
5340
|
+
if (scaleY > 0.995 && scaleY < 1.005 || !isFinite(scaleY) || Math.abs(domRect.height - dom.offsetHeight) < 1)
|
|
5341
5341
|
scaleY = 1;
|
|
5342
5342
|
if (this.scaleX != scaleX || this.scaleY != scaleY) {
|
|
5343
5343
|
this.scaleX = scaleX;
|
|
@@ -6075,10 +6075,20 @@ class DOMReader {
|
|
|
6075
6075
|
if (point.node == node && node.childNodes[point.offset] == next)
|
|
6076
6076
|
point.pos = this.text.length;
|
|
6077
6077
|
}
|
|
6078
|
-
findPointInside(node,
|
|
6078
|
+
findPointInside(node, length) {
|
|
6079
6079
|
for (let point of this.points)
|
|
6080
6080
|
if (node.nodeType == 3 ? point.node == node : node.contains(point.node))
|
|
6081
|
-
point.pos = this.text.length +
|
|
6081
|
+
point.pos = this.text.length + (isAtEnd(node, point.node, point.offset) ? length : 0);
|
|
6082
|
+
}
|
|
6083
|
+
}
|
|
6084
|
+
function isAtEnd(parent, node, offset) {
|
|
6085
|
+
for (;;) {
|
|
6086
|
+
if (!node || offset < maxOffset(node))
|
|
6087
|
+
return false;
|
|
6088
|
+
if (node == parent)
|
|
6089
|
+
return true;
|
|
6090
|
+
offset = domIndex(node) + 1;
|
|
6091
|
+
node = node.parentNode;
|
|
6082
6092
|
}
|
|
6083
6093
|
}
|
|
6084
6094
|
function isBlockElement(node) {
|
|
@@ -8077,7 +8087,23 @@ class RectangleMarker {
|
|
|
8077
8087
|
Create a marker with the given class and dimensions. If `width`
|
|
8078
8088
|
is null, the DOM element will get no width style.
|
|
8079
8089
|
*/
|
|
8080
|
-
constructor(className,
|
|
8090
|
+
constructor(className,
|
|
8091
|
+
/**
|
|
8092
|
+
The left position of the marker (in pixels, document-relative).
|
|
8093
|
+
*/
|
|
8094
|
+
left,
|
|
8095
|
+
/**
|
|
8096
|
+
The top position of the marker.
|
|
8097
|
+
*/
|
|
8098
|
+
top,
|
|
8099
|
+
/**
|
|
8100
|
+
The width of the marker, or null if it shouldn't get a width assigned.
|
|
8101
|
+
*/
|
|
8102
|
+
width,
|
|
8103
|
+
/**
|
|
8104
|
+
The height of the marker.
|
|
8105
|
+
*/
|
|
8106
|
+
height) {
|
|
8081
8107
|
this.className = className;
|
|
8082
8108
|
this.left = left;
|
|
8083
8109
|
this.top = top;
|
|
@@ -10023,14 +10049,14 @@ class UpdateContext {
|
|
|
10023
10049
|
this.cursor = state.RangeSet.iter(gutter.markers, viewport.from);
|
|
10024
10050
|
}
|
|
10025
10051
|
addElement(view, block, markers) {
|
|
10026
|
-
let { gutter } = this, above = block.top - this.height;
|
|
10052
|
+
let { gutter } = this, above = (block.top - this.height) / view.scaleY, height = block.height / view.scaleY;
|
|
10027
10053
|
if (this.i == gutter.elements.length) {
|
|
10028
|
-
let newElt = new GutterElement(view,
|
|
10054
|
+
let newElt = new GutterElement(view, height, above, markers);
|
|
10029
10055
|
gutter.elements.push(newElt);
|
|
10030
10056
|
gutter.dom.appendChild(newElt.dom);
|
|
10031
10057
|
}
|
|
10032
10058
|
else {
|
|
10033
|
-
gutter.elements[this.i].update(view,
|
|
10059
|
+
gutter.elements[this.i].update(view, height, above, markers);
|
|
10034
10060
|
}
|
|
10035
10061
|
this.height = block.bottom;
|
|
10036
10062
|
this.i++;
|
|
@@ -10123,10 +10149,10 @@ class GutterElement {
|
|
|
10123
10149
|
update(view, height, above, markers) {
|
|
10124
10150
|
if (this.height != height) {
|
|
10125
10151
|
this.height = height;
|
|
10126
|
-
this.dom.style.height = height
|
|
10152
|
+
this.dom.style.height = height + "px";
|
|
10127
10153
|
}
|
|
10128
10154
|
if (this.above != above)
|
|
10129
|
-
this.dom.style.marginTop = (this.above = above) ? above
|
|
10155
|
+
this.dom.style.marginTop = (this.above = above) ? above + "px" : "";
|
|
10130
10156
|
if (!sameMarkers(this.markers, markers))
|
|
10131
10157
|
this.setMarkers(view, markers);
|
|
10132
10158
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1519,15 +1519,43 @@ a rectangle at a given set of coordinates.
|
|
|
1519
1519
|
*/
|
|
1520
1520
|
declare class RectangleMarker implements LayerMarker {
|
|
1521
1521
|
private className;
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1522
|
+
/**
|
|
1523
|
+
The left position of the marker (in pixels, document-relative).
|
|
1524
|
+
*/
|
|
1525
|
+
readonly left: number;
|
|
1526
|
+
/**
|
|
1527
|
+
The top position of the marker.
|
|
1528
|
+
*/
|
|
1529
|
+
readonly top: number;
|
|
1530
|
+
/**
|
|
1531
|
+
The width of the marker, or null if it shouldn't get a width assigned.
|
|
1532
|
+
*/
|
|
1533
|
+
readonly width: number | null;
|
|
1534
|
+
/**
|
|
1535
|
+
The height of the marker.
|
|
1536
|
+
*/
|
|
1537
|
+
readonly height: number;
|
|
1526
1538
|
/**
|
|
1527
1539
|
Create a marker with the given class and dimensions. If `width`
|
|
1528
1540
|
is null, the DOM element will get no width style.
|
|
1529
1541
|
*/
|
|
1530
|
-
constructor(className: string,
|
|
1542
|
+
constructor(className: string,
|
|
1543
|
+
/**
|
|
1544
|
+
The left position of the marker (in pixels, document-relative).
|
|
1545
|
+
*/
|
|
1546
|
+
left: number,
|
|
1547
|
+
/**
|
|
1548
|
+
The top position of the marker.
|
|
1549
|
+
*/
|
|
1550
|
+
top: number,
|
|
1551
|
+
/**
|
|
1552
|
+
The width of the marker, or null if it shouldn't get a width assigned.
|
|
1553
|
+
*/
|
|
1554
|
+
width: number | null,
|
|
1555
|
+
/**
|
|
1556
|
+
The height of the marker.
|
|
1557
|
+
*/
|
|
1558
|
+
height: number);
|
|
1531
1559
|
draw(): HTMLDivElement;
|
|
1532
1560
|
update(elt: HTMLElement, prev: RectangleMarker): boolean;
|
|
1533
1561
|
private adjust;
|
package/dist/index.d.ts
CHANGED
|
@@ -1519,15 +1519,43 @@ a rectangle at a given set of coordinates.
|
|
|
1519
1519
|
*/
|
|
1520
1520
|
declare class RectangleMarker implements LayerMarker {
|
|
1521
1521
|
private className;
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1522
|
+
/**
|
|
1523
|
+
The left position of the marker (in pixels, document-relative).
|
|
1524
|
+
*/
|
|
1525
|
+
readonly left: number;
|
|
1526
|
+
/**
|
|
1527
|
+
The top position of the marker.
|
|
1528
|
+
*/
|
|
1529
|
+
readonly top: number;
|
|
1530
|
+
/**
|
|
1531
|
+
The width of the marker, or null if it shouldn't get a width assigned.
|
|
1532
|
+
*/
|
|
1533
|
+
readonly width: number | null;
|
|
1534
|
+
/**
|
|
1535
|
+
The height of the marker.
|
|
1536
|
+
*/
|
|
1537
|
+
readonly height: number;
|
|
1526
1538
|
/**
|
|
1527
1539
|
Create a marker with the given class and dimensions. If `width`
|
|
1528
1540
|
is null, the DOM element will get no width style.
|
|
1529
1541
|
*/
|
|
1530
|
-
constructor(className: string,
|
|
1542
|
+
constructor(className: string,
|
|
1543
|
+
/**
|
|
1544
|
+
The left position of the marker (in pixels, document-relative).
|
|
1545
|
+
*/
|
|
1546
|
+
left: number,
|
|
1547
|
+
/**
|
|
1548
|
+
The top position of the marker.
|
|
1549
|
+
*/
|
|
1550
|
+
top: number,
|
|
1551
|
+
/**
|
|
1552
|
+
The width of the marker, or null if it shouldn't get a width assigned.
|
|
1553
|
+
*/
|
|
1554
|
+
width: number | null,
|
|
1555
|
+
/**
|
|
1556
|
+
The height of the marker.
|
|
1557
|
+
*/
|
|
1558
|
+
height: number);
|
|
1531
1559
|
draw(): HTMLDivElement;
|
|
1532
1560
|
update(elt: HTMLElement, prev: RectangleMarker): boolean;
|
|
1533
1561
|
private adjust;
|
package/dist/index.js
CHANGED
|
@@ -594,7 +594,7 @@ function replaceRange(parent, fromI, fromOff, toI, toOff, insert, breakAtStart,
|
|
|
594
594
|
else {
|
|
595
595
|
// Remove the start of the after element, if necessary, and
|
|
596
596
|
// add it to `content`.
|
|
597
|
-
if (toOff)
|
|
597
|
+
if (toOff || after.children.length && !after.children[0].length)
|
|
598
598
|
after.merge(0, toOff, null, false, 0, openEnd);
|
|
599
599
|
insert.push(after);
|
|
600
600
|
}
|
|
@@ -5330,9 +5330,9 @@ class ViewState {
|
|
|
5330
5330
|
if (domRect.width && domRect.height) {
|
|
5331
5331
|
let scaleX = domRect.width / dom.offsetWidth;
|
|
5332
5332
|
let scaleY = domRect.height / dom.offsetHeight;
|
|
5333
|
-
if (scaleX > 0.995 && scaleX < 1.005 || !isFinite(scaleX))
|
|
5333
|
+
if (scaleX > 0.995 && scaleX < 1.005 || !isFinite(scaleX) || Math.abs(domRect.width - dom.offsetWidth) < 1)
|
|
5334
5334
|
scaleX = 1;
|
|
5335
|
-
if (scaleY > 0.995 && scaleY < 1.005 || !isFinite(scaleY))
|
|
5335
|
+
if (scaleY > 0.995 && scaleY < 1.005 || !isFinite(scaleY) || Math.abs(domRect.height - dom.offsetHeight) < 1)
|
|
5336
5336
|
scaleY = 1;
|
|
5337
5337
|
if (this.scaleX != scaleX || this.scaleY != scaleY) {
|
|
5338
5338
|
this.scaleX = scaleX;
|
|
@@ -6070,10 +6070,20 @@ class DOMReader {
|
|
|
6070
6070
|
if (point.node == node && node.childNodes[point.offset] == next)
|
|
6071
6071
|
point.pos = this.text.length;
|
|
6072
6072
|
}
|
|
6073
|
-
findPointInside(node,
|
|
6073
|
+
findPointInside(node, length) {
|
|
6074
6074
|
for (let point of this.points)
|
|
6075
6075
|
if (node.nodeType == 3 ? point.node == node : node.contains(point.node))
|
|
6076
|
-
point.pos = this.text.length +
|
|
6076
|
+
point.pos = this.text.length + (isAtEnd(node, point.node, point.offset) ? length : 0);
|
|
6077
|
+
}
|
|
6078
|
+
}
|
|
6079
|
+
function isAtEnd(parent, node, offset) {
|
|
6080
|
+
for (;;) {
|
|
6081
|
+
if (!node || offset < maxOffset(node))
|
|
6082
|
+
return false;
|
|
6083
|
+
if (node == parent)
|
|
6084
|
+
return true;
|
|
6085
|
+
offset = domIndex(node) + 1;
|
|
6086
|
+
node = node.parentNode;
|
|
6077
6087
|
}
|
|
6078
6088
|
}
|
|
6079
6089
|
function isBlockElement(node) {
|
|
@@ -8072,7 +8082,23 @@ class RectangleMarker {
|
|
|
8072
8082
|
Create a marker with the given class and dimensions. If `width`
|
|
8073
8083
|
is null, the DOM element will get no width style.
|
|
8074
8084
|
*/
|
|
8075
|
-
constructor(className,
|
|
8085
|
+
constructor(className,
|
|
8086
|
+
/**
|
|
8087
|
+
The left position of the marker (in pixels, document-relative).
|
|
8088
|
+
*/
|
|
8089
|
+
left,
|
|
8090
|
+
/**
|
|
8091
|
+
The top position of the marker.
|
|
8092
|
+
*/
|
|
8093
|
+
top,
|
|
8094
|
+
/**
|
|
8095
|
+
The width of the marker, or null if it shouldn't get a width assigned.
|
|
8096
|
+
*/
|
|
8097
|
+
width,
|
|
8098
|
+
/**
|
|
8099
|
+
The height of the marker.
|
|
8100
|
+
*/
|
|
8101
|
+
height) {
|
|
8076
8102
|
this.className = className;
|
|
8077
8103
|
this.left = left;
|
|
8078
8104
|
this.top = top;
|
|
@@ -10018,14 +10044,14 @@ class UpdateContext {
|
|
|
10018
10044
|
this.cursor = RangeSet.iter(gutter.markers, viewport.from);
|
|
10019
10045
|
}
|
|
10020
10046
|
addElement(view, block, markers) {
|
|
10021
|
-
let { gutter } = this, above = block.top - this.height;
|
|
10047
|
+
let { gutter } = this, above = (block.top - this.height) / view.scaleY, height = block.height / view.scaleY;
|
|
10022
10048
|
if (this.i == gutter.elements.length) {
|
|
10023
|
-
let newElt = new GutterElement(view,
|
|
10049
|
+
let newElt = new GutterElement(view, height, above, markers);
|
|
10024
10050
|
gutter.elements.push(newElt);
|
|
10025
10051
|
gutter.dom.appendChild(newElt.dom);
|
|
10026
10052
|
}
|
|
10027
10053
|
else {
|
|
10028
|
-
gutter.elements[this.i].update(view,
|
|
10054
|
+
gutter.elements[this.i].update(view, height, above, markers);
|
|
10029
10055
|
}
|
|
10030
10056
|
this.height = block.bottom;
|
|
10031
10057
|
this.i++;
|
|
@@ -10118,10 +10144,10 @@ class GutterElement {
|
|
|
10118
10144
|
update(view, height, above, markers) {
|
|
10119
10145
|
if (this.height != height) {
|
|
10120
10146
|
this.height = height;
|
|
10121
|
-
this.dom.style.height = height
|
|
10147
|
+
this.dom.style.height = height + "px";
|
|
10122
10148
|
}
|
|
10123
10149
|
if (this.above != above)
|
|
10124
|
-
this.dom.style.marginTop = (this.above = above) ? above
|
|
10150
|
+
this.dom.style.marginTop = (this.above = above) ? above + "px" : "";
|
|
10125
10151
|
if (!sameMarkers(this.markers, markers))
|
|
10126
10152
|
this.setMarkers(view, markers);
|
|
10127
10153
|
}
|