xiongzhu před 4 roky
rodič
revize
06e2c2e162
1 změnil soubory, kde provedl 29 přidání a 0 odebrání
  1. 29 0
      src/main/vue/src/components/RichText.vue

+ 29 - 0
src/main/vue/src/components/RichText.vue

@@ -65,6 +65,35 @@ export default {
                 },
                 init_instance_callback: editor => {
                     this.editor = editor;
+                },
+                file_picker_types: 'media',
+                relative_urls: false,
+                remove_script_host: false,
+                convert_urls: true,
+                file_picker_callback: (cb, value, meta) => {
+                    var input = document.createElement('input');
+                    input.setAttribute('type', 'file');
+                    input.setAttribute('accept', 'video/*');
+                    input.onchange = e => {
+                        var file = input.files[0];
+
+                        var reader = new FileReader();
+                        reader.readAsDataURL(file);
+                        reader.onload = () => {
+                            let formData = new FormData();
+                            formData.append('file', file);
+                            this.$axios
+                                .post('/upload/file', formData)
+                                .then(res => {
+                                    cb(res.data);
+                                })
+                                .catch(e => {
+                                    console.log(e);
+                                });
+                        };
+                    };
+
+                    input.click();
                 }
             },
             editor: null,