drawio.html 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <!-- draw.io -->
  2. {% if getConfig('crowi', 'app:drawioUri') %}
  3. <script type="text/javascript">
  4. // refs: https://github.com/jgraph/drawio/blob/v13.4.3/etc/build/build.xml#L35-L38
  5. let url = new URL("{{ getConfig('crowi', 'app:drawioUri') }}");
  6. let origin = url.origin;
  7. window.DRAWIO_BASE_URL = origin;
  8. window.DRAWIO_LIGHTBOX_URL = origin;
  9. window.STENCIL_PATH = [origin, 'stencils'].join('/');
  10. window.SHAPES_PATH = [origin, 'shapes'].join('/');
  11. window.mxBasePath = [origin, 'mxgraph'].join('/');
  12. </script>
  13. {% endif %}
  14. <script type="text/javascript">
  15. // define callback function invoked by viewer.min.js of draw.io
  16. // refs: https://github.com/jgraph/drawio/blob/v12.9.1/etc/build/build.xml#L219-L232
  17. window.onDrawioViewerLoad = function() {
  18. const DrawioViewer = window.GraphViewer;
  19. if (DrawioViewer != null) {
  20. // disable useResizeSensor and checkVisibleState
  21. // for preventing resize event by viewer.min.js
  22. DrawioViewer.useResizeSensor = false;
  23. DrawioViewer.prototype.checkVisibleState = false;
  24. // Set responsive option.
  25. // refs: https://github.com/jgraph/drawio/blob/v13.9.1/src/main/webapp/js/diagramly/GraphViewer.js#L89-L95
  26. DrawioViewer.prototype.responsive = true;
  27. // Set z-index ($zindex-dropdown + 200) for lightbox.
  28. // 'lightbox' is like a modal dialog that appears when click on a drawio diagram.
  29. // z-index refs: https://github.com/twbs/bootstrap/blob/v4.6.2/scss/_variables.scss#L681
  30. DrawioViewer.prototype.lightboxZIndex = 1200;
  31. DrawioViewer.prototype.toolbarZIndex = 1200;
  32. }
  33. };
  34. </script>