Code Monkey home page Code Monkey logo

Comments (1)

MaxArt2501 avatar MaxArt2501 commented on May 11, 2024

Short answer: no.

Long answer: the library relies on some document-wide events to check whether a selection is present. And the selection itself is retrieved using the Selection API.

The problem here is that, although the selectionchange event is fired when you select something in a textarea... it doesn't happen in Firefox and I'd say that, in fact, it should not happen. So it's not reliable.
But what's worse is that when something is selected inside a textarea (or any other input field), window.getSelection().getRangeAt(0) yields either null or a collapsed range that has nothing to do with the textarea.

In short, as far as I know it's not possible to know the visual boundaries of a selection inside a textarea. Not without some unacceptable approximations.

from share-this.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.