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 event is dispatched multiple times when multiple EditorJS are launched. #1011

Closed
hata6502 opened this issue Jan 15, 2020 · 16 comments
Closed

Comments

@hata6502
Copy link
Contributor

I'll write more detail soon. 😃

@hata6502
Copy link
Contributor Author

hata6502 commented Jan 21, 2020

When launched two EditorJS in same page:

スクリーンショット 2020-01-21 18 17 20

(example-dev.html)

Paste event is dispatched multiple times when multiple EditorJS are launched:

スクリーンショット 2020-01-21 18 19 12

@gkshi
Copy link

gkshi commented Jan 21, 2020

I have the same problem. It may be related with the last update. I haven't get this bug before v2.16.1.

More details:
There are two editors on the page with unique holder options (every holder value matches to div with the same id value).

ezgif-2-a934ec589a18

@DDroll
Copy link

DDroll commented Jan 23, 2020

Confirm and rolled back to previous version (npm install @editorjs/editorjs@2.15.1 --save), it solves problem)

@gkshi
Copy link

gkshi commented Jan 28, 2020

I've tried to return to v2.15.1 and It works fine, no double paste behavior on the page.
But it isn't a solution. Previous version has other critical bugs with inline toolbar and text selection.

@ponnex
Copy link
Contributor

ponnex commented Jan 30, 2020

Experienced the same hope this issue will be fixed soon 👍

@ponnex
Copy link
Contributor

ponnex commented Jan 30, 2020

From what I've observed it will pasted multiple times based on how many instances of editorjs there is

@ponnex
Copy link
Contributor

ponnex commented Jan 31, 2020

For the meantime I've published an editorjs with the assumed "fix" on the paste issue -> @ponnex/editorjs will delete this one when the pull request is accepted or when a fix is already available

@tasuku-s
Copy link
Contributor

thanks to @ponnex, I could write this workarround.
I apply this until the PR is merged.

class PatchedEditor extends EditorJS {
  constructor(configuration?: EditorConfig|string) {
    super(configuration);
  }

  public exportAPI(editor: any) {
    super['exportAPI'](editor);
    const Paste = editor.moduleInstances.Paste;
    const onPastes = Paste.Editor.Listeners.findAll(document, 'paste');
    Paste.Editor.Listeners.allListeners = (Paste.Editor.Listeners.allListeners as []).filter(l => !onPastes.includes(l));
    onPastes.forEach(paste => paste.element.removeEventListener(paste.eventType, paste.handler, paste.options));
    Paste.Editor.Listeners.on(Paste.Editor.UI.nodes.holder, 'paste', Paste.handlePasteEvent);
  }
}

@hata6502 hata6502 closed this as completed Mar 4, 2020
@ponnex
Copy link
Contributor

ponnex commented Mar 16, 2020

Hi all! 2.17 is already released with this I will be deleting @ponnex/editorjs, those that are using the package kindly move to @editorjs/editorjs@2.17

@akash1201
Copy link

akash1201 commented Sep 14, 2023

I'm still facing the issue, I'm on V2.26.5

image

Update:- There are two instance of editor.js running in the page, hence it's being pasted twice. So I'm suspecting this maybe the issue. Any solution for the same?

@akash1201
Copy link

Hi All,
The issue was resolved, I just changed the holder of one editor instance, that sort of did the trick.

Thanks.

@sergey-yarchuk-4ib
Copy link

Hi All, The issue was resolved, I just changed the holder of one editor instance, that sort of did the trick.

Thanks.

Hi, can you write what exactly you did?

@akash1201
Copy link

Hi,

Earlier I was using two instance of editor.js.

<div id="editorjs"></div> // for title
<div id="editorjs"></div> //for body

It caused the above mentioned issue.

Then I changed it to

<div id="editorjs-title"></div> //title
<div id="editorjs"></div> //body

This solved the issue.

@sergey-yarchuk-4ib
Copy link

Hi,

Earlier I was using two instance of editor.js.

<div id="editorjs"></div> // for title
<div id="editorjs"></div> //for body

It caused the above mentioned issue.

Then I changed it to

<div id="editorjs-title"></div> //title
<div id="editorjs"></div> //body

This solved the issue.

thx for answer.

@akash1201
Copy link

Hi,
Earlier I was using two instance of editor.js.

<div id="editorjs"></div> // for title
<div id="editorjs"></div> //for body

It caused the above mentioned issue.
Then I changed it to

<div id="editorjs-title"></div> //title
<div id="editorjs"></div> //body

This solved the issue.

thx for answer.

Please let me know if that solved your issue or you're facing a different issue.

@sergey-yarchuk-4ib
Copy link

Please let me know if that solved your issue or you're facing a different issue.

Unfortunately, it didn't solve it. I think I have something different, thank you anyway.

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

7 participants