Commit a4234ff0 authored by Oleg Korshul's avatar Oleg Korshul

новая схема работы с апи билдера

parent 0957160f
"use strict"; "use strict";
(function(window, undefined){ (function(window, undefined)
// Import {
var offlineMode = AscCommon.offlineMode; // Import
var c_oEditorId = AscCommon.c_oEditorId; var offlineMode = AscCommon.offlineMode;
var c_oEditorId = AscCommon.c_oEditorId;
var c_oAscError = Asc.c_oAscError; var c_oAscError = Asc.c_oAscError;
var c_oAscAsyncAction = Asc.c_oAscAsyncAction; var c_oAscAsyncAction = Asc.c_oAscAsyncAction;
var c_oAscAsyncActionType = Asc.c_oAscAsyncActionType; var c_oAscAsyncActionType = Asc.c_oAscAsyncActionType;
var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
/** @constructor */ /** @constructor */
function baseEditorsApi(config, editorId) { function baseEditorsApi(config, editorId)
{
this.editorId = editorId; this.editorId = editorId;
this.isLoadFullApi = false; this.isLoadFullApi = false;
this.openResult = null; this.openResult = null;
...@@ -116,41 +118,52 @@ function baseEditorsApi(config, editorId) { ...@@ -116,41 +118,52 @@ function baseEditorsApi(config, editorId) {
this.pluginsManager = null; this.pluginsManager = null;
return this; return this;
} }
baseEditorsApi.prototype._init = function() {
baseEditorsApi.prototype._init = function()
{
var t = this; var t = this;
//Asc.editor = Asc['editor'] = AscCommon['editor'] = AscCommon.editor = this; // ToDo сделать это! //Asc.editor = Asc['editor'] = AscCommon['editor'] = AscCommon.editor = this; // ToDo сделать это!
this.HtmlElement = document.getElementById(this.HtmlElementName); this.HtmlElement = document.getElementById(this.HtmlElementName);
// init OnMessage // init OnMessage
AscCommon.InitOnMessage(function(error, url) { AscCommon.InitOnMessage(function(error, url)
if (c_oAscError.ID.No !== error) { {
if (c_oAscError.ID.No !== error)
{
t.sendEvent("asc_onError", error, c_oAscError.Level.NoCritical); t.sendEvent("asc_onError", error, c_oAscError.Level.NoCritical);
} else { }
else
{
t._addImageUrl(url); t._addImageUrl(url);
} }
t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage); t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
}); });
// init drag&drop // init drag&drop
AscCommon.InitDragAndDrop(this.HtmlElement, function(error, files) { AscCommon.InitDragAndDrop(this.HtmlElement, function(error, files)
{
t._uploadCallback(error, files); t._uploadCallback(error, files);
}); });
AscCommon.loadSdk(this._editorNameById(), function() { AscCommon.loadSdk(this._editorNameById(), function()
{
t.isLoadFullApi = true; t.isLoadFullApi = true;
if (t.DocInfo && t.DocInfo.get_OfflineApp()) { if (t.DocInfo && t.DocInfo.get_OfflineApp())
{
t._OfflineAppDocumentStartLoad(); t._OfflineAppDocumentStartLoad();
} }
t._onEndLoadSdk(); t._onEndLoadSdk();
t.onEndLoadFile(null); t.onEndLoadFile(null);
}); });
}; };
baseEditorsApi.prototype._editorNameById = function() { baseEditorsApi.prototype._editorNameById = function()
{
var res = ''; var res = '';
switch (this.editorId) { switch (this.editorId)
{
case c_oEditorId.Word: case c_oEditorId.Word:
res = 'word'; res = 'word';
break; break;
...@@ -162,22 +175,28 @@ baseEditorsApi.prototype._editorNameById = function() { ...@@ -162,22 +175,28 @@ baseEditorsApi.prototype._editorNameById = function() {
break; break;
} }
return res; return res;
}; };
baseEditorsApi.prototype.getEditorId = function() { baseEditorsApi.prototype.getEditorId = function()
{
return this.editorId; return this.editorId;
}; };
baseEditorsApi.prototype.asc_GetFontThumbnailsPath = function() { baseEditorsApi.prototype.asc_GetFontThumbnailsPath = function()
{
return '../Common/Images/'; return '../Common/Images/';
}; };
baseEditorsApi.prototype.asc_getDocumentName = function() { baseEditorsApi.prototype.asc_getDocumentName = function()
{
return this.documentTitle; return this.documentTitle;
}; };
baseEditorsApi.prototype.asc_setDocInfo = function(oDocInfo) { baseEditorsApi.prototype.asc_setDocInfo = function(oDocInfo)
if (oDocInfo) { {
if (oDocInfo)
{
this.DocInfo = oDocInfo; this.DocInfo = oDocInfo;
} }
if (this.DocInfo) { if (this.DocInfo)
{
this.documentId = this.DocInfo.get_Id(); this.documentId = this.DocInfo.get_Id();
this.documentUserId = this.DocInfo.get_UserId(); this.documentUserId = this.DocInfo.get_UserId();
this.documentUrl = this.DocInfo.get_Url(); this.documentUrl = this.DocInfo.get_Url();
...@@ -196,89 +215,117 @@ baseEditorsApi.prototype.asc_setDocInfo = function(oDocInfo) { ...@@ -196,89 +215,117 @@ baseEditorsApi.prototype.asc_setDocInfo = function(oDocInfo) {
this.CoAuthoringApi.setDocId(this.documentId); this.CoAuthoringApi.setDocId(this.documentId);
} }
if (undefined !== window["AscDesktopEditor"] && offlineMode != this.documentUrl) { if (undefined !== window["AscDesktopEditor"] && offlineMode != this.documentUrl)
{
window["AscDesktopEditor"]["SetDocumentName"](this.documentTitle); window["AscDesktopEditor"]["SetDocumentName"](this.documentTitle);
} }
}; };
baseEditorsApi.prototype.asc_enableKeyEvents = function(isEnabled) { baseEditorsApi.prototype.asc_enableKeyEvents = function(isEnabled)
}; {
// Copy/Past/Cut };
baseEditorsApi.prototype.asc_IsFocus = function(bIsNaturalFocus) { // Copy/Past/Cut
}; baseEditorsApi.prototype.asc_IsFocus = function(bIsNaturalFocus)
// Просмотр PDF {
baseEditorsApi.prototype.isPdfViewer = function() { };
// Просмотр PDF
baseEditorsApi.prototype.isPdfViewer = function()
{
return false; return false;
}; };
// Events // Events
baseEditorsApi.prototype.sendEvent = function() { baseEditorsApi.prototype.sendEvent = function()
}; {
baseEditorsApi.prototype.SendOpenProgress = function() { };
baseEditorsApi.prototype.SendOpenProgress = function()
{
this.sendEvent("asc_onOpenDocumentProgress", this.OpenDocumentProgress); this.sendEvent("asc_onOpenDocumentProgress", this.OpenDocumentProgress);
}; };
baseEditorsApi.prototype.sync_InitEditorFonts = function(gui_fonts) { baseEditorsApi.prototype.sync_InitEditorFonts = function(gui_fonts)
{
this.sendEvent("asc_onInitEditorFonts", gui_fonts); this.sendEvent("asc_onInitEditorFonts", gui_fonts);
}; };
baseEditorsApi.prototype.sync_StartAction = function(type, id) { baseEditorsApi.prototype.sync_StartAction = function(type, id)
{
this.sendEvent('asc_onStartAction', type, id); this.sendEvent('asc_onStartAction', type, id);
//console.log("asc_onStartAction: type = " + type + " id = " + id); //console.log("asc_onStartAction: type = " + type + " id = " + id);
if (c_oAscAsyncActionType.BlockInteraction === type) { if (c_oAscAsyncActionType.BlockInteraction === type)
{
this.incrementCounterLongAction(); this.incrementCounterLongAction();
} }
}; };
baseEditorsApi.prototype.sync_EndAction = function(type, id) { baseEditorsApi.prototype.sync_EndAction = function(type, id)
{
this.sendEvent('asc_onEndAction', type, id); this.sendEvent('asc_onEndAction', type, id);
//console.log("asc_onEndAction: type = " + type + " id = " + id); //console.log("asc_onEndAction: type = " + type + " id = " + id);
if (c_oAscAsyncActionType.BlockInteraction === type) { if (c_oAscAsyncActionType.BlockInteraction === type)
{
this.decrementCounterLongAction(); this.decrementCounterLongAction();
} }
}; };
baseEditorsApi.prototype.sync_TryUndoInFastCollaborative = function() { baseEditorsApi.prototype.sync_TryUndoInFastCollaborative = function()
{
this.sendEvent("asc_OnTryUndoInFastCollaborative"); this.sendEvent("asc_OnTryUndoInFastCollaborative");
}; };
baseEditorsApi.prototype.asc_enableKeyEvents = function(val) {}; baseEditorsApi.prototype.asc_enableKeyEvents = function(val)
baseEditorsApi.prototype.asc_setViewMode = function() { {
}; };
baseEditorsApi.prototype.getViewMode = function() { baseEditorsApi.prototype.asc_setViewMode = function()
}; {
baseEditorsApi.prototype.isLongAction = function() { };
baseEditorsApi.prototype.getViewMode = function()
{
};
baseEditorsApi.prototype.isLongAction = function()
{
return (0 !== this.IsLongActionCurrent); return (0 !== this.IsLongActionCurrent);
}; };
baseEditorsApi.prototype.incrementCounterLongAction = function() { baseEditorsApi.prototype.incrementCounterLongAction = function()
{
++this.IsLongActionCurrent; ++this.IsLongActionCurrent;
}; };
baseEditorsApi.prototype.decrementCounterLongAction = function() { baseEditorsApi.prototype.decrementCounterLongAction = function()
{
this.IsLongActionCurrent--; this.IsLongActionCurrent--;
if (this.IsLongActionCurrent < 0) { if (this.IsLongActionCurrent < 0)
{
this.IsLongActionCurrent = 0; this.IsLongActionCurrent = 0;
} }
if (!this.isLongAction()) { if (!this.isLongAction())
{
var _length = this.LongActionCallbacks.length; var _length = this.LongActionCallbacks.length;
for (var i = 0; i < _length; i++) { for (var i = 0; i < _length; i++)
{
this.LongActionCallbacks[i](this.LongActionCallbacksParams[i]); this.LongActionCallbacks[i](this.LongActionCallbacksParams[i]);
} }
this.LongActionCallbacks.splice(0, _length); this.LongActionCallbacks.splice(0, _length);
this.LongActionCallbacksParams.splice(0, _length); this.LongActionCallbacksParams.splice(0, _length);
} }
}; };
baseEditorsApi.prototype.checkLongActionCallback = function(_callback, _param) { baseEditorsApi.prototype.checkLongActionCallback = function(_callback, _param)
if (this.isLongAction()) { {
if (this.isLongAction())
{
this.LongActionCallbacks[this.LongActionCallbacks.length] = _callback; this.LongActionCallbacks[this.LongActionCallbacks.length] = _callback;
this.LongActionCallbacksParams[this.LongActionCallbacksParams.length] = _param; this.LongActionCallbacksParams[this.LongActionCallbacksParams.length] = _param;
return false; return false;
} else { }
else
{
return true; return true;
} }
}; };
/** /**
* Функция для загрузчика шрифтов (нужно ли грузить default шрифты). Для Excel всегда возвращаем false * Функция для загрузчика шрифтов (нужно ли грузить default шрифты). Для Excel всегда возвращаем false
* @returns {boolean} * @returns {boolean}
*/ */
baseEditorsApi.prototype.IsNeedDefaultFonts = function() { baseEditorsApi.prototype.IsNeedDefaultFonts = function()
{
var res = false; var res = false;
switch (this.editorId) { switch (this.editorId)
{
case c_oEditorId.Word: case c_oEditorId.Word:
res = !this.isPdfViewer(); res = !this.isPdfViewer();
break; break;
...@@ -287,28 +334,32 @@ baseEditorsApi.prototype.IsNeedDefaultFonts = function() { ...@@ -287,28 +334,32 @@ baseEditorsApi.prototype.IsNeedDefaultFonts = function() {
break; break;
} }
return res; return res;
}; };
baseEditorsApi.prototype.onPrint = function() { baseEditorsApi.prototype.onPrint = function()
{
this.sendEvent("asc_onPrint"); this.sendEvent("asc_onPrint");
}; };
// Open // Open
baseEditorsApi.prototype.asc_LoadDocument = function(isVersionHistory) { baseEditorsApi.prototype.asc_LoadDocument = function(isVersionHistory)
{
// Меняем тип состояния (на открытие) // Меняем тип состояния (на открытие)
this.advancedOptionsAction = AscCommon.c_oAscAdvancedOptionsAction.Open; this.advancedOptionsAction = AscCommon.c_oAscAdvancedOptionsAction.Open;
var rData = null; var rData = null;
if (offlineMode !== this.documentUrl) { if (offlineMode !== this.documentUrl)
{
rData = { rData = {
"c": 'open', "c" : 'open',
"id": this.documentId, "id" : this.documentId,
"userid": this.documentUserId, "userid" : this.documentUserId,
"format": this.documentFormat, "format" : this.documentFormat,
"vkey": this.documentVKey, "vkey" : this.documentVKey,
"url": this.documentUrl, "url" : this.documentUrl,
"title": this.documentTitle, "title" : this.documentTitle,
"embeddedfonts": this.isUseEmbeddedCutFonts, "embeddedfonts" : this.isUseEmbeddedCutFonts,
"viewmode": this.getViewMode() "viewmode" : this.getViewMode()
}; };
if (isVersionHistory) { if (isVersionHistory)
{
//чтобы результат пришел только этому соединению, а не всем кто в документе //чтобы результат пришел только этому соединению, а не всем кто в документе
rData["userconnectionid"] = this.CoAuthoringApi.getUserConnectionId(); rData["userconnectionid"] = this.CoAuthoringApi.getUserConnectionId();
} }
...@@ -317,123 +368,160 @@ baseEditorsApi.prototype.asc_LoadDocument = function(isVersionHistory) { ...@@ -317,123 +368,160 @@ baseEditorsApi.prototype.asc_LoadDocument = function(isVersionHistory) {
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open); this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Open);
if (offlineMode === this.documentUrl) { if (offlineMode === this.documentUrl)
{
this.documentUrl = '/sdkjs/' + this._editorNameById() + '/document/'; this.documentUrl = '/sdkjs/' + this._editorNameById() + '/document/';
this.DocInfo.asc_putOfflineApp(true); this.DocInfo.asc_putOfflineApp(true);
} }
}; };
baseEditorsApi.prototype._OfflineAppDocumentStartLoad = function() { baseEditorsApi.prototype._OfflineAppDocumentStartLoad = function()
{
var t = this; var t = this;
var scriptElem = document.createElement('script'); var scriptElem = document.createElement('script');
scriptElem.onload = scriptElem.onerror = function() { scriptElem.onload = scriptElem.onerror = function()
{
t._OfflineAppDocumentEndLoad(); t._OfflineAppDocumentEndLoad();
}; };
scriptElem.setAttribute('src', this.documentUrl + 'editor.js'); scriptElem.setAttribute('src', this.documentUrl + 'editor.js');
scriptElem.setAttribute('type', 'text/javascript'); scriptElem.setAttribute('type', 'text/javascript');
document.getElementsByTagName('head')[0].appendChild(scriptElem); document.getElementsByTagName('head')[0].appendChild(scriptElem);
}; };
baseEditorsApi.prototype._onOpenCommand = function(data) { baseEditorsApi.prototype._onOpenCommand = function(data)
}; {
baseEditorsApi.prototype._onNeedParams = function(data) { };
}; baseEditorsApi.prototype._onNeedParams = function(data)
baseEditorsApi.prototype.asyncServerIdEndLoaded = function() { {
}; };
baseEditorsApi.prototype.asyncFontStartLoaded = function() { baseEditorsApi.prototype.asyncServerIdEndLoaded = function()
{
};
baseEditorsApi.prototype.asyncFontStartLoaded = function()
{
// здесь прокинуть евент о заморозке меню // здесь прокинуть евент о заморозке меню
this.sync_StartAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.LoadFont); this.sync_StartAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.LoadFont);
}; };
baseEditorsApi.prototype.asyncImageStartLoaded = function() { baseEditorsApi.prototype.asyncImageStartLoaded = function()
{
// здесь прокинуть евент о заморозке меню // здесь прокинуть евент о заморозке меню
}; };
baseEditorsApi.prototype.asyncImagesDocumentStartLoaded = function() { baseEditorsApi.prototype.asyncImagesDocumentStartLoaded = function()
{
// евент о заморозке не нужен... оно и так заморожено // евент о заморозке не нужен... оно и так заморожено
// просто нужно вывести информацию в статус бар (что началась загрузка картинок) // просто нужно вывести информацию в статус бар (что началась загрузка картинок)
}; };
// Save // Save
baseEditorsApi.prototype.processSavedFile = function(url, downloadType) { baseEditorsApi.prototype.processSavedFile = function(url, downloadType)
if (AscCommon.DownloadType.None !== downloadType) { {
this.sendEvent(downloadType, url, function(hasError) { if (AscCommon.DownloadType.None !== downloadType)
{
this.sendEvent(downloadType, url, function(hasError)
{
}); });
} else { }
else
{
AscCommon.getFile(url); AscCommon.getFile(url);
} }
}; };
// Выставление интервала автосохранения (0 - означает, что автосохранения нет) // Выставление интервала автосохранения (0 - означает, что автосохранения нет)
baseEditorsApi.prototype.asc_setAutoSaveGap = function(autoSaveGap) { baseEditorsApi.prototype.asc_setAutoSaveGap = function(autoSaveGap)
if (typeof autoSaveGap === "number") { {
if (typeof autoSaveGap === "number")
{
this.autoSaveGap = autoSaveGap * 1000; // Нам выставляют в секундах this.autoSaveGap = autoSaveGap * 1000; // Нам выставляют в секундах
} }
}; };
// send chart message // send chart message
baseEditorsApi.prototype.asc_coAuthoringChatSendMessage = function(message) { baseEditorsApi.prototype.asc_coAuthoringChatSendMessage = function(message)
{
this.CoAuthoringApi.sendMessage(message); this.CoAuthoringApi.sendMessage(message);
}; };
// get chart messages // get chart messages
baseEditorsApi.prototype.asc_coAuthoringChatGetMessages = function() { baseEditorsApi.prototype.asc_coAuthoringChatGetMessages = function()
{
this.CoAuthoringApi.getMessages(); this.CoAuthoringApi.getMessages();
}; };
// get users, возвращается массив users // get users, возвращается массив users
baseEditorsApi.prototype.asc_coAuthoringGetUsers = function() { baseEditorsApi.prototype.asc_coAuthoringGetUsers = function()
{
this.CoAuthoringApi.getUsers(); this.CoAuthoringApi.getUsers();
}; };
// get permissions // get permissions
baseEditorsApi.prototype.asc_getEditorPermissions = function() { baseEditorsApi.prototype.asc_getEditorPermissions = function()
{
this._coAuthoringInit(); this._coAuthoringInit();
}; };
baseEditorsApi.prototype._onEndPermissions = function() { baseEditorsApi.prototype._onEndPermissions = function()
if (this.isOnFirstConnectEnd && this.isOnLoadLicense) { {
if (this.isOnFirstConnectEnd && this.isOnLoadLicense)
{
this.sendEvent('asc_onGetEditorPermissions', new AscCommon.asc_CAscEditorPermissions()); this.sendEvent('asc_onGetEditorPermissions', new AscCommon.asc_CAscEditorPermissions());
} }
}; };
// CoAuthoring // CoAuthoring
baseEditorsApi.prototype._coAuthoringInit = function() { baseEditorsApi.prototype._coAuthoringInit = function()
{
var t = this; var t = this;
//Если User не задан, отключаем коавторинг. //Если User не задан, отключаем коавторинг.
if (null == this.User || null == this.User.asc_getId()) { if (null == this.User || null == this.User.asc_getId())
{
this.User = new AscCommon.asc_CUser(); this.User = new AscCommon.asc_CUser();
this.User.setId("Unknown"); this.User.setId("Unknown");
this.User.setUserName("Unknown"); this.User.setUserName("Unknown");
} }
//в обычном серверном режиме портим ссылку, потому что CoAuthoring теперь имеет встроенный адрес //в обычном серверном режиме портим ссылку, потому что CoAuthoring теперь имеет встроенный адрес
//todo надо использовать проверку get_OfflineApp //todo надо использовать проверку get_OfflineApp
if (!(window['NATIVE_EDITOR_ENJINE'] || offlineMode === this.documentUrl)) { if (!(window['NATIVE_EDITOR_ENJINE'] || offlineMode === this.documentUrl))
{
this.CoAuthoringApi.set_url(null); this.CoAuthoringApi.set_url(null);
} }
this.CoAuthoringApi.onMessage = function(e, clear) { this.CoAuthoringApi.onMessage = function(e, clear)
{
t.sendEvent('asc_onCoAuthoringChatReceiveMessage', e, clear); t.sendEvent('asc_onCoAuthoringChatReceiveMessage', e, clear);
}; };
this.CoAuthoringApi.onAuthParticipantsChanged = function(e, count) { this.CoAuthoringApi.onAuthParticipantsChanged = function(e, count)
{
t.sendEvent("asc_onAuthParticipantsChanged", e, count); t.sendEvent("asc_onAuthParticipantsChanged", e, count);
}; };
this.CoAuthoringApi.onParticipantsChanged = function(e, CountEditUsers) { this.CoAuthoringApi.onParticipantsChanged = function(e, CountEditUsers)
{
t.sendEvent("asc_onParticipantsChanged", e, CountEditUsers); t.sendEvent("asc_onParticipantsChanged", e, CountEditUsers);
}; };
this.CoAuthoringApi.onSpellCheckInit = function(e) { this.CoAuthoringApi.onSpellCheckInit = function(e)
{
t.SpellCheckUrl = e; t.SpellCheckUrl = e;
t._coSpellCheckInit(); t._coSpellCheckInit();
}; };
this.CoAuthoringApi.onSetIndexUser = function(e) { this.CoAuthoringApi.onSetIndexUser = function(e)
{
AscCommon.g_oIdCounter.Set_UserId('' + e); AscCommon.g_oIdCounter.Set_UserId('' + e);
}; };
this.CoAuthoringApi.onFirstLoadChangesEnd = function() { this.CoAuthoringApi.onFirstLoadChangesEnd = function()
{
t.asyncServerIdEndLoaded(); t.asyncServerIdEndLoaded();
}; };
this.CoAuthoringApi.onFirstConnect = function() { this.CoAuthoringApi.onFirstConnect = function()
if (t.isOnFirstConnectEnd) { {
if (t.isOnFirstConnectEnd)
{
t.CoAuthoringApi.auth(t.getViewMode()); t.CoAuthoringApi.auth(t.getViewMode());
} else { }
else
{
t.isOnFirstConnectEnd = true; t.isOnFirstConnectEnd = true;
t._onEndPermissions(); t._onEndPermissions();
} }
}; };
this.CoAuthoringApi.onLicense = function(res) { this.CoAuthoringApi.onLicense = function(res)
{
t.licenseResult = res; t.licenseResult = res;
t.isOnLoadLicense = true; t.isOnLoadLicense = true;
t._onEndPermissions(); t._onEndPermissions();
}; };
this.CoAuthoringApi.onWarning = function(e) { this.CoAuthoringApi.onWarning = function(e)
{
t.sendEvent('asc_onError', c_oAscError.ID.Warning, c_oAscError.Level.NoCritical); t.sendEvent('asc_onError', c_oAscError.ID.Warning, c_oAscError.Level.NoCritical);
}; };
/** /**
...@@ -442,11 +530,14 @@ baseEditorsApi.prototype._coAuthoringInit = function() { ...@@ -442,11 +530,14 @@ baseEditorsApi.prototype._coAuthoringInit = function() {
* @param {Bool} isDisconnectAtAll окончательно ли отсоединяемся(true) или будем пробовать сделать reconnect(false) + сами отключились * @param {Bool} isDisconnectAtAll окончательно ли отсоединяемся(true) или будем пробовать сделать reconnect(false) + сами отключились
* @param {Bool} isCloseCoAuthoring * @param {Bool} isCloseCoAuthoring
*/ */
this.CoAuthoringApi.onDisconnect = function(e, isDisconnectAtAll, isCloseCoAuthoring) { this.CoAuthoringApi.onDisconnect = function(e, isDisconnectAtAll, isCloseCoAuthoring)
if (AscCommon.ConnectionState.None === t.CoAuthoringApi.get_state()) { {
if (AscCommon.ConnectionState.None === t.CoAuthoringApi.get_state())
{
t.asyncServerIdEndLoaded(); t.asyncServerIdEndLoaded();
} }
if (isDisconnectAtAll) { if (isDisconnectAtAll)
{
// Посылаем наверх эвент об отключении от сервера // Посылаем наверх эвент об отключении от сервера
t.sendEvent('asc_onCoAuthoringDisconnect'); t.sendEvent('asc_onCoAuthoringDisconnect');
// И переходим в режим просмотра т.к. мы не можем сохранить файл // И переходим в режим просмотра т.к. мы не можем сохранить файл
...@@ -454,29 +545,41 @@ baseEditorsApi.prototype._coAuthoringInit = function() { ...@@ -454,29 +545,41 @@ baseEditorsApi.prototype._coAuthoringInit = function() {
t.sendEvent('asc_onError', isCloseCoAuthoring ? c_oAscError.ID.UserDrop : c_oAscError.ID.CoAuthoringDisconnect, c_oAscError.Level.NoCritical); t.sendEvent('asc_onError', isCloseCoAuthoring ? c_oAscError.ID.UserDrop : c_oAscError.ID.CoAuthoringDisconnect, c_oAscError.Level.NoCritical);
} }
}; };
this.CoAuthoringApi.onDocumentOpen = function(inputWrap) { this.CoAuthoringApi.onDocumentOpen = function(inputWrap)
if (inputWrap["data"]) { {
if (inputWrap["data"])
{
var input = inputWrap["data"]; var input = inputWrap["data"];
switch (input["type"]) { switch (input["type"])
{
case 'reopen': case 'reopen':
case 'open': case 'open':
switch (input["status"]) { switch (input["status"])
{
case "updateversion": case "updateversion":
case "ok": case "ok":
var urls = input["data"]; var urls = input["data"];
AscCommon.g_oDocumentUrls.init(urls); AscCommon.g_oDocumentUrls.init(urls);
if (null != urls['Editor.bin']) { if (null != urls['Editor.bin'])
if ('ok' === input["status"] || t.getViewMode()) { {
if ('ok' === input["status"] || t.getViewMode())
{
t._onOpenCommand(urls['Editor.bin']); t._onOpenCommand(urls['Editor.bin']);
} else { }
t.sendEvent("asc_onDocumentUpdateVersion", function() { else
if (t.isCoAuthoringEnable) { {
t.sendEvent("asc_onDocumentUpdateVersion", function()
{
if (t.isCoAuthoringEnable)
{
t.asc_coAuthoringDisconnect(); t.asc_coAuthoringDisconnect();
} }
t._onOpenCommand(urls['Editor.bin']); t._onOpenCommand(urls['Editor.bin']);
}) })
} }
} else { }
else
{
t.sendEvent("asc_onError", c_oAscError.ID.ConvertationError, c_oAscError.Level.Critical); t.sendEvent("asc_onError", c_oAscError.ID.ConvertationError, c_oAscError.Level.Critical);
} }
break; break;
...@@ -492,10 +595,13 @@ baseEditorsApi.prototype._coAuthoringInit = function() { ...@@ -492,10 +595,13 @@ baseEditorsApi.prototype._coAuthoringInit = function() {
} }
break; break;
default: default:
if (t.fCurCallback) { if (t.fCurCallback)
{
t.fCurCallback(input); t.fCurCallback(input);
t.fCurCallback = null; t.fCurCallback = null;
} else { }
else
{
t.sendEvent("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical); t.sendEvent("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
} }
break; break;
...@@ -505,109 +611,143 @@ baseEditorsApi.prototype._coAuthoringInit = function() { ...@@ -505,109 +611,143 @@ baseEditorsApi.prototype._coAuthoringInit = function() {
this._coAuthoringInitEnd(); this._coAuthoringInitEnd();
this.CoAuthoringApi.init(this.User, this.documentId, this.documentCallbackUrl, 'fghhfgsjdgfjs', this.editorId, this.documentFormatSave); this.CoAuthoringApi.init(this.User, this.documentId, this.documentCallbackUrl, 'fghhfgsjdgfjs', this.editorId, this.documentFormatSave);
}; };
baseEditorsApi.prototype._coAuthoringInitEnd = function() { baseEditorsApi.prototype._coAuthoringInitEnd = function()
}; {
// server disconnect };
baseEditorsApi.prototype.asc_coAuthoringDisconnect = function() { // server disconnect
baseEditorsApi.prototype.asc_coAuthoringDisconnect = function()
{
this.CoAuthoringApi.disconnect(); this.CoAuthoringApi.disconnect();
this.isCoAuthoringEnable = false; this.isCoAuthoringEnable = false;
// Выставляем view-режим // Выставляем view-режим
this.asc_setViewMode(true); this.asc_setViewMode(true);
}; };
baseEditorsApi.prototype.asc_stopSaving = function() { baseEditorsApi.prototype.asc_stopSaving = function()
{
this.incrementCounterLongAction(); this.incrementCounterLongAction();
}; };
baseEditorsApi.prototype.asc_continueSaving = function() { baseEditorsApi.prototype.asc_continueSaving = function()
{
this.decrementCounterLongAction(); this.decrementCounterLongAction();
}; };
// SpellCheck // SpellCheck
baseEditorsApi.prototype._coSpellCheckInit = function() { baseEditorsApi.prototype._coSpellCheckInit = function()
}; {
// Images & Charts & TextArts };
baseEditorsApi.prototype.asc_setChartTranslate = function(translate) { // Images & Charts & TextArts
baseEditorsApi.prototype.asc_setChartTranslate = function(translate)
{
this.chartTranslate = translate; this.chartTranslate = translate;
}; };
baseEditorsApi.prototype.asc_setTextArtTranslate = function(translate) { baseEditorsApi.prototype.asc_setTextArtTranslate = function(translate)
{
this.textArtTranslate = translate; this.textArtTranslate = translate;
}; };
baseEditorsApi.prototype.asc_getChartPreviews = function(chartType) { baseEditorsApi.prototype.asc_getChartPreviews = function(chartType)
{
return this.chartPreviewManager.getChartPreviews(chartType); return this.chartPreviewManager.getChartPreviews(chartType);
}; };
baseEditorsApi.prototype.asc_getTextArtPreviews = function() { baseEditorsApi.prototype.asc_getTextArtPreviews = function()
{
return this.textArtPreviewManager.getWordArtStyles(); return this.textArtPreviewManager.getWordArtStyles();
}; };
baseEditorsApi.prototype.asc_onOpenChartFrame = function() { baseEditorsApi.prototype.asc_onOpenChartFrame = function()
{
this.isOpenedChartFrame = true; this.isOpenedChartFrame = true;
}; };
baseEditorsApi.prototype.asc_onCloseChartFrame = function() { baseEditorsApi.prototype.asc_onCloseChartFrame = function()
{
this.isOpenedChartFrame = false; this.isOpenedChartFrame = false;
}; };
baseEditorsApi.prototype.asc_setInterfaceDrawImagePlaceShape = function(elementId) { baseEditorsApi.prototype.asc_setInterfaceDrawImagePlaceShape = function(elementId)
{
this.shapeElementId = elementId; this.shapeElementId = elementId;
}; };
baseEditorsApi.prototype.asc_getPropertyEditorShapes = function() { baseEditorsApi.prototype.asc_getPropertyEditorShapes = function()
{
return [AscCommon.g_oAutoShapesGroups, AscCommon.g_oAutoShapesTypes]; return [AscCommon.g_oAutoShapesGroups, AscCommon.g_oAutoShapesTypes];
}; };
baseEditorsApi.prototype.asc_getPropertyEditorTextArts = function() { baseEditorsApi.prototype.asc_getPropertyEditorTextArts = function()
{
return [AscCommon.g_oPresetTxWarpGroups, AscCommon.g_PresetTxWarpTypes]; return [AscCommon.g_oPresetTxWarpGroups, AscCommon.g_PresetTxWarpTypes];
}; };
// Add image // Add image
baseEditorsApi.prototype._addImageUrl = function() { baseEditorsApi.prototype._addImageUrl = function()
}; {
baseEditorsApi.prototype.asc_addImage = function() { };
baseEditorsApi.prototype.asc_addImage = function()
{
var t = this; var t = this;
AscCommon.ShowImageFileDialog(this.documentId, this.documentUserId, function(error, files) { AscCommon.ShowImageFileDialog(this.documentId, this.documentUserId, function(error, files)
{
t._uploadCallback(error, files); t._uploadCallback(error, files);
}, function(error) { }, function(error)
if (c_oAscError.ID.No !== error) { {
if (c_oAscError.ID.No !== error)
{
t.sendEvent("asc_onError", error, c_oAscError.Level.NoCritical); t.sendEvent("asc_onError", error, c_oAscError.Level.NoCritical);
} }
t.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage); t.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
}); });
}; };
baseEditorsApi.prototype._uploadCallback = function(error, files) { baseEditorsApi.prototype._uploadCallback = function(error, files)
{
var t = this; var t = this;
if (c_oAscError.ID.No !== error) { if (c_oAscError.ID.No !== error)
{
this.sendEvent("asc_onError", error, c_oAscError.Level.NoCritical); this.sendEvent("asc_onError", error, c_oAscError.Level.NoCritical);
} else { }
else
{
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage); this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
AscCommon.UploadImageFiles(files, this.documentId, this.documentUserId, function(error, url) { AscCommon.UploadImageFiles(files, this.documentId, this.documentUserId, function(error, url)
if (c_oAscError.ID.No !== error) { {
if (c_oAscError.ID.No !== error)
{
t.sendEvent("asc_onError", error, c_oAscError.Level.NoCritical); t.sendEvent("asc_onError", error, c_oAscError.Level.NoCritical);
} else { }
else
{
t._addImageUrl(url); t._addImageUrl(url);
} }
t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage); t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.UploadImage);
}); });
} }
}; };
//метод, который подменяет callback загрузки в каждом редакторе, TODO: переделать, сделать одинаково в о всех редакторах //метод, который подменяет callback загрузки в каждом редакторе, TODO: переделать, сделать одинаково в о всех редакторах
baseEditorsApi.prototype.asc_replaceLoadImageCallback = function(fCallback){ baseEditorsApi.prototype.asc_replaceLoadImageCallback = function(fCallback)
{
}; };
baseEditorsApi.prototype.asc_loadLocalImageAndAction = function(sLocalImage, fCallback){ baseEditorsApi.prototype.asc_loadLocalImageAndAction = function(sLocalImage, fCallback)
{
this.ImageLoader.LoadImage(AscCommon.getFullImageSrc2(sLocalImage), 1); this.ImageLoader.LoadImage(AscCommon.getFullImageSrc2(sLocalImage), 1);
this.asc_replaceLoadImageCallback(fCallback); this.asc_replaceLoadImageCallback(fCallback);
}; };
baseEditorsApi.prototype.asc_checkImageUrlAndAction = function(sImageUrl, fCallback){ baseEditorsApi.prototype.asc_checkImageUrlAndAction = function(sImageUrl, fCallback)
{
var sLocalImage = AscCommon.g_oDocumentUrls.getImageLocal(sImageUrl); var sLocalImage = AscCommon.g_oDocumentUrls.getImageLocal(sImageUrl);
if(sLocalImage){ if (sLocalImage)
{
this.asc_loadLocalImageAndAction(sLocalImage, fCallback); this.asc_loadLocalImageAndAction(sLocalImage, fCallback);
return; return;
} }
var oThis = this; var oThis = this;
AscCommon.sendImgUrls(oThis, [sImageUrl], function(data){ AscCommon.sendImgUrls(oThis, [sImageUrl], function(data)
if(data[0] && data[0].path != null){ {
if (data[0] && data[0].path != null)
{
oThis.asc_loadLocalImageAndAction(AscCommon.g_oDocumentUrls.imagePath2Local(data[0].path), fCallback); oThis.asc_loadLocalImageAndAction(AscCommon.g_oDocumentUrls.imagePath2Local(data[0].path), fCallback);
} }
}, this.editorId === c_oEditorId.Spreadsheet); }, this.editorId === c_oEditorId.Spreadsheet);
}; };
baseEditorsApi.prototype.asc_addOleObject = function(oPluginData){ baseEditorsApi.prototype.asc_addOleObject = function(oPluginData)
{
Asc.CPluginData_wrap(oPluginData); Asc.CPluginData_wrap(oPluginData);
var oThis = this; var oThis = this;
var oThis = this; var oThis = this;
...@@ -618,15 +758,19 @@ baseEditorsApi.prototype._uploadCallback = function(error, files) { ...@@ -618,15 +758,19 @@ baseEditorsApi.prototype._uploadCallback = function(error, files) {
var fHeight = oPluginData.getAttribute("height"); var fHeight = oPluginData.getAttribute("height");
var sData = oPluginData.getAttribute("data"); var sData = oPluginData.getAttribute("data");
var sGuid = oPluginData.getAttribute("guid"); var sGuid = oPluginData.getAttribute("guid");
if(typeof sImgSrc === "string" && sImgSrc.length > 0 && typeof sData === "string" if (typeof sImgSrc === "string" && sImgSrc.length > 0 && typeof sData === "string"
&& typeof sGuid === "string" && sGuid.length > 0 && typeof sGuid === "string" && sGuid.length > 0
&& AscFormat.isRealNumber(nWidthPix) && AscFormat.isRealNumber(nHeightPix) && AscFormat.isRealNumber(nWidthPix) && AscFormat.isRealNumber(nHeightPix)
&& AscFormat.isRealNumber(fWidth) && AscFormat.isRealNumber(fHeight) && AscFormat.isRealNumber(fWidth) && AscFormat.isRealNumber(fHeight)
) )
this.asc_checkImageUrlAndAction(sImgSrc, function(oImage){oThis.asc_addOleObjectAction(AscCommon.g_oDocumentUrls.getImageLocal(oImage.src), sData, sGuid, fWidth, fHeight, nWidthPix, nHeightPix);}); this.asc_checkImageUrlAndAction(sImgSrc, function(oImage)
{
oThis.asc_addOleObjectAction(AscCommon.g_oDocumentUrls.getImageLocal(oImage.src), sData, sGuid, fWidth, fHeight, nWidthPix, nHeightPix);
});
}; };
baseEditorsApi.prototype.asc_editOleObject = function(oPluginData){ baseEditorsApi.prototype.asc_editOleObject = function(oPluginData)
{
Asc.CPluginData_wrap(oPluginData); Asc.CPluginData_wrap(oPluginData);
var oThis = this; var oThis = this;
var bResize = oPluginData.getAttribute("resize"); var bResize = oPluginData.getAttribute("resize");
...@@ -635,9 +779,13 @@ baseEditorsApi.prototype._uploadCallback = function(error, files) { ...@@ -635,9 +779,13 @@ baseEditorsApi.prototype._uploadCallback = function(error, files) {
var nWidthPix = oPluginData.getAttribute("widthPix"); var nWidthPix = oPluginData.getAttribute("widthPix");
var nHeightPix = oPluginData.getAttribute("heightPix"); var nHeightPix = oPluginData.getAttribute("heightPix");
var sData = oPluginData.getAttribute("data"); var sData = oPluginData.getAttribute("data");
if(typeof sImgSrc === "string" && sImgSrc.length > 0 && typeof sData === "string" if (typeof sImgSrc === "string" && sImgSrc.length > 0 && typeof sData === "string"
&& oOleObject && AscFormat.isRealNumber(nWidthPix) && AscFormat.isRealNumber(nHeightPix)){ && oOleObject && AscFormat.isRealNumber(nWidthPix) && AscFormat.isRealNumber(nHeightPix))
this.asc_checkImageUrlAndAction(sImgSrc, function(oImage){oThis.asc_editOleObjectAction(bResize, oOleObject, AscCommon.g_oDocumentUrls.getImageLocal(oImage.src), sData, nWidthPix, nHeightPix);}); {
this.asc_checkImageUrlAndAction(sImgSrc, function(oImage)
{
oThis.asc_editOleObjectAction(bResize, oOleObject, AscCommon.g_oDocumentUrls.getImageLocal(oImage.src), sData, nWidthPix, nHeightPix);
});
} }
}; };
...@@ -649,37 +797,47 @@ baseEditorsApi.prototype._uploadCallback = function(error, files) { ...@@ -649,37 +797,47 @@ baseEditorsApi.prototype._uploadCallback = function(error, files) {
{ {
}; };
// Version History // Version History
baseEditorsApi.prototype.asc_showRevision = function(newObj) { baseEditorsApi.prototype.asc_showRevision = function(newObj)
}; {
baseEditorsApi.prototype.asc_undoAllChanges = function() { };
}; baseEditorsApi.prototype.asc_undoAllChanges = function()
/** {
};
/**
* Эта функция возвращает true, если есть изменения или есть lock-и в документе * Эта функция возвращает true, если есть изменения или есть lock-и в документе
*/ */
baseEditorsApi.prototype.asc_isDocumentCanSave = function() { baseEditorsApi.prototype.asc_isDocumentCanSave = function()
{
return this.isDocumentCanSave; return this.isDocumentCanSave;
}; };
// Offline mode // Offline mode
baseEditorsApi.prototype.asc_isOffline = function() { baseEditorsApi.prototype.asc_isOffline = function()
{
return false; return false;
}; };
baseEditorsApi.prototype.asc_getUrlType = function(url) { baseEditorsApi.prototype.asc_getUrlType = function(url)
{
return AscCommon.getUrlType(url); return AscCommon.getUrlType(url);
}; };
baseEditorsApi.prototype.openDocument = function() { baseEditorsApi.prototype.openDocument = function()
{
}; };
baseEditorsApi.prototype.onEndLoadFile = function(result) { baseEditorsApi.prototype.onEndLoadFile = function(result)
if (result) { {
if (result)
{
this.openResult = result; this.openResult = result;
} }
if (this.isLoadFullApi && this.openResult) { if (this.isLoadFullApi && this.openResult)
{
this.openDocument(this.openResult); this.openDocument(this.openResult);
} }
}; };
baseEditorsApi.prototype._onEndLoadSdk = function() { baseEditorsApi.prototype._onEndLoadSdk = function()
{
AscFonts.g_fontApplication.Init(); AscFonts.g_fontApplication.Init();
this.FontLoader = AscCommon.g_font_loader; this.FontLoader = AscCommon.g_font_loader;
...@@ -695,15 +853,18 @@ baseEditorsApi.prototype.asc_getUrlType = function(url) { ...@@ -695,15 +853,18 @@ baseEditorsApi.prototype.asc_getUrlType = function(url) {
AscFormat.initStyleManager(); AscFormat.initStyleManager();
if (null !== this.tmpFocus) { if (null !== this.tmpFocus)
{
this.asc_enableKeyEvents(this.tmpFocus); this.asc_enableKeyEvents(this.tmpFocus);
} }
}; };
baseEditorsApi.prototype.sendStandartTextures = function() { baseEditorsApi.prototype.sendStandartTextures = function()
{
var _count = AscCommon.g_oUserTexturePresets.length; var _count = AscCommon.g_oUserTexturePresets.length;
var arr = new Array(_count); var arr = new Array(_count);
for (var i = 0; i < _count; ++i) { for (var i = 0; i < _count; ++i)
{
arr[i] = new AscCommon.asc_CTexture(); arr[i] = new AscCommon.asc_CTexture();
arr[i].Id = i; arr[i].Id = i;
arr[i].Image = AscCommon.g_oUserTexturePresets[i]; arr[i].Image = AscCommon.g_oUserTexturePresets[i];
...@@ -713,41 +874,45 @@ baseEditorsApi.prototype.asc_getUrlType = function(url) { ...@@ -713,41 +874,45 @@ baseEditorsApi.prototype.asc_getUrlType = function(url) {
this.sendEvent('asc_onInitStandartTextures', arr); this.sendEvent('asc_onInitStandartTextures', arr);
}; };
// plugins // plugins
baseEditorsApi.prototype.asc_pluginsRegister = function(basePath, plugins) baseEditorsApi.prototype.asc_pluginsRegister = function(basePath, plugins)
{ {
if (null != this.pluginsManager) if (null != this.pluginsManager)
this.pluginsManager.register(basePath, plugins); this.pluginsManager.register(basePath, plugins);
}; };
baseEditorsApi.prototype.asc_pluginRun = function(guid, variation, pluginData) baseEditorsApi.prototype.asc_pluginRun = function(guid, variation, pluginData)
{ {
if (null != this.pluginsManager) if (null != this.pluginsManager)
this.pluginsManager.run(guid, variation, pluginData); this.pluginsManager.run(guid, variation, pluginData);
}; };
baseEditorsApi.prototype.asc_pluginResize = function(pluginData) baseEditorsApi.prototype.asc_pluginResize = function(pluginData)
{ {
if (null != this.pluginsManager) if (null != this.pluginsManager)
this.pluginsManager.runResize(pluginData); this.pluginsManager.runResize(pluginData);
}; };
baseEditorsApi.prototype.asc_pluginButtonClick = function(id) baseEditorsApi.prototype.asc_pluginButtonClick = function(id)
{ {
if (null != this.pluginsManager) if (null != this.pluginsManager)
this.pluginsManager.buttonClick(id); this.pluginsManager.buttonClick(id);
}; };
// Builder // Builder
baseEditorsApi.prototype.asc_nativeInitBuilder = function() { baseEditorsApi.prototype.asc_nativeInitBuilder = function()
{
this.asc_setDocInfo(new Asc.asc_CDocInfo()); this.asc_setDocInfo(new Asc.asc_CDocInfo());
}; };
baseEditorsApi.prototype.asc_SetSilentMode = function() { baseEditorsApi.prototype.asc_SetSilentMode = function()
{
}; };
baseEditorsApi.prototype.asc_canPaste = function() { baseEditorsApi.prototype.asc_canPaste = function()
{
return false;
}; };
baseEditorsApi.prototype.asc_Recalculate = function() { baseEditorsApi.prototype.asc_Recalculate = function()
{
}; };
//----------------------------------------------------------export---------------------------------------------------- //----------------------------------------------------------export----------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {}; window['AscCommon'] = window['AscCommon'] || {};
window['AscCommon'].baseEditorsApi = baseEditorsApi; window['AscCommon'].baseEditorsApi = baseEditorsApi;
......
...@@ -305,9 +305,28 @@ ...@@ -305,9 +305,28 @@
if (value && value != "") if (value && value != "")
{ {
try try
{
if (window.g_asc_plugins.api.asc_canPaste())
{ {
var _script = "(function(){ var Api = window.g_asc_plugins.api;\n" + value + "})();"; var _script = "(function(){ var Api = window.g_asc_plugins.api;\n" + value + "})();";
eval(_script); eval(_script);
var oLogicDocument = window.g_asc_plugins.api.WordControl ? window.g_asc_plugins.api.WordControl.m_oLogicDocument : null;
if (pluginData.getAttribute("recalculate") == true)
{
var _fonts = oLogicDocument.Document_Get_AllFontNames();
var _imagesArray = oLogicDocument.Get_AllImageUrls();
var _images = {};
for (var i = 0; i < _imagesArray.length; i++)
{
_images[_imagesArray[i]] = _imagesArray[i];
}
AscCommon.Check_LoadingDataBeforePrepaste(window.g_asc_plugins.api, _fonts, _images, function()
{
window.g_asc_plugins.api.asc_Recalculate();
});
}
}
} }
catch (err) catch (err)
{ {
...@@ -495,6 +514,38 @@ function TEST_PLUGINS() ...@@ -495,6 +514,38 @@ function TEST_PLUGINS()
{ text: "Cancel", primary: false } ] { text: "Cancel", primary: false } ]
} }
] ]
},
{
"name" : "cbr",
"guid" : "asc.{5F9D4EB4-AF61-46EF-AE25-46C96E75E1DD}",
"variations" : [
{
"description" : "cbr",
"url" : "cbr/index.html",
"icons" : ["cbr/icon.png", "cbr/icon@2x.png"],
// "isViewer" : true,
"isViewer" : false,
"EditorsSupport" : ["word", "cell", "slide"],
// "isVisual" : true,
// "isModal" : true,
"isVisual" : false,
"isModal" : false,
"isInsideMode" : false,
"initDataType" : "none",
"initData" : "",
// "isUpdateOleOnResize" : true,
"isUpdateOleOnResize" : false,
// "buttons" : [ { "text": "Ok", "primary": true },
// { "text": "Cancel", "primary": false } ]
"buttons" : []
}
]
} }
]; ];
......
...@@ -7817,8 +7817,81 @@ function CreateImageFromBinary(bin, nW, nH) ...@@ -7817,8 +7817,81 @@ function CreateImageFromBinary(bin, nW, nH)
return para_drawing; return para_drawing;
} }
function Check_LoadingDataBeforePrepaste(_api, _fonts, _images, _callback)
{
var aPrepeareFonts = [];
for (var font_family in _fonts)
{
aPrepeareFonts.push(new CFont(font_family, 0, "", 0));
};
var aImagesToDownload = [];
var _mapLocal = {};
for (var image in _images)
{
var src = _images[image];
if (undefined !== window["Native"] && undefined !== window["Native"]["GetImageUrl"])
{
_images[image] = window["Native"]["GetImageUrl"](_images[image]);
}
else if (0 == src.indexOf("file:"))
{
if (window["AscDesktopEditor"] !== undefined)
{
if (window["AscDesktopEditor"]["LocalFileGetImageUrl"] !== undefined)
{
aImagesToDownload.push(src);
}
else
{
var _base64 = window["AscDesktopEditor"]["GetImageBase64"](src);
if (_base64 != "")
{
aImagesToDownload.push(_base64);
_mapLocal[_base64] = src;
}
else
{
_images[image] = "local";
}
}
}
else
_images[image] = "local";
}
else if (!g_oDocumentUrls.getImageLocal(src))
aImagesToDownload.push(src);
}
if (aImagesToDownload.length > 0)
{
AscCommon.sendImgUrls(_api, aImagesToDownload, function (data) {
var image_map = {};
for (var i = 0, length = Math.min(data.length, aImagesToDownload.length); i < length; ++i)
{
var elem = data[i];
var sFrom = aImagesToDownload[i];
if (null != elem.url)
{
var name = g_oDocumentUrls.imagePath2Local(elem.path);
_images[sFrom] = name;
image_map[i] = name;
}
else
{
image_map[i] = sFrom;
}
}
_api.pre_Paste(aPrepeareFonts, image_map, _callback);
});
}
else
_api.pre_Paste(aPrepeareFonts, _images, _callback);
}
//---------------------------------------------------------export--------------------------------------------------- //---------------------------------------------------------export---------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {}; window['AscCommon'] = window['AscCommon'] || {};
window["AscCommon"].Check_LoadingDataBeforePrepaste = Check_LoadingDataBeforePrepaste;
window["AscCommon"].CDocumentReaderMode = CDocumentReaderMode; window["AscCommon"].CDocumentReaderMode = CDocumentReaderMode;
window["AscCommon"].GetObjectsForImageDownload = GetObjectsForImageDownload; window["AscCommon"].GetObjectsForImageDownload = GetObjectsForImageDownload;
window["AscCommon"].ResetNewUrls = ResetNewUrls; window["AscCommon"].ResetNewUrls = ResetNewUrls;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment