@editora/core 1.0.17 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CodePlugin.native-BH-K4xmW.mjs → CodePlugin.native-BcVqm5MS.mjs} +64 -65
- package/dist/{CodePlugin.native-hNgfXlfS.mjs → CodePlugin.native-Rgxx2Igx.mjs} +2708 -1225
- package/dist/{DocumentManagerPlugin.native-iFip6s4Q.mjs → DocumentManagerPlugin.native-B8K-Oqom.mjs} +12 -11
- package/dist/{PreviewPlugin.native-CiR51jql.mjs → PreviewPlugin.native-Dyht8mGi.mjs} +48 -51
- package/dist/{TablePlugin.native-BjIxYZ2X.mjs → TablePlugin.native-C1YZ372P.mjs} +156 -147
- package/dist/TemplatePlugin.native-BDV2eik2.mjs +628 -0
- package/dist/{documentManager-BcBIv5P-.mjs → documentManager-BWK_-KJp.mjs} +524 -526
- package/dist/editora.min.js +17 -17
- package/dist/editora.umd.js +22 -22
- package/dist/index-CclXYzUB.js +12 -0
- package/dist/{index-XsYC_KdJ.mjs → index-DeUjxpKd.mjs} +406 -386
- package/dist/index.cjs.js +10 -10
- package/dist/index.esm.js +78 -67
- package/dist/plugin-loader.js +4 -4
- package/dist/purify.es-BHa5gZB7.mjs +1481 -0
- package/dist/sanitizeHtml-DA0ajC6k.mjs +17 -0
- package/dist/webcomponent-core.js +376 -362
- package/dist/webcomponent-core.min.js +91 -89
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +2 -2
- package/dist/webcomponent.js +382 -368
- package/dist/webcomponent.min.js +968 -967
- package/index.d.ts +9 -0
- package/package.json +1 -1
- package/dist/TemplatePlugin.native-D6n5RUnC.mjs +0 -1176
- package/dist/index-_eKRBZPq.js +0 -12
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./index-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("./index-CclXYzUB.js");class w{constructor(e){if(this.listeners=[],e instanceof l.PluginManager)this.pluginManager=e;else{const i=e;this.pluginManager=new l.PluginManager,i.plugins&&Array.isArray(i.plugins)&&i.plugins.forEach(n=>{this.pluginManager.register(n)}),i.element&&(this.domElement=i.element,this.setupDOMElement(i))}const t=this.pluginManager.buildSchema();this.state=l.EditorState.create(t),this.commands=this.pluginManager.getCommands()}setupDOMElement(e){this.domElement&&(e.enableToolbar!==!1&&e.toolbarElement?this.toolbarElement=e.toolbarElement:e.enableToolbar!==!1&&(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.domElement.appendChild(this.toolbarElement)),this.contentElement=document.createElement("div"),this.contentElement.contentEditable="true",this.contentElement.className="editora-content",this.contentElement.style.minHeight="200px",this.contentElement.style.outline="none",this.contentElement.style.padding="12px",e.content&&(this.contentElement.innerHTML=e.content),this.domElement.appendChild(this.contentElement),this.contentElement.addEventListener("input",()=>{this.listeners.forEach(t=>t(this.state))}))}setupKeyboardShortcuts(e){const t={};e.forEach(i=>{i.shortcut&&(t[i.shortcut.toLowerCase()]=i.command)}),document.addEventListener("keydown",i=>{if(this.contentElement!==document.activeElement&&!(document.activeElement instanceof HTMLElement&&document.activeElement.contentEditable==="true"))return;const n=[];(i.ctrlKey||i.metaKey)&&n.push("ctrl"),i.shiftKey&&n.push("shift"),i.altKey&&n.push("alt");const o=i.key.toLowerCase(),s=n.length>0?`${n.join("+")}+${o}`:o,a=t[s];a&&(i.preventDefault(),this.execCommand(a))})}handleToolbarCommand(e,t){const n=this.pluginManager.getToolbarItems().find(o=>o.id&&o.id===e||o.command===e);n!=null&&n.command&&(t!==void 0?this.execCommand(n.command,t):this.execCommand(n.command))}setState(e){this.state=e,this.listeners.forEach(t=>t(e))}onChange(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}on(e,t){return e==="change"||e==="input"?this.onChange(t):()=>{}}getElement(){return this.contentElement||this.domElement||null}execCommand(e,t){const i=this.commands[e];if(!i)return console.warn(`Command not found: ${e}`),!1;let n;return t!==void 0?n=i(this.state,t):n=i(this.state),n instanceof Promise?(n.then(o=>{o&&typeof o=="object"&&"doc"in o&&"selection"in o&&this.setState(o)}).catch(o=>{console.error(`Async command failed: ${e}`,o)}),!0):n&&typeof n=="object"&&"doc"in n&&"selection"in n?(this.setState(n),!0):n!==!1&&n!=null}setContent(e){typeof e=="string"?this.contentElement&&(this.contentElement.innerHTML=e):this.setState(this.state.apply(e))}getContent(){return this.contentElement?this.contentElement.innerHTML:this.state.doc}destroy(){this.listeners=[],this.contentElement&&this.contentElement.removeEventListener("input",()=>{})}}class f{constructor(e){this.initialized=!1,this.plugin=e}initialize(e){var t,i;if(this.initialized)return console.warn(`Plugin "${this.plugin.name}" already initialized`),!1;try{return this.context=e,(t=this.plugin.context)!=null&&t.initialize&&this.plugin.context.initialize(),(i=this.plugin.context)!=null&&i.onEditorReady&&e.provider&&this.plugin.context.onEditorReady(e),this.initialized=!0,!0}catch(n){return console.error(`Failed to initialize plugin "${this.plugin.name}":`,n),!1}}destroy(){var e;if(!this.initialized)return!1;try{return(e=this.plugin.context)!=null&&e.destroy&&this.plugin.context.destroy(),this.initialized=!1,this.context=void 0,!0}catch(t){return console.error(`Failed to destroy plugin "${this.plugin.name}":`,t),!1}}executeCommand(e,...t){var i;if(!this.initialized)return console.warn(`Plugin "${this.plugin.name}" not initialized, cannot execute command "${e}"`),null;try{const n=(i=this.plugin.commands)==null?void 0:i[e];return n?n(...t):(console.warn(`Command "${e}" not found in plugin "${this.plugin.name}"`),null)}catch(n){return console.error(`Error executing command "${e}" in plugin "${this.plugin.name}":`,n),null}}getName(){return this.plugin.name}isInitialized(){return this.initialized}getPlugin(){return this.plugin}getContext(){return this.context}}function x(r){return new f(r)}const b=new Set;function y(r,e){b.has(r)||(b.add(r),console.warn(`[Editora] ${r} from @editora/core is a deprecated, non-functional scaffold: its commands and toolbar buttons do nothing. It will be removed in a future major release - use ${e} instead.`))}function S(r={}){y("SpellcheckPlugin","`SpellCheckPlugin` from @editora/spell-check");const{enabled:e=!1,provider:t="browser",apiUrl:i="",apiHeaders:n={},language:o="en",customDictionary:s=[],ignoreAllCaps:a=!0,ignoreNumbers:c=!0}=r;return{name:"spellcheck",context:{initialize:()=>{if(e)switch(console.log("[Spellcheck Plugin] Initialized",{provider:t,language:o}),t){case"browser":console.log("[Spellcheck] Using browser spellcheck");break;case"local":console.log("[Spellcheck] Using local dictionary (not implemented)");break;case"api":i?console.log("[Spellcheck] Using API:",i):console.warn("[Spellcheck] API provider selected but no apiUrl provided");break}},destroy:()=>{console.log("[Spellcheck Plugin] Destroyed")},onEditorReady:h=>{console.log("[Spellcheck Plugin] Editor ready")}},commands:{toggleSpellcheck:()=>(console.log("[Spellcheck] Toggle command (not implemented)"),null),addToDictionary:h=>(console.log("[Spellcheck] Add to dictionary:",h),null),checkSpelling:async()=>(console.log("[Spellcheck] Check spelling (not implemented)"),null)},toolbar:e?[{label:"Spellcheck",command:"toggleSpellcheck",icon:"Aa",type:"button"}]:[]}}function C(r={}){y("MediaPlugin","`MediaManagerPlugin` from @editora/media-manager");const{uploadUrl:e="",libraryUrl:t="",maxFileSize:i=10*1024*1024,allowedTypes:n=["image/jpeg","image/png","image/gif","image/webp"],headers:o={},withCredentials:s=!1,chunkSize:a=1024*1024,enableChunking:c=!0,onProgress:h,onError:u,onSuccess:D}=r;return{name:"media",context:{initialize:()=>{console.log("[Media Plugin] Initialized",{uploadUrl:e,libraryUrl:t,maxFileSize:i,allowedTypes:n}),e||console.warn("[Media] No uploadUrl provided - upload will not work")},destroy:()=>{console.log("[Media Plugin] Destroyed")},onEditorReady:d=>{console.log("[Media Plugin] Editor ready")}},commands:{insertImage:async d=>{if(console.log("[Media] Insert image command (not implemented)",d),!d)return console.log("[Media] No file provided - should open picker"),null;if(!n.includes(d.type)){const g=new Error(`File type ${d.type} not allowed`);return u==null||u(g),null}if(d.size>i){const g=new Error(`File size ${d.size} exceeds max ${i}`);return u==null||u(g),null}return null},openMediaLibrary:()=>(console.log("[Media] Open media library (not implemented)"),t||console.warn("[Media] No libraryUrl provided"),null),uploadMedia:async d=>(console.log("[Media] Upload media (not implemented)",{name:d.name,size:d.size,type:d.type}),null)},toolbar:[{label:"Image",command:"insertImage",icon:"🖼️",type:"button"},{label:"Media Library",command:"openMediaLibrary",icon:"📁",type:"button"}]}}class p{constructor(e,t={anchor:0,head:0}){this.doc=e,this.selection=t}getDocument(){return this.doc}setDocument(e){return new p(e,this.selection)}getSelection(){return{...this.selection}}setSelection(e){return new p(this.doc,e)}update(e,t){return new p(e||this.doc,t||this.selection)}getTextContent(){return""}isSelectionEmpty(){return this.selection.anchor===this.selection.head}}class m{constructor(e){this.config={closeOnEscape:!0,closeOnBackdrop:!0,...e},this.element=this.createElement(),this.attachEventListeners()}createElement(){const e=document.createElement("dialog");e.className="editora-dialog",this.config.width&&(e.style.width=this.config.width),this.config.height&&(e.style.height=this.config.height);const t=this.config.buttons&&this.config.buttons.length>0?this.config.buttons.map((i,n)=>`<button type="button" class="editora-btn ${i.type==="danger"?"editora-btn-danger":i.type==="primary"||i.primary?"editora-btn-primary":"editora-btn-cancel"}" data-dialog-button="${n}">${i.label}</button>`).join(""):`
|
|
2
2
|
<button type="button" class="editora-btn editora-btn-cancel" data-dialog-default="cancel">Cancel</button>
|
|
3
3
|
<button type="button" class="editora-btn editora-btn-primary" data-dialog-default="ok">OK</button>
|
|
4
4
|
`;if(e.innerHTML=`
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
${t}
|
|
15
15
|
</div>
|
|
16
16
|
</div>
|
|
17
|
-
`,typeof this.config.content!="string"){const i=e.querySelector(".editora-dialog-body");i&&(i.innerHTML="",i.appendChild(this.config.content))}return e}attachEventListeners(){const e=this.element.querySelector(".editora-dialog-close");if(e==null||e.addEventListener("click",()=>this.close()),this.config.buttons&&this.config.buttons.length>0)this.element.querySelectorAll("[data-dialog-button]").forEach(i=>{i.addEventListener("click",()=>{var s,a;const n=Number(i.getAttribute("data-dialog-button")),o=(s=this.config.buttons)==null?void 0:s[n];(a=o==null?void 0:o.onClick)==null||a.call(o)})});else{const t=this.element.querySelector('[data-dialog-default="cancel"]');t==null||t.addEventListener("click",()=>{var n,o;(o=(n=this.config).onCancel)==null||o.call(n),this.close()});const i=this.element.querySelector('[data-dialog-default="ok"]');i==null||i.addEventListener("click",()=>this.handleSubmit())}this.config.closeOnEscape&&this.element.addEventListener("cancel",t=>{t.preventDefault(),this.close()}),this.config.closeOnBackdrop&&this.element.addEventListener("click",t=>{const i=this.element.getBoundingClientRect();(t.clientX<i.left||t.clientX>i.right||t.clientY<i.top||t.clientY>i.bottom)&&this.close()})}handleSubmit(){var t,i,n,o;const e=this.element.querySelector("form");if(e){const s=new FormData(e);(i=(t=this.config).onSubmit)==null||i.call(t,s)}else{const s=this.element.querySelectorAll("input, select, textarea"),a=new FormData;s.forEach(c=>{c.name&&a.append(c.name,c.value)}),(o=(n=this.config).onSubmit)==null||o.call(n,a)}this.close()}show(){document.body.appendChild(this.element),this.element.showModal()}close(){this.element.close(),this.element.remove()}destroy(){this.close()}}class
|
|
17
|
+
`,typeof this.config.content!="string"){const i=e.querySelector(".editora-dialog-body");i&&(i.innerHTML="",i.appendChild(this.config.content))}return e}attachEventListeners(){const e=this.element.querySelector(".editora-dialog-close");if(e==null||e.addEventListener("click",()=>this.close()),this.config.buttons&&this.config.buttons.length>0)this.element.querySelectorAll("[data-dialog-button]").forEach(i=>{i.addEventListener("click",()=>{var s,a;const n=Number(i.getAttribute("data-dialog-button")),o=(s=this.config.buttons)==null?void 0:s[n];(a=o==null?void 0:o.onClick)==null||a.call(o)})});else{const t=this.element.querySelector('[data-dialog-default="cancel"]');t==null||t.addEventListener("click",()=>{var n,o;(o=(n=this.config).onCancel)==null||o.call(n),this.close()});const i=this.element.querySelector('[data-dialog-default="ok"]');i==null||i.addEventListener("click",()=>this.handleSubmit())}this.config.closeOnEscape&&this.element.addEventListener("cancel",t=>{t.preventDefault(),this.close()}),this.config.closeOnBackdrop&&this.element.addEventListener("click",t=>{const i=this.element.getBoundingClientRect();(t.clientX<i.left||t.clientX>i.right||t.clientY<i.top||t.clientY>i.bottom)&&this.close()})}handleSubmit(){var t,i,n,o;const e=this.element.querySelector("form");if(e){const s=new FormData(e);(i=(t=this.config).onSubmit)==null||i.call(t,s)}else{const s=this.element.querySelectorAll("input, select, textarea"),a=new FormData;s.forEach(c=>{c.name&&a.append(c.name,c.value)}),(o=(n=this.config).onSubmit)==null||o.call(n,a)}this.close()}show(){document.body.appendChild(this.element),this.element.showModal()}close(){this.element.close(),this.element.remove()}destroy(){this.close()}}class L{constructor(e){this.isOpen=!1,this.config=e,this.selectedValue=e.value,this.element=this.createElement(),this.attachEventListeners()}createElement(){const e=document.createElement("div");e.className="editora-dropdown",this.config.width&&(e.style.width=this.config.width);const t=this.config.options.find(n=>n.value===this.selectedValue),i=(t==null?void 0:t.label)||this.config.placeholder||"Select...";return e.innerHTML=`
|
|
18
18
|
<button class="editora-dropdown-toggle" type="button">
|
|
19
19
|
<span class="editora-dropdown-label">${i}</span>
|
|
20
20
|
<span class="editora-dropdown-arrow">▼</span>
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
</div>
|
|
28
28
|
`).join("")}
|
|
29
29
|
</div>
|
|
30
|
-
`,e}attachEventListeners(){const e=this.element.querySelector(".editora-dropdown-toggle"),t=this.element.querySelector(".editora-dropdown-menu");e.addEventListener("click",n=>{n.stopPropagation(),this.isOpen=!this.isOpen,t.style.display=this.isOpen?"block":"none"}),this.element.querySelectorAll(".editora-dropdown-item").forEach(n=>{n.addEventListener("click",()=>{var s,a;const o=n.getAttribute("data-value");o&&(this.setValue(o),(a=(s=this.config).onChange)==null||a.call(s,o),this.close())})}),document.addEventListener("click",n=>{this.element.contains(n.target)||this.close()})}setValue(e){this.selectedValue=e;const t=this.config.options.find(n=>n.value===e),i=this.element.querySelector(".editora-dropdown-label");i&&t&&(i.textContent=t.label)}getValue(){return this.selectedValue}close(){this.isOpen=!1;const e=this.element.querySelector(".editora-dropdown-menu");e&&(e.style.display="none")}getElement(){return this.element}destroy(){this.element.remove()}}class
|
|
30
|
+
`,e}attachEventListeners(){const e=this.element.querySelector(".editora-dropdown-toggle"),t=this.element.querySelector(".editora-dropdown-menu");e.addEventListener("click",n=>{n.stopPropagation(),this.isOpen=!this.isOpen,t.style.display=this.isOpen?"block":"none"}),this.element.querySelectorAll(".editora-dropdown-item").forEach(n=>{n.addEventListener("click",()=>{var s,a;const o=n.getAttribute("data-value");o&&(this.setValue(o),(a=(s=this.config).onChange)==null||a.call(s,o),this.close())})}),document.addEventListener("click",n=>{this.element.contains(n.target)||this.close()})}setValue(e){this.selectedValue=e;const t=this.config.options.find(n=>n.value===e),i=this.element.querySelector(".editora-dropdown-label");i&&t&&(i.textContent=t.label)}getValue(){return this.selectedValue}close(){this.isOpen=!1;const e=this.element.querySelector(".editora-dropdown-menu");e&&(e.style.display="none")}getElement(){return this.element}destroy(){this.element.remove()}}class k{constructor(e){this.defaultPresets=["#000000","#434343","#666666","#999999","#B7B7B7","#CCCCCC","#D9D9D9","#EFEFEF","#F3F3F3","#FFFFFF","#980000","#FF0000","#FF9900","#FFFF00","#00FF00","#00FFFF","#4A86E8","#0000FF","#9900FF","#FF00FF","#E6B8AF","#F4CCCC","#FCE5CD","#FFF2CC","#D9EAD3","#D0E0E3","#C9DAF8","#CFE2F3","#D9D2E9","#EAD1DC"],this.config={presetColors:this.defaultPresets,...e},this.selectedColor=e.value,this.element=this.createElement(),this.attachEventListeners()}createElement(){var t;const e=document.createElement("div");return e.className="editora-color-picker",e.innerHTML=`
|
|
31
31
|
<div class="editora-color-picker-input">
|
|
32
32
|
<input type="color" value="${this.selectedColor||"#000000"}" />
|
|
33
33
|
<input type="text" value="${this.selectedColor||"#000000"}" placeholder="#000000" />
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
></button>
|
|
43
43
|
`).join("")}
|
|
44
44
|
</div>
|
|
45
|
-
`,e}attachEventListeners(){const e=this.element.querySelector('input[type="color"]'),t=this.element.querySelector('input[type="text"]');e.addEventListener("input",n=>{var s,a;const o=n.target.value;t.value=o,this.selectedColor=o,(a=(s=this.config).onChange)==null||a.call(s,o)}),t.addEventListener("input",n=>{var s,a;const o=n.target.value;/^#[0-9A-Fa-f]{6}$/.test(o)&&(e.value=o,this.selectedColor=o,(a=(s=this.config).onChange)==null||a.call(s,o))}),this.element.querySelectorAll(".editora-color-preset").forEach(n=>{n.addEventListener("click",()=>{var s,a;const o=n.getAttribute("data-color");o&&(e.value=o,t.value=o,this.selectedColor=o,(a=(s=this.config).onChange)==null||a.call(s,o))})})}getValue(){return this.selectedColor}setValue(e){this.selectedColor=e;const t=this.element.querySelector('input[type="color"]'),i=this.element.querySelector('input[type="text"]');t&&(t.value=e),i&&(i.value=e)}getElement(){return this.element}destroy(){this.element.remove()}}class
|
|
45
|
+
`,e}attachEventListeners(){const e=this.element.querySelector('input[type="color"]'),t=this.element.querySelector('input[type="text"]');e.addEventListener("input",n=>{var s,a;const o=n.target.value;t.value=o,this.selectedColor=o,(a=(s=this.config).onChange)==null||a.call(s,o)}),t.addEventListener("input",n=>{var s,a;const o=n.target.value;/^#[0-9A-Fa-f]{6}$/.test(o)&&(e.value=o,this.selectedColor=o,(a=(s=this.config).onChange)==null||a.call(s,o))}),this.element.querySelectorAll(".editora-color-preset").forEach(n=>{n.addEventListener("click",()=>{var s,a;const o=n.getAttribute("data-color");o&&(e.value=o,t.value=o,this.selectedColor=o,(a=(s=this.config).onChange)==null||a.call(s,o))})})}getValue(){return this.selectedColor}setValue(e){this.selectedColor=e;const t=this.element.querySelector('input[type="color"]'),i=this.element.querySelector('input[type="text"]');t&&(t.value=e),i&&(i.value=e)}getElement(){return this.element}destroy(){this.element.remove()}}class T{constructor(e){const{initialUrl:t="",initialText:i="",onSubmit:n,onCancel:o}=e;this.dialog=new m({title:"Insert/Edit Link",content:this.createFormHTML(t,i),onSubmit:s=>{const a=(s.get("url")||"").trim(),c=(s.get("text")||"").trim(),h=s.get("openInNewTab")==="on";if(!a){alert("Please enter a URL");return}n({url:a,text:c,openInNewTab:h}),this.dialog.close()},onCancel:()=>{o==null||o(),this.dialog.close()},width:"500px"})}createFormHTML(e,t){return`
|
|
46
46
|
<form class="link-dialog-form">
|
|
47
47
|
<div class="form-group">
|
|
48
48
|
<label for="link-url">URL</label>
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
</button>
|
|
91
91
|
</div>
|
|
92
92
|
</form>
|
|
93
|
-
`}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}show(){this.dialog.show()}close(){this.dialog.close()}}class
|
|
93
|
+
`}escapeHtml(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}show(){this.dialog.show()}close(){this.dialog.close()}}class M{constructor(e){const{onSubmit:t,onCancel:i}=e;this.dialog=new m({title:"Insert Table",content:this.createFormHTML(),onSubmit:n=>{const o=parseInt(n.get("rows"),10),s=parseInt(n.get("cols"),10),a=n.get("headerRow")==="on";if(o<1||o>100){alert("Please enter a valid number of rows (1-100)");return}if(s<1||s>20){alert("Please enter a valid number of columns (1-20)");return}t({rows:o,cols:s,headerRow:a}),this.dialog.close()},onCancel:()=>{i==null||i(),this.dialog.close()},width:"400px"})}createFormHTML(){return`
|
|
94
94
|
<form class="table-dialog-form">
|
|
95
95
|
<div class="form-group">
|
|
96
96
|
<label for="table-rows">Rows</label>
|
|
@@ -149,7 +149,7 @@
|
|
|
149
149
|
</button>
|
|
150
150
|
</div>
|
|
151
151
|
</form>
|
|
152
|
-
`}show(){this.dialog.show(),this.attachPreviewListeners()}close(){this.dialog.close()}attachPreviewListeners(){const e=document.querySelector(".table-dialog-form");if(!e)return;const t=e.querySelector("#table-rows"),i=e.querySelector("#table-cols"),n=e.querySelector("#table-header"),o=e.querySelector("#table-preview-content"),s=()=>{const a=parseInt((t==null?void 0:t.value)||"3",10),c=parseInt((i==null?void 0:i.value)||"3",10),h=n==null?void 0:n.checked;o&&(o.textContent=`${a} rows × ${c} columns${h?" with header":""}`)};t==null||t.addEventListener("input",s),i==null||i.addEventListener("input",s),n==null||n.addEventListener("change",s)}}class
|
|
152
|
+
`}show(){this.dialog.show(),this.attachPreviewListeners()}close(){this.dialog.close()}attachPreviewListeners(){const e=document.querySelector(".table-dialog-form");if(!e)return;const t=e.querySelector("#table-rows"),i=e.querySelector("#table-cols"),n=e.querySelector("#table-header"),o=e.querySelector("#table-preview-content"),s=()=>{const a=parseInt((t==null?void 0:t.value)||"3",10),c=parseInt((i==null?void 0:i.value)||"3",10),h=n==null?void 0:n.checked;o&&(o.textContent=`${a} rows × ${c} columns${h?" with header":""}`)};t==null||t.addEventListener("input",s),i==null||i.addEventListener("input",s),n==null||n.addEventListener("change",s)}}class I{constructor(e){this.config=e;const{onSubmit:t,onCancel:i}=e;this.dialog=new m({title:"Insert Image",content:this.createFormHTML(),onSubmit:n=>{const o=(n.get("src")||"").trim(),s=(n.get("alt")||"").trim(),a=(n.get("width")||"").trim(),c=(n.get("height")||"").trim();if(!o){alert("Please enter an image URL or upload an image");return}t({src:o,alt:s,width:a||void 0,height:c||void 0}),this.dialog.close()},onCancel:()=>{i==null||i(),this.dialog.close()},width:"500px"})}createFormHTML(){return`
|
|
153
153
|
<form class="image-dialog-form">
|
|
154
154
|
${this.config.allowUpload?`
|
|
155
155
|
<div class="form-group">
|
|
@@ -223,7 +223,7 @@
|
|
|
223
223
|
</button>
|
|
224
224
|
</div>
|
|
225
225
|
</form>
|
|
226
|
-
`}show(){this.dialog.show(),this.attachImagePreview(),this.attachFileUpload()}close(){this.dialog.close()}attachImagePreview(){const e=document.querySelector(".image-dialog-form");if(!e)return;const t=e.querySelector("#image-src"),i=e.querySelector("#image-preview"),n=e.querySelector("#preview-img");t==null||t.addEventListener("input",()=>{const o=t.value.trim();o&&this.isValidImageUrl(o)?(n.src=o,i.style.display="block",n.onerror=()=>{i.style.display="none"}):i.style.display="none"})}attachFileUpload(){if(!this.config.allowUpload)return;const e=document.querySelector(".image-dialog-form");if(!e)return;const t=e.querySelector("#image-upload"),i=e.querySelector("#image-src");t==null||t.addEventListener("change",async n=>{var a;const o=(a=n.target.files)==null?void 0:a[0];if(!o)return;const s=new FileReader;s.onload=c=>{var u;const h=(u=c.target)==null?void 0:u.result;i.value=h,i.dispatchEvent(new Event("input"))},s.readAsDataURL(o)})}isValidImageUrl(e){try{return new URL(e),/\.(jpg|jpeg|png|gif|svg|webp|bmp)$/i.test(e)||e.startsWith("data:image/")}catch(t){return!1}}}class
|
|
226
|
+
`}show(){this.dialog.show(),this.attachImagePreview(),this.attachFileUpload()}close(){this.dialog.close()}attachImagePreview(){const e=document.querySelector(".image-dialog-form");if(!e)return;const t=e.querySelector("#image-src"),i=e.querySelector("#image-preview"),n=e.querySelector("#preview-img");t==null||t.addEventListener("input",()=>{const o=t.value.trim();o&&this.isValidImageUrl(o)?(n.src=o,i.style.display="block",n.onerror=()=>{i.style.display="none"}):i.style.display="none"})}attachFileUpload(){if(!this.config.allowUpload)return;const e=document.querySelector(".image-dialog-form");if(!e)return;const t=e.querySelector("#image-upload"),i=e.querySelector("#image-src");t==null||t.addEventListener("change",async n=>{var a;const o=(a=n.target.files)==null?void 0:a[0];if(!o)return;const s=new FileReader;s.onload=c=>{var u;const h=(u=c.target)==null?void 0:u.result;i.value=h,i.dispatchEvent(new Event("input"))},s.readAsDataURL(o)})}isValidImageUrl(e){try{return new URL(e),/\.(jpg|jpeg|png|gif|svg|webp|bmp)$/i.test(e)||e.startsWith("data:image/")}catch(t){return!1}}}class P{constructor(e){this.onSubmit=e.onSubmit;const t=this.createContent();this.dialog=new m({title:"Insert Math Equation",content:t,buttons:[{label:"Cancel",onClick:()=>this.dialog.close()},{label:"Insert",onClick:()=>this.handleSubmit(),primary:!0}]}),this.latexInput=t.querySelector("#math-latex"),this.previewDiv=t.querySelector("#math-preview"),this.displayTypeSelect=t.querySelector("#math-display-type"),this.latexInput.addEventListener("input",()=>this.updatePreview())}createContent(){const e=document.createElement("div");return e.className="math-dialog-content",e.style.minWidth="500px",e.innerHTML=`
|
|
227
227
|
<style>
|
|
228
228
|
.math-dialog-content {
|
|
229
229
|
display: flex;
|
|
@@ -335,7 +335,7 @@
|
|
|
335
335
|
<option value="block">Block (centered, new line)</option>
|
|
336
336
|
</select>
|
|
337
337
|
</div>
|
|
338
|
-
`,e.querySelectorAll(".math-symbol-btn").forEach(i=>{i.addEventListener("click",n=>{n.preventDefault();const o=i.getAttribute("data-symbol");if(o&&this.latexInput){const s=this.latexInput.selectionStart,a=this.latexInput.selectionEnd,c=this.latexInput.value;this.latexInput.value=c.substring(0,s)+o+c.substring(a),this.latexInput.focus(),this.latexInput.selectionStart=this.latexInput.selectionEnd=s+o.length,this.updatePreview()}})}),e}updatePreview(){const e=this.latexInput.value.trim();if(!e){this.previewDiv.textContent="";return}const t=e.replace(/\\frac\{([^}]+)\}\{([^}]+)\}/g,"($1)/($2)").replace(/\^\{([^}]+)\}/g,"^$1").replace(/\_\{([^}]+)\}/g,"_$1").replace(/\\sqrt\{([^}]+)\}/g,"√($1)").replace(/\\sum/g,"∑").replace(/\\int/g,"∫").replace(/\\pi/g,"π").replace(/\\alpha/g,"α").replace(/\\beta/g,"β").replace(/\\gamma/g,"γ").replace(/\\theta/g,"θ").replace(/\\lambda/g,"λ").replace(/\\infty/g,"∞").replace(/\\leq/g,"≤").replace(/\\geq/g,"≥").replace(/\\neq/g,"≠");this.previewDiv.textContent=t}handleSubmit(){const e=this.latexInput.value.trim();if(!e){alert("Please enter a LaTeX expression.");return}const t=this.displayTypeSelect.value;this.onSubmit({latex:e,display:t}),this.dialog.close()}show(){this.dialog.show(),this.latexInput.value="",this.previewDiv.textContent="",this.displayTypeSelect.value="inline",setTimeout(()=>this.latexInput.focus(),100)}close(){this.dialog.close()}}class
|
|
338
|
+
`,e.querySelectorAll(".math-symbol-btn").forEach(i=>{i.addEventListener("click",n=>{n.preventDefault();const o=i.getAttribute("data-symbol");if(o&&this.latexInput){const s=this.latexInput.selectionStart,a=this.latexInput.selectionEnd,c=this.latexInput.value;this.latexInput.value=c.substring(0,s)+o+c.substring(a),this.latexInput.focus(),this.latexInput.selectionStart=this.latexInput.selectionEnd=s+o.length,this.updatePreview()}})}),e}updatePreview(){const e=this.latexInput.value.trim();if(!e){this.previewDiv.textContent="";return}const t=e.replace(/\\frac\{([^}]+)\}\{([^}]+)\}/g,"($1)/($2)").replace(/\^\{([^}]+)\}/g,"^$1").replace(/\_\{([^}]+)\}/g,"_$1").replace(/\\sqrt\{([^}]+)\}/g,"√($1)").replace(/\\sum/g,"∑").replace(/\\int/g,"∫").replace(/\\pi/g,"π").replace(/\\alpha/g,"α").replace(/\\beta/g,"β").replace(/\\gamma/g,"γ").replace(/\\theta/g,"θ").replace(/\\lambda/g,"λ").replace(/\\infty/g,"∞").replace(/\\leq/g,"≤").replace(/\\geq/g,"≥").replace(/\\neq/g,"≠");this.previewDiv.textContent=t}handleSubmit(){const e=this.latexInput.value.trim();if(!e){alert("Please enter a LaTeX expression.");return}const t=this.displayTypeSelect.value;this.onSubmit({latex:e,display:t}),this.dialog.close()}show(){this.dialog.show(),this.latexInput.value="",this.previewDiv.textContent="",this.displayTypeSelect.value="inline",setTimeout(()=>this.latexInput.focus(),100)}close(){this.dialog.close()}}class F{constructor(e){this.characters={common:["©","®","™","§","¶","†","‡","•","‣","⁃","◦","▪","▫","◊","○","●","□","■","△","▲","▽","▼","◇","◆","★","☆"],arrows:["←","→","↑","↓","↔","↕","⇐","⇒","⇑","⇓","⇔","⇕","⟵","⟶","⟷","↖","↗","↘","↙","⇖","⇗","⇘","⇙"],currency:["$","€","£","¥","₹","₽","₩","₪","₦","฿","₴","₡","₵","₸","₫","₱","₲","₳","₭"],math:["±","×","÷","=","≠","≈","≡","≤","≥","<",">","∞","∑","∏","∫","∂","√","∛","∜","°","′","″","∠","∟","⊥","∥"],greek:["α","β","γ","δ","ε","ζ","η","θ","ι","κ","λ","μ","ν","ξ","ο","π","ρ","σ","τ","υ","φ","χ","ψ","ω","Α","Β","Γ","Δ","Ε","Ζ","Η","Θ"],punctuation:["‚","„","“","”","‘","’","«","»","‹","›","—","–","…","·","¡","¿","‰","′","″","‴"],superscript:["⁰","¹","²","³","⁴","⁵","⁶","⁷","⁸","⁹","⁺","⁻","⁼","⁽","⁾","ⁿ","ⁱ"],subscript:["₀","₁","₂","₃","₄","₅","₆","₇","₈","₉","₊","₋","₌","₍","₎"]},this.onSelect=e.onSelect;const t=this.createContent();this.dialog=new m({title:"Insert Special Character",content:t,buttons:[{label:"Close",onClick:()=>this.dialog.close()}]}),this.searchInput=t.querySelector("#char-search"),this.categorySelect=t.querySelector("#char-category"),this.charactersGrid=t.querySelector("#char-grid"),this.searchInput.addEventListener("input",()=>this.filterCharacters()),this.categorySelect.addEventListener("change",()=>this.updateGrid()),this.updateGrid()}createContent(){const e=document.createElement("div");return e.className="character-dialog-content",e.style.minWidth="500px",e.innerHTML=`
|
|
339
339
|
<style>
|
|
340
340
|
.character-dialog-content {
|
|
341
341
|
display: flex;
|
|
@@ -422,7 +422,7 @@
|
|
|
422
422
|
<div class="char-info">
|
|
423
423
|
Click any character to insert it into your document.
|
|
424
424
|
</div>
|
|
425
|
-
`,e}updateGrid(){const e=this.categorySelect.value;this.charactersGrid.innerHTML="";let t=[];e==="all"?t=Object.values(this.characters).flat():t=this.characters[e]||[],t.forEach(i=>{const n=document.createElement("button");n.className="char-button",n.textContent=i,n.title=`Insert ${i} (U+${i.charCodeAt(0).toString(16).toUpperCase()})`,n.addEventListener("click",o=>{o.preventDefault(),this.handleSelect(i)}),this.charactersGrid.appendChild(n)})}filterCharacters(){const e=this.searchInput.value.toLowerCase();this.charactersGrid.querySelectorAll(".char-button").forEach(i=>{const n=i.textContent||"",o=`u+${n.charCodeAt(0).toString(16)}`,s=!e||n.includes(e)||o.includes(e);i.style.display=s?"flex":"none"})}handleSelect(e){this.onSelect(e),this.dialog.close()}show(){this.dialog.show(),this.searchInput.value="",this.categorySelect.value="all",this.updateGrid(),setTimeout(()=>this.searchInput.focus(),100)}close(){this.dialog.close()}}class
|
|
425
|
+
`,e}updateGrid(){const e=this.categorySelect.value;this.charactersGrid.innerHTML="";let t=[];e==="all"?t=Object.values(this.characters).flat():t=this.characters[e]||[],t.forEach(i=>{const n=document.createElement("button");n.className="char-button",n.textContent=i,n.title=`Insert ${i} (U+${i.charCodeAt(0).toString(16).toUpperCase()})`,n.addEventListener("click",o=>{o.preventDefault(),this.handleSelect(i)}),this.charactersGrid.appendChild(n)})}filterCharacters(){const e=this.searchInput.value.toLowerCase();this.charactersGrid.querySelectorAll(".char-button").forEach(i=>{const n=i.textContent||"",o=`u+${n.charCodeAt(0).toString(16)}`,s=!e||n.includes(e)||o.includes(e);i.style.display=s?"flex":"none"})}handleSelect(e){this.onSelect(e),this.dialog.close()}show(){this.dialog.show(),this.searchInput.value="",this.categorySelect.value="all",this.updateGrid(),setTimeout(()=>this.searchInput.focus(),100)}close(){this.dialog.close()}}class q{constructor(e){this.emojis={popular:["😀","😃","😄","😁","😊","😍","🤩","😘","😗","😚","😙","🙂","🤗","🤔","🤨","😐","😑","😶","🙄","😏","👍","👎","👌","✌️","🤞","🤝","👏","🙌","👋","🤚","✋","🖐️","🖖","👊","✊","🤛","🤜","💪"],smileys:["😀","😃","😄","😁","😆","😅","🤣","😂","🙂","🙃","😉","😊","😇","🥰","😍","🤩","😘","😗","😚","😙","😋","😛","😜","🤪","😝","🤑","🤗","🤭","🤫","🤔"],emotions:["😳","😞","😟","😠","😡","🤬","😔","😕","🙁","😬","🥺","😣","😖","😫","😩","🥱","😤","😮","😱","😨","😰","😥","😢","😭","😪","😓","🤤","😴","😷","🤒"],gestures:["👍","👎","👌","✌️","🤞","🤟","🤘","🤙","👈","👉","👆","👇","☝️","👋","🤚","✋","🖐️","🖖","👏","🙌","👐","🤲","🤝","🙏","✍️","💅","🤳","💪","🦾","🦿"],people:["👶","👧","🧒","👦","👩","🧑","👨","👵","🧓","👴","👲","👳","🧕","👮","👷","💂","🕵️","👩⚕️","👨⚕️","👩🎓","👨🎓","👩🏫","👨🏫","👩⚖️","👨⚖️","👩🌾","👨🌾","👩🍳","👨🍳","👩🔧"],animals:["🐶","🐱","🐭","🐹","🐰","🦊","🐻","🐼","🐨","🐯","🦁","🐮","🐷","🐸","🐵","🙈","🙉","🙊","🐔","🐧","🐦","🐤","🐣","🐥","🦆","🦅","🦉","🦇","🐺","🐗"],nature:["🌵","🎄","🌲","🌳","🌴","🌱","🌿","☘️","🍀","🎍","🎋","🍃","🍂","🍁","🍄","🌾","💐","🌷","🌹","🥀","🌺","🌸","🌼","🌻","🌞","🌝","🌛","🌜","⭐","🌟"],food:["🍏","🍎","🍐","🍊","🍋","🍌","🍉","🍇","🍓","🍈","🍒","🍑","🥭","🍍","🥥","🥝","🍅","🍆","🥑","🥦","🥬","🥒","🌶️","🌽","🥕","🧄","🧅","🥔","🍠","🥐"],objects:["⌚","📱","💻","⌨️","🖥️","🖨️","🖱️","🕹️","💾","💿","📀","📷","📹","🎥","📞","☎️","📟","📠","📺","📻","🎙️","🎚️","🎛️","🧭","⏱️","⏰","📡","🔋","🔌","💡"],symbols:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","🤎","💔","❣️","💕","💞","💓","💗","💖","💘","💝","✨","💫","⭐","🌟","✔️","✅","❌","❎","➕","➖","✖️","➗"],activities:["⚽","🏀","🏈","⚾","🥎","🎾","🏐","🏉","🥏","🎱","🪀","🏓","🏸","🏒","🏑","🥍","🏏","🪃","🥅","⛳","🪁","🏹","🎣","🤿","🥊","🥋","🎽","🛹","🛼","🛷"]},this.onSelect=e.onSelect;const t=this.createContent();this.dialog=new m({title:"Insert Emoji",content:t,buttons:[{label:"Close",onClick:()=>this.dialog.close()}]}),this.searchInput=t.querySelector("#emoji-search"),this.categorySelect=t.querySelector("#emoji-category"),this.emojisGrid=t.querySelector("#emoji-grid"),this.searchInput.addEventListener("input",()=>this.filterEmojis()),this.categorySelect.addEventListener("change",()=>this.updateGrid()),this.updateGrid()}createContent(){const e=document.createElement("div");return e.className="emoji-dialog-content",e.style.minWidth="500px",e.innerHTML=`
|
|
426
426
|
<style>
|
|
427
427
|
.emoji-dialog-content {
|
|
428
428
|
display: flex;
|
|
@@ -512,5 +512,5 @@
|
|
|
512
512
|
<div class="emoji-info">
|
|
513
513
|
Click any emoji to insert it into your document.
|
|
514
514
|
</div>
|
|
515
|
-
`,e}updateGrid(){const e=this.categorySelect.value;this.emojisGrid.innerHTML="";let t=[];e==="all"?t=Object.values(this.emojis).flat():t=this.emojis[e]||[],t.forEach(i=>{const n=document.createElement("button");n.className="emoji-button",n.textContent=i,n.title=`Insert ${i}`,n.addEventListener("click",o=>{o.preventDefault(),this.handleSelect(i)}),this.emojisGrid.appendChild(n)})}filterEmojis(){const e=this.searchInput.value.toLowerCase();this.emojisGrid.querySelectorAll(".emoji-button").forEach(i=>{const n=i.textContent||"",o=!e||n.includes(e);i.style.display=o?"flex":"none"})}handleSelect(e){this.onSelect(e),this.dialog.close()}show(){this.dialog.show(),this.searchInput.value="",this.categorySelect.value="popular",this.updateGrid(),setTimeout(()=>this.searchInput.focus(),100)}close(){this.dialog.close()}}class
|
|
515
|
+
`,e}updateGrid(){const e=this.categorySelect.value;this.emojisGrid.innerHTML="";let t=[];e==="all"?t=Object.values(this.emojis).flat():t=this.emojis[e]||[],t.forEach(i=>{const n=document.createElement("button");n.className="emoji-button",n.textContent=i,n.title=`Insert ${i}`,n.addEventListener("click",o=>{o.preventDefault(),this.handleSelect(i)}),this.emojisGrid.appendChild(n)})}filterEmojis(){const e=this.searchInput.value.toLowerCase();this.emojisGrid.querySelectorAll(".emoji-button").forEach(i=>{const n=i.textContent||"",o=!e||n.includes(e);i.style.display=o?"flex":"none"})}handleSelect(e){this.onSelect(e),this.dialog.close()}show(){this.dialog.show(),this.searchInput.value="",this.categorySelect.value="popular",this.updateGrid(),setTimeout(()=>this.searchInput.focus(),100)}close(){this.dialog.close()}}class v{constructor(e={}){this.changeListeners=[],this.options=e,this.engine=new l.EditorEngine({content:e.content,plugins:e.plugins||[],readonly:e.readonly}),e.onChange&&this.onChange(e.onChange),this.engine.on("change",()=>{const t=this.getHTML();this.changeListeners.forEach(i=>i(t))})}mount(e,t){this.contentElement=e,this.toolbarElement=t,this.contentElement.contentEditable=this.options.readonly?"false":"true",this.contentElement.className="rte-content",this.options.content&&(this.contentElement.innerHTML=this.options.content),this.options.toolbar!==!1&&this.toolbarElement&&(this.toolbar=new l.ToolbarRenderer({items:typeof this.options.toolbar=="string"?this.options.toolbar:void 0},this.options.plugins||[]),this.toolbar.setCommandHandler((i,n)=>{this.execCommand(i,n)}),this.toolbar.render(this.toolbarElement)),this.contentElement.addEventListener("input",()=>{const i=this.getHTML();this.changeListeners.forEach(n=>n(i))}),this.options.onInit&&this.options.onInit(this.getAPI())}getHTML(){var e;return((e=this.contentElement)==null?void 0:e.innerHTML)||""}setHTML(e){this.contentElement&&(this.contentElement.innerHTML=e)}execCommand(e,t){const i=this.engine.execCommand(e,t);return this.toolbar,i}focus(){var e;(e=this.contentElement)==null||e.focus()}blur(){var e;(e=this.contentElement)==null||e.blur()}onChange(e){return this.changeListeners.push(e),()=>{const t=this.changeListeners.indexOf(e);t>-1&&this.changeListeners.splice(t,1)}}registerCommand(e,t){if(typeof window!="undefined"){const i=window.__editorCommands||new Map;i.set(e,t),window.__editorCommands=i}}getState(){return{plugins:this.options.plugins,config:this.options,engine:this.engine.getState()}}getAPI(){var e;return{getHTML:()=>this.getHTML(),setHTML:t=>this.setHTML(t),execCommand:(t,i)=>this.execCommand(t,i),focus:()=>this.focus(),blur:()=>this.blur(),destroy:()=>this.destroy(),registerCommand:(t,i)=>this.registerCommand(t,i),onChange:t=>this.onChange(t),getState:()=>this.getState(),toolbar:{items:((e=this.options.plugins)==null?void 0:e.flatMap(t=>t.toolbar||[]))||[]}}}destroy(){var e;this.engine.destroy(),(e=this.toolbar)==null||e.destroy(),this.changeListeners=[],this.options.onDestroy&&this.options.onDestroy()}}function j(r){return new v(r)}class E{constructor(e){this.options=e,this.containerElement=e.element;const t=this.resolvePlugins(e.plugins);this.engine=new l.EditorEngine({content:e.content,plugins:t,readonly:e.readonly}),this.initializeDOM()}resolvePlugins(e){return e?typeof e=="string"?(console.warn("String-based plugin loading not yet implemented for VanillaAdapter"),[]):e:[]}initializeDOM(){this.containerElement.innerHTML="",this.containerElement.classList.add("editora-editor"),this.options.enableToolbar!==!1&&this.options.toolbar!==!1&&(this.toolbarElement=document.createElement("div"),this.toolbarElement.className="editora-toolbar-container",this.containerElement.appendChild(this.toolbarElement),this.toolbar=new l.ToolbarRenderer({items:typeof this.options.toolbar=="string"?this.options.toolbar:void 0},this.options.plugins||[]),this.toolbar.setCommandHandler((e,t)=>{this.execCommand(e,t)}),this.toolbar.render(this.toolbarElement)),this.contentElement=document.createElement("div"),this.contentElement.className="editora-content",this.contentElement.contentEditable=this.options.readonly?"false":"true",this.contentElement.style.minHeight="200px",this.contentElement.style.outline="none",this.contentElement.style.padding="12px",this.options.content&&(this.contentElement.innerHTML=this.options.content),this.containerElement.appendChild(this.contentElement),this.contentElement.addEventListener("input",()=>{this.containerElement.dispatchEvent(new CustomEvent("change",{detail:{html:this.getContent()}}))})}getContent(){var e;return((e=this.contentElement)==null?void 0:e.innerHTML)||""}setContent(e){this.contentElement&&(this.contentElement.innerHTML=e)}execCommand(e,t){return this.engine.execCommand(e,t)}focus(){var e;(e=this.contentElement)==null||e.focus()}on(e,t){const i=n=>{t(n.detail)};return this.containerElement.addEventListener(e,i),()=>{this.containerElement.removeEventListener(e,i)}}destroy(){var e;this.engine.destroy(),(e=this.toolbar)==null||e.destroy(),this.containerElement.innerHTML=""}}function H(r){return new E(r)}function $(){typeof window!="undefined"&&!customElements.get("editora-editor")&&customElements.define("editora-editor",l.RichTextEditorElement)}exports.CommandRegistry=l.CommandRegistry;exports.ConfigResolver=l.ConfigResolver;exports.EditorEngine=l.EditorEngine;exports.EditorState=l.EditorState;exports.FloatingToolbar=l.FloatingToolbar;exports.KeyboardShortcutManager=l.KeyboardShortcutManager;exports.PluginLoader=l.PluginLoader;exports.PluginManager=l.PluginManager;exports.RichTextEditorElement=l.RichTextEditorElement;exports.Schema=l.Schema;exports.StatusBar=l.StatusBar;exports.ToolbarRenderer=l.ToolbarRenderer;exports.calculateTextStats=l.calculateTextStats;exports.countLines=l.countLines;exports.createPluginManager=l.createPluginManager;exports.getCleanEditorHTML=l.getCleanEditorHTML;exports.getCursorPosition=l.getCursorPosition;exports.getSelectionInfo=l.getSelectionInfo;exports.getTextOffset=l.getTextOffset;exports.sanitizeHTML=l.sanitizeHTML;exports.sanitizeInputHTML=l.sanitizeInputHTML;exports.sanitizePastedHTML=l.sanitizePastedHTML;exports.stripEditorUiArtifacts=l.stripEditorUiArtifacts;exports.CharacterDialog=F;exports.ColorPicker=k;exports.Dialog=m;exports.DocumentModel=p;exports.Dropdown=L;exports.Editor=w;exports.EmojiDialog=q;exports.ImageDialog=I;exports.LinkDialog=T;exports.MathDialog=P;exports.MediaPlugin=C;exports.PluginRuntime=f;exports.ReactAdapter=v;exports.SpellcheckPlugin=S;exports.TableDialog=M;exports.VanillaAdapter=E;exports.createEditor=H;exports.createPluginRuntime=x;exports.createReactAdapter=j;exports.initWebComponent=$;
|
|
516
516
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as g, E
|
|
2
|
-
import { C as
|
|
3
|
-
class
|
|
1
|
+
import { P as g, E, a as f, T as y, R as w } from "./index-DeUjxpKd.mjs";
|
|
2
|
+
import { C as V, b as K, F as B, K as W, c as X, S as _, d as Y, e as J, f as Q, g as Z, h as ee, i as te, j as ie, k as ne, s as oe, l as se, m as ae, n as le } from "./index-DeUjxpKd.mjs";
|
|
3
|
+
class T {
|
|
4
4
|
constructor(e) {
|
|
5
5
|
if (this.listeners = [], e instanceof g)
|
|
6
6
|
this.pluginManager = e;
|
|
@@ -11,7 +11,7 @@ class L {
|
|
|
11
11
|
}), i.element && (this.domElement = i.element, this.setupDOMElement(i));
|
|
12
12
|
}
|
|
13
13
|
const t = this.pluginManager.buildSchema();
|
|
14
|
-
this.state =
|
|
14
|
+
this.state = E.create(t), this.commands = this.pluginManager.getCommands();
|
|
15
15
|
}
|
|
16
16
|
setupDOMElement(e) {
|
|
17
17
|
this.domElement && (e.enableToolbar !== !1 && e.toolbarElement ? this.toolbarElement = e.toolbarElement : e.enableToolbar !== !1 && (this.toolbarElement = document.createElement("div"), this.toolbarElement.className = "editora-toolbar-container", this.domElement.appendChild(this.toolbarElement)), this.contentElement = document.createElement("div"), this.contentElement.contentEditable = "true", this.contentElement.className = "editora-content", this.contentElement.style.minHeight = "200px", this.contentElement.style.outline = "none", this.contentElement.style.padding = "12px", e.content && (this.contentElement.innerHTML = e.content), this.domElement.appendChild(this.contentElement), this.contentElement.addEventListener("input", () => {
|
|
@@ -73,7 +73,7 @@ class L {
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
class
|
|
76
|
+
class x {
|
|
77
77
|
constructor(e) {
|
|
78
78
|
this.initialized = !1, this.plugin = e;
|
|
79
79
|
}
|
|
@@ -142,10 +142,17 @@ class E {
|
|
|
142
142
|
return this.context;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
function
|
|
146
|
-
return new
|
|
145
|
+
function M(l) {
|
|
146
|
+
return new x(l);
|
|
147
|
+
}
|
|
148
|
+
const b = /* @__PURE__ */ new Set();
|
|
149
|
+
function v(l, e) {
|
|
150
|
+
b.has(l) || (b.add(l), console.warn(
|
|
151
|
+
`[Editora] ${l} from @editora/core is a deprecated, non-functional scaffold: its commands and toolbar buttons do nothing. It will be removed in a future major release - use ${e} instead.`
|
|
152
|
+
));
|
|
147
153
|
}
|
|
148
|
-
function
|
|
154
|
+
function I(l = {}) {
|
|
155
|
+
v("SpellcheckPlugin", "`SpellCheckPlugin` from @editora/spell-check");
|
|
149
156
|
const {
|
|
150
157
|
enabled: e = !1,
|
|
151
158
|
provider: t = "browser",
|
|
@@ -198,7 +205,8 @@ function T(l = {}) {
|
|
|
198
205
|
] : []
|
|
199
206
|
};
|
|
200
207
|
}
|
|
201
|
-
function
|
|
208
|
+
function F(l = {}) {
|
|
209
|
+
v("MediaPlugin", "`MediaManagerPlugin` from @editora/media-manager");
|
|
202
210
|
const {
|
|
203
211
|
uploadUrl: e = "",
|
|
204
212
|
libraryUrl: t = "",
|
|
@@ -212,7 +220,7 @@ function I(l = {}) {
|
|
|
212
220
|
enableChunking: r = !0,
|
|
213
221
|
onProgress: d,
|
|
214
222
|
onError: h,
|
|
215
|
-
onSuccess:
|
|
223
|
+
onSuccess: L
|
|
216
224
|
} = l;
|
|
217
225
|
return {
|
|
218
226
|
name: "media",
|
|
@@ -391,7 +399,7 @@ class u {
|
|
|
391
399
|
this.close();
|
|
392
400
|
}
|
|
393
401
|
}
|
|
394
|
-
class
|
|
402
|
+
class q {
|
|
395
403
|
constructor(e) {
|
|
396
404
|
this.isOpen = !1, this.config = e, this.selectedValue = e.value, this.element = this.createElement(), this.attachEventListeners();
|
|
397
405
|
}
|
|
@@ -448,7 +456,7 @@ class M {
|
|
|
448
456
|
this.element.remove();
|
|
449
457
|
}
|
|
450
458
|
}
|
|
451
|
-
class
|
|
459
|
+
class j {
|
|
452
460
|
constructor(e) {
|
|
453
461
|
this.defaultPresets = [
|
|
454
462
|
"#000000",
|
|
@@ -539,7 +547,7 @@ class F {
|
|
|
539
547
|
this.element.remove();
|
|
540
548
|
}
|
|
541
549
|
}
|
|
542
|
-
class
|
|
550
|
+
class P {
|
|
543
551
|
constructor(e) {
|
|
544
552
|
const { initialUrl: t = "", initialText: i = "", onSubmit: n, onCancel: o } = e;
|
|
545
553
|
this.dialog = new u({
|
|
@@ -621,7 +629,7 @@ class q {
|
|
|
621
629
|
this.dialog.close();
|
|
622
630
|
}
|
|
623
631
|
}
|
|
624
|
-
class
|
|
632
|
+
class $ {
|
|
625
633
|
constructor(e) {
|
|
626
634
|
const { onSubmit: t, onCancel: i } = e;
|
|
627
635
|
this.dialog = new u({
|
|
@@ -723,7 +731,7 @@ class j {
|
|
|
723
731
|
t == null || t.addEventListener("input", s), i == null || i.addEventListener("input", s), n == null || n.addEventListener("change", s);
|
|
724
732
|
}
|
|
725
733
|
}
|
|
726
|
-
class
|
|
734
|
+
class H {
|
|
727
735
|
constructor(e) {
|
|
728
736
|
this.config = e;
|
|
729
737
|
const { onSubmit: t, onCancel: i } = e;
|
|
@@ -868,7 +876,7 @@ class $ {
|
|
|
868
876
|
}
|
|
869
877
|
}
|
|
870
878
|
}
|
|
871
|
-
class
|
|
879
|
+
class A {
|
|
872
880
|
constructor(e) {
|
|
873
881
|
this.onSubmit = e.onSubmit;
|
|
874
882
|
const t = this.createContent();
|
|
@@ -1038,7 +1046,7 @@ class P {
|
|
|
1038
1046
|
this.dialog.close();
|
|
1039
1047
|
}
|
|
1040
1048
|
}
|
|
1041
|
-
class
|
|
1049
|
+
class z {
|
|
1042
1050
|
constructor(e) {
|
|
1043
1051
|
this.characters = {
|
|
1044
1052
|
common: ["©", "®", "™", "§", "¶", "†", "‡", "•", "‣", "⁃", "◦", "▪", "▫", "◊", "○", "●", "□", "■", "△", "▲", "▽", "▼", "◇", "◆", "★", "☆"],
|
|
@@ -1181,7 +1189,7 @@ class H {
|
|
|
1181
1189
|
this.dialog.close();
|
|
1182
1190
|
}
|
|
1183
1191
|
}
|
|
1184
|
-
class
|
|
1192
|
+
class D {
|
|
1185
1193
|
constructor(e) {
|
|
1186
1194
|
this.emojis = {
|
|
1187
1195
|
popular: ["😀", "😃", "😄", "😁", "😊", "😍", "🤩", "😘", "😗", "😚", "😙", "🙂", "🤗", "🤔", "🤨", "😐", "😑", "😶", "🙄", "😏", "👍", "👎", "👌", "✌️", "🤞", "🤝", "👏", "🙌", "👋", "🤚", "✋", "🖐️", "🖖", "👊", "✊", "🤛", "🤜", "💪"],
|
|
@@ -1330,9 +1338,9 @@ class z {
|
|
|
1330
1338
|
this.dialog.close();
|
|
1331
1339
|
}
|
|
1332
1340
|
}
|
|
1333
|
-
class
|
|
1341
|
+
class S {
|
|
1334
1342
|
constructor(e = {}) {
|
|
1335
|
-
this.changeListeners = [], this.options = e, this.engine = new
|
|
1343
|
+
this.changeListeners = [], this.options = e, this.engine = new f({
|
|
1336
1344
|
content: e.content,
|
|
1337
1345
|
plugins: e.plugins || [],
|
|
1338
1346
|
readonly: e.readonly
|
|
@@ -1345,7 +1353,7 @@ class x {
|
|
|
1345
1353
|
* Mount editor to DOM elements
|
|
1346
1354
|
*/
|
|
1347
1355
|
mount(e, t) {
|
|
1348
|
-
this.contentElement = e, this.toolbarElement = t, this.contentElement.contentEditable = this.options.readonly ? "false" : "true", this.contentElement.className = "rte-content", this.options.content && (this.contentElement.innerHTML = this.options.content), this.options.toolbar !== !1 && this.toolbarElement && (this.toolbar = new
|
|
1356
|
+
this.contentElement = e, this.toolbarElement = t, this.contentElement.contentEditable = this.options.readonly ? "false" : "true", this.contentElement.className = "rte-content", this.options.content && (this.contentElement.innerHTML = this.options.content), this.options.toolbar !== !1 && this.toolbarElement && (this.toolbar = new y(
|
|
1349
1357
|
{
|
|
1350
1358
|
items: typeof this.options.toolbar == "string" ? this.options.toolbar : void 0
|
|
1351
1359
|
},
|
|
@@ -1447,14 +1455,14 @@ class x {
|
|
|
1447
1455
|
this.engine.destroy(), (e = this.toolbar) == null || e.destroy(), this.changeListeners = [], this.options.onDestroy && this.options.onDestroy();
|
|
1448
1456
|
}
|
|
1449
1457
|
}
|
|
1450
|
-
function
|
|
1451
|
-
return new
|
|
1458
|
+
function U(l) {
|
|
1459
|
+
return new S(l);
|
|
1452
1460
|
}
|
|
1453
|
-
class
|
|
1461
|
+
class C {
|
|
1454
1462
|
constructor(e) {
|
|
1455
1463
|
this.options = e, this.containerElement = e.element;
|
|
1456
1464
|
const t = this.resolvePlugins(e.plugins);
|
|
1457
|
-
this.engine = new
|
|
1465
|
+
this.engine = new f({
|
|
1458
1466
|
content: e.content,
|
|
1459
1467
|
plugins: t,
|
|
1460
1468
|
readonly: e.readonly
|
|
@@ -1470,7 +1478,7 @@ class w {
|
|
|
1470
1478
|
* Initialize DOM elements
|
|
1471
1479
|
*/
|
|
1472
1480
|
initializeDOM() {
|
|
1473
|
-
this.containerElement.innerHTML = "", this.containerElement.classList.add("editora-editor"), this.options.enableToolbar !== !1 && this.options.toolbar !== !1 && (this.toolbarElement = document.createElement("div"), this.toolbarElement.className = "editora-toolbar-container", this.containerElement.appendChild(this.toolbarElement), this.toolbar = new
|
|
1481
|
+
this.containerElement.innerHTML = "", this.containerElement.classList.add("editora-editor"), this.options.enableToolbar !== !1 && this.options.toolbar !== !1 && (this.toolbarElement = document.createElement("div"), this.toolbarElement.className = "editora-toolbar-container", this.containerElement.appendChild(this.toolbarElement), this.toolbar = new y(
|
|
1474
1482
|
{
|
|
1475
1483
|
items: typeof this.options.toolbar == "string" ? this.options.toolbar : void 0
|
|
1476
1484
|
},
|
|
@@ -1528,52 +1536,55 @@ class w {
|
|
|
1528
1536
|
this.engine.destroy(), (e = this.toolbar) == null || e.destroy(), this.containerElement.innerHTML = "";
|
|
1529
1537
|
}
|
|
1530
1538
|
}
|
|
1531
|
-
function
|
|
1532
|
-
return new
|
|
1539
|
+
function R(l) {
|
|
1540
|
+
return new C(l);
|
|
1533
1541
|
}
|
|
1534
|
-
function
|
|
1535
|
-
typeof window != "undefined" && !customElements.get("editora-editor") && customElements.define("editora-editor",
|
|
1542
|
+
function N() {
|
|
1543
|
+
typeof window != "undefined" && !customElements.get("editora-editor") && customElements.define("editora-editor", w);
|
|
1536
1544
|
}
|
|
1537
1545
|
export {
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1546
|
+
z as CharacterDialog,
|
|
1547
|
+
j as ColorPicker,
|
|
1548
|
+
V as CommandRegistry,
|
|
1549
|
+
K as ConfigResolver,
|
|
1542
1550
|
u as Dialog,
|
|
1543
1551
|
m as DocumentModel,
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1552
|
+
q as Dropdown,
|
|
1553
|
+
T as Editor,
|
|
1554
|
+
f as EditorEngine,
|
|
1555
|
+
E as EditorState,
|
|
1556
|
+
D as EmojiDialog,
|
|
1557
|
+
B as FloatingToolbar,
|
|
1558
|
+
H as ImageDialog,
|
|
1559
|
+
W as KeyboardShortcutManager,
|
|
1560
|
+
P as LinkDialog,
|
|
1561
|
+
A as MathDialog,
|
|
1562
|
+
F as MediaPlugin,
|
|
1563
|
+
X as PluginLoader,
|
|
1556
1564
|
g as PluginManager,
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1565
|
+
x as PluginRuntime,
|
|
1566
|
+
S as ReactAdapter,
|
|
1567
|
+
w as RichTextEditorElement,
|
|
1568
|
+
_ as Schema,
|
|
1569
|
+
I as SpellcheckPlugin,
|
|
1570
|
+
Y as StatusBar,
|
|
1571
|
+
$ as TableDialog,
|
|
1572
|
+
y as ToolbarRenderer,
|
|
1573
|
+
C as VanillaAdapter,
|
|
1574
|
+
J as calculateTextStats,
|
|
1575
|
+
Q as countLines,
|
|
1576
|
+
R as createEditor,
|
|
1577
|
+
Z as createPluginManager,
|
|
1578
|
+
M as createPluginRuntime,
|
|
1579
|
+
U as createReactAdapter,
|
|
1580
|
+
ee as getCleanEditorHTML,
|
|
1581
|
+
te as getCursorPosition,
|
|
1582
|
+
ie as getSelectionInfo,
|
|
1583
|
+
ne as getTextOffset,
|
|
1584
|
+
N as initWebComponent,
|
|
1585
|
+
oe as sanitizeHTML,
|
|
1586
|
+
se as sanitizeInputHTML,
|
|
1587
|
+
ae as sanitizePastedHTML,
|
|
1588
|
+
le as stripEditorUiArtifacts
|
|
1578
1589
|
};
|
|
1579
1590
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/plugin-loader.js
CHANGED
|
@@ -14,7 +14,7 @@ const r = {
|
|
|
14
14
|
lineHeight: () => import("./LineHeightPlugin.native-CM7iXdQj.mjs").then((n) => n.LineHeightPlugin()),
|
|
15
15
|
capitalization: () => import("./CapitalizationPlugin.native-C-HRbXGh.mjs").then((n) => n.CapitalizationPlugin()),
|
|
16
16
|
link: () => import("./LinkPlugin.native-BsQXYsK6.mjs").then((n) => n.LinkPlugin()),
|
|
17
|
-
table: () => import("./TablePlugin.native-
|
|
17
|
+
table: () => import("./TablePlugin.native-C1YZ372P.mjs").then((n) => n.TablePlugin()),
|
|
18
18
|
trackChanges: () => import("./TrackChangesPlugin.native-Bghu2q4a.mjs").then((n) => n.TrackChangesPlugin()),
|
|
19
19
|
versionDiff: () => import("./VersionDiffPlugin.native-Ca1fMWUJ.mjs").then((n) => n.VersionDiffPlugin()),
|
|
20
20
|
"version-diff": () => import("./VersionDiffPlugin.native-Ca1fMWUJ.mjs").then((n) => n.VersionDiffPlugin()),
|
|
@@ -57,7 +57,7 @@ const r = {
|
|
|
57
57
|
mergeTag: () => import("./MergeTagPlugin.native-7-6F3S1Y.mjs").then((n) => n.MergeTagPlugin()),
|
|
58
58
|
pageBreak: () => import("./PageBreakPlugin.native-DijGuHJZ.mjs").then((n) => n.PageBreakPlugin()),
|
|
59
59
|
print: () => import("./PrintPlugin.native-7qt5v7L5.mjs").then((n) => n.PrintPlugin()),
|
|
60
|
-
preview: () => import("./PreviewPlugin.native-
|
|
60
|
+
preview: () => import("./PreviewPlugin.native-Dyht8mGi.mjs").then((n) => n.PreviewPlugin()),
|
|
61
61
|
specialCharacters: () => import("./SpecialCharactersPlugin.native-CdZoc1GB.mjs").then((n) => n.SpecialCharactersPlugin()),
|
|
62
62
|
slashCommands: () => import("./SlashCommandsPlugin.native-BDIIwGNs.mjs").then((n) => n.SlashCommandsPlugin()),
|
|
63
63
|
"slash-commands": () => import("./SlashCommandsPlugin.native-BDIIwGNs.mjs").then((n) => n.SlashCommandsPlugin()),
|
|
@@ -66,9 +66,9 @@ const r = {
|
|
|
66
66
|
a11yChecker: () => import("./A11yCheckerPlugin.native-DIKuCeFw.mjs").then((n) => n.A11yCheckerPlugin()),
|
|
67
67
|
comments: () => import("./CommentsPlugin.native-CLip9wAO.mjs").then((n) => n.CommentsPlugin()),
|
|
68
68
|
collaboration: () => import("./CollaborationPlugin.native-oSybCGPW.mjs").then((n) => n.CollaborationPlugin()),
|
|
69
|
-
"document-manager": () => import("./DocumentManagerPlugin.native-
|
|
69
|
+
"document-manager": () => import("./DocumentManagerPlugin.native-B8K-Oqom.mjs").then((n) => n.DocumentManagerPlugin()),
|
|
70
70
|
fullscreen: () => import("./FullscreenPlugin.native-ChXyxeNw.mjs").then((n) => n.FullscreenPlugin()),
|
|
71
|
-
template: () => import("./TemplatePlugin.native-
|
|
71
|
+
template: () => import("./TemplatePlugin.native-BDV2eik2.mjs").then((n) => n.TemplatePlugin()),
|
|
72
72
|
footnote: () => import("./FootnotePlugin.native-D730OGRm.mjs").then((n) => n.FootnotePlugin())
|
|
73
73
|
};
|
|
74
74
|
async function a(n) {
|