]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/attachments.js
Removed parallel testing, updated predis
[bookstack] / resources / js / components / attachments.js
index 51e54054ebabba076089798a3c7591088ac18caa..d8a506270dfcb3c8764364db961d921a9300c24a 100644 (file)
@@ -1,10 +1,7 @@
-/**
- * Attachments
- * @extends {Component}
- */
 import {showLoading} from "../services/dom";
+import {Component} from "./component";
 
-class Attachments {
+export class Attachments extends Component {
 
     setup() {
         this.container = this.$el;
@@ -33,14 +30,25 @@ class Attachments {
         this.container.addEventListener('event-emit-select-edit-back', event => {
             this.stopEdit();
         });
+
+        this.container.addEventListener('event-emit-select-insert', event => {
+            const insertContent = event.target.closest('[data-drag-content]').getAttribute('data-drag-content');
+            const contentTypes = JSON.parse(insertContent);
+            window.$events.emit('editor::insert', {
+                html: contentTypes['text/html'],
+                markdown: contentTypes['text/plain'],
+            });
+        });
     }
 
     reloadList() {
         this.stopEdit();
-        this.mainTabs.components.tabs.show('items');
+        /** @var {Tabs} */
+        const tabs = window.$components.firstOnElement(this.mainTabs, 'tabs');
+        tabs.show('attachment-panel-items');
         window.$http.get(`/attachments/get/page/${this.pageId}`).then(resp => {
             this.list.innerHTML = resp.data;
-            window.components.init(this.list);
+            window.$components.init(this.list);
         });
     }
 
@@ -57,7 +65,7 @@ class Attachments {
         showLoading(this.editContainer);
         const resp = await window.$http.get(`/attachments/edit/${id}`);
         this.editContainer.innerHTML = resp.data;
-        window.components.init(this.editContainer);
+        window.$components.init(this.editContainer);
     }
 
     stopEdit() {
@@ -65,6 +73,4 @@ class Attachments {
         this.listContainer.classList.remove('hidden');
     }
 
-}
-
-export default Attachments;
\ No newline at end of file
+}
\ No newline at end of file