Parcourir la source

modify agent-for-hackmd.js

* return if codemirror or editor is not found
Yuki Takei il y a 7 ans
Parent
commit
8f080e41dc
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5 0
      resource/js/agent-for-hackmd.js

+ 5 - 0
resource/js/agent-for-hackmd.js

@@ -73,6 +73,11 @@ function addEventListenersToCodemirror() {
   // get CodeMirror editor instance
   const editor = window.editor;
 
+  // e.g. 404 not found
+  if (codemirror == null || editor == null) {
+    return;
+  }
+
   //// change event
   editor.on('change', (cm, change) => {
     debouncedPostParentToNotifyBodyChanges(cm.doc.getValue());