Update wireframe-renderer.component.ts

This commit is contained in:
string 2025-05-31 20:47:28 +05:30
parent d0a336928c
commit 3529008e16

View File

@ -1998,23 +1998,62 @@ async generateJson(data: { jsonStructure: any, sectionType: string }): Promise<s
});
}
downloadHtml(pageName: string) {
// Make sure we're using the sections in the correct order
const orderedSectionKeys = this.sectionOrderMap[pageName] || this.getSectionKeys(pageName);
// downloadHtml(pageName: string) {
// // Make sure we're using the sections in the correct order
// console.log(pageName, ' downloading ..')
// const orderedSectionKeys = this.sectionOrderMap[pageName] || this.getSectionKeys(pageName);
// Update the sectionHtmls order to match orderedSectionKeys
const reorderedSectionHtmls: Record<string, SafeHtml> = {};
for (const sectionKey of orderedSectionKeys) {
if (this.sectionHtmls[pageName][sectionKey]) {
reorderedSectionHtmls[sectionKey] = this.sectionHtmls[pageName][sectionKey];
}
// // Update the sectionHtmls order to match orderedSectionKeys
// const reorderedSectionHtmls: Record<string, SafeHtml> = {};
// for (const sectionKey of orderedSectionKeys) {
// if (this.sectionHtmls[pageName][sectionKey]) {
// reorderedSectionHtmls[sectionKey] = this.sectionHtmls[pageName][sectionKey];
// }
// }
// console.log('📦 Original sectionHtmls:', this.sectionHtmls[pageName]);
// console.log('📦 Section order:', orderedSectionKeys);
// console.log('📦 FullPage HTML:', this.pageSections[pageName]?.FullPage);
// this.sectionHtmls[pageName] = reorderedSectionHtmls;
// console.log('page data ',reorderedSectionHtmls)
// // Now update the full page HTML with correct order
// // this.updateFullPageHtml(pageName);
// // const fullHtml = this.pageSections[pageName].FullPage.toString();
// const fullHtml = this.pageSections[pageName].FullPage; // must be plain string
// if (!fullHtml || typeof fullHtml !== 'string' || fullHtml.trim() === '') {
// alert(`⚠️ No content available for page "${pageName}". Please generate HTML first.`);
// console.error('❌ FullPage content missing or empty for:', pageName);
// return;
// }
// const blob = new Blob([fullHtml], { type: 'text/html' });
// const url = window.URL.createObjectURL(blob);
// const link = document.createElement('a');
// link.href = url;
// link.download = `${pageName}.html`;
// link.click();
// window.URL.revokeObjectURL(url);
// }
// Upload HTML files
downloadHtml(pageName: string) {
console.log(pageName, ' downloading ..');
const fullHtml = this.pageSections[pageName]?.FullPage;
if (!fullHtml || typeof fullHtml !== 'string' || fullHtml.trim() === '') {
alert(`⚠️ No content available for page "${pageName}". Please generate HTML first.`);
console.error('❌ FullPage content missing or empty for:', pageName);
return;
}
this.sectionHtmls[pageName] = reorderedSectionHtmls;
// Now update the full page HTML with correct order
this.updateFullPageHtml(pageName);
const fullHtml = this.pageSections[pageName].FullPage.toString();
console.log('📦 FullPage HTML:', fullHtml);
const blob = new Blob([fullHtml], { type: 'text/html' });
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
@ -2023,7 +2062,7 @@ downloadHtml(pageName: string) {
link.click();
window.URL.revokeObjectURL(url);
}
// Upload HTML files
buildWireframe(projId: number) {
const pageHtmlMap: Record<string, string> = {};
@ -2551,16 +2590,32 @@ setCurrentPage(index: number): void {
}
// Copy specific page to clipboard
// copyPageToClipboard(pageName?: string): void {
// const pageToSelect = pageName || this.getCurrentPageName();
// const html = this.mapofPageAndHtmlBody[pageToSelect];
// if (html) {
// navigator.clipboard.writeText(html).then(() => {
// this.toastr.success(`${pageToSelect} copied to clipboard!`);
// }).catch(() => {
// this.toastr.error('Failed to copy to clipboard');
// });
// }
// }
copyPageToClipboard(pageName?: string): void {
const pageToSelect = pageName || this.getCurrentPageName();
const html = this.mapofPageAndHtmlBody[pageToSelect];
if (html) {
const html = this.mapofPageAndHtmlBody?.[pageToSelect] || this.pageSections?.[pageToSelect]?.FullPage;
if (html && typeof html === 'string' && html.trim() !== '') {
navigator.clipboard.writeText(html).then(() => {
this.toastr.success(`${pageToSelect} copied to clipboard!`);
}).catch(() => {
}).catch((err) => {
console.error('❌ Clipboard error:', err);
this.toastr.error('Failed to copy to clipboard');
});
} else {
console.warn(`⚠️ No HTML content found for: ${pageToSelect}`);
this.toastr.error(`Nothing to copy for page "${pageToSelect}"`);
}
}
@ -2568,6 +2623,7 @@ copyPageToClipboard(pageName?: string): void {
getAllSectionLists(): HTMLElement[] {
return Array.from(document.querySelectorAll('.connected-sections')) as HTMLElement[];
}
@ -2810,10 +2866,10 @@ endPan(): void {
// });
// }
downloadCurrentPage(): void {
const currentPage = this.getCurrentPageName();
this.downloadHtml(currentPage);
}
// downloadCurrentPage(): void {
// const currentPage = this.getCurrentPageName();
// this.downloadHtml(currentPage);
// }
// Update existing download method
handleDirectContentEdit(event: Event, page: string, section: string) {