roam-toolkit
roam-toolkit copied to clipboard
Add reference sorting
This is a super hacky proof-of-concept, but I wanted to get some feedback on the direction before investing too much time into it.
Features being added:
- Reference Sorting
- Alphabetically (asc/desc)
- Daily notes (first/last)
TODOs
I've tried pointing out all the pending TODO items in code comments, but just capturing the major ones here as well:
- [ ] Add settings for the different sorting modes
- [ ] Toggle sorting for Linked References and/or Unlinked References
- [ ] Refactor out DOM MutationObserver into a generic helper util
- [ ] Handle page navigation and potential reference filtering updates
- Similar discussion: https://github.com/roam-unofficial/roam-toolkit/pull/72#discussion_r432984849
- [x] Figure out a better way to store class selectors for easier maintenance
- Potentially something like what @tntmarket did here: #63 (file)
- [ ] Add logic for destroying HTML elements + eventListeners
- [ ] Wrap everything in a
Class - [ ] Fix sorting logic for daily notes (first/last)
Clean-up
- [ ] Remove debug + console.logs
- [ ] Squash commits
Example

(it was super fun getting back into a bit of JavaScript again, and using TypeScript for the first time)
would be nice to support queries too :)
@matiassingers Just fyi @tntmarket has already created the abstraction to wait for selector on top of mutation observe (that's the same use-case you have if I understand correctly)
@tntmarket can you create a PR to push that part as it'd be useful here and in #83
Opened up a PR here: https://github.com/roam-unofficial/roam-toolkit/pull/93
The helpers will be in src/ts/core/common/mutation-observer.ts
Thanks, merged!