roam-toolkit icon indicating copy to clipboard operation
roam-toolkit copied to clipboard

Add reference sorting

Open matiassingers opened this issue 5 years ago • 4 comments

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

reference-sorting-poc

(it was super fun getting back into a bit of JavaScript again, and using TypeScript for the first time)

matiassingers avatar Jun 15 '20 01:06 matiassingers

would be nice to support queries too :)

Stvad avatar Jun 15 '20 06:06 Stvad

@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

Stvad avatar Jun 27 '20 06:06 Stvad

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

tntmarket avatar Jun 27 '20 23:06 tntmarket

Thanks, merged!

Stvad avatar Jun 27 '20 23:06 Stvad