@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
package/dist/a11y-checker.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const v=require("./escapeHtml-D2Zh82pD.js"),H=require("./dialogHelpers-zU6zpMIA.js"),T=new Set,C=[],f=t=>{C.push(t)},x='[data-theme="dark"], .dark, .editora-theme-dark';f({id:"image-alt-text",wcag:"1.1.1",description:"Images must have alt text",severity:"error",selector:"img",evaluate(t,n){const e=t;return e.hasAttribute("role")&&e.getAttribute("role")==="presentation"||e.hasAttribute("data-a11y-ignore")&&e.getAttribute("data-a11y-ignore")==="image-alt-text"||e.hasAttribute("alt")?null:{id:`img-alt-${n.cache.get("imgIdx")}`,rule:"image-alt-text",wcag:"1.1.1",severity:"error",message:"Image missing alt text",nodePath:n.cache.get("imgPath"),element:e,suggestion:"Add descriptive alt text to all images",fixable:!0,fixLabel:"Add empty alt"}},fix(t){t.element&&t.element.setAttribute("alt","")}});f({id:"empty-interactive",wcag:"4.1.2",description:"Interactive elements must have accessible names",severity:"error",selector:'button, a, [role="button"]',evaluate(t,n){const e=t;if(e.hasAttribute("data-a11y-ignore")&&e.getAttribute("data-a11y-ignore")==="empty-interactive")return null;const r=e.textContent?.trim(),a=e.hasAttribute("aria-label"),i=e.hasAttribute("aria-labelledby"),s=e.hasAttribute("title");return!r&&!a&&!i&&!s?{id:`interactive-empty-${n.cache.get("buttonIdx")}`,rule:"empty-interactive",wcag:"4.1.2",severity:"error",message:"Interactive element has no accessible name",nodePath:n.cache.get("buttonPath"),element:e,suggestion:"Add text, aria-label, aria-labelledby, or title",fixable:!0,fixLabel:"Add aria-label"}:null},fix(t){t.element&&t.element.setAttribute("aria-label","Button")}});f({id:"form-label",wcag:"1.3.1",description:"Form controls must have labels",severity:"error",selector:"input, textarea, select",evaluate(t,n){const e=t;if(e.hasAttribute("type")&&e.getAttribute("type")==="hidden"||e.hasAttribute("data-a11y-ignore")&&e.getAttribute("data-a11y-ignore")==="form-label")return null;const r=n.doc.querySelector(`label[for="${e.getAttribute("id")}"]`),a=e.hasAttribute("aria-label"),i=e.hasAttribute("aria-labelledby");return!r&&!a&&!i?{id:`form-label-${n.cache.get("inputIdx")}`,rule:"form-label",wcag:"1.3.1",severity:"error",message:"Form control missing label",nodePath:n.cache.get("inputPath"),element:e,suggestion:"Add <label>, aria-label, or aria-labelledby",fixable:!0,fixLabel:"Add aria-label"}:null},fix(t){t.element&&t.element.setAttribute("aria-label","Input")}});f({id:"table-headers",wcag:"1.3.1",description:"Tables must have header rows",severity:"error",selector:"table",evaluate(t,n){const e=t;if(e.hasAttribute("data-a11y-ignore")&&e.getAttribute("data-a11y-ignore")==="table-headers")return null;const r=e.querySelectorAll("th"),a=e.querySelectorAll("tr");return r.length===0&&a.length>0?{id:`table-no-headers-${n.cache.get("tableIdx")}`,rule:"table-headers",wcag:"1.3.1",severity:"error",message:"Table missing header row (<th> elements)",nodePath:n.cache.get("tablePath"),element:e,suggestion:"Add <th> elements to first row",fixable:!0,fixLabel:"Convert first row to headers"}:null},fix(t){if(t.element){const e=t.element.querySelector("tr");e&&Array.from(e.children).forEach(r=>{if(r.tagName==="TD"){const a=document.createElement("th");a.innerHTML=r.innerHTML,e.replaceChild(a,r)}})}}});f({id:"heading-empty",wcag:"1.3.1",description:"Headings must not be empty",severity:"error",selector:"h1, h2, h3, h4, h5, h6",evaluate(t,n){const e=t;if(e.hasAttribute("data-a11y-ignore")&&e.getAttribute("data-a11y-ignore")==="heading-empty")return null;const r=e.textContent?.replace(/\s+/g,"")||"",a=e.childNodes.length===1&&e.childNodes[0].nodeName==="BR";return!r&&!a?{id:`heading-empty-${n.cache.get("headingIdx")}`,rule:"heading-empty",wcag:"1.3.1",severity:"error",message:`Empty ${e.tagName.toLowerCase()} heading`,nodePath:n.cache.get("headingPath"),element:e,suggestion:"All headings must contain text",fixable:!1}:null}});f({id:"heading-order",wcag:"1.3.1",description:"Headings should not skip levels",severity:"warning",selector:"h1, h2, h3, h4, h5, h6",evaluate(t,n){const e=t,r=parseInt(e.tagName[1]),a=n.cache.get("previousHeadingLevel")||r;return n.cache.set("previousHeadingLevel",r),r-a>1?{id:`heading-order-${n.cache.get("headingIdx")}`,rule:"heading-order",wcag:"1.3.1",severity:"warning",message:`Heading skips level (${a} → ${r})`,nodePath:n.cache.get("headingPath"),element:e,suggestion:`Use heading level ${a+1} instead`,fixable:!1}:null}});f({id:"link-text",wcag:"2.4.4",description:"Links must have descriptive text",severity:"error",selector:"a",evaluate(t,n){const e=t;if(e.hasAttribute("data-a11y-ignore")&&e.getAttribute("data-a11y-ignore")==="link-text")return null;const r=e.textContent?.replace(/\s+/g,"").toLowerCase()||"",a=e.childNodes.length===1&&e.childNodes[0].nodeName==="BR",i=["clickhere","readmore","link","here","this","page"];return!r&&!a?{id:`link-empty-${n.cache.get("aIdx")}`,rule:"link-text",wcag:"2.4.4",severity:"error",message:"Link has no text content",nodePath:n.cache.get("aPath"),element:e,suggestion:"All links must have descriptive text",fixable:!0,fixLabel:"Insert placeholder"}:i.some(s=>r.includes(s))?{id:`link-vague-${n.cache.get("aIdx")}`,rule:"link-text",wcag:"2.4.4",severity:"warning",message:`Vague link text: "${e.textContent?.trim()}"`,nodePath:n.cache.get("aPath"),element:e,suggestion:"Use descriptive link text",fixable:!1}:null},fix(t){t.element&&(t.element.textContent="Link")}});f({id:"list-structure",wcag:"1.3.1",description:"Lists must only contain <li> children",severity:"error",selector:"ul, ol",evaluate(t,n){const e=t;if(e.hasAttribute("data-a11y-ignore")&&e.getAttribute("data-a11y-ignore")==="list-structure")return null;const r=e.querySelectorAll(":scope > li");return Array.from(e.children).filter(i=>i.tagName!=="LI").length>0?{id:`list-structure-${n.cache.get("ulIdx")}`,rule:"list-structure",wcag:"1.3.1",severity:"error",message:"List contains non-li elements",nodePath:n.cache.get("ulPath"),element:e,suggestion:"All direct children of ul/ol must be li elements",fixable:!1}:r.length===0?{id:`list-empty-${n.cache.get("ulIdx")}`,rule:"list-structure",wcag:"1.3.1",severity:"warning",message:"Empty list element",nodePath:n.cache.get("ulPath"),element:e,suggestion:"Remove empty lists or add list items",fixable:!1}:null}});const w=()=>{const t=window.getSelection();if(t&&t.rangeCount>0){let e=t.getRangeAt(0).startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const r=e;if(r.getAttribute("contenteditable")==="true")return r}e=e.parentNode}}const n=document.activeElement;if(n){if(n.getAttribute("contenteditable")==="true")return n;const e=n.closest('[contenteditable="true"]');if(e)return e}return document.querySelector('[contenteditable="true"]')},I=()=>{if(w()?.closest(x))return!0;const n=window.getSelection();if(n&&n.rangeCount>0){const r=n.getRangeAt(0).startContainer;if((r.nodeType===Node.ELEMENT_NODE?r:r.parentElement)?.closest(x))return!0}return document.activeElement?.closest(x)?!0:document.body.matches(x)||document.documentElement.matches(x)},k=()=>{const t=w();if(!t)return[];const n=[],e={doc:t.ownerDocument||document,cache:new Map},r=e.doc.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null);let a=r.currentNode;const i={},s={};let p=0;for(;a&&p<5e3;){const h=a,o=h.tagName?.toLowerCase?.()||"";if(h.hidden||h.style.display==="none"||h.style.visibility==="hidden"){a=r.nextNode(),p++;continue}i[o]=(i[o]||0)+1,s[o]=`${o}[${i[o]-1}]`;for(const g of C){if(T.has(g.id)||g.selector&&!a.matches?.(g.selector))continue;e.cache.set(`${o}Idx`,i[o]-1),e.cache.set(`${o}Path`,s[o]),/^h[1-6]$/.test(o)&&(e.cache.set("headingIdx",i[o]-1),e.cache.set("headingPath",s[o])),o==="a"&&(e.cache.set("aIdx",i[o]-1),e.cache.set("aPath",s[o])),o==="table"&&(e.cache.set("tableIdx",i[o]-1),e.cache.set("tablePath",s[o])),o==="button"&&(e.cache.set("buttonIdx",i[o]-1),e.cache.set("buttonPath",s[o])),o==="input"&&(e.cache.set("inputIdx",i[o]-1),e.cache.set("inputPath",s[o])),(o==="ul"||o==="ol")&&(e.cache.set("ulIdx",i[o]-1),e.cache.set("ulPath",s[o]));const m=g.evaluate(a,e);m&&n.push(m)}a=r.nextNode(),p++}return n},b=(t,n=!0)=>{t.element&&(n?(t.element.classList.add("a11y-highlighted"),t.element.style.outline="2px solid #ff9800",t.element.style.backgroundColor="#fff3cd"):(t.element.classList.remove("a11y-highlighted"),t.element.style.outline="",t.element.style.backgroundColor=""))},P=t=>{t||(t=k());const n=t.filter(a=>a.severity==="error").length,e=t.filter(a=>a.severity==="warning").length,r=100-n*20-e*5;return Math.max(0,r)},N=t=>{const n=C.find(e=>e.id===t.rule);n&&n.fix&&n.fix(t)},$=()=>{document.querySelectorAll(".a11y-dialog-overlay").forEach(d=>d.remove());const t=k(),n=P(t),r=I()?{overlay:"rgba(0, 0, 0, 0.62)",dialogBg:"#1f2937",panelBg:"#222d3a",border:"#3b4657",text:"#e2e8f0",muted:"#9fb0c6",closeHover:"#334155",summaryBg:"#111827",issueBg:"#1f2937",issueHoverBg:"#273244",issueBorder:"#4b5563",issueHoverBorder:"#58a6ff",fixBtn:"#3b82f6",fixBtnHover:"#2563eb"}:{overlay:"rgba(0, 0, 0, 0.5)",dialogBg:"#ffffff",panelBg:"#ffffff",border:"#e0e0e0",text:"#1f2937",muted:"#666666",closeHover:"#f0f0f0",summaryBg:"#f5f5f5",issueBg:"#ffffff",issueHoverBg:"#f5f9ff",issueBorder:"#e0e0e0",issueHoverBorder:"#2196f3",fixBtn:"#2196f3",fixBtnHover:"#1976d2"},a=document.createElement("div");H.initDialogOverlay(a),a.className="a11y-dialog-overlay",a.style.cssText=`
|
|
2
2
|
position: fixed;
|
|
3
3
|
top: 0;
|
|
4
4
|
left: 0;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
display: flex;
|
|
10
10
|
align-items: center;
|
|
11
11
|
justify-content: center;
|
|
12
|
-
`;const
|
|
12
|
+
`;const i=document.createElement("div");i.className="a11y-dialog",i.style.cssText=`
|
|
13
13
|
background: ${r.dialogBg};
|
|
14
14
|
border: 1px solid ${r.border};
|
|
15
15
|
color: ${r.text};
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
border-radius: 4px;
|
|
35
35
|
background: ${n>=80?"#4caf50":n>=60?"#ff9800":"#f44336"};
|
|
36
36
|
color: white;
|
|
37
|
-
`,h.textContent=`${n}/100`;const
|
|
37
|
+
`,h.textContent=`${n}/100`;const o=document.createElement("button");o.textContent="✕",o.style.cssText=`
|
|
38
38
|
background: none;
|
|
39
39
|
border: none;
|
|
40
40
|
font-size: 24px;
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
justify-content: center;
|
|
48
48
|
border-radius: 4px;
|
|
49
49
|
color: ${r.muted};
|
|
50
|
-
`,
|
|
50
|
+
`,o.onmouseover=()=>{o.style.background=r.closeHover,o.style.color="#f8fafc"},o.onmouseout=()=>{o.style.background="none",o.style.color=r.muted},o.onclick=()=>{t.forEach(d=>b(d,!1)),a.remove()};const g=document.createElement("div");g.style.cssText="display: flex; align-items: center; gap: 16px;",g.appendChild(p),g.appendChild(h),s.appendChild(g),s.appendChild(o);const m=document.createElement("div");if(m.style.cssText=`
|
|
51
51
|
flex: 1;
|
|
52
52
|
overflow-y: auto;
|
|
53
53
|
padding: 20px;
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
<h3 style="margin: 0 0 8px 0; color: #4caf50;">No issues found!</h3>
|
|
59
59
|
<p style="margin: 0; color: ${r.muted};">Your content meets WCAG 2.1 AA standards.</p>
|
|
60
60
|
</div>
|
|
61
|
-
`;else{const
|
|
61
|
+
`;else{const d=document.createElement("div");d.style.cssText=`
|
|
62
62
|
background: ${r.summaryBg};
|
|
63
63
|
border: 1px solid ${r.border};
|
|
64
64
|
padding: 12px 16px;
|
|
@@ -66,11 +66,11 @@
|
|
|
66
66
|
margin-bottom: 20px;
|
|
67
67
|
display: flex;
|
|
68
68
|
gap: 20px;
|
|
69
|
-
`;const y=t.filter(l=>l.severity==="error").length
|
|
69
|
+
`;const y=t.filter(l=>l.severity==="error").length,E=t.filter(l=>l.severity==="warning").length,L=t.filter(l=>l.severity==="info").length;d.innerHTML=`
|
|
70
70
|
<div><strong style="color: #f44336;">${y}</strong> <span style="color: ${r.muted};">Errors</span></div>
|
|
71
|
-
<div><strong style="color: #ff9800;">${
|
|
72
|
-
<div><strong style="color: #2196f3;">${
|
|
73
|
-
`,m.appendChild(
|
|
71
|
+
<div><strong style="color: #ff9800;">${E}</strong> <span style="color: ${r.muted};">Warnings</span></div>
|
|
72
|
+
<div><strong style="color: #2196f3;">${L}</strong> <span style="color: ${r.muted};">Info</span></div>
|
|
73
|
+
`,m.appendChild(d),t.forEach(l=>{const u=document.createElement("div");u.style.cssText=`
|
|
74
74
|
border: 1px solid ${r.issueBorder};
|
|
75
75
|
border-radius: 6px;
|
|
76
76
|
padding: 16px;
|
|
@@ -78,10 +78,10 @@
|
|
|
78
78
|
transition: all 0.2s;
|
|
79
79
|
background: ${r.issueBg};
|
|
80
80
|
color: ${r.text};
|
|
81
|
-
`,
|
|
81
|
+
`,u.onmouseover=()=>{u.style.borderColor=r.issueHoverBorder,u.style.background=r.issueHoverBg,b(l,!0)},u.onmouseout=()=>{u.style.borderColor=r.issueBorder,u.style.background=r.issueBg,b(l,!1)};const B=l.severity==="error"?"#f44336":l.severity==="warning"?"#ff9800":"#2196f3";if(u.innerHTML=`
|
|
82
82
|
<div style="display: flex; align-items: start; gap: 12px; margin-bottom: 8px;">
|
|
83
83
|
<span style="
|
|
84
|
-
background: ${
|
|
84
|
+
background: ${B};
|
|
85
85
|
color: white;
|
|
86
86
|
padding: 2px 8px;
|
|
87
87
|
border-radius: 4px;
|
|
@@ -90,14 +90,14 @@
|
|
|
90
90
|
text-transform: uppercase;
|
|
91
91
|
">${l.severity}</span>
|
|
92
92
|
<div style="flex: 1;">
|
|
93
|
-
<div style="font-weight: 600; margin-bottom: 4px;">${l.message}</div>
|
|
94
|
-
<div style="font-size: 12px; color: ${r.muted};">WCAG ${l.wcag} · ${l.rule}</div>
|
|
93
|
+
<div style="font-weight: 600; margin-bottom: 4px;">${v.escapeHtml(l.message)}</div>
|
|
94
|
+
<div style="font-size: 12px; color: ${r.muted};">WCAG ${v.escapeHtml(l.wcag)} · ${v.escapeHtml(l.rule)}</div>
|
|
95
95
|
</div>
|
|
96
96
|
</div>
|
|
97
97
|
<div style="font-size: 14px; color: ${r.text}; margin-bottom: 8px; padding-left: 68px;">
|
|
98
|
-
${l.suggestion||""}
|
|
98
|
+
${v.escapeHtml(l.suggestion||"")}
|
|
99
99
|
</div>
|
|
100
|
-
`,l.fixable){const
|
|
100
|
+
`,l.fixable){const c=document.createElement("button");c.textContent=`🔧 ${l.fixLabel||"Auto-fix"}`,c.style.cssText=`
|
|
101
101
|
background: ${r.fixBtn};
|
|
102
102
|
color: white;
|
|
103
103
|
border: none;
|
|
@@ -106,4 +106,4 @@
|
|
|
106
106
|
cursor: pointer;
|
|
107
107
|
font-size: 13px;
|
|
108
108
|
margin-left: 68px;
|
|
109
|
-
`,
|
|
109
|
+
`,c.onmouseover=()=>c.style.background=r.fixBtnHover,c.onmouseout=()=>c.style.background=r.fixBtn,c.onclick=()=>{N(l),c.textContent="✓ Fixed",c.style.background="#4caf50",c.disabled=!0,c.style.cursor="not-allowed",b(l,!1),setTimeout(()=>{a.remove(),$()},1e3)},u.appendChild(c)}m.appendChild(u)})}i.appendChild(s),i.appendChild(m),a.appendChild(i),document.body.appendChild(a),a.onclick=d=>{d.target===a&&(t.forEach(y=>b(y,!1)),a.remove())};const A=d=>{d.key==="Escape"&&(t.forEach(y=>b(y,!1)),a.remove(),document.removeEventListener("keydown",A))};document.addEventListener("keydown",A)},M=()=>({name:"a11yChecker",toolbar:[{label:"Accessibility",command:"toggleA11yChecker",icon:'<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M9 6.82954C10.1652 6.4177 11 5.30646 11 4.00024C11 2.34339 9.65686 1.00024 8 1.00024C6.34315 1.00024 5 2.34339 5 4.00024C5 5.30646 5.83481 6.4177 7 6.82954V12.0002C7 13.6571 8.34315 15.0002 10 15.0002H14.9296C15.264 15.0002 15.5762 15.1673 15.7617 15.4455L18.4913 19.54C19.1914 20.5901 20.6772 20.7373 21.5696 19.8448L22.7071 18.7074C23.0976 18.3168 23.0976 17.6837 22.7071 17.2931C22.3166 16.9026 21.6834 16.9026 21.2929 17.2931L20.1554 18.4306L17.4258 14.3361C16.8694 13.5015 15.9327 13.0002 14.9296 13.0002H10C9.44772 13.0002 9 12.5525 9 12.0002V11.0002H15C15.5523 11.0002 16 10.5525 16 10.0002C16 9.44796 15.5523 9.00025 15 9.00025H9V6.82954ZM8 5.10758C7.38844 5.10758 6.89267 4.61181 6.89267 4.00024C6.89267 3.38868 7.38844 2.89291 8 2.89291C8.61157 2.89291 9.10734 3.38868 9.10734 4.00024C9.10734 4.61181 8.61157 5.10758 8 5.10758Z" fill="#0F0F0F"></path> <path d="M4.6328 9.07414C5.10517 8.78987 5.69738 9.0279 5.91645 9.53381C6.13552 10.0397 5.89604 10.6205 5.43795 10.9272C4.92993 11.2673 4.48018 11.6911 4.10882 12.1826C3.53598 12.9408 3.16922 13.8345 3.04425 14.7765C2.91928 15.7185 3.04036 16.6768 3.3957 17.5582C3.75103 18.4395 4.32852 19.2138 5.07194 19.8058C5.81535 20.3977 6.69937 20.787 7.63791 20.9359C8.57646 21.0847 9.53756 20.988 10.4276 20.6552C11.3177 20.3223 12.1065 19.7647 12.7171 19.0366C13.1129 18.5645 13.4251 18.0313 13.6428 17.46C13.8391 16.9448 14.3514 16.5813 14.8936 16.6815C15.4357 16.7816 15.8004 17.3054 15.6291 17.8295C15.3326 18.7372 14.8644 19.583 14.2468 20.3194C13.4147 21.3117 12.3399 22.0716 11.1269 22.5252C9.91394 22.9787 8.6042 23.1105 7.32518 22.9077C6.04617 22.7048 4.84148 22.1742 3.82838 21.3676C2.81528 20.561 2.02831 19.5058 1.54407 18.3047C1.05983 17.1037 0.894836 15.7977 1.06514 14.5139C1.23545 13.2302 1.73525 12.0124 2.51589 10.9791C3.09523 10.2123 3.81459 9.56654 4.6328 9.07414Z" fill="#0F0F0F"></path> </g></svg>',shortcut:"Mod-Shift-Alt-a"}],commands:{toggleA11yChecker:()=>{try{return $(),!0}catch(t){return console.error("Failed to open accessibility checker:",t),!1}}},keymap:{"Mod-Shift-Alt-a":"toggleA11yChecker"}});exports.A11yCheckerPlugin=M;
|
package/dist/a11y-checker.esm.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { e as v } from "./escapeHtml-DyksyvcZ.mjs";
|
|
2
|
+
import { i as T } from "./dialogHelpers-5d5BuOCW.mjs";
|
|
3
|
+
const H = /* @__PURE__ */ new Set(), C = [], f = (t) => {
|
|
4
|
+
C.push(t);
|
|
3
5
|
}, x = '[data-theme="dark"], .dark, .editora-theme-dark';
|
|
4
6
|
f({
|
|
5
7
|
id: "image-alt-text",
|
|
@@ -9,7 +11,7 @@ f({
|
|
|
9
11
|
selector: "img",
|
|
10
12
|
evaluate(t, n) {
|
|
11
13
|
const e = t;
|
|
12
|
-
return e.hasAttribute("role") && e.getAttribute("role") === "presentation" || e.hasAttribute("data-a11y-ignore") && e.getAttribute("data-a11y-ignore") === "image-alt-text"
|
|
14
|
+
return e.hasAttribute("role") && e.getAttribute("role") === "presentation" || e.hasAttribute("data-a11y-ignore") && e.getAttribute("data-a11y-ignore") === "image-alt-text" || e.hasAttribute("alt") ? null : {
|
|
13
15
|
id: `img-alt-${n.cache.get("imgIdx")}`,
|
|
14
16
|
rule: "image-alt-text",
|
|
15
17
|
wcag: "1.1.1",
|
|
@@ -20,7 +22,7 @@ f({
|
|
|
20
22
|
suggestion: "Add descriptive alt text to all images",
|
|
21
23
|
fixable: !0,
|
|
22
24
|
fixLabel: "Add empty alt"
|
|
23
|
-
}
|
|
25
|
+
};
|
|
24
26
|
},
|
|
25
27
|
fix(t) {
|
|
26
28
|
t.element && t.element.setAttribute("alt", "");
|
|
@@ -35,8 +37,8 @@ f({
|
|
|
35
37
|
evaluate(t, n) {
|
|
36
38
|
const e = t;
|
|
37
39
|
if (e.hasAttribute("data-a11y-ignore") && e.getAttribute("data-a11y-ignore") === "empty-interactive") return null;
|
|
38
|
-
const r = e.textContent?.trim(), a = e.hasAttribute("aria-label"),
|
|
39
|
-
return !r && !a && !
|
|
40
|
+
const r = e.textContent?.trim(), a = e.hasAttribute("aria-label"), i = e.hasAttribute("aria-labelledby"), s = e.hasAttribute("title");
|
|
41
|
+
return !r && !a && !i && !s ? {
|
|
40
42
|
id: `interactive-empty-${n.cache.get("buttonIdx")}`,
|
|
41
43
|
rule: "empty-interactive",
|
|
42
44
|
wcag: "4.1.2",
|
|
@@ -62,8 +64,8 @@ f({
|
|
|
62
64
|
evaluate(t, n) {
|
|
63
65
|
const e = t;
|
|
64
66
|
if (e.hasAttribute("type") && e.getAttribute("type") === "hidden" || e.hasAttribute("data-a11y-ignore") && e.getAttribute("data-a11y-ignore") === "form-label") return null;
|
|
65
|
-
const r = n.doc.querySelector(`label[for="${e.getAttribute("id")}"]`), a = e.hasAttribute("aria-label"),
|
|
66
|
-
return !r && !a && !
|
|
67
|
+
const r = n.doc.querySelector(`label[for="${e.getAttribute("id")}"]`), a = e.hasAttribute("aria-label"), i = e.hasAttribute("aria-labelledby");
|
|
68
|
+
return !r && !a && !i ? {
|
|
67
69
|
id: `form-label-${n.cache.get("inputIdx")}`,
|
|
68
70
|
rule: "form-label",
|
|
69
71
|
wcag: "1.3.1",
|
|
@@ -168,7 +170,7 @@ f({
|
|
|
168
170
|
evaluate(t, n) {
|
|
169
171
|
const e = t;
|
|
170
172
|
if (e.hasAttribute("data-a11y-ignore") && e.getAttribute("data-a11y-ignore") === "link-text") return null;
|
|
171
|
-
const r = e.textContent?.replace(/\s+/g, "").toLowerCase() || "", a = e.childNodes.length === 1 && e.childNodes[0].nodeName === "BR",
|
|
173
|
+
const r = e.textContent?.replace(/\s+/g, "").toLowerCase() || "", a = e.childNodes.length === 1 && e.childNodes[0].nodeName === "BR", i = ["clickhere", "readmore", "link", "here", "this", "page"];
|
|
172
174
|
return !r && !a ? {
|
|
173
175
|
id: `link-empty-${n.cache.get("aIdx")}`,
|
|
174
176
|
rule: "link-text",
|
|
@@ -180,7 +182,7 @@ f({
|
|
|
180
182
|
suggestion: "All links must have descriptive text",
|
|
181
183
|
fixable: !0,
|
|
182
184
|
fixLabel: "Insert placeholder"
|
|
183
|
-
} :
|
|
185
|
+
} : i.some((s) => r.includes(s)) ? {
|
|
184
186
|
id: `link-vague-${n.cache.get("aIdx")}`,
|
|
185
187
|
rule: "link-text",
|
|
186
188
|
wcag: "2.4.4",
|
|
@@ -206,7 +208,7 @@ f({
|
|
|
206
208
|
const e = t;
|
|
207
209
|
if (e.hasAttribute("data-a11y-ignore") && e.getAttribute("data-a11y-ignore") === "list-structure") return null;
|
|
208
210
|
const r = e.querySelectorAll(":scope > li");
|
|
209
|
-
return Array.from(e.children).filter((
|
|
211
|
+
return Array.from(e.children).filter((i) => i.tagName !== "LI").length > 0 ? {
|
|
210
212
|
id: `list-structure-${n.cache.get("ulIdx")}`,
|
|
211
213
|
rule: "list-structure",
|
|
212
214
|
wcag: "1.3.1",
|
|
@@ -229,7 +231,7 @@ f({
|
|
|
229
231
|
} : null;
|
|
230
232
|
}
|
|
231
233
|
});
|
|
232
|
-
const
|
|
234
|
+
const w = () => {
|
|
233
235
|
const t = window.getSelection();
|
|
234
236
|
if (t && t.rangeCount > 0) {
|
|
235
237
|
let e = t.getRangeAt(0).startContainer;
|
|
@@ -250,30 +252,32 @@ const A = () => {
|
|
|
250
252
|
if (e) return e;
|
|
251
253
|
}
|
|
252
254
|
return document.querySelector('[contenteditable="true"]');
|
|
253
|
-
},
|
|
254
|
-
if (
|
|
255
|
+
}, I = () => {
|
|
256
|
+
if (w()?.closest(x)) return !0;
|
|
255
257
|
const n = window.getSelection();
|
|
256
258
|
if (n && n.rangeCount > 0) {
|
|
257
259
|
const r = n.getRangeAt(0).startContainer;
|
|
258
260
|
if ((r.nodeType === Node.ELEMENT_NODE ? r : r.parentElement)?.closest(x)) return !0;
|
|
259
261
|
}
|
|
260
262
|
return document.activeElement?.closest(x) ? !0 : document.body.matches(x) || document.documentElement.matches(x);
|
|
261
|
-
},
|
|
262
|
-
const t =
|
|
263
|
+
}, k = () => {
|
|
264
|
+
const t = w();
|
|
263
265
|
if (!t) return [];
|
|
264
266
|
const n = [], e = { doc: t.ownerDocument || document, cache: /* @__PURE__ */ new Map() }, r = e.doc.createTreeWalker(t, NodeFilter.SHOW_ELEMENT, null);
|
|
265
|
-
let a = r.currentNode
|
|
267
|
+
let a = r.currentNode;
|
|
268
|
+
const i = {}, s = {};
|
|
269
|
+
let p = 0;
|
|
266
270
|
for (; a && p < 5e3; ) {
|
|
267
|
-
const h = a,
|
|
271
|
+
const h = a, o = h.tagName?.toLowerCase?.() || "";
|
|
268
272
|
if (h.hidden || h.style.display === "none" || h.style.visibility === "hidden") {
|
|
269
273
|
a = r.nextNode(), p++;
|
|
270
274
|
continue;
|
|
271
275
|
}
|
|
272
|
-
o
|
|
273
|
-
for (const
|
|
274
|
-
if (
|
|
275
|
-
e.cache.set(`${
|
|
276
|
-
const m =
|
|
276
|
+
i[o] = (i[o] || 0) + 1, s[o] = `${o}[${i[o] - 1}]`;
|
|
277
|
+
for (const g of C) {
|
|
278
|
+
if (H.has(g.id) || g.selector && !a.matches?.(g.selector)) continue;
|
|
279
|
+
e.cache.set(`${o}Idx`, i[o] - 1), e.cache.set(`${o}Path`, s[o]), /^h[1-6]$/.test(o) && (e.cache.set("headingIdx", i[o] - 1), e.cache.set("headingPath", s[o])), o === "a" && (e.cache.set("aIdx", i[o] - 1), e.cache.set("aPath", s[o])), o === "table" && (e.cache.set("tableIdx", i[o] - 1), e.cache.set("tablePath", s[o])), o === "button" && (e.cache.set("buttonIdx", i[o] - 1), e.cache.set("buttonPath", s[o])), o === "input" && (e.cache.set("inputIdx", i[o] - 1), e.cache.set("inputPath", s[o])), (o === "ul" || o === "ol") && (e.cache.set("ulIdx", i[o] - 1), e.cache.set("ulPath", s[o]));
|
|
280
|
+
const m = g.evaluate(a, e);
|
|
277
281
|
m && n.push(m);
|
|
278
282
|
}
|
|
279
283
|
a = r.nextNode(), p++;
|
|
@@ -281,16 +285,16 @@ const A = () => {
|
|
|
281
285
|
return n;
|
|
282
286
|
}, b = (t, n = !0) => {
|
|
283
287
|
t.element && (n ? (t.element.classList.add("a11y-highlighted"), t.element.style.outline = "2px solid #ff9800", t.element.style.backgroundColor = "#fff3cd") : (t.element.classList.remove("a11y-highlighted"), t.element.style.outline = "", t.element.style.backgroundColor = ""));
|
|
284
|
-
},
|
|
285
|
-
t || (t =
|
|
286
|
-
const n = t.filter((a) => a.severity === "error").length, e = t.filter((a) => a.severity === "warning").length;
|
|
287
|
-
let r = 100 - n * 20 - e * 5;
|
|
288
|
+
}, P = (t) => {
|
|
289
|
+
t || (t = k());
|
|
290
|
+
const n = t.filter((a) => a.severity === "error").length, e = t.filter((a) => a.severity === "warning").length, r = 100 - n * 20 - e * 5;
|
|
288
291
|
return Math.max(0, r);
|
|
289
|
-
},
|
|
290
|
-
const n =
|
|
292
|
+
}, N = (t) => {
|
|
293
|
+
const n = C.find((e) => e.id === t.rule);
|
|
291
294
|
n && n.fix && n.fix(t);
|
|
292
|
-
},
|
|
293
|
-
|
|
295
|
+
}, $ = () => {
|
|
296
|
+
document.querySelectorAll(".a11y-dialog-overlay").forEach((c) => c.remove());
|
|
297
|
+
const t = k(), n = P(t), r = I() ? {
|
|
294
298
|
overlay: "rgba(0, 0, 0, 0.62)",
|
|
295
299
|
dialogBg: "#1f2937",
|
|
296
300
|
panelBg: "#222d3a",
|
|
@@ -321,7 +325,7 @@ const A = () => {
|
|
|
321
325
|
fixBtn: "#2196f3",
|
|
322
326
|
fixBtnHover: "#1976d2"
|
|
323
327
|
}, a = document.createElement("div");
|
|
324
|
-
a.className = "a11y-dialog-overlay", a.style.cssText = `
|
|
328
|
+
T(a), a.className = "a11y-dialog-overlay", a.style.cssText = `
|
|
325
329
|
position: fixed;
|
|
326
330
|
top: 0;
|
|
327
331
|
left: 0;
|
|
@@ -333,8 +337,8 @@ const A = () => {
|
|
|
333
337
|
align-items: center;
|
|
334
338
|
justify-content: center;
|
|
335
339
|
`;
|
|
336
|
-
const
|
|
337
|
-
|
|
340
|
+
const i = document.createElement("div");
|
|
341
|
+
i.className = "a11y-dialog", i.style.cssText = `
|
|
338
342
|
background: ${r.dialogBg};
|
|
339
343
|
border: 1px solid ${r.border};
|
|
340
344
|
color: ${r.text};
|
|
@@ -366,8 +370,8 @@ const A = () => {
|
|
|
366
370
|
background: ${n >= 80 ? "#4caf50" : n >= 60 ? "#ff9800" : "#f44336"};
|
|
367
371
|
color: white;
|
|
368
372
|
`, h.textContent = `${n}/100`;
|
|
369
|
-
const
|
|
370
|
-
|
|
373
|
+
const o = document.createElement("button");
|
|
374
|
+
o.textContent = "✕", o.style.cssText = `
|
|
371
375
|
background: none;
|
|
372
376
|
border: none;
|
|
373
377
|
font-size: 24px;
|
|
@@ -380,15 +384,15 @@ const A = () => {
|
|
|
380
384
|
justify-content: center;
|
|
381
385
|
border-radius: 4px;
|
|
382
386
|
color: ${r.muted};
|
|
383
|
-
`,
|
|
384
|
-
|
|
385
|
-
},
|
|
386
|
-
|
|
387
|
-
},
|
|
388
|
-
t.forEach((
|
|
387
|
+
`, o.onmouseover = () => {
|
|
388
|
+
o.style.background = r.closeHover, o.style.color = "#f8fafc";
|
|
389
|
+
}, o.onmouseout = () => {
|
|
390
|
+
o.style.background = "none", o.style.color = r.muted;
|
|
391
|
+
}, o.onclick = () => {
|
|
392
|
+
t.forEach((c) => b(c, !1)), a.remove();
|
|
389
393
|
};
|
|
390
|
-
const
|
|
391
|
-
|
|
394
|
+
const g = document.createElement("div");
|
|
395
|
+
g.style.cssText = "display: flex; align-items: center; gap: 16px;", g.appendChild(p), g.appendChild(h), s.appendChild(g), s.appendChild(o);
|
|
392
396
|
const m = document.createElement("div");
|
|
393
397
|
if (m.style.cssText = `
|
|
394
398
|
flex: 1;
|
|
@@ -404,8 +408,8 @@ const A = () => {
|
|
|
404
408
|
</div>
|
|
405
409
|
`;
|
|
406
410
|
else {
|
|
407
|
-
const
|
|
408
|
-
|
|
411
|
+
const c = document.createElement("div");
|
|
412
|
+
c.style.cssText = `
|
|
409
413
|
background: ${r.summaryBg};
|
|
410
414
|
border: 1px solid ${r.border};
|
|
411
415
|
padding: 12px 16px;
|
|
@@ -414,14 +418,14 @@ const A = () => {
|
|
|
414
418
|
display: flex;
|
|
415
419
|
gap: 20px;
|
|
416
420
|
`;
|
|
417
|
-
const y = t.filter((l) => l.severity === "error").length,
|
|
418
|
-
|
|
421
|
+
const y = t.filter((l) => l.severity === "error").length, E = t.filter((l) => l.severity === "warning").length, L = t.filter((l) => l.severity === "info").length;
|
|
422
|
+
c.innerHTML = `
|
|
419
423
|
<div><strong style="color: #f44336;">${y}</strong> <span style="color: ${r.muted};">Errors</span></div>
|
|
420
|
-
<div><strong style="color: #ff9800;">${
|
|
421
|
-
<div><strong style="color: #2196f3;">${
|
|
422
|
-
`, m.appendChild(
|
|
423
|
-
const
|
|
424
|
-
|
|
424
|
+
<div><strong style="color: #ff9800;">${E}</strong> <span style="color: ${r.muted};">Warnings</span></div>
|
|
425
|
+
<div><strong style="color: #2196f3;">${L}</strong> <span style="color: ${r.muted};">Info</span></div>
|
|
426
|
+
`, m.appendChild(c), t.forEach((l) => {
|
|
427
|
+
const u = document.createElement("div");
|
|
428
|
+
u.style.cssText = `
|
|
425
429
|
border: 1px solid ${r.issueBorder};
|
|
426
430
|
border-radius: 6px;
|
|
427
431
|
padding: 16px;
|
|
@@ -429,16 +433,16 @@ const A = () => {
|
|
|
429
433
|
transition: all 0.2s;
|
|
430
434
|
background: ${r.issueBg};
|
|
431
435
|
color: ${r.text};
|
|
432
|
-
`,
|
|
433
|
-
|
|
434
|
-
},
|
|
435
|
-
|
|
436
|
+
`, u.onmouseover = () => {
|
|
437
|
+
u.style.borderColor = r.issueHoverBorder, u.style.background = r.issueHoverBg, b(l, !0);
|
|
438
|
+
}, u.onmouseout = () => {
|
|
439
|
+
u.style.borderColor = r.issueBorder, u.style.background = r.issueBg, b(l, !1);
|
|
436
440
|
};
|
|
437
|
-
const
|
|
438
|
-
if (
|
|
441
|
+
const B = l.severity === "error" ? "#f44336" : l.severity === "warning" ? "#ff9800" : "#2196f3";
|
|
442
|
+
if (u.innerHTML = `
|
|
439
443
|
<div style="display: flex; align-items: start; gap: 12px; margin-bottom: 8px;">
|
|
440
444
|
<span style="
|
|
441
|
-
background: ${
|
|
445
|
+
background: ${B};
|
|
442
446
|
color: white;
|
|
443
447
|
padding: 2px 8px;
|
|
444
448
|
border-radius: 4px;
|
|
@@ -447,12 +451,12 @@ const A = () => {
|
|
|
447
451
|
text-transform: uppercase;
|
|
448
452
|
">${l.severity}</span>
|
|
449
453
|
<div style="flex: 1;">
|
|
450
|
-
<div style="font-weight: 600; margin-bottom: 4px;">${l.message}</div>
|
|
451
|
-
<div style="font-size: 12px; color: ${r.muted};">WCAG ${l.wcag} · ${l.rule}</div>
|
|
454
|
+
<div style="font-weight: 600; margin-bottom: 4px;">${v(l.message)}</div>
|
|
455
|
+
<div style="font-size: 12px; color: ${r.muted};">WCAG ${v(l.wcag)} · ${v(l.rule)}</div>
|
|
452
456
|
</div>
|
|
453
457
|
</div>
|
|
454
458
|
<div style="font-size: 14px; color: ${r.text}; margin-bottom: 8px; padding-left: 68px;">
|
|
455
|
-
${l.suggestion || ""}
|
|
459
|
+
${v(l.suggestion || "")}
|
|
456
460
|
</div>
|
|
457
461
|
`, l.fixable) {
|
|
458
462
|
const d = document.createElement("button");
|
|
@@ -466,22 +470,22 @@ const A = () => {
|
|
|
466
470
|
font-size: 13px;
|
|
467
471
|
margin-left: 68px;
|
|
468
472
|
`, d.onmouseover = () => d.style.background = r.fixBtnHover, d.onmouseout = () => d.style.background = r.fixBtn, d.onclick = () => {
|
|
469
|
-
|
|
470
|
-
a.remove(),
|
|
473
|
+
N(l), d.textContent = "✓ Fixed", d.style.background = "#4caf50", d.disabled = !0, d.style.cursor = "not-allowed", b(l, !1), setTimeout(() => {
|
|
474
|
+
a.remove(), $();
|
|
471
475
|
}, 1e3);
|
|
472
|
-
},
|
|
476
|
+
}, u.appendChild(d);
|
|
473
477
|
}
|
|
474
|
-
m.appendChild(
|
|
478
|
+
m.appendChild(u);
|
|
475
479
|
});
|
|
476
480
|
}
|
|
477
|
-
|
|
478
|
-
|
|
481
|
+
i.appendChild(s), i.appendChild(m), a.appendChild(i), document.body.appendChild(a), a.onclick = (c) => {
|
|
482
|
+
c.target === a && (t.forEach((y) => b(y, !1)), a.remove());
|
|
479
483
|
};
|
|
480
|
-
const
|
|
481
|
-
|
|
484
|
+
const A = (c) => {
|
|
485
|
+
c.key === "Escape" && (t.forEach((y) => b(y, !1)), a.remove(), document.removeEventListener("keydown", A));
|
|
482
486
|
};
|
|
483
|
-
document.addEventListener("keydown",
|
|
484
|
-
},
|
|
487
|
+
document.addEventListener("keydown", A);
|
|
488
|
+
}, R = () => ({
|
|
485
489
|
name: "a11yChecker",
|
|
486
490
|
toolbar: [
|
|
487
491
|
{
|
|
@@ -494,7 +498,7 @@ const A = () => {
|
|
|
494
498
|
commands: {
|
|
495
499
|
toggleA11yChecker: () => {
|
|
496
500
|
try {
|
|
497
|
-
return
|
|
501
|
+
return $(), !0;
|
|
498
502
|
} catch (t) {
|
|
499
503
|
return console.error("Failed to open accessibility checker:", t), !1;
|
|
500
504
|
}
|
|
@@ -505,5 +509,5 @@ const A = () => {
|
|
|
505
509
|
}
|
|
506
510
|
});
|
|
507
511
|
export {
|
|
508
|
-
|
|
512
|
+
R as A11yCheckerPlugin
|
|
509
513
|
};
|
package/dist/anchor.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const w=require("./editorContainerHelpers-CFbfiOJI.js"),b=new Set,
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const $=require("./dialogHelpers-zU6zpMIA.js"),w=require("./editorContainerHelpers-CFbfiOJI.js"),b=new Set,y='[data-theme="dark"], .dark, .editora-theme-dark';function z(t,c){if(c===t.innerHTML)return;const s=window.execEditorCommand||window.executeEditorCommand;if(typeof s=="function")try{s("recordDomTransaction",t,c,t.innerHTML)}catch{}}function M(){if(typeof window>"u"||window.__anchorObserverInitialized)return;window.__anchorObserverInitialized=!0,new MutationObserver(c=>{c.forEach(s=>{s.removedNodes.forEach(a=>{if(a.nodeType===Node.ELEMENT_NODE){const l=a;if(l.classList?.contains("rte-anchor")){const r=l.id;r&&b.delete(r)}l.querySelectorAll?.(".rte-anchor")?.forEach(r=>{const u=r.id;u&&b.delete(u)})}})})}).observe(document.body,{childList:!0,subtree:!0})}function S(t){return!t||t.trim().length===0?{valid:!1,error:"Anchor ID cannot be empty"}:t.length>256?{valid:!1,error:"Anchor ID must be less than 256 characters"}:/^[A-Za-z_]/.test(t)?/^[A-Za-z0-9\-_]+$/.test(t)?{valid:!0,error:""}:{valid:!1,error:"Anchor ID can only contain letters, numbers, hyphens, and underscores"}:{valid:!1,error:"Anchor ID must start with a letter or underscore"}}function R(){const t=w.findEditorContainerFromSelection();if(!t)return;const c=w.getContentElement(t);if(!c)return;const s=c.querySelectorAll(".rte-anchor"),a=new Set;s.forEach(l=>{const e=l.id;e&&a.add(e)}),b.clear(),a.forEach(l=>b.add(l))}function H(t){if(t){const a=t.startContainer;if((a.nodeType===Node.ELEMENT_NODE?a:a.parentElement)?.closest(y))return!0}const c=window.getSelection();if(c&&c.rangeCount>0){const a=c.getRangeAt(0).startContainer;if((a.nodeType===Node.ELEMENT_NODE?a:a.parentElement)?.closest(y))return!0}return document.activeElement?.closest(y)?!0:document.body.matches(y)||document.documentElement.matches(y)}function _(t,c,s,a){document.querySelectorAll(".rte-anchor-dialog-overlay").forEach(n=>n.remove()),R();const l=H(a),e=l?{overlay:"rgba(0, 0, 0, 0.62)",dialogBg:"#1f2937",panelBg:"#222d3a",border:"#3b4657",text:"#e2e8f0",muted:"#94a3b8",closeHoverBg:"#334155",fieldBg:"#111827",fieldFocusBg:"#111827",fieldBorder:"#4b5563",fieldText:"#e2e8f0",fieldErrorBg:"#3f2124",fieldErrorBorder:"#ef4444",cancelBg:"#334155",cancelHover:"#475569",cancelText:"#e2e8f0",saveBg:"#3b82f6",saveHover:"#2563eb",saveDisabledBg:"#374151",saveDisabledText:"#7f8ca1",help:"#9fb0c6",focusRing:"rgba(88, 166, 255, 0.25)",errorRing:"rgba(239, 68, 68, 0.25)"}:{overlay:"rgba(0, 0, 0, 0.5)",dialogBg:"#ffffff",panelBg:"#f9f9f9",border:"#e0e0e0",text:"#333333",muted:"#999999",closeHoverBg:"#e0e0e0",fieldBg:"#ffffff",fieldFocusBg:"#f9f9ff",fieldBorder:"#d0d0d0",fieldText:"#333333",fieldErrorBg:"#ffebee",fieldErrorBorder:"#d32f2f",cancelBg:"#f0f0f0",cancelHover:"#e0e0e0",cancelText:"#333333",saveBg:"#0066cc",saveHover:"#0052a3",saveDisabledBg:"#d0d0d0",saveDisabledText:"#999999",help:"#999999",focusRing:"rgba(0, 102, 204, 0.1)",errorRing:"rgba(211, 47, 47, 0.1)"},r=document.createElement("div");$.initDialogOverlay(r),r.className="rte-anchor-dialog-overlay",r.style.cssText=`
|
|
2
2
|
position: fixed;
|
|
3
3
|
top: 0;
|
|
4
4
|
left: 0;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
max-width: 450px;
|
|
20
20
|
overflow: hidden;
|
|
21
21
|
animation: rte-anchor-dialog-appear 0.2s ease;
|
|
22
|
-
`,!document.getElementById("rte-anchor-dialog-styles")){const
|
|
22
|
+
`,!document.getElementById("rte-anchor-dialog-styles")){const n=document.createElement("style");n.id="rte-anchor-dialog-styles",n.textContent=`
|
|
23
23
|
@keyframes rte-anchor-dialog-appear {
|
|
24
24
|
from { opacity: 0; transform: scale(0.95); }
|
|
25
25
|
to { opacity: 1; transform: scale(1); }
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
.rte-anchor-dialog input:focus {
|
|
28
28
|
outline: none !important;
|
|
29
29
|
}
|
|
30
|
-
`,document.head.appendChild(
|
|
30
|
+
`,document.head.appendChild(n)}let d="";const h=document.createElement("div");h.style.cssText=`
|
|
31
31
|
display: flex;
|
|
32
32
|
align-items: center;
|
|
33
33
|
justify-content: space-between;
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
justify-content: center;
|
|
49
49
|
border-radius: 4px;
|
|
50
50
|
transition: all 0.2s ease;
|
|
51
|
-
`,f.onmouseover=()=>{f.style.background=e.closeHoverBg,f.style.color="#f8fafc"},f.onmouseout=()=>{f.style.background="none",f.style.color=e.muted},h.appendChild(C),h.appendChild(f);const B=document.createElement("div");B.style.cssText="padding: 20px;";const m=document.createElement("div");m.style.cssText="margin-bottom: 0;";const
|
|
51
|
+
`,f.onmouseover=()=>{f.style.background=e.closeHoverBg,f.style.color="#f8fafc"},f.onmouseout=()=>{f.style.background="none",f.style.color=e.muted},h.appendChild(C),h.appendChild(f);const B=document.createElement("div");B.style.cssText="padding: 20px;";const m=document.createElement("div");m.style.cssText="margin-bottom: 0;";const x=document.createElement("label");x.textContent="Anchor ID",x.style.cssText=`display: block; font-size: 14px; font-weight: 500; color: ${e.text}; margin-bottom: 8px;`,x.setAttribute("for","anchor-id-input");const o=document.createElement("input");o.id="anchor-id-input",o.type="text",o.placeholder="e.g., section-introduction",o.value="",o.style.cssText=`
|
|
52
52
|
width: 100%;
|
|
53
53
|
padding: 10px 12px;
|
|
54
54
|
font-size: 14px;
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
font-size: 12px;
|
|
65
65
|
margin-top: 6px;
|
|
66
66
|
display: none;
|
|
67
|
-
`;const k=document.createElement("div");k.textContent="URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.",k.style.cssText=`color: ${e.help}; font-size: 12px; margin-top: 8px; line-height: 1.4;`,m.appendChild(
|
|
67
|
+
`;const k=document.createElement("div");k.textContent="URL-safe ID (letters, numbers, hyphens, underscores). Must start with letter or underscore.",k.style.cssText=`color: ${e.help}; font-size: 12px; margin-top: 8px; line-height: 1.4;`,m.appendChild(x),m.appendChild(o),m.appendChild(p),m.appendChild(k),B.appendChild(m);const v=document.createElement("div");v.style.cssText=`
|
|
68
68
|
display: flex;
|
|
69
69
|
gap: 12px;
|
|
70
70
|
padding: 16px 20px;
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
transition: all 0.2s ease;
|
|
82
82
|
background: ${e.cancelBg};
|
|
83
83
|
color: ${e.cancelText};
|
|
84
|
-
`,g.onmouseover=()=>g.style.background=e.cancelHover,g.onmouseout=()=>g.style.background=e.cancelBg;const
|
|
84
|
+
`,g.onmouseover=()=>g.style.background=e.cancelHover,g.onmouseout=()=>g.style.background=e.cancelBg;const i=document.createElement("button");i.textContent="Add Anchor",i.style.cssText=`
|
|
85
85
|
padding: 8px 16px;
|
|
86
86
|
font-size: 14px;
|
|
87
87
|
font-weight: 500;
|
|
@@ -91,11 +91,11 @@
|
|
|
91
91
|
transition: all 0.2s ease;
|
|
92
92
|
background: ${e.saveBg};
|
|
93
93
|
color: white;
|
|
94
|
-
`,
|
|
94
|
+
`,i.disabled=!o.value.trim();const N=()=>{o.value.trim()?(i.disabled=!1,i.style.background=e.saveBg,i.style.color="white",i.style.cursor="pointer"):(i.disabled=!0,i.style.background=e.saveDisabledBg,i.style.color=e.saveDisabledText,i.style.cursor="not-allowed")};i.onmouseover=()=>{i.disabled||(i.style.background=e.saveHover,i.style.boxShadow=l?"0 2px 8px rgba(59, 130, 246, 0.35)":"0 2px 8px rgba(0, 102, 204, 0.3)")},i.onmouseout=()=>{i.disabled||(i.style.background=e.saveBg,i.style.boxShadow="none")},v.appendChild(g),v.appendChild(i),o.oninput=()=>{const n=o.value;if(N(),n.trim()){const T=S(n);T.valid?b.has(n)?(d=`Anchor ID already exists: ${n}`,p.textContent="⚠ "+d,p.style.display="block",o.style.borderColor=e.fieldErrorBorder,o.style.background=e.fieldErrorBg):(d="",p.style.display="none",o.style.borderColor=e.fieldBorder,o.style.background=e.fieldBg):(d=T.error,p.textContent="⚠ "+d,p.style.display="block",o.style.borderColor=e.fieldErrorBorder,o.style.background=e.fieldErrorBg)}else p.style.display="none",o.style.borderColor=e.fieldBorder,o.style.background=e.fieldBg},o.onfocus=()=>{o.style.borderColor=d?e.fieldErrorBorder:e.saveBg,o.style.boxShadow=d?`0 0 0 3px ${e.errorRing}`:`0 0 0 3px ${e.focusRing}`,o.style.background=d?e.fieldErrorBg:e.fieldFocusBg},o.onblur=()=>{o.style.boxShadow="none",d||(o.style.background=e.fieldBg)};const A=()=>{const n=o.value.trim();!n||!S(n).valid||b.has(n)||(s&&s(n),r.remove())},E=()=>{r.remove()};i.onclick=A,g.onclick=E,f.onclick=E,o.onkeydown=n=>{n.key==="Enter"?(n.preventDefault(),A()):n.key==="Escape"&&(n.preventDefault(),E())},r.onclick=n=>{n.target===r&&E()},u.appendChild(h),u.appendChild(B),u.appendChild(v),r.appendChild(u),document.body.appendChild(r),setTimeout(()=>o.focus(),100)}function I(t,c){let s;if(c)s=c;else{const d=window.getSelection();if(!d||d.rangeCount===0)return;s=d.getRangeAt(0)}let a=null,l=s.startContainer;for(;l&&l!==document.body;){if(l.nodeType===Node.ELEMENT_NODE){const d=l;if(d.getAttribute("contenteditable")==="true"){a=d;break}}l=l.parentNode}const e=a?.innerHTML??"",r=document.createElement("span");r.id=t,r.className="rte-anchor",r.setAttribute("data-type","anchor"),r.setAttribute("data-anchor-id",t),r.setAttribute("title",`Anchor: ${t}`),r.style.cssText=`
|
|
95
95
|
display: inline;
|
|
96
96
|
position: relative;
|
|
97
97
|
cursor: pointer;
|
|
98
|
-
`,
|
|
98
|
+
`,s.insertNode(r),b.add(t),s.setStart(r.nextSibling||r.parentNode,0),s.collapse(!0);const u=window.getSelection();if(u&&(u.removeAllRanges(),u.addRange(s)),a)z(a,e),a.dispatchEvent(new Event("input",{bubbles:!0}));else{const d=w.findEditorContainerFromSelection();if(d){const h=w.getContentElement(d);h&&h.dispatchEvent(new Event("input",{bubbles:!0}))}}D()}function D(){if(document.getElementById("rte-anchor-styles"))return;const t=document.createElement("style");t.id="rte-anchor-styles",t.textContent=`
|
|
99
99
|
.rte-anchor {
|
|
100
100
|
display: inline;
|
|
101
101
|
position: relative;
|
|
@@ -173,4 +173,4 @@
|
|
|
173
173
|
outline: 2px solid #0066cc;
|
|
174
174
|
outline-offset: 2px;
|
|
175
175
|
}
|
|
176
|
-
`,document.head.appendChild(t)}const
|
|
176
|
+
`,document.head.appendChild(t)}const O=()=>(typeof window<"u"&&(M(),D()),{name:"anchor",toolbar:[{label:"Anchor",command:"insertAnchor",icon:'<svg width="24px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path d="M12 8.4C13.4912 8.4 14.7 7.19117 14.7 5.7C14.7 4.20883 13.4912 3 12 3C10.5088 3 9.3 4.20883 9.3 5.7C9.3 7.19117 10.5088 8.4 12 8.4ZM12 8.4V20.9999M12 20.9999C9.61305 20.9999 7.32387 20.0518 5.63604 18.364C3.94821 16.6761 3 14.3869 3 12H5M12 20.9999C14.3869 20.9999 16.6761 20.0518 18.364 18.364C20.0518 16.6761 21 14.3869 21 12H19" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg>',shortcut:"Mod-Shift-k"}],commands:{insertAnchor:()=>{try{const t=window.getSelection();if(!t||t.rangeCount===0)return alert("Please place your cursor where you want to insert the anchor."),!1;const c=t.getRangeAt(0).cloneRange();return _("add","",s=>{I(s,c)},c),!0}catch(t){return console.error("Failed to insert anchor:",t),!1}}},keymap:{"Mod-Shift-k":"insertAnchor"}});exports.AnchorPlugin=O;
|