@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
|
@@ -141,6 +141,7 @@ var Pl = /* @__PURE__ */ Qr(On, 9, 0), kl = /* @__PURE__ */ Qr(On, 9, 1), Fl = /
|
|
|
141
141
|
"stream finished",
|
|
142
142
|
"no stream handler",
|
|
143
143
|
,
|
|
144
|
+
// determined by compression function
|
|
144
145
|
"no callback",
|
|
145
146
|
"invalid UTF-8 data",
|
|
146
147
|
"extra field too long",
|
|
@@ -4059,7 +4060,7 @@ var ho, pu, gu, ds = ["times"];
|
|
|
4059
4060
|
}));
|
|
4060
4061
|
}
|
|
4061
4062
|
function r() {
|
|
4062
|
-
return (Ht.DOMPurify ? Promise.resolve(Ht.DOMPurify) : import("./purify.es-
|
|
4063
|
+
return (Ht.DOMPurify ? Promise.resolve(Ht.DOMPurify) : import("./purify.es-Dewe88eZ.mjs")).catch((function(c) {
|
|
4063
4064
|
return Promise.reject(new Error("Could not load dompurify: " + c));
|
|
4064
4065
|
})).then((function(c) {
|
|
4065
4066
|
return c.default ? c.default : c;
|
|
@@ -7082,7 +7083,7 @@ function wu(n) {
|
|
|
7082
7083
|
*/
|
|
7083
7084
|
(function(n) {
|
|
7084
7085
|
function e() {
|
|
7085
|
-
return (Ht.canvg ? Promise.resolve(Ht.canvg) : import("./index.es-
|
|
7086
|
+
return (Ht.canvg ? Promise.resolve(Ht.canvg) : import("./index.es-B7pVaNEV.mjs")).catch((function(r) {
|
|
7086
7087
|
return Promise.reject(new Error("Could not load canvg: " + r));
|
|
7087
7088
|
})).then((function(r) {
|
|
7088
7089
|
return r.default ? r.default : r;
|
package/dist/link.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let a=null,
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const O=require("./dialogHelpers-zU6zpMIA.js"),k=require("./historyHelpers-Cu8Pk7m1.js");let a=null,m="",g=!1,l=null;const y='[data-theme="dark"], .dark, .editora-theme-dark',z=new Set(["http:","https:","mailto:","tel:","sms:","ftp:"]),C="Enter a valid URL, e.g. https://example.com, /page, #section or mailto:name@example.com",R=e=>{const t=e.trim();if(!t)return{error:"Please enter a URL."};if(/\s/.test(t))return{error:"The URL cannot contain spaces."};if(/^(#|\/(?!\/)|\?|\.{1,2}\/)/.test(t))return{url:t};if(/^localhost(:\d+)?([/?#]|$)/i.test(t)||/^[^\s/:@]+:\d+([/?#]|$)/.test(t))return{url:`https://${t}`};const o=t.match(/^([a-z][a-z0-9+.-]*):/i);if(o){const r=`${o[1].toLowerCase()}:`;if(!z.has(r))return{error:"Links must use http, https, mailto or tel."};if(r==="http:"||r==="https:"||r==="ftp:")try{if(!new URL(t).hostname)return{error:C}}catch{return{error:C}}return{url:t}}return t.startsWith("//")?{url:`https:${t}`}:/^[^\s@/]+@[^\s@/]+\.[^\s@/]+$/.test(t)?{url:`mailto:${t}`}:/^[^\s/]+\.[^\s/]+/.test(t)?{url:`https://${t}`}:{error:C}},H="p, div, ul, ol, li, table, blockquote, pre, h1, h2, h3, h4, h5, h6",q=(e,t)=>e.replace(/[\r\n]+/g,"")===t.replace(/[\r\n]+/g,""),x=e=>{e?.dispatchEvent(new Event("input",{bubbles:!0}))},v=e=>{if(!e)return null;let t=e;for(;t;){if(t.hasAttribute("contenteditable")&&t.getAttribute("contenteditable")==="true"||t.hasAttribute("data-editora-content"))return t;t=t.parentElement}return null},I=e=>{if(e){const o=e.startContainer;if((o.nodeType===Node.ELEMENT_NODE?o:o.parentElement)?.closest(y))return!0}return document.activeElement?.closest(y)?!0:document.body.matches(y)||document.documentElement.matches(y)},$=()=>{if(document.getElementById("rte-link-dialog-theme-styles"))return;const e=document.createElement("style");e.id="rte-link-dialog-theme-styles",e.textContent=`
|
|
2
2
|
.link-dialog-overlay.rte-theme-dark .link-dialog {
|
|
3
3
|
background: #1f2937 !important;
|
|
4
4
|
border: 1px solid #4b5563 !important;
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
.link-dialog-overlay.rte-theme-dark .btn-submit:hover {
|
|
62
62
|
background: #2563eb !important;
|
|
63
63
|
}
|
|
64
|
-
`,document.head.appendChild(e)},
|
|
64
|
+
`,document.head.appendChild(e)},U=e=>{if(!a){console.warn("No selection range stored");return}const t=a.startContainer,o=t.nodeType===Node.TEXT_NODE?t.parentElement:t,r=v(o);if(!r)return;const d=r.innerHTML;if(g&&l){l.setAttribute("href",e.url),l.textContent!==e.text&&(l.textContent=e.text),l.target=e.target,e.target==="_blank"?l.setAttribute("rel","noopener noreferrer"):l.removeAttribute("rel"),e.title?l.title=e.title:l.removeAttribute("title");const n=document.createRange();n.selectNodeContents(l);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(n))}else{const n=document.createElement("a");n.setAttribute("href",e.url),n.textContent=e.text,n.target=e.target,e.target==="_blank"&&n.setAttribute("rel","noopener noreferrer"),e.title&&(n.title=e.title);const i=!a.collapsed&&!!a.cloneContents().querySelector(H);if(i&&q(e.text,m)){const L=new Set(Array.from(r.querySelectorAll("a"))),f=window.getSelection();f&&(f.removeAllRanges(),f.addRange(a)),r.focus(),document.execCommand("createLink",!1,e.url),r.querySelectorAll("a").forEach(u=>{L.has(u)||(u.setAttribute("target",e.target),e.target==="_blank"&&u.setAttribute("rel","noopener noreferrer"),e.title&&u.setAttribute("title",e.title))}),k.recordDomHistory(r,d),x(r),a=null,m="",g=!1,l=null;return}!a.collapsed&&e.text===m&&!i?(n.textContent="",n.appendChild(a.extractContents())):a.deleteContents(),a.insertNode(n),a.setStartAfter(n),a.setEndAfter(n);const b=window.getSelection();b&&(b.removeAllRanges(),b.addRange(a))}r.focus(),k.recordDomHistory(r,d),x(r),a=null,m="",g=!1,l=null},S=(e,t)=>{document.querySelectorAll(".link-dialog-overlay").forEach(s=>s.remove()),$();const o=document.createElement("div");O.initDialogOverlay(o),o.className="link-dialog-overlay",t&&o.classList.add("rte-theme-dark"),o.style.cssText=`
|
|
65
65
|
position: fixed;
|
|
66
66
|
top: 0;
|
|
67
67
|
left: 0;
|
|
@@ -72,25 +72,26 @@
|
|
|
72
72
|
align-items: center;
|
|
73
73
|
justify-content: center;
|
|
74
74
|
z-index: 10000;
|
|
75
|
-
`;const
|
|
75
|
+
`;const r=document.createElement("div");r.className="link-dialog",r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("aria-labelledby","link-dialog-title"),r.style.cssText=`
|
|
76
76
|
background: white;
|
|
77
|
+
color: #1f2937;
|
|
78
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
77
79
|
border-radius: 8px;
|
|
78
80
|
width: 500px;
|
|
79
81
|
max-width: 90%;
|
|
80
82
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
|
|
81
|
-
`,
|
|
83
|
+
`,r.innerHTML=`
|
|
82
84
|
<div class="link-dialog-header" style="padding: 16px 20px; border-bottom: 1px solid #ddd; display: flex; justify-content: space-between; align-items: center;">
|
|
83
|
-
<h3 style="margin: 0; font-size: 18px;">${e.isEditing?"Edit Link":"Insert Link"}</h3>
|
|
84
|
-
<button class="link-dialog-close" style="background: none; border: none; font-size: 24px; cursor: pointer; padding: 0; width: 30px; height: 30px;">×</button>
|
|
85
|
+
<h3 id="link-dialog-title" style="margin: 0; font-size: 18px;">${e.isEditing?"Edit Link":"Insert Link"}</h3>
|
|
86
|
+
<button type="button" class="link-dialog-close" aria-label="Close" style="background: none; border: none; font-size: 24px; cursor: pointer; padding: 0; width: 30px; height: 30px;">×</button>
|
|
85
87
|
</div>
|
|
86
|
-
<form id="link-form">
|
|
88
|
+
<form id="link-form" novalidate>
|
|
87
89
|
<div class="link-dialog-body" style="padding: 20px;">
|
|
88
90
|
<div class="form-group" style="margin-bottom: 16px;">
|
|
89
91
|
<label for="link-text" style="display: block; margin-bottom: 6px; font-weight: 500;">Link Text:</label>
|
|
90
92
|
<input
|
|
91
93
|
id="link-text"
|
|
92
94
|
type="text"
|
|
93
|
-
value="${e.text||""}"
|
|
94
95
|
placeholder="Enter link text"
|
|
95
96
|
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
|
|
96
97
|
/>
|
|
@@ -99,19 +100,21 @@
|
|
|
99
100
|
<label for="link-url" style="display: block; margin-bottom: 6px; font-weight: 500;">URL:</label>
|
|
100
101
|
<input
|
|
101
102
|
id="link-url"
|
|
102
|
-
type="
|
|
103
|
-
|
|
103
|
+
type="text"
|
|
104
|
+
inputmode="url"
|
|
105
|
+
autocapitalize="off"
|
|
106
|
+
spellcheck="false"
|
|
104
107
|
placeholder="https://example.com"
|
|
105
|
-
|
|
108
|
+
aria-describedby="link-url-error"
|
|
106
109
|
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
|
|
107
110
|
/>
|
|
111
|
+
<div id="link-url-error" role="alert" hidden style="margin-top: 4px; font-size: 12px; color: #c62828;"></div>
|
|
108
112
|
</div>
|
|
109
113
|
<div class="form-group" style="margin-bottom: 16px;">
|
|
110
114
|
<label for="link-title" style="display: block; margin-bottom: 6px; font-weight: 500;">Title (optional):</label>
|
|
111
115
|
<input
|
|
112
116
|
id="link-title"
|
|
113
117
|
type="text"
|
|
114
|
-
value="${e.title||""}"
|
|
115
118
|
placeholder="Link tooltip text"
|
|
116
119
|
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
|
|
117
120
|
/>
|
|
@@ -129,10 +132,11 @@
|
|
|
129
132
|
</div>
|
|
130
133
|
</div>
|
|
131
134
|
<div class="link-dialog-footer" style="padding: 12px 20px; border-top: 1px solid #ddd; display: flex; justify-content: flex-end; gap: 10px;">
|
|
135
|
+
${e.isEditing?'<button type="button" class="btn-remove" style="padding: 8px 16px; border: 1px solid #dc3545; background: white; color: #dc3545; border-radius: 4px; cursor: pointer; margin-right: auto;">Remove Link</button>':""}
|
|
132
136
|
<button type="button" class="btn-cancel" style="padding: 8px 16px; border: 1px solid #ccc; background: white; border-radius: 4px; cursor: pointer;">Cancel</button>
|
|
133
137
|
<button type="submit" class="btn-submit" style="padding: 8px 16px; border: none; background: #007bff; color: white; border-radius: 4px; cursor: pointer;">
|
|
134
138
|
${e.isEditing?"Update Link":"Insert Link"}
|
|
135
139
|
</button>
|
|
136
140
|
</div>
|
|
137
141
|
</form>
|
|
138
|
-
`,
|
|
142
|
+
`,o.appendChild(r),document.body.appendChild(o);const d=r.querySelector("#link-form"),n=r.querySelector("#link-text"),i=r.querySelector("#link-url"),E=r.querySelector("#link-title"),b=r.querySelector("#link-target"),L=r.querySelector(".link-dialog-close"),f=r.querySelector(".btn-cancel"),u=r.querySelector(".btn-remove"),w=r.querySelector("#link-url-error");n.value=e.text||"",i.value=e.url||"",E.value=e.title||"",i.addEventListener("input",()=>{w.hidden=!0,i.removeAttribute("aria-invalid")});const A=s=>{s.key==="Escape"&&(s.preventDefault(),s.stopPropagation(),p())},p=()=>{document.removeEventListener("keydown",A,!0),o.remove()};L.addEventListener("click",p),f.addEventListener("click",p),u?.addEventListener("click",()=>{if(l){const s=v(l),h=s?s.innerHTML:"",c=l.parentNode;if(c){for(;l.firstChild;)c.insertBefore(l.firstChild,l);c.removeChild(l)}s&&(k.recordDomHistory(s,h),x(s))}a=null,m="",g=!1,l=null,p()}),o.addEventListener("click",s=>{s.target===o&&p()}),document.addEventListener("keydown",A,!0),d.addEventListener("submit",s=>{s.preventDefault();const h=R(i.value);if("error"in h){w.textContent=h.error,w.hidden=!1,i.setAttribute("aria-invalid","true"),i.focus();return}const c=h.url;i.value=c,U({text:n.value.trim()||c,url:c,target:b.checked?"_blank":"_self",title:E.value.trim()||void 0}),p()}),setTimeout(()=>n.focus(),100)},_=()=>{const e=window.getSelection();if(!e||e.rangeCount===0)return!1;const t=e.getRangeAt(0).cloneRange();a=t;const o=I(t),r=e.toString()||"";m=r;const d=t.startContainer,i=(d.nodeType===Node.TEXT_NODE?d.parentElement:d)?.closest("a");return i?(g=!0,l=i,S({text:i.textContent||"",url:i.getAttribute("href")||"",target:i.target||"_self",title:i.title||"",isEditing:!0},o)):(g=!1,l=null,S({text:r,url:"",target:"_self",isEditing:!1},o)),!0},M=()=>{const e=window.getSelection(),t=e&&e.rangeCount>0?e.getRangeAt(0).startContainer:null,o=t&&t.nodeType===Node.TEXT_NODE?t.parentElement:t,r=v(o),d=r?r.innerHTML:"";return document.execCommand("unlink",!1),r&&(k.recordDomHistory(r,d),x(r)),!0},T=(e,t)=>{typeof window<"u"&&window.registerEditorCommand?.(e,t)},N=()=>{T("openLinkDialog",_),T("removeLink",M),T("createLink",e=>{if(!e)return;const t=R(e);if("error"in t)return;const o=window.getSelection(),r=o&&o.rangeCount>0?o.getRangeAt(0).startContainer:null,d=r&&r.nodeType===Node.TEXT_NODE?r.parentElement:r,n=v(d),i=n?n.innerHTML:"";document.execCommand("createLink",!1,t.url),n&&(k.recordDomHistory(n,i),x(n))})};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",N):N());const B=()=>({name:"link",marks:{link:{attrs:{href:{},title:{default:null},target:{default:null}},parseDOM:[{tag:"a[href]",getAttrs:e=>({href:e.getAttribute("href"),title:e.getAttribute("title"),target:e.getAttribute("target")})}],toDOM:e=>["a",{href:e.attrs.href,title:e.attrs.title,target:e.attrs.target,rel:e.attrs.target==="_blank"?"noopener noreferrer":null},0]}},toolbar:[{label:"Link",command:"openLinkDialog",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M6.2 12.3a1 1 0 0 1 1.4 1.4l-2 2a2 2 0 1 0 2.6 2.8l4.8-4.8a1 1 0 0 0 0-1.4 1 1 0 1 1 1.4-1.3 2.9 2.9 0 0 1 0 4L9.6 20a3.9 3.9 0 0 1-5.5-5.5l2-2Zm11.6-.6a1 1 0 0 1-1.4-1.4l2-2a2 2 0 1 0-2.6-2.8L11 10.3a1 1 0 0 0 0 1.4A1 1 0 1 1 9.6 13a2.9 2.9 0 0 1 0-4L14.4 4a3.9 3.9 0 0 1 5.5 5.5l-2 2Z" fill-rule="nonzero"></path></svg>',shortcut:"Mod-k"}],commands:{openLinkDialog:_,removeLink:M},keymap:{"Mod-k":"openLinkDialog"}});exports.LinkPlugin=B;
|
package/dist/link.esm.js
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { i as M } from "./dialogHelpers-5d5BuOCW.mjs";
|
|
2
|
+
import { r as k } from "./historyHelpers-BEKwNOtA.mjs";
|
|
3
|
+
let a = null, m = "", g = !1, i = null;
|
|
4
|
+
const y = '[data-theme="dark"], .dark, .editora-theme-dark', O = /* @__PURE__ */ new Set(["http:", "https:", "mailto:", "tel:", "sms:", "ftp:"]), C = "Enter a valid URL, e.g. https://example.com, /page, #section or mailto:name@example.com", R = (e) => {
|
|
5
|
+
const t = e.trim();
|
|
6
|
+
if (!t) return { error: "Please enter a URL." };
|
|
7
|
+
if (/\s/.test(t)) return { error: "The URL cannot contain spaces." };
|
|
8
|
+
if (/^(#|\/(?!\/)|\?|\.{1,2}\/)/.test(t)) return { url: t };
|
|
9
|
+
if (/^localhost(:\d+)?([/?#]|$)/i.test(t) || /^[^\s/:@]+:\d+([/?#]|$)/.test(t))
|
|
10
|
+
return { url: `https://${t}` };
|
|
11
|
+
const n = t.match(/^([a-z][a-z0-9+.-]*):/i);
|
|
12
|
+
if (n) {
|
|
13
|
+
const r = `${n[1].toLowerCase()}:`;
|
|
14
|
+
if (!O.has(r))
|
|
15
|
+
return { error: "Links must use http, https, mailto or tel." };
|
|
16
|
+
if (r === "http:" || r === "https:" || r === "ftp:")
|
|
17
|
+
try {
|
|
18
|
+
if (!new URL(t).hostname) return { error: C };
|
|
19
|
+
} catch {
|
|
20
|
+
return { error: C };
|
|
21
|
+
}
|
|
22
|
+
return { url: t };
|
|
23
|
+
}
|
|
24
|
+
return t.startsWith("//") ? { url: `https:${t}` } : /^[^\s@/]+@[^\s@/]+\.[^\s@/]+$/.test(t) ? { url: `mailto:${t}` } : /^[^\s/]+\.[^\s/]+/.test(t) ? { url: `https://${t}` } : { error: C };
|
|
25
|
+
}, q = "p, div, ul, ol, li, table, blockquote, pre, h1, h2, h3, h4, h5, h6", H = (e, t) => e.replace(/[\r\n]+/g, "") === t.replace(/[\r\n]+/g, ""), x = (e) => {
|
|
26
|
+
e?.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
27
|
+
}, v = (e) => {
|
|
3
28
|
if (!e) return null;
|
|
4
29
|
let t = e;
|
|
5
30
|
for (; t; ) {
|
|
@@ -8,13 +33,13 @@ const p = '[data-theme="dark"], .dark, .editora-theme-dark', w = (e) => {
|
|
|
8
33
|
t = t.parentElement;
|
|
9
34
|
}
|
|
10
35
|
return null;
|
|
11
|
-
},
|
|
36
|
+
}, I = (e) => {
|
|
12
37
|
if (e) {
|
|
13
38
|
const n = e.startContainer;
|
|
14
|
-
if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(
|
|
39
|
+
if ((n.nodeType === Node.ELEMENT_NODE ? n : n.parentElement)?.closest(y)) return !0;
|
|
15
40
|
}
|
|
16
|
-
return document.activeElement?.closest(
|
|
17
|
-
},
|
|
41
|
+
return document.activeElement?.closest(y) ? !0 : document.body.matches(y) || document.documentElement.matches(y);
|
|
42
|
+
}, $ = () => {
|
|
18
43
|
if (document.getElementById("rte-link-dialog-theme-styles")) return;
|
|
19
44
|
const e = document.createElement("style");
|
|
20
45
|
e.id = "rte-link-dialog-theme-styles", e.textContent = `
|
|
@@ -81,31 +106,40 @@ const p = '[data-theme="dark"], .dark, .editora-theme-dark', w = (e) => {
|
|
|
81
106
|
background: #2563eb !important;
|
|
82
107
|
}
|
|
83
108
|
`, document.head.appendChild(e);
|
|
84
|
-
},
|
|
109
|
+
}, U = (e) => {
|
|
85
110
|
if (!a) {
|
|
86
111
|
console.warn("No selection range stored");
|
|
87
112
|
return;
|
|
88
113
|
}
|
|
89
|
-
const t = a.startContainer, n = t.nodeType === Node.TEXT_NODE ? t.parentElement : t,
|
|
90
|
-
if (
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
114
|
+
const t = a.startContainer, n = t.nodeType === Node.TEXT_NODE ? t.parentElement : t, r = v(n);
|
|
115
|
+
if (!r) return;
|
|
116
|
+
const d = r.innerHTML;
|
|
117
|
+
if (g && i) {
|
|
118
|
+
i.setAttribute("href", e.url), i.textContent !== e.text && (i.textContent = e.text), i.target = e.target, e.target === "_blank" ? i.setAttribute("rel", "noopener noreferrer") : i.removeAttribute("rel"), e.title ? i.title = e.title : i.removeAttribute("title");
|
|
119
|
+
const o = document.createRange();
|
|
120
|
+
o.selectNodeContents(i);
|
|
121
|
+
const l = window.getSelection();
|
|
122
|
+
l && (l.removeAllRanges(), l.addRange(o));
|
|
123
|
+
} else {
|
|
124
|
+
const o = document.createElement("a");
|
|
125
|
+
o.setAttribute("href", e.url), o.textContent = e.text, o.target = e.target, e.target === "_blank" && o.setAttribute("rel", "noopener noreferrer"), e.title && (o.title = e.title);
|
|
126
|
+
const l = !a.collapsed && !!a.cloneContents().querySelector(q);
|
|
127
|
+
if (l && H(e.text, m)) {
|
|
128
|
+
const L = new Set(Array.from(r.querySelectorAll("a"))), f = window.getSelection();
|
|
129
|
+
f && (f.removeAllRanges(), f.addRange(a)), r.focus(), document.execCommand("createLink", !1, e.url), r.querySelectorAll("a").forEach((u) => {
|
|
130
|
+
L.has(u) || (u.setAttribute("target", e.target), e.target === "_blank" && u.setAttribute("rel", "noopener noreferrer"), e.title && u.setAttribute("title", e.title));
|
|
131
|
+
}), k(r, d), x(r), a = null, m = "", g = !1, i = null;
|
|
132
|
+
return;
|
|
102
133
|
}
|
|
103
|
-
o.
|
|
134
|
+
!a.collapsed && e.text === m && !l ? (o.textContent = "", o.appendChild(a.extractContents())) : a.deleteContents(), a.insertNode(o), a.setStartAfter(o), a.setEndAfter(o);
|
|
135
|
+
const b = window.getSelection();
|
|
136
|
+
b && (b.removeAllRanges(), b.addRange(a));
|
|
104
137
|
}
|
|
105
|
-
|
|
106
|
-
|
|
138
|
+
r.focus(), k(r, d), x(r), a = null, m = "", g = !1, i = null;
|
|
139
|
+
}, S = (e, t) => {
|
|
140
|
+
document.querySelectorAll(".link-dialog-overlay").forEach((s) => s.remove()), $();
|
|
107
141
|
const n = document.createElement("div");
|
|
108
|
-
n.className = "link-dialog-overlay", t && n.classList.add("rte-theme-dark"), n.style.cssText = `
|
|
142
|
+
M(n), n.className = "link-dialog-overlay", t && n.classList.add("rte-theme-dark"), n.style.cssText = `
|
|
109
143
|
position: fixed;
|
|
110
144
|
top: 0;
|
|
111
145
|
left: 0;
|
|
@@ -117,26 +151,27 @@ const p = '[data-theme="dark"], .dark, .editora-theme-dark', w = (e) => {
|
|
|
117
151
|
justify-content: center;
|
|
118
152
|
z-index: 10000;
|
|
119
153
|
`;
|
|
120
|
-
const
|
|
121
|
-
|
|
154
|
+
const r = document.createElement("div");
|
|
155
|
+
r.className = "link-dialog", r.setAttribute("role", "dialog"), r.setAttribute("aria-modal", "true"), r.setAttribute("aria-labelledby", "link-dialog-title"), r.style.cssText = `
|
|
122
156
|
background: white;
|
|
157
|
+
color: #1f2937;
|
|
158
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
123
159
|
border-radius: 8px;
|
|
124
160
|
width: 500px;
|
|
125
161
|
max-width: 90%;
|
|
126
162
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
|
|
127
|
-
`,
|
|
163
|
+
`, r.innerHTML = `
|
|
128
164
|
<div class="link-dialog-header" style="padding: 16px 20px; border-bottom: 1px solid #ddd; display: flex; justify-content: space-between; align-items: center;">
|
|
129
|
-
<h3 style="margin: 0; font-size: 18px;">${e.isEditing ? "Edit Link" : "Insert Link"}</h3>
|
|
130
|
-
<button class="link-dialog-close" style="background: none; border: none; font-size: 24px; cursor: pointer; padding: 0; width: 30px; height: 30px;">×</button>
|
|
165
|
+
<h3 id="link-dialog-title" style="margin: 0; font-size: 18px;">${e.isEditing ? "Edit Link" : "Insert Link"}</h3>
|
|
166
|
+
<button type="button" class="link-dialog-close" aria-label="Close" style="background: none; border: none; font-size: 24px; cursor: pointer; padding: 0; width: 30px; height: 30px;">×</button>
|
|
131
167
|
</div>
|
|
132
|
-
<form id="link-form">
|
|
168
|
+
<form id="link-form" novalidate>
|
|
133
169
|
<div class="link-dialog-body" style="padding: 20px;">
|
|
134
170
|
<div class="form-group" style="margin-bottom: 16px;">
|
|
135
171
|
<label for="link-text" style="display: block; margin-bottom: 6px; font-weight: 500;">Link Text:</label>
|
|
136
172
|
<input
|
|
137
173
|
id="link-text"
|
|
138
174
|
type="text"
|
|
139
|
-
value="${e.text || ""}"
|
|
140
175
|
placeholder="Enter link text"
|
|
141
176
|
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
|
|
142
177
|
/>
|
|
@@ -145,19 +180,21 @@ const p = '[data-theme="dark"], .dark, .editora-theme-dark', w = (e) => {
|
|
|
145
180
|
<label for="link-url" style="display: block; margin-bottom: 6px; font-weight: 500;">URL:</label>
|
|
146
181
|
<input
|
|
147
182
|
id="link-url"
|
|
148
|
-
type="
|
|
149
|
-
|
|
183
|
+
type="text"
|
|
184
|
+
inputmode="url"
|
|
185
|
+
autocapitalize="off"
|
|
186
|
+
spellcheck="false"
|
|
150
187
|
placeholder="https://example.com"
|
|
151
|
-
|
|
188
|
+
aria-describedby="link-url-error"
|
|
152
189
|
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
|
|
153
190
|
/>
|
|
191
|
+
<div id="link-url-error" role="alert" hidden style="margin-top: 4px; font-size: 12px; color: #c62828;"></div>
|
|
154
192
|
</div>
|
|
155
193
|
<div class="form-group" style="margin-bottom: 16px;">
|
|
156
194
|
<label for="link-title" style="display: block; margin-bottom: 6px; font-weight: 500;">Title (optional):</label>
|
|
157
195
|
<input
|
|
158
196
|
id="link-title"
|
|
159
197
|
type="text"
|
|
160
|
-
value="${e.title || ""}"
|
|
161
198
|
placeholder="Link tooltip text"
|
|
162
199
|
style="width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; line-height: 1.45; box-sizing: border-box;"
|
|
163
200
|
/>
|
|
@@ -175,57 +212,89 @@ const p = '[data-theme="dark"], .dark, .editora-theme-dark', w = (e) => {
|
|
|
175
212
|
</div>
|
|
176
213
|
</div>
|
|
177
214
|
<div class="link-dialog-footer" style="padding: 12px 20px; border-top: 1px solid #ddd; display: flex; justify-content: flex-end; gap: 10px;">
|
|
215
|
+
${e.isEditing ? '<button type="button" class="btn-remove" style="padding: 8px 16px; border: 1px solid #dc3545; background: white; color: #dc3545; border-radius: 4px; cursor: pointer; margin-right: auto;">Remove Link</button>' : ""}
|
|
178
216
|
<button type="button" class="btn-cancel" style="padding: 8px 16px; border: 1px solid #ccc; background: white; border-radius: 4px; cursor: pointer;">Cancel</button>
|
|
179
217
|
<button type="submit" class="btn-submit" style="padding: 8px 16px; border: none; background: #007bff; color: white; border-radius: 4px; cursor: pointer;">
|
|
180
218
|
${e.isEditing ? "Update Link" : "Insert Link"}
|
|
181
219
|
</button>
|
|
182
220
|
</div>
|
|
183
221
|
</form>
|
|
184
|
-
`, n.appendChild(
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
222
|
+
`, n.appendChild(r), document.body.appendChild(n);
|
|
223
|
+
const d = r.querySelector("#link-form"), o = r.querySelector("#link-text"), l = r.querySelector("#link-url"), E = r.querySelector("#link-title"), b = r.querySelector("#link-target"), L = r.querySelector(".link-dialog-close"), f = r.querySelector(".btn-cancel"), u = r.querySelector(".btn-remove"), w = r.querySelector("#link-url-error");
|
|
224
|
+
o.value = e.text || "", l.value = e.url || "", E.value = e.title || "", l.addEventListener("input", () => {
|
|
225
|
+
w.hidden = !0, l.removeAttribute("aria-invalid");
|
|
226
|
+
});
|
|
227
|
+
const A = (s) => {
|
|
228
|
+
s.key === "Escape" && (s.preventDefault(), s.stopPropagation(), p());
|
|
229
|
+
}, p = () => {
|
|
230
|
+
document.removeEventListener("keydown", A, !0), n.remove();
|
|
189
231
|
};
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
232
|
+
L.addEventListener("click", p), f.addEventListener("click", p), u?.addEventListener("click", () => {
|
|
233
|
+
if (i) {
|
|
234
|
+
const s = v(i), h = s ? s.innerHTML : "", c = i.parentNode;
|
|
235
|
+
if (c) {
|
|
236
|
+
for (; i.firstChild; )
|
|
237
|
+
c.insertBefore(i.firstChild, i);
|
|
238
|
+
c.removeChild(i);
|
|
239
|
+
}
|
|
240
|
+
s && (k(s, h), x(s));
|
|
241
|
+
}
|
|
242
|
+
a = null, m = "", g = !1, i = null, p();
|
|
243
|
+
}), n.addEventListener("click", (s) => {
|
|
244
|
+
s.target === n && p();
|
|
245
|
+
}), document.addEventListener("keydown", A, !0), d.addEventListener("submit", (s) => {
|
|
193
246
|
s.preventDefault();
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
247
|
+
const h = R(l.value);
|
|
248
|
+
if ("error" in h) {
|
|
249
|
+
w.textContent = h.error, w.hidden = !1, l.setAttribute("aria-invalid", "true"), l.focus();
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const c = h.url;
|
|
253
|
+
l.value = c, U({
|
|
254
|
+
text: o.value.trim() || c,
|
|
255
|
+
url: c,
|
|
256
|
+
target: b.checked ? "_blank" : "_self",
|
|
257
|
+
title: E.value.trim() || void 0
|
|
258
|
+
}), p();
|
|
259
|
+
}), setTimeout(() => o.focus(), 100);
|
|
260
|
+
}, _ = () => {
|
|
203
261
|
const e = window.getSelection();
|
|
204
262
|
if (!e || e.rangeCount === 0) return !1;
|
|
205
263
|
const t = e.getRangeAt(0).cloneRange();
|
|
206
264
|
a = t;
|
|
207
|
-
const n =
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
265
|
+
const n = I(t), r = e.toString() || "";
|
|
266
|
+
m = r;
|
|
267
|
+
const d = t.startContainer, l = (d.nodeType === Node.TEXT_NODE ? d.parentElement : d)?.closest("a");
|
|
268
|
+
return l ? (g = !0, i = l, S({
|
|
269
|
+
text: l.textContent || "",
|
|
270
|
+
// The attribute, not the resolved .href - otherwise editing a relative or
|
|
271
|
+
// in-page link silently rewrites it to an absolute URL.
|
|
272
|
+
url: l.getAttribute("href") || "",
|
|
273
|
+
target: l.target || "_self",
|
|
274
|
+
title: l.title || "",
|
|
213
275
|
isEditing: !0
|
|
214
|
-
}, n)) : (
|
|
215
|
-
text:
|
|
276
|
+
}, n)) : (g = !1, i = null, S({
|
|
277
|
+
text: r,
|
|
216
278
|
url: "",
|
|
217
279
|
target: "_self",
|
|
218
280
|
isEditing: !1
|
|
219
281
|
}, n)), !0;
|
|
220
|
-
},
|
|
282
|
+
}, z = () => {
|
|
283
|
+
const e = window.getSelection(), t = e && e.rangeCount > 0 ? e.getRangeAt(0).startContainer : null, n = t && t.nodeType === Node.TEXT_NODE ? t.parentElement : t, r = v(n), d = r ? r.innerHTML : "";
|
|
284
|
+
return document.execCommand("unlink", !1), r && (k(r, d), x(r)), !0;
|
|
285
|
+
}, T = (e, t) => {
|
|
221
286
|
typeof window < "u" && window.registerEditorCommand?.(e, t);
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
|
|
287
|
+
}, N = () => {
|
|
288
|
+
T("openLinkDialog", _), T("removeLink", z), T("createLink", (e) => {
|
|
289
|
+
if (!e) return;
|
|
290
|
+
const t = R(e);
|
|
291
|
+
if ("error" in t) return;
|
|
292
|
+
const n = window.getSelection(), r = n && n.rangeCount > 0 ? n.getRangeAt(0).startContainer : null, d = r && r.nodeType === Node.TEXT_NODE ? r.parentElement : r, o = v(d), l = o ? o.innerHTML : "";
|
|
293
|
+
document.execCommand("createLink", !1, t.url), o && (k(o, l), x(o));
|
|
225
294
|
});
|
|
226
295
|
};
|
|
227
|
-
typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
228
|
-
const
|
|
296
|
+
typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", N) : N());
|
|
297
|
+
const K = () => ({
|
|
229
298
|
name: "link",
|
|
230
299
|
marks: {
|
|
231
300
|
link: {
|
|
@@ -266,13 +335,13 @@ const S = () => ({
|
|
|
266
335
|
}
|
|
267
336
|
],
|
|
268
337
|
commands: {
|
|
269
|
-
openLinkDialog:
|
|
270
|
-
removeLink:
|
|
338
|
+
openLinkDialog: _,
|
|
339
|
+
removeLink: z
|
|
271
340
|
},
|
|
272
341
|
keymap: {
|
|
273
342
|
"Mod-k": "openLinkDialog"
|
|
274
343
|
}
|
|
275
344
|
});
|
|
276
345
|
export {
|
|
277
|
-
|
|
346
|
+
K as LinkPlugin
|
|
278
347
|
};
|
package/dist/list.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=()=>m("insertUnorderedList"),u=()=>m("insertOrderedList");function g(){const o=window.getSelection();if(o&&o.rangeCount>0){const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("./historyHelpers-Cu8Pk7m1.js"),d=()=>m("insertUnorderedList"),u=()=>m("insertOrderedList");function g(){const o=window.getSelection();if(o&&o.rangeCount>0){const t=o.getRangeAt(0).startContainer,n=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest('[contenteditable="true"], .rte-content, .editora-content');if(n)return n}const e=document.activeElement;return e?e.getAttribute("contenteditable")==="true"?e:e.closest('[contenteditable="true"], .rte-content, .editora-content'):null}function p(o){o.querySelectorAll('ul:not([data-type="checklist"]), ol').forEach(t=>{Array.from(t.childNodes).forEach(n=>{if(n.nodeType===Node.TEXT_NODE){const l=(n.textContent||"").trim();if(!l){t.removeChild(n);return}const s=document.createElement("li");s.textContent=l,t.replaceChild(s,n);return}if(!(n instanceof HTMLElement)){t.removeChild(n);return}if(n.tagName==="LI")return;const i=document.createElement("li");for(;n.firstChild;)i.appendChild(n.firstChild);t.replaceChild(i,n)})})}const h=new Set(["P","DIV","UL","OL","LI","BLOCKQUOTE","H1","H2","H3","H4","H5","H6","TABLE","PRE","FIGURE","SECTION","ARTICLE","HEADER","FOOTER"]);function E(o){let e=null;Array.from(o.childNodes).forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE&&h.has(t.tagName)){e=null;return}t.nodeType===Node.TEXT_NODE&&!(t.textContent||"").trim()||(e||(e=document.createElement("p"),o.insertBefore(e,t)),e.appendChild(t))})}function m(o){const e=g();if(!e)return!1;const t=window.getSelection();if(!t||t.rangeCount===0)return!1;const r=t.getRangeAt(0);if(!e.contains(r.commonAncestorContainer))return!1;const n=e.innerHTML;e.focus({preventScroll:!0});const i=document.execCommand(o,!1);return p(e),E(e),f.recordDomHistory(e,n),e.dispatchEvent(new Event("input",{bubbles:!0})),i!==!1}const a=(o,e)=>{typeof window<"u"&&window.registerEditorCommand?.(o,e)},c=()=>{a("toggleBulletList",d),a("toggleOrderedList",u)};typeof window<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",c):c());const L=()=>({name:"list",nodes:{bulletList:{content:"listItem+",group:"block",parseDOM:[{tag:"ul"}],toDOM:()=>["ul",0]},orderedList:{content:"listItem+",group:"block",parseDOM:[{tag:"ol"}],toDOM:()=>["ol",0]},listItem:{content:"paragraph",parseDOM:[{tag:"li"}],toDOM:()=>["li",0]}},toolbar:[{label:"Bullet List",command:"toggleBulletList",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M11 5h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0 6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0 6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2ZM4.5 6c0 .4.1.8.4 1 .3.4.7.5 1.1.5.4 0 .8-.1 1-.4.4-.3.5-.7.5-1.1 0-.4-.1-.8-.4-1-.3-.4-.7-.5-1.1-.5-.4 0-.8.1-1 .4-.4.3-.5.7-.5 1.1Zm0 6c0 .4.1.8.4 1 .3.4.7.5 1.1.5.4 0 .8-.1 1-.4.4-.3.5-.7.5-1.1 0-.4-.1-.8-.4-1-.3-.4-.7-.5-1.1-.5-.4 0-.8.1-1 .4-.4.3-.5.7-.5 1.1Zm0 6c0 .4.1.8.4 1 .3.4.7.5 1.1.5.4 0 .8-.1 1-.4.4-.3.5-.7.5-1.1 0-.4-.1-.8-.4-1-.3-.4-.7-.5-1.1-.5-.4 0-.8.1-1 .4-.4.3-.5.7-.5 1.1Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-Shift-8"},{label:"Numbered List",command:"toggleOrderedList",type:"button",icon:'<svg width="24" height="24" focusable="false"><path d="M10 17h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2Zm0-6h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 1 1 0-2ZM6 4v3.5c0 .3-.2.5-.5.5a.5.5 0 0 1-.5-.5V5h-.5a.5.5 0 0 1 0-1H6Zm-1 8.8l.2.2h1.3c.3 0 .5.2.5.5s-.2.5-.5.5H4.9a1 1 0 0 1-.9-1V13c0-.4.3-.8.6-1l1.2-.4.2-.3a.2.2 0 0 0 0-.2l-.7.3a.5.5 0 0 1-.7-.3.5.5 0 0 1 .3-.6l.7-.4c.5-.2 1.1 0 1.4.4.3.5.3 1.1-.1 1.5l-1.2.7Zm0 3.7v.5c0 .3.2.5.5.5h1c.3 0 .5.2.5.5s-.2.5-.5.5h-1a1.5 1.5 0 0 1-1.5-1.5v-.5c0-.3.1-.6.3-.8l1.3-1.4c.3-.4.1-.9-.2-1-.1 0-.2 0-.3.2l-.4.5a.5.5 0 0 1-.7.1.5.5 0 0 1-.1-.7l.4-.5c.5-.5 1.2-.6 1.8-.4.6.3 1 .9 1 1.6 0 .4-.2.8-.5 1.1l-1.3 1.4-.3.4Z" fill-rule="evenodd"></path></svg>',shortcut:"Mod-Shift-7"}],commands:{toggleBulletList:d,toggleOrderedList:u},keymap:{"Mod-Shift-8":"toggleBulletList","Mod-Shift-7":"toggleOrderedList"}});exports.ListPlugin=L;
|
package/dist/list.esm.js
CHANGED
|
@@ -1,57 +1,90 @@
|
|
|
1
|
+
import { r as f } from "./historyHelpers-BEKwNOtA.mjs";
|
|
1
2
|
const d = () => m("insertUnorderedList"), u = () => m("insertOrderedList");
|
|
2
3
|
function g() {
|
|
3
4
|
const o = window.getSelection();
|
|
4
5
|
if (o && o.rangeCount > 0) {
|
|
5
|
-
const
|
|
6
|
-
if (
|
|
6
|
+
const t = o.getRangeAt(0).startContainer, n = (t.nodeType === Node.ELEMENT_NODE ? t : t.parentElement)?.closest('[contenteditable="true"], .rte-content, .editora-content');
|
|
7
|
+
if (n) return n;
|
|
7
8
|
}
|
|
8
|
-
const
|
|
9
|
-
return
|
|
9
|
+
const e = document.activeElement;
|
|
10
|
+
return e ? e.getAttribute("contenteditable") === "true" ? e : e.closest('[contenteditable="true"], .rte-content, .editora-content') : null;
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
-
o.querySelectorAll('ul:not([data-type="checklist"]), ol').forEach((
|
|
13
|
-
Array.from(
|
|
14
|
-
if (
|
|
15
|
-
const l = (
|
|
12
|
+
function p(o) {
|
|
13
|
+
o.querySelectorAll('ul:not([data-type="checklist"]), ol').forEach((t) => {
|
|
14
|
+
Array.from(t.childNodes).forEach((n) => {
|
|
15
|
+
if (n.nodeType === Node.TEXT_NODE) {
|
|
16
|
+
const l = (n.textContent || "").trim();
|
|
16
17
|
if (!l) {
|
|
17
|
-
|
|
18
|
+
t.removeChild(n);
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
21
|
const s = document.createElement("li");
|
|
21
|
-
s.textContent = l,
|
|
22
|
+
s.textContent = l, t.replaceChild(s, n);
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
|
-
if (!(
|
|
25
|
-
|
|
25
|
+
if (!(n instanceof HTMLElement)) {
|
|
26
|
+
t.removeChild(n);
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
|
-
if (
|
|
29
|
+
if (n.tagName === "LI")
|
|
29
30
|
return;
|
|
30
31
|
const i = document.createElement("li");
|
|
31
|
-
for (;
|
|
32
|
-
i.appendChild(
|
|
33
|
-
|
|
32
|
+
for (; n.firstChild; )
|
|
33
|
+
i.appendChild(n.firstChild);
|
|
34
|
+
t.replaceChild(i, n);
|
|
34
35
|
});
|
|
35
36
|
});
|
|
36
37
|
}
|
|
38
|
+
const h = /* @__PURE__ */ new Set([
|
|
39
|
+
"P",
|
|
40
|
+
"DIV",
|
|
41
|
+
"UL",
|
|
42
|
+
"OL",
|
|
43
|
+
"LI",
|
|
44
|
+
"BLOCKQUOTE",
|
|
45
|
+
"H1",
|
|
46
|
+
"H2",
|
|
47
|
+
"H3",
|
|
48
|
+
"H4",
|
|
49
|
+
"H5",
|
|
50
|
+
"H6",
|
|
51
|
+
"TABLE",
|
|
52
|
+
"PRE",
|
|
53
|
+
"FIGURE",
|
|
54
|
+
"SECTION",
|
|
55
|
+
"ARTICLE",
|
|
56
|
+
"HEADER",
|
|
57
|
+
"FOOTER"
|
|
58
|
+
]);
|
|
59
|
+
function E(o) {
|
|
60
|
+
let e = null;
|
|
61
|
+
Array.from(o.childNodes).forEach((t) => {
|
|
62
|
+
if (t.nodeType === Node.ELEMENT_NODE && h.has(t.tagName)) {
|
|
63
|
+
e = null;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
t.nodeType === Node.TEXT_NODE && !(t.textContent || "").trim() || (e || (e = document.createElement("p"), o.insertBefore(e, t)), e.appendChild(t));
|
|
67
|
+
});
|
|
68
|
+
}
|
|
37
69
|
function m(o) {
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
42
|
-
const r =
|
|
43
|
-
if (!
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
70
|
+
const e = g();
|
|
71
|
+
if (!e) return !1;
|
|
72
|
+
const t = window.getSelection();
|
|
73
|
+
if (!t || t.rangeCount === 0) return !1;
|
|
74
|
+
const r = t.getRangeAt(0);
|
|
75
|
+
if (!e.contains(r.commonAncestorContainer)) return !1;
|
|
76
|
+
const n = e.innerHTML;
|
|
77
|
+
e.focus({ preventScroll: !0 });
|
|
78
|
+
const i = document.execCommand(o, !1);
|
|
79
|
+
return p(e), E(e), f(e, n), e.dispatchEvent(new Event("input", { bubbles: !0 })), i !== !1;
|
|
47
80
|
}
|
|
48
|
-
const
|
|
49
|
-
typeof window < "u" && window.registerEditorCommand?.(o,
|
|
50
|
-
},
|
|
51
|
-
|
|
81
|
+
const a = (o, e) => {
|
|
82
|
+
typeof window < "u" && window.registerEditorCommand?.(o, e);
|
|
83
|
+
}, c = () => {
|
|
84
|
+
a("toggleBulletList", d), a("toggleOrderedList", u);
|
|
52
85
|
};
|
|
53
|
-
typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded",
|
|
54
|
-
const
|
|
86
|
+
typeof window < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", c) : c());
|
|
87
|
+
const C = () => ({
|
|
55
88
|
name: "list",
|
|
56
89
|
nodes: {
|
|
57
90
|
bulletList: {
|
|
@@ -98,5 +131,5 @@ const h = () => ({
|
|
|
98
131
|
}
|
|
99
132
|
});
|
|
100
133
|
export {
|
|
101
|
-
|
|
134
|
+
C as ListPlugin
|
|
102
135
|
};
|