Dynannotate: Improve selection tracker

These improvements rely on the new JSON operators to be useful. Those improvements were originally in #6522 but now there's an updated version in #6666. Managing things is simpler if I merge these changes now
This commit is contained in:
jeremy@jermolene.com
2022-05-25 15:23:11 +01:00
parent a226975b3e
commit df7416d16b
5 changed files with 372 additions and 100 deletions

View File

@@ -183,7 +183,16 @@ DynannotateWidget.prototype.applyAnnotations = function() {
// We'll dynamically build the click event handler so that we can reuse it
var clickHandlerFn = function(title) {
return function(event,domOverlay,modifierKey) {
self.invokeActionString(self.getAttribute("actions"),self,event,{annotationTiddler: title, modifier: modifierKey});
var bounds = domOverlay.getBoundingClientRect();
self.invokeActionString(self.getAttribute("actions"),self,event,{
annotationTiddler: title,
modifier: modifierKey,
"tv-selection-posx": (bounds.left).toString(),
"tv-selection-posy": (bounds.top).toString(),
"tv-selection-width": (bounds.width).toString(),
"tv-selection-height": (bounds.height).toString(),
"tv-selection-coords": "(" + bounds.left + "," + bounds.top + "," + bounds.width + "," + bounds.height + ")"
});
if(self.hasAttribute("popup")) {
$tw.popup.triggerPopup({
domNode: domOverlay,