@innoviatech/lexical-text-editor 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/index.d.ts +19 -22
- 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/plugins/InlineCodeExitPlugin.d.ts +17 -0
- package/dist/plugins/toolbarOverflowContext.d.ts +8 -0
- package/package.json +1 -1
|
@@ -38,49 +38,46 @@ export declare enum HeadingAction {
|
|
|
38
38
|
H5 = "h5",
|
|
39
39
|
H6 = "h6"
|
|
40
40
|
}
|
|
41
|
-
export declare const RICH_TEXT_FORMAT_OPTIONS:
|
|
41
|
+
export declare const RICH_TEXT_FORMAT_OPTIONS: {
|
|
42
42
|
id: RichTextAction;
|
|
43
43
|
icon: import("react/jsx-runtime").JSX.Element;
|
|
44
44
|
label: string;
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
}[];
|
|
46
|
+
export declare const RICH_TEXT_OPTIONS: {
|
|
47
47
|
id: RichTextAction;
|
|
48
48
|
icon: import("react/jsx-runtime").JSX.Element;
|
|
49
49
|
label: string;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
export declare const RICH_TEXT_OPTIONS: ({
|
|
50
|
+
}[];
|
|
51
|
+
export declare const RICH_HIGHLIGHT_OPTIONS: {
|
|
53
52
|
id: RichTextAction;
|
|
54
53
|
icon: import("react/jsx-runtime").JSX.Element;
|
|
55
54
|
label: string;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
icon?: undefined;
|
|
59
|
-
label?: undefined;
|
|
60
|
-
})[];
|
|
61
|
-
export declare const RICH_REDO_UNDO_OPTIONS: ({
|
|
55
|
+
}[];
|
|
56
|
+
export declare const RICH_QUOTE_CODE_OPTIONS: {
|
|
62
57
|
id: RichTextAction;
|
|
63
58
|
icon: import("react/jsx-runtime").JSX.Element;
|
|
64
59
|
label: string;
|
|
65
|
-
}
|
|
60
|
+
}[];
|
|
61
|
+
export declare const RICH_REDO_UNDO_OPTIONS: {
|
|
66
62
|
id: RichTextAction;
|
|
67
|
-
icon
|
|
68
|
-
label
|
|
69
|
-
}
|
|
70
|
-
export declare const
|
|
63
|
+
icon: import("react/jsx-runtime").JSX.Element;
|
|
64
|
+
label: string;
|
|
65
|
+
}[];
|
|
66
|
+
export declare const RICH_BLOCK_OPTIONS: {
|
|
71
67
|
id: RichTextAction;
|
|
72
68
|
icon: import("react/jsx-runtime").JSX.Element;
|
|
73
69
|
label: string;
|
|
74
70
|
}[];
|
|
75
|
-
export declare const
|
|
71
|
+
export declare const RICH_HLINE_OPTIONS: {
|
|
76
72
|
id: RichTextAction;
|
|
77
73
|
icon: import("react/jsx-runtime").JSX.Element;
|
|
78
74
|
label: string;
|
|
79
|
-
}
|
|
75
|
+
}[];
|
|
76
|
+
export declare const RICH_ALIGNMENT_OPTIONS: {
|
|
80
77
|
id: RichTextAction;
|
|
81
|
-
icon
|
|
82
|
-
label
|
|
83
|
-
}
|
|
78
|
+
icon: import("react/jsx-runtime").JSX.Element;
|
|
79
|
+
label: string;
|
|
80
|
+
}[];
|
|
84
81
|
export declare const LOW_PRIORIRTY = 1;
|
|
85
82
|
export declare const HEADINGS: {
|
|
86
83
|
id: string;
|
package/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{LexicalComposer as o}from"@lexical/react/LexicalComposer";import i,{useRef as l,useEffect as r,cloneElement as a,useState as c,useCallback as s,useMemo as d}from"react";import{$isHeadingNode as u,$isQuoteNode as h,$createQuoteNode as p,$createHeadingNode as m,HeadingNode as g,QuoteNode as f}from"@lexical/rich-text";import{$isCodeNode as b,$createCodeNode as y,CodeHighlightNode as v,CodeNode as x}from"@lexical/code";import{RichTextPlugin as w}from"@lexical/react/LexicalRichTextPlugin";import{ContentEditable as C}from"@lexical/react/LexicalContentEditable";import{LexicalErrorBoundary as k}from"@lexical/react/LexicalErrorBoundary";import{$createRangeSelection as N,$findMatchingParent as S,INTERNAL_$isBlock as _,$isElementNode as L,$getSelection as T,$setSelection as E,$isRootOrShadowRoot as A,$hasAncestor as R,$isRangeSelection as M,$isTextNode as D,$isTokenOrSegmented as F,$getCharacterOffsets as z,$isLeafNode as W,$getPreviousSelection as O,$caretRangeFromSelection as I,$getRoot as H,$getNodeByKey as U,SELECTION_CHANGE_COMMAND as $,$createParagraphNode as P,KEY_TAB_COMMAND as B,OUTDENT_CONTENT_COMMAND as K,INDENT_CONTENT_COMMAND as J,COMMAND_PRIORITY_EDITOR as V,DecoratorNode as j,$applyNodeReplacement as q,PASTE_COMMAND as Q,COMMAND_PRIORITY_LOW as X,$insertNodes as Y,CAN_REDO_COMMAND as G,CAN_UNDO_COMMAND as Z,REDO_COMMAND as ee,UNDO_COMMAND as te,FORMAT_ELEMENT_COMMAND as ne,FORMAT_TEXT_COMMAND as oe,isDOMDocumentNode as ie,ArtificialNode__DO_NOT_USE as le,$createLineBreakNode as re,$cloneWithProperties as ae,getRegisteredNode as ce,isHTMLElement as se,isDocumentFragment as de,$isBlockElementNode as ue,isBlockDomNode as he,isInlineDomNode as pe,TextNode as me}from"lexical";import{HistoryPlugin as ge}from"@lexical/react/LexicalHistoryPlugin";import{ListPlugin as fe}from"@lexical/react/LexicalListPlugin";import{REMOVE_LIST_COMMAND as be,INSERT_ORDERED_LIST_COMMAND as ye,INSERT_UNORDERED_LIST_COMMAND as ve,ListNode as xe,$isListNode as we,ListItemNode as Ce}from"@lexical/list";import{INSERT_HORIZONTAL_RULE_COMMAND as ke,HorizontalRuleNode as Ne}from"@lexical/react/LexicalHorizontalRuleNode";import{HorizontalRulePlugin as Se}from"@lexical/react/LexicalHorizontalRulePlugin";import{TablePlugin as _e}from"@lexical/react/LexicalTablePlugin";import{$findCellNode as Le,INSERT_TABLE_COMMAND as Te,$isTableCellNode as Ee,TableCellHeaderStates as Ae,$insertTableRowAtSelection as Re,$deleteTableRowAtSelection as Me,$insertTableColumnAtSelection as De,$deleteTableColumnAtSelection as Fe,TableNode as ze,TableRowNode as We,TableCellNode as Oe}from"@lexical/table";import{RxLetterCaseLowercase as Ie,RxLetterCaseUppercase as He,RxLetterCaseCapitalize as Ue}from"react-icons/rx";import{TbBold as $e,TbItalic as Pe,TbUnderline as Be,TbSeparatorHorizontal as Ke,TbArrowsLeftRight as Je}from"react-icons/tb";import{BsSuperscript as Ve,BsSubscript as je,BsChatSquareQuote as qe,BsArrowCounterclockwise as Qe,BsArrowClockwise as Xe,BsJustifyLeft as Ye,BsTextCenter as Ge,BsJustifyRight as Ze,BsJustify as et,BsTextParagraph as tt,BsTypeH1 as nt,BsTypeH2 as ot,BsTypeH3 as it,BsTypeH4 as lt,BsTypeH5 as rt,BsTypeH6 as at,BsPencilSquare as ct,BsListOl as st,BsListUl as dt,BsTable as ut,BsFullscreenExit as ht,BsFullscreen as pt,BsThreeDots as mt,BsSun as gt,BsMoon as ft}from"react-icons/bs";import{AiOutlineStrikethrough as bt,AiOutlineFontColors as yt,AiOutlineBgColors as vt}from"react-icons/ai";import{IoCodeSlashOutline as xt,IoChevronUp as wt,IoChevronDown as Ct,IoClose as kt,IoImageOutline as Nt,IoSearchOutline as St,IoCodeOutline as _t}from"react-icons/io5";import{PiHighlighterLight as Lt}from"react-icons/pi";import{RiEraserLine as Tt,RiIndentIncrease as Et,RiIndentDecrease as At,RiFontFamily as Rt,RiFontSize as Mt}from"react-icons/ri";import{useLexicalComposerContext as Dt}from"@lexical/react/LexicalComposerContext";import{TOGGLE_LINK_COMMAND as Ft,$isLinkNode as zt,LinkNode as Wt}from"@lexical/link";import{HiChevronDown as Ot}from"react-icons/hi2";import{createPortal as It}from"react-dom";import{IoIosLink as Ht}from"react-icons/io";import{MdCheck as Ut,MdMonitor as $t,MdWrapText as Pt}from"react-icons/md";import{BiUnlink as Bt}from"react-icons/bi";import{SketchPicker as Kt}from"react-color";import{LuUpload as Jt}from"react-icons/lu";import{FaYoutube as Vt}from"react-icons/fa";import{VscPreview as jt}from"react-icons/vsc";import{LinkPlugin as qt}from"@lexical/react/LexicalLinkPlugin";import{OnChangePlugin as Qt}from"@lexical/react/LexicalOnChangePlugin";var Xt,Yt;!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"}(Xt||(Xt={})),function(e){e.Normal="normal",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6"}(Yt||(Yt={}));const Gt=[{id:Xt.Lowercase,icon:e(Ie,{}),label:"Lowercase"},{id:Xt.Uppercase,icon:e(He,{}),label:"Uppercase"},{id:Xt.Capitalize,icon:e(Ue,{}),label:"Capitalize"},{id:Xt.Strikethrough,icon:e(bt,{}),label:"Strikethrough"},{id:Xt.Highlight,icon:e(Lt,{}),label:"Highlight",fontSize:10},{id:Xt.Superscript,icon:e(Ve,{}),label:"Superscript"},{id:Xt.Subscript,icon:e(je,{}),label:"Subscript"}],Zt=[{id:Xt.Bold,icon:e($e,{}),label:"Bold"},{id:Xt.Italics,icon:e(Pe,{}),label:"Italics"},{id:Xt.Underline,icon:e(Be,{}),label:"Underline"},{id:Xt.Divider},{id:Xt.Quote,icon:e(qe,{}),label:"Quote"},{id:Xt.Code,icon:e(xt,{}),label:"Code"},{id:Xt.ClearFormatting,icon:e(Tt,{}),label:"Clear Formatting"}],en=[{id:Xt.Undo,icon:e(Qe,{}),label:"Undo"},{id:Xt.Redo,icon:e(Xe,{}),label:"Redo"},{id:Xt.Divider}],tn=[{id:Xt.LeftAlign,icon:e(Ye,{}),label:"Left Align"},{id:Xt.CenterAlign,icon:e(Ge,{}),label:"Center Align"},{id:Xt.RightAlign,icon:e(Ze,{}),label:"Right Align"},{id:Xt.JustifyAlign,icon:e(et,{}),label:"Justify Align"}],nn=[{id:Xt.Indent,icon:e(Et,{}),label:"Indent"},{id:Xt.Outdent,icon:e(At,{}),label:"Outdent"},{id:Xt.Divider},{id:Xt.HorizontalRule,icon:e(Ke,{}),label:"Horizontal Rule"}],on=[{id:"normal",label:"Normal",icon:e(tt,{})},{id:"h1",label:"Heading 1",icon:e(nt,{})},{id:"h2",label:"Heading 2",icon:e(ot,{})},{id:"h3",label:"Heading 3",icon:e(it,{})},{id:"h4",label:"Heading 4",icon:e(lt,{})},{id:"h5",label:"Heading 5",icon:e(rt,{})},{id:"h6",label:"Heading 6",icon:e(at,{})}],ln=[{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 rn(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 an=new Map;function cn(e){let t=an.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),an.set(e,t)),t}function sn(e,t){(M(e)?e.isCollapsed():D(e)||L(e))||rn(280);const n=cn(M(e)?e.style:D(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);M(e)||D(e)?e.setStyle(i):e.setTextStyle(i),an.set(i,o)}function dn(e,t){if(M(e)&&e.isCollapsed()){sn(e,t);const n=e.anchor.getNode();L(n)&&n.isEmpty()&&sn(n,t)}!function(e){const t=T();if(!t)return;const n=new Map,o=e=>n.get(e.getKey())||[0,e.getTextContentSize()];if(M(t))for(const e of I(t).getTextSlices())e&&n.set(e.caret.origin.getKey(),e.getSliceIndices());const i=t.getNodes();for(const t of i){if(!D(t)||!t.canHaveFormat())continue;const[n,i]=o(t);i!==n&&(F(t)||0===n&&i===t.getTextContentSize()?e(t):e(t.splitText(n,i)[0===n?0:1]))}M(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=>{sn(e,t)})}function un(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o)}function hn(e,t,n=un){if(null===e)return;const o=e.getStartEndPoints(),i=new Map;let l=null;if(o){const[e,t]=o;l=N(),l.anchor.set(e.key,e.offset,e.type),l.focus.set(t.key,t.offset,t.type);const n=S(e.getNode(),_),r=S(t.getNode(),_);L(n)&&i.set(n.getKey(),n),L(r)&&i.set(r.getKey(),r)}for(const t of e.getNodes())if(L(t)&&_(t))i.set(t.getKey(),t);else if(null===o){const e=S(t,_);L(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(T())&&E(l)}function pn(e){return e.getNode().isAttached()}function mn(e){let t=e;for(;null!==t&&!A(t);){const e=t.getLatest(),n=t.getParent();0===e.getChildrenSize()&&t.remove(!0),t=n}}function gn(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 a=null,c=[];for(let o=0;o<r;o++){const i=l[o];A(i)?(fn(e,c,c.length,t,n),c=[],a=i):null===a||null!==a&&R(i,a)?c.push(i):(fn(e,c,c.length,t,n),c=[i])}fn(e,c,c.length,t,n)}function fn(e,t,n,o,i=null){if(0===t.length)return;const l=t[0],r=new Map,a=[];let c=L(l)?l:l.getParentOrThrow();c.isInline()&&(c=c.getParentOrThrow());let s=!1;for(;null!==c;){const e=c.getPreviousSibling();if(null!==e){c=e,s=!0;break}if(c=c.getParentOrThrow(),A(c))break}const d=new Set;for(let e=0;e<n;e++){const n=t[e];L(n)&&0===n.getChildrenSize()&&d.add(n.getKey())}const u=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&&W(n)&&!u.has(n.getKey())){const e=i.getKey();if(void 0===r.get(e)){const t=o();t.setFormat(i.getFormatType()),t.setIndent(i.getIndent()),a.push(t),r.set(e,t),i.getChildren().forEach(e=>{t.append(e),u.add(e.getKey()),L(e)&&e.getChildrenKeys().forEach(e=>u.add(e))}),mn(i)}}else if(d.has(n.getKey())){L(n)||rn(179);const e=o();e.setFormat(n.getFormatType()),e.setIndent(n.getIndent()),a.push(e),n.remove(!0)}}if(null!==i)for(let e=0;e<a.length;e++){const t=a[e];i.append(t)}let h=null;if(A(c))if(s)if(null!==i)c.insertAfter(i);else for(let e=a.length-1;e>=0;e--){const t=a[e];c.insertAfter(t)}else{const e=c.getFirstChild();if(L(e)&&(c=e),null===e)if(i)c.append(i);else for(let e=0;e<a.length;e++){const t=a[e];c.append(t),h=t}else if(null!==i)e.insertBefore(i);else for(let t=0;t<a.length;t++){const n=a[t];e.insertBefore(n),h=n}}else if(i)c.insertAfter(i);else for(let e=a.length-1;e>=0;e--){const t=a[e];c.insertAfter(t),h=t}const p=O();M(p)&&pn(p.anchor)&&pn(p.focus)?E(p.clone()):null!==h?h.selectEnd():e.dirty=!0}function bn(e,t,n){const o=cn(e.getStyle());return null!==o&&o[t]||n}function yn(e,t,n=""){let o=null;const i=e.getNodes(),l=e.anchor,r=e.focus,a=e.isBackward(),c=a?r.offset:l.offset,s=a?r.getNode():l.getNode();if(M(e)&&e.isCollapsed()&&""!==e.style){const n=cn(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!==c||!l.is(s))&&D(l)){const e=bn(l,t,n);if(null===o)o=e;else if(o!==e){o="";break}}}return null===o?n:o}const vn="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,xn=vn&&"documentMode"in document?document.documentMode:null;function wn(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function Cn(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null}function kn({open:t,onOpenChange:n,children:o}){const c=l(null),s=l(null);return r(()=>{function e(e){c.current?.contains(e.target)||s.current?.contains(e.target)||n(!1)}return t&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t,n]),e("div",{className:"popover-root",children:i.Children.map(o,e=>e&&"object"==typeof e?e.type===Nn?a(e,{triggerRef:c}):e.type===Sn?a(e,{contentRef:s,triggerRef:c}):e:e)})}function Nn({children:t,triggerRef:n}){return e("div",{className:"popover-trigger",ref:n,children:t})}function Sn({open:t,align:n="start",children:o,contentRef:a,triggerRef:c}){const s=l(null),[d,u]=i.useState(!1);return r(()=>{if(!t)return;const e=()=>{const e=s.current,t=c?.current;if(!e||!t)return;const o=t.closest(".lexical-text-editor"),i=!!o?.classList.contains("lexical-dark");e.classList.contains("lexical-dark")!==i&&e.classList.toggle("lexical-dark",i);const l=t.getBoundingClientRect(),r=e.offsetWidth,a=e.offsetHeight;let d=l.left;"center"===n?d=l.left+l.width/2-r/2:"end"===n&&(d=l.right-r),d=Math.max(8,Math.min(window.innerWidth-r-8,d));let h=l.bottom+4;h+a>window.innerHeight-8&&l.top>a+8&&(h=l.top-a-4),e.style.left=`${d}px`,e.style.top=`${h}px`,u(i)};return e(),requestAnimationFrame(e),window.addEventListener("resize",e),document.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),document.removeEventListener("scroll",e,!0)}},[t,n,c]),t?It(e("div",{ref:s,className:"lexical-text-editor"+(d?" 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:e("div",{ref:e=>{a.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 _n({onAction:n,selectionMap:o}){const[i,r]=c(!1),a=l(null),s=l(null);return t(kn,{open:i,onOpenChange:r,children:[e(Nn,{triggerRef:a,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(i?"toolbar-active":"toolbar"),onClick:()=>r(e=>!e),children:[e("span",{children:"Aa"}),e(Ot,{className:"chevron "+(i?"rotated":"")})]})}),e(Sn,{open:i,align:"start",onClose:()=>r(!1),contentRef:s,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:Gt.map(({id:i,label:l,icon:a})=>t("button",{type:"button",className:"lexical-btn "+(o[i]?"toolbar-active":"toolbar"),onClick:()=>{n(i),r(!1)},style:{minWidth:130},children:[a,e("span",{className:"label",children:l})]},i))})})]})}function Ln(){return e("div",{className:"w-[1px] h-[20px] mx-[2px] bg-gray-300 shrink-0"})}function Tn({updateHeading:n,headingSelectionMap:o}){const i=on.find(e=>o[e.id]),[r,a]=c(!1),s=l(null),d=l(null);return t(kn,{open:r,onOpenChange:a,children:[e(Nn,{triggerRef:s,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(r?"toolbar-active":"toolbar"),onClick:()=>a(e=>!e),style:{minWidth:132},children:[i?.icon,e("span",{children:i?.label}),e(Ot,{className:"chevron "+(r?"rotated":"")})]})}),e(Sn,{open:r,align:"start",onClose:()=>a(!1),contentRef:d,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:on.map(({id:i,label:l,icon:r})=>t("button",{type:"button",className:"lexical-btn "+(o[i]?"toolbar-active":"toolbar"),onClick:()=>{n(i),a(!1)},children:[r,e("span",{className:"label",children:l})]},i))})})]})}function En({linkUrl:n,setLinkUrl:o,onConfirm:i,onCancel:a,removeLink:s}){const[d,u]=c(!1),h=l(null),p=l(null);return r(()=>{"https://"===n&&u(!0)},[n]),r(()=>{d&&p.current?.focus()},[d]),r(()=>{const e=e=>{h.current&&!h.current.contains(e.target)&&a()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[a]),t("div",{ref:h,className:"lexical-text-editor-link link-editor-container",children:[e("div",{className:"link-editor-input-wrapper",children:d?e("input",{ref:p,className:"link-editor-input",value:n,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),i(n),u(!1)):"Escape"===e.key&&(e.preventDefault(),u(!1),a())}}):e("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"link-editor-url",children:n})}),t("div",{className:"link-editor-buttons",children:[e("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>{d?(i(n),u(!1)):u(!0)},children:d?e(Ut,{size:18}):e(ct,{size:14})}),e("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onMouseDown:e=>e.preventDefault(),onClick:s,children:e(Bt,{size:14,style:{stroke:"black"}})})]})]})}function An({onClose:n}){const[o]=Dt(),[i,a]=c(""),[s,d]=c(""),[u,h]=c(!1),[p,m]=c([]),[g,f]=c(0),b=l(null);r(()=>{b.current?.focus()},[]);const y=()=>{if(!i)return[];const e=u?i:i.toLowerCase(),t=[],n=H().getAllTextNodes();for(const o of n){const n=u?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};r(()=>{const e=o.getEditorState().read(y);m(e),f(0)},[o,i,u]),r(()=>o.registerUpdateListener(({editorState:e})=>{const t=e.read(y);m(t),f(e=>0===t.length?0:Math.min(e,t.length-1))}),[o,i,u]);const v=e=>{if(0===p.length)return;const t=(g+e+p.length)%p.length,n=p[t];f(t),o.update(()=>{const e=U(n.key);D(e)&&e.select(n.start,n.start+i.length)}),requestAnimationFrame(()=>{const e=o.getElementByKey(n.key);e?.scrollIntoView({block:"nearest"})})},x=i.length>0,w=p.length>0;return t("div",{className:"lexical-find-replace",onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),n())},children:[t("div",{className:"lexical-fr-row",children:[e("input",{ref:b,className:"lexical-fr-input",placeholder:"Find",value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),v(e.shiftKey?-1:1))}}),e("span",{className:"lexical-fr-count",children:w?`${g+1} of ${p.length}`:x?"0 results":""})]}),e("div",{className:"lexical-fr-row",children:e("input",{className:"lexical-fr-input",placeholder:"Replace with",value:s,onChange:e=>d(e.target.value)})}),t("div",{className:"lexical-fr-row",children:[t("label",{className:"lexical-fr-case",children:[e("input",{type:"checkbox",checked:u,onChange:e=>h(e.target.checked)}),e("span",{children:"Match case"})]}),e("span",{style:{flex:1}}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>v(-1),disabled:!w,"aria-label":"Previous match",children:e(wt,{})}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>v(1),disabled:!w,"aria-label":"Next match",children:e(Ct,{})}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>{o.update(()=>{const e=y();if(0===e.length)return m([]),void f(0);const t=e[Math.min(g,e.length-1)],n=U(t.key);D(n)&&n.spliceText(t.start,i.length,s,!0)})},disabled:!w,children:"Replace"}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>{o.update(()=>{const e=y();for(let t=e.length-1;t>=0;t--){const n=e[t],o=U(n.key);D(o)&&o.spliceText(n.start,i.length,s,!1)}})},disabled:!w,children:"Replace All"}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:n,"aria-label":"Close find and replace",children:e(kt,{})})]})]})}function Rn({anchorRef:t,onClose:n,children:o}){const i=l(null);return r(()=>{const e=e=>{const o=e.target;!i.current||i.current.contains(o)||t.current&&t.current.contains(o)||n()},o=e=>{"Escape"===e.key&&n()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",o)}},[t,n]),e("div",{ref:i,className:"lte-overflow-panel",children:e("div",{className:"lte-overflow-grid",children:o})})}function Mn({onAction:n,alignmentSelectionMap:o}){const i=tn.find(e=>o[e.id]),[r,a]=c(!1),s=l(null),d=l(null);return t(kn,{open:r,onOpenChange:a,children:[e(Nn,{triggerRef:s,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(r?"toolbar-active":"toolbar"),onClick:()=>a(e=>!e),style:{minWidth:146},children:[i?.icon,e("span",{children:i?.label}),e(Ot,{className:"chevron "+(r?"rotated":"")})]})}),e(Sn,{open:r,align:"start",onClose:()=>a(!1),contentRef:d,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:tn.map(({id:i,label:l,icon:r})=>t("button",{type:"button",className:"lexical-btn "+(o[i]?"toolbar-active":"toolbar"),onClick:()=>{n(i),a(!1)},children:[r,e("span",{className:"label",children:l})]},i))})})]})}function Dn({color:n,onChange:o,icon:i}){const[a,s]=c(!1),d=l(null),u=l(null);r(()=>{const e=e=>{u.current&&!u.current.contains(e.target)&&d.current&&!d.current.contains(e.target)&&s(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);return t("div",{className:"color-picker-wrapper",children:[e("button",{type:"button",ref:d,className:`size-10 lexical-btn ${a?"toolbarActive":"toolbar"} icon`,onClick:()=>s(e=>!e),children:i}),a&&It(e("div",{ref:u,className:"lexical-color-popover "+(a?"open":""),style:{top:d.current?.getBoundingClientRect().bottom,left:d.current?.getBoundingClientRect().left,position:"absolute"},onMouseDown:e=>e.preventDefault(),children:e(Kt,{color:n,onChangeComplete:e=>{o(e.hex)}})}),document.body)]})}function Fn(){const[o]=Dt(),[{color:i,bgColor:l},a]=c({color:"#000",bgColor:"#fff"}),s=()=>{const e=T();if(M(e)){const t=yn(e,"color","#000"),n=yn(e,"background","#fff");a({color:t,bgColor:n})}};r(()=>wn(o.registerUpdateListener(({editorState:e})=>{e.read(()=>{s()})}),o.registerCommand($,()=>(s(),!1),1)),[o]);const d=({property:e,color:t})=>{o.update(()=>{const n=T();n&&dn(n,{[e]:t})})};return t(n,{children:[e(Dn,{color:i,onChange:e=>{d({property:"color",color:e})},icon:e(yt,{})}),e(Dn,{color:l,onChange:e=>{d({property:"background",color:e})},icon:e(vt,{})})]})}function zn({icon:n,tooltipLabel:o,currentValue:i,options:r,onSelect:a,minWidth:s=132}){const d=r.find(e=>""!==e.id&&e.id===i),[u,h]=c(!1),p=l(null),m=l(null);return t(kn,{open:u,onOpenChange:h,children:[e(Nn,{triggerRef:p,children:t("button",{type:"button","aria-label":o,className:"lexical-btn heading-trigger font-trigger "+(u?"toolbar-active":"toolbar"),style:{minWidth:s},onClick:()=>h(e=>!e),children:[n,e("span",{children:d?.label??"Default"}),e(Ot,{className:"chevron "+(u?"rotated":"")})]})}),e(Sn,{open:u,align:"start",onClose:()=>h(!1),contentRef:m,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:r.map(t=>e("button",{type:"button",className:"lexical-btn "+(""===t.id&&""===i||""!==t.id&&t.id===i?"toolbar-active":"toolbar"),onClick:()=>{a(t.id),h(!1)},children:e("span",{className:"label",children:t.label})},t.label))})})]})}vn&&"InputEvent"in window&&!xn&&new window.InputEvent("input");const Wn=[{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 On(){const[t]=Dt(),[n,o]=c(""),i=()=>{const e=T();if(M(e)){const t=yn(e,"font-family","");o((e=>e.replace(/['"]/g,"").trim())(t))}};r(()=>wn(t.registerUpdateListener(({editorState:e})=>{e.read(()=>{i()})}),t.registerCommand($,()=>(i(),!1),1)),[t]);return e(zn,{icon:e(Rt,{}),tooltipLabel:"Font Family",currentValue:n,options:Wn,onSelect:e=>{t.update(()=>{const t=T();M(t)&&dn(t,{"font-family":""===e?null:e})})}})}const In=[{id:"",label:"Default"},...[12,14,16,18,20,24,28,32,36,48].map(e=>({id:`${e}px`,label:`${e}`}))];function Hn(){const[t]=Dt(),[n,o]=c(""),i=()=>{const e=T();if(M(e)){const t=yn(e,"font-size","");o((e=>e.trim())(t))}};r(()=>wn(t.registerUpdateListener(({editorState:e})=>{e.read(()=>{i()})}),t.registerCommand($,()=>(i(),!1),1)),[t]);return e(zn,{icon:e(Mt,{}),tooltipLabel:"Font Size",currentValue:n,options:In,onSelect:e=>{t.update(()=>{const t=T();M(t)&&dn(t,{"font-size":""===e?null:e})})}})}function Un(){const[n]=Dt(),[o,i]=c(!1),[a,s]=c(null),[d,u]=c(!1),h=l(null),p=l(null),m=()=>{const e=T();if(M(e)){const t=e.anchor.getNode(),n="root"===t.getKey()?t:t.getTopLevelElementOrThrow(),o=b(n);i(o),o&&s(n.getLanguage()??null)}};r(()=>wn(n.registerUpdateListener(({editorState:e})=>{e.read(()=>{m()})}),n.registerCommand($,()=>(m(),!1),1)),[n]);const g=ln.find(e=>e.id===a)?.label??"Plain Text";return t(kn,{open:d,onOpenChange:u,children:[e(Nn,{triggerRef:h,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(o?"toolbar-active":"toolbar"),onClick:()=>u(e=>!e),children:[e(xt,{}),e("span",{children:g}),e(Ot,{className:"chevron "+(d?"rotated":"")})]})}),e(Sn,{open:d,align:"start",onClose:()=>u(!1),contentRef:p,children:t("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[t("button",{type:"button",className:"lexical-btn "+(o?"toolbar-active":"toolbar"),onClick:()=>{n.update(()=>{const e=T();if(!M(e))return;const t=e.anchor.getNode(),n="root"===t.getKey()?t:t.getTopLevelElementOrThrow();if(b(n))hn(e,()=>P());else{const t=a??"javascript";hn(e,()=>y(t))}}),u(!1)},style:{minWidth:150},children:[e(xt,{}),e("span",{className:"label",children:o?"Remove Code Block":"Code Block"})]}),e("div",{className:"w-full h-[1px] bg-gray-200 my-1"}),e("div",{style:{display:"flex",flexDirection:"column",gap:5,maxHeight:260,overflowY:"auto"},children:ln.map(({id:t,label:o})=>e("button",{type:"button",className:"lexical-btn "+(a===t?"toolbar-active":"toolbar"),onClick:()=>{var e;s(e=t),n.update(()=>{const t=T();if(!M(t))return;const n=t.anchor.getNode(),o="root"===n.getKey()?n:n.getTopLevelElementOrThrow();b(o)&&o.setLanguage(e)}),u(!1)},style:{minWidth:150},children:e("span",{className:"label",children:o})},t))})]})})]})}const $n=({content:n,direction:o="top",delay:i=400,children:r})=>{const[a,s]=c(!1),[d,u]=c(null),h=l(null),p=l(null),m=()=>{h.current=window.setTimeout(()=>{const e=p.current;if(e){const t=e.getBoundingClientRect();u({left:t.left,top:t.top,right:t.right,bottom:t.bottom,width:t.width,height:t.height})}s(!0)},i)},g=()=>{h.current&&clearTimeout(h.current),s(!1)};if(!d)return e("div",{ref:p,className:"Lexical-Tooltip-Wrapper",onMouseEnter:m,onMouseLeave:g,children:r});const f=d.left+d.width/2,b=d.top+d.height/2,y="bottom"===o?{top:d.bottom+10,left:f,bottom:"auto"}:"top"===o?{bottom:window.innerHeight-d.top+10,top:"auto",left:f}:"right"===o?{left:d.right+10,right:"auto",top:b}:{left:"auto",right:window.innerWidth-d.left+10,top:b};return t("div",{ref:p,className:"Lexical-Tooltip-Wrapper",onMouseEnter:m,onMouseLeave:g,children:[r,a&&It(e("div",{className:`Lexical-Tooltip-Tip ${o}`,style:{position:"fixed",pointerEvents:"none",...y,zIndex:1e4},children:n}),document.body)]})};function Pn({blockType:o}){const[i]=Dt();r(()=>wn(i.registerCommand(B,e=>{const t=T();if(!M(t))return!1;return!!Cn(t.anchor.getNode(),xe)&&(e.preventDefault(),i.dispatchCommand(e.shiftKey?K:J,void 0),!0)},V)),[i]);return t(n,{children:[e($n,{content:"Ordered list",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${"ol"===o?"toolbarActive":"toolbar"} icon`,onClick:()=>{"ol"===o?i.dispatchCommand(be,void 0):i.dispatchCommand(ye,void 0)},children:e(st,{})})}),e($n,{content:"Unordered list",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${"ul"===o?"toolbarActive":"toolbar"} icon`,onClick:()=>{"ul"===o?i.dispatchCommand(be,void 0):i.dispatchCommand(ve,void 0)},children:e(dt,{})})})]})}function Bn(){const[n]=Dt(),[o,i]=c(!1),[a,s]=c(!1),[d,u]=c(null),h=l(null),p=l(null),m=()=>{const e=T();if(M(e)){const t=Le(e.anchor.getNode());i(!!t)}else i(!1)};r(()=>wn(n.registerUpdateListener(({editorState:e})=>{e.read(()=>{m()})}),n.registerCommand($,()=>(m(),!1),1)),[n]);const g=e=>{n.update(()=>{const t=T();M(t)&&e()}),s(!1)},f=d?`${d.rows} × ${d.cols}`:"Insert Table";return t(kn,{open:a,onOpenChange:s,children:[e(Nn,{triggerRef:h,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(o?"toolbar-active":"toolbar"),onClick:()=>s(e=>!e),children:[e(ut,{}),e(Ot,{className:"chevron "+(a?"rotated":"")})]})}),e(Sn,{open:a,align:"start",onClose:()=>s(!1),contentRef:p,children:t("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t("div",{style:{width:"fit-content"},children:[e("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,r=d&&i<=d.rows&&l<=d.cols;return e("div",{onMouseEnter:()=>u({rows:i,cols:l}),onClick:()=>{return e=i,t=l,n.dispatchCommand(Te,{rows:String(e),columns:String(t),includeHeaders:!1}),void s(!1);var e,t},style:{width:18,height:18,borderRadius:3,border:"1px solid #d1d5db",backgroundColor:r?"#c7d2fe":"#fff",cursor:"pointer"}},o)})}),e("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:f})]}),e("div",{className:"w-full h-[1px] bg-gray-200"}),t("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{Re(!1)}),style:{minWidth:160},children:e("span",{className:"label",children:"Insert row above"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{Re(!0)}),style:{minWidth:160},children:e("span",{className:"label",children:"Insert row below"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{Me()}),style:{minWidth:160},children:e("span",{className:"label",children:"Delete row"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{De(!1)}),style:{minWidth:160},children:e("span",{className:"label",children:"Insert column left"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{De(!0)}),style:{minWidth:160},children:e("span",{className:"label",children:"Insert column right"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{Fe()}),style:{minWidth:160},children:e("span",{className:"label",children:"Delete column"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>{g(()=>{const e=T();if(!M(e))return;const t=Le(e.anchor.getNode());if(!t)return;const n=t.getParent();if(!n)return;const o=n.getChildren().filter(Ee),i=o.some(e=>e.hasHeaderState(Ae.ROW));for(const e of o)e.setHeaderStyles(i?Ae.NO_STATUS:Ae.ROW,Ae.ROW)})},style:{minWidth:160},children:e("span",{className:"label",children:"Toggle header row"})})]})]})})]})}const Kn=({src:n,altText:o,nodeKey:i,width:r,height:a,maxWidth:s,caption:d=""})=>{const[u]=Dt(),[h,p]=c(!1),[m,g]=c(d),f=l(null),b=l(null),y=l(null),v=l(null),x=e=>{if(!v.current||!b.current)return;const t=e.clientX-v.current.x,n=Math.min(s,Math.max(50,v.current.width+t)),o=n*b.current.ratio;b.current.width=n,b.current.height=o;const i=y.current?.querySelector("img");i&&(i.style.width=n+"px",i.style.height=o+"px")},w=()=>{if(!b.current)return;const{width:e,height:t}=b.current;u.update(()=>{const n=U(i);n&&"function"==typeof n.updateDimensions&&n.updateDimensions(e,t)}),b.current=null,v.current=null,window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",w)},C=()=>{p(!1),u.update(()=>{const e=U(i);e&&"function"==typeof e.setCaption&&e.setCaption(m)})},k=()=>{g(d),p(!0),setTimeout(()=>f.current?.focus(),0)};return t("div",{ref:y,style:{display:"inline-block",position:"relative",maxWidth:s},children:[e("img",{src:n,alt:o,width:"inherit"===r?void 0:r,height:"inherit"===a?void 0:a,style:{maxWidth:"100%",display:"block"}}),(d||h)&&e("div",{style:{textAlign:"center",marginTop:4},children:h?e("input",{ref:f,className:"lte-input",style:{width:"100%",textAlign:"center"},value:m,onChange:e=>g(e.target.value),onBlur:C,onKeyDown:e=>{"Enter"===e.key&&C()}}):e("span",{style:{fontSize:13,color:"#666",cursor:"text",display:"inline-block",minWidth:20,minHeight:18},onClick:k,children:d})}),!d&&!h&&e("div",{style:{textAlign:"center",marginTop:2},children:e("span",{style:{fontSize:12,color:"#999",cursor:"pointer"},onClick:k,children:"+ Add caption"})}),e("div",{onMouseDown:e=>{e.preventDefault(),e.stopPropagation();const t=y.current?.querySelector("img");if(!t)return;const n=t.getBoundingClientRect().width,o=t.naturalHeight/t.naturalWidth,i=n*o;v.current={x:e.clientX,y:e.clientY,width:n,height:i},b.current={width:n,height:i,ratio:o},window.addEventListener("mousemove",x),window.addEventListener("mouseup",w)},style:{position:"absolute",bottom:d||h?40:0,right:0,width:14,height:14,background:"white",border:"1px solid #999",cursor:"nwse-resize",borderRadius:2}})]})},Jn=e=>q(new jn(e)),Vn=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:Jn({src:t,altText:n,width:o??"inherit",height:i??"inherit"})}};class jn extends j{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 jn({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:Vn,priority:1}),figure:()=>({conversion:e=>{const t=e.querySelector("img");if(!t)return null;const n=e.querySelector("figcaption"),o=n?.textContent||"",i=Vn(t);return i?.node instanceof jn&&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 jn({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 e(Kn,{src:this.__src,altText:this.__altText,nodeKey:this.getKey(),width:this.__width,height:this.__height,maxWidth:this.__maxWidth,caption:this.__caption})}}function qn({open:n,onClose:o,forPreview:i=!1,children:a}){const c=l(null);return r(()=>{if(!n)return;const e=e=>{c.current&&!c.current.contains(e.target)&&o()},t=e=>{"Escape"===e.key&&o()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[n,o]),n?e("div",{className:"lexical-text-editor-dialog lte-dialog-overlay",children:t("div",{ref:c,className:"lte-dialog "+(i?"preview":""),children:[e("button",{type:"button",className:"lte-dialog-close",onClick:o,children:"×"}),a]})}):null}async function Qn(e,{src:t,altText:n="",caption:o=""}){e.update(()=>{const e=Jn({src:t,altText:n,caption:o});Y([e])})}function Xn({onImageUpload:n}){const[o]=Dt(),i=l(null),[a,d]=c(!1),[u,h]=c(""),[p,m]=c(""),[g,f]=c(""),[b,y]=c(),[v,x]=c(!1),w=s(async(e,t="",i="")=>{let l;l=n?await n(e):URL.createObjectURL(e),Qn(o,{src:l,altText:t,caption:i})},[o,n]);return r(()=>{const e=o.registerCommand(Q,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&&w(t,"","").catch(console.error),!0}}return!1},X);return()=>e()},[o,w]),t("div",{className:"lexical-text-editor-dialog",children:[e("input",{type:"file",ref:i,accept:"image/*",className:"lte-hidden",onChange:e=>{const t=e.target.files?.[0];t&&y(t),e.target.value=""}}),e($n,{content:"Add Image",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${a?"toolbarActive":"toolbar"} icon`,onClick:()=>d(e=>!e),children:e(Nt,{size:18})})}),t(qn,{open:a,onClose:()=>d(!1),children:[e("div",{className:"lte-dialog-header",children:"Add Image"}),t("div",{className:"lte-dialog-body",children:[e("input",{className:"lte-input",placeholder:"Alt text",value:p,onChange:e=>m(e.target.value)}),e("input",{className:"lte-input",placeholder:"Caption",value:g,onChange:e=>f(e.target.value)}),e("input",{className:"lte-input",placeholder:"Add image by URL",value:u,onChange:e=>h(e.target.value)}),e("div",{className:"lte-divider",children:e("span",{children:"or"})}),t("button",{type:"button",className:"lexical-btn heading-trigger toolbar-active",onClick:()=>i.current?.click(),style:{width:"fit-content",margin:"0 auto"},children:[e(Jt,{size:20}),e("span",{children:"Upload Image"})]}),b&&e("div",{className:"lte-file-name",children:b.name})]}),e("div",{className:"lte-dialog-footer",children:e("button",{type:"button",className:"lte-primary-btn",disabled:!u&&!b||v,onClick:async()=>{if(!v){if(b){x(!0);try{await w(b,p,g)}catch(e){return console.error("Image upload failed:",e),void x(!1)}x(!1)}else{if(!u)return;Qn(o,{src:u,altText:p,caption:g})}y(void 0),m(""),f(""),h(""),d(!1)}},children:v?"Uploading...":"Add Image"})})]})]})}const Yn=({id:e,provider:t})=>new io({id:e,provider:t}),Gn="data-lexical-video",Zn="data-provider",eo="315px",to="560px",no=(e,t)=>"drive"===t?`https://drive.google.com/file/d/${e}/preview`:`https://www.youtube-nocookie.com/embed/${e}`,oo=e=>{const t=e?.getAttribute(Gn),n=e?.getAttribute(Zn)??"youtube";if(!t)return null;return{node:Yn({id:t,provider:n})}};class io extends j{constructor({id:e,provider:t,key:n}){super(n),this.__id=e,this.__provider=t}static getType(){return"video"}static clone(e){return new io({id:e.__id,provider:e.__provider,key:e.getKey()})}static importJSON(e){return Yn({id:e.id,provider:e.provider})}exportJSON(){return{id:this.__id,provider:this.__provider,type:"video",version:1}}updateDOM(){return!1}decorate(){return e("iframe",{height:eo,width:to,src:no(this.__id,this.__provider),frameBorder:"0",allowFullScreen:!0})}createDOM(){return document.createElement("div")}exportDOM(){const e=document.createElement("iframe");return e.setAttribute(Gn,this.__id),e.setAttribute(Zn,this.__provider),e.setAttribute("height",eo),e.setAttribute("width",to),e.setAttribute("src",no(this.__id,this.__provider)),{element:e}}static importDOM(){return{iframe:()=>({conversion:oo,priority:0})}}}function lo(){const[n,o]=c(!1),[i,l]=c(!1),[a,s]=c(""),[d]=Dt();return r(()=>{n||(s(""),l(!1))},[n]),t("div",{className:"lexical-text-editor-dialog",children:[e($n,{content:"Embed Video",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${n?"toolbarActive":"toolbar"} icon`,onClick:()=>o(!0),children:e(Vt,{size:18,color:"red"})})}),t(qn,{open:n,onClose:()=>o(!1),children:[e("div",{className:"lte-dialog-header",children:"Embed Video"}),t("div",{className:"lte-dialog-body",children:[e("input",{className:"lte-input",placeholder:"Add YouTube or Google Drive URL",value:a,onChange:e=>s(e.target.value)}),i&&e("p",{className:"lte-error-text",children:"It's not a valid YouTube or Google Drive URL"})]}),e("div",{className:"lte-dialog-footer",children:e("button",{type:"button",className:"lte-primary-btn",disabled:!a,onClick:()=>{if(!a)return;let e=null,t=null;const n=/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/.exec(a);n&&11===n[2]?.length&&(e="youtube",t=n[2]);const i=/drive\.google\.com\/file\/d\/([a-zA-Z0-9_-]+)\//.exec(a);i&&i[1]&&(e="drive",t=i[1]),t&&e?(d.update(()=>{const n=Yn({id:t,provider:e});Y([n])}),s(""),l(!1),o(!1)):l(!0)},children:"Embed"})})]})]})}function ro({value:t}){return e("div",{className:"lexical-text-editor-html-preview",dangerouslySetInnerHTML:{__html:t}})}function ao({value:n,triggerLabel:o="Preview"}){const[i,l]=c(!1);return t("div",{className:"lexical-text-editor-dialog",children:[e($n,{content:o,direction:"bottom",children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(i?"toolbar-active":"toolbar"),onClick:()=>l(e=>!e),children:[e(jt,{size:18}),e("span",{children:o})]})}),t(qn,{open:i,onClose:()=>l(!1),forPreview:!0,children:[e("div",{className:"lte-dialog-header",children:"Content Preview"}),t("div",{className:"lte-preview-container",children:[e("div",{className:"lte-preview-title",children:"CONTENT"}),e(ro,{value:n})]})]})]})}const co=[{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"}];co.filter(e=>!e.primary).map(e=>e.id);const so=["textFormats","lists","primaryAlignment","primaryLink","fontFamily","fontSize","color","dropdown","codeBlock","blockOptions","image","video","table","utility","preview"],uo=({value:o,onImageUpload:i,sourceView:a=!1,onToggleSourceView:d,fullscreen:g=!1,onToggleFullscreen:f,toolbarStyle:b="wrap"})=>{const y="normal"===b?"collapse":b,[v]=Dt(),[x,w]=c({[Xt.Undo]:!0,[Xt.Redo]:!0}),[C,k]=c(!1),[N,S]=c(!1),[_,E]=c(0),[A,R]=c(!1),F=l(null),z=l(null),W=l(null),O=l({}),I=l({}),H=l(0),U=l(null),B=l(null),[V,j]=c({[Xt.LeftAlign]:!0}),[q,Q]=c({[Yt.Normal]:!0}),[X,Y]=c("paragraph"),[ie,le]=c("https://");let re=!0;const ae=()=>{if(re){const e=v.getRootElement();e&&(e.scrollTop=0,re=!1)}const e=T();if(M(e)){const t={[Xt.Bold]:e.hasFormat("bold"),[Xt.Italics]:e.hasFormat("italic"),[Xt.Underline]:e.hasFormat("underline"),[Xt.Uppercase]:e.hasFormat("uppercase"),[Xt.Lowercase]:e.hasFormat("lowercase"),[Xt.Capitalize]:e.hasFormat("capitalize"),[Xt.Strikethrough]:e.hasFormat("strikethrough"),[Xt.Superscript]:e.hasFormat("superscript"),[Xt.Subscript]:e.hasFormat("subscript"),[Xt.Code]:e.hasFormat("code"),[Xt.Highlight]:e.hasFormat("highlight")};j(t);const n=e.anchor.getNode(),o="root"===n.getKey()?n:n.getTopLevelElementOrThrow(),i=o.getKey();if(!v.getElementByKey(i))return;if(we(o)){const e=Cn(n,xe),t=e?e.getTag():o.getTag();Y(t)}else if("paragraph"===o.getType()||u(o)){let e=null;u(o)&&(e=o.getTag());const t={[Yt.H1]:"h1"===e,[Yt.H2]:"h2"===e,[Yt.H3]:"h3"===e,[Yt.H4]:"h4"===e,[Yt.H5]:"h5"===e,[Yt.H6]:"h6"===e,[Yt.Normal]:"paragraph"===o.getType()};Y(o.getType()),Q(t)}else Y(o.getType());const l=(L(n)?n:o).getFormat();j(e=>({...e,[Xt.LeftAlign]:0===l||1===l,[Xt.CenterAlign]:2===l,[Xt.RightAlign]:3===l,[Xt.JustifyAlign]:4===l})),"quote"===o.getType()?j(e=>({...e,[Xt.Quote]:!0})):j(e=>({...e,[Xt.Quote]:!1}));const r=e.anchor.getNode(),a=r.getParent();zt(a)?(j(e=>({...e,[Xt.Link]:!0})),le(a.getURL()),k(!0)):zt(r)?(j(e=>({...e,[Xt.Link]:!0})),le(r.getURL()),k(!0)):(j(e=>({...e,[Xt.Link]:!1})),le("https://"),k(!1))}};r(()=>wn(v.registerUpdateListener(({editorState:e})=>{e.read(()=>{ae()})}),v.registerCommand($,()=>(ae(),!1),1),v.registerCommand(Z,e=>(w(t=>({...t,undo:!e})),!1),1),v.registerCommand(G,e=>(w(t=>({...t,redo:!e})),!1),1)),[]);const ce="scrollbar"===y,se=s(()=>{if("collapse"!==y)return;const e=F.current;if(!e)return;const t=e.clientWidth;if(t<=0)return;const n=z.current?z.current.offsetWidth:0,o=so.map(e=>{const t=O.current[e];return t&&"none"!==t.style.display&&(I.current[e]=t.offsetWidth),I.current[e]??0});W.current&&(H.current=W.current.offsetWidth);const i=H.current||40,l=e=>{const t=1+(e>0?1:0)+(so.length-e);let l=n+6*Math.max(0,t-1)+(e>0?i:0);for(let t=0;t<so.length-e;t++)l+=o[t];return l};let r=_;for(;r<so.length&&l(r)>t;)r++;for(;r>0&&l(r-1)<=t;)r--;E(e=>e===r?e:r)},[_,y]);r(()=>{se()});const de=l(()=>{});de.current=se,r(()=>{if("undefined"==typeof ResizeObserver)return;const e=F.current;if(!e)return;const t=new ResizeObserver(()=>{de.current(),fe.current()});return t.observe(e),()=>t.disconnect()},[]),r(()=>{0===_&&R(!1)},[_]),r(()=>{"collapse"!==y&&E(0)},[y]);const ue=s(()=>{if("scrollbar"!==y)return;const e=F.current,t=U.current,n=B.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,a=l>0?e.scrollLeft/l*r:0;n.style.width=`${i}px`,n.style.transform=`translateX(${a}px)`},[b]),he=s(e=>{e.stopPropagation(),e.preventDefault();const t=F.current,n=B.current;if(!t||!n)return;const o=e.clientX,i=t.scrollLeft,l=t.clientWidth,r=Math.max(24,l/t.scrollWidth*l),a=t.scrollWidth-l,c=l-r,s=e=>{const n=e.clientX-o;t.scrollLeft=c>0?i+n/c*a:0},d=()=>{document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",d)};document.addEventListener("pointermove",s),document.addEventListener("pointerup",d)},[]),pe=s(e=>{const t=F.current,n=U.current;if(!t||!n)return;const o=n.getBoundingClientRect(),i=(e.clientX-o.left)/o.width;t.scrollLeft=i*t.scrollWidth-t.clientWidth/2},[]),me=l(null),ge=s(()=>{const e=me.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 a=Math.min(22,Math.max(17,15/r));parseFloat(e.style.width)!==a&&(e.style.width=`${a}px`,e.style.height=`${a}px`)}catch{}}},[]);r(()=>{ge()}),r(()=>{ue()});const fe=l(()=>{});fe.current=ue,r(()=>{if("scrollbar"!==y)return;const e=F.current;if(!e)return;const t=()=>ue();return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)},[y,ue]);const be=e=>{switch(e){case Xt.Bold:v.dispatchCommand(oe,"bold");break;case Xt.Italics:v.dispatchCommand(oe,"italic");break;case Xt.Underline:v.dispatchCommand(oe,"underline");break;case Xt.Lowercase:v.dispatchCommand(oe,"lowercase");break;case Xt.Uppercase:v.dispatchCommand(oe,"uppercase");break;case Xt.Capitalize:v.dispatchCommand(oe,"capitalize");break;case Xt.Strikethrough:v.dispatchCommand(oe,"strikethrough");break;case Xt.Superscript:v.dispatchCommand(oe,"superscript");break;case Xt.Subscript:v.dispatchCommand(oe,"subscript");break;case Xt.Highlight:v.dispatchCommand(oe,"highlight");break;case Xt.Code:v.dispatchCommand(oe,"code");break;case Xt.Quote:v.update(()=>{const e=T();if(M(e)){const t=e.anchor.getNode().getParent();t&&h(t)?hn(e,()=>P()):gn(e,()=>p())}});break;case Xt.Link:ye(),k(!0);break;case Xt.LeftAlign:v.dispatchCommand(ne,"left");break;case Xt.RightAlign:v.dispatchCommand(ne,"right");break;case Xt.CenterAlign:v.dispatchCommand(ne,"center");break;case Xt.JustifyAlign:v.dispatchCommand(ne,"justify");break;case Xt.Undo:v.dispatchCommand(te,void 0);break;case Xt.Redo:v.dispatchCommand(ee,void 0);break;case Xt.ClearFormatting:v.update(()=>{const e=T();if(!M(e))return;const t=e.getNodes().filter(D);for(const e of t)e.setFormat(0),e.setStyle("")});break;case Xt.HorizontalRule:v.dispatchCommand(ke,void 0);break;case Xt.Indent:v.dispatchCommand(J,void 0);break;case Xt.Outdent:v.dispatchCommand(K,void 0)}},ye=s(()=>{v.update(()=>{const e=T();M(e)&&!e.isCollapsed()&&(C?v.dispatchCommand(Ft,null):""!==ie&&v.dispatchCommand(Ft,ie))})},[v,C,ie]),ve=s(()=>{le(""),v.dispatchCommand(Ft,null),k(!1)},[v]),Ce=e=>so.indexOf(e)>=so.length-_,Ne={textFormats:e(n,{children:Zt.map(({id:t,label:n,icon:o})=>t===Xt.Divider?e(Ln,{},t):e($n,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${V[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>be(t),children:o})},t))}),primaryAlignment:t(n,{children:[e(Mn,{onAction:be,alignmentSelectionMap:V}),e(Ln,{})]}),primaryLink:e($n,{content:"Link",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${V[Xt.Link]?"toolbarActive":"toolbar"} icon`,onClick:()=>be(Xt.Link),disabled:!!x[Xt.Link],children:e(Ht,{})})}),lists:t(n,{children:[e(Pn,{blockType:X}),e(Ln,{})]}),blockOptions:e(n,{children:nn.map(({id:t,label:n,icon:o})=>t===Xt.Divider?e(Ln,{},t):e($n,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${V[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>be(t),children:o})},t))}),fontFamily:e(On,{}),fontSize:e(Hn,{}),color:e(Fn,{}),codeBlock:e(Un,{}),dropdown:e(_n,{onAction:be,selectionMap:V}),image:e(Xn,{onImageUpload:i}),video:e(lo,{}),table:e(Bn,{}),utility:t(n,{children:[e(Ln,{}),e($n,{content:"Find & Replace",direction:"bottom",children:e("button",{type:"button","aria-label":"Find & Replace",className:`size-10 lexical-btn ${N?"toolbarActive":"toolbar"} icon`,onClick:()=>S(e=>!e),children:e(St,{})})}),e($n,{content:"Source Code View",direction:"bottom",children:e("button",{type:"button","aria-label":"Source Code View",className:`size-10 lexical-btn ${a?"toolbarActive":"toolbar"} icon`,onClick:()=>d?.(),children:e(_t,{})})}),e($n,{content:g?"Exit Fullscreen":"Fullscreen",direction:"bottom",children:e("button",{type:"button","aria-label":g?"Exit Fullscreen":"Fullscreen",className:`size-10 lexical-btn ${g?"toolbarActive":"toolbar"} icon`,onClick:()=>f?.(),children:e(g?ht:pt,{})})})]}),preview:e(ao,{value:o})};return t("div",{ref:me,className:"lexical-toolbar-wrapper",style:{position:"relative",padding:12,marginBottom:4,borderBottom:"1px solid #e5e7eb"},children:[t("div",{ref:F,className:"lte-toolbar-row "+(ce?"useScroll":"collapse"===y?"lte-nowrap":"lte-wrap"),children:[t("div",{ref:z,className:"lte-toolbar-primary",style:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:[en.map(({id:t,label:n,icon:o})=>t===Xt.Divider?e(Ln,{},t):e($n,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${V[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>be(t),disabled:!!x[t],children:o})},n)),t("div",{style:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:[e(Tn,{updateHeading:e=>{v.update(()=>{const t=T();M(t)&&gn(t,"normal"===e?()=>P():()=>m(e))})},headingSelectionMap:q}),e(Ln,{})]})]}),co.map(({id:t})=>{const n=Ce(t);return e("div",{ref:e=>{O.current[t]=e},style:n?{display:"none"}:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:n?null:Ne[t]},t)}),_>0&&e($n,{content:"More tools",direction:"bottom",children:e("button",{type:"button",ref:W,"aria-label":"More tools",className:`size-10 lexical-btn ${A?"toolbarActive":"toolbar"} icon`,onClick:()=>R(e=>!e),children:e(mt,{})})})]}),ce&&e("div",{ref:U,className:"lte-custom-scrollbar",onPointerDown:pe,"aria-hidden":"true",children:e("div",{ref:B,className:"lte-custom-scrollbar-thumb",onPointerDown:he})}),C&&e(En,{linkUrl:ie,setLinkUrl:le,removeLink:ve,onConfirm:e=>{v.dispatchCommand(Ft,{url:e,target:"_blank"}),le(e),k(!1)},onCancel:()=>{le(""),k(!1)}}),A&&e(Rn,{anchorRef:W,onClose:()=>R(!1),children:co.map(({id:e})=>e).filter(e=>Ce(e)&&Ne[e]).map(t=>e("div",{className:"lte-overflow-item",children:Ne[t]},t))}),N&&e(An,{onClose:()=>S(!1)})]})};function ho(e,t){const n=ie(t)?t.body.childNodes:t.childNodes;let o=[];const i=[];for(const t of n)if(!go.has(t.nodeName)){const n=fo(t,e,i,!1);null!==n&&(o=o.concat(n))}return function(e){for(const t of e)t.getNextSibling()instanceof le&&t.insertAfter(re());for(const t of e){const e=t.getChildren();for(const n of e)t.insertBefore(n);t.remove()}}(i),o}function po(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=H().getChildren();for(let i=0;i<o.length;i++)mo(e,o[i],n,t);return n.innerHTML}function mo(e,t,n,o=null){let i=null===o||t.isSelected(o);const l=L(t)&&t.excludeFromCopy("html");let r=t;if(null!==o){let e=ae(t);e=D(e)&&null!==o?function(e,t){const n=e.getStartEndPoints();if(t.isSelected(e)&&!F(t)&&null!==n){const[o,i]=n,l=e.isBackward(),r=o.getNode(),a=i.getNode(),c=t.is(r),s=t.is(a);if(c||s){const[n,o]=z(e),i=r.is(a),c=t.is(l?a:r),s=t.is(l?r:a);let d,u=0;i?(u=n>o?o:n,d=n>o?n:o):c?(u=l?o:n,d=void 0):s&&(u=0,d=l?n:o),t.__text=t.__text.slice(u,d)}}return t}(o,e):e,r=e}const a=L(r)?r.getChildren():[],c=ce(e,r.getType());let s;s=c&&void 0!==c.exportDOM?c.exportDOM(e,r):r.exportDOM(e);const{element:d,after:u}=s;if(!d)return!1;const h=document.createDocumentFragment();for(let n=0;n<a.length;n++){const l=a[n],r=mo(e,l,h,o);!i&&L(t)&&r&&t.extractWithChild(l,o,"html")&&(i=!0)}if(i&&!l){if((se(d)||de(d))&&d.append(h),n.append(d),u){const e=u.call(r,d);e&&(de(d)?d.replaceChildren(e):d.replaceWith(e))}}else n.append(h);return i}const go=new Set(["STYLE","SCRIPT"]);function fo(e,t,n,o,i=new Map,l){let r=[];if(go.has(e.nodeName))return r;let a=null;const c=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),s=c?c(e):null;let d=null;if(null!==s){d=s.after;const t=s.node;if(a=Array.isArray(t)?t[t.length-1]:t,null!==a){for(const[,e]of i)if(a=e(a,l),!a)break;a&&r.push(...Array.isArray(t)?t:[a])}null!=s.forChild&&i.set(e.nodeName,s.forChild)}const u=e.childNodes;let h=[];const p=(null==a||!A(a))&&(null!=a&&ue(a)||o);for(let e=0;e<u.length;e++)h.push(...fo(u[e],t,n,p,new Map(i),a));return null!=d&&(h=d(h)),he(e)&&(h=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(ue(r))o&&!r.getFormat()&&r.setFormat(o),i.push(r);else if(l.push(r),e===t.length-1||e<t.length-1&&ue(t[e+1])){const e=n();e.setFormat(o),e.append(...l),i.push(e),l=[]}}return i}(e,h,p?()=>{const e=new le;return n.push(e),e}:P)),null==a?h.length>0?r=r.concat(h):he(e)&&function(e){return null!=e.nextSibling&&null!=e.previousSibling&&(pe(e.nextSibling)&&pe(e.previousSibling))}(e)&&(r=r.concat(re())):L(a)&&a.append(...h),r}function bo({value:t,onChange:n}){const[o]=Dt(),[i,l]=c(!0);return r(()=>{t&&i&&(l(!1),o.update(()=>{if(po(o)!==t){H().clear();const e=(new DOMParser).parseFromString(t,"text/html"),n=ho(o,e);Y(n)}}))},[o,t,i]),r(()=>{l(!0)},[t]),e(Qt,{onChange:e=>{e.read(()=>{n(po(o))})}})}function yo({applyRef:n,onExit:o}){const[i]=Dt(),[a,s]=c(()=>i.getEditorState().read(()=>po(i))),d=l(a),u=e=>{e!==d.current&&(i.update(()=>{const t=H();if(t.clear(),t.selectEnd(),e){const t=(new DOMParser).parseFromString(e,"text/html"),n=ho(i,t);n.length>0&&Y(n)}}),d.current=e)};return r(()=>(n.current=()=>{u(a),o()},()=>{n.current=null}),[n,a,o,i]),t("div",{className:"lexical-source-view",children:[e("textarea",{className:"lexical-source-textarea",value:a,onChange:e=>s(e.target.value),"aria-label":"HTML source",spellCheck:!1}),t("div",{className:"lexical-source-actions",children:[e($n,{content:"Apply HTML to the editor",direction:"top",children:t("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>u(a),children:[e(Ut,{size:16}),e("span",{className:"label",children:"Update"})]})}),e("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>{u(a),o()},children:"Done"})]})]})}function vo({showWordCount:n=!0,showCharCount:o=!0,rightSlot:i}){const[l]=Dt(),[a,s]=c({words:0,chars:0});return r(()=>{const e=e=>{e.read(()=>{const e=H().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]),t("div",{className:"lexical-status-bar",children:[n&&t("span",{children:[a.words," words"]}),o&&t("span",{children:[a.chars," characters"]}),i&&e("div",{className:"lexical-status-bar-right",children:i})]})}function xo({theme:n,toolbarStyle:o,onThemeChange:i,onToolbarStyleChange:l}){const r="normal"===o?"collapse":o,a=[{value:"light",label:"Light theme",icon:e(gt,{})},{value:"dark",label:"Dark theme",icon:e(ft,{})},{value:"system",label:"Follow system theme",icon:e($t,{})}],c=[{value:"wrap",label:"Toolbar: wrap to new lines",icon:e(Pt,{})},{value:"collapse",label:'Toolbar: collapse into "..."',icon:e(mt,{})},{value:"scrollbar",label:"Toolbar: scroll in one row",icon:e(Je,{})}];return t("div",{className:"lexical-display-controls",role:"group","aria-label":"Display settings",children:[e("div",{className:"lte-mini-seg",role:"radiogroup","aria-label":"Theme",children:a.map(t=>e($n,{content:t.label,direction:"top",children:e("button",{type:"button",role:"radio","aria-checked":n===t.value,"aria-label":t.label,className:"lte-mini-btn btn "+(n===t.value?"active":""),onClick:()=>i?.(t.value),children:t.icon})},t.value))}),e("div",{className:"lte-mini-seg",role:"radiogroup","aria-label":"Toolbar style",children:c.map(t=>e($n,{content:t.label,direction:"top",children:e("button",{type:"button",role:"radio","aria-checked":r===t.value,"aria-label":t.label,className:"lte-mini-btn btn "+(r===t.value?"active":""),onClick:()=>l?.(t.value),children:t.icon})},t.value))})]})}const wo=({id:e})=>new Lo({id:e}),Co="data-lexical-youtube",ko="315px",No="560px",So=e=>`https://www.youtube-nocookie.com/embed/${e}`,_o=e=>{const t=e?.getAttribute(Co);if(!t)return null;return{node:wo({id:t})}};class Lo extends j{constructor({id:e,key:t}){super(t),this.__id=e}static getType(){return"youtube"}static clone(e){return new Lo({id:e.__id,key:e.getKey()})}static importJSON(e){return wo({id:e.id})}exportJSON(){return{id:this.__id,type:"youtube",version:1}}decorate(){return e("iframe",{height:ko,width:No,src:So(this.__id),frameBorder:"0",allowFullScreen:!0})}createDOM(){return document.createElement("div")}exportDOM(){const e=document.createElement("iframe");return e.setAttribute(Co,this.__id),e.setAttribute("height",ko),e.setAttribute("width",No),e.setAttribute("src",So(this.__id)),{element:e}}static importDOM(){return{iframe:()=>({conversion:_o,priority:0})}}}class To extends me{constructor(e,t){super(e,t)}static getType(){return"extended-text"}static clone(e){return new To(e.__text,e.__key)}static importDOM(){const e=me.importDOM();return{...e,span:()=>({conversion:Eo(e?.span),priority:1}),div:()=>({conversion:Eo(e?.div),priority:1}),p:()=>({conversion:Eo(e?.p),priority:1}),b:()=>({conversion:Eo(e?.b),priority:1}),strong:()=>({conversion:Eo(e?.strong),priority:1}),i:()=>({conversion:Eo(e?.i),priority:1}),em:()=>({conversion:Eo(e?.em),priority:1}),u:()=>({conversion:Eo(e?.u),priority:1}),s:()=>({conversion:Eo(e?.s),priority:1}),strike:()=>({conversion:Eo(e?.strike),priority:1}),code:()=>({conversion:Eo(e?.code),priority:1})}}static importJSON(e){return function(e=""){return q(new To(e))}().updateFromJSON(e)}isSimpleText(){return"extended-text"===this.__type&&0===this.__mode}}function Eo(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(i)&&l.length>0){const e=l.join("; ");return i.setStyle(e)}return i}}}}const Ao={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"}},Ro=i.memo(function({name:n,value:i,onChange:a,placeholder:s,maxWidth:u=null,height:h=null,onImageUpload:p,showWordCount:m=!0,showCharCount:b=!0,theme:y="system",toolbarStyle:N="collapse",showDisplayControls:S=!0,onThemeChange:_,onToolbarStyleChange:L}){const[T,E]=c(!1),[A,R]=c(!1),M=l(null),[D,F]=c(!1),[z,W]=c(y),[O,I]=c("normal"===N?"collapse":N);r(()=>{W(y)},[y]),r(()=>{I("normal"===N?"collapse":N)},[N]),r(()=>{if("system"!==z||"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))},[z]);const H="dark"===z||"system"===z&&D;r(()=>{if(!A)return;const e=e=>{"Escape"===e.key&&R(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[A]);const U=d(()=>({namespace:n,theme:Ao,onError:e=>{console.error("Lexical error:",e)},nodes:[To,{replace:me,with:e=>new To(e.__text),withKlass:To},g,v,x,xe,Ce,f,Wt,jn,Lo,io,Ne,ze,We,Oe]}),[n]);return e("div",{className:`lexical-text-editor lexical-editor-container ${A?"lexical-fullscreen":""} ${H?"lexical-dark":""}`,style:{maxWidth:A?"none":u||"1090px"},children:t(o,{initialConfig:U,children:[e("div",{className:"lexical-toolbar-container",children:e(uo,{value:i,onImageUpload:p,sourceView:T,onToggleSourceView:()=>{E(e=>!e||(M.current?.(),!1))},fullscreen:A,onToggleFullscreen:()=>{R(e=>!e)},toolbarStyle:O})}),e("div",{className:"lexical-editor-inner",style:T?{display:"none"}:void 0,children:e(w,{contentEditable:e(C,{className:"lexical-content-editable",style:{height:h||"500px"}}),placeholder:e("div",{className:"lexical-placeholder",children:s||"Some Text"}),ErrorBoundary:k})}),T&&e(yo,{applyRef:M,onExit:()=>E(!1)}),(m||b||S)&&e(vo,{showWordCount:m,showCharCount:b,rightSlot:S?e(xo,{theme:z,toolbarStyle:O,onThemeChange:e=>{W(e),_?.(e)},onToolbarStyleChange:e=>{I(e),L?.(e)}}):void 0}),e(ge,{}),e(fe,{}),e(_e,{}),e(Se,{}),e(qt,{}),e(bo,{value:i,onChange:a})]})})});export{Ro as LexicalTextEditor};
|
|
1
|
+
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{LexicalComposer as o}from"@lexical/react/LexicalComposer";import i,{createContext as l,useContext as r,useRef as a,useEffect as c,cloneElement as s,useState as d,useCallback as u,useMemo as h}from"react";import{$isHeadingNode as p,$isQuoteNode as m,$createQuoteNode as g,$createHeadingNode as f,HeadingNode as b,QuoteNode as y}from"@lexical/rich-text";import{$isCodeNode as v,$createCodeNode as x,CodeHighlightNode as w,CodeNode as C}from"@lexical/code";import{RichTextPlugin as k}from"@lexical/react/LexicalRichTextPlugin";import{ContentEditable as N}from"@lexical/react/LexicalContentEditable";import{LexicalErrorBoundary as S}from"@lexical/react/LexicalErrorBoundary";import{$createRangeSelection as _,$findMatchingParent as L,INTERNAL_$isBlock as T,$isElementNode as E,$getSelection as A,$setSelection as F,$isRootOrShadowRoot as D,$hasAncestor as M,$isRangeSelection as z,$isTextNode as R,$isTokenOrSegmented as W,$getCharacterOffsets as O,$isLeafNode as I,$getPreviousSelection as H,$caretRangeFromSelection as U,$getRoot as P,$getNodeByKey as $,SELECTION_CHANGE_COMMAND as K,$createParagraphNode as B,KEY_TAB_COMMAND as J,OUTDENT_CONTENT_COMMAND as q,INDENT_CONTENT_COMMAND as V,COMMAND_PRIORITY_EDITOR as j,DecoratorNode as Q,$applyNodeReplacement as X,PASTE_COMMAND as Y,COMMAND_PRIORITY_LOW as G,$insertNodes as Z,CAN_REDO_COMMAND as ee,CAN_UNDO_COMMAND as te,REDO_COMMAND as ne,UNDO_COMMAND as oe,FORMAT_ELEMENT_COMMAND as ie,FORMAT_TEXT_COMMAND as le,KEY_DOWN_COMMAND as re,COMMAND_PRIORITY_HIGH as ae,KEY_ENTER_COMMAND as ce,isDOMDocumentNode as se,ArtificialNode__DO_NOT_USE as de,$createLineBreakNode as ue,$cloneWithProperties as he,getRegisteredNode as pe,isHTMLElement as me,isDocumentFragment as ge,$isBlockElementNode as fe,isBlockDomNode as be,isInlineDomNode as ye,TextNode as ve}from"lexical";import{HistoryPlugin as xe}from"@lexical/react/LexicalHistoryPlugin";import{ListPlugin as we}from"@lexical/react/LexicalListPlugin";import{REMOVE_LIST_COMMAND as Ce,INSERT_ORDERED_LIST_COMMAND as ke,INSERT_UNORDERED_LIST_COMMAND as Ne,ListNode as Se,$isListNode as _e,ListItemNode as Le}from"@lexical/list";import{INSERT_HORIZONTAL_RULE_COMMAND as Te,HorizontalRuleNode as Ee}from"@lexical/react/LexicalHorizontalRuleNode";import{HorizontalRulePlugin as Ae}from"@lexical/react/LexicalHorizontalRulePlugin";import{TablePlugin as Fe}from"@lexical/react/LexicalTablePlugin";import{$findCellNode as De,INSERT_TABLE_COMMAND as Me,$isTableCellNode as ze,TableCellHeaderStates as Re,$insertTableRowAtSelection as We,$deleteTableRowAtSelection as Oe,$insertTableColumnAtSelection as Ie,$deleteTableColumnAtSelection as He,TableNode as Ue,TableRowNode as Pe,TableCellNode as $e}from"@lexical/table";import{RxLetterCaseLowercase as Ke,RxLetterCaseUppercase as Be,RxLetterCaseCapitalize as Je}from"react-icons/rx";import{TbBold as qe,TbItalic as Ve,TbUnderline as je,TbSeparatorHorizontal as Qe,TbArrowsLeftRight as Xe}from"react-icons/tb";import{BsSuperscript as Ye,BsSubscript as Ge,BsChatSquareQuote as Ze,BsArrowCounterclockwise as et,BsArrowClockwise as tt,BsJustifyLeft as nt,BsTextCenter as ot,BsJustifyRight as it,BsJustify as lt,BsTextParagraph as rt,BsTypeH1 as at,BsTypeH2 as ct,BsTypeH3 as st,BsTypeH4 as dt,BsTypeH5 as ut,BsTypeH6 as ht,BsPencilSquare as pt,BsFonts as mt,BsListOl as gt,BsListUl as ft,BsTable as bt,BsFullscreenExit as yt,BsFullscreen as vt,BsThreeDots as xt,BsSun as wt,BsMoon as Ct}from"react-icons/bs";import{AiOutlineStrikethrough as kt,AiOutlineFontColors as Nt,AiOutlineBgColors as St}from"react-icons/ai";import{IoCodeSlashOutline as _t,IoChevronUp as Lt,IoChevronDown as Tt,IoClose as Et,IoImageOutline as At,IoSearchOutline as Ft,IoCodeOutline as Dt}from"react-icons/io5";import{PiHighlighterLight as Mt}from"react-icons/pi";import{RiEraserLine as zt,RiIndentIncrease as Rt,RiIndentDecrease as Wt}from"react-icons/ri";import{useLexicalComposerContext as Ot}from"@lexical/react/LexicalComposerContext";import{TOGGLE_LINK_COMMAND as It,$isLinkNode as Ht,LinkNode as Ut}from"@lexical/link";import{HiChevronDown as Pt}from"react-icons/hi2";import{createPortal as $t}from"react-dom";import{IoIosLink as Kt}from"react-icons/io";import{MdCheck as Bt,MdMonitor as Jt,MdWrapText as qt}from"react-icons/md";import{BiUnlink as Vt}from"react-icons/bi";import{SketchPicker as jt}from"react-color";import{LuMinus as Qt,LuPlus as Xt,LuUpload as Yt}from"react-icons/lu";import{FaYoutube as Gt}from"react-icons/fa";import{VscPreview as Zt}from"react-icons/vsc";import{LinkPlugin as en}from"@lexical/react/LexicalLinkPlugin";import{OnChangePlugin as tn}from"@lexical/react/LexicalOnChangePlugin";var nn,on;!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"}(nn||(nn={})),function(e){e.Normal="normal",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6"}(on||(on={}));const ln=[{id:nn.Lowercase,icon:e(Ke,{}),label:"Lowercase"},{id:nn.Uppercase,icon:e(Be,{}),label:"Uppercase"},{id:nn.Capitalize,icon:e(Je,{}),label:"Capitalize"},{id:nn.Superscript,icon:e(Ye,{}),label:"Superscript"},{id:nn.Subscript,icon:e(Ge,{}),label:"Subscript"}],rn=[{id:nn.Bold,icon:e(qe,{}),label:"Bold"},{id:nn.Italics,icon:e(Ve,{}),label:"Italics"},{id:nn.Underline,icon:e(je,{}),label:"Underline"},{id:nn.Strikethrough,icon:e(kt,{}),label:"Strikethrough"}],an=[{id:nn.Highlight,icon:e(Mt,{}),label:"Highlight"}],cn=[{id:nn.Quote,icon:e(Ze,{}),label:"Quote"},{id:nn.Code,icon:e(_t,{}),label:"Code"}],sn=[{id:nn.Undo,icon:e(et,{}),label:"Undo"},{id:nn.Redo,icon:e(tt,{}),label:"Redo"},{id:nn.ClearFormatting,icon:e(zt,{}),label:"Clear Formatting"}],dn=[{id:nn.Indent,icon:e(Rt,{}),label:"Indent"},{id:nn.Outdent,icon:e(Wt,{}),label:"Outdent"}],un=[{id:nn.HorizontalRule,icon:e(Qe,{}),label:"Horizontal Rule"}],hn=[{id:nn.LeftAlign,icon:e(nt,{}),label:"Left Align"},{id:nn.CenterAlign,icon:e(ot,{}),label:"Center Align"},{id:nn.RightAlign,icon:e(it,{}),label:"Right Align"},{id:nn.JustifyAlign,icon:e(lt,{}),label:"Justify Align"}],pn=[{id:"normal",label:"Normal",icon:e(rt,{})},{id:"h1",label:"Heading 1",icon:e(at,{})},{id:"h2",label:"Heading 2",icon:e(ct,{})},{id:"h3",label:"Heading 3",icon:e(st,{})},{id:"h4",label:"Heading 4",icon:e(dt,{})},{id:"h5",label:"Heading 5",icon:e(ut,{})},{id:"h6",label:"Heading 6",icon:e(ht,{})}],mn=[{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"}],gn=l(()=>{});function fn(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 bn=new Map;function yn(e){let t=bn.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),bn.set(e,t)),t}function vn(e,t){(z(e)?e.isCollapsed():R(e)||E(e))||fn(280);const n=yn(z(e)?e.style:R(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);z(e)||R(e)?e.setStyle(i):e.setTextStyle(i),bn.set(i,o)}function xn(e,t){if(z(e)&&e.isCollapsed()){vn(e,t);const n=e.anchor.getNode();E(n)&&n.isEmpty()&&vn(n,t)}!function(e){const t=A();if(!t)return;const n=new Map,o=e=>n.get(e.getKey())||[0,e.getTextContentSize()];if(z(t))for(const e of U(t).getTextSlices())e&&n.set(e.caret.origin.getKey(),e.getSliceIndices());const i=t.getNodes();for(const t of i){if(!R(t)||!t.canHaveFormat())continue;const[n,i]=o(t);i!==n&&(W(t)||0===n&&i===t.getTextContentSize()?e(t):e(t.splitText(n,i)[0===n?0:1]))}z(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=>{vn(e,t)})}function wn(e,t){const n=e.getFormatType(),o=e.getIndent();n!==t.getFormatType()&&t.setFormat(n),o!==t.getIndent()&&t.setIndent(o)}function Cn(e,t,n=wn){if(null===e)return;const o=e.getStartEndPoints(),i=new Map;let l=null;if(o){const[e,t]=o;l=_(),l.anchor.set(e.key,e.offset,e.type),l.focus.set(t.key,t.offset,t.type);const n=L(e.getNode(),T),r=L(t.getNode(),T);E(n)&&i.set(n.getKey(),n),E(r)&&i.set(r.getKey(),r)}for(const t of e.getNodes())if(E(t)&&T(t))i.set(t.getKey(),t);else if(null===o){const e=L(t,T);E(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(A())&&F(l)}function kn(e){return e.getNode().isAttached()}function Nn(e){let t=e;for(;null!==t&&!D(t);){const e=t.getLatest(),n=t.getParent();0===e.getChildrenSize()&&t.remove(!0),t=n}}function Sn(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 a=null,c=[];for(let o=0;o<r;o++){const i=l[o];D(i)?(_n(e,c,c.length,t,n),c=[],a=i):null===a||null!==a&&M(i,a)?c.push(i):(_n(e,c,c.length,t,n),c=[i])}_n(e,c,c.length,t,n)}function _n(e,t,n,o,i=null){if(0===t.length)return;const l=t[0],r=new Map,a=[];let c=E(l)?l:l.getParentOrThrow();c.isInline()&&(c=c.getParentOrThrow());let s=!1;for(;null!==c;){const e=c.getPreviousSibling();if(null!==e){c=e,s=!0;break}if(c=c.getParentOrThrow(),D(c))break}const d=new Set;for(let e=0;e<n;e++){const n=t[e];E(n)&&0===n.getChildrenSize()&&d.add(n.getKey())}const u=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&&I(n)&&!u.has(n.getKey())){const e=i.getKey();if(void 0===r.get(e)){const t=o();t.setFormat(i.getFormatType()),t.setIndent(i.getIndent()),a.push(t),r.set(e,t),i.getChildren().forEach(e=>{t.append(e),u.add(e.getKey()),E(e)&&e.getChildrenKeys().forEach(e=>u.add(e))}),Nn(i)}}else if(d.has(n.getKey())){E(n)||fn(179);const e=o();e.setFormat(n.getFormatType()),e.setIndent(n.getIndent()),a.push(e),n.remove(!0)}}if(null!==i)for(let e=0;e<a.length;e++){const t=a[e];i.append(t)}let h=null;if(D(c))if(s)if(null!==i)c.insertAfter(i);else for(let e=a.length-1;e>=0;e--){const t=a[e];c.insertAfter(t)}else{const e=c.getFirstChild();if(E(e)&&(c=e),null===e)if(i)c.append(i);else for(let e=0;e<a.length;e++){const t=a[e];c.append(t),h=t}else if(null!==i)e.insertBefore(i);else for(let t=0;t<a.length;t++){const n=a[t];e.insertBefore(n),h=n}}else if(i)c.insertAfter(i);else for(let e=a.length-1;e>=0;e--){const t=a[e];c.insertAfter(t),h=t}const p=H();z(p)&&kn(p.anchor)&&kn(p.focus)?F(p.clone()):null!==h?h.selectEnd():e.dirty=!0}function Ln(e,t,n){const o=yn(e.getStyle());return null!==o&&o[t]||n}function Tn(e,t,n=""){let o=null;const i=e.getNodes(),l=e.anchor,r=e.focus,a=e.isBackward(),c=a?r.offset:l.offset,s=a?r.getNode():l.getNode();if(z(e)&&e.isCollapsed()&&""!==e.style){const n=yn(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!==c||!l.is(s))&&R(l)){const e=Ln(l,t,n);if(null===o)o=e;else if(o!==e){o="";break}}}return null===o?n:o}const En="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,An=En&&"documentMode"in document?document.documentMode:null;function Fn(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function Dn(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null}function Mn({open:t,onOpenChange:n,children:o}){const l=a(null),r=a(null);return c(()=>{function e(e){l.current?.contains(e.target)||r.current?.contains(e.target)||n(!1)}return t&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[t,n]),e("div",{className:"popover-root",children:i.Children.map(o,e=>e&&"object"==typeof e?e.type===zn?s(e,{triggerRef:l}):e.type===Rn?s(e,{contentRef:r,triggerRef:l}):e:e)})}function zn({children:t,triggerRef:n}){return e("div",{className:"popover-trigger",ref:n,children:t})}function Rn({open:t,align:n="start",children:o,contentRef:l,triggerRef:r}){const s=a(null),[d,u]=i.useState(!1);return c(()=>{if(!t)return;const e=()=>{const e=s.current,t=r?.current;if(!e||!t)return;const o=t.closest(".lexical-text-editor"),i=!!o?.classList.contains("lexical-dark");e.classList.contains("lexical-dark")!==i&&e.classList.toggle("lexical-dark",i);const l=t.getBoundingClientRect(),a=e.offsetWidth,c=e.offsetHeight;let d=l.left;"center"===n?d=l.left+l.width/2-a/2:"end"===n&&(d=l.right-a),d=Math.max(8,Math.min(window.innerWidth-a-8,d));let h=l.bottom+4;h+c>window.innerHeight-8&&l.top>c+8&&(h=l.top-c-4),e.style.left=`${d}px`,e.style.top=`${h}px`,u(i)};return e(),requestAnimationFrame(e),window.addEventListener("resize",e),document.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),document.removeEventListener("scroll",e,!0)}},[t,n,r]),t?$t(e("div",{ref:s,className:"lexical-text-editor"+(d?" lexical-dark":""),"data-lte-popover-portal":"true",onMouseDown:e=>e.preventDefault(),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:e("div",{ref:e=>{l.current=e},className:"popover-content",style:{position:"static",top:"auto",left:"auto",borderRadius:6,border:"none",margin:0,width:"100%"},children:o})}),document.body):null}function Wn({onAction:n,selectionMap:o}){const[i,l]=d(!1),r=a(null),c=a(null);return t(Mn,{open:i,onOpenChange:l,children:[e(zn,{triggerRef:r,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(i?"toolbar-active":"toolbar"),onClick:()=>l(e=>!e),children:[e("span",{children:"Aa"}),e(Pt,{className:"chevron "+(i?"rotated":"")})]})}),e(Rn,{open:i,align:"start",onClose:()=>l(!1),contentRef:c,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:ln.map(({id:i,label:r,icon:a})=>t("button",{type:"button",className:"lexical-btn "+(o[i]?"toolbar-active":"toolbar"),onClick:()=>{n(i),l(!1)},style:{minWidth:130},children:[a,e("span",{className:"label",children:r})]},i))})})]})}function On(){return e("div",{className:"lexical-separator"})}function In({updateHeading:n,headingSelectionMap:o}){const i=pn.find(e=>o[e.id]),[l,r]=d(!1),c=a(null),s=a(null);return t(Mn,{open:l,onOpenChange:r,children:[e(zn,{triggerRef:c,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(l?"toolbar-active":"toolbar"),onClick:()=>r(e=>!e),style:{minWidth:132},children:[i?.icon,e("span",{children:i?.label}),e(Pt,{className:"chevron "+(l?"rotated":"")})]})}),e(Rn,{open:l,align:"start",onClose:()=>r(!1),contentRef:s,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:pn.map(({id:i,label:l,icon:a})=>t("button",{type:"button",className:"lexical-btn "+(o[i]?"toolbar-active":"toolbar"),onClick:()=>{n(i),r(!1)},children:[a,e("span",{className:"label",children:l})]},i))})})]})}function Hn({linkUrl:n,setLinkUrl:o,onConfirm:i,onCancel:l,removeLink:r}){const[s,u]=d(!1),h=a(null),p=a(null);return c(()=>{"https://"===n&&u(!0)},[n]),c(()=>{s&&p.current?.focus()},[s]),c(()=>{const e=e=>{h.current&&!h.current.contains(e.target)&&l()};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[l]),t("div",{ref:h,className:"lexical-text-editor-link link-editor-container",children:[e("div",{className:"link-editor-input-wrapper",children:s?e("input",{ref:p,className:"link-editor-input",value:n,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),i(n),u(!1)):"Escape"===e.key&&(e.preventDefault(),u(!1),l())}}):e("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"link-editor-url",children:n})}),t("div",{className:"link-editor-buttons",children:[e("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>{s?(i(n),u(!1)):u(!0)},children:s?e(Bt,{size:18}):e(pt,{size:14})}),e("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onMouseDown:e=>e.preventDefault(),onClick:r,children:e(Vt,{size:14,style:{stroke:"black"}})})]})]})}function Un({onClose:n}){const[o]=Ot(),[i,l]=d(""),[r,s]=d(""),[u,h]=d(!1),[p,m]=d([]),[g,f]=d(0),b=a(null);c(()=>{b.current?.focus()},[]);const y=()=>{if(!i)return[];const e=u?i:i.toLowerCase(),t=[],n=P().getAllTextNodes();for(const o of n){const n=u?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};c(()=>{const e=o.getEditorState().read(y);m(e),f(0)},[o,i,u]),c(()=>o.registerUpdateListener(({editorState:e})=>{const t=e.read(y);m(t),f(e=>0===t.length?0:Math.min(e,t.length-1))}),[o,i,u]);const v=e=>{if(0===p.length)return;const t=(g+e+p.length)%p.length,n=p[t];f(t),o.update(()=>{const e=$(n.key);R(e)&&e.select(n.start,n.start+i.length)}),requestAnimationFrame(()=>{const e=o.getElementByKey(n.key);e?.scrollIntoView({block:"nearest"})})},x=i.length>0,w=p.length>0;return t("div",{className:"lexical-find-replace",onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),n())},children:[t("div",{className:"lexical-fr-row",children:[e("input",{ref:b,className:"lexical-fr-input",placeholder:"Find",value:i,onChange:e=>l(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),v(e.shiftKey?-1:1))}}),e("span",{className:"lexical-fr-count",children:w?`${g+1} of ${p.length}`:x?"0 results":""})]}),e("div",{className:"lexical-fr-row",children:e("input",{className:"lexical-fr-input",placeholder:"Replace with",value:r,onChange:e=>s(e.target.value)})}),t("div",{className:"lexical-fr-row",children:[t("label",{className:"lexical-fr-case",children:[e("input",{type:"checkbox",checked:u,onChange:e=>h(e.target.checked)}),e("span",{children:"Match case"})]}),e("span",{style:{flex:1}}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>v(-1),disabled:!w,"aria-label":"Previous match",children:e(Lt,{})}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>v(1),disabled:!w,"aria-label":"Next match",children:e(Tt,{})}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>{o.update(()=>{const e=y();if(0===e.length)return m([]),void f(0);const t=e[Math.min(g,e.length-1)],n=$(t.key);R(n)&&n.spliceText(t.start,i.length,r,!0)})},disabled:!w,children:"Replace"}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:()=>{o.update(()=>{const e=y();for(let t=e.length-1;t>=0;t--){const n=e[t],o=$(n.key);R(o)&&o.spliceText(n.start,i.length,r,!1)}})},disabled:!w,children:"Replace All"}),e("button",{type:"button",className:"lexical-btn toolbar",onClick:n,"aria-label":"Close find and replace",children:e(Et,{})})]})]})}function Pn({anchorRef:t,onClose:n,children:o}){const i=a(null);return c(()=>{const e=e=>{const o=e.target;o instanceof HTMLElement&&o.closest("[data-lte-popover-portal]")||!i.current||i.current.contains(o)||t.current&&t.current.contains(o)||n()},o=e=>{"Escape"===e.key&&n()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",o)}},[t,n]),e("div",{ref:i,className:"lte-overflow-panel",onMouseDown:e=>e.preventDefault(),children:e("div",{className:"lte-overflow-grid",children:o})})}function $n({onAction:n,alignmentSelectionMap:o}){const i=hn.find(e=>o[e.id]),[l,r]=d(!1),c=a(null),s=a(null);return t(Mn,{open:l,onOpenChange:r,children:[e(zn,{triggerRef:c,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(l?"toolbar-active":"toolbar"),onClick:()=>r(e=>!e),style:{minWidth:146},children:[i?.icon,e("span",{children:i?.label}),e(Pt,{className:"chevron "+(l?"rotated":"")})]})}),e(Rn,{open:l,align:"start",onClose:()=>r(!1),contentRef:s,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:hn.map(({id:i,label:l,icon:a})=>t("button",{type:"button",className:"lexical-btn "+(o[i]?"toolbar-active":"toolbar"),onClick:()=>{n(i),r(!1)},children:[a,e("span",{className:"label",children:l})]},i))})})]})}function Kn({color:n,onChange:o,icon:i}){const[l,r]=d(!1),s=a(null),u=a(null);c(()=>{const e=e=>{u.current&&!u.current.contains(e.target)&&s.current&&!s.current.contains(e.target)&&r(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);return t("div",{className:"color-picker-wrapper",children:[e("button",{type:"button",ref:s,className:`size-10 lexical-btn ${l?"toolbarActive":"toolbar"} icon`,onClick:()=>r(e=>!e),children:i}),l&&$t(e("div",{ref:u,className:"lexical-color-popover "+(l?"open":""),"data-lte-popover-portal":"true",style:{top:s.current?.getBoundingClientRect().bottom,left:s.current?.getBoundingClientRect().left,position:"absolute"},onMouseDown:e=>{e.preventDefault(),(e=>{e.preventDefault()})(e)},children:e(jt,{color:n,onChangeComplete:e=>{o(e.hex)}})}),document.body)]})}function Bn(){const[o]=Ot(),[{color:i,bgColor:l},r]=d({color:"#000",bgColor:"#fff"}),a=()=>{const e=A();if(z(e)){const t=Tn(e,"color","#000"),n=Tn(e,"background","#fff");r({color:t,bgColor:n})}};c(()=>Fn(o.registerUpdateListener(({editorState:e})=>{e.read(()=>{a()})}),o.registerCommand(K,()=>(a(),!1),1)),[o]);const s=({property:e,color:t})=>{o.update(()=>{const n=A();n&&xn(n,{[e]:t})})};return t(n,{children:[e(Kn,{color:i,onChange:e=>{s({property:"color",color:e})},icon:e(Nt,{})}),e(Kn,{color:l,onChange:e=>{s({property:"background",color:e})},icon:e(St,{})})]})}function Jn({icon:n,tooltipLabel:o,currentValue:i,options:l,onSelect:r,minWidth:c=132}){const s=l.find(e=>""!==e.id&&e.id===i),[u,h]=d(!1),p=a(null),m=a(null);return t(Mn,{open:u,onOpenChange:h,children:[e(zn,{triggerRef:p,children:t("button",{type:"button","aria-label":o,className:"lexical-btn heading-trigger font-trigger "+(u?"toolbar-active":"toolbar"),style:{minWidth:c},onClick:()=>h(e=>!e),children:[n,e("span",{children:s?.label??"Default"}),e(Pt,{className:"chevron "+(u?"rotated":"")})]})}),e(Rn,{open:u,align:"start",onClose:()=>h(!1),contentRef:m,children:e("div",{style:{display:"flex",flexDirection:"column",gap:5},children:l.map(t=>e("button",{type:"button",className:"lexical-btn "+(""===t.id&&""===i||""!==t.id&&t.id===i?"toolbar-active":"toolbar"),onClick:()=>{r(t.id),h(!1)},children:e("span",{className:"label",children:t.label})},t.label))})})]})}En&&"InputEvent"in window&&!An&&new window.InputEvent("input");const qn=[{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 Vn(){const[t]=Ot(),[n,o]=d(""),i=()=>{const e=A();if(z(e)){const t=Tn(e,"font-family","");o((e=>e.replace(/['"]/g,"").trim())(t))}};c(()=>Fn(t.registerUpdateListener(({editorState:e})=>{e.read(()=>{i()})}),t.registerCommand(K,()=>(i(),!1),1)),[t]);return e(Jn,{icon:e(mt,{}),tooltipLabel:"Font Family",currentValue:n,options:qn,onSelect:e=>{t.update(()=>{const t=A();z(t)&&xn(t,{"font-family":""===e?null:e})})}})}const jn=({content:n,direction:o="top",delay:i=400,children:l})=>{const[r,c]=d(!1),[s,u]=d(null),h=a(null),p=a(null),m=()=>{h.current=window.setTimeout(()=>{const e=p.current;if(e){const t=e.getBoundingClientRect();u({left:t.left,top:t.top,right:t.right,bottom:t.bottom,width:t.width,height:t.height})}c(!0)},i)},g=()=>{h.current&&clearTimeout(h.current),c(!1)};if(!s)return e("div",{ref:p,className:"Lexical-Tooltip-Wrapper",onMouseEnter:m,onMouseLeave:g,children:l});const f=s.left+s.width/2,b=s.top+s.height/2,y="bottom"===o?{top:s.bottom+10,left:f,bottom:"auto"}:"top"===o?{bottom:window.innerHeight-s.top+10,top:"auto",left:f}:"right"===o?{left:s.right+10,right:"auto",top:b}:{left:"auto",right:window.innerWidth-s.left+10,top:b};return t("div",{ref:p,className:"Lexical-Tooltip-Wrapper",onMouseEnter:m,onMouseLeave:g,children:[l,r&&$t(e("div",{className:`Lexical-Tooltip-Tip ${o}`,style:{position:"fixed",pointerEvents:"none",...y,zIndex:1e4},children:n}),document.body)]})};function Qn(){const[n]=Ot(),[o,i]=d(""),[l,r]=d(null),s=a(null),u=()=>{const e=A();if(z(e)){let t=Xn(Tn(e,"font-size",""));if(!t)try{const o=n.getElementByKey(e.anchor.getNode().getKey());o&&(t=window.getComputedStyle(o).fontSize||"")}catch{}i(Xn(t)),document.activeElement!==s.current&&r(null)}};c(()=>Fn(n.registerUpdateListener(({editorState:e})=>{e.read(()=>{u()})}),n.registerCommand(K,()=>(u(),!1),1)),[n]);const h=e=>{const t=Math.min(90,Math.max(6,e));n.update(()=>{const e=A();z(e)&&xn(e,{"font-size":`${t}px`})})},p=e=>{const t=l??o,n=Number.parseInt(t,10),i=Number.isNaN(n)?16:n;h(i+e)},m=()=>{const e=l;if(r(null),null===e)return;const t=Number.parseInt(e,10);if(Number.isNaN(t))return;t!==Number.parseInt(o,10)&&h(t)},g=Number.parseInt(o,10),f=Number.isNaN(g)?null:g;return t("div",{className:"lexical-stepper","aria-label":"Font Size",role:"group",children:[e(jn,{content:"Decrease font size",direction:"bottom",children:e("button",{type:"button","aria-label":"Decrease Font Size",className:"lexical-stepper-btn",disabled:null!==f&&f<=6,onClick:()=>p(-1),children:e(Qt,{})})}),e("input",{ref:s,type:"text",inputMode:"numeric",className:"lexical-stepper-value lexical-stepper-input","aria-label":"Font size in pixels",placeholder:"—",title:"Click to type a size (6-90), then press Enter",value:l??(null!==f?String(f):""),onChange:e=>r(e.target.value.replace(/[^\d]/g,"")),onFocus:e=>e.currentTarget.select(),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),m(),e.currentTarget.blur()):"Escape"===e.key?(e.preventDefault(),r(null),e.currentTarget.blur()):"ArrowUp"!==e.key&&"ArrowDown"!==e.key||(e.preventDefault(),m(),p("ArrowUp"===e.key?1:-1)),e.stopPropagation()},onBlur:m}),e(jn,{content:"Increase font size",direction:"bottom",children:e("button",{type:"button","aria-label":"Increase Font Size",className:"lexical-stepper-btn",disabled:null!==f&&f>=90,onClick:()=>p(1),children:e(Xt,{})})})]})}const Xn=e=>e.trim();function Yn(){const[n]=Ot(),o=r(gn),[i,l]=d(!1),[s,u]=d(null),[h,p]=d(!1),m=a(null),g=a(null),f=()=>{const e=A();if(z(e)){const t=e.anchor.getNode(),n="root"===t.getKey()?t:t.getTopLevelElementOrThrow(),o=v(n);l(o),o&&u(n.getLanguage()??null)}};c(()=>Fn(n.registerUpdateListener(({editorState:e})=>{e.read(()=>{f()})}),n.registerCommand(K,()=>(f(),!1),1)),[n]);const b=mn.find(e=>e.id===s)?.label??"Plain Text";return t(Mn,{open:h,onOpenChange:p,children:[e(zn,{triggerRef:m,children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(i?"toolbar-active":"toolbar"),onClick:()=>p(e=>!e),children:[e(_t,{}),e("span",{children:b}),e(Pt,{className:"chevron "+(h?"rotated":"")})]})}),e(Rn,{open:h,align:"start",onClose:()=>p(!1),contentRef:g,children:t("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[t("button",{type:"button",className:"lexical-btn "+(i?"toolbar-active":"toolbar"),onClick:()=>{n.update(()=>{if(!z(A())){const e=P().getFirstChild();E(e)&&e.select(0,0)}const e=A();if(!z(e))return;const t=e.anchor.getNode(),n="root"===t.getKey()?t:t.getTopLevelElementOrThrow();if(v(n))Cn(e,()=>B());else{const t=s??"javascript";Cn(e,()=>x(t))}}),o(),p(!1)},style:{minWidth:150},children:[e(_t,{}),e("span",{className:"label",children:i?"Remove Code Block":"Code Block"})]}),e("div",{className:"w-full h-[1px] bg-gray-200 my-1"}),e("div",{style:{display:"flex",flexDirection:"column",gap:5,maxHeight:260,overflowY:"auto"},children:mn.map(({id:t,label:i})=>e("button",{type:"button",className:"lexical-btn "+(s===t?"toolbar-active":"toolbar"),onClick:()=>{var e;u(e=t),n.update(()=>{if(!z(A())){const e=P().getFirstChild();E(e)&&e.select(0,0)}const t=A();if(!z(t))return;const n=t.anchor.getNode(),o="root"===n.getKey()?n:n.getTopLevelElementOrThrow();v(o)?o.setLanguage(e):Cn(t,()=>x(e))}),o(),p(!1)},style:{minWidth:150},children:e("span",{className:"label",children:i})},t))})]})})]})}function Gn({blockType:o}){const[i]=Ot();c(()=>Fn(i.registerCommand(J,e=>{const t=A();if(!z(t))return!1;return!!Dn(t.anchor.getNode(),Se)&&(e.preventDefault(),i.dispatchCommand(e.shiftKey?q:V,void 0),!0)},j)),[i]);return t(n,{children:[e(jn,{content:"Ordered list",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${"ol"===o?"toolbarActive":"toolbar"} icon`,onClick:()=>{"ol"===o?i.dispatchCommand(Ce,void 0):i.dispatchCommand(ke,void 0)},children:e(gt,{})})}),e(jn,{content:"Unordered list",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${"ul"===o?"toolbarActive":"toolbar"} icon`,onClick:()=>{"ul"===o?i.dispatchCommand(Ce,void 0):i.dispatchCommand(Ne,void 0)},children:e(ft,{})})})]})}function Zn(){const[n]=Ot(),[o,i]=d(!1),[l,r]=d(!1),[s,u]=d(null),h=a(null),p=a(null),m=()=>{const e=A();if(z(e)){const t=De(e.anchor.getNode());i(!!t)}else i(!1)};c(()=>Fn(n.registerUpdateListener(({editorState:e})=>{e.read(()=>{m()})}),n.registerCommand(K,()=>(m(),!1),1)),[n]);const g=e=>{n.update(()=>{const t=A();z(t)&&e()}),r(!1)},f=s?`${s.rows} × ${s.cols}`:"Insert Table";return t(Mn,{open:l,onOpenChange:r,children:[e(zn,{triggerRef:h,children:t("button",{type:"button","aria-label":"Insert Table",className:"lexical-btn heading-trigger "+(o?"toolbar-active":"toolbar"),onClick:()=>r(e=>!e),children:[e(bt,{}),e(Pt,{className:"chevron "+(l?"rotated":"")})]})}),e(Rn,{open:l,align:"start",onClose:()=>r(!1),contentRef:p,children:t("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t("div",{style:{width:"fit-content"},children:[e("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,a=s&&i<=s.rows&&l<=s.cols;return e("div",{onMouseEnter:()=>u({rows:i,cols:l}),onClick:()=>{return e=i,t=l,n.update(()=>{if(!z(A())){const e=P().getFirstChild();E(e)&&e.select(0,0)}}),n.dispatchCommand(Me,{rows:String(e),columns:String(t),includeHeaders:!1}),void r(!1);var e,t},style:{width:18,height:18,borderRadius:3,border:"1px solid #d1d5db",backgroundColor:a?"#c7d2fe":"#fff",cursor:"pointer"}},o)})}),e("div",{style:{fontSize:12,color:"#6b7280",marginTop:4},children:f})]}),e("div",{className:"w-full h-[1px] bg-gray-200"}),t("div",{style:{display:"flex",flexDirection:"column",gap:5},children:[e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{We(!1)}),style:{minWidth:160},children:e("span",{className:"label",children:"Insert row above"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{We(!0)}),style:{minWidth:160},children:e("span",{className:"label",children:"Insert row below"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{Oe()}),style:{minWidth:160},children:e("span",{className:"label",children:"Delete row"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{Ie(!1)}),style:{minWidth:160},children:e("span",{className:"label",children:"Insert column left"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{Ie(!0)}),style:{minWidth:160},children:e("span",{className:"label",children:"Insert column right"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>g(()=>{He()}),style:{minWidth:160},children:e("span",{className:"label",children:"Delete column"})}),e("button",{type:"button",className:"lexical-btn toolbar",disabled:!o,onClick:()=>{g(()=>{const e=A();if(!z(e))return;const t=De(e.anchor.getNode());if(!t)return;const n=t.getParent();if(!n)return;const o=n.getChildren().filter(ze),i=o.some(e=>e.hasHeaderState(Re.ROW));for(const e of o)e.setHeaderStyles(i?Re.NO_STATUS:Re.ROW,Re.ROW)})},style:{minWidth:160},children:e("span",{className:"label",children:"Toggle header row"})})]})]})})]})}const eo=({src:n,altText:o,nodeKey:i,width:l,height:r,maxWidth:c,caption:s=""})=>{const[u]=Ot(),[h,p]=d(!1),[m,g]=d(s),f=a(null),b=a(null),y=a(null),v=a(null),x=e=>{if(!v.current||!b.current)return;const t=e.clientX-v.current.x,n=Math.min(c,Math.max(50,v.current.width+t)),o=n*b.current.ratio;b.current.width=n,b.current.height=o;const i=y.current?.querySelector("img");i&&(i.style.width=n+"px",i.style.height=o+"px")},w=()=>{if(!b.current)return;const{width:e,height:t}=b.current;u.update(()=>{const n=$(i);n&&"function"==typeof n.updateDimensions&&n.updateDimensions(e,t)}),b.current=null,v.current=null,window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",w)},C=()=>{p(!1),u.update(()=>{const e=$(i);e&&"function"==typeof e.setCaption&&e.setCaption(m)})},k=()=>{g(s),p(!0),setTimeout(()=>f.current?.focus(),0)};return t("div",{ref:y,style:{display:"inline-block",position:"relative",maxWidth:c},children:[e("img",{src:n,alt:o,width:"inherit"===l?void 0:l,height:"inherit"===r?void 0:r,style:{maxWidth:"100%",display:"block"}}),(s||h)&&e("div",{style:{textAlign:"center",marginTop:4},children:h?e("input",{ref:f,className:"lte-input",style:{width:"100%",textAlign:"center"},value:m,onChange:e=>g(e.target.value),onBlur:C,onKeyDown:e=>{"Enter"===e.key&&C()}}):e("span",{style:{fontSize:13,color:"#666",cursor:"text",display:"inline-block",minWidth:20,minHeight:18},onClick:k,children:s})}),!s&&!h&&e("div",{style:{textAlign:"center",marginTop:2},children:e("span",{style:{fontSize:12,color:"#999",cursor:"pointer"},onClick:k,children:"+ Add caption"})}),e("div",{onMouseDown:e=>{e.preventDefault(),e.stopPropagation();const t=y.current?.querySelector("img");if(!t)return;const n=t.getBoundingClientRect().width,o=t.naturalHeight/t.naturalWidth,i=n*o;v.current={x:e.clientX,y:e.clientY,width:n,height:i},b.current={width:n,height:i,ratio:o},window.addEventListener("mousemove",x),window.addEventListener("mouseup",w)},style:{position:"absolute",bottom:s||h?40:0,right:0,width:14,height:14,background:"white",border:"1px solid #999",cursor:"nwse-resize",borderRadius:2}})]})},to=e=>X(new oo(e)),no=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:to({src:t,altText:n,width:o??"inherit",height:i??"inherit"})}};class oo extends Q{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 oo({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:no,priority:1}),figure:()=>({conversion:e=>{const t=e.querySelector("img");if(!t)return null;const n=e.querySelector("figcaption"),o=n?.textContent||"",i=no(t);return i?.node instanceof oo&&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 oo({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 e(eo,{src:this.__src,altText:this.__altText,nodeKey:this.getKey(),width:this.__width,height:this.__height,maxWidth:this.__maxWidth,caption:this.__caption})}}function io({open:n,onClose:o,forPreview:i=!1,children:l}){const r=a(null);return c(()=>{if(!n)return;const e=e=>{r.current&&!r.current.contains(e.target)&&o()},t=e=>{"Escape"===e.key&&o()};return document.addEventListener("mousedown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[n,o]),n?e("div",{className:"lexical-text-editor-dialog lte-dialog-overlay",children:t("div",{ref:r,className:"lte-dialog "+(i?"preview":""),children:[e("button",{type:"button",className:"lte-dialog-close",onClick:o,children:"×"}),l]})}):null}async function lo(e,{src:t,altText:n="",caption:o=""}){e.update(()=>{const e=to({src:t,altText:n,caption:o});Z([e])})}function ro({onImageUpload:n}){const[o]=Ot(),i=a(null),[l,r]=d(!1),[s,h]=d(""),[p,m]=d(""),[g,f]=d(""),[b,y]=d(),[v,x]=d(!1),w=u(async(e,t="",i="")=>{let l;l=n?await n(e):URL.createObjectURL(e),lo(o,{src:l,altText:t,caption:i})},[o,n]);return c(()=>{const e=o.registerCommand(Y,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&&w(t,"","").catch(console.error),!0}}return!1},G);return()=>e()},[o,w]),t("div",{className:"lexical-text-editor-dialog",children:[e("input",{type:"file",ref:i,accept:"image/*",className:"lte-hidden",onChange:e=>{const t=e.target.files?.[0];t&&y(t),e.target.value=""}}),e(jn,{content:"Add Image",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${l?"toolbarActive":"toolbar"} icon`,onClick:()=>r(e=>!e),children:e(At,{size:18})})}),t(io,{open:l,onClose:()=>r(!1),children:[e("div",{className:"lte-dialog-header",children:"Add Image"}),t("div",{className:"lte-dialog-body",children:[e("input",{className:"lte-input",placeholder:"Alt text",value:p,onChange:e=>m(e.target.value)}),e("input",{className:"lte-input",placeholder:"Caption",value:g,onChange:e=>f(e.target.value)}),e("input",{className:"lte-input",placeholder:"Add image by URL",value:s,onChange:e=>h(e.target.value)}),e("div",{className:"lte-divider",children:e("span",{children:"or"})}),t("button",{type:"button",className:"lexical-btn heading-trigger toolbar-active",onClick:()=>i.current?.click(),style:{width:"fit-content",margin:"0 auto"},children:[e(Yt,{size:20}),e("span",{children:"Upload Image"})]}),b&&e("div",{className:"lte-file-name",children:b.name})]}),e("div",{className:"lte-dialog-footer",children:e("button",{type:"button",className:"lte-primary-btn",disabled:!s&&!b||v,onClick:async()=>{if(!v){if(b){x(!0);try{await w(b,p,g)}catch(e){return console.error("Image upload failed:",e),void x(!1)}x(!1)}else{if(!s)return;lo(o,{src:s,altText:p,caption:g})}y(void 0),m(""),f(""),h(""),r(!1)}},children:v?"Uploading...":"Add Image"})})]})]})}const ao=({id:e,provider:t})=>new go({id:e,provider:t}),co="data-lexical-video",so="data-provider",uo="315px",ho="560px",po=(e,t)=>"drive"===t?`https://drive.google.com/file/d/${e}/preview`:`https://www.youtube-nocookie.com/embed/${e}`,mo=e=>{const t=e?.getAttribute(co),n=e?.getAttribute(so)??"youtube";if(!t)return null;return{node:ao({id:t,provider:n})}};class go extends Q{constructor({id:e,provider:t,key:n}){super(n),this.__id=e,this.__provider=t}static getType(){return"video"}static clone(e){return new go({id:e.__id,provider:e.__provider,key:e.getKey()})}static importJSON(e){return ao({id:e.id,provider:e.provider})}exportJSON(){return{id:this.__id,provider:this.__provider,type:"video",version:1}}updateDOM(){return!1}decorate(){return e("iframe",{height:uo,width:ho,src:po(this.__id,this.__provider),frameBorder:"0",allowFullScreen:!0})}createDOM(){return document.createElement("div")}exportDOM(){const e=document.createElement("iframe");return e.setAttribute(co,this.__id),e.setAttribute(so,this.__provider),e.setAttribute("height",uo),e.setAttribute("width",ho),e.setAttribute("src",po(this.__id,this.__provider)),{element:e}}static importDOM(){return{iframe:()=>({conversion:mo,priority:0})}}}function fo(){const[n,o]=d(!1),[i,l]=d(!1),[r,a]=d(""),[s]=Ot();return c(()=>{n||(a(""),l(!1))},[n]),t("div",{className:"lexical-text-editor-dialog",children:[e(jn,{content:"Embed Video",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${n?"toolbarActive":"toolbar"} icon`,onClick:()=>o(!0),children:e(Gt,{size:18,color:"red"})})}),t(io,{open:n,onClose:()=>o(!1),children:[e("div",{className:"lte-dialog-header",children:"Embed Video"}),t("div",{className:"lte-dialog-body",children:[e("input",{className:"lte-input",placeholder:"Add YouTube or Google Drive URL",value:r,onChange:e=>a(e.target.value)}),i&&e("p",{className:"lte-error-text",children:"It's not a valid YouTube or Google Drive URL"})]}),e("div",{className:"lte-dialog-footer",children:e("button",{type:"button",className:"lte-primary-btn",disabled:!r,onClick:()=>{if(!r)return;let e=null,t=null;const n=/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/.exec(r);n&&11===n[2]?.length&&(e="youtube",t=n[2]);const i=/drive\.google\.com\/file\/d\/([a-zA-Z0-9_-]+)\//.exec(r);i&&i[1]&&(e="drive",t=i[1]),t&&e?(s.update(()=>{const n=ao({id:t,provider:e});Z([n])}),a(""),l(!1),o(!1)):l(!0)},children:"Embed"})})]})]})}function bo({value:t}){return e("div",{className:"lexical-text-editor-html-preview",dangerouslySetInnerHTML:{__html:t}})}function yo({value:n,triggerLabel:o="Preview"}){const[i,l]=d(!1);return t("div",{className:"lexical-text-editor-dialog",children:[e(jn,{content:o,direction:"bottom",children:t("button",{type:"button",className:"lexical-btn heading-trigger "+(i?"toolbar-active":"toolbar"),onClick:()=>l(e=>!e),children:[e(Zt,{size:18}),e("span",{children:o})]})}),t(io,{open:i,onClose:()=>l(!1),forPreview:!0,children:[e("div",{className:"lte-dialog-header",children:"Content Preview"}),t("div",{className:"lte-preview-container",children:[e("div",{className:"lte-preview-title",children:"CONTENT"}),e(bo,{value:n})]})]})]})}const vo=[{id:"headings",sep:!0},{id:"fontFamily"},{id:"fontSize"},{id:"textFormats",sep:!0},{id:"dropdown",sep:!0},{id:"color",sep:!0},{id:"quoteCode",sep:!0},{id:"codeBlock"},{id:"alignment",sep:!0},{id:"lists",sep:!0},{id:"blockOptions"},{id:"table",sep:!0},{id:"hline"},{id:"link",sep:!0},{id:"image"},{id:"video"},{id:"utility",sep:!0},{id:"preview"}],xo=vo.map(e=>e.id),wo=({value:o,onImageUpload:i,sourceView:l=!1,onToggleSourceView:r,fullscreen:s=!1,onToggleFullscreen:h,toolbarStyle:b="wrap"})=>{const y="normal"===b?"collapse":b,[v]=Ot(),[x,w]=d({[nn.Undo]:!0,[nn.Redo]:!0}),[C,k]=d(!1),[N,S]=d(!1),[_,L]=d(0),[T,F]=d(!1),D=u(()=>F(!1),[]),M=a(null),W=a(null),O=a(null),I=a({}),H=a({}),U=a(0),P=a(null),$=a(null),[J,j]=d({[nn.LeftAlign]:!0}),[Q,X]=d({[on.Normal]:!0}),[Y,G]=d("paragraph"),[Z,re]=d("https://");let ae=!0;const ce=()=>{if(ae){const e=v.getRootElement();e&&(e.scrollTop=0,ae=!1)}const e=A();if(z(e)){const t={[nn.Bold]:e.hasFormat("bold"),[nn.Italics]:e.hasFormat("italic"),[nn.Underline]:e.hasFormat("underline"),[nn.Uppercase]:e.hasFormat("uppercase"),[nn.Lowercase]:e.hasFormat("lowercase"),[nn.Capitalize]:e.hasFormat("capitalize"),[nn.Strikethrough]:e.hasFormat("strikethrough"),[nn.Superscript]:e.hasFormat("superscript"),[nn.Subscript]:e.hasFormat("subscript"),[nn.Code]:e.hasFormat("code"),[nn.Highlight]:e.hasFormat("highlight")};j(t);const n=e.anchor.getNode(),o="root"===n.getKey()?n:n.getTopLevelElementOrThrow(),i=o.getKey();if(!v.getElementByKey(i))return;if(_e(o)){const e=Dn(n,Se),t=e?e.getTag():o.getTag();G(t)}else if("paragraph"===o.getType()||p(o)){let e=null;p(o)&&(e=o.getTag());const t={[on.H1]:"h1"===e,[on.H2]:"h2"===e,[on.H3]:"h3"===e,[on.H4]:"h4"===e,[on.H5]:"h5"===e,[on.H6]:"h6"===e,[on.Normal]:"paragraph"===o.getType()};G(o.getType()),X(t)}else G(o.getType());const l=(E(n)?n:o).getFormat();j(e=>({...e,[nn.LeftAlign]:0===l||1===l,[nn.CenterAlign]:2===l,[nn.RightAlign]:3===l,[nn.JustifyAlign]:4===l})),"quote"===o.getType()?j(e=>({...e,[nn.Quote]:!0})):j(e=>({...e,[nn.Quote]:!1}));const r=e.anchor.getNode(),a=r.getParent();Ht(a)?(j(e=>({...e,[nn.Link]:!0})),re(a.getURL()),k(!0)):Ht(r)?(j(e=>({...e,[nn.Link]:!0})),re(r.getURL()),k(!0)):(j(e=>({...e,[nn.Link]:!1})),re("https://"),k(!1))}};c(()=>Fn(v.registerUpdateListener(({editorState:e})=>{e.read(()=>{ce()})}),v.registerCommand(K,()=>(ce(),!1),1),v.registerCommand(te,e=>(w(t=>({...t,undo:!e})),!1),1),v.registerCommand(ee,e=>(w(t=>({...t,redo:!e})),!1),1)),[]);const se="scrollbar"===y,de=u(()=>{if("collapse"!==y)return;const e=M.current;if(!e)return;const t=e.clientWidth;if(t<=0)return;const n=W.current?W.current.offsetWidth:0,o=xo.map(e=>{const t=I.current[e];return t&&"none"!==t.style.display&&(H.current[e]=t.offsetWidth),H.current[e]??0});O.current&&(U.current=O.current.offsetWidth);const i=U.current||40,l=e=>{const t=1+(e>0?1:0)+(xo.length-e);let l=n+6*Math.max(0,t-1)+(e>0?i:0);for(let t=0;t<xo.length-e;t++)l+=o[t];return l};let r=_;for(;r<xo.length&&l(r)>t;)r++;for(;r>0&&l(r-1)<=t;)r--;L(e=>e===r?e:r)},[_,y]);c(()=>{de()});const ue=a(()=>{});ue.current=de,c(()=>{if("undefined"==typeof ResizeObserver)return;const e=M.current;if(!e)return;const t=new ResizeObserver(()=>{ue.current(),be.current()});return t.observe(e),()=>t.disconnect()},[]),c(()=>{0===_&&F(!1)},[_]),c(()=>{"collapse"!==y&&L(0)},[y]);const he=u(()=>{if("scrollbar"!==y)return;const e=M.current,t=P.current,n=$.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,a=l>0?e.scrollLeft/l*r:0;n.style.width=`${i}px`,n.style.transform=`translateX(${a}px)`},[b]),pe=u(e=>{e.stopPropagation(),e.preventDefault();const t=M.current,n=$.current;if(!t||!n)return;const o=e.clientX,i=t.scrollLeft,l=t.clientWidth,r=Math.max(24,l/t.scrollWidth*l),a=t.scrollWidth-l,c=l-r,s=e=>{const n=e.clientX-o;t.scrollLeft=c>0?i+n/c*a:0},d=()=>{document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",d)};document.addEventListener("pointermove",s),document.addEventListener("pointerup",d)},[]),me=u(e=>{const t=M.current,n=P.current;if(!t||!n)return;const o=n.getBoundingClientRect(),i=(e.clientX-o.left)/o.width;t.scrollLeft=i*t.scrollWidth-t.clientWidth/2},[]),ge=a(null),fe=u(()=>{const e=ge.current;if(e)for(const t of e.querySelectorAll(".lte-toolbar-row svg:not(.chevron), .lte-overflow-panel svg:not(.chevron)")){if(t.closest(".lexical-stepper"))continue;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 a=Math.min(22,Math.max(17,15/r));parseFloat(e.style.width)!==a&&(e.style.width=`${a}px`,e.style.height=`${a}px`)}catch{}}},[]);c(()=>{fe()}),c(()=>{he()});const be=a(()=>{});be.current=he,c(()=>{if("scrollbar"!==y)return;const e=M.current;if(!e)return;const t=()=>he();return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)},[y,he]);const ye=e=>{switch(e){case nn.Bold:v.dispatchCommand(le,"bold");break;case nn.Italics:v.dispatchCommand(le,"italic");break;case nn.Underline:v.dispatchCommand(le,"underline");break;case nn.Lowercase:v.dispatchCommand(le,"lowercase");break;case nn.Uppercase:v.dispatchCommand(le,"uppercase");break;case nn.Capitalize:v.dispatchCommand(le,"capitalize");break;case nn.Strikethrough:v.dispatchCommand(le,"strikethrough");break;case nn.Superscript:v.dispatchCommand(le,"superscript");break;case nn.Subscript:v.dispatchCommand(le,"subscript");break;case nn.Highlight:v.dispatchCommand(le,"highlight");break;case nn.Code:v.dispatchCommand(le,"code");break;case nn.Quote:v.update(()=>{const e=A();if(z(e)){const t=e.anchor.getNode().getParent();t&&m(t)?Cn(e,()=>B()):Sn(e,()=>g())}});break;case nn.Link:ve(),k(!0);break;case nn.LeftAlign:v.dispatchCommand(ie,"left");break;case nn.RightAlign:v.dispatchCommand(ie,"right");break;case nn.CenterAlign:v.dispatchCommand(ie,"center");break;case nn.JustifyAlign:v.dispatchCommand(ie,"justify");break;case nn.Undo:v.dispatchCommand(oe,void 0);break;case nn.Redo:v.dispatchCommand(ne,void 0);break;case nn.ClearFormatting:v.update(()=>{const e=A();if(!z(e))return;const t=e.getNodes().filter(R);for(const e of t)e.setFormat(0),e.setStyle("")});break;case nn.HorizontalRule:v.dispatchCommand(Te,void 0);break;case nn.Indent:v.dispatchCommand(V,void 0);break;case nn.Outdent:v.dispatchCommand(q,void 0)}},ve=u(()=>{v.update(()=>{const e=A();z(e)&&!e.isCollapsed()&&(C?v.dispatchCommand(It,null):""!==Z&&v.dispatchCommand(It,Z))})},[v,C,Z]),xe=u(()=>{re(""),v.dispatchCommand(It,null),k(!1)},[v]),we=e=>xo.indexOf(e)>=xo.length-_,Ce={headings:e(In,{updateHeading:e=>{v.update(()=>{const t=A();z(t)&&Sn(t,"normal"===e?()=>B():()=>f(e))})},headingSelectionMap:Q}),fontFamily:e(Vn,{}),fontSize:e(Qn,{}),textFormats:e(n,{children:rn.map(({id:t,label:n,icon:o})=>t===nn.Divider?e(On,{},t):e(jn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${J[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),children:o})},t))}),dropdown:e(Wn,{onAction:ye,selectionMap:J}),color:t(n,{children:[e(Bn,{}),an.map(({id:t,label:n,icon:o})=>e(jn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${J[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),children:o})},t))]}),quoteCode:e(n,{children:cn.map(({id:t,label:n,icon:o})=>e(jn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${J[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),children:o})},t))}),codeBlock:e(Yn,{}),alignment:e($n,{onAction:ye,alignmentSelectionMap:J}),lists:e(Gn,{blockType:Y}),blockOptions:e(n,{children:dn.map(({id:t,label:n,icon:o})=>t===nn.Divider?e(On,{},t):e(jn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${J[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),children:o})},t))}),table:e(Zn,{}),hline:e(n,{children:un.map(({id:t,label:n,icon:o})=>e(jn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${J[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),children:o})},t))}),link:e(jn,{content:"Link",direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${J[nn.Link]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(nn.Link),disabled:!!x[nn.Link],children:e(Kt,{})})}),image:e(ro,{onImageUpload:i}),video:e(fo,{}),utility:t(n,{children:[e(jn,{content:"Find & Replace",direction:"bottom",children:e("button",{type:"button","aria-label":"Find & Replace",className:`size-10 lexical-btn ${N?"toolbarActive":"toolbar"} icon`,onClick:()=>S(e=>!e),children:e(Ft,{})})}),e(jn,{content:"Source Code View",direction:"bottom",children:e("button",{type:"button","aria-label":"Source Code View",className:`size-10 lexical-btn ${l?"toolbarActive":"toolbar"} icon`,onClick:()=>r?.(),children:e(Dt,{})})}),e(jn,{content:s?"Exit Fullscreen":"Fullscreen",direction:"bottom",children:e("button",{type:"button","aria-label":s?"Exit Fullscreen":"Fullscreen",className:`size-10 lexical-btn ${s?"toolbarActive":"toolbar"} icon`,onClick:()=>h?.(),children:e(s?yt:vt,{})})})]}),preview:e(yo,{value:o})};return e(gn.Provider,{value:D,children:t("div",{ref:ge,className:"lexical-toolbar-wrapper",style:{position:"relative",padding:12,marginBottom:4,borderBottom:"1px solid #e5e7eb"},children:[t("div",{ref:M,className:"lte-toolbar-row "+(se?"useScroll":"collapse"===y?"lte-nowrap":"lte-wrap"),onMouseDown:e=>{"INPUT"!==e.target.tagName&&e.preventDefault()},children:[e("div",{ref:W,className:"lte-toolbar-primary",style:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:sn.map(({id:t,label:n,icon:o})=>t===nn.Divider?e(On,{},t):e(jn,{content:n,direction:"bottom",children:e("button",{type:"button",className:`size-10 lexical-btn ${J[t]?"toolbarActive":"toolbar"} icon`,onClick:()=>ye(t),disabled:!!x[t],children:o})},n))}),vo.map(({id:n,sep:o})=>{const i=we(n);return t("div",{ref:e=>{I.current[n]=e},style:i?{display:"none"}:{display:"flex",gap:6,justifyContent:"start",alignItems:"center"},children:[o?e(On,{}):null,i?null:Ce[n]]},n)}),_>0&&e(jn,{content:"More tools",direction:"bottom",children:e("button",{type:"button",ref:O,"aria-label":"More tools",className:`size-10 lexical-btn ${T?"toolbarActive":"toolbar"} icon`,onClick:()=>F(e=>!e),children:e(xt,{})})})]}),se&&e("div",{ref:P,className:"lte-custom-scrollbar",onPointerDown:me,"aria-hidden":"true",children:e("div",{ref:$,className:"lte-custom-scrollbar-thumb",onPointerDown:pe})}),C&&e(Hn,{linkUrl:Z,setLinkUrl:re,removeLink:xe,onConfirm:e=>{v.dispatchCommand(It,{url:e,target:"_blank"}),re(e),k(!1)},onCancel:()=>{re(""),k(!1)}}),T&&e(Pn,{anchorRef:O,onClose:()=>F(!1),children:vo.filter(({id:e})=>we(e)&&Ce[e]).map(({id:n,sep:o},i)=>t("div",{className:"lte-overflow-item",children:[o&&i>0?e(On,{}):null,Ce[n]]},n))}),N&&e(Un,{onClose:()=>S(!1)})]})})};function Co(){const[e]=Ot();return c(()=>{let t=!1;return Fn(e.registerCommand(ce,()=>{const e=A();if(!z(e))return!1;const n=e.anchor.getNode();return R(n)&&n.hasFormat("code")&&e.anchor.offset===n.getTextContentSize()&&(t=!0),!1},ae),e.registerCommand(re,t=>{if(t.ctrlKey||t.metaKey||t.altKey)return!1;const n=t.key;if(1!==n.length)return!1;const o=A();if(!z(o)||!o.isCollapsed())return!1;const i=o.anchor.getNode();if(!R(i)||i.hasFormat("code"))return!1;if(0!==o.anchor.offset)return!1;const l=i.getPreviousSibling();if(!R(l)||!l.hasFormat("code"))return!1;t.preventDefault();const r=l.getKey();return e.update(()=>{const e=$(r);if(!R(e)||!e.hasFormat("code"))return;e.setTextContent(e.getTextContent()+n);const t=e.getTextContentSize();e.select(t,t)}),!0},ae),e.registerUpdateListener(({editorState:n})=>{t&&(t=!1,n.read(()=>{const t=A();z(t)&&e.update(()=>{const e=A();if(!z(e))return;const t=e.anchor.getNode(),n=e=>R(e)&&0===e.getTextContentSize()&&e.hasFormat("code");if(R(t))if(n(t))t.setFormat(0);else{let e=t.getPreviousSibling();for(;e&&R(e)&&0===e.getTextContentSize();)e.hasFormat("code")&&e.setFormat(0),e=e.getPreviousSibling()}else if(E(t))if(0===t.getChildrenSize())e.hasFormat("code")&&e.setFormat(0);else{const e=t.getFirstChild();n(e)&&R(e)&&e.setFormat(0)}R(t)&&t.hasFormat("code")||e.hasFormat("code")&&e.setFormat(0)})}))}))},[e]),null}function ko(e,t){const n=se(t)?t.body.childNodes:t.childNodes;let o=[];const i=[];for(const t of n)if(!_o.has(t.nodeName)){const n=Lo(t,e,i,!1);null!==n&&(o=o.concat(n))}return function(e){for(const t of e)t.getNextSibling()instanceof de&&t.insertAfter(ue());for(const t of e){const e=t.getChildren();for(const n of e)t.insertBefore(n);t.remove()}}(i),o}function No(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=P().getChildren();for(let i=0;i<o.length;i++)So(e,o[i],n,t);return n.innerHTML}function So(e,t,n,o=null){let i=null===o||t.isSelected(o);const l=E(t)&&t.excludeFromCopy("html");let r=t;if(null!==o){let e=he(t);e=R(e)&&null!==o?function(e,t){const n=e.getStartEndPoints();if(t.isSelected(e)&&!W(t)&&null!==n){const[o,i]=n,l=e.isBackward(),r=o.getNode(),a=i.getNode(),c=t.is(r),s=t.is(a);if(c||s){const[n,o]=O(e),i=r.is(a),c=t.is(l?a:r),s=t.is(l?r:a);let d,u=0;i?(u=n>o?o:n,d=n>o?n:o):c?(u=l?o:n,d=void 0):s&&(u=0,d=l?n:o),t.__text=t.__text.slice(u,d)}}return t}(o,e):e,r=e}const a=E(r)?r.getChildren():[],c=pe(e,r.getType());let s;s=c&&void 0!==c.exportDOM?c.exportDOM(e,r):r.exportDOM(e);const{element:d,after:u}=s;if(!d)return!1;const h=document.createDocumentFragment();for(let n=0;n<a.length;n++){const l=a[n],r=So(e,l,h,o);!i&&E(t)&&r&&t.extractWithChild(l,o,"html")&&(i=!0)}if(i&&!l){if((me(d)||ge(d))&&d.append(h),n.append(d),u){const e=u.call(r,d);e&&(ge(d)?d.replaceChildren(e):d.replaceWith(e))}}else n.append(h);return i}const _o=new Set(["STYLE","SCRIPT"]);function Lo(e,t,n,o,i=new Map,l){let r=[];if(_o.has(e.nodeName))return r;let a=null;const c=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),s=c?c(e):null;let d=null;if(null!==s){d=s.after;const t=s.node;if(a=Array.isArray(t)?t[t.length-1]:t,null!==a){for(const[,e]of i)if(a=e(a,l),!a)break;a&&r.push(...Array.isArray(t)?t:[a])}null!=s.forChild&&i.set(e.nodeName,s.forChild)}const u=e.childNodes;let h=[];const p=(null==a||!D(a))&&(null!=a&&fe(a)||o);for(let e=0;e<u.length;e++)h.push(...Lo(u[e],t,n,p,new Map(i),a));return null!=d&&(h=d(h)),be(e)&&(h=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(fe(r))o&&!r.getFormat()&&r.setFormat(o),i.push(r);else if(l.push(r),e===t.length-1||e<t.length-1&&fe(t[e+1])){const e=n();e.setFormat(o),e.append(...l),i.push(e),l=[]}}return i}(e,h,p?()=>{const e=new de;return n.push(e),e}:B)),null==a?h.length>0?r=r.concat(h):be(e)&&function(e){return null!=e.nextSibling&&null!=e.previousSibling&&(ye(e.nextSibling)&&ye(e.previousSibling))}(e)&&(r=r.concat(ue())):E(a)&&a.append(...h),r}function To({value:t,onChange:n}){const[o]=Ot(),[i,l]=d(!0);return c(()=>{t&&i&&(l(!1),o.update(()=>{if(No(o)!==t){P().clear();const e=(new DOMParser).parseFromString(t,"text/html"),n=ko(o,e);Z(n)}}))},[o,t,i]),c(()=>{l(!0)},[t]),e(tn,{onChange:e=>{e.read(()=>{n(No(o))})}})}function Eo({applyRef:n,onExit:o}){const[i]=Ot(),[l,r]=d(()=>i.getEditorState().read(()=>No(i))),s=a(l),u=e=>{e!==s.current&&(i.update(()=>{const t=P();if(t.clear(),t.selectEnd(),e){const t=(new DOMParser).parseFromString(e,"text/html"),n=ko(i,t);n.length>0&&Z(n)}}),s.current=e)};return c(()=>(n.current=()=>{u(l),o()},()=>{n.current=null}),[n,l,o,i]),t("div",{className:"lexical-source-view",children:[e("textarea",{className:"lexical-source-textarea",value:l,onChange:e=>r(e.target.value),"aria-label":"HTML source",spellCheck:!1}),t("div",{className:"lexical-source-actions",children:[e(jn,{content:"Apply HTML to the editor",direction:"top",children:t("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>u(l),children:[e(Bt,{size:16}),e("span",{className:"label",children:"Update"})]})}),e("button",{type:"button",className:"lexical-btn heading-trigger toolbar",onClick:()=>{u(l),o()},children:"Done"})]})]})}function Ao({showWordCount:n=!0,showCharCount:o=!0,rightSlot:i}){const[l]=Ot(),[r,a]=d({words:0,chars:0});return c(()=>{const e=e=>{e.read(()=>{const e=P().getTextContent(),t=e.trim();a({words:t?t.split(/\s+/).length:0,chars:e.length})})};return e(l.getEditorState()),l.registerUpdateListener(({editorState:t})=>{e(t)})},[l]),t("div",{className:"lexical-status-bar",children:[n&&t("span",{children:[r.words," words"]}),o&&t("span",{children:[r.chars," characters"]}),i&&e("div",{className:"lexical-status-bar-right",children:i})]})}function Fo({theme:n,toolbarStyle:o,onThemeChange:i,onToolbarStyleChange:l}){const r="normal"===o?"collapse":o,a=[{value:"light",label:"Light theme",icon:e(wt,{})},{value:"dark",label:"Dark theme",icon:e(Ct,{})},{value:"system",label:"Follow system theme",icon:e(Jt,{})}],c=[{value:"wrap",label:"Toolbar: wrap to new lines",icon:e(qt,{})},{value:"collapse",label:'Toolbar: collapse into "..."',icon:e(xt,{})},{value:"scrollbar",label:"Toolbar: scroll in one row",icon:e(Xe,{})}];return t("div",{className:"lexical-display-controls",role:"group","aria-label":"Display settings",children:[e("div",{className:"lte-mini-seg",role:"radiogroup","aria-label":"Theme",children:a.map(t=>e(jn,{content:t.label,direction:"top",children:e("button",{type:"button",role:"radio","aria-checked":n===t.value,"aria-label":t.label,className:"lte-mini-btn btn "+(n===t.value?"active":""),onClick:()=>i?.(t.value),children:t.icon})},t.value))}),e("div",{className:"lte-mini-seg",role:"radiogroup","aria-label":"Toolbar style",children:c.map(t=>e(jn,{content:t.label,direction:"top",children:e("button",{type:"button",role:"radio","aria-checked":r===t.value,"aria-label":t.label,className:"lte-mini-btn btn "+(r===t.value?"active":""),onClick:()=>l?.(t.value),children:t.icon})},t.value))})]})}const Do=({id:e})=>new Io({id:e}),Mo="data-lexical-youtube",zo="315px",Ro="560px",Wo=e=>`https://www.youtube-nocookie.com/embed/${e}`,Oo=e=>{const t=e?.getAttribute(Mo);if(!t)return null;return{node:Do({id:t})}};class Io extends Q{constructor({id:e,key:t}){super(t),this.__id=e}static getType(){return"youtube"}static clone(e){return new Io({id:e.__id,key:e.getKey()})}static importJSON(e){return Do({id:e.id})}exportJSON(){return{id:this.__id,type:"youtube",version:1}}decorate(){return e("iframe",{height:zo,width:Ro,src:Wo(this.__id),frameBorder:"0",allowFullScreen:!0})}createDOM(){return document.createElement("div")}exportDOM(){const e=document.createElement("iframe");return e.setAttribute(Mo,this.__id),e.setAttribute("height",zo),e.setAttribute("width",Ro),e.setAttribute("src",Wo(this.__id)),{element:e}}static importDOM(){return{iframe:()=>({conversion:Oo,priority:0})}}}class Ho extends ve{constructor(e,t){super(e,t)}static getType(){return"extended-text"}static clone(e){return new Ho(e.__text,e.__key)}static importDOM(){const e=ve.importDOM();return{...e,span:()=>({conversion:Uo(e?.span),priority:1}),div:()=>({conversion:Uo(e?.div),priority:1}),p:()=>({conversion:Uo(e?.p),priority:1}),b:()=>({conversion:Uo(e?.b),priority:1}),strong:()=>({conversion:Uo(e?.strong),priority:1}),i:()=>({conversion:Uo(e?.i),priority:1}),em:()=>({conversion:Uo(e?.em),priority:1}),u:()=>({conversion:Uo(e?.u),priority:1}),s:()=>({conversion:Uo(e?.s),priority:1}),strike:()=>({conversion:Uo(e?.strike),priority:1}),code:()=>({conversion:Uo(e?.code),priority:1})}}static importJSON(e){return function(e=""){return X(new Ho(e))}().updateFromJSON(e)}isSimpleText(){return"extended-text"===this.__type&&0===this.__mode}}function Uo(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(R(i)&&l.length>0){const e=l.join("; ");return i.setStyle(e)}return i}}}}const Po={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"}},$o=i.memo(function({name:n,value:i,onChange:l,placeholder:r,maxWidth:s=null,height:u=null,onImageUpload:p,showWordCount:m=!0,showCharCount:g=!0,theme:f="system",toolbarStyle:v="collapse",showDisplayControls:x=!0,onThemeChange:_,onToolbarStyleChange:L}){const[T,E]=d(!1),[A,F]=d(!1),D=a(null),[M,z]=d(!1),[R,W]=d(f),[O,I]=d("normal"===v?"collapse":v);c(()=>{W(f)},[f]),c(()=>{I("normal"===v?"collapse":v)},[v]),c(()=>{if("system"!==R||"undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-color-scheme: dark)");z(e.matches);const t=e=>z(e.matches);return e.addEventListener?(e.addEventListener("change",t),()=>e.removeEventListener("change",t)):(e.addListener(t),()=>e.removeListener(t))},[R]);const H="dark"===R||"system"===R&&M;c(()=>{if(!A)return;const e=e=>{"Escape"===e.key&&F(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[A]);const U=h(()=>({namespace:n,theme:Po,onError:e=>{console.error("Lexical error:",e)},nodes:[Ho,{replace:ve,with:e=>new Ho(e.__text),withKlass:Ho},b,w,C,Se,Le,y,Ut,oo,Io,go,Ee,Ue,Pe,$e]}),[n]);return e("div",{className:`lexical-text-editor lexical-editor-container ${A?"lexical-fullscreen":""} ${H?"lexical-dark":""}`,style:{maxWidth:A?"none":s||"1090px"},children:t(o,{initialConfig:U,children:[e("div",{className:"lexical-toolbar-container",children:e(wo,{value:i,onImageUpload:p,sourceView:T,onToggleSourceView:()=>{E(e=>!e||(D.current?.(),!1))},fullscreen:A,onToggleFullscreen:()=>{F(e=>!e)},toolbarStyle:O})}),e("div",{className:"lexical-editor-inner",style:T?{display:"none"}:void 0,children:e(k,{contentEditable:e(N,{className:"lexical-content-editable",style:{height:u||"500px"}}),placeholder:e("div",{className:"lexical-placeholder",children:r||"Some Text"}),ErrorBoundary:S})}),T&&e(Eo,{applyRef:D,onExit:()=>E(!1)}),(m||g||x)&&e(Ao,{showWordCount:m,showCharCount:g,rightSlot:x?e(Fo,{theme:R,toolbarStyle:O,onThemeChange:e=>{W(e),_?.(e)},onToolbarStyleChange:e=>{I(e),L?.(e)}}):void 0}),e(xe,{}),e(we,{}),e(Fe,{}),e(Ae,{}),e(en,{}),e(Co,{}),e(To,{value:i,onChange:l})]})})});export{$o as LexicalTextEditor};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|