@editora/plugins 1.0.16 → 1.0.18
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-Bwf25lLX.js +460 -0
- package/dist/CodePlugin.native-Cpp4u3Jl.mjs +648 -0
- 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 -669
- package/dist/code.esm.js +2 -4560
- 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-Jf0RbSks.js → documentManager-BDz6tovy.js} +2 -2
- package/dist/{documentManager-CTqRftU8.mjs → documentManager-yjRBab4v.mjs} +3 -3
- 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-CxhJLMPS.js +221 -0
- package/dist/{index-D3CycEFU.mjs → index-Di1ZqIDs.mjs} +6420 -6232
- package/dist/index.cjs.js +1 -1
- package/dist/{index.es-DQ78mYYo.mjs → index.es-B7pVaNEV.mjs} +1558 -1542
- package/dist/{index.es-CE_A4QSm.js → index.es-I9N4o4Iq.js} +5 -5
- package/dist/index.esm.js +17 -15
- package/dist/{jspdf.es.min-BoS80556.js → jspdf.es.min-B5Idu0Wl.js} +2 -2
- package/dist/{jspdf.es.min-DQCoX5yh.mjs → jspdf.es.min-BCzHIwvz.mjs} +3 -2
- 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/{purify.es-T2a3nLiC.js → purify.es-DWpzYfqy.js} +1 -1
- package/dist/{purify.es-DHhaBdbu.mjs → purify.es-Dewe88eZ.mjs} +2 -2
- 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 +10 -4
- package/dist/anchoredPopover-BzqGPOAE.js +0 -1
- package/dist/anchoredPopover-Dts0IrgU.mjs +0 -106
- package/dist/index-BFsKNTTj.mjs +0 -145
- package/dist/index-CvJk4DKa.js +0 -221
- package/dist/index-tqLTHcO6.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f='.rte-content, .editora-content, [contenteditable="true"]',w="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",h=t=>t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null,v=t=>{const e=t?.contentElement;if(e instanceof HTMLElement)return e;const n=t?.editorElement;if(n instanceof HTMLElement){const s=n.querySelector(f);if(s instanceof HTMLElement)return s;if(n.getAttribute("contenteditable")==="true")return n}const r=window.__editoraCommandEditorRoot;if(r instanceof HTMLElement){const s=r.querySelector(f);if(s instanceof HTMLElement)return s;if(r.getAttribute("contenteditable")==="true")return r}const c=window.getSelection();if(c&&c.rangeCount>0){const s=h(c.getRangeAt(0).startContainer),i=s?.closest(f);if(i instanceof HTMLElement)return i;const a=s?.closest(w)?.querySelector(f);if(a instanceof HTMLElement)return a}const l=document.activeElement,u=l instanceof HTMLElement?l.closest(f):null;return u instanceof HTMLElement?u:document.querySelector(f)},R=t=>{const e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return null;const n=e.getRangeAt(0);return!t.contains(n.startContainer)||!t.contains(n.endContainer)?null:n},S=(t,e)=>{if(!e.data)return!1;if(typeof t.intersectsNode=="function")try{return t.intersectsNode(e)}catch{return!1}const n=document.createRange();return n.selectNodeContents(e),t.compareBoundaryPoints(Range.END_TO_START,n)<0&&t.compareBoundaryPoints(Range.START_TO_END,n)>0},
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f='.rte-content, .editora-content, [contenteditable="true"]',w="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",h=t=>t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null,v=t=>{const e=t?.contentElement;if(e instanceof HTMLElement)return e;const n=t?.editorElement;if(n instanceof HTMLElement){const s=n.querySelector(f);if(s instanceof HTMLElement)return s;if(n.getAttribute("contenteditable")==="true")return n}const r=window.__editoraCommandEditorRoot;if(r instanceof HTMLElement){const s=r.querySelector(f);if(s instanceof HTMLElement)return s;if(r.getAttribute("contenteditable")==="true")return r}const c=window.getSelection();if(c&&c.rangeCount>0){const s=h(c.getRangeAt(0).startContainer),i=s?.closest(f);if(i instanceof HTMLElement)return i;const a=s?.closest(w)?.querySelector(f);if(a instanceof HTMLElement)return a}const l=document.activeElement,u=l instanceof HTMLElement?l.closest(f):null;return u instanceof HTMLElement?u:document.querySelector(f)},R=t=>{const e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed)return null;const n=e.getRangeAt(0);return!t.contains(n.startContainer)||!t.contains(n.endContainer)?null:n},S=(t,e)=>{if(!e.data)return!1;if(typeof t.intersectsNode=="function")try{return t.intersectsNode(e)}catch{return!1}const n=document.createRange();return n.selectNodeContents(e),t.compareBoundaryPoints(Range.END_TO_START,n)<0&&t.compareBoundaryPoints(Range.START_TO_END,n)>0},L=(t,e)=>{const n=[],r=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let c=r.nextNode();for(;c;){const l=c;if(S(e,l)){const u=l===e.startContainer?e.startOffset:0,s=l===e.endContainer?e.endOffset:l.data.length;u<s&&n.push({node:l,start:u,end:s,text:l.data.slice(u,s)})}c=r.nextNode()}return n},_=t=>new RegExp("\\p{L}","u").test(t),x=t=>/[\p{M}'’-]/u.test(t),y=()=>{let t=!1;return e=>{let n="";return Array.from(e.text).forEach(r=>{if(_(r)){n+=t?r.toLocaleLowerCase():r.toLocaleUpperCase(),t=!0;return}n+=r,x(r)||(t=!1)}),n}},M=t=>{if(t.length===0)return;const e=t[0],n=t[t.length-1],r=window.getSelection();if(!r)return;const c=document.createRange();c.setStart(e.node,e.start),c.setEnd(n.node,n.end),r.removeAllRanges(),r.addRange(c)},b=(t,e,n)=>{if(e!==n){if(typeof window.execEditorCommand=="function"){window.execEditorCommand("recordDomTransaction",t,e,n);return}if(typeof window.executeEditorCommand=="function")try{window.executeEditorCommand("recordDomTransaction",{editor:t,beforeHTML:e,afterHTML:n})}catch{}}},H=()=>{const t=(i,o)=>{try{const a=v(o);if(!a)return!1;const m=R(a);if(!m)return!1;const p=L(a,m);if(p.length===0)return!1;const C=a.innerHTML;p.forEach((d,T)=>{const E=i(d,T);d.node.replaceData(d.start,d.end-d.start,E),d.end=d.start+E.length});const g=a.innerHTML;return C===g?!1:(b(a,C,g),a.dispatchEvent(new window.Event("input",{bubbles:!0})),M(p),!0)}catch(a){return console.error("Failed to transform capitalization:",a),!1}},e=(i,o)=>t(a=>a.text.toLocaleUpperCase(),o),n=(i,o)=>t(a=>a.text.toLocaleLowerCase(),o),r=(i,o)=>t(y(),o),c=(i,o)=>{if(!i)return!1;switch(i){case"uppercase":return e(void 0,o);case"lowercase":return n(void 0,o);case"titlecase":return r(void 0,o);default:return!1}},l=(i,o)=>typeof i=="string"?{value:i,context:o}:typeof o=="string"?{value:o}:{value:void 0,context:o},u=(i,o)=>{if(o&&typeof o=="object"&&!o.doc)return o},s=i=>(o,a)=>i(void 0,u(o,a));return{name:"capitalization",toolbar:[{label:"Capitalization",command:"setCapitalization",type:"inline-menu",options:[{label:"lowercase",value:"lowercase"},{label:"UPPERCASE",value:"uppercase"},{label:"Title Case",value:"titlecase"}],icon:'<svg fill="#000000" width="24" height="24" viewBox="0 0 32.00 32.00" id="icon" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC" stroke-width="0.192"></g><g id="SVGRepo_iconCarrier"><title>letter--Aa</title><path d="M23,13H18v2h5v2H19a2,2,0,0,0-2,2v2a2,2,0,0,0,2,2h6V15A2,2,0,0,0,23,13Zm0,8H19V19h4Z"></path><path d="M13,9H9a2,2,0,0,0-2,2V23H9V18h4v5h2V11A2,2,0,0,0,13,9ZM9,16V11h4v5Z"></path><rect id="_Transparent_Rectangle_" data-name="<Transparent Rectangle>" fill="none" width="32" height="32"></rect></g></svg>'}],commands:{setCapitalization:(i,o)=>{const{value:a,context:m}=l(i,o);return c(a,m)},toUpperCase:s(e),toLowerCase:s(n),toTitleCase:s(r)},keymap:{"Mod-Shift-u":"toUpperCase","Mod-Shift-k":"toLowerCase","Mod-Shift-t":"toTitleCase"}}};exports.CapitalizationPlugin=H;
|
|
@@ -54,7 +54,7 @@ const f = '.rte-content, .editora-content, [contenteditable="true"]', w = "[data
|
|
|
54
54
|
c = r.nextNode();
|
|
55
55
|
}
|
|
56
56
|
return n;
|
|
57
|
-
}, x = (t) => new RegExp("\\p{L}", "u").test(t),
|
|
57
|
+
}, x = (t) => new RegExp("\\p{L}", "u").test(t), _ = (t) => /[\p{M}'’-]/u.test(t), y = () => {
|
|
58
58
|
let t = !1;
|
|
59
59
|
return (e) => {
|
|
60
60
|
let n = "";
|
|
@@ -63,7 +63,7 @@ const f = '.rte-content, .editora-content, [contenteditable="true"]', w = "[data
|
|
|
63
63
|
n += t ? r.toLocaleLowerCase() : r.toLocaleUpperCase(), t = !0;
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
|
-
n += r,
|
|
66
|
+
n += r, _(r) || (t = !1);
|
|
67
67
|
}), n;
|
|
68
68
|
};
|
|
69
69
|
}, M = (t) => {
|
|
@@ -103,7 +103,7 @@ const f = '.rte-content, .editora-content, [contenteditable="true"]', w = "[data
|
|
|
103
103
|
} catch (a) {
|
|
104
104
|
return console.error("Failed to transform capitalization:", a), !1;
|
|
105
105
|
}
|
|
106
|
-
}, e = (i, o) => t((a) => a.text.toLocaleUpperCase(), o), n = (i, o) => t((a) => a.text.toLocaleLowerCase(), o), r = (i, o) => t(
|
|
106
|
+
}, e = (i, o) => t((a) => a.text.toLocaleUpperCase(), o), n = (i, o) => t((a) => a.text.toLocaleLowerCase(), o), r = (i, o) => t(y(), o), c = (i, o) => {
|
|
107
107
|
if (!i) return !1;
|
|
108
108
|
switch (i) {
|
|
109
109
|
case "uppercase":
|
|
@@ -134,7 +134,12 @@ const f = '.rte-content, .editora-content, [contenteditable="true"]', w = "[data
|
|
|
134
134
|
{ label: "UPPERCASE", value: "uppercase" },
|
|
135
135
|
{ label: "Title Case", value: "titlecase" }
|
|
136
136
|
],
|
|
137
|
-
|
|
137
|
+
// Inlined fill="none" on the bounding rect instead of the upstream
|
|
138
|
+
// SVGRepo export's class-based <defs><style>.cls-1{...}</style>
|
|
139
|
+
// block - that style tag applies document-wide once inserted via
|
|
140
|
+
// raw innerHTML into light-DOM toolbar content, so it can collide
|
|
141
|
+
// with any other icon reusing the same auto-generated class name.
|
|
142
|
+
icon: '<svg fill="#000000" width="24" height="24" viewBox="0 0 32.00 32.00" id="icon" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round" stroke="#CCCCCC" stroke-width="0.192"></g><g id="SVGRepo_iconCarrier"><title>letter--Aa</title><path d="M23,13H18v2h5v2H19a2,2,0,0,0-2,2v2a2,2,0,0,0,2,2h6V15A2,2,0,0,0,23,13Zm0,8H19V19h4Z"></path><path d="M13,9H9a2,2,0,0,0-2,2V23H9V18h4v5h2V11A2,2,0,0,0,13,9ZM9,16V11h4v5Z"></path><rect id="_Transparent_Rectangle_" data-name="<Transparent Rectangle>" fill="none" width="32" height="32"></rect></g></svg>'
|
|
138
143
|
}
|
|
139
144
|
],
|
|
140
145
|
commands: {
|
package/dist/checklist.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const M="__editoraCommandEditorRoot",H=e=>{if(!e)return null;const t=e.querySelector('[contenteditable="true"]');return t instanceof HTMLElement?t:null},R=()=>{if(typeof window>"u")return null;const e=window[M];if(!(e instanceof HTMLElement))return null;window[M]=null;const t=e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?e:null);if(t){const n=H(t);if(n)return n;if(t.getAttribute("contenteditable")==="true")return t}if(e.getAttribute("contenteditable")==="true")return e;const r=e.closest('[contenteditable="true"]');return r instanceof HTMLElement?r:null},_=()=>{const e=R();if(e&&document.contains(e))return e;const t=window.getSelection();if(t&&t.rangeCount>0){let n=t.getRangeAt(0).startContainer;for(;n&&n!==document.body;){if(n.nodeType===Node.ELEMENT_NODE){const o=n;if(o.getAttribute("contenteditable")==="true")return o}n=n.parentNode}}const r=document.activeElement;if(r){if(r.getAttribute("contenteditable")==="true")return r;const n=r.closest('[contenteditable="true"]');if(n)return n}return document.querySelector('[contenteditable="true"]')},A=e=>e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null,I=e=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);return e.contains(r.commonAncestorContainer)?r:null},T=e=>{e.dispatchEvent(new Event("input",{bubbles:!0}))},b=(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{}},C=(e,t)=>{if(!e.isConnected){t.focus({preventScroll:!0});return}const r=window.getSelection();if(!r)return;const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),r.removeAllRanges();try{r.addRange(n)}catch{t.focus({preventScroll:!0});return}t.focus({preventScroll:!0})},N=e=>{let t=e.querySelector(":scope > p");if(!t){t=document.createElement("p");const r=[];e.childNodes.forEach(n=>{n.nodeType===Node.ELEMENT_NODE&&["UL","OL"].includes(n.tagName)||r.push(n)}),r.forEach(n=>t.appendChild(n)),e.insertBefore(t,e.firstChild)}return t.innerHTML.trim()||(t.innerHTML="<br>"),t},v=e=>(e.textContent||"").replace(/\u200B/g,"").trim()?!1:!e.querySelector("img, video, table, iframe, hr, pre, ul, ol"),P=()=>{const e=document.createElement("p");return e.innerHTML="<br>",e},S=(e,t)=>{if(!e.isConnected){t.focus({preventScroll:!0});return}const r=window.getSelection();if(!r)return;const n=document.createRange();n.selectNodeContents(e),n.collapse(!0),r.removeAllRanges();try{r.addRange(n)}catch{t.focus({preventScroll:!0});return}t.focus({preventScroll:!0})},x=(e,t)=>{e.appendChild(t),e.innerHTML.trim()||(e.innerHTML="<br>")},O=(e,t,r)=>{const n=P();t.parentNode?.insertBefore(n,t.nextSibling),r.remove(),y(t).length===0&&t.remove(),S(n,e)},D=(e,t,r)=>{const n=N(t),o=r.cloneRange();o.deleteContents();const i=document.createRange();i.setStart(o.startContainer,o.startOffset),i.setEndAfter(n.lastChild||n);const d=document.createDocumentFragment();try{d.appendChild(i.extractContents())}catch{}n.innerHTML.trim()||(n.innerHTML="<br>");const c=document.createElement("li");c.setAttribute("data-type","checklist-item"),c.setAttribute("data-checked","false");const h=document.createElement("p");x(h,d),c.appendChild(h),t.parentNode?.insertBefore(c,t.nextSibling),S(h,e)},k=e=>{const t=document.createElement("li");t.setAttribute("data-type","checklist-item"),t.setAttribute("data-checked","false");const r=document.createElement("p");return r.innerHTML=e.trim()||"<br>",t.appendChild(r),t},y=e=>Array.from(e.children).filter(t=>t instanceof HTMLLIElement),F=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","LI"]),L=e=>F.has(e.tagName)&&e.getAttribute("contenteditable")!=="true",B=(e,t)=>{const r=[],n=new Set,o=s=>{!s||n.has(s)||t.contains(s)&&L(s)&&(s.closest("ul, ol")||(n.add(s),r.push(s)))},i=s=>{let l=s;for(;l&&l!==document.body;){if(l.nodeType===Node.ELEMENT_NODE){const p=l;if(L(p))return p;if(p.getAttribute("contenteditable")==="true")break}l=l.parentNode}return null};if(e.collapsed)return o(i(e.startContainer)),r;const d=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const l=s;if(!L(l)||l.closest("ul, ol"))return NodeFilter.FILTER_SKIP;if(typeof e.intersectsNode=="function")return e.intersectsNode(l)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP;const p=document.createRange();return p.selectNodeContents(l),e.compareBoundaryPoints(Range.END_TO_START,p)>0&&e.compareBoundaryPoints(Range.START_TO_END,p)<0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let c=d.nextNode();for(;c;)o(c),c=d.nextNode();if(r.length===0&&o(i(e.commonAncestorContainer)),r.length<=1)return r;const h=r.filter(s=>!r.some(l=>l!==s&&s.contains(l)));return h.length>0?h:r},K=e=>{const t=[],r=document.createElement("div"),n=()=>{const o=r.innerHTML.trim();if(!o)return;const i=document.createElement("p");i.innerHTML=o,t.push(i),r.innerHTML=""};if(e.childNodes.forEach(o=>{if(o.nodeType===Node.ELEMENT_NODE&&["UL","OL"].includes(o.tagName)){n();return}if(o.nodeType===Node.ELEMENT_NODE&&o.tagName==="P"){n();const i=o.innerHTML.trim(),d=document.createElement("p");d.innerHTML=i||"<br>",t.push(d);return}o.nodeType===Node.TEXT_NODE&&!(o.textContent||"").trim()||r.appendChild(o.cloneNode(!0))}),n(),t.length===0){const o=document.createElement("p");o.innerHTML="<br>",t.push(o)}return t},z=()=>({name:"checklist",init:()=>{if(!(typeof document>"u"||typeof window>"u")){if(!window.__checklistPluginClickInitialized){window.__checklistPluginClickInitialized=!0;const e=t=>{const n=t.target.closest('li[data-type="checklist-item"]');if(!n)return;const o=n.getBoundingClientRect();if(!(t.clientX-o.left<32))return;t.preventDefault(),t.stopPropagation();const c=n.closest("[contenteditable], .rte-content, .editora-content");if(c?.getAttribute("contenteditable")==="false"||!!c?.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]'))return;const s=c?.innerHTML||"",l=n.getAttribute("data-checked")==="true";n.setAttribute("data-checked",(!l).toString()),c&&(b(c,s),T(c))};document.addEventListener("click",e)}if(!window.__checklistPluginKeydownInitialized){window.__checklistPluginKeydownInitialized=!0;const e=t=>{if(t.key!=="Enter"||t.shiftKey||t.altKey||t.ctrlKey||t.metaKey||t.defaultPrevented)return;const r=window.getSelection();if(!r||r.rangeCount===0)return;const n=r.getRangeAt(0),i=A(n.startContainer)?.closest('li[data-type="checklist-item"]');if(!i)return;const d=i.closest('ul[data-type="checklist"]');if(!d)return;const c=i.closest("[contenteditable], .rte-content, .editora-content");if(!c||c.getAttribute("contenteditable")==="false"||!!c.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]'))return;t.preventDefault();const s=c.innerHTML,l=N(i);v(l)?O(c,d,i):D(c,i,n),b(c,s),T(c)};document.addEventListener("keydown",e)}}},nodes:{checklist:{content:"checklistItem+",group:"block",parseDOM:[{tag:'ul[data-type="checklist"]'}],toDOM:()=>["ul",{"data-type":"checklist"},0]},checklistItem:{content:"paragraph",attrs:{checked:{default:!1}},parseDOM:[{tag:'li[data-type="checklist-item"]',getAttrs:e=>({checked:e.getAttribute("data-checked")==="true"})}],toDOM:e=>["li",{"data-type":"checklist-item","data-checked":e?.attrs?.checked?"true":"false"},0]}},toolbar:[{label:"Checklist",command:"toggleChecklist",icon:'<svg width="24px" height="24px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 4.48h-.71L2 3.43l.71-.7.69.68L4.81 2l.71.71-1.77 1.77zM6.99 3h8v1h-8V3zm0 3h8v1h-8V6zm8 3h-8v1h8V9zm-8 3h8v1h-8v-1zM3.04 7.48h.71l1.77-1.77-.71-.7L3.4 6.42l-.69-.69-.71.71 1.04 1.04zm.71 3.01h-.71L2 9.45l.71-.71.69.69 1.41-1.42.71.71-1.77 1.77zm-.71 3.01h.71l1.77-1.77-.71-.71-1.41 1.42-.69-.69-.71.7 1.04 1.05z"></path></g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleChecklist:()=>{try{const e=_();if(!e)return!1;const t=e.innerHTML,r=()=>(b(e,t),T(e),!0),n=I(e);if(!n)return!1;const o=A(n.startContainer);if(!o)return!1;const i=o.closest('ul[data-type="checklist"]');if(i&&e.contains(i)){const a=y(i);if(a.length===0)return!1;const f=document.createDocumentFragment();let u=null;return a.forEach((m,g)=>{const E=K(m);E.forEach(w=>{f.appendChild(w),!u&&(m.contains(n.startContainer)||g===0)&&(u=w)}),!u&&g===0&&E[0]&&(u=E[0])}),i.replaceWith(f),u&&C(u,e),r()}const d=o.closest("ul, ol");if(d&&e.contains(d)){let a;if(d.tagName.toLowerCase()==="ul")a=d;else{for(a=document.createElement("ul");d.firstChild;)a.appendChild(d.firstChild);d.replaceWith(a)}a.setAttribute("data-type","checklist");let f=y(a);f.length===0&&(a.appendChild(k("")),f=y(a));let u=null;f.forEach(g=>{g.setAttribute("data-type","checklist-item"),g.hasAttribute("data-checked")||g.setAttribute("data-checked","false");const E=N(g);g.contains(n.startContainer)&&(u=E)});const m=a.querySelector(':scope > li[data-type="checklist-item"] > p');return C(u||m||a,e),r()}const c=B(n,e);if(c.length>1){const a=document.createElement("ul");a.setAttribute("data-type","checklist"),c.forEach(m=>{a.appendChild(k(m.innerHTML))}),c[0].replaceWith(a),c.slice(1).forEach(m=>{m.isConnected&&m.remove()});const u=a.querySelector(':scope > li[data-type="checklist-item"] > p');return u&&C(u,e),r()}const h=c[0]||o.closest("p, h1, h2, h3, h4, h5, h6, blockquote, pre");if(h&&h!==e){const a=document.createElement("ul");a.setAttribute("data-type","checklist");const f=k(h.innerHTML);a.appendChild(f),h.replaceWith(a);const u=f.querySelector(":scope > p");return u&&C(u,e),r()}const s=document.createElement("ul");s.setAttribute("data-type","checklist");const l=k("");s.appendChild(l),n.deleteContents(),n.insertNode(s);const p=l.querySelector(":scope > p");return p&&C(p,e),r()}catch(e){return console.error("Failed to toggle checklist:",e),!1}}},keymap:{"Mod-Shift-9":"toggleChecklist"}});exports.ChecklistPlugin=z;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const M="__editoraCommandEditorRoot",R=e=>{if(!e)return null;const t=e.querySelector('[contenteditable="true"]');return t instanceof HTMLElement?t:null},H=()=>{if(typeof window>"u")return null;const e=window[M];if(!(e instanceof HTMLElement))return null;window[M]=null;const t=e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||(e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")?e:null);if(t){const n=R(t);if(n)return n;if(t.getAttribute("contenteditable")==="true")return t}if(e.getAttribute("contenteditable")==="true")return e;const r=e.closest('[contenteditable="true"]');return r instanceof HTMLElement?r:null},_=()=>{const e=H();if(e&&document.contains(e))return e;const t=window.getSelection();if(t&&t.rangeCount>0){let n=t.getRangeAt(0).startContainer;for(;n&&n!==document.body;){if(n.nodeType===Node.ELEMENT_NODE){const o=n;if(o.getAttribute("contenteditable")==="true")return o}n=n.parentNode}}const r=document.activeElement;if(r){if(r.getAttribute("contenteditable")==="true")return r;const n=r.closest('[contenteditable="true"]');if(n)return n}return document.querySelector('[contenteditable="true"]')},A=e=>e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null,O=e=>{const t=window.getSelection();if(!t||t.rangeCount===0)return null;const r=t.getRangeAt(0);return e.contains(r.commonAncestorContainer)?r:null},y=e=>{e.dispatchEvent(new Event("input",{bubbles:!0}))},L=(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{}},C=(e,t)=>{if(!e.isConnected){t.focus({preventScroll:!0});return}const r=window.getSelection();if(!r)return;const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),r.removeAllRanges();try{r.addRange(n)}catch{t.focus({preventScroll:!0});return}t.focus({preventScroll:!0})},b=e=>{let t=e.querySelector(":scope > p");if(!t){t=document.createElement("p");const r=[];e.childNodes.forEach(n=>{n.nodeType===Node.ELEMENT_NODE&&["UL","OL"].includes(n.tagName)||r.push(n)}),r.forEach(n=>t.appendChild(n)),e.insertBefore(t,e.firstChild)}return t.innerHTML.trim()||(t.innerHTML="<br>"),t},I=e=>(e.textContent||"").replace(/\u200B/g,"").trim()?!1:!e.querySelector("img, video, table, iframe, hr, pre, ul, ol"),v=()=>{const e=document.createElement("p");return e.innerHTML="<br>",e},S=(e,t)=>{if(!e.isConnected){t.focus({preventScroll:!0});return}const r=window.getSelection();if(!r)return;const n=document.createRange();n.selectNodeContents(e),n.collapse(!0),r.removeAllRanges();try{r.addRange(n)}catch{t.focus({preventScroll:!0});return}t.focus({preventScroll:!0})},P=(e,t)=>{e.appendChild(t),e.innerHTML.trim()||(e.innerHTML="<br>")},D=(e,t,r)=>{const n=v();t.parentNode?.insertBefore(n,t.nextSibling),r.remove(),T(t).length===0&&t.remove(),S(n,e)},x=(e,t,r)=>{const n=b(t),o=r.cloneRange();o.deleteContents();const a=document.createRange();a.setStart(o.startContainer,o.startOffset),a.setEndAfter(n.lastChild||n);const s=document.createDocumentFragment();try{s.appendChild(a.extractContents())}catch{}n.innerHTML.trim()||(n.innerHTML="<br>");const c=document.createElement("li");c.setAttribute("data-type","checklist-item"),c.setAttribute("data-checked","false");const u=document.createElement("p");P(u,s),c.appendChild(u),t.parentNode?.insertBefore(c,t.nextSibling),S(u,e)},k=e=>{const t=document.createElement("li");t.setAttribute("data-type","checklist-item"),t.setAttribute("data-checked","false");const r=document.createElement("p");return r.innerHTML=e.trim()||"<br>",t.appendChild(r),t},T=e=>Array.from(e.children).filter(t=>t instanceof HTMLLIElement),B=new Set(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","LI"]),N=e=>B.has(e.tagName)&&e.getAttribute("contenteditable")!=="true",F=(e,t)=>{const r=[],n=new Set,o=i=>{!i||n.has(i)||t.contains(i)&&N(i)&&(i.closest("ul, ol")||(n.add(i),r.push(i)))},a=i=>{let d=i;for(;d&&d!==document.body;){if(d.nodeType===Node.ELEMENT_NODE){const p=d;if(N(p))return p;if(p.getAttribute("contenteditable")==="true")break}d=d.parentNode}return null};if(e.collapsed)return o(a(e.startContainer)),r;const s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:i=>{const d=i;if(!N(d)||d.closest("ul, ol"))return NodeFilter.FILTER_SKIP;if(typeof e.intersectsNode=="function")return e.intersectsNode(d)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP;const p=document.createRange();return p.selectNodeContents(d),e.compareBoundaryPoints(Range.END_TO_START,p)>0&&e.compareBoundaryPoints(Range.START_TO_END,p)<0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});let c=s.nextNode();for(;c;)o(c),c=s.nextNode();if(r.length===0&&o(a(e.commonAncestorContainer)),r.length<=1)return r;const u=r.filter(i=>!r.some(d=>d!==i&&i.contains(d)));return u.length>0?u:r},K=new Set(["P","DIV","UL","OL","LI","BLOCKQUOTE","H1","H2","H3","H4","H5","H6","TABLE","PRE","FIGURE","SECTION","ARTICLE","HEADER","FOOTER","HR"]),z=(e,t)=>{const r=t.startContainer,n=t.startOffset,o=t.endContainer,a=t.endOffset;let s=null,c=!1;if(Array.from(e.childNodes).forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE&&K.has(i.tagName)){s=null;return}i.nodeType===Node.TEXT_NODE&&!(i.textContent||"").trim()||i.nodeType!==Node.TEXT_NODE&&i.nodeType!==Node.ELEMENT_NODE||(s||(s=document.createElement("p"),e.insertBefore(s,i)),s.appendChild(i),c=!0)}),!c)return;try{r===e?t.setStart(e,0):r.isConnected&&t.setStart(r,n),o===e?t.setEnd(e,e.childNodes.length):o.isConnected&&t.setEnd(o,a)}catch{}const u=window.getSelection();u&&(u.removeAllRanges(),u.addRange(t))},q=e=>{const t=[],r=document.createElement("div"),n=()=>{const o=r.innerHTML.trim();if(!o)return;const a=document.createElement("p");a.innerHTML=o,t.push(a),r.innerHTML=""};if(e.childNodes.forEach(o=>{if(o.nodeType===Node.ELEMENT_NODE&&["UL","OL"].includes(o.tagName)){n();return}if(o.nodeType===Node.ELEMENT_NODE&&o.tagName==="P"){n();const a=o.innerHTML.trim(),s=document.createElement("p");s.innerHTML=a||"<br>",t.push(s);return}o.nodeType===Node.TEXT_NODE&&!(o.textContent||"").trim()||r.appendChild(o.cloneNode(!0))}),n(),t.length===0){const o=document.createElement("p");o.innerHTML="<br>",t.push(o)}return t},V=()=>({name:"checklist",init:()=>{if(!(typeof document>"u"||typeof window>"u")){if(!window.__checklistPluginClickInitialized){window.__checklistPluginClickInitialized=!0;const e=t=>{const n=t.target.closest('li[data-type="checklist-item"]');if(!n)return;const o=n.getBoundingClientRect();if(!(t.clientX-o.left<32))return;t.preventDefault(),t.stopPropagation();const c=n.closest("[contenteditable], .rte-content, .editora-content");if(c?.getAttribute("contenteditable")==="false"||!!c?.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]'))return;const i=c?.innerHTML||"",d=n.getAttribute("data-checked")==="true";n.setAttribute("data-checked",(!d).toString()),c&&(L(c,i),y(c))};document.addEventListener("click",e)}if(!window.__checklistPluginKeydownInitialized){window.__checklistPluginKeydownInitialized=!0;const e=t=>{if(t.key!=="Enter"||t.shiftKey||t.altKey||t.ctrlKey||t.metaKey||t.defaultPrevented)return;const r=window.getSelection();if(!r||r.rangeCount===0)return;const n=r.getRangeAt(0),a=A(n.startContainer)?.closest('li[data-type="checklist-item"]');if(!a)return;const s=a.closest('ul[data-type="checklist"]');if(!s)return;const c=a.closest("[contenteditable], .rte-content, .editora-content");if(!c||c.getAttribute("contenteditable")==="false"||!!c.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]'))return;t.preventDefault();const i=c.innerHTML,d=b(a);I(d)?D(c,s,a):x(c,a,n),L(c,i),y(c)};document.addEventListener("keydown",e)}}},nodes:{checklist:{content:"checklistItem+",group:"block",parseDOM:[{tag:'ul[data-type="checklist"]'}],toDOM:()=>["ul",{"data-type":"checklist"},0]},checklistItem:{content:"paragraph",attrs:{checked:{default:!1}},parseDOM:[{tag:'li[data-type="checklist-item"]',getAttrs:e=>({checked:e.getAttribute("data-checked")==="true"})}],toDOM:e=>["li",{"data-type":"checklist-item","data-checked":e?.attrs?.checked?"true":"false"},0]}},toolbar:[{label:"Checklist",command:"toggleChecklist",icon:'<svg width="24px" height="24px" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"><path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 4.48h-.71L2 3.43l.71-.7.69.68L4.81 2l.71.71-1.77 1.77zM6.99 3h8v1h-8V3zm0 3h8v1h-8V6zm8 3h-8v1h8V9zm-8 3h8v1h-8v-1zM3.04 7.48h.71l1.77-1.77-.71-.7L3.4 6.42l-.69-.69-.71.71 1.04 1.04zm.71 3.01h-.71L2 9.45l.71-.71.69.69 1.41-1.42.71.71-1.77 1.77zm-.71 3.01h.71l1.77-1.77-.71-.71-1.41 1.42-.69-.69-.71.7 1.04 1.05z"></path></g></svg>',shortcut:"Mod-Shift-9"}],commands:{toggleChecklist:()=>{try{const e=_();if(!e)return!1;const t=e.innerHTML,r=()=>(L(e,t),y(e),!0),n=O(e);if(!n)return!1;z(e,n);const o=A(n.startContainer);if(!o)return!1;const a=o.closest('ul[data-type="checklist"]');if(a&&e.contains(a)){const l=T(a);if(l.length===0)return!1;const h=document.createDocumentFragment();let f=null;return l.forEach((m,E)=>{const g=q(m);g.forEach(w=>{h.appendChild(w),!f&&(m.contains(n.startContainer)||E===0)&&(f=w)}),!f&&E===0&&g[0]&&(f=g[0])}),a.replaceWith(h),f&&C(f,e),r()}const s=o.closest("ul, ol");if(s&&e.contains(s)){let l;if(s.tagName.toLowerCase()==="ul")l=s;else{for(l=document.createElement("ul");s.firstChild;)l.appendChild(s.firstChild);s.replaceWith(l)}l.setAttribute("data-type","checklist");let h=T(l);h.length===0&&(l.appendChild(k("")),h=T(l));let f=null;h.forEach(E=>{E.setAttribute("data-type","checklist-item"),E.hasAttribute("data-checked")||E.setAttribute("data-checked","false");const g=b(E);E.contains(n.startContainer)&&(f=g)});const m=l.querySelector(':scope > li[data-type="checklist-item"] > p');return C(f||m||l,e),r()}const c=F(n,e);if(c.length>1){const l=document.createElement("ul");l.setAttribute("data-type","checklist"),c.forEach(m=>{l.appendChild(k(m.innerHTML))}),c[0].replaceWith(l),c.slice(1).forEach(m=>{m.isConnected&&m.remove()});const f=l.querySelector(':scope > li[data-type="checklist-item"] > p');return f&&C(f,e),r()}const u=c[0]||o.closest("p, h1, h2, h3, h4, h5, h6, blockquote, pre");if(u&&u!==e){const l=document.createElement("ul");l.setAttribute("data-type","checklist");const h=k(u.innerHTML);l.appendChild(h),u.replaceWith(l);const f=h.querySelector(":scope > p");return f&&C(f,e),r()}const i=document.createElement("ul");i.setAttribute("data-type","checklist");const d=k("");i.appendChild(d),n.deleteContents(),n.insertNode(i);const p=d.querySelector(":scope > p");return p&&C(p,e),r()}catch(e){return console.error("Failed to toggle checklist:",e),!1}}},keymap:{"Mod-Shift-9":"toggleChecklist"}});exports.ChecklistPlugin=V;
|
package/dist/checklist.esm.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const
|
|
1
|
+
const A = "__editoraCommandEditorRoot", S = (e) => {
|
|
2
2
|
if (!e) return null;
|
|
3
3
|
const t = e.querySelector('[contenteditable="true"]');
|
|
4
4
|
return t instanceof HTMLElement ? t : null;
|
|
5
|
-
},
|
|
5
|
+
}, H = () => {
|
|
6
6
|
if (typeof window > "u") return null;
|
|
7
|
-
const e = window[
|
|
7
|
+
const e = window[A];
|
|
8
8
|
if (!(e instanceof HTMLElement)) return null;
|
|
9
|
-
window[
|
|
9
|
+
window[A] = null;
|
|
10
10
|
const t = e.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") || (e.matches("[data-editora-editor], .rte-editor, .editora-editor, editora-editor") ? e : null);
|
|
11
11
|
if (t) {
|
|
12
|
-
const n =
|
|
12
|
+
const n = S(t);
|
|
13
13
|
if (n) return n;
|
|
14
14
|
if (t.getAttribute("contenteditable") === "true") return t;
|
|
15
15
|
}
|
|
@@ -18,7 +18,7 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
|
|
|
18
18
|
const r = e.closest('[contenteditable="true"]');
|
|
19
19
|
return r instanceof HTMLElement ? r : null;
|
|
20
20
|
}, _ = () => {
|
|
21
|
-
const e =
|
|
21
|
+
const e = H();
|
|
22
22
|
if (e && document.contains(e))
|
|
23
23
|
return e;
|
|
24
24
|
const t = window.getSelection();
|
|
@@ -41,14 +41,14 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
|
|
|
41
41
|
if (n) return n;
|
|
42
42
|
}
|
|
43
43
|
return document.querySelector('[contenteditable="true"]');
|
|
44
|
-
},
|
|
44
|
+
}, M = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? e : e.parentElement : null, O = (e) => {
|
|
45
45
|
const t = window.getSelection();
|
|
46
46
|
if (!t || t.rangeCount === 0) return null;
|
|
47
47
|
const r = t.getRangeAt(0);
|
|
48
48
|
return e.contains(r.commonAncestorContainer) ? r : null;
|
|
49
|
-
},
|
|
49
|
+
}, y = (e) => {
|
|
50
50
|
e.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
51
|
-
},
|
|
51
|
+
}, L = (e, t) => {
|
|
52
52
|
if (t === e.innerHTML) return;
|
|
53
53
|
const r = window.execEditorCommand || window.executeEditorCommand;
|
|
54
54
|
if (typeof r == "function")
|
|
@@ -72,7 +72,7 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
|
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
t.focus({ preventScroll: !0 });
|
|
75
|
-
},
|
|
75
|
+
}, b = (e) => {
|
|
76
76
|
let t = e.querySelector(":scope > p");
|
|
77
77
|
if (!t) {
|
|
78
78
|
t = document.createElement("p");
|
|
@@ -82,10 +82,10 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
|
|
|
82
82
|
}), r.forEach((n) => t.appendChild(n)), e.insertBefore(t, e.firstChild);
|
|
83
83
|
}
|
|
84
84
|
return t.innerHTML.trim() || (t.innerHTML = "<br>"), t;
|
|
85
|
-
},
|
|
85
|
+
}, I = (e) => (e.textContent || "").replace(/\u200B/g, "").trim() ? !1 : !e.querySelector("img, video, table, iframe, hr, pre, ul, ol"), v = () => {
|
|
86
86
|
const e = document.createElement("p");
|
|
87
87
|
return e.innerHTML = "<br>", e;
|
|
88
|
-
},
|
|
88
|
+
}, R = (e, t) => {
|
|
89
89
|
if (!e.isConnected) {
|
|
90
90
|
t.focus({ preventScroll: !0 });
|
|
91
91
|
return;
|
|
@@ -101,34 +101,34 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
|
|
|
101
101
|
return;
|
|
102
102
|
}
|
|
103
103
|
t.focus({ preventScroll: !0 });
|
|
104
|
-
},
|
|
104
|
+
}, D = (e, t) => {
|
|
105
105
|
e.appendChild(t), e.innerHTML.trim() || (e.innerHTML = "<br>");
|
|
106
|
-
},
|
|
107
|
-
const n =
|
|
108
|
-
t.parentNode?.insertBefore(n, t.nextSibling), r.remove(),
|
|
109
|
-
},
|
|
110
|
-
const n =
|
|
106
|
+
}, x = (e, t, r) => {
|
|
107
|
+
const n = v();
|
|
108
|
+
t.parentNode?.insertBefore(n, t.nextSibling), r.remove(), T(t).length === 0 && t.remove(), R(n, e);
|
|
109
|
+
}, P = (e, t, r) => {
|
|
110
|
+
const n = b(t), o = r.cloneRange();
|
|
111
111
|
o.deleteContents();
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
const
|
|
112
|
+
const a = document.createRange();
|
|
113
|
+
a.setStart(o.startContainer, o.startOffset), a.setEndAfter(n.lastChild || n);
|
|
114
|
+
const s = document.createDocumentFragment();
|
|
115
115
|
try {
|
|
116
|
-
|
|
116
|
+
s.appendChild(a.extractContents());
|
|
117
117
|
} catch {
|
|
118
118
|
}
|
|
119
119
|
n.innerHTML.trim() || (n.innerHTML = "<br>");
|
|
120
120
|
const c = document.createElement("li");
|
|
121
121
|
c.setAttribute("data-type", "checklist-item"), c.setAttribute("data-checked", "false");
|
|
122
|
-
const
|
|
123
|
-
|
|
122
|
+
const u = document.createElement("p");
|
|
123
|
+
D(u, s), c.appendChild(u), t.parentNode?.insertBefore(c, t.nextSibling), R(u, e);
|
|
124
124
|
}, k = (e) => {
|
|
125
125
|
const t = document.createElement("li");
|
|
126
126
|
t.setAttribute("data-type", "checklist-item"), t.setAttribute("data-checked", "false");
|
|
127
127
|
const r = document.createElement("p");
|
|
128
128
|
return r.innerHTML = e.trim() || "<br>", t.appendChild(r), t;
|
|
129
|
-
},
|
|
129
|
+
}, T = (e) => Array.from(e.children).filter(
|
|
130
130
|
(t) => t instanceof HTMLLIElement
|
|
131
|
-
),
|
|
131
|
+
), B = /* @__PURE__ */ new Set([
|
|
132
132
|
"P",
|
|
133
133
|
"DIV",
|
|
134
134
|
"H1",
|
|
@@ -140,50 +140,87 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
|
|
|
140
140
|
"BLOCKQUOTE",
|
|
141
141
|
"PRE",
|
|
142
142
|
"LI"
|
|
143
|
-
]),
|
|
144
|
-
const r = [], n = /* @__PURE__ */ new Set(), o = (
|
|
145
|
-
!
|
|
146
|
-
},
|
|
147
|
-
let
|
|
148
|
-
for (;
|
|
149
|
-
if (
|
|
150
|
-
const p =
|
|
151
|
-
if (
|
|
143
|
+
]), N = (e) => B.has(e.tagName) && e.getAttribute("contenteditable") !== "true", F = (e, t) => {
|
|
144
|
+
const r = [], n = /* @__PURE__ */ new Set(), o = (i) => {
|
|
145
|
+
!i || n.has(i) || t.contains(i) && N(i) && (i.closest("ul, ol") || (n.add(i), r.push(i)));
|
|
146
|
+
}, a = (i) => {
|
|
147
|
+
let d = i;
|
|
148
|
+
for (; d && d !== document.body; ) {
|
|
149
|
+
if (d.nodeType === Node.ELEMENT_NODE) {
|
|
150
|
+
const p = d;
|
|
151
|
+
if (N(p)) return p;
|
|
152
152
|
if (p.getAttribute("contenteditable") === "true") break;
|
|
153
153
|
}
|
|
154
|
-
|
|
154
|
+
d = d.parentNode;
|
|
155
155
|
}
|
|
156
156
|
return null;
|
|
157
157
|
};
|
|
158
158
|
if (e.collapsed)
|
|
159
|
-
return o(
|
|
160
|
-
const
|
|
159
|
+
return o(a(e.startContainer)), r;
|
|
160
|
+
const s = document.createTreeWalker(
|
|
161
161
|
t,
|
|
162
162
|
NodeFilter.SHOW_ELEMENT,
|
|
163
163
|
{
|
|
164
|
-
acceptNode: (
|
|
165
|
-
const
|
|
166
|
-
if (!
|
|
164
|
+
acceptNode: (i) => {
|
|
165
|
+
const d = i;
|
|
166
|
+
if (!N(d) || d.closest("ul, ol")) return NodeFilter.FILTER_SKIP;
|
|
167
167
|
if (typeof e.intersectsNode == "function")
|
|
168
|
-
return e.intersectsNode(
|
|
168
|
+
return e.intersectsNode(d) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
169
169
|
const p = document.createRange();
|
|
170
|
-
return p.selectNodeContents(
|
|
170
|
+
return p.selectNodeContents(d), e.compareBoundaryPoints(Range.END_TO_START, p) > 0 && e.compareBoundaryPoints(Range.START_TO_END, p) < 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
);
|
|
174
|
-
let c =
|
|
174
|
+
let c = s.nextNode();
|
|
175
175
|
for (; c; )
|
|
176
|
-
o(c), c =
|
|
177
|
-
if (r.length === 0 && o(
|
|
176
|
+
o(c), c = s.nextNode();
|
|
177
|
+
if (r.length === 0 && o(a(e.commonAncestorContainer)), r.length <= 1)
|
|
178
178
|
return r;
|
|
179
|
-
const
|
|
180
|
-
return
|
|
181
|
-
}, K =
|
|
179
|
+
const u = r.filter((i) => !r.some((d) => d !== i && i.contains(d)));
|
|
180
|
+
return u.length > 0 ? u : r;
|
|
181
|
+
}, K = /* @__PURE__ */ new Set([
|
|
182
|
+
"P",
|
|
183
|
+
"DIV",
|
|
184
|
+
"UL",
|
|
185
|
+
"OL",
|
|
186
|
+
"LI",
|
|
187
|
+
"BLOCKQUOTE",
|
|
188
|
+
"H1",
|
|
189
|
+
"H2",
|
|
190
|
+
"H3",
|
|
191
|
+
"H4",
|
|
192
|
+
"H5",
|
|
193
|
+
"H6",
|
|
194
|
+
"TABLE",
|
|
195
|
+
"PRE",
|
|
196
|
+
"FIGURE",
|
|
197
|
+
"SECTION",
|
|
198
|
+
"ARTICLE",
|
|
199
|
+
"HEADER",
|
|
200
|
+
"FOOTER",
|
|
201
|
+
"HR"
|
|
202
|
+
]), z = (e, t) => {
|
|
203
|
+
const r = t.startContainer, n = t.startOffset, o = t.endContainer, a = t.endOffset;
|
|
204
|
+
let s = null, c = !1;
|
|
205
|
+
if (Array.from(e.childNodes).forEach((i) => {
|
|
206
|
+
if (i.nodeType === Node.ELEMENT_NODE && K.has(i.tagName)) {
|
|
207
|
+
s = null;
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
i.nodeType === Node.TEXT_NODE && !(i.textContent || "").trim() || i.nodeType !== Node.TEXT_NODE && i.nodeType !== Node.ELEMENT_NODE || (s || (s = document.createElement("p"), e.insertBefore(s, i)), s.appendChild(i), c = !0);
|
|
211
|
+
}), !c) return;
|
|
212
|
+
try {
|
|
213
|
+
r === e ? t.setStart(e, 0) : r.isConnected && t.setStart(r, n), o === e ? t.setEnd(e, e.childNodes.length) : o.isConnected && t.setEnd(o, a);
|
|
214
|
+
} catch {
|
|
215
|
+
}
|
|
216
|
+
const u = window.getSelection();
|
|
217
|
+
u && (u.removeAllRanges(), u.addRange(t));
|
|
218
|
+
}, q = (e) => {
|
|
182
219
|
const t = [], r = document.createElement("div"), n = () => {
|
|
183
220
|
const o = r.innerHTML.trim();
|
|
184
221
|
if (!o) return;
|
|
185
|
-
const
|
|
186
|
-
|
|
222
|
+
const a = document.createElement("p");
|
|
223
|
+
a.innerHTML = o, t.push(a), r.innerHTML = "";
|
|
187
224
|
};
|
|
188
225
|
if (e.childNodes.forEach((o) => {
|
|
189
226
|
if (o.nodeType === Node.ELEMENT_NODE && ["UL", "OL"].includes(o.tagName)) {
|
|
@@ -192,8 +229,8 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
|
|
|
192
229
|
}
|
|
193
230
|
if (o.nodeType === Node.ELEMENT_NODE && o.tagName === "P") {
|
|
194
231
|
n();
|
|
195
|
-
const
|
|
196
|
-
|
|
232
|
+
const a = o.innerHTML.trim(), s = document.createElement("p");
|
|
233
|
+
s.innerHTML = a || "<br>", t.push(s);
|
|
197
234
|
return;
|
|
198
235
|
}
|
|
199
236
|
o.nodeType === Node.TEXT_NODE && !(o.textContent || "").trim() || r.appendChild(o.cloneNode(!0));
|
|
@@ -202,7 +239,7 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
|
|
|
202
239
|
o.innerHTML = "<br>", t.push(o);
|
|
203
240
|
}
|
|
204
241
|
return t;
|
|
205
|
-
},
|
|
242
|
+
}, V = () => ({
|
|
206
243
|
name: "checklist",
|
|
207
244
|
// Initialize click handler when plugin is loaded
|
|
208
245
|
init: () => {
|
|
@@ -217,8 +254,8 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
|
|
|
217
254
|
t.preventDefault(), t.stopPropagation();
|
|
218
255
|
const c = n.closest("[contenteditable], .rte-content, .editora-content");
|
|
219
256
|
if (c?.getAttribute("contenteditable") === "false" || !!c?.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]')) return;
|
|
220
|
-
const
|
|
221
|
-
n.setAttribute("data-checked", (!
|
|
257
|
+
const i = c?.innerHTML || "", d = n.getAttribute("data-checked") === "true";
|
|
258
|
+
n.setAttribute("data-checked", (!d).toString()), c && (L(c, i), y(c));
|
|
222
259
|
};
|
|
223
260
|
document.addEventListener("click", e);
|
|
224
261
|
}
|
|
@@ -228,15 +265,15 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
|
|
|
228
265
|
if (t.key !== "Enter" || t.shiftKey || t.altKey || t.ctrlKey || t.metaKey || t.defaultPrevented) return;
|
|
229
266
|
const r = window.getSelection();
|
|
230
267
|
if (!r || r.rangeCount === 0) return;
|
|
231
|
-
const n = r.getRangeAt(0),
|
|
232
|
-
if (!
|
|
233
|
-
const
|
|
234
|
-
if (!
|
|
235
|
-
const c =
|
|
268
|
+
const n = r.getRangeAt(0), a = M(n.startContainer)?.closest('li[data-type="checklist-item"]');
|
|
269
|
+
if (!a) return;
|
|
270
|
+
const s = a.closest('ul[data-type="checklist"]');
|
|
271
|
+
if (!s) return;
|
|
272
|
+
const c = a.closest("[contenteditable], .rte-content, .editora-content");
|
|
236
273
|
if (!c || c.getAttribute("contenteditable") === "false" || !!c.closest('[data-readonly="true"], .editora-editor[readonly], editora-editor[readonly]')) return;
|
|
237
274
|
t.preventDefault();
|
|
238
|
-
const
|
|
239
|
-
|
|
275
|
+
const i = c.innerHTML, d = b(a);
|
|
276
|
+
I(d) ? x(c, s, a) : P(c, a, n), L(c, i), y(c);
|
|
240
277
|
};
|
|
241
278
|
document.addEventListener("keydown", e);
|
|
242
279
|
}
|
|
@@ -286,70 +323,71 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
|
|
|
286
323
|
try {
|
|
287
324
|
const e = _();
|
|
288
325
|
if (!e) return !1;
|
|
289
|
-
const t = e.innerHTML, r = () => (
|
|
326
|
+
const t = e.innerHTML, r = () => (L(e, t), y(e), !0), n = O(e);
|
|
290
327
|
if (!n) return !1;
|
|
291
|
-
|
|
328
|
+
z(e, n);
|
|
329
|
+
const o = M(n.startContainer);
|
|
292
330
|
if (!o) return !1;
|
|
293
|
-
const
|
|
294
|
-
if (
|
|
295
|
-
const
|
|
296
|
-
if (
|
|
297
|
-
const
|
|
298
|
-
let
|
|
299
|
-
return
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
}), !
|
|
304
|
-
}),
|
|
331
|
+
const a = o.closest('ul[data-type="checklist"]');
|
|
332
|
+
if (a && e.contains(a)) {
|
|
333
|
+
const l = T(a);
|
|
334
|
+
if (l.length === 0) return !1;
|
|
335
|
+
const h = document.createDocumentFragment();
|
|
336
|
+
let f = null;
|
|
337
|
+
return l.forEach((m, E) => {
|
|
338
|
+
const g = q(m);
|
|
339
|
+
g.forEach((w) => {
|
|
340
|
+
h.appendChild(w), !f && (m.contains(n.startContainer) || E === 0) && (f = w);
|
|
341
|
+
}), !f && E === 0 && g[0] && (f = g[0]);
|
|
342
|
+
}), a.replaceWith(h), f && C(f, e), r();
|
|
305
343
|
}
|
|
306
|
-
const
|
|
307
|
-
if (
|
|
308
|
-
let
|
|
309
|
-
if (
|
|
310
|
-
|
|
344
|
+
const s = o.closest("ul, ol");
|
|
345
|
+
if (s && e.contains(s)) {
|
|
346
|
+
let l;
|
|
347
|
+
if (s.tagName.toLowerCase() === "ul")
|
|
348
|
+
l = s;
|
|
311
349
|
else {
|
|
312
|
-
for (
|
|
313
|
-
|
|
314
|
-
|
|
350
|
+
for (l = document.createElement("ul"); s.firstChild; )
|
|
351
|
+
l.appendChild(s.firstChild);
|
|
352
|
+
s.replaceWith(l);
|
|
315
353
|
}
|
|
316
|
-
|
|
317
|
-
let
|
|
318
|
-
|
|
319
|
-
let
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
const
|
|
323
|
-
|
|
354
|
+
l.setAttribute("data-type", "checklist");
|
|
355
|
+
let h = T(l);
|
|
356
|
+
h.length === 0 && (l.appendChild(k("")), h = T(l));
|
|
357
|
+
let f = null;
|
|
358
|
+
h.forEach((E) => {
|
|
359
|
+
E.setAttribute("data-type", "checklist-item"), E.hasAttribute("data-checked") || E.setAttribute("data-checked", "false");
|
|
360
|
+
const g = b(E);
|
|
361
|
+
E.contains(n.startContainer) && (f = g);
|
|
324
362
|
});
|
|
325
|
-
const m =
|
|
326
|
-
return C(
|
|
363
|
+
const m = l.querySelector(':scope > li[data-type="checklist-item"] > p');
|
|
364
|
+
return C(f || m || l, e), r();
|
|
327
365
|
}
|
|
328
|
-
const c =
|
|
366
|
+
const c = F(n, e);
|
|
329
367
|
if (c.length > 1) {
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}), c[0].replaceWith(
|
|
368
|
+
const l = document.createElement("ul");
|
|
369
|
+
l.setAttribute("data-type", "checklist"), c.forEach((m) => {
|
|
370
|
+
l.appendChild(k(m.innerHTML));
|
|
371
|
+
}), c[0].replaceWith(l), c.slice(1).forEach((m) => {
|
|
334
372
|
m.isConnected && m.remove();
|
|
335
373
|
});
|
|
336
|
-
const
|
|
337
|
-
return
|
|
374
|
+
const f = l.querySelector(':scope > li[data-type="checklist-item"] > p');
|
|
375
|
+
return f && C(f, e), r();
|
|
338
376
|
}
|
|
339
|
-
const
|
|
340
|
-
if (
|
|
341
|
-
const
|
|
342
|
-
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
const
|
|
346
|
-
return
|
|
377
|
+
const u = c[0] || o.closest("p, h1, h2, h3, h4, h5, h6, blockquote, pre");
|
|
378
|
+
if (u && u !== e) {
|
|
379
|
+
const l = document.createElement("ul");
|
|
380
|
+
l.setAttribute("data-type", "checklist");
|
|
381
|
+
const h = k(u.innerHTML);
|
|
382
|
+
l.appendChild(h), u.replaceWith(l);
|
|
383
|
+
const f = h.querySelector(":scope > p");
|
|
384
|
+
return f && C(f, e), r();
|
|
347
385
|
}
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
const p =
|
|
386
|
+
const i = document.createElement("ul");
|
|
387
|
+
i.setAttribute("data-type", "checklist");
|
|
388
|
+
const d = k("");
|
|
389
|
+
i.appendChild(d), n.deleteContents(), n.insertNode(i);
|
|
390
|
+
const p = d.querySelector(":scope > p");
|
|
353
391
|
return p && C(p, e), r();
|
|
354
392
|
} catch (e) {
|
|
355
393
|
return console.error("Failed to toggle checklist:", e), !1;
|
|
@@ -361,5 +399,5 @@ const M = "__editoraCommandEditorRoot", H = (e) => {
|
|
|
361
399
|
}
|
|
362
400
|
});
|
|
363
401
|
export {
|
|
364
|
-
|
|
402
|
+
V as ChecklistPlugin
|
|
365
403
|
};
|