Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
🐛 (#2842): use menu bar as container for emoji and list actions
Signed-off-by: Vinicius Reis <[email protected]>
  • Loading branch information
Vinicius Reis authored and vinicius73 committed Sep 29, 2022
commit 17c2da24267ba5e9edffc7bbe8abcc4bb29d0221
4 changes: 3 additions & 1 deletion src/components/Menu/ActionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
class="entry-list-action entry-action"
role="menu"
v-bind="state"
:container="menuIDSelector"
:aria-label="actionEntry.label"
:title="actionEntry.label"
:data-text-action-entry="actionEntry.key"
Expand All @@ -48,12 +49,13 @@ import ActionSingle from './ActionSingle.vue'
import { getIsActive } from './utils.js'
import { useOutlineStateMixin } from '../Editor/Wrapper.provider.js'
import useStore from '../../mixins/store.js'
import { useMenuIDMixin } from './MenuBar.provider.js'

export default {
name: 'ActionList',
components: { NcActions, ActionSingle },
extends: BaseActionEntry,
mixins: [useStore, useOutlineStateMixin],
mixins: [useStore, useOutlineStateMixin, useMenuIDMixin],
computed: {
currentChild() {
const {
Expand Down
7 changes: 4 additions & 3 deletions src/components/Menu/EmojiPickerAction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<template>
<NcEmojiPicker class="entry-action entry-action__emoji"
:data-text-action-entry="actionEntry.key"
:container="menuIDSelector"
@selectData="addEmoji">
<NcButton v-tooltip="actionEntry.label"
class="entry-action__button"
Expand All @@ -39,6 +40,7 @@
<script>
import { BaseActionEntry } from './BaseActionEntry.js'
import { NcEmojiPicker, NcButton } from '@nextcloud/vue'
import { useMenuIDMixin } from './MenuBar.provider.js'

export default {
name: 'EmojiPickerAction',
Expand All @@ -47,11 +49,10 @@ export default {
NcButton,
},
extends: BaseActionEntry,
mixins: [useMenuIDMixin],
methods: {
toggleChildMenu() {

},
addEmoji({ id, native }) {
console.log({ id, native })
this.actionEntry
.action(this.$editor.chain(), { id, native })
.focus()
Expand Down
12 changes: 12 additions & 0 deletions src/components/Menu/MenuBar.provider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const MENU_ID = Symbol('menu::id')

export const useMenuIDMixin = {
inject: {
$menuID: { from: MENU_ID, default: null },
},
computed: {
menuIDSelector() {
return `#${this.$menuID}`
},
},
}
16 changes: 15 additions & 1 deletion src/components/Menu/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
-->

<template>
<div class="text-menubar"
<div :id="randomID"
class="text-menubar"
data-text-el="menubar"
role="menubar"
:aria-label="t('text', 'Formatting menu bar')"
Expand Down Expand Up @@ -57,6 +58,7 @@ import debounce from 'debounce'
import HelpModal from '../HelpModal.vue'
import actionsFullEntries from './entries.js'
import ActionEntry from './ActionEntry.js'
import { MENU_ID } from './MenuBar.provider.js'
import { DotsHorizontal } from '../icons.js'
import {
useEditorMixin,
Expand All @@ -72,6 +74,17 @@ export default {
useIsRichEditorMixin,
useIsRichWorkspaceMixin,
],
provide() {
const val = {}

Object.defineProperties(val, {
[MENU_ID]: {
get: () => this.randomID,
},
})

return val
},
props: {
autohide: {
type: Boolean,
Expand All @@ -80,6 +93,7 @@ export default {
},
data() {
return {
randomID: `menu-bar-${(Math.ceil((Math.random() * 10000) + 500)).toString(16)}`,
displayHelp: false,
forceRecompute: 0,
isReady: false,
Expand Down