@codemirror/view 0.20.1 → 0.20.2

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 CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.20.2 (2022-04-22)
2
+
3
+ ### New features
4
+
5
+ The new `hideOn` option to `hoverTooltip` allows more fine-grained control over when the tooltip should hide.
6
+
1
7
  ## 0.20.1 (2022-04-20)
2
8
 
3
9
  ### Bug fixes
package/dist/index.cjs CHANGED
@@ -8261,7 +8261,8 @@ function hoverTooltip(source, options = {}) {
8261
8261
  let hoverState = state.StateField.define({
8262
8262
  create() { return null; },
8263
8263
  update(value, tr) {
8264
- if (value && (options.hideOnChange && (tr.docChanged || tr.selection)))
8264
+ if (value && (options.hideOnChange && (tr.docChanged || tr.selection) ||
8265
+ options.hideOn && options.hideOn(tr, value)))
8265
8266
  return null;
8266
8267
  if (value && tr.docChanged) {
8267
8268
  let newPos = tr.changes.mapPos(value.pos, -1, state.MapMode.TrackDel);
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
@@ -8254,7 +8254,8 @@ function hoverTooltip(source, options = {}) {
8254
8254
  let hoverState = StateField.define({
8255
8255
  create() { return null; },
8256
8256
  update(value, tr) {
8257
- if (value && (options.hideOnChange && (tr.docChanged || tr.selection)))
8257
+ if (value && (options.hideOnChange && (tr.docChanged || tr.selection) ||
8258
+ options.hideOn && options.hideOn(tr, value)))
8258
8259
  return null;
8259
8260
  if (value && tr.docChanged) {
8260
8261
  let newPos = tr.changes.mapPos(value.pos, -1, MapMode.TrackDel);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemirror/view",
3
- "version": "0.20.1",
3
+ "version": "0.20.2",
4
4
  "description": "DOM view component for the CodeMirror code editor",
5
5
  "scripts": {
6
6
  "test": "cm-runtests",