`;
return wrapper.firstElementChild;
}
async function handleError(err, guid, imgElementId) {
updateStatus(`Error: ${err.message}`, true);
const imgElement = document.getElementById(imgElementId);
if (imgElement && imgElement.parentNode) {
const errorSvg = createErrorSvgElement(imgElementId);
imgElement.replaceWith(errorSvg);
}
}
function escapeODataString(value) {
return value.replace(/'/g, "''");
}
async function displayImageSecurely(filename, imgElementId, isProtected = 0) {
let guid = null;
const safeFilename = escapeODataString(filename);
try {
const imgElement = document.getElementById(imgElementId);
if (!imgElement) throw new Error(`Image element with ID '${imgElementId}' not found.`);
imgElement.src = `${AzureBaseUrl}/api/fetchblobimage?Image=${filename}`;
imgElement.alt = filename;
imgElement.onerror = () => {
console.warn(`Image failed: ${filename}`);
imgElement.dataset.loadFailed = "true";
imgElement.removeAttribute("src");
const errorSvg = createErrorSvgElement(imgElementId);
imgElement.replaceWith(errorSvg);
};
const blobUrl = `${AzureBaseUrl}/api/fetchblobimage?Image=${filename}`;
return blobUrl;
} catch (err) {
await handleError(err, guid, imgElementId);
}
}
return { displayImageSecurely };
})();
}
})();
${block.Paragraph || ""}`;
break;
case "Link":
const isProtected = String(block.IsProtected).toLowerCase() === 'true' ? 1 : 0;
const linkAttrs = `
href="#"
data-href="${block.Link}"
onclick="SecureLinkHandler.handleProtectedNavigation(event, this, ${isProtected})"
rel="noopener noreferrer"
`;
const linkInnerHTML = `${block.LinkTitle || "Click here"}