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.3 to 0.18.4

16

CHANGELOG.md

@@ -0,1 +1,17 @@

## 0.18.4 (2021-03-15)
### Breaking changes
It is no longer necessary to use the `tooltips` extension when using this package—just providing values through `showTooltip` will implicitly enable the necessary extensions.
Tooltips no longer use the `class` property on the spec object (just apply the class yourself when creating the DOM element).
### Bug fixes
Tooltips in a dark theme that doesn't explicitly style them no longer use the light theme defaults.
### New features
`showTooltip` now accepts null as input value, which doesn't produce a tooltip.
## 0.18.3 (2021-03-14)

@@ -2,0 +18,0 @@

17

dist/index.d.ts
import { EditorView, ViewUpdate } from '@codemirror/view';
import { Extension, Facet } from '@codemirror/state';
import { Facet, Extension } 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

@@ -31,7 +25,2 @@ the [`showTooltip`](https://codemirror.net/6/docs/ref/#tooltip.showTooltip) facet, control the

/**
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

@@ -72,3 +61,3 @@ position. Defaults to false.

*/
declare const showTooltip: Facet<Tooltip, readonly Tooltip[]>;
declare const showTooltip: Facet<Tooltip | null, readonly (Tooltip | null)[]>;
/**

@@ -87,2 +76,2 @@ Enable a hover tooltip, which shows up when the pointer hovers

export { Tooltip, TooltipView, hoverTooltip, showTooltip, tooltips };
export { Tooltip, TooltipView, hoverTooltip, showTooltip };

@@ -13,8 +13,9 @@ import { ViewPlugin, Direction, EditorView, logException } from '@codemirror/view';

this.measureReq = { read: this.readMeasure.bind(this), write: this.writeMeasure.bind(this), key: this };
this.tooltips = view.state.facet(showTooltip);
this.input = view.state.facet(showTooltip);
this.tooltips = this.input.filter(t => t);
this.tooltipViews = this.tooltips.map(tp => this.createTooltip(tp));
}
update(update) {
let tooltips = update.state.facet(showTooltip);
if (tooltips == this.tooltips) {
let input = update.state.facet(showTooltip);
if (input == this.input) {
for (let t of this.tooltipViews)

@@ -25,8 +26,13 @@ if (t.update)

else {
let tooltips = input.filter(x => x);
let views = [];
for (let i = 0; i < tooltips.length; i++) {
let tip = tooltips[i], known = -1;
for (let i = 0; i < this.tooltips.length; i++)
if (this.tooltips[i].create == tip.create)
if (!tip)
continue;
for (let i = 0; i < this.tooltips.length; i++) {
let other = this.tooltips[i];
if (other && other.create == tip.create)
known = i;
}
if (known < 0) {

@@ -44,2 +50,3 @@ views[i] = this.createTooltip(tip);

t.dom.remove();
this.input = input;
this.tooltips = tooltips;

@@ -53,2 +60,3 @@ this.tooltipViews = views;

tooltipView.dom.classList.add("cm-tooltip");
// FIXME drop this on the next breaking release
if (tooltip.class)

@@ -122,14 +130,19 @@ tooltipView.dom.classList.add(tooltip.class);

position: "fixed",
zIndex: 100
},
"&light .cm-tooltip": {
border: "1px solid #ddd",
backgroundColor: "#f5f5f5",
zIndex: 100
backgroundColor: "#f5f5f5"
},
"&dark .cm-tooltip": {
backgroundColor: "#333338",
color: "white"
}
});
// FIXME backward-compat shim. Delete on next major version.
/**
Supporting extension for displaying tooltips. Allows
[`showTooltip`](https://codemirror.net/6/docs/ref/#tooltip.showTooltip) to be used to create
tooltips.
@internal
*/
function tooltips() {
return [tooltipPlugin, baseTheme];
return [];
}

@@ -139,3 +152,5 @@ /**

*/
const showTooltip = Facet.define();
const showTooltip = Facet.define({
enables: [tooltipPlugin, baseTheme]
});
const HoverTime = 750, HoverMaxDist = 6;

@@ -286,8 +301,7 @@ class HoverPlugin {

},
provide: f => showTooltip.computeN([f], s => { let val = s.field(f); return val ? [val] : []; })
provide: f => showTooltip.from(f)
});
return [
hoverState,
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover)),
tooltips()
ViewPlugin.define(view => new HoverPlugin(view, source, hoverState, setHover))
];

@@ -294,0 +308,0 @@ }

{
"name": "@codemirror/tooltip",
"version": "0.18.3",
"version": "0.18.4",
"description": "Tooltip support for the CodeMirror code editor",

@@ -5,0 +5,0 @@ "scripts": {

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