From 73803f66330aced88a12ec0661cb406205f6c936 Mon Sep 17 00:00:00 2001 From: GoshaZotov Date: Mon, 9 Dec 2024 17:14:09 +0300 Subject: [PATCH] [se] Fix --- cell/api.js | 5 +++-- cell/model/clipboard.js | 2 +- cell/view/WorkbookView.js | 4 ++-- common/clipboard_base.js | 14 +++++++++----- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/cell/api.js b/cell/api.js index c09c6204e1..82123743e0 100644 --- a/cell/api.js +++ b/cell/api.js @@ -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 () { diff --git a/cell/model/clipboard.js b/cell/model/clipboard.js index 44f8d05a84..63656f7191 100644 --- a/cell/model/clipboard.js +++ b/cell/model/clipboard.js @@ -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; diff --git a/cell/view/WorkbookView.js b/cell/view/WorkbookView.js index e574795701..748c33d071 100644 --- a/cell/view/WorkbookView.js +++ b/cell/view/WorkbookView.js @@ -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) { diff --git a/common/clipboard_base.js b/common/clipboard_base.js index 6b54e062e6..8a0b628e54 100644 --- a/common/clipboard_base.js +++ b/common/clipboard_base.js @@ -55,7 +55,8 @@ Html : 2, Internal : 4, HtmlElement : 8, - Rtf : 16 + Rtf : 16, + Image : 32 }; var c_oClipboardPastedFrom = { Word : 0, @@ -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(){});