diff --git a/playwright/e2e/mobile.spec.ts b/playwright/e2e/mobile.spec.ts
index c64d4114bb1..f7b7af5ca9b 100644
--- a/playwright/e2e/mobile.spec.ts
+++ b/playwright/e2e/mobile.spec.ts
@@ -23,3 +23,33 @@ test('Formatting help', async ({ editor }) => {
await editor.formattingHelp.getByLabel('Close').click()
await expect(editor.formattingHelp).not.toBeVisible()
})
+
+test.describe('Actions with their own menu in remaining actions', () => {
+ test.beforeEach(async ({ page }) => {
+ // Narrow enough to move link, attachment and emoji into the remaining actions
+ await page.setViewportSize({ width: 280, height: 640 })
+ })
+
+ test('Insert emoji', async ({ editor }) => {
+ await editor.clickMenu('Remain', 'Insert emoji')
+ const picker = editor.el.getByRole('dialog', { name: 'Emoji picker' })
+ await expect(picker).toBeVisible()
+ const search = picker.getByRole('textbox', { name: 'Search' })
+ await search.fill('cat')
+ await expect(picker.getByLabel('🐱, cat')).toHaveClass(/emoji-mart-emoji-selected/)
+ await search.press('Enter')
+ await expect(editor.content).toContainText('🐱')
+ await expect(editor.content).not.toContainText('undefined')
+ })
+
+ test('Insert attachment', async ({ editor }) => {
+ await editor.clickMenu('Remain', 'Insert attachment')
+ await expect(editor.getMenuItem('Upload from computer')).toBeVisible()
+ await expect(editor.getMenuItem('Insert from Files')).toBeVisible()
+ })
+
+ test('Insert link', async ({ editor }) => {
+ await editor.clickMenu('Remain', 'Insert link')
+ await expect(editor.getMenuItem('Link to website')).toBeVisible()
+ })
+})
diff --git a/src/components/Menu/ActionList.vue b/src/components/Menu/ActionList.vue
index 293dbaac6b4..577c5eac3fe 100644
--- a/src/components/Menu/ActionList.vue
+++ b/src/components/Menu/ActionList.vue
@@ -19,10 +19,11 @@
-
-
+
+
!!entry),
+ forcedEntryKey: null,
randomID: `menu-bar-${Math.ceil(Math.random() * 10000 + 500).toString(16)}`,
displayHelp: false,
isReady: false,
@@ -166,10 +167,15 @@ export default {
computed: {
visibleEntryKeys() {
// if entry has no priority, we assume it always will be visible (priority: 0)
- return this.entries
+ const keys = this.entries
.toSorted((a, b) => (a.priority ?? 0) - (b.priority ?? 0))
.map((e) => e.key)
.slice(0, this.iconsLimit)
+ if (this.forcedEntryKey && !keys.includes(this.forcedEntryKey)) {
+ // Make room for the entry that was opened from the remaining actions
+ keys.splice(-1, 1, this.forcedEntryKey)
+ }
+ return keys
},
visibleEntries() {
@@ -186,14 +192,18 @@ export default {
})
const entries = remainingEntries.reduce((acc, entry, index) => {
// If entry has children, merge them into list. Otherwise keep entry itself.
- const children = entry.children ?? [entry]
+ // Entries rendered by their own component cannot run inside the list,
+ // so they are moved into the menu bar and opened there.
+ const children = entry.children ?? [entry.component
+ ? { ...entry, click: () => this.openRemainingEntry(entry.key) }
+ : entry]
// If this block has menu entries, it should be separated for better visibility and a11y (menu item radio grouping)
if (children.length > 1) {
const hasPreviousItem = acc.length && !acc.at(-1).isSeparator
const separatorBefore = hasPreviousItem
? [
{
- key: `separator-before-${entry.id}`,
+ key: `separator-before-${entry.key}`,
isSeparator: true,
},
]
@@ -201,7 +211,7 @@ export default {
const hasNextItem = index !== remainingEntries.length - 1
const separatorAfter = hasNextItem
- ? [{ key: `separator-after-${entry.id}`, isSeparator: true }]
+ ? [{ key: `separator-after-${entry.key}`, isSeparator: true }]
: []
return [
@@ -258,6 +268,18 @@ export default {
this.displayHelp = false
},
+ /**
+ * Show an entry from the remaining actions in the menu bar and open it
+ *
+ * @param {string} key The key of the menu entry
+ */
+ async openRemainingEntry(key) {
+ this.forcedEntryKey = key
+ await this.$nextTick()
+ const index = this.visibleEntries.findIndex((entry) => entry.key === key)
+ this.menuEntryRefs[index]?.openMenu()
+ },
+
collectMenuEntryRef(el, index) {
if (el) {
this.menuEntryRefs[index] = el
diff --git a/src/components/Menu/entries.ts b/src/components/Menu/entries.ts
index 770d16ab3ab..1d5bdd44e71 100644
--- a/src/components/Menu/entries.ts
+++ b/src/components/Menu/entries.ts
@@ -13,7 +13,6 @@ import ActionAttachmentUpload from './ActionAttachmentUpload.vue'
import ActionInsertLink from './ActionInsertLink.vue'
import AssistantAction from './AssistantAction.vue'
import EmojiPickerAction from './EmojiPickerAction.vue'
-import { isMobileDevice } from '../../helpers/isMobileDevice.js'
import {
Asterisk,
CodeBrackets,
@@ -614,10 +613,7 @@ export function getMenuEntries(isRichWorkspace: boolean, annotationsHidden?: Ref
component: markRaw(ActionAttachmentUpload),
priority: 6,
},
- ]
-
- if (!isMobileDevice) {
- menuEntries.push({
+ {
key: 'emoji-picker',
label: t('text', 'Insert emoji'),
icon: Emoticon,
@@ -627,8 +623,8 @@ export function getMenuEntries(isRichWorkspace: boolean, annotationsHidden?: Ref
return command.emoji(emojiObject)
},
priority: 7,
- })
- }
+ },
+ ]
return menuEntries
}