selection.js is a JavaScript library to manipulate multiple selections, inspired by Kakoune.
Add selection.js
and selection.css
to your project.
Navigate to https://kakoune.org:
const selections = new SelectionList
// Getting Started
const getStarted = document.querySelector('a[href*="getting-started"]')
selections.add(getStarted) // Selects “Getting Started”
selections.parent(2) // Selects the navigation section
selections.select('a') // Selects all links
selections.focus(getStarted) // Selects “Getting Started”
selections.next(2) // Selects “Issue Tracker”
selections.children() // Selects all of the child elements
selections.previous() // Selects the bug icon
selections.remove(selections.mainSelection) // Removes the main selection
You can find some examples in Krabby.
See the source for a complete reference.