@editora/plugins 1.0.17 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{CodePlugin.native-Cqi46sxh.js → CodePlugin.native-Bwf25lLX.js} +6 -6
- package/dist/{CodePlugin.native-CmnEFfJi.mjs → CodePlugin.native-Cpp4u3Jl.mjs} +23 -21
- package/dist/a11y-checker.cjs.js +16 -16
- package/dist/a11y-checker.esm.js +79 -75
- package/dist/anchor.cjs.js +9 -9
- package/dist/anchor.esm.js +61 -60
- package/dist/anchoredPopover-Bg-ey7Yo.js +1 -0
- package/dist/anchoredPopover-D_JbjvdA.mjs +111 -0
- package/dist/approval-workflow.cjs.js +5 -5
- package/dist/approval-workflow.esm.js +105 -104
- package/dist/background-color.cjs.js +1 -1
- package/dist/background-color.esm.js +1 -1
- package/dist/blocks-library.cjs.js +6 -6
- package/dist/blocks-library.esm.js +226 -202
- package/dist/capitalization.cjs.js +1 -1
- package/dist/capitalization.esm.js +9 -4
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +154 -116
- package/dist/citations.cjs.js +43 -18
- package/dist/citations.esm.js +465 -446
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +21 -20
- package/dist/code-sample.cjs.js +85 -66
- package/dist/code-sample.esm.js +301 -190
- package/dist/code.cjs.js +1 -1
- package/dist/code.esm.js +1 -1
- package/dist/collaboration.cjs.js +68 -0
- package/dist/collaboration.esm.js +7428 -0
- package/dist/comments.cjs.js +11 -11
- package/dist/comments.esm.js +284 -237
- package/dist/conditional-content.cjs.js +67 -60
- package/dist/conditional-content.esm.js +270 -220
- package/dist/data-binding.cjs.js +3 -3
- package/dist/data-binding.esm.js +28 -27
- package/dist/dialogHelpers-5d5BuOCW.mjs +39 -0
- package/dist/dialogHelpers-zU6zpMIA.js +12 -0
- package/dist/document-manager.cjs.js +1 -1
- package/dist/document-manager.esm.js +1 -1
- package/dist/{documentManager-3nPkITwx.js → documentManager-BDz6tovy.js} +1 -1
- package/dist/{documentManager-CRumGpCT.mjs → documentManager-yjRBab4v.mjs} +1 -1
- package/dist/embed-iframe.cjs.js +37 -17
- package/dist/embed-iframe.esm.js +188 -143
- package/dist/emojis.cjs.js +13 -10
- package/dist/emojis.esm.js +288 -76
- package/dist/enterprise.cjs.js +1 -1
- package/dist/enterprise.esm.js +9 -7
- package/dist/escapeHtml-D2Zh82pD.js +1 -0
- package/dist/escapeHtml-DyksyvcZ.mjs +6 -0
- package/dist/font-family.cjs.js +1 -1
- package/dist/font-family.esm.js +48 -41
- package/dist/font-size.cjs.js +1 -1
- package/dist/font-size.esm.js +67 -60
- package/dist/format-painter.cjs.js +1 -1
- package/dist/format-painter.esm.js +2 -1
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +40 -36
- package/dist/historyHelpers-BEKwNOtA.mjs +14 -0
- package/dist/historyHelpers-Cu8Pk7m1.js +1 -0
- package/dist/index-Bm1eqYHh.mjs +194 -0
- package/dist/index-CoflqYuK.js +30 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +17 -15
- package/dist/link.cjs.js +17 -13
- package/dist/link.esm.js +138 -69
- package/dist/list.cjs.js +1 -1
- package/dist/list.esm.js +66 -33
- package/dist/math.cjs.js +22 -22
- package/dist/math.esm.js +221 -126
- package/dist/media-manager.cjs.js +12 -12
- package/dist/media-manager.esm.js +55 -50
- package/dist/mentions.cjs.js +2 -2
- package/dist/mentions.esm.js +17 -12
- package/dist/merge-tag.cjs.js +2 -2
- package/dist/merge-tag.esm.js +43 -42
- package/dist/plugins.css +1 -1
- package/dist/preview.cjs.js +3 -3
- package/dist/preview.esm.js +30 -27
- package/dist/slash-commands.cjs.js +13 -7
- package/dist/slash-commands.esm.js +90 -79
- package/dist/smart-paste.cjs.js +5 -5
- package/dist/smart-paste.esm.js +85 -81
- package/dist/special-characters.cjs.js +6 -3
- package/dist/special-characters.esm.js +72 -25
- package/dist/spell-check.cjs.js +8 -8
- package/dist/spell-check.esm.js +10189 -295
- package/dist/table.cjs.js +166 -13
- package/dist/table.esm.js +543 -266
- package/dist/template.cjs.js +11 -11
- package/dist/template.esm.js +290 -264
- package/dist/text-color.cjs.js +1 -1
- package/dist/text-color.esm.js +1 -1
- package/dist/translation-workflow.cjs.js +4 -4
- package/dist/translation-workflow.esm.js +33 -31
- package/dist/version-diff.cjs.js +6 -6
- package/dist/version-diff.esm.js +40 -40
- package/package.json +12 -5
- package/dist/anchoredPopover-BzqGPOAE.js +0 -1
- package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
- package/dist/index-CJ90EVWy.mjs +0 -145
- package/dist/index-DTkvH8gX.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function H(e,t){const o=Array.from({length:t}).map(()=>"<th><p><br></p></th>").join(""),n=Array.from({length:e}).map(()=>`<tr>${Array.from({length:t}).map(()=>"<td><p><br></p></td>").join("")}</tr>`).join("");return`<table class="rte-table"><thead><tr>${o}</tr></thead><tbody>${n}</tbody></table><p><br></p>`}function q(){return[{id:"paragraph",label:"Paragraph",description:"Switch to paragraph text",command:"paragraph",keywords:["text","normal","p"]},{id:"h1",label:"Heading 1",description:"Large section heading",command:"heading1",keywords:["title","header","h1"]},{id:"h2",label:"Heading 2",description:"Medium section heading",command:"heading2",keywords:["subtitle","header","h2"]},{id:"h3",label:"Heading 3",description:"Small section heading",command:"heading3",keywords:["header","h3"]},{id:"bulleted-list",label:"Bulleted List",description:"Create a bullet list",command:"toggleBulletList",keywords:["list","ul","bullet"]},{id:"numbered-list",label:"Numbered List",description:"Create a numbered list",command:"toggleOrderedList",keywords:["list","ol","numbered"]},{id:"blockquote",label:"Blockquote",description:"Insert a quote block",command:"toggleBlockquote",keywords:["quote","citation"]},{id:"table-3x3",label:"Table 3x3",description:"Insert a 3 x 3 table",action:({insertHTML:e})=>e(H(3,3)),keywords:["table","grid","rows","columns"]},{id:"horizontal-rule",label:"Divider",description:"Insert a horizontal rule",command:"insertHorizontalRule",keywords:["hr","separator","line"]},{id:"bold",label:"Bold",description:"Toggle bold formatting",command:"toggleBold",keywords:["strong","b"]},{id:"italic",label:"Italic",description:"Toggle italic formatting",command:"toggleItalic",keywords:["emphasis","i"]},{id:"underline",label:"Underline",description:"Toggle underline formatting",command:"toggleUnderline",keywords:["u"]},{id:"strikethrough",label:"Strikethrough",description:"Toggle strikethrough formatting",command:"toggleStrikethrough",keywords:["strike","s"]},{id:"clear-formatting",label:"Clear Formatting",description:"Remove text formatting",command:"clearFormatting",keywords:["reset","plain"]}]}function $(e){const t=[],o=new Set;return e.forEach(n=>{const r=String(n.id||"").trim(),i=String(n.label||"").trim();!r||!i||o.has(r)||(o.add(r),t.push({...n,id:r,label:i,description:n.description?String(n.description):void 0,keywords:Array.isArray(n.keywords)?n.keywords.map(a=>String(a)).filter(Boolean):void 0}))}),t}function D(e){const t=(e.triggerChar||"/")[0]||"/",o=e.includeDefaultItems!==!1,n=o?[...e.items||[],...q()]:e.items||[];return{triggerChar:t,minChars:Math.max(0,e.minChars??0),maxQueryLength:Math.max(1,e.maxQueryLength??48),maxSuggestions:Math.max(1,e.maxSuggestions??10),requireBoundary:e.requireBoundary!==!1,includeDefaultItems:o,items:$(n),itemRenderer:e.itemRenderer||(r=>r.label),emptyStateText:e.emptyStateText||"No commands found",panelLabel:e.panelLabel||"Slash commands"}}const u='[data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark';let
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function H(e,t){const o=Array.from({length:t}).map(()=>"<th><p><br></p></th>").join(""),n=Array.from({length:e}).map(()=>`<tr>${Array.from({length:t}).map(()=>"<td><p><br></p></td>").join("")}</tr>`).join("");return`<table class="rte-table"><thead><tr>${o}</tr></thead><tbody>${n}</tbody></table><p><br></p>`}function q(){return[{id:"paragraph",label:"Paragraph",description:"Switch to paragraph text",command:"paragraph",keywords:["text","normal","p"]},{id:"h1",label:"Heading 1",description:"Large section heading",command:"heading1",keywords:["title","header","h1"]},{id:"h2",label:"Heading 2",description:"Medium section heading",command:"heading2",keywords:["subtitle","header","h2"]},{id:"h3",label:"Heading 3",description:"Small section heading",command:"heading3",keywords:["header","h3"]},{id:"bulleted-list",label:"Bulleted List",description:"Create a bullet list",command:"toggleBulletList",keywords:["list","ul","bullet"]},{id:"numbered-list",label:"Numbered List",description:"Create a numbered list",command:"toggleOrderedList",keywords:["list","ol","numbered"]},{id:"blockquote",label:"Blockquote",description:"Insert a quote block",command:"toggleBlockquote",keywords:["quote","citation"]},{id:"table-3x3",label:"Table 3x3",description:"Insert a 3 x 3 table",action:({insertHTML:e})=>e(H(3,3)),keywords:["table","grid","rows","columns"]},{id:"horizontal-rule",label:"Divider",description:"Insert a horizontal rule",command:"insertHorizontalRule",keywords:["hr","separator","line"]},{id:"bold",label:"Bold",description:"Toggle bold formatting",command:"toggleBold",keywords:["strong","b"]},{id:"italic",label:"Italic",description:"Toggle italic formatting",command:"toggleItalic",keywords:["emphasis","i"]},{id:"underline",label:"Underline",description:"Toggle underline formatting",command:"toggleUnderline",keywords:["u"]},{id:"strikethrough",label:"Strikethrough",description:"Toggle strikethrough formatting",command:"toggleStrikethrough",keywords:["strike","s"]},{id:"clear-formatting",label:"Clear Formatting",description:"Remove text formatting",command:"clearFormatting",keywords:["reset","plain"]}]}function $(e){const t=[],o=new Set;return e.forEach(n=>{const r=String(n.id||"").trim(),i=String(n.label||"").trim();!r||!i||o.has(r)||(o.add(r),t.push({...n,id:r,label:i,description:n.description?String(n.description):void 0,keywords:Array.isArray(n.keywords)?n.keywords.map(a=>String(a)).filter(Boolean):void 0}))}),t}function D(e){const t=(e.triggerChar||"/")[0]||"/",o=e.includeDefaultItems!==!1,n=o?[...e.items||[],...q()]:e.items||[];return{triggerChar:t,minChars:Math.max(0,e.minChars??0),maxQueryLength:Math.max(1,e.maxQueryLength??48),maxSuggestions:Math.max(1,e.maxSuggestions??10),requireBoundary:e.requireBoundary!==!1,includeDefaultItems:o,items:$(n),itemRenderer:e.itemRenderer||(r=>r.label),emptyStateText:e.emptyStateText||"No commands found",panelLabel:e.panelLabel||"Slash commands"}}const u='[data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark';let v=!1;function B(){if(v||typeof document>"u")return;v=!0;const e=document.createElement("style");e.id="rte-slash-commands-styles",e.textContent=`
|
|
2
2
|
.rte-slash-panel {
|
|
3
3
|
width: min(225px, calc(100vw - 16px));
|
|
4
4
|
max-height: min(360px, calc(100vh - 24px));
|
|
@@ -64,27 +64,33 @@
|
|
|
64
64
|
padding: 12px;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
${u} .rte-slash-panel
|
|
67
|
+
${u} .rte-slash-panel,
|
|
68
|
+
.rte-slash-panel.rte-slash-theme-dark {
|
|
68
69
|
border-color: #364152;
|
|
69
70
|
background: #1f2937;
|
|
70
71
|
box-shadow: 0 22px 44px rgba(0, 0, 0, 0.48);
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
${u} .rte-slash-item
|
|
74
|
+
${u} .rte-slash-item,
|
|
75
|
+
.rte-slash-panel.rte-slash-theme-dark .rte-slash-item {
|
|
74
76
|
color: #e5e7eb;
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
${u} .rte-slash-item:hover,
|
|
78
|
-
${u} .rte-slash-item.active
|
|
80
|
+
${u} .rte-slash-item.active,
|
|
81
|
+
.rte-slash-panel.rte-slash-theme-dark .rte-slash-item:hover,
|
|
82
|
+
.rte-slash-panel.rte-slash-theme-dark .rte-slash-item.active {
|
|
79
83
|
background: #334155;
|
|
80
84
|
color: #bfdbfe;
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
${u} .rte-slash-item-description,
|
|
84
|
-
${u} .rte-slash-empty
|
|
88
|
+
${u} .rte-slash-empty,
|
|
89
|
+
.rte-slash-panel.rte-slash-theme-dark .rte-slash-item-description,
|
|
90
|
+
.rte-slash-panel.rte-slash-theme-dark .rte-slash-empty {
|
|
85
91
|
color: #9ca3af;
|
|
86
92
|
}
|
|
87
|
-
`,document.head.appendChild(e)}const
|
|
93
|
+
`,document.head.appendChild(e)}const c=".rte-content, .editora-content",z='[data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark',g=new WeakMap,p=new WeakMap;let b=!1,f=null,h=0,P=0;function _(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function I(e){return e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||e}function F(e){if(e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const n=e.editorElement;if(n.matches(c))return n;const r=n.querySelector(c);if(r instanceof HTMLElement)return r}const t=window.getSelection();if(t&&t.rangeCount>0){const n=t.getRangeAt(0).startContainer,i=(n.nodeType===Node.ELEMENT_NODE?n:n.parentElement)?.closest(c);if(i)return i}const o=document.activeElement;if(o){if(o.matches(c))return o;const n=o.closest(c);if(n)return n}return document.querySelector(c)}function m(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function j(e){return e?/\s|[([{"'`]/.test(e):!0}function E(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const o=t.getRangeAt(0);return e.contains(o.commonAncestorContainer)?o.cloneRange():null}function y(e,t){const o=window.getSelection();o&&(o.removeAllRanges(),o.addRange(t),e.focus({preventScroll:!0}))}function K(e){if(!e.collapsed)return null;const t=e.startContainer,o=e.startOffset;if(t.nodeType===Node.TEXT_NODE){const n=t;return{node:n,textBefore:n.data.slice(0,o),caretOffset:o}}if(t.nodeType===Node.ELEMENT_NODE){const n=t;if(o>0){const r=n.childNodes[o-1];if(r&&r.nodeType===Node.TEXT_NODE){const i=r;return{node:i,textBefore:i.data,caretOffset:i.length}}}}return null}function Q(e,t,o,n){const r=e.lastIndexOf(t);if(r<0||n&&!j(e[r-1]))return null;const i=e.slice(r+1);return/\s/.test(i)||i.length>o?null:{trigger:t,query:i,startOffset:r}}function U(e,t){const o=t.cloneRange();o.collapse(!1);const n=o.getClientRects();if(n.length>0)return n[n.length-1];const r=document.createElement("span");r.textContent="",o.insertNode(r);const i=r.getBoundingClientRect();return r.remove(),e.normalize(),i}function A(e,t){if(!e.panel)return;const o=U(e.editor,t),n=e.panel;n.classList.toggle("rte-slash-theme-dark",!!e.editor.closest(z)),n.style.display="block",n.classList.add("show"),n.style.left="0px",n.style.top="0px";const r=n.getBoundingClientRect(),i=window.innerWidth,a=window.innerHeight,l=Math.max(8,Math.min(o.left,i-r.width-8));let d=o.bottom+8;d+r.height>a-8&&(d=Math.max(8,o.top-r.height-8)),n.style.position="fixed",n.style.left=`${l}px`,n.style.top=`${d}px`}function k(e,t){if(!t)return m(e);const o=e.toLowerCase(),n=t.toLowerCase(),r=o.indexOf(n);if(r<0)return m(e);const i=m(e.slice(0,r)),a=m(e.slice(r,r+t.length)),l=m(e.slice(r+t.length));return`${i}<mark>${a}</mark>${l}`}function W(e,t){if(e.panel&&e.list)return;const o=document.createElement("div");o.className="rte-slash-panel",o.style.display="none",o.setAttribute("role","dialog"),o.setAttribute("aria-modal","false");const n=document.createElement("div");n.className="rte-slash-list",n.setAttribute("role","listbox"),n.setAttribute("aria-label",t.panelLabel),o.appendChild(n),document.body.appendChild(o),e.panel=o,e.list=n,o.addEventListener("mousedown",r=>{r.preventDefault()}),o.addEventListener("click",r=>{const i=r.target;if(!i)return;const a=i.closest(".rte-slash-item");if(!a)return;const l=Number(a.getAttribute("data-index"));Number.isFinite(l)&&M(e,l)})}function s(e){e.panel&&(e.panel.style.display="none",e.panel.classList.remove("show"),e.isOpen=!1,e.filteredItems=[],e.activeIndex=0,e.query="",e.replaceRange=null,e.anchorRange=null)}function Z(e,t,o){if(!t)return e.slice(0,o);const n=t.toLowerCase();return e.filter(i=>[i.id,i.label,i.description||"",i.command||"",...i.keywords||[]].join(" ").toLowerCase().includes(n)).slice(0,o)}function G(e,t){if(!e.list)return;const o=e.list;if(o.innerHTML="",e.filteredItems.length===0){const n=document.createElement("div");n.className="rte-slash-empty",n.textContent=t.emptyStateText,o.appendChild(n),o.removeAttribute("aria-activedescendant");return}e.filteredItems.forEach((n,r)=>{const i=document.createElement("button");i.type="button",i.className="rte-slash-item",i.setAttribute("role","option"),i.setAttribute("data-index",String(r)),i.setAttribute("id",`rte-slash-item-${e.instanceId}-${r}`),i.setAttribute("aria-selected",r===e.activeIndex?"true":"false"),i.setAttribute("aria-label",n.description?`${n.label} - ${n.description}`:n.label),r===e.activeIndex&&i.classList.add("active"),t.itemRenderer?i.innerHTML=t.itemRenderer(n,e.query):i.innerHTML=`
|
|
88
94
|
<span class="rte-slash-item-title">${k(n.label,e.query)}</span>
|
|
89
95
|
${n.description?`<span class="rte-slash-item-description">${k(n.description,e.query)}</span>`:""}
|
|
90
|
-
`,o.appendChild(i)}),e.filteredItems.length>0&&o.setAttribute("aria-activedescendant",`rte-slash-item-${e.instanceId}-${e.activeIndex}`)}function
|
|
96
|
+
`,o.appendChild(i)}),e.filteredItems.length>0&&o.setAttribute("aria-activedescendant",`rte-slash-item-${e.instanceId}-${e.activeIndex}`)}function V(e,t){if(t===e.innerHTML)return;const o=window.execEditorCommand||window.executeEditorCommand;if(typeof o=="function")try{o("recordDomTransaction",e,t,e.innerHTML)}catch{}}function X(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function L(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertHTML",!1,t))return!0}catch{}const o=window.getSelection();if(!o||o.rangeCount===0)return!1;const n=o.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return!1;n.deleteContents();const r=document.createElement("template");r.innerHTML=t;const i=r.content,a=i.lastChild;if(n.insertNode(i),a){const l=document.createRange();l.setStartAfter(a),l.collapse(!0),y(e,l)}return!0}function J(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertText",!1,t))return!0}catch{}const o=window.getSelection();if(!o||o.rangeCount===0)return!1;const n=o.getRangeAt(0);if(!e.contains(n.commonAncestorContainer))return!1;n.deleteContents();const r=document.createTextNode(t);n.insertNode(r);const i=document.createRange();return i.setStart(r,r.length),i.collapse(!0),y(e,i),!0}function Y(e,t){switch(e.toLowerCase()){case"paragraph":case"p":return document.execCommand("formatBlock",!1,"<p>");case"heading1":case"h1":return document.execCommand("formatBlock",!1,"<h1>");case"heading2":case"h2":return document.execCommand("formatBlock",!1,"<h2>");case"heading3":case"h3":return document.execCommand("formatBlock",!1,"<h3>");case"blockquote":case"toggleblockquote":return document.execCommand("formatBlock",!1,"<blockquote>");case"bulletlist":case"togglebulletlist":case"insertunorderedlist":return document.execCommand("insertUnorderedList");case"numberedlist":case"toggleorderedlist":case"insertorderedlist":return document.execCommand("insertOrderedList");case"horizontalrule":case"divider":case"inserthorizontalrule":return document.execCommand("insertHorizontalRule");case"bold":case"togglebold":return document.execCommand("bold");case"italic":case"toggleitalic":return document.execCommand("italic");case"underline":case"toggleunderline":return document.execCommand("underline");case"strikethrough":case"togglestrikethrough":return document.execCommand("strikeThrough");case"clearformatting":case"removeformat":return document.execCommand("removeFormat");default:try{return document.execCommand(e,!1,t)}catch{return!1}}}function S(e,t,o){const n=I(e);if(n&&typeof n.execCommand=="function")try{if(n.execCommand(t,o)!==!1)return!0}catch{}const r=window.execEditorCommand||window.executeEditorCommand;if(typeof r=="function")try{if(r(t,o,{editorElement:n,contentElement:e})!==!1)return!0}catch{}return Y(t,o)}async function ee(e,t){const o=e.editor,n=I(o),r={editor:o,editorRoot:n,query:e.query,trigger:e.trigger,executeCommand:(i,a)=>S(o,i,a),insertHTML:i=>L(o,i)};return t.action?await Promise.resolve(t.action(r))!==!1:t.insertHTML?L(o,t.insertHTML):t.command?S(o,t.command,t.commandValue):!1}async function M(e,t){if(t<0||t>=e.filteredItems.length||!e.replaceRange)return;const o=e.filteredItems[t],n=e.editor,r=n.innerHTML,i=`${e.trigger}${e.query}`;if(!window.getSelection())return;const l=e.replaceRange.cloneRange();if(!n.contains(l.commonAncestorContainer))return;l.deleteContents();const d=l.cloneRange();d.collapse(!0),y(n,d);let x=!1;try{x=await ee(e,o)}catch{x=!1}s(e),x?(X(n),V(n,r)):i&&J(n,i),n.focus({preventScroll:!0})}function R(e,t){if(e.filteredItems.length===0)return;const o=e.filteredItems.length;if(e.activeIndex=((e.activeIndex+t)%o+o)%o,!e.list)return;const n=Array.from(e.list.querySelectorAll(".rte-slash-item"));n.forEach((i,a)=>{const l=a===e.activeIndex;i.classList.toggle("active",l),i.setAttribute("aria-selected",l?"true":"false")});const r=n[e.activeIndex];r&&(e.list.setAttribute("aria-activedescendant",r.id),r.scrollIntoView({block:"nearest"}))}function T(e){if(!(!e.isOpen||!e.panel||!e.anchorRange)){if(!e.editor.isConnected){s(e);return}A(e,e.anchorRange)}}function N(e,t,o,n,r,i){W(e,t),e.query=n,e.trigger=r,e.replaceRange=i.cloneRange(),e.anchorRange=o.cloneRange(),e.filteredItems=Z(e.items,n,t.maxSuggestions),e.activeIndex=0,e.isOpen=!0,e.panel&&(G(e,t),A(e,o))}function te(e,t){const o=e.editor;if(o.getAttribute("contenteditable")==="false"){s(e);return}const n=E(o);if(!n||!n.collapsed){s(e);return}const r=K(n);if(!r){s(e);return}const i=Q(r.textBefore,t.triggerChar,t.maxQueryLength,t.requireBoundary);if(!i){s(e);return}if(i.query.length<t.minChars){s(e);return}if(e.dismissedNode===r.node&&e.dismissedOffset===i.startOffset)return;e.dismissedNode=null,e.dismissedOffset=-1;const a=n.cloneRange();a.setStart(r.node,i.startOffset),a.setEnd(r.node,r.caretOffset),N(e,t,n,i.query,i.trigger,a)}function O(e,t){const o=e.editor;if(o.getAttribute("contenteditable")==="false")return!1;let n=E(o);n||(n=document.createRange(),n.selectNodeContents(o),n.collapse(!1),y(o,n));const r=n.cloneRange();return r.collapse(!0),N(e,t,n,"",t.triggerChar,r),!0}function ne(e){return!(e.metaKey||e.ctrlKey)||e.altKey?!1:e.key==="/"||e.code==="Slash"}function re(e,t){return{editor:e,panel:null,list:null,replaceRange:null,items:t.items,filteredItems:[],activeIndex:0,query:"",trigger:t.triggerChar,isOpen:!1,instanceId:++P,anchorRange:null,dismissedNode:null,dismissedOffset:-1}}function w(e,t){const o=g.get(e);if(o)return o.items=t.items,o;const n=re(e,t);return g.set(e,n),n}function oe(e){const t=g.get(e);t&&(t.panel?.parentNode&&t.panel.parentNode.removeChild(t.panel),g.delete(e))}function C(e,t,o){if(p.has(e))return;const n={input:()=>{te(t,o)},keydown:r=>{if(t.editor.getAttribute("contenteditable")==="false"){s(t);return}if(!t.isOpen&&ne(r)){r.preventDefault(),O(t,o);return}if(t.isOpen){if(r.key==="ArrowDown"){r.preventDefault(),R(t,1);return}if(r.key==="ArrowUp"){r.preventDefault(),R(t,-1);return}if(r.key==="Enter"||r.key==="Tab"){if(t.filteredItems.length===0){r.key==="Tab"&&r.preventDefault(),s(t);return}r.preventDefault(),M(t,t.activeIndex);return}if(r.key==="Escape"){r.preventDefault(),t.replaceRange&&(t.dismissedNode=t.replaceRange.startContainer,t.dismissedOffset=t.replaceRange.startOffset),s(t);return}}},blur:()=>{window.setTimeout(()=>{const r=document.activeElement;t.panel&&r&&t.panel.contains(r)||s(t)},0)},mousedown:r=>{if(!t.isOpen||!t.panel)return;const i=r.target;i&&!t.panel.contains(i)&&!e.contains(i)&&s(t)},selectionchange:()=>{if(!t.isOpen)return;const r=E(e);if(!r||!r.collapsed){s(t);return}t.anchorRange=r.cloneRange(),T(t)},reposition:()=>{T(t)}};e.addEventListener("input",n.input),e.addEventListener("keydown",n.keydown),e.addEventListener("blur",n.blur),document.addEventListener("mousedown",n.mousedown,!0),document.addEventListener("selectionchange",n.selectionchange),window.addEventListener("resize",n.reposition,{passive:!0}),window.addEventListener("scroll",n.reposition,!0),p.set(e,n)}function ie(e){const t=p.get(e);t&&(e.removeEventListener("input",t.input),e.removeEventListener("keydown",t.keydown),e.removeEventListener("blur",t.blur),document.removeEventListener("mousedown",t.mousedown,!0),document.removeEventListener("selectionchange",t.selectionchange),window.removeEventListener("resize",t.reposition),window.removeEventListener("scroll",t.reposition,!0),p.delete(e))}function ae(e){b||(b=!0,f=t=>{const o=t.target;if(!(o instanceof Node))return;const r=_(o)?.closest(c)||null;if(!r)return;const i=w(r,e);C(r,i,e)},document.addEventListener("focusin",f,!0))}function le(){!b||!f||(document.removeEventListener("focusin",f,!0),b=!1,f=null)}const se=(e={})=>{B();const t=D(e);return{name:"slashCommands",toolbar:[{id:"slashCommands",label:"Slash Commands",command:"openSlashCommands",icon:'<svg width="24" height="24" focusable="false" aria-hidden="true"><path d="M8.7 20a1 1 0 0 1-.7-.3c-.4-.4-.4-1 0-1.4L15.6 5a1 1 0 0 1 1.4 1.4L9.4 19.7a1 1 0 0 1-.7.3Zm7.8 0c-.3 0-.5 0-.7-.3l-1.8-1.8a1 1 0 1 1 1.4-1.4l1.8 1.8a1 1 0 0 1-.7 1.7Zm-9-12a1 1 0 0 1-.7-1.7L8.6 4.5A1 1 0 1 1 10 6L8.2 7.8a1 1 0 0 1-.7.3Z"></path></svg>'}],commands:{openSlashCommands:(o,n)=>{const r=F(n);if(!r)return!1;const i=w(r,t);return C(r,i,t),O(i,t)}},keymap:{"Mod-/":"openSlashCommands","Mod-Shift-7":"openSlashCommands"},init:()=>{h+=1,ae(t),Array.from(document.querySelectorAll(c)).forEach(n=>{const r=w(n,t);C(n,r,t)})},destroy:()=>{h=Math.max(0,h-1),Array.from(document.querySelectorAll(c)).forEach(n=>{const r=g.get(n);r&&(s(r),ie(n),oe(n))}),h===0&&le()}}};exports.SlashCommandsPlugin=se;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function H(e, t) {
|
|
2
2
|
const o = Array.from({ length: t }).map(() => "<th><p><br></p></th>").join(""), n = Array.from({ length: e }).map(
|
|
3
3
|
() => `<tr>${Array.from({ length: t }).map(() => "<td><p><br></p></td>").join("")}</tr>`
|
|
4
4
|
).join("");
|
|
@@ -59,7 +59,7 @@ function q() {
|
|
|
59
59
|
id: "table-3x3",
|
|
60
60
|
label: "Table 3x3",
|
|
61
61
|
description: "Insert a 3 x 3 table",
|
|
62
|
-
action: ({ insertHTML: e }) => e(
|
|
62
|
+
action: ({ insertHTML: e }) => e(H(3, 3)),
|
|
63
63
|
keywords: ["table", "grid", "rows", "columns"]
|
|
64
64
|
},
|
|
65
65
|
{
|
|
@@ -206,31 +206,37 @@ function B() {
|
|
|
206
206
|
padding: 12px;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
${u} .rte-slash-panel
|
|
209
|
+
${u} .rte-slash-panel,
|
|
210
|
+
.rte-slash-panel.rte-slash-theme-dark {
|
|
210
211
|
border-color: #364152;
|
|
211
212
|
background: #1f2937;
|
|
212
213
|
box-shadow: 0 22px 44px rgba(0, 0, 0, 0.48);
|
|
213
214
|
}
|
|
214
215
|
|
|
215
|
-
${u} .rte-slash-item
|
|
216
|
+
${u} .rte-slash-item,
|
|
217
|
+
.rte-slash-panel.rte-slash-theme-dark .rte-slash-item {
|
|
216
218
|
color: #e5e7eb;
|
|
217
219
|
}
|
|
218
220
|
|
|
219
221
|
${u} .rte-slash-item:hover,
|
|
220
|
-
${u} .rte-slash-item.active
|
|
222
|
+
${u} .rte-slash-item.active,
|
|
223
|
+
.rte-slash-panel.rte-slash-theme-dark .rte-slash-item:hover,
|
|
224
|
+
.rte-slash-panel.rte-slash-theme-dark .rte-slash-item.active {
|
|
221
225
|
background: #334155;
|
|
222
226
|
color: #bfdbfe;
|
|
223
227
|
}
|
|
224
228
|
|
|
225
229
|
${u} .rte-slash-item-description,
|
|
226
|
-
${u} .rte-slash-empty
|
|
230
|
+
${u} .rte-slash-empty,
|
|
231
|
+
.rte-slash-panel.rte-slash-theme-dark .rte-slash-item-description,
|
|
232
|
+
.rte-slash-panel.rte-slash-theme-dark .rte-slash-empty {
|
|
227
233
|
color: #9ca3af;
|
|
228
234
|
}
|
|
229
235
|
`, document.head.appendChild(e);
|
|
230
236
|
}
|
|
231
|
-
const
|
|
232
|
-
let b = !1, f = null, h = 0,
|
|
233
|
-
function
|
|
237
|
+
const c = ".rte-content, .editora-content", z = '[data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark', g = /* @__PURE__ */ new WeakMap(), p = /* @__PURE__ */ new WeakMap();
|
|
238
|
+
let b = !1, f = null, h = 0, P = 0;
|
|
239
|
+
function _(e) {
|
|
234
240
|
return e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null;
|
|
235
241
|
}
|
|
236
242
|
function I(e) {
|
|
@@ -240,27 +246,27 @@ function F(e) {
|
|
|
240
246
|
if (e?.contentElement instanceof HTMLElement) return e.contentElement;
|
|
241
247
|
if (e?.editorElement instanceof HTMLElement) {
|
|
242
248
|
const n = e.editorElement;
|
|
243
|
-
if (n.matches(
|
|
244
|
-
const r = n.querySelector(
|
|
249
|
+
if (n.matches(c)) return n;
|
|
250
|
+
const r = n.querySelector(c);
|
|
245
251
|
if (r instanceof HTMLElement) return r;
|
|
246
252
|
}
|
|
247
253
|
const t = window.getSelection();
|
|
248
254
|
if (t && t.rangeCount > 0) {
|
|
249
|
-
const n = t.getRangeAt(0).startContainer, i = (n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(
|
|
255
|
+
const n = t.getRangeAt(0).startContainer, i = (n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(c);
|
|
250
256
|
if (i) return i;
|
|
251
257
|
}
|
|
252
258
|
const o = document.activeElement;
|
|
253
259
|
if (o) {
|
|
254
|
-
if (o.matches(
|
|
255
|
-
const n = o.closest(
|
|
260
|
+
if (o.matches(c)) return o;
|
|
261
|
+
const n = o.closest(c);
|
|
256
262
|
if (n) return n;
|
|
257
263
|
}
|
|
258
|
-
return document.querySelector(
|
|
264
|
+
return document.querySelector(c);
|
|
259
265
|
}
|
|
260
266
|
function m(e) {
|
|
261
267
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
262
268
|
}
|
|
263
|
-
function
|
|
269
|
+
function j(e) {
|
|
264
270
|
return e ? /\s|[([{"'`]/.test(e) : !0;
|
|
265
271
|
}
|
|
266
272
|
function E(e) {
|
|
@@ -273,7 +279,7 @@ function y(e, t) {
|
|
|
273
279
|
const o = window.getSelection();
|
|
274
280
|
o && (o.removeAllRanges(), o.addRange(t), e.focus({ preventScroll: !0 }));
|
|
275
281
|
}
|
|
276
|
-
function
|
|
282
|
+
function K(e) {
|
|
277
283
|
if (!e.collapsed) return null;
|
|
278
284
|
const t = e.startContainer, o = e.startOffset;
|
|
279
285
|
if (t.nodeType === Node.TEXT_NODE) {
|
|
@@ -300,9 +306,9 @@ function j(e) {
|
|
|
300
306
|
}
|
|
301
307
|
return null;
|
|
302
308
|
}
|
|
303
|
-
function
|
|
309
|
+
function Q(e, t, o, n) {
|
|
304
310
|
const r = e.lastIndexOf(t);
|
|
305
|
-
if (r < 0 || n && !
|
|
311
|
+
if (r < 0 || n && !j(e[r - 1]))
|
|
306
312
|
return null;
|
|
307
313
|
const i = e.slice(r + 1);
|
|
308
314
|
return /\s/.test(i) || i.length > o ? null : {
|
|
@@ -311,7 +317,7 @@ function K(e, t, o, n) {
|
|
|
311
317
|
startOffset: r
|
|
312
318
|
};
|
|
313
319
|
}
|
|
314
|
-
function
|
|
320
|
+
function U(e, t) {
|
|
315
321
|
const o = t.cloneRange();
|
|
316
322
|
o.collapse(!1);
|
|
317
323
|
const n = o.getClientRects();
|
|
@@ -324,10 +330,10 @@ function Q(e, t) {
|
|
|
324
330
|
}
|
|
325
331
|
function A(e, t) {
|
|
326
332
|
if (!e.panel) return;
|
|
327
|
-
const o =
|
|
328
|
-
n.style.display = "block", n.classList.add("show"), n.style.left = "0px", n.style.top = "0px";
|
|
329
|
-
const r = n.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight;
|
|
330
|
-
let
|
|
333
|
+
const o = U(e.editor, t), n = e.panel;
|
|
334
|
+
n.classList.toggle("rte-slash-theme-dark", !!e.editor.closest(z)), n.style.display = "block", n.classList.add("show"), n.style.left = "0px", n.style.top = "0px";
|
|
335
|
+
const r = n.getBoundingClientRect(), i = window.innerWidth, a = window.innerHeight, l = Math.max(8, Math.min(o.left, i - r.width - 8));
|
|
336
|
+
let d = o.bottom + 8;
|
|
331
337
|
d + r.height > a - 8 && (d = Math.max(8, o.top - r.height - 8)), n.style.position = "fixed", n.style.left = `${l}px`, n.style.top = `${d}px`;
|
|
332
338
|
}
|
|
333
339
|
function k(e, t) {
|
|
@@ -337,7 +343,7 @@ function k(e, t) {
|
|
|
337
343
|
const i = m(e.slice(0, r)), a = m(e.slice(r, r + t.length)), l = m(e.slice(r + t.length));
|
|
338
344
|
return `${i}<mark>${a}</mark>${l}`;
|
|
339
345
|
}
|
|
340
|
-
function
|
|
346
|
+
function W(e, t) {
|
|
341
347
|
if (e.panel && e.list) return;
|
|
342
348
|
const o = document.createElement("div");
|
|
343
349
|
o.className = "rte-slash-panel", o.style.display = "none", o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "false");
|
|
@@ -350,13 +356,13 @@ function U(e, t) {
|
|
|
350
356
|
const a = i.closest(".rte-slash-item");
|
|
351
357
|
if (!a) return;
|
|
352
358
|
const l = Number(a.getAttribute("data-index"));
|
|
353
|
-
Number.isFinite(l) &&
|
|
359
|
+
Number.isFinite(l) && N(e, l);
|
|
354
360
|
});
|
|
355
361
|
}
|
|
356
|
-
function
|
|
362
|
+
function s(e) {
|
|
357
363
|
e.panel && (e.panel.style.display = "none", e.panel.classList.remove("show"), e.isOpen = !1, e.filteredItems = [], e.activeIndex = 0, e.query = "", e.replaceRange = null, e.anchorRange = null);
|
|
358
364
|
}
|
|
359
|
-
function
|
|
365
|
+
function Z(e, t, o) {
|
|
360
366
|
if (!t) return e.slice(0, o);
|
|
361
367
|
const n = t.toLowerCase();
|
|
362
368
|
return e.filter((i) => [
|
|
@@ -367,7 +373,7 @@ function W(e, t, o) {
|
|
|
367
373
|
...i.keywords || []
|
|
368
374
|
].join(" ").toLowerCase().includes(n)).slice(0, o);
|
|
369
375
|
}
|
|
370
|
-
function
|
|
376
|
+
function G(e, t) {
|
|
371
377
|
if (!e.list) return;
|
|
372
378
|
const o = e.list;
|
|
373
379
|
if (o.innerHTML = "", e.filteredItems.length === 0) {
|
|
@@ -383,7 +389,7 @@ function Z(e, t) {
|
|
|
383
389
|
`, o.appendChild(i);
|
|
384
390
|
}), e.filteredItems.length > 0 && o.setAttribute("aria-activedescendant", `rte-slash-item-${e.instanceId}-${e.activeIndex}`);
|
|
385
391
|
}
|
|
386
|
-
function
|
|
392
|
+
function V(e, t) {
|
|
387
393
|
if (t === e.innerHTML) return;
|
|
388
394
|
const o = window.execEditorCommand || window.executeEditorCommand;
|
|
389
395
|
if (typeof o == "function")
|
|
@@ -392,7 +398,7 @@ function G(e, t) {
|
|
|
392
398
|
} catch {
|
|
393
399
|
}
|
|
394
400
|
}
|
|
395
|
-
function
|
|
401
|
+
function X(e) {
|
|
396
402
|
e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
397
403
|
}
|
|
398
404
|
function L(e, t) {
|
|
@@ -416,7 +422,7 @@ function L(e, t) {
|
|
|
416
422
|
}
|
|
417
423
|
return !0;
|
|
418
424
|
}
|
|
419
|
-
function
|
|
425
|
+
function J(e, t) {
|
|
420
426
|
e.focus({ preventScroll: !0 });
|
|
421
427
|
try {
|
|
422
428
|
if (document.execCommand("insertText", !1, t))
|
|
@@ -433,7 +439,7 @@ function X(e, t) {
|
|
|
433
439
|
const i = document.createRange();
|
|
434
440
|
return i.setStart(r, r.length), i.collapse(!0), y(e, i), !0;
|
|
435
441
|
}
|
|
436
|
-
function
|
|
442
|
+
function Y(e, t) {
|
|
437
443
|
switch (e.toLowerCase()) {
|
|
438
444
|
case "paragraph":
|
|
439
445
|
case "p":
|
|
@@ -501,9 +507,9 @@ function S(e, t, o) {
|
|
|
501
507
|
}) !== !1) return !0;
|
|
502
508
|
} catch {
|
|
503
509
|
}
|
|
504
|
-
return
|
|
510
|
+
return Y(t, o);
|
|
505
511
|
}
|
|
506
|
-
async function
|
|
512
|
+
async function ee(e, t) {
|
|
507
513
|
const o = e.editor, n = I(o), r = {
|
|
508
514
|
editor: o,
|
|
509
515
|
editorRoot: n,
|
|
@@ -514,7 +520,7 @@ async function Y(e, t) {
|
|
|
514
520
|
};
|
|
515
521
|
return t.action ? await Promise.resolve(t.action(r)) !== !1 : t.insertHTML ? L(o, t.insertHTML) : t.command ? S(o, t.command, t.commandValue) : !1;
|
|
516
522
|
}
|
|
517
|
-
async function
|
|
523
|
+
async function N(e, t) {
|
|
518
524
|
if (t < 0 || t >= e.filteredItems.length || !e.replaceRange) return;
|
|
519
525
|
const o = e.filteredItems[t], n = e.editor, r = n.innerHTML, i = `${e.trigger}${e.query}`;
|
|
520
526
|
if (!window.getSelection()) return;
|
|
@@ -525,11 +531,11 @@ async function M(e, t) {
|
|
|
525
531
|
d.collapse(!0), y(n, d);
|
|
526
532
|
let x = !1;
|
|
527
533
|
try {
|
|
528
|
-
x = await
|
|
534
|
+
x = await ee(e, o);
|
|
529
535
|
} catch {
|
|
530
536
|
x = !1;
|
|
531
537
|
}
|
|
532
|
-
|
|
538
|
+
s(e), x ? (X(n), V(n, r)) : i && J(n, i), n.focus({ preventScroll: !0 });
|
|
533
539
|
}
|
|
534
540
|
function R(e, t) {
|
|
535
541
|
if (e.filteredItems.length === 0) return;
|
|
@@ -546,61 +552,64 @@ function R(e, t) {
|
|
|
546
552
|
function T(e) {
|
|
547
553
|
if (!(!e.isOpen || !e.panel || !e.anchorRange)) {
|
|
548
554
|
if (!e.editor.isConnected) {
|
|
549
|
-
|
|
555
|
+
s(e);
|
|
550
556
|
return;
|
|
551
557
|
}
|
|
552
558
|
A(e, e.anchorRange);
|
|
553
559
|
}
|
|
554
560
|
}
|
|
555
|
-
function
|
|
556
|
-
|
|
561
|
+
function M(e, t, o, n, r, i) {
|
|
562
|
+
W(e, t), e.query = n, e.trigger = r, e.replaceRange = i.cloneRange(), e.anchorRange = o.cloneRange(), e.filteredItems = Z(e.items, n, t.maxSuggestions), e.activeIndex = 0, e.isOpen = !0, e.panel && (G(e, t), A(e, o));
|
|
557
563
|
}
|
|
558
|
-
function
|
|
564
|
+
function te(e, t) {
|
|
559
565
|
const o = e.editor;
|
|
560
566
|
if (o.getAttribute("contenteditable") === "false") {
|
|
561
|
-
|
|
567
|
+
s(e);
|
|
562
568
|
return;
|
|
563
569
|
}
|
|
564
570
|
const n = E(o);
|
|
565
571
|
if (!n || !n.collapsed) {
|
|
566
|
-
|
|
572
|
+
s(e);
|
|
567
573
|
return;
|
|
568
574
|
}
|
|
569
|
-
const r =
|
|
575
|
+
const r = K(n);
|
|
570
576
|
if (!r) {
|
|
571
|
-
|
|
577
|
+
s(e);
|
|
572
578
|
return;
|
|
573
579
|
}
|
|
574
|
-
const i =
|
|
580
|
+
const i = Q(
|
|
575
581
|
r.textBefore,
|
|
576
582
|
t.triggerChar,
|
|
577
583
|
t.maxQueryLength,
|
|
578
584
|
t.requireBoundary
|
|
579
585
|
);
|
|
580
586
|
if (!i) {
|
|
581
|
-
|
|
587
|
+
s(e);
|
|
582
588
|
return;
|
|
583
589
|
}
|
|
584
590
|
if (i.query.length < t.minChars) {
|
|
585
|
-
|
|
591
|
+
s(e);
|
|
586
592
|
return;
|
|
587
593
|
}
|
|
594
|
+
if (e.dismissedNode === r.node && e.dismissedOffset === i.startOffset)
|
|
595
|
+
return;
|
|
596
|
+
e.dismissedNode = null, e.dismissedOffset = -1;
|
|
588
597
|
const a = n.cloneRange();
|
|
589
|
-
a.setStart(r.node, i.startOffset), a.setEnd(r.node, r.caretOffset),
|
|
598
|
+
a.setStart(r.node, i.startOffset), a.setEnd(r.node, r.caretOffset), M(e, t, n, i.query, i.trigger, a);
|
|
590
599
|
}
|
|
591
|
-
function
|
|
600
|
+
function O(e, t) {
|
|
592
601
|
const o = e.editor;
|
|
593
602
|
if (o.getAttribute("contenteditable") === "false")
|
|
594
603
|
return !1;
|
|
595
604
|
let n = E(o);
|
|
596
605
|
n || (n = document.createRange(), n.selectNodeContents(o), n.collapse(!1), y(o, n));
|
|
597
606
|
const r = n.cloneRange();
|
|
598
|
-
return r.collapse(!0),
|
|
607
|
+
return r.collapse(!0), M(e, t, n, "", t.triggerChar, r), !0;
|
|
599
608
|
}
|
|
600
|
-
function
|
|
609
|
+
function ne(e) {
|
|
601
610
|
return !(e.metaKey || e.ctrlKey) || e.altKey ? !1 : e.key === "/" || e.code === "Slash";
|
|
602
611
|
}
|
|
603
|
-
function
|
|
612
|
+
function re(e, t) {
|
|
604
613
|
return {
|
|
605
614
|
editor: e,
|
|
606
615
|
panel: null,
|
|
@@ -612,18 +621,20 @@ function ne(e, t) {
|
|
|
612
621
|
query: "",
|
|
613
622
|
trigger: t.triggerChar,
|
|
614
623
|
isOpen: !1,
|
|
615
|
-
instanceId: ++
|
|
616
|
-
anchorRange: null
|
|
624
|
+
instanceId: ++P,
|
|
625
|
+
anchorRange: null,
|
|
626
|
+
dismissedNode: null,
|
|
627
|
+
dismissedOffset: -1
|
|
617
628
|
};
|
|
618
629
|
}
|
|
619
630
|
function w(e, t) {
|
|
620
631
|
const o = g.get(e);
|
|
621
632
|
if (o)
|
|
622
633
|
return o.items = t.items, o;
|
|
623
|
-
const n =
|
|
634
|
+
const n = re(e, t);
|
|
624
635
|
return g.set(e, n), n;
|
|
625
636
|
}
|
|
626
|
-
function
|
|
637
|
+
function oe(e) {
|
|
627
638
|
const t = g.get(e);
|
|
628
639
|
t && (t.panel?.parentNode && t.panel.parentNode.removeChild(t.panel), g.delete(e));
|
|
629
640
|
}
|
|
@@ -631,15 +642,15 @@ function C(e, t, o) {
|
|
|
631
642
|
if (p.has(e)) return;
|
|
632
643
|
const n = {
|
|
633
644
|
input: () => {
|
|
634
|
-
|
|
645
|
+
te(t, o);
|
|
635
646
|
},
|
|
636
647
|
keydown: (r) => {
|
|
637
648
|
if (t.editor.getAttribute("contenteditable") === "false") {
|
|
638
|
-
|
|
649
|
+
s(t);
|
|
639
650
|
return;
|
|
640
651
|
}
|
|
641
|
-
if (!t.isOpen &&
|
|
642
|
-
r.preventDefault(),
|
|
652
|
+
if (!t.isOpen && ne(r)) {
|
|
653
|
+
r.preventDefault(), O(t, o);
|
|
643
654
|
return;
|
|
644
655
|
}
|
|
645
656
|
if (t.isOpen) {
|
|
@@ -653,14 +664,14 @@ function C(e, t, o) {
|
|
|
653
664
|
}
|
|
654
665
|
if (r.key === "Enter" || r.key === "Tab") {
|
|
655
666
|
if (t.filteredItems.length === 0) {
|
|
656
|
-
r.key === "Tab" && r.preventDefault(),
|
|
667
|
+
r.key === "Tab" && r.preventDefault(), s(t);
|
|
657
668
|
return;
|
|
658
669
|
}
|
|
659
|
-
r.preventDefault(),
|
|
670
|
+
r.preventDefault(), N(t, t.activeIndex);
|
|
660
671
|
return;
|
|
661
672
|
}
|
|
662
673
|
if (r.key === "Escape") {
|
|
663
|
-
r.preventDefault(),
|
|
674
|
+
r.preventDefault(), t.replaceRange && (t.dismissedNode = t.replaceRange.startContainer, t.dismissedOffset = t.replaceRange.startOffset), s(t);
|
|
664
675
|
return;
|
|
665
676
|
}
|
|
666
677
|
}
|
|
@@ -668,19 +679,19 @@ function C(e, t, o) {
|
|
|
668
679
|
blur: () => {
|
|
669
680
|
window.setTimeout(() => {
|
|
670
681
|
const r = document.activeElement;
|
|
671
|
-
t.panel && r && t.panel.contains(r) ||
|
|
682
|
+
t.panel && r && t.panel.contains(r) || s(t);
|
|
672
683
|
}, 0);
|
|
673
684
|
},
|
|
674
685
|
mousedown: (r) => {
|
|
675
686
|
if (!t.isOpen || !t.panel) return;
|
|
676
687
|
const i = r.target;
|
|
677
|
-
i && !t.panel.contains(i) && !e.contains(i) &&
|
|
688
|
+
i && !t.panel.contains(i) && !e.contains(i) && s(t);
|
|
678
689
|
},
|
|
679
690
|
selectionchange: () => {
|
|
680
691
|
if (!t.isOpen) return;
|
|
681
692
|
const r = E(e);
|
|
682
693
|
if (!r || !r.collapsed) {
|
|
683
|
-
|
|
694
|
+
s(t);
|
|
684
695
|
return;
|
|
685
696
|
}
|
|
686
697
|
t.anchorRange = r.cloneRange(), T(t);
|
|
@@ -691,24 +702,24 @@ function C(e, t, o) {
|
|
|
691
702
|
};
|
|
692
703
|
e.addEventListener("input", n.input), e.addEventListener("keydown", n.keydown), e.addEventListener("blur", n.blur), document.addEventListener("mousedown", n.mousedown, !0), document.addEventListener("selectionchange", n.selectionchange), window.addEventListener("resize", n.reposition, { passive: !0 }), window.addEventListener("scroll", n.reposition, !0), p.set(e, n);
|
|
693
704
|
}
|
|
694
|
-
function
|
|
705
|
+
function ie(e) {
|
|
695
706
|
const t = p.get(e);
|
|
696
707
|
t && (e.removeEventListener("input", t.input), e.removeEventListener("keydown", t.keydown), e.removeEventListener("blur", t.blur), document.removeEventListener("mousedown", t.mousedown, !0), document.removeEventListener("selectionchange", t.selectionchange), window.removeEventListener("resize", t.reposition), window.removeEventListener("scroll", t.reposition, !0), p.delete(e));
|
|
697
708
|
}
|
|
698
|
-
function
|
|
709
|
+
function ae(e) {
|
|
699
710
|
b || (b = !0, f = (t) => {
|
|
700
711
|
const o = t.target;
|
|
701
712
|
if (!(o instanceof Node)) return;
|
|
702
|
-
const r =
|
|
713
|
+
const r = _(o)?.closest(c) || null;
|
|
703
714
|
if (!r) return;
|
|
704
715
|
const i = w(r, e);
|
|
705
716
|
C(r, i, e);
|
|
706
717
|
}, document.addEventListener("focusin", f, !0));
|
|
707
718
|
}
|
|
708
|
-
function
|
|
719
|
+
function le() {
|
|
709
720
|
!b || !f || (document.removeEventListener("focusin", f, !0), b = !1, f = null);
|
|
710
721
|
}
|
|
711
|
-
const
|
|
722
|
+
const se = (e = {}) => {
|
|
712
723
|
B();
|
|
713
724
|
const t = D(e);
|
|
714
725
|
return {
|
|
@@ -726,7 +737,7 @@ const le = (e = {}) => {
|
|
|
726
737
|
const r = F(n);
|
|
727
738
|
if (!r) return !1;
|
|
728
739
|
const i = w(r, t);
|
|
729
|
-
return C(r, i, t),
|
|
740
|
+
return C(r, i, t), O(i, t);
|
|
730
741
|
}
|
|
731
742
|
},
|
|
732
743
|
keymap: {
|
|
@@ -734,19 +745,19 @@ const le = (e = {}) => {
|
|
|
734
745
|
"Mod-Shift-7": "openSlashCommands"
|
|
735
746
|
},
|
|
736
747
|
init: () => {
|
|
737
|
-
h += 1,
|
|
748
|
+
h += 1, ae(t), Array.from(document.querySelectorAll(c)).forEach((n) => {
|
|
738
749
|
const r = w(n, t);
|
|
739
750
|
C(n, r, t);
|
|
740
751
|
});
|
|
741
752
|
},
|
|
742
753
|
destroy: () => {
|
|
743
|
-
h = Math.max(0, h - 1), Array.from(document.querySelectorAll(
|
|
754
|
+
h = Math.max(0, h - 1), Array.from(document.querySelectorAll(c)).forEach((n) => {
|
|
744
755
|
const r = g.get(n);
|
|
745
|
-
r && (
|
|
746
|
-
}), h === 0 &&
|
|
756
|
+
r && (s(r), ie(n), oe(n));
|
|
757
|
+
}), h === 0 && le();
|
|
747
758
|
}
|
|
748
759
|
};
|
|
749
760
|
};
|
|
750
761
|
export {
|
|
751
|
-
|
|
762
|
+
se as SlashCommandsPlugin
|
|
752
763
|
};
|