@apolitical/component-library 6.0.3-ac.2 → 6.0.3-ac.3
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/index.js +1 -1
- package/index.mjs +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -98,7 +98,7 @@ ${p}${h?"1.":"-"} ${u}${m?`
|
|
|
98
98
|
`:""}`;case o[K.paragraph]:return`${u}
|
|
99
99
|
|
|
100
100
|
`;case o[K.hr]:return`---
|
|
101
|
-
`;default:return u}}function Gn(e,t){const n=e.trim(),r=n,a=`${t}${r}${Mc(t)}`;if(r.length===e.length)return a;const i=t+r+Mc(t);return e.replace(n,i)}const Mc=e=>e.split("").reverse().join(""),Rw=e=>e.map(t=>Eh(t)).join("").trim();const Iw=({onFallbackClick:e=()=>{}})=>{const t=se.useIntl(),n=Cn(),{dispatch:r,isInOverlay:a,mentionPopover:i,id:s,onMention:o}=y.useContext(Jt),{show:l,selectedUser:u,possibleUsers:d}=i,h=sh(n,"mention-popover",`toolbar-${s}`);if(!l)return c.jsx(c.Fragment,{});const m=wh(a);return c.jsx(gr,{parent:m,children:c.jsx(cd,{ref:h,className:"mention-popover",onKeyDown:p=>{p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),r([{type:"showMentionPopover",value:!1}]))},children:c.jsxs("ul",{children:[d.map(({userId:p,user:g},f)=>c.jsx(an,{element:"li",className:Z({selected:f===u}),member:{id:p,...g,link:!1},functions:{onClick:v=>{v.preventDefault(),v.stopPropagation();const b={...i,selectedUser:f};r([{type:"mentionPopover",value:b}]),Ch(n,b,r,s),o&&o({id:p||"",name:g.name||""})}}},p)),c.jsx(an,{element:"li",className:Z("fallback",{selected:d.length===u}),member:{id:"0",name:t.formatMessage({id:"richTextEditor_mention_fallback"}),image:{thumbnail:`${Yt}icons/invite-user.svg`},link:!1},functions:{onClick:p=>{p.preventDefault(),p.stopPropagation(),e(),r([{type:"mentionPopover",value:{show:!1,selectedUser:0,possibleUsers:[],position:null}}])}}})]})})})};const Wo=({formID:e,label:t,showLabel:n})=>{const{visible:r="",screenreader:a=""}=t||{};return n?c.jsx("label",{htmlFor:`${e}-input`,className:"rte-label text-small",onClick:i=>{i.preventDefault(),i.stopPropagation();const s=new CustomEvent("focusEditor",{detail:{id:`rte-${e}-input`}});window.dispatchEvent(s)},children:r}):c.jsx(Me,{element:"label",showOnFocus:!1,htmlFor:`${e}-input`,children:a})},yi=({id:e,active:t,hasDivider:n=!1,callback:r,className:a="",children:i,"aria-pressed":s,...o})=>{const l=se.useIntl(),u=Cn(),{id:d,tabbableOption:h,setFocus:m,openTooltip:p,dispatch:g}=y.useContext(Jt),f={};return e!==h&&(f.tabIndex=-1),s!==null&&(f["aria-pressed"]=typeof s=="boolean"?s:t),c.jsxs("li",{id:`${d}-${e}`,className:Z(e,{"has-divider":n}),onMouseEnter:()=>{g([{type:"openTooltip",value:e}])},onMouseLeave:()=>{g([{type:"openTooltip",value:null}])},onFocus:()=>{g([{type:"openTooltip",value:e}])},onBlur:v=>{v.stopPropagation();const b=[{type:"openTooltip",value:null}];u.selection&&b.push({type:"lastAnchor",value:u.selection.anchor}),g(b)},contentEditable:!1,children:[c.jsxs("button",{...o,...f,className:Z(e,a,{active:t}),onClick:v=>{v.stopPropagation(),v.preventDefault()},onMouseDown:v=>{v.stopPropagation(),v.preventDefault(),r()},onKeyDown:v=>{var b,w,_,B;if(v.key!=="Tab")switch(v.key){case"Enter":v.stopPropagation(),v.preventDefault(),r();break;case"ArrowLeft":case"ArrowRight":v.stopPropagation(),v.preventDefault();const C=v.currentTarget.closest("li");let E=C==null?void 0:C.nextElementSibling;if(v.key==="ArrowLeft"){const M=C==null?void 0:C.previousElementSibling;M?E=M:E=(b=C==null?void 0:C.parentElement)==null?void 0:b.lastElementChild}else E||(E=(w=C==null?void 0:C.parentElement)==null?void 0:w.firstElementChild);const S=E==null?void 0:E.className.split(" ")[0];S&&(m(S),(_=E==null?void 0:E.querySelector("button"))==null||_.focus());break;default:const z=v.currentTarget.closest("fieldset");if(z){(B=z==null?void 0:z.previousElementSibling)==null||B.focus();break}}},children:[c.jsx(Me,{showOnFocus:!1,children:l.formatMessage({id:`richTextEditor_${e}`})}),c.jsx(Ln,{id:`tooltip-${e}`,styling:{extraPadding:!1,hasPointer:"bottom"},isOpen:p===e,accessibility:{"aria-hidden":!0},children:l.formatMessage({id:`richTextEditor_${e}`})})]}),i]})},Nc=[K.ol,K.ul],_h=(e,t)=>{const{selection:n}=e;if(!n)return!1;const[r]=Array.from(x.nodes(e,{at:x.unhangRange(e,n),match:a=>{const i=a;return!x.isEditor(a)&&de.isElement(a)&&i.type===t}}));return!!r},$w=e=>{const[t]=x.nodes(e,{match:n=>n.type===K.blockquote});return!!t},kh=(e,t,n)=>{try{const r=$w(e),a=_h(e,t),i=Nc.includes(t);J.unwrapNodes(e,{match:l=>{const u=l;return!x.isEditor(u)&&de.isElement(u)&&Nc.includes(u.type)},split:!0});const o={type:a?K.paragraph:i?K.li:t};if(J.setNodes(e,o),i)if(a){const{selection:l}=e;if(!l)return;const[u,d]=x.parent(e,l,{edge:"end"});Array.from(x.nodes(e,{at:d,match:m=>{const p=m;return!x.isEditor(m)&&de.isElement(m)&&p.type===K.li}})).forEach(([m,p])=>{le.string(m).trim()===""&&J.removeNodes(e,{at:p})})}else{if(r){const u={type:K.blockquote,children:[]};J.wrapNodes(e,u)}const l={type:t,children:[]};J.wrapNodes(e,l)}}catch(r){const a=r.message;n(`Error toggling block: ${a}`)}},Lw=({format:e,hasDivider:t=!1})=>{const{setFocus:n,reportError:r}=y.useContext(Jt),a=Cn(),i=_h(a,e);return c.jsx(yi,{id:e,active:i,hasDivider:t,callback:()=>{kh(a,e,r),n(i?null:e)}})},Ir=e=>{const[t]=x.nodes(e,{match:n=>{const r=n;return!x.isEditor(n)&&de.isElement(n)&&r.type===K.link}});return!!t},zw=(e,t,n,r)=>{e.selection&&Ho(e,t,n,r)},qw=(e,t,n,r)=>{const{selection:a}=e;if(a&&Y.isCollapsed(a)){const[s]=x.nodes(e,{match:o=>{const l=o;return!x.isEditor(o)&&de.isElement(o)&&l.type===K.link}});if(s){const[o,l]=s,u={link:t};J.setNodes(e,u,{at:l}),Uo(n)}}else Ho(e,t,n,r)},Ho=(e,t,n,r=a=>{console.error(a)})=>{try{Ir(e)&&Fh(e);const{selection:a}=e,i=a&&Y.isCollapsed(a),s={type:K.link,link:t,children:i?[{text:t}]:[]};i?(J.insertNodes(e,s),J.move(e,{distance:1,unit:"offset"})):(J.wrapNodes(e,s,{split:!0}),J.collapse(e,{edge:"end"}),J.insertNodes(e,{text:""}),J.move(e,{distance:1,unit:"offset"})),Uo(n)}catch(a){const i=a.message;r(`Error in wrapLink: ${i}`)}},Fh=e=>{J.unwrapNodes(e,{match:t=>{const n=t;return!x.isEditor(t)&&de.isElement(t)&&n.type===K.link}})};let as=null;const Uw=()=>{const e=se.useIntl(),t="richTextEditor_link_",{id:n,showLinkEditor:r,isInOverlay:a,enrichedUrl:i,dispatch:s,getLinkPreview:o,reportError:l}=y.useContext(Jt),u=Cn(),d=tD(u),h=(d==null?void 0:d.text)||jw(u),m=i!==!1,[p,g]=y.useState(Ir(u)),f=sh(u,"link-editor",`${n}-link`),v=y.useRef(null);y.useEffect(()=>{var C;!p&&r&&((C=v.current)==null||C.focus())},[p]),y.useEffect(()=>{as&&clearTimeout(as),as=setTimeout(()=>{g(Ir(u))},500)},[u.selection]);const b=[],w=["open","edit","remove"].map(C=>{const E={variant:"tertiary",size:"small",children:e.formatMessage({id:`${t}${C}`},{link:d==null?void 0:d.pretty})};switch(b.push({className:C}),C){case"open":E.href=(d==null?void 0:d.full)||"",E.onClick=S=>{S.preventDefault(),S.stopPropagation(),window.open((d==null?void 0:d.full)||"","_blank"),s([{type:"showLinkEditor",value:!1}])},E.children=c.jsxs(c.Fragment,{children:[E.children,c.jsx(Me,{children:e.formatMessage({id:`${t}${C}_text`})})]});break;case"edit":E.onClick=()=>{g(!1)};break;case"remove":E.onClick=()=>{const S=[{type:"showLinkEditor",value:!1}];Ir(u)&&(Fh(u),S.push({type:"lastAnchor",value:null}),i&&(d==null?void 0:d.full)===(i==null?void 0:i.url)&&S.push({type:"enrichedUrl",value:!1})),s(S)};break}return E}),_=[{id:"url",type:"url",inputRef:v,label:e.formatMessage({id:`${t}url`}),placeholder:e.formatMessage({id:`${t}placeholder`}),value:(d==null?void 0:d.full)||"",validation:[{condition:"required",error:e.formatMessage({id:`${t}error_required`})},{condition:"valid-url"}],submitOnEnter:!0,autoFocus:!0,functions:{onChange:()=>{},onKeyDown:C=>{if(C.key==="Tab"){if(!u)return;C.preventDefault(),C.stopPropagation();const E=x.end(u,[]);J.select(u,E),ee.focus(u)}}}}];h&&_.unshift({component:()=>c.jsxs("p",{children:[c.jsx("strong",{"aria-label":e.formatMessage({id:`${t}text_aria`}),children:e.formatMessage({id:`${t}text`})})," ",h]})});const B=wh(a);return c.jsx(gr,{parent:B,children:c.jsx(Ln,{ref:f,id:`${n}-link-editor`,className:"link-editor",isOpen:r,styling:{extraPadding:!1,hasForm:!p},functions:{onBlur:()=>{s([{type:"showLinkEditor",value:!1}])}},callbacks:{onOpen:()=>{setTimeout(()=>{var C;return(C=v.current)==null?void 0:C.focus()})}},children:p?c.jsx(pr,{wrappers:b,buttons:w}):c.jsx(Qt,{element:"fieldset",id:`${n}-link-editor`,className:Z({"show-labels":h}),meta:{shouldReset:!0,showRequiredLabels:!1},functions:{onSuccess:async C=>{setTimeout(async()=>{const E=[{type:"showLinkEditor",value:!1}];let S=C.url;if(C.url){const{full:z}=io(C.url);S=z,d!=null&&d.full?qw(u,S,n,l):zw(u,S,n,l),E.push({type:"lastAnchor",value:null})}if(s(E),C.url&&o&&(!m||i&&(d==null?void 0:d.full)===i.url)){const z=await o(S);z.url&&s([{type:"enrichedUrl",value:z}])}})}},fields:_,button:{text:e.formatMessage({id:`${t}button`}),variant:"tertiary",size:"small"}})})})},Ww=()=>{const e=Cn(),{setFocus:t,dispatch:n}=y.useContext(Jt),[r,a]=y.useState(!1);return y.useEffect(()=>{a(Ir(e))},[e.selection]),c.jsx(yi,{id:"link",active:r,hasDivider:!0,callback:()=>{n([{type:"showLinkEditor",value:!0}]),t(r?null:"link"),a(!0)},"aria-pressed":null})},Hw=e=>[K.bold,K.italic,K.strikethrough].includes(e),Vo=(e,t)=>{const n=x.marks(e);return n?n[t]===!0:!1},Ko=(e,t,n)=>{try{Vo(e,t)?x.removeMark(e,t):x.addMark(e,t,!0)}catch(r){const a=r.message;n(`Error toggling mark: ${a}`)}},Vw=({format:e,hasDivider:t=!1})=>{const{setFocus:n,reportError:r}=y.useContext(Jt),a=Cn(),i=Vo(a,e);return c.jsx(yi,{id:e,active:i,hasDivider:t,callback:()=>{Ko(a,e,r),n(i?null:e)}})},ei=[K.bold,K.italic,K.strikethrough],Kw=[K.ol,K.ul,K.blockquote];const Zw=()=>{const e=K.h3,{setFocus:t,reportError:n}=y.useContext(Jt),r=Cn(),a=Vo(r,e),i={type:e};return c.jsx(yi,{id:"h3",active:a,hasDivider:!0,callback:()=>{Ko(r,e,n),t(a?null:e),J.setNodes(r,i)},"aria-pressed":null})},Yw=({styling:e={showHeadingOption:!1},...t})=>{const n=se.useIntl(),{id:r}=y.useContext(Jt);return c.jsxs(c.Fragment,{children:[c.jsxs("fieldset",{id:`toolbar-${r}`,className:"toolbar",...t,children:[c.jsx(Me,{element:"legend",showOnFocus:!1,children:n.formatMessage({id:"richTextEditor_toolbar"})}),c.jsxs("ul",{children:[ei.map((a,i)=>c.jsx(Vw,{format:a,hasDivider:i===ei.length-1},a)),(e==null?void 0:e.showHeadingOption)&&c.jsx(Zw,{}),c.jsx(Ww,{}),Kw.map((a,i)=>c.jsx(Lw,{format:a,hasDivider:i===1},a))]})]}),c.jsx(Uw,{})]})};function Gw(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}function Xs(e,t){return Array(t+1).join(e)}function Qw(e){return e.replace(/^\n*/,"")}function Jw(e){for(var t=e.length;t>0&&e[t-1]===`
|
|
101
|
+
`;default:return u}}function Gn(e,t){const n=e.trim(),r=n,a=`${t}${r}${Mc(t)}`;if(r.length===e.length)return a;const i=t+r+Mc(t);return e.replace(n,i)}const Mc=e=>e.split("").reverse().join(""),Rw=e=>e.map(t=>Eh(t)).join("").trim();const Iw=({onFallbackClick:e=()=>{}})=>{const t=se.useIntl(),n=Cn(),{dispatch:r,isInOverlay:a,mentionPopover:i,id:s,onMention:o}=y.useContext(Jt),{show:l,selectedUser:u,possibleUsers:d}=i,h=sh(n,"mention-popover",`toolbar-${s}`);if(!l)return c.jsx(c.Fragment,{});const m=wh(a);return c.jsx(gr,{parent:m,children:c.jsx(cd,{ref:h,className:"mention-popover",onKeyDown:p=>{p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),r([{type:"showMentionPopover",value:!1}]))},children:c.jsxs("ul",{children:[d.map(({userId:p,user:g},f)=>c.jsx(an,{element:"li",className:Z({selected:f===u}),member:{id:p,...g,link:!1},functions:{onClick:v=>{v.preventDefault(),v.stopPropagation();const b={...i,selectedUser:f};r([{type:"mentionPopover",value:b}]),Ch(n,b,r,s),o&&o({id:p||"",name:g.name||""})}}},p)),c.jsx(an,{element:"li",className:Z("fallback",{selected:d.length===u}),member:{id:"0",name:t.formatMessage({id:"richTextEditor_mention_fallback"}),image:{thumbnail:`${Yt}icons/invite-user.svg`},link:!1},functions:{onClick:p=>{p.preventDefault(),p.stopPropagation(),e(),r([{type:"mentionPopover",value:{show:!1,selectedUser:0,possibleUsers:[],position:null}}])}}})]})})})};const Wo=({formID:e,label:t,showLabel:n})=>{const{visible:r="",screenreader:a=""}=t||{};return n?c.jsx("label",{htmlFor:`${e}-input`,className:"rte-label text-small",onClick:i=>{i.preventDefault(),i.stopPropagation();const s=new CustomEvent("focusEditor",{detail:{id:`rte-${e}-input`}});window.dispatchEvent(s)},children:r}):c.jsx(Me,{element:"label",showOnFocus:!1,htmlFor:`${e}-input`,children:a})},yi=({id:e,active:t,hasDivider:n=!1,callback:r,className:a="",children:i,"aria-pressed":s,...o})=>{const l=se.useIntl(),u=Cn(),{id:d,tabbableOption:h,setFocus:m,openTooltip:p,dispatch:g}=y.useContext(Jt),f={};return e!==h&&(f.tabIndex=-1),s!==null&&(f["aria-pressed"]=typeof s=="boolean"?s:t),c.jsxs("li",{id:`${d}-${e}`,className:Z(e,{"has-divider":n}),onMouseEnter:()=>{g([{type:"openTooltip",value:e}])},onMouseLeave:()=>{g([{type:"openTooltip",value:null}])},onFocus:()=>{g([{type:"openTooltip",value:e}])},onBlur:v=>{v.stopPropagation();const b=[{type:"openTooltip",value:null}];u.selection&&b.push({type:"lastAnchor",value:u.selection.anchor}),g(b)},contentEditable:!1,children:[c.jsxs("button",{...o,...f,className:Z(e,a,{active:t}),onClick:v=>{v.stopPropagation(),v.preventDefault()},onMouseDown:v=>{v.stopPropagation(),v.preventDefault(),r()},onKeyDown:v=>{var b,w,_,B;if(v.key!=="Tab")switch(v.key){case"Enter":v.stopPropagation(),v.preventDefault(),r();break;case"ArrowLeft":case"ArrowRight":v.stopPropagation(),v.preventDefault();const C=v.currentTarget.closest("li");let E=C==null?void 0:C.nextElementSibling;if(v.key==="ArrowLeft"){const M=C==null?void 0:C.previousElementSibling;M?E=M:E=(b=C==null?void 0:C.parentElement)==null?void 0:b.lastElementChild}else E||(E=(w=C==null?void 0:C.parentElement)==null?void 0:w.firstElementChild);const S=E==null?void 0:E.className.split(" ")[0];S&&(m(S),(_=E==null?void 0:E.querySelector("button"))==null||_.focus());break;default:const z=v.currentTarget.closest("fieldset");if(z){(B=z==null?void 0:z.previousElementSibling)==null||B.focus();break}}},children:[c.jsx(Me,{showOnFocus:!1,children:l.formatMessage({id:`richTextEditor_${e}`})}),c.jsx(Ln,{id:`tooltip-${e}`,styling:{extraPadding:!1,hasPointer:"bottom"},isOpen:p===e,accessibility:{"aria-hidden":!0},children:l.formatMessage({id:`richTextEditor_${e}`})})]}),i]})},Nc=[K.ol,K.ul],_h=(e,t)=>{const{selection:n}=e;if(!n)return!1;const[r]=Array.from(x.nodes(e,{at:x.unhangRange(e,n),match:a=>{const i=a;return!x.isEditor(a)&&de.isElement(a)&&i.type===t}}));return!!r},$w=e=>{const[t]=x.nodes(e,{match:n=>n.type===K.blockquote});return!!t},kh=(e,t,n)=>{try{const r=$w(e),a=_h(e,t),i=Nc.includes(t);J.unwrapNodes(e,{match:l=>{const u=l;return!x.isEditor(u)&&de.isElement(u)&&Nc.includes(u.type)},split:!0});const o={type:a?K.paragraph:i?K.li:t};if(J.setNodes(e,o),i)if(a){const{selection:l}=e;if(!l)return;const[u,d]=x.parent(e,l,{edge:"end"});Array.from(x.nodes(e,{at:d,match:m=>{const p=m;return!x.isEditor(m)&&de.isElement(m)&&p.type===K.li}})).forEach(([m,p])=>{le.string(m).trim()===""&&J.removeNodes(e,{at:p})})}else{if(r){const u={type:K.blockquote,children:[]};J.wrapNodes(e,u)}const l={type:t,children:[]};J.wrapNodes(e,l)}}catch(r){const a=r.message;n(`Error toggling block: ${a}`)}},Lw=({format:e,hasDivider:t=!1})=>{const{setFocus:n,reportError:r}=y.useContext(Jt),a=Cn(),i=_h(a,e);return c.jsx(yi,{id:e,active:i,hasDivider:t,callback:()=>{kh(a,e,r),n(i?null:e)}})},Ir=e=>{const[t]=x.nodes(e,{match:n=>{const r=n;return!x.isEditor(n)&&de.isElement(n)&&r.type===K.link}});return!!t},zw=(e,t,n,r)=>{e.selection&&Ho(e,t,n,r)},qw=(e,t,n,r)=>{const{selection:a}=e;if(a&&Y.isCollapsed(a)){const[s]=x.nodes(e,{match:o=>{const l=o;return!x.isEditor(o)&&de.isElement(o)&&l.type===K.link}});if(s){const[o,l]=s,u={link:t};J.setNodes(e,u,{at:l}),Uo(n)}}else Ho(e,t,n,r)},Ho=(e,t,n,r=a=>{console.error(a)})=>{try{Ir(e)&&Fh(e);const{selection:a}=e,i=a&&Y.isCollapsed(a),s={type:K.link,link:t,children:i?[{text:t}]:[]};i?(J.insertNodes(e,s),J.move(e,{distance:1,unit:"offset"})):(J.wrapNodes(e,s,{split:!0}),J.collapse(e,{edge:"end"}),J.insertNodes(e,{text:""}),J.move(e,{distance:1,unit:"offset"})),Uo(n)}catch(a){const i=a.message;r(`Error in wrapLink: ${i}`)}},Fh=e=>{J.unwrapNodes(e,{match:t=>{const n=t;return!x.isEditor(t)&&de.isElement(t)&&n.type===K.link}})};let as=null;const Uw=()=>{const e=se.useIntl(),t="richTextEditor_link_",{id:n,showLinkEditor:r,isInOverlay:a,enrichedUrl:i,dispatch:s,getLinkPreview:o,reportError:l}=y.useContext(Jt),u=Cn(),d=tD(u),h=(d==null?void 0:d.text)||jw(u),m=i!==!1,[p,g]=y.useState(Ir(u)),f=sh(u,"link-editor",`${n}-link`),v=y.useRef(null);y.useEffect(()=>{var C;!p&&r&&((C=v.current)==null||C.focus())},[p]),y.useEffect(()=>{as&&clearTimeout(as),as=setTimeout(()=>{g(Ir(u))},500)},[u.selection]);const b=[],w=["open","edit","remove"].map(C=>{const E={variant:"tertiary",size:"small",children:e.formatMessage({id:`${t}${C}`},{link:d==null?void 0:d.pretty})};switch(b.push({className:C}),C){case"open":E.href=(d==null?void 0:d.full)||"",E.onClick=S=>{S.preventDefault(),S.stopPropagation(),window.open((d==null?void 0:d.full)||"","_blank"),s([{type:"showLinkEditor",value:!1}])},E.children=c.jsxs(c.Fragment,{children:[E.children,c.jsx(Me,{children:e.formatMessage({id:`${t}${C}_text`})})]});break;case"edit":E.onClick=()=>{g(!1)};break;case"remove":E.onClick=()=>{const S=[{type:"showLinkEditor",value:!1}];Ir(u)&&(Fh(u),S.push({type:"lastAnchor",value:null}),i&&(d==null?void 0:d.full)===(i==null?void 0:i.url)&&S.push({type:"enrichedUrl",value:!1})),s(S)};break}return E}),_=[{id:"url",type:"url",inputRef:v,label:e.formatMessage({id:`${t}url`}),placeholder:e.formatMessage({id:`${t}placeholder`}),value:(d==null?void 0:d.full)||"",validation:[{condition:"required",error:e.formatMessage({id:`${t}error_required`})},{condition:"valid-url"}],submitOnEnter:!0,autoFocus:!0,functions:{onChange:()=>{},onKeyDown:C=>{if(C.key==="Tab"){if(!u)return;C.preventDefault(),C.stopPropagation();const E=x.end(u,[]);J.select(u,E),ee.focus(u)}}}}];h&&_.unshift({component:()=>c.jsxs("p",{children:[c.jsx("strong",{"aria-label":e.formatMessage({id:`${t}text_aria`}),children:e.formatMessage({id:`${t}text`})})," ",h]})});const B=wh(a);return c.jsx(gr,{parent:B,children:c.jsx(Ln,{ref:f,id:`${n}-link-editor`,className:"link-editor",isOpen:r,styling:{extraPadding:!1,hasForm:!p},functions:{onBlur:()=>{s([{type:"showLinkEditor",value:!1}])}},callbacks:{onOpen:()=>{setTimeout(()=>{var C;return(C=v.current)==null?void 0:C.focus()})}},children:p?c.jsx(pr,{wrappers:b,buttons:w}):c.jsx(Qt,{element:"fieldset",id:`${n}-link-editor`,className:Z({"show-labels":h}),meta:{shouldReset:!0,showRequiredLabels:!1},functions:{onSuccess:async C=>{setTimeout(async()=>{const E=[{type:"showLinkEditor",value:!1}];let S=C.url;if(C.url){const{full:z}=io(C.url);S=z,d!=null&&d.full?qw(u,S,n,l):zw(u,S,n,l),E.push({type:"lastAnchor",value:null})}if(s(E),C.url&&o&&(!m||i&&(d==null?void 0:d.full)===i.url)){const z=await o(S);z.url&&s([{type:"enrichedUrl",value:z}])}})}},fields:_,button:{text:e.formatMessage({id:`${t}button`}),variant:"tertiary",size:"small"}})})})},Ww=()=>{const e=Cn(),{setFocus:t,dispatch:n}=y.useContext(Jt),[r,a]=y.useState(!1);return y.useEffect(()=>{a(Ir(e))},[e.selection]),c.jsx(yi,{id:"link",active:r,hasDivider:!0,callback:()=>{n([{type:"showLinkEditor",value:!0}]),t(r?null:"link"),a(!0)},"aria-pressed":null})},Hw=e=>[K.bold,K.italic,K.strikethrough].includes(e),Vo=(e,t)=>{const n=x.marks(e);return n?n[t]===!0:!1},Ko=(e,t,n)=>{try{Vo(e,t)?x.removeMark(e,t):x.addMark(e,t,!0)}catch(r){const a=r.message;n(`Error toggling mark: ${a}`)}},Vw=({format:e,hasDivider:t=!1})=>{const{setFocus:n,reportError:r}=y.useContext(Jt),a=Cn(),i=Vo(a,e);return c.jsx(yi,{id:e,active:i,hasDivider:t,callback:()=>{Ko(a,e,r),n(i?null:e)}})},ei=[K.bold,K.italic,K.strikethrough],Kw=[K.ol,K.ul,K.blockquote];const Zw=()=>{const e=K.h3,{setFocus:t,reportError:n}=y.useContext(Jt),r=Cn(),a=Vo(r,e),i={type:e};return c.jsx(yi,{id:"h3",active:a,hasDivider:!0,callback:()=>{Ko(r,e,n),t(a?null:e),J.setNodes(r,i)},"aria-pressed":null})},Yw=({styling:e={showHeadingOption:!1},...t})=>{const n=se.useIntl(),{id:r}=y.useContext(Jt);return c.jsxs(c.Fragment,{children:[c.jsxs("fieldset",{id:`toolbar-${r}`,className:"toolbar",...t,children:[c.jsx(Me,{element:"legend",showOnFocus:!1,children:n.formatMessage({id:"richTextEditor_toolbar"})}),c.jsxs("ul",{children:[(e==null?void 0:e.showHeadingOption)&&c.jsx(Zw,{}),ei.map((a,i)=>c.jsx(Vw,{format:a,hasDivider:i===ei.length-1},a)),c.jsx(Ww,{}),Kw.map((a,i)=>c.jsx(Lw,{format:a,hasDivider:i===1},a))]})]}),c.jsx(Uw,{})]})};function Gw(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])}return e}function Xs(e,t){return Array(t+1).join(e)}function Qw(e){return e.replace(/^\n*/,"")}function Jw(e){for(var t=e.length;t>0&&e[t-1]===`
|
|
102
102
|
`;)t--;return e.substring(0,t)}var Xw=["ADDRESS","ARTICLE","ASIDE","AUDIO","BLOCKQUOTE","BODY","CANVAS","CENTER","DD","DIR","DIV","DL","DT","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","FRAMESET","H1","H2","H3","H4","H5","H6","HEADER","HGROUP","HR","HTML","ISINDEX","LI","MAIN","MENU","NAV","NOFRAMES","NOSCRIPT","OL","OUTPUT","P","PRE","SECTION","TABLE","TBODY","TD","TFOOT","TH","THEAD","TR","UL"];function Zo(e){return Yo(e,Xw)}var Ah=["AREA","BASE","BR","COL","COMMAND","EMBED","HR","IMG","INPUT","KEYGEN","LINK","META","PARAM","SOURCE","TRACK","WBR"];function Bh(e){return Yo(e,Ah)}function eE(e){return Sh(e,Ah)}var Th=["A","TABLE","THEAD","TBODY","TFOOT","TH","TD","IFRAME","SCRIPT","AUDIO","VIDEO"];function tE(e){return Yo(e,Th)}function nE(e){return Sh(e,Th)}function Yo(e,t){return t.indexOf(e.nodeName)>=0}function Sh(e,t){return e.getElementsByTagName&&t.some(function(n){return e.getElementsByTagName(n).length})}var ct={};ct.paragraph={filter:"p",replacement:function(e){return`
|
|
103
103
|
|
|
104
104
|
`+e+`
|
package/index.mjs
CHANGED
|
@@ -22215,8 +22215,8 @@ const RC = () => {
|
|
|
22215
22215
|
/* @__PURE__ */ c.jsxs("fieldset", { id: `toolbar-${r}`, className: "toolbar", ...t, children: [
|
|
22216
22216
|
/* @__PURE__ */ c.jsx(Ue, { element: "legend", showOnFocus: !1, children: n.formatMessage({ id: "richTextEditor_toolbar" }) }),
|
|
22217
22217
|
/* @__PURE__ */ c.jsxs("ul", { children: [
|
|
22218
|
-
aa.map((i, a) => /* @__PURE__ */ c.jsx(NC, { format: i, hasDivider: a === aa.length - 1 }, i)),
|
|
22219
22218
|
(e == null ? void 0 : e.showHeadingOption) && /* @__PURE__ */ c.jsx(RC, {}),
|
|
22219
|
+
aa.map((i, a) => /* @__PURE__ */ c.jsx(NC, { format: i, hasDivider: a === aa.length - 1 }, i)),
|
|
22220
22220
|
/* @__PURE__ */ c.jsx(OC, {}),
|
|
22221
22221
|
MC.map((i, a) => /* @__PURE__ */ c.jsx(BC, { format: i, hasDivider: a === 1 }, i))
|
|
22222
22222
|
] })
|