feat: add Cmd/Ctrl+P shortcut to trigger print preview
Added Cmd+P (Mac) or Ctrl+P (Windows/Linux) to trigger printPreview(): - Prevents default browser print dialog - Triggers custom print preview function - Updated print button tooltip to show keyboard shortcut - Added platform detection for correct symbol display (⌘ or Ctrl) Works in all contexts (main document and iframe). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
4d39a83a63
commit
dac532a932
1 changed files with 11 additions and 1 deletions
12
src/App.vue
12
src/App.vue
|
|
@ -38,6 +38,9 @@ const activeFrame = computed(() => {
|
|||
: previewFrame2.value;
|
||||
});
|
||||
|
||||
// Detect platform for keyboard shortcut display
|
||||
const isMac = typeof navigator !== 'undefined' && navigator.platform.toUpperCase().indexOf('MAC') >= 0;
|
||||
|
||||
// Handle keyboard shortcuts
|
||||
const handleKeyboardShortcut = (event) => {
|
||||
// Escape key - close any open popup
|
||||
|
|
@ -60,6 +63,13 @@ const handleKeyboardShortcut = (event) => {
|
|||
return;
|
||||
}
|
||||
|
||||
// Cmd+P (Mac) or Ctrl+P (Windows/Linux) - print
|
||||
if ((event.metaKey || event.ctrlKey) && event.key === 'p') {
|
||||
event.preventDefault();
|
||||
printPreview();
|
||||
return;
|
||||
}
|
||||
|
||||
// Cmd+S (Mac) or Ctrl+S (Windows/Linux) - save
|
||||
if ((event.metaKey || event.ctrlKey) && event.key === 's') {
|
||||
event.preventDefault();
|
||||
|
|
@ -645,7 +655,7 @@ onUnmounted(() => {
|
|||
@close="handlePagePopupClose"
|
||||
/>
|
||||
|
||||
<button class="print-btn" @click="printPreview" title="Imprimer">
|
||||
<button class="print-btn" @click="printPreview" :title="`Imprimer (${isMac ? '⌘' : 'Ctrl'}+P)`">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue