overtype 2.3.3 → 2.3.4
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 +16 -4
- package/dist/overtype-webcomponent.esm.js.map +2 -2
- package/dist/overtype-webcomponent.js +16 -4
- package/dist/overtype-webcomponent.js.map +2 -2
- package/dist/overtype-webcomponent.min.js +9 -4
- package/dist/overtype.cjs +16 -4
- package/dist/overtype.cjs.map +2 -2
- package/dist/overtype.esm.js +16 -4
- package/dist/overtype.esm.js.map +2 -2
- package/dist/overtype.js +16 -4
- package/dist/overtype.js.map +2 -2
- package/dist/overtype.min.js +10 -5
- package/package.json +1 -1
- package/src/overtype.js +20 -12
- package/src/styles.js +5 -0
package/dist/overtype.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OverType v2.3.
|
|
2
|
+
* OverType v2.3.4
|
|
3
3
|
* A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
4
4
|
* @license MIT
|
|
5
5
|
* @author David Miranda
|
|
@@ -12,7 +12,7 @@ var OverType=(()=>{var ve=Object.defineProperty;var cn=Object.getOwnPropertyDesc
|
|
|
12
12
|
`),d=s.slice(3).trim(),h=d?` class="language-${d}"`:"",u=l,f=n||this.codeHighlighter;if(f)try{let g=l.replace(/"/g,'"').replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"),y=f(g,d);y&&typeof y.then=="function"?console.warn("Async highlighters are not supported in Node.js (non-DOM) context. Use synchronous highlighters for server-side rendering."):y&&typeof y=="string"&&y.trim()&&(u=y)}catch(g){console.warn("Code highlighting failed:",g)}let m=`<div><span class="code-fence">${s}</span></div>`;return m+=`<pre class="code-block"><code${h}>${u}</code></pre>`,m+=`<div><span class="code-fence">${c}</span></div>`,m}),i}static getListContext(e,n){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>=n){r=h,s=o;break}o+=u+1}let a=i[r],c=s+a.length,p=a.match(this.LIST_PATTERNS.checkbox);if(p)return{inList:!0,listType:"checkbox",indent:p[1],marker:"-",checked:p[2]==="x",content:p[3],lineStart:s,lineEnd:c,markerEndPos:s+p[1].length+p[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:c,markerEndPos:s+l[1].length+l[2].length+1};let d=a.match(this.LIST_PATTERNS.numbered);return d?{inList:!0,listType:"numbered",indent:d[1],marker:parseInt(d[2]),content:d[3],lineStart:s,lineEnd:c,markerEndPos:s+d[1].length+d[2].length+2}:{inList:!1,listType:null,indent:"",marker:null,content:a,lineStart:s,lineEnd:c,markerEndPos:s}}static createNewListItem(e){switch(e.listType){case"bullet":return`${e.indent}${e.marker} `;case"numbered":return`${e.indent}${e.marker+1}. `;case"checkbox":return`${e.indent}- [ ] `;default:return""}}static renumberLists(e){let n=e.split(`
|
|
14
14
|
`),i=new Map,o=!1;return n.map(s=>{let a=s.match(this.LIST_PATTERNS.numbered);if(a){let c=a[1],p=c.length,l=a[3];o||i.clear();let d=(i.get(p)||0)+1;i.set(p,d);for(let[h]of i)h>p&&i.delete(h);return o=!0,`${c}${d}. ${l}`}else return(s.trim()===""||!s.match(/^\s/))&&(o=!1,i.clear()),s}).join(`
|
|
15
|
-
`)}};C(T,"linkIndex",0),C(T,"codeHighlighter",null),C(T,"customSyntax",null),C(T,"LIST_PATTERNS",{bullet:/^(\s*)([-*+])\s+(.*)$/,numbered:/^(\s*)(\d+)\.\s+(.*)$/,checkbox:/^(\s*)-\s+\[([ x])\]\s+(.*)$/});var re=class{constructor(e){this.editor=e}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.performAction(o,e),!0):!1}destroy(){}};var _={name:"solar",colors:{bgPrimary:"#faf0ca",bgSecondary:"#ffffff",text:"#0d3b66",textPrimary:"#0d3b66",textSecondary:"#5a7a9b",h1:"#f95738",h2:"#ee964b",h3:"#3d8a51",strong:"#ee964b",em:"#f95738",del:"#ee964b",link:"#0d3b66",code:"#0d3b66",codeBg:"rgba(244, 211, 94, 0.4)",blockquote:"#5a7a9b",hr:"#5a7a9b",syntaxMarker:"rgba(13, 59, 102, 0.52)",syntax:"#999999",cursor:"#f95738",selection:"rgba(244, 211, 94, 0.4)",listMarker:"#ee964b",rawLine:"#5a7a9b",border:"#e0e0e0",hoverBg:"#f0f0f0",primary:"#0d3b66",toolbarBg:"#ffffff",toolbarIcon:"#0d3b66",toolbarHover:"#f5f5f5",toolbarActive:"#faf0ca",placeholder:"#999999"},previewColors:{text:"#0d3b66",h1:"inherit",h2:"inherit",h3:"inherit",strong:"inherit",em:"inherit",link:"#0d3b66",code:"#0d3b66",codeBg:"rgba(244, 211, 94, 0.4)",blockquote:"#5a7a9b",hr:"#5a7a9b",bg:"transparent"}},qe={name:"cave",colors:{bgPrimary:"#141E26",bgSecondary:"#1D2D3E",text:"#c5dde8",textPrimary:"#c5dde8",textSecondary:"#9fcfec",h1:"#d4a5ff",h2:"#f6ae2d",h3:"#9fcfec",strong:"#f6ae2d",em:"#9fcfec",del:"#f6ae2d",link:"#9fcfec",code:"#c5dde8",codeBg:"#1a232b",blockquote:"#9fcfec",hr:"#c5dde8",syntaxMarker:"rgba(159, 207, 236, 0.73)",syntax:"#7a8c98",cursor:"#f26419",selection:"rgba(51, 101, 138, 0.4)",listMarker:"#f6ae2d",rawLine:"#9fcfec",border:"#2a3f52",hoverBg:"#243546",primary:"#9fcfec",toolbarBg:"#1D2D3E",toolbarIcon:"#c5dde8",toolbarHover:"#243546",toolbarActive:"#2a3f52",placeholder:"#6a7a88"},previewColors:{text:"#c5dde8",h1:"inherit",h2:"inherit",h3:"inherit",strong:"inherit",em:"inherit",link:"#9fcfec",code:"#c5dde8",codeBg:"#1a232b",blockquote:"#9fcfec",hr:"#c5dde8",bg:"transparent"}},We={solar:_,cave:qe,auto:_,light:_,dark:qe};function V(t){return typeof t=="string"?{...We[t]||We.solar,name:t}:t}function
|
|
15
|
+
`)}};C(T,"linkIndex",0),C(T,"codeHighlighter",null),C(T,"customSyntax",null),C(T,"LIST_PATTERNS",{bullet:/^(\s*)([-*+])\s+(.*)$/,numbered:/^(\s*)(\d+)\.\s+(.*)$/,checkbox:/^(\s*)-\s+\[([ x])\]\s+(.*)$/});var re=class{constructor(e){this.editor=e}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.performAction(o,e),!0):!1}destroy(){}};var _={name:"solar",colors:{bgPrimary:"#faf0ca",bgSecondary:"#ffffff",text:"#0d3b66",textPrimary:"#0d3b66",textSecondary:"#5a7a9b",h1:"#f95738",h2:"#ee964b",h3:"#3d8a51",strong:"#ee964b",em:"#f95738",del:"#ee964b",link:"#0d3b66",code:"#0d3b66",codeBg:"rgba(244, 211, 94, 0.4)",blockquote:"#5a7a9b",hr:"#5a7a9b",syntaxMarker:"rgba(13, 59, 102, 0.52)",syntax:"#999999",cursor:"#f95738",selection:"rgba(244, 211, 94, 0.4)",listMarker:"#ee964b",rawLine:"#5a7a9b",border:"#e0e0e0",hoverBg:"#f0f0f0",primary:"#0d3b66",toolbarBg:"#ffffff",toolbarIcon:"#0d3b66",toolbarHover:"#f5f5f5",toolbarActive:"#faf0ca",placeholder:"#999999"},previewColors:{text:"#0d3b66",h1:"inherit",h2:"inherit",h3:"inherit",strong:"inherit",em:"inherit",link:"#0d3b66",code:"#0d3b66",codeBg:"rgba(244, 211, 94, 0.4)",blockquote:"#5a7a9b",hr:"#5a7a9b",bg:"transparent"}},qe={name:"cave",colors:{bgPrimary:"#141E26",bgSecondary:"#1D2D3E",text:"#c5dde8",textPrimary:"#c5dde8",textSecondary:"#9fcfec",h1:"#d4a5ff",h2:"#f6ae2d",h3:"#9fcfec",strong:"#f6ae2d",em:"#9fcfec",del:"#f6ae2d",link:"#9fcfec",code:"#c5dde8",codeBg:"#1a232b",blockquote:"#9fcfec",hr:"#c5dde8",syntaxMarker:"rgba(159, 207, 236, 0.73)",syntax:"#7a8c98",cursor:"#f26419",selection:"rgba(51, 101, 138, 0.4)",listMarker:"#f6ae2d",rawLine:"#9fcfec",border:"#2a3f52",hoverBg:"#243546",primary:"#9fcfec",toolbarBg:"#1D2D3E",toolbarIcon:"#c5dde8",toolbarHover:"#243546",toolbarActive:"#2a3f52",placeholder:"#6a7a88"},previewColors:{text:"#c5dde8",h1:"inherit",h2:"inherit",h3:"inherit",strong:"inherit",em:"inherit",link:"#9fcfec",code:"#c5dde8",codeBg:"#1a232b",blockquote:"#9fcfec",hr:"#c5dde8",bg:"transparent"}},We={solar:_,cave:qe,auto:_,light:_,dark:qe};function V(t){return typeof t=="string"?{...We[t]||We.solar,name:t}:t}function Oe(t){if(t!=="auto")return t;let e=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)");return e!=null&&e.matches?"cave":"solar"}function Q(t,e){let n=[];for(let[i,o]of Object.entries(t)){let r=i.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(`--${r}: ${o};`)}if(e)for(let[i,o]of Object.entries(e)){let r=i.replace(/([A-Z])/g,"-$1").toLowerCase();n.push(`--preview-${r}-default: ${o};`)}return n.join(`
|
|
16
16
|
`)}function Ke(t,e={},n={}){return{...t,colors:{...t.colors,...e},previewColors:{...t.previewColors,...n}}}function Ze(t={}){let{fontSize:e="14px",lineHeight:n=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={}}=t,a=Object.keys(s).length>0?`
|
|
17
17
|
@media (max-width: 640px) {
|
|
18
18
|
.overtype-wrapper .overtype-input,
|
|
@@ -675,6 +675,11 @@ var OverType=(()=>{var ve=Object.defineProperty;var cn=Object.getOwnPropertyDesc
|
|
|
675
675
|
cursor: text !important;
|
|
676
676
|
}
|
|
677
677
|
|
|
678
|
+
.overtype-container.overtype-auto-resize[data-mode="preview"] .overtype-preview {
|
|
679
|
+
position: static !important;
|
|
680
|
+
height: auto !important;
|
|
681
|
+
}
|
|
682
|
+
|
|
678
683
|
/* Hide syntax markers in preview mode */
|
|
679
684
|
.overtype-container[data-mode="preview"] .syntax-marker {
|
|
680
685
|
display: none !important;
|
|
@@ -895,7 +900,7 @@ ${a}`:r;if(p){let k=t.value[t.selectionStart-1];t.selectionStart!==0&&k!=null&&!
|
|
|
895
900
|
`)+u;return n?(i=Math.max(i+se(0,e.unorderedList).length+h.length,0),o=i):a.processed?(i=Math.max(t.selectionStart+h.length,0),o=t.selectionEnd+h.length+l-d):(i=Math.max(t.selectionStart+h.length,0),o=t.selectionEnd+h.length+l),{text:f,selectionStart:i,selectionEnd:o}}function ot(t,e){let n=be(t,i=>En(i,e),{adjustSelection:(i,o,r,s)=>{let a=t.value.slice(s,t.selectionEnd),c=/^\d+\.\s+/,p=/^- /,l=c.test(a),d=p.test(a),h=e.orderedList&&l||e.unorderedList&&d;if(o===r)if(h){let u=a.match(e.orderedList?c:p),f=u?u[0].length:0;return{start:Math.max(o-f,s),end:Math.max(o-f,s)}}else if(l||d){let u=a.match(l?c:p),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?c:p),f=u?u[0].length:0;return{start:Math.max(o-f,s),end:Math.max(r-f,s)}}else if(l||d){let u=a.match(l?c:p),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}}}});U(t,n)}function Tn(t){if(!t)return[];let e=[],{selectionStart:n,selectionEnd:i,value:o}=t,r=o.split(`
|
|
896
901
|
`),s=0,a="";for(let d of r){if(n>=s&&n<=s+d.length){a=d;break}s+=d.length+1}a.startsWith("- ")&&(a.startsWith("- [ ] ")||a.startsWith("- [x] ")?e.push("task-list"):e.push("bullet-list")),/^\d+\.\s/.test(a)&&e.push("numbered-list"),a.startsWith("> ")&&e.push("quote"),a.startsWith("# ")&&e.push("header"),a.startsWith("## ")&&e.push("header-2"),a.startsWith("### ")&&e.push("header-3");let c=Math.max(0,n-10),p=Math.min(o.length,i+10),l=o.slice(c,p);if(l.includes("**")){let d=o.slice(Math.max(0,n-100),n),h=o.slice(i,Math.min(o.length,i+100)),u=d.lastIndexOf("**"),f=h.indexOf("**");u!==-1&&f!==-1&&e.push("bold")}if(l.includes("_")){let d=o.slice(Math.max(0,n-100),n),h=o.slice(i,Math.min(o.length,i+100)),u=d.lastIndexOf("_"),f=h.indexOf("_");u!==-1&&f!==-1&&e.push("italic")}if(l.includes("`")){let d=o.slice(Math.max(0,n-100),n),h=o.slice(i,Math.min(o.length,i+100));d.includes("`")&&h.includes("`")&&e.push("code")}if(l.includes("[")&&l.includes("]")){let d=o.slice(Math.max(0,n-100),n),h=o.slice(i,Math.min(o.length,i+100)),u=d.lastIndexOf("["),f=h.indexOf("]");u!==-1&&f!==-1&&o.slice(i+f+1,i+f+10).startsWith("(")&&e.push("link")}return e}function rt(t){if(!t||t.disabled||t.readOnly)return;x("toggleBold","Starting"),ye(t,"Before");let e=N(I.bold),n=xe(t,e);tt(n),U(t,n),ye(t,"After")}function st(t){if(!t||t.disabled||t.readOnly)return;let e=N(I.italic),n=xe(t,e);U(t,n)}function at(t){if(!t||t.disabled||t.readOnly)return;let e=N(I.code),n=xe(t,e);U(t,n)}function lt(t,e={}){if(!t||t.disabled||t.readOnly)return;let n=t.value.slice(t.selectionStart,t.selectionEnd),i=N(I.link);if(n&&n.match(/^https?:\/\//)&&!e.url?(i.suffix=`](${n})`,i.replaceNext=""):e.url&&(i.suffix=`](${e.url})`,i.replaceNext=""),e.text&&!n){let s=t.selectionStart;t.value=t.value.slice(0,s)+e.text+t.value.slice(s),t.selectionStart=s,t.selectionEnd=s+e.text.length}let r=xe(t,i);U(t,r)}function ct(t){if(!t||t.disabled||t.readOnly)return;let e=N(I.bulletList);ot(t,e)}function pt(t){if(!t||t.disabled||t.readOnly)return;let e=N(I.numberedList);ot(t,e)}function dt(t){if(!t||t.disabled||t.readOnly)return;x("toggleQuote","Starting"),ye(t,"Initial");let e=N(I.quote),n=be(t,i=>it(i,e),{prefix:e.prefix});tt(n),U(t,n),ye(t,"Final")}function Ie(t){if(!t||t.disabled||t.readOnly)return;let e=N(I.taskList),n=be(t,i=>it(i,e),{prefix:e.prefix});U(t,n)}function Re(t,e=1,n=!1){if(!t||t.disabled||t.readOnly)return;(e<1||e>6)&&(e=1),x("insertHeader","============ START ============"),x("insertHeader",`Level: ${e}, Toggle: ${n}`),x("insertHeader",`Initial cursor: ${t.selectionStart}-${t.selectionEnd}`);let i=`header${e===1?"1":e}`,o=N(I[i]||I.header1);x("insertHeader",`Style prefix: "${o.prefix}"`);let r=t.value,s=t.selectionStart,a=t.selectionEnd,c=s;for(;c>0&&r[c-1]!==`
|
|
897
902
|
`;)c--;let p=a;for(;p<r.length&&r[p]!==`
|
|
898
|
-
`;)p++;let l=r.slice(c,p);x("insertHeader",`Current line (before): "${l}"`);let d=l.match(/^(#{1,6})\s*/),h=d?d[1].length:0,u=d?d[0].length:0;x("insertHeader","Existing header check:"),x("insertHeader",` - Match: ${d?`"${d[0]}"`:"none"}`),x("insertHeader",` - Existing level: ${h}`),x("insertHeader",` - Existing prefix length: ${u}`),x("insertHeader",` - Target level: ${e}`);let f=n&&h===e;x("insertHeader",`Should toggle OFF: ${f} (toggle=${n}, existingLevel=${h}, level=${e})`);let m=be(t,g=>{let y=g.value.slice(g.selectionStart,g.selectionEnd);x("insertHeader",`Line in operation: "${y}"`);let w=y.replace(/^#{1,6}\s*/,"");x("insertHeader",`Cleaned line: "${w}"`);let b;return f?(x("insertHeader","ACTION: Toggling OFF - removing header"),b=w):h>0?(x("insertHeader",`ACTION: Replacing H${h} with H${e}`),b=o.prefix+w):(x("insertHeader","ACTION: Adding new header"),b=o.prefix+w),x("insertHeader",`New line: "${b}"`),{text:b,selectionStart:g.selectionStart,selectionEnd:g.selectionEnd}},{prefix:o.prefix,adjustSelection:(g,y,w,b)=>{if(x("insertHeader","Adjusting selection:"),x("insertHeader",` - isRemoving param: ${g}`),x("insertHeader",` - shouldToggleOff: ${f}`),x("insertHeader",` - selStart: ${y}, selEnd: ${w}`),x("insertHeader",` - lineStartPos: ${b}`),f){let L=Math.max(y-u,b);return x("insertHeader",` - Removing header, adjusting by -${u}`),{start:L,end:y===w?L:Math.max(w-u,b)}}else if(u>0){let L=o.prefix.length-u;return x("insertHeader",` - Replacing header, adjusting by ${L}`),{start:y+L,end:w+L}}else return x("insertHeader",` - Adding header, adjusting by +${o.prefix.length}`),{start:y+o.prefix.length,end:w+o.prefix.length}}});x("insertHeader",`Final result: text="${m.text}", cursor=${m.selectionStart}-${m.selectionEnd}`),x("insertHeader","============ END ============"),U(t,m)}function ut(t){Re(t,1,!0)}function ht(t){Re(t,2,!0)}function ft(t){Re(t,3,!0)}function mt(t){return Tn(t)}var ke=class{constructor(e,n={}){this.editor=e,this.container=null,this.buttons={},this.toolbarButtons=n.toolbarButtons||[]}create(){this.container=document.createElement("div"),this.container.className="overtype-toolbar",this.container.setAttribute("role","toolbar"),this.container.setAttribute("aria-label","Formatting toolbar"),this.toolbarButtons.forEach(e=>{if(e.name==="separator"){let n=this.createSeparator();this.container.appendChild(n)}else{let n=this.createButton(e);this.buttons[e.name]=n,this.container.appendChild(n)}}),this.editor.container.insertBefore(this.container,this.editor.wrapper)}createSeparator(){let e=document.createElement("div");return e.className="overtype-toolbar-separator",e.setAttribute("role","separator"),e}createButton(e){let n=document.createElement("button");return n.className="overtype-toolbar-button",n.type="button",n.setAttribute("data-button",e.name),n.title=e.title||"",n.setAttribute("aria-label",e.title||e.name),n.innerHTML=this.sanitizeSVG(e.icon||""),e.name==="viewMode"?(n.classList.add("has-dropdown"),n.dataset.dropdown="true",n.addEventListener("click",i=>{i.preventDefault(),this.toggleViewModeDropdown(n)}),n):(n._clickHandler=i=>{i.preventDefault();let o=e.actionId||e.name;this.editor.performAction(o,i)},n.addEventListener("click",n._clickHandler),n)}async handleAction(e){if(e&&typeof e=="object"&&typeof e.action=="function"){this.editor.textarea.focus();try{return await e.action({editor:this.editor,getValue:()=>this.editor.getValue(),setValue:n=>this.editor.setValue(n),event:null}),!0}catch(n){return console.error(`Action "${e.name}" error:`,n),this.editor.wrapper.dispatchEvent(new CustomEvent("button-error",{detail:{buttonName:e.name,error:n}})),!1}}return typeof e=="string"?this.editor.performAction(e,null):!1}sanitizeSVG(e){return typeof e!="string"?"":e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/\son\w+\s*=\s*["'][^"']*["']/gi,"").replace(/\son\w+\s*=\s*[^\s>]*/gi,"")}toggleViewModeDropdown(e){let n=document.querySelector(".overtype-dropdown-menu");if(n){n.remove(),e.classList.remove("dropdown-active");return}e.classList.add("dropdown-active");let i=this.createViewModeDropdown(e),o=e.getBoundingClientRect();i.style.position="absolute",i.style.top=`${o.bottom+5}px`,i.style.left=`${o.left}px`,document.body.appendChild(i),this.handleDocumentClick=r=>{!i.contains(r.target)&&!e.contains(r.target)&&(i.remove(),e.classList.remove("dropdown-active"),document.removeEventListener("click",this.handleDocumentClick))},setTimeout(()=>{document.addEventListener("click",this.handleDocumentClick)},0)}createViewModeDropdown(e){let n=document.createElement("div");n.className="overtype-dropdown-menu";let i=[{id:"normal",label:"Normal Edit",icon:"\u2713"},{id:"plain",label:"Plain Textarea",icon:"\u2713"},{id:"preview",label:"Preview Mode",icon:"\u2713"}],o=this.editor.container.dataset.mode||"normal";return i.forEach(r=>{let s=document.createElement("button");if(s.className="overtype-dropdown-item",s.type="button",s.textContent=r.label,r.id===o){s.classList.add("active"),s.setAttribute("aria-current","true");let a=document.createElement("span");a.className="overtype-dropdown-icon",a.textContent=r.icon,s.prepend(a)}s.addEventListener("click",a=>{switch(a.preventDefault(),r.id){case"plain":this.editor.showPlainTextarea();break;case"preview":this.editor.showPreviewMode();break;case"normal":default:this.editor.showNormalEditMode();break}n.remove(),e.classList.remove("dropdown-active"),document.removeEventListener("click",this.handleDocumentClick)}),n.appendChild(s)}),n}updateButtonStates(){var e;try{let n=((e=mt)==null?void 0:e(this.editor.textarea,this.editor.textarea.selectionStart))||[];Object.entries(this.buttons).forEach(([i,o])=>{if(i==="viewMode")return;let r=!1;switch(i){case"bold":r=n.includes("bold");break;case"italic":r=n.includes("italic");break;case"code":r=!1;break;case"bulletList":r=n.includes("bullet-list");break;case"orderedList":r=n.includes("numbered-list");break;case"taskList":r=n.includes("task-list");break;case"quote":r=n.includes("quote");break;case"h1":r=n.includes("header");break;case"h2":r=n.includes("header-2");break;case"h3":r=n.includes("header-3");break}o.classList.toggle("active",r),o.setAttribute("aria-pressed",r.toString())})}catch(n){}}show(){this.container&&this.container.classList.remove("overtype-toolbar-hidden")}hide(){this.container&&this.container.classList.add("overtype-toolbar-hidden")}destroy(){this.container&&(this.handleDocumentClick&&document.removeEventListener("click",this.handleDocumentClick),Object.values(this.buttons).forEach(e=>{e._clickHandler&&(e.removeEventListener("click",e._clickHandler),delete e._clickHandler)}),this.container.remove(),this.container=null,this.buttons={})}};var le=Math.min,q=Math.max,ce=Math.round;var P=t=>({x:t,y:t}),Cn={left:"right",right:"left",bottom:"top",top:"bottom"},An={start:"end",end:"start"};function _e(t,e,n){return q(t,le(e,n))}function pe(t,e){return typeof t=="function"?t(e):t}function W(t){return t.split("-")[0]}function de(t){return t.split("-")[1]}function Be(t){return t==="x"?"y":"x"}function Ne(t){return t==="y"?"height":"width"}var Mn=new Set(["top","bottom"]);function F(t){return Mn.has(W(t))?"y":"x"}function Fe(t){return Be(F(t))}function wt(t,e,n){n===void 0&&(n=!1);let i=de(t),o=Fe(t),r=Ne(o),s=o==="x"?i===(n?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=ae(s)),[s,ae(s)]}function bt(t){let e=ae(t);return[Le(t),e,Le(e)]}function Le(t){return t.replace(/start|end/g,e=>An[e])}var vt=["left","right"],yt=["right","left"],Hn=["top","bottom"],On=["bottom","top"];function Pn(t,e,n){switch(t){case"top":case"bottom":return n?e?yt:vt:e?vt:yt;case"left":case"right":return e?Hn:On;default:return[]}}function xt(t,e,n,i){let o=de(t),r=Pn(W(t),n==="start",i);return o&&(r=r.map(s=>s+"-"+o),e&&(r=r.concat(r.map(Le)))),r}function ae(t){return t.replace(/left|right|bottom|top/g,e=>Cn[e])}function $n(t){return{top:0,right:0,bottom:0,left:0,...t}}function kt(t){return typeof t!="number"?$n(t):{top:t,right:t,bottom:t,left:t}}function G(t){let{x:e,y:n,width:i,height:o}=t;return{width:i,height:o,top:n,left:e,right:e+i,bottom:n+o,x:e,y:n}}function Lt(t,e,n){let{reference:i,floating:o}=t,r=F(e),s=Fe(e),a=Ne(s),c=W(e),p=r==="y",l=i.x+i.width/2-o.width/2,d=i.y+i.height/2-o.height/2,h=i[a]/2-o[a]/2,u;switch(c){case"top":u={x:l,y:i.y-o.height};break;case"bottom":u={x:l,y:i.y+i.height};break;case"right":u={x:i.x+i.width,y:d};break;case"left":u={x:i.x-o.width,y:d};break;default:u={x:i.x,y:i.y}}switch(de(e)){case"start":u[s]-=h*(n&&p?-1:1);break;case"end":u[s]+=h*(n&&p?-1:1);break}return u}async function St(t,e){var n;e===void 0&&(e={});let{x:i,y:o,platform:r,rects:s,elements:a,strategy:c}=t,{boundary:p="clippingAncestors",rootBoundary:l="viewport",elementContext:d="floating",altBoundary:h=!1,padding:u=0}=pe(e,t),f=kt(u),g=a[h?d==="floating"?"reference":"floating":d],y=G(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(g)))==null||n?g:g.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(a.floating)),boundary:p,rootBoundary:l,strategy:c})),w=d==="floating"?{x:i,y:o,width:s.floating.width,height:s.floating.height}:s.reference,b=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a.floating)),L=await(r.isElement==null?void 0:r.isElement(b))?await(r.getScale==null?void 0:r.getScale(b))||{x:1,y:1}:{x:1,y:1},k=G(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:b,strategy:c}):w);return{top:(y.top-k.top+f.top)/L.y,bottom:(k.bottom-y.bottom+f.bottom)/L.y,left:(y.left-k.left+f.left)/L.x,right:(k.right-y.right+f.right)/L.x}}var Et=async(t,e,n)=>{let{placement:i="bottom",strategy:o="absolute",middleware:r=[],platform:s}=n,a=r.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(e)),p=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:l,y:d}=Lt(p,i,c),h=i,u={},f=0;for(let g=0;g<a.length;g++){var m;let{name:y,fn:w}=a[g],{x:b,y:L,data:k,reset:E}=await w({x:l,y:d,initialPlacement:i,placement:h,strategy:o,middlewareData:u,rects:p,platform:{...s,detectOverflow:(m=s.detectOverflow)!=null?m:St},elements:{reference:t,floating:e}});l=b!=null?b:l,d=L!=null?L:d,u={...u,[y]:{...u[y],...k}},E&&f<=50&&(f++,typeof E=="object"&&(E.placement&&(h=E.placement),E.rects&&(p=E.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:o}):E.rects),{x:l,y:d}=Lt(p,h,c)),g=-1)}return{x:l,y:d,placement:h,strategy:o,middlewareData:u}};var Tt=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,i;let{placement:o,middlewareData:r,rects:s,initialPlacement:a,platform:c,elements:p}=e,{mainAxis:l=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:m=!0,...g}=pe(t,e);if((n=r.arrow)!=null&&n.alignmentOffset)return{};let y=W(o),w=F(a),b=W(a)===a,L=await(c.isRTL==null?void 0:c.isRTL(p.floating)),k=h||(b||!m?[ae(a)]:bt(a)),E=f!=="none";!h&&E&&k.push(...xt(a,m,f,L));let me=[a,...k],Y=await c.detectOverflow(e,g),ge=[],ee=((i=r.flip)==null?void 0:i.overflows)||[];if(l&&ge.push(Y[y]),d){let K=wt(o,s,L);ge.push(Y[K[0]],Y[K[1]])}if(ee=[...ee,{placement:o,overflows:ge}],!ge.every(K=>K<=0)){var je,Ve;let K=(((je=r.flip)==null?void 0:je.index)||0)+1,Oe=me[K];if(Oe&&(!(d==="alignment"?w!==F(Oe):!1)||ee.every(O=>F(O.placement)===w?O.overflows[0]>0:!0)))return{data:{index:K,overflows:ee},reset:{placement:Oe}};let oe=(Ve=ee.filter(Z=>Z.overflows[0]<=0).sort((Z,O)=>Z.overflows[1]-O.overflows[1])[0])==null?void 0:Ve.placement;if(!oe)switch(u){case"bestFit":{var Ue;let Z=(Ue=ee.filter(O=>{if(E){let j=F(O.placement);return j===w||j==="y"}return!0}).map(O=>[O.placement,O.overflows.filter(j=>j>0).reduce((j,ln)=>j+ln,0)]).sort((O,j)=>O[1]-j[1])[0])==null?void 0:Ue[0];Z&&(oe=Z);break}case"initialPlacement":oe=a;break}if(o!==oe)return{reset:{placement:oe}}}return{}}}};var In=new Set(["left","top"]);async function Rn(t,e){let{placement:n,platform:i,elements:o}=t,r=await(i.isRTL==null?void 0:i.isRTL(o.floating)),s=W(n),a=de(n),c=F(n)==="y",p=In.has(s)?-1:1,l=r&&c?-1:1,d=pe(e,t),{mainAxis:h,crossAxis:u,alignmentAxis:f}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof f=="number"&&(u=a==="end"?f*-1:f),c?{x:u*l,y:h*p}:{x:h*p,y:u*l}}var Ct=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,i;let{x:o,y:r,placement:s,middlewareData:a}=e,c=await Rn(e,t);return s===((n=a.offset)==null?void 0:n.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:o+c.x,y:r+c.y,data:{...c,placement:s}}}}},At=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:i,placement:o,platform:r}=e,{mainAxis:s=!0,crossAxis:a=!1,limiter:c={fn:y=>{let{x:w,y:b}=y;return{x:w,y:b}}},...p}=pe(t,e),l={x:n,y:i},d=await r.detectOverflow(e,p),h=F(W(o)),u=Be(h),f=l[u],m=l[h];if(s){let y=u==="y"?"top":"left",w=u==="y"?"bottom":"right",b=f+d[y],L=f-d[w];f=_e(b,f,L)}if(a){let y=h==="y"?"top":"left",w=h==="y"?"bottom":"right",b=m+d[y],L=m-d[w];m=_e(b,m,L)}let g=c.fn({...e,[u]:f,[h]:m});return{...g,data:{x:g.x-n,y:g.y-i,enabled:{[u]:s,[h]:a}}}}}};function Ee(){return typeof window<"u"}function J(t){return Ht(t)?(t.nodeName||"").toLowerCase():"#document"}function A(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function R(t){var e;return(e=(Ht(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Ht(t){return Ee()?t instanceof Node||t instanceof A(t).Node:!1}function M(t){return Ee()?t instanceof Element||t instanceof A(t).Element:!1}function $(t){return Ee()?t instanceof HTMLElement||t instanceof A(t).HTMLElement:!1}function Mt(t){return!Ee()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof A(t).ShadowRoot}var _n=new Set(["inline","contents"]);function te(t){let{overflow:e,overflowX:n,overflowY:i,display:o}=H(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&!_n.has(o)}var Bn=new Set(["table","td","th"]);function Ot(t){return Bn.has(J(t))}var Nn=[":popover-open",":modal"];function ue(t){return Nn.some(e=>{try{return t.matches(e)}catch(n){return!1}})}var Fn=["transform","translate","scale","rotate","perspective"],Dn=["transform","translate","scale","rotate","perspective","filter"],zn=["paint","layout","strict","content"];function Te(t){let e=Ce(),n=M(t)?H(t):t;return Fn.some(i=>n[i]?n[i]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||Dn.some(i=>(n.willChange||"").includes(i))||zn.some(i=>(n.contain||"").includes(i))}function Pt(t){let e=D(t);for(;$(e)&&!X(e);){if(Te(e))return e;if(ue(e))return null;e=D(e)}return null}function Ce(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var jn=new Set(["html","body","#document"]);function X(t){return jn.has(J(t))}function H(t){return A(t).getComputedStyle(t)}function he(t){return M(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function D(t){if(J(t)==="html")return t;let e=t.assignedSlot||t.parentNode||Mt(t)&&t.host||R(t);return Mt(e)?e.host:e}function $t(t){let e=D(t);return X(e)?t.ownerDocument?t.ownerDocument.body:t.body:$(e)&&te(e)?e:$t(e)}function Se(t,e,n){var i;e===void 0&&(e=[]),n===void 0&&(n=!0);let o=$t(t),r=o===((i=t.ownerDocument)==null?void 0:i.body),s=A(o);if(r){let a=Ae(s);return e.concat(s,s.visualViewport||[],te(o)?o:[],a&&n?Se(a):[])}return e.concat(o,Se(o,[],n))}function Ae(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Bt(t){let e=H(t),n=parseFloat(e.width)||0,i=parseFloat(e.height)||0,o=$(t),r=o?t.offsetWidth:n,s=o?t.offsetHeight:i,a=ce(n)!==r||ce(i)!==s;return a&&(n=r,i=s),{width:n,height:i,$:a}}function Nt(t){return M(t)?t:t.contextElement}function ne(t){let e=Nt(t);if(!$(e))return P(1);let n=e.getBoundingClientRect(),{width:i,height:o,$:r}=Bt(e),s=(r?ce(n.width):n.width)/i,a=(r?ce(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var Vn=P(0);function Ft(t){let e=A(t);return!Ce()||!e.visualViewport?Vn:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Un(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==A(t)?!1:e}function fe(t,e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1);let o=t.getBoundingClientRect(),r=Nt(t),s=P(1);e&&(i?M(i)&&(s=ne(i)):s=ne(t));let a=Un(r,n,i)?Ft(r):P(0),c=(o.left+a.x)/s.x,p=(o.top+a.y)/s.y,l=o.width/s.x,d=o.height/s.y;if(r){let h=A(r),u=i&&M(i)?A(i):i,f=h,m=Ae(f);for(;m&&i&&u!==f;){let g=ne(m),y=m.getBoundingClientRect(),w=H(m),b=y.left+(m.clientLeft+parseFloat(w.paddingLeft))*g.x,L=y.top+(m.clientTop+parseFloat(w.paddingTop))*g.y;c*=g.x,p*=g.y,l*=g.x,d*=g.y,c+=b,p+=L,f=A(m),m=Ae(f)}}return G({width:l,height:d,x:c,y:p})}function Me(t,e){let n=he(t).scrollLeft;return e?e.left+n:fe(R(t)).left+n}function Dt(t,e){let n=t.getBoundingClientRect(),i=n.left+e.scrollLeft-Me(t,n),o=n.top+e.scrollTop;return{x:i,y:o}}function qn(t){let{elements:e,rect:n,offsetParent:i,strategy:o}=t,r=o==="fixed",s=R(i),a=e?ue(e.floating):!1;if(i===s||a&&r)return n;let c={scrollLeft:0,scrollTop:0},p=P(1),l=P(0),d=$(i);if((d||!d&&!r)&&((J(i)!=="body"||te(s))&&(c=he(i)),$(i))){let u=fe(i);p=ne(i),l.x=u.x+i.clientLeft,l.y=u.y+i.clientTop}let h=s&&!d&&!r?Dt(s,c):P(0);return{width:n.width*p.x,height:n.height*p.y,x:n.x*p.x-c.scrollLeft*p.x+l.x+h.x,y:n.y*p.y-c.scrollTop*p.y+l.y+h.y}}function Wn(t){return Array.from(t.getClientRects())}function Kn(t){let e=R(t),n=he(t),i=t.ownerDocument.body,o=q(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),r=q(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight),s=-n.scrollLeft+Me(t),a=-n.scrollTop;return H(i).direction==="rtl"&&(s+=q(e.clientWidth,i.clientWidth)-o),{width:o,height:r,x:s,y:a}}var It=25;function Zn(t,e){let n=A(t),i=R(t),o=n.visualViewport,r=i.clientWidth,s=i.clientHeight,a=0,c=0;if(o){r=o.width,s=o.height;let l=Ce();(!l||l&&e==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}let p=Me(i);if(p<=0){let l=i.ownerDocument,d=l.body,h=getComputedStyle(d),u=l.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,f=Math.abs(i.clientWidth-d.clientWidth-u);f<=It&&(r-=f)}else p<=It&&(r+=p);return{width:r,height:s,x:a,y:c}}var Qn=new Set(["absolute","fixed"]);function Gn(t,e){let n=fe(t,!0,e==="fixed"),i=n.top+t.clientTop,o=n.left+t.clientLeft,r=$(t)?ne(t):P(1),s=t.clientWidth*r.x,a=t.clientHeight*r.y,c=o*r.x,p=i*r.y;return{width:s,height:a,x:c,y:p}}function Rt(t,e,n){let i;if(e==="viewport")i=Zn(t,n);else if(e==="document")i=Kn(R(t));else if(M(e))i=Gn(e,n);else{let o=Ft(t);i={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return G(i)}function zt(t,e){let n=D(t);return n===e||!M(n)||X(n)?!1:H(n).position==="fixed"||zt(n,e)}function Jn(t,e){let n=e.get(t);if(n)return n;let i=Se(t,[],!1).filter(a=>M(a)&&J(a)!=="body"),o=null,r=H(t).position==="fixed",s=r?D(t):t;for(;M(s)&&!X(s);){let a=H(s),c=Te(s);!c&&a.position==="fixed"&&(o=null),(r?!c&&!o:!c&&a.position==="static"&&!!o&&Qn.has(o.position)||te(s)&&!c&&zt(t,s))?i=i.filter(l=>l!==s):o=a,s=D(s)}return e.set(t,i),i}function Xn(t){let{element:e,boundary:n,rootBoundary:i,strategy:o}=t,s=[...n==="clippingAncestors"?ue(e)?[]:Jn(e,this._c):[].concat(n),i],a=s[0],c=s.reduce((p,l)=>{let d=Rt(e,l,o);return p.top=q(d.top,p.top),p.right=le(d.right,p.right),p.bottom=le(d.bottom,p.bottom),p.left=q(d.left,p.left),p},Rt(e,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Yn(t){let{width:e,height:n}=Bt(t);return{width:e,height:n}}function ei(t,e,n){let i=$(e),o=R(e),r=n==="fixed",s=fe(t,!0,r,e),a={scrollLeft:0,scrollTop:0},c=P(0);function p(){c.x=Me(o)}if(i||!i&&!r)if((J(e)!=="body"||te(o))&&(a=he(e)),i){let u=fe(e,!0,r,e);c.x=u.x+e.clientLeft,c.y=u.y+e.clientTop}else o&&p();r&&!i&&o&&p();let l=o&&!i&&!r?Dt(o,a):P(0),d=s.left+a.scrollLeft-c.x-l.x,h=s.top+a.scrollTop-c.y-l.y;return{x:d,y:h,width:s.width,height:s.height}}function De(t){return H(t).position==="static"}function _t(t,e){if(!$(t)||H(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return R(t)===n&&(n=n.ownerDocument.body),n}function jt(t,e){let n=A(t);if(ue(t))return n;if(!$(t)){let o=D(t);for(;o&&!X(o);){if(M(o)&&!De(o))return o;o=D(o)}return n}let i=_t(t,e);for(;i&&Ot(i)&&De(i);)i=_t(i,e);return i&&X(i)&&De(i)&&!Te(i)?n:i||Pt(t)||n}var ti=async function(t){let e=this.getOffsetParent||jt,n=this.getDimensions,i=await n(t.floating);return{reference:ei(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function ni(t){return H(t).direction==="rtl"}var ii={convertOffsetParentRelativeRectToViewportRelativeRect:qn,getDocumentElement:R,getClippingRect:Xn,getOffsetParent:jt,getElementRects:ti,getClientRects:Wn,getDimensions:Yn,getScale:ne,isElement:M,isRTL:ni};var Vt=Ct;var Ut=At,qt=Tt;var Wt=(t,e,n)=>{let i=new Map,o={platform:ii,...n},r={...o.platform,_c:i};return Et(t,e,{...o,platform:r})};var He=class{constructor(e){this.editor=e,this.tooltip=null,this.currentLink=null,this.hideTimeout=null,this.visibilityChangeHandler=null,this.isTooltipHovered=!1,this.init()}init(){this.createTooltip(),this.editor.textarea.addEventListener("selectionchange",()=>this.checkCursorPosition()),this.editor.textarea.addEventListener("keyup",e=>{(e.key.includes("Arrow")||e.key==="Home"||e.key==="End")&&this.checkCursorPosition()}),this.editor.textarea.addEventListener("input",()=>this.hide()),this.editor.textarea.addEventListener("scroll",()=>{this.currentLink&&this.positionTooltip(this.currentLink)}),this.editor.textarea.addEventListener("blur",()=>{this.isTooltipHovered||this.hide()}),this.visibilityChangeHandler=()=>{document.hidden&&this.hide()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),this.tooltip.addEventListener("mouseenter",()=>{this.isTooltipHovered=!0,this.cancelHide()}),this.tooltip.addEventListener("mouseleave",()=>{this.isTooltipHovered=!1,this.scheduleHide()})}createTooltip(){this.tooltip=document.createElement("div"),this.tooltip.className="overtype-link-tooltip",this.tooltip.innerHTML=`
|
|
903
|
+
`;)p++;let l=r.slice(c,p);x("insertHeader",`Current line (before): "${l}"`);let d=l.match(/^(#{1,6})\s*/),h=d?d[1].length:0,u=d?d[0].length:0;x("insertHeader","Existing header check:"),x("insertHeader",` - Match: ${d?`"${d[0]}"`:"none"}`),x("insertHeader",` - Existing level: ${h}`),x("insertHeader",` - Existing prefix length: ${u}`),x("insertHeader",` - Target level: ${e}`);let f=n&&h===e;x("insertHeader",`Should toggle OFF: ${f} (toggle=${n}, existingLevel=${h}, level=${e})`);let m=be(t,g=>{let y=g.value.slice(g.selectionStart,g.selectionEnd);x("insertHeader",`Line in operation: "${y}"`);let w=y.replace(/^#{1,6}\s*/,"");x("insertHeader",`Cleaned line: "${w}"`);let b;return f?(x("insertHeader","ACTION: Toggling OFF - removing header"),b=w):h>0?(x("insertHeader",`ACTION: Replacing H${h} with H${e}`),b=o.prefix+w):(x("insertHeader","ACTION: Adding new header"),b=o.prefix+w),x("insertHeader",`New line: "${b}"`),{text:b,selectionStart:g.selectionStart,selectionEnd:g.selectionEnd}},{prefix:o.prefix,adjustSelection:(g,y,w,b)=>{if(x("insertHeader","Adjusting selection:"),x("insertHeader",` - isRemoving param: ${g}`),x("insertHeader",` - shouldToggleOff: ${f}`),x("insertHeader",` - selStart: ${y}, selEnd: ${w}`),x("insertHeader",` - lineStartPos: ${b}`),f){let L=Math.max(y-u,b);return x("insertHeader",` - Removing header, adjusting by -${u}`),{start:L,end:y===w?L:Math.max(w-u,b)}}else if(u>0){let L=o.prefix.length-u;return x("insertHeader",` - Replacing header, adjusting by ${L}`),{start:y+L,end:w+L}}else return x("insertHeader",` - Adding header, adjusting by +${o.prefix.length}`),{start:y+o.prefix.length,end:w+o.prefix.length}}});x("insertHeader",`Final result: text="${m.text}", cursor=${m.selectionStart}-${m.selectionEnd}`),x("insertHeader","============ END ============"),U(t,m)}function ut(t){Re(t,1,!0)}function ht(t){Re(t,2,!0)}function ft(t){Re(t,3,!0)}function mt(t){return Tn(t)}var ke=class{constructor(e,n={}){this.editor=e,this.container=null,this.buttons={},this.toolbarButtons=n.toolbarButtons||[]}create(){this.container=document.createElement("div"),this.container.className="overtype-toolbar",this.container.setAttribute("role","toolbar"),this.container.setAttribute("aria-label","Formatting toolbar"),this.toolbarButtons.forEach(e=>{if(e.name==="separator"){let n=this.createSeparator();this.container.appendChild(n)}else{let n=this.createButton(e);this.buttons[e.name]=n,this.container.appendChild(n)}}),this.editor.container.insertBefore(this.container,this.editor.wrapper)}createSeparator(){let e=document.createElement("div");return e.className="overtype-toolbar-separator",e.setAttribute("role","separator"),e}createButton(e){let n=document.createElement("button");return n.className="overtype-toolbar-button",n.type="button",n.setAttribute("data-button",e.name),n.title=e.title||"",n.setAttribute("aria-label",e.title||e.name),n.innerHTML=this.sanitizeSVG(e.icon||""),e.name==="viewMode"?(n.classList.add("has-dropdown"),n.dataset.dropdown="true",n.addEventListener("click",i=>{i.preventDefault(),this.toggleViewModeDropdown(n)}),n):(n._clickHandler=i=>{i.preventDefault();let o=e.actionId||e.name;this.editor.performAction(o,i)},n.addEventListener("click",n._clickHandler),n)}async handleAction(e){if(e&&typeof e=="object"&&typeof e.action=="function"){this.editor.textarea.focus();try{return await e.action({editor:this.editor,getValue:()=>this.editor.getValue(),setValue:n=>this.editor.setValue(n),event:null}),!0}catch(n){return console.error(`Action "${e.name}" error:`,n),this.editor.wrapper.dispatchEvent(new CustomEvent("button-error",{detail:{buttonName:e.name,error:n}})),!1}}return typeof e=="string"?this.editor.performAction(e,null):!1}sanitizeSVG(e){return typeof e!="string"?"":e.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/\son\w+\s*=\s*["'][^"']*["']/gi,"").replace(/\son\w+\s*=\s*[^\s>]*/gi,"")}toggleViewModeDropdown(e){let n=document.querySelector(".overtype-dropdown-menu");if(n){n.remove(),e.classList.remove("dropdown-active");return}e.classList.add("dropdown-active");let i=this.createViewModeDropdown(e),o=e.getBoundingClientRect();i.style.position="absolute",i.style.top=`${o.bottom+5}px`,i.style.left=`${o.left}px`,document.body.appendChild(i),this.handleDocumentClick=r=>{!i.contains(r.target)&&!e.contains(r.target)&&(i.remove(),e.classList.remove("dropdown-active"),document.removeEventListener("click",this.handleDocumentClick))},setTimeout(()=>{document.addEventListener("click",this.handleDocumentClick)},0)}createViewModeDropdown(e){let n=document.createElement("div");n.className="overtype-dropdown-menu";let i=[{id:"normal",label:"Normal Edit",icon:"\u2713"},{id:"plain",label:"Plain Textarea",icon:"\u2713"},{id:"preview",label:"Preview Mode",icon:"\u2713"}],o=this.editor.container.dataset.mode||"normal";return i.forEach(r=>{let s=document.createElement("button");if(s.className="overtype-dropdown-item",s.type="button",s.textContent=r.label,r.id===o){s.classList.add("active"),s.setAttribute("aria-current","true");let a=document.createElement("span");a.className="overtype-dropdown-icon",a.textContent=r.icon,s.prepend(a)}s.addEventListener("click",a=>{switch(a.preventDefault(),r.id){case"plain":this.editor.showPlainTextarea();break;case"preview":this.editor.showPreviewMode();break;case"normal":default:this.editor.showNormalEditMode();break}n.remove(),e.classList.remove("dropdown-active"),document.removeEventListener("click",this.handleDocumentClick)}),n.appendChild(s)}),n}updateButtonStates(){var e;try{let n=((e=mt)==null?void 0:e(this.editor.textarea,this.editor.textarea.selectionStart))||[];Object.entries(this.buttons).forEach(([i,o])=>{if(i==="viewMode")return;let r=!1;switch(i){case"bold":r=n.includes("bold");break;case"italic":r=n.includes("italic");break;case"code":r=!1;break;case"bulletList":r=n.includes("bullet-list");break;case"orderedList":r=n.includes("numbered-list");break;case"taskList":r=n.includes("task-list");break;case"quote":r=n.includes("quote");break;case"h1":r=n.includes("header");break;case"h2":r=n.includes("header-2");break;case"h3":r=n.includes("header-3");break}o.classList.toggle("active",r),o.setAttribute("aria-pressed",r.toString())})}catch(n){}}show(){this.container&&this.container.classList.remove("overtype-toolbar-hidden")}hide(){this.container&&this.container.classList.add("overtype-toolbar-hidden")}destroy(){this.container&&(this.handleDocumentClick&&document.removeEventListener("click",this.handleDocumentClick),Object.values(this.buttons).forEach(e=>{e._clickHandler&&(e.removeEventListener("click",e._clickHandler),delete e._clickHandler)}),this.container.remove(),this.container=null,this.buttons={})}};var le=Math.min,q=Math.max,ce=Math.round;var O=t=>({x:t,y:t}),Cn={left:"right",right:"left",bottom:"top",top:"bottom"},An={start:"end",end:"start"};function _e(t,e,n){return q(t,le(e,n))}function pe(t,e){return typeof t=="function"?t(e):t}function W(t){return t.split("-")[0]}function de(t){return t.split("-")[1]}function Be(t){return t==="x"?"y":"x"}function Ne(t){return t==="y"?"height":"width"}var Mn=new Set(["top","bottom"]);function F(t){return Mn.has(W(t))?"y":"x"}function Fe(t){return Be(F(t))}function wt(t,e,n){n===void 0&&(n=!1);let i=de(t),o=Fe(t),r=Ne(o),s=o==="x"?i===(n?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=ae(s)),[s,ae(s)]}function bt(t){let e=ae(t);return[Le(t),e,Le(e)]}function Le(t){return t.replace(/start|end/g,e=>An[e])}var vt=["left","right"],yt=["right","left"],Hn=["top","bottom"],Pn=["bottom","top"];function On(t,e,n){switch(t){case"top":case"bottom":return n?e?yt:vt:e?vt:yt;case"left":case"right":return e?Hn:Pn;default:return[]}}function xt(t,e,n,i){let o=de(t),r=On(W(t),n==="start",i);return o&&(r=r.map(s=>s+"-"+o),e&&(r=r.concat(r.map(Le)))),r}function ae(t){return t.replace(/left|right|bottom|top/g,e=>Cn[e])}function $n(t){return{top:0,right:0,bottom:0,left:0,...t}}function kt(t){return typeof t!="number"?$n(t):{top:t,right:t,bottom:t,left:t}}function G(t){let{x:e,y:n,width:i,height:o}=t;return{width:i,height:o,top:n,left:e,right:e+i,bottom:n+o,x:e,y:n}}function Lt(t,e,n){let{reference:i,floating:o}=t,r=F(e),s=Fe(e),a=Ne(s),c=W(e),p=r==="y",l=i.x+i.width/2-o.width/2,d=i.y+i.height/2-o.height/2,h=i[a]/2-o[a]/2,u;switch(c){case"top":u={x:l,y:i.y-o.height};break;case"bottom":u={x:l,y:i.y+i.height};break;case"right":u={x:i.x+i.width,y:d};break;case"left":u={x:i.x-o.width,y:d};break;default:u={x:i.x,y:i.y}}switch(de(e)){case"start":u[s]-=h*(n&&p?-1:1);break;case"end":u[s]+=h*(n&&p?-1:1);break}return u}async function St(t,e){var n;e===void 0&&(e={});let{x:i,y:o,platform:r,rects:s,elements:a,strategy:c}=t,{boundary:p="clippingAncestors",rootBoundary:l="viewport",elementContext:d="floating",altBoundary:h=!1,padding:u=0}=pe(e,t),f=kt(u),g=a[h?d==="floating"?"reference":"floating":d],y=G(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(g)))==null||n?g:g.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(a.floating)),boundary:p,rootBoundary:l,strategy:c})),w=d==="floating"?{x:i,y:o,width:s.floating.width,height:s.floating.height}:s.reference,b=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a.floating)),L=await(r.isElement==null?void 0:r.isElement(b))?await(r.getScale==null?void 0:r.getScale(b))||{x:1,y:1}:{x:1,y:1},k=G(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:b,strategy:c}):w);return{top:(y.top-k.top+f.top)/L.y,bottom:(k.bottom-y.bottom+f.bottom)/L.y,left:(y.left-k.left+f.left)/L.x,right:(k.right-y.right+f.right)/L.x}}var Et=async(t,e,n)=>{let{placement:i="bottom",strategy:o="absolute",middleware:r=[],platform:s}=n,a=r.filter(Boolean),c=await(s.isRTL==null?void 0:s.isRTL(e)),p=await s.getElementRects({reference:t,floating:e,strategy:o}),{x:l,y:d}=Lt(p,i,c),h=i,u={},f=0;for(let g=0;g<a.length;g++){var m;let{name:y,fn:w}=a[g],{x:b,y:L,data:k,reset:E}=await w({x:l,y:d,initialPlacement:i,placement:h,strategy:o,middlewareData:u,rects:p,platform:{...s,detectOverflow:(m=s.detectOverflow)!=null?m:St},elements:{reference:t,floating:e}});l=b!=null?b:l,d=L!=null?L:d,u={...u,[y]:{...u[y],...k}},E&&f<=50&&(f++,typeof E=="object"&&(E.placement&&(h=E.placement),E.rects&&(p=E.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:o}):E.rects),{x:l,y:d}=Lt(p,h,c)),g=-1)}return{x:l,y:d,placement:h,strategy:o,middlewareData:u}};var Tt=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,i;let{placement:o,middlewareData:r,rects:s,initialPlacement:a,platform:c,elements:p}=e,{mainAxis:l=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:u="bestFit",fallbackAxisSideDirection:f="none",flipAlignment:m=!0,...g}=pe(t,e);if((n=r.arrow)!=null&&n.alignmentOffset)return{};let y=W(o),w=F(a),b=W(a)===a,L=await(c.isRTL==null?void 0:c.isRTL(p.floating)),k=h||(b||!m?[ae(a)]:bt(a)),E=f!=="none";!h&&E&&k.push(...xt(a,m,f,L));let me=[a,...k],Y=await c.detectOverflow(e,g),ge=[],ee=((i=r.flip)==null?void 0:i.overflows)||[];if(l&&ge.push(Y[y]),d){let K=wt(o,s,L);ge.push(Y[K[0]],Y[K[1]])}if(ee=[...ee,{placement:o,overflows:ge}],!ge.every(K=>K<=0)){var je,Ve;let K=(((je=r.flip)==null?void 0:je.index)||0)+1,Pe=me[K];if(Pe&&(!(d==="alignment"?w!==F(Pe):!1)||ee.every(P=>F(P.placement)===w?P.overflows[0]>0:!0)))return{data:{index:K,overflows:ee},reset:{placement:Pe}};let oe=(Ve=ee.filter(Z=>Z.overflows[0]<=0).sort((Z,P)=>Z.overflows[1]-P.overflows[1])[0])==null?void 0:Ve.placement;if(!oe)switch(u){case"bestFit":{var Ue;let Z=(Ue=ee.filter(P=>{if(E){let j=F(P.placement);return j===w||j==="y"}return!0}).map(P=>[P.placement,P.overflows.filter(j=>j>0).reduce((j,ln)=>j+ln,0)]).sort((P,j)=>P[1]-j[1])[0])==null?void 0:Ue[0];Z&&(oe=Z);break}case"initialPlacement":oe=a;break}if(o!==oe)return{reset:{placement:oe}}}return{}}}};var In=new Set(["left","top"]);async function Rn(t,e){let{placement:n,platform:i,elements:o}=t,r=await(i.isRTL==null?void 0:i.isRTL(o.floating)),s=W(n),a=de(n),c=F(n)==="y",p=In.has(s)?-1:1,l=r&&c?-1:1,d=pe(e,t),{mainAxis:h,crossAxis:u,alignmentAxis:f}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof f=="number"&&(u=a==="end"?f*-1:f),c?{x:u*l,y:h*p}:{x:h*p,y:u*l}}var Ct=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,i;let{x:o,y:r,placement:s,middlewareData:a}=e,c=await Rn(e,t);return s===((n=a.offset)==null?void 0:n.placement)&&(i=a.arrow)!=null&&i.alignmentOffset?{}:{x:o+c.x,y:r+c.y,data:{...c,placement:s}}}}},At=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:i,placement:o,platform:r}=e,{mainAxis:s=!0,crossAxis:a=!1,limiter:c={fn:y=>{let{x:w,y:b}=y;return{x:w,y:b}}},...p}=pe(t,e),l={x:n,y:i},d=await r.detectOverflow(e,p),h=F(W(o)),u=Be(h),f=l[u],m=l[h];if(s){let y=u==="y"?"top":"left",w=u==="y"?"bottom":"right",b=f+d[y],L=f-d[w];f=_e(b,f,L)}if(a){let y=h==="y"?"top":"left",w=h==="y"?"bottom":"right",b=m+d[y],L=m-d[w];m=_e(b,m,L)}let g=c.fn({...e,[u]:f,[h]:m});return{...g,data:{x:g.x-n,y:g.y-i,enabled:{[u]:s,[h]:a}}}}}};function Ee(){return typeof window<"u"}function J(t){return Ht(t)?(t.nodeName||"").toLowerCase():"#document"}function A(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function R(t){var e;return(e=(Ht(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Ht(t){return Ee()?t instanceof Node||t instanceof A(t).Node:!1}function M(t){return Ee()?t instanceof Element||t instanceof A(t).Element:!1}function $(t){return Ee()?t instanceof HTMLElement||t instanceof A(t).HTMLElement:!1}function Mt(t){return!Ee()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof A(t).ShadowRoot}var _n=new Set(["inline","contents"]);function te(t){let{overflow:e,overflowX:n,overflowY:i,display:o}=H(t);return/auto|scroll|overlay|hidden|clip/.test(e+i+n)&&!_n.has(o)}var Bn=new Set(["table","td","th"]);function Pt(t){return Bn.has(J(t))}var Nn=[":popover-open",":modal"];function ue(t){return Nn.some(e=>{try{return t.matches(e)}catch(n){return!1}})}var Fn=["transform","translate","scale","rotate","perspective"],Dn=["transform","translate","scale","rotate","perspective","filter"],zn=["paint","layout","strict","content"];function Te(t){let e=Ce(),n=M(t)?H(t):t;return Fn.some(i=>n[i]?n[i]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||Dn.some(i=>(n.willChange||"").includes(i))||zn.some(i=>(n.contain||"").includes(i))}function Ot(t){let e=D(t);for(;$(e)&&!X(e);){if(Te(e))return e;if(ue(e))return null;e=D(e)}return null}function Ce(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var jn=new Set(["html","body","#document"]);function X(t){return jn.has(J(t))}function H(t){return A(t).getComputedStyle(t)}function he(t){return M(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function D(t){if(J(t)==="html")return t;let e=t.assignedSlot||t.parentNode||Mt(t)&&t.host||R(t);return Mt(e)?e.host:e}function $t(t){let e=D(t);return X(e)?t.ownerDocument?t.ownerDocument.body:t.body:$(e)&&te(e)?e:$t(e)}function Se(t,e,n){var i;e===void 0&&(e=[]),n===void 0&&(n=!0);let o=$t(t),r=o===((i=t.ownerDocument)==null?void 0:i.body),s=A(o);if(r){let a=Ae(s);return e.concat(s,s.visualViewport||[],te(o)?o:[],a&&n?Se(a):[])}return e.concat(o,Se(o,[],n))}function Ae(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Bt(t){let e=H(t),n=parseFloat(e.width)||0,i=parseFloat(e.height)||0,o=$(t),r=o?t.offsetWidth:n,s=o?t.offsetHeight:i,a=ce(n)!==r||ce(i)!==s;return a&&(n=r,i=s),{width:n,height:i,$:a}}function Nt(t){return M(t)?t:t.contextElement}function ne(t){let e=Nt(t);if(!$(e))return O(1);let n=e.getBoundingClientRect(),{width:i,height:o,$:r}=Bt(e),s=(r?ce(n.width):n.width)/i,a=(r?ce(n.height):n.height)/o;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var Vn=O(0);function Ft(t){let e=A(t);return!Ce()||!e.visualViewport?Vn:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Un(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==A(t)?!1:e}function fe(t,e,n,i){e===void 0&&(e=!1),n===void 0&&(n=!1);let o=t.getBoundingClientRect(),r=Nt(t),s=O(1);e&&(i?M(i)&&(s=ne(i)):s=ne(t));let a=Un(r,n,i)?Ft(r):O(0),c=(o.left+a.x)/s.x,p=(o.top+a.y)/s.y,l=o.width/s.x,d=o.height/s.y;if(r){let h=A(r),u=i&&M(i)?A(i):i,f=h,m=Ae(f);for(;m&&i&&u!==f;){let g=ne(m),y=m.getBoundingClientRect(),w=H(m),b=y.left+(m.clientLeft+parseFloat(w.paddingLeft))*g.x,L=y.top+(m.clientTop+parseFloat(w.paddingTop))*g.y;c*=g.x,p*=g.y,l*=g.x,d*=g.y,c+=b,p+=L,f=A(m),m=Ae(f)}}return G({width:l,height:d,x:c,y:p})}function Me(t,e){let n=he(t).scrollLeft;return e?e.left+n:fe(R(t)).left+n}function Dt(t,e){let n=t.getBoundingClientRect(),i=n.left+e.scrollLeft-Me(t,n),o=n.top+e.scrollTop;return{x:i,y:o}}function qn(t){let{elements:e,rect:n,offsetParent:i,strategy:o}=t,r=o==="fixed",s=R(i),a=e?ue(e.floating):!1;if(i===s||a&&r)return n;let c={scrollLeft:0,scrollTop:0},p=O(1),l=O(0),d=$(i);if((d||!d&&!r)&&((J(i)!=="body"||te(s))&&(c=he(i)),$(i))){let u=fe(i);p=ne(i),l.x=u.x+i.clientLeft,l.y=u.y+i.clientTop}let h=s&&!d&&!r?Dt(s,c):O(0);return{width:n.width*p.x,height:n.height*p.y,x:n.x*p.x-c.scrollLeft*p.x+l.x+h.x,y:n.y*p.y-c.scrollTop*p.y+l.y+h.y}}function Wn(t){return Array.from(t.getClientRects())}function Kn(t){let e=R(t),n=he(t),i=t.ownerDocument.body,o=q(e.scrollWidth,e.clientWidth,i.scrollWidth,i.clientWidth),r=q(e.scrollHeight,e.clientHeight,i.scrollHeight,i.clientHeight),s=-n.scrollLeft+Me(t),a=-n.scrollTop;return H(i).direction==="rtl"&&(s+=q(e.clientWidth,i.clientWidth)-o),{width:o,height:r,x:s,y:a}}var It=25;function Zn(t,e){let n=A(t),i=R(t),o=n.visualViewport,r=i.clientWidth,s=i.clientHeight,a=0,c=0;if(o){r=o.width,s=o.height;let l=Ce();(!l||l&&e==="fixed")&&(a=o.offsetLeft,c=o.offsetTop)}let p=Me(i);if(p<=0){let l=i.ownerDocument,d=l.body,h=getComputedStyle(d),u=l.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,f=Math.abs(i.clientWidth-d.clientWidth-u);f<=It&&(r-=f)}else p<=It&&(r+=p);return{width:r,height:s,x:a,y:c}}var Qn=new Set(["absolute","fixed"]);function Gn(t,e){let n=fe(t,!0,e==="fixed"),i=n.top+t.clientTop,o=n.left+t.clientLeft,r=$(t)?ne(t):O(1),s=t.clientWidth*r.x,a=t.clientHeight*r.y,c=o*r.x,p=i*r.y;return{width:s,height:a,x:c,y:p}}function Rt(t,e,n){let i;if(e==="viewport")i=Zn(t,n);else if(e==="document")i=Kn(R(t));else if(M(e))i=Gn(e,n);else{let o=Ft(t);i={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return G(i)}function zt(t,e){let n=D(t);return n===e||!M(n)||X(n)?!1:H(n).position==="fixed"||zt(n,e)}function Jn(t,e){let n=e.get(t);if(n)return n;let i=Se(t,[],!1).filter(a=>M(a)&&J(a)!=="body"),o=null,r=H(t).position==="fixed",s=r?D(t):t;for(;M(s)&&!X(s);){let a=H(s),c=Te(s);!c&&a.position==="fixed"&&(o=null),(r?!c&&!o:!c&&a.position==="static"&&!!o&&Qn.has(o.position)||te(s)&&!c&&zt(t,s))?i=i.filter(l=>l!==s):o=a,s=D(s)}return e.set(t,i),i}function Xn(t){let{element:e,boundary:n,rootBoundary:i,strategy:o}=t,s=[...n==="clippingAncestors"?ue(e)?[]:Jn(e,this._c):[].concat(n),i],a=s[0],c=s.reduce((p,l)=>{let d=Rt(e,l,o);return p.top=q(d.top,p.top),p.right=le(d.right,p.right),p.bottom=le(d.bottom,p.bottom),p.left=q(d.left,p.left),p},Rt(e,a,o));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Yn(t){let{width:e,height:n}=Bt(t);return{width:e,height:n}}function ei(t,e,n){let i=$(e),o=R(e),r=n==="fixed",s=fe(t,!0,r,e),a={scrollLeft:0,scrollTop:0},c=O(0);function p(){c.x=Me(o)}if(i||!i&&!r)if((J(e)!=="body"||te(o))&&(a=he(e)),i){let u=fe(e,!0,r,e);c.x=u.x+e.clientLeft,c.y=u.y+e.clientTop}else o&&p();r&&!i&&o&&p();let l=o&&!i&&!r?Dt(o,a):O(0),d=s.left+a.scrollLeft-c.x-l.x,h=s.top+a.scrollTop-c.y-l.y;return{x:d,y:h,width:s.width,height:s.height}}function De(t){return H(t).position==="static"}function _t(t,e){if(!$(t)||H(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return R(t)===n&&(n=n.ownerDocument.body),n}function jt(t,e){let n=A(t);if(ue(t))return n;if(!$(t)){let o=D(t);for(;o&&!X(o);){if(M(o)&&!De(o))return o;o=D(o)}return n}let i=_t(t,e);for(;i&&Pt(i)&&De(i);)i=_t(i,e);return i&&X(i)&&De(i)&&!Te(i)?n:i||Ot(t)||n}var ti=async function(t){let e=this.getOffsetParent||jt,n=this.getDimensions,i=await n(t.floating);return{reference:ei(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function ni(t){return H(t).direction==="rtl"}var ii={convertOffsetParentRelativeRectToViewportRelativeRect:qn,getDocumentElement:R,getClippingRect:Xn,getOffsetParent:jt,getElementRects:ti,getClientRects:Wn,getDimensions:Yn,getScale:ne,isElement:M,isRTL:ni};var Vt=Ct;var Ut=At,qt=Tt;var Wt=(t,e,n)=>{let i=new Map,o={platform:ii,...n},r={...o.platform,_c:i};return Et(t,e,{...o,platform:r})};var He=class{constructor(e){this.editor=e,this.tooltip=null,this.currentLink=null,this.hideTimeout=null,this.visibilityChangeHandler=null,this.isTooltipHovered=!1,this.init()}init(){this.createTooltip(),this.editor.textarea.addEventListener("selectionchange",()=>this.checkCursorPosition()),this.editor.textarea.addEventListener("keyup",e=>{(e.key.includes("Arrow")||e.key==="Home"||e.key==="End")&&this.checkCursorPosition()}),this.editor.textarea.addEventListener("input",()=>this.hide()),this.editor.textarea.addEventListener("scroll",()=>{this.currentLink&&this.positionTooltip(this.currentLink)}),this.editor.textarea.addEventListener("blur",()=>{this.isTooltipHovered||this.hide()}),this.visibilityChangeHandler=()=>{document.hidden&&this.hide()},document.addEventListener("visibilitychange",this.visibilityChangeHandler),this.tooltip.addEventListener("mouseenter",()=>{this.isTooltipHovered=!0,this.cancelHide()}),this.tooltip.addEventListener("mouseleave",()=>{this.isTooltipHovered=!1,this.scheduleHide()})}createTooltip(){this.tooltip=document.createElement("div"),this.tooltip.className="overtype-link-tooltip",this.tooltip.innerHTML=`
|
|
899
904
|
<span style="display: flex; align-items: center; gap: 6px;">
|
|
900
905
|
<svg width="12" height="12" viewBox="0 0 20 20" fill="currentColor" style="flex-shrink: 0;">
|
|
901
906
|
<path d="M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z"></path>
|
|
@@ -966,7 +971,7 @@ ${a}`:r;if(p){let k=t.value[t.selectionStart-1];t.selectionStart!==0&&k!=null&&!
|
|
|
966
971
|
`+n),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}splitListItem(e,n){let i=e.content.substring(n-e.markerEndPos);this.textarea.setSelectionRange(n,e.lineEnd),document.execCommand("delete");let o=T.createNewListItem(e);document.execCommand("insertText",!1,`
|
|
967
972
|
`+o+i);let r=this.textarea.selectionStart-i.length;this.textarea.setSelectionRange(r,r),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}scheduleNumberedListUpdate(){this.numberUpdateTimeout&&clearTimeout(this.numberUpdateTimeout),this.numberUpdateTimeout=setTimeout(()=>{this.updateNumberedLists()},10)}updateNumberedLists(){let e=this.textarea.value,n=this.textarea.selectionStart,i=T.renumberLists(e);if(i!==e){let o=0,r=e.split(`
|
|
968
973
|
`),s=i.split(`
|
|
969
|
-
`),a=0;for(let p=0;p<r.length&&a<n;p++){if(r[p]!==s[p]){let l=s[p].length-r[p].length;a+r[p].length<n&&(o+=l)}a+=r[p].length+1}this.textarea.value=i;let c=n+o;this.textarea.setSelectionRange(c,c),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}}handleScroll(e){this.preview.scrollTop=this.textarea.scrollTop,this.preview.scrollLeft=this.textarea.scrollLeft}getValue(){return this.textarea.value}setValue(e){this.textarea.value=e,this.updatePreview(),this.options.autoResize&&this._updateAutoHeight()}async performAction(e,n=null){var r;let i=this.textarea;if(!i)return!1;let o=(r=this.actionsById)==null?void 0:r[e];if(!o)return console.warn(`OverType: Unknown action "${e}"`),!1;i.focus();try{return await o({editor:this,getValue:()=>this.getValue(),setValue:s=>this.setValue(s),event:n}),!0}catch(s){return console.error(`OverType: Action "${e}" error:`,s),this.wrapper.dispatchEvent(new CustomEvent("button-error",{detail:{actionId:e,error:s}})),!1}}getRenderedHTML(e={}){let n=this.getValue(),i=T.parse(n,-1,!1,this.options.codeHighlighter);return e.cleanHTML&&(i=i.replace(/<span class="syntax-marker[^"]*">.*?<\/span>/g,""),i=i.replace(/\sclass="(bullet-list|ordered-list|code-fence|hr-marker|blockquote|url-part)"/g,""),i=i.replace(/\sclass=""/g,"")),i}getPreviewHTML(){return this.preview.innerHTML}getCleanHTML(){return this.getRenderedHTML({cleanHTML:!0})}focus(){this.textarea.focus()}blur(){this.textarea.blur()}isInitialized(){return this.initialized}reinit(e={}){var o;let n=(o=this.options)==null?void 0:o.toolbarButtons;this.options=this._mergeOptions({...this.options,...e});let i=this.toolbar&&this.options.toolbar&&ri(n,this.options.toolbarButtons);this._rebuildActionsMap(),i&&(this._cleanupToolbarListeners(),this.toolbar.destroy(),this.toolbar=null,this._createToolbar()),this.fileUploadInitialized&&this._destroyFileUpload(),this.options.fileUpload&&this._initFileUpload(),this._applyOptions(),this.updatePreview()}showToolbar(){this.toolbar?this.toolbar.show():this._createToolbar()}hideToolbar(){this.toolbar&&this.toolbar.hide()}setTheme(e){if(v._autoInstances.delete(this),this.instanceTheme=e,e==="auto")v._autoInstances.add(this),v._startAutoListener(),this._applyResolvedTheme(
|
|
974
|
+
`),a=0;for(let p=0;p<r.length&&a<n;p++){if(r[p]!==s[p]){let l=s[p].length-r[p].length;a+r[p].length<n&&(o+=l)}a+=r[p].length+1}this.textarea.value=i;let c=n+o;this.textarea.setSelectionRange(c,c),this.textarea.dispatchEvent(new Event("input",{bubbles:!0}))}}handleScroll(e){this.preview.scrollTop=this.textarea.scrollTop,this.preview.scrollLeft=this.textarea.scrollLeft}getValue(){return this.textarea.value}setValue(e){this.textarea.value=e,this.updatePreview(),this.options.autoResize&&this._updateAutoHeight()}async performAction(e,n=null){var r;let i=this.textarea;if(!i)return!1;let o=(r=this.actionsById)==null?void 0:r[e];if(!o)return console.warn(`OverType: Unknown action "${e}"`),!1;i.focus();try{return await o({editor:this,getValue:()=>this.getValue(),setValue:s=>this.setValue(s),event:n}),!0}catch(s){return console.error(`OverType: Action "${e}" error:`,s),this.wrapper.dispatchEvent(new CustomEvent("button-error",{detail:{actionId:e,error:s}})),!1}}getRenderedHTML(e={}){let n=this.getValue(),i=T.parse(n,-1,!1,this.options.codeHighlighter);return e.cleanHTML&&(i=i.replace(/<span class="syntax-marker[^"]*">.*?<\/span>/g,""),i=i.replace(/\sclass="(bullet-list|ordered-list|code-fence|hr-marker|blockquote|url-part)"/g,""),i=i.replace(/\sclass=""/g,"")),i}getPreviewHTML(){return this.preview.innerHTML}getCleanHTML(){return this.getRenderedHTML({cleanHTML:!0})}focus(){this.textarea.focus()}blur(){this.textarea.blur()}isInitialized(){return this.initialized}reinit(e={}){var o;let n=(o=this.options)==null?void 0:o.toolbarButtons;this.options=this._mergeOptions({...this.options,...e});let i=this.toolbar&&this.options.toolbar&&ri(n,this.options.toolbarButtons);this._rebuildActionsMap(),i&&(this._cleanupToolbarListeners(),this.toolbar.destroy(),this.toolbar=null,this._createToolbar()),this.fileUploadInitialized&&this._destroyFileUpload(),this.options.fileUpload&&this._initFileUpload(),this._applyOptions(),this.updatePreview()}showToolbar(){this.toolbar?this.toolbar.show():this._createToolbar()}hideToolbar(){this.toolbar&&this.toolbar.hide()}setTheme(e){if(v._autoInstances.delete(this),this.instanceTheme=e,e==="auto")v._autoInstances.add(this),v._startAutoListener(),this._applyResolvedTheme(Oe("auto"));else{let n=typeof e=="string"?V(e):e,i=typeof n=="string"?n:n.name;if(i&&this.container.setAttribute("data-theme",i),n&&n.colors){let o=Q(n.colors,n.previewColors);this.container.style.cssText+=o}this.updatePreview()}return v._stopAutoListener(),this}_applyResolvedTheme(e){let n=V(e);this.container.setAttribute("data-theme",e),n&&n.colors&&(this.container.style.cssText=Q(n.colors,n.previewColors)),this.updatePreview()}setCodeHighlighter(e){this.options.codeHighlighter=e,this.updatePreview()}_updateStats(){if(!this.statsBar)return;let e=this.textarea.value,n=e.split(`
|
|
970
975
|
`),i=e.length,o=e.split(/\s+/).filter(l=>l.length>0).length,r=this.textarea.selectionStart,a=e.substring(0,r).split(`
|
|
971
976
|
`),c=a.length,p=a[a.length-1].length+1;this.options.statsFormatter?this.statsBar.innerHTML=this.options.statsFormatter({chars:i,words:o,lines:n.length,line:c,column:p}):this.statsBar.innerHTML=`
|
|
972
977
|
<div class="overtype-stat">
|
|
@@ -974,7 +979,7 @@ ${a}`:r;if(p){let k=t.value[t.selectionStart-1];t.selectionStart!==0&&k!=null&&!
|
|
|
974
979
|
<span>${i} chars, ${o} words, ${n.length} lines</span>
|
|
975
980
|
</div>
|
|
976
981
|
<div class="overtype-stat">Line ${c}, Col ${p}</div>
|
|
977
|
-
`}_setupAutoResize(){this.container.classList.add("overtype-auto-resize"),this.previousHeight=null,this._updateAutoHeight(),this.textarea.addEventListener("input",()=>this._updateAutoHeight()),window.addEventListener("resize",()=>this._updateAutoHeight())}_updateAutoHeight(){if(!this.options.autoResize)return;let e=this.textarea,n=this.preview,i=this.wrapper
|
|
982
|
+
`}_setupAutoResize(){this.container.classList.add("overtype-auto-resize"),this.previousHeight=null,this._updateAutoHeight(),this.textarea.addEventListener("input",()=>this._updateAutoHeight()),window.addEventListener("resize",()=>this._updateAutoHeight())}_updateAutoHeight(){if(!this.options.autoResize)return;let e=this.textarea,n=this.preview,i=this.wrapper;if(this.container.dataset.mode==="preview"){i.style.removeProperty("height"),n.style.removeProperty("height"),n.style.removeProperty("overflow-y"),e.style.removeProperty("height"),e.style.removeProperty("overflow-y");return}let r=e.scrollTop;i.style.setProperty("height","auto","important"),e.style.setProperty("height","auto","important");let s=e.scrollHeight;if(this.options.minHeight){let p=parseInt(this.options.minHeight);s=Math.max(s,p)}let a="hidden";if(this.options.maxHeight){let p=parseInt(this.options.maxHeight);s>p&&(s=p,a="auto")}let c=s+"px";e.style.setProperty("height",c,"important"),e.style.setProperty("overflow-y",a,"important"),n.style.setProperty("height",c,"important"),n.style.setProperty("overflow-y",a,"important"),i.style.setProperty("height",c,"important"),e.scrollTop=r,n.scrollTop=r,this.previousHeight!==s&&(this.previousHeight=s)}showStats(e){this.options.showStats=e,e&&!this.statsBar?(this.statsBar=document.createElement("div"),this.statsBar.className="overtype-stats",this.container.appendChild(this.statsBar),this._updateStats()):e&&this.statsBar?this._updateStats():!e&&this.statsBar&&(this.statsBar.remove(),this.statsBar=null)}showNormalEditMode(){return this.container.dataset.mode="normal",this.updatePreview(),this._updateAutoHeight(),requestAnimationFrame(()=>{this.textarea.scrollTop=this.preview.scrollTop,this.textarea.scrollLeft=this.preview.scrollLeft}),this}showPlainTextarea(){if(this.container.dataset.mode="plain",this._updateAutoHeight(),this.toolbar){let e=this.container.querySelector('[data-action="toggle-plain"]');e&&(e.classList.remove("active"),e.title="Show markdown preview")}return this}showPreviewMode(){return this.container.dataset.mode="preview",this.updatePreview(),this._updateAutoHeight(),this}destroy(){if(v._autoInstances.delete(this),v._stopAutoListener(),this.fileUploadInitialized&&this._destroyFileUpload(),this.element.overTypeInstance=null,v.instances.delete(this.element),this.shortcuts&&this.shortcuts.destroy(),this.wrapper){let e=this.getValue();this.wrapper.remove(),this.element.textContent=e}this.initialized=!1}static init(e,n={}){return new v(e,n)}static initFromData(e,n={}){let i=document.querySelectorAll(e);return Array.from(i).map(o=>{let r={...n};for(let s of o.attributes)if(s.name.startsWith("data-ot-")){let c=s.name.slice(8).replace(/-([a-z])/g,(p,l)=>l.toUpperCase());r[c]=v._parseDataValue(s.value)}return new v(o,r)[0]})}static _parseDataValue(e){return e==="true"?!0:e==="false"?!1:e==="null"?null:e!==""&&!isNaN(Number(e))?Number(e):e}static getInstance(e){return e.overTypeInstance||v.instances.get(e)||null}static destroyAll(){document.querySelectorAll("[data-overtype-instance]").forEach(n=>{let i=v.getInstance(n);i&&i.destroy()})}static injectStyles(e=!1){if(v.stylesInjected&&!e)return;let n=document.querySelector("style.overtype-styles");n&&n.remove();let i=v.currentTheme||_,o=Ze({theme:i}),r=document.createElement("style");r.className="overtype-styles",r.textContent=o,document.head.appendChild(r),v.stylesInjected=!0}static setTheme(e,n=null){if(v._globalAutoTheme=!1,v._globalAutoCustomColors=null,e==="auto"){v._globalAutoTheme=!0,v._globalAutoCustomColors=n,v._startAutoListener(),v._applyGlobalTheme(Oe("auto"),n);return}v._stopAutoListener(),v._applyGlobalTheme(e,n)}static _applyGlobalTheme(e,n=null){let i=typeof e=="string"?V(e):e;n&&(i=Ke(i,n)),v.currentTheme=i,v.injectStyles(!0);let o=typeof i=="string"?i:i.name;document.querySelectorAll(".overtype-container").forEach(r=>{o&&r.setAttribute("data-theme",o)}),document.querySelectorAll(".overtype-wrapper").forEach(r=>{r.closest(".overtype-container")||o&&r.setAttribute("data-theme",o);let s=r._instance;s&&s.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(r=>{o&&typeof r.setAttribute=="function"&&r.setAttribute("theme",o),typeof r.refreshTheme=="function"&&r.refreshTheme()})}static _startAutoListener(){v._autoMediaQuery||window.matchMedia&&(v._autoMediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),v._autoMediaListener=e=>{let n=e.matches?"cave":"solar";v._globalAutoTheme&&v._applyGlobalTheme(n,v._globalAutoCustomColors),v._autoInstances.forEach(i=>i._applyResolvedTheme(n))},v._autoMediaQuery.addEventListener("change",v._autoMediaListener))}static _stopAutoListener(){v._autoInstances.size>0||v._globalAutoTheme||v._autoMediaQuery&&(v._autoMediaQuery.removeEventListener("change",v._autoMediaListener),v._autoMediaQuery=null,v._autoMediaListener=null)}static setCodeHighlighter(e){T.setCodeHighlighter(e),document.querySelectorAll(".overtype-wrapper").forEach(n=>{let i=n._instance;i&&i.updatePreview&&i.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(n=>{if(typeof n.getEditor=="function"){let i=n.getEditor();i&&i.updatePreview&&i.updatePreview()}})}static setCustomSyntax(e){T.setCustomSyntax(e),document.querySelectorAll(".overtype-wrapper").forEach(n=>{let i=n._instance;i&&i.updatePreview&&i.updatePreview()}),document.querySelectorAll("overtype-editor").forEach(n=>{if(typeof n.getEditor=="function"){let i=n.getEditor();i&&i.updatePreview&&i.updatePreview()}})}static initGlobalListeners(){v.globalListenersInitialized||(document.addEventListener("input",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let n=e.target.closest(".overtype-wrapper"),i=n==null?void 0:n._instance;i&&i.handleInput(e)}}),document.addEventListener("keydown",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let n=e.target.closest(".overtype-wrapper"),i=n==null?void 0:n._instance;i&&i.handleKeydown(e)}}),document.addEventListener("scroll",e=>{if(e.target&&e.target.classList&&e.target.classList.contains("overtype-input")){let n=e.target.closest(".overtype-wrapper"),i=n==null?void 0:n._instance;i&&i.handleScroll(e)}},!0),document.addEventListener("selectionchange",e=>{let n=document.activeElement;if(n&&n.classList.contains("overtype-input")){let i=n.closest(".overtype-wrapper"),o=i==null?void 0:i._instance;o&&(o.options.showStats&&o.statsBar&&o._updateStats(),clearTimeout(o._selectionTimeout),o._selectionTimeout=setTimeout(()=>{o.updatePreview()},50))}}),v.globalListenersInitialized=!0)}};C(v,"instances",new WeakMap),C(v,"stylesInjected",!1),C(v,"globalListenersInitialized",!1),C(v,"instanceCount",0),C(v,"_autoMediaQuery",null),C(v,"_autoMediaListener",null),C(v,"_autoInstances",new Set),C(v,"_globalAutoTheme",!1),C(v,"_globalAutoCustomColors",null);var z=v;z.MarkdownParser=T;z.ShortcutsManager=re;z.themes={solar:_,cave:V("cave")};z.getTheme=V;z.currentTheme=_;var si=z;return mn(ai);})();
|
|
978
983
|
/**
|
|
979
984
|
* OverType - A lightweight markdown editor library with perfect WYSIWYG alignment
|
|
980
985
|
* @version 1.0.0
|
package/package.json
CHANGED
package/src/overtype.js
CHANGED
|
@@ -1327,24 +1327,33 @@ class OverType {
|
|
|
1327
1327
|
const wrapper = this.wrapper;
|
|
1328
1328
|
const isPreviewMode = this.container.dataset.mode === 'preview';
|
|
1329
1329
|
|
|
1330
|
+
if (isPreviewMode) {
|
|
1331
|
+
// In preview mode, CSS makes the preview position:static so it flows naturally.
|
|
1332
|
+
// Just clear any inline heights left over from edit mode.
|
|
1333
|
+
wrapper.style.removeProperty('height');
|
|
1334
|
+
preview.style.removeProperty('height');
|
|
1335
|
+
preview.style.removeProperty('overflow-y');
|
|
1336
|
+
textarea.style.removeProperty('height');
|
|
1337
|
+
textarea.style.removeProperty('overflow-y');
|
|
1338
|
+
return;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1330
1341
|
// Store scroll positions
|
|
1331
|
-
const scrollTop =
|
|
1342
|
+
const scrollTop = textarea.scrollTop;
|
|
1332
1343
|
|
|
1333
1344
|
// Reset heights to get accurate scrollHeight
|
|
1334
1345
|
// Wrapper must also reset so the absolute-positioned textarea isn't constrained
|
|
1335
1346
|
wrapper.style.setProperty('height', 'auto', 'important');
|
|
1336
|
-
preview.style.setProperty('height', 'auto', 'important');
|
|
1337
1347
|
textarea.style.setProperty('height', 'auto', 'important');
|
|
1338
1348
|
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1349
|
+
let newHeight = textarea.scrollHeight;
|
|
1350
|
+
|
|
1342
1351
|
// Apply min height constraint
|
|
1343
1352
|
if (this.options.minHeight) {
|
|
1344
1353
|
const minHeight = parseInt(this.options.minHeight);
|
|
1345
1354
|
newHeight = Math.max(newHeight, minHeight);
|
|
1346
1355
|
}
|
|
1347
|
-
|
|
1356
|
+
|
|
1348
1357
|
// Apply max height constraint
|
|
1349
1358
|
let overflow = 'hidden';
|
|
1350
1359
|
if (this.options.maxHeight) {
|
|
@@ -1354,25 +1363,24 @@ class OverType {
|
|
|
1354
1363
|
overflow = 'auto';
|
|
1355
1364
|
}
|
|
1356
1365
|
}
|
|
1357
|
-
|
|
1366
|
+
|
|
1358
1367
|
// Apply the new height to all elements with !important to override base styles
|
|
1359
1368
|
const heightPx = newHeight + 'px';
|
|
1360
1369
|
textarea.style.setProperty('height', heightPx, 'important');
|
|
1361
1370
|
textarea.style.setProperty('overflow-y', overflow, 'important');
|
|
1362
|
-
|
|
1371
|
+
|
|
1363
1372
|
preview.style.setProperty('height', heightPx, 'important');
|
|
1364
1373
|
preview.style.setProperty('overflow-y', overflow, 'important');
|
|
1365
|
-
|
|
1374
|
+
|
|
1366
1375
|
wrapper.style.setProperty('height', heightPx, 'important');
|
|
1367
|
-
|
|
1376
|
+
|
|
1368
1377
|
// Restore scroll position
|
|
1369
1378
|
textarea.scrollTop = scrollTop;
|
|
1370
1379
|
preview.scrollTop = scrollTop;
|
|
1371
|
-
|
|
1380
|
+
|
|
1372
1381
|
// Track if height changed
|
|
1373
1382
|
if (this.previousHeight !== newHeight) {
|
|
1374
1383
|
this.previousHeight = newHeight;
|
|
1375
|
-
// Could dispatch a custom event here if needed
|
|
1376
1384
|
}
|
|
1377
1385
|
}
|
|
1378
1386
|
|
package/src/styles.js
CHANGED
|
@@ -693,6 +693,11 @@ export function generateStyles(options = {}) {
|
|
|
693
693
|
cursor: text !important;
|
|
694
694
|
}
|
|
695
695
|
|
|
696
|
+
.overtype-container.overtype-auto-resize[data-mode="preview"] .overtype-preview {
|
|
697
|
+
position: static !important;
|
|
698
|
+
height: auto !important;
|
|
699
|
+
}
|
|
700
|
+
|
|
696
701
|
/* Hide syntax markers in preview mode */
|
|
697
702
|
.overtype-container[data-mode="preview"] .syntax-marker {
|
|
698
703
|
display: none !important;
|