Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Copying into a code block doesn't retain code block formatting. #1276

Closed
CharlesIrvineKC opened this issue Jul 4, 2017 · 1 comment
Closed

Comments

@CharlesIrvineKC
Copy link

CharlesIrvineKC commented Jul 4, 2017

Do you want to request a feature or report a bug?

Bug.

What is the current behavior?

It is not possible to paste a code snippet into a Draftjs code block. When you try, the text on the clipboard is copied into the editor, but the code block formatting is lost.

**If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. **

  1. From a code editor, copy some code into the clipboard.
  2. Go to https://draftjs.org/
  3. Click in the editor window.
  4. Click on "Code Block" in the toolbar.
  5. Try to paste the code on the clipboard into the editor code block.

What is the expected behavior?

The expectation is that the code copied from the text editor would be inserted into a Draftjs code block.

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js?

I'm using Chrome Version 59.0.3071.115 (Official Build) (64-bit) on MacOS version 10.12.5.

I'm new to Draft.js so I don't know if this was working previously.

facebook-github-bot pushed a commit that referenced this issue Sep 7, 2017
Summary:
Preserve block style when pasting plain text. That would allow pasting into code blocks and lists and applying respective styles to new blocks.
That should work for any type of block: code, list, quote, heading...

Probably related github issues:

  - #1276
  - #1219

Reviewed By: sophiebits

Differential Revision: D5786405

fbshipit-source-id: 3c6d074b0c3fe200761164ec6c5ccf1a82df5072
@sophiebits
Copy link
Contributor

e8d1011 should fix this!

midas19910709 added a commit to midas19910709/draft-js that referenced this issue Mar 30, 2022
Summary:
Preserve block style when pasting plain text. That would allow pasting into code blocks and lists and applying respective styles to new blocks.
That should work for any type of block: code, list, quote, heading...

Probably related github issues:

  - facebookarchive/draft-js#1276
  - facebookarchive/draft-js#1219

Reviewed By: sophiebits

Differential Revision: D5786405

fbshipit-source-id: 3c6d074b0c3fe200761164ec6c5ccf1a82df5072
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants