Copy/Paste not working on Custom Editor?

Tags: #<Tag:0x00007f0b038a3558>

Hello,

Currently, we are working on the implementation of multi-select cells on our Handsontable-based product. In order to do so, we tried several custom components already developed by the community such as https://github.com/orestisrodriguez/handsontable-multi-select ( not working as well as we expected ) therefore we switched to https://github.com/mydea/handsontable-chosen-editor.

However, in both of these components, we encoutered the same bug : The copy/paste function is not working for Handsontable ( v7.0.0+ ). After further analysis and research, the root of the main problem could be that the implementation of the custom editor could be wrong for the newest version of the CopyPaste plugin ( for instance here https://github.com/mydea/handsontable-chosen-editor/blob/master/handsontable-chosen-editor.js#L26. )

Can someone please help us figure out why the CopyPaste plugin of Handsontable is not working in this particular case ?

Edit: Even the beforeCopy event is not triggerred in this scenario.

Hi @nicolas.lehalper,

Our CopyPaste bases on the native ClipboardEvents. Under the hood, we create or keep actively selected HTMLTextAreaElement element that has to be focused (be an document.activeElement) with selected text inside. That trick allows preventing default actions for copy/paste/cut.

Though, in these custom editors, I see that authors extends TextEditor, which has TEXTAREA property. It’s something, that we internally use to determine if we need to create secondaryElement for CopyPaste (you can find that fragment here: https://github.com/handsontable/handsontable/blob/f9420a22e272df9cf37d54abb75bdb47db1149e0/src/plugins/copyPaste/copyPaste.js#L364-L373).

What I can suggest, is to move one of these packages you mentioned into your project, but replace parent class to Handsontable.editors.SelectEditor (or even use BaseEditor) to rid of all unnecessary things from the prototype.

Thanks for your feedback and your assist @piotr.laszczkowski. I am going to try this approach this week. I’ll keep you in touch.
Regards

Hi @nicolas.lehalper

do we have any updates here?

Sorry I was on holidays. We decided to postponed this development for now ( deadlines … ). Anyway, @piotr.laszczkowski gave me the perfect lead to resolve it so I think we can close this discussion for now. Thanks both of you for your assistance. :slight_smile:

Oh… I hope that you had great vacation :slight_smile:
and I’m glad that the feedback was helpful.

If you’d need anything you can directly reach us at support@handsontable.com