Debug the JS functions which transfer to "window.Asc.plugin.callCommand" method

Hello everyone!
I test plugins for editor and my next question about debugging of the js code in devtools.
My plugin has the next code:

(function(window, undefined) {

	window.Asc.plugin.init = function() {
		var comment = document.getElementById("textareaIDComment");
		document.getElementById("buttonIDAddComment").onclick = function() {
			Asc.scope.textComment = comment.value; // export variable to plugin scope
			window.Asc.plugin.callCommand(filling, true);
		};
	};
	
	window.Asc.plugin.button = function() {
		this.executeCommand("close", "");
	};
	
	function filling()
	{
		//here is something code
        };

})(window, undefined);

When i try see work of the program step-by-step in debugger i see that my filling function transfer to the “window.Asc.plugin.callCommand” method and that is all. Next step is result of my function on the table sheet. As i understand my filling function transfer to callCommand method as instance not as link and i can’t see debugging in my main js code.

May be i not understand logic of work JS and i want your advise.

How i can debug the code which is under comment “here is something …” of the code above?

Hello @Vasily

If understand your request correctly, you want to be able to debug your plugin from a certain position. I think you can use debugger; command for this case. This command works as a breakpoint and pauses the execution at the script point where this command is inserted.

Here is an example how this can be used:

                function filling() {
					debugger;
                    var oDocument = Api.GetDocument();
                    var oParagraph = Api.CreateParagraph();
                    ...
                };

Please note that the debugger; command will only work if the development tools are open. Otherwise, the browser will ignore it.

Let me know if it is not what you are looking for.

Yes! This is what I was looking for! Thank you!

Only one question. Why breakpoints doesn’t work in devtool when i mark the row in the code? It stop only if code has “debugger”…

I’m glad to hear it.
The debugger; is equivalent to a line-of-code breakpoint, except that the breakpoint is set in your code, not in the DevTools UI.