Fixes for image support

This commit is contained in:
Ludovic Dubost
2020-01-02 20:12:00 +01:00
parent 6155284c4d
commit d9fb248504
7 changed files with 250 additions and 64 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) Ascensio System SIA 2012-2019. All rights reserved
* Copyright (C) Ascensio System SIA 2012-2020. All rights reserved
*
* https://www.onlyoffice.com/
*
@@ -11208,7 +11208,7 @@ function isRealObject(obj)
if (window['IS_NATIVE_EDITOR'])
{
var stream = window["native"]["openFileCommand"](sFileUrl, changesUrl, Signature);
//получаем url к папке с файлом
var url;
var nIndex = sFileUrl.lastIndexOf("/");
@@ -11220,7 +11220,7 @@ function isRealObject(obj)
} else {
bError = true;
}
bEndLoadFile = true;
onEndOpen();
}
@@ -12108,6 +12108,10 @@ function isRealObject(obj)
function UploadImageFiles(files, documentId, documentUserId, jwt, callback)
{
// CryptPad: we need to take control of the upload
window.parent.APP.UploadImageFiles(files, documentId, documentUserId, jwt, callback);
return;
if (files.length > 0)
{
var url = sUploadServiceLocalUrl + '/' + documentId + '/' + documentUserId + '/' + g_oDocumentUrls.getMaxIndex();
@@ -15318,6 +15322,7 @@ window["AscDesktopEditor_Save"] = function()
window["AscDesktopEditor"]["OnSave"]();
}
};
/*
* (c) Copyright Ascensio System SIA 2010-2018
*
@@ -25857,9 +25862,32 @@ function (window, undefined)
baseEditorsApi.prototype._addImageUrl = function()
{
};
// CRYPTPAD
// This method is necessary to add the loaded images to the list of loaded images
// The code is in slide/api.js
baseEditorsApi.prototype.asc_addImageCallback = function(res)
{
};
baseEditorsApi.prototype.asc_addImage = function()
{
var t = this;
// CryptPad: we need to take control of the upload
// t.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
// This method calls back to the cryptpad onlyoffice inner.js to load the cryptad file dialog
window.parent.APP.AddImage(function(res) {
// This method adds the loaded image to the list of loaded images
t.asc_addImageCallback(res);
// This method activats the image
t._addImageUrl([res.url]);
// t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
}, function() {
// t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
t.sendEvent("asc_onError", error, c_oAscError.Level.NoCritical);
});
return;
// Cryptpad end
AscCommon.ShowImageFileDialog(this.documentId, this.documentUserId, this.CoAuthoringApi.get_jwt(), function(error, files)
{
t._uploadCallback(error, files);
@@ -31199,6 +31227,16 @@ var editor;
// ToDo заменить на общую функцию для всех
this.asc_addImage();
};
// CRYPTPAD
// This method is necessary to add the loaded images to the list of loaded images
spreadsheet_api.prototype.asc_addImageCallback = function(res)
{
g_oDocumentUrls.addImageUrl(res.name, res.url)
};
spreadsheet_api.prototype.asyncImageEndLoadedBackground = function(_image)
{
};
spreadsheet_api.prototype._addImageUrl = function(urls) {
var ws = this.wb.getWorksheet();
if (ws) {