Răsfoiți Sursa

minimize diff of PR

Yuki Takei 1 an în urmă
părinte
comite
cc5b385083

+ 34 - 35
packages/editor/src/client/components-internal/CodeMirrorEditor/CodeMirrorEditor.tsx

@@ -84,41 +84,6 @@ export const CodeMirrorEditor = (props: Props): JSX.Element => {
 
 
   }, [codeMirrorEditor, indentSize]);
   }, [codeMirrorEditor, indentSize]);
 
 
-  useEffect(() => {
-
-    const handleDrop = (event: DragEvent) => {
-      // prevents conflicts between codemirror and react-dropzone during file drops.
-      event.preventDefault();
-    };
-
-    const extension = EditorView.domEventHandlers({
-      drop: handleDrop,
-    });
-
-    const cleanupFunction = codeMirrorEditor?.appendExtensions(extension);
-    return cleanupFunction;
-
-  }, [codeMirrorEditor]);
-
-  useEffect(() => {
-
-    const handleScroll = (event: Event) => {
-      event.preventDefault();
-      if (onScroll != null) {
-        onScroll();
-      }
-    };
-
-    const extension = EditorView.domEventHandlers({
-      scroll: handleScroll,
-    });
-
-    const cleanupFunction = codeMirrorEditor?.appendExtensions(extension);
-    return cleanupFunction;
-
-  }, [onScroll, codeMirrorEditor]);
-
-
   useEffect(() => {
   useEffect(() => {
     const handlePaste = (event: ClipboardEvent) => {
     const handlePaste = (event: ClipboardEvent) => {
       event.preventDefault();
       event.preventDefault();
@@ -157,6 +122,40 @@ export const CodeMirrorEditor = (props: Props): JSX.Element => {
 
 
   }, [codeMirrorEditor, editorSettings?.pasteMode, onUpload]);
   }, [codeMirrorEditor, editorSettings?.pasteMode, onUpload]);
 
 
+  useEffect(() => {
+
+    const handleDrop = (event: DragEvent) => {
+      // prevents conflicts between codemirror and react-dropzone during file drops.
+      event.preventDefault();
+    };
+
+    const extension = EditorView.domEventHandlers({
+      drop: handleDrop,
+    });
+
+    const cleanupFunction = codeMirrorEditor?.appendExtensions(extension);
+    return cleanupFunction;
+
+  }, [codeMirrorEditor]);
+
+  useEffect(() => {
+
+    const handleScroll = (event: Event) => {
+      event.preventDefault();
+      if (onScroll != null) {
+        onScroll();
+      }
+    };
+
+    const extension = EditorView.domEventHandlers({
+      scroll: handleScroll,
+    });
+
+    const cleanupFunction = codeMirrorEditor?.appendExtensions(extension);
+    return cleanupFunction;
+
+  }, [onScroll, codeMirrorEditor]);
+
   const {
   const {
     getRootProps,
     getRootProps,
     getInputProps,
     getInputProps,