Open dxcore35 opened 6 months ago
You can already achieve that with replaceSelf
and an empty replacement string.
Maybe just add it duplicity and call it Remove button. More clear and not much code for you to implement. The empty string is "hack" it works, but not so obvious.
I just rested it unfortunately it is not working in my case for INLINE BUTTON.
ButtonMDRC >> error while running action Error: Replace self action not supported for inline buttons
at bp.runReplaceSelfAction (plugin:obsidian-meta-bind-plugin:53:52)
at bp.runAction (plugin:obsidian-meta-bind-plugin:51:7266)
at bp.runButtonAction (plugin:obsidian-meta-bind-plugin:51:5233)
at async onClick (plugin:obsidian-meta-bind-plugin:57:14387)
at async f (plugin:obsidian-meta-bind-plugin:57:13107)
Yep, because of a limitation in the Obsidian API. There is no way for inline buttons to know where in the file they are, and they need that to replace themselves.
But inline buttons are just text no? If you know the name of button that was triggered you can simply replace the inline button as text with null no?
The same string of text might occur multiple times in the file, or even as part of something else which is not an inline button declaration. So doing a simple find and replace could result in undesirable behavior.
Do you really thing somebody will add text in those brackets? BUTTON[action-summarize]
? I highly doubt and other inline will also not use BUTTON as prefix. It is something to think about, I think percentage is extremely small.... Maybe just write good explanation with warning in description? will be sufficient.
This inline buttons are gold it is pitty to not have option to destroy them :)
@mProjectsCode it's pretty easy to work around that. The Buttons plugin generates unique identifiers for each button, and as @dxcore35 suggested, meta bind could just make use of the BUTTON[ID]
syntax as their unique identifier as it's very unlikely that this will be used elsewhere. While I have not tested and so I suppose the ID may not be a unique identifier, a possible solution is to add in a unique ID if the inline button is set for self destruct on click.
@mProjectsCode wrote that the buttons can be remove using JS. Please show me an example of how to do this?
Is your Feature Request Related to a Problem?
In this list
Add auto destruct button action
Describe the Feature you'd Like
After clicking on the button the button will be removed from note. It should respect the order. For example I will asign button to export to PDF and then delete itself. The deletion should be executed the last.
Additional Context
No response