@frontify/fondue 12.0.0-beta.336 → 12.0.0-beta.337
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/RichTextEditor/Plugins/AutoformatPlugin/index.es.js +32 -25
- package/dist/components/RichTextEditor/Plugins/AutoformatPlugin/index.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,86 +1,93 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { TextStyles as
|
|
5
|
-
import { ELEMENT_CHECK_ITEM as
|
|
6
|
-
class
|
|
1
|
+
import { Plugin as p } from "../Plugin.es.js";
|
|
2
|
+
import { AUTOFORMAT_PLUGIN as i } from "./id.es.js";
|
|
3
|
+
import { createAutoformatPlugin as u, autoformatPunctuation as c, autoformatArrow as n, autoformatLegal as s, autoformatSubscriptNumbers as l, autoformatSubscriptSymbols as d, autoformatSuperscriptNumbers as y, autoformatSuperscriptSymbols as f, MARK_UNDERLINE as g, MARK_BOLD as h, MARK_ITALIC as E, MARK_STRIKETHROUGH as T, MARK_CODE as b, ELEMENT_UL as r, unwrapList as m, toggleList as e, ELEMENT_OL as a } from "@udecode/plate";
|
|
4
|
+
import { TextStyles as o } from "../TextStylePlugin/types.es.js";
|
|
5
|
+
import { ELEMENT_CHECK_ITEM as k } from "../CheckboxListPlugin/id.es.js";
|
|
6
|
+
class S extends p {
|
|
7
7
|
constructor(t) {
|
|
8
|
-
super(
|
|
8
|
+
super(i, {
|
|
9
9
|
...t
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
plugins() {
|
|
13
13
|
return [
|
|
14
|
-
|
|
14
|
+
u({
|
|
15
15
|
options: {
|
|
16
16
|
rules: [
|
|
17
|
+
...c,
|
|
18
|
+
...n,
|
|
19
|
+
...s,
|
|
20
|
+
...l,
|
|
21
|
+
...d,
|
|
22
|
+
...y,
|
|
23
|
+
...f,
|
|
17
24
|
{
|
|
18
25
|
mode: "mark",
|
|
19
|
-
type: [
|
|
26
|
+
type: [g],
|
|
20
27
|
match: ["_", "_"],
|
|
21
28
|
ignoreTrim: !0
|
|
22
29
|
},
|
|
23
30
|
{
|
|
24
31
|
mode: "mark",
|
|
25
|
-
type: [
|
|
32
|
+
type: [h],
|
|
26
33
|
match: ["**", "**"],
|
|
27
34
|
ignoreTrim: !0
|
|
28
35
|
},
|
|
29
36
|
{
|
|
30
37
|
mode: "mark",
|
|
31
|
-
type: [
|
|
38
|
+
type: [E],
|
|
32
39
|
match: ["*", "*"],
|
|
33
40
|
ignoreTrim: !0
|
|
34
41
|
},
|
|
35
42
|
{
|
|
36
43
|
mode: "mark",
|
|
37
|
-
type: [
|
|
44
|
+
type: [T],
|
|
38
45
|
match: ["~~", "~~"],
|
|
39
46
|
ignoreTrim: !0
|
|
40
47
|
},
|
|
41
48
|
{
|
|
42
49
|
mode: "mark",
|
|
43
|
-
type: [
|
|
50
|
+
type: [b],
|
|
44
51
|
match: ["`", "`"],
|
|
45
52
|
ignoreTrim: !0
|
|
46
53
|
},
|
|
47
54
|
{
|
|
48
55
|
mode: "block",
|
|
49
56
|
match: ["# "],
|
|
50
|
-
type:
|
|
57
|
+
type: o.heading1
|
|
51
58
|
},
|
|
52
59
|
{
|
|
53
60
|
mode: "block",
|
|
54
61
|
match: ["## "],
|
|
55
|
-
type:
|
|
62
|
+
type: o.heading2
|
|
56
63
|
},
|
|
57
64
|
{
|
|
58
65
|
mode: "block",
|
|
59
66
|
match: ["### "],
|
|
60
|
-
type:
|
|
67
|
+
type: o.heading3
|
|
61
68
|
},
|
|
62
69
|
{
|
|
63
70
|
mode: "block",
|
|
64
71
|
match: ["#### "],
|
|
65
|
-
type:
|
|
72
|
+
type: o.heading4
|
|
66
73
|
},
|
|
67
74
|
{
|
|
68
75
|
mode: "block",
|
|
69
|
-
type:
|
|
76
|
+
type: r,
|
|
70
77
|
match: ["- "],
|
|
71
|
-
preFormat:
|
|
72
|
-
format: (t) =>
|
|
78
|
+
preFormat: m,
|
|
79
|
+
format: (t) => e(t, { type: r })
|
|
73
80
|
},
|
|
74
81
|
{
|
|
75
82
|
mode: "block",
|
|
76
83
|
type: a,
|
|
77
|
-
match: ["1. "],
|
|
78
|
-
preFormat:
|
|
79
|
-
format: (t) =>
|
|
84
|
+
match: ["1. ", "1) "],
|
|
85
|
+
preFormat: m,
|
|
86
|
+
format: (t) => e(t, { type: a })
|
|
80
87
|
},
|
|
81
88
|
{
|
|
82
89
|
mode: "block",
|
|
83
|
-
type:
|
|
90
|
+
type: k,
|
|
84
91
|
match: ["[] "]
|
|
85
92
|
}
|
|
86
93
|
]
|
|
@@ -90,6 +97,6 @@ class L extends u {
|
|
|
90
97
|
}
|
|
91
98
|
}
|
|
92
99
|
export {
|
|
93
|
-
|
|
100
|
+
S as AutoformatPlugin
|
|
94
101
|
};
|
|
95
102
|
//# sourceMappingURL=index.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/AutoformatPlugin/index.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../../../../src/components/RichTextEditor/Plugins/AutoformatPlugin/index.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { Plugin, PluginProps } from '../Plugin';\nimport { AUTOFORMAT_PLUGIN } from './id';\nimport {\n ELEMENT_OL,\n ELEMENT_UL,\n MARK_BOLD,\n MARK_CODE,\n MARK_ITALIC,\n MARK_STRIKETHROUGH,\n MARK_UNDERLINE,\n autoformatArrow,\n autoformatLegal,\n autoformatPunctuation,\n autoformatSubscriptNumbers,\n autoformatSubscriptSymbols,\n autoformatSuperscriptNumbers,\n autoformatSuperscriptSymbols,\n createAutoformatPlugin,\n toggleList,\n unwrapList,\n} from '@udecode/plate';\nimport { TextStyles } from '../TextStylePlugin';\nimport { ELEMENT_CHECK_ITEM } from '../CheckboxListPlugin';\n\nexport class AutoformatPlugin extends Plugin {\n constructor(props?: PluginProps) {\n super(AUTOFORMAT_PLUGIN, {\n ...props,\n });\n }\n\n plugins() {\n return [\n createAutoformatPlugin({\n options: {\n rules: [\n ...autoformatPunctuation,\n ...autoformatArrow,\n ...autoformatLegal,\n ...autoformatSubscriptNumbers,\n ...autoformatSubscriptSymbols,\n ...autoformatSuperscriptNumbers,\n ...autoformatSuperscriptSymbols,\n {\n mode: 'mark',\n type: [MARK_UNDERLINE],\n match: ['_', '_'],\n ignoreTrim: true,\n },\n {\n mode: 'mark',\n type: [MARK_BOLD],\n match: ['**', '**'],\n ignoreTrim: true,\n },\n {\n mode: 'mark',\n type: [MARK_ITALIC],\n match: ['*', '*'],\n ignoreTrim: true,\n },\n {\n mode: 'mark',\n type: [MARK_STRIKETHROUGH],\n match: ['~~', '~~'],\n ignoreTrim: true,\n },\n {\n mode: 'mark',\n type: [MARK_CODE],\n match: ['`', '`'],\n ignoreTrim: true,\n },\n {\n mode: 'block',\n match: ['# '],\n type: TextStyles.heading1,\n },\n {\n mode: 'block',\n match: ['## '],\n type: TextStyles.heading2,\n },\n {\n mode: 'block',\n match: ['### '],\n type: TextStyles.heading3,\n },\n {\n mode: 'block',\n match: ['#### '],\n type: TextStyles.heading4,\n },\n {\n mode: 'block',\n type: ELEMENT_UL,\n match: ['- '],\n preFormat: unwrapList,\n format: (editor) => toggleList(editor, { type: ELEMENT_UL }),\n },\n {\n mode: 'block',\n type: ELEMENT_OL,\n match: ['1. ', '1) '],\n preFormat: unwrapList,\n format: (editor) => toggleList(editor, { type: ELEMENT_OL }),\n },\n {\n mode: 'block',\n type: ELEMENT_CHECK_ITEM,\n match: ['[] '],\n },\n ],\n },\n }),\n ];\n }\n}\n"],"names":["AutoformatPlugin","Plugin","props","AUTOFORMAT_PLUGIN","createAutoformatPlugin","autoformatPunctuation","autoformatArrow","autoformatLegal","autoformatSubscriptNumbers","autoformatSubscriptSymbols","autoformatSuperscriptNumbers","autoformatSuperscriptSymbols","MARK_UNDERLINE","MARK_BOLD","MARK_ITALIC","MARK_STRIKETHROUGH","MARK_CODE","TextStyles","ELEMENT_UL","unwrapList","editor","toggleList","ELEMENT_OL","ELEMENT_CHECK_ITEM"],"mappings":";;;;;AA0BO,MAAMA,UAAyBC,EAAO;AAAA,EACzC,YAAYC,GAAqB;AAC7B,UAAMC,GAAmB;AAAA,MACrB,GAAGD;AAAA,IAAA,CACN;AAAA,EACL;AAAA,EAEA,UAAU;AACC,WAAA;AAAA,MACHE,EAAuB;AAAA,QACnB,SAAS;AAAA,UACL,OAAO;AAAA,YACH,GAAGC;AAAA,YACH,GAAGC;AAAA,YACH,GAAGC;AAAA,YACH,GAAGC;AAAA,YACH,GAAGC;AAAA,YACH,GAAGC;AAAA,YACH,GAAGC;AAAA,YACH;AAAA,cACI,MAAM;AAAA,cACN,MAAM,CAACC,CAAc;AAAA,cACrB,OAAO,CAAC,KAAK,GAAG;AAAA,cAChB,YAAY;AAAA,YAChB;AAAA,YACA;AAAA,cACI,MAAM;AAAA,cACN,MAAM,CAACC,CAAS;AAAA,cAChB,OAAO,CAAC,MAAM,IAAI;AAAA,cAClB,YAAY;AAAA,YAChB;AAAA,YACA;AAAA,cACI,MAAM;AAAA,cACN,MAAM,CAACC,CAAW;AAAA,cAClB,OAAO,CAAC,KAAK,GAAG;AAAA,cAChB,YAAY;AAAA,YAChB;AAAA,YACA;AAAA,cACI,MAAM;AAAA,cACN,MAAM,CAACC,CAAkB;AAAA,cACzB,OAAO,CAAC,MAAM,IAAI;AAAA,cAClB,YAAY;AAAA,YAChB;AAAA,YACA;AAAA,cACI,MAAM;AAAA,cACN,MAAM,CAACC,CAAS;AAAA,cAChB,OAAO,CAAC,KAAK,GAAG;AAAA,cAChB,YAAY;AAAA,YAChB;AAAA,YACA;AAAA,cACI,MAAM;AAAA,cACN,OAAO,CAAC,IAAI;AAAA,cACZ,MAAMC,EAAW;AAAA,YACrB;AAAA,YACA;AAAA,cACI,MAAM;AAAA,cACN,OAAO,CAAC,KAAK;AAAA,cACb,MAAMA,EAAW;AAAA,YACrB;AAAA,YACA;AAAA,cACI,MAAM;AAAA,cACN,OAAO,CAAC,MAAM;AAAA,cACd,MAAMA,EAAW;AAAA,YACrB;AAAA,YACA;AAAA,cACI,MAAM;AAAA,cACN,OAAO,CAAC,OAAO;AAAA,cACf,MAAMA,EAAW;AAAA,YACrB;AAAA,YACA;AAAA,cACI,MAAM;AAAA,cACN,MAAMC;AAAA,cACN,OAAO,CAAC,IAAI;AAAA,cACZ,WAAWC;AAAA,cACX,QAAQ,CAACC,MAAWC,EAAWD,GAAQ,EAAE,MAAMF,GAAY;AAAA,YAC/D;AAAA,YACA;AAAA,cACI,MAAM;AAAA,cACN,MAAMI;AAAA,cACN,OAAO,CAAC,OAAO,KAAK;AAAA,cACpB,WAAWH;AAAA,cACX,QAAQ,CAACC,MAAWC,EAAWD,GAAQ,EAAE,MAAME,GAAY;AAAA,YAC/D;AAAA,YACA;AAAA,cACI,MAAM;AAAA,cACN,MAAMC;AAAA,cACN,OAAO,CAAC,KAAK;AAAA,YACjB;AAAA,UACJ;AAAA,QACJ;AAAA,MAAA,CACH;AAAA,IAAA;AAAA,EAET;AACJ;"}
|
package/dist/index.cjs.js
CHANGED
|
@@ -36,7 +36,7 @@ ${j2("Ctrl+B")}`),type:w.getPluginType(e,l),icon:t.jsx(p0,{icon:t.jsx(n3,{})}),c
|
|
|
36
36
|
`]},jh0={renderAfterEditable:vh0};class IT extends t0{constructor(l){super(uh0,{button:xh0,showIn:[c0.BOTTOM,c0.TOP],...l})}plugins(){return[w.createComboboxPlugin(),w.createEmojiPlugin(jh0)]}}const Ch0="soft-break-plugin";class ZT extends t0{constructor(l){super(Ch0,{...l})}plugins(){return[w.createSoftBreakPlugin()]}}const Mh0="italic-plugin",k5="tw-italic",pT=({attributes:e,children:l})=>t.jsx("span",{...e,className:k5,children:l});class NT extends e0{constructor(l=w.MARK_ITALIC,o=pT){super(l,o)}}const Ih0=({editor:e,id:l})=>t.jsx(C0,{id:l,children:t.jsx(w.MarkToolbarButton,{tooltip:b0(`Italic
|
|
37
37
|
${j2("Ctrl+I")}`),type:w.getPluginType(e,l),icon:t.jsx(p0,{icon:t.jsx(a3,{})}),classNames:j0(),styles:N0,actionHandler:"onMouseDown"})}),Zh0=[{validNodeName:["EM","I"]},{validStyle:{fontStyle:"italic"}}];class ST extends t0{constructor(l){super(Mh0,{button:Ih0,markupElement:new NT,...l})}plugins(){return[w.createItalicPlugin({deserializeHtml:{rules:[...Zh0,{validNodeName:["SPAN"],validClassName:k5}]},options:{hotkey:["mod+i","ctrl+i"]}})]}}const ph0=e=>!!e.match(/^(https?:\/\/|mailto:|tel:).+/),Nh0=w.createComponentAs(e=>{var o;const l=w.useFloatingLinkInsert({...e,floatingOptions:{strategy:"fixed"}});return((o=l.style)==null?void 0:o.display)==="none"?null:w.createElementAs("div",l)}),Sh0=w.createComponentAs(e=>{var o;const l=kh0({...e,floatingOptions:{strategy:"fixed"}});return((o=l.style)==null?void 0:o.display)==="none"?null:w.createElementAs("div",l)});w.FloatingLink.EditRoot=Sh0;w.FloatingLink.InsertRoot=Nh0;const X2=w.FloatingLink,T1="link-plugin",yh0=()=>{const e=w.useFloatingLinkUrlInput({}),{styles:l}=C1();return t.jsx("div",{"data-test-id":"floating-link-edit",className:"tw-bg-white tw-rounded tw-shadow tw-p-4 tw-min-w-[400px]",children:t.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between",children:[t.jsx("span",{style:l[T1],className:"tw-pointer-events-none",children:e.defaultValue}),t.jsxs("span",{className:"tw-flex tw-gap-2",children:[t.jsx("span",{role:"button",tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:t.jsx(X2.EditButton,{children:t.jsx(Ge,{})})}),t.jsx("span",{role:"button",tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:t.jsx(X2.UnlinkButton,{children:t.jsx(i3,{})})})]})]})})},d7=(e,l)=>{const o=w.getAboveNode(e,{match:{type:w.ELEMENT_LINK}});return Array.isArray(o)?l(o[0]):""},Rh0=e=>d7(e,l=>{var o,i;return((i=(o=l.chosenLink)==null?void 0:o.searchResult)==null?void 0:i.link)||""}),bh0=e=>d7(e,l=>l.url||""),yT=e=>{var l,o;return e.url||((o=(l=e.chosenLink)==null?void 0:l.searchResult)==null?void 0:o.link)||""},Hh0=e=>d7(e,yT),kh0=({floatingOptions:e,...l})=>{const o=w.useEditorRef(),i=w.usePlateSelectors().keyEditor(),s=w.useFloatingLinkSelectors().mode(),r=w.useFloatingLinkSelectors().isOpen(o.id),{triggerFloatingLinkHotkeys:c="command+k, ctrl+k"}=w.getPluginOptions(o,w.ELEMENT_LINK),d=n.useCallback(()=>{const f=w.getAboveNode(o,{match:{type:w.getPluginType(o,w.ELEMENT_LINK)}});if(f){const[,g]=f;return w.getRangeBoundingClientRect(o,{anchor:w.getStartPoint(o,g),focus:w.getEndPoint(o,g)})}return w.getDefaultBoundingClientRect()},[o]),h=r&&s==="edit",{update:u,style:L,floating:m}=w.useVirtualFloatingLink({editorId:o.id,open:h,getBoundingClientRect:d,...e});return n.useEffect(()=>{const f=Hh0(o);if(f&&w.floatingLinkActions.url(f),o.selection&&w.someNode(o,{match:{type:w.getPluginType(o,w.ELEMENT_LINK)}})){w.floatingLinkActions.show("edit",o.id),u();return}w.floatingLinkSelectors.mode()==="edit"&&w.floatingLinkActions.hide()},[o,i,u]),w.useHotkeys(c,f=>{f.preventDefault(),w.floatingLinkSelectors.mode()==="edit"&&w.triggerFloatingLinkEdit(o)},{enableOnContentEditable:!0},[]),w.useFloatingLinkEnter(),w.useFloatingLinkEscape(),{style:{...L,zIndex:1},...l,ref:w.useComposedRef(l.ref,m)}},zh0=({state:e,onTextChange:l,onUrlChange:o,onToggleTab:i,onCancel:s,onSave:r,isValidUrlOrEmpty:c,hasValues:d,testId:h,children:u})=>t.jsxs("div",{"data-test-id":h,className:"tw-bg-white tw-rounded tw-shadow tw-p-7 tw-min-w-[400px] tw-overflow-y-auto",children:[t.jsx(Y2,{label:{children:"Text",htmlFor:"linkText",required:!0},children:t.jsx(m1,{id:"linkText",value:e.text,placeholder:"Link Text",onChange:l})}),u,t.jsxs("div",{className:"tw-pt-5",children:[t.jsx(Y2,{label:{children:"URL",htmlFor:"url",required:!0},children:t.jsx(m1,{id:"url",value:e.url,placeholder:"https://example.com",focusOnMount:!0,onChange:o})}),!c()&&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(j1,{value:"new-tab",label:"Open in new tab",state:e.newTab,onChange:i})}),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:s,size:a0.Medium,style:X.Default,emphasis:h0.Default,children:"Cancel"}),t.jsx(y0,{onClick:r,size:a0.Medium,icon:t.jsx(ze,{}),disabled:!c()||!d,children:"Save"})]})})]}),Th0={url:"",text:"",newTab:x0.Unchecked},Vh0=()=>{const[e,l]=n.useReducer((o,i)=>{const{type:s,payload:r}=i;switch(s){case"NEW_TAB":return{...o,newTab:x0.Checked};case"SAME_TAB":return{...o,newTab:x0.Unchecked};case"URL":case"TEXT":case"INIT":return{...o,...r};default:return o}},Th0);return[e,l]},Dh0=()=>{const e=w.useEditorRef(),[l,o]=Vh0();n.useEffect(()=>{const L=Rh0(e),m=bh0(e);o({type:"INIT",payload:{text:w.floatingLinkSelectors.text(),newTab:w.floatingLinkSelectors.newTab()?x0.Checked:x0.Unchecked,url:L&&m===""?L:w.floatingLinkSelectors.url()}})},[o,e]);const i=L=>{o({type:"TEXT",payload:{text:L}})},s=L=>{o({type:"URL",payload:{url:L}})},r=L=>{o(L?{type:"NEW_TAB"}:{type:"SAME_TAB"})},c=()=>{w.floatingLinkActions.hide()},d=L=>{!u()||!h||(w.floatingLinkActions.text(l.text),w.floatingLinkActions.url(l.url),w.floatingLinkActions.newTab(l.newTab===x0.Checked),w.submitFloatingLink(e)&&(L==null||L.preventDefault()))},h=l.url!==""&&l.text!=="",u=()=>{const{isUrl:L}=w.getPluginOptions(e,w.ELEMENT_LINK);return!l.url||L&&L(l.url)};return w.useHotkeys("enter",d,{enableOnFormTags:["INPUT"]},[]),{state:l,onTextChange:i,onUrlChange:s,onToggleTab:r,onCancel:c,onSave:d,hasValues:h,isValidUrlOrEmpty:u}},Fh0=()=>t.jsx(zh0,{...Dh0(),testId:"floating-link-insert"}),Bh0=({readOnly:e})=>{const l=w.useFloatingLinkSelectors().isEditing();if(e)return null;const o=t.jsx(Fh0,{}),i=l?o:t.jsx(yh0,{});return t.jsxs(t.Fragment,{children:[t.jsx(X2.InsertRoot,{children:o}),t.jsx(X2.EditRoot,{children:i})]})},Oh0=({id:e,editorId:l})=>{const o=w.usePlateEditorState(w.useEventPlateId(l)),i=!!w.isRangeInSameBlock(o,{at:o.selection}),s=j0(i);return t.jsx(C0,{id:e,children:t.jsx(w.LinkToolbarButton,{tooltip:b0(i?`Link
|
|
38
38
|
${j2("Ctrl+K")}`:"Links can only be set for a single text block."),icon:t.jsx(p0,{icon:t.jsx(Pe,{})}),classNames:s,styles:N0,actionHandler:"onMouseDown"})})},Ph0=e=>({...w.useElementProps({...e,elementToAttributes:o=>({href:yT(o),target:o.target||"_self"})}),onMouseOver:o=>{o.stopPropagation()}}),Uh0=e=>{const l=Ph0(e),{attributes:o,children:i}=e,{styles:s}=C1();return t.jsx("a",{...o,href:l.href,target:l.target,style:s[T1],children:i})};class Qh0 extends e0{constructor(l=w.ELEMENT_LINK,o=Uh0){super(l,o)}}const RT=w.createPluginFactory({...w.createLinkPlugin(),renderAfterEditable:Bh0,options:{isUrl:ph0,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"command+k, ctrl+k"}});class bT extends t0{constructor({styles:o=R0[T1],...i}={}){super(T1,{button:Oh0,markupElement:new Qh0,...i});W(this,"styles",{});this.styles=o}plugins(){return[RT()]}}const h7="tw-border-b tw-border-dashed tw-border-line-x-strong tw-pb-5",HT=`${h7} tw-break-after-column tw-break-inside-avoid-column`,D0=e=>{const l=e.breakAfterColumn;return v([l==="active"&&HT,l==="inactive"&&h7])},L7=e=>v([D0(e),e.align?i7[e.align]:"tw-justify-start","tw-grid tw-grid-cols-[min-content_repeat(3,_auto)]"]),kT=({attributes:e,children:l,element:o})=>t.jsx("p",{className:L7(o),...e,children:t.jsx("span",{className:"tw-w-auto tw-min-w-[10px]",children:l})});class zT extends e0{constructor(l=w.ELEMENT_LIC,o=kT){super(l,o)}}const TT="text-style-plugin",z5="list-plugin",Yh0=(e,{options:{validLiChildrenTypes:l,isSoftBreak:o}})=>{const{insertBreak:i,deleteBackward:s,deleteForward:r,deleteFragment:c}=e;return o?e.insertSoftBreak=()=>{w.insertBreakList(e)||i()}:e.insertBreak=()=>{w.insertBreakList(e)||i()},e.deleteBackward=d=>{w.deleteBackwardList(e,d)||s(d)},e.deleteForward=d=>{w.deleteForwardList(e)||r(d)},e.deleteFragment=d=>{w.deleteFragmentList(e)||c(d)},e.insertFragment=w.insertFragmentList(e),e.normalizeNode=w.normalizeList(e,{validLiChildrenTypes:l}),e},a2="textStyle",VT=w.createPluginFactory({key:a2,isLeaf:!0});class u7 extends t0{constructor(o){super(z5,{leafMarkupElements:[new zT,new WT],...o});W(this,"isSoftBreak");this.isSoftBreak=(o==null?void 0:o.isSoftBreak)??!1}plugins(){return[w.createListPlugin({withOverrides:Yh0,options:{isSoftBreak:this.isSoftBreak}}),VT()]}}const Eh0=e=>w.getAboveNode(e,{match:{type:w.ELEMENT_LI},mode:"lowest"})||w.someNode(e,{match:{type:G0},mode:"lowest"}),Gh0=({editor:e,type:l,children:o})=>{const i=e!=null&&e.selection?w.getMark(e,a2)===l.id:w.someNode(e,{match:{type:l}});return t.jsx("button",{"data-test-id":"textstyle-option",type:"button",className:v(["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]",i?"tw-text-box-neutral-inverse tw-bg-box-neutral":"tw-text-text"]),onMouseDown:s=>{s.preventDefault(),s.stopPropagation(),!(!e||!e.selection)&&(w.setMarks(e,{[a2]:l.id}),Eh0(e)||w.toggleNodeType(e,{activeType:l.id,inactiveType:l.id}))},children:o})},Wh0=({label:e,open:l,onClick:o},i)=>t.jsx("button",{ref:i,"data-test-id":"textstyle-dropdown-trigger",type:"button",className:"tw-cursor-pointer tw-h-8 tw-w-full",onMouseDown:s=>{s.preventDefault(),s.stopPropagation(),o()},children:t.jsxs("div",{className:v(["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:v(["tw-transition-transform",l&&"tw-rotate-180"]),children:t.jsx(ke,{})})]})}),qh0=n.forwardRef(Wh0),Kh0=e=>Array.isArray(e.children)?(e.children.find(o=>w.isText(o))??{})[a2]:w.ELEMENT_PARAGRAPH,$h0=[w.ELEMENT_LI,w.ELEMENT_UL,w.ELEMENT_OL],Xh0=e=>!e||!e.selection?[]:Array.from(w.getNodeEntries(e,{unhang:!0,at:e.selection,reverse:!0})).reduce((o,[i])=>{if(!w.isNode(i))return o;const s=i.type===w.ELEMENT_LIC||i.type===G0?Kh0(i):i.textStyle;return s&&!o.includes(s)&&!$h0.includes(s)&&o.push(s),o},[]),Jh0=6,_h0=10,eL0={name:"vertical-positioning",phase:"read",fn:({state:e,name:l})=>{if(e.modifiersData[l]._skip)return;const{position:o,maxHeight:i}=F3(e.elements.reference,e.rects.popper.height,Jh0+_h0,0);o==="top"&&(e.placement="top-start"),e.styles.popper={maxHeight:`${i}px`},e.reset=!0,e.modifiersData[l]._skip=!0},enabled:!0},J2="Mixed";var T=(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))(T||{});const tL0=e=>{const[l,o]=n.useState(!1),[i,s]=n.useState(null),[r,c]=n.useState(null),d=w.usePlateEditorState(e),h=Xh0(d);let u=J2;h.length===1?u=h[0]:h.length===0&&(u="p");const L=n.useCallback(()=>{o(f=>!f)},[o]),m=B1.usePopper(i,r,{placement:"bottom-start",strategy:"fixed",modifiers:[{name:"offset",options:{offset:[0,6]}},{name:"flip",enabled:!1},eL0]});return n.useEffect(()=>{const f=g=>{if(l){const x=g.target;if(r&&r.contains(x)||i&&i.contains(x))return;o(!1)}};return document.addEventListener("pointerdown",f),()=>{document.removeEventListener("pointerdown",f)}},[l,r,o,i]),{state:{isOpen:l,toggle:L,editor:d},dropdownProps:{...m.attributes.popper,style:m.styles.popper},key:u,dropdownRef:c,triggerRef:s}},lL0=({editorId:e,textStyles:l=[]})=>{var m;const{state:{editor:o,toggle:i,isOpen:s},dropdownProps:r,triggerRef:c,dropdownRef:d,key:h}=tL0(e);let u=J2;const L=l.find(f=>{var g;return f.id===h&&((g=f.props)==null?void 0:g.label)});return L&&(u=((m=L.props)==null?void 0:m.label)||J2),t.jsxs(t.Fragment,{children:[t.jsx(qh0,{label:u,open:s,onClick:i,ref:c}),s&&t.jsx("div",{className:"tw-divide-y tw-divide-line tw-bg-base tw-shadow-md tw-border tw-border-line tw-z-[1000] tw-overflow-auto tw-min-h-[40px]",ref:d,...r,children:l.map(f=>{var g;return t.jsx(Gh0,{editor:o,type:f,children:t.jsx("span",{style:f.styles??{},children:(g=f.props)==null?void 0:g.label})},f.id)})})]})},nL0=({editorId:e,id:l,textStyles:o})=>t.jsx(C0,{id:l,children:t.jsx(lL0,{editorId:e,textStyles:o})}),aL0=(e,l)=>o=>t.jsx(e,{...o,textStyles:l}),oL0="textstyle-custom1-plugin";class iL0 extends t0{constructor({styles:o=R0.custom1,...i}={}){super(T.custom1,{label:"Custom 1",markupElement:new sL0,...i});W(this,"styles",{});this.styles=o}plugins(){return[rL0(this.styles)]}}class sL0 extends e0{constructor(l=oL0,o=DT){super(l,o)}}const DT=({element:e,attributes:l,children:o,styles:i})=>{const s=e.align;return t.jsx("p",{...l,className:v([s&&V0[s],D0(e)]),style:i,children:o})},rL0=e=>w.createPluginFactory({key:T.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:T.custom1}]}})({component:l=>t.jsx(DT,{...l,styles:e})}),cL0="textstyle-custom2-plugin";class dL0 extends t0{constructor({styles:o=R0.custom2,...i}={}){super(T.custom2,{label:"Custom 2",markupElement:new hL0,...i});W(this,"styles",{});this.styles=o}plugins(){return[LL0(this.styles)]}}class hL0 extends e0{constructor(l=cL0,o=FT){super(l,o)}}const FT=({element:e,attributes:l,children:o,styles:i})=>{const s=e.align;return t.jsx("p",{...l,className:v([s&&V0[s],D0(e)]),style:i,children:o})},LL0=e=>w.createPluginFactory({key:T.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:T.custom2}]}})({component:l=>t.jsx(FT,{...l,styles:e})}),uL0="textstyle-custom3-plugin";class wL0 extends t0{constructor({styles:o=R0.custom3,...i}={}){super(T.custom3,{label:"Custom 3",markupElement:new mL0,...i});W(this,"styles",{});this.styles=o}plugins(){return[fL0(this.styles)]}}class mL0 extends e0{constructor(l=uL0,o=BT){super(l,o)}}const BT=({element:e,attributes:l,children:o,styles:i})=>{const s=e.align;return t.jsx("p",{...l,className:v([s&&V0[s],D0(e)]),style:i,children:o})},fL0=e=>w.createPluginFactory({key:T.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:T.custom3}]}})({component:l=>t.jsx(BT,{...l,styles:e})}),xL0="textstyle-heading1-plugin";class vL0 extends t0{constructor({styles:o=R0.heading1,...i}={}){super(T.heading1,{label:"Heading 1",markupElement:new gL0,...i});W(this,"styles",{});this.styles=o}plugins(){return[AL0(this.styles)]}}class gL0 extends e0{constructor(l=xL0,o=re){super(l,o)}}const re=({element:e,attributes:l,children:o,styles:i})=>{const s=e.align;return t.jsx("h1",{...l,className:v([s&&V0[s],D0(e)]),style:i,children:o})},AL0=e=>w.createPluginFactory({key:T.heading1,isElement:!0,component:re,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:l=>t.jsx(re,{...l,styles:e})}),jL0="textstyle-heading2-plugin";class CL0 extends t0{constructor({styles:o=R0.heading2,...i}={}){super(T.heading2,{label:"Heading 2",markupElement:new ML0,...i});W(this,"styles",{});this.styles=o}plugins(){return[IL0(this.styles)]}}class ML0 extends e0{constructor(l=jL0,o=ce){super(l,o)}}const ce=({element:e,attributes:l,children:o,styles:i})=>{const s=e.align;return t.jsx("h2",{...l,className:v([s&&V0[s],D0(e)]),style:i,children:o})},IL0=e=>w.createPluginFactory({key:T.heading2,isElement:!0,component:ce,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:l=>t.jsx(ce,{...l,styles:e})}),ZL0="textstyle-heading3-plugin";class pL0 extends t0{constructor({styles:o=R0.heading3,...i}={}){super(T.heading3,{label:"Heading 3",markupElement:new NL0,...i});W(this,"styles",{});this.styles=o}plugins(){return[SL0(this.styles)]}}class NL0 extends e0{constructor(l=ZL0,o=de){super(l,o)}}const de=({element:e,attributes:l,children:o,styles:i})=>{const s=e.align;return t.jsx("h3",{...l,className:v([s&&V0[s],D0(e)]),style:i,children:o})},SL0=e=>w.createPluginFactory({key:T.heading3,isElement:!0,component:de,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:l=>t.jsx(de,{...l,styles:e})}),yL0="textstyle-heading4-plugin";class RL0 extends t0{constructor({styles:o=R0.heading4,...i}={}){super(T.heading4,{label:"Heading 4",markupElement:new bL0,...i});W(this,"styles",{});this.styles=o}plugins(){return[HL0(this.styles)]}}class bL0 extends e0{constructor(l=yL0,o=he){super(l,o)}}const he=({element:e,attributes:l,children:o,styles:i})=>{const s=e.align;return t.jsx("h4",{...l,className:v([s&&V0[s],D0(e)]),style:i,children:o})},HL0=e=>w.createPluginFactory({key:T.heading4,isElement:!0,component:he,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:l=>t.jsx(he,{...l,styles:e})}),kL0="textstyle-imageCaption-plugin";class zL0 extends t0{constructor({styles:o=R0.imageCaption,...i}={}){super(T.imageCaption,{label:"Image Caption",markupElement:new TL0,...i});W(this,"styles",{});this.styles=o}plugins(){return[VL0(this.styles)]}}class TL0 extends e0{constructor(l=kL0,o=Le){super(l,o)}}const Le=({element:e,attributes:l,children:o,styles:i})=>{const s=e.align;return t.jsx("p",{...l,className:v([s&&V0[s],D0(e)]),style:i,children:o})},VL0=e=>w.createPluginFactory({key:T.imageCaption,isElement:!0,component:Le,deserializeHtml:{rules:[{validClassName:T.imageCaption}]}})({component:l=>t.jsx(Le,{...l,styles:e})}),DL0="textstyle-imageTitle-plugin";class FL0 extends t0{constructor({styles:o=R0.imageTitle,...i}={}){super(T.imageTitle,{label:"Image Title",markupElement:new BL0,...i});W(this,"styles",{});this.styles=o}plugins(){return[OL0(this.styles)]}}class BL0 extends e0{constructor(l=DL0,o=ue){super(l,o)}}const ue=({element:e,attributes:l,children:o,styles:i})=>{const s=e.align;return t.jsx("p",{...l,className:v([s&&V0[s],D0(e)]),style:i,children:o})},OL0=e=>w.createPluginFactory({key:T.imageTitle,isElement:!0,component:ue,deserializeHtml:{rules:[{validClassName:T.imageTitle}]}})({component:l=>t.jsx(ue,{...l,styles:e})});class OT extends t0{constructor({styles:o=R0.p,...i}={}){super(T.p,{markupElement:new UT,label:"Body Text",...i});W(this,"styles",{});this.styles=o}plugins(){return[QT(this.styles)]}}const PT="tw-m-0 tw-px-0 tw-py-0",_2=({element:e,attributes:l,children:o,styles:i})=>{const s=e.align,r=v([s&&V0[s],PT,D0(e)]);return t.jsx("p",{...l,className:r,style:i,children:o})};class UT extends e0{constructor(l=T.p,o=_2){super(l,o)}}const QT=e=>w.createPluginFactory({...w.createParagraphPlugin(),key:T.p,isElement:!0,component:_2})({component:l=>t.jsx(_2,{...l,styles:e})}),PL0="textstyle-quote-plugin";class UL0 extends t0{constructor({styles:o=R0.quote,...i}={}){super(T.quote,{label:"Quote",markupElement:new QL0,...i});W(this,"styles",{});this.styles=o}plugins(){return[YT(this.styles)]}}class QL0 extends e0{constructor(l=PL0,o=e5){super(l,o)}}const e5=({element:e,attributes:l,children:o,styles:i})=>{const s=e.align;return t.jsx("blockquote",{...l,className:v([s&&V0[s],D0(e)]),style:i,children:o})},YT=e=>w.createPluginFactory({key:T.quote,isElement:!0,component:e5,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:l=>t.jsx(e5,{...l,styles:e})});class ET extends t0{constructor({...o}){super(TT,{button:aL0(nL0,o.textStyles),...o});W(this,"textStyles");this.textStyles=o.textStyles}plugins(){return this.textStyles.map(o=>o.plugins()).flat()}}const w7="[&>p]:before:tw-flex [&>p]:before:tw-justify-end [&>p]:before:tw-w-[1.2em] !tw-no-underline !tw-list-item",GT=({attributes:e,children:l,element:o})=>{const{styles:i}=C1();return t.jsx("li",{style:m7(o,i),...e,className:w7,children:l})};class WT extends e0{constructor(l=w.ELEMENT_LI,o=GT){super(l,o)}}const m7=(e,l)=>({...l[qT(e)??T.p],counterIncrement:"count"}),qT=e=>{let l;if(e.type==="a")l=e.children[0].textStyle;else if(e.children)for(const o of e.children){const i=qT(o);i&&(!l||i.startsWith(l))&&(l=i)}else l=e.textStyle;return l},YL0=["[&>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)_'._']"],EL0=(e,l)=>{const o=w.findNodePath(e,l);if(!o)return 0;const i=w.getNodeAncestors(e,o);return Array.from(i).filter(s=>s[0].type===w.ELEMENT_LI).length},f7=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 ${YL0[e%3]}`,x7={counterReset:"count"},KT=({attributes:e,children:l,element:o})=>{const i=w.usePlateEditorRef(),s=EL0(i,o);return t.jsx("ol",{className:f7(s),...e,style:x7,children:l})};class $T extends e0{constructor(l=w.ELEMENT_OL,o=KT){super(l,o)}}const XT=({editor:e,id:l})=>t.jsx(C0,{id:l,children:t.jsx(w.ListToolbarButton,{tooltip:b0("Ordered list"),type:w.getPluginType(e,l),icon:t.jsx(p0,{icon:t.jsx(Ye,{})}),classNames:j0(),styles:N0,actionHandler:"onMouseDown"})});class JT extends u7{constructor(l){super({id:z5,button:XT,markupElement:new $T,...l})}}const v7="[&>li>p]:before:tw-content-['•'] [&>li>p]:before:tw-px-2 tw-list-none tw-pl-[10px] tw-mb-[10px] tw-ml-[15px]",_T=({attributes:e,children:l})=>t.jsx("ul",{className:v7,...e,children:l});class eV extends e0{constructor(l=w.ELEMENT_UL,o=_T){super(l,o)}}const tV=({editor:e,id:l})=>t.jsx(C0,{id:l,children:t.jsx(w.ListToolbarButton,{tooltip:b0("Bullet list"),type:w.getPluginType(e,l),icon:t.jsx(p0,{icon:t.jsx(Ue,{})}),classNames:j0(),styles:N0,actionHandler:"onMouseDown"})});class lV extends u7{constructor(l){super({id:z5,button:tV,markupElement:new eV,...l})}}class GL0{constructor(){W(this,"toolbarButtons",{[c0.BOTTOM]:[],[c0.FLOATING]:[],[c0.TOP]:[]})}createGroupOfButtons(l){const o=[],i=[],s=[];for(const{markupElement:r,button:c,id:d,showIn:h}of l){if(!c)continue;const u={id:(r==null?void 0:r.getId())||d,button:c};h.includes(c0.BOTTOM)&&o.push(u),h.includes(c0.TOP)&&i.push(u),h.includes(c0.FLOATING)&&s.push(u)}o.length>0&&this.toolbarButtons[c0.BOTTOM].push(o),i.length>0&&this.toolbarButtons[c0.TOP].push(i),s.length>0&&this.toolbarButtons[c0.FLOATING].push(s)}at(l){return this.toolbarButtons[l]}}class nV{constructor(l){W(this,"platePlugins",new Map);W(this,"markupElements",{});W(this,"inlineElements",[]);W(this,"toolbarButtons",new GL0);W(this,"styles",{});this.props=l}setPlugin(...l){for(const o of l){const i=Array.isArray(o)?o:[o];for(const s of i)this.addElement(s.markupElement),this.addElement(s.markupInputElement),this.addLeafElements(s.leafMarkupElements),this.addPlugin(s),this.addInline(s.inline()),s.styles&&this.addStyles(s.styles,s.id),s.textStyles&&this.addTextStylesOfSubPlugins(s.textStyles);this.hasToolbar&&this.toolbarButtons.createGroupOfButtons(i)}return this}addTextStylesOfSubPlugins(l){for(const o of l)o.styles&&this.addStyles(o.styles,o.id)}addLeafElements(l){if(l===void 0)return;const o=Array.isArray(l)?l:[l];for(const i of o)this.addElement(i)}addElement(l){if(l===void 0)return;const o=l.getId(),i=l.getNode();i&&!this.markupElements[o]&&(this.markupElements[o]=i)}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,o){this.styles[o]=l}get elements(){return{...this.defaultElementsFromPlugins,...this.markupElements}}get defaultElementsFromPlugins(){const l={};for(const o of this.platePlugins.values())for(const i of o){const{key:s,component:r}=i;r&&(l[s]=r)}return l}get plugins(){const l=[];for(const o of this.platePlugins.values())l.push(...o);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 aV="reset-formatting-plugin",oV="reset-formatting",WL0=e=>{!e||!e.selection||(w.removeMark(e,{key:[w.MARK_BOLD,w.MARK_ITALIC,w.MARK_CODE,w.MARK_UNDERLINE,w.MARK_STRIKETHROUGH]}),w.unwrapList(e,{}),w.setElements(e,{type:w.ELEMENT_PARAGRAPH,align:void 0}))},qL0=w.withPlateProvider(({id:e,...l})=>{const o=w.usePlateEditorState(w.useEventPlateId(e));return t.jsx(w.ToolbarButton,{tooltip:b0("Clear formatting"),onMouseDown:()=>{WL0(o)},...l})}),KL0=({id:e})=>t.jsx(C0,{id:e,children:t.jsx(qL0,{icon:t.jsx(p0,{icon:t.jsx(Fe,{})}),classNames:j0(),styles:N0})}),iV=w.createPluginFactory({key:oV,isElement:!1});class sV extends t0{constructor(l){super(aV,{button:KL0,...l})}plugins(){return[iV()]}}const $L0="strikethrough-plugin",g7="!tw-line-through",rV=({attributes:e,children:l})=>t.jsx("span",{...e,className:g7,children:l});class cV extends e0{constructor(l=w.MARK_STRIKETHROUGH,o=rV){super(l,o)}}const XL0=({editor:e,id:l})=>t.jsx(C0,{id:l,children:t.jsx(w.MarkToolbarButton,{tooltip:b0("Strikethrough"),type:w.getPluginType(e,l),icon:t.jsx(p0,{icon:t.jsx(vb,{})}),classNames:j0(),styles:N0,actionHandler:"onMouseDown"})});class dV extends t0{constructor(l){super($L0,{button:XL0,markupElement:new cV,...l})}plugins(){return[w.createStrikethroughPlugin()]}}const JL0="underline-plugin",T5="tw-underline",hV=({attributes:e,children:l})=>t.jsx("span",{...e,className:T5,children:l});class LV extends e0{constructor(l=w.MARK_UNDERLINE,o=hV){super(l,o)}}const _L0=({editor:e,id:l})=>t.jsx(C0,{id:l,children:t.jsx(w.MarkToolbarButton,{tooltip:b0(`Underline
|
|
39
|
-
${j2("Ctrl+U")}`),type:w.getPluginType(e,l),icon:t.jsx(p0,{icon:t.jsx(o3,{})}),classNames:j0(),styles:N0,actionHandler:"onMouseDown"})}),eu0=[{validNodeName:["U"]},{validStyle:{textDecoration:["underline"]}}];class uV extends t0{constructor(l){super(JL0,{button:_L0,markupElement:new LV,...l})}plugins(){return[w.createUnderlinePlugin({deserializeHtml:{rules:[...eu0,{validNodeName:["SPAN"],validClassName:T5}]},options:{hotkey:["mod+u","ctrl+u"]}})]}}const tu0="autoformat-plugin";class lu0 extends t0{constructor(l){super(tu0,{...l})}plugins(){return[w.createAutoformatPlugin({options:{rules:[{mode:"mark",type:[w.MARK_UNDERLINE],match:["_","_"],ignoreTrim:!0},{mode:"mark",type:[w.MARK_BOLD],match:["**","**"],ignoreTrim:!0},{mode:"mark",type:[w.MARK_ITALIC],match:["*","*"],ignoreTrim:!0},{mode:"mark",type:[w.MARK_STRIKETHROUGH],match:["~~","~~"],ignoreTrim:!0},{mode:"mark",type:[w.MARK_CODE],match:["`","`"],ignoreTrim:!0},{mode:"block",match:["# "],type:T.heading1},{mode:"block",match:["## "],type:T.heading2},{mode:"block",match:["### "],type:T.heading3},{mode:"block",match:["#### "],type:T.heading4},{mode:"block",type:w.ELEMENT_UL,match:["- "],preFormat:w.unwrapList,format:l=>w.toggleList(l,{type:w.ELEMENT_UL})},{mode:"block",type:w.ELEMENT_OL,match:["1. "],preFormat:w.unwrapList,format:l=>w.toggleList(l,{type:w.ELEMENT_OL})},{mode:"block",type:G0,match:["[] "]}]}})]}}const wV=e=>Array.from(w.getNodeEntries(e,{at:[],match:l=>!!l.breakAfterColumn})).length,o2=(e,{key:l=E1,value:o,at:i})=>{const s=r=>w.isBlock(e,r);o?w.setElements(e,{[l]:o},{mode:"lowest",match:s,at:i}):w.unsetNodes(e,l,{match:s,mode:"lowest",at:i})},nu0=(e,l,o)=>{o2(e,{at:l,value:o})},we=(e,l)=>{const o=Array.from(w.getNodeEntries(e,{at:[],match:i=>!!i.breakAfterColumn}));for(const[i,[,s]]of o.entries())nu0(e,s,i<l-1?"active":"inactive")},mV=(e,l,o)=>{if(o.preventDefault(),o.stopPropagation(),!!(e!=null&&e.selection)&&w.someNode(e,{match:s=>!!s.breakAfterColumn}))o2(e,{value:void 0});else{const s=wV(e),r=Math.max(l-s-1,0);if(r===0)return;const c=Array.from(w.getNodeEntries(e,{at:e.selection,match:d=>w.isBlock(e,d),mode:"lowest"})).slice(-r);for(const d of c)o2(e,{value:"active",at:d[1]})}we(e,l)},au0=(e,{options:{hotkey:l}})=>o=>{var i;if(!o.defaultPrevented&&l&&hF(l,o)){const s=e.plugins.find(c=>c.key===E1),r=((i=s==null?void 0:s.options)==null?void 0:i.columns)??1;mV(e,r,o)}},ou0=({id:e,...l})=>{var h,u;const o=w.usePlateEditorState(w.useEventPlateId(e)),i=!!(o!=null&&o.selection)&&w.someNode(o,{match:L=>!!L.breakAfterColumn}),s=(u=(h=o==null?void 0:o.pluginsByKey.breakAfterColumn)==null?void 0:h.options)==null?void 0:u.columns,r=Number(s)||1,c=iu0(o,r,i),d=j0(c);return t.jsx(w.ToolbarButton,{active:i,tooltip:b0(c?`Column Break
|
|
39
|
+
${j2("Ctrl+U")}`),type:w.getPluginType(e,l),icon:t.jsx(p0,{icon:t.jsx(o3,{})}),classNames:j0(),styles:N0,actionHandler:"onMouseDown"})}),eu0=[{validNodeName:["U"]},{validStyle:{textDecoration:["underline"]}}];class uV extends t0{constructor(l){super(JL0,{button:_L0,markupElement:new LV,...l})}plugins(){return[w.createUnderlinePlugin({deserializeHtml:{rules:[...eu0,{validNodeName:["SPAN"],validClassName:T5}]},options:{hotkey:["mod+u","ctrl+u"]}})]}}const tu0="autoformat-plugin";class lu0 extends t0{constructor(l){super(tu0,{...l})}plugins(){return[w.createAutoformatPlugin({options:{rules:[...w.autoformatPunctuation,...w.autoformatArrow,...w.autoformatLegal,...w.autoformatSubscriptNumbers,...w.autoformatSubscriptSymbols,...w.autoformatSuperscriptNumbers,...w.autoformatSuperscriptSymbols,{mode:"mark",type:[w.MARK_UNDERLINE],match:["_","_"],ignoreTrim:!0},{mode:"mark",type:[w.MARK_BOLD],match:["**","**"],ignoreTrim:!0},{mode:"mark",type:[w.MARK_ITALIC],match:["*","*"],ignoreTrim:!0},{mode:"mark",type:[w.MARK_STRIKETHROUGH],match:["~~","~~"],ignoreTrim:!0},{mode:"mark",type:[w.MARK_CODE],match:["`","`"],ignoreTrim:!0},{mode:"block",match:["# "],type:T.heading1},{mode:"block",match:["## "],type:T.heading2},{mode:"block",match:["### "],type:T.heading3},{mode:"block",match:["#### "],type:T.heading4},{mode:"block",type:w.ELEMENT_UL,match:["- "],preFormat:w.unwrapList,format:l=>w.toggleList(l,{type:w.ELEMENT_UL})},{mode:"block",type:w.ELEMENT_OL,match:["1. ","1) "],preFormat:w.unwrapList,format:l=>w.toggleList(l,{type:w.ELEMENT_OL})},{mode:"block",type:G0,match:["[] "]}]}})]}}const wV=e=>Array.from(w.getNodeEntries(e,{at:[],match:l=>!!l.breakAfterColumn})).length,o2=(e,{key:l=E1,value:o,at:i})=>{const s=r=>w.isBlock(e,r);o?w.setElements(e,{[l]:o},{mode:"lowest",match:s,at:i}):w.unsetNodes(e,l,{match:s,mode:"lowest",at:i})},nu0=(e,l,o)=>{o2(e,{at:l,value:o})},we=(e,l)=>{const o=Array.from(w.getNodeEntries(e,{at:[],match:i=>!!i.breakAfterColumn}));for(const[i,[,s]]of o.entries())nu0(e,s,i<l-1?"active":"inactive")},mV=(e,l,o)=>{if(o.preventDefault(),o.stopPropagation(),!!(e!=null&&e.selection)&&w.someNode(e,{match:s=>!!s.breakAfterColumn}))o2(e,{value:void 0});else{const s=wV(e),r=Math.max(l-s-1,0);if(r===0)return;const c=Array.from(w.getNodeEntries(e,{at:e.selection,match:d=>w.isBlock(e,d),mode:"lowest"})).slice(-r);for(const d of c)o2(e,{value:"active",at:d[1]})}we(e,l)},au0=(e,{options:{hotkey:l}})=>o=>{var i;if(!o.defaultPrevented&&l&&hF(l,o)){const s=e.plugins.find(c=>c.key===E1),r=((i=s==null?void 0:s.options)==null?void 0:i.columns)??1;mV(e,r,o)}},ou0=({id:e,...l})=>{var h,u;const o=w.usePlateEditorState(w.useEventPlateId(e)),i=!!(o!=null&&o.selection)&&w.someNode(o,{match:L=>!!L.breakAfterColumn}),s=(u=(h=o==null?void 0:o.pluginsByKey.breakAfterColumn)==null?void 0:h.options)==null?void 0:u.columns,r=Number(s)||1,c=iu0(o,r,i),d=j0(c);return t.jsx(w.ToolbarButton,{active:i,tooltip:b0(c?`Column Break
|
|
40
40
|
Shift+Ctrl+Return`:"Already at maximum numbers of columns"),onMouseDown:L=>mV(o,r,L),...l,classNames:d})},iu0=(e,l,o)=>wV(e)+1<l||o,fV=({id:e})=>t.jsx(C0,{id:e,children:t.jsx(ou0,{icon:t.jsx(p0,{icon:t.jsx(l3,{})}),classNames:j0(),styles:N0})}),su0=(e,l)=>{const o=w.getStartPoint(e,l);setTimeout(()=>{w.select(e,{anchor:o,focus:o})})},ru0=e=>{var o;const l=e.plugins.find(i=>i.key===E1);return((o=l==null?void 0:l.options)==null?void 0:o.columns)??1},cu0=e=>{const{apply:l}=e,o=ru0(e);e.apply=i=>{switch(i.type){case"split_node":i.properties={...i.properties,breakAfterColumn:void 0};break;case"merge_node":const s=w.getPointBefore(e,i.path);if(!s)break;const r=w.getParentNode(e,s.path);if(o2(e,{at:s,value:void 0}),we(e,o),r!=null&&r[0].breakAfterColumn)return su0(e,i.path),e;break}l(i)},setTimeout(()=>we(e,o))},E1="breakAfterColumn",A7="normal";class du0 extends t0{constructor(o){super("break-after-plugin",{button:fV,...o});W(this,"columns");W(this,"gap");this.columns=(o==null?void 0:o.columns)??1,this.gap=(o==null?void 0:o.gap)??A7}plugins(){return[xV(this.columns,this.gap)]}}const xV=(e,l)=>w.createPluginFactory({key:E1,handlers:{onKeyDown:au0},useHooks:cu0,options:{columns:e,gap:l,hotkey:["shift+ctrl+enter"]}})(),hu0=12,Lu0=26,uu0=124,wu0=e=>e.map((l,o)=>({group:l,buttonGroupWidth:l.reduce((i,s)=>s.id===TT?uu0:Lu0+i,hu0),index:o})),mu0=(e,l)=>l.reduce((o,{group:i,buttonGroupWidth:s,index:r})=>{const c=Math.max(0,o.length-1);return o[c]=o[c]??[],(o[c]??[{actions:[],buttonGroupWidth:0}]).reduce((h,{buttonGroupWidth:u})=>h+u,0)+s<=e?o[c].push({group:i,buttonGroupWidth:s,index:r}):o.push([{group:i,buttonGroupWidth:s,index:r}]),o.filter(h=>h.length)},[]),fu0=({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}),xu0=({toolbarButtons:e,editorId:l,toolbarWidth:o})=>{const i=w.usePlateEditorRef(l),{editorWidth:s}=oT(),{position:r}=C1(),c=o||s||0,d=wu0(e.at(r)),h=mu0(c,d),u=ZV[r];return t.jsx(u.ToolbarWrapper,{editorWidth:s,toolbarWidth:o,toolbarButtonGroups:h,children:h.map((L,m)=>t.jsx("div",{className:"tw-divide-x tw-divide-line tw-flex tw-w-full tw-flex-wrap",children:L.map(({group:f,index:g})=>t.jsx(fu0,{index:g,children:f.map((x,j)=>t.jsx(x.button,{editor:i,editorId:l,id:x.id},j.toString()))},g))},m))})},vV=e=>w.createPlugins(e.plugins,{components:w.createPlateUI(e.elements)}),j7=(e,l)=>({create:()=>vV(l),toolbar:o=>l.hasToolbar?t.jsx(xu0,{toolbarButtons:l.buttons,editorId:e,toolbarWidth:o}):null,inline:()=>t.jsx(t.Fragment,{children:l.inline.map((o,i)=>t.jsx(o,{},i))}),styles:()=>l.getStyles}),vu0="mention-plugin",gu0=e=>l=>l.text.toLowerCase().includes(e.toLowerCase()),C7=(e,l)=>`${e}:${l}`,M7=e=>{const l=new Map;for(const o of e){const i=C7(o.data.category,o.data.id),s=o.text;l.set(i,s)}return l},gV=(e,l,o)=>e.get(l)??o;var K0=(e=>(e.GROUP="group",e.ALL="all",e.USER="user",e))(K0||{});const I7=({attributes:e,element:l,nodeProps:o,children:i})=>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)"},...o,children:i}),Au0=({children:e,...l})=>t.jsxs(I7,{...l,children:[t.jsx("span",{style:{paddingRight:"3px",display:"inline-block",margin:"-1px 0"},children:t.jsx(d5,{})}),e]}),ju0=({children:e,...l})=>t.jsxs(I7,{...l,children:["@",e]}),Cu0=({children:e,...l})=>t.jsx(I7,{...l,children:e}),Mu0=({category:e,children:l,...o})=>{const i={[K0.USER]:Cu0,[K0.GROUP]:Au0,[K0.ALL]:ju0},s=i[e]??i[K0.USER];return t.jsx(s,{...o,children:l})},Z7=e=>l=>{const{element:o,children:i}=l,s=C7(o==null?void 0:o.category,String(o==null?void 0:o.id));return t.jsxs(Mu0,{category:o==null?void 0:o.category,...l,children:[gV(e,s,String(o==null?void 0:o.id)),i]})};class AV extends e0{constructor(l=w.ELEMENT_MENTION){super(l)}setNodeWithMentionable(l){return this.node=Z7(M7(l)),this}}const Iu0=({image:e,category:l,text:o,id:i})=>{if(e)return t.jsx("img",{src:e,alt:`${i}-${l}-${o}`});switch(l){case K0.GROUP:return t.jsx(d5,{});case K0.ALL:return t.jsx($e,{});default:return t.jsx(We,{})}},Zu0=({item:e})=>{const{data:{image:l,category:o},key:i,text:s}=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(Iu0,{image:l,category:o,text:s,id:i})}),t.jsx("span",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis",children:s})]})},H4=[`
|
|
41
41
|
color: var(--text-color-weak);
|
|
42
42
|
padding-left: 1.25rem;
|