@editora/core 1.0.18 → 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 +17 -17
- package/dist/index-CclXYzUB.js +12 -0
- package/dist/{index-XsYC_KdJ.mjs → index-DeUjxpKd.mjs} +406 -386
- package/dist/index.cjs.js +4 -4
- package/dist/index.esm.js +19 -16
- 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=`
|
|
@@ -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;
|
|
@@ -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 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
|
|
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,5 +1,5 @@
|
|
|
1
|
-
import { P as g, E, a as f, T as y, R as w } from "./index-
|
|
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,
|
|
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
3
|
class T {
|
|
4
4
|
constructor(e) {
|
|
5
5
|
if (this.listeners = [], e instanceof g)
|
|
@@ -142,7 +142,7 @@ class x {
|
|
|
142
142
|
return this.context;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
function
|
|
145
|
+
function M(l) {
|
|
146
146
|
return new x(l);
|
|
147
147
|
}
|
|
148
148
|
const b = /* @__PURE__ */ new Set();
|
|
@@ -151,7 +151,7 @@ function v(l, e) {
|
|
|
151
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
152
|
));
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function I(l = {}) {
|
|
155
155
|
v("SpellcheckPlugin", "`SpellCheckPlugin` from @editora/spell-check");
|
|
156
156
|
const {
|
|
157
157
|
enabled: e = !1,
|
|
@@ -876,7 +876,7 @@ class H {
|
|
|
876
876
|
}
|
|
877
877
|
}
|
|
878
878
|
}
|
|
879
|
-
class
|
|
879
|
+
class A {
|
|
880
880
|
constructor(e) {
|
|
881
881
|
this.onSubmit = e.onSubmit;
|
|
882
882
|
const t = this.createContent();
|
|
@@ -1046,7 +1046,7 @@ class z {
|
|
|
1046
1046
|
this.dialog.close();
|
|
1047
1047
|
}
|
|
1048
1048
|
}
|
|
1049
|
-
class
|
|
1049
|
+
class z {
|
|
1050
1050
|
constructor(e) {
|
|
1051
1051
|
this.characters = {
|
|
1052
1052
|
common: ["©", "®", "™", "§", "¶", "†", "‡", "•", "‣", "⁃", "◦", "▪", "▫", "◊", "○", "●", "□", "■", "△", "▲", "▽", "▼", "◇", "◆", "★", "☆"],
|
|
@@ -1543,7 +1543,7 @@ function N() {
|
|
|
1543
1543
|
typeof window != "undefined" && !customElements.get("editora-editor") && customElements.define("editora-editor", w);
|
|
1544
1544
|
}
|
|
1545
1545
|
export {
|
|
1546
|
-
|
|
1546
|
+
z as CharacterDialog,
|
|
1547
1547
|
j as ColorPicker,
|
|
1548
1548
|
V as CommandRegistry,
|
|
1549
1549
|
K as ConfigResolver,
|
|
@@ -1558,7 +1558,7 @@ export {
|
|
|
1558
1558
|
H as ImageDialog,
|
|
1559
1559
|
W as KeyboardShortcutManager,
|
|
1560
1560
|
P as LinkDialog,
|
|
1561
|
-
|
|
1561
|
+
A as MathDialog,
|
|
1562
1562
|
F as MediaPlugin,
|
|
1563
1563
|
X as PluginLoader,
|
|
1564
1564
|
g as PluginManager,
|
|
@@ -1566,7 +1566,7 @@ export {
|
|
|
1566
1566
|
S as ReactAdapter,
|
|
1567
1567
|
w as RichTextEditorElement,
|
|
1568
1568
|
_ as Schema,
|
|
1569
|
-
|
|
1569
|
+
I as SpellcheckPlugin,
|
|
1570
1570
|
Y as StatusBar,
|
|
1571
1571
|
$ as TableDialog,
|
|
1572
1572
|
y as ToolbarRenderer,
|
|
@@ -1574,14 +1574,17 @@ export {
|
|
|
1574
1574
|
J as calculateTextStats,
|
|
1575
1575
|
Q as countLines,
|
|
1576
1576
|
R as createEditor,
|
|
1577
|
-
|
|
1577
|
+
Z as createPluginManager,
|
|
1578
|
+
M as createPluginRuntime,
|
|
1578
1579
|
U as createReactAdapter,
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1580
|
+
ee as getCleanEditorHTML,
|
|
1581
|
+
te as getCursorPosition,
|
|
1582
|
+
ie as getSelectionInfo,
|
|
1583
|
+
ne as getTextOffset,
|
|
1582
1584
|
N as initWebComponent,
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1585
|
+
oe as sanitizeHTML,
|
|
1586
|
+
se as sanitizeInputHTML,
|
|
1587
|
+
ae as sanitizePastedHTML,
|
|
1588
|
+
le as stripEditorUiArtifacts
|
|
1586
1589
|
};
|
|
1587
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) {
|