@editora/light-code-editor 1.0.2 → 1.0.3

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/dist/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
- (function(c,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(c=typeof globalThis<"u"?globalThis:c||self,f(c.LightCodeEditor={}))})(this,(function(c){"use strict";class f{constructor(e=""){this._lines=[],this._version=0,this.setText(e)}getLine(e){return this._lines[e]||""}getLines(){return[...this._lines]}getLineCount(){return this._lines.length}getText(){return this._lines.join(`
2
- `)}setText(e){this._lines=e.split(`
3
- `),this._version++}getTextInRange(e){if(e.start.line===e.end.line)return this.getLine(e.start.line).substring(e.start.column,e.end.column);const t=[];t.push(this.getLine(e.start.line).substring(e.start.column));for(let n=e.start.line+1;n<e.end.line;n++)t.push(this.getLine(n));return e.end.line<this.getLineCount()&&t.push(this.getLine(e.end.line).substring(0,e.end.column)),t.join(`
4
- `)}replaceRange(e,t){const n=this.getTextInRange(e);if(e.start.line===e.end.line){const i=this.getLine(e.start.line),s=i.substring(0,e.start.column)+t+i.substring(e.end.column);this._lines[e.start.line]=s}else{const i=this.getLine(e.start.line),s=this.getLine(e.end.line),o=i.substring(0,e.start.column)+t,h=s.substring(e.end.column),r=t.split(`
5
- `);r[0]=o+r[0],r[r.length-1]=r[r.length-1]+h,this._lines.splice(e.start.line,e.end.line-e.start.line+1,...r)}return this._version++,{range:e,text:t,oldText:n}}insertText(e,t){const n={start:e,end:e};return this.replaceRange(n,t)}deleteRange(e){return this.replaceRange(e,"")}positionToOffset(e){let t=0;for(let n=0;n<e.line;n++)t+=this.getLine(n).length+1;return t+=e.column,t}offsetToPosition(e){let t=e;for(let n=0;n<this.getLineCount();n++){const i=this.getLine(n).length;if(t<=i)return{line:n,column:t};t-=i+1}return{line:this.getLineCount()-1,column:this.getLine(this.getLineCount()-1).length}}isValidPosition(e){return!(e.line<0||e.line>=this.getLineCount()||e.column<0||e.column>this.getLine(e.line).length)}isValidRange(e){return this.isValidPosition(e.start)&&this.isValidPosition(e.end)}getVersion(){return this._version}clone(){const e=new f;return e._lines=[...this._lines],e._version=this._version,e}}class y{constructor(e){this.gutterWidth=50,this.lineHeight=21,this.container=e,this.createDOM()}createDOM(){this.container.innerHTML="";const e=document.createElement("div");e.style.cssText=`
1
+ (function(m,b){typeof exports=="object"&&typeof module<"u"?b(exports):typeof define=="function"&&define.amd?define(["exports"],b):(m=typeof globalThis<"u"?globalThis:m||self,b(m.LightCodeEditor={}))})(this,(function(m){"use strict";class b{constructor(t=""){this._lines=[],this._version=0,this.setText(t)}getLine(t){return this._lines[t]||""}getLines(){return[...this._lines]}getLineCount(){return this._lines.length}getText(){return this._lines.join(`
2
+ `)}setText(t){this._lines=t.split(`
3
+ `),this._version++}getTextInRange(t){if(t.start.line===t.end.line)return this.getLine(t.start.line).substring(t.start.column,t.end.column);const e=[];e.push(this.getLine(t.start.line).substring(t.start.column));for(let s=t.start.line+1;s<t.end.line;s++)e.push(this.getLine(s));return t.end.line<this.getLineCount()&&e.push(this.getLine(t.end.line).substring(0,t.end.column)),e.join(`
4
+ `)}replaceRange(t,e){const s=this.getTextInRange(t);if(t.start.line===t.end.line){const i=this.getLine(t.start.line),n=i.substring(0,t.start.column)+e+i.substring(t.end.column);this._lines[t.start.line]=n}else{const i=this.getLine(t.start.line),n=this.getLine(t.end.line),o=i.substring(0,t.start.column)+e,h=n.substring(t.end.column),r=e.split(`
5
+ `);r[0]=o+r[0],r[r.length-1]=r[r.length-1]+h,this._lines.splice(t.start.line,t.end.line-t.start.line+1,...r)}return this._version++,{range:t,text:e,oldText:s}}insertText(t,e){const s={start:t,end:t};return this.replaceRange(s,e)}deleteRange(t){return this.replaceRange(t,"")}positionToOffset(t){let e=0;for(let s=0;s<t.line;s++)e+=this.getLine(s).length+1;return e+=t.column,e}offsetToPosition(t){let e=t;for(let s=0;s<this.getLineCount();s++){const i=this.getLine(s).length;if(e<=i)return{line:s,column:e};e-=i+1}return{line:this.getLineCount()-1,column:this.getLine(this.getLineCount()-1).length}}isValidPosition(t){return!(t.line<0||t.line>=this.getLineCount()||t.column<0||t.column>this.getLine(t.line).length)}isValidRange(t){return this.isValidPosition(t.start)&&this.isValidPosition(t.end)}getVersion(){return this._version}clone(){const t=new b;return t._lines=[...this._lines],t._version=this._version,t}}class O{constructor(t){this.gutterWidth=50,this.lineHeight=21,this.container=t,this.createDOM()}createDOM(){this.container.innerHTML="";const t=document.createElement("div");this.editorContainer=t,t.style.cssText=`
6
6
  position: relative;
7
7
  display: flex;
8
8
  width: 100%;
@@ -12,29 +12,29 @@
12
12
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
13
13
  font-size: 14px;
14
14
  line-height: ${this.lineHeight}px;
15
- overflow: hidden;
16
- `,this.lineNumbersElement=document.createElement("div"),this.lineNumbersElement.style.cssText=`
17
- position: sticky;
18
- left: 0;
19
- top: 0;
15
+ /* make the outer container the single scrollable element so gutter and content scroll together */
16
+ overflow: auto;
17
+ `,this.lineNumbersElement=document.createElement("div"),this.lineNumbersElement.setAttribute("data-editor-gutter","true"),this.lineNumbersElement.style.cssText=`
18
+ display: table-cell;
19
+ vertical-align: top;
20
20
  width: ${this.gutterWidth}px;
21
21
  background: var(--editor-gutter-background, #252526);
22
22
  color: var(--editor-gutter-foreground, #858585);
23
- padding: 0;
23
+ padding: 0 8px 0 0;
24
24
  text-align: right;
25
25
  border-right: 1px solid var(--editor-gutter-border, #3e3e42);
26
26
  user-select: none;
27
- overflow: hidden;
28
27
  z-index: 1;
29
28
  `,this.contentElement=document.createElement("div"),this.contentElement.style.cssText=`
30
- flex: 1;
31
- padding: 0;
29
+ display: table-cell;
30
+ vertical-align: top;
31
+ padding: 0 12px;
32
32
  background: transparent;
33
33
  border: none;
34
34
  outline: none;
35
35
  white-space: pre;
36
36
  overflow-x: auto;
37
- overflow-y: auto;
37
+ overflow-y: visible;
38
38
  min-height: 400px;
39
39
  font-family: inherit;
40
40
  font-size: inherit;
@@ -42,32 +42,17 @@
42
42
  color: inherit;
43
43
  tab-size: 2;
44
44
  -moz-tab-size: 2;
45
- `,this.contentElement.contentEditable="true",this.contentElement.spellcheck=!1,e.appendChild(this.lineNumbersElement),e.appendChild(this.contentElement),this.container.appendChild(e),this.updateLineNumbers(1)}updateLineNumbers(e){const t=Math.max(e,20),n=Array.from({length:t},(i,s)=>s+1);this.lineNumbersElement.innerHTML=n.map(i=>`<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px; padding-right: 12px;">${i}</div>`).join("")}getContentElement(){return this.contentElement}getLineNumbersElement(){return this.lineNumbersElement}getText(){return this.contentElement.textContent||""}setText(e){this.contentElement.textContent=e;const t=e.split(`
46
- `).length;this.updateLineNumbers(t)}getCursorPosition(){const e=window.getSelection();if(!e||e.rangeCount===0)return{line:0,column:0};const t=e.getRangeAt(0),n=t.cloneRange();n.selectNodeContents(this.contentElement),n.setEnd(t.endContainer,t.endOffset);const s=n.toString().split(`
47
- `);return{line:s.length-1,column:s[s.length-1].length}}setCursorPosition(e){const n=this.getText().split(`
48
- `),i=Math.min(e.line,n.length-1),s=Math.min(e.column,n[i]?.length||0);let o=0;for(let m=0;m<i;m++)o+=n[m].length+1;o+=s;const h=document.createRange(),r=window.getSelection();let l=0,d=null,a=0;const g=document.createTreeWalker(this.contentElement,NodeFilter.SHOW_TEXT,null);let x;for(;x=g.nextNode();){const m=x.textContent?.length||0;if(l+m>=o){d=x,a=o-l;break}l+=m}if(d)try{h.setStart(d,a),h.setEnd(d,a),r?.removeAllRanges(),r?.addRange(h)}catch(m){console.warn("Could not set cursor position:",m)}}getSelectionRange(){const e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return;const t=e.getRangeAt(0),n=t.cloneRange();n.selectNodeContents(this.contentElement),n.setEnd(t.startContainer,t.startOffset);const s=n.toString().split(`
49
- `),o=t.cloneRange();o.selectNodeContents(this.contentElement),o.setEnd(t.endContainer,t.endOffset);const r=o.toString().split(`
50
- `);return{start:{line:s.length-1,column:s[s.length-1].length},end:{line:r.length-1,column:r[r.length-1].length}}}setSelectionRange(e){this.setCursorPosition(e.start)}focus(){this.contentElement.focus()}blur(){this.contentElement.blur()}setReadOnly(e){this.contentElement.contentEditable=e?"false":"true"}applyTheme(e){Object.entries(e).forEach(([t,n])=>{this.container.style.setProperty(`--${t}`,n)})}scrollToPosition(e){const t=this.lineNumbersElement.children[e.line];t&&t.scrollIntoView({block:"center",behavior:"smooth"})}getScrollTop(){return this.contentElement.scrollTop}setScrollTop(e){this.contentElement.scrollTop=e,this.lineNumbersElement.scrollTop=e}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container)}}class p{constructor(e,t={}){this.extensions=new Map,this.commands=new Map,this.eventListeners=new Map,this.folds=[],this.currentTheme="default",this.isDestroyed=!1,this.config={value:"",theme:"default",readOnly:!1,tabSize:2,lineWrapping:!1,lineNumbers:!0,...t},this.textModel=new f(this.config.value),this.view=new y(e),this.view.setText(this.textModel.getText()),this.view.setReadOnly(this.config.readOnly||!1),this.setupEventHandlers(),this.config.extensions&&this.config.extensions.forEach(n=>this.addExtension(n)),this.setTheme(this.config.theme)}getTextModel(){return this.textModel}getView(){return this.view}getConfig(){return{...this.config}}getKeymapExtension(){return this.extensions.get("keymap")}setupEventHandlers(){const e=this.view.getContentElement();e.addEventListener("input",()=>{const t=this.view.getText(),n=this.textModel.getText();t!==n&&(this.textModel.setText(t),this.emit("change",[{range:this.getFullRange(),text:t,oldText:n}]),this.updateLineNumbers())}),e.addEventListener("selectionchange",()=>{const t=this.getCursor(),n=this.getSelection();this.emit("cursor",t),n&&this.emit("selection",n)}),e.addEventListener("keydown",t=>{this.emit("keydown",t);for(const n of this.extensions.values())if(n.onKeyDown&&n.onKeyDown(t)===!1){t.preventDefault(),t.stopPropagation();return}}),e.addEventListener("mousedown",t=>{this.emit("mousedown",t);for(const n of this.extensions.values())if(n.onMouseDown&&n.onMouseDown(t)===!1){t.preventDefault(),t.stopPropagation();return}}),e.addEventListener("focus",()=>{this.emit("focus")}),e.addEventListener("blur",()=>{this.emit("blur")})}updateLineNumbers(){const e=this.textModel.getLineCount();this.view.updateLineNumbers(e)}getFullRange(){return{start:{line:0,column:0},end:{line:this.textModel.getLineCount()-1,column:this.textModel.getLine(this.textModel.getLineCount()-1).length}}}emit(e,...t){const n=this.eventListeners.get(e);n&&n.forEach(i=>i(...t))}getValue(){return this.textModel.getText()}setValue(e){this.textModel.setText(e),this.view.setText(e),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:e,oldText:this.getValue()}])}getState(){return{text:this.getValue(),cursor:this.getCursor(),selection:this.getSelection(),readOnly:this.config.readOnly||!1,theme:this.currentTheme}}getCursor(){const e=this.view.getCursorPosition();return{position:e,anchor:e}}setCursor(e){this.view.setCursorPosition(e),this.emit("cursor",this.getCursor())}getSelection(){return this.view.getSelectionRange()}setSelection(e){this.view.setSelectionRange(e),this.emit("selection",e)}setTheme(e){this.currentTheme=e;const t={"editor-background":e==="dark"?"#1e1e1e":"#ffffff","editor-foreground":e==="dark"?"#f8f9fa":"#1a1a1a","editor-gutter-background":e==="dark"?"#252526":"#f8f9fa","editor-gutter-foreground":e==="dark"?"#858585":"#666666","editor-gutter-border":e==="dark"?"#3e3e42":"#e1e5e9"};this.view.applyTheme(t)}setReadOnly(e){this.config.readOnly=e,this.view.setReadOnly(e)}addExtension(e){if(this.extensions.has(e.name))throw new Error(`Extension '${e.name}' already exists`);this.extensions.set(e.name,e),e.setup(this)}removeExtension(e){const t=this.extensions.get(e);t&&t.destroy&&t.destroy(),this.extensions.delete(e)}executeCommand(e,...t){const n=this.commands.get(e);n?n(this,...t):console.warn(`Command '${e}' not found`)}registerCommand(e,t){this.commands.set(e,t)}search(e,t={}){const n={caseSensitive:!1,regex:!1,...t},i=[],s=this.getValue();s.split(`
51
- `);let o=n.caseSensitive?s:s.toLowerCase(),h=n.caseSensitive?e:e.toLowerCase();if(n.regex){const r=new RegExp(h,n.caseSensitive?"g":"gi");let l;for(;(l=r.exec(o))!==null;){const d=this.textModel.offsetToPosition(l.index),a=this.textModel.offsetToPosition(l.index+l[0].length);i.push({range:{start:d,end:a},match:l[0]})}}else{let r=0,l=o.indexOf(h,r);for(;l!==-1;){const d=l+e.length,a=this.textModel.offsetToPosition(l),g=this.textModel.offsetToPosition(d);i.push({range:{start:a,end:g},match:s.substring(l,d)}),r=d,l=o.indexOf(h,r)}}return i}replace(e,t){const n=this.textModel.replaceRange(e,t);this.view.setText(this.getValue()),this.emit("change",[n])}replaceAll(e,t,n={}){const i=this.search(e,n);let s=0;for(let o=i.length-1;o>=0;o--)this.replace(i[o].range,t),s++;return s}fold(e){const t={start:e.start,end:e.end,collapsed:!0,level:0};this.folds.push(t)}unfold(e){this.folds=this.folds.filter(t=>!(t.start.line===e.start.line&&t.end.line===e.end.line))}getFolds(){return[...this.folds]}focus(){this.view.focus()}blur(){this.view.blur()}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;for(const e of this.extensions.values())e.destroy&&e.destroy();this.extensions.clear(),this.view.destroy(),this.commands.clear(),this.eventListeners.clear()}}on(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,[]),this.eventListeners.get(e).push(t)}off(e,t){if(!this.eventListeners.has(e))return;const n=this.eventListeners.get(e);if(t){const i=n.indexOf(t);i!==-1&&n.splice(i,1)}else n.length=0}}class b{constructor(e){this.name="keymap",this.editor=null,this.keymap={},this.isMac=navigator.platform.toUpperCase().indexOf("MAC")>=0,this.keymap=e||this.getDefaultKeymap()}setup(e){this.editor=e,e.on("keydown",t=>this.handleKeyDown(t))}handleKeyDown(e){if(!this.editor)return;const t=this.findMatchingBinding(e);if(t)return this.editor.executeCommand(t.command),e.preventDefault(),e.stopPropagation(),!1}findMatchingBinding(e){const{key:t,ctrlKey:n,altKey:i,shiftKey:s,metaKey:o}=e,h=t.toLowerCase(),r=this.keymap[h];if(!r)return null;for(const l of r)if((l.ctrlKey===n||!l.ctrlKey&&!n)&&(l.altKey===i||!l.altKey&&!i)&&(l.shiftKey===s||!l.shiftKey&&!s)&&(l.metaKey===o||!l.metaKey&&!o))return l;return null}getDefaultKeymap(){const e={};return this.addBinding(e,"f",{ctrlKey:!this.isMac,metaKey:this.isMac},"find"),this.addBinding(e,"h",{ctrlKey:!this.isMac,metaKey:this.isMac},"replace"),this.addBinding(e,"f3",{},"findNext"),this.addBinding(e,"f3",{shiftKey:!0},"findPrev"),this.addBinding(e,"g",{ctrlKey:!this.isMac,metaKey:this.isMac},"findNext"),this.addBinding(e,"[",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"fold"),this.addBinding(e,"]",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"unfold"),this.addBinding(e,"s",{ctrlKey:!this.isMac,metaKey:this.isMac},"save"),this.addBinding(e,"z",{ctrlKey:!this.isMac,metaKey:this.isMac},"undo"),this.addBinding(e,"y",{ctrlKey:!this.isMac,metaKey:this.isMac},"redo"),this.addBinding(e,"z",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"redo"),this.addBinding(e,"t",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"toggleTheme"),e}addBinding(e,t,n,i){const s=t.toLowerCase();e[s]||(e[s]=[]),e[s].push({key:s,command:i,...n})}setKeymap(e){this.keymap={...e}}addKeyBinding(e){const t=e.key.toLowerCase();this.keymap[t]||(this.keymap[t]=[]),this.keymap[t]=this.keymap[t].filter(n=>n.command!==e.command),this.keymap[t].push({...e,key:t})}removeKeyBinding(e,t){const n=e.toLowerCase();t?this.keymap[n]&&(this.keymap[n]=this.keymap[n].filter(i=>i.command!==t),this.keymap[n].length===0&&delete this.keymap[n]):delete this.keymap[n]}getKeymap(){return{...this.keymap}}getBindingsForCommand(e){const t=[];for(const n in this.keymap)for(const i of this.keymap[n])i.command===e&&t.push({...i});return t}getPlatformInfo(){return{isMac:this.isMac,platform:navigator.platform}}destroy(){this.keymap={},this.editor=null}}class v{constructor(){this.name="line-numbers",this.editor=null,this.lineNumbersElement=null,this.isEnabled=!0}setup(e){this.editor=e,this.createLineNumbers(),e.registerCommand("toggleLineNumbers",()=>{this.toggle()}),e.on("change",()=>{this.updateLineNumbers()}),this.updateLineNumbers()}createLineNumbers(){if(!this.editor)return;const e=this.editor.getView();if(!e.container)return;this.lineNumbersElement=document.createElement("div"),this.lineNumbersElement.style.cssText=`
52
- position: absolute;
53
- left: 0;
54
- top: 0;
55
- bottom: 0;
56
- width: 50px;
57
- background: var(--editor-gutter-background, #252526);
58
- color: var(--editor-gutter-foreground, #858585);
59
- font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
60
- font-size: 14px;
61
- line-height: 21px;
62
- padding: 0;
63
- text-align: right;
64
- border-right: 1px solid var(--editor-gutter-border, #3e3e42);
65
- user-select: none;
66
- overflow: hidden;
67
- z-index: 1;
68
- pointer-events: none;
69
- `;const n=e.getContentElement();n&&n.parentNode&&(n.parentNode.insertBefore(this.lineNumbersElement,n),n.style.marginLeft="60px")}updateLineNumbers(){if(!this.lineNumbersElement||!this.editor||!this.isEnabled)return;const e=this.editor.getValue().split(`
70
- `).length,t=Array.from({length:Math.max(e,20)},(n,i)=>i+1);this.lineNumbersElement.innerHTML=t.map(n=>`<div style="height: 21px; line-height: 21px; padding-right: 12px;">${n}</div>`).join("")}toggle(){this.isEnabled=!this.isEnabled,this.lineNumbersElement&&(this.lineNumbersElement.style.display=this.isEnabled?"block":"none");const e=this.editor.getView().getContentElement();e&&(e.style.marginLeft=this.isEnabled?"60px":"0"),this.updateLineNumbers()}destroy(){this.lineNumbersElement&&this.lineNumbersElement.parentNode&&this.lineNumbersElement.parentNode.removeChild(this.lineNumbersElement),this.lineNumbersElement=null,this.editor=null}}class E{constructor(){this.name="theme",this.editor=null,this.currentTheme="dark"}setup(e){this.editor=e,e.registerCommand("setTheme",t=>{this.setTheme(t)}),e.registerCommand("toggleTheme",()=>{this.toggleTheme()}),this.setTheme(this.currentTheme)}setTheme(e){this.editor&&(this.currentTheme=e,this.editor.setTheme(e))}toggleTheme(){const e=this.currentTheme==="dark"?"light":"dark";this.setTheme(e)}getCurrentTheme(){return this.currentTheme}destroy(){this.editor=null}}class w{constructor(){this.name="read-only",this.editor=null,this.isReadOnly=!1}setup(e){this.editor=e,e.registerCommand("setReadOnly",t=>{this.setReadOnly(t)}),e.registerCommand("toggleReadOnly",()=>{this.toggleReadOnly()}),e.on("keydown",t=>{if(t.ctrlKey&&t.key==="r")return t.preventDefault(),this.toggleReadOnly(),!1})}setReadOnly(e){this.editor&&(this.isReadOnly=e,this.editor.setReadOnly(e))}toggleReadOnly(){this.setReadOnly(!this.isReadOnly)}isCurrentlyReadOnly(){return this.isReadOnly}destroy(){this.editor=null}}class k{constructor(){this.name="search",this.editor=null,this.searchUI=null,this.isVisible=!1,this.currentResults=[],this.currentIndex=-1}setup(e){this.editor=e,e.registerCommand("find",()=>{this.showSearch()}),e.registerCommand("findNext",()=>{this.findNext()}),e.registerCommand("findPrev",()=>{this.findPrev()}),e.registerCommand("replace",()=>{this.showReplace()}),e.registerCommand("replaceAll",(t,n)=>{this.replaceAll(t,n)})}showSearch(){if(this.editor&&(this.searchUI||this.createSearchUI(),this.isVisible=!0,this.searchUI)){this.searchUI.style.display="block";const e=this.searchUI.querySelector("input");e&&(e.focus(),e.select())}}showReplace(){this.showSearch();const e=this.searchUI?.querySelector(".search-replace-input");e&&(e.style.display="block",e.focus());const t=this.searchUI?.querySelector(".search-status");t&&(t.textContent="Replace mode - Enter to replace, Shift+Enter to replace all")}hideSearch(){this.isVisible=!1,this.searchUI&&(this.searchUI.style.display="none"),this.clearHighlights()}createSearchUI(){if(!this.editor)return;const e=document.querySelector(".rte-source-editor-modal");if(!e)return;this.searchUI=document.createElement("div"),this.searchUI.style.cssText=`
45
+ `,this.contentElement.contentEditable="true",this.contentElement.spellcheck=!1;const e=document.createElement("div");e.setAttribute("data-editora-editor","true"),e.style.cssText="display: table; table-layout: fixed; width: 100%; height: 100%;",e.appendChild(this.lineNumbersElement),e.appendChild(this.contentElement),t.appendChild(e),this.container.appendChild(t),this.updateLineNumbers(1)}updateLineNumbers(t){const e=Math.max(t,20),s=Array.from({length:e},(i,n)=>n+1);this.lineNumbersElement.innerHTML=s.map(i=>`<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px; padding-right: 12px;">${i}</div>`).join("")}getContentElement(){return this.contentElement}getLineNumbersElement(){return this.lineNumbersElement}getText(){return this.contentElement.textContent||""}setText(t){this.contentElement.textContent=t;const e=t.split(`
46
+ `).length;this.updateLineNumbers(e)}setHTML(t){const e=/&lt;|&gt;/.test(t),s=/<span\b/i.test(t),i=/<[^>]+>/.test(t);e&&s?this.contentElement.innerHTML=t:i&&!e?this.contentElement.textContent=t:this.contentElement.innerHTML=t;const o=(this.contentElement.textContent||"").split(`
47
+ `).length;this.updateLineNumbers(o)}getCursorPosition(){const t=window.getSelection();if(!t||t.rangeCount===0)return{line:0,column:0};const e=t.getRangeAt(0),s=e.cloneRange();s.selectNodeContents(this.contentElement),s.setEnd(e.endContainer,e.endOffset);const n=s.toString().split(`
48
+ `);return{line:n.length-1,column:n[n.length-1].length}}setCursorPosition(t){const s=this.getText().split(`
49
+ `),i=Math.min(t.line,s.length-1),n=Math.min(t.column,s[i]?.length||0);let o=0;for(let a=0;a<i;a++)o+=s[a].length+1;o+=n;const h=document.createRange(),r=window.getSelection();let l=0,c=null,d=0;const f=document.createTreeWalker(this.contentElement,NodeFilter.SHOW_TEXT,null);let g;for(;g=f.nextNode();){const a=g.textContent?.length||0;if(l+a>=o){c=g,d=o-l;break}l+=a}if(c)try{h.setStart(c,d),h.setEnd(c,d),r?.removeAllRanges(),r?.addRange(h)}catch(a){console.warn("Could not set cursor position:",a)}}getSelectionRange(){const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return;const e=t.getRangeAt(0),s=e.cloneRange();s.selectNodeContents(this.contentElement),s.setEnd(e.startContainer,e.startOffset);const n=s.toString().split(`
50
+ `),o=e.cloneRange();o.selectNodeContents(this.contentElement),o.setEnd(e.endContainer,e.endOffset);const r=o.toString().split(`
51
+ `);return{start:{line:n.length-1,column:n[n.length-1].length},end:{line:r.length-1,column:r[r.length-1].length}}}setSelectionRange(t){this.setCursorPosition(t.start)}focus(){this.contentElement.focus()}blur(){this.contentElement.blur()}setReadOnly(t){this.contentElement.contentEditable=t?"false":"true"}applyTheme(t){Object.entries(t).forEach(([e,s])=>{this.container.style.setProperty(`--${e}`,s)})}scrollToPosition(t){const e=this.lineNumbersElement.children[t.line];e&&e.scrollIntoView({block:"center",behavior:"smooth"})}getScrollTop(){return this.editorContainer.scrollTop}setScrollTop(t){this.editorContainer.scrollTop=t}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=void 0)}}class k{constructor(t,e={}){this.extensions=new Map,this.commands=new Map,this.eventListeners=new Map,this.folds=[],this.currentTheme="default",this.isDestroyed=!1,this.undoStack=[],this.redoStack=[],this.suppressHistory=!1,this.expectingProgrammaticCursor=!1,this.config={value:"",theme:"default",readOnly:!1,tabSize:2,lineWrapping:!1,lineNumbers:!0,...e},this.textModel=new b(this.config.value),this.view=new O(t),this.setupEventHandlers(),this.config.extensions&&this.config.extensions.forEach(s=>this.addExtension(s)),this.setTheme(this.config.theme),this.view.setReadOnly(this.config.readOnly||!1),this.renderTextWithHighlight(this.textModel.getText()),this.registerBuiltInCommands()}getTextModel(){return this.textModel}getView(){return this.view}getConfig(){return{...this.config}}registerBuiltInCommands(){this.registerCommand("undo",()=>this.undo()),this.registerCommand("redo",()=>this.redo()),this.registerCommand("insertTab",()=>this.insertTab()),this.registerCommand("save",()=>{this.emit("save")})}getKeymapExtension(){return this.extensions.get("keymap")}setupEventHandlers(){const t=this.view.getContentElement();t.addEventListener("input",()=>{const e=this.view.getText(),s=this.textModel.getText();if(e!==s){if(!this.suppressHistory){const i=this.getCursor().position,n=this.textModel.positionToOffset(i),o=this.getSelection();let h,r;o&&(h=this.textModel.positionToOffset(o.start),r=this.textModel.positionToOffset(o.end)),this.undoStack.push({text:s,cursorOffset:n,anchorOffset:h,focusOffset:r}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack.length=0}this.textModel.setText(e),this.highlightTimeout&&clearTimeout(this.highlightTimeout),this.highlightTimeout=setTimeout(()=>{this.renderTextWithHighlight(this.textModel.getText(),!1),this.highlightTimeout=null},300),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:e,oldText:s}])}}),t.addEventListener("selectionchange",()=>{const e=this.getCursor(),s=this.getSelection();this.emit("cursor",e),s&&this.emit("selection",s)}),t.addEventListener("keydown",e=>{if(this.emit("keydown",e),e.key==="Tab"){this.config.readOnly||this.insertTab(),e.preventDefault(),e.stopPropagation();return}if(e.key==="Enter"){if(!this.config.readOnly){const s=window.getSelection();if(s&&s.rangeCount>0){const i=this.getCursor().position,n=this.textModel.positionToOffset(i),o=this.getSelection();let h,r;o&&(h=this.textModel.positionToOffset(o.start),r=this.textModel.positionToOffset(o.end)),this.suppressHistory||(this.undoStack.push({text:this.textModel.getText(),cursorOffset:n,anchorOffset:h,focusOffset:r}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack.length=0);const l=s.getRangeAt(0);l.deleteContents();const c=document.createTextNode(`
52
+ `);l.insertNode(c),l.setStartAfter(c),l.collapse(!0),s.removeAllRanges(),s.addRange(l);const d=this.getCursor().position,f=this.textModel.positionToOffset(d),g=this.getSelection();let a,u;g&&(a=this.textModel.positionToOffset(g.start),u=this.textModel.positionToOffset(g.end));const p=this.view.getText();this.textModel.setText(p),this.highlightTimeout&&clearTimeout(this.highlightTimeout),this.highlightTimeout=setTimeout(()=>{this.renderTextWithHighlight(this.textModel.getText(),!1),requestAnimationFrame(()=>{try{if(g&&(a!==void 0||u!==void 0)){const x=a!==void 0?a:f,w=u!==void 0?u:f,T=Math.min(x,w),L=Math.max(x,w),S=this.textModel.offsetToPosition(T),C=this.textModel.offsetToPosition(L);this.setSelection({start:S,end:C})}else{const x=this.textModel.offsetToPosition(f);this.setCursor(x)}}catch{}}),this.highlightTimeout=null},300),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:this.getValue(),oldText:""}])}}e.preventDefault(),e.stopPropagation();return}for(const s of this.extensions.values())if(s.onKeyDown&&s.onKeyDown(e)===!1){e.preventDefault(),e.stopPropagation();return}}),t.addEventListener("mousedown",e=>{this.emit("mousedown",e);for(const s of this.extensions.values())if(s.onMouseDown&&s.onMouseDown(e)===!1){e.preventDefault(),e.stopPropagation();return}}),t.addEventListener("focus",()=>{this.emit("focus")}),t.addEventListener("blur",()=>{this.emit("blur")})}updateLineNumbers(){const t=this.textModel.getLineCount();this.view.updateLineNumbers(t)}getFullRange(){return{start:{line:0,column:0},end:{line:this.textModel.getLineCount()-1,column:this.textModel.getLine(this.textModel.getLineCount()-1).length}}}emit(t,...e){const s=this.eventListeners.get(t);s&&s.forEach(i=>i(...e))}getValue(){return this.textModel.getText()}setValue(t){const e=this.textModel.getText();this.textModel.setText(t),this.renderTextWithHighlight(t,!1),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:t,oldText:e}])}getState(){return{text:this.getValue(),cursor:this.getCursor(),selection:this.getSelection(),readOnly:this.config.readOnly||!1,theme:this.currentTheme}}getCursor(){const t=this.view.getCursorPosition();return{position:t,anchor:t}}setCursor(t){this.view.setCursorPosition(t),this.emit("cursor",this.getCursor())}getSelection(){return this.view.getSelectionRange()}setSelection(t){this.view.setSelectionRange(t),this.emit("selection",t)}setTheme(t){this.currentTheme=t;const e={"editor-background":t==="dark"?"#1e1e1e":"#ffffff","editor-foreground":t==="dark"?"#f8f9fa":"#1a1a1a","editor-gutter-background":t==="dark"?"#252526":"#f8f9fa","editor-gutter-foreground":t==="dark"?"#858585":"#666666","editor-gutter-border":t==="dark"?"#3e3e42":"#e1e5e9"};this.view.applyTheme(e);const s=this.extensions.get("syntax-highlighting");if(s&&typeof s.setTheme=="function")try{s.setTheme(t==="dark"?"dark":"light"),this.renderTextWithHighlight(this.textModel.getText())}catch(i){console.warn("Error applying theme to syntax-highlighting extension",i)}}setReadOnly(t){this.config.readOnly=t,this.view.setReadOnly(t)}addExtension(t){if(this.extensions.has(t.name))throw new Error(`Extension '${t.name}' already exists`);this.extensions.set(t.name,t),t.setup(this),t.name==="syntax-highlighting"&&typeof t.highlightHTML=="function"&&this.renderTextWithHighlight(this.textModel.getText())}removeExtension(t){const e=this.extensions.get(t);e&&e.destroy&&e.destroy(),this.extensions.delete(t)}executeCommand(t,...e){const s=this.commands.get(t);s?s(this,...e):console.warn(`Command '${t}' not found`)}registerCommand(t,e){this.commands.set(t,e)}search(t,e={}){const s={caseSensitive:!1,regex:!1,...e},i=[],n=this.getValue();n.split(`
53
+ `);let o=s.caseSensitive?n:n.toLowerCase(),h=s.caseSensitive?t:t.toLowerCase();if(s.regex){const r=new RegExp(h,s.caseSensitive?"g":"gi");let l;for(;(l=r.exec(o))!==null;){const c=this.textModel.offsetToPosition(l.index),d=this.textModel.offsetToPosition(l.index+l[0].length);i.push({range:{start:c,end:d},match:l[0]})}}else{let r=0,l=o.indexOf(h,r);for(;l!==-1;){const c=l+t.length,d=this.textModel.offsetToPosition(l),f=this.textModel.offsetToPosition(c);i.push({range:{start:d,end:f},match:n.substring(l,c)}),r=c,l=o.indexOf(h,r)}}return i}replace(t,e){const s=this.getValue();if(!this.suppressHistory){const n=this.getCursor().position,o=this.textModel.positionToOffset(n),h=this.getSelection();let r,l;h&&(r=this.textModel.positionToOffset(h.start),l=this.textModel.positionToOffset(h.end)),this.undoStack.push({text:s,cursorOffset:o,anchorOffset:r,focusOffset:l}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack.length=0}const i=this.textModel.replaceRange(t,e);this.renderTextWithHighlight(this.getValue(),!1),this.emit("change",[i])}replaceAll(t,e,s={}){const i=this.search(t,s);let n=0;for(let o=i.length-1;o>=0;o--)this.replace(i[o].range,e),n++;return n}fold(t){const e={start:t.start,end:t.end,collapsed:!0,level:0};this.folds.push(e)}unfold(t){this.folds=this.folds.filter(e=>!(e.start.line===t.start.line&&e.end.line===t.end.line))}getFolds(){return[...this.folds]}focus(){this.view.focus()}blur(){this.view.blur()}renderTextWithHighlight(t,e=!0){const s=this.extensions.get("syntax-highlighting");if(s&&typeof s.highlightHTML=="function")try{const i=!e&&!this.expectingProgrammaticCursor;let n,o,h,r;if(e||i){n=this.getSelection();const c=this.getCursor().position;o=this.textModel.positionToOffset(c),n&&(h=this.textModel.positionToOffset(n.start),r=this.textModel.positionToOffset(n.end))}const l=s.highlightHTML(t);typeof this.view.setHighlightHTML=="function"?this.view.setHighlightHTML(l):this.view.setHTML(l),(e||i)&&requestAnimationFrame(()=>{try{if(n&&(h!==void 0||r!==void 0)){const c=h!==void 0?h:o,d=r!==void 0?r:o,f=Math.min(c,d),g=Math.max(c,d),a=this.textModel.offsetToPosition(f),u=this.textModel.offsetToPosition(g);this.view.setSelectionRange({start:a,end:u})}else if(o!==void 0){const c=this.textModel.offsetToPosition(o);this.view.setCursorPosition(c)}}catch{}});return}catch(i){console.warn("Syntax highlighting failed, falling back to plain text",i)}this.view.setText(t)}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;for(const t of this.extensions.values())t.destroy&&t.destroy();this.extensions.clear(),this.view.destroy(),this.commands.clear(),this.eventListeners.clear()}}undo(){if(this.undoStack.length===0)return;const t=this.undoStack.pop(),e={text:this.getValue(),cursorOffset:this.textModel.positionToOffset(this.getCursor().position)};this.redoStack.push(e);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0;let s,i;typeof t=="string"?s=t:(s=t.text,i=t.cursorOffset),this.setValue(s),requestAnimationFrame(()=>{try{if(i!=null)if(typeof t!="string"&&(t.anchorOffset!==void 0||t.focusOffset!==void 0)){const n=t.anchorOffset!==void 0?t.anchorOffset:i,o=t.focusOffset!==void 0?t.focusOffset:i,h=Math.min(n,o),r=Math.max(n,o),l=this.textModel.offsetToPosition(h),c=this.textModel.offsetToPosition(r);this.setSelection({start:l,end:c})}else{const n=this.textModel.offsetToPosition(i);this.setCursor(n)}}catch{}}),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}redo(){if(this.redoStack.length===0)return;const t=this.redoStack.pop(),e={text:this.getValue(),cursorOffset:this.textModel.positionToOffset(this.getCursor().position)};this.undoStack.push(e);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0;let s,i;typeof t=="string"?s=t:(s=t.text,i=t.cursorOffset),this.setValue(s),requestAnimationFrame(()=>{try{if(i!=null)if(typeof t!="string"&&(t.anchorOffset!==void 0||t.focusOffset!==void 0)){const n=t.anchorOffset!==void 0?t.anchorOffset:i,o=t.focusOffset!==void 0?t.focusOffset:i,h=Math.min(n,o),r=Math.max(n,o),l=this.textModel.offsetToPosition(h),c=this.textModel.offsetToPosition(r);this.setSelection({start:l,end:c})}else{const n=this.textModel.offsetToPosition(i);this.setCursor(n)}}catch{}}),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}insertTab(){if(this.config.readOnly)return;const t=this.getCursor().position,e=this.textModel.positionToOffset(t),s=" ".repeat(this.config.tabSize||2),i=this.textModel.insertText(t,s),n=this.textModel.offsetToPosition(this.textModel.positionToOffset(t)+s.length);if(!this.suppressHistory){const o=this.getSelection();let h,r;o&&(h=this.textModel.positionToOffset(o.start),r=this.textModel.positionToOffset(o.end)),this.undoStack.push({text:this.getValue(),cursorOffset:e,anchorOffset:h,focusOffset:r}),this.redoStack.length=0}this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.setCursor(n),setTimeout(()=>{this.expectingProgrammaticCursor=!1},20),this.emit("change",[i])}insertNewLine(){if(this.config.readOnly)return;const t=this.getCursor().position,e=this.textModel.positionToOffset(t),s=this.textModel.insertText(t,`
54
+ `),i=this.textModel.offsetToPosition(this.textModel.positionToOffset(t)+1);if(!this.suppressHistory){const n=this.getSelection();let o,h;n&&(o=this.textModel.positionToOffset(n.start),h=this.textModel.positionToOffset(n.end)),this.undoStack.push({text:this.getValue(),cursorOffset:e,anchorOffset:o,focusOffset:h}),this.redoStack.length=0}this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.setCursor(i),setTimeout(()=>{this.expectingProgrammaticCursor=!1},20),this.emit("change",[s])}on(t,e){this.eventListeners.has(t)||this.eventListeners.set(t,[]),this.eventListeners.get(t).push(e)}off(t,e){if(!this.eventListeners.has(t))return;const s=this.eventListeners.get(t);if(e){const i=s.indexOf(e);i!==-1&&s.splice(i,1)}else s.length=0}}class E{constructor(t){this.name="keymap",this.editor=null,this.keymap={},this.isMac=navigator.platform.toUpperCase().indexOf("MAC")>=0,this.keymap=t||this.getDefaultKeymap()}setup(t){this.editor=t}handleKeyDown(t){if(!this.editor)return;const e=this.findMatchingBinding(t);if(e)return this.editor.executeCommand(e.command),t.preventDefault(),t.stopPropagation(),!1}findMatchingBinding(t){const{key:e,ctrlKey:s,altKey:i,shiftKey:n,metaKey:o}=t,h=String(e).toLowerCase(),r=this.keymap[h];if(!r)return null;for(const l of r){const c=l.ctrlKey===void 0||l.ctrlKey===s,d=l.altKey===void 0||l.altKey===i,f=l.shiftKey===void 0||l.shiftKey===n,g=l.metaKey===void 0||l.metaKey===o;if(c&&d&&f&&g)return l}return null}onKeyDown(t){return this.handleKeyDown(t)}getDefaultKeymap(){const t={};return this.addBinding(t,"f",{ctrlKey:!this.isMac,metaKey:this.isMac},"find"),this.addBinding(t,"h",{ctrlKey:!this.isMac,metaKey:this.isMac},"replace"),this.addBinding(t,"f3",{},"findNext"),this.addBinding(t,"f3",{shiftKey:!0},"findPrev"),this.addBinding(t,"g",{ctrlKey:!this.isMac,metaKey:this.isMac},"findNext"),this.addBinding(t,"[",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"fold"),this.addBinding(t,"]",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"unfold"),this.addBinding(t,"s",{ctrlKey:!0},"save"),this.addBinding(t,"s",{metaKey:!0},"save"),this.addBinding(t,"z",{ctrlKey:!0},"undo"),this.addBinding(t,"z",{metaKey:!0},"undo"),this.addBinding(t,"y",{ctrlKey:!0},"redo"),this.addBinding(t,"y",{metaKey:!0},"redo"),this.addBinding(t,"z",{ctrlKey:!0,shiftKey:!0},"redo"),this.addBinding(t,"z",{metaKey:!0,shiftKey:!0},"redo"),this.addBinding(t,"tab",{},"insertTab"),this.addBinding(t,"t",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"toggleTheme"),t}addBinding(t,e,s,i){const n=e.toLowerCase();t[n]||(t[n]=[]),t[n].push({key:n,command:i,...s})}setKeymap(t){this.keymap={...t}}addKeyBinding(t){const e=t.key.toLowerCase();this.keymap[e]||(this.keymap[e]=[]),this.keymap[e]=this.keymap[e].filter(s=>s.command!==t.command),this.keymap[e].push({...t,key:e})}removeKeyBinding(t,e){const s=t.toLowerCase();e?this.keymap[s]&&(this.keymap[s]=this.keymap[s].filter(i=>i.command!==e),this.keymap[s].length===0&&delete this.keymap[s]):delete this.keymap[s]}getKeymap(){return{...this.keymap}}getBindingsForCommand(t){const e=[];for(const s in this.keymap)for(const i of this.keymap[s])i.command===t&&e.push({...i});return e}getPlatformInfo(){return{isMac:this.isMac,platform:navigator.platform}}destroy(){this.keymap={},this.editor=null}}class ${constructor(){this.name="transaction",this.transactions=[]}setup(t){t.on("change",e=>{const s={changes:[e],selection:t.getSelection(),effects:[],annotations:[]};this.transactions.push(s)})}getTransactions(){return this.transactions}destroy(){this.transactions=[]}}class H{constructor(){this.name="line-numbers",this.editor=null,this.lineNumbersElement=null,this.isEnabled=!0}setup(t){this.editor=t,this.createLineNumbers(),t.registerCommand("toggleLineNumbers",()=>{this.toggle()}),t.on("change",()=>{this.updateLineNumbers()}),this.updateLineNumbers()}createLineNumbers(){if(!this.editor)return;const e=this.editor.getView().getLineNumbersElement();e&&(this.lineNumbersElement=e)}updateLineNumbers(){if(!this.lineNumbersElement||!this.editor||!this.isEnabled)return;const t=this.editor.getValue().split(`
55
+ `).length,e=Array.from({length:Math.max(t,20)},(s,i)=>i+1);this.lineNumbersElement.innerHTML=e.map(s=>`<div style="height: 21px; line-height: 21px; padding-right: 12px;">${s}</div>`).join("")}toggle(){this.isEnabled=!this.isEnabled,this.lineNumbersElement&&(this.lineNumbersElement.style.display=this.isEnabled?"block":"none");const t=this.editor.getView().getContentElement();t&&(t.style.marginLeft=this.isEnabled?"60px":"0"),this.updateLineNumbers()}destroy(){this.lineNumbersElement=null,this.editor=null}}class R{constructor(){this.name="theme",this.editor=null,this.currentTheme="dark"}setup(t){this.editor=t,t.registerCommand("setTheme",e=>{this.setTheme(e)}),t.registerCommand("toggleTheme",()=>{this.toggleTheme()}),this.setTheme(this.currentTheme)}setTheme(t){this.editor&&(this.currentTheme=t,this.editor.setTheme(t))}toggleTheme(){const t=this.currentTheme==="dark"?"light":"dark";this.setTheme(t)}getCurrentTheme(){return this.currentTheme}destroy(){this.editor=null}}class I{constructor(){this.name="read-only",this.editor=null,this.isReadOnly=!1}setup(t){this.editor=t,t.registerCommand("setReadOnly",e=>{this.setReadOnly(e)}),t.registerCommand("toggleReadOnly",()=>{this.toggleReadOnly()}),t.on("keydown",e=>{if(e.ctrlKey&&e.key==="r")return e.preventDefault(),this.toggleReadOnly(),!1})}setReadOnly(t){this.editor&&(this.isReadOnly=t,this.editor.setReadOnly(t))}toggleReadOnly(){this.setReadOnly(!this.isReadOnly)}isCurrentlyReadOnly(){return this.isReadOnly}destroy(){this.editor=null}}class N{constructor(){this.name="search",this.editor=null,this.searchUI=null,this.isVisible=!1,this.currentResults=[],this.currentIndex=-1}setup(t){this.editor=t,t.registerCommand("find",()=>{this.showSearch()}),t.registerCommand("findNext",()=>{this.findNext()}),t.registerCommand("findPrev",()=>{this.findPrev()}),t.registerCommand("replace",()=>{this.showReplace()}),t.registerCommand("replaceAll",(e,s)=>{this.replaceAll(e,s)})}showSearch(){if(this.editor&&(this.searchUI||this.createSearchUI(),this.isVisible=!0,this.searchUI)){this.searchUI.style.display="block";const t=this.searchUI.querySelector("input");t&&(t.focus(),t.select())}}showReplace(){this.showSearch();const t=this.searchUI?.querySelector(".search-replace-input");t&&(t.style.display="block",t.focus());const e=this.searchUI?.querySelector(".search-status");e&&(e.textContent="Replace mode - Enter to replace, Shift+Enter to replace all")}hideSearch(){this.isVisible=!1,this.searchUI&&(this.searchUI.style.display="none"),this.clearHighlights()}createSearchUI(){if(!this.editor)return;const t=document.querySelector(".rte-source-editor-modal");if(!t)return;this.searchUI=document.createElement("div"),this.searchUI.style.cssText=`
71
56
  position: absolute;
72
57
  top: 10px;
73
58
  right: 10px;
@@ -136,11 +121,11 @@
136
121
  display: none;
137
122
  margin-top: 4px;
138
123
  " />
139
- `;const t=this.searchUI.querySelector("input"),n=this.searchUI.querySelector(".search-replace-input"),i=this.searchUI.querySelector(".search-prev"),s=this.searchUI.querySelector(".search-next"),o=this.searchUI.querySelector(".search-close");t.addEventListener("input",()=>{this.performSearch(t.value)}),t.addEventListener("keydown",h=>{h.key==="Enter"&&(h.preventDefault(),h.shiftKey?this.findPrev():this.findNext())}),n.addEventListener("keydown",h=>{h.key==="Enter"&&(h.preventDefault(),h.shiftKey?this.replaceAll(t.value,n.value):this.replaceCurrent(t.value,n.value))}),i.addEventListener("click",()=>this.findPrev()),s.addEventListener("click",()=>this.findNext()),o.addEventListener("click",()=>this.hideSearch()),e.appendChild(this.searchUI)}performSearch(e){if(!this.editor||!e.trim()){this.clearHighlights(),this.updateStatus("");return}const t=this.editor.getValue(),n=[];let i=t.toLowerCase().indexOf(e.toLowerCase());for(;i!==-1;){const s=this.getPositionFromOffset(t,i),o=this.getPositionFromOffset(t,i+e.length);n.push({range:{start:s,end:o},match:t.substring(i,i+e.length)}),i=t.toLowerCase().indexOf(e.toLowerCase(),i+1)}this.currentResults=n,this.currentIndex=this.currentResults.length>0?0:-1,this.updateHighlights(),this.updateStatus(`${this.currentResults.length} matches`)}getPositionFromOffset(e,t){const n=e.substring(0,t).split(`
140
- `),i=n.length-1,s=n[n.length-1].length;return{line:i,column:s}}findNext(){this.currentResults.length!==0&&(this.currentIndex=(this.currentIndex+1)%this.currentResults.length,this.updateHighlights())}findPrev(){this.currentResults.length!==0&&(this.currentIndex=this.currentIndex<=0?this.currentResults.length-1:this.currentIndex-1,this.updateHighlights())}replaceCurrent(e,t){if(!this.editor||!e.trim()||this.currentIndex===-1)return;const n=this.currentResults[this.currentIndex];if(!n)return;const i=this.editor.getValue(),s=this.getOffsetFromPosition(i,n.range.start),o=i.substring(0,s),h=i.substring(s+e.length),r=o+t+h;this.editor.setValue(r),this.performSearch(e),this.updateStatus("Replaced current occurrence")}replaceAll(e,t){if(!this.editor||!e.trim())return;let n=this.editor.getValue(),i=0,s=n.toLowerCase().indexOf(e.toLowerCase());for(;s!==-1;)n=n.substring(0,s)+t+n.substring(s+e.length),i++,s=n.toLowerCase().indexOf(e.toLowerCase(),s+t.length);i>0&&(this.editor.setValue(n),this.updateStatus(`Replaced ${i} occurrences`))}getOffsetFromPosition(e,t){const n=e.split(`
141
- `);let i=0;for(let s=0;s<t.line;s++)i+=n[s].length+1;return i+=t.column,i}updateHighlights(){this.clearHighlights(),!(this.currentResults.length===0||this.currentIndex===-1)&&(this.currentResults[this.currentIndex],this.updateStatus(`${this.currentResults.length} matches (showing ${this.currentIndex+1}/${this.currentResults.length})`))}clearHighlights(){}updateStatus(e){const t=this.searchUI?.querySelector(".search-status");t&&(t.textContent=e)}destroy(){this.searchUI&&this.searchUI.parentNode&&this.searchUI.parentNode.removeChild(this.searchUI),this.searchUI=null,this.editor=null}}class C{constructor(){this.name="bracket-matching",this.editor=null,this.bracketPairs={"(":")","[":"]","{":"}","<":">"},this.reverseBracketPairs={")":"(","]":"[","}":"{",">":"<"},this.currentMatch=null}setup(e){this.editor=e,e.on("cursor",()=>{this.updateBracketMatching()}),e.on("change",()=>{this.updateBracketMatching()})}updateBracketMatching(){if(!this.editor)return;const e=this.editor.getCursor(),t=this.editor.getValue();this.clearBracketHighlighting();const n=this.getBracketAtPosition(t,e.position);if(!n)return;const i=this.findMatchingBracket(t,n);i&&(this.currentMatch=i,this.highlightBrackets(i))}getBracketAtPosition(e,t){const n=e.split(`
142
- `);if(t.line>=n.length)return null;const i=n[t.line];if(t.column>=i.length)return null;const s=i[t.column];return this.bracketPairs[s]||this.reverseBracketPairs[s]?{char:s,position:t}:null}findMatchingBracket(e,t){const n=e.split(`
143
- `),i=t.position.line,s=t.position.column,o=t.char;return this.bracketPairs[o]?this.findClosingBracket(e,n,i,s,o):this.reverseBracketPairs[o]?this.findOpeningBracket(e,n,i,s,o):null}findClosingBracket(e,t,n,i,s){const o=this.bracketPairs[s];let h=0;for(let r=n;r<t.length;r++){const l=t[r],d=r===n?i:0;for(let a=d;a<l.length;a++){const g=l[a];if(g===s)h++;else if(g===o&&(h--,h===0))return{open:{start:{line:n,column:i},end:{line:n,column:i+1}},close:{start:{line:r,column:a},end:{line:r,column:a+1}},type:s}}}return null}findOpeningBracket(e,t,n,i,s){const o=this.reverseBracketPairs[s];let h=0;for(let r=n;r>=0;r--){const l=t[r],d=r===n?i:l.length-1;for(let a=d;a>=0;a--){const g=l[a];if(g===s)h++;else if(g===o&&(h--,h===0))return{open:{start:{line:r,column:a},end:{line:r,column:a+1}},close:{start:{line:n,column:i},end:{line:n,column:i+1}},type:o}}}return null}highlightBrackets(e){console.log("Bracket match found:",e)}clearBracketHighlighting(){this.currentMatch=null}getCurrentMatch(){return this.currentMatch}destroy(){this.clearBracketHighlighting(),this.editor=null}}class L{constructor(){this.name="code-folding",this.editor=null,this.foldIndicators=[],this.foldingUI=null}setup(e){this.editor=e,e.registerCommand("fold",()=>{console.log("Fold command executed - folding not yet implemented"),this.foldAtCursor()}),e.registerCommand("unfold",()=>{console.log("Unfold command executed - unfolding not yet implemented"),this.unfoldAtCursor()}),e.registerCommand("foldAll",()=>{console.log("Fold all command executed - folding not yet implemented"),this.foldAll()}),e.registerCommand("unfoldAll",()=>{console.log("Unfold all command executed - unfolding not yet implemented"),this.unfoldAll()}),e.on("change",()=>{this.updateFoldIndicators()}),this.createFoldingUI(),this.updateFoldIndicators()}createFoldingUI(){if(!this.editor)return;const e=document.querySelector(".rte-source-editor-modal");e&&(this.foldingUI=document.createElement("div"),this.foldingUI.style.cssText=`
124
+ `;const e=this.searchUI.querySelector("input"),s=this.searchUI.querySelector(".search-replace-input"),i=this.searchUI.querySelector(".search-prev"),n=this.searchUI.querySelector(".search-next"),o=this.searchUI.querySelector(".search-close");e.addEventListener("input",()=>{this.performSearch(e.value)}),e.addEventListener("keydown",h=>{h.key==="Enter"&&(h.preventDefault(),h.shiftKey?this.findPrev():this.findNext())}),s.addEventListener("keydown",h=>{h.key==="Enter"&&(h.preventDefault(),h.shiftKey?this.replaceAll(e.value,s.value):this.replaceCurrent(e.value,s.value))}),i.addEventListener("click",()=>this.findPrev()),n.addEventListener("click",()=>this.findNext()),o.addEventListener("click",()=>this.hideSearch()),t.appendChild(this.searchUI)}performSearch(t){if(!this.editor||!t.trim()){this.clearHighlights(),this.updateStatus("");return}const e=this.editor.getValue(),s=[];let i=e.toLowerCase().indexOf(t.toLowerCase());for(;i!==-1;){const n=this.getPositionFromOffset(e,i),o=this.getPositionFromOffset(e,i+t.length);s.push({range:{start:n,end:o},match:e.substring(i,i+t.length)}),i=e.toLowerCase().indexOf(t.toLowerCase(),i+1)}this.currentResults=s,this.currentIndex=this.currentResults.length>0?0:-1,this.updateHighlights(),this.updateStatus(`${this.currentResults.length} matches`)}getPositionFromOffset(t,e){const s=t.substring(0,e).split(`
125
+ `),i=s.length-1,n=s[s.length-1].length;return{line:i,column:n}}findNext(){this.currentResults.length!==0&&(this.currentIndex=(this.currentIndex+1)%this.currentResults.length,this.updateHighlights())}findPrev(){this.currentResults.length!==0&&(this.currentIndex=this.currentIndex<=0?this.currentResults.length-1:this.currentIndex-1,this.updateHighlights())}replaceCurrent(t,e){if(!this.editor||!t.trim()||this.currentIndex===-1)return;const s=this.currentResults[this.currentIndex];if(!s)return;const i=this.editor.getValue(),n=this.getOffsetFromPosition(i,s.range.start),o=i.substring(0,n),h=i.substring(n+t.length),r=o+e+h;this.editor.setValue(r),this.performSearch(t),this.updateStatus("Replaced current occurrence")}replaceAll(t,e){if(!this.editor||!t.trim())return;let s=this.editor.getValue(),i=0,n=s.toLowerCase().indexOf(t.toLowerCase());for(;n!==-1;)s=s.substring(0,n)+e+s.substring(n+t.length),i++,n=s.toLowerCase().indexOf(t.toLowerCase(),n+e.length);i>0&&(this.editor.setValue(s),this.updateStatus(`Replaced ${i} occurrences`))}getOffsetFromPosition(t,e){const s=t.split(`
126
+ `);let i=0;for(let n=0;n<e.line;n++)i+=s[n].length+1;return i+=e.column,i}updateHighlights(){this.clearHighlights(),!(this.currentResults.length===0||this.currentIndex===-1)&&(this.currentResults[this.currentIndex],this.updateStatus(`${this.currentResults.length} matches (showing ${this.currentIndex+1}/${this.currentResults.length})`))}clearHighlights(){}updateStatus(t){const e=this.searchUI?.querySelector(".search-status");e&&(e.textContent=t)}destroy(){this.searchUI&&this.searchUI.parentNode&&this.searchUI.parentNode.removeChild(this.searchUI),this.searchUI=null,this.editor=null}}class K{constructor(){this.name="bracket-matching",this.editor=null,this.bracketPairs={"(":")","[":"]","{":"}","<":">"},this.reverseBracketPairs={")":"(","]":"[","}":"{",">":"<"},this.currentMatch=null}setup(t){this.editor=t,t.on("cursor",()=>{this.updateBracketMatching()}),t.on("change",()=>{this.updateBracketMatching()})}updateBracketMatching(){if(!this.editor)return;const t=this.editor.getCursor(),e=this.editor.getValue();this.clearBracketHighlighting();const s=this.getBracketAtPosition(e,t.position);if(!s)return;const i=this.findMatchingBracket(e,s);i&&(this.currentMatch=i,this.highlightBrackets(i))}getBracketAtPosition(t,e){const s=t.split(`
127
+ `);if(e.line>=s.length)return null;const i=s[e.line];if(e.column>=i.length)return null;const n=i[e.column];return this.bracketPairs[n]||this.reverseBracketPairs[n]?{char:n,position:e}:null}findMatchingBracket(t,e){const s=t.split(`
128
+ `),i=e.position.line,n=e.position.column,o=e.char;return this.bracketPairs[o]?this.findClosingBracket(t,s,i,n,o):this.reverseBracketPairs[o]?this.findOpeningBracket(t,s,i,n,o):null}findClosingBracket(t,e,s,i,n){const o=this.bracketPairs[n];let h=0;for(let r=s;r<e.length;r++){const l=e[r],c=r===s?i:0;for(let d=c;d<l.length;d++){const f=l[d];if(f===n)h++;else if(f===o&&(h--,h===0))return{open:{start:{line:s,column:i},end:{line:s,column:i+1}},close:{start:{line:r,column:d},end:{line:r,column:d+1}},type:n}}}return null}findOpeningBracket(t,e,s,i,n){const o=this.reverseBracketPairs[n];let h=0;for(let r=s;r>=0;r--){const l=e[r],c=r===s?i:l.length-1;for(let d=c;d>=0;d--){const f=l[d];if(f===n)h++;else if(f===o&&(h--,h===0))return{open:{start:{line:r,column:d},end:{line:r,column:d+1}},close:{start:{line:s,column:i},end:{line:s,column:i+1}},type:o}}}return null}highlightBrackets(t){}clearBracketHighlighting(){this.currentMatch=null}getCurrentMatch(){return this.currentMatch}destroy(){this.clearBracketHighlighting(),this.editor=null}}class B{constructor(){this.name="code-folding",this.editor=null,this.foldIndicators=[],this.foldingUI=null}setup(t){this.editor=t,t.registerCommand("fold",()=>{this.foldAtCursor()}),t.registerCommand("unfold",()=>{this.unfoldAtCursor()}),t.registerCommand("foldAll",()=>{this.foldAll()}),t.registerCommand("unfoldAll",()=>{this.unfoldAll()}),t.on("change",()=>{this.updateFoldIndicators()}),this.createFoldingUI(),this.updateFoldIndicators()}createFoldingUI(){if(!this.editor)return;const t=document.querySelector(".rte-source-editor-modal");t&&(this.foldingUI=document.createElement("div"),this.foldingUI.style.cssText=`
144
129
  position: absolute;
145
130
  left: 40px;
146
131
  top: 0;
@@ -148,11 +133,11 @@
148
133
  width: 20px;
149
134
  pointer-events: none;
150
135
  z-index: 2;
151
- `,e.appendChild(this.foldingUI))}updateFoldIndicators(){if(!this.editor||!this.foldingUI)return;this.foldingUI.innerHTML="",this.foldIndicators=[];const t=this.editor.getValue().split(`
152
- `);this.findFoldableLines(t).forEach(i=>{this.createFoldIndicator(i)})}findFoldableLines(e){const t=[];for(let n=0;n<e.length;n++){const i=e[n].trim();(i.startsWith("{")||i.startsWith("function")||i.startsWith("class")||i.startsWith("if")||i.includes("=>")||i.startsWith("for")||i.startsWith("while")||i.startsWith("try"))&&t.push(n)}return t}createFoldIndicator(e){if(!this.foldingUI)return;const t=document.createElement("div");t.style.cssText=`
136
+ `,t.appendChild(this.foldingUI))}updateFoldIndicators(){if(!this.editor||!this.foldingUI)return;this.foldingUI.innerHTML="",this.foldIndicators=[];const e=this.editor.getValue().split(`
137
+ `);this.findFoldableLines(e).forEach(i=>{this.createFoldIndicator(i)})}findFoldableLines(t){const e=[];for(let s=0;s<t.length;s++){const i=t[s].trim();(i.startsWith("{")||i.startsWith("function")||i.startsWith("class")||i.startsWith("if")||i.includes("=>")||i.startsWith("for")||i.startsWith("while")||i.startsWith("try"))&&e.push(s)}return e}createFoldIndicator(t){if(!this.foldingUI)return;const e=document.createElement("div");e.style.cssText=`
153
138
  position: absolute;
154
139
  left: 0;
155
- top: ${e*21}px;
140
+ top: ${t*21}px;
156
141
  width: 20px;
157
142
  height: 21px;
158
143
  display: flex;
@@ -163,4 +148,4 @@
163
148
  color: var(--editor-gutter-foreground, #858585);
164
149
  font-size: 10px;
165
150
  user-select: none;
166
- `,t.innerHTML="▶",t.title="Code folding not yet implemented - click shows fold indicators",t.addEventListener("click",()=>{console.log(`Fold toggle clicked at line ${e} - implementation pending`)}),this.foldingUI.appendChild(t),this.foldIndicators.push(t)}foldAtCursor(){console.log("foldAtCursor called - implementation pending")}unfoldAtCursor(){console.log("unfoldAtCursor called - implementation pending")}foldAll(){console.log("foldAll called - implementation pending")}unfoldAll(){console.log("unfoldAll called - implementation pending")}destroy(){this.foldingUI&&this.foldingUI.parentNode&&this.foldingUI.parentNode.removeChild(this.foldingUI),this.foldingUI=null,this.foldIndicators=[],this.editor=null}}class T{constructor(){this.name="syntax-highlighting",this.editor=null,this.currentTheme="dark"}setup(e){this.editor=e,console.log("SyntaxHighlightingExtension: Isolated extension loaded - ready for use")}setTheme(e){this.currentTheme=e,console.log(`SyntaxHighlightingExtension: Theme changed to ${e}`)}getSyntaxColors(){return this.currentTheme==="dark"?{tag:"#569cd6",comment:"#6a9955",attrValue:"#ce9178",text:"#d4d4d4"}:{tag:"#0000ff",comment:"#008000",attrValue:"#a31515",text:"#000000"}}highlightHTML(e){const t=this.getSyntaxColors();let n=e;return n=n.replace(/(<\/?[\w:-]+(?:\s[^>]*?)?\/?>)/g,`<span style="color: ${t.tag};">$1</span>`),n=n.replace(/(<!--[\s\S]*?-->)/g,`<span style="color: ${t.comment};">$1</span>`),n=n.replace(/("[^"]*"|'[^']*')/g,`<span style="color: ${t.attrValue};">$1</span>`),n}shouldHighlight(e){return/<\/?[\w:-]+|<!--/.test(e)}destroy(){this.editor=null,console.log("SyntaxHighlightingExtension: Extension destroyed")}}function M(u,e){const t={...e};return t.extensions||(t.extensions=[]),t.extensions.some(i=>i.name==="keymap")||t.extensions.unshift(new b(t.keymap)),new p(u,t)}c.BracketMatchingExtension=C,c.CodeFoldingExtension=L,c.EditorCore=p,c.KeymapExtension=b,c.LineNumbersExtension=v,c.ReadOnlyExtension=w,c.SearchExtension=k,c.SyntaxHighlightingExtension=T,c.TextModel=f,c.ThemeExtension=E,c.View=y,c.createEditor=M,c.default=p,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
151
+ `,e.innerHTML="▶",e.title="Code folding not yet implemented - click shows fold indicators",e.addEventListener("click",()=>{}),this.foldingUI.appendChild(e),this.foldIndicators.push(e)}foldAtCursor(){}unfoldAtCursor(){}foldAll(){}unfoldAll(){}destroy(){this.foldingUI&&this.foldingUI.parentNode&&this.foldingUI.parentNode.removeChild(this.foldingUI),this.foldingUI=null,this.foldIndicators=[],this.editor=null}}class V{constructor(){this.name="syntax-highlighting",this.editor=null,this.currentTheme="dark",this.currentLanguage=null,this.modes=new Map}setup(t){this.editor=t,this.registerMode("html",{name:"html",highlight:(e,s)=>this._highlightHTML(e,s)}),this.registerMode("javascript",{name:"javascript",highlight:(e,s)=>this._highlightJS(e,s)}),this.registerMode("typescript",{name:"typescript",highlight:(e,s)=>this._highlightJS(e,s)}),this.registerMode("php",{name:"php",highlight:(e,s)=>this._highlightPHP(e,s)})}setTheme(t){this.currentTheme=t}setLanguage(t){this.currentLanguage=t}registerMode(t,e){this.modes.set(t.toLowerCase(),e)}getSyntaxColors(){return this.currentTheme==="dark"?{tag:"#569cd6",comment:"#6a9955",attrName:"#9cdcfe",attrValue:"#ce9178",styleProp:"#c586c0",styleVal:"#dcdcaa",doctype:"#808080",text:"#d4d4d4",keyword:"#c586c0",string:"#ce9178",number:"#b5cea8",variable:"#9cdcfe"}:{tag:"#0000ff",comment:"#008000",attrName:"#001080",attrValue:"#a31515",styleProp:"#6a00a8",styleVal:"#804000",doctype:"#444444",text:"#000000",keyword:"#000080",string:"#a31515",number:"#0086b3",variable:"#001080"}}highlight(t,e){const s=this.getSyntaxColors(),i=(e||this.currentLanguage||"html").toLowerCase();return(this.modes.get(i)||this.modes.get("html")).highlight(t,s)}highlightHTML(t){return this.highlight(t,"html")}escapeHTML(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;").replace(/'/g,"&#39;")}unescapeEntitiesRepeated(t){let e=t||"";for(let s=0;s<5;s++){const i=e;if(e=e.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),e===i)break}return e}_highlightHTML(t,e){const s=e,i=l=>this.escapeHTML(l);let n=i(t);const o=l=>{let c=l.replace(/&quot;/g,'"').replace(/&#39;/g,"'");return c=c.replace(/(\/\*[\s\S]*?\*\/)/g,`<span style="color: ${s.comment};">$1</span>`),c=c.replace(/([a-zA-Z-]+)(\s*:\s*)([^;{]+)(;?)/g,(d,f,g,a,u)=>{const p=String(a).trim(),x=i(p);return`<span style="color: ${s.styleProp};">${f}</span>${g}<span style="color: ${s.styleVal};">${x}</span>${u}`}),c},h=[];try{t.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(l,c,d)=>(h.push({attrs:String(c||""),inner:String(d||"")}),l))}catch{}let r=0;return n=n.replace(/(&lt;script\b([^&>]*)&gt;)([\s\S]*?)(&lt;\/script&gt;)/gi,(l,c,d,f,g)=>{const a=h[r++]?.inner??this.unescapeEntitiesRepeated(f||"");(h[r-1]?.attrs||d||"").toLowerCase();const u=this._highlightJS(a,s);return`${c}${u}${g}`}),n=n.replace(/(&lt;style\b[^&]*&gt;)([\s\S]*?)(&lt;\/style&gt;)/gi,(l,c,d,f)=>{const g=o(d);return`${c}${g}${f}`}),n=n.replace(/(&lt;!--[\s\S]*?--&gt;)/g,`<span style="color: ${s.comment};">$1</span>`),n=n.replace(/(&lt;!DOCTYPE[\s\S]*?&gt;)/i,`<span style="color: ${s.doctype};">$1</span>`),n=n.replace(/(&lt;\/?\s*)([^\s&>\/]+)([\s\S]*?)(\/?&gt;)/g,(l,c,d,f,g)=>{const a=`<span style="color: ${s.tag};">${d}</span>`;let u=f;return u=u.replace(/([\w:-]+)(\s*=\s*)((&quot;[\s\S]*?&quot;|&#39;[\s\S]*?&#39;|[^\s&>]+))/g,(p,x,w,T)=>{const L=String(x).toLowerCase(),S=`<span style="color: ${s.attrName};">${x}</span>`;let C=T,v="";T.startsWith("&quot;")&&T.endsWith("&quot;")?(C=T.slice(6,-6),v="&quot;"):T.startsWith("&#39;")&&T.endsWith("&#39;")&&(C=T.slice(5,-5),v="&#39;");let M=T;if(L==="style"){const P=C.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g,(z,U,F,_)=>`<span style="color: ${s.styleProp};">${U}</span>:<span style="color: ${s.styleVal};">${F.trim()}</span>${_}`);v?M=`${v}${P}${v}`:M=P,M=`<span style="color: ${s.attrValue};">${M}</span>`}else v&&(M=`${v}${C}${v}`),M=`<span style="color: ${s.attrValue};">${M}</span>`;return`${S}${w}${M}`}),`${c}${a}${u}${g}`}),n}_highlightJS(t,e){const s=this.unescapeEntitiesRepeated(t);this.escapeHTML(s);const i=[],n=g=>{let a="",u=g;do a=String.fromCharCode(97+u%26)+a,u=Math.floor(u/26)-1;while(u>=0);return a||"a"},o=g=>`\0${n(g)}\0`,h=g=>{const a=i.length;return i.push(g),o(a)};let r;const l=/(\/\*[\s\S]*?\*\/)|(\/\/[^\n\r]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)/g;let c=0,d="";for(;r=l.exec(s);){const g=r.index;c<g&&(d+=this.escapeHTML(s.slice(c,g)));const a=r[0];/^\/\*/.test(a)||/^\/\//.test(a)?d+=h(`<span style="color: ${e.comment};">${this.escapeHTML(a)}</span>`):d+=h(`<span style="color: ${e.string};">${this.escapeHTML(a)}</span>`),c=l.lastIndex}return c<s.length&&(d+=this.escapeHTML(s.slice(c))),d=d.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g,(g,a,u)=>{const p=d[u-1]||"",x=d[u+g.length]||"";return p==="&"||p==="#"||x===";"||x==="#"?g:`<span style="color: ${e.number};">${g}</span>`}),d=d.replace(/\b(const|let|var|function|class|if|else|return|for|while|switch|case|break|import|from|export|extends|new|try|catch|finally|throw|await|async|interface|type)\b/g,`<span style="color: ${e.keyword};">$1</span>`),d.replace(/\u0000([a-z]+)\u0000/g,(g,a)=>{let u=0;for(let p=0;p<a.length;p++)u=u*26+(a.charCodeAt(p)-97+1);return u=u-1,i[u]||""})}_highlightPHP(t,e){const s=this.unescapeEntitiesRepeated(t);let i=this.escapeHTML(s);const n=[],o=a=>{let u="",p=a;do u=String.fromCharCode(97+p%26)+u,p=Math.floor(p/26)-1;while(p>=0);return u||"a"},h=a=>{const u=n.length;return n.push(a),`\0${o(u)}\0`},r=(a,u)=>{const p=i.indexOf(a);return p===-1?!1:(i=i.slice(0,p)+u+i.slice(p+a.length),!0)};let l;const c=/\/\*[\s\S]*?\*\//g,d=/\/\/[^\n\r]*/g,f=/\#([^\n\r]*)/g,g=/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;for(;l=c.exec(s);){const a=l[0];r(this.escapeHTML(a),h(`<span style="color: ${e.comment};">${this.escapeHTML(a)}</span>`))}for(;l=d.exec(s);){const a=l[0];r(this.escapeHTML(a),h(`<span style="color: ${e.comment};">${this.escapeHTML(a)}</span>`))}for(;l=f.exec(s);){const a=l[0];r(this.escapeHTML(a),h(`<span style="color: ${e.comment};">${this.escapeHTML(a)}</span>`))}for(;l=g.exec(s);){const a=l[0];r(this.escapeHTML(a),h(`<span style="color: ${e.string};">${this.escapeHTML(a)}</span>`))}return i=i.replace(/(\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/g,`<span style="color: ${e.variable};">$1</span>`),i=i.replace(/\b(echo|print|function|class|if|else|elseif|foreach|as|return|namespace|use|new|extends|public|protected|private|static)\b/g,`<span style="color: ${e.keyword};">$1</span>`),i=i.replace(/\u0000([a-z]+)\u0000/g,(a,u)=>{let p=0;for(let x=0;x<u.length;x++)p=p*26+(u.charCodeAt(x)-97+1);return p=p-1,n[p]||""}),i}shouldHighlight(t){return/<\/?[\w:-]+|<!--/.test(t)}destroy(){this.editor=null,this.modes.clear()}}function A(y,t){const e={...t};return e.extensions||(e.extensions=[]),e.extensions.some(n=>n.name==="keymap")||e.extensions.unshift(new E(e.keymap)),e.extensions.some(n=>n.name==="transaction")||e.extensions.unshift(new $),new k(y,e)}m.BracketMatchingExtension=K,m.CodeFoldingExtension=B,m.EditorCore=k,m.KeymapExtension=E,m.LineNumbersExtension=H,m.ReadOnlyExtension=I,m.SearchExtension=N,m.SyntaxHighlightingExtension=V,m.TextModel=b,m.ThemeExtension=R,m.View=O,m.createEditor=A,m.default=k,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
@@ -1 +1 @@
1
- .rte-light-editor{position:relative;width:100%;height:400px;border:1px solid #ccc;border-radius:4px;overflow:hidden;font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:14px;line-height:21px}.rte-light-editor-content{position:relative;width:100%;height:100%;padding:8px;margin:0;border:none;outline:none;resize:none;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre-wrap;word-wrap:break-word;overflow:auto;background:transparent}.rte-light-editor-gutter{position:absolute;left:0;top:0;bottom:0;width:50px;padding:8px 0;text-align:right;border-right:1px solid #e0e0e0;background:#f8f8f8;color:#999;font-size:12px;line-height:21px;-webkit-user-select:none;user-select:none;overflow:hidden}.rte-light-editor-gutter.dark{border-right-color:#3e3e3e;background:#1e1e1e;color:#666}.rte-syntax-highlight-overlay{position:absolute;inset:0 0 0 50px;pointer-events:none;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre-wrap;word-wrap:break-word;overflow:hidden;z-index:5;background:transparent;color:transparent}.syntax-html-tag{color:#569cd6!important}.syntax-html-comment{color:#6a9955!important}.syntax-html-attr-value{color:#ce9178!important}.dark .syntax-html-tag{color:#569cd6!important}.dark .syntax-html-comment{color:#6a9955!important}.dark .syntax-html-attr-value{color:#ce9178!important}.light .syntax-html-tag{color:#00f!important}.light .syntax-html-comment{color:green!important}.light .syntax-html-attr-value{color:#a31515!important}.rte-light-editor.dark{background:#1e1e1e;color:#d4d4d4;border-color:#3e3e3e}.rte-light-editor.dark .rte-light-editor-content{background:#1e1e1e;color:#d4d4d4}.rte-light-editor.light{background:#fff;color:#000;border-color:#e0e0e0}.rte-light-editor.light .rte-light-editor-content{background:#fff;color:#000}.rte-light-editor.readonly .rte-light-editor-content{cursor:not-allowed;opacity:.7}.rte-light-editor.readonly .rte-light-editor-content:after{content:"";position:absolute;inset:0;background:#ffffff1a;pointer-events:none}.rte-light-editor.focused{border-color:#007acc;box-shadow:0 0 0 2px #007acc33}.rte-light-editor-content::selection{background:#007acc33}.rte-light-editor.dark .rte-light-editor-content::selection{background:#007acc4d}.rte-light-editor-content::-webkit-scrollbar{width:12px;height:12px}.rte-light-editor-content::-webkit-scrollbar-track{background:#f1f1f1}.rte-light-editor.dark .rte-light-editor-content::-webkit-scrollbar-track{background:#2d2d2d}.rte-light-editor-content::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:6px}.rte-light-editor.dark .rte-light-editor-content::-webkit-scrollbar-thumb{background:#555}.rte-light-editor-content::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.rte-light-editor.dark .rte-light-editor-content::-webkit-scrollbar-thumb:hover{background:#666}.bracket-match{background:#007acc1a;border-radius:2px}.dark .bracket-match{background:#007acc33}.search-match{background:#ffff004d;border-radius:2px}.search-match.current{background:#ff09;border:1px solid #ffcc00}.fold-indicator{position:absolute;left:35px;width:12px;height:12px;cursor:pointer;opacity:.5;transition:opacity .2s}.fold-indicator:hover{opacity:1}.fold-indicator.expanded:before{content:"▼";font-size:10px;color:#666}.fold-indicator.collapsed:before{content:"▶";font-size:10px;color:#666}.dark .fold-indicator.expanded:before,.dark .fold-indicator.collapsed:before{color:#999}
1
+ .rte-light-editor{position:relative;width:100%;height:400px;border:1px solid #ccc;border-radius:4px;overflow:hidden;font-family:Monaco,Menlo,Ubuntu Mono,monospace;font-size:14px;line-height:21px}.rte-light-editor-content{position:relative;width:100%;height:100%;padding:8px;margin:0;border:none;outline:none;resize:none;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre-wrap;word-wrap:break-word;overflow:auto;background:transparent}.rte-light-editor-gutter{position:absolute;left:0;top:0;bottom:0;width:50px;padding:8px 0;text-align:right;border-right:1px solid #e0e0e0;background:#f8f8f8;color:#999;font-size:12px;line-height:21px;-webkit-user-select:none;user-select:none;overflow:hidden}.rte-light-editor-gutter.dark{border-right-color:#3e3e3e;background:#1e1e1e;color:#666}.rte-syntax-highlight-overlay{position:absolute;inset:0 0 0 50px;pointer-events:none;font-family:inherit;font-size:inherit;line-height:inherit;white-space:pre-wrap;word-wrap:break-word;overflow:hidden;z-index:5;background:transparent;color:transparent}.syntax-html-tag{color:#569cd6!important}.syntax-html-comment{color:#6a9955!important}.syntax-html-attr-value{color:#ce9178!important}.dark .syntax-html-tag{color:#569cd6!important}.dark .syntax-html-comment{color:#6a9955!important}.dark .syntax-html-attr-value{color:#ce9178!important}.light .syntax-html-tag{color:#00f!important}.light .syntax-html-comment{color:green!important}.light .syntax-html-attr-value{color:#a31515!important}.rte-light-editor.dark{background:#1e1e1e;color:#d4d4d4;border-color:#3e3e3e}.rte-light-editor.dark .rte-light-editor-content{background:#1e1e1e;color:#d4d4d4}.rte-light-editor.light{background:#fff;color:#000;border-color:#e0e0e0}.rte-light-editor.light .rte-light-editor-content{background:#fff;color:#000}.rte-light-editor.readonly .rte-light-editor-content{cursor:not-allowed;opacity:.7}.rte-light-editor.readonly .rte-light-editor-content:after{content:"";position:absolute;inset:0;background:#ffffff1a;pointer-events:none}.rte-light-editor.focused{border-color:#007acc;box-shadow:0 0 0 2px #007acc33}.rte-light-editor-content::selection{background:#007acc33}.rte-light-editor.dark .rte-light-editor-content::selection{background:#007acc4d}.rte-light-editor-content::-webkit-scrollbar{width:12px;height:12px}.rte-light-editor-content::-webkit-scrollbar-track{background:#f1f1f1}.rte-light-editor.dark .rte-light-editor-content::-webkit-scrollbar-track{background:#2d2d2d}.rte-light-editor-content::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:6px}.rte-light-editor.dark .rte-light-editor-content::-webkit-scrollbar-thumb{background:#555}.rte-light-editor-content::-webkit-scrollbar-thumb:hover{background:#a8a8a8}.rte-light-editor.dark .rte-light-editor-content::-webkit-scrollbar-thumb:hover{background:#666}.bracket-match{background:#007acc1a;border-radius:2px}.dark .bracket-match{background:#007acc33}.search-match{background:#ffff004d;border-radius:2px}.search-match.current{background:#ff09;border:1px solid #ffcc00}.fold-indicator{position:absolute;left:35px;width:12px;height:12px;cursor:pointer;opacity:.5;transition:opacity .2s}.fold-indicator:hover{opacity:1}.fold-indicator.expanded:before{content:"▼";font-size:10px;color:#666}.fold-indicator.collapsed:before{content:"▶";font-size:10px;color:#666}.dark .fold-indicator.expanded:before,.dark .fold-indicator.collapsed:before{color:#999}.editor-container{font-family:monospace;background-color:#1e1e1e;color:#d4d4d4;padding:10px;border:1px solid #333;border-radius:4px;overflow:auto}.editor-line{white-space:pre}.editor-line-number{display:inline-block;width:30px;text-align:right;margin-right:10px;color:#858585}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@editora/light-code-editor",
3
- "version": "1.0.2",
4
- "description": "Lightweight, extensible code editor library inspired by CodeMirror",
3
+ "version": "1.0.3",
4
+ "description": "Lightweight, extensible code editor for the web — syntax highlighting, line numbers, code folding, and a plugin-friendly API. Ideal for embedding in docs, demos, and web apps.",
5
5
  "authors": [
6
6
  "Ajay Kumar <ajaykr089@gmail.com>"
7
7
  ],
@@ -25,11 +25,29 @@
25
25
  },
26
26
  "keywords": [
27
27
  "code-editor",
28
- "codemirror",
29
- "lightweight",
30
- "extensible",
31
- "typescript"
28
+ "lightweight-editor",
29
+ "syntax-highlighting",
30
+ "javascript-editor",
31
+ "typescript-editor",
32
+ "web-editor",
33
+ "code-playground",
34
+ "line-numbers",
35
+ "code-folding",
36
+ "plugin-friendly"
32
37
  ],
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/ajaykr089/Editora.git",
41
+ "directory": "packages/light-code-editor"
42
+ },
43
+ "homepage": "https://github.com/ajaykr089/Editora#readme",
44
+ "bugs": {
45
+ "url": "https://github.com/ajaykr089/Editora/issues"
46
+ },
47
+ "style": "dist/light-code-editor.css",
48
+ "publishConfig": {
49
+ "access": "public"
50
+ },
33
51
  "author": "Ajay Kumar <ajaykr089@gmail.com>",
34
52
  "license": "MIT",
35
53
  "devDependencies": {
@@ -37,5 +55,5 @@
37
55
  "typescript": "^5.0.0",
38
56
  "vite": "^7.3.1"
39
57
  },
40
- "gitHead": "b4a92679b7a31308632c48abd5e536476d58b0c7"
58
+ "gitHead": "694494db58b809f0dcf24501696284faa1ab68a5"
41
59
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Ajay Kumar
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.