1(function () { 2 let docxPreviewLoaded = false; 3 4 function loadScript(url) { 5 return new Promise((resolve, reject) => { 6 const existingScript = document.querySelector(`script[src="${url}"]`); 7 if (existingScript) { 8 resolve(); 9 return; 10 } 11 12 const script = document.createElement('script'); 13 script.src = url; 14 script.onload = () => resolve(); 15 script.onerror = () => reject(new Error(`Failed to load script: ${url}`)); 16 document.head.appendChild(script); 17 }); 18 } 19 20 // Main render function called from Blazor via JS interop 21 window.argusRenderDocx = async function (base64Data, containerId) { 22 try { 23 const container = document.getElementById(containerId); 24 if (!container) { 25 console.error(`argusRenderDocx: container "${containerId}" not found`); 26 return; 27 } 28 29 container.innerHTML = '<div class="text-center text-muted p-4"><i class="fa fa-spinner fa-spin"></i> Loading document...</div>'; 30 31 // jszip must be loaded before docx-preview (required dependency per README) 32 if (!docxPreviewLoaded) { 33 await loadScript('https://unpkg.com/jszip/dist/jszip.min.js'); 34 await loadScript('https://cdn.jsdelivr.net/npm/docx-preview/dist/docx-preview.min.js'); 35 docxPreviewLoaded = true; 36 } 37 38 // Decode base64 string to Uint8Array 39 // renderAsync accepts Blob | ArrayBuffer | Uint8Array (JSZip-compatible) 40 const binaryString = atob(base64Data); 41 const bytes = new Uint8Array(binaryString.length); 42 for (let i = 0; i < binaryString.length; i++) { 43 bytes[i] = binaryString.charCodeAt(i); 44 } 45 46 container.innerHTML = ''; 47 48 await docx.renderAsync(bytes, container, null, { 49 className: 'docx', // default class prefix used by docx-preview styles 50 inWrapper: true, 51 breakPages: true, 52 useBase64URL: true, // inline images/fonts as base64 (no blob URLs) 53 ignoreWidth: false, 54 ignoreHeight: true, // let the dialog control height â no internal scroll 55 experimental: true, 56 renderHeaders: true, 57 renderFooters: true, 58 renderFootnotes: true, 59 renderEndnotes: true 60 }); 61 62 } catch (error) { 63 console.error('argusRenderDocx error:', error); 64 const container = document.getElementById(containerId); 65 if (container) { 66 container.innerHTML = `<div class="alert alert-danger m-3">Failed to render document: ${error.message}</div>`; 67 } 68 } 69 }; 70})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.