From 883601f548a36c6999861704848066e81f741d87 Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Sun, 17 May 2026 14:31:29 +0300 Subject: [PATCH] fix(ui): format shortcut tooltips by platform --- scripts/steiger-rules.ts | 21 +++++++++++++++++++ src/components/ZoomDropdown.vue | 12 +++++------ .../properties/TypographySection.vue | 10 ++++----- src/views/EditorView.vue | 4 ++-- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/scripts/steiger-rules.ts b/scripts/steiger-rules.ts index 8cdf21eeb..57e5028b7 100644 --- a/scripts/steiger-rules.ts +++ b/scripts/steiger-rules.ts @@ -478,6 +478,26 @@ const noPropertyPanelInternalsOutsidePanel = createImportRule( } ) +const MACOS_MODIFIER_GLYPH_PATTERN = /[⌘⌥⌃]/u + +const noHardcodedMacOSShortcutGlyphs = createTextRule( + 'open-pencil/no-hardcoded-macos-shortcut-glyphs', + (sourceRel, content) => { + if (!sourceRel.endsWith('.vue')) return [] + const diagnostics: Array<{ message: string; line?: number; column?: number }> = [] + for (const match of content.matchAll(MACOS_MODIFIER_GLYPH_PATTERN)) { + const before = content.slice(0, match.index) + const lines = before.split('\n') + diagnostics.push({ + message: 'Use formatShortcut() instead of hardcoding macOS-only modifier glyphs.', + line: lines.length, + column: lines.at(-1)?.length ?? 0 + }) + } + return diagnostics + } +) + const SHORTCUT_LABEL_PATTERN = /(?:Shift|Ctrl|Alt|Option|Cmd|Command|⌘|⇧|⌥|⌃)\s*[+)\w]/u const noShortcutTextInLabels = createTextRule( @@ -546,6 +566,7 @@ export const openPencilArchitecturePlugin = { noAppImportsInSharedUi, noPropertyPanelInternalsOutsidePanel, noShortcutTextInLabels, + noHardcodedMacOSShortcutGlyphs, noUiImportsInCore ] } diff --git a/src/components/ZoomDropdown.vue b/src/components/ZoomDropdown.vue index ffbc1386c..b23b3c224 100644 --- a/src/components/ZoomDropdown.vue +++ b/src/components/ZoomDropdown.vue @@ -9,7 +9,7 @@ import { } from 'reka-ui' import { nextTick, ref, watch } from 'vue' -import { useEditorCommands, useI18n } from '@open-pencil/vue' +import { useEditorCommands, useI18n, formatShortcut } from '@open-pencil/vue' import { menuItem, useMenuUI } from '@/components/ui/menu' import { useEditorStore } from '@/app/editor/active-store' @@ -69,7 +69,7 @@ function zoomOut() { const ZOOM_PRESETS: ReadonlyArray<{ label: string; level: number; shortcut?: string }> = [ { label: '50%', level: 0.5 }, - { label: '100%', level: 1, shortcut: '⌘0' }, + { label: '100%', level: 1, shortcut: 'MOD+0' }, { label: '200%', level: 2 } ] @@ -126,15 +126,15 @@ watch(open, (v) => { {{ menuText.zoomIn }} - ⌘+ + {{ formatShortcut('MOD++') }} {{ menuText.zoomOut }} - ⌘− + {{ formatShortcut('MOD+−') }} {{ commands.zoomToFit }} - ⇧1 + {{ formatShortcut('SHIFT+1') }} { > {{ preset.label }} - {{ preset.shortcut }} + {{ formatShortcut(preset.shortcut) }} diff --git a/src/components/properties/TypographySection.vue b/src/components/properties/TypographySection.vue index b675b3c36..744124cf7 100644 --- a/src/components/properties/TypographySection.vue +++ b/src/components/properties/TypographySection.vue @@ -1,7 +1,7 @@ @@ -125,7 +125,7 @@ const fontLoader = { load: loadFont }
- + - + - +