Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multi-caret #123

Open
feraxhp opened this issue Nov 11, 2024 · 3 comments
Open

Add support for multi-caret #123

feraxhp opened this issue Nov 11, 2024 · 3 comments

Comments

@feraxhp
Copy link
Contributor

feraxhp commented Nov 11, 2024

It would be awesome to have multi-caret function in CodeJar, just like codemirror or monica. But with the awesome simplicity that codejar has.

@antonmedv
Copy link
Owner

Very difficult to do.

@zamfofex
Copy link

I decided I wanted to tackle this. I don’t think it warrants being part of CodeJar itself (it is a bit too complicated, I think), but I made my code available as a separate JSR package: https://jsr.io/@zamfofex/multiselect

Some more information: Apparently Firefox has inbuilt support for multiple selections! (Try it: In Firefox, hold “ctrl” and select some text to add a new selection.) Unfortunately, editing with them works very poorly, so my package adds some better editing capabilities and also common shortcuts (e.g. “ctrl-D” to select occurrences, “ctrl-{up,down}” to add carets above/below).

For browsers that don’t support multiple selections (i.e. all browsers except Firefox), I added a small polyfill that uses the custom highlights API to add fake extra selections (and monkeypatch the selection API to make them visible). The custom highlights API is supported in all browsers except Firefox (which doesn’t need it, because it supports multiple selections by itself).

The documentation for the package is kinda lacking currently, but I wanted to be able to improve on if I ever add it to a Git repository (if there seems to be some kind of interest on it).

If anyone wants to take a look, there is a little “demo” (and/or use case) here: https://zamfofex.neocities.org/aesthetics/

@feraxhp
Copy link
Contributor Author

feraxhp commented Dec 16, 2024

@zamfofex I really like your implementation, i would love to talk with u about some things that i been found over this implementation.

I really support the idea of making a repo with this implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants