mokelay-editor 0.0.3 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/assets/ApiBuilderShell-Bm4OYwge.js +1 -0
  2. package/assets/ApiBuilderShell-DGgsHv3d.css +1 -0
  3. package/assets/EditorPanel-CF3kVQ21.css +1 -0
  4. package/assets/EditorPanel-DU-O-EE-.js +1 -0
  5. package/assets/MPage-ChS8xsfM.js +1 -0
  6. package/assets/MPage.vue_vue_type_script_setup_true_lang-D2OXItLi.js +1 -0
  7. package/assets/PreviewPanel-Dt5b3mBI.js +1 -0
  8. package/assets/block-advanced-CdUL2rGG.js +1 -0
  9. package/assets/block-advanced-DfEsE7Tf.css +1 -0
  10. package/assets/block-chart-BDhOWgsD.css +1 -0
  11. package/assets/block-chart-C_HzJKhS.js +1 -0
  12. package/assets/block-datasource-B8nJNjoV.js +1 -0
  13. package/assets/block-datasource-DIH8wAmJ.css +1 -0
  14. package/assets/block-editor-selector-DWvvND_N.js +72 -0
  15. package/assets/block-editor-selector-Da_ew6E9.css +1 -0
  16. package/assets/block-form-0t-EPu3N.css +1 -0
  17. package/assets/block-form-C_cJnRtX.js +51 -0
  18. package/assets/echarts-BN_iJMI5.js +24 -0
  19. package/assets/{editorjs-hCuh8vdW.js → editorjs-CrGo22NX.js} +10 -10
  20. package/assets/element-plus-Bo3B6ZwD.js +1 -0
  21. package/assets/element-plus-Dit-l95b.css +1 -0
  22. package/assets/index-BJ_rhCtu.js +10 -0
  23. package/assets/index-D7DgezOc.css +1 -0
  24. package/assets/vue-vendor-CGusfGYN.js +17 -0
  25. package/assets/zrender-CyMoNtco.js +29 -0
  26. package/index.html +19 -6
  27. package/package.json +1 -1
  28. package/assets/EditorPanel-C1sfyxYP.js +0 -1
  29. package/assets/EditorPanel-vQbiWj6F.css +0 -1
  30. package/assets/MForm-DHyGtILs.css +0 -1
  31. package/assets/MForm-IOgKE4fR.js +0 -50
  32. package/assets/MPage-DdQoXp86.css +0 -1
  33. package/assets/MPage-okwcd_fI.js +0 -1
  34. package/assets/MPage.vue_vue_type_script_setup_true_lang-BfUuzlf-.js +0 -51
  35. package/assets/PreviewPanel-BB0_i9aa.js +0 -1
  36. package/assets/index-CH5-XypS.css +0 -1
  37. package/assets/index-DKqdRiPk.js +0 -26
@@ -0,0 +1,72 @@
1
+ var te=Object.defineProperty;var oe=(u,s,d)=>s in u?te(u,s,{enumerable:!0,configurable:!0,writable:!0,value:d}):u[s]=d;var w=(u,s,d)=>oe(u,typeof s!="symbol"?s+"":s,d);import{A as re}from"./editorjs-CrGo22NX.js";import{i as E,u as ae,k as le,_ as se}from"./block-advanced-CdUL2rGG.js";import{J as ne,f as ie,r as $,z as ce,F as S,A as L,B as pe,o as T,j as V,n as z,l as ue,x as de,t as ye,e as he}from"./vue-vendor-CGusfGYN.js";import{g as me,a as Z,n as A,c as H,_ as ve,m as fe}from"./block-form-C_cJnRtX.js";const K=new Map;class ge{static create(s){const d=K.get(s);if(d)return d;const r=Z(s);if(!r)throw new Error(`EditorToolFactory could not find a registered component for "${s}".`);class h{constructor({data:e,config:o}){w(this,"state");w(this,"wrapper",null);w(this,"contentRoot",null);w(this,"vueApp",null);w(this,"propertyDialog",null);const n={...o??{},...e??{}};if(typeof n.edit!="boolean")throw new Error(`EditorToolFactory requires config.edit to be explicitly set for "${s}".`);this.state=r.normalizeProps({...n})}static get toolbox(){return r.toolbox}render(){const e=document.createElement("div");e.className="mokelay-editor-tool",e.dataset.toolName=s,e.dataset.testid=`editor-tool-${s}`;const o=document.createElement("div");return o.className="mokelay-editor-tool__content",o.dataset.testid=`editor-tool-content-${s}`,e.appendChild(o),this.wrapper=e,this.contentRoot=o,this.createPropertyDialog(),this.mountVueApp(),e}destroy(){var e;this.unmountVueApp(),(e=this.propertyDialog)==null||e.remove(),this.propertyDialog=null,this.contentRoot=null,this.wrapper=null}save(){return r.serialize(this.state)}renderSettings(){var e;return(e=r.propertyPanel)!=null&&e.fields.length?{icon:'<svg width="17" height="17" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19.14 12.94C19.18 12.63 19.2 12.32 19.2 12C19.2 11.68 19.18 11.36 19.13 11.06L21.11 9.51C21.29 9.37 21.34 9.11 21.23 8.9L19.35 5.64C19.24 5.43 18.99 5.35 18.77 5.42L16.44 6.17C15.96 5.8 15.44 5.48 14.87 5.23L14.51 2.75C14.48 2.52 14.28 2.35 14.04 2.35H10.28C10.04 2.35 9.84 2.52 9.81 2.75L9.45 5.23C8.88 5.48 8.36 5.81 7.88 6.17L5.55 5.42C5.33 5.35 5.08 5.43 4.97 5.64L3.09 8.9C2.98 9.11 3.03 9.37 3.21 9.51L5.19 11.06C5.14 11.36 5.12 11.68 5.12 12C5.12 12.32 5.14 12.64 5.19 12.94L3.21 14.49C3.03 14.63 2.98 14.89 3.09 15.1L4.97 18.36C5.08 18.57 5.33 18.65 5.55 18.58L7.88 17.83C8.36 18.2 8.88 18.52 9.45 18.77L9.81 21.25C9.84 21.48 10.04 21.65 10.28 21.65H14.04C14.28 21.65 14.48 21.48 14.51 21.25L14.87 18.77C15.44 18.52 15.96 18.19 16.44 17.83L18.77 18.58C18.99 18.65 19.24 18.57 19.35 18.36L21.23 15.1C21.34 14.89 21.29 14.63 21.11 14.49L19.14 12.94ZM12.16 15.6C10.17 15.6 8.56 13.99 8.56 12C8.56 10.01 10.17 8.4 12.16 8.4C14.15 8.4 15.76 10.01 15.76 12C15.76 13.99 14.15 15.6 12.16 15.6Z" fill="currentColor"/></svg>',title:E.t("editor.properties"),onActivate:()=>{this.openPropertyDialog()},closeOnActivate:!0}:[]}mountVueApp(){this.contentRoot&&(this.unmountVueApp(),this.vueApp=ne(r.component,{...this.state,onToolChange:e=>{Object.assign(this.state,e)},onChange:e=>{Object.assign(this.state,e)}}),this.vueApp.mount(this.contentRoot))}unmountVueApp(){var e;(e=this.vueApp)==null||e.unmount(),this.vueApp=null}createPropertyDialog(){var a;if(!this.wrapper||!((a=r.propertyPanel)!=null&&a.fields.length))return;const e=document.createElement("dialog");e.className="mokelay-editor-tool__property-dialog",e.dataset.testid="tool-property-dialog",e.dataset.toolName=s;const o=r.propertyPanel.title||E.t("editor.propertyDialogTitle"),n=r.propertyPanel.fields.map(i=>this.renderPropertyField(i)).join("");e.innerHTML=`
2
+ <form method="dialog" class="mokelay-editor-tool__property-panel" data-testid="tool-property-panel">
3
+ <div class="mokelay-editor-tool__property-header">
4
+ <h3 class="mokelay-editor-tool__property-title" data-testid="tool-property-title">${this.escapeHtml(o)}</h3>
5
+ <button type="submit" class="mokelay-editor-tool__property-close" data-testid="tool-property-close">${this.escapeHtml(E.t("editor.close"))}</button>
6
+ </div>
7
+ <div class="mokelay-editor-tool__property-body" data-testid="tool-property-body">
8
+ ${n}
9
+ </div>
10
+ </form>
11
+ `,this.wrapper.appendChild(e),this.propertyDialog=e,this.bindPropertyInputs()}openPropertyDialog(){this.propertyDialog&&(this.syncPropertyDialogValues(),this.propertyDialog.open||this.propertyDialog.showModal())}syncPropertyDialogValues(){this.propertyDialog&&this.propertyDialog.querySelectorAll("[data-property-key]").forEach(e=>{const o=e.dataset.propertyKey;if(!o)return;const n=this.getPropertyFieldValue(o);if(this.setPropertyInputValidity(e,""),e instanceof HTMLInputElement&&e.type==="checkbox"){e.checked=n===!0;return}e.value=this.stringifyPropertyInputValue(n,e.dataset.propertyValueType)})}updateProperty(e,o){this.state[e]=o,this.mountVueApp()}getPropertyFieldValue(e){return this.state[e]}escapeHtml(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}renderPropertyField(e){if(e.type==="checkbox")return`
12
+ <label class="mokelay-editor-tool__property-field mokelay-editor-tool__property-field--checkbox">
13
+ <input
14
+ class="mokelay-editor-tool__property-checkbox"
15
+ data-testid="tool-property-input-${e.key}"
16
+ data-property-key="${e.key}"
17
+ data-property-type="checkbox"
18
+ type="checkbox"
19
+ ${this.getPropertyFieldValue(e.key)===!0?"checked":""}
20
+ />
21
+ <span class="mokelay-editor-tool__property-label">${this.escapeHtml(e.label)}</span>
22
+ </label>
23
+ `;if(e.type==="select"){const a=this.getPropertyFieldValue(e.key),i=(e.options??[]).map(p=>`
24
+ <option value="${this.escapeHtml(p.value)}" ${a===p.value?"selected":""}>${this.escapeHtml(p.label)}</option>
25
+ `).join("");return`
26
+ <label class="mokelay-editor-tool__property-field">
27
+ <span class="mokelay-editor-tool__property-label">${this.escapeHtml(e.label)}</span>
28
+ <select
29
+ class="mokelay-editor-tool__property-input"
30
+ data-testid="tool-property-input-${e.key}"
31
+ data-property-key="${e.key}"
32
+ data-property-type="select"
33
+ >
34
+ ${i}
35
+ </select>
36
+ </label>
37
+ `}if(e.type==="textarea"){const a=this.getPropertyFieldValue(e.key),i=e.valueType??"string",p=e.validationMessage??E.t("editor.invalidJson"),f=i==="json"?6:4,g=this.stringifyPropertyInputValue(a,i);return`
38
+ <label class="mokelay-editor-tool__property-field">
39
+ <span class="mokelay-editor-tool__property-label">${this.escapeHtml(e.label)}</span>
40
+ <textarea
41
+ class="mokelay-editor-tool__property-input mokelay-editor-tool__property-textarea"
42
+ data-testid="tool-property-input-${e.key}"
43
+ data-property-key="${e.key}"
44
+ data-property-type="textarea"
45
+ data-property-value-type="${this.escapeHtml(i)}"
46
+ data-property-validation-message="${this.escapeHtml(p)}"
47
+ rows="${f}"
48
+ placeholder="${this.escapeHtml(e.placeholder??"")}"
49
+ >${this.escapeHtml(g)}</textarea>
50
+ <span
51
+ class="mokelay-editor-tool__property-error"
52
+ data-testid="tool-property-error-${e.key}"
53
+ data-property-error-for="${e.key}"
54
+ hidden
55
+ ></span>
56
+ </label>
57
+ `}const o=this.getPropertyFieldValue(e.key),n=e.valueType??"string";return`
58
+ <label class="mokelay-editor-tool__property-field">
59
+ <span class="mokelay-editor-tool__property-label">${this.escapeHtml(e.label)}</span>
60
+ <input
61
+ class="mokelay-editor-tool__property-input"
62
+ data-testid="tool-property-input-${e.key}"
63
+ data-property-key="${e.key}"
64
+ data-property-type="text"
65
+ data-property-value-type="${this.escapeHtml(n)}"
66
+ data-property-validation-message="${this.escapeHtml(e.validationMessage??E.t("editor.invalidJson"))}"
67
+ type="text"
68
+ value="${this.escapeHtml(this.stringifyPropertyInputValue(o,n))}"
69
+ placeholder="${this.escapeHtml(e.placeholder??"")}"
70
+ />
71
+ </label>
72
+ `}bindPropertyInputs(){this.propertyDialog&&this.propertyDialog.querySelectorAll("[data-property-key]").forEach(e=>{const o=e instanceof HTMLSelectElement||e instanceof HTMLInputElement&&e.type==="checkbox"?"change":"input";e.addEventListener(o,()=>{const n=e.dataset.propertyKey;if(!n)return;const a=this.readPropertyInputValue(e);if(!a.valid){this.setPropertyInputValidity(e,a.message);return}this.setPropertyInputValidity(e,""),this.updateProperty(n,a.value)})})}readPropertyInputValue(e){if(e instanceof HTMLInputElement&&e.type==="checkbox")return{valid:!0,value:e.checked};if(e.dataset.propertyValueType==="json")try{return{valid:!0,value:JSON.parse(e.value)}}catch{return{valid:!1,message:e.dataset.propertyValidationMessage||E.t("editor.invalidJson")}}return{valid:!0,value:e.value}}stringifyPropertyInputValue(e,o){if(o==="json")try{return JSON.stringify(e,null,2)??""}catch{return""}return typeof e=="string"?e:""}setPropertyInputValidity(e,o){var i;o?e.setAttribute("aria-invalid","true"):e.removeAttribute("aria-invalid"),e.dataset.invalid=o?"true":"false",e.title=o;const n=e.dataset.propertyKey,a=n?(i=this.propertyDialog)==null?void 0:i.querySelector(`[data-property-error-for="${n}"]`):null;a&&(a.textContent=o,a.hidden=!o)}}const m=h;return K.set(s,m),m}}function ke(u={},s={}){const d=new Set(s.exclude??[]);return Object.fromEntries(Object.entries(me()).filter(([r])=>!d.has(r)).map(([r,h])=>{var m;return[r,{class:ge.create(r),config:h.normalizeProps({...((m=h.createInitialProps)==null?void 0:m.call(h))??{},...u})}]}))}const _e={key:1,class:"ce-editor-selector-tool__preview","data-testid":"preview-editor-selector-value"},be=ie({__name:"MEditorSelector",props:{edit:{type:Boolean,default:!1},value:{default:void 0},excludeToolNames:{},onChange:{},onToolChange:{}},setup(u){const s="MEditorSelector",d=new Set(["paragraph","table","columns"]),r=u,{t:h,localeValue:m}=ae(),C=$(null),e=$(null),o=$(A(r.value)),n=he(()=>o.value!==void 0);let a=null,i=!1,p=null,f=null,g=null,v=k(o.value);function k(t){return{blocks:t?[H(t)]:[]}}function b(t){return t?JSON.stringify(t):""}function M(){const t=new Set([s]);return(r.excludeToolNames??[]).forEach(l=>{t.add(l)}),t}function D(t){return!M().has(t)&&!d.has(t)&&!!Z(t)}function B(t){if(D(t.type))return A(t)}function I(t){const c=(Array.isArray(t.blocks)?t.blocks:[]).map(y=>B(y)).filter(y=>y!==void 0);return c[c.length-1]}function U(t,l){const c=Array.isArray(t.blocks)?t.blocks:[];return l?c.length!==1?!0:b(B(c[0]))!==b(l):c.some(y=>D(y.type))}function Y(t){var c,y;const l={edit:r.edit,value:t?H(t):void 0};(c=r.onToolChange)==null||c.call(r,l),(y=r.onChange)==null||y.call(r,l)}async function O(t){const l=a;if(l){i=!0,v=k(t);try{await l.blocks.render(v)}finally{await L(),i=!1}}}async function R(t){if(i)return;const l=I(t),c=b(o.value),y=b(l);o.value=l?H(l):void 0,v=k(o.value),c!==y&&Y(o.value),U(t,o.value)&&await O(o.value)}function F(){f!==null&&(window.clearTimeout(f),f=null)}function _(){!a||i||(F(),f=window.setTimeout(async()=>{if(f=null,!(!a||i))try{const t=await a.save();await R(t)}catch{}},0))}function G(){const t=e.value;t&&(j(),p=new MutationObserver(()=>{_()}),p.observe(t,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),t.addEventListener("input",_),t.addEventListener("change",_),t.addEventListener("click",_))}function j(){const t=e.value;p==null||p.disconnect(),p=null,F(),t==null||t.removeEventListener("input",_),t==null||t.removeEventListener("change",_),t==null||t.removeEventListener("click",_)}function Q(t){return t.querySelector(".codex-editor > .ce-toolbar")}function W(t){return t.closest('[data-testid="editor-form-tool"]')??t.closest('[data-testid="editor-panel"]')??document}function X(){const t=C.value;t&&W(t).querySelectorAll(".ce-editor-selector-tool").forEach(l=>{if(l===t)return;const c=Q(l);c==null||c.classList.remove("ce-toolbar--opened")})}function ee(){C.value&&X()}function N(){g!==null&&(window.clearTimeout(g),g=null)}function J(){N(),g=window.setTimeout(()=>{g=null,ee()},0)}async function x(){if(!r.edit||!e.value||a)return;v=k(o.value);const t=ke({edit:!0},{exclude:M()});a=new re({holder:e.value,placeholder:h("editorSelector.placeholder"),tools:t,data:v,minHeight:0,i18n:{messages:le(m.value)},onChange:async()=>{if(!a)return;const l=await a.save();await R(l)}}),G()}async function P(){const t=a;if(t){a=null,j();try{const l=await t.save();o.value=I(l),v=k(o.value)}catch{v=k(o.value)}t.destroy()}}async function q(){await P(),await L(),await x()}return ce(async()=>{await x()}),S(()=>r.value,async t=>{const l=A(t);b(l)!==b(o.value)&&(o.value=l,v=k(l),a&&await O(l))},{deep:!0}),S(()=>r.edit,async t=>{if(t){await L(),await x();return}await P()}),S(m,async()=>{a&&await q()}),S(()=>r.excludeToolNames,async()=>{a&&await q()},{deep:!0}),pe(async()=>{N(),await P()}),(t,l)=>(T(),V("div",{ref_key:"rootRef",ref:C,class:z(["ce-editor-selector-tool",{"ce-editor-selector-tool--filled":n.value}]),"data-testid":"editor-selector-tool",onMouseenter:J,onMousemove:J},[u.edit?(T(),V("div",{key:0,class:z(["ce-editor-selector-tool__editor-shell",{"ce-editor-selector-tool__editor-shell--filled":n.value}]),"data-testid":"editor-selector-shell"},[ue("div",{ref_key:"holderRef",ref:e,class:"ce-editor-selector-tool__editor","data-testid":"editor-selector-surface"},null,512)],2)):(T(),V("div",_e,[o.value?(T(),de(ve,{key:0,block:o.value},null,8,["block"])):ye("",!0)]))],34))}}),we=se(be,[["__scopeId","data-v-865609b6"]]),Pe=Object.freeze(Object.defineProperty({__proto__:null,default:we,mEditorSelectorEditorTool:fe},Symbol.toStringTag,{value:"Module"}));export{Pe as M,ke as c};
@@ -0,0 +1 @@
1
+ .ce-editor-selector-tool[data-v-865609b6]{position:relative;width:100%}.ce-editor-selector-tool__editor-shell[data-v-865609b6],.ce-editor-selector-tool__preview[data-v-865609b6]{position:relative;width:100%;min-height:38px;border:1px solid rgb(148 163 184 / .6);border-radius:8px;background:#fff}.ce-editor-selector-tool__editor-shell[data-v-865609b6]{height:38px;padding:0 10px 0 38px;overflow:visible}.ce-editor-selector-tool__editor-shell--filled[data-v-865609b6]{height:auto;padding-top:4px;padding-bottom:4px}.ce-editor-selector-tool__editor[data-v-865609b6],.ce-editor-selector-tool__preview[data-v-865609b6]{min-height:0}.ce-editor-selector-tool__preview[data-v-865609b6]{display:flex;align-items:center;padding:7px 10px}.ce-editor-selector-tool__preview[data-v-865609b6]:empty{padding:0 10px}.ce-editor-selector-tool[data-v-865609b6] .codex-editor{min-height:0}.ce-editor-selector-tool[data-v-865609b6] .codex-editor__redactor{min-height:0;padding-bottom:0!important}.ce-editor-selector-tool[data-v-865609b6] .ce-block{padding:0}.ce-editor-selector-tool[data-v-865609b6] .ce-block__content,.ce-editor-selector-tool[data-v-865609b6] .ce-toolbar__content{max-width:none;margin:0}.ce-editor-selector-tool[data-v-865609b6] .ce-toolbar__actions{right:calc(100% + 8px);padding-right:0}.ce-editor-selector-tool[data-v-865609b6] .ce-paragraph{min-height:36px;padding:8px 0;line-height:20px;font-size:14px}.ce-editor-selector-tool[data-v-865609b6]:not(.ce-editor-selector-tool--filled) .ce-block,.ce-editor-selector-tool[data-v-865609b6]:not(.ce-editor-selector-tool--filled) .ce-block__content,.ce-editor-selector-tool[data-v-865609b6]:not(.ce-editor-selector-tool--filled) .ce-paragraph{min-height:0;height:36px}.ce-editor-selector-tool[data-v-865609b6]:not(.ce-editor-selector-tool--filled) .ce-paragraph{padding:8px 0}.ce-editor-selector-tool[data-v-865609b6] .ce-popover-item[data-item-name=paragraph],.ce-editor-selector-tool[data-v-865609b6] .ce-popover-item[data-item-name=table],.ce-editor-selector-tool[data-v-865609b6] .ce-popover-item[data-item-name=columns],.ce-editor-selector-tool[data-v-865609b6] .ce-popover-item[data-item-name=MEditorSelector]{display:none}.dark{border-color:#475569e6;background:#0f172a}
@@ -0,0 +1 @@
1
+ .ce-divider-line-tool[data-v-65668242]{display:flex;align-items:center;width:100%;min-height:32px;padding:8px 0}.ce-divider-line-tool__line[data-v-65668242]{display:block;width:100%;height:1px;background-color:#cbd5e1}.dark{background-color:#475569}.ce-form-item-tool[data-v-c59f1044]{width:100%;color:#0f172a}.ce-form-item-tool__edit-shell[data-v-c59f1044]{width:100%;border:1px dashed rgb(148 163 184 / .7);border-radius:8px;padding:8px}.ce-form-item-tool__label[data-v-c59f1044]{color:#334155;font-size:13px;font-weight:600;line-height:20px}.ce-form-item-tool__body[data-v-c59f1044]{display:flex;flex-direction:column;gap:8px}.ce-form-item-tool--horizontal .ce-form-item-tool__body[data-v-c59f1044]{display:grid;grid-template-columns:minmax(96px,max-content) minmax(0,1fr);align-items:start;gap:12px}.ce-form-item-tool__label[data-v-c59f1044]{padding-top:9px;word-break:break-word}.ce-form-item-tool__editor[data-v-c59f1044]{min-width:0}.ce-form-item-tool__empty[data-v-c59f1044]{display:inline-flex;min-height:38px;align-items:center;color:#64748b;font-size:14px;line-height:20px}@media(max-width:640px){.ce-form-item-tool--horizontal .ce-form-item-tool__body[data-v-c59f1044]{display:flex;flex-direction:column}}.dark{border-color:#475569e6}.dark{color:#cbd5e1}.ce-form-tool[data-v-a3894c78]{width:100%;color:#0f172a}.ce-form-tool__editor-shell[data-v-a3894c78]{width:100%;min-height:54px;border:1px dashed rgb(148 163 184 / .72);border-radius:8px;background:#f8fafc;padding:8px 10px 8px 38px}.ce-form-tool__editor[data-v-a3894c78],.ce-form-tool__preview[data-v-a3894c78]{width:100%}.ce-form-tool__preview[data-v-a3894c78]{display:flex;flex-direction:column;gap:12px}.ce-form-tool[data-v-a3894c78] .codex-editor{min-height:0}.ce-form-tool[data-v-a3894c78] .codex-editor__redactor{min-height:0;padding-bottom:0!important}.ce-form-tool[data-v-a3894c78] .ce-block{padding:0}.ce-form-tool[data-v-a3894c78] .ce-block+.ce-block{margin-top:10px}.ce-form-tool[data-v-a3894c78] .ce-block__content,.ce-form-tool[data-v-a3894c78] .ce-toolbar__content{max-width:none;margin:0}.ce-form-tool[data-v-a3894c78] .ce-toolbar__actions{right:calc(100% + 8px);padding-right:0}.ce-form-tool[data-v-a3894c78] .ce-popover-item[data-item-name=paragraph]{display:none}.ce-form-tool[data-v-a3894c78] .ce-paragraph{min-height:36px;padding:8px 0;color:#64748b;font-size:14px;line-height:20px}.dark{color:#e2e8f0}.dark{border-color:#475569e6;background:#0f172a}.dark{color:#94a3b8}
@@ -0,0 +1,51 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./block-editor-selector-DWvvND_N.js","./editorjs-CrGo22NX.js","./block-advanced-CdUL2rGG.js","./vue-vendor-CGusfGYN.js","./element-plus-Bo3B6ZwD.js","./element-plus-Dit-l95b.css","./block-advanced-DfEsE7Tf.css","./block-editor-selector-Da_ew6E9.css","./MPage-ChS8xsfM.js","./MPage.vue_vue_type_script_setup_true_lang-D2OXItLi.js","./block-chart-C_HzJKhS.js","./echarts-BN_iJMI5.js","./zrender-CyMoNtco.js","./block-chart-BDhOWgsD.css","./block-datasource-B8nJNjoV.js","./block-datasource-DIH8wAmJ.css"])))=>i.map(i=>d[i]);
2
+ var We=Object.defineProperty;var Qe=(e,r,d)=>r in e?We(e,r,{enumerable:!0,configurable:!0,writable:!0,value:d}):e[r]=d;var L=(e,r,d)=>Qe(e,typeof r!="symbol"?r+"":r,d);import{f as Q,o as p,j as g,l as N,G as ae,H as ne,x as K,I as ge,n as Z,M as Xe,m as Ye,C as j,e as ie,L as Ne,F as U,q as et,u as le,N as q,E as T,z as tt,A as ve,B as ot,r as rt,J as at,O as nt}from"./vue-vendor-CGusfGYN.js";import{A as it}from"./editorjs-CrGo22NX.js";import{d as O,i as f,_ as de,u as Me,m as lt,a as st,b as ct,c as dt,e as ut,M as ke,f as _e,g as we,h as Te,j as Ee,k as mt}from"./block-advanced-CdUL2rGG.js";import{m as pt,M as Ce}from"./block-chart-C_HzJKhS.js";import{m as yt,M as Ie}from"./block-datasource-B8nJNjoV.js";const ft="modulepreload",ht=function(e,r){return new URL(e,r).href},xe={},J=function(r,d,M){let C=Promise.resolve();if(d&&d.length>0){let _=function(n){return Promise.all(n.map(s=>Promise.resolve(s).then(k=>({status:"fulfilled",value:k}),k=>({status:"rejected",reason:k}))))};const h=document.getElementsByTagName("link"),v=document.querySelector("meta[property=csp-nonce]"),a=(v==null?void 0:v.nonce)||(v==null?void 0:v.getAttribute("nonce"));C=_(d.map(n=>{if(n=ht(n,M),n in xe)return;xe[n]=!0;const s=n.endsWith(".css"),k=s?'[rel="stylesheet"]':"";if(!!M)for(let E=h.length-1;E>=0;E--){const b=h[E];if(b.href===n&&(!s||b.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${n}"]${k}`))return;const y=document.createElement("link");if(y.rel=s?"stylesheet":ft,s||(y.as="script"),y.crossOrigin="",y.href=n,a&&y.setAttribute("nonce",a),document.head.appendChild(y),s)return new Promise((E,b)=>{y.addEventListener("load",E),y.addEventListener("error",()=>b(new Error(`Unable to preload CSS for ${n}`)))})}))}function l(_){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=_,window.dispatchEvent(h),!h.defaultPrevented)throw _}return C.then(_=>{for(const h of _||[])h.status==="rejected"&&l(h.reason);return r().catch(l)})},bt={class:"ce-divider-line-tool","data-testid":"editor-divider-line-tool",role:"separator","aria-orientation":"horizontal"},gt=O({toolbox:{get title(){return f.t("dividerLine.toolboxTitle")},icon:'<svg width="18" height="18" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M4 12h16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>'},createInitialProps:()=>({}),normalizeProps:e=>({edit:e.edit??!1}),serialize:()=>({})}),vt=Q({__name:"MDividerLine",props:{edit:{type:Boolean},onChange:{type:Function},onToolChange:{type:Function}},setup(e){return(r,d)=>(p(),g("div",bt,[...d[0]||(d[0]=[N("span",{class:"ce-divider-line-tool__line"},null,-1)])]))}}),Pe=de(vt,[["__scopeId","data-v-65668242"]]);function kt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID().slice(0,10):Math.random().toString(36).slice(2,12)}function _t(e){return JSON.parse(JSON.stringify(e))}function Ae(e){return typeof e!="object"||e===null||Array.isArray(e)?{}:_t(e)}function V(e){if(typeof e!="object"||e===null||Array.isArray(e))return;const r=e;if(!(typeof r.type!="string"||typeof r.data!="object"||r.data===null||Array.isArray(r.data)))return{id:typeof r.id=="string"&&r.id?r.id:kt(),type:r.type,data:Ae(r.data)}}function X(e){return{id:e.id,type:e.type,data:Ae(e.data)}}const wt=O({toolbox:{get title(){return f.t("editorSelector.toolboxTitle")},icon:'<svg width="18" height="18" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect x="4" y="5" width="16" height="14" rx="2" fill="none" stroke="currentColor" stroke-width="2"/><path d="M8 9h8M8 13h5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><path d="M16 15l2 2 3-4" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'},createInitialProps:()=>({value:void 0}),normalizeProps:e=>({edit:e.edit??!1,value:V(e.value),excludeToolNames:Array.isArray(e.excludeToolNames)?e.excludeToolNames.filter(r=>typeof r=="string"):[]}),serialize:e=>{const r=V(e.value);return r?{value:r}:{}}}),Tt=["innerHTML"],Et={key:1,class:"overflow-auto"},Ct={key:3,class:"overflow-auto rounded bg-slate-100 p-2 text-xs dark:bg-slate-800"},It=Q({__name:"EditorPreviewBlock",props:{block:{},compactTable:{type:Boolean,default:!1}},setup(e){const r=e,d=ie(()=>r.compactTable?"min-w-full border-collapse text-xs":"min-w-full border-collapse text-sm"),M=ie(()=>r.compactTable?"border border-slate-200 px-2 py-1 text-left align-top dark:border-slate-700":"border border-slate-200 px-3 py-2 text-left align-top dark:border-slate-700");function C(a){const n=a.data.content;return Array.isArray(n)?n.filter(s=>Array.isArray(s)):[]}function l(a,n){const s=a.data.withHeadings;return n===0&&s===!0}function _(a){return Ot(a)}function h(a){const n=R(a);return(n==null?void 0:n.component)??null}function v(a){var s;const n=R(a.type);return n?{...n.normalizeProps({...((s=n.createInitialProps)==null?void 0:s.call(n))??{},...a.data,edit:!1})}:{edit:!1,...a.data}}return(a,n)=>e.block.type==="paragraph"?(p(),g("p",{key:0,class:"text-sm leading-6",innerHTML:e.block.data.text},null,8,Tt)):e.block.type==="table"?(p(),g("div",Et,[N("table",{class:Z(d.value)},[N("tbody",null,[(p(!0),g(ae,null,ne(C(e.block),(s,k)=>(p(),g("tr",{key:`table-${k}`,class:"border-b border-slate-200 dark:border-slate-700"},[(p(!0),g(ae,null,ne(s,(D,y)=>(p(),K(ge(l(e.block,k)?"th":"td"),{key:`table-${k}-${y}`,class:Z(M.value),innerHTML:D},null,8,["class","innerHTML"]))),128))]))),128))])],2)])):_(e.block.type)?(p(),K(ge(h(e.block.type)),Xe(Ye({key:2},v(e.block))),null,16)):(p(),g("pre",Ct,j(e.block),1))}}),xt={key:0,class:"ce-form-item-tool__edit-shell","data-testid":"form-item-edit-shell"},Pt={class:"ce-form-item-tool__body"},Nt={class:"ce-form-item-tool__label","data-testid":"form-item-label-preview"},Mt={class:"ce-form-item-tool__editor","data-testid":"form-item-editor-field"},At={key:1,class:"ce-form-item-tool__body"},Lt={class:"ce-form-item-tool__label","data-testid":"preview-form-item-label"},Ft={class:"ce-form-item-tool__editor","data-testid":"preview-form-item-editor"},$t={key:1,class:"ce-form-item-tool__empty"};function Le(){return`field_${typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID().slice(0,8):Math.random().toString(36).slice(2,10)}`}function Fe(){return f.t("formItem.defaultLabelName")}function se(e){return e==="Horizontal"?"Horizontal":"Vertical"}function Dt(e){return typeof e=="string"&&e.trim()?e:Fe()}function St(e,r){return typeof e=="string"&&e.trim()?e.trim():r||Le()}function Bt(e){return e?X(e):void 0}function F(e,r){return{edit:e.edit??!1,labelName:Dt(e.labelName),variableName:St(e.variableName,r),editor:V(e.editor),layout:se(e.layout)}}function $e(e){const r=F(e);return{labelName:r.labelName,variableName:r.variableName,...r.editor?{editor:X(r.editor)}:{},layout:r.layout}}const ce=O({toolbox:{get title(){return f.t("formItem.toolboxTitle")},icon:'<svg width="18" height="18" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect x="4" y="5" width="16" height="14" rx="2" fill="none" stroke="currentColor" stroke-width="2"/><path d="M8 9h8M8 13h3" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><circle cx="16" cy="13" r="2" fill="none" stroke="currentColor" stroke-width="2"/></svg>'},propertyPanel:{get title(){return f.t("formItem.propertyPanelTitle")},get fields(){return[{key:"labelName",label:f.t("formItem.properties.labelName"),placeholder:f.t("formItem.placeholders.labelName")},{key:"variableName",label:f.t("formItem.properties.variableName"),placeholder:f.t("formItem.placeholders.variableName")},{key:"layout",label:f.t("formItem.properties.layout"),type:"select",options:[{label:f.t("formItem.layouts.vertical"),value:"Vertical"},{label:f.t("formItem.layouts.horizontal"),value:"Horizontal"}]}]}},createInitialProps:()=>({labelName:Fe(),variableName:Le(),editor:void 0,layout:"Vertical"}),normalizeProps:e=>F(e),serialize:$e}),zt=Q({__name:"MFormItem",props:{edit:{type:Boolean,default:!1},labelName:{},variableName:{},editor:{default:void 0},layout:{default:"Vertical"},onChange:{},onToolChange:{}},setup(e){const r=q(()=>J(()=>import("./block-editor-selector-DWvvND_N.js").then(a=>a.M),__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url)),d=e,{t:M}=Me(),C=["MFormItem","MForm"],l=Ne(F(d));function _(){var n,s;const a={edit:d.edit,labelName:l.labelName,variableName:l.variableName,editor:Bt(l.editor),layout:se(l.layout)};(n=d.onToolChange)==null||n.call(d,a),(s=d.onChange)==null||s.call(d,a)}function h(a){a.labelName!==void 0&&(l.labelName=a.labelName),a.variableName!==void 0&&(l.variableName=a.variableName),"editor"in a&&(l.editor=V(a.editor)),a.layout!==void 0&&(l.layout=se(a.layout)),_()}function v(a){h({editor:a.value})}return U(()=>({labelName:d.labelName,variableName:d.variableName,editor:d.editor,layout:d.layout,edit:d.edit}),a=>{Object.assign(l,F(a,l.variableName))},{deep:!0}),(a,n)=>(p(),g("div",{class:Z(["ce-form-item-tool",{"ce-form-item-tool--edit":e.edit,"ce-form-item-tool--horizontal":l.layout==="Horizontal"}]),"data-testid":"editor-form-item-tool"},[e.edit?(p(),g("div",xt,[N("div",Pt,[N("div",Nt,j(l.labelName),1),N("div",Mt,[et(le(r),{edit:!0,value:l.editor,"exclude-tool-names":C,"on-change":v},null,8,["value"])])])])):(p(),g("div",At,[N("div",Lt,j(l.labelName),1),N("div",Ft,[l.editor?(p(),K(It,{key:0,block:l.editor},null,8,["block"])):(p(),g("span",$t,j(le(M)("formItem.emptyEditor")),1))])]))],2))}}),G=de(zt,[["__scopeId","data-v-c59f1044"]]);function Rt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function W(e){const r=F({...e,edit:!1});return{labelName:r.labelName,variableName:r.variableName,...r.editor?{editor:X(r.editor)}:{},layout:r.layout}}function De(e){if(Rt(e))return W(e)}function z(e){return Array.isArray(e)?e.map(r=>De(r)).filter(r=>r!==void 0):[]}const Se=O({toolbox:{get title(){return f.t("form.toolboxTitle")},icon:'<svg width="18" height="18" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect x="4" y="4" width="16" height="16" rx="2" fill="none" stroke="currentColor" stroke-width="2"/><path d="M8 8h8M8 12h8M8 16h4" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>'},createInitialProps:()=>({items:[]}),normalizeProps:e=>({edit:e.edit??!1,items:z(e.items)}),serialize:e=>({items:z(e.items).map(r=>W(r))})}),Vt=O({toolbox:{get title(){return f.t("page.toolboxTitle")},icon:'<svg width="18" height="18" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect x="4" y="3" width="16" height="18" rx="2" ry="2" fill="none" stroke="currentColor" stroke-width="2"/><path d="M8 8h8M8 12h8M8 16h5" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>'},createInitialProps:()=>({edit:!1,value:[]}),normalizeProps:e=>({edit:e.edit??!1,value:Array.isArray(e.value)?e.value:[]}),serialize:e=>({value:e.value})});function P(e){const r=e.name||e.__name;if(!r)throw new Error("Editor component is missing both name and __name.");return r}const ue={MPage:{component:T(q(()=>J(()=>import("./MPage-ChS8xsfM.js"),__vite__mapDeps([8,9,1,2,3,4,5,6,0,7,10,11,12,13,14,15]),import.meta.url))),...Vt},MEditorSelector:{component:T(q(()=>J(()=>import("./block-editor-selector-DWvvND_N.js").then(e=>e.M),__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url))),...wt},MForm:{component:T(q(()=>J(()=>Promise.resolve().then(()=>Kt),void 0,import.meta.url))),...Se},[P(Ee)]:{component:T(Ee),...ut},[P(Te)]:{component:T(Te),...dt},[P(we)]:{component:T(we),...ct},[P(_e)]:{component:T(_e),...st},[P(Ce)]:{component:T(Ce),...pt},[P(Ie)]:{component:T(Ie),...yt},[P(Pe)]:{component:T(Pe),...gt},[P(G)]:{component:T(G),...ce},[P(ke)]:{component:T(ke),...lt}};function R(e){return ue[e]}function Ot(e){return e in ue}function Ht(){return ue}const jt={key:0,class:"ce-form-tool__editor-shell","data-testid":"form-editor-shell"},Ut={key:1,class:"ce-form-tool__preview","data-testid":"preview-form-items"},qt=Q({__name:"MForm",props:{edit:{type:Boolean,default:!1},items:{default:()=>[]},onChange:{},onToolChange:{}},emits:["change"],setup(e,{expose:r,emit:d}){const M=new Set(["MPage","MForm","MFormItem","MEditorSelector"]),C=new Map,l=e,_=d,{t:h,localeValue:v}=Me(),a=rt(null),n=ie(()=>z(l.items));let s=null,k=!1,D=!1,y=null,E=null,b=S(n.value);function Be(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID().slice(0,10):Math.random().toString(36).slice(2,12)}function I(o){return o.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Y(){return Object.keys(Ht()).filter(o=>!M.has(o)&&!!R(o))}function ee(o){return Y().includes(o)}function ze(){const o="MInput";return ee(o)?o:Y()[0]}function Re(o){var x;const c=R(o);if(!c)throw new Error(`MForm could not find a registered component for "${o}".`);const i=c.normalizeProps({...((x=c.createInitialProps)==null?void 0:x.call(c))??{},edit:!0});return{id:Be(),type:o,data:c.serialize(i)}}function Ve(o){const c=C.get(o);if(c)return c;const i=R(o);if(!i)throw new Error(`MForm could not create a form item tool for "${o}".`);class x{constructor({data:t,config:u}){L(this,"state");L(this,"wrapper",null);L(this,"contentRoot",null);L(this,"vueApp",null);L(this,"propertyDialog",null);L(this,"toolbarAlignTimer",null);L(this,"handleToolbarPointer",()=>{this.scheduleToolbarAlignment()});const m=typeof(u==null?void 0:u.edit)=="boolean"?u.edit:!0,w=V(t==null?void 0:t.editor);this.state=Ne(F({...t??{},edit:m,editor:w??Re(o)}))}static get toolbox(){return i.toolbox}render(){const t=document.createElement("div");t.className="mokelay-form-item-tool",t.dataset.toolName=o,t.dataset.testid=`form-item-tool-${o}`;const u=document.createElement("div");return u.className="mokelay-form-item-tool__content",t.appendChild(u),this.wrapper=t,this.contentRoot=u,t.addEventListener("mouseenter",this.handleToolbarPointer),t.addEventListener("mousemove",this.handleToolbarPointer),this.createPropertyDialog(),this.mountVueApp(),t}destroy(){var t,u,m;this.clearToolbarAlignTimer(),(t=this.wrapper)==null||t.removeEventListener("mouseenter",this.handleToolbarPointer),(u=this.wrapper)==null||u.removeEventListener("mousemove",this.handleToolbarPointer),this.unmountVueApp(),(m=this.propertyDialog)==null||m.remove(),this.propertyDialog=null,this.contentRoot=null,this.wrapper=null}save(){return $e(this.state)}renderSettings(){return this.getPropertyFields().length?{icon:'<svg width="17" height="17" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M19.14 12.94C19.18 12.63 19.2 12.32 19.2 12C19.2 11.68 19.18 11.36 19.13 11.06L21.11 9.51C21.29 9.37 21.34 9.11 21.23 8.9L19.35 5.64C19.24 5.43 18.99 5.35 18.77 5.42L16.44 6.17C15.96 5.8 15.44 5.48 14.87 5.23L14.51 2.75C14.48 2.52 14.28 2.35 14.04 2.35H10.28C10.04 2.35 9.84 2.52 9.81 2.75L9.45 5.23C8.88 5.48 8.36 5.81 7.88 6.17L5.55 5.42C5.33 5.35 5.08 5.43 4.97 5.64L3.09 8.9C2.98 9.11 3.03 9.37 3.21 9.51L5.19 11.06C5.14 11.36 5.12 11.68 5.12 12C5.12 12.32 5.14 12.64 5.19 12.94L3.21 14.49C3.03 14.63 2.98 14.89 3.09 15.1L4.97 18.36C5.08 18.57 5.33 18.65 5.55 18.58L7.88 17.83C8.36 18.2 8.88 18.52 9.45 18.77L9.81 21.25C9.84 21.48 10.04 21.65 10.28 21.65H14.04C14.28 21.65 14.48 21.48 14.51 21.25L14.87 18.77C15.44 18.52 15.96 18.19 16.44 17.83L18.77 18.58C18.99 18.65 19.24 18.57 19.35 18.36L21.23 15.1C21.34 14.89 21.29 14.63 21.11 14.49L19.14 12.94ZM12.16 15.6C10.17 15.6 8.56 13.99 8.56 12C8.56 10.01 10.17 8.4 12.16 8.4C14.15 8.4 15.76 10.01 15.76 12C15.76 13.99 14.15 15.6 12.16 15.6Z" fill="currentColor"/></svg>',title:f.t("editor.properties"),onActivate:()=>{this.openPropertyDialog()},closeOnActivate:!0}:[]}mountVueApp(){if(!this.contentRoot)return;const t=u=>{Object.assign(this.state,F(u,this.state.variableName))};this.unmountVueApp(),this.vueApp=at({render:()=>nt(G,{...this.state,edit:!0,onToolChange:t,onChange:t})}),this.vueApp.mount(this.contentRoot)}unmountVueApp(){var t;(t=this.vueApp)==null||t.unmount(),this.vueApp=null}clearToolbarAlignTimer(){this.toolbarAlignTimer!==null&&(window.clearTimeout(this.toolbarAlignTimer),this.toolbarAlignTimer=null)}scheduleToolbarAlignment(){this.clearToolbarAlignTimer(),this.toolbarAlignTimer=window.setTimeout(()=>{this.alignToolbarToFormItem()},0)}alignToolbarToFormItem(){this.toolbarAlignTimer=null;const t=this.wrapper;if(!t)return;const u=t.closest(".ce-block"),m=t.closest(".codex-editor"),w=m==null?void 0:m.querySelector(":scope > .ce-toolbar"),A=w==null?void 0:w.querySelector(".ce-toolbar__plus");if(!u||!w||!A)return;const Ke=u.getBoundingClientRect(),be=t.getBoundingClientRect(),Ze=A.getBoundingClientRect().height||26,Ge=u.offsetTop+(be.top-Ke.top)+(be.height-Ze)/2;w.style.top=`${Math.max(0,Math.round(Ge))}px`}getPropertyFields(){var t;return((t=ce.propertyPanel)==null?void 0:t.fields)??[]}createPropertyDialog(){var w;if(!this.wrapper||!this.getPropertyFields().length)return;const t=document.createElement("dialog");t.className="mokelay-editor-tool__property-dialog",t.dataset.testid="tool-property-dialog",t.dataset.toolName="MFormItem";const u=((w=ce.propertyPanel)==null?void 0:w.title)||f.t("editor.propertyDialogTitle"),m=this.getPropertyFields().map(A=>this.renderPropertyField(A)).join("");t.innerHTML=`
3
+ <form method="dialog" class="mokelay-editor-tool__property-panel" data-testid="tool-property-panel">
4
+ <div class="mokelay-editor-tool__property-header">
5
+ <h3 class="mokelay-editor-tool__property-title" data-testid="tool-property-title">${I(u)}</h3>
6
+ <button type="submit" class="mokelay-editor-tool__property-close" data-testid="tool-property-close">${I(f.t("editor.close"))}</button>
7
+ </div>
8
+ <div class="mokelay-editor-tool__property-body" data-testid="tool-property-body">
9
+ ${m}
10
+ </div>
11
+ </form>
12
+ `,this.wrapper.appendChild(t),this.propertyDialog=t,this.bindPropertyInputs()}openPropertyDialog(){this.propertyDialog&&(this.syncPropertyDialogValues(),this.propertyDialog.open||this.propertyDialog.showModal())}syncPropertyDialogValues(){this.propertyDialog&&this.propertyDialog.querySelectorAll("[data-property-key]").forEach(t=>{const u=t.dataset.propertyKey;if(!u)return;const m=this.getPropertyFieldValue(u);if(t instanceof HTMLInputElement&&t.type==="checkbox"){t.checked=m===!0;return}t.value=typeof m=="string"?m:""})}updateProperty(t,u){Object.assign(this.state,F({...this.state,[t]:u,edit:!0},this.state.variableName))}getPropertyFieldValue(t){return this.state[t]}renderPropertyField(t){if(t.type==="checkbox")return`
13
+ <label class="mokelay-editor-tool__property-field mokelay-editor-tool__property-field--checkbox">
14
+ <input
15
+ class="mokelay-editor-tool__property-checkbox"
16
+ data-testid="tool-property-input-${t.key}"
17
+ data-property-key="${t.key}"
18
+ data-property-type="checkbox"
19
+ type="checkbox"
20
+ ${this.getPropertyFieldValue(t.key)===!0?"checked":""}
21
+ />
22
+ <span class="mokelay-editor-tool__property-label">${I(t.label)}</span>
23
+ </label>
24
+ `;if(t.type==="select"){const m=this.getPropertyFieldValue(t.key),w=(t.options??[]).map(A=>`
25
+ <option value="${I(A.value)}" ${m===A.value?"selected":""}>${I(A.label)}</option>
26
+ `).join("");return`
27
+ <label class="mokelay-editor-tool__property-field">
28
+ <span class="mokelay-editor-tool__property-label">${I(t.label)}</span>
29
+ <select
30
+ class="mokelay-editor-tool__property-input"
31
+ data-testid="tool-property-input-${t.key}"
32
+ data-property-key="${t.key}"
33
+ data-property-type="select"
34
+ >
35
+ ${w}
36
+ </select>
37
+ </label>
38
+ `}const u=this.getPropertyFieldValue(t.key);return`
39
+ <label class="mokelay-editor-tool__property-field">
40
+ <span class="mokelay-editor-tool__property-label">${I(t.label)}</span>
41
+ <input
42
+ class="mokelay-editor-tool__property-input"
43
+ data-testid="tool-property-input-${t.key}"
44
+ data-property-key="${t.key}"
45
+ data-property-type="text"
46
+ type="text"
47
+ value="${I(typeof u=="string"?u:"")}"
48
+ placeholder="${I(t.placeholder??"")}"
49
+ />
50
+ </label>
51
+ `}bindPropertyInputs(){this.propertyDialog&&this.propertyDialog.querySelectorAll("[data-property-key]").forEach(t=>{const u=t instanceof HTMLInputElement?t.type==="checkbox"?"change":"input":"change";t.addEventListener(u,()=>{const m=t.dataset.propertyKey;m&&this.updateProperty(m,this.readPropertyInputValue(t))})})}readPropertyInputValue(t){return t instanceof HTMLInputElement&&t.type==="checkbox"?t.checked:t.value}}const B=x;return C.set(o,B),B}function Oe(){return Object.fromEntries(Y().map(o=>[o,{class:Ve(o),config:{edit:!0}}]))}function He(o){var i;const c=(i=o.editor)==null?void 0:i.type;return c&&ee(c)?c:ze()}function je(o,c){const i=He(o);if(i)return{id:`form-item-${o.variableName||c}`,type:i,data:W(o)}}function S(o){return{blocks:o.map((c,i)=>je(c,i)).filter(c=>c!==void 0)}}function H(o){return(Array.isArray(o.blocks)?o.blocks:[]).filter(i=>ee(i.type)).map(i=>De(i.data)).filter(i=>i!==void 0)}function me(o,c){return JSON.stringify(o)===JSON.stringify(c)}function Ue(o){var x,B;const c=z(o),i={edit:l.edit,items:c.map(he=>W(he))};D=!0,(x=l.onToolChange)==null||x.call(l,i),(B=l.onChange)==null||B.call(l,i),_("change",i.items)}async function te(o){const c=H(b),i=H(o);b=S(i),!k&&!me(c,i)&&Ue(i)}function pe(){E!==null&&(window.clearTimeout(E),E=null)}function $(){s&&(pe(),E=window.setTimeout(async()=>{if(E=null,!!s)try{const o=await s.save();await te(o)}catch{}},0))}function qe(){const o=a.value;o&&(ye(),y=new MutationObserver(()=>{$()}),y.observe(o,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),o.addEventListener("input",$),o.addEventListener("change",$),o.addEventListener("click",$))}function ye(){const o=a.value;y==null||y.disconnect(),y=null,pe(),o==null||o.removeEventListener("input",$),o==null||o.removeEventListener("change",$),o==null||o.removeEventListener("click",$)}async function oe(){!l.edit||!a.value||s||(b=S(n.value),s=new it({holder:a.value,placeholder:h("form.placeholder"),tools:Oe(),data:b,minHeight:0,i18n:{messages:mt(v.value)},onChange:async()=>{if(!s)return;const o=await s.save();await te(o)}}),qe())}async function re(){const o=s;if(o){s=null,ye();try{const c=await o.save();b=S(H(c))}catch{b=S(n.value)}o.destroy()}}async function fe(){await re(),await ve(),await oe()}async function Je(){if(!s)return b;const o=await s.save();return await te(o),b}return r({saveEditor:Je}),tt(async()=>{await oe()}),U(()=>l.items,async o=>{if(D){D=!1;return}const c=z(o),i=H(b);me(c,i)||(k=!0,b=S(c),s&&await fe(),k=!1)},{deep:!0}),U(v,async()=>{s&&await fe()}),U(()=>l.edit,async o=>{if(o){await ve(),await oe();return}await re()}),ot(async()=>{await re()}),(o,c)=>(p(),g("div",{class:Z(["ce-form-tool",{"ce-form-tool--edit":e.edit}]),"data-testid":"editor-form-tool"},[e.edit?(p(),g("div",jt,[N("div",{ref_key:"holderRef",ref:a,class:"ce-form-tool__editor","data-testid":"form-editor-surface"},null,512)])):(p(),g("div",Ut,[(p(!0),g(ae,null,ne(n.value,(i,x)=>(p(),K(G,{key:`${i.variableName}-${x}`,edit:!1,"label-name":i.labelName,"variable-name":i.variableName,editor:i.editor?le(X)(i.editor):void 0,layout:i.layout},null,8,["label-name","variable-name","editor","layout"]))),128))]))],2))}}),Jt=de(qt,[["__scopeId","data-v-a3894c78"]]),Kt=Object.freeze(Object.defineProperty({__proto__:null,default:Jt,mFormEditorTool:Se},Symbol.toStringTag,{value:"Module"}));export{It as _,R as a,J as b,X as c,Ht as g,wt as m,V as n};