Yuki Takei пре 7 година
родитељ
комит
81c04e2daf
1 измењених фајлова са 18 додато и 15 уклоњено
  1. 18 15
      resource/js/agent-for-hackmd.js

+ 18 - 15
resource/js/agent-for-hackmd.js

@@ -92,6 +92,23 @@ function addEventListenersToCodemirror() {
   delete editor.options.extraKeys['Ctrl-S'];
 }
 
+function connectToParentWithPenpal() {
+  const connection = Penpal.connectToParent({
+    parentOrigin: allowedOrigin,
+    // Methods child is exposing to parent
+    methods: {
+      getValue() {
+        return getValueOfCodemirror();
+      },
+      setValue(newValue) {
+        setValueToCodemirror(newValue);
+      },
+    }
+  });
+  connection.promise.then(parent => {
+    window.growi = parent;
+  });
+}
 
 /**
  * main
@@ -112,21 +129,7 @@ function addEventListenersToCodemirror() {
     addEventListenersToCodemirror();
   });
 
-  const connection = Penpal.connectToParent({
-    parentOrigin: allowedOrigin,
-    // Methods child is exposing to parent
-    methods: {
-      getValue() {
-        return getValueOfCodemirror();
-      },
-      setValue(newValue) {
-        setValueToCodemirror(newValue);
-      },
-    }
-  });
-  connection.promise.then(parent => {
-    window.growi = parent;
-  });
+  connectToParentWithPenpal();
 
   console.log('[HackMD] GROWI agent for HackMD has successfully loaded.');
 }());