sanity icon indicating copy to clipboard operation
sanity copied to clipboard

White spaces not preserved when pasting text into Sanity editor

Open petervukovic opened this issue 2 years ago • 4 comments

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.

petervukovic avatar Apr 08 '22 14:04 petervukovic

facing the same problem

TanvirXen avatar Jun 07 '22 14:06 TanvirXen

facing the same problem as well

Jayprecode avatar Jul 14 '22 02:07 Jayprecode

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.

sarahbrodwall avatar Nov 02 '22 10:11 sarahbrodwall