|
|
@ -18,7 +18,6 @@ define([
|
|
|
|
'/common/outer/worker-channel.js',
|
|
|
|
'/common/outer/worker-channel.js',
|
|
|
|
|
|
|
|
|
|
|
|
'/bower_components/file-saver/FileSaver.min.js',
|
|
|
|
'/bower_components/file-saver/FileSaver.min.js',
|
|
|
|
'/common/sframe-common-file.js',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
|
|
|
|
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
|
|
|
|
'less!/bower_components/components-font-awesome/css/font-awesome.min.css',
|
|
|
|
'less!/bower_components/components-font-awesome/css/font-awesome.min.css',
|
|
|
@ -40,8 +39,7 @@ define([
|
|
|
|
EmptyCell,
|
|
|
|
EmptyCell,
|
|
|
|
EmptyDoc,
|
|
|
|
EmptyDoc,
|
|
|
|
EmptySlide,
|
|
|
|
EmptySlide,
|
|
|
|
Channel,
|
|
|
|
Channel)
|
|
|
|
SFCFile)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var saveAs = window.saveAs;
|
|
|
|
var saveAs = window.saveAs;
|
|
|
|
var Nacl = window.nacl;
|
|
|
|
var Nacl = window.nacl;
|
|
|
@ -56,7 +54,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var debug = function (x) {
|
|
|
|
var debug = function (x) {
|
|
|
|
if (!window.CP_DEV_MODE) { return; }
|
|
|
|
if (!window.CP_DEV_MODE) { return; }
|
|
|
|
console.log(x);
|
|
|
|
console.debug(x);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var stringify = function (obj) {
|
|
|
|
var stringify = function (obj) {
|
|
|
@ -89,11 +87,8 @@ define([
|
|
|
|
var mediasData = {};
|
|
|
|
var mediasData = {};
|
|
|
|
|
|
|
|
|
|
|
|
var getMediasSources = APP.getMediasSources = function() {
|
|
|
|
var getMediasSources = APP.getMediasSources = function() {
|
|
|
|
if (!content.mediasSources) {
|
|
|
|
return content.mediasSources = content.mediaSources || {};
|
|
|
|
content.mediasSources = {}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return content.mediasSources;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var getId = function () {
|
|
|
|
var getId = function () {
|
|
|
|
return metadataMgr.getNetfluxId() + '-' + privateData.clientId;
|
|
|
|
return metadataMgr.getNetfluxId() + '-' + privateData.clientId;
|
|
|
@ -242,8 +237,7 @@ define([
|
|
|
|
var editor = window.frames[0].editor;
|
|
|
|
var editor = window.frames[0].editor;
|
|
|
|
// if we are not in the sheet app
|
|
|
|
// if we are not in the sheet app
|
|
|
|
// we should not call this code
|
|
|
|
// we should not call this code
|
|
|
|
if (typeof editor.GetSheets === 'undefined')
|
|
|
|
if (typeof editor.GetSheets === 'undefined') { return; }
|
|
|
|
return;
|
|
|
|
|
|
|
|
var s = editor.GetSheets();
|
|
|
|
var s = editor.GetSheets();
|
|
|
|
if (s.length === 0) { return; }
|
|
|
|
if (s.length === 0) { return; }
|
|
|
|
var wb = s[0].worksheet.workbook;
|
|
|
|
var wb = s[0].worksheet.workbook;
|
|
|
@ -717,6 +711,7 @@ define([
|
|
|
|
'#panel-settings-general tr.autosave { display: none !important; }' +
|
|
|
|
'#panel-settings-general tr.autosave { display: none !important; }' +
|
|
|
|
'#panel-settings-general tr.coauth { display: none !important; }' +
|
|
|
|
'#panel-settings-general tr.coauth { display: none !important; }' +
|
|
|
|
'#header { display: none !important; }';
|
|
|
|
'#header { display: none !important; }';
|
|
|
|
|
|
|
|
// #asc-gen566 // XXX
|
|
|
|
// + '#id-toolbar-full-placeholder-btn-insertimage { display: none; }' +
|
|
|
|
// + '#id-toolbar-full-placeholder-btn-insertimage { display: none; }' +
|
|
|
|
// '#id-toolbar-full-placeholder-btn-insertequation { display: none; }';
|
|
|
|
// '#id-toolbar-full-placeholder-btn-insertequation { display: none; }';
|
|
|
|
$('<style>').text(css).appendTo($tb);
|
|
|
|
$('<style>').text(css).appendTo($tb);
|
|
|
@ -736,10 +731,9 @@ define([
|
|
|
|
common.initFilePicker({
|
|
|
|
common.initFilePicker({
|
|
|
|
onSelect: function (data) {
|
|
|
|
onSelect: function (data) {
|
|
|
|
if (data.type !== 'file') {
|
|
|
|
if (data.type !== 'file') {
|
|
|
|
console.log("Unexpected data type picked " + data.type);
|
|
|
|
debug("Unexpected data type picked " + data.type);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (data.type !== 'file') { console.log('unhandled embed type ' + data.type); return; }
|
|
|
|
|
|
|
|
var privateDat = cpNfInner.metadataMgr.getPrivateData();
|
|
|
|
var privateDat = cpNfInner.metadataMgr.getPrivateData();
|
|
|
|
var origin = privateDat.fileHost || privateDat.origin;
|
|
|
|
var origin = privateDat.fileHost || privateDat.origin;
|
|
|
|
var name = data.name;
|
|
|
|
var name = data.name;
|
|
|
@ -749,7 +743,7 @@ define([
|
|
|
|
mediasSources[name] = data;
|
|
|
|
mediasSources[name] = data;
|
|
|
|
|
|
|
|
|
|
|
|
APP.getImageURL(name, function(url) {
|
|
|
|
APP.getImageURL(name, function(url) {
|
|
|
|
console.log("CRYPTPAD success add " + name);
|
|
|
|
debug("CRYPTPAD success add " + name);
|
|
|
|
APP.AddImageSuccessCallback({
|
|
|
|
APP.AddImageSuccessCallback({
|
|
|
|
name: name,
|
|
|
|
name: name,
|
|
|
|
url: url
|
|
|
|
url: url
|
|
|
@ -765,50 +759,53 @@ define([
|
|
|
|
types: ['file'],
|
|
|
|
types: ['file'],
|
|
|
|
where: ['root']
|
|
|
|
where: ['root']
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
APP.getImageURL = function(name, callback) {
|
|
|
|
APP.getImageURL = function(name, callback) {
|
|
|
|
var mediasSources = getMediasSources();
|
|
|
|
var mediasSources = getMediasSources();
|
|
|
|
var data = mediasSources[name];
|
|
|
|
var data = mediasSources[name];
|
|
|
|
|
|
|
|
|
|
|
|
if (typeof data === 'undefined') {
|
|
|
|
if (typeof data === 'undefined') {
|
|
|
|
console.log("CryptPad - could not find matching media for " + name);
|
|
|
|
debug("CryptPad - could not find matching media for " + name);
|
|
|
|
callback("");
|
|
|
|
return void callback("");
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var blobUrl = (typeof mediasData[data.src] === 'undefined') ? "" : mediasData[data.src].src;
|
|
|
|
var blobUrl = (typeof mediasData[data.src] === 'undefined') ? "" : mediasData[data.src].src;
|
|
|
|
if (blobUrl != "") {
|
|
|
|
if (blobUrl) {
|
|
|
|
console.log("CryptPad Image already loaded " + blobUrl);
|
|
|
|
debug("CryptPad Image already loaded " + blobUrl);
|
|
|
|
callback(blobUrl);
|
|
|
|
return void callback(blobUrl);
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Util.fetch(data.src, function (err, u8) {
|
|
|
|
Util.fetch(data.src, function (err, u8) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
console.log("Decrypt with key " + data.key);
|
|
|
|
debug("Decrypt with key " + data.key);
|
|
|
|
FileCrypto.decrypt(u8, Nacl.util.decodeBase64(data.key), function (err, res) {
|
|
|
|
FileCrypto.decrypt(u8, Nacl.util.decodeBase64(data.key), function (err, res) {
|
|
|
|
if (err || !res.content) { console.log("Decrypting failed"); callback(""); }
|
|
|
|
if (err || !res.content) {
|
|
|
|
|
|
|
|
debug("Decrypting failed");
|
|
|
|
|
|
|
|
return void callback("");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var blobUrl = URL.createObjectURL(res.content);
|
|
|
|
var blobUrl = URL.createObjectURL(res.content);
|
|
|
|
// store media blobUrl and content for cache and export
|
|
|
|
// store media blobUrl and content for cache and export
|
|
|
|
var mediaData = { blobUrl : blobUrl, content : "" };
|
|
|
|
var mediaData = { blobUrl : blobUrl, content : "" };
|
|
|
|
mediasData[data.src] = mediaData;
|
|
|
|
mediasData[data.src] = mediaData;
|
|
|
|
var reader = new FileReader();
|
|
|
|
var reader = new FileReader();
|
|
|
|
reader.onloadend = (event) => {
|
|
|
|
reader.onloadend = function (event) {
|
|
|
|
console.log("MediaData set");
|
|
|
|
debug("MediaData set");
|
|
|
|
mediaData.content = reader.result;
|
|
|
|
mediaData.content = reader.result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reader.readAsArrayBuffer(res.content);
|
|
|
|
reader.readAsArrayBuffer(res.content);
|
|
|
|
console.log("Adding CryptPad Image " + data.name + ": " + blobUrl);
|
|
|
|
debug("Adding CryptPad Image " + data.name + ": " + blobUrl);
|
|
|
|
window.frames[0].AscCommon.g_oDocumentUrls.addImageUrl(data.name, blobUrl);
|
|
|
|
window.frames[0].AscCommon.g_oDocumentUrls.addImageUrl(data.name, blobUrl);
|
|
|
|
callback(blobUrl);
|
|
|
|
callback(blobUrl);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} catch(e) {
|
|
|
|
} catch (e) {
|
|
|
|
console.log("Exception decrypting image " + data.name);
|
|
|
|
debug("Exception decrypting image " + data.name);
|
|
|
|
|
|
|
|
console.error(e);
|
|
|
|
callback("");
|
|
|
|
callback("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
APP.docEditor = new window.DocsAPI.DocEditor("cp-app-oo-placeholder", APP.ooconfig);
|
|
|
|
APP.docEditor = new window.DocsAPI.DocEditor("cp-app-oo-placeholder", APP.ooconfig);
|
|
|
|
ooLoaded = true;
|
|
|
|
ooLoaded = true;
|
|
|
@ -829,12 +826,13 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var x2tInitialized = false;
|
|
|
|
var x2tInitialized = false;
|
|
|
|
var x2tInit = function(x2t) {
|
|
|
|
var x2tInit = function(x2t) {
|
|
|
|
console.log("x2t mount");
|
|
|
|
debug("x2t mount");
|
|
|
|
// x2t.FS.mount(x2t.MEMFS, {} , '/');
|
|
|
|
// x2t.FS.mount(x2t.MEMFS, {} , '/');
|
|
|
|
x2t.FS.mkdir('/working');
|
|
|
|
x2t.FS.mkdir('/working');
|
|
|
|
x2t.FS.mkdir('/working/media');
|
|
|
|
x2t.FS.mkdir('/working/media');
|
|
|
|
console.log("x2t mount done");
|
|
|
|
x2tInitialized = true;
|
|
|
|
}
|
|
|
|
debug("x2t mount done");
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
Converting Data
|
|
|
|
Converting Data
|
|
|
@ -844,7 +842,7 @@ define([
|
|
|
|
Example: fileName=cryptpad.bin outputFormat=xlsx
|
|
|
|
Example: fileName=cryptpad.bin outputFormat=xlsx
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
var x2tConvertDataInternal = function(x2t, data, fileName, outputFormat) {
|
|
|
|
var x2tConvertDataInternal = function(x2t, data, fileName, outputFormat) {
|
|
|
|
console.log("Converting Data for " + fileName + " to " + outputFormat);
|
|
|
|
debug("Converting Data for " + fileName + " to " + outputFormat);
|
|
|
|
// writing file to mounted working disk (in memory)
|
|
|
|
// writing file to mounted working disk (in memory)
|
|
|
|
x2t.FS.writeFile('/working/' + fileName, data);
|
|
|
|
x2t.FS.writeFile('/working/' + fileName, data);
|
|
|
|
|
|
|
|
|
|
|
@ -853,14 +851,14 @@ define([
|
|
|
|
var mediaFileName = mediaFileName.substring(6);
|
|
|
|
var mediaFileName = mediaFileName.substring(6);
|
|
|
|
var mediasSources = getMediasSources();
|
|
|
|
var mediasSources = getMediasSources();
|
|
|
|
var mediaSource = mediasSources[mediaFileName];
|
|
|
|
var mediaSource = mediasSources[mediaFileName];
|
|
|
|
var mediaData = (typeof mediaSource === 'undefined') ? mediaSource : mediasData[mediaSource.src];
|
|
|
|
var mediaData = mediaSource ? mediasData[mediaSource.src] : undefined;
|
|
|
|
if (typeof mediaData !== 'undefined') {
|
|
|
|
if (mediaData) {
|
|
|
|
console.log("Writing media data " + mediaFileName);
|
|
|
|
debug("Writing media data " + mediaFileName);
|
|
|
|
console.log("Data");
|
|
|
|
debug("Data");
|
|
|
|
var fileData = mediaData.content;
|
|
|
|
var fileData = mediaData.content;
|
|
|
|
x2t.FS.writeFile('/working/media/' + mediaFileName, new Uint8Array(fileData));
|
|
|
|
x2t.FS.writeFile('/working/media/' + mediaFileName, new Uint8Array(fileData));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
console.log("Could not find media content for " + mediaFileName);
|
|
|
|
debug("Could not find media content for " + mediaFileName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -869,7 +867,7 @@ define([
|
|
|
|
+ "<m_sFileFrom>/working/" + fileName + "</m_sFileFrom>"
|
|
|
|
+ "<m_sFileFrom>/working/" + fileName + "</m_sFileFrom>"
|
|
|
|
+ "<m_sFileTo>/working/" + fileName + "." + outputFormat + "</m_sFileTo>"
|
|
|
|
+ "<m_sFileTo>/working/" + fileName + "." + outputFormat + "</m_sFileTo>"
|
|
|
|
+ "<m_bIsNoBase64>false</m_bIsNoBase64>"
|
|
|
|
+ "<m_bIsNoBase64>false</m_bIsNoBase64>"
|
|
|
|
+ "</TaskQueueDataConvert>"
|
|
|
|
+ "</TaskQueueDataConvert>";
|
|
|
|
// writing params file to mounted working disk (in memory)
|
|
|
|
// writing params file to mounted working disk (in memory)
|
|
|
|
x2t.FS.writeFile('/working/params.xml', params);
|
|
|
|
x2t.FS.writeFile('/working/params.xml', params);
|
|
|
|
// running conversion
|
|
|
|
// running conversion
|
|
|
@ -878,19 +876,19 @@ define([
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
var result = x2t.FS.readFile('/working/' + fileName + "." + outputFormat);
|
|
|
|
var result = x2t.FS.readFile('/working/' + fileName + "." + outputFormat);
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
console.log("Failed reading converted file");
|
|
|
|
debug("Failed reading converted file");
|
|
|
|
return "";
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var x2tSaveAndConvertDataInternal = function(x2t, data, filename, extension, finalFilename) {
|
|
|
|
var x2tSaveAndConvertDataInternal = function(x2t, data, filename, extension, finalFilename) {
|
|
|
|
var xlsData = x2tConvertDataInternal(x2t, data, filename, extension);
|
|
|
|
var xlsData = x2tConvertDataInternal(x2t, data, filename, extension);
|
|
|
|
if (xlsData!="") {
|
|
|
|
if (xlsData) {
|
|
|
|
var blob = new Blob([xlsData], {type: "application/bin;charset=utf-8"});
|
|
|
|
var blob = new Blob([xlsData], {type: "application/bin;charset=utf-8"});
|
|
|
|
saveAs(blob, finalFilename);
|
|
|
|
saveAs(blob, finalFilename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var x2tSaveAndConvertData = function(data, filename, extension, finalFilename) {
|
|
|
|
var x2tSaveAndConvertData = function(data, filename, extension, finalFilename) {
|
|
|
|
// Perform the x2t conversion
|
|
|
|
// Perform the x2t conversion
|
|
|
@ -898,62 +896,61 @@ define([
|
|
|
|
var x2t = Module;
|
|
|
|
var x2t = Module;
|
|
|
|
x2t.run();
|
|
|
|
x2t.run();
|
|
|
|
if (x2tInitialized) {
|
|
|
|
if (x2tInitialized) {
|
|
|
|
console.log("x2t runtime already initialized");
|
|
|
|
debug("x2t runtime already initialized");
|
|
|
|
x2tSaveAndConvertDataInternal(x2t, data, filename, extension, finalFilename);
|
|
|
|
x2tSaveAndConvertDataInternal(x2t, data, filename, extension, finalFilename);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
x2t.onRuntimeInitialized = function() {
|
|
|
|
x2t.onRuntimeInitialized = function() {
|
|
|
|
console.log("x2t in runtime initialized");
|
|
|
|
debug("x2t in runtime initialized");
|
|
|
|
// Init x2t js module
|
|
|
|
// Init x2t js module
|
|
|
|
x2tInit(x2t);
|
|
|
|
x2tInit(x2t);
|
|
|
|
x2tInitialized = true;
|
|
|
|
|
|
|
|
x2tSaveAndConvertDataInternal(x2t, data, filename, extension, finalFilename);
|
|
|
|
x2tSaveAndConvertDataInternal(x2t, data, filename, extension, finalFilename);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var exportXLSXFile = function() {
|
|
|
|
var exportXLSXFile = function() {
|
|
|
|
var text = getContent();
|
|
|
|
var text = getContent();
|
|
|
|
var suggestion = Title.suggestTitle(Title.defaultTitle);
|
|
|
|
var suggestion = Title.suggestTitle(Title.defaultTitle);
|
|
|
|
var ext="xlsx";
|
|
|
|
var ext = "xlsx";
|
|
|
|
var type = common.getMetadataMgr().getPrivateData().ooType;
|
|
|
|
var type = common.getMetadataMgr().getPrivateData().ooType;
|
|
|
|
if (type==="ooslide")
|
|
|
|
if (type==="ooslide") {
|
|
|
|
ext = "pptx";
|
|
|
|
ext = "pptx";
|
|
|
|
else if (type==="oodoc")
|
|
|
|
} else if (type==="oodoc") {
|
|
|
|
ext = "docx";
|
|
|
|
ext = "docx";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UI.prompt(Messages.exportPrompt,
|
|
|
|
UI.prompt(Messages.exportPrompt, Util.fixFileName(suggestion) + '.' + ext, function (filename) {
|
|
|
|
Util.fixFileName(suggestion) + '.' + ext, function (filename) {
|
|
|
|
|
|
|
|
if (!(typeof(filename) === 'string' && filename)) { return; }
|
|
|
|
if (!(typeof(filename) === 'string' && filename)) { return; }
|
|
|
|
x2tSaveAndConvertData(text, "filename.bin", ext, filename);
|
|
|
|
x2tSaveAndConvertData(text, "filename.bin", ext, filename);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var x2tImportImagesInternal = function(x2t, images, i, callback) {
|
|
|
|
var x2tImportImagesInternal = function(x2t, images, i, callback) {
|
|
|
|
if (i>=images.length) {
|
|
|
|
if (i >= images.length) {
|
|
|
|
callback();
|
|
|
|
callback();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
console.log("Import image " + i);
|
|
|
|
debug("Import image " + i);
|
|
|
|
var handleFileData = {
|
|
|
|
var handleFileData = {
|
|
|
|
name: images[i],
|
|
|
|
name: images[i],
|
|
|
|
mediasSources: getMediasSources(),
|
|
|
|
mediasSources: getMediasSources(),
|
|
|
|
callback: function() {
|
|
|
|
callback: function() {
|
|
|
|
console.log("next image");
|
|
|
|
debug("next image");
|
|
|
|
x2tImportImagesInternal(x2t, images, i+1, callback);
|
|
|
|
x2tImportImagesInternal(x2t, images, i+1, callback);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var filePath = "/working/media/" + images[i];
|
|
|
|
var filePath = "/working/media/" + images[i];
|
|
|
|
console.log("Import filename " + filePath);
|
|
|
|
debug("Import filename " + filePath);
|
|
|
|
var fileData = x2t.FS.readFile("/working/media/" + images[i], { encoding : "binary" });
|
|
|
|
var fileData = x2t.FS.readFile("/working/media/" + images[i], { encoding : "binary" });
|
|
|
|
console.log("Importing data");
|
|
|
|
debug("Importing data");
|
|
|
|
console.log("Buffer");
|
|
|
|
debug("Buffer");
|
|
|
|
console.log(fileData.buffer);
|
|
|
|
debug(fileData.buffer);
|
|
|
|
var blob = new Blob([fileData.buffer], {type: 'image/png'});
|
|
|
|
var blob = new Blob([fileData.buffer], {type: 'image/png'});
|
|
|
|
blob.name = images[i];
|
|
|
|
blob.name = images[i];
|
|
|
|
APP.FMImages.handleFile(blob, handleFileData);
|
|
|
|
APP.FMImages.handleFile(blob, handleFileData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var x2tImportImages = function (x2t, callback) {
|
|
|
|
var x2tImportImages = function (x2t, callback) {
|
|
|
|
if (!APP.FMImages) {
|
|
|
|
if (!APP.FMImages) {
|
|
|
@ -963,14 +960,14 @@ define([
|
|
|
|
body: $('body'),
|
|
|
|
body: $('body'),
|
|
|
|
onUploaded: function (ev, data) {
|
|
|
|
onUploaded: function (ev, data) {
|
|
|
|
if (!ev.callback) { return; }
|
|
|
|
if (!ev.callback) { return; }
|
|
|
|
console.log("Image uploaded at " + data.url);
|
|
|
|
debug("Image uploaded at " + data.url);
|
|
|
|
var parsed = Hash.parsePadUrl(data.url);
|
|
|
|
var parsed = Hash.parsePadUrl(data.url);
|
|
|
|
if (parsed.type === 'file') {
|
|
|
|
if (parsed.type === 'file') {
|
|
|
|
var secret = Hash.getSecrets('file', parsed.hash, data.password);
|
|
|
|
var secret = Hash.getSecrets('file', parsed.hash, data.password);
|
|
|
|
var fileHost = privateData.fileHost || privateData.origin;
|
|
|
|
var fileHost = privateData.fileHost || privateData.origin;
|
|
|
|
var src = fileHost + Hash.getBlobPathFromHex(secret.channel);
|
|
|
|
var src = fileHost + Hash.getBlobPathFromHex(secret.channel);
|
|
|
|
var key = Hash.encodeBase64(secret.keys.cryptKey);
|
|
|
|
var key = Hash.encodeBase64(secret.keys.cryptKey);
|
|
|
|
console.log("Final src: " + src);
|
|
|
|
debug("Final src: " + src);
|
|
|
|
ev.mediasSources[ev.name] = { name : ev.name, src : src, key : key };
|
|
|
|
ev.mediasSources[ev.name] = { name : ev.name, src : src, key : key };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ev.callback();
|
|
|
|
ev.callback();
|
|
|
@ -980,61 +977,44 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Import Images
|
|
|
|
// Import Images
|
|
|
|
console.log("Import Images");
|
|
|
|
debug("Import Images");
|
|
|
|
var files = x2t.FS.readdir("/working/media/");
|
|
|
|
var files = x2t.FS.readdir("/working/media/");
|
|
|
|
var images = [];
|
|
|
|
var images = [];
|
|
|
|
files.forEach(file => {
|
|
|
|
files.forEach(function (file) {
|
|
|
|
if (file!="." && file!="..")
|
|
|
|
if (file !== "." && file !== "..") {
|
|
|
|
images.push(file);
|
|
|
|
images.push(file);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
x2tImportImagesInternal(x2t, images, 0, function() {
|
|
|
|
x2tImportImagesInternal(x2t, images, 0, function() {
|
|
|
|
console.log("Sync media sources elements");
|
|
|
|
debug("Sync media sources elements");
|
|
|
|
console.log(getMediasSources());
|
|
|
|
debug(getMediasSources());
|
|
|
|
APP.onLocal();
|
|
|
|
APP.onLocal();
|
|
|
|
console.log("Import Images finalized");
|
|
|
|
debug("Import Images finalized");
|
|
|
|
callback();
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var x2tConvertData = function (x2t, data, filename, extension, callback) {
|
|
|
|
var x2tConvertData = function (x2t, data, filename, extension, callback) {
|
|
|
|
var convertedContent;
|
|
|
|
var convertedContent;
|
|
|
|
|
|
|
|
// Convert from ODF format:
|
|
|
|
|
|
|
|
// first convert to Office format then to the selected extension
|
|
|
|
if (filename.endsWith(".ods")) {
|
|
|
|
if (filename.endsWith(".ods")) {
|
|
|
|
convertedContent = x2tConvertDataInternal(x2t, new Uint8Array(data), filename, "xlsx");
|
|
|
|
convertedContent = x2tConvertDataInternal(x2t, new Uint8Array(data), filename, "xlsx");
|
|
|
|
convertedContent = x2tConvertDataInternal(x2t, convertedContent, filename + ".xlsx", extension);
|
|
|
|
convertedContent = x2tConvertDataInternal(x2t, convertedContent, filename + ".xlsx", extension);
|
|
|
|
|
|
|
|
} else if (filename.endsWith(".odt")) {
|
|
|
|
|
|
|
|
convertedContent = x2tConvertDataInternal(x2t, new Uint8Array(data), filename, "docx");
|
|
|
|
|
|
|
|
convertedContent = x2tConvertDataInternal(x2t, convertedContent, filename + ".docx", extension);
|
|
|
|
|
|
|
|
} else if (filename.endsWith(".odp")) {
|
|
|
|
|
|
|
|
convertedContent = x2tConvertDataInternal(x2t, new Uint8Array(data), filename, "pptx");
|
|
|
|
|
|
|
|
convertedContent = x2tConvertDataInternal(x2t, convertedContent, filename + ".pptx", extension);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
convertedContent = x2tConvertDataInternal(x2t, new Uint8Array(data), filename, extension);
|
|
|
|
convertedContent = x2tConvertDataInternal(x2t, new Uint8Array(data), filename, extension);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
x2tImportImages(x2t, function() {
|
|
|
|
x2tImportImages(x2t, function() {
|
|
|
|
callback(convertedContent);
|
|
|
|
callback(convertedContent);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var importXLSXFile = function(content, filename) {
|
|
|
|
|
|
|
|
// Perform the x2t conversion
|
|
|
|
|
|
|
|
console.log("Filename");
|
|
|
|
|
|
|
|
console.log(filename);
|
|
|
|
|
|
|
|
require(['/common/onlyoffice/x2t/x2t.js'], function() {
|
|
|
|
|
|
|
|
var x2t = Module;
|
|
|
|
|
|
|
|
x2t.run();
|
|
|
|
|
|
|
|
if (x2tInitialized) {
|
|
|
|
|
|
|
|
console.log("x2t runtime already initialized");
|
|
|
|
|
|
|
|
x2tConvertData(x2t, new Uint8Array(content), filename.name, "bin", function(convertedContent) {
|
|
|
|
|
|
|
|
importFile(convertedContent);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
x2t.onRuntimeInitialized = function() {
|
|
|
|
|
|
|
|
console.log("x2t in runtime initialized");
|
|
|
|
|
|
|
|
// Init x2t js module
|
|
|
|
|
|
|
|
x2tInit(x2t);
|
|
|
|
|
|
|
|
x2tInitialized = true;
|
|
|
|
|
|
|
|
var convertedContent = x2tConvertData(x2t, new Uint8Array(content), filename.name, "bin", function(convertedContent) {
|
|
|
|
|
|
|
|
importFile(convertedContent);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var importFile = function(content) {
|
|
|
|
var importFile = function(content) {
|
|
|
|
// Abort if there is another real user in the channel (history keeper excluded)
|
|
|
|
// Abort if there is another real user in the channel (history keeper excluded)
|
|
|
@ -1044,7 +1024,7 @@ define([
|
|
|
|
if (m.length > 1) {
|
|
|
|
if (m.length > 1) {
|
|
|
|
return void UI.alert(Messages.oo_cantUpload);
|
|
|
|
return void UI.alert(Messages.oo_cantUpload);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (content=="") {
|
|
|
|
if (!content) {
|
|
|
|
return void UI.alert(Messages.oo_cantUpload);
|
|
|
|
return void UI.alert(Messages.oo_cantUpload);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var blob = new Blob([content], {type: 'plain/text'});
|
|
|
|
var blob = new Blob([content], {type: 'plain/text'});
|
|
|
@ -1067,9 +1047,30 @@ define([
|
|
|
|
APP.FM.handleFile(blob, data);
|
|
|
|
APP.FM.handleFile(blob, data);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var importXLSXFile = function(content, filename) {
|
|
|
|
|
|
|
|
// Perform the x2t conversion
|
|
|
|
|
|
|
|
debug("Filename");
|
|
|
|
|
|
|
|
debug(filename);
|
|
|
|
|
|
|
|
require(['/common/onlyoffice/x2t/x2t.js'], function() {
|
|
|
|
|
|
|
|
var x2t = Module;
|
|
|
|
|
|
|
|
x2t.run();
|
|
|
|
|
|
|
|
if (x2tInitialized) {
|
|
|
|
|
|
|
|
debug("x2t runtime already initialized");
|
|
|
|
|
|
|
|
x2tConvertData(x2t, new Uint8Array(content), filename.name, "bin", function(convertedContent) {
|
|
|
|
|
|
|
|
importFile(convertedContent);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
x2t.onRuntimeInitialized = function() {
|
|
|
|
|
|
|
|
debug("x2t in runtime initialized");
|
|
|
|
|
|
|
|
// Init x2t js module
|
|
|
|
|
|
|
|
x2tInit(x2t);
|
|
|
|
|
|
|
|
var convertedContent = x2tConvertData(x2t, new Uint8Array(content), filename.name, "bin", function(convertedContent) {
|
|
|
|
|
|
|
|
importFile(convertedContent);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var loadLastDocument = function () {
|
|
|
|
var loadLastDocument = function () {
|
|
|
|
var lastCp = getLastCp();
|
|
|
|
var lastCp = getLastCp();
|
|
|
@ -1139,7 +1140,7 @@ define([
|
|
|
|
JSON.parse(content);
|
|
|
|
JSON.parse(content);
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
console.log("Failed to parse, rejecting patch");
|
|
|
|
debug("Failed to parse, rejecting patch");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1151,7 +1152,7 @@ define([
|
|
|
|
window.frames[0].editor.setViewModeDisconnect(true);
|
|
|
|
window.frames[0].editor.setViewModeDisconnect(true);
|
|
|
|
} catch (e) {}
|
|
|
|
} catch (e) {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(state);
|
|
|
|
debug(state);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var stringifyInner = function () {
|
|
|
|
var stringifyInner = function () {
|
|
|
|