diff --git a/plugins/default-editor/frontend/src/index.js b/plugins/default-editor/frontend/src/index.js index 91adefb..5728f9c 100644 --- a/plugins/default-editor/frontend/src/index.js +++ b/plugins/default-editor/frontend/src/index.js @@ -6,7 +6,6 @@ (function () { 'use strict'; - /* ── Style injection ─────────────────────────────────────── */ function injectStyles() { if (document.getElementById('de-style-injected')) return; var style = document.createElement('style'); @@ -16,114 +15,41 @@ } var STYLES = [ - '.de-root { display:flex; flex-direction:column; height:100%; min-height:0; overflow:hidden; font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif; color:#e0e0e0; }', - '.de-toolbar { display:flex; align-items:center; gap:0.5rem; padding:0.5rem 0.75rem; border-bottom:1px solid #16213e; flex-shrink:0; background:#12122a; }', - '.de-toolbar-mode { font-size:0.75rem; color:#4ecca3; padding:0.15rem 0.5rem; border-radius:3px; background:#1a2a3a; }', - '.de-toolbar-context { font-size:0.7rem; color:#8b8ba8; margin-left:0.25rem; }', - '.de-toolbar-spacer { flex:1; }', - '.de-toolbar-btn { font-size:0.75rem; padding:0.25rem 0.6rem; border:1px solid #333; border-radius:4px; background:#1a1a2e; color:#ccc; cursor:pointer; }', - '.de-toolbar-btn:hover { background:#2a2a4e; border-color:#4ecca3; }', - '.de-toolbar-btn.active { background:#1a3a2a; border-color:#4ecca3; color:#4ecca3; }', - '.de-toolbar-btn:disabled { opacity:0.4; cursor:default; }', - '.de-status { font-size:0.7rem; color:#8b8ba8; padding:0.15rem 0.5rem; }', - '.de-status.saved { color:#4ecca3; }', - '.de-status.error { color:#e74c3c; }', - '.de-status.dirty { color:#f39c12; }', - '.de-editor-wrap { flex:1; display:flex; min-height:0; overflow:hidden; }', - '.de-textarea { flex:1; width:100%; height:100%; resize:none; border:none; outline:none; padding:0.75rem; font-family:"SF Mono","Fira Code","Cascadia Code",monospace; font-size:0.85rem; line-height:1.6; background:#0d0d1a; color:#e0e0e0; tab-size:2; }', - '.de-textarea:focus { outline:none; }', - '.de-preview { flex:1; height:100%; padding:0.75rem 1rem; overflow-y:auto; background:#0d0d1a; line-height:1.7; font-size:0.9rem; }', - '.de-preview h1,.de-preview h2,.de-preview h3,.de-preview h4,.de-preview h5,.de-preview h6 { color:#e0e0f0; margin:1rem 0 0.5rem; }', - '.de-preview h1 { font-size:1.5rem; border-bottom:1px solid #16213e; padding-bottom:0.3rem; }', - '.de-preview h2 { font-size:1.25rem; border-bottom:1px solid #16213e; padding-bottom:0.25rem; }', - '.de-preview h3 { font-size:1.1rem; }', - '.de-preview p { margin:0.5rem 0; }', - '.de-preview code { background:#1a1a2e; padding:0.15rem 0.35rem; border-radius:3px; font-size:0.85em; color:#4ecca3; }', - '.de-preview pre { background:#1a1a2e; padding:0.75rem; border-radius:4px; overflow-x:auto; margin:0.75rem 0; }', - '.de-preview pre code { background:none; padding:0; }', - '.de-preview ul,.de-preview ol { padding-left:1.5rem; margin:0.5rem 0; }', - '.de-preview li { margin:0.25rem 0; }', - '.de-preview blockquote { border-left:3px solid #4ecca3; margin:0.5rem 0; padding:0.25rem 0.75rem; color:#aaa; }', - '.de-preview a { color:#4ecca3; text-decoration:none; }', - '.de-preview a:hover { text-decoration:underline; }', - '.de-preview hr { border:none; border-top:1px solid #16213e; margin:1rem 0; }', - '.de-preview table { border-collapse:collapse; margin:0.75rem 0; }', - '.de-preview th,.de-preview td { border:1px solid #333; padding:0.35rem 0.6rem; text-align:left; }', - '.de-preview th { background:#1a1a2e; }', - '.de-notes-badge { font-size:0.65rem; padding:0.1rem 0.4rem; border-radius:3px; background:#2a1a3a; color:#b388ff; margin-left:0.5rem; }', - '.de-notes-info { padding:0.5rem 0.75rem; background:#1a1a2a; border-top:1px solid #16213e; font-size:0.75rem; color:#8b8ba8; flex-shrink:0; }', - '.de-loading { flex:1; display:flex; align-items:center; justify-content:center; color:#666; }', - '.de-error { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; color:#e74c3c; gap:0.5rem; }', - '.de-error-msg { font-size:0.85rem; color:#aaa; max-width:400px; text-align:center; }', + '.de-root{display:flex;flex-direction:column;height:100%;min-height:0;overflow:hidden;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;color:#e0e0e0;background:#0d0d1a}', + '.de-toolbar,.de-md-toolbar{display:flex;align-items:center;gap:.45rem;padding:.45rem .75rem;border-bottom:1px solid #16213e;flex-shrink:0;background:#12122a;flex-wrap:wrap}', + '.de-md-toolbar{background:#101028;padding:.38rem .75rem}', + '.de-toolbar-mode{font-size:.75rem;color:#4ecca3;padding:.15rem .5rem;border-radius:3px;background:#1a2a3a}', + '.de-toolbar-context{font-size:.75rem;color:#a0a0bb;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}', + '.de-toolbar-spacer{flex:1}', + '.de-toolbar-btn,.de-md-btn{font-size:.75rem;padding:.28rem .58rem;border:1px solid #333;border-radius:4px;background:#1a1a2e;color:#ccc;cursor:pointer}', + '.de-md-btn{min-width:2rem;font-family:inherit}', + '.de-toolbar-btn:hover,.de-md-btn:hover{background:#2a2a4e;border-color:#4ecca3}', + '.de-toolbar-btn.active{background:#1a3a2a;border-color:#4ecca3;color:#4ecca3}', + '.de-toolbar-btn:disabled,.de-md-btn:disabled{opacity:.45;cursor:default}', + '.de-status{font-size:.72rem;color:#8b8ba8;padding:.15rem .5rem;white-space:nowrap}', + '.de-status.saved{color:#4ecca3}.de-status.error{color:#e74c3c}.de-status.dirty{color:#f39c12}.de-status.saving{color:#79c0ff}', + '.de-editor-wrap{flex:1;display:flex;min-height:0;overflow:hidden;background:#0d0d1a}', + '.de-pane{flex:1;min-width:0;min-height:0;display:flex;overflow:hidden}', + '.de-pane+.de-pane{border-left:1px solid #16213e}', + '.de-editor-shell{flex:1;display:flex;min-width:0;min-height:0;overflow:hidden;background:#0d0d1a}', + '.de-lines{flex:0 0 auto;min-width:3rem;padding:.75rem .45rem;text-align:right;background:#0a0a15;color:#555;font-family:"SF Mono","Fira Code","Cascadia Code",Consolas,monospace;font-size:.82rem;line-height:1.6;user-select:none;overflow:hidden;white-space:pre}', + '.de-textarea{flex:1;width:100%;height:100%;resize:none;border:0;outline:0;padding:.75rem;font-family:"SF Mono","Fira Code","Cascadia Code",Consolas,monospace;font-size:.86rem;line-height:1.6;background:#0d0d1a;color:#e0e0e0;tab-size:2;white-space:pre;overflow:auto}', + '.de-preview{flex:1;height:100%;padding:1rem 1.15rem;overflow:auto;background:#0d0d1a;line-height:1.7;font-size:.92rem;color:#d8d8e8}', + '.de-preview h1,.de-preview h2,.de-preview h3,.de-preview h4,.de-preview h5,.de-preview h6{color:#f0f0ff;margin:1rem 0 .5rem}', + '.de-preview h1{font-size:1.55rem;border-bottom:1px solid #16213e;padding-bottom:.35rem}.de-preview h2{font-size:1.3rem;border-bottom:1px solid #16213e;padding-bottom:.25rem}.de-preview h3{font-size:1.12rem}', + '.de-preview p{margin:.55rem 0}.de-preview code{background:#1a1a2e;padding:.15rem .35rem;border-radius:3px;font-size:.87em;color:#4ecca3}', + '.de-preview pre{background:#1a1a2e;padding:.85rem;border-radius:4px;overflow:auto;margin:.8rem 0}.de-preview pre code{background:none;padding:0;color:#d8d8e8}', + '.de-preview ul,.de-preview ol{padding-left:1.5rem;margin:.55rem 0}.de-preview li{margin:.25rem 0}', + '.de-preview blockquote{border-left:3px solid #4ecca3;margin:.6rem 0;padding:.25rem .85rem;color:#aaa;background:#101028}', + '.de-preview a{color:#4ecca3;text-decoration:none}.de-preview a:hover{text-decoration:underline}', + '.de-preview table{border-collapse:collapse;margin:.8rem 0;max-width:100%;display:block;overflow:auto}.de-preview th,.de-preview td{border:1px solid #333;padding:.35rem .6rem;text-align:left}.de-preview th{background:#1a1a2e}', + '.de-preview img{max-width:100%;height:auto;border-radius:4px}.de-preview .task{margin-right:.4rem}', + '.de-notes-badge{font-size:.65rem;padding:.1rem .4rem;border-radius:3px;background:#2a1a3a;color:#b388ff}', + '.de-notes-info{padding:.45rem .75rem;background:#111126;border-top:1px solid #16213e;font-size:.75rem;color:#8b8ba8;flex-shrink:0}', + '.de-loading,.de-error{flex:1;display:flex;align-items:center;justify-content:center;color:#777;padding:2rem}.de-error{color:#e74c3c;flex-direction:column;gap:.5rem}.de-error-msg{font-size:.85rem;color:#aaa;max-width:420px;text-align:center}', + '@media(max-width:780px){.de-editor-wrap{flex-direction:column}.de-pane+.de-pane{border-left:0;border-top:1px solid #16213e}.de-toolbar-context{max-width:100%}}' ].join('\n'); - /* ── Simple markdown renderer (no raw HTML) ──────────────── */ - function renderMarkdown(text) { - if (!text) return ''; - var html = text - .replace(/&/g, '&') - .replace(//g, '>'); - - // Code blocks (``` ... ```) - html = html.replace(/```(\w*)\n([\s\S]*?)```/g, function (_, lang, code) { - return '
' + code.trimEnd() + '
'; - }); - - // Inline code - html = html.replace(/`([^`\n]+)`/g, '$1'); - - // Headings - html = html.replace(/^######\s+(.+)$/gm, '
$1
'); - html = html.replace(/^#####\s+(.+)$/gm, '
$1
'); - html = html.replace(/^####\s+(.+)$/gm, '

$1

'); - html = html.replace(/^###\s+(.+)$/gm, '

$1

'); - html = html.replace(/^##\s+(.+)$/gm, '

$1

'); - html = html.replace(/^#\s+(.+)$/gm, '

$1

'); - - // Horizontal rule - html = html.replace(/^---+$/gm, '
'); - html = html.replace(/^\*\*\*+$/gm, '
'); - - // Bold and italic - html = html.replace(/\*\*\*(.+?)\*\*\*/g, '$1'); - html = html.replace(/\*\*(.+?)\*\*/g, '$1'); - html = html.replace(/\*(.+?)\*/g, '$1'); - - // Strikethrough - html = html.replace(/~~(.+?)~~/g, '$1'); - - // Blockquote - html = html.replace(/^>\s+(.+)$/gm, '
$1
'); - - // Unordered list items - html = html.replace(/^[\-\*]\s+(.+)$/gm, '
  • $1
  • '); - - // Ordered list items - html = html.replace(/^\d+\.\s+(.+)$/gm, '
  • $1
  • '); - - // Wrap consecutive
  • in