obsidian-releases
obsidian-releases copied to clipboard
Add Obsidian-Reset-Checkboxes Plugin
I am submitting a new Community Plugin
Repo URL
Release Checklist
- [X] I have tested the plugin on
- [x] Windows
- [ ] macOS
- [ ] Linux
- [ ] Android (if applicable)
- [x] iOS (if applicable)
- [x] My GitHub release contains all required files
- [x]
main.js
- [x]
manifest.json
- [ ]
styles.css
(optional)
- [x]
- [x] GitHub release name matches the exact version number specified in my manifest.json (Note: Use the exact version number, don't include a prefix
v
) - [x] The
id
in mymanifest.json
matches theid
in thecommunity-plugins.json
file. - [x] My README.md describes the plugin's purpose and provides clear usage instructions.
- [x] I have read the tips in https://github.com/obsidianmd/obsidian-releases/blob/master/plugin-review.md and have self-reviewed my plugin to avoid these common pitfalls.
- [x] I have added a license in the LICENSE file.
- [x] My project respects and is compatible with the original license of any code from other plugins that I'm using.
I have given proper attribution to these other projects in my
README.md
.
https://github.com/branwall/obsidian-reset-checkboxes/blob/f3a10dd1f7dc4b8442dba2cd6e5a66230a7faca5/main.ts#L13
Ok here I would suggest running your code on a line-by-line basis instead of using getValue()
because when you replace the whole file's content with setValue()
, it causes line and position associations (like folding, etc) to be completely broken, which means when you do this, the user will lose all of their editor folding. Other plugins that rely on text positions and markers will also lose positions, and may or may not be able to deal with that gracefully. Lastly this is bad for performance because it forces the editor to re-parse the entire file.
What you can do is to get the number of lines, iterate through each line, and issue a replaceRange
only when you find a match. The downside with doing that is that the undo history will now undo each line at a time.
For a perfect implementation, you should add your changed ranges to an array and use the editor API "transaction" with an array of changes
, which will performs all changes at the same time in a single undo commit:
https://github.com/obsidianmd/obsidian-api/blob/036708710c4a4b652d8166c5929d5ba1ffb7fb91/obsidian.d.ts#L836
Hi there, to keep things tidy, we're going to temporarily close plugin PRs after a month of inactivity.
Feel free to tell us to re-open it when you're ready to continue. Thanks for your understanding!