From 2d1778b32feb39350fe3a77f91e9140f0e6a64cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Thu, 3 Oct 2019 15:56:41 +0200 Subject: [PATCH] add drag handle example --- .../Components/Routes/DragHandle/DragItem.js | 32 +++++++++ .../Components/Routes/DragHandle/index.vue | 70 +++++++++++++++++++ examples/Components/Subnavigation/index.vue | 3 + examples/main.js | 7 ++ 4 files changed, 112 insertions(+) create mode 100644 examples/Components/Routes/DragHandle/DragItem.js create mode 100644 examples/Components/Routes/DragHandle/index.vue diff --git a/examples/Components/Routes/DragHandle/DragItem.js b/examples/Components/Routes/DragHandle/DragItem.js new file mode 100644 index 000000000..66ed3c003 --- /dev/null +++ b/examples/Components/Routes/DragHandle/DragItem.js @@ -0,0 +1,32 @@ +import { Node } from 'tiptap' + +export default class DragItem extends Node { + + get name() { + return 'drag_item' + } + + get schema() { + return { + group: 'block', + draggable: true, + content: 'paragraph+', + toDOM: () => ['div', { 'data-type': this.name }, 0], + parseDOM: [{ + tag: `[data-type="${this.name}"]`, + }], + } + } + + get view() { + return { + template: ` +
+
+
+
+ `, + } + } + +} diff --git a/examples/Components/Routes/DragHandle/index.vue b/examples/Components/Routes/DragHandle/index.vue new file mode 100644 index 000000000..dbcaec96f --- /dev/null +++ b/examples/Components/Routes/DragHandle/index.vue @@ -0,0 +1,70 @@ + + + + + diff --git a/examples/Components/Subnavigation/index.vue b/examples/Components/Subnavigation/index.vue index f1a05f929..a4a773455 100644 --- a/examples/Components/Subnavigation/index.vue +++ b/examples/Components/Subnavigation/index.vue @@ -60,6 +60,9 @@ Trailing Paragraph + + Drag Handle + Export HTML or JSON diff --git a/examples/main.js b/examples/main.js index 8ee8e3e74..e873023f6 100644 --- a/examples/main.js +++ b/examples/main.js @@ -151,6 +151,13 @@ const routes = [ githubUrl: 'https://github.com/scrumpy/tiptap/tree/master/examples/Components/Routes/TrailingParagraph', }, }, + { + path: '/drag-handle', + component: () => import('Components/Routes/DragHandle'), + meta: { + githubUrl: 'https://github.com/scrumpy/tiptap/tree/master/examples/Components/Routes/DragHandle', + }, + }, { path: '/export', component: () => import('Components/Routes/Export'),