@frontify/fondue 12.0.0-beta.413 → 12.0.0-beta.414
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/fondue/components/RichTextEditor/BlurObserver.es.js +6 -6
- package/dist/fondue/components/RichTextEditor/BlurObserver.es.js.map +1 -1
- package/dist/fondue/index.cjs.js +1 -1
- package/dist/fondue/index.cjs.js.map +1 -1
- package/dist/fondue/index.umd.js +1 -1
- package/dist/fondue/index.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { useEditorRef as b } from "@udecode/plate-core";
|
|
2
2
|
import { useFloatingLinkSelectors as I, floatingLinkActions as S } from "@udecode/plate-link";
|
|
3
3
|
import { useState as T, useCallback as f, useEffect as m } from "react";
|
|
4
|
-
import { FLOATING_MODAL_SELECTOR as
|
|
4
|
+
import { FLOATING_MODAL_SELECTOR as h } from "./components/FloatingModal/FloatingModal.es.js";
|
|
5
5
|
const B = ({
|
|
6
|
-
hideExternalFloatingModals:
|
|
6
|
+
hideExternalFloatingModals: i
|
|
7
7
|
}) => {
|
|
8
|
-
const e = b(),
|
|
9
|
-
|
|
10
|
-
}, [
|
|
8
|
+
const e = b(), n = I().isOpen(e.id), [c, d] = T(!1), o = f(() => {
|
|
9
|
+
n && S.hide(), i && i(e.id);
|
|
10
|
+
}, [n, i, e]), l = f(() => {
|
|
11
11
|
e.collapse(), o();
|
|
12
12
|
}, [e, o]);
|
|
13
13
|
return m(() => {
|
|
14
14
|
if (!c)
|
|
15
15
|
return;
|
|
16
16
|
const t = (r) => {
|
|
17
|
-
const v = `[data-editor-id='${e.id}']`, E = "[role='toolbar']", p = "[data-is-underlay]", s = r.target, L = s.closest(p), O = s.closest(
|
|
17
|
+
const v = `[data-editor-id='${e.id}']`, E = "[role='toolbar']", p = "[data-is-underlay]", s = r.target, L = s.closest(p), O = s.closest(h), a = s.closest(v), u = s.closest(E);
|
|
18
18
|
a && !O || u ? o() : !a && !u && !L && (l(), d(!1));
|
|
19
19
|
};
|
|
20
20
|
return document.addEventListener("pointerdown", t), document.addEventListener("focusin", t), () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlurObserver.es.js","sources":["../../../../src/components/RichTextEditor/BlurObserver.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useEditorRef } from '@udecode/plate-core';\nimport { floatingLinkActions, useFloatingLinkSelectors } from '@udecode/plate-link';\nimport { useCallback, useEffect, useState } from 'react';\n\nimport { FLOATING_MODAL_SELECTOR } from './components';\n\nexport const BlurObserver = ({\n hideExternalFloatingModals,\n}: {\n hideExternalFloatingModals?: (editorId: string) => void;\n}) => {\n const editorRef = useEditorRef();\n const isFloatingLinkModalOpen = useFloatingLinkSelectors().isOpen(editorRef.id);\n const [isBlurObserverActive, setIsBlurObserverActive] = useState(false);\n\n const collapseFloatingModals = useCallback(() => {\n if (isFloatingLinkModalOpen) {\n floatingLinkActions.
|
|
1
|
+
{"version":3,"file":"BlurObserver.es.js","sources":["../../../../src/components/RichTextEditor/BlurObserver.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useEditorRef } from '@udecode/plate-core';\nimport { floatingLinkActions, useFloatingLinkSelectors } from '@udecode/plate-link';\nimport { useCallback, useEffect, useState } from 'react';\n\nimport { FLOATING_MODAL_SELECTOR } from './components';\n\nexport const BlurObserver = ({\n hideExternalFloatingModals,\n}: {\n hideExternalFloatingModals?: (editorId: string) => void;\n}) => {\n const editorRef = useEditorRef();\n const isFloatingLinkModalOpen = useFloatingLinkSelectors().isOpen(editorRef.id);\n const [isBlurObserverActive, setIsBlurObserverActive] = useState(false);\n\n const collapseFloatingModals = useCallback(() => {\n if (isFloatingLinkModalOpen) {\n floatingLinkActions.hide();\n }\n if (hideExternalFloatingModals) {\n hideExternalFloatingModals(editorRef.id);\n }\n }, [isFloatingLinkModalOpen, hideExternalFloatingModals, editorRef]);\n\n const collapseEverything = useCallback(() => {\n editorRef.collapse();\n collapseFloatingModals();\n }, [editorRef, collapseFloatingModals]);\n\n useEffect(() => {\n if (!isBlurObserverActive) {\n return;\n }\n\n const handleInteractWithOutside = (event: FocusEvent | MouseEvent) => {\n const richTextEditorSelector = `[data-editor-id='${editorRef.id}']`;\n const toolbarSelector = \"[role='toolbar']\";\n const modalSelector = '[data-is-underlay]';\n\n const targetElement = event.target as HTMLElement;\n\n const isInsidePortalledModal = targetElement.closest(modalSelector);\n const isInsideNonPortalledModal = targetElement.closest(FLOATING_MODAL_SELECTOR);\n const isInsideRichTextEditor = targetElement.closest(richTextEditorSelector);\n const isInsideRichTextEditorToolbar = targetElement.closest(toolbarSelector);\n\n if ((isInsideRichTextEditor && !isInsideNonPortalledModal) || isInsideRichTextEditorToolbar) {\n collapseFloatingModals();\n } else if (!isInsideRichTextEditor && !isInsideRichTextEditorToolbar && !isInsidePortalledModal) {\n collapseEverything();\n setIsBlurObserverActive(false);\n }\n };\n\n document.addEventListener('pointerdown', handleInteractWithOutside);\n document.addEventListener('focusin', handleInteractWithOutside);\n\n return () => {\n document.removeEventListener('focusin', handleInteractWithOutside);\n document.removeEventListener('pointerdown', handleInteractWithOutside);\n };\n }, [collapseEverything, collapseFloatingModals, editorRef.id, isBlurObserverActive]);\n\n /* Only activate blur observer when the user has focused the editor\n to limit the number of active document event listeners */\n useEffect(() => {\n const richTextEditor = document.querySelector(`[data-editor-id='${editorRef.id}']`);\n\n if (!richTextEditor) {\n return;\n }\n\n const setupBlurObserver = () => {\n setIsBlurObserverActive(true);\n };\n\n richTextEditor.addEventListener('focusin', setupBlurObserver);\n\n return () => {\n richTextEditor.removeEventListener('focusin', setupBlurObserver);\n };\n }, [editorRef.id]);\n\n return null;\n};\n"],"names":["BlurObserver","hideExternalFloatingModals","editorRef","useEditorRef","isFloatingLinkModalOpen","useFloatingLinkSelectors","isBlurObserverActive","setIsBlurObserverActive","useState","collapseFloatingModals","useCallback","floatingLinkActions","collapseEverything","useEffect","handleInteractWithOutside","event","richTextEditorSelector","toolbarSelector","modalSelector","targetElement","isInsidePortalledModal","isInsideNonPortalledModal","FLOATING_MODAL_SELECTOR","isInsideRichTextEditor","isInsideRichTextEditorToolbar","richTextEditor","setupBlurObserver"],"mappings":";;;;AAQO,MAAMA,IAAe,CAAC;AAAA,EACzB,4BAAAC;AACJ,MAEM;AACF,QAAMC,IAAYC,KACZC,IAA0BC,EAA2B,EAAA,OAAOH,EAAU,EAAE,GACxE,CAACI,GAAsBC,CAAuB,IAAIC,EAAS,EAAK,GAEhEC,IAAyBC,EAAY,MAAM;AAC7C,IAAIN,KACAO,EAAoB,KAAK,GAEzBV,KACAA,EAA2BC,EAAU,EAAE;AAAA,EAE5C,GAAA,CAACE,GAAyBH,GAA4BC,CAAS,CAAC,GAE7DU,IAAqBF,EAAY,MAAM;AACzC,IAAAR,EAAU,SAAS,GACIO;EAAA,GACxB,CAACP,GAAWO,CAAsB,CAAC;AAEtC,SAAAI,EAAU,MAAM;AACZ,QAAI,CAACP;AACD;AAGE,UAAAQ,IAA4B,CAACC,MAAmC;AAC5D,YAAAC,IAAyB,oBAAoBd,EAAU,EAAE,MACzDe,IAAkB,oBAClBC,IAAgB,sBAEhBC,IAAgBJ,EAAM,QAEtBK,IAAyBD,EAAc,QAAQD,CAAa,GAC5DG,IAA4BF,EAAc,QAAQG,CAAuB,GACzEC,IAAyBJ,EAAc,QAAQH,CAAsB,GACrEQ,IAAgCL,EAAc,QAAQF,CAAe;AAEtE,MAAAM,KAA0B,CAACF,KAA8BG,IACnCf,MAChB,CAACc,KAA0B,CAACC,KAAiC,CAACJ,MAClDR,KACnBL,EAAwB,EAAK;AAAA,IACjC;AAGK,oBAAA,iBAAiB,eAAeO,CAAyB,GACzD,SAAA,iBAAiB,WAAWA,CAAyB,GAEvD,MAAM;AACA,eAAA,oBAAoB,WAAWA,CAAyB,GACxD,SAAA,oBAAoB,eAAeA,CAAyB;AAAA,IAAA;AAAA,EACzE,GACD,CAACF,GAAoBH,GAAwBP,EAAU,IAAII,CAAoB,CAAC,GAInFO,EAAU,MAAM;AACZ,UAAMY,IAAiB,SAAS,cAAc,oBAAoBvB,EAAU,EAAE,IAAI;AAElF,QAAI,CAACuB;AACD;AAGJ,UAAMC,IAAoB,MAAM;AAC5B,MAAAnB,EAAwB,EAAI;AAAA,IAAA;AAGjB,WAAAkB,EAAA,iBAAiB,WAAWC,CAAiB,GAErD,MAAM;AACM,MAAAD,EAAA,oBAAoB,WAAWC,CAAiB;AAAA,IAAA;AAAA,EACnE,GACD,CAACxB,EAAU,EAAE,CAAC,GAEV;AACX;"}
|
package/dist/fondue/index.cjs.js
CHANGED
|
@@ -10,7 +10,7 @@ ${_1("Ctrl+.")}`),nodeType:b.getPluginType(e,l),clear:b.getPluginType(e,i0.MARK_
|
|
|
10
10
|
${_1("Ctrl+,")}`),nodeType:b.getPluginType(e,l),clear:b.getPluginType(e,i0.MARK_SUBSCRIPT),children:t.jsx(M0,{icon:t.jsx(H7,{})})})}),ux0="superscript-plugin",vB=({attributes:e,children:l})=>t.jsx("sup",{...e,children:l});class gB extends r0{constructor(l=i0.MARK_SUPERSCRIPT,s=vB){super(l,s)}}class mx0 extends c0{constructor(l){super(ux0,{button:dx0,markupElement:new gB,...l})}plugins(){return[i0.createSuperscriptPlugin({options:{hotkey:["mod+,","ctrl+,"]}})]}}const hx0="underline-plugin",be="tw-underline",CB=({attributes:e,children:l})=>t.jsx("span",{...e,className:be,children:l});class AB extends r0{constructor(l=i0.MARK_UNDERLINE,s=CB){super(l,s)}}const Lx0=({editor:e,id:l})=>t.jsx(z0,{id:l,children:t.jsx(R1,{tooltip:T0(`Underline
|
|
11
11
|
${_1("Ctrl+U")}`),nodeType:b.getPluginType(e,l),children:t.jsx(M0,{icon:t.jsx(Z7,{})})})}),wx0=[{validNodeName:["U"]},{validStyle:{textDecoration:["underline"]}}];class jB extends c0{constructor(l){super(hx0,{button:Lx0,markupElement:new AB,...l})}plugins(){return[i0.createUnderlinePlugin({deserializeHtml:{rules:[...wx0,{validNodeName:["SPAN"],validClassName:be}]},options:{hotkey:["mod+u","ctrl+u"]}})]}}const fx0=e=>!!e.match(/^(https?:\/\/|mailto:|tel:).+/),IB="text-style-plugin",xx0=12,vx0=26,gx0=124,Cx0=e=>e.map((l,s)=>({group:l,buttonGroupWidth:l.reduce((o,r)=>r.id===IB?gx0:vx0+o,xx0),index:s})),Ax0=(e,l)=>l.reduce((s,{group:o,buttonGroupWidth:r,index:c})=>{const i=Math.max(0,s.length-1);return s[i]=s[i]??[],(s[i]??[{actions:[],buttonGroupWidth:0}]).reduce((u,{buttonGroupWidth:m})=>u+m,0)+r<=e?s[i].push({group:o,buttonGroupWidth:r,index:c}):s.push([{group:o,buttonGroupWidth:r,index:c}]),s.filter(u=>u.length)},[]),jx0=({index:e,children:l})=>t.jsx("div",{"data-test-id":`toolbar-group-${e}`,className:"tw-flex tw-items-center tw-h-9 tw-p-2",children:l}),pB=({toolbarButtons:e,editorId:l,toolbarWidth:s})=>{const o=b.useEditorRef(l),{editorWidth:r}=ZF(),{position:c}=e2(),i=s||r||0,d=Cx0(e.at(c)),u=Ax0(i,d),m=I7[c];return t.jsx(m.ToolbarWrapper,{editorWidth:r,toolbarWidth:s,toolbarButtonGroups:u,children:u.map((h,L)=>t.jsx("div",{className:"tw-divide-x tw-divide-line tw-flex tw-w-full",children:h.map(({group:w,index:v})=>t.jsx(jx0,{index:v,children:w.map((f,g)=>t.jsx(f.button,{editor:o,editorId:l,id:f.id},g.toString()))},v))},L))})},NB="[data-floating-modal]",E7=({children:e,minWidth:l,padding:s,"data-test-id":o="floating-modal"})=>t.jsx("div",{"data-test-id":o,className:"tw-bg-white tw-rounded tw-shadow tw-overflow-y-auto",style:{minWidth:l,padding:s},"data-floating-modal":!0,children:e}),w2="link-plugin",MB=(e,l)=>{const s=q.getAboveNode(e,{match:{type:a0.ELEMENT_LINK}});return Array.isArray(s)?l(s[0]):""},Ix0=e=>MB(e,l=>{var s,o;return((o=(s=l.chosenLink)==null?void 0:s.searchResult)==null?void 0:o.link)||""}),px0=e=>MB(e,l=>l.url||""),Nx0=e=>{var l,s;return e.url||((s=(l=e.chosenLink)==null?void 0:l.searchResult)==null?void 0:s.link)||""},Mx0=({editButtonProps:e,unlinkButtonProps:l})=>{const{element:s}=a0.useLinkOpenButtonState(),{styles:o}=e2(),r=s?Nx0(s):"";return t.jsx(E7,{"data-test-id":"floating-link-edit",padding:"16px",minWidth:"400px",children:t.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between",children:[t.jsx("span",{style:o[w2],className:"tw-pointer-events-none",children:r}),t.jsxs("span",{className:"tw-flex tw-gap-2",children:[t.jsx("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",...e,children:t.jsx(R7,{})}),t.jsx("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",...l,children:t.jsx(k3,{})})]})]})})},zx0=({state:e,onTextChange:l,onUrlChange:s,onToggleTab:o,onCancel:r,onSave:c,isValidUrlOrEmpty:i,hasValues:d,testId:u,children:m})=>t.jsxs(E7,{"data-test-id":u,minWidth:"400px",padding:"28px",children:[t.jsx(z5,{label:{children:"Text",htmlFor:"linkText",required:!0},children:t.jsx(P1,{id:"linkText",value:e.text,placeholder:"Link Text",onChange:l})}),m,t.jsxs("div",{className:"tw-pt-5",children:[t.jsx(z5,{label:{children:"URL",htmlFor:"url",required:!0},children:t.jsx(P1,{id:"url",value:e.url,placeholder:"https://example.com",focusOnMount:!0,onChange:s})}),!i()&&t.jsx("div",{className:"tw-text-red-65 tw-mt-3",children:"Please enter a valid URL."})]}),t.jsx("div",{className:"tw-pt-5",children:t.jsx(y1,{value:"new-tab",label:"Open in new tab",state:e.newTab,onChange:o})}),t.jsx("div",{className:"tw-mt-3",children:t.jsxs("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10",children:[t.jsx(y0,{onClick:r,size:m0.Medium,style:t0.Default,emphasis:x0.Default,children:"Cancel"}),t.jsx(y0,{onClick:c,size:m0.Medium,icon:t.jsx(Ot,{}),disabled:!i()||!d,children:"Save"})]})})]}),Sx0={url:"",text:"",newTab:A0.Unchecked},yx0=()=>{const[e,l]=n.useReducer((s,o)=>{const{type:r,payload:c}=o;switch(r){case"NEW_TAB":return{...s,newTab:A0.Checked};case"SAME_TAB":return{...s,newTab:A0.Unchecked};case"URL":case"TEXT":case"INIT":return{...s,...c};default:return s}},Sx0);return[e,l]},Rx0=()=>{const e=b.useEditorRef(),[l,s]=yx0();n.useEffect(()=>{const h=Ix0(e),L=px0(e),w=a0.floatingLinkSelectors.newTab();s({type:"INIT",payload:{text:a0.floatingLinkSelectors.text(),newTab:w?A0.Checked:A0.Unchecked,url:h&&L===""?h:a0.floatingLinkSelectors.url()}})},[s,e]);const o=h=>{s({type:"TEXT",payload:{text:h}})},r=h=>{s({type:"URL",payload:{url:h}})},c=h=>{s(h?{type:"NEW_TAB"}:{type:"SAME_TAB"})},i=()=>{a0.floatingLinkActions.reset()},d=h=>{!m()||!u||(a0.floatingLinkActions.text(l.text),a0.floatingLinkActions.url(l.url),a0.floatingLinkActions.newTab(l.newTab===A0.Checked),a0.submitFloatingLink(e)&&(h==null||h.preventDefault()))},u=l.url!==""&&l.text!=="",m=()=>{const{isUrl:h}=b.getPluginOptions(e,a0.ELEMENT_LINK);return!l.url||h&&h(l.url)};return b.useHotkeys("enter",d,{enableOnFormTags:["INPUT"]},[]),{state:l,onTextChange:o,onUrlChange:r,onToggleTab:c,onCancel:i,onSave:d,hasValues:u,isValidUrlOrEmpty:m}},bx0=()=>t.jsx(zx0,{...Rx0(),testId:"floating-link-insert"}),P6={placement:"bottom-start",strategy:"absolute",middleware:[O0.offset(12),O0.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},kx0=()=>{const e=a0.useFloatingLinkInsertState({floatingOptions:P6}),{props:l,ref:s,hidden:o}=a0.useFloatingLinkInsert(e),r=a0.useFloatingLinkEditState({floatingOptions:P6}),{props:c,ref:i,editButtonProps:d,unlinkButtonProps:u}=a0.useFloatingLinkEdit(r);if(o)return null;const m=t.jsx(bx0,{}),h=r.isEditing?m:t.jsx(Mx0,{editButtonProps:d,unlinkButtonProps:u});return t.jsxs(t.Fragment,{children:[e.isOpen&&!r.isOpen&&t.jsx("div",{ref:s,...l,style:{...l.style,zIndex:q1.floatingModal},children:m}),r.isOpen&&t.jsx("div",{ref:i,...c,style:{...c.style,zIndex:q1.floatingModal},children:h})]})},zB=n.forwardRef((e,l)=>{const s=b.useEditorRef(),o=a0.useLinkToolbarButtonState(),{props:r}=a0.useLinkToolbarButton(o);return t.jsx(s1,{onMouseDown:()=>{v2.focusEditor(s,s.selection??s.prevSelection??void 0)},ref:l,...r,...e,children:t.jsx(M0,{icon:t.jsx(_3,{})})})});zB.displayName="LinkToolbarButton";const Hx0=({id:e,editorId:l})=>{const s=b.useEditorState(b.useEventPlateId(l)),o=!!L1.isRangeInSameBlock(s,{at:s.selection});return t.jsx(z0,{id:e,children:t.jsx(zB,{disabled:!o,tooltip:T0(o?`Link
|
|
12
12
|
${_1("Ctrl+K")}`:"Links can only be set for a single text block.")})})},Vx0=e=>{var i,d;const{attributes:l,children:s}=e,{styles:o}=e2(),r=e.element.url||((d=(i=e.element.chosenLink)==null?void 0:i.searchResult)==null?void 0:d.link)||"",c=e.element.target||"_self";return t.jsx("a",{...l,href:r,target:c,style:o[w2],children:s})};class Tx0 extends r0{constructor(l=a0.ELEMENT_LINK,s=Vx0){super(l,s)}}const Fx0=b.createPluginFactory({...a0.createLinkPlugin(),renderAfterEditable:kx0,options:{isUrl:fx0,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"meta+k, ctrl+k",keepSelectedTextOnPaste:!0}});class SB extends c0{constructor({styles:s=D0[w2],...o}={}){super(w2,{button:Hx0,markupElement:new Tx0,...o});e0(this,"styles",{});this.styles=s}plugins(){return[Fx0()]}}const Y7="tw-border-b tw-border-dashed tw-border-line-x-strong tw-pb-5",yB=`${Y7} tw-break-after-column tw-break-inside-avoid-column`,K0=e=>{const l=e.breakAfterColumn;return x([l==="active"&&yB,l==="inactive"&&Y7])},K7="tw-w-auto tw-min-w-[10px]",$7=e=>x([K0(e),e.align?U7[e.align]:"tw-justify-start","tw-grid tw-grid-cols-[min-content_repeat(3,_auto)]"]),RB=({attributes:e,children:l,element:s})=>t.jsx("p",{className:$7(s),...e,children:t.jsx("span",{className:K7,children:l})});class bB extends r0{constructor(l=J.ELEMENT_LIC,s=RB){super(l,s)}}const ke="list-plugin",Bx0=(e,{options:{validLiChildrenTypes:l,isSoftBreak:s}})=>{const{insertBreak:o,deleteBackward:r,deleteForward:c,deleteFragment:i}=e;return s?e.insertSoftBreak=()=>{J.insertBreakList(e)||o()}:e.insertBreak=()=>{J.insertBreakList(e)||o()},e.deleteBackward=d=>{J.deleteBackwardList(e,d)||r(d)},e.deleteForward=d=>{J.deleteForwardList(e,()=>{},d)||c(d)},e.deleteFragment=d=>{J.deleteFragmentList(e)||i(d)},e.insertFragment=J.insertFragmentList(e),e.normalizeNode=J.normalizeList(e,{validLiChildrenTypes:l}),e},O2="textStyle",kB=b.createPluginFactory({key:O2,isLeaf:!0});class X7 extends c0{constructor(s){super(ke,{leafMarkupElements:[new bB,new UB],...s});e0(this,"isSoftBreak");this.isSoftBreak=(s==null?void 0:s.isSoftBreak)??!1}plugins(){return[J.createListPlugin({withOverrides:Bx0,options:{isSoftBreak:this.isSoftBreak}}),kB()]}}const Px0=e=>q.getAboveNode(e,{match:{type:J.ELEMENT_LI},mode:"lowest"})||q.someNode(e,{match:{type:o1},mode:"lowest"}),Dx0=({editor:e,type:l,children:s})=>{const o=e!=null&&e.selection?L1.getMark(e,O2)===l.id:q.someNode(e,{match:{type:l}});return t.jsx("button",{"data-test-id":"textstyle-option",type:"button",className:x(["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]",o?"tw-text-box-neutral-inverse tw-bg-box-neutral":"tw-text-text"]),onMouseDown:r=>{r.preventDefault(),r.stopPropagation(),!(!e||!e.selection)&&(L1.setMarks(e,{[O2]:l.id}),Px0(e)||b.toggleNodeType(e,{activeType:l.id,inactiveType:l.id}))},children:s})},Ox0=({label:e,open:l,onClick:s},o)=>t.jsx("button",{ref:o,"data-test-id":"textstyle-dropdown-trigger",type:"button",className:"tw-cursor-pointer tw-h-8 tw-w-full",onClick:r=>{r.preventDefault(),r.stopPropagation(),s()},children:t.jsxs("div",{className:x(["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"]),children:[t.jsx("span",{className:"tw-text-xs tw-truncate",children:e}),t.jsx("div",{className:x(["tw-transition-transform",l&&"tw-rotate-180"]),children:t.jsx(Vt,{})})]})}),Zx0=n.forwardRef(Ox0),Ux0=e=>Array.isArray(e.children)?(e.children.find(s=>q.isText(s))??{})[O2]:z1.ELEMENT_PARAGRAPH,qx0=[J.ELEMENT_LI,J.ELEMENT_UL,J.ELEMENT_OL],Gx0=e=>!e||!e.selection?[]:Array.from(q.getNodeEntries(e,{unhang:!0,at:e.selection,reverse:!0})).reduce((s,[o])=>{if(!q.isNode(o))return s;const r=o.type===J.ELEMENT_LIC||o.type===o1?Ux0(o):o.textStyle;return r&&!s.includes(r)&&!qx0.includes(r)&&s.push(r),s},[]),Wx0=6,Qx0=10,Ex0={name:"vertical-positioning",phase:"read",fn:({state:e,name:l})=>{if(e.modifiersData[l]._skip)return;const{position:s,maxHeight:o}=P3(e.elements.reference,e.rects.popper.height,Wx0+Qx0,0);s==="top"&&(e.placement="top-start"),e.styles.popper={maxHeight:`${o}px`},e.reset=!0,e.modifiersData[l]._skip=!0},enabled:!0},Z5="Mixed";var U=(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.p="p",e))(U||{});const Yx0=e=>{const[l,s]=n.useState(!1),[o,r]=n.useState(null),[c,i]=n.useState(null),d=b.useEditorState(e),u=Gx0(d);let m=Z5;u.length===1?m=u[0]:u.length===0&&(m="p");const h=n.useCallback(()=>{s(w=>!w)},[s]),L=x2.usePopper(o,c,{placement:"bottom-start",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,6]}},{name:"flip",enabled:!1},Ex0]});return n.useEffect(()=>{const w=v=>{if(l){const f=v.target;if(c&&c.contains(f)||o&&o.contains(f))return;s(!1)}};return document.addEventListener("pointerdown",w),()=>{document.removeEventListener("pointerdown",w)}},[l,c,s,o]),{state:{isOpen:l,toggle:h,editor:d},dropdownProps:{...L.attributes.popper,style:L.styles.popper},key:m,dropdownRef:i,triggerRef:r}},Kx0=({editorId:e,textStyles:l=[]})=>{var L;const{state:{editor:s,toggle:o,isOpen:r},dropdownProps:c,triggerRef:i,dropdownRef:d,key:u}=Yx0(e);let m=Z5;const h=l.find(w=>{var v;return w.id===u&&((v=w.props)==null?void 0:v.label)});return h&&(m=((L=h.props)==null?void 0:L.label)||Z5),t.jsxs(t.Fragment,{children:[t.jsx(Zx0,{label:m,open:r,onClick:o,ref:i}),r&&t.jsx("div",{style:{zIndex:q1.textStyleDropdown},className:"tw-divide-y tw-divide-line tw-bg-base tw-shadow-md tw-border tw-border-line tw-overflow-auto tw-min-h-[40px]",ref:d,...c,children:l.map(w=>{var v;return t.jsx(Dx0,{editor:s,type:w,children:t.jsx("span",{style:w.styles??{},children:(v=w.props)==null?void 0:v.label})},w.id)})})]})},$x0=({editorId:e,id:l,textStyles:s})=>t.jsx(z0,{id:l,children:t.jsx(Kx0,{editorId:e,textStyles:s})}),Xx0=(e,l)=>s=>t.jsx(e,{...s,textStyles:l}),Jx0="textstyle-custom1-plugin";class _x0 extends c0{constructor({styles:s=D0.custom1,...o}={}){super(U.custom1,{label:"Custom 1",markupElement:new ev0,...o});e0(this,"styles",{});this.styles=s}plugins(){return[tv0(this.styles)]}}class ev0 extends r0{constructor(l=Jx0,s=HB){super(l,s)}}const HB=({element:e,attributes:l,children:s,styles:o})=>{const r=e.align;return t.jsx("p",{...l,className:x([r&&Y0[r],K0(e)]),style:o,children:s})},tv0=e=>b.createPluginFactory({key:U.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:U.custom1}]}})({component:l=>t.jsx(HB,{...l,styles:e})}),lv0="textstyle-custom2-plugin";class nv0 extends c0{constructor({styles:s=D0.custom2,...o}={}){super(U.custom2,{label:"Custom 2",markupElement:new av0,...o});e0(this,"styles",{});this.styles=s}plugins(){return[sv0(this.styles)]}}class av0 extends r0{constructor(l=lv0,s=VB){super(l,s)}}const VB=({element:e,attributes:l,children:s,styles:o})=>{const r=e.align;return t.jsx("p",{...l,className:x([r&&Y0[r],K0(e)]),style:o,children:s})},sv0=e=>b.createPluginFactory({key:U.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:U.custom2}]}})({component:l=>t.jsx(VB,{...l,styles:e})}),ov0="textstyle-custom3-plugin";class rv0 extends c0{constructor({styles:s=D0.custom3,...o}={}){super(U.custom3,{label:"Custom 3",markupElement:new cv0,...o});e0(this,"styles",{});this.styles=s}plugins(){return[iv0(this.styles)]}}class cv0 extends r0{constructor(l=ov0,s=TB){super(l,s)}}const TB=({element:e,attributes:l,children:s,styles:o})=>{const r=e.align;return t.jsx("p",{...l,className:x([r&&Y0[r],K0(e)]),style:o,children:s})},iv0=e=>b.createPluginFactory({key:U.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:U.custom3}]}})({component:l=>t.jsx(TB,{...l,styles:e})}),dv0="textstyle-heading1-plugin";class uv0 extends c0{constructor({styles:s=D0.heading1,...o}={}){super(U.heading1,{label:"Heading 1",markupElement:new mv0,...o});e0(this,"styles",{});this.styles=s}plugins(){return[hv0(this.styles)]}}class mv0 extends r0{constructor(l=dv0,s=Lt){super(l,s)}}const Lt=({element:e,attributes:l,children:s,styles:o})=>{const r=e.align;return t.jsx("h1",{...l,className:x([r&&Y0[r],K0(e)]),style:o,children:s})},hv0=e=>b.createPluginFactory({key:U.heading1,isElement:!0,component:Lt,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:l=>t.jsx(Lt,{...l,styles:e})}),Lv0="textstyle-heading2-plugin";class wv0 extends c0{constructor({styles:s=D0.heading2,...o}={}){super(U.heading2,{label:"Heading 2",markupElement:new fv0,...o});e0(this,"styles",{});this.styles=s}plugins(){return[xv0(this.styles)]}}class fv0 extends r0{constructor(l=Lv0,s=wt){super(l,s)}}const wt=({element:e,attributes:l,children:s,styles:o})=>{const r=e.align;return t.jsx("h2",{...l,className:x([r&&Y0[r],K0(e)]),style:o,children:s})},xv0=e=>b.createPluginFactory({key:U.heading2,isElement:!0,component:wt,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:l=>t.jsx(wt,{...l,styles:e})}),vv0="textstyle-heading3-plugin";class gv0 extends c0{constructor({styles:s=D0.heading3,...o}={}){super(U.heading3,{label:"Heading 3",markupElement:new Cv0,...o});e0(this,"styles",{});this.styles=s}plugins(){return[Av0(this.styles)]}}class Cv0 extends r0{constructor(l=vv0,s=ft){super(l,s)}}const ft=({element:e,attributes:l,children:s,styles:o})=>{const r=e.align;return t.jsx("h3",{...l,className:x([r&&Y0[r],K0(e)]),style:o,children:s})},Av0=e=>b.createPluginFactory({key:U.heading3,isElement:!0,component:ft,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:l=>t.jsx(ft,{...l,styles:e})}),jv0="textstyle-heading4-plugin";class Iv0 extends c0{constructor({styles:s=D0.heading4,...o}={}){super(U.heading4,{label:"Heading 4",markupElement:new pv0,...o});e0(this,"styles",{});this.styles=s}plugins(){return[Nv0(this.styles)]}}class pv0 extends r0{constructor(l=jv0,s=xt){super(l,s)}}const xt=({element:e,attributes:l,children:s,styles:o})=>{const r=e.align;return t.jsx("h4",{...l,className:x([r&&Y0[r],K0(e)]),style:o,children:s})},Nv0=e=>b.createPluginFactory({key:U.heading4,isElement:!0,component:xt,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:l=>t.jsx(xt,{...l,styles:e})}),Mv0="textstyle-imageCaption-plugin";class zv0 extends c0{constructor({styles:s=D0.imageCaption,...o}={}){super(U.imageCaption,{label:"Image Caption",markupElement:new Sv0,...o});e0(this,"styles",{});this.styles=s}plugins(){return[yv0(this.styles)]}}class Sv0 extends r0{constructor(l=Mv0,s=vt){super(l,s)}}const vt=({element:e,attributes:l,children:s,styles:o})=>{const r=e.align;return t.jsx("p",{...l,className:x([r&&Y0[r],K0(e)]),style:o,children:s})},yv0=e=>b.createPluginFactory({key:U.imageCaption,isElement:!0,component:vt,deserializeHtml:{rules:[{validClassName:U.imageCaption}]}})({component:l=>t.jsx(vt,{...l,styles:e})}),Rv0="textstyle-imageTitle-plugin";class bv0 extends c0{constructor({styles:s=D0.imageTitle,...o}={}){super(U.imageTitle,{label:"Image Title",markupElement:new kv0,...o});e0(this,"styles",{});this.styles=s}plugins(){return[Hv0(this.styles)]}}class kv0 extends r0{constructor(l=Rv0,s=gt){super(l,s)}}const gt=({element:e,attributes:l,children:s,styles:o})=>{const r=e.align;return t.jsx("p",{...l,className:x([r&&Y0[r],K0(e)]),style:o,children:s})},Hv0=e=>b.createPluginFactory({key:U.imageTitle,isElement:!0,component:gt,deserializeHtml:{rules:[{validClassName:U.imageTitle}]}})({component:l=>t.jsx(gt,{...l,styles:e})});class FB extends c0{constructor({styles:s=D0.p,...o}={}){super(U.p,{markupElement:new PB,label:"Body Text",...o});e0(this,"styles",{});this.styles=s}plugins(){return[Vv0(this.styles)]}}const BB="tw-m-0 tw-px-0 tw-py-0",U5=({element:e,attributes:l,children:s,styles:o})=>{const r=e.align,c=x([r&&Y0[r],BB,K0(e)]);return t.jsx("p",{...l,className:c,style:o,children:s})};class PB extends r0{constructor(l=U.p,s=U5){super(l,s)}}const Vv0=e=>b.createPluginFactory({...z1.createParagraphPlugin(),key:U.p,isElement:!0,component:U5})({component:l=>t.jsx(U5,{...l,styles:e})}),Tv0="textstyle-quote-plugin";class Fv0 extends c0{constructor({styles:s=D0.quote,...o}={}){super(U.quote,{label:"Quote",markupElement:new Bv0,...o});e0(this,"styles",{});this.styles=s}plugins(){return[DB(this.styles)]}}class Bv0 extends r0{constructor(l=Tv0,s=q5){super(l,s)}}const q5=({element:e,attributes:l,children:s,styles:o})=>{const r=e.align;return t.jsx("blockquote",{...l,className:x([r&&Y0[r],K0(e)]),style:o,children:s})},DB=e=>b.createPluginFactory({key:U.quote,isElement:!0,component:q5,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:l=>t.jsx(q5,{...l,styles:e})});class OB extends c0{constructor({...s}){super(IB,{button:Xx0($x0,s.textStyles),...s});e0(this,"textStyles");this.textStyles=s.textStyles}plugins(){return this.textStyles.map(s=>s.plugins()).flat()}}const J7="[&>p]:before:tw-flex [&>p]:before:tw-justify-end [&>p]:before:tw-w-[1.2em] !tw-no-underline !tw-list-item",ZB=({attributes:e,children:l,element:s})=>{const{styles:o}=e2();return t.jsx("li",{style:_7(s,o),...e,className:J7,children:l})};class UB extends r0{constructor(l=J.ELEMENT_LI,s=ZB){super(l,s)}}const _7=(e,l)=>({...l[qB(e)??U.p],counterIncrement:"count"}),qB=e=>{let l;if(e.type==="a")l=e.children[0].textStyle;else if(e.children)for(const s of e.children){const o=qB(s);o&&(!l||o.startsWith(l))&&(l=o)}else l=e.textStyle;return l},Pv0=["[&>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)_'._']"],Dv0=(e,l)=>{const s=v2.findNodePath(e,l);if(!s)return 0;const o=q.getNodeAncestors(e,s);return Array.from(o).filter(r=>r[0].type===J.ELEMENT_LI).length},e4=e=>`tw-list-none tw-pl-[10px] tw-mb-[10px] tw-ml-[15px] [&>li>p]:before:tw-pr-1 [&>li>p]:before:tw-tabular-nums ${Pv0[e%3]}`,t4={counterReset:"count"},GB=({attributes:e,children:l,element:s})=>{const o=b.useEditorRef(),r=Dv0(o,s);return t.jsx("ol",{className:e4(r),...e,style:t4,children:l})};class WB extends r0{constructor(l=J.ELEMENT_OL,s=GB){super(l,s)}}const l4=n.forwardRef(({nodeType:e=J.ELEMENT_UL,tooltip:l,...s},o)=>{const r=J.useListToolbarButtonState({nodeType:e}),{props:c}=J.useListToolbarButton(r);return t.jsx(s1,{tooltip:l,ref:o,...c,...s})});l4.displayName="ListToolbarButton";const QB=({editor:e,id:l})=>t.jsx(z0,{id:l,children:t.jsx(l4,{tooltip:T0("Ordered list"),nodeType:b.getPluginType(e,l),children:t.jsx(M0,{icon:t.jsx(y7,{})})})});class EB extends X7{constructor(l){super({id:ke,button:QB,markupElement:new WB,...l})}}const n4="[&>li>p]:before:tw-content-['•'] [&>li>p]:before:tw-px-2 tw-list-none tw-pl-[10px] tw-mb-[10px] tw-ml-[15px]",YB=({attributes:e,children:l})=>t.jsx("ul",{className:n4,...e,children:l});class KB extends r0{constructor(l=J.ELEMENT_UL,s=YB){super(l,s)}}const $B=({editor:e,id:l})=>t.jsx(z0,{id:l,children:t.jsx(l4,{tooltip:T0("Bullet list"),nodeType:b.getPluginType(e,l),children:t.jsx(M0,{icon:t.jsx(z7,{})})})});class XB extends X7{constructor(l){super({id:ke,button:$B,markupElement:new KB,...l})}}class Ov0{constructor(){e0(this,"toolbarButtons",{[g0.BOTTOM]:[],[g0.FLOATING]:[],[g0.TOP]:[]})}createGroupOfButtons(l){const s=[],o=[],r=[];for(const{markupElement:c,button:i,id:d,showIn:u}of l){if(!i)continue;const m={id:(c==null?void 0:c.getId())||d,button:i};u.includes(g0.BOTTOM)&&s.push(m),u.includes(g0.TOP)&&o.push(m),u.includes(g0.FLOATING)&&r.push(m)}s.length>0&&this.toolbarButtons[g0.BOTTOM].push(s),o.length>0&&this.toolbarButtons[g0.TOP].push(o),r.length>0&&this.toolbarButtons[g0.FLOATING].push(r)}at(l){return this.toolbarButtons[l]}}class JB{constructor(l){e0(this,"platePlugins",new Map);e0(this,"markupElements",{});e0(this,"inlineElements",[]);e0(this,"toolbarButtons",new Ov0);e0(this,"styles",{});this.props=l}setPlugin(...l){for(const s of l){const o=Array.isArray(s)?s:[s];for(const r of o)this.addElement(r.markupElement),this.addElement(r.markupInputElement),this.addLeafElements(r.leafMarkupElements),this.addPlugin(r),this.addInline(r.inline()),r.styles&&this.addStyles(r.styles,r.id),r.textStyles&&this.addTextStylesOfSubPlugins(r.textStyles);this.hasToolbar&&this.toolbarButtons.createGroupOfButtons(o)}return this}addTextStylesOfSubPlugins(l){for(const s of l)s.styles&&this.addStyles(s.styles,s.id)}addLeafElements(l){if(l===void 0)return;const s=Array.isArray(l)?l:[l];for(const o of s)this.addElement(o)}addElement(l){if(l===void 0)return;const s=l.getId(),o=l.getNode();o&&!this.markupElements[s]&&(this.markupElements[s]=o)}addPlugin(l){l.id&&!this.platePlugins.has(l.id)&&this.platePlugins.set(l.id,l.plugins())}addInline(l){l&&this.inlineElements.push(l)}addStyles(l,s){this.styles[s]=l}get elements(){return{...this.defaultElementsFromPlugins,...this.markupElements}}get defaultElementsFromPlugins(){const l={};for(const s of this.platePlugins.values())for(const o of s){const{key:r,component:c}=o;c&&(l[r]=c)}return l}get plugins(){const l=[];for(const s of this.platePlugins.values())l.push(...s);return l}get buttons(){return this.toolbarButtons}get inline(){return this.inlineElements}get hasToolbar(){var l;return!((l=this.props)!=null&&l.noToolbar)}get getStyles(){return this.styles}}const _B="reset-formatting-plugin",eP="reset-formatting",Zv0=e=>{!e||!e.selection||(L1.removeMark(e,{key:[i0.MARK_BOLD,i0.MARK_ITALIC,i0.MARK_CODE,i0.MARK_UNDERLINE,i0.MARK_STRIKETHROUGH]}),J.unwrapList(e,{}),q.setElements(e,{type:z1.ELEMENT_PARAGRAPH,align:void 0}))},Uv0=({id:e,...l})=>{const s=b.useEditorState(b.useEventPlateId(e));return t.jsx(s1,{tooltip:T0("Clear formatting"),onPointerDown:o=>{o.preventDefault(),Zv0(s)},...l,children:t.jsx(M0,{icon:t.jsx(N7,{})})})},qv0=({id:e})=>t.jsx(z0,{id:e,children:t.jsx(Uv0,{id:e})}),tP=b.createPluginFactory({key:eP,isElement:!1});class lP extends c0{constructor(l){super(_B,{button:qv0,...l})}plugins(){return[tP()]}}const Gv0="autoformat-plugin";class Wv0 extends c0{constructor(l){super(Gv0,{...l})}plugins(){return[c1.createAutoformatPlugin({options:{rules:[...c1.autoformatPunctuation,...c1.autoformatArrow,...c1.autoformatLegal,...c1.autoformatSubscriptNumbers,...c1.autoformatSubscriptSymbols,...c1.autoformatSuperscriptNumbers,...c1.autoformatSuperscriptSymbols,...c1.autoformatFraction,{mode:"mark",type:[i0.MARK_UNDERLINE],match:["_","_"],ignoreTrim:!0},{mode:"mark",type:[i0.MARK_BOLD],match:["**","**"],ignoreTrim:!0},{mode:"mark",type:[i0.MARK_ITALIC],match:["*","*"],ignoreTrim:!0},{mode:"mark",type:[i0.MARK_STRIKETHROUGH],match:["~~","~~"],ignoreTrim:!0},{mode:"mark",type:[i0.MARK_CODE],match:["`","`"],ignoreTrim:!0},{mode:"block",match:["# "],type:U.heading1},{mode:"block",match:["## "],type:U.heading2},{mode:"block",match:["### "],type:U.heading3},{mode:"block",match:["#### "],type:U.heading4},{mode:"block",type:J.ELEMENT_UL,match:["- "],preFormat:J.unwrapList,format:l=>J.toggleList(l,{type:J.ELEMENT_UL})},{mode:"block",type:J.ELEMENT_OL,match:["1. ","1) "],preFormat:J.unwrapList,format:l=>J.toggleList(l,{type:J.ELEMENT_OL})},{mode:"block",type:o1,match:["[] "]}]}})]}}const nP=e=>Array.from(q.getNodeEntries(e,{at:[],match:l=>!!l.breakAfterColumn})).length,Z2=(e,{key:l=I2,value:s,at:o})=>{const r=c=>q.isBlock(e,c);s?q.setElements(e,{[l]:s},{mode:"lowest",match:r,at:o}):q.unsetNodes(e,l,{match:r,mode:"lowest",at:o})},Qv0=(e,l,s)=>{Z2(e,{at:l,value:s})},Ct=(e,l)=>{const s=Array.from(q.getNodeEntries(e,{at:[],match:o=>!!o.breakAfterColumn}));for(const[o,[,r]]of s.entries())Qv0(e,r,o<l-1?"active":"inactive")},aP=(e,l,s)=>{if(s.preventDefault(),s.stopPropagation(),!!(e!=null&&e.selection)&&q.someNode(e,{match:r=>!!r.breakAfterColumn}))Z2(e,{value:void 0});else{const r=nP(e),c=Math.max(l-r-1,0);if(c===0)return;const i=Array.from(q.getNodeEntries(e,{at:e.selection,match:d=>q.isBlock(e,d),mode:"lowest"})).slice(-c);for(const d of i)Z2(e,{value:"active",at:d[1]})}Ct(e,l)},Ev0=(e,{options:{hotkey:l}})=>s=>{var o;if(!s.defaultPrevented&&l&&b.isHotkey(l,s)){const r=e.plugins.find(i=>i.key===I2),c=((o=r==null?void 0:r.options)==null?void 0:o.columns)??1;aP(e,c,s)}},Yv0=({id:e,...l})=>{var d,u;const s=b.useEditorState(b.useEventPlateId(e)),o=!!(s!=null&&s.selection)&&q.someNode(s,{match:m=>!!m.breakAfterColumn}),r=(u=(d=s==null?void 0:s.pluginsByKey.breakAfterColumn)==null?void 0:d.options)==null?void 0:u.columns,c=Number(r)||1,i=Kv0(s,c,o);return t.jsx(s1,{disabled:!i,pressed:!o,tooltip:T0(i?`Column Break
|
|
13
|
-
Shift+Ctrl+Return`:"Already at maximum numbers of columns"),onPointerDown:m=>m.preventDefault(),onClick:m=>{aP(s,c,m)},...l,children:t.jsx(M0,{icon:t.jsx(ze,{})})})},Kv0=(e,l,s)=>nP(e)+1<l||s,sP=({id:e})=>t.jsx(z0,{id:e,children:t.jsx(Yv0,{children:t.jsx(M0,{icon:t.jsx(ze,{})})})}),$v0=(e,l)=>{const s=q.getStartPoint(e,l);setTimeout(()=>{q.select(e,{anchor:s,focus:s})})},Xv0=e=>{var s;const l=e.plugins.find(o=>o.key===I2);return((s=l==null?void 0:l.options)==null?void 0:s.columns)??1},Jv0=e=>{const{apply:l}=e,s=Xv0(e);e.apply=o=>{switch(o.type){case"split_node":o.properties={...o.properties,breakAfterColumn:void 0};break;case"merge_node":const r=q.getPointBefore(e,o.path);if(!r)break;const c=q.getParentNode(e,r.path);if(Z2(e,{at:r,value:void 0}),Ct(e,s),c!=null&&c[0].breakAfterColumn)return $v0(e,o.path),e;break}l(o)},setTimeout(()=>Ct(e,s))},I2="breakAfterColumn",a4="normal";class _v0 extends c0{constructor(s){super("break-after-plugin",{button:sP,...s});e0(this,"columns");e0(this,"gap");this.columns=(s==null?void 0:s.columns)??1,this.gap=(s==null?void 0:s.gap)??a4}plugins(){return[oP(this.columns,this.gap)]}}const oP=(e,l)=>b.createPluginFactory({key:I2,handlers:{onKeyDown:Ev0},useHooks:Jv0,options:{columns:e,gap:l,hotkey:["shift+ctrl+enter"]}})(),rP=e=>b.createPlugins(e.plugins,{components:e.elements}),s4=(e,l)=>({plugins:rP(l),toolbar:s=>l.hasToolbar?t.jsx(pB,{toolbarButtons:l.buttons,editorId:e,toolbarWidth:s}):null,inline:()=>t.jsx(t.Fragment,{children:l.inline.map((s,o)=>t.jsx(s,{},o))}),styles:()=>l.getStyles}),eg0="mention-plugin",tg0=e=>l=>l.text.toLowerCase().includes(e.toLowerCase()),o4=(e,l)=>`${e}:${l}`,r4=e=>{const l=new Map;for(const s of e){const o=o4(s.data.category,s.data.id),r=s.text;l.set(o,r)}return l},cP=(e,l,s)=>e.get(l)??s;var d1=(e=>(e.GROUP="group",e.ALL="all",e.USER="user",e))(d1||{});const c4=({attributes:e,element:l,nodeProps:s,children:o})=>t.jsx("span",{...e,dir:"auto","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)"},...s,children:o}),lg0=({children:e,...l})=>t.jsxs(c4,{...l,children:[t.jsx("span",{style:{paddingRight:"3px",display:"inline-block",margin:"-1px 0"},children:t.jsx(Me,{})}),e]}),ng0=({children:e,...l})=>t.jsxs(c4,{...l,children:["@",e]}),ag0=({children:e,...l})=>t.jsx(c4,{...l,children:e}),sg0=({category:e,children:l,...s})=>{const o={[d1.USER]:ag0,[d1.GROUP]:lg0,[d1.ALL]:ng0},r=o[e]??o[d1.USER];return t.jsx(r,{...s,children:l})},i4=e=>l=>{const{element:s,children:o}=l,r=o4(s==null?void 0:s.category,String(s==null?void 0:s.id));return t.jsxs(sg0,{category:s==null?void 0:s.category,...l,children:[cP(e,r,String(s==null?void 0:s.id)),o]})};class iP extends r0{constructor(l=B1.ELEMENT_MENTION){super(l)}setNodeWithMentionable(l){return this.node=i4(r4(l)),this}}const og0=({image:e,category:l,text:s,id:o})=>{if(e)return t.jsx("img",{src:e,alt:`${o}-${l}-${s}`});switch(l){case d1.GROUP:return t.jsx(Me,{});case d1.ALL:return t.jsx(V7,{});default:return t.jsx(b7,{})}},rg0=({item:e})=>{const{data:{image:l,category:s},key:o,text:r}=e;return t.jsxs("div",{className:"tw-flex tw-items-center tw-w-full tw-min-h-[inherit]",children:[t.jsx("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",children:t.jsx(og0,{image:l,category:s,text:r,id:o})}),t.jsx("span",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis",children:r})]})};function cg0({pluginKey:e=B1.ELEMENT_MENTION,id:l=e,...s}){const o=b.useEditorRef(),{trigger:r}=b.getPluginOptions(o,e);return t.jsx(tB,{id:l,trigger:r,controlled:!0,onSelectItem:(c,i)=>B1.getMentionOnSelectItem({key:e})(o,i),onRenderItem:rg0,...s})}const ig0=e=>()=>t.jsx(cg0,{items:e,filter:tg0}),dg0={options:{trigger:"@",insertSpaceAfterMention:!0,createMentionNode:e=>({value:e.text,category:e.data.category,id:e.data.id})}},dP=n.forwardRef(({className:e,onClick:l,...s},o)=>{const{children:r,element:c}=s;return t.jsx(_e.PlateElement,{ref:o,asChild:!0,"data-slate-value":c.value,className:x(["tw-inline-block tw-rounded-sm tw-shadow-none tw-font-bold tw-leading-[10px] tw-m-0 tw-py-0.5 tw-px-1.5 tw-text-[rgb(130,95,255)] tw-bg-[rgb(227,232,246)]",e]),onClick:St.getHandler(l,c),...s,children:t.jsx("span",{children:r})})});dP.displayName="MentionInputElement";const ug0=e=>t.jsx(dP,{...e});class mg0 extends r0{constructor(l=B1.ELEMENT_MENTION_INPUT,s=ug0){super(l,s)}}class hg0 extends c0{constructor(l){super(eg0,{markupElement:new iP().setNodeWithMentionable(l.mentionableItems),markupInputElement:new mg0,...l})}inline(){var l;return ig0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[G0.createComboboxPlugin(),B1.createMentionPlugin(dg0)]}}const Lg0="blur-on-break-plugin",wg0=(e,{options:{onBreak:l=()=>{}}})=>s=>{b.Hotkeys.isSplitBlock(s)&&(s.stopPropagation(),s.preventDefault(),rr(),typeof l=="function"&&l(e.children))},fg0="blurOnBreak",xg0=b.createPluginFactory({key:fg0,handlers:{onKeyDown:wg0}});class vg0 extends c0{constructor(s){super(Lg0,{...s});e0(this,"onBreak");this.onBreak=s==null?void 0:s.onBreak}plugins(){return[xg0({options:{onBreak:this.onBreak}})]}}const p2=new JB;p2.setPlugin(new nB).setPlugin(new OB({textStyles:[new FB]})).setPlugin([new oB,new mB,new jB,new wB,new SB,new iB],[new KF,new YF,new XF,new $F,new XB,new EF,new EB,new lP,new lB]);class U2{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=N1(),s=p2){const o=s4(l,s);return this.editor=b.createPlateEditor({id:l,plugins:o.plugins}),this}}e0(U2,"editor"),e0(U2,"editorId",N1());const gg0=e=>e[0].hasOwnProperty("type")?e:[{type:"p",children:e}],uP=[{type:z1.ELEMENT_PARAGRAPH,children:[{text:""}]}],t5=({editorId:e="parseRawValue",raw:l,plugins:s})=>{const o=U2.init(`${e}_parseRawValue`,s).getInstance();let r=uP;if(!l)return r;try{r=JSON.parse(l)}catch{const c=l.trim().replaceAll(/>\s+</g,"><"),i=b.deserializeHtml(o,{element:c});r=gg0(i)}return o.children=r,q.normalizeEditor(o,{force:!0}),o.children},Cg0=({children:e,apply:l})=>{for(const s of e)l({type:"remove_node",path:[0],node:s})},Ag0=({value:e})=>{const l=b.useEditorRef();return n.useEffect(()=>{e&&(Cg0(l),q.insertNodes(l,e))},[l,e]),null},jg0=({hideExternalFloatingModals:e})=>{const l=b.useEditorRef(),s=a0.useFloatingLinkSelectors().isOpen(l.id),[o,r]=n.useState(!1),c=n.useCallback(()=>{s&&a0.floatingLinkActions.
|
|
13
|
+
Shift+Ctrl+Return`:"Already at maximum numbers of columns"),onPointerDown:m=>m.preventDefault(),onClick:m=>{aP(s,c,m)},...l,children:t.jsx(M0,{icon:t.jsx(ze,{})})})},Kv0=(e,l,s)=>nP(e)+1<l||s,sP=({id:e})=>t.jsx(z0,{id:e,children:t.jsx(Yv0,{children:t.jsx(M0,{icon:t.jsx(ze,{})})})}),$v0=(e,l)=>{const s=q.getStartPoint(e,l);setTimeout(()=>{q.select(e,{anchor:s,focus:s})})},Xv0=e=>{var s;const l=e.plugins.find(o=>o.key===I2);return((s=l==null?void 0:l.options)==null?void 0:s.columns)??1},Jv0=e=>{const{apply:l}=e,s=Xv0(e);e.apply=o=>{switch(o.type){case"split_node":o.properties={...o.properties,breakAfterColumn:void 0};break;case"merge_node":const r=q.getPointBefore(e,o.path);if(!r)break;const c=q.getParentNode(e,r.path);if(Z2(e,{at:r,value:void 0}),Ct(e,s),c!=null&&c[0].breakAfterColumn)return $v0(e,o.path),e;break}l(o)},setTimeout(()=>Ct(e,s))},I2="breakAfterColumn",a4="normal";class _v0 extends c0{constructor(s){super("break-after-plugin",{button:sP,...s});e0(this,"columns");e0(this,"gap");this.columns=(s==null?void 0:s.columns)??1,this.gap=(s==null?void 0:s.gap)??a4}plugins(){return[oP(this.columns,this.gap)]}}const oP=(e,l)=>b.createPluginFactory({key:I2,handlers:{onKeyDown:Ev0},useHooks:Jv0,options:{columns:e,gap:l,hotkey:["shift+ctrl+enter"]}})(),rP=e=>b.createPlugins(e.plugins,{components:e.elements}),s4=(e,l)=>({plugins:rP(l),toolbar:s=>l.hasToolbar?t.jsx(pB,{toolbarButtons:l.buttons,editorId:e,toolbarWidth:s}):null,inline:()=>t.jsx(t.Fragment,{children:l.inline.map((s,o)=>t.jsx(s,{},o))}),styles:()=>l.getStyles}),eg0="mention-plugin",tg0=e=>l=>l.text.toLowerCase().includes(e.toLowerCase()),o4=(e,l)=>`${e}:${l}`,r4=e=>{const l=new Map;for(const s of e){const o=o4(s.data.category,s.data.id),r=s.text;l.set(o,r)}return l},cP=(e,l,s)=>e.get(l)??s;var d1=(e=>(e.GROUP="group",e.ALL="all",e.USER="user",e))(d1||{});const c4=({attributes:e,element:l,nodeProps:s,children:o})=>t.jsx("span",{...e,dir:"auto","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)"},...s,children:o}),lg0=({children:e,...l})=>t.jsxs(c4,{...l,children:[t.jsx("span",{style:{paddingRight:"3px",display:"inline-block",margin:"-1px 0"},children:t.jsx(Me,{})}),e]}),ng0=({children:e,...l})=>t.jsxs(c4,{...l,children:["@",e]}),ag0=({children:e,...l})=>t.jsx(c4,{...l,children:e}),sg0=({category:e,children:l,...s})=>{const o={[d1.USER]:ag0,[d1.GROUP]:lg0,[d1.ALL]:ng0},r=o[e]??o[d1.USER];return t.jsx(r,{...s,children:l})},i4=e=>l=>{const{element:s,children:o}=l,r=o4(s==null?void 0:s.category,String(s==null?void 0:s.id));return t.jsxs(sg0,{category:s==null?void 0:s.category,...l,children:[cP(e,r,String(s==null?void 0:s.id)),o]})};class iP extends r0{constructor(l=B1.ELEMENT_MENTION){super(l)}setNodeWithMentionable(l){return this.node=i4(r4(l)),this}}const og0=({image:e,category:l,text:s,id:o})=>{if(e)return t.jsx("img",{src:e,alt:`${o}-${l}-${s}`});switch(l){case d1.GROUP:return t.jsx(Me,{});case d1.ALL:return t.jsx(V7,{});default:return t.jsx(b7,{})}},rg0=({item:e})=>{const{data:{image:l,category:s},key:o,text:r}=e;return t.jsxs("div",{className:"tw-flex tw-items-center tw-w-full tw-min-h-[inherit]",children:[t.jsx("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",children:t.jsx(og0,{image:l,category:s,text:r,id:o})}),t.jsx("span",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis",children:r})]})};function cg0({pluginKey:e=B1.ELEMENT_MENTION,id:l=e,...s}){const o=b.useEditorRef(),{trigger:r}=b.getPluginOptions(o,e);return t.jsx(tB,{id:l,trigger:r,controlled:!0,onSelectItem:(c,i)=>B1.getMentionOnSelectItem({key:e})(o,i),onRenderItem:rg0,...s})}const ig0=e=>()=>t.jsx(cg0,{items:e,filter:tg0}),dg0={options:{trigger:"@",insertSpaceAfterMention:!0,createMentionNode:e=>({value:e.text,category:e.data.category,id:e.data.id})}},dP=n.forwardRef(({className:e,onClick:l,...s},o)=>{const{children:r,element:c}=s;return t.jsx(_e.PlateElement,{ref:o,asChild:!0,"data-slate-value":c.value,className:x(["tw-inline-block tw-rounded-sm tw-shadow-none tw-font-bold tw-leading-[10px] tw-m-0 tw-py-0.5 tw-px-1.5 tw-text-[rgb(130,95,255)] tw-bg-[rgb(227,232,246)]",e]),onClick:St.getHandler(l,c),...s,children:t.jsx("span",{children:r})})});dP.displayName="MentionInputElement";const ug0=e=>t.jsx(dP,{...e});class mg0 extends r0{constructor(l=B1.ELEMENT_MENTION_INPUT,s=ug0){super(l,s)}}class hg0 extends c0{constructor(l){super(eg0,{markupElement:new iP().setNodeWithMentionable(l.mentionableItems),markupInputElement:new mg0,...l})}inline(){var l;return ig0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[G0.createComboboxPlugin(),B1.createMentionPlugin(dg0)]}}const Lg0="blur-on-break-plugin",wg0=(e,{options:{onBreak:l=()=>{}}})=>s=>{b.Hotkeys.isSplitBlock(s)&&(s.stopPropagation(),s.preventDefault(),rr(),typeof l=="function"&&l(e.children))},fg0="blurOnBreak",xg0=b.createPluginFactory({key:fg0,handlers:{onKeyDown:wg0}});class vg0 extends c0{constructor(s){super(Lg0,{...s});e0(this,"onBreak");this.onBreak=s==null?void 0:s.onBreak}plugins(){return[xg0({options:{onBreak:this.onBreak}})]}}const p2=new JB;p2.setPlugin(new nB).setPlugin(new OB({textStyles:[new FB]})).setPlugin([new oB,new mB,new jB,new wB,new SB,new iB],[new KF,new YF,new XF,new $F,new XB,new EF,new EB,new lP,new lB]);class U2{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=N1(),s=p2){const o=s4(l,s);return this.editor=b.createPlateEditor({id:l,plugins:o.plugins}),this}}e0(U2,"editor"),e0(U2,"editorId",N1());const gg0=e=>e[0].hasOwnProperty("type")?e:[{type:"p",children:e}],uP=[{type:z1.ELEMENT_PARAGRAPH,children:[{text:""}]}],t5=({editorId:e="parseRawValue",raw:l,plugins:s})=>{const o=U2.init(`${e}_parseRawValue`,s).getInstance();let r=uP;if(!l)return r;try{r=JSON.parse(l)}catch{const c=l.trim().replaceAll(/>\s+</g,"><"),i=b.deserializeHtml(o,{element:c});r=gg0(i)}return o.children=r,q.normalizeEditor(o,{force:!0}),o.children},Cg0=({children:e,apply:l})=>{for(const s of e)l({type:"remove_node",path:[0],node:s})},Ag0=({value:e})=>{const l=b.useEditorRef();return n.useEffect(()=>{e&&(Cg0(l),q.insertNodes(l,e))},[l,e]),null},jg0=({hideExternalFloatingModals:e})=>{const l=b.useEditorRef(),s=a0.useFloatingLinkSelectors().isOpen(l.id),[o,r]=n.useState(!1),c=n.useCallback(()=>{s&&a0.floatingLinkActions.hide(),e&&e(l.id)},[s,e,l]),i=n.useCallback(()=>{l.collapse(),c()},[l,c]);return n.useEffect(()=>{if(!o)return;const d=u=>{const m=`[data-editor-id='${l.id}']`,h="[role='toolbar']",L="[data-is-underlay]",w=u.target,v=w.closest(L),f=w.closest(NB),g=w.closest(m),A=w.closest(h);g&&!f||A?c():!g&&!A&&!v&&(i(),r(!1))};return document.addEventListener("pointerdown",d),document.addEventListener("focusin",d),()=>{document.removeEventListener("focusin",d),document.removeEventListener("pointerdown",d)}},[i,c,l.id,o]),n.useEffect(()=>{const d=document.querySelector(`[data-editor-id='${l.id}']`);if(!d)return;const u=()=>{r(!0)};return d.addEventListener("focusin",u),()=>{d.removeEventListener("focusin",u)}},[l.id]),null},Ig0={position:"relative",height:"0"},pg0=({children:e,attributes:l})=>{const s={...l,style:{...l.style,...Ig0}};return t.jsx("span",{...s,children:e})},mP=({id:e,value:l,placeholder:s="",readonly:o=!1,onTextChange:r,onBlur:c,padding:i=A7.None,position:d=g0.FLOATING,plugins:u=p2,updateValueOnChange:m=!1,onValueChanged:h,border:L=!0,toolbarWidth:w,hideExternalFloatingModals:v})=>{var M,N;const f=p0(e),{localValue:g,onChange:A,memoizedValue:C,config:j}=xf0({editorId:f,initialValue:l,onTextChange:r,plugins:u,onValueChanged:h}),p=u.plugins.find(k=>k.key===I2),z=((M=p==null?void 0:p.options)==null?void 0:M.columns)??1,y=((N=p==null?void 0:p.options)==null?void 0:N.gap)??a4,S=n.useMemo(()=>({columns:z,columnGap:y,outline:"none"}),[z,y]),V=n.useCallback(()=>{c&&c(JSON.stringify(g.current))},[c,g]),I=n.useCallback(k=>{k.code==="Tab"&&or(k,!k.shiftKey)},[]),R={placeholder:s,renderPlaceholder:pg0,readOnly:o,onBlur:V,className:`${i}`,style:S,onKeyDown:I,scrollSelectionIntoView:a7};return t.jsx(PF,{styles:j.styles(),position:d,border:L,editorId:f,children:t.jsxs(b.Plate,{id:f,onChange:A,plugins:j.plugins,initialValue:C,children:[t.jsx(b.PlateContent,{...R}),!R.readOnly&&j.toolbar(w),j.inline(),m&&t.jsx(Ag0,{value:t5({editorId:f,raw:l,plugins:u})}),d===g0.FLOATING&&t.jsx(jg0,{hideExternalFloatingModals:v})]})})};mP.displayName="FondueRichTextEditor";const D6=e=>e.split("").reverse().join(""),a2=(e,l)=>{const s=e.trim(),o=s,r=`${l}${o}${D6(l)}`;if(o.length===e.length)return r;const c=l+o+D6(l);return e.replace(s,c)},Ng0=(e,l)=>{const s=`
|
|
14
14
|
`;return(l.strikethrough||l.bold||l.italic)&&new RegExp(s,"g").test(e)&&(e=e.replaceAll(s,`\\
|
|
15
15
|
`)),e},Mg0=(e,l)=>(l.strikethrough&&l.bold&&l.italic?e=a2(e,"~~***"):l.bold&&l.italic?e=a2(e,"***"):(l.bold&&(e=a2(e,"**")),l.italic&&(e=a2(e,"_")),l.strikethrough&&(e=a2(e,"~~")),l.code&&(e=a2(e,"`"))),e=Ng0(e,l),e),f2=e=>!("type"in e),zg0={paragraph:"paragraph",blockQuote:"block_quote",codeBlock:"code_block",link:"link",ulList:"ul_list",olList:"ol_list",listItem:"list_item",listItemChild:"lic",heading:{1:"heading_one",2:"heading_two",3:"heading_three",4:"heading_four",5:"heading_five",6:"heading_six"},emphasisMark:"italic",strongMark:"bold",deleteMark:"strikethrough",inlineCodeMark:"code",thematicBreak:"thematic_break",image:"image",mention:"mention"},G5={Blank:"_blank",Self:"_self"},hP="[\\d=a-z]+",LP=Object.values(d1).join("|"),Sg0=`@\\[(${LP}):${hP}\\]`,wP=`@\\[(${LP}):(${hP})\\]`,yg0=new RegExp(Sg0,"gi"),Rg0=new RegExp(wP,"i"),O6="<br>",bg0="link",Ke={nodeTypes:zg0,ignoreParagraphNewline:!1,listDepth:0,linkDestinationKey:bg0},fP=e=>{var l;return{...Ke,...e,nodeTypes:{...Ke.nodeTypes,...e==null?void 0:e.nodeTypes,heading:{...Ke.nodeTypes.heading,...(l=e==null?void 0:e.nodeTypes)==null?void 0:l.heading}}}},At=e=>/^(javascript:|data:text\/).+/i.test(e),kg0=e=>`@[${e.category}:${e.id}]`,Hg0=e=>`${e}
|
|
16
16
|
`,Vg0=(e,l,s,o)=>{const r=s&&s.parentType===e.olList,c=s.children.length===1&&f2(s.children[0]);let i="";for(let d=0;o>d;d++)r?i+=" ":i+=" ";return`${i}${r?"1.":"-"} ${l}${c?`
|