SlickGrid icon indicating copy to clipboard operation
SlickGrid copied to clipboard

Safari 6.0.2 support

Open mplorentz opened this issue 12 years ago • 19 comments

It appears that the excel copy and paste does not work in Safari 6.0.2.

mplorentz avatar Nov 29 '12 02:11 mplorentz

Yes it should work with command + C/V. My code captures the native clipboard events and then does a few hacks in order to send them to slickgrid. Verify you don't capture these events anywhere else in your program.

Could you tell me if this online demo works for you http://labs.nereo.fr/SlickGrid/examples/example-excel-compatible-spreadsheet.html ?

Celebio avatar Nov 29 '12 08:11 Celebio

ommand +C/V in the demo works for me on a MacBook Air

gibito avatar Nov 29 '12 09:11 gibito

Hmm, its the demo that's not working for me. I tried it in Safari, Chrome, and Firefox. I've got a Macbook running Mountain Lion (10.8.2).

I've tried to copy and paste to and from TextEdit, within one of the grids on the demo page, and between the grids on the demo page. The cells turn blue when I copy them, and when I paste the Edit menu item on the menubar flashes blue like it pasted, but the grid does not change. If I paste into TextEdit I just get what was previously on my clipboard.

mplorentz avatar Nov 29 '12 15:11 mplorentz

Ok, now it works for me in Chrome and Firefox, so... Safari issue? I'm running 6.0.2. What are you running @gibito? (I updated the issue title to reflect)

mplorentz avatar Dec 12 '12 16:12 mplorentz

I checked (I use chrome on air) and there is a problem with Safari on my machine too.

gibito avatar Dec 12 '12 16:12 gibito

I confirm the safari bug, I will have a look when possible.

Celebio avatar Dec 12 '12 16:12 Celebio

Looks like this isn't working on Safari 7.0. http://labs.nereo.com/SlickGrid/examples/example-excel-compatible-spreadsheet.html isn't working either.

dmccraw avatar Oct 31 '13 17:10 dmccraw

Yes. I investigated it a litte bit earlier. The hack seems not working with safari because the textarea selection is not "seen" by the native clipboard copy handler. We can use the official onPaste handler but an editable (ie editMode on) element has to have focus and I didn't manage to get that because the "canvas" div from slickgrid core needs to be changed.

If someone finds another way to do it, that would be great, otherwise we need to modify slickgrid core code.

Celebio avatar Oct 31 '13 18:10 Celebio

Yeah I've spent a few hours on it myself without making any progress.

mplorentz avatar Nov 01 '13 14:11 mplorentz

Gents,

Just to 'poke' at this issue..it'd be nice to get this working in Safari. I'm more interested in the copy feature.

I've confirmed that 'copy' from Safari 6.1.4 (8537.76.4) to an external target does not work.

A couple interesting notes:

  1. If Safari handles the Command-C, the "Edit" menu blinks; otherwise, Safari induces a system beep. Command-C on a grid selection issues this beep.
  2. If I hold on to Command-C for a second or so, the contents eventually gets copied, so the text area focus does seem working..there appears to be a timing issue unique to Safari?

@Celebio If I were to try to get this working, what changes need I make to the slickgrid core? Could you give some pointers?

Thanks! Owen

forbearer avatar Aug 28 '14 12:08 forbearer

That's really interesting that holding command-C eventually executes the copy, you might try pursuing that. I have sunk quite a few hours into trying to fix this issue with no progress. The fact is that it's a security vulnerability to be able to change what the user thinks they are copying to the clipboard, and Safari does a good job of making sure that doesn't happen. I wish I could give you some more pointers of things to try, but I've tried all the hacks I can think of.

On Aug 28, 2014, at 8:26 AM, Owen Cheng [email protected] wrote:

Gents,

Just to 'poke' at this issue..it'd be nice to get this working in Safari. I'm more interested in the copy feature.

I've confirmed that 'copy' from Safari 6.1.4 (8537.76.4) to an external target does not work.

A couple interesting notes:

  1. If Safari handles the Command-C, the "Edit" menu blinks; otherwise, Safari induces a system beep. Command-C on a grid selection issues this beep.
  2. If I hold on to Command-C for a second or so, the contents eventually gets copied, so the text area focus does seem working..there appears to be a timing issue unique to Safari?

@Celebio If I were to try to get this working, what changes need I make to the slickgrid core? Could you give some pointers?

Thanks! Owen

— Reply to this email directly or view it on GitHub.

mplorentz avatar Aug 29 '14 01:08 mplorentz

As far as I remember the only way to make it work with Safari was a hack with contenteditable = true for the top level item. That's what I saw here.

However, @rb-cohen seems to have a solution that would not affect any core item of the grid. I let you see with him if you can go further.

Another possibility is to reverse engineer that awesome grid which seems to work with Safari.

Celebio avatar Sep 02 '14 22:09 Celebio

I didn't have much luck with setting contenteditable=true on the $focusSink div in Safari 5/6, but as soon as it was a textarea, the beeps stopped and I could copy/paste using the alt menus and keyboard shortcuts.

The only trouble is I couldn't find a way to get/change this $focusSink element without a change to core.

rb-cohen avatar Sep 03 '14 08:09 rb-cohen

https://github.com/mleibman/SlickGrid/issues/1000 $focusSink as textarea (has a nice commit/pull request)

6pac avatar Sep 03 '14 09:09 6pac

@rb-cohen, can I see your modifications? By changing $focusSink to a textarea, safari is happy for pasting but not for copying. What other modifications did you to make copy work?

Celebio avatar Sep 03 '14 12:09 Celebio

Sorry, I got a bit ahead of myself.. copy is not working at the moment, only paste.

I'll have another play, in Google Drive it works so it must be possible natively.

rb-cohen avatar Sep 03 '14 13:09 rb-cohen

I'm getting closer, with some tweaks I can copy in Safari with Ctrl/Cmd+C and from the context menus, but Firefox will only copy grid content using Ctrl+C. Edit>Copy in FF returns the value of $focusSink..

I bound a focus handler to $focusSink, which always populated the textarea with some dummy content and selected it. That way Safari will accept attempts to copy, and you can listen for "oncopy".

The bind ( in slick.grid.js, although this could happen in the plugin if we implement grid.getFocusSinks() ):

$focusSink.bind('focus', function() {
  var $this = $(this);
  $this.val('Please use Ctrl+C to copy content from the grid');
  $this.get(0).select();
 });

Clone the events for the second sink (still in slick.grid.js at the moment):

 $focusSink2 = $focusSink.clone(true).appendTo($container);

Oncopy event (witin the copy/paste plugin), where doCopy is the same code executed on Ctrl+C:

$focusSink.bind('copy', function() {
  return doCopy();
});

I'll try to consolidate this all in to a pull request, at the moment my working Slick Grid/CopyPaste files are a little outdated and contain a few patches.

rb-cohen avatar Sep 04 '14 12:09 rb-cohen

good news !

Celebio avatar Sep 04 '14 12:09 Celebio

i'd like to integrate this into my fork. Is there any progress on this one? Can you perhaps just point me to a bunch of commits on your own fork ?

6pac avatar Jun 04 '15 23:06 6pac