You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(formatter): replace input textarea with rich text contenteditable editor
The input pane now uses a contenteditable div instead of a textarea,
so pasting rich text from Word, Google Docs, or any webpage renders
visually (bold, headings, links, etc.) instead of showing raw HTML
source. Clicking Format extracts the underlying HTML and outputs
clean markup — matching the htmltidy.net workflow.
- Input: contenteditable div with sans-serif font for visual editing
- Output: textarea with monospace font for HTML source code
- Paste handler strips clipboard StartFragment/EndFragment boilerplate
- Example updated to rich text snippet showing realistic CMS cleanup
- CSS split into .editor-richtext (input) and .editor-textarea (output)
Agent: Main Assistant
Machine: WPMNB-JHP69N7
Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
* Rich text example — rendered visually in the contenteditable input.
563
+
* Simulates what you'd get pasting from a word processor or CMS.
564
+
*/
565
+
constEXAMPLE_RICH_HTML=`<h1 style="font-size:24px;color:#333" CLASS="title">Welcome to My Website</h1>
566
+
<p style="margin-bottom:12px">This is a <strong>sample page</strong> with <em>mixed formatting</em>,
567
+
<span style="color:red;font-weight:bold" class="highlight">inline styles</span>, and various issues that need cleaning.</p>
568
+
<h2>Features</h2>
569
+
<ul>
570
+
<li>Fast loading</li>
571
+
<li>Responsive design</li>
572
+
<li>Accessible markup</li>
573
+
</ul>
574
+
<p>Visit <a HREF="https://example.com" TARGET="_blank" REL="noopener" style="color:blue">our website</a> for more information.</p>
575
+
<p data-source="cms" class="body-text" id="intro">This paragraph has <span style="font-weight:bold"><span class="">unnecessary wrapper spans</span></span> and extra attributes that should be cleaned up.</p>
576
+
<div></div>
577
+
<!-- TODO: add sidebar -->`;
578
+
579
+
/**
580
+
* Get the HTML content from the contenteditable input.
581
+
* Returns trimmed innerHTML.
582
+
*/
583
+
functiongetInputHTML(el){
584
+
// innerHTML is used intentionally — this is a rich text editing tool
585
+
// where rendering user-pasted HTML is the core functionality.
586
+
// All processing is client-side; nothing is sent to a server.
587
+
returnel.innerHTML.trim();
588
+
}
589
+
590
+
/**
591
+
* Set the HTML content of the contenteditable input.
592
+
* innerHTML is safe here — this is a local-only HTML editing tool.
0 commit comments