refactor(ascii-art): delete in-app modal #ascii-art-dialog, controller, dead preload channels

Amit Haridas
This commit is contained in:
2026-09-14 21:06:28 +05:30
parent 8c162c1714
commit ab50183dc0
6 changed files with 4 additions and 1029 deletions
-799
View File
@@ -2185,7 +2185,6 @@ document.addEventListener('DOMContentLoaded', async () => {
const exportModal = new ModalManager('#export-dialog');
const printPreviewModal = new ModalManager('#print-preview-overlay');
const tableModal = new ModalManager('#table-generator-dialog');
const asciiModal = new ModalManager('#ascii-art-dialog');
const converterModal = new ModalManager('#universal-converter-dialog');
const batchModal = new ModalManager('#batch-dialog');
const pdfEditorModal = new ModalManager('#pdf-editor-dialog');
@@ -2199,7 +2198,6 @@ document.addEventListener('DOMContentLoaded', async () => {
exportModal,
printPreviewModal,
tableModal,
asciiModal,
converterModal,
batchModal,
pdfEditorModal,
@@ -5965,803 +5963,6 @@ document.getElementById('table-cols').addEventListener('keypress', (e) => {
}
});
// ============================================================================
// ASCII ART GENERATOR
// ============================================================================
let currentASCIIMode = 'text';
function showASCIIGenerator() {
window.modals.asciiModal.open();
// Initialize with text mode
switchASCIIMode('text');
// Generate initial preview
setTimeout(() => {
generateASCIIPreview();
}, 100);
}
function hideASCIIGenerator() {
window.modals.asciiModal.close();
}
function switchASCIIMode(mode) {
currentASCIIMode = mode;
// Update button states
document.querySelectorAll('.ascii-mode-btn').forEach((btn) => {
btn.classList.remove('active');
});
// Hide all mode sections
document.querySelectorAll('.ascii-mode-section').forEach((section) => {
section.classList.add('hidden');
});
// Show selected mode
if (mode === 'text') {
document.getElementById('ascii-mode-text').classList.add('active');
document.getElementById('ascii-text-mode').classList.remove('hidden');
} else if (mode === 'box') {
document.getElementById('ascii-mode-box').classList.add('active');
document.getElementById('ascii-box-mode').classList.remove('hidden');
} else if (mode === 'templates') {
document.getElementById('ascii-mode-templates').classList.add('active');
document.getElementById('ascii-templates-mode').classList.remove('hidden');
}
// Generate preview
generateASCIIPreview();
}
function generateASCIIPreview() {
let result = '';
if (currentASCIIMode === 'text') {
const text = document.getElementById('ascii-text-input').value || 'Sample';
const style = document.getElementById('ascii-font-style').value;
result = textToASCII(text, style);
} else if (currentASCIIMode === 'box') {
const text = document.getElementById('ascii-box-text').value || 'Sample Text';
const style = document.getElementById('ascii-box-style').value;
const padding = parseInt(document.getElementById('ascii-box-padding').value) || 2;
result = createASCIIBox(text, style, padding);
} else if (currentASCIIMode === 'templates') {
result = 'Select a template from the buttons above';
}
document.getElementById('ascii-preview').textContent = result;
}
// Simple ASCII art text generator
function textToASCII(text, style) {
const fonts = {
standard: {
height: 5,
chars: {
A: [' _ ', ' / \\ ', '/___\\', '| |', '| |'],
B: ['____ ', '| \\', '|___/', '| \\', '|___/'],
C: [' ___ ', '/ _/', '| \\', '| ', '\\___/'],
D: ['____ ', '| \\', '| |', '| |', '|___/'],
E: ['_____', '| ', '|___ ', '| ', '|____'],
F: ['_____', '| ', '|___ ', '| ', '| '],
G: [' ___ ', '/ _', '| ||', '| |', '\\___/'],
H: ['| |', '| |', '|___|', '| |', '| |'],
I: ['_____', ' | ', ' | ', ' | ', '_____'],
J: ['_____', ' | ', ' | ', '| | ', '\\__/ '],
K: ['| |', '| / ', '|_/ ', '| \\ ', '| \\ '],
L: ['| ', '| ', '| ', '| ', '|____'],
M: ['| |', '|\\ /|', '| V |', '| |', '| |'],
N: ['| |', '|\\ |', '| \\ |', '| \\|', '| |'],
O: [' ___ ', '/ \\', '| |', '| |', '\\___/'],
P: ['____ ', '| \\', '|___/', '| ', '| '],
Q: [' ___ ', '/ \\', '| |', '| |\\ ', '\\__\\|'],
R: ['____ ', '| \\', '|___/', '| \\ ', '| \\ '],
S: [' ___ ', '/ _/', '\\_ \\', ' \\ ', '\\___/'],
T: ['_____', ' | ', ' | ', ' | ', ' | '],
U: ['| |', '| |', '| |', '| |', '\\___/'],
V: ['| |', '| |', '| |', ' \\ / ', ' V '],
W: ['| |', '| |', '| W |', '|/ \\|', '| |'],
X: ['| |', ' \\ / ', ' X ', ' / \\ ', '| |'],
Y: ['| |', ' \\ / ', ' Y ', ' | ', ' | '],
Z: ['_____', ' / ', ' / ', ' / ', '/___ '],
' ': [' ', ' ', ' ', ' ', ' '],
0: [' ___ ', '/ \\', '| | |', '| |', '\\___/'],
1: [' | ', ' || ', ' | ', ' | ', ' _|_ '],
2: [' ___ ', '\\ /', ' __/ ', '/ ', '\\____'],
3: [' ___ ', '\\ /', ' __/ ', ' / ', '\\___/'],
4: ['| |', '| |', '|___|', ' |', ' |'],
5: [' ___ ', '| ', '|___ ', ' / ', '\\___/'],
6: [' ___ ', '/ ', '|___ ', '| |', '\\___/'],
7: ['_____', ' / ', ' / ', ' / ', '/ '],
8: [' ___ ', '| |', ' ___ ', '| |', '\\___/'],
9: [' ___ ', '| |', '\\___|', ' |', '\\___/'],
},
},
banner: {
height: 7,
chars: {
A: [
' ### ',
' ## ## ',
' ## ## ',
' ## ## ',
' ####### ',
' ## ## ',
' ## ## ',
],
B: [
' ###### ',
' ## ## ',
' ## ## ',
' ###### ',
' ## ## ',
' ## ## ',
' ###### ',
],
C: [
' ##### ',
' ## ## ',
' ## ',
' ## ',
' ## ',
' ## ## ',
' ##### ',
],
D: [
' ###### ',
' ## ## ',
' ## ## ',
' ## ## ',
' ## ## ',
' ## ## ',
' ###### ',
],
E: [
' ####### ',
' ## ',
' ## ',
' ##### ',
' ## ',
' ## ',
' ####### ',
],
F: [
' ####### ',
' ## ',
' ## ',
' ##### ',
' ## ',
' ## ',
' ## ',
],
G: [
' ##### ',
' ## ## ',
' ## ',
' ## ### ',
' ## ## ',
' ## ## ',
' ##### ',
],
H: [
' ## ## ',
' ## ## ',
' ## ## ',
' ####### ',
' ## ## ',
' ## ## ',
' ## ## ',
],
I: [
' ####### ',
' ### ',
' ### ',
' ### ',
' ### ',
' ### ',
' ####### ',
],
J: [
' ####### ',
' ## ',
' ## ',
' ## ',
' ## ## ',
' ## ## ',
' #### ',
],
K: [
' ## ## ',
' ## ## ',
' ## ## ',
' #### ',
' ## ## ',
' ## ## ',
' ## ## ',
],
L: [
' ## ',
' ## ',
' ## ',
' ## ',
' ## ',
' ## ',
' ####### ',
],
M: [
' ## ## ',
' ### ### ',
' ####### ',
' ## # ## ',
' ## ## ',
' ## ## ',
' ## ## ',
],
N: [
' ## ## ',
' ### ## ',
' #### ## ',
' ## #### ',
' ## ### ',
' ## ## ',
' ## ## ',
],
O: [
' ##### ',
' ## ## ',
' ## ## ',
' ## ## ',
' ## ## ',
' ## ## ',
' ##### ',
],
P: [
' ###### ',
' ## ## ',
' ## ## ',
' ###### ',
' ## ',
' ## ',
' ## ',
],
Q: [
' ##### ',
' ## ## ',
' ## ## ',
' ## ## ',
' ## # ## ',
' ## ## ',
' ### ## ',
],
R: [
' ###### ',
' ## ## ',
' ## ## ',
' ###### ',
' ## ## ',
' ## ## ',
' ## ## ',
],
S: [
' ##### ',
' ## ## ',
' ## ',
' ##### ',
' ## ',
' ## ## ',
' ##### ',
],
T: [
' ####### ',
' ### ',
' ### ',
' ### ',
' ### ',
' ### ',
' ### ',
],
U: [
' ## ## ',
' ## ## ',
' ## ## ',
' ## ## ',
' ## ## ',
' ## ## ',
' ##### ',
],
V: [
' ## ## ',
' ## ## ',
' ## ## ',
' ## ## ',
' ## ## ',
' ## ## ',
' ### ',
],
W: [
' ## ## ',
' ## ## ',
' ## ## ',
' ## # ## ',
' ####### ',
' ### ### ',
' ## ## ',
],
X: [
' ## ## ',
' ## ## ',
' ### ',
' # ',
' ### ',
' ## ## ',
' ## ## ',
],
Y: [
' ## ## ',
' ## ## ',
' ### ',
' # ',
' # ',
' # ',
' # ',
],
Z: [
' ####### ',
' ## ',
' ## ',
' ## ',
' ## ',
' ## ',
' ####### ',
],
' ': [
' ',
' ',
' ',
' ',
' ',
' ',
' ',
],
0: [
' ##### ',
' ## ## ',
' ## ### ',
' ## #### ',
' ### ## ',
' ## ## ',
' ##### ',
],
1: [
' ## ',
' ### ',
' ## ',
' ## ',
' ## ',
' ## ',
' ####### ',
],
2: [
' ##### ',
' ## ## ',
' ## ',
' ## ',
' ## ',
' ## ',
' ####### ',
],
3: [
' ##### ',
' ## ## ',
' ## ',
' ### ',
' ## ',
' ## ## ',
' ##### ',
],
4: [
' ### ',
' #### ',
' ## ## ',
' ## ## ',
' ####### ',
' ## ',
' ## ',
],
5: [
' ####### ',
' ## ',
' ###### ',
' ## ',
' ## ',
' ## ## ',
' ##### ',
],
6: [
' ##### ',
' ## ## ',
' ## ',
' ###### ',
' ## ## ',
' ## ## ',
' ##### ',
],
7: [
' ####### ',
' ## ',
' ## ',
' ## ',
' ## ',
' ## ',
' ## ',
],
8: [
' ##### ',
' ## ## ',
' ## ## ',
' ##### ',
' ## ## ',
' ## ## ',
' ##### ',
],
9: [
' ##### ',
' ## ## ',
' ## ## ',
' ###### ',
' ## ',
' ## ## ',
' ##### ',
],
},
},
block: {
height: 6,
chars: {
A: ['█████╗ ', '██╔══██╗', '███████║', '██╔══██║', '██║ ██║', '╚═╝ ╚═╝'],
B: ['██████╗ ', '██╔══██╗', '██████╔╝', '██╔══██╗', '██████╔╝', '╚═════╝ '],
C: ['██████╗', '██╔════╝', '██║ ', '██║ ', '╚██████╗', ' ╚═════╝'],
D: ['██████╗ ', '██╔══██╗', '██║ ██║', '██║ ██║', '██████╔╝', '╚═════╝ '],
E: ['███████╗', '██╔════╝', '█████╗ ', '██╔══╝ ', '███████╗', '╚══════╝'],
F: ['███████╗', '██╔════╝', '█████╗ ', '██╔══╝ ', '██║ ', '╚═╝ '],
G: ['██████╗ ', '██╔════╝', '██║ ███╗', '██║ ██║', '╚██████╔╝', ' ╚═════╝ '],
H: ['██╗ ██╗', '██║ ██║', '███████║', '██╔══██║', '██║ ██║', '╚═╝ ╚═╝'],
I: ['██╗', '██║', '██║', '██║', '██║', '╚═╝'],
' ': [' ', ' ', ' ', ' ', ' ', ' '],
},
},
bubble: {
height: 5,
chars: {
A: [' Ⓐ ', ' ⒜ ⒜ ', '⒜⒜⒜⒜⒜', '⒜ ⒜', '⒜ ⒜'],
B: ['ⒷⒷⒷⒷ ', 'Ⓑ Ⓑ', 'ⒷⒷⒷⒷ ', 'Ⓑ Ⓑ', 'ⒷⒷⒷⒷ '],
C: [' ⒸⒸⒸ ', 'Ⓒ ', 'Ⓒ ', 'Ⓒ ', ' ⒸⒸⒸ '],
' ': [' ', ' ', ' ', ' ', ' '],
},
},
digital: {
height: 7,
chars: {
A: [' ▄▀▀▀▄ ', '▐ ▌', '▐▄▄▄▄▌', '▐ ▌', '▐ ▌', '▐ ▌', ' '],
B: ['▐▀▀▀▄ ', '▐▄▄▄▀ ', '▐▄▄▄▄ ', '▐ ▌', '▐▄▄▄▀ ', ' ', ' '],
C: [' ▄▀▀▀▄', '▐ ', '▐ ', '▐ ', ' ▀▄▄▄▀', ' ', ' '],
' ': [' ', ' ', ' ', ' ', ' ', ' ', ' '],
},
},
};
// Use selected font or fallback to standard
const font = fonts[style] || fonts.standard;
const lines = [];
const upperText = text.toUpperCase();
for (let i = 0; i < font.height; i++) {
lines[i] = '';
}
for (const char of upperText) {
const charLines = font.chars[char] || font.chars[' '];
if (charLines) {
for (let i = 0; i < font.height; i++) {
lines[i] += charLines[i] || ' '.repeat(font.chars[' '][i].length);
}
}
}
return lines.join('\n');
}
// Create ASCII box/frame
function createASCIIBox(text, style, padding) {
const styles = {
single: {
tl: '┌',
tr: '┐',
bl: '└',
br: '┘',
h: '─',
v: '│',
},
double: {
tl: '╔',
tr: '╗',
bl: '╚',
br: '╝',
h: '═',
v: '║',
},
rounded: {
tl: '╭',
tr: '╮',
bl: '╰',
br: '╯',
h: '─',
v: '│',
},
bold: {
tl: '┏',
tr: '┓',
bl: '┗',
br: '┛',
h: '━',
v: '┃',
},
ascii: {
tl: '+',
tr: '+',
bl: '+',
br: '+',
h: '-',
v: '|',
},
};
const chars = styles[style] || styles.single;
const lines = text.split('\n');
const maxLength = Math.max(...lines.map((l) => l.length));
const width = maxLength + padding * 2;
let result = '';
// Top border
result += chars.tl + chars.h.repeat(width) + chars.tr + '\n';
// Padding rows above
for (let i = 0; i < padding - 1; i++) {
result += chars.v + ' '.repeat(width) + chars.v + '\n';
}
// Content lines
for (const line of lines) {
const paddedLine = line.padEnd(maxLength, ' ');
result += chars.v + ' '.repeat(padding) + paddedLine + ' '.repeat(padding) + chars.v + '\n';
}
// Padding rows below
for (let i = 0; i < padding - 1; i++) {
result += chars.v + ' '.repeat(width) + chars.v + '\n';
}
// Bottom border
result += chars.bl + chars.h.repeat(width) + chars.br;
return result;
}
// ASCII Art Templates
function getASCIITemplate(templateName) {
const templates = {
'arrow-right': `
┌────────┐
│ │
────► NEXT │
│ │
└────────┘`,
'arrow-down': `
│
│
▼
┌──────┐
│ NEXT │
└──────┘`,
check: `
✓ Task completed
✓ All tests passed
✓ Ready to deploy
✓ Documentation updated`,
divider: `
═══════════════════════════════════════════════════════════
`,
header: `
╔═══════════════════════════════════════════════════╗
║ SECTION HEADER ║
╚═══════════════════════════════════════════════════╝`,
flowchart: `
┌─────────────┐
│ START │
└──────┬──────┘
│
▼
┌─────────────┐
│ PROCESS │
└──────┬──────┘
│
┌───┴───┐
│ Check │
└───┬───┘
│
┌───▼──┬──────┐
│ Yes │ No │
▼ ▼ │
┌────┐ ┌────┐ │
│ A │ │ B │ │
└─┬──┘ └─┬──┘ │
│ │ │
└──┬───┘ │
│◄──────────┘
▼
┌─────────────┐
│ END │
└─────────────┘`,
decision: `
┌─────────┐
│ Check? │
└────┬────┘
│
┌─────┴─────┐
│ │
Yes│ │No
▼ ▼
┌────────┐ ┌────────┐
│ True │ │ False │
└────────┘ └────────┘`,
sequence: `
User System Database
│ │ │
│ Request │ │
├──────────►│ │
│ │ Query │
│ ├──────────►│
│ │ │
│ │ Result │
│ │◄──────────┤
│ Response │ │
│◄──────────┤ │
│ │ │`,
'table-simple': `
┌──────────┬──────────┬──────────┐
│ Header 1 │ Header 2 │ Header 3 │
├──────────┼──────────┼──────────┤
│ Data 1 │ Data 2 │ Data 3 │
├──────────┼──────────┼──────────┤
│ Data 4 │ Data 5 │ Data 6 │
└──────────┴──────────┴──────────┘`,
timeline: `
2020 2021 2022 2023
│ │ │ │
●───────────●───────────●───────────●
│ │ │ │
Start Milestone Release Current`,
network: `
┌──────────┐
│ Server │
└────┬─────┘
│
┌─────────┼─────────┐
│ │ │
┌───▼───┐ ┌──▼────┐ ┌──▼────┐
│Client1│ │Client2│ │Client3│
└───────┘ └───────┘ └───────┘`,
hierarchy: `
┌─────────┐
│ Root │
└────┬────┘
│
┌────────┴────────┐
│ │
┌───▼───┐ ┌───▼───┐
│Child 1│ │Child 2│
└───┬───┘ └───┬───┘
│ │
┌───▼───┐ ┌───▼───┐
│Grand 1│ │Grand 2│
└───────┘ └───────┘`,
'process-flow': `
┌─────────┐ ┌─────────┐ ┌─────────┐
│ Input │────►│Process 1│────►│ Output │
└─────────┘ └────┬────┘ └─────────┘
│
┌────▼────┐
│Process 2│
└─────────┘`,
'note-box': `
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ NOTE: ┃
┃ This is an important note ┃
┃ that requires attention! ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛`,
'warning-box': `
╔════════════════════════════════════╗
║ ⚠ WARNING ║
║ Proceed with caution! ║
╚════════════════════════════════════╝`,
'info-box': `
╭────────────────────────────────────╮
│ ℹ Information │
│ Additional context here │
╰────────────────────────────────────╯`,
'separator-fancy': `
╭──────────────────────────────────────────────────────╮
│ │
╰──────────────────────────────────────────────────────╯`,
brackets: `
【 Important Text 】`,
'banner-stars': `
************************************************************************
* IMPORTANT BANNER *
************************************************************************`,
'progress-bar': `
Progress: [████████████░░░░░░░░] 60%
0% 100%`,
};
return templates[templateName] || '';
}
function loadASCIITemplate(templateName) {
const template = getASCIITemplate(templateName);
document.getElementById('ascii-preview').textContent = template;
}
function insertASCIIArt() {
const asciiArt = document.getElementById('ascii-preview').textContent;
if (!asciiArt || asciiArt === 'Select a template from the buttons above') {
notifyUser('Generate ASCII art first.', 'warning');
return;
}
// Insert using CodeMirror
if (!tabManager) {
notifyUser('No active editor found.', 'warning');
return;
}
// Insert in code block for proper rendering
const codeBlock = '\n```\n' + asciiArt + '\n```\n';
tabManager.insertAtCursor(codeBlock);
// Trigger update
if (tabManager) {
tabManager.handleEditorInput(tabManager.activeTabId);
}
// Close dialog
hideASCIIGenerator();
}
// ASCII Art Event Listeners
document.getElementById('ascii-dialog-close').addEventListener('click', hideASCIIGenerator);
document.getElementById('ascii-cancel').addEventListener('click', hideASCIIGenerator);
document.getElementById('ascii-generate').addEventListener('click', generateASCIIPreview);
document.getElementById('ascii-insert').addEventListener('click', insertASCIIArt);
// Mode switching
document.getElementById('ascii-mode-text').addEventListener('click', () => switchASCIIMode('text'));
document.getElementById('ascii-mode-box').addEventListener('click', () => switchASCIIMode('box'));
document
.getElementById('ascii-mode-templates')
.addEventListener('click', () => switchASCIIMode('templates'));
// Auto-update preview for text mode
document.getElementById('ascii-text-input').addEventListener('input', generateASCIIPreview);
document.getElementById('ascii-font-style').addEventListener('change', generateASCIIPreview);
// Auto-update preview for box mode
document.getElementById('ascii-box-text').addEventListener('input', generateASCIIPreview);
document.getElementById('ascii-box-style').addEventListener('change', generateASCIIPreview);
document.getElementById('ascii-box-padding').addEventListener('input', generateASCIIPreview);
// Template buttons
document.querySelectorAll('.ascii-template-btn').forEach((btn) => {
btn.addEventListener('click', function () {
const template = this.getAttribute('data-template');
loadASCIITemplate(template);
});
});
// IPC listener for menu
ipcRenderer.on('show-ascii-generator', () => {
showASCIIGenerator();
});
// ============================================================================
// PANE RESIZING
// ============================================================================