-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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: Treat single-item lists as paragraphs #5354
Conversation
Personally, I don't find this to be the expected behavior. Even within Google Docs, when copying the single list item from one document to another, its list-iness is preserved. |
@@ -137,6 +141,7 @@ export default function rawHandler( { HTML, plainText = '', mode = 'AUTO', tagNa | |||
] ) ); | |||
|
|||
piece = deepFilterHTML( piece, [ | |||
singleItemListConverter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the "filter" was implemented in separate so the changes are isolated, but as we already have a listReducer filter would it make sense for singleItemListConverter to be part of the other filter?
Not related to this changes but we have 3 consecutive calls to deepFilterHTML, Should we just join them all? One has a comment specifying it should be the first but even if we join them all we can still have comment saying msListConverter should be the first filter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind moving it out of that particular deepFilterHTML
call, but differences in the document mean that the ms-word-online
integration test fails if the filter is placed in the same deepFilterHTML
call as listReducer
, …, inlineContentConverter
.
That said, I agree there's room to improve the overall efficiency in that bit of rawHandler
.
Not judging if this should be the right behavior or not, this seems to work fine. I wonder if for this behavior, interpreting simple item paste as plaintext would also not have some advantages. E.g: if I paste a single list item in an heading it would still be a heading. Maybe the list item you are pasting from has a more complex markup? |
The problem with this is losing rich-text formatting from the source.
Yes, I'm using Google Docs, which is a little idiosyncratic. |
I have to agree with @aduth that I'm personally expecting the current behaviour... Plus it's introducing quite a bit of complex, list-specific code. In my opinion this is a bit too much correcting. Pasting a list item into an existing list and it creating empty items should be fixed though. |
@aduth @iseulde @mcsf @jorgefilipecosta I think we need to revisit this a bit. I agree pasting a single item in an empty paragraph we can respect the source and create a list. But this behaviour makes it really hard to copy text and be able to paste it in a heading or list without messing things up and creating a separate block. Here's my proposal:
|
Tracked in #6555 to keep this closed PR clean. |
Description
When pasting content from rich-text sources, if the object being pasted is a single item from a list, treat it as a paragraph. That is, pasting the object will not result in a new List block with a single item, but rather a Paragraph block with the text content copied from the source.
How Has This Been Tested?
blocks/api/raw-handler
Types of changes
Enhancement. This is an opinionated optimization for something that has emerged as a common enough pattern.
Checklist: