mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-02-10 18:05:10 +08:00
python: onRequestOpen for referenceData source file
This commit is contained in:
@ -502,7 +502,8 @@ def reference(request):
|
||||
'instanceId' : docManager.getServerUrl(False, request),
|
||||
'fileKey' : json.dumps({'fileName' : fileName, 'userAddress': request.META['REMOTE_ADDR']})
|
||||
},
|
||||
'path' : fileName
|
||||
'path' : fileName,
|
||||
'link' : docManager.getServerUrl(False, request) + '/edit?filename=' + fileName
|
||||
}
|
||||
|
||||
if (jwtManager.isEnabled()):
|
||||
|
||||
@ -170,18 +170,40 @@
|
||||
}
|
||||
};
|
||||
|
||||
var onRequestReferenceData = function(event) { // user refresh external data source
|
||||
innerAlert("onRequestReferenceData: " + JSON.stringify(event.data));
|
||||
var onRequestOpen = function (event) { // user open external data source
|
||||
innerAlert("onRequestOpen");
|
||||
var windowName = event.data.windowName;
|
||||
requestReference(event.data, function (data) {
|
||||
if (data.error) {
|
||||
var winEditor = window.open("", windowName);
|
||||
winEditor.close();
|
||||
innerAlert(data.error, true);
|
||||
return;
|
||||
}
|
||||
var link = data.link;
|
||||
window.open(link, windowName);
|
||||
});
|
||||
};
|
||||
|
||||
event.data.directUrl = !!config.document.directUrl;
|
||||
var onRequestReferenceData = function(event) { // user refresh external data source
|
||||
innerAlert("onRequestReferenceData");
|
||||
|
||||
requestReference(event.data, function (data) {
|
||||
docEditor.setReferenceData(data);
|
||||
});
|
||||
};
|
||||
|
||||
var requestReference = function (data, callback) {
|
||||
innerAlert(data);
|
||||
data.directUrl = !!config.document.directUrl;
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", "reference");
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.send(JSON.stringify(event.data));
|
||||
xhr.send(JSON.stringify(data));
|
||||
xhr.onload = function () {
|
||||
innerAlert(xhr.responseText);
|
||||
console.log(JSON.parse(xhr.responseText));
|
||||
docEditor.setReferenceData(JSON.parse(xhr.responseText));
|
||||
callback(JSON.parse(xhr.responseText));
|
||||
}
|
||||
};
|
||||
|
||||
@ -265,6 +287,8 @@
|
||||
|
||||
// prevent switch the document from the viewing into the editing mode for anonymous users
|
||||
config.events['onRequestEditRights'] = onRequestEditRights;
|
||||
// add link to reference data source file
|
||||
config.events['onRequestOpen'] = onRequestOpen;
|
||||
}
|
||||
|
||||
if (config.editorConfig.createUrl) {
|
||||
|
||||
Reference in New Issue
Block a user