GithubHelp home page GithubHelp logo

phuocng / mirror-a-text-area Goto Github PK

View Code? Open in Web Editor NEW
50.0 3.0 4.0 8.84 MB

Enhancing user experience through text area mirroring

Home Page: https://phuoc.ng/collection/mirror-a-text-area/

License: MIT License

HTML 100.00%
dom-manipulation javascript

mirror-a-text-area's Issues

Empty lines at the bottom of the scrolled area break the mirroring

(Hi. Thank you for putting all these interesting articles together.)
I believe there's an issue with the mirroring from the first article, and this issue find its way in the next parts as well.
Although you're setting the scrollTop of the mirrored div to the scrollTop of the textarea on scroll, it's still going out of sync for some reasons once one or more empty new lines are entered at the bottom of the textarea.
Here's a screenshot of the issue:
image
I just typed a few more "you\n\n"s so that the area gets a scrollbar, and then I scrolled up a bit.
I don't know why this is happening yet, but it's obviously not expected.
I've encountered and reproduced this in my own code too, when I was trying your first article (just doing the mirroring). I just used a red color (any color other than transparent works as well) instead of transparent, and it's in sync on scroll, however, as soon as I entered a newline at the last line, it went out of sync.
image
image

How to add hover events to mirrored/highlighted div

I have a use case to show the suggestions inline upon hovering the highlighted word. I tried with higher z-index to mirrored/highlight div but it stopping me from inputting into text area itself. Any other way to add the mouse events to delegate to mirrored/highlight div so that we can show suggestions like grammarly extension ?

Example: when I hover on a mark tag/highlighted content it should me a suggestions like grammarly which adds card and user can select the suggestion, just like mention, for this we need to delegate the move events to mirrored div.

Displayed line numbers don't remain aligned with their corresponding text on mobile

These are screenshots of the issue:
photo1705526781_cr
photo1705526843_cr

I guess the root of this issue is related to the other issue I opened here: #11 Because this is again happening towards the end of the textarea. I.e., if I start from top and go towards the bottom, line numbers remain aligned for most of the path, however, as soon as it gets to the last lines, the line numbers don't move up with the scrolled lines anymore (which is in my opinion, very similar to what happened in the last issue I opened.)

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.