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

Paste loses structure of first block element #4486

Closed
dylans opened this issue Sep 2, 2021 · 0 comments · Fixed by #4489
Closed

Paste loses structure of first block element #4486

dylans opened this issue Sep 2, 2021 · 0 comments · Fixed by #4489
Assignees
Labels

Comments

@dylans
Copy link
Collaborator

dylans commented Sep 2, 2021

Description

There's a long standing issue when pasting into a Slate document where the structure of the first element gets converted to plain text if only part of that first element was selected. It's very common for users to not capture the start of the tree intentionally or unintentionally.

I believe the reason this issue exists is to support the case of just selecting some text and wanting to just paste text rather than the full structure of the original.

The logic in https://github.com/ianstormtaylor/slate/blob/main/packages/slate/src/transforms/text.ts#L312-L320 is incorrect, or at least it is far too aggressive at treating that first element as text.

This is the underlying issue of many bugs, including but probably not limited to #3320, #4408, #3926, and possibly related to #3469, #4401.

We're having some discussion on whether this is something that belongs in the text transform where it currently lives, or if it should have been handled earlier in the fragment that gets passed in, e.g should we clean up the separation of concerns here or go with the least invasive change possible to get things working to fix various issues.

We're working on a PR which I hope to raise today or tomorrow.

Steps
To reproduce the behavior:

  1. Copy a slate tree without completely selecting the first element, where that first element is a heading, list item, etc.
  2. Paste it into the document
  3. First element pasted is now text inside a paragraph instead of its original structure

Expectation

Copy/paste of non-simple text should preserve the structure and formatting of what was copied/

Environment

  • Slate Version: 0.65.3
  • Operating System: all
  • Browser: all
  • TypeScript Version: all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant