--- import Icon from './Icon.astro' import CaptureScript from '../components/CaptureScript.astro' interface Props { id: string class?: string clear?: boolean width?: number height?: number event?: string /** extra-js param — raw JS appended inside the init callback */ extraJs?: string } const { id, class: className, clear, width = 400, height = 400, event = 'DOMContentLoaded', extraJs } = Astro.props const signatureClass = ['signature position-relative', className] const clearSnippet = clear ? ` document.querySelector(${JSON.stringify(`#signature-${id}-clear`)}).addEventListener("click", function () { signaturePad.clear(); }); ` : '' // extraJs is a documented escape hatch for raw JS (see Props) — not user data, so it // stays interpolated verbatim rather than JSON-serialized. const extraSnippet = extraJs ? `${extraJs} ` : '' // set:html (below) is genuinely required here: extraJs is a documented raw-JS escape // hatch that must land *inside* the init callback body (it references canvas / // signaturePad), so the whole script has to be assembled as text — ` ---
{ clear && (
) }