@codemirror/view 0.20.0 → 0.20.3
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 +20 -0
- package/dist/index.cjs +8 -10
- package/dist/index.d.ts +7 -2
- package/dist/index.js +8 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## 0.20.3 (2022-04-27)
|
|
2
|
+
|
|
3
|
+
### Bug fixes
|
|
4
|
+
|
|
5
|
+
Fix a bug where the input handling could crash on repeated (or held) backspace presses on Chrome Android.
|
|
6
|
+
|
|
7
|
+
## 0.20.2 (2022-04-22)
|
|
8
|
+
|
|
9
|
+
### New features
|
|
10
|
+
|
|
11
|
+
The new `hideOn` option to `hoverTooltip` allows more fine-grained control over when the tooltip should hide.
|
|
12
|
+
|
|
13
|
+
## 0.20.1 (2022-04-20)
|
|
14
|
+
|
|
15
|
+
### Bug fixes
|
|
16
|
+
|
|
17
|
+
Remove debug statements that accidentally made it into 0.20.0.
|
|
18
|
+
|
|
19
|
+
Fix a regression in `moveVertically`.
|
|
20
|
+
|
|
1
21
|
## 0.20.0 (2022-04-20)
|
|
2
22
|
|
|
3
23
|
### Breaking changes
|
package/dist/index.cjs
CHANGED
|
@@ -2880,7 +2880,8 @@ function computeCompositionDeco(view, changes) {
|
|
|
2880
2880
|
topView = topView.widget.topView;
|
|
2881
2881
|
else if (topView)
|
|
2882
2882
|
topView.parent = null;
|
|
2883
|
-
return Decoration.set(Decoration.replace({ widget: new CompositionWidget(node, textNode, topView) })
|
|
2883
|
+
return Decoration.set(Decoration.replace({ widget: new CompositionWidget(node, textNode, topView), inclusive: true })
|
|
2884
|
+
.range(newFrom, newTo));
|
|
2884
2885
|
}
|
|
2885
2886
|
class CompositionWidget extends WidgetType {
|
|
2886
2887
|
constructor(top, text, topView) {
|
|
@@ -3230,7 +3231,7 @@ function moveVertically(view, start, forward, distance) {
|
|
|
3230
3231
|
startY = dir < 0 ? startCoords.top : startCoords.bottom;
|
|
3231
3232
|
}
|
|
3232
3233
|
else {
|
|
3233
|
-
let line = view.viewState.lineBlockAt(startPos
|
|
3234
|
+
let line = view.viewState.lineBlockAt(startPos);
|
|
3234
3235
|
if (goal == null)
|
|
3235
3236
|
goal = Math.min(rect.right - rect.left, view.defaultCharacterWidth * (startPos - line.from));
|
|
3236
3237
|
startY = (dir < 0 ? line.top : line.bottom) + docTop;
|
|
@@ -5563,6 +5564,7 @@ class DOMObserver {
|
|
|
5563
5564
|
let key = this.delayedAndroidKey;
|
|
5564
5565
|
this.delayedAndroidKey = null;
|
|
5565
5566
|
let startState = this.view.state;
|
|
5567
|
+
this.readSelectionRange();
|
|
5566
5568
|
if (dispatchKey(this.view.contentDOM, key.key, key.keyCode))
|
|
5567
5569
|
this.processRecords();
|
|
5568
5570
|
else
|
|
@@ -8081,9 +8083,7 @@ Facet to which an extension can add a value to show a tooltip.
|
|
|
8081
8083
|
const showTooltip = state.Facet.define({
|
|
8082
8084
|
enables: [tooltipPlugin, baseTheme]
|
|
8083
8085
|
});
|
|
8084
|
-
const showHoverTooltip = state.Facet.define(
|
|
8085
|
-
combine(x) { console.log("show", x.map(x => !!x)); return x; }
|
|
8086
|
-
});
|
|
8086
|
+
const showHoverTooltip = state.Facet.define();
|
|
8087
8087
|
class HoverTooltipHost {
|
|
8088
8088
|
constructor(view) {
|
|
8089
8089
|
this.view = view;
|
|
@@ -8123,7 +8123,6 @@ class HoverTooltipHost {
|
|
|
8123
8123
|
}
|
|
8124
8124
|
const showHoverTooltipHost = showTooltip.compute([showHoverTooltip], state => {
|
|
8125
8125
|
let tooltips = state.facet(showHoverTooltip).filter(t => t);
|
|
8126
|
-
console.log("hover tooltips: ", tooltips.length);
|
|
8127
8126
|
if (tooltips.length === 0)
|
|
8128
8127
|
return null;
|
|
8129
8128
|
return {
|
|
@@ -8264,8 +8263,8 @@ function hoverTooltip(source, options = {}) {
|
|
|
8264
8263
|
let hoverState = state.StateField.define({
|
|
8265
8264
|
create() { return null; },
|
|
8266
8265
|
update(value, tr) {
|
|
8267
|
-
|
|
8268
|
-
|
|
8266
|
+
if (value && (options.hideOnChange && (tr.docChanged || tr.selection) ||
|
|
8267
|
+
options.hideOn && options.hideOn(tr, value)))
|
|
8269
8268
|
return null;
|
|
8270
8269
|
if (value && tr.docChanged) {
|
|
8271
8270
|
let newPos = tr.changes.mapPos(value.pos, -1, state.MapMode.TrackDel);
|
|
@@ -8281,9 +8280,8 @@ function hoverTooltip(source, options = {}) {
|
|
|
8281
8280
|
if (effect.is(setHover))
|
|
8282
8281
|
value = effect.value;
|
|
8283
8282
|
if (effect.is(closeHoverTooltipEffect))
|
|
8284
|
-
value =
|
|
8283
|
+
value = null;
|
|
8285
8284
|
}
|
|
8286
|
-
console.log("updated: " + !!value);
|
|
8287
8285
|
return value;
|
|
8288
8286
|
},
|
|
8289
8287
|
provide: f => showHoverTooltip.from(f)
|
package/dist/index.d.ts
CHANGED
|
@@ -1546,11 +1546,16 @@ container element. This allows multiple tooltips over the same
|
|
|
1546
1546
|
range to be "merged" together without overlapping.
|
|
1547
1547
|
*/
|
|
1548
1548
|
declare function hoverTooltip(source: (view: EditorView, pos: number, side: -1 | 1) => Tooltip | null | Promise<Tooltip | null>, options?: {
|
|
1549
|
+
/**
|
|
1550
|
+
Controls whether a transaction hides the tooltip. The default
|
|
1551
|
+
is to not hide.
|
|
1552
|
+
*/
|
|
1553
|
+
hideOn?: (tr: Transaction, tooltip: Tooltip) => boolean;
|
|
1549
1554
|
/**
|
|
1550
1555
|
When enabled (this defaults to false), close the tooltip
|
|
1551
|
-
whenever the document changes.
|
|
1556
|
+
whenever the document changes or the selection is set.
|
|
1552
1557
|
*/
|
|
1553
|
-
hideOnChange?: boolean;
|
|
1558
|
+
hideOnChange?: boolean | "touch";
|
|
1554
1559
|
/**
|
|
1555
1560
|
Hover time after which the tooltip should appear, in
|
|
1556
1561
|
milliseconds. Defaults to 300ms.
|
package/dist/index.js
CHANGED
|
@@ -2874,7 +2874,8 @@ function computeCompositionDeco(view, changes) {
|
|
|
2874
2874
|
topView = topView.widget.topView;
|
|
2875
2875
|
else if (topView)
|
|
2876
2876
|
topView.parent = null;
|
|
2877
|
-
return Decoration.set(Decoration.replace({ widget: new CompositionWidget(node, textNode, topView) })
|
|
2877
|
+
return Decoration.set(Decoration.replace({ widget: new CompositionWidget(node, textNode, topView), inclusive: true })
|
|
2878
|
+
.range(newFrom, newTo));
|
|
2878
2879
|
}
|
|
2879
2880
|
class CompositionWidget extends WidgetType {
|
|
2880
2881
|
constructor(top, text, topView) {
|
|
@@ -3224,7 +3225,7 @@ function moveVertically(view, start, forward, distance) {
|
|
|
3224
3225
|
startY = dir < 0 ? startCoords.top : startCoords.bottom;
|
|
3225
3226
|
}
|
|
3226
3227
|
else {
|
|
3227
|
-
let line = view.viewState.lineBlockAt(startPos
|
|
3228
|
+
let line = view.viewState.lineBlockAt(startPos);
|
|
3228
3229
|
if (goal == null)
|
|
3229
3230
|
goal = Math.min(rect.right - rect.left, view.defaultCharacterWidth * (startPos - line.from));
|
|
3230
3231
|
startY = (dir < 0 ? line.top : line.bottom) + docTop;
|
|
@@ -5556,6 +5557,7 @@ class DOMObserver {
|
|
|
5556
5557
|
let key = this.delayedAndroidKey;
|
|
5557
5558
|
this.delayedAndroidKey = null;
|
|
5558
5559
|
let startState = this.view.state;
|
|
5560
|
+
this.readSelectionRange();
|
|
5559
5561
|
if (dispatchKey(this.view.contentDOM, key.key, key.keyCode))
|
|
5560
5562
|
this.processRecords();
|
|
5561
5563
|
else
|
|
@@ -8074,9 +8076,7 @@ Facet to which an extension can add a value to show a tooltip.
|
|
|
8074
8076
|
const showTooltip = /*@__PURE__*/Facet.define({
|
|
8075
8077
|
enables: [tooltipPlugin, baseTheme]
|
|
8076
8078
|
});
|
|
8077
|
-
const showHoverTooltip = /*@__PURE__*/Facet.define(
|
|
8078
|
-
combine(x) { console.log("show", x.map(x => !!x)); return x; }
|
|
8079
|
-
});
|
|
8079
|
+
const showHoverTooltip = /*@__PURE__*/Facet.define();
|
|
8080
8080
|
class HoverTooltipHost {
|
|
8081
8081
|
constructor(view) {
|
|
8082
8082
|
this.view = view;
|
|
@@ -8116,7 +8116,6 @@ class HoverTooltipHost {
|
|
|
8116
8116
|
}
|
|
8117
8117
|
const showHoverTooltipHost = /*@__PURE__*/showTooltip.compute([showHoverTooltip], state => {
|
|
8118
8118
|
let tooltips = state.facet(showHoverTooltip).filter(t => t);
|
|
8119
|
-
console.log("hover tooltips: ", tooltips.length);
|
|
8120
8119
|
if (tooltips.length === 0)
|
|
8121
8120
|
return null;
|
|
8122
8121
|
return {
|
|
@@ -8257,8 +8256,8 @@ function hoverTooltip(source, options = {}) {
|
|
|
8257
8256
|
let hoverState = StateField.define({
|
|
8258
8257
|
create() { return null; },
|
|
8259
8258
|
update(value, tr) {
|
|
8260
|
-
|
|
8261
|
-
|
|
8259
|
+
if (value && (options.hideOnChange && (tr.docChanged || tr.selection) ||
|
|
8260
|
+
options.hideOn && options.hideOn(tr, value)))
|
|
8262
8261
|
return null;
|
|
8263
8262
|
if (value && tr.docChanged) {
|
|
8264
8263
|
let newPos = tr.changes.mapPos(value.pos, -1, MapMode.TrackDel);
|
|
@@ -8274,9 +8273,8 @@ function hoverTooltip(source, options = {}) {
|
|
|
8274
8273
|
if (effect.is(setHover))
|
|
8275
8274
|
value = effect.value;
|
|
8276
8275
|
if (effect.is(closeHoverTooltipEffect))
|
|
8277
|
-
value =
|
|
8276
|
+
value = null;
|
|
8278
8277
|
}
|
|
8279
|
-
console.log("updated: " + !!value);
|
|
8280
8278
|
return value;
|
|
8281
8279
|
},
|
|
8282
8280
|
provide: f => showHoverTooltip.from(f)
|