@innoviatech/lexical-text-editor 2.0.7 → 3.0.0
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/README.md +390 -288
- package/dist/components/AlignmentSelectionList.js +19 -0
- package/dist/components/ColorPicker.js +30 -0
- package/dist/components/ContentPreview.js +11 -0
- package/dist/components/DisplayControls.d.ts +16 -0
- package/dist/components/DropdownList.js +18 -0
- package/dist/components/FindReplaceModal.d.ts +11 -0
- package/dist/components/FindReplaceModal.js +120 -0
- package/dist/components/FontSelectionList.d.ts +17 -0
- package/dist/components/FontSelectionList.js +17 -0
- package/dist/components/HeadingSelectionList.js +19 -0
- package/dist/components/ImageComponent.js +111 -0
- package/dist/components/InsertDropdownList.js +17 -0
- package/dist/components/LexicalTextEditor.d.ts +10 -0
- package/dist/components/LexicalTextEditor.js +128 -0
- package/dist/components/LinkModal.js +47 -0
- package/dist/components/Separator.js +4 -0
- package/dist/components/SourceView.d.ts +13 -0
- package/dist/components/SourceView.js +50 -0
- package/dist/components/StatusBar.d.ts +14 -0
- package/dist/components/StatusBar.js +30 -0
- package/dist/components/ToolbarOverflowModal.d.ts +15 -0
- package/dist/components/common/Dialog.js +27 -0
- package/dist/components/common/Popover.d.ts +10 -1
- package/dist/components/common/Popover.js +37 -0
- package/dist/components/common/Tooltip.d.ts +7 -0
- package/dist/components/common/Tooltip.js +20 -0
- package/dist/components/ui/button.js +35 -0
- package/dist/components/ui/command.js +33 -0
- package/dist/components/ui/dialog.js +35 -0
- package/dist/components/ui/input.js +6 -0
- package/dist/components/ui/popover.js +16 -0
- package/dist/components/ui/scroll-area.js +12 -0
- package/dist/components/ui/tooltip.js +16 -0
- package/dist/constants/index.d.ts +23 -1
- package/dist/constants/index.js +224 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lexical-editor.css +1 -1
- package/dist/lib/utils.js +5 -0
- package/dist/nodes/ExtendedTextNode.js +140 -0
- package/dist/nodes/ImageNode.js +149 -0
- package/dist/nodes/VideoNode.js +80 -0
- package/dist/nodes/YoutubeNode.js +64 -0
- package/dist/plugins/CodeBlockPlugin.d.ts +1 -0
- package/dist/plugins/CodeBlockPlugin.js +88 -0
- package/dist/plugins/ColorPlugin.js +47 -0
- package/dist/plugins/CustomOnChangePlugin.js +33 -0
- package/dist/plugins/FontFamilyPlugin.d.ts +1 -0
- package/dist/plugins/FontFamilyPlugin.js +53 -0
- package/dist/plugins/FontSizePlugin.d.ts +1 -0
- package/dist/plugins/FontSizePlugin.js +48 -0
- package/dist/plugins/ImagePlugin.js +91 -0
- package/dist/plugins/ListPlugin.js +44 -0
- package/dist/plugins/TablePlugin.d.ts +1 -0
- package/dist/plugins/TablePlugin.js +92 -0
- package/dist/plugins/ToolbarPlugin.d.ts +13 -1
- package/dist/plugins/ToolbarPlugin.js +381 -0
- package/dist/plugins/VideoPlugin.js +49 -0
- package/dist/plugins/YoutubePlugin.js +30 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/editor_screenshot.png +0 -0
- package/package.json +11 -4
- package/googlebd703883f12c69e4.html +0 -1
- package/rollup.config.js +0 -55
- package/src/components/AlignmentSelectionList.tsx +0 -61
- package/src/components/ColorPicker.tsx +0 -66
- package/src/components/ContentPreview.tsx +0 -51
- package/src/components/DropdownList.tsx +0 -57
- package/src/components/HeadingSelectionList.tsx +0 -61
- package/src/components/ImageComponent.tsx +0 -206
- package/src/components/InsertDropdownList.tsx +0 -36
- package/src/components/LexicalTextEditor.tsx +0 -119
- package/src/components/LinkModal.tsx +0 -127
- package/src/components/Separator.tsx +0 -7
- package/src/components/common/Dialog.tsx +0 -47
- package/src/components/common/Popover.tsx +0 -87
- package/src/components/common/Tooltip.tsx +0 -43
- package/src/components/ui/button.tsx +0 -58
- package/src/components/ui/command.tsx +0 -183
- package/src/components/ui/dialog.tsx +0 -142
- package/src/components/ui/input.tsx +0 -21
- package/src/components/ui/popover.tsx +0 -46
- package/src/components/ui/scroll-area.tsx +0 -56
- package/src/components/ui/tooltip.tsx +0 -59
- package/src/constants/index.tsx +0 -177
- package/src/index.ts +0 -6
- package/src/lib/utils.ts +0 -6
- package/src/nodes/ExtendedTextNode.tsx +0 -174
- package/src/nodes/ImageNode.tsx +0 -232
- package/src/nodes/VideoNode.tsx +0 -134
- package/src/nodes/YoutubeNode.tsx +0 -101
- package/src/plugins/ColorPlugin.tsx +0 -85
- package/src/plugins/CustomOnChangePlugin.tsx +0 -50
- package/src/plugins/ImagePlugin.tsx +0 -189
- package/src/plugins/ListPlugin.tsx +0 -58
- package/src/plugins/ToolbarPlugin.tsx +0 -500
- package/src/plugins/VideoPlugin.tsx +0 -100
- package/src/plugins/YoutubePlugin.tsx +0 -83
- package/src/styles/lexical-editor.css +0 -1053
- package/src/types/global.d.ts +0 -34
- package/src/types/other.d.ts +0 -11
- package/src/types/react-icons.d.ts +0 -11
- package/tailwind.config.js +0 -10
- package/tsconfig.json +0 -32
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e,t,n=require("react/jsx-runtime"),i=require("@lexical/react/LexicalComposer"),o=require("react"),r=require("@lexical/rich-text"),s=require("@lexical/code"),l=require("@lexical/react/LexicalRichTextPlugin"),a=require("@lexical/react/LexicalContentEditable"),c=require("@lexical/react/LexicalErrorBoundary"),d=require("lexical"),u=require("@lexical/react/LexicalHistoryPlugin"),h=require("@lexical/react/LexicalListPlugin"),p=require("@lexical/list"),g=require("react-icons/rx"),m=require("react-icons/tb"),x=require("react-icons/bs"),f=require("react-icons/ai"),b=require("react-icons/io5"),y=require("react-icons/pi"),N=require("@lexical/react/LexicalComposerContext"),v=require("@lexical/link"),C=require("react-icons/hi2"),_=require("react-icons/io"),j=require("react-icons/md"),w=require("react-icons/bi"),S=require("react-color"),T=require("react-dom"),k=require("react-icons/lu"),E=require("react-icons/fa"),A=require("react-icons/vsc"),M=require("@lexical/react/LexicalLinkPlugin"),L=require("@lexical/react/LexicalOnChangePlugin");!function(e){e.Bold="bold",e.Italics="italics",e.Underline="underline",e.Quote="quote",e.Lowercase="lowercase",e.Uppercase="uppercase",e.Capitalize="capitalize",e.Strikethrough="strikethrough",e.Superscript="superscript",e.Subscript="subscript",e.Highlight="highlight",e.Code="code",e.Link="link",e.LeftAlign="leftAlign",e.CenterAlign="centerAlign",e.RightAlign="rightAlign",e.JustifyAlign="justifyAlign",e.Divider="divider",e.Undo="undo",e.Redo="redo"}(e||(e={})),function(e){e.Normal="normal",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6"}(t||(t={}));const O=[{id:e.Lowercase,icon:n.jsx(g.RxLetterCaseLowercase,{}),label:"Lowercase"},{id:e.Uppercase,icon:n.jsx(g.RxLetterCaseUppercase,{}),label:"Uppercase"},{id:e.Capitalize,icon:n.jsx(g.RxLetterCaseCapitalize,{}),label:"Capitalize"},{id:e.Strikethrough,icon:n.jsx(f.AiOutlineStrikethrough,{}),label:"Strikethrough"},{id:e.Highlight,icon:n.jsx(y.PiHighlighterLight,{}),label:"Highlight",fontSize:10},{id:e.Superscript,icon:n.jsx(x.BsSuperscript,{}),label:"Superscript"},{id:e.Subscript,icon:n.jsx(x.BsSubscript,{}),label:"Subscript"}],R=[{id:e.Bold,icon:n.jsx(m.TbBold,{}),label:"Bold"},{id:e.Italics,icon:n.jsx(m.TbItalic,{}),label:"Italics"},{id:e.Underline,icon:n.jsx(m.TbUnderline,{}),label:"Underline"},{id:e.Divider},{id:e.Quote,icon:n.jsx(x.BsChatSquareQuote,{}),label:"Quote"},{id:e.Code,icon:n.jsx(b.IoCodeSlashOutline,{}),label:"Code"}],$=[{id:e.Undo,icon:n.jsx(x.BsArrowCounterclockwise,{}),label:"Undo"},{id:e.Redo,icon:n.jsx(x.BsArrowClockwise,{}),label:"Redo"},{id:e.Divider}],D=[{id:e.LeftAlign,icon:n.jsx(x.BsJustifyLeft,{}),label:"Left Align"},{id:e.CenterAlign,icon:n.jsx(x.BsTextCenter,{}),label:"Center Align"},{id:e.RightAlign,icon:n.jsx(x.BsJustifyRight,{}),label:"Right Align"},{id:e.JustifyAlign,icon:n.jsx(x.BsJustify,{}),label:"Justify Align"}],I=[{id:"normal",label:"Normal",icon:n.jsx(x.BsTextParagraph,{})},{id:"h1",label:"Heading 1",icon:n.jsx(x.BsTypeH1,{})},{id:"h2",label:"Heading 2",icon:n.jsx(x.BsTypeH2,{})},{id:"h3",label:"Heading 3",icon:n.jsx(x.BsTypeH3,{})},{id:"h4",label:"Heading 4",icon:n.jsx(x.BsTypeH4,{})},{id:"h5",label:"Heading 5",icon:n.jsx(x.BsTypeH5,{})},{id:"h6",label:"Heading 6",icon:n.jsx(x.BsTypeH6,{})}];function B(e,...t){const n=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",e);for(const e of t)i.append("v",e);throw n.search=i.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const F=new Map;function H(e){let t=F.get(e);return void 0===t&&(t=function(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,i]=e.split(/:([^]+)/);n&&i&&(t[n.trim()]=i.trim())}return t}(e),F.set(e,t)),t}function P(e,t){(d.$isRangeSelection(e)?e.isCollapsed():d.$isTextNode(e)||d.$isElementNode(e))||B(280);const n=H(d.$isRangeSelection(e)?e.style:d.$isTextNode(e)?e.getStyle():e.getTextStyle()),i=Object.entries(t).reduce((t,[i,o])=>("function"==typeof o?t[i]=o(n[i],e):null===o?delete t[i]:t[i]=o,t),{...n}),o=function(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}(i);d.$isRangeSelection(e)||d.$isTextNode(e)?e.setStyle(o):e.setTextStyle(o),F.set(o,i)}function U(e,t){if(d.$isRangeSelection(e)&&e.isCollapsed()){P(e,t);const n=e.anchor.getNode();d.$isElementNode(n)&&n.isEmpty()&&P(n,t)}!function(e){const t=d.$getSelection();if(!t)return;const n=new Map,i=e=>n.get(e.getKey())||[0,e.getTextContentSize()];if(d.$isRangeSelection(t))for(const e of d.$caretRangeFromSelection(t).getTextSlices())e&&n.set(e.caret.origin.getKey(),e.getSliceIndices());const o=t.getNodes();for(const t of o){if(!d.$isTextNode(t)||!t.canHaveFormat())continue;const[n,o]=i(t);o!==n&&(d.$isTokenOrSegmented(t)||0===n&&o===t.getTextContentSize()?e(t):e(t.splitText(n,o)[0===n?0:1]))}d.$isRangeSelection(t)&&"text"===t.anchor.type&&"text"===t.focus.type&&t.anchor.key===t.focus.key&&function(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:i,offset:o,type:r}=t;t.set(n.key,n.offset,n.type),n.set(i,o,r)}}(t)}(e=>{P(e,t)})}function q(e,t){const n=e.getFormatType(),i=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),i!==t.getIndent()&&t.setIndent(i)}function z(e){return e.getNode().isAttached()}function K(e){let t=e;for(;null!==t&&!d.$isRootOrShadowRoot(t);){const e=t.getLatest(),n=t.getParent();0===e.getChildrenSize()&&t.remove(!0),t=n}}function W(e,t,n=null){const i=e.getStartEndPoints(),o=i?i[0]:null,r=e.getNodes(),s=r.length;if(null!==o&&(0===s||1===s&&"element"===o.type&&0===o.getNode().getChildrenSize())){const e="text"===o.type?o.getNode().getParentOrThrow():o.getNode(),i=e.getChildren();let r=t();return r.setFormat(e.getFormatType()),r.setIndent(e.getIndent()),i.forEach(e=>r.append(e)),n&&(r=n.append(r)),void e.replace(r)}let l=null,a=[];for(let i=0;i<s;i++){const o=r[i];d.$isRootOrShadowRoot(o)?(J(e,a,a.length,t,n),a=[],l=o):null===l||null!==l&&d.$hasAncestor(o,l)?a.push(o):(J(e,a,a.length,t,n),a=[o])}J(e,a,a.length,t,n)}function J(e,t,n,i,o=null){if(0===t.length)return;const r=t[0],s=new Map,l=[];let a=d.$isElementNode(r)?r:r.getParentOrThrow();a.isInline()&&(a=a.getParentOrThrow());let c=!1;for(;null!==a;){const e=a.getPreviousSibling();if(null!==e){a=e,c=!0;break}if(a=a.getParentOrThrow(),d.$isRootOrShadowRoot(a))break}const u=new Set;for(let e=0;e<n;e++){const n=t[e];d.$isElementNode(n)&&0===n.getChildrenSize()&&u.add(n.getKey())}const h=new Set;for(let e=0;e<n;e++){const n=t[e];let o=n.getParent();if(null!==o&&o.isInline()&&(o=o.getParent()),null!==o&&d.$isLeafNode(n)&&!h.has(n.getKey())){const e=o.getKey();if(void 0===s.get(e)){const t=i();t.setFormat(o.getFormatType()),t.setIndent(o.getIndent()),l.push(t),s.set(e,t),o.getChildren().forEach(e=>{t.append(e),h.add(e.getKey()),d.$isElementNode(e)&&e.getChildrenKeys().forEach(e=>h.add(e))}),K(o)}}else if(u.has(n.getKey())){d.$isElementNode(n)||B(179);const e=i();e.setFormat(n.getFormatType()),e.setIndent(n.getIndent()),l.push(e),n.remove(!0)}}if(null!==o)for(let e=0;e<l.length;e++){const t=l[e];o.append(t)}let p=null;if(d.$isRootOrShadowRoot(a))if(c)if(null!==o)a.insertAfter(o);else for(let e=l.length-1;e>=0;e--){const t=l[e];a.insertAfter(t)}else{const e=a.getFirstChild();if(d.$isElementNode(e)&&(a=e),null===e)if(o)a.append(o);else for(let e=0;e<l.length;e++){const t=l[e];a.append(t),p=t}else if(null!==o)e.insertBefore(o);else for(let t=0;t<l.length;t++){const n=l[t];e.insertBefore(n),p=n}}else if(o)a.insertAfter(o);else for(let e=l.length-1;e>=0;e--){const t=l[e];a.insertAfter(t),p=t}const g=d.$getPreviousSelection();d.$isRangeSelection(g)&&z(g.anchor)&&z(g.focus)?d.$setSelection(g.clone()):null!==p?p.selectEnd():e.dirty=!0}function X(e,t,n){const i=H(e.getStyle());return null!==i&&i[t]||n}function G(e,t,n=""){let i=null;const o=e.getNodes(),r=e.anchor,s=e.focus,l=e.isBackward(),a=l?s.offset:r.offset,c=l?s.getNode():r.getNode();if(d.$isRangeSelection(e)&&e.isCollapsed()&&""!==e.style){const n=H(e.style);if(null!==n&&t in n)return n[t]}for(let e=0;e<o.length;e++){const r=o[e];if((0===e||0!==a||!r.is(c))&&d.$isTextNode(r)){const e=X(r,t,n);if(null===i)i=e;else if(i!==e){i="";break}}}return null===i?n:i}const Q="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,Y=Q&&"documentMode"in document?document.documentMode:null;function V(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function Z({open:e,onOpenChange:t,children:i}){const r=o.useRef(null),s=o.useRef(null);return o.useEffect(()=>{function n(e){r.current?.contains(e.target)||s.current?.contains(e.target)||t(!1)}return e&&document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[e,t]),n.jsx("div",{className:"popover-root",children:o.Children.map(i,e=>e&&"object"==typeof e?e.type===ee?o.cloneElement(e,{triggerRef:r}):e.type===te?o.cloneElement(e,{contentRef:s}):e:e)})}function ee({children:e,triggerRef:t}){return n.jsx("div",{className:"popover-trigger",ref:t,children:e})}function te({open:e,align:t="start",children:i,contentRef:o}){return e?n.jsx("div",{ref:o,className:`popover-content align-${t}`,children:i}):null}function ne({onAction:e,selectionMap:t}){const[i,r]=o.useState(!1),s=o.useRef(null),l=o.useRef(null);return n.jsxs(Z,{open:i,onOpenChange:r,children:[n.jsx(ee,{triggerRef:s,children:n.jsxs("button",{type:"button",className:"lexical-btn heading-trigger "+(i?"toolbar-active":"toolbar"),onClick:()=>r(e=>!e),children:[n.jsx("span",{children:"Aa"}),n.jsx(C.HiChevronDown,{className:"chevron "+(i?"rotated":"")})]})}),n.jsx(te,{open:i,align:"start",onClose:()=>r(!1),contentRef:l,children:n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:O.map(({id:i,label:o,icon:s})=>n.jsxs("button",{type:"button",className:"lexical-btn "+(t[i]?"toolbar-active":"toolbar"),onClick:()=>{e(i),r(!1)},style:{minWidth:130},children:[s,n.jsx("span",{className:"label",children:o})]},i))})})]})}function ie(){return n.jsx("div",{className:"w-[1px] h-[20px] mx-[2px] bg-gray-300 shrink-0"})}function oe({updateHeading:e,headingSelectionMap:t}){const i=I.find(e=>t[e.id]),[r,s]=o.useState(!1),l=o.useRef(null),a=o.useRef(null);return n.jsxs(Z,{open:r,onOpenChange:s,children:[n.jsx(ee,{triggerRef:l,children:n.jsxs("button",{type:"button",className:"lexical-btn heading-trigger "+(r?"toolbar-active":"toolbar"),onClick:()=>s(e=>!e),style:{minWidth:132},children:[i?.icon,n.jsx("span",{children:i?.label}),n.jsx(C.HiChevronDown,{className:"chevron "+(r?"rotated":"")})]})}),n.jsx(te,{open:r,align:"start",onClose:()=>s(!1),contentRef:a,children:n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:I.map(({id:i,label:o,icon:r})=>n.jsxs("button",{type:"button",className:"lexical-btn "+(t[i]?"toolbar-active":"toolbar"),onClick:()=>{e(i),s(!1)},children:[r,n.jsx("span",{className:"label",children:o})]},i))})})]})}function re({linkUrl:e,setLinkUrl:t,onConfirm:i,onCancel:r,removeLink:s}){const[l,a]=o.useState(!1),c=o.useRef(null),d=o.useRef(null);return o.useEffect(()=>{"https://"===e&&a(!0)},[e]),o.useEffect(()=>{l&&d.current?.focus()},[l]),o.useEffect(()=>{const e=e=>{c.current&&!c.current.contains(e.target)&&r()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r]),n.jsxs("div",{ref:c,className:"lexical-text-editor-link link-editor-container",children:[n.jsx("div",{className:"link-editor-input-wrapper",children:l?n.jsx("input",{ref:d,className:"link-editor-input",value:e,onChange:e=>t(e.target.value),onKeyDown:t=>{"Enter"===t.key?(t.preventDefault(),i(e),a(!1)):"Escape"===t.key&&(t.preventDefault(),a(!1),r())}}):n.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"link-editor-url",children:e})}),n.jsxs("div",{className:"link-editor-buttons",children:[n.jsx("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>{l?(i(e),a(!1)):a(!0)},children:l?n.jsx(j.MdCheck,{size:18}):n.jsx(x.BsPencilSquare,{size:14})}),n.jsx("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onMouseDown:e=>e.preventDefault(),onClick:s,children:n.jsx(w.BiUnlink,{size:14,style:{stroke:"black"}})})]})]})}function se({onAction:e,alignmentSelectionMap:t}){const i=D.find(e=>t[e.id]),[r,s]=o.useState(!1),l=o.useRef(null),a=o.useRef(null);return n.jsxs(Z,{open:r,onOpenChange:s,children:[n.jsx(ee,{triggerRef:l,children:n.jsxs("button",{type:"button",className:"lexical-btn heading-trigger "+(r?"toolbar-active":"toolbar"),onClick:()=>s(e=>!e),style:{minWidth:146},children:[i?.icon,n.jsx("span",{children:i?.label}),n.jsx(C.HiChevronDown,{className:"chevron "+(r?"rotated":"")})]})}),n.jsx(te,{open:r,align:"start",onClose:()=>s(!1),contentRef:a,children:n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:D.map(({id:i,label:o,icon:r})=>n.jsxs("button",{type:"button",className:"lexical-btn "+(t[i]?"toolbar-active":"toolbar"),onClick:()=>{e(i),s(!1)},children:[r,n.jsx("span",{className:"label",children:o})]},i))})})]})}function le({color:e,onChange:t,icon:i}){const[r,s]=o.useState(!1),l=o.useRef(null),a=o.useRef(null);o.useEffect(()=>{const e=e=>{a.current&&!a.current.contains(e.target)&&l.current&&!l.current.contains(e.target)&&s(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);return n.jsxs("div",{className:"color-picker-wrapper",children:[n.jsx("button",{type:"button",ref:l,className:`size-8 lexical-btn ${r?"toolbarActive":"toolbar"} icon`,onClick:()=>s(e=>!e),children:i}),r&&T.createPortal(n.jsx("div",{ref:a,className:"lexical-color-popover "+(r?"open":""),style:{top:l.current?.getBoundingClientRect().bottom,left:l.current?.getBoundingClientRect().left,position:"absolute"},onMouseDown:e=>e.preventDefault(),children:n.jsx(S.SketchPicker,{color:e,onChangeComplete:e=>{t(e.hex)}})}),document.body)]})}Q&&"InputEvent"in window&&!Y&&new window.InputEvent("input");const ae=({content:e,direction:t="top",delay:i=400,children:r})=>{const[s,l]=o.useState(!1),a=o.useRef(null);return n.jsxs("div",{className:"Lexical-Tooltip-Wrapper",onMouseEnter:()=>{a.current=window.setTimeout(()=>{l(!0)},i)},onMouseLeave:()=>{a.current&&clearTimeout(a.current),l(!1)},children:[r,s&&n.jsx("div",{className:`Lexical-Tooltip-Tip ${t}`,children:e})]})};function ce(){const[e]=N.useLexicalComposerContext(),[{color:t,bgColor:i},r]=o.useState({color:"#000",bgColor:"#fff"}),s=()=>{const e=d.$getSelection();if(d.$isRangeSelection(e)){const t=G(e,"color","#000"),n=G(e,"background","#fff");r({color:t,bgColor:n})}};o.useEffect(()=>V(e.registerUpdateListener(({editorState:e})=>{e.read(()=>{s()})}),e.registerCommand(d.SELECTION_CHANGE_COMMAND,()=>(s(),!1),1)),[e]);const l=({property:t,color:n})=>{e.update(()=>{const e=d.$getSelection();e&&U(e,{[t]:n})})};return n.jsxs(n.Fragment,{children:[n.jsx(ae,{content:"Font Color",direction:"bottom",children:n.jsx(le,{color:t,onChange:e=>{l({property:"color",color:e})},icon:n.jsx(f.AiOutlineFontColors,{})})}),n.jsx(ae,{content:"Background Color",direction:"bottom",children:n.jsx(le,{color:i,onChange:e=>{l({property:"background",color:e})},icon:n.jsx(f.AiOutlineBgColors,{})})})]})}function de({blockType:e}){const[t]=N.useLexicalComposerContext();return n.jsxs(n.Fragment,{children:[n.jsx(ae,{content:"Ordered list",direction:"bottom",children:n.jsx("button",{type:"button",className:`size-8 lexical-btn ${"ol"===e?"toolbarActive":"toolbar"} icon`,onClick:()=>{"ol"===e?t.dispatchCommand(p.REMOVE_LIST_COMMAND,void 0):t.dispatchCommand(p.INSERT_ORDERED_LIST_COMMAND,void 0)},children:n.jsx(x.BsListOl,{})})}),n.jsx(ae,{content:"Unordered list",direction:"bottom",children:n.jsx("button",{type:"button",className:`size-8 lexical-btn ${"ul"===e?"toolbarActive":"toolbar"} icon`,onClick:()=>{"ul"===e?t.dispatchCommand(p.REMOVE_LIST_COMMAND,void 0):t.dispatchCommand(p.INSERT_UNORDERED_LIST_COMMAND,void 0)},children:n.jsx(x.BsListUl,{})})})]})}const ue=({src:e,altText:t,nodeKey:i,width:r,height:s,maxWidth:l,caption:a=""})=>{const[c]=N.useLexicalComposerContext(),[u,h]=o.useState(!1),[p,g]=o.useState(a),m=o.useRef(null),x=o.useRef(null),f=o.useRef(null),b=o.useRef(null),y=e=>{if(!b.current||!x.current)return;const t=e.clientX-b.current.x,n=Math.min(l,Math.max(50,b.current.width+t)),i=n*x.current.ratio;x.current.width=n,x.current.height=i;const o=f.current?.querySelector("img");o&&(o.style.width=n+"px",o.style.height=i+"px")},v=()=>{if(!x.current)return;const{width:e,height:t}=x.current;c.update(()=>{const n=d.$getNodeByKey(i);n&&"function"==typeof n.updateDimensions&&n.updateDimensions(e,t)}),x.current=null,b.current=null,window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",v)},C=()=>{h(!1),c.update(()=>{const e=d.$getNodeByKey(i);e&&"function"==typeof e.setCaption&&e.setCaption(p)})},_=()=>{g(a),h(!0),setTimeout(()=>m.current?.focus(),0)};return n.jsxs("div",{ref:f,style:{display:"inline-block",position:"relative",maxWidth:l},children:[n.jsx("img",{src:e,alt:t,width:"inherit"===r?void 0:r,height:"inherit"===s?void 0:s,style:{maxWidth:"100%",display:"block"}}),(a||u)&&n.jsx("div",{style:{textAlign:"center",marginTop:4},children:u?n.jsx("input",{ref:m,className:"lte-input",style:{width:"100%",textAlign:"center"},value:p,onChange:e=>g(e.target.value),onBlur:C,onKeyDown:e=>{"Enter"===e.key&&C()}}):n.jsx("span",{style:{fontSize:13,color:"#666",cursor:"text",display:"inline-block",minWidth:20,minHeight:18},onClick:_,children:a})}),!a&&!u&&n.jsx("div",{style:{textAlign:"center",marginTop:2},children:n.jsx("span",{style:{fontSize:12,color:"#999",cursor:"pointer"},onClick:_,children:"+ Add caption"})}),n.jsx("div",{onMouseDown:e=>{e.preventDefault(),e.stopPropagation();const t=f.current?.querySelector("img");if(!t)return;const n=t.getBoundingClientRect().width,i=t.naturalHeight/t.naturalWidth,o=n*i;b.current={x:e.clientX,y:e.clientY,width:n,height:o},x.current={width:n,height:o,ratio:i},window.addEventListener("mousemove",y),window.addEventListener("mouseup",v)},style:{position:"absolute",bottom:a||u?40:0,right:0,width:14,height:14,background:"white",border:"1px solid #999",cursor:"nwse-resize",borderRadius:2}})]})},he=e=>d.$applyNodeReplacement(new ge(e)),pe=e=>{if(!(e instanceof HTMLImageElement))return null;const{src:t,alt:n}=e;let i,o;e.width&&(i=e.width),e.height&&(o=e.height);const r=e.style;if((!i||0===i)&&r.width){const e=parseInt(r.width,10);Number.isNaN(e)||(i=e)}if((!o||0===o)&&r.height){const e=parseInt(r.height,10);Number.isNaN(e)||(o=e)}return{node:he({src:t,altText:n,width:i??"inherit",height:o??"inherit"})}};class ge extends d.DecoratorNode{constructor({src:e="",altText:t="",maxWidth:n=1080,width:i="inherit",height:o="inherit",caption:r="",key:s}={src:"",altText:""}){super(s),this.__src=e,this.__altText=t,this.__maxWidth=n,this.__width=i,this.__height=o,this.__caption=r}static getType(){return"image"}static clone(e){return new ge({src:e.__src,altText:e.__altText,width:e.__width,height:e.__height,maxWidth:e.__maxWidth,caption:e.__caption,key:e.getKey()})}createDOM(){return document.createElement("span")}updateDOM(e){return e.__width!==this.__width||e.__height!==this.__height}exportDOM(){const e=document.createElement("img");if(e.src=this.__src,e.alt=this.__altText,"inherit"!==this.__width&&(e.width=this.__width??0),"inherit"!==this.__height&&(e.height=this.__height??0),this.__caption){const t=document.createElement("figure"),n=document.createElement("figcaption");return n.textContent=this.__caption,t.appendChild(e),t.appendChild(n),{element:t}}return{element:e}}static importDOM(){return{img:()=>({conversion:pe,priority:1}),figure:()=>({conversion:e=>{const t=e.querySelector("img");if(!t)return null;const n=e.querySelector("figcaption"),i=n?.textContent||"",o=pe(t);return o?.node instanceof ge&&i&&(o.node.__caption=i),o},priority:1})}}exportJSON(){return{type:"image",version:1,src:this.__src,altText:this.__altText,maxWidth:this.__maxWidth,width:this.__width,height:this.__height,caption:this.__caption}}static importJSON(e){return new ge({src:e.src,altText:e.altText,maxWidth:e.maxWidth,width:e.width,height:e.height,caption:e.caption})}updateDimensions(e,t){const n=this.getWritable();n.__width=e,n.__height=t}setCaption(e){this.getWritable().__caption=e}decorate(){return n.jsx(ue,{src:this.__src,altText:this.__altText,nodeKey:this.getKey(),width:this.__width,height:this.__height,maxWidth:this.__maxWidth,caption:this.__caption})}}function me({open:e,onClose:t,forPreview:i=!1,children:r}){const s=o.useRef(null);return o.useEffect(()=>{if(!e)return;const n=e=>{s.current&&!s.current.contains(e.target)&&t()},i=e=>{"Escape"===e.key&&t()};return document.addEventListener("mousedown",n),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("keydown",i)}},[e,t]),e?n.jsx("div",{className:"lexical-text-editor-dialog lte-dialog-overlay",children:n.jsxs("div",{ref:s,className:"lte-dialog "+(i?"preview":""),children:[n.jsx("button",{type:"button",className:"lte-dialog-close",onClick:t,children:"×"}),r]})}):null}async function xe(e,{src:t,altText:n="",caption:i=""}){e.update(()=>{const e=he({src:t,altText:n,caption:i});d.$insertNodes([e])})}function fe({onImageUpload:e}){const[t]=N.useLexicalComposerContext(),i=o.useRef(null),[r,s]=o.useState(!1),[l,a]=o.useState(""),[c,u]=o.useState(""),[h,p]=o.useState(""),[g,m]=o.useState(),[x,f]=o.useState(!1),y=o.useCallback(async(n,i="",o="")=>{let r;r=e?await e(n):URL.createObjectURL(n),xe(t,{src:r,altText:i,caption:o})},[t,e]);return o.useEffect(()=>{const e=t.registerCommand(d.PASTE_COMMAND,e=>{if(e instanceof ClipboardEvent){const t=e.clipboardData?.items;if(!t)return!1;for(const n of t)if(n.type.startsWith("image/")){e.preventDefault();const t=n.getAsFile();return t&&y(t,"","").catch(console.error),!0}}return!1},d.COMMAND_PRIORITY_LOW);return()=>e()},[t,y]),n.jsxs("div",{className:"lexical-text-editor-dialog",children:[n.jsx("input",{type:"file",ref:i,accept:"image/*",className:"lte-hidden",onChange:e=>{const t=e.target.files?.[0];t&&m(t),e.target.value=""}}),n.jsx("button",{type:"button",className:`size-8 lexical-btn ${r?"toolbarActive":"toolbar"} icon`,onClick:()=>s(e=>!e),children:n.jsx(b.IoImageOutline,{size:18})}),n.jsxs(me,{open:r,onClose:()=>s(!1),children:[n.jsx("div",{className:"lte-dialog-header",children:"Add Image"}),n.jsxs("div",{className:"lte-dialog-body",children:[n.jsx("input",{className:"lte-input",placeholder:"Alt text",value:c,onChange:e=>u(e.target.value)}),n.jsx("input",{className:"lte-input",placeholder:"Caption",value:h,onChange:e=>p(e.target.value)}),n.jsx("input",{className:"lte-input",placeholder:"Add image by URL",value:l,onChange:e=>a(e.target.value)}),n.jsx("div",{className:"lte-divider",children:n.jsx("span",{children:"or"})}),n.jsxs("button",{type:"button",className:"lexical-btn heading-trigger toolbar-active",onClick:()=>i.current?.click(),style:{width:"fit-content",margin:"0 auto"},children:[n.jsx(k.LuUpload,{size:20}),n.jsx("span",{children:"Upload Image"})]}),g&&n.jsx("div",{className:"lte-file-name",children:g.name})]}),n.jsx("div",{className:"lte-dialog-footer",children:n.jsx("button",{type:"button",className:"lte-primary-btn",disabled:!l&&!g||x,onClick:async()=>{if(!x){if(g){f(!0);try{await y(g,c,h)}catch(e){return console.error("Image upload failed:",e),void f(!1)}f(!1)}else{if(!l)return;xe(t,{src:l,altText:c,caption:h})}m(void 0),u(""),p(""),a(""),s(!1)}},children:x?"Uploading...":"Add Image"})})]})]})}const be=({id:e,provider:t})=>new we({id:e,provider:t}),ye="data-lexical-video",Ne="data-provider",ve="315px",Ce="560px",_e=(e,t)=>"drive"===t?`https://drive.google.com/file/d/${e}/preview`:`https://www.youtube-nocookie.com/embed/${e}`,je=e=>{const t=e?.getAttribute(ye),n=e?.getAttribute(Ne)??"youtube";if(!t)return null;return{node:be({id:t,provider:n})}};class we extends d.DecoratorNode{constructor({id:e,provider:t,key:n}){super(n),this.__id=e,this.__provider=t}static getType(){return"video"}static clone(e){return new we({id:e.__id,provider:e.__provider,key:e.getKey()})}static importJSON(e){return be({id:e.id,provider:e.provider})}exportJSON(){return{id:this.__id,provider:this.__provider,type:"video",version:1}}updateDOM(){return!1}decorate(){return n.jsx("iframe",{height:ve,width:Ce,src:_e(this.__id,this.__provider),frameBorder:"0",allowFullScreen:!0})}createDOM(){return document.createElement("div")}exportDOM(){const e=document.createElement("iframe");return e.setAttribute(ye,this.__id),e.setAttribute(Ne,this.__provider),e.setAttribute("height",ve),e.setAttribute("width",Ce),e.setAttribute("src",_e(this.__id,this.__provider)),{element:e}}static importDOM(){return{iframe:()=>({conversion:je,priority:0})}}}function Se(){const[e,t]=o.useState(!1),[i,r]=o.useState(!1),[s,l]=o.useState(""),[a]=N.useLexicalComposerContext();return o.useEffect(()=>{e||(l(""),r(!1))},[e]),n.jsxs("div",{className:"lexical-text-editor-dialog",children:[n.jsx("button",{type:"button",className:`size-8 lexical-btn ${e?"toolbarActive":"toolbar"} icon`,onClick:()=>t(!0),children:n.jsx(E.FaYoutube,{size:18,color:"red"})}),n.jsxs(me,{open:e,onClose:()=>t(!1),children:[n.jsx("div",{className:"lte-dialog-header",children:"Embed Video"}),n.jsxs("div",{className:"lte-dialog-body",children:[n.jsx("input",{className:"lte-input",placeholder:"Add YouTube or Google Drive URL",value:s,onChange:e=>l(e.target.value)}),i&&n.jsx("p",{className:"lte-error-text",children:"It's not a valid YouTube or Google Drive URL"})]}),n.jsx("div",{className:"lte-dialog-footer",children:n.jsx("button",{type:"button",className:"lte-primary-btn",disabled:!s,onClick:()=>{if(!s)return;let e=null,n=null;const i=/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/.exec(s);i&&11===i[2]?.length&&(e="youtube",n=i[2]);const o=/drive\.google\.com\/file\/d\/([a-zA-Z0-9_-]+)\//.exec(s);o&&o[1]&&(e="drive",n=o[1]),n&&e?(a.update(()=>{const t=be({id:n,provider:e});d.$insertNodes([t])}),l(""),r(!1),t(!1)):r(!0)},children:"Embed"})})]})]})}function Te({value:e}){return n.jsx("div",{className:"lexical-text-editor-html-preview",dangerouslySetInnerHTML:{__html:e}})}function ke({value:e,triggerLabel:t="Preview"}){const[i,r]=o.useState(!1);return n.jsxs("div",{className:"lexical-text-editor-dialog",children:[n.jsxs("button",{type:"button",className:"lexical-btn heading-trigger "+(i?"toolbar-active":"toolbar"),onClick:()=>r(e=>!e),children:[n.jsx(A.VscPreview,{size:18}),n.jsx("span",{children:t})]}),n.jsxs(me,{open:i,onClose:()=>r(!1),forPreview:!0,children:[n.jsx("div",{className:"lte-dialog-header",children:"Content Preview"}),n.jsxs("div",{className:"lte-preview-container",children:[n.jsx("div",{className:"lte-preview-title",children:"CONTENT"}),n.jsx(Te,{value:e})]})]})]})}const Ee=({value:i,onImageUpload:s})=>{const[l]=N.useLexicalComposerContext(),[a,c]=o.useState({[e.Undo]:!0,[e.Redo]:!0}),[u,h]=o.useState(!1),[g,m]=o.useState({[e.LeftAlign]:!0}),[x,f]=o.useState({[t.Normal]:!0}),[b,y]=o.useState("paragraph"),[C,j]=o.useState("https://");let w=!0;const S=()=>{if(w){const e=l.getRootElement();e&&(e.scrollTop=0,w=!1)}const n=d.$getSelection();if(d.$isRangeSelection(n)){const i={[e.Bold]:n.hasFormat("bold"),[e.Italics]:n.hasFormat("italic"),[e.Underline]:n.hasFormat("underline"),[e.Uppercase]:n.hasFormat("uppercase"),[e.Lowercase]:n.hasFormat("lowercase"),[e.Capitalize]:n.hasFormat("capitalize"),[e.Strikethrough]:n.hasFormat("strikethrough"),[e.Superscript]:n.hasFormat("superscript"),[e.Subscript]:n.hasFormat("subscript"),[e.Code]:n.hasFormat("code"),[e.Highlight]:n.hasFormat("highlight")};m(i);const o=n.anchor.getNode(),s="root"===o.getKey()?o:o.getTopLevelElementOrThrow(),a=s.getKey();if(!l.getElementByKey(a))return;if(p.$isListNode(s)){const e=function(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null}(o,p.ListNode),t=e?e.getTag():s.getTag();y(t)}else if("paragraph"===s.getType()||r.$isHeadingNode(s)){let e=null;r.$isHeadingNode(s)&&(e=s.getTag());const n={[t.H1]:"h1"===e,[t.H2]:"h2"===e,[t.H3]:"h3"===e,[t.H4]:"h4"===e,[t.H5]:"h5"===e,[t.H6]:"h6"===e,[t.Normal]:"paragraph"===s.getType()};y(s.getType()),f(n)}else y(s.getType());const c=(d.$isElementNode(o)?o:s).getFormat();m(t=>({...t,[e.LeftAlign]:0===c||1===c,[e.CenterAlign]:2===c,[e.RightAlign]:3===c,[e.JustifyAlign]:4===c})),"quote"===s.getType()?m(t=>({...t,[e.Quote]:!0})):m(t=>({...t,[e.Quote]:!1}));const u=n.anchor.getNode(),g=u.getParent();v.$isLinkNode(g)?(m(t=>({...t,[e.Link]:!0})),j(g.getURL()),h(!0)):v.$isLinkNode(u)?(m(t=>({...t,[e.Link]:!0})),j(u.getURL()),h(!0)):(m(t=>({...t,[e.Link]:!1})),j("https://"),h(!1))}};o.useEffect(()=>V(l.registerUpdateListener(({editorState:e})=>{e.read(()=>{S()})}),l.registerCommand(d.SELECTION_CHANGE_COMMAND,()=>(S(),!1),1),l.registerCommand(d.CAN_UNDO_COMMAND,e=>(c(t=>({...t,undo:!e})),!1),1),l.registerCommand(d.CAN_REDO_COMMAND,e=>(c(t=>({...t,redo:!e})),!1),1)),[]);const T=t=>{switch(t){case e.Bold:l.dispatchCommand(d.FORMAT_TEXT_COMMAND,"bold");break;case e.Italics:l.dispatchCommand(d.FORMAT_TEXT_COMMAND,"italic");break;case e.Underline:l.dispatchCommand(d.FORMAT_TEXT_COMMAND,"underline");break;case e.Lowercase:l.dispatchCommand(d.FORMAT_TEXT_COMMAND,"lowercase");break;case e.Uppercase:l.dispatchCommand(d.FORMAT_TEXT_COMMAND,"uppercase");break;case e.Capitalize:l.dispatchCommand(d.FORMAT_TEXT_COMMAND,"capitalize");break;case e.Strikethrough:l.dispatchCommand(d.FORMAT_TEXT_COMMAND,"strikethrough");break;case e.Superscript:l.dispatchCommand(d.FORMAT_TEXT_COMMAND,"superscript");break;case e.Subscript:l.dispatchCommand(d.FORMAT_TEXT_COMMAND,"subscript");break;case e.Highlight:l.dispatchCommand(d.FORMAT_TEXT_COMMAND,"highlight");break;case e.Code:l.dispatchCommand(d.FORMAT_TEXT_COMMAND,"code");break;case e.Quote:l.update(()=>{const e=d.$getSelection();if(d.$isRangeSelection(e)){const t=e.anchor.getNode().getParent();t&&r.$isQuoteNode(t)?function(e,t,n=q){if(null===e)return;const i=e.getStartEndPoints(),o=new Map;let r=null;if(i){const[e,t]=i;r=d.$createRangeSelection(),r.anchor.set(e.key,e.offset,e.type),r.focus.set(t.key,t.offset,t.type);const n=d.$findMatchingParent(e.getNode(),d.INTERNAL_$isBlock),s=d.$findMatchingParent(t.getNode(),d.INTERNAL_$isBlock);d.$isElementNode(n)&&o.set(n.getKey(),n),d.$isElementNode(s)&&o.set(s.getKey(),s)}for(const t of e.getNodes())if(d.$isElementNode(t)&&d.INTERNAL_$isBlock(t))o.set(t.getKey(),t);else if(null===i){const e=d.$findMatchingParent(t,d.INTERNAL_$isBlock);d.$isElementNode(e)&&o.set(e.getKey(),e)}for(const[e,i]of o){const o=t();n(i,o),i.replace(o,!0),r&&(e===r.anchor.key&&r.anchor.set(o.getKey(),r.anchor.offset,r.anchor.type),e===r.focus.key&&r.focus.set(o.getKey(),r.focus.offset,r.focus.type))}r&&e.is(d.$getSelection())&&d.$setSelection(r)}(e,()=>d.$createParagraphNode()):W(e,()=>r.$createQuoteNode())}});break;case e.Link:k(),h(!0);break;case e.LeftAlign:l.dispatchCommand(d.FORMAT_ELEMENT_COMMAND,"left");break;case e.RightAlign:l.dispatchCommand(d.FORMAT_ELEMENT_COMMAND,"right");break;case e.CenterAlign:l.dispatchCommand(d.FORMAT_ELEMENT_COMMAND,"center");break;case e.JustifyAlign:l.dispatchCommand(d.FORMAT_ELEMENT_COMMAND,"justify");break;case e.Undo:l.dispatchCommand(d.UNDO_COMMAND,void 0);break;case e.Redo:l.dispatchCommand(d.REDO_COMMAND,void 0)}},k=o.useCallback(()=>{l.update(()=>{const e=d.$getSelection();d.$isRangeSelection(e)&&!e.isCollapsed()&&(u?l.dispatchCommand(v.TOGGLE_LINK_COMMAND,null):""!==C&&l.dispatchCommand(v.TOGGLE_LINK_COMMAND,C))})},[l,u,C]),E=o.useCallback(()=>{j(""),l.dispatchCommand(v.TOGGLE_LINK_COMMAND,null),h(!1)},[l]);return n.jsxs("div",{className:"lexical-toolbar-wrapper",style:{position:"relative",padding:12,marginBottom:4,borderBottom:"1px solid #e5e7eb"},children:[$.map(({id:t,label:i,icon:o})=>t===e.Divider?n.jsx(ie,{},t):n.jsx(ae,{content:i,direction:"bottom",children:n.jsx("button",{type:"button",className:`size-8 lexical-btn ${g[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>T(t),disabled:!!a[t],children:o})},i)),n.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:[n.jsx(oe,{updateHeading:e=>{l.update(()=>{const t=d.$getSelection();d.$isRangeSelection(t)&&W(t,"normal"===e?()=>d.$createParagraphNode():()=>r.$createHeadingNode(e))})},headingSelectionMap:x}),n.jsx(ie,{})]}),R.map(({id:t,label:i,icon:o})=>t===e.Divider?n.jsx(ie,{},t):n.jsx(ae,{content:i,direction:"bottom",children:n.jsx("button",{type:"button",className:`size-8 lexical-btn ${g[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>T(t),children:o})},t)),n.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:[n.jsx(de,{blockType:b}),n.jsx(ie,{})]}),n.jsx(ce,{}),n.jsx(ne,{onAction:T,selectionMap:g}),n.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:[n.jsx(se,{onAction:T,alignmentSelectionMap:g}),n.jsx(ie,{})]}),n.jsx(ae,{content:"Link",direction:"bottom",children:n.jsx("button",{type:"button",className:`size-8 lexical-btn ${g[e.Link]?"toolbarActive":"toolbar"} icon`,onClick:()=>T(e.Link),disabled:!!a[e.Link],children:n.jsx(_.IoIosLink,{})})}),u&&n.jsx(re,{linkUrl:C,setLinkUrl:j,removeLink:E,onConfirm:e=>{l.dispatchCommand(v.TOGGLE_LINK_COMMAND,{url:e,target:"_blank"}),j(e),h(!1)},onCancel:()=>{j(""),h(!1)}}),n.jsx(fe,{onImageUpload:s}),n.jsx(Se,{}),n.jsx(ke,{value:i})]})};function Ae(e,t){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const n=document.createElement("div"),i=d.$getRoot().getChildren();for(let o=0;o<i.length;o++)Me(e,i[o],n,t);return n.innerHTML}function Me(e,t,n,i=null){let o=null===i||t.isSelected(i);const r=d.$isElementNode(t)&&t.excludeFromCopy("html");let s=t;if(null!==i){let e=d.$cloneWithProperties(t);e=d.$isTextNode(e)&&null!==i?function(e,t){const n=e.getStartEndPoints();if(t.isSelected(e)&&!d.$isTokenOrSegmented(t)&&null!==n){const[i,o]=n,r=e.isBackward(),s=i.getNode(),l=o.getNode(),a=t.is(s),c=t.is(l);if(a||c){const[n,i]=d.$getCharacterOffsets(e),o=s.is(l),a=t.is(r?l:s),c=t.is(r?s:l);let u,h=0;o?(h=n>i?i:n,u=n>i?n:i):a?(h=r?i:n,u=void 0):c&&(h=0,u=r?n:i),t.__text=t.__text.slice(h,u)}}return t}(i,e):e,s=e}const l=d.$isElementNode(s)?s.getChildren():[],a=d.getRegisteredNode(e,s.getType());let c;c=a&&void 0!==a.exportDOM?a.exportDOM(e,s):s.exportDOM(e);const{element:u,after:h}=c;if(!u)return!1;const p=document.createDocumentFragment();for(let n=0;n<l.length;n++){const r=l[n],s=Me(e,r,p,i);!o&&d.$isElementNode(t)&&s&&t.extractWithChild(r,i,"html")&&(o=!0)}if(o&&!r){if((d.isHTMLElement(u)||d.isDocumentFragment(u))&&u.append(p),n.append(u),h){const e=h.call(s,u);e&&(d.isDocumentFragment(u)?u.replaceChildren(e):u.replaceWith(e))}}else n.append(p);return o}const Le=new Set(["STYLE","SCRIPT"]);function Oe(e,t,n,i,o=new Map,r){let s=[];if(Le.has(e.nodeName))return s;let l=null;const a=function(e,t){const{nodeName:n}=e,i=t._htmlConversions.get(n.toLowerCase());let o=null;if(void 0!==i)for(const t of i){const n=t(e);null!==n&&(null===o||(o.priority||0)<=(n.priority||0))&&(o=n)}return null!==o?o.conversion:null}(e,t),c=a?a(e):null;let u=null;if(null!==c){u=c.after;const t=c.node;if(l=Array.isArray(t)?t[t.length-1]:t,null!==l){for(const[,e]of o)if(l=e(l,r),!l)break;l&&s.push(...Array.isArray(t)?t:[l])}null!=c.forChild&&o.set(e.nodeName,c.forChild)}const h=e.childNodes;let p=[];const g=(null==l||!d.$isRootOrShadowRoot(l))&&(null!=l&&d.$isBlockElementNode(l)||i);for(let e=0;e<h.length;e++)p.push(...Oe(h[e],t,n,g,new Map(o),l));return null!=u&&(p=u(p)),d.isBlockDomNode(e)&&(p=function(e,t,n){const i=e.style.textAlign,o=[];let r=[];for(let e=0;e<t.length;e++){const s=t[e];if(d.$isBlockElementNode(s))i&&!s.getFormat()&&s.setFormat(i),o.push(s);else if(r.push(s),e===t.length-1||e<t.length-1&&d.$isBlockElementNode(t[e+1])){const e=n();e.setFormat(i),e.append(...r),o.push(e),r=[]}}return o}(e,p,g?()=>{const e=new d.ArtificialNode__DO_NOT_USE;return n.push(e),e}:d.$createParagraphNode)),null==l?p.length>0?s=s.concat(p):d.isBlockDomNode(e)&&function(e){return null!=e.nextSibling&&null!=e.previousSibling&&(d.isInlineDomNode(e.nextSibling)&&d.isInlineDomNode(e.previousSibling))}(e)&&(s=s.concat(d.$createLineBreakNode())):d.$isElementNode(l)&&l.append(...p),s}function Re({value:e,onChange:t}){const[i]=N.useLexicalComposerContext(),[r,s]=o.useState(!0);return o.useEffect(()=>{e&&r&&(s(!1),i.update(()=>{if(Ae(i)!==e){d.$getRoot().clear();const t=(new DOMParser).parseFromString(e,"text/html"),n=function(e,t){const n=d.isDOMDocumentNode(t)?t.body.childNodes:t.childNodes;let i=[];const o=[];for(const t of n)if(!Le.has(t.nodeName)){const n=Oe(t,e,o,!1);null!==n&&(i=i.concat(n))}return function(e){for(const t of e)t.getNextSibling()instanceof d.ArtificialNode__DO_NOT_USE&&t.insertAfter(d.$createLineBreakNode());for(const t of e){const e=t.getChildren();for(const n of e)t.insertBefore(n);t.remove()}}(o),i}(i,t);d.$insertNodes(n)}}))},[i,e,r]),o.useEffect(()=>{s(!0)},[e]),n.jsx(L.OnChangePlugin,{onChange:e=>{e.read(()=>{t(Ae(i))})}})}const $e=({id:e})=>new Pe({id:e}),De="data-lexical-youtube",Ie="315px",Be="560px",Fe=e=>`https://www.youtube-nocookie.com/embed/${e}`,He=e=>{const t=e?.getAttribute(De);if(!t)return null;return{node:$e({id:t})}};class Pe extends d.DecoratorNode{constructor({id:e,key:t}){super(t),this.__id=e}static getType(){return"youtube"}static clone(e){return new Pe({id:e.__id,key:e.getKey()})}static importJSON(e){return $e({id:e.id})}exportJSON(){return{id:this.__id,type:"youtube",version:1}}decorate(){return n.jsx("iframe",{height:Ie,width:Be,src:Fe(this.__id),frameBorder:"0",allowFullScreen:!0})}createDOM(){return document.createElement("div")}exportDOM(){const e=document.createElement("iframe");return e.setAttribute(De,this.__id),e.setAttribute("height",Ie),e.setAttribute("width",Be),e.setAttribute("src",Fe(this.__id)),{element:e}}static importDOM(){return{iframe:()=>({conversion:He,priority:0})}}}class Ue extends d.TextNode{constructor(e,t){super(e,t)}static getType(){return"extended-text"}static clone(e){return new Ue(e.__text,e.__key)}static importDOM(){const e=d.TextNode.importDOM();return{...e,span:()=>({conversion:qe(e?.span),priority:1}),div:()=>({conversion:qe(e?.div),priority:1}),p:()=>({conversion:qe(e?.p),priority:1}),b:()=>({conversion:qe(e?.b),priority:1}),strong:()=>({conversion:qe(e?.strong),priority:1}),i:()=>({conversion:qe(e?.i),priority:1}),em:()=>({conversion:qe(e?.em),priority:1}),u:()=>({conversion:qe(e?.u),priority:1}),s:()=>({conversion:qe(e?.s),priority:1}),strike:()=>({conversion:qe(e?.strike),priority:1}),code:()=>({conversion:qe(e?.code),priority:1})}}static importJSON(e){return function(e=""){return d.$applyNodeReplacement(new Ue(e))}().updateFromJSON(e)}isSimpleText(){return"extended-text"===this.__type&&0===this.__mode}}function qe(e){return t=>{const n=e?.(t);if(!n)return null;const i=n.conversion(t);if(!i)return i;const o=t.style,r=[];o.backgroundColor&&r.push(`background-color: ${o.backgroundColor}`),o.color&&r.push(`color: ${o.color}`),o.fontFamily&&r.push(`font-family: ${o.fontFamily}`),o.fontWeight&&r.push(`font-weight: ${o.fontWeight}`),o.fontSize&&r.push(`font-size: ${o.fontSize}`),o.fontStyle&&r.push(`font-style: ${o.fontStyle}`),o.textDecoration&&r.push(`text-decoration: ${o.textDecoration}`),o.whiteSpace&&r.push(`white-space: ${o.whiteSpace}`),o.textAlign&&r.push(`text-align: ${o.textAlign}`);const s=t.getAttribute("style");if(s){s.split(";").filter(e=>e.trim()).forEach(e=>{const[t]=e.split(":").map(e=>e.trim());t&&!r.some(e=>e.startsWith(t))&&r.push(e.trim())})}return{...i,forChild:(e,t)=>{const n=i?.forChild??(e=>e),o=n(e,t);if(d.$isTextNode(o)&&r.length>0){const e=r.join("; ");return o.setStyle(e)}return o}}}}const ze={text:{bold:"lexical-bold",underline:"lexical-underline",italic:"lexical-italic",strikethrough:"lexical-strikethrough",underlineStrikethrough:"lexical-underline-strikethrough",uppercase:"lexical-uppercase",lowercase:"lexical-lowercase",capitalize:"lexical-capitalize",code:"lexical-code"},paragraph:"lexical-paragraph",list:{ul:"lexical-list-ul",ol:"lexical-list-ol",listitem:"lexical-listitem"},quote:"lexical-quote",link:"lexical-link"},Ke=o.memo(function({name:e,value:t,onChange:g,placeholder:m,maxWidth:x=null,height:f=null,onImageUpload:b}){const y=o.useMemo(()=>({namespace:e,theme:ze,onError:e=>{console.error("Lexical error:",e)},nodes:[Ue,{replace:d.TextNode,with:e=>new Ue(e.__text),withKlass:Ue},r.HeadingNode,s.CodeHighlightNode,s.CodeNode,p.ListNode,p.ListItemNode,r.QuoteNode,v.LinkNode,ge,Pe,we]}),[e]);return n.jsx("div",{className:"lexical-text-editor lexical-editor-container",style:{maxWidth:x||"1090px"},children:n.jsxs(i.LexicalComposer,{initialConfig:y,children:[n.jsx("div",{className:"lexical-toolbar-container",children:n.jsx(Ee,{value:t,onImageUpload:b})}),n.jsx("div",{className:"lexical-editor-inner",children:n.jsx(l.RichTextPlugin,{contentEditable:n.jsx(a.ContentEditable,{className:"lexical-content-editable",style:{height:f||"500px"}}),placeholder:n.jsx("div",{className:"lexical-placeholder",children:m||"Some Text"}),ErrorBoundary:c.LexicalErrorBoundary})}),n.jsx(u.HistoryPlugin,{}),n.jsx(h.ListPlugin,{}),n.jsx(M.LinkPlugin,{}),n.jsx(Re,{value:t,onChange:g})]})})});exports.LexicalTextEditor=Ke;
|
|
1
|
+
"use strict";var e,t,n=require("react/jsx-runtime"),o=require("@lexical/react/LexicalComposer"),i=require("react"),l=require("@lexical/rich-text"),r=require("@lexical/code"),s=require("@lexical/react/LexicalRichTextPlugin"),a=require("@lexical/react/LexicalContentEditable"),c=require("@lexical/react/LexicalErrorBoundary"),d=require("lexical"),u=require("@lexical/react/LexicalHistoryPlugin"),h=require("@lexical/react/LexicalListPlugin"),p=require("@lexical/list"),g=require("@lexical/react/LexicalHorizontalRuleNode"),m=require("@lexical/react/LexicalHorizontalRulePlugin"),x=require("@lexical/react/LexicalTablePlugin"),f=require("@lexical/table"),b=require("react-icons/rx"),y=require("react-icons/tb"),C=require("react-icons/bs"),v=require("react-icons/ai"),N=require("react-icons/io5"),j=require("react-icons/pi"),w=require("react-icons/ri"),S=require("@lexical/react/LexicalComposerContext"),k=require("@lexical/link"),T=require("react-icons/hi2"),E=require("react-dom"),_=require("react-icons/io"),R=require("react-icons/md"),L=require("react-icons/bi"),M=require("react-color"),$=require("react-icons/lu"),A=require("react-icons/fa"),O=require("react-icons/vsc"),D=require("@lexical/react/LexicalLinkPlugin"),I=require("@lexical/react/LexicalOnChangePlugin");!function(e){e.Bold="bold",e.Italics="italics",e.Underline="underline",e.Quote="quote",e.Lowercase="lowercase",e.Uppercase="uppercase",e.Capitalize="capitalize",e.Strikethrough="strikethrough",e.Superscript="superscript",e.Subscript="subscript",e.Highlight="highlight",e.Code="code",e.Link="link",e.LeftAlign="leftAlign",e.CenterAlign="centerAlign",e.RightAlign="rightAlign",e.JustifyAlign="justifyAlign",e.Divider="divider",e.Undo="undo",e.Redo="redo",e.ClearFormatting="clearFormatting",e.CodeBlock="codeBlock",e.HorizontalRule="horizontalRule",e.Indent="indent",e.Outdent="outdent",e.Table="table",e.FindReplace="findReplace",e.SourceView="sourceView",e.Fullscreen="fullscreen"}(e||(e={})),function(e){e.Normal="normal",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6"}(t||(t={}));const F=[{id:e.Lowercase,icon:n.jsx(b.RxLetterCaseLowercase,{}),label:"Lowercase"},{id:e.Uppercase,icon:n.jsx(b.RxLetterCaseUppercase,{}),label:"Uppercase"},{id:e.Capitalize,icon:n.jsx(b.RxLetterCaseCapitalize,{}),label:"Capitalize"},{id:e.Strikethrough,icon:n.jsx(v.AiOutlineStrikethrough,{}),label:"Strikethrough"},{id:e.Highlight,icon:n.jsx(j.PiHighlighterLight,{}),label:"Highlight",fontSize:10},{id:e.Superscript,icon:n.jsx(C.BsSuperscript,{}),label:"Superscript"},{id:e.Subscript,icon:n.jsx(C.BsSubscript,{}),label:"Subscript"}],B=[{id:e.Bold,icon:n.jsx(y.TbBold,{}),label:"Bold"},{id:e.Italics,icon:n.jsx(y.TbItalic,{}),label:"Italics"},{id:e.Underline,icon:n.jsx(y.TbUnderline,{}),label:"Underline"},{id:e.Divider},{id:e.Quote,icon:n.jsx(C.BsChatSquareQuote,{}),label:"Quote"},{id:e.Code,icon:n.jsx(N.IoCodeSlashOutline,{}),label:"Code"},{id:e.ClearFormatting,icon:n.jsx(w.RiEraserLine,{}),label:"Clear Formatting"}],H=[{id:e.Undo,icon:n.jsx(C.BsArrowCounterclockwise,{}),label:"Undo"},{id:e.Redo,icon:n.jsx(C.BsArrowClockwise,{}),label:"Redo"},{id:e.Divider}],z=[{id:e.LeftAlign,icon:n.jsx(C.BsJustifyLeft,{}),label:"Left Align"},{id:e.CenterAlign,icon:n.jsx(C.BsTextCenter,{}),label:"Center Align"},{id:e.RightAlign,icon:n.jsx(C.BsJustifyRight,{}),label:"Right Align"},{id:e.JustifyAlign,icon:n.jsx(C.BsJustify,{}),label:"Justify Align"}],P=[{id:e.Indent,icon:n.jsx(w.RiIndentIncrease,{}),label:"Indent"},{id:e.Outdent,icon:n.jsx(w.RiIndentDecrease,{}),label:"Outdent"},{id:e.Divider},{id:e.HorizontalRule,icon:n.jsx(y.TbSeparatorHorizontal,{}),label:"Horizontal Rule"}],W=[{id:"normal",label:"Normal",icon:n.jsx(C.BsTextParagraph,{})},{id:"h1",label:"Heading 1",icon:n.jsx(C.BsTypeH1,{})},{id:"h2",label:"Heading 2",icon:n.jsx(C.BsTypeH2,{})},{id:"h3",label:"Heading 3",icon:n.jsx(C.BsTypeH3,{})},{id:"h4",label:"Heading 4",icon:n.jsx(C.BsTypeH4,{})},{id:"h5",label:"Heading 5",icon:n.jsx(C.BsTypeH5,{})},{id:"h6",label:"Heading 6",icon:n.jsx(C.BsTypeH6,{})}],U=[{id:"plaintext",label:"Plain Text"},{id:"javascript",label:"JavaScript"},{id:"typescript",label:"TypeScript"},{id:"python",label:"Python"},{id:"java",label:"Java"},{id:"csharp",label:"C#"},{id:"cpp",label:"C++"},{id:"php",label:"PHP"},{id:"ruby",label:"Ruby"},{id:"go",label:"Go"},{id:"rust",label:"Rust"},{id:"swift",label:"Swift"},{id:"kotlin",label:"Kotlin"},{id:"html",label:"HTML"},{id:"css",label:"CSS"},{id:"sql",label:"SQL"},{id:"json",label:"JSON"},{id:"bash",label:"Bash"},{id:"markdown",label:"Markdown"},{id:"yaml",label:"YAML"},{id:"xml",label:"XML"}];function q(e,...t){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",e);for(const e of t)o.append("v",e);throw n.search=o.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const K=new Map;function J(e){let t=K.get(e);return void 0===t&&(t=function(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,o]=e.split(/:([^]+)/);n&&o&&(t[n.trim()]=o.trim())}return t}(e),K.set(e,t)),t}function G(e,t){(d.$isRangeSelection(e)?e.isCollapsed():d.$isTextNode(e)||d.$isElementNode(e))||q(280);const n=J(d.$isRangeSelection(e)?e.style:d.$isTextNode(e)?e.getStyle():e.getTextStyle()),o=Object.entries(t).reduce((t,[o,i])=>("function"==typeof i?t[o]=i(n[o],e):null===i?delete t[o]:t[o]=i,t),{...n}),i=function(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}(o);d.$isRangeSelection(e)||d.$isTextNode(e)?e.setStyle(i):e.setTextStyle(i),K.set(i,o)}function V(e,t){if(d.$isRangeSelection(e)&&e.isCollapsed()){G(e,t);const n=e.anchor.getNode();d.$isElementNode(n)&&n.isEmpty()&&G(n,t)}!function(e){const t=d.$getSelection();if(!t)return;const n=new Map,o=e=>n.get(e.getKey())||[0,e.getTextContentSize()];if(d.$isRangeSelection(t))for(const e of d.$caretRangeFromSelection(t).getTextSlices())e&&n.set(e.caret.origin.getKey(),e.getSliceIndices());const i=t.getNodes();for(const t of i){if(!d.$isTextNode(t)||!t.canHaveFormat())continue;const[n,i]=o(t);i!==n&&(d.$isTokenOrSegmented(t)||0===n&&i===t.getTextContentSize()?e(t):e(t.splitText(n,i)[0===n?0:1]))}d.$isRangeSelection(t)&&"text"===t.anchor.type&&"text"===t.focus.type&&t.anchor.key===t.focus.key&&function(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:o,offset:i,type:l}=t;t.set(n.key,n.offset,n.type),n.set(o,i,l)}}(t)}(e=>{G(e,t)})}function X(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o)}function Q(e,t,n=X){if(null===e)return;const o=e.getStartEndPoints(),i=new Map;let l=null;if(o){const[e,t]=o;l=d.$createRangeSelection(),l.anchor.set(e.key,e.offset,e.type),l.focus.set(t.key,t.offset,t.type);const n=d.$findMatchingParent(e.getNode(),d.INTERNAL_$isBlock),r=d.$findMatchingParent(t.getNode(),d.INTERNAL_$isBlock);d.$isElementNode(n)&&i.set(n.getKey(),n),d.$isElementNode(r)&&i.set(r.getKey(),r)}for(const t of e.getNodes())if(d.$isElementNode(t)&&d.INTERNAL_$isBlock(t))i.set(t.getKey(),t);else if(null===o){const e=d.$findMatchingParent(t,d.INTERNAL_$isBlock);d.$isElementNode(e)&&i.set(e.getKey(),e)}for(const[e,o]of i){const i=t();n(o,i),o.replace(i,!0),l&&(e===l.anchor.key&&l.anchor.set(i.getKey(),l.anchor.offset,l.anchor.type),e===l.focus.key&&l.focus.set(i.getKey(),l.focus.offset,l.focus.type))}l&&e.is(d.$getSelection())&&d.$setSelection(l)}function Y(e){return e.getNode().isAttached()}function Z(e){let t=e;for(;null!==t&&!d.$isRootOrShadowRoot(t);){const e=t.getLatest(),n=t.getParent();0===e.getChildrenSize()&&t.remove(!0),t=n}}function ee(e,t,n=null){const o=e.getStartEndPoints(),i=o?o[0]:null,l=e.getNodes(),r=l.length;if(null!==i&&(0===r||1===r&&"element"===i.type&&0===i.getNode().getChildrenSize())){const e="text"===i.type?i.getNode().getParentOrThrow():i.getNode(),o=e.getChildren();let l=t();return l.setFormat(e.getFormatType()),l.setIndent(e.getIndent()),o.forEach(e=>l.append(e)),n&&(l=n.append(l)),void e.replace(l)}let s=null,a=[];for(let o=0;o<r;o++){const i=l[o];d.$isRootOrShadowRoot(i)?(te(e,a,a.length,t,n),a=[],s=i):null===s||null!==s&&d.$hasAncestor(i,s)?a.push(i):(te(e,a,a.length,t,n),a=[i])}te(e,a,a.length,t,n)}function te(e,t,n,o,i=null){if(0===t.length)return;const l=t[0],r=new Map,s=[];let a=d.$isElementNode(l)?l:l.getParentOrThrow();a.isInline()&&(a=a.getParentOrThrow());let c=!1;for(;null!==a;){const e=a.getPreviousSibling();if(null!==e){a=e,c=!0;break}if(a=a.getParentOrThrow(),d.$isRootOrShadowRoot(a))break}const u=new Set;for(let e=0;e<n;e++){const n=t[e];d.$isElementNode(n)&&0===n.getChildrenSize()&&u.add(n.getKey())}const h=new Set;for(let e=0;e<n;e++){const n=t[e];let i=n.getParent();if(null!==i&&i.isInline()&&(i=i.getParent()),null!==i&&d.$isLeafNode(n)&&!h.has(n.getKey())){const e=i.getKey();if(void 0===r.get(e)){const t=o();t.setFormat(i.getFormatType()),t.setIndent(i.getIndent()),s.push(t),r.set(e,t),i.getChildren().forEach(e=>{t.append(e),h.add(e.getKey()),d.$isElementNode(e)&&e.getChildrenKeys().forEach(e=>h.add(e))}),Z(i)}}else if(u.has(n.getKey())){d.$isElementNode(n)||q(179);const e=o();e.setFormat(n.getFormatType()),e.setIndent(n.getIndent()),s.push(e),n.remove(!0)}}if(null!==i)for(let e=0;e<s.length;e++){const t=s[e];i.append(t)}let p=null;if(d.$isRootOrShadowRoot(a))if(c)if(null!==i)a.insertAfter(i);else for(let e=s.length-1;e>=0;e--){const t=s[e];a.insertAfter(t)}else{const e=a.getFirstChild();if(d.$isElementNode(e)&&(a=e),null===e)if(i)a.append(i);else for(let e=0;e<s.length;e++){const t=s[e];a.append(t),p=t}else if(null!==i)e.insertBefore(i);else for(let t=0;t<s.length;t++){const n=s[t];e.insertBefore(n),p=n}}else if(i)a.insertAfter(i);else for(let e=s.length-1;e>=0;e--){const t=s[e];a.insertAfter(t),p=t}const g=d.$getPreviousSelection();d.$isRangeSelection(g)&&Y(g.anchor)&&Y(g.focus)?d.$setSelection(g.clone()):null!==p?p.selectEnd():e.dirty=!0}function ne(e,t,n){const o=J(e.getStyle());return null!==o&&o[t]||n}function oe(e,t,n=""){let o=null;const i=e.getNodes(),l=e.anchor,r=e.focus,s=e.isBackward(),a=s?r.offset:l.offset,c=s?r.getNode():l.getNode();if(d.$isRangeSelection(e)&&e.isCollapsed()&&""!==e.style){const n=J(e.style);if(null!==n&&t in n)return n[t]}for(let e=0;e<i.length;e++){const l=i[e];if((0===e||0!==a||!l.is(c))&&d.$isTextNode(l)){const e=ne(l,t,n);if(null===o)o=e;else if(o!==e){o="";break}}}return null===o?n:o}const ie="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,le=ie&&"documentMode"in document?document.documentMode:null;function re(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function se(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null}function ae({open:e,onOpenChange:t,children:o}){const l=i.useRef(null),r=i.useRef(null);return i.useEffect(()=>{function n(e){l.current?.contains(e.target)||r.current?.contains(e.target)||t(!1)}return e&&document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[e,t]),n.jsx("div",{className:"popover-root",children:i.Children.map(o,e=>e&&"object"==typeof e?e.type===ce?i.cloneElement(e,{triggerRef:l}):e.type===de?i.cloneElement(e,{contentRef:r,triggerRef:l}):e:e)})}function ce({children:e,triggerRef:t}){return n.jsx("div",{className:"popover-trigger",ref:t,children:e})}function de({open:e,align:t="start",children:o,contentRef:l,triggerRef:r}){const s=i.useRef(null),[a,c]=i.useState(!1);return i.useEffect(()=>{if(!e)return;const n=()=>{const e=s.current,n=r?.current;if(!e||!n)return;const o=n.closest(".lexical-text-editor"),i=!!o?.classList.contains("lexical-dark");e.classList.contains("lexical-dark")!==i&&e.classList.toggle("lexical-dark",i);const l=n.getBoundingClientRect(),a=e.offsetWidth,d=e.offsetHeight;let u=l.left;"center"===t?u=l.left+l.width/2-a/2:"end"===t&&(u=l.right-a),u=Math.max(8,Math.min(window.innerWidth-a-8,u));let h=l.bottom+4;h+d>window.innerHeight-8&&l.top>d+8&&(h=l.top-d-4),e.style.left=`${u}px`,e.style.top=`${h}px`,c(i)};return n(),requestAnimationFrame(n),window.addEventListener("resize",n),document.addEventListener("scroll",n,!0),()=>{window.removeEventListener("resize",n),document.removeEventListener("scroll",n,!0)}},[e,t,r]),e?E.createPortal(n.jsx("div",{ref:s,className:"lexical-text-editor"+(a?" lexical-dark":""),style:{position:"fixed",top:0,left:0,zIndex:9999,background:"transparent",border:"none",borderRadius:0,boxShadow:"none",padding:0,margin:0,height:"fit-content",maxWidth:"none"},children:n.jsx("div",{ref:e=>{l.current=e},className:"popover-content",style:{position:"static",top:"auto",left:"auto",borderRadius:6,border:"none",boxShadow:"none",margin:0,width:"100%"},children:o})}),document.body):null}function ue({onAction:e,selectionMap:t}){const[o,l]=i.useState(!1),r=i.useRef(null),s=i.useRef(null);return n.jsxs(ae,{open:o,onOpenChange:l,children:[n.jsx(ce,{triggerRef:r,children:n.jsxs("button",{type:"button",className:"lexical-btn heading-trigger "+(o?"toolbar-active":"toolbar"),onClick:()=>l(e=>!e),children:[n.jsx("span",{children:"Aa"}),n.jsx(T.HiChevronDown,{className:"chevron "+(o?"rotated":"")})]})}),n.jsx(de,{open:o,align:"start",onClose:()=>l(!1),contentRef:s,children:n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:F.map(({id:o,label:i,icon:r})=>n.jsxs("button",{type:"button",className:"lexical-btn "+(t[o]?"toolbar-active":"toolbar"),onClick:()=>{e(o),l(!1)},style:{minWidth:130},children:[r,n.jsx("span",{className:"label",children:i})]},o))})})]})}function he(){return n.jsx("div",{className:"w-[1px] h-[20px] mx-[2px] bg-gray-300 shrink-0"})}function pe({updateHeading:e,headingSelectionMap:t}){const o=W.find(e=>t[e.id]),[l,r]=i.useState(!1),s=i.useRef(null),a=i.useRef(null);return n.jsxs(ae,{open:l,onOpenChange:r,children:[n.jsx(ce,{triggerRef:s,children:n.jsxs("button",{type:"button",className:"lexical-btn heading-trigger "+(l?"toolbar-active":"toolbar"),onClick:()=>r(e=>!e),style:{minWidth:132},children:[o?.icon,n.jsx("span",{children:o?.label}),n.jsx(T.HiChevronDown,{className:"chevron "+(l?"rotated":"")})]})}),n.jsx(de,{open:l,align:"start",onClose:()=>r(!1),contentRef:a,children:n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:W.map(({id:o,label:i,icon:l})=>n.jsxs("button",{type:"button",className:"lexical-btn "+(t[o]?"toolbar-active":"toolbar"),onClick:()=>{e(o),r(!1)},children:[l,n.jsx("span",{className:"label",children:i})]},o))})})]})}function ge({linkUrl:e,setLinkUrl:t,onConfirm:o,onCancel:l,removeLink:r}){const[s,a]=i.useState(!1),c=i.useRef(null),d=i.useRef(null);return i.useEffect(()=>{"https://"===e&&a(!0)},[e]),i.useEffect(()=>{s&&d.current?.focus()},[s]),i.useEffect(()=>{const e=e=>{c.current&&!c.current.contains(e.target)&&l()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[l]),n.jsxs("div",{ref:c,className:"lexical-text-editor-link link-editor-container",children:[n.jsx("div",{className:"link-editor-input-wrapper",children:s?n.jsx("input",{ref:d,className:"link-editor-input",value:e,onChange:e=>t(e.target.value),onKeyDown:t=>{"Enter"===t.key?(t.preventDefault(),o(e),a(!1)):"Escape"===t.key&&(t.preventDefault(),a(!1),l())}}):n.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"link-editor-url",children:e})}),n.jsxs("div",{className:"link-editor-buttons",children:[n.jsx("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>{s?(o(e),a(!1)):a(!0)},children:s?n.jsx(R.MdCheck,{size:18}):n.jsx(C.BsPencilSquare,{size:14})}),n.jsx("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onMouseDown:e=>e.preventDefault(),onClick:r,children:n.jsx(L.BiUnlink,{size:14,style:{stroke:"black"}})})]})]})}function me({onClose:e}){const[t]=S.useLexicalComposerContext(),[o,l]=i.useState(""),[r,s]=i.useState(""),[a,c]=i.useState(!1),[u,h]=i.useState([]),[p,g]=i.useState(0),m=i.useRef(null);i.useEffect(()=>{m.current?.focus()},[]);const x=()=>{if(!o)return[];const e=a?o:o.toLowerCase(),t=[],n=d.$getRoot().getAllTextNodes();for(const o of n){const n=a?o.getTextContent():o.getTextContent().toLowerCase();let i=n.indexOf(e);for(;-1!==i;)t.push({key:o.getKey(),start:i}),i=n.indexOf(e,i+e.length)}return t};i.useEffect(()=>{const e=t.getEditorState().read(x);h(e),g(0)},[t,o,a]),i.useEffect(()=>t.registerUpdateListener(({editorState:e})=>{const t=e.read(x);h(t),g(e=>0===t.length?0:Math.min(e,t.length-1))}),[t,o,a]);const f=e=>{if(0===u.length)return;const n=(p+e+u.length)%u.length,i=u[n];g(n),t.update(()=>{const e=d.$getNodeByKey(i.key);d.$isTextNode(e)&&e.select(i.start,i.start+o.length)}),requestAnimationFrame(()=>{const e=t.getElementByKey(i.key);e?.scrollIntoView({block:"nearest"})})},b=o.length>0,y=u.length>0;return n.jsxs("div",{className:"lexical-find-replace",onKeyDown:t=>{"Escape"===t.key&&(t.preventDefault(),e())},children:[n.jsxs("div",{className:"lexical-fr-row",children:[n.jsx("input",{ref:m,className:"lexical-fr-input",placeholder:"Find",value:o,onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),f(e.shiftKey?-1:1))}}),n.jsx("span",{className:"lexical-fr-count",children:y?`${p+1} of ${u.length}`:b?"0 results":""})]}),n.jsx("div",{className:"lexical-fr-row",children:n.jsx("input",{className:"lexical-fr-input",placeholder:"Replace with",value:r,onChange:e=>s(e.target.value)})}),n.jsxs("div",{className:"lexical-fr-row",children:[n.jsxs("label",{className:"lexical-fr-case",children:[n.jsx("input",{type:"checkbox",checked:a,onChange:e=>c(e.target.checked)}),n.jsx("span",{children:"Match case"})]}),n.jsx("span",{style:{flex:1}}),n.jsx("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>f(-1),disabled:!y,"aria-label":"Previous match",children:n.jsx(N.IoChevronUp,{})}),n.jsx("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>f(1),disabled:!y,"aria-label":"Next match",children:n.jsx(N.IoChevronDown,{})}),n.jsx("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>{t.update(()=>{const e=x();if(0===e.length)return h([]),void g(0);const t=e[Math.min(p,e.length-1)],n=d.$getNodeByKey(t.key);d.$isTextNode(n)&&n.spliceText(t.start,o.length,r,!0)})},disabled:!y,children:"Replace"}),n.jsx("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>{t.update(()=>{const e=x();for(let t=e.length-1;t>=0;t--){const n=e[t],i=d.$getNodeByKey(n.key);d.$isTextNode(i)&&i.spliceText(n.start,o.length,r,!1)}})},disabled:!y,children:"Replace All"}),n.jsx("button",{type:"button",className:"lexical-btn toolbar",onClick:e,"aria-label":"Close find and replace",children:n.jsx(N.IoClose,{})})]})]})}function xe({anchorRef:e,onClose:t,children:o}){const l=i.useRef(null);return i.useEffect(()=>{const n=n=>{const o=n.target;!l.current||l.current.contains(o)||e.current&&e.current.contains(o)||t()},o=e=>{"Escape"===e.key&&t()};return document.addEventListener("mousedown",n),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("keydown",o)}},[e,t]),n.jsx("div",{ref:l,className:"lte-overflow-panel",children:n.jsx("div",{className:"lte-overflow-grid",children:o})})}function fe({onAction:e,alignmentSelectionMap:t}){const o=z.find(e=>t[e.id]),[l,r]=i.useState(!1),s=i.useRef(null),a=i.useRef(null);return n.jsxs(ae,{open:l,onOpenChange:r,children:[n.jsx(ce,{triggerRef:s,children:n.jsxs("button",{type:"button",className:"lexical-btn heading-trigger "+(l?"toolbar-active":"toolbar"),onClick:()=>r(e=>!e),style:{minWidth:146},children:[o?.icon,n.jsx("span",{children:o?.label}),n.jsx(T.HiChevronDown,{className:"chevron "+(l?"rotated":"")})]})}),n.jsx(de,{open:l,align:"start",onClose:()=>r(!1),contentRef:a,children:n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:z.map(({id:o,label:i,icon:l})=>n.jsxs("button",{type:"button",className:"lexical-btn "+(t[o]?"toolbar-active":"toolbar"),onClick:()=>{e(o),r(!1)},children:[l,n.jsx("span",{className:"label",children:i})]},o))})})]})}function be({color:e,onChange:t,icon:o}){const[l,r]=i.useState(!1),s=i.useRef(null),a=i.useRef(null);i.useEffect(()=>{const e=e=>{a.current&&!a.current.contains(e.target)&&s.current&&!s.current.contains(e.target)&&r(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);return n.jsxs("div",{className:"color-picker-wrapper",children:[n.jsx("button",{type:"button",ref:s,className:`size-10 lexical-btn ${l?"toolbarActive":"toolbar"} icon`,onClick:()=>r(e=>!e),children:o}),l&&E.createPortal(n.jsx("div",{ref:a,className:"lexical-color-popover "+(l?"open":""),style:{top:s.current?.getBoundingClientRect().bottom,left:s.current?.getBoundingClientRect().left,position:"absolute"},onMouseDown:e=>e.preventDefault(),children:n.jsx(M.SketchPicker,{color:e,onChangeComplete:e=>{t(e.hex)}})}),document.body)]})}function ye(){const[e]=S.useLexicalComposerContext(),[{color:t,bgColor:o},l]=i.useState({color:"#000",bgColor:"#fff"}),r=()=>{const e=d.$getSelection();if(d.$isRangeSelection(e)){const t=oe(e,"color","#000"),n=oe(e,"background","#fff");l({color:t,bgColor:n})}};i.useEffect(()=>re(e.registerUpdateListener(({editorState:e})=>{e.read(()=>{r()})}),e.registerCommand(d.SELECTION_CHANGE_COMMAND,()=>(r(),!1),1)),[e]);const s=({property:t,color:n})=>{e.update(()=>{const e=d.$getSelection();e&&V(e,{[t]:n})})};return n.jsxs(n.Fragment,{children:[n.jsx(be,{color:t,onChange:e=>{s({property:"color",color:e})},icon:n.jsx(v.AiOutlineFontColors,{})}),n.jsx(be,{color:o,onChange:e=>{s({property:"background",color:e})},icon:n.jsx(v.AiOutlineBgColors,{})})]})}function Ce({icon:e,tooltipLabel:t,currentValue:o,options:l,onSelect:r,minWidth:s=132}){const a=l.find(e=>""!==e.id&&e.id===o),[c,d]=i.useState(!1),u=i.useRef(null),h=i.useRef(null);return n.jsxs(ae,{open:c,onOpenChange:d,children:[n.jsx(ce,{triggerRef:u,children:n.jsxs("button",{type:"button","aria-label":t,className:"lexical-btn heading-trigger font-trigger "+(c?"toolbar-active":"toolbar"),style:{minWidth:s},onClick:()=>d(e=>!e),children:[e,n.jsx("span",{children:a?.label??"Default"}),n.jsx(T.HiChevronDown,{className:"chevron "+(c?"rotated":"")})]})}),n.jsx(de,{open:c,align:"start",onClose:()=>d(!1),contentRef:h,children:n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:l.map(e=>n.jsx("button",{type:"button",className:"lexical-btn "+(""===e.id&&""===o||""!==e.id&&e.id===o?"toolbar-active":"toolbar"),onClick:()=>{r(e.id),d(!1)},children:n.jsx("span",{className:"label",children:e.label})},e.label))})})]})}ie&&"InputEvent"in window&&!le&&new window.InputEvent("input");const ve=[{id:"",label:"Default"},{id:"Inter",label:"Inter"},{id:"System UI",label:"System"},{id:"serif",label:"Serif"},{id:"monospace",label:"Monospace"},{id:"cursive",label:"Cursive"},{id:"Georgia",label:"Georgia"},{id:"Courier New",label:"Courier"}];function Ne(){const[e]=S.useLexicalComposerContext(),[t,o]=i.useState(""),l=()=>{const e=d.$getSelection();if(d.$isRangeSelection(e)){const t=oe(e,"font-family","");o((e=>e.replace(/['"]/g,"").trim())(t))}};i.useEffect(()=>re(e.registerUpdateListener(({editorState:e})=>{e.read(()=>{l()})}),e.registerCommand(d.SELECTION_CHANGE_COMMAND,()=>(l(),!1),1)),[e]);return n.jsx(Ce,{icon:n.jsx(w.RiFontFamily,{}),tooltipLabel:"Font Family",currentValue:t,options:ve,onSelect:t=>{e.update(()=>{const e=d.$getSelection();d.$isRangeSelection(e)&&V(e,{"font-family":""===t?null:t})})}})}const je=[{id:"",label:"Default"},...[12,14,16,18,20,24,28,32,36,48].map(e=>({id:`${e}px`,label:`${e}`}))];function we(){const[e]=S.useLexicalComposerContext(),[t,o]=i.useState(""),l=()=>{const e=d.$getSelection();if(d.$isRangeSelection(e)){const t=oe(e,"font-size","");o((e=>e.trim())(t))}};i.useEffect(()=>re(e.registerUpdateListener(({editorState:e})=>{e.read(()=>{l()})}),e.registerCommand(d.SELECTION_CHANGE_COMMAND,()=>(l(),!1),1)),[e]);return n.jsx(Ce,{icon:n.jsx(w.RiFontSize,{}),tooltipLabel:"Font Size",currentValue:t,options:je,onSelect:t=>{e.update(()=>{const e=d.$getSelection();d.$isRangeSelection(e)&&V(e,{"font-size":""===t?null:t})})}})}function Se(){const[e]=S.useLexicalComposerContext(),[t,o]=i.useState(!1),[l,s]=i.useState(null),[a,c]=i.useState(!1),u=i.useRef(null),h=i.useRef(null),p=()=>{const e=d.$getSelection();if(d.$isRangeSelection(e)){const t=e.anchor.getNode(),n="root"===t.getKey()?t:t.getTopLevelElementOrThrow(),i=r.$isCodeNode(n);o(i),i&&s(n.getLanguage()??null)}};i.useEffect(()=>re(e.registerUpdateListener(({editorState:e})=>{e.read(()=>{p()})}),e.registerCommand(d.SELECTION_CHANGE_COMMAND,()=>(p(),!1),1)),[e]);const g=U.find(e=>e.id===l)?.label??"Plain Text";return n.jsxs(ae,{open:a,onOpenChange:c,children:[n.jsx(ce,{triggerRef:u,children:n.jsxs("button",{type:"button",className:"lexical-btn heading-trigger "+(t?"toolbar-active":"toolbar"),onClick:()=>c(e=>!e),children:[n.jsx(N.IoCodeSlashOutline,{}),n.jsx("span",{children:g}),n.jsx(T.HiChevronDown,{className:"chevron "+(a?"rotated":"")})]})}),n.jsx(de,{open:a,align:"start",onClose:()=>c(!1),contentRef:h,children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[n.jsxs("button",{type:"button",className:"lexical-btn "+(t?"toolbar-active":"toolbar"),onClick:()=>{e.update(()=>{const e=d.$getSelection();if(!d.$isRangeSelection(e))return;const t=e.anchor.getNode(),n="root"===t.getKey()?t:t.getTopLevelElementOrThrow();if(r.$isCodeNode(n))Q(e,()=>d.$createParagraphNode());else{const t=l??"javascript";Q(e,()=>r.$createCodeNode(t))}}),c(!1)},style:{minWidth:150},children:[n.jsx(N.IoCodeSlashOutline,{}),n.jsx("span",{className:"label",children:t?"Remove Code Block":"Code Block"})]}),n.jsx("div",{className:"w-full h-[1px] bg-gray-200 my-1"}),n.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5,maxHeight:260,overflowY:"auto"},children:U.map(({id:t,label:o})=>n.jsx("button",{type:"button",className:"lexical-btn "+(l===t?"toolbar-active":"toolbar"),onClick:()=>{var n;s(n=t),e.update(()=>{const e=d.$getSelection();if(!d.$isRangeSelection(e))return;const t=e.anchor.getNode(),o="root"===t.getKey()?t:t.getTopLevelElementOrThrow();r.$isCodeNode(o)&&o.setLanguage(n)}),c(!1)},style:{minWidth:150},children:n.jsx("span",{className:"label",children:o})},t))})]})})]})}const ke=({content:e,direction:t="top",delay:o=400,children:l})=>{const[r,s]=i.useState(!1),[a,c]=i.useState(null),d=i.useRef(null),u=i.useRef(null),h=()=>{d.current=window.setTimeout(()=>{const e=u.current;if(e){const t=e.getBoundingClientRect();c({left:t.left,top:t.top,right:t.right,bottom:t.bottom,width:t.width,height:t.height})}s(!0)},o)},p=()=>{d.current&&clearTimeout(d.current),s(!1)};if(!a)return n.jsx("div",{ref:u,className:"Lexical-Tooltip-Wrapper",onMouseEnter:h,onMouseLeave:p,children:l});const g=a.left+a.width/2,m=a.top+a.height/2,x="bottom"===t?{top:a.bottom+10,left:g,bottom:"auto"}:"top"===t?{bottom:window.innerHeight-a.top+10,top:"auto",left:g}:"right"===t?{left:a.right+10,right:"auto",top:m}:{left:"auto",right:window.innerWidth-a.left+10,top:m};return n.jsxs("div",{ref:u,className:"Lexical-Tooltip-Wrapper",onMouseEnter:h,onMouseLeave:p,children:[l,r&&E.createPortal(n.jsx("div",{className:`Lexical-Tooltip-Tip ${t}`,style:{position:"fixed",pointerEvents:"none",...x,zIndex:1e4},children:e}),document.body)]})};function Te({blockType:e}){const[t]=S.useLexicalComposerContext();i.useEffect(()=>re(t.registerCommand(d.KEY_TAB_COMMAND,e=>{const n=d.$getSelection();if(!d.$isRangeSelection(n))return!1;return!!se(n.anchor.getNode(),p.ListNode)&&(e.preventDefault(),t.dispatchCommand(e.shiftKey?d.OUTDENT_CONTENT_COMMAND:d.INDENT_CONTENT_COMMAND,void 0),!0)},d.COMMAND_PRIORITY_EDITOR)),[t]);return n.jsxs(n.Fragment,{children:[n.jsx(ke,{content:"Ordered list",direction:"bottom",children:n.jsx("button",{type:"button",className:`size-10 lexical-btn ${"ol"===e?"toolbarActive":"toolbar"} icon`,onClick:()=>{"ol"===e?t.dispatchCommand(p.REMOVE_LIST_COMMAND,void 0):t.dispatchCommand(p.INSERT_ORDERED_LIST_COMMAND,void 0)},children:n.jsx(C.BsListOl,{})})}),n.jsx(ke,{content:"Unordered list",direction:"bottom",children:n.jsx("button",{type:"button",className:`size-10 lexical-btn ${"ul"===e?"toolbarActive":"toolbar"} icon`,onClick:()=>{"ul"===e?t.dispatchCommand(p.REMOVE_LIST_COMMAND,void 0):t.dispatchCommand(p.INSERT_UNORDERED_LIST_COMMAND,void 0)},children:n.jsx(C.BsListUl,{})})})]})}function Ee(){const[e]=S.useLexicalComposerContext(),[t,o]=i.useState(!1),[l,r]=i.useState(!1),[s,a]=i.useState(null),c=i.useRef(null),u=i.useRef(null),h=()=>{const e=d.$getSelection();if(d.$isRangeSelection(e)){const t=f.$findCellNode(e.anchor.getNode());o(!!t)}else o(!1)};i.useEffect(()=>re(e.registerUpdateListener(({editorState:e})=>{e.read(()=>{h()})}),e.registerCommand(d.SELECTION_CHANGE_COMMAND,()=>(h(),!1),1)),[e]);const p=t=>{e.update(()=>{const e=d.$getSelection();d.$isRangeSelection(e)&&t()}),r(!1)},g=s?`${s.rows} × ${s.cols}`:"Insert Table";return n.jsxs(ae,{open:l,onOpenChange:r,children:[n.jsx(ce,{triggerRef:c,children:n.jsxs("button",{type:"button",className:"lexical-btn heading-trigger "+(t?"toolbar-active":"toolbar"),onClick:()=>r(e=>!e),children:[n.jsx(C.BsTable,{}),n.jsx(T.HiChevronDown,{className:"chevron "+(l?"rotated":"")})]})}),n.jsx(de,{open:l,align:"start",onClose:()=>r(!1),contentRef:u,children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[n.jsxs("div",{style:{width:"fit-content"},children:[n.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 18px)",gap:3},children:Array.from({length:25},(t,o)=>{const i=Math.floor(o/5)+1,l=o%5+1,c=s&&i<=s.rows&&l<=s.cols;return n.jsx("div",{onMouseEnter:()=>a({rows:i,cols:l}),onClick:()=>{return t=i,n=l,e.dispatchCommand(f.INSERT_TABLE_COMMAND,{rows:String(t),columns:String(n),includeHeaders:!1}),void r(!1);var t,n},style:{width:18,height:18,borderRadius:3,border:"1px solid #d1d5db",backgroundColor:c?"#c7d2fe":"#fff",cursor:"pointer"}},o)})}),n.jsx("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:g})]}),n.jsx("div",{className:"w-full h-[1px] bg-gray-200"}),n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[n.jsx("button",{type:"button",className:"lexical-btn toolbar",disabled:!t,onClick:()=>p(()=>{f.$insertTableRowAtSelection(!1)}),style:{minWidth:160},children:n.jsx("span",{className:"label",children:"Insert row above"})}),n.jsx("button",{type:"button",className:"lexical-btn toolbar",disabled:!t,onClick:()=>p(()=>{f.$insertTableRowAtSelection(!0)}),style:{minWidth:160},children:n.jsx("span",{className:"label",children:"Insert row below"})}),n.jsx("button",{type:"button",className:"lexical-btn toolbar",disabled:!t,onClick:()=>p(()=>{f.$deleteTableRowAtSelection()}),style:{minWidth:160},children:n.jsx("span",{className:"label",children:"Delete row"})}),n.jsx("button",{type:"button",className:"lexical-btn toolbar",disabled:!t,onClick:()=>p(()=>{f.$insertTableColumnAtSelection(!1)}),style:{minWidth:160},children:n.jsx("span",{className:"label",children:"Insert column left"})}),n.jsx("button",{type:"button",className:"lexical-btn toolbar",disabled:!t,onClick:()=>p(()=>{f.$insertTableColumnAtSelection(!0)}),style:{minWidth:160},children:n.jsx("span",{className:"label",children:"Insert column right"})}),n.jsx("button",{type:"button",className:"lexical-btn toolbar",disabled:!t,onClick:()=>p(()=>{f.$deleteTableColumnAtSelection()}),style:{minWidth:160},children:n.jsx("span",{className:"label",children:"Delete column"})}),n.jsx("button",{type:"button",className:"lexical-btn toolbar",disabled:!t,onClick:()=>{p(()=>{const e=d.$getSelection();if(!d.$isRangeSelection(e))return;const t=f.$findCellNode(e.anchor.getNode());if(!t)return;const n=t.getParent();if(!n)return;const o=n.getChildren().filter(f.$isTableCellNode),i=o.some(e=>e.hasHeaderState(f.TableCellHeaderStates.ROW));for(const e of o)e.setHeaderStyles(i?f.TableCellHeaderStates.NO_STATUS:f.TableCellHeaderStates.ROW,f.TableCellHeaderStates.ROW)})},style:{minWidth:160},children:n.jsx("span",{className:"label",children:"Toggle header row"})})]})]})})]})}const _e=({src:e,altText:t,nodeKey:o,width:l,height:r,maxWidth:s,caption:a=""})=>{const[c]=S.useLexicalComposerContext(),[u,h]=i.useState(!1),[p,g]=i.useState(a),m=i.useRef(null),x=i.useRef(null),f=i.useRef(null),b=i.useRef(null),y=e=>{if(!b.current||!x.current)return;const t=e.clientX-b.current.x,n=Math.min(s,Math.max(50,b.current.width+t)),o=n*x.current.ratio;x.current.width=n,x.current.height=o;const i=f.current?.querySelector("img");i&&(i.style.width=n+"px",i.style.height=o+"px")},C=()=>{if(!x.current)return;const{width:e,height:t}=x.current;c.update(()=>{const n=d.$getNodeByKey(o);n&&"function"==typeof n.updateDimensions&&n.updateDimensions(e,t)}),x.current=null,b.current=null,window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",C)},v=()=>{h(!1),c.update(()=>{const e=d.$getNodeByKey(o);e&&"function"==typeof e.setCaption&&e.setCaption(p)})},N=()=>{g(a),h(!0),setTimeout(()=>m.current?.focus(),0)};return n.jsxs("div",{ref:f,style:{display:"inline-block",position:"relative",maxWidth:s},children:[n.jsx("img",{src:e,alt:t,width:"inherit"===l?void 0:l,height:"inherit"===r?void 0:r,style:{maxWidth:"100%",display:"block"}}),(a||u)&&n.jsx("div",{style:{textAlign:"center",marginTop:4},children:u?n.jsx("input",{ref:m,className:"lte-input",style:{width:"100%",textAlign:"center"},value:p,onChange:e=>g(e.target.value),onBlur:v,onKeyDown:e=>{"Enter"===e.key&&v()}}):n.jsx("span",{style:{fontSize:13,color:"#666",cursor:"text",display:"inline-block",minWidth:20,minHeight:18},onClick:N,children:a})}),!a&&!u&&n.jsx("div",{style:{textAlign:"center",marginTop:2},children:n.jsx("span",{style:{fontSize:12,color:"#999",cursor:"pointer"},onClick:N,children:"+ Add caption"})}),n.jsx("div",{onMouseDown:e=>{e.preventDefault(),e.stopPropagation();const t=f.current?.querySelector("img");if(!t)return;const n=t.getBoundingClientRect().width,o=t.naturalHeight/t.naturalWidth,i=n*o;b.current={x:e.clientX,y:e.clientY,width:n,height:i},x.current={width:n,height:i,ratio:o},window.addEventListener("mousemove",y),window.addEventListener("mouseup",C)},style:{position:"absolute",bottom:a||u?40:0,right:0,width:14,height:14,background:"white",border:"1px solid #999",cursor:"nwse-resize",borderRadius:2}})]})},Re=e=>d.$applyNodeReplacement(new Me(e)),Le=e=>{if(!(e instanceof HTMLImageElement))return null;const{src:t,alt:n}=e;let o,i;e.width&&(o=e.width),e.height&&(i=e.height);const l=e.style;if((!o||0===o)&&l.width){const e=parseInt(l.width,10);Number.isNaN(e)||(o=e)}if((!i||0===i)&&l.height){const e=parseInt(l.height,10);Number.isNaN(e)||(i=e)}return{node:Re({src:t,altText:n,width:o??"inherit",height:i??"inherit"})}};class Me extends d.DecoratorNode{constructor({src:e="",altText:t="",maxWidth:n=1080,width:o="inherit",height:i="inherit",caption:l="",key:r}={src:"",altText:""}){super(r),this.__src=e,this.__altText=t,this.__maxWidth=n,this.__width=o,this.__height=i,this.__caption=l}static getType(){return"image"}static clone(e){return new Me({src:e.__src,altText:e.__altText,width:e.__width,height:e.__height,maxWidth:e.__maxWidth,caption:e.__caption,key:e.getKey()})}createDOM(){return document.createElement("span")}updateDOM(e){return e.__width!==this.__width||e.__height!==this.__height}exportDOM(){const e=document.createElement("img");if(e.src=this.__src,e.alt=this.__altText,"inherit"!==this.__width&&(e.width=this.__width??0),"inherit"!==this.__height&&(e.height=this.__height??0),this.__caption){const t=document.createElement("figure"),n=document.createElement("figcaption");return n.textContent=this.__caption,t.appendChild(e),t.appendChild(n),{element:t}}return{element:e}}static importDOM(){return{img:()=>({conversion:Le,priority:1}),figure:()=>({conversion:e=>{const t=e.querySelector("img");if(!t)return null;const n=e.querySelector("figcaption"),o=n?.textContent||"",i=Le(t);return i?.node instanceof Me&&o&&(i.node.__caption=o),i},priority:1})}}exportJSON(){return{type:"image",version:1,src:this.__src,altText:this.__altText,maxWidth:this.__maxWidth,width:this.__width,height:this.__height,caption:this.__caption}}static importJSON(e){return new Me({src:e.src,altText:e.altText,maxWidth:e.maxWidth,width:e.width,height:e.height,caption:e.caption})}updateDimensions(e,t){const n=this.getWritable();n.__width=e,n.__height=t}setCaption(e){this.getWritable().__caption=e}decorate(){return n.jsx(_e,{src:this.__src,altText:this.__altText,nodeKey:this.getKey(),width:this.__width,height:this.__height,maxWidth:this.__maxWidth,caption:this.__caption})}}function $e({open:e,onClose:t,forPreview:o=!1,children:l}){const r=i.useRef(null);return i.useEffect(()=>{if(!e)return;const n=e=>{r.current&&!r.current.contains(e.target)&&t()},o=e=>{"Escape"===e.key&&t()};return document.addEventListener("mousedown",n),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("keydown",o)}},[e,t]),e?n.jsx("div",{className:"lexical-text-editor-dialog lte-dialog-overlay",children:n.jsxs("div",{ref:r,className:"lte-dialog "+(o?"preview":""),children:[n.jsx("button",{type:"button",className:"lte-dialog-close",onClick:t,children:"×"}),l]})}):null}async function Ae(e,{src:t,altText:n="",caption:o=""}){e.update(()=>{const e=Re({src:t,altText:n,caption:o});d.$insertNodes([e])})}function Oe({onImageUpload:e}){const[t]=S.useLexicalComposerContext(),o=i.useRef(null),[l,r]=i.useState(!1),[s,a]=i.useState(""),[c,u]=i.useState(""),[h,p]=i.useState(""),[g,m]=i.useState(),[x,f]=i.useState(!1),b=i.useCallback(async(n,o="",i="")=>{let l;l=e?await e(n):URL.createObjectURL(n),Ae(t,{src:l,altText:o,caption:i})},[t,e]);return i.useEffect(()=>{const e=t.registerCommand(d.PASTE_COMMAND,e=>{if(e instanceof ClipboardEvent){const t=e.clipboardData?.items;if(!t)return!1;for(const n of t)if(n.type.startsWith("image/")){e.preventDefault();const t=n.getAsFile();return t&&b(t,"","").catch(console.error),!0}}return!1},d.COMMAND_PRIORITY_LOW);return()=>e()},[t,b]),n.jsxs("div",{className:"lexical-text-editor-dialog",children:[n.jsx("input",{type:"file",ref:o,accept:"image/*",className:"lte-hidden",onChange:e=>{const t=e.target.files?.[0];t&&m(t),e.target.value=""}}),n.jsx(ke,{content:"Add Image",direction:"bottom",children:n.jsx("button",{type:"button",className:`size-10 lexical-btn ${l?"toolbarActive":"toolbar"} icon`,onClick:()=>r(e=>!e),children:n.jsx(N.IoImageOutline,{size:18})})}),n.jsxs($e,{open:l,onClose:()=>r(!1),children:[n.jsx("div",{className:"lte-dialog-header",children:"Add Image"}),n.jsxs("div",{className:"lte-dialog-body",children:[n.jsx("input",{className:"lte-input",placeholder:"Alt text",value:c,onChange:e=>u(e.target.value)}),n.jsx("input",{className:"lte-input",placeholder:"Caption",value:h,onChange:e=>p(e.target.value)}),n.jsx("input",{className:"lte-input",placeholder:"Add image by URL",value:s,onChange:e=>a(e.target.value)}),n.jsx("div",{className:"lte-divider",children:n.jsx("span",{children:"or"})}),n.jsxs("button",{type:"button",className:"lexical-btn heading-trigger toolbar-active",onClick:()=>o.current?.click(),style:{width:"fit-content",margin:"0 auto"},children:[n.jsx($.LuUpload,{size:20}),n.jsx("span",{children:"Upload Image"})]}),g&&n.jsx("div",{className:"lte-file-name",children:g.name})]}),n.jsx("div",{className:"lte-dialog-footer",children:n.jsx("button",{type:"button",className:"lte-primary-btn",disabled:!s&&!g||x,onClick:async()=>{if(!x){if(g){f(!0);try{await b(g,c,h)}catch(e){return console.error("Image upload failed:",e),void f(!1)}f(!1)}else{if(!s)return;Ae(t,{src:s,altText:c,caption:h})}m(void 0),u(""),p(""),a(""),r(!1)}},children:x?"Uploading...":"Add Image"})})]})]})}const De=({id:e,provider:t})=>new We({id:e,provider:t}),Ie="data-lexical-video",Fe="data-provider",Be="315px",He="560px",ze=(e,t)=>"drive"===t?`https://drive.google.com/file/d/${e}/preview`:`https://www.youtube-nocookie.com/embed/${e}`,Pe=e=>{const t=e?.getAttribute(Ie),n=e?.getAttribute(Fe)??"youtube";if(!t)return null;return{node:De({id:t,provider:n})}};class We extends d.DecoratorNode{constructor({id:e,provider:t,key:n}){super(n),this.__id=e,this.__provider=t}static getType(){return"video"}static clone(e){return new We({id:e.__id,provider:e.__provider,key:e.getKey()})}static importJSON(e){return De({id:e.id,provider:e.provider})}exportJSON(){return{id:this.__id,provider:this.__provider,type:"video",version:1}}updateDOM(){return!1}decorate(){return n.jsx("iframe",{height:Be,width:He,src:ze(this.__id,this.__provider),frameBorder:"0",allowFullScreen:!0})}createDOM(){return document.createElement("div")}exportDOM(){const e=document.createElement("iframe");return e.setAttribute(Ie,this.__id),e.setAttribute(Fe,this.__provider),e.setAttribute("height",Be),e.setAttribute("width",He),e.setAttribute("src",ze(this.__id,this.__provider)),{element:e}}static importDOM(){return{iframe:()=>({conversion:Pe,priority:0})}}}function Ue(){const[e,t]=i.useState(!1),[o,l]=i.useState(!1),[r,s]=i.useState(""),[a]=S.useLexicalComposerContext();return i.useEffect(()=>{e||(s(""),l(!1))},[e]),n.jsxs("div",{className:"lexical-text-editor-dialog",children:[n.jsx(ke,{content:"Embed Video",direction:"bottom",children:n.jsx("button",{type:"button",className:`size-10 lexical-btn ${e?"toolbarActive":"toolbar"} icon`,onClick:()=>t(!0),children:n.jsx(A.FaYoutube,{size:18,color:"red"})})}),n.jsxs($e,{open:e,onClose:()=>t(!1),children:[n.jsx("div",{className:"lte-dialog-header",children:"Embed Video"}),n.jsxs("div",{className:"lte-dialog-body",children:[n.jsx("input",{className:"lte-input",placeholder:"Add YouTube or Google Drive URL",value:r,onChange:e=>s(e.target.value)}),o&&n.jsx("p",{className:"lte-error-text",children:"It's not a valid YouTube or Google Drive URL"})]}),n.jsx("div",{className:"lte-dialog-footer",children:n.jsx("button",{type:"button",className:"lte-primary-btn",disabled:!r,onClick:()=>{if(!r)return;let e=null,n=null;const o=/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/.exec(r);o&&11===o[2]?.length&&(e="youtube",n=o[2]);const i=/drive\.google\.com\/file\/d\/([a-zA-Z0-9_-]+)\//.exec(r);i&&i[1]&&(e="drive",n=i[1]),n&&e?(a.update(()=>{const t=De({id:n,provider:e});d.$insertNodes([t])}),s(""),l(!1),t(!1)):l(!0)},children:"Embed"})})]})]})}function qe({value:e}){return n.jsx("div",{className:"lexical-text-editor-html-preview",dangerouslySetInnerHTML:{__html:e}})}function Ke({value:e,triggerLabel:t="Preview"}){const[o,l]=i.useState(!1);return n.jsxs("div",{className:"lexical-text-editor-dialog",children:[n.jsx(ke,{content:t,direction:"bottom",children:n.jsxs("button",{type:"button",className:"lexical-btn heading-trigger "+(o?"toolbar-active":"toolbar"),onClick:()=>l(e=>!e),children:[n.jsx(O.VscPreview,{size:18}),n.jsx("span",{children:t})]})}),n.jsxs($e,{open:o,onClose:()=>l(!1),forPreview:!0,children:[n.jsx("div",{className:"lte-dialog-header",children:"Content Preview"}),n.jsxs("div",{className:"lte-preview-container",children:[n.jsx("div",{className:"lte-preview-title",children:"CONTENT"}),n.jsx(qe,{value:e})]})]})]})}const Je=[{id:"fontFamily"},{id:"fontSize"},{id:"color"},{id:"textFormats",primary:!0},{id:"dropdown"},{id:"lists"},{id:"blockOptions"},{id:"primaryAlignment",primary:!0},{id:"primaryLink",primary:!0},{id:"codeBlock"},{id:"image"},{id:"video"},{id:"table"},{id:"utility"},{id:"preview"}];Je.filter(e=>!e.primary).map(e=>e.id);const Ge=["textFormats","lists","primaryAlignment","primaryLink","fontFamily","fontSize","color","dropdown","codeBlock","blockOptions","image","video","table","utility","preview"],Ve=({value:o,onImageUpload:r,sourceView:s=!1,onToggleSourceView:a,fullscreen:c=!1,onToggleFullscreen:u,toolbarStyle:h="wrap"})=>{const m="normal"===h?"collapse":h,[x]=S.useLexicalComposerContext(),[f,b]=i.useState({[e.Undo]:!0,[e.Redo]:!0}),[y,v]=i.useState(!1),[j,w]=i.useState(!1),[T,E]=i.useState(0),[R,L]=i.useState(!1),M=i.useRef(null),$=i.useRef(null),A=i.useRef(null),O=i.useRef({}),D=i.useRef({}),I=i.useRef(0),F=i.useRef(null),z=i.useRef(null),[W,U]=i.useState({[e.LeftAlign]:!0}),[q,K]=i.useState({[t.Normal]:!0}),[J,G]=i.useState("paragraph"),[V,X]=i.useState("https://");let Y=!0;const Z=()=>{if(Y){const e=x.getRootElement();e&&(e.scrollTop=0,Y=!1)}const n=d.$getSelection();if(d.$isRangeSelection(n)){const o={[e.Bold]:n.hasFormat("bold"),[e.Italics]:n.hasFormat("italic"),[e.Underline]:n.hasFormat("underline"),[e.Uppercase]:n.hasFormat("uppercase"),[e.Lowercase]:n.hasFormat("lowercase"),[e.Capitalize]:n.hasFormat("capitalize"),[e.Strikethrough]:n.hasFormat("strikethrough"),[e.Superscript]:n.hasFormat("superscript"),[e.Subscript]:n.hasFormat("subscript"),[e.Code]:n.hasFormat("code"),[e.Highlight]:n.hasFormat("highlight")};U(o);const i=n.anchor.getNode(),r="root"===i.getKey()?i:i.getTopLevelElementOrThrow(),s=r.getKey();if(!x.getElementByKey(s))return;if(p.$isListNode(r)){const e=se(i,p.ListNode),t=e?e.getTag():r.getTag();G(t)}else if("paragraph"===r.getType()||l.$isHeadingNode(r)){let e=null;l.$isHeadingNode(r)&&(e=r.getTag());const n={[t.H1]:"h1"===e,[t.H2]:"h2"===e,[t.H3]:"h3"===e,[t.H4]:"h4"===e,[t.H5]:"h5"===e,[t.H6]:"h6"===e,[t.Normal]:"paragraph"===r.getType()};G(r.getType()),K(n)}else G(r.getType());const a=(d.$isElementNode(i)?i:r).getFormat();U(t=>({...t,[e.LeftAlign]:0===a||1===a,[e.CenterAlign]:2===a,[e.RightAlign]:3===a,[e.JustifyAlign]:4===a})),"quote"===r.getType()?U(t=>({...t,[e.Quote]:!0})):U(t=>({...t,[e.Quote]:!1}));const c=n.anchor.getNode(),u=c.getParent();k.$isLinkNode(u)?(U(t=>({...t,[e.Link]:!0})),X(u.getURL()),v(!0)):k.$isLinkNode(c)?(U(t=>({...t,[e.Link]:!0})),X(c.getURL()),v(!0)):(U(t=>({...t,[e.Link]:!1})),X("https://"),v(!1))}};i.useEffect(()=>re(x.registerUpdateListener(({editorState:e})=>{e.read(()=>{Z()})}),x.registerCommand(d.SELECTION_CHANGE_COMMAND,()=>(Z(),!1),1),x.registerCommand(d.CAN_UNDO_COMMAND,e=>(b(t=>({...t,undo:!e})),!1),1),x.registerCommand(d.CAN_REDO_COMMAND,e=>(b(t=>({...t,redo:!e})),!1),1)),[]);const te="scrollbar"===m,ne=i.useCallback(()=>{if("collapse"!==m)return;const e=M.current;if(!e)return;const t=e.clientWidth;if(t<=0)return;const n=$.current?$.current.offsetWidth:0,o=Ge.map(e=>{const t=O.current[e];return t&&"none"!==t.style.display&&(D.current[e]=t.offsetWidth),D.current[e]??0});A.current&&(I.current=A.current.offsetWidth);const i=I.current||40,l=e=>{const t=1+(e>0?1:0)+(Ge.length-e);let l=n+6*Math.max(0,t-1)+(e>0?i:0);for(let t=0;t<Ge.length-e;t++)l+=o[t];return l};let r=T;for(;r<Ge.length&&l(r)>t;)r++;for(;r>0&&l(r-1)<=t;)r--;E(e=>e===r?e:r)},[T,m]);i.useEffect(()=>{ne()});const oe=i.useRef(()=>{});oe.current=ne,i.useEffect(()=>{if("undefined"==typeof ResizeObserver)return;const e=M.current;if(!e)return;const t=new ResizeObserver(()=>{oe.current(),be.current()});return t.observe(e),()=>t.disconnect()},[]),i.useEffect(()=>{0===T&&L(!1)},[T]),i.useEffect(()=>{"collapse"!==m&&E(0)},[m]);const ie=i.useCallback(()=>{if("scrollbar"!==m)return;const e=M.current,t=F.current,n=z.current;if(!e||!t||!n)return;const o=e.clientWidth;if(e.scrollWidth-o<=1)return void(t.style.display="none");t.style.display="flex";const i=Math.max(24,o/e.scrollWidth*o),l=e.scrollWidth-o,r=o-i,s=l>0?e.scrollLeft/l*r:0;n.style.width=`${i}px`,n.style.transform=`translateX(${s}px)`},[h]),le=i.useCallback(e=>{e.stopPropagation(),e.preventDefault();const t=M.current,n=z.current;if(!t||!n)return;const o=e.clientX,i=t.scrollLeft,l=t.clientWidth,r=Math.max(24,l/t.scrollWidth*l),s=t.scrollWidth-l,a=l-r,c=e=>{const n=e.clientX-o;t.scrollLeft=a>0?i+n/a*s:0},d=()=>{document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",d)};document.addEventListener("pointermove",c),document.addEventListener("pointerup",d)},[]),ae=i.useCallback(e=>{const t=M.current,n=F.current;if(!t||!n)return;const o=n.getBoundingClientRect(),i=(e.clientX-o.left)/o.width;t.scrollLeft=i*t.scrollWidth-t.clientWidth/2},[]),ce=i.useRef(null),de=i.useCallback(()=>{const e=ce.current;if(e)for(const t of e.querySelectorAll(".lte-toolbar-row svg:not(.chevron), .lte-overflow-panel svg:not(.chevron)")){const e=t;try{const t=e.viewBox?.baseVal;if(!t||!t.width)continue;let n=1/0,o=1/0,i=-1/0,l=-1/0;if(e.querySelectorAll("path, circle, rect, ellipse, polygon, polyline, line").forEach(e=>{const t=e.getBBox();(t.width||t.height)&&(n=Math.min(n,t.x),o=Math.min(o,t.y),i=Math.max(i,t.x+t.width),l=Math.max(l,t.y+t.height))}),i===-1/0)continue;const r=((i-n)/t.width+(l-o)/t.height)/2;if(!isFinite(r)||r<=0)continue;const s=Math.min(22,Math.max(17,15/r));parseFloat(e.style.width)!==s&&(e.style.width=`${s}px`,e.style.height=`${s}px`)}catch{}}},[]);i.useEffect(()=>{de()}),i.useEffect(()=>{ie()});const be=i.useRef(()=>{});be.current=ie,i.useEffect(()=>{if("scrollbar"!==m)return;const e=M.current;if(!e)return;const t=()=>ie();return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)},[m,ie]);const Ce=t=>{switch(t){case e.Bold:x.dispatchCommand(d.FORMAT_TEXT_COMMAND,"bold");break;case e.Italics:x.dispatchCommand(d.FORMAT_TEXT_COMMAND,"italic");break;case e.Underline:x.dispatchCommand(d.FORMAT_TEXT_COMMAND,"underline");break;case e.Lowercase:x.dispatchCommand(d.FORMAT_TEXT_COMMAND,"lowercase");break;case e.Uppercase:x.dispatchCommand(d.FORMAT_TEXT_COMMAND,"uppercase");break;case e.Capitalize:x.dispatchCommand(d.FORMAT_TEXT_COMMAND,"capitalize");break;case e.Strikethrough:x.dispatchCommand(d.FORMAT_TEXT_COMMAND,"strikethrough");break;case e.Superscript:x.dispatchCommand(d.FORMAT_TEXT_COMMAND,"superscript");break;case e.Subscript:x.dispatchCommand(d.FORMAT_TEXT_COMMAND,"subscript");break;case e.Highlight:x.dispatchCommand(d.FORMAT_TEXT_COMMAND,"highlight");break;case e.Code:x.dispatchCommand(d.FORMAT_TEXT_COMMAND,"code");break;case e.Quote:x.update(()=>{const e=d.$getSelection();if(d.$isRangeSelection(e)){const t=e.anchor.getNode().getParent();t&&l.$isQuoteNode(t)?Q(e,()=>d.$createParagraphNode()):ee(e,()=>l.$createQuoteNode())}});break;case e.Link:ve(),v(!0);break;case e.LeftAlign:x.dispatchCommand(d.FORMAT_ELEMENT_COMMAND,"left");break;case e.RightAlign:x.dispatchCommand(d.FORMAT_ELEMENT_COMMAND,"right");break;case e.CenterAlign:x.dispatchCommand(d.FORMAT_ELEMENT_COMMAND,"center");break;case e.JustifyAlign:x.dispatchCommand(d.FORMAT_ELEMENT_COMMAND,"justify");break;case e.Undo:x.dispatchCommand(d.UNDO_COMMAND,void 0);break;case e.Redo:x.dispatchCommand(d.REDO_COMMAND,void 0);break;case e.ClearFormatting:x.update(()=>{const e=d.$getSelection();if(!d.$isRangeSelection(e))return;const t=e.getNodes().filter(d.$isTextNode);for(const e of t)e.setFormat(0),e.setStyle("")});break;case e.HorizontalRule:x.dispatchCommand(g.INSERT_HORIZONTAL_RULE_COMMAND,void 0);break;case e.Indent:x.dispatchCommand(d.INDENT_CONTENT_COMMAND,void 0);break;case e.Outdent:x.dispatchCommand(d.OUTDENT_CONTENT_COMMAND,void 0)}},ve=i.useCallback(()=>{x.update(()=>{const e=d.$getSelection();d.$isRangeSelection(e)&&!e.isCollapsed()&&(y?x.dispatchCommand(k.TOGGLE_LINK_COMMAND,null):""!==V&&x.dispatchCommand(k.TOGGLE_LINK_COMMAND,V))})},[x,y,V]),je=i.useCallback(()=>{X(""),x.dispatchCommand(k.TOGGLE_LINK_COMMAND,null),v(!1)},[x]),_e=e=>Ge.indexOf(e)>=Ge.length-T,Re={textFormats:n.jsx(n.Fragment,{children:B.map(({id:t,label:o,icon:i})=>t===e.Divider?n.jsx(he,{},t):n.jsx(ke,{content:o,direction:"bottom",children:n.jsx("button",{type:"button",className:`size-10 lexical-btn ${W[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>Ce(t),children:i})},t))}),primaryAlignment:n.jsxs(n.Fragment,{children:[n.jsx(fe,{onAction:Ce,alignmentSelectionMap:W}),n.jsx(he,{})]}),primaryLink:n.jsx(ke,{content:"Link",direction:"bottom",children:n.jsx("button",{type:"button",className:`size-10 lexical-btn ${W[e.Link]?"toolbarActive":"toolbar"} icon`,onClick:()=>Ce(e.Link),disabled:!!f[e.Link],children:n.jsx(_.IoIosLink,{})})}),lists:n.jsxs(n.Fragment,{children:[n.jsx(Te,{blockType:J}),n.jsx(he,{})]}),blockOptions:n.jsx(n.Fragment,{children:P.map(({id:t,label:o,icon:i})=>t===e.Divider?n.jsx(he,{},t):n.jsx(ke,{content:o,direction:"bottom",children:n.jsx("button",{type:"button",className:`size-10 lexical-btn ${W[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>Ce(t),children:i})},t))}),fontFamily:n.jsx(Ne,{}),fontSize:n.jsx(we,{}),color:n.jsx(ye,{}),codeBlock:n.jsx(Se,{}),dropdown:n.jsx(ue,{onAction:Ce,selectionMap:W}),image:n.jsx(Oe,{onImageUpload:r}),video:n.jsx(Ue,{}),table:n.jsx(Ee,{}),utility:n.jsxs(n.Fragment,{children:[n.jsx(he,{}),n.jsx(ke,{content:"Find & Replace",direction:"bottom",children:n.jsx("button",{type:"button","aria-label":"Find & Replace",className:`size-10 lexical-btn ${j?"toolbarActive":"toolbar"} icon`,onClick:()=>w(e=>!e),children:n.jsx(N.IoSearchOutline,{})})}),n.jsx(ke,{content:"Source Code View",direction:"bottom",children:n.jsx("button",{type:"button","aria-label":"Source Code View",className:`size-10 lexical-btn ${s?"toolbarActive":"toolbar"} icon`,onClick:()=>a?.(),children:n.jsx(N.IoCodeOutline,{})})}),n.jsx(ke,{content:c?"Exit Fullscreen":"Fullscreen",direction:"bottom",children:n.jsx("button",{type:"button","aria-label":c?"Exit Fullscreen":"Fullscreen",className:`size-10 lexical-btn ${c?"toolbarActive":"toolbar"} icon`,onClick:()=>u?.(),children:c?n.jsx(C.BsFullscreenExit,{}):n.jsx(C.BsFullscreen,{})})})]}),preview:n.jsx(Ke,{value:o})};return n.jsxs("div",{ref:ce,className:"lexical-toolbar-wrapper",style:{position:"relative",padding:12,marginBottom:4,borderBottom:"1px solid #e5e7eb"},children:[n.jsxs("div",{ref:M,className:"lte-toolbar-row "+(te?"useScroll":"collapse"===m?"lte-nowrap":"lte-wrap"),children:[n.jsxs("div",{ref:$,className:"lte-toolbar-primary",style:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:[H.map(({id:t,label:o,icon:i})=>t===e.Divider?n.jsx(he,{},t):n.jsx(ke,{content:o,direction:"bottom",children:n.jsx("button",{type:"button",className:`size-10 lexical-btn ${W[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>Ce(t),disabled:!!f[t],children:i})},o)),n.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:[n.jsx(pe,{updateHeading:e=>{x.update(()=>{const t=d.$getSelection();d.$isRangeSelection(t)&&ee(t,"normal"===e?()=>d.$createParagraphNode():()=>l.$createHeadingNode(e))})},headingSelectionMap:q}),n.jsx(he,{})]})]}),Je.map(({id:e})=>{const t=_e(e);return n.jsx("div",{ref:t=>{O.current[e]=t},style:t?{display:"none"}:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:t?null:Re[e]},e)}),T>0&&n.jsx(ke,{content:"More tools",direction:"bottom",children:n.jsx("button",{type:"button",ref:A,"aria-label":"More tools",className:`size-10 lexical-btn ${R?"toolbarActive":"toolbar"} icon`,onClick:()=>L(e=>!e),children:n.jsx(C.BsThreeDots,{})})})]}),te&&n.jsx("div",{ref:F,className:"lte-custom-scrollbar",onPointerDown:ae,"aria-hidden":"true",children:n.jsx("div",{ref:z,className:"lte-custom-scrollbar-thumb",onPointerDown:le})}),y&&n.jsx(ge,{linkUrl:V,setLinkUrl:X,removeLink:je,onConfirm:e=>{x.dispatchCommand(k.TOGGLE_LINK_COMMAND,{url:e,target:"_blank"}),X(e),v(!1)},onCancel:()=>{X(""),v(!1)}}),R&&n.jsx(xe,{anchorRef:A,onClose:()=>L(!1),children:Je.map(({id:e})=>e).filter(e=>_e(e)&&Re[e]).map(e=>n.jsx("div",{className:"lte-overflow-item",children:Re[e]},e))}),j&&n.jsx(me,{onClose:()=>w(!1)})]})};function Xe(e,t){const n=d.isDOMDocumentNode(t)?t.body.childNodes:t.childNodes;let o=[];const i=[];for(const t of n)if(!Ze.has(t.nodeName)){const n=et(t,e,i,!1);null!==n&&(o=o.concat(n))}return function(e){for(const t of e)t.getNextSibling()instanceof d.ArtificialNode__DO_NOT_USE&&t.insertAfter(d.$createLineBreakNode());for(const t of e){const e=t.getChildren();for(const n of e)t.insertBefore(n);t.remove()}}(i),o}function Qe(e,t){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const n=document.createElement("div"),o=d.$getRoot().getChildren();for(let i=0;i<o.length;i++)Ye(e,o[i],n,t);return n.innerHTML}function Ye(e,t,n,o=null){let i=null===o||t.isSelected(o);const l=d.$isElementNode(t)&&t.excludeFromCopy("html");let r=t;if(null!==o){let e=d.$cloneWithProperties(t);e=d.$isTextNode(e)&&null!==o?function(e,t){const n=e.getStartEndPoints();if(t.isSelected(e)&&!d.$isTokenOrSegmented(t)&&null!==n){const[o,i]=n,l=e.isBackward(),r=o.getNode(),s=i.getNode(),a=t.is(r),c=t.is(s);if(a||c){const[n,o]=d.$getCharacterOffsets(e),i=r.is(s),a=t.is(l?s:r),c=t.is(l?r:s);let u,h=0;i?(h=n>o?o:n,u=n>o?n:o):a?(h=l?o:n,u=void 0):c&&(h=0,u=l?n:o),t.__text=t.__text.slice(h,u)}}return t}(o,e):e,r=e}const s=d.$isElementNode(r)?r.getChildren():[],a=d.getRegisteredNode(e,r.getType());let c;c=a&&void 0!==a.exportDOM?a.exportDOM(e,r):r.exportDOM(e);const{element:u,after:h}=c;if(!u)return!1;const p=document.createDocumentFragment();for(let n=0;n<s.length;n++){const l=s[n],r=Ye(e,l,p,o);!i&&d.$isElementNode(t)&&r&&t.extractWithChild(l,o,"html")&&(i=!0)}if(i&&!l){if((d.isHTMLElement(u)||d.isDocumentFragment(u))&&u.append(p),n.append(u),h){const e=h.call(r,u);e&&(d.isDocumentFragment(u)?u.replaceChildren(e):u.replaceWith(e))}}else n.append(p);return i}const Ze=new Set(["STYLE","SCRIPT"]);function et(e,t,n,o,i=new Map,l){let r=[];if(Ze.has(e.nodeName))return r;let s=null;const a=function(e,t){const{nodeName:n}=e,o=t._htmlConversions.get(n.toLowerCase());let i=null;if(void 0!==o)for(const t of o){const n=t(e);null!==n&&(null===i||(i.priority||0)<=(n.priority||0))&&(i=n)}return null!==i?i.conversion:null}(e,t),c=a?a(e):null;let u=null;if(null!==c){u=c.after;const t=c.node;if(s=Array.isArray(t)?t[t.length-1]:t,null!==s){for(const[,e]of i)if(s=e(s,l),!s)break;s&&r.push(...Array.isArray(t)?t:[s])}null!=c.forChild&&i.set(e.nodeName,c.forChild)}const h=e.childNodes;let p=[];const g=(null==s||!d.$isRootOrShadowRoot(s))&&(null!=s&&d.$isBlockElementNode(s)||o);for(let e=0;e<h.length;e++)p.push(...et(h[e],t,n,g,new Map(i),s));return null!=u&&(p=u(p)),d.isBlockDomNode(e)&&(p=function(e,t,n){const o=e.style.textAlign,i=[];let l=[];for(let e=0;e<t.length;e++){const r=t[e];if(d.$isBlockElementNode(r))o&&!r.getFormat()&&r.setFormat(o),i.push(r);else if(l.push(r),e===t.length-1||e<t.length-1&&d.$isBlockElementNode(t[e+1])){const e=n();e.setFormat(o),e.append(...l),i.push(e),l=[]}}return i}(e,p,g?()=>{const e=new d.ArtificialNode__DO_NOT_USE;return n.push(e),e}:d.$createParagraphNode)),null==s?p.length>0?r=r.concat(p):d.isBlockDomNode(e)&&function(e){return null!=e.nextSibling&&null!=e.previousSibling&&(d.isInlineDomNode(e.nextSibling)&&d.isInlineDomNode(e.previousSibling))}(e)&&(r=r.concat(d.$createLineBreakNode())):d.$isElementNode(s)&&s.append(...p),r}function tt({value:e,onChange:t}){const[o]=S.useLexicalComposerContext(),[l,r]=i.useState(!0);return i.useEffect(()=>{e&&l&&(r(!1),o.update(()=>{if(Qe(o)!==e){d.$getRoot().clear();const t=(new DOMParser).parseFromString(e,"text/html"),n=Xe(o,t);d.$insertNodes(n)}}))},[o,e,l]),i.useEffect(()=>{r(!0)},[e]),n.jsx(I.OnChangePlugin,{onChange:e=>{e.read(()=>{t(Qe(o))})}})}function nt({applyRef:e,onExit:t}){const[o]=S.useLexicalComposerContext(),[l,r]=i.useState(()=>o.getEditorState().read(()=>Qe(o))),s=i.useRef(l),a=e=>{e!==s.current&&(o.update(()=>{const t=d.$getRoot();if(t.clear(),t.selectEnd(),e){const t=(new DOMParser).parseFromString(e,"text/html"),n=Xe(o,t);n.length>0&&d.$insertNodes(n)}}),s.current=e)};return i.useEffect(()=>(e.current=()=>{a(l),t()},()=>{e.current=null}),[e,l,t,o]),n.jsxs("div",{className:"lexical-source-view",children:[n.jsx("textarea",{className:"lexical-source-textarea",value:l,onChange:e=>r(e.target.value),"aria-label":"HTML source",spellCheck:!1}),n.jsxs("div",{className:"lexical-source-actions",children:[n.jsx(ke,{content:"Apply HTML to the editor",direction:"top",children:n.jsxs("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>a(l),children:[n.jsx(R.MdCheck,{size:16}),n.jsx("span",{className:"label",children:"Update"})]})}),n.jsx("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>{a(l),t()},children:"Done"})]})]})}function ot({showWordCount:e=!0,showCharCount:t=!0,rightSlot:o}){const[l]=S.useLexicalComposerContext(),[r,s]=i.useState({words:0,chars:0});return i.useEffect(()=>{const e=e=>{e.read(()=>{const e=d.$getRoot().getTextContent(),t=e.trim();s({words:t?t.split(/\s+/).length:0,chars:e.length})})};return e(l.getEditorState()),l.registerUpdateListener(({editorState:t})=>{e(t)})},[l]),n.jsxs("div",{className:"lexical-status-bar",children:[e&&n.jsxs("span",{children:[r.words," words"]}),t&&n.jsxs("span",{children:[r.chars," characters"]}),o&&n.jsx("div",{className:"lexical-status-bar-right",children:o})]})}function it({theme:e,toolbarStyle:t,onThemeChange:o,onToolbarStyleChange:i}){const l="normal"===t?"collapse":t,r=[{value:"light",label:"Light theme",icon:n.jsx(C.BsSun,{})},{value:"dark",label:"Dark theme",icon:n.jsx(C.BsMoon,{})},{value:"system",label:"Follow system theme",icon:n.jsx(R.MdMonitor,{})}],s=[{value:"wrap",label:"Toolbar: wrap to new lines",icon:n.jsx(R.MdWrapText,{})},{value:"collapse",label:'Toolbar: collapse into "..."',icon:n.jsx(C.BsThreeDots,{})},{value:"scrollbar",label:"Toolbar: scroll in one row",icon:n.jsx(y.TbArrowsLeftRight,{})}];return n.jsxs("div",{className:"lexical-display-controls",role:"group","aria-label":"Display settings",children:[n.jsx("div",{className:"lte-mini-seg",role:"radiogroup","aria-label":"Theme",children:r.map(t=>n.jsx(ke,{content:t.label,direction:"top",children:n.jsx("button",{type:"button",role:"radio","aria-checked":e===t.value,"aria-label":t.label,className:"lte-mini-btn btn "+(e===t.value?"active":""),onClick:()=>o?.(t.value),children:t.icon})},t.value))}),n.jsx("div",{className:"lte-mini-seg",role:"radiogroup","aria-label":"Toolbar style",children:s.map(e=>n.jsx(ke,{content:e.label,direction:"top",children:n.jsx("button",{type:"button",role:"radio","aria-checked":l===e.value,"aria-label":e.label,className:"lte-mini-btn btn "+(l===e.value?"active":""),onClick:()=>i?.(e.value),children:e.icon})},e.value))})]})}const lt=({id:e})=>new ut({id:e}),rt="data-lexical-youtube",st="315px",at="560px",ct=e=>`https://www.youtube-nocookie.com/embed/${e}`,dt=e=>{const t=e?.getAttribute(rt);if(!t)return null;return{node:lt({id:t})}};class ut extends d.DecoratorNode{constructor({id:e,key:t}){super(t),this.__id=e}static getType(){return"youtube"}static clone(e){return new ut({id:e.__id,key:e.getKey()})}static importJSON(e){return lt({id:e.id})}exportJSON(){return{id:this.__id,type:"youtube",version:1}}decorate(){return n.jsx("iframe",{height:st,width:at,src:ct(this.__id),frameBorder:"0",allowFullScreen:!0})}createDOM(){return document.createElement("div")}exportDOM(){const e=document.createElement("iframe");return e.setAttribute(rt,this.__id),e.setAttribute("height",st),e.setAttribute("width",at),e.setAttribute("src",ct(this.__id)),{element:e}}static importDOM(){return{iframe:()=>({conversion:dt,priority:0})}}}class ht extends d.TextNode{constructor(e,t){super(e,t)}static getType(){return"extended-text"}static clone(e){return new ht(e.__text,e.__key)}static importDOM(){const e=d.TextNode.importDOM();return{...e,span:()=>({conversion:pt(e?.span),priority:1}),div:()=>({conversion:pt(e?.div),priority:1}),p:()=>({conversion:pt(e?.p),priority:1}),b:()=>({conversion:pt(e?.b),priority:1}),strong:()=>({conversion:pt(e?.strong),priority:1}),i:()=>({conversion:pt(e?.i),priority:1}),em:()=>({conversion:pt(e?.em),priority:1}),u:()=>({conversion:pt(e?.u),priority:1}),s:()=>({conversion:pt(e?.s),priority:1}),strike:()=>({conversion:pt(e?.strike),priority:1}),code:()=>({conversion:pt(e?.code),priority:1})}}static importJSON(e){return function(e=""){return d.$applyNodeReplacement(new ht(e))}().updateFromJSON(e)}isSimpleText(){return"extended-text"===this.__type&&0===this.__mode}}function pt(e){return t=>{const n=e?.(t);if(!n)return null;const o=n.conversion(t);if(!o)return o;const i=t.style,l=[];i.backgroundColor&&l.push(`background-color: ${i.backgroundColor}`),i.color&&l.push(`color: ${i.color}`),i.fontFamily&&l.push(`font-family: ${i.fontFamily}`),i.fontWeight&&l.push(`font-weight: ${i.fontWeight}`),i.fontSize&&l.push(`font-size: ${i.fontSize}`),i.fontStyle&&l.push(`font-style: ${i.fontStyle}`),i.textDecoration&&l.push(`text-decoration: ${i.textDecoration}`),i.whiteSpace&&l.push(`white-space: ${i.whiteSpace}`),i.textAlign&&l.push(`text-align: ${i.textAlign}`);const r=t.getAttribute("style");if(r){r.split(";").filter(e=>e.trim()).forEach(e=>{const[t]=e.split(":").map(e=>e.trim());t&&!l.some(e=>e.startsWith(t))&&l.push(e.trim())})}return{...o,forChild:(e,t)=>{const n=o?.forChild??(e=>e),i=n(e,t);if(d.$isTextNode(i)&&l.length>0){const e=l.join("; ");return i.setStyle(e)}return i}}}}const gt={text:{bold:"lexical-bold",underline:"lexical-underline",italic:"lexical-italic",strikethrough:"lexical-strikethrough",underlineStrikethrough:"lexical-underline-strikethrough",uppercase:"lexical-uppercase",lowercase:"lexical-lowercase",capitalize:"lexical-capitalize",code:"lexical-code"},paragraph:"lexical-paragraph",list:{ul:"lexical-list-ul",ol:"lexical-list-ol",listitem:"lexical-listitem"},quote:"lexical-quote",link:"lexical-link",code:"lexical-code-block",hr:"lexical-hr",indent:"lexical-indent",table:"lexical-table",tableRow:"lexical-table-row",tableCell:"lexical-table-cell",codeHighlight:{keyword:"lexical-code-token-keyword",string:"lexical-code-token-string",number:"lexical-code-token-number",comment:"lexical-code-token-comment",function:"lexical-code-token-function",operator:"lexical-code-token-operator",punctuation:"lexical-code-token-punctuation"}},mt=i.memo(function({name:e,value:t,onChange:b,placeholder:y,maxWidth:C=null,height:v=null,onImageUpload:N,showWordCount:j=!0,showCharCount:w=!0,theme:S="system",toolbarStyle:T="collapse",showDisplayControls:E=!0,onThemeChange:_,onToolbarStyleChange:R}){const[L,M]=i.useState(!1),[$,A]=i.useState(!1),O=i.useRef(null),[I,F]=i.useState(!1),[B,H]=i.useState(S),[z,P]=i.useState("normal"===T?"collapse":T);i.useEffect(()=>{H(S)},[S]),i.useEffect(()=>{P("normal"===T?"collapse":T)},[T]),i.useEffect(()=>{if("system"!==B||"undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)");F(e.matches);const t=e=>F(e.matches);return e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))},[B]);const W="dark"===B||"system"===B&&I;i.useEffect(()=>{if(!$)return;const e=e=>{"Escape"===e.key&&A(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[$]);const U=i.useMemo(()=>({namespace:e,theme:gt,onError:e=>{console.error("Lexical error:",e)},nodes:[ht,{replace:d.TextNode,with:e=>new ht(e.__text),withKlass:ht},l.HeadingNode,r.CodeHighlightNode,r.CodeNode,p.ListNode,p.ListItemNode,l.QuoteNode,k.LinkNode,Me,ut,We,g.HorizontalRuleNode,f.TableNode,f.TableRowNode,f.TableCellNode]}),[e]);return n.jsx("div",{className:`lexical-text-editor lexical-editor-container ${$?"lexical-fullscreen":""} ${W?"lexical-dark":""}`,style:{maxWidth:$?"none":C||"1090px"},children:n.jsxs(o.LexicalComposer,{initialConfig:U,children:[n.jsx("div",{className:"lexical-toolbar-container",children:n.jsx(Ve,{value:t,onImageUpload:N,sourceView:L,onToggleSourceView:()=>{M(e=>!e||(O.current?.(),!1))},fullscreen:$,onToggleFullscreen:()=>{A(e=>!e)},toolbarStyle:z})}),n.jsx("div",{className:"lexical-editor-inner",style:L?{display:"none"}:void 0,children:n.jsx(s.RichTextPlugin,{contentEditable:n.jsx(a.ContentEditable,{className:"lexical-content-editable",style:{height:v||"500px"}}),placeholder:n.jsx("div",{className:"lexical-placeholder",children:y||"Some Text"}),ErrorBoundary:c.LexicalErrorBoundary})}),L&&n.jsx(nt,{applyRef:O,onExit:()=>M(!1)}),(j||w||E)&&n.jsx(ot,{showWordCount:j,showCharCount:w,rightSlot:E?n.jsx(it,{theme:B,toolbarStyle:z,onThemeChange:e=>{H(e),_?.(e)},onToolbarStyleChange:e=>{P(e),R?.(e)}}):void 0}),n.jsx(u.HistoryPlugin,{}),n.jsx(h.ListPlugin,{}),n.jsx(x.TablePlugin,{}),n.jsx(m.HorizontalRulePlugin,{}),n.jsx(D.LinkPlugin,{}),n.jsx(tt,{value:t,onChange:b})]})})});exports.LexicalTextEditor=mt;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|