@frontify/fondue 12.0.0-beta.226 → 12.0.0-beta.227
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/components/RichTextEditor/Plugins/TextStylePlugin/TextStyleDropdown/useTextStyleDropdown.es.js +14 -11
- package/dist/components/RichTextEditor/Plugins/TextStylePlugin/TextStyleDropdown/useTextStyleDropdown.es.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { usePlateEditorState as E } from "@udecode/plate";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as p, useCallback as T, useEffect as y } from "react";
|
|
3
3
|
import { usePopper as S } from "react-popper";
|
|
4
4
|
import { useSelectedTextStyles as w } from "./useSelectedTextStyles.es.js";
|
|
5
5
|
import { verticalPositionModifier as x } from "./verticalPositionModifier.es.js";
|
|
6
6
|
import { DEFAULT_TEXT_STYLE_VALUE as L } from "../types.es.js";
|
|
7
|
-
const
|
|
8
|
-
const [s, e] =
|
|
7
|
+
const A = (a) => {
|
|
8
|
+
const [s, e] = p(!1), [t, c] = p(null), [o, d] = p(null), l = E(a), n = w(l);
|
|
9
|
+
let i = L;
|
|
10
|
+
n.length === 1 ? i = n[0] : n.length === 0 && (i = "p");
|
|
11
|
+
const u = T(() => {
|
|
9
12
|
e((r) => !r);
|
|
10
|
-
}, [e]),
|
|
13
|
+
}, [e]), f = S(t, o, {
|
|
11
14
|
placement: "bottom-start",
|
|
12
15
|
strategy: "fixed",
|
|
13
16
|
modifiers: [
|
|
@@ -37,17 +40,17 @@ const D = (f) => {
|
|
|
37
40
|
document.removeEventListener("mousedown", r);
|
|
38
41
|
};
|
|
39
42
|
}, [s, o, e, t]), {
|
|
40
|
-
state: { isOpen: s, toggle: u, editor:
|
|
43
|
+
state: { isOpen: s, toggle: u, editor: l },
|
|
41
44
|
dropdownProps: {
|
|
42
|
-
...
|
|
43
|
-
style:
|
|
45
|
+
...f.attributes.popper,
|
|
46
|
+
style: f.styles.popper
|
|
44
47
|
},
|
|
45
|
-
key:
|
|
46
|
-
dropdownRef:
|
|
47
|
-
triggerRef:
|
|
48
|
+
key: i,
|
|
49
|
+
dropdownRef: d,
|
|
50
|
+
triggerRef: c
|
|
48
51
|
};
|
|
49
52
|
};
|
|
50
53
|
export {
|
|
51
|
-
|
|
54
|
+
A as useTextStyleDropdown
|
|
52
55
|
};
|
|
53
56
|
//# sourceMappingURL=useTextStyleDropdown.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTextStyleDropdown.es.js","sources":["../../../../../../src/components/RichTextEditor/Plugins/TextStylePlugin/TextStyleDropdown/useTextStyleDropdown.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { PlateEditor, usePlateEditorState } from '@udecode/plate';\nimport { Dispatch, HTMLAttributes, SetStateAction, useCallback, useEffect, useState } from 'react';\nimport { usePopper } from 'react-popper';\nimport { useSelectedTextStyles } from './useSelectedTextStyles';\nimport { verticalPositionModifier } from './verticalPositionModifier';\nimport { DEFAULT_TEXT_STYLE_VALUE } from '../types';\n\ntype UseTextStyleDropdownReturn<T, P> = {\n state: { isOpen: boolean; toggle: () => void; editor: PlateEditor };\n key: string;\n dropdownProps: HTMLAttributes<P>;\n triggerRef: Dispatch<SetStateAction<T | null>>;\n dropdownRef: Dispatch<SetStateAction<P | null>>;\n};\n\nexport const useTextStyleDropdown = <T extends HTMLElement, P extends HTMLElement>(\n editorId?: string,\n): UseTextStyleDropdownReturn<T, P> => {\n const [isOpen, setIsOpen] = useState(false);\n const [triggerElement, setTriggerElement] = useState<T | null>(null);\n const [popperElement, setPopperElement] = useState<P | null>(null);\n const editor = usePlateEditorState(editorId);\n const selectedTextStyles = useSelectedTextStyles(editor);\n
|
|
1
|
+
{"version":3,"file":"useTextStyleDropdown.es.js","sources":["../../../../../../src/components/RichTextEditor/Plugins/TextStylePlugin/TextStyleDropdown/useTextStyleDropdown.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { PlateEditor, usePlateEditorState } from '@udecode/plate';\nimport { Dispatch, HTMLAttributes, SetStateAction, useCallback, useEffect, useState } from 'react';\nimport { usePopper } from 'react-popper';\nimport { useSelectedTextStyles } from './useSelectedTextStyles';\nimport { verticalPositionModifier } from './verticalPositionModifier';\nimport { DEFAULT_TEXT_STYLE_VALUE } from '../types';\n\ntype UseTextStyleDropdownReturn<T, P> = {\n state: { isOpen: boolean; toggle: () => void; editor: PlateEditor };\n key: string;\n dropdownProps: HTMLAttributes<P>;\n triggerRef: Dispatch<SetStateAction<T | null>>;\n dropdownRef: Dispatch<SetStateAction<P | null>>;\n};\n\nexport const useTextStyleDropdown = <T extends HTMLElement, P extends HTMLElement>(\n editorId?: string,\n): UseTextStyleDropdownReturn<T, P> => {\n const [isOpen, setIsOpen] = useState(false);\n const [triggerElement, setTriggerElement] = useState<T | null>(null);\n const [popperElement, setPopperElement] = useState<P | null>(null);\n const editor = usePlateEditorState(editorId);\n const selectedTextStyles = useSelectedTextStyles(editor);\n\n let key = DEFAULT_TEXT_STYLE_VALUE;\n if (selectedTextStyles.length === 1) {\n key = selectedTextStyles[0];\n } else if (selectedTextStyles.length === 0) {\n key = 'p';\n }\n\n const toggle = useCallback(() => {\n setIsOpen((open) => !open);\n }, [setIsOpen]);\n\n const popperInstance = usePopper<'offset' | 'flip' | 'vertical-positioning'>(triggerElement, popperElement, {\n placement: 'bottom-start',\n strategy: 'fixed',\n modifiers: [\n {\n name: 'offset',\n options: {\n offset: [0, 6],\n },\n },\n {\n name: 'flip',\n enabled: false,\n },\n verticalPositionModifier,\n ],\n });\n\n useEffect(() => {\n const listener = (event: Event) => {\n if (isOpen) {\n const target = event.target as HTMLElement;\n if (popperElement && popperElement.contains(target)) {\n return;\n }\n if (triggerElement && triggerElement.contains(target)) {\n return;\n }\n\n setIsOpen(false);\n }\n };\n document.addEventListener('mousedown', listener);\n return () => {\n document.removeEventListener('mousedown', listener);\n };\n }, [isOpen, popperElement, setIsOpen, triggerElement]);\n\n return {\n state: { isOpen, toggle, editor },\n dropdownProps: {\n ...popperInstance.attributes.popper,\n style: popperInstance.styles.popper,\n },\n key,\n dropdownRef: setPopperElement,\n triggerRef: setTriggerElement,\n };\n};\n"],"names":["useTextStyleDropdown","editorId","isOpen","setIsOpen","useState","triggerElement","setTriggerElement","popperElement","setPopperElement","editor","usePlateEditorState","selectedTextStyles","useSelectedTextStyles","key","DEFAULT_TEXT_STYLE_VALUE","toggle","useCallback","open","popperInstance","usePopper","verticalPositionModifier","useEffect","listener","event","target"],"mappings":";;;;;;AAiBa,MAAAA,IAAuB,CAChCC,MACmC;AACnC,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpC,CAACC,GAAgBC,CAAiB,IAAIF,EAAmB,IAAI,GAC7D,CAACG,GAAeC,CAAgB,IAAIJ,EAAmB,IAAI,GAC3DK,IAASC,EAAoBT,CAAQ,GACrCU,IAAqBC,EAAsBH,CAAM;AAEvD,MAAII,IAAMC;AACN,EAAAH,EAAmB,WAAW,IAC9BE,IAAMF,EAAmB,CAAC,IACnBA,EAAmB,WAAW,MAC/BE,IAAA;AAGJ,QAAAE,IAASC,EAAY,MAAM;AACnB,IAAAb,EAAA,CAACc,MAAS,CAACA,CAAI;AAAA,EAAA,GAC1B,CAACd,CAAS,CAAC,GAERe,IAAiBC,EAAsDd,GAAgBE,GAAe;AAAA,IACxG,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,MACP;AAAA,QACI,MAAM;AAAA,QACN,SAAS;AAAA,UACL,QAAQ,CAAC,GAAG,CAAC;AAAA,QACjB;AAAA,MACJ;AAAA,MACA;AAAA,QACI,MAAM;AAAA,QACN,SAAS;AAAA,MACb;AAAA,MACAa;AAAA,IACJ;AAAA,EAAA,CACH;AAED,SAAAC,EAAU,MAAM;AACN,UAAAC,IAAW,CAACC,MAAiB;AAC/B,UAAIrB,GAAQ;AACR,cAAMsB,IAASD,EAAM;AAIrB,YAHIhB,KAAiBA,EAAc,SAASiB,CAAM,KAG9CnB,KAAkBA,EAAe,SAASmB,CAAM;AAChD;AAGJ,QAAArB,EAAU,EAAK;AAAA,MACnB;AAAA,IAAA;AAEK,oBAAA,iBAAiB,aAAamB,CAAQ,GACxC,MAAM;AACA,eAAA,oBAAoB,aAAaA,CAAQ;AAAA,IAAA;AAAA,KAEvD,CAACpB,GAAQK,GAAeJ,GAAWE,CAAc,CAAC,GAE9C;AAAA,IACH,OAAO,EAAE,QAAAH,GAAQ,QAAAa,GAAQ,QAAAN,EAAO;AAAA,IAChC,eAAe;AAAA,MACX,GAAGS,EAAe,WAAW;AAAA,MAC7B,OAAOA,EAAe,OAAO;AAAA,IACjC;AAAA,IACA,KAAAL;AAAA,IACA,aAAaL;AAAA,IACb,YAAYF;AAAA,EAAA;AAEpB;"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -36,7 +36,7 @@ ${q1("Ctrl+Shift+K")}`:"Buttons can only be set for a single text block."),class
|
|
|
36
36
|
color: var(--box-neutral-inverse-color-hover);
|
|
37
37
|
`]},Md0={renderAfterEditable:Cd0};class jT extends x0{constructor(l){super(hd0,{button:Ad0,showIn:[u0.BOTTOM,u0.TOP],...l})}plugins(){return[u.createComboboxPlugin(),u.createEmojiPlugin(Md0)]}}const xd0="soft-break-plugin";class DT extends x0{constructor(l){super(xd0,{...l})}plugins(){return[u.createSoftBreakPlugin()]}}const Zd0="italic-plugin",qe="tw-italic",FT=({attributes:e,children:l})=>t.createElement("span",{...e,className:qe},l);class BT extends A0{constructor(l=u.MARK_ITALIC,a=FT){super(l,a)}}const pd0=({editor:e,id:l})=>t.createElement(M0,{id:l},t.createElement(u.MarkToolbarButton,{tooltip:S0(`Italic
|
|
38
38
|
${q1("Ctrl+I")}`),type:u.getPluginType(e,l),icon:t.createElement(Z0,{icon:t.createElement(Et,null)}),classNames:I0(),styles:p0,actionHandler:"onMouseDown"})),Nd0=[{validNodeName:["EM","I"]},{validStyle:{fontStyle:"italic"}}];class OT extends x0{constructor(l){super(Zd0,{button:pd0,markupElement:new BT,...l})}plugins(){return[u.createItalicPlugin({deserializeHtml:{rules:[...Nd0,{validNodeName:["SPAN"],validClassName:qe}]},options:{hotkey:["mod+i","ctrl+i"]}})]}}const Sd0=u.createComponentAs(e=>{var a;const l=u.useFloatingLinkInsert({...e,floatingOptions:{strategy:"fixed"}});return((a=l.style)==null?void 0:a.display)==="none"?null:u.createElementAs("div",l)}),yd0=u.createComponentAs(e=>{var a;const l=zd0({...e,floatingOptions:{strategy:"fixed"}});return((a=l.style)==null?void 0:a.display)==="none"?null:u.createElementAs("div",l)});u.FloatingLink.EditRoot=yd0;u.FloatingLink.InsertRoot=Sd0;const me=u.FloatingLink,Rd0=()=>{const e=u.useFloatingLinkUrlInput({});return t.createElement("div",{"data-test-id":"floating-link-edit",className:"tw-bg-white tw-rounded tw-shadow tw-p-4 tw-min-w-[400px]"},t.createElement("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between"},t.createElement("span",{style:j0("link"),className:"tw-pointer-events-none"},e.defaultValue),t.createElement("span",{className:"tw-flex tw-gap-2"},t.createElement("span",{role:"button",tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1"},t.createElement(me.EditButton,null,t.createElement(Ie,null))),t.createElement("span",{role:"button",tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1"},t.createElement(me.UnlinkButton,null,t.createElement(xe,null))))))},z3=(e,l)=>{const a=u.getAboveNode(e,{match:{type:u.ELEMENT_LINK}});return Array.isArray(a)?l(a[0]):""},bd0=e=>z3(e,l=>{var a,r;return((r=(a=l.chosenLink)==null?void 0:a.searchResult)==null?void 0:r.link)||""}),kd0=e=>z3(e,l=>l.url||""),PT=e=>{var l,a;return e.url||((a=(l=e.chosenLink)==null?void 0:l.searchResult)==null?void 0:a.link)||""},Hd0=e=>z3(e,PT),zd0=({floatingOptions:e,...l})=>{const a=u.useEditorRef(),r=u.usePlateSelectors().keyEditor(),c=u.useFloatingLinkSelectors().mode(),o=u.useFloatingLinkSelectors().isOpen(a.id),{triggerFloatingLinkHotkeys:i="command+k, ctrl+k"}=u.getPluginOptions(a,u.ELEMENT_LINK),s=t.useCallback(()=>{const w=u.getAboveNode(a,{match:{type:u.getPluginType(a,u.ELEMENT_LINK)}});if(w){const[,f]=w;return u.getRangeBoundingClientRect(a,{anchor:u.getStartPoint(a,f),focus:u.getEndPoint(a,f)})}return u.getDefaultBoundingClientRect()},[a]),m=o&&c==="edit",{update:L,style:d,floating:h}=u.useVirtualFloatingLink({editorId:a.id,open:m,getBoundingClientRect:s,...e});return t.useEffect(()=>{const w=Hd0(a);if(w&&u.floatingLinkActions.url(w),a.selection&&u.someNode(a,{match:{type:u.getPluginType(a,u.ELEMENT_LINK)}})){u.floatingLinkActions.show("edit",a.id),L();return}u.floatingLinkSelectors.mode()==="edit"&&u.floatingLinkActions.hide()},[a,r,L]),u.useHotkeys(i,w=>{w.preventDefault(),u.floatingLinkSelectors.mode()==="edit"&&u.triggerFloatingLinkEdit(a)},{enableOnContentEditable:!0},[]),u.useFloatingLinkEnter(),u.useFloatingLinkEscape(),{style:{...d,zIndex:1},...l,ref:u.useComposedRef(l.ref,h)}},Td0={url:"",text:"",newTab:a0.Unchecked},Vd0=()=>{const[e,l]=t.useReducer((a,r)=>{const{type:c,payload:o}=r;switch(c){case"NEW_TAB":return{...a,newTab:a0.Checked};case"SAME_TAB":return{...a,newTab:a0.Unchecked};case"URL":case"TEXT":case"INIT":return{...a,...o};default:return a}},Td0);return[e,l]},jd0=()=>{const e=u.useEditorRef(),[l,a]=Vd0();t.useEffect(()=>{const d=bd0(e),h=kd0(e);a({type:"INIT",payload:{text:u.floatingLinkSelectors.text(),newTab:u.floatingLinkSelectors.newTab()?a0.Checked:a0.Unchecked,url:d&&h===""?d:u.floatingLinkSelectors.url()}})},[a,e]);const r=d=>{a({type:"TEXT",payload:{text:d}})},c=d=>{a({type:"URL",payload:{url:d}})},o=d=>{a(d?{type:"NEW_TAB"}:{type:"SAME_TAB"})},i=()=>{u.floatingLinkActions.hide()},s=d=>{!L()||!m||(u.floatingLinkActions.text(l.text),u.floatingLinkActions.url(l.url),u.floatingLinkActions.newTab(l.newTab===a0.Checked),u.submitFloatingLink(e)&&(d==null||d.preventDefault()))},m=l.url!==""&&l.text!=="",L=()=>{const{isUrl:d}=u.getPluginOptions(e,u.ELEMENT_LINK);return!l.url||d&&d(l.url)};return u.useHotkeys("enter",s,{enableOnTags:["INPUT"]},[]),{state:l,onTextChange:r,onUrlChange:c,onToggleTab:o,onCancel:i,onSave:s,hasValues:m,isValidUrlOrEmpty:L}},Dd0=()=>t.createElement(yT,{...jd0(),testId:"floating-link-insert"}),Fd0=({readOnly:e})=>{const l=u.useFloatingLinkSelectors().isEditing();if(e)return null;const a=t.createElement(Dd0,null),r=l?a:t.createElement(Rd0,null);return t.createElement(t.Fragment,null,t.createElement(me.InsertRoot,null,a),t.createElement(me.EditRoot,null,r))},Bd0="link-plugin",Od0=({id:e,editorId:l})=>{const a=u.usePlateEditorState(u.useEventPlateId(l)),r=!!u.isRangeInSameBlock(a,{at:a.selection}),c=I0(r);return t.createElement(M0,{id:e},t.createElement(u.LinkToolbarButton,{tooltip:S0(r?`Link
|
|
39
|
-
${q1("Ctrl+K")}`:"Links can only be set for a single text block."),icon:t.createElement(Z0,{icon:t.createElement(rt,null)}),classNames:c,styles:p0,actionHandler:"onMouseDown"}))},Pd0=e=>({...u.useElementProps({...e,elementToAttributes:a=>({href:PT(a),target:a.target||"_blank"})}),onMouseOver:a=>{a.stopPropagation()}}),Ud0=e=>{const l=Pd0(e),{attributes:a,children:r}=e;return t.createElement("a",{...a,href:l.href,target:l.target,style:j0("link")},r)};class Qd0 extends A0{constructor(l=u.ELEMENT_LINK,a=Ud0){super(l,a)}}const UT=u.createPluginFactory({...u.createLinkPlugin(),renderAfterEditable:Fd0,options:{isUrl:cT,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"command+k, ctrl+k"}});class QT extends x0{constructor(l){super(Bd0,{button:Od0,markupElement:new Qd0,...l})}plugins(){return[UT()]}}const Ke="list-plugin",Yd0=["[&>li>p]:before:tw-content-[counter(count,decimal)_'._']","[&>li>p]:before:tw-content-[counter(count,_lower-alpha)_'._']","[&>li>p]:before:tw-content-[counter(count,lower-roman)_'._']"],Gd0=(e,l)=>{const a=u.findNodePath(e,l);if(!a)return 0;const r=u.getNodeAncestors(e,a);return Array.from(r).filter(c=>c[0].type===u.ELEMENT_LI).length},T3=e=>`tw-list-none tw-pl-[10px] tw-mb-[10px] tw-ml-[15px] [&>li>p]:before:tw-pr-1 ${Yd0[e%3]}`,V3={counterReset:"count"},YT=({attributes:e,children:l,element:a})=>{const r=u.usePlateEditorRef(),c=Gd0(r,a);return t.createElement("ol",{className:T3(c),...e,style:V3},l)};class GT extends A0{constructor(l=u.ELEMENT_OL,a=YT){super(l,a)}}const WT=({editor:e,id:l})=>t.createElement(M0,{id:l},t.createElement(u.ListToolbarButton,{tooltip:S0("Ordered list"),type:u.getPluginType(e,l),icon:t.createElement(Z0,{icon:t.createElement(it,null)}),classNames:I0(),styles:p0,actionHandler:"onMouseDown"})),j3="tw-border-b tw-border-dashed tw-border-line-x-strong tw-pb-5",$T=`${j3} tw-break-after-column tw-break-inside-avoid-column`,D3=e=>{const l=e.breakAfterColumn;return C([l==="active"&&$T,l==="inactive"&&j3])},qT=e=>C([D3(e),e.align?Z3[e.align]:"tw-justify-start","tw-grid tw-grid-cols-[min-content_repeat(3,_auto)]"]),Wd0=({attributes:e,children:l,element:a})=>t.createElement("p",{className:qT(a),...e},t.createElement("span",{className:"tw-w-auto tw-min-w-[10px]",style:j0(a.children[0].textStyle)},l));class $d0 extends A0{constructor(l=u.ELEMENT_LIC,a=Wd0){super(l,a)}}const KT="[&>p]:before:tw-flex [&>p]:before:tw-justify-end [&>p]:before:tw-w-[1.2em] !tw-no-underline",qd0=({attributes:e,children:l,element:a})=>t.createElement("li",{style:XT(a),...e,className:KT},l);class Kd0 extends A0{constructor(l=u.ELEMENT_LI,a=qd0){super(l,a)}}const XT=e=>({...j0(JT(e)),counterIncrement:"count"}),JT=e=>{let l;if(e.type==="a")l=e.children[0].textStyle;else if(e.children)for(const a of e.children){const r=JT(a);r&&(!l||r.startsWith(l))&&(l=r)}else l=e.textStyle;return l},Xd0=(e,{options:{validLiChildrenTypes:l,isSoftBreak:a}})=>{const{insertBreak:r,deleteBackward:c,deleteForward:o,deleteFragment:i}=e;return a?e.insertSoftBreak=()=>{u.insertBreakList(e)||r()}:e.insertBreak=()=>{u.insertBreakList(e)||r()},e.deleteBackward=s=>{u.deleteBackwardList(e,s)||c(s)},e.deleteForward=s=>{u.deleteForwardList(e)||o(s)},e.deleteFragment=s=>{u.deleteFragmentList(e)||i(s)},e.insertFragment=u.insertFragmentList(e),e.normalizeNode=u.normalizeList(e,{validLiChildrenTypes:l}),e},v2="textStyle",_T=u.createPluginFactory({key:v2,isLeaf:!0});class F3 extends x0{constructor(a){super(Ke,{leafMarkupElements:[new $d0,new Kd0],...a});o0(this,"isSoftBreak");this.isSoftBreak=(a==null?void 0:a.isSoftBreak)??!1}plugins(){return[u.createListPlugin({withOverrides:Xd0,options:{isSoftBreak:this.isSoftBreak}}),_T()]}}class eV extends F3{constructor(l){super({id:Ke,button:WT,markupElement:new GT,...l})}}const B3="[&>li>p]:before:tw-content-['•'] [&>li>p]:before:tw-px-2 tw-list-none tw-pl-[10px] tw-mb-[10px] tw-ml-[15px]",tV=({attributes:e,children:l})=>t.createElement("ul",{className:B3,...e},l);class lV extends A0{constructor(l=u.ELEMENT_UL,a=tV){super(l,a)}}const nV=({editor:e,id:l})=>t.createElement(M0,{id:l},t.createElement(u.ListToolbarButton,{tooltip:S0("Bullet list"),type:u.getPluginType(e,l),icon:t.createElement(Z0,{icon:t.createElement(ct,null)}),classNames:I0(),styles:p0,actionHandler:"onMouseDown"}));class aV extends F3{constructor(l){super({id:Ke,button:nV,markupElement:new lV,...l})}}const rV="tw-m-0 tw-px-0 tw-py-0",O3=({element:e,attributes:l,children:a})=>{const r=e.align,c=C([r&&x3[r],rV,D3(e)]);return t.createElement("p",{...l,className:c,style:j0("body")},a)};class cV extends A0{constructor(l=u.ELEMENT_PARAGRAPH,a=O3){super(l,a)}}const oV=u.createPluginFactory({...u.createParagraphPlugin(),key:u.ELEMENT_PARAGRAPH,isElement:!0,component:O3});class iV extends x0{constructor(l){super(u.ELEMENT_PARAGRAPH,{markupElement:new cV,label:"Body Text",...l})}plugins(){return[oV()]}}class Jd0{constructor(){o0(this,"toolbarButtons",{[u0.BOTTOM]:[],[u0.FLOATING]:[],[u0.TOP]:[]})}createGroupOfButtons(l){const a=[],r=[],c=[];for(const{markupElement:o,button:i,id:s,showIn:m}of l){if(!i)continue;const L={id:(o==null?void 0:o.getId())||s,button:i};m.includes(u0.BOTTOM)&&a.push(L),m.includes(u0.TOP)&&r.push(L),m.includes(u0.FLOATING)&&c.push(L)}a.length>0&&this.toolbarButtons[u0.BOTTOM].push(a),r.length>0&&this.toolbarButtons[u0.TOP].push(r),c.length>0&&this.toolbarButtons[u0.FLOATING].push(c)}at(l){return this.toolbarButtons[l]}}class sV{constructor(l){o0(this,"platePlugins",new Map);o0(this,"markupElements",{});o0(this,"inlineElements",[]);o0(this,"toolbarButtons",new Jd0);this.props=l}setPlugin(...l){for(const a of l){const r=Array.isArray(a)?a:[a];for(const c of r)this.addElement(c.markupElement),this.addElement(c.markupInputElement),this.addLeafElements(c.leafMarkupElements),this.addPlugin(c),this.addInline(c.inline());this.hasToolbar&&this.toolbarButtons.createGroupOfButtons(r)}return this}addLeafElements(l){if(l===void 0)return;const a=Array.isArray(l)?l:[l];for(const r of a)this.addElement(r)}addElement(l){if(l===void 0)return;const a=l.getId(),r=l.getNode();r&&!this.markupElements[a]&&(this.markupElements[a]=r)}addPlugin(l){l.id&&!this.platePlugins.has(l.id)&&this.platePlugins.set(l.id,l.plugins())}addInline(l){l&&this.inlineElements.push(l)}get elements(){return{...this.defaultElementsFromPlugins,...this.markupElements}}get defaultElementsFromPlugins(){const l={};for(const a of this.platePlugins.values())for(const r of a){const{key:c,component:o}=r;o&&(l[c]=o)}return l}get plugins(){const l=[];for(const a of this.platePlugins.values())l.push(...a);return l}get buttons(){return this.toolbarButtons}get inline(){return this.inlineElements}get hasToolbar(){var l;return!((l=this.props)!=null&&l.noToolbar)}}const mV="reset-formatting-plugin",LV="reset-formatting",_d0=e=>{!e||!e.selection||(u.removeMark(e,{key:[u.MARK_BOLD,u.MARK_ITALIC,u.MARK_CODE,u.MARK_UNDERLINE,u.MARK_STRIKETHROUGH]}),u.unwrapList(e,{}),u.setElements(e,{type:u.ELEMENT_PARAGRAPH,align:void 0}))},ew0=u.withPlateProvider(({id:e,...l})=>{const a=u.usePlateEditorState(u.useEventPlateId(e));return t.createElement(u.ToolbarButton,{tooltip:S0("Clear formatting"),onMouseDown:()=>{_d0(a)},...l})}),tw0=({id:e})=>t.createElement(M0,{id:e},t.createElement(ew0,{icon:t.createElement(Z0,{icon:t.createElement(lt,null)}),classNames:I0(),styles:p0})),uV=u.createPluginFactory({key:LV,isElement:!1});class dV extends x0{constructor(l){super(mV,{button:tw0,...l})}plugins(){return[uV()]}}const lw0="strikethrough-plugin",P3="!tw-line-through",wV=({attributes:e,children:l})=>t.createElement("span",{...e,className:P3},l);class hV extends A0{constructor(l=u.MARK_STRIKETHROUGH,a=wV){super(l,a)}}const nw0=({editor:e,id:l})=>t.createElement(M0,{id:l},t.createElement(u.MarkToolbarButton,{tooltip:S0("Strikethrough"),type:u.getPluginType(e,l),icon:t.createElement(Z0,{icon:t.createElement(mb,null)}),classNames:I0(),styles:p0,actionHandler:"onMouseDown"}));class fV extends x0{constructor(l){super(lw0,{button:nw0,markupElement:new hV,...l})}plugins(){return[u.createStrikethroughPlugin()]}}const vV="text-style-plugin",aw0=e=>u.getAboveNode(e,{match:{type:u.ELEMENT_LI},mode:"lowest"})||u.someNode(e,{match:{type:o1},mode:"lowest"}),rw0=({editor:e,type:l,children:a})=>{const r=e!=null&&e.selection?u.getMark(e,v2)===l.id:u.someNode(e,{match:{type:l}});return t.createElement("button",{"data-test-id":"textstyle-option",type:"button",className:C(["tw-block tw-w-full tw-text-left tw-px-3 tw-py-2 tw-outline-none tw-cursor-pointer tw-truncate hover:tw-bg-box-neutral-hover hover:w-text-box-neutral-inverse-hover tw-max-h-20 tw-max-w-[15rem] tw-min-h-[2.25rem]",r?"tw-text-box-neutral-inverse tw-bg-box-neutral":"tw-text-text"]),onMouseDown:c=>{!e||!e.selection||(u.setMarks(e,{[v2]:l.id}),aw0(e)||u.getPreventDefaultHandler(u.toggleNodeType,e,{activeType:l.id,inactiveType:l.id})(c))}},a)},cw0=({label:e,open:l,onClick:a},r)=>t.createElement("button",{ref:r,"data-test-id":"textstyle-dropdown-trigger",type:"button",className:"tw-cursor-pointer tw-h-8 tw-w-full",onMouseDown:u.getPreventDefaultHandler(a)},t.createElement("div",{className:C(["tw-relative tw-inline-flex tw-flex-row tw-items-center tw-justify-between tw-overflow-hidden tw-text-text tw-rounded tw-gap-1 tw-px-2 hover:tw-text-box-selected-inverse hover:tw-bg-box-selected tw-h-6 tw-w-28",l&&"tw-text-box-selected-inverse tw-bg-box-selected"])},t.createElement("span",{className:"tw-text-xs tw-truncate"},e),t.createElement("div",{className:C(["tw-transition-transform",l&&"tw-rotate-180"])},t.createElement(K5,null)))),ow0=t.forwardRef(cw0),iw0=e=>Array.isArray(e.children)?(e.children.find(a=>u.isText(a))??{})[v2]:u.ELEMENT_PARAGRAPH,sw0=[u.ELEMENT_LI,u.ELEMENT_UL,u.ELEMENT_OL],mw0=e=>!e||!e.selection?[]:Array.from(u.getNodeEntries(e,{unhang:!0,at:e.selection,reverse:!0})).reduce((a,[r])=>{if(!u.isNode(r))return a;const c=r.type===u.ELEMENT_LIC||r.type===o1?iw0(r):r.textStyle;return c&&!a.includes(c)&&!sw0.includes(c)&&a.push(c),a},[]),Lw0=6,uw0=10,dw0={name:"vertical-positioning",phase:"read",fn:({state:e,name:l})=>{if(e.modifiersData[l]._skip)return;const{position:a,maxHeight:r}=e3(e.elements.reference,e.rects.popper.height,Lw0+uw0,0);a==="top"&&(e.placement="top-start"),e.styles.popper={maxHeight:`${r}px`},e.reset=!0,e.modifiersData[l]._skip=!0},enabled:!0},Le="Mixed";var B0=(e=>(e.heading1="heading1",e.heading2="heading2",e.heading3="heading3",e.heading4="heading4",e.custom1="custom1",e.custom2="custom2",e.custom3="custom3",e.quote="quote",e.imageCaption="imageCaption",e.imageTitle="imageTitle",e))(B0||{});const ww0=e=>{const[l,a]=t.useState(!1),[r,c]=t.useState(null),[o,i]=t.useState(null),s=u.usePlateEditorState(e),m=mw0(s),L=m.length===1?m[0]:Le,d=t.useCallback(()=>{a(w=>!w)},[a]),h=Q1.usePopper(r,o,{placement:"bottom-start",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,6]}},{name:"flip",enabled:!1},dw0]});return t.useEffect(()=>{const w=f=>{if(l){const v=f.target;if(o&&o.contains(v)||r&&r.contains(v))return;a(!1)}};return document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},[l,o,a,r]),{state:{isOpen:l,toggle:d,editor:s},dropdownProps:{...h.attributes.popper,style:h.styles.popper},key:L,dropdownRef:i,triggerRef:c}},hw0=({editorId:e,textStyles:l=[]})=>{var h;const{state:{editor:a,toggle:r,isOpen:c},dropdownProps:o,triggerRef:i,dropdownRef:s,key:m}=ww0(e);if(l.length===0)return null;let L=Le;const d=l.find(w=>{var f;return w.id===m&&((f=w.props)==null?void 0:f.label)});return d&&(L=((h=d.props)==null?void 0:h.label)||Le),t.createElement(t.Fragment,null,t.createElement(ow0,{label:L,open:c,onClick:r,ref:i}),c&&t.createElement("div",{className:"tw-divide-y tw-divide-line tw-bg-base tw-shadow-md tw-border tw-border-line tw-z-[1000] tw-overflow-auto tw-min-h-[40px]",ref:s,...o},l.map(w=>{var f;return t.createElement(rw0,{editor:a,type:w,key:w.id},t.createElement("span",{style:j0(w.id)},(f=w.props)==null?void 0:f.label))})))},fw0=({editorId:e,id:l,textStyles:a})=>t.createElement(M0,{id:l},t.createElement(hw0,{editorId:e,textStyles:a})),vw0=(e,l)=>a=>t.createElement(e,{...a,textStyles:l});class gV extends x0{constructor({textStyles:a=[],...r}={}){super(vV,{button:vw0(fw0,a),textStyles:a,...r});o0(this,"textStyles");this.textStyles=a}plugins(){return this.textStyles.map(a=>a.plugins()).flat()}}const gw0="underline-plugin",Xe="tw-underline",AV=({attributes:e,children:l})=>t.createElement("span",{...e,className:Xe},l);class CV extends A0{constructor(l=u.MARK_UNDERLINE,a=AV){super(l,a)}}const Aw0=({editor:e,id:l})=>t.createElement(M0,{id:l},t.createElement(u.MarkToolbarButton,{tooltip:S0(`Underline
|
|
39
|
+
${q1("Ctrl+K")}`:"Links can only be set for a single text block."),icon:t.createElement(Z0,{icon:t.createElement(rt,null)}),classNames:c,styles:p0,actionHandler:"onMouseDown"}))},Pd0=e=>({...u.useElementProps({...e,elementToAttributes:a=>({href:PT(a),target:a.target||"_blank"})}),onMouseOver:a=>{a.stopPropagation()}}),Ud0=e=>{const l=Pd0(e),{attributes:a,children:r}=e;return t.createElement("a",{...a,href:l.href,target:l.target,style:j0("link")},r)};class Qd0 extends A0{constructor(l=u.ELEMENT_LINK,a=Ud0){super(l,a)}}const UT=u.createPluginFactory({...u.createLinkPlugin(),renderAfterEditable:Fd0,options:{isUrl:cT,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"command+k, ctrl+k"}});class QT extends x0{constructor(l){super(Bd0,{button:Od0,markupElement:new Qd0,...l})}plugins(){return[UT()]}}const Ke="list-plugin",Yd0=["[&>li>p]:before:tw-content-[counter(count,decimal)_'._']","[&>li>p]:before:tw-content-[counter(count,_lower-alpha)_'._']","[&>li>p]:before:tw-content-[counter(count,lower-roman)_'._']"],Gd0=(e,l)=>{const a=u.findNodePath(e,l);if(!a)return 0;const r=u.getNodeAncestors(e,a);return Array.from(r).filter(c=>c[0].type===u.ELEMENT_LI).length},T3=e=>`tw-list-none tw-pl-[10px] tw-mb-[10px] tw-ml-[15px] [&>li>p]:before:tw-pr-1 ${Yd0[e%3]}`,V3={counterReset:"count"},YT=({attributes:e,children:l,element:a})=>{const r=u.usePlateEditorRef(),c=Gd0(r,a);return t.createElement("ol",{className:T3(c),...e,style:V3},l)};class GT extends A0{constructor(l=u.ELEMENT_OL,a=YT){super(l,a)}}const WT=({editor:e,id:l})=>t.createElement(M0,{id:l},t.createElement(u.ListToolbarButton,{tooltip:S0("Ordered list"),type:u.getPluginType(e,l),icon:t.createElement(Z0,{icon:t.createElement(it,null)}),classNames:I0(),styles:p0,actionHandler:"onMouseDown"})),j3="tw-border-b tw-border-dashed tw-border-line-x-strong tw-pb-5",$T=`${j3} tw-break-after-column tw-break-inside-avoid-column`,D3=e=>{const l=e.breakAfterColumn;return C([l==="active"&&$T,l==="inactive"&&j3])},qT=e=>C([D3(e),e.align?Z3[e.align]:"tw-justify-start","tw-grid tw-grid-cols-[min-content_repeat(3,_auto)]"]),Wd0=({attributes:e,children:l,element:a})=>t.createElement("p",{className:qT(a),...e},t.createElement("span",{className:"tw-w-auto tw-min-w-[10px]",style:j0(a.children[0].textStyle)},l));class $d0 extends A0{constructor(l=u.ELEMENT_LIC,a=Wd0){super(l,a)}}const KT="[&>p]:before:tw-flex [&>p]:before:tw-justify-end [&>p]:before:tw-w-[1.2em] !tw-no-underline",qd0=({attributes:e,children:l,element:a})=>t.createElement("li",{style:XT(a),...e,className:KT},l);class Kd0 extends A0{constructor(l=u.ELEMENT_LI,a=qd0){super(l,a)}}const XT=e=>({...j0(JT(e)),counterIncrement:"count"}),JT=e=>{let l;if(e.type==="a")l=e.children[0].textStyle;else if(e.children)for(const a of e.children){const r=JT(a);r&&(!l||r.startsWith(l))&&(l=r)}else l=e.textStyle;return l},Xd0=(e,{options:{validLiChildrenTypes:l,isSoftBreak:a}})=>{const{insertBreak:r,deleteBackward:c,deleteForward:o,deleteFragment:i}=e;return a?e.insertSoftBreak=()=>{u.insertBreakList(e)||r()}:e.insertBreak=()=>{u.insertBreakList(e)||r()},e.deleteBackward=s=>{u.deleteBackwardList(e,s)||c(s)},e.deleteForward=s=>{u.deleteForwardList(e)||o(s)},e.deleteFragment=s=>{u.deleteFragmentList(e)||i(s)},e.insertFragment=u.insertFragmentList(e),e.normalizeNode=u.normalizeList(e,{validLiChildrenTypes:l}),e},v2="textStyle",_T=u.createPluginFactory({key:v2,isLeaf:!0});class F3 extends x0{constructor(a){super(Ke,{leafMarkupElements:[new $d0,new Kd0],...a});o0(this,"isSoftBreak");this.isSoftBreak=(a==null?void 0:a.isSoftBreak)??!1}plugins(){return[u.createListPlugin({withOverrides:Xd0,options:{isSoftBreak:this.isSoftBreak}}),_T()]}}class eV extends F3{constructor(l){super({id:Ke,button:WT,markupElement:new GT,...l})}}const B3="[&>li>p]:before:tw-content-['•'] [&>li>p]:before:tw-px-2 tw-list-none tw-pl-[10px] tw-mb-[10px] tw-ml-[15px]",tV=({attributes:e,children:l})=>t.createElement("ul",{className:B3,...e},l);class lV extends A0{constructor(l=u.ELEMENT_UL,a=tV){super(l,a)}}const nV=({editor:e,id:l})=>t.createElement(M0,{id:l},t.createElement(u.ListToolbarButton,{tooltip:S0("Bullet list"),type:u.getPluginType(e,l),icon:t.createElement(Z0,{icon:t.createElement(ct,null)}),classNames:I0(),styles:p0,actionHandler:"onMouseDown"}));class aV extends F3{constructor(l){super({id:Ke,button:nV,markupElement:new lV,...l})}}const rV="tw-m-0 tw-px-0 tw-py-0",O3=({element:e,attributes:l,children:a})=>{const r=e.align,c=C([r&&x3[r],rV,D3(e)]);return t.createElement("p",{...l,className:c,style:j0("body")},a)};class cV extends A0{constructor(l=u.ELEMENT_PARAGRAPH,a=O3){super(l,a)}}const oV=u.createPluginFactory({...u.createParagraphPlugin(),key:u.ELEMENT_PARAGRAPH,isElement:!0,component:O3});class iV extends x0{constructor(l){super(u.ELEMENT_PARAGRAPH,{markupElement:new cV,label:"Body Text",...l})}plugins(){return[oV()]}}class Jd0{constructor(){o0(this,"toolbarButtons",{[u0.BOTTOM]:[],[u0.FLOATING]:[],[u0.TOP]:[]})}createGroupOfButtons(l){const a=[],r=[],c=[];for(const{markupElement:o,button:i,id:s,showIn:m}of l){if(!i)continue;const L={id:(o==null?void 0:o.getId())||s,button:i};m.includes(u0.BOTTOM)&&a.push(L),m.includes(u0.TOP)&&r.push(L),m.includes(u0.FLOATING)&&c.push(L)}a.length>0&&this.toolbarButtons[u0.BOTTOM].push(a),r.length>0&&this.toolbarButtons[u0.TOP].push(r),c.length>0&&this.toolbarButtons[u0.FLOATING].push(c)}at(l){return this.toolbarButtons[l]}}class sV{constructor(l){o0(this,"platePlugins",new Map);o0(this,"markupElements",{});o0(this,"inlineElements",[]);o0(this,"toolbarButtons",new Jd0);this.props=l}setPlugin(...l){for(const a of l){const r=Array.isArray(a)?a:[a];for(const c of r)this.addElement(c.markupElement),this.addElement(c.markupInputElement),this.addLeafElements(c.leafMarkupElements),this.addPlugin(c),this.addInline(c.inline());this.hasToolbar&&this.toolbarButtons.createGroupOfButtons(r)}return this}addLeafElements(l){if(l===void 0)return;const a=Array.isArray(l)?l:[l];for(const r of a)this.addElement(r)}addElement(l){if(l===void 0)return;const a=l.getId(),r=l.getNode();r&&!this.markupElements[a]&&(this.markupElements[a]=r)}addPlugin(l){l.id&&!this.platePlugins.has(l.id)&&this.platePlugins.set(l.id,l.plugins())}addInline(l){l&&this.inlineElements.push(l)}get elements(){return{...this.defaultElementsFromPlugins,...this.markupElements}}get defaultElementsFromPlugins(){const l={};for(const a of this.platePlugins.values())for(const r of a){const{key:c,component:o}=r;o&&(l[c]=o)}return l}get plugins(){const l=[];for(const a of this.platePlugins.values())l.push(...a);return l}get buttons(){return this.toolbarButtons}get inline(){return this.inlineElements}get hasToolbar(){var l;return!((l=this.props)!=null&&l.noToolbar)}}const mV="reset-formatting-plugin",LV="reset-formatting",_d0=e=>{!e||!e.selection||(u.removeMark(e,{key:[u.MARK_BOLD,u.MARK_ITALIC,u.MARK_CODE,u.MARK_UNDERLINE,u.MARK_STRIKETHROUGH]}),u.unwrapList(e,{}),u.setElements(e,{type:u.ELEMENT_PARAGRAPH,align:void 0}))},ew0=u.withPlateProvider(({id:e,...l})=>{const a=u.usePlateEditorState(u.useEventPlateId(e));return t.createElement(u.ToolbarButton,{tooltip:S0("Clear formatting"),onMouseDown:()=>{_d0(a)},...l})}),tw0=({id:e})=>t.createElement(M0,{id:e},t.createElement(ew0,{icon:t.createElement(Z0,{icon:t.createElement(lt,null)}),classNames:I0(),styles:p0})),uV=u.createPluginFactory({key:LV,isElement:!1});class dV extends x0{constructor(l){super(mV,{button:tw0,...l})}plugins(){return[uV()]}}const lw0="strikethrough-plugin",P3="!tw-line-through",wV=({attributes:e,children:l})=>t.createElement("span",{...e,className:P3},l);class hV extends A0{constructor(l=u.MARK_STRIKETHROUGH,a=wV){super(l,a)}}const nw0=({editor:e,id:l})=>t.createElement(M0,{id:l},t.createElement(u.MarkToolbarButton,{tooltip:S0("Strikethrough"),type:u.getPluginType(e,l),icon:t.createElement(Z0,{icon:t.createElement(mb,null)}),classNames:I0(),styles:p0,actionHandler:"onMouseDown"}));class fV extends x0{constructor(l){super(lw0,{button:nw0,markupElement:new hV,...l})}plugins(){return[u.createStrikethroughPlugin()]}}const vV="text-style-plugin",aw0=e=>u.getAboveNode(e,{match:{type:u.ELEMENT_LI},mode:"lowest"})||u.someNode(e,{match:{type:o1},mode:"lowest"}),rw0=({editor:e,type:l,children:a})=>{const r=e!=null&&e.selection?u.getMark(e,v2)===l.id:u.someNode(e,{match:{type:l}});return t.createElement("button",{"data-test-id":"textstyle-option",type:"button",className:C(["tw-block tw-w-full tw-text-left tw-px-3 tw-py-2 tw-outline-none tw-cursor-pointer tw-truncate hover:tw-bg-box-neutral-hover hover:w-text-box-neutral-inverse-hover tw-max-h-20 tw-max-w-[15rem] tw-min-h-[2.25rem]",r?"tw-text-box-neutral-inverse tw-bg-box-neutral":"tw-text-text"]),onMouseDown:c=>{!e||!e.selection||(u.setMarks(e,{[v2]:l.id}),aw0(e)||u.getPreventDefaultHandler(u.toggleNodeType,e,{activeType:l.id,inactiveType:l.id})(c))}},a)},cw0=({label:e,open:l,onClick:a},r)=>t.createElement("button",{ref:r,"data-test-id":"textstyle-dropdown-trigger",type:"button",className:"tw-cursor-pointer tw-h-8 tw-w-full",onMouseDown:u.getPreventDefaultHandler(a)},t.createElement("div",{className:C(["tw-relative tw-inline-flex tw-flex-row tw-items-center tw-justify-between tw-overflow-hidden tw-text-text tw-rounded tw-gap-1 tw-px-2 hover:tw-text-box-selected-inverse hover:tw-bg-box-selected tw-h-6 tw-w-28",l&&"tw-text-box-selected-inverse tw-bg-box-selected"])},t.createElement("span",{className:"tw-text-xs tw-truncate"},e),t.createElement("div",{className:C(["tw-transition-transform",l&&"tw-rotate-180"])},t.createElement(K5,null)))),ow0=t.forwardRef(cw0),iw0=e=>Array.isArray(e.children)?(e.children.find(a=>u.isText(a))??{})[v2]:u.ELEMENT_PARAGRAPH,sw0=[u.ELEMENT_LI,u.ELEMENT_UL,u.ELEMENT_OL],mw0=e=>!e||!e.selection?[]:Array.from(u.getNodeEntries(e,{unhang:!0,at:e.selection,reverse:!0})).reduce((a,[r])=>{if(!u.isNode(r))return a;const c=r.type===u.ELEMENT_LIC||r.type===o1?iw0(r):r.textStyle;return c&&!a.includes(c)&&!sw0.includes(c)&&a.push(c),a},[]),Lw0=6,uw0=10,dw0={name:"vertical-positioning",phase:"read",fn:({state:e,name:l})=>{if(e.modifiersData[l]._skip)return;const{position:a,maxHeight:r}=e3(e.elements.reference,e.rects.popper.height,Lw0+uw0,0);a==="top"&&(e.placement="top-start"),e.styles.popper={maxHeight:`${r}px`},e.reset=!0,e.modifiersData[l]._skip=!0},enabled:!0},Le="Mixed";var B0=(e=>(e.heading1="heading1",e.heading2="heading2",e.heading3="heading3",e.heading4="heading4",e.custom1="custom1",e.custom2="custom2",e.custom3="custom3",e.quote="quote",e.imageCaption="imageCaption",e.imageTitle="imageTitle",e))(B0||{});const ww0=e=>{const[l,a]=t.useState(!1),[r,c]=t.useState(null),[o,i]=t.useState(null),s=u.usePlateEditorState(e),m=mw0(s);let L=Le;m.length===1?L=m[0]:m.length===0&&(L="p");const d=t.useCallback(()=>{a(w=>!w)},[a]),h=Q1.usePopper(r,o,{placement:"bottom-start",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,6]}},{name:"flip",enabled:!1},dw0]});return t.useEffect(()=>{const w=f=>{if(l){const v=f.target;if(o&&o.contains(v)||r&&r.contains(v))return;a(!1)}};return document.addEventListener("mousedown",w),()=>{document.removeEventListener("mousedown",w)}},[l,o,a,r]),{state:{isOpen:l,toggle:d,editor:s},dropdownProps:{...h.attributes.popper,style:h.styles.popper},key:L,dropdownRef:i,triggerRef:c}},hw0=({editorId:e,textStyles:l=[]})=>{var h;const{state:{editor:a,toggle:r,isOpen:c},dropdownProps:o,triggerRef:i,dropdownRef:s,key:m}=ww0(e);if(l.length===0)return null;let L=Le;const d=l.find(w=>{var f;return w.id===m&&((f=w.props)==null?void 0:f.label)});return d&&(L=((h=d.props)==null?void 0:h.label)||Le),t.createElement(t.Fragment,null,t.createElement(ow0,{label:L,open:c,onClick:r,ref:i}),c&&t.createElement("div",{className:"tw-divide-y tw-divide-line tw-bg-base tw-shadow-md tw-border tw-border-line tw-z-[1000] tw-overflow-auto tw-min-h-[40px]",ref:s,...o},l.map(w=>{var f;return t.createElement(rw0,{editor:a,type:w,key:w.id},t.createElement("span",{style:j0(w.id)},(f=w.props)==null?void 0:f.label))})))},fw0=({editorId:e,id:l,textStyles:a})=>t.createElement(M0,{id:l},t.createElement(hw0,{editorId:e,textStyles:a})),vw0=(e,l)=>a=>t.createElement(e,{...a,textStyles:l});class gV extends x0{constructor({textStyles:a=[],...r}={}){super(vV,{button:vw0(fw0,a),textStyles:a,...r});o0(this,"textStyles");this.textStyles=a}plugins(){return this.textStyles.map(a=>a.plugins()).flat()}}const gw0="underline-plugin",Xe="tw-underline",AV=({attributes:e,children:l})=>t.createElement("span",{...e,className:Xe},l);class CV extends A0{constructor(l=u.MARK_UNDERLINE,a=AV){super(l,a)}}const Aw0=({editor:e,id:l})=>t.createElement(M0,{id:l},t.createElement(u.MarkToolbarButton,{tooltip:S0(`Underline
|
|
40
40
|
${q1("Ctrl+U")}`),type:u.getPluginType(e,l),icon:t.createElement(Z0,{icon:t.createElement(It,null)}),classNames:I0(),styles:p0,actionHandler:"onMouseDown"})),Cw0=[{validNodeName:["U"]},{validStyle:{textDecoration:["underline"]}}];class EV extends x0{constructor(l){super(gw0,{button:Aw0,markupElement:new CV,...l})}plugins(){return[u.createUnderlinePlugin({deserializeHtml:{rules:[...Cw0,{validNodeName:["SPAN"],validClassName:Xe}]},options:{hotkey:["mod+u","ctrl+u"]}})]}}const IV=e=>Array.from(u.getNodeEntries(e,{at:[],match:l=>!!l.breakAfterColumn})).length,g2=(e,{key:l=_1,value:a,at:r})=>{const c=o=>u.isBlock(e,o);a?u.setElements(e,{[l]:a},{mode:"lowest",match:c,at:r}):u.unsetNodes(e,l,{match:c,mode:"lowest",at:r})},Ew0=(e,l,a)=>{g2(e,{at:l,value:a})},H5=(e,l)=>{const a=Array.from(u.getNodeEntries(e,{at:[],match:r=>!!r.breakAfterColumn}));for(const[r,[,c]]of a.entries())Ew0(e,c,r<l-1?"active":"inactive")},MV=(e,l,a)=>{if(!!(e!=null&&e.selection)&&u.someNode(e,{match:c=>!!c.breakAfterColumn}))g2(e,{value:void 0});else{const c=IV(e),o=Math.max(l-c-1,0);if(o===0)return;const i=Array.from(u.getNodeEntries(e,{at:e.selection,match:s=>u.isBlock(e,s),mode:"lowest"})).slice(-o);u.getPreventDefaultHandler(()=>{for(const s of i)g2(e,{value:"active",at:s[1]})})(a)}H5(e,l)},Iw0=e=>l=>{var a;if(!l.defaultPrevented&&Fj("shift+ctrl+enter",l)){const r=e.plugins.find(o=>o.key===_1),c=((a=r==null?void 0:r.options)==null?void 0:a.columns)??1;MV(e,c,l)}},Mw0=({id:e,...l})=>{var L;const a=u.usePlateEditorState(u.useEventPlateId(e)),r=!!(a!=null&&a.selection)&&u.someNode(a,{match:d=>!!d.breakAfterColumn}),c=a.pluginsByKey.breakAfterColumn,o=(L=c==null?void 0:c.options)==null?void 0:L.columns,i=Number(o)||1,s=xw0(a,i,r),m=I0(s);return t.createElement(u.ToolbarButton,{active:r,tooltip:S0(s?`Column Break
|
|
41
41
|
Shift+Ctrl+Return`:"Already at maximum numbers of columns"),onMouseDown:d=>MV(a,i,d),...l,classNames:m})},xw0=(e,l,a)=>IV(e)+1<l||a,xV=({id:e})=>t.createElement(M0,{id:e},t.createElement(Mw0,{icon:t.createElement(Z0,{icon:t.createElement(At,null)}),classNames:I0(),styles:p0})),Zw0=(e,l)=>{const a=u.getStartPoint(e,l);setTimeout(()=>{u.select(e,{anchor:a,focus:a})})},pw0=e=>{var a;const l=e.plugins.find(r=>r.key===_1);return((a=l==null?void 0:l.options)==null?void 0:a.columns)??1},Nw0=e=>{const{apply:l}=e,a=pw0(e);e.apply=r=>{switch(r.type){case"split_node":r.properties={...r.properties,breakAfterColumn:void 0};break;case"merge_node":const c=u.getPointBefore(e,r.path);if(!c)break;const o=u.getParentNode(e,c.path);if(g2(e,{at:c,value:void 0}),H5(e,a),o!=null&&o[0].breakAfterColumn)return Zw0(e,r.path),e;break}l(r)},setTimeout(()=>H5(e,a))},_1="breakAfterColumn",U3="normal";class Sw0 extends x0{constructor(a){super("break-after-plugin",{button:xV,...a});o0(this,"columns");o0(this,"gap");this.columns=(a==null?void 0:a.columns)??1,this.gap=(a==null?void 0:a.gap)??U3}plugins(){return[ZV(this.columns,this.gap)]}}const ZV=(e,l)=>u.createPluginFactory({key:_1,handlers:{onKeyDown:Iw0},useHooks:Nw0,options:{columns:e,gap:l}})(),yw0=12,Rw0=26,bw0=124,kw0=e=>e.map((l,a)=>({group:l,buttonGroupWidth:l.reduce((r,c)=>c.id===vV?bw0:Rw0+r,yw0),index:a})),Hw0=(e,l)=>l.reduce((a,{group:r,buttonGroupWidth:c,index:o})=>{const i=Math.max(0,a.length-1);return a[i]=a[i]??[],(a[i]??[{actions:[],buttonGroupWidth:0}]).reduce((m,{buttonGroupWidth:L})=>m+L,0)+c<=e?a[i].push({group:r,buttonGroupWidth:c,index:o}):a.push([{group:r,buttonGroupWidth:c,index:o}]),a.filter(m=>m.length)},[]),zw0=({index:e,children:l})=>t.createElement("div",{"data-test-id":`toolbar-group-${e}`,className:"tw-flex tw-items-center tw-h-9 tw-p-2"},l),Tw0=({toolbarButtons:e,editorId:l,toolbarWidth:a})=>{const r=u.usePlateEditorRef(l),{editorWidth:c}=sT(),{position:o}=Qe(),i=a||c||0,s=kw0(e.at(o)),m=Hw0(i,s),L=bV[o];return t.createElement(L.ToolbarWrapper,{editorWidth:c,toolbarWidth:a,toolbarButtonGroups:m},m.map((d,h)=>t.createElement("div",{className:"tw-divide-x tw-divide-line tw-flex tw-w-full tw-flex-wrap",key:h},d.map(({group:w,index:f})=>t.createElement(zw0,{index:f,key:f},w.map((v,A)=>t.createElement(v.button,{editor:r,editorId:l,id:v.id,key:A.toString()})))))))},pV=e=>u.createPlugins(e.plugins,{components:u.createPlateUI(e.elements)}),Q3=(e,l)=>({create:()=>pV(l),toolbar:a=>l.hasToolbar?t.createElement(Tw0,{toolbarButtons:l.buttons,editorId:e,toolbarWidth:a}):null,inline:()=>t.createElement(t.Fragment,null,l.inline.map((a,r)=>t.createElement(a,{key:r})))}),Vw0="mention-plugin",jw0=e=>l=>l.text.toLowerCase().includes(e.toLowerCase()),Y3=(e,l)=>`${e}:${l}`,G3=e=>{const l=new Map;for(const a of e){const r=Y3(a.data.category,a.data.id),c=a.text;l.set(r,c)}return l},NV=(e,l,a)=>e.get(l)??a;var Y0=(e=>(e.GROUP="group",e.ALL="all",e.USER="user",e))(Y0||{});const W3=({attributes:e,element:l,nodeProps:a,children:r})=>t.createElement("span",{...e,"data-slate-value":l==null?void 0:l.value,"data-slate-key":l==null?void 0:l.key,"data-slate-category":l==null?void 0:l.category,contentEditable:!1,style:{lineHeight:"10px",padding:"1px",margin:"0 1px",fontWeight:"bold",verticalAlign:"baseline",display:"inline-block",borderRadius:"2px",backgroundColor:"rgb(227, 232, 246)",color:"rgb(130, 95, 255)"},...a},r),Dw0=({children:e,...l})=>t.createElement(W3,{...l},t.createElement("span",{style:{paddingRight:"3px",display:"inline-block",margin:"-1px 0"}},t.createElement(Me,null)),e),Fw0=({children:e,...l})=>t.createElement(W3,{...l},"@",e),Bw0=({children:e,...l})=>t.createElement(W3,{...l},e),Ow0=({category:e,children:l,...a})=>{const r={[Y0.USER]:Bw0,[Y0.GROUP]:Dw0,[Y0.ALL]:Fw0},c=r[e]??r[Y0.USER];return t.createElement(c,{...a},l)},$3=e=>l=>{const{element:a,children:r}=l,c=Y3(a==null?void 0:a.category,String(a==null?void 0:a.id));return t.createElement(Ow0,{category:a==null?void 0:a.category,...l},NV(e,c,String(a==null?void 0:a.id)),r)};class SV extends A0{constructor(l=u.ELEMENT_MENTION){super(l)}setNodeWithMentionable(l){return this.node=$3(G3(l)),this}}const Pw0=({image:e,category:l,text:a,id:r})=>{if(e)return t.createElement("img",{src:e,alt:`${r}-${l}-${a}`});switch(l){case Y0.GROUP:return t.createElement(Me,null);case Y0.ALL:return t.createElement(dt,null);default:return t.createElement(mt,null)}},Uw0=({item:e})=>{const{data:{image:l,category:a},key:r,text:c}=e;return t.createElement("div",{className:"tw-flex tw-items-center tw-w-full tw-min-h-[inherit]"},t.createElement("span",{className:"tw-flex tw-items-center tw-justify-center tw-rounded-full tw-mr-2.5 tw-bg-base-alt tw-border tw-border-line-weak tw-w-[22px] tw-h-[22px] tw-shrink-0 tw-overflow-hidden group-hover:tw-border-base group-aria-selected:tw-border-base"},t.createElement(Pw0,{image:l,category:a,text:c,id:r})),t.createElement("span",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis"},c))},W7=[`
|
|
42
42
|
color: var(--text-color-weak);
|