Quellcode durchsuchen

Merge pull request #2543 from kaishuu0123/fix/2509-drawio-and-no-cdn-rich-icon

Fix #2509 #2561: cannot be displayed AWS icons when NO_CDN + drawio
Yuki Takei vor 5 Jahren
Ursprung
Commit
1f740dc021

+ 0 - 16
src/client/js/util/interceptor/drawio-interceptor.js

@@ -18,22 +18,6 @@ export class DrawioInterceptor extends BasicInterceptor {
 
 
     this.previousPreviewContext = null;
     this.previousPreviewContext = null;
     this.appContainer = appContainer;
     this.appContainer = appContainer;
-
-    // define callback function invoked by viewer.min.js of draw.io
-    // refs: https://github.com/jgraph/drawio/blob/v12.9.1/etc/build/build.xml#L219-L232
-    window.onDrawioViewerLoad = function() {
-      const DrawioViewer = window.GraphViewer;
-
-      if (DrawioViewer != null) {
-        // disable useResizeSensor and checkVisibleState
-        //   for preventing resize event by viewer.min.js
-        DrawioViewer.useResizeSensor = false;
-        DrawioViewer.prototype.checkVisibleState = false;
-
-        // initialize
-        DrawioViewer.processElements();
-      }
-    };
   }
   }
 
 
   /**
   /**

+ 6 - 0
src/server/service/config-loader.js

@@ -107,6 +107,12 @@ const ENV_VAR_NAME_TO_CONFIG_INFO = {
   //   type:    ,
   //   type:    ,
   //   default:
   //   default:
   // },
   // },
+  DRAWIO_URI: {
+    ns:      'crowi',
+    key:     'app:drawioUri',
+    type:    TYPES.STRING,
+    default: null,
+  },
   NCHAN_URI: {
   NCHAN_URI: {
     ns:      'crowi',
     ns:      'crowi',
     key:     'app:nchanUri',
     key:     'app:nchanUri',

+ 2 - 0
src/server/views/layout/layout.html

@@ -23,6 +23,8 @@
     {% include '../widget/headers/mathjax.html' %}
     {% include '../widget/headers/mathjax.html' %}
   {% endif %}
   {% endif %}
 
 
+  {% include '../widget/headers/drawio.html' %}
+
   {% include '../widget/headers/scripts-for-dev.html' %}
   {% include '../widget/headers/scripts-for-dev.html' %}
 
 
   <script src="{{ webpack_asset('js/boot.js') }}"></script>
   <script src="{{ webpack_asset('js/boot.js') }}"></script>

+ 31 - 0
src/server/views/widget/headers/drawio.html

@@ -0,0 +1,31 @@
+<!-- draw.io -->
+{% if getConfig('crowi', 'app:drawioUri') %}
+<script type="text/javascript">
+  // refs: https://github.com/jgraph/drawio/blob/v13.4.3/etc/build/build.xml#L35-L38
+  let url = new URL("{{ getConfig('crowi', 'app:drawioUri') }}");
+  let origin = url.origin;
+  window.DRAWIO_BASE_URL = origin;
+  window.DRAWIO_LIGHTBOX_URL = origin;
+  window.STENCIL_PATH = [origin, 'stencils'].join('/');
+  window.SHAPES_PATH = [origin, 'shapes'].join('/');
+  window.mxBasePath = [origin, 'mxgraph'].join('/');
+</script>
+{% endif %}
+
+<script type="text/javascript">
+  // define callback function invoked by viewer.min.js of draw.io
+  // refs: https://github.com/jgraph/drawio/blob/v12.9.1/etc/build/build.xml#L219-L232
+  window.onDrawioViewerLoad = function() {
+    const DrawioViewer = window.GraphViewer;
+
+    if (DrawioViewer != null) {
+      // disable useResizeSensor and checkVisibleState
+      //   for preventing resize event by viewer.min.js
+      DrawioViewer.useResizeSensor = false;
+      DrawioViewer.prototype.checkVisibleState = false;
+
+      // initialize
+      DrawioViewer.processElements();
+    }
+  };
+</script>