@innoviatech/lexical-text-editor 0.0.5 → 0.0.6

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.
Files changed (38) hide show
  1. package/README.md +161 -0
  2. package/package.json +1 -1
  3. package/src/components/ui/popover.tsx +1 -1
  4. package/dist/components/AlignmentSelectionList.d.ts +0 -9
  5. package/dist/components/ColorPicker.d.ts +0 -7
  6. package/dist/components/ContentPreview.d.ts +0 -10
  7. package/dist/components/DropdownList.d.ts +0 -9
  8. package/dist/components/HeadingSelectionList.d.ts +0 -9
  9. package/dist/components/ImageComponent.d.ts +0 -11
  10. package/dist/components/InsertDropdownList.d.ts +0 -1
  11. package/dist/components/LexicalTextEditor.d.ts +0 -9
  12. package/dist/components/LinkModal.d.ts +0 -9
  13. package/dist/components/Separator.d.ts +0 -1
  14. package/dist/components/ui/button.d.ts +0 -14
  15. package/dist/components/ui/command.d.ts +0 -18
  16. package/dist/components/ui/dialog.d.ts +0 -15
  17. package/dist/components/ui/input.d.ts +0 -3
  18. package/dist/components/ui/popover.d.ts +0 -7
  19. package/dist/components/ui/scroll-area.d.ts +0 -5
  20. package/dist/components/ui/tooltip.d.ts +0 -7
  21. package/dist/constants/index.d.ts +0 -71
  22. package/dist/index.d.ts +0 -12
  23. package/dist/index.esm.js +0 -2
  24. package/dist/index.esm.js.map +0 -1
  25. package/dist/index.js +0 -2
  26. package/dist/index.js.map +0 -1
  27. package/dist/lib/utils.d.ts +0 -1
  28. package/dist/nodes/ImageNode.d.ts +0 -43
  29. package/dist/nodes/VideoNode.d.ts +0 -30
  30. package/dist/nodes/YoutubeNode.d.ts +0 -25
  31. package/dist/plugins/ColorPlugin.d.ts +0 -1
  32. package/dist/plugins/CustomOnChangePlugin.d.ts +0 -6
  33. package/dist/plugins/ImagePlugin.d.ts +0 -1
  34. package/dist/plugins/ListPlugin.d.ts +0 -5
  35. package/dist/plugins/ToolbarPlugin.d.ts +0 -3
  36. package/dist/plugins/VideoPlugin.d.ts +0 -1
  37. package/dist/style.css +0 -2
  38. package/innoviatech-lexical-text-editor-0.0.5.tgz +0 -0
package/README.md ADDED
@@ -0,0 +1,161 @@
1
+ # @innoviatech/lexical-text-editor
2
+
3
+ A powerful, customizable rich text editor component built with Lexical, React, and Tailwind CSS. Features a modern toolbar, image support, video embedding, and comprehensive text formatting options.
4
+
5
+ ## Features
6
+
7
+ - 🎨 **Rich Text Editing** — Bold, italic, underline, strikethrough, code blocks
8
+ - 📝 **Text Formatting** — Headers, paragraphs, lists (bulleted & numbered), quotes
9
+ - 🔗 **Link Support** — Insert and edit hyperlinks
10
+ - 🖼️ **Media Embedding** — Images and YouTube videos with resizing
11
+ - 🎯 **Customizable Toolbar** — Modern, intuitive interface
12
+ - 🎨 **Color Picker** — Text and background color options
13
+ - 📱 **Responsive Design** — Works on desktop and mobile
14
+ - 🎪 **Radix UI Components** — Accessible, well-designed UI elements
15
+ - ⚡ **TypeScript Support** — Fully typed for better development experience
16
+
17
+ ---
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ npm install @innoviatech/lexical-text-editor
23
+ ```
24
+
25
+ ### Peer Dependencies
26
+
27
+ This package requires several peer dependencies. Make sure to install them in your project:
28
+
29
+ ```bash
30
+ # UI dependencies (required for full functionality)
31
+ npm install react-icons lucide-react @radix-ui/react-slot @radix-ui/react-tooltip @radix-ui/react-popover @radix-ui/react-dialog clsx tailwind-merge class-variance-authority react-color
32
+ ```
33
+
34
+
35
+
36
+
37
+
38
+ ## Quick Start
39
+
40
+ ```tsx
41
+ import React, { useState } from 'react';
42
+ import { LexicalTextEditor } from '@innoviatech/lexical-text-editor';
43
+ import '@innoviatech/lexical-text-editor/style.css';
44
+
45
+ function App() {
46
+ const [content, setContent] = useState('');
47
+
48
+ return (
49
+ <div style={{ padding: '20px', maxWidth: '900px', margin: '0 auto' }}>
50
+ <LexicalTextEditor
51
+ name="my-editor"
52
+ value={content}
53
+ onChange={setContent}
54
+ placeholder="Start typing your content here..."
55
+ />
56
+ </div>
57
+ );
58
+ }
59
+
60
+ export default App;
61
+ ```
62
+
63
+ ---
64
+
65
+ ## Props
66
+
67
+ | Prop | Type | Required | Default | Description |
68
+ |-------------|-------------------------------------|----------|---------------|---------------------------------------------|
69
+ | `name` | `string` | Yes | — | Unique identifier for the editor instance |
70
+ | `value` | `string` | Yes | — | Current editor content (HTML string) |
71
+ | `onChange` | `(value: string) => void` | Yes | — | Callback fired when content changes |
72
+ | `placeholder`| `string` | No | `"Some Text"` | Placeholder text when editor is empty |
73
+
74
+ ---
75
+
76
+ ## Advanced Usage
77
+
78
+ ### With Initial Content
79
+
80
+ ```tsx
81
+ import React, { useState } from 'react';
82
+ import { LexicalTextEditor } from '@innoviatech/lexical-text-editor';
83
+ import '@innoviatech/lexical-text-editor/style.css';
84
+
85
+ function App() {
86
+ const [content, setContent] = useState('<p>Welcome to the editor!</p><ul><li>Feature 1</li><li>Feature 2</li></ul>');
87
+
88
+ const handleSave = () => {
89
+ console.log('Current content:', content);
90
+ };
91
+
92
+ return (
93
+ <div>
94
+ <LexicalTextEditor
95
+ name="content-editor"
96
+ value={content}
97
+ onChange={setContent}
98
+ placeholder="Write your content..."
99
+ />
100
+ <button onClick={handleSave}>Save Content</button>
101
+ </div>
102
+ );
103
+ }
104
+
105
+ export default App;
106
+ ```
107
+
108
+
109
+ ## Toolbar Features
110
+
111
+ - Text Formatting: Bold, Italic, Underline, Strikethrough
112
+ - Headings: H1–H6
113
+ - Lists: Bulleted and Numbered
114
+ - Alignment: Left, Center, Right, Justify
115
+ - Text Case: Uppercase, Lowercase, Capitalize
116
+ - Colors: Text & background color picker
117
+ - Media: Image upload, YouTube embedding, video node
118
+ - Links: Insert and edit hyperlinks
119
+ - Code: Inline code & code blocks
120
+ - Quotes: Blockquote formatting
121
+ - Undo/Redo, Clear formatting, Remove link
122
+
123
+ ---
124
+
125
+ ## Browser Support
126
+
127
+ - Chrome 90+
128
+ - Firefox 88+
129
+ - Safari 14+
130
+ - Edge 90+
131
+
132
+ ---
133
+
134
+ ## Troubleshooting
135
+
136
+ - **Missing peer dependencies:** install required packages
137
+ - **CSS not loading:** `import '@innoviatech/lexical-text-editor/style.css'`
138
+ - **Icons not showing:** verify `react-icons` and `lucide-react`
139
+ - **Toolbar not working:** ensure Radix UI peer deps installed
140
+
141
+ ---
142
+
143
+ ## Version Compatibility
144
+
145
+ - React 18+
146
+ - Lexical 0.36.0+
147
+ - TypeScript 5.0+
148
+
149
+ ---
150
+
151
+ ## License
152
+
153
+ MIT © Innoviatech
154
+
155
+ ---
156
+
157
+ ## Support
158
+
159
+ For issues and feature requests, open an issue on GitHub.
160
+
161
+ Built with ❤️ by Innoviatech
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innoviatech/lexical-text-editor",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.esm.js",
@@ -28,7 +28,7 @@ function PopoverContent({
28
28
  align={align}
29
29
  sideOffset={sideOffset}
30
30
  className={cn(
31
- "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
31
+ "bg-white text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
32
32
  className
33
33
  )}
34
34
  {...props}
@@ -1,9 +0,0 @@
1
- import { RichTextAction } from "../constants/index";
2
- interface Props {
3
- onAction: (id: RichTextAction) => void;
4
- alignmentSelectionMap: {
5
- [id: string]: boolean;
6
- };
7
- }
8
- export declare function AlignmentSelectionList({ onAction, alignmentSelectionMap }: Props): import("react/jsx-runtime").JSX.Element;
9
- export {};
@@ -1,7 +0,0 @@
1
- interface ColorPickerProps {
2
- color: string;
3
- onChange: (color: string) => void;
4
- icon: React.ReactElement;
5
- }
6
- export default function ColorPicker({ color, onChange, icon }: ColorPickerProps): import("react/jsx-runtime").JSX.Element;
7
- export {};
@@ -1,10 +0,0 @@
1
- type HtmlPreviewProps = {
2
- value: string;
3
- };
4
- export declare function HtmlPreview({ value }: HtmlPreviewProps): import("react/jsx-runtime").JSX.Element;
5
- type ContentPreviewDialogProps = {
6
- value: string;
7
- triggerLabel?: string;
8
- };
9
- export default function ContentPreviewDialog({ value, triggerLabel }: ContentPreviewDialogProps): import("react/jsx-runtime").JSX.Element;
10
- export {};
@@ -1,9 +0,0 @@
1
- import { RichTextAction } from "../constants/index";
2
- interface Props {
3
- onAction: (id: RichTextAction) => void;
4
- selectionMap: {
5
- [id: string]: boolean;
6
- };
7
- }
8
- export declare function DropdownList({ onAction, selectionMap }: Props): import("react/jsx-runtime").JSX.Element;
9
- export {};
@@ -1,9 +0,0 @@
1
- import { type HeadingTagType } from '@lexical/rich-text';
2
- interface Props {
3
- updateHeading: (heading: HeadingTagType | "normal") => void;
4
- headingSelectionMap: {
5
- [id: string]: boolean;
6
- };
7
- }
8
- export declare function HeadingSelectionList({ updateHeading, headingSelectionMap }: Props): import("react/jsx-runtime").JSX.Element;
9
- export {};
@@ -1,11 +0,0 @@
1
- import { type NodeKey } from "lexical";
2
- type ImageComponentProps = {
3
- src: string;
4
- altText: string;
5
- nodeKey: NodeKey;
6
- width?: number | "inherit";
7
- height?: number | "inherit";
8
- maxWidth: number;
9
- };
10
- export declare const ImageComponent: React.FC<ImageComponentProps>;
11
- export {};
@@ -1 +0,0 @@
1
- export declare function InsertDropdownList({}: {}): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +0,0 @@
1
- import React from "react";
2
- import "../styles/lexical-editor.css";
3
- export interface LexiTexProps {
4
- value: string;
5
- onChange: (value: string) => void;
6
- placeholder?: string;
7
- name: string;
8
- }
9
- export declare const LexicalTextEditor: React.FC<LexiTexProps>;
@@ -1,9 +0,0 @@
1
- interface LinkEditorProps {
2
- linkUrl: string;
3
- setLinkUrl: React.Dispatch<React.SetStateAction<string>>;
4
- onConfirm: (url: string) => void;
5
- onCancel: () => void;
6
- removeLink: () => void;
7
- }
8
- export default function LinkModal({ linkUrl, setLinkUrl, onConfirm, onCancel, removeLink, }: LinkEditorProps): import("react/jsx-runtime").JSX.Element;
9
- export {};
@@ -1 +0,0 @@
1
- export default function Separator(): import("react/jsx-runtime").JSX.Element;
@@ -1,14 +0,0 @@
1
- import * as React from "react";
2
- declare const buttonVariants: (props?: {
3
- variant?: "link" | "default" | "toolbar" | "toolbarActive" | "destructive" | "outline" | "secondary" | "ghost";
4
- size?: "icon" | "default" | "sm" | "lg";
5
- } & {
6
- className?: string;
7
- }) => string;
8
- interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
9
- variant?: "default" | "toolbar" | "toolbarActive" | "destructive" | "outline" | "secondary" | "ghost" | "link";
10
- size?: "default" | "sm" | "lg" | "icon";
11
- asChild?: boolean;
12
- }
13
- declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement>>;
14
- export { Button, buttonVariants };
@@ -1,18 +0,0 @@
1
- import * as React from "react";
2
- import { Command as CommandPrimitive } from "cmdk";
3
- import { Dialog } from "./dialog";
4
- declare function Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>): import("react/jsx-runtime").JSX.Element;
5
- declare function CommandDialog({ title, description, children, className, showCloseButton, ...props }: React.ComponentProps<typeof Dialog> & {
6
- title?: string;
7
- description?: string;
8
- className?: string;
9
- showCloseButton?: boolean;
10
- }): import("react/jsx-runtime").JSX.Element;
11
- declare function CommandInput({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Input>): import("react/jsx-runtime").JSX.Element;
12
- declare function CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>): import("react/jsx-runtime").JSX.Element;
13
- declare function CommandEmpty({ ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>): import("react/jsx-runtime").JSX.Element;
14
- declare function CommandGroup({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Group>): import("react/jsx-runtime").JSX.Element;
15
- declare function CommandSeparator({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Separator>): import("react/jsx-runtime").JSX.Element;
16
- declare function CommandItem({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Item>): import("react/jsx-runtime").JSX.Element;
17
- declare function CommandShortcut({ className, ...props }: React.ComponentProps<"span">): import("react/jsx-runtime").JSX.Element;
18
- export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandShortcut, CommandSeparator, };
@@ -1,15 +0,0 @@
1
- import * as React from "react";
2
- import * as DialogPrimitive from "@radix-ui/react-dialog";
3
- declare function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
4
- declare function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
5
- declare function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>): import("react/jsx-runtime").JSX.Element;
6
- declare function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>): import("react/jsx-runtime").JSX.Element;
7
- declare function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>): import("react/jsx-runtime").JSX.Element;
8
- declare function DialogContent({ className, children, showCloseButton, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
9
- showCloseButton?: boolean;
10
- }): import("react/jsx-runtime").JSX.Element;
11
- declare function DialogHeader({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
12
- declare function DialogFooter({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
13
- declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): import("react/jsx-runtime").JSX.Element;
14
- declare function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>): import("react/jsx-runtime").JSX.Element;
15
- export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, };
@@ -1,3 +0,0 @@
1
- import * as React from "react";
2
- declare function Input({ className, type, ...props }: React.ComponentProps<"input">): import("react/jsx-runtime").JSX.Element;
3
- export { Input };
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
- import * as PopoverPrimitive from "@radix-ui/react-popover";
3
- declare function Popover({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
4
- declare function PopoverTrigger({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
5
- declare function PopoverContent({ className, align, sideOffset, ...props }: React.ComponentProps<typeof PopoverPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
6
- declare function PopoverAnchor({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Anchor>): import("react/jsx-runtime").JSX.Element;
7
- export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
@@ -1,5 +0,0 @@
1
- import * as React from "react";
2
- import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
3
- declare function ScrollArea({ className, children, ...props }: React.ComponentProps<typeof ScrollAreaPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
4
- declare function ScrollBar({ className, orientation, ...props }: React.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>): import("react/jsx-runtime").JSX.Element;
5
- export { ScrollArea, ScrollBar };
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
- import * as TooltipPrimitive from "@radix-ui/react-tooltip";
3
- declare function TooltipProvider({ delayDuration, ...props }: React.ComponentProps<typeof TooltipPrimitive.Provider>): import("react/jsx-runtime").JSX.Element;
4
- declare function Tooltip({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
5
- declare function TooltipTrigger({ ...props }: React.ComponentProps<typeof TooltipPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
6
- declare function TooltipContent({ className, sideOffset, children, ...props }: React.ComponentProps<typeof TooltipPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
7
- export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
@@ -1,71 +0,0 @@
1
- export declare enum RichTextAction {
2
- Bold = "bold",
3
- Italics = "italics",
4
- Underline = "underline",
5
- Quote = "quote",
6
- Lowercase = "lowercase",
7
- Uppercase = "uppercase",
8
- Capitalize = "capitalize",
9
- Strikethrough = "strikethrough",
10
- Superscript = "superscript",
11
- Subscript = "subscript",
12
- Highlight = "highlight",
13
- Code = "code",
14
- Link = "link",
15
- LeftAlign = "leftAlign",
16
- CenterAlign = "centerAlign",
17
- RightAlign = "rightAlign",
18
- JustifyAlign = "justifyAlign",
19
- Divider = "divider",
20
- Undo = "undo",
21
- Redo = "redo"
22
- }
23
- export declare enum HeadingAction {
24
- Normal = "normal",
25
- H1 = "h1",
26
- H2 = "h2",
27
- H3 = "h3",
28
- H4 = "h4",
29
- H5 = "h5",
30
- H6 = "h6"
31
- }
32
- export declare const RICH_TEXT_FORMAT_OPTIONS: ({
33
- id: RichTextAction;
34
- icon: import("react/jsx-runtime").JSX.Element;
35
- label: string;
36
- fontSize?: undefined;
37
- } | {
38
- id: RichTextAction;
39
- icon: import("react/jsx-runtime").JSX.Element;
40
- label: string;
41
- fontSize: number;
42
- })[];
43
- export declare const RICH_TEXT_OPTIONS: ({
44
- id: RichTextAction;
45
- icon: import("react/jsx-runtime").JSX.Element;
46
- label: string;
47
- } | {
48
- id: RichTextAction;
49
- icon?: undefined;
50
- label?: undefined;
51
- })[];
52
- export declare const RICH_REDO_UNDO_OPTIONS: ({
53
- id: RichTextAction;
54
- icon: import("react/jsx-runtime").JSX.Element;
55
- label: string;
56
- } | {
57
- id: RichTextAction;
58
- icon?: undefined;
59
- label?: undefined;
60
- })[];
61
- export declare const RICH_ALIGNMENT_OPTIONS: {
62
- id: RichTextAction;
63
- icon: import("react/jsx-runtime").JSX.Element;
64
- label: string;
65
- }[];
66
- export declare const LOW_PRIORIRTY = 1;
67
- export declare const HEADINGS: {
68
- id: string;
69
- label: string;
70
- icon: import("react/jsx-runtime").JSX.Element;
71
- }[];
package/dist/index.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
-
3
- interface LexiTexProps {
4
- value: string;
5
- onChange: (value: string) => void;
6
- placeholder?: string;
7
- name: string;
8
- }
9
- declare const LexicalTextEditor: React.FC<LexiTexProps>;
10
-
11
- export { LexicalTextEditor };
12
- export type { LexiTexProps as LexicalTextEditorProps };
package/dist/index.esm.js DELETED
@@ -1,2 +0,0 @@
1
- import{jsx as e,jsxs as t,Fragment as i}from"react/jsx-runtime";import{LexicalComposer as n}from"@lexical/react/LexicalComposer";import*as r from"react";import o,{useState as a,useRef as l,useEffect as s,useCallback as c,useMemo as d}from"react";import{$isHeadingNode as u,$isQuoteNode as h,$createQuoteNode as m,$createHeadingNode as p,HeadingNode as g,QuoteNode as f}from"@lexical/rich-text";import{CodeHighlightNode as b,CodeNode as x}from"@lexical/code";import{RichTextPlugin as v}from"@lexical/react/LexicalRichTextPlugin";import{ContentEditable as y}from"@lexical/react/LexicalContentEditable";import{LexicalErrorBoundary as w}from"@lexical/react/LexicalErrorBoundary";import{HistoryPlugin as C}from"@lexical/react/LexicalHistoryPlugin";import{ListPlugin as N}from"@lexical/react/LexicalListPlugin";import{REMOVE_LIST_COMMAND as k,INSERT_ORDERED_LIST_COMMAND as _,INSERT_UNORDERED_LIST_COMMAND as A,$isListNode as z,ListNode as S,ListItemNode as L}from"@lexical/list";import{RxLetterCaseLowercase as T,RxLetterCaseUppercase as D,RxLetterCaseCapitalize as E}from"react-icons/rx";import{TbBold as O,TbItalic as M,TbUnderline as F}from"react-icons/tb";import{BsSuperscript as H,BsSubscript as U,BsChatSquareQuote as P,BsArrowCounterclockwise as R,BsArrowClockwise as I,BsJustifyLeft as K,BsTextCenter as B,BsJustifyRight as W,BsJustify as j,BsTextParagraph as J,BsTypeH1 as $,BsTypeH2 as Q,BsTypeH3 as q,BsTypeH4 as Y,BsTypeH5 as V,BsTypeH6 as X,BsListOl as G,BsListUl as Z}from"react-icons/bs";import{AiOutlineStrikethrough as ee,AiOutlineFontColors as te,AiOutlineBgColors as ie}from"react-icons/ai";import{IoCodeSlashOutline as ne,IoImageOutline as re}from"react-icons/io5";import{PiHighlighterLight as oe}from"react-icons/pi";import{useLexicalComposerContext as ae}from"@lexical/react/LexicalComposerContext";import{$createRangeSelection as le,$findMatchingParent as se,INTERNAL_$isBlock as ce,$isElementNode as de,$getSelection as ue,$setSelection as he,$isRootOrShadowRoot as me,$hasAncestor as pe,$isRangeSelection as ge,$isTextNode as fe,$isTokenOrSegmented as be,$getCharacterOffsets as xe,$isLeafNode as ve,$getPreviousSelection as ye,$caretRangeFromSelection as we,SELECTION_CHANGE_COMMAND as Ce,$getNodeByKey as Ne,DecoratorNode as ke,$applyNodeReplacement as _e,$insertNodes as Ae,CAN_REDO_COMMAND as ze,CAN_UNDO_COMMAND as Se,REDO_COMMAND as Le,UNDO_COMMAND as Te,FORMAT_ELEMENT_COMMAND as De,FORMAT_TEXT_COMMAND as Ee,$createParagraphNode as Oe,$getRoot as Me,isDOMDocumentNode as Fe,ArtificialNode__DO_NOT_USE as He,$createLineBreakNode as Ue,$cloneWithProperties as Pe,getRegisteredNode as Re,isHTMLElement as Ie,isDocumentFragment as Ke,$isBlockElementNode as Be,isBlockDomNode as We,isInlineDomNode as je}from"lexical";import{TOGGLE_LINK_COMMAND as Je,$isLinkNode as $e,LinkNode as Qe}from"@lexical/link";import{Slot as qe}from"@radix-ui/react-slot";import{cva as Ye}from"class-variance-authority";import{clsx as Ve}from"clsx";import{twMerge as Xe}from"tailwind-merge";import*as Ge from"@radix-ui/react-tooltip";import*as Ze from"@radix-ui/react-popover";import{HiChevronDown as et}from"react-icons/hi2";import{IoIosLink as tt}from"react-icons/io";import{Check as it,Pencil as nt,XIcon as rt,Upload as ot}from"lucide-react";import{TiDeleteOutline as at}from"react-icons/ti";import{SketchPicker as lt}from"react-color";import{createPortal as st}from"react-dom";import*as ct from"@radix-ui/react-dialog";import{FaYoutube as dt}from"react-icons/fa";import{VscPreview as ut}from"react-icons/vsc";import{LinkPlugin as ht}from"@lexical/react/LexicalLinkPlugin";import{OnChangePlugin as mt}from"@lexical/react/LexicalOnChangePlugin";var pt,gt;!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"}(pt||(pt={})),function(e){e.Normal="normal",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6"}(gt||(gt={}));const ft=[{id:pt.Lowercase,icon:e(T,{}),label:"Lowercase"},{id:pt.Uppercase,icon:e(D,{}),label:"Uppercase"},{id:pt.Capitalize,icon:e(E,{}),label:"Capitalize"},{id:pt.Strikethrough,icon:e(ee,{}),label:"Strikethrough"},{id:pt.Highlight,icon:e(oe,{}),label:"Highlight",fontSize:10},{id:pt.Superscript,icon:e(H,{}),label:"Superscript"},{id:pt.Subscript,icon:e(U,{}),label:"Subscript"}],bt=[{id:pt.Bold,icon:e(O,{}),label:"Bold"},{id:pt.Italics,icon:e(M,{}),label:"Italics"},{id:pt.Underline,icon:e(F,{}),label:"Underline"},{id:pt.Divider},{id:pt.Quote,icon:e(P,{}),label:"Quote"},{id:pt.Code,icon:e(ne,{}),label:"Code"}],xt=[{id:pt.Undo,icon:e(R,{}),label:"Undo"},{id:pt.Redo,icon:e(I,{}),label:"Redo"},{id:pt.Divider}],vt=[{id:pt.LeftAlign,icon:e(K,{}),label:"Left Align"},{id:pt.CenterAlign,icon:e(B,{}),label:"Center Align"},{id:pt.RightAlign,icon:e(W,{}),label:"Right Align"},{id:pt.JustifyAlign,icon:e(j,{}),label:"Justify Align"}],yt=[{id:"normal",label:"Normal",icon:e(J,{})},{id:"h1",label:"Heading 1",icon:e($,{})},{id:"h2",label:"Heading 2",icon:e(Q,{})},{id:"h3",label:"Heading 3",icon:e(q,{})},{id:"h4",label:"Heading 4",icon:e(Y,{})},{id:"h5",label:"Heading 5",icon:e(V,{})},{id:"h6",label:"Heading 6",icon:e(X,{})}];function wt(e,...t){const i=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",e);for(const e of t)n.append("v",e);throw i.search=n.toString(),Error(`Minified Lexical error #${e}; visit ${i.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const Ct=new Map;function Nt(e){let t=Ct.get(e);return void 0===t&&(t=function(e){const t={};if(!e)return t;const i=e.split(";");for(const e of i)if(""!==e){const[i,n]=e.split(/:([^]+)/);i&&n&&(t[i.trim()]=n.trim())}return t}(e),Ct.set(e,t)),t}function kt(e,t){(ge(e)?e.isCollapsed():fe(e)||de(e))||wt(280);const i=Nt(ge(e)?e.style:fe(e)?e.getStyle():e.getTextStyle()),n=Object.entries(t).reduce((t,[n,r])=>("function"==typeof r?t[n]=r(i[n],e):null===r?delete t[n]:t[n]=r,t),{...i}),r=function(e){let t="";for(const i in e)i&&(t+=`${i}: ${e[i]};`);return t}(n);ge(e)||fe(e)?e.setStyle(r):e.setTextStyle(r),Ct.set(r,n)}function _t(e,t){if(ge(e)&&e.isCollapsed()){kt(e,t);const i=e.anchor.getNode();de(i)&&i.isEmpty()&&kt(i,t)}!function(e){const t=ue();if(!t)return;const i=new Map,n=e=>i.get(e.getKey())||[0,e.getTextContentSize()];if(ge(t))for(const e of we(t).getTextSlices())e&&i.set(e.caret.origin.getKey(),e.getSliceIndices());const r=t.getNodes();for(const t of r){if(!fe(t)||!t.canHaveFormat())continue;const[i,r]=n(t);r!==i&&(be(t)||0===i&&r===t.getTextContentSize()?e(t):e(t.splitText(i,r)[0===i?0:1]))}ge(t)&&"text"===t.anchor.type&&"text"===t.focus.type&&t.anchor.key===t.focus.key&&function(e){if(e.isBackward()){const{anchor:t,focus:i}=e,{key:n,offset:r,type:o}=t;t.set(i.key,i.offset,i.type),i.set(n,r,o)}}(t)}(e=>{kt(e,t)})}function At(e,t){const i=e.getFormatType(),n=e.getIndent();i!==t.getFormatType()&&t.setFormat(i),n!==t.getIndent()&&t.setIndent(n)}function zt(e){return e.getNode().isAttached()}function St(e){let t=e;for(;null!==t&&!me(t);){const e=t.getLatest(),i=t.getParent();0===e.getChildrenSize()&&t.remove(!0),t=i}}function Lt(e,t,i=null){const n=e.getStartEndPoints(),r=n?n[0]:null,o=e.getNodes(),a=o.length;if(null!==r&&(0===a||1===a&&"element"===r.type&&0===r.getNode().getChildrenSize())){const e="text"===r.type?r.getNode().getParentOrThrow():r.getNode(),n=e.getChildren();let o=t();return o.setFormat(e.getFormatType()),o.setIndent(e.getIndent()),n.forEach(e=>o.append(e)),i&&(o=i.append(o)),void e.replace(o)}let l=null,s=[];for(let n=0;n<a;n++){const r=o[n];me(r)?(Tt(e,s,s.length,t,i),s=[],l=r):null===l||null!==l&&pe(r,l)?s.push(r):(Tt(e,s,s.length,t,i),s=[r])}Tt(e,s,s.length,t,i)}function Tt(e,t,i,n,r=null){if(0===t.length)return;const o=t[0],a=new Map,l=[];let s=de(o)?o:o.getParentOrThrow();s.isInline()&&(s=s.getParentOrThrow());let c=!1;for(;null!==s;){const e=s.getPreviousSibling();if(null!==e){s=e,c=!0;break}if(s=s.getParentOrThrow(),me(s))break}const d=new Set;for(let e=0;e<i;e++){const i=t[e];de(i)&&0===i.getChildrenSize()&&d.add(i.getKey())}const u=new Set;for(let e=0;e<i;e++){const i=t[e];let r=i.getParent();if(null!==r&&r.isInline()&&(r=r.getParent()),null!==r&&ve(i)&&!u.has(i.getKey())){const e=r.getKey();if(void 0===a.get(e)){const t=n();t.setFormat(r.getFormatType()),t.setIndent(r.getIndent()),l.push(t),a.set(e,t),r.getChildren().forEach(e=>{t.append(e),u.add(e.getKey()),de(e)&&e.getChildrenKeys().forEach(e=>u.add(e))}),St(r)}}else if(d.has(i.getKey())){de(i)||wt(179);const e=n();e.setFormat(i.getFormatType()),e.setIndent(i.getIndent()),l.push(e),i.remove(!0)}}if(null!==r)for(let e=0;e<l.length;e++){const t=l[e];r.append(t)}let h=null;if(me(s))if(c)if(null!==r)s.insertAfter(r);else for(let e=l.length-1;e>=0;e--){const t=l[e];s.insertAfter(t)}else{const e=s.getFirstChild();if(de(e)&&(s=e),null===e)if(r)s.append(r);else for(let e=0;e<l.length;e++){const t=l[e];s.append(t),h=t}else if(null!==r)e.insertBefore(r);else for(let t=0;t<l.length;t++){const i=l[t];e.insertBefore(i),h=i}}else if(r)s.insertAfter(r);else for(let e=l.length-1;e>=0;e--){const t=l[e];s.insertAfter(t),h=t}const m=ye();ge(m)&&zt(m.anchor)&&zt(m.focus)?he(m.clone()):null!==h?h.selectEnd():e.dirty=!0}function Dt(e,t,i){const n=Nt(e.getStyle());return null!==n&&n[t]||i}function Et(e,t,i=""){let n=null;const r=e.getNodes(),o=e.anchor,a=e.focus,l=e.isBackward(),s=l?a.offset:o.offset,c=l?a.getNode():o.getNode();if(ge(e)&&e.isCollapsed()&&""!==e.style){const i=Nt(e.style);if(null!==i&&t in i)return i[t]}for(let e=0;e<r.length;e++){const o=r[e];if((0===e||0!==s||!o.is(c))&&fe(o)){const e=Dt(o,t,i);if(null===n)n=e;else if(n!==e){n="";break}}}return null===n?i:n}const Ot="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,Mt=Ot&&"documentMode"in document?document.documentMode:null;function Ft(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function Ht(...e){return Xe(Ve(e))}Ot&&"InputEvent"in window&&!Mt&&new window.InputEvent("input");const Ut=Ye("cursor-pointer inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",toolbar:"bg-transparent hover:bg-slate-100/80 text-gray-600",toolbarActive:"bg-slate-100 text-gray-900 ",destructive:"bg-destructive text-white hover:bg-destructive/90",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-2",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}}),Pt=r.forwardRef(({className:t,variant:i,size:n,asChild:r=!1,...o},a)=>e(r?qe:"button",{"data-slot":"button",className:Ht(Ut({variant:i,size:n,className:t})),ref:a,...o}));function Rt({delayDuration:t=0,...i}){return e(Ge.Provider,{"data-slot":"tooltip-provider",delayDuration:t,...i})}function It({...t}){return e(Rt,{children:e(Ge.Root,{"data-slot":"tooltip",...t})})}function Kt({...t}){return e(Ge.Trigger,{"data-slot":"tooltip-trigger",...t})}function Bt({className:i,sideOffset:n=0,children:r,...o}){return e(Ge.Portal,{children:t(Ge.Content,{"data-slot":"tooltip-content",sideOffset:n,className:Ht("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",i),...o,children:[r,e(Ge.Arrow,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}function Wt({...t}){return e(Ze.Root,{"data-slot":"popover",...t})}function jt({...t}){return e(Ze.Trigger,{"data-slot":"popover-trigger",...t})}function Jt({className:t,align:i="center",sideOffset:n=4,...r}){return e(Ze.Portal,{children:e(Ze.Content,{"data-slot":"popover-content",align:i,sideOffset:n,className:Ht("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...r})})}function $t({onAction:i,selectionMap:n}){const[r,o]=a(!1);return t(Wt,{open:r,onOpenChange:e=>o(e),children:[e(jt,{asChild:!0,children:t(Pt,{variant:r?"toolbarActive":"toolbar",onClick:()=>o(!r),size:"icon",className:"size-8 w-fit p-2 select-none border-[1px] border-gray-100",children:[e("span",{children:"Aa"})," ",e(et,{className:" transition-normal duration-100 "+(r?"rotate-180":"rotate-0")})]})}),e(Jt,{className:"p-2 w-fit flex flex-col items-start gap-1",children:ft.map(({id:r,label:o,icon:a})=>t(Pt,{variant:n[r]?"toolbarActive":"toolbar",onClick:()=>i(r),size:"icon",className:"size-8 w-full flex justify-start py-2 px-3 select-none",children:[a," ",e("span",{className:"ml-2",children:o})]},r))})]})}function Qt(){return e("div",{className:"w-[1px] h-[20px] mx-[2px] bg-gray-300 shrink-0"})}function qt({updateHeading:i,headingSelectionMap:n}){const r=yt.find(e=>n[e.id]),[o,l]=a(!1);return t(Wt,{open:o,onOpenChange:e=>l(e),children:[e(jt,{asChild:!0,children:t(Pt,{variant:o?"toolbarActive":"toolbar",onClick:()=>l(!o),size:"icon",className:"size-8 w-fit p-2 select-none min-w-[130px] border-[1px] border-gray-100",children:[r?.icon,e("span",{children:r?.label})," ",e(et,{className:" transition-normal duration-100 "+(o?"rotate-180":"rotate-0")})]})}),e(Jt,{align:"start",className:"p-2 w-fit flex flex-col items-start gap-1",children:yt.map(({id:r,label:o,icon:a})=>t(Pt,{variant:n[r]?"toolbarActive":"toolbar",onClick:()=>i(r),size:"icon",className:"size-8 w-full flex justify-start py-2 px-3 select-none",children:[a," ",e("span",{className:"ml-2",children:o})]},r))})]})}function Yt({className:t,type:i,...n}){return e("input",{type:i,"data-slot":"input",className:Ht("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...n})}function Vt({linkUrl:i,setLinkUrl:n,onConfirm:r,onCancel:o,removeLink:c}){const[d,u]=a(!1),h=l(null),m=l(null);return s(()=>{"https://"===i&&u(!0)},[i]),s(()=>{d&&m.current?.focus()},[d]),s(()=>{const e=e=>{h.current&&!h.current.contains(e.target)&&o()};return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[o]),t("div",{ref:h,className:Ht("absolute z-[9999] top-[100px] right-[20px]","bg-white shadow-lg rounded-xl px-1.5 py-1 sm:px-3 sm:py-2 flex items-center space-x-2","border border-gray-200"),children:[e("div",{className:"flex-1 min-w-[200px]",children:d?e(Yt,{ref:m,className:"h-8 text-sm",value:i,onChange:e=>n(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),r(i),u(!1)):"Escape"===e.key&&(e.preventDefault(),u(!1),o())}}):e("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 text-sm underline truncate block max-w-full text-start",children:i})}),t("div",{children:[e(Pt,{variant:"ghost",size:"icon",onMouseDown:e=>e.preventDefault(),onClick:()=>{d?(r(i),u(!1)):u(!0)},className:"h-8 w-8",children:e(d?it:nt,{className:"h-4 w-4"})}),e(Pt,{variant:"ghost",size:"icon",onMouseDown:e=>e.preventDefault(),onClick:c,className:"h-8 w-8",children:e(at,{className:"h-4 w-4"})})]})]})}function Xt({onAction:i,alignmentSelectionMap:n}){const r=vt.find(e=>n[e.id]),[o,l]=a(!1);return t(Wt,{open:o,onOpenChange:e=>l(e),children:[e(jt,{asChild:!0,children:t(Pt,{variant:o?"toolbarActive":"toolbar",onClick:()=>l(!o),size:"icon",className:"size-8 w-fit p-2 select-none min-w-[145px] border-[1px] border-gray-100",children:[r?.icon,e("span",{children:r?.label})," ",e(et,{className:" transition-normal duration-100 "+(o?"rotate-180":"rotate-0")})]})}),e(Jt,{align:"start",className:"p-2 w-fit flex flex-col items-start gap-1",children:vt.map(({id:r,label:o,icon:a})=>t(Pt,{variant:n[r]?"toolbarActive":"toolbar",onClick:()=>i(r),size:"icon",className:"size-8 w-full flex justify-start py-2 px-3 select-none",children:[a," ",e("span",{className:"ml-2",children:o})]},r))})]})}function Gt({color:i,onChange:n,icon:r}){const[o,c]=a(!1),d=l(null),u=l(null);s(()=>{const e=e=>{u.current&&!u.current.contains(e.target)&&d.current&&!d.current.contains(e.target)&&c(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);return t("div",{className:"relative inline-block",children:[e(Pt,{ref:d,variant:"ghost",size:"icon",className:"rounded-md text-gray-700 hover:bg-gray-200","aria-label":"Change Color",onClick:()=>c(e=>!e),children:r}),o&&st(e("div",{ref:u,className:"\n absolute z-50 p-2 bg-transparent rounded-md select-none\n transition-all duration-200\n origin-top-left w-fit\n "+(o?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 -translate-y-2 pointer-events-none"),style:{top:d.current?.getBoundingClientRect().bottom,left:d.current?.getBoundingClientRect().left,position:"absolute"},onMouseDown:e=>e.preventDefault(),children:e(lt,{color:i,onChangeComplete:e=>{n(e.hex)}})}),document.body)]})}function Zt(){const[n]=ae(),[{color:r,bgColor:o},l]=a({color:"#000",bgColor:"#fff"}),c=()=>{const e=ue();if(ge(e)){const t=Et(e,"color","#000"),i=Et(e,"background","#fff");l({color:t,bgColor:i})}};s(()=>Ft(n.registerUpdateListener(({editorState:e})=>{e.read(()=>{c()})}),n.registerCommand(Ce,()=>(c(),!1),1)),[n]);const d=({property:e,color:t})=>{n.update(()=>{const i=ue();i&&_t(i,{[e]:t})})};return t(i,{children:[e(Gt,{color:r,onChange:e=>{d({property:"color",color:e})},icon:e(te,{})}),e(Gt,{color:o,onChange:e=>{d({property:"background",color:e})},icon:e(ie,{})})]})}function ei({blockType:n}){const[r]=ae();return t(i,{children:[t(It,{delayDuration:700,children:[e(Kt,{asChild:!0,children:e(Pt,{variant:"ol"===n?"toolbarActive":"toolbar",size:"icon",className:"size-8","aria-label":"Add ordered list",onClick:()=>{"ol"===n?r.dispatchCommand(k,void 0):r.dispatchCommand(_,void 0)},children:e(G,{})})}),e(Bt,{side:"bottom",children:"Ordered list"})]}),t(It,{delayDuration:700,children:[e(Kt,{asChild:!0,children:e(Pt,{variant:"ul"===n?"toolbarActive":"toolbar",size:"icon",className:"size-8","aria-label":"Add unordered list",onClick:()=>{"ul"===n?r.dispatchCommand(k,void 0):r.dispatchCommand(A,void 0)},children:e(Z,{})})}),e(Bt,{side:"bottom",children:"Unordered list"})]})]})}Pt.displayName="Button";const ti=({src:i,altText:n,nodeKey:r,width:o,height:s,maxWidth:c})=>{const[d]=ae(),[u,h]=a({width:"number"==typeof o?o:c,height:"number"==typeof s?s:"auto"}),m=l(null),p=l(null),g=e=>{if(!p.current)return;const t=e.clientX-p.current.x,i=Math.min(c,Math.max(50,p.current.width+t)),n=i/p.current.width*p.current.height||"auto";h({width:i,height:n})},f=()=>{p.current&&(d.update(()=>{const e=Ne(r);e&&"function"==typeof e.updateDimensions&&e.updateDimensions(u.width,u.height)}),window.removeEventListener("mousemove",g),window.removeEventListener("mouseup",f))};return t("div",{ref:m,style:{display:"inline-block",position:"relative",maxWidth:c},children:[e("img",{src:i,alt:n,style:{width:u.width,height:u.height,maxWidth:"100%",display:"block"}}),e("div",{onMouseDown:e=>{e.preventDefault(),e.stopPropagation(),p.current={x:e.clientX,y:e.clientY,width:u.width,height:m.current?.offsetHeight??0},window.addEventListener("mousemove",g),window.addEventListener("mouseup",f)},style:{position:"absolute",bottom:0,right:0,width:14,height:14,background:"white",border:"1px solid #999",cursor:"nwse-resize",borderRadius:2}})]})},ii=e=>_e(new ri(e)),ni=e=>{if(e instanceof HTMLImageElement){const{src:t,alt:i}=e;return{node:ii({src:t,altText:i})}}return null};class ri extends ke{constructor({src:e="",altText:t="",maxWidth:i=1080,width:n,height:r,key:o}={}){super(o),this.__altText=t,this.__src=e,this.__maxWidth=i,this.__height=r,this.__width=n}static getType(){return"image"}static clone(e){return new ri({altText:e.__altText,src:e.__src,height:e.__height,width:e.__width,maxWidth:e.__maxWidth,key:e.getKey()})}createDOM(){return document.createElement("span")}exportDOM(){const e=document.createElement("img");return e.setAttribute("src",this.__src),e.setAttribute("alt",this.__altText),this.__width&&"inherit"!==this.__width&&e.setAttribute("width",String(this.__width)),this.__height&&"inherit"!==this.__height&&e.setAttribute("height",String(this.__height)),{element:e}}static importDOM(){return{img:()=>({conversion:ni,priority:0})}}exportJSON(){return{type:"image",version:1,src:this.__src,altText:this.__altText,maxWidth:this.__maxWidth,width:this.__width,height:this.__height}}static importJSON(e){return new ri({src:e.src,altText:e.altText,maxWidth:e.maxWidth,width:e.width,height:e.height})}updateDimensions(e,t){const i=this.getWritable();i.__width=e,i.__height=t}updateDOM(){return!1}decorate(){return e(ti,{src:this.__src,altText:this.__altText,nodeKey:this.getKey(),width:this.__width,height:this.__height,maxWidth:this.__maxWidth})}}function oi({...t}){return e(ct.Root,{"data-slot":"dialog",...t})}function ai({...t}){return e(ct.Trigger,{"data-slot":"dialog-trigger",...t})}function li({...t}){return e(ct.Portal,{"data-slot":"dialog-portal",...t})}function si({className:t,...i}){return e(ct.Overlay,{"data-slot":"dialog-overlay",className:Ht("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...i})}function ci({className:i,children:n,showCloseButton:r=!0,...o}){return t(li,{"data-slot":"dialog-portal",children:[e(si,{}),t(ct.Content,{"data-slot":"dialog-content","aria-describedby":"",className:Ht("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",i),...o,children:[n,r&&t(ct.Close,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[e(rt,{}),e("span",{className:"sr-only",children:"Close"})]})]})]})}function di({className:t,...i}){return e("div",{"data-slot":"dialog-header",className:Ht("flex flex-col gap-2 text-center sm:text-left",t),...i})}function ui({className:t,...i}){return e("div",{"data-slot":"dialog-footer",className:Ht("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...i})}function hi({className:t,...i}){return e(ct.Title,{"data-slot":"dialog-title",className:Ht("text-lg leading-none font-semibold",t),...i})}function mi(){const[i,n]=a(!1),[r,o]=a(""),[s,c]=a(""),[d,u]=a(),h=l(null),[m]=ae();return t("div",{children:[e("input",{type:"file",ref:h,accept:"image/*",className:"hidden",onChange:e=>{const t=e.target.files?.[0];t&&u(t),e.target.value=""}}),t(oi,{open:i,onOpenChange:n,children:[e(ai,{asChild:!0,children:e(Pt,{size:"icon",variant:"ghost",className:"rounded-md text-gray-700 hover:bg-gray-200",children:e(re,{})})}),t(ci,{className:"sm:max-w-md",children:[e(di,{children:e(hi,{className:"!text-lg text-gray-800",children:"Add Image"})}),e("div",{className:"flex flex-col gap-4 py-2",children:t("div",{className:"flex flex-col items-center gap-4",children:[e(Yt,{value:s,onChange:e=>c(e.target.value),placeholder:"Alt text"}),e(Yt,{value:r,onChange:e=>o(e.target.value),placeholder:"Add Image by URL"}),t("div",{className:"flex items-center w-full text-gray-500 text-sm",children:[e("div",{className:"flex-grow border-t border-gray-300"}),e("span",{className:"mx-2",children:"or"}),e("div",{className:"flex-grow border-t border-gray-300"})]}),t("div",{className:"flex flex-col gap-2 w-fit",children:[t(Pt,{variant:"outline",className:"flex items-center gap-2 bg-gray-50 hover:bg-gray-100",onClick:()=>h.current?.click(),children:[e(ot,{className:"h-4 w-4"})," Upload Image"]}),d&&e("span",{className:"text-sm text-gray-600",children:d.name})]})]})}),e(ui,{children:e(Pt,{onClick:()=>{let e="";r&&(e=r),d&&(e=URL.createObjectURL(d)),m.update(()=>{const t=ii({src:e,altText:s});Ae([t])}),u(void 0),c(""),o(""),n(!1)},disabled:!r&&!d,className:"!bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50",children:"Add Image"})})]})]})]})}const pi=({id:e,provider:t})=>new wi({id:e,provider:t}),gi="data-lexical-video",fi="data-provider",bi="315px",xi="560px",vi=(e,t)=>"drive"===t?`https://drive.google.com/file/d/${e}/preview`:`https://www.youtube-nocookie.com/embed/${e}`,yi=e=>{const t=e?.getAttribute(gi),i=e?.getAttribute(fi)??"youtube";if(!t)return null;return{node:pi({id:t,provider:i})}};class wi extends ke{constructor({id:e,provider:t,key:i}){super(i),this.__id=e,this.__provider=t}static getType(){return"video"}static clone(e){return new wi({id:e.__id,provider:e.__provider,key:e.getKey()})}static importJSON(e){return pi({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:bi,width:xi,src:vi(this.__id,this.__provider),frameBorder:"0",allowFullScreen:!0})}createDOM(){return document.createElement("div")}exportDOM(){const e=document.createElement("iframe");return e.setAttribute(gi,this.__id),e.setAttribute(fi,this.__provider),e.setAttribute("height",bi),e.setAttribute("width",xi),e.setAttribute("src",vi(this.__id,this.__provider)),{element:e}}static importDOM(){return{iframe:()=>({conversion:yi,priority:0})}}}function Ci(){const[i,n]=a(!1),[r,o]=a(!1),[l,c]=a(""),[d]=ae();return s(()=>{i||(c(""),o(!1))},[i]),e("div",{children:t(oi,{open:i,onOpenChange:n,children:[e(ai,{asChild:!0,children:e(Pt,{size:"icon",variant:"ghost",className:"rounded-md text-gray-700 hover:bg-gray-200",children:e(dt,{})})}),t(ci,{className:"sm:max-w-md",children:[e(di,{children:e(hi,{className:"!text-lg text-gray-800",children:"Embed Video"})}),t("div",{className:"py-2",children:[e(Yt,{value:l,onChange:e=>c(e.target.value),placeholder:"Add YouTube or Google Drive URL"}),r&&e("p",{className:"mt-1.5 text-red-800/80 text-[0.8rem]",children:"It's not a valid youtube or google drive URL"})]}),e(ui,{children:e(Pt,{onClick:()=>{if(!l)return;let e=null,t=null;const i=/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/.exec(l);i&&11===i[2]?.length&&(e="youtube",t=i[2]);const r=/drive\.google\.com\/file\/d\/([a-zA-Z0-9_-]+)\//.exec(l);r&&r[1]&&(e="drive",t=r[1]),t&&e?(d.update(()=>{const i=pi({id:t,provider:e});Ae([i])}),c(""),o(!1),n(!1)):o(!0)},disabled:!l,className:"bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50",children:"Embed"})})]})]})})}function Ni({value:t}){return e("div",{className:"prose max-w-none",dangerouslySetInnerHTML:{__html:t}})}function ki({value:i,triggerLabel:n="Preview"}){const[r,o]=a(!1);return t(oi,{open:r,onOpenChange:o,children:[e(ai,{asChild:!0,children:t(Pt,{variant:r?"toolbarActive":"toolbar",size:"icon",className:"size-8 w-fit p-2 select-none border-[1px] border-gray-100",children:[e(ut,{})," ",n]})}),t(ci,{className:"w-[90vw] md:w-[80vw] lg:w-[70vw] max-w-4xl max-h-[90vh] sm:max-w-[1000px] overflow-y-auto bg-white",children:[e(di,{children:e(hi,{className:"!text-xl",children:"Content Preview"})}),t("div",{className:" p-[2vw] rounded-lg border min-h-[400px] w-full text-start bg-white",children:[e("div",{className:"py-1 border-b-2 mb-4 font-medium",children:"CONTENT"}),e(Ni,{value:i})]})]})]})}const _i=({value:i})=>{const[n]=ae(),[r,o]=a({[pt.Undo]:!0,[pt.Redo]:!0}),[l,d]=a(!1),[g,f]=a({[pt.LeftAlign]:!0}),[b,x]=a({[gt.Normal]:!0}),[v,y]=a("paragraph"),[w,C]=a("https://");let N=!0;const k=()=>{if(N){const e=n.getRootElement();e&&(e.scrollTop=0,N=!1)}const e=ue();if(ge(e)){const t={[pt.Bold]:e.hasFormat("bold"),[pt.Italics]:e.hasFormat("italic"),[pt.Underline]:e.hasFormat("underline"),[pt.Uppercase]:e.hasFormat("uppercase"),[pt.Lowercase]:e.hasFormat("lowercase"),[pt.Capitalize]:e.hasFormat("capitalize"),[pt.Strikethrough]:e.hasFormat("strikethrough"),[pt.Superscript]:e.hasFormat("superscript"),[pt.Subscript]:e.hasFormat("subscript"),[pt.Code]:e.hasFormat("code"),[pt.Highlight]:e.hasFormat("highlight")};f(t);const i=e.anchor.getNode(),r="root"===i.getKey()?i:i.getTopLevelElementOrThrow(),o=r.getKey();if(!n.getElementByKey(o))return;if(z(r)){const e=function(e,t){let i=e;for(;null!=i;){if(i instanceof t)return i;i=i.getParent()}return null}(i,S),t=e?e.getTag():r.getTag();y(t)}else if("paragraph"===r.getType()||u(r)){let e=null;u(r)&&(e=r.getTag());const t={[gt.H1]:"h1"===e,[gt.H2]:"h2"===e,[gt.H3]:"h3"===e,[gt.H4]:"h4"===e,[gt.H5]:"h5"===e,[gt.H6]:"h6"===e,[gt.Normal]:"paragraph"===r.getType()};x(t)}else y(r.getType());const a=(de(i)?i:r).getFormat();f(e=>({...e,[pt.LeftAlign]:0===a||1===a,[pt.CenterAlign]:2===a,[pt.RightAlign]:3===a,[pt.JustifyAlign]:4===a})),"quote"===r.getType()?f(e=>({...e,[pt.Quote]:!0})):f(e=>({...e,[pt.Quote]:!1}));const l=e.anchor.getNode(),s=l.getParent();$e(s)?(f(e=>({...e,[pt.Link]:!0})),C(s.getURL()),d(!0)):$e(l)?(f(e=>({...e,[pt.Link]:!0})),C(l.getURL()),d(!0)):(f(e=>({...e,[pt.Link]:!1})),C("https://"),d(!1))}};s(()=>Ft(n.registerUpdateListener(({editorState:e})=>{e.read(()=>{k()})}),n.registerCommand(Ce,()=>(k(),!1),1),n.registerCommand(Se,e=>(o(t=>({...t,undo:!e})),!1),1),n.registerCommand(ze,e=>(o(t=>({...t,redo:!e})),!1),1)),[]);const _=e=>{switch(e){case pt.Bold:n.dispatchCommand(Ee,"bold");break;case pt.Italics:n.dispatchCommand(Ee,"italic");break;case pt.Underline:n.dispatchCommand(Ee,"underline");break;case pt.Lowercase:n.dispatchCommand(Ee,"lowercase");break;case pt.Uppercase:n.dispatchCommand(Ee,"uppercase");break;case pt.Capitalize:n.dispatchCommand(Ee,"capitalize");break;case pt.Strikethrough:n.dispatchCommand(Ee,"strikethrough");break;case pt.Superscript:n.dispatchCommand(Ee,"superscript");break;case pt.Subscript:n.dispatchCommand(Ee,"subscript");break;case pt.Highlight:n.dispatchCommand(Ee,"highlight");break;case pt.Code:n.dispatchCommand(Ee,"code");break;case pt.Quote:n.update(()=>{const e=ue();if(ge(e)){const t=e.anchor.getNode().getParent();t&&h(t)?function(e,t,i=At){if(null===e)return;const n=e.getStartEndPoints(),r=new Map;let o=null;if(n){const[e,t]=n;o=le(),o.anchor.set(e.key,e.offset,e.type),o.focus.set(t.key,t.offset,t.type);const i=se(e.getNode(),ce),a=se(t.getNode(),ce);de(i)&&r.set(i.getKey(),i),de(a)&&r.set(a.getKey(),a)}for(const t of e.getNodes())if(de(t)&&ce(t))r.set(t.getKey(),t);else if(null===n){const e=se(t,ce);de(e)&&r.set(e.getKey(),e)}for(const[e,n]of r){const r=t();i(n,r),n.replace(r,!0),o&&(e===o.anchor.key&&o.anchor.set(r.getKey(),o.anchor.offset,o.anchor.type),e===o.focus.key&&o.focus.set(r.getKey(),o.focus.offset,o.focus.type))}o&&e.is(ue())&&he(o)}(e,()=>Oe()):Lt(e,()=>m())}});break;case pt.Link:A(),d(!0);break;case pt.LeftAlign:n.dispatchCommand(De,"left");break;case pt.RightAlign:n.dispatchCommand(De,"right");break;case pt.CenterAlign:n.dispatchCommand(De,"center");break;case pt.JustifyAlign:n.dispatchCommand(De,"justify");break;case pt.Undo:n.dispatchCommand(Te,void 0);break;case pt.Redo:n.dispatchCommand(Le,void 0)}},A=c(()=>{console.log("insertlink"),l?n.dispatchCommand(Je,null):""!==w&&n.dispatchCommand(Je,w)},[n,l]),L=c(()=>{C(""),n.dispatchCommand(Je,null),d(!1)},[n]);return t("div",{className:"relative flex gap-1.5 flex-wrap justify-center items-center p-1.5 pb-2 mb-1 border-b-[1px]",children:[xt.map(({id:i,label:n,icon:o})=>i===pt.Divider?e(Qt,{},i):t(It,{delayDuration:700,children:[e(Kt,{asChild:!0,children:e(Pt,{variant:g[i]?"toolbarActive":"toolbar",size:"icon",className:"size-8",onClick:()=>_(i),disabled:!!r[i],children:o})}),e(Bt,{side:"bottom",children:n})]},i)),t("div",{className:"flex gap-1.5 justify-start items-center",children:[e(qt,{updateHeading:e=>{n.update(()=>{const t=ue();ge(t)&&Lt(t,"normal"===e?()=>Oe():()=>p(e))})},headingSelectionMap:b}),e(Qt,{})]}),bt.map(({id:i,label:n,icon:o})=>i===pt.Divider?e(Qt,{},i):t(It,{delayDuration:700,children:[e(Kt,{asChild:!0,children:e(Pt,{variant:g[i]?"toolbarActive":"toolbar",size:"icon",className:"size-8",onClick:()=>_(i),disabled:!!r[i],children:o})}),e(Bt,{side:"bottom",children:n})]},i)),t("div",{className:"flex gap-1.5 justify-start items-center",children:[e(ei,{blockType:v}),e(Qt,{})]}),e(Zt,{}),e($t,{onAction:_,selectionMap:g}),t("div",{className:"flex gap-1.5 justify-start items-center",children:[e(Xt,{onAction:_,alignmentSelectionMap:g}),e(Qt,{})]}),t(It,{delayDuration:700,children:[e(Kt,{asChild:!0,children:e(Pt,{variant:g[pt.Link]?"toolbarActive":"toolbar",size:"icon",className:"size-8",onClick:()=>_(pt.Link),disabled:!!r[pt.Link],children:e(tt,{})})}),e(Bt,{side:"bottom",children:"Link"})]}),l&&e(Vt,{linkUrl:w,setLinkUrl:C,removeLink:L,onConfirm:e=>{n.dispatchCommand(Je,{url:e,target:"_blank"}),C(e),d(!1)},onCancel:()=>{C(""),d(!1)}}),e(mi,{}),e(Ci,{}),e(ki,{value:i})]})};function Ai(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 i=document.createElement("div"),n=Me().getChildren();for(let r=0;r<n.length;r++)zi(e,n[r],i,t);return i.innerHTML}function zi(e,t,i,n=null){let r=null===n||t.isSelected(n);const o=de(t)&&t.excludeFromCopy("html");let a=t;if(null!==n){let e=Pe(t);e=fe(e)&&null!==n?function(e,t){const i=e.getStartEndPoints();if(t.isSelected(e)&&!be(t)&&null!==i){const[n,r]=i,o=e.isBackward(),a=n.getNode(),l=r.getNode(),s=t.is(a),c=t.is(l);if(s||c){const[i,n]=xe(e),r=a.is(l),s=t.is(o?l:a),c=t.is(o?a:l);let d,u=0;r?(u=i>n?n:i,d=i>n?i:n):s?(u=o?n:i,d=void 0):c&&(u=0,d=o?i:n),t.__text=t.__text.slice(u,d)}}return t}(n,e):e,a=e}const l=de(a)?a.getChildren():[],s=Re(e,a.getType());let c;c=s&&void 0!==s.exportDOM?s.exportDOM(e,a):a.exportDOM(e);const{element:d,after:u}=c;if(!d)return!1;const h=document.createDocumentFragment();for(let i=0;i<l.length;i++){const o=l[i],a=zi(e,o,h,n);!r&&de(t)&&a&&t.extractWithChild(o,n,"html")&&(r=!0)}if(r&&!o){if((Ie(d)||Ke(d))&&d.append(h),i.append(d),u){const e=u.call(a,d);e&&(Ke(d)?d.replaceChildren(e):d.replaceWith(e))}}else i.append(h);return r}const Si=new Set(["STYLE","SCRIPT"]);function Li(e,t,i,n,r=new Map,o){let a=[];if(Si.has(e.nodeName))return a;let l=null;const s=function(e,t){const{nodeName:i}=e,n=t._htmlConversions.get(i.toLowerCase());let r=null;if(void 0!==n)for(const t of n){const i=t(e);null!==i&&(null===r||(r.priority||0)<=(i.priority||0))&&(r=i)}return null!==r?r.conversion:null}(e,t),c=s?s(e):null;let d=null;if(null!==c){d=c.after;const t=c.node;if(l=Array.isArray(t)?t[t.length-1]:t,null!==l){for(const[,e]of r)if(l=e(l,o),!l)break;l&&a.push(...Array.isArray(t)?t:[l])}null!=c.forChild&&r.set(e.nodeName,c.forChild)}const u=e.childNodes;let h=[];const m=(null==l||!me(l))&&(null!=l&&Be(l)||n);for(let e=0;e<u.length;e++)h.push(...Li(u[e],t,i,m,new Map(r),l));return null!=d&&(h=d(h)),We(e)&&(h=function(e,t,i){const n=e.style.textAlign,r=[];let o=[];for(let e=0;e<t.length;e++){const a=t[e];if(Be(a))n&&!a.getFormat()&&a.setFormat(n),r.push(a);else if(o.push(a),e===t.length-1||e<t.length-1&&Be(t[e+1])){const e=i();e.setFormat(n),e.append(...o),r.push(e),o=[]}}return r}(e,h,m?()=>{const e=new He;return i.push(e),e}:Oe)),null==l?h.length>0?a=a.concat(h):We(e)&&function(e){return null!=e.nextSibling&&null!=e.previousSibling&&(je(e.nextSibling)&&je(e.previousSibling))}(e)&&(a=a.concat(Ue())):de(l)&&l.append(...h),a}function Ti({value:t,onChange:i}){const[n]=ae(),[r,o]=a(!0);return s(()=>{t&&r&&(o(!1),n.update(()=>{if(Ai(n)!==t){Me().clear();const e=(new DOMParser).parseFromString(t,"text/html"),i=function(e,t){const i=Fe(t)?t.body.childNodes:t.childNodes;let n=[];const r=[];for(const t of i)if(!Si.has(t.nodeName)){const i=Li(t,e,r,!1);null!==i&&(n=n.concat(i))}return function(e){for(const t of e)t.getNextSibling()instanceof He&&t.insertAfter(Ue());for(const t of e){const e=t.getChildren();for(const i of e)t.insertBefore(i);t.remove()}}(r),n}(n,e);Ae(i)}}))},[n,t,r]),s(()=>{o(!0)},[t]),e(mt,{onChange:e=>{e.read(()=>{i(Ai(n))})}})}const Di=({id:e})=>new Ui({id:e}),Ei="data-lexical-youtube",Oi="315px",Mi="560px",Fi=e=>`https://www.youtube-nocookie.com/embed/${e}`,Hi=e=>{const t=e?.getAttribute(Ei);if(!t)return null;return{node:Di({id:t})}};class Ui extends ke{constructor({id:e,key:t}){super(t),this.__id=e}static getType(){return"youtube"}static clone(e){return new Ui({id:e.__id,key:e.getKey()})}static importJSON(e){return Di({id:e.id})}exportJSON(){return{id:this.__id,type:"youtube",version:1}}decorate(){return e("iframe",{height:Oi,width:Mi,src:Fi(this.__id),frameBorder:"0",allowFullScreen:!0})}createDOM(){return document.createElement("div")}exportDOM(){const e=document.createElement("iframe");return e.setAttribute(Ei,this.__id),e.setAttribute("height",Oi),e.setAttribute("width",Mi),e.setAttribute("src",Fi(this.__id)),{element:e}}static importDOM(){return{iframe:()=>({conversion:Hi,priority:0})}}}const Pi={text:{bold:"font-bold",underline:"underline",italic:"italic",strikethrough:"line-through",underlineStrikethrough:"underline line-through",uppercase:"uppercase",lowercase:"lowercase",capitalize:"capitalize",code:"bg-gray-100 border border-gray-300 px-1 rounded text-sm font-mono text-black"},paragraph:"mb-2",list:{ul:"list-disc list-inside pl-6",ol:"list-decimal list-inside pl-6",listitem:"mb-1"},quote:"border-l-4 border-gray-400 pl-4 italic text-gray-800 bg-gray-50 py-2 rounded-r",link:"text-blue-600 underline hover:text-blue-800"},Ri=o.memo(function({name:i,value:r,onChange:o,placeholder:a}){const l=d(()=>({namespace:i,theme:Pi,onError:e=>{console.error("Lexical error:",e)},nodes:[g,b,x,S,L,f,Qe,ri,Ui,wi]}),[i]);return e("div",{className:"lexical-text-editor border-[1px] rounded-lg w-full max-w-[900px] pb-2 scrollbar-thin",children:t(n,{initialConfig:l,children:[e("div",{className:"px-2",children:e(_i,{value:r})}),e("div",{className:"relative",children:e(v,{contentEditable:e(y,{className:"h-[400px] text-start w-full text-[14px] p-[8px] overflow-auto outline-0"}),placeholder:e("div",{className:"absolute text-[#999] top-[8px] left-[10px] text-[14px]",children:a||"Some Text"}),ErrorBoundary:w})}),e(C,{}),e(N,{}),e(ht,{}),e(Ti,{value:r,onChange:o})]})})});export{Ri as LexicalTextEditor};
2
- //# sourceMappingURL=index.esm.js.map