@codemirror/view 6.21.2 → 6.21.4
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 +61 -34
- package/dist/index.js +61 -34
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
## 6.21.4 (2023-10-24)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Support the `offset`, `getCoords`, `overlap`, and `resize` properties on hover tooltips, as long as they aren't given conflicting values when there are multiple active hover tooltips.
|
|
6
|
+
|
|
7
|
+
Fix a bug that caused tooltips in the default configuration to be positioned incorrectly on Chrome when the editor was transformed.
|
|
8
|
+
|
|
9
|
+
## 6.21.3 (2023-10-06)
|
|
10
|
+
|
|
11
|
+
### Bug fixes
|
|
12
|
+
|
|
13
|
+
Fix an issue that caused `coordsForChar` to return the wrong rectangle for characters after a line wrap in Safari.
|
|
14
|
+
|
|
15
|
+
Make the context menu work when clicking below the content in a fixed-height editor.
|
|
16
|
+
|
|
17
|
+
Tooltips that have been put below/above their target position because there is no room on their default side now stay there on further updates.
|
|
18
|
+
|
|
1
19
|
## 6.21.2 (2023-10-02)
|
|
2
20
|
|
|
3
21
|
### Bug fixes
|
package/dist/index.cjs
CHANGED
|
@@ -2981,7 +2981,12 @@ class DocView extends ContentView {
|
|
|
2981
2981
|
if (end == off)
|
|
2982
2982
|
return null;
|
|
2983
2983
|
let rects = textRange(child.dom, off, end).getClientRects();
|
|
2984
|
-
|
|
2984
|
+
for (let i = 0; i < rects.length; i++) {
|
|
2985
|
+
let rect = rects[i];
|
|
2986
|
+
if (i == rects.length - 1 || rect.top < rect.bottom && rect.left < rect.right)
|
|
2987
|
+
return rect;
|
|
2988
|
+
}
|
|
2989
|
+
return null;
|
|
2985
2990
|
}
|
|
2986
2991
|
measureVisibleLineHeights(viewport) {
|
|
2987
2992
|
let result = [], { from, to } = viewport;
|
|
@@ -3635,22 +3640,6 @@ class InputState {
|
|
|
3635
3640
|
this.compositionPendingChange = false;
|
|
3636
3641
|
this.mouseSelection = null;
|
|
3637
3642
|
this.handleEvent = this.handleEvent.bind(this);
|
|
3638
|
-
view.scrollDOM.addEventListener("mousedown", (event) => {
|
|
3639
|
-
if (event.target == view.scrollDOM && event.clientY > view.contentDOM.getBoundingClientRect().bottom) {
|
|
3640
|
-
this.runHandlers("mousedown", event);
|
|
3641
|
-
if (!event.defaultPrevented && event.button == 2) {
|
|
3642
|
-
// Make sure the content covers the entire scroller height, in order
|
|
3643
|
-
// to catch a native context menu click below it
|
|
3644
|
-
let start = view.contentDOM.style.minHeight;
|
|
3645
|
-
view.contentDOM.style.minHeight = "100%";
|
|
3646
|
-
setTimeout(() => view.contentDOM.style.minHeight = start, 200);
|
|
3647
|
-
}
|
|
3648
|
-
}
|
|
3649
|
-
});
|
|
3650
|
-
view.scrollDOM.addEventListener("drop", (event) => {
|
|
3651
|
-
if (event.target == view.scrollDOM && event.clientY > view.contentDOM.getBoundingClientRect().bottom)
|
|
3652
|
-
this.runHandlers("drop", event);
|
|
3653
|
-
});
|
|
3654
3643
|
this.notifiedFocused = view.hasFocus;
|
|
3655
3644
|
// On Safari adding an input event handler somehow prevents an
|
|
3656
3645
|
// issue where the composition vanishes when you press enter.
|
|
@@ -5786,6 +5775,7 @@ const baseTheme$1 = buildTheme("." + baseThemeID, {
|
|
|
5786
5775
|
whiteSpace: "pre",
|
|
5787
5776
|
wordWrap: "normal",
|
|
5788
5777
|
boxSizing: "border-box",
|
|
5778
|
+
minHeight: "100%",
|
|
5789
5779
|
padding: "4px 0",
|
|
5790
5780
|
outline: "none",
|
|
5791
5781
|
"&[contenteditable=true]": {
|
|
@@ -6381,7 +6371,6 @@ class DOMObserver {
|
|
|
6381
6371
|
this.scrollTargets = [];
|
|
6382
6372
|
this.intersection = null;
|
|
6383
6373
|
this.resizeScroll = null;
|
|
6384
|
-
this.resizeContent = null;
|
|
6385
6374
|
this.intersecting = false;
|
|
6386
6375
|
this.gapIntersection = null;
|
|
6387
6376
|
this.gaps = [];
|
|
@@ -6425,8 +6414,6 @@ class DOMObserver {
|
|
|
6425
6414
|
this.onResize();
|
|
6426
6415
|
});
|
|
6427
6416
|
this.resizeScroll.observe(view.scrollDOM);
|
|
6428
|
-
this.resizeContent = new ResizeObserver(() => this.view.requestMeasure());
|
|
6429
|
-
this.resizeContent.observe(view.contentDOM);
|
|
6430
6417
|
}
|
|
6431
6418
|
this.addWindowListeners(this.win = view.win);
|
|
6432
6419
|
this.start();
|
|
@@ -6704,8 +6691,10 @@ class DOMObserver {
|
|
|
6704
6691
|
if (readSelection)
|
|
6705
6692
|
this.readSelectionRange();
|
|
6706
6693
|
let domChange = this.readChange();
|
|
6707
|
-
if (!domChange)
|
|
6694
|
+
if (!domChange) {
|
|
6695
|
+
this.view.requestMeasure();
|
|
6708
6696
|
return false;
|
|
6697
|
+
}
|
|
6709
6698
|
let startState = this.view.state;
|
|
6710
6699
|
let handled = applyDOMChange(this.view, domChange);
|
|
6711
6700
|
// The view wasn't updated
|
|
@@ -6753,12 +6742,11 @@ class DOMObserver {
|
|
|
6753
6742
|
win.document.removeEventListener("selectionchange", this.onSelectionChange);
|
|
6754
6743
|
}
|
|
6755
6744
|
destroy() {
|
|
6756
|
-
var _a, _b, _c
|
|
6745
|
+
var _a, _b, _c;
|
|
6757
6746
|
this.stop();
|
|
6758
6747
|
(_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
6759
6748
|
(_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
6760
6749
|
(_c = this.resizeScroll) === null || _c === void 0 ? void 0 : _c.disconnect();
|
|
6761
|
-
(_d = this.resizeContent) === null || _d === void 0 ? void 0 : _d.disconnect();
|
|
6762
6750
|
for (let dom of this.scrollTargets)
|
|
6763
6751
|
dom.removeEventListener("scroll", this.onScroll);
|
|
6764
6752
|
this.removeWindowListeners(this.win);
|
|
@@ -9049,7 +9037,7 @@ class TooltipViewManager {
|
|
|
9049
9037
|
this.tooltips = this.input.filter(t => t);
|
|
9050
9038
|
this.tooltipViews = this.tooltips.map(createTooltipView);
|
|
9051
9039
|
}
|
|
9052
|
-
update(update) {
|
|
9040
|
+
update(update, above) {
|
|
9053
9041
|
var _a;
|
|
9054
9042
|
let input = update.state.facet(this.facet);
|
|
9055
9043
|
let tooltips = input.filter(x => x);
|
|
@@ -9059,7 +9047,7 @@ class TooltipViewManager {
|
|
|
9059
9047
|
t.update(update);
|
|
9060
9048
|
return false;
|
|
9061
9049
|
}
|
|
9062
|
-
let tooltipViews = [];
|
|
9050
|
+
let tooltipViews = [], newAbove = above ? [] : null;
|
|
9063
9051
|
for (let i = 0; i < tooltips.length; i++) {
|
|
9064
9052
|
let tip = tooltips[i], known = -1;
|
|
9065
9053
|
if (!tip)
|
|
@@ -9071,9 +9059,13 @@ class TooltipViewManager {
|
|
|
9071
9059
|
}
|
|
9072
9060
|
if (known < 0) {
|
|
9073
9061
|
tooltipViews[i] = this.createTooltipView(tip);
|
|
9062
|
+
if (newAbove)
|
|
9063
|
+
newAbove[i] = !!tip.above;
|
|
9074
9064
|
}
|
|
9075
9065
|
else {
|
|
9076
9066
|
let tooltipView = tooltipViews[i] = this.tooltipViews[known];
|
|
9067
|
+
if (newAbove)
|
|
9068
|
+
newAbove[i] = above[known];
|
|
9077
9069
|
if (tooltipView.update)
|
|
9078
9070
|
tooltipView.update(update);
|
|
9079
9071
|
}
|
|
@@ -9083,6 +9075,10 @@ class TooltipViewManager {
|
|
|
9083
9075
|
t.dom.remove();
|
|
9084
9076
|
(_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);
|
|
9085
9077
|
}
|
|
9078
|
+
if (above) {
|
|
9079
|
+
newAbove.forEach((val, i) => above[i] = val);
|
|
9080
|
+
above.length = newAbove.length;
|
|
9081
|
+
}
|
|
9086
9082
|
this.input = input;
|
|
9087
9083
|
this.tooltips = tooltips;
|
|
9088
9084
|
this.tooltipViews = tooltipViews;
|
|
@@ -9113,6 +9109,7 @@ const knownHeight = new WeakMap();
|
|
|
9113
9109
|
const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
9114
9110
|
constructor(view) {
|
|
9115
9111
|
this.view = view;
|
|
9112
|
+
this.above = [];
|
|
9116
9113
|
this.inView = true;
|
|
9117
9114
|
this.madeAbsolute = false;
|
|
9118
9115
|
this.lastTransaction = 0;
|
|
@@ -9161,7 +9158,7 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
9161
9158
|
update(update) {
|
|
9162
9159
|
if (update.transactions.length)
|
|
9163
9160
|
this.lastTransaction = Date.now();
|
|
9164
|
-
let updated = this.manager.update(update);
|
|
9161
|
+
let updated = this.manager.update(update, this.above);
|
|
9165
9162
|
if (updated)
|
|
9166
9163
|
this.observeIntersection();
|
|
9167
9164
|
let shouldMeasure = updated || update.geometryChanged;
|
|
@@ -9197,6 +9194,7 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
9197
9194
|
}
|
|
9198
9195
|
tooltipView.dom.style.position = this.position;
|
|
9199
9196
|
tooltipView.dom.style.top = Outside;
|
|
9197
|
+
tooltipView.dom.style.left = "0px";
|
|
9200
9198
|
this.container.appendChild(tooltipView.dom);
|
|
9201
9199
|
if (tooltipView.mount)
|
|
9202
9200
|
tooltipView.mount(this.view);
|
|
@@ -9218,12 +9216,24 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
9218
9216
|
let editor = this.view.dom.getBoundingClientRect();
|
|
9219
9217
|
let scaleX = 1, scaleY = 1, makeAbsolute = false;
|
|
9220
9218
|
if (this.position == "fixed" && this.manager.tooltipViews.length) {
|
|
9221
|
-
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
|
|
9219
|
+
let { dom } = this.manager.tooltipViews[0];
|
|
9220
|
+
if (browser.gecko) {
|
|
9221
|
+
// Firefox sets the element's `offsetParent` to the
|
|
9222
|
+
// transformed element when a transform interferes with fixed
|
|
9223
|
+
// positioning.
|
|
9224
|
+
makeAbsolute = dom.offsetParent != this.container.ownerDocument.body;
|
|
9225
|
+
}
|
|
9226
|
+
else {
|
|
9227
|
+
// On other browsers, we have to awkwardly try and use other
|
|
9228
|
+
// information to detect a transform.
|
|
9229
|
+
if (this.view.scaleX != 1 || this.view.scaleY != 1) {
|
|
9230
|
+
makeAbsolute = true;
|
|
9231
|
+
}
|
|
9232
|
+
else if (dom.style.top == Outside && dom.style.left == "0px") {
|
|
9233
|
+
let rect = dom.getBoundingClientRect();
|
|
9234
|
+
makeAbsolute = Math.abs(rect.top + 10000) > 1 || Math.abs(rect.left) > 1;
|
|
9235
|
+
}
|
|
9236
|
+
}
|
|
9227
9237
|
}
|
|
9228
9238
|
if (makeAbsolute || this.position == "absolute") {
|
|
9229
9239
|
if (this.parent) {
|
|
@@ -9277,12 +9287,12 @@ const tooltipPlugin = ViewPlugin.fromClass(class {
|
|
|
9277
9287
|
let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)
|
|
9278
9288
|
: ltr ? Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width)
|
|
9279
9289
|
: Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x);
|
|
9280
|
-
let above =
|
|
9290
|
+
let above = this.above[i];
|
|
9281
9291
|
if (!tooltip.strictSide && (above
|
|
9282
9292
|
? pos.top - (size.bottom - size.top) - offset.y < space.top
|
|
9283
9293
|
: pos.bottom + (size.bottom - size.top) + offset.y > space.bottom) &&
|
|
9284
9294
|
above == (space.bottom - pos.bottom > pos.top - space.top))
|
|
9285
|
-
above = !above;
|
|
9295
|
+
above = this.above[i] = !above;
|
|
9286
9296
|
let spaceVert = (above ? pos.top - space.top : space.bottom - pos.bottom) - arrowHeight;
|
|
9287
9297
|
if (spaceVert < height && tView.resize !== false) {
|
|
9288
9298
|
if (spaceVert < this.view.defaultLineHeight) {
|
|
@@ -9449,6 +9459,23 @@ class HoverTooltipHost {
|
|
|
9449
9459
|
for (let t of this.manager.tooltipViews)
|
|
9450
9460
|
(_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);
|
|
9451
9461
|
}
|
|
9462
|
+
passProp(name) {
|
|
9463
|
+
let value = undefined;
|
|
9464
|
+
for (let view of this.manager.tooltipViews) {
|
|
9465
|
+
let given = view[name];
|
|
9466
|
+
if (given !== undefined) {
|
|
9467
|
+
if (value === undefined)
|
|
9468
|
+
value = given;
|
|
9469
|
+
else if (value !== given)
|
|
9470
|
+
return undefined;
|
|
9471
|
+
}
|
|
9472
|
+
}
|
|
9473
|
+
return value;
|
|
9474
|
+
}
|
|
9475
|
+
get offset() { return this.passProp("offset"); }
|
|
9476
|
+
get getCoords() { return this.passProp("getCoords"); }
|
|
9477
|
+
get overlap() { return this.passProp("overlap"); }
|
|
9478
|
+
get resize() { return this.passProp("resize"); }
|
|
9452
9479
|
}
|
|
9453
9480
|
const showHoverTooltipHost = showTooltip.compute([showHoverTooltip], state => {
|
|
9454
9481
|
let tooltips = state.facet(showHoverTooltip).filter(t => t);
|
package/dist/index.js
CHANGED
|
@@ -2977,7 +2977,12 @@ class DocView extends ContentView {
|
|
|
2977
2977
|
if (end == off)
|
|
2978
2978
|
return null;
|
|
2979
2979
|
let rects = textRange(child.dom, off, end).getClientRects();
|
|
2980
|
-
|
|
2980
|
+
for (let i = 0; i < rects.length; i++) {
|
|
2981
|
+
let rect = rects[i];
|
|
2982
|
+
if (i == rects.length - 1 || rect.top < rect.bottom && rect.left < rect.right)
|
|
2983
|
+
return rect;
|
|
2984
|
+
}
|
|
2985
|
+
return null;
|
|
2981
2986
|
}
|
|
2982
2987
|
measureVisibleLineHeights(viewport) {
|
|
2983
2988
|
let result = [], { from, to } = viewport;
|
|
@@ -3631,22 +3636,6 @@ class InputState {
|
|
|
3631
3636
|
this.compositionPendingChange = false;
|
|
3632
3637
|
this.mouseSelection = null;
|
|
3633
3638
|
this.handleEvent = this.handleEvent.bind(this);
|
|
3634
|
-
view.scrollDOM.addEventListener("mousedown", (event) => {
|
|
3635
|
-
if (event.target == view.scrollDOM && event.clientY > view.contentDOM.getBoundingClientRect().bottom) {
|
|
3636
|
-
this.runHandlers("mousedown", event);
|
|
3637
|
-
if (!event.defaultPrevented && event.button == 2) {
|
|
3638
|
-
// Make sure the content covers the entire scroller height, in order
|
|
3639
|
-
// to catch a native context menu click below it
|
|
3640
|
-
let start = view.contentDOM.style.minHeight;
|
|
3641
|
-
view.contentDOM.style.minHeight = "100%";
|
|
3642
|
-
setTimeout(() => view.contentDOM.style.minHeight = start, 200);
|
|
3643
|
-
}
|
|
3644
|
-
}
|
|
3645
|
-
});
|
|
3646
|
-
view.scrollDOM.addEventListener("drop", (event) => {
|
|
3647
|
-
if (event.target == view.scrollDOM && event.clientY > view.contentDOM.getBoundingClientRect().bottom)
|
|
3648
|
-
this.runHandlers("drop", event);
|
|
3649
|
-
});
|
|
3650
3639
|
this.notifiedFocused = view.hasFocus;
|
|
3651
3640
|
// On Safari adding an input event handler somehow prevents an
|
|
3652
3641
|
// issue where the composition vanishes when you press enter.
|
|
@@ -5781,6 +5770,7 @@ const baseTheme$1 = /*@__PURE__*/buildTheme("." + baseThemeID, {
|
|
|
5781
5770
|
whiteSpace: "pre",
|
|
5782
5771
|
wordWrap: "normal",
|
|
5783
5772
|
boxSizing: "border-box",
|
|
5773
|
+
minHeight: "100%",
|
|
5784
5774
|
padding: "4px 0",
|
|
5785
5775
|
outline: "none",
|
|
5786
5776
|
"&[contenteditable=true]": {
|
|
@@ -6376,7 +6366,6 @@ class DOMObserver {
|
|
|
6376
6366
|
this.scrollTargets = [];
|
|
6377
6367
|
this.intersection = null;
|
|
6378
6368
|
this.resizeScroll = null;
|
|
6379
|
-
this.resizeContent = null;
|
|
6380
6369
|
this.intersecting = false;
|
|
6381
6370
|
this.gapIntersection = null;
|
|
6382
6371
|
this.gaps = [];
|
|
@@ -6420,8 +6409,6 @@ class DOMObserver {
|
|
|
6420
6409
|
this.onResize();
|
|
6421
6410
|
});
|
|
6422
6411
|
this.resizeScroll.observe(view.scrollDOM);
|
|
6423
|
-
this.resizeContent = new ResizeObserver(() => this.view.requestMeasure());
|
|
6424
|
-
this.resizeContent.observe(view.contentDOM);
|
|
6425
6412
|
}
|
|
6426
6413
|
this.addWindowListeners(this.win = view.win);
|
|
6427
6414
|
this.start();
|
|
@@ -6699,8 +6686,10 @@ class DOMObserver {
|
|
|
6699
6686
|
if (readSelection)
|
|
6700
6687
|
this.readSelectionRange();
|
|
6701
6688
|
let domChange = this.readChange();
|
|
6702
|
-
if (!domChange)
|
|
6689
|
+
if (!domChange) {
|
|
6690
|
+
this.view.requestMeasure();
|
|
6703
6691
|
return false;
|
|
6692
|
+
}
|
|
6704
6693
|
let startState = this.view.state;
|
|
6705
6694
|
let handled = applyDOMChange(this.view, domChange);
|
|
6706
6695
|
// The view wasn't updated
|
|
@@ -6748,12 +6737,11 @@ class DOMObserver {
|
|
|
6748
6737
|
win.document.removeEventListener("selectionchange", this.onSelectionChange);
|
|
6749
6738
|
}
|
|
6750
6739
|
destroy() {
|
|
6751
|
-
var _a, _b, _c
|
|
6740
|
+
var _a, _b, _c;
|
|
6752
6741
|
this.stop();
|
|
6753
6742
|
(_a = this.intersection) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
6754
6743
|
(_b = this.gapIntersection) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
6755
6744
|
(_c = this.resizeScroll) === null || _c === void 0 ? void 0 : _c.disconnect();
|
|
6756
|
-
(_d = this.resizeContent) === null || _d === void 0 ? void 0 : _d.disconnect();
|
|
6757
6745
|
for (let dom of this.scrollTargets)
|
|
6758
6746
|
dom.removeEventListener("scroll", this.onScroll);
|
|
6759
6747
|
this.removeWindowListeners(this.win);
|
|
@@ -9044,7 +9032,7 @@ class TooltipViewManager {
|
|
|
9044
9032
|
this.tooltips = this.input.filter(t => t);
|
|
9045
9033
|
this.tooltipViews = this.tooltips.map(createTooltipView);
|
|
9046
9034
|
}
|
|
9047
|
-
update(update) {
|
|
9035
|
+
update(update, above) {
|
|
9048
9036
|
var _a;
|
|
9049
9037
|
let input = update.state.facet(this.facet);
|
|
9050
9038
|
let tooltips = input.filter(x => x);
|
|
@@ -9054,7 +9042,7 @@ class TooltipViewManager {
|
|
|
9054
9042
|
t.update(update);
|
|
9055
9043
|
return false;
|
|
9056
9044
|
}
|
|
9057
|
-
let tooltipViews = [];
|
|
9045
|
+
let tooltipViews = [], newAbove = above ? [] : null;
|
|
9058
9046
|
for (let i = 0; i < tooltips.length; i++) {
|
|
9059
9047
|
let tip = tooltips[i], known = -1;
|
|
9060
9048
|
if (!tip)
|
|
@@ -9066,9 +9054,13 @@ class TooltipViewManager {
|
|
|
9066
9054
|
}
|
|
9067
9055
|
if (known < 0) {
|
|
9068
9056
|
tooltipViews[i] = this.createTooltipView(tip);
|
|
9057
|
+
if (newAbove)
|
|
9058
|
+
newAbove[i] = !!tip.above;
|
|
9069
9059
|
}
|
|
9070
9060
|
else {
|
|
9071
9061
|
let tooltipView = tooltipViews[i] = this.tooltipViews[known];
|
|
9062
|
+
if (newAbove)
|
|
9063
|
+
newAbove[i] = above[known];
|
|
9072
9064
|
if (tooltipView.update)
|
|
9073
9065
|
tooltipView.update(update);
|
|
9074
9066
|
}
|
|
@@ -9078,6 +9070,10 @@ class TooltipViewManager {
|
|
|
9078
9070
|
t.dom.remove();
|
|
9079
9071
|
(_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);
|
|
9080
9072
|
}
|
|
9073
|
+
if (above) {
|
|
9074
|
+
newAbove.forEach((val, i) => above[i] = val);
|
|
9075
|
+
above.length = newAbove.length;
|
|
9076
|
+
}
|
|
9081
9077
|
this.input = input;
|
|
9082
9078
|
this.tooltips = tooltips;
|
|
9083
9079
|
this.tooltipViews = tooltipViews;
|
|
@@ -9108,6 +9104,7 @@ const knownHeight = /*@__PURE__*/new WeakMap();
|
|
|
9108
9104
|
const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
9109
9105
|
constructor(view) {
|
|
9110
9106
|
this.view = view;
|
|
9107
|
+
this.above = [];
|
|
9111
9108
|
this.inView = true;
|
|
9112
9109
|
this.madeAbsolute = false;
|
|
9113
9110
|
this.lastTransaction = 0;
|
|
@@ -9156,7 +9153,7 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
9156
9153
|
update(update) {
|
|
9157
9154
|
if (update.transactions.length)
|
|
9158
9155
|
this.lastTransaction = Date.now();
|
|
9159
|
-
let updated = this.manager.update(update);
|
|
9156
|
+
let updated = this.manager.update(update, this.above);
|
|
9160
9157
|
if (updated)
|
|
9161
9158
|
this.observeIntersection();
|
|
9162
9159
|
let shouldMeasure = updated || update.geometryChanged;
|
|
@@ -9192,6 +9189,7 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
9192
9189
|
}
|
|
9193
9190
|
tooltipView.dom.style.position = this.position;
|
|
9194
9191
|
tooltipView.dom.style.top = Outside;
|
|
9192
|
+
tooltipView.dom.style.left = "0px";
|
|
9195
9193
|
this.container.appendChild(tooltipView.dom);
|
|
9196
9194
|
if (tooltipView.mount)
|
|
9197
9195
|
tooltipView.mount(this.view);
|
|
@@ -9213,12 +9211,24 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
9213
9211
|
let editor = this.view.dom.getBoundingClientRect();
|
|
9214
9212
|
let scaleX = 1, scaleY = 1, makeAbsolute = false;
|
|
9215
9213
|
if (this.position == "fixed" && this.manager.tooltipViews.length) {
|
|
9216
|
-
|
|
9217
|
-
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9214
|
+
let { dom } = this.manager.tooltipViews[0];
|
|
9215
|
+
if (browser.gecko) {
|
|
9216
|
+
// Firefox sets the element's `offsetParent` to the
|
|
9217
|
+
// transformed element when a transform interferes with fixed
|
|
9218
|
+
// positioning.
|
|
9219
|
+
makeAbsolute = dom.offsetParent != this.container.ownerDocument.body;
|
|
9220
|
+
}
|
|
9221
|
+
else {
|
|
9222
|
+
// On other browsers, we have to awkwardly try and use other
|
|
9223
|
+
// information to detect a transform.
|
|
9224
|
+
if (this.view.scaleX != 1 || this.view.scaleY != 1) {
|
|
9225
|
+
makeAbsolute = true;
|
|
9226
|
+
}
|
|
9227
|
+
else if (dom.style.top == Outside && dom.style.left == "0px") {
|
|
9228
|
+
let rect = dom.getBoundingClientRect();
|
|
9229
|
+
makeAbsolute = Math.abs(rect.top + 10000) > 1 || Math.abs(rect.left) > 1;
|
|
9230
|
+
}
|
|
9231
|
+
}
|
|
9222
9232
|
}
|
|
9223
9233
|
if (makeAbsolute || this.position == "absolute") {
|
|
9224
9234
|
if (this.parent) {
|
|
@@ -9272,12 +9282,12 @@ const tooltipPlugin = /*@__PURE__*/ViewPlugin.fromClass(class {
|
|
|
9272
9282
|
let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)
|
|
9273
9283
|
: ltr ? Math.min(pos.left - (arrow ? 14 /* Arrow.Offset */ : 0) + offset.x, space.right - width)
|
|
9274
9284
|
: Math.max(space.left, pos.left - width + (arrow ? 14 /* Arrow.Offset */ : 0) - offset.x);
|
|
9275
|
-
let above =
|
|
9285
|
+
let above = this.above[i];
|
|
9276
9286
|
if (!tooltip.strictSide && (above
|
|
9277
9287
|
? pos.top - (size.bottom - size.top) - offset.y < space.top
|
|
9278
9288
|
: pos.bottom + (size.bottom - size.top) + offset.y > space.bottom) &&
|
|
9279
9289
|
above == (space.bottom - pos.bottom > pos.top - space.top))
|
|
9280
|
-
above = !above;
|
|
9290
|
+
above = this.above[i] = !above;
|
|
9281
9291
|
let spaceVert = (above ? pos.top - space.top : space.bottom - pos.bottom) - arrowHeight;
|
|
9282
9292
|
if (spaceVert < height && tView.resize !== false) {
|
|
9283
9293
|
if (spaceVert < this.view.defaultLineHeight) {
|
|
@@ -9444,6 +9454,23 @@ class HoverTooltipHost {
|
|
|
9444
9454
|
for (let t of this.manager.tooltipViews)
|
|
9445
9455
|
(_a = t.destroy) === null || _a === void 0 ? void 0 : _a.call(t);
|
|
9446
9456
|
}
|
|
9457
|
+
passProp(name) {
|
|
9458
|
+
let value = undefined;
|
|
9459
|
+
for (let view of this.manager.tooltipViews) {
|
|
9460
|
+
let given = view[name];
|
|
9461
|
+
if (given !== undefined) {
|
|
9462
|
+
if (value === undefined)
|
|
9463
|
+
value = given;
|
|
9464
|
+
else if (value !== given)
|
|
9465
|
+
return undefined;
|
|
9466
|
+
}
|
|
9467
|
+
}
|
|
9468
|
+
return value;
|
|
9469
|
+
}
|
|
9470
|
+
get offset() { return this.passProp("offset"); }
|
|
9471
|
+
get getCoords() { return this.passProp("getCoords"); }
|
|
9472
|
+
get overlap() { return this.passProp("overlap"); }
|
|
9473
|
+
get resize() { return this.passProp("resize"); }
|
|
9447
9474
|
}
|
|
9448
9475
|
const showHoverTooltipHost = /*@__PURE__*/showTooltip.compute([showHoverTooltip], state => {
|
|
9449
9476
|
let tooltips = state.facet(showHoverTooltip).filter(t => t);
|