@editora/plugins 1.0.2 → 1.0.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.
Files changed (105) hide show
  1. package/README.md +30 -5
  2. package/dist/a11y-checker.cjs.js +109 -0
  3. package/dist/a11y-checker.esm.js +509 -0
  4. package/dist/anchor.cjs.js +176 -0
  5. package/dist/anchor.esm.js +400 -0
  6. package/dist/background-color.cjs.js +218 -0
  7. package/dist/background-color.esm.js +482 -0
  8. package/dist/blockquote.cjs.js +1 -0
  9. package/dist/blockquote.esm.js +47 -0
  10. package/dist/bold.cjs.js +1 -0
  11. package/dist/bold.esm.js +44 -0
  12. package/dist/capitalization.cjs.js +1 -0
  13. package/dist/capitalization.esm.js +78 -0
  14. package/dist/checklist.cjs.js +1 -0
  15. package/dist/checklist.esm.js +305 -0
  16. package/dist/clear-formatting.cjs.js +1 -0
  17. package/dist/clear-formatting.esm.js +138 -0
  18. package/dist/code-sample.cjs.js +161 -0
  19. package/dist/code-sample.esm.js +381 -0
  20. package/dist/code.cjs.js +598 -0
  21. package/dist/code.esm.js +2034 -0
  22. package/dist/colorSelectionApply-C0iOfMWb.js +1 -0
  23. package/dist/colorSelectionApply-D8r_gV32.mjs +63 -0
  24. package/dist/comments.cjs.js +354 -0
  25. package/dist/comments.esm.js +692 -0
  26. package/dist/direction.cjs.js +1 -0
  27. package/dist/direction.esm.js +129 -0
  28. package/dist/document-manager.cjs.js +1 -0
  29. package/dist/document-manager.esm.js +6 -0
  30. package/dist/{documentManager-CYC9totK.mjs → documentManager-DRUc1-Cs.mjs} +3 -3
  31. package/dist/{documentManager-BGlu3WRB.js → documentManager-_tQQfQi9.js} +3 -3
  32. package/dist/editorContainerHelpers-C7kdWnS0.mjs +26 -0
  33. package/dist/editorContainerHelpers-CFbfiOJI.js +1 -0
  34. package/dist/embed-iframe.cjs.js +361 -0
  35. package/dist/embed-iframe.esm.js +556 -0
  36. package/dist/emojis.cjs.js +284 -0
  37. package/dist/emojis.esm.js +1080 -0
  38. package/dist/font-family.cjs.js +1 -0
  39. package/dist/font-family.esm.js +152 -0
  40. package/dist/font-size.cjs.js +1 -0
  41. package/dist/font-size.esm.js +278 -0
  42. package/dist/footnote.cjs.js +85 -0
  43. package/dist/footnote.esm.js +397 -0
  44. package/dist/fullscreen.cjs.js +1 -0
  45. package/dist/fullscreen.esm.js +73 -0
  46. package/dist/heading.cjs.js +1 -0
  47. package/dist/heading.esm.js +63 -0
  48. package/dist/history.cjs.js +1 -0
  49. package/dist/history.esm.js +246 -0
  50. package/dist/indent.cjs.js +1 -0
  51. package/dist/indent.esm.js +146 -0
  52. package/dist/index-Bskk414V.mjs +145 -0
  53. package/dist/index-D3pJyAsj.js +1 -0
  54. package/dist/index.cjs.js +1 -1
  55. package/dist/{index.es-B-to-4j4.js → index.es-Cz1qItab.js} +1 -1
  56. package/dist/{index.es-BbXJ7tyO.mjs → index.es-DEcRmSTY.mjs} +1 -1
  57. package/dist/index.esm.js +89 -49
  58. package/dist/italic.cjs.js +1 -0
  59. package/dist/italic.esm.js +40 -0
  60. package/dist/line-height.cjs.js +1 -0
  61. package/dist/line-height.esm.js +145 -0
  62. package/dist/link.cjs.js +138 -0
  63. package/dist/link.esm.js +276 -0
  64. package/dist/list.cjs.js +1 -0
  65. package/dist/list.esm.js +102 -0
  66. package/dist/lite.cjs.js +1 -0
  67. package/dist/lite.esm.js +61 -0
  68. package/dist/math.cjs.js +45 -0
  69. package/dist/math.esm.js +249 -0
  70. package/dist/media-manager.cjs.js +619 -0
  71. package/dist/media-manager.esm.js +994 -0
  72. package/dist/merge-tag.cjs.js +93 -0
  73. package/dist/merge-tag.esm.js +412 -0
  74. package/dist/page-break.cjs.js +72 -0
  75. package/dist/page-break.esm.js +295 -0
  76. package/dist/plugins.css +1 -1
  77. package/dist/preview.cjs.js +230 -0
  78. package/dist/preview.esm.js +321 -0
  79. package/dist/print.cjs.js +254 -0
  80. package/dist/print.esm.js +309 -0
  81. package/dist/purify.es-DHhaBdbu.mjs +470 -0
  82. package/dist/purify.es-T2a3nLiC.js +3 -0
  83. package/dist/shared-config.cjs.js +1 -0
  84. package/dist/shared-config.esm.js +30 -0
  85. package/dist/special-characters.cjs.js +257 -0
  86. package/dist/special-characters.esm.js +772 -0
  87. package/dist/spell-check.cjs.js +512 -0
  88. package/dist/spell-check.esm.js +1013 -0
  89. package/dist/strikethrough.cjs.js +1 -0
  90. package/dist/strikethrough.esm.js +71 -0
  91. package/dist/table.cjs.js +35 -0
  92. package/dist/table.esm.js +477 -0
  93. package/dist/template.cjs.js +356 -0
  94. package/dist/template.esm.js +560 -0
  95. package/dist/text-alignment.cjs.js +1 -0
  96. package/dist/text-alignment.esm.js +105 -0
  97. package/dist/text-color.cjs.js +300 -0
  98. package/dist/text-color.esm.js +507 -0
  99. package/dist/underline.cjs.js +1 -0
  100. package/dist/underline.esm.js +34 -0
  101. package/index.d.ts +62 -0
  102. package/package.json +218 -6
  103. package/LICENSE +0 -21
  104. package/dist/index-BbORIHoM.mjs +0 -11763
  105. package/dist/index-C-OCBS_6.js +0 -3753
@@ -0,0 +1,598 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class H{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 s=e.start.line+1;s<e.end.line;s++)t.push(this.getLine(s));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 s=this.getTextInRange(e);if(e.start.line===e.end.line){const i=this.getLine(e.start.line),r=i.substring(0,e.start.column)+t+i.substring(e.end.column);this._lines[e.start.line]=r}else{const i=this.getLine(e.start.line),r=this.getLine(e.end.line),n=i.substring(0,e.start.column)+t,o=r.substring(e.end.column),a=t.split(`
5
+ `);a[0]=n+a[0],a[a.length-1]=a[a.length-1]+o,this._lines.splice(e.start.line,e.end.line-e.start.line+1,...a)}return this._version++,{range:e,text:t,oldText:s}}insertText(e,t){const s={start:e,end:e};return this.replaceRange(s,t)}deleteRange(e){return this.replaceRange(e,"")}positionToOffset(e){let t=0;for(let s=0;s<e.line;s++)t+=this.getLine(s).length+1;return t+=e.column,t}offsetToPosition(e){let t=e;for(let s=0;s<this.getLineCount();s++){const i=this.getLine(s).length;if(t<=i)return{line:s,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 H;return e._lines=[...this._lines],e._version=this._version,e}}class R{constructor(e){this.gutterWidth=50,this.lineHeight=21,this.container=e,this.createDOM()}createDOM(){this.container.innerHTML="";const e=document.createElement("div");this.editorContainer=e,e.style.cssText=`
6
+ position: relative;
7
+ display: flex;
8
+ width: 100%;
9
+ height: 100%;
10
+ background: var(--editor-background, #1e1e1e);
11
+ color: var(--editor-foreground, #f8f9fa);
12
+ font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
13
+ font-size: 14px;
14
+ line-height: ${this.lineHeight}px;
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
+ width: ${this.gutterWidth}px;
21
+ background: var(--editor-gutter-background, #252526);
22
+ color: var(--editor-gutter-foreground, #858585);
23
+ padding: 0 8px 0 0;
24
+ text-align: right;
25
+ border-right: 1px solid var(--editor-gutter-border, #3e3e42);
26
+ user-select: none;
27
+ z-index: 1;
28
+ `,this.contentElement=document.createElement("div"),this.contentElement.style.cssText=`
29
+ display: table-cell;
30
+ vertical-align: top;
31
+ padding: 0 12px;
32
+ background: transparent;
33
+ border: none;
34
+ outline: none;
35
+ white-space: pre;
36
+ overflow-x: auto;
37
+ overflow-y: visible;
38
+ min-height: 400px;
39
+ font-family: inherit;
40
+ font-size: inherit;
41
+ line-height: inherit;
42
+ color: inherit;
43
+ tab-size: 2;
44
+ -moz-tab-size: 2;
45
+ `,this.contentElement.contentEditable="true",this.contentElement.spellcheck=!1;const t=document.createElement("div");t.setAttribute("data-editora-editor","true"),t.style.cssText="display: table; table-layout: fixed; width: 100%; height: 100%;",t.appendChild(this.lineNumbersElement),t.appendChild(this.contentElement),e.appendChild(t),this.container.appendChild(e),this.updateLineNumbers(1)}updateLineNumbers(e){const t=Math.max(e,20),s=Array.from({length:t},(i,r)=>r+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(e){this.contentElement.textContent=e;const t=e.split(`
46
+ `).length;this.updateLineNumbers(t)}setHTML(e){const t=/&lt;|&gt;/.test(e),s=/<span\b/i.test(e),i=/<[^>]+>/.test(e);t&&s?this.contentElement.innerHTML=e:i&&!t?this.contentElement.textContent=e:this.contentElement.innerHTML=e;const r=(this.contentElement.textContent||"").split(`
47
+ `).length;this.updateLineNumbers(r)}getCursorPosition(){const e=window.getSelection();if(!e||e.rangeCount===0)return{line:0,column:0};const t=e.getRangeAt(0),s=t.cloneRange();s.selectNodeContents(this.contentElement),s.setEnd(t.endContainer,t.endOffset);const i=s.toString().split(`
48
+ `);return{line:i.length-1,column:i[i.length-1].length}}setCursorPosition(e){const t=this.getText().split(`
49
+ `),s=Math.min(e.line,t.length-1),i=Math.min(e.column,t[s]?.length||0);let r=0;for(let u=0;u<s;u++)r+=t[u].length+1;r+=i;const n=document.createRange(),o=window.getSelection();let a=0,l=null,c=0;const g=document.createTreeWalker(this.contentElement,NodeFilter.SHOW_TEXT,null);let d;for(;d=g.nextNode();){const u=d.textContent?.length||0;if(a+u>=r){l=d,c=r-a;break}a+=u}if(l)try{n.setStart(l,c),n.setEnd(l,c),o?.removeAllRanges(),o?.addRange(n)}catch(u){console.warn("Could not set cursor position:",u)}}getSelectionRange(){const e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return;const t=e.getRangeAt(0),s=t.cloneRange();s.selectNodeContents(this.contentElement),s.setEnd(t.startContainer,t.startOffset);const i=s.toString().split(`
50
+ `),r=t.cloneRange();r.selectNodeContents(this.contentElement),r.setEnd(t.endContainer,t.endOffset);const n=r.toString().split(`
51
+ `);return{start:{line:i.length-1,column:i[i.length-1].length},end:{line:n.length-1,column:n[n.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,s])=>{this.container.style.setProperty(`--${t}`,s)})}scrollToPosition(e){const t=this.lineNumbersElement.children[e.line];t&&t.scrollIntoView({block:"center",behavior:"smooth"})}getScrollTop(){return this.editorContainer.scrollTop}setScrollTop(e){this.editorContainer.scrollTop=e}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=void 0)}}class I{constructor(e,t={}){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,...t},this.textModel=new H(this.config.value),this.view=new R(e),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 e=this.view.getContentElement();e.addEventListener("input",()=>{const t=this.view.getText(),s=this.textModel.getText();if(t!==s){if(!this.suppressHistory){const i=this.getCursor().position,r=this.textModel.positionToOffset(i),n=this.getSelection();let o,a;n&&(o=this.textModel.positionToOffset(n.start),a=this.textModel.positionToOffset(n.end)),this.undoStack.push({text:s,cursorOffset:r,anchorOffset:o,focusOffset:a}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack.length=0}this.textModel.setText(t),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:t,oldText:s}])}}),e.addEventListener("selectionchange",()=>{const t=this.getCursor(),s=this.getSelection();this.emit("cursor",t),s&&this.emit("selection",s)}),e.addEventListener("keydown",t=>{if(this.emit("keydown",t),t.key==="Tab"){this.config.readOnly||this.insertTab(),t.preventDefault(),t.stopPropagation();return}if(t.key==="Enter"){if(!this.config.readOnly){const s=window.getSelection();if(s&&s.rangeCount>0){const i=this.getCursor().position,r=this.textModel.positionToOffset(i),n=this.getSelection();let o,a;n&&(o=this.textModel.positionToOffset(n.start),a=this.textModel.positionToOffset(n.end)),this.suppressHistory||(this.undoStack.push({text:this.textModel.getText(),cursorOffset:r,anchorOffset:o,focusOffset:a}),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 g=this.getCursor().position,d=this.textModel.positionToOffset(g),u=this.getSelection();let h,f;u&&(h=this.textModel.positionToOffset(u.start),f=this.textModel.positionToOffset(u.end));const m=this.view.getText();this.textModel.setText(m),this.highlightTimeout&&clearTimeout(this.highlightTimeout),this.highlightTimeout=setTimeout(()=>{this.renderTextWithHighlight(this.textModel.getText(),!1),requestAnimationFrame(()=>{try{if(u&&(h!==void 0||f!==void 0)){const x=h!==void 0?h:d,k=f!==void 0?f:d,y=Math.min(x,k),C=Math.max(x,k),L=this.textModel.offsetToPosition(y),w=this.textModel.offsetToPosition(C);this.setSelection({start:L,end:w})}else{const x=this.textModel.offsetToPosition(d);this.setCursor(x)}}catch{}}),this.highlightTimeout=null},300),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:this.getValue(),oldText:""}])}}t.preventDefault(),t.stopPropagation();return}for(const s of this.extensions.values())if(s.onKeyDown&&s.onKeyDown(t)===!1){t.preventDefault(),t.stopPropagation();return}}),e.addEventListener("mousedown",t=>{this.emit("mousedown",t);for(const s of this.extensions.values())if(s.onMouseDown&&s.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 s=this.eventListeners.get(e);s&&s.forEach(i=>i(...t))}getValue(){return this.textModel.getText()}setValue(e){const t=this.textModel.getText();this.textModel.setText(e),this.renderTextWithHighlight(e,!1),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:e,oldText:t}])}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);const s=this.extensions.get("syntax-highlighting");if(s&&typeof s.setTheme=="function")try{s.setTheme(e==="dark"?"dark":"light"),this.renderTextWithHighlight(this.textModel.getText())}catch(i){console.warn("Error applying theme to syntax-highlighting extension",i)}}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),e.name==="syntax-highlighting"&&typeof e.highlightHTML=="function"&&this.renderTextWithHighlight(this.textModel.getText())}removeExtension(e){const t=this.extensions.get(e);t&&t.destroy&&t.destroy(),this.extensions.delete(e)}executeCommand(e,...t){const s=this.commands.get(e);s?s(this,...t):console.warn(`Command '${e}' not found`)}registerCommand(e,t){this.commands.set(e,t)}search(e,t={}){const s={caseSensitive:!1,regex:!1,...t},i=[],r=this.getValue();r.split(`
53
+ `);let n=s.caseSensitive?r:r.toLowerCase(),o=s.caseSensitive?e:e.toLowerCase();if(s.regex){const a=new RegExp(o,s.caseSensitive?"g":"gi");let l;for(;(l=a.exec(n))!==null;){const c=this.textModel.offsetToPosition(l.index),g=this.textModel.offsetToPosition(l.index+l[0].length);i.push({range:{start:c,end:g},match:l[0]})}}else{let a=0,l=n.indexOf(o,a);for(;l!==-1;){const c=l+e.length,g=this.textModel.offsetToPosition(l),d=this.textModel.offsetToPosition(c);i.push({range:{start:g,end:d},match:r.substring(l,c)}),a=c,l=n.indexOf(o,a)}}return i}replace(e,t){const s=this.getValue();if(!this.suppressHistory){const r=this.getCursor().position,n=this.textModel.positionToOffset(r),o=this.getSelection();let a,l;o&&(a=this.textModel.positionToOffset(o.start),l=this.textModel.positionToOffset(o.end)),this.undoStack.push({text:s,cursorOffset:n,anchorOffset:a,focusOffset:l}),this.undoStack.length>100&&this.undoStack.shift(),this.redoStack.length=0}const i=this.textModel.replaceRange(e,t);this.renderTextWithHighlight(this.getValue(),!1),this.emit("change",[i])}replaceAll(e,t,s={}){const i=this.search(e,s);let r=0;for(let n=i.length-1;n>=0;n--)this.replace(i[n].range,t),r++;return r}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()}renderTextWithHighlight(e,t=!0){const s=this.extensions.get("syntax-highlighting");if(s&&typeof s.highlightHTML=="function")try{const i=!t&&!this.expectingProgrammaticCursor;let r,n,o,a;if(t||i){r=this.getSelection();const c=this.getCursor().position;n=this.textModel.positionToOffset(c),r&&(o=this.textModel.positionToOffset(r.start),a=this.textModel.positionToOffset(r.end))}const l=s.highlightHTML(e);typeof this.view.setHighlightHTML=="function"?this.view.setHighlightHTML(l):this.view.setHTML(l),(t||i)&&requestAnimationFrame(()=>{try{if(r&&(o!==void 0||a!==void 0)){const c=o!==void 0?o:n,g=a!==void 0?a:n,d=Math.min(c,g),u=Math.max(c,g),h=this.textModel.offsetToPosition(d),f=this.textModel.offsetToPosition(u);this.view.setSelectionRange({start:h,end:f})}else if(n!==void 0){const c=this.textModel.offsetToPosition(n);this.view.setCursorPosition(c)}}catch{}});return}catch(i){console.warn("Syntax highlighting failed, falling back to plain text",i)}this.view.setText(e)}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()}}undo(){if(this.undoStack.length===0)return;const e=this.undoStack.pop(),t={text:this.getValue(),cursorOffset:this.textModel.positionToOffset(this.getCursor().position)};this.redoStack.push(t);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0;let s,i;typeof e=="string"?s=e:(s=e.text,i=e.cursorOffset),this.setValue(s),requestAnimationFrame(()=>{try{if(i!=null)if(typeof e!="string"&&(e.anchorOffset!==void 0||e.focusOffset!==void 0)){const r=e.anchorOffset!==void 0?e.anchorOffset:i,n=e.focusOffset!==void 0?e.focusOffset:i,o=Math.min(r,n),a=Math.max(r,n),l=this.textModel.offsetToPosition(o),c=this.textModel.offsetToPosition(a);this.setSelection({start:l,end:c})}else{const r=this.textModel.offsetToPosition(i);this.setCursor(r)}}catch{}}),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}redo(){if(this.redoStack.length===0)return;const e=this.redoStack.pop(),t={text:this.getValue(),cursorOffset:this.textModel.positionToOffset(this.getCursor().position)};this.undoStack.push(t);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0;let s,i;typeof e=="string"?s=e:(s=e.text,i=e.cursorOffset),this.setValue(s),requestAnimationFrame(()=>{try{if(i!=null)if(typeof e!="string"&&(e.anchorOffset!==void 0||e.focusOffset!==void 0)){const r=e.anchorOffset!==void 0?e.anchorOffset:i,n=e.focusOffset!==void 0?e.focusOffset:i,o=Math.min(r,n),a=Math.max(r,n),l=this.textModel.offsetToPosition(o),c=this.textModel.offsetToPosition(a);this.setSelection({start:l,end:c})}else{const r=this.textModel.offsetToPosition(i);this.setCursor(r)}}catch{}}),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}insertTab(){if(this.config.readOnly)return;const e=this.getCursor().position,t=this.textModel.positionToOffset(e),s=" ".repeat(this.config.tabSize||2),i=this.textModel.insertText(e,s),r=this.textModel.offsetToPosition(this.textModel.positionToOffset(e)+s.length);if(!this.suppressHistory){const n=this.getSelection();let o,a;n&&(o=this.textModel.positionToOffset(n.start),a=this.textModel.positionToOffset(n.end)),this.undoStack.push({text:this.getValue(),cursorOffset:t,anchorOffset:o,focusOffset:a}),this.redoStack.length=0}this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.setCursor(r),setTimeout(()=>{this.expectingProgrammaticCursor=!1},20),this.emit("change",[i])}insertNewLine(){if(this.config.readOnly)return;const e=this.getCursor().position,t=this.textModel.positionToOffset(e),s=this.textModel.insertText(e,`
54
+ `),i=this.textModel.offsetToPosition(this.textModel.positionToOffset(e)+1);if(!this.suppressHistory){const r=this.getSelection();let n,o;r&&(n=this.textModel.positionToOffset(r.start),o=this.textModel.positionToOffset(r.end)),this.undoStack.push({text:this.getValue(),cursorOffset:t,anchorOffset:n,focusOffset:o}),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(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 s=this.eventListeners.get(e);if(t){const i=s.indexOf(t);i!==-1&&s.splice(i,1)}else s.length=0}}class N{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}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:s,altKey:i,shiftKey:r,metaKey:n}=e,o=String(t).toLowerCase(),a=this.keymap[o];if(!a)return null;for(const l of a){const c=l.ctrlKey===void 0||l.ctrlKey===s,g=l.altKey===void 0||l.altKey===i,d=l.shiftKey===void 0||l.shiftKey===r,u=l.metaKey===void 0||l.metaKey===n;if(c&&g&&d&&u)return l}return null}onKeyDown(e){return this.handleKeyDown(e)}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:!0},"save"),this.addBinding(e,"s",{metaKey:!0},"save"),this.addBinding(e,"z",{ctrlKey:!0},"undo"),this.addBinding(e,"z",{metaKey:!0},"undo"),this.addBinding(e,"y",{ctrlKey:!0},"redo"),this.addBinding(e,"y",{metaKey:!0},"redo"),this.addBinding(e,"z",{ctrlKey:!0,shiftKey:!0},"redo"),this.addBinding(e,"z",{metaKey:!0,shiftKey:!0},"redo"),this.addBinding(e,"tab",{},"insertTab"),this.addBinding(e,"t",{ctrlKey:!this.isMac,metaKey:this.isMac,shiftKey:!0},"toggleTheme"),e}addBinding(e,t,s,i){const r=t.toLowerCase();e[r]||(e[r]=[]),e[r].push({key:r,command:i,...s})}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(s=>s.command!==e.command),this.keymap[t].push({...e,key:t})}removeKeyBinding(e,t){const s=e.toLowerCase();t?this.keymap[s]&&(this.keymap[s]=this.keymap[s].filter(i=>i.command!==t),this.keymap[s].length===0&&delete this.keymap[s]):delete this.keymap[s]}getKeymap(){return{...this.keymap}}getBindingsForCommand(e){const t=[];for(const s in this.keymap)for(const i of this.keymap[s])i.command===e&&t.push({...i});return t}getPlatformInfo(){return{isMac:this.isMac,platform:navigator.platform}}destroy(){this.keymap={},this.editor=null}}class B{constructor(){this.name="transaction",this.transactions=[]}setup(e){e.on("change",t=>{const s={changes:[t],selection:e.getSelection(),effects:[],annotations:[]};this.transactions.push(s)})}getTransactions(){return this.transactions}destroy(){this.transactions=[]}}class K{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().getLineNumbersElement();e&&(this.lineNumbersElement=e)}updateLineNumbers(){if(!this.lineNumbersElement||!this.editor||!this.isEnabled)return;const e=this.editor.getValue().split(`
55
+ `).length,t=Array.from({length:Math.max(e,20)},(s,i)=>i+1);this.lineNumbersElement.innerHTML=t.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 e=this.editor.getView().getContentElement();e&&(e.style.marginLeft=this.isEnabled?"60px":"0"),this.updateLineNumbers()}destroy(){this.lineNumbersElement=null,this.editor=null}}class A{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 V{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 U{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,s)=>{this.replaceAll(t,s)})}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=`
56
+ position: absolute;
57
+ top: 10px;
58
+ right: 10px;
59
+ background: var(--editor-background, #1e1e1e);
60
+ border: 1px solid var(--editor-gutter-border, #3e3e42);
61
+ border-radius: 4px;
62
+ padding: 8px;
63
+ z-index: 1000;
64
+ display: none;
65
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
66
+ min-width: 250px;
67
+ `,this.searchUI.innerHTML=`
68
+ <div style="display: flex; align-items: center; gap: 4px; margin-bottom: 4px;">
69
+ <input type="text" placeholder="Find..." style="
70
+ flex: 1;
71
+ padding: 4px 8px;
72
+ background: var(--editor-gutter-background, #252526);
73
+ color: var(--editor-foreground, #f8f9fa);
74
+ border: 1px solid var(--editor-gutter-border, #3e3e42);
75
+ border-radius: 3px;
76
+ font-size: 12px;
77
+ outline: none;
78
+ " />
79
+ <button class="search-prev" style="
80
+ padding: 2px 6px;
81
+ background: var(--editor-gutter-background, #252526);
82
+ color: var(--editor-gutter-foreground, #858585);
83
+ border: 1px solid var(--editor-gutter-border, #3e3e42);
84
+ border-radius: 3px;
85
+ cursor: pointer;
86
+ font-size: 11px;
87
+ ">↑</button>
88
+ <button class="search-next" style="
89
+ padding: 2px 6px;
90
+ background: var(--editor-gutter-background, #252526);
91
+ color: var(--editor-gutter-foreground, #858585);
92
+ border: 1px solid var(--editor-gutter-border, #3e3e42);
93
+ border-radius: 3px;
94
+ cursor: pointer;
95
+ font-size: 11px;
96
+ ">↓</button>
97
+ <button class="search-close" style="
98
+ padding: 2px 6px;
99
+ background: var(--editor-gutter-background, #252526);
100
+ color: var(--editor-gutter-foreground, #858585);
101
+ border: 1px solid var(--editor-gutter-border, #3e3e42);
102
+ border-radius: 3px;
103
+ cursor: pointer;
104
+ font-size: 11px;
105
+ ">×</button>
106
+ </div>
107
+ <div class="search-status" style="
108
+ font-size: 11px;
109
+ color: var(--editor-gutter-foreground, #858585);
110
+ text-align: center;
111
+ "></div>
112
+ <input type="text" class="search-replace-input" placeholder="Replace with..." style="
113
+ width: 100%;
114
+ padding: 4px 8px;
115
+ background: var(--editor-gutter-background, #252526);
116
+ color: var(--editor-foreground, #f8f9fa);
117
+ border: 1px solid var(--editor-gutter-border, #3e3e42);
118
+ border-radius: 3px;
119
+ font-size: 12px;
120
+ outline: none;
121
+ display: none;
122
+ margin-top: 4px;
123
+ " />
124
+ `;const t=this.searchUI.querySelector("input"),s=this.searchUI.querySelector(".search-replace-input"),i=this.searchUI.querySelector(".search-prev"),r=this.searchUI.querySelector(".search-next"),n=this.searchUI.querySelector(".search-close");t.addEventListener("input",()=>{this.performSearch(t.value)}),t.addEventListener("keydown",o=>{o.key==="Enter"&&(o.preventDefault(),o.shiftKey?this.findPrev():this.findNext())}),s.addEventListener("keydown",o=>{o.key==="Enter"&&(o.preventDefault(),o.shiftKey?this.replaceAll(t.value,s.value):this.replaceCurrent(t.value,s.value))}),i.addEventListener("click",()=>this.findPrev()),r.addEventListener("click",()=>this.findNext()),n.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(),s=[];let i=t.toLowerCase().indexOf(e.toLowerCase());for(;i!==-1;){const r=this.getPositionFromOffset(t,i),n=this.getPositionFromOffset(t,i+e.length);s.push({range:{start:r,end:n},match:t.substring(i,i+e.length)}),i=t.toLowerCase().indexOf(e.toLowerCase(),i+1)}this.currentResults=s,this.currentIndex=this.currentResults.length>0?0:-1,this.updateHighlights(),this.updateStatus(`${this.currentResults.length} matches`)}getPositionFromOffset(e,t){const s=e.substring(0,t).split(`
125
+ `),i=s.length-1,r=s[s.length-1].length;return{line:i,column:r}}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 s=this.currentResults[this.currentIndex];if(!s)return;const i=this.editor.getValue(),r=this.getOffsetFromPosition(i,s.range.start),n=i.substring(0,r),o=i.substring(r+e.length),a=n+t+o;this.editor.setValue(a),this.performSearch(e),this.updateStatus("Replaced current occurrence")}replaceAll(e,t){if(!this.editor||!e.trim())return;let s=this.editor.getValue(),i=0,r=s.toLowerCase().indexOf(e.toLowerCase());for(;r!==-1;)s=s.substring(0,r)+t+s.substring(r+e.length),i++,r=s.toLowerCase().indexOf(e.toLowerCase(),r+t.length);i>0&&(this.editor.setValue(s),this.updateStatus(`Replaced ${i} occurrences`))}getOffsetFromPosition(e,t){const s=e.split(`
126
+ `);let i=0;for(let r=0;r<t.line;r++)i+=s[r].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 z{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 s=this.getBracketAtPosition(t,e.position);if(!s)return;const i=this.findMatchingBracket(t,s);i&&(this.currentMatch=i,this.highlightBrackets(i))}getBracketAtPosition(e,t){const s=e.split(`
127
+ `);if(t.line>=s.length)return null;const i=s[t.line];if(t.column>=i.length)return null;const r=i[t.column];return this.bracketPairs[r]||this.reverseBracketPairs[r]?{char:r,position:t}:null}findMatchingBracket(e,t){const s=e.split(`
128
+ `),i=t.position.line,r=t.position.column,n=t.char;return this.bracketPairs[n]?this.findClosingBracket(e,s,i,r,n):this.reverseBracketPairs[n]?this.findOpeningBracket(e,s,i,r,n):null}findClosingBracket(e,t,s,i,r){const n=this.bracketPairs[r];let o=0;for(let a=s;a<t.length;a++){const l=t[a],c=a===s?i:0;for(let g=c;g<l.length;g++){const d=l[g];if(d===r)o++;else if(d===n&&(o--,o===0))return{open:{start:{line:s,column:i},end:{line:s,column:i+1}},close:{start:{line:a,column:g},end:{line:a,column:g+1}},type:r}}}return null}findOpeningBracket(e,t,s,i,r){const n=this.reverseBracketPairs[r];let o=0;for(let a=s;a>=0;a--){const l=t[a],c=a===s?i:l.length-1;for(let g=c;g>=0;g--){const d=l[g];if(d===r)o++;else if(d===n&&(o--,o===0))return{open:{start:{line:a,column:g},end:{line:a,column:g+1}},close:{start:{line:s,column:i},end:{line:s,column:i+1}},type:n}}}return null}highlightBrackets(e){}clearBracketHighlighting(){this.currentMatch=null}getCurrentMatch(){return this.currentMatch}destroy(){this.clearBracketHighlighting(),this.editor=null}}class q{constructor(){this.name="code-folding",this.editor=null,this.foldIndicators=[],this.foldingUI=null}setup(e){this.editor=e,e.registerCommand("fold",()=>{this.foldAtCursor()}),e.registerCommand("unfold",()=>{this.unfoldAtCursor()}),e.registerCommand("foldAll",()=>{this.foldAll()}),e.registerCommand("unfoldAll",()=>{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=`
129
+ position: absolute;
130
+ left: 40px;
131
+ top: 0;
132
+ bottom: 0;
133
+ width: 20px;
134
+ pointer-events: none;
135
+ z-index: 2;
136
+ `,e.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(t=>{this.createFoldIndicator(t)})}findFoldableLines(e){const t=[];for(let s=0;s<e.length;s++){const i=e[s].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(s)}return t}createFoldIndicator(e){if(!this.foldingUI)return;const t=document.createElement("div");t.style.cssText=`
138
+ position: absolute;
139
+ left: 0;
140
+ top: ${e*21}px;
141
+ width: 20px;
142
+ height: 21px;
143
+ display: flex;
144
+ align-items: center;
145
+ justify-content: center;
146
+ cursor: pointer;
147
+ pointer-events: auto;
148
+ color: var(--editor-gutter-foreground, #858585);
149
+ font-size: 10px;
150
+ user-select: none;
151
+ `,t.innerHTML="▶",t.title="Code folding not yet implemented - click shows fold indicators",t.addEventListener("click",()=>{}),this.foldingUI.appendChild(t),this.foldIndicators.push(t)}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 _{constructor(){this.name="syntax-highlighting",this.editor=null,this.currentTheme="dark",this.currentLanguage=null,this.modes=new Map}setup(e){this.editor=e,this.registerMode("html",{name:"html",highlight:(t,s)=>this._highlightHTML(t,s)}),this.registerMode("javascript",{name:"javascript",highlight:(t,s)=>this._highlightJS(t,s)}),this.registerMode("typescript",{name:"typescript",highlight:(t,s)=>this._highlightJS(t,s)}),this.registerMode("php",{name:"php",highlight:(t,s)=>this._highlightPHP(t,s)})}setTheme(e){this.currentTheme=e}setLanguage(e){this.currentLanguage=e}registerMode(e,t){this.modes.set(e.toLowerCase(),t)}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(e,t){const s=this.getSyntaxColors(),i=(t||this.currentLanguage||"html").toLowerCase();return(this.modes.get(i)||this.modes.get("html")).highlight(e,s)}highlightHTML(e){return this.highlight(e,"html")}escapeHTML(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;").replace(/'/g,"&#39;")}unescapeEntitiesRepeated(e){let t=e||"";for(let s=0;s<5;s++){const i=t;if(t=t.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),t===i)break}return t}_highlightHTML(e,t){const s=t,i=l=>this.escapeHTML(l);let r=i(e);const n=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,(g,d,u,h,f)=>{const m=String(h).trim(),x=i(m);return`<span style="color: ${s.styleProp};">${d}</span>${u}<span style="color: ${s.styleVal};">${x}</span>${f}`}),c},o=[];try{e.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(l,c,g)=>(o.push({attrs:String(c||""),inner:String(g||"")}),l))}catch{}let a=0;return r=r.replace(/(&lt;script\b([^&>]*)&gt;)([\s\S]*?)(&lt;\/script&gt;)/gi,(l,c,g,d,u)=>{const h=o[a++]?.inner??this.unescapeEntitiesRepeated(d||"");(o[a-1]?.attrs||g||"").toLowerCase();const f=this._highlightJS(h,s);return`${c}${f}${u}`}),r=r.replace(/(&lt;style\b[^&]*&gt;)([\s\S]*?)(&lt;\/style&gt;)/gi,(l,c,g,d)=>{const u=n(g);return`${c}${u}${d}`}),r=r.replace(/(&lt;!--[\s\S]*?--&gt;)/g,`<span style="color: ${s.comment};">$1</span>`),r=r.replace(/(&lt;!DOCTYPE[\s\S]*?&gt;)/i,`<span style="color: ${s.doctype};">$1</span>`),r=r.replace(/(&lt;\/?\s*)([^\s&>\/]+)([\s\S]*?)(\/?&gt;)/g,(l,c,g,d,u)=>{const h=`<span style="color: ${s.tag};">${g}</span>`;let f=d;return f=f.replace(/([\w:-]+)(\s*=\s*)((&quot;[\s\S]*?&quot;|&#39;[\s\S]*?&#39;|[^\s&>]+))/g,(m,x,k,y)=>{const C=String(x).toLowerCase(),L=`<span style="color: ${s.attrName};">${x}</span>`;let w=y,b="";y.startsWith("&quot;")&&y.endsWith("&quot;")?(w=y.slice(6,-6),b="&quot;"):y.startsWith("&#39;")&&y.endsWith("&#39;")&&(w=y.slice(5,-5),b="&#39;");let T=y;if(C==="style"){const S=w.replace(/([\w-]+)\s*:\s*([^;]+)(;?)/g,(E,p,M,$)=>`<span style="color: ${s.styleProp};">${p}</span>:<span style="color: ${s.styleVal};">${M.trim()}</span>${$}`);b?T=`${b}${S}${b}`:T=S,T=`<span style="color: ${s.attrValue};">${T}</span>`}else b&&(T=`${b}${w}${b}`),T=`<span style="color: ${s.attrValue};">${T}</span>`;return`${L}${k}${T}`}),`${c}${h}${f}${u}`}),r}_highlightJS(e,t){const s=this.unescapeEntitiesRepeated(e);this.escapeHTML(s);const i=[],r=d=>{let u="",h=d;do u=String.fromCharCode(97+h%26)+u,h=Math.floor(h/26)-1;while(h>=0);return u||"a"},n=d=>`\0${r(d)}\0`,o=d=>{const u=i.length;return i.push(d),n(u)};let a;const l=/(\/\*[\s\S]*?\*\/)|(\/\/[^\n\r]*)|("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`)/g;let c=0,g="";for(;a=l.exec(s);){const d=a.index;c<d&&(g+=this.escapeHTML(s.slice(c,d)));const u=a[0];/^\/\*/.test(u)||/^\/\//.test(u)?g+=o(`<span style="color: ${t.comment};">${this.escapeHTML(u)}</span>`):g+=o(`<span style="color: ${t.string};">${this.escapeHTML(u)}</span>`),c=l.lastIndex}return c<s.length&&(g+=this.escapeHTML(s.slice(c))),g=g.replace(/\b(0x[0-9a-fA-F]+|\d+\.?\d*|\d*\.\d+)\b/g,(d,u,h)=>{const f=g[h-1]||"",m=g[h+d.length]||"";return f==="&"||f==="#"||m===";"||m==="#"?d:`<span style="color: ${t.number};">${d}</span>`}),g=g.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: ${t.keyword};">$1</span>`),g.replace(/\u0000([a-z]+)\u0000/g,(d,u)=>{let h=0;for(let f=0;f<u.length;f++)h=h*26+(u.charCodeAt(f)-97+1);return h=h-1,i[h]||""})}_highlightPHP(e,t){const s=this.unescapeEntitiesRepeated(e);let i=this.escapeHTML(s);const r=[],n=h=>{let f="",m=h;do f=String.fromCharCode(97+m%26)+f,m=Math.floor(m/26)-1;while(m>=0);return f||"a"},o=h=>{const f=r.length;return r.push(h),`\0${n(f)}\0`},a=(h,f)=>{const m=i.indexOf(h);return m===-1?!1:(i=i.slice(0,m)+f+i.slice(m+h.length),!0)};let l;const c=/\/\*[\s\S]*?\*\//g,g=/\/\/[^\n\r]*/g,d=/\#([^\n\r]*)/g,u=/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')/g;for(;l=c.exec(s);){const h=l[0];a(this.escapeHTML(h),o(`<span style="color: ${t.comment};">${this.escapeHTML(h)}</span>`))}for(;l=g.exec(s);){const h=l[0];a(this.escapeHTML(h),o(`<span style="color: ${t.comment};">${this.escapeHTML(h)}</span>`))}for(;l=d.exec(s);){const h=l[0];a(this.escapeHTML(h),o(`<span style="color: ${t.comment};">${this.escapeHTML(h)}</span>`))}for(;l=u.exec(s);){const h=l[0];a(this.escapeHTML(h),o(`<span style="color: ${t.string};">${this.escapeHTML(h)}</span>`))}return i=i.replace(/(\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)/g,`<span style="color: ${t.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: ${t.keyword};">$1</span>`),i=i.replace(/\u0000([a-z]+)\u0000/g,(h,f)=>{let m=0;for(let x=0;x<f.length;x++)m=m*26+(f.charCodeAt(x)-97+1);return m=m-1,r[m]||""}),i}shouldHighlight(e){return/<\/?[\w:-]+|<!--/.test(e)}destroy(){this.editor=null,this.modes.clear()}}function F(v,e){const t={...e};return t.extensions||(t.extensions=[]),t.extensions.some(s=>s.name==="keymap")||t.extensions.unshift(new N(t.keymap)),t.extensions.some(s=>s.name==="transaction")||t.extensions.unshift(new B),new I(v,t)}const O='[data-theme="dark"], .dark, .editora-theme-dark',D=`/* Source Editor Dialog Styles */
152
+ .rte-source-editor-overlay {
153
+ position: fixed !important;
154
+ top: 0 !important;
155
+ left: 0 !important;
156
+ right: 0 !important;
157
+ bottom: 0 !important;
158
+ width: 100vw !important;
159
+ height: 100vh !important;
160
+ background-color: rgba(0, 0, 0, 0.6) !important;
161
+ display: flex !important;
162
+ align-items: center !important;
163
+ justify-content: center !important;
164
+ z-index: 10000 !important;
165
+ padding: 20px !important;
166
+ box-sizing: border-box !important;
167
+ margin: 0 !important;
168
+ }
169
+
170
+ .rte-source-editor-overlay.fullscreen {
171
+ padding: 0 !important;
172
+ }
173
+
174
+ .rte-source-editor-modal {
175
+ background: white;
176
+ border-radius: 8px;
177
+ box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
178
+ width: 100%;
179
+ max-width: 1200px;
180
+ max-height: 90vh;
181
+ display: flex;
182
+ flex-direction: column;
183
+ overflow: hidden;
184
+ position: relative;
185
+ }
186
+
187
+ .rte-source-editor-overlay.fullscreen .rte-source-editor-modal {
188
+ border-radius: 0;
189
+ max-width: 100%;
190
+ max-height: 100vh;
191
+ width: 100%;
192
+ height: 100vh;
193
+ }
194
+
195
+ .rte-source-editor-header {
196
+ display: flex;
197
+ align-items: center;
198
+ justify-content: space-between;
199
+ padding: 16px 20px;
200
+ border-bottom: 1px solid #e1e5e9;
201
+ background: #f8f9fa;
202
+ border-radius: 8px 8px 0 0;
203
+ }
204
+
205
+ .rte-source-editor-overlay.fullscreen .rte-source-editor-header {
206
+ border-radius: 0;
207
+ }
208
+
209
+ .rte-source-editor-header h2 {
210
+ margin: 0;
211
+ font-size: 18px;
212
+ font-weight: 600;
213
+ color: #1a1a1a;
214
+ }
215
+
216
+ .rte-source-editor-header-toolbar {
217
+ display: flex;
218
+ gap: 8px;
219
+ margin-left: auto;
220
+ margin-right: 16px;
221
+ }
222
+
223
+ .rte-source-editor-toolbar-btn {
224
+ background: none;
225
+ border: none;
226
+ cursor: pointer;
227
+ padding: 6px;
228
+ border-radius: 4px;
229
+ font-size: 16px;
230
+ line-height: 1;
231
+ transition: all 0.2s ease;
232
+ color: #666;
233
+ }
234
+
235
+ .rte-source-editor-toolbar-btn:hover:not(:disabled) {
236
+ background: #e1e5e9;
237
+ color: #1a1a1a;
238
+ }
239
+
240
+ .rte-source-editor-toolbar-btn:disabled {
241
+ opacity: 0.5;
242
+ cursor: not-allowed;
243
+ }
244
+
245
+ .rte-source-editor-toolbar-btn.active {
246
+ background: #007acc;
247
+ color: white;
248
+ }
249
+
250
+ .rte-source-editor-toolbar-btn.active:hover {
251
+ background: #0056b3;
252
+ }
253
+
254
+ .rte-source-editor-header-actions {
255
+ display: flex;
256
+ gap: 8px;
257
+ }
258
+
259
+ .rte-source-editor-fullscreen-btn,
260
+ .rte-source-editor-close-btn {
261
+ background: none;
262
+ border: none;
263
+ cursor: pointer;
264
+ padding: 4px;
265
+ border-radius: 4px;
266
+ color: #666;
267
+ font-size: 16px;
268
+ line-height: 1;
269
+ transition: all 0.2s ease;
270
+ }
271
+
272
+ .rte-source-editor-fullscreen-btn:hover,
273
+ .rte-source-editor-close-btn:hover {
274
+ background: #e1e5e9;
275
+ color: #1a1a1a;
276
+ }
277
+
278
+ .rte-source-editor-body {
279
+ flex: 1;
280
+ overflow: hidden;
281
+ display: flex;
282
+ flex-direction: column;
283
+ }
284
+
285
+ .rte-source-editor-loading {
286
+ display: flex;
287
+ flex-direction: column;
288
+ align-items: center;
289
+ justify-content: center;
290
+ padding: 40px;
291
+ color: #666;
292
+ position: absolute;
293
+ z-index: 9;
294
+ margin: 0 auto;
295
+ width: 100%;
296
+ top: 44%;
297
+ }
298
+
299
+ .rte-source-editor-spinner {
300
+ width: 32px;
301
+ height: 32px;
302
+ border: 3px solid #e1e5e9;
303
+ border-top: 3px solid #007acc;
304
+ border-radius: 50%;
305
+ animation: spin 1s linear infinite;
306
+ margin-bottom: 16px;
307
+ }
308
+
309
+ @keyframes spin {
310
+ 0% { transform: rotate(0deg); }
311
+ 100% { transform: rotate(360deg); }
312
+ }
313
+
314
+ .rte-source-editor-error {
315
+ background: #fee;
316
+ color: #c53030;
317
+ padding: 12px 16px;
318
+ border-left: 4px solid #c53030;
319
+ margin: 16px;
320
+ border-radius: 4px;
321
+ font-size: 14px;
322
+ }
323
+
324
+ .rte-source-editor-content {
325
+ flex: 1;
326
+ display: flex;
327
+ flex-direction: column;
328
+ overflow: hidden;
329
+ }
330
+
331
+ .rte-source-editor-warning {
332
+ background: #fefcbf;
333
+ color: #744210;
334
+ padding: 8px 16px;
335
+ font-size: 12px;
336
+ font-weight: 500;
337
+ border-bottom: 1px solid #f6e05e;
338
+ }
339
+
340
+ .rte-source-editor-codemirror {
341
+ flex: 1;
342
+ overflow: auto;
343
+ font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
344
+ font-size: 14px;
345
+ line-height: 1.5;
346
+ }
347
+
348
+ .rte-source-editor-codemirror .cm-editor {
349
+ height: 100%;
350
+ }
351
+
352
+ .rte-source-editor-codemirror .cm-focused {
353
+ outline: none;
354
+ }
355
+
356
+ .rte-source-editor-footer {
357
+ display: flex;
358
+ align-items: center;
359
+ justify-content: space-between;
360
+ padding: 16px 20px;
361
+ border-top: 1px solid #e1e5e9;
362
+ background: #f8f9fa;
363
+ border-radius: 0 0 8px 8px;
364
+ }
365
+
366
+ .rte-source-editor-overlay.fullscreen .rte-source-editor-footer {
367
+ border-radius: 0;
368
+ }
369
+
370
+ .rte-source-editor-footer-info {
371
+ font-size: 12px;
372
+ color: #666;
373
+ }
374
+
375
+ .unsaved-changes {
376
+ color: #d69e2e;
377
+ font-weight: 500;
378
+ }
379
+
380
+ .rte-source-editor-footer-actions {
381
+ display: flex;
382
+ gap: 12px;
383
+ }
384
+
385
+ .rte-source-editor-btn {
386
+ padding: 8px 16px;
387
+ border-radius: 4px;
388
+ font-size: 14px;
389
+ font-weight: 500;
390
+ cursor: pointer;
391
+ border: 1px solid transparent;
392
+ transition: all 0.2s ease;
393
+ }
394
+
395
+ .rte-source-editor-btn:disabled {
396
+ opacity: 0.6;
397
+ cursor: not-allowed;
398
+ }
399
+
400
+ .rte-source-editor-btn-cancel {
401
+ background: white;
402
+ border-color: #d1d5db;
403
+ color: #374151;
404
+ }
405
+
406
+ .rte-source-editor-btn-cancel:hover:not(:disabled) {
407
+ background: #f9fafb;
408
+ border-color: #9ca3af;
409
+ }
410
+
411
+ .rte-source-editor-btn-save {
412
+ background: #007acc;
413
+ color: white;
414
+ }
415
+
416
+ .rte-source-editor-btn-save:hover:not(:disabled) {
417
+ background: #0056b3;
418
+ }
419
+
420
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-modal {
421
+ background: #1e1e1e;
422
+ color: #f8f9fa;
423
+ border: 1px solid #434d5f;
424
+ }
425
+
426
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-header,
427
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-footer {
428
+ background: #2a3442;
429
+ border-color: #434d5f;
430
+ }
431
+
432
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-header h2 {
433
+ color: #f8f9fa;
434
+ }
435
+
436
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn,
437
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-fullscreen-btn,
438
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-close-btn {
439
+ color: #c1cede;
440
+ }
441
+
442
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn:hover:not(:disabled),
443
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-fullscreen-btn:hover,
444
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-close-btn:hover {
445
+ background: #404a5a;
446
+ color: #f8fafc;
447
+ }
448
+
449
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn.active {
450
+ background: #3b82f6;
451
+ color: #ffffff;
452
+ }
453
+
454
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-toolbar-btn.active:hover {
455
+ background: #2563eb;
456
+ }
457
+
458
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-loading,
459
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-footer-info {
460
+ color: #cbd5e1;
461
+ }
462
+
463
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-spinner {
464
+ border-color: #3f4b60;
465
+ border-top-color: #58a6ff;
466
+ }
467
+
468
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-error {
469
+ background: #3f2124;
470
+ color: #fecaca;
471
+ border-color: #ef4444;
472
+ }
473
+
474
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-warning {
475
+ background: #3b3220;
476
+ color: #fde68a;
477
+ border-color: #f59e0b;
478
+ }
479
+
480
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-cancel {
481
+ background: #334155;
482
+ border-color: #475569;
483
+ color: #f1f5f9;
484
+ }
485
+
486
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-cancel:hover:not(:disabled) {
487
+ background: #475569;
488
+ border-color: #64748b;
489
+ }
490
+
491
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-save {
492
+ background: #3b82f6;
493
+ }
494
+
495
+ .rte-source-editor-overlay.rte-theme-dark .rte-source-editor-btn-save:hover:not(:disabled) {
496
+ background: #2563eb;
497
+ }
498
+
499
+ /* Responsive design */
500
+ @media (max-width: 768px) {
501
+ .rte-source-editor-overlay {
502
+ padding: 10px;
503
+ }
504
+
505
+ .rte-source-editor-modal {
506
+ max-height: 95vh;
507
+ }
508
+
509
+ .rte-source-editor-header {
510
+ padding: 12px 16px;
511
+ }
512
+
513
+ .rte-source-editor-footer {
514
+ padding: 12px 16px;
515
+ flex-direction: column;
516
+ gap: 12px;
517
+ align-items: stretch;
518
+ }
519
+
520
+ .rte-source-editor-footer-actions {
521
+ justify-content: stretch;
522
+ }
523
+
524
+ .rte-source-editor-btn {
525
+ flex: 1;
526
+ text-align: center;
527
+ }
528
+ }`,W=()=>({name:"code",toolbar:[{label:"Source",command:"toggleSourceView",type:"button",icon:"<>",shortcut:"Mod-Shift-S"}],commands:{toggleSourceView:()=>{const e=(()=>{const r=window.getSelection();if(r&&r.anchorNode){let o=r.anchorNode instanceof HTMLElement?r.anchorNode:r.anchorNode.parentElement;for(;o;){if(o.classList?.contains("rte-content"))return o;o=o.parentElement}}if(document.activeElement){let o=document.activeElement;if(o.classList?.contains("rte-content"))return o;for(;o&&o!==document.body;){if(o.classList?.contains("rte-content"))return o;const a=o.querySelector(".rte-content");if(a)return a;o=o.parentElement}}const n=document.querySelector("[data-editora-editor]");if(n){const o=n.querySelector(".rte-content");if(o)return o}return document.querySelector(".rte-content")})();if(!e)return console.error("[CodePlugin] Editor content area not found"),alert("Editor content area not found. Please click inside the editor first."),!1;const t=e.innerHTML,s=r=>{let n="",o=0;const a=2,l=r.split(/(<\/?[a-zA-Z][^>]*>)/);for(const c of l)c.trim()&&(c.match(/^<\/[a-zA-Z]/)?(o=Math.max(0,o-1),n+=`
529
+ `+" ".repeat(o*a)+c):c.match(/^<[a-zA-Z]/)&&!c.match(/\/>$/)?(n+=`
530
+ `+" ".repeat(o*a)+c,o++):c.match(/^<[a-zA-Z].*\/>$/)?n+=`
531
+ `+" ".repeat(o*a)+c:n+=c.trim());return n.trim()};return(()=>{let r=null,n="dark",o=!1,a=!1,l=!1;const c=t,g=!!e.closest(O)||document.body.matches(O)||document.documentElement.matches(O),d=document.createElement("div");d.className="rte-source-editor-overlay",g&&d.classList.add("rte-theme-dark");const u=document.createElement("div");u.className="rte-source-editor-modal",u.setAttribute("role","dialog"),u.setAttribute("aria-modal","true"),u.setAttribute("aria-labelledby","source-editor-title");const h=document.createElement("div");h.className="rte-source-editor-header",h.innerHTML=`
532
+ <h2 id="source-editor-title">Source Editor</h2>
533
+ <div class="rte-source-editor-header-toolbar">
534
+ <button class="rte-source-editor-toolbar-btn theme-toggle-btn" title="Switch theme">
535
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
536
+ <circle cx="12" cy="12" r="5"/>
537
+ <line x1="12" y1="1" x2="12" y2="3"/>
538
+ <line x1="12" y1="21" x2="12" y2="23"/>
539
+ <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/>
540
+ <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/>
541
+ <line x1="1" y1="12" x2="3" y2="12"/>
542
+ <line x1="21" y1="12" x2="23" y2="12"/>
543
+ <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/>
544
+ <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>
545
+ </svg>
546
+ </button>
547
+ <button class="rte-source-editor-toolbar-btn readonly-toggle-btn" title="Toggle read-only">
548
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
549
+ <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
550
+ <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
551
+ </svg>
552
+ </button>
553
+ </div>
554
+ <div class="rte-source-editor-header-actions">
555
+ <button class="rte-source-editor-fullscreen-btn" title="Toggle fullscreen">
556
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
557
+ <path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/>
558
+ </svg>
559
+ </button>
560
+ <button class="rte-source-editor-close-btn" aria-label="Close source editor">
561
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
562
+ <line x1="18" y1="6" x2="6" y2="18"/>
563
+ <line x1="6" y1="6" x2="18" y2="18"/>
564
+ </svg>
565
+ </button>
566
+ </div>
567
+ `;const f=document.createElement("div");f.className="rte-source-editor-body";const m=document.createElement("div");m.className="rte-source-editor-content";const x=document.createElement("div");x.className="rte-source-editor-warning",x.textContent="⚠️ Advanced users only. Invalid HTML may break the editor.";const k=document.createElement("div");k.className="rte-source-editor-light-editor",k.style.height="400px",m.appendChild(x),m.appendChild(k),f.appendChild(m);const y=document.createElement("div");if(y.className="rte-source-editor-footer",y.innerHTML=`
568
+ <div class="rte-source-editor-footer-info">
569
+ <span class="unsaved-changes" style="display: none;">• Unsaved changes</span>
570
+ </div>
571
+ <div class="rte-source-editor-footer-actions">
572
+ <button class="rte-source-editor-btn rte-source-editor-btn-cancel">Cancel</button>
573
+ <button class="rte-source-editor-btn rte-source-editor-btn-save">Save</button>
574
+ </div>
575
+ `,u.appendChild(h),u.appendChild(f),u.appendChild(y),d.appendChild(u),!document.getElementById("rte-source-editor-styles")){const p=document.createElement("style");p.id="rte-source-editor-styles",p.textContent=D,document.head.appendChild(p)}document.body.appendChild(d);try{r=F(k,{value:s(t),theme:"dark",readOnly:!1,extensions:[new K,new A,new V,new z,new U,new q,new _]}),r.on("change",()=>{l=(r?.getValue()||"")!==s(c);const M=y.querySelector(".unsaved-changes");M&&(M.style.display=l?"inline":"none")}),setTimeout(()=>r?.focus(),100)}catch(p){console.error("Failed to initialize code editor:",p)}const C=()=>{n=n==="dark"?"light":"dark",r?.setTheme(n);const p=h.querySelector(".theme-toggle-btn");p&&n==="light"&&(p.innerHTML=`
576
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
577
+ <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>
578
+ </svg>
579
+ `)},L=()=>{o=!o,r?.setReadOnly(o);const p=h.querySelector(".readonly-toggle-btn");p&&(o?(p.classList.add("active"),p.innerHTML=`
580
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
581
+ <rect x="3" y="11" width="18" height="11" rx="2" ry="2"/>
582
+ <circle cx="12" cy="16" r="1"/>
583
+ <path d="M7 11V7a5 5 0 0 1 10 0v4"/>
584
+ </svg>
585
+ `):(p.classList.remove("active"),p.innerHTML=`
586
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
587
+ <path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/>
588
+ <path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/>
589
+ </svg>
590
+ `))},w=()=>{a=!a,a?(d.classList.add("fullscreen"),k.style.height="calc(100vh - 200px)"):(d.classList.remove("fullscreen"),k.style.height="400px");const p=h.querySelector(".rte-source-editor-fullscreen-btn");p&&(p.innerHTML=a?`
591
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
592
+ <path d="M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 0 2-2h3M3 16h3a2 2 0 0 0 2 2v3"/>
593
+ </svg>
594
+ `:`
595
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
596
+ <path d="M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7"/>
597
+ </svg>
598
+ `)},b=()=>{r&&(r.destroy(),r=null),document.body.removeChild(d)},T=()=>{l&&!confirm("You have unsaved changes. Are you sure you want to cancel?")||b()},S=()=>{try{const p=r?.getValue()||"",M=document.createElement("div");M.innerHTML=p,M.querySelectorAll('script, iframe[src^="javascript:"], object, embed').forEach(P=>P.remove()),e.innerHTML=M.innerHTML,l=!1,b()}catch(p){alert("Failed to update HTML. Please check your syntax."),console.error("HTML update error:",p)}};h.querySelector(".theme-toggle-btn")?.addEventListener("click",C),h.querySelector(".readonly-toggle-btn")?.addEventListener("click",L),h.querySelector(".rte-source-editor-fullscreen-btn")?.addEventListener("click",w),h.querySelector(".rte-source-editor-close-btn")?.addEventListener("click",b),y.querySelector(".rte-source-editor-btn-cancel")?.addEventListener("click",T),y.querySelector(".rte-source-editor-btn-save")?.addEventListener("click",S),d.addEventListener("click",p=>{p.target===d&&b()});const E=p=>{p.key==="Escape"&&(b(),document.removeEventListener("keydown",E))};document.addEventListener("keydown",E)})(),!0}},keymap:{"Mod-Shift-s":"toggleSourceView","Mod-Shift-S":"toggleSourceView"}});exports.CodePlugin=W;