@editora/plugins 1.0.12 → 1.0.13
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/approval-workflow.cjs.js +14 -14
- package/dist/approval-workflow.esm.js +265 -262
- package/dist/blockquote.cjs.js +1 -1
- package/dist/blockquote.esm.js +177 -15
- package/dist/blocks-library.cjs.js +6 -6
- package/dist/blocks-library.esm.js +95 -92
- package/dist/bold.cjs.js +1 -1
- package/dist/bold.esm.js +10 -6
- package/dist/capitalization.cjs.js +1 -1
- package/dist/capitalization.esm.js +124 -44
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +251 -191
- package/dist/citations.cjs.js +4 -4
- package/dist/citations.esm.js +131 -128
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +68 -36
- package/dist/content-rules.cjs.js +5 -5
- package/dist/content-rules.esm.js +104 -101
- package/dist/data-binding.cjs.js +3 -3
- package/dist/data-binding.esm.js +51 -48
- package/dist/direction.cjs.js +1 -1
- package/dist/direction.esm.js +97 -74
- package/dist/doc-schema.cjs.js +4 -4
- package/dist/doc-schema.esm.js +104 -101
- package/dist/embed-iframe.cjs.js +21 -4
- package/dist/embed-iframe.esm.js +279 -116
- package/dist/heading.cjs.js +1 -1
- package/dist/heading.esm.js +239 -56
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +74 -89
- package/dist/inlineFormatting-DOYOJdnD.js +1 -0
- package/dist/inlineFormatting-DuVTGXYG.mjs +95 -0
- package/dist/italic.cjs.js +1 -1
- package/dist/italic.esm.js +12 -8
- package/dist/math.cjs.js +27 -21
- package/dist/math.esm.js +218 -146
- package/dist/merge-tag.cjs.js +8 -2
- package/dist/merge-tag.esm.js +130 -111
- package/dist/pii-redaction.cjs.js +6 -6
- package/dist/pii-redaction.esm.js +169 -166
- package/dist/smart-paste.cjs.js +5 -5
- package/dist/smart-paste.esm.js +120 -117
- package/dist/special-characters.cjs.js +6 -10
- package/dist/special-characters.esm.js +97 -75
- package/dist/strikethrough.cjs.js +1 -1
- package/dist/strikethrough.esm.js +11 -25
- package/dist/translation-workflow.cjs.js +7 -7
- package/dist/translation-workflow.esm.js +103 -100
- package/dist/underline.cjs.js +1 -1
- package/dist/underline.esm.js +7 -3
- package/package.json +3 -3
package/dist/data-binding.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=".rte-content, .editora-content",C='.rte-data-binding[data-binding="true"]',it="rte-data-binding-styles",g="rte-data-binding-dialog-overlay",f=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=".rte-content, .editora-content",C='.rte-data-binding[data-binding="true"]',it="rte-data-binding-styles",g="rte-data-binding-dialog-overlay",f=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',yt={dialogTitleInsert:"Insert Data Binding",dialogTitleEdit:"Edit Data Binding",keyLabel:"Data Key",keyPlaceholder:"user.firstName",fallbackLabel:"Fallback Text",fallbackPlaceholder:"Guest",formatLabel:"Format",currencyLabel:"Currency",currencyPlaceholder:"USD",saveText:"Save",cancelText:"Cancel",previewOnText:"Preview On",previewOffText:"Preview Off",tokenAriaPrefix:"Data binding token"},v=new WeakMap,W=new WeakMap,b=new WeakMap,K=new WeakMap,G=new WeakMap;let N=null,h=null,U=0,P=null,O=null,M=null,_=null;function ht(t){return{...yt,...t||{}}}function ot(t={}){const n=(t.locale||(typeof navigator<"u"?navigator.language:"en-US")).trim()||"en-US";return{data:t.data,getData:t.getData,api:t.api,cacheTtlMs:Math.max(0,Number(t.cacheTtlMs??3e4)),labels:ht(t.labels),defaultFormat:t.defaultFormat||"text",defaultFallback:t.defaultFallback||"",locale:n,numberFormatOptions:t.numberFormatOptions||{},dateFormatOptions:t.dateFormatOptions||{year:"numeric",month:"short",day:"2-digit"}}}function y(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function dt(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function j(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function q(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function kt(t){const n=j(t);if(q(n))return!0;const a=n.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return q(a)?!0:q(document.documentElement)||q(document.body)}function D(t,n=!0){if(t?.contentElement instanceof HTMLElement)return t.contentElement;if(t?.editorElement instanceof HTMLElement){const e=t.editorElement;if(e.matches(A))return e;const i=e.querySelector(A);if(i instanceof HTMLElement)return i}const a=window.getSelection();if(a&&a.rangeCount>0){const e=a.getRangeAt(0).startContainer,o=dt(e)?.closest(A);if(o)return o}const r=document.activeElement;if(r){if(r.matches(A))return r;const e=r.closest(A);if(e)return e}return h&&h.isConnected?h:n?document.querySelector(A):null}function R(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function lt(t){const n=window.getSelection();if(!n||n.rangeCount===0)return null;const a=n.getRangeAt(0);return t.contains(a.commonAncestorContainer)?a.cloneRange():null}function st(t,n){const a=window.getSelection();a&&(a.removeAllRanges(),a.addRange(n),t.focus({preventScroll:!0}))}function vt(t,n){const a=(n||"").trim();if(a)return a.split(".").filter(Boolean).reduce((r,e)=>{if(!(r==null||typeof r!="object"))return r[e]},t)}function xt(){if(typeof document>"u"||document.getElementById(it))return;const t=document.createElement("style");t.id=it,t.textContent=`
|
|
2
2
|
.rte-data-binding {
|
|
3
3
|
display: inline-flex;
|
|
4
4
|
align-items: center;
|
|
@@ -284,7 +284,7 @@
|
|
|
284
284
|
border-color: #2563eb;
|
|
285
285
|
color: #ffffff;
|
|
286
286
|
}
|
|
287
|
-
`,document.head.appendChild(t)}function J(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function Y(t,n){if(n===t.innerHTML)return;const a=window.execEditorCommand||window.executeEditorCommand;if(typeof a=="function")try{a("recordDomTransaction",t,n,t.innerHTML)}catch{}}function H(t,n){return{key:String(t.key||"").trim(),fallback:String(t.fallback??n.defaultFallback??""),format:t.format||n.defaultFormat||"text",currency:String(t.currency||"USD").trim().toUpperCase()||"USD"}}function ct(t){return`{{${t.key}}}`}function ut(t,n){const a=document.createElement("span");return a.className="rte-data-binding",a.setAttribute("data-binding","true"),a.setAttribute("data-binding-key",t.key),a.setAttribute("data-binding-fallback",t.fallback||""),a.setAttribute("data-binding-format",t.format||"text"),a.setAttribute("data-binding-currency",t.currency||"USD"),a.setAttribute("contenteditable","false"),a.setAttribute("spellcheck","false"),a.setAttribute("draggable","false"),a.setAttribute("tabindex","0"),a.setAttribute("role","button"),a.setAttribute("aria-label",`${n.tokenAriaPrefix}: ${t.key}. Press Enter to edit.`),a.textContent=ct(t),a}function Z(t,n){return H({key:t.getAttribute("data-binding-key")||"",fallback:t.getAttribute("data-binding-fallback")||n.defaultFallback,format:t.getAttribute("data-binding-format")||n.defaultFormat,currency:t.getAttribute("data-binding-currency")||"USD"},n)}function X(t,n,a){t.classList.add("rte-data-binding"),t.setAttribute("data-binding","true"),t.setAttribute("data-binding-key",n.key),t.setAttribute("data-binding-fallback",n.fallback||""),t.setAttribute("data-binding-format",n.format||"text"),t.setAttribute("data-binding-currency",n.currency||"USD"),t.setAttribute("contenteditable","false"),t.setAttribute("spellcheck","false"),t.setAttribute("draggable","false"),t.setAttribute("tabindex","0"),t.setAttribute("role","button"),t.setAttribute("aria-label",`${a.tokenAriaPrefix}: ${n.key}. Press Enter to edit.`)}function V(t,n){const a=Array.from(t.querySelectorAll(C));return a.forEach(r=>{const e=Z(r,n);X(r,e,n.labels)}),a}function Q(t){const n=window.getSelection();if(n&&n.rangeCount>0){const e=n.getRangeAt(0).startContainer,o=dt(e)?.closest(C);if(o&&t.contains(o))return o}const r=document.activeElement?.closest(C);return r&&t.contains(r)?r:null}function ft(){
|
|
287
|
+
`,document.head.appendChild(t)}function J(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function Y(t,n){if(n===t.innerHTML)return;const a=window.execEditorCommand||window.executeEditorCommand;if(typeof a=="function")try{a("recordDomTransaction",t,n,t.innerHTML)}catch{}}function H(t,n){return{key:String(t.key||"").trim(),fallback:String(t.fallback??n.defaultFallback??""),format:t.format||n.defaultFormat||"text",currency:String(t.currency||"USD").trim().toUpperCase()||"USD"}}function ct(t){return`{{${t.key}}}`}function ut(t,n){const a=document.createElement("span");return a.className="rte-data-binding",a.setAttribute("data-binding","true"),a.setAttribute("data-binding-key",t.key),a.setAttribute("data-binding-fallback",t.fallback||""),a.setAttribute("data-binding-format",t.format||"text"),a.setAttribute("data-binding-currency",t.currency||"USD"),a.setAttribute("contenteditable","false"),a.setAttribute("spellcheck","false"),a.setAttribute("draggable","false"),a.setAttribute("tabindex","0"),a.setAttribute("role","button"),a.setAttribute("aria-label",`${n.tokenAriaPrefix}: ${t.key}. Press Enter to edit.`),a.textContent=ct(t),a}function Z(t,n){return H({key:t.getAttribute("data-binding-key")||"",fallback:t.getAttribute("data-binding-fallback")||n.defaultFallback,format:t.getAttribute("data-binding-format")||n.defaultFormat,currency:t.getAttribute("data-binding-currency")||"USD"},n)}function X(t,n,a){t.classList.add("rte-data-binding"),t.setAttribute("data-binding","true"),t.setAttribute("data-binding-key",n.key),t.setAttribute("data-binding-fallback",n.fallback||""),t.setAttribute("data-binding-format",n.format||"text"),t.setAttribute("data-binding-currency",n.currency||"USD"),t.setAttribute("contenteditable","false"),t.setAttribute("spellcheck","false"),t.setAttribute("draggable","false"),t.setAttribute("tabindex","0"),t.setAttribute("role","button"),t.setAttribute("aria-label",`${a.tokenAriaPrefix}: ${n.key}. Press Enter to edit.`)}function V(t,n){const a=Array.from(t.querySelectorAll(C));return a.forEach(r=>{const e=Z(r,n);X(r,e,n.labels)}),a}function Q(t){const n=window.getSelection();if(n&&n.rangeCount>0){const e=n.getRangeAt(0).startContainer,o=dt(e)?.closest(C);if(o&&t.contains(o))return o}const r=document.activeElement?.closest(C);return r&&t.contains(r)?r:null}function ft(){N&&(N.cleanup(),N=null)}function tt(t,n,a){const r=j(t);Array.from(r.querySelectorAll('[data-command="toggleDataBindingPreview"]')).forEach(i=>{if(i.setAttribute("data-active",n?"true":"false"),i.classList.toggle("active",n),i.setAttribute("aria-pressed",n?"true":"false"),a){const o=n?a.labels.previewOnText:a.labels.previewOffText;i.setAttribute("title",o),i.setAttribute("aria-label",o)}})}function wt(t,n,a){const r=n.format||"text";if(t==null)return n.fallback||"";if(r==="json"){if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}if(r==="date"){const e=t instanceof Date?t:new Date(String(t));if(Number.isNaN(e.getTime()))return String(t);try{return new Intl.DateTimeFormat(a.locale,a.dateFormatOptions).format(e)}catch{return e.toISOString()}}if(r==="number"||r==="currency"){const e=typeof t=="number"?t:Number(t);if(!Number.isFinite(e))return String(t);const i={...a.numberFormatOptions};if(r==="currency"){const o=(n.currency||"USD").toUpperCase();Object.assign(i,{style:"currency",currency:o})}try{return new Intl.NumberFormat(a.locale,i).format(e)}catch{return String(e)}}return String(t)}function T(t,n,a,r){const e=Z(t,n),i=e.key;if(t.classList.remove("rte-data-binding-preview","rte-data-binding-missing"),!a){t.textContent=ct(e),t.setAttribute("aria-label",`${n.labels.tokenAriaPrefix}: ${i}. Press Enter to edit.`);return}const o=vt(r,i),l=o==null,d=l?e.fallback||"":wt(o,e,n);t.textContent=d||e.fallback||"",t.classList.add("rte-data-binding-preview"),l&&!(e.fallback||"").trim()&&t.classList.add("rte-data-binding-missing"),t.setAttribute("aria-label",`${n.labels.tokenAriaPrefix}: ${i} = ${t.textContent||""}. Press Enter to edit.`)}function x(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Et(t,n){return n?n.split(".").filter(Boolean).reduce((a,r)=>{if(!(!x(a)&&!Array.isArray(a)))return a[r]},t):t}function Dt(t,n,a){const r=n.api,e=j(t),i={editor:t,editorRoot:e,signal:a};if(r.buildRequest){const p=r.buildRequest(i);return{url:p.url,init:{...p.init||{},signal:a}}}const o=(r.method||"GET").toUpperCase(),l=typeof r.headers=="function"?r.headers(i):r.headers||{},d=typeof r.params=="function"?r.params(i):r.params,c=new URL(r.url,window.location.origin);d&&Object.entries(d).forEach(([p,m])=>{m!=null&&c.searchParams.set(p,String(m))});const u={method:o,headers:{...l},credentials:r.credentials,mode:r.mode,cache:r.cache,signal:a};if(o!=="GET"&&o!=="HEAD"){const p=typeof r.body=="function"?r.body(i):r.body;if(p!=null)if(x(p)){u.body=JSON.stringify(p);const m=u.headers;!m["Content-Type"]&&!m["content-type"]&&(m["Content-Type"]="application/json")}else u.body=p}return{url:c.toString(),init:u}}async function At(t,n){const a=n.api;if(!a)return{};const r=new AbortController,e=j(t),i={editor:t,editorRoot:e,signal:r.signal},o=Math.max(0,Number(a.timeoutMs??1e4));let l=null;o>0&&(l=window.setTimeout(()=>r.abort(),o));try{const{url:d,init:c}=Dt(t,n,r.signal),u=await fetch(d,{...c,signal:r.signal});if(!u.ok)throw new Error(`Data binding API request failed: ${u.status}`);const m=(a.responseType||"json")==="text"?await u.text():await u.json();if(a.transformResponse){const B=a.transformResponse(m,i);return x(B)?B:{}}const $=Et(m,a.responsePath);return x($)?$:x(m)?m:{value:$}}catch(d){return d?.name!=="AbortError"&&a.onError?.(d,i),{}}finally{l!==null&&window.clearTimeout(l)}}async function I(t,n){const a=W.get(t);if(a)return a;const r=K.get(t),e=Date.now();if(r&&e-r.timestamp<=n.cacheTtlMs)return r.data;const i=G.get(t);if(i)return i;const o=(async()=>{try{if(typeof n.getData=="function"){const d=await Promise.resolve(n.getData({editor:t,editorRoot:j(t)}));if(x(d))return d}if(n.api){const d=await At(t,n);if(x(d))return d}if(typeof n.data=="function"){const d=await Promise.resolve(n.data());if(x(d))return d}return x(n.data)?n.data:{}}finally{G.delete(t)}})();G.set(t,o);const l=await o;return K.set(t,{timestamp:e,data:l}),l}async function z(t,n,a){const r=V(t,n);if(v.set(t,a),tt(t,a,n),!a){r.forEach(i=>T(i,n,!1));return}const e=await I(t,n);r.forEach(i=>T(i,n,!0,e))}function bt(t,n){let a=lt(t);a||(a=document.createRange(),a.selectNodeContents(t),a.collapse(!1)),a.collapsed||a.deleteContents(),a.insertNode(n);const r=document.createTextNode(" ");n.after(r);const e=document.createRange();e.setStart(r,1),e.collapse(!0),st(t,e),t.normalize()}function gt(t){return typeof t.key=="string"?t.key.toLowerCase():""}function St(t){const n=t.metaKey||t.ctrlKey,a=gt(t),r=n&&t.altKey&&t.shiftKey&&a==="d",e=!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey&&a==="f7";return r||e}function Tt(t){const n=t.metaKey||t.ctrlKey,a=gt(t),r=n&&t.altKey&&t.shiftKey&&a==="b",e=!t.metaKey&&!t.ctrlKey&&!t.altKey&&!t.shiftKey&&a==="f8";return r||e}function S(t,n,a,r,e){ft();const i=a==="insert"?lt(t):null,o=n.labels,l=e?Z(e,n):H(r||{},n),d=document.createElement("div");d.className=g,kt(t)&&d.classList.add("rte-data-binding-theme-dark");const c=document.createElement("section");c.className="rte-data-binding-dialog",c.setAttribute("role","dialog"),c.setAttribute("aria-modal","true"),c.setAttribute("aria-labelledby","rte-data-binding-dialog-title"),c.innerHTML=`
|
|
288
288
|
<header class="rte-data-binding-header">
|
|
289
289
|
<h2 id="rte-data-binding-dialog-title" class="rte-data-binding-title">${y(a==="edit"?o.dialogTitleEdit:o.dialogTitleInsert)}</h2>
|
|
290
290
|
<button type="button" class="rte-data-binding-btn" data-action="cancel" aria-label="${y(o.cancelText)}">✕</button>
|
|
@@ -318,4 +318,4 @@
|
|
|
318
318
|
<button type="button" class="rte-data-binding-btn" data-action="cancel">${y(o.cancelText)}</button>
|
|
319
319
|
<button type="button" class="rte-data-binding-btn rte-data-binding-btn-primary" data-action="save">${y(o.saveText)}</button>
|
|
320
320
|
</footer>
|
|
321
|
-
`,d.appendChild(c),document.body.appendChild(d);const u=c.querySelector(".rte-data-binding-key"),p=c.querySelector(".rte-data-binding-fallback"),m=c.querySelector(".rte-data-binding-format"),$=c.querySelector(".rte-data-binding-currency"),B=()=>{const s=m?.value==="currency",k=$?.closest(".rte-data-binding-field");k&&(k.style.display=s?"grid":"none")};B(),m?.addEventListener("change",B);const L=()=>{d.removeEventListener("click",nt),d.removeEventListener("keydown",rt,!0),document.removeEventListener("keydown",et,!0),d.parentNode&&d.parentNode.removeChild(d),
|
|
321
|
+
`,d.appendChild(c),document.body.appendChild(d);const u=c.querySelector(".rte-data-binding-key"),p=c.querySelector(".rte-data-binding-fallback"),m=c.querySelector(".rte-data-binding-format"),$=c.querySelector(".rte-data-binding-currency"),B=()=>{const s=m?.value==="currency",k=$?.closest(".rte-data-binding-field");k&&(k.style.display=s?"grid":"none")};B(),m?.addEventListener("change",B);const L=()=>{d.removeEventListener("click",nt),d.removeEventListener("keydown",rt,!0),document.removeEventListener("keydown",et,!0),d.parentNode&&d.parentNode.removeChild(d),N=null,t.focus({preventScroll:!0})},et=s=>{s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),L())},nt=s=>{s.target===d&&L()},mt=s=>{if(s.key!=="Tab")return;const k=Array.from(c.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(k.length===0)return;const w=k[0],E=k[k.length-1],F=document.activeElement;if(s.shiftKey&&F===w){s.preventDefault(),E.focus();return}!s.shiftKey&&F===E&&(s.preventDefault(),w.focus())},at=async()=>{const s=(u?.value||"").trim();if(!s){u?.focus();return}const k=H({key:s,fallback:(p?.value||"").trim(),format:m?.value||n.defaultFormat,currency:($?.value||"USD").trim().toUpperCase()},n),w=t.innerHTML;if(e){X(e,k,o);const E=v.get(t)===!0,F=E?await I(t,n):void 0;T(e,n,E,F)}else{if(i)try{st(t,i)}catch{}const E=ut(k,o);if(bt(t,E),v.get(t)===!0){const pt=await I(t,n);T(E,n,!0,pt)}}J(t),Y(t,w),L()},rt=s=>{if(s.key==="Escape"){s.preventDefault(),L();return}mt(s),s.key==="Enter"&&!s.shiftKey&&s.target instanceof HTMLInputElement&&(s.preventDefault(),at())};c.addEventListener("click",s=>{const w=s.target?.getAttribute("data-action");if(w){if(w==="cancel"){L();return}w==="save"&&at()}}),d.addEventListener("click",nt),d.addEventListener("keydown",rt,!0),document.addEventListener("keydown",et,!0),N={cleanup:L},u?.focus()}function $t(t){_=t,O||(O=n=>{const r=n.target?.closest(A);if(!r)return;h=r,b.has(r)||b.set(r,t);const e=b.get(r)||t;V(r,e);const i=v.get(r)===!0;tt(r,i,e),i||Array.from(r.querySelectorAll(C)).forEach(l=>T(l,e,!1))},document.addEventListener("focusin",O,!0)),P||(P=n=>{if(document.querySelector(`.${g}`))return;const a=n.target;if(a?.closest("input, textarea, select"))return;const r=D(void 0,!1);if(!r||R(r))return;const e=b.get(r)||_||t,i=a?.closest(C);if(i&&(n.key==="Enter"||n.key===" ")){n.preventDefault(),n.stopPropagation(),h=r,S(r,e,"edit",void 0,i);return}if(St(n)){n.preventDefault(),n.stopPropagation();const o=Q(r);o?S(r,e,"edit",void 0,o):S(r,e,"insert");return}if(Tt(n)){n.preventDefault(),n.stopPropagation();const o=v.get(r)!==!0;z(r,e,o)}},document.addEventListener("keydown",P,!0)),M||(M=n=>{if(document.querySelector(`.${g}`)||n.defaultPrevented||n.button!==0||n.metaKey||n.ctrlKey||n.altKey||n.shiftKey)return;const r=n.target?.closest(C);if(!r)return;const e=r.closest(A);if(!e||R(e))return;const i=b.get(e)||_||t;b.set(e,i),h=e,n.preventDefault(),n.stopPropagation(),r.focus({preventScroll:!0}),S(e,i,"edit",void 0,r)},document.addEventListener("click",M,!0))}function Lt(){O&&(document.removeEventListener("focusin",O,!0),O=null),P&&(document.removeEventListener("keydown",P,!0),P=null),M&&(document.removeEventListener("click",M,!0),M=null),_=null,h=null}const Ct=(t={})=>{const n=ot(t);return xt(),{name:"dataBinding",toolbar:[{id:"dataBindingTools",label:"Data Binding",type:"group",command:"openDataBindingDialog",items:[{id:"dataBinding",label:"Data Binding",command:"openDataBindingDialog",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M7 4a3 3 0 0 0-3 3v3h2V7a1 1 0 0 1 1-1h3V4H7Zm10 0h-3v2h3a1 1 0 0 1 1 1v3h2V7a3 3 0 0 0-3-3ZM4 14v3a3 3 0 0 0 3 3h3v-2H7a1 1 0 0 1-1-1v-3H4Zm14 0v3a1 1 0 0 1-1 1h-3v2h3a3 3 0 0 0 3-3v-3h-2ZM8.5 12a1.5 1.5 0 1 1 0-3h7a1.5 1.5 0 0 1 0 3h-7Zm0 4a1.5 1.5 0 1 1 0-3h4a1.5 1.5 0 0 1 0 3h-4Z" fill="currentColor"></path></svg>'},{id:"dataBindingPreview",label:"Data Preview",command:"toggleDataBindingPreview",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M12 3c-4.4 0-8 1.3-8 3v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6c0-1.7-3.6-3-8-3Zm0 2c3.9 0 6 .9 6 1s-2.1 1-6 1-6-.9-6-1 2.1-1 6-1Zm0 4c3 0 5.6-.5 7-1.3V11c0 .9-2.7 2-7 2s-7-1.1-7-2V7.7C6.4 8.5 9 9 12 9Zm0 6c-4.3 0-7-1.1-7-2v3c0 .9 2.7 2 7 2s7-1.1 7-2v-3c0 .9-2.7 2-7 2Z" fill="currentColor"></path><path d="M16.5 9.4a1 1 0 0 1 1.4 0l1.1 1.1 1.8-1.8a1 1 0 1 1 1.4 1.4l-2.5 2.5a1 1 0 0 1-1.4 0l-1.8-1.8a1 1 0 0 1 0-1.4Z" fill="currentColor"></path></svg>'}]}],commands:{openDataBindingDialog:(a,r)=>{const e=D(r);if(!e||R(e))return!1;h=e;const i=b.get(e)||n;b.set(e,i),V(e,i);const o=a?.target;if(o==="insert")return S(e,i,"insert",a),!0;const l=Q(e);return o==="edit"||l?!l&&o==="edit"?!1:(S(e,i,"edit",a,l||void 0),!0):(S(e,i,"insert",a),!0)},insertDataBindingToken:async(a,r)=>{const e=D(r);if(!e||R(e))return!1;h=e;const i=b.get(e)||n;b.set(e,i);const o=H(a||{},i);if(!o.key)return!1;const l=e.innerHTML,d=ut(o,i.labels);if(bt(e,d),v.get(e)===!0){const u=await I(e,i);T(d,i,!0,u)}return J(e),Y(e,l),!0},editDataBindingToken:async(a,r)=>{const e=D(r);if(!e||R(e))return!1;h=e;const i=b.get(e)||n;b.set(e,i);const o=Q(e);if(!o)return!1;const l=Z(o,i),d=H({...l,...a||{}},i);if(!d.key)return!1;const c=e.innerHTML;X(o,d,i.labels);const u=v.get(e)===!0,p=u?await I(e,i):void 0;return T(o,i,u,p),J(e),Y(e,c),!0},toggleDataBindingPreview:async(a,r)=>{const e=D(r);if(!e)return!1;h=e;const i=b.get(e)||n;b.set(e,i);const o=typeof a=="boolean"?a:v.get(e)!==!0;return await z(e,i,o),!0},setDataBindingData:async(a,r)=>{const e=D(r);if(!e)return!1;if(h=e,a&&typeof a=="object"?(W.set(e,a),K.set(e,{timestamp:Date.now(),data:a})):(W.delete(e),K.delete(e)),v.get(e)===!0){const i=b.get(e)||n;await z(e,i,!0)}return!0},refreshDataBindings:async(a,r)=>{const e=D(r);if(!e)return!1;h=e,K.delete(e);const i=b.get(e)||n;b.set(e,i);const o=v.get(e)===!0;return await z(e,i,o),!0}},keymap:{"Mod-Alt-Shift-d":"openDataBindingDialog","Mod-Alt-Shift-D":"openDataBindingDialog","Mod-Alt-Shift-b":"toggleDataBindingPreview","Mod-Alt-Shift-B":"toggleDataBindingPreview",F7:"openDataBindingDialog",F8:"toggleDataBindingPreview"},init:function(r){U+=1;const e=this&&typeof this.__pluginConfig=="object"?ot({...n,...this.__pluginConfig}):n;$t(e);const i=D(r&&r.editorElement?{editorElement:r.editorElement}:void 0,!1);if(i){h=i,b.set(i,e),V(i,e);const o=v.get(i)===!0;tt(i,o,e)}},destroy:()=>{U=Math.max(0,U-1),U===0&&(ft(),Lt())}}};exports.DataBindingPlugin=Ct;
|
package/dist/data-binding.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const A = ".rte-content, .editora-content", C = '.rte-data-binding[data-binding="true"]', it = "rte-data-binding-styles", g = "rte-data-binding-dialog-overlay", f = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',
|
|
1
|
+
const A = ".rte-content, .editora-content", C = '.rte-data-binding[data-binding="true"]', it = "rte-data-binding-styles", g = "rte-data-binding-dialog-overlay", f = ':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)', yt = {
|
|
2
2
|
dialogTitleInsert: "Insert Data Binding",
|
|
3
3
|
dialogTitleEdit: "Edit Data Binding",
|
|
4
4
|
keyLabel: "Data Key",
|
|
@@ -13,11 +13,11 @@ const A = ".rte-content, .editora-content", C = '.rte-data-binding[data-binding=
|
|
|
13
13
|
previewOnText: "Preview On",
|
|
14
14
|
previewOffText: "Preview Off",
|
|
15
15
|
tokenAriaPrefix: "Data binding token"
|
|
16
|
-
}, x = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap(),
|
|
17
|
-
let
|
|
18
|
-
function
|
|
16
|
+
}, x = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
let N = null, h = null, U = 0, P = null, O = null, M = null, z = null;
|
|
18
|
+
function ht(t) {
|
|
19
19
|
return {
|
|
20
|
-
...
|
|
20
|
+
...yt,
|
|
21
21
|
...t || {}
|
|
22
22
|
};
|
|
23
23
|
}
|
|
@@ -28,7 +28,7 @@ function ot(t = {}) {
|
|
|
28
28
|
getData: t.getData,
|
|
29
29
|
api: t.api,
|
|
30
30
|
cacheTtlMs: Math.max(0, Number(t.cacheTtlMs ?? 3e4)),
|
|
31
|
-
labels:
|
|
31
|
+
labels: ht(t.labels),
|
|
32
32
|
defaultFormat: t.defaultFormat || "text",
|
|
33
33
|
defaultFallback: t.defaultFallback || "",
|
|
34
34
|
locale: n,
|
|
@@ -48,7 +48,7 @@ function j(t) {
|
|
|
48
48
|
function q(t) {
|
|
49
49
|
return t ? (t.getAttribute("data-theme") || t.getAttribute("theme") || "").toLowerCase() === "dark" ? !0 : t.classList.contains("dark") || t.classList.contains("editora-theme-dark") || t.classList.contains("rte-theme-dark") : !1;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function kt(t) {
|
|
52
52
|
const n = j(t);
|
|
53
53
|
if (q(n)) return !0;
|
|
54
54
|
const a = n.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");
|
|
@@ -75,7 +75,7 @@ function D(t, n = !0) {
|
|
|
75
75
|
}
|
|
76
76
|
return h && h.isConnected ? h : n ? document.querySelector(A) : null;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function R(t) {
|
|
79
79
|
return t.getAttribute("contenteditable") === "false" || t.getAttribute("data-readonly") === "true";
|
|
80
80
|
}
|
|
81
81
|
function lt(t) {
|
|
@@ -88,7 +88,7 @@ function st(t, n) {
|
|
|
88
88
|
const a = window.getSelection();
|
|
89
89
|
a && (a.removeAllRanges(), a.addRange(n), t.focus({ preventScroll: !0 }));
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function xt(t, n) {
|
|
92
92
|
const a = (n || "").trim();
|
|
93
93
|
if (a)
|
|
94
94
|
return a.split(".").filter(Boolean).reduce((r, e) => {
|
|
@@ -96,7 +96,7 @@ function kt(t, n) {
|
|
|
96
96
|
return r[e];
|
|
97
97
|
}, t);
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function vt() {
|
|
100
100
|
if (typeof document > "u" || document.getElementById(it)) return;
|
|
101
101
|
const t = document.createElement("style");
|
|
102
102
|
t.id = it, t.textContent = `
|
|
@@ -445,7 +445,7 @@ function Q(t) {
|
|
|
445
445
|
return r && t.contains(r) ? r : null;
|
|
446
446
|
}
|
|
447
447
|
function ft() {
|
|
448
|
-
|
|
448
|
+
N && (N.cleanup(), N = null);
|
|
449
449
|
}
|
|
450
450
|
function tt(t, n, a) {
|
|
451
451
|
const r = j(t);
|
|
@@ -456,7 +456,7 @@ function tt(t, n, a) {
|
|
|
456
456
|
}
|
|
457
457
|
});
|
|
458
458
|
}
|
|
459
|
-
function
|
|
459
|
+
function wt(t, n, a) {
|
|
460
460
|
const r = n.format || "text";
|
|
461
461
|
if (t == null) return n.fallback || "";
|
|
462
462
|
if (r === "json") {
|
|
@@ -498,19 +498,19 @@ function T(t, n, a, r) {
|
|
|
498
498
|
t.textContent = ct(e), t.setAttribute("aria-label", `${n.labels.tokenAriaPrefix}: ${i}. Press Enter to edit.`);
|
|
499
499
|
return;
|
|
500
500
|
}
|
|
501
|
-
const o =
|
|
501
|
+
const o = xt(r, i), l = o == null, d = l ? e.fallback || "" : wt(o, e, n);
|
|
502
502
|
t.textContent = d || e.fallback || "", t.classList.add("rte-data-binding-preview"), l && !(e.fallback || "").trim() && t.classList.add("rte-data-binding-missing"), t.setAttribute("aria-label", `${n.labels.tokenAriaPrefix}: ${i} = ${t.textContent || ""}. Press Enter to edit.`);
|
|
503
503
|
}
|
|
504
504
|
function v(t) {
|
|
505
505
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
506
506
|
}
|
|
507
|
-
function
|
|
507
|
+
function Et(t, n) {
|
|
508
508
|
return n ? n.split(".").filter(Boolean).reduce((a, r) => {
|
|
509
509
|
if (!(!v(a) && !Array.isArray(a)))
|
|
510
510
|
return a[r];
|
|
511
511
|
}, t) : t;
|
|
512
512
|
}
|
|
513
|
-
function
|
|
513
|
+
function Dt(t, n, a) {
|
|
514
514
|
const r = n.api, e = j(t), i = { editor: t, editorRoot: e, signal: a };
|
|
515
515
|
if (r.buildRequest) {
|
|
516
516
|
const p = r.buildRequest(i);
|
|
@@ -540,14 +540,14 @@ function Et(t, n, a) {
|
|
|
540
540
|
}
|
|
541
541
|
return { url: c.toString(), init: u };
|
|
542
542
|
}
|
|
543
|
-
async function
|
|
543
|
+
async function At(t, n) {
|
|
544
544
|
const a = n.api;
|
|
545
545
|
if (!a) return {};
|
|
546
546
|
const r = new AbortController(), e = j(t), i = { editor: t, editorRoot: e, signal: r.signal }, o = Math.max(0, Number(a.timeoutMs ?? 1e4));
|
|
547
547
|
let l = null;
|
|
548
548
|
o > 0 && (l = window.setTimeout(() => r.abort(), o));
|
|
549
549
|
try {
|
|
550
|
-
const { url: d, init: c } =
|
|
550
|
+
const { url: d, init: c } = Dt(t, n, r.signal), u = await fetch(d, { ...c, signal: r.signal });
|
|
551
551
|
if (!u.ok)
|
|
552
552
|
throw new Error(`Data binding API request failed: ${u.status}`);
|
|
553
553
|
const m = (a.responseType || "json") === "text" ? await u.text() : await u.json();
|
|
@@ -555,7 +555,7 @@ async function Dt(t, n) {
|
|
|
555
555
|
const B = a.transformResponse(m, i);
|
|
556
556
|
return v(B) ? B : {};
|
|
557
557
|
}
|
|
558
|
-
const $ =
|
|
558
|
+
const $ = Et(m, a.responsePath);
|
|
559
559
|
return v($) ? $ : v(m) ? m : { value: $ };
|
|
560
560
|
} catch (d) {
|
|
561
561
|
return d?.name !== "AbortError" && a.onError?.(d, i), {};
|
|
@@ -566,7 +566,7 @@ async function Dt(t, n) {
|
|
|
566
566
|
async function I(t, n) {
|
|
567
567
|
const a = W.get(t);
|
|
568
568
|
if (a) return a;
|
|
569
|
-
const r =
|
|
569
|
+
const r = K.get(t), e = Date.now();
|
|
570
570
|
if (r && e - r.timestamp <= n.cacheTtlMs)
|
|
571
571
|
return r.data;
|
|
572
572
|
const i = G.get(t);
|
|
@@ -578,7 +578,7 @@ async function I(t, n) {
|
|
|
578
578
|
if (v(d)) return d;
|
|
579
579
|
}
|
|
580
580
|
if (n.api) {
|
|
581
|
-
const d = await
|
|
581
|
+
const d = await At(t, n);
|
|
582
582
|
if (v(d)) return d;
|
|
583
583
|
}
|
|
584
584
|
if (typeof n.data == "function") {
|
|
@@ -592,7 +592,7 @@ async function I(t, n) {
|
|
|
592
592
|
})();
|
|
593
593
|
G.set(t, o);
|
|
594
594
|
const l = await o;
|
|
595
|
-
return
|
|
595
|
+
return K.set(t, { timestamp: e, data: l }), l;
|
|
596
596
|
}
|
|
597
597
|
async function _(t, n, a) {
|
|
598
598
|
const r = V(t, n);
|
|
@@ -611,18 +611,21 @@ function bt(t, n) {
|
|
|
611
611
|
const e = document.createRange();
|
|
612
612
|
e.setStart(r, 1), e.collapse(!0), st(t, e), t.normalize();
|
|
613
613
|
}
|
|
614
|
-
function
|
|
615
|
-
|
|
616
|
-
return r || e;
|
|
614
|
+
function gt(t) {
|
|
615
|
+
return typeof t.key == "string" ? t.key.toLowerCase() : "";
|
|
617
616
|
}
|
|
618
617
|
function St(t) {
|
|
619
|
-
const n = t.metaKey || t.ctrlKey, a = t
|
|
618
|
+
const n = t.metaKey || t.ctrlKey, a = gt(t), r = n && t.altKey && t.shiftKey && a === "d", e = !t.metaKey && !t.ctrlKey && !t.altKey && !t.shiftKey && a === "f7";
|
|
619
|
+
return r || e;
|
|
620
|
+
}
|
|
621
|
+
function Tt(t) {
|
|
622
|
+
const n = t.metaKey || t.ctrlKey, a = gt(t), r = n && t.altKey && t.shiftKey && a === "b", e = !t.metaKey && !t.ctrlKey && !t.altKey && !t.shiftKey && a === "f8";
|
|
620
623
|
return r || e;
|
|
621
624
|
}
|
|
622
625
|
function S(t, n, a, r, e) {
|
|
623
626
|
ft();
|
|
624
627
|
const i = a === "insert" ? lt(t) : null, o = n.labels, l = e ? Z(e, n) : H(r || {}, n), d = document.createElement("div");
|
|
625
|
-
d.className = g,
|
|
628
|
+
d.className = g, kt(t) && d.classList.add("rte-data-binding-theme-dark");
|
|
626
629
|
const c = document.createElement("section");
|
|
627
630
|
c.className = "rte-data-binding-dialog", c.setAttribute("role", "dialog"), c.setAttribute("aria-modal", "true"), c.setAttribute("aria-labelledby", "rte-data-binding-dialog-title"), c.innerHTML = `
|
|
628
631
|
<header class="rte-data-binding-header">
|
|
@@ -673,12 +676,12 @@ function S(t, n, a, r, e) {
|
|
|
673
676
|
};
|
|
674
677
|
B(), m?.addEventListener("change", B);
|
|
675
678
|
const L = () => {
|
|
676
|
-
d.removeEventListener("click", nt), d.removeEventListener("keydown", rt, !0), document.removeEventListener("keydown", et, !0), d.parentNode && d.parentNode.removeChild(d),
|
|
679
|
+
d.removeEventListener("click", nt), d.removeEventListener("keydown", rt, !0), document.removeEventListener("keydown", et, !0), d.parentNode && d.parentNode.removeChild(d), N = null, t.focus({ preventScroll: !0 });
|
|
677
680
|
}, et = (s) => {
|
|
678
681
|
s.key === "Escape" && (s.preventDefault(), s.stopPropagation(), L());
|
|
679
682
|
}, nt = (s) => {
|
|
680
683
|
s.target === d && L();
|
|
681
|
-
},
|
|
684
|
+
}, mt = (s) => {
|
|
682
685
|
if (s.key !== "Tab") return;
|
|
683
686
|
const k = Array.from(
|
|
684
687
|
c.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')
|
|
@@ -717,8 +720,8 @@ function S(t, n, a, r, e) {
|
|
|
717
720
|
}
|
|
718
721
|
const E = ut(k, o);
|
|
719
722
|
if (bt(t, E), x.get(t) === !0) {
|
|
720
|
-
const
|
|
721
|
-
T(E, n, !0,
|
|
723
|
+
const pt = await I(t, n);
|
|
724
|
+
T(E, n, !0, pt);
|
|
722
725
|
}
|
|
723
726
|
}
|
|
724
727
|
J(t), Y(t, w), L();
|
|
@@ -727,7 +730,7 @@ function S(t, n, a, r, e) {
|
|
|
727
730
|
s.preventDefault(), L();
|
|
728
731
|
return;
|
|
729
732
|
}
|
|
730
|
-
|
|
733
|
+
mt(s), s.key === "Enter" && !s.shiftKey && s.target instanceof HTMLInputElement && (s.preventDefault(), at());
|
|
731
734
|
};
|
|
732
735
|
c.addEventListener("click", (s) => {
|
|
733
736
|
const w = s.target?.getAttribute("data-action");
|
|
@@ -738,9 +741,9 @@ function S(t, n, a, r, e) {
|
|
|
738
741
|
}
|
|
739
742
|
w === "save" && at();
|
|
740
743
|
}
|
|
741
|
-
}), d.addEventListener("click", nt), d.addEventListener("keydown", rt, !0), document.addEventListener("keydown", et, !0),
|
|
744
|
+
}), d.addEventListener("click", nt), d.addEventListener("keydown", rt, !0), document.addEventListener("keydown", et, !0), N = { cleanup: L }, u?.focus();
|
|
742
745
|
}
|
|
743
|
-
function
|
|
746
|
+
function $t(t) {
|
|
744
747
|
z = t, O || (O = (n) => {
|
|
745
748
|
const r = n.target?.closest(A);
|
|
746
749
|
if (!r) return;
|
|
@@ -754,19 +757,19 @@ function Tt(t) {
|
|
|
754
757
|
const a = n.target;
|
|
755
758
|
if (a?.closest("input, textarea, select")) return;
|
|
756
759
|
const r = D(void 0, !1);
|
|
757
|
-
if (!r ||
|
|
760
|
+
if (!r || R(r)) return;
|
|
758
761
|
const e = b.get(r) || z || t, i = a?.closest(C);
|
|
759
762
|
if (i && (n.key === "Enter" || n.key === " ")) {
|
|
760
763
|
n.preventDefault(), n.stopPropagation(), h = r, S(r, e, "edit", void 0, i);
|
|
761
764
|
return;
|
|
762
765
|
}
|
|
763
|
-
if (
|
|
766
|
+
if (St(n)) {
|
|
764
767
|
n.preventDefault(), n.stopPropagation();
|
|
765
768
|
const o = Q(r);
|
|
766
769
|
o ? S(r, e, "edit", void 0, o) : S(r, e, "insert");
|
|
767
770
|
return;
|
|
768
771
|
}
|
|
769
|
-
if (
|
|
772
|
+
if (Tt(n)) {
|
|
770
773
|
n.preventDefault(), n.stopPropagation();
|
|
771
774
|
const o = x.get(r) !== !0;
|
|
772
775
|
_(r, e, o);
|
|
@@ -776,17 +779,17 @@ function Tt(t) {
|
|
|
776
779
|
const r = n.target?.closest(C);
|
|
777
780
|
if (!r) return;
|
|
778
781
|
const e = r.closest(A);
|
|
779
|
-
if (!e ||
|
|
782
|
+
if (!e || R(e)) return;
|
|
780
783
|
const i = b.get(e) || z || t;
|
|
781
784
|
b.set(e, i), h = e, n.preventDefault(), n.stopPropagation(), r.focus({ preventScroll: !0 }), S(e, i, "edit", void 0, r);
|
|
782
785
|
}, document.addEventListener("click", M, !0));
|
|
783
786
|
}
|
|
784
|
-
function
|
|
787
|
+
function Lt() {
|
|
785
788
|
O && (document.removeEventListener("focusin", O, !0), O = null), P && (document.removeEventListener("keydown", P, !0), P = null), M && (document.removeEventListener("click", M, !0), M = null), z = null, h = null;
|
|
786
789
|
}
|
|
787
|
-
const
|
|
790
|
+
const Ct = (t = {}) => {
|
|
788
791
|
const n = ot(t);
|
|
789
|
-
return
|
|
792
|
+
return vt(), {
|
|
790
793
|
name: "dataBinding",
|
|
791
794
|
toolbar: [
|
|
792
795
|
{
|
|
@@ -813,7 +816,7 @@ const Lt = (t = {}) => {
|
|
|
813
816
|
commands: {
|
|
814
817
|
openDataBindingDialog: (a, r) => {
|
|
815
818
|
const e = D(r);
|
|
816
|
-
if (!e ||
|
|
819
|
+
if (!e || R(e)) return !1;
|
|
817
820
|
h = e;
|
|
818
821
|
const i = b.get(e) || n;
|
|
819
822
|
b.set(e, i), V(e, i);
|
|
@@ -825,7 +828,7 @@ const Lt = (t = {}) => {
|
|
|
825
828
|
},
|
|
826
829
|
insertDataBindingToken: async (a, r) => {
|
|
827
830
|
const e = D(r);
|
|
828
|
-
if (!e ||
|
|
831
|
+
if (!e || R(e)) return !1;
|
|
829
832
|
h = e;
|
|
830
833
|
const i = b.get(e) || n;
|
|
831
834
|
b.set(e, i);
|
|
@@ -840,7 +843,7 @@ const Lt = (t = {}) => {
|
|
|
840
843
|
},
|
|
841
844
|
editDataBindingToken: async (a, r) => {
|
|
842
845
|
const e = D(r);
|
|
843
|
-
if (!e ||
|
|
846
|
+
if (!e || R(e)) return !1;
|
|
844
847
|
h = e;
|
|
845
848
|
const i = b.get(e) || n;
|
|
846
849
|
b.set(e, i);
|
|
@@ -865,7 +868,7 @@ const Lt = (t = {}) => {
|
|
|
865
868
|
setDataBindingData: async (a, r) => {
|
|
866
869
|
const e = D(r);
|
|
867
870
|
if (!e) return !1;
|
|
868
|
-
if (h = e, a && typeof a == "object" ? (W.set(e, a),
|
|
871
|
+
if (h = e, a && typeof a == "object" ? (W.set(e, a), K.set(e, { timestamp: Date.now(), data: a })) : (W.delete(e), K.delete(e)), x.get(e) === !0) {
|
|
869
872
|
const i = b.get(e) || n;
|
|
870
873
|
await _(e, i, !0);
|
|
871
874
|
}
|
|
@@ -874,7 +877,7 @@ const Lt = (t = {}) => {
|
|
|
874
877
|
refreshDataBindings: async (a, r) => {
|
|
875
878
|
const e = D(r);
|
|
876
879
|
if (!e) return !1;
|
|
877
|
-
h = e,
|
|
880
|
+
h = e, K.delete(e);
|
|
878
881
|
const i = b.get(e) || n;
|
|
879
882
|
b.set(e, i);
|
|
880
883
|
const o = x.get(e) === !0;
|
|
@@ -892,7 +895,7 @@ const Lt = (t = {}) => {
|
|
|
892
895
|
init: function(r) {
|
|
893
896
|
U += 1;
|
|
894
897
|
const e = this && typeof this.__pluginConfig == "object" ? ot({ ...n, ...this.__pluginConfig }) : n;
|
|
895
|
-
|
|
898
|
+
$t(e);
|
|
896
899
|
const i = D(
|
|
897
900
|
r && r.editorElement ? { editorElement: r.editorElement } : void 0,
|
|
898
901
|
!1
|
|
@@ -904,10 +907,10 @@ const Lt = (t = {}) => {
|
|
|
904
907
|
}
|
|
905
908
|
},
|
|
906
909
|
destroy: () => {
|
|
907
|
-
U = Math.max(0, U - 1), U === 0 && (ft(),
|
|
910
|
+
U = Math.max(0, U - 1), U === 0 && (ft(), Lt());
|
|
908
911
|
}
|
|
909
912
|
};
|
|
910
913
|
};
|
|
911
914
|
export {
|
|
912
|
-
|
|
915
|
+
Ct as DataBindingPlugin
|
|
913
916
|
};
|
package/dist/direction.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l='.rte-content, .editora-content, [contenteditable="true"]',g="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",T=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","LI","BLOCKQUOTE","PRE","TABLE","FIGURE","UL","OL"]),d=e=>T.has(e.tagName)&&e.getAttribute("contenteditable")!=="true",m=e=>e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null,C=e=>{const n=e?.contentElement;if(n instanceof HTMLElement)return n;const t=e?.editorElement;if(t instanceof HTMLElement){const o=t.querySelector(l);if(o instanceof HTMLElement)return o;if(t.getAttribute("contenteditable")==="true")return t}const r=window.__editoraCommandEditorRoot;if(r instanceof HTMLElement){const o=r.querySelector(l);if(o instanceof HTMLElement)return o;if(r.getAttribute("contenteditable")==="true")return r}const i=window.getSelection();if(i&&i.rangeCount>0){const o=m(i.getRangeAt(0).startContainer),c=o?.closest(l);if(c instanceof HTMLElement)return c;const f=o?.closest(g)?.querySelector(l);if(f instanceof HTMLElement)return f}const a=document.activeElement,s=a instanceof HTMLElement?a.closest(l):null;return s instanceof HTMLElement?s:document.querySelector(l)},L=e=>{const n=window.getSelection();if(!n||n.rangeCount===0)return null;const t=n.getRangeAt(0);return!e.contains(t.startContainer)||!e.contains(t.endContainer)?null:t},R=(e,n)=>{let t=m(n);for(;t&&t!==e&&e.contains(t);){if(d(t))return t;t=t.parentElement}return d(e)?e:null},u=(e,n)=>{const t=R(e,n);if(!t||t===e)return null;const r=t.closest("li");return r instanceof HTMLElement&&e.contains(r)?r:t},h=(e,n)=>{if(typeof e.intersectsNode=="function")try{return e.intersectsNode(n)}catch{return!1}const t=document.createRange();return t.selectNode(n),e.compareBoundaryPoints(Range.END_TO_START,t)<0&&e.compareBoundaryPoints(Range.START_TO_END,t)>0},w=(e,n)=>{const t=[],r=new Set,i=o=>{!o||r.has(o)||o===n||!n.contains(o)||d(o)&&(r.add(o),t.push(o))};if(e.collapsed)return i(u(n,e.startContainer)),t;i(u(n,e.startContainer)),i(u(n,e.endContainer));const a=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const c=o;return!d(c)||c.closest("li")&&c.tagName!=="LI"?NodeFilter.FILTER_SKIP:h(e,c)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let s=a.nextNode();for(;s;)i(s),s=a.nextNode();return t.length===0&&i(u(n,e.commonAncestorContainer)),t.filter(o=>!t.some(c=>c!==o&&o.contains(c)))},p=(e,n,t)=>{if(n!==t){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",e,n,t);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:e,beforeHTML:n,afterHTML:t})}catch{}}},E=(e,n)=>{const t=C(n);if(!t)return!1;const r=L(t);if(!r)return!1;const i=w(r,t);if(i.length===0)return!1;const a=t.innerHTML;i.forEach(o=>{o.setAttribute("dir",e)});const s=t.innerHTML;return a===s?!1:(p(t,a,s),t.dispatchEvent(new window.Event("input",{bubbles:!0})),!0)},S=()=>({name:"direction",toolbar:[{label:"Left to Right",command:"setDirectionLTR",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M21 18H3M21 18L18 21M21 18L18 15M13 3V12M13 3H7M13 3C13.4596 3 13.9148 3.0776 14.3394 3.22836C14.764 3.37913 15.1499 3.6001 15.4749 3.87868C15.7999 4.15726 16.0577 4.48797 16.2336 4.85195C16.4095 5.21593 16.5 5.60603 16.5 6C16.5 6.39397 16.4095 6.78407 16.2336 7.14805C16.0577 7.51203 15.7999 7.84274 15.4749 8.12132C15.1499 8.3999 14.764 8.62087 14.3394 8.77164C13.9148 8.9224 13.4596 9 13 9V3ZM9 3V12" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-l"},{label:"Right to Left",command:"setDirectionRTL",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M3 18H21M3 18L6 21M3 18L6 15M11 12V3H17M15 3V12M10.5 3C10.0404 3 9.58525 3.0776 9.16061 3.22836C8.73597 3.37913 8.35013 3.6001 8.02513 3.87868C7.70012 4.15726 7.44231 4.48797 7.26642 4.85195C7.09053 5.21593 7 5.60603 7 6C7 6.39397 7.09053 6.78407 7.26642 7.14805C7.44231 7.51203 7.70012 7.84274 8.02513 8.12132C8.35013 8.3999 8.73597 8.62087 9.16061 8.77164C9.58525 8.9224 10.0404 9 10.5 9L10.5 3Z" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-r"}],commands:{setDirectionLTR:(e,n)=>{try{return E("ltr",n)}catch(t){return console.error("Failed to set LTR direction:",t),!1}},setDirectionRTL:(e,n)=>{try{return E("rtl",n)}catch(t){return console.error("Failed to set RTL direction:",t),!1}}},keymap:{"Mod-Shift-l":"setDirectionLTR","Mod-Shift-r":"setDirectionRTL"}});exports.DirectionPlugin=S;
|