mProjectsCode / mProjectsCode/obsidian-meta-bind-plugin
Replace Self for inline buttons
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1k
- Forks
- 86
- PR merge metrics
- No merged PRs in 30d
Description
Please fill out these Check-boxes
- I checked for existing similar feature requests
- I have read the docs and checked that the feature I am requesting is not already implemented
- My feature request consists of only one feature
Is your Feature Request related to a Problem or Annoyance?
My real problem is that I want to have a button to add rows to a table following a template.
| Time | Note |
| ----- | ------------- |
| 10:00 | [[Breakfast]] |
| 13:25 | [[Meditate]] |
`BUTTON[add]`
But the only way I have figured out to do this is to replace the button with a template that itself contains a copy of the button:
| <% tp.date.now("HH:mm") %> | |
```meta-bind-button
label: Add
style: default
id: add
actions:
- type: replaceSelf
replacement: "templater/Log Entry.md"
templater: true
```
But now I have to maintain the two copies. I was frustrated to find out that this does not work with inline buttons that would make this an almost elegant solution.
I'm open to better solutions, but I still feel that inline button replacement would be nice.
Describe the Feature you'd like
Make Replace Self work with inline buttons so that the inline button is replaced.
Example
| Time | Note |
| ----- | ------------- |
| 10:00 | [[Breakfast]] |
| 13:25 | [[Meditate]] |
`BUTTON[add]`
```meta-bind-button
label: Add
style: default
id: add
hidden: true
actions:
- type: replaceSelf
replacement: "templater/Log Entry.md"
templater: true
```
Template
| <% tp.date.now("HH:mm") %> | |
`BUTTON[add]`
Alternatives
- Insert Into Note with line number wouldn't work because line number increases for each table row
- RegExp Replace In Note could be used to replace the button, but it does not seem to support templates
- Run JavaScript File could be used but would be tedious to figure out
- Run Templater File, likewise
Additional Context
This is mentioned in docs of Replace Self.
This only works with buttons in blocks, so this action will not work with inline buttons which are not inside a meta-bind block.
A bonus is that you would no longer need to document this limitation :-)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Replace Self action documentation and the inline button behavior described in the issue, then locate the implementation that currently limits the action to buttons in blocks. Verify the action can replace an inline button while processing the templater replacement, and update the documented limitation when the behavior works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100