diff --git a/app/Uploads/Attachment.php b/app/Uploads/Attachment.php index 6e55003a9..3367594ef 100644 --- a/app/Uploads/Attachment.php +++ b/app/Uploads/Attachment.php @@ -38,4 +38,14 @@ class Attachment extends Ownable } return url('/attachments/' . $this->id); } + + public function htmlLink(): string + { + return ''.e($this->name).''; + } + + public function markdownLink(): string + { + + } } diff --git a/resources/js/components/sortable-list.js b/resources/js/components/sortable-list.js index d2b39ff95..db50352b8 100644 --- a/resources/js/components/sortable-list.js +++ b/resources/js/components/sortable-list.js @@ -2,6 +2,11 @@ import Sortable from "sortablejs"; /** * SortableList + * + * Can have data set on the dragged items by setting a 'data-drag-content' attribute. + * This attribute must contain JSON where the keys are content types and the values are + * the data to set on the data-transfer. + * * @extends {Component} */ class SortableList { @@ -14,7 +19,21 @@ class SortableList { animation: 150, onSort: () => { this.$emit('sort', {ids: sortable.toArray()}); - } + }, + setData(dataTransferItem, dragEl) { + console.log('cat'); + const jsonContent = dragEl.getAttribute('data-drag-content'); + if (jsonContent) { + const contentByType = JSON.parse(jsonContent); + dataTransferItem.setData('bookstack/json', jsonContent); + for (const [type, content] of Object.entries(contentByType)) { + dataTransferItem.setData(type, content); + } + } + }, + revertOnSpill: true, + dropBubble: true, + dragoverBubble: false, }); } } diff --git a/resources/js/components/wysiwyg-editor.js b/resources/js/components/wysiwyg-editor.js index 98a5e95c4..92a678fbd 100644 --- a/resources/js/components/wysiwyg-editor.js +++ b/resources/js/components/wysiwyg-editor.js @@ -639,6 +639,7 @@ class WysiwygEditor { }); editor.on('drop', function (event) { + console.log('drop') let dom = editor.dom, rng = tinymce.dom.RangeUtils.getCaretRangeFromPoint(event.clientX, event.clientY, editor.getDoc()); diff --git a/resources/views/attachments/manager-list.blade.php b/resources/views/attachments/manager-list.blade.php index 06ab5f912..671864a3b 100644 --- a/resources/views/attachments/manager-list.blade.php +++ b/resources/views/attachments/manager-list.blade.php @@ -3,6 +3,7 @@