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

Carriage Return on copy behavior reverted #3801

Closed
mikeyoon opened this Issue Oct 5, 2016 · 8 comments

Comments

@mikeyoon
Copy link

mikeyoon commented Oct 5, 2016

Description

If you copy a single cell, a carriage return is added. There was a PR #1621 to remove that, but at some point that change was reverted. Is this intended?

Steps to reproduce

  1. Copy a single cell to a text editor

Your environment

  • Version: 0.23.0
  • Browser Name and version: Chrome 53
  • Operating System: Mac OS X Sierra
@AMBudnik

This comment has been minimized.

Copy link
Contributor

AMBudnik commented Oct 6, 2016

Hi @mikeyoon
I've tested 0.16.0, 0.23.0 and newest 0.28.3 (on Mac and Win10) and if I paste some content in a cell with closed editor I won't get a carriage and if the cell is is the edit mode the carriage will appear.
However I think that I may misunderstood the following case. Can you share w .gif of the action you took? (or a set of key codes)

@mikeyoon

This comment has been minimized.

Copy link
Author

mikeyoon commented Oct 6, 2016

Ah, seems I was missing a lot of details. The issue happens if you copy and paste from a cell into a text editor. Here's a gif of what I'm talking about.

copy-paste

I'm selecting a cell, not double clicking it, and then Cmd-C and Cmd-V in the text editor.

@AMBudnik

This comment has been minimized.

Copy link
Contributor

AMBudnik commented Oct 7, 2016

Aah I see. Thanks for a gif @mikeyoon
I got the same result. Thanks for sharing.

@jromero-onclick

This comment has been minimized.

Copy link

jromero-onclick commented Nov 22, 2016

Any update about these behaviour? Thank you

@AMBudnik

This comment has been minimized.

Copy link
Contributor

AMBudnik commented Nov 23, 2016

Hi @jromero-onclick
unfortunately there's no update on this subject yet

@sp-andres-gutierrez

This comment has been minimized.

Copy link

sp-andres-gutierrez commented Dec 7, 2016

We're trying to hijack copy event from Hansontable this way we can remove that \n at the end of the copied text.

I'm not sure if it's a good idea. Please let me know what do you think

    /**
     * Handsond table is adding a carriage return at the end of the cells
     * We don't want that extra \n so we remove it.
     * Here a relevant issue: https://github.com/handsontable/handsontable/issues/3801
     */
    function onCopyEvent(event){
      var $textarea = $(event.target);
      var $parent = $textarea ? $textarea.parent() : null;
      var isHandsonTableText = $parent && $parent.attr('id') === 'CopyPasteDiv' ? true : false;

      var clipboard = event.clipboardData || event.originalEvent.clipboardData;

      if (!isHandsonTableText || !clipboard || !clipboard.setData) return;

      var copiedText = $textarea.val();

      var newText = copiedText.replace(/\n$/, '');

      // Write into clipboard
      clipboard.setData('text/plain', newText);

      // This is the key. We're not allowing
      // Handsondata to write into clipboard. They're adding
      // the content with \n at the end.
      event.preventDefault();
    };

    $($window.document).on('copy', onCopyEvent);
@AMBudnik

This comment has been minimized.

Copy link
Contributor

AMBudnik commented May 18, 2017

Hi @mikeyoon

I am happy to say that we have fixed the issue and the fix is available at v0.32.0-beta1. Does it work for you as well?

@AMBudnik

This comment has been minimized.

Copy link
Contributor

AMBudnik commented May 22, 2017

I am closing this issue as there are no other questions/bug reports or concerns but if someone has any please leave a comment. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.