Commit a4234ff0 authored by Oleg Korshul's avatar Oleg Korshul

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

parent 0957160f
This diff is collapsed.
...@@ -306,8 +306,27 @@ ...@@ -306,8 +306,27 @@
{ {
try try
{ {
var _script = "(function(){ var Api = window.g_asc_plugins.api;\n" + value + "})();"; if (window.g_asc_plugins.api.asc_canPaste())
eval(_script); {
var _script = "(function(){ var Api = window.g_asc_plugins.api;\n" + value + "})();";
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 diff is collapsed.
This diff is collapsed.
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