How can i trigger “Start” function automatically on document load?? and the manual button should also be available… is there way to seperate if its automatically triggered or manually triggered??
Hello @anand.mainali
If you want to leave the plugin available in the Plugins tab, i.e. without using isSystem, then you should use onDocumentContentReady event and wrap your code in it.
@Constantine i’ve tried this:
window.Asc.plugin.init = function () {
main("manuallyClicked");
};
window.Asc.plugin.button = function () {
this.executeCommand("close", "");
};
Asc.plugin.attachEvent("onDocumentContentReady", () => {
main("automaticallyTriggered");
});
but its working when i add below code in config but its triggering both init & onDocumentContentReady:
"plugins": {
"autostart": [
"asc.{0616AE85-5DBE-4B6B-A0A9-4555555555}"
]
}
I wanted to seperate the event if its manually clicked or automatically triggered.
plugins.autostart
simply runs the main functionality of the plugin once editor is ready.
This sample does not invoke the event, it is incorrect usage. Here is an example for the reference:
window.Asc.plugin.event_onDocumentContentReady = function() {
var oProperties = {
"searchString" : "ONLYOFFICE",
"replaceString" : "ONLYOFFICE is cool",
"matchCase" : false
};
window.Asc.plugin.executeMethod("SearchAndReplace", [oProperties], function() {
window.Asc.plugin.executeCommand("close", "");
});
};