editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

Paste: new block is created instead of inline-pasting

Open sebastian-mckelvey opened this issue 3 years ago • 3 comments

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" }

sebastian-mckelvey avatar Sep 20 '22 17:09 sebastian-mckelvey

+1

kevingilbert100 avatar Nov 01 '22 18:11 kevingilbert100

+1

zolotykh avatar Apr 20 '23 08:04 zolotykh

+1

AndreasFaust avatar May 23 '23 00:05 AndreasFaust