@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
package/README.md CHANGED
@@ -1,288 +1,390 @@
1
- # @innoviatech/lexical-text-editor v2.0
2
-
3
- A powerful, customizable rich text editor component built with Lexical and React. Features a modern toolbar, image support, video embedding, and comprehensive text formatting options.
4
-
5
- ![Editor Preview](./editor_screenshot.png)
6
-
7
-
8
- ## What's New in v2.0.7
9
-
10
- - **Image Upload Handler** — Custom upload endpoint support via `onImageUpload` prop
11
- - **Image Captions** — Add and edit captions on images inline
12
- - **Paste Image Support** — Paste images from clipboard with automatic upload
13
- - **No Tailwind CSS Required** - Now uses raw CSS for styling
14
- - **Reduced Dependencies** - Fewer peer dependencies to install
15
- - **Simpler Setup** - Import CSS and start using immediately
16
- - **Lightweight** - Smaller bundle size
17
- - **Better Compatibility** - Works with any React project setup
18
-
19
-
20
-
21
-
22
- ## Features
23
-
24
- - 🎨 **Rich Text Editing** — Bold, italic, underline, strikethrough, code blocks
25
- - 📝 **Text Formatting** — Headers, paragraphs, lists (bulleted & numbered), quotes
26
- - 🔗 **Link Support** — Insert and edit hyperlinks
27
- - 🖼️ **Media Embedding** — Images (with captions & resize), YouTube videos
28
- - 🎯 **Customizable Toolbar** — Modern, intuitive interface
29
- - 🎨 **Color Picker** — Text and background color options
30
- - 📱 **Responsive Design** — Works on desktop and mobile
31
- - ⚡ **TypeScript Support** — Fully typed for better development experience
32
-
33
-
34
-
35
- ## Installation
36
-
37
- ```bash
38
- npm install @innoviatech/lexical-text-editor
39
- ```
40
-
41
- ### No Peer Dependencies Required! 🎉
42
-
43
- Version 2.0 eliminates the need for Tailwind CSS and multiple UI libraries. Just install the package and start using it!
44
-
45
-
46
- ## Quick Start
47
-
48
- ```tsx
49
- import React, { useState } from 'react';
50
- import { LexicalTextEditor } from '@innoviatech/lexical-text-editor';
51
- import '@innoviatech/lexical-text-editor/style.css';
52
-
53
- function App() {
54
- const [content, setContent] = useState('');
55
-
56
- return (
57
- <>
58
- <LexicalTextEditor
59
- name="my-editor"
60
- value={content}
61
- onChange={setContent}
62
- placeholder="Start typing your content here..."
63
- />
64
- </>
65
- );
66
- }
67
-
68
- export default App;
69
- ```
70
-
71
-
72
-
73
- ## Props
74
-
75
- | Prop | Type | Required | Default | Description |
76
- |----------------|-------------------------------------|----------|---------------|----------------------------------------------------------|
77
- | `name` | `string` | Yes | — | Unique identifier for the editor instance |
78
- | `value` | `string` | Yes | — | Current editor content (HTML string) |
79
- | `onChange` | `(value: string) => void` | Yes | — | Callback fired when content changes |
80
- | `placeholder` | `string` | No | `"Some Text"` | Placeholder text when editor is empty |
81
- | `maxWidth` | `string` | No | `"1090px"` | Adjust the maximum width (`'80%'` or `'800px'`) |
82
- | `height` | `string` | No | `"500px"` | Adjust the height (`'50vh'` or `'500px'`) |
83
- | `onImageUpload`| `(file: File) => Promise<string>` | No | — | Custom handler for uploading images to your server |
84
-
85
-
86
-
87
- ## Advanced Usage
88
-
89
- ### With Initial Content
90
-
91
- ```tsx
92
- import React, { useState } from 'react';
93
- import { LexicalTextEditor } from '@innoviatech/lexical-text-editor';
94
- import '@innoviatech/lexical-text-editor/style.css';
95
-
96
- function App() {
97
- const [content, setContent] = useState('<p>Welcome to the editor!</p><ul><li>Feature 1</li><li>Feature 2</li></ul>');
98
-
99
- const handleSave = () => {
100
- console.log('Current content:', content);
101
- };
102
-
103
- return (
104
- <form onSubmit={handleSave}>
105
- <LexicalTextEditor
106
- name="content-editor"
107
- value={content}
108
- onChange={setContent}
109
- placeholder="Write your content..."
110
- maxWidth="600px"
111
- height="400px"
112
- />
113
- <button type="submit">Save Content</button>
114
- </form>
115
- );
116
- }
117
-
118
- export default App;
119
- ```
120
-
121
-
122
- ### Image Upload Handler
123
-
124
- Upload images to your own server instead of using temporary blob URLs:
125
-
126
- ```tsx
127
- import React, { useState } from 'react';
128
- import { LexicalTextEditor } from '@innoviatech/lexical-text-editor';
129
- import '@innoviatech/lexical-text-editor/style.css';
130
-
131
- function App() {
132
- const [content, setContent] = useState('');
133
-
134
- const handleImageUpload = async (file: File): Promise<string> => {
135
- const formData = new FormData();
136
- formData.append('image', file);
137
-
138
- const res = await fetch('/api/upload', {
139
- method: 'POST',
140
- body: formData,
141
- });
142
-
143
- const data = await res.json();
144
- if (!data.url) throw new Error('Upload failed');
145
- return data.url; // permanent URL stored in editor content
146
- };
147
-
148
- return (
149
- <LexicalTextEditor
150
- name="editor"
151
- value={content}
152
- onChange={setContent}
153
- onImageUpload={handleImageUpload}
154
- />
155
- );
156
- }
157
- ```
158
-
159
- When `onImageUpload` is provided, images selected via the dialog, pasted from clipboard, or drag-dropped will be uploaded to your endpoint. The returned URL is stored permanently in the editor content (unlike temporary blob URLs).
160
-
161
- ### Image Captions
162
-
163
- Images support captions. When inserting an image via the dialog, fill in the **Caption** field. After insertion, click the caption text below the image to edit it inline, or click **"+ Add caption"** to add one.
164
-
165
- ## Toolbar Features
166
-
167
- - Text Formatting: Bold, Italic, Underline, Strikethrough
168
- - Headings: H1–H6
169
- - Lists: Bulleted and Numbered
170
- - Alignment: Left, Center, Right, Justify
171
- - Text Case: Uppercase, Lowercase, Capitalize
172
- - Colors: Text & background color picker
173
- - Media: Image upload, YouTube embedding, video node
174
- - Links: Insert and edit hyperlinks
175
- - Code: Inline code & code blocks
176
- - Quotes: Blockquote formatting
177
- - Undo/Redo, Clear formatting, Remove link
178
-
179
-
180
- ## Browser Support
181
-
182
- - Chrome 90+
183
- - Firefox 88+
184
- - Safari 14+
185
- - Edge 90+
186
-
187
-
188
- ## Troubleshooting
189
-
190
-
191
- - **CSS not loading:** `import '@innoviatech/lexical-text-editor/style.css'`
192
- - **Editor not rendering:** Check that React 18+ or next.js 14+ is installed
193
- - **TypeScript errors:** Update to TypeScript 5.0+
194
- - **Missing styles:** Verify the CSS import path is correct
195
-
196
-
197
-
198
- ## Version Compatibility
199
-
200
- - React 18+
201
- - Next.js 14+
202
- - Lexical 0.36.0+
203
- - TypeScript 5.0+
204
-
205
-
206
- ## License
207
-
208
- MIT © Innoviatech
209
-
210
- ## Support & Community
211
-
212
- ### Get Help
213
-
214
- We're here to help you succeed with our editor! Here are the best ways to get support:
215
-
216
- ### Report an Issue
217
- Found a bug or experiencing problems?
218
- 👉 [Open a GitHub Issue](https://github.com/technohaattech/Lexical-Text-Editor/issues)
219
-
220
- **Please include:**
221
- - 📱 **Environment** (Browser, OS, React/Next.js version)
222
- - 🔍 **Steps to reproduce**
223
- - 🎯 **Expected vs Actual behavior**
224
- - 📋 **Relevant code snippets**
225
- - 🖼️ **Screenshots** (if applicable)
226
-
227
- ### Request a Feature
228
- Have an idea to make the editor even better?
229
- ✨ [Submit a Feature Request](https://github.com/technohaattech/Lexical-Text-Editor/issues/new?template=feature_request.md)
230
-
231
-
232
-
233
- ### Documentation
234
- [Getting Started Guide](https://github.com/technohaattech/Lexical-Text-Editor)
235
-
236
- ### Video Tutorials
237
- - [Installation & Setup](https://youtube.com/playlist?list=...) *(Coming Soon!)*
238
- - [Advanced Features](https://youtube.com/playlist?list=...) *(Coming Soon!)*
239
- - [Integration Examples](https://youtube.com/playlist?list=...) *(Coming Soon!)*
240
-
241
- ### Community
242
- Join our growing community of developers:
243
-
244
- | Platform | Link | Best For |
245
- |----------|------|----------|
246
- | **GitHub Discussions** | [Join Discussion](https://github.com/technohaattech/Lexical-Text-Editor/discussions) | Questions & ideas |
247
-
248
-
249
- ### Contribute
250
-
251
- Love our editor? Here's how you can contribute:
252
-
253
- ### Ways to Contribute
254
- - 📝 **Improve Documentation** – Help others learn
255
- - 🔧 **Fix Bugs** – Submit pull requests
256
- - ✨ **Add Features** – Extend functionality
257
- - 🧪 **Write Tests** – Improve reliability
258
- - 🌍 **Translate** – Help with localization
259
- - 📣 **Spread the Word** – Star the repo, share with others
260
-
261
-
262
- ### About Innoviatech
263
-
264
-
265
- **Our Mission**
266
-
267
- At Innoviatech, we believe that creating great digital experiences should be accessible to every developer. We build tools that empower teams to focus on what matters most.
268
-
269
-
270
- **Built with Passion**
271
-
272
- > "Great tools shouldn't get in the way of great ideas. That's why we build editors that feel like an extension of your creativity."
273
-
274
-
275
-
276
- **Star Us on GitHub!**
277
-
278
- If you find this project helpful, please consider giving it a star on GitHub. It helps us reach more developers like you!
279
-
280
- [![Star on GitHub](https://img.shields.io/github/stars/technohaattech/Lexical-Text-Editor?style=social)](https://github.com/technohaattech/Lexical-Text-Editor)
281
-
282
- [![npm version](https://img.shields.io/npm/v/@innoviatech/lexical-text-editor)](
283
- https://www.npmjs.com/package/@innoviatech/lexical-text-editor
284
- )
285
-
286
- ---
287
-
288
- *Made with ❤️ by the Innoviatech team*
1
+ # @innoviatech/lexical-text-editor
2
+
3
+ A rich text editor component for React, built on [Lexical](https://lexical.dev/). It ships with a complete toolbar covering text, block, table, code, and media tools, plus theming, a responsive layout engine, and TypeScript support, all in a single package with plain CSS (no Tailwind required).
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@innoviatech/lexical-text-editor)](https://www.npmjs.com/package/@innoviatech/lexical-text-editor)
6
+ [![GitHub stars](https://img.shields.io/github/stars/technohaattech/lexical-text-editor?style=social)](https://github.com/technohaattech/lexical-text-editor)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](#license)
8
+
9
+ ![Editor Preview](./editor_screenshot.png)
10
+
11
+ ## What's New in v3.0
12
+
13
+ Fourteen new features, all implemented and verified end-to-end in the test app:
14
+
15
+ | Feature | Name | Description |
16
+ |---------|------|-------------|
17
+ | Feature 1 | Clear Formatting | Strips all inline formatting from the current selection (bold, italic, underline, colors, case transforms, and more) with one click. Block-level formatting such as headings and lists is preserved. |
18
+ | Feature 2 | Code Blocks | Block-level code with syntax highlighting and a language picker: JavaScript, TypeScript, Python, Java, C#, C++, PHP, Ruby, Go, Rust, Swift, Kotlin, HTML, CSS, SQL, JSON, Bash, Markdown, YAML, XML, and more. |
19
+ | Feature 3 | Horizontal Rule | Inserts `<hr>` dividers between blocks from the toolbar. |
20
+ | Feature 4 | Tables | Insert tables through a dimension grid picker; insert/delete rows and columns, and toggle a header row. Row/column operations detect the current cell automatically. |
21
+ | Feature 5 | Indent / Outdent | Toolbar buttons plus `Tab` / `Shift+Tab` nesting inside lists, including multi-level list support. |
22
+ | Feature 6 | Font Family Dropdown | Apply Inter, System, Serif, Monospace, Cursive, Georgia, Courier, or revert to Default for the current selection. |
23
+ | Feature 7 | Font Size Dropdown | Fixed presets from 12 px to 48 px, applied per selection, with a Default reset. |
24
+ | Feature 8 | Find & Replace | Live match count ("n of m"), next/previous navigation, match-case toggle, and Replace / Replace All. Replace All runs as a single undo step. |
25
+ | Feature 9 | Source Code View | Toggle between WYSIWYG and raw HTML editing. Edits are applied on demand (Update / Done) so typing malformed markup never floods the undo history. |
26
+ | Feature 10 | Fullscreen Mode | Expands the editor to fill the viewport; `Escape` exits. |
27
+ | Feature 11 | Word / Character Count | Live counts in a status bar, independently hideable. |
28
+ | Feature 12 | Light / Dark / System Theme | `theme` prop plus an end-user switcher in the status bar. Dark styling covers every UI surface; `system` tracks the OS `prefers-color-scheme` live and is SSR-safe. |
29
+ | Feature 13 | Toolbar Style Variants | `wrap` (tools flow across lines), `collapse` (single row with a "…" overflow button), and `scrollbar` (single row with a custom slim scrollbar). |
30
+ | Feature 14 | Responsive Overflow Toolbar | Predictive width fitting via `ResizeObserver`: primary tools (undo/redo, headings, text formats, alignment, link) stay inline while the rest collapse into the "…" panel on narrow containers. |
31
+
32
+ ### Previous releases
33
+
34
+ - v2.0.x: Custom image upload handler (`onImageUpload`), image captions, paste-image support, plain-CSS styling (Tailwind removed), and a reduced dependency footprint.
35
+
36
+ ## Features
37
+
38
+ - **Text formatting:** bold, italic, underline, strikethrough, superscript, subscript, inline code, highlight, text case (uppercase / lowercase / capitalize)
39
+ - **Block formatting:** headings (H1 to H6), paragraphs, quotes, ordered & unordered lists, horizontal rules
40
+ - **Tables & code:** table editor with row/column operations and header rows; syntax-highlighted code blocks in 20+ languages
41
+ - **Links & media:** hyperlink insert/edit/remove; images (URL, upload, paste, captions) and YouTube / Google Drive embeds
42
+ - **Editor utilities:** find & replace, source code view, fullscreen, content preview, clear formatting, undo/redo
43
+ - **Typography controls:** font family and font size dropdowns, text & background color pickers
44
+ - **Theming:** light, dark, and system color schemes with full dark-mode styling
45
+ - **Responsive toolbar:** wrap / collapse / scrollbar layouts with automatic overflow handling
46
+ - **Status bar:** live word and character count, user-facing theme and layout switchers
47
+ - **Developer experience:** fully typed TypeScript API, controlled HTML value model, minimal CSS integration
48
+
49
+ ## Installation
50
+
51
+ ```bash
52
+ npm install @innoviatech/lexical-text-editor
53
+ ```
54
+
55
+ ### Dependencies
56
+
57
+ The package relies on matching Lexical peer packages. npm 7+ installs peer dependencies automatically; with yarn or pnpm, install them explicitly:
58
+
59
+ ```bash
60
+ npm install lexical@^0.36.2 @lexical/react@^0.36.2 @lexical/code@^0.36.2 @lexical/link@^0.36.2 \
61
+ @lexical/list@^0.36.2 @lexical/rich-text@^0.36.2 @lexical/table@^0.36.2 \
62
+ react-color react-icons
63
+ ```
64
+
65
+ No Tailwind CSS is required: just import the stylesheet and use the component directly.
66
+
67
+ ## Quick Start
68
+
69
+ ```tsx
70
+ import React, { useState } from 'react';
71
+ import { LexicalTextEditor } from '@innoviatech/lexical-text-editor';
72
+ import '@innoviatech/lexical-text-editor/style.css';
73
+
74
+ function App() {
75
+ const [content, setContent] = useState('');
76
+
77
+ return (
78
+ <LexicalTextEditor
79
+ name="my-editor"
80
+ value={content}
81
+ onChange={setContent}
82
+ placeholder="Start typing your content here..."
83
+ />
84
+ );
85
+ }
86
+
87
+ export default App;
88
+ ```
89
+
90
+ ## Props
91
+
92
+ | Prop | Type | Required | Default | Description |
93
+ |----------------|-------------------------------------|----------|---------------|----------------------------------------------------------|
94
+ | `name` | `string` | Yes | none | Unique identifier for the editor instance |
95
+ | `value` | `string` | Yes | none | Current editor content (HTML string) |
96
+ | `onChange` | `(value: string) => void` | Yes | none | Callback fired when content changes |
97
+ | `placeholder` | `string` | No | `"Some Text"` | Placeholder text when editor is empty |
98
+ | `maxWidth` | `string` | No | `"1090px"` | Adjust the maximum width (`'80%'` or `'800px'`) |
99
+ | `height` | `string` | No | `"500px"` | Adjust the height (`'50vh'` or `'500px'`) |
100
+ | `onImageUpload`| `(file: File) => Promise<string>` | No | none | Custom handler for uploading images to your server |
101
+ | `theme` | `'light' \| 'dark' \| 'system'` | No | `'system'` | Color scheme; `'system'` follows the OS `prefers-color-scheme` |
102
+ | `toolbarStyle` | `'wrap' \| 'collapse' \| 'scrollbar'` | No | `'collapse'` | Toolbar layout (`'normal'` is a deprecated alias for `'collapse'`) |
103
+ | `showWordCount`| `boolean` | No | `true` | Show live word count in the status bar |
104
+ | `showCharCount`| `boolean` | No | `true` | Show live character count in the status bar |
105
+ | `showDisplayControls` | `boolean` | No | `true` | Show light/dark + toolbar-style switchers in the status bar so end users can change these too |
106
+ | `onThemeChange`| `(theme: 'light' \| 'dark' \| 'system') => void` | No | none | Fires when the end user switches theme from the editor UI (not on prop changes) |
107
+ | `onToolbarStyleChange` | `(style: 'wrap' \| 'collapse' \| 'scrollbar') => void` | No | none | Fires when the end user switches toolbar style from the editor UI (not on prop changes) |
108
+
109
+ ## Advanced Usage
110
+
111
+ ### With Initial Content
112
+
113
+ ```tsx
114
+ import React, { useState } from 'react';
115
+ import { LexicalTextEditor } from '@innoviatech/lexical-text-editor';
116
+ import '@innoviatech/lexical-text-editor/style.css';
117
+
118
+ function App() {
119
+ const [content, setContent] = useState(
120
+ '<p>Welcome to the editor!</p><ul><li>Feature 1</li><li>Feature 2</li></ul>'
121
+ );
122
+
123
+ return (
124
+ <LexicalTextEditor
125
+ name="content-editor"
126
+ value={content}
127
+ onChange={setContent}
128
+ placeholder="Write your content..."
129
+ maxWidth="600px"
130
+ height="400px"
131
+ />
132
+ );
133
+ }
134
+ ```
135
+
136
+ ### Theme Control (Light / Dark / System)
137
+
138
+ Control the color scheme programmatically and persist the end user's choice:
139
+
140
+ ```tsx
141
+ const [theme, setTheme] = useState<'light' | 'dark' | 'system'>('system');
142
+
143
+ <LexicalTextEditor
144
+ name="editor"
145
+ value={content}
146
+ onChange={setContent}
147
+ theme={theme}
148
+ onThemeChange={(t) => {
149
+ setTheme(t);
150
+ localStorage.setItem('editor-theme', t); // persist the user's choice
151
+ }}
152
+ />
153
+ ```
154
+
155
+ `'system'` follows the OS color scheme live (including change events) and is SSR/render-safe because `matchMedia` is only touched inside effects.
156
+
157
+ ### Toolbar Style + Display Controls
158
+
159
+ Choose `wrap` (tools flow to new lines), `collapse` (single row; overflowed tools collapse into a "…" button + modal; this is the default), or `scrollbar` (single scrollable row with a custom slim scrollbar):
160
+
161
+ ```tsx
162
+ <LexicalTextEditor
163
+ name="editor"
164
+ value={content}
165
+ onChange={setContent}
166
+ toolbarStyle="collapse" // 'wrap' | 'collapse' | 'scrollbar'
167
+ onToolbarStyleChange={(style) => persist(style)}
168
+ showDisplayControls // status-bar switchers for end users (default: true)
169
+ />
170
+ ```
171
+
172
+ In `collapse` mode the toolbar measures its width with a `ResizeObserver` and collapses non-primary segments (last in, first out; undo/redo and the heading picker are never collapsed) until everything fits.
173
+
174
+ ### Hiding Status Bar Elements
175
+
176
+ ```tsx
177
+ <LexicalTextEditor
178
+ name="editor"
179
+ value={content}
180
+ onChange={setContent}
181
+ showWordCount={false}
182
+ showCharCount={false}
183
+ showDisplayControls={false}
184
+ />
185
+ ```
186
+
187
+ ### Custom Image Upload
188
+
189
+ Upload images to your own server instead of using temporary blob URLs:
190
+
191
+ ```tsx
192
+ const handleImageUpload = async (file: File): Promise<string> => {
193
+ const formData = new FormData();
194
+ formData.append('image', file);
195
+
196
+ const res = await fetch('/api/upload', { method: 'POST', body: formData });
197
+ const data = await res.json();
198
+ if (!data.url) throw new Error('Upload failed');
199
+ return data.url; // permanent URL stored in editor content
200
+ };
201
+
202
+ <LexicalTextEditor
203
+ name="editor"
204
+ value={content}
205
+ onChange={setContent}
206
+ onImageUpload={handleImageUpload}
207
+ />
208
+ ```
209
+
210
+ When `onImageUpload` is provided, images selected via the dialog, pasted from the clipboard, or drag-dropped are uploaded to your endpoint. The returned URL is stored permanently in the editor content (unlike temporary blob URLs).
211
+
212
+ ### Image Captions
213
+
214
+ Images support captions. Fill in the **Caption** field when inserting an image via the dialog, or click **"+ Add caption"** below an inserted image to edit it inline.
215
+
216
+ ### Find & Replace / Source Code View
217
+
218
+ Both require no configuration; they are toolbar utilities:
219
+
220
+ - **Find & Replace** (magnifier icon): search with a live "n of m" match count, `Enter` / `Shift+Enter` to navigate, `Match case` toggle, Replace / Replace All, `Escape` closes the panel.
221
+ - **Source Code View** (`</>` icon): edit raw HTML in a textarea; **Update** applies edits to the editor, **Done** applies and exits. Toggle the toolbar button again to close without applying.
222
+
223
+ ## Toolbar Reference
224
+
225
+ | Group | Tools |
226
+ |-------|-------|
227
+ | Undo / Redo | History operations (redo disabled when empty) |
228
+ | Headings | Normal, H1 to H6 |
229
+ | Text formats | Bold, Italic, Underline, Quote, Inline Code, Clear Formatting |
230
+ | Case & extras | Uppercase, Lowercase, Capitalize, Strikethrough, Highlight, Superscript, Subscript |
231
+ | Typography | Font family, font size |
232
+ | Colors | Text color, background color (SketchPicker) |
233
+ | Lists & blocks | Ordered list, unordered list, indent, outdent, horizontal rule |
234
+ | Layout | Alignment (left, center, right, justify) |
235
+ | Links & code | Link insert/edit/remove, code block with language picker |
236
+ | Media | Image (URL / upload), YouTube & Google Drive video |
237
+ | Utilities | Find & Replace, Source Code View, Fullscreen, Content Preview |
238
+ | Status bar | Word count, character count, theme switcher, toolbar style switcher |
239
+
240
+ ## Browser Support
241
+
242
+ - Chrome 90+
243
+ - Firefox 88+
244
+ - Safari 14+
245
+ - Edge 90+
246
+
247
+ ## Troubleshooting
248
+
249
+ | Problem | Solution |
250
+ |---------|----------|
251
+ | CSS not loading | Verify the import: `import '@innoviatech/lexical-text-editor/style.css'` |
252
+ | Editor not rendering | Confirm React 18+ (Next.js 14+) is installed |
253
+ | Runtime Lexical errors | Install the Lexical peer packages at `^0.36.2` (see [Dependencies](#dependencies)); mismatched versions across `node_modules` cause errors. Run `npm dedupe` and configure bundler-level dedupe for `lexical`. |
254
+ | TypeScript errors | Update to TypeScript 5.0+ |
255
+ | Missing styles | Confirm the CSS import path is correct |
256
+ | Dropdowns / popovers clipped | Do not add `overflow: hidden` to ancestors of the toolbar; popovers are absolutely positioned and require `overflow: visible` on ancestor elements. |
257
+
258
+ ## Version Compatibility
259
+
260
+ - React 18+
261
+ - Next.js 14+
262
+ - Lexical 0.36.2
263
+ - TypeScript 5.0+
264
+
265
+ ## License
266
+
267
+ [MIT](https://github.com/technohaattech/lexical-text-editor/blob/main/LICENSE) © Innoviatech
268
+
269
+ ## Publishing to npm (Maintainers)
270
+
271
+ Release process for this package:
272
+
273
+ ### Prerequisites
274
+
275
+ 1. An npm account with publish access to the `@innoviatech` scope
276
+ (`npm access ls-packages innoviatech` to verify).
277
+ 2. `npm login` completed locally. If 2FA is enabled, keep the authenticator ready.
278
+ 3. A clean working tree on `main`:
279
+
280
+ ```bash
281
+ git status
282
+ git checkout main
283
+ git pull origin main
284
+ ```
285
+
286
+ ### Step 1: Bump the version
287
+
288
+ ```bash
289
+ npm version 3.0.0 --no-git-tag-version
290
+ # or semantic shortcuts:
291
+ # npm version patch # 3.0.1 bugfix / docs / styles
292
+ # npm version minor # 3.1.0 new feature, backwards-compatible
293
+ # npm version major # 4.0.0 breaking change
294
+ ```
295
+
296
+ Commit and tag:
297
+
298
+ ```bash
299
+ git add package.json package-lock.json
300
+ git commit -m "chore: release v3.0.0"
301
+ git tag v3.0.0
302
+ ```
303
+
304
+ ### Step 2: Build and sanity-check
305
+
306
+ `prepublishOnly` runs the build automatically on publish; verify beforehand:
307
+
308
+ ```bash
309
+ npm run build # dist/index.js, dist/index.esm.js, dist/index.d.ts, dist/lexical-editor.css
310
+ npx tsc --noEmit # typecheck the source
311
+ npm pack --dry-run # review the exact tarball contents (files + sizes)
312
+ ```
313
+
314
+ Checklist for the dry-run output:
315
+ - [ ] `dist/index.js`, `dist/index.esm.js`, `dist/index.d.ts`, `dist/lexical-editor.css` present
316
+ - [ ] `README.md`, `package.json` present
317
+ - [ ] No stray files (`src/`, `rollup.config.js`, test folders); the `files` whitelist in `package.json` enforces this
318
+
319
+ ### Step 3: Smoke-test the tarball locally (recommended)
320
+
321
+ ```bash
322
+ npm pack # innoviatech-lexical-text-editor-3.0.0.tgz
323
+ cd ../test-app
324
+ npm install ../Lexical-Text-Editor/innoviatech-lexical-text-editor-3.0.0.tgz
325
+ npm run build && npm run dev # exercise the editor once
326
+ ```
327
+
328
+ ### Step 4: Publish
329
+
330
+ The package is scoped, so public access must be requested explicitly:
331
+
332
+ ```bash
333
+ npm publish --access public # enter OTP if prompted
334
+ ```
335
+
336
+ If the publish was interrupted, the version metadata may already be reserved.
337
+ Check `npm view @innoviatech/lexical-text-editor` and recover with
338
+ `npm publish --foreground-scripts`, or as a last resort unpublish and republish deliberately.
339
+
340
+ ### Step 5: Verify and tag the release
341
+
342
+ ```bash
343
+ npm view @innoviatech/lexical-text-editor version # should print the new version
344
+ git push origin main --tags
345
+ ```
346
+
347
+ Create a GitHub Release under `technohaattech/lexical-text-editor → Releases`, select the
348
+ `v3.0.0` tag, paste the "What's New" notes, and publish the release.
349
+
350
+ ### Quick reference
351
+
352
+ ```bash
353
+ npm run build && npx tsc --noEmit # 1. build + typecheck
354
+ npm version <x.y.z> --no-git-tag-version # 2. bump
355
+ git add -A && git commit -m "chore: release vX.Y.Z" && git tag vX.Y.Z
356
+ npm pack --dry-run # 3. inspect tarball
357
+ npm publish --access public # 4. publish
358
+ git push origin main --tags # 5. push code + tag
359
+ ```
360
+
361
+ ## Support & Community
362
+
363
+ ### Reporting Issues
364
+
365
+ Open an issue at [GitHub Issues](https://github.com/technohaattech/lexical-text-editor/issues) and include:
366
+
367
+ - Environment details (browser, OS, React / Next.js version)
368
+ - Steps to reproduce
369
+ - Expected vs. actual behavior
370
+ - Relevant code snippets and screenshots, if applicable
371
+
372
+ ### Feature Requests
373
+
374
+ Submit ideas via the
375
+ [feature request template](https://github.com/technohaattech/lexical-text-editor/issues/new?template=feature_request.md).
376
+
377
+ ### Contributing
378
+
379
+ Contributions are welcome:
380
+
381
+ - Improve the documentation
382
+ - Fix bugs or add features via pull requests
383
+ - Write tests
384
+ - Star and share the repository
385
+
386
+ Give the project a ⭐ on GitHub if you find it useful; it helps other developers discover it.
387
+
388
+ ---
389
+
390
+ *Built and maintained by the Innoviatech team.*