@editora/plugins 1.0.9 → 1.0.10
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/README.md +5 -0
- package/dist/_commonjsHelpers-6763f629.js +1 -0
- package/dist/_commonjsHelpers-c5d32002.mjs +30 -0
- package/dist/a11y-checker.cjs.js +12 -12
- package/dist/a11y-checker.esm.js +98 -80
- package/dist/anchor.cjs.js +12 -12
- package/dist/anchor.esm.js +128 -115
- package/dist/anchoredPopover-33f1358d.mjs +109 -0
- package/dist/anchoredPopover-8151d535.js +1 -0
- package/dist/approval-workflow.cjs.js +40 -40
- package/dist/approval-workflow.esm.js +249 -208
- package/dist/background-color.cjs.js +2 -2
- package/dist/background-color.esm.js +68 -55
- package/dist/blockquote.esm.js +2 -1
- package/dist/blocks-library.cjs.js +45 -45
- package/dist/blocks-library.esm.js +245 -178
- package/dist/capitalization.esm.js +2 -1
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +82 -58
- package/dist/citations.cjs.js +37 -37
- package/dist/citations.esm.js +512 -439
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +33 -27
- package/dist/code-sample.cjs.js +14 -14
- package/dist/code-sample.esm.js +93 -82
- package/dist/code.cjs.js +32 -32
- package/dist/code.esm.js +653 -594
- package/dist/comments.cjs.js +6 -6
- package/dist/comments.esm.js +158 -116
- package/dist/conditional-content.cjs.js +90 -90
- package/dist/conditional-content.esm.js +432 -371
- package/dist/content-rules.cjs.js +7 -7
- package/dist/content-rules.esm.js +159 -105
- package/dist/data-binding.cjs.js +46 -46
- package/dist/data-binding.esm.js +368 -328
- package/dist/direction.esm.js +18 -9
- package/dist/doc-schema.cjs.js +29 -29
- package/dist/doc-schema.esm.js +308 -240
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +5 -4
- package/dist/documentManager-25b6203c.mjs +9122 -0
- package/dist/documentManager-b69e7054.js +17 -0
- package/dist/{editorContainerHelpers-C7kdWnS0.mjs → editorContainerHelpers-69585c07.mjs} +2 -1
- package/dist/embed-iframe.cjs.js +4 -4
- package/dist/embed-iframe.esm.js +81 -73
- package/dist/emojis.cjs.js +8 -8
- package/dist/emojis.esm.js +77 -65
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +56 -54
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +47 -39
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +53 -37
- package/dist/footnote.cjs.js +2 -2
- package/dist/footnote.esm.js +117 -76
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +92 -70
- package/dist/html2canvas.esm-09133e29.js +22 -0
- package/dist/{html2canvas.esm-BWVIUcAF.mjs → html2canvas.esm-1a1724a1.mjs} +225 -141
- package/dist/indent.cjs.js +1 -1
- package/dist/indent.esm.js +24 -12
- package/dist/index-656d224b.js +231 -0
- package/dist/index-6a8c48bb.js +1 -0
- package/dist/index-d027b7e2.mjs +16859 -0
- package/dist/{index-BFsKNTTj.mjs → index-f04538f2.mjs} +71 -70
- package/dist/index.cjs.js +1 -1
- package/dist/index.es-730f2d98.mjs +5775 -0
- package/dist/index.es-dd40173b.js +18 -0
- package/dist/index.esm.js +128 -125
- package/dist/italic.cjs.js +1 -1
- package/dist/italic.esm.js +9 -8
- package/dist/jspdf.es.min-90db2c97.js +243 -0
- package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-c36a4fd8.mjs} +4682 -3658
- package/dist/line-height.cjs.js +1 -1
- package/dist/line-height.esm.js +24 -11
- package/dist/link.cjs.js +5 -5
- package/dist/link.esm.js +30 -24
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +25 -20
- package/dist/lite.cjs.js +1 -1
- package/dist/lite.esm.js +61 -59
- package/dist/math.cjs.js +21 -21
- package/dist/math.esm.js +146 -139
- package/dist/media-manager.cjs.js +38 -38
- package/dist/media-manager.esm.js +325 -308
- package/dist/mentions.cjs.js +9 -9
- package/dist/mentions.esm.js +286 -238
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +216 -177
- package/dist/page-break.cjs.js +2 -2
- package/dist/page-break.esm.js +49 -33
- package/dist/pii-redaction.cjs.js +19 -19
- package/dist/pii-redaction.esm.js +463 -393
- package/dist/preview.esm.js +10 -5
- package/dist/print.cjs.js +4 -4
- package/dist/print.esm.js +20 -17
- package/dist/{purify.es-DHhaBdbu.mjs → purify.es-35a15df8.mjs} +19 -9
- package/dist/{purify.es-T2a3nLiC.js → purify.es-a8d731c6.js} +1 -1
- package/dist/slash-commands.cjs.js +3 -3
- package/dist/slash-commands.esm.js +212 -176
- package/dist/smart-paste.cjs.js +27 -27
- package/dist/smart-paste.esm.js +336 -280
- package/dist/special-characters.cjs.js +7 -7
- package/dist/special-characters.esm.js +69 -61
- package/dist/spell-check.cjs.js +5 -5
- package/dist/spell-check.esm.js +123 -97
- package/dist/strikethrough.cjs.js +1 -1
- package/dist/strikethrough.esm.js +19 -14
- package/dist/style.css +1 -0
- package/dist/table.cjs.js +4 -4
- package/dist/table.esm.js +225 -191
- package/dist/template.cjs.js +11 -11
- package/dist/template.esm.js +153 -124
- package/dist/text-alignment.cjs.js +1 -1
- package/dist/text-alignment.esm.js +27 -21
- package/dist/text-color.cjs.js +3 -3
- package/dist/text-color.esm.js +87 -70
- package/dist/track-changes.cjs.js +2 -2
- package/dist/track-changes.esm.js +162 -100
- package/dist/translation-workflow.cjs.js +74 -74
- package/dist/translation-workflow.esm.js +678 -602
- package/dist/version-diff.cjs.js +14 -14
- package/dist/version-diff.esm.js +157 -128
- package/package.json +13 -7
- package/LICENSE +0 -21
- package/dist/_commonjsHelpers-BH3jXuIh.js +0 -1
- package/dist/_commonjsHelpers-ByX85dGu.mjs +0 -33
- package/dist/anchoredPopover-BzqGPOAE.js +0 -1
- package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
- package/dist/documentManager-CTqRftU8.mjs +0 -8369
- package/dist/documentManager-Jf0RbSks.js +0 -17
- package/dist/html2canvas.esm-B5qzocYs.js +0 -5
- package/dist/index-CvJk4DKa.js +0 -221
- package/dist/index-D3CycEFU.mjs +0 -16543
- package/dist/index-tqLTHcO6.js +0 -1
- package/dist/index.es-CE_A4QSm.js +0 -5
- package/dist/index.es-DQ78mYYo.mjs +0 -6665
- package/dist/jspdf.es.min-BoS80556.js +0 -77
- package/dist/plugins.css +0 -1
- /package/dist/{editorContainerHelpers-CFbfiOJI.js → editorContainerHelpers-36b8ddf3.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=".rte-content, .editora-content",fe="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",ye="__editoraCommandEditorRoot",he="rte-blocks-library-styles",d="rte-blocks-library-panel",E="blocks-library",C="blocksLibrary",$=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Pe=80,Be=new Set(["script","style","meta","link","object","embed","iframe"]),De=/^(https?:|mailto:|tel:|#|\/)/i,Oe=/^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i,Ne={panelTitle:"Blocks Library",panelAriaLabel:"Blocks library panel",searchLabel:"Search blocks",searchPlaceholder:"Search by name, category, or keyword",categoryLabel:"Category",allCategoriesText:"All categories",recentHeading:"Recent inserts",insertText:"Insert Selected",closeText:"Close",noResultsText:"No matching blocks found.",summaryPrefix:"Blocks",loadingText:"Loading blocks...",loadErrorText:"Unable to load blocks right now.",readonlyMessage:"Editor is read-only. Block insertion is disabled.",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+B (panel), Ctrl/Cmd+Alt+Shift+L (insert last)",helperText:"Use Arrow keys to move through blocks, Enter to insert, Esc to close.",lastInsertedPrefix:"Last inserted",resultsListLabel:"Block results"},b=new WeakMap,J=new WeakMap,w=new WeakMap,I=new WeakMap,O=new WeakMap,j=new WeakMap,W=new WeakMap,z=new WeakMap,q=new WeakMap,te=new WeakMap,x=new Map,U=new WeakMap,oe=new Set;let X=0,Ke=0,ke=0,M=null,y=null,_=null,P=null,A=null,D=null;function m(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function je(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function We(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function ce(e){const t=e.trim();return t&&(De.test(t)||Oe.test(t))?t:""}function xe(e){let t=e;return Be.forEach(r=>{const o=new RegExp(`<${r}[\\s\\S]*?>[\\s\\S]*?<\\/${r}>`,"gi"),l=new RegExp(`<${r}\\b[^>]*\\/?>`,"gi");t=t.replace(o,"").replace(l,"")}),t=t.replace(/\son\w+=(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(xmlns|xml:[^=\s>]+)\s*=\s*(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("|\')\s*(?:javascript:|vbscript:|data:text\/html)[^"']*\2/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*(?:javascript:|vbscript:|data:text\/html)[^\s>]*/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("([^"]*)"|'([^']*)')/gi,(r,o,l,n,a)=>{const s=typeof n=="string"&&n.length>0?n:a||"",i=ce(s);if(!i)return"";const c=l.startsWith('"')?'"':"'";return` ${o}=${c}${i}${c}`}).replace(/\s(href|src|xlink:href)\s*=\s*([^\s>]+)/gi,(r,o,l)=>{const n=ce(l);return n?` ${o}="${n}"`:""}).replace(/\sstyle\s*=\s*("([^"]*)"|'([^']*)')/gi,(r,o,l,n)=>{const a=typeof l=="string"&&l.length>0?l:n||"";if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(a))return"";const s=o.startsWith('"')?'"':"'";return` style=${s}${a}${s}`}).trim(),t}function Fe(e){if(!e)return"";if(typeof document>"u")return xe(e);const t=document.createElement("template");t.innerHTML=e;const r=t.content;return!r||typeof r.querySelectorAll!="function"?xe(e):(Array.from(r.querySelectorAll("*")).forEach(l=>{const n=l.tagName.toLowerCase();if(Be.has(n)){l.remove();return}Array.from(l.attributes).forEach(s=>{const i=s.name.toLowerCase(),c=s.value;if(i.startsWith("on")){l.removeAttribute(s.name);return}if(i==="style"){/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(c)&&l.removeAttribute(s.name);return}if(i==="href"||i==="src"||i==="xlink:href"){const u=ce(c);if(!u){l.removeAttribute(s.name);return}u!==c&&l.setAttribute(s.name,u)}})}),t.innerHTML.trim())}function ne(e){return e.trim().toLowerCase()}function Ge(e){if(!e)return"";if(typeof document>"u")return e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();const t=document.createElement("template");t.innerHTML=e;const r=t.content;return!r||typeof r.textContent!="string"?e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim():r.textContent.replace(/\s+/g," ").trim()}function Ce(e,t){if(!Array.isArray(e)||e.length===0)return[];const r=new Set,o=[];return e.forEach(l=>{const n=t.normalizeText(l.label||""),a=t.sanitizeBlockHtml(l.html||"",l).trim();if(!n||!a)return;const s=t.normalizeText(l.category||"General")||"General",i=ne(s);let u=We(t.normalizeText(l.id||n))||`block-${ke++}`;for(;r.has(u);)u=`${u}-${ke++}`;r.add(u);const f=(l.tags||[]).map(H=>t.normalizeText(H)).filter(Boolean),g=(l.keywords||[]).map(H=>t.normalizeText(H)).filter(Boolean),h=t.normalizeText(l.description||""),R=Ge(a),V=[n,h,s,...f,...g,R].join(" ").toLowerCase();o.push({id:u,label:n,html:a,description:h,category:s,categoryKey:i,tags:f,keywords:g,previewText:R,searchBlob:V})}),o}function Q(e={}){const t=e.normalizeText||je,r=e.sanitizeBlockHtml||Fe,o={blocks:[],defaultCategory:t(e.defaultCategory||""),maxResults:Math.max(4,Math.min(300,Number(e.maxResults??80))),maxRecentBlocks:Math.max(1,Math.min(20,Number(e.maxRecentBlocks??6))),debounceMs:Math.max(0,Math.min(700,Number(e.debounceMs??90))),cacheTtlMs:Math.max(0,Number(e.cacheTtlMs??6e4)),labels:{...Ne,...e.labels||{}},normalizeText:t,sanitizeBlockHtml:r,getBlocks:typeof e.getBlocks=="function"?e.getBlocks:void 0};return o.blocks=Ce(e.blocks,o),o}function Ue(e){return{blocks:e.blocks.map(t=>({id:t.id,label:t.label,html:t.html,description:t.description||void 0,category:t.category||void 0,tags:t.tags.length?[...t.tags]:void 0,keywords:t.keywords.length?[...t.keywords]:void 0})),defaultCategory:e.defaultCategory,maxResults:e.maxResults,maxRecentBlocks:e.maxRecentBlocks,debounceMs:e.debounceMs,cacheTtlMs:e.cacheTtlMs,labels:{...e.labels},normalizeText:e.normalizeText,sanitizeBlockHtml:e.sanitizeBlockHtml,getBlocks:e.getBlocks}}function le(e){return e.closest(fe)||e}function G(e){if(!e)return null;if(e.matches(v))return e;const t=e.querySelector(v);return t instanceof HTMLElement?t:null}function Ve(){if(typeof window>"u")return null;const e=window[ye];if(!(e instanceof HTMLElement))return null;window[ye]=null;const t=G(e);if(t)return t;const r=e.closest(fe);if(r){const l=G(r);if(l)return l}const o=e.closest(v);return o instanceof HTMLElement?o:null}function Ye(e){const t=e.closest("[data-editora-editor]");if(t&&G(t)===e)return t;let r=e;for(;r;){if(r.matches(fe)&&(r===e||G(r)===e))return r;r=r.parentElement}return le(e)}function $e(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function ee(){Array.from(oe).forEach(t=>{t.isConnected||ge(t)})}function S(e,t=!0,r=!0){if(ee(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const a=G(e.editorElement);if(a)return a}const o=Ve();if(o)return o;const l=window.getSelection();if(l&&l.rangeCount>0){const s=$e(l.getRangeAt(0).startContainer)?.closest(v);if(s)return s}const n=document.activeElement;if(n){if(n.matches(v))return n;const a=n.closest(v);if(a)return a}if(r){if(y&&y.isConnected)return y;y&&!y.isConnected&&(y=null)}return t?document.querySelector(v):null}function Xe(e){const t=e.target;if(t){const o=t.closest(v);if(o)return o}const r=window.getSelection();if(r&&r.rangeCount>0){const l=$e(r.getRangeAt(0).startContainer)?.closest(v);if(l)return l}return null}function Z(e){return e?(e.getAttribute("data-theme")||e.getAttribute("theme")||"").toLowerCase()==="dark"?!0:e.classList.contains("dark")||e.classList.contains("editora-theme-dark")||e.classList.contains("rte-theme-dark"):!1}function Ze(e){const t=le(e);if(Z(t))return!0;const r=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Z(r)?!0:Z(document.documentElement)||Z(document.body)}function re(e,t){e.classList.remove("rte-blocks-library-theme-dark"),Ze(t)&&e.classList.add("rte-blocks-library-theme-dark")}function Se(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function we(e,t,r){const o=Ye(e);Array.from(o.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(n=>{n.classList.toggle("active",r),n.setAttribute("data-active",r?"true":"false"),n.setAttribute("aria-pressed",r?"true":"false")})}function Ee(e,t){const r=e.querySelector(".rte-blocks-library-live");r&&(r.textContent=t)}function se(e){const t=Re(e);if(t)try{q.set(e,t.cloneRange())}catch{}}function Te(e){const t=q.get(e);if(!t)return null;if(!e.isConnected)return q.delete(e),null;try{const r=t.cloneRange();return e.contains(r.commonAncestorContainer)?r:(q.delete(e),null)}catch{return q.delete(e),null}}function Je(e){const t=Te(e);return t?(He(e,t),!0):!1}function Qe(e){if(te.has(e))return;const t=()=>{const r=window.getSelection();if(!r||r.rangeCount===0)return;const o=r.getRangeAt(0);e.contains(o.commonAncestorContainer)&&se(e)};e.addEventListener("keyup",t),e.addEventListener("mouseup",t),e.addEventListener("touchend",t),te.set(e,t)}function et(e){const t=te.get(e);t&&(e.removeEventListener("keyup",t),e.removeEventListener("mouseup",t),e.removeEventListener("touchend",t),te.delete(e))}function k(e,t){b.has(e)||b.set(e,t),I.has(e)||(I.set(e,t.blocks),O.set(e,Date.now()));let r=w.get(e);return r||(r={query:"",category:t.defaultCategory?ne(t.defaultCategory):"all",selectedBlockId:null,recentBlockIds:[],lastInsertedBlockId:null,loading:!1,loadError:null,totalMatches:0,visibleMatches:0,filterCache:new Map,debounceTimer:null},w.set(e,r)),oe.add(e),Qe(e),r}function Me(e){const t=w.get(e);!t||t.debounceTimer===null||(window.clearTimeout(t.debounceTimer),t.debounceTimer=null)}function ge(e){Me(e),et(e),q.delete(e);const t=W.get(e);t&&(t.abort(),W.delete(e)),j.delete(e),z.delete(e),x.get(e)?.remove(),x.delete(e),U.delete(e),b.delete(e),J.delete(e),w.delete(e),I.delete(e),O.delete(e),oe.delete(e),y===e&&(y=null)}function tt(e){for(let t=0;t<e.length;t+=1){const r=e[t];if(!(r.type!=="childList"||r.removedNodes.length===0))for(let o=0;o<r.removedNodes.length;o+=1){const l=r.removedNodes[o];if(l.nodeType!==Node.ELEMENT_NODE)continue;const n=l;if(n.matches?.(v)||n.matches?.(`.${d}`)||n.querySelector?.(v)||n.querySelector?.(`.${d}`))return!0}}return!1}function pe(e){return U.get(e)===!0}function ue(e,t){if(!t.classList.contains("show"))return;const r=le(e).getBoundingClientRect(),o=Math.min(window.innerWidth-20,420),l=Math.max(10,window.innerWidth-o-10),n=Math.min(Math.max(10,r.right-o),l),a=Math.max(10,Math.min(window.innerHeight-10,r.top+12));t.style.width=`${o}px`,t.style.left=`${n}px`,t.style.top=`${a}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function ae(e){return I.get(e)||b.get(e)?.blocks||[]}function rt(e,t){const r=new Map;ae(e).forEach(l=>{r.has(l.categoryKey)||r.set(l.categoryKey,l.category)});const o=Array.from(r.entries()).sort((l,n)=>l[1].localeCompare(n[1])).map(([l,n])=>({value:l,label:n}));return[{value:"all",label:t.labels.allCategoriesText},...o]}function Ae(e,t){const r=k(e,t),o=ae(e),l=r.query.trim().toLowerCase(),n=r.category||"all",a=`${l}|${n}|${t.maxResults}`,s=r.filterCache.get(a);if(s){const u=new Map(o.map(g=>[g.id,g])),f=s.ids.map(g=>u.get(g)).filter(Boolean);return r.totalMatches=s.total,r.visibleMatches=f.length,f}const i=[];let c=0;for(let u=0;u<o.length;u+=1){const f=o[u];n!=="all"&&f.categoryKey!==n||l&&!f.searchBlob.includes(l)||(c+=1,i.length<t.maxResults&&i.push(f))}if(r.totalMatches=c,r.visibleMatches=i.length,r.filterCache.set(a,{ids:i.map(u=>u.id),total:c}),r.filterCache.size>Pe){const u=r.filterCache.keys().next().value;typeof u=="string"&&r.filterCache.delete(u)}return i}function ot(e,t){const r=w.get(e);if(!r)return;if(t.length===0){r.selectedBlockId=null;return}t.some(l=>l.id===r.selectedBlockId)||(r.selectedBlockId=t[0].id)}function N(e){const t=w.get(e);we(e,"toggleBlocksLibraryPanel",pe(e)),we(e,"insertLastBlockSnippet",!!t?.lastInsertedBlockId)}function L(e){const t=x.get(e),r=b.get(e)||M,o=w.get(e);if(!t||!r||!o)return;re(t,e);const l=t.querySelector(".rte-blocks-library-title");l&&(l.textContent=r.labels.panelTitle);const n=t.querySelector('[data-action="close"]');n&&(n.setAttribute("aria-label",r.labels.closeText),n.textContent="✕");const a=t.querySelector(".rte-blocks-library-search-label");a&&(a.textContent=r.labels.searchLabel);const s=t.querySelector('[data-field="query"]');s&&(s.setAttribute("placeholder",r.labels.searchPlaceholder),s.value!==o.query&&(s.value=o.query));const i=t.querySelector(".rte-blocks-library-category-label");i&&(i.textContent=r.labels.categoryLabel);const c=t.querySelector('[data-field="category"]');if(c){const B=rt(e,r);c.innerHTML=B.map(p=>`<option value="${m(p.value)}">${m(p.label)}</option>`).join(""),B.some(p=>p.value===o.category)||(o.category="all"),c.value=o.category}const u=t.querySelector(".rte-blocks-library-helper");u&&(u.textContent=r.labels.helperText);const f=t.querySelector('.rte-blocks-library-list[role="listbox"]');f&&f.setAttribute("aria-label",r.labels.resultsListLabel);const g=t.querySelector(".rte-blocks-library-shortcut");g&&(g.textContent=r.labels.shortcutText);const h=t.querySelector('[data-action="insert-selected"]');if(h){h.textContent=r.labels.insertText;const B=!Se(e)&&!!o.selectedBlockId;h.disabled=!B,h.setAttribute("aria-disabled",B?"false":"true")}const R=t.querySelector(".rte-blocks-library-empty"),V=t.querySelector(".rte-blocks-library-list"),H=Ae(e,r);ot(e,H);const Y=t.querySelector(".rte-blocks-library-status");if(Y&&(o.loading?Y.textContent=r.labels.loadingText:o.loadError?Y.textContent=o.loadError:Y.textContent=`${r.labels.summaryPrefix}: ${o.visibleMatches}/${o.totalMatches}`),V){const B=new Set(o.recentBlockIds);V.innerHTML=H.map(p=>{const ie=o.selectedBlockId===p.id,qe=p.tags.length?` • ${p.tags.join(", ")}`:"",_e=B.has(p.id),me=p.previewText.slice(0,180);return`
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=".rte-content, .editora-content",fe="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",ye="__editoraCommandEditorRoot",he="rte-blocks-library-styles",u="rte-blocks-library-panel",E="blocks-library",$="blocksLibrary",S=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',Pe=80,Be=new Set(["script","style","meta","link","object","embed","iframe"]),De=/^(https?:|mailto:|tel:|#|\/)/i,Oe=/^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i,Ne={panelTitle:"Blocks Library",panelAriaLabel:"Blocks library panel",searchLabel:"Search blocks",searchPlaceholder:"Search by name, category, or keyword",categoryLabel:"Category",allCategoriesText:"All categories",recentHeading:"Recent inserts",insertText:"Insert Selected",closeText:"Close",noResultsText:"No matching blocks found.",summaryPrefix:"Blocks",loadingText:"Loading blocks...",loadErrorText:"Unable to load blocks right now.",readonlyMessage:"Editor is read-only. Block insertion is disabled.",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+B (panel), Ctrl/Cmd+Alt+Shift+L (insert last)",helperText:"Use Arrow keys to move through blocks, Enter to insert, Esc to close.",lastInsertedPrefix:"Last inserted",resultsListLabel:"Block results"},b=new WeakMap,J=new WeakMap,w=new WeakMap,R=new WeakMap,O=new WeakMap,j=new WeakMap,W=new WeakMap,z=new WeakMap,q=new WeakMap,te=new WeakMap,x=new Map,U=new WeakMap,oe=new Set;let X=0,Ke=0,ke=0,A=null,y=null,_=null,P=null,I=null,D=null;function m(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function je(e){return e.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function We(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function ce(e){const t=e.trim();return t&&(De.test(t)||Oe.test(t))?t:""}function xe(e){let t=e;return Be.forEach(r=>{const o=new RegExp(`<${r}[\\s\\S]*?>[\\s\\S]*?<\\/${r}>`,"gi"),l=new RegExp(`<${r}\\b[^>]*\\/?>`,"gi");t=t.replace(o,"").replace(l,"")}),t=t.replace(/\son\w+=(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(xmlns|xml:[^=\s>]+)\s*=\s*(\"[^\"]*\"|'[^']*'|[^\s>]+)/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("|\')\s*(?:javascript:|vbscript:|data:text\/html)[^"']*\2/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*(?:javascript:|vbscript:|data:text\/html)[^\s>]*/gi,"").replace(/\s(href|src|xlink:href)\s*=\s*("([^"]*)"|'([^']*)')/gi,(r,o,l,n,a)=>{const s=typeof n=="string"&&n.length>0?n:a||"",i=ce(s);if(!i)return"";const c=l.startsWith('"')?'"':"'";return` ${o}=${c}${i}${c}`}).replace(/\s(href|src|xlink:href)\s*=\s*([^\s>]+)/gi,(r,o,l)=>{const n=ce(l);return n?` ${o}="${n}"`:""}).replace(/\sstyle\s*=\s*("([^"]*)"|'([^']*)')/gi,(r,o,l,n)=>{const a=typeof l=="string"&&l.length>0?l:n||"";if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(a))return"";const s=o.startsWith('"')?'"':"'";return` style=${s}${a}${s}`}).trim(),t}function Fe(e){if(!e)return"";if(typeof document>"u")return xe(e);const t=document.createElement("template");t.innerHTML=e;const r=t.content;return!r||typeof r.querySelectorAll!="function"?xe(e):(Array.from(r.querySelectorAll("*")).forEach(l=>{const n=l.tagName.toLowerCase();if(Be.has(n)){l.remove();return}Array.from(l.attributes).forEach(s=>{const i=s.name.toLowerCase(),c=s.value;if(i.startsWith("on")){l.removeAttribute(s.name);return}if(i==="style"){/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(c)&&l.removeAttribute(s.name);return}if(i==="href"||i==="src"||i==="xlink:href"){const d=ce(c);if(!d){l.removeAttribute(s.name);return}d!==c&&l.setAttribute(s.name,d)}})}),t.innerHTML.trim())}function ne(e){return e.trim().toLowerCase()}function Ge(e){if(!e)return"";if(typeof document>"u")return e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();const t=document.createElement("template");t.innerHTML=e;const r=t.content;return!r||typeof r.textContent!="string"?e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim():r.textContent.replace(/\s+/g," ").trim()}function Ce(e,t){if(!Array.isArray(e)||e.length===0)return[];const r=new Set,o=[];return e.forEach(l=>{const n=t.normalizeText(l.label||""),a=t.sanitizeBlockHtml(l.html||"",l).trim();if(!n||!a)return;const s=t.normalizeText(l.category||"General")||"General",i=ne(s);let d=We(t.normalizeText(l.id||n))||`block-${ke++}`;for(;r.has(d);)d=`${d}-${ke++}`;r.add(d);const f=(l.tags||[]).map(H=>t.normalizeText(H)).filter(Boolean),g=(l.keywords||[]).map(H=>t.normalizeText(H)).filter(Boolean),h=t.normalizeText(l.description||""),B=Ge(a),V=[n,h,s,...f,...g,B].join(" ").toLowerCase();o.push({id:d,label:n,html:a,description:h,category:s,categoryKey:i,tags:f,keywords:g,previewText:B,searchBlob:V})}),o}function Q(e={}){const t=e.normalizeText||je,r=e.sanitizeBlockHtml||Fe,o={blocks:[],defaultCategory:t(e.defaultCategory||""),maxResults:Math.max(4,Math.min(300,Number(e.maxResults??80))),maxRecentBlocks:Math.max(1,Math.min(20,Number(e.maxRecentBlocks??6))),debounceMs:Math.max(0,Math.min(700,Number(e.debounceMs??90))),cacheTtlMs:Math.max(0,Number(e.cacheTtlMs??6e4)),labels:{...Ne,...e.labels||{}},normalizeText:t,sanitizeBlockHtml:r,getBlocks:typeof e.getBlocks=="function"?e.getBlocks:void 0};return o.blocks=Ce(e.blocks,o),o}function Ue(e){return{blocks:e.blocks.map(t=>({id:t.id,label:t.label,html:t.html,description:t.description||void 0,category:t.category||void 0,tags:t.tags.length?[...t.tags]:void 0,keywords:t.keywords.length?[...t.keywords]:void 0})),defaultCategory:e.defaultCategory,maxResults:e.maxResults,maxRecentBlocks:e.maxRecentBlocks,debounceMs:e.debounceMs,cacheTtlMs:e.cacheTtlMs,labels:{...e.labels},normalizeText:e.normalizeText,sanitizeBlockHtml:e.sanitizeBlockHtml,getBlocks:e.getBlocks}}function le(e){return e.closest(fe)||e}function G(e){if(!e)return null;if(e.matches(v))return e;const t=e.querySelector(v);return t instanceof HTMLElement?t:null}function Ve(){if(typeof window>"u")return null;const e=window[ye];if(!(e instanceof HTMLElement))return null;window[ye]=null;const t=G(e);if(t)return t;const r=e.closest(fe);if(r){const l=G(r);if(l)return l}const o=e.closest(v);return o instanceof HTMLElement?o:null}function Ye(e){const t=e.closest("[data-editora-editor]");if(t&&G(t)===e)return t;let r=e;for(;r;){if(r.matches(fe)&&(r===e||G(r)===e))return r;r=r.parentElement}return le(e)}function $e(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function ee(){Array.from(oe).forEach(t=>{t.isConnected||ge(t)})}function T(e,t=!0,r=!0){if(ee(),(e==null?void 0:e.contentElement)instanceof HTMLElement)return e.contentElement;if((e==null?void 0:e.editorElement)instanceof HTMLElement){const a=G(e.editorElement);if(a)return a}const o=Ve();if(o)return o;const l=window.getSelection();if(l&&l.rangeCount>0){const a=$e(l.getRangeAt(0).startContainer),s=a==null?void 0:a.closest(v);if(s)return s}const n=document.activeElement;if(n){if(n.matches(v))return n;const a=n.closest(v);if(a)return a}if(r){if(y&&y.isConnected)return y;y&&!y.isConnected&&(y=null)}return t?document.querySelector(v):null}function Xe(e){const t=e.target;if(t){const o=t.closest(v);if(o)return o}const r=window.getSelection();if(r&&r.rangeCount>0){const o=$e(r.getRangeAt(0).startContainer),l=o==null?void 0:o.closest(v);if(l)return l}return null}function Z(e){return e?(e.getAttribute("data-theme")||e.getAttribute("theme")||"").toLowerCase()==="dark"?!0:e.classList.contains("dark")||e.classList.contains("editora-theme-dark")||e.classList.contains("rte-theme-dark"):!1}function Ze(e){const t=le(e);if(Z(t))return!0;const r=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return Z(r)?!0:Z(document.documentElement)||Z(document.body)}function re(e,t){e.classList.remove("rte-blocks-library-theme-dark"),Ze(t)&&e.classList.add("rte-blocks-library-theme-dark")}function Se(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function we(e,t,r){const o=Ye(e);Array.from(o.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(n=>{n.classList.toggle("active",r),n.setAttribute("data-active",r?"true":"false"),n.setAttribute("aria-pressed",r?"true":"false")})}function Ee(e,t){const r=e.querySelector(".rte-blocks-library-live");r&&(r.textContent=t)}function se(e){const t=Re(e);if(t)try{q.set(e,t.cloneRange())}catch{}}function Te(e){const t=q.get(e);if(!t)return null;if(!e.isConnected)return q.delete(e),null;try{const r=t.cloneRange();return e.contains(r.commonAncestorContainer)?r:(q.delete(e),null)}catch{return q.delete(e),null}}function Je(e){const t=Te(e);return t?(He(e,t),!0):!1}function Qe(e){if(te.has(e))return;const t=()=>{const r=window.getSelection();if(!r||r.rangeCount===0)return;const o=r.getRangeAt(0);e.contains(o.commonAncestorContainer)&&se(e)};e.addEventListener("keyup",t),e.addEventListener("mouseup",t),e.addEventListener("touchend",t),te.set(e,t)}function et(e){const t=te.get(e);t&&(e.removeEventListener("keyup",t),e.removeEventListener("mouseup",t),e.removeEventListener("touchend",t),te.delete(e))}function k(e,t){b.has(e)||b.set(e,t),R.has(e)||(R.set(e,t.blocks),O.set(e,Date.now()));let r=w.get(e);return r||(r={query:"",category:t.defaultCategory?ne(t.defaultCategory):"all",selectedBlockId:null,recentBlockIds:[],lastInsertedBlockId:null,loading:!1,loadError:null,totalMatches:0,visibleMatches:0,filterCache:new Map,debounceTimer:null},w.set(e,r)),oe.add(e),Qe(e),r}function Me(e){const t=w.get(e);!t||t.debounceTimer===null||(window.clearTimeout(t.debounceTimer),t.debounceTimer=null)}function ge(e){var r;Me(e),et(e),q.delete(e);const t=W.get(e);t&&(t.abort(),W.delete(e)),j.delete(e),z.delete(e),(r=x.get(e))==null||r.remove(),x.delete(e),U.delete(e),b.delete(e),J.delete(e),w.delete(e),R.delete(e),O.delete(e),oe.delete(e),y===e&&(y=null)}function tt(e){var t,r,o,l;for(let n=0;n<e.length;n+=1){const a=e[n];if(!(a.type!=="childList"||a.removedNodes.length===0))for(let s=0;s<a.removedNodes.length;s+=1){const i=a.removedNodes[s];if(i.nodeType!==Node.ELEMENT_NODE)continue;const c=i;if((t=c.matches)!=null&&t.call(c,v)||(r=c.matches)!=null&&r.call(c,`.${u}`)||(o=c.querySelector)!=null&&o.call(c,v)||(l=c.querySelector)!=null&&l.call(c,`.${u}`))return!0}}return!1}function pe(e){return U.get(e)===!0}function de(e,t){if(!t.classList.contains("show"))return;const r=le(e).getBoundingClientRect(),o=Math.min(window.innerWidth-20,420),l=Math.max(10,window.innerWidth-o-10),n=Math.min(Math.max(10,r.right-o),l),a=Math.max(10,Math.min(window.innerHeight-10,r.top+12));t.style.width=`${o}px`,t.style.left=`${n}px`,t.style.top=`${a}px`,t.style.maxHeight=`${Math.max(260,window.innerHeight-20)}px`}function ae(e){var t;return R.get(e)||((t=b.get(e))==null?void 0:t.blocks)||[]}function rt(e,t){const r=new Map;ae(e).forEach(l=>{r.has(l.categoryKey)||r.set(l.categoryKey,l.category)});const o=Array.from(r.entries()).sort((l,n)=>l[1].localeCompare(n[1])).map(([l,n])=>({value:l,label:n}));return[{value:"all",label:t.labels.allCategoriesText},...o]}function Ae(e,t){const r=k(e,t),o=ae(e),l=r.query.trim().toLowerCase(),n=r.category||"all",a=`${l}|${n}|${t.maxResults}`,s=r.filterCache.get(a);if(s){const d=new Map(o.map(g=>[g.id,g])),f=s.ids.map(g=>d.get(g)).filter(Boolean);return r.totalMatches=s.total,r.visibleMatches=f.length,f}const i=[];let c=0;for(let d=0;d<o.length;d+=1){const f=o[d];n!=="all"&&f.categoryKey!==n||l&&!f.searchBlob.includes(l)||(c+=1,i.length<t.maxResults&&i.push(f))}if(r.totalMatches=c,r.visibleMatches=i.length,r.filterCache.set(a,{ids:i.map(d=>d.id),total:c}),r.filterCache.size>Pe){const d=r.filterCache.keys().next().value;typeof d=="string"&&r.filterCache.delete(d)}return i}function ot(e,t){const r=w.get(e);if(!r)return;if(t.length===0){r.selectedBlockId=null;return}t.some(l=>l.id===r.selectedBlockId)||(r.selectedBlockId=t[0].id)}function N(e){const t=w.get(e);we(e,"toggleBlocksLibraryPanel",pe(e)),we(e,"insertLastBlockSnippet",!!(t!=null&&t.lastInsertedBlockId))}function L(e){const t=x.get(e),r=b.get(e)||A,o=w.get(e);if(!t||!r||!o)return;re(t,e);const l=t.querySelector(".rte-blocks-library-title");l&&(l.textContent=r.labels.panelTitle);const n=t.querySelector('[data-action="close"]');n&&(n.setAttribute("aria-label",r.labels.closeText),n.textContent="✕");const a=t.querySelector(".rte-blocks-library-search-label");a&&(a.textContent=r.labels.searchLabel);const s=t.querySelector('[data-field="query"]');s&&(s.setAttribute("placeholder",r.labels.searchPlaceholder),s.value!==o.query&&(s.value=o.query));const i=t.querySelector(".rte-blocks-library-category-label");i&&(i.textContent=r.labels.categoryLabel);const c=t.querySelector('[data-field="category"]');if(c){const C=rt(e,r);c.innerHTML=C.map(p=>`<option value="${m(p.value)}">${m(p.label)}</option>`).join(""),C.some(p=>p.value===o.category)||(o.category="all"),c.value=o.category}const d=t.querySelector(".rte-blocks-library-helper");d&&(d.textContent=r.labels.helperText);const f=t.querySelector('.rte-blocks-library-list[role="listbox"]');f&&f.setAttribute("aria-label",r.labels.resultsListLabel);const g=t.querySelector(".rte-blocks-library-shortcut");g&&(g.textContent=r.labels.shortcutText);const h=t.querySelector('[data-action="insert-selected"]');if(h){h.textContent=r.labels.insertText;const C=!Se(e)&&!!o.selectedBlockId;h.disabled=!C,h.setAttribute("aria-disabled",C?"false":"true")}const B=t.querySelector(".rte-blocks-library-empty"),V=t.querySelector(".rte-blocks-library-list"),H=Ae(e,r);ot(e,H);const Y=t.querySelector(".rte-blocks-library-status");if(Y&&(o.loading?Y.textContent=r.labels.loadingText:o.loadError?Y.textContent=o.loadError:Y.textContent=`${r.labels.summaryPrefix}: ${o.visibleMatches}/${o.totalMatches}`),V){const C=new Set(o.recentBlockIds);V.innerHTML=H.map(p=>{const ie=o.selectedBlockId===p.id,qe=p.tags.length?` • ${p.tags.join(", ")}`:"",_e=C.has(p.id),me=p.previewText.slice(0,180);return`
|
|
2
2
|
<li class="rte-blocks-library-item-wrapper" role="presentation">
|
|
3
3
|
<button
|
|
4
4
|
type="button"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
${me?`<span class="rte-blocks-library-item-preview">${m(me)}</span>`:""}
|
|
19
19
|
</button>
|
|
20
20
|
</li>
|
|
21
|
-
`}).join("")}
|
|
21
|
+
`}).join("")}B&&(B.hidden=H.length>0,B.textContent=r.labels.noResultsText);const K=t.querySelector(".rte-blocks-library-last-inserted");if(K)if(o.lastInsertedBlockId){const C=ae(e).find(p=>p.id===o.lastInsertedBlockId);C?(K.hidden=!1,K.textContent=`${r.labels.lastInsertedPrefix}: ${C.label}`):K.hidden=!0}else K.hidden=!0;t.setAttribute("aria-label",r.labels.panelAriaLabel)}function M(e,t=!1){const r=x.get(e);r&&(r.classList.remove("show"),U.set(e,!1),N(e),t&&(e.focus({preventScroll:!0}),Je(e)))}function nt(e){const t=e.querySelector(".rte-blocks-library-item.active");t==null||t.focus()}function ve(e,t){const r=b.get(e)||A;if(!r)return;const o=w.get(e);if(!o)return;const l=Ae(e,r);if(l.length===0)return;const a=(Math.max(0,l.findIndex(i=>i.id===o.selectedBlockId))+t+l.length)%l.length;o.selectedBlockId=l[a].id,L(e);const s=x.get(e);s&&nt(s)}function ue(e){const t=ct(e);se(e),x.forEach((o,l)=>{l!==e&&M(l,!1)}),t.classList.add("show"),U.set(e,!0),L(e),de(e,t),N(e);const r=t.querySelector('[data-field="query"]');r==null||r.focus(),be(e,!1)}function Ie(e,t){const r=pe(e);return(typeof t=="boolean"?t:!r)?ue(e):M(e,!1),!0}function Re(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);return e.contains(r.commonAncestorContainer)?r:null}function He(e,t){if(!e.isConnected)return;const r=window.getSelection();r&&(r.removeAllRanges(),r.addRange(t))}function Le(e,t,r){const o=t.cloneRange();if(!e.contains(o.commonAncestorContainer))return!1;o.deleteContents();const l=document.createElement("template");l.innerHTML=r;const n=l.content;if(!n)return!1;const a=n.lastChild;if(o.insertNode(n),a){const s=document.createRange();s.setStartAfter(a),s.collapse(!0),He(e,s)}return se(e),!0}function lt(e,t){e.focus({preventScroll:!0});const r=Te(e);if(r&&Le(e,r,t))return!0;try{if(document.execCommand("insertHTML",!1,t))return se(e),!0}catch{}const o=Re(e);return o?Le(e,o,t):!1}function st(e,t){if(t===e.innerHTML)return;const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{r("recordDomTransaction",e,t,e.innerHTML)}catch{}}function at(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function F(e,t){const r=b.get(e)||A;if(!r)return!1;const o=k(e,r),l=x.get(e);if(Se(e))return l&&Ee(l,r.labels.readonlyMessage),!1;const n=ae(e).find(i=>i.id===t);if(!n)return!1;const a=e.innerHTML;return lt(e,n.html)?(o.lastInsertedBlockId=n.id,o.selectedBlockId=n.id,o.recentBlockIds=[n.id,...o.recentBlockIds.filter(i=>i!==n.id)].slice(0,r.maxRecentBlocks),st(e,a),at(e),N(e),e.dispatchEvent(new CustomEvent("editora:blocks-library-insert",{bubbles:!0,detail:{blockId:n.id,label:n.label,category:n.category}})),L(e),l&&Ee(l,`${r.labels.lastInsertedPrefix}: ${n.label}`),!0):!1}function ze(e){const t=w.get(e);return t!=null&&t.lastInsertedBlockId?F(e,t.lastInsertedBlockId):!1}function it(e){const t=b.get(e)||A;if(!t)return;const r=w.get(e);if(!r)return;Me(e);const o=()=>{r.debounceTimer=null,r.filterCache.clear(),L(e)};if(t.debounceMs<=0){o();return}r.debounceTimer=window.setTimeout(o,t.debounceMs)}function ct(e){const t=x.get(e);if(t)return t;const r=b.get(e)||A||Q(),o=k(e,r),l=`rte-blocks-library-panel-${Ke++}`,n=`${l}-query`,a=`${l}-category`,s=document.createElement("section");return s.className=u,s.id=l,s.setAttribute("role","dialog"),s.setAttribute("aria-modal","false"),s.setAttribute("aria-label",r.labels.panelAriaLabel),s.innerHTML=`
|
|
22
22
|
<header class="rte-blocks-library-header">
|
|
23
23
|
<h2 class="rte-blocks-library-title">${m(r.labels.panelTitle)}</h2>
|
|
24
24
|
<button type="button" class="rte-blocks-library-icon-btn" data-action="close" aria-label="${m(r.labels.closeText)}">✕</button>
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
<p class="rte-blocks-library-shortcut"></p>
|
|
42
42
|
</div>
|
|
43
43
|
<div class="rte-blocks-library-live" aria-live="polite" aria-atomic="true"></div>
|
|
44
|
-
`,s.addEventListener("click",i=>{const c=i.target,
|
|
44
|
+
`,s.addEventListener("click",i=>{const c=i.target,d=c==null?void 0:c.closest("[data-action]");if(d){const h=d.getAttribute("data-action");if(h==="close"){M(e,!0);return}if(h==="insert-selected"){if(!o.selectedBlockId)return;F(e,o.selectedBlockId)&&M(e,!0)}return}const f=c==null?void 0:c.closest("[data-block-id]");if(!f)return;const g=f.getAttribute("data-block-id");g&&(o.selectedBlockId=g,L(e),i.detail>=2&&F(e,g)&&M(e,!0))}),s.addEventListener("input",i=>{const c=i.target;!(c instanceof HTMLInputElement)||c.getAttribute("data-field")!=="query"||(o.query=r.normalizeText(c.value).toLowerCase(),o.filterCache.clear(),it(e))}),s.addEventListener("change",i=>{const c=i.target;!(c instanceof HTMLSelectElement)||c.getAttribute("data-field")!=="category"||(o.category=ne(c.value||"all")||"all",o.filterCache.clear(),L(e))}),s.addEventListener("keydown",i=>{if(i.key==="Escape"){i.preventDefault(),M(e,!0);return}if(i.key==="ArrowDown"){i.preventDefault(),ve(e,1);return}if(i.key==="ArrowUp"){i.preventDefault(),ve(e,-1);return}if(i.key==="Enter"){const c=i.target;if(!(c==null?void 0:c.matches('[data-field="query"], [data-field="category"], [data-block-id]'))||!o.selectedBlockId)return;i.preventDefault(),F(e,o.selectedBlockId)&&M(e,!0)}}),re(s,e),document.body.appendChild(s),x.set(e,s),U.set(e,!1),L(e),s}function dt(e){const t=w.get(e);return{query:(t==null?void 0:t.query)||"",category:(t==null?void 0:t.category)||"all",selectedBlockId:(t==null?void 0:t.selectedBlockId)||null,totalMatches:(t==null?void 0:t.totalMatches)||0,visibleMatches:(t==null?void 0:t.visibleMatches)||0,recentBlockIds:t!=null&&t.recentBlockIds?[...t.recentBlockIds]:[],lastInsertedBlockId:(t==null?void 0:t.lastInsertedBlockId)||null,loading:(t==null?void 0:t.loading)===!0,loadError:(t==null?void 0:t.loadError)||null}}async function be(e,t){const r=b.get(e)||A;if(!r||typeof r.getBlocks!="function")return;const o=k(e,r),l=O.get(e)||0;if(!t&&r.cacheTtlMs>0&&Date.now()-l<r.cacheTtlMs)return;const n=j.get(e);if(n&&!t)return n;const a=W.get(e);a&&a.abort(),t&&n&&j.delete(e);const s=new AbortController;W.set(e,s);const i=(z.get(e)||0)+1;z.set(e,i),o.loading=!0,o.loadError=null,L(e);const c=Promise.resolve().then(async()=>{var B;const d={editor:e,editorRoot:le(e),signal:s.signal},f=await((B=r.getBlocks)==null?void 0:B.call(r,d));if(s.signal.aborted||z.get(e)!==i)return;const g=Ce(f||[],r);R.set(e,g),O.set(e,Date.now());const h=w.get(e);h&&(h.loading=!1,h.loadError=null,h.filterCache.clear())}).catch(()=>{if(s.signal.aborted||z.get(e)!==i)return;const d=w.get(e);d&&(d.loading=!1,d.loadError=r.labels.loadErrorText)}).finally(()=>{z.get(e)===i&&(j.delete(e),W.delete(e)),L(e)});return j.set(e,c),c}function ut(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="b"}function bt(e){const t=e.key.toLowerCase();return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="l"}function ft(e){A=e,_||(_=t=>{ee();const r=t.target,o=r==null?void 0:r.closest(v);if(!o)return;const l=b.get(o)||e;k(o,l),b.set(o,l),y=o,N(o);const n=x.get(o);n&&(re(n,o),de(o,n),L(o))},document.addEventListener("focusin",_,!0)),P||(P=t=>{if(t.defaultPrevented)return;const r=`.${u} input, .${u} textarea, .${u} select`,o=t.target;if(o!=null&&o.closest(r)){if(t.key==="Escape"){const a=o.closest(`.${u}`),s=Array.from(x.entries()).find(([,i])=>i===a);s&&(t.preventDefault(),M(s[0],!0))}return}const l=Xe(t);if(!l)return;const n=b.get(l)||A||e;if(k(l,n),b.set(l,n),y=l,t.key==="Escape"&&pe(l)){t.preventDefault(),M(l,!0);return}if(ut(t)){t.preventDefault(),t.stopPropagation(),Ie(l);return}bt(t)&&(t.preventDefault(),t.stopPropagation(),ze(l))},document.addEventListener("keydown",P,!0)),I||(I=()=>{ee(),x.forEach((t,r)=>{!r.isConnected||!t.isConnected||(re(t,r),de(r,t))})},window.addEventListener("scroll",I,!0),window.addEventListener("resize",I)),!D&&typeof MutationObserver<"u"&&document.body&&(D=new MutationObserver(t=>{tt(t)&&ee()}),D.observe(document.body,{childList:!0,subtree:!0}))}function gt(){_&&(document.removeEventListener("focusin",_,!0),_=null),P&&(document.removeEventListener("keydown",P,!0),P=null),I&&(window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I),I=null),D&&(D.disconnect(),D=null),x.forEach(t=>t.remove()),x.clear(),Array.from(oe).forEach(t=>ge(t)),A=null,y=null}function pt(){if(typeof document>"u"||document.getElementById(he))return;const e=document.createElement("style");e.id=he,e.textContent=`
|
|
45
45
|
.rte-toolbar-group-items.${E},
|
|
46
46
|
.editora-toolbar-group-items.${E},
|
|
47
|
-
.rte-toolbar-group-items.${
|
|
48
|
-
.editora-toolbar-group-items.${
|
|
47
|
+
.rte-toolbar-group-items.${$},
|
|
48
|
+
.editora-toolbar-group-items.${$} {
|
|
49
49
|
display: flex;
|
|
50
50
|
border: 1px solid #cbd5e1;
|
|
51
51
|
border-radius: 4px;
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
|
|
55
55
|
.rte-toolbar-group-items.${E} .rte-toolbar-button,
|
|
56
56
|
.editora-toolbar-group-items.${E} .editora-toolbar-button,
|
|
57
|
-
.rte-toolbar-group-items.${
|
|
58
|
-
.editora-toolbar-group-items.${
|
|
57
|
+
.rte-toolbar-group-items.${$} .rte-toolbar-button,
|
|
58
|
+
.editora-toolbar-group-items.${$} .editora-toolbar-button {
|
|
59
59
|
border: none;
|
|
60
60
|
border-right: 1px solid #cbd5e1;
|
|
61
61
|
border-radius: 0;
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
|
|
64
64
|
.rte-toolbar-group-items.${E} .rte-toolbar-item:last-child .rte-toolbar-button,
|
|
65
65
|
.editora-toolbar-group-items.${E} .editora-toolbar-item:last-child .editora-toolbar-button,
|
|
66
|
-
.rte-toolbar-group-items.${
|
|
67
|
-
.editora-toolbar-group-items.${
|
|
66
|
+
.rte-toolbar-group-items.${$} .rte-toolbar-item:last-child .rte-toolbar-button,
|
|
67
|
+
.editora-toolbar-group-items.${$} .editora-toolbar-item:last-child .editora-toolbar-button {
|
|
68
68
|
border-right: none;
|
|
69
69
|
}
|
|
70
70
|
|
|
@@ -73,25 +73,25 @@
|
|
|
73
73
|
background: rgba(15, 118, 110, 0.12);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
${
|
|
77
|
-
${
|
|
78
|
-
${
|
|
79
|
-
${
|
|
76
|
+
${S} .rte-toolbar-group-items.${E},
|
|
77
|
+
${S} .editora-toolbar-group-items.${E},
|
|
78
|
+
${S} .rte-toolbar-group-items.${$},
|
|
79
|
+
${S} .editora-toolbar-group-items.${$} {
|
|
80
80
|
border-color: #566275;
|
|
81
81
|
}
|
|
82
|
-
${
|
|
83
|
-
${
|
|
84
|
-
${
|
|
85
|
-
${
|
|
82
|
+
${S} .rte-toolbar-group-items.${E} .rte-toolbar-button svg,
|
|
83
|
+
${S} .editora-toolbar-group-items.${E} .editora-toolbar-button svg,
|
|
84
|
+
${S} .rte-toolbar-group-items.${$} .rte-toolbar-button svg,
|
|
85
|
+
${S} .editora-toolbar-group-items.${$} .editora-toolbar-button svg
|
|
86
86
|
{
|
|
87
87
|
fill: none;
|
|
88
88
|
}
|
|
89
|
-
${
|
|
90
|
-
${
|
|
89
|
+
${S} .rte-toolbar-group-items.${E} .rte-toolbar-button,
|
|
90
|
+
${S} .editora-toolbar-group-items.${E} .editora-toolbar-button
|
|
91
91
|
{
|
|
92
92
|
border-color: #566275;
|
|
93
93
|
}
|
|
94
|
-
.${
|
|
94
|
+
.${u} {
|
|
95
95
|
position: fixed;
|
|
96
96
|
z-index: 12000;
|
|
97
97
|
display: none;
|
|
@@ -105,12 +105,12 @@
|
|
|
105
105
|
overflow: hidden;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
.${
|
|
108
|
+
.${u}.show {
|
|
109
109
|
display: flex;
|
|
110
110
|
flex-direction: column;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
.${
|
|
113
|
+
.${u}.rte-blocks-library-theme-dark {
|
|
114
114
|
border-color: #334155;
|
|
115
115
|
background: #0f172a;
|
|
116
116
|
color: #e2e8f0;
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
.${
|
|
130
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-header {
|
|
131
131
|
border-color: #1e293b;
|
|
132
132
|
background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
|
|
133
133
|
}
|
|
@@ -165,14 +165,14 @@
|
|
|
165
165
|
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
.${
|
|
168
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-icon-btn {
|
|
169
169
|
border-color: #475569;
|
|
170
170
|
background: #0f172a;
|
|
171
171
|
color: #e2e8f0;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
.${
|
|
175
|
-
.${
|
|
174
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-icon-btn:hover,
|
|
175
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-icon-btn:focus-visible {
|
|
176
176
|
border-color: #60a5fa;
|
|
177
177
|
box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.24);
|
|
178
178
|
}
|
|
@@ -193,8 +193,8 @@
|
|
|
193
193
|
color: #334155;
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
.${
|
|
197
|
-
.${
|
|
196
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-search-label,
|
|
197
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-category-label {
|
|
198
198
|
color: #cbd5e1;
|
|
199
199
|
}
|
|
200
200
|
|
|
@@ -216,8 +216,8 @@
|
|
|
216
216
|
outline: none;
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
.${
|
|
220
|
-
.${
|
|
219
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-input,
|
|
220
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-select {
|
|
221
221
|
border-color: #334155;
|
|
222
222
|
background: #0b1220;
|
|
223
223
|
color: #e2e8f0;
|
|
@@ -238,13 +238,13 @@
|
|
|
238
238
|
color: #0f766e;
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
.${
|
|
242
|
-
.${
|
|
243
|
-
.${
|
|
241
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-status,
|
|
242
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-helper,
|
|
243
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-shortcut {
|
|
244
244
|
color: #94a3b8;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
.${
|
|
247
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-last-inserted {
|
|
248
248
|
color: #5eead4;
|
|
249
249
|
}
|
|
250
250
|
|
|
@@ -257,7 +257,7 @@
|
|
|
257
257
|
overflow: auto;
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
.${
|
|
260
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-list-wrap {
|
|
261
261
|
border-color: #334155;
|
|
262
262
|
background: #0b1220;
|
|
263
263
|
}
|
|
@@ -299,13 +299,13 @@
|
|
|
299
299
|
background: rgba(15, 118, 110, 0.12);
|
|
300
300
|
}
|
|
301
301
|
|
|
302
|
-
.${
|
|
302
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-item {
|
|
303
303
|
border-color: #334155;
|
|
304
304
|
background: #111827;
|
|
305
305
|
color: #e2e8f0;
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
-
.${
|
|
308
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-item.active {
|
|
309
309
|
border-color: #2dd4bf;
|
|
310
310
|
background: rgba(45, 212, 191, 0.15);
|
|
311
311
|
}
|
|
@@ -335,7 +335,7 @@
|
|
|
335
335
|
padding: 2px 6px;
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
.${
|
|
338
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-recent-pill {
|
|
339
339
|
color: #5eead4;
|
|
340
340
|
border-color: rgba(94, 234, 212, 0.45);
|
|
341
341
|
}
|
|
@@ -357,12 +357,12 @@
|
|
|
357
357
|
overflow: hidden;
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
-
.${
|
|
361
|
-
.${
|
|
360
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-item-meta,
|
|
361
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-item-description {
|
|
362
362
|
color: #94a3b8;
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
-
.${
|
|
365
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-item-preview {
|
|
366
366
|
color: #cbd5e1;
|
|
367
367
|
}
|
|
368
368
|
|
|
@@ -407,13 +407,13 @@
|
|
|
407
407
|
outline: none;
|
|
408
408
|
}
|
|
409
409
|
|
|
410
|
-
.${
|
|
410
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-btn {
|
|
411
411
|
border-color: #334155;
|
|
412
412
|
background: #111827;
|
|
413
413
|
color: #e2e8f0;
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
-
.${
|
|
416
|
+
.${u}.rte-blocks-library-theme-dark .rte-blocks-library-btn-primary {
|
|
417
417
|
border-color: #14b8a6;
|
|
418
418
|
background: #0f766e;
|
|
419
419
|
color: #f0fdfa;
|
|
@@ -431,7 +431,7 @@
|
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
@media (max-width: 768px) {
|
|
434
|
-
.${
|
|
434
|
+
.${u} {
|
|
435
435
|
left: 10px !important;
|
|
436
436
|
right: 10px;
|
|
437
437
|
top: 10px !important;
|
|
@@ -439,4 +439,4 @@
|
|
|
439
439
|
max-height: calc(100vh - 20px);
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
|
-
`,document.head.appendChild(e)}const mt=(e={})=>{const t=Q(e),r=new Set;return pt(),{name:"blocksLibrary",toolbar:[{id:"blocksLibraryGroup",label:"Blocks Library",type:"group",command:"blocksLibrary",items:[{id:"blocksLibraryPanel",label:"Blocks Library Panel",command:"toggleBlocksLibraryPanel",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="4" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"insertLastBlockSnippet",label:"Insert Last Block",command:"insertLastBlockSnippet",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M7 5.5h10a1.5 1.5 0 0 1 1.5 1.5v10A1.5 1.5 0 0 1 17 18.5H7A1.5 1.5 0 0 1 5.5 17V7A1.5 1.5 0 0 1 7 5.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M12 8.5v7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M8.5 12h7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'}]}],commands:{blocksLibrary:(o,l)=>{const n=
|
|
442
|
+
`,document.head.appendChild(e)}const mt=(e={})=>{const t=Q(e),r=new Set;return pt(),{name:"blocksLibrary",toolbar:[{id:"blocksLibraryGroup",label:"Blocks Library",type:"group",command:"blocksLibrary",items:[{id:"blocksLibraryPanel",label:"Blocks Library Panel",command:"toggleBlocksLibraryPanel",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="4" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="5" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="4" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/><rect x="13" y="13" width="7" height="6" rx="1.5" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"insertLastBlockSnippet",label:"Insert Last Block",command:"insertLastBlockSnippet",shortcut:"Mod-Alt-Shift-l",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M7 5.5h10a1.5 1.5 0 0 1 1.5 1.5v10A1.5 1.5 0 0 1 17 18.5H7A1.5 1.5 0 0 1 5.5 17V7A1.5 1.5 0 0 1 7 5.5Z" stroke="currentColor" stroke-width="1.6"/><path d="M12 8.5v7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M8.5 12h7" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'}]}],commands:{blocksLibrary:(o,l)=>{const n=T(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,ue(n),!0},openBlocksLibraryPanel:(o,l)=>{const n=T(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,ue(n),!0},toggleBlocksLibraryPanel:(o,l)=>{const n=T(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,Ie(n,typeof o=="boolean"?o:void 0)},insertBlockSnippet:(o,l)=>{const n=T(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;k(n,a),b.set(n,a);const s=typeof o=="string"?o:o==null?void 0:o.id;return s?(y=n,F(n,s)):!1},insertLastBlockSnippet:(o,l)=>{const n=T(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),y=n,ze(n)},refreshBlocksLibraryData:(o,l)=>{const n=T(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;return k(n,a),b.set(n,a),be(n,!0),!0},setBlocksLibraryOptions:(o,l)=>{const n=T(l,!1,!1);if(!n||!o||typeof o!="object")return!1;const a=b.get(n)||t,s=J.get(n)||Ue(a),i={...s,...o,labels:{...s.labels||{},...o.labels||{}},blocks:Array.isArray(o.blocks)?o.blocks:s.blocks,normalizeText:o.normalizeText||a.normalizeText,sanitizeBlockHtml:o.sanitizeBlockHtml||a.sanitizeBlockHtml,getBlocks:o.getBlocks||a.getBlocks},c=Q(i),d=Array.isArray(o.blocks),f=o.getBlocks!==void 0;b.set(n,c),J.set(n,i),(d||f||!R.has(n))&&(R.set(n,c.blocks),O.set(n,f?0:Date.now()));const g=k(n,c);return g.filterCache.clear(),typeof o.defaultCategory=="string"&&(g.category=ne(c.defaultCategory)||"all"),L(n),N(n),f&&be(n,!0),!0},getBlocksLibraryState:(o,l)=>{const n=T(l,!1,!1);if(!n)return!1;const a=b.get(n)||t;k(n,a);const s=dt(n);if(typeof o=="function")try{o(s)}catch{}return n.__blocksLibraryState=s,n.dispatchEvent(new CustomEvent("editora:blocks-library-state",{bubbles:!0,detail:s})),!0}},keymap:{"Mod-Alt-Shift-b":"toggleBlocksLibraryPanel","Mod-Alt-Shift-B":"toggleBlocksLibraryPanel","Mod-Alt-Shift-l":"insertLastBlockSnippet","Mod-Alt-Shift-L":"insertLastBlockSnippet"},init:function(l){X+=1;const n=this&&typeof this.__pluginConfig=="object"?{...e,...this.__pluginConfig}:e,a=Q(n);ft(a);const s=T(l!=null&&l.editorElement?{editorElement:l.editorElement}:void 0,!1,!1);s&&(y=s,r.add(s),k(s,a),b.set(s,a),J.set(s,n),R.set(s,a.blocks),O.set(s,Date.now()),N(s))},destroy:()=>{r.forEach(o=>ge(o)),r.clear(),X=Math.max(0,X-1),!(X>0)&>()}}};exports.BlocksLibraryPlugin=mt;
|