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

[Bug] Pasting list items doesn't format correctly and isn't seen by undo history #2142

Open
sebastian-mckelvey opened this issue Sep 20, 2022 · 3 comments
Labels

Comments

@sebastian-mckelvey
Copy link

sebastian-mckelvey commented Sep 20, 2022

I've run into some odd behavior around pasting items in a list. I'd love to get some insight if this is intentional, or perhaps a bug.

When copying a list item from a list block in the editor, the <li> element is copied to the clipboard. When pasting an <li> element, it triggers the creation of a new list block, regardless of the location of the caret. If the caret was placed in an existing list node, I would expect the pasted content to appear there.

In addition, if I've copied and pasted multiple list items from my clipboard, I would expect the first item to paste as text and fill the list node where the caret was placed, and the rest of the list items to be pasted as new list nodes.

Compared to other text editors/word processors these quirks did not present themselves. In an effort to rectify this, I started down the path of creating a new block tool which inherits the List class, and overriding the pasteHandler with custom logic that is aware of the caret's location.

There is also an issue in regards to undo. If I attempt to undo a pasted list, it won't work and will revert the steps made before pasting. Undo doesn't seem to "see" the list in the chain of user action history.

I've attached some GIFs and JSON below for a visual reference. The JSON shows items that have been pasted from a list created in Google Docs, which keeps any formatting intact (bold in this case).

Browsers: Firefox, Chrome, & Safari
@editorjs/editorjs: 2.25.0
@editorjs/list: 1.7.0

Expected Behavior

expected_behavior

Unexpected Behavior

odd_behavior

JSON

{ "time": 1663606028518, "blocks": [ { "id": "dSo3v4P9w3", "type": "list", "data": { "style": "ordered", "items": [ "test1", "test2", "test3", "<b>Test3ULGD</b><br>", "<b><b>Test3ULGD</b><br></b>", "<b><b><br></b></b>" ] } }, { "id": "yyGjDcyCFp", "type": "list", "data": { "style": "ordered", "items": [ "<b><b>Test3ULGD</b></b>" ] } }, { "id": "Ujzmbf6XIX", "type": "list", "data": { "style": "ordered", "items": [ "<b><b>Test3ULGD</b></b>" ] } } ], "version": "2.24.3" }

@kevingilbert100
Copy link

+1

2 similar comments
@zolotykh
Copy link

+1

@AndreasFaust
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants