Merge pull request #34195 from overleaf/mj-command-palette-menu-labels

[web] Add menu labels to commands, and add more commands to command palette

GitOrigin-RevId: 21e17142bb3112b5fdcda85a472122b011979f49
This commit is contained in:
Mathias Jakobsen
2026-06-04 14:55:03 +01:00
committed by Copybot
parent cabe0046c5
commit b7735d402d
8 changed files with 62 additions and 14 deletions
@@ -827,6 +827,7 @@
"go_to_next_page": "",
"go_to_overleaf": "",
"go_to_pdf_location_in_code": "",
"go_to_pdf_location_in_code_action": "",
"go_to_previous_page": "",
"go_to_settings": "",
"go_to_subscriptions": "",
@@ -969,15 +970,25 @@
"inr_discount_modal_info": "",
"inr_discount_modal_title": "",
"insert": "",
"insert_citation": "",
"insert_column_left": "",
"insert_column_right": "",
"insert_cross_reference": "",
"insert_display_math": "",
"insert_figure": "",
"insert_figure_from_another_project": "",
"insert_figure_from_computer": "",
"insert_figure_from_project_files": "",
"insert_figure_from_url": "",
"insert_from_another_project": "",
"insert_from_project_files": "",
"insert_from_url": "",
"insert_image": "",
"insert_inline_math": "",
"insert_link": "",
"insert_row_above": "",
"insert_row_below": "",
"insert_table": "",
"insert_x_columns_left": "",
"insert_x_columns_right": "",
"insert_x_rows_above": "",
@@ -1350,6 +1361,7 @@
"open_path": "",
"open_pdf_in_separate_tab": "",
"open_project": "",
"open_settings": "",
"open_target": "",
"optional": "",
"or": "",
@@ -20,6 +20,16 @@ const ENABLED_COMMANDS: string[] = [
'recompile-from-scratch',
'synctex-sync-to-pdf',
'synctex-sync-to-code',
'insert-inline-math',
'insert-display-math',
'insert-figure-from-computer',
'insert-figure-from-project-files',
'insert-figure-from-another-project',
'insert-figure-from-url',
'insert-table',
'insert-citation',
'insert-link',
'insert-cross-reference',
]
const useCommandRegistrySource = (): CommandPaletteSource => {
@@ -180,7 +180,8 @@ export const RailLayout = () => {
handler: () => {
setLeftMenuShown(true)
},
label: t('settings'),
menuLabel: t('settings'),
label: t('open_settings'),
},
],
[t, setLeftMenuShown]
@@ -122,7 +122,7 @@ const CommandDropdownChild = ({ item }: { item: Entry<TaggedCommand> }) => {
<MenuBarOption
eventKey={item.id}
key={item.id}
title={item.label}
title={item.menuLabel ?? item.label}
// eslint-disable-next-line react/jsx-handler-names
onClick={onClickHandler}
href={item.href}
@@ -13,6 +13,8 @@ type CommandInvocationContext = {
export type Command = {
label: string
// Optional label for the command when it appears in a menu. If not provided, `label` will be used.
menuLabel?: string
id: string
handler?: (context: CommandInvocationContext) => void
href?: string
@@ -35,7 +35,7 @@ const GoToCodeButton = memo(function GoToCodeButton({
syncToCode({ visualOffset: 72 })
},
disabled: syncToCodeInFlight,
label: t('go_to_pdf_location_in_code'),
label: t('go_to_pdf_location_in_code_action'),
},
],
[t, syncToCode, syncToCodeInFlight]
@@ -101,7 +101,8 @@ export const useToolbarMenuBarEditorCommands = () => {
************************************/
{
id: 'insert-inline-math',
label: t('inline_math'),
menuLabel: t('inline_math'),
label: t('insert_inline_math'),
handler: () => {
commands.wrapInInlineMath(view)
view.focus()
@@ -109,21 +110,24 @@ export const useToolbarMenuBarEditorCommands = () => {
},
{
id: 'insert-display-math',
label: t('display_math'),
menuLabel: t('display_math'),
label: t('insert_display_math'),
handler: () => {
commands.wrapInDisplayMath(view)
view.focus()
},
},
{
label: t('upload_from_computer'),
menuLabel: t('upload_from_computer'),
label: t('insert_figure_from_computer'),
id: 'insert-figure-from-computer',
handler: () => {
openFigureModal(FigureModalSource.FILE_UPLOAD)
},
},
{
label: t('from_project_files'),
menuLabel: t('from_project_files'),
label: t('insert_figure_from_project_files'),
id: 'insert-figure-from-project-files',
handler: () => {
openFigureModal(FigureModalSource.FILE_TREE)
@@ -144,7 +148,8 @@ export const useToolbarMenuBarEditorCommands = () => {
}
return [
{
label: t('from_another_project'),
menuLabel: t('from_another_project'),
label: t('insert_figure_from_another_project'),
id: 'insert-figure-from-another-project',
handler: () => {
openFigureModal(FigureModalSource.OTHER_PROJECT)
@@ -173,7 +178,8 @@ export const useToolbarMenuBarEditorCommands = () => {
}
return [
{
label: t('from_url'),
menuLabel: t('from_url'),
label: t('insert_figure_from_url'),
id: 'insert-figure-from-url',
handler: () => {
openFigureModal(FigureModalSource.FROM_URL)
@@ -200,7 +206,8 @@ export const useToolbarMenuBarEditorCommands = () => {
return [
{
id: 'insert-table',
label: t('table'),
menuLabel: t('table'),
label: t('insert_table'),
handler: () => {
commands.insertTable(view, 3, 3)
view.focus()
@@ -208,7 +215,8 @@ export const useToolbarMenuBarEditorCommands = () => {
},
{
id: 'insert-citation',
label: t('citation'),
menuLabel: t('citation'),
label: t('insert_citation'),
handler: () => {
commands.insertCite(view)
view.focus()
@@ -216,7 +224,8 @@ export const useToolbarMenuBarEditorCommands = () => {
},
{
id: 'insert-link',
label: t('link'),
menuLabel: t('link'),
label: t('insert_link'),
handler: () => {
commands.wrapInHref(view)
view.focus()
@@ -224,7 +233,8 @@ export const useToolbarMenuBarEditorCommands = () => {
},
{
id: 'insert-cross-reference',
label: t('cross_reference'),
menuLabel: t('cross_reference'),
label: t('insert_cross_reference'),
handler: () => {
commands.insertRef(view)
view.focus()
@@ -232,7 +242,8 @@ export const useToolbarMenuBarEditorCommands = () => {
},
{
id: 'comment',
label: t('comment'),
menuLabel: t('comment'),
label: t('add_comment'),
handler: () => {
commands.addComment('toolbar')
},
+12
View File
@@ -1081,6 +1081,7 @@
"go_to_overleaf": "Go to Overleaf",
"go_to_page_x": "Go to page __page__",
"go_to_pdf_location_in_code": "Go to PDF location in code (Tip: double click on the PDF for best results)",
"go_to_pdf_location_in_code_action": "Go to PDF location in code",
"go_to_previous_page": "Go to previous page",
"go_to_settings": "Go to settings",
"go_to_sign_in": "Go to sign in",
@@ -1247,15 +1248,25 @@
"inr_discount_modal_title": "70% off all Overleaf premium plans for users in India",
"inr_discount_offer_plans_page_banner": "__flag__ <b>Great news!</b> Weve applied a <b>70% discount</b> to premium plans for our users in India. Check out the new lower prices below.",
"insert": "Insert",
"insert_citation": "Insert citation",
"insert_column_left": "Insert column left",
"insert_column_right": "Insert column right",
"insert_cross_reference": "Insert cross reference",
"insert_display_math": "Insert display math",
"insert_figure": "Insert figure",
"insert_figure_from_another_project": "Insert figure from another project",
"insert_figure_from_computer": "Insert figure from your computer",
"insert_figure_from_project_files": "Insert figure from project files",
"insert_figure_from_url": "Insert figure from URL",
"insert_from_another_project": "Insert from another project",
"insert_from_project_files": "Insert from project files",
"insert_from_url": "Insert from URL",
"insert_image": "Insert image",
"insert_inline_math": "Insert inline math",
"insert_link": "Insert link",
"insert_row_above": "Insert row above",
"insert_row_below": "Insert row below",
"insert_table": "Insert table",
"insert_x_columns_left": "Insert __columns__ columns left",
"insert_x_columns_right": "Insert __columns__ columns right",
"insert_x_rows_above": "Insert __rows__ rows above",
@@ -1770,6 +1781,7 @@
"open_path": "Open __path__",
"open_pdf_in_separate_tab": "Open PDF in separate tab",
"open_project": "Open Project",
"open_settings": "Open settings",
"open_target": "Go to target",
"opens_in_new_tab": "opens in new tab",
"operation": "Operation",