-
Hi, I've written my own canvas plugin and one of the options I want to add to the popup menu is a quick button to open the current node in a hover editor. I think I've figured out how to add the button but I'm not sure how to access the hover editor plugin's methods to actually open the note in a hover editor. I apologise if this is a really dumb basic question but any pointers would be greatly appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Have a look at Quick Explorer: https://github.com/pjeby/quick-explorer/blob/master/src/FolderMenu.ts#L345 Basically, you fire an event with the right link and a hoverParent (second arg to const parent = {
set hoverPopover(popover) {
if (!popover) return // it can be null!
popover.togglePin?.(true); // pin the popover
// XXX do other stuff here?
}
};
// relativeTo should be "" unless path is a relative link, in which case it should be
// what it's relative to. If you have a TFile, use file.path and "" for the last two args:
app.workspace.trigger('link-hover', parent, buttonElement, path, relativeTo); If you want to actually focus the hover editor, not just pop it up, it might be a bit trickier than that. |
Beta Was this translation helpful? Give feedback.
Have a look at Quick Explorer: https://github.com/pjeby/quick-explorer/blob/master/src/FolderMenu.ts#L345
Basically, you fire an event with the right link and a hoverParent (second arg to
trigger
) that's an ObsidianHoverParent
(i.e. has ahoverPopover
property). The object's hoverPopover property will be set to the popover object and you can then callpopover.togglePin?.(true);
to pin it and leave it open (assuming hover editor is installed, otherwise you'll just get a hover preview at the targeted location). Something like: