From c9b7d0a83991f6b41166931285d6315c119eccd9 Mon Sep 17 00:00:00 2001 From: Ryan McKay-Fleming Date: Tue, 24 Sep 2019 14:04:46 -0400 Subject: [PATCH 1/7] Allow for MenuBubbles appearing below the selection --- packages/tiptap/src/Plugins/MenuBubble.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/tiptap/src/Plugins/MenuBubble.js b/packages/tiptap/src/Plugins/MenuBubble.js index 1e2f9e70..df2e6fe1 100644 --- a/packages/tiptap/src/Plugins/MenuBubble.js +++ b/packages/tiptap/src/Plugins/MenuBubble.js @@ -66,6 +66,7 @@ class Menu { this.isActive = false this.left = 0 this.bottom = 0 + this.top = 0 // the mousedown event is fired before blur so we can prevent it this.options.element.addEventListener('mousedown', this.handleClick) @@ -129,6 +130,7 @@ class Menu { this.left = Math.round(this.options.keepInBounds ? Math.min(box.width - (el.width / 2), Math.max(left, el.width / 2)) : left) this.bottom = Math.round(box.bottom - start.top) + this.top = Math.round(end.bottom - box.top) this.isActive = true this.sendUpdate() @@ -139,6 +141,7 @@ class Menu { isActive: this.isActive, left: this.left, bottom: this.bottom, + top: this.top, }) } From 8cce2508a9aad73fd2597539b20f1e89cd462a67 Mon Sep 17 00:00:00 2001 From: Chrissi2812 Date: Wed, 2 Oct 2019 15:47:41 +0200 Subject: [PATCH 2/7] set selection to first cell after table insert fixes #447 --- packages/tiptap-extensions/src/nodes/Table.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/tiptap-extensions/src/nodes/Table.js b/packages/tiptap-extensions/src/nodes/Table.js index 90540757..fcc8d803 100644 --- a/packages/tiptap-extensions/src/nodes/Table.js +++ b/packages/tiptap-extensions/src/nodes/Table.js @@ -19,6 +19,7 @@ import { fixTables, } from 'prosemirror-tables' import { createTable } from 'prosemirror-utils' +import { TextSelection } from 'prosemirror-state' import TableNodes from './TableNodes' export default class Table extends Node { @@ -43,6 +44,11 @@ export default class Table extends Node { (state, dispatch) => { const nodes = createTable(schema, rowsCount, colsCount, withHeaderRow) const tr = state.tr.replaceSelectionWith(nodes).scrollIntoView() + + // get selection for first cell + const resolvedPos = tr.doc.resolve(tr.selection.anchor - nodes.content.size) + tr.setSelection(TextSelection.near(resolvedPos)) + dispatch(tr) } ), From 527a7443f14a532ddefe9d612a7bafc6af7846d4 Mon Sep 17 00:00:00 2001 From: Christopher Brown Date: Thu, 3 Oct 2019 10:51:08 +0200 Subject: [PATCH 3/7] fix(menu-bubble-hide): only send hide update, target not child of editor --- packages/tiptap/src/Plugins/MenuBubble.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tiptap/src/Plugins/MenuBubble.js b/packages/tiptap/src/Plugins/MenuBubble.js index 1e2f9e70..60245b86 100644 --- a/packages/tiptap/src/Plugins/MenuBubble.js +++ b/packages/tiptap/src/Plugins/MenuBubble.js @@ -143,7 +143,7 @@ class Menu { } hide(event) { - if (event && event.relatedTarget) { + if (event && event.relatedTarget && this.options.element.parentNode.contains(event.relatedTarget)) { return } From cfa506e89effc5c95f2c789687cad0c1a614e9fb Mon Sep 17 00:00:00 2001 From: Christopher Brown Date: Thu, 3 Oct 2019 11:01:22 +0200 Subject: [PATCH 4/7] refactor(menu-bubble-hide): break conditional to multiple lines --- packages/tiptap/src/Plugins/MenuBubble.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/tiptap/src/Plugins/MenuBubble.js b/packages/tiptap/src/Plugins/MenuBubble.js index 60245b86..e2e1fd43 100644 --- a/packages/tiptap/src/Plugins/MenuBubble.js +++ b/packages/tiptap/src/Plugins/MenuBubble.js @@ -143,7 +143,8 @@ class Menu { } hide(event) { - if (event && event.relatedTarget && this.options.element.parentNode.contains(event.relatedTarget)) { + if (event && event.relatedTarget + && this.options.element.parentNode.contains(event.relatedTarget)) { return } From 483fe114347e0f55d53b6883fd65900b73f2e95d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Thu, 3 Oct 2019 11:50:43 +0200 Subject: [PATCH 5/7] refactoring --- packages/tiptap/src/Plugins/FloatingMenu.js | 5 ++++- packages/tiptap/src/Plugins/MenuBubble.js | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/tiptap/src/Plugins/FloatingMenu.js b/packages/tiptap/src/Plugins/FloatingMenu.js index de3a04ed..0775b921 100644 --- a/packages/tiptap/src/Plugins/FloatingMenu.js +++ b/packages/tiptap/src/Plugins/FloatingMenu.js @@ -91,7 +91,10 @@ class Menu { } hide(event) { - if (event && event.relatedTarget) { + if (event + && event.relatedTarget + && this.options.element.parentNode.contains(event.relatedTarget) + ) { return } diff --git a/packages/tiptap/src/Plugins/MenuBubble.js b/packages/tiptap/src/Plugins/MenuBubble.js index be32049b..21f510f1 100644 --- a/packages/tiptap/src/Plugins/MenuBubble.js +++ b/packages/tiptap/src/Plugins/MenuBubble.js @@ -146,8 +146,10 @@ class Menu { } hide(event) { - if (event && event.relatedTarget - && this.options.element.parentNode.contains(event.relatedTarget)) { + if (event + && event.relatedTarget + && this.options.element.parentNode.contains(event.relatedTarget) + ) { return } 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 6/7] 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 00000000..66ed3c00 --- /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 00000000..dbcaec96 --- /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 f1a05f92..a4a77345 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 8ee8e3e7..e873023f 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'), From c2b99e25d9d011cf0c5d8de744ba43807a99c3ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Thu, 3 Oct 2019 15:58:07 +0200 Subject: [PATCH 7/7] Publish - tiptap-extensions@1.28.1 - tiptap@1.26.1 --- packages/tiptap-extensions/package.json | 4 ++-- packages/tiptap/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/tiptap-extensions/package.json b/packages/tiptap-extensions/package.json index 50182e68..a0e59a3f 100644 --- a/packages/tiptap-extensions/package.json +++ b/packages/tiptap-extensions/package.json @@ -1,6 +1,6 @@ { "name": "tiptap-extensions", - "version": "1.28.0", + "version": "1.28.1", "description": "Extensions for tiptap", "homepage": "https://tiptap.scrumpy.io", "license": "MIT", @@ -30,7 +30,7 @@ "prosemirror-transform": "^1.1.4", "prosemirror-utils": "^0.9.6", "prosemirror-view": "^1.11.4", - "tiptap": "^1.26.0", + "tiptap": "^1.26.1", "tiptap-commands": "^1.12.0" }, "peerDependencies": { diff --git a/packages/tiptap/package.json b/packages/tiptap/package.json index b207978e..ab88ad7e 100644 --- a/packages/tiptap/package.json +++ b/packages/tiptap/package.json @@ -1,6 +1,6 @@ { "name": "tiptap", - "version": "1.26.0", + "version": "1.26.1", "description": "A rich-text editor for Vue.js", "homepage": "https://tiptap.scrumpy.io", "license": "MIT",