obsidian-releases icon indicating copy to clipboard operation
obsidian-releases copied to clipboard

Add Obsidian-Reset-Checkboxes Plugin

Open branwall opened this issue 2 years ago • 1 comments

I am submitting a new Community Plugin

Repo URL

Link to my plugin

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] 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 my manifest.json matches the id in the community-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.

branwall avatar Apr 20 '22 21:04 branwall

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

lishid avatar Apr 26 '22 18:04 lishid

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!

ericaxu avatar Nov 09 '22 01:11 ericaxu