@editora/plugins 1.0.12 → 1.0.13
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/approval-workflow.cjs.js +14 -14
- package/dist/approval-workflow.esm.js +265 -262
- package/dist/blockquote.cjs.js +1 -1
- package/dist/blockquote.esm.js +177 -15
- package/dist/blocks-library.cjs.js +6 -6
- package/dist/blocks-library.esm.js +95 -92
- package/dist/bold.cjs.js +1 -1
- package/dist/bold.esm.js +10 -6
- package/dist/capitalization.cjs.js +1 -1
- package/dist/capitalization.esm.js +124 -44
- package/dist/checklist.cjs.js +1 -1
- package/dist/checklist.esm.js +251 -191
- package/dist/citations.cjs.js +4 -4
- package/dist/citations.esm.js +131 -128
- package/dist/clear-formatting.cjs.js +1 -1
- package/dist/clear-formatting.esm.js +68 -36
- package/dist/content-rules.cjs.js +5 -5
- package/dist/content-rules.esm.js +104 -101
- package/dist/data-binding.cjs.js +3 -3
- package/dist/data-binding.esm.js +51 -48
- package/dist/direction.cjs.js +1 -1
- package/dist/direction.esm.js +97 -74
- package/dist/doc-schema.cjs.js +4 -4
- package/dist/doc-schema.esm.js +104 -101
- package/dist/embed-iframe.cjs.js +21 -4
- package/dist/embed-iframe.esm.js +279 -116
- package/dist/heading.cjs.js +1 -1
- package/dist/heading.esm.js +239 -56
- package/dist/history.cjs.js +1 -1
- package/dist/history.esm.js +74 -89
- package/dist/inlineFormatting-DOYOJdnD.js +1 -0
- package/dist/inlineFormatting-DuVTGXYG.mjs +95 -0
- package/dist/italic.cjs.js +1 -1
- package/dist/italic.esm.js +12 -8
- package/dist/math.cjs.js +27 -21
- package/dist/math.esm.js +218 -146
- package/dist/merge-tag.cjs.js +8 -2
- package/dist/merge-tag.esm.js +130 -111
- package/dist/pii-redaction.cjs.js +6 -6
- package/dist/pii-redaction.esm.js +169 -166
- package/dist/smart-paste.cjs.js +5 -5
- package/dist/smart-paste.esm.js +120 -117
- package/dist/special-characters.cjs.js +6 -10
- package/dist/special-characters.esm.js +97 -75
- package/dist/strikethrough.cjs.js +1 -1
- package/dist/strikethrough.esm.js +11 -25
- package/dist/translation-workflow.cjs.js +7 -7
- package/dist/translation-workflow.esm.js +103 -100
- package/dist/underline.cjs.js +1 -1
- package/dist/underline.esm.js +7 -3
- package/package.json +3 -3
package/dist/smart-paste.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=".rte-content, .editora-content",ee="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",
|
|
2
|
-
`)}function z(e){return e==="balanced"||e==="plain"?e:"fidelity"}function Z(e,t){return{keepStyles:e?.keepStyles??t.keepStyles,keepClasses:e?.keepClasses??t.keepClasses,keepDataAttributes:e?.keepDataAttributes??t.keepDataAttributes,preserveTables:e?.preserveTables??t.preserveTables}}function K(e={}){const t=e.profileOptions||{};return{enabled:e.enabled!==!1,defaultProfile:z(e.defaultProfile),maxHtmlLength:Math.max(8e3,Math.min(8e5,Number(e.maxHtmlLength??22e4))),removeComments:e.removeComments!==!1,normalizeWhitespace:e.normalizeWhitespace!==!1,labels:{
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const y=".rte-content, .editora-content",ee="[data-editora-editor], .rte-editor, .editora-editor, editora-editor",le="__editoraCommandEditorRoot",ie="rte-smart-paste-styles",u="rte-smart-paste-panel",h="smart-paste",S="smartPaste",E=':is([data-theme="dark"], .dark, .editora-theme-dark, .rte-theme-dark)',ke=typeof NodeFilter<"u"?NodeFilter.SHOW_COMMENT:128,ce="__editoraSmartPasteHandled",Ce=new Set(["script","style","meta","link","object","embed","iframe","svg","canvas","math","form","input","button","textarea","select","option"]),Te=new Set(["table","thead","tbody","tfoot","tr","td","th","colgroup","col"]),Pe=new Set(["span","font"]),Ae=/^(https?:|mailto:|tel:|#|\/)/i,we=/^data:image\/(?:png|gif|jpeg|jpg|webp);base64,/i,Le=new Set(["color","background-color","font-weight","font-style","text-decoration","text-align","font-size","font-family","line-height","letter-spacing","word-spacing","white-space","vertical-align","margin-left","margin-right","margin-top","margin-bottom","padding-left","padding-right","padding-top","padding-bottom","text-indent","border","border-top","border-right","border-bottom","border-left","border-color","border-width","border-style","list-style-type"]),$e={panelTitle:"Smart Paste",panelAriaLabel:"Smart paste panel",enabledText:"Smart paste is enabled",disabledText:"Smart paste is disabled",toggleOnText:"Disable Smart Paste",toggleOffText:"Enable Smart Paste",cycleProfileText:"Cycle Profile",profileLabel:"Profile",fidelityText:"Fidelity",balancedText:"Balanced",plainText:"Plain Text",lastPasteHeading:"Last Paste Result",lastPasteEmptyText:"Paste content to see cleanup metrics.",lastPasteSourceLabel:"Source",lastPasteProfileLabel:"Profile",lastPasteRemovedLabel:"Removed",lastPasteCharsLabel:"Output Chars",closeText:"Close",shortcutText:"Shortcuts: Ctrl/Cmd+Alt+Shift+S/V/G",readonlyMessage:"Editor is read-only. Smart paste was skipped."},Y={fidelity:{keepStyles:!0,keepClasses:!1,keepDataAttributes:!1,preserveTables:!0},balanced:{keepStyles:!1,keepClasses:!1,keepDataAttributes:!1,preserveTables:!0},plain:{keepStyles:!1,keepClasses:!1,keepDataAttributes:!1,preserveTables:!1}},d=new WeakMap,L=new WeakMap,g=new Map,q=new WeakMap,j=new WeakMap,_=new Set;let I=0,Me=0,$=null,m=null,P=null,A=null,T=null,w=null;function X(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Oe(e){return e.replace(/\u00A0/g," ").replace(/\r\n?/g,`
|
|
2
|
+
`)}function z(e){return e==="balanced"||e==="plain"?e:"fidelity"}function Z(e,t){return{keepStyles:e?.keepStyles??t.keepStyles,keepClasses:e?.keepClasses??t.keepClasses,keepDataAttributes:e?.keepDataAttributes??t.keepDataAttributes,preserveTables:e?.preserveTables??t.preserveTables}}function K(e={}){const t=e.profileOptions||{};return{enabled:e.enabled!==!1,defaultProfile:z(e.defaultProfile),maxHtmlLength:Math.max(8e3,Math.min(8e5,Number(e.maxHtmlLength??22e4))),removeComments:e.removeComments!==!1,normalizeWhitespace:e.normalizeWhitespace!==!1,labels:{...$e,...e.labels||{}},normalizeText:e.normalizeText||Oe,profileOptions:{fidelity:Z(t.fidelity,Y.fidelity),balanced:Z(t.balanced,Y.balanced),plain:Z(t.plain,Y.plain)}}}function de(e){return{enabled:e.enabled,defaultProfile:e.defaultProfile,maxHtmlLength:e.maxHtmlLength,removeComments:e.removeComments,normalizeWhitespace:e.normalizeWhitespace,labels:{...e.labels},normalizeText:e.normalizeText,profileOptions:{fidelity:{...e.profileOptions.fidelity},balanced:{...e.profileOptions.balanced},plain:{...e.profileOptions.plain}}}}function te(e){return e.closest(ee)||e}function H(e){if(!e)return null;if(e.matches(y))return e;const t=e.querySelector(y);return t instanceof HTMLElement?t:null}function Re(){if(typeof window>"u")return null;const e=window[le];if(!(e instanceof HTMLElement))return null;window[le]=null;const t=H(e);if(t)return t;const a=e.closest(ee);if(a){const n=H(a);if(n)return n}const r=e.closest(y);return r instanceof HTMLElement?r:null}function _e(e){const t=e.closest("[data-editora-editor]");if(t&&H(t)===e)return t;let a=e;for(;a;){if(a.matches(ee)&&(a===e||H(a)===e))return a;a=a.parentElement}return te(e)}function me(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function C(e,t=!0,a=!0){if(V(),e?.contentElement instanceof HTMLElement)return e.contentElement;if(e?.editorElement instanceof HTMLElement){const s=H(e.editorElement);if(s)return s}const r=Re();if(r)return r;const n=window.getSelection();if(n&&n.rangeCount>0){const l=me(n.getRangeAt(0).startContainer)?.closest(y);if(l)return l}const o=document.activeElement;if(o){if(o.matches(y))return o;const s=o.closest(y);if(s)return s}if(a){if(m&&m.isConnected)return m;m&&!m.isConnected&&(m=null)}return t?document.querySelector(y):null}function ze(e){const t=e.target;if(t){const r=t.closest(y);if(r)return r}const a=window.getSelection();if(a&&a.rangeCount>0){const n=me(a.getRangeAt(0).startContainer)?.closest(y);if(n)return n}return null}function B(e){return e?(e.getAttribute("data-theme")||e.getAttribute("theme")||"").toLowerCase()==="dark"?!0:e.classList.contains("dark")||e.classList.contains("editora-theme-dark")||e.classList.contains("rte-theme-dark"):!1}function He(e){const t=te(e);if(B(t))return!0;const a=t.closest("[data-theme], [theme], .dark, .editora-theme-dark, .rte-theme-dark");return B(a)?!0:B(document.documentElement)||B(document.body)}function F(e,t){e.classList.remove("rte-smart-paste-theme-dark"),He(t)&&e.classList.add("rte-smart-paste-theme-dark")}function ue(e){return e.getAttribute("contenteditable")==="false"||e.getAttribute("data-readonly")==="true"}function D(e,t,a){const r=_e(e);Array.from(r.querySelectorAll(`.rte-toolbar-button[data-command="${t}"], .editora-toolbar-button[data-command="${t}"]`)).forEach(o=>{o.classList.toggle("active",a),o.setAttribute("data-active",a?"true":"false"),o.setAttribute("aria-pressed",a?"true":"false")})}function p(e,t){d.has(e)||d.set(e,t);let a=L.get(e);return a||(a={enabled:t.enabled,profile:t.defaultProfile,lastReport:null},L.set(e,a)),et(e),_.add(e),a}function be(e){const t=j.get(e);t&&(e.removeEventListener("paste",t,!0),j.delete(e))}function ge(e){be(e),g.get(e)?.remove(),g.delete(e),q.delete(e),d.delete(e),L.delete(e),_.delete(e),m===e&&(m=null)}function V(){Array.from(_).forEach(t=>{t.isConnected||ge(t)})}function De(e){for(let t=0;t<e.length;t+=1){const a=e[t];if(!(a.type!=="childList"||a.removedNodes.length===0))for(let r=0;r<a.removedNodes.length;r+=1){const n=a.removedNodes[r];if(n.nodeType!==Node.ELEMENT_NODE)continue;const o=n;if(o.matches?.(y)||o.matches?.(`.${u}`)||o.querySelector?.(y)||o.querySelector?.(`.${u}`))return!0}}return!1}function re(e){return q.get(e)===!0}function O(e,t){const a=e.querySelector(".rte-smart-paste-live");a&&(a.textContent=t)}function J(e,t){const a=t.normalizeText(e);return t.normalizeWhitespace?a.split(`
|
|
3
3
|
`).map(n=>n.replace(/[\t ]+/g," ").trimEnd()).join(`
|
|
4
4
|
`).replace(/\n{3,}/g,`
|
|
5
5
|
|
|
6
|
-
`).trim():a}function
|
|
6
|
+
`).trim():a}function Ne(e){return/class=["'][^"']*Mso|xmlns:w=|urn:schemas-microsoft-com:office|<o:p\b/i.test(e)}function qe(e){return/id=["']docs-internal-guid|docs-\w+|data-sheets-value|data-sheets-userformat/i.test(e)}function Ie(e,t){return e?Ne(e)?"word":qe(e)?"google-docs":"html":t?"plain":"html"}function Be(e){return e.split(/\s+/).map(a=>a.trim()).filter(Boolean).filter(a=>!/^mso/i.test(a)).filter(a=>!/^docs-/i.test(a)).filter(a=>!/^c\d+$/i.test(a)).join(" ")}function We(e){if(!e)return{value:"",changed:!1};const t=e.split(";"),a=[];let r=!1;return t.forEach(n=>{const o=n.indexOf(":");if(o<=0){n.trim()&&(r=!0);return}const s=n.slice(0,o).trim().toLowerCase(),l=n.slice(o+1).trim();if(!s||!l){r=!0;return}if(!Le.has(s)){r=!0;return}if(/expression\s*\(|javascript\s*:|vbscript\s*:|url\s*\(/i.test(l)){r=!0;return}a.push(`${s}: ${l}`)}),{value:a.join("; "),changed:r}}function fe(e){const t=e.trim();return t&&(Ae.test(t)||we.test(t))?t:""}function pe(e){const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}}function Ke(e,t,a,r){const n=e.tagName.toLowerCase();if(Ce.has(n)){r.removedElements+=1,e.remove();return}if(!t.preserveTables&&Te.has(n)){const s=e.textContent||"",l=document.createTextNode(s);e.replaceWith(l),r.removedElements+=1;return}if(Array.from(e.attributes).forEach(s=>{const l=s.name.toLowerCase(),i=s.value;if(l.startsWith("on")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="style"){if(!t.keepStyles){e.removeAttribute(s.name),r.removedAttributes+=1;return}const c=We(i);if(!c.value){e.removeAttribute(s.name),r.removedAttributes+=1,c.changed&&(r.normalizedStyles+=1);return}(c.changed||c.value!==i)&&(e.setAttribute("style",c.value),r.normalizedStyles+=1);return}if(l==="class"){if(!t.keepClasses){e.removeAttribute(s.name),r.removedAttributes+=1;return}const c=Be(i);if(!c){e.removeAttribute(s.name),r.removedAttributes+=1;return}c!==i&&(e.setAttribute("class",c),r.removedAttributes+=1);return}if(l.startsWith("data-")&&!t.keepDataAttributes){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="id"||l==="xmlns"||l.startsWith("xml")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if((a==="word"||a==="google-docs")&&(l==="lang"||l==="dir")){e.removeAttribute(s.name),r.removedAttributes+=1;return}if(l==="href"||l==="src"||l==="xlink:href"){const c=fe(i);if(!c){e.removeAttribute(s.name),r.removedAttributes+=1;return}c!==i&&e.setAttribute(s.name,c)}}),n==="a"){if(!e.getAttribute("href")){pe(e),r.removedElements+=1;return}e.getAttribute("target")==="_blank"&&e.setAttribute("rel","noopener noreferrer")}if(n==="img"){const s=e.getAttribute("src");if(!s||!fe(s)){r.removedElements+=1,e.remove();return}}if(Pe.has(n)&&!e.attributes.length&&!e.className&&!e.style.cssText){const s=e.children.length>0,l=(e.textContent||"").trim().length>0;if(!s&&!l){e.remove(),r.removedElements+=1;return}!s&&l&&(pe(e),r.removedElements+=1)}}function Ve(e,t,a,r,n){const o=document.createElement("template");o.innerHTML=e;const s={removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0};if(r.removeComments)try{const f=document.createTreeWalker(o.content,ke,null),b=[];let k=f.nextNode();for(;k;)b.push(k),k=f.nextNode();b.forEach(v=>{v.remove(),s.removedComments+=1})}catch{}Array.from(o.content.querySelectorAll("*")).forEach(f=>{f.isConnected&&Ke(f,t,a,s)});let i=o.innerHTML;r.normalizeWhitespace&&n!=="fidelity"?i=i.replace(/\s{2,}/g," ").replace(/>\s+</g,"><").trim():r.normalizeWhitespace&&(i=i.trim());const c=(o.content.textContent||"").trim().length;return{html:i,textLength:c,counters:s}}function he(e){const t=window.getSelection();if(!t||t.rangeCount===0)return null;const a=t.getRangeAt(0);return e.contains(a.commonAncestorContainer)?a:null}function ye(e,t){if(!e.isConnected)return;const a=window.getSelection();a&&(a.removeAllRanges(),a.addRange(t))}function je(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertHTML",!1,t))return!0}catch{}const a=he(e);if(!a)return!1;a.deleteContents();const r=document.createElement("template");r.innerHTML=t;const n=r.content,o=n.lastChild;if(a.insertNode(n),o){const s=document.createRange();s.setStartAfter(o),s.collapse(!0),ye(e,s)}return!0}function Fe(e,t){e.focus({preventScroll:!0});try{if(document.execCommand("insertText",!1,t))return!0}catch{}const a=he(e);if(!a)return!1;a.deleteContents();const r=document.createTextNode(t);a.insertNode(r);const n=document.createRange();return n.setStart(r,r.length),n.collapse(!0),ye(e,n),!0}function Ge(e,t){if(t===e.innerHTML)return;const a=window.execEditorCommand||window.executeEditorCommand;if(typeof a=="function")try{a("recordDomTransaction",e,t,e.innerHTML)}catch{}}function Ue(e){e.dispatchEvent(new Event("input",{bubbles:!0}))}function W(e,t,a,r,n,o){return{source:e,profile:t,inputHtmlLength:a,outputHtmlLength:r,outputTextLength:n,removedElements:o.removedElements,removedAttributes:o.removedAttributes,removedComments:o.removedComments,normalizedStyles:o.normalizedStyles,createdAt:new Date().toISOString()}}function Ye(e,t,a,r){const n=Ie(e,t);if(a==="plain"){const l=t||e.replace(/<[^>]*>/g," "),i=J(l,r);return{mode:"text",value:i,report:W(n,a,e.length,0,i.length,{removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0})}}if(!e||e.length>r.maxHtmlLength){const l=J(t||e.replace(/<[^>]*>/g," "),r);return{mode:"text",value:l,report:W(n,a,e.length,0,l.length,{removedElements:0,removedAttributes:0,removedComments:0,normalizedStyles:0})}}const o=r.profileOptions[a],s=Ve(e,o,n,r,a);if(!s.html){const l=J(t||e.replace(/<[^>]*>/g," "),r);return{mode:"text",value:l,report:W(n,a,e.length,0,l.length,s.counters)}}return{mode:"html",value:s.html,report:W(n,a,e.length,s.html.length,s.textLength,s.counters)}}function G(e,t){return e==="balanced"?t.balancedText:e==="plain"?t.plainText:t.fidelityText}function ae(e){return e==="fidelity"?"balanced":e==="balanced"?"plain":"fidelity"}function Xe(e,t){e.setAttribute("aria-label",t.labels.panelAriaLabel);const a=e.querySelector(".rte-smart-paste-title");a&&(a.textContent=t.labels.panelTitle);const r=e.querySelector('[data-action="close"]');r&&r.setAttribute("aria-label",t.labels.closeText);const n=e.querySelector('[data-action="toggle-enabled"]');if(n){const Ee=n.getAttribute("data-enabled")==="true";n.textContent=Ee?t.labels.toggleOnText:t.labels.toggleOffText}const o=e.querySelector('[data-action="cycle-profile"]');o&&(o.textContent=t.labels.cycleProfileText);const s=e.querySelector(".rte-smart-paste-profile-heading");s&&(s.textContent=t.labels.profileLabel);const l=e.querySelector('.rte-smart-paste-profile[role="group"]');l&&l.setAttribute("aria-label",t.labels.profileLabel);const i=e.querySelector('[data-action="set-profile"][data-profile="fidelity"]');i&&(i.textContent=t.labels.fidelityText);const c=e.querySelector('[data-action="set-profile"][data-profile="balanced"]');c&&(c.textContent=t.labels.balancedText);const f=e.querySelector('[data-action="set-profile"][data-profile="plain"]');f&&(f.textContent=t.labels.plainText);const b=e.querySelector(".rte-smart-paste-report-title");b&&(b.textContent=t.labels.lastPasteHeading);const k=e.querySelector(".rte-smart-paste-empty");k&&(k.textContent=t.labels.lastPasteEmptyText);const v=e.querySelector('[data-key="source-label"]');v&&(v.textContent=t.labels.lastPasteSourceLabel);const U=e.querySelector('[data-key="profile-label"]');U&&(U.textContent=t.labels.lastPasteProfileLabel);const M=e.querySelector('[data-key="removed-label"]');M&&(M.textContent=t.labels.lastPasteRemovedLabel);const ne=e.querySelector('[data-key="chars-label"]');ne&&(ne.textContent=t.labels.lastPasteCharsLabel);const se=e.querySelector(".rte-smart-paste-shortcut");se&&(se.textContent=t.labels.shortcutText)}function x(e){const t=g.get(e),a=d.get(e)||$,r=L.get(e);if(!t||!a||!r)return;Xe(t,a);const n=t.querySelector(".rte-smart-paste-status");n&&(n.textContent=r.enabled?a.labels.enabledText:a.labels.disabledText);const o=t.querySelector('[data-action="toggle-enabled"]');o&&(o.setAttribute("data-enabled",r.enabled?"true":"false"),o.textContent=r.enabled?a.labels.toggleOnText:a.labels.toggleOffText,o.setAttribute("aria-pressed",r.enabled?"true":"false")),Array.from(t.querySelectorAll('[data-action="set-profile"][data-profile]')).forEach(v=>{const M=z(v.getAttribute("data-profile"))===r.profile;v.classList.toggle("active",M),v.setAttribute("aria-pressed",M?"true":"false")});const l=t.querySelector(".rte-smart-paste-empty"),i=t.querySelector(".rte-smart-paste-report"),c=t.querySelector('[data-key="source-value"]'),f=t.querySelector('[data-key="profile-value"]'),b=t.querySelector('[data-key="removed-value"]'),k=t.querySelector('[data-key="chars-value"]');if(!r.lastReport){l&&(l.hidden=!1),i&&(i.hidden=!0);return}if(l&&(l.hidden=!0),i&&(i.hidden=!1),c&&(c.textContent=r.lastReport.source),f&&(f.textContent=G(r.lastReport.profile,a.labels)),b){const v=r.lastReport.removedElements+r.lastReport.removedAttributes+r.lastReport.removedComments+r.lastReport.normalizedStyles;b.textContent=String(v)}k&&(k.textContent=String(r.lastReport.outputTextLength))}function Q(e,t){if(!t.classList.contains("show"))return;const a=te(e).getBoundingClientRect(),r=Math.min(window.innerWidth-20,360),n=Math.max(10,window.innerWidth-r-10),o=Math.min(Math.max(10,a.right-r),n),s=Math.max(10,Math.min(window.innerHeight-10,a.top+12));t.style.width=`${r}px`,t.style.left=`${o}px`,t.style.top=`${s}px`,t.style.maxHeight=`${Math.max(240,window.innerHeight-20)}px`}function N(e,t=!1){const a=g.get(e);a&&(a.classList.remove("show"),q.set(e,!1),D(e,"toggleSmartPastePanel",!1),t&&e.focus({preventScroll:!0}))}function Ze(e){const t=g.get(e);if(t)return t;const a=d.get(e)||$||K(),r=`rte-smart-paste-panel-${Me++}`,n=document.createElement("section");return n.className=u,n.id=r,n.setAttribute("role","dialog"),n.setAttribute("aria-modal","false"),n.setAttribute("aria-label",a.labels.panelAriaLabel),n.innerHTML=`
|
|
7
7
|
<header class="rte-smart-paste-header">
|
|
8
8
|
<h2 class="rte-smart-paste-title">${X(a.labels.panelTitle)}</h2>
|
|
9
9
|
<button type="button" class="rte-smart-paste-icon-btn" data-action="close" aria-label="${X(a.labels.closeText)}">✕</button>
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
<p class="rte-smart-paste-shortcut"></p>
|
|
36
36
|
</div>
|
|
37
37
|
<div class="rte-smart-paste-live" aria-live="polite" aria-atomic="true"></div>
|
|
38
|
-
`,n.addEventListener("click",o=>{const l=o.target?.closest("[data-action]");if(!l)return;const i=l.getAttribute("data-action");if(i){if(i==="close"){N(e,!0);return}if(i==="toggle-enabled"){const c=p(e,d.get(e)||a);c.enabled=!c.enabled,D(e,"toggleSmartPasteEnabled",c.enabled),x(e),O(n,c.enabled?a.labels.enabledText:a.labels.disabledText);return}if(i==="cycle-profile"){const c=p(e,d.get(e)||a);c.profile=ae(c.profile),x(e),O(n,`${a.labels.profileLabel}: ${G(c.profile,a.labels)}`);return}if(i==="set-profile"){const c=p(e,d.get(e)||a);c.profile=z(l.getAttribute("data-profile")),x(e),O(n,`${a.labels.profileLabel}: ${G(c.profile,a.labels)}`)}}}),n.addEventListener("keydown",o=>{if(o.key==="Escape"){o.preventDefault(),N(e,!0);return}if(o.key!=="ArrowRight"&&o.key!=="ArrowLeft")return;const s=Array.from(n.querySelectorAll('[data-action="set-profile"][data-profile]'));if(s.length===0)return;const l=s.findIndex(f=>f===document.activeElement);if(l<0)return;const i=o.key==="ArrowRight"?1:-1,c=(l+i+s.length)%s.length;o.preventDefault(),s[c].focus()}),F(n,e),document.body.appendChild(n),g.set(e,n),q.set(e,!1),x(e),n}function
|
|
38
|
+
`,n.addEventListener("click",o=>{const l=o.target?.closest("[data-action]");if(!l)return;const i=l.getAttribute("data-action");if(i){if(i==="close"){N(e,!0);return}if(i==="toggle-enabled"){const c=p(e,d.get(e)||a);c.enabled=!c.enabled,D(e,"toggleSmartPasteEnabled",c.enabled),x(e),O(n,c.enabled?a.labels.enabledText:a.labels.disabledText);return}if(i==="cycle-profile"){const c=p(e,d.get(e)||a);c.profile=ae(c.profile),x(e),O(n,`${a.labels.profileLabel}: ${G(c.profile,a.labels)}`);return}if(i==="set-profile"){const c=p(e,d.get(e)||a);c.profile=z(l.getAttribute("data-profile")),x(e),O(n,`${a.labels.profileLabel}: ${G(c.profile,a.labels)}`)}}}),n.addEventListener("keydown",o=>{if(o.key==="Escape"){o.preventDefault(),N(e,!0);return}if(o.key!=="ArrowRight"&&o.key!=="ArrowLeft")return;const s=Array.from(n.querySelectorAll('[data-action="set-profile"][data-profile]'));if(s.length===0)return;const l=s.findIndex(f=>f===document.activeElement);if(l<0)return;const i=o.key==="ArrowRight"?1:-1,c=(l+i+s.length)%s.length;o.preventDefault(),s[c].focus()}),F(n,e),document.body.appendChild(n),g.set(e,n),q.set(e,!1),x(e),n}function xe(e){const t=Ze(e);g.forEach((r,n)=>{n!==e&&N(n,!1)}),t.classList.add("show"),q.set(e,!0),D(e,"toggleSmartPastePanel",!0),F(t,e),Q(e,t),t.querySelector('[data-action="toggle-enabled"]')?.focus()}function ve(e,t){const a=re(e);return(typeof t=="boolean"?t:!a)?xe(e):N(e,!1),!0}function Se(e){return{enabled:e.enabled,profile:e.profile,lastReport:e.lastReport?{...e.lastReport}:null}}function Je(e,t){const a=d.get(e)||$;if(!a)return!1;const r=p(e,a);if(!r.enabled||ue(e)){const b=g.get(e);return b&&ue(e)&&O(b,a.labels.readonlyMessage),!1}const n=t.clipboardData;if(!n)return!1;const o=n.getData("text/html")||"",s=n.getData("text/plain")||"";if(!o&&!s)return!1;const l=Ye(o,s,r.profile,a);if(!l.value)return!1;const i=e.innerHTML;if(!(l.mode==="html"?je(e,l.value):Fe(e,l.value)))return!1;r.lastReport={...l.report},L.set(e,r),Ge(e,i),Ue(e),e.dispatchEvent(new CustomEvent("editora:smart-paste",{bubbles:!0,detail:Se(r)})),x(e);const f=g.get(e);if(f){const b=l.report.removedElements+l.report.removedAttributes+l.report.removedComments+l.report.normalizedStyles;O(f,`${a.labels.panelTitle}: ${G(r.profile,a.labels)}. ${a.labels.lastPasteRemovedLabel}: ${b}.`)}return!0}function Qe(e){return t=>{t.defaultPrevented||t[ce]===!0||(m=e,!Je(e,t))||(t[ce]=!0,t.preventDefault(),typeof t.stopImmediatePropagation=="function"?t.stopImmediatePropagation():t.stopPropagation())}}function et(e){if(j.has(e))return;const t=Qe(e);e.addEventListener("paste",t,!0),j.set(e,t)}function R(e){const t=L.get(e);D(e,"toggleSmartPastePanel",re(e)),D(e,"toggleSmartPasteEnabled",t?.enabled===!0)}function oe(e){return typeof e.key=="string"?e.key.toLowerCase():""}function tt(e){const t=oe(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="s"}function rt(e){const t=oe(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="v"}function at(e){const t=oe(e);return(e.metaKey||e.ctrlKey)&&e.altKey&&e.shiftKey&&t==="g"}function ot(e){$=e,P||(P=t=>{V();const r=t.target?.closest(y);if(!r)return;const n=d.get(r)||e;p(r,n),d.set(r,n),m=r,R(r);const o=g.get(r);o&&(F(o,r),Q(r,o),x(r))},document.addEventListener("focusin",P,!0)),A||(A=t=>{if(t.defaultPrevented||t.target?.closest(`.${u} input, .${u} textarea, .${u} select`))return;const r=ze(t);if(!r)return;const n=d.get(r)||$||e;if(p(r,n),d.set(r,n),m=r,t.key==="Escape"&&re(r)){t.preventDefault(),N(r,!0);return}if(tt(t)){t.preventDefault(),t.stopPropagation(),ve(r);return}if(rt(t)){t.preventDefault(),t.stopPropagation();const o=p(r,n);o.profile=ae(o.profile),x(r);return}if(at(t)){t.preventDefault(),t.stopPropagation();const o=p(r,n);o.enabled=!o.enabled,R(r),x(r)}},document.addEventListener("keydown",A,!0)),T||(T=()=>{V(),g.forEach((t,a)=>{!a.isConnected||!t.isConnected||(F(t,a),Q(a,t))})},window.addEventListener("scroll",T,!0),window.addEventListener("resize",T)),!w&&typeof MutationObserver<"u"&&document.body&&(w=new MutationObserver(t=>{De(t)&&V()}),w.observe(document.body,{childList:!0,subtree:!0}))}function nt(){P&&(document.removeEventListener("focusin",P,!0),P=null),A&&(document.removeEventListener("keydown",A,!0),A=null),T&&(window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T),T=null),w&&(w.disconnect(),w=null),g.forEach(e=>e.remove()),g.clear(),_.forEach(e=>be(e)),_.clear(),$=null,m=null}function st(){if(typeof document>"u"||document.getElementById(ie))return;const e=document.createElement("style");e.id=ie,e.textContent=`
|
|
39
39
|
.rte-toolbar-group-items.${h},
|
|
40
40
|
.editora-toolbar-group-items.${h},
|
|
41
41
|
.rte-toolbar-group-items.${S},
|
|
@@ -395,4 +395,4 @@
|
|
|
395
395
|
grid-template-columns: 1fr;
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
|
-
`,document.head.appendChild(e)}const
|
|
398
|
+
`,document.head.appendChild(e)}const lt=(e={})=>{const t=K(e),a=new Set;return st(),{name:"smartPaste",toolbar:[{id:"smartPasteGroup",label:"Smart Paste",type:"group",command:"smartPaste",items:[{id:"smartPaste",label:"Smart Paste Panel",command:"toggleSmartPastePanel",shortcut:"Mod-Alt-Shift-s",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M8.5 4.5h7l3 3V18a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 6.5 18V7a2.5 2.5 0 0 1 2-2.45Z" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><path d="M15.5 4.5V8h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/><path d="M9.3 12h5.4M9.3 15h5.4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'},{id:"smartPasteProfile",label:"Cycle Smart Paste Profile",command:"cycleSmartPasteProfile",shortcut:"Mod-Alt-Shift-v",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><path d="M4.5 7.5h10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="17.5" cy="7.5" r="2" stroke="currentColor" stroke-width="1.6"/><path d="M4.5 12h5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="12.5" cy="12" r="2" stroke="currentColor" stroke-width="1.6"/><path d="M4.5 16.5h12" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><circle cx="9.5" cy="16.5" r="2" stroke="currentColor" stroke-width="1.6"/></svg>'},{id:"smartPasteToggle",label:"Toggle Smart Paste",command:"toggleSmartPasteEnabled",shortcut:"Mod-Alt-Shift-g",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none" focusable="false" aria-hidden="true"><rect x="3.5" y="8" width="17" height="8" rx="4" stroke="currentColor" stroke-width="1.6"/><circle cx="8" cy="12" r="2.6" fill="currentColor"/><path d="M14.5 12h3" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/></svg>'}]}],commands:{smartPaste:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t;return p(o,s),d.set(o,s),m=o,xe(o),!0},toggleSmartPastePanel:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t;return p(o,s),d.set(o,s),m=o,ve(o,typeof r=="boolean"?r:void 0)},cycleSmartPasteProfile:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s);return d.set(o,s),l.profile=ae(l.profile),x(o),!0},setSmartPasteProfile:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s);return d.set(o,s),l.profile=z(r),x(o),!0},toggleSmartPasteEnabled:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s);return d.set(o,s),l.enabled=typeof r=="boolean"?r:!l.enabled,R(o),x(o),!0},setSmartPasteOptions:(r,n)=>{const o=C(n,!1,!1);if(!o||!r||typeof r!="object")return!1;const s=d.get(o)||t,l=de(s),i=K({...l,...r,labels:{...s.labels,...r.labels||{}},profileOptions:{...l.profileOptions,...r.profileOptions||{},fidelity:{...l.profileOptions?.fidelity||{},...r.profileOptions?.fidelity||{}},balanced:{...l.profileOptions?.balanced||{},...r.profileOptions?.balanced||{}},plain:{...l.profileOptions?.plain||{},...r.profileOptions?.plain||{}}},normalizeText:r.normalizeText||s.normalizeText});d.set(o,i);const c=p(o,i);return typeof r.enabled=="boolean"&&(c.enabled=r.enabled),r.defaultProfile&&(c.profile=z(r.defaultProfile)),x(o),R(o),!0},getSmartPasteState:(r,n)=>{const o=C(n,!1,!1);if(!o)return!1;const s=d.get(o)||t,l=p(o,s),i=Se(l);if(typeof r=="function")try{r(i)}catch{}return o.__smartPasteState=i,o.dispatchEvent(new CustomEvent("editora:smart-paste-state",{bubbles:!0,detail:i})),!0}},keymap:{"Mod-Alt-Shift-s":"toggleSmartPastePanel","Mod-Alt-Shift-S":"toggleSmartPastePanel","Mod-Alt-Shift-v":"cycleSmartPasteProfile","Mod-Alt-Shift-V":"cycleSmartPasteProfile","Mod-Alt-Shift-g":"toggleSmartPasteEnabled","Mod-Alt-Shift-G":"toggleSmartPasteEnabled"},init:function(n){I+=1;const o=this&&typeof this.__pluginConfig=="object"?K({...de(t),...this.__pluginConfig}):t;ot(o);const s=C(n?.editorElement?{editorElement:n.editorElement}:void 0,!1,!1);if(!s)return;m=s,a.add(s);const l=p(s,o);l.enabled=o.enabled,l.profile=o.defaultProfile,d.set(s,o),R(s)},destroy:()=>{a.forEach(r=>ge(r)),a.clear(),I=Math.max(0,I-1),!(I>0)&&nt()}}};exports.SmartPastePlugin=lt;
|