From cb2ac95a73680a339125af2cbb8ccd74126b60e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 28 Sep 2018 23:05:34 +0200 Subject: [PATCH] rename mentions to suggestions --- .../{Mentions => Suggestions}/index.vue | 43 +++++++++++++------ examples/Components/Subnavigation/index.vue | 4 +- examples/main.js | 6 +-- 3 files changed, 34 insertions(+), 19 deletions(-) rename examples/Components/Routes/{Mentions => Suggestions}/index.vue (80%) diff --git a/examples/Components/Routes/Mentions/index.vue b/examples/Components/Routes/Suggestions/index.vue similarity index 80% rename from examples/Components/Routes/Mentions/index.vue rename to examples/Components/Routes/Suggestions/index.vue index ec756fcd..e9d700df 100644 --- a/examples/Components/Routes/Mentions/index.vue +++ b/examples/Components/Routes/Suggestions/index.vue @@ -4,10 +4,13 @@

- Mentions + Suggestions

- Yeah Philipp Kühn and Hans Pagel. + Sometimes it's useful to mention someone. That's a feature we're very used to. Under the hood this technique can also be used for other features likes hashtags and commands – lets call it suggestions. +

+

+ This is an example how to mention some users like Philipp Kühn or Hans Pagel. Try to type @ and a popup (rendered with tippy.js) will appear. You can navigate with arrow keys through a list of suggestions.

@@ -40,6 +43,9 @@ import { HardBreakNode, HeadingNode, MentionNode, + CodeMark, + BoldMark, + ItalicMark, } from 'tiptap-extensions' export default { @@ -62,25 +68,33 @@ export default { name: 'Hans Pagel', id: 2, }, + { + name: 'Kris Siepert', + id: 3, + }, + { + name: 'Justin Schüler', + id: 4, + }, ], onEnter: ({ items, query, range, command, virtualNode }) => { this.query = query this.filteredUsers = items this.pos = range this.insertMention = command - this.renderDropdown(virtualNode) + this.renderPopup(virtualNode) }, onChange: ({ items, query, range, virtualNode }) => { this.query = query this.filteredUsers = items this.pos = range - this.renderDropdown(virtualNode) + this.renderPopup(virtualNode) }, onExit: () => { this.query = null this.filteredUsers = [] this.pos = null - this.destroyDropdown() + this.destroyPopup() }, onKeyDown: ({ event }) => { // pressing up arrow @@ -116,6 +130,9 @@ export default { return fuse.search(query) }, }), + new CodeMark(), + new BoldMark(), + new ItalicMark(), ], query: null, pos: null, @@ -147,12 +164,12 @@ export default { }, }) }, - renderDropdown(node) { - if (this.dropdown) { + renderPopup(node) { + if (this.popup) { return } - this.dropdown = tippy(node, { + this.popup = tippy(node, { content: this.$refs.suggestions, trigger: 'mouseenter', interactive: true, @@ -166,10 +183,10 @@ export default { arrowType: 'round', }) }, - destroyDropdown() { - if (this.dropdown) { - this.dropdown.destroyAll() - this.dropdown = null + destroyPopup() { + if (this.popup) { + this.popup.destroyAll() + this.popup = null } }, }, @@ -215,7 +232,6 @@ export default { } .tippy-tooltip.dark-theme { - background-color: $color-black; padding: 0; font-size: 1rem; @@ -246,6 +262,5 @@ export default { .tippy-popper[x-placement^=right] & .tippy-arrow { border-right-color: $color-black; } - } diff --git a/examples/Components/Subnavigation/index.vue b/examples/Components/Subnavigation/index.vue index 162ee95c..7f1305cf 100644 --- a/examples/Components/Subnavigation/index.vue +++ b/examples/Components/Subnavigation/index.vue @@ -33,8 +33,8 @@ Embeds - - Mentions + + Suggestions Placeholder diff --git a/examples/main.js b/examples/main.js index 877cd458..edb57a34 100644 --- a/examples/main.js +++ b/examples/main.js @@ -90,10 +90,10 @@ const routes = [ }, }, { - path: '/mentions', - component: () => import('Components/Routes/Mentions'), + path: '/suggestions', + component: () => import('Components/Routes/Suggestions'), meta: { - githubUrl: 'https://github.com/heyscrumpy/tiptap/tree/master/examples/Components/Routes/Mentions', + githubUrl: 'https://github.com/heyscrumpy/tiptap/tree/master/examples/Components/Routes/Suggestions', }, }, {