diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index b54cd4f37..43f9f3d8c 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -23,7 +23,7 @@ /> {{ form.contentLength }}/{{ contentMax }} - + +import tippy from 'tippy.js' + +export default { + props: { + content: Object, + node: Object, + }, + methods: { + displayContextMenu(target, content, type) { + const placement = type === 'link' ? 'right' : 'top-start' + const trigger = type === 'link' ? 'click' : 'mouseenter' + const showOnInit = type !== 'link' + + if (this.menu) { + return + } + + this.menu = tippy(target, { + arrow: true, + arrowType: 'round', + content: content, + duration: [400, 200], + inertia: true, + interactive: true, + placement, + showOnInit, + theme: 'human-connection', + trigger, + onMount(instance) { + const input = instance.popper.querySelector('input') + + if (input) { + input.focus({ preventScroll: true }) + } + }, + }) + + // we have to update tippy whenever the DOM is updated + if (MutationObserver) { + this.observer = new MutationObserver(() => { + this.menu.popperInstance.scheduleUpdate() + }) + this.observer.observe(content, { + childList: true, + subtree: true, + characterData: true, + }) + } + }, + hideContextMenu() { + if (this.menu) { + this.menu.destroy() + this.menu = null + } + if (this.observer) { + this.observer.disconnect() + } + }, + }, + render() { + return null + }, +} + + + diff --git a/webapp/components/Editor/Editor.vue b/webapp/components/Editor/Editor.vue index 7791facb6..33fe6b5d4 100644 --- a/webapp/components/Editor/Editor.vue +++ b/webapp/components/Editor/Editor.vue @@ -1,203 +1,52 @@ - - - - - - @{{ item.slug }} - #{{ item.id }} - - - - - {{ $t('editor.hashtag.addHashtag') }} - #{{ query }} - - - - {{ $t('editor.hashtag.addLetter') }} - - - - - - - {{ $t('editor.mention.noUsersFound') }} - - - - {{ $t('editor.hashtag.noHashtagsFound') }} - - - - {{ $t('editor.hashtag.addHashtag') }} - #{{ query }} - - - - - - - - - - - - - {}" - @mousedown.native.prevent="commands.bold" - > - - - - {}" - @mousedown.native.prevent="commands.italic" - > - - - - {}" - @mousedown.native.prevent="showLinkMenu(getMarkAttrs('link'))" - > - - - - - - - - - - - - - - - H3 - - - - H4 - - - - - - - - - - - - - - - - - - - - + + + + + diff --git a/webapp/components/Editor/LinkInput.vue b/webapp/components/Editor/LinkInput.vue new file mode 100644 index 000000000..dede19302 --- /dev/null +++ b/webapp/components/Editor/LinkInput.vue @@ -0,0 +1,33 @@ + + + + + + + diff --git a/webapp/components/Editor/MenuBar.vue b/webapp/components/Editor/MenuBar.vue new file mode 100644 index 000000000..4e43050e9 --- /dev/null +++ b/webapp/components/Editor/MenuBar.vue @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/webapp/components/Editor/MenuBarButton.vue b/webapp/components/Editor/MenuBarButton.vue new file mode 100644 index 000000000..49e480ca5 --- /dev/null +++ b/webapp/components/Editor/MenuBarButton.vue @@ -0,0 +1,16 @@ + + + {{ label }} + + + + diff --git a/webapp/components/Editor/SuggestionList.vue b/webapp/components/Editor/SuggestionList.vue new file mode 100644 index 000000000..b351e6b74 --- /dev/null +++ b/webapp/components/Editor/SuggestionList.vue @@ -0,0 +1,96 @@ + + + + {{ createItemLabel(item) }} + + + + {{ $t('editor.hashtag.addLetter') }} + + + {{ $t('editor.hashtag.addHashtag') }} + #{{ query }} + + + + + {{ $t('editor.mention.noUsersFound') }} + + + + + + + + diff --git a/webapp/constants/editor.js b/webapp/constants/editor.js new file mode 100644 index 000000000..ac4e53641 --- /dev/null +++ b/webapp/constants/editor.js @@ -0,0 +1,2 @@ +export const HASHTAG = 'hashtag' +export const MENTION = 'mention' diff --git a/webapp/constants/keycodes.js b/webapp/constants/keycodes.js new file mode 100644 index 000000000..b34eb8dbe --- /dev/null +++ b/webapp/constants/keycodes.js @@ -0,0 +1,4 @@ +export const ARROW_UP = 38 +export const ARROW_DOWN = 40 +export const RETURN = 13 +export const SPACE = 32