gatsby-remark-shiki-twoslash
Advanced tools
Comparing version 0.5.5 to 0.5.6
@@ -15,5 +15,16 @@ "use strict"; | ||
var resetHover = function () { | ||
var globalPopover = document.getElementById('mouse-hover-info'); | ||
var globalPopover = document.getElementById('twoslash-mouse-hover-info'); | ||
globalPopover.style.display = 'none'; | ||
}; | ||
// Get it | ||
var findOrCreateTooltip = function () { | ||
var globalPopover = document.getElementById('twoslash-mouse-hover-info'); | ||
if (!globalPopover) { | ||
globalPopover = document.createElement('div'); | ||
globalPopover.style.position = 'absolute'; | ||
globalPopover.id = 'twoslash-mouse-hover-info'; | ||
document.body.appendChild(globalPopover); | ||
} | ||
return globalPopover; | ||
}; | ||
/** | ||
@@ -47,11 +58,13 @@ * Creates the main mouse over popup for LSP info using the DOM API. | ||
var position = getAbsoluteElementPos(hovered); | ||
var globalPopover = document.getElementById('mouse-hover-info'); | ||
// Create or re-use the current hover dic | ||
var tooltip = findOrCreateTooltip(); | ||
// Use a textarea to un-htmlencode for presenting to the user | ||
var txt = document.createElement('textarea'); | ||
txt.innerHTML = message; | ||
globalPopover.textContent = txt.value; | ||
tooltip.textContent = txt.value; | ||
// Offset it a bit from the mouse and present it at an absolute position | ||
var yOffset = 20; | ||
globalPopover.style.display = 'block'; | ||
globalPopover.style.top = position.top + yOffset + "px"; | ||
globalPopover.style.left = position.left + "px"; | ||
tooltip.style.display = 'block'; | ||
tooltip.style.top = position.top + yOffset + "px"; | ||
tooltip.style.left = position.left + "px"; | ||
}; | ||
@@ -58,0 +71,0 @@ twoslashes.forEach(function (codeblock) { |
{ | ||
"name": "gatsby-remark-shiki-twoslash", | ||
"version": "0.5.5", | ||
"version": "0.5.6", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/microsoft/TypeScript-Website/", |
92835
710