Embed Tritium as an HTML Element


Embed the Tritium Legal IDE in your existing web platform with a small code snippet.

<input type="file">
<canvas id="tritium-canvas"></canvas>

<script type="module">
    const tritium = await import("https://tritium.legal/static/init.js");

    // Attach a save handler to receive saved files.
    tritium.setSaveHandler(({ file, id }) => {
        window.alert(`Saving ${file.size} bytes to: ${file.name} (${id})`);
    });

    // Open files in the IDE or pass a document containing a browser File.
    const input = document.querySelector("input[type=file]");
    input.addEventListener("change", async () => {
        const file = input.files?.[0];
        if (file) {
            await tritium.openFile({ file });
        }
    });
    
    // Start with no `documents` or `folder` for the launch view.
    await tritium.start({settings: {showLauncher: true, provider: {Tritium: {}}}});
</script>

That's it! The snippet gives you this:

Learn more about our web API in the documentation pages or request source access.