Examples

DOCX Export

The editor exports its HTML to a Microsoft Word .docx file via a server endpoint you control. The server uses MIT-licensed DocumentFormat.OpenXml to build the document (paragraphs, headings, lists, tables, inline formatting, hyperlinks, data-URI images, text alignment, colors). No external service, no cloud API, no DOCX SaaS subscription.

This is a server-driven feature. The demo below calls a mock endpoint that returns the editor’s HTML as an illustration — for a live DOCX response, wire up the ASP.NET Core RichTextBox.AspNetCore endpoint or your own converter.

Quarterly update

Summary. Revenue grew 15% year-over-year.

  • Two new enterprise customers in March.
  • Streaming AI shipped in preview.10.
Our buyers want one perpetual license, not three subscription SKUs.

Example code

<link rel="stylesheet" href="/richtexteditor/rte_theme_default.css" />
        <script type="text/javascript" src="/richtexteditor/rte.js"></script>
        <script type="text/javascript" src='/richtexteditor/plugins/all_plugins.js'></script>

        <div id="docx_editor">
            <h3>Quarterly update</h3>
            <p><strong>Summary.</strong> Revenue grew <em>15%</em> year-over-year.</p>
            <ul><li>Two new enterprise customers in March.</li><li>Streaming AI shipped in preview.10.</li></ul>
            <blockquote>Our buyers want one perpetual license, not three subscription SKUs.</blockquote>
        </div>

        <button type="button" onclick="exportToDocx()" style="margin-top:.5rem; padding:8px 18px; border-radius:999px; background:#0f172a; color:#fff; border:0; cursor:pointer; font-weight:600;">
            Export to .docx
        </button>
        <span id="docxStatus" style="margin-left:12px; color:#64748b; font-size:13px;"></span>

        <script>
            var docxEditor = new RichTextEditor("#docx_editor", { toolbar: "default" });

            function exportToDocx() {
                var status = document.getElementById("docxStatus");
                status.textContent = "Calling server endpoint...";

                if (!docxEditor.aiToolkit || typeof docxEditor.aiToolkit.exportDocx !== "function") {
                    status.textContent = "exportDocx helper not available (make sure aitoolkit.js is loaded).";
                    return;
                }

                docxEditor.aiToolkit.exportDocx({
                    // In production, replace with your own DOCX endpoint — e.g. /richtextbox/export/docx (ASP.NET Core).
                    url: "/richtextbox/export/docx",
                    fileName: "quarterly-update.docx",
                    title: "Quarterly update",
                    onError: function (err) { status.textContent = "Failed: " + err.message; }
                }).then(function (name) {
                    status.textContent = "Downloaded " + name;
                }).catch(function () { /* handled in onError */ });
            }
        </script>