@innoviatech/lexical-text-editor 2.0.7 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +390 -288
  2. package/dist/components/AlignmentSelectionList.js +19 -0
  3. package/dist/components/ColorPicker.js +30 -0
  4. package/dist/components/ContentPreview.js +11 -0
  5. package/dist/components/DisplayControls.d.ts +16 -0
  6. package/dist/components/DropdownList.js +18 -0
  7. package/dist/components/FindReplaceModal.d.ts +11 -0
  8. package/dist/components/FindReplaceModal.js +120 -0
  9. package/dist/components/FontSelectionList.d.ts +17 -0
  10. package/dist/components/FontSelectionList.js +17 -0
  11. package/dist/components/HeadingSelectionList.js +19 -0
  12. package/dist/components/ImageComponent.js +111 -0
  13. package/dist/components/InsertDropdownList.js +17 -0
  14. package/dist/components/LexicalTextEditor.d.ts +10 -0
  15. package/dist/components/LexicalTextEditor.js +128 -0
  16. package/dist/components/LinkModal.js +47 -0
  17. package/dist/components/Separator.js +4 -0
  18. package/dist/components/SourceView.d.ts +13 -0
  19. package/dist/components/SourceView.js +50 -0
  20. package/dist/components/StatusBar.d.ts +14 -0
  21. package/dist/components/StatusBar.js +30 -0
  22. package/dist/components/ToolbarOverflowModal.d.ts +15 -0
  23. package/dist/components/common/Dialog.js +27 -0
  24. package/dist/components/common/Popover.d.ts +10 -1
  25. package/dist/components/common/Popover.js +37 -0
  26. package/dist/components/common/Tooltip.d.ts +7 -0
  27. package/dist/components/common/Tooltip.js +20 -0
  28. package/dist/components/ui/button.js +35 -0
  29. package/dist/components/ui/command.js +33 -0
  30. package/dist/components/ui/dialog.js +35 -0
  31. package/dist/components/ui/input.js +6 -0
  32. package/dist/components/ui/popover.js +16 -0
  33. package/dist/components/ui/scroll-area.js +12 -0
  34. package/dist/components/ui/tooltip.js +16 -0
  35. package/dist/constants/index.d.ts +23 -1
  36. package/dist/constants/index.js +224 -0
  37. package/dist/index.d.ts +10 -0
  38. package/dist/index.esm.js +1 -1
  39. package/dist/index.esm.js.map +1 -1
  40. package/dist/index.js +1 -1
  41. package/dist/index.js.map +1 -1
  42. package/dist/lexical-editor.css +1 -1
  43. package/dist/lib/utils.js +5 -0
  44. package/dist/nodes/ExtendedTextNode.js +140 -0
  45. package/dist/nodes/ImageNode.js +149 -0
  46. package/dist/nodes/VideoNode.js +80 -0
  47. package/dist/nodes/YoutubeNode.js +64 -0
  48. package/dist/plugins/CodeBlockPlugin.d.ts +1 -0
  49. package/dist/plugins/CodeBlockPlugin.js +88 -0
  50. package/dist/plugins/ColorPlugin.js +47 -0
  51. package/dist/plugins/CustomOnChangePlugin.js +33 -0
  52. package/dist/plugins/FontFamilyPlugin.d.ts +1 -0
  53. package/dist/plugins/FontFamilyPlugin.js +53 -0
  54. package/dist/plugins/FontSizePlugin.d.ts +1 -0
  55. package/dist/plugins/FontSizePlugin.js +48 -0
  56. package/dist/plugins/ImagePlugin.js +91 -0
  57. package/dist/plugins/ListPlugin.js +44 -0
  58. package/dist/plugins/TablePlugin.d.ts +1 -0
  59. package/dist/plugins/TablePlugin.js +92 -0
  60. package/dist/plugins/ToolbarPlugin.d.ts +13 -1
  61. package/dist/plugins/ToolbarPlugin.js +381 -0
  62. package/dist/plugins/VideoPlugin.js +49 -0
  63. package/dist/plugins/YoutubePlugin.js +30 -0
  64. package/dist/tsconfig.tsbuildinfo +1 -0
  65. package/editor_screenshot.png +0 -0
  66. package/package.json +11 -4
  67. package/googlebd703883f12c69e4.html +0 -1
  68. package/rollup.config.js +0 -55
  69. package/src/components/AlignmentSelectionList.tsx +0 -61
  70. package/src/components/ColorPicker.tsx +0 -66
  71. package/src/components/ContentPreview.tsx +0 -51
  72. package/src/components/DropdownList.tsx +0 -57
  73. package/src/components/HeadingSelectionList.tsx +0 -61
  74. package/src/components/ImageComponent.tsx +0 -206
  75. package/src/components/InsertDropdownList.tsx +0 -36
  76. package/src/components/LexicalTextEditor.tsx +0 -119
  77. package/src/components/LinkModal.tsx +0 -127
  78. package/src/components/Separator.tsx +0 -7
  79. package/src/components/common/Dialog.tsx +0 -47
  80. package/src/components/common/Popover.tsx +0 -87
  81. package/src/components/common/Tooltip.tsx +0 -43
  82. package/src/components/ui/button.tsx +0 -58
  83. package/src/components/ui/command.tsx +0 -183
  84. package/src/components/ui/dialog.tsx +0 -142
  85. package/src/components/ui/input.tsx +0 -21
  86. package/src/components/ui/popover.tsx +0 -46
  87. package/src/components/ui/scroll-area.tsx +0 -56
  88. package/src/components/ui/tooltip.tsx +0 -59
  89. package/src/constants/index.tsx +0 -177
  90. package/src/index.ts +0 -6
  91. package/src/lib/utils.ts +0 -6
  92. package/src/nodes/ExtendedTextNode.tsx +0 -174
  93. package/src/nodes/ImageNode.tsx +0 -232
  94. package/src/nodes/VideoNode.tsx +0 -134
  95. package/src/nodes/YoutubeNode.tsx +0 -101
  96. package/src/plugins/ColorPlugin.tsx +0 -85
  97. package/src/plugins/CustomOnChangePlugin.tsx +0 -50
  98. package/src/plugins/ImagePlugin.tsx +0 -189
  99. package/src/plugins/ListPlugin.tsx +0 -58
  100. package/src/plugins/ToolbarPlugin.tsx +0 -500
  101. package/src/plugins/VideoPlugin.tsx +0 -100
  102. package/src/plugins/YoutubePlugin.tsx +0 -83
  103. package/src/styles/lexical-editor.css +0 -1053
  104. package/src/types/global.d.ts +0 -34
  105. package/src/types/other.d.ts +0 -11
  106. package/src/types/react-icons.d.ts +0 -11
  107. package/tailwind.config.js +0 -10
  108. package/tsconfig.json +0 -32
@@ -1,21 +0,0 @@
1
- import * as React from "react"
2
-
3
- import { cn } from "../../lib/utils"
4
-
5
- function Input({ className, type, ...props }: React.ComponentProps<"input">) {
6
- return (
7
- <input
8
- type={type}
9
- data-slot="input"
10
- className={cn(
11
- "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",
12
- "focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
13
- "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
14
- className
15
- )}
16
- {...props}
17
- />
18
- )
19
- }
20
-
21
- export { Input }
@@ -1,46 +0,0 @@
1
- import * as React from "react"
2
- import * as PopoverPrimitive from "@radix-ui/react-popover"
3
-
4
- import { cn } from "../../lib/utils"
5
-
6
- function Popover({
7
- ...props
8
- }: React.ComponentProps<typeof PopoverPrimitive.Root>) {
9
- return <PopoverPrimitive.Root data-slot="popover" {...props} />
10
- }
11
-
12
- function PopoverTrigger({
13
- ...props
14
- }: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
15
- return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
16
- }
17
-
18
- function PopoverContent({
19
- className,
20
- align = "center",
21
- sideOffset = 4,
22
- ...props
23
- }: React.ComponentProps<typeof PopoverPrimitive.Content>) {
24
- return (
25
- <PopoverPrimitive.Portal>
26
- <PopoverPrimitive.Content
27
- data-slot="popover-content"
28
- align={align}
29
- sideOffset={sideOffset}
30
- className={cn(
31
- "bg-[#ffffff] 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
- className
33
- )}
34
- {...props}
35
- />
36
- </PopoverPrimitive.Portal>
37
- )
38
- }
39
-
40
- function PopoverAnchor({
41
- ...props
42
- }: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
43
- return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
44
- }
45
-
46
- export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
@@ -1,56 +0,0 @@
1
- import * as React from "react"
2
- import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"
3
-
4
- import { cn } from "../../lib/utils"
5
-
6
- function ScrollArea({
7
- className,
8
- children,
9
- ...props
10
- }: React.ComponentProps<typeof ScrollAreaPrimitive.Root>) {
11
- return (
12
- <ScrollAreaPrimitive.Root
13
- data-slot="scroll-area"
14
- className={cn("relative", className)}
15
- {...props}
16
- >
17
- <ScrollAreaPrimitive.Viewport
18
- data-slot="scroll-area-viewport"
19
- className="focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1"
20
- >
21
- {children}
22
- </ScrollAreaPrimitive.Viewport>
23
- <ScrollBar />
24
- <ScrollAreaPrimitive.Corner />
25
- </ScrollAreaPrimitive.Root>
26
- )
27
- }
28
-
29
- function ScrollBar({
30
- className,
31
- orientation = "vertical",
32
- ...props
33
- }: React.ComponentProps<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>) {
34
- return (
35
- <ScrollAreaPrimitive.ScrollAreaScrollbar
36
- data-slot="scroll-area-scrollbar"
37
- orientation={orientation}
38
- className={cn(
39
- "flex touch-none p-px transition-colors select-none",
40
- orientation === "vertical" &&
41
- "h-full w-2.5 border-l border-l-transparent",
42
- orientation === "horizontal" &&
43
- "h-2.5 flex-col border-t border-t-transparent",
44
- className
45
- )}
46
- {...props}
47
- >
48
- <ScrollAreaPrimitive.ScrollAreaThumb
49
- data-slot="scroll-area-thumb"
50
- className="bg-border relative flex-1 rounded-full"
51
- />
52
- </ScrollAreaPrimitive.ScrollAreaScrollbar>
53
- )
54
- }
55
-
56
- export { ScrollArea, ScrollBar }
@@ -1,59 +0,0 @@
1
- import * as React from "react"
2
- import * as TooltipPrimitive from "@radix-ui/react-tooltip"
3
-
4
- import { cn } from "../../lib/utils"
5
-
6
- function TooltipProvider({
7
- delayDuration = 0,
8
- ...props
9
- }: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
10
- return (
11
- <TooltipPrimitive.Provider
12
- data-slot="tooltip-provider"
13
- delayDuration={delayDuration}
14
- {...props}
15
- />
16
- )
17
- }
18
-
19
- function Tooltip({
20
- ...props
21
- }: React.ComponentProps<typeof TooltipPrimitive.Root>) {
22
- return (
23
- <TooltipProvider>
24
- <TooltipPrimitive.Root data-slot="tooltip" {...props} />
25
- </TooltipProvider>
26
- )
27
- }
28
-
29
- function TooltipTrigger({
30
- ...props
31
- }: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
32
- return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
33
- }
34
-
35
- function TooltipContent({
36
- className,
37
- sideOffset = 0,
38
- children,
39
- ...props
40
- }: React.ComponentProps<typeof TooltipPrimitive.Content>) {
41
- return (
42
- <TooltipPrimitive.Portal>
43
- <TooltipPrimitive.Content
44
- data-slot="tooltip-content"
45
- sideOffset={sideOffset}
46
- className={cn(
47
- "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",
48
- className
49
- )}
50
- {...props}
51
- >
52
- {children}
53
- <TooltipPrimitive.Arrow className="bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
54
- </TooltipPrimitive.Content>
55
- </TooltipPrimitive.Portal>
56
- )
57
- }
58
-
59
- export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
@@ -1,177 +0,0 @@
1
-
2
- import { RxLetterCaseLowercase, RxLetterCaseCapitalize, RxLetterCaseUppercase } from "react-icons/rx";
3
- import { TbBold, TbItalic, TbUnderline } from "react-icons/tb";
4
- import { BsArrowClockwise, BsArrowCounterclockwise, BsChatSquareQuote, BsJustify, BsJustifyLeft, BsJustifyRight, BsSubscript, BsSuperscript, BsTextCenter, BsTextParagraph, BsTypeH1, BsTypeH2, BsTypeH3, BsTypeH4, BsTypeH5, BsTypeH6 } from "react-icons/bs";
5
- import { AiOutlineStrikethrough } from "react-icons/ai";
6
- import { IoCodeSlashOutline } from "react-icons/io5";
7
- import { PiHighlighterLight } from "react-icons/pi";
8
-
9
- export enum RichTextAction {
10
- Bold = "bold",
11
- Italics = "italics",
12
- Underline = "underline",
13
- Quote = 'quote',
14
- Lowercase = "lowercase",
15
- Uppercase = "uppercase",
16
- Capitalize = "capitalize",
17
- Strikethrough = "strikethrough",
18
- Superscript = "superscript",
19
- Subscript = "subscript",
20
- Highlight = "highlight",
21
- Code = "code",
22
- Link = 'link',
23
- LeftAlign = "leftAlign",
24
- CenterAlign = "centerAlign",
25
- RightAlign = "rightAlign",
26
- JustifyAlign = "justifyAlign",
27
- Divider = "divider",
28
- Undo = "undo",
29
- Redo = "redo",
30
- }
31
-
32
- export enum HeadingAction {
33
- Normal = 'normal',
34
- H1 = 'h1',
35
- H2 = 'h2',
36
- H3 = 'h3',
37
- H4 = 'h4',
38
- H5 = 'h5',
39
- H6 = 'h6',
40
- }
41
-
42
- export const RICH_TEXT_FORMAT_OPTIONS = [
43
- {
44
- id: RichTextAction.Lowercase,
45
- icon: <RxLetterCaseLowercase />,
46
- label: "Lowercase",
47
- },
48
- {
49
- id: RichTextAction.Uppercase,
50
- icon: <RxLetterCaseUppercase />,
51
- label: "Uppercase",
52
- },
53
- {
54
- id: RichTextAction.Capitalize,
55
- icon: <RxLetterCaseCapitalize />,
56
- label: "Capitalize",
57
- },
58
- {
59
- id: RichTextAction.Strikethrough,
60
- icon: <AiOutlineStrikethrough />,
61
- label: "Strikethrough",
62
- },
63
- {
64
- id: RichTextAction.Highlight,
65
- icon: <PiHighlighterLight />,
66
- label: "Highlight",
67
- fontSize: 10,
68
- },
69
- {
70
- id: RichTextAction.Superscript,
71
- icon: <BsSuperscript />,
72
- label: "Superscript",
73
- },
74
- {
75
- id: RichTextAction.Subscript,
76
- icon: <BsSubscript />,
77
- label: "Subscript",
78
- },
79
-
80
- ];
81
-
82
- export const RICH_TEXT_OPTIONS = [
83
- { id: RichTextAction.Bold, icon: <TbBold />, label: "Bold" },
84
- { id: RichTextAction.Italics, icon: <TbItalic />, label: "Italics" },
85
- { id: RichTextAction.Underline, icon: <TbUnderline />, label: "Underline" },
86
- { id: RichTextAction.Divider },
87
- { id: RichTextAction.Quote, icon: <BsChatSquareQuote />, label: "Quote" },
88
- // { id: RichTextAction.Divider },
89
-
90
- {
91
- id: RichTextAction.Code,
92
- icon: <IoCodeSlashOutline />,
93
- label: "Code",
94
- },
95
- // { id: RichTextAction.Link, label: "Link", icon: <IoIosLink /> },
96
-
97
- ];
98
-
99
- export const RICH_REDO_UNDO_OPTIONS = [
100
- {
101
- id: RichTextAction.Undo,
102
- icon: <BsArrowCounterclockwise />,
103
- label: "Undo",
104
- },
105
- {
106
- id: RichTextAction.Redo,
107
- icon: <BsArrowClockwise />,
108
- label: "Redo",
109
- },
110
- { id: RichTextAction.Divider },
111
- ]
112
-
113
- export const RICH_ALIGNMENT_OPTIONS = [
114
-
115
- {
116
- id: RichTextAction.LeftAlign,
117
- icon: <BsJustifyLeft />,
118
- label: "Left Align",
119
- },
120
- {
121
- id: RichTextAction.CenterAlign,
122
- icon: <BsTextCenter />,
123
- label: "Center Align",
124
- },
125
- {
126
- id: RichTextAction.RightAlign,
127
- icon: <BsJustifyRight />,
128
- label: "Right Align",
129
- },
130
- {
131
- id: RichTextAction.JustifyAlign,
132
- icon: <BsJustify />,
133
- label: "Justify Align",
134
- },
135
- ];
136
-
137
- export const LOW_PRIORIRTY = 1;
138
- export const HEADINGS = [
139
- {
140
- id: "normal",
141
- label: "Normal",
142
- icon: <BsTextParagraph />
143
- },
144
- {
145
- id: "h1",
146
- label: "Heading 1",
147
- icon: <BsTypeH1 />
148
- },
149
- {
150
- id: "h2",
151
- label: "Heading 2",
152
- icon: <BsTypeH2 />
153
- },
154
- {
155
- id: "h3",
156
- label: "Heading 3",
157
- icon: <BsTypeH3 />
158
- },
159
- {
160
- id: "h4",
161
- label: "Heading 4",
162
- icon: <BsTypeH4 />
163
- },
164
- {
165
- id: "h5",
166
- label: "Heading 5",
167
- icon: <BsTypeH5 />
168
- },
169
- {
170
- id: "h6",
171
- label: "Heading 6",
172
- icon: <BsTypeH6 />
173
- },
174
-
175
- ]
176
-
177
- // ["Normal", "H1", "H2", "H3", "H4", "H5", "H6"];
package/src/index.ts DELETED
@@ -1,6 +0,0 @@
1
- // Export main component
2
- export { LexicalTextEditor } from './components/LexicalTextEditor';
3
- export type { LexiTexProps as LexicalTextEditorProps } from './components/LexicalTextEditor';
4
-
5
- // Export styles
6
- import './styles/lexical-editor.css';
package/src/lib/utils.ts DELETED
@@ -1,6 +0,0 @@
1
- import { clsx } from "clsx";
2
- import { twMerge } from "tailwind-merge";
3
-
4
- export function cn(...inputs: any[]) {
5
- return twMerge(clsx(inputs));
6
- }
@@ -1,174 +0,0 @@
1
- import {
2
- $applyNodeReplacement,
3
- $isTextNode,
4
- DOMConversion,
5
- DOMConversionMap,
6
- DOMConversionOutput,
7
- NodeKey,
8
- TextNode,
9
- SerializedTextNode,
10
- LexicalNode
11
- } from 'lexical';
12
-
13
- export class ExtendedTextNode extends TextNode {
14
- constructor(text: string, key?: NodeKey) {
15
- super(text, key);
16
- }
17
-
18
- static getType(): string {
19
- return 'extended-text';
20
- }
21
-
22
- static clone(node: ExtendedTextNode): ExtendedTextNode {
23
- return new ExtendedTextNode(node.__text, node.__key);
24
- }
25
-
26
- static importDOM(): DOMConversionMap | null {
27
- const importers = TextNode.importDOM();
28
- return {
29
- ...importers,
30
- span: () => ({
31
- conversion: patchStyleConversion(importers?.span),
32
- priority: 1
33
- }),
34
- div: () => ({
35
- conversion: patchStyleConversion(importers?.div),
36
- priority: 1
37
- }),
38
- p: () => ({
39
- conversion: patchStyleConversion(importers?.p),
40
- priority: 1
41
- }),
42
- b: () => ({
43
- conversion: patchStyleConversion(importers?.b),
44
- priority: 1
45
- }),
46
- strong: () => ({
47
- conversion: patchStyleConversion(importers?.strong),
48
- priority: 1
49
- }),
50
- i: () => ({
51
- conversion: patchStyleConversion(importers?.i),
52
- priority: 1
53
- }),
54
- em: () => ({
55
- conversion: patchStyleConversion(importers?.em),
56
- priority: 1
57
- }),
58
- u: () => ({
59
- conversion: patchStyleConversion(importers?.u),
60
- priority: 1
61
- }),
62
- s: () => ({
63
- conversion: patchStyleConversion(importers?.s),
64
- priority: 1
65
- }),
66
- strike: () => ({
67
- conversion: patchStyleConversion(importers?.strike),
68
- priority: 1
69
- }),
70
- code: () => ({
71
- conversion: patchStyleConversion(importers?.code),
72
- priority: 1
73
- })
74
- };
75
- }
76
-
77
- static importJSON(serializedNode: SerializedTextNode): ExtendedTextNode {
78
- return $createExtendedTextNode().updateFromJSON(serializedNode);
79
- }
80
-
81
- isSimpleText() {
82
- return this.__type === 'extended-text' && this.__mode === 0;
83
- }
84
- }
85
-
86
- export function $createExtendedTextNode(text: string = ''): ExtendedTextNode {
87
- return $applyNodeReplacement(new ExtendedTextNode(text));
88
- }
89
-
90
- export function $isExtendedTextNode(node: LexicalNode | null | undefined): node is ExtendedTextNode {
91
- return node instanceof ExtendedTextNode;
92
- }
93
-
94
- // Helper function to patch style conversion
95
- function patchStyleConversion(
96
- originalDOMConverter?: (node: HTMLElement) => DOMConversion | null
97
- ): (node: HTMLElement) => DOMConversionOutput | null {
98
- return (node) => {
99
- const original = originalDOMConverter?.(node);
100
- if (!original) {
101
- return null;
102
- }
103
- const originalOutput = original.conversion(node);
104
-
105
- if (!originalOutput) {
106
- return originalOutput;
107
- }
108
-
109
- // Extract all style properties
110
- const style = node.style;
111
- const styleAttributes: string[] = [];
112
-
113
- if (style.backgroundColor) {
114
- styleAttributes.push(`background-color: ${style.backgroundColor}`);
115
- }
116
-
117
- if (style.color) {
118
- styleAttributes.push(`color: ${style.color}`);
119
- }
120
-
121
- if (style.fontFamily) {
122
- styleAttributes.push(`font-family: ${style.fontFamily}`);
123
- }
124
-
125
- if (style.fontWeight) {
126
- styleAttributes.push(`font-weight: ${style.fontWeight}`);
127
- }
128
-
129
- if (style.fontSize) {
130
- styleAttributes.push(`font-size: ${style.fontSize}`);
131
- }
132
-
133
- if (style.fontStyle) {
134
- styleAttributes.push(`font-style: ${style.fontStyle}`);
135
- }
136
-
137
- if (style.textDecoration) {
138
- styleAttributes.push(`text-decoration: ${style.textDecoration}`);
139
- }
140
-
141
- if (style.whiteSpace) {
142
- styleAttributes.push(`white-space: ${style.whiteSpace}`);
143
- }
144
-
145
- if (style.textAlign) {
146
- styleAttributes.push(`text-align: ${style.textAlign}`);
147
- }
148
-
149
- const inlineStyle = node.getAttribute('style');
150
- if (inlineStyle) {
151
- // Parse the style string to avoid duplicates
152
- const stylePairs = inlineStyle.split(';').filter(pair => pair.trim());
153
- stylePairs.forEach(pair => {
154
- const [property] = pair.split(':').map(s => s.trim());
155
- if (property && !styleAttributes.some(attr => attr.startsWith(property))) {
156
- styleAttributes.push(pair.trim());
157
- }
158
- });
159
- }
160
-
161
- return {
162
- ...originalOutput,
163
- forChild: (lexicalNode, parent) => {
164
- const originalForChild = originalOutput?.forChild ?? ((x) => x);
165
- const result = originalForChild(lexicalNode, parent);
166
- if ($isTextNode(result) && styleAttributes.length > 0) {
167
- const styleString = styleAttributes.join('; ');
168
- return result.setStyle(styleString);
169
- }
170
- return result;
171
- }
172
- };
173
- };
174
- }