Liveweave: Generative AI Web Editor & HTML/CSS/JS Playground
Initializing
Liveweave
Web
expand_more
home
Home
Palette
Color Explorer
arrow_outward
Polyline
Graphics Editor
arrow_outward
frame_source
Python Playground
arrow_outward
build
Tools
expand_more
restart_alt
Load "Hello Weaver!"
post_add
Generate Lorem ipsum...
code
Format HTML
code_blocks
Format CSS
data_object
Format JavaScript
library_add
Library
expand_more
A
Algolia JS
Animate CSS
Apex Charts JS
B
Bulma CSS
Bootstrap
C
Chart JS
Chartist
Create JS
D
D3
Dojo
F
Foundation
Fullpage JS
G
Granim JS
Google Charts
H
Halfmoon
J
jQuery
M
Materialize
Moment JS
Masonry JS
Milligram CSS
P
Pure CSS
Primer CSS
Popper JS
Pattern CSS
Picnic CSS
R
React JS
Raphael JS
Raisin CSS
S
Semantic UI
Skeleton CSS
Spectre CSS
Tachyons CSS
T
Tailwind
Three JS
U
UI Kit
Vis JS
W
Water CSS
download
Download
expand_more
developer_mode
Download as HTML
folder_zip
Download as .ZIP
cloud_upload
Fork
account_circle
Login
settings
Settings
expand_more
Editor font
14
px
A
A
Night mode
Line number
Mini map
Word wrap
sync_alt
Reset Settings
smart_display
Run
left_panel_close
AI Assistant
dashboard
All
HTML
CSS
JS
visibility
Preview
bolt
Live Preview
terminal
JS Console
<!DOCTYPE html> <html> <head> <title>Rich text editor using Tiptap</title> </head> <body> <!-- Turn-off the Live Preview mode to run this properly --> <div class="typecraft-app" id="typecraftApp"> <header class="tc-topbar"> <div class="tc-brand"> <span class="tc-brand-icon">t</span> <span>typecraft<span class="tc-brand-dot">.</span></span> </div> <input class="tc-title" id="tcTitle" value="Untitled document" aria-label="Document title"> <div class="tc-top-actions"> <button id="tcNew" class="tc-button tc-light">New</button> <button id="tcDownload" class="tc-button tc-dark">Download</button> </div> </header> <main class="tc-main"> <section class="tc-editor"> <div class="tc-toolbar" id="tcToolbar"> <select id="tcFont" aria-label="Font family" title="Font family"> <option value="Arial">Arial</option> <option value="Georgia">Georgia</option> <option value="Times New Roman">Times New Roman</option> <option value="Verdana">Verdana</option> <option value="Courier New">Courier New</option> </select> <select id="tcSize" aria-label="Font size" title="Font size"> <option value="12px">12</option> <option value="14px" selected>14</option> <option value="16px">16</option> <option value="18px">18</option> <option value="20px">20</option> <option value="24px">24</option> <option value="28px">28</option> <option value="32px">32</option> <option value="36px">36</option> </select> <span class="tc-divider"></span> <button class="tc-tool" data-action="bold" title="Bold"><b>B</b></button> <button class="tc-tool" data-action="italic" title="Italic"><i>I</i></button> <button class="tc-tool" data-action="underline" title="Underline"><u>U</u></button> <span class="tc-divider"></span> <button class="tc-tool" data-action="alignLeft" title="Align left">☰</button> <button class="tc-tool" data-action="alignCenter" title="Center">≡</button> <button class="tc-tool" data-action="alignRight" title="Align right">☷</button> <span class="tc-divider"></span> <button class="tc-tool" data-action="bulletList" title="Bullet list">•≡</button> <button class="tc-tool" data-action="orderedList" title="Numbered list">1≡</button> <span class="tc-divider"></span> <label class="tc-color-control" title="Text color"> <span>A</span> <input type="color" id="tcColor" value="#30352f" aria-label="Text color"> </label> <span class="tc-divider"></span> <button class="tc-tool" data-action="undo" title="Undo">↶</button> <button class="tc-tool" data-action="redo" title="Redo">↷</button> </div> <div class="tc-paper-wrap"> <div class="tc-paper"> <div id="tcDocument"></div> </div> </div> <footer class="tc-statusbar"> <span id="tcStatus">Ready</span> <div> <span><b id="tcWordCount">0</b> words</span> <span class="tc-status-divider">·</span> <span><b id="tcCharCount">0</b> characters</span> </div> </footer> </section> </main> </div> <!-- End your code here --> </body> </html>
/********************************************************************/ /* IMPORTANT: Turn-off the "Live Preview" mode to run this properly */ /********************************************************************/ @import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap'); * { box-sizing: border-box; } body { margin: 0; padding: 0; background: #eae8e1; color: #343a34; font-family: 'DM Sans', Arial, sans-serif; } .typecraft-app { min-height: 100vh; background: #eae8e1; } /* HEADER */ .tc-topbar { min-height: 66px; padding: 12px 26px; display: flex; align-items: center; gap: 24px; background: #fbfaf6; border-bottom: 1px solid #deddd4; } .tc-brand { display: flex; align-items: center; gap: 9px; white-space: nowrap; font-size: 18px; font-weight: 700; letter-spacing: -1px; } .tc-brand-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 7px; background: #405c4b; color: white; font: italic 22px Georgia, serif; } .tc-brand-dot { color: #c47d57; } .tc-title { width: min(300px, 35vw); padding: 8px 10px; border: 1px solid transparent; border-radius: 4px; outline: none; background: transparent; color: #555c53; font: 13px 'DM Sans', sans-serif; } .tc-title:hover, .tc-title:focus { border-color: #d9d8ce; background: white; } .tc-top-actions { margin-left: auto; display: flex; gap: 8px; } .tc-button { border: 0; border-radius: 5px; padding: 10px 15px; cursor: pointer; font: 600 11px 'DM Sans', sans-serif; transition: background .2s ease; } .tc-light { background: #eeede6; color: #4d554c; } .tc-dark { background: #405c4b; color: white; } .tc-button:hover { filter: brightness(1.07); } /* MAIN WORKSPACE */ .tc-main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 40px; } .tc-editor { overflow: hidden; border: 1px solid #d7d5cb; border-radius: 7px; background: #fbfaf6; box-shadow: 0 8px 30px rgba(48, 47, 37, .06); } /* TOOLBAR */ .tc-toolbar { min-height: 52px; padding: 8px 13px; display: flex; align-items: center; flex-wrap: wrap; gap: 5px; background: #f5f3ed; border-bottom: 1px solid #deddd4; } /* CUSTOM DROPDOWN ARROWS */ .tc-toolbar select { appearance: none; -webkit-appearance: none; -moz-appearance: none; height: 31px; padding: 0 34px 0 12px !important; border: 1px solid #deddd4; border-radius: 5px; background-color: #fffefa; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%234c554c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; background-size: 14px 14px; color: #444b43; outline: none; font: 11px 'DM Sans', sans-serif; cursor: pointer; } #tcFont { width: 130px; } #tcSize { width: 62px; } .tc-tool { min-width: 30px; height: 30px; padding: 0 7px; border: 0; border-radius: 4px; background: transparent; color: #4c554c; cursor: pointer; font: 13px 'DM Sans', sans-serif; transition: background .15s ease; } .tc-tool:hover, .tc-tool.active { background: #e1e8df; color: #345541; } .tc-tool:disabled { opacity: .35; cursor: default; } .tc-divider { height: 22px; width: 1px; margin: 0 5px; background: #d9d7cd; } /* TEXT COLOR */ .tc-color-control { position: relative; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 4px; color: #394b3f; font-size: 16px; font-weight: 700; cursor: pointer; } .tc-color-control:hover { background: #e1e8df; } .tc-color-control input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; } /* DOCUMENT AREA */ .tc-paper-wrap { padding: 30px 20px; background: #eae8e1; } .tc-paper { width: 100%; max-width: 790px; min-height: 760px; margin: 0 auto; padding: 65px 76px; background: #fff; box-shadow: 0 2px 12px rgba(40, 40, 30, .07); } /* EDITABLE DOCUMENT */ #tcDocument { display: block; width: 100%; min-height: 620px; padding: 0; margin: 0; outline: none !important; border: none !important; box-shadow: none !important; background: transparent; overflow-wrap: anywhere; color: #30352f; caret-color: #405c4b; cursor: text; font: 14px/1.65 Arial, sans-serif; } /* REMOVE BLUE EDITING OUTLINES */ #tcDocument, #tcDocument:focus, #tcDocument:focus-visible, #tcDocument.ProseMirror, #tcDocument.ProseMirror:focus, #tcDocument.ProseMirror:focus-visible, #tcDocument.ProseMirror-focused, #tcDocument[contenteditable="true"], #tcDocument[contenteditable="true"]:focus { outline: none !important; border: none !important; box-shadow: none !important; } /* INDIVIDUAL DOCUMENT ELEMENTS */ #tcDocument *:focus, #tcDocument *:focus-visible, #tcDocument p:focus, #tcDocument h1:focus, #tcDocument h2:focus, #tcDocument h3:focus, #tcDocument li:focus { outline: none !important; border: none !important; box-shadow: none !important; } .tc-paper:focus, .tc-paper:focus-within, .tc-paper-wrap:focus-within { outline: none !important; box-shadow: none; } /* TEXT SELECTION */ #tcDocument ::selection { background: #c9ddce; color: #253b2d; } /* DOCUMENT TYPOGRAPHY */ #tcDocument p { margin: 0 0 12px; } #tcDocument h1, #tcDocument h2, #tcDocument h3 { line-height: 1.3; margin: 20px 0 12px; } #tcDocument h1 { font-size: 30px; } #tcDocument h2 { font-size: 23px; } #tcDocument h3 { font-size: 18px; } #tcDocument ul, #tcDocument ol { padding-left: 27px; margin: 12px 0; } #tcDocument li { margin-bottom: 5px; } #tcDocument blockquote { margin: 18px 0; padding-left: 18px; border-left: 3px solid #8b9b85; color: #686f66; } #tcDocument a { color: #456f8a; text-decoration: underline; } #tcDocument pre { padding: 14px; border-radius: 4px; background: #f0f0ed; white-space: pre-wrap; overflow-x: auto; } #tcDocument code { font-family: 'Courier New', monospace; } #tcDocument hr { border: 0; border-top: 1px solid #ddd; margin: 22px 0; } #tcDocument img { max-width: 100%; height: auto; } /* STATUS BAR */ .tc-statusbar { min-height: 39px; padding: 9px 16px; display: flex; justify-content: space-between; gap: 12px; background: #f5f3ed; border-top: 1px solid #deddd4; color: #898b80; font-size: 10px; } .tc-statusbar > div { display: flex; gap: 8px; } .tc-statusbar b { color: #526552; font-weight: 600; } .tc-status-divider { color: #b5b3a9; } /* ACCESSIBLE TOOLBAR FOCUS */ .tc-tool:focus-visible, .tc-button:focus-visible, .tc-toolbar select:focus-visible { outline: 2px solid #8b9b85; outline-offset: 2px; } /* RESPONSIVE */ @media (max-width: 700px) { .tc-topbar { padding: 12px; gap: 10px; flex-wrap: wrap; } .tc-title { order: 3; width: 100%; } .tc-main { padding: 15px 9px 25px; } .tc-paper-wrap { padding: 12px 7px; } .tc-paper { min-height: 650px; padding: 35px 22px; } .tc-toolbar { gap: 3px; padding: 8px; } .tc-divider { margin: 0 2px; } #tcFont { width: 105px; } .tc-statusbar { font-size: 9px; } } @media (max-width: 380px) { .tc-brand { font-size: 16px; } .tc-button { padding: 9px 11px; } .tc-toolbar { gap: 2px; } .tc-tool { min-width: 27px; } .tc-divider { margin: 0 1px; } }
/********************************************************************/ /* IMPORTANT: Turn-off the "Live Preview" mode to run this properly */ /********************************************************************/ (function () { const root = document.getElementById('typecraftApp'); if (!root || root.dataset.started === 'true') return; root.dataset.started = 'true'; const status = document.getElementById('tcStatus'); function setStatus(message) { status.textContent = message; } const script = document.createElement('script'); script.type = 'module'; script.textContent = ` import { Editor, Extension } from 'https://esm.sh/@tiptap/core@2.11.5'; import StarterKit from 'https://esm.sh/@tiptap/starter-kit@2.11.5'; import Underline from 'https://esm.sh/@tiptap/extension-underline@2.11.5'; import TextStyle from 'https://esm.sh/@tiptap/extension-text-style@2.11.5'; import FontFamily from 'https://esm.sh/@tiptap/extension-font-family@2.11.5'; import Color from 'https://esm.sh/@tiptap/extension-color@2.11.5'; import TextAlign from 'https://esm.sh/@tiptap/extension-text-align@2.11.5'; const root = document.getElementById('typecraftApp'); const documentArea = document.getElementById('tcDocument'); const status = document.getElementById('tcStatus'); function setStatus(message) { status.textContent = message; } // Add a simple font-size attribute to the TextStyle mark. const FontSize = Extension.create({ name: 'fontSize', addGlobalAttributes() { return [{ types: ['textStyle'], attributes: { fontSize: { default: null, parseHTML: element => element.style.fontSize || null, renderHTML: attributes => { if (!attributes.fontSize) return {}; return { style: 'font-size: ' + attributes.fontSize }; } } } }]; } }); const editor = new Editor({ element: documentArea, extensions: [ StarterKit, Underline, TextStyle, FontFamily, Color, FontSize, TextAlign.configure({ types: ['heading', 'paragraph'] }) ], content: '<p></p>', editorProps: { attributes: { spellcheck: 'true', autocorrect: 'on', autocapitalize: 'sentences', 'aria-label': 'Editable document' } }, onUpdate: function () { updateStats(); updateToolbar(); setStatus('Editing'); }, onSelectionUpdate: function () { updateToolbar(); }, onTransaction: function () { updateToolbar(); } }); function updateStats() { const text = editor.getText(); const trimmed = text.trim(); const words = trimmed ? trimmed.split(/\\s+/).length : 0; document.getElementById('tcWordCount').textContent = words; document.getElementById('tcCharCount').textContent = text.length; } function updateToolbar() { const activeStates = { bold: editor.isActive('bold'), italic: editor.isActive('italic'), underline: editor.isActive('underline'), bulletList: editor.isActive('bulletList'), orderedList: editor.isActive('orderedList') }; Object.keys(activeStates).forEach(function (action) { const button = root.querySelector('[data-action="' + action + '"]'); if (button) { button.classList.toggle('active', activeStates[action]); } }); const undo = root.querySelector('[data-action="undo"]'); const redo = root.querySelector('[data-action="redo"]'); undo.disabled = !editor.can().undo(); redo.disabled = !editor.can().redo(); const font = editor.getAttributes('textStyle').fontFamily; const size = editor.getAttributes('textStyle').fontSize; const fontSelect = document.getElementById('tcFont'); const sizeSelect = document.getElementById('tcSize'); if (font) { fontSelect.value = font.replace(/["']/g, ''); } if (size) { sizeSelect.value = size; } } function runAction(action) { const chain = editor.chain().focus(); switch (action) { case 'bold': chain.toggleBold().run(); break; case 'italic': chain.toggleItalic().run(); break; case 'underline': chain.toggleUnderline().run(); break; case 'alignLeft': chain.setTextAlign('left').run(); break; case 'alignCenter': chain.setTextAlign('center').run(); break; case 'alignRight': chain.setTextAlign('right').run(); break; case 'bulletList': chain.toggleBulletList().run(); break; case 'orderedList': chain.toggleOrderedList().run(); break; case 'undo': chain.undo().run(); break; case 'redo': chain.redo().run(); break; } updateToolbar(); } // Keep the editor selection when clicking formatting buttons. root.querySelectorAll('[data-action]').forEach(function (button) { button.addEventListener('mousedown', function (event) { event.preventDefault(); }); button.addEventListener('click', function () { runAction(button.dataset.action); }); }); // Font family. document.getElementById('tcFont').addEventListener('change', function () { editor.chain().focus().setFontFamily(this.value).run(); }); // Font size. document.getElementById('tcSize').addEventListener('change', function () { editor.chain().focus() .setMark('textStyle', { fontSize: this.value }) .run(); }); // Text color. document.getElementById('tcColor').addEventListener('input', function () { editor.chain().focus().setColor(this.value).run(); }); // Start a new blank document. document.getElementById('tcNew').addEventListener('click', function () { if (!window.confirm('Start a new blank document?')) return; editor.commands.setContent('<p></p>'); document.getElementById('tcTitle').value = 'Untitled document'; editor.commands.focus(); updateStats(); updateToolbar(); setStatus('New document'); }); // Download the complete document as standalone HTML. document.getElementById('tcDownload').addEventListener('click', function () { const titleInput = document.getElementById('tcTitle').value.trim(); const title = titleInput || 'Untitled document'; const safeTitle = title.replace(/[&<>"']/g, function (character) { return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[character]; }); const html = '<!DOCTYPE html>\\n' + '<html lang="en">\\n' + '<head>\\n' + '<meta charset="UTF-8">\\n' + '<meta name="viewport" content="width=device-width, initial-scale=1.0">\\n' + '<title>' + safeTitle + '</title>\\n' + '<style>' + 'body{max-width:850px;margin:50px auto;padding:0 30px;font:14px/1.65 Arial,sans-serif;color:#30352f}' + 'h1,h2,h3{line-height:1.3}blockquote{border-left:3px solid #8b9b85;padding-left:18px;color:#686f66}' + 'pre{padding:14px;background:#f0f0ed;white-space:pre-wrap}' + 'img{max-width:100%}' + '</style>\\n' + '</head>\\n<body>\\n' + editor.getHTML() + '\\n</body>\\n</html>'; const blob = new Blob([html], { type: 'text/html;charset=utf-8' }); const url = URL.createObjectURL(blob); const link = document.createElement('a'); link.href = url; link.download = title.replace(/[^a-z0-9_-]+/gi, '-').toLowerCase() + '.html'; document.body.appendChild(link); link.click(); link.remove(); setTimeout(function () { URL.revokeObjectURL(url); }, 1000); setStatus('Document downloaded'); }); updateStats(); updateToolbar(); setStatus('Ready'); root.dataset.ready = 'true'; editor.commands.focus(); `; script.onerror = function () { setStatus('Could not load the editor library. Check your internet connection.'); }; document.body.appendChild(script); })();
terminal
JavaScript Console
Preview
Clear
close
›
Run