@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/citations.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const S=".rte-content, .editora-content",pt="rte-citations-styles",b="rte-citations-panel",ot=".rte-citation-ref[data-citation-id]",W='.rte-citation-bibliography[data-type="citation-bibliography"]',G='.rte-citation-footnotes[data-type="citation-footnotes"]',x=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',L=["apa","mla","chicago"],Ot={panelTitle:"Citations",panelAriaLabel:"Citations panel",styleLabel:"Citation style",authorLabel:"Author",yearLabel:"Year",titleLabel:"Title",sourceLabel:"Source",urlLabel:"URL",noteLabel:"Footnote note",insertText:"Insert Citation",refreshText:"Refresh Bibliography",closeText:"Close",bibliographyTitle:"References",footnotesTitle:"Citation Notes",noCitationsText:"No citations inserted yet.",styleButtonPrefix:"Style",recentHeading:"Recent citations",deleteRecentText:"x",summaryPrefix:"Citations",invalidMessage:"Author and title are required."},f=new WeakMap,T=new WeakMap,ht=new WeakMap,D=new WeakMap,w=new Map,V=new WeakMap,Q=new WeakMap,q=new Set;let I=null,B=null,O=null,k=null,Y=0,Pt=0,at=0,M=null,p=null;function g(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Dt(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function xt(t,e){const n=e(t);if(!n)return"";const i=n.match(/\d{4}/);return i?i[0]:n}function yt(t,e){const n=e(t);return n?/^https?:\/\//i.test(n)?n:`https://${n}`:""}function F(t){return t.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function Ct(t,e){return{id:F(e.normalizeText(t.id||"")),author:e.normalizeText(t.author||""),year:xt(t.year||"",e.normalizeText)||void 0,title:e.normalizeText(t.title||""),source:e.normalizeText(t.source||"")||void 0,url:yt(t.url||"",e.normalizeText)||void 0,note:e.normalizeText(t.note||"")||void 0}}function Z(t={}){const e=t.defaultStyle&&L.includes(t.defaultStyle)?t.defaultStyle:"apa",n={...Ot,...t.labels||{}};return{defaultStyle:e,enableFootnoteSync:t.enableFootnoteSync!==!1,debounceMs:Math.max(80,Number(t.debounceMs??220)),maxRecentCitations:Math.max(3,Math.min(30,Number(t.maxRecentCitations??8))),labels:n,normalizeText:t.normalizeText||Dt,generateCitationId:typeof t.generateCitationId=="function"?t.generateCitationId:void 0}}function vt(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function lt(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function X(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function Ht(t){const e=lt(t);if(X(e))return!0;const n=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return X(n)?!0:X(document.documentElement)||X(document.body)}function tt(t,e){t.classList.remove("rte-citations-theme-dark"),Ht(e)&&t.classList.add("rte-citations-theme-dark")}function h(t,e=!0){if(t?.contentElement instanceof HTMLElement)return t.contentElement;if(t?.editorElement instanceof HTMLElement){const o=t.editorElement;if(o.matches(S))return o;const r=o.querySelector(S);if(r instanceof HTMLElement)return r}const n=window.getSelection();if(n&&n.rangeCount>0){const o=n.getRangeAt(0).startContainer,a=vt(o)?.closest(S);if(a)return a}const i=document.activeElement;if(i){if(i.matches(S))return i;const o=i.closest(S);if(o)return o}return p&&p.isConnected?p:(p&&!p.isConnected&&(p=null),e?document.querySelector(S):null)}function $(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function K(t){const e=vt(t);return e?!!(e.closest(W)||e.closest(G)):!1}function Ft(t,e){if(at+=1,e.generateCitationId){const n=e.generateCitationId({editor:t,index:at}),i=F(e.normalizeText(n||""));if(i)return i}return`cite-${Date.now().toString(36)}-${at.toString(36)}`}function st(t){return t.map(e=>(e||"").trim()).filter(Boolean).join(" ").trim()}function _t(t,e){const n=t.author||"Unknown",i=t.year||"n.d.";return e==="mla"?`(${n} ${i})`:e==="chicago"?`(${n} ${i})`:`(${n}, ${i})`}function ut(t,e){const n=t.author||"Unknown",i=t.year||"n.d.",o=t.title||"Untitled",r=t.source||"",a=t.url||"";return st(e==="mla"?[`${n}.`,`"${o}."`,r?`${r},`:"",`${i}.`,a]:e==="chicago"?[`${n}.`,`${o}.`,r?`${r}.`:"",`(${i}).`,a]:[`${n}.`,`(${i}).`,`${o}.`,r?`${r}.`:"",a])}function R(t){return Array.from(t.querySelectorAll(ot)).filter(e=>!e.closest(W)&&!e.closest(G))}function wt(t,e){const n=F(e.normalizeText(t.getAttribute("data-citation-id")||""));if(!n)return null;const i=e.normalizeText(t.getAttribute("data-citation-author")||""),o=e.normalizeText(t.getAttribute("data-citation-title")||"");return{id:n,author:i||"Unknown",year:xt(t.getAttribute("data-citation-year")||"",e.normalizeText)||void 0,title:o||"Untitled",source:e.normalizeText(t.getAttribute("data-citation-source")||"")||void 0,url:yt(t.getAttribute("data-citation-url")||"",e.normalizeText)||void 0,note:e.normalizeText(t.getAttribute("data-citation-note")||"")||void 0}}function Et(t,e,n){t.classList.add("rte-citation-ref"),t.setAttribute("data-citation-id",e.id),t.setAttribute("data-citation-author",e.author||""),t.setAttribute("data-citation-year",e.year||""),t.setAttribute("data-citation-title",e.title||""),t.setAttribute("data-citation-source",e.source||""),t.setAttribute("data-citation-url",e.url||""),t.setAttribute("data-citation-note",e.note||""),t.setAttribute("contenteditable","false"),t.setAttribute("tabindex","0"),t.setAttribute("role","doc-biblioref"),t.setAttribute("data-style",n),t.textContent=_t(e,n)}function it(t,e,n){const i=lt(t);Array.from(i.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(r=>{r.classList.toggle("active",n),r.setAttribute("data-active",n?"true":"false"),r.setAttribute("aria-pressed",n?"true":"false")})}function N(t,e){const n=T.get(t);return n&&L.includes(n)?n:e?.defaultStyle||"apa"}function j(t,e){const n=R(t),i=new Map;return n.forEach(o=>{const r=wt(o,e);if(!r)return;if(!i.has(r.id)){i.set(r.id,r);return}const a=i.get(r.id);i.set(r.id,{...a,author:a.author||r.author,title:a.title||r.title,year:a.year||r.year,source:a.source||r.source,url:a.url||r.url,note:a.note||r.note})}),Array.from(i.values())}function qt(t,e,n){const i=Ct(e,n);if(!i.id||!i.author||!i.title)return;const r=(D.get(t)||[]).filter(a=>a.id!==i.id);D.set(t,[i,...r].slice(0,n.maxRecentCitations))}function rt(t,e,n){const i=D.get(t)||[],o=new Map;e.slice(Math.max(0,e.length-n.maxRecentCitations)).reverse().forEach(a=>{a.id&&o.set(a.id,a)}),i.forEach(a=>{!a.id||o.has(a.id)||o.set(a.id,a)});const r=Array.from(o.values()).slice(0,n.maxRecentCitations);return D.set(t,r),r}function St(t,e,n,i){const o=F(i.normalizeText(e||""));return o&&rt(t,n,i).find(a=>a.id===o)||null}function Kt(t,e,n){const i=F(n.normalizeText(e||""));if(!i)return!1;const o=D.get(t)||[],r=o.filter(a=>a.id!==i);return r.length===o.length?!1:(D.set(t,r),!0)}function $t(t,e,n){const i=document.createElement("section");i.className=t,i.setAttribute("data-type",e),i.setAttribute("contenteditable","false"),i.setAttribute("aria-label",n),e==="citation-bibliography"?i.setAttribute("role","doc-bibliography"):e==="citation-footnotes"&&i.setAttribute("role","doc-endnotes");const o=document.createElement("h3");o.className="rte-citation-section-title",o.textContent=n;const r=document.createElement("ol");return r.className="rte-citation-list",r.setAttribute("role","list"),i.appendChild(o),i.appendChild(r),i}function jt(t,e){let n=t.querySelector(W);n||(n=$t("rte-citation-bibliography","citation-bibliography",e.labels.bibliographyTitle),t.appendChild(n));const i=n.querySelector(".rte-citation-section-title");return i&&(i.textContent=e.labels.bibliographyTitle),n.setAttribute("aria-label",e.labels.bibliographyTitle),n}function Ut(t,e){let n=t.querySelector(G);n||(n=$t("rte-citation-footnotes","citation-footnotes",e.labels.footnotesTitle),t.appendChild(n));const i=n.querySelector(".rte-citation-section-title");return i&&(i.textContent=e.labels.footnotesTitle),n.setAttribute("aria-label",e.labels.footnotesTitle),n}function At(t,e){t.querySelector(e)?.remove()}function Wt(t,e,n,i){if(e.length===0){At(t,W);return}const r=jt(t,n).querySelector(".rte-citation-list");if(!r)return;const a=document.createDocumentFragment();e.forEach((s,u)=>{const c=document.createElement("li");c.className="rte-citation-item",c.id=`rte-citation-entry-${s.id}`,c.setAttribute("data-citation-id",s.id),c.setAttribute("data-citation-number",String(u+1)),c.textContent=ut(s,i),a.appendChild(c)}),r.innerHTML="",r.appendChild(a)}function Gt(t,e,n,i){if(!n.enableFootnoteSync||e.length===0){At(t,G),R(t).forEach(l=>{l.removeAttribute("data-footnote-number"),l.removeAttribute("data-footnote-target")});return}const r=Ut(t,n).querySelector(".rte-citation-list");if(!r)return;const a=new Map,s=new Map;e.forEach((l,d)=>{s.set(l.id,d+1)});const u=new Map;R(t).forEach(l=>{const d=l.getAttribute("data-citation-id")||"";if(!d||!s.has(d))return;const m=(u.get(d)||0)+1;u.set(d,m);const v=`rte-citation-ref-${d}-${m}`;l.id=v;const A=s.get(d);l.setAttribute("data-footnote-number",String(A)),l.setAttribute("data-footnote-target",`rte-citation-note-${d}`),a.has(d)||a.set(d,v)});const c=document.createDocumentFragment();e.forEach((l,d)=>{const m=document.createElement("li");m.className="rte-citation-item rte-citation-footnote-item",m.id=`rte-citation-note-${l.id}`,m.setAttribute("data-citation-id",l.id);const v=document.createElement("span");v.className="rte-citation-footnote-number",v.textContent=`${d+1}. `;const A=document.createElement("span");A.className="rte-citation-footnote-text";const Bt=l.note?`${l.note}. `:"";A.textContent=`${Bt}${ut(l,i)}`,m.appendChild(v),m.appendChild(A);const mt=a.get(l.id);if(mt){const _=document.createElement("a");_.className="rte-citation-backref",_.href=`#${mt}`,_.setAttribute("aria-label",`Back to citation ${d+1}`),_.textContent="Back",m.appendChild(_)}c.appendChild(m)}),r.innerHTML="",r.appendChild(c)}function Vt(t,e,n,i){const o=ut(e,n);t.setAttribute("data-citation-number",String(i)),t.setAttribute("aria-label",`Citation ${i}: ${o}`)}function Yt(t,e,n){const i=R(t);let o=`${e}:${n?"1":"0"}:${i.length}`;return i.forEach(r=>{o+=`|${r.getAttribute("data-citation-id")||""}`,o+=`|${r.getAttribute("data-citation-author")||""}`,o+=`|${r.getAttribute("data-citation-year")||""}`,o+=`|${r.getAttribute("data-citation-title")||""}`,o+=`|${r.getAttribute("data-citation-source")||""}`,o+=`|${r.getAttribute("data-citation-url")||""}`,o+=`|${r.getAttribute("data-citation-note")||""}`}),o}function H(t){const e=w.get(t);if(!e)return;const n=f.get(t)||M;if(!n)return;const i=N(t,n),o=j(t,n),r=rt(t,o,n),a=e.querySelector(".rte-citations-status"),s=e.querySelector('[data-action="cycle-style"]'),u=e.querySelector(".rte-citations-recent-list");if(a){const c=o.length;a.textContent=`${n.labels.summaryPrefix}: ${c} | Style: ${i.toUpperCase()} | Footnotes: ${n.enableFootnoteSync?"On":"Off"}`}if(s&&(s.textContent=`${n.labels.styleButtonPrefix}: ${i.toUpperCase()}`,s.setAttribute("aria-label",`${n.labels.styleButtonPrefix}: ${i.toUpperCase()}`)),u){if(r.length===0){u.innerHTML=`<li class="rte-citations-empty">${g(n.labels.noCitationsText)}</li>`;return}u.innerHTML=r.map(c=>`
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const E=".rte-content, .editora-content",ht="rte-citations-styles",b="rte-citations-panel",it=".rte-citation-ref[data-citation-id]",G='.rte-citation-bibliography[data-type="citation-bibliography"]',V='.rte-citation-footnotes[data-type="citation-footnotes"]',x=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',L=["apa","mla","chicago"],Ot={panelTitle:"Citations",panelAriaLabel:"Citations panel",styleLabel:"Citation style",authorLabel:"Author",yearLabel:"Year",titleLabel:"Title",sourceLabel:"Source",urlLabel:"URL",noteLabel:"Footnote note",insertText:"Insert Citation",refreshText:"Refresh Bibliography",closeText:"Close",bibliographyTitle:"References",footnotesTitle:"Citation Notes",noCitationsText:"No citations inserted yet.",styleButtonPrefix:"Style",recentHeading:"Recent citations",deleteRecentText:"x",summaryPrefix:"Citations",invalidMessage:"Author and title are required."},f=new WeakMap,T=new WeakMap,xt=new WeakMap,H=new WeakMap,v=new Map,Y=new WeakMap,tt=new WeakMap,K=new Set;let P=null,B=null,O=null,k=null,X=0,Dt=0,st=0,M=null,p=null;function g(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ht(t){return t.replace(/\u00A0/g," ").replace(/\s+/g," ").trim()}function yt(t,e){const o=e(t);if(!o)return"";const i=o.match(/\d{4}/);return i?i[0]:o}function Ct(t,e){const o=e(t);return o?/^https?:\/\//i.test(o)?o:`https://${o}`:""}function _(t){return t.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function wt(t,e){return{id:_(e.normalizeText(t.id||"")),author:e.normalizeText(t.author||""),year:yt(t.year||"",e.normalizeText)||void 0,title:e.normalizeText(t.title||""),source:e.normalizeText(t.source||"")||void 0,url:Ct(t.url||"",e.normalizeText)||void 0,note:e.normalizeText(t.note||"")||void 0}}function Q(t={}){const e=t.defaultStyle&&L.includes(t.defaultStyle)?t.defaultStyle:"apa",o={...Ot,...t.labels||{}};return{defaultStyle:e,enableFootnoteSync:t.enableFootnoteSync!==!1,debounceMs:Math.max(80,Number(t.debounceMs??220)),maxRecentCitations:Math.max(3,Math.min(30,Number(t.maxRecentCitations??8))),labels:o,normalizeText:t.normalizeText||Ht,generateCitationId:typeof t.generateCitationId=="function"?t.generateCitationId:void 0}}function vt(t){return t?t.nodeType===Node.ELEMENT_NODE?t:t.parentElement:null}function ut(t){return t.closest("[data-editora-editor], .rte-editor, .editora-editor, editora-editor")||t}function J(t){return t?(t.getAttribute("data-theme")||t.getAttribute("theme")||"").toLowerCase()==="dark"?!0:t.classList.contains("dark")||t.classList.contains("editora-theme-dark")||t.classList.contains("rte-theme-dark"):!1}function Ft(t){const e=ut(t);if(J(e))return!0;const o=e.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return J(o)?!0:J(document.documentElement)||J(document.body)}function et(t,e){t.classList.remove("rte-citations-theme-dark"),Ft(e)&&t.classList.add("rte-citations-theme-dark")}function h(t,e=!0){if(t?.contentElement instanceof HTMLElement)return t.contentElement;if(t?.editorElement instanceof HTMLElement){const n=t.editorElement;if(n.matches(E))return n;const r=n.querySelector(E);if(r instanceof HTMLElement)return r}const o=window.getSelection();if(o&&o.rangeCount>0){const n=o.getRangeAt(0).startContainer,a=vt(n)?.closest(E);if(a)return a}const i=document.activeElement;if(i){if(i.matches(E))return i;const n=i.closest(E);if(n)return n}return p&&p.isConnected?p:(p&&!p.isConnected&&(p=null),e?document.querySelector(E):null)}function $(t){return t.getAttribute("contenteditable")==="false"||t.getAttribute("data-readonly")==="true"}function j(t){const e=vt(t);return e?!!(e.closest(G)||e.closest(V)):!1}function _t(t,e){if(st+=1,e.generateCitationId){const o=e.generateCitationId({editor:t,index:st}),i=_(e.normalizeText(o||""));if(i)return i}return`cite-${Date.now().toString(36)}-${st.toString(36)}`}function ct(t){return t.map(e=>(e||"").trim()).filter(Boolean).join(" ").trim()}function qt(t,e){const o=t.author||"Unknown",i=t.year||"n.d.";return e==="mla"?`(${o} ${i})`:e==="chicago"?`(${o} ${i})`:`(${o}, ${i})`}function N(t){const e=t.trim();return!e||/[.!?]$/.test(e)?e:`${e}.`}function dt(t,e){const o=N(t.author||"Unknown"),i=t.year||"n.d.",n=t.title||"Untitled",r=(t.source||"").trim(),a=t.url||"";return ct(e==="mla"?[o,`"${N(n)}"`,r?`${r.replace(/[.,]$/,"")},`:"",`${i}.`,a]:e==="chicago"?[o,N(n),N(r),`(${i}).`,a]:[o,`(${i}).`,N(n),N(r),a])}function R(t){return Array.from(t.querySelectorAll(it)).filter(e=>!e.closest(G)&&!e.closest(V))}function St(t,e){const o=_(e.normalizeText(t.getAttribute("data-citation-id")||""));if(!o)return null;const i=e.normalizeText(t.getAttribute("data-citation-author")||""),n=e.normalizeText(t.getAttribute("data-citation-title")||"");return{id:o,author:i||"Unknown",year:yt(t.getAttribute("data-citation-year")||"",e.normalizeText)||void 0,title:n||"Untitled",source:e.normalizeText(t.getAttribute("data-citation-source")||"")||void 0,url:Ct(t.getAttribute("data-citation-url")||"",e.normalizeText)||void 0,note:e.normalizeText(t.getAttribute("data-citation-note")||"")||void 0}}function Et(t,e,o){t.classList.add("rte-citation-ref"),t.setAttribute("data-citation-id",e.id),t.setAttribute("data-citation-author",e.author||""),t.setAttribute("data-citation-year",e.year||""),t.setAttribute("data-citation-title",e.title||""),t.setAttribute("data-citation-source",e.source||""),t.setAttribute("data-citation-url",e.url||""),t.setAttribute("data-citation-note",e.note||""),t.setAttribute("contenteditable","false"),t.setAttribute("tabindex","0"),t.setAttribute("role","doc-biblioref"),t.setAttribute("data-style",o),t.textContent=qt(e,o)}function rt(t,e,o){const i=ut(t);Array.from(i.querySelectorAll(`.rte-toolbar-button[data-command="${e}"], .editora-toolbar-button[data-command="${e}"]`)).forEach(r=>{r.classList.toggle("active",o),r.setAttribute("data-active",o?"true":"false"),r.setAttribute("aria-pressed",o?"true":"false")})}function z(t,e){const o=T.get(t);return o&&L.includes(o)?o:e?.defaultStyle||"apa"}function U(t,e){const o=R(t),i=new Map;return o.forEach(n=>{const r=St(n,e);if(!r)return;if(!i.has(r.id)){i.set(r.id,r);return}const a=i.get(r.id);i.set(r.id,{...a,author:a.author||r.author,title:a.title||r.title,year:a.year||r.year,source:a.source||r.source,url:a.url||r.url,note:a.note||r.note})}),Array.from(i.values())}function Kt(t,e,o){const i=wt(e,o);if(!i.id||!i.author||!i.title)return;const r=(H.get(t)||[]).filter(a=>a.id!==i.id);H.set(t,[i,...r].slice(0,o.maxRecentCitations))}function at(t,e,o){const i=H.get(t)||[],n=new Map;e.slice(Math.max(0,e.length-o.maxRecentCitations)).reverse().forEach(a=>{a.id&&n.set(a.id,a)}),i.forEach(a=>{!a.id||n.has(a.id)||n.set(a.id,a)});const r=Array.from(n.values()).slice(0,o.maxRecentCitations);return H.set(t,r),r}function $t(t,e,o,i){const n=_(i.normalizeText(e||""));return n&&at(t,o,i).find(a=>a.id===n)||null}function jt(t,e,o){const i=_(o.normalizeText(e||""));if(!i)return!1;const n=H.get(t)||[],r=n.filter(a=>a.id!==i);return r.length===n.length?!1:(H.set(t,r),!0)}function At(t,e,o){const i=document.createElement("section");i.className=t,i.setAttribute("data-type",e),i.setAttribute("contenteditable","false"),i.setAttribute("aria-label",o),e==="citation-bibliography"?i.setAttribute("role","doc-bibliography"):e==="citation-footnotes"&&i.setAttribute("role","doc-endnotes");const n=document.createElement("h3");n.className="rte-citation-section-title",n.textContent=o;const r=document.createElement("ol");return r.className="rte-citation-list",r.setAttribute("role","list"),i.appendChild(n),i.appendChild(r),i}function Ut(t,e){let o=t.querySelector(G);o||(o=At("rte-citation-bibliography","citation-bibliography",e.labels.bibliographyTitle),t.appendChild(o));const i=o.querySelector(".rte-citation-section-title");return i&&(i.textContent=e.labels.bibliographyTitle),o.setAttribute("aria-label",e.labels.bibliographyTitle),o}function Wt(t,e){let o=t.querySelector(V);o||(o=At("rte-citation-footnotes","citation-footnotes",e.labels.footnotesTitle),t.appendChild(o));const i=o.querySelector(".rte-citation-section-title");return i&&(i.textContent=e.labels.footnotesTitle),o.setAttribute("aria-label",e.labels.footnotesTitle),o}function kt(t,e){t.querySelector(e)?.remove()}function Gt(t,e,o,i){if(e.length===0){kt(t,G);return}const r=Ut(t,o).querySelector(".rte-citation-list");if(!r)return;const a=document.createDocumentFragment();e.forEach((s,u)=>{const c=document.createElement("li");c.className="rte-citation-item",c.id=`rte-citation-entry-${s.id}`,c.setAttribute("data-citation-id",s.id),c.setAttribute("data-citation-number",String(u+1)),c.textContent=dt(s,i),a.appendChild(c)}),r.innerHTML="",r.appendChild(a)}function Vt(t,e,o,i){if(!o.enableFootnoteSync||e.length===0){kt(t,V),R(t).forEach(l=>{l.removeAttribute("data-footnote-number"),l.removeAttribute("data-footnote-target")});return}const r=Wt(t,o).querySelector(".rte-citation-list");if(!r)return;const a=new Map,s=new Map;e.forEach((l,d)=>{s.set(l.id,d+1)});const u=new Map;R(t).forEach(l=>{const d=l.getAttribute("data-citation-id")||"";if(!d||!s.has(d))return;const m=(u.get(d)||0)+1;u.set(d,m);const w=`rte-citation-ref-${d}-${m}`;l.id=w;const A=s.get(d);l.setAttribute("data-footnote-number",String(A)),l.setAttribute("data-footnote-target",`rte-citation-note-${d}`),a.has(d)||a.set(d,w)});const c=document.createDocumentFragment();e.forEach((l,d)=>{const m=document.createElement("li");m.className="rte-citation-item rte-citation-footnote-item",m.id=`rte-citation-note-${l.id}`,m.setAttribute("data-citation-id",l.id);const w=document.createElement("span");w.className="rte-citation-footnote-number",w.textContent=`${d+1}. `;const A=document.createElement("span");A.className="rte-citation-footnote-text";const Bt=l.note?`${l.note}. `:"";A.textContent=`${Bt}${dt(l,i)}`,m.appendChild(w),m.appendChild(A);const pt=a.get(l.id);if(pt){const q=document.createElement("a");q.className="rte-citation-backref",q.href=`#${pt}`,q.setAttribute("aria-label",`Back to citation ${d+1}`),q.textContent="Back",m.appendChild(q)}c.appendChild(m)}),r.innerHTML="",r.appendChild(c)}function Yt(t,e,o,i){const n=dt(e,o);t.setAttribute("data-citation-number",String(i)),t.setAttribute("aria-label",`Citation ${i}: ${n}`)}function Xt(t,e,o){const i=R(t);let n=`${e}:${o?"1":"0"}:${i.length}`;return i.forEach(r=>{n+=`|${r.getAttribute("data-citation-id")||""}`,n+=`|${r.getAttribute("data-citation-author")||""}`,n+=`|${r.getAttribute("data-citation-year")||""}`,n+=`|${r.getAttribute("data-citation-title")||""}`,n+=`|${r.getAttribute("data-citation-source")||""}`,n+=`|${r.getAttribute("data-citation-url")||""}`,n+=`|${r.getAttribute("data-citation-note")||""}`}),n}function F(t){const e=v.get(t);if(!e)return;const o=f.get(t)||M;if(!o)return;const i=z(t,o),n=U(t,o),r=at(t,n,o),a=e.querySelector(".rte-citations-status"),s=e.querySelector('[data-action="cycle-style"]'),u=e.querySelector(".rte-citations-recent-list");if(a){const c=n.length;a.textContent=`${o.labels.summaryPrefix}: ${c} | Style: ${i.toUpperCase()} | Footnotes: ${o.enableFootnoteSync?"On":"Off"}`}if(s&&(s.textContent=`${o.labels.styleButtonPrefix}: ${i.toUpperCase()}`,s.setAttribute("aria-label",`${o.labels.styleButtonPrefix}: ${i.toUpperCase()}`)),u){if(r.length===0){u.innerHTML=`<li class="rte-citations-empty">${g(o.labels.noCitationsText)}</li>`;return}u.innerHTML=r.map(c=>`
|
|
2
2
|
<li class="rte-citations-recent-item">
|
|
3
3
|
<div class="rte-citations-recent-row">
|
|
4
4
|
<button
|
|
@@ -17,20 +17,20 @@
|
|
|
17
17
|
data-action="delete-by-id"
|
|
18
18
|
data-citation-id="${g(c.id)}"
|
|
19
19
|
aria-label="Delete citation: ${g(c.title)}"
|
|
20
|
-
>${g(
|
|
20
|
+
>${g(o.labels.deleteRecentText)}</button>
|
|
21
21
|
</div>
|
|
22
22
|
</li>
|
|
23
|
-
`).join("")}}function y(t,e,
|
|
23
|
+
`).join("")}}function y(t,e,o=!1){const i=z(t,e),n=Xt(t,i,e.enableFootnoteSync);if(!o&&xt.get(t)===n)return U(t,e);const r=R(t),a=new Map;r.forEach(c=>{const l=St(c,e);l&&(a.has(l.id)||a.set(l.id,l))});const s=Array.from(a.values());at(t,s,e);const u=new Map;return s.forEach((c,l)=>{u.set(c.id,l+1)}),r.forEach(c=>{const l=c.getAttribute("data-citation-id")||"",d=a.get(l);if(!d)return;Et(c,d,i);const m=u.get(d.id)||1;Yt(c,d,i,Math.max(1,m))}),Gt(t,s,e,i),Vt(t,s,e,i),xt.set(t,n),F(t),t.dispatchEvent(new CustomEvent("editora:citations-refreshed",{bubbles:!0,detail:{citations:s,style:i,footnoteSync:e.enableFootnoteSync}})),s}function Tt(t){const e=tt.get(t);typeof e=="number"&&(window.clearTimeout(e),K.delete(e),tt.delete(t))}function Mt(t){const e=f.get(t)||M;if(!e)return;Tt(t);const o=window.setTimeout(()=>{K.delete(o),tt.delete(t),y(t,e,!1)},e.debounceMs);K.add(o),tt.set(t,o)}function Jt(t){const e=window.getSelection();if(!e)throw new Error("Selection unavailable");if(e.rangeCount>0){const a=e.getRangeAt(0);if(t.contains(a.commonAncestorContainer)&&!j(a.commonAncestorContainer))return a.cloneRange()}const o=document.createRange(),i=t.querySelector(G),n=t.querySelector(V),r=i||n;return r?(o.setStartBefore(r),o.collapse(!0),o):(o.selectNodeContents(t),o.collapse(!1),o)}function ft(t){t.dispatchEvent(new Event("input",{bubbles:!0}))}function bt(t,e){if(e===t.innerHTML)return;const o=window.execEditorCommand||window.executeEditorCommand;if(typeof o=="function")try{o("recordDomTransaction",t,e,t.innerHTML)}catch{}}function Lt(t,e){const o=window.getSelection();if(!o)return;const i=document.createRange();if(t.nodeType===Node.TEXT_NODE){const n=t,r=Math.max(0,Math.min(e,n.length));i.setStart(n,r)}else{const n=t.childNodes.length,r=Math.max(0,Math.min(e,n));i.setStart(t,r)}i.collapse(!0),o.removeAllRanges(),o.addRange(i)}function Rt(t){if(t.collapsed||t.startContainer!==t.endContainer||t.endOffset!==t.startOffset+1||!(t.startContainer instanceof Element||t.startContainer instanceof DocumentFragment))return null;const e=t.startContainer.childNodes[t.startOffset];return!(e instanceof HTMLElement)||!e.matches(it)?null:e}function Z(t,e,o){const{startContainer:i,startOffset:n}=t;if(i.nodeType===Node.ELEMENT_NODE){const a=i;if(o==="previous"){if(n>0)return a.childNodes[n-1]||null}else if(n<a.childNodes.length)return a.childNodes[n]||null}if(i.nodeType===Node.TEXT_NODE&&(o==="previous"&&n<i.data.length||o==="next"&&n>0))return null;let r=i;for(;r&&r!==e;){const a=o==="previous"?r.previousSibling:r.nextSibling;if(a)return a;r=r.parentNode}return null}function zt(t,e,o){if(!t.collapsed)return null;const i=a=>a instanceof HTMLElement&&a.matches(it)?a:null,{startContainer:n,startOffset:r}=t;if(n.nodeType===Node.ELEMENT_NODE){const a=n;return o==="Backspace"&&r>0?i(a.childNodes[r-1]||null):o==="Delete"?i(a.childNodes[r]||null):null}if(n.nodeType===Node.TEXT_NODE){const a=n;if(o==="Backspace"&&r===0){const s=i(a.previousSibling);return s||i(Z(t,e,"previous"))}if(o==="Delete"&&r===a.data.length){const s=i(a.nextSibling);return s||i(Z(t,e,"next"))}}return i(o==="Backspace"?Z(t,e,"previous"):Z(t,e,"next"))}function D(t,e,o){const i=t.closest(E);if(!i||j(t))return!1;const n=t.parentNode;if(!n)return!1;const r=i.innerHTML,a=Array.from(n.childNodes).indexOf(t);if(a<0)return!1;const s=t.nextSibling;return s instanceof Text&&(s.data===" "?s.remove():s.data.startsWith(" ")&&(s.data=s.data.slice(1))),t.remove(),Lt(n,a),y(i,o,!0),bt(i,r),ft(i),e==="Delete"&&i.focus({preventScroll:!0}),!0}function Zt(t,e,o){if(t.key!=="Backspace"&&t.key!=="Delete")return!1;const i=t.key,n=t.target;if(n?.matches(it)&&e.contains(n)&&!j(n))return t.preventDefault(),t.stopPropagation(),D(n,i,o);const r=window.getSelection();if(!r||r.rangeCount===0)return!1;const a=r.getRangeAt(0);if(!e.contains(a.commonAncestorContainer)||j(a.commonAncestorContainer))return!1;const s=Rt(a);if(s)return t.preventDefault(),t.stopPropagation(),D(s,i,o);const u=zt(a,e,i);return u?(t.preventDefault(),t.stopPropagation(),D(u,i,o)):!1}function Nt(t,e,o){const i=_(o.normalizeText(e||""));if(!i)return!1;const n=R(t).filter(a=>a.getAttribute("data-citation-id")===i);if(n.length===0)return!1;if(n.length===1)return D(n[0],"Delete",o);const r=t.innerHTML;return n.forEach(a=>{const s=a.nextSibling;s instanceof Text&&(s.data===" "?s.remove():s.data.startsWith(" ")&&(s.data=s.data.slice(1))),a.remove()}),Lt(t,t.childNodes.length),y(t,o,!0),bt(t,r),ft(t),t.focus({preventScroll:!0}),!0}function Qt(t,e){const o=window.getSelection();if(!o||o.rangeCount===0)return!1;const i=o.getRangeAt(0);if(!t.contains(i.commonAncestorContainer)||j(i.commonAncestorContainer))return!1;const n=Rt(i);if(n)return D(n,"Delete",e);const r=zt(i,t,"Backspace");return r?D(r,"Backspace",e):!1}function nt(t,e,o){const i=wt(e,o);if(!i.author||!i.title)return!1;i.id||(i.id=_t(t,o));const n=t.innerHTML;let r;try{r=Jt(t)}catch{return!1}const a=window.getSelection();if(!a)return!1;r.collapsed||r.deleteContents();const s=document.createElement("span");Et(s,i,z(t,o));try{r.insertNode(s)}catch{return!1}const u=document.createTextNode(" ");s.nextSibling?s.parentNode?.insertBefore(u,s.nextSibling):s.parentNode?.appendChild(u);const c=document.createRange();if(u.parentNode){const l=Array.from(u.parentNode.childNodes).indexOf(u)+1;c.setStart(u.parentNode,Math.max(0,l))}else c.setStartAfter(s);return c.collapse(!0),a.removeAllRanges(),a.addRange(c),Kt(t,i,o),y(t,o,!0),bt(t,n),ft(t),!0}function te(t,e){if(!e)return!1;const o=R(t).find(r=>r.getAttribute("data-citation-id")===e)||null;if(!o)return!1;o.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"}),o.focus({preventScroll:!0});const i=window.getSelection();if(!i)return!0;const n=document.createRange();return n.selectNode(o),i.removeAllRanges(),i.addRange(n),!0}function ot(t){return Y.get(t)===!0}function W(t,e=!1){const o=v.get(t);o&&(o.classList.remove("show"),Y.set(t,!1),rt(t,"toggleCitationsPanel",!1),e&&t.focus({preventScroll:!0}))}function ee(t){v.forEach((e,o)=>{o!==t&&W(o,!1)})}function lt(t,e){if(!e.classList.contains("show"))return;const i=ut(t).getBoundingClientRect(),n=Math.min(window.innerWidth-20,380),r=Math.max(10,window.innerWidth-n-10),a=Math.min(Math.max(10,i.right-n),r),s=Math.max(10,Math.min(window.innerHeight-10-260,i.top+10));e.style.width=`${n}px`,e.style.left=`${a}px`,e.style.top=`${s}px`,e.style.maxHeight=`${Math.max(260,window.innerHeight-24)}px`}function C(t,e){return t.querySelector(`[data-field="${e}"]`)}function ne(t){const e=C(t,"author")?.value||"",o=C(t,"year")?.value||"",i=C(t,"title")?.value||"",n=C(t,"source")?.value||"",r=C(t,"url")?.value||"",a=C(t,"note")?.value||"";return{author:e,year:o,title:i,source:n,url:r,note:a}}function S(t,e,o=!1){const i=t.querySelector(".rte-citations-live");i&&(i.textContent=e);const n=t.querySelector(".rte-citations-status");n&&(n.textContent=e,n.classList.toggle("rte-citations-status-error",o))}function oe(t,e,o){const i=C(e,"style");i&&(i.value=z(t,o))}function It(t,e,o){const i=L.includes(e)?e:o.defaultStyle;return T.set(t,i),y(t,o,!0),i}function gt(t,e){const o=z(t,e),i=L.indexOf(o),n=L[(i+1)%L.length];return T.set(t,n),y(t,e,!0),n}function ie(t){const e=v.get(t);if(e)return e;const o=f.get(t)||M||Q(),i=`rte-citations-panel-${Dt++}`,n=document.createElement("section");n.className=b,n.id=i,n.setAttribute("role","dialog"),n.setAttribute("aria-modal","false"),n.setAttribute("aria-label",o.labels.panelAriaLabel),n.setAttribute("tabindex","-1"),n.innerHTML=`
|
|
24
24
|
<header class="rte-citations-header">
|
|
25
|
-
<h2 class="rte-citations-title">${g(
|
|
26
|
-
<button type="button" class="rte-citations-icon-btn" data-action="close" aria-label="${g(
|
|
25
|
+
<h2 class="rte-citations-title">${g(o.labels.panelTitle)}</h2>
|
|
26
|
+
<button type="button" class="rte-citations-icon-btn" data-action="close" aria-label="${g(o.labels.closeText)}">✕</button>
|
|
27
27
|
</header>
|
|
28
28
|
<div class="rte-citations-body">
|
|
29
29
|
<p class="rte-citations-status" aria-live="polite"></p>
|
|
30
30
|
|
|
31
31
|
<div class="rte-citations-grid">
|
|
32
32
|
<label class="rte-citations-label">
|
|
33
|
-
${g(
|
|
33
|
+
${g(o.labels.styleLabel)}
|
|
34
34
|
<select data-field="style" class="rte-citations-field">
|
|
35
35
|
<option value="apa">APA</option>
|
|
36
36
|
<option value="mla">MLA</option>
|
|
@@ -38,46 +38,47 @@
|
|
|
38
38
|
</select>
|
|
39
39
|
</label>
|
|
40
40
|
<label class="rte-citations-label">
|
|
41
|
-
${g(
|
|
41
|
+
${g(o.labels.authorLabel)}
|
|
42
42
|
<input type="text" data-field="author" class="rte-citations-field" autocomplete="off" />
|
|
43
43
|
</label>
|
|
44
44
|
<label class="rte-citations-label">
|
|
45
|
-
${g(
|
|
45
|
+
${g(o.labels.yearLabel)}
|
|
46
46
|
<input type="text" data-field="year" class="rte-citations-field" inputmode="numeric" autocomplete="off" />
|
|
47
47
|
</label>
|
|
48
48
|
<label class="rte-citations-label">
|
|
49
|
-
${g(
|
|
49
|
+
${g(o.labels.titleLabel)}
|
|
50
50
|
<input type="text" data-field="title" class="rte-citations-field" autocomplete="off" />
|
|
51
51
|
</label>
|
|
52
52
|
<label class="rte-citations-label">
|
|
53
|
-
${g(
|
|
53
|
+
${g(o.labels.sourceLabel)}
|
|
54
54
|
<input type="text" data-field="source" class="rte-citations-field" autocomplete="off" />
|
|
55
55
|
</label>
|
|
56
56
|
<label class="rte-citations-label">
|
|
57
|
-
${g(
|
|
57
|
+
${g(o.labels.urlLabel)}
|
|
58
58
|
<input type="url" data-field="url" class="rte-citations-field" autocomplete="off" />
|
|
59
59
|
</label>
|
|
60
60
|
<label class="rte-citations-label rte-citations-label-note">
|
|
61
|
-
${g(
|
|
61
|
+
${g(o.labels.noteLabel)}
|
|
62
62
|
<textarea data-field="note" class="rte-citations-field" rows="2"></textarea>
|
|
63
63
|
</label>
|
|
64
64
|
</div>
|
|
65
65
|
|
|
66
66
|
<div class="rte-citations-controls" role="toolbar" aria-label="Citation actions">
|
|
67
|
-
<button type="button" class="rte-citations-btn rte-citations-btn-primary" data-action="insert">${g(
|
|
68
|
-
<button type="button" class="rte-citations-btn" data-action="refresh">${g(
|
|
67
|
+
<button type="button" class="rte-citations-btn rte-citations-btn-primary" data-action="insert">${g(o.labels.insertText)}</button>
|
|
68
|
+
<button type="button" class="rte-citations-btn" data-action="refresh">${g(o.labels.refreshText)}</button>
|
|
69
69
|
<button type="button" class="rte-citations-btn" data-action="cycle-style"></button>
|
|
70
70
|
</div>
|
|
71
71
|
|
|
72
|
-
<section class="rte-citations-recent" aria-label="${g(
|
|
73
|
-
<h3 class="rte-citations-recent-heading">${g(
|
|
72
|
+
<section class="rte-citations-recent" aria-label="${g(o.labels.recentHeading)}">
|
|
73
|
+
<h3 class="rte-citations-recent-heading">${g(o.labels.recentHeading)}</h3>
|
|
74
74
|
<ul class="rte-citations-recent-list" role="list"></ul>
|
|
75
75
|
</section>
|
|
76
76
|
|
|
77
|
+
<p class="rte-citations-status" aria-hidden="true"></p>
|
|
77
78
|
<p class="rte-citations-shortcut">Shortcut: Ctrl/Cmd + Alt + Shift + C</p>
|
|
78
79
|
<span class="rte-citations-live" aria-live="polite"></span>
|
|
79
80
|
</div>
|
|
80
|
-
`,
|
|
81
|
+
`,n.addEventListener("click",a=>{const s=a.target;if(!s)return;const u=s.closest("[data-action]");if(!u)return;const c=u.getAttribute("data-action")||"",l=f.get(t)||M||o;if(f.set(t,l),c==="close"){W(t,!0);return}if(c==="insert"){if($(t))return;const d=ne(n);if(!l.normalizeText(d.author)||!l.normalizeText(d.title)){S(n,l.labels.invalidMessage,!0);return}if(!nt(t,d,l)){S(n,l.labels.invalidMessage,!0);return}S(n,"Citation inserted.");const w=C(n,"title"),A=C(n,"note");w&&(w.value=""),A&&(A.value="");return}if(c==="refresh"){const d=y(t,l,!0);S(n,`Refreshed ${d.length} citation${d.length===1?"":"s"}.`);return}if(c==="cycle-style"){const d=gt(t,l);oe(t,n,l),S(n,`Style changed to ${d.toUpperCase()}.`);return}if(c==="insert-from-recent"){if($(t))return;const d=u.getAttribute("data-citation-id")||"",m=$t(t,d,U(t,l),l);if(!m)return;nt(t,m,l),S(n,`Inserted citation: ${m.title}.`);return}if(c==="delete-by-id"){if($(t))return;const d=u.getAttribute("data-citation-id")||"";if(Nt(t,d,l)){S(n,"Citation deleted.");return}jt(t,d,l)&&(F(t),S(n,"Removed from recent citations."))}}),n.addEventListener("keydown",a=>{if(a.key==="Escape"){a.preventDefault(),W(t,!0);return}const s=a.target;if(!s||!s.matches(".rte-citations-recent-btn")||a.key!=="ArrowDown"&&a.key!=="ArrowUp")return;const u=Array.from(n.querySelectorAll(".rte-citations-recent-btn"));if(u.length===0)return;const c=u.indexOf(s);if(c<0)return;a.preventDefault();const l=a.key==="ArrowDown"?1:-1,d=(c+l+u.length)%u.length;u[d].focus()});const r=C(n,"style");return r?.addEventListener("change",()=>{const a=f.get(t)||M||o,s=r.value;It(t,s,a),S(n,`Style changed to ${s.toUpperCase()}.`)}),et(n,t),document.body.appendChild(n),v.set(t,n),Y.set(t,!1),F(t),n}function I(t){const e=ie(t);ee(t),e.classList.add("show"),Y.set(t,!0),rt(t,"toggleCitationsPanel",!0),et(e,t),lt(t,e),F(t),C(e,"author")?.focus()}function Pt(t,e){const o=ot(t);return(typeof e=="boolean"?e:!o)?I(t):W(t,!1),!0}function mt(t){return typeof t.key=="string"?t.key.toLowerCase():""}function re(t){const e=mt(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="c"}function ae(t){const e=mt(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="b"}function se(t){const e=mt(t);return(t.metaKey||t.ctrlKey)&&t.altKey&&t.shiftKey&&e==="j"}function ce(t){M=t,P||(P=e=>{const i=e.target?.closest(E);if(!i)return;p=i,f.has(i)||f.set(i,t),T.has(i)||T.set(i,t.defaultStyle);const n=v.get(i);n&&(et(n,i),lt(i,n)),rt(i,"toggleCitationsPanel",ot(i))},document.addEventListener("focusin",P,!0)),B||(B=e=>{const i=e.target?.closest(E);i&&(p=i,Mt(i))},document.addEventListener("input",B,!0)),O||(O=e=>{if(e.defaultPrevented)return;const i=!!e.target?.closest(`.${b} input, .${b} textarea, .${b} select`),n=h(void 0,!1);if(!n||$(n))return;const r=f.get(n)||M||t;if(f.set(n,r),p=n,e.key==="Escape"&&ot(n)){e.preventDefault(),W(n,!0);return}if(!i&&!Zt(e,n,r)){if(re(e)){e.preventDefault(),e.stopPropagation(),Pt(n);return}if(ae(e)){e.preventDefault(),e.stopPropagation(),y(n,r,!0),I(n);return}se(e)&&(e.preventDefault(),e.stopPropagation(),gt(n,r))}},document.addEventListener("keydown",O,!0)),k||(k=()=>{v.forEach((e,o)=>{if(!o.isConnected||!e.isConnected){Tt(o),e.remove(),v.delete(o),Y.delete(o);return}et(e,o),lt(o,e)})},window.addEventListener("scroll",k,!0),window.addEventListener("resize",k))}function le(){P&&(document.removeEventListener("focusin",P,!0),P=null),B&&(document.removeEventListener("input",B,!0),B=null),O&&(document.removeEventListener("keydown",O,!0),O=null),k&&(window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k),k=null),v.forEach(t=>t.remove()),v.clear(),M=null,p=null}function ue(){if(typeof document>"u"||document.getElementById(ht))return;const t=document.createElement("style");t.id=ht,t.textContent=`
|
|
81
82
|
.rte-toolbar-group-items.citations,
|
|
82
83
|
.editora-toolbar-group-items.citations {
|
|
83
84
|
display: flex;
|
|
@@ -443,6 +444,30 @@
|
|
|
443
444
|
color: #94a3b8;
|
|
444
445
|
}
|
|
445
446
|
|
|
447
|
+
.rte-citations-status {
|
|
448
|
+
margin: 0;
|
|
449
|
+
min-height: 16px;
|
|
450
|
+
font-size: 12px;
|
|
451
|
+
font-weight: 600;
|
|
452
|
+
color: #166534;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
.rte-citations-status:empty {
|
|
456
|
+
display: none;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
.rte-citations-status.rte-citations-status-error {
|
|
460
|
+
color: #b91c1c;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
.${b}.rte-citations-theme-dark .rte-citations-status {
|
|
464
|
+
color: #86efac;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
.${b}.rte-citations-theme-dark .rte-citations-status.rte-citations-status-error {
|
|
468
|
+
color: #fca5a5;
|
|
469
|
+
}
|
|
470
|
+
|
|
446
471
|
.rte-citations-live {
|
|
447
472
|
position: absolute;
|
|
448
473
|
width: 1px;
|
|
@@ -545,4 +570,4 @@
|
|
|
545
570
|
max-height: 34vh;
|
|
546
571
|
}
|
|
547
572
|
}
|
|
548
|
-
`,document.head.appendChild(t)}const
|
|
573
|
+
`,document.head.appendChild(t)}const de=(t={})=>{const e=Q(t);return ue(),{name:"citations",toolbar:[{id:"citationsGroup",label:"Citations",type:"group",command:"citations",items:[{id:"citations",label:"Citations",command:"toggleCitationsPanel",shortcut:"Mod-Alt-Shift-c",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M6 5h12M6 9h12M6 13h8M6 17h10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M17 14.5a2.5 2.5 0 0 1 2.5 2.5v2H15v-2a2 2 0 0 1 2-2Z" stroke="currentColor" stroke-width="1.5"/></svg>'},{id:"citationsRefresh",label:"Refresh Citations",command:"refreshCitations",shortcut:"Mod-Alt-Shift-b",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M20 12a8 8 0 1 1-2.34-5.66" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><path d="M20 4v6h-6" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"/></svg>'},{id:"citationsStyle",label:"Cycle Citation Style",command:"cycleCitationStyle",shortcut:"Mod-Alt-Shift-j",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M5 6h14M5 10h8M5 14h14M5 18h10" stroke="currentColor" stroke-width="1.7" stroke-linecap="round"/><circle cx="18" cy="10" r="2" stroke="currentColor" stroke-width="1.6"/></svg>'}]}],commands:{citations:(o,i)=>{const n=h(i);if(!n||$(n))return!1;const r=f.get(n)||e;return f.set(n,r),T.set(n,z(n,r)),p=n,I(n),y(n,r,!1),!0},toggleCitationsPanel:(o,i)=>{const n=h(i);if(!n||$(n))return!1;const r=f.get(n)||e;f.set(n,r),p=n;const a=Pt(n,typeof o=="boolean"?o:void 0);return ot(n)&&y(n,r,!1),a},insertCitation:(o,i)=>{const n=h(i);if(!n||$(n)||!o||typeof o!="object")return!1;const r=f.get(n)||e;f.set(n,r),p=n;const a=nt(n,o,r);return a&&I(n),a},refreshCitations:(o,i)=>{const n=h(i);if(!n)return!1;const r=f.get(n)||e;return f.set(n,r),p=n,y(n,r,!0),I(n),!0},setCitationStyle:(o,i)=>{const n=h(i);if(!n||!o)return!1;const r=f.get(n)||e;return f.set(n,r),p=n,It(n,o,r),!0},cycleCitationStyle:(o,i)=>{const n=h(i);if(!n)return!1;const r=f.get(n)||e;return f.set(n,r),p=n,gt(n,r),F(n),!0},getCitationRecords:(o,i)=>{const n=h(i);if(!n)return!1;const r=f.get(n)||e,a=U(n,r);if(typeof o=="function")try{o(a)}catch{}return n.__citationRecords=a,n.dispatchEvent(new CustomEvent("editora:citations-data",{bubbles:!0,detail:{records:a,style:z(n,r)}})),!0},setCitationsOptions:(o,i)=>{const n=h(i);if(!n||!o||typeof o!="object")return!1;const r=f.get(n)||e,a=Q({...r,...o,labels:{...r.labels,...o.labels||{}},normalizeText:o.normalizeText||r.normalizeText,generateCitationId:o.generateCitationId||r.generateCitationId});return f.set(n,a),o.defaultStyle&&L.includes(o.defaultStyle)&&T.set(n,o.defaultStyle),y(n,a,!0),F(n),!0},locateCitation:(o,i)=>{const n=h(i);return!n||typeof o!="string"?!1:te(n,o)},deleteCitation:(o,i)=>{const n=h(i);if(!n||$(n))return!1;const r=f.get(n)||e;return f.set(n,r),typeof o=="string"&&o.trim()?Nt(n,o,r):Qt(n,r)},insertRecentCitation:(o,i)=>{const n=h(i);if(!n||$(n))return!1;const r=f.get(n)||e;f.set(n,r);const a=U(n,r),s=at(n,a,r);if(s.length===0)return!1;const u=typeof o=="string"&&o.trim()?$t(n,o,a,r):s[0];if(!u)return!1;const c=nt(n,u,r);return c&&I(n),c}},keymap:{"Mod-Alt-Shift-c":"toggleCitationsPanel","Mod-Alt-Shift-C":"toggleCitationsPanel","Mod-Alt-Shift-b":"refreshCitations","Mod-Alt-Shift-B":"refreshCitations","Mod-Alt-Shift-j":"cycleCitationStyle","Mod-Alt-Shift-J":"cycleCitationStyle"},init:function(i){X+=1;const n=this&&typeof this.__pluginConfig=="object"?Q({...e,...this.__pluginConfig}):e;ce(n);const r=h(i&&i.editorElement?{editorElement:i.editorElement}:void 0,!1);r&&(p=r,f.set(r,n),T.set(r,n.defaultStyle),rt(r,"toggleCitationsPanel",!1),Mt(r))},destroy:()=>{X=Math.max(0,X-1),!(X>0)&&(K.forEach(o=>{window.clearTimeout(o)}),K.clear(),le())}}};exports.CitationsPlugin=de;
|