@editora/core 1.0.10 → 1.0.11

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.
@@ -2321,7 +2321,7 @@ const rt = {
2321
2321
  clearFormatting: () => import("./ClearFormattingPlugin.native-DIS6AN2t.mjs").then((i) => i.ClearFormattingPlugin()),
2322
2322
  heading: () => import("./HeadingPlugin.native-DZdvubrQ.mjs").then((i) => i.HeadingPlugin()),
2323
2323
  blockquote: () => import("./BlockquotePlugin.native-57_Xcjl1.mjs").then((i) => i.BlockquotePlugin()),
2324
- code: () => import("./CodePlugin.native-C5l1IeSS.mjs").then((i) => i.CodePlugin()),
2324
+ code: () => import("./CodePlugin.native-veDC_kx5.mjs").then((i) => i.CodePlugin()),
2325
2325
  codeSample: () => import("./CodeSamplePlugin.native-CgGoH-X4.mjs").then((i) => i.CodeSamplePlugin()),
2326
2326
  list: () => import("./ListPlugin.native-V7EZC1lM.mjs").then((i) => i.ListPlugin()),
2327
2327
  checklist: () => import("./ChecklistPlugin.native-BS-kMz9O.mjs").then((i) => i.ChecklistPlugin()),
@@ -9,7 +9,7 @@
9
9
  `}),n}getShortcutCategory(e){return e.includes("toggle")&&(e.includes("Bold")||e.includes("Italic")||e.includes("Underline")||e.includes("Strike")||e.includes("Code")||e.includes("Super")||e.includes("Sub"))?"Text Formatting":e.includes("Heading")||e.includes("Paragraph")?"Block Formatting":e.includes("List")||e.includes("Checklist")?"Lists":e.includes("Alignment")||e.includes("Indent")?"Alignment & Indentation":e.includes("undo")||e.includes("redo")?"History":e.includes("insert")?"Insert":e.includes("find")||e.includes("replace")?"Find & Replace":e.includes("Accessibility")||e.includes("spell")?"Tools":"Other"}}const XV=["p","br","strong","em","u","s","strike","del","b","i","h1","h2","h3","h4","h5","h6","ul","ol","li","a","img","video","audio","iframe","table","thead","tbody","tr","th","td","blockquote","pre","code","span","div","section","sup","sub","hr"],YV={"*":["class","style","id","data-*","role","aria-*","tabindex","contenteditable","spellcheck","dir","lang"],a:["href","target","rel","title"],img:["src","alt","width","height","loading"],video:["src","controls","width","height","autoplay","loop","muted"],audio:["src","controls","autoplay","loop","muted"],iframe:["src","width","height","name","title","longdesc","allow","allowfullscreen","frameborder","scrolling","loading","referrerpolicy"],table:["border","cellpadding","cellspacing"],td:["colspan","rowspan","align","valign"],th:["colspan","rowspan","align","valign"]};function U6(t,e,r){if((e==null?void 0:e.sanitize)===!1)return t;const n=e!=null&&e.allowedTags&&e.allowedTags.length>0?e.allowedTags:XV,o=!!(e!=null&&e.allowedAttributes)&&Object.keys(e.allowedAttributes).length>0?e.allowedAttributes:YV,a=document.createElement("div");return a.innerHTML=t,I6(a,n,o),a.innerHTML}function I6(t,e,r){const n=Array.from(t.childNodes);for(const i of n)if(i.nodeType===Node.ELEMENT_NODE){const o=i,a=o.tagName.toLowerCase();if(!e.includes(a)){for(;o.firstChild;)t.insertBefore(o.firstChild,o);t.removeChild(o);continue}ZV(o,r),I6(o,e,r)}else i.nodeType!==Node.TEXT_NODE&&t.removeChild(i)}function ZV(t,e){const r=t.tagName.toLowerCase(),n=Array.from(t.attributes),i=e[r]||[],o=e["*"]||[],a=[...i,...o];for(const s of n){const c=s.name.toLowerCase();let l=!1;a.includes(c)&&(l=!0);for(const u of a)if(u.endsWith("*")){const d=u.slice(0,-1);if(c.startsWith(d)){l=!0;break}}(c.startsWith("on")||c==="javascript:"||c==="href"&&s.value.trim().toLowerCase().startsWith("javascript:")||c==="src"&&s.value.trim().toLowerCase().startsWith("javascript:"))&&(l=!1),c==="dir"&&!["ltr","rtl","auto"].includes(s.value.trim().toLowerCase())&&(l=!1),l||t.removeAttribute(s.name)}t.hasAttribute("href")&&(t.getAttribute("href")||"").trim().toLowerCase().startsWith("javascript:")&&t.removeAttribute("href"),t.hasAttribute("src")&&(t.getAttribute("src")||"").trim().toLowerCase().startsWith("javascript:")&&t.removeAttribute("src")}function JV(t,e,r){return(r==null?void 0:r.sanitizeOnPaste)===!1?t:U6(t,e)}function eG(t,e,r){return(r==null?void 0:r.sanitizeOnInput)===!1?t:U6(t,e)}const c6=class c6{static resolve(e){const r={};if(Object.assign(r,this.EDITOR_DEFAULTS),e.pluginDefaults&&Object.assign(r,e.pluginDefaults),e.attributes){const n=this.parseAttributes(e.attributes);Object.assign(r,n)}return e.jsConfig&&Object.assign(r,e.jsConfig),this.normalizeConfig(r)}static normalizeConfig(e){const r={...e};if(r.toolbarFloating!==void 0||r.toolbarSticky!==void 0){const a=typeof r.toolbar=="object"&&r.toolbar?{...r.toolbar}:typeof r.toolbar=="string"?{items:r.toolbar}:{};r.toolbarFloating!==void 0&&(a.floating=!!r.toolbarFloating),r.toolbarSticky!==void 0&&(a.sticky=!!r.toolbarSticky),r.toolbar=a}if(r.toolbarItems!==void 0&&typeof r.toolbar=="object"&&r.toolbar&&(r.toolbar.items=r.toolbarItems),r.autosaveEnabled!==void 0||r.autosaveIntervalMs!==void 0||r.autosaveStorageKey!==void 0||r.autosaveProvider!==void 0||r.autosaveApiUrl!==void 0){const a=typeof r.autosave=="object"&&r.autosave?{...r.autosave}:{};r.autosaveEnabled!==void 0&&(a.enabled=!!r.autosaveEnabled),r.autosaveIntervalMs!==void 0&&(a.intervalMs=Number(r.autosaveIntervalMs)),r.autosaveStorageKey!==void 0&&(a.storageKey=r.autosaveStorageKey),r.autosaveProvider!==void 0&&(a.provider=r.autosaveProvider),r.autosaveApiUrl!==void 0&&(a.apiUrl=r.autosaveApiUrl),r.autosave=a}const n={enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage",apiUrl:""};if(typeof r.autosave=="boolean")r.autosave={...n,enabled:r.autosave};else if(typeof r.autosave=="object"&&r.autosave){const a={...n,...r.autosave};a.intervalMs===void 0&&a.interval!==void 0&&(a.intervalMs=Number(a.interval)),a.enabled===void 0&&(a.enabled=!0),(!Number.isFinite(a.intervalMs)||a.intervalMs<=0)&&(a.intervalMs=n.intervalMs),r.autosave=a}else r.autosave=n;if(r.languageLocale!==void 0||r.languageDirection!==void 0){const a=typeof r.language=="object"&&r.language?{...r.language}:{};r.languageLocale!==void 0&&(a.locale=r.languageLocale),r.languageDirection!==void 0&&(a.direction=r.languageDirection),r.language=a}const i={locale:"en",direction:"ltr"};if(typeof r.language=="string"?r.language={locale:r.language,direction:i.direction}:typeof r.language=="object"&&r.language?r.language={...i,...r.language}:r.language=i,r.spellcheckEnabled!==void 0||r.spellcheckProvider!==void 0||r.spellcheckApiUrl!==void 0){const a=typeof r.spellcheck=="object"&&r.spellcheck?{...r.spellcheck}:{};r.spellcheckEnabled!==void 0&&(a.enabled=!!r.spellcheckEnabled),r.spellcheckProvider!==void 0&&(a.provider=r.spellcheckProvider),r.spellcheckApiUrl!==void 0&&(a.apiUrl=r.spellcheckApiUrl),r.spellcheck=a}const o={enabled:!1,provider:"browser",apiUrl:""};if(typeof r.spellcheck=="boolean")r.spellcheck={...o,enabled:r.spellcheck};else if(typeof r.spellcheck=="object"&&r.spellcheck){const a={...o,...r.spellcheck};!a.provider&&a.mode&&(a.provider=a.mode==="local"?"browser":"api"),a.enabled===void 0&&(a.enabled=!!(a.mode||a.provider||a.apiUrl)),r.spellcheck=a}else r.spellcheck=o;return r.contextMenuEnabled!==void 0&&(r.contextMenu={enabled:!!r.contextMenuEnabled}),typeof r.contextMenu=="boolean"?r.contextMenu={enabled:r.contextMenu}:typeof r.contextMenu=="object"&&r.contextMenu?r.contextMenu={enabled:r.contextMenu.enabled!==!1}:r.contextMenu={enabled:!0},(r.pasteClean!==void 0||r.pasteKeepFormatting!==void 0||r.pasteConvertWord!==void 0)&&(r.paste={...r.paste||{},...r.pasteClean!==void 0?{clean:!!r.pasteClean}:{},...r.pasteKeepFormatting!==void 0?{keepFormatting:!!r.pasteKeepFormatting}:{},...r.pasteConvertWord!==void 0?{convertWord:!!r.pasteConvertWord}:{}}),r.paste={clean:!0,keepFormatting:!1,convertWord:!0,...r.paste||{}},r.contentConfig={allowedTags:[],allowedAttributes:{},sanitize:!0,...r.contentConfig||{}},(r.securitySanitizeOnPaste!==void 0||r.securitySanitizeOnInput!==void 0)&&(r.security={...r.security||{},...r.securitySanitizeOnPaste!==void 0?{sanitizeOnPaste:!!r.securitySanitizeOnPaste}:{},...r.securitySanitizeOnInput!==void 0?{sanitizeOnInput:!!r.securitySanitizeOnInput}:{}}),r.security={sanitizeOnPaste:!0,sanitizeOnInput:!0,...r.security||{}},(r.accessibilityEnableAria!==void 0||r.accessibilityKeyboardNavigation!==void 0||r.accessibilityChecker!==void 0)&&(r.accessibility={...r.accessibility||{},...r.accessibilityEnableAria!==void 0?{enableARIA:!!r.accessibilityEnableAria}:{},...r.accessibilityKeyboardNavigation!==void 0?{keyboardNavigation:!!r.accessibilityKeyboardNavigation}:{},...r.accessibilityChecker!==void 0?{checker:!!r.accessibilityChecker}:{}}),typeof r.accessibility=="boolean"&&(r.accessibility={enableARIA:r.accessibility,keyboardNavigation:r.accessibility,checker:!1}),r.accessibility={enableARIA:!0,keyboardNavigation:!0,checker:!1,...r.accessibility||{}},(r.performanceDebounceInputMs!==void 0||r.performanceViewportOnlyScan!==void 0)&&(r.performance={...r.performance||{},...r.performanceDebounceInputMs!==void 0?{debounceInputMs:Number(r.performanceDebounceInputMs)}:{},...r.performanceViewportOnlyScan!==void 0?{viewportOnlyScan:!!r.performanceViewportOnlyScan}:{}}),typeof r.performance=="boolean"&&(r.performance={debounceInputMs:100,viewportOnlyScan:r.performance}),r.performance={debounceInputMs:100,viewportOnlyScan:!0,...r.performance||{}},(typeof r.performance.debounceInputMs!="number"||!Number.isFinite(r.performance.debounceInputMs)||r.performance.debounceInputMs<0)&&(r.performance.debounceInputMs=100),r}static parseAttributes(e){const r={};for(const[n,i]of Object.entries(e)){const o=this.kebabToCamel(n);r[o]=this.parseAttributeValue(i)}return r}static parseAttributeValue(e){if(e==="true")return!0;if(e==="false")return!1;if(/^\d+$/.test(e))return parseInt(e,10);if(/^\d+\.\d+$/.test(e))return parseFloat(e);if(e.startsWith("{")||e.startsWith("["))try{return JSON.parse(e)}catch(r){return e}return e}static kebabToCamel(e){return e.replace(/-([a-z])/g,(r,n)=>n.toUpperCase())}static validate(e){const r=[];return e.height!==void 0&&typeof e.height=="number"&&e.height<0&&r.push("height must be a positive number"),e.width!==void 0&&typeof e.width=="number"&&e.width<0&&r.push("width must be a positive number"),e.plugins!==void 0&&!Array.isArray(e.plugins)&&typeof e.plugins!="string"&&r.push("plugins must be an array or string"),e.theme!==void 0&&typeof e.theme!="string"&&r.push("theme must be a string"),{valid:r.length===0,errors:r}}static getDefaults(){return{...this.EDITOR_DEFAULTS}}static merge(...e){const r={};for(const n of e)for(const[i,o]of Object.entries(n))o!=null&&(typeof o=="object"&&!Array.isArray(o)&&r[i]?r[i]=this.merge(r[i],o):r[i]=o);return r}};c6.EDITOR_DEFAULTS={height:400,width:"100%",readonly:!1,disabled:!1,menubar:!0,toolbar:!0,plugins:[],theme:"light",content:"",placeholder:"Start typing...",autofocus:!1,autosave:!1,accessibility:{enableARIA:!0,keyboardNavigation:!0,checker:!1},performance:{debounceInputMs:100,viewportOnlyScan:!0},spellcheck:{enabled:!1,provider:"browser",apiUrl:""},language:{locale:"en",direction:"ltr"},contextMenu:{enabled:!0},contentConfig:{allowedTags:[],allowedAttributes:{},sanitize:!0},paste:{clean:!0,keepFormatting:!1,convertWord:!0},security:{sanitizeOnPaste:!0,sanitizeOnInput:!0},statusbar:!1};let hE=c6;const tG='.editora-editor{display:flex;flex-direction:column;border:1px solid #ddd;border-radius:4px;background:#fff;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,sans-serif;font-size:14px;overflow:hidden}.editora-editor *{box-sizing:border-box}.editora-theme-light{background:#fff;color:#333}.editora-theme-dark{--editora-dark-toolbar-bg-start: #353d48;--editora-dark-toolbar-bg-end: #2d3540;--editora-dark-button-bg-start: #46505f;--editora-dark-button-bg-end: #3b4553;--editora-dark-button-hover-start: #525d6d;--editora-dark-button-hover-end: #465262;--editora-dark-button-active-start: #5eaaf6;--editora-dark-button-active-end: #4a95de;--editora-dark-border: #475263;--editora-dark-border-strong: #566275;--editora-dark-text: #e1e9f5;--editora-dark-text-strong: #f3f7ff;--editora-dark-text-muted: #aeb9cc;--editora-dark-surface: #1d242d;--editora-dark-content: #1f2732;background:linear-gradient(180deg,#1b2330,#1c2430);color:var(--editora-dark-text);border-color:var(--editora-dark-border)}.editora-toolbar{display:flex;align-items:center;gap:4px;padding:8px;background:#f5f5f5;border-bottom:1px solid #ddd;flex-wrap:wrap}.editora-theme-dark .editora-toolbar{background:linear-gradient(180deg,var(--editora-dark-toolbar-bg-start) 0%,var(--editora-dark-toolbar-bg-end) 100%);border-bottom-color:var(--editora-dark-border);box-shadow:inset 0 1px #ffffff0d}.editora-toolbar-sticky{position:sticky;top:0;z-index:100;position:-webkit-sticky}.editora-toolbar-group{display:flex;align-items:center;gap:2px}.editora-toolbar-button{padding:6px 12px;border:1px solid #ccc;background:#fff;cursor:pointer;border-radius:3px;font-weight:600;font-size:14px;height:30px;display:flex;align-items:center;white-space:nowrap}.editora-toolbar-group-button{display:flex;align-items:center}.editora-toolbar-input.font-size{width:40px;padding:.25rem;text-align:center;font-size:14px;background:#fff;border:1px solid var(--rte-color-border-light);border-radius:var(--rte-radius-sm)}.editora-toolbar-group-items{display:flex;align-items:center;border:1px solid #ccc;.editora-toolbar-button{border:none;border-radius:0;&:first-child{border-right:1px solid #ccc;border-top-left-radius:3px;border-bottom-left-radius:3px}&:last-child{border:0px solid #ccc;border-radius:0!important}&:hover{background:#e0e0e0;border-color:#ccc}}}.editora-theme-dark .editora-toolbar-button{background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%);border-color:var(--editora-dark-border-strong);color:var(--editora-dark-text);box-shadow:inset 0 1px #ffffff14,0 1px 1px #00000059}.editora-theme-dark .editora-toolbar-group-items{border-color:var(--editora-dark-border-strong);background:linear-gradient(180deg,var(--editora-dark-button-bg-start) 0%,var(--editora-dark-button-bg-end) 100%)}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:first-child{border-right-color:#566275}.editora-theme-dark .editora-toolbar-group-items .editora-toolbar-button:last-child{border-left-color:#566275}.editora-theme-dark .editora-toolbar-input.font-size{background-color:#2e3642;color:var(--editora-dark-text-strong);border-color:var(--editora-dark-border-strong);caret-color:var(--editora-dark-text-strong)}.editora-theme-dark .editora-toolbar-input.font-size::placeholder{color:var(--editora-dark-text-strong);opacity:1}.editora-toolbar-button:hover{background:#e0e0e0;border-color:#ccc}.editora-theme-dark .editora-toolbar-button:hover{background:linear-gradient(180deg,var(--editora-dark-button-hover-start) 0%,var(--editora-dark-button-hover-end) 100%);border-color:#66748a;color:var(--editora-dark-text-strong)}.editora-toolbar-button:active,.editora-toolbar-button.active{background:#d0d0d0;border-color:#999}.editora-theme-dark .editora-toolbar-button:active,.editora-theme-dark .editora-toolbar-button.active{background:linear-gradient(180deg,var(--editora-dark-button-active-start) 0%,var(--editora-dark-button-active-end) 100%);border-color:#67adf4;color:#0f1b2a}.editora-theme-dark .editora-toolbar-button:disabled{background:#313946;border-color:#424d5e;color:#7f8ca1}.editora-theme-dark .editora-toolbar-button[data-command=insertTable],.editora-theme-dark .editora-toolbar-button[data-command=print],.editora-theme-dark .editora-toolbar-button[data-command=toggleSpellCheck],.editora-theme-dark .editora-toolbar-button[data-command=toggleA11yChecker],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionLTR],.editora-theme-dark .editora-toolbar-button[data-command=setDirectionRTL]{color:#f1f6ff}.editora-toolbar-button:disabled{opacity:.5;cursor:not-allowed}.editora-toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;line-height:1}.editora-toolbar-button svg,.editora-toolbar-icon svg{width:20px;height:20px;display:block;color:currentColor;fill:currentColor}.editora-theme-dark .editora-toolbar-icon,.editora-theme-dark .editora-toolbar-icon *{color:inherit}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([stroke="#000" i],[stroke="#000000" i],[stroke=black i],[stroke="#0f0f0f" i],[stroke="#111111" i],[style*="stroke:#000" i],[style*="stroke: #000" i],[style*="stroke:black" i],[style*="stroke: black" i],[style*="stroke:#0f0f0f" i],[style*="stroke: #0f0f0f" i]){stroke:currentColor!important}.editora-theme-dark :is(.editora-toolbar-button,.editora-toolbar-icon) svg :is([fill="#000" i],[fill="#000000" i],[fill=black i],[fill="#0f0f0f" i],[fill="#111111" i],[style*="fill:#000" i],[style*="fill: #000" i],[style*="fill:black" i],[style*="fill: black" i],[style*="fill:#0f0f0f" i],[style*="fill: #0f0f0f" i]){fill:currentColor!important}.editora-toolbar-separator{width:1px;height:24px;background:#ddd;margin:0 4px}.editora-theme-dark .editora-toolbar-separator{background:#4d596b}.editora-toolbar-dropdown{position:relative}.editora-toolbar-dropdown-menu{position:absolute;top:100%;left:0;min-width:150px;margin-top:4px;padding:4px 0;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-toolbar-dropdown-menu{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;color:#333;text-align:left;cursor:pointer;font-size:13px;transition:background .15s ease}.editora-theme-dark .editora-toolbar-dropdown-item{color:#d7deea}.editora-toolbar-dropdown-item:hover{background:#f5f5f5}.editora-theme-dark .editora-toolbar-dropdown-item:hover{background:#3a4554;color:#f0f6ff}.editora-content{flex:1;min-height:200px;padding:16px;outline:none;overflow-y:auto;line-height:1.6}.editora-theme-dark .editora-content{color:#ecf3ff;background:linear-gradient(180deg,var(--editora-dark-content) 0%,#1c232e 100%)}.editora-content:empty:before{content:attr(data-placeholder);color:#999;pointer-events:none}.editora-theme-dark .editora-content:empty:before{color:#8f9bb0}.editora-content h1{font-size:2em;margin:.67em 0;font-weight:600}.editora-content h2{font-size:1.5em;margin:.75em 0;font-weight:600}.editora-content h3{font-size:1.17em;margin:.83em 0;font-weight:600}.editora-content p{margin:1em 0}.editora-theme-dark .editora-content,.editora-theme-dark .editora-content :is(p,span,div,li,ul,ol,td,th,h1,h2,h3,h4,h5,h6,strong,em,u,s,small,sub,sup,blockquote,code,pre,a){color:#ecf3ff}.editora-content ul,.editora-content ol{margin:1em 0;padding-left:2em}.editora-content a{color:#06c;text-decoration:underline}.editora-theme-dark .editora-content a{color:#ecf3ff}.editora-content code{padding:2px 4px;background:#f5f5f5;border-radius:3px;font-family:Monaco,Menlo,Consolas,monospace;font-size:.9em}.editora-theme-dark .editora-content code{background:#1e1e1e}.editora-content pre{padding:12px;background:#f5f5f5;border-radius:4px;overflow-x:auto;margin:1em 0}.editora-theme-dark .editora-content pre{background:#1e1e1e}.editora-theme-dark .rte-code-block{background:linear-gradient(180deg,#212a36,#1b2430)!important;border-color:#4f5b70!important;color:#e7effc!important}.editora-theme-dark .rte-code-block code{color:#e7effc!important}.editora-theme-dark .rte-code-block:before{background:#111927!important;color:#dce8ff!important}.editora-theme-dark .rte-code-block .rte-code-copy{background:#2b3441!important;border-color:#5a667b!important;color:#dce8ff!important}.editora-content blockquote{margin:1em 0;padding-left:1em;border-left:4px solid #ddd;color:#666}.editora-theme-dark .editora-content blockquote{border-left-color:#3c3c3c;color:#ecf3ff}.editora-floating-toolbar{position:absolute;padding:4px;background:#fff;border:1px solid #ddd;border-radius:4px;box-shadow:0 2px 8px #00000026;z-index:1000}.editora-theme-dark .editora-floating-toolbar{background:#29323d;border-color:#4d596b;box-shadow:0 8px 20px #00000073}.editora-statusbar-container{display:flex;flex-direction:column}.editora-statusbar-left{display:flex;align-items:center;gap:8px}.editora-statusbar-right{display:flex;align-items:center;gap:8px;margin-left:auto}.editora-statusbar{display:flex;align-items:center;gap:12px;padding:6px 12px;background:#f5f5f5;border-top:1px solid #ddd;font-size:12px;color:#666}.editora-theme-dark .editora-statusbar{background:linear-gradient(180deg,#2c3440,#252d37);border-top-color:#3f4a5b;color:#d7deea}.editora-statusbar-item{white-space:nowrap}.editora-statusbar-separator{color:#ddd}.editora-theme-dark .editora-statusbar-separator{color:#566275}.editora-editor[readonly] .editora-content{background:#fafafa;cursor:not-allowed}.editora-theme-dark.editora-editor[readonly] .editora-content{background:#1a1a1a}.editora-editor:focus-within{border-color:#06c;box-shadow:0 0 0 3px #0066cc1a}.editora-theme-dark.editora-editor:focus-within{border-color:#4db8ff;box-shadow:0 0 0 3px #4db8ff1a}.editora-editor[disabled]{opacity:.6;pointer-events:none}@media(max-width:768px){.editora-toolbar{padding:4px}.editora-toolbar-button{min-width:28px;min-height:28px;padding:4px 8px;font-size:12px}.editora-content{padding:12px}}.editora-content ::selection{background:#06c3}.editora-theme-dark .editora-content ::selection{background:#4db8ff33}.editora-content table{border-collapse:collapse;width:100%;margin:1em 0}.editora-content th,.editora-content td{border:1px solid #ddd;padding:8px 12px;text-align:left}.editora-theme-dark .editora-content th,.editora-theme-dark .editora-content td{border-color:#3c3c3c}.editora-content th{background:#f5f5f5;font-weight:600}.editora-theme-dark .editora-content th{background:#252526}.editora-content img{max-width:100%;height:auto;border-radius:4px;display:block}.editora-content video{max-width:100%;height:auto;border-radius:4px;display:block}.editora-editor.loading{opacity:.7;pointer-events:none}.editora-editor.loading:after{content:"";position:absolute;top:50%;left:50%;width:24px;height:24px;margin:-12px 0 0 -12px;border:3px solid #ddd;border-top-color:#06c;border-radius:50%;animation:editora-spin .8s linear infinite}@keyframes editora-spin{to{transform:rotate(360deg)}}.toolbar-container-wrapper{display:flex;align-items:center;background:#fff;border-bottom:1px solid #e0e0e0;padding:0;margin:0;width:100%;box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-size:14px;line-height:1.5;position:relative}.toolbar-container-wrapper[data-toolbar-sticky=true]{position:sticky;top:0;z-index:999;box-shadow:0 2px 4px #0000001a}.toolbar-container-wrapper[data-toolbar-floating=true]{position:fixed;top:0;left:0;right:0;z-index:1000;box-shadow:0 4px 12px #00000026}.toolbar-container-wrapper[data-toolbar-position=bottom]{border-bottom:none;border-top:1px solid #e0e0e0}.toolbar-container-wrapper .toolbar-wrapper{display:flex;width:100%;padding:8px;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar{display:flex;width:100%;gap:4px;flex-wrap:wrap;align-items:center}.toolbar-container-wrapper .toolbar-container{display:flex;gap:4px;flex-wrap:wrap;align-items:center;flex:1;position:relative}.toolbar-container-wrapper .toolbar-item{display:flex;align-items:center;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:6px 10px;border:1px solid #d1d5db;background:#fff;border-radius:4px;cursor:pointer;font-size:13px;display:flex;align-items:center;justify-content:center;gap:4px;transition:all .15s ease;min-height:32px;white-space:nowrap}.toolbar-container-wrapper .toolbar-button:hover{background-color:#f3f4f6;border-color:#9ca3af}.toolbar-container-wrapper .toolbar-button:active,.toolbar-container-wrapper .toolbar-button[data-active=true]{background-color:#06c;color:#fff;border-color:#0052a3;box-shadow:inset 0 1px 3px #0000001a}.toolbar-container-wrapper .toolbar-button:disabled{opacity:.5;cursor:not-allowed;background-color:#f9fafb}.toolbar-container-wrapper .toolbar-more-button{padding:6px 8px;font-size:16px;font-weight:500;line-height:1}.toolbar-container-wrapper .toolbar-separator{width:1px;height:24px;background-color:#d1d5db;margin:0 4px}.toolbar-container-wrapper .toolbar-icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;flex-shrink:0}.toolbar-container-wrapper .toolbar-icon svg{width:100%;height:100%}.toolbar-container-wrapper .toolbar-dropdown{position:relative;display:flex;align-items:center}.toolbar-container-wrapper .toolbar-dropdown-arrow{font-size:10px;margin-left:2px;line-height:1}.toolbar-container-wrapper .toolbar-dropdown-menu{position:absolute;top:100%;left:0;background:#fff;border:1px solid #d1d5db;border-radius:6px;box-shadow:0 4px 12px #00000026;z-index:1000;min-width:160px;padding:4px 0;margin-top:4px;display:none}.toolbar-container-wrapper .toolbar-dropdown-menu.show{display:block}.toolbar-container-wrapper .toolbar-dropdown-item{display:block;width:100%;padding:8px 12px;border:none;background:transparent;text-align:left;cursor:pointer;font-size:13px;color:#1f2937;transition:background-color .15s ease;font-family:inherit}.toolbar-container-wrapper .toolbar-dropdown-item:hover{background-color:#f3f4f6}.toolbar-container-wrapper .toolbar-dropdown-item:active{background-color:#e5e7eb}.toolbar-container-wrapper .toolbar-input{padding:6px 8px;border:1px solid #d1d5db;border-radius:4px;font-size:13px;font-family:inherit;background-color:#fff;color:#1f2937;transition:all .15s ease}.toolbar-container-wrapper .toolbar-input:focus{outline:none;border-color:#06c;box-shadow:0 0 0 3px #0066cc1a;background-color:#fff}.toolbar-container-wrapper .toolbar-input::placeholder{color:#9ca3af}.toolbar-overflow-menu{animation:slideDown .2s ease-out}@keyframes slideDown{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}.toolbar-overflow-item{transition:background-color .15s ease}.floating-toolbar{user-select:none;-webkit-user-select:none;font-family:system-ui,-apple-system,sans-serif;font-size:14px;animation:fadeInUp .15s ease-out}@keyframes fadeInUp{0%{opacity:0;transform:translate(-50%) translateY(10px)}to{opacity:1;transform:translate(-50%) translateY(0)}}.floating-toolbar-btn{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border:none;background:transparent;border-radius:4px;color:#495057;cursor:pointer;font-size:14px;font-weight:500;transition:all .15s ease;outline:none}.floating-toolbar-btn:hover{background:#f8f9fa;color:#212529}.floating-toolbar-btn:active{background:#e9ecef;transform:scale(.95)}.floating-toolbar-btn.floating-toolbar-toggle{color:#dc3545;font-weight:700}.floating-toolbar-btn.floating-toolbar-toggle:hover{background:#f8d7da;color:#721c24}.floating-toolbar-separator{width:1px;height:20px;background:#e1e5e9;margin:0 2px}@media(max-width:768px){.toolbar-container-wrapper .toolbar-button{padding:5px 8px;font-size:12px;min-height:28px}.toolbar-container-wrapper .toolbar-icon{width:16px;height:16px}.toolbar-container-wrapper .toolbar-dropdown-menu{min-width:140px}.toolbar-container-wrapper .toolbar-dropdown-item{padding:6px 10px;font-size:12px}.floating-toolbar{padding:4px;gap:2px}.floating-toolbar-btn{width:28px;height:28px;font-size:12px}}@media(max-width:480px){.toolbar-container-wrapper{padding:4px}.toolbar-container-wrapper .toolbar-wrapper{padding:4px;gap:2px}.toolbar-container-wrapper .toolbar-button{padding:4px 6px;font-size:11px;min-height:24px}.toolbar-container-wrapper .toolbar-icon{width:14px;height:14px}}.floating-toolbar{pointer-events:auto}.floating-toolbar{max-width:calc(100vw - 20px);overflow-x:auto}@media(prefers-color-scheme:dark){.floating-toolbar{background:#2d3748;border-color:#4a5568;color:#e2e8f0}.floating-toolbar-btn:hover{background:#4a5568;color:#f7fafc}.floating-toolbar-btn:active{background:#718096}.floating-toolbar-separator{background:#4a5568}}';let J1;const rG="__editoraCommandEditorRoot",nG="__editoraLastCommandButton",N6="editora-editor, [data-editora-editor], .rte-editor, .editora-editor",R6=".rte-content, .editora-content",pE=new Set;let Yl=null,O6=!1,gE=null,mE=null;function M6(t){if(!(t instanceof HTMLElement))return!1;const e=t;return typeof e.execCommand=="function"&&(e.tagName.toLowerCase()==="editora-editor"||e.classList.contains("editora-editor")||e.hasAttribute("data-editora-editor"))}function iG(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function gg(t){if(!t)return null;if(M6(t))return t;const e=t.matches(N6)?t:t.closest(N6);return!e||!M6(e)?null:e}function oG(){var i;if(typeof window=="undefined")return null;const t=window[rG];if(t instanceof HTMLElement){const o=gg(t);if(o)return o;const a=t.matches(R6)?t:t.querySelector(R6);if(a){const s=gg(a);if(s)return s}}const e=window[nG];if(e instanceof HTMLElement){const o=gg(e);if(o)return o}const r=document.activeElement;if(r){const o=gg(r);if(o)return o}const n=(i=window.getSelection)==null?void 0:i.call(window);if(n&&n.rangeCount>0){const o=gg(iG(n.getRangeAt(0).startContainer));if(o)return o}if(Yl&&Yl.isConnected)return Yl;for(const o of pE)if(o.isConnected)return o;return null}function aG(){if(typeof window=="undefined"||O6)return;gE=typeof window.executeEditorCommand=="function"?window.executeEditorCommand.bind(window):null,mE=typeof window.execEditorCommand=="function"?window.execEditorCommand.bind(window):null;const t=(e,r)=>{const n=oG();return n?n.execCommand(e,r):gE?gE(e,r):mE?mE(e,r):!1};window.executeEditorCommand=t,window.execEditorCommand=t,O6=!0}function sG(){const t="editora-webcomponent-styles";if(!document.getElementById(t)){const e=document.createElement("style");e.id=t,e.textContent=tG,document.head.appendChild(e)}}function cG(){if(!J1){const t=ha.__globalPluginLoader;t?J1=t:J1=new F6}return J1}class ha extends HTMLElement{constructor(){if(super(),this.pluginLoader=cG(),this.config={},this.isInitialized=!1,this.keyboardShortcutManager=new GV,this.lastAutosavedContent="",this.loadedPlugins=[],this.lastBeforeInputType=null,sG(),!this.hasAttribute("data-initial-content")){const e=this.innerHTML.trim();e&&this.setAttribute("data-initial-content",e)}}static get observedAttributes(){return["height","width","menubar","plugins","toolbar","toolbar-items","toolbar-floating","toolbar-sticky","readonly","disabled","theme","placeholder","autofocus","autosave","autosave-enabled","autosave-interval-ms","autosave-storage-key","autosave-provider","autosave-api-url","accessibility","accessibility-enable-aria","accessibility-keyboard-navigation","accessibility-checker","performance","performance-debounce-input-ms","performance-viewport-only-scan","language","language-locale","language-direction","spellcheck","spellcheck-enabled","spellcheck-provider","context-menu","context-menu-enabled","paste","paste-clean","paste-keep-formatting","paste-convert-word","security","security-sanitize-on-paste","security-sanitize-on-input","statusbar"]}connectedCallback(){this.config=this.resolveConfig(),this.waitForPluginLoader().then(()=>{setTimeout(async()=>{await this.initialize()},0)})}async waitForPluginLoader(){if(ha.__globalPluginLoader){this.pluginLoader=ha.__globalPluginLoader;return}return new Promise(e=>{const r=()=>{ha.__globalPluginLoader?(this.pluginLoader=ha.__globalPluginLoader,e()):setTimeout(r,0)};r()})}disconnectedCallback(){this.destroy()}attributeChangedCallback(e,r,n){r!==n&&(this.config=this.resolveConfig(),this.handleAttributeChange(e,n))}async setConfig(e){this.jsConfig=e,this.config=this.resolveConfig(),this.isConnected&&(this.destroy(),await this.waitForPluginLoader(),await this.initialize())}async initialize(){var n;if(this.querySelector(".editora-toolbar")||this.isInitialized)return;this.setAttribute("data-editora-editor","true"),pE.add(this),Yl||(Yl=this),aG(),this.config.height&&(this.style.height=typeof this.config.height=="number"?`${this.config.height}px`:this.config.height),this.config.width&&(this.style.width=typeof this.config.width=="number"?`${this.config.width}px`:this.config.width),this.classList.add("editora-editor"),this.config.theme&&this.classList.add(`editora-theme-${this.config.theme}`);const e=await this.loadPlugins();this.loadedPlugins=e,e.forEach(i=>{if(i.init&&typeof i.init=="function")try{i.init({editorElement:this})}catch(o){console.error(`[RichTextEditor] Error initializing plugin ${i.name}:`,o)}});const r=(n=this.restoreAutosavedContent())!=null?n:this.getAttribute("data-initial-content")||"";this.engine=new HV({content:r,plugins:e,readonly:this.config.readonly}),this.createUI(e,r),this.setupEventListeners(),this.startAutosave(),this.isInitialized=!0,this.dispatchEvent(new CustomEvent("editor-ready",{detail:{api:this.getAPI()},bubbles:!0}))}getInitialContent(){if(this.config.content)return this.config.content;const e=this.querySelector("[slot]");return e?e.innerHTML:this.hasChildNodes()?Array.from(this.childNodes).map(n=>n.nodeType===Node.TEXT_NODE?n.textContent:n.nodeType===Node.ELEMENT_NODE?n.outerHTML:"").join("").trim():""}async loadPlugins(){this.pluginLoader||await this.waitForPluginLoader();const e=[],r=this.config.plugins&&(typeof this.config.plugins=="string"&&this.config.plugins.length>0||Array.isArray(this.config.plugins)&&this.config.plugins.length>0),i=this.getAccessibilityConfig().checker===!0;if(r){if(typeof this.config.plugins=="string"){const o=this.config.plugins.split(/\s+/).filter(Boolean);i&&!o.includes("a11yChecker")&&o.push("a11yChecker");for(const a of o){const s=await this.pluginLoader.load(a,this.getPluginLoadConfig(a));s&&e.push(s)}}else if(Array.isArray(this.config.plugins)){for(const o of this.config.plugins)if(typeof o=="string"){const a=await this.pluginLoader.load(o,this.getPluginLoadConfig(o));a&&e.push(a)}else e.push(o);if(i&&!e.some(o=>(o==null?void 0:o.name)==="a11yChecker")){const o=await this.pluginLoader.load("a11yChecker",this.getPluginLoadConfig("a11yChecker"));o&&e.push(o)}}}else{const o=this.pluginLoader.getRegisteredPluginNames();for(const a of o){const s=await this.pluginLoader.load(a,this.getPluginLoadConfig(a));s&&e.push(s)}}return e}resolveToolbarItems(){const e=this.config.toolbarItems;if(typeof e=="string")return e;if(Array.isArray(e))return e.join(" ");const r=this.config.toolbar;if(typeof r=="string")return r;if(!r||typeof r!="object")return;const n=r.items;if(typeof n=="string")return n;if(Array.isArray(n))return n.join(" ")}isToolbarStickyEnabled(){const e=this.config.toolbar;return!e||typeof e!="object"?!1:!!e.sticky}isToolbarFloatingEnabled(){const e=this.config.toolbar;return!e||typeof e!="object"?!1:!!e.floating}isStatusbarEnabled(){const e=this.config.statusbar;return typeof e=="boolean"?e:e&&typeof e=="object"?e.enabled!==!1:!1}getStatusbarPosition(){const e=this.config.statusbar;return e&&typeof e=="object"&&e.position==="top"?"top":"bottom"}getLanguageConfig(){const e=this.config.language;return typeof e=="string"?{locale:e,direction:"ltr"}:e&&typeof e=="object"?{locale:e.locale||"en",direction:e.direction==="rtl"?"rtl":"ltr"}:{locale:"en",direction:"ltr"}}getAccessibilityConfig(){const e=this.config.accessibility;return typeof e=="boolean"?{enableARIA:e,keyboardNavigation:e,checker:!1}:e&&typeof e=="object"?{enableARIA:e.enableARIA!==!1,keyboardNavigation:e.keyboardNavigation!==!1,checker:!!e.checker}:{enableARIA:!0,keyboardNavigation:!0,checker:!1}}getPerformanceConfig(){var r;const e=this.config.performance;if(typeof e=="boolean")return{debounceInputMs:100,viewportOnlyScan:e};if(e&&typeof e=="object"){const n=Number((r=e.debounceInputMs)!=null?r:100);return{debounceInputMs:Number.isFinite(n)&&n>=0?n:100,viewportOnlyScan:e.viewportOnlyScan!==!1}}return{debounceInputMs:100,viewportOnlyScan:!0}}isEditorInViewport(){if(!this.contentElement||typeof window=="undefined")return!0;const e=this.contentElement.getBoundingClientRect();return e.bottom>=0&&e.top<=window.innerHeight}applyAccessibilitySettings(){if(!this.contentElement)return;const e=this.getAccessibilityConfig();if(e.enableARIA){this.contentElement.setAttribute("role","textbox"),this.contentElement.setAttribute("aria-multiline","true"),this.contentElement.setAttribute("aria-disabled",this.config.readonly?"true":"false");const r=typeof this.config.placeholder=="string"?this.config.placeholder.trim():"";r?this.contentElement.setAttribute("aria-label",r):this.contentElement.removeAttribute("aria-label")}else this.contentElement.removeAttribute("role"),this.contentElement.removeAttribute("aria-multiline"),this.contentElement.removeAttribute("aria-disabled"),this.contentElement.removeAttribute("aria-label");this.contentElement.tabIndex=e.keyboardNavigation?0:-1}applyLanguageSettings(){if(!this.contentElement)return;const e=this.getLanguageConfig();this.contentElement.setAttribute("lang",e.locale),this.contentElement.setAttribute("dir",e.direction)}getSpellcheckConfig(){const e=this.config.spellcheck;if(typeof e=="boolean")return{enabled:e,provider:"browser"};if(e&&typeof e=="object"){const r=e.provider||"browser";return{enabled:!!e.enabled,provider:r,mode:e.mode}}return{enabled:!1,provider:"browser"}}applySpellcheckSettings(){if(!this.contentElement)return;const e=this.getSpellcheckConfig(),r=e.enabled&&e.provider==="browser";this.contentElement.spellcheck=r,this.contentElement.setAttribute("spellcheck",r?"true":"false")}executeCommand(e,r){var o;typeof window!="undefined"&&(window.__editoraCommandEditorRoot=this);const n={editorElement:this,contentElement:this.contentElement,toolbarElement:this.toolbarElement},i=this.loadedPlugins.find(a=>a.commands&&a.commands[e]);if(i&&i.commands){const a=i.commands[e];if(typeof a=="function")try{return a(e==="toggleFullscreen"?this:r,n),!0}catch(s){return console.error(`[RichTextEditor] Error executing native command ${e}:`,s),!1}}return((o=this.engine)==null?void 0:o.execCommand(e,r))||!1}getPluginLoadConfig(e){const r=this.config.pluginConfig;if(r&&typeof r=="object"){const o=r[e];if(o&&typeof o=="object")return o}const n={spellCheck:["spellcheck","spellCheck"],trackChanges:["trackchanges","track-changes","trackChanges"],versionDiff:["versiondiff","version-diff","versionDiff"],"version-diff":["versiondiff","version-diff","versionDiff"],conditionalContent:["conditionalcontent","conditional-content","conditionalContent"],"conditional-content":["conditionalcontent","conditional-content","conditionalContent"],dataBinding:["databinding","data-binding","dataBinding"],"data-binding":["databinding","data-binding","dataBinding"],contentRules:["contentrules","content-rules","contentRules"],"content-rules":["contentrules","content-rules","contentRules"],mentions:["mention","mentions"],mention:["mention","mentions"],slashCommands:["slashcommands","slash-commands","slashCommands"],"slash-commands":["slashcommands","slash-commands","slashCommands"]},i=[e,e.toLowerCase(),...n[e]||[]];for(const o of i){const a=this.config[o];if(a&&typeof a=="object"&&!Array.isArray(a))return a}}getContentSanitizeConfig(){const e=this.config.contentConfig;return e&&typeof e=="object"?e:{sanitize:!0}}getSecurityConfig(){const e=this.config.security;return e&&typeof e=="object"?e:{sanitizeOnPaste:!0,sanitizeOnInput:!0}}getAutosaveConfig(){var r,n;const e=this.config.autosave;if(typeof e=="boolean")return{enabled:e,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"};if(e&&typeof e=="object"){const i=Number((n=(r=e.intervalMs)!=null?r:e.interval)!=null?n:3e4);return{enabled:!!e.enabled,intervalMs:Number.isFinite(i)&&i>0?i:3e4,storageKey:String(e.storageKey||"rte-autosave"),provider:e.provider||"localStorage",apiUrl:e.apiUrl}}return{enabled:!1,intervalMs:3e4,storageKey:"rte-autosave",provider:"localStorage"}}persistAutosave(e){const r=this.getAutosaveConfig();if(r.enabled&&e!==this.lastAutosavedContent){if(this.lastAutosavedContent=e,r.provider==="localStorage"){try{localStorage.setItem(r.storageKey,e),localStorage.setItem(`${r.storageKey}-timestamp`,Date.now().toString())}catch(n){console.error("[RichTextEditor] Failed to save autosave content to localStorage:",n)}return}r.provider==="api"&&r.apiUrl&&fetch(r.apiUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:e,timestamp:Date.now()})}).catch(n=>{console.error("[RichTextEditor] Failed to save autosave content to API:",n)})}}restoreAutosavedContent(){const e=this.getAutosaveConfig();if(!e.enabled||e.provider!=="localStorage")return null;try{const r=localStorage.getItem(e.storageKey);if(r)return this.lastAutosavedContent=r,r}catch(r){console.error("[RichTextEditor] Failed to restore autosaved content:",r)}return null}stopAutosave(){this.autosaveTimer&&(clearInterval(this.autosaveTimer),this.autosaveTimer=void 0)}startAutosave(){this.stopAutosave();const e=this.getAutosaveConfig();!e.enabled||!this.contentElement||(this.autosaveTimer=setInterval(()=>{var r;this.persistAutosave(((r=this.contentElement)==null?void 0:r.innerHTML)||"")},e.intervalMs))}insertHTMLAtSelection(e){if(!this.contentElement)return;const r=window.getSelection();if(r&&r.rangeCount>0){const n=r.getRangeAt(0);n.deleteContents();const i=document.createElement("div");i.innerHTML=e;const o=document.createDocumentFragment();for(;i.firstChild;)o.appendChild(i.firstChild);n.insertNode(o),n.collapse(!1),r.removeAllRanges(),r.addRange(n)}else this.contentElement.focus(),document.execCommand("insertHTML",!1,e)}createUI(e,r){const n=this.querySelector('[slot="toolbar"]'),i=this.querySelector('[slot="statusbar"]');this.innerHTML="",this.config.toolbar!==!1&&!n?(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.appendChild(this.toolbarElement),this.toolbar=new QV({items:this.resolveToolbarItems(),sticky:this.isToolbarStickyEnabled(),position:"top"},e,this.pluginLoader),this.toolbar.setCommandHandler((o,a)=>{var s;if(this.contentElement){this.contentElement.focus();const c=window.getSelection();if(!c||c.rangeCount===0||!this.contentElement.contains(c.anchorNode)){const l=document.createRange(),u=this.contentElement.lastChild||this.contentElement;u.nodeType===Node.TEXT_NODE?l.setStart(u,((s=u.textContent)==null?void 0:s.length)||0):u.nodeType===Node.ELEMENT_NODE?(l.selectNodeContents(u),l.collapse(!1)):l.setStart(this.contentElement,0),l.collapse(!0),c==null||c.removeAllRanges(),c==null||c.addRange(l)}}return this.executeCommand(o,a)}),this.toolbar.render(this.toolbarElement)):n&&this.appendChild(n),this.contentElement=document.createElement("div"),this.contentElement.className="editora-content rte-content",this.contentElement.contentEditable=this.config.readonly?"false":"true",this.applyLanguageSettings(),this.applyAccessibilitySettings(),this.applySpellcheckSettings(),this.config.placeholder&&this.contentElement.setAttribute("data-placeholder",this.config.placeholder);try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(o){console.warn("defaultParagraphSeparator not supported:",o)}if(r){const o=document.createElement("div");o.innerHTML=r.trim(),!Array.from(o.childNodes).some(s=>{if(s.nodeType===Node.ELEMENT_NODE){const c=s.tagName;return["P","DIV","H1","H2","H3","H4","H5","H6","UL","OL","BLOCKQUOTE","PRE"].includes(c)}return!1})&&r.trim()?this.contentElement.innerHTML=`<p>${r.trim()}</p>`:this.contentElement.innerHTML=r}else this.config.placeholder?this.contentElement.innerHTML="":this.contentElement.innerHTML="<p><br></p>";this.appendChild(this.contentElement),this.isToolbarFloatingEnabled()&&(this.floatingToolbar=new $V({enabled:!0}),this.floatingToolbar.create(this)),i?this.appendChild(i):this.isStatusbarEnabled()&&(this.statusBarElement=document.createElement("div"),this.statusBarElement.className="editora-statusbar-container",this.appendChild(this.statusBarElement),this.statusBar=new qV({position:this.getStatusbarPosition()}),this.statusBar.create(this.statusBarElement)),this.config.autofocus&&setTimeout(()=>{var o;return(o=this.contentElement)==null?void 0:o.focus()},0)}setupEventListeners(){if(!this.contentElement||!this.engine)return;const e=this.keyboardShortcutManager;this.contentElement.addEventListener("beforeinput",n=>{this.lastBeforeInputType=n.inputType||null}),this.contentElement.addEventListener("input",()=>{if(!this.contentElement)return;let n=this.contentElement.innerHTML;const i=this.getPerformanceConfig(),o=this.getContentSanitizeConfig(),a=this.getSecurityConfig(),s=this.lastBeforeInputType;if(this.lastBeforeInputType=null,a.sanitizeOnInput!==!1&&o.sanitize!==!1&&!s){const u=eG(n,o,a);if(u!==n){const d=window.getSelection(),f=d&&d.rangeCount>0?d.getRangeAt(0):null;if(this.contentElement.innerHTML=u,f&&d)try{d.removeAllRanges(),d.addRange(f)}catch(A){}n=u}}this.contentChangeDebounceTimer&&clearTimeout(this.contentChangeDebounceTimer);const l=()=>{this.dispatchEvent(new CustomEvent("content-change",{detail:{html:n},bubbles:!0}))};i.debounceInputMs>0?this.contentChangeDebounceTimer=setTimeout(l,i.debounceInputMs):l(),this.updateStatusBar()}),this.contentElement.addEventListener("contextmenu",n=>{const i=this.config.contextMenu;(i===!1||typeof i=="object"&&i!==null&&i.enabled===!1)&&n.preventDefault()}),this.contentElement.addEventListener("paste",n=>{var u,d;if(n.__editoraSmartPasteHandled===!0||n.defaultPrevented)return;n.preventDefault();const i=this.config.paste||{};let o=((u=n.clipboardData)==null?void 0:u.getData("text/html"))||"";const a=((d=n.clipboardData)==null?void 0:d.getData("text/plain"))||"",s=this.getContentSanitizeConfig(),c=this.getSecurityConfig(),l=!!o&&/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office/i.test(o);if((i.clean||!i.keepFormatting)&&a){document.execCommand("insertText",!1,a);return}if(i.convertWord===!1&&l&&a){document.execCommand("insertText",!1,a);return}if(o){c.sanitizeOnPaste!==!1&&s.sanitize!==!1&&(o=JV(o,s,c)),this.insertHTMLAtSelection(o);return}a&&document.execCommand("insertText",!1,a)}),this.contentElement.addEventListener("focus",()=>{Yl=this,this.dispatchEvent(new Event("editor-focus",{bubbles:!0})),this.updateStatusBar()}),this.contentElement.addEventListener("blur",()=>{this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&this.dispatchEvent(new CustomEvent("content-change",{detail:{html:this.contentElement.innerHTML},bubbles:!0})),this.dispatchEvent(new Event("editor-blur",{bubbles:!0})),this.updateFloatingToolbar(),this.updateStatusBar()}),this.contentElement.addEventListener("keydown",n=>{this.getAccessibilityConfig().keyboardNavigation&&e.handleKeyDown(n,(o,a)=>{this.executeCommand(o,a)})});const r=()=>{const n=this.getSelectionRangeInEditor(),i=document.activeElement,o=!!i&&!!this.contentElement&&(i===this.contentElement||this.contentElement.contains(i));this.getPerformanceConfig().viewportOnlyScan&&!this.isEditorInViewport()&&!o||!n&&!o||(this.updateFloatingToolbar(),this.updateStatusBar())};this.selectionChangeHandler=r,document.addEventListener("selectionchange",this.selectionChangeHandler)}getSelectionRangeInEditor(){if(!this.contentElement)return null;const e=window.getSelection();if(!e||e.rangeCount===0)return null;const r=e.getRangeAt(0),n=r.commonAncestorContainer;return this.contentElement.contains(n)?r:null}isSelectionBackward(e){if(!e.anchorNode||!e.focusNode)return!1;try{const r=document.createRange();return r.setStart(e.anchorNode,e.anchorOffset),r.setEnd(e.focusNode,e.focusOffset),r.collapsed}catch(r){return!1}}getSelectionAnchorRect(e,r){const n=Array.from(r.getClientRects()).filter(o=>o.width>0||o.height>0);return n.length===0?r.getBoundingClientRect():this.isSelectionBackward(e)?n[0]:n[n.length-1]}updateFloatingToolbar(){if(!this.floatingToolbar||!this.contentElement)return;if(this.config.readonly||this.contentElement.contentEditable==="false"||this.contentElement.getAttribute("data-readonly")==="true"||this.getAttribute("readonly")==="true"||this.getAttribute("data-readonly")==="true"){this.floatingToolbar.hide();return}const r=this.getPerformanceConfig(),n=document.activeElement===this.contentElement||!!this.contentElement&&this.contentElement.contains(document.activeElement);if(r.viewportOnlyScan&&!this.isEditorInViewport()&&!n){this.floatingToolbar.hide();return}const i=this.getSelectionRangeInEditor();if(!i){this.floatingToolbar.hide();return}if(i.collapsed){this.floatingToolbar.hide();return}const o=window.getSelection();if(!o){this.floatingToolbar.hide();return}const a=this.getSelectionAnchorRect(o,i);if(!a){this.floatingToolbar.hide();return}this.floatingToolbar.show(a.left,a.top-40)}updateStatusBar(){if(!this.statusBar||!this.contentElement)return;const e=this.getPerformanceConfig(),r=document.activeElement===this.contentElement||this.contentElement.contains(document.activeElement);if(e.viewportOnlyScan&&!this.isEditorInViewport()&&!r)return;const n=this.contentElement.textContent||"",{words:i,chars:o}=KV(n),a=jV(this.contentElement);let s,c;const l=this.getSelectionRangeInEditor();l&&(s=WV(this.contentElement,l),l.collapsed||(c=VV(l,s),s=void 0)),this.statusBar.update({wordCount:i,charCount:o,lineCount:a,cursorPosition:s,selectionInfo:c})}handleAttributeChange(e,r){switch(e){case"readonly":this.contentElement&&(this.contentElement.contentEditable=r==="true"?"false":"true",this.applyAccessibilitySettings()),this.engine&&this.engine.setReadonly(r==="true");break;case"theme":this.classList.forEach(n=>{n.startsWith("editora-theme-")&&this.classList.remove(n)}),r&&this.classList.add(`editora-theme-${r}`);break;case"placeholder":this.contentElement&&(this.contentElement.setAttribute("data-placeholder",r),this.applyAccessibilitySettings());break;case"accessibility":case"accessibility-enable-aria":case"accessibility-keyboard-navigation":case"accessibility-checker":this.applyAccessibilitySettings();break;case"performance":case"performance-debounce-input-ms":case"performance-viewport-only-scan":break;case"language":case"language-locale":case"language-direction":this.applyLanguageSettings();break;case"spellcheck":case"spellcheck-enabled":case"spellcheck-provider":this.applySpellcheckSettings();break;case"autosave":case"autosave-enabled":case"autosave-interval-ms":case"autosave-storage-key":case"autosave-provider":case"autosave-api-url":this.startAutosave();break;case"security":case"security-sanitize-on-paste":case"security-sanitize-on-input":case"paste":case"paste-clean":case"paste-keep-formatting":case"paste-convert-word":case"context-menu":case"context-menu-enabled":break;case"toolbar":case"toolbar-items":case"toolbar-floating":case"toolbar-sticky":case"plugins":case"statusbar":this.isConnected&&(this.destroy(),this.waitForPluginLoader().then(()=>{this.initialize().catch(n=>{console.error("[RichTextEditor] Error during attribute change re-initialization:",n)})}));break}}resolveConfig(){const e={};for(let r=0;r<this.attributes.length;r++){const n=this.attributes[r];e[n.name]=n.value}return hE.resolve({jsConfig:this.jsConfig,attributes:e})}getAPI(){return{getContent:()=>{var e;return((e=this.contentElement)==null?void 0:e.innerHTML)||""},setContent:e=>{this.contentElement&&(this.contentElement.innerHTML=e)},execCommand:(e,r)=>this.executeCommand(e,r),focus:()=>{var e;(e=this.contentElement)==null||e.focus()},blur:()=>{var e;(e=this.contentElement)==null||e.blur()},destroy:()=>{this.destroy()},on:(e,r)=>(this.addEventListener(e,r),()=>this.removeEventListener(e,r)),getConfig:()=>({...this.config}),setReadonly:e=>{this.setAttribute("readonly",e.toString())}}}destroy(){var e,r,n,i;this.contentChangeDebounceTimer&&(clearTimeout(this.contentChangeDebounceTimer),this.contentChangeDebounceTimer=void 0),this.contentElement&&this.persistAutosave(this.contentElement.innerHTML||""),this.stopAutosave(),this.selectionChangeHandler&&(document.removeEventListener("selectionchange",this.selectionChangeHandler),this.selectionChangeHandler=void 0),(e=this.engine)==null||e.destroy(),(r=this.toolbar)==null||r.destroy(),(n=this.floatingToolbar)==null||n.destroy(),(i=this.statusBar)==null||i.destroy(),this.innerHTML="",this.contentElement=void 0,this.toolbarElement=void 0,this.statusBarElement=void 0,this.loadedPlugins=[],this.isInitialized=!1,pE.delete(this),Yl===this&&(Yl=null),this.dispatchEvent(new Event("editor-destroy",{bubbles:!0}))}getContent(){var e;return((e=this.contentElement)==null?void 0:e.innerHTML)||""}setContent(e){this.contentElement&&(this.contentElement.innerHTML=e)}execCommand(e,r){return this.executeCommand(e,r)}focus(){var e;(e=this.contentElement)==null||e.focus()}blur(){var e;(e=this.contentElement)==null||e.blur()}}const e0=new F6;ha.__globalPluginLoader=e0;const lG={bold:()=>Promise.resolve().then(()=>pG).then(t=>t.BoldPlugin()),italic:()=>Promise.resolve().then(()=>mG).then(t=>t.ItalicPlugin()),underline:()=>Promise.resolve().then(()=>bG).then(t=>t.UnderlinePlugin()),strikethrough:()=>Promise.resolve().then(()=>wG).then(t=>t.StrikethroughPlugin()),clearFormatting:()=>Promise.resolve().then(()=>FG).then(t=>t.ClearFormattingPlugin()),heading:()=>Promise.resolve().then(()=>KG).then(t=>t.HeadingPlugin()),blockquote:()=>Promise.resolve().then(()=>o3).then(t=>t.BlockquotePlugin()),code:()=>Promise.resolve().then(()=>E3).then(t=>t.CodePlugin()),codeSample:()=>Promise.resolve().then(()=>k3).then(t=>t.CodeSamplePlugin()),list:()=>Promise.resolve().then(()=>L3).then(t=>t.ListPlugin()),checklist:()=>Promise.resolve().then(()=>W3).then(t=>t.ChecklistPlugin()),textAlignment:()=>Promise.resolve().then(()=>K3).then(t=>t.TextAlignmentPlugin()),indent:()=>Promise.resolve().then(()=>V3).then(t=>t.IndentPlugin()),direction:()=>Promise.resolve().then(()=>nX).then(t=>t.DirectionPlugin()),textColor:()=>Promise.resolve().then(()=>mX).then(t=>t.TextColorPlugin()),backgroundColor:()=>Promise.resolve().then(()=>SX).then(t=>t.BackgroundColorPlugin()),fontSize:()=>Promise.resolve().then(()=>MX).then(t=>t.FontSizePlugin()),fontFamily:()=>Promise.resolve().then(()=>GX).then(t=>t.FontFamilyPlugin()),lineHeight:()=>Promise.resolve().then(()=>nY).then(t=>t.LineHeightPlugin()),capitalization:()=>Promise.resolve().then(()=>pY).then(t=>t.CapitalizationPlugin()),history:()=>Promise.resolve().then(()=>vY).then(t=>t.HistoryPlugin()),link:()=>Promise.resolve().then(()=>CY).then(t=>t.LinkPlugin()),table:()=>Promise.resolve().then(()=>qY).then(t=>t.TablePlugin()),trackChanges:()=>Promise.resolve().then(()=>CZ).then(t=>t.TrackChangesPlugin()),versionDiff:()=>Promise.resolve().then(()=>yC).then(t=>t.VersionDiffPlugin()),"version-diff":()=>Promise.resolve().then(()=>yC).then(t=>t.VersionDiffPlugin()),versiondiff:()=>Promise.resolve().then(()=>yC).then(t=>t.VersionDiffPlugin()),conditionalContent:()=>Promise.resolve().then(()=>BC).then(t=>t.ConditionalContentPlugin()),"conditional-content":()=>Promise.resolve().then(()=>BC).then(t=>t.ConditionalContentPlugin()),conditionalcontent:()=>Promise.resolve().then(()=>BC).then(t=>t.ConditionalContentPlugin()),dataBinding:()=>Promise.resolve().then(()=>IC).then(t=>t.DataBindingPlugin()),"data-binding":()=>Promise.resolve().then(()=>IC).then(t=>t.DataBindingPlugin()),databinding:()=>Promise.resolve().then(()=>IC).then(t=>t.DataBindingPlugin()),docSchema:()=>Promise.resolve().then(()=>zC).then(t=>t.DocSchemaPlugin()),"doc-schema":()=>Promise.resolve().then(()=>zC).then(t=>t.DocSchemaPlugin()),docschema:()=>Promise.resolve().then(()=>zC).then(t=>t.DocSchemaPlugin()),translationWorkflow:()=>Promise.resolve().then(()=>i5).then(t=>t.TranslationWorkflowPlugin()),"translation-workflow":()=>Promise.resolve().then(()=>i5).then(t=>t.TranslationWorkflowPlugin()),translationworkflow:()=>Promise.resolve().then(()=>i5).then(t=>t.TranslationWorkflowPlugin()),contentRules:()=>Promise.resolve().then(()=>f5).then(t=>t.ContentRulesPlugin()),"content-rules":()=>Promise.resolve().then(()=>f5).then(t=>t.ContentRulesPlugin()),contentrules:()=>Promise.resolve().then(()=>f5).then(t=>t.ContentRulesPlugin()),citations:()=>Promise.resolve().then(()=>D4).then(t=>t.CitationsPlugin()),citation:()=>Promise.resolve().then(()=>D4).then(t=>t.CitationsPlugin()),approvalWorkflow:()=>Promise.resolve().then(()=>_5).then(t=>t.ApprovalWorkflowPlugin()),"approval-workflow":()=>Promise.resolve().then(()=>_5).then(t=>t.ApprovalWorkflowPlugin()),approvalworkflow:()=>Promise.resolve().then(()=>_5).then(t=>t.ApprovalWorkflowPlugin()),piiRedaction:()=>Promise.resolve().then(()=>$5).then(t=>t.PIIRedactionPlugin()),"pii-redaction":()=>Promise.resolve().then(()=>$5).then(t=>t.PIIRedactionPlugin()),piiredaction:()=>Promise.resolve().then(()=>$5).then(t=>t.PIIRedactionPlugin()),smartPaste:()=>Promise.resolve().then(()=>J5).then(t=>t.SmartPastePlugin()),"smart-paste":()=>Promise.resolve().then(()=>J5).then(t=>t.SmartPastePlugin()),smartpaste:()=>Promise.resolve().then(()=>J5).then(t=>t.SmartPastePlugin()),blocksLibrary:()=>Promise.resolve().then(()=>sT).then(t=>t.BlocksLibraryPlugin()),"blocks-library":()=>Promise.resolve().then(()=>sT).then(t=>t.BlocksLibraryPlugin()),blockslibrary:()=>Promise.resolve().then(()=>sT).then(t=>t.BlocksLibraryPlugin()),mentions:()=>Promise.resolve().then(()=>JN).then(t=>t.MentionPlugin()),mention:()=>Promise.resolve().then(()=>JN).then(t=>t.MentionPlugin()),anchor:()=>Promise.resolve().then(()=>xie).then(t=>t.AnchorPlugin()),embedIframe:()=>Promise.resolve().then(()=>jie).then(t=>t.EmbedIframePlugin()),math:()=>Promise.resolve().then(()=>ooe).then(t=>t.MathPlugin()),image:()=>Promise.resolve().then(()=>foe).then(t=>t.MediaManagerPlugin()),mergeTag:()=>Promise.resolve().then(()=>Uoe).then(t=>t.MergeTagPlugin()),pageBreak:()=>Promise.resolve().then(()=>Woe).then(t=>t.PageBreakPlugin()),print:()=>Promise.resolve().then(()=>joe).then(t=>t.PrintPlugin()),preview:()=>Promise.resolve().then(()=>Zoe).then(t=>t.PreviewPlugin()),specialCharacters:()=>Promise.resolve().then(()=>cae).then(t=>t.SpecialCharactersPlugin()),slashCommands:()=>Promise.resolve().then(()=>KR).then(t=>t.SlashCommandsPlugin()),"slash-commands":()=>Promise.resolve().then(()=>KR).then(t=>t.SlashCommandsPlugin()),spellCheck:()=>Promise.resolve().then(()=>nse).then(t=>t.SpellCheckPlugin()),emojis:()=>Promise.resolve().then(()=>Ase).then(t=>t.EmojisPlugin()),a11yChecker:()=>Promise.resolve().then(()=>gse).then(t=>t.A11yCheckerPlugin()),comments:()=>Promise.resolve().then(()=>kse).then(t=>t.CommentsPlugin()),"document-manager":()=>Promise.resolve().then(()=>Dse).then(t=>t.DocumentManagerPlugin()),fullscreen:()=>Promise.resolve().then(()=>Lse).then(t=>t.FullscreenPlugin()),template:()=>Promise.resolve().then(()=>hce).then(t=>t.TemplatePlugin()),footnote:()=>Promise.resolve().then(()=>kce).then(t=>t.FootnotePlugin())};async function P6(){return Object.entries(lG).forEach(([t,e])=>{e0.register(t,e)}),e0}typeof window!="undefined"&&P6().then(t=>{ha.__globalPluginLoader=t,customElements.get("editora-editor")||customElements.define("editora-editor",ha);const e=document.querySelectorAll("editora-editor:not([data-initial-content])"),r=[];e.forEach(o=>{const a=o.innerHTML.trim();r.push(a),a&&o.setAttribute("data-initial-content",a)});const n=document.querySelectorAll("editora-editor");Array.from(n).filter(o=>!o.hasAttribute("data-initial-content")).forEach(o=>{const a=Array.from(n).indexOf(o);r[a]&&o.setAttribute("data-initial-content",r[a])}),window.Editora={version:"1.0.0",plugins:e0.getRegisteredPluginNames(),WebComponent:ha,init:async(o,a)=>{const s=document.querySelector(o);return s instanceof ha?(a&&await s.setConfig(a),s.getAPI()):null}}});const t0="data-editora-selection-marker";function uG(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function H6(t){return t?t.getAttribute("contenteditable")==="true"?t:t.querySelector('[contenteditable="true"]'):null}function dG(t){var a;if((t==null?void 0:t.contentElement)instanceof HTMLElement)return t.contentElement;const e=H6((a=t==null?void 0:t.editorElement)!=null?a:null);if(e)return e;const r=typeof window!="undefined"?window.__editoraCommandEditorRoot:null,n=r instanceof HTMLElement?H6(r):null;if(n)return n;const i=window.getSelection();if(i&&i.rangeCount>0){const s=uG(i.getRangeAt(0).startContainer),c=s==null?void 0:s.closest('.rte-content, .editora-content, [contenteditable="true"]');if(c instanceof HTMLElement)return c}const o=document.activeElement;if(o instanceof HTMLElement){const s=o.closest('.rte-content, .editora-content, [contenteditable="true"]');if(s instanceof HTMLElement)return s}return document.querySelector('.rte-content, .editora-content, [contenteditable="true"]')}function AG(t){const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const r=e.getRangeAt(0);return t.contains(r.startContainer)&&t.contains(r.endContainer)}function Q6(t){const e=document.createElement("span");return e.setAttribute(t0,t),e.style.display="inline-block",e.style.width="0",e.style.height="0",e.style.overflow="hidden",e.style.lineHeight="0",e.appendChild(document.createTextNode("\uFEFF")),e}function fG(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const r=e.getRangeAt(0);if(!t.contains(r.startContainer)||!t.contains(r.endContainer))return null;const n=r.collapsed,i=Q6("start"),o=n?null:Q6("end"),a=r.cloneRange();if(o){const c=a.cloneRange();c.collapse(!1),c.insertNode(o)}const s=a.cloneRange();return s.collapse(!0),s.insertNode(i),()=>{const c=window.getSelection(),l=document.createRange(),u=t.querySelector(`[${t0}="start"]`),d=t.querySelector(`[${t0}="end"]`);if(!c||!u){t.querySelectorAll(`[${t0}]`).forEach(f=>f.remove());return}n||!d?(l.setStartBefore(u),l.collapse(!0)):(l.setStartAfter(u),l.setEndBefore(d)),c.removeAllRanges(),c.addRange(l),u.remove(),d==null||d.remove()}}function hG(t,e,r){if(e!==r){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",t,e,r);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:r})}catch(n){}}}function r0(t){const e=dG(t.context);if(!e)return!1;const r=e.innerHTML;AG(e)&&e.focus({preventScroll:!0});let n=!1;try{n=document.execCommand(t.command,!1)}catch(a){n=!1}const i=e.innerHTML;if(t.normalize&&i!==r){const a=fG(e);t.normalize(e),a==null||a()}const o=e.innerHTML;return r!==o&&(hG(e,r,o),e.dispatchEvent(new Event("input",{bubbles:!0}))),n!==!1||r!==o}const pG=Object.freeze(Object.defineProperty({__proto__:null,BoldPlugin:()=>({name:"bold",marks:{bold:{parseDOM:[{tag:"strong"},{tag:"b"},{style:"font-weight",getAttrs:t=>{const e=typeof t=="string"?t:t.style.fontWeight;return/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}}],toDOM:()=>["strong",0]}},toolbar:[{label:"Bold",command:"toggleBold",icon:'<svg width="24" height="24" focusable="false"><path d="M7.8 19c-.3 0-.5 0-.6-.2l-.2-.5V5.7c0-.2 0-.4.2-.5l.6-.2h5c1.5 0 2.7.3 3.5 1 .7.6 1.1 1.4 1.1 2.5a3 3 0 0 1-.6 1.9c-.4.6-1 1-1.6 1.2.4.1.9.3 1.3.6s.8.7 1 1.2c.4.4.5 1 .5 1.6 0 1.3-.4 2.3-1.3 3-.8.7-2.1 1-3.8 1H7.8Zm5-8.3c.6 0 1.2-.1 1.6-.5.4-.3.6-.7.6-1.3 0-1.1-.8-1.7-2.3-1.7H9.3v3.5h3.4Zm.5 6c.7 0 1.3-.1 1.7-.4.4-.4.6-.9.6-1.5s-.2-1-.7-1.4c-.4-.3-1-.4-2-.4H9.4v3.8h4Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-b"}],commands:{toggleBold:(t,e)=>r0({command:"bold",context:e})},keymap:{"Mod-b":"toggleBold","Mod-B":"toggleBold"}})},Symbol.toStringTag,{value:"Module"})),bE=(t,e)=>r0({command:"italic",context:e}),gG=(t,e)=>{var r;typeof window!="undefined"&&((r=window.registerEditorCommand)==null||r.call(window,t,e))},$6=()=>{gG("toggleItalic",bE)};typeof window!="undefined"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",$6):$6());const mG=Object.freeze(Object.defineProperty({__proto__:null,ItalicPlugin:()=>({name:"italic",marks:{italic:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:()=>["em",0]}},toolbar:[{label:"Italic",command:"toggleItalic",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M16.7 4.7l-.1.9h-.3c-.6 0-1 0-1.4.3-.3.3-.4.6-.5 1.1l-2.1 9.8v.6c0 .5.4.8 1.4.8h.2l-.2.8H8l.2-.8h.2c1.1 0 1.8-.5 2-1.5l2-9.8.1-.5c0-.6-.4-.8-1.4-.8h-.3l.2-.9h5.8Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-i"}],commands:{toggleItalic:bE},keymap:{"Mod-i":"toggleItalic","Mod-I":"toggleItalic"}}),toggleItalic:bE},Symbol.toStringTag,{value:"Module"})),bG=Object.freeze(Object.defineProperty({__proto__:null,UnderlinePlugin:()=>({name:"underline",marks:{underline:{parseDOM:[{tag:"u"}],toDOM:()=>["u",{},0]}},toolbar:[{label:"Underline",command:"toggleUnderline",icon:'<svg width="24" height="24" focusable="false"><path d="M16 5c.6 0 1 .4 1 1v7c0 2.8-2.2 5-5 5s-5-2.2-5-5V6c0-.6.4-1 1-1s1 .4 1 1v7c0 1.7 1.3 3 3 3s3-1.3 3-3V6c0-.6.4-1 1-1ZM4 17h16c.6 0 1 .4 1 1s-.4 1-1 1H4a1 1 0 1 1 0-2Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-u"}],commands:{toggleUnderline:(t,e)=>r0({command:"underline",context:e})},keymap:{"Mod-u":"toggleUnderline","Mod-U":"toggleUnderline"}})},Symbol.toStringTag,{value:"Module"})),vG=()=>({name:"strikethrough",marks:{strikethrough:{parseDOM:[{tag:"s"},{tag:"strike"},{tag:"del"},{style:"text-decoration",getAttrs:t=>(typeof t=="string"?t:t.style.textDecoration)==="line-through"&&null}],toDOM:()=>["s",0]}},toolbar:[{label:"Strikethrough",command:"toggleStrikethrough",icon:'<svg width="24" height="24" focusable="false"><g fill-rule="evenodd"><path d="M15.6 8.5c-.5-.7-1-1.1-1.3-1.3-.6-.4-1.3-.6-2-.6-2.7 0-2.8 1.7-2.8 2.1 0 1.6 1.8 2 3.2 2.3 4.4.9 4.6 2.8 4.6 3.9 0 1.4-.7 4.1-5 4.1A6.2 6.2 0 0 1 7 16.4l1.5-1.1c.4.6 1.6 2 3.7 2 1.6 0 2.5-.4 3-1.2.4-.8.3-2-.8-2.6-.7-.4-1.6-.7-2.9-1-1-.2-3.9-.8-3.9-3.6C7.6 6 10.3 5 12.4 5c2.9 0 4.2 1.6 4.7 2.4l-1.5 1.1Z"></path><path d="M5 11h14a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z" fill-rule="nonzero"></path></g></svg>',shortcut:"Mod-Shift-x"}],commands:{toggleStrikethrough:(t,e)=>r0({command:"strikeThrough",context:e,normalize:yG})},keymap:{"Mod-Shift-x":"toggleStrikethrough","Mod-Shift-X":"toggleStrikethrough"}});function yG(t){t.querySelectorAll("strike, del").forEach(r=>{var i;const n=document.createElement("s");for(const o of Array.from(r.attributes))o.name!=="style"&&n.setAttribute(o.name,o.value);for(;r.firstChild;)n.appendChild(r.firstChild);(i=r.parentNode)==null||i.replaceChild(n,r)})}const wG=Object.freeze(Object.defineProperty({__proto__:null,StrikethroughPlugin:vG},Symbol.toStringTag,{value:"Module"})),xG=()=>({name:"clearFormatting",toolbar:[{label:"Clear Formatting",command:"clearFormatting",icon:'<svg width="24" height="24" focusable="false"><path d="M13.2 6a1 1 0 0 1 0 .2l-2.6 10a1 1 0 0 1-1 .8h-.2a.8.8 0 0 1-.8-1l2.6-10H8a1 1 0 1 1 0-2h9a1 1 0 0 1 0 2h-3.8ZM5 18h7a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Zm13 1.5L16.5 18 15 19.5a.7.7 0 0 1-1-1l1.5-1.5-1.5-1.5a.7.7 0 0 1 1-1l1.5 1.5 1.5-1.5a.7.7 0 0 1 1 1L17.5 17l1.5 1.5a.7.7 0 0 1-1 1Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-\\"}],commands:{clearFormatting:()=>{const t=BG();if(!t)return!1;const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const r=e.getRangeAt(0);if(!t.contains(r.commonAncestorContainer))return!1;const n=r.cloneRange();return t.focus({preventScroll:!0}),LG(t,n),_G(t,n),t.dispatchEvent(new Event("input",{bubbles:!0})),!0}},keymap:{"Mod-\\":"clearFormatting"}}),EG=new Set(["A","B","STRONG","I","EM","U","S","STRIKE","DEL","FONT","MARK","CODE","SUB","SUP"]),CG=new Set(["H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE"]),TG=["color","background-color","font-size","font-family","font-weight","font-style","text-decoration","text-transform","line-height","letter-spacing","word-spacing","vertical-align","text-align","padding-left"];function BG(){const t=window.getSelection();if(t&&t.rangeCount>0){const r=t.getRangeAt(0).startContainer,n=r.nodeType===Node.ELEMENT_NODE?r:r.parentElement,i=n==null?void 0:n.closest('[contenteditable="true"], .rte-content, .editora-content');if(i)return i}const e=document.activeElement;return e?e.getAttribute("contenteditable")==="true"?e:e.closest('[contenteditable="true"], .rte-content, .editora-content'):null}function q6(t,e){try{if(typeof t.intersectsNode=="function")return t.intersectsNode(e)}catch(n){}const r=document.createRange();return e.nodeType===Node.ELEMENT_NODE?r.selectNodeContents(e):r.selectNode(e),t.compareBoundaryPoints(Range.END_TO_START,r)>0&&t.compareBoundaryPoints(Range.START_TO_END,r)<0}function W6(t){let e=0,r=t;for(;r&&r.parentNode;)e+=1,r=r.parentNode;return e}function SG(t){TG.forEach(e=>{t.style.removeProperty(e)}),(!t.getAttribute("style")||t.style.length===0)&&t.removeAttribute("style"),t.classList.contains("rte-text-color")&&t.classList.remove("rte-text-color"),t.classList.contains("rte-bg-color")&&t.classList.remove("rte-bg-color"),t.classList.length===0&&t.removeAttribute("class")}function vE(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}}function kG(t){return t.tagName!=="P"||t.attributes.length>0||(t.textContent||"").trim()!==""?!1:!t.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function z6(t){Array.from(t.children).forEach(e=>{kG(e)&&e.remove()})}function j6(t){z6(t),vE(t)}function K6(t){var r;const e=document.createElement("p");for(Array.from(t.attributes).forEach(n=>{e.setAttribute(n.name,n.value)});t.firstChild;)e.appendChild(t.firstChild);e.innerHTML.trim()||(e.innerHTML="<br>"),(r=t.parentNode)==null||r.replaceChild(e,t)}function DG(t){if(z6(t),t.parentElement instanceof HTMLLIElement){j6(t);return}if(Array.from(t.childNodes).filter(i=>i.nodeType!==Node.TEXT_NODE||(i.textContent||"").trim()!=="").some(i=>i instanceof HTMLElement&&/^(P|DIV|H[1-6]|UL|OL|PRE|TABLE|BLOCKQUOTE)$/.test(i.tagName))){j6(t);return}K6(t)}function _G(t,e){Array.from(t.querySelectorAll("h1,h2,h3,h4,h5,h6,blockquote,pre")).forEach(n=>{if(q6(e,n)&&CG.has(n.tagName)){if(n.tagName==="BLOCKQUOTE"){DG(n);return}K6(n)}})}function LG(t,e){const r=Array.from(t.querySelectorAll("a,b,strong,i,em,u,s,strike,del,font,mark,code,sub,sup,span,[style],[class]"));r.sort((n,i)=>W6(i)-W6(n)),r.forEach(n=>{if(n.isConnected&&q6(e,n)&&!(n.getAttribute("contenteditable")==="false"||n.closest('[contenteditable="false"]'))){if(SG(n),EG.has(n.tagName)){vE(n);return}n.tagName==="SPAN"&&n.attributes.length===0&&vE(n)}})}const FG=Object.freeze(Object.defineProperty({__proto__:null,ClearFormattingPlugin:xG},Symbol.toStringTag,{value:"Module"})),mg='.rte-content, .editora-content, [contenteditable="true"]',UG="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",V6=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","PRE"]),G6="p,div,h1,h2,h3,h4,h5,h6,ul,ol,blockquote,pre,table",IG=new Set(["p","h1","h2","h3","h4","h5","h6"]);function X6(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function NG(t){const e=t==null?void 0:t.contentElement;if(e instanceof HTMLElement)return e;const r=t==null?void 0:t.editorElement;if(r instanceof HTMLElement){const a=r.querySelector(mg);if(a instanceof HTMLElement)return a;if(r.getAttribute("contenteditable")==="true")return r}const n=window.getSelection();if(n&&n.rangeCount>0){const a=X6(n.getRangeAt(0).startContainer),s=a==null?void 0:a.closest(mg);if(s instanceof HTMLElement)return s;const c=a==null?void 0:a.closest(UG),l=c==null?void 0:c.querySelector(mg);if(l instanceof HTMLElement)return l}const i=document.activeElement,o=i==null?void 0:i.closest(mg);return o instanceof HTMLElement?o:document.querySelector(mg)}function RG(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const r=e.getRangeAt(0);return!t.contains(r.startContainer)||!t.contains(r.endContainer)?null:r}function Y6(t,e){let r=X6(e);if(!r||r===t||!t.contains(r))return null;for(;r.parentElement&&r.parentElement!==t;)r=r.parentElement;if(r.parentElement!==t)return null;if(r.matches(G6))return r;const n=r.closest(G6);return n instanceof HTMLElement&&n.parentElement===t?n:r}function Z6(t,e){if(typeof t.intersectsNode=="function")try{return t.intersectsNode(e)}catch(n){return!1}const r=document.createRange();return r.selectNode(e),t.compareBoundaryPoints(Range.END_TO_START,r)<0&&t.compareBoundaryPoints(Range.START_TO_END,r)>0}function OG(t,e){const r=Y6(t,e.startContainer),n=Y6(t,e.endContainer);if(!r)return[];if(!n||r===n)return[r];const o=Array.from(t.children).filter(a=>a instanceof HTMLElement).filter(a=>Z6(e,a));return o.length>0?o:[r]}function MG(t,e){Array.from(t.attributes).forEach(r=>{e.setAttribute(r.name,r.value)})}function yE(t,e){for(;t.firstChild;)e.appendChild(t.firstChild)}function PG(t){return t.tagName!=="P"||t.attributes.length>0||(t.textContent||"").trim()!==""?!1:!t.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function n0(t,e){const r=document.createElement(t);return e&&MG(e,r),r}function J6(t,e){const r=n0(e,t);return yE(t,r),r.innerHTML.trim()||(r.innerHTML="<br>"),r}function HG(t){const e=t.cloneNode(!1);return e instanceof HTMLElement?e:document.createElement(t.tagName.toLowerCase())}function e8(t,e,r){const n=t.parentNode;if(!n)return[];const i=document.createDocumentFragment(),o=[];let a=null;const s=()=>{a&&a.children.length>0&&i.appendChild(a),a=null};return Array.from(t.children).forEach(c=>{if(c instanceof HTMLLIElement){if(e.has(c)){s();const l=J6(c,r);i.appendChild(l),o.push(l);return}a||(a=HG(t)),a.appendChild(c)}}),s(),n.insertBefore(i,t),n.removeChild(t),o}function QG(t,e){var n;if(t.tagName.toLowerCase()===e)return[t];const r=n0(e,t);return yE(t,r),r.innerHTML.trim()||(r.innerHTML="<br>"),(n=t.parentNode)==null||n.replaceChild(r,t),[r]}function $G(t,e){const r=t.parentNode;if(!r)return[];const n=document.createDocumentFragment(),i=[];return Array.from(t.childNodes).forEach(o=>{if(o instanceof HTMLElement&&PG(o)){o.remove();return}if(o instanceof HTMLUListElement||o instanceof HTMLOListElement){Array.from(o.children).forEach(s=>{if(!(s instanceof HTMLLIElement))return;const c=J6(s,e);n.appendChild(c),i.push(c)}),o.remove();return}if(o instanceof HTMLElement&&V6.has(o.tagName)){const s=n0(e,o);yE(o,s),n.appendChild(s),i.push(s);return}if(o.nodeType===Node.TEXT_NODE&&(o.textContent||"").trim()===""){o.remove();return}const a=n0(e,t);a.appendChild(o),n.appendChild(a),i.push(a)}),r.insertBefore(n,t),r.removeChild(t),i}function qG(t){const e=window.getSelection();if(!e)return;const r=document.createRange(),n=t instanceof HTMLElement&&t.querySelector("p,li,h1,h2,h3,h4,h5,h6")||t;r.selectNodeContents(n),r.collapse(!0),e.removeAllRanges(),e.addRange(r)}function WG(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function zG(t,e,r){const n=window.execEditorCommand;if(typeof n=="function"){n("recordDomTransaction",t,e,r);return}const i=window.executeEditorCommand;typeof i=="function"&&i("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:r})}function jG(t,e){const r=new Map;return Array.from(t.querySelectorAll("li")).filter(i=>i instanceof HTMLLIElement&&Z6(e,i)).forEach(i=>{var a;const o=i.parentElement;(o instanceof HTMLUListElement||o instanceof HTMLOListElement)&&o.parentElement===t&&(r.has(o)||r.set(o,new Set),(a=r.get(o))==null||a.add(i))}),r}function bg(t,e){const r=t.toLowerCase();if(!IG.has(r))return!1;const n=NG(e);if(!n)return!1;const i=RG(n);if(!i)return!1;const o=n.innerHTML,a=[],s=jG(n,i);s.size>0?s.forEach((l,u)=>{a.push(...e8(u,l,r))}):OG(n,i).forEach(u=>{if(u instanceof HTMLUListElement||u instanceof HTMLOListElement){const d=new Set(Array.from(u.children).filter(f=>f instanceof HTMLLIElement));a.push(...e8(u,d,r));return}if(V6.has(u.tagName)){const d=u.querySelector(":scope > ul, :scope > ol, :scope > blockquote, :scope > table");a.push(...d?$G(u,r):QG(u,r))}});const c=n.innerHTML;return o===c||a.length===0?!1:(zG(n,o,c),WG(n),qG(a[0]),!0)}const KG=Object.freeze(Object.defineProperty({__proto__:null,HeadingPlugin:()=>({name:"heading",toolbar:[{label:"P",command:"setBlockType",type:"dropdown",options:[{value:"p",label:"P"},{value:"h1",label:"H1"},{value:"h2",label:"H2"},{value:"h3",label:"H3"},{value:"h4",label:"H4"},{value:"h5",label:"H5"},{value:"h6",label:"H6"}],icon:'<svg width="24" height="24" focusable="false"><path d="M16.1 8.6 14.2 4l-1.4.5 2.8 7.4c.1.4.5.6.9.6h.1c.4-.1.6-.5.6-.9l1.8-4.8-1.4-.5-1.5 2.3ZM4 11.5h6V10H4v1.5ZM18.5 3v1L17 7l.9.9L20.7 3h-2.2ZM5.5 12h1v7h1v-7h1v-.5h-3V12Zm4 0h1v7h1v-7h1v-.5h-3V12Zm10 1.5a2 2 0 0 0-2-2h-1v7.5h1v-2.7h1a2 2 0 0 0 2-2v-.8Zm-2 1.3h-1v-2.3h1a.8.8 0 1 1 0 1.6v.7Z" fill-rule="evenodd"></path></svg>'}],commands:{setBlockType:(t,e)=>t?bg(t,e):!1,setHeading1:(t,e)=>bg("h1",e),setHeading2:(t,e)=>bg("h2",e),setHeading3:(t,e)=>bg("h3",e),setParagraph:(t,e)=>bg("p",e)},keymap:{"Mod-Alt-1":"setHeading1","Mod-Alt-2":"setHeading2","Mod-Alt-3":"setHeading3","Mod-Alt-0":"setParagraph"}})},Symbol.toStringTag,{value:"Module"})),vg='.rte-content, .editora-content, [contenteditable="true"]',VG="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",t8=["p","div","h1","h2","h3","h4","h5","h6","ul","ol","blockquote","pre","table"].join(",");function wE(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function GG(t){const e=t==null?void 0:t.contentElement;if(e instanceof HTMLElement)return e;const r=t==null?void 0:t.editorElement;if(r instanceof HTMLElement){const a=r.querySelector(vg);if(a instanceof HTMLElement)return a;if(r.getAttribute("contenteditable")==="true")return r}const n=window.getSelection();if(n&&n.rangeCount>0){const a=wE(n.getRangeAt(0).startContainer),s=a==null?void 0:a.closest(vg);if(s instanceof HTMLElement)return s;const c=a==null?void 0:a.closest(VG),l=c==null?void 0:c.querySelector(vg);if(l instanceof HTMLElement)return l}const i=document.activeElement,o=i==null?void 0:i.closest(vg);return o instanceof HTMLElement?o:document.querySelector(vg)}function XG(t){const e=window.getSelection();if(!e||e.rangeCount===0)return null;const r=e.getRangeAt(0);return!t.contains(r.startContainer)||!t.contains(r.endContainer)?null:r}function r8(t,e){let r=wE(e);if(!r||r===t||!t.contains(r))return null;for(;r.parentElement&&r.parentElement!==t;)r=r.parentElement;if(r.parentElement!==t)return null;if(r.matches(t8))return r;const n=r.closest(t8);return n instanceof HTMLElement&&n.parentElement===t?n:r}function n8(t,e){if(typeof t.intersectsNode=="function")try{return t.intersectsNode(e)}catch(n){return!1}const r=document.createRange();return r.selectNode(e),t.compareBoundaryPoints(Range.END_TO_START,r)<0&&t.compareBoundaryPoints(Range.START_TO_END,r)>0}function YG(t,e){const r=r8(t,e.startContainer),n=r8(t,e.endContainer);if(!r)return[];if(!n||r===n)return[r];const o=Array.from(t.children).filter(a=>a instanceof HTMLElement).filter(a=>n8(e,a));return o.length>0?o:[r]}function i8(t,e){const r=wE(e),n=r==null?void 0:r.closest("blockquote");return n instanceof HTMLQuoteElement&&t.contains(n)?n:null}function ZG(t){return t.tagName!=="P"||t.attributes.length>0||(t.textContent||"").trim()!==""?!1:!t.querySelector("img, video, table, iframe, hr, pre, ul, ol")}function JG(t){Array.from(t.children).forEach(e=>{ZG(e)&&e.remove()})}function xE(t){JG(t);const e=t.parentNode;if(!e)return;Array.from(t.childNodes).forEach(n=>{e.insertBefore(n,t)}),e.removeChild(t)}function o8(t){return t.nodeType===Node.TEXT_NODE&&(t.textContent||"").trim()===""}function a8(t){const e=Array.from(t.childNodes).filter(n=>!o8(n));if(e.length!==1)return null;const r=e[0];return r instanceof HTMLQuoteElement?r:null}function e3(t){const e=document.createElement("blockquote");return Array.from(t.childNodes).filter(n=>!o8(n)).forEach(n=>{e.appendChild(n)}),e.childNodes.length||(e.innerHTML="<br>"),t.appendChild(e),e}function t3(t,e){const r=Array.from(t.querySelectorAll("li")).filter(i=>i instanceof HTMLLIElement&&n8(e,i)),n=new Set(r);return r.filter(i=>{var a,s;let o=(a=i.parentElement)==null?void 0:a.closest("li");for(;o;){if(n.has(o))return!1;o=(s=o.parentElement)==null?void 0:s.closest("li")}return!0})}function yg(t){const e=window.getSelection();if(!e)return;const r=document.createRange(),n=t instanceof HTMLElement&&t.querySelector("p,li,h1,h2,h3,h4,h5,h6")||t;r.selectNodeContents(n),r.collapse(!0),e.removeAllRanges(),e.addRange(r)}function r3(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function n3(t,e,r){const n=window.execEditorCommand;if(typeof n=="function"){n("recordDomTransaction",t,e,r);return}const i=window.executeEditorCommand;typeof i=="function"&&i("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:r})}function i3(t){var u,d;const e=GG(t);if(!e)return!1;const r=XG(e);if(!r)return!1;const n=e.innerHTML,i=i8(e,r.startContainer),o=i8(e,r.endContainer),a=t3(e,r),s=YG(e,r),c=s.length>0&&s.every(f=>f.tagName==="BLOCKQUOTE");if(i&&i===o){const f=i.firstChild||i;xE(i),yg(f)}else if(a.length>0){const f=a.map(a8);if(f.every(Boolean)){const h=((u=f[0])==null?void 0:u.firstChild)||a[0];f.forEach(p=>{p&&xE(p)}),yg(h)}else{const h=a[0];a.forEach(p=>{a8(p)||e3(p)}),yg(h)}}else if(c){const f=s[0].firstChild||s[0];s.forEach(xE),yg(f)}else{const f=s.filter(p=>p.tagName!=="BLOCKQUOTE");if(f.length===0)return!1;const A=document.createElement("blockquote"),h=f[0];(d=h.parentNode)==null||d.insertBefore(A,h),f.forEach(p=>{A.appendChild(p)}),yg(A)}const l=e.innerHTML;return n===l?!1:(n3(e,n,l),r3(e),!0)}const o3=Object.freeze(Object.defineProperty({__proto__:null,BlockquotePlugin:()=>({name:"blockquote",nodes:{blockquote:{content:"block+",group:"block",parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]}},toolbar:[{label:"Quote",command:"toggleBlockquote",icon:'<svg fill="#000000" height="24px" width="24px" version="1.1" id="Icons" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" xml:space="preserve"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <g> <path d="M13,11c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5s-2.2-5-5-5c-0.3,0-0.7,0-1,0.1 C9.3,11.8,11,11,13,11z"></path> <path d="M23,13c-0.3,0-0.7,0-1,0.1c1.3-1.3,3-2.1,5-2.1c0.6,0,1-0.4,1-1s-0.4-1-1-1c-5,0-9,4-9,9c0,2.8,2.2,5,5,5s5-2.2,5-5 S25.8,13,23,13z"></path> </g> </g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleBlockquote:(t,e)=>i3(e)},keymap:{"Mod-Shift-9":"toggleBlockquote"}})},Symbol.toStringTag,{value:"Module"}));let a3=class RV{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(`
10
10
  `)}setText(e){this._lines=e.split(`
11
11
  `),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 r=[];r.push(this.getLine(e.start.line).substring(e.start.column));for(let n=e.start.line+1;n<e.end.line;n++)r.push(this.getLine(n));return e.end.line<this.getLineCount()&&r.push(this.getLine(e.end.line).substring(0,e.end.column)),r.join(`
12
- `)}replaceRange(e,r){const n=this.normalizeRange(e),i=this.getTextInRange(n),o=this.getText(),a=this.positionToOffset(n.start),s=this.positionToOffset(n.end),c=o.slice(0,a)+r+o.slice(s);return this.setText(c),{range:n,text:r,oldText:i}}insertText(e,r){const n={start:e,end:e};return this.replaceRange(n,r)}deleteRange(e){return this.replaceRange(e,"")}positionToOffset(e){let r=0;for(let n=0;n<e.line;n++)r+=this.getLine(n).length+1;return r+=e.column,r}offsetToPosition(e){let r=e;for(let n=0;n<this.getLineCount();n++){const i=this.getLine(n).length;if(r<=i)return{line:n,column:r};r-=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 RV;return e._lines=[...this._lines],e._version=this._version,e}normalizeRange(e){return this.comparePositions(e.start,e.end)<=0?e:{start:e.end,end:e.start}}comparePositions(e,r){return e.line!==r.line?e.line-r.line:e.column-r.column}},s3=class{constructor(e){this.gutterWidth=50,this.lineHeight=21,this.trailingNewlineMarkerAttr="data-lce-trailing-newline-marker",this.foldPlaceholderAttr="data-lce-fold-placeholder",this.virtualMarkerRegex=/[\u200B\uE000]/,this.virtualMarkerGlobalRegex=/[\u200B\uE000]/g,this.lastLineCount=0,this.lastHighlightHTML="",this.highlightOverlayActive=!1,this.lastLineDecorationSnapshot="",this.lastGutterDecorationSnapshot="",this.container=e,this.createDOM()}createDOM(){this.container.innerHTML="";const e=document.createElement("div");this.editorContainer=e,e.setAttribute("data-lce-editor-container","true"),e.style.cssText=`
12
+ `)}replaceRange(e,r){const n=this.normalizeRange(e),i=this.getTextInRange(n),o=this.getText(),a=this.positionToOffset(n.start),s=this.positionToOffset(n.end),c=o.slice(0,a)+r+o.slice(s);return this.setText(c),{range:n,text:r,oldText:i}}insertText(e,r){const n={start:e,end:e};return this.replaceRange(n,r)}deleteRange(e){return this.replaceRange(e,"")}positionToOffset(e){let r=0;for(let n=0;n<e.line;n++)r+=this.getLine(n).length+1;return r+=e.column,r}offsetToPosition(e){let r=e;for(let n=0;n<this.getLineCount();n++){const i=this.getLine(n).length;if(r<=i)return{line:n,column:r};r-=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 RV;return e._lines=[...this._lines],e._version=this._version,e}normalizeRange(e){return this.comparePositions(e.start,e.end)<=0?e:{start:e.end,end:e.start}}comparePositions(e,r){return e.line!==r.line?e.line-r.line:e.column-r.column}},s3=class{constructor(e){this.gutterWidth=50,this.gutterFoldColumnWidth=20,this.gutterFoldColumnGap=4,this.gutterLineNumberPaddingLeft=8,this.gutterLineNumberPaddingRight=4,this.gutterDigitWidth=9,this.lineHeight=21,this.trailingNewlineMarkerAttr="data-lce-trailing-newline-marker",this.foldPlaceholderAttr="data-lce-fold-placeholder",this.virtualMarkerRegex=/[\u200B\uE000]/,this.virtualMarkerGlobalRegex=/[\u200B\uE000]/g,this.lastLineCount=0,this.lastHighlightHTML="",this.highlightOverlayActive=!1,this.lastLineDecorationSnapshot="",this.lastGutterDecorationSnapshot="",this.container=e,this.createDOM()}createDOM(){this.container.innerHTML="";const e=document.createElement("div");this.editorContainer=e,e.setAttribute("data-lce-editor-container","true"),e.style.cssText=`
13
13
  position: relative;
14
14
  display: flex;
15
15
  width: 100%;
@@ -19,20 +19,20 @@
19
19
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
20
20
  font-size: 14px;
21
21
  line-height: ${this.lineHeight}px;
22
- /* vertical scrolling is shared; horizontal scrolling belongs to the code pane */
23
- overflow-x: hidden;
24
- overflow-y: auto;
22
+ overflow: auto;
25
23
  `,this.lineNumbersElement=document.createElement("div"),this.lineNumbersElement.setAttribute("data-editor-gutter","true"),this.lineNumbersElement.style.cssText=`
26
24
  display: table-cell;
27
25
  vertical-align: top;
28
26
  position: sticky;
29
27
  left: 0;
30
28
  width: ${this.gutterWidth}px;
29
+ min-width: ${this.gutterWidth}px;
31
30
  background: var(--editor-gutter-background, #252526);
32
31
  color: var(--editor-gutter-foreground, #858585);
33
- padding: 0 8px 0 0;
32
+ padding: 0;
34
33
  text-align: right;
35
34
  border-right: 1px solid var(--editor-gutter-border, #3e3e42);
35
+ box-sizing: border-box;
36
36
  background-clip: padding-box;
37
37
  user-select: none;
38
38
  overflow: hidden;
@@ -40,6 +40,8 @@
40
40
  `,this.lineNumbersContentElement=document.createElement("div"),this.lineNumbersContentElement.setAttribute("data-editor-gutter-content","true"),this.lineNumbersContentElement.style.cssText=`
41
41
  position: relative;
42
42
  z-index: 1;
43
+ box-sizing: border-box;
44
+ padding: 0 ${this.gutterFoldColumnWidth+this.gutterFoldColumnGap}px 0 ${this.gutterLineNumberPaddingLeft}px;
43
45
  `,this.gutterDecorationsElement=document.createElement("div"),this.gutterDecorationsElement.setAttribute("data-editor-gutter-decorations","true"),this.gutterDecorationsElement.setAttribute("aria-hidden","true"),this.gutterDecorationsElement.style.cssText=`
44
46
  position: absolute;
45
47
  inset: 0;
@@ -50,6 +52,7 @@
50
52
  vertical-align: top;
51
53
  position: relative;
52
54
  width: 100%;
55
+ min-width: max-content;
53
56
  min-height: 400px;
54
57
  `,this.highlightElement=document.createElement("div"),this.highlightElement.setAttribute("data-editor-highlight","true"),this.highlightElement.setAttribute("aria-hidden","true"),this.highlightElement.style.cssText=`
55
58
  position: absolute;
@@ -73,14 +76,16 @@
73
76
  `,this.contentElement=document.createElement("div"),this.contentElement.style.cssText=`
74
77
  position: relative;
75
78
  z-index: 1;
79
+ display: block;
80
+ box-sizing: border-box;
76
81
  padding: 0 12px;
77
82
  background: transparent;
78
83
  border: none;
79
84
  outline: none;
80
85
  white-space: pre;
81
- overflow-x: auto;
82
- overflow-y: visible;
86
+ overflow: visible;
83
87
  width: 100%;
88
+ min-width: max-content;
84
89
  min-height: 400px;
85
90
  font-family: inherit;
86
91
  font-size: inherit;
@@ -92,21 +97,22 @@
92
97
  `,this.contentElement.contentEditable="true",this.contentElement.spellcheck=!1,this.contentElement.tabIndex=0;const n=document.createElement("div");this.scrollWrapper=n,n.setAttribute("data-editora-editor","true"),n.style.cssText=`
93
98
  position: relative;
94
99
  display: table;
95
- table-layout: fixed;
100
+ table-layout: auto;
96
101
  width: 100%;
102
+ min-width: 100%;
97
103
  height: 100%;
98
- `,this.lineNumbersElement.appendChild(this.lineNumbersContentElement),this.lineNumbersElement.appendChild(this.gutterDecorationsElement),n.appendChild(this.lineNumbersElement),r.appendChild(this.lineDecorationsElement),r.appendChild(this.highlightElement),r.appendChild(this.contentElement),n.appendChild(r),e.appendChild(n),this.container.appendChild(e),this.updateLineNumbers(1)}updateLineNumbers(e){if(e===this.lastLineCount)return;this.lastLineCount=e;const r=Math.max(e,1),n=Array.from({length:r},(i,o)=>o+1);this.lineNumbersContentElement.innerHTML=n.map(i=>`<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px; padding-right: 12px;">${i}</div>`).join("")}setDecorations(e,r){this.renderLineDecorations(e),this.renderGutterDecorations(r)}clearDecorations(){this.lastLineDecorationSnapshot&&(this.lineDecorationsElement.innerHTML="",this.lastLineDecorationSnapshot=""),this.lastGutterDecorationSnapshot&&(this.gutterDecorationsElement.innerHTML="",this.lastGutterDecorationSnapshot="")}getContentElement(){return this.contentElement}getLineNumbersElement(){return this.lineNumbersElement}getText(){return this.serializeContentToSource()}setText(e){this.clearHighlightOverlay(),this.setFoldPlaceholderSources(new Map),this.contentElement.textContent!==e&&(this.contentElement.textContent=e),this.syncTrailingNewlineMarker(e.endsWith(`
104
+ `,this.lineNumbersElement.appendChild(this.lineNumbersContentElement),this.lineNumbersElement.appendChild(this.gutterDecorationsElement),n.appendChild(this.lineNumbersElement),r.appendChild(this.lineDecorationsElement),r.appendChild(this.highlightElement),r.appendChild(this.contentElement),n.appendChild(r),e.appendChild(n),this.container.appendChild(e),this.updateLineNumbers(1)}updateLineNumbers(e){if(this.updateGutterWidth(e),e===this.lastLineCount)return;this.lastLineCount=e;const r=Math.max(e,1),n=Array.from({length:r},(i,o)=>o+1);this.lineNumbersContentElement.innerHTML=n.map(i=>`<div style="height: ${this.lineHeight}px; line-height: ${this.lineHeight}px;">${i}</div>`).join("")}updateGutterWidth(e){const r=String(Math.max(e,1)).length*this.gutterDigitWidth+this.gutterLineNumberPaddingLeft+this.gutterLineNumberPaddingRight,n=Math.ceil(r+this.gutterFoldColumnGap+this.gutterFoldColumnWidth);n!==this.gutterWidth&&(this.gutterWidth=n,this.lineNumbersElement.style.display!=="none"&&(this.lineNumbersElement.style.width=`${this.gutterWidth}px`,this.lineNumbersElement.style.minWidth=`${this.gutterWidth}px`))}setDecorations(e,r){this.renderLineDecorations(e),this.renderGutterDecorations(r)}clearDecorations(){this.lastLineDecorationSnapshot&&(this.lineDecorationsElement.innerHTML="",this.lastLineDecorationSnapshot=""),this.lastGutterDecorationSnapshot&&(this.gutterDecorationsElement.innerHTML="",this.lastGutterDecorationSnapshot="")}getContentElement(){return this.contentElement}getLineNumbersElement(){return this.lineNumbersElement}getText(){return this.serializeContentToSource()}setText(e){this.clearHighlightOverlay(),this.setFoldPlaceholderSources(new Map),this.contentElement.textContent!==e&&(this.contentElement.textContent=e),this.syncTrailingNewlineMarker(e.endsWith(`
99
105
  `));const r=e.split(`
100
106
  `).length;this.updateLineNumbers(r)}setHTML(e){this.clearHighlightOverlay(),this.setFoldPlaceholderSources(new Map);const r=/\n$/.test(e),n=/&lt;|&gt;/.test(e),i=/<span\b/i.test(e),o=/<[^>]+>/.test(e);n&&i?this.contentElement.innerHTML=e:o&&!n?this.contentElement.textContent=e:this.contentElement.innerHTML=e,this.syncTrailingNewlineMarker(r);const a=(this.contentElement.textContent||"").split(`
101
107
  `).length;this.updateLineNumbers(a)}setHighlightHTML(e){e!==this.lastHighlightHTML&&(this.highlightElement.innerHTML=e,this.lastHighlightHTML=e),this.highlightElement.style.visibility="visible",this.highlightOverlayActive=!0,this.contentElement.style.color="transparent",this.contentElement.style.WebkitTextFillColor="transparent";const r=(this.contentElement.textContent||"").split(`
102
- `).length;this.updateLineNumbers(r)}setLineWrapping(e){this.contentElement.style.whiteSpace=e?"pre-wrap":"pre",this.contentElement.style.overflowX=e?"hidden":"auto",this.contentElement.style.overflowY="visible",this.contentElement.style.wordBreak="normal",this.contentElement.style.overflowWrap=e?"anywhere":"normal",this.highlightElement.style.whiteSpace=e?"pre-wrap":"pre",this.highlightElement.style.wordBreak="normal",this.highlightElement.style.overflowWrap=e?"anywhere":"normal"}setLineNumbersVisible(e){this.lineNumbersElement.style.display=e?"table-cell":"none",this.lineNumbersElement.style.width=e?`${this.gutterWidth}px`:"0",this.lineNumbersElement.style.paddingRight=e?"8px":"0",this.lineNumbersElement.style.borderRightWidth=e?"1px":"0",this.scrollWrapper.style.width=e?"100%":"auto"}setTabSize(e){const r=Math.max(1,Math.floor(e)||2);this.contentElement.style.tabSize=String(r),this.contentElement.style.MozTabSize=String(r),this.highlightElement.style.tabSize=String(r),this.highlightElement.style.MozTabSize=String(r)}syncTrailingNewlineMarkerForText(e){this.syncTrailingNewlineMarker(e.endsWith(`
103
- `))}getCursorPosition(){var e;return(e=this.getSelectionState().cursor)!=null?e:{line:0,column:0}}setCursorPosition(e){const r=this.getText(),n=this.positionToTextOffset(e,r),i=window.getSelection(),o=this.createDomRangeFromOffsets(n);if(o)try{i==null||i.removeAllRanges(),i==null||i.addRange(o),this.ensureCaretVisible()}catch(a){console.warn("Could not set cursor position:",a)}else{const a=this.contentElement.querySelector(`[${this.trailingNewlineMarkerAttr}]`),s=document.createRange();try{a&&a.parentNode===this.contentElement?s.setStartBefore(a):(s.selectNodeContents(this.contentElement),s.collapse(!1)),s.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(s),this.ensureCaretVisible()}catch(c){console.warn("Could not set fallback cursor position:",c)}}}getSelectionRange(){return this.getSelectionState().range}getSelectionOffsets(){const e=window.getSelection();if(!e||e.rangeCount===0)return{isInEditor:!1,isCollapsed:!0,startOffset:0,endOffset:0};const r=e.getRangeAt(0);if(!this.isNodeInsideContent(r.startContainer)||!this.isNodeInsideContent(r.endContainer))return{isInEditor:!1,isCollapsed:e.isCollapsed,startOffset:0,endOffset:0};const n=e.anchorNode&&this.isNodeInsideContent(e.anchorNode)?this.sourceOffsetFromBoundary(e.anchorNode,e.anchorOffset):void 0,i=e.focusNode&&this.isNodeInsideContent(e.focusNode)?this.sourceOffsetFromBoundary(e.focusNode,e.focusOffset):void 0;return{isInEditor:!0,isCollapsed:e.isCollapsed,startOffset:this.sourceOffsetFromBoundary(r.startContainer,r.startOffset),endOffset:this.sourceOffsetFromBoundary(r.endContainer,r.endOffset),anchorOffset:n,focusOffset:i}}getSelectionState(){const e=window.getSelection();if(!e||e.rangeCount===0)return{isInEditor:!1,isCollapsed:!0};const r=e.getRangeAt(0);if(!this.isNodeInsideContent(r.startContainer)||!this.isNodeInsideContent(r.endContainer))return{isInEditor:!1,isCollapsed:e.isCollapsed};const n=this.getText(),i=this.sourceOffsetFromBoundary(r.startContainer,r.startOffset),o=this.sourceOffsetFromBoundary(r.endContainer,r.endOffset),a=e.focusNode&&this.isNodeInsideContent(e.focusNode)?this.sourceOffsetFromBoundary(e.focusNode,e.focusOffset):o,s=this.offsetToPositionInText(i,n),c=this.offsetToPositionInText(o,n),l=this.offsetToPositionInText(a,n);return{isInEditor:!0,isCollapsed:e.isCollapsed,cursor:l,range:e.isCollapsed?void 0:{start:s,end:c}}}setSelectionRange(e){const r=this.createDomRangeFromRange(e);if(r)try{const n=window.getSelection();n==null||n.removeAllRanges(),n==null||n.addRange(r),this.ensureCaretVisible()}catch(n){console.warn("Could not set selection range:",n)}}createDomRangeFromOffsets(e,r=e){const[n,i]=e<=r?[e,r]:[r,e],o=this.resolveOffsetToDomPoint(n),a=this.resolveOffsetToDomPoint(i);if(!o||!a)return null;const s=document.createRange();try{return s.setStart(o.node,o.offset),s.setEnd(a.node,a.offset),s}catch(c){return null}}createDomRangeFromRange(e){const r=this.getText();return this.createDomRangeFromOffsets(this.positionToTextOffset(e.start,r),this.positionToTextOffset(e.end,r))}getPositionFromClientPoint(e,r){const n=this.getDomRangeFromClientPoint(e,r);if(!n||!this.isNodeInsideContent(n.startContainer))return null;const i=this.sourceOffsetFromBoundary(n.startContainer,n.startOffset);return this.offsetToPositionInText(i,this.getText())}setSelectionOffsets(e,r=e){const n=this.createDomRangeFromOffsets(e,r);if(n)try{const i=window.getSelection();i==null||i.removeAllRanges(),i==null||i.addRange(n),this.ensureCaretVisible()}catch(i){console.warn("Could not set selection offsets:",i)}}setSelectionBoundaryOffsets(e,r){const n=this.resolveOffsetToDomPoint(e),i=this.resolveOffsetToDomPoint(r),o=window.getSelection();if(!n||!i||!o){this.setSelectionOffsets(e,r);return}try{if(o.removeAllRanges(),e===r){const s=document.createRange();s.setStart(n.node,n.offset),s.collapse(!0),o.addRange(s),this.ensureCaretVisible();return}if(typeof o.extend=="function"){const s=document.createRange();s.setStart(n.node,n.offset),s.collapse(!0),o.addRange(s),o.extend(i.node,i.offset),this.ensureCaretVisible();return}const a=this.createDomRangeFromOffsets(e,r);if(!a)return;o.addRange(a),this.ensureCaretVisible()}catch(a){console.warn("Could not set selection boundary offsets:",a),this.setSelectionOffsets(e,r)}}focus(){this.contentElement.focus(),this.ensureCaretVisible()}blur(){this.contentElement.blur()}setReadOnly(e){this.contentElement.contentEditable=e?"false":"true"}applyTheme(e){Object.entries(e).forEach(([r,n])=>{this.container.style.setProperty(`--${r}`,n)})}scrollToPosition(e){const r=this.lineNumbersElement.children[e.line];r&&r.scrollIntoView({block:"center",behavior:"smooth"})}getScrollTop(){return this.editorContainer.scrollTop}getScrollElement(){return this.editorContainer}setScrollTop(e){this.editorContainer.scrollTop=e}syncTrailingNewlineMarker(e){if(this.contentElement.querySelectorAll(`[${this.trailingNewlineMarkerAttr}]`).forEach(n=>n.remove()),!e)return;const r=document.createElement("span");r.setAttribute(this.trailingNewlineMarkerAttr,"true"),r.setAttribute("aria-hidden","true"),r.contentEditable="false",r.style.cssText=`
108
+ `).length;this.updateLineNumbers(r)}setLineWrapping(e){this.contentElement.style.whiteSpace=e?"pre-wrap":"pre",this.contentElement.style.overflow="visible",this.contentElement.style.minWidth=e?"100%":"max-content",this.contentSurface.style.minWidth=e?"100%":"max-content",this.contentElement.style.wordBreak="normal",this.contentElement.style.overflowWrap=e?"anywhere":"normal",this.highlightElement.style.whiteSpace=e?"pre-wrap":"pre",this.highlightElement.style.wordBreak="normal",this.highlightElement.style.overflowWrap=e?"anywhere":"normal"}setLineNumbersVisible(e){this.lineNumbersElement.style.display=e?"table-cell":"none",this.lineNumbersElement.style.width=e?`${this.gutterWidth}px`:"0",this.lineNumbersElement.style.minWidth=e?`${this.gutterWidth}px`:"0",this.lineNumbersElement.style.borderRightWidth=e?"1px":"0",this.scrollWrapper.style.width="100%",this.scrollWrapper.style.minWidth="100%"}setTabSize(e){const r=Math.max(1,Math.floor(e)||2);this.contentElement.style.tabSize=String(r),this.contentElement.style.MozTabSize=String(r),this.highlightElement.style.tabSize=String(r),this.highlightElement.style.MozTabSize=String(r)}syncTrailingNewlineMarkerForText(e){this.syncTrailingNewlineMarker(e.endsWith(`
109
+ `))}getCursorPosition(){var e;return(e=this.getSelectionState().cursor)!=null?e:{line:0,column:0}}setCursorPosition(e){const r=this.getText(),n=this.positionToTextOffset(e,r),i=window.getSelection(),o=this.createDomRangeFromOffsets(n);if(o)try{i==null||i.removeAllRanges(),i==null||i.addRange(o),this.ensureCaretVisible()}catch(a){console.warn("Could not set cursor position:",a)}else{const a=this.contentElement.querySelector(`[${this.trailingNewlineMarkerAttr}]`),s=document.createRange();try{a&&a.parentNode===this.contentElement?s.setStartBefore(a):(s.selectNodeContents(this.contentElement),s.collapse(!1)),s.collapse(!0),i==null||i.removeAllRanges(),i==null||i.addRange(s),this.ensureCaretVisible()}catch(c){console.warn("Could not set fallback cursor position:",c)}}}getSelectionRange(){return this.getSelectionState().range}getSelectionOffsets(){const e=window.getSelection();if(!e||e.rangeCount===0)return{isInEditor:!1,isCollapsed:!0,startOffset:0,endOffset:0};const r=e.getRangeAt(0);if(!this.isNodeInsideContent(r.startContainer)||!this.isNodeInsideContent(r.endContainer))return{isInEditor:!1,isCollapsed:e.isCollapsed,startOffset:0,endOffset:0};const n=e.anchorNode&&this.isNodeInsideContent(e.anchorNode)?this.sourceOffsetFromBoundary(e.anchorNode,e.anchorOffset):void 0,i=e.focusNode&&this.isNodeInsideContent(e.focusNode)?this.sourceOffsetFromBoundary(e.focusNode,e.focusOffset):void 0;return{isInEditor:!0,isCollapsed:e.isCollapsed,startOffset:this.sourceOffsetFromBoundary(r.startContainer,r.startOffset),endOffset:this.sourceOffsetFromBoundary(r.endContainer,r.endOffset),anchorOffset:n,focusOffset:i}}getSelectionState(){const e=window.getSelection();if(!e||e.rangeCount===0)return{isInEditor:!1,isCollapsed:!0};const r=e.getRangeAt(0);if(!this.isNodeInsideContent(r.startContainer)||!this.isNodeInsideContent(r.endContainer))return{isInEditor:!1,isCollapsed:e.isCollapsed};const n=this.getText(),i=this.sourceOffsetFromBoundary(r.startContainer,r.startOffset),o=this.sourceOffsetFromBoundary(r.endContainer,r.endOffset),a=e.focusNode&&this.isNodeInsideContent(e.focusNode)?this.sourceOffsetFromBoundary(e.focusNode,e.focusOffset):o,s=this.offsetToPositionInText(i,n),c=this.offsetToPositionInText(o,n),l=this.offsetToPositionInText(a,n);return{isInEditor:!0,isCollapsed:e.isCollapsed,cursor:l,range:e.isCollapsed?void 0:{start:s,end:c}}}setSelectionRange(e){const r=this.createDomRangeFromRange(e);if(r)try{const n=window.getSelection();n==null||n.removeAllRanges(),n==null||n.addRange(r),this.ensureCaretVisible()}catch(n){console.warn("Could not set selection range:",n)}}createDomRangeFromOffsets(e,r=e){const[n,i]=e<=r?[e,r]:[r,e],o=this.resolveOffsetToDomPoint(n),a=this.resolveOffsetToDomPoint(i);if(!o||!a)return null;const s=document.createRange();try{return s.setStart(o.node,o.offset),s.setEnd(a.node,a.offset),s}catch(c){return null}}createDomRangeFromRange(e){const r=this.getText();return this.createDomRangeFromOffsets(this.positionToTextOffset(e.start,r),this.positionToTextOffset(e.end,r))}getPositionFromClientPoint(e,r){const n=this.getDomRangeFromClientPoint(e,r);if(!n||!this.isNodeInsideContent(n.startContainer))return null;const i=this.sourceOffsetFromBoundary(n.startContainer,n.startOffset);return this.offsetToPositionInText(i,this.getText())}setSelectionOffsets(e,r=e){const n=this.createDomRangeFromOffsets(e,r);if(n)try{const i=window.getSelection();i==null||i.removeAllRanges(),i==null||i.addRange(n),this.ensureCaretVisible()}catch(i){console.warn("Could not set selection offsets:",i)}}setSelectionBoundaryOffsets(e,r){const n=this.resolveOffsetToDomPoint(e),i=this.resolveOffsetToDomPoint(r),o=window.getSelection();if(!n||!i||!o){this.setSelectionOffsets(e,r);return}try{if(o.removeAllRanges(),e===r){const s=document.createRange();s.setStart(n.node,n.offset),s.collapse(!0),o.addRange(s),this.ensureCaretVisible();return}if(typeof o.extend=="function"){const s=document.createRange();s.setStart(n.node,n.offset),s.collapse(!0),o.addRange(s),o.extend(i.node,i.offset),this.ensureCaretVisible();return}const a=this.createDomRangeFromOffsets(e,r);if(!a)return;o.addRange(a),this.ensureCaretVisible()}catch(a){console.warn("Could not set selection boundary offsets:",a),this.setSelectionOffsets(e,r)}}focus(){this.contentElement.focus(),this.ensureCaretVisible()}blur(){this.contentElement.blur()}setReadOnly(e){this.contentElement.contentEditable=e?"false":"true"}applyTheme(e){Object.entries(e).forEach(([r,n])=>{this.container.style.setProperty(`--${r}`,n)})}scrollToPosition(e){const r=Math.max(0,Math.floor(e.line)||0)*this.lineHeight-this.editorContainer.clientHeight/2+this.lineHeight/2;this.editorContainer.scrollTop=Math.max(0,r)}getScrollTop(){return this.editorContainer.scrollTop}getScrollElement(){return this.editorContainer}setScrollTop(e){this.editorContainer.scrollTop=e}syncTrailingNewlineMarker(e){if(this.contentElement.querySelectorAll(`[${this.trailingNewlineMarkerAttr}]`).forEach(n=>n.remove()),!e)return;const r=document.createElement("span");r.setAttribute(this.trailingNewlineMarkerAttr,"true"),r.setAttribute("aria-hidden","true"),r.contentEditable="false",r.style.cssText=`
104
110
  display: inline-block;
105
111
  width: 0;
106
112
  overflow: hidden;
107
113
  pointer-events: none;
108
114
  user-select: none;
109
- `,r.appendChild(document.createTextNode("​")),this.contentElement.appendChild(r)}ensureCaretVisible(){const e=window.getSelection();if(!e||e.rangeCount===0)return;const r=this.getCaretClientRect(e);if(!r)return;const n=this.editorContainer.getBoundingClientRect(),i=12;r.bottom>n.bottom-i?this.editorContainer.scrollTop+=r.bottom-(n.bottom-i):r.top<n.top+i&&(this.editorContainer.scrollTop-=n.top+i-r.top)}destroy(){this.clearDecorations(),this.container&&(this.container.innerHTML=""),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=void 0)}resolveOffsetToDomPoint(e){var o;const r=Math.max(0,e);let n=0;const i=Array.from(this.contentElement.childNodes);for(let a=0;a<i.length;a++){const s=i[a];if(s instanceof Text){const c=s.textContent||"",l=this.buildVisibleToDomMap(c),u=Math.max(0,l.length-1);if(n+u>=r){const d=Math.max(0,r-n),f=(o=l[d])!=null?o:c.length;return{node:s,offset:f}}n+=u;continue}if(s instanceof HTMLElement&&!s.hasAttribute(this.trailingNewlineMarkerAttr)&&s.hasAttribute(this.foldPlaceholderAttr)){const c=this.getFoldPlaceholderSource(s).length;if(n+c>=r){const l=r-n;return{node:this.contentElement,offset:l<=c/2?a:a+1}}n+=c}}return{node:this.contentElement,offset:this.contentElement.childNodes.length}}getDomRangeFromClientPoint(e,r){const n=document;if(typeof n.caretPositionFromPoint=="function"){const i=n.caretPositionFromPoint(e,r);if(i!=null&&i.offsetNode){const o=document.createRange();try{return o.setStart(i.offsetNode,i.offset),o.collapse(!0),o}catch(a){return null}}}return typeof n.caretRangeFromPoint=="function"?n.caretRangeFromPoint(e,r):null}buildVisibleToDomMap(e){const r=[0];let n=0;for(let i=0;i<e.length;i++){const o=e[i];this.virtualMarkerRegex.test(o)||(n+=1,r[n]=i+1)}return r}isNodeInsideContent(e){return e===this.contentElement||this.contentElement.contains(e)}getCaretClientRect(e){var s,c,l;const r=e.getRangeAt(0).cloneRange();r.collapse(!1);const n=this.getUsableRangeRect(r);if(n)return n;const i=e.focusNode,o=e.focusOffset;if(i instanceof Text){const u=(c=(s=i.textContent)==null?void 0:s.length)!=null?c:0,d=document.createRange();if(o<u){d.setStart(i,o),d.setEnd(i,Math.min(u,o+1));const f=this.getUsableRangeRect(d);if(f)return f}if(o>0){d.setStart(i,o-1),d.setEnd(i,o);const f=this.getUsableRangeRect(d);if(f)return f}}const a=i instanceof Element?i:(l=i==null?void 0:i.parentElement)!=null?l:null;if(a&&a!==this.contentElement&&a!==this.editorContainer&&this.contentElement.contains(a)){const u=a.getBoundingClientRect();if(this.isUsableRect(u))return u}return null}getUsableRangeRect(e){const r=Array.from(e.getClientRects());for(let i=0;i<r.length;i++)if(this.isUsableRect(r[i]))return r[i];const n=e.getBoundingClientRect();return this.isUsableRect(n)?n:null}isUsableRect(e){return!!e&&Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&(e.width>0||e.height>0)}stripVirtualMarkers(e){return e.replace(this.virtualMarkerGlobalRegex,"")}clearHighlightOverlay(){!this.highlightOverlayActive&&!this.lastHighlightHTML||(this.highlightElement.innerHTML="",this.highlightElement.style.visibility="hidden",this.lastHighlightHTML="",this.highlightOverlayActive=!1,this.contentElement.style.color="inherit",this.contentElement.style.WebkitTextFillColor="currentcolor")}serializeContentToSource(){let e="";const r=Array.from(this.contentElement.childNodes);for(const n of r){if(n instanceof Text){e+=this.stripVirtualMarkers(n.textContent||"");continue}if(n instanceof HTMLElement&&!n.hasAttribute(this.trailingNewlineMarkerAttr)){if(n.hasAttribute(this.foldPlaceholderAttr)){e+=this.getFoldPlaceholderSource(n);continue}e+=this.stripVirtualMarkers(n.textContent||"")}}return e}sourceOffsetFromBoundary(e,r){let n=0;const i=Array.from(this.contentElement.childNodes);if(e===this.contentElement){for(let o=0;o<Math.min(r,i.length);o++)n+=this.getSourceLength(i[o]);return n}for(let o=0;o<i.length;o++){const a=i[o];if(a===e){if(a instanceof Text)return n+this.stripVirtualMarkers((a.textContent||"").slice(0,r)).length;if(a instanceof HTMLElement){if(a.hasAttribute(this.foldPlaceholderAttr))return n+this.getFoldPlaceholderBoundaryOffset(a,a,r);const s=Array.from(a.childNodes);for(let c=0;c<Math.min(r,s.length);c++)n+=this.getSourceLength(s[c]);return n}}if(a instanceof HTMLElement&&a.contains(e))return a.hasAttribute(this.foldPlaceholderAttr)?n+this.getFoldPlaceholderBoundaryOffset(a,e,r):n+this.sourceOffsetWithinNode(a,e,r);n+=this.getSourceLength(a)}return n}sourceOffsetWithinNode(e,r,n){let i=0;const o=Array.from(e.childNodes);if(r===e){for(let a=0;a<Math.min(n,o.length);a++)i+=this.getSourceLength(o[a]);return i}for(let a=0;a<o.length;a++){const s=o[a];if(s===r){if(s instanceof Text)return i+this.stripVirtualMarkers((s.textContent||"").slice(0,n)).length;if(s instanceof HTMLElement){if(s.hasAttribute(this.foldPlaceholderAttr))return i+this.getFoldPlaceholderBoundaryOffset(s,s,n);const c=Array.from(s.childNodes);for(let l=0;l<Math.min(n,c.length);l++)i+=this.getSourceLength(c[l]);return i}}if(s instanceof HTMLElement&&s.contains(r))return s.hasAttribute(this.foldPlaceholderAttr)?i+this.getFoldPlaceholderBoundaryOffset(s,r,n):i+this.sourceOffsetWithinNode(s,r,n);i+=this.getSourceLength(s)}return i}getSourceLength(e){if(e instanceof Text)return this.stripVirtualMarkers(e.textContent||"").length;if(!(e instanceof HTMLElement)||e.hasAttribute(this.trailingNewlineMarkerAttr))return 0;if(e.hasAttribute(this.foldPlaceholderAttr))return this.getFoldPlaceholderSource(e).length;let r=0;return e.childNodes.forEach(n=>{r+=this.getSourceLength(n)}),r}renderLineDecorations(e){const r=[...e].filter(o=>Number.isFinite(o.line)&&o.line>=0).sort((o,a)=>o.line-a.line||o.id.localeCompare(a.id)),n=r.map(o=>`${o.id}:${o.line}:${o.className||""}:${this.serializeStyleObject(o.style)}`).join("|");if(n===this.lastLineDecorationSnapshot||(this.lineDecorationsElement.innerHTML="",this.lastLineDecorationSnapshot=n,r.length===0))return;const i=document.createDocumentFragment();for(const o of r){const a=document.createElement("div");a.className=this.joinClassNames("lce-decoration lce-decoration-line",o.className),a.setAttribute("data-decoration-id",o.id),a.setAttribute("data-decoration-line",String(o.line)),a.style.cssText=this.joinStyleFragments(["position: absolute",`top: ${o.line*this.lineHeight}px`,`height: ${this.lineHeight}px`,"left: 12px","right: 12px","border-radius: 3px",this.serializeStyleObject(o.style)]),i.appendChild(a)}this.lineDecorationsElement.appendChild(i)}renderGutterDecorations(e){const r=[...e].filter(o=>Number.isFinite(o.line)&&o.line>=0).sort((o,a)=>o.line-a.line||o.id.localeCompare(a.id)),n=r.map(o=>`${o.id}:${o.line}:${o.label||""}:${o.title||""}:${o.className||""}:${this.serializeStyleObject(o.style)}`).join("|");if(n===this.lastGutterDecorationSnapshot||(this.gutterDecorationsElement.innerHTML="",this.lastGutterDecorationSnapshot=n,r.length===0))return;const i=document.createDocumentFragment();for(const o of r){const a=document.createElement("div");a.className=this.joinClassNames("lce-decoration lce-decoration-gutter",o.className),a.setAttribute("data-decoration-id",o.id),a.setAttribute("data-decoration-line",String(o.line)),a.style.cssText=this.joinStyleFragments(["position: absolute",`top: ${o.line*this.lineHeight}px`,`height: ${this.lineHeight}px`,"left: 0","right: 0","display: flex","align-items: center","justify-content: flex-end","padding-right: 4px","box-sizing: border-box",this.serializeStyleObject(o.style)]),o.title&&(a.title=o.title),a.textContent=o.label||"",i.appendChild(a)}this.gutterDecorationsElement.appendChild(i)}joinClassNames(...e){return e.filter(Boolean).join(" ").trim()}joinStyleFragments(e){return e.filter(r=>!!r&&r.trim().length>0).map(r=>{const n=r.trim();return n.endsWith(";")?n:`${n};`}).join(" ")}serializeStyleObject(e){return e?Object.entries(e).filter(([,r])=>typeof r=="string"&&r.length>0).map(([r,n])=>`${this.toKebabCase(r)}: ${n}`).join("; "):""}toKebabCase(e){return e.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`)}offsetToPositionInText(e,r){const n=Math.max(0,Math.min(e,r.length)),i=r.slice(0,n).split(`
115
+ `,r.appendChild(document.createTextNode("​")),this.contentElement.appendChild(r)}ensureCaretVisible(){const e=window.getSelection();if(!e||e.rangeCount===0)return;const r=this.getCaretClientRect(e);if(!r)return;const n=this.editorContainer.getBoundingClientRect(),i=12;r.bottom>n.bottom-i?this.editorContainer.scrollTop+=r.bottom-(n.bottom-i):r.top<n.top+i&&(this.editorContainer.scrollTop-=n.top+i-r.top),r.right>n.right-i?this.editorContainer.scrollLeft+=r.right-(n.right-i):r.left<n.left+i&&(this.editorContainer.scrollLeft-=n.left+i-r.left)}destroy(){this.clearDecorations(),this.container&&(this.container.innerHTML=""),this._rafId&&(cancelAnimationFrame(this._rafId),this._rafId=void 0)}resolveOffsetToDomPoint(e){var o;const r=Math.max(0,e);let n=0;const i=Array.from(this.contentElement.childNodes);for(let a=0;a<i.length;a++){const s=i[a];if(s instanceof Text){const c=s.textContent||"",l=this.buildVisibleToDomMap(c),u=Math.max(0,l.length-1);if(n+u>=r){const d=Math.max(0,r-n),f=(o=l[d])!=null?o:c.length;return{node:s,offset:f}}n+=u;continue}if(s instanceof HTMLElement&&!s.hasAttribute(this.trailingNewlineMarkerAttr)&&s.hasAttribute(this.foldPlaceholderAttr)){const c=this.getFoldPlaceholderSource(s).length;if(n+c>=r){const l=r-n;return{node:this.contentElement,offset:l<=c/2?a:a+1}}n+=c}}return{node:this.contentElement,offset:this.contentElement.childNodes.length}}getDomRangeFromClientPoint(e,r){const n=document;if(typeof n.caretPositionFromPoint=="function"){const i=n.caretPositionFromPoint(e,r);if(i!=null&&i.offsetNode){const o=document.createRange();try{return o.setStart(i.offsetNode,i.offset),o.collapse(!0),o}catch(a){return null}}}return typeof n.caretRangeFromPoint=="function"?n.caretRangeFromPoint(e,r):null}buildVisibleToDomMap(e){const r=[0];let n=0;for(let i=0;i<e.length;i++){const o=e[i];this.virtualMarkerRegex.test(o)||(n+=1,r[n]=i+1)}return r}isNodeInsideContent(e){return e===this.contentElement||this.contentElement.contains(e)}getCaretClientRect(e){var s,c,l;const r=e.getRangeAt(0).cloneRange();r.collapse(!1);const n=this.getUsableRangeRect(r);if(n)return n;const i=e.focusNode,o=e.focusOffset;if(i instanceof Text){const u=(c=(s=i.textContent)==null?void 0:s.length)!=null?c:0,d=document.createRange();if(o<u){d.setStart(i,o),d.setEnd(i,Math.min(u,o+1));const f=this.getUsableRangeRect(d);if(f)return f}if(o>0){d.setStart(i,o-1),d.setEnd(i,o);const f=this.getUsableRangeRect(d);if(f)return f}}const a=i instanceof Element?i:(l=i==null?void 0:i.parentElement)!=null?l:null;if(a&&a!==this.contentElement&&a!==this.editorContainer&&this.contentElement.contains(a)){const u=a.getBoundingClientRect();if(this.isUsableRect(u))return u}return null}getUsableRangeRect(e){const r=Array.from(e.getClientRects());for(let i=0;i<r.length;i++)if(this.isUsableRect(r[i]))return r[i];const n=e.getBoundingClientRect();return this.isUsableRect(n)?n:null}isUsableRect(e){return!!e&&Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&(e.width>0||e.height>0)}stripVirtualMarkers(e){return e.replace(this.virtualMarkerGlobalRegex,"")}clearHighlightOverlay(){!this.highlightOverlayActive&&!this.lastHighlightHTML||(this.highlightElement.innerHTML="",this.highlightElement.style.visibility="hidden",this.lastHighlightHTML="",this.highlightOverlayActive=!1,this.contentElement.style.color="inherit",this.contentElement.style.WebkitTextFillColor="currentcolor")}serializeContentToSource(){let e="";const r=Array.from(this.contentElement.childNodes);for(const n of r){if(n instanceof Text){e+=this.stripVirtualMarkers(n.textContent||"");continue}if(n instanceof HTMLElement&&!n.hasAttribute(this.trailingNewlineMarkerAttr)){if(n.hasAttribute(this.foldPlaceholderAttr)){e+=this.getFoldPlaceholderSource(n);continue}e+=this.stripVirtualMarkers(n.textContent||"")}}return e}sourceOffsetFromBoundary(e,r){let n=0;const i=Array.from(this.contentElement.childNodes);if(e===this.contentElement){for(let o=0;o<Math.min(r,i.length);o++)n+=this.getSourceLength(i[o]);return n}for(let o=0;o<i.length;o++){const a=i[o];if(a===e){if(a instanceof Text)return n+this.stripVirtualMarkers((a.textContent||"").slice(0,r)).length;if(a instanceof HTMLElement){if(a.hasAttribute(this.foldPlaceholderAttr))return n+this.getFoldPlaceholderBoundaryOffset(a,a,r);const s=Array.from(a.childNodes);for(let c=0;c<Math.min(r,s.length);c++)n+=this.getSourceLength(s[c]);return n}}if(a instanceof HTMLElement&&a.contains(e))return a.hasAttribute(this.foldPlaceholderAttr)?n+this.getFoldPlaceholderBoundaryOffset(a,e,r):n+this.sourceOffsetWithinNode(a,e,r);n+=this.getSourceLength(a)}return n}sourceOffsetWithinNode(e,r,n){let i=0;const o=Array.from(e.childNodes);if(r===e){for(let a=0;a<Math.min(n,o.length);a++)i+=this.getSourceLength(o[a]);return i}for(let a=0;a<o.length;a++){const s=o[a];if(s===r){if(s instanceof Text)return i+this.stripVirtualMarkers((s.textContent||"").slice(0,n)).length;if(s instanceof HTMLElement){if(s.hasAttribute(this.foldPlaceholderAttr))return i+this.getFoldPlaceholderBoundaryOffset(s,s,n);const c=Array.from(s.childNodes);for(let l=0;l<Math.min(n,c.length);l++)i+=this.getSourceLength(c[l]);return i}}if(s instanceof HTMLElement&&s.contains(r))return s.hasAttribute(this.foldPlaceholderAttr)?i+this.getFoldPlaceholderBoundaryOffset(s,r,n):i+this.sourceOffsetWithinNode(s,r,n);i+=this.getSourceLength(s)}return i}getSourceLength(e){if(e instanceof Text)return this.stripVirtualMarkers(e.textContent||"").length;if(!(e instanceof HTMLElement)||e.hasAttribute(this.trailingNewlineMarkerAttr))return 0;if(e.hasAttribute(this.foldPlaceholderAttr))return this.getFoldPlaceholderSource(e).length;let r=0;return e.childNodes.forEach(n=>{r+=this.getSourceLength(n)}),r}renderLineDecorations(e){const r=[...e].filter(o=>Number.isFinite(o.line)&&o.line>=0).sort((o,a)=>o.line-a.line||o.id.localeCompare(a.id)),n=r.map(o=>`${o.id}:${o.line}:${o.className||""}:${this.serializeStyleObject(o.style)}`).join("|");if(n===this.lastLineDecorationSnapshot||(this.lineDecorationsElement.innerHTML="",this.lastLineDecorationSnapshot=n,r.length===0))return;const i=document.createDocumentFragment();for(const o of r){const a=document.createElement("div");a.className=this.joinClassNames("lce-decoration lce-decoration-line",o.className),a.setAttribute("data-decoration-id",o.id),a.setAttribute("data-decoration-line",String(o.line)),a.style.cssText=this.joinStyleFragments(["position: absolute",`top: ${o.line*this.lineHeight}px`,`height: ${this.lineHeight}px`,"left: 12px","right: 12px","border-radius: 3px",this.serializeStyleObject(o.style)]),i.appendChild(a)}this.lineDecorationsElement.appendChild(i)}renderGutterDecorations(e){const r=[...e].filter(o=>Number.isFinite(o.line)&&o.line>=0).sort((o,a)=>o.line-a.line||o.id.localeCompare(a.id)),n=r.map(o=>`${o.id}:${o.line}:${o.label||""}:${o.title||""}:${o.className||""}:${this.serializeStyleObject(o.style)}`).join("|");if(n===this.lastGutterDecorationSnapshot||(this.gutterDecorationsElement.innerHTML="",this.lastGutterDecorationSnapshot=n,r.length===0))return;const i=document.createDocumentFragment();for(const o of r){const a=document.createElement("div");a.className=this.joinClassNames("lce-decoration lce-decoration-gutter",o.className),a.setAttribute("data-decoration-id",o.id),a.setAttribute("data-decoration-line",String(o.line)),a.style.cssText=this.joinStyleFragments(["position: absolute",`top: ${o.line*this.lineHeight}px`,`height: ${this.lineHeight}px`,"left: 0","right: 0","display: flex","align-items: center","justify-content: flex-end","padding-right: 4px","box-sizing: border-box",this.serializeStyleObject(o.style)]),o.title&&(a.title=o.title),a.textContent=o.label||"",i.appendChild(a)}this.gutterDecorationsElement.appendChild(i)}joinClassNames(...e){return e.filter(Boolean).join(" ").trim()}joinStyleFragments(e){return e.filter(r=>!!r&&r.trim().length>0).map(r=>{const n=r.trim();return n.endsWith(";")?n:`${n};`}).join(" ")}serializeStyleObject(e){return e?Object.entries(e).filter(([,r])=>typeof r=="string"&&r.length>0).map(([r,n])=>`${this.toKebabCase(r)}: ${n}`).join("; "):""}toKebabCase(e){return e.replace(/[A-Z]/g,r=>`-${r.toLowerCase()}`)}offsetToPositionInText(e,r){const n=Math.max(0,Math.min(e,r.length)),i=r.slice(0,n).split(`
110
116
  `);return{line:i.length-1,column:i[i.length-1].length}}positionToTextOffset(e,r){var s;const n=r.split(`
111
117
  `),i=Math.max(0,Math.min(e.line,n.length-1)),o=Math.max(0,Math.min(e.column,((s=n[i])==null?void 0:s.length)||0));let a=0;for(let c=0;c<i;c++)a+=n[c].length+1;return a+o}getFoldPlaceholderSource(e){const r=e.getAttribute(this.foldPlaceholderAttr),n=this.getFoldPlaceholderSources();return r&&n.has(r)?n.get(r)||"":e.__lceFoldHiddenText||""}getFoldPlaceholderSources(){return this.contentElement.__lceFoldPlaceholderSources||new Map}getFoldPlaceholderBoundaryOffset(e,r,n){const i=this.getFoldPlaceholderSource(e).length,o=this.stripVirtualMarkers(e.textContent||"").length;if(i===0||o===0)return 0;const a=document.createRange();a.selectNodeContents(e);try{a.setEnd(r,n)}catch(s){return 0}return this.stripVirtualMarkers(a.toString()).length<=o/2?0:i}setFoldPlaceholderSources(e){this.contentElement.__lceFoldPlaceholderSources=e}},c3=0;const s8=class hg{constructor(e,r={}){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.highlightTimeout=null,this.expectingProgrammaticCursor=!1,this.lastKnownCursor={line:0,column:0},this.editorInstanceId=++c3,this.decorationHighlightStyleId=`editora-decoration-style-${this.editorInstanceId}`,this.decorationHighlightLimit=1e3,this.decorationLayers=new Map,this.inlineDecorationHighlightNames=new Set,this.decorationRenderRaf=null,this.decorationMutationObserver=null,this.hasCustomDecorationHighlightSupport=!1,this.lastProgrammaticClipboardInsertAt=0,this.config={value:"",theme:"default",readOnly:!1,tabSize:2,lineWrapping:!1,lineNumbers:!0,...r},this.textModel=new a3(this.config.value),this.view=new s3(e),this.view.setTabSize(this.config.tabSize||2),this.view.setLineWrapping(!!this.config.lineWrapping),this.view.setLineNumbersVisible(this.config.lineNumbers!==!1),this.hasCustomDecorationHighlightSupport=this.detectCustomHighlightSupport(),this.observeDecorationRelevantMutations(),this.setupEventHandlers(),this.config.extensions&&this.config.extensions.forEach(n=>this.addExtension(n)),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("beforeinput",r=>{if(this.suppressHistory||this.config.readOnly){this.pendingInputSnapshot=void 0;return}if(r.inputType==="insertFromPaste"||r.inputType==="insertFromPasteAsQuotation"||r.inputType==="insertFromDrop"){const n=r.dataTransfer,i=this.getPlainTextFromDataTransfer(n);if(i.length===0||(r.preventDefault(),this.pendingInputSnapshot=void 0,Date.now()-this.lastProgrammaticClipboardInsertAt<80))return;this.insertClipboardText(i);return}if(r.inputType==="insertParagraph"||r.inputType==="insertLineBreak"){r.preventDefault(),this.pendingInputSnapshot=void 0,this.insertNewLine();return}if(r.inputType==="deleteContentBackward"||r.inputType==="deleteWordBackward"){r.preventDefault(),this.pendingInputSnapshot=void 0,this.deleteBackward();return}if(r.inputType==="deleteContentForward"||r.inputType==="deleteWordForward"){r.preventDefault(),this.pendingInputSnapshot=void 0,this.deleteForward();return}if(r.inputType==="deleteByCut"){r.preventDefault(),this.pendingInputSnapshot=void 0,this.deleteSelection();return}if(r.inputType==="insertText"&&typeof r.data=="string"&&!r.isComposing){r.preventDefault(),this.pendingInputSnapshot=void 0,this.replaceSelectionWithText(r.data);return}this.pendingInputSnapshot=this.captureHistorySnapshot()}),e.addEventListener("paste",r=>{if(this.config.readOnly){r.preventDefault();return}if(Date.now()-this.lastProgrammaticClipboardInsertAt<80){r.preventDefault();return}const n=this.getPlainTextFromDataTransfer(r.clipboardData);n.length!==0&&(r.preventDefault(),this.insertClipboardText(n))}),e.addEventListener("input",()=>{var i;const r=this.view.getText(),n=this.textModel.getText();r!==n?(this.suppressHistory||this.pushUndoSnapshot((i=this.pendingInputSnapshot)!=null?i:this.captureHistorySnapshot(n)),this.pendingInputSnapshot=void 0,this.textModel.setText(r),this.view.syncTrailingNewlineMarkerForText(r),this.hasRenderedFoldPlaceholders()?this.clearPendingHighlightRender():(this.clearPendingHighlightRender(),this.highlightTimeout=setTimeout(()=>{const o=this.view.getText();o!==this.textModel.getText()&&this.textModel.setText(o),this.renderTextWithHighlight(this.textModel.getText(),!1),this.highlightTimeout=null},300)),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:r,oldText:n}])):this.pendingInputSnapshot=void 0}),this.documentSelectionChangeHandler=()=>{var i,o,a;const r=this.syncSelectionCacheFromView();if(!r.isInEditor)return;const n=(i=r.cursor)!=null?i:this.lastKnownCursor;this.emit("cursor",{position:n,anchor:(a=(o=r.range)==null?void 0:o.start)!=null?a:n}),this.emit("selection",r.isCollapsed?void 0:r.range)},document.addEventListener("selectionchange",this.documentSelectionChangeHandler),e.addEventListener("keydown",r=>{this.emit("keydown",r);const n=Array.from(this.extensions.values()).reverse();for(const i of n)if(i.onKeyDown&&i.onKeyDown(r)===!1){r.preventDefault(),r.stopPropagation();return}if(r.key==="Tab"&&!this.config.readOnly){this.insertTab(),r.preventDefault(),r.stopPropagation();return}if(r.key==="Backspace"&&!this.config.readOnly){this.deleteBackward(),r.preventDefault(),r.stopPropagation();return}if(r.key==="Delete"&&!this.config.readOnly){this.deleteForward(),r.preventDefault(),r.stopPropagation();return}if(r.key==="Enter"&&!this.config.readOnly){this.insertNewLine(),r.preventDefault(),r.stopPropagation();return}}),e.addEventListener("mousedown",r=>{this.emit("mousedown",r);const n=Array.from(this.extensions.values()).reverse();for(const i of n)if(i.onMouseDown&&i.onMouseDown(r)===!1){r.preventDefault(),r.stopPropagation();return}}),e.addEventListener("contextmenu",r=>{this.emit("contextmenu",r);const n=Array.from(this.extensions.values()).reverse();for(const i of n)if(i.onContextMenu&&i.onContextMenu(r)===!1){r.preventDefault(),r.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,...r){const n=this.eventListeners.get(e);n&&n.forEach(i=>i(...r))}getValue(){return this.textModel.getText()}setValue(e){const r=this.textModel.getText();this.textModel.setText(e),this.renderTextWithHighlight(e,!1),this.updateLineNumbers(),this.emit("change",[{range:this.getFullRange(),text:e,oldText:r}])}getState(){return{text:this.getValue(),cursor:this.getCursor(),selection:this.getSelection(),readOnly:this.config.readOnly||!1,theme:this.currentTheme}}getCursor(){var n,i,o;const e=this.syncSelectionCacheFromView(),r=(n=e.cursor)!=null?n:this.lastKnownCursor;return{position:r,anchor:(o=(i=e.range)==null?void 0:i.start)!=null?o:r}}setCursor(e){const r=this.textModel.getText(),n=this.clampPositionToText(e,r),i=this.positionToOffsetInText(n,r);this.lastKnownCursor=n,this.lastKnownSelection=void 0,this.view.setSelectionOffsets(i),this.emit("cursor",this.getCursor())}getSelection(){const e=this.syncSelectionCacheFromView();if(!(!e.isInEditor||e.isCollapsed))return e.range}setSelection(e){const r=this.textModel.getText(),n=this.normalizeRange({start:this.clampPositionToText(e.start,r),end:this.clampPositionToText(e.end,r)}),i=this.positionToOffsetInText(n.start,r),o=this.positionToOffsetInText(n.end,r);this.lastKnownSelection=n,this.lastKnownCursor=n.end,this.view.setSelectionOffsets(i,o),this.emit("selection",n)}setTheme(e){this.currentTheme=e;const r={"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(r);const n=this.extensions.get("syntax-highlighting");if(n&&typeof n.setTheme=="function")try{n.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 r=this.extensions.get(e);r&&r.destroy&&r.destroy(),this.extensions.delete(e)}executeCommand(e,...r){const n=this.commands.get(e);n?n(...r):console.warn(`Command '${e}' not found`)}registerCommand(e,r){this.commands.set(e,r)}setDecorations(e,r){const n=e.trim();if(!n)throw new Error("Decoration layer name must not be empty");if(!Array.isArray(r)||r.length===0){this.decorationLayers.delete(n),this.scheduleDecorationRender();return}this.decorationLayers.set(n,r.map(i=>this.cloneDecoration(i))),this.scheduleDecorationRender()}clearDecorations(e){typeof e=="string"?this.decorationLayers.delete(e.trim()):this.decorationLayers.clear(),this.scheduleDecorationRender()}getDecorations(e){if(typeof e=="string")return(this.decorationLayers.get(e.trim())||[]).map(n=>this.cloneDecoration(n));const r=[];for(const n of this.decorationLayers.values())r.push(...n.map(i=>this.cloneDecoration(i)));return r}search(e,r={}){var u;if(!e)return[];const n={query:e,caseSensitive:!1,wholeWord:!1,regex:!1,...r},i=[],o=this.textModel.getText(),{normalizedText:a,normalizedToRawOffsets:s}=this.buildSearchTextAndOffsetMap(o),c=n.caseSensitive?a:a.toLowerCase(),l=n.caseSensitive?e:e.toLowerCase();if(n.regex){let d;try{d=new RegExp(e,n.caseSensitive?"g":"gi")}catch(A){return[]}let f;for(;(f=d.exec(a))!==null;){const A=(u=f[0])!=null?u:"";if(A.length===0){d.lastIndex=f.index+1;continue}const h=f.index,p=f.index+A.length;n.wholeWord&&!this.isWholeWordBoundary(a,h,p)||this.pushSearchResultFromOffsets(i,h,p,a,s)}}else{let d=0,f=c.indexOf(l,d);for(;f!==-1;){const A=f+l.length;!n.wholeWord||this.isWholeWordBoundary(a,f,A)?(this.pushSearchResultFromOffsets(i,f,A,a,s),d=A):d=f+1,f=c.indexOf(l,d)}}return i}pushSearchResultFromOffsets(e,r,n,i,o){var u,d;const a=(u=o[r])!=null?u:r,s=(d=o[n])!=null?d:a,c=this.textModel.offsetToPosition(a),l=this.textModel.offsetToPosition(s);e.push({range:{start:c,end:l},match:i.substring(r,n)})}isWholeWordBoundary(e,r,n){const i=r>0?e[r-1]:"",o=n<e.length?e[n]:"";return!this.isWordChar(i)&&!this.isWordChar(o)}isWordChar(e){return/^[A-Za-z0-9_]$/.test(e)}buildSearchTextAndOffsetMap(e){const r=[],n=[0];let i=0;for(let o=0;o<e.length;o++){const a=e[o];a==="​"||a===hg.CURSOR_SENTINEL||(r.push(a),i+=1,n[i]=o+1)}return n[i]=e.length,{normalizedText:r.join(""),normalizedToRawOffsets:n}}replace(e,r){const n=this.getValue();this.suppressHistory||this.pushUndoSnapshot(this.captureHistorySnapshot(n));const i=this.textModel.replaceRange(e,r);this.expectingProgrammaticCursor=!0,this.renderTextWithHighlight(this.getValue(),!1),this.expectingProgrammaticCursor=!1,this.emit("change",[i])}replaceAll(e,r,n={}){const i=this.search(e,n);let o=0;for(let a=i.length-1;a>=0;a--)this.replace(i[a].range,r),o++;return o}fold(e){this.clearPendingHighlightRender();const r=this.normalizeRange(e);if(r.start.line===r.end.line&&r.start.column===r.end.column)return;const n=this.folds.findIndex(o=>this.isSameFoldRange(o,r)),i={start:r.start,end:r.end,collapsed:!0,level:0};n!==-1?this.folds[n]=i:(this.folds.push(i),this.folds.sort((o,a)=>this.comparePositions(o.start,a.start)))}unfold(e){this.clearPendingHighlightRender();const r=this.normalizeRange(e);this.folds=this.folds.filter(n=>!this.isSameFoldRange(n,r))}getFolds(){return[...this.folds]}focus(){this.view.focus()}blur(){this.view.blur()}renderTextWithHighlight(e,r=!0){const n=this.extensions.get("syntax-highlighting");if(n&&typeof n.highlightHTML=="function")try{if(typeof this.view.setHighlightHTML=="function"){const h=this.view.getContentElement();(h.querySelector("[data-lce-fold-placeholder]")||h.textContent!==e)&&this.view.setText(e);const p=typeof n.highlight=="function"?n.highlight(e):n.highlightHTML(e);this.view.setHighlightHTML(p),this.view.syncTrailingNewlineMarkerForText(e),this.scheduleDecorationRender();return}const i=!r&&!this.expectingProgrammaticCursor;let o,a,s,c;const l=this.view.getSelectionState(),u=l.isInEditor&&!!l.cursor;(r||i)&&u&&(o=l.isCollapsed?void 0:l.range,a=this.textModel.positionToOffset(l.cursor),o&&(s=this.textModel.positionToOffset(o.start),c=this.textModel.positionToOffset(o.end)));const d=u&&(r||i)&&!o&&a!==void 0&&this.hasCollapsedSelectionInEditor(),f=d?this.insertSentinelAtOffset(e,a):e,A=typeof n.highlight=="function"?n.highlight(f):n.highlightHTML(f);typeof this.view.setHighlightHTML=="function"?this.view.setHighlightHTML(A):this.view.setHTML(A),this.view.syncTrailingNewlineMarkerForText(e),(r||i)&&u&&requestAnimationFrame(()=>{try{if(d&&this.restoreCursorFromSentinel()){this.view.ensureCaretVisible();return}if(o&&(s!==void 0||c!==void 0)){const h=s!==void 0?s:a,p=c!==void 0?c:a,m=Math.min(h,p),g=Math.max(h,p),b=this.textModel.offsetToPosition(m),v=this.textModel.offsetToPosition(g);this.view.setSelectionRange({start:b,end:v})}else if(a!==void 0){const h=this.textModel.offsetToPosition(a);this.view.setCursorPosition(h)}}catch(h){}}),this.scheduleDecorationRender();return}catch(i){console.warn("Syntax highlighting failed, falling back to plain text",i)}this.view.setText(e),this.scheduleDecorationRender()}hasCollapsedSelectionInEditor(){const e=window.getSelection();if(!e||e.rangeCount===0||!e.isCollapsed)return!1;const r=e.getRangeAt(0);return this.view.getContentElement().contains(r.commonAncestorContainer)}getCollapsedSelectionOffsetInEditor(){const e=window.getSelection();if(!e||e.rangeCount===0||!e.isCollapsed)return;const r=e.getRangeAt(0),n=this.view.getContentElement();if(!n.contains(r.commonAncestorContainer))return;const i=r.cloneRange();return i.selectNodeContents(n),i.setEnd(r.endContainer,r.endOffset),this.stripVirtualMarkers(i.toString()).length}stripVirtualMarkers(e){return e.replace(/\u200B/g,"").split(hg.CURSOR_SENTINEL).join("")}insertSentinelAtOffset(e,r){const n=Math.max(0,Math.min(r,e.length));return e.slice(0,n)+hg.CURSOR_SENTINEL+e.slice(n)}restoreCursorFromSentinel(){var s;const e=this.view.getContentElement(),r=window.getSelection(),n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let i=n.nextNode(),o=null,a=0;for(;i;){const c=(s=i.textContent)!=null?s:"",l=c.indexOf(hg.CURSOR_SENTINEL);l!==-1&&(o||(o=i,a=l),i.textContent=c.split(hg.CURSOR_SENTINEL).join("")),i=n.nextNode()}if(!o||!r)return!1;try{const c=document.createRange();return c.setStart(o,a),c.collapse(!0),r.removeAllRanges(),r.addRange(c),!0}catch(c){return!1}}destroy(){var e;if(!this.isDestroyed){this.isDestroyed=!0,this.highlightTimeout&&(clearTimeout(this.highlightTimeout),this.highlightTimeout=null),this.pendingInputSnapshot=void 0,this.documentSelectionChangeHandler&&(document.removeEventListener("selectionchange",this.documentSelectionChangeHandler),this.documentSelectionChangeHandler=void 0),this.decorationRenderRaf!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(this.decorationRenderRaf),this.decorationRenderRaf=null),(e=this.decorationMutationObserver)==null||e.disconnect(),this.decorationMutationObserver=null,this.clearInlineDecorationHighlights(!0),this.decorationLayers.clear(),this.view.clearDecorations();for(const r of this.extensions.values())r.destroy&&r.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(),r=this.captureHistorySnapshot();this.pushSnapshot(this.redoStack,r);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0,this.restoreHistorySnapshot(e),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}redo(){if(this.redoStack.length===0)return;const e=this.redoStack.pop(),r=this.captureHistorySnapshot();this.pushSnapshot(this.undoStack,r);try{this.suppressHistory=!0,this.expectingProgrammaticCursor=!0,this.restoreHistorySnapshot(e),setTimeout(()=>{this.expectingProgrammaticCursor=!1},30)}finally{this.suppressHistory=!1}}insertTab(){if(this.config.readOnly)return;const e=" ".repeat(this.config.tabSize||2);this.replaceSelectionWithText(e)}insertNewLine(){this.config.readOnly||this.replaceSelectionWithText(`
112
118
  `)}deleteBackward(){this.config.readOnly||this.deleteUsingDirection("backward")}deleteForward(){this.config.readOnly||this.deleteUsingDirection("forward")}deleteSelection(){if(this.config.readOnly)return;const e=this.textModel.getText(),{startOffset:r,endOffset:n}=this.getActiveSelectionOffsets(e),i=Math.min(r,n),o=Math.max(r,n);i!==o&&this.replaceOffsetsWithText(i,o,"")}on(e,r){this.eventListeners.has(e)||this.eventListeners.set(e,[]),this.eventListeners.get(e).push(r)}off(e,r){if(!this.eventListeners.has(e))return;const n=this.eventListeners.get(e);if(r){const i=n.indexOf(r);i!==-1&&n.splice(i,1)}else n.length=0}normalizeRange(e){return this.comparePositions(e.start,e.end)<=0?e:{start:e.end,end:e.start}}comparePositions(e,r){return e.line!==r.line?e.line-r.line:e.column-r.column}captureHistorySnapshot(e=this.textModel.getText()){const r=this.view.getSelectionState(),n=r.isInEditor&&!r.isCollapsed?r.range:void 0,i=r.isInEditor&&r.cursor?r.cursor:void 0,o=n!=null?n:this.lastKnownSelection,a=i!=null?i:this.lastKnownCursor,s=this.clampPositionToText(a,e),c={text:e,cursorOffset:this.positionToOffsetInText(s,e)};if(o){const l=this.clampPositionToText(o.start,e),u=this.clampPositionToText(o.end,e);c.anchorOffset=this.positionToOffsetInText(l,e),c.focusOffset=this.positionToOffsetInText(u,e)}return c}restoreHistorySnapshot(e){this.setValue(e.text),requestAnimationFrame(()=>{try{if(e.anchorOffset!==void 0&&e.focusOffset!==void 0&&e.anchorOffset!==e.focusOffset){const r=Math.min(e.anchorOffset,e.focusOffset),n=Math.max(e.anchorOffset,e.focusOffset);this.setSelection({start:this.textModel.offsetToPosition(r),end:this.textModel.offsetToPosition(n)});return}this.setCursor(this.textModel.offsetToPosition(e.cursorOffset))}catch(r){}})}pushUndoSnapshot(e){this.pushSnapshot(this.undoStack,e),this.redoStack.length=0}pushSnapshot(e,r){e.push(r),e.length>100&&e.shift()}clampPositionToText(e,r){var a,s;const n=r.split(`
@@ -173,9 +179,9 @@
173
179
  background-color: var(--lce-bracket-match-bg, rgba(86, 156, 214, 0.4));
174
180
  text-decoration: underline solid var(--lce-bracket-match-border, rgba(156, 220, 254, 0.95)) 2px;
175
181
  }
176
- `,document.head.appendChild(e)}getCurrentMatch(){return this.currentMatch}destroy(){var e;if(this.pendingUpdateRaf!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(this.pendingUpdateRaf),this.pendingUpdateRaf=null),this.clearBracketHighlighting(),(e=this.observer)==null||e.disconnect(),this.observer=null,this.editor&&this.cursorHandler&&this.editor.off("cursor",this.cursorHandler),this.editor&&this.changeHandler&&this.editor.off("change",this.changeHandler),typeof document<"u"){const r=document.getElementById(this.highlightStyleId);r!=null&&r.parentNode&&r.parentNode.removeChild(r)}this.cursorHandler=null,this.changeHandler=null,this.editor=null}},v3=class{constructor(){this.name="code-folding",this.lineHeight=21,this.voidMarkupTags=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),this.nonFoldableInlineMarkupTags=new Set(["a","abbr","b","bdi","bdo","button","cite","code","data","del","dfn","em","i","ins","kbd","label","mark","output","q","ruby","s","samp","small","span","strong","sub","sup","time","u","var"]),this.rawTextMarkupTags=new Set(["script","style","textarea","title"]),this.editor=null,this.foldingUI=null,this.pendingUpdateRaf=null,this.lastSnapshot="",this.lastParsedText=null,this.changeHandler=null,this.foldRegions=[],this.foldSnapshots=new Map,this.isDisplayingFolded=!1,this.cachedLineInfo=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()}),this.changeHandler=()=>{this.syncFoldingState()},e.on("change",this.changeHandler),this.createFoldingUI(),this.syncFoldingState()}onKeyDown(e){}onMouseDown(e){}createFoldingUI(){if(!this.editor)return;const e=this.editor.getView().getContentElement().closest('[data-lce-editor-container="true"]');e&&(this.foldingUI=document.createElement("div"),this.foldingUI.setAttribute("data-lce-folding-ui","true"),this.foldingUI.style.cssText=`
182
+ `,document.head.appendChild(e)}getCurrentMatch(){return this.currentMatch}destroy(){var e;if(this.pendingUpdateRaf!==null&&typeof cancelAnimationFrame=="function"&&(cancelAnimationFrame(this.pendingUpdateRaf),this.pendingUpdateRaf=null),this.clearBracketHighlighting(),(e=this.observer)==null||e.disconnect(),this.observer=null,this.editor&&this.cursorHandler&&this.editor.off("cursor",this.cursorHandler),this.editor&&this.changeHandler&&this.editor.off("change",this.changeHandler),typeof document<"u"){const r=document.getElementById(this.highlightStyleId);r!=null&&r.parentNode&&r.parentNode.removeChild(r)}this.cursorHandler=null,this.changeHandler=null,this.editor=null}},v3=class{constructor(){this.name="code-folding",this.lineHeight=21,this.voidMarkupTags=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),this.nonFoldableInlineMarkupTags=new Set(["a","abbr","b","bdi","bdo","button","cite","code","data","del","dfn","em","i","ins","kbd","label","mark","output","q","ruby","s","samp","small","span","strong","sub","sup","time","u","var"]),this.rawTextMarkupTags=new Set(["script","style","textarea","title"]),this.editor=null,this.foldingUI=null,this.pendingUpdateRaf=null,this.lastSnapshot="",this.lastParsedText=null,this.changeHandler=null,this.foldRegions=[],this.foldSnapshots=new Map,this.isDisplayingFolded=!1,this.cachedLineInfo=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()}),this.changeHandler=()=>{this.syncFoldingState()},e.on("change",this.changeHandler),this.createFoldingUI(),this.syncFoldingState()}onKeyDown(e){}onMouseDown(e){}createFoldingUI(){if(!this.editor)return;const e=this.editor.getView().getLineNumbersElement();e&&(this.foldingUI=document.createElement("div"),this.foldingUI.setAttribute("data-lce-folding-ui","true"),this.foldingUI.style.cssText=`
177
183
  position: absolute;
178
- left: 0;
184
+ right: 0;
179
185
  top: 0;
180
186
  bottom: 0;
181
187
  width: 20px;
@@ -199,7 +205,7 @@
199
205
  padding: 0;
200
206
  font-size: 10px;
201
207
  user-select: none;
202
- `,i.textContent=n?"▶":"▼",i.title=n?"Expand folded region":"Collapse region",i.setAttribute("aria-label",i.title),i.addEventListener("mousedown",o=>{o.preventDefault()}),i.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),this.toggleFold(e)}),i}toggleFold(e){this.editor&&(this.isFoldActive(e)?this.editor.unfold(e):this.editor.fold(e),this.syncFoldingState())}foldAtCursor(){if(!this.editor)return;const e=this.editor.getCursor().position.line,r=this.findBestRegionForLine(e,!1);r&&(this.editor.fold(r),this.syncFoldingState())}unfoldAtCursor(){if(!this.editor)return;const e=this.editor.getCursor().position.line,r=this.findBestRegionForLine(e,!0);r&&(this.editor.unfold(r),this.syncFoldingState())}foldAll(){if(!this.editor)return;const e=this.getTopLevelFoldRegions(this.foldRegions);for(const r of e)this.editor.fold(r);this.syncFoldingState()}unfoldAll(){if(!this.editor)return;const e=this.getActiveFolds();for(const r of e)this.editor.unfold(r);this.syncFoldingState()}applyFoldedDisplay(){if(!this.editor)return;const e=this.getRenderableActiveFolds();if(e.length===0){this.restoreFullDisplay();return}const r=this.buildFoldedProjection(this.editor.getValue(),e);this.withPreservedSelection(()=>{this.renderEditorText(r.text),this.renderFoldPlaceholders(r),this.isDisplayingFolded=!0})}restoreFullDisplay(){this.editor&&(this.isDisplayingFolded&&this.withPreservedSelection(()=>{this.renderEditorText(this.editor.getValue())}),this.isDisplayingFolded=!1)}renderEditorText(e){if(!this.editor)return;const r=this.editor;if(typeof r.renderTextWithHighlight=="function"){r.expectingProgrammaticCursor=!0,r.renderTextWithHighlight(e,!1),r.expectingProgrammaticCursor=!1;return}this.editor.getView().setText(e)}buildFoldedProjection(e,r){const{lineStarts:n,lines:i}=this.buildLineStarts(e),o=[...r].sort((u,d)=>this.comparePositions(u.start,d.start));let a="";const s=[];let c=0;for(const u of o){const d=this.positionToOffset(u.start,n,i),f=this.positionToOffset(u.end,n,i),A=e.slice(c,d),h=this.getFoldPlaceholder(u),p=e.slice(d,f);a+=A,a+=h,A&&s.push({type:"text",text:A}),s.push({type:"placeholder",text:h,fold:u,hiddenText:p}),c=f}const l=e.slice(c);return a+=l,l&&s.push({type:"text",text:l}),{text:a,segments:s}}renderFoldPlaceholders(e){if(!this.editor)return;const r=this.editor.getView().getContentElement(),n=new Map,i=document.createDocumentFragment();for(const o of e.segments){if(o.type==="text"){i.appendChild(document.createTextNode(o.text));continue}const a=document.createElement("span"),s=this.getFoldKey(o.fold);a.setAttribute("data-lce-fold-placeholder",s),a.setAttribute("aria-label","Folded region"),a.contentEditable="false",n.set(s,o.hiddenText),a.style.cssText=`
208
+ `,i.textContent=n?"▶":"▼",i.title=n?"Expand folded region":"Collapse region",i.setAttribute("aria-label",i.title),i.addEventListener("mousedown",o=>{o.preventDefault()}),i.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),this.toggleFold(e)}),i}toggleFold(e){this.editor&&(this.isFoldActive(e)?this.editor.unfold(e):this.editor.fold(e),this.syncFoldingStatePreservingScroll())}foldAtCursor(){if(!this.editor)return;const e=this.editor.getCursor().position.line,r=this.findBestRegionForLine(e,!1);r&&(this.editor.fold(r),this.syncFoldingStatePreservingScroll())}unfoldAtCursor(){if(!this.editor)return;const e=this.editor.getCursor().position.line,r=this.findBestRegionForLine(e,!0);r&&(this.editor.unfold(r),this.syncFoldingStatePreservingScroll())}foldAll(){if(!this.editor)return;const e=this.getTopLevelFoldRegions(this.foldRegions);for(const r of e)this.editor.fold(r);this.syncFoldingStatePreservingScroll()}unfoldAll(){if(!this.editor)return;const e=this.getActiveFolds();for(const r of e)this.editor.unfold(r);this.syncFoldingStatePreservingScroll()}syncFoldingStatePreservingScroll(){this.withPreservedScroll(()=>{this.syncFoldingState()})}withPreservedScroll(e){var o;const r=(o=this.editor)==null?void 0:o.getView().getScrollElement();if(!r){e();return}const n=r.scrollLeft,i=r.scrollTop;e(),this.restoreScrollPosition(r,n,i)}restoreScrollPosition(e,r,n){e.scrollLeft=r,e.scrollTop=n,requestAnimationFrame(()=>{e.isConnected&&(e.scrollLeft=r,e.scrollTop=n)})}applyFoldedDisplay(){if(!this.editor)return;const e=this.getRenderableActiveFolds();if(e.length===0){this.restoreFullDisplay();return}const r=this.buildFoldedProjection(this.editor.getValue(),e);this.withPreservedSelection(()=>{this.renderEditorText(r.text),this.renderFoldPlaceholders(r),this.isDisplayingFolded=!0})}restoreFullDisplay(){this.editor&&(this.isDisplayingFolded&&this.withPreservedSelection(()=>{this.renderEditorText(this.editor.getValue())}),this.isDisplayingFolded=!1)}renderEditorText(e){if(!this.editor)return;const r=this.editor;if(typeof r.renderTextWithHighlight=="function"){r.expectingProgrammaticCursor=!0,r.renderTextWithHighlight(e,!1),r.expectingProgrammaticCursor=!1;return}this.editor.getView().setText(e)}buildFoldedProjection(e,r){const{lineStarts:n,lines:i}=this.buildLineStarts(e),o=[...r].sort((u,d)=>this.comparePositions(u.start,d.start));let a="";const s=[];let c=0;for(const u of o){const d=this.positionToOffset(u.start,n,i),f=this.positionToOffset(u.end,n,i),A=e.slice(c,d),h=this.getFoldPlaceholder(u),p=e.slice(d,f);a+=A,a+=h,A&&s.push({type:"text",text:A}),s.push({type:"placeholder",text:h,fold:u,hiddenText:p}),c=f}const l=e.slice(c);return a+=l,l&&s.push({type:"text",text:l}),{text:a,segments:s}}renderFoldPlaceholders(e){if(!this.editor)return;const r=this.editor.getView().getContentElement(),n=new Map,i=document.createDocumentFragment();for(const o of e.segments){if(o.type==="text"){i.appendChild(document.createTextNode(o.text));continue}const a=document.createElement("span"),s=this.getFoldKey(o.fold);a.setAttribute("data-lce-fold-placeholder",s),a.setAttribute("aria-label","Folded region"),a.contentEditable="false",n.set(s,o.hiddenText),a.style.cssText=`
203
209
  cursor: text;
204
210
  user-select: text;
205
211
  pointer-events: auto;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@editora/core",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "Framework-agnostic rich text editor core for React and web apps, built for enterprise editing workflows.",
5
5
  "author": "Ajay Kumar <ajaykr089@gmail.com>",
6
6
  "license": "MIT",