@editora/core 1.0.13 → 1.0.15
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/LICENSE +21 -0
- package/dist/{CodePlugin.native-veDC_kx5.mjs → CodePlugin.native-knhM8NNo.mjs} +895 -895
- package/dist/{DocumentManagerPlugin.native-C2cs_1w4.mjs → DocumentManagerPlugin.native-D1YHQ2NN.mjs} +4 -4
- package/dist/{documentManager-vQ1VkbUY.mjs → documentManager-BcBIv5P-.mjs} +3 -3
- package/dist/editora.min.js +2 -2
- package/dist/editora.umd.js +2 -2
- package/dist/{index-B5BzVUdg.js → index-BLm1MtzH.js} +3 -3
- package/dist/{index-BslAFzmv.mjs → index-CavM-mEM.mjs} +6391 -6203
- package/dist/{index-YZ5TROdg.mjs → index-Cd9jEuZP.mjs} +16 -16
- package/dist/index.cjs.js +1 -1
- package/dist/{index.es-BYD2KEo6.mjs → index.es-BK-4TPv8.mjs} +1562 -1546
- package/dist/index.esm.js +2 -2
- package/dist/{jspdf.es.min-BJGtOnRT.mjs → jspdf.es.min-BsnKYYHL.mjs} +4 -3
- package/dist/plugin-loader.js +1 -1
- package/dist/{purify.es-CKpwg8Tk.mjs → purify.es-DhWKBjsL.mjs} +3 -3
- package/dist/webcomponent-core.js +10 -10
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +40 -40
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +11 -11
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +877 -877
- package/package.json +2 -2
|
@@ -499,7 +499,7 @@ class z {
|
|
|
499
499
|
/**
|
|
500
500
|
* Execute a command
|
|
501
501
|
*/
|
|
502
|
-
execCommand(t, e) {
|
|
502
|
+
execCommand(t, ...e) {
|
|
503
503
|
if (this.isReadonly)
|
|
504
504
|
return console.warn("Cannot execute commands in readonly mode"), !1;
|
|
505
505
|
if (this.isDestroyed)
|
|
@@ -508,7 +508,7 @@ class z {
|
|
|
508
508
|
if (!o)
|
|
509
509
|
return console.warn(`Command not found: ${t}`), !1;
|
|
510
510
|
let n;
|
|
511
|
-
return e
|
|
511
|
+
return e.length === 0 ? n = o(this.state) : e.length === 1 ? n = o(this.state, e[0]) : n = o(this.state, ...e), n instanceof Promise ? (n.then((i) => {
|
|
512
512
|
i && typeof i == "object" && "doc" in i && "selection" in i && (this.setState(i), this.emit("change", this.state));
|
|
513
513
|
}).catch((i) => {
|
|
514
514
|
console.error(`Async command failed: ${t}`, i);
|
|
@@ -1526,9 +1526,9 @@ function et() {
|
|
|
1526
1526
|
function ot() {
|
|
1527
1527
|
if (typeof window == "undefined" || A) return;
|
|
1528
1528
|
k = typeof window.executeEditorCommand == "function" ? window.executeEditorCommand.bind(window) : null, w = typeof window.execEditorCommand == "function" ? window.execEditorCommand.bind(window) : null;
|
|
1529
|
-
const s = (t, e) => {
|
|
1529
|
+
const s = (t, ...e) => {
|
|
1530
1530
|
const o = et();
|
|
1531
|
-
return o ? o.execCommand(t, e) : k ? k(t, e) : w ? w(t, e) : !1;
|
|
1531
|
+
return o ? o.execCommand(t, ...e) : k ? k(t, ...e) : w ? w(t, ...e) : !1;
|
|
1532
1532
|
};
|
|
1533
1533
|
window.executeEditorCommand = s, window.execEditorCommand = s, A = !0;
|
|
1534
1534
|
}
|
|
@@ -1832,7 +1832,7 @@ class m extends HTMLElement {
|
|
|
1832
1832
|
const t = this.getSpellcheckConfig(), e = t.enabled && t.provider === "browser";
|
|
1833
1833
|
this.contentElement.spellcheck = e, this.contentElement.setAttribute("spellcheck", e ? "true" : "false");
|
|
1834
1834
|
}
|
|
1835
|
-
executeCommand(t, e) {
|
|
1835
|
+
executeCommand(t, ...e) {
|
|
1836
1836
|
var i;
|
|
1837
1837
|
typeof window != "undefined" && (window.__editoraCommandEditorRoot = this);
|
|
1838
1838
|
const o = {
|
|
@@ -1844,12 +1844,12 @@ class m extends HTMLElement {
|
|
|
1844
1844
|
const r = n.commands[t];
|
|
1845
1845
|
if (typeof r == "function")
|
|
1846
1846
|
try {
|
|
1847
|
-
return
|
|
1847
|
+
return t === "toggleFullscreen" ? r(this, o) : r(...e, o), !0;
|
|
1848
1848
|
} catch (a) {
|
|
1849
1849
|
return console.error(`[RichTextEditor] Error executing native command ${t}:`, a), !1;
|
|
1850
1850
|
}
|
|
1851
1851
|
}
|
|
1852
|
-
return ((i = this.engine) == null ? void 0 : i.execCommand(t, e)) || !1;
|
|
1852
|
+
return ((i = this.engine) == null ? void 0 : i.execCommand(t, ...e)) || !1;
|
|
1853
1853
|
}
|
|
1854
1854
|
getPluginLoadConfig(t) {
|
|
1855
1855
|
const e = this.config.pluginConfig;
|
|
@@ -2306,8 +2306,8 @@ class m extends HTMLElement {
|
|
|
2306
2306
|
setContent(t) {
|
|
2307
2307
|
this.contentElement && (this.contentElement.innerHTML = t);
|
|
2308
2308
|
}
|
|
2309
|
-
execCommand(t, e) {
|
|
2310
|
-
return this.executeCommand(t, e);
|
|
2309
|
+
execCommand(t, ...e) {
|
|
2310
|
+
return this.executeCommand(t, ...e);
|
|
2311
2311
|
}
|
|
2312
2312
|
focus() {
|
|
2313
2313
|
var t;
|
|
@@ -2328,14 +2328,14 @@ export {
|
|
|
2328
2328
|
P as S,
|
|
2329
2329
|
R as T,
|
|
2330
2330
|
z as a,
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2331
|
+
x as b,
|
|
2332
|
+
K as c,
|
|
2333
|
+
j as d,
|
|
2334
2334
|
W as e,
|
|
2335
|
-
|
|
2335
|
+
_ as f,
|
|
2336
2336
|
F as g,
|
|
2337
|
-
|
|
2338
|
-
|
|
2337
|
+
U as h,
|
|
2338
|
+
$ as i,
|
|
2339
2339
|
nt as j
|
|
2340
2340
|
};
|
|
2341
|
-
//# sourceMappingURL=index-
|
|
2341
|
+
//# sourceMappingURL=index-Cd9jEuZP.mjs.map
|
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-BLm1MtzH.js");class v{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 b{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 E(r){return new b(r)}function x(r={}){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 w(r={}){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:$}=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=`
|