@frontify/fondue 12.0.0-beta.135 → 12.0.0-beta.136
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/RichTextEditor.es.js +25 -23
- package/dist/components/RichTextEditor/RichTextEditor.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/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { useMemoizedId as
|
|
1
|
+
import { useMemoizedId as O } from "../../hooks/useMemoizedId.es.js";
|
|
2
2
|
import { Plate as v } from "@udecode/plate";
|
|
3
3
|
import t from "react";
|
|
4
|
-
import { ContentReplacement as
|
|
5
|
-
import { RichTextEditorProvider as
|
|
6
|
-
import { defaultPlugins as
|
|
7
|
-
import { PaddingSizes as
|
|
8
|
-
import { defaultDesignTokens as
|
|
9
|
-
import { useEditorState as
|
|
10
|
-
import { KEY_ELEMENT_BREAK_AFTER_COLUMN as
|
|
4
|
+
import { ContentReplacement as w } from "./ContentReplacement.es.js";
|
|
5
|
+
import { RichTextEditorProvider as x } from "./context/RichTextEditorContext.es.js";
|
|
6
|
+
import { defaultPlugins as C } from "./Plugins/index.es.js";
|
|
7
|
+
import { PaddingSizes as D } from "./types.es.js";
|
|
8
|
+
import { defaultDesignTokens as F } from "./utils/defaultDesignTokens.es.js";
|
|
9
|
+
import { useEditorState as I } from "./hooks/useEditorState.es.js";
|
|
10
|
+
import { KEY_ELEMENT_BREAK_AFTER_COLUMN as z, GAP_DEFAULT as G } from "./Plugins/ColumnBreakPlugin/createColumnBreakPlugin.es.js";
|
|
11
11
|
import { Position as K } from "./EditorPositioningWrapper/types.es.js";
|
|
12
12
|
import { parseRawValue as M } from "./utils/parseRawValue.es.js";
|
|
13
13
|
import { forceToBlurActiveElement as B } from "./helpers/forceToBlurActiveElement.es.js";
|
|
@@ -19,48 +19,50 @@ const U = {
|
|
|
19
19
|
value: m,
|
|
20
20
|
placeholder: p = "",
|
|
21
21
|
readonly: f = !1,
|
|
22
|
-
designTokens: E =
|
|
22
|
+
designTokens: E = F,
|
|
23
23
|
onTextChange: u,
|
|
24
|
-
onBlur:
|
|
25
|
-
padding: T =
|
|
24
|
+
onBlur: l,
|
|
25
|
+
padding: T = D.None,
|
|
26
26
|
position: R = K.FLOATING,
|
|
27
|
-
plugins: r =
|
|
27
|
+
plugins: r = C,
|
|
28
28
|
updateValueOnChange: y = !1,
|
|
29
29
|
onValueChanged: h,
|
|
30
30
|
border: L = !0
|
|
31
31
|
}) => {
|
|
32
|
-
var
|
|
33
|
-
const i =
|
|
32
|
+
var a, s;
|
|
33
|
+
const i = O(d), { localValue: N, onChange: g, memoizedValue: P, config: n } = I({
|
|
34
34
|
editorId: i,
|
|
35
35
|
initialValue: m,
|
|
36
36
|
onTextChange: u,
|
|
37
37
|
plugins: r,
|
|
38
38
|
onValueChanged: h
|
|
39
|
-
}), e = r.plugins.find((o) => o.key ===
|
|
39
|
+
}), e = r.plugins.find((o) => o.key === z), S = ((a = e == null ? void 0 : e.options) == null ? void 0 : a.columns) ?? 1, V = ((s = e == null ? void 0 : e.options) == null ? void 0 : s.gap) ?? G, _ = {
|
|
40
40
|
placeholder: p,
|
|
41
41
|
renderPlaceholder: ({ children: o, attributes: c }) => {
|
|
42
|
-
const
|
|
42
|
+
const A = {
|
|
43
43
|
...c,
|
|
44
44
|
style: {
|
|
45
45
|
...c.style,
|
|
46
46
|
...U
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
return /* @__PURE__ */ t.createElement("span", { ...
|
|
49
|
+
return /* @__PURE__ */ t.createElement("span", { ...A }, o);
|
|
50
50
|
},
|
|
51
51
|
readOnly: f,
|
|
52
|
-
onBlur: () =>
|
|
52
|
+
onBlur: () => l && l(JSON.stringify(N.current)),
|
|
53
53
|
className: `${T}`,
|
|
54
54
|
style: {
|
|
55
|
-
columns:
|
|
56
|
-
columnGap:
|
|
55
|
+
columns: S,
|
|
56
|
+
columnGap: V
|
|
57
57
|
},
|
|
58
58
|
onKeyDown: (o) => {
|
|
59
59
|
o.code === "Tab" && B();
|
|
60
|
+
},
|
|
61
|
+
scrollSelectionIntoView: () => {
|
|
60
62
|
}
|
|
61
63
|
};
|
|
62
64
|
return /* @__PURE__ */ t.createElement(
|
|
63
|
-
|
|
65
|
+
x,
|
|
64
66
|
{
|
|
65
67
|
value: {
|
|
66
68
|
designTokens: E,
|
|
@@ -73,13 +75,13 @@ const U = {
|
|
|
73
75
|
{
|
|
74
76
|
id: i,
|
|
75
77
|
onChange: g,
|
|
76
|
-
editableProps:
|
|
78
|
+
editableProps: _,
|
|
77
79
|
plugins: n.create(),
|
|
78
80
|
initialValue: P
|
|
79
81
|
},
|
|
80
82
|
n.toolbar(),
|
|
81
83
|
n.inline(),
|
|
82
|
-
y && /* @__PURE__ */ t.createElement(
|
|
84
|
+
y && /* @__PURE__ */ t.createElement(w, { value: M({ editorId: i, raw: m, plugins: r }) })
|
|
83
85
|
)
|
|
84
86
|
);
|
|
85
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextEditor.es.js","sources":["../../../src/components/RichTextEditor/RichTextEditor.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useMemoizedId } from '@hooks/useMemoizedId';\nimport { Plate } from '@udecode/plate';\nimport React from 'react';\nimport {
|
|
1
|
+
{"version":3,"file":"RichTextEditor.es.js","sources":["../../../src/components/RichTextEditor/RichTextEditor.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useMemoizedId } from '@hooks/useMemoizedId';\nimport { Plate, TEditableProps } from '@udecode/plate';\nimport React from 'react';\nimport { RenderPlaceholderProps } from 'slate-react';\nimport { ContentReplacement } from './ContentReplacement';\nimport { RichTextEditorProvider } from './context/RichTextEditorContext';\nimport { Position } from './EditorPositioningWrapper';\nimport { forceToBlurActiveElement } from './helpers';\nimport { useEditorState } from './hooks';\nimport { GAP_DEFAULT, KEY_ELEMENT_BREAK_AFTER_COLUMN, PluginComposer, defaultPlugins } from './Plugins';\nimport { DesignTokens, PaddingSizes, TreeOfNodes } from './types';\nimport { parseRawValue } from './utils';\nimport { defaultDesignTokens } from './utils/defaultDesignTokens';\n\nconst PLACEHOLDER_STYLES: RenderPlaceholderProps['attributes']['style'] = {\n position: 'relative',\n height: '0',\n};\n\nexport type RichTextEditorProps = {\n id?: string;\n placeholder?: string;\n value?: string;\n onTextChange?: (value: string) => void;\n onBlur?: (value: string) => void;\n readonly?: boolean;\n designTokens?: DesignTokens;\n padding?: PaddingSizes;\n position?: Position;\n plugins?: PluginComposer;\n onValueChanged?: (value: TreeOfNodes | null) => void;\n border?: boolean;\n updateValueOnChange?: boolean; // Only set to true when you are sure that performance isn't an issue\n};\n\nexport const RichTextEditor = ({\n id,\n value,\n placeholder = '',\n readonly = false,\n designTokens = defaultDesignTokens,\n onTextChange,\n onBlur,\n padding = PaddingSizes.None,\n position = Position.FLOATING,\n plugins = defaultPlugins,\n updateValueOnChange = false,\n onValueChanged,\n border = true,\n}: RichTextEditorProps) => {\n const editorId = useMemoizedId(id);\n const { localValue, onChange, memoizedValue, config } = useEditorState({\n editorId,\n initialValue: value,\n onTextChange,\n plugins,\n onValueChanged,\n });\n\n const breakAfterPlugin = plugins.plugins.find((plugin) => plugin.key === KEY_ELEMENT_BREAK_AFTER_COLUMN);\n const columns = breakAfterPlugin?.options?.columns ?? 1;\n const columnGap = breakAfterPlugin?.options?.gap ?? GAP_DEFAULT;\n\n const editableProps: TEditableProps = {\n placeholder,\n renderPlaceholder: ({ children, attributes }) => {\n const mergedAttributes = {\n ...attributes,\n style: {\n ...attributes.style,\n ...PLACEHOLDER_STYLES,\n },\n };\n return <span {...mergedAttributes}>{children}</span>;\n },\n readOnly: readonly,\n onBlur: () => onBlur && onBlur(JSON.stringify(localValue.current)),\n className: `${padding}`,\n style: {\n columns,\n columnGap,\n },\n onKeyDown: (event) => {\n if (event.code === 'Tab') {\n // Forcing a blur event because of accessibility\n forceToBlurActiveElement();\n }\n },\n scrollSelectionIntoView: () => {\n // We pass in an empty function here because we don't want the default scroll behaviour\n },\n };\n\n return (\n <RichTextEditorProvider\n value={{\n designTokens,\n position,\n border,\n }}\n >\n <Plate\n id={editorId}\n onChange={onChange}\n editableProps={editableProps}\n plugins={config.create()}\n initialValue={memoizedValue}\n >\n {config.toolbar()}\n {config.inline()}\n {updateValueOnChange && <ContentReplacement value={parseRawValue({ editorId, raw: value, plugins })} />}\n </Plate>\n </RichTextEditorProvider>\n );\n};\nRichTextEditor.displayName = 'FondueRichTextEditor';\n"],"names":["PLACEHOLDER_STYLES","RichTextEditor","id","value","placeholder","readonly","designTokens","defaultDesignTokens","onTextChange","onBlur","padding","PaddingSizes","position","Position","plugins","defaultPlugins","updateValueOnChange","onValueChanged","border","editorId","useMemoizedId","localValue","onChange","memoizedValue","config","useEditorState","breakAfterPlugin","plugin","KEY_ELEMENT_BREAK_AFTER_COLUMN","columns","_a","columnGap","_b","GAP_DEFAULT","editableProps","children","attributes","mergedAttributes","React","event","forceToBlurActiveElement","RichTextEditorProvider","Plate","ContentReplacement","parseRawValue"],"mappings":";;;;;;;;;;;;;AAgBA,MAAMA,IAAoE;AAAA,EACtE,UAAU;AAAA,EACV,QAAQ;AACZ,GAkBaC,IAAiB,CAAC;AAAA,EAC3B,IAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,UAAAC,IAAW;AAAA,EACX,cAAAC,IAAeC;AAAA,EACf,cAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC,IAAUC,EAAa;AAAA,EACvB,UAAAC,IAAWC,EAAS;AAAA,EACpB,SAAAC,IAAUC;AAAA,EACV,qBAAAC,IAAsB;AAAA,EACtB,gBAAAC;AAAA,EACA,QAAAC,IAAS;AACb,MAA2B;;AACjB,QAAAC,IAAWC,EAAclB,CAAE,GAC3B,EAAE,YAAAmB,GAAY,UAAAC,GAAU,eAAAC,GAAe,QAAAC,EAAA,IAAWC,EAAe;AAAA,IACnE,UAAAN;AAAA,IACA,cAAchB;AAAA,IACd,cAAAK;AAAA,IACA,SAAAM;AAAA,IACA,gBAAAG;AAAA,EAAA,CACH,GAEKS,IAAmBZ,EAAQ,QAAQ,KAAK,CAACa,MAAWA,EAAO,QAAQC,CAA8B,GACjGC,MAAUC,IAAAJ,KAAA,gBAAAA,EAAkB,YAAlB,gBAAAI,EAA2B,YAAW,GAChDC,MAAYC,IAAAN,KAAA,gBAAAA,EAAkB,YAAlB,gBAAAM,EAA2B,QAAOC,GAE9CC,IAAgC;AAAA,IAClC,aAAA9B;AAAA,IACA,mBAAmB,CAAC,EAAE,UAAA+B,GAAU,YAAAC,QAAiB;AAC7C,YAAMC,IAAmB;AAAA,QACrB,GAAGD;AAAA,QACH,OAAO;AAAA,UACH,GAAGA,EAAW;AAAA,UACd,GAAGpC;AAAA,QACP;AAAA,MAAA;AAEJ,aAAQ,gBAAAsC,EAAA,cAAA,QAAA,EAAM,GAAGD,EAAA,GAAmBF,CAAS;AAAA,IACjD;AAAA,IACA,UAAU9B;AAAA,IACV,QAAQ,MAAMI,KAAUA,EAAO,KAAK,UAAUY,EAAW,OAAO,CAAC;AAAA,IACjE,WAAW,GAAGX;AAAA,IACd,OAAO;AAAA,MACH,SAAAmB;AAAA,MACA,WAAAE;AAAA,IACJ;AAAA,IACA,WAAW,CAACQ,MAAU;AACd,MAAAA,EAAM,SAAS,SAEUC;IAEjC;AAAA,IACA,yBAAyB,MAAM;AAAA,IAE/B;AAAA,EAAA;AAIA,SAAA,gBAAAF,EAAA;AAAA,IAACG;AAAA,IAAA;AAAA,MACG,OAAO;AAAA,QACH,cAAAnC;AAAA,QACA,UAAAM;AAAA,QACA,QAAAM;AAAA,MACJ;AAAA,IAAA;AAAA,IAEA,gBAAAoB,EAAA;AAAA,MAACI;AAAA,MAAA;AAAA,QACG,IAAIvB;AAAA,QACJ,UAAAG;AAAA,QACA,eAAAY;AAAA,QACA,SAASV,EAAO,OAAO;AAAA,QACvB,cAAcD;AAAA,MAAA;AAAA,MAEbC,EAAO,QAAQ;AAAA,MACfA,EAAO,OAAO;AAAA,MACdR,KAAwB,gBAAAsB,EAAA,cAAAK,GAAA,EAAmB,OAAOC,EAAc,EAAE,UAAAzB,GAAU,KAAKhB,GAAO,SAAAW,EAAQ,CAAC,EAAG,CAAA;AAAA,IACzG;AAAA,EAAA;AAGZ;AACAb,EAAe,cAAc;"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -69,7 +69,7 @@ Shift+Ctrl+Return`:"Already at maximum numbers of columns"),onMouseDown:d=>WH(a,
|
|
|
69
69
|
font-weight: bold;
|
|
70
70
|
line-height: 10px;
|
|
71
71
|
border-radius: 2px;
|
|
72
|
-
`]},oi0=e=>t.createElement(s.MentionInputElement,{...e,styles:ri0});class ii0 extends m0{constructor(l=s.ELEMENT_MENTION_INPUT,a=oi0){super(l,a)}}class si0 extends w0{constructor(l){super(Ko0,{markupElement:new $H().setNodeWithMentionable(l.mentionableItems),markupInputElement:new ii0,...l})}inline(){var l;return ai0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[s.createComboboxPlugin(),s.createMentionPlugin(ci0)]}}const mi0="blur-on-break-plugin",ot=()=>{var e;(e=document.activeElement)==null||e.blur()},Li0=(e,{options:{onBreak:l=()=>{}}})=>a=>{s.Hotkeys.isSplitBlock(a)&&(a.stopPropagation(),a.preventDefault(),ot(),typeof l=="function"&&l(e.children))},di0="blurOnBreak",ui0=s.createPluginFactory({key:di0,handlers:{onKeyDown:Li0}});class wi0 extends w0{constructor(a){super(mi0,{...a});n0(this,"onBreak");this.onBreak=a==null?void 0:a.onBreak}plugins(){return[ui0({options:{onBreak:this.onBreak}})]}}const G2=new TH;G2.setPlugin(new AH,new bH).setPlugin(new Yk).setPlugin([new eH,new MH,new YH,new OH,new ZH,new wH,new vH],[new Kk,new qk,new Jk,new Xk,new zH,new Wk,new yH,new BH,new gH]);class b1{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=N1(),a=G2){const c=lt(l,a);return this.editor=s.createPlateEditor({id:l,plugins:c.create()}),this}}n0(b1,"editor"),n0(b1,"editorId",N1());const hi0=e=>new DOMParser().parseFromString(e,"text/html").body.children.length>0,fi0=e=>hi0(e)?e:`<p>${e}</p>`,_H=[{type:s.ELEMENT_PARAGRAPH,children:[{text:""}]}],W2=({editorId:e="parseRawValue",raw:l,plugins:a})=>{const c=b1.init(`${e}_parseRawValue`,a).getInstance();let r=_H;if(!l)return r;try{r=JSON.parse(l)}catch{const o=l.trim().replace(/>\s+</g,"><"),i=fi0(o),m=s.deserializeHtml(c,{element:i,stripWhitespace:!0});m&&(r=m)}return c.children=r,s.normalizeEditor(c,{force:!0}),c.children},e2=e=>e&&typeof e=="object"&&!Array.isArray(e),it=(e,l)=>{if(!e2(e)||!e2(l))return{};const a=Object.assign({},e);for(const c of Object.keys(l)){if(c in e&&e2(l[c])){a[c]=it(e[c],l[c]);continue}Object.assign(a,{[c]:l[c]})}return a},vi0=e=>e.hasOwnProperty("type")&&typeof e.type=="string"&&e.type.length>0,gi0=e=>e.hasOwnProperty("children")&&Array.isArray(e.children)&&e.children.length===1,Ai0=e=>typeof e=="object"&&e.hasOwnProperty("text")&&typeof e.text=="string"&&e.text.length===0,Ci0=e=>gi0(e)&&Ai0(e.children[0]),Ei0=e=>{if(!e)return!0;if(Array.isArray(e)&&e.length<2){if(e.length===0)return!0;const l=e[0];if(vi0(l)&&Ci0(l))return!0}return!1},Mi0=({children:e,editorWidth:l,toolbarButtonGroups:a=[]})=>{const[c,r]=t.useState();return t.useEffect(()=>{const o=zk(a);o>0&&r(o+a.length+Hk)},[l,a]),t.createElement(s.BalloonToolbar,{floatingOptions:{middleware:[s.flip(),s.shift()]},styles:{root:{border:"none",background:"#ffffff",width:c}}},t.createElement("div",{"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))},ez={[t0.BOTTOM]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col",ToolbarWrapper:ac0},[t0.FLOATING]:{PlateWrapperClassNames:"tw-relative tw-w-full",ToolbarWrapper:Mi0},[t0.TOP]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col-reverse",ToolbarWrapper:cc0}},Ii0=(e,l)=>{const a=ez[e].PlateWrapperClassNames;return f([a,l&&"tw-border tw-border-line tw-rounded"])},xi0=({children:e,apply:l})=>{for(const a of e)l({type:"remove_node",path:[0],node:a})},Zi0=({value:e})=>{const l=s.usePlateEditorRef();return t.useEffect(()=>{e&&(xi0(l),s.insertNodes(l,e))},[l,e]),null},Ni0={position:"relative",height:"0"},tz=({id:e,value:l,placeholder:a="",readonly:c=!1,designTokens:r=l1,onTextChange:o,onBlur:i,padding:m=U5.None,position:L=t0.FLOATING,plugins:d=G2,updateValueOnChange:u=!1,onValueChanged:w,border:h=!0})=>{var A,p;const g=A0(e),{localValue:v,onChange:M,memoizedValue:C,config:I}=sc0({editorId:g,initialValue:l,onTextChange:o,plugins:d,onValueChanged:w}),E=d.plugins.find(y=>y.key===I1),x=((A=E==null?void 0:E.options)==null?void 0:A.columns)??1,Z=((p=E==null?void 0:E.options)==null?void 0:p.gap)??tt,H={placeholder:a,renderPlaceholder:({children:y,attributes:k})=>{const S={...k,style:{...k.style,...Ni0}};return t.createElement("span",{...S},y)},readOnly:c,onBlur:()=>i&&i(JSON.stringify(v.current)),className:`${m}`,style:{columns:x,columnGap:Z},onKeyDown:y=>{y.code==="Tab"&&ot()}};return t.createElement(uc0,{value:{designTokens:r,position:L,border:h}},t.createElement(s.Plate,{id:g,onChange:M,editableProps:H,plugins:I.create(),initialValue:C},I.toolbar(),I.inline(),u&&t.createElement(Zi0,{value:W2({editorId:g,raw:l,plugins:d})})))};tz.displayName="FondueRichTextEditor";const pi0=(e,l)=>(l.strikethrough&&l.bold&&l.italic?e=o1(e,"~~***"):l.bold&&l.italic?e=o1(e,"***"):(l.bold&&(e=o1(e,"**")),l.italic&&(e=o1(e,"_")),l.strikethrough&&(e=o1(e,"~~")),l.code&&(e=o1(e,"`"))),e),jt=e=>e.split("").reverse().join("");function o1(e,l){const a=e.trim(),c=a,r=`${l}${c}${jt(l)}`;if(c.length===e.length)return r;const o=l+c+jt(l);return e.replace(a,o)}const g1=e=>!("type"in e),Si0=e=>`@[${e.category}:${e.id}]`,yi0=e=>`${e}
|
|
72
|
+
`]},oi0=e=>t.createElement(s.MentionInputElement,{...e,styles:ri0});class ii0 extends m0{constructor(l=s.ELEMENT_MENTION_INPUT,a=oi0){super(l,a)}}class si0 extends w0{constructor(l){super(Ko0,{markupElement:new $H().setNodeWithMentionable(l.mentionableItems),markupInputElement:new ii0,...l})}inline(){var l;return ai0(((l=this.props)==null?void 0:l.mentionableItems)||[])}plugins(){return[s.createComboboxPlugin(),s.createMentionPlugin(ci0)]}}const mi0="blur-on-break-plugin",ot=()=>{var e;(e=document.activeElement)==null||e.blur()},Li0=(e,{options:{onBreak:l=()=>{}}})=>a=>{s.Hotkeys.isSplitBlock(a)&&(a.stopPropagation(),a.preventDefault(),ot(),typeof l=="function"&&l(e.children))},di0="blurOnBreak",ui0=s.createPluginFactory({key:di0,handlers:{onKeyDown:Li0}});class wi0 extends w0{constructor(a){super(mi0,{...a});n0(this,"onBreak");this.onBreak=a==null?void 0:a.onBreak}plugins(){return[ui0({options:{onBreak:this.onBreak}})]}}const G2=new TH;G2.setPlugin(new AH,new bH).setPlugin(new Yk).setPlugin([new eH,new MH,new YH,new OH,new ZH,new wH,new vH],[new Kk,new qk,new Jk,new Xk,new zH,new Wk,new yH,new BH,new gH]);class b1{static getInstance(){return this.editor===void 0&&this.init(),this.editor}static init(l=N1(),a=G2){const c=lt(l,a);return this.editor=s.createPlateEditor({id:l,plugins:c.create()}),this}}n0(b1,"editor"),n0(b1,"editorId",N1());const hi0=e=>new DOMParser().parseFromString(e,"text/html").body.children.length>0,fi0=e=>hi0(e)?e:`<p>${e}</p>`,_H=[{type:s.ELEMENT_PARAGRAPH,children:[{text:""}]}],W2=({editorId:e="parseRawValue",raw:l,plugins:a})=>{const c=b1.init(`${e}_parseRawValue`,a).getInstance();let r=_H;if(!l)return r;try{r=JSON.parse(l)}catch{const o=l.trim().replace(/>\s+</g,"><"),i=fi0(o),m=s.deserializeHtml(c,{element:i,stripWhitespace:!0});m&&(r=m)}return c.children=r,s.normalizeEditor(c,{force:!0}),c.children},e2=e=>e&&typeof e=="object"&&!Array.isArray(e),it=(e,l)=>{if(!e2(e)||!e2(l))return{};const a=Object.assign({},e);for(const c of Object.keys(l)){if(c in e&&e2(l[c])){a[c]=it(e[c],l[c]);continue}Object.assign(a,{[c]:l[c]})}return a},vi0=e=>e.hasOwnProperty("type")&&typeof e.type=="string"&&e.type.length>0,gi0=e=>e.hasOwnProperty("children")&&Array.isArray(e.children)&&e.children.length===1,Ai0=e=>typeof e=="object"&&e.hasOwnProperty("text")&&typeof e.text=="string"&&e.text.length===0,Ci0=e=>gi0(e)&&Ai0(e.children[0]),Ei0=e=>{if(!e)return!0;if(Array.isArray(e)&&e.length<2){if(e.length===0)return!0;const l=e[0];if(vi0(l)&&Ci0(l))return!0}return!1},Mi0=({children:e,editorWidth:l,toolbarButtonGroups:a=[]})=>{const[c,r]=t.useState();return t.useEffect(()=>{const o=zk(a);o>0&&r(o+a.length+Hk)},[l,a]),t.createElement(s.BalloonToolbar,{floatingOptions:{middleware:[s.flip(),s.shift()]},styles:{root:{border:"none",background:"#ffffff",width:c}}},t.createElement("div",{"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))},ez={[t0.BOTTOM]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col",ToolbarWrapper:ac0},[t0.FLOATING]:{PlateWrapperClassNames:"tw-relative tw-w-full",ToolbarWrapper:Mi0},[t0.TOP]:{PlateWrapperClassNames:"tw-relative tw-w-full tw-flex tw-flex-col-reverse",ToolbarWrapper:cc0}},Ii0=(e,l)=>{const a=ez[e].PlateWrapperClassNames;return f([a,l&&"tw-border tw-border-line tw-rounded"])},xi0=({children:e,apply:l})=>{for(const a of e)l({type:"remove_node",path:[0],node:a})},Zi0=({value:e})=>{const l=s.usePlateEditorRef();return t.useEffect(()=>{e&&(xi0(l),s.insertNodes(l,e))},[l,e]),null},Ni0={position:"relative",height:"0"},tz=({id:e,value:l,placeholder:a="",readonly:c=!1,designTokens:r=l1,onTextChange:o,onBlur:i,padding:m=U5.None,position:L=t0.FLOATING,plugins:d=G2,updateValueOnChange:u=!1,onValueChanged:w,border:h=!0})=>{var A,p;const g=A0(e),{localValue:v,onChange:M,memoizedValue:C,config:I}=sc0({editorId:g,initialValue:l,onTextChange:o,plugins:d,onValueChanged:w}),E=d.plugins.find(y=>y.key===I1),x=((A=E==null?void 0:E.options)==null?void 0:A.columns)??1,Z=((p=E==null?void 0:E.options)==null?void 0:p.gap)??tt,H={placeholder:a,renderPlaceholder:({children:y,attributes:k})=>{const S={...k,style:{...k.style,...Ni0}};return t.createElement("span",{...S},y)},readOnly:c,onBlur:()=>i&&i(JSON.stringify(v.current)),className:`${m}`,style:{columns:x,columnGap:Z},onKeyDown:y=>{y.code==="Tab"&&ot()},scrollSelectionIntoView:()=>{}};return t.createElement(uc0,{value:{designTokens:r,position:L,border:h}},t.createElement(s.Plate,{id:g,onChange:M,editableProps:H,plugins:I.create(),initialValue:C},I.toolbar(),I.inline(),u&&t.createElement(Zi0,{value:W2({editorId:g,raw:l,plugins:d})})))};tz.displayName="FondueRichTextEditor";const pi0=(e,l)=>(l.strikethrough&&l.bold&&l.italic?e=o1(e,"~~***"):l.bold&&l.italic?e=o1(e,"***"):(l.bold&&(e=o1(e,"**")),l.italic&&(e=o1(e,"_")),l.strikethrough&&(e=o1(e,"~~")),l.code&&(e=o1(e,"`"))),e),jt=e=>e.split("").reverse().join("");function o1(e,l){const a=e.trim(),c=a,r=`${l}${c}${jt(l)}`;if(c.length===e.length)return r;const o=l+c+jt(l);return e.replace(a,o)}const g1=e=>!("type"in e),Si0=e=>`@[${e.category}:${e.id}]`,yi0=e=>`${e}
|
|
73
73
|
`,Ri0=(e,l,a,c)=>{const r=a&&a.parentType===e.olList,o=a.children.length===1&&g1(a.children[0]);let i="";for(let m=0;c>m;m++)r?i+=" ":i+=" ";return`${i}${r?"1.":"-"} ${l}${o?`
|
|
74
74
|
`:""}`},ki0=(e,l,a,c)=>(c===l.codeBlock||a===l.codeBlock||(e=n2(e)),e),Hi0=(e,l,a,c,r,o)=>{const i=e.nodeTypes;switch(r){case i.heading[1]:return`# ${l}
|
|
75
75
|
`;case i.heading[2]:return`## ${l}
|