Copy/Paste functionality works correctly in Chrome and works poorly in Safari. I am running on Mac OS (Maverick). The code uses Handsontable 0.11.4 and ZeroClipboard plugin.
Operations that work in both browsers:
Copying and pasting inside the grid using context menu. Example:
- Highlight grid area with content, choose Copy from right-click menu, click on the destination cell and use Paste from the context menu.
Operations that use key combinations for cutting or copying and context menu for pasting. Example:
- Select grid area and use Cmd-C or Cmd-X, then choose a destination cell and use Paste from the context menu.
Operations that work in Chrome but not in Safari
- Copying/pasting among the grid cells whenever Cmd-P is used. That is, in Safari (unlike in Chrome) you cannot paste selection copied from the grid back into some grid area using a Cmd-P key shortcut.
- Copying from another program (like Excel or Sublime) into the grid. It works fine in Chrome (using either Cmd-P or Paste menu option) and does not work in Safari at all. You cannot copy from an outside program into Handsontable when running in Safari.
Debugging this issue proves tricky since when I set breakpoints in some code sections, the act of breaking prevents the "paste" functionality from working even in Chrome. There is something about the timing of the operations which makes the code hard to debug. One observation I made is that in the function (line 6938)
CopyPasteClass.prototype.triggerPaste = function (event, str) {
var that = this;
if (that.pasteCallbacks) {
setTimeout(function () {
var val = (str || that.elTextarea.value).replace(/\n$/, ''); //remove trailing newline
for (var i = 0, ilen = that.pasteCallbacks.length; i < ilen; i++) {
that.pasteCallbacks[i](val, event);
}
}, 50);
}
};
the value of that.elTextarea.value
is correct in Chrome when I use Cmd-P to paste and empty in Safari. Likewise, it is correct in Chrome when I paste from Excel and empty in Safari when I do the same.
The problem of the table not working in Safari is not the issue per se. The issue is that on my company intranet (in the production environment) all the browsers (Chrome and Firefox in Windows) behave the way Safari does on the Mac. I cannot paste content copied from Excel or a text editor into the Handsontable grid. Nor can I paste using Ctrl-P, even when I paste from another area of the grid. Using Copy and Paste functions of the grid context menu work correctly.
What accounts for this difference in grid behavior among the browser?