Jelajahi Sumber

handle paste

fengchang 1 tahun lalu
induk
melakukan
403d15a7e8
1 mengubah file dengan 16 tambahan dan 0 penghapusan
  1. 16 0
      hichina-main-front-mobile-first/src/pages/BlogEditPage.vue

+ 16 - 0
hichina-main-front-mobile-first/src/pages/BlogEditPage.vue

@@ -7,10 +7,12 @@
         </div>
         <div class="col-12 q-mt-xl">
           <QuillEditor
+            @paste="handlePaste"
             theme="snow"
             v-model:content="content"
             contentType="html"
             toolbar="full"
+            ref="quillEditor"
             :modules="combineModule"
           />
         </div>
@@ -66,11 +68,24 @@ export default {
 
     const title = ref("");
     const content = ref("");
+    const savedScrollPosition = ref(null);
 
     const currentBlogId = ref("");
 
     currentBlogId.value = route.params.blogId;
 
+    function handlePaste() {
+      // Save the current scroll position before paste
+      savedScrollPosition.value =
+        instance.refs.quillEditor.quill.root.scrollTop;
+      // Delay the paste operation to ensure the content is available
+      setTimeout(() => {
+        // Restore the scroll position after paste
+        instance.refs.quillEditor.quill.root.scrollTop =
+          savedScrollPosition.value;
+      }, 0);
+    }
+
     const imageUploadModule = {
       name: "imageUploader",
       module: ImageUploader,
@@ -154,6 +169,7 @@ export default {
       title,
       content,
       updateBlog,
+      handlePaste,
       currentBlogId,
       combineModule,
     };