@seorii/prosemirror-math
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -66,3 +66,3 @@ import { TextSelection, Plugin, EditorState, PluginKey, NodeSelection } from 'prosemirror-state'; | ||
this.tooltip = document.createElement("div"); | ||
this.tooltip.className = "tooltip"; | ||
this.tooltip.className = "prosemirror-math-tooltip"; | ||
equation.dom.parentNode.appendChild(this.tooltip); | ||
@@ -82,3 +82,2 @@ this.update(equation, null); | ||
} | ||
// Hide the tooltip if the selection is empty | ||
if (texString.length === 0) { | ||
@@ -88,10 +87,12 @@ this.tooltip.style.display = "none"; | ||
} | ||
// Otherwise, reposition it and update its content | ||
this.tooltip.style.display = ""; | ||
// let {from, to} = state.selection | ||
// let start = view.coordsAtPos(from), end = view.coordsAtPos(to) | ||
let box = this.tooltip.offsetParent.getBoundingClientRect(); | ||
this.tooltip.style.left = equation.coordsAtPos(0).left + "px"; //start.left + "px" | ||
this.tooltip.style.bottom = (box.bottom - equation.coordsAtPos(0).top) + "px"; | ||
try { | ||
this.tooltip.style.display = ""; | ||
let box = this.tooltip.offsetParent?.getBoundingClientRect?.() || { left: 0, top: 0 }; | ||
this.tooltip.style.right = (box.left - equation.coordsAtPos(0).left) + "px"; | ||
this.tooltip.style.top = (box.top - equation.coordsAtPos(0).bottom + 2) + "px"; | ||
} | ||
catch (e) { | ||
return; | ||
} | ||
try { | ||
render(texString, this.tooltip, Object.assign({ | ||
@@ -313,2 +314,3 @@ globalGroup: true, | ||
"Mod-z": () => undo(this._outerView.state, this._outerView.dispatch), | ||
"Mod-Shift-z": () => redo(this._outerView.state, this._outerView.dispatch), | ||
"Mod-y": () => redo(this._outerView.state, this._outerView.dispatch), | ||
@@ -315,0 +317,0 @@ "Tab": (state, dispatch) => { |
@@ -68,3 +68,3 @@ 'use strict'; | ||
this.tooltip = document.createElement("div"); | ||
this.tooltip.className = "tooltip"; | ||
this.tooltip.className = "prosemirror-math-tooltip"; | ||
equation.dom.parentNode.appendChild(this.tooltip); | ||
@@ -84,3 +84,2 @@ this.update(equation, null); | ||
} | ||
// Hide the tooltip if the selection is empty | ||
if (texString.length === 0) { | ||
@@ -90,10 +89,12 @@ this.tooltip.style.display = "none"; | ||
} | ||
// Otherwise, reposition it and update its content | ||
this.tooltip.style.display = ""; | ||
// let {from, to} = state.selection | ||
// let start = view.coordsAtPos(from), end = view.coordsAtPos(to) | ||
let box = this.tooltip.offsetParent.getBoundingClientRect(); | ||
this.tooltip.style.left = equation.coordsAtPos(0).left + "px"; //start.left + "px" | ||
this.tooltip.style.bottom = (box.bottom - equation.coordsAtPos(0).top) + "px"; | ||
try { | ||
this.tooltip.style.display = ""; | ||
let box = this.tooltip.offsetParent?.getBoundingClientRect?.() || { left: 0, top: 0 }; | ||
this.tooltip.style.right = (box.left - equation.coordsAtPos(0).left) + "px"; | ||
this.tooltip.style.top = (box.top - equation.coordsAtPos(0).bottom + 2) + "px"; | ||
} | ||
catch (e) { | ||
return; | ||
} | ||
try { | ||
katex.render(texString, this.tooltip, Object.assign({ | ||
@@ -315,2 +316,3 @@ globalGroup: true, | ||
"Mod-z": () => prosemirrorHistory.undo(this._outerView.state, this._outerView.dispatch), | ||
"Mod-Shift-z": () => prosemirrorHistory.redo(this._outerView.state, this._outerView.dispatch), | ||
"Mod-y": () => prosemirrorHistory.redo(this._outerView.state, this._outerView.dispatch), | ||
@@ -317,0 +319,0 @@ "Tab": (state, dispatch) => { |
{ | ||
"name": "@seorii/prosemirror-math", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Schema and plugins for first-class math support in ProseMirror.", | ||
@@ -5,0 +5,0 @@ "repository": "github:benrbray/prosemirror-math", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
239835
2298