mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-02 18:10:18 +05:30
refactor: update renderer.js to use ModalManager for all dialogs
- Import ModalManager and create instances for all 10 dialogs
- Replace classList.add/remove('hidden') with modal.open()/close()
- Remove duplicate backdrop click and escape key handlers (now handled by ModalManager)
- Update print-preview.js to use ModalManager when available
- Add CommonJS export to ModalManager for renderer compatibility
Dialogs updated:
- find-dialog (findModal)
- export-dialog (exportModal)
- print-preview-overlay (printPreviewModal)
- table-generator-dialog (tableModal)
- ascii-art-dialog (asciiModal)
- universal-converter-dialog (converterModal)
- batch-dialog (batchModal)
- pdf-editor-dialog (pdfEditorModal)
- header-footer-dialog (headerFooterModal)
- field-picker-dialog (fieldPickerModal)
Amit Haridas
This commit is contained in:
+12
-13
@@ -1,19 +1,28 @@
|
||||
class PrintPreview {
|
||||
constructor() {
|
||||
this.overlay = document.getElementById('print-preview-overlay');
|
||||
this.modal = window.modals?.printPreviewModal;
|
||||
this._lastContent = '';
|
||||
this.setupEventListeners();
|
||||
}
|
||||
|
||||
open(htmlContent) {
|
||||
this._lastContent = htmlContent;
|
||||
this.overlay.classList.remove('hidden');
|
||||
if (this.modal) {
|
||||
this.modal.open();
|
||||
} else {
|
||||
this.overlay.classList.remove('hidden');
|
||||
}
|
||||
this.updatePreview(htmlContent);
|
||||
this.updateScaleLabel();
|
||||
}
|
||||
|
||||
close() {
|
||||
this.overlay.classList.add('hidden');
|
||||
if (this.modal) {
|
||||
this.modal.close();
|
||||
} else {
|
||||
this.overlay.classList.add('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
setupEventListeners() {
|
||||
@@ -38,17 +47,7 @@ class PrintPreview {
|
||||
}
|
||||
});
|
||||
|
||||
// Close on overlay click
|
||||
this.overlay?.addEventListener('click', (e) => {
|
||||
if (e.target === this.overlay) this.close();
|
||||
});
|
||||
|
||||
// Close on Escape
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape' && !this.overlay.classList.contains('hidden')) {
|
||||
this.close();
|
||||
}
|
||||
});
|
||||
// Note: Backdrop click and Escape key are now handled by ModalManager
|
||||
}
|
||||
|
||||
updateScaleLabel() {
|
||||
|
||||
Reference in New Issue
Block a user