feat: intercept Cmd+P to print PagedJS preview

Override default print behavior to print the active iframe
content (PagedJS rendered preview) instead of the main page.
Works with both Cmd+P (Mac) and Ctrl+P (Windows/Linux).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
isUnknown 2025-12-08 13:59:33 +01:00
parent 0052c3c19f
commit 100226427d

View file

@ -4,7 +4,7 @@ import EditorPanel from './components/editor/EditorPanel.vue';
import ElementPopup from './components/ElementPopup.vue';
import PagePopup from './components/PagePopup.vue';
import PreviewLoader from './components/PreviewLoader.vue';
import { onMounted, ref, watch, computed, provide } from 'vue';
import { onMounted, onUnmounted, ref, watch, computed, provide } from 'vue';
import { useStylesheetStore } from './stores/stylesheet';
import Coloris from '@melloware/coloris';
@ -274,7 +274,25 @@ watch(
}
);
onMounted(() => renderPreview(true));
// Handle Cmd+P / Ctrl+P to print the iframe content
const handlePrint = (event) => {
if ((event.metaKey || event.ctrlKey) && event.key === 'p') {
event.preventDefault();
const frame = activeFrame.value;
if (frame && frame.contentWindow) {
frame.contentWindow.print();
}
}
};
onMounted(() => {
renderPreview(true);
window.addEventListener('keydown', handlePrint);
});
onUnmounted(() => {
window.removeEventListener('keydown', handlePrint);
});
</script>
<template>