overtype 2.0.4 → 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * OverType v2.0.4
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
@@ -21,7 +21,7 @@ var OverTypeEditor=(()=>{var N=Object.defineProperty;var Ne=Object.getOwnPropert
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,k=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=k=_}else k=b+L.length;return{text:L,selectionStart:b,selectionEnd:k}}else if($)if(l&&l.length>0&&m.match(l)){v=v.replace(p,m);let L=g+v;return b=k=b+g.length,{text:L,selectionStart:b,selectionEnd:k}}else{let L=g+m+v;return b=b+g.length+m.length+v.indexOf(p),k=b+p.length,{text:L,selectionStart:b,selectionEnd:k}}else{let L=g+m+v;b=u+g.length,k=f+g.length;let _=m.match(/^\s*|\s*$/g);if(h&&_){let ne=_[0]||"",oe=_[1]||"";L=ne+g+m.trim()+v+oe,b+=ne.length,k-=oe.length}return{text:L,selectionStart:b,selectionEnd:k}}}function ue(n,e){let{prefix:t,suffix:i,surroundWithNewlines:o}=e,r=n.value.slice(n.selectionStart,n.selectionEnd),s=n.selectionStart,a=n.selectionEnd,p=r.split(`
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(`
@@ -33,7 +33,7 @@ ${a}`:r;if(d){let L=n.value[n.selectionStart-1];n.selectionStart!==0&&L!=null&&!
33
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
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=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 k;return f?(y("insertHeader","ACTION: Toggling OFF - removing header"),k=b):h>0?(y("insertHeader",`ACTION: Replacing H${h} with H${e}`),k=o.prefix+b):(y("insertHeader","ACTION: Adding new header"),k=o.prefix+b),y("insertHeader",`New line: "${k}"`),{text:k,selectionStart:g.selectionStart,selectionEnd:g.selectionEnd}},{prefix:o.prefix,adjustSelection:(g,v,b,k)=>{if(y("insertHeader","Adjusting selection:"),y("insertHeader",` - isRemoving param: ${g}`),y("insertHeader",` - shouldToggleOff: ${f}`),y("insertHeader",` - selStart: ${v}, selEnd: ${b}`),y("insertHeader",` - lineStartPos: ${k}`),f){let $=Math.max(v-u,k);return y("insertHeader",` - Removing header, adjusting by -${u}`),{start:$,end:v===b?$:Math.max(b-u,k)}}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",h1:"#f95738",h2:"#ee964b",h3:"#3d8a51",strong:"#ee964b",em:"#f95738",link:"#0d3b66",code:"#0d3b66",codeBg:"rgba(244, 211, 94, 0.4)",blockquote:"#5a7a9b",hr:"#5a7a9b",syntaxMarker:"rgba(13, 59, 102, 0.52)",cursor:"#f95738",selection:"rgba(244, 211, 94, 0.4)",listMarker:"#ee964b",toolbarBg:"#ffffff",toolbarBorder:"rgba(13, 59, 102, 0.15)",toolbarIcon:"#0d3b66",toolbarHover:"#f5f5f5",toolbarActive:"#faf0ca"}},ke={name:"cave",colors:{bgPrimary:"#141E26",bgSecondary:"#1D2D3E",text:"#c5dde8",h1:"#d4a5ff",h2:"#f6ae2d",h3:"#9fcfec",strong:"#f6ae2d",em:"#9fcfec",link:"#9fcfec",code:"#c5dde8",codeBg:"#1a232b",blockquote:"#9fcfec",hr:"#c5dde8",syntaxMarker:"rgba(159, 207, 236, 0.73)",cursor:"#f26419",selection:"rgba(51, 101, 138, 0.4)",listMarker:"#f6ae2d",toolbarBg:"#1D2D3E",toolbarBorder:"rgba(197, 221, 232, 0.1)",toolbarIcon:"#c5dde8",toolbarHover:"#243546",toolbarActive:"#2a3f52"}},xe={solar:I,cave:ke,light:I,dark:ke};function H(n){return typeof n=="string"?{...xe[n]||xe.solar,name:n}:n}function 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(`
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,
@@ -498,6 +498,7 @@ ${a}`:r;if(d){let L=n.value[n.selectionStart-1];n.selectionStart!==0&&L!=null&&!
498
498
  gap: 4px !important;
499
499
  padding: 8px !important; /* Override reset */
500
500
  background: var(--toolbar-bg, var(--bg-primary, #f8f9fa)) !important; /* Override reset */
501
+ border-bottom: 1px solid var(--toolbar-border, transparent) !important; /* Override reset */
501
502
  overflow-x: auto !important; /* Allow horizontal scrolling */
502
503
  overflow-y: hidden !important; /* Hide vertical overflow */
503
504
  -webkit-overflow-scrolling: touch !important;
@@ -938,7 +939,7 @@ ${a}`:r;if(d){let L=n.value[n.selectionStart-1];n.selectionStart!==0&&L!=null&&!
938
939
  </svg>`,Be=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
939
940
  <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" fill="none"></path>
940
941
  <circle cx="12" cy="12" r="3" fill="none"></circle>
941
- </svg>`;var x={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=[x.bold,x.italic,x.code,x.separator,x.link,x.separator,x.h1,x.h2,x.h3,x.separator,x.bulletList,x.orderedList,x.taskList,x.separator,x.quote,x.separator,x.viewMode];var w=class w{constructor(e,t={}){let i;if(typeof e=="string"){if(i=document.querySelectorAll(e),i.length===0)throw new Error(`No elements found for selector: ${e}`);i=Array.from(i)}else if(e instanceof Element)i=[e];else if(e instanceof NodeList)i=Array.from(e);else if(Array.isArray(e))i=e;else throw new Error("Invalid target: must be selector string, Element, NodeList, or Array");return i.map(r=>{if(r.overTypeInstance)return r.overTypeInstance.reinit(t),r.overTypeInstance;let s=Object.create(w.prototype);return s._init(r,t),r.overTypeInstance=s,w.instances.set(r,s),s})}_init(e,t={}){this.element=e,this.instanceTheme=t.theme||null,this.options=this._mergeOptions(t),this.instanceId=++w.instanceCount,this.initialized=!1,w.injectStyles(),w.initGlobalListeners();let i=e.querySelector(".overtype-container"),o=e.querySelector(".overtype-wrapper");i||o?this._recoverFromDOM(i,o):this._buildFromScratch(),this.shortcuts=new O(this),this.linkTooltip=new G(this),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(`
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(`
942
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(`
943
944
  `).map(c=>c.replace(/^ /,"")).join(`
944
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(`
@@ -978,7 +979,7 @@ ${a}`:r;if(d){let L=n.value[n.selectionStart-1];n.selectionStart!==0&&L!=null&&!
978
979
  }
979
980
  `;this._styleVersion+=1;let a=`
980
981
  /* overtype-webcomponent styles v${this._styleVersion} */
981
- `;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(`
982
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(`
983
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);})();
984
985
  /**
package/dist/overtype.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * OverType v2.0.4
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",
@@ -2288,6 +2316,7 @@ function generateStyles(options = {}) {
2288
2316
  gap: 4px !important;
2289
2317
  padding: 8px !important; /* Override reset */
2290
2318
  background: var(--toolbar-bg, var(--bg-primary, #f8f9fa)) !important; /* Override reset */
2319
+ border-bottom: 1px solid var(--toolbar-border, transparent) !important; /* Override reset */
2291
2320
  overflow-x: auto !important; /* Allow horizontal scrolling */
2292
2321
  overflow-y: hidden !important; /* Hide vertical overflow */
2293
2322
  -webkit-overflow-scrolling: touch !important;