Skip to content

Commit

Permalink
[se] Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
GoshaZotov committed Dec 9, 2024
1 parent 9002b0d commit 73803f6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions cell/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,9 @@ var editor;
}
};

spreadsheet_api.prototype.asc_CheckCopy = function (_clipboard /* CClipboardData */, _formats) {
return this.wb.checkCopyToClipboard(_clipboard, _formats);
spreadsheet_api.prototype.asc_CheckCopy = function (_clipboard /* CClipboardData */, _formats, callback) {
//callback - for async operation on copy to clipboard. for example - generate image blob
return this.wb.checkCopyToClipboard(_clipboard, _formats, callback);
};

spreadsheet_api.prototype.asc_SelectionCut = function () {
Expand Down
2 changes: 1 addition & 1 deletion cell/model/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
return this;
}

Clipboard.prototype.checkCopyToClipboard = function (ws, _clipboard, _formats) {
Clipboard.prototype.checkCopyToClipboard = function (ws, _clipboard, _formats, callback) {
var _data = null;
var wb = window["Asc"]["editor"].wb;

Expand Down
4 changes: 2 additions & 2 deletions cell/view/WorkbookView.js
Original file line number Diff line number Diff line change
Expand Up @@ -3218,12 +3218,12 @@
return g_clipboardExcel.bIsEmptyClipboard(this.getCellEditMode());
};

WorkbookView.prototype.checkCopyToClipboard = function (_clipboard, _formats) {
WorkbookView.prototype.checkCopyToClipboard = function (_clipboard, _formats, callback) {
if (this.isProtectedFromCut()) {
return false;
}
var ws = this.getWorksheet();
g_clipboardExcel.checkCopyToClipboard(ws, _clipboard, _formats);
g_clipboardExcel.checkCopyToClipboard(ws, _clipboard, _formats, callback);
};

WorkbookView.prototype.pasteData = function(_format, data1, data2, text_data, doNotShowButton, callback) {
Expand Down
14 changes: 9 additions & 5 deletions common/clipboard_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
Html : 2,
Internal : 4,
HtmlElement : 8,
Rtf : 16
Rtf : 16,
Image : 32
};
var c_oClipboardPastedFrom = {
Word : 0,
Expand Down Expand Up @@ -964,13 +965,16 @@
{
this.Api.asc_CheckCopy(copy_data, c_oAscClipboardDataFormat.Text | c_oAscClipboardDataFormat.Html | c_oAscClipboardDataFormat.Internal);

//change write order
//if push "image/png" last, data don't put in clipboard
//supports only "text/plain", "text/html", and "image/png" types
//"text/uri-list" not support
//https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/clipboard/clipboard_writer.cc;drc=e882b8e4a8272f65cb14c608d3d2bc4f0512aa20;l=304
//https://webkit.org/blog/10855/async-clipboard-api/
const data = [new ClipboardItem({
"text/plain" : new Blob([copy_data.data[c_oAscClipboardDataFormat.Text]], {type: "text/plain"}),
"text/html" : new Blob([copy_data.data[c_oAscClipboardDataFormat.Html]], {type: "text/html"}),
//"image/png" : window._blob,
"web text/x-custom" : new Blob(["asc_internalData2;" + copy_data.data[c_oAscClipboardDataFormat.Internal]], {type: "web text/x-custom"})
"image/png" : copy_data.data[c_oAscClipboardDataFormat.Image]
/*"web text/x-custom" : new Blob(["asc_internalData2;" + copy_data.data[c_oAscClipboardDataFormat.Internal]], {type: "web text/x-custom"})/*,//not support
*/
})];

navigator.clipboard.write(data).then(function(){},function(){});
Expand Down

0 comments on commit 73803f6

Please sign in to comment.