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

Cannot store and display whitespace #311

Open
emaciel10 opened this issue Jan 2, 2018 · 6 comments
Open

Cannot store and display whitespace #311

emaciel10 opened this issue Jan 2, 2018 · 6 comments

Comments

@emaciel10
Copy link

I noticed a strange bug when attempting to save and re-render html from quill. I am using React Quill v1.2.3

Right now it is impossible to store and display a string with more than one tab or space in a row.
Here is a link to a comment from LDFM who also experienced this same problem:
slab/quill#1751 (comment)
LFDM pointed out that the line that is causing this issue is:
https://github.com/zenoamaro/react-quill/blob/master/src/mixin.js#L68

Since dangerouslyPasteHTML is called, the whitespace get's collapsed down to a single space but jhchen's comment towards the end of that same issue linked above seems to point to a solution.
slab/quill#1751 (comment)

Thanks for your help!

@alexkrolick
Copy link
Collaborator

We'd take a PR to add a preserveWhitespace (or similar) option - it sounds like creating a pre tag around or instead of the container div would cause the paste to not collapse spaces.

@twmilli
Copy link

twmilli commented Apr 25, 2018

Are there any updates or workarounds for this issue?

@roelzkie15
Copy link

Still no update regarding this issue?

@948198676
Copy link

Still no update regarding this issue?

@murtyjones
Copy link

murtyjones commented Aug 27, 2018

Anyone have a workaround here?

Tried to add <pre> around all tab instances using react-quill's onChange handler, but it continually is replace by <p>.

@murtyjones
Copy link

murtyjones commented Aug 28, 2018

In my case, I managed to make it work by doing this:

        <ReactQuill
          ...
          defaultValue={ this.state.value }
          onChange={ v => {
            // replace tabs with spaces
            this.handleChange(
              v.replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;')
            )
          } }
        />

Note the use of defaultValue instead of value.

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

No branches or pull requests

6 participants