Is it possible that it is no longer possible to trigger a PostMessage from a plugin panel? I'm using the latest version 1.4.12 and the I am only able to hit the event listener in webview.js.
I'm testing the TOC example plugin and the event listener looks currently like this:
document.addEventListener('click', event => {
const element = event.target;
if (element.className === 'toc-item-link') {
const slug = element.dataset.slug;
console.info('Clicked header slug: ' + slug);
webviewApi.postMessage({
name: 'scrollToHash',
hash: element.dataset.slug,
});
}
})
On the console I can see that the info message is printed.
But the onMessage handler in the plugin is not reached:
panels.onMessage(view, (message:any) => {
console.info("message received");
alert("message received");
if (message.name === 'scrollToHash') {
joplin.commands.execute('scrollToHash', message.hash)
}
});
The panel itself is created as in the example described.
Is there something I have to add in the latest version to get this running?