fix(export): enable proper file downloads and fix empty PNG export
This commit is contained in:
@@ -417,11 +417,27 @@ export class AsciiController {
|
||||
// ============= Export =============
|
||||
|
||||
savePNG(): void {
|
||||
const wasShowing = this.zoomState.showMagnifier;
|
||||
|
||||
// 1. Force hide magnifier for clean export
|
||||
if (wasShowing) {
|
||||
this.zoomState.showMagnifier = false;
|
||||
this.requestRender('uniforms');
|
||||
// Force synchronous render
|
||||
this.renderFrame();
|
||||
}
|
||||
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
||||
AsciiExporter.downloadPNG(this.canvas, `ascii-art-${timestamp}.png`);
|
||||
|
||||
// 2. Restore state
|
||||
if (wasShowing) {
|
||||
this.zoomState.showMagnifier = true;
|
||||
this.requestRender('uniforms');
|
||||
}
|
||||
}
|
||||
|
||||
async copyText(): Promise<void> {
|
||||
saveText(): void {
|
||||
if (!this.cachedGrid.imgEl) return;
|
||||
const text = AsciiExporter.generateText(
|
||||
this.cachedGrid.imgEl,
|
||||
@@ -429,10 +445,11 @@ export class AsciiController {
|
||||
this.cachedGrid.widthCols,
|
||||
Math.floor(this.cachedGrid.heightRows)
|
||||
);
|
||||
await AsciiExporter.copyToClipboard(text);
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
||||
AsciiExporter.downloadText(text, `ascii-art-${timestamp}.txt`);
|
||||
}
|
||||
|
||||
async copyHTML(): Promise<void> {
|
||||
saveHTML(): void {
|
||||
if (!this.cachedGrid.imgEl) return;
|
||||
const html = AsciiExporter.generateHTML(
|
||||
this.cachedGrid.imgEl,
|
||||
@@ -440,7 +457,8 @@ export class AsciiController {
|
||||
this.cachedGrid.widthCols,
|
||||
Math.floor(this.cachedGrid.heightRows)
|
||||
);
|
||||
await AsciiExporter.copyToClipboard(html);
|
||||
const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
||||
AsciiExporter.downloadText(html, `ascii-art-${timestamp}.html`);
|
||||
}
|
||||
|
||||
// ============= Utilities =============
|
||||
|
||||
Reference in New Issue
Block a user