diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js
index a955a106d0..7d1fb90ae4 100644
--- a/apps/api/documents/api.js
+++ b/apps/api/documents/api.js
@@ -517,6 +517,20 @@
if (_config.editorConfig.customization && _config.editorConfig.customization.integrationMode==='embed')
window.AscEmbed && window.AscEmbed.initWorker(iframe);
+ if (_config.document && (_config.document.isForm===undefined)) {
+ iframe.onload = function() {
+ _sendCommand({
+ command: 'checkParams',
+ data: {
+ url: _config.document.url,
+ directUrl: _config.document.directUrl,
+ token: _config.document.token,
+ key: _config.document.key
+ }
+ })
+ };
+ }
+
if (iframe.src) {
var pathArray = iframe.src.split('/');
this.frameOrigin = pathArray[0] + '//' + pathArray[2];
@@ -1016,14 +1030,15 @@
if (config.frameEditorId)
params += "&frameEditorId=" + config.frameEditorId;
- var type = config.document ? /^(?:(pdf))$/.exec(config.document.fileType) : null,
- isPdf = type && typeof type[1] === 'string';
- if (!isPdf && (config.editorConfig && config.editorConfig.mode == 'view' ||
+ var type = config.document ? /^(?:(pdf))$/.exec(config.document.fileType) : null;
+ if (!(type && typeof type[1] === 'string') && (config.editorConfig && config.editorConfig.mode == 'view' ||
config.document && config.document.permissions && (config.document.permissions.edit === false && !config.document.permissions.review )))
params += "&mode=view";
- config.document.isForm = isPdf ? config.document.isForm : false;
- if (config.document && (config.document.isForm!==undefined))
- params += "&isForm=" + config.document.isForm;
+
+ if (config.document) {
+ config.document.isForm = (type && typeof type[1] === 'string') ? config.document.isForm : false;
+ (config.document.isForm!==undefined) && (params += "&isForm=" + config.document.isForm);
+ }
if (config.editorConfig && config.editorConfig.customization && !!config.editorConfig.customization.compactHeader)
params += "&compact=true";
@@ -1040,20 +1055,6 @@
if (config.document && config.document.fileType)
params += "&fileType=" + config.document.fileType;
- if (isPdf) {
- if (config.document && config.document.directUrl)
- params += "&directUrl=" + encodeURIComponent(config.document.directUrl);
-
- if (config.document && config.document.key)
- params += "&key=" + config.document.key;
-
- if (config.document && config.document.url)
- params += "&url=" + encodeURIComponent(config.document.url);
-
- if (config.document && config.document.token)
- params += "&token=" + config.document.token;
- }
-
return params;
}
diff --git a/apps/common/checkExtendedPDF.js b/apps/common/checkExtendedPDF.js
index 5589c48732..469b8e18df 100644
--- a/apps/common/checkExtendedPDF.js
+++ b/apps/common/checkExtendedPDF.js
@@ -116,4 +116,46 @@ function downloadPartialy(url, limit, headers, callback) {
}
}
xhr.send();
-}
\ No newline at end of file
+}
+
+var startCallback;
+var eventFn = function(msg) {
+ if (msg.origin !== window.parentOrigin && msg.origin !== window.location.origin && !(msg.origin==="null" && (window.parentOrigin==="file://" || window.location.origin==="file://"))) return;
+
+ var data = msg.data;
+ if (Object.prototype.toString.apply(data) !== '[object String]' || !window.JSON) {
+ return;
+ }
+ try {
+ data = window.JSON.parse(data)
+ } catch(e) {
+ data = '';
+ }
+
+ if (data && data.command==="checkParams") {
+ data = data.data || {};
+ checkExtendedPDF(data.directUrl, data.key, data.url, data.token, startCallback);
+ _unbindWindowEvents();
+ }
+};
+
+var _bindWindowEvents = function() {
+ if (window.addEventListener) {
+ window.addEventListener("message", eventFn, false)
+ } else if (window.attachEvent) {
+ window.attachEvent("onmessage", eventFn);
+ }
+};
+
+var _unbindWindowEvents = function() {
+ if (window.removeEventListener) {
+ window.removeEventListener("message", eventFn)
+ } else if (window.detachEvent) {
+ window.detachEvent("onmessage", eventFn);
+ }
+};
+
+function listenApiMsg(callback) {
+ startCallback = callback;
+ _bindWindowEvents();
+}
diff --git a/apps/documenteditor/embed/index.html b/apps/documenteditor/embed/index.html
index bddada7aa7..9242b17b78 100644
--- a/apps/documenteditor/embed/index.html
+++ b/apps/documenteditor/embed/index.html
@@ -197,10 +197,6 @@
var params = getUrlParams(),
lang = (params["lang"] || 'en').split(/[\-\_]/)[0],
logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null,
- directUrl = params["directUrl"] ? encodeUrlParam(params["directUrl"]) : null,
- url = params["url"] ? encodeUrlParam(params["url"]) : null,
- fileKey = params["key"] || '',
- token = params["token"] || '',
isForm = params["isForm"];
window.frameEditorId = params["frameEditorId"];
@@ -306,7 +302,7 @@
document.body.appendChild(script);
}
if (isForm===undefined) {
- checkExtendedPDF(directUrl, fileKey, url, token, function (isform) {
+ listenApiMsg(function (isform) {
window.isPDFForm = !!isform;
startApp();
});
diff --git a/apps/documenteditor/embed/index.html.deploy b/apps/documenteditor/embed/index.html.deploy
index feedff229f..5fd9b41c37 100644
--- a/apps/documenteditor/embed/index.html.deploy
+++ b/apps/documenteditor/embed/index.html.deploy
@@ -189,11 +189,7 @@
var params = getUrlParams(),
lang = (params["lang"] || 'en').split(/[\-\_]/)[0],
logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null,
- directUrl = params["directUrl"] ? encodeUrlParam(params["directUrl"]) : null,
- url = params["url"] ? encodeUrlParam(params["url"]) : null,
- fileKey = params["key"] || '',
- token = params["token"] || '',
- isForm = params["isForm"];
+ isForm = params["isForm"];
window.frameEditorId = params["frameEditorId"];
window.parentOrigin = params["parentOrigin"];
@@ -281,7 +277,7 @@
document.body.appendChild(script);
}
if (isForm===undefined) {
- checkExtendedPDF(directUrl, fileKey, url, token, function (isform) {
+ listenApiMsg(function (isform) {
window.isPDFForm = !!isform;
startApp();
});
diff --git a/apps/documenteditor/embed/index_loader.html b/apps/documenteditor/embed/index_loader.html
index 971b43b8fa..b972da3666 100644
--- a/apps/documenteditor/embed/index_loader.html
+++ b/apps/documenteditor/embed/index_loader.html
@@ -237,10 +237,6 @@
margin = (customer !== '') ? 50 : 20,
loading = 'Loading...',
logo = params["logo"] ? ((params["logo"] !== 'none') ? ('
') : '') : null,
- directUrl = params["directUrl"] ? encodeUrlParam(params["directUrl"]) : null,
- url = params["url"] ? encodeUrlParam(params["url"]) : null,
- fileKey = params["key"] || '',
- token = params["token"] || '',
isForm = params["isForm"];
window.frameEditorId = params["frameEditorId"];
@@ -365,7 +361,7 @@
document.body.appendChild(script);
}
if (isForm===undefined) {
- checkExtendedPDF(directUrl, fileKey, url, token, function (isform) {
+ listenApiMsg(function (isform) {
window.isPDFForm = !!isform;
startApp();
});
diff --git a/apps/documenteditor/embed/index_loader.html.deploy b/apps/documenteditor/embed/index_loader.html.deploy
index 39dff2ee4c..7844bb22e3 100644
--- a/apps/documenteditor/embed/index_loader.html.deploy
+++ b/apps/documenteditor/embed/index_loader.html.deploy
@@ -229,10 +229,6 @@
margin = (customer !== '') ? 50 : 20,
loading = 'Loading...',
logo = params["logo"] ? ((params["logo"] !== 'none') ? ('
') : '') : null,
- directUrl = params["directUrl"] ? encodeUrlParam(params["directUrl"]) : null,
- url = params["url"] ? encodeUrlParam(params["url"]) : null,
- fileKey = params["key"] || '',
- token = params["token"] || '',
isForm = params["isForm"];
window.frameEditorId = params["frameEditorId"];
@@ -342,7 +338,7 @@
document.body.appendChild(script);
}
if (isForm===undefined) {
- checkExtendedPDF(directUrl, fileKey, url, token, function (isform) {
+ listenApiMsg(function (isform) {
window.isPDFForm = !!isform;
startApp();
});
diff --git a/apps/documenteditor/mobile/src/app.js b/apps/documenteditor/mobile/src/app.js
index 8e0d2e2624..cadbd22776 100644
--- a/apps/documenteditor/mobile/src/app.js
+++ b/apps/documenteditor/mobile/src/app.js
@@ -51,12 +51,8 @@ const startApp = () => {
const params = getUrlParams(),
isForm = params["isForm"];
-if (isForm===undefined && checkExtendedPDF) {
- const directUrl = params["directUrl"] ? encodeUrlParam(params["directUrl"]) : null,
- url = params["url"] ? encodeUrlParam(params["url"]) : null,
- fileKey = params["key"] || '',
- token = params["token"] || '';
- checkExtendedPDF(directUrl, fileKey, url, token, function (isform) {
+if (isForm===undefined && listenApiMsg) {
+ listenApiMsg(function (isform) {
window.isPDFForm = !!isform;
startApp();
});
diff --git a/apps/pdfeditor/main/index.html b/apps/pdfeditor/main/index.html
index 5069292184..25ecbface6 100644
--- a/apps/pdfeditor/main/index.html
+++ b/apps/pdfeditor/main/index.html
@@ -257,10 +257,6 @@
lang = (params["lang"] || 'en').split(/[\-\_]/)[0],
logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null,
logoDark = params["headerlogodark"] ? encodeUrlParam(params["headerlogodark"]) : null,
- directUrl = params["directUrl"] ? encodeUrlParam(params["directUrl"]) : null,
- url = params["url"] ? encodeUrlParam(params["url"]) : null,
- fileKey = params["key"] || '',
- token = params["token"] || '',
isForm = params["isForm"];
window.frameEditorId = params["frameEditorId"];
@@ -382,7 +378,7 @@
document.body.appendChild(script);
}
if (isForm===undefined) {
- checkExtendedPDF(directUrl, fileKey, url, token, function (isform) {
+ listenApiMsg(function (isform) {
window.isPDFForm = !!isform;
startApp();
});
diff --git a/apps/pdfeditor/main/index.html.deploy b/apps/pdfeditor/main/index.html.deploy
index 71f3660be7..812545605f 100644
--- a/apps/pdfeditor/main/index.html.deploy
+++ b/apps/pdfeditor/main/index.html.deploy
@@ -230,10 +230,6 @@
lang = (params["lang"] || 'en').split(/[\-\_]/)[0],
logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null,
logoDark = params["headerlogodark"] ? encodeUrlParam(params["headerlogodark"]) : null,
- directUrl = params["directUrl"] ? encodeUrlParam(params["directUrl"]) : null,
- url = params["url"] ? encodeUrlParam(params["url"]) : null,
- fileKey = params["key"] || '',
- token = params["token"] || '',
isForm = params["isForm"];
window.frameEditorId = params["frameEditorId"];
@@ -340,7 +336,7 @@
document.body.appendChild(script);
}
if (isForm===undefined) {
- checkExtendedPDF(directUrl, fileKey, url, token, function (isform) {
+ listenApiMsg(function (isform) {
window.isPDFForm = !!isform;
startApp();
});
diff --git a/apps/pdfeditor/main/index_loader.html b/apps/pdfeditor/main/index_loader.html
index 559f7313de..738e9f61b8 100644
--- a/apps/pdfeditor/main/index_loader.html
+++ b/apps/pdfeditor/main/index_loader.html
@@ -220,10 +220,6 @@
margin = (customer !== '') ? 50 : 20,
loading = 'Loading...',
logo = params["logo"] ? ((params["logo"] !== 'none') ? ('
') : '') : null,
- directUrl = params["directUrl"] ? encodeUrlParam(params["directUrl"]) : null,
- url = params["url"] ? encodeUrlParam(params["url"]) : null,
- fileKey = params["key"] || '',
- token = params["token"] || '',
isForm = params["isForm"];
window.frameEditorId = params["frameEditorId"];
@@ -315,7 +311,7 @@
document.body.appendChild(script);
}
if (isForm===undefined) {
- checkExtendedPDF(directUrl, fileKey, url, token, function (isform) {
+ listenApiMsg(function (isform) {
window.isPDFForm = !!isform;
startApp();
});
diff --git a/apps/pdfeditor/main/index_loader.html.deploy b/apps/pdfeditor/main/index_loader.html.deploy
index e9c3e2c14a..1ac39891cc 100644
--- a/apps/pdfeditor/main/index_loader.html.deploy
+++ b/apps/pdfeditor/main/index_loader.html.deploy
@@ -242,10 +242,6 @@
margin = (customer !== '') ? 50 : 20,
loading = 'Loading...',
logo = params["logo"] ? ((params["logo"] !== 'none') ? ('
') : '') : null,
- directUrl = params["directUrl"] ? encodeUrlParam(params["directUrl"]) : null,
- url = params["url"] ? encodeUrlParam(params["url"]) : null,
- fileKey = params["key"] || '',
- token = params["token"] || '',
isForm = params["isForm"];
window.frameEditorId = params["frameEditorId"];
@@ -335,7 +331,7 @@
document.body.appendChild(script);
}
if (isForm===undefined) {
- checkExtendedPDF(directUrl, fileKey, url, token, function (isform) {
+ listenApiMsg(function (isform) {
window.isPDFForm = !!isform;
startApp();
});