@frontify/fondue 12.0.0-beta.282 → 12.0.0-beta.283
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/EditorPositioningWrapper/ToolbarWrapper/ToolbarWrapperPositioningFloating.es.js +6 -6
- package/dist/components/RichTextEditor/EditorPositioningWrapper/ToolbarWrapper/ToolbarWrapperPositioningFloating.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,22 +1,22 @@
|
|
|
1
|
-
import c, { useState as w, useRef as h, useEffect as
|
|
1
|
+
import c, { useState as w, useRef as h, useEffect as s } from "react";
|
|
2
2
|
import { BalloonToolbar as p, flip as b, shift as v, autoUpdate as E } from "@udecode/plate";
|
|
3
3
|
import { calculateToolbarWidth as S } from "../../utils/calculateToolbarWidth.es.js";
|
|
4
4
|
import { OFFSET_IN_PX as F } from "../../utils/constants.es.js";
|
|
5
5
|
const x = ({
|
|
6
|
-
children:
|
|
6
|
+
children: l,
|
|
7
7
|
editorWidth: d,
|
|
8
8
|
toolbarButtonGroups: o = [],
|
|
9
9
|
toolbarWidth: a
|
|
10
10
|
}) => {
|
|
11
11
|
const [f, i] = w(), r = h();
|
|
12
|
-
|
|
12
|
+
s(() => {
|
|
13
13
|
if (a)
|
|
14
14
|
i(a);
|
|
15
15
|
else {
|
|
16
16
|
const t = S(o);
|
|
17
17
|
t > 0 && i(t + o.length + F);
|
|
18
18
|
}
|
|
19
|
-
}, [d, a, o]),
|
|
19
|
+
}, [d, a, o]), s(() => {
|
|
20
20
|
const t = () => {
|
|
21
21
|
const e = window.getSelection(), n = (e == null ? void 0 : e.rangeCount) ?? 0, m = n > 0 && (e == null ? void 0 : e.getRangeAt(0).startOffset), u = n > 0 && (e == null ? void 0 : e.getRangeAt(0).endOffset);
|
|
22
22
|
!(!!e && m !== u && n > 0) && r.current && r.current();
|
|
@@ -33,7 +33,7 @@ const x = ({
|
|
|
33
33
|
middleware: [b(), v()],
|
|
34
34
|
whileElementsMounted: g
|
|
35
35
|
},
|
|
36
|
-
styles: { root: { border: "none", background: "#ffffff", width: f } }
|
|
36
|
+
styles: { root: { border: "none", background: "#ffffff", width: f, transitionDuration: "0s" } }
|
|
37
37
|
},
|
|
38
38
|
/* @__PURE__ */ c.createElement(
|
|
39
39
|
"div",
|
|
@@ -42,7 +42,7 @@ const x = ({
|
|
|
42
42
|
"data-test-id": "toolbar-floating",
|
|
43
43
|
className: "tw-rounded tw-min-h-12 tw-border tw-border-line tw-shadow-lg tw-bg-base tw-divide-y tw-divide-line tw-flex tw-flex-wrap"
|
|
44
44
|
},
|
|
45
|
-
|
|
45
|
+
l
|
|
46
46
|
)
|
|
47
47
|
);
|
|
48
48
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarWrapperPositioningFloating.es.js","sources":["../../../../../src/components/RichTextEditor/EditorPositioningWrapper/ToolbarWrapper/ToolbarWrapperPositioningFloating.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport { BalloonToolbar, ReferenceType, autoUpdate, flip, shift } from '@udecode/plate';\nimport { OFFSET_IN_PX, calculateToolbarWidth } from '@components/RichTextEditor/utils';\nimport { ToolbarWrapperProps } from './types';\n\nexport const ToolbarWrapperPositioningFloating = ({\n children,\n editorWidth,\n toolbarButtonGroups = [],\n toolbarWidth,\n}: ToolbarWrapperProps) => {\n const [width, setWidth] = useState<number | undefined>();\n const cleanupFunction = useRef<() => void | undefined>();\n\n useEffect(() => {\n if (toolbarWidth) {\n setWidth(toolbarWidth);\n } else {\n const toolbarWidthSum = calculateToolbarWidth(toolbarButtonGroups);\n if (toolbarWidthSum > 0) {\n setWidth(toolbarWidthSum + toolbarButtonGroups.length + OFFSET_IN_PX);\n }\n }\n }, [editorWidth, toolbarWidth, toolbarButtonGroups]);\n\n useEffect(() => {\n const handleSelectionChange = () => {\n const selection = window.getSelection();\n const rangeCount = selection?.rangeCount ?? 0;\n\n const selectionFrom = rangeCount > 0 && selection?.getRangeAt(0).startOffset;\n const selectionTo = rangeCount > 0 && selection?.getRangeAt(0).endOffset;\n const hasActiveSelection = !!selection && selectionFrom !== selectionTo && rangeCount > 0;\n\n if (!hasActiveSelection && cleanupFunction.current) {\n cleanupFunction.current();\n }\n };\n\n document.addEventListener('selectionchange', handleSelectionChange);\n return () => document.removeEventListener('selectionchange', handleSelectionChange);\n }, []);\n\n const autoUpdateWithCleanup = (reference: ReferenceType, floating: HTMLElement, update: () => void) => {\n cleanupFunction.current = autoUpdate(reference, floating, update);\n };\n\n return (\n <BalloonToolbar\n floatingOptions={{\n middleware: [flip(), shift()],\n whileElementsMounted: autoUpdateWithCleanup,\n }}\n styles={{ root: { border: 'none', background: '#ffffff', width } }}\n >\n <div\n data-selector=\"toolbar-floating\"\n data-test-id=\"toolbar-floating\"\n className=\"tw-rounded tw-min-h-12 tw-border tw-border-line tw-shadow-lg tw-bg-base tw-divide-y tw-divide-line tw-flex tw-flex-wrap\"\n >\n {children}\n </div>\n </BalloonToolbar>\n );\n};\n"],"names":["ToolbarWrapperPositioningFloating","children","editorWidth","toolbarButtonGroups","toolbarWidth","width","setWidth","useState","cleanupFunction","useRef","useEffect","toolbarWidthSum","calculateToolbarWidth","OFFSET_IN_PX","handleSelectionChange","selection","rangeCount","selectionFrom","selectionTo","autoUpdateWithCleanup","reference","floating","update","autoUpdate","React","BalloonToolbar","flip","shift"],"mappings":";;;;AAOO,MAAMA,IAAoC,CAAC;AAAA,EAC9C,UAAAC;AAAA,EACA,aAAAC;AAAA,EACA,qBAAAC,IAAsB,CAAC;AAAA,EACvB,cAAAC;AACJ,MAA2B;AACvB,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAA6B,GACjDC,IAAkBC;AAExB,EAAAC,EAAU,MAAM;AACZ,QAAIN;AACA,MAAAE,EAASF,CAAY;AAAA,SAClB;AACG,YAAAO,IAAkBC,EAAsBT,CAAmB;AACjE,MAAIQ,IAAkB,KACTL,EAAAK,IAAkBR,EAAoB,SAASU,CAAY;AAAA,IAE5E;AAAA,EACD,GAAA,CAACX,GAAaE,GAAcD,CAAmB,CAAC,GAEnDO,EAAU,MAAM;AACZ,UAAMI,IAAwB,MAAM;AAC1B,YAAAC,IAAY,OAAO,gBACnBC,KAAaD,KAAA,gBAAAA,EAAW,eAAc,GAEtCE,IAAgBD,IAAa,MAAKD,KAAA,gBAAAA,EAAW,WAAW,GAAG,cAC3DG,IAAcF,IAAa,MAAKD,KAAA,gBAAAA,EAAW,WAAW,GAAG;AAG3D,MAAA,EAFuB,CAAC,CAACA,KAAaE,MAAkBC,KAAeF,IAAa,MAE7DR,EAAgB,WACvCA,EAAgB,QAAQ;AAAA,IAC5B;AAGK,oBAAA,iBAAiB,mBAAmBM,CAAqB,GAC3D,MAAM,SAAS,oBAAoB,mBAAmBA,CAAqB;AAAA,EACtF,GAAG,CAAE,CAAA;AAEL,QAAMK,IAAwB,CAACC,GAA0BC,GAAuBC,MAAuB;AACnG,IAAAd,EAAgB,UAAUe,EAAWH,GAAWC,GAAUC,CAAM;AAAA,EAAA;AAIhE,SAAA,gBAAAE,EAAA;AAAA,IAACC;AAAA,IAAA;AAAA,MACG,iBAAiB;AAAA,QACb,YAAY,CAACC,KAAQC,GAAO;AAAA,QAC5B,sBAAsBR;AAAA,MAC1B;AAAA,MACA,QAAQ,EAAE,MAAM,EAAE,QAAQ,QAAQ,YAAY,WAAW,OAAAd,
|
|
1
|
+
{"version":3,"file":"ToolbarWrapperPositioningFloating.es.js","sources":["../../../../../src/components/RichTextEditor/EditorPositioningWrapper/ToolbarWrapper/ToolbarWrapperPositioningFloating.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { useEffect, useRef, useState } from 'react';\nimport { BalloonToolbar, ReferenceType, autoUpdate, flip, shift } from '@udecode/plate';\nimport { OFFSET_IN_PX, calculateToolbarWidth } from '@components/RichTextEditor/utils';\nimport { ToolbarWrapperProps } from './types';\n\nexport const ToolbarWrapperPositioningFloating = ({\n children,\n editorWidth,\n toolbarButtonGroups = [],\n toolbarWidth,\n}: ToolbarWrapperProps) => {\n const [width, setWidth] = useState<number | undefined>();\n const cleanupFunction = useRef<() => void | undefined>();\n\n useEffect(() => {\n if (toolbarWidth) {\n setWidth(toolbarWidth);\n } else {\n const toolbarWidthSum = calculateToolbarWidth(toolbarButtonGroups);\n if (toolbarWidthSum > 0) {\n setWidth(toolbarWidthSum + toolbarButtonGroups.length + OFFSET_IN_PX);\n }\n }\n }, [editorWidth, toolbarWidth, toolbarButtonGroups]);\n\n useEffect(() => {\n const handleSelectionChange = () => {\n const selection = window.getSelection();\n const rangeCount = selection?.rangeCount ?? 0;\n\n const selectionFrom = rangeCount > 0 && selection?.getRangeAt(0).startOffset;\n const selectionTo = rangeCount > 0 && selection?.getRangeAt(0).endOffset;\n const hasActiveSelection = !!selection && selectionFrom !== selectionTo && rangeCount > 0;\n\n if (!hasActiveSelection && cleanupFunction.current) {\n cleanupFunction.current();\n }\n };\n\n document.addEventListener('selectionchange', handleSelectionChange);\n return () => document.removeEventListener('selectionchange', handleSelectionChange);\n }, []);\n\n const autoUpdateWithCleanup = (reference: ReferenceType, floating: HTMLElement, update: () => void) => {\n cleanupFunction.current = autoUpdate(reference, floating, update);\n };\n\n return (\n <BalloonToolbar\n floatingOptions={{\n middleware: [flip(), shift()],\n whileElementsMounted: autoUpdateWithCleanup,\n }}\n styles={{ root: { border: 'none', background: '#ffffff', width, transitionDuration: '0s' } }}\n >\n <div\n data-selector=\"toolbar-floating\"\n data-test-id=\"toolbar-floating\"\n className=\"tw-rounded tw-min-h-12 tw-border tw-border-line tw-shadow-lg tw-bg-base tw-divide-y tw-divide-line tw-flex tw-flex-wrap\"\n >\n {children}\n </div>\n </BalloonToolbar>\n );\n};\n"],"names":["ToolbarWrapperPositioningFloating","children","editorWidth","toolbarButtonGroups","toolbarWidth","width","setWidth","useState","cleanupFunction","useRef","useEffect","toolbarWidthSum","calculateToolbarWidth","OFFSET_IN_PX","handleSelectionChange","selection","rangeCount","selectionFrom","selectionTo","autoUpdateWithCleanup","reference","floating","update","autoUpdate","React","BalloonToolbar","flip","shift"],"mappings":";;;;AAOO,MAAMA,IAAoC,CAAC;AAAA,EAC9C,UAAAC;AAAA,EACA,aAAAC;AAAA,EACA,qBAAAC,IAAsB,CAAC;AAAA,EACvB,cAAAC;AACJ,MAA2B;AACvB,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAA6B,GACjDC,IAAkBC;AAExB,EAAAC,EAAU,MAAM;AACZ,QAAIN;AACA,MAAAE,EAASF,CAAY;AAAA,SAClB;AACG,YAAAO,IAAkBC,EAAsBT,CAAmB;AACjE,MAAIQ,IAAkB,KACTL,EAAAK,IAAkBR,EAAoB,SAASU,CAAY;AAAA,IAE5E;AAAA,EACD,GAAA,CAACX,GAAaE,GAAcD,CAAmB,CAAC,GAEnDO,EAAU,MAAM;AACZ,UAAMI,IAAwB,MAAM;AAC1B,YAAAC,IAAY,OAAO,gBACnBC,KAAaD,KAAA,gBAAAA,EAAW,eAAc,GAEtCE,IAAgBD,IAAa,MAAKD,KAAA,gBAAAA,EAAW,WAAW,GAAG,cAC3DG,IAAcF,IAAa,MAAKD,KAAA,gBAAAA,EAAW,WAAW,GAAG;AAG3D,MAAA,EAFuB,CAAC,CAACA,KAAaE,MAAkBC,KAAeF,IAAa,MAE7DR,EAAgB,WACvCA,EAAgB,QAAQ;AAAA,IAC5B;AAGK,oBAAA,iBAAiB,mBAAmBM,CAAqB,GAC3D,MAAM,SAAS,oBAAoB,mBAAmBA,CAAqB;AAAA,EACtF,GAAG,CAAE,CAAA;AAEL,QAAMK,IAAwB,CAACC,GAA0BC,GAAuBC,MAAuB;AACnG,IAAAd,EAAgB,UAAUe,EAAWH,GAAWC,GAAUC,CAAM;AAAA,EAAA;AAIhE,SAAA,gBAAAE,EAAA;AAAA,IAACC;AAAA,IAAA;AAAA,MACG,iBAAiB;AAAA,QACb,YAAY,CAACC,KAAQC,GAAO;AAAA,QAC5B,sBAAsBR;AAAA,MAC1B;AAAA,MACA,QAAQ,EAAE,MAAM,EAAE,QAAQ,QAAQ,YAAY,WAAW,OAAAd,GAAO,oBAAoB,OAAO;AAAA,IAAA;AAAA,IAE3F,gBAAAmB,EAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,iBAAc;AAAA,QACd,gBAAa;AAAA,QACb,WAAU;AAAA,MAAA;AAAA,MAETvB;AAAA,IACL;AAAA,EAAA;AAGZ;"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -68,7 +68,7 @@ Shift+Ctrl+Return`:"Already at maximum numbers of columns"),onMouseDown:d=>qV(a,
|
|
|
68
68
|
font-weight: bold;
|
|
69
69
|
line-height: 10px;
|
|
70
70
|
border-radius: 2px;
|
|
71
|
-
`]},Qd0=e=>t.createElement(u.MentionInputElement,{...e,styles:Ud0});class Yd0 extends t0{constructor(l=u.ELEMENT_MENTION_INPUT,a=Qd0){super(l,a)}}class Gd0 extends n0{constructor(l){super(bd0,{markupElement:new _V().setNodeWithMentionable(l.mentionableItems),markupInputElement:new Yd0,...l})}inline(){var l;return Od0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[u.createComboboxPlugin(),u.createMentionPlugin(Pd0)]}}const Wd0="blur-on-break-plugin",qd0=["input","select","textarea","button","a[href]","area[href]","summary","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]","[tabindex]"].join(':not([hidden]):not([tabindex="-1"]):not([disabled]),'),eT=(e,l)=>{if(!document.activeElement)return;e.preventDefault();const a=Array.from(document.querySelectorAll(qd0)).filter(i=>Kd0(i)),c=a.indexOf(document.activeElement),r=(l?c+1:c-1+a.length)%a.length,o=a[r];o&&o.focus()},Kd0=e=>{let l=e;for(;l;){const a=window.getComputedStyle(l);if(a.display==="none"||a.visibility==="hidden")return!1;l=l.parentElement}return!0},tT=()=>{var e;(e=document.activeElement)==null||e.blur()},$d0=(e,{options:{onBreak:l=()=>{}}})=>a=>{u.Hotkeys.isSplitBlock(a)&&(a.stopPropagation(),a.preventDefault(),tT(),typeof l=="function"&&l(e.children))},Xd0="blurOnBreak",Jd0=u.createPluginFactory({key:Xd0,handlers:{onKeyDown:$d0}});class _d0 extends n0{constructor(a){super(Wd0,{...a});Y(this,"onBreak");this.onBreak=a==null?void 0:a.onBreak}plugins(){return[Jd0({options:{onBreak:this.onBreak}})]}}const U1=new TV;U1.setPlugin(new aV).setPlugin(new xV({textStyles:[new AV]})).setPlugin([new _z,new oV,new GV,new UV,new mV,new lV],[new Wz,new Gz,new Kz,new qz,new VV,new Yz,new bV,new BV,new nV]);class l2{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=b1(),a=U1){const c=u3(l,a);return this.editor=u.createPlateEditor({id:l,plugins:c.create()}),this}}Y(l2,"editor"),Y(l2,"editorId",b1());const eu0=e=>e[0].hasOwnProperty("type")?e:[{type:"p",children:e}],lT=[{type:u.ELEMENT_PARAGRAPH,children:[{text:""}]}],f2=({editorId:e="parseRawValue",raw:l,plugins:a})=>{const c=l2.init(`${e}_parseRawValue`,a).getInstance();let r=lT;if(!l)return r;try{r=JSON.parse(l)}catch{const o=l.trim().replaceAll(/>\s+</g,"><"),i=u.deserializeHtml(c,{element:o});r=eu0(i)}return c.children=r,u.normalizeEditor(c,{force:!0}),c.children},H2=e=>e&&typeof e=="object"&&!Array.isArray(e),nT=(e,l)=>{if(!H2(e)||!H2(l))return{};const a=Object.assign({},e);for(const c of Object.keys(l)){if(c in e&&H2(l[c])){a[c]=nT(e[c],l[c]);continue}Object.assign(a,{[c]:l[c]})}return a},tu0=e=>e.hasOwnProperty("type")&&typeof e.type=="string"&&e.type.length>0,lu0=e=>e.hasOwnProperty("children")&&Array.isArray(e.children)&&e.children.length===1,nu0=e=>typeof e=="object"&&e.hasOwnProperty("text")&&typeof e.text=="string"&&e.text.length===0,au0=e=>lu0(e)&&nu0(e.children[0]),cu0=e=>{if(!e)return!0;if(Array.isArray(e)&&e.length<2){if(e.length===0)return!0;const l=e[0];if(tu0(l)&&au0(l))return!0}return!1},ru0=({children:e,editorWidth:l,toolbarButtonGroups:a=[],toolbarWidth:c})=>{const[r,o]=t.useState(),i=t.useRef();t.useEffect(()=>{if(c)o(c);else{const m=Tz(a);m>0&&o(m+a.length+Vz)}},[l,c,a]),t.useEffect(()=>{const m=()=>{const L=window.getSelection(),d=(L==null?void 0:L.rangeCount)??0,h=d>0&&(L==null?void 0:L.getRangeAt(0).startOffset),w=d>0&&(L==null?void 0:L.getRangeAt(0).endOffset);!(!!L&&h!==w&&d>0)&&i.current&&i.current()};return document.addEventListener("selectionchange",m),()=>document.removeEventListener("selectionchange",m)},[]);const s=(m,L,d)=>{i.current=u.autoUpdate(m,L,d)};return t.createElement(u.BalloonToolbar,{floatingOptions:{middleware:[u.flip(),u.shift()],whileElementsMounted:s},styles:{root:{border:"none",background:"#ffffff",width:r}}},t.createElement("div",{"data-selector":"toolbar-floating","data-test-id":"toolbar-floating",className:"tw-rounded tw-min-h-12 tw-border tw-border-line tw-shadow-lg tw-bg-base tw-divide-y tw-divide-line tw-flex tw-flex-wrap"},e))},aT={[u0.BOTTOM]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col",ToolbarWrapper:nm0},[u0.FLOATING]:{PlateWrapperClassNames:"tw-relative tw-w-full",ToolbarWrapper:ru0},[u0.TOP]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col-reverse",ToolbarWrapper:am0}},ou0=(e,l)=>{const a=aT[e].PlateWrapperClassNames;return g([a,l&&"tw-border tw-border-line-strong tw-rounded"])},iu0=({children:e,apply:l})=>{for(const a of e)l({type:"remove_node",path:[0],node:a})},su0=({value:e})=>{const l=u.usePlateEditorRef();return t.useEffect(()=>{e&&(iu0(l),u.insertNodes(l,e))},[l,e]),null},mu0=({hideExternalFloatingModals:e})=>{const l=u.useEditorRef(),a=u.useFloatingLinkSelectors().isOpen(l.id),c=t.useCallback(()=>{a&&u.floatingLinkActions.reset(),e&&e(l.id)},[a,e,l]),r=t.useCallback(()=>{l.collapse(),c()},[l,c]);return t.useEffect(()=>{const o=i=>{const s=`[data-editor-id='${l.id}']`,m="[data-selector='toolbar-floating']",L="[data-is-underlay]",d=document.querySelector(s),h=document.querySelector(m),w=document.querySelector(L),v=i.target,f=w==null?void 0:w.contains(v),C=d==null?void 0:d.contains(v),A=h==null?void 0:h.contains(v);A&&c(),!C&&!A&&!f&&r()};return document.addEventListener("pointerdown",o),document.addEventListener("focusin",o),()=>{document.removeEventListener("focusin",o),document.removeEventListener("pointerdown",o)}},[r,c,l.id]),null},Lu0={position:"relative",height:"0"},cT=({id:e,value:l,placeholder:a="",readonly:c=!1,onTextChange:r,onBlur:o,padding:i=Xt.None,position:s=u0.FLOATING,plugins:m=U1,updateValueOnChange:L=!1,onValueChanged:d,border:h=!0,toolbarWidth:w,hideExternalFloatingModals:v})=>{var S,M;const f=E0(e),{localValue:C,onChange:A,memoizedValue:E,config:I}=im0({editorId:f,initialValue:l,onTextChange:r,plugins:m,onValueChanged:d}),x=m.plugins.find(y=>y.key===P1),N=((S=x==null?void 0:x.options)==null?void 0:S.columns)??1,R=((M=x==null?void 0:x.options)==null?void 0:M.gap)??d3,Z={placeholder:a,renderPlaceholder:({children:y,attributes:p})=>{const k={...p,style:{...p.style,...Lu0}};return t.createElement("span",{...k},y)},readOnly:c,onBlur:()=>o&&o(JSON.stringify(C.current)),className:`${i}`,style:{columns:N,columnGap:R,outline:"none"},onKeyDown:y=>{y.code==="Tab"&&eT(y,!y.shiftKey)},scrollSelectionIntoView:()=>{}};return t.createElement(Fz,{value:{styles:I.styles(),position:s,border:h,editorId:f}},t.createElement(u.Plate,{id:f,onChange:A,editableProps:Z,plugins:I.create(),initialValue:E},!Z.readOnly&&I.toolbar(w),I.inline(),L&&t.createElement(su0,{value:f2({editorId:f,raw:l,plugins:m})}),s===u0.FLOATING&&t.createElement(mu0,{hideExternalFloatingModals:v})))};cT.displayName="FondueRichTextEditor";const v7=e=>e.split("").reverse().join(""),Z1=(e,l)=>{const a=e.trim(),c=a,r=`${l}${c}${v7(l)}`;if(c.length===e.length)return r;const o=l+c+v7(l);return e.replace(a,o)},du0=(e,l)=>{const a=`
|
|
71
|
+
`]},Qd0=e=>t.createElement(u.MentionInputElement,{...e,styles:Ud0});class Yd0 extends t0{constructor(l=u.ELEMENT_MENTION_INPUT,a=Qd0){super(l,a)}}class Gd0 extends n0{constructor(l){super(bd0,{markupElement:new _V().setNodeWithMentionable(l.mentionableItems),markupInputElement:new Yd0,...l})}inline(){var l;return Od0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[u.createComboboxPlugin(),u.createMentionPlugin(Pd0)]}}const Wd0="blur-on-break-plugin",qd0=["input","select","textarea","button","a[href]","area[href]","summary","iframe","object","embed","audio[controls]","video[controls]","[contenteditable]","[tabindex]"].join(':not([hidden]):not([tabindex="-1"]):not([disabled]),'),eT=(e,l)=>{if(!document.activeElement)return;e.preventDefault();const a=Array.from(document.querySelectorAll(qd0)).filter(i=>Kd0(i)),c=a.indexOf(document.activeElement),r=(l?c+1:c-1+a.length)%a.length,o=a[r];o&&o.focus()},Kd0=e=>{let l=e;for(;l;){const a=window.getComputedStyle(l);if(a.display==="none"||a.visibility==="hidden")return!1;l=l.parentElement}return!0},tT=()=>{var e;(e=document.activeElement)==null||e.blur()},$d0=(e,{options:{onBreak:l=()=>{}}})=>a=>{u.Hotkeys.isSplitBlock(a)&&(a.stopPropagation(),a.preventDefault(),tT(),typeof l=="function"&&l(e.children))},Xd0="blurOnBreak",Jd0=u.createPluginFactory({key:Xd0,handlers:{onKeyDown:$d0}});class _d0 extends n0{constructor(a){super(Wd0,{...a});Y(this,"onBreak");this.onBreak=a==null?void 0:a.onBreak}plugins(){return[Jd0({options:{onBreak:this.onBreak}})]}}const U1=new TV;U1.setPlugin(new aV).setPlugin(new xV({textStyles:[new AV]})).setPlugin([new _z,new oV,new GV,new UV,new mV,new lV],[new Wz,new Gz,new Kz,new qz,new VV,new Yz,new bV,new BV,new nV]);class l2{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=b1(),a=U1){const c=u3(l,a);return this.editor=u.createPlateEditor({id:l,plugins:c.create()}),this}}Y(l2,"editor"),Y(l2,"editorId",b1());const eu0=e=>e[0].hasOwnProperty("type")?e:[{type:"p",children:e}],lT=[{type:u.ELEMENT_PARAGRAPH,children:[{text:""}]}],f2=({editorId:e="parseRawValue",raw:l,plugins:a})=>{const c=l2.init(`${e}_parseRawValue`,a).getInstance();let r=lT;if(!l)return r;try{r=JSON.parse(l)}catch{const o=l.trim().replaceAll(/>\s+</g,"><"),i=u.deserializeHtml(c,{element:o});r=eu0(i)}return c.children=r,u.normalizeEditor(c,{force:!0}),c.children},H2=e=>e&&typeof e=="object"&&!Array.isArray(e),nT=(e,l)=>{if(!H2(e)||!H2(l))return{};const a=Object.assign({},e);for(const c of Object.keys(l)){if(c in e&&H2(l[c])){a[c]=nT(e[c],l[c]);continue}Object.assign(a,{[c]:l[c]})}return a},tu0=e=>e.hasOwnProperty("type")&&typeof e.type=="string"&&e.type.length>0,lu0=e=>e.hasOwnProperty("children")&&Array.isArray(e.children)&&e.children.length===1,nu0=e=>typeof e=="object"&&e.hasOwnProperty("text")&&typeof e.text=="string"&&e.text.length===0,au0=e=>lu0(e)&&nu0(e.children[0]),cu0=e=>{if(!e)return!0;if(Array.isArray(e)&&e.length<2){if(e.length===0)return!0;const l=e[0];if(tu0(l)&&au0(l))return!0}return!1},ru0=({children:e,editorWidth:l,toolbarButtonGroups:a=[],toolbarWidth:c})=>{const[r,o]=t.useState(),i=t.useRef();t.useEffect(()=>{if(c)o(c);else{const m=Tz(a);m>0&&o(m+a.length+Vz)}},[l,c,a]),t.useEffect(()=>{const m=()=>{const L=window.getSelection(),d=(L==null?void 0:L.rangeCount)??0,h=d>0&&(L==null?void 0:L.getRangeAt(0).startOffset),w=d>0&&(L==null?void 0:L.getRangeAt(0).endOffset);!(!!L&&h!==w&&d>0)&&i.current&&i.current()};return document.addEventListener("selectionchange",m),()=>document.removeEventListener("selectionchange",m)},[]);const s=(m,L,d)=>{i.current=u.autoUpdate(m,L,d)};return t.createElement(u.BalloonToolbar,{floatingOptions:{middleware:[u.flip(),u.shift()],whileElementsMounted:s},styles:{root:{border:"none",background:"#ffffff",width:r,transitionDuration:"0s"}}},t.createElement("div",{"data-selector":"toolbar-floating","data-test-id":"toolbar-floating",className:"tw-rounded tw-min-h-12 tw-border tw-border-line tw-shadow-lg tw-bg-base tw-divide-y tw-divide-line tw-flex tw-flex-wrap"},e))},aT={[u0.BOTTOM]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col",ToolbarWrapper:nm0},[u0.FLOATING]:{PlateWrapperClassNames:"tw-relative tw-w-full",ToolbarWrapper:ru0},[u0.TOP]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col-reverse",ToolbarWrapper:am0}},ou0=(e,l)=>{const a=aT[e].PlateWrapperClassNames;return g([a,l&&"tw-border tw-border-line-strong tw-rounded"])},iu0=({children:e,apply:l})=>{for(const a of e)l({type:"remove_node",path:[0],node:a})},su0=({value:e})=>{const l=u.usePlateEditorRef();return t.useEffect(()=>{e&&(iu0(l),u.insertNodes(l,e))},[l,e]),null},mu0=({hideExternalFloatingModals:e})=>{const l=u.useEditorRef(),a=u.useFloatingLinkSelectors().isOpen(l.id),c=t.useCallback(()=>{a&&u.floatingLinkActions.reset(),e&&e(l.id)},[a,e,l]),r=t.useCallback(()=>{l.collapse(),c()},[l,c]);return t.useEffect(()=>{const o=i=>{const s=`[data-editor-id='${l.id}']`,m="[data-selector='toolbar-floating']",L="[data-is-underlay]",d=document.querySelector(s),h=document.querySelector(m),w=document.querySelector(L),v=i.target,f=w==null?void 0:w.contains(v),C=d==null?void 0:d.contains(v),A=h==null?void 0:h.contains(v);A&&c(),!C&&!A&&!f&&r()};return document.addEventListener("pointerdown",o),document.addEventListener("focusin",o),()=>{document.removeEventListener("focusin",o),document.removeEventListener("pointerdown",o)}},[r,c,l.id]),null},Lu0={position:"relative",height:"0"},cT=({id:e,value:l,placeholder:a="",readonly:c=!1,onTextChange:r,onBlur:o,padding:i=Xt.None,position:s=u0.FLOATING,plugins:m=U1,updateValueOnChange:L=!1,onValueChanged:d,border:h=!0,toolbarWidth:w,hideExternalFloatingModals:v})=>{var S,M;const f=E0(e),{localValue:C,onChange:A,memoizedValue:E,config:I}=im0({editorId:f,initialValue:l,onTextChange:r,plugins:m,onValueChanged:d}),x=m.plugins.find(y=>y.key===P1),N=((S=x==null?void 0:x.options)==null?void 0:S.columns)??1,R=((M=x==null?void 0:x.options)==null?void 0:M.gap)??d3,Z={placeholder:a,renderPlaceholder:({children:y,attributes:p})=>{const k={...p,style:{...p.style,...Lu0}};return t.createElement("span",{...k},y)},readOnly:c,onBlur:()=>o&&o(JSON.stringify(C.current)),className:`${i}`,style:{columns:N,columnGap:R,outline:"none"},onKeyDown:y=>{y.code==="Tab"&&eT(y,!y.shiftKey)},scrollSelectionIntoView:()=>{}};return t.createElement(Fz,{value:{styles:I.styles(),position:s,border:h,editorId:f}},t.createElement(u.Plate,{id:f,onChange:A,editableProps:Z,plugins:I.create(),initialValue:E},!Z.readOnly&&I.toolbar(w),I.inline(),L&&t.createElement(su0,{value:f2({editorId:f,raw:l,plugins:m})}),s===u0.FLOATING&&t.createElement(mu0,{hideExternalFloatingModals:v})))};cT.displayName="FondueRichTextEditor";const v7=e=>e.split("").reverse().join(""),Z1=(e,l)=>{const a=e.trim(),c=a,r=`${l}${c}${v7(l)}`;if(c.length===e.length)return r;const o=l+c+v7(l);return e.replace(a,o)},du0=(e,l)=>{const a=`
|
|
72
72
|
`;return(l.strikethrough||l.bold||l.italic)&&new RegExp(a,"g").test(e)&&(e=e.replaceAll(a,`\\
|
|
73
73
|
`)),e},uu0=(e,l)=>(l.strikethrough&&l.bold&&l.italic?e=Z1(e,"~~***"):l.bold&&l.italic?e=Z1(e,"***"):(l.bold&&(e=Z1(e,"**")),l.italic&&(e=Z1(e,"_")),l.strikethrough&&(e=Z1(e,"~~")),l.code&&(e=Z1(e,"`"))),e=du0(e,l),e),z1=e=>!("type"in e),wu0={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"},X2={Blank:"_blank",Self:"_self"},hu0=e=>`@[${e.category}:${e.id}]`,fu0=e=>`${e}
|
|
74
74
|
`,vu0=(e,l,a,c)=>{const r=a&&a.parentType===e.olList,o=a.children.length===1&&z1(a.children[0]);let i="";for(let s=0;c>s;s++)r?i+=" ":i+=" ";return`${i}${r?"1.":"-"} ${l}${o?`
|