overtype 1.2.7 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +222 -34
- package/dist/overtype-webcomponent.esm.js +4763 -0
- package/dist/overtype-webcomponent.esm.js.map +7 -0
- package/dist/overtype-webcomponent.js +4785 -0
- package/dist/overtype-webcomponent.js.map +7 -0
- package/dist/overtype-webcomponent.min.js +991 -0
- package/dist/overtype.cjs +682 -389
- package/dist/overtype.cjs.map +4 -4
- package/dist/overtype.d.ts +57 -14
- package/dist/overtype.esm.js +679 -388
- package/dist/overtype.esm.js.map +4 -4
- package/dist/overtype.js +679 -388
- package/dist/overtype.js.map +4 -4
- package/dist/overtype.min.js +157 -125
- package/package.json +18 -4
- package/src/link-tooltip.js +48 -73
- package/src/overtype-webcomponent.js +676 -0
- package/src/overtype.d.ts +57 -14
- package/src/overtype.js +186 -59
- package/src/parser.js +120 -17
- package/src/styles.js +92 -30
- package/src/toolbar-buttons.js +163 -0
- package/src/toolbar.js +194 -249
- package/diagram.png +0 -0
|
@@ -0,0 +1,991 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OverType v2.0.0
|
|
3
|
+
* A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @author Demo User
|
|
6
|
+
* https://github.com/demo/overtype
|
|
7
|
+
*/
|
|
8
|
+
var OverTypeEditor=(()=>{var N=Object.defineProperty;var Ne=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var Re=Object.prototype.hasOwnProperty;var Ve=(n,e,t)=>e in n?N(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Fe=(n,e)=>{for(var t in e)N(n,t,{get:e[t],enumerable:!0})},De=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of je(e))!Re.call(n,o)&&o!==t&&N(n,o,{get:()=>e[o],enumerable:!(i=Ne(e,o))||i.enumerable});return n};var qe=n=>De(N({},"__esModule",{value:!0}),n);var C=(n,e,t)=>(Ve(n,typeof e!="symbol"?e+"":e,t),t);var st={};Fe(st,{default:()=>rt});var S=class{static resetLinkIndex(){this.linkIndex=0}static setCodeHighlighter(e){this.codeHighlighter=e}static escapeHtml(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,i=>t[i])}static preserveIndentation(e,t){let o=t.match(/^(\s*)/)[1].replace(/ /g," ");return e.replace(/^\s*/,o)}static parseHeader(e){return e.replace(/^(#{1,3})\s(.+)$/,(t,i,o)=>{let r=i.length;return`<h${r}><span class="syntax-marker">${i} </span>${o}</h${r}>`})}static parseHorizontalRule(e){return e.match(/^(-{3,}|\*{3,}|_{3,})$/)?`<div><span class="hr-marker">${e}</span></div>`:null}static parseBlockquote(e){return e.replace(/^> (.+)$/,(t,i)=>`<span class="blockquote"><span class="syntax-marker">></span> ${i}</span>`)}static parseBulletList(e){return e.replace(/^((?: )*)([-*])\s(.+)$/,(t,i,o,r)=>`${i}<li class="bullet-list"><span class="syntax-marker">${o} </span>${r}</li>`)}static parseTaskList(e,t=!1){return e.replace(/^((?: )*)-\s+\[([ xX])\]\s+(.+)$/,(i,o,r,s)=>{if(t){let a=r.toLowerCase()==="x";return`${o}<li class="task-list"><input type="checkbox" disabled ${a?"checked":""}> ${s}</li>`}else return`${o}<li class="task-list"><span class="syntax-marker">- [${r}] </span>${s}</li>`})}static parseNumberedList(e){return e.replace(/^((?: )*)(\d+\.)\s(.+)$/,(t,i,o,r)=>`${i}<li class="ordered-list"><span class="syntax-marker">${o} </span>${r}</li>`)}static parseCodeBlock(e){return/^`{3}[^`]*$/.test(e)?`<div><span class="code-fence">${e}</span></div>`:null}static parseBold(e){return e=e.replace(/\*\*(.+?)\*\*/g,'<strong><span class="syntax-marker">**</span>$1<span class="syntax-marker">**</span></strong>'),e=e.replace(/__(.+?)__/g,'<strong><span class="syntax-marker">__</span>$1<span class="syntax-marker">__</span></strong>'),e}static parseItalic(e){return e=e.replace(new RegExp("(?<!\\*)\\*(?!\\*)(.+?)(?<!\\*)\\*(?!\\*)","g"),'<em><span class="syntax-marker">*</span>$1<span class="syntax-marker">*</span></em>'),e=e.replace(new RegExp("(?<=^|\\s)_(?!_)(.+?)(?<!_)_(?!_)(?=\\s|$)","g"),'<em><span class="syntax-marker">_</span>$1<span class="syntax-marker">_</span></em>'),e}static parseStrikethrough(e){return e=e.replace(new RegExp("(?<!~)~~(?!~)(.+?)(?<!~)~~(?!~)","g"),'<del><span class="syntax-marker">~~</span>$1<span class="syntax-marker">~~</span></del>'),e=e.replace(new RegExp("(?<!~)~(?!~)(.+?)(?<!~)~(?!~)","g"),'<del><span class="syntax-marker">~</span>$1<span class="syntax-marker">~</span></del>'),e}static parseInlineCode(e){return e.replace(new RegExp("(?<!`)(`+)(?!`)((?:(?!\\1).)+?)(\\1)(?!`)","g"),'<code><span class="syntax-marker">$1</span>$2<span class="syntax-marker">$3</span></code>')}static sanitizeUrl(e){let t=e.trim(),i=t.toLowerCase(),r=["http://","https://","mailto:","ftp://","ftps://"].some(a=>i.startsWith(a)),s=t.startsWith("/")||t.startsWith("#")||t.startsWith("?")||t.startsWith(".")||!t.includes(":")&&!t.includes("//");return r||s?e:"#"}static parseLinks(e){return e.replace(/\[(.+?)\]\((.+?)\)/g,(t,i,o)=>{let r=`--link-${this.linkIndex++}`;return`<a href="${this.sanitizeUrl(o)}" style="anchor-name: ${r}"><span class="syntax-marker">[</span>${i}<span class="syntax-marker url-part">](${o})</span></a>`})}static identifyAndProtectSanctuaries(e){let t=new Map,i=0,o=e,r=[],s=/\[([^\]]+)\]\(([^)]+)\)/g,a;for(;(a=s.exec(e))!==null;){let h=a.index+a[0].indexOf("](")+2,u=h+a[2].length;r.push({start:h,end:u})}let p=new RegExp("(?<!`)(`+)(?!`)((?:(?!\\1).)+?)(\\1)(?!`)","g"),d,l=[];for(;(d=p.exec(e))!==null;){let c=d.index,h=d.index+d[0].length;r.some(f=>c>=f.start&&h<=f.end)||l.push({match:d[0],index:d.index,openTicks:d[1],content:d[2],closeTicks:d[3]})}return l.sort((c,h)=>h.index-c.index),l.forEach(c=>{let h=`\uE000${i++}\uE001`;t.set(h,{type:"code",original:c.match,openTicks:c.openTicks,content:c.content,closeTicks:c.closeTicks}),o=o.substring(0,c.index)+h+o.substring(c.index+c.match.length)}),o=o.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(c,h,u)=>{let f=`\uE000${i++}\uE001`;return t.set(f,{type:"link",original:c,linkText:h,url:u}),f}),{protectedText:o,sanctuaries:t}}static restoreAndTransformSanctuaries(e,t){return Array.from(t.keys()).sort((o,r)=>{let s=e.indexOf(o),a=e.indexOf(r);return s-a}).forEach(o=>{let r=t.get(o),s;if(r.type==="code")s=`<code><span class="syntax-marker">${r.openTicks}</span>${r.content}<span class="syntax-marker">${r.closeTicks}</span></code>`;else if(r.type==="link"){let a=r.linkText;t.forEach((l,c)=>{if(a.includes(c)&&l.type==="code"){let h=`<code><span class="syntax-marker">${l.openTicks}</span>${l.content}<span class="syntax-marker">${l.closeTicks}</span></code>`;a=a.replace(c,h)}}),a=this.parseStrikethrough(a),a=this.parseBold(a),a=this.parseItalic(a);let p=`--link-${this.linkIndex++}`;s=`<a href="${this.sanitizeUrl(r.url)}" style="anchor-name: ${p}"><span class="syntax-marker">[</span>${a}<span class="syntax-marker url-part">](${r.url})</span></a>`}e=e.replace(o,s)}),e}static parseInlineElements(e){let{protectedText:t,sanctuaries:i}=this.identifyAndProtectSanctuaries(e),o=t;return o=this.parseStrikethrough(o),o=this.parseBold(o),o=this.parseItalic(o),o=this.restoreAndTransformSanctuaries(o,i),o}static parseLine(e,t=!1){let i=this.escapeHtml(e);i=this.preserveIndentation(i,e);let o=this.parseHorizontalRule(i);if(o)return o;let r=this.parseCodeBlock(i);return r||(i=this.parseHeader(i),i=this.parseBlockquote(i),i=this.parseTaskList(i,t),i=this.parseBulletList(i),i=this.parseNumberedList(i),i=this.parseInlineElements(i),i.trim()===""?"<div> </div>":`<div>${i}</div>`)}static parse(e,t=-1,i=!1,o,r=!1){this.resetLinkIndex();let s=e.split(`
|
|
9
|
+
`),a=!1,d=s.map((l,c)=>{if(i&&c===t)return`<div class="raw-line">${this.escapeHtml(l)||" "}</div>`;if(/^```[^`]*$/.test(l))return a=!a,this.parseLine(l,r);if(a){let u=this.escapeHtml(l);return`<div>${this.preserveIndentation(u,l)||" "}</div>`}return this.parseLine(l,r)}).join("");return this.postProcessHTML(d,o)}static postProcessHTML(e,t){if(typeof document>"u"||!document)return this.postProcessHTMLManual(e,t);let i=document.createElement("div");i.innerHTML=e;let o=null,r=null,s=null,a=!1,p=Array.from(i.children);for(let d=0;d<p.length;d++){let l=p[d];if(!l.parentNode)continue;let c=l.querySelector(".code-fence");if(c){let u=c.textContent;if(u.startsWith("```"))if(a){let f=t||this.codeHighlighter;if(s&&f&&s._codeContent)try{let m=f(s._codeContent,s._language||"");m&&typeof m.then=="function"?console.warn("Async highlighters are not supported in parse() because it returns an HTML string. The caller creates new DOM elements from that string, breaking references to the elements we would update. Use synchronous highlighters only."):m&&typeof m=="string"&&m.trim()&&(s._codeElement.innerHTML=m)}catch(m){console.warn("Code highlighting failed:",m)}a=!1,s=null;continue}else{a=!0,s=document.createElement("pre");let f=document.createElement("code");s.appendChild(f),s.className="code-block";let m=u.slice(3).trim();m&&(f.className=`language-${m}`),i.insertBefore(s,l.nextSibling),s._codeElement=f,s._language=m,s._codeContent="";continue}}if(a&&s&&l.tagName==="DIV"&&!l.querySelector(".code-fence")){let u=s._codeElement||s.querySelector("code");s._codeContent.length>0&&(s._codeContent+=`
|
|
10
|
+
`);let f=l.textContent.replace(/\u00A0/g," ");s._codeContent+=f,u.textContent.length>0&&(u.textContent+=`
|
|
11
|
+
`),u.textContent+=f,l.remove();continue}let h=null;if(l.tagName==="DIV"&&(h=l.querySelector("li")),h){let u=h.classList.contains("bullet-list"),f=h.classList.contains("ordered-list");if(!u&&!f){o=null,r=null;continue}let m=u?"ul":"ol";(!o||r!==m)&&(o=document.createElement(m),i.insertBefore(o,l),r=m);let g=[];for(let v of l.childNodes)if(v.nodeType===3&&v.textContent.match(/^\u00A0+$/))g.push(v.cloneNode(!0));else if(v===h)break;g.forEach(v=>{h.insertBefore(v,h.firstChild)}),o.appendChild(h),l.remove()}else o=null,r=null}return i.innerHTML}static postProcessHTMLManual(e,t){let i=e;i=i.replace(/((?:<div>(?: )*<li class="bullet-list">.*?<\/li><\/div>\s*)+)/gs,r=>{let s=r.match(/<div>(?: )*<li class="bullet-list">.*?<\/li><\/div>/gs)||[];return s.length>0?"<ul>"+s.map(p=>{let d=p.match(/<div>((?: )*)<li/),l=p.match(/<li class="bullet-list">.*?<\/li>/);if(d&&l){let c=d[1];return l[0].replace(/<li class="bullet-list">/,`<li class="bullet-list">${c}`)}return l?l[0]:""}).filter(Boolean).join("")+"</ul>":r}),i=i.replace(/((?:<div>(?: )*<li class="ordered-list">.*?<\/li><\/div>\s*)+)/gs,r=>{let s=r.match(/<div>(?: )*<li class="ordered-list">.*?<\/li><\/div>/gs)||[];return s.length>0?"<ol>"+s.map(p=>{let d=p.match(/<div>((?: )*)<li/),l=p.match(/<li class="ordered-list">.*?<\/li>/);if(d&&l){let c=d[1];return l[0].replace(/<li class="ordered-list">/,`<li class="ordered-list">${c}`)}return l?l[0]:""}).filter(Boolean).join("")+"</ol>":r});let o=/<div><span class="code-fence">(```[^<]*)<\/span><\/div>(.*?)<div><span class="code-fence">(```)<\/span><\/div>/gs;return i=i.replace(o,(r,s,a,p)=>{let l=(a.match(/<div>(.*?)<\/div>/gs)||[]).map(g=>g.replace(/<div>(.*?)<\/div>/s,"$1").replace(/ /g," ")).join(`
|
|
12
|
+
`),c=s.slice(3).trim(),h=c?` class="language-${c}"`:"",u=l,f=t||this.codeHighlighter;if(f)try{let g=l.replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"),v=f(g,c);v&&typeof v.then=="function"?console.warn("Async highlighters are not supported in Node.js (non-DOM) context. Use synchronous highlighters for server-side rendering."):v&&typeof v=="string"&&v.trim()&&(u=v)}catch(g){console.warn("Code highlighting failed:",g)}let m=`<div><span class="code-fence">${s}</span></div>`;return m+=`<pre class="code-block"><code${h}>${u}</code></pre>`,m+=`<div><span class="code-fence">${p}</span></div>`,m}),i}static getListContext(e,t){let i=e.split(`
|
|
13
|
+
`),o=0,r=0,s=0;for(let h=0;h<i.length;h++){let u=i[h].length;if(o+u>=t){r=h,s=o;break}o+=u+1}let a=i[r],p=s+a.length,d=a.match(this.LIST_PATTERNS.checkbox);if(d)return{inList:!0,listType:"checkbox",indent:d[1],marker:"-",checked:d[2]==="x",content:d[3],lineStart:s,lineEnd:p,markerEndPos:s+d[1].length+d[2].length+5};let l=a.match(this.LIST_PATTERNS.bullet);if(l)return{inList:!0,listType:"bullet",indent:l[1],marker:l[2],content:l[3],lineStart:s,lineEnd:p,markerEndPos:s+l[1].length+l[2].length+1};let c=a.match(this.LIST_PATTERNS.numbered);return c?{inList:!0,listType:"numbered",indent:c[1],marker:parseInt(c[2]),content:c[3],lineStart:s,lineEnd:p,markerEndPos:s+c[1].length+c[2].length+2}:{inList:!1,listType:null,indent:"",marker:null,content:a,lineStart:s,lineEnd:p,markerEndPos:s}}static createNewListItem(e){switch(e.listType){case"bullet":return`${e.indent}${e.marker} `;case"numbered":return`${e.indent}${e.marker+1}. `;case"checkbox":return`${e.indent}- [ ] `;default:return""}}static renumberLists(e){let t=e.split(`
|
|
14
|
+
`),i=new Map,o=!1;return t.map(s=>{let a=s.match(this.LIST_PATTERNS.numbered);if(a){let p=a[1],d=p.length,l=a[3];o||i.clear();let c=(i.get(d)||0)+1;i.set(d,c);for(let[h]of i)h>d&&i.delete(h);return o=!0,`${p}${c}. ${l}`}else return(s.trim()===""||!s.match(/^\s/))&&(o=!1,i.clear()),s}).join(`
|
|
15
|
+
`)}};C(S,"linkIndex",0),C(S,"codeHighlighter",null),C(S,"LIST_PATTERNS",{bullet:/^(\s*)([-*+])\s+(.*)$/,numbered:/^(\s*)(\d+)\.\s+(.*)$/,checkbox:/^(\s*)-\s+\[([ x])\]\s+(.*)$/});var Ue=Object.defineProperty,re=Object.getOwnPropertySymbols,We=Object.prototype.hasOwnProperty,Ke=Object.prototype.propertyIsEnumerable,se=(n,e,t)=>e in n?Ue(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ae=(n,e)=>{for(var t in e||(e={}))We.call(e,t)&&se(n,t,e[t]);if(re)for(var t of re(e))Ke.call(e,t)&&se(n,t,e[t]);return n},E={bold:{prefix:"**",suffix:"**",trimFirst:!0},italic:{prefix:"_",suffix:"_",trimFirst:!0},code:{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"},link:{prefix:"[",suffix:"](url)",replaceNext:"url",scanFor:"https?://"},bulletList:{prefix:"- ",multiline:!0,unorderedList:!0},numberedList:{prefix:"1. ",multiline:!0,orderedList:!0},quote:{prefix:"> ",multiline:!0,surroundWithNewlines:!0},taskList:{prefix:"- [ ] ",multiline:!0,surroundWithNewlines:!0},header1:{prefix:"# "},header2:{prefix:"## "},header3:{prefix:"### "},header4:{prefix:"#### "},header5:{prefix:"##### "},header6:{prefix:"###### "}};function Ze(){return{prefix:"",suffix:"",blockPrefix:"",blockSuffix:"",multiline:!1,replaceNext:"",prefixSpace:!1,scanFor:"",surroundWithNewlines:!1,orderedList:!1,unorderedList:!1,trimFirst:!1}}function A(n){return ae(ae({},Ze()),n)}var R=!1;function Je(){return R}function y(n,e,t){R&&(console.group(`\u{1F50D} ${n}`),console.log(e),t&&console.log("Data:",t),console.groupEnd())}function j(n,e){if(!R)return;let t=n.value.slice(n.selectionStart,n.selectionEnd);console.group(`\u{1F4CD} Selection: ${e}`),console.log("Position:",`${n.selectionStart}-${n.selectionEnd}`),console.log("Selected text:",JSON.stringify(t)),console.log("Length:",t.length);let i=n.value.slice(Math.max(0,n.selectionStart-10),n.selectionStart),o=n.value.slice(n.selectionEnd,Math.min(n.value.length,n.selectionEnd+10));console.log("Context:",JSON.stringify(i)+"[SELECTION]"+JSON.stringify(o)),console.groupEnd()}function de(n){R&&(console.group("\u{1F4DD} Result"),console.log("Text to insert:",JSON.stringify(n.text)),console.log("New selection:",`${n.selectionStart}-${n.selectionEnd}`),console.groupEnd())}var T=null;function $(n,{text:e,selectionStart:t,selectionEnd:i}){let o=Je();o&&(console.group("\u{1F527} insertText"),console.log("Current selection:",`${n.selectionStart}-${n.selectionEnd}`),console.log("Text to insert:",JSON.stringify(e)),console.log("New selection to set:",t,"-",i)),n.focus();let r=n.selectionStart,s=n.selectionEnd,a=n.value.slice(0,r),p=n.value.slice(s);o&&(console.log("Before text (last 20):",JSON.stringify(a.slice(-20))),console.log("After text (first 20):",JSON.stringify(p.slice(0,20))),console.log("Selected text being replaced:",JSON.stringify(n.value.slice(r,s))));let d=n.value,l=r!==s;if(T===null||T===!0){n.contentEditable="true";try{T=document.execCommand("insertText",!1,e),o&&console.log("execCommand returned:",T,"for text with",e.split(`
|
|
16
|
+
`).length,"lines")}catch(c){T=!1,o&&console.log("execCommand threw error:",c)}n.contentEditable="false"}if(o&&(console.log("canInsertText before:",T),console.log("execCommand result:",T)),T){let c=a+e+p,h=n.value;o&&(console.log("Expected length:",c.length),console.log("Actual length:",h.length)),h!==c&&o&&(console.log("execCommand changed the value but not as expected"),console.log("Expected:",JSON.stringify(c.slice(0,100))),console.log("Actual:",JSON.stringify(h.slice(0,100))))}if(!T)if(o&&console.log("Using manual insertion"),n.value===d){o&&console.log("Value unchanged, doing manual replacement");try{document.execCommand("ms-beginUndoUnit")}catch(c){}n.value=a+e+p;try{document.execCommand("ms-endUndoUnit")}catch(c){}n.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0}))}else o&&console.log("Value was changed by execCommand, skipping manual insertion");o&&console.log("Setting selection range:",t,i),t!=null&&i!=null?n.setSelectionRange(t,i):n.setSelectionRange(r,n.selectionEnd),o&&(console.log("Final value length:",n.value.length),console.groupEnd())}function le(n){return n.trim().split(`
|
|
17
|
+
`).length>1}function Ge(n,e){let t=e;for(;n[t]&&n[t-1]!=null&&!n[t-1].match(/\s/);)t--;return t}function Qe(n,e,t){let i=e,o=t?/\n/:/\s/;for(;n[i]&&!n[i].match(o);)i++;return i}function he(n){let e=n.value.split(`
|
|
18
|
+
`),t=0;for(let i=0;i<e.length;i++){let o=e[i].length+1;n.selectionStart>=t&&n.selectionStart<t+o&&(n.selectionStart=t),n.selectionEnd>=t&&n.selectionEnd<t+o&&(i===e.length-1?n.selectionEnd=Math.min(t+e[i].length,n.value.length):n.selectionEnd=t+o-1),t+=o}}function Xe(n,e,t,i=!1){if(n.selectionStart===n.selectionEnd)n.selectionStart=Ge(n.value,n.selectionStart),n.selectionEnd=Qe(n.value,n.selectionEnd,i);else{let o=n.selectionStart-e.length,r=n.selectionEnd+t.length,s=n.value.slice(o,n.selectionStart)===e,a=n.value.slice(n.selectionEnd,r)===t;s&&a&&(n.selectionStart=o,n.selectionEnd=r)}return n.value.slice(n.selectionStart,n.selectionEnd)}function X(n){let e=n.value.slice(0,n.selectionStart),t=n.value.slice(n.selectionEnd),i=e.match(/\n*$/),o=t.match(/^\n*/),r=i?i[0].length:0,s=o?o[0].length:0,a="",p="";return e.match(/\S/)&&r<2&&(a=`
|
|
19
|
+
`.repeat(2-r)),t.match(/\S/)&&s<2&&(p=`
|
|
20
|
+
`.repeat(2-s)),{newlinesToAppend:a,newlinesToPrepend:p}}function V(n,e,t={}){let i=n.selectionStart,o=n.selectionEnd,r=i===o,s=n.value,a=i;for(;a>0&&s[a-1]!==`
|
|
21
|
+
`;)a--;if(r){let d=i;for(;d<s.length&&s[d]!==`
|
|
22
|
+
`;)d++;n.selectionStart=a,n.selectionEnd=d}else he(n);let p=e(n);if(t.adjustSelection){let l=n.value.slice(n.selectionStart,n.selectionEnd).startsWith(t.prefix),c=t.adjustSelection(l,i,o,a);p.selectionStart=c.start,p.selectionEnd=c.end}else if(t.prefix){let l=n.value.slice(n.selectionStart,n.selectionEnd).startsWith(t.prefix);r?l?(p.selectionStart=Math.max(i-t.prefix.length,a),p.selectionEnd=p.selectionStart):(p.selectionStart=i+t.prefix.length,p.selectionEnd=p.selectionStart):l?(p.selectionStart=Math.max(i-t.prefix.length,a),p.selectionEnd=Math.max(o-t.prefix.length,a)):(p.selectionStart=i+t.prefix.length,p.selectionEnd=o+t.prefix.length)}return p}function F(n,e){let t,i,{prefix:o,suffix:r,blockPrefix:s,blockSuffix:a,replaceNext:p,prefixSpace:d,scanFor:l,surroundWithNewlines:c,trimFirst:h}=e,u=n.selectionStart,f=n.selectionEnd,m=n.value.slice(n.selectionStart,n.selectionEnd),g=le(m)&&s&&s.length>0?`${s}
|
|
23
|
+
`:o,v=le(m)&&a&&a.length>0?`
|
|
24
|
+
${a}`:r;if(d){let L=n.value[n.selectionStart-1];n.selectionStart!==0&&L!=null&&!L.match(/\s/)&&(g=` ${g}`)}m=Xe(n,g,v,e.multiline);let b=n.selectionStart,k=n.selectionEnd,M=p&&p.length>0&&v.indexOf(p)>-1&&m.length>0;if(c){let L=X(n);t=L.newlinesToAppend,i=L.newlinesToPrepend,g=t+o,v+=i}if(m.startsWith(g)&&m.endsWith(v)){let L=m.slice(g.length,m.length-v.length);if(u===f){let _=u-g.length;_=Math.max(_,b),_=Math.min(_,b+L.length),b=k=_}else k=b+L.length;return{text:L,selectionStart:b,selectionEnd:k}}else if(M)if(l&&l.length>0&&m.match(l)){v=v.replace(p,m);let L=g+v;return b=k=b+g.length,{text:L,selectionStart:b,selectionEnd:k}}else{let L=g+m+v;return b=b+g.length+m.length+v.indexOf(p),k=b+p.length,{text:L,selectionStart:b,selectionEnd:k}}else{let L=g+m+v;b=u+g.length,k=f+g.length;let _=m.match(/^\s*|\s*$/g);if(h&&_){let ne=_[0]||"",oe=_[1]||"";L=ne+g+m.trim()+v+oe,b+=ne.length,k-=oe.length}return{text:L,selectionStart:b,selectionEnd:k}}}function ue(n,e){let{prefix:t,suffix:i,surroundWithNewlines:o}=e,r=n.value.slice(n.selectionStart,n.selectionEnd),s=n.selectionStart,a=n.selectionEnd,p=r.split(`
|
|
25
|
+
`);if(p.every(l=>l.startsWith(t)&&(!i||l.endsWith(i))))r=p.map(l=>{let c=l.slice(t.length);return i&&(c=c.slice(0,c.length-i.length)),c}).join(`
|
|
26
|
+
`),a=s+r.length;else if(r=p.map(l=>t+l+(i||"")).join(`
|
|
27
|
+
`),o){let{newlinesToAppend:l,newlinesToPrepend:c}=X(n);s+=l.length,a=s+r.length,r=l+r+c}return{text:r,selectionStart:s,selectionEnd:a}}function ce(n){let e=n.split(`
|
|
28
|
+
`),t=/^\d+\.\s+/,i=e.every(r=>t.test(r)),o=e;return i&&(o=e.map(r=>r.replace(t,""))),{text:o.join(`
|
|
29
|
+
`),processed:i}}function pe(n){let e=n.split(`
|
|
30
|
+
`),t="- ",i=e.every(r=>r.startsWith(t)),o=e;return i&&(o=e.map(r=>r.slice(t.length))),{text:o.join(`
|
|
31
|
+
`),processed:i}}function z(n,e){return e?"- ":`${n+1}. `}function Ye(n,e){let t,i,o;return n.orderedList?(t=ce(e),i=pe(t.text),o=i.text):(t=pe(e),i=ce(t.text),o=i.text),[t,i,o]}function et(n,e){let t=n.selectionStart===n.selectionEnd,i=n.selectionStart,o=n.selectionEnd;he(n);let r=n.value.slice(n.selectionStart,n.selectionEnd),[s,a,p]=Ye(e,r),d=p.split(`
|
|
32
|
+
`).map((m,g)=>`${z(g,e.unorderedList)}${m}`),l=d.reduce((m,g,v)=>m+z(v,e.unorderedList).length,0),c=d.reduce((m,g,v)=>m+z(v,!e.unorderedList).length,0);if(s.processed)return t?(i=Math.max(i-z(0,e.unorderedList).length,0),o=i):(i=n.selectionStart,o=n.selectionEnd-l),{text:p,selectionStart:i,selectionEnd:o};let{newlinesToAppend:h,newlinesToPrepend:u}=X(n),f=h+d.join(`
|
|
33
|
+
`)+u;return t?(i=Math.max(i+z(0,e.unorderedList).length+h.length,0),o=i):a.processed?(i=Math.max(n.selectionStart+h.length,0),o=n.selectionEnd+h.length+l-c):(i=Math.max(n.selectionStart+h.length,0),o=n.selectionEnd+h.length+l),{text:f,selectionStart:i,selectionEnd:o}}function me(n,e){let t=V(n,i=>et(i,e),{adjustSelection:(i,o,r,s)=>{let a=n.value.slice(s,n.selectionEnd),p=/^\d+\.\s+/,d=/^- /,l=p.test(a),c=d.test(a),h=e.orderedList&&l||e.unorderedList&&c;if(o===r)if(h){let u=a.match(e.orderedList?p:d),f=u?u[0].length:0;return{start:Math.max(o-f,s),end:Math.max(o-f,s)}}else if(l||c){let u=a.match(l?p:d),f=u?u[0].length:0,g=(e.unorderedList?2:3)-f;return{start:o+g,end:o+g}}else{let u=e.unorderedList?2:3;return{start:o+u,end:o+u}}else if(h){let u=a.match(e.orderedList?p:d),f=u?u[0].length:0;return{start:Math.max(o-f,s),end:Math.max(r-f,s)}}else if(l||c){let u=a.match(l?p:d),f=u?u[0].length:0,g=(e.unorderedList?2:3)-f;return{start:o+g,end:r+g}}else{let u=e.unorderedList?2:3;return{start:o+u,end:r+u}}}});$(n,t)}function tt(n){if(!n)return[];let e=[],{selectionStart:t,selectionEnd:i,value:o}=n,r=o.split(`
|
|
34
|
+
`),s=0,a="";for(let c of r){if(t>=s&&t<=s+c.length){a=c;break}s+=c.length+1}a.startsWith("- ")&&(a.startsWith("- [ ] ")||a.startsWith("- [x] ")?e.push("task-list"):e.push("bullet-list")),/^\d+\.\s/.test(a)&&e.push("numbered-list"),a.startsWith("> ")&&e.push("quote"),a.startsWith("# ")&&e.push("header"),a.startsWith("## ")&&e.push("header-2"),a.startsWith("### ")&&e.push("header-3");let p=Math.max(0,t-10),d=Math.min(o.length,i+10),l=o.slice(p,d);if(l.includes("**")){let c=o.slice(Math.max(0,t-100),t),h=o.slice(i,Math.min(o.length,i+100)),u=c.lastIndexOf("**"),f=h.indexOf("**");u!==-1&&f!==-1&&e.push("bold")}if(l.includes("_")){let c=o.slice(Math.max(0,t-100),t),h=o.slice(i,Math.min(o.length,i+100)),u=c.lastIndexOf("_"),f=h.indexOf("_");u!==-1&&f!==-1&&e.push("italic")}if(l.includes("`")){let c=o.slice(Math.max(0,t-100),t),h=o.slice(i,Math.min(o.length,i+100));c.includes("`")&&h.includes("`")&&e.push("code")}if(l.includes("[")&&l.includes("]")){let c=o.slice(Math.max(0,t-100),t),h=o.slice(i,Math.min(o.length,i+100)),u=c.lastIndexOf("["),f=h.indexOf("]");u!==-1&&f!==-1&&o.slice(i+f+1,i+f+10).startsWith("(")&&e.push("link")}return e}function D(n){if(!n||n.disabled||n.readOnly)return;y("toggleBold","Starting"),j(n,"Before");let e=A(E.bold),t=F(n,e);de(t),$(n,t),j(n,"After")}function q(n){if(!n||n.disabled||n.readOnly)return;let e=A(E.italic),t=F(n,e);$(n,t)}function fe(n){if(!n||n.disabled||n.readOnly)return;let e=A(E.code),t=F(n,e);$(n,t)}function U(n,e={}){if(!n||n.disabled||n.readOnly)return;let t=n.value.slice(n.selectionStart,n.selectionEnd),i=A(E.link);if(t&&t.match(/^https?:\/\//)&&!e.url?(i.suffix=`](${t})`,i.replaceNext=""):e.url&&(i.suffix=`](${e.url})`,i.replaceNext=""),e.text&&!t){let s=n.selectionStart;n.value=n.value.slice(0,s)+e.text+n.value.slice(s),n.selectionStart=s,n.selectionEnd=s+e.text.length}let r=F(n,i);$(n,r)}function W(n){if(!n||n.disabled||n.readOnly)return;let e=A(E.bulletList);me(n,e)}function K(n){if(!n||n.disabled||n.readOnly)return;let e=A(E.numberedList);me(n,e)}function ge(n){if(!n||n.disabled||n.readOnly)return;y("toggleQuote","Starting"),j(n,"Initial");let e=A(E.quote),t=V(n,i=>ue(i,e),{prefix:e.prefix});de(t),$(n,t),j(n,"Final")}function Y(n){if(!n||n.disabled||n.readOnly)return;let e=A(E.taskList),t=V(n,i=>ue(i,e),{prefix:e.prefix});$(n,t)}function ee(n,e=1,t=!1){if(!n||n.disabled||n.readOnly)return;(e<1||e>6)&&(e=1),y("insertHeader","============ START ============"),y("insertHeader",`Level: ${e}, Toggle: ${t}`),y("insertHeader",`Initial cursor: ${n.selectionStart}-${n.selectionEnd}`);let i=`header${e===1?"1":e}`,o=A(E[i]||E.header1);y("insertHeader",`Style prefix: "${o.prefix}"`);let r=n.value,s=n.selectionStart,a=n.selectionEnd,p=s;for(;p>0&&r[p-1]!==`
|
|
35
|
+
`;)p--;let d=a;for(;d<r.length&&r[d]!==`
|
|
36
|
+
`;)d++;let l=r.slice(p,d);y("insertHeader",`Current line (before): "${l}"`);let c=l.match(/^(#{1,6})\s*/),h=c?c[1].length:0,u=c?c[0].length:0;y("insertHeader","Existing header check:"),y("insertHeader",` - Match: ${c?`"${c[0]}"`:"none"}`),y("insertHeader",` - Existing level: ${h}`),y("insertHeader",` - Existing prefix length: ${u}`),y("insertHeader",` - Target level: ${e}`);let f=t&&h===e;y("insertHeader",`Should toggle OFF: ${f} (toggle=${t}, existingLevel=${h}, level=${e})`);let m=V(n,g=>{let v=g.value.slice(g.selectionStart,g.selectionEnd);y("insertHeader",`Line in operation: "${v}"`);let b=v.replace(/^#{1,6}\s*/,"");y("insertHeader",`Cleaned line: "${b}"`);let k;return f?(y("insertHeader","ACTION: Toggling OFF - removing header"),k=b):h>0?(y("insertHeader",`ACTION: Replacing H${h} with H${e}`),k=o.prefix+b):(y("insertHeader","ACTION: Adding new header"),k=o.prefix+b),y("insertHeader",`New line: "${k}"`),{text:k,selectionStart:g.selectionStart,selectionEnd:g.selectionEnd}},{prefix:o.prefix,adjustSelection:(g,v,b,k)=>{if(y("insertHeader","Adjusting selection:"),y("insertHeader",` - isRemoving param: ${g}`),y("insertHeader",` - shouldToggleOff: ${f}`),y("insertHeader",` - selStart: ${v}, selEnd: ${b}`),y("insertHeader",` - lineStartPos: ${k}`),f){let M=Math.max(v-u,k);return y("insertHeader",` - Removing header, adjusting by -${u}`),{start:M,end:v===b?M:Math.max(b-u,k)}}else if(u>0){let M=o.prefix.length-u;return y("insertHeader",` - Replacing header, adjusting by ${M}`),{start:v+M,end:b+M}}else return y("insertHeader",` - Adding header, adjusting by +${o.prefix.length}`),{start:v+o.prefix.length,end:b+o.prefix.length}}});y("insertHeader",`Final result: text="${m.text}", cursor=${m.selectionStart}-${m.selectionEnd}`),y("insertHeader","============ END ============"),$(n,m)}function ve(n){ee(n,1,!0)}function ye(n){ee(n,2,!0)}function be(n){ee(n,3,!0)}function we(n){return tt(n)}var O=class{constructor(e){this.editor=e,this.textarea=e.textarea}handleKeydown(e){if(!(navigator.platform.toLowerCase().includes("mac")?e.metaKey:e.ctrlKey))return!1;let o=null;switch(e.key.toLowerCase()){case"b":e.shiftKey||(o="toggleBold");break;case"i":e.shiftKey||(o="toggleItalic");break;case"k":e.shiftKey||(o="insertLink");break;case"7":e.shiftKey&&(o="toggleNumberedList");break;case"8":e.shiftKey&&(o="toggleBulletList");break}return o?(e.preventDefault(),this.editor.toolbar?this.editor.toolbar.handleAction(o):this.handleAction(o),!0):!1}async handleAction(e){let t=this.textarea;if(t){t.focus();try{switch(e){case"toggleBold":D(t);break;case"toggleItalic":q(t);break;case"insertLink":U(t);break;case"toggleBulletList":W(t);break;case"toggleNumberedList":K(t);break}t.dispatchEvent(new Event("input",{bubbles:!0}))}catch(i){console.error("Error in markdown action:",i)}}}destroy(){}};var I={name:"solar",colors:{bgPrimary:"#faf0ca",bgSecondary:"#ffffff",text:"#0d3b66",h1:"#f95738",h2:"#ee964b",h3:"#3d8a51",strong:"#ee964b",em:"#f95738",link:"#0d3b66",code:"#0d3b66",codeBg:"rgba(244, 211, 94, 0.4)",blockquote:"#5a7a9b",hr:"#5a7a9b",syntaxMarker:"rgba(13, 59, 102, 0.52)",cursor:"#f95738",selection:"rgba(244, 211, 94, 0.4)",listMarker:"#ee964b",toolbarBg:"#ffffff",toolbarBorder:"rgba(13, 59, 102, 0.15)",toolbarIcon:"#0d3b66",toolbarHover:"#f5f5f5",toolbarActive:"#faf0ca"}},ke={name:"cave",colors:{bgPrimary:"#141E26",bgSecondary:"#1D2D3E",text:"#c5dde8",h1:"#d4a5ff",h2:"#f6ae2d",h3:"#9fcfec",strong:"#f6ae2d",em:"#9fcfec",link:"#9fcfec",code:"#c5dde8",codeBg:"#1a232b",blockquote:"#9fcfec",hr:"#c5dde8",syntaxMarker:"rgba(159, 207, 236, 0.73)",cursor:"#f26419",selection:"rgba(51, 101, 138, 0.4)",listMarker:"#f6ae2d",toolbarBg:"#1D2D3E",toolbarBorder:"rgba(197, 221, 232, 0.1)",toolbarIcon:"#c5dde8",toolbarHover:"#243546",toolbarActive:"#2a3f52"}},xe={solar:I,cave:ke,light:I,dark:ke};function H(n){return typeof n=="string"?{...xe[n]||xe.solar,name:n}:n}function P(n){let e=[];for(let[t,i]of Object.entries(n)){let o=t.replace(/([A-Z])/g,"-$1").toLowerCase();e.push(`--${o}: ${i};`)}return e.join(`
|
|
37
|
+
`)}function Le(n,e={}){return{...n,colors:{...n.colors,...e}}}function Z(n={}){let{fontSize:e="14px",lineHeight:t=1.6,fontFamily:i='"SF Mono", SFMono-Regular, Menlo, Monaco, "Cascadia Code", Consolas, "Roboto Mono", "Noto Sans Mono", "Droid Sans Mono", "Ubuntu Mono", "DejaVu Sans Mono", "Liberation Mono", "Courier New", Courier, monospace',padding:o="20px",theme:r=null,mobile:s={}}=n,a=Object.keys(s).length>0?`
|
|
38
|
+
@media (max-width: 640px) {
|
|
39
|
+
.overtype-wrapper .overtype-input,
|
|
40
|
+
.overtype-wrapper .overtype-preview {
|
|
41
|
+
${Object.entries(s).map(([d,l])=>`${d.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${l} !important;`).join(`
|
|
42
|
+
`)}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`:"",p=r&&r.colors?P(r.colors):"";return`
|
|
46
|
+
/* OverType Editor Styles */
|
|
47
|
+
|
|
48
|
+
/* Middle-ground CSS Reset - Prevent parent styles from leaking in */
|
|
49
|
+
.overtype-container * {
|
|
50
|
+
/* Box model - these commonly leak */
|
|
51
|
+
margin: 0 !important;
|
|
52
|
+
padding: 0 !important;
|
|
53
|
+
border: 0 !important;
|
|
54
|
+
|
|
55
|
+
/* Layout - these can break our layout */
|
|
56
|
+
/* Don't reset position - it breaks dropdowns */
|
|
57
|
+
float: none !important;
|
|
58
|
+
clear: none !important;
|
|
59
|
+
|
|
60
|
+
/* Typography - only reset decorative aspects */
|
|
61
|
+
text-decoration: none !important;
|
|
62
|
+
text-transform: none !important;
|
|
63
|
+
letter-spacing: normal !important;
|
|
64
|
+
|
|
65
|
+
/* Visual effects that can interfere */
|
|
66
|
+
box-shadow: none !important;
|
|
67
|
+
text-shadow: none !important;
|
|
68
|
+
|
|
69
|
+
/* Ensure box-sizing is consistent */
|
|
70
|
+
box-sizing: border-box !important;
|
|
71
|
+
|
|
72
|
+
/* Keep inheritance for these */
|
|
73
|
+
/* font-family, color, line-height, font-size - inherit */
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* Container base styles after reset */
|
|
77
|
+
.overtype-container {
|
|
78
|
+
display: grid !important;
|
|
79
|
+
grid-template-rows: auto 1fr auto !important;
|
|
80
|
+
width: 100% !important;
|
|
81
|
+
height: 100% !important;
|
|
82
|
+
position: relative !important; /* Override reset - needed for absolute children */
|
|
83
|
+
overflow: visible !important; /* Allow dropdown to overflow container */
|
|
84
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
|
|
85
|
+
text-align: left !important;
|
|
86
|
+
${p?`
|
|
87
|
+
/* Theme Variables */
|
|
88
|
+
${p}`:""}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* Force left alignment for all elements in the editor */
|
|
92
|
+
.overtype-container .overtype-wrapper * {
|
|
93
|
+
text-align: left !important;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* Auto-resize mode styles */
|
|
97
|
+
.overtype-container.overtype-auto-resize {
|
|
98
|
+
height: auto !important;
|
|
99
|
+
grid-template-rows: auto auto auto !important;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.overtype-container.overtype-auto-resize .overtype-wrapper {
|
|
103
|
+
height: auto !important;
|
|
104
|
+
min-height: 60px !important;
|
|
105
|
+
overflow: visible !important;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.overtype-wrapper {
|
|
109
|
+
position: relative !important; /* Override reset - needed for absolute children */
|
|
110
|
+
width: 100% !important;
|
|
111
|
+
height: 100% !important; /* Take full height of grid cell */
|
|
112
|
+
min-height: 60px !important; /* Minimum usable height */
|
|
113
|
+
overflow: hidden !important;
|
|
114
|
+
background: var(--bg-secondary, #ffffff) !important;
|
|
115
|
+
grid-row: 2 !important; /* Always second row in grid */
|
|
116
|
+
z-index: 1; /* Below toolbar and dropdown */
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* Critical alignment styles - must be identical for both layers */
|
|
120
|
+
.overtype-wrapper .overtype-input,
|
|
121
|
+
.overtype-wrapper .overtype-preview {
|
|
122
|
+
/* Positioning - must be identical */
|
|
123
|
+
position: absolute !important; /* Override reset - required for overlay */
|
|
124
|
+
top: 0 !important;
|
|
125
|
+
left: 0 !important;
|
|
126
|
+
width: 100% !important;
|
|
127
|
+
height: 100% !important;
|
|
128
|
+
|
|
129
|
+
/* Font properties - any difference breaks alignment */
|
|
130
|
+
font-family: ${i} !important;
|
|
131
|
+
font-variant-ligatures: none !important; /* keep metrics stable for code */
|
|
132
|
+
font-size: var(--instance-font-size, ${e}) !important;
|
|
133
|
+
line-height: var(--instance-line-height, ${t}) !important;
|
|
134
|
+
font-weight: normal !important;
|
|
135
|
+
font-style: normal !important;
|
|
136
|
+
font-variant: normal !important;
|
|
137
|
+
font-stretch: normal !important;
|
|
138
|
+
font-kerning: none !important;
|
|
139
|
+
font-feature-settings: normal !important;
|
|
140
|
+
|
|
141
|
+
/* Box model - must match exactly */
|
|
142
|
+
padding: var(--instance-padding, ${o}) !important;
|
|
143
|
+
margin: 0 !important;
|
|
144
|
+
border: none !important;
|
|
145
|
+
outline: none !important;
|
|
146
|
+
box-sizing: border-box !important;
|
|
147
|
+
|
|
148
|
+
/* Text layout - critical for character positioning */
|
|
149
|
+
white-space: pre-wrap !important;
|
|
150
|
+
word-wrap: break-word !important;
|
|
151
|
+
word-break: normal !important;
|
|
152
|
+
overflow-wrap: break-word !important;
|
|
153
|
+
tab-size: 2 !important;
|
|
154
|
+
-moz-tab-size: 2 !important;
|
|
155
|
+
text-align: left !important;
|
|
156
|
+
text-indent: 0 !important;
|
|
157
|
+
letter-spacing: normal !important;
|
|
158
|
+
word-spacing: normal !important;
|
|
159
|
+
|
|
160
|
+
/* Text rendering */
|
|
161
|
+
text-transform: none !important;
|
|
162
|
+
text-rendering: auto !important;
|
|
163
|
+
-webkit-font-smoothing: auto !important;
|
|
164
|
+
-webkit-text-size-adjust: 100% !important;
|
|
165
|
+
|
|
166
|
+
/* Direction and writing */
|
|
167
|
+
direction: ltr !important;
|
|
168
|
+
writing-mode: horizontal-tb !important;
|
|
169
|
+
unicode-bidi: normal !important;
|
|
170
|
+
text-orientation: mixed !important;
|
|
171
|
+
|
|
172
|
+
/* Visual effects that could shift perception */
|
|
173
|
+
text-shadow: none !important;
|
|
174
|
+
filter: none !important;
|
|
175
|
+
transform: none !important;
|
|
176
|
+
zoom: 1 !important;
|
|
177
|
+
|
|
178
|
+
/* Vertical alignment */
|
|
179
|
+
vertical-align: baseline !important;
|
|
180
|
+
|
|
181
|
+
/* Size constraints */
|
|
182
|
+
min-width: 0 !important;
|
|
183
|
+
min-height: 0 !important;
|
|
184
|
+
max-width: none !important;
|
|
185
|
+
max-height: none !important;
|
|
186
|
+
|
|
187
|
+
/* Overflow */
|
|
188
|
+
overflow-y: auto !important;
|
|
189
|
+
overflow-x: auto !important;
|
|
190
|
+
/* overscroll-behavior removed to allow scroll-through to parent */
|
|
191
|
+
scrollbar-width: auto !important;
|
|
192
|
+
scrollbar-gutter: auto !important;
|
|
193
|
+
|
|
194
|
+
/* Animation/transition - disabled to prevent movement */
|
|
195
|
+
animation: none !important;
|
|
196
|
+
transition: none !important;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/* Input layer styles */
|
|
200
|
+
.overtype-wrapper .overtype-input {
|
|
201
|
+
/* Layer positioning */
|
|
202
|
+
z-index: 1 !important;
|
|
203
|
+
|
|
204
|
+
/* Text visibility */
|
|
205
|
+
color: transparent !important;
|
|
206
|
+
caret-color: var(--cursor, #f95738) !important;
|
|
207
|
+
background-color: transparent !important;
|
|
208
|
+
|
|
209
|
+
/* Textarea-specific */
|
|
210
|
+
resize: none !important;
|
|
211
|
+
appearance: none !important;
|
|
212
|
+
-webkit-appearance: none !important;
|
|
213
|
+
-moz-appearance: none !important;
|
|
214
|
+
|
|
215
|
+
/* Prevent mobile zoom on focus */
|
|
216
|
+
touch-action: manipulation !important;
|
|
217
|
+
|
|
218
|
+
/* Disable autofill and spellcheck */
|
|
219
|
+
autocomplete: off !important;
|
|
220
|
+
autocorrect: off !important;
|
|
221
|
+
autocapitalize: off !important;
|
|
222
|
+
spellcheck: false !important;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.overtype-wrapper .overtype-input::selection {
|
|
226
|
+
background-color: var(--selection, rgba(244, 211, 94, 0.4));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/* Preview layer styles */
|
|
230
|
+
.overtype-wrapper .overtype-preview {
|
|
231
|
+
/* Layer positioning */
|
|
232
|
+
z-index: 0 !important;
|
|
233
|
+
pointer-events: none !important;
|
|
234
|
+
color: var(--text, #0d3b66) !important;
|
|
235
|
+
background-color: transparent !important;
|
|
236
|
+
|
|
237
|
+
/* Prevent text selection */
|
|
238
|
+
user-select: none !important;
|
|
239
|
+
-webkit-user-select: none !important;
|
|
240
|
+
-moz-user-select: none !important;
|
|
241
|
+
-ms-user-select: none !important;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/* Defensive styles for preview child divs */
|
|
245
|
+
.overtype-wrapper .overtype-preview div {
|
|
246
|
+
/* Reset any inherited styles */
|
|
247
|
+
margin: 0 !important;
|
|
248
|
+
padding: 0 !important;
|
|
249
|
+
border: none !important;
|
|
250
|
+
text-align: left !important;
|
|
251
|
+
text-indent: 0 !important;
|
|
252
|
+
display: block !important;
|
|
253
|
+
position: static !important;
|
|
254
|
+
transform: none !important;
|
|
255
|
+
min-height: 0 !important;
|
|
256
|
+
max-height: none !important;
|
|
257
|
+
line-height: inherit !important;
|
|
258
|
+
font-size: inherit !important;
|
|
259
|
+
font-family: inherit !important;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/* Markdown element styling - NO SIZE CHANGES */
|
|
263
|
+
.overtype-wrapper .overtype-preview .header {
|
|
264
|
+
font-weight: bold !important;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/* Header colors */
|
|
268
|
+
.overtype-wrapper .overtype-preview .h1 {
|
|
269
|
+
color: var(--h1, #f95738) !important;
|
|
270
|
+
}
|
|
271
|
+
.overtype-wrapper .overtype-preview .h2 {
|
|
272
|
+
color: var(--h2, #ee964b) !important;
|
|
273
|
+
}
|
|
274
|
+
.overtype-wrapper .overtype-preview .h3 {
|
|
275
|
+
color: var(--h3, #3d8a51) !important;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* Semantic headers - flatten in edit mode */
|
|
279
|
+
.overtype-wrapper .overtype-preview h1,
|
|
280
|
+
.overtype-wrapper .overtype-preview h2,
|
|
281
|
+
.overtype-wrapper .overtype-preview h3 {
|
|
282
|
+
font-size: inherit !important;
|
|
283
|
+
font-weight: bold !important;
|
|
284
|
+
margin: 0 !important;
|
|
285
|
+
padding: 0 !important;
|
|
286
|
+
display: inline !important;
|
|
287
|
+
line-height: inherit !important;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/* Header colors for semantic headers */
|
|
291
|
+
.overtype-wrapper .overtype-preview h1 {
|
|
292
|
+
color: var(--h1, #f95738) !important;
|
|
293
|
+
}
|
|
294
|
+
.overtype-wrapper .overtype-preview h2 {
|
|
295
|
+
color: var(--h2, #ee964b) !important;
|
|
296
|
+
}
|
|
297
|
+
.overtype-wrapper .overtype-preview h3 {
|
|
298
|
+
color: var(--h3, #3d8a51) !important;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/* Lists - remove styling in edit mode */
|
|
302
|
+
.overtype-wrapper .overtype-preview ul,
|
|
303
|
+
.overtype-wrapper .overtype-preview ol {
|
|
304
|
+
list-style: none !important;
|
|
305
|
+
margin: 0 !important;
|
|
306
|
+
padding: 0 !important;
|
|
307
|
+
display: block !important; /* Lists need to be block for line breaks */
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.overtype-wrapper .overtype-preview li {
|
|
311
|
+
display: block !important; /* Each item on its own line */
|
|
312
|
+
margin: 0 !important;
|
|
313
|
+
padding: 0 !important;
|
|
314
|
+
/* Don't set list-style here - let ul/ol control it */
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/* Bold text */
|
|
318
|
+
.overtype-wrapper .overtype-preview strong {
|
|
319
|
+
color: var(--strong, #ee964b) !important;
|
|
320
|
+
font-weight: bold !important;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/* Italic text */
|
|
324
|
+
.overtype-wrapper .overtype-preview em {
|
|
325
|
+
color: var(--em, #f95738) !important;
|
|
326
|
+
text-decoration-color: var(--em, #f95738) !important;
|
|
327
|
+
text-decoration-thickness: 1px !important;
|
|
328
|
+
font-style: italic !important;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/* Strikethrough text */
|
|
332
|
+
.overtype-wrapper .overtype-preview del {
|
|
333
|
+
color: var(--del, #ee964b) !important;
|
|
334
|
+
text-decoration: line-through !important;
|
|
335
|
+
text-decoration-color: var(--del, #ee964b) !important;
|
|
336
|
+
text-decoration-thickness: 1px !important;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/* Inline code */
|
|
340
|
+
.overtype-wrapper .overtype-preview code {
|
|
341
|
+
background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;
|
|
342
|
+
color: var(--code, #0d3b66) !important;
|
|
343
|
+
padding: 0 !important;
|
|
344
|
+
border-radius: 2px !important;
|
|
345
|
+
font-family: inherit !important;
|
|
346
|
+
font-size: inherit !important;
|
|
347
|
+
line-height: inherit !important;
|
|
348
|
+
font-weight: normal !important;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/* Code blocks - consolidated pre blocks */
|
|
352
|
+
.overtype-wrapper .overtype-preview pre {
|
|
353
|
+
padding: 0 !important;
|
|
354
|
+
margin: 0 !important;
|
|
355
|
+
border-radius: 4px !important;
|
|
356
|
+
overflow-x: auto !important;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/* Code block styling in normal mode - yellow background */
|
|
360
|
+
.overtype-wrapper .overtype-preview pre.code-block {
|
|
361
|
+
background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;
|
|
362
|
+
white-space: break-spaces !important; /* Prevent horizontal scrollbar that breaks alignment */
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/* Code inside pre blocks - remove background */
|
|
366
|
+
.overtype-wrapper .overtype-preview pre code {
|
|
367
|
+
background: transparent !important;
|
|
368
|
+
color: var(--code, #0d3b66) !important;
|
|
369
|
+
font-family: ${i} !important; /* Match textarea font exactly for alignment */
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/* Blockquotes */
|
|
373
|
+
.overtype-wrapper .overtype-preview .blockquote {
|
|
374
|
+
color: var(--blockquote, #5a7a9b) !important;
|
|
375
|
+
padding: 0 !important;
|
|
376
|
+
margin: 0 !important;
|
|
377
|
+
border: none !important;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/* Links */
|
|
381
|
+
.overtype-wrapper .overtype-preview a {
|
|
382
|
+
color: var(--link, #0d3b66) !important;
|
|
383
|
+
text-decoration: underline !important;
|
|
384
|
+
font-weight: normal !important;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.overtype-wrapper .overtype-preview a:hover {
|
|
388
|
+
text-decoration: underline !important;
|
|
389
|
+
color: var(--link, #0d3b66) !important;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/* Lists - no list styling */
|
|
393
|
+
.overtype-wrapper .overtype-preview ul,
|
|
394
|
+
.overtype-wrapper .overtype-preview ol {
|
|
395
|
+
list-style: none !important;
|
|
396
|
+
margin: 0 !important;
|
|
397
|
+
padding: 0 !important;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
/* Horizontal rules */
|
|
402
|
+
.overtype-wrapper .overtype-preview hr {
|
|
403
|
+
border: none !important;
|
|
404
|
+
color: var(--hr, #5a7a9b) !important;
|
|
405
|
+
margin: 0 !important;
|
|
406
|
+
padding: 0 !important;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
.overtype-wrapper .overtype-preview .hr-marker {
|
|
410
|
+
color: var(--hr, #5a7a9b) !important;
|
|
411
|
+
opacity: 0.6 !important;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/* Code fence markers - with background when not in code block */
|
|
415
|
+
.overtype-wrapper .overtype-preview .code-fence {
|
|
416
|
+
color: var(--code, #0d3b66) !important;
|
|
417
|
+
background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/* Code block lines - background for entire code block */
|
|
421
|
+
.overtype-wrapper .overtype-preview .code-block-line {
|
|
422
|
+
background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/* Remove background from code fence when inside code block line */
|
|
426
|
+
.overtype-wrapper .overtype-preview .code-block-line .code-fence {
|
|
427
|
+
background: transparent !important;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/* Raw markdown line */
|
|
431
|
+
.overtype-wrapper .overtype-preview .raw-line {
|
|
432
|
+
color: var(--raw-line, #5a7a9b) !important;
|
|
433
|
+
font-style: normal !important;
|
|
434
|
+
font-weight: normal !important;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/* Syntax markers */
|
|
438
|
+
.overtype-wrapper .overtype-preview .syntax-marker {
|
|
439
|
+
color: var(--syntax-marker, rgba(13, 59, 102, 0.52)) !important;
|
|
440
|
+
opacity: 0.7 !important;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/* List markers */
|
|
444
|
+
.overtype-wrapper .overtype-preview .list-marker {
|
|
445
|
+
color: var(--list-marker, #ee964b) !important;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/* Stats bar */
|
|
449
|
+
|
|
450
|
+
/* Stats bar - positioned by grid, not absolute */
|
|
451
|
+
.overtype-stats {
|
|
452
|
+
height: 40px !important;
|
|
453
|
+
padding: 0 20px !important;
|
|
454
|
+
background: #f8f9fa !important;
|
|
455
|
+
border-top: 1px solid #e0e0e0 !important;
|
|
456
|
+
display: flex !important;
|
|
457
|
+
justify-content: space-between !important;
|
|
458
|
+
align-items: center !important;
|
|
459
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
|
|
460
|
+
font-size: 0.85rem !important;
|
|
461
|
+
color: #666 !important;
|
|
462
|
+
grid-row: 3 !important; /* Always third row in grid */
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/* Dark theme stats bar */
|
|
466
|
+
.overtype-container[data-theme="cave"] .overtype-stats {
|
|
467
|
+
background: var(--bg-secondary, #1D2D3E) !important;
|
|
468
|
+
border-top: 1px solid rgba(197, 221, 232, 0.1) !important;
|
|
469
|
+
color: var(--text, #c5dde8) !important;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.overtype-stats .overtype-stat {
|
|
473
|
+
display: flex !important;
|
|
474
|
+
align-items: center !important;
|
|
475
|
+
gap: 5px !important;
|
|
476
|
+
white-space: nowrap !important;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
.overtype-stats .live-dot {
|
|
480
|
+
width: 8px !important;
|
|
481
|
+
height: 8px !important;
|
|
482
|
+
background: #4caf50 !important;
|
|
483
|
+
border-radius: 50% !important;
|
|
484
|
+
animation: overtype-pulse 2s infinite !important;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
@keyframes overtype-pulse {
|
|
488
|
+
0%, 100% { opacity: 1; transform: scale(1); }
|
|
489
|
+
50% { opacity: 0.6; transform: scale(1.2); }
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
/* Toolbar Styles */
|
|
494
|
+
.overtype-toolbar {
|
|
495
|
+
display: flex !important;
|
|
496
|
+
align-items: center !important;
|
|
497
|
+
gap: 4px !important;
|
|
498
|
+
padding: 8px !important; /* Override reset */
|
|
499
|
+
background: var(--toolbar-bg, var(--bg-primary, #f8f9fa)) !important; /* Override reset */
|
|
500
|
+
overflow-x: auto !important; /* Allow horizontal scrolling */
|
|
501
|
+
overflow-y: hidden !important; /* Hide vertical overflow */
|
|
502
|
+
-webkit-overflow-scrolling: touch !important;
|
|
503
|
+
flex-shrink: 0 !important;
|
|
504
|
+
height: auto !important;
|
|
505
|
+
grid-row: 1 !important; /* Always first row in grid */
|
|
506
|
+
position: relative !important; /* Override reset */
|
|
507
|
+
z-index: 100 !important; /* Ensure toolbar is above wrapper */
|
|
508
|
+
scrollbar-width: thin; /* Thin scrollbar on Firefox */
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/* Thin scrollbar styling */
|
|
512
|
+
.overtype-toolbar::-webkit-scrollbar {
|
|
513
|
+
height: 4px;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
.overtype-toolbar::-webkit-scrollbar-track {
|
|
517
|
+
background: transparent;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
.overtype-toolbar::-webkit-scrollbar-thumb {
|
|
521
|
+
background: rgba(0, 0, 0, 0.2);
|
|
522
|
+
border-radius: 2px;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
.overtype-toolbar-button {
|
|
526
|
+
display: flex;
|
|
527
|
+
align-items: center;
|
|
528
|
+
justify-content: center;
|
|
529
|
+
width: 32px;
|
|
530
|
+
height: 32px;
|
|
531
|
+
padding: 0;
|
|
532
|
+
border: none;
|
|
533
|
+
border-radius: 6px;
|
|
534
|
+
background: transparent;
|
|
535
|
+
color: var(--toolbar-icon, var(--text-secondary, #666));
|
|
536
|
+
cursor: pointer;
|
|
537
|
+
transition: all 0.2s ease;
|
|
538
|
+
flex-shrink: 0;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
.overtype-toolbar-button svg {
|
|
542
|
+
width: 20px;
|
|
543
|
+
height: 20px;
|
|
544
|
+
fill: currentColor;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
.overtype-toolbar-button:hover {
|
|
548
|
+
background: var(--toolbar-hover, var(--bg-secondary, #e9ecef));
|
|
549
|
+
color: var(--toolbar-icon, var(--text-primary, #333));
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
.overtype-toolbar-button:active {
|
|
553
|
+
transform: scale(0.95);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
.overtype-toolbar-button.active {
|
|
557
|
+
background: var(--toolbar-active, var(--primary, #007bff));
|
|
558
|
+
color: var(--toolbar-icon, var(--text-primary, #333));
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
.overtype-toolbar-button:disabled {
|
|
562
|
+
opacity: 0.5;
|
|
563
|
+
cursor: not-allowed;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
.overtype-toolbar-separator {
|
|
567
|
+
width: 1px;
|
|
568
|
+
height: 24px;
|
|
569
|
+
background: var(--border, #e0e0e0);
|
|
570
|
+
margin: 0 4px;
|
|
571
|
+
flex-shrink: 0;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/* Adjust wrapper when toolbar is present */
|
|
575
|
+
.overtype-container .overtype-toolbar + .overtype-wrapper {
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/* Mobile toolbar adjustments */
|
|
579
|
+
@media (max-width: 640px) {
|
|
580
|
+
.overtype-toolbar {
|
|
581
|
+
padding: 6px;
|
|
582
|
+
gap: 2px;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
.overtype-toolbar-button {
|
|
586
|
+
width: 36px;
|
|
587
|
+
height: 36px;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
.overtype-toolbar-separator {
|
|
591
|
+
margin: 0 2px;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/* Plain mode - hide preview and show textarea text */
|
|
596
|
+
.overtype-container[data-mode="plain"] .overtype-preview {
|
|
597
|
+
display: none !important;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
.overtype-container[data-mode="plain"] .overtype-input {
|
|
601
|
+
color: var(--text, #0d3b66) !important;
|
|
602
|
+
/* Use system font stack for better plain text readability */
|
|
603
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
604
|
+
"Helvetica Neue", Arial, sans-serif !important;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/* Ensure textarea remains transparent in overlay mode */
|
|
608
|
+
.overtype-container:not([data-mode="plain"]) .overtype-input {
|
|
609
|
+
color: transparent !important;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/* Dropdown menu styles */
|
|
613
|
+
.overtype-toolbar-button {
|
|
614
|
+
position: relative !important; /* Override reset - needed for dropdown */
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
.overtype-toolbar-button.dropdown-active {
|
|
618
|
+
background: var(--toolbar-active, var(--hover-bg, #f0f0f0));
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
.overtype-dropdown-menu {
|
|
622
|
+
position: fixed !important; /* Fixed positioning relative to viewport */
|
|
623
|
+
background: var(--bg-secondary, white) !important; /* Override reset */
|
|
624
|
+
border: 1px solid var(--border, #e0e0e0) !important; /* Override reset */
|
|
625
|
+
border-radius: 6px;
|
|
626
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important; /* Override reset */
|
|
627
|
+
z-index: 10000; /* Very high z-index to ensure visibility */
|
|
628
|
+
min-width: 150px;
|
|
629
|
+
padding: 4px 0 !important; /* Override reset */
|
|
630
|
+
/* Position will be set via JavaScript based on button position */
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
.overtype-dropdown-item {
|
|
634
|
+
display: flex;
|
|
635
|
+
align-items: center;
|
|
636
|
+
width: 100%;
|
|
637
|
+
padding: 8px 12px;
|
|
638
|
+
border: none;
|
|
639
|
+
background: none;
|
|
640
|
+
text-align: left;
|
|
641
|
+
cursor: pointer;
|
|
642
|
+
font-size: 14px;
|
|
643
|
+
color: var(--text, #333);
|
|
644
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
.overtype-dropdown-item:hover {
|
|
648
|
+
background: var(--hover-bg, #f0f0f0);
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
.overtype-dropdown-item.active {
|
|
652
|
+
font-weight: 600;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
.overtype-dropdown-check {
|
|
656
|
+
width: 16px;
|
|
657
|
+
margin-right: 8px;
|
|
658
|
+
color: var(--h1, #007bff);
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
.overtype-dropdown-icon {
|
|
662
|
+
width: 20px;
|
|
663
|
+
margin-right: 8px;
|
|
664
|
+
text-align: center;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/* Preview mode styles */
|
|
668
|
+
.overtype-container[data-mode="preview"] .overtype-input {
|
|
669
|
+
display: none !important;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
.overtype-container[data-mode="preview"] .overtype-preview {
|
|
673
|
+
pointer-events: auto !important;
|
|
674
|
+
user-select: text !important;
|
|
675
|
+
cursor: text !important;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/* Hide syntax markers in preview mode */
|
|
679
|
+
.overtype-container[data-mode="preview"] .syntax-marker {
|
|
680
|
+
display: none !important;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/* Hide URL part of links in preview mode - extra specificity */
|
|
684
|
+
.overtype-container[data-mode="preview"] .syntax-marker.url-part,
|
|
685
|
+
.overtype-container[data-mode="preview"] .url-part {
|
|
686
|
+
display: none !important;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/* Hide all syntax markers inside links too */
|
|
690
|
+
.overtype-container[data-mode="preview"] a .syntax-marker {
|
|
691
|
+
display: none !important;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/* Headers - restore proper sizing in preview mode */
|
|
695
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1,
|
|
696
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2,
|
|
697
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 {
|
|
698
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
|
|
699
|
+
font-weight: 600 !important;
|
|
700
|
+
margin: 0 !important;
|
|
701
|
+
display: block !important;
|
|
702
|
+
color: inherit !important; /* Use parent text color */
|
|
703
|
+
line-height: 1 !important; /* Tight line height for headings */
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1 {
|
|
707
|
+
font-size: 2em !important;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2 {
|
|
711
|
+
font-size: 1.5em !important;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 {
|
|
715
|
+
font-size: 1.17em !important;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/* Lists - restore list styling in preview mode */
|
|
719
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview ul {
|
|
720
|
+
display: block !important;
|
|
721
|
+
list-style: disc !important;
|
|
722
|
+
padding-left: 2em !important;
|
|
723
|
+
margin: 1em 0 !important;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview ol {
|
|
727
|
+
display: block !important;
|
|
728
|
+
list-style: decimal !important;
|
|
729
|
+
padding-left: 2em !important;
|
|
730
|
+
margin: 1em 0 !important;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li {
|
|
734
|
+
display: list-item !important;
|
|
735
|
+
margin: 0 !important;
|
|
736
|
+
padding: 0 !important;
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
/* Task list checkboxes - only in preview mode */
|
|
740
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li.task-list {
|
|
741
|
+
list-style: none !important;
|
|
742
|
+
position: relative !important;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li.task-list input[type="checkbox"] {
|
|
746
|
+
margin-right: 0.5em !important;
|
|
747
|
+
cursor: default !important;
|
|
748
|
+
vertical-align: middle !important;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/* Task list in normal mode - keep syntax visible */
|
|
752
|
+
.overtype-container:not([data-mode="preview"]) .overtype-wrapper .overtype-preview li.task-list {
|
|
753
|
+
list-style: none !important;
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
.overtype-container:not([data-mode="preview"]) .overtype-wrapper .overtype-preview li.task-list .syntax-marker {
|
|
757
|
+
color: var(--syntax, #999999) !important;
|
|
758
|
+
font-weight: normal !important;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
/* Links - make clickable in preview mode */
|
|
762
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview a {
|
|
763
|
+
pointer-events: auto !important;
|
|
764
|
+
cursor: pointer !important;
|
|
765
|
+
color: var(--link, #0066cc) !important;
|
|
766
|
+
text-decoration: underline !important;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/* Code blocks - proper pre/code styling in preview mode */
|
|
770
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block {
|
|
771
|
+
background: #2d2d2d !important;
|
|
772
|
+
color: #f8f8f2 !important;
|
|
773
|
+
padding: 1.2em !important;
|
|
774
|
+
border-radius: 3px !important;
|
|
775
|
+
overflow-x: auto !important;
|
|
776
|
+
margin: 0 !important;
|
|
777
|
+
display: block !important;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/* Cave theme code block background in preview mode */
|
|
781
|
+
.overtype-container[data-theme="cave"][data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block {
|
|
782
|
+
background: #11171F !important;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block code {
|
|
786
|
+
background: transparent !important;
|
|
787
|
+
color: inherit !important;
|
|
788
|
+
padding: 0 !important;
|
|
789
|
+
font-family: ${i} !important;
|
|
790
|
+
font-size: 0.9em !important;
|
|
791
|
+
line-height: 1.4 !important;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
/* Hide old code block lines and fences in preview mode */
|
|
795
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .code-block-line {
|
|
796
|
+
display: none !important;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .code-fence {
|
|
800
|
+
display: none !important;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/* Blockquotes - enhanced styling in preview mode */
|
|
804
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .blockquote {
|
|
805
|
+
display: block !important;
|
|
806
|
+
border-left: 4px solid var(--blockquote, #ddd) !important;
|
|
807
|
+
padding-left: 1em !important;
|
|
808
|
+
margin: 1em 0 !important;
|
|
809
|
+
font-style: italic !important;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
/* Typography improvements in preview mode */
|
|
813
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview {
|
|
814
|
+
font-family: Georgia, 'Times New Roman', serif !important;
|
|
815
|
+
font-size: 16px !important;
|
|
816
|
+
line-height: 1.8 !important;
|
|
817
|
+
color: var(--text, #333) !important; /* Consistent text color */
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
/* Inline code in preview mode - keep monospace */
|
|
821
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview code {
|
|
822
|
+
font-family: ${i} !important;
|
|
823
|
+
font-size: 0.9em !important;
|
|
824
|
+
background: rgba(135, 131, 120, 0.15) !important;
|
|
825
|
+
padding: 0.2em 0.4em !important;
|
|
826
|
+
border-radius: 3px !important;
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/* Strong and em elements in preview mode */
|
|
830
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview strong {
|
|
831
|
+
font-weight: 700 !important;
|
|
832
|
+
color: inherit !important; /* Use parent text color */
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview em {
|
|
836
|
+
font-style: italic !important;
|
|
837
|
+
color: inherit !important; /* Use parent text color */
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
/* HR in preview mode */
|
|
841
|
+
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .hr-marker {
|
|
842
|
+
display: block !important;
|
|
843
|
+
border-top: 2px solid var(--hr, #ddd) !important;
|
|
844
|
+
text-indent: -9999px !important;
|
|
845
|
+
height: 2px !important;
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
/* Link Tooltip - CSS Anchor Positioning */
|
|
849
|
+
@supports (position-anchor: --x) and (position-area: center) {
|
|
850
|
+
.overtype-link-tooltip {
|
|
851
|
+
position: absolute;
|
|
852
|
+
position-anchor: var(--target-anchor, --link-0);
|
|
853
|
+
position-area: block-end center;
|
|
854
|
+
margin-top: 8px !important;
|
|
855
|
+
|
|
856
|
+
background: #333 !important;
|
|
857
|
+
color: white !important;
|
|
858
|
+
padding: 6px 10px !important;
|
|
859
|
+
border-radius: 16px !important;
|
|
860
|
+
font-size: 12px !important;
|
|
861
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
|
|
862
|
+
display: none !important;
|
|
863
|
+
z-index: 10000 !important;
|
|
864
|
+
cursor: pointer !important;
|
|
865
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
|
|
866
|
+
max-width: 300px !important;
|
|
867
|
+
white-space: nowrap !important;
|
|
868
|
+
overflow: hidden !important;
|
|
869
|
+
text-overflow: ellipsis !important;
|
|
870
|
+
|
|
871
|
+
position-try: most-width block-end inline-end, flip-inline, block-start center;
|
|
872
|
+
position-visibility: anchors-visible;
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
.overtype-link-tooltip.visible {
|
|
876
|
+
display: flex !important;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
${a}
|
|
881
|
+
`}var J=class{constructor(e,t={}){this.editor=e,this.container=null,this.buttons={},this.toolbarButtons=t.toolbarButtons||[]}create(){this.container=document.createElement("div"),this.container.className="overtype-toolbar",this.container.setAttribute("role","toolbar"),this.container.setAttribute("aria-label","Formatting toolbar"),this.toolbarButtons.forEach(e=>{if(e.name==="separator"){let t=this.createSeparator();this.container.appendChild(t)}else{let t=this.createButton(e);this.buttons[e.name]=t,this.container.appendChild(t)}}),this.editor.wrapper.insertBefore(this.container,this.editor.wrapper.firstChild)}createSeparator(){let e=document.createElement("div");return e.className="overtype-toolbar-separator",e.setAttribute("role","separator"),e}createButton(e){let t=document.createElement("button");return t.className="overtype-toolbar-button",t.type="button",t.setAttribute("data-button",e.name),t.title=e.title||"",t.setAttribute("aria-label",e.title||e.name),t.innerHTML=this.sanitizeSVG(e.icon||""),e.name==="viewMode"?(t.classList.add("has-dropdown"),t.dataset.dropdown="true",t.addEventListener("click",i=>{i.preventDefault(),this.toggleViewModeDropdown(t)}),t):(t._clickHandler=async i=>{i.preventDefault(),this.editor.textarea.focus();try{e.action&&await e.action({editor:this.editor,getValue:()=>this.editor.getValue(),setValue:o=>this.editor.setValue(o),event:i})}catch(o){console.error(`Button "${e.name}" error:`,o),this.editor.wrapper.dispatchEvent(new CustomEvent("button-error",{detail:{buttonName:e.name,error:o}})),t.classList.add("button-error"),t.style.animation="buttonError 0.3s",setTimeout(()=>{t.classList.remove("button-error"),t.style.animation=""},300)}},t.addEventListener("click",t._clickHandler),t)}sanitizeSVG(e){return typeof e!="string"?"":e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/\son\w+\s*=\s*["'][^"']*["']/gi,"").replace(/\son\w+\s*=\s*[^\s>]*/gi,"")}toggleViewModeDropdown(e){let t=document.querySelector(".overtype-dropdown-menu");if(t){t.remove(),e.classList.remove("dropdown-active");return}e.classList.add("dropdown-active");let i=this.createViewModeDropdown(e),o=e.getBoundingClientRect();i.style.position="absolute",i.style.top=`${o.bottom+5}px`,i.style.left=`${o.left}px`,document.body.appendChild(i),this.handleDocumentClick=r=>{!i.contains(r.target)&&!e.contains(r.target)&&(i.remove(),e.classList.remove("dropdown-active"),document.removeEventListener("click",this.handleDocumentClick))},setTimeout(()=>{document.addEventListener("click",this.handleDocumentClick)},0)}createViewModeDropdown(e){let t=document.createElement("div");t.className="overtype-dropdown-menu";let i=[{id:"normal",label:"Normal Edit",icon:"\u2713"},{id:"plain",label:"Plain Textarea",icon:"\u2713"},{id:"preview",label:"Preview Mode",icon:"\u2713"}],o=this.editor.container.dataset.mode||"normal";return i.forEach(r=>{let s=document.createElement("button");if(s.className="overtype-dropdown-item",s.type="button",s.textContent=r.label,r.id===o){s.classList.add("active"),s.setAttribute("aria-current","true");let a=document.createElement("span");a.className="overtype-dropdown-icon",a.textContent=r.icon,s.prepend(a)}s.addEventListener("click",a=>{switch(a.preventDefault(),r.id){case"plain":this.editor.showPlainTextarea();break;case"preview":this.editor.showPreviewMode();break;case"normal":default:this.editor.showNormalEditMode();break}t.remove(),e.classList.remove("dropdown-active"),document.removeEventListener("click",this.handleDocumentClick)}),t.appendChild(s)}),t}updateButtonStates(){var e;try{let t=((e=we)==null?void 0:e(this.editor.textarea,this.editor.textarea.selectionStart))||[];Object.entries(this.buttons).forEach(([i,o])=>{if(i==="viewMode")return;let r=!1;switch(i){case"bold":r=t.includes("bold");break;case"italic":r=t.includes("italic");break;case"code":r=!1;break;case"bulletList":r=t.includes("bullet-list");break;case"orderedList":r=t.includes("numbered-list");break;case"taskList":r=t.includes("task-list");break;case"quote":r=t.includes("quote");break;case"h1":r=t.includes("header");break;case"h2":r=t.includes("header-2");break;case"h3":r=t.includes("header-3");break}o.classList.toggle("active",r),o.setAttribute("aria-pressed",r.toString())})}catch(t){}}destroy(){this.container&&(this.handleDocumentClick&&document.removeEventListener("click",this.handleDocumentClick),Object.values(this.buttons).forEach(e=>{e._clickHandler&&(e.removeEventListener("click",e._clickHandler),delete e._clickHandler)}),this.container.remove(),this.container=null,this.buttons={})}};var G=class{constructor(e){this.editor=e,this.tooltip=null,this.currentLink=null,this.hideTimeout=null,this.visibilityChangeHandler=null,this.init()}init(){this.createTooltip(),this.editor.textarea.addEventListener("selectionchange",()=>this.checkCursorPosition()),this.editor.textarea.addEventListener("keyup",e=>{(e.key.includes("Arrow")||e.key==="Home"||e.key==="End")&&this.checkCursorPosition()}),this.editor.textarea.addEventListener("input",()=>this.hide()),this.editor.textarea.addEventListener("scroll",()=>this.hide()),this.editor.textarea.addEventListener("blur",()=>this.hide()),this.visibilityChangeHandler=()=>{document.hidden&&this.hide()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),this.tooltip.addEventListener("mouseenter",()=>this.cancelHide()),this.tooltip.addEventListener("mouseleave",()=>this.scheduleHide())}createTooltip(){this.tooltip=document.createElement("div"),this.tooltip.className="overtype-link-tooltip",this.tooltip.innerHTML=`
|
|
882
|
+
<span style="display: flex; align-items: center; gap: 6px;">
|
|
883
|
+
<svg width="12" height="12" viewBox="0 0 20 20" fill="currentColor" style="flex-shrink: 0;">
|
|
884
|
+
<path d="M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z"></path>
|
|
885
|
+
<path d="M5 5a2 2 0 00-2 2v8a2 2 0 002 2h8a2 2 0 002-2v-3a1 1 0 10-2 0v3H5V7h3a1 1 0 000-2H5z"></path>
|
|
886
|
+
</svg>
|
|
887
|
+
<span class="overtype-link-tooltip-url"></span>
|
|
888
|
+
</span>
|
|
889
|
+
`,this.tooltip.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.currentLink&&(window.open(this.currentLink.url,"_blank"),this.hide())}),this.editor.container.appendChild(this.tooltip)}checkCursorPosition(){let e=this.editor.textarea.selectionStart,t=this.editor.textarea.value,i=this.findLinkAtPosition(t,e);i?(!this.currentLink||this.currentLink.url!==i.url||this.currentLink.index!==i.index)&&this.show(i):this.scheduleHide()}findLinkAtPosition(e,t){let i=/\[([^\]]+)\]\(([^)]+)\)/g,o,r=0;for(;(o=i.exec(e))!==null;){let s=o.index,a=o.index+o[0].length;if(t>=s&&t<=a)return{text:o[1],url:o[2],index:r,start:s,end:a};r++}return null}show(e){this.currentLink=e,this.cancelHide();let t=this.tooltip.querySelector(".overtype-link-tooltip-url");t.textContent=e.url,this.tooltip.style.setProperty("--target-anchor",`--link-${e.index}`),this.tooltip.classList.add("visible")}hide(){this.tooltip.classList.remove("visible"),this.currentLink=null}scheduleHide(){this.cancelHide(),this.hideTimeout=setTimeout(()=>this.hide(),300)}cancelHide(){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null)}destroy(){this.cancelHide(),this.visibilityChangeHandler&&(document.removeEventListener("visibilitychange",this.visibilityChangeHandler),this.visibilityChangeHandler=null),this.tooltip&&this.tooltip.parentNode&&this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null,this.currentLink=null}};var Se=`<svg viewBox="0 0 18 18">
|
|
890
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z"></path>
|
|
891
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z"></path>
|
|
892
|
+
</svg>`,Ee=`<svg viewBox="0 0 18 18">
|
|
893
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="13" y1="4" y2="4"></line>
|
|
894
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="5" x2="11" y1="14" y2="14"></line>
|
|
895
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="8" x2="10" y1="14" y2="4"></line>
|
|
896
|
+
</svg>`,_e=`<svg viewBox="0 0 18 18">
|
|
897
|
+
<path fill="currentColor" d="M10,4V14a1,1,0,0,1-2,0V10H3v4a1,1,0,0,1-2,0V4A1,1,0,0,1,3,4V8H8V4a1,1,0,0,1,2,0Zm6.06787,9.209H14.98975V7.59863a.54085.54085,0,0,0-.605-.60547h-.62744a1.01119,1.01119,0,0,0-.748.29688L11.645,8.56641a.5435.5435,0,0,0-.022.8584l.28613.30762a.53861.53861,0,0,0,.84717.0332l.09912-.08789a1.2137,1.2137,0,0,0,.2417-.35254h.02246s-.01123.30859-.01123.60547V13.209H12.041a.54085.54085,0,0,0-.605.60547v.43945a.54085.54085,0,0,0,.605.60547h4.02686a.54085.54085,0,0,0,.605-.60547v-.43945A.54085.54085,0,0,0,16.06787,13.209Z"></path>
|
|
898
|
+
</svg>`,Ce=`<svg viewBox="0 0 18 18">
|
|
899
|
+
<path fill="currentColor" d="M16.73975,13.81445v.43945a.54085.54085,0,0,1-.605.60547H11.855a.58392.58392,0,0,1-.64893-.60547V14.0127c0-2.90527,3.39941-3.42187,3.39941-4.55469a.77675.77675,0,0,0-.84717-.78125,1.17684,1.17684,0,0,0-.83594.38477c-.2749.26367-.561.374-.85791.13184l-.4292-.34082c-.30811-.24219-.38525-.51758-.1543-.81445a2.97155,2.97155,0,0,1,2.45361-1.17676,2.45393,2.45393,0,0,1,2.68408,2.40918c0,2.45312-3.1792,2.92676-3.27832,3.93848h2.79443A.54085.54085,0,0,1,16.73975,13.81445ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z"></path>
|
|
900
|
+
</svg>`,Te=`<svg viewBox="0 0 18 18">
|
|
901
|
+
<path fill="currentColor" d="M16.65186,12.30664a2.6742,2.6742,0,0,1-2.915,2.68457,3.96592,3.96592,0,0,1-2.25537-.6709.56007.56007,0,0,1-.13232-.83594L11.64648,13c.209-.34082.48389-.36328.82471-.1543a2.32654,2.32654,0,0,0,1.12256.33008c.71484,0,1.12207-.35156,1.12207-.78125,0-.61523-.61621-.86816-1.46338-.86816H13.2085a.65159.65159,0,0,1-.68213-.41895l-.05518-.10937a.67114.67114,0,0,1,.14307-.78125l.71533-.86914a8.55289,8.55289,0,0,1,.68213-.7373V8.58887a3.93913,3.93913,0,0,1-.748.05469H11.9873a.54085.54085,0,0,1-.605-.60547V7.59863a.54085.54085,0,0,1,.605-.60547h3.75146a.53773.53773,0,0,1,.60547.59375v.17676a1.03723,1.03723,0,0,1-.27539.748L14.74854,10.0293A2.31132,2.31132,0,0,1,16.65186,12.30664ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z"></path>
|
|
902
|
+
</svg>`,Ae=`<svg viewBox="0 0 18 18">
|
|
903
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="11" y1="7" y2="11"></line>
|
|
904
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z"></path>
|
|
905
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z"></path>
|
|
906
|
+
</svg>`,He=`<svg viewBox="0 0 18 18">
|
|
907
|
+
<polyline stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" points="5 7 3 9 5 11"></polyline>
|
|
908
|
+
<polyline stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" points="13 7 15 9 13 11"></polyline>
|
|
909
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="10" x2="8" y1="5" y2="13"></line>
|
|
910
|
+
</svg>`,Me=`<svg viewBox="0 0 18 18">
|
|
911
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="6" x2="15" y1="4" y2="4"></line>
|
|
912
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="6" x2="15" y1="9" y2="9"></line>
|
|
913
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="6" x2="15" y1="14" y2="14"></line>
|
|
914
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="3" x2="3" y1="4" y2="4"></line>
|
|
915
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="3" x2="3" y1="9" y2="9"></line>
|
|
916
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="3" x2="3" y1="14" y2="14"></line>
|
|
917
|
+
</svg>`,$e=`<svg viewBox="0 0 18 18">
|
|
918
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="15" y1="4" y2="4"></line>
|
|
919
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="15" y1="9" y2="9"></line>
|
|
920
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="15" y1="14" y2="14"></line>
|
|
921
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1" x1="2.5" x2="4.5" y1="5.5" y2="5.5"></line>
|
|
922
|
+
<path fill="currentColor" d="M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z"></path>
|
|
923
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156"></path>
|
|
924
|
+
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109"></path>
|
|
925
|
+
</svg>`,Ie=`<svg viewBox="2 2 20 20">
|
|
926
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 10.8182L9 10.8182C8.80222 10.8182 8.60888 10.7649 8.44443 10.665C8.27998 10.5651 8.15181 10.4231 8.07612 10.257C8.00043 10.0909 7.98063 9.90808 8.01922 9.73174C8.0578 9.55539 8.15304 9.39341 8.29289 9.26627C8.43275 9.13913 8.61093 9.05255 8.80491 9.01747C8.99889 8.98239 9.19996 9.00039 9.38268 9.0692C9.56541 9.13801 9.72159 9.25453 9.83147 9.40403C9.94135 9.55353 10 9.72929 10 9.90909L10 12.1818C10 12.664 9.78929 13.1265 9.41421 13.4675C9.03914 13.8084 8.53043 14 8 14"></path>
|
|
927
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 10.8182L15 10.8182C14.8022 10.8182 14.6089 10.7649 14.4444 10.665C14.28 10.5651 14.1518 10.4231 14.0761 10.257C14.0004 10.0909 13.9806 9.90808 14.0192 9.73174C14.0578 9.55539 14.153 9.39341 14.2929 9.26627C14.4327 9.13913 14.6109 9.05255 14.8049 9.01747C14.9989 8.98239 15.2 9.00039 15.3827 9.0692C15.5654 9.13801 15.7216 9.25453 15.8315 9.40403C15.9414 9.55353 16 9.72929 16 9.90909L16 12.1818C16 12.664 15.7893 13.1265 15.4142 13.4675C15.0391 13.8084 14.5304 14 14 14"></path>
|
|
928
|
+
</svg>`,Be=`<svg viewBox="0 0 18 18">
|
|
929
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="8" x2="16" y1="4" y2="4"></line>
|
|
930
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="8" x2="16" y1="9" y2="9"></line>
|
|
931
|
+
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="8" x2="16" y1="14" y2="14"></line>
|
|
932
|
+
<rect stroke="currentColor" fill="none" stroke-width="1.5" x="2" y="3" width="3" height="3" rx="0.5"></rect>
|
|
933
|
+
<rect stroke="currentColor" fill="none" stroke-width="1.5" x="2" y="13" width="3" height="3" rx="0.5"></rect>
|
|
934
|
+
<polyline stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" points="2.65 9.5 3.5 10.5 5 8.5"></polyline>
|
|
935
|
+
</svg>`,Pe=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
936
|
+
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" fill="none"></path>
|
|
937
|
+
<circle cx="12" cy="12" r="3" fill="none"></circle>
|
|
938
|
+
</svg>`;var x={bold:{name:"bold",icon:Se,title:"Bold (Ctrl+B)",action:({editor:n,event:e})=>{D(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},italic:{name:"italic",icon:Ee,title:"Italic (Ctrl+I)",action:({editor:n,event:e})=>{q(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},code:{name:"code",icon:He,title:"Inline Code",action:({editor:n,event:e})=>{fe(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},separator:{name:"separator"},link:{name:"link",icon:Ae,title:"Insert Link",action:({editor:n,event:e})=>{U(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h1:{name:"h1",icon:_e,title:"Heading 1",action:({editor:n,event:e})=>{ve(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h2:{name:"h2",icon:Ce,title:"Heading 2",action:({editor:n,event:e})=>{ye(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h3:{name:"h3",icon:Te,title:"Heading 3",action:({editor:n,event:e})=>{be(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},bulletList:{name:"bulletList",icon:Me,title:"Bullet List",action:({editor:n,event:e})=>{W(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},orderedList:{name:"orderedList",icon:$e,title:"Numbered List",action:({editor:n,event:e})=>{K(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},taskList:{name:"taskList",icon:Be,title:"Task List",action:({editor:n,event:e})=>{Y&&(Y(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0})))}},quote:{name:"quote",icon:Ie,title:"Quote",action:({editor:n,event:e})=>{ge(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},viewMode:{name:"viewMode",icon:Pe,title:"View mode"}},ie=[x.bold,x.italic,x.code,x.separator,x.link,x.separator,x.h1,x.h2,x.h3,x.separator,x.bulletList,x.orderedList,x.taskList,x.separator,x.quote,x.separator,x.viewMode];var w=class w{constructor(e,t={}){let i;if(typeof e=="string"){if(i=document.querySelectorAll(e),i.length===0)throw new Error(`No elements found for selector: ${e}`);i=Array.from(i)}else if(e instanceof Element)i=[e];else if(e instanceof NodeList)i=Array.from(e);else if(Array.isArray(e))i=e;else throw new Error("Invalid target: must be selector string, Element, NodeList, or Array");return i.map(r=>{if(r.overTypeInstance)return r.overTypeInstance.reinit(t),r.overTypeInstance;let s=Object.create(w.prototype);return s._init(r,t),r.overTypeInstance=s,w.instances.set(r,s),s})}_init(e,t={}){this.element=e,this.instanceTheme=t.theme||null,this.options=this._mergeOptions(t),this.instanceId=++w.instanceCount,this.initialized=!1,w.injectStyles(),w.initGlobalListeners();let i=e.querySelector(".overtype-container"),o=e.querySelector(".overtype-wrapper");i||o?this._recoverFromDOM(i,o):this._buildFromScratch(),this.shortcuts=new O(this),this.linkTooltip=new G(this),this.initialized=!0,this.options.onChange&&this.options.onChange(this.getValue(),this)}_mergeOptions(e){let t={fontSize:"14px",lineHeight:1.6,fontFamily:'"SF Mono", SFMono-Regular, Menlo, Monaco, "Cascadia Code", Consolas, "Roboto Mono", "Noto Sans Mono", "Droid Sans Mono", "Ubuntu Mono", "DejaVu Sans Mono", "Liberation Mono", "Courier New", Courier, monospace',padding:"16px",mobile:{fontSize:"16px",padding:"12px",lineHeight:1.5},textareaProps:{},autofocus:!1,autoResize:!1,minHeight:"100px",maxHeight:null,placeholder:"Start typing...",value:"",onChange:null,onKeydown:null,showActiveLineRaw:!1,showStats:!1,toolbar:!1,toolbarButtons:null,statsFormatter:null,smartLists:!0,codeHighlighter:null},{theme:i,colors:o,...r}=e;return{...t,...r}}_recoverFromDOM(e,t){if(e&&e.classList.contains("overtype-container"))this.container=e,this.wrapper=e.querySelector(".overtype-wrapper");else if(t){this.wrapper=t,this.container=document.createElement("div"),this.container.className="overtype-container";let i=this.instanceTheme||w.currentTheme||I,o=typeof i=="string"?i:i.name;if(o&&this.container.setAttribute("data-theme",o),this.instanceTheme){let r=typeof this.instanceTheme=="string"?H(this.instanceTheme):this.instanceTheme;if(r&&r.colors){let s=P(r.colors);this.container.style.cssText+=s}}t.parentNode.insertBefore(this.container,t),this.container.appendChild(t)}if(!this.wrapper){e&&e.remove(),t&&t.remove(),this._buildFromScratch();return}if(this.textarea=this.wrapper.querySelector(".overtype-input"),this.preview=this.wrapper.querySelector(".overtype-preview"),!this.textarea||!this.preview){this.container.remove(),this._buildFromScratch();return}this.wrapper._instance=this,this.options.fontSize&&this.wrapper.style.setProperty("--instance-font-size",this.options.fontSize),this.options.lineHeight&&this.wrapper.style.setProperty("--instance-line-height",String(this.options.lineHeight)),this.options.padding&&this.wrapper.style.setProperty("--instance-padding",this.options.padding),this._configureTextarea(),this._applyOptions()}_buildFromScratch(){let e=this._extractContent();this.element.innerHTML="",this._createDOM(),(e||this.options.value)&&this.setValue(e||this.options.value),this._applyOptions()}_extractContent(){let e=this.element.querySelector(".overtype-input");return e?e.value:this.element.textContent||""}_createDOM(){this.container=document.createElement("div"),this.container.className="overtype-container";let e=this.instanceTheme||w.currentTheme||I,t=typeof e=="string"?e:e.name;if(t&&this.container.setAttribute("data-theme",t),this.instanceTheme){let i=typeof this.instanceTheme=="string"?H(this.instanceTheme):this.instanceTheme;if(i&&i.colors){let o=P(i.colors);this.container.style.cssText+=o}}this.wrapper=document.createElement("div"),this.wrapper.className="overtype-wrapper",this.options.fontSize&&this.wrapper.style.setProperty("--instance-font-size",this.options.fontSize),this.options.lineHeight&&this.wrapper.style.setProperty("--instance-line-height",String(this.options.lineHeight)),this.options.padding&&this.wrapper.style.setProperty("--instance-padding",this.options.padding),this.wrapper._instance=this,this.textarea=document.createElement("textarea"),this.textarea.className="overtype-input",this.textarea.placeholder=this.options.placeholder,this._configureTextarea(),this.options.textareaProps&&Object.entries(this.options.textareaProps).forEach(([i,o])=>{i==="className"||i==="class"?this.textarea.className+=" "+o:i==="style"&&typeof o=="object"?Object.assign(this.textarea.style,o):this.textarea.setAttribute(i,o)}),this.preview=document.createElement("div"),this.preview.className="overtype-preview",this.preview.setAttribute("aria-hidden","true"),this.wrapper.appendChild(this.textarea),this.wrapper.appendChild(this.preview),this.container.appendChild(this.wrapper),this.options.showStats&&(this.statsBar=document.createElement("div"),this.statsBar.className="overtype-stats",this.container.appendChild(this.statsBar),this._updateStats()),this.element.appendChild(this.container),window.location.pathname.includes("demo.html")&&console.log("_createDOM completed:",{elementId:this.element.id,autoResize:this.options.autoResize,containerClasses:this.container.className,hasStats:!!this.statsBar,hasToolbar:this.options.toolbar}),this.options.autoResize?this._setupAutoResize():(this.container.classList.remove("overtype-auto-resize"),window.location.pathname.includes("demo.html")&&console.log("Removed auto-resize class from:",this.element.id))}_configureTextarea(){this.textarea.setAttribute("autocomplete","off"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.setAttribute("data-gramm","false"),this.textarea.setAttribute("data-gramm_editor","false"),this.textarea.setAttribute("data-enable-grammarly","false")}_createToolbar(){let e=this.options.toolbarButtons||ie;this.toolbar=new J(this,{toolbarButtons:e}),this.toolbar.create(),this._toolbarSelectionListener=()=>{this.toolbar&&this.toolbar.updateButtonStates()},this._toolbarInputListener=()=>{this.toolbar&&this.toolbar.updateButtonStates()},this.textarea.addEventListener("selectionchange",this._toolbarSelectionListener),this.textarea.addEventListener("input",this._toolbarInputListener)}_cleanupToolbarListeners(){this._toolbarSelectionListener&&(this.textarea.removeEventListener("selectionchange",this._toolbarSelectionListener),this._toolbarSelectionListener=null),this._toolbarInputListener&&(this.textarea.removeEventListener("input",this._toolbarInputListener),this._toolbarInputListener=null)}_applyOptions(){this.options.autofocus&&this.textarea.focus(),this.options.autoResize?this.container.classList.contains("overtype-auto-resize")||this._setupAutoResize():this.container.classList.remove("overtype-auto-resize"),this.options.toolbar&&!this.toolbar?this._createToolbar():!this.options.toolbar&&this.toolbar&&(this._cleanupToolbarListeners(),this.toolbar.destroy(),this.toolbar=null),this.updatePreview()}updatePreview(){let e=this.textarea.value,t=this.textarea.selectionStart,i=this._getCurrentLine(e,t),o=this.container.dataset.mode==="preview",r=S.parse(e,i,this.options.showActiveLineRaw,this.options.codeHighlighter,o);this.preview.innerHTML=r||'<span style="color: #808080;">Start typing...</span>',this._applyCodeBlockBackgrounds(),this.options.showStats&&this.statsBar&&this._updateStats(),this.options.onChange&&this.initialized&&this.options.onChange(e,this)}_applyCodeBlockBackgrounds(){let e=this.preview.querySelectorAll(".code-fence");for(let t=0;t<e.length-1;t+=2){let i=e[t],o=e[t+1],r=i.parentElement,s=o.parentElement;!r||!s||(i.style.display="block",o.style.display="block",r.classList.add("code-block-line"),s.classList.add("code-block-line"))}}_getCurrentLine(e,t){return e.substring(0,t).split(`
|
|
939
|
+
`).length-1}handleInput(e){this.updatePreview()}handleKeydown(e){if(e.key==="Tab"){e.preventDefault();let i=this.textarea.selectionStart,o=this.textarea.selectionEnd,r=this.textarea.value;if(i!==o&&e.shiftKey){let s=r.substring(0,i),a=r.substring(i,o),p=r.substring(o),l=a.split(`
|
|
940
|
+
`).map(c=>c.replace(/^ /,"")).join(`
|
|
941
|
+
`);document.execCommand?(this.textarea.setSelectionRange(i,o),document.execCommand("insertText",!1,l)):(this.textarea.value=s+l+p,this.textarea.selectionStart=i,this.textarea.selectionEnd=i+l.length)}else if(i!==o){let s=r.substring(0,i),a=r.substring(i,o),p=r.substring(o),l=a.split(`
|
|
942
|
+
`).map(c=>" "+c).join(`
|
|
943
|
+
`);document.execCommand?(this.textarea.setSelectionRange(i,o),document.execCommand("insertText",!1,l)):(this.textarea.value=s+l+p,this.textarea.selectionStart=i,this.textarea.selectionEnd=i+l.length)}else document.execCommand?document.execCommand("insertText",!1," "):(this.textarea.value=r.substring(0,i)+" "+r.substring(o),this.textarea.selectionStart=this.textarea.selectionEnd=i+2);this.textarea.dispatchEvent(new Event("input",{bubbles:!0}));return}if(e.key==="Enter"&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&this.options.smartLists&&this.handleSmartListContinuation()){e.preventDefault();return}!this.shortcuts.handleKeydown(e)&&this.options.onKeydown&&this.options.onKeydown(e,this)}handleSmartListContinuation(){let e=this.textarea,t=e.selectionStart,i=S.getListContext(e.value,t);return!i||!i.inList?!1:i.content.trim()===""&&t>=i.markerEndPos?(this.deleteListMarker(i),!0):(t>i.markerEndPos&&t<i.lineEnd?this.splitListItem(i,t):this.insertNewListItem(i),i.listType==="numbered"&&this.scheduleNumberedListUpdate(),!0)}deleteListMarker(e){this.textarea.setSelectionRange(e.lineStart,e.markerEndPos),document.execCommand("delete"),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}insertNewListItem(e){let t=S.createNewListItem(e);document.execCommand("insertText",!1,`
|
|
944
|
+
`+t),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}splitListItem(e,t){let i=e.content.substring(t-e.markerEndPos);this.textarea.setSelectionRange(t,e.lineEnd),document.execCommand("delete");let o=S.createNewListItem(e);document.execCommand("insertText",!1,`
|
|
945
|
+
`+o+i);let r=this.textarea.selectionStart-i.length;this.textarea.setSelectionRange(r,r),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}scheduleNumberedListUpdate(){this.numberUpdateTimeout&&clearTimeout(this.numberUpdateTimeout),this.numberUpdateTimeout=setTimeout(()=>{this.updateNumberedLists()},10)}updateNumberedLists(){let e=this.textarea.value,t=this.textarea.selectionStart,i=S.renumberLists(e);if(i!==e){let o=0,r=e.split(`
|
|
946
|
+
`),s=i.split(`
|
|
947
|
+
`),a=0;for(let d=0;d<r.length&&a<t;d++){if(r[d]!==s[d]){let l=s[d].length-r[d].length;a+r[d].length<t&&(o+=l)}a+=r[d].length+1}this.textarea.value=i;let p=t+o;this.textarea.setSelectionRange(p,p),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}}handleScroll(e){this.preview.scrollTop=this.textarea.scrollTop,this.preview.scrollLeft=this.textarea.scrollLeft}getValue(){return this.textarea.value}setValue(e){this.textarea.value=e,this.updatePreview(),this.options.autoResize&&this._updateAutoHeight()}getRenderedHTML(e={}){let t=this.getValue(),i=S.parse(t,-1,!1,this.options.codeHighlighter);return e.cleanHTML&&(i=i.replace(/<span class="syntax-marker[^"]*">.*?<\/span>/g,""),i=i.replace(/\sclass="(bullet-list|ordered-list|code-fence|hr-marker|blockquote|url-part)"/g,""),i=i.replace(/\sclass=""/g,"")),i}getPreviewHTML(){return this.preview.innerHTML}getCleanHTML(){return this.getRenderedHTML({cleanHTML:!0})}focus(){this.textarea.focus()}blur(){this.textarea.blur()}isInitialized(){return this.initialized}reinit(e={}){this.options=this._mergeOptions({...this.options,...e}),this._applyOptions(),this.updatePreview()}setTheme(e){this.instanceTheme=e;let t=typeof e=="string"?H(e):e,i=typeof t=="string"?t:t.name;if(i&&this.container.setAttribute("data-theme",i),t&&t.colors){let o=P(t.colors);this.container.style.cssText+=o}return this.updatePreview(),this}setCodeHighlighter(e){this.options.codeHighlighter=e,this.updatePreview()}_updateStats(){if(!this.statsBar)return;let e=this.textarea.value,t=e.split(`
|
|
948
|
+
`),i=e.length,o=e.split(/\s+/).filter(l=>l.length>0).length,r=this.textarea.selectionStart,a=e.substring(0,r).split(`
|
|
949
|
+
`),p=a.length,d=a[a.length-1].length+1;this.options.statsFormatter?this.statsBar.innerHTML=this.options.statsFormatter({chars:i,words:o,lines:t.length,line:p,column:d}):this.statsBar.innerHTML=`
|
|
950
|
+
<div class="overtype-stat">
|
|
951
|
+
<span class="live-dot"></span>
|
|
952
|
+
<span>${i} chars, ${o} words, ${t.length} lines</span>
|
|
953
|
+
</div>
|
|
954
|
+
<div class="overtype-stat">Line ${p}, Col ${d}</div>
|
|
955
|
+
`}_setupAutoResize(){this.container.classList.add("overtype-auto-resize"),this.previousHeight=null,this._updateAutoHeight(),this.textarea.addEventListener("input",()=>this._updateAutoHeight()),window.addEventListener("resize",()=>this._updateAutoHeight())}_updateAutoHeight(){if(!this.options.autoResize)return;let e=this.textarea,t=this.preview,i=this.wrapper,o=window.getComputedStyle(e),r=parseFloat(o.paddingTop),s=parseFloat(o.paddingBottom),a=e.scrollTop;e.style.setProperty("height","auto","important");let p=e.scrollHeight;if(this.options.minHeight){let c=parseInt(this.options.minHeight);p=Math.max(p,c)}let d="hidden";if(this.options.maxHeight){let c=parseInt(this.options.maxHeight);p>c&&(p=c,d="auto")}let l=p+"px";e.style.setProperty("height",l,"important"),e.style.setProperty("overflow-y",d,"important"),t.style.setProperty("height",l,"important"),t.style.setProperty("overflow-y",d,"important"),i.style.setProperty("height",l,"important"),e.scrollTop=a,t.scrollTop=a,this.previousHeight!==p&&(this.previousHeight=p)}showStats(e){this.options.showStats=e,e&&!this.statsBar?(this.statsBar=document.createElement("div"),this.statsBar.className="overtype-stats",this.container.appendChild(this.statsBar),this._updateStats()):!e&&this.statsBar&&(this.statsBar.remove(),this.statsBar=null)}showNormalEditMode(){return this.container.dataset.mode="normal",requestAnimationFrame(()=>{this.textarea.scrollTop=this.preview.scrollTop,this.textarea.scrollLeft=this.preview.scrollLeft}),this}showPlainTextarea(){if(this.container.dataset.mode="plain",this.toolbar){let e=this.container.querySelector('[data-action="toggle-plain"]');e&&(e.classList.remove("active"),e.title="Show markdown preview")}return this}showPreviewMode(){return this.container.dataset.mode="preview",this}destroy(){if(this.element.overTypeInstance=null,w.instances.delete(this.element),this.shortcuts&&this.shortcuts.destroy(),this.wrapper){let e=this.getValue();this.wrapper.remove(),this.element.textContent=e}this.initialized=!1}static init(e,t={}){return new w(e,t)}static getInstance(e){return e.overTypeInstance||w.instances.get(e)||null}static destroyAll(){document.querySelectorAll("[data-overtype-instance]").forEach(t=>{let i=w.getInstance(t);i&&i.destroy()})}static injectStyles(e=!1){if(w.stylesInjected&&!e)return;let t=document.querySelector("style.overtype-styles");t&&t.remove();let i=w.currentTheme||I,o=Z({theme:i}),r=document.createElement("style");r.className="overtype-styles",r.textContent=o,document.head.appendChild(r),w.stylesInjected=!0}static setTheme(e,t=null){let i=typeof e=="string"?H(e):e;t&&(i=Le(i,t)),w.currentTheme=i,w.injectStyles(!0),document.querySelectorAll(".overtype-container").forEach(r=>{let s=typeof i=="string"?i:i.name;s&&r.setAttribute("data-theme",s)}),document.querySelectorAll(".overtype-wrapper").forEach(r=>{if(!r.closest(".overtype-container")){let a=typeof i=="string"?i:i.name;a&&r.setAttribute("data-theme",a)}let s=r._instance;s&&s.updatePreview()});let o=typeof i=="string"?i:i.name;document.querySelectorAll("overtype-editor").forEach(r=>{o&&typeof r.setAttribute=="function"&&r.setAttribute("theme",o),typeof r.refreshTheme=="function"&&r.refreshTheme()})}static setCodeHighlighter(e){S.setCodeHighlighter(e),document.querySelectorAll(".overtype-wrapper").forEach(t=>{let i=t._instance;i&&i.updatePreview&&i.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(t=>{if(typeof t.getEditor=="function"){let i=t.getEditor();i&&i.updatePreview&&i.updatePreview()}})}static initGlobalListeners(){w.globalListenersInitialized||(document.addEventListener("input",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let t=e.target.closest(".overtype-wrapper"),i=t==null?void 0:t._instance;i&&i.handleInput(e)}}),document.addEventListener("keydown",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let t=e.target.closest(".overtype-wrapper"),i=t==null?void 0:t._instance;i&&i.handleKeydown(e)}}),document.addEventListener("scroll",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let t=e.target.closest(".overtype-wrapper"),i=t==null?void 0:t._instance;i&&i.handleScroll(e)}},!0),document.addEventListener("selectionchange",e=>{let t=document.activeElement;if(t&&t.classList.contains("overtype-input")){let i=t.closest(".overtype-wrapper"),o=i==null?void 0:i._instance;o&&(o.options.showStats&&o.statsBar&&o._updateStats(),clearTimeout(o._selectionTimeout),o._selectionTimeout=setTimeout(()=>{o.updatePreview()},50))}}),w.globalListenersInitialized=!0)}};C(w,"instances",new WeakMap),C(w,"stylesInjected",!1),C(w,"globalListenersInitialized",!1),C(w,"instanceCount",0);var B=w;B.MarkdownParser=S;B.ShortcutsManager=O;B.themes={solar:I,cave:H("cave")};B.getTheme=H;B.currentTheme=I;var ze=B;var Oe="overtype-webcomponent-container",nt="Start typing...",ot=["value","theme","toolbar","height","min-height","max-height","placeholder","font-size","line-height","padding","auto-resize","autofocus","show-stats","smart-lists","readonly"],Q=class extends HTMLElement{constructor(){super(),this.attachShadow({mode:"open"}),this._editor=null,this._initialized=!1,this._pendingOptions={},this._styleVersion=0,this._baseStyleElement=null,this._selectionChangeHandler=null,this._isConnected=!1,this._handleChange=this._handleChange.bind(this),this._handleKeydown=this._handleKeydown.bind(this)}_decodeValue(e){return typeof e!="string"?"":e.replace(/\\r/g,"\r").replace(/\\n/g,`
|
|
956
|
+
`).replace(/\\t/g," ")}static get observedAttributes(){return ot}connectedCallback(){this._isConnected=!0,this._initializeEditor()}disconnectedCallback(){this._isConnected=!1,this._cleanup()}attributeChangedCallback(e,t,i){if(t!==i&&!this._silentUpdate){if(!this._initialized){this._pendingOptions[e]=i;return}this._updateOption(e,i)}}_initializeEditor(){if(!(this._initialized||!this._isConnected))try{let e=document.createElement("div");e.className=Oe;let t=this.getAttribute("height"),i=this.getAttribute("min-height"),o=this.getAttribute("max-height");t&&(e.style.height=t),i&&(e.style.minHeight=i),o&&(e.style.maxHeight=o),this._injectStyles(),this.shadowRoot.appendChild(e);let r=this._getOptionsFromAttributes(),s=new ze(e,r);this._editor=s[0],this._initialized=!0,this._editor&&this._editor.textarea&&(this._editor.textarea.addEventListener("scroll",()=>{this._editor&&this._editor.preview&&this._editor.textarea&&(this._editor.preview.scrollTop=this._editor.textarea.scrollTop,this._editor.preview.scrollLeft=this._editor.textarea.scrollLeft)}),this._editor.textarea.addEventListener("input",a=>{this._editor&&this._editor.handleInput&&this._editor.handleInput(a)}),this._editor.textarea.addEventListener("keydown",a=>{this._editor&&this._editor.handleKeydown&&this._editor.handleKeydown(a)}),this._selectionChangeHandler=()=>{if(document.activeElement===this){let a=this.shadowRoot.activeElement;a&&a===this._editor.textarea&&(this._editor.options.showStats&&this._editor.statsBar&&this._editor._updateStats(),this._editor.linkTooltip&&this._editor.linkTooltip.checkCursorPosition&&this._editor.linkTooltip.checkCursorPosition())}},document.addEventListener("selectionchange",this._selectionChangeHandler)),this._applyPendingOptions(),this._dispatchEvent("ready",{editor:this._editor})}catch(e){let t=e&&e.message?e.message:String(e);console.warn("OverType Web Component initialization failed:",t),this._dispatchEvent("error",{error:{message:t}})}}_injectStyles(){let e=document.createElement("style"),t=this.getAttribute("theme")||"solar",i=H(t),o=this._getOptionsFromAttributes(),r=Z({...o,theme:i}),s=`
|
|
957
|
+
/* Web Component Host Styles */
|
|
958
|
+
:host {
|
|
959
|
+
display: block;
|
|
960
|
+
position: relative;
|
|
961
|
+
width: 100%;
|
|
962
|
+
height: 100%;
|
|
963
|
+
contain: layout style;
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
.overtype-webcomponent-container {
|
|
967
|
+
width: 100%;
|
|
968
|
+
height: 100%;
|
|
969
|
+
position: relative;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
/* Override container grid layout for web component */
|
|
973
|
+
.overtype-container {
|
|
974
|
+
height: 100% !important;
|
|
975
|
+
}
|
|
976
|
+
`;this._styleVersion+=1;let a=`
|
|
977
|
+
/* overtype-webcomponent styles v${this._styleVersion} */
|
|
978
|
+
`;e.textContent=a+r+s,this._baseStyleElement=e,this.shadowRoot.appendChild(e)}_getOptionsFromAttributes(){let e={value:this.getAttribute("value")!==null?this._decodeValue(this.getAttribute("value")):(this.textContent||"").trim(),placeholder:this.getAttribute("placeholder")||nt,toolbar:this.hasAttribute("toolbar"),autofocus:this.hasAttribute("autofocus"),autoResize:this.hasAttribute("auto-resize"),showStats:this.hasAttribute("show-stats"),smartLists:!this.hasAttribute("smart-lists")||this.getAttribute("smart-lists")!=="false",onChange:this._handleChange,onKeydown:this._handleKeydown},t=this.getAttribute("font-size");t&&(e.fontSize=t);let i=this.getAttribute("line-height");i&&(e.lineHeight=parseFloat(i)||1.6);let o=this.getAttribute("padding");o&&(e.padding=o);let r=this.getAttribute("min-height");r&&(e.minHeight=r);let s=this.getAttribute("max-height");return s&&(e.maxHeight=s),e}_applyPendingOptions(){for(let[e,t]of Object.entries(this._pendingOptions))this._updateOption(e,t);this._pendingOptions={}}_updateOption(e,t){if(this._editor)switch(e){case"value":{let i=this._decodeValue(t);this._editor.getValue()!==i&&this._editor.setValue(i||"")}break;case"theme":this._reinjectStyles();break;case"placeholder":this._editor.textarea&&(this._editor.textarea.placeholder=t||"");break;case"readonly":this._editor.textarea&&(this._editor.textarea.readOnly=this.hasAttribute("readonly"));break;case"height":case"min-height":case"max-height":this._updateContainerHeight();break;case"toolbar":if(!!this.hasAttribute("toolbar")==!!this._editor.options.toolbar)return;this._reinitializeEditor();break;case"auto-resize":if(!!this.hasAttribute("auto-resize")==!!this._editor.options.autoResize)return;this._reinitializeEditor();break;case"show-stats":if(!!this.hasAttribute("show-stats")==!!this._editor.options.showStats)return;this._reinitializeEditor();break;case"font-size":{this._updateFontSize(t)&&this._reinjectStyles();break}case"line-height":{this._updateLineHeight(t)&&this._reinjectStyles();break}case"padding":this._reinjectStyles();break;case"smart-lists":{let i=!this.hasAttribute("smart-lists")||this.getAttribute("smart-lists")!=="false";if(!!this._editor.options.smartLists==!!i)return;this._reinitializeEditor();break}}}_updateContainerHeight(){let e=this.shadowRoot.querySelector(`.${Oe}`);if(!e)return;let t=this.getAttribute("height"),i=this.getAttribute("min-height"),o=this.getAttribute("max-height");e.style.height=t||"",e.style.minHeight=i||"",e.style.maxHeight=o||""}_updateFontSize(e){return this._editor&&this._editor.wrapper?(this._editor.options.fontSize=e||"",this._editor.wrapper.style.setProperty("--instance-font-size",this._editor.options.fontSize),this._editor.updatePreview(),!0):!1}_updateLineHeight(e){if(this._editor&&this._editor.wrapper){let t=parseFloat(e),i=Number.isFinite(t)?t:this._editor.options.lineHeight;return this._editor.options.lineHeight=i,this._editor.wrapper.style.setProperty("--instance-line-height",String(i)),this._editor.updatePreview(),!0}return!1}_reinjectStyles(){this._baseStyleElement&&this._baseStyleElement.parentNode&&this._baseStyleElement.remove(),this._injectStyles()}_reinitializeEditor(){let e=this._editor?this._editor.getValue():"";this._cleanup(),this._initialized=!1,this.shadowRoot.innerHTML="",e&&!this.getAttribute("value")&&this.setAttribute("value",e),this._initializeEditor()}_handleChange(e){this._updateValueAttribute(e),!(!this._initialized||!this._editor)&&this._dispatchEvent("change",{value:e,editor:this._editor})}_handleKeydown(e){this._dispatchEvent("keydown",{event:e,editor:this._editor})}_updateValueAttribute(e){this.getAttribute("value")!==e&&(this._silentUpdate=!0,this.setAttribute("value",e),this._silentUpdate=!1)}_dispatchEvent(e,t={}){let i=new CustomEvent(e,{detail:t,bubbles:!0,composed:!0});this.dispatchEvent(i)}_cleanup(){this._selectionChangeHandler&&(document.removeEventListener("selectionchange",this._selectionChangeHandler),this._selectionChangeHandler=null),this._editor&&typeof this._editor.destroy=="function"&&this._editor.destroy(),this._editor=null,this._initialized=!1,this.shadowRoot&&(this.shadowRoot.innerHTML="")}refreshTheme(){this._initialized&&this._reinjectStyles()}getValue(){return this._editor?this._editor.getValue():this.getAttribute("value")||""}setValue(e){this._editor?this._editor.setValue(e):this.setAttribute("value",e)}getHTML(){return this._editor?this._editor.getRenderedHTML(!1):""}insertText(e){!this._editor||typeof e!="string"||this._editor.insertText(e)}focus(){this._editor&&this._editor.textarea&&this._editor.textarea.focus()}blur(){this._editor&&this._editor.textarea&&this._editor.textarea.blur()}getStats(){if(!this._editor||!this._editor.textarea)return null;let e=this._editor.textarea.value,t=e.split(`
|
|
979
|
+
`),i=e.length,o=e.split(/\s+/).filter(l=>l.length>0).length,r=this._editor.textarea.selectionStart,a=e.substring(0,r).split(`
|
|
980
|
+
`),p=a.length,d=a[a.length-1].length+1;return{characters:i,words:o,lines:t.length,line:p,column:d}}isReady(){return this._initialized&&this._editor!==null}getEditor(){return this._editor}};customElements.get("overtype-editor")||customElements.define("overtype-editor",Q);var rt=Q;return qe(st);})();
|
|
981
|
+
/**
|
|
982
|
+
* OverType - A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
983
|
+
* @version 1.0.0
|
|
984
|
+
* @license MIT
|
|
985
|
+
*/
|
|
986
|
+
/**
|
|
987
|
+
* OverType Web Component
|
|
988
|
+
* A custom element wrapper for the OverType markdown editor with Shadow DOM isolation
|
|
989
|
+
* @version 1.0.0
|
|
990
|
+
* @license MIT
|
|
991
|
+
*/
|