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

Cut and Paste (CMD+X -> CMD+P) does not restore pasted custom block with it's data #954

Closed
natterstefan opened this issue Nov 22, 2019 · 5 comments

Comments

@natterstefan
Copy link
Contributor

Issue

In our app we have lot's of "Enrichments". They can have several different types (eg. image, audio, ...). Because of legacy reasons we cannot simply render a <img> or <audio> tag.

Nevertheless, I was able to register and add custom tools (with React support) for each enrichment type. BUT when one moves them with CMD+X and CMD+P they are added as a simple paragraph or when the block is detected without data.

FTR:

  • I am not sure if the pasteConfig is correct, as I render a div with some other elements inside. Not sure what's the correct pattern/tag then.
  • Not sure how to make sure onPaste receives existing data from the pasted block as well.

Expected outcome

I can copy and paste existing blocks with all it's data within the Editor container.

Example

An example codesandbox can be found here: https://codesandbox.io/s/epic-feynman-myinj.

Screen Capture on 2019-11-22 at 11-33-20

Environment

  • React: "react": "16.11.0"
  • Editorjs: "@editorjs/editorjs": "2.15.1"
@kinsleykajiva
Copy link

i am getting a number in the text object of theresult , if i copy and paste text it puts numbers as shown below :

{
    "time" : 1574519623180,
    "blocks" : [
        {
            "type" : "paragraph",
            "data" : {
                "text" : "2"
            }
        },
        {
            "type" : "paragraph",
            "data" : {
                "text" : "2"
            }
        }
    ],
    "version" : "2.15.1"
}

@neSpecc
Copy link
Member

neSpecc commented Dec 2, 2019

We can add special formatting to the copied text that will allow us to determine block types on pasting. But in this case, copying/pasting to the other regular text documents will contain unwanted extra symbols.

We will research this case and find a solution. Maybe this can be done by modifying the DataTransfer object by adding our own mime-type. Or we can provide options on how you want to copy selected fragment: as simple text or as Editorjs format.

@natterstefan
Copy link
Contributor Author

Hi @neSpecc, thanks for the feedback. If I came up with an idea, I'll let you know.

@neSpecc neSpecc added the viewed label Dec 9, 2019
@neSpecc
Copy link
Member

neSpecc commented Mar 14, 2020

Resolved by #1060
Released in 2.17.0

@neSpecc neSpecc closed this as completed Mar 14, 2020
@natterstefan
Copy link
Contributor Author

Awesome, so far I can confirm it works. Thank you @neSpecc.

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

No branches or pull requests

3 participants