Socket
Socket
Sign inDemoInstall

@codemirror/tooltip

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@codemirror/tooltip - npm Package Compare versions

Comparing version 0.18.1 to 0.18.2

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## 0.18.2 (2021-03-14)
### Bug fixes
Fix an issue where tooltips created in an out-of-view editor show up in the wrong place.
## 0.18.1 (2021-03-04)

@@ -2,0 +8,0 @@

import { EditorView, ViewUpdate } from '@codemirror/view';
import { Extension, Facet } from '@codemirror/state';
/**
Supporting extension for displaying tooltips. Allows
[`showTooltip`](https://codemirror.net/6/docs/ref/#tooltip.showTooltip) to be used to create
tooltips.
*/
declare function tooltips(): Extension;
/**
Describes a tooltip. Values of this type, when provided through
the [`showTooltip`](https://codemirror.net/6/docs/ref/#tooltip.showTooltip) facet, control the
individual tooltips on the editor.
*/
interface Tooltip {
/**
The document position at which to show the tooltip.
*/
pos: number;
/**
The end of the range annotated by this tooltip, if different
from `pos`.
*/
end?: number;
/**
A constructor function that creates the tooltip's [DOM
representation](https://codemirror.net/6/docs/ref/#tooltip.TooltipView).
*/
create(view: EditorView): TooltipView;
/**
An extra class to add to the tooltip element. By default,
it'll get only `"cm-tooltip"`.
*/
class?: string;
/**
Whether the tooltip should be shown above or below the target
position. Defaults to false.
*/
above?: boolean;
/**
Whether the `above` option should be honored when there isn't
enough space on that side to show the tooltip inside the
viewport. Defaults to false.
*/
strictSide?: boolean;
}
/**
Describes the way a tooltip is displayed.
*/
interface TooltipView {
/**
The DOM element to position over the editor.
*/
dom: HTMLElement;
/**
Called after the tooltip is added to the DOM for the first time.
*/
mount?(view: EditorView): void;
/**
Update the DOM element for a change in the view's state.
*/
update?(update: ViewUpdate): void;
/**
Called when the tooltip has been (re)positioned.
*/
positioned?(): void;
}
/**
Behavior by which an extension can provide a tooltip to be shown.
*/
declare const showTooltip: Facet<Tooltip, readonly Tooltip[]>;
/**
Enable a hover tooltip, which shows up when the pointer hovers
over ranges of text. The callback is called when the mouse hovers
over the document text. It should, if there is a tooltip
associated with position `pos` return the tooltip description
(either directly or in a promise). The `side` argument indicates
on which side of the position the pointer is—it will be -1 if the
pointer is before the position, 1 if after the position.
*/
declare function hoverTooltip(source: (view: EditorView, pos: number, side: -1 | 1) => Tooltip | null | Promise<Tooltip | null>, options?: {

@@ -21,0 +82,0 @@ hideOnChange?: boolean;

33

dist/index.js

@@ -1,2 +0,2 @@

import { ViewPlugin, Direction, EditorView } from '@codemirror/view';
import { ViewPlugin, Direction, EditorView, logException } from '@codemirror/view';
import { Facet, StateEffect, StateField, MapMode } from '@codemirror/state';

@@ -52,2 +52,3 @@

tooltipView.dom.classList.add(tooltip.class);
tooltip.style.top = Outside;
this.view.dom.appendChild(tooltipView.dom);

@@ -123,9 +124,13 @@ if (tooltipView.mount)

});
/// Supporting extension for displaying tooltips. Allows
/// [`showTooltip`](#tooltip.showTooltip) to be used to create
/// tooltips.
/**
Supporting extension for displaying tooltips. Allows
[`showTooltip`](https://codemirror.net/6/docs/ref/#tooltip.showTooltip) to be used to create
tooltips.
*/
function tooltips() {
return [tooltipPlugin, baseTheme];
}
/// Behavior by which an extension can provide a tooltip to be shown.
/**
Behavior by which an extension can provide a tooltip to be shown.
*/
const showTooltip = Facet.define();

@@ -192,3 +197,3 @@ const HoverTime = 750, HoverMaxDist = 6;

}
});
}, e => logException(this.view.state, e, "hover tooltip"));
}

@@ -247,9 +252,11 @@ else if (open) {

}
/// Enable a hover tooltip, which shows up when the pointer hovers
/// over ranges of text. The callback is called when the mouse hovers
/// over the document text. It should, if there is a tooltip
/// associated with position `pos` return the tooltip description
/// (either directly or in a promise). The `side` argument indicates
/// on which side of the position the pointer is—it will be -1 if the
/// pointer is before the position, 1 if after the position.
/**
Enable a hover tooltip, which shows up when the pointer hovers
over ranges of text. The callback is called when the mouse hovers
over the document text. It should, if there is a tooltip
associated with position `pos` return the tooltip description
(either directly or in a promise). The `side` argument indicates
on which side of the position the pointer is—it will be -1 if the
pointer is before the position, 1 if after the position.
*/
function hoverTooltip(source, options = {}) {

@@ -256,0 +263,0 @@ const setHover = StateEffect.define();

{
"name": "@codemirror/tooltip",
"version": "0.18.1",
"version": "0.18.2",
"description": "Tooltip support for the CodeMirror code editor",
"scripts": {
"test": "echo 'No tests'",
"prepare": "tsc -p tsconfig.local.json && rollup -c"
"prepare": "cm-buildhelper src/tooltip.ts"
},

@@ -33,5 +33,3 @@ "keywords": [

"devDependencies": {
"rollup": "^2.35.1",
"rollup-plugin-dts": "^2.0.1",
"typescript": "^4.1.3"
"@codemirror/buildhelper": "^0.1.0"
},

@@ -38,0 +36,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc