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.19.9 to 0.19.10

10

CHANGELOG.md

@@ -0,1 +1,11 @@

## 0.19.10 (2021-11-23)
### Bug fixes
Make positioning of tooltips that don't fit the available space more well-defined.
### New features
The new `repositionTooltips` function can be used to tell an editor to recompute its tooltip positions.
## 0.19.9 (2021-11-22)

@@ -2,0 +12,0 @@

9

dist/index.d.ts

@@ -143,3 +143,10 @@ import { EditorView, ViewUpdate } from '@codemirror/view';

declare const closeHoverTooltips: StateEffect<null>;
/**
Tell the tooltip extension to recompute the position of the active
tooltips. This can be useful when something happens (such as a
re-positioning or CSS change affecting the editor) that could
invalidate the existing tooltip positions.
*/
declare function repositionTooltips(view: EditorView): void;
export { Tooltip, TooltipView, closeHoverTooltips, hasHoverTooltips, hoverTooltip, showTooltip, tooltips };
export { Tooltip, TooltipView, closeHoverTooltips, hasHoverTooltips, hoverTooltip, repositionTooltips, showTooltip, tooltips };

35

dist/index.js

@@ -76,3 +76,4 @@ import { ViewPlugin, Direction, EditorView, logException } from '@codemirror/view';

this.inView = true;
this.lastLayoutWrite = 0;
this.lastTransaction = 0;
this.intersectionTimeout = -1;
let config = view.state.facet(tooltipConfig);

@@ -86,5 +87,8 @@ this.position = config.position;

this.intersectionObserver = typeof IntersectionObserver == "function" ? new IntersectionObserver(entries => {
if (Date.now() > this.lastLayoutWrite - 20 &&
if (this.intersectionTimeout < 0 && Date.now() > this.lastTransaction - 50 &&
entries.length > 0 && entries[entries.length - 1].intersectionRatio < 1)
this.maybeMeasure();
this.intersectionTimeout = setTimeout(() => {
this.intersectionTimeout = -1;
this.maybeMeasure();
}, 50);
}, { threshold: [1] }) : null;

@@ -113,2 +117,4 @@ this.observeIntersection();

update(update) {
if (update.transactions.length)
this.lastTransaction = Date.now();
let updated = this.manager.update(update);

@@ -160,2 +166,3 @@ if (updated)

(_a = this.intersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
clearTimeout(this.intersectionTimeout);
}

@@ -173,3 +180,2 @@ readMeasure() {

writeMeasure(measured) {
this.lastLayoutWrite = Date.now();
let { editor, space } = measured;

@@ -192,9 +198,10 @@ let others = [];

let offset = tView.offset || noOffset, ltr = this.view.textDirection == Direction.LTR;
let left = ltr
? Math.min(pos.left - (arrow ? 14 /* Offset */ : 0) + offset.x, space.right - width)
: Math.max(space.left, pos.left - width + (arrow ? 14 /* Offset */ : 0) - offset.x);
let left = size.width > space.right - space.left ? (ltr ? space.left : space.right - size.width)
: ltr ? Math.min(pos.left - (arrow ? 14 /* Offset */ : 0) + offset.x, space.right - width)
: Math.max(space.left, pos.left - width + (arrow ? 14 /* Offset */ : 0) - offset.x);
let above = !!tooltip.above;
if (!tooltip.strictSide && (above
? pos.top - (size.bottom - size.top) - offset.y < space.top
: pos.bottom + (size.bottom - size.top) + offset.y > space.bottom))
: pos.bottom + (size.bottom - size.top) + offset.y > space.bottom) &&
above == (space.bottom - pos.bottom > pos.top - space.top))
above = !above;

@@ -528,3 +535,13 @@ let top = above ? pos.top - height - arrowHeight - offset.y : pos.bottom + arrowHeight + offset.y;

const closeHoverTooltips = /*@__PURE__*/closeHoverTooltipEffect.of(null);
/**
Tell the tooltip extension to recompute the position of the active
tooltips. This can be useful when something happens (such as a
re-positioning or CSS change affecting the editor) that could
invalidate the existing tooltip positions.
*/
function repositionTooltips(view) {
var _a;
(_a = view.plugin(tooltipPlugin)) === null || _a === void 0 ? void 0 : _a.maybeMeasure();
}
export { closeHoverTooltips, hasHoverTooltips, hoverTooltip, showTooltip, tooltips };
export { closeHoverTooltips, hasHoverTooltips, hoverTooltip, repositionTooltips, showTooltip, tooltips };
{
"name": "@codemirror/tooltip",
"version": "0.19.9",
"version": "0.19.10",
"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