sanity-io / sanity

Sanity Studio – Rapidly configure content workspaces powered by structured content
https://www.sanity.io
MIT License
5.33k stars 430 forks source link

White spaces not preserved when pasting text into Sanity editor #3240

Open petervukovic opened 2 years ago

petervukovic commented 2 years ago

Describe the bug

When you copy & paste a piece of plain text that contains multiple spaces and indents, the spaces aren't preserved.

To Reproduce

  1. Set up a Sanity schema for a blog based on any example
  2. Create a new post
  3. Copy & paste the following text:
Line breaks
   and        spaces
      should be preserved

Expected behavior

Line breaks and spaces should be preserved as in the above example.

Actual behavior

While line breaks get preserved, all extraneous spaces are removed, resulting in this output:

Line breaks
and spaces
should be preserved

Which versions of Sanity are you using?

@sanity/cli                   2.29.5 (up to date)
@sanity/base                  2.29.5 (up to date)
@sanity/core                  2.29.5 (up to date)
@sanity/default-layout        2.29.5 (up to date)
@sanity/default-login         2.29.5 (up to date)
@sanity/desk-tool             2.29.5 (up to date)
@sanity/eslint-config-studio   2.0.0 (up to date)
@sanity/production-preview    2.29.3 (up to date)
@sanity/vision                2.29.5 (up to date)

What operating system are you using?

OSX Catalina 10.15.7

Which versions of Node.js / npm are you running?

Run npm -v && node -v in the terminal and copy-paste the result here.

8.1.0
v17.0.1

Additional context

I discovered this problem while building a custom style block for preformatted text. My intention was to support copying/pasting plain text snippets (such as ASCII art or code) into the text editor in order to display them on the blog. Unfortunately, this is impossible due to the way the text editor behaves today, and building a custom paste handler for this seems like overkill.

TanvirXen commented 2 years ago

facing the same problem

Jayprecode commented 2 years ago

facing the same problem as well

sarahbrodwall commented 2 years ago

Any progress on this? Even sitting on a wired fiber connection, I get disconnected from Sanity so often that I feel like I have to compose in Word. Then when I paste in my content, I have to go back and add spaces. Not cool.

jeffspurlock commented 2 months ago

almost 2 years later and i'm still having this too. I'm trying to use the <> code format on code blocks in block content, and none of the indentation comes through. There's gotta be solution for this.