@innoviatech/lexical-text-editor 1.0.5 → 2.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 (44) hide show
  1. package/README.md +105 -35
  2. package/dist/components/ContentPreview.d.ts +1 -1
  3. package/dist/components/HeadingSelectionList.d.ts +1 -1
  4. package/dist/components/LexicalTextEditor.d.ts +1 -1
  5. package/dist/components/common/Dialog.d.ts +9 -0
  6. package/dist/components/common/Popover.d.ts +21 -0
  7. package/dist/components/common/Tooltip.d.ts +10 -0
  8. package/dist/components/ui/button.d.ts +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.esm.js +1 -1
  11. package/dist/index.esm.js.map +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/lexical-editor.css +1 -0
  15. package/dist/nodes/ExtendedTextNode.d.ts +11 -0
  16. package/dist/nodes/ImageNode.d.ts +1 -1
  17. package/dist/plugins/YoutubePlugin.d.ts +1 -0
  18. package/package.json +20 -16
  19. package/rollup.config.js +3 -4
  20. package/src/components/AlignmentSelectionList.tsx +41 -24
  21. package/src/components/ColorPicker.tsx +7 -21
  22. package/src/components/ContentPreview.tsx +27 -20
  23. package/src/components/DropdownList.tsx +39 -24
  24. package/src/components/HeadingSelectionList.tsx +48 -32
  25. package/src/components/ImageComponent.tsx +52 -19
  26. package/src/components/InsertDropdownList.tsx +1 -1
  27. package/src/components/LexicalTextEditor.tsx +33 -28
  28. package/src/components/LinkModal.tsx +42 -45
  29. package/src/components/common/Dialog.tsx +47 -0
  30. package/src/components/common/Popover.tsx +87 -0
  31. package/src/components/common/Tooltip.tsx +43 -0
  32. package/src/components/ui/command.tsx +0 -1
  33. package/src/nodes/ExtendedTextNode.tsx +174 -0
  34. package/src/nodes/ImageNode.tsx +48 -9
  35. package/src/plugins/ColorPlugin.tsx +19 -14
  36. package/src/plugins/ImagePlugin.tsx +79 -84
  37. package/src/plugins/ListPlugin.tsx +20 -38
  38. package/src/plugins/ToolbarPlugin.tsx +76 -78
  39. package/src/plugins/VideoPlugin.tsx +46 -55
  40. package/src/plugins/YoutubePlugin.tsx +83 -0
  41. package/src/styles/lexical-editor.css +962 -3
  42. package/dist/style.css +0 -3
  43. package/postcss.config.js +0 -6
  44. package/src/assets/react.svg +0 -1
@@ -4,7 +4,7 @@ import {
4
4
  PopoverContent,
5
5
  PopoverTrigger,
6
6
  } from "./ui/popover"
7
- // import { RichTextAction } from "@/constants";
7
+ // import { RichTextAction } from "constants";
8
8
  import { useState } from "react"
9
9
  import { BsPlus } from "react-icons/bs";
10
10
  import { HiChevronDown } from "react-icons/hi2";
@@ -5,7 +5,7 @@ import { CodeHighlightNode, CodeNode } from "@lexical/code"
5
5
  import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin"
6
6
  import { ContentEditable } from "@lexical/react/LexicalContentEditable"
7
7
  import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary"
8
- import type { EditorThemeClasses } from "lexical"
8
+ import { TextNode, type EditorThemeClasses } from "lexical"
9
9
  import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin"
10
10
  import { ListPlugin } from "@lexical/react/LexicalListPlugin"
11
11
  import { ListItemNode, ListNode } from "@lexical/list"
@@ -17,6 +17,7 @@ import { ImageNode } from "../nodes/ImageNode"
17
17
  import { YoutubeNode } from "../nodes/YoutubeNode"
18
18
  import { VideoNode } from "../nodes/VideoNode"
19
19
  import "../styles/lexical-editor.css"
20
+ import { ExtendedTextNode } from "../nodes/ExtendedTextNode"
20
21
 
21
22
  export interface LexiTexProps {
22
23
  value: string
@@ -24,35 +25,33 @@ export interface LexiTexProps {
24
25
  placeholder?: string
25
26
  name: string,
26
27
  height?: string | null | undefined;
27
- width?: string | null | undefined;
28
+ maxWidth?: string | null | undefined;
28
29
  }
29
30
 
30
- // ✅ Theme config stays same
31
31
  const theme: EditorThemeClasses = {
32
32
  text: {
33
- bold: "font-bold",
34
- underline: "underline",
35
- italic: "italic",
36
- strikethrough: "line-through",
37
- underlineStrikethrough: "underline line-through",
38
- uppercase: "uppercase",
39
- lowercase: "lowercase",
40
- capitalize: "capitalize",
41
- code: "bg-gray-100 border border-gray-300 px-1 rounded text-sm font-mono text-black",
33
+ bold: "lexical-bold",
34
+ underline: "lexical-underline",
35
+ italic: "lexical-italic",
36
+ strikethrough: "lexical-strikethrough",
37
+ underlineStrikethrough: "lexical-underline-strikethrough",
38
+ uppercase: "lexical-uppercase",
39
+ lowercase: "lexical-lowercase",
40
+ capitalize: "lexical-capitalize",
41
+ code: "lexical-code",
42
42
  },
43
- paragraph: "mb-2",
43
+ paragraph: "lexical-paragraph",
44
44
  list: {
45
- ul: "list-disc list-inside pl-6",
46
- ol: "list-decimal list-inside pl-6",
47
- listitem: "mb-1",
45
+ ul: "lexical-list-ul",
46
+ ol: "lexical-list-ol",
47
+ listitem: "lexical-listitem",
48
48
  },
49
- quote: "border-l-4 border-gray-400 pl-4 italic text-gray-800 bg-gray-50 py-2 rounded-r",
50
- link: "text-blue-600 underline hover:text-blue-800",
49
+ quote: "lexical-quote",
50
+ link: "lexical-link",
51
51
  }
52
- // ... your imports
53
52
 
54
53
  export const LexicalTextEditor: React.FC<LexiTexProps> = React.memo(
55
- function LexicalTextEditor({ name, value, onChange, placeholder, width = null, height = null }) {
54
+ function LexicalTextEditor({ name, value, onChange, placeholder, maxWidth = null, height = null }) {
56
55
 
57
56
  const initialConfig = useMemo(
58
57
  () => ({
@@ -62,6 +61,12 @@ export const LexicalTextEditor: React.FC<LexiTexProps> = React.memo(
62
61
  console.error("Lexical error:", error);
63
62
  },
64
63
  nodes: [
64
+ ExtendedTextNode,
65
+ {
66
+ replace: TextNode,
67
+ with: (node: TextNode) => new ExtendedTextNode(node.__text),
68
+ withKlass: ExtendedTextNode,
69
+ },
65
70
  HeadingNode,
66
71
  CodeHighlightNode,
67
72
  CodeNode,
@@ -78,24 +83,24 @@ export const LexicalTextEditor: React.FC<LexiTexProps> = React.memo(
78
83
  );
79
84
 
80
85
  return (
81
- <div className="lexical-text-editor border-[1px] rounded-lg pb-2 scrollbar-thin"
86
+ <div className="lexical-text-editor lexical-editor-container"
82
87
  style={{
83
- width: width ? width : '',
84
- maxWidth: width ? '' : '1090px',
85
- height: height ? height : '500px',
88
+ maxWidth: maxWidth ? maxWidth : '1090px',
86
89
  }}
87
90
  >
88
91
  <LexicalComposer initialConfig={initialConfig}>
89
- <div className="px-2">
92
+ <div className="lexical-toolbar-container">
90
93
  <ToolbarPlugin value={value} />
91
94
  </div>
92
- <div className="relative">
95
+ <div className="lexical-editor-inner">
93
96
  <RichTextPlugin
94
97
  contentEditable={
95
- <ContentEditable className={`text-start w-full h-full text-[14px] p-[8px] overflow-auto outline-0`} />
98
+ <ContentEditable className="lexical-content-editable" style={{
99
+ height: height ? height : '500px',
100
+ }} />
96
101
  }
97
102
  placeholder={
98
- <div className="absolute text-[#999] top-[8px] left-[10px] text-[14px]">
103
+ <div className="lexical-placeholder">
99
104
  {placeholder || "Some Text"}
100
105
  </div>
101
106
  }
@@ -1,10 +1,7 @@
1
- // FloatingLinkEditor.tsx
2
1
  import { useEffect, useRef, useState } from "react";
3
- import { Input } from "../components/ui/input";
4
- import { Button } from "../components/ui/button";
5
- import { Check, Pencil } from "lucide-react";
6
- import { cn } from "../lib/utils";
7
- import { TiDeleteOutline } from "react-icons/ti";
2
+ import { BsPencilSquare } from "react-icons/bs";
3
+ import { MdCheck } from "react-icons/md";
4
+ import { BiUnlink } from "react-icons/bi";
8
5
 
9
6
  interface LinkEditorProps {
10
7
  linkUrl: string;
@@ -25,7 +22,6 @@ export default function LinkModal({
25
22
  const editorRef = useRef<HTMLDivElement | null>(null);
26
23
  const inputRef = useRef<HTMLInputElement | null>(null);
27
24
 
28
-
29
25
  useEffect(() => {
30
26
  if (linkUrl === "https://") setEditMode(true);
31
27
  }, [linkUrl]);
@@ -45,26 +41,16 @@ export default function LinkModal({
45
41
  };
46
42
 
47
43
  document.addEventListener("mousedown", handleClickOutside);
48
- return () => {
49
- document.removeEventListener("mousedown", handleClickOutside);
50
- };
44
+ return () => document.removeEventListener("mousedown", handleClickOutside);
51
45
  }, [onCancel]);
52
46
 
53
47
  return (
54
- <div
55
- ref={editorRef}
56
- className={cn(
57
- "absolute z-[9999] bottom-[-50px] sm:bottom-[-60px] right-[20px]",
58
- "bg-white shadow-lg rounded-xl px-1.5 py-1 sm:px-3 sm:py-2 flex items-center space-x-2",
59
- "border border-gray-200"
60
- )}
61
-
62
- >
63
- <div className="flex-1 min-w-[200px]">
48
+ <div ref={editorRef} className="lexical-text-editor-link link-editor-container">
49
+ <div className="link-editor-input-wrapper">
64
50
  {isEditMode ? (
65
- <Input
51
+ <input
66
52
  ref={inputRef}
67
- className="h-8 text-sm"
53
+ className="link-editor-input"
68
54
  value={linkUrl}
69
55
  onChange={(e) => setLinkUrl(e.target.value)}
70
56
  onKeyDown={(e) => {
@@ -84,47 +70,58 @@ export default function LinkModal({
84
70
  href={linkUrl}
85
71
  target="_blank"
86
72
  rel="noopener noreferrer"
87
- className="text-blue-600 text-sm underline truncate block max-w-full text-start"
73
+ className="link-editor-url"
88
74
  >
89
75
  {linkUrl}
90
76
  </a>
91
77
  )}
92
78
  </div>
93
79
 
94
- <div>
95
- <Button
96
- variant="ghost"
97
- size="icon"
80
+ <div className="link-editor-buttons">
81
+
82
+ <button
83
+ className={`lexical-btn heading-trigger toolbar`}
84
+ onClick={() => {
85
+ if (isEditMode) {
86
+ onConfirm(linkUrl);
87
+ setEditMode(false);
88
+ } else setEditMode(true);
89
+ }}
90
+ >
91
+ {isEditMode ? <MdCheck size={18} /> : <BsPencilSquare size={14} />}
92
+ </button>
93
+
94
+ <button
95
+ className={`lexical-btn heading-trigger toolbar`}
96
+ onMouseDown={(e) => e.preventDefault()}
97
+ onClick={removeLink}
98
+ >
99
+ <BiUnlink size={14} style={{ stroke: 'black' }} />
100
+ </button>
101
+
102
+
103
+
104
+ {/* <button
98
105
  onMouseDown={(e) => e.preventDefault()}
99
106
  onClick={() => {
100
107
  if (isEditMode) {
101
108
  onConfirm(linkUrl);
102
109
  setEditMode(false);
103
- } else {
104
- setEditMode(true);
105
- }
110
+ } else setEditMode(true);
106
111
  }}
107
- className="h-8 w-8"
112
+ className={`size-8 toolbar icon`}
108
113
  >
109
- {isEditMode ? (
110
- <Check className="h-4 w-4" />
111
- ) : (
112
- <Pencil className="h-4 w-4" />
113
- )}
114
- </Button>
114
+ {isEditMode ? <MdCheck size={18} /> : <BsPencilSquare size={14} />}
115
+ </button> */}
115
116
 
116
- <Button
117
- variant="ghost"
118
- size="icon"
117
+ {/* <button
119
118
  onMouseDown={(e) => e.preventDefault()}
120
119
  onClick={removeLink}
121
- className="h-8 w-8"
120
+ className={`size-8 toolbar icon`}
122
121
  >
123
- <TiDeleteOutline className="h-4 w-4" />
124
- </Button>
122
+ <BiUnlink size={14} style={{ stroke: 'black' }} />
123
+ </button> */}
125
124
  </div>
126
-
127
125
  </div>
128
126
  );
129
127
  }
130
-
@@ -0,0 +1,47 @@
1
+ import { ReactNode, useEffect, useRef } from "react";
2
+
3
+ interface Props {
4
+ open: boolean;
5
+ onClose: () => void;
6
+ children: ReactNode;
7
+ forPreview?: boolean;
8
+ }
9
+
10
+ export default function RawDialog({ open, onClose, forPreview = false, children }: Props) {
11
+ const dialogRef = useRef<HTMLDivElement>(null);
12
+
13
+ useEffect(() => {
14
+ if (!open) return;
15
+
16
+ const handleOutsideClick = (e: MouseEvent) => {
17
+ if (dialogRef.current && !dialogRef.current.contains(e.target as Node)) {
18
+ onClose();
19
+ }
20
+ };
21
+
22
+ const handleEsc = (e: KeyboardEvent) => {
23
+ if (e.key === "Escape") onClose();
24
+ };
25
+
26
+ document.addEventListener("mousedown", handleOutsideClick);
27
+ document.addEventListener("keydown", handleEsc);
28
+
29
+ return () => {
30
+ document.removeEventListener("mousedown", handleOutsideClick);
31
+ document.removeEventListener("keydown", handleEsc);
32
+ };
33
+ }, [open, onClose]);
34
+
35
+ if (!open) return null;
36
+
37
+ return (
38
+ <div className="lexical-text-editor-dialog lte-dialog-overlay">
39
+ <div ref={dialogRef} className={`lte-dialog ${forPreview ? 'preview' : ''}`}>
40
+ <button className="lte-dialog-close" onClick={onClose}>
41
+ ×
42
+ </button>
43
+ {children}
44
+ </div>
45
+ </div>
46
+ );
47
+ }
@@ -0,0 +1,87 @@
1
+ import React, { useEffect, useRef, cloneElement } from "react";
2
+
3
+ interface PopoverProps {
4
+ open: boolean;
5
+ onOpenChange: (open: boolean) => void;
6
+ children: React.ReactNode;
7
+ }
8
+
9
+ export function Popover({ open, onOpenChange, children }: PopoverProps) {
10
+ const triggerRef = useRef<HTMLElement | null>(null);
11
+ const contentRef = useRef<HTMLDivElement | null>(null);
12
+
13
+ // Close on outside click
14
+ useEffect(() => {
15
+ function handleClick(e: MouseEvent) {
16
+ if (
17
+ !triggerRef.current?.contains(e.target as Node) &&
18
+ !contentRef.current?.contains(e.target as Node)
19
+ ) {
20
+ onOpenChange(false);
21
+ }
22
+ }
23
+ if (open) document.addEventListener("mousedown", handleClick);
24
+ return () => document.removeEventListener("mousedown", handleClick);
25
+ }, [open, onOpenChange]);
26
+
27
+ return (
28
+ <div className="popover-root">
29
+ {/*
30
+ Pass refs to trigger/content via props
31
+ so child components can attach them
32
+ */}
33
+ {React.Children.map(children, (child) => {
34
+ if (!child || typeof child !== "object") return child;
35
+
36
+ if ((child as any).type === PopoverTrigger) {
37
+ return cloneElement(child as any, { triggerRef });
38
+ }
39
+
40
+ if ((child as any).type === PopoverContent) {
41
+ return cloneElement(child as any, { contentRef });
42
+ }
43
+
44
+ return child;
45
+ })}
46
+ </div>
47
+ );
48
+ }
49
+
50
+ interface PopoverTriggerProps {
51
+ children: React.ReactNode;
52
+ triggerRef: React.RefObject<HTMLDivElement | null>;
53
+ }
54
+
55
+ export function PopoverTrigger({ children, triggerRef }: PopoverTriggerProps) {
56
+ return (
57
+ <div className="popover-trigger" ref={triggerRef}>
58
+ {children}
59
+ </div>
60
+ );
61
+ }
62
+
63
+ interface PopoverContentProps {
64
+ open: boolean;
65
+ align?: "start" | "center" | "end";
66
+ onClose: () => void;
67
+ children: React.ReactNode;
68
+ contentRef: React.RefObject<HTMLDivElement | null>;
69
+ }
70
+
71
+ export function PopoverContent({
72
+ open,
73
+ align = "start",
74
+ children,
75
+ contentRef,
76
+ }: PopoverContentProps) {
77
+ if (!open) return null;
78
+
79
+ return (
80
+ <div
81
+ ref={contentRef}
82
+ className={`popover-content align-${align}`}
83
+ >
84
+ {children}
85
+ </div>
86
+ );
87
+ }
@@ -0,0 +1,43 @@
1
+ import React, { useState, useRef, ReactNode } from "react";
2
+ import '../../styles/lexical-editor.css'
3
+ interface TooltipProps {
4
+ content: ReactNode;
5
+ direction?: "top" | "right" | "bottom" | "left";
6
+ delay?: number;
7
+ children: ReactNode;
8
+ }
9
+
10
+ const TooltipX: React.FC<TooltipProps> = ({ content, direction = "top", delay = 400, children }) => {
11
+ const [active, setActive] = useState(false);
12
+ const timeout = useRef<number | null>(null); // <-- browser setTimeout returns number
13
+
14
+ const showTip = () => {
15
+ timeout.current = window.setTimeout(() => {
16
+ setActive(true);
17
+ }, delay);
18
+ };
19
+
20
+ const hideTip = () => {
21
+ if (timeout.current) {
22
+ clearTimeout(timeout.current);
23
+ }
24
+ setActive(false);
25
+ };
26
+
27
+ return (
28
+ <div
29
+ className="Lexical-Tooltip-Wrapper"
30
+ onMouseEnter={showTip}
31
+ onMouseLeave={hideTip}
32
+ >
33
+ {children}
34
+ {active && (
35
+ <div className={`Lexical-Tooltip-Tip ${direction}`}>
36
+ {content}
37
+ </div>
38
+ )}
39
+ </div>
40
+ );
41
+ };
42
+
43
+ export default TooltipX;
@@ -1,4 +1,3 @@
1
- "use client"
2
1
 
3
2
  import * as React from "react"
4
3
  import { Command as CommandPrimitive } from "cmdk"
@@ -0,0 +1,174 @@
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
+ }