Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
130 changes: 36 additions & 94 deletions packages/desktop/app/javascripts/Main/Menus/Menus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,40 +30,26 @@ const Separator: MenuItemConstructorOptions = {
type: 'separator',
}

function menuRole(label: string, role: string): MenuItemConstructorOptions {
return { label, role: role as MenuItemConstructorOptions['role'] }
}

export function buildContextMenu(webContents: WebContents, params: ContextMenuParams): Menu {
if (!params.isEditable) {
return Menu.buildFromTemplate([
{
role: 'copy',
},
])
return Menu.buildFromTemplate([menuRole(str().copy, Roles.Copy)])
}

return Menu.buildFromTemplate([
...suggestionsMenu(params.selectionText, params.misspelledWord, params.dictionarySuggestions, webContents),
Separator,
{
role: 'undo',
},
{
role: 'redo',
},
menuRole(str().undo, Roles.Undo),
menuRole(str().redo, Roles.Redo),
Separator,
{
role: 'cut',
},
{
role: 'copy',
},
{
role: 'paste',
},
{
role: 'pasteAndMatchStyle',
},
{
role: 'selectAll',
},
menuRole(str().cut, Roles.Cut),
menuRole(str().copy, Roles.Copy),
menuRole(str().paste, Roles.Paste),
menuRole(str().pasteAndMatchStyle, Roles.PasteAndMatchStyle),
menuRole(str().selectAll, Roles.SelectAll),
])
}

Expand Down Expand Up @@ -208,28 +194,19 @@ function macAppMenu(appName: string): MenuItemConstructorOptions {
role: 'appMenu',
label: appName,
submenu: [
{
role: Roles.About,
},
menuRole(str().about(appName), Roles.About),
Separator,
{
label: str().services,
role: Roles.Services,
submenu: [],
},
Separator,
{
role: Roles.Hide,
},
{
role: Roles.HideOthers,
},
{
role: Roles.UnHide,
},
menuRole(str().hide(appName), Roles.Hide),
menuRole(str().hideOthers, Roles.HideOthers),
menuRole(str().showAll, Roles.UnHide),
Separator,
{
role: Roles.Quit,
},
menuRole(str().quit(appName), Roles.Quit),
],
}
}
Expand All @@ -249,28 +226,14 @@ function editMenu(
role: 'editMenu',
label: str().edit,
submenu: [
{
role: Roles.Undo,
},
{
role: Roles.Redo,
},
menuRole(str().undo, Roles.Undo),
menuRole(str().redo, Roles.Redo),
Separator,
{
role: Roles.Cut,
},
{
role: Roles.Copy,
},
{
role: Roles.Paste,
},
{
role: Roles.PasteAndMatchStyle,
},
{
role: Roles.SelectAll,
},
menuRole(str().cut, Roles.Cut),
menuRole(str().copy, Roles.Copy),
menuRole(str().paste, Roles.Paste),
menuRole(str().pasteAndMatchStyle, Roles.PasteAndMatchStyle),
menuRole(str().selectAll, Roles.SelectAll),
...(isMac() ? [Separator, macSpeechMenu()] : [spellcheckerMenu(spellcheckerManager!, reload)]),
],
}
Expand All @@ -279,14 +242,7 @@ function editMenu(
function macSpeechMenu(): MenuItemConstructorOptions {
return {
label: str().speech,
submenu: [
{
role: Roles.StopSeeking,
},
{
role: Roles.StopSeeking,
},
],
submenu: [menuRole(str().startSpeaking, Roles.StartSeeking), menuRole(str().stopSpeaking, Roles.StopSeeking)],
}
}

Expand Down Expand Up @@ -317,26 +273,14 @@ function viewMenu(window: Electron.BrowserWindow, store: Store, reload: () => vo
return {
label: str().view,
submenu: [
{
role: Roles.Reload,
},
{
role: Roles.ToggleDevTools,
},
menuRole(str().reload, Roles.Reload),
menuRole(str().toggleDeveloperTools, Roles.ToggleDevTools),
Separator,
{
role: Roles.ResetZoom,
},
{
role: Roles.ZoomIn,
},
{
role: Roles.ZoomOut,
},
menuRole(str().actualSize, Roles.ResetZoom),
menuRole(str().zoomIn, Roles.ZoomIn),
menuRole(str().zoomOut, Roles.ZoomOut),
Separator,
{
role: Roles.ToggleFullScreen,
},
menuRole(str().toggleFullScreen, Roles.ToggleFullScreen),
...(isMac() ? [] : [Separator, ...menuBarOptions(window, store, reload)]),
],
}
Expand Down Expand Up @@ -375,14 +319,11 @@ function menuBarOptions(window: Electron.BrowserWindow, store: Store, reload: ()

function windowMenu(store: Store, trayManager: TrayManager, reload: () => void): MenuItemConstructorOptions {
return {
label: str().window,
role: Roles.Window,
submenu: [
{
role: Roles.Minimize,
},
{
role: Roles.Close,
},
menuRole(str().minimize, Roles.Minimize),
menuRole(str().close, Roles.Close),
Separator,
...(isMac() ? macWindowItems() : [minimizeToTrayItem(store, trayManager, reload)]),
],
Expand Down Expand Up @@ -512,6 +453,7 @@ function updateMenu(window: BrowserWindow, appState: AppState) {

function helpMenu(window: Electron.BrowserWindow, shell: Electron.Shell) {
return {
label: str().help,
role: Roles.Help,
submenu: [
{
Expand Down
29 changes: 29 additions & 0 deletions packages/desktop/app/javascripts/Main/Strings/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,37 @@ import { Strings } from './types'
export function createStrings(): Strings {
return {
appMenu: {
window: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Window`,
help: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Help`,
edit: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Edit`,
view: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`View`,
about(appName: string) {
return jtString(c('B8.MobileDesktopShared.Desktop.Menu.Label').jt`About ${appName}`)
},
services: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Services`,
hide(appName: string) {
return jtString(c('B8.MobileDesktopShared.Desktop.Menu.Label').jt`Hide ${appName}`)
},
hideOthers: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Hide Others`,
showAll: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Show All`,
quit(appName: string) {
return jtString(c('B8.MobileDesktopShared.Desktop.Menu.Label').jt`Quit ${appName}`)
},
startSpeaking: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Start Speaking`,
stopSpeaking: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Stop Speaking`,
undo: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Undo`,
redo: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Redo`,
cut: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Cut`,
copy: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Copy`,
paste: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Paste`,
pasteAndMatchStyle: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Paste and Match Style`,
selectAll: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Select All`,
reload: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Reload`,
toggleDeveloperTools: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Toggle Developer Tools`,
actualSize: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Actual Size`,
zoomIn: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Zoom In`,
zoomOut: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Zoom Out`,
toggleFullScreen: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Toggle Full Screen`,
hideMenuBar: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Hide Menu Bar`,
useThemedMenuBar: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Use Themed Menu Bar`,
minimizeToTrayOnClose: c('B8.MobileDesktopShared.Desktop.Menu.Label').t`Minimize To Tray On Close`,
Expand Down
23 changes: 23 additions & 0 deletions packages/desktop/app/javascripts/Main/Strings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,31 @@ export interface Strings {
}

interface AppMenuStrings {
window: string
help: string
edit: string
view: string
about(appName: string): string
services: string
hide(appName: string): string
hideOthers: string
showAll: string
quit(appName: string): string
startSpeaking: string
stopSpeaking: string
undo: string
redo: string
cut: string
copy: string
paste: string
pasteAndMatchStyle: string
selectAll: string
reload: string
toggleDeveloperTools: string
actualSize: string
zoomIn: string
zoomOut: string
toggleFullScreen: string
hideMenuBar: string
useThemedMenuBar: string
minimizeToTrayOnClose: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ function CommandPalette() {
section,
id: UuidGenerator.GenerateUuid(),
itemUuid: item.uuid,
description: item.title || c('B2.NavSharedUI.Placeholder').t`<no title>`,
description: item.title || c('B2.NavSharedUI.Placeholder').t`Untitled`,
icon: <Icon type={icon[0]} className={item instanceof SNNote ? icon[1] : ''} />,
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import { AnyTag } from '@/Controllers/Navigation/AnyTagType'
import { PreferenceMode } from './PreferenceMode'
import { EditorOption, getDropdownItemsForAllEditors } from '@/Utils/DropdownItemsForEditors'
import { classNames } from '@standardnotes/utils'
import { NoteTitleFormatOptions } from './NoteTitleFormatOptions'
import { NOTE_TITLE_FORMAT_PATTERN_EXAMPLE, NoteTitleFormatOptions } from './NoteTitleFormatOptions'
import { usePremiumModal } from '@/Hooks/usePremiumModal'
import { getDayjsFormattedString } from '@/Utils/GetDayjsFormattedString'
import { ErrorBoundary } from '@/Utils/ErrorBoundary'
import { jtString } from '@standardnotes/features'
import { c } from 'ttag'

const PrefChangeDebounceTimeInMs = 25
Expand Down Expand Up @@ -173,6 +174,31 @@ const NewNotePreferences: FunctionComponent<Props> = ({
}, PrefChangeDebounceTimeInMs)
}

const titleFormatOptionsLink = (
<a
className="underline"
href={HelpPageUrl}
rel="noreferrer"
target="_blank"
onClick={(event) => {
if (application.isNativeMobileWeb()) {
event.preventDefault()
application.mobileDevice.openUrl(HelpPageUrl)
}
}}
>
{c('B3.Notes.NoteList.Action').t`Options`}
</a>
)

const bracketsLiteral = <code>[]</code>

const titleFormatPreview = (
<ErrorBoundary>
<CustomNoteTitleFormatPreview format={customNoteTitleFormat} />
</ErrorBoundary>
)

return (
<div className="px-3 py-3">
<div>
Expand Down Expand Up @@ -211,35 +237,15 @@ const NewNotePreferences: FunctionComponent<Props> = ({
'w-full min-w-55 rounded border border-solid border-passive-3 bg-default px-2 py-1.5 text-sm md:translucent-ui:bg-transparent',
'focus-within:ring-2 focus-within:ring-info',
)}
placeholder={c('B3.Notes.NoteList.Label').t`e.g. YYYY-MM-DD`}
placeholder={jtString(c('B3.Notes.NoteList.Label').jt`e.g. ${NOTE_TITLE_FORMAT_PATTERN_EXAMPLE}`)}
value={customNoteTitleFormat}
onChange={handleCustomFormatInputChange}
spellCheck={false}
/>
</div>
<div className="mt-3 text-neutral">
<span className="font-bold">{c('B3.Notes.NoteList.Label').t`Preview:`} </span>
<ErrorBoundary>
<CustomNoteTitleFormatPreview format={customNoteTitleFormat} />
</ErrorBoundary>
</div>
<div className="mt-3 text-neutral">{c('B3.Notes.NoteList.Info').jt`Preview: ${titleFormatPreview}`}</div>
<div className="mt-2 text-neutral">
<a
className="underline"
href={HelpPageUrl}
rel="noreferrer"
target="_blank"
onClick={(event) => {
if (application.isNativeMobileWeb()) {
event.preventDefault()
application.mobileDevice.openUrl(HelpPageUrl)
}
}}
>
{c('B3.Notes.NoteList.Action').t`Options`}
</a>
. {c('B3.Notes.NoteList.Info').t`Use`} <code>[]</code>{' '}
{c('B3.Notes.NoteList.Info').t`to escape formatting.`}
{c('B3.Notes.NoteList.Info').jt`${titleFormatOptionsLink}. Use ${bracketsLiteral} to escape formatting.`}
</div>
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { NewNoteTitleFormat } from '@standardnotes/snjs'
import { c } from 'ttag'

export const NOTE_TITLE_FORMAT_PATTERN_EXAMPLE = 'YYYY-MM-DD'

export const NoteTitleFormatOptions = [
{
label: c('B3.Notes.NoteList.Label').t`Current date and time`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { action, computed, makeObservable, observable, runInAction } from 'mobx'
import { c } from 'ttag'
import {
UniversalSearchProvider,
UniversalSearchResult,
Expand Down Expand Up @@ -32,7 +33,7 @@ function errorMessage(error: unknown): string {
return error.message
}

return 'Search failed'
return c('B3.Notes.EditorToolbar.Error').t`Search failed`
}

type SetSearchResultsOptions = {
Expand Down
Loading
Loading