Closed koboldMaki closed 2 years ago
Hi @koboldMaki, thanks for reporting the issue.
The error was caused by a change in an external javascript from embed.diagrams.net
(drawio site) which is included and patched runtime, used to render diagrams in XML format.
Sorry for this, but I don't have control on those files...
just add this code:
var searchRegex = /(mxEvent\.addListener\([^,]+,[^,]+),([ a-zA-Z0-9]+)(\))/g;
var replaceRules = "$1,(typeof($2)=='string')?eval($2):$2$3"
code = code.replaceAll(searchRegex, replaceRules);
above assets/javascripts/drawioEditor.js:568
// Apply the patch
GraphViewer.prototype.addToolbar = eval("("+code+")");
thanks for you great works, @mikitex70
Works great, big thanks!
Hi @gavin887, your fix works fine but if think it may touch too many places. With your code I realized that the only important code to fix is:
mxEvent.addListener(g,"click",b);
which is near the beginning of the script, easier to find and less likely to be interrupted by new lines (which was the cause of this issue). So I came to this patch code:
// Patch the code
var code = GraphViewer.prototype.addToolbar.toString();
var searchRegex = /mxEvent\.addListener\(([a-zA-Z]),"click",([a-zA-Z])\)/;
var replaceRules = "mxEvent.addListener($1,\"click\",(typeof($2)==='string'?eval($2):$2))";
code = code.replace(searchRegex, replaceRules);
// Apply the patch
GraphViewer.prototype.addToolbar = eval("("+code+")");
It wiill be included in the next release. Thanks again for your suggestion, which suggested a simpler and more stable code.
Hello. I've noticed that a recent diagrams.net update caused this error to return. There is a following line in the minified JS now:
mxEvent.addListener(I, "click", ea);
Variable name "ea" is not being caught by the regular expression in drawioEditor.js, as it only matches single letter names. I suggest changing it to:
var searchRegex = /mxEvent\.addListener\(([a-zA-Z]+),"click",([a-zA-Z]+)\)/;
Solved, thanks for reporting the issue.
Please, next time open a new report, it is easier to track changes in the CHANGELOG
:smiley:.
Following error occurs when attaching an XML or drawio drawing on any redmine page:
Failed to execute 'addEventListener' on 'EventTarget': parameter 2 is not of type 'Object'.
Error occurs also at redmine_drawio 1.1.4 i used before patch to 1.2.0 today but before holidays all works fine.