Coder Social home page Coder Social logo

Comments (5)

gscottolson avatar gscottolson commented on April 20, 2024

I should also add…

Killer work on this project, team. I have been exploring contentEditable-n-React solutions for a few weeks now. This project is a huge leap forward. Thanks for sharing it!

from draft-js.

hellendag avatar hellendag commented on April 20, 2024

Thanks @gscottolson!

I think the problem here is that the SelectionState is wrapping into the next line, and probably looks something like:

SelectionState {
  anchorKey: 'a',
  anchorOffset: 0,
  focusKey: 'b',
  focusOffset: 0,
  ...
}

One option would be to change getDraftEditorSelectionWithNodes to be more aware of this possibility and normalize the DOM selection to a SelectionState that just includes block a. Another would be to make block-type and inline-style changes not apply to the second block, within modifier code.

I'm thinking the first option might be a little cleaner, though it means that there would be no state distinction between selecting an entire line of text and selection the text plus the newline. Given that we pretty much ignore the newline as content, though, that might be fine.

What do you think?

from draft-js.

gscottolson avatar gscottolson commented on April 20, 2024

I think the first solution seems reasonable. Thanks for the quick reply.

FWIW, Facebook Notes does not exhibit this behavior. How is this selection case handled in that product?

Edit: You are right about Notes.

from draft-js.

hellendag avatar hellendag commented on April 20, 2024

Looks like Notes does have this problem. :)

from draft-js.

gscottolson avatar gscottolson commented on April 20, 2024

Excellent. Thanks for the quick fix! 🎩

from draft-js.

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.