overtype 2.3.7 → 2.3.9
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 +5 -4
- package/dist/overtype-webcomponent.esm.js +220 -23
- package/dist/overtype-webcomponent.esm.js.map +3 -3
- package/dist/overtype-webcomponent.js +216 -23
- package/dist/overtype-webcomponent.js.map +3 -3
- package/dist/overtype-webcomponent.min.js +52 -945
- package/dist/overtype.cjs +218 -23
- package/dist/overtype.cjs.map +3 -3
- package/dist/overtype.d.ts +24 -1
- package/dist/overtype.esm.js +221 -23
- package/dist/overtype.esm.js.map +3 -3
- package/dist/overtype.js +218 -23
- package/dist/overtype.js.map +3 -3
- package/dist/overtype.min.js +49 -941
- package/package.json +1 -1
- package/src/overtype.d.ts +24 -1
- package/src/overtype.js +92 -24
package/dist/overtype.min.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OverType v2.3.
|
|
2
|
+
* OverType v2.3.9
|
|
3
3
|
* A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @author David Miranda
|
|
6
6
|
* https://github.com/panphora/overtype
|
|
7
7
|
*/
|
|
8
|
-
var OverType=(()=>{var
|
|
9
|
-
`),a=!1,p=s.map((c,d)=>{if(
|
|
10
|
-
`);let f=c.textContent.replace(/\u00A0/g," ");s._codeContent+=f,
|
|
11
|
-
`),
|
|
12
|
-
`),d=s.slice(3).trim(),
|
|
13
|
-
`),
|
|
14
|
-
`),
|
|
15
|
-
`)}};T(C,"linkIndex",0),T(C,"codeHighlighter",null),T(C,"customSyntax",null),T(C,"LIST_PATTERNS",{bullet:/^(\s*)([-*+])\s+(.*)$/,numbered:/^(\s*)(\d+)\.\s+(.*)$/,checkbox:/^(\s*)-\s+\[([ x])\]\s+(.*)$/});var
|
|
16
|
-
`)}function
|
|
8
|
+
var OverType=(()=>{var ke=Object.defineProperty;var yn=Object.getOwnPropertyDescriptor;var wn=Object.getOwnPropertyNames;var bn=Object.prototype.hasOwnProperty;var xn=(t,e,n)=>e in t?ke(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var st=(t,e)=>{for(var n in e)ke(t,n,{get:e[n],enumerable:!0})},kn=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of wn(e))!bn.call(t,i)&&i!==n&&ke(t,i,{get:()=>e[i],enumerable:!(o=yn(e,i))||o.enumerable});return t};var Ln=t=>kn(ke({},"__esModule",{value:!0}),t);var T=(t,e,n)=>(xn(t,typeof e!="symbol"?e+"":e,n),n);var vo={};st(vo,{OverType:()=>j,default:()=>go,defaultToolbarButtons:()=>re,markdownActions:()=>ne,toolbarButtons:()=>S});var C=class{static resetLinkIndex(){this.linkIndex=0}static setCodeHighlighter(e){this.codeHighlighter=e}static setCustomSyntax(e){this.customSyntax=e}static applyCustomSyntax(e){return this.customSyntax?this.customSyntax(e):e}static escapeHtml(e){let n={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,o=>n[o])}static preserveIndentation(e,n){let i=n.match(/^(\s*)/)[1].replace(/ /g," ");return e.replace(/^\s*/,i)}static parseHeader(e){return e.replace(/^(#{1,3})\s(.+)$/,(n,o,i)=>{let r=o.length;return i=this.parseInlineElements(i),`<h${r}><span class="syntax-marker">${o} </span>${i}</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(/^> (.+)$/,(n,o)=>`<span class="blockquote"><span class="syntax-marker">></span> ${o}</span>`)}static parseBulletList(e){return e.replace(/^((?: )*)([-*+])\s(.+)$/,(n,o,i,r)=>(r=this.parseInlineElements(r),`${o}<li class="bullet-list"><span class="syntax-marker">${i} </span>${r}</li>`))}static parseTaskList(e,n=!1){return e.replace(/^((?: )*)-(\s+)\[([ xX])\](\s*)(.*)$/,(o,i,r,s,a,l)=>{if(l=this.parseInlineElements(l),n){let p=s.toLowerCase()==="x";return`${i}<li class="task-list"><input type="checkbox" ${p?"checked":""}> ${l}</li>`}else return`${i}<li class="task-list"><span class="syntax-marker">-${r}[${s}]${a}</span>${l}</li>`})}static parseNumberedList(e){return e.replace(/^((?: )*)(\d+\.)\s(.+)$/,(n,o,i,r)=>(r=this.parseInlineElements(r),`${o}<li class="ordered-list"><span class="syntax-marker">${i} </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 n=e.trim(),o=n.toLowerCase(),r=["http://","https://","mailto:","ftp://","ftps://"].some(a=>o.startsWith(a)),s=n.startsWith("/")||n.startsWith("#")||n.startsWith("?")||n.startsWith(".")||!n.includes(":")&&!n.includes("//");return r||s?e:"#"}static parseLinks(e){return e.replace(/\[(.+?)\]\((.+?)\)/g,(n,o,i)=>{let r=`--link-${this.linkIndex++}`;return`<a href="${this.sanitizeUrl(i)}" style="anchor-name: ${r}"><span class="syntax-marker">[</span>${o}<span class="syntax-marker url-part">](${i})</span></a>`})}static identifyAndProtectSanctuaries(e){let n=new Map,o=0,i=e,r=[],s=/\[([^\]]+)\]\(([^)]+)\)/g,a;for(;(a=s.exec(e))!==null;){let u=a.index+a[0].indexOf("](")+2,h=u+a[2].length;r.push({start:u,end:h})}let l=new RegExp("(?<!`)(`+)(?!`)((?:(?!\\1).)+?)(\\1)(?!`)","g"),p,c=[];for(;(p=l.exec(e))!==null;){let d=p.index,u=p.index+p[0].length;r.some(f=>d>=f.start&&u<=f.end)||c.push({match:p[0],index:p.index,openTicks:p[1],content:p[2],closeTicks:p[3]})}return c.sort((d,u)=>u.index-d.index),c.forEach(d=>{let u=`\uE000${o++}\uE001`;n.set(u,{type:"code",original:d.match,openTicks:d.openTicks,content:d.content,closeTicks:d.closeTicks}),i=i.substring(0,d.index)+u+i.substring(d.index+d.match.length)}),i=i.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(d,u,h)=>{let f=`\uE000${o++}\uE001`;return n.set(f,{type:"link",original:d,linkText:u,url:h}),f}),{protectedText:i,sanctuaries:n}}static restoreAndTransformSanctuaries(e,n){return Array.from(n.keys()).sort((i,r)=>{let s=e.indexOf(i),a=e.indexOf(r);return s-a}).forEach(i=>{let r=n.get(i),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;n.forEach((c,d)=>{if(a.includes(d)&&c.type==="code"){let u=`<code><span class="syntax-marker">${c.openTicks}</span>${c.content}<span class="syntax-marker">${c.closeTicks}</span></code>`;a=a.replace(d,u)}}),a=this.parseStrikethrough(a),a=this.parseBold(a),a=this.parseItalic(a);let l=`--link-${this.linkIndex++}`;s=`<a href="${this.sanitizeUrl(r.url)}" style="anchor-name: ${l}"><span class="syntax-marker">[</span>${a}<span class="syntax-marker url-part">](${r.url})</span></a>`}e=e.replace(i,s)}),e}static parseInlineElements(e){let{protectedText:n,sanctuaries:o}=this.identifyAndProtectSanctuaries(e),i=n;return i=this.parseStrikethrough(i),i=this.parseBold(i),i=this.parseItalic(i),i=this.restoreAndTransformSanctuaries(i,o),i}static parseLine(e,n=!1){let o=this.escapeHtml(e);o=this.preserveIndentation(o,e);let i=this.parseHorizontalRule(o);if(i)return i;let r=this.parseCodeBlock(o);return r||(o=this.parseHeader(o),o=this.parseBlockquote(o),o=this.parseTaskList(o,n),o=this.parseBulletList(o),o=this.parseNumberedList(o),!o.includes("<li")&&!o.includes("<h")&&(o=this.parseInlineElements(o)),o.trim()===""?"<div> </div>":`<div>${o}</div>`)}static parse(e,n=-1,o=!1,i,r=!1){this.resetLinkIndex();let s=e.split(`
|
|
9
|
+
`),a=!1,p=s.map((c,d)=>{if(o&&d===n)return`<div class="raw-line">${this.escapeHtml(c)||" "}</div>`;if(/^```[^`]*$/.test(c))return a=!a,this.applyCustomSyntax(this.parseLine(c,r));if(a){let h=this.escapeHtml(c);return`<div>${this.preserveIndentation(h,c)||" "}</div>`}return this.applyCustomSyntax(this.parseLine(c,r))}).join("");return this.postProcessHTML(p,i)}static postProcessHTML(e,n){if(typeof document>"u"||!document)return this.postProcessHTMLManual(e,n);let o=document.createElement("div");o.innerHTML=e;let i=null,r=null,s=null,a=!1,l=Array.from(o.children);for(let p=0;p<l.length;p++){let c=l[p];if(!c.parentNode)continue;let d=c.querySelector(".code-fence");if(d){let h=d.textContent;if(h.startsWith("```"))if(a){let f=n||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=h.slice(3).trim();m&&(f.className=`language-${m}`),o.insertBefore(s,c.nextSibling),s._codeElement=f,s._language=m,s._codeContent="";continue}}if(a&&s&&c.tagName==="DIV"&&!c.querySelector(".code-fence")){let h=s._codeElement||s.querySelector("code");s._codeContent.length>0&&(s._codeContent+=`
|
|
10
|
+
`);let f=c.textContent.replace(/\u00A0/g," ");s._codeContent+=f,h.textContent.length>0&&(h.textContent+=`
|
|
11
|
+
`),h.textContent+=f,c.remove();continue}let u=null;if(c.tagName==="DIV"&&(u=c.querySelector("li")),u){let h=u.classList.contains("bullet-list"),f=u.classList.contains("ordered-list");if(!h&&!f){i=null,r=null;continue}let m=h?"ul":"ol";(!i||r!==m)&&(i=document.createElement(m),o.insertBefore(i,c),r=m);let g=[];for(let y of c.childNodes)if(y.nodeType===3&&y.textContent.match(/^\u00A0+$/))g.push(y.cloneNode(!0));else if(y===u)break;g.forEach(y=>{u.insertBefore(y,u.firstChild)}),i.appendChild(u),c.remove()}else i=null,r=null}return o.innerHTML}static postProcessHTMLManual(e,n){let o=e;o=o.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(l=>{let p=l.match(/<div>((?: )*)<li/),c=l.match(/<li class="bullet-list">.*?<\/li>/);if(p&&c){let d=p[1];return c[0].replace(/<li class="bullet-list">/,`<li class="bullet-list">${d}`)}return c?c[0]:""}).filter(Boolean).join("")+"</ul>":r}),o=o.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(l=>{let p=l.match(/<div>((?: )*)<li/),c=l.match(/<li class="ordered-list">.*?<\/li>/);if(p&&c){let d=p[1];return c[0].replace(/<li class="ordered-list">/,`<li class="ordered-list">${d}`)}return c?c[0]:""}).filter(Boolean).join("")+"</ol>":r});let i=/<div><span class="code-fence">(```[^<]*)<\/span><\/div>(.*?)<div><span class="code-fence">(```)<\/span><\/div>/gs;return o=o.replace(i,(r,s,a,l)=>{let c=(a.match(/<div>(.*?)<\/div>/gs)||[]).map(g=>g.replace(/<div>(.*?)<\/div>/s,"$1").replace(/ /g," ")).join(`
|
|
12
|
+
`),d=s.slice(3).trim(),u=d?` class="language-${d}"`:"",h=c,f=n||this.codeHighlighter;if(f)try{let g=c.replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"),y=f(g,d);y&&typeof y.then=="function"?console.warn("Async highlighters are not supported in Node.js (non-DOM) context. Use synchronous highlighters for server-side rendering."):y&&typeof y=="string"&&y.trim()&&(h=y)}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${u}>${h}</code></pre>`,m+=`<div><span class="code-fence">${l}</span></div>`,m}),o}static getListContext(e,n){let o=e.split(`
|
|
13
|
+
`),i=0,r=0,s=0;for(let u=0;u<o.length;u++){let h=o[u].length;if(i+h>=n){r=u,s=i;break}i+=h+1}let a=o[r],l=s+a.length,p=a.match(this.LIST_PATTERNS.checkbox);if(p)return{inList:!0,listType:"checkbox",indent:p[1],marker:"-",checked:p[2]==="x",content:p[3],lineStart:s,lineEnd:l,markerEndPos:s+p[1].length+p[2].length+5};let c=a.match(this.LIST_PATTERNS.bullet);if(c)return{inList:!0,listType:"bullet",indent:c[1],marker:c[2],content:c[3],lineStart:s,lineEnd:l,markerEndPos:s+c[1].length+c[2].length+1};let d=a.match(this.LIST_PATTERNS.numbered);return d?{inList:!0,listType:"numbered",indent:d[1],marker:parseInt(d[2]),content:d[3],lineStart:s,lineEnd:l,markerEndPos:s+d[1].length+d[2].length+2}:{inList:!1,listType:null,indent:"",marker:null,content:a,lineStart:s,lineEnd:l,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 n=e.split(`
|
|
14
|
+
`),o=new Map,i=!1;return n.map(s=>{let a=s.match(this.LIST_PATTERNS.numbered);if(a){let l=a[1],p=l.length,c=a[3];i||o.clear();let d=(o.get(p)||0)+1;o.set(p,d);for(let[u]of o)u>p&&o.delete(u);return i=!0,`${l}${d}. ${c}`}else return(s.trim()===""||!s.match(/^\s/))&&(i=!1,o.clear()),s}).join(`
|
|
15
|
+
`)}};T(C,"linkIndex",0),T(C,"codeHighlighter",null),T(C,"customSyntax",null),T(C,"LIST_PATTERNS",{bullet:/^(\s*)([-*+])\s+(.*)$/,numbered:/^(\s*)(\d+)\.\s+(.*)$/,checkbox:/^(\s*)-\s+\[([ x])\]\s+(.*)$/});var ae=class{constructor(e){this.editor=e}handleKeydown(e){if(!(navigator.platform.toLowerCase().includes("mac")?e.metaKey:e.ctrlKey))return!1;let i=null;switch(e.key.toLowerCase()){case"b":e.shiftKey||(i="toggleBold");break;case"i":e.shiftKey||(i="toggleItalic");break;case"k":e.shiftKey||(i="insertLink");break;case"7":e.shiftKey&&(i="toggleNumberedList");break;case"8":e.shiftKey&&(i="toggleBulletList");break}return i?(e.preventDefault(),this.editor.performAction(i,e),!0):!1}destroy(){}};var F={name:"solar",colors:{bgPrimary:"#faf0ca",bgSecondary:"#ffffff",text:"#0d3b66",textPrimary:"#0d3b66",textSecondary:"#5a7a9b",h1:"#f95738",h2:"#ee964b",h3:"#3d8a51",strong:"#ee964b",em:"#f95738",del:"#ee964b",link:"#0d3b66",code:"#0d3b66",codeBg:"rgba(244, 211, 94, 0.4)",blockquote:"#5a7a9b",hr:"#5a7a9b",syntaxMarker:"rgba(13, 59, 102, 0.52)",syntax:"#999999",cursor:"#f95738",selection:"rgba(244, 211, 94, 0.4)",listMarker:"#ee964b",rawLine:"#5a7a9b",border:"#e0e0e0",hoverBg:"#f0f0f0",primary:"#0d3b66",toolbarBg:"#ffffff",toolbarIcon:"#0d3b66",toolbarHover:"#f5f5f5",toolbarActive:"#faf0ca",placeholder:"#999999"},previewColors:{text:"#0d3b66",h1:"inherit",h2:"inherit",h3:"inherit",strong:"inherit",em:"inherit",link:"#0d3b66",code:"#0d3b66",codeBg:"rgba(244, 211, 94, 0.4)",blockquote:"#5a7a9b",hr:"#5a7a9b",bg:"transparent"}},at={name:"cave",colors:{bgPrimary:"#141E26",bgSecondary:"#1D2D3E",text:"#c5dde8",textPrimary:"#c5dde8",textSecondary:"#9fcfec",h1:"#d4a5ff",h2:"#f6ae2d",h3:"#9fcfec",strong:"#f6ae2d",em:"#9fcfec",del:"#f6ae2d",link:"#9fcfec",code:"#c5dde8",codeBg:"#1a232b",blockquote:"#9fcfec",hr:"#c5dde8",syntaxMarker:"rgba(159, 207, 236, 0.73)",syntax:"#7a8c98",cursor:"#f26419",selection:"rgba(51, 101, 138, 0.4)",listMarker:"#f6ae2d",rawLine:"#9fcfec",border:"#2a3f52",hoverBg:"#243546",primary:"#9fcfec",toolbarBg:"#1D2D3E",toolbarIcon:"#c5dde8",toolbarHover:"#243546",toolbarActive:"#2a3f52",placeholder:"#6a7a88"},previewColors:{text:"#c5dde8",h1:"inherit",h2:"inherit",h3:"inherit",strong:"inherit",em:"inherit",link:"#9fcfec",code:"#c5dde8",codeBg:"#1a232b",blockquote:"#9fcfec",hr:"#c5dde8",bg:"transparent"}},lt={solar:F,cave:at,auto:F,light:F,dark:at};function U(t){return typeof t=="string"?{...lt[t]||lt.solar,name:t}:t}function qe(t){if(t!=="auto")return t;let e=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)");return e!=null&&e.matches?"cave":"solar"}function Q(t,e){let n=[];for(let[o,i]of Object.entries(t)){let r=o.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(`--${r}: ${i};`)}if(e)for(let[o,i]of Object.entries(e)){let r=o.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(`--preview-${r}-default: ${i};`)}return n.join(`
|
|
16
|
+
`)}function ct(t,e={},n={}){return{...t,colors:{...t.colors,...e},previewColors:{...t.previewColors,...n}}}function pt(t={}){let{fontSize:e="14px",lineHeight:n=1.6,fontFamily:o='"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:i="20px",theme:r=null,mobile:s={}}=t,a=Object.keys(s).length>0?`
|
|
17
17
|
@media (max-width: 640px) {
|
|
18
18
|
.overtype-wrapper .overtype-input,
|
|
19
19
|
.overtype-wrapper .overtype-preview {
|
|
@@ -21,91 +21,9 @@ var OverType=(()=>{var ve=Object.defineProperty;var cn=Object.getOwnPropertyDesc
|
|
|
21
21
|
`)}
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
`:"",l=r&&r.colors?Q(r.colors,r.previewColors):"";return
|
|
25
|
-
/* OverType Editor Styles */
|
|
26
|
-
|
|
27
|
-
/* Middle-ground CSS Reset - Prevent parent styles from leaking in */
|
|
28
|
-
.overtype-container * {
|
|
29
|
-
/* Box model - these commonly leak */
|
|
30
|
-
margin: 0 !important;
|
|
31
|
-
padding: 0 !important;
|
|
32
|
-
border: 0 !important;
|
|
33
|
-
|
|
34
|
-
/* Layout - these can break our layout */
|
|
35
|
-
/* Don't reset position - it breaks dropdowns */
|
|
36
|
-
float: none !important;
|
|
37
|
-
clear: none !important;
|
|
38
|
-
|
|
39
|
-
/* Typography - only reset decorative aspects */
|
|
40
|
-
text-decoration: none !important;
|
|
41
|
-
text-transform: none !important;
|
|
42
|
-
letter-spacing: normal !important;
|
|
43
|
-
|
|
44
|
-
/* Visual effects that can interfere */
|
|
45
|
-
box-shadow: none !important;
|
|
46
|
-
text-shadow: none !important;
|
|
47
|
-
|
|
48
|
-
/* Ensure box-sizing is consistent */
|
|
49
|
-
box-sizing: border-box !important;
|
|
50
|
-
|
|
51
|
-
/* Keep inheritance for these */
|
|
52
|
-
/* font-family, color, line-height, font-size - inherit */
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/* Container base styles after reset */
|
|
56
|
-
.overtype-container {
|
|
57
|
-
display: flex !important;
|
|
58
|
-
flex-direction: column !important;
|
|
59
|
-
width: 100% !important;
|
|
60
|
-
height: 100% !important;
|
|
61
|
-
position: relative !important; /* Override reset - needed for absolute children */
|
|
62
|
-
overflow: visible !important; /* Allow dropdown to overflow container */
|
|
63
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
|
|
64
|
-
text-align: left !important;
|
|
65
|
-
${l?`
|
|
24
|
+
`:"",l=r&&r.colors?Q(r.colors,r.previewColors):"";return`.overtype-container *{margin: 0 !important;padding: 0 !important;border: 0 !important;float: none !important;clear: none !important;text-decoration: none !important;text-transform: none !important;letter-spacing: normal !important;box-shadow: none !important;text-shadow: none !important;box-sizing: border-box !important}.overtype-container{display: flex !important;flex-direction: column !important;width: 100% !important;height: 100% !important;position: relative !important;overflow: visible !important;font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif !important;text-align: left !important;${l?`
|
|
66
25
|
/* Theme Variables */
|
|
67
|
-
${l}`:""}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/* Force left alignment for all elements in the editor */
|
|
71
|
-
.overtype-container .overtype-wrapper * {
|
|
72
|
-
text-align: left !important;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/* Auto-resize mode styles */
|
|
76
|
-
.overtype-container.overtype-auto-resize {
|
|
77
|
-
height: auto !important;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.overtype-container.overtype-auto-resize .overtype-wrapper {
|
|
81
|
-
flex: 0 0 auto !important; /* Don't grow/shrink, use explicit height */
|
|
82
|
-
height: auto !important;
|
|
83
|
-
min-height: 60px !important;
|
|
84
|
-
overflow: visible !important;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.overtype-wrapper {
|
|
88
|
-
position: relative !important; /* Override reset - needed for absolute children */
|
|
89
|
-
width: 100% !important;
|
|
90
|
-
flex: 1 1 0 !important; /* Grow to fill remaining space, with flex-basis: 0 */
|
|
91
|
-
min-height: 60px !important; /* Minimum usable height */
|
|
92
|
-
overflow: hidden !important;
|
|
93
|
-
background: var(--bg-secondary, #ffffff) !important;
|
|
94
|
-
z-index: 1; /* Below toolbar and dropdown */
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/* Critical alignment styles - must be identical for both layers */
|
|
98
|
-
.overtype-wrapper .overtype-input,
|
|
99
|
-
.overtype-wrapper .overtype-preview {
|
|
100
|
-
/* Positioning - must be identical */
|
|
101
|
-
position: absolute !important; /* Override reset - required for overlay */
|
|
102
|
-
top: 0 !important;
|
|
103
|
-
left: 0 !important;
|
|
104
|
-
width: 100% !important;
|
|
105
|
-
height: 100% !important;
|
|
106
|
-
|
|
107
|
-
/* Font properties - any difference breaks alignment */
|
|
108
|
-
font-family: var(--instance-font-family, ${i}) !important;
|
|
26
|
+
${l}`:""}}.overtype-container .overtype-wrapper *{text-align: left !important}.overtype-container.overtype-auto-resize{height: auto !important}.overtype-container.overtype-auto-resize .overtype-wrapper{flex: 0 0 auto !important;height: auto !important;min-height: 60px !important;overflow: visible !important}.overtype-wrapper{position: relative !important;width: 100% !important;flex: 1 1 0 !important;min-height: 60px !important;overflow: hidden !important;background: var(--bg-secondary,#ffffff) !important;z-index: 1}.overtype-wrapper .overtype-input,.overtype-wrapper .overtype-preview{position: absolute !important;top: 0 !important;left: 0 !important;width: 100% !important;height: 100% !important;font-family: var(--instance-font-family,${o}) !important;
|
|
109
27
|
font-variant-ligatures: none !important; /* keep metrics stable for code */
|
|
110
28
|
font-size: var(--instance-font-size, ${e}) !important;
|
|
111
29
|
line-height: var(--instance-line-height, ${n}) !important;
|
|
@@ -117,791 +35,33 @@ var OverType=(()=>{var ve=Object.defineProperty;var cn=Object.getOwnPropertyDesc
|
|
|
117
35
|
font-feature-settings: normal !important;
|
|
118
36
|
|
|
119
37
|
/* Box model - must match exactly */
|
|
120
|
-
padding: var(--instance-padding, ${o}) !important;
|
|
121
|
-
margin: 0 !important;
|
|
122
|
-
border: none !important;
|
|
123
|
-
outline: none !important;
|
|
124
|
-
box-sizing: border-box !important;
|
|
125
|
-
|
|
126
|
-
/* Text layout - critical for character positioning */
|
|
127
|
-
white-space: pre-wrap !important;
|
|
128
|
-
word-wrap: break-word !important;
|
|
129
|
-
word-break: normal !important;
|
|
130
|
-
overflow-wrap: break-word !important;
|
|
131
|
-
tab-size: 2 !important;
|
|
132
|
-
-moz-tab-size: 2 !important;
|
|
133
|
-
text-align: left !important;
|
|
134
|
-
text-indent: 0 !important;
|
|
135
|
-
letter-spacing: normal !important;
|
|
136
|
-
word-spacing: normal !important;
|
|
137
|
-
|
|
138
|
-
/* Text rendering */
|
|
139
|
-
text-transform: none !important;
|
|
140
|
-
text-rendering: auto !important;
|
|
141
|
-
-webkit-font-smoothing: auto !important;
|
|
142
|
-
-webkit-text-size-adjust: 100% !important;
|
|
143
|
-
|
|
144
|
-
/* Direction and writing */
|
|
145
|
-
direction: ltr !important;
|
|
146
|
-
writing-mode: horizontal-tb !important;
|
|
147
|
-
unicode-bidi: normal !important;
|
|
148
|
-
text-orientation: mixed !important;
|
|
149
|
-
|
|
150
|
-
/* Visual effects that could shift perception */
|
|
151
|
-
text-shadow: none !important;
|
|
152
|
-
filter: none !important;
|
|
153
|
-
transform: none !important;
|
|
154
|
-
zoom: 1 !important;
|
|
155
|
-
|
|
156
|
-
/* Vertical alignment */
|
|
157
|
-
vertical-align: baseline !important;
|
|
158
|
-
|
|
159
|
-
/* Size constraints */
|
|
160
|
-
min-width: 0 !important;
|
|
161
|
-
min-height: 0 !important;
|
|
162
|
-
max-width: none !important;
|
|
163
|
-
max-height: none !important;
|
|
164
|
-
|
|
165
|
-
/* Overflow */
|
|
166
|
-
overflow-y: auto !important;
|
|
167
|
-
overflow-x: auto !important;
|
|
168
|
-
/* overscroll-behavior removed to allow scroll-through to parent */
|
|
169
|
-
scrollbar-width: auto !important;
|
|
170
|
-
scrollbar-gutter: auto !important;
|
|
171
|
-
|
|
172
|
-
/* Animation/transition - disabled to prevent movement */
|
|
173
|
-
animation: none !important;
|
|
174
|
-
transition: none !important;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/* Input layer styles */
|
|
178
|
-
.overtype-wrapper .overtype-input {
|
|
179
|
-
/* Layer positioning */
|
|
180
|
-
z-index: 1 !important;
|
|
181
|
-
|
|
182
|
-
/* Text visibility */
|
|
183
|
-
color: transparent !important;
|
|
184
|
-
caret-color: var(--cursor, #f95738) !important;
|
|
185
|
-
background-color: transparent !important;
|
|
186
|
-
|
|
187
|
-
/* Textarea-specific */
|
|
188
|
-
resize: none !important;
|
|
189
|
-
appearance: none !important;
|
|
190
|
-
-webkit-appearance: none !important;
|
|
191
|
-
-moz-appearance: none !important;
|
|
192
|
-
|
|
193
|
-
/* Prevent mobile zoom on focus */
|
|
194
|
-
touch-action: manipulation !important;
|
|
195
|
-
|
|
196
|
-
/* Disable autofill */
|
|
197
|
-
autocomplete: off !important;
|
|
198
|
-
autocorrect: off !important;
|
|
199
|
-
autocapitalize: off !important;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
.overtype-wrapper .overtype-input::selection {
|
|
203
|
-
background-color: var(--selection, rgba(244, 211, 94, 0.4));
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/* Placeholder shim - visible when textarea is empty */
|
|
207
|
-
.overtype-wrapper .overtype-placeholder {
|
|
208
|
-
position: absolute !important;
|
|
209
|
-
top: 0 !important;
|
|
210
|
-
left: 0 !important;
|
|
211
|
-
width: 100% !important;
|
|
212
|
-
z-index: 0 !important;
|
|
213
|
-
pointer-events: none !important;
|
|
214
|
-
user-select: none !important;
|
|
215
|
-
font-family: var(--instance-font-family, ${i}) !important;
|
|
38
|
+
padding: var(--instance-padding, ${i}) !important;margin: 0 !important;border: none !important;outline: none !important;box-sizing: border-box !important;white-space: pre-wrap !important;word-wrap: break-word !important;word-break: normal !important;overflow-wrap: break-word !important;tab-size: 2 !important;-moz-tab-size: 2 !important;text-align: left !important;text-indent: 0 !important;letter-spacing: normal !important;word-spacing: normal !important;text-transform: none !important;text-rendering: auto !important;-webkit-font-smoothing: auto !important;-webkit-text-size-adjust: 100% !important;direction: ltr !important;writing-mode: horizontal-tb !important;unicode-bidi: normal !important;text-orientation: mixed !important;text-shadow: none !important;filter: none !important;transform: none !important;zoom: 1 !important;vertical-align: baseline !important;min-width: 0 !important;min-height: 0 !important;max-width: none !important;max-height: none !important;overflow-y: auto !important;overflow-x: auto !important;scrollbar-width: auto !important;scrollbar-gutter: auto !important;animation: none !important;transition: none !important}.overtype-wrapper .overtype-input{z-index: 1 !important;color: transparent !important;caret-color: var(--cursor,#f95738) !important;background-color: transparent !important;resize: none !important;appearance: none !important;-webkit-appearance: none !important;-moz-appearance: none !important;touch-action: manipulation !important;autocomplete: off !important;autocorrect: off !important;autocapitalize: off !important}.overtype-wrapper .overtype-input::selection{background-color: var(--selection,rgba(244,211,94,0.4))}.overtype-wrapper .overtype-placeholder{position: absolute !important;top: 0 !important;left: 0 !important;width: 100% !important;z-index: 0 !important;pointer-events: none !important;user-select: none !important;font-family: var(--instance-font-family,${o}) !important;
|
|
216
39
|
font-size: var(--instance-font-size, ${e}) !important;
|
|
217
40
|
line-height: var(--instance-line-height, ${n}) !important;
|
|
218
|
-
padding: var(--instance-padding, ${o}) !important;
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
/* Preview layer styles */
|
|
224
|
-
.overtype-wrapper .overtype-preview {
|
|
225
|
-
/* Layer positioning */
|
|
226
|
-
z-index: 0 !important;
|
|
227
|
-
pointer-events: none !important;
|
|
228
|
-
color: var(--text, #0d3b66) !important;
|
|
229
|
-
background-color: transparent !important;
|
|
230
|
-
|
|
231
|
-
/* Prevent text selection */
|
|
232
|
-
user-select: none !important;
|
|
233
|
-
-webkit-user-select: none !important;
|
|
234
|
-
-moz-user-select: none !important;
|
|
235
|
-
-ms-user-select: none !important;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/* Prevent external resets (Tailwind, Bootstrap, etc.) from breaking alignment.
|
|
239
|
-
Any element whose font metrics differ from the textarea causes the CSS "strut"
|
|
240
|
-
to inflate line boxes, drifting the overlay. Force inheritance so every element
|
|
241
|
-
inside the preview matches the textarea exactly. */
|
|
242
|
-
.overtype-wrapper .overtype-preview * {
|
|
243
|
-
font-family: inherit !important;
|
|
244
|
-
font-size: inherit !important;
|
|
245
|
-
line-height: inherit !important;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
/* Defensive styles for preview child divs */
|
|
249
|
-
.overtype-wrapper .overtype-preview div {
|
|
250
|
-
/* Reset any inherited styles */
|
|
251
|
-
margin: 0 !important;
|
|
252
|
-
padding: 0 !important;
|
|
253
|
-
border: none !important;
|
|
254
|
-
text-align: left !important;
|
|
255
|
-
text-indent: 0 !important;
|
|
256
|
-
display: block !important;
|
|
257
|
-
position: static !important;
|
|
258
|
-
transform: none !important;
|
|
259
|
-
min-height: 0 !important;
|
|
260
|
-
max-height: none !important;
|
|
261
|
-
line-height: inherit !important;
|
|
262
|
-
font-size: inherit !important;
|
|
263
|
-
font-family: inherit !important;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/* Markdown element styling - NO SIZE CHANGES */
|
|
267
|
-
.overtype-wrapper .overtype-preview .header {
|
|
268
|
-
font-weight: bold !important;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/* Header colors */
|
|
272
|
-
.overtype-wrapper .overtype-preview .h1 {
|
|
273
|
-
color: var(--h1, #f95738) !important;
|
|
274
|
-
}
|
|
275
|
-
.overtype-wrapper .overtype-preview .h2 {
|
|
276
|
-
color: var(--h2, #ee964b) !important;
|
|
277
|
-
}
|
|
278
|
-
.overtype-wrapper .overtype-preview .h3 {
|
|
279
|
-
color: var(--h3, #3d8a51) !important;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/* Semantic headers - flatten in edit mode */
|
|
283
|
-
.overtype-wrapper .overtype-preview h1,
|
|
284
|
-
.overtype-wrapper .overtype-preview h2,
|
|
285
|
-
.overtype-wrapper .overtype-preview h3 {
|
|
286
|
-
font-size: inherit !important;
|
|
287
|
-
font-weight: bold !important;
|
|
288
|
-
margin: 0 !important;
|
|
289
|
-
padding: 0 !important;
|
|
290
|
-
display: inline !important;
|
|
291
|
-
line-height: inherit !important;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
/* Header colors for semantic headers */
|
|
295
|
-
.overtype-wrapper .overtype-preview h1 {
|
|
296
|
-
color: var(--h1, #f95738) !important;
|
|
297
|
-
}
|
|
298
|
-
.overtype-wrapper .overtype-preview h2 {
|
|
299
|
-
color: var(--h2, #ee964b) !important;
|
|
300
|
-
}
|
|
301
|
-
.overtype-wrapper .overtype-preview h3 {
|
|
302
|
-
color: var(--h3, #3d8a51) !important;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/* Lists - remove styling in edit mode */
|
|
306
|
-
.overtype-wrapper .overtype-preview ul,
|
|
307
|
-
.overtype-wrapper .overtype-preview ol {
|
|
308
|
-
list-style: none !important;
|
|
309
|
-
margin: 0 !important;
|
|
310
|
-
padding: 0 !important;
|
|
311
|
-
display: block !important; /* Lists need to be block for line breaks */
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
.overtype-wrapper .overtype-preview li {
|
|
315
|
-
display: block !important; /* Each item on its own line */
|
|
316
|
-
margin: 0 !important;
|
|
317
|
-
padding: 0 !important;
|
|
318
|
-
/* Don't set list-style here - let ul/ol control it */
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
/* Bold text */
|
|
322
|
-
.overtype-wrapper .overtype-preview strong {
|
|
323
|
-
color: var(--strong, #ee964b) !important;
|
|
324
|
-
font-weight: bold !important;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/* Italic text */
|
|
328
|
-
.overtype-wrapper .overtype-preview em {
|
|
329
|
-
color: var(--em, #f95738) !important;
|
|
330
|
-
text-decoration-color: var(--em, #f95738) !important;
|
|
331
|
-
text-decoration-thickness: 1px !important;
|
|
332
|
-
font-style: italic !important;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
/* Strikethrough text */
|
|
336
|
-
.overtype-wrapper .overtype-preview del {
|
|
337
|
-
color: var(--del, #ee964b) !important;
|
|
338
|
-
text-decoration: line-through !important;
|
|
339
|
-
text-decoration-color: var(--del, #ee964b) !important;
|
|
340
|
-
text-decoration-thickness: 1px !important;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
/* Inline code */
|
|
344
|
-
.overtype-wrapper .overtype-preview code {
|
|
345
|
-
background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;
|
|
346
|
-
color: var(--code, #0d3b66) !important;
|
|
347
|
-
padding: 0 !important;
|
|
348
|
-
border-radius: 2px !important;
|
|
349
|
-
font-family: inherit !important;
|
|
350
|
-
font-size: inherit !important;
|
|
351
|
-
line-height: inherit !important;
|
|
352
|
-
font-weight: normal !important;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
/* Code blocks - consolidated pre blocks */
|
|
356
|
-
.overtype-wrapper .overtype-preview pre {
|
|
357
|
-
padding: 0 !important;
|
|
358
|
-
margin: 0 !important;
|
|
359
|
-
border-radius: 4px !important;
|
|
360
|
-
overflow-x: auto !important;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
/* Code block styling in normal mode - yellow background */
|
|
364
|
-
.overtype-wrapper .overtype-preview pre.code-block {
|
|
365
|
-
background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;
|
|
366
|
-
white-space: break-spaces !important; /* Prevent horizontal scrollbar that breaks alignment */
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
/* Code inside pre blocks - remove background */
|
|
370
|
-
.overtype-wrapper .overtype-preview pre code {
|
|
371
|
-
background: transparent !important;
|
|
372
|
-
color: var(--code, #0d3b66) !important;
|
|
373
|
-
font-family: var(--instance-font-family, ${i}) !important; /* Match textarea font exactly for alignment */
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/* Blockquotes */
|
|
377
|
-
.overtype-wrapper .overtype-preview .blockquote {
|
|
378
|
-
color: var(--blockquote, #5a7a9b) !important;
|
|
379
|
-
padding: 0 !important;
|
|
380
|
-
margin: 0 !important;
|
|
381
|
-
border: none !important;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/* Links */
|
|
385
|
-
.overtype-wrapper .overtype-preview a {
|
|
386
|
-
color: var(--link, #0d3b66) !important;
|
|
387
|
-
text-decoration: underline !important;
|
|
388
|
-
font-weight: normal !important;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
.overtype-wrapper .overtype-preview a:hover {
|
|
392
|
-
text-decoration: underline !important;
|
|
393
|
-
color: var(--link, #0d3b66) !important;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
/* Lists - no list styling */
|
|
397
|
-
.overtype-wrapper .overtype-preview ul,
|
|
398
|
-
.overtype-wrapper .overtype-preview ol {
|
|
399
|
-
list-style: none !important;
|
|
400
|
-
margin: 0 !important;
|
|
401
|
-
padding: 0 !important;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
/* Horizontal rules */
|
|
406
|
-
.overtype-wrapper .overtype-preview hr {
|
|
407
|
-
border: none !important;
|
|
408
|
-
color: var(--hr, #5a7a9b) !important;
|
|
409
|
-
margin: 0 !important;
|
|
410
|
-
padding: 0 !important;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
.overtype-wrapper .overtype-preview .hr-marker {
|
|
414
|
-
color: var(--hr, #5a7a9b) !important;
|
|
415
|
-
opacity: 0.6 !important;
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/* Code fence markers - with background when not in code block */
|
|
419
|
-
.overtype-wrapper .overtype-preview .code-fence {
|
|
420
|
-
color: var(--code, #0d3b66) !important;
|
|
421
|
-
background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
/* Code block lines - background for entire code block */
|
|
425
|
-
.overtype-wrapper .overtype-preview .code-block-line {
|
|
426
|
-
background: var(--code-bg, rgba(244, 211, 94, 0.4)) !important;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
/* Remove background from code fence when inside code block line */
|
|
430
|
-
.overtype-wrapper .overtype-preview .code-block-line .code-fence {
|
|
431
|
-
background: transparent !important;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/* Raw markdown line */
|
|
435
|
-
.overtype-wrapper .overtype-preview .raw-line {
|
|
436
|
-
color: var(--raw-line, #5a7a9b) !important;
|
|
437
|
-
font-style: normal !important;
|
|
438
|
-
font-weight: normal !important;
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
/* Syntax markers */
|
|
442
|
-
.overtype-wrapper .overtype-preview .syntax-marker {
|
|
443
|
-
color: var(--syntax-marker, rgba(13, 59, 102, 0.52)) !important;
|
|
444
|
-
opacity: 0.7 !important;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
/* List markers */
|
|
448
|
-
.overtype-wrapper .overtype-preview .list-marker {
|
|
449
|
-
color: var(--list-marker, #ee964b) !important;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
/* Stats bar */
|
|
453
|
-
|
|
454
|
-
/* Stats bar - positioned by flexbox */
|
|
455
|
-
.overtype-stats {
|
|
456
|
-
height: 40px !important;
|
|
457
|
-
padding: 0 20px !important;
|
|
458
|
-
background: var(--bg-secondary, #f8f9fa) !important;
|
|
459
|
-
border-top: 1px solid var(--border, #e0e0e0) !important;
|
|
460
|
-
display: flex !important;
|
|
461
|
-
justify-content: space-between !important;
|
|
462
|
-
align-items: center !important;
|
|
463
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
|
|
464
|
-
font-size: 0.85rem !important;
|
|
465
|
-
color: var(--text-secondary, #666) !important;
|
|
466
|
-
flex-shrink: 0 !important; /* Don't shrink */
|
|
467
|
-
z-index: 10001 !important; /* Above link tooltip */
|
|
468
|
-
position: relative !important; /* Enable z-index */
|
|
469
|
-
}
|
|
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.overtype-toolbar-hidden {
|
|
495
|
-
display: none !important;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
.overtype-toolbar {
|
|
499
|
-
display: flex !important;
|
|
500
|
-
align-items: center !important;
|
|
501
|
-
gap: 4px !important;
|
|
502
|
-
padding: 8px !important; /* Override reset */
|
|
503
|
-
background: var(--toolbar-bg, var(--bg-primary, #f8f9fa)) !important; /* Override reset */
|
|
504
|
-
border-bottom: 1px solid var(--toolbar-border, transparent) !important; /* Override reset */
|
|
505
|
-
overflow-x: auto !important; /* Allow horizontal scrolling */
|
|
506
|
-
overflow-y: hidden !important; /* Hide vertical overflow */
|
|
507
|
-
-webkit-overflow-scrolling: touch !important;
|
|
508
|
-
flex-shrink: 0 !important;
|
|
509
|
-
height: auto !important;
|
|
510
|
-
position: relative !important; /* Override reset */
|
|
511
|
-
z-index: 100 !important; /* Ensure toolbar is above wrapper */
|
|
512
|
-
scrollbar-width: thin; /* Thin scrollbar on Firefox */
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/* Thin scrollbar styling */
|
|
516
|
-
.overtype-toolbar::-webkit-scrollbar {
|
|
517
|
-
height: 4px;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
.overtype-toolbar::-webkit-scrollbar-track {
|
|
521
|
-
background: transparent;
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
.overtype-toolbar::-webkit-scrollbar-thumb {
|
|
525
|
-
background: rgba(0, 0, 0, 0.2);
|
|
526
|
-
border-radius: 2px;
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
.overtype-toolbar-button {
|
|
530
|
-
display: flex;
|
|
531
|
-
align-items: center;
|
|
532
|
-
justify-content: center;
|
|
533
|
-
width: 32px;
|
|
534
|
-
height: 32px;
|
|
535
|
-
padding: 0;
|
|
536
|
-
border: none;
|
|
537
|
-
border-radius: 6px;
|
|
538
|
-
background: transparent;
|
|
539
|
-
color: var(--toolbar-icon, var(--text-secondary, #666));
|
|
540
|
-
cursor: pointer;
|
|
541
|
-
transition: all 0.2s ease;
|
|
542
|
-
flex-shrink: 0;
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
.overtype-toolbar-button svg {
|
|
546
|
-
width: 20px;
|
|
547
|
-
height: 20px;
|
|
548
|
-
fill: currentColor;
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
.overtype-toolbar-button:hover {
|
|
552
|
-
background: var(--toolbar-hover, var(--bg-secondary, #e9ecef));
|
|
553
|
-
color: var(--toolbar-icon, var(--text-primary, #333));
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
.overtype-toolbar-button:active {
|
|
557
|
-
transform: scale(0.95);
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
.overtype-toolbar-button.active {
|
|
561
|
-
background: var(--toolbar-active, var(--primary, #007bff));
|
|
562
|
-
color: var(--toolbar-icon, var(--text-primary, #333));
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
.overtype-toolbar-button:disabled {
|
|
566
|
-
opacity: 0.5;
|
|
567
|
-
cursor: not-allowed;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
.overtype-toolbar-separator {
|
|
571
|
-
width: 1px;
|
|
572
|
-
height: 24px;
|
|
573
|
-
background: var(--border, #e0e0e0);
|
|
574
|
-
margin: 0 4px;
|
|
575
|
-
flex-shrink: 0;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
/* Adjust wrapper when toolbar is present */
|
|
579
|
-
/* Mobile toolbar adjustments */
|
|
580
|
-
@media (max-width: 640px) {
|
|
581
|
-
.overtype-toolbar {
|
|
582
|
-
padding: 6px;
|
|
583
|
-
gap: 2px;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
.overtype-toolbar-button {
|
|
587
|
-
width: 36px;
|
|
588
|
-
height: 36px;
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
.overtype-toolbar-separator {
|
|
592
|
-
margin: 0 2px;
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
/* Plain mode - hide preview and show textarea text */
|
|
597
|
-
.overtype-container[data-mode="plain"] .overtype-preview {
|
|
598
|
-
display: none !important;
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
.overtype-container[data-mode="plain"] .overtype-input {
|
|
602
|
-
color: var(--text, #0d3b66) !important;
|
|
603
|
-
/* Use system font stack for better plain text readability */
|
|
604
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
605
|
-
"Helvetica Neue", Arial, sans-serif !important;
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
/* Ensure textarea remains transparent in overlay mode */
|
|
609
|
-
.overtype-container:not([data-mode="plain"]) .overtype-input {
|
|
610
|
-
color: transparent !important;
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
/* Dropdown menu styles */
|
|
614
|
-
.overtype-toolbar-button {
|
|
615
|
-
position: relative !important; /* Override reset - needed for dropdown */
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
.overtype-toolbar-button.dropdown-active {
|
|
619
|
-
background: var(--toolbar-active, var(--hover-bg, #f0f0f0));
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
.overtype-dropdown-menu {
|
|
623
|
-
position: fixed !important; /* Fixed positioning relative to viewport */
|
|
624
|
-
background: var(--bg-secondary, white) !important; /* Override reset */
|
|
625
|
-
border: 1px solid var(--border, #e0e0e0) !important; /* Override reset */
|
|
626
|
-
border-radius: 6px;
|
|
627
|
-
box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important; /* Override reset */
|
|
628
|
-
z-index: 10000; /* Very high z-index to ensure visibility */
|
|
629
|
-
min-width: 150px;
|
|
630
|
-
padding: 4px 0 !important; /* Override reset */
|
|
631
|
-
/* Position will be set via JavaScript based on button position */
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
.overtype-dropdown-item {
|
|
635
|
-
display: flex;
|
|
636
|
-
align-items: center;
|
|
637
|
-
width: 100%;
|
|
638
|
-
padding: 8px 12px;
|
|
639
|
-
border: none;
|
|
640
|
-
background: none;
|
|
641
|
-
text-align: left;
|
|
642
|
-
cursor: pointer;
|
|
643
|
-
font-size: 14px;
|
|
644
|
-
color: var(--text, #333);
|
|
645
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
.overtype-dropdown-item:hover {
|
|
649
|
-
background: var(--hover-bg, #f0f0f0);
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
.overtype-dropdown-item.active {
|
|
653
|
-
font-weight: 600;
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
.overtype-dropdown-check {
|
|
657
|
-
width: 16px;
|
|
658
|
-
margin-right: 8px;
|
|
659
|
-
color: var(--h1, #007bff);
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
.overtype-dropdown-icon {
|
|
663
|
-
width: 20px;
|
|
664
|
-
margin-right: 8px;
|
|
665
|
-
text-align: center;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
/* Preview mode styles */
|
|
669
|
-
.overtype-container[data-mode="preview"] .overtype-input {
|
|
670
|
-
display: none !important;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
.overtype-container[data-mode="preview"] .overtype-preview {
|
|
674
|
-
pointer-events: auto !important;
|
|
675
|
-
user-select: text !important;
|
|
676
|
-
cursor: text !important;
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
.overtype-container.overtype-auto-resize[data-mode="preview"] .overtype-preview {
|
|
680
|
-
position: static !important;
|
|
681
|
-
height: auto !important;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
/* Hide syntax markers in preview mode */
|
|
685
|
-
.overtype-container[data-mode="preview"] .syntax-marker {
|
|
686
|
-
display: none !important;
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
/* Hide URL part of links in preview mode - extra specificity */
|
|
690
|
-
.overtype-container[data-mode="preview"] .syntax-marker.url-part,
|
|
691
|
-
.overtype-container[data-mode="preview"] .url-part {
|
|
692
|
-
display: none !important;
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
/* Hide all syntax markers inside links too */
|
|
696
|
-
.overtype-container[data-mode="preview"] a .syntax-marker {
|
|
697
|
-
display: none !important;
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
/* Headers - restore proper sizing in preview mode */
|
|
701
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1,
|
|
702
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2,
|
|
703
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 {
|
|
704
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
|
|
705
|
-
font-weight: 600 !important;
|
|
706
|
-
margin: 0 !important;
|
|
707
|
-
display: block !important;
|
|
708
|
-
line-height: 1 !important;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1 {
|
|
712
|
-
font-size: 2em !important;
|
|
713
|
-
color: var(--preview-h1, var(--preview-h1-default)) !important;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2 {
|
|
717
|
-
font-size: 1.5em !important;
|
|
718
|
-
color: var(--preview-h2, var(--preview-h2-default)) !important;
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3 {
|
|
722
|
-
font-size: 1.17em !important;
|
|
723
|
-
color: var(--preview-h3, var(--preview-h3-default)) !important;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
/* Lists - restore list styling in preview mode */
|
|
727
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview ul {
|
|
728
|
-
display: block !important;
|
|
729
|
-
list-style: disc !important;
|
|
730
|
-
padding-left: 2em !important;
|
|
731
|
-
margin: 1em 0 !important;
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview ol {
|
|
735
|
-
display: block !important;
|
|
736
|
-
list-style: decimal !important;
|
|
737
|
-
padding-left: 2em !important;
|
|
738
|
-
margin: 1em 0 !important;
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li {
|
|
742
|
-
display: list-item !important;
|
|
743
|
-
margin: 0 !important;
|
|
744
|
-
padding: 0 !important;
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
/* Task list checkboxes - only in preview mode */
|
|
748
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li.task-list {
|
|
749
|
-
list-style: none !important;
|
|
750
|
-
position: relative !important;
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li.task-list input[type="checkbox"] {
|
|
754
|
-
margin-right: 0.5em !important;
|
|
755
|
-
cursor: default !important;
|
|
756
|
-
vertical-align: middle !important;
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
/* Task list in normal mode - keep syntax visible */
|
|
760
|
-
.overtype-container:not([data-mode="preview"]) .overtype-wrapper .overtype-preview li.task-list {
|
|
761
|
-
list-style: none !important;
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
.overtype-container:not([data-mode="preview"]) .overtype-wrapper .overtype-preview li.task-list .syntax-marker {
|
|
765
|
-
color: var(--syntax, #999999) !important;
|
|
766
|
-
font-weight: normal !important;
|
|
767
|
-
}
|
|
768
|
-
|
|
769
|
-
/* Links - make clickable in preview mode */
|
|
770
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview a {
|
|
771
|
-
pointer-events: auto !important;
|
|
772
|
-
cursor: pointer !important;
|
|
773
|
-
color: var(--preview-link, var(--preview-link-default)) !important;
|
|
774
|
-
text-decoration: underline !important;
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
/* Code blocks - proper pre/code styling in preview mode */
|
|
778
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block {
|
|
779
|
-
background: var(--preview-code-bg, var(--preview-code-bg-default)) !important;
|
|
780
|
-
color: var(--preview-code, var(--preview-code-default)) !important;
|
|
781
|
-
padding: 1.2em !important;
|
|
782
|
-
border-radius: 3px !important;
|
|
783
|
-
overflow-x: auto !important;
|
|
784
|
-
margin: 0 !important;
|
|
785
|
-
display: block !important;
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block code {
|
|
789
|
-
background: transparent !important;
|
|
790
|
-
color: inherit !important;
|
|
791
|
-
padding: 0 !important;
|
|
792
|
-
font-family: ${i} !important;
|
|
793
|
-
font-size: 0.9em !important;
|
|
794
|
-
line-height: 1.4 !important;
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
/* Hide old code block lines and fences in preview mode */
|
|
798
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .code-block-line {
|
|
799
|
-
display: none !important;
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .code-fence {
|
|
803
|
-
display: none !important;
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
/* Blockquotes - enhanced styling in preview mode */
|
|
807
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .blockquote {
|
|
808
|
-
display: block !important;
|
|
809
|
-
border-left: 4px solid var(--preview-blockquote, var(--preview-blockquote-default)) !important;
|
|
810
|
-
color: var(--preview-blockquote, var(--preview-blockquote-default)) !important;
|
|
811
|
-
padding-left: 1em !important;
|
|
812
|
-
margin: 1em 0 !important;
|
|
813
|
-
font-style: italic !important;
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
/* Typography improvements in preview mode */
|
|
817
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview {
|
|
818
|
-
font-family: Georgia, 'Times New Roman', serif !important;
|
|
819
|
-
font-size: 16px !important;
|
|
820
|
-
line-height: 1.8 !important;
|
|
821
|
-
color: var(--preview-text, var(--preview-text-default)) !important;
|
|
822
|
-
background: var(--preview-bg, var(--preview-bg-default)) !important;
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
/* Inline code in preview mode - keep monospace */
|
|
826
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview code {
|
|
827
|
-
font-family: ${i} !important;
|
|
828
|
-
font-size: 0.9em !important;
|
|
829
|
-
background: var(--preview-code-bg, var(--preview-code-bg-default)) !important;
|
|
830
|
-
color: var(--preview-code, var(--preview-code-default)) !important;
|
|
831
|
-
padding: 0.2em 0.4em !important;
|
|
832
|
-
border-radius: 3px !important;
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
/* Strong and em elements in preview mode */
|
|
836
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview strong {
|
|
837
|
-
font-weight: 700 !important;
|
|
838
|
-
color: var(--preview-strong, var(--preview-strong-default)) !important;
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview em {
|
|
842
|
-
font-style: italic !important;
|
|
843
|
-
color: var(--preview-em, var(--preview-em-default)) !important;
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
/* HR in preview mode */
|
|
847
|
-
.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .hr-marker {
|
|
848
|
-
display: block !important;
|
|
849
|
-
border-top: 2px solid var(--preview-hr, var(--preview-hr-default)) !important;
|
|
850
|
-
text-indent: -9999px !important;
|
|
851
|
-
height: 2px !important;
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
/* Link Tooltip */
|
|
855
|
-
.overtype-link-tooltip {
|
|
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: flex !important;
|
|
863
|
-
visibility: hidden !important;
|
|
864
|
-
pointer-events: none !important;
|
|
865
|
-
z-index: 10000 !important;
|
|
866
|
-
cursor: pointer !important;
|
|
867
|
-
box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;
|
|
868
|
-
max-width: 300px !important;
|
|
869
|
-
white-space: nowrap !important;
|
|
870
|
-
overflow: hidden !important;
|
|
871
|
-
text-overflow: ellipsis !important;
|
|
872
|
-
position: fixed;
|
|
873
|
-
top: 0;
|
|
874
|
-
left: 0;
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
.overtype-link-tooltip.visible {
|
|
878
|
-
visibility: visible !important;
|
|
879
|
-
pointer-events: auto !important;
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
${a}
|
|
883
|
-
`}var gn=Object.defineProperty,Qe=Object.getOwnPropertySymbols,vn=Object.prototype.hasOwnProperty,yn=Object.prototype.propertyIsEnumerable,Ge=(t,e,n)=>e in t?gn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Je=(t,e)=>{for(var n in e||(e={}))vn.call(e,n)&&Ge(t,n,e[n]);if(Qe)for(var n of Qe(e))yn.call(e,n)&&Ge(t,n,e[n]);return t},I={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 wn(){return{prefix:"",suffix:"",blockPrefix:"",blockSuffix:"",multiline:!1,replaceNext:"",prefixSpace:!1,scanFor:"",surroundWithNewlines:!1,orderedList:!1,unorderedList:!1,trimFirst:!1}}function F(t){return Je(Je({},wn()),t)}var we=!1;function bn(){return we}function x(t,e,n){we&&(console.group(`\u{1F50D} ${t}`),console.log(e),n&&console.log("Data:",n),console.groupEnd())}function ye(t,e){if(!we)return;let n=t.value.slice(t.selectionStart,t.selectionEnd);console.group(`\u{1F4CD} Selection: ${e}`),console.log("Position:",`${t.selectionStart}-${t.selectionEnd}`),console.log("Selected text:",JSON.stringify(n)),console.log("Length:",n.length);let i=t.value.slice(Math.max(0,t.selectionStart-10),t.selectionStart),o=t.value.slice(t.selectionEnd,Math.min(t.value.length,t.selectionEnd+10));console.log("Context:",JSON.stringify(i)+"[SELECTION]"+JSON.stringify(o)),console.groupEnd()}function tt(t){we&&(console.group("\u{1F4DD} Result"),console.log("Text to insert:",JSON.stringify(t.text)),console.log("New selection:",`${t.selectionStart}-${t.selectionEnd}`),console.groupEnd())}var B=null;function U(t,{text:e,selectionStart:n,selectionEnd:i}){let o=bn();o&&(console.group("\u{1F527} insertText"),console.log("Current selection:",`${t.selectionStart}-${t.selectionEnd}`),console.log("Text to insert:",JSON.stringify(e)),console.log("New selection to set:",n,"-",i)),t.focus();let r=t.selectionStart,s=t.selectionEnd,a=t.value.slice(0,r),l=t.value.slice(s);o&&(console.log("Before text (last 20):",JSON.stringify(a.slice(-20))),console.log("After text (first 20):",JSON.stringify(l.slice(0,20))),console.log("Selected text being replaced:",JSON.stringify(t.value.slice(r,s))));let p=t.value,c=r!==s;if(B===null||B===!0){t.contentEditable="true";try{B=document.execCommand("insertText",!1,e),o&&console.log("execCommand returned:",B,"for text with",e.split(`
|
|
884
|
-
`).length,"lines")}catch(d){B=!1,o&&console.log("execCommand threw error:",d)}t.contentEditable="false"}if(o&&(console.log("canInsertText before:",B),console.log("execCommand result:",B)),B){let d=a+e+l,h=t.value;o&&(console.log("Expected length:",d.length),console.log("Actual length:",h.length)),h!==d&&o&&(console.log("execCommand changed the value but not as expected"),console.log("Expected:",JSON.stringify(d.slice(0,100))),console.log("Actual:",JSON.stringify(h.slice(0,100))))}if(!B)if(o&&console.log("Using manual insertion"),t.value===p){o&&console.log("Value unchanged, doing manual replacement");try{document.execCommand("ms-beginUndoUnit")}catch(d){}t.value=a+e+l;try{document.execCommand("ms-endUndoUnit")}catch(d){}t.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:",n,i),n!=null&&i!=null?t.setSelectionRange(n,i):t.setSelectionRange(r,t.selectionEnd),o&&(console.log("Final value length:",t.value.length),console.groupEnd())}function Xe(t){return t.trim().split(`
|
|
885
|
-
`).length>1}function xn(t,e){let n=e;for(;t[n]&&t[n-1]!=null&&!t[n-1].match(/\s/);)n--;return n}function kn(t,e,n){let i=e,o=n?/\n/:/\s/;for(;t[i]&&!t[i].match(o);)i++;return i}function nt(t){let e=t.value.split(`
|
|
886
|
-
`),n=0;for(let i=0;i<e.length;i++){let o=e[i].length+1;t.selectionStart>=n&&t.selectionStart<n+o&&(t.selectionStart=n),t.selectionEnd>=n&&t.selectionEnd<n+o&&(i===e.length-1?t.selectionEnd=Math.min(n+e[i].length,t.value.length):t.selectionEnd=n+o-1),n+=o}}function Ln(t,e,n,i=!1){if(t.selectionStart===t.selectionEnd)t.selectionStart=xn(t.value,t.selectionStart),t.selectionEnd=kn(t.value,t.selectionEnd,i);else{let o=t.selectionStart-e.length,r=t.selectionEnd+n.length,s=t.value.slice(o,t.selectionStart)===e,a=t.value.slice(t.selectionEnd,r)===n;s&&a&&(t.selectionStart=o,t.selectionEnd=r)}return t.value.slice(t.selectionStart,t.selectionEnd)}function $e(t){let e=t.value.slice(0,t.selectionStart),n=t.value.slice(t.selectionEnd),i=e.match(/\n*$/),o=n.match(/^\n*/),r=i?i[0].length:0,s=o?o[0].length:0,a="",l="";return e.match(/\S/)&&r<2&&(a=`
|
|
41
|
+
padding: var(--instance-padding, ${i}) !important;box-sizing: border-box !important;color: var(--placeholder,#999) !important}.overtype-wrapper .overtype-preview{z-index: 0 !important;pointer-events: none !important;color: var(--text,#0d3b66) !important;background-color: transparent !important;user-select: none !important;-webkit-user-select: none !important;-moz-user-select: none !important;-ms-user-select: none !important}.overtype-wrapper .overtype-preview *{font-family: inherit !important;font-size: inherit !important;line-height: inherit !important}.overtype-wrapper .overtype-preview div{margin: 0 !important;padding: 0 !important;border: none !important;text-align: left !important;text-indent: 0 !important;display: block !important;position: static !important;transform: none !important;min-height: 0 !important;max-height: none !important;line-height: inherit !important;font-size: inherit !important;font-family: inherit !important}.overtype-wrapper .overtype-preview .header{font-weight: bold !important}.overtype-wrapper .overtype-preview .h1{color: var(--h1,#f95738) !important}.overtype-wrapper .overtype-preview .h2{color: var(--h2,#ee964b) !important}.overtype-wrapper .overtype-preview .h3{color: var(--h3,#3d8a51) !important}.overtype-wrapper .overtype-preview h1,.overtype-wrapper .overtype-preview h2,.overtype-wrapper .overtype-preview h3{font-size: inherit !important;font-weight: bold !important;margin: 0 !important;padding: 0 !important;display: inline !important;line-height: inherit !important}.overtype-wrapper .overtype-preview h1{color: var(--h1,#f95738) !important}.overtype-wrapper .overtype-preview h2{color: var(--h2,#ee964b) !important}.overtype-wrapper .overtype-preview h3{color: var(--h3,#3d8a51) !important}.overtype-wrapper .overtype-preview ul,.overtype-wrapper .overtype-preview ol{list-style: none !important;margin: 0 !important;padding: 0 !important;display: block !important}.overtype-wrapper .overtype-preview li{display: block !important;margin: 0 !important;padding: 0 !important}.overtype-wrapper .overtype-preview strong{color: var(--strong,#ee964b) !important;font-weight: bold !important}.overtype-wrapper .overtype-preview em{color: var(--em,#f95738) !important;text-decoration-color: var(--em,#f95738) !important;text-decoration-thickness: 1px !important;font-style: italic !important}.overtype-wrapper .overtype-preview del{color: var(--del,#ee964b) !important;text-decoration: line-through !important;text-decoration-color: var(--del,#ee964b) !important;text-decoration-thickness: 1px !important}.overtype-wrapper .overtype-preview code{background: var(--code-bg,rgba(244,211,94,0.4)) !important;color: var(--code,#0d3b66) !important;padding: 0 !important;border-radius: 2px !important;font-family: inherit !important;font-size: inherit !important;line-height: inherit !important;font-weight: normal !important}.overtype-wrapper .overtype-preview pre{padding: 0 !important;margin: 0 !important;border-radius: 4px !important;overflow-x: auto !important}.overtype-wrapper .overtype-preview pre.code-block{background: var(--code-bg,rgba(244,211,94,0.4)) !important;white-space: break-spaces !important}.overtype-wrapper .overtype-preview pre code{background: transparent !important;color: var(--code,#0d3b66) !important;font-family: var(--instance-font-family,${o}) !important}.overtype-wrapper .overtype-preview .blockquote{color: var(--blockquote,#5a7a9b) !important;padding: 0 !important;margin: 0 !important;border: none !important}.overtype-wrapper .overtype-preview a{color: var(--link,#0d3b66) !important;text-decoration: underline !important;font-weight: normal !important}.overtype-wrapper .overtype-preview a:hover{text-decoration: underline !important;color: var(--link,#0d3b66) !important}.overtype-wrapper .overtype-preview ul,.overtype-wrapper .overtype-preview ol{list-style: none !important;margin: 0 !important;padding: 0 !important}.overtype-wrapper .overtype-preview hr{border: none !important;color: var(--hr,#5a7a9b) !important;margin: 0 !important;padding: 0 !important}.overtype-wrapper .overtype-preview .hr-marker{color: var(--hr,#5a7a9b) !important;opacity: 0.6 !important}.overtype-wrapper .overtype-preview .code-fence{color: var(--code,#0d3b66) !important;background: var(--code-bg,rgba(244,211,94,0.4)) !important}.overtype-wrapper .overtype-preview .code-block-line{background: var(--code-bg,rgba(244,211,94,0.4)) !important}.overtype-wrapper .overtype-preview .code-block-line .code-fence{background: transparent !important}.overtype-wrapper .overtype-preview .raw-line{color: var(--raw-line,#5a7a9b) !important;font-style: normal !important;font-weight: normal !important}.overtype-wrapper .overtype-preview .syntax-marker{color: var(--syntax-marker,rgba(13,59,102,0.52)) !important;opacity: 0.7 !important}.overtype-wrapper .overtype-preview .list-marker{color: var(--list-marker,#ee964b) !important}.overtype-stats{height: 40px !important;padding: 0 20px !important;background: var(--bg-secondary,#f8f9fa) !important;border-top: 1px solid var(--border,#e0e0e0) !important;display: flex !important;justify-content: space-between !important;align-items: center !important;font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif !important;font-size: 0.85rem !important;color: var(--text-secondary,#666) !important;flex-shrink: 0 !important;z-index: 10001 !important;position: relative !important}.overtype-stats .overtype-stat{display: flex !important;align-items: center !important;gap: 5px !important;white-space: nowrap !important}.overtype-stats .live-dot{width: 8px !important;height: 8px !important;background: #4caf50 !important;border-radius: 50% !important;animation: overtype-pulse 2s infinite !important}@keyframes overtype-pulse{0%,100%{opacity: 1;transform: scale(1)}50%{opacity: 0.6;transform: scale(1.2)}}.overtype-toolbar.overtype-toolbar-hidden{display: none !important}.overtype-toolbar{display: flex !important;align-items: center !important;gap: 4px !important;padding: 8px !important;background: var(--toolbar-bg,var(--bg-primary,#f8f9fa)) !important;border-bottom: 1px solid var(--toolbar-border,transparent) !important;overflow-x: auto !important;overflow-y: hidden !important;-webkit-overflow-scrolling: touch !important;flex-shrink: 0 !important;height: auto !important;position: relative !important;z-index: 100 !important;scrollbar-width: thin}.overtype-toolbar::-webkit-scrollbar{height: 4px}.overtype-toolbar::-webkit-scrollbar-track{background: transparent}.overtype-toolbar::-webkit-scrollbar-thumb{background: rgba(0,0,0,0.2);border-radius: 2px}.overtype-toolbar-button{display: flex;align-items: center;justify-content: center;width: 32px;height: 32px;padding: 0;border: none;border-radius: 6px;background: transparent;color: var(--toolbar-icon,var(--text-secondary,#666));cursor: pointer;transition: all 0.2s ease;flex-shrink: 0}.overtype-toolbar-button svg{width: 20px;height: 20px;fill: currentColor}.overtype-toolbar-button:hover{background: var(--toolbar-hover,var(--bg-secondary,#e9ecef));color: var(--toolbar-icon,var(--text-primary,#333))}.overtype-toolbar-button:active{transform: scale(0.95)}.overtype-toolbar-button.active{background: var(--toolbar-active,var(--primary,#007bff));color: var(--toolbar-icon,var(--text-primary,#333))}.overtype-toolbar-button:disabled{opacity: 0.5;cursor: not-allowed}.overtype-toolbar-separator{width: 1px;height: 24px;background: var(--border,#e0e0e0);margin: 0 4px;flex-shrink: 0}@media (max-width: 640px){.overtype-toolbar{padding: 6px;gap: 2px}.overtype-toolbar-button{width: 36px;height: 36px}.overtype-toolbar-separator{margin: 0 2px}}.overtype-container[data-mode="plain"] .overtype-preview{display: none !important}.overtype-container[data-mode="plain"] .overtype-input{color: var(--text,#0d3b66) !important;font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif !important}.overtype-container:not([data-mode="plain"]) .overtype-input{color: transparent !important}.overtype-toolbar-button{position: relative !important}.overtype-toolbar-button.dropdown-active{background: var(--toolbar-active,var(--hover-bg,#f0f0f0))}.overtype-dropdown-menu{position: fixed !important;background: var(--bg-secondary,white) !important;border: 1px solid var(--border,#e0e0e0) !important;border-radius: 6px;box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;z-index: 10000;min-width: 150px;padding: 4px 0 !important}.overtype-dropdown-item{display: flex;align-items: center;width: 100%;padding: 8px 12px;border: none;background: none;text-align: left;cursor: pointer;font-size: 14px;color: var(--text,#333);font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif}.overtype-dropdown-item:hover{background: var(--hover-bg,#f0f0f0)}.overtype-dropdown-item.active{font-weight: 600}.overtype-dropdown-check{width: 16px;margin-right: 8px;color: var(--h1,#007bff)}.overtype-dropdown-icon{width: 20px;margin-right: 8px;text-align: center}.overtype-container[data-mode="preview"] .overtype-input{display: none !important}.overtype-container[data-mode="preview"] .overtype-preview{pointer-events: auto !important;user-select: text !important;cursor: text !important}.overtype-container.overtype-auto-resize[data-mode="preview"] .overtype-preview{position: static !important;height: auto !important}.overtype-container[data-mode="preview"] .syntax-marker{display: none !important}.overtype-container[data-mode="preview"] .syntax-marker.url-part,.overtype-container[data-mode="preview"] .url-part{display: none !important}.overtype-container[data-mode="preview"] a .syntax-marker{display: none !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1,.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2,.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3{font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif !important;font-weight: 600 !important;margin: 0 !important;display: block !important;line-height: 1 !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h1{font-size: 2em !important;color: var(--preview-h1,var(--preview-h1-default)) !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h2{font-size: 1.5em !important;color: var(--preview-h2,var(--preview-h2-default)) !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview h3{font-size: 1.17em !important;color: var(--preview-h3,var(--preview-h3-default)) !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview ul{display: block !important;list-style: disc !important;padding-left: 2em !important;margin: 1em 0 !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview ol{display: block !important;list-style: decimal !important;padding-left: 2em !important;margin: 1em 0 !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li{display: list-item !important;margin: 0 !important;padding: 0 !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li.task-list{list-style: none !important;position: relative !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview li.task-list input[type="checkbox"]{margin-right: 0.5em !important;cursor: default !important;vertical-align: middle !important}.overtype-container:not([data-mode="preview"]) .overtype-wrapper .overtype-preview li.task-list{list-style: none !important}.overtype-container:not([data-mode="preview"]) .overtype-wrapper .overtype-preview li.task-list .syntax-marker{color: var(--syntax,#999999) !important;font-weight: normal !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview a{pointer-events: auto !important;cursor: pointer !important;color: var(--preview-link,var(--preview-link-default)) !important;text-decoration: underline !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block{background: var(--preview-code-bg,var(--preview-code-bg-default)) !important;color: var(--preview-code,var(--preview-code-default)) !important;padding: 1.2em !important;border-radius: 3px !important;overflow-x: auto !important;margin: 0 !important;display: block !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview pre.code-block code{background: transparent !important;color: inherit !important;padding: 0 !important;font-family:${o}!important;font-size: 0.9em !important;line-height: 1.4 !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .code-block-line{display: none !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .code-fence{display: none !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .blockquote{display: block !important;border-left: 4px solid var(--preview-blockquote,var(--preview-blockquote-default)) !important;color: var(--preview-blockquote,var(--preview-blockquote-default)) !important;padding-left: 1em !important;margin: 1em 0 !important;font-style: italic !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview{font-family: Georgia,'Times New Roman',serif !important;font-size: 16px !important;line-height: 1.8 !important;color: var(--preview-text,var(--preview-text-default)) !important;background: var(--preview-bg,var(--preview-bg-default)) !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview code{font-family:${o}!important;font-size: 0.9em !important;background: var(--preview-code-bg,var(--preview-code-bg-default)) !important;color: var(--preview-code,var(--preview-code-default)) !important;padding: 0.2em 0.4em !important;border-radius: 3px !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview strong{font-weight: 700 !important;color: var(--preview-strong,var(--preview-strong-default)) !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview em{font-style: italic !important;color: var(--preview-em,var(--preview-em-default)) !important}.overtype-container[data-mode="preview"] .overtype-wrapper .overtype-preview .hr-marker{display: block !important;border-top: 2px solid var(--preview-hr,var(--preview-hr-default)) !important;text-indent: -9999px !important;height: 2px !important}.overtype-link-tooltip{background: #333 !important;color: white !important;padding: 6px 10px !important;border-radius: 16px !important;font-size: 12px !important;font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif !important;display: flex !important;visibility: hidden !important;pointer-events: none !important;z-index: 10000 !important;cursor: pointer !important;box-shadow: 0 2px 8px rgba(0,0,0,0.3) !important;max-width: 300px !important;white-space: nowrap !important;overflow: hidden !important;text-overflow: ellipsis !important;position: fixed;top: 0;left: 0}.overtype-link-tooltip.visible{visibility: visible !important;pointer-events: auto !important}${a}
|
|
42
|
+
`}var ne={};st(ne,{applyCustomFormat:()=>Et,default:()=>In,expandSelection:()=>St,getActiveFormats:()=>Ie,getDebugMode:()=>Ze,hasFormat:()=>Lt,insertHeader:()=>de,insertLink:()=>Ae,preserveSelection:()=>bt,setDebugMode:()=>gt,setUndoMethod:()=>yt,toggleBold:()=>Ee,toggleBulletList:()=>Me,toggleCode:()=>Te,toggleH1:()=>Pe,toggleH2:()=>Oe,toggleH3:()=>_e,toggleItalic:()=>Ce,toggleNumberedList:()=>$e,toggleQuote:()=>He,toggleTaskList:()=>pe});var Sn=Object.defineProperty,dt=Object.getOwnPropertySymbols,En=Object.prototype.hasOwnProperty,Cn=Object.prototype.propertyIsEnumerable,ut=(t,e,n)=>e in t?Sn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,ht=(t,e)=>{for(var n in e||(e={}))En.call(e,n)&&ut(t,n,e[n]);if(dt)for(var n of dt(e))Cn.call(e,n)&&ut(t,n,e[n]);return t},I={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 Tn(){return{prefix:"",suffix:"",blockPrefix:"",blockSuffix:"",multiline:!1,replaceNext:"",prefixSpace:!1,scanFor:"",surroundWithNewlines:!1,orderedList:!1,unorderedList:!1,trimFirst:!1}}function R(t){return ht(ht({},Tn()),t)}var ce=!1;function gt(t){ce=t}function Ze(){return ce}function x(t,e,n){ce&&(console.group(`\u{1F50D} ${t}`),console.log(e),n&&console.log("Data:",n),console.groupEnd())}function Le(t,e){if(!ce)return;let n=t.value.slice(t.selectionStart,t.selectionEnd);console.group(`\u{1F4CD} Selection: ${e}`),console.log("Position:",`${t.selectionStart}-${t.selectionEnd}`),console.log("Selected text:",JSON.stringify(n)),console.log("Length:",n.length);let o=t.value.slice(Math.max(0,t.selectionStart-10),t.selectionStart),i=t.value.slice(t.selectionEnd,Math.min(t.value.length,t.selectionEnd+10));console.log("Context:",JSON.stringify(o)+"[SELECTION]"+JSON.stringify(i)),console.groupEnd()}function vt(t){ce&&(console.group("\u{1F4DD} Result"),console.log("Text to insert:",JSON.stringify(t.text)),console.log("New selection:",`${t.selectionStart}-${t.selectionEnd}`),console.groupEnd())}var M=null;function N(t,{text:e,selectionStart:n,selectionEnd:o}){let i=Ze();i&&(console.group("\u{1F527} insertText"),console.log("Current selection:",`${t.selectionStart}-${t.selectionEnd}`),console.log("Text to insert:",JSON.stringify(e)),console.log("New selection to set:",n,"-",o)),t.focus();let r=t.selectionStart,s=t.selectionEnd,a=t.value.slice(0,r),l=t.value.slice(s);i&&(console.log("Before text (last 20):",JSON.stringify(a.slice(-20))),console.log("After text (first 20):",JSON.stringify(l.slice(0,20))),console.log("Selected text being replaced:",JSON.stringify(t.value.slice(r,s))));let p=t.value,c=r!==s;if(M===null||M===!0){t.contentEditable="true";try{M=document.execCommand("insertText",!1,e),i&&console.log("execCommand returned:",M,"for text with",e.split(`
|
|
43
|
+
`).length,"lines")}catch(d){M=!1,i&&console.log("execCommand threw error:",d)}t.contentEditable="false"}if(i&&(console.log("canInsertText before:",M),console.log("execCommand result:",M)),M){let d=a+e+l,u=t.value;i&&(console.log("Expected length:",d.length),console.log("Actual length:",u.length)),u!==d&&i&&(console.log("execCommand changed the value but not as expected"),console.log("Expected:",JSON.stringify(d.slice(0,100))),console.log("Actual:",JSON.stringify(u.slice(0,100))))}if(!M)if(i&&console.log("Using manual insertion"),t.value===p){i&&console.log("Value unchanged, doing manual replacement");try{document.execCommand("ms-beginUndoUnit")}catch(d){}t.value=a+e+l;try{document.execCommand("ms-endUndoUnit")}catch(d){}t.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0}))}else i&&console.log("Value was changed by execCommand, skipping manual insertion");i&&console.log("Setting selection range:",n,o),n!=null&&o!=null?t.setSelectionRange(n,o):t.setSelectionRange(r,t.selectionEnd),i&&(console.log("Final value length:",t.value.length),console.groupEnd())}function yt(t){switch(t){case"native":M=!0;break;case"manual":M=!1;break;case"auto":M=null;break}}function Ke(t){return t.trim().split(`
|
|
44
|
+
`).length>1}function An(t,e){let n=e;for(;t[n]&&t[n-1]!=null&&!t[n-1].match(/\s/);)n--;return n}function Mn(t,e,n){let o=e,i=n?/\n/:/\s/;for(;t[o]&&!t[o].match(i);)o++;return o}function wt(t){let e=t.value.split(`
|
|
45
|
+
`),n=0;for(let o=0;o<e.length;o++){let i=e[o].length+1;t.selectionStart>=n&&t.selectionStart<n+i&&(t.selectionStart=n),t.selectionEnd>=n&&t.selectionEnd<n+i&&(o===e.length-1?t.selectionEnd=Math.min(n+e[o].length,t.value.length):t.selectionEnd=n+i-1),n+=i}}function $n(t,e,n,o=!1){if(t.selectionStart===t.selectionEnd)t.selectionStart=An(t.value,t.selectionStart),t.selectionEnd=Mn(t.value,t.selectionEnd,o);else{let i=t.selectionStart-e.length,r=t.selectionEnd+n.length,s=t.value.slice(i,t.selectionStart)===e,a=t.value.slice(t.selectionEnd,r)===n;s&&a&&(t.selectionStart=i,t.selectionEnd=r)}return t.value.slice(t.selectionStart,t.selectionEnd)}function Qe(t){let e=t.value.slice(0,t.selectionStart),n=t.value.slice(t.selectionEnd),o=e.match(/\n*$/),i=n.match(/^\n*/),r=o?o[0].length:0,s=i?i[0].length:0,a="",l="";return e.match(/\S/)&&r<2&&(a=`
|
|
887
46
|
`.repeat(2-r)),n.match(/\S/)&&s<2&&(l=`
|
|
888
|
-
`.repeat(2-s)),{newlinesToAppend:a,newlinesToPrepend:l}}function
|
|
889
|
-
`;)a--;if(r){let p=
|
|
890
|
-
`;)p++;t.selectionStart=a,t.selectionEnd=p}else
|
|
891
|
-
`:
|
|
892
|
-
${a}`:r;if(p){let k=t.value[t.selectionStart-1];t.selectionStart!==0&&k!=null&&!k.match(/\s/)&&(g=` ${g}`)}m
|
|
893
|
-
`);if(l.every(c=>c.startsWith(n)&&(!
|
|
894
|
-
`),a=s+r.length;else if(r=l.map(c=>n+c+(
|
|
895
|
-
`),
|
|
896
|
-
`),n=/^\d+\.\s+/,
|
|
897
|
-
`),processed:
|
|
898
|
-
`),n="- ",
|
|
899
|
-
`),processed:
|
|
900
|
-
`).map((m,g)=>`${
|
|
901
|
-
`)+
|
|
902
|
-
`),s=0,a="";for(let d of r){if(n>=s&&n<=s+d.length){a=d;break}s+=d.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 l=Math.max(0,n-10),p=Math.min(
|
|
47
|
+
`.repeat(2-s)),{newlinesToAppend:a,newlinesToPrepend:l}}function bt(t,e){let n=t.selectionStart,o=t.selectionEnd,i=t.scrollTop;e(),t.selectionStart=n,t.selectionEnd=o,t.scrollTop=i}function Se(t,e,n={}){let o=t.selectionStart,i=t.selectionEnd,r=o===i,s=t.value,a=o;for(;a>0&&s[a-1]!==`
|
|
48
|
+
`;)a--;if(r){let p=o;for(;p<s.length&&s[p]!==`
|
|
49
|
+
`;)p++;t.selectionStart=a,t.selectionEnd=p}else wt(t);let l=e(t);if(n.adjustSelection){let c=t.value.slice(t.selectionStart,t.selectionEnd).startsWith(n.prefix),d=n.adjustSelection(c,o,i,a);l.selectionStart=d.start,l.selectionEnd=d.end}else if(n.prefix){let c=t.value.slice(t.selectionStart,t.selectionEnd).startsWith(n.prefix);r?c?(l.selectionStart=Math.max(o-n.prefix.length,a),l.selectionEnd=l.selectionStart):(l.selectionStart=o+n.prefix.length,l.selectionEnd=l.selectionStart):c?(l.selectionStart=Math.max(o-n.prefix.length,a),l.selectionEnd=Math.max(i-n.prefix.length,a)):(l.selectionStart=o+n.prefix.length,l.selectionEnd=i+n.prefix.length)}return l}function te(t,e){let n,o,{prefix:i,suffix:r,blockPrefix:s,blockSuffix:a,replaceNext:l,prefixSpace:p,scanFor:c,surroundWithNewlines:d,trimFirst:u}=e,h=t.selectionStart,f=t.selectionEnd,m=t.value.slice(t.selectionStart,t.selectionEnd),g=Ke(m)&&s&&s.length>0?`${s}
|
|
50
|
+
`:i,y=Ke(m)&&a&&a.length>0?`
|
|
51
|
+
${a}`:r;if(p){let k=t.value[t.selectionStart-1];t.selectionStart!==0&&k!=null&&!k.match(/\s/)&&(g=` ${g}`)}m=$n(t,g,y,e.multiline);let w=t.selectionStart,b=t.selectionEnd,L=l&&l.length>0&&y.indexOf(l)>-1&&m.length>0;if(d){let k=Qe(t);n=k.newlinesToAppend,o=k.newlinesToPrepend,g=n+i,y+=o}if(m.startsWith(g)&&m.endsWith(y)){let k=m.slice(g.length,m.length-y.length);if(h===f){let E=h-g.length;E=Math.max(E,w),E=Math.min(E,w+k.length),w=b=E}else b=w+k.length;return{text:k,selectionStart:w,selectionEnd:b}}else if(L)if(c&&c.length>0&&m.match(c)){y=y.replace(l,m);let k=g+y;return w=b=w+g.length,{text:k,selectionStart:w,selectionEnd:b}}else{let k=g+m+y;return w=w+g.length+m.length+y.indexOf(l),b=w+l.length,{text:k,selectionStart:w,selectionEnd:b}}else{let k=g+m+y;w=h+g.length,b=f+g.length;let E=m.match(/^\s*|\s*$/g);if(u&&E){let be=E[0]||"",Y=E[1]||"";k=be+g+m.trim()+y+Y,w+=be.length,b-=Y.length}return{text:k,selectionStart:w,selectionEnd:b}}}function Je(t,e){let{prefix:n,suffix:o,surroundWithNewlines:i}=e,r=t.value.slice(t.selectionStart,t.selectionEnd),s=t.selectionStart,a=t.selectionEnd,l=r.split(`
|
|
52
|
+
`);if(l.every(c=>c.startsWith(n)&&(!o||c.endsWith(o))))r=l.map(c=>{let d=c.slice(n.length);return o&&(d=d.slice(0,d.length-o.length)),d}).join(`
|
|
53
|
+
`),a=s+r.length;else if(r=l.map(c=>n+c+(o||"")).join(`
|
|
54
|
+
`),i){let{newlinesToAppend:c,newlinesToPrepend:d}=Qe(t);s+=c.length,a=s+r.length,r=c+r+d}return{text:r,selectionStart:s,selectionEnd:a}}function ft(t){let e=t.split(`
|
|
55
|
+
`),n=/^\d+\.\s+/,o=e.every(r=>n.test(r)),i=e;return o&&(i=e.map(r=>r.replace(n,""))),{text:i.join(`
|
|
56
|
+
`),processed:o}}function mt(t){let e=t.split(`
|
|
57
|
+
`),n="- ",o=e.every(r=>r.startsWith(n)),i=e;return o&&(i=e.map(r=>r.slice(n.length))),{text:i.join(`
|
|
58
|
+
`),processed:o}}function le(t,e){return e?"- ":`${t+1}. `}function Hn(t,e){let n,o,i;return t.orderedList?(n=ft(e),o=mt(n.text),i=o.text):(n=mt(e),o=ft(n.text),i=o.text),[n,o,i]}function Pn(t,e){let n=t.selectionStart===t.selectionEnd,o=t.selectionStart,i=t.selectionEnd;wt(t);let r=t.value.slice(t.selectionStart,t.selectionEnd),[s,a,l]=Hn(e,r),p=l.split(`
|
|
59
|
+
`).map((m,g)=>`${le(g,e.unorderedList)}${m}`),c=p.reduce((m,g,y)=>m+le(y,e.unorderedList).length,0),d=p.reduce((m,g,y)=>m+le(y,!e.unorderedList).length,0);if(s.processed)return n?(o=Math.max(o-le(0,e.unorderedList).length,0),i=o):(o=t.selectionStart,i=t.selectionEnd-c),{text:l,selectionStart:o,selectionEnd:i};let{newlinesToAppend:u,newlinesToPrepend:h}=Qe(t),f=u+p.join(`
|
|
60
|
+
`)+h;return n?(o=Math.max(o+le(0,e.unorderedList).length+u.length,0),i=o):a.processed?(o=Math.max(t.selectionStart+u.length,0),i=t.selectionEnd+u.length+c-d):(o=Math.max(t.selectionStart+u.length,0),i=t.selectionEnd+u.length+c),{text:f,selectionStart:o,selectionEnd:i}}function xt(t,e){let n=Se(t,o=>Pn(o,e),{adjustSelection:(o,i,r,s)=>{let a=t.value.slice(s,t.selectionEnd),l=/^\d+\.\s+/,p=/^- /,c=l.test(a),d=p.test(a),u=e.orderedList&&c||e.unorderedList&&d;if(i===r)if(u){let h=a.match(e.orderedList?l:p),f=h?h[0].length:0;return{start:Math.max(i-f,s),end:Math.max(i-f,s)}}else if(c||d){let h=a.match(c?l:p),f=h?h[0].length:0,g=(e.unorderedList?2:3)-f;return{start:i+g,end:i+g}}else{let h=e.unorderedList?2:3;return{start:i+h,end:i+h}}else if(u){let h=a.match(e.orderedList?l:p),f=h?h[0].length:0;return{start:Math.max(i-f,s),end:Math.max(r-f,s)}}else if(c||d){let h=a.match(c?l:p),f=h?h[0].length:0,g=(e.unorderedList?2:3)-f;return{start:i+g,end:r+g}}else{let h=e.unorderedList?2:3;return{start:i+h,end:r+h}}}});N(t,n)}function kt(t){if(!t)return[];let e=[],{selectionStart:n,selectionEnd:o,value:i}=t,r=i.split(`
|
|
61
|
+
`),s=0,a="";for(let d of r){if(n>=s&&n<=s+d.length){a=d;break}s+=d.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 l=Math.max(0,n-10),p=Math.min(i.length,o+10),c=i.slice(l,p);if(c.includes("**")){let d=i.slice(Math.max(0,n-100),n),u=i.slice(o,Math.min(i.length,o+100)),h=d.lastIndexOf("**"),f=u.indexOf("**");h!==-1&&f!==-1&&e.push("bold")}if(c.includes("_")){let d=i.slice(Math.max(0,n-100),n),u=i.slice(o,Math.min(i.length,o+100)),h=d.lastIndexOf("_"),f=u.indexOf("_");h!==-1&&f!==-1&&e.push("italic")}if(c.includes("`")){let d=i.slice(Math.max(0,n-100),n),u=i.slice(o,Math.min(i.length,o+100));d.includes("`")&&u.includes("`")&&e.push("code")}if(c.includes("[")&&c.includes("]")){let d=i.slice(Math.max(0,n-100),n),u=i.slice(o,Math.min(i.length,o+100)),h=d.lastIndexOf("["),f=u.indexOf("]");h!==-1&&f!==-1&&i.slice(o+f+1,o+f+10).startsWith("(")&&e.push("link")}return e}function On(t,e){return kt(t).includes(e)}function _n(t,e={}){if(!t)return;let{toWord:n,toLine:o,toFormat:i}=e,{selectionStart:r,selectionEnd:s,value:a}=t;if(o){let l=a.split(`
|
|
62
|
+
`),p=0,c=0,d=0;for(let u of l){if(r>=d&&r<=d+u.length){p=d,c=d+u.length;break}d+=u.length+1}t.selectionStart=p,t.selectionEnd=c}else if(n&&r===s){let l=r,p=s;for(;l>0&&!/\s/.test(a[l-1]);)l--;for(;p<a.length&&!/\s/.test(a[p]);)p++;t.selectionStart=l,t.selectionEnd=p}}function Ee(t){if(!t||t.disabled||t.readOnly)return;x("toggleBold","Starting"),Le(t,"Before");let e=R(I.bold),n=te(t,e);vt(n),N(t,n),Le(t,"After")}function Ce(t){if(!t||t.disabled||t.readOnly)return;let e=R(I.italic),n=te(t,e);N(t,n)}function Te(t){if(!t||t.disabled||t.readOnly)return;let e=R(I.code),n=te(t,e);N(t,n)}function Ae(t,e={}){if(!t||t.disabled||t.readOnly)return;let n=t.value.slice(t.selectionStart,t.selectionEnd),o=R(I.link);if(n&&n.match(/^https?:\/\//)&&!e.url?(o.suffix=`](${n})`,o.replaceNext=""):e.url&&(o.suffix=`](${e.url})`,o.replaceNext=""),e.text&&!n){let s=t.selectionStart;t.value=t.value.slice(0,s)+e.text+t.value.slice(s),t.selectionStart=s,t.selectionEnd=s+e.text.length}let r=te(t,o);N(t,r)}function Me(t){if(!t||t.disabled||t.readOnly)return;let e=R(I.bulletList);xt(t,e)}function $e(t){if(!t||t.disabled||t.readOnly)return;let e=R(I.numberedList);xt(t,e)}function He(t){if(!t||t.disabled||t.readOnly)return;x("toggleQuote","Starting"),Le(t,"Initial");let e=R(I.quote),n=Se(t,o=>Je(o,e),{prefix:e.prefix});vt(n),N(t,n),Le(t,"Final")}function pe(t){if(!t||t.disabled||t.readOnly)return;let e=R(I.taskList),n=Se(t,o=>Je(o,e),{prefix:e.prefix});N(t,n)}function de(t,e=1,n=!1){if(!t||t.disabled||t.readOnly)return;(e<1||e>6)&&(e=1),x("insertHeader","============ START ============"),x("insertHeader",`Level: ${e}, Toggle: ${n}`),x("insertHeader",`Initial cursor: ${t.selectionStart}-${t.selectionEnd}`);let o=`header${e===1?"1":e}`,i=R(I[o]||I.header1);x("insertHeader",`Style prefix: "${i.prefix}"`);let r=t.value,s=t.selectionStart,a=t.selectionEnd,l=s;for(;l>0&&r[l-1]!==`
|
|
903
63
|
`;)l--;let p=a;for(;p<r.length&&r[p]!==`
|
|
904
|
-
`;)p++;let c=r.slice(l,p);x("insertHeader",`Current line (before): "${c}"`);let d=c.match(/^(#{1,6})\s*/),h=d?d[1].length:0,u=d?d[0].length:0;x("insertHeader","Existing header check:"),x("insertHeader",` - Match: ${d?`"${d[0]}"`:"none"}`),x("insertHeader",` - Existing level: ${h}`),x("insertHeader",` - Existing prefix length: ${u}`),x("insertHeader",` - Target level: ${e}`);let f=n&&h===e;x("insertHeader",`Should toggle OFF: ${f} (toggle=${n}, existingLevel=${h}, level=${e})`);let m=be(t,g=>{let y=g.value.slice(g.selectionStart,g.selectionEnd);x("insertHeader",`Line in operation: "${y}"`);let w=y.replace(/^#{1,6}\s*/,"");x("insertHeader",`Cleaned line: "${w}"`);let b;return f?(x("insertHeader","ACTION: Toggling OFF - removing header"),b=w):h>0?(x("insertHeader",`ACTION: Replacing H${h} with H${e}`),b=o.prefix+w):(x("insertHeader","ACTION: Adding new header"),b=o.prefix+w),x("insertHeader",`New line: "${b}"`),{text:b,selectionStart:g.selectionStart,selectionEnd:g.selectionEnd}},{prefix:o.prefix,adjustSelection:(g,y,w,b)=>{if(x("insertHeader","Adjusting selection:"),x("insertHeader",` - isRemoving param: ${g}`),x("insertHeader",` - shouldToggleOff: ${f}`),x("insertHeader",` - selStart: ${y}, selEnd: ${w}`),x("insertHeader",` - lineStartPos: ${b}`),f){let L=Math.max(y-u,b);return x("insertHeader",` - Removing header, adjusting by -${u}`),{start:L,end:y===w?L:Math.max(w-u,b)}}else if(u>0){let L=o.prefix.length-u;return x("insertHeader",` - Replacing header, adjusting by ${L}`),{start:y+L,end:w+L}}else return x("insertHeader",` - Adding header, adjusting by +${o.prefix.length}`),{start:y+o.prefix.length,end:w+o.prefix.length}}});x("insertHeader",`Final result: text="${m.text}", cursor=${m.selectionStart}-${m.selectionEnd}`),x("insertHeader","============ END ============"),U(t,m)}function ut(t){_e(t,1,!0)}function ht(t){_e(t,2,!0)}function ft(t){_e(t,3,!0)}function mt(t){return Cn(t)}var ke=class{constructor(e,n={}){this.editor=e,this.container=null,this.buttons={},this.toolbarButtons=n.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 n=this.createSeparator();this.container.appendChild(n)}else{let n=this.createButton(e);this.buttons[e.name]=n,this.container.appendChild(n)}}),this.editor.container.insertBefore(this.container,this.editor.wrapper)}createSeparator(){let e=document.createElement("div");return e.className="overtype-toolbar-separator",e.setAttribute("role","separator"),e}createButton(e){let n=document.createElement("button");return n.className="overtype-toolbar-button",n.type="button",n.setAttribute("data-button",e.name),n.title=e.title||"",n.setAttribute("aria-label",e.title||e.name),n.innerHTML=this.sanitizeSVG(e.icon||""),e.name==="viewMode"?(n.classList.add("has-dropdown"),n.dataset.dropdown="true",n.addEventListener("click",i=>{i.preventDefault(),this.toggleViewModeDropdown(n)}),n):(n._clickHandler=i=>{i.preventDefault();let o=e.actionId||e.name;this.editor.performAction(o,i)},n.addEventListener("click",n._clickHandler),n)}async handleAction(e){if(e&&typeof e=="object"&&typeof e.action=="function"){this.editor.textarea.focus();try{return await e.action({editor:this.editor,getValue:()=>this.editor.getValue(),setValue:n=>this.editor.setValue(n),event:null}),!0}catch(n){return console.error(`Action "${e.name}" error:`,n),this.editor.wrapper.dispatchEvent(new CustomEvent("button-error",{detail:{buttonName:e.name,error:n}})),!1}}return typeof e=="string"?this.editor.performAction(e,null):!1}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 n=document.querySelector(".overtype-dropdown-menu");if(n){n.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 n=document.createElement("div");n.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}n.remove(),e.classList.remove("dropdown-active"),document.removeEventListener("click",this.handleDocumentClick)}),n.appendChild(s)}),n}updateButtonStates(){var e;try{let n=((e=mt)==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=n.includes("bold");break;case"italic":r=n.includes("italic");break;case"code":r=!1;break;case"bulletList":r=n.includes("bullet-list");break;case"orderedList":r=n.includes("numbered-list");break;case"taskList":r=n.includes("task-list");break;case"quote":r=n.includes("quote");break;case"h1":r=n.includes("header");break;case"h2":r=n.includes("header-2");break;case"h3":r=n.includes("header-3");break}o.classList.toggle("active",r),o.setAttribute("aria-pressed",r.toString())})}catch(n){}}show(){this.container&&this.container.classList.remove("overtype-toolbar-hidden")}hide(){this.container&&this.container.classList.add("overtype-toolbar-hidden")}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 le=Math.min,q=Math.max,ce=Math.round;var O=t=>({x:t,y:t}),Tn={left:"right",right:"left",bottom:"top",top:"bottom"},An={start:"end",end:"start"};function Re(t,e,n){return q(t,le(e,n))}function pe(t,e){return typeof t=="function"?t(e):t}function W(t){return t.split("-")[0]}function de(t){return t.split("-")[1]}function Be(t){return t==="x"?"y":"x"}function Fe(t){return t==="y"?"height":"width"}var Mn=new Set(["top","bottom"]);function N(t){return Mn.has(W(t))?"y":"x"}function Ne(t){return Be(N(t))}function wt(t,e,n){n===void 0&&(n=!1);let i=de(t),o=Ne(t),r=Fe(o),s=o==="x"?i===(n?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=ae(s)),[s,ae(s)]}function bt(t){let e=ae(t);return[Le(t),e,Le(e)]}function Le(t){return t.replace(/start|end/g,e=>An[e])}var vt=["left","right"],yt=["right","left"],Hn=["top","bottom"],Pn=["bottom","top"];function On(t,e,n){switch(t){case"top":case"bottom":return n?e?yt:vt:e?vt:yt;case"left":case"right":return e?Hn:Pn;default:return[]}}function xt(t,e,n,i){let o=de(t),r=On(W(t),n==="start",i);return o&&(r=r.map(s=>s+"-"+o),e&&(r=r.concat(r.map(Le)))),r}function ae(t){return t.replace(/left|right|bottom|top/g,e=>Tn[e])}function $n(t){return{top:0,right:0,bottom:0,left:0,...t}}function kt(t){return typeof t!="number"?$n(t):{top:t,right:t,bottom:t,left:t}}function G(t){let{x:e,y:n,width:i,height:o}=t;return{width:i,height:o,top:n,left:e,right:e+i,bottom:n+o,x:e,y:n}}function Lt(t,e,n){let{reference:i,floating:o}=t,r=N(e),s=Ne(e),a=Fe(s),l=W(e),p=r==="y",c=i.x+i.width/2-o.width/2,d=i.y+i.height/2-o.height/2,h=i[a]/2-o[a]/2,u;switch(l){case"top":u={x:c,y:i.y-o.height};break;case"bottom":u={x:c,y:i.y+i.height};break;case"right":u={x:i.x+i.width,y:d};break;case"left":u={x:i.x-o.width,y:d};break;default:u={x:i.x,y:i.y}}switch(de(e)){case"start":u[s]-=h*(n&&p?-1:1);break;case"end":u[s]+=h*(n&&p?-1:1);break}return u}async function St(t,e){var n;e===void 0&&(e={});let{x:i,y:o,platform:r,rects:s,elements:a,strategy:l}=t,{boundary:p="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:h=!1,padding:u=0}=pe(e,t),f=kt(u),g=a[h?d==="floating"?"reference":"floating":d],y=G(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(g)))==null||n?g:g.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(a.floating)),boundary:p,rootBoundary:c,strategy:l})),w=d==="floating"?{x:i,y:o,width:s.floating.width,height:s.floating.height}:s.reference,b=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a.floating)),L=await(r.isElement==null?void 0:r.isElement(b))?await(r.getScale==null?void 0:r.getScale(b))||{x:1,y:1}:{x:1,y:1},k=G(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:b,strategy:l}):w);return{top:(y.top-k.top+f.top)/L.y,bottom:(k.bottom-y.bottom+f.bottom)/L.y,left:(y.left-k.left+f.left)/L.x,right:(k.right-y.right+f.right)/L.x}}var Et=async(t,e,n)=>{let{placement:i="bottom",strategy:o="absolute",middleware:r=[],platform:s}=n,a=r.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(e)),p=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:c,y:d}=Lt(p,i,l),h=i,u={},f=0;for(let g=0;g<a.length;g++){var m;let{name:y,fn:w}=a[g],{x:b,y:L,data:k,reset:E}=await w({x:c,y:d,initialPlacement:i,placement:h,strategy:o,middlewareData:u,rects:p,platform:{...s,detectOverflow:(m=s.detectOverflow)!=null?m:St},elements:{reference:t,floating:e}});c=b!=null?b:c,d=L!=null?L:d,u={...u,[y]:{...u[y],...k}},E&&f<=50&&(f++,typeof E=="object"&&(E.placement&&(h=E.placement),E.rects&&(p=E.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:o}):E.rects),{x:c,y:d}=Lt(p,h,l)),g=-1)}return{x:c,y:d,placement:h,strategy:o,middlewareData:u}};var Ct=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,i;let{placement:o,middlewareData:r,rects:s,initialPlacement:a,platform:l,elements:p}=e,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:m=!0,...g}=pe(t,e);if((n=r.arrow)!=null&&n.alignmentOffset)return{};let y=W(o),w=N(a),b=W(a)===a,L=await(l.isRTL==null?void 0:l.isRTL(p.floating)),k=h||(b||!m?[ae(a)]:bt(a)),E=f!=="none";!h&&E&&k.push(...xt(a,m,f,L));let me=[a,...k],Y=await l.detectOverflow(e,g),ge=[],ee=((i=r.flip)==null?void 0:i.overflows)||[];if(c&&ge.push(Y[y]),d){let K=wt(o,s,L);ge.push(Y[K[0]],Y[K[1]])}if(ee=[...ee,{placement:o,overflows:ge}],!ge.every(K=>K<=0)){var je,Ve;let K=(((je=r.flip)==null?void 0:je.index)||0)+1,Pe=me[K];if(Pe&&(!(d==="alignment"?w!==N(Pe):!1)||ee.every(P=>N(P.placement)===w?P.overflows[0]>0:!0)))return{data:{index:K,overflows:ee},reset:{placement:Pe}};let oe=(Ve=ee.filter(Z=>Z.overflows[0]<=0).sort((Z,P)=>Z.overflows[1]-P.overflows[1])[0])==null?void 0:Ve.placement;if(!oe)switch(u){case"bestFit":{var Ue;let Z=(Ue=ee.filter(P=>{if(E){let j=N(P.placement);return j===w||j==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(j=>j>0).reduce((j,ln)=>j+ln,0)]).sort((P,j)=>P[1]-j[1])[0])==null?void 0:Ue[0];Z&&(oe=Z);break}case"initialPlacement":oe=a;break}if(o!==oe)return{reset:{placement:oe}}}return{}}}};var In=new Set(["left","top"]);async function _n(t,e){let{placement:n,platform:i,elements:o}=t,r=await(i.isRTL==null?void 0:i.isRTL(o.floating)),s=W(n),a=de(n),l=N(n)==="y",p=In.has(s)?-1:1,c=r&&l?-1:1,d=pe(e,t),{mainAxis:h,crossAxis:u,alignmentAxis:f}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof f=="number"&&(u=a==="end"?f*-1:f),l?{x:u*c,y:h*p}:{x:h*p,y:u*c}}var Tt=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,i;let{x:o,y:r,placement:s,middlewareData:a}=e,l=await _n(e,t);return s===((n=a.offset)==null?void 0:n.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:o+l.x,y:r+l.y,data:{...l,placement:s}}}}},At=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:i,placement:o,platform:r}=e,{mainAxis:s=!0,crossAxis:a=!1,limiter:l={fn:y=>{let{x:w,y:b}=y;return{x:w,y:b}}},...p}=pe(t,e),c={x:n,y:i},d=await r.detectOverflow(e,p),h=N(W(o)),u=Be(h),f=c[u],m=c[h];if(s){let y=u==="y"?"top":"left",w=u==="y"?"bottom":"right",b=f+d[y],L=f-d[w];f=Re(b,f,L)}if(a){let y=h==="y"?"top":"left",w=h==="y"?"bottom":"right",b=m+d[y],L=m-d[w];m=Re(b,m,L)}let g=l.fn({...e,[u]:f,[h]:m});return{...g,data:{x:g.x-n,y:g.y-i,enabled:{[u]:s,[h]:a}}}}}};function Ee(){return typeof window<"u"}function J(t){return Ht(t)?(t.nodeName||"").toLowerCase():"#document"}function A(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function _(t){var e;return(e=(Ht(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Ht(t){return Ee()?t instanceof Node||t instanceof A(t).Node:!1}function M(t){return Ee()?t instanceof Element||t instanceof A(t).Element:!1}function $(t){return Ee()?t instanceof HTMLElement||t instanceof A(t).HTMLElement:!1}function Mt(t){return!Ee()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof A(t).ShadowRoot}var Rn=new Set(["inline","contents"]);function te(t){let{overflow:e,overflowX:n,overflowY:i,display:o}=H(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&!Rn.has(o)}var Bn=new Set(["table","td","th"]);function Pt(t){return Bn.has(J(t))}var Fn=[":popover-open",":modal"];function ue(t){return Fn.some(e=>{try{return t.matches(e)}catch(n){return!1}})}var Nn=["transform","translate","scale","rotate","perspective"],Dn=["transform","translate","scale","rotate","perspective","filter"],zn=["paint","layout","strict","content"];function Ce(t){let e=Te(),n=M(t)?H(t):t;return Nn.some(i=>n[i]?n[i]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||Dn.some(i=>(n.willChange||"").includes(i))||zn.some(i=>(n.contain||"").includes(i))}function Ot(t){let e=D(t);for(;$(e)&&!X(e);){if(Ce(e))return e;if(ue(e))return null;e=D(e)}return null}function Te(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var jn=new Set(["html","body","#document"]);function X(t){return jn.has(J(t))}function H(t){return A(t).getComputedStyle(t)}function he(t){return M(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function D(t){if(J(t)==="html")return t;let e=t.assignedSlot||t.parentNode||Mt(t)&&t.host||_(t);return Mt(e)?e.host:e}function $t(t){let e=D(t);return X(e)?t.ownerDocument?t.ownerDocument.body:t.body:$(e)&&te(e)?e:$t(e)}function Se(t,e,n){var i;e===void 0&&(e=[]),n===void 0&&(n=!0);let o=$t(t),r=o===((i=t.ownerDocument)==null?void 0:i.body),s=A(o);if(r){let a=Ae(s);return e.concat(s,s.visualViewport||[],te(o)?o:[],a&&n?Se(a):[])}return e.concat(o,Se(o,[],n))}function Ae(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Bt(t){let e=H(t),n=parseFloat(e.width)||0,i=parseFloat(e.height)||0,o=$(t),r=o?t.offsetWidth:n,s=o?t.offsetHeight:i,a=ce(n)!==r||ce(i)!==s;return a&&(n=r,i=s),{width:n,height:i,$:a}}function Ft(t){return M(t)?t:t.contextElement}function ne(t){let e=Ft(t);if(!$(e))return O(1);let n=e.getBoundingClientRect(),{width:i,height:o,$:r}=Bt(e),s=(r?ce(n.width):n.width)/i,a=(r?ce(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var Vn=O(0);function Nt(t){let e=A(t);return!Te()||!e.visualViewport?Vn:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Un(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==A(t)?!1:e}function fe(t,e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1);let o=t.getBoundingClientRect(),r=Ft(t),s=O(1);e&&(i?M(i)&&(s=ne(i)):s=ne(t));let a=Un(r,n,i)?Nt(r):O(0),l=(o.left+a.x)/s.x,p=(o.top+a.y)/s.y,c=o.width/s.x,d=o.height/s.y;if(r){let h=A(r),u=i&&M(i)?A(i):i,f=h,m=Ae(f);for(;m&&i&&u!==f;){let g=ne(m),y=m.getBoundingClientRect(),w=H(m),b=y.left+(m.clientLeft+parseFloat(w.paddingLeft))*g.x,L=y.top+(m.clientTop+parseFloat(w.paddingTop))*g.y;l*=g.x,p*=g.y,c*=g.x,d*=g.y,l+=b,p+=L,f=A(m),m=Ae(f)}}return G({width:c,height:d,x:l,y:p})}function Me(t,e){let n=he(t).scrollLeft;return e?e.left+n:fe(_(t)).left+n}function Dt(t,e){let n=t.getBoundingClientRect(),i=n.left+e.scrollLeft-Me(t,n),o=n.top+e.scrollTop;return{x:i,y:o}}function qn(t){let{elements:e,rect:n,offsetParent:i,strategy:o}=t,r=o==="fixed",s=_(i),a=e?ue(e.floating):!1;if(i===s||a&&r)return n;let l={scrollLeft:0,scrollTop:0},p=O(1),c=O(0),d=$(i);if((d||!d&&!r)&&((J(i)!=="body"||te(s))&&(l=he(i)),$(i))){let u=fe(i);p=ne(i),c.x=u.x+i.clientLeft,c.y=u.y+i.clientTop}let h=s&&!d&&!r?Dt(s,l):O(0);return{width:n.width*p.x,height:n.height*p.y,x:n.x*p.x-l.scrollLeft*p.x+c.x+h.x,y:n.y*p.y-l.scrollTop*p.y+c.y+h.y}}function Wn(t){return Array.from(t.getClientRects())}function Kn(t){let e=_(t),n=he(t),i=t.ownerDocument.body,o=q(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),r=q(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight),s=-n.scrollLeft+Me(t),a=-n.scrollTop;return H(i).direction==="rtl"&&(s+=q(e.clientWidth,i.clientWidth)-o),{width:o,height:r,x:s,y:a}}var It=25;function Zn(t,e){let n=A(t),i=_(t),o=n.visualViewport,r=i.clientWidth,s=i.clientHeight,a=0,l=0;if(o){r=o.width,s=o.height;let c=Te();(!c||c&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}let p=Me(i);if(p<=0){let c=i.ownerDocument,d=c.body,h=getComputedStyle(d),u=c.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,f=Math.abs(i.clientWidth-d.clientWidth-u);f<=It&&(r-=f)}else p<=It&&(r+=p);return{width:r,height:s,x:a,y:l}}var Qn=new Set(["absolute","fixed"]);function Gn(t,e){let n=fe(t,!0,e==="fixed"),i=n.top+t.clientTop,o=n.left+t.clientLeft,r=$(t)?ne(t):O(1),s=t.clientWidth*r.x,a=t.clientHeight*r.y,l=o*r.x,p=i*r.y;return{width:s,height:a,x:l,y:p}}function _t(t,e,n){let i;if(e==="viewport")i=Zn(t,n);else if(e==="document")i=Kn(_(t));else if(M(e))i=Gn(e,n);else{let o=Nt(t);i={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return G(i)}function zt(t,e){let n=D(t);return n===e||!M(n)||X(n)?!1:H(n).position==="fixed"||zt(n,e)}function Jn(t,e){let n=e.get(t);if(n)return n;let i=Se(t,[],!1).filter(a=>M(a)&&J(a)!=="body"),o=null,r=H(t).position==="fixed",s=r?D(t):t;for(;M(s)&&!X(s);){let a=H(s),l=Ce(s);!l&&a.position==="fixed"&&(o=null),(r?!l&&!o:!l&&a.position==="static"&&!!o&&Qn.has(o.position)||te(s)&&!l&&zt(t,s))?i=i.filter(c=>c!==s):o=a,s=D(s)}return e.set(t,i),i}function Xn(t){let{element:e,boundary:n,rootBoundary:i,strategy:o}=t,s=[...n==="clippingAncestors"?ue(e)?[]:Jn(e,this._c):[].concat(n),i],a=s[0],l=s.reduce((p,c)=>{let d=_t(e,c,o);return p.top=q(d.top,p.top),p.right=le(d.right,p.right),p.bottom=le(d.bottom,p.bottom),p.left=q(d.left,p.left),p},_t(e,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function Yn(t){let{width:e,height:n}=Bt(t);return{width:e,height:n}}function ei(t,e,n){let i=$(e),o=_(e),r=n==="fixed",s=fe(t,!0,r,e),a={scrollLeft:0,scrollTop:0},l=O(0);function p(){l.x=Me(o)}if(i||!i&&!r)if((J(e)!=="body"||te(o))&&(a=he(e)),i){let u=fe(e,!0,r,e);l.x=u.x+e.clientLeft,l.y=u.y+e.clientTop}else o&&p();r&&!i&&o&&p();let c=o&&!i&&!r?Dt(o,a):O(0),d=s.left+a.scrollLeft-l.x-c.x,h=s.top+a.scrollTop-l.y-c.y;return{x:d,y:h,width:s.width,height:s.height}}function De(t){return H(t).position==="static"}function Rt(t,e){if(!$(t)||H(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return _(t)===n&&(n=n.ownerDocument.body),n}function jt(t,e){let n=A(t);if(ue(t))return n;if(!$(t)){let o=D(t);for(;o&&!X(o);){if(M(o)&&!De(o))return o;o=D(o)}return n}let i=Rt(t,e);for(;i&&Pt(i)&&De(i);)i=Rt(i,e);return i&&X(i)&&De(i)&&!Ce(i)?n:i||Ot(t)||n}var ti=async function(t){let e=this.getOffsetParent||jt,n=this.getDimensions,i=await n(t.floating);return{reference:ei(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function ni(t){return H(t).direction==="rtl"}var ii={convertOffsetParentRelativeRectToViewportRelativeRect:qn,getDocumentElement:_,getClippingRect:Xn,getOffsetParent:jt,getElementRects:ti,getClientRects:Wn,getDimensions:Yn,getScale:ne,isElement:M,isRTL:ni};var Vt=Tt;var Ut=At,qt=Ct;var Wt=(t,e,n)=>{let i=new Map,o={platform:ii,...n},r={...o.platform,_c:i};return Et(t,e,{...o,platform:r})};var He=class{constructor(e){this.editor=e,this.tooltip=null,this.currentLink=null,this.hideTimeout=null,this.visibilityChangeHandler=null,this.isTooltipHovered=!1,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.currentLink&&this.positionTooltip(this.currentLink)}),this.editor.textarea.addEventListener("blur",()=>{this.isTooltipHovered||this.hide()}),this.visibilityChangeHandler=()=>{document.hidden&&this.hide()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),this.tooltip.addEventListener("mouseenter",()=>{this.isTooltipHovered=!0,this.cancelHide()}),this.tooltip.addEventListener("mouseleave",()=>{this.isTooltipHovered=!1,this.scheduleHide()})}createTooltip(){this.tooltip=document.createElement("div"),this.tooltip.className="overtype-link-tooltip",this.tooltip.innerHTML=`
|
|
64
|
+
`;)p++;let c=r.slice(l,p);x("insertHeader",`Current line (before): "${c}"`);let d=c.match(/^(#{1,6})\s*/),u=d?d[1].length:0,h=d?d[0].length:0;x("insertHeader","Existing header check:"),x("insertHeader",` - Match: ${d?`"${d[0]}"`:"none"}`),x("insertHeader",` - Existing level: ${u}`),x("insertHeader",` - Existing prefix length: ${h}`),x("insertHeader",` - Target level: ${e}`);let f=n&&u===e;x("insertHeader",`Should toggle OFF: ${f} (toggle=${n}, existingLevel=${u}, level=${e})`);let m=Se(t,g=>{let y=g.value.slice(g.selectionStart,g.selectionEnd);x("insertHeader",`Line in operation: "${y}"`);let w=y.replace(/^#{1,6}\s*/,"");x("insertHeader",`Cleaned line: "${w}"`);let b;return f?(x("insertHeader","ACTION: Toggling OFF - removing header"),b=w):u>0?(x("insertHeader",`ACTION: Replacing H${u} with H${e}`),b=i.prefix+w):(x("insertHeader","ACTION: Adding new header"),b=i.prefix+w),x("insertHeader",`New line: "${b}"`),{text:b,selectionStart:g.selectionStart,selectionEnd:g.selectionEnd}},{prefix:i.prefix,adjustSelection:(g,y,w,b)=>{if(x("insertHeader","Adjusting selection:"),x("insertHeader",` - isRemoving param: ${g}`),x("insertHeader",` - shouldToggleOff: ${f}`),x("insertHeader",` - selStart: ${y}, selEnd: ${w}`),x("insertHeader",` - lineStartPos: ${b}`),f){let L=Math.max(y-h,b);return x("insertHeader",` - Removing header, adjusting by -${h}`),{start:L,end:y===w?L:Math.max(w-h,b)}}else if(h>0){let L=i.prefix.length-h;return x("insertHeader",` - Replacing header, adjusting by ${L}`),{start:y+L,end:w+L}}else return x("insertHeader",` - Adding header, adjusting by +${i.prefix.length}`),{start:y+i.prefix.length,end:w+i.prefix.length}}});x("insertHeader",`Final result: text="${m.text}", cursor=${m.selectionStart}-${m.selectionEnd}`),x("insertHeader","============ END ============"),N(t,m)}function Pe(t){de(t,1,!0)}function Oe(t){de(t,2,!0)}function _e(t){de(t,3,!0)}function Ie(t){return kt(t)}function Lt(t,e){return On(t,e)}function St(t,e={}){_n(t,e)}function Et(t,e){if(!t||t.disabled||t.readOnly)return;let n=R(e),o;if(n.multiline){let i=t.value.slice(t.selectionStart,t.selectionEnd);Ke(i)?o=Je(t,n):o=te(t,n)}else o=te(t,n);N(t,o)}var In={toggleBold:Ee,toggleItalic:Ce,toggleCode:Te,insertLink:Ae,toggleBulletList:Me,toggleNumberedList:$e,toggleQuote:He,toggleTaskList:pe,insertHeader:de,toggleH1:Pe,toggleH2:Oe,toggleH3:_e,getActiveFormats:Ie,hasFormat:Lt,expandSelection:St,applyCustomFormat:Et,preserveSelection:bt,setUndoMethod:yt,setDebugMode:gt,getDebugMode:Ze};var Re=class{constructor(e,n={}){this.editor=e,this.container=null,this.buttons={},this.toolbarButtons=n.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 n=this.createSeparator();this.container.appendChild(n)}else{let n=this.createButton(e);this.buttons[e.name]=n,this.container.appendChild(n)}}),this.editor.container.insertBefore(this.container,this.editor.wrapper)}createSeparator(){let e=document.createElement("div");return e.className="overtype-toolbar-separator",e.setAttribute("role","separator"),e}createButton(e){let n=document.createElement("button");return n.className="overtype-toolbar-button",n.type="button",n.setAttribute("data-button",e.name),n.title=e.title||"",n.setAttribute("aria-label",e.title||e.name),n.innerHTML=this.sanitizeSVG(e.icon||""),e.name==="viewMode"?(n.classList.add("has-dropdown"),n.dataset.dropdown="true",n.addEventListener("click",o=>{o.preventDefault(),this.toggleViewModeDropdown(n)}),n):(n._clickHandler=o=>{o.preventDefault();let i=e.actionId||e.name;this.editor.performAction(i,o)},n.addEventListener("click",n._clickHandler),n)}async handleAction(e){if(e&&typeof e=="object"&&typeof e.action=="function"){this.editor.textarea.focus();try{return await e.action({editor:this.editor,getValue:()=>this.editor.getValue(),setValue:n=>this.editor.setValue(n),event:null}),!0}catch(n){return console.error(`Action "${e.name}" error:`,n),this.editor.wrapper.dispatchEvent(new CustomEvent("button-error",{detail:{buttonName:e.name,error:n}})),!1}}return typeof e=="string"?this.editor.performAction(e,null):!1}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 n=document.querySelector(".overtype-dropdown-menu");if(n){n.remove(),e.classList.remove("dropdown-active");return}e.classList.add("dropdown-active");let o=this.createViewModeDropdown(e),i=e.getBoundingClientRect();o.style.position="absolute",o.style.top=`${i.bottom+5}px`,o.style.left=`${i.left}px`,document.body.appendChild(o),this.handleDocumentClick=r=>{!o.contains(r.target)&&!e.contains(r.target)&&(o.remove(),e.classList.remove("dropdown-active"),document.removeEventListener("click",this.handleDocumentClick))},setTimeout(()=>{document.addEventListener("click",this.handleDocumentClick)},0)}createViewModeDropdown(e){let n=document.createElement("div");n.className="overtype-dropdown-menu";let o=[{id:"normal",label:"Normal Edit",icon:"\u2713"},{id:"plain",label:"Plain Textarea",icon:"\u2713"},{id:"preview",label:"Preview Mode",icon:"\u2713"}],i=this.editor.container.dataset.mode||"normal";return o.forEach(r=>{let s=document.createElement("button");if(s.className="overtype-dropdown-item",s.type="button",s.textContent=r.label,r.id===i){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}n.remove(),e.classList.remove("dropdown-active"),document.removeEventListener("click",this.handleDocumentClick)}),n.appendChild(s)}),n}updateButtonStates(){var e;try{let n=((e=Ie)==null?void 0:e(this.editor.textarea,this.editor.textarea.selectionStart))||[];Object.entries(this.buttons).forEach(([o,i])=>{if(o==="viewMode")return;let r=!1;switch(o){case"bold":r=n.includes("bold");break;case"italic":r=n.includes("italic");break;case"code":r=!1;break;case"bulletList":r=n.includes("bullet-list");break;case"orderedList":r=n.includes("numbered-list");break;case"taskList":r=n.includes("task-list");break;case"quote":r=n.includes("quote");break;case"h1":r=n.includes("header");break;case"h2":r=n.includes("header-2");break;case"h3":r=n.includes("header-3");break}i.classList.toggle("active",r),i.setAttribute("aria-pressed",r.toString())})}catch(n){}}show(){this.container&&this.container.classList.remove("overtype-toolbar-hidden")}hide(){this.container&&this.container.classList.add("overtype-toolbar-hidden")}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 he=Math.min,W=Math.max,fe=Math.round;var O=t=>({x:t,y:t}),Rn={left:"right",right:"left",bottom:"top",top:"bottom"},Bn={start:"end",end:"start"};function Xe(t,e,n){return W(t,he(e,n))}function me(t,e){return typeof t=="function"?t(e):t}function q(t){return t.split("-")[0]}function ge(t){return t.split("-")[1]}function Ge(t){return t==="x"?"y":"x"}function Ye(t){return t==="y"?"height":"width"}var Fn=new Set(["top","bottom"]);function D(t){return Fn.has(q(t))?"y":"x"}function et(t){return Ge(D(t))}function At(t,e,n){n===void 0&&(n=!1);let o=ge(t),i=et(t),r=Ye(i),s=i==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=ue(s)),[s,ue(s)]}function Mt(t){let e=ue(t);return[Be(t),e,Be(e)]}function Be(t){return t.replace(/start|end/g,e=>Bn[e])}var Ct=["left","right"],Tt=["right","left"],Nn=["top","bottom"],Dn=["bottom","top"];function zn(t,e,n){switch(t){case"top":case"bottom":return n?e?Tt:Ct:e?Ct:Tt;case"left":case"right":return e?Nn:Dn;default:return[]}}function $t(t,e,n,o){let i=ge(t),r=zn(q(t),n==="start",o);return i&&(r=r.map(s=>s+"-"+i),e&&(r=r.concat(r.map(Be)))),r}function ue(t){return t.replace(/left|right|bottom|top/g,e=>Rn[e])}function jn(t){return{top:0,right:0,bottom:0,left:0,...t}}function Ht(t){return typeof t!="number"?jn(t):{top:t,right:t,bottom:t,left:t}}function J(t){let{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}}function Pt(t,e,n){let{reference:o,floating:i}=t,r=D(e),s=et(e),a=Ye(s),l=q(e),p=r==="y",c=o.x+o.width/2-i.width/2,d=o.y+o.height/2-i.height/2,u=o[a]/2-i[a]/2,h;switch(l){case"top":h={x:c,y:o.y-i.height};break;case"bottom":h={x:c,y:o.y+o.height};break;case"right":h={x:o.x+o.width,y:d};break;case"left":h={x:o.x-i.width,y:d};break;default:h={x:o.x,y:o.y}}switch(ge(e)){case"start":h[s]-=u*(n&&p?-1:1);break;case"end":h[s]+=u*(n&&p?-1:1);break}return h}async function Ot(t,e){var n;e===void 0&&(e={});let{x:o,y:i,platform:r,rects:s,elements:a,strategy:l}=t,{boundary:p="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:u=!1,padding:h=0}=me(e,t),f=Ht(h),g=a[u?d==="floating"?"reference":"floating":d],y=J(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(g)))==null||n?g:g.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(a.floating)),boundary:p,rootBoundary:c,strategy:l})),w=d==="floating"?{x:o,y:i,width:s.floating.width,height:s.floating.height}:s.reference,b=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a.floating)),L=await(r.isElement==null?void 0:r.isElement(b))?await(r.getScale==null?void 0:r.getScale(b))||{x:1,y:1}:{x:1,y:1},k=J(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:b,strategy:l}):w);return{top:(y.top-k.top+f.top)/L.y,bottom:(k.bottom-y.bottom+f.bottom)/L.y,left:(y.left-k.left+f.left)/L.x,right:(k.right-y.right+f.right)/L.x}}var _t=async(t,e,n)=>{let{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:s}=n,a=r.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(e)),p=await s.getElementRects({reference:t,floating:e,strategy:i}),{x:c,y:d}=Pt(p,o,l),u=o,h={},f=0;for(let g=0;g<a.length;g++){var m;let{name:y,fn:w}=a[g],{x:b,y:L,data:k,reset:E}=await w({x:c,y:d,initialPlacement:o,placement:u,strategy:i,middlewareData:h,rects:p,platform:{...s,detectOverflow:(m=s.detectOverflow)!=null?m:Ot},elements:{reference:t,floating:e}});c=b!=null?b:c,d=L!=null?L:d,h={...h,[y]:{...h[y],...k}},E&&f<=50&&(f++,typeof E=="object"&&(E.placement&&(u=E.placement),E.rects&&(p=E.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:i}):E.rects),{x:c,y:d}=Pt(p,u,l)),g=-1)}return{x:c,y:d,placement:u,strategy:i,middlewareData:h}};var It=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,o;let{placement:i,middlewareData:r,rects:s,initialPlacement:a,platform:l,elements:p}=e,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:u,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:m=!0,...g}=me(t,e);if((n=r.arrow)!=null&&n.alignmentOffset)return{};let y=q(i),w=D(a),b=q(a)===a,L=await(l.isRTL==null?void 0:l.isRTL(p.floating)),k=u||(b||!m?[ue(a)]:Mt(a)),E=f!=="none";!u&&E&&k.push(...$t(a,m,f,L));let be=[a,...k],Y=await l.detectOverflow(e,g),xe=[],ee=((o=r.flip)==null?void 0:o.overflows)||[];if(c&&xe.push(Y[y]),d){let K=At(i,s,L);xe.push(Y[K[0]],Y[K[1]])}if(ee=[...ee,{placement:i,overflows:xe}],!xe.every(K=>K<=0)){var ot,it;let K=(((ot=r.flip)==null?void 0:ot.index)||0)+1,We=be[K];if(We&&(!(d==="alignment"?w!==D(We):!1)||ee.every(P=>D(P.placement)===w?P.overflows[0]>0:!0)))return{data:{index:K,overflows:ee},reset:{placement:We}};let se=(it=ee.filter(Z=>Z.overflows[0]<=0).sort((Z,P)=>Z.overflows[1]-P.overflows[1])[0])==null?void 0:it.placement;if(!se)switch(h){case"bestFit":{var rt;let Z=(rt=ee.filter(P=>{if(E){let V=D(P.placement);return V===w||V==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(V=>V>0).reduce((V,vn)=>V+vn,0)]).sort((P,V)=>P[1]-V[1])[0])==null?void 0:rt[0];Z&&(se=Z);break}case"initialPlacement":se=a;break}if(i!==se)return{reset:{placement:se}}}return{}}}};var Vn=new Set(["left","top"]);async function Un(t,e){let{placement:n,platform:o,elements:i}=t,r=await(o.isRTL==null?void 0:o.isRTL(i.floating)),s=q(n),a=ge(n),l=D(n)==="y",p=Vn.has(s)?-1:1,c=r&&l?-1:1,d=me(e,t),{mainAxis:u,crossAxis:h,alignmentAxis:f}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof f=="number"&&(h=a==="end"?f*-1:f),l?{x:h*c,y:u*p}:{x:u*p,y:h*c}}var Rt=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,o;let{x:i,y:r,placement:s,middlewareData:a}=e,l=await Un(e,t);return s===((n=a.offset)==null?void 0:n.placement)&&(o=a.arrow)!=null&&o.alignmentOffset?{}:{x:i+l.x,y:r+l.y,data:{...l,placement:s}}}}},Bt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:o,placement:i,platform:r}=e,{mainAxis:s=!0,crossAxis:a=!1,limiter:l={fn:y=>{let{x:w,y:b}=y;return{x:w,y:b}}},...p}=me(t,e),c={x:n,y:o},d=await r.detectOverflow(e,p),u=D(q(i)),h=Ge(u),f=c[h],m=c[u];if(s){let y=h==="y"?"top":"left",w=h==="y"?"bottom":"right",b=f+d[y],L=f-d[w];f=Xe(b,f,L)}if(a){let y=u==="y"?"top":"left",w=u==="y"?"bottom":"right",b=m+d[y],L=m-d[w];m=Xe(b,m,L)}let g=l.fn({...e,[h]:f,[u]:m});return{...g,data:{x:g.x-n,y:g.y-o,enabled:{[h]:s,[u]:a}}}}}};function Ne(){return typeof window<"u"}function X(t){return Nt(t)?(t.nodeName||"").toLowerCase():"#document"}function A(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function B(t){var e;return(e=(Nt(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Nt(t){return Ne()?t instanceof Node||t instanceof A(t).Node:!1}function $(t){return Ne()?t instanceof Element||t instanceof A(t).Element:!1}function _(t){return Ne()?t instanceof HTMLElement||t instanceof A(t).HTMLElement:!1}function Ft(t){return!Ne()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof A(t).ShadowRoot}var Wn=new Set(["inline","contents"]);function oe(t){let{overflow:e,overflowX:n,overflowY:o,display:i}=H(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!Wn.has(i)}var qn=new Set(["table","td","th"]);function Dt(t){return qn.has(X(t))}var Kn=[":popover-open",":modal"];function ve(t){return Kn.some(e=>{try{return t.matches(e)}catch(n){return!1}})}var Zn=["transform","translate","scale","rotate","perspective"],Qn=["transform","translate","scale","rotate","perspective","filter"],Jn=["paint","layout","strict","content"];function De(t){let e=ze(),n=$(t)?H(t):t;return Zn.some(o=>n[o]?n[o]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||Qn.some(o=>(n.willChange||"").includes(o))||Jn.some(o=>(n.contain||"").includes(o))}function zt(t){let e=z(t);for(;_(e)&&!G(e);){if(De(e))return e;if(ve(e))return null;e=z(e)}return null}function ze(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var Xn=new Set(["html","body","#document"]);function G(t){return Xn.has(X(t))}function H(t){return A(t).getComputedStyle(t)}function ye(t){return $(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function z(t){if(X(t)==="html")return t;let e=t.assignedSlot||t.parentNode||Ft(t)&&t.host||B(t);return Ft(e)?e.host:e}function jt(t){let e=z(t);return G(e)?t.ownerDocument?t.ownerDocument.body:t.body:_(e)&&oe(e)?e:jt(e)}function Fe(t,e,n){var o;e===void 0&&(e=[]),n===void 0&&(n=!0);let i=jt(t),r=i===((o=t.ownerDocument)==null?void 0:o.body),s=A(i);if(r){let a=je(s);return e.concat(s,s.visualViewport||[],oe(i)?i:[],a&&n?Fe(a):[])}return e.concat(i,Fe(i,[],n))}function je(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function qt(t){let e=H(t),n=parseFloat(e.width)||0,o=parseFloat(e.height)||0,i=_(t),r=i?t.offsetWidth:n,s=i?t.offsetHeight:o,a=fe(n)!==r||fe(o)!==s;return a&&(n=r,o=s),{width:n,height:o,$:a}}function Kt(t){return $(t)?t:t.contextElement}function ie(t){let e=Kt(t);if(!_(e))return O(1);let n=e.getBoundingClientRect(),{width:o,height:i,$:r}=qt(e),s=(r?fe(n.width):n.width)/o,a=(r?fe(n.height):n.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var Gn=O(0);function Zt(t){let e=A(t);return!ze()||!e.visualViewport?Gn:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Yn(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==A(t)?!1:e}function we(t,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);let i=t.getBoundingClientRect(),r=Kt(t),s=O(1);e&&(o?$(o)&&(s=ie(o)):s=ie(t));let a=Yn(r,n,o)?Zt(r):O(0),l=(i.left+a.x)/s.x,p=(i.top+a.y)/s.y,c=i.width/s.x,d=i.height/s.y;if(r){let u=A(r),h=o&&$(o)?A(o):o,f=u,m=je(f);for(;m&&o&&h!==f;){let g=ie(m),y=m.getBoundingClientRect(),w=H(m),b=y.left+(m.clientLeft+parseFloat(w.paddingLeft))*g.x,L=y.top+(m.clientTop+parseFloat(w.paddingTop))*g.y;l*=g.x,p*=g.y,c*=g.x,d*=g.y,l+=b,p+=L,f=A(m),m=je(f)}}return J({width:c,height:d,x:l,y:p})}function Ve(t,e){let n=ye(t).scrollLeft;return e?e.left+n:we(B(t)).left+n}function Qt(t,e){let n=t.getBoundingClientRect(),o=n.left+e.scrollLeft-Ve(t,n),i=n.top+e.scrollTop;return{x:o,y:i}}function eo(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t,r=i==="fixed",s=B(o),a=e?ve(e.floating):!1;if(o===s||a&&r)return n;let l={scrollLeft:0,scrollTop:0},p=O(1),c=O(0),d=_(o);if((d||!d&&!r)&&((X(o)!=="body"||oe(s))&&(l=ye(o)),_(o))){let h=we(o);p=ie(o),c.x=h.x+o.clientLeft,c.y=h.y+o.clientTop}let u=s&&!d&&!r?Qt(s,l):O(0);return{width:n.width*p.x,height:n.height*p.y,x:n.x*p.x-l.scrollLeft*p.x+c.x+u.x,y:n.y*p.y-l.scrollTop*p.y+c.y+u.y}}function to(t){return Array.from(t.getClientRects())}function no(t){let e=B(t),n=ye(t),o=t.ownerDocument.body,i=W(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),r=W(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight),s=-n.scrollLeft+Ve(t),a=-n.scrollTop;return H(o).direction==="rtl"&&(s+=W(e.clientWidth,o.clientWidth)-i),{width:i,height:r,x:s,y:a}}var Vt=25;function oo(t,e){let n=A(t),o=B(t),i=n.visualViewport,r=o.clientWidth,s=o.clientHeight,a=0,l=0;if(i){r=i.width,s=i.height;let c=ze();(!c||c&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}let p=Ve(o);if(p<=0){let c=o.ownerDocument,d=c.body,u=getComputedStyle(d),h=c.compatMode==="CSS1Compat"&&parseFloat(u.marginLeft)+parseFloat(u.marginRight)||0,f=Math.abs(o.clientWidth-d.clientWidth-h);f<=Vt&&(r-=f)}else p<=Vt&&(r+=p);return{width:r,height:s,x:a,y:l}}var io=new Set(["absolute","fixed"]);function ro(t,e){let n=we(t,!0,e==="fixed"),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=_(t)?ie(t):O(1),s=t.clientWidth*r.x,a=t.clientHeight*r.y,l=i*r.x,p=o*r.y;return{width:s,height:a,x:l,y:p}}function Ut(t,e,n){let o;if(e==="viewport")o=oo(t,n);else if(e==="document")o=no(B(t));else if($(e))o=ro(e,n);else{let i=Zt(t);o={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return J(o)}function Jt(t,e){let n=z(t);return n===e||!$(n)||G(n)?!1:H(n).position==="fixed"||Jt(n,e)}function so(t,e){let n=e.get(t);if(n)return n;let o=Fe(t,[],!1).filter(a=>$(a)&&X(a)!=="body"),i=null,r=H(t).position==="fixed",s=r?z(t):t;for(;$(s)&&!G(s);){let a=H(s),l=De(s);!l&&a.position==="fixed"&&(i=null),(r?!l&&!i:!l&&a.position==="static"&&!!i&&io.has(i.position)||oe(s)&&!l&&Jt(t,s))?o=o.filter(c=>c!==s):i=a,s=z(s)}return e.set(t,o),o}function ao(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t,s=[...n==="clippingAncestors"?ve(e)?[]:so(e,this._c):[].concat(n),o],a=s[0],l=s.reduce((p,c)=>{let d=Ut(e,c,i);return p.top=W(d.top,p.top),p.right=he(d.right,p.right),p.bottom=he(d.bottom,p.bottom),p.left=W(d.left,p.left),p},Ut(e,a,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function lo(t){let{width:e,height:n}=qt(t);return{width:e,height:n}}function co(t,e,n){let o=_(e),i=B(e),r=n==="fixed",s=we(t,!0,r,e),a={scrollLeft:0,scrollTop:0},l=O(0);function p(){l.x=Ve(i)}if(o||!o&&!r)if((X(e)!=="body"||oe(i))&&(a=ye(e)),o){let h=we(e,!0,r,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop}else i&&p();r&&!o&&i&&p();let c=i&&!o&&!r?Qt(i,a):O(0),d=s.left+a.scrollLeft-l.x-c.x,u=s.top+a.scrollTop-l.y-c.y;return{x:d,y:u,width:s.width,height:s.height}}function tt(t){return H(t).position==="static"}function Wt(t,e){if(!_(t)||H(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return B(t)===n&&(n=n.ownerDocument.body),n}function Xt(t,e){let n=A(t);if(ve(t))return n;if(!_(t)){let i=z(t);for(;i&&!G(i);){if($(i)&&!tt(i))return i;i=z(i)}return n}let o=Wt(t,e);for(;o&&Dt(o)&&tt(o);)o=Wt(o,e);return o&&G(o)&&tt(o)&&!De(o)?n:o||zt(t)||n}var po=async function(t){let e=this.getOffsetParent||Xt,n=this.getDimensions,o=await n(t.floating);return{reference:co(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function uo(t){return H(t).direction==="rtl"}var ho={convertOffsetParentRelativeRectToViewportRelativeRect:eo,getDocumentElement:B,getClippingRect:ao,getOffsetParent:Xt,getElementRects:po,getClientRects:to,getDimensions:lo,getScale:ie,isElement:$,isRTL:uo};var Gt=Rt;var Yt=Bt,en=It;var tn=(t,e,n)=>{let o=new Map,i={platform:ho,...n},r={...i.platform,_c:o};return _t(t,e,{...i,platform:r})};var Ue=class{constructor(e){this.editor=e,this.tooltip=null,this.currentLink=null,this.hideTimeout=null,this.visibilityChangeHandler=null,this.isTooltipHovered=!1,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.currentLink&&this.positionTooltip(this.currentLink)}),this.editor.textarea.addEventListener("blur",()=>{this.isTooltipHovered||this.hide()}),this.visibilityChangeHandler=()=>{document.hidden&&this.hide()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),this.tooltip.addEventListener("mouseenter",()=>{this.isTooltipHovered=!0,this.cancelHide()}),this.tooltip.addEventListener("mouseleave",()=>{this.isTooltipHovered=!1,this.scheduleHide()})}createTooltip(){this.tooltip=document.createElement("div"),this.tooltip.className="overtype-link-tooltip",this.tooltip.innerHTML=`
|
|
905
65
|
<span style="display: flex; align-items: center; gap: 6px;">
|
|
906
66
|
<svg width="12" height="12" viewBox="0 0 20 20" fill="currentColor" style="flex-shrink: 0;">
|
|
907
67
|
<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>
|
|
@@ -909,78 +69,25 @@ ${a}`:r;if(p){let k=t.value[t.selectionStart-1];t.selectionStart!==0&&k!=null&&!
|
|
|
909
69
|
</svg>
|
|
910
70
|
<span class="overtype-link-tooltip-url"></span>
|
|
911
71
|
</span>
|
|
912
|
-
`,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,n=this.editor.textarea.value,i=this.findLinkAtPosition(n,e);i?(!this.currentLink||this.currentLink.url!==i.url||this.currentLink.index!==i.index)&&this.show(i):this.scheduleHide()}findLinkAtPosition(e,n){let i=/\[([^\]]+)\]\(([^)]+)\)/g,o,r=0;for(;(o=i.exec(e))!==null;){let s=o.index,a=o.index+o[0].length;if(n>=s&&n<=a)return{text:o[1],url:o[2],index:r,start:s,end:a};r++}return null}async show(e){this.currentLink=e,this.cancelHide();let n=this.tooltip.querySelector(".overtype-link-tooltip-url");n.textContent=e.url,await this.positionTooltip(e),this.currentLink===e&&this.tooltip.classList.add("visible")}async positionTooltip(e){let n=this.findAnchorElement(e.index);if(!n)return;let i=n.getBoundingClientRect();if(!(i.width===0||i.height===0))try{let{x:o,y:r}=await Wt(n,this.tooltip,{strategy:"fixed",placement:"bottom",middleware:[Vt(8),Ut({padding:8}),qt()]});Object.assign(this.tooltip.style,{left:`${o}px`,top:`${r}px`,position:"fixed"})}catch(o){console.warn("Floating UI positioning failed:",o)}}findAnchorElement(e){return this.editor.preview.querySelector(`a[style*="--link-${e}"]`)}hide(){this.tooltip.classList.remove("visible"),this.currentLink=null,this.isTooltipHovered=!1}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,this.isTooltipHovered=!1}};var Kt=`<svg viewBox="0 0 18 18">
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
</svg>`,Zt=`<svg viewBox="0 0 18 18">
|
|
916
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="13" y1="4" y2="4"></line>
|
|
917
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="5" x2="11" y1="14" y2="14"></line>
|
|
918
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="8" x2="10" y1="14" y2="4"></line>
|
|
919
|
-
</svg>`,Qt=`<svg viewBox="0 0 18 18">
|
|
920
|
-
<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>
|
|
921
|
-
</svg>`,Gt=`<svg viewBox="0 0 18 18">
|
|
922
|
-
<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>
|
|
923
|
-
</svg>`,Jt=`<svg viewBox="0 0 18 18">
|
|
924
|
-
<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>
|
|
925
|
-
</svg>`,Xt=`<svg viewBox="0 0 18 18">
|
|
926
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="11" y1="7" y2="11"></line>
|
|
927
|
-
<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>
|
|
928
|
-
<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>
|
|
929
|
-
</svg>`,Yt=`<svg viewBox="0 0 18 18">
|
|
930
|
-
<polyline stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" points="5 7 3 9 5 11"></polyline>
|
|
931
|
-
<polyline stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" points="13 7 15 9 13 11"></polyline>
|
|
932
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="10" x2="8" y1="5" y2="13"></line>
|
|
933
|
-
</svg>`,en=`<svg viewBox="0 0 18 18">
|
|
934
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="6" x2="15" y1="4" y2="4"></line>
|
|
935
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="6" x2="15" y1="9" y2="9"></line>
|
|
936
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="6" x2="15" y1="14" y2="14"></line>
|
|
937
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="3" x2="3" y1="4" y2="4"></line>
|
|
938
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="3" x2="3" y1="9" y2="9"></line>
|
|
939
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="3" x2="3" y1="14" y2="14"></line>
|
|
940
|
-
</svg>`,tn=`<svg viewBox="0 0 18 18">
|
|
941
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="15" y1="4" y2="4"></line>
|
|
942
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="15" y1="9" y2="9"></line>
|
|
943
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="15" y1="14" y2="14"></line>
|
|
944
|
-
<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>
|
|
945
|
-
<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>
|
|
946
|
-
<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>
|
|
947
|
-
<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>
|
|
948
|
-
</svg>`,nn=`<svg viewBox="2 2 20 20">
|
|
949
|
-
<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>
|
|
950
|
-
<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>
|
|
951
|
-
</svg>`,on=`<svg viewBox="0 0 18 18">
|
|
952
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="8" x2="16" y1="4" y2="4"></line>
|
|
953
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="8" x2="16" y1="9" y2="9"></line>
|
|
954
|
-
<line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="8" x2="16" y1="14" y2="14"></line>
|
|
955
|
-
<rect stroke="currentColor" fill="none" stroke-width="1.5" x="2" y="3" width="3" height="3" rx="0.5"></rect>
|
|
956
|
-
<rect stroke="currentColor" fill="none" stroke-width="1.5" x="2" y="13" width="3" height="3" rx="0.5"></rect>
|
|
957
|
-
<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>
|
|
958
|
-
</svg>`,rn=`<svg viewBox="0 0 18 18">
|
|
959
|
-
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.25 12.375v1.688A1.688 1.688 0 0 0 3.938 15.75h10.124a1.688 1.688 0 0 0 1.688-1.688V12.375"></path>
|
|
960
|
-
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5.063 6.188L9 2.25l3.938 3.938"></path>
|
|
961
|
-
<path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 2.25v10.125"></path>
|
|
962
|
-
</svg>`,sn=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
963
|
-
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" fill="none"></path>
|
|
964
|
-
<circle cx="12" cy="12" r="3" fill="none"></circle>
|
|
965
|
-
</svg>`;var S={bold:{name:"bold",actionId:"toggleBold",icon:Kt,title:"Bold (Ctrl+B)",action:({editor:t})=>{rt(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},italic:{name:"italic",actionId:"toggleItalic",icon:Zt,title:"Italic (Ctrl+I)",action:({editor:t})=>{st(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},code:{name:"code",actionId:"toggleCode",icon:Yt,title:"Inline Code",action:({editor:t})=>{at(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},separator:{name:"separator"},link:{name:"link",actionId:"insertLink",icon:Xt,title:"Insert Link",action:({editor:t})=>{lt(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h1:{name:"h1",actionId:"toggleH1",icon:Qt,title:"Heading 1",action:({editor:t})=>{ut(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h2:{name:"h2",actionId:"toggleH2",icon:Gt,title:"Heading 2",action:({editor:t})=>{ht(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h3:{name:"h3",actionId:"toggleH3",icon:Jt,title:"Heading 3",action:({editor:t})=>{ft(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},bulletList:{name:"bulletList",actionId:"toggleBulletList",icon:en,title:"Bullet List",action:({editor:t})=>{ct(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},orderedList:{name:"orderedList",actionId:"toggleNumberedList",icon:tn,title:"Numbered List",action:({editor:t})=>{pt(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},taskList:{name:"taskList",actionId:"toggleTaskList",icon:on,title:"Task List",action:({editor:t})=>{Ie&&(Ie(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0})))}},quote:{name:"quote",actionId:"toggleQuote",icon:nn,title:"Quote",action:({editor:t})=>{dt(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},upload:{name:"upload",actionId:"uploadFile",icon:rn,title:"Upload File",action:({editor:t})=>{var n,i;if(!((n=t.options.fileUpload)!=null&&n.enabled))return;let e=document.createElement("input");e.type="file",e.multiple=!0,((i=t.options.fileUpload.mimeTypes)==null?void 0:i.length)>0&&(e.accept=t.options.fileUpload.mimeTypes.join(",")),e.onchange=()=>{var r;if(!((r=e.files)!=null&&r.length))return;let o=new DataTransfer;for(let s of e.files)o.items.add(s);t._handleDataTransfer(o)},e.click()}},viewMode:{name:"viewMode",icon:sn,title:"View mode"}},ie=[S.bold,S.italic,S.code,S.separator,S.link,S.separator,S.h1,S.h2,S.h3,S.separator,S.bulletList,S.orderedList,S.taskList,S.separator,S.quote,S.separator,S.viewMode];function ze(t){let e={};return(t||[]).forEach(n=>{if(!n||n.name==="separator")return;let i=n.actionId||n.name;n.action&&(e[i]=n.action)}),e}function an(t){let e=t||ie;return Array.isArray(e)?e.map(n=>({name:(n==null?void 0:n.name)||null,actionId:(n==null?void 0:n.actionId)||(n==null?void 0:n.name)||null,icon:(n==null?void 0:n.icon)||null,title:(n==null?void 0:n.title)||null})):null}function ri(t,e){let n=an(t),i=an(e);if(n===null||i===null)return n!==i;if(n.length!==i.length)return!0;for(let o=0;o<n.length;o++){let r=n[o],s=i[o];if(r.name!==s.name||r.actionId!==s.actionId||r.icon!==s.icon||r.title!==s.title)return!0}return!1}var v=class v{constructor(e,n={}){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(n),r.overTypeInstance;let s=Object.create(v.prototype);return s._init(r,n),r.overTypeInstance=s,v.instances.set(r,s),s})}_init(e,n={}){this.element=e,this.instanceTheme=n.theme||null,this.options=this._mergeOptions(n),this.instanceId=++v.instanceCount,this.initialized=!1,v.injectStyles(),v.initGlobalListeners();let i=e.querySelector(".overtype-container"),o=e.querySelector(".overtype-wrapper");i||o?this._recoverFromDOM(i,o):this._buildFromScratch(),this.instanceTheme==="auto"&&this.setTheme("auto"),this.shortcuts=new re(this),this._rebuildActionsMap(),this.linkTooltip=new He(this),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.textarea.scrollTop=this.preview.scrollTop,this.textarea.scrollLeft=this.preview.scrollLeft})}),this.initialized=!0,this.options.onChange&&this._notifyChange()}_mergeOptions(e){let n={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,onRender:null,showActiveLineRaw:!1,showStats:!1,toolbar:!1,toolbarButtons:null,statsFormatter:null,smartLists:!0,codeHighlighter:null,spellcheck:!1},{theme:i,colors:o,...r}=e;return{...n,...r}}_recoverFromDOM(e,n){if(e&&e.classList.contains("overtype-container"))this.container=e,this.wrapper=e.querySelector(".overtype-wrapper");else if(n){this.wrapper=n,this.container=document.createElement("div"),this.container.className="overtype-container";let i=this.instanceTheme||v.currentTheme||R,o=typeof i=="string"?i:i.name;if(o&&this.container.setAttribute("data-theme",o),this.instanceTheme){let r=typeof this.instanceTheme=="string"?V(this.instanceTheme):this.instanceTheme;if(r&&r.colors){let s=Q(r.colors);this.container.style.cssText+=s}}n.parentNode.insertBefore(this.container,n),this.container.appendChild(n)}if(!this.wrapper){e&&e.remove(),n&&n.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._applyInstanceCSSVars(),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||v.currentTheme||R,n=typeof e=="string"?e:e.name;if(n&&this.container.setAttribute("data-theme",n),this.instanceTheme){let i=typeof this.instanceTheme=="string"?V(this.instanceTheme):this.instanceTheme;if(i&&i.colors){let o=Q(i.colors);this.container.style.cssText+=o}}this.wrapper=document.createElement("div"),this.wrapper.className="overtype-wrapper",this._applyInstanceCSSVars(),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.placeholderEl=document.createElement("div"),this.placeholderEl.className="overtype-placeholder",this.placeholderEl.setAttribute("aria-hidden","true"),this.placeholderEl.textContent=this.options.placeholder,this.wrapper.appendChild(this.textarea),this.wrapper.appendChild(this.preview),this.wrapper.appendChild(this.placeholderEl),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),this.options.autoResize?this._setupAutoResize():this.container.classList.remove("overtype-auto-resize")}_configureTextarea(){this.textarea.setAttribute("autocomplete","off"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck",String(this.options.spellcheck)),this.textarea.setAttribute("data-gramm","false"),this.textarea.setAttribute("data-gramm_editor","false"),this.textarea.setAttribute("data-enable-grammarly","false")}_createToolbar(){var n;let e=this.options.toolbarButtons||ie;if((n=this.options.fileUpload)!=null&&n.enabled&&!e.some(i=>(i==null?void 0:i.name)==="upload")){let i=e.findIndex(o=>(o==null?void 0:o.name)==="viewMode");i!==-1?(e=[...e],e.splice(i,0,S.separator,S.upload)):e=[...e,S.separator,S.upload]}this.toolbar=new ke(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)}_rebuildActionsMap(){var e;this.actionsById=ze(ie),this.options.toolbarButtons&&Object.assign(this.actionsById,ze(this.options.toolbarButtons)),(e=this.options.fileUpload)!=null&&e.enabled&&Object.assign(this.actionsById,ze([S.upload]))}_applyInstanceCSSVars(){this.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.options.fontFamily&&this.wrapper.style.setProperty("--instance-font-family",this.options.fontFamily))}_applyOptions(){this._applyInstanceCSSVars(),this.options.autofocus&&this.textarea.focus(),this.options.autoResize?this.container.classList.contains("overtype-auto-resize")?this._updateAutoHeight():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.placeholderEl&&(this.placeholderEl.textContent=this.options.placeholder),this.options.fileUpload&&!this.fileUploadInitialized?this._initFileUpload():!this.options.fileUpload&&this.fileUploadInitialized&&this._destroyFileUpload(),this.updatePreview()}_initFileUpload(){let e=this.options.fileUpload;if(!(!e||!e.enabled)){if(e.maxSize=e.maxSize||10*1024*1024,e.mimeTypes=e.mimeTypes||[],e.batch=e.batch||!1,!e.onInsertFile||typeof e.onInsertFile!="function"){console.warn("OverType: fileUpload.onInsertFile callback is required for file uploads.");return}this._fileUploadCounter=0,this._boundHandleFilePaste=this._handleFilePaste.bind(this),this._boundHandleFileDrop=this._handleFileDrop.bind(this),this._boundHandleDragOver=this._handleDragOver.bind(this),this.textarea.addEventListener("paste",this._boundHandleFilePaste),this.textarea.addEventListener("drop",this._boundHandleFileDrop),this.textarea.addEventListener("dragover",this._boundHandleDragOver),this.fileUploadInitialized=!0}}_handleFilePaste(e){var n,i;(i=(n=e==null?void 0:e.clipboardData)==null?void 0:n.files)!=null&&i.length&&(e.preventDefault(),this._handleDataTransfer(e.clipboardData))}_handleFileDrop(e){var n,i;(i=(n=e==null?void 0:e.dataTransfer)==null?void 0:n.files)!=null&&i.length&&(e.preventDefault(),this._handleDataTransfer(e.dataTransfer))}_handleDataTransfer(e){let n=[];for(let i of e.files){if(i.size>this.options.fileUpload.maxSize||this.options.fileUpload.mimeTypes.length>0&&!this.options.fileUpload.mimeTypes.includes(i.type))continue;let o=++this._fileUploadCounter,s=`${i.type.startsWith("image/")?"!":""}[Uploading ${i.name} (#${o})...]()`;if(this.insertAtCursor(`${s}
|
|
966
|
-
`),this.options.fileUpload.batch){n.push({file:i,placeholder:s});continue}this.options.fileUpload.onInsertFile(i).then(a=>{this.textarea.value=this.textarea.value.replace(s,a),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))},a=>{console.error("OverType: File upload failed",a),this.textarea.value=this.textarea.value.replace(s,"[Upload failed]()"),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))})}this.options.fileUpload.batch&&n.length>0&&this.options.fileUpload.onInsertFile(n.map(i=>i.file)).then(i=>{(Array.isArray(i)?i:[i]).forEach((r,s)=>{this.textarea.value=this.textarea.value.replace(n[s].placeholder,r)}),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))},i=>{console.error("OverType: File upload failed",i),n.forEach(({placeholder:o})=>{this.textarea.value=this.textarea.value.replace(o,"[Upload failed]()")}),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))})}_handleDragOver(e){e.preventDefault()}_destroyFileUpload(){this.textarea.removeEventListener("paste",this._boundHandleFilePaste),this.textarea.removeEventListener("drop",this._boundHandleFileDrop),this.textarea.removeEventListener("dragover",this._boundHandleDragOver),this._boundHandleFilePaste=null,this._boundHandleFileDrop=null,this._boundHandleDragOver=null,this.fileUploadInitialized=!1}insertAtCursor(e){let n=this.textarea.selectionStart,i=this.textarea.selectionEnd,o=!1;try{o=document.execCommand("insertText",!1,e)}catch(r){}if(!o){let r=this.textarea.value.slice(0,n),s=this.textarea.value.slice(i);this.textarea.value=r+e+s,this.textarea.setSelectionRange(n+e.length,n+e.length)}this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}updatePreview(){let e=this.textarea.value,n=this.textarea.selectionStart,i=this._getCurrentLine(e,n),o=this.container.dataset.mode==="preview",r=C.parse(e,i,this.options.showActiveLineRaw,this.options.codeHighlighter,o);this.preview.innerHTML=r,this.placeholderEl&&(this.placeholderEl.style.display=e?"none":""),this._applyCodeBlockBackgrounds(),this.options.showStats&&this.statsBar&&this._updateStats(),this.options.onRender&&this.options.onRender(this.preview,o?"preview":"normal",this)}_notifyChange(){!this.options.onChange||!this.initialized||this.options.onChange(this.textarea.value,this)}_applyCodeBlockBackgrounds(){let e=this.preview.querySelectorAll(".code-fence");for(let n=0;n<e.length-1;n+=2){let i=e[n],o=e[n+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,n){return e.substring(0,n).split(`
|
|
967
|
-
`).length-1}handleInput(e){this.updatePreview(),this._notifyChange()}handleKeydown(e){if(e.key==="Tab"){let i=this.textarea.selectionStart,o=this.textarea.selectionEnd,r=this.textarea.value;if(e.shiftKey&&i===o)return;if(e.preventDefault(),i!==o&&e.shiftKey){let s=r.substring(0,i),a=r.substring(i,o),l=r.substring(o),c=a.split(`
|
|
72
|
+
`,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,n=this.editor.textarea.value,o=this.findLinkAtPosition(n,e);o?(!this.currentLink||this.currentLink.url!==o.url||this.currentLink.index!==o.index)&&this.show(o):this.scheduleHide()}findLinkAtPosition(e,n){let o=/\[([^\]]+)\]\(([^)]+)\)/g,i,r=0;for(;(i=o.exec(e))!==null;){let s=i.index,a=i.index+i[0].length;if(n>=s&&n<=a)return{text:i[1],url:i[2],index:r,start:s,end:a};r++}return null}async show(e){this.currentLink=e,this.cancelHide();let n=this.tooltip.querySelector(".overtype-link-tooltip-url");n.textContent=e.url,await this.positionTooltip(e),this.currentLink===e&&this.tooltip.classList.add("visible")}async positionTooltip(e){let n=this.findAnchorElement(e.index);if(!n)return;let o=n.getBoundingClientRect();if(!(o.width===0||o.height===0))try{let{x:i,y:r}=await tn(n,this.tooltip,{strategy:"fixed",placement:"bottom",middleware:[Gt(8),Yt({padding:8}),en()]});Object.assign(this.tooltip.style,{left:`${i}px`,top:`${r}px`,position:"fixed"})}catch(i){console.warn("Floating UI positioning failed:",i)}}findAnchorElement(e){return this.editor.preview.querySelector(`a[style*="--link-${e}"]`)}hide(){this.tooltip.classList.remove("visible"),this.currentLink=null,this.isTooltipHovered=!1}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,this.isTooltipHovered=!1}};var nn='<svg viewBox="0 0 18 18"><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><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></svg>',on='<svg viewBox="0 0 18 18"><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="13" y1="4" y2="4"></line><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="5" x2="11" y1="14" y2="14"></line><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="8" x2="10" y1="14" y2="4"></line></svg>',rn='<svg viewBox="0 0 18 18"><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></svg>',sn='<svg viewBox="0 0 18 18"><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></svg>',an='<svg viewBox="0 0 18 18"><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></svg>',ln='<svg viewBox="0 0 18 18"><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="11" y1="7" y2="11"></line><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><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></svg>',cn='<svg viewBox="0 0 18 18"><polyline stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" points="5 7 3 9 5 11"></polyline><polyline stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" points="13 7 15 9 13 11"></polyline><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="10" x2="8" y1="5" y2="13"></line></svg>',pn='<svg viewBox="0 0 18 18"><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="6" x2="15" y1="4" y2="4"></line><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="6" x2="15" y1="9" y2="9"></line><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="6" x2="15" y1="14" y2="14"></line><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="3" x2="3" y1="4" y2="4"></line><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="3" x2="3" y1="9" y2="9"></line><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="3" x2="3" y1="14" y2="14"></line></svg>',dn='<svg viewBox="0 0 18 18"><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="15" y1="4" y2="4"></line><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="15" y1="9" y2="9"></line><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="7" x2="15" y1="14" y2="14"></line><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><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><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><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></svg>',un='<svg viewBox="2 2 20 20"><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><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></svg>',hn='<svg viewBox="0 0 18 18"><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="8" x2="16" y1="4" y2="4"></line><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="8" x2="16" y1="9" y2="9"></line><line stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" x1="8" x2="16" y1="14" y2="14"></line><rect stroke="currentColor" fill="none" stroke-width="1.5" x="2" y="3" width="3" height="3" rx="0.5"></rect><rect stroke="currentColor" fill="none" stroke-width="1.5" x="2" y="13" width="3" height="3" rx="0.5"></rect><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></svg>',fn='<svg viewBox="0 0 18 18"><path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.25 12.375v1.688A1.688 1.688 0 0 0 3.938 15.75h10.124a1.688 1.688 0 0 0 1.688-1.688V12.375"></path><path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5.063 6.188L9 2.25l3.938 3.938"></path><path stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 2.25v10.125"></path></svg>',mn='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" fill="none"></path><circle cx="12" cy="12" r="3" fill="none"></circle></svg>';var S={bold:{name:"bold",actionId:"toggleBold",icon:nn,title:"Bold (Ctrl+B)",action:({editor:t})=>{Ee(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},italic:{name:"italic",actionId:"toggleItalic",icon:on,title:"Italic (Ctrl+I)",action:({editor:t})=>{Ce(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},code:{name:"code",actionId:"toggleCode",icon:cn,title:"Inline Code",action:({editor:t})=>{Te(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},separator:{name:"separator"},link:{name:"link",actionId:"insertLink",icon:ln,title:"Insert Link",action:({editor:t})=>{Ae(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h1:{name:"h1",actionId:"toggleH1",icon:rn,title:"Heading 1",action:({editor:t})=>{Pe(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h2:{name:"h2",actionId:"toggleH2",icon:sn,title:"Heading 2",action:({editor:t})=>{Oe(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h3:{name:"h3",actionId:"toggleH3",icon:an,title:"Heading 3",action:({editor:t})=>{_e(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},bulletList:{name:"bulletList",actionId:"toggleBulletList",icon:pn,title:"Bullet List",action:({editor:t})=>{Me(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},orderedList:{name:"orderedList",actionId:"toggleNumberedList",icon:dn,title:"Numbered List",action:({editor:t})=>{$e(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},taskList:{name:"taskList",actionId:"toggleTaskList",icon:hn,title:"Task List",action:({editor:t})=>{pe&&(pe(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0})))}},quote:{name:"quote",actionId:"toggleQuote",icon:un,title:"Quote",action:({editor:t})=>{He(t.textarea),t.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},upload:{name:"upload",actionId:"uploadFile",icon:fn,title:"Upload File",action:({editor:t})=>{var n,o;if(!((n=t.options.fileUpload)!=null&&n.enabled))return;let e=document.createElement("input");e.type="file",e.multiple=!0,((o=t.options.fileUpload.mimeTypes)==null?void 0:o.length)>0&&(e.accept=t.options.fileUpload.mimeTypes.join(",")),e.onchange=()=>{var r;if(!((r=e.files)!=null&&r.length))return;let i=new DataTransfer;for(let s of e.files)i.items.add(s);t._handleDataTransfer(i)},e.click()}},viewMode:{name:"viewMode",icon:mn,title:"View mode"}},re=[S.bold,S.italic,S.code,S.separator,S.link,S.separator,S.h1,S.h2,S.h3,S.separator,S.bulletList,S.orderedList,S.taskList,S.separator,S.quote,S.separator,S.viewMode];function nt(t){let e={};return(t||[]).forEach(n=>{if(!n||n.name==="separator")return;let o=n.actionId||n.name;n.action&&(e[o]=n.action)}),e}function gn(t){let e=t||re;return Array.isArray(e)?e.map(n=>({name:(n==null?void 0:n.name)||null,actionId:(n==null?void 0:n.actionId)||(n==null?void 0:n.name)||null,icon:(n==null?void 0:n.icon)||null,title:(n==null?void 0:n.title)||null})):null}function mo(t,e){let n=gn(t),o=gn(e);if(n===null||o===null)return n!==o;if(n.length!==o.length)return!0;for(let i=0;i<n.length;i++){let r=n[i],s=o[i];if(r.name!==s.name||r.actionId!==s.actionId||r.icon!==s.icon||r.title!==s.title)return!0}return!1}var v=class v{constructor(e,n={}){let o=v._resolveTargets(e);if(typeof e=="string"&&o.length===0)throw new Error(`No elements found for selector: ${e}`);return o.map(r=>{if(r.overTypeInstance)return r.overTypeInstance.reinit(n),r.overTypeInstance;let s=Object.create(v.prototype);return s._init(r,n),r.overTypeInstance=s,v.instances.set(r,s),s})}_init(e,n={}){this.element=e,this.instanceTheme=n.theme||null,this.options=this._mergeOptions(n),this.instanceId=++v.instanceCount,this.initialized=!1,v.injectStyles(),v.initGlobalListeners();let o=e.querySelector(".overtype-container"),i=e.querySelector(".overtype-wrapper");o||i?this._recoverFromDOM(o,i):this._buildFromScratch(),this.instanceTheme==="auto"&&this.setTheme("auto"),this.shortcuts=new ae(this),this._rebuildActionsMap(),this.linkTooltip=new Ue(this),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.textarea.scrollTop=this.preview.scrollTop,this.textarea.scrollLeft=this.preview.scrollLeft})}),this.initialized=!0,this.options.onChange&&this._notifyChange()}_mergeOptions(e){let n={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,onRender:null,onFocus:null,onBlur:null,showActiveLineRaw:!1,showStats:!1,toolbar:!1,toolbarButtons:null,statsFormatter:null,smartLists:!0,codeHighlighter:null,spellcheck:!1},{theme:o,colors:i,...r}=e;return{...n,...r}}_recoverFromDOM(e,n){if(e&&e.classList.contains("overtype-container"))this.container=e,this.wrapper=e.querySelector(".overtype-wrapper");else if(n){this.wrapper=n,this.container=document.createElement("div"),this.container.className="overtype-container";let o=this.instanceTheme||v.currentTheme||F,i=typeof o=="string"?o:o.name;if(i&&this.container.setAttribute("data-theme",i),this.instanceTheme){let r=typeof this.instanceTheme=="string"?U(this.instanceTheme):this.instanceTheme;if(r&&r.colors){let s=Q(r.colors);this.container.style.cssText+=s}}n.parentNode.insertBefore(this.container,n),this.container.appendChild(n)}if(!this.wrapper){e&&e.remove(),n&&n.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._applyInstanceCSSVars(),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||v.currentTheme||F,n=typeof e=="string"?e:e.name;if(n&&this.container.setAttribute("data-theme",n),this.instanceTheme){let o=typeof this.instanceTheme=="string"?U(this.instanceTheme):this.instanceTheme;if(o&&o.colors){let i=Q(o.colors);this.container.style.cssText+=i}}this.wrapper=document.createElement("div"),this.wrapper.className="overtype-wrapper",this._applyInstanceCSSVars(),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(([o,i])=>{o==="className"||o==="class"?this.textarea.className+=" "+i:o==="style"&&typeof i=="object"?Object.assign(this.textarea.style,i):this.textarea.setAttribute(o,i)}),this.preview=document.createElement("div"),this.preview.className="overtype-preview",this.preview.setAttribute("aria-hidden","true"),this.placeholderEl=document.createElement("div"),this.placeholderEl.className="overtype-placeholder",this.placeholderEl.setAttribute("aria-hidden","true"),this.placeholderEl.textContent=this.options.placeholder,this.wrapper.appendChild(this.textarea),this.wrapper.appendChild(this.preview),this.wrapper.appendChild(this.placeholderEl),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),this.options.autoResize?this._setupAutoResize():this.container.classList.remove("overtype-auto-resize")}_configureTextarea(){this.textarea.setAttribute("autocomplete","off"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck",String(this.options.spellcheck)),this.textarea.setAttribute("data-gramm","false"),this.textarea.setAttribute("data-gramm_editor","false"),this.textarea.setAttribute("data-enable-grammarly","false")}_createToolbar(){var n;let e=this.options.toolbarButtons||re;if((n=this.options.fileUpload)!=null&&n.enabled&&!e.some(o=>(o==null?void 0:o.name)==="upload")){let o=e.findIndex(i=>(i==null?void 0:i.name)==="viewMode");o!==-1?(e=[...e],e.splice(o,0,S.separator,S.upload)):e=[...e,S.separator,S.upload]}this.toolbar=new Re(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)}_rebuildActionsMap(){var e;this.actionsById=nt(re),this.options.toolbarButtons&&Object.assign(this.actionsById,nt(this.options.toolbarButtons)),(e=this.options.fileUpload)!=null&&e.enabled&&Object.assign(this.actionsById,nt([S.upload]))}_applyInstanceCSSVars(){this.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.options.fontFamily&&this.wrapper.style.setProperty("--instance-font-family",this.options.fontFamily))}_applyOptions(){this._applyInstanceCSSVars(),this.options.autofocus&&this.textarea.focus(),this.options.autoResize?this.container.classList.contains("overtype-auto-resize")?this._updateAutoHeight():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.placeholderEl&&(this.placeholderEl.textContent=this.options.placeholder),this.options.fileUpload&&!this.fileUploadInitialized?this._initFileUpload():!this.options.fileUpload&&this.fileUploadInitialized&&this._destroyFileUpload(),this.updatePreview()}_initFileUpload(){let e=this.options.fileUpload;if(!(!e||!e.enabled)){if(e.maxSize=e.maxSize||10*1024*1024,e.mimeTypes=e.mimeTypes||[],e.batch=e.batch||!1,!e.onInsertFile||typeof e.onInsertFile!="function"){console.warn("OverType: fileUpload.onInsertFile callback is required for file uploads.");return}this._fileUploadCounter=0,this._boundHandleFilePaste=this._handleFilePaste.bind(this),this._boundHandleFileDrop=this._handleFileDrop.bind(this),this._boundHandleDragOver=this._handleDragOver.bind(this),this.textarea.addEventListener("paste",this._boundHandleFilePaste),this.textarea.addEventListener("drop",this._boundHandleFileDrop),this.textarea.addEventListener("dragover",this._boundHandleDragOver),this.fileUploadInitialized=!0}}_handleFilePaste(e){var n,o;(o=(n=e==null?void 0:e.clipboardData)==null?void 0:n.files)!=null&&o.length&&(e.preventDefault(),this._handleDataTransfer(e.clipboardData))}_handleFileDrop(e){var n,o;(o=(n=e==null?void 0:e.dataTransfer)==null?void 0:n.files)!=null&&o.length&&(e.preventDefault(),this._handleDataTransfer(e.dataTransfer))}_handleDataTransfer(e){let n=[];for(let o of e.files){if(o.size>this.options.fileUpload.maxSize||this.options.fileUpload.mimeTypes.length>0&&!this.options.fileUpload.mimeTypes.includes(o.type))continue;let i=++this._fileUploadCounter,s=`${o.type.startsWith("image/")?"!":""}[Uploading ${o.name} (#${i})...]()`;if(this.insertAtCursor(`${s}
|
|
73
|
+
`),this.options.fileUpload.batch){n.push({file:o,placeholder:s});continue}this.options.fileUpload.onInsertFile(o).then(a=>{this.textarea.value=this.textarea.value.replace(s,a),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))},a=>{console.error("OverType: File upload failed",a),this.textarea.value=this.textarea.value.replace(s,"[Upload failed]()"),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))})}this.options.fileUpload.batch&&n.length>0&&this.options.fileUpload.onInsertFile(n.map(o=>o.file)).then(o=>{(Array.isArray(o)?o:[o]).forEach((r,s)=>{this.textarea.value=this.textarea.value.replace(n[s].placeholder,r)}),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))},o=>{console.error("OverType: File upload failed",o),n.forEach(({placeholder:i})=>{this.textarea.value=this.textarea.value.replace(i,"[Upload failed]()")}),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))})}_handleDragOver(e){e.preventDefault()}_destroyFileUpload(){this.textarea.removeEventListener("paste",this._boundHandleFilePaste),this.textarea.removeEventListener("drop",this._boundHandleFileDrop),this.textarea.removeEventListener("dragover",this._boundHandleDragOver),this._boundHandleFilePaste=null,this._boundHandleFileDrop=null,this._boundHandleDragOver=null,this.fileUploadInitialized=!1}insertAtCursor(e){let n=this.textarea.selectionStart,o=this.textarea.selectionEnd,i=!1;try{i=document.execCommand("insertText",!1,e)}catch(r){}if(!i){let r=this.textarea.value.slice(0,n),s=this.textarea.value.slice(o);this.textarea.value=r+e+s,this.textarea.setSelectionRange(n+e.length,n+e.length)}this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}updatePreview(){let e=this.textarea.value,n=this.textarea.selectionStart,o=this._getCurrentLine(e,n),i=this.container.dataset.mode==="preview",r=C.parse(e,o,this.options.showActiveLineRaw,this.options.codeHighlighter,i);this.preview.innerHTML=r,this.placeholderEl&&(this.placeholderEl.style.display=e?"none":""),this._applyCodeBlockBackgrounds(),this.options.showStats&&this.statsBar&&this._updateStats(),this.options.onRender&&this.options.onRender(this.preview,i?"preview":"normal",this)}_notifyChange(){!this.options.onChange||!this.initialized||this.options.onChange(this.textarea.value,this)}_applyCodeBlockBackgrounds(){let e=this.preview.querySelectorAll(".code-fence");for(let n=0;n<e.length-1;n+=2){let o=e[n],i=e[n+1],r=o.parentElement,s=i.parentElement;!r||!s||(o.style.display="block",i.style.display="block",r.classList.add("code-block-line"),s.classList.add("code-block-line"))}}_getCurrentLine(e,n){return e.substring(0,n).split(`
|
|
74
|
+
`).length-1}handleInput(e){this.updatePreview(),this._notifyChange()}handleFocus(e){this.options.onFocus&&this.options.onFocus(e,this)}handleBlur(e){this.options.onBlur&&this.options.onBlur(e,this)}handleKeydown(e){if(e.key==="Tab"){let o=this.textarea.selectionStart,i=this.textarea.selectionEnd,r=this.textarea.value;if(e.shiftKey&&o===i)return;if(e.preventDefault(),o!==i&&e.shiftKey){let s=r.substring(0,o),a=r.substring(o,i),l=r.substring(i),c=a.split(`
|
|
968
75
|
`).map(d=>d.replace(/^ /,"")).join(`
|
|
969
|
-
`);document.execCommand?(this.textarea.setSelectionRange(i
|
|
76
|
+
`);document.execCommand?(this.textarea.setSelectionRange(o,i),document.execCommand("insertText",!1,c)):(this.textarea.value=s+c+l,this.textarea.selectionStart=o,this.textarea.selectionEnd=o+c.length)}else if(o!==i){let s=r.substring(0,o),a=r.substring(o,i),l=r.substring(i),c=a.split(`
|
|
970
77
|
`).map(d=>" "+d).join(`
|
|
971
|
-
`);document.execCommand?(this.textarea.setSelectionRange(i
|
|
972
|
-
`+n),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}splitListItem(e,n){let
|
|
973
|
-
`+o
|
|
974
|
-
`),s=
|
|
975
|
-
`),a=0;for(let p=0;p<r.length&&a<n;p++){if(r[p]!==s[p]){let c=s[p].length-r[p].length;a+r[p].length<n&&(
|
|
976
|
-
`),
|
|
977
|
-
`),l=a.length,p=a[a.length-1].length+1;this.options.statsFormatter?this.statsBar.innerHTML=this.options.statsFormatter({chars:
|
|
78
|
+
`);document.execCommand?(this.textarea.setSelectionRange(o,i),document.execCommand("insertText",!1,c)):(this.textarea.value=s+c+l,this.textarea.selectionStart=o,this.textarea.selectionEnd=o+c.length)}else document.execCommand?document.execCommand("insertText",!1," "):(this.textarea.value=r.substring(0,o)+" "+r.substring(i),this.textarea.selectionStart=this.textarea.selectionEnd=o+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,n=e.selectionStart,o=C.getListContext(e.value,n);return!o||!o.inList?!1:o.content.trim()===""&&n>=o.markerEndPos?(this.deleteListMarker(o),!0):(n>o.markerEndPos&&n<o.lineEnd?this.splitListItem(o,n):this.insertNewListItem(o),o.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 n=C.createNewListItem(e);document.execCommand("insertText",!1,`
|
|
79
|
+
`+n),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}splitListItem(e,n){let o=e.content.substring(n-e.markerEndPos);this.textarea.setSelectionRange(n,e.lineEnd),document.execCommand("delete");let i=C.createNewListItem(e);document.execCommand("insertText",!1,`
|
|
80
|
+
`+i+o);let r=this.textarea.selectionStart-o.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,n=this.textarea.selectionStart,o=C.renumberLists(e);if(o!==e){let i=0,r=e.split(`
|
|
81
|
+
`),s=o.split(`
|
|
82
|
+
`),a=0;for(let p=0;p<r.length&&a<n;p++){if(r[p]!==s[p]){let c=s[p].length-r[p].length;a+r[p].length<n&&(i+=c)}a+=r[p].length+1}this.textarea.value=o;let l=n+i;this.textarea.setSelectionRange(l,l),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){let n=this.textarea.value!==e;this.textarea.value=e,this.updatePreview(),this.options.autoResize&&this._updateAutoHeight(),n&&this._notifyChange()}async performAction(e,n=null){var r;let o=this.textarea;if(!o)return!1;let i=(r=this.actionsById)==null?void 0:r[e];if(!i)return console.warn(`OverType: Unknown action "${e}"`),!1;o.focus();try{return await i({editor:this,getValue:()=>this.getValue(),setValue:s=>this.setValue(s),event:n}),!0}catch(s){return console.error(`OverType: Action "${e}" error:`,s),this.wrapper.dispatchEvent(new CustomEvent("button-error",{detail:{actionId:e,error:s}})),!1}}getRenderedHTML(e={}){let n=this.getValue(),o=C.parse(n,-1,!1,this.options.codeHighlighter);return e.cleanHTML&&(o=o.replace(/<span class="syntax-marker[^"]*">.*?<\/span>/g,""),o=o.replace(/\sclass="(bullet-list|ordered-list|code-fence|hr-marker|blockquote|url-part)"/g,""),o=o.replace(/\sclass=""/g,"")),o}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={}){var i;let n=(i=this.options)==null?void 0:i.toolbarButtons;this.options=this._mergeOptions({...this.options,...e});let o=this.toolbar&&this.options.toolbar&&mo(n,this.options.toolbarButtons);this._rebuildActionsMap(),o&&(this._cleanupToolbarListeners(),this.toolbar.destroy(),this.toolbar=null,this._createToolbar()),this.fileUploadInitialized&&this._destroyFileUpload(),this.options.fileUpload&&this._initFileUpload(),this._applyOptions(),this.updatePreview()}showToolbar(){this.toolbar?this.toolbar.show():this._createToolbar()}hideToolbar(){this.toolbar&&this.toolbar.hide()}setTheme(e){if(v._autoInstances.delete(this),this.instanceTheme=e,e==="auto")v._autoInstances.add(this),v._startAutoListener(),this._applyResolvedTheme(qe("auto"));else{let n=typeof e=="string"?U(e):e,o=typeof n=="string"?n:n.name;if(o&&this.container.setAttribute("data-theme",o),n&&n.colors){let i=Q(n.colors,n.previewColors);this.container.style.cssText+=i}this.updatePreview()}return v._stopAutoListener(),this}_applyResolvedTheme(e){let n=U(e);this.container.setAttribute("data-theme",e),n&&n.colors&&(this.container.style.cssText=Q(n.colors,n.previewColors)),this.updatePreview()}setCodeHighlighter(e){this.options.codeHighlighter=e,this.updatePreview()}_updateStats(){if(!this.statsBar)return;let e=this.textarea.value,n=e.split(`
|
|
83
|
+
`),o=e.length,i=e.split(/\s+/).filter(c=>c.length>0).length,r=this.textarea.selectionStart,a=e.substring(0,r).split(`
|
|
84
|
+
`),l=a.length,p=a[a.length-1].length+1;this.options.statsFormatter?this.statsBar.innerHTML=this.options.statsFormatter({chars:o,words:i,lines:n.length,line:l,column:p}):this.statsBar.innerHTML=`
|
|
978
85
|
<div class="overtype-stat">
|
|
979
86
|
<span class="live-dot"></span>
|
|
980
|
-
<span>${
|
|
87
|
+
<span>${o} chars, ${i} words, ${n.length} lines</span>
|
|
981
88
|
</div>
|
|
982
89
|
<div class="overtype-stat">Line ${l}, Col ${p}</div>
|
|
983
|
-
`}_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,n=this.preview,
|
|
90
|
+
`}_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,n=this.preview,o=this.wrapper;if(this.container.dataset.mode==="preview"){o.style.removeProperty("height"),n.style.removeProperty("height"),n.style.removeProperty("overflow-y"),e.style.removeProperty("height"),e.style.removeProperty("overflow-y");return}let r=e.scrollTop;o.style.setProperty("height","auto","important"),e.style.setProperty("height","auto","important");let s=e.scrollHeight;if(this.options.minHeight){let p=parseInt(this.options.minHeight);s=Math.max(s,p)}let a="hidden";if(this.options.maxHeight){let p=parseInt(this.options.maxHeight);s>p&&(s=p,a="auto")}let l=s+"px";e.style.setProperty("height",l,"important"),e.style.setProperty("overflow-y",a,"important"),n.style.setProperty("height",l,"important"),n.style.setProperty("overflow-y",a,"important"),o.style.setProperty("height",l,"important"),e.scrollTop=r,n.scrollTop=r,this.previousHeight!==s&&(this.previousHeight=s)}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._updateStats():!e&&this.statsBar&&(this.statsBar.remove(),this.statsBar=null)}showNormalEditMode(){return this.container.dataset.mode="normal",this.updatePreview(),this._updateAutoHeight(),requestAnimationFrame(()=>{this.textarea.scrollTop=this.preview.scrollTop,this.textarea.scrollLeft=this.preview.scrollLeft}),this}showPlainTextarea(){if(this.container.dataset.mode="plain",this._updateAutoHeight(),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.updatePreview(),this._updateAutoHeight(),this}destroy(){if(v._autoInstances.delete(this),v._stopAutoListener(),this.fileUploadInitialized&&this._destroyFileUpload(),this.element.overTypeInstance=null,v.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,n={}){return new v(e,n)}static initFromData(e,n={}){return v._resolveTargets(e).map(i=>{let r={...n};for(let s of i.attributes)if(s.name.startsWith("data-ot-")){let l=s.name.slice(8).replace(/-([a-z])/g,(p,c)=>c.toUpperCase());r[l]=v._parseDataValue(s.value)}return new v(i,r)[0]})}static _resolveTargets(e){if(e==null)throw new Error("Invalid target: must be selector string, Element, NodeList, or Array");if(typeof e=="string")return Array.from(document.querySelectorAll(e));if(e instanceof Element)return[e];if(e instanceof NodeList)return Array.from(e);if(Array.isArray(e))return e;if(typeof e.length=="number")return Array.from(e);throw new Error("Invalid target: must be selector string, Element, NodeList, or Array")}static _parseDataValue(e){return e==="true"?!0:e==="false"?!1:e==="null"?null:e!==""&&!isNaN(Number(e))?Number(e):e}static getInstance(e){let n;return e instanceof Element?n=e:n=v._resolveTargets(e)[0],n&&(n.overTypeInstance||v.instances.get(n))||null}static destroyAll(){document.querySelectorAll("[data-overtype-instance]").forEach(n=>{let o=v.getInstance(n);o&&o.destroy()})}static injectStyles(e=!1){if(v.stylesInjected&&!e)return;let n=document.querySelector("style.overtype-styles");n&&n.remove();let o=v.currentTheme||F,i=pt({theme:o}),r=document.createElement("style");r.className="overtype-styles",r.textContent=i,document.head.appendChild(r),v.stylesInjected=!0}static setTheme(e,n=null){if(v._globalAutoTheme=!1,v._globalAutoCustomColors=null,e==="auto"){v._globalAutoTheme=!0,v._globalAutoCustomColors=n,v._startAutoListener(),v._applyGlobalTheme(qe("auto"),n);return}v._stopAutoListener(),v._applyGlobalTheme(e,n)}static _applyGlobalTheme(e,n=null){let o=typeof e=="string"?U(e):e;n&&(o=ct(o,n)),v.currentTheme=o,v.injectStyles(!0);let i=typeof o=="string"?o:o.name;document.querySelectorAll(".overtype-container").forEach(r=>{i&&r.setAttribute("data-theme",i)}),document.querySelectorAll(".overtype-wrapper").forEach(r=>{r.closest(".overtype-container")||i&&r.setAttribute("data-theme",i);let s=r._instance;s&&s.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(r=>{i&&typeof r.setAttribute=="function"&&r.setAttribute("theme",i),typeof r.refreshTheme=="function"&&r.refreshTheme()})}static _startAutoListener(){v._autoMediaQuery||window.matchMedia&&(v._autoMediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),v._autoMediaListener=e=>{let n=e.matches?"cave":"solar";v._globalAutoTheme&&v._applyGlobalTheme(n,v._globalAutoCustomColors),v._autoInstances.forEach(o=>o._applyResolvedTheme(n))},v._autoMediaQuery.addEventListener("change",v._autoMediaListener))}static _stopAutoListener(){v._autoInstances.size>0||v._globalAutoTheme||v._autoMediaQuery&&(v._autoMediaQuery.removeEventListener("change",v._autoMediaListener),v._autoMediaQuery=null,v._autoMediaListener=null)}static setCodeHighlighter(e){C.setCodeHighlighter(e),document.querySelectorAll(".overtype-wrapper").forEach(n=>{let o=n._instance;o&&o.updatePreview&&o.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(n=>{if(typeof n.getEditor=="function"){let o=n.getEditor();o&&o.updatePreview&&o.updatePreview()}})}static setCustomSyntax(e){C.setCustomSyntax(e),document.querySelectorAll(".overtype-wrapper").forEach(n=>{let o=n._instance;o&&o.updatePreview&&o.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(n=>{if(typeof n.getEditor=="function"){let o=n.getEditor();o&&o.updatePreview&&o.updatePreview()}})}static initGlobalListeners(){v.globalListenersInitialized||(document.addEventListener("input",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let n=e.target.closest(".overtype-wrapper"),o=n==null?void 0:n._instance;o&&o.handleInput(e)}}),document.addEventListener("keydown",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let n=e.target.closest(".overtype-wrapper"),o=n==null?void 0:n._instance;o&&o.handleKeydown(e)}}),document.addEventListener("focus",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let n=e.target.closest(".overtype-wrapper"),o=n==null?void 0:n._instance;o&&o.handleFocus(e)}},!0),document.addEventListener("blur",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let n=e.target.closest(".overtype-wrapper"),o=n==null?void 0:n._instance;o&&o.handleBlur(e)}},!0),document.addEventListener("scroll",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let n=e.target.closest(".overtype-wrapper"),o=n==null?void 0:n._instance;o&&o.handleScroll(e)}},!0),document.addEventListener("selectionchange",e=>{let n=document.activeElement;if(n&&n.classList.contains("overtype-input")){let o=n.closest(".overtype-wrapper"),i=o==null?void 0:o._instance;i&&(i.options.showStats&&i.statsBar&&i._updateStats(),clearTimeout(i._selectionTimeout),i._selectionTimeout=setTimeout(()=>{i.updatePreview()},50))}}),v.globalListenersInitialized=!0)}};T(v,"instances",new WeakMap),T(v,"stylesInjected",!1),T(v,"globalListenersInitialized",!1),T(v,"instanceCount",0),T(v,"_autoMediaQuery",null),T(v,"_autoMediaListener",null),T(v,"_autoInstances",new Set),T(v,"_globalAutoTheme",!1),T(v,"_globalAutoCustomColors",null);var j=v;j.MarkdownParser=C;j.ShortcutsManager=ae;j.themes={solar:F,cave:U("cave")};j.getTheme=U;j.currentTheme=F;var go=j;return Ln(vo);})();
|
|
984
91
|
/**
|
|
985
92
|
* OverType - A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
986
93
|
* @version 1.0.0
|
|
@@ -991,6 +98,7 @@ if (typeof window !== "undefined" && typeof window.document !== "undefined") {
|
|
|
991
98
|
// Extract exports BEFORE reassigning OverType (var OverType is window.OverType)
|
|
992
99
|
window.toolbarButtons = OverType.toolbarButtons;
|
|
993
100
|
window.defaultToolbarButtons = OverType.defaultToolbarButtons;
|
|
101
|
+
window.markdownActions = OverType.markdownActions;
|
|
994
102
|
window.OverType = OverType.default ? OverType.default : OverType;
|
|
995
103
|
}
|
|
996
104
|
|