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:
isUnknown 2026-01-09 17:11:18 +01:00
parent 4d39a83a63
commit dac532a932

View file

@ -38,6 +38,9 @@ const activeFrame = computed(() => {
: previewFrame2.value; : previewFrame2.value;
}); });
// Detect platform for keyboard shortcut display
const isMac = typeof navigator !== 'undefined' && navigator.platform.toUpperCase().indexOf('MAC') >= 0;
// Handle keyboard shortcuts // Handle keyboard shortcuts
const handleKeyboardShortcut = (event) => { const handleKeyboardShortcut = (event) => {
// Escape key - close any open popup // Escape key - close any open popup
@ -60,6 +63,13 @@ const handleKeyboardShortcut = (event) => {
return; 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 // Cmd+S (Mac) or Ctrl+S (Windows/Linux) - save
if ((event.metaKey || event.ctrlKey) && event.key === 's') { if ((event.metaKey || event.ctrlKey) && event.key === 's') {
event.preventDefault(); event.preventDefault();
@ -645,7 +655,7 @@ onUnmounted(() => {
@close="handlePagePopupClose" @close="handlePagePopupClose"
/> />
<button class="print-btn" @click="printPreview" title="Imprimer"> <button class="print-btn" @click="printPreview" :title="`Imprimer (${isMac ? '⌘' : 'Ctrl'}+P)`">
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24" viewBox="0 0 24 24"