hey!
Unfortunately there’s no way right now to understand whether widget is locked or not.
Will add it to our backlog
@Boris Borodyansky gave an answer in another thread on how to add an icon to a widget:
https://community.miro.com/developer-forum-57/add-icon-to-widgetcontextmenu-393?postid=1253#post1253
But i have not yet found out, how the onClick Callback retrieves any info on the widget that was clicked. The callback from the SDK does not deliver anything.
t.prototype.callMenuItemClickListener = function(t) {
this.menuItemsClickListenerss"widgetMenuItems_" + t]()
}
I am afraid, that we have to get the info about the items that contextmenu is supposed to work on, from the current selection. But we might have to catch it in the outer widgets context method and not give it as a parameter in the onClick method.
Any thoughts or ideas?
Falk
Yes i have successfully added the button using the following (apologies for the formatting, it seems to be broken):
miro.onReady(() => {
miro.initialize({
extensionPoints: {
getWidgetMenuItems: async (widgets) => {
if (widgetss0]]'type'] == 'STICKER') {
return Promise.resolve({
tooltip: 'tooltip',
svgIcon: icon,
onClick: (widgets) => {
doStuff(widgets)
}
})
}
}
}
})
})
Getting the information that contextmenu is supposed to work on from the current selection should not be an issue here, as the resulting action (doStuff() in the above code) acts on the current selection anyway.
But we might have to catch it in the outer widgets context method and not give it as a parameter in the onClick method.
I am sorry but i’m not sure I understand this part. In essence I suppose I am asking is it possible to distinguish if a widget is locked from the context of a web plugin?
Just remove the parameter widgets in the onClick method and then it should work:
...
onClick: () => {
doStuff(widgets)
}
...
Since the widgets will not be given as a parameter to the onClick callback, but stay in the context of the getWidgetMenuItems context, you can still access the widgets there, if you do not put them as a parameter in the callback function.
Have fun!
Falk
I appreciate the guidance @Falk Kühnel, howewer I am afraid the issue persists.
My updated code is here if it’s of interest:
https://github.com/Pheels/miro-underline-text/blob/master/index.html