Update wireframe-renderer.component.ts
This commit is contained in:
		
							parent
							
								
									d0a336928c
								
							
						
					
					
						commit
						3529008e16
					
				@ -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
 | 
				
			||||||
 | 
					//   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];
 | 
				
			||||||
 | 
					//     }
 | 
				
			||||||
 | 
					//   }
 | 
				
			||||||
 | 
					//   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) {
 | 
					   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 fullHtml = this.pageSections[pageName]?.FullPage;
 | 
				
			||||||
  const reorderedSectionHtmls: Record<string, SafeHtml> = {};
 | 
					
 | 
				
			||||||
  for (const sectionKey of orderedSectionKeys) {
 | 
					  if (!fullHtml || typeof fullHtml !== 'string' || fullHtml.trim() === '') {
 | 
				
			||||||
    if (this.sectionHtmls[pageName][sectionKey]) {
 | 
					    alert(`⚠️ No content available for page "${pageName}". Please generate HTML first.`);
 | 
				
			||||||
      reorderedSectionHtmls[sectionKey] = this.sectionHtmls[pageName][sectionKey];
 | 
					    console.error('❌ FullPage content missing or empty for:', pageName);
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  this.sectionHtmls[pageName] = reorderedSectionHtmls;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Now update the full page HTML with correct order
 | 
					  console.log('📦 FullPage HTML:', fullHtml);
 | 
				
			||||||
  this.updateFullPageHtml(pageName);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const fullHtml = this.pageSections[pageName].FullPage.toString();
 | 
					 | 
				
			||||||
  const blob = new Blob([fullHtml], { type: 'text/html' });
 | 
					  const blob = new Blob([fullHtml], { type: 'text/html' });
 | 
				
			||||||
  const url = window.URL.createObjectURL(blob);
 | 
					  const url = window.URL.createObjectURL(blob);
 | 
				
			||||||
  const link = document.createElement('a');
 | 
					  const link = document.createElement('a');
 | 
				
			||||||
@ -2023,7 +2062,7 @@ downloadHtml(pageName: string) {
 | 
				
			|||||||
  link.click();
 | 
					  link.click();
 | 
				
			||||||
  window.URL.revokeObjectURL(url);
 | 
					  window.URL.revokeObjectURL(url);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
    // Upload HTML files
 | 
					
 | 
				
			||||||
    buildWireframe(projId: number) {
 | 
					    buildWireframe(projId: number) {
 | 
				
			||||||
        const pageHtmlMap: Record<string, string> = {};
 | 
					        const pageHtmlMap: Record<string, string> = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2551,16 +2590,32 @@ setCurrentPage(index: number): void {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Copy specific page to clipboard
 | 
					// 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 {
 | 
					copyPageToClipboard(pageName?: string): void {
 | 
				
			||||||
  const pageToSelect = pageName || this.getCurrentPageName();
 | 
					  const pageToSelect = pageName || this.getCurrentPageName();
 | 
				
			||||||
  const html = this.mapofPageAndHtmlBody[pageToSelect];
 | 
					  const html = this.mapofPageAndHtmlBody?.[pageToSelect] || this.pageSections?.[pageToSelect]?.FullPage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (html) {
 | 
					  if (html && typeof html === 'string' && html.trim() !== '') {
 | 
				
			||||||
    navigator.clipboard.writeText(html).then(() => {
 | 
					    navigator.clipboard.writeText(html).then(() => {
 | 
				
			||||||
      this.toastr.success(`${pageToSelect} copied to clipboard!`);
 | 
					      this.toastr.success(`${pageToSelect} copied to clipboard!`);
 | 
				
			||||||
    }).catch(() => {
 | 
					    }).catch((err) => {
 | 
				
			||||||
 | 
					      console.error('❌ Clipboard error:', err);
 | 
				
			||||||
      this.toastr.error('Failed to copy to clipboard');
 | 
					      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[] {
 | 
					getAllSectionLists(): HTMLElement[] {
 | 
				
			||||||
  return Array.from(document.querySelectorAll('.connected-sections')) as HTMLElement[];
 | 
					  return Array.from(document.querySelectorAll('.connected-sections')) as HTMLElement[];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -2810,10 +2866,10 @@ endPan(): void {
 | 
				
			|||||||
//   });
 | 
					//   });
 | 
				
			||||||
// }
 | 
					// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
downloadCurrentPage(): void {
 | 
					// downloadCurrentPage(): void {
 | 
				
			||||||
  const currentPage = this.getCurrentPageName();
 | 
					//   const currentPage = this.getCurrentPageName();
 | 
				
			||||||
  this.downloadHtml(currentPage);
 | 
					//   this.downloadHtml(currentPage);
 | 
				
			||||||
}
 | 
					// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Update existing download method
 | 
					// Update existing download method
 | 
				
			||||||
      handleDirectContentEdit(event: Event, page: string, section: string) {
 | 
					      handleDirectContentEdit(event: Event, page: string, section: string) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user