overtype 2.0.3 → 2.0.5
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 +1 -1
- package/dist/overtype-webcomponent.esm.js +46 -6
- package/dist/overtype-webcomponent.esm.js.map +2 -2
- package/dist/overtype-webcomponent.js +46 -6
- package/dist/overtype-webcomponent.js.map +2 -2
- package/dist/overtype-webcomponent.min.js +13 -10
- package/dist/overtype.cjs +43 -6
- package/dist/overtype.cjs.map +2 -2
- package/dist/overtype.d.ts +25 -19
- package/dist/overtype.esm.js +43 -6
- package/dist/overtype.esm.js.map +2 -2
- package/dist/overtype.js +43 -6
- package/dist/overtype.js.map +2 -2
- package/dist/overtype.min.js +6 -3
- package/package.json +3 -2
- package/src/overtype-webcomponent.js +5 -1
- package/src/overtype.d.ts +25 -19
- package/src/overtype.js +10 -0
- package/src/styles.js +3 -0
- package/src/themes.js +17 -3
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OverType v2.0.
|
|
2
|
+
* OverType v2.0.5
|
|
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 OverTypeEditor=(()=>{var N=Object.defineProperty;var Ne=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var
|
|
8
|
+
var OverTypeEditor=(()=>{var N=Object.defineProperty;var Ne=Object.getOwnPropertyDescriptor;var je=Object.getOwnPropertyNames;var Fe=Object.prototype.hasOwnProperty;var Re=(n,e,t)=>e in n?N(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Ve=(n,e)=>{for(var t in e)N(n,t,{get:e[t],enumerable:!0})},Ue=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of je(e))!Fe.call(n,o)&&o!==t&&N(n,o,{get:()=>e[o],enumerable:!(i=Ne(e,o))||i.enumerable});return n};var De=n=>Ue(N({},"__esModule",{value:!0}),n);var C=(n,e,t)=>(Re(n,typeof e!="symbol"?e+"":e,t),t);var st={};Ve(st,{default:()=>rt});var S=class{static resetLinkIndex(){this.linkIndex=0}static setCodeHighlighter(e){this.codeHighlighter=e}static escapeHtml(e){let t={"&":"&","<":"<",">":">",'"':""","'":"'"};return e.replace(/[&<>"']/g,i=>t[i])}static preserveIndentation(e,t){let o=t.match(/^(\s*)/)[1].replace(/ /g," ");return e.replace(/^\s*/,o)}static parseHeader(e){return e.replace(/^(#{1,3})\s(.+)$/,(t,i,o)=>{let r=i.length;return`<h${r}><span class="syntax-marker">${i} </span>${o}</h${r}>`})}static parseHorizontalRule(e){return e.match(/^(-{3,}|\*{3,}|_{3,})$/)?`<div><span class="hr-marker">${e}</span></div>`:null}static parseBlockquote(e){return e.replace(/^> (.+)$/,(t,i)=>`<span class="blockquote"><span class="syntax-marker">></span> ${i}</span>`)}static parseBulletList(e){return e.replace(/^((?: )*)([-*])\s(.+)$/,(t,i,o,r)=>`${i}<li class="bullet-list"><span class="syntax-marker">${o} </span>${r}</li>`)}static parseTaskList(e,t=!1){return e.replace(/^((?: )*)-\s+\[([ xX])\]\s+(.+)$/,(i,o,r,s)=>{if(t){let a=r.toLowerCase()==="x";return`${o}<li class="task-list"><input type="checkbox" ${a?"checked":""}> ${s}</li>`}else return`${o}<li class="task-list"><span class="syntax-marker">- [${r}] </span>${s}</li>`})}static parseNumberedList(e){return e.replace(/^((?: )*)(\d+\.)\s(.+)$/,(t,i,o,r)=>`${i}<li class="ordered-list"><span class="syntax-marker">${o} </span>${r}</li>`)}static parseCodeBlock(e){return/^`{3}[^`]*$/.test(e)?`<div><span class="code-fence">${e}</span></div>`:null}static parseBold(e){return e=e.replace(/\*\*(.+?)\*\*/g,'<strong><span class="syntax-marker">**</span>$1<span class="syntax-marker">**</span></strong>'),e=e.replace(/__(.+?)__/g,'<strong><span class="syntax-marker">__</span>$1<span class="syntax-marker">__</span></strong>'),e}static parseItalic(e){return e=e.replace(new RegExp("(?<!\\*)\\*(?!\\*)(.+?)(?<!\\*)\\*(?!\\*)","g"),'<em><span class="syntax-marker">*</span>$1<span class="syntax-marker">*</span></em>'),e=e.replace(new RegExp("(?<=^|\\s)_(?!_)(.+?)(?<!_)_(?!_)(?=\\s|$)","g"),'<em><span class="syntax-marker">_</span>$1<span class="syntax-marker">_</span></em>'),e}static parseStrikethrough(e){return e=e.replace(new RegExp("(?<!~)~~(?!~)(.+?)(?<!~)~~(?!~)","g"),'<del><span class="syntax-marker">~~</span>$1<span class="syntax-marker">~~</span></del>'),e=e.replace(new RegExp("(?<!~)~(?!~)(.+?)(?<!~)~(?!~)","g"),'<del><span class="syntax-marker">~</span>$1<span class="syntax-marker">~</span></del>'),e}static parseInlineCode(e){return e.replace(new RegExp("(?<!`)(`+)(?!`)((?:(?!\\1).)+?)(\\1)(?!`)","g"),'<code><span class="syntax-marker">$1</span>$2<span class="syntax-marker">$3</span></code>')}static sanitizeUrl(e){let t=e.trim(),i=t.toLowerCase(),r=["http://","https://","mailto:","ftp://","ftps://"].some(a=>i.startsWith(a)),s=t.startsWith("/")||t.startsWith("#")||t.startsWith("?")||t.startsWith(".")||!t.includes(":")&&!t.includes("//");return r||s?e:"#"}static parseLinks(e){return e.replace(/\[(.+?)\]\((.+?)\)/g,(t,i,o)=>{let r=`--link-${this.linkIndex++}`;return`<a href="${this.sanitizeUrl(o)}" style="anchor-name: ${r}"><span class="syntax-marker">[</span>${i}<span class="syntax-marker url-part">](${o})</span></a>`})}static identifyAndProtectSanctuaries(e){let t=new Map,i=0,o=e,r=[],s=/\[([^\]]+)\]\(([^)]+)\)/g,a;for(;(a=s.exec(e))!==null;){let h=a.index+a[0].indexOf("](")+2,u=h+a[2].length;r.push({start:h,end:u})}let p=new RegExp("(?<!`)(`+)(?!`)((?:(?!\\1).)+?)(\\1)(?!`)","g"),d,l=[];for(;(d=p.exec(e))!==null;){let c=d.index,h=d.index+d[0].length;r.some(f=>c>=f.start&&h<=f.end)||l.push({match:d[0],index:d.index,openTicks:d[1],content:d[2],closeTicks:d[3]})}return l.sort((c,h)=>h.index-c.index),l.forEach(c=>{let h=`\uE000${i++}\uE001`;t.set(h,{type:"code",original:c.match,openTicks:c.openTicks,content:c.content,closeTicks:c.closeTicks}),o=o.substring(0,c.index)+h+o.substring(c.index+c.match.length)}),o=o.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(c,h,u)=>{let f=`\uE000${i++}\uE001`;return t.set(f,{type:"link",original:c,linkText:h,url:u}),f}),{protectedText:o,sanctuaries:t}}static restoreAndTransformSanctuaries(e,t){return Array.from(t.keys()).sort((o,r)=>{let s=e.indexOf(o),a=e.indexOf(r);return s-a}).forEach(o=>{let r=t.get(o),s;if(r.type==="code")s=`<code><span class="syntax-marker">${r.openTicks}</span>${r.content}<span class="syntax-marker">${r.closeTicks}</span></code>`;else if(r.type==="link"){let a=r.linkText;t.forEach((l,c)=>{if(a.includes(c)&&l.type==="code"){let h=`<code><span class="syntax-marker">${l.openTicks}</span>${l.content}<span class="syntax-marker">${l.closeTicks}</span></code>`;a=a.replace(c,h)}}),a=this.parseStrikethrough(a),a=this.parseBold(a),a=this.parseItalic(a);let p=`--link-${this.linkIndex++}`;s=`<a href="${this.sanitizeUrl(r.url)}" style="anchor-name: ${p}"><span class="syntax-marker">[</span>${a}<span class="syntax-marker url-part">](${r.url})</span></a>`}e=e.replace(o,s)}),e}static parseInlineElements(e){let{protectedText:t,sanctuaries:i}=this.identifyAndProtectSanctuaries(e),o=t;return o=this.parseStrikethrough(o),o=this.parseBold(o),o=this.parseItalic(o),o=this.restoreAndTransformSanctuaries(o,i),o}static parseLine(e,t=!1){let i=this.escapeHtml(e);i=this.preserveIndentation(i,e);let o=this.parseHorizontalRule(i);if(o)return o;let r=this.parseCodeBlock(i);return r||(i=this.parseHeader(i),i=this.parseBlockquote(i),i=this.parseTaskList(i,t),i=this.parseBulletList(i),i=this.parseNumberedList(i),i=this.parseInlineElements(i),i.trim()===""?"<div> </div>":`<div>${i}</div>`)}static parse(e,t=-1,i=!1,o,r=!1){this.resetLinkIndex();let s=e.split(`
|
|
9
9
|
`),a=!1,d=s.map((l,c)=>{if(i&&c===t)return`<div class="raw-line">${this.escapeHtml(l)||" "}</div>`;if(/^```[^`]*$/.test(l))return a=!a,this.parseLine(l,r);if(a){let u=this.escapeHtml(l);return`<div>${this.preserveIndentation(u,l)||" "}</div>`}return this.parseLine(l,r)}).join("");return this.postProcessHTML(d,o)}static postProcessHTML(e,t){if(typeof document>"u"||!document)return this.postProcessHTMLManual(e,t);let i=document.createElement("div");i.innerHTML=e;let o=null,r=null,s=null,a=!1,p=Array.from(i.children);for(let d=0;d<p.length;d++){let l=p[d];if(!l.parentNode)continue;let c=l.querySelector(".code-fence");if(c){let u=c.textContent;if(u.startsWith("```"))if(a){let f=t||this.codeHighlighter;if(s&&f&&s._codeContent)try{let m=f(s._codeContent,s._language||"");m&&typeof m.then=="function"?console.warn("Async highlighters are not supported in parse() because it returns an HTML string. The caller creates new DOM elements from that string, breaking references to the elements we would update. Use synchronous highlighters only."):m&&typeof m=="string"&&m.trim()&&(s._codeElement.innerHTML=m)}catch(m){console.warn("Code highlighting failed:",m)}a=!1,s=null;continue}else{a=!0,s=document.createElement("pre");let f=document.createElement("code");s.appendChild(f),s.className="code-block";let m=u.slice(3).trim();m&&(f.className=`language-${m}`),i.insertBefore(s,l.nextSibling),s._codeElement=f,s._language=m,s._codeContent="";continue}}if(a&&s&&l.tagName==="DIV"&&!l.querySelector(".code-fence")){let u=s._codeElement||s.querySelector("code");s._codeContent.length>0&&(s._codeContent+=`
|
|
10
10
|
`);let f=l.textContent.replace(/\u00A0/g," ");s._codeContent+=f,u.textContent.length>0&&(u.textContent+=`
|
|
11
11
|
`),u.textContent+=f,l.remove();continue}let h=null;if(l.tagName==="DIV"&&(h=l.querySelector("li")),h){let u=h.classList.contains("bullet-list"),f=h.classList.contains("ordered-list");if(!u&&!f){o=null,r=null;continue}let m=u?"ul":"ol";(!o||r!==m)&&(o=document.createElement(m),i.insertBefore(o,l),r=m);let g=[];for(let v of l.childNodes)if(v.nodeType===3&&v.textContent.match(/^\u00A0+$/))g.push(v.cloneNode(!0));else if(v===h)break;g.forEach(v=>{h.insertBefore(v,h.firstChild)}),o.appendChild(h),l.remove()}else o=null,r=null}return i.innerHTML}static postProcessHTMLManual(e,t){let i=e;i=i.replace(/((?:<div>(?: )*<li class="bullet-list">.*?<\/li><\/div>\s*)+)/gs,r=>{let s=r.match(/<div>(?: )*<li class="bullet-list">.*?<\/li><\/div>/gs)||[];return s.length>0?"<ul>"+s.map(p=>{let d=p.match(/<div>((?: )*)<li/),l=p.match(/<li class="bullet-list">.*?<\/li>/);if(d&&l){let c=d[1];return l[0].replace(/<li class="bullet-list">/,`<li class="bullet-list">${c}`)}return l?l[0]:""}).filter(Boolean).join("")+"</ul>":r}),i=i.replace(/((?:<div>(?: )*<li class="ordered-list">.*?<\/li><\/div>\s*)+)/gs,r=>{let s=r.match(/<div>(?: )*<li class="ordered-list">.*?<\/li><\/div>/gs)||[];return s.length>0?"<ol>"+s.map(p=>{let d=p.match(/<div>((?: )*)<li/),l=p.match(/<li class="ordered-list">.*?<\/li>/);if(d&&l){let c=d[1];return l[0].replace(/<li class="ordered-list">/,`<li class="ordered-list">${c}`)}return l?l[0]:""}).filter(Boolean).join("")+"</ol>":r});let o=/<div><span class="code-fence">(```[^<]*)<\/span><\/div>(.*?)<div><span class="code-fence">(```)<\/span><\/div>/gs;return i=i.replace(o,(r,s,a,p)=>{let l=(a.match(/<div>(.*?)<\/div>/gs)||[]).map(g=>g.replace(/<div>(.*?)<\/div>/s,"$1").replace(/ /g," ")).join(`
|
|
12
12
|
`),c=s.slice(3).trim(),h=c?` class="language-${c}"`:"",u=l,f=t||this.codeHighlighter;if(f)try{let g=l.replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"),v=f(g,c);v&&typeof v.then=="function"?console.warn("Async highlighters are not supported in Node.js (non-DOM) context. Use synchronous highlighters for server-side rendering."):v&&typeof v=="string"&&v.trim()&&(u=v)}catch(g){console.warn("Code highlighting failed:",g)}let m=`<div><span class="code-fence">${s}</span></div>`;return m+=`<pre class="code-block"><code${h}>${u}</code></pre>`,m+=`<div><span class="code-fence">${p}</span></div>`,m}),i}static getListContext(e,t){let i=e.split(`
|
|
13
13
|
`),o=0,r=0,s=0;for(let h=0;h<i.length;h++){let u=i[h].length;if(o+u>=t){r=h,s=o;break}o+=u+1}let a=i[r],p=s+a.length,d=a.match(this.LIST_PATTERNS.checkbox);if(d)return{inList:!0,listType:"checkbox",indent:d[1],marker:"-",checked:d[2]==="x",content:d[3],lineStart:s,lineEnd:p,markerEndPos:s+d[1].length+d[2].length+5};let l=a.match(this.LIST_PATTERNS.bullet);if(l)return{inList:!0,listType:"bullet",indent:l[1],marker:l[2],content:l[3],lineStart:s,lineEnd:p,markerEndPos:s+l[1].length+l[2].length+1};let c=a.match(this.LIST_PATTERNS.numbered);return c?{inList:!0,listType:"numbered",indent:c[1],marker:parseInt(c[2]),content:c[3],lineStart:s,lineEnd:p,markerEndPos:s+c[1].length+c[2].length+2}:{inList:!1,listType:null,indent:"",marker:null,content:a,lineStart:s,lineEnd:p,markerEndPos:s}}static createNewListItem(e){switch(e.listType){case"bullet":return`${e.indent}${e.marker} `;case"numbered":return`${e.indent}${e.marker+1}. `;case"checkbox":return`${e.indent}- [ ] `;default:return""}}static renumberLists(e){let t=e.split(`
|
|
14
14
|
`),i=new Map,o=!1;return t.map(s=>{let a=s.match(this.LIST_PATTERNS.numbered);if(a){let p=a[1],d=p.length,l=a[3];o||i.clear();let c=(i.get(d)||0)+1;i.set(d,c);for(let[h]of i)h>d&&i.delete(h);return o=!0,`${p}${c}. ${l}`}else return(s.trim()===""||!s.match(/^\s/))&&(o=!1,i.clear()),s}).join(`
|
|
15
|
-
`)}};C(S,"linkIndex",0),C(S,"codeHighlighter",null),C(S,"LIST_PATTERNS",{bullet:/^(\s*)([-*+])\s+(.*)$/,numbered:/^(\s*)(\d+)\.\s+(.*)$/,checkbox:/^(\s*)-\s+\[([ x])\]\s+(.*)$/});var qe=Object.defineProperty,re=Object.getOwnPropertySymbols,We=Object.prototype.hasOwnProperty,Ke=Object.prototype.propertyIsEnumerable,se=(n,e,t)=>e in n?qe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ae=(n,e)=>{for(var t in e||(e={}))We.call(e,t)&&se(n,t,e[t]);if(re)for(var t of re(e))Ke.call(e,t)&&se(n,t,e[t]);return n},E={bold:{prefix:"**",suffix:"**",trimFirst:!0},italic:{prefix:"_",suffix:"_",trimFirst:!0},code:{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"},link:{prefix:"[",suffix:"](url)",replaceNext:"url",scanFor:"https?://"},bulletList:{prefix:"- ",multiline:!0,unorderedList:!0},numberedList:{prefix:"1. ",multiline:!0,orderedList:!0},quote:{prefix:"> ",multiline:!0,surroundWithNewlines:!0},taskList:{prefix:"- [ ] ",multiline:!0,surroundWithNewlines:!0},header1:{prefix:"# "},header2:{prefix:"## "},header3:{prefix:"### "},header4:{prefix:"#### "},header5:{prefix:"##### "},header6:{prefix:"###### "}};function Ze(){return{prefix:"",suffix:"",blockPrefix:"",blockSuffix:"",multiline:!1,replaceNext:"",prefixSpace:!1,scanFor:"",surroundWithNewlines:!1,orderedList:!1,unorderedList:!1,trimFirst:!1}}function A(n){return ae(ae({},Ze()),n)}var
|
|
15
|
+
`)}};C(S,"linkIndex",0),C(S,"codeHighlighter",null),C(S,"LIST_PATTERNS",{bullet:/^(\s*)([-*+])\s+(.*)$/,numbered:/^(\s*)(\d+)\.\s+(.*)$/,checkbox:/^(\s*)-\s+\[([ x])\]\s+(.*)$/});var qe=Object.defineProperty,re=Object.getOwnPropertySymbols,We=Object.prototype.hasOwnProperty,Ke=Object.prototype.propertyIsEnumerable,se=(n,e,t)=>e in n?qe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ae=(n,e)=>{for(var t in e||(e={}))We.call(e,t)&&se(n,t,e[t]);if(re)for(var t of re(e))Ke.call(e,t)&&se(n,t,e[t]);return n},E={bold:{prefix:"**",suffix:"**",trimFirst:!0},italic:{prefix:"_",suffix:"_",trimFirst:!0},code:{prefix:"`",suffix:"`",blockPrefix:"```",blockSuffix:"```"},link:{prefix:"[",suffix:"](url)",replaceNext:"url",scanFor:"https?://"},bulletList:{prefix:"- ",multiline:!0,unorderedList:!0},numberedList:{prefix:"1. ",multiline:!0,orderedList:!0},quote:{prefix:"> ",multiline:!0,surroundWithNewlines:!0},taskList:{prefix:"- [ ] ",multiline:!0,surroundWithNewlines:!0},header1:{prefix:"# "},header2:{prefix:"## "},header3:{prefix:"### "},header4:{prefix:"#### "},header5:{prefix:"##### "},header6:{prefix:"###### "}};function Ze(){return{prefix:"",suffix:"",blockPrefix:"",blockSuffix:"",multiline:!1,replaceNext:"",prefixSpace:!1,scanFor:"",surroundWithNewlines:!1,orderedList:!1,unorderedList:!1,trimFirst:!1}}function A(n){return ae(ae({},Ze()),n)}var F=!1;function Je(){return F}function y(n,e,t){F&&(console.group(`\u{1F50D} ${n}`),console.log(e),t&&console.log("Data:",t),console.groupEnd())}function j(n,e){if(!F)return;let t=n.value.slice(n.selectionStart,n.selectionEnd);console.group(`\u{1F4CD} Selection: ${e}`),console.log("Position:",`${n.selectionStart}-${n.selectionEnd}`),console.log("Selected text:",JSON.stringify(t)),console.log("Length:",t.length);let i=n.value.slice(Math.max(0,n.selectionStart-10),n.selectionStart),o=n.value.slice(n.selectionEnd,Math.min(n.value.length,n.selectionEnd+10));console.log("Context:",JSON.stringify(i)+"[SELECTION]"+JSON.stringify(o)),console.groupEnd()}function de(n){F&&(console.group("\u{1F4DD} Result"),console.log("Text to insert:",JSON.stringify(n.text)),console.log("New selection:",`${n.selectionStart}-${n.selectionEnd}`),console.groupEnd())}var T=null;function M(n,{text:e,selectionStart:t,selectionEnd:i}){let o=Je();o&&(console.group("\u{1F527} insertText"),console.log("Current selection:",`${n.selectionStart}-${n.selectionEnd}`),console.log("Text to insert:",JSON.stringify(e)),console.log("New selection to set:",t,"-",i)),n.focus();let r=n.selectionStart,s=n.selectionEnd,a=n.value.slice(0,r),p=n.value.slice(s);o&&(console.log("Before text (last 20):",JSON.stringify(a.slice(-20))),console.log("After text (first 20):",JSON.stringify(p.slice(0,20))),console.log("Selected text being replaced:",JSON.stringify(n.value.slice(r,s))));let d=n.value,l=r!==s;if(T===null||T===!0){n.contentEditable="true";try{T=document.execCommand("insertText",!1,e),o&&console.log("execCommand returned:",T,"for text with",e.split(`
|
|
16
16
|
`).length,"lines")}catch(c){T=!1,o&&console.log("execCommand threw error:",c)}n.contentEditable="false"}if(o&&(console.log("canInsertText before:",T),console.log("execCommand result:",T)),T){let c=a+e+p,h=n.value;o&&(console.log("Expected length:",c.length),console.log("Actual length:",h.length)),h!==c&&o&&(console.log("execCommand changed the value but not as expected"),console.log("Expected:",JSON.stringify(c.slice(0,100))),console.log("Actual:",JSON.stringify(h.slice(0,100))))}if(!T)if(o&&console.log("Using manual insertion"),n.value===d){o&&console.log("Value unchanged, doing manual replacement");try{document.execCommand("ms-beginUndoUnit")}catch(c){}n.value=a+e+p;try{document.execCommand("ms-endUndoUnit")}catch(c){}n.dispatchEvent(new CustomEvent("input",{bubbles:!0,cancelable:!0}))}else o&&console.log("Value was changed by execCommand, skipping manual insertion");o&&console.log("Setting selection range:",t,i),t!=null&&i!=null?n.setSelectionRange(t,i):n.setSelectionRange(r,n.selectionEnd),o&&(console.log("Final value length:",n.value.length),console.groupEnd())}function le(n){return n.trim().split(`
|
|
17
17
|
`).length>1}function Ge(n,e){let t=e;for(;n[t]&&n[t-1]!=null&&!n[t-1].match(/\s/);)t--;return t}function Qe(n,e,t){let i=e,o=t?/\n/:/\s/;for(;n[i]&&!n[i].match(o);)i++;return i}function he(n){let e=n.value.split(`
|
|
18
18
|
`),t=0;for(let i=0;i<e.length;i++){let o=e[i].length+1;n.selectionStart>=t&&n.selectionStart<t+o&&(n.selectionStart=t),n.selectionEnd>=t&&n.selectionEnd<t+o&&(i===e.length-1?n.selectionEnd=Math.min(t+e[i].length,n.value.length):n.selectionEnd=t+o-1),t+=o}}function Xe(n,e,t,i=!1){if(n.selectionStart===n.selectionEnd)n.selectionStart=Ge(n.value,n.selectionStart),n.selectionEnd=Qe(n.value,n.selectionEnd,i);else{let o=n.selectionStart-e.length,r=n.selectionEnd+t.length,s=n.value.slice(o,n.selectionStart)===e,a=n.value.slice(n.selectionEnd,r)===t;s&&a&&(n.selectionStart=o,n.selectionEnd=r)}return n.value.slice(n.selectionStart,n.selectionEnd)}function X(n){let e=n.value.slice(0,n.selectionStart),t=n.value.slice(n.selectionEnd),i=e.match(/\n*$/),o=t.match(/^\n*/),r=i?i[0].length:0,s=o?o[0].length:0,a="",p="";return e.match(/\S/)&&r<2&&(a=`
|
|
19
19
|
`.repeat(2-r)),t.match(/\S/)&&s<2&&(p=`
|
|
20
|
-
`.repeat(2-s)),{newlinesToAppend:a,newlinesToPrepend:p}}function
|
|
20
|
+
`.repeat(2-s)),{newlinesToAppend:a,newlinesToPrepend:p}}function R(n,e,t={}){let i=n.selectionStart,o=n.selectionEnd,r=i===o,s=n.value,a=i;for(;a>0&&s[a-1]!==`
|
|
21
21
|
`;)a--;if(r){let d=i;for(;d<s.length&&s[d]!==`
|
|
22
22
|
`;)d++;n.selectionStart=a,n.selectionEnd=d}else he(n);let p=e(n);if(t.adjustSelection){let l=n.value.slice(n.selectionStart,n.selectionEnd).startsWith(t.prefix),c=t.adjustSelection(l,i,o,a);p.selectionStart=c.start,p.selectionEnd=c.end}else if(t.prefix){let l=n.value.slice(n.selectionStart,n.selectionEnd).startsWith(t.prefix);r?l?(p.selectionStart=Math.max(i-t.prefix.length,a),p.selectionEnd=p.selectionStart):(p.selectionStart=i+t.prefix.length,p.selectionEnd=p.selectionStart):l?(p.selectionStart=Math.max(i-t.prefix.length,a),p.selectionEnd=Math.max(o-t.prefix.length,a)):(p.selectionStart=i+t.prefix.length,p.selectionEnd=o+t.prefix.length)}return p}function V(n,e){let t,i,{prefix:o,suffix:r,blockPrefix:s,blockSuffix:a,replaceNext:p,prefixSpace:d,scanFor:l,surroundWithNewlines:c,trimFirst:h}=e,u=n.selectionStart,f=n.selectionEnd,m=n.value.slice(n.selectionStart,n.selectionEnd),g=le(m)&&s&&s.length>0?`${s}
|
|
23
23
|
`:o,v=le(m)&&a&&a.length>0?`
|
|
24
|
-
${a}`:r;if(d){let L=n.value[n.selectionStart-1];n.selectionStart!==0&&L!=null&&!L.match(/\s/)&&(g=` ${g}`)}m=Xe(n,g,v,e.multiline);let b=n.selectionStart,
|
|
24
|
+
${a}`:r;if(d){let L=n.value[n.selectionStart-1];n.selectionStart!==0&&L!=null&&!L.match(/\s/)&&(g=` ${g}`)}m=Xe(n,g,v,e.multiline);let b=n.selectionStart,x=n.selectionEnd,$=p&&p.length>0&&v.indexOf(p)>-1&&m.length>0;if(c){let L=X(n);t=L.newlinesToAppend,i=L.newlinesToPrepend,g=t+o,v+=i}if(m.startsWith(g)&&m.endsWith(v)){let L=m.slice(g.length,m.length-v.length);if(u===f){let _=u-g.length;_=Math.max(_,b),_=Math.min(_,b+L.length),b=x=_}else x=b+L.length;return{text:L,selectionStart:b,selectionEnd:x}}else if($)if(l&&l.length>0&&m.match(l)){v=v.replace(p,m);let L=g+v;return b=x=b+g.length,{text:L,selectionStart:b,selectionEnd:x}}else{let L=g+m+v;return b=b+g.length+m.length+v.indexOf(p),x=b+p.length,{text:L,selectionStart:b,selectionEnd:x}}else{let L=g+m+v;b=u+g.length,x=f+g.length;let _=m.match(/^\s*|\s*$/g);if(h&&_){let ne=_[0]||"",oe=_[1]||"";L=ne+g+m.trim()+v+oe,b+=ne.length,x-=oe.length}return{text:L,selectionStart:b,selectionEnd:x}}}function ue(n,e){let{prefix:t,suffix:i,surroundWithNewlines:o}=e,r=n.value.slice(n.selectionStart,n.selectionEnd),s=n.selectionStart,a=n.selectionEnd,p=r.split(`
|
|
25
25
|
`);if(p.every(l=>l.startsWith(t)&&(!i||l.endsWith(i))))r=p.map(l=>{let c=l.slice(t.length);return i&&(c=c.slice(0,c.length-i.length)),c}).join(`
|
|
26
26
|
`),a=s+r.length;else if(r=p.map(l=>t+l+(i||"")).join(`
|
|
27
27
|
`),o){let{newlinesToAppend:l,newlinesToPrepend:c}=X(n);s+=l.length,a=s+r.length,r=l+r+c}return{text:r,selectionStart:s,selectionEnd:a}}function ce(n){let e=n.split(`
|
|
@@ -30,10 +30,10 @@ ${a}`:r;if(d){let L=n.value[n.selectionStart-1];n.selectionStart!==0&&L!=null&&!
|
|
|
30
30
|
`),t="- ",i=e.every(r=>r.startsWith(t)),o=e;return i&&(o=e.map(r=>r.slice(t.length))),{text:o.join(`
|
|
31
31
|
`),processed:i}}function z(n,e){return e?"- ":`${n+1}. `}function Ye(n,e){let t,i,o;return n.orderedList?(t=ce(e),i=pe(t.text),o=i.text):(t=pe(e),i=ce(t.text),o=i.text),[t,i,o]}function et(n,e){let t=n.selectionStart===n.selectionEnd,i=n.selectionStart,o=n.selectionEnd;he(n);let r=n.value.slice(n.selectionStart,n.selectionEnd),[s,a,p]=Ye(e,r),d=p.split(`
|
|
32
32
|
`).map((m,g)=>`${z(g,e.unorderedList)}${m}`),l=d.reduce((m,g,v)=>m+z(v,e.unorderedList).length,0),c=d.reduce((m,g,v)=>m+z(v,!e.unorderedList).length,0);if(s.processed)return t?(i=Math.max(i-z(0,e.unorderedList).length,0),o=i):(i=n.selectionStart,o=n.selectionEnd-l),{text:p,selectionStart:i,selectionEnd:o};let{newlinesToAppend:h,newlinesToPrepend:u}=X(n),f=h+d.join(`
|
|
33
|
-
`)+u;return t?(i=Math.max(i+z(0,e.unorderedList).length+h.length,0),o=i):a.processed?(i=Math.max(n.selectionStart+h.length,0),o=n.selectionEnd+h.length+l-c):(i=Math.max(n.selectionStart+h.length,0),o=n.selectionEnd+h.length+l),{text:f,selectionStart:i,selectionEnd:o}}function me(n,e){let t=
|
|
34
|
-
`),s=0,a="";for(let c of r){if(t>=s&&t<=s+c.length){a=c;break}s+=c.length+1}a.startsWith("- ")&&(a.startsWith("- [ ] ")||a.startsWith("- [x] ")?e.push("task-list"):e.push("bullet-list")),/^\d+\.\s/.test(a)&&e.push("numbered-list"),a.startsWith("> ")&&e.push("quote"),a.startsWith("# ")&&e.push("header"),a.startsWith("## ")&&e.push("header-2"),a.startsWith("### ")&&e.push("header-3");let p=Math.max(0,t-10),d=Math.min(o.length,i+10),l=o.slice(p,d);if(l.includes("**")){let c=o.slice(Math.max(0,t-100),t),h=o.slice(i,Math.min(o.length,i+100)),u=c.lastIndexOf("**"),f=h.indexOf("**");u!==-1&&f!==-1&&e.push("bold")}if(l.includes("_")){let c=o.slice(Math.max(0,t-100),t),h=o.slice(i,Math.min(o.length,i+100)),u=c.lastIndexOf("_"),f=h.indexOf("_");u!==-1&&f!==-1&&e.push("italic")}if(l.includes("`")){let c=o.slice(Math.max(0,t-100),t),h=o.slice(i,Math.min(o.length,i+100));c.includes("`")&&h.includes("`")&&e.push("code")}if(l.includes("[")&&l.includes("]")){let c=o.slice(Math.max(0,t-100),t),h=o.slice(i,Math.min(o.length,i+100)),u=c.lastIndexOf("["),f=h.indexOf("]");u!==-1&&f!==-1&&o.slice(i+f+1,i+f+10).startsWith("(")&&e.push("link")}return e}function U(n){if(!n||n.disabled||n.readOnly)return;y("toggleBold","Starting"),j(n,"Before");let e=A(E.bold),t=V(n,e);de(t),M(n,t),j(n,"After")}function D(n){if(!n||n.disabled||n.readOnly)return;let e=A(E.italic),t=V(n,e);M(n,t)}function fe(n){if(!n||n.disabled||n.readOnly)return;let e=A(E.code),t=V(n,e);M(n,t)}function q(n,e={}){if(!n||n.disabled||n.readOnly)return;let t=n.value.slice(n.selectionStart,n.selectionEnd),i=A(E.link);if(t&&t.match(/^https?:\/\//)&&!e.url?(i.suffix=`](${t})`,i.replaceNext=""):e.url&&(i.suffix=`](${e.url})`,i.replaceNext=""),e.text&&!t){let s=n.selectionStart;n.value=n.value.slice(0,s)+e.text+n.value.slice(s),n.selectionStart=s,n.selectionEnd=s+e.text.length}let r=V(n,i);M(n,r)}function W(n){if(!n||n.disabled||n.readOnly)return;let e=A(E.bulletList);me(n,e)}function K(n){if(!n||n.disabled||n.readOnly)return;let e=A(E.numberedList);me(n,e)}function ge(n){if(!n||n.disabled||n.readOnly)return;y("toggleQuote","Starting"),j(n,"Initial");let e=A(E.quote),t=
|
|
33
|
+
`)+u;return t?(i=Math.max(i+z(0,e.unorderedList).length+h.length,0),o=i):a.processed?(i=Math.max(n.selectionStart+h.length,0),o=n.selectionEnd+h.length+l-c):(i=Math.max(n.selectionStart+h.length,0),o=n.selectionEnd+h.length+l),{text:f,selectionStart:i,selectionEnd:o}}function me(n,e){let t=R(n,i=>et(i,e),{adjustSelection:(i,o,r,s)=>{let a=n.value.slice(s,n.selectionEnd),p=/^\d+\.\s+/,d=/^- /,l=p.test(a),c=d.test(a),h=e.orderedList&&l||e.unorderedList&&c;if(o===r)if(h){let u=a.match(e.orderedList?p:d),f=u?u[0].length:0;return{start:Math.max(o-f,s),end:Math.max(o-f,s)}}else if(l||c){let u=a.match(l?p:d),f=u?u[0].length:0,g=(e.unorderedList?2:3)-f;return{start:o+g,end:o+g}}else{let u=e.unorderedList?2:3;return{start:o+u,end:o+u}}else if(h){let u=a.match(e.orderedList?p:d),f=u?u[0].length:0;return{start:Math.max(o-f,s),end:Math.max(r-f,s)}}else if(l||c){let u=a.match(l?p:d),f=u?u[0].length:0,g=(e.unorderedList?2:3)-f;return{start:o+g,end:r+g}}else{let u=e.unorderedList?2:3;return{start:o+u,end:r+u}}}});M(n,t)}function tt(n){if(!n)return[];let e=[],{selectionStart:t,selectionEnd:i,value:o}=n,r=o.split(`
|
|
34
|
+
`),s=0,a="";for(let c of r){if(t>=s&&t<=s+c.length){a=c;break}s+=c.length+1}a.startsWith("- ")&&(a.startsWith("- [ ] ")||a.startsWith("- [x] ")?e.push("task-list"):e.push("bullet-list")),/^\d+\.\s/.test(a)&&e.push("numbered-list"),a.startsWith("> ")&&e.push("quote"),a.startsWith("# ")&&e.push("header"),a.startsWith("## ")&&e.push("header-2"),a.startsWith("### ")&&e.push("header-3");let p=Math.max(0,t-10),d=Math.min(o.length,i+10),l=o.slice(p,d);if(l.includes("**")){let c=o.slice(Math.max(0,t-100),t),h=o.slice(i,Math.min(o.length,i+100)),u=c.lastIndexOf("**"),f=h.indexOf("**");u!==-1&&f!==-1&&e.push("bold")}if(l.includes("_")){let c=o.slice(Math.max(0,t-100),t),h=o.slice(i,Math.min(o.length,i+100)),u=c.lastIndexOf("_"),f=h.indexOf("_");u!==-1&&f!==-1&&e.push("italic")}if(l.includes("`")){let c=o.slice(Math.max(0,t-100),t),h=o.slice(i,Math.min(o.length,i+100));c.includes("`")&&h.includes("`")&&e.push("code")}if(l.includes("[")&&l.includes("]")){let c=o.slice(Math.max(0,t-100),t),h=o.slice(i,Math.min(o.length,i+100)),u=c.lastIndexOf("["),f=h.indexOf("]");u!==-1&&f!==-1&&o.slice(i+f+1,i+f+10).startsWith("(")&&e.push("link")}return e}function U(n){if(!n||n.disabled||n.readOnly)return;y("toggleBold","Starting"),j(n,"Before");let e=A(E.bold),t=V(n,e);de(t),M(n,t),j(n,"After")}function D(n){if(!n||n.disabled||n.readOnly)return;let e=A(E.italic),t=V(n,e);M(n,t)}function fe(n){if(!n||n.disabled||n.readOnly)return;let e=A(E.code),t=V(n,e);M(n,t)}function q(n,e={}){if(!n||n.disabled||n.readOnly)return;let t=n.value.slice(n.selectionStart,n.selectionEnd),i=A(E.link);if(t&&t.match(/^https?:\/\//)&&!e.url?(i.suffix=`](${t})`,i.replaceNext=""):e.url&&(i.suffix=`](${e.url})`,i.replaceNext=""),e.text&&!t){let s=n.selectionStart;n.value=n.value.slice(0,s)+e.text+n.value.slice(s),n.selectionStart=s,n.selectionEnd=s+e.text.length}let r=V(n,i);M(n,r)}function W(n){if(!n||n.disabled||n.readOnly)return;let e=A(E.bulletList);me(n,e)}function K(n){if(!n||n.disabled||n.readOnly)return;let e=A(E.numberedList);me(n,e)}function ge(n){if(!n||n.disabled||n.readOnly)return;y("toggleQuote","Starting"),j(n,"Initial");let e=A(E.quote),t=R(n,i=>ue(i,e),{prefix:e.prefix});de(t),M(n,t),j(n,"Final")}function Y(n){if(!n||n.disabled||n.readOnly)return;let e=A(E.taskList),t=R(n,i=>ue(i,e),{prefix:e.prefix});M(n,t)}function ee(n,e=1,t=!1){if(!n||n.disabled||n.readOnly)return;(e<1||e>6)&&(e=1),y("insertHeader","============ START ============"),y("insertHeader",`Level: ${e}, Toggle: ${t}`),y("insertHeader",`Initial cursor: ${n.selectionStart}-${n.selectionEnd}`);let i=`header${e===1?"1":e}`,o=A(E[i]||E.header1);y("insertHeader",`Style prefix: "${o.prefix}"`);let r=n.value,s=n.selectionStart,a=n.selectionEnd,p=s;for(;p>0&&r[p-1]!==`
|
|
35
35
|
`;)p--;let d=a;for(;d<r.length&&r[d]!==`
|
|
36
|
-
`;)d++;let l=r.slice(p,d);y("insertHeader",`Current line (before): "${l}"`);let c=l.match(/^(#{1,6})\s*/),h=c?c[1].length:0,u=c?c[0].length:0;y("insertHeader","Existing header check:"),y("insertHeader",` - Match: ${c?`"${c[0]}"`:"none"}`),y("insertHeader",` - Existing level: ${h}`),y("insertHeader",` - Existing prefix length: ${u}`),y("insertHeader",` - Target level: ${e}`);let f=t&&h===e;y("insertHeader",`Should toggle OFF: ${f} (toggle=${t}, existingLevel=${h}, level=${e})`);let m=
|
|
36
|
+
`;)d++;let l=r.slice(p,d);y("insertHeader",`Current line (before): "${l}"`);let c=l.match(/^(#{1,6})\s*/),h=c?c[1].length:0,u=c?c[0].length:0;y("insertHeader","Existing header check:"),y("insertHeader",` - Match: ${c?`"${c[0]}"`:"none"}`),y("insertHeader",` - Existing level: ${h}`),y("insertHeader",` - Existing prefix length: ${u}`),y("insertHeader",` - Target level: ${e}`);let f=t&&h===e;y("insertHeader",`Should toggle OFF: ${f} (toggle=${t}, existingLevel=${h}, level=${e})`);let m=R(n,g=>{let v=g.value.slice(g.selectionStart,g.selectionEnd);y("insertHeader",`Line in operation: "${v}"`);let b=v.replace(/^#{1,6}\s*/,"");y("insertHeader",`Cleaned line: "${b}"`);let x;return f?(y("insertHeader","ACTION: Toggling OFF - removing header"),x=b):h>0?(y("insertHeader",`ACTION: Replacing H${h} with H${e}`),x=o.prefix+b):(y("insertHeader","ACTION: Adding new header"),x=o.prefix+b),y("insertHeader",`New line: "${x}"`),{text:x,selectionStart:g.selectionStart,selectionEnd:g.selectionEnd}},{prefix:o.prefix,adjustSelection:(g,v,b,x)=>{if(y("insertHeader","Adjusting selection:"),y("insertHeader",` - isRemoving param: ${g}`),y("insertHeader",` - shouldToggleOff: ${f}`),y("insertHeader",` - selStart: ${v}, selEnd: ${b}`),y("insertHeader",` - lineStartPos: ${x}`),f){let $=Math.max(v-u,x);return y("insertHeader",` - Removing header, adjusting by -${u}`),{start:$,end:v===b?$:Math.max(b-u,x)}}else if(u>0){let $=o.prefix.length-u;return y("insertHeader",` - Replacing header, adjusting by ${$}`),{start:v+$,end:b+$}}else return y("insertHeader",` - Adding header, adjusting by +${o.prefix.length}`),{start:v+o.prefix.length,end:b+o.prefix.length}}});y("insertHeader",`Final result: text="${m.text}", cursor=${m.selectionStart}-${m.selectionEnd}`),y("insertHeader","============ END ============"),M(n,m)}function ve(n){ee(n,1,!0)}function ye(n){ee(n,2,!0)}function be(n){ee(n,3,!0)}function we(n){return tt(n)}var O=class{constructor(e){this.editor=e,this.textarea=e.textarea}handleKeydown(e){if(!(navigator.platform.toLowerCase().includes("mac")?e.metaKey:e.ctrlKey))return!1;let o=null;switch(e.key.toLowerCase()){case"b":e.shiftKey||(o="toggleBold");break;case"i":e.shiftKey||(o="toggleItalic");break;case"k":e.shiftKey||(o="insertLink");break;case"7":e.shiftKey&&(o="toggleNumberedList");break;case"8":e.shiftKey&&(o="toggleBulletList");break}return o?(e.preventDefault(),this.editor.toolbar?this.editor.toolbar.handleAction(o):this.handleAction(o),!0):!1}async handleAction(e){let t=this.textarea;if(t){t.focus();try{switch(e){case"toggleBold":U(t);break;case"toggleItalic":D(t);break;case"insertLink":q(t);break;case"toggleBulletList":W(t);break;case"toggleNumberedList":K(t);break}t.dispatchEvent(new Event("input",{bubbles:!0}))}catch(i){console.error("Error in markdown action:",i)}}}destroy(){}};var I={name:"solar",colors:{bgPrimary:"#faf0ca",bgSecondary:"#ffffff",text:"#0d3b66",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"}},xe={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"}},ke={solar:I,cave:xe,light:I,dark:xe};function H(n){return typeof n=="string"?{...ke[n]||ke.solar,name:n}:n}function B(n){let e=[];for(let[t,i]of Object.entries(n)){let o=t.replace(/([A-Z])/g,"-$1").toLowerCase();e.push(`--${o}: ${i};`)}return e.join(`
|
|
37
37
|
`)}function Le(n,e={}){return{...n,colors:{...n.colors,...e}}}function Z(n={}){let{fontSize:e="14px",lineHeight:t=1.6,fontFamily:i='"SF Mono", SFMono-Regular, Menlo, Monaco, "Cascadia Code", Consolas, "Roboto Mono", "Noto Sans Mono", "Droid Sans Mono", "Ubuntu Mono", "DejaVu Sans Mono", "Liberation Mono", "Courier New", Courier, monospace',padding:o="20px",theme:r=null,mobile:s={}}=n,a=Object.keys(s).length>0?`
|
|
38
38
|
@media (max-width: 640px) {
|
|
39
39
|
.overtype-wrapper .overtype-input,
|
|
@@ -459,6 +459,8 @@ ${a}`:r;if(d){let L=n.value[n.selectionStart-1];n.selectionStart!==0&&L!=null&&!
|
|
|
459
459
|
font-size: 0.85rem !important;
|
|
460
460
|
color: #666 !important;
|
|
461
461
|
flex-shrink: 0 !important; /* Don't shrink */
|
|
462
|
+
z-index: 10001 !important; /* Above link tooltip */
|
|
463
|
+
position: relative !important; /* Enable z-index */
|
|
462
464
|
}
|
|
463
465
|
|
|
464
466
|
/* Dark theme stats bar */
|
|
@@ -496,6 +498,7 @@ ${a}`:r;if(d){let L=n.value[n.selectionStart-1];n.selectionStart!==0&&L!=null&&!
|
|
|
496
498
|
gap: 4px !important;
|
|
497
499
|
padding: 8px !important; /* Override reset */
|
|
498
500
|
background: var(--toolbar-bg, var(--bg-primary, #f8f9fa)) !important; /* Override reset */
|
|
501
|
+
border-bottom: 1px solid var(--toolbar-border, transparent) !important; /* Override reset */
|
|
499
502
|
overflow-x: auto !important; /* Allow horizontal scrolling */
|
|
500
503
|
overflow-y: hidden !important; /* Hide vertical overflow */
|
|
501
504
|
-webkit-overflow-scrolling: touch !important;
|
|
@@ -936,7 +939,7 @@ ${a}`:r;if(d){let L=n.value[n.selectionStart-1];n.selectionStart!==0&&L!=null&&!
|
|
|
936
939
|
</svg>`,Be=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
937
940
|
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" fill="none"></path>
|
|
938
941
|
<circle cx="12" cy="12" r="3" fill="none"></circle>
|
|
939
|
-
</svg>`;var
|
|
942
|
+
</svg>`;var k={bold:{name:"bold",icon:Se,title:"Bold (Ctrl+B)",action:({editor:n,event:e})=>{U(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},italic:{name:"italic",icon:Ee,title:"Italic (Ctrl+I)",action:({editor:n,event:e})=>{D(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},code:{name:"code",icon:He,title:"Inline Code",action:({editor:n,event:e})=>{fe(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},separator:{name:"separator"},link:{name:"link",icon:Ae,title:"Insert Link",action:({editor:n,event:e})=>{q(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h1:{name:"h1",icon:_e,title:"Heading 1",action:({editor:n,event:e})=>{ve(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h2:{name:"h2",icon:Ce,title:"Heading 2",action:({editor:n,event:e})=>{ye(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},h3:{name:"h3",icon:Te,title:"Heading 3",action:({editor:n,event:e})=>{be(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},bulletList:{name:"bulletList",icon:$e,title:"Bullet List",action:({editor:n,event:e})=>{W(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},orderedList:{name:"orderedList",icon:Me,title:"Numbered List",action:({editor:n,event:e})=>{K(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},taskList:{name:"taskList",icon:Pe,title:"Task List",action:({editor:n,event:e})=>{Y&&(Y(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0})))}},quote:{name:"quote",icon:Ie,title:"Quote",action:({editor:n,event:e})=>{ge(n.textarea),n.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}},viewMode:{name:"viewMode",icon:Be,title:"View mode"}},ie=[k.bold,k.italic,k.code,k.separator,k.link,k.separator,k.h1,k.h2,k.h3,k.separator,k.bulletList,k.orderedList,k.taskList,k.separator,k.quote,k.separator,k.viewMode];var w=class w{constructor(e,t={}){let i;if(typeof e=="string"){if(i=document.querySelectorAll(e),i.length===0)throw new Error(`No elements found for selector: ${e}`);i=Array.from(i)}else if(e instanceof Element)i=[e];else if(e instanceof NodeList)i=Array.from(e);else if(Array.isArray(e))i=e;else throw new Error("Invalid target: must be selector string, Element, NodeList, or Array");return i.map(r=>{if(r.overTypeInstance)return r.overTypeInstance.reinit(t),r.overTypeInstance;let s=Object.create(w.prototype);return s._init(r,t),r.overTypeInstance=s,w.instances.set(r,s),s})}_init(e,t={}){this.element=e,this.instanceTheme=t.theme||null,this.options=this._mergeOptions(t),this.instanceId=++w.instanceCount,this.initialized=!1,w.injectStyles(),w.initGlobalListeners();let i=e.querySelector(".overtype-container"),o=e.querySelector(".overtype-wrapper");i||o?this._recoverFromDOM(i,o):this._buildFromScratch(),this.shortcuts=new O(this),this.linkTooltip=new G(this),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.textarea.scrollTop=this.preview.scrollTop,this.textarea.scrollLeft=this.preview.scrollLeft})}),this.initialized=!0,this.options.onChange&&this.options.onChange(this.getValue(),this)}_mergeOptions(e){let t={fontSize:"14px",lineHeight:1.6,fontFamily:'"SF Mono", SFMono-Regular, Menlo, Monaco, "Cascadia Code", Consolas, "Roboto Mono", "Noto Sans Mono", "Droid Sans Mono", "Ubuntu Mono", "DejaVu Sans Mono", "Liberation Mono", "Courier New", Courier, monospace',padding:"16px",mobile:{fontSize:"16px",padding:"12px",lineHeight:1.5},textareaProps:{},autofocus:!1,autoResize:!1,minHeight:"100px",maxHeight:null,placeholder:"Start typing...",value:"",onChange:null,onKeydown:null,showActiveLineRaw:!1,showStats:!1,toolbar:!1,toolbarButtons:null,statsFormatter:null,smartLists:!0,codeHighlighter:null},{theme:i,colors:o,...r}=e;return{...t,...r}}_recoverFromDOM(e,t){if(e&&e.classList.contains("overtype-container"))this.container=e,this.wrapper=e.querySelector(".overtype-wrapper");else if(t){this.wrapper=t,this.container=document.createElement("div"),this.container.className="overtype-container";let i=this.instanceTheme||w.currentTheme||I,o=typeof i=="string"?i:i.name;if(o&&this.container.setAttribute("data-theme",o),this.instanceTheme){let r=typeof this.instanceTheme=="string"?H(this.instanceTheme):this.instanceTheme;if(r&&r.colors){let s=B(r.colors);this.container.style.cssText+=s}}t.parentNode.insertBefore(this.container,t),this.container.appendChild(t)}if(!this.wrapper){e&&e.remove(),t&&t.remove(),this._buildFromScratch();return}if(this.textarea=this.wrapper.querySelector(".overtype-input"),this.preview=this.wrapper.querySelector(".overtype-preview"),!this.textarea||!this.preview){this.container.remove(),this._buildFromScratch();return}this.wrapper._instance=this,this.options.fontSize&&this.wrapper.style.setProperty("--instance-font-size",this.options.fontSize),this.options.lineHeight&&this.wrapper.style.setProperty("--instance-line-height",String(this.options.lineHeight)),this.options.padding&&this.wrapper.style.setProperty("--instance-padding",this.options.padding),this._configureTextarea(),this._applyOptions()}_buildFromScratch(){let e=this._extractContent();this.element.innerHTML="",this._createDOM(),(e||this.options.value)&&this.setValue(e||this.options.value),this._applyOptions()}_extractContent(){let e=this.element.querySelector(".overtype-input");return e?e.value:this.element.textContent||""}_createDOM(){this.container=document.createElement("div"),this.container.className="overtype-container";let e=this.instanceTheme||w.currentTheme||I,t=typeof e=="string"?e:e.name;if(t&&this.container.setAttribute("data-theme",t),this.instanceTheme){let i=typeof this.instanceTheme=="string"?H(this.instanceTheme):this.instanceTheme;if(i&&i.colors){let o=B(i.colors);this.container.style.cssText+=o}}this.wrapper=document.createElement("div"),this.wrapper.className="overtype-wrapper",this.options.fontSize&&this.wrapper.style.setProperty("--instance-font-size",this.options.fontSize),this.options.lineHeight&&this.wrapper.style.setProperty("--instance-line-height",String(this.options.lineHeight)),this.options.padding&&this.wrapper.style.setProperty("--instance-padding",this.options.padding),this.wrapper._instance=this,this.textarea=document.createElement("textarea"),this.textarea.className="overtype-input",this.textarea.placeholder=this.options.placeholder,this._configureTextarea(),this.options.textareaProps&&Object.entries(this.options.textareaProps).forEach(([i,o])=>{i==="className"||i==="class"?this.textarea.className+=" "+o:i==="style"&&typeof o=="object"?Object.assign(this.textarea.style,o):this.textarea.setAttribute(i,o)}),this.preview=document.createElement("div"),this.preview.className="overtype-preview",this.preview.setAttribute("aria-hidden","true"),this.wrapper.appendChild(this.textarea),this.wrapper.appendChild(this.preview),this.container.appendChild(this.wrapper),this.options.showStats&&(this.statsBar=document.createElement("div"),this.statsBar.className="overtype-stats",this.container.appendChild(this.statsBar),this._updateStats()),this.element.appendChild(this.container),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","false"),this.textarea.setAttribute("data-gramm","false"),this.textarea.setAttribute("data-gramm_editor","false"),this.textarea.setAttribute("data-enable-grammarly","false")}_createToolbar(){let e=this.options.toolbarButtons||ie;this.toolbar=new J(this,{toolbarButtons:e}),this.toolbar.create(),this._toolbarSelectionListener=()=>{this.toolbar&&this.toolbar.updateButtonStates()},this._toolbarInputListener=()=>{this.toolbar&&this.toolbar.updateButtonStates()},this.textarea.addEventListener("selectionchange",this._toolbarSelectionListener),this.textarea.addEventListener("input",this._toolbarInputListener)}_cleanupToolbarListeners(){this._toolbarSelectionListener&&(this.textarea.removeEventListener("selectionchange",this._toolbarSelectionListener),this._toolbarSelectionListener=null),this._toolbarInputListener&&(this.textarea.removeEventListener("input",this._toolbarInputListener),this._toolbarInputListener=null)}_applyOptions(){this.options.autofocus&&this.textarea.focus(),this.options.autoResize?this.container.classList.contains("overtype-auto-resize")||this._setupAutoResize():this.container.classList.remove("overtype-auto-resize"),this.options.toolbar&&!this.toolbar?this._createToolbar():!this.options.toolbar&&this.toolbar&&(this._cleanupToolbarListeners(),this.toolbar.destroy(),this.toolbar=null),this.updatePreview()}updatePreview(){let e=this.textarea.value,t=this.textarea.selectionStart,i=this._getCurrentLine(e,t),o=this.container.dataset.mode==="preview",r=S.parse(e,i,this.options.showActiveLineRaw,this.options.codeHighlighter,o);this.preview.innerHTML=r||'<span style="color: #808080;">Start typing...</span>',this._applyCodeBlockBackgrounds(),this.options.showStats&&this.statsBar&&this._updateStats(),this.options.onChange&&this.initialized&&this.options.onChange(e,this)}_applyCodeBlockBackgrounds(){let e=this.preview.querySelectorAll(".code-fence");for(let t=0;t<e.length-1;t+=2){let i=e[t],o=e[t+1],r=i.parentElement,s=o.parentElement;!r||!s||(i.style.display="block",o.style.display="block",r.classList.add("code-block-line"),s.classList.add("code-block-line"))}}_getCurrentLine(e,t){return e.substring(0,t).split(`
|
|
940
943
|
`).length-1}handleInput(e){this.updatePreview()}handleKeydown(e){if(e.key==="Tab"){e.preventDefault();let i=this.textarea.selectionStart,o=this.textarea.selectionEnd,r=this.textarea.value;if(i!==o&&e.shiftKey){let s=r.substring(0,i),a=r.substring(i,o),p=r.substring(o),l=a.split(`
|
|
941
944
|
`).map(c=>c.replace(/^ /,"")).join(`
|
|
942
945
|
`);document.execCommand?(this.textarea.setSelectionRange(i,o),document.execCommand("insertText",!1,l)):(this.textarea.value=s+l+p,this.textarea.selectionStart=i,this.textarea.selectionEnd=i+l.length)}else if(i!==o){let s=r.substring(0,i),a=r.substring(i,o),p=r.substring(o),l=a.split(`
|
|
@@ -976,7 +979,7 @@ ${a}`:r;if(d){let L=n.value[n.selectionStart-1];n.selectionStart!==0&&L!=null&&!
|
|
|
976
979
|
}
|
|
977
980
|
`;this._styleVersion+=1;let a=`
|
|
978
981
|
/* overtype-webcomponent styles v${this._styleVersion} */
|
|
979
|
-
`;e.textContent=a+r+s,this._baseStyleElement=e,this.shadowRoot.appendChild(e)}_getOptionsFromAttributes(){let e={value:this.getAttribute("value")!==null?this._decodeValue(this.getAttribute("value")):(this.textContent||"").trim(),placeholder:this.getAttribute("placeholder")||nt,toolbar:this.hasAttribute("toolbar"),autofocus:this.hasAttribute("autofocus"),autoResize:this.hasAttribute("auto-resize"),showStats:this.hasAttribute("show-stats"),smartLists:!this.hasAttribute("smart-lists")||this.getAttribute("smart-lists")!=="false",onChange:this._handleChange,onKeydown:this._handleKeydown},t=this.getAttribute("font-size");t&&(e.fontSize=t);let i=this.getAttribute("line-height");i&&(e.lineHeight=parseFloat(i)||1.6);let o=this.getAttribute("padding");o&&(e.padding=o);let r=this.getAttribute("min-height");r&&(e.minHeight=r);let s=this.getAttribute("max-height");return s&&(e.maxHeight=s),e}_applyPendingOptions(){for(let[e,t]of Object.entries(this._pendingOptions))this._updateOption(e,t);this._pendingOptions={}}_updateOption(e,t){if(this._editor)switch(e){case"value":{let i=this._decodeValue(t);this._editor.getValue()!==i&&this._editor.setValue(i||"")}break;case"theme":this._reinjectStyles();break;case"placeholder":this._editor.textarea&&(this._editor.textarea.placeholder=t||"");break;case"readonly":this._editor.textarea&&(this._editor.textarea.readOnly=this.hasAttribute("readonly"));break;case"height":case"min-height":case"max-height":this._updateContainerHeight();break;case"toolbar":if(!!this.hasAttribute("toolbar")==!!this._editor.options.toolbar)return;this._reinitializeEditor();break;case"auto-resize":if(!!this.hasAttribute("auto-resize")==!!this._editor.options.autoResize)return;this._reinitializeEditor();break;case"show-stats":if(!!this.hasAttribute("show-stats")==!!this._editor.options.showStats)return;this._reinitializeEditor();break;case"font-size":{this._updateFontSize(t)&&this._reinjectStyles();break}case"line-height":{this._updateLineHeight(t)&&this._reinjectStyles();break}case"padding":this._reinjectStyles();break;case"smart-lists":{let i=!this.hasAttribute("smart-lists")||this.getAttribute("smart-lists")!=="false";if(!!this._editor.options.smartLists==!!i)return;this._reinitializeEditor();break}}}_updateContainerHeight(){let e=this.shadowRoot.querySelector(`.${Oe}`);if(!e)return;let t=this.getAttribute("height"),i=this.getAttribute("min-height"),o=this.getAttribute("max-height");e.style.height=t||"",e.style.minHeight=i||"",e.style.maxHeight=o||""}_updateFontSize(e){return this._editor&&this._editor.wrapper?(this._editor.options.fontSize=e||"",this._editor.wrapper.style.setProperty("--instance-font-size",this._editor.options.fontSize),this._editor.updatePreview(),!0):!1}_updateLineHeight(e){if(this._editor&&this._editor.wrapper){let t=parseFloat(e),i=Number.isFinite(t)?t:this._editor.options.lineHeight;return this._editor.options.lineHeight=i,this._editor.wrapper.style.setProperty("--instance-line-height",String(i)),this._editor.updatePreview(),!0}return!1}_reinjectStyles(){this._baseStyleElement&&this._baseStyleElement.parentNode&&this._baseStyleElement.remove(),this._injectStyles()}_reinitializeEditor(){let e=this._editor?this._editor.getValue():"";this._cleanup(),this._initialized=!1,this.shadowRoot.innerHTML="",e&&!this.getAttribute("value")&&this.setAttribute("value",e),this._initializeEditor()}_handleChange(e){this._updateValueAttribute(e),!(!this._initialized||!this._editor)&&this._dispatchEvent("change",{value:e,editor:this._editor})}_handleKeydown(e){this._dispatchEvent("keydown",{event:e,editor:this._editor})}_updateValueAttribute(e){this.getAttribute("value")!==e&&(this._silentUpdate=!0,this.setAttribute("value",e),this._silentUpdate=!1)}_dispatchEvent(e,t={}){let i=new CustomEvent(e,{detail:t,bubbles:!0,composed:!0});this.dispatchEvent(i)}_cleanup(){this._selectionChangeHandler&&(document.removeEventListener("selectionchange",this._selectionChangeHandler),this._selectionChangeHandler=null),this._editor&&typeof this._editor.destroy=="function"&&this._editor.destroy(),this._editor=null,this._initialized=!1,this.shadowRoot&&(this.shadowRoot.innerHTML="")}refreshTheme(){this._initialized&&this._reinjectStyles()}getValue(){return this._editor?this._editor.getValue():this.getAttribute("value")||""}setValue(e){this._editor?this._editor.setValue(e):this.setAttribute("value",e)}getHTML(){return this._editor?this._editor.getRenderedHTML(!1):""}insertText(e){!this._editor||typeof e!="string"||this._editor.insertText(e)}focus(){this._editor&&this._editor.textarea&&this._editor.textarea.focus()}blur(){this._editor&&this._editor.textarea&&this._editor.textarea.blur()}getStats(){if(!this._editor||!this._editor.textarea)return null;let e=this._editor.textarea.value,t=e.split(`
|
|
982
|
+
`;e.textContent=a+r+s,this._baseStyleElement=e,this.shadowRoot.appendChild(e)}_getOptionsFromAttributes(){let e={value:this.getAttribute("value")!==null?this._decodeValue(this.getAttribute("value")):(this.textContent||"").trim(),placeholder:this.getAttribute("placeholder")||nt,toolbar:this.hasAttribute("toolbar"),autofocus:this.hasAttribute("autofocus"),autoResize:this.hasAttribute("auto-resize"),showStats:this.hasAttribute("show-stats"),smartLists:!this.hasAttribute("smart-lists")||this.getAttribute("smart-lists")!=="false",onChange:this._handleChange,onKeydown:this._handleKeydown},t=this.getAttribute("font-size");t&&(e.fontSize=t);let i=this.getAttribute("line-height");i&&(e.lineHeight=parseFloat(i)||1.6);let o=this.getAttribute("padding");o&&(e.padding=o);let r=this.getAttribute("min-height");r&&(e.minHeight=r);let s=this.getAttribute("max-height");return s&&(e.maxHeight=s),e}_applyPendingOptions(){for(let[e,t]of Object.entries(this._pendingOptions))this._updateOption(e,t);this._pendingOptions={}}_updateOption(e,t){if(this._editor)switch(e){case"value":{let i=this._decodeValue(t);this._editor.getValue()!==i&&this._editor.setValue(i||"")}break;case"theme":this._reinjectStyles(),this._editor&&this._editor.setTheme&&this._editor.setTheme(t||"solar");break;case"placeholder":this._editor.textarea&&(this._editor.textarea.placeholder=t||"");break;case"readonly":this._editor.textarea&&(this._editor.textarea.readOnly=this.hasAttribute("readonly"));break;case"height":case"min-height":case"max-height":this._updateContainerHeight();break;case"toolbar":if(!!this.hasAttribute("toolbar")==!!this._editor.options.toolbar)return;this._reinitializeEditor();break;case"auto-resize":if(!!this.hasAttribute("auto-resize")==!!this._editor.options.autoResize)return;this._reinitializeEditor();break;case"show-stats":if(!!this.hasAttribute("show-stats")==!!this._editor.options.showStats)return;this._reinitializeEditor();break;case"font-size":{this._updateFontSize(t)&&this._reinjectStyles();break}case"line-height":{this._updateLineHeight(t)&&this._reinjectStyles();break}case"padding":this._reinjectStyles();break;case"smart-lists":{let i=!this.hasAttribute("smart-lists")||this.getAttribute("smart-lists")!=="false";if(!!this._editor.options.smartLists==!!i)return;this._reinitializeEditor();break}}}_updateContainerHeight(){let e=this.shadowRoot.querySelector(`.${Oe}`);if(!e)return;let t=this.getAttribute("height"),i=this.getAttribute("min-height"),o=this.getAttribute("max-height");e.style.height=t||"",e.style.minHeight=i||"",e.style.maxHeight=o||""}_updateFontSize(e){return this._editor&&this._editor.wrapper?(this._editor.options.fontSize=e||"",this._editor.wrapper.style.setProperty("--instance-font-size",this._editor.options.fontSize),this._editor.updatePreview(),!0):!1}_updateLineHeight(e){if(this._editor&&this._editor.wrapper){let t=parseFloat(e),i=Number.isFinite(t)?t:this._editor.options.lineHeight;return this._editor.options.lineHeight=i,this._editor.wrapper.style.setProperty("--instance-line-height",String(i)),this._editor.updatePreview(),!0}return!1}_reinjectStyles(){this._baseStyleElement&&this._baseStyleElement.parentNode&&this._baseStyleElement.remove(),this._injectStyles()}_reinitializeEditor(){let e=this._editor?this._editor.getValue():"";this._cleanup(),this._initialized=!1,this.shadowRoot.innerHTML="",e&&!this.getAttribute("value")&&this.setAttribute("value",e),this._initializeEditor()}_handleChange(e){this._updateValueAttribute(e),!(!this._initialized||!this._editor)&&this._dispatchEvent("change",{value:e,editor:this._editor})}_handleKeydown(e){this._dispatchEvent("keydown",{event:e,editor:this._editor})}_updateValueAttribute(e){this.getAttribute("value")!==e&&(this._silentUpdate=!0,this.setAttribute("value",e),this._silentUpdate=!1)}_dispatchEvent(e,t={}){let i=new CustomEvent(e,{detail:t,bubbles:!0,composed:!0});this.dispatchEvent(i)}_cleanup(){this._selectionChangeHandler&&(document.removeEventListener("selectionchange",this._selectionChangeHandler),this._selectionChangeHandler=null),this._editor&&typeof this._editor.destroy=="function"&&this._editor.destroy(),this._editor=null,this._initialized=!1,this.shadowRoot&&(this.shadowRoot.innerHTML="")}refreshTheme(){this._initialized&&this._reinjectStyles()}getValue(){return this._editor?this._editor.getValue():this.getAttribute("value")||""}setValue(e){this._editor?this._editor.setValue(e):this.setAttribute("value",e)}getHTML(){return this._editor?this._editor.getRenderedHTML(!1):""}insertText(e){!this._editor||typeof e!="string"||this._editor.insertText(e)}focus(){this._editor&&this._editor.textarea&&this._editor.textarea.focus()}blur(){this._editor&&this._editor.textarea&&this._editor.textarea.blur()}getStats(){if(!this._editor||!this._editor.textarea)return null;let e=this._editor.textarea.value,t=e.split(`
|
|
980
983
|
`),i=e.length,o=e.split(/\s+/).filter(l=>l.length>0).length,r=this._editor.textarea.selectionStart,a=e.substring(0,r).split(`
|
|
981
984
|
`),p=a.length,d=a[a.length-1].length+1;return{characters:i,words:o,lines:t.length,line:p,column:d}}isReady(){return this._initialized&&this._editor!==null}getEditor(){return this._editor}};customElements.get("overtype-editor")||customElements.define("overtype-editor",Q);var rt=Q;return De(st);})();
|
|
982
985
|
/**
|
package/dist/overtype.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OverType v2.0.
|
|
2
|
+
* OverType v2.0.5
|
|
3
3
|
* A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @author David Miranda
|
|
@@ -1686,16 +1686,22 @@ var solar = {
|
|
|
1686
1686
|
// White - editor background
|
|
1687
1687
|
text: "#0d3b66",
|
|
1688
1688
|
// Yale Blue - main text
|
|
1689
|
+
textPrimary: "#0d3b66",
|
|
1690
|
+
// Yale Blue - primary text (same as text)
|
|
1691
|
+
textSecondary: "#5a7a9b",
|
|
1692
|
+
// Muted blue - secondary text
|
|
1689
1693
|
h1: "#f95738",
|
|
1690
1694
|
// Tomato - h1 headers
|
|
1691
1695
|
h2: "#ee964b",
|
|
1692
|
-
// Sandy Brown - h2 headers
|
|
1696
|
+
// Sandy Brown - h2 headers
|
|
1693
1697
|
h3: "#3d8a51",
|
|
1694
1698
|
// Forest green - h3 headers
|
|
1695
1699
|
strong: "#ee964b",
|
|
1696
1700
|
// Sandy Brown - bold text
|
|
1697
1701
|
em: "#f95738",
|
|
1698
1702
|
// Tomato - italic text
|
|
1703
|
+
del: "#ee964b",
|
|
1704
|
+
// Sandy Brown - deleted text (same as strong)
|
|
1699
1705
|
link: "#0d3b66",
|
|
1700
1706
|
// Yale Blue - links
|
|
1701
1707
|
code: "#0d3b66",
|
|
@@ -1708,17 +1714,25 @@ var solar = {
|
|
|
1708
1714
|
// Muted blue - horizontal rules
|
|
1709
1715
|
syntaxMarker: "rgba(13, 59, 102, 0.52)",
|
|
1710
1716
|
// Yale Blue with transparency
|
|
1717
|
+
syntax: "#999999",
|
|
1718
|
+
// Gray - syntax highlighting fallback
|
|
1711
1719
|
cursor: "#f95738",
|
|
1712
1720
|
// Tomato - cursor
|
|
1713
1721
|
selection: "rgba(244, 211, 94, 0.4)",
|
|
1714
1722
|
// Naples Yellow with transparency
|
|
1715
1723
|
listMarker: "#ee964b",
|
|
1716
1724
|
// Sandy Brown - list markers
|
|
1725
|
+
rawLine: "#5a7a9b",
|
|
1726
|
+
// Muted blue - raw line indicators
|
|
1727
|
+
border: "#e0e0e0",
|
|
1728
|
+
// Light gray - borders
|
|
1729
|
+
hoverBg: "#f0f0f0",
|
|
1730
|
+
// Very light gray - hover backgrounds
|
|
1731
|
+
primary: "#0d3b66",
|
|
1732
|
+
// Yale Blue - primary accent
|
|
1717
1733
|
// Toolbar colors
|
|
1718
1734
|
toolbarBg: "#ffffff",
|
|
1719
1735
|
// White - toolbar background
|
|
1720
|
-
toolbarBorder: "rgba(13, 59, 102, 0.15)",
|
|
1721
|
-
// Yale Blue border
|
|
1722
1736
|
toolbarIcon: "#0d3b66",
|
|
1723
1737
|
// Yale Blue - icon color
|
|
1724
1738
|
toolbarHover: "#f5f5f5",
|
|
@@ -1736,6 +1750,10 @@ var cave = {
|
|
|
1736
1750
|
// Darker charcoal - editor background
|
|
1737
1751
|
text: "#c5dde8",
|
|
1738
1752
|
// Light blue-gray - main text
|
|
1753
|
+
textPrimary: "#c5dde8",
|
|
1754
|
+
// Light blue-gray - primary text (same as text)
|
|
1755
|
+
textSecondary: "#9fcfec",
|
|
1756
|
+
// Brighter blue - secondary text
|
|
1739
1757
|
h1: "#d4a5ff",
|
|
1740
1758
|
// Rich lavender - h1 headers
|
|
1741
1759
|
h2: "#f6ae2d",
|
|
@@ -1746,6 +1764,8 @@ var cave = {
|
|
|
1746
1764
|
// Hunyadi Yellow - bold text
|
|
1747
1765
|
em: "#9fcfec",
|
|
1748
1766
|
// Brighter blue - italic text
|
|
1767
|
+
del: "#f6ae2d",
|
|
1768
|
+
// Hunyadi Yellow - deleted text (same as strong)
|
|
1749
1769
|
link: "#9fcfec",
|
|
1750
1770
|
// Brighter blue - links
|
|
1751
1771
|
code: "#c5dde8",
|
|
@@ -1758,17 +1778,25 @@ var cave = {
|
|
|
1758
1778
|
// Light blue-gray - horizontal rules
|
|
1759
1779
|
syntaxMarker: "rgba(159, 207, 236, 0.73)",
|
|
1760
1780
|
// Brighter blue semi-transparent
|
|
1781
|
+
syntax: "#7a8c98",
|
|
1782
|
+
// Muted gray-blue - syntax highlighting fallback
|
|
1761
1783
|
cursor: "#f26419",
|
|
1762
1784
|
// Orange Pantone - cursor
|
|
1763
1785
|
selection: "rgba(51, 101, 138, 0.4)",
|
|
1764
1786
|
// Lapis Lazuli with transparency
|
|
1765
1787
|
listMarker: "#f6ae2d",
|
|
1766
1788
|
// Hunyadi Yellow - list markers
|
|
1789
|
+
rawLine: "#9fcfec",
|
|
1790
|
+
// Brighter blue - raw line indicators
|
|
1791
|
+
border: "#2a3f52",
|
|
1792
|
+
// Dark blue-gray - borders
|
|
1793
|
+
hoverBg: "#243546",
|
|
1794
|
+
// Slightly lighter charcoal - hover backgrounds
|
|
1795
|
+
primary: "#9fcfec",
|
|
1796
|
+
// Brighter blue - primary accent
|
|
1767
1797
|
// Toolbar colors for dark theme
|
|
1768
1798
|
toolbarBg: "#1D2D3E",
|
|
1769
1799
|
// Darker charcoal - toolbar background
|
|
1770
|
-
toolbarBorder: "rgba(197, 221, 232, 0.1)",
|
|
1771
|
-
// Light blue-gray border
|
|
1772
1800
|
toolbarIcon: "#c5dde8",
|
|
1773
1801
|
// Light blue-gray - icon color
|
|
1774
1802
|
toolbarHover: "#243546",
|
|
@@ -2249,6 +2277,8 @@ function generateStyles(options = {}) {
|
|
|
2249
2277
|
font-size: 0.85rem !important;
|
|
2250
2278
|
color: #666 !important;
|
|
2251
2279
|
flex-shrink: 0 !important; /* Don't shrink */
|
|
2280
|
+
z-index: 10001 !important; /* Above link tooltip */
|
|
2281
|
+
position: relative !important; /* Enable z-index */
|
|
2252
2282
|
}
|
|
2253
2283
|
|
|
2254
2284
|
/* Dark theme stats bar */
|
|
@@ -2286,6 +2316,7 @@ function generateStyles(options = {}) {
|
|
|
2286
2316
|
gap: 4px !important;
|
|
2287
2317
|
padding: 8px !important; /* Override reset */
|
|
2288
2318
|
background: var(--toolbar-bg, var(--bg-primary, #f8f9fa)) !important; /* Override reset */
|
|
2319
|
+
border-bottom: 1px solid var(--toolbar-border, transparent) !important; /* Override reset */
|
|
2289
2320
|
overflow-x: auto !important; /* Allow horizontal scrolling */
|
|
2290
2321
|
overflow-y: hidden !important; /* Hide vertical overflow */
|
|
2291
2322
|
-webkit-overflow-scrolling: touch !important;
|
|
@@ -3359,6 +3390,12 @@ var _OverType = class _OverType {
|
|
|
3359
3390
|
}
|
|
3360
3391
|
this.shortcuts = new ShortcutsManager(this);
|
|
3361
3392
|
this.linkTooltip = new LinkTooltip(this);
|
|
3393
|
+
requestAnimationFrame(() => {
|
|
3394
|
+
requestAnimationFrame(() => {
|
|
3395
|
+
this.textarea.scrollTop = this.preview.scrollTop;
|
|
3396
|
+
this.textarea.scrollLeft = this.preview.scrollLeft;
|
|
3397
|
+
});
|
|
3398
|
+
});
|
|
3362
3399
|
this.initialized = true;
|
|
3363
3400
|
if (this.options.onChange) {
|
|
3364
3401
|
this.options.onChange(this.getValue(), this);
|