@lyfie/luthor 2.0.0 → 2.1.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 (3) hide show
  1. package/README.md +527 -20
  2. package/dist/index.js +1 -1
  3. package/package.json +15 -15
package/README.md CHANGED
@@ -1,48 +1,555 @@
1
1
  # Luthor Presets
2
2
 
3
- Presets and plug-and-play configurations for the Luthor headless editor.
3
+ **Batteries-included presets and plug-and-play configurations for the Luthor editor**
4
4
 
5
- ## Install
5
+ This package provides ready-to-use editor presets built on top of [@lyfie/luthor-headless](../headless/README.md). All Lexical dependencies are included - no additional installations required.
6
+
7
+ [![npm version](https://badge.fury.io/js/%40lyfie%2Fluthor.svg)](https://badge.fury.io/js/%40lyfie%2Fluthor)
8
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
9
+
10
+ ---
11
+
12
+ ## Why Use This Package?
13
+
14
+ ### ✅ Zero Configuration Hassle
15
+ - All Lexical packages bundled as dependencies
16
+ - No peer dependency warnings
17
+ - No version conflicts to resolve
18
+
19
+ ### 🎮 Ready-to-Use Editors
20
+ - Multiple presets for different use cases
21
+ - Pre-built toolbar components
22
+ - Styled and themed out of the box
23
+
24
+ ### 🔧 Still Fully Customizable
25
+ - Extend or modify any preset
26
+ - Access all luthor-headless features
27
+ - Build on top of presets with your own extensions
28
+
29
+ ---
30
+
31
+ ## Installation
32
+
33
+ Install both the headless package and this preset package:
6
34
 
7
35
  ```bash
8
- npm install @lyfie/luthor @lyfie/luthor-headless
36
+ npm install @lyfie/luthor-headless
37
+ npm install @lyfie/luthor
9
38
  ```
10
39
 
11
- Install the Lexical peer dependencies:
40
+ **That's it!** All required Lexical packages are automatically installed as dependencies of `@lyfie/luthor`.
12
41
 
13
- ```bash
14
- npm install lexical @lexical/react @lexical/html @lexical/markdown @lexical/list @lexical/rich-text @lexical/selection @lexical/utils
42
+ ### What Gets Installed
43
+
44
+ When you install `@lyfie/luthor`, npm automatically installs:
45
+ - `@lyfie/luthor-headless` (the core editor)
46
+ - `lexical` (the Lexical framework)
47
+ - All `@lexical/*` packages (code, html, link, list, markdown, react, rich-text, selection, table, utils)
48
+
49
+ These satisfy the peer dependencies of luthor-headless, so you don't need to install anything else.
50
+
51
+ ### Peer Dependencies
52
+
53
+ Only React remains as a peer dependency (which you already have in your project):
54
+ - `react` (^18.0.0 or ^19.0.0)
55
+ - `react-dom` (^18.0.0 or ^19.0.0)
56
+
57
+ ---
58
+
59
+ ## Quick Start
60
+
61
+ ### Using the Extensive Editor (Recommended)
62
+
63
+ The fastest way to get a full-featured editor:
64
+
65
+ ```tsx
66
+ import { ExtensiveEditor } from "@lyfie/luthor";
67
+ import type { ExtensiveEditorRef } from "@lyfie/luthor";
68
+ import { useRef } from "react";
69
+
70
+ function App() {
71
+ const editorRef = useRef<ExtensiveEditorRef>(null);
72
+
73
+ const handleSave = () => {
74
+ const html = editorRef.current?.getHTML();
75
+ const markdown = editorRef.current?.getMarkdown();
76
+ console.log({ html, markdown });
77
+ };
78
+
79
+ return (
80
+ <div>
81
+ <ExtensiveEditor
82
+ ref={editorRef}
83
+ placeholder="Start writing..."
84
+ onReady={(methods) => {
85
+ console.log("Editor ready!", methods);
86
+ }}
87
+ />
88
+ <button onClick={handleSave}>Save Content</button>
89
+ </div>
90
+ );
91
+ }
15
92
  ```
16
93
 
17
- ## Usage
94
+ This gives you:
95
+ - ✅ Full-featured toolbar
96
+ - ✅ All formatting options (bold, italic, underline, etc.)
97
+ - ✅ Lists, tables, images, links
98
+ - ✅ Code blocks with syntax highlighting
99
+ - ✅ HTML/Markdown export
100
+ - ✅ Dark mode support
101
+ - ✅ Command palette (Cmd+K / Ctrl+K)
102
+
103
+ ### Using Preset Definitions
104
+
105
+ For more control over the editor setup:
18
106
 
19
107
  ```tsx
20
- import { presetRegistry, defaultPreset } from "@lyfie/luthor";
108
+ import { createEditorSystem, RichText } from "@lyfie/luthor-headless";
109
+ import { extensiveExtensions } from "@lyfie/luthor";
21
110
 
22
- // Get a preset by id
23
- const preset = presetRegistry.default;
111
+ const { Provider, useEditor } = createEditorSystem<typeof extensiveExtensions>();
24
112
 
25
- // Or use a named preset directly
26
- const explicit = defaultPreset;
113
+ function MyToolbar() {
114
+ const { commands, activeStates } = useEditor();
115
+
116
+ return (
117
+ <div className="my-custom-toolbar">
118
+ <button onClick={() => commands.toggleBold()}>
119
+ Bold
120
+ </button>
121
+ {/* Add your custom UI */}
122
+ </div>
123
+ );
124
+ }
125
+
126
+ function App() {
127
+ return (
128
+ <Provider extensions={extensiveExtensions}>
129
+ <MyToolbar />
130
+ <RichText placeholder="Start writing..." />
131
+ </Provider>
132
+ );
133
+ }
27
134
  ```
28
135
 
29
- ## What is included
136
+ ---
137
+
138
+ ## Available Presets
139
+
140
+ All presets are exported with their configurations and can be used as starting points:
141
+
142
+ ### 1. **Minimal** - `minimalPreset`
143
+ Lightweight editor for short text and basic formatting.
144
+ - Bold, italic, link
145
+ - Perfect for comments or short descriptions
146
+
147
+ ### 2. **Classic** - `classicPreset`
148
+ Traditional rich text editor feel.
149
+ - Standard formatting toolbar
150
+ - Good for general content editing
151
+
152
+ ### 3. **Blog** - `blogPreset`
153
+ Optimized for blog post writing.
154
+ - Headings, images, quotes
155
+ - Clean reading experience
156
+
157
+ ### 4. **CMS** - `cmsPreset`
158
+ Content management system focused.
159
+ - Advanced formatting options
160
+ - Image handling with alignment
161
+ - Tables for structured content
162
+
163
+ ### 5. **Docs** - `docsPreset`
164
+ Documentation and technical writing.
165
+ - Code blocks with syntax highlighting
166
+ - Tables and lists
167
+ - Markdown export
168
+
169
+ ### 6. **Chat** - `chatPreset`
170
+ Lightweight for messaging interfaces.
171
+ - Minimal formatting
172
+ - Emoji and mentions (with custom extensions)
173
+
174
+ ### 7. **Email** - `emailPreset`
175
+ Email composition focused.
176
+ - Safe HTML output
177
+ - Link handling
178
+ - Simple formatting
179
+
180
+ ### 8. **Markdown** - `markdownPreset`
181
+ Markdown-first editing.
182
+ - Markdown shortcuts
183
+ - Preview mode
184
+ - Clean export
30
185
 
31
- - Preset definitions (toolbar, config, optional theme)
32
- - Registry lookup by id
33
- - Readme files describing each preset
186
+ ### 9. **Code** - `codePreset`
187
+ Code snippet editor.
188
+ - Syntax highlighting
189
+ - Multiple language support
190
+ - Line numbers
34
191
 
35
- ## Customization
192
+ ### 10. **Default** - `defaultPreset`
193
+ Balanced general-purpose editor.
194
+ - Good starting point for customization
36
195
 
37
- Presets are data objects. You can clone and override any field:
196
+ ### 11. **Extensive** - `extensivePreset` + `ExtensiveEditor`
197
+ Full-featured editor with everything.
198
+ - All extensions included
199
+ - Complete toolbar
200
+ - Pre-built component
201
+
202
+ ---
203
+
204
+ ## Usage Examples
205
+
206
+ ### Example 1: Using Preset Registry
207
+
208
+ ```tsx
209
+ import { presetRegistry } from "@lyfie/luthor";
210
+
211
+ // Get a preset by ID
212
+ const blogPreset = presetRegistry.blog;
213
+ const minimalPreset = presetRegistry.minimal;
214
+
215
+ console.log(blogPreset.label); // "Blog"
216
+ console.log(blogPreset.toolbar); // ["heading", "bold", "italic", ...]
217
+ ```
218
+
219
+ ### Example 2: Customizing a Preset
38
220
 
39
221
  ```tsx
40
222
  import { defaultPreset } from "@lyfie/luthor";
223
+ import { createEditorSystem } from "@lyfie/luthor-headless";
41
224
 
225
+ // Clone and customize
42
226
  const myPreset = {
43
227
  ...defaultPreset,
44
- id: "my-default",
45
- label: "My Default",
228
+ id: "my-custom",
229
+ label: "My Custom Editor",
230
+ toolbar: ["bold", "italic", "link"], // Override toolbar
231
+ config: {
232
+ ...defaultPreset.config,
233
+ placeholder: "Write your story...",
234
+ },
235
+ };
236
+ ```
237
+
238
+ ### Example 3: Building with Extensions
239
+
240
+ ```tsx
241
+ import { extensiveExtensions } from "@lyfie/luthor";
242
+ import { createEditorSystem, RichText } from "@lyfie/luthor-headless";
243
+
244
+ const { Provider, useEditor } = createEditorSystem<typeof extensiveExtensions>();
245
+
246
+ function Editor() {
247
+ const { commands } = useEditor();
248
+
249
+ return (
250
+ <div>
251
+ <button onClick={() => commands.toggleBold()}>Bold</button>
252
+ <button onClick={() => commands.insertTable({ rows: 3, cols: 3 })}>
253
+ Insert Table
254
+ </button>
255
+ <RichText />
256
+ </div>
257
+ );
258
+ }
259
+
260
+ function App() {
261
+ return (
262
+ <Provider extensions={extensiveExtensions}>
263
+ <Editor />
264
+ </Provider>
265
+ );
266
+ }
267
+ ```
268
+
269
+ ### Example 4: Export/Import Content
270
+
271
+ ```tsx
272
+ import { ExtensiveEditor } from "@lyfie/luthor";
273
+ import type { ExtensiveEditorRef } from "@lyfie/luthor";
274
+ import { useRef, useState } from "react";
275
+
276
+ function App() {
277
+ const editorRef = useRef<ExtensiveEditorRef>(null);
278
+ const [savedContent, setSavedContent] = useState("");
279
+
280
+ const handleExport = () => {
281
+ const html = editorRef.current?.getHTML();
282
+ const markdown = editorRef.current?.getMarkdown();
283
+ setSavedContent(html || "");
284
+ console.log({ html, markdown });
285
+ };
286
+
287
+ const handleImport = () => {
288
+ editorRef.current?.injectHTML(savedContent);
289
+ // or
290
+ editorRef.current?.injectMarkdown("# Hello\n\nMarkdown content");
291
+ };
292
+
293
+ return (
294
+ <div>
295
+ <ExtensiveEditor ref={editorRef} />
296
+ <button onClick={handleExport}>Export</button>
297
+ <button onClick={handleImport}>Import</button>
298
+ </div>
299
+ );
300
+ }
301
+ ```
302
+
303
+ ---
304
+
305
+ ## API Reference
306
+
307
+ ### ExtensiveEditor Component
308
+
309
+ ```tsx
310
+ import { ExtensiveEditor } from "@lyfie/luthor";
311
+ import type { ExtensiveEditorRef, ExtensiveEditorProps } from "@lyfie/luthor";
312
+ ```
313
+
314
+ **Props:**
315
+ ```typescript
316
+ interface ExtensiveEditorProps {
317
+ placeholder?: string; // Placeholder text
318
+ className?: string; // CSS class for container
319
+ onReady?: (ref: ExtensiveEditorRef) => void; // Called when editor is ready
320
+ }
321
+ ```
322
+
323
+ **Ref Methods:**
324
+ ```typescript
325
+ interface ExtensiveEditorRef {
326
+ injectMarkdown: (content: string) => void; // Import markdown
327
+ injectHTML: (content: string) => void; // Import HTML
328
+ getMarkdown: () => string; // Export as markdown
329
+ getHTML: () => string; // Export as HTML
330
+ }
331
+ ```
332
+
333
+ ### Preset Registry
334
+
335
+ ```tsx
336
+ import { presetRegistry } from "@lyfie/luthor";
337
+ import type { EditorPreset } from "@lyfie/luthor";
338
+ ```
339
+
340
+ **Type:**
341
+ ```typescript
342
+ interface EditorPreset {
343
+ id: string; // Unique preset ID
344
+ label: string; // Display name
345
+ description?: string; // Preset description
346
+ extensions?: Extension[]; // Included extensions
347
+ config?: EditorConfig; // Editor configuration
348
+ theme?: LuthorTheme; // Custom theme
349
+ toolbar?: string[]; // Toolbar items
350
+ components?: Record<string, unknown>; // Custom components
351
+ css?: string; // CSS file path
352
+ }
353
+ ```
354
+
355
+ **Available Presets:**
356
+ - `presetRegistry.minimal`
357
+ - `presetRegistry.classic`
358
+ - `presetRegistry.blog`
359
+ - `presetRegistry.cms`
360
+ - `presetRegistry.docs`
361
+ - `presetRegistry.chat`
362
+ - `presetRegistry.email`
363
+ - `presetRegistry.markdown`
364
+ - `presetRegistry.code`
365
+ - `presetRegistry.default`
366
+ - `presetRegistry.extensive`
367
+
368
+ ### Extension Sets
369
+
370
+ ```tsx
371
+ import { extensiveExtensions } from "@lyfie/luthor";
372
+ ```
373
+
374
+ Pre-configured extension arrays that can be used with luthor-headless:
375
+
376
+ ```typescript
377
+ const extensions = extensiveExtensions as const;
378
+ const { Provider } = createEditorSystem<typeof extensions>();
379
+ ```
380
+
381
+ ---
382
+
383
+ ## Comparison: Headless vs Luthor
384
+
385
+ | Feature | @lyfie/luthor-headless | @lyfie/luthor |
386
+ |---------|----------------------|---------------|
387
+ | **Installation** | Manual Lexical deps | Zero additional deps |
388
+ | **Bundle Size** | Minimal | Includes all Lexical |
389
+ | **Setup Time** | More configuration | Instant |
390
+ | **Flexibility** | Maximum control | Pre-configured |
391
+ | **Use Case** | Custom editors | Quick implementation |
392
+ | **UI Components** | Build your own | ExtensiveEditor included |
393
+ | **Presets** | None | 11 ready-to-use |
394
+ | **Dependencies** | Peer deps | Bundled deps |
395
+
396
+ **Choose luthor-headless when:**
397
+ - Building completely custom UI
398
+ - Need minimal bundle size
399
+ - Want control over Lexical versions
400
+ - Have specific dependency requirements
401
+
402
+ **Choose @lyfie/luthor when:**
403
+ - Want to start quickly
404
+ - Need a working editor ASAP
405
+ - Don't want to manage dependencies
406
+ - Want ready-to-use components
407
+
408
+ [📖 Learn more about luthor-headless](../headless/README.md)
409
+
410
+ ---
411
+
412
+ ## Advanced Usage
413
+
414
+ ### Creating Custom Presets
415
+
416
+ ```tsx
417
+ import type { EditorPreset } from "@lyfie/luthor";
418
+ import {
419
+ boldExtension,
420
+ italicExtension,
421
+ linkExtension
422
+ } from "@lyfie/luthor-headless";
423
+
424
+ const myCustomPreset: EditorPreset = {
425
+ id: "my-custom",
426
+ label: "My Custom Editor",
427
+ description: "A tailored editor for my use case",
428
+ extensions: [boldExtension, italicExtension, linkExtension],
429
+ config: {
430
+ placeholder: "Start typing...",
431
+ editable: true,
432
+ },
46
433
  toolbar: ["bold", "italic", "link"],
47
434
  };
48
435
  ```
436
+
437
+ ### Extending Existing Presets
438
+
439
+ ```tsx
440
+ import { defaultPreset } from "@lyfie/luthor";
441
+ import { myCustomExtension } from "./my-extension";
442
+
443
+ const enhancedPreset: EditorPreset = {
444
+ ...defaultPreset,
445
+ id: "enhanced-default",
446
+ extensions: [
447
+ ...(defaultPreset.extensions || []),
448
+ myCustomExtension,
449
+ ],
450
+ toolbar: [
451
+ ...(defaultPreset.toolbar || []),
452
+ "myCustomCommand",
453
+ ],
454
+ };
455
+ ```
456
+
457
+ ### Accessing Luthor-Headless Features
458
+
459
+ Since `@lyfie/luthor` depends on `@lyfie/luthor-headless`, you have access to all headless features:
460
+
461
+ ```tsx
462
+ import { createEditorSystem, RichText } from "@lyfie/luthor-headless";
463
+ import { extensiveExtensions } from "@lyfie/luthor";
464
+
465
+ const { Provider, useEditor } = createEditorSystem<typeof extensiveExtensions>();
466
+
467
+ // Use all luthor-headless APIs
468
+ function MyEditor() {
469
+ const { commands, activeStates, lexical } = useEditor();
470
+
471
+ // Access Lexical editor instance
472
+ lexical?.update(() => {
473
+ // Direct Lexical operations
474
+ });
475
+
476
+ return <RichText />;
477
+ }
478
+ ```
479
+
480
+ ---
481
+
482
+ ## TypeScript Support
483
+
484
+ Fully typed with TypeScript. All exports include type definitions:
485
+
486
+ ```typescript
487
+ import type {
488
+ EditorPreset,
489
+ ExtensiveEditorRef,
490
+ ExtensiveEditorProps,
491
+ ExtensiveEditorMode,
492
+ } from "@lyfie/luthor";
493
+ ```
494
+
495
+ ---
496
+
497
+ ## Styling
498
+
499
+ The `ExtensiveEditor` component includes default styles. To customize:
500
+
501
+ ```tsx
502
+ import { ExtensiveEditor } from "@lyfie/luthor";
503
+
504
+ // Add custom class
505
+ <ExtensiveEditor className="my-editor" />
506
+ ```
507
+
508
+ ```css
509
+ /* Override default styles */
510
+ .my-editor {
511
+ --luthor-bg: #ffffff;
512
+ --luthor-text: #000000;
513
+ --luthor-border: #e5e5e5;
514
+ }
515
+
516
+ /* Dark mode */
517
+ .my-editor.dark {
518
+ --luthor-bg: #1a1a1a;
519
+ --luthor-text: #ffffff;
520
+ --luthor-border: #333333;
521
+ }
522
+ ```
523
+
524
+ ---
525
+
526
+ ## Migration from Headless
527
+
528
+ If you're using luthor-headless and want to switch:
529
+
530
+ **Before:**
531
+ ```bash
532
+ npm install @lyfie/luthor-headless
533
+ npm install lexical @lexical/react @lexical/html # ... many packages
534
+ ```
535
+
536
+ **After:**
537
+ ```bash
538
+ npm install @lyfie/luthor-headless
539
+ npm install @lyfie/luthor
540
+ # Remove individual @lexical/* packages if desired
541
+ ```
542
+
543
+ Your code doesn't need to change! All luthor-headless APIs work the same way.
544
+
545
+ ---
546
+
547
+ ## Examples
548
+
549
+ Check out the [demo site](https://luthor.lyfie.app/demo) for live examples of all presets.
550
+
551
+ ---
552
+
553
+ **Built with ❤️ by the Luthor Team**
554
+
555
+ MIT License - Use it however you want.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import {MarkdownExtension,ALL_MARKDOWN_TRANSFORMERS,ImageExtension,TableExtension,HTMLEmbedExtension,FloatingToolbarExtension,ContextMenuExtension,CommandPaletteExtension,DraggableBlockExtension,LinkExtension,createEditorSystem,boldExtension,italicExtension,underlineExtension,strikethroughExtension,horizontalRuleExtension,listExtension,historyExtension,blockFormatExtension,htmlExtension,codeExtension,codeFormatExtension,RichText}from'@lyfie/luthor-headless';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import Rt,{forwardRef,useState,useRef,useEffect,useMemo}from'react';var te={id:"blog",label:"Blog",description:"Long form publishing with media and quotes.",toolbar:["heading","bold","italic","link","image","blockquote","bulletedList","numberedList"],config:{placeholder:"Tell your story..."},css:"blog/styles.css"};var oe={id:"chat",label:"Chat",description:"Compact composer with mentions and quick formatting.",toolbar:["bold","italic","link","emoji","mention"],config:{placeholder:"Write a message..."},css:"chat/styles.css"};var re={id:"classic",label:"Classic",description:"Full featured WYSIWYG default.",toolbar:["undo","redo","bold","italic","underline","link","image","table","bulletedList","numberedList"],config:{placeholder:"Start writing..."},css:"classic/styles.css"};var ne={id:"cms",label:"CMS",description:"Structured content with validation and schema rules.",toolbar:["heading","bold","italic","link","image"],config:{placeholder:"Compose structured content..."},css:"cms/styles.css"};var ie={id:"code",label:"Code",description:"Developer focused editing with code as a first class block.",toolbar:["code","codeBlock","copy","link"],config:{placeholder:"Paste or write code..."},css:"code/styles.css"};var ae={id:"default",label:"Default",description:"Balanced general purpose editor preset.",toolbar:["heading","bold","italic","link","image","table"],config:{placeholder:"Start writing..."},css:"default/styles.css"};var le={id:"docs",label:"Docs",description:"Documentation focused with code and callouts.",toolbar:["heading","bold","italic","code","codeBlock","link"],config:{placeholder:"Write documentation..."},css:"docs/styles.css"};var se={id:"email",label:"Email",description:"Email safe markup with stricter rules.",toolbar:["bold","italic","link","button","table"],config:{placeholder:"Write an email..."},css:"email/styles.css"};function u({size:e=16,className:n,children:i}){return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:n,"aria-hidden":"true",children:i})}function O(e){return jsxs(u,{...e,children:[jsx("path",{d:"M7 5h6a3 3 0 0 1 0 6H7z"}),jsx("path",{d:"M7 11h7a3 3 0 0 1 0 6H7z"})]})}function $(e){return jsxs(u,{...e,children:[jsx("path",{d:"M11 5h6"}),jsx("path",{d:"M7 19h6"}),jsx("path",{d:"M14 5l-4 14"})]})}function q(e){return jsxs(u,{...e,children:[jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),jsx("path",{d:"M4 20h16"})]})}function j(e){return jsxs(u,{...e,children:[jsx("path",{d:"M4 12h16"}),jsx("path",{d:"M7 5h7a3 3 0 0 1 0 6H7"}),jsx("path",{d:"M7 19h10"})]})}function Q(e){return jsxs(u,{...e,children:[jsx("path",{d:"M8 7l-4 5 4 5"}),jsx("path",{d:"M16 7l4 5-4 5"})]})}function Ee(e){return jsxs(u,{...e,children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M4 18h16"}),jsx("path",{d:"M9 9l-3 3 3 3"}),jsx("path",{d:"M15 9l3 3-3 3"})]})}function R(e){return jsxs(u,{...e,children:[jsx("path",{d:"M10 13a5 5 0 0 1 0-7l2-2a5 5 0 1 1 7 7l-2 2"}),jsx("path",{d:"M14 11a5 5 0 0 1 0 7l-2 2a5 5 0 1 1-7-7l2-2"})]})}function W(e){return jsxs(u,{...e,children:[jsx("path",{d:"M8 8l8 8"}),jsx("path",{d:"M10 13a5 5 0 0 1 0-7l2-2a5 5 0 0 1 7 7l-1 1"}),jsx("path",{d:"M14 11a5 5 0 0 1 0 7l-2 2a5 5 0 0 1-7-7l1-1"})]})}function V(e){return jsxs(u,{...e,children:[jsx("path",{d:"M8 6h12"}),jsx("path",{d:"M8 12h12"}),jsx("path",{d:"M8 18h12"}),jsx("circle",{cx:"4",cy:"6",r:"1"}),jsx("circle",{cx:"4",cy:"12",r:"1"}),jsx("circle",{cx:"4",cy:"18",r:"1"})]})}function Y(e){return jsxs(u,{...e,children:[jsx("path",{d:"M9 6h11"}),jsx("path",{d:"M9 12h11"}),jsx("path",{d:"M9 18h11"}),jsx("path",{d:"M4 6h1"}),jsx("path",{d:"M4 12h1"}),jsx("path",{d:"M4 18h1"})]})}function Ce(e){return jsxs(u,{...e,children:[jsx("path",{d:"M3 7v6h6"}),jsx("path",{d:"M21 17a9 9 0 0 0-9-9H3"})]})}function Me(e){return jsxs(u,{...e,children:[jsx("path",{d:"M21 7v6h-6"}),jsx("path",{d:"M3 17a9 9 0 0 1 9-9h9"})]})}function Pe(e){return jsxs(u,{...e,children:[jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),jsx("circle",{cx:"8",cy:"10",r:"2"}),jsx("path",{d:"M21 16l-5-5-4 4-2-2-5 5"})]})}function _(e){return jsxs(u,{...e,children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M4 12h10"}),jsx("path",{d:"M4 18h12"})]})}function N(e){return jsxs(u,{...e,children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M7 12h10"}),jsx("path",{d:"M6 18h12"})]})}function G(e){return jsxs(u,{...e,children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M10 12h10"}),jsx("path",{d:"M8 18h12"})]})}function Le(e){return jsxs(u,{...e,children:[jsx("path",{d:"M12 16V6"}),jsx("path",{d:"M8 10l4-4 4 4"}),jsx("path",{d:"M4 18h16"})]})}function Be(e){return jsx(u,{...e,children:jsx("path",{d:"M5 12h14"})})}function ze(e){return jsxs(u,{...e,children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),jsx("path",{d:"M3 10h18"}),jsx("path",{d:"M9 4v16"}),jsx("path",{d:"M15 4v16"})]})}function Te(e){return jsxs(u,{...e,children:[jsx("path",{d:"M14 2H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7z"}),jsx("path",{d:"M14 2v5h5"}),jsx("path",{d:"M9 13l-2 2 2 2"}),jsx("path",{d:"M15 13l2 2-2 2"})]})}function Re(e){return jsxs(u,{...e,children:[jsx("path",{d:"M2 12s4-6 10-6 10 6 10 6-4 6-10 6-10-6-10-6"}),jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function Ne(e){return jsxs(u,{...e,children:[jsx("path",{d:"M3 17l4 4"}),jsx("path",{d:"M14 3l7 7"}),jsx("path",{d:"M7 21l10-10"})]})}function Z(e){return jsxs(u,{...e,children:[jsx("path",{d:"M7 7h10v10H7z"}),jsx("path",{d:"M7 7v-2a2 2 0 1 1 4 0v2"}),jsx("path",{d:"M13 7v-2a2 2 0 1 1 4 0v2"}),jsx("path",{d:"M7 17v2a2 2 0 1 0 4 0v-2"}),jsx("path",{d:"M13 17v2a2 2 0 1 0 4 0v-2"})]})}function He(e){return jsxs(u,{...e,children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M12 6v12"})]})}function Ke(e){return jsxs(u,{...e,children:[jsx("path",{d:"M6 8h4v8H6z"}),jsx("path",{d:"M14 8h4v8h-4z"})]})}function Fe(e){return jsxs(u,{...e,children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M4 12h10"}),jsx("path",{d:"M4 18h16"}),jsx("path",{d:"M14 9l4 3-4 3"})]})}function Se(e){return jsxs(u,{...e,children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M4 12h10"}),jsx("path",{d:"M4 18h16"}),jsx("path",{d:"M18 9l-4 3 4 3"})]})}function Ae(e){return jsxs(u,{...e,children:[jsx("circle",{cx:"12",cy:"12",r:"4"}),jsx("path",{d:"M12 2v3"}),jsx("path",{d:"M12 19v3"}),jsx("path",{d:"M4.9 4.9l2.1 2.1"}),jsx("path",{d:"M17 17l2.1 2.1"}),jsx("path",{d:"M2 12h3"}),jsx("path",{d:"M19 12h3"}),jsx("path",{d:"M4.9 19.1L7 17"}),jsx("path",{d:"M17 7l2.1-2.1"})]})}function Ue(e){return jsx(u,{...e,children:jsx("path",{d:"M21 12.8A8 8 0 1 1 11.2 3a6 6 0 0 0 9.8 9.8z"})})}function De(e){return jsxs(u,{...e,children:[jsx("circle",{cx:"11",cy:"11",r:"7"}),jsx("path",{d:"M20 20l-3-3"})]})}function Oe(e){return jsx(u,{...e,children:jsx("path",{d:"M6 9l6 6 6-6"})})}function $e(e){return jsxs(u,{...e,children:[jsx("path",{d:"M6 6l12 12"}),jsx("path",{d:"M18 6l-12 12"})]})}function c({children:e,onClick:n,title:i,active:l,disabled:r,className:a,type:s="button"}){return jsx("button",{type:s,className:`luthor-toolbar-button${l?" active":""}${a?` ${a}`:""}`,onClick:n,title:i,disabled:r,children:e})}function ue({children:e,onClick:n,variant:i="primary",type:l="button",className:r}){return jsx("button",{type:l,onClick:n,className:`${i==="primary"?"luthor-button-primary":"luthor-button-secondary"}${r?` ${r}`:""}`,children:e})}function qe({value:e,onValueChange:n,options:i,placeholder:l="Select..."}){let[r,a]=useState(false),s=useRef(null);useEffect(()=>{function v(y){s.current&&!s.current.contains(y.target)&&a(false);}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]);let d=i.find(v=>v.value===e);return jsxs("div",{className:"luthor-select",ref:s,children:[jsxs("button",{className:`luthor-select-trigger ${r?"open":""}`,onClick:()=>a(!r),type:"button",children:[jsx("span",{children:d?.label||l}),jsx(Oe,{size:14})]}),r&&jsx("div",{className:"luthor-select-dropdown",children:i.map(v=>jsx("button",{className:`luthor-select-option ${e===v.value?"selected":""}`,onClick:()=>{n(v.value),a(false);},type:"button",children:v.label},v.value))})]})}function pe({trigger:e,children:n,isOpen:i,onOpenChange:l}){let r=useRef(null);return useEffect(()=>{function a(s){r.current&&!r.current.contains(s.target)&&l(false);}return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[l]),jsxs("div",{className:"luthor-dropdown",ref:r,children:[jsx("div",{onClick:()=>l(!i),children:e}),i&&jsx("div",{className:"luthor-dropdown-content",children:n})]})}function je({isOpen:e,onClose:n,title:i,children:l}){let r=useRef(null);return useEffect(()=>{function a(d){r.current&&!r.current.contains(d.target)&&n();}function s(d){d.key==="Escape"&&n();}return e&&(document.addEventListener("mousedown",a),document.addEventListener("keydown",s),document.body.style.overflow="hidden"),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",s),document.body.style.overflow="unset";}},[e,n]),e?jsx("div",{className:"luthor-dialog-overlay",children:jsxs("div",{className:"luthor-dialog",ref:r,children:[jsxs("div",{className:"luthor-dialog-header",children:[jsx("h3",{className:"luthor-dialog-title",children:i}),jsx("button",{className:"luthor-dialog-close",onClick:n,type:"button",children:jsx($e,{size:16})})]}),jsx("div",{className:"luthor-dialog-content",children:l})]})}):null}function We(e){let{isVisible:n,selectionRect:i,commands:l,activeStates:r}=e;if(!n||!i)return null;let a={position:"absolute",top:i.y,left:i.positionFromRight?"auto":i.x,right:i.positionFromRight?10:"auto",zIndex:9999,pointerEvents:"auto"};return r?.imageSelected?jsxs("div",{className:"luthor-floating-toolbar",style:a,children:[jsx(c,{onClick:()=>l.setImageAlignment("left"),active:r.isImageAlignedLeft,title:"Align Left",children:jsx(_,{size:14})}),jsx(c,{onClick:()=>l.setImageAlignment("center"),active:r.isImageAlignedCenter,title:"Align Center",children:jsx(N,{size:14})}),jsx(c,{onClick:()=>l.setImageAlignment("right"),active:r.isImageAlignedRight,title:"Align Right",children:jsx(G,{size:14})}),jsx("div",{className:"luthor-floating-toolbar-separator"}),jsx(c,{onClick:()=>l.setImageCaption(prompt("Enter caption:")||""),title:"Edit Caption",children:jsx(Ke,{size:14})})]}):jsxs("div",{className:"luthor-floating-toolbar",style:a,children:[jsx(c,{onClick:()=>l.toggleBold(),active:r.bold,title:"Bold",children:jsx(O,{size:14})}),jsx(c,{onClick:()=>l.toggleItalic(),active:r.italic,title:"Italic",children:jsx($,{size:14})}),jsx(c,{onClick:()=>l.toggleUnderline(),active:r.underline,title:"Underline",children:jsx(q,{size:14})}),jsx(c,{onClick:()=>l.toggleStrikethrough(),active:r.strikethrough,title:"Strikethrough",children:jsx(j,{size:14})}),jsx("div",{className:"luthor-floating-toolbar-separator"}),jsx(c,{onClick:()=>l.formatText("code"),active:r.code,title:"Inline Code",children:jsx(Q,{size:14})}),jsx(c,{onClick:()=>r.isLink?l.removeLink():l.insertLink(),active:r.isLink,title:r.isLink?"Remove Link":"Insert Link",children:r.isLink?jsx(W,{size:14}):jsx(R,{size:14})}),jsx("div",{className:"luthor-floating-toolbar-separator"}),jsx(c,{onClick:()=>l.toggleUnorderedList(),active:r.unorderedList,title:"Bullet List",children:jsx(V,{size:14})}),jsx(c,{onClick:()=>l.toggleOrderedList(),active:r.orderedList,title:"Numbered List",children:jsx(Y,{size:14})})]})}var K=new MarkdownExtension;K.config={...K.config,customTransformers:ALL_MARKDOWN_TRANSFORMERS};var F=new ImageExtension;F.config={...F.config,uploadHandler:async e=>URL.createObjectURL(e),defaultAlignment:"center",resizable:true,pasteListener:{insert:true,replace:true},debug:false};var he=new TableExtension;he.config={...he.config,enableContextMenu:true,markdownExtension:K};var me=new HTMLEmbedExtension;me.config={...me.config,markdownExtension:K};var J={commands:{},activeStates:{}};function Ve(e,n){J.commands=e,J.activeStates=n;}var ge=new FloatingToolbarExtension;ge.config={...ge.config,render:e=>jsx(We,{...e}),getCommands:()=>J.commands,getActiveStates:()=>J.activeStates};var be=new ContextMenuExtension;be.config={...be.config,preventDefault:true};var Ct=new CommandPaletteExtension,fe=new DraggableBlockExtension;fe.config={...fe.config,showMoveButtons:true,showUpButton:true,showDownButton:true,buttonStackPosition:"left"};var xe=new LinkExtension;xe.config={...xe.config,linkSelectedTextOnPaste:true,autoLinkText:true,autoLinkUrls:true};var z=[boldExtension,italicExtension,underlineExtension,strikethroughExtension,xe,horizontalRuleExtension,he,listExtension,historyExtension,F,blockFormatExtension,htmlExtension,K,codeExtension,codeFormatExtension,me,ge,be,Ct,fe];function Ye(){return [{id:"format.bold",label:"Toggle Bold",description:"Make text bold or remove bold formatting",category:"Format",action:e=>e.toggleBold(),shortcuts:[{key:"b",ctrlKey:true}],keywords:["bold","strong","format"]},{id:"format.italic",label:"Toggle Italic",description:"Make text italic or remove italic formatting",category:"Format",action:e=>e.toggleItalic(),shortcuts:[{key:"i",ctrlKey:true}],keywords:["italic","emphasis","format"]},{id:"format.underline",label:"Toggle Underline",description:"Add or remove underline formatting",category:"Format",action:e=>e.toggleUnderline(),shortcuts:[{key:"u",ctrlKey:true}],keywords:["underline","format"]},{id:"format.strikethrough",label:"Toggle Strikethrough",description:"Add or remove strikethrough formatting",category:"Format",action:e=>e.toggleStrikethrough(),keywords:["strikethrough","format"]},{id:"format.code",label:"Toggle Inline Code",description:"Format text as inline code",category:"Format",action:e=>e.formatText("code"),shortcuts:[{key:"`",ctrlKey:true}],keywords:["code","inline","format"]},{id:"block.heading1",label:"Heading 1",description:"Convert to large heading",category:"Block",action:e=>e.toggleHeading("h1"),shortcuts:[{key:"1",ctrlKey:true,altKey:true}],keywords:["heading","h1"]},{id:"block.heading2",label:"Heading 2",description:"Convert to medium heading",category:"Block",action:e=>e.toggleHeading("h2"),shortcuts:[{key:"2",ctrlKey:true,altKey:true}],keywords:["heading","h2"]},{id:"block.heading3",label:"Heading 3",description:"Convert to small heading",category:"Block",action:e=>e.toggleHeading("h3"),shortcuts:[{key:"3",ctrlKey:true,altKey:true}],keywords:["heading","h3"]},{id:"block.paragraph",label:"Paragraph",description:"Convert to paragraph",category:"Block",action:e=>e.toggleParagraph(),shortcuts:[{key:"0",ctrlKey:true,altKey:true}],keywords:["paragraph","text"]},{id:"block.quote",label:"Quote",description:"Convert to blockquote",category:"Block",action:e=>e.toggleQuote(),keywords:["quote","blockquote"]},{id:"block.codeblock",label:"Code Block",description:"Convert to code block",category:"Block",action:e=>e.toggleCodeBlock(),shortcuts:[{key:"`",ctrlKey:true,shiftKey:true}],keywords:["code","block"]},{id:"list.bullet",label:"Bullet List",description:"Create or toggle bullet list",category:"List",action:e=>e.toggleUnorderedList(),shortcuts:[{key:"l",ctrlKey:true,shiftKey:true}],keywords:["list","bullet"]},{id:"list.numbered",label:"Numbered List",description:"Create or toggle numbered list",category:"List",action:e=>e.toggleOrderedList(),shortcuts:[{key:"l",ctrlKey:true,altKey:true}],keywords:["list","numbered"]},{id:"link.insert",label:"Insert Link",description:"Insert or edit a link",category:"Insert",action:e=>e.insertLink(),shortcuts:[{key:"k",ctrlKey:true}],keywords:["link","url"]},{id:"link.remove",label:"Remove Link",description:"Remove link formatting",category:"Format",action:e=>e.removeLink(),shortcuts:[{key:"k",ctrlKey:true,shiftKey:true}],keywords:["unlink","remove","link"]},{id:"insert.horizontal-rule",label:"Insert Horizontal Rule",description:"Insert a horizontal line separator",category:"Insert",action:e=>e.insertHorizontalRule(),keywords:["horizontal","rule"]},{id:"insert.image",label:"Insert Image",description:"Insert an image from URL",category:"Insert",action:e=>{let n=prompt("Enter image URL:");if(n){let i=prompt("Enter alt text:")||"";e.insertImage({src:n,alt:i});}},keywords:["image","photo"]},{id:"insert.table",label:"Insert Table",description:"Insert a 3x3 table",category:"Insert",action:e=>e.insertTable({rows:3,columns:3,includeHeaders:true}),keywords:["table","grid"]},{id:"insert.html-embed",label:"Insert HTML Embed",description:"Insert a custom HTML block",category:"Insert",action:e=>e.insertHTMLEmbed(),keywords:["html","embed"]},{id:"edit.undo",label:"Undo",description:"Undo the last action",category:"Edit",action:e=>e.undo(),shortcuts:[{key:"z",ctrlKey:true}],keywords:["undo","revert"]},{id:"edit.redo",label:"Redo",description:"Redo the last undone action",category:"Edit",action:e=>e.redo(),shortcuts:[{key:"y",ctrlKey:true},{key:"z",ctrlKey:true,shiftKey:true}],keywords:["redo","repeat"]},{id:"palette.show",label:"Show Command Palette",description:"Open the command palette",category:"View",action:e=>e.showCommandPalette(),shortcuts:[{key:"p",ctrlKey:true,shiftKey:true}],keywords:["command","palette"]}]}function _e(e){return Ye().map(n=>({id:n.id,label:n.label,description:n.description,category:n.category,action:()=>n.action(e),keywords:n.keywords,shortcut:n.shortcuts?.[0]?Pt(n.shortcuts[0]):void 0}))}function Pt(e){let n=[];return e.ctrlKey&&n.push("Ctrl"),e.metaKey&&n.push("Cmd"),e.altKey&&n.push("Alt"),e.shiftKey&&n.push("Shift"),n.push(e.key.toUpperCase()),n.join("+")}function Ge(e,n=document.body){let i=Ye(),l=r=>{for(let a of i)if(a.shortcuts){for(let s of a.shortcuts)if(r.key.toLowerCase()===s.key.toLowerCase()&&!!r.ctrlKey==!!s.ctrlKey&&!!r.metaKey==!!s.metaKey&&!!r.shiftKey==!!s.shiftKey&&!!r.altKey==!!s.altKey){s.preventDefault!==false&&r.preventDefault(),(!a.condition||a.condition(e))&&a.action(e);return}}};return n.addEventListener("keydown",l),()=>n.removeEventListener("keydown",l)}function zt(e,n){let i=useRef(null),l=F.config;return {handlers:useMemo(()=>({insertFromUrl:()=>{let a=prompt("Enter image URL:");if(!a)return;let s=prompt("Enter alt text:")||"",d=prompt("Enter caption (optional):")||void 0;e.insertImage({src:a,alt:s,caption:d});},insertFromFile:()=>i.current?.click(),handleUpload:async a=>{let s=a.target.files?.[0];if(!s)return;let d;if(l.uploadHandler)try{d=await l.uploadHandler(s);}catch{alert("Failed to upload image");return}else d=URL.createObjectURL(s);e.insertImage({src:d,alt:s.name,file:s}),a.target.value="";},setAlignment:a=>{e.setImageAlignment(a);},setCaption:()=>{let a=prompt("Enter caption:")||"";e.setImageCaption(a);}}),[e,l]),fileInputRef:i}}function Je({commands:e,hasExtension:n,activeStates:i,isDark:l,toggleTheme:r,onCommandPaletteOpen:a,editor:s}){let{handlers:d,fileInputRef:v}=zt(e),[y,w]=useState(false),[h,f]=useState(false),[k,L]=useState(false),[P,B]=useState({rows:3,columns:3,includeHeaders:false}),D=[{value:"p",label:"Paragraph"},{value:"h1",label:"Heading 1"},{value:"h2",label:"Heading 2"},{value:"h3",label:"Heading 3"},{value:"h4",label:"Heading 4"},{value:"h5",label:"Heading 5"},{value:"h6",label:"Heading 6"},{value:"quote",label:"Quote"}],we=i.isH1?"h1":i.isH2?"h2":i.isH3?"h3":i.isH4?"h4":i.isH5?"h5":i.isH6?"h6":i.isQuote?"quote":"p",b=m=>{m==="p"?e.toggleParagraph():m.startsWith("h")?e.toggleHeading(m):m==="quote"&&e.toggleQuote();};return jsxs(Fragment,{children:[jsxs("div",{className:"luthor-toolbar",children:[jsxs("div",{className:"luthor-toolbar-section",children:[jsx(c,{onClick:()=>e.toggleBold(),active:i.bold,title:"Bold (Ctrl+B)",children:jsx(O,{size:16})}),jsx(c,{onClick:()=>e.toggleItalic(),active:i.italic,title:"Italic (Ctrl+I)",children:jsx($,{size:16})}),jsx(c,{onClick:()=>e.toggleUnderline(),active:i.underline,title:"Underline (Ctrl+U)",children:jsx(q,{size:16})}),jsx(c,{onClick:()=>e.toggleStrikethrough(),active:i.strikethrough,title:"Strikethrough",children:jsx(j,{size:16})}),jsx(c,{onClick:()=>e.formatText("code"),active:i.code,title:"Inline Code",children:jsx(Q,{size:16})}),jsx(c,{onClick:()=>i.isLink?e.removeLink():e.insertLink(),active:i.isLink,title:i.isLink?"Remove Link":"Insert Link",children:i.isLink?jsx(W,{size:16}):jsx(R,{size:16})})]}),n("blockFormat")&&jsxs("div",{className:"luthor-toolbar-section",children:[jsx(qe,{value:we,onValueChange:b,options:D,placeholder:"Format"}),n("code")&&jsx(c,{onClick:()=>e.toggleCodeBlock(),active:i.isInCodeBlock,title:"Code Block",children:jsx(Ee,{size:16})})]}),n("list")&&jsxs("div",{className:"luthor-toolbar-section",children:[jsx(c,{onClick:()=>e.toggleUnorderedList(),active:i.unorderedList,title:"Bullet List",children:jsx(V,{size:16})}),jsx(c,{onClick:()=>e.toggleOrderedList(),active:i.orderedList,title:"Numbered List",children:jsx(Y,{size:16})}),(i.unorderedList||i.orderedList)&&jsxs(Fragment,{children:[jsx(c,{onClick:()=>e.indentList(),title:"Indent List",children:jsx(Fe,{size:14})}),jsx(c,{onClick:()=>e.outdentList(),title:"Outdent List",children:jsx(Se,{size:14})})]})]}),n("horizontalRule")&&jsx("div",{className:"luthor-toolbar-section",children:jsx(c,{onClick:()=>e.insertHorizontalRule(),title:"Insert Horizontal Rule",children:jsx(Be,{size:16})})}),n("table")&&jsx("div",{className:"luthor-toolbar-section",children:jsx(c,{onClick:()=>L(true),title:"Insert Table",children:jsx(ze,{size:16})})}),n("image")&&jsxs("div",{className:"luthor-toolbar-section",children:[jsxs(pe,{trigger:jsx("button",{className:`luthor-toolbar-button ${i.imageSelected?"active":""}`,title:"Insert Image",children:jsx(Pe,{size:16})}),isOpen:y,onOpenChange:w,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{d.insertFromUrl(),w(false);},children:[jsx(R,{size:16}),jsx("span",{children:"From URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{d.insertFromFile(),w(false);},children:[jsx(Le,{size:16}),jsx("span",{children:"Upload File"})]})]}),i.imageSelected&&jsxs(pe,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Align Image",children:jsx(N,{size:16})}),isOpen:h,onOpenChange:f,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{d.setAlignment("left"),f(false);},children:[jsx(_,{size:16}),jsx("span",{children:"Align Left"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{d.setAlignment("center"),f(false);},children:[jsx(N,{size:16}),jsx("span",{children:"Align Center"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{d.setAlignment("right"),f(false);},children:[jsx(G,{size:16}),jsx("span",{children:"Align Right"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{d.setCaption(),f(false);},children:[jsx(He,{size:16}),jsx("span",{children:"Set Caption"})]})]}),jsx("input",{ref:v,type:"file",accept:"image/*",onChange:d.handleUpload,className:"luthor-file-input"})]}),n("htmlEmbed")&&jsxs("div",{className:"luthor-toolbar-section",children:[jsx(c,{onClick:()=>e.insertHTMLEmbed(),active:i.isHTMLEmbedSelected,title:"Insert HTML Embed",children:jsx(Te,{size:16})}),i.isHTMLEmbedSelected&&jsx(c,{onClick:()=>e.toggleHTMLPreview(),title:"Toggle Preview/Edit",children:i.isHTMLPreviewMode?jsx(Re,{size:16}):jsx(Ne,{size:16})})]}),n("history")&&jsxs("div",{className:"luthor-toolbar-section",children:[jsx(c,{onClick:()=>e.undo(),disabled:!i.canUndo,title:"Undo (Ctrl+Z)",children:jsx(Ce,{size:16})}),jsx(c,{onClick:()=>e.redo(),disabled:!i.canRedo,title:"Redo (Ctrl+Y)",children:jsx(Me,{size:16})})]}),jsx("div",{className:"luthor-toolbar-section",children:jsx(c,{onClick:a,title:"Command Palette (Ctrl+Shift+P)",children:jsx(Z,{size:16})})}),jsx("div",{className:"luthor-toolbar-section",children:jsx(c,{onClick:r,title:l?"Light Mode":"Dark Mode",children:l?jsx(Ae,{size:16}):jsx(Ue,{size:16})})})]}),jsx(je,{isOpen:k,onClose:()=>L(false),title:"Insert Table",children:jsxs("div",{className:"luthor-table-dialog",children:[jsxs("div",{className:"luthor-form-group",children:[jsx("label",{htmlFor:"table-rows",children:"Rows:"}),jsx("input",{id:"table-rows",type:"number",min:"1",max:"20",value:P.rows,onChange:m=>B(I=>({...I,rows:parseInt(m.target.value)||1})),className:"luthor-input"})]}),jsxs("div",{className:"luthor-form-group",children:[jsx("label",{htmlFor:"table-columns",children:"Columns:"}),jsx("input",{id:"table-columns",type:"number",min:"1",max:"20",value:P.columns,onChange:m=>B(I=>({...I,columns:parseInt(m.target.value)||1})),className:"luthor-input"})]}),jsx("div",{className:"luthor-form-group",children:jsxs("label",{className:"luthor-checkbox-label",children:[jsx("input",{type:"checkbox",checked:P.includeHeaders||false,onChange:m=>B(I=>({...I,includeHeaders:m.target.checked})),className:"luthor-checkbox"}),"Include headers"]})}),jsxs("div",{className:"luthor-dialog-actions",children:[jsx(ue,{variant:"secondary",onClick:()=>L(false),children:"Cancel"}),jsx(ue,{variant:"primary",onClick:()=>{e.insertTable(P),L(false);},children:"Insert Table"})]})]})})]})}function et({isOpen:e,onClose:n,commands:i}){let[l,r]=useState(""),[a,s]=useState(0),d=useRef(null),v=i.filter(h=>`${h.label} ${h.description||""} ${h.keywords?.join(" ")||""}`.toLowerCase().includes(l.toLowerCase())),y=v.reduce((h,f)=>{let k=f.category||"Other";return h[k]||(h[k]=[]),h[k].push(f),h},{}),w=v;return useEffect(()=>{s(0);},[l]),useEffect(()=>{e&&d.current&&(d.current.focus(),r(""),s(0));},[e]),useEffect(()=>{let h=f=>{if(e)switch(f.key){case "Escape":f.preventDefault(),n();break;case "ArrowDown":f.preventDefault(),s(k=>Math.min(k+1,w.length-1));break;case "ArrowUp":f.preventDefault(),s(k=>Math.max(k-1,0));break;case "Enter":f.preventDefault(),w[a]&&(w[a].action(),n());break}};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[e,a,w,n]),e?jsx("div",{className:"luthor-command-palette-overlay",onClick:n,children:jsxs("div",{className:"luthor-command-palette",onClick:h=>h.stopPropagation(),children:[jsxs("div",{className:"luthor-command-palette-header",children:[jsx(De,{size:16,className:"luthor-command-palette-icon"}),jsx("input",{ref:d,type:"text",placeholder:"Type a command or search...",value:l,onChange:h=>r(h.target.value),className:"luthor-command-palette-input"}),jsx("kbd",{className:"luthor-command-palette-kbd",children:"ESC"})]}),jsx("div",{className:"luthor-command-palette-list",children:Object.keys(y).length===0?jsx("div",{className:"luthor-command-palette-empty",children:"No commands found"}):Object.entries(y).map(([h,f])=>jsxs("div",{className:"luthor-command-palette-group",children:[jsx("div",{className:"luthor-command-palette-group-title",children:h}),f.map(k=>{let L=w.indexOf(k);return jsxs("div",{className:`luthor-command-palette-item ${L===a?"selected":""}`,onClick:()=>{k.action(),n();},onMouseEnter:()=>s(L),children:[jsxs("div",{className:"luthor-command-palette-item-content",children:[jsx("div",{className:"luthor-command-palette-item-title",children:k.label}),k.description&&jsx("div",{className:"luthor-command-palette-item-description",children:k.description})]}),k.shortcut&&jsx("kbd",{className:"luthor-command-palette-item-shortcut",children:k.shortcut})]},k.id)})]},h))}),jsx("div",{className:"luthor-command-palette-footer",children:jsxs("span",{className:"luthor-command-palette-hint",children:[jsx(Z,{size:14}),jsx("span",{children:"Use arrow keys, Enter, ESC"})]})})]})}):null}var{Provider:St,useEditor:At}=createEditorSystem();function Ut({mode:e,onModeChange:n}){return jsxs("div",{className:"luthor-mode-tabs",children:[jsx("button",{className:`luthor-mode-tab ${e==="visual"?"active":""}`,onClick:()=>n("visual"),children:"Visual"}),jsx("button",{className:`luthor-mode-tab ${e==="html"?"active":""}`,onClick:()=>n("html"),children:"HTML"}),jsx("button",{className:`luthor-mode-tab ${e==="markdown"?"active":""}`,onClick:()=>n("markdown"),children:"Markdown"})]})}function ot({value:e,onChange:n,placeholder:i}){return jsx("textarea",{className:"luthor-source-view",value:e,onChange:l=>n(l.target.value),placeholder:i,spellCheck:false})}function Dt({className:e,isDark:n,toggleTheme:i,onReady:l}){let{commands:r,hasExtension:a,activeStates:s,lexical:d,extensions:v}=At(),[y,w]=useState("visual"),[h,f]=useState({html:"",markdown:""}),[k,L]=useState({isOpen:false,commands:[]}),P=useRef(r),B=useRef(false);useEffect(()=>{P.current=r;},[r]),useEffect(()=>{Ve(r,s);},[r,s]);let D=useMemo(()=>({injectMarkdown:b=>{setTimeout(()=>{d&&d.update(()=>{P.current.importFromMarkdown(b,{immediate:true,preventFocus:true});});},100);},injectHTML:b=>{setTimeout(()=>{d&&d.update(()=>{P.current.importFromHTML(b,{preventFocus:true});});},100);},getMarkdown:()=>P.current.exportToMarkdown(),getHTML:()=>P.current.exportToHTML()}),[d]);return useEffect(()=>{if(!d||!r)return;let b=_e(r);b.forEach(I=>r.registerCommand(I));let m=Ge(r,document.body);return B.current||(B.current=true,l?.(D)),()=>{m(),b.forEach(I=>r.unregisterCommand(I.id));}},[d,r,D,l]),useEffect(()=>{let b=v.find(m=>m.name==="commandPalette");if(!(!b||!b.subscribe))return b.subscribe((m,I)=>{L({isOpen:m,commands:I});})},[v]),jsxs(Fragment,{children:[jsxs("div",{className:"luthor-editor-header",children:[jsx(Ut,{mode:y,onModeChange:async b=>{if(y==="markdown"&&b!=="markdown"&&a("markdown")&&(await r.importFromMarkdown(h.markdown,{immediate:true}),await new Promise(m=>setTimeout(m,50))),y==="html"&&b!=="html"&&a("html")&&(await r.importFromHTML(h.html),await new Promise(m=>setTimeout(m,50))),b==="markdown"&&y!=="markdown"&&a("markdown")){await new Promise(I=>setTimeout(I,50));let m=r.exportToMarkdown();f(I=>({...I,markdown:m}));}if(b==="html"&&y!=="html"&&a("html")){await new Promise(I=>setTimeout(I,50));let m=r.exportToHTML();f(I=>({...I,html:m}));}w(b),b==="visual"&&setTimeout(()=>d?.focus(),100);}}),y==="visual"&&jsx(Je,{commands:r,hasExtension:a,activeStates:s,isDark:n,toggleTheme:i,onCommandPaletteOpen:()=>r.showCommandPalette(),editor:d})]}),jsxs("div",{className:"luthor-editor","data-mode":y,children:[y==="visual"&&jsx(RichText,{placeholder:"Write anything...",classNames:{container:"luthor-richtext-container",contentEditable:"luthor-content-editable",placeholder:"luthor-placeholder"}}),y!=="visual"&&jsxs("div",{className:"luthor-source-panel",children:[y==="html"&&jsx(ot,{value:h.html,onChange:b=>f(m=>({...m,html:b})),placeholder:"Enter HTML content..."}),y==="markdown"&&jsx(ot,{value:h.markdown,onChange:b=>f(m=>({...m,markdown:b})),placeholder:"Enter Markdown content..."})]})]}),jsx(et,{isOpen:k.isOpen,onClose:()=>r.hideCommandPalette(),commands:k.commands})]})}var U=forwardRef(({className:e,onReady:n,initialTheme:i="light"},l)=>{let[r,a]=useState(i),s=r==="dark",d=()=>a(s?"light":"dark"),[v,y]=useState(null);Rt.useImperativeHandle(l,()=>v,[v]);let w=h=>{y(h),n?.(h);};return jsx("div",{className:`luthor-editor-wrapper ${e||""}`,"data-editor-theme":r,children:jsx(St,{extensions:z,children:jsx(Dt,{className:e,isDark:s,toggleTheme:d,onReady:w})})})});U.displayName="ExtensiveEditor";var ke={id:"extensive",label:"Extensive",description:"All features enabled for power users.",extensions:[...z],components:{Editor:U},toolbar:["undo","redo","heading","bold","italic","underline","strikethrough","link","image","table","blockquote","code","codeBlock","bulletedList","numberedList"],config:{placeholder:"Write anything..."},css:"extensive/styles.css"};var ye={id:"markdown",label:"Markdown",description:"Markdown first editing with predictable output.",toolbar:["bold","italic","link","code","codeBlock"],config:{placeholder:"Write in markdown..."},css:"markdown/styles.css"};var Ie={id:"minimal",label:"Minimal",description:"Lightweight editor for short text and embeds.",toolbar:["bold","italic","link"],config:{placeholder:"Write something..."},css:"minimal/styles.css"};var wr={minimal:Ie,classic:re,docs:le,blog:te,cms:ne,chat:oe,email:se,markdown:ye,code:ie,default:ae,extensive:ke};export{U as ExtensiveEditor,te as blogPreset,oe as chatPreset,re as classicPreset,ne as cmsPreset,ie as codePreset,ae as defaultPreset,le as docsPreset,se as emailPreset,z as extensiveExtensions,ke as extensivePreset,ye as markdownPreset,Ie as minimalPreset,wr as presetRegistry};
1
+ import {MarkdownExtension,ALL_MARKDOWN_TRANSFORMERS,ImageExtension,TableExtension,HTMLEmbedExtension,FloatingToolbarExtension,ContextMenuExtension,CommandPaletteExtension,DraggableBlockExtension,LinkExtension,createEditorSystem,boldExtension,italicExtension,underlineExtension,strikethroughExtension,horizontalRuleExtension,listExtension,historyExtension,blockFormatExtension,htmlExtension,codeExtension,codeFormatExtension,RichText}from'@lyfie/luthor-headless';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import Rt,{forwardRef,useState,useRef,useEffect,useMemo}from'react';var te={id:"blog",label:"Blog",description:"Long form publishing with media and quotes.",toolbar:["heading","bold","italic","link","image","blockquote","bulletedList","numberedList"],config:{placeholder:"Tell your story..."},css:"blog/styles.css"};var oe={id:"chat",label:"Chat",description:"Compact composer with mentions and quick formatting.",toolbar:["bold","italic","link","emoji","mention"],config:{placeholder:"Write a message..."},css:"chat/styles.css"};var re={id:"classic",label:"Classic",description:"Full featured WYSIWYG default.",toolbar:["undo","redo","bold","italic","underline","link","image","table","bulletedList","numberedList"],config:{placeholder:"Start writing..."},css:"classic/styles.css"};var ne={id:"cms",label:"CMS",description:"Structured content with validation and schema rules.",toolbar:["heading","bold","italic","link","image"],config:{placeholder:"Compose structured content..."},css:"cms/styles.css"};var ie={id:"code",label:"Code",description:"Developer focused editing with code as a first class block.",toolbar:["code","codeBlock","copy","link"],config:{placeholder:"Paste or write code..."},css:"code/styles.css"};var ae={id:"default",label:"Default",description:"Balanced general purpose editor preset.",toolbar:["heading","bold","italic","link","image","table"],config:{placeholder:"Start writing..."},css:"default/styles.css"};var le={id:"docs",label:"Docs",description:"Documentation focused with code and callouts.",toolbar:["heading","bold","italic","code","codeBlock","link"],config:{placeholder:"Write documentation..."},css:"docs/styles.css"};var se={id:"email",label:"Email",description:"Email safe markup with stricter rules.",toolbar:["bold","italic","link","button","table"],config:{placeholder:"Write an email..."},css:"email/styles.css"};function u({size:e=16,className:n,children:i}){return jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:n,"aria-hidden":"true",children:i})}function O(e){return jsxs(u,{...e,children:[jsx("path",{d:"M7 5h6a3 3 0 0 1 0 6H7z"}),jsx("path",{d:"M7 11h7a3 3 0 0 1 0 6H7z"})]})}function $(e){return jsxs(u,{...e,children:[jsx("path",{d:"M11 5h6"}),jsx("path",{d:"M7 19h6"}),jsx("path",{d:"M14 5l-4 14"})]})}function q(e){return jsxs(u,{...e,children:[jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),jsx("path",{d:"M4 20h16"})]})}function j(e){return jsxs(u,{...e,children:[jsx("path",{d:"M4 12h16"}),jsx("path",{d:"M7 5h7a3 3 0 0 1 0 6H7"}),jsx("path",{d:"M7 19h10"})]})}function Q(e){return jsxs(u,{...e,children:[jsx("path",{d:"M8 7l-4 5 4 5"}),jsx("path",{d:"M16 7l4 5-4 5"})]})}function Ee(e){return jsxs(u,{...e,children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M4 18h16"}),jsx("path",{d:"M9 9l-3 3 3 3"}),jsx("path",{d:"M15 9l3 3-3 3"})]})}function R(e){return jsxs(u,{...e,children:[jsx("path",{d:"M10 13a5 5 0 0 1 0-7l2-2a5 5 0 1 1 7 7l-2 2"}),jsx("path",{d:"M14 11a5 5 0 0 1 0 7l-2 2a5 5 0 1 1-7-7l2-2"})]})}function W(e){return jsxs(u,{...e,children:[jsx("path",{d:"M8 8l8 8"}),jsx("path",{d:"M10 13a5 5 0 0 1 0-7l2-2a5 5 0 0 1 7 7l-1 1"}),jsx("path",{d:"M14 11a5 5 0 0 1 0 7l-2 2a5 5 0 0 1-7-7l1-1"})]})}function V(e){return jsxs(u,{...e,children:[jsx("path",{d:"M8 6h12"}),jsx("path",{d:"M8 12h12"}),jsx("path",{d:"M8 18h12"}),jsx("circle",{cx:"4",cy:"6",r:"1"}),jsx("circle",{cx:"4",cy:"12",r:"1"}),jsx("circle",{cx:"4",cy:"18",r:"1"})]})}function Y(e){return jsxs(u,{...e,children:[jsx("path",{d:"M9 6h11"}),jsx("path",{d:"M9 12h11"}),jsx("path",{d:"M9 18h11"}),jsx("path",{d:"M4 6h1"}),jsx("path",{d:"M4 12h1"}),jsx("path",{d:"M4 18h1"})]})}function Ce(e){return jsxs(u,{...e,children:[jsx("path",{d:"M3 7v6h6"}),jsx("path",{d:"M21 17a9 9 0 0 0-9-9H3"})]})}function Me(e){return jsxs(u,{...e,children:[jsx("path",{d:"M21 7v6h-6"}),jsx("path",{d:"M3 17a9 9 0 0 1 9-9h9"})]})}function Pe(e){return jsxs(u,{...e,children:[jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),jsx("circle",{cx:"8",cy:"10",r:"2"}),jsx("path",{d:"M21 16l-5-5-4 4-2-2-5 5"})]})}function _(e){return jsxs(u,{...e,children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M4 12h10"}),jsx("path",{d:"M4 18h12"})]})}function N(e){return jsxs(u,{...e,children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M7 12h10"}),jsx("path",{d:"M6 18h12"})]})}function G(e){return jsxs(u,{...e,children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M10 12h10"}),jsx("path",{d:"M8 18h12"})]})}function Le(e){return jsxs(u,{...e,children:[jsx("path",{d:"M12 16V6"}),jsx("path",{d:"M8 10l4-4 4 4"}),jsx("path",{d:"M4 18h16"})]})}function Be(e){return jsx(u,{...e,children:jsx("path",{d:"M5 12h14"})})}function ze(e){return jsxs(u,{...e,children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),jsx("path",{d:"M3 10h18"}),jsx("path",{d:"M9 4v16"}),jsx("path",{d:"M15 4v16"})]})}function Te(e){return jsxs(u,{...e,children:[jsx("path",{d:"M14 2H7a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7z"}),jsx("path",{d:"M14 2v5h5"}),jsx("path",{d:"M9 13l-2 2 2 2"}),jsx("path",{d:"M15 13l2 2-2 2"})]})}function Re(e){return jsxs(u,{...e,children:[jsx("path",{d:"M2 12s4-6 10-6 10 6 10 6-4 6-10 6-10-6-10-6"}),jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function Ne(e){return jsxs(u,{...e,children:[jsx("path",{d:"M3 17l4 4"}),jsx("path",{d:"M14 3l7 7"}),jsx("path",{d:"M7 21l10-10"})]})}function Z(e){return jsxs(u,{...e,children:[jsx("path",{d:"M7 7h10v10H7z"}),jsx("path",{d:"M7 7v-2a2 2 0 1 1 4 0v2"}),jsx("path",{d:"M13 7v-2a2 2 0 1 1 4 0v2"}),jsx("path",{d:"M7 17v2a2 2 0 1 0 4 0v-2"}),jsx("path",{d:"M13 17v2a2 2 0 1 0 4 0v-2"})]})}function He(e){return jsxs(u,{...e,children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M12 6v12"})]})}function Ke(e){return jsxs(u,{...e,children:[jsx("path",{d:"M6 8h4v8H6z"}),jsx("path",{d:"M14 8h4v8h-4z"})]})}function Fe(e){return jsxs(u,{...e,children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M4 12h10"}),jsx("path",{d:"M4 18h16"}),jsx("path",{d:"M14 9l4 3-4 3"})]})}function Se(e){return jsxs(u,{...e,children:[jsx("path",{d:"M4 6h16"}),jsx("path",{d:"M4 12h10"}),jsx("path",{d:"M4 18h16"}),jsx("path",{d:"M18 9l-4 3 4 3"})]})}function Ae(e){return jsxs(u,{...e,children:[jsx("circle",{cx:"12",cy:"12",r:"4"}),jsx("path",{d:"M12 2v3"}),jsx("path",{d:"M12 19v3"}),jsx("path",{d:"M4.9 4.9l2.1 2.1"}),jsx("path",{d:"M17 17l2.1 2.1"}),jsx("path",{d:"M2 12h3"}),jsx("path",{d:"M19 12h3"}),jsx("path",{d:"M4.9 19.1L7 17"}),jsx("path",{d:"M17 7l2.1-2.1"})]})}function Ue(e){return jsx(u,{...e,children:jsx("path",{d:"M21 12.8A8 8 0 1 1 11.2 3a6 6 0 0 0 9.8 9.8z"})})}function De(e){return jsxs(u,{...e,children:[jsx("circle",{cx:"11",cy:"11",r:"7"}),jsx("path",{d:"M20 20l-3-3"})]})}function Oe(e){return jsx(u,{...e,children:jsx("path",{d:"M6 9l6 6 6-6"})})}function $e(e){return jsxs(u,{...e,children:[jsx("path",{d:"M6 6l12 12"}),jsx("path",{d:"M18 6l-12 12"})]})}function c({children:e,onClick:n,title:i,active:l,disabled:r,className:a,type:s="button"}){return jsx("button",{type:s,className:`luthor-toolbar-button${l?" active":""}${a?` ${a}`:""}`,onClick:n,title:i,disabled:r,children:e})}function ue({children:e,onClick:n,variant:i="primary",type:l="button",className:r}){return jsx("button",{type:l,onClick:n,className:`${i==="primary"?"luthor-button-primary":"luthor-button-secondary"}${r?` ${r}`:""}`,children:e})}function qe({value:e,onValueChange:n,options:i,placeholder:l="Select..."}){let[r,a]=useState(false),s=useRef(null);useEffect(()=>{function v(y){s.current&&!s.current.contains(y.target)&&a(false);}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]);let d=i.find(v=>v.value===e);return jsxs("div",{className:"luthor-select",ref:s,children:[jsxs("button",{className:`luthor-select-trigger ${r?"open":""}`,onClick:()=>a(!r),type:"button",children:[jsx("span",{children:d?.label||l}),jsx(Oe,{size:14})]}),r&&jsx("div",{className:"luthor-select-dropdown",children:i.map(v=>jsx("button",{className:`luthor-select-option ${e===v.value?"selected":""}`,onClick:()=>{n(v.value),a(false);},type:"button",children:v.label},v.value))})]})}function pe({trigger:e,children:n,isOpen:i,onOpenChange:l}){let r=useRef(null);return useEffect(()=>{function a(s){r.current&&!r.current.contains(s.target)&&l(false);}return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[l]),jsxs("div",{className:"luthor-dropdown",ref:r,children:[jsx("div",{onClick:()=>l(!i),children:e}),i&&jsx("div",{className:"luthor-dropdown-content",children:n})]})}function je({isOpen:e,onClose:n,title:i,children:l}){let r=useRef(null);return useEffect(()=>{function a(d){r.current&&!r.current.contains(d.target)&&n();}function s(d){d.key==="Escape"&&n();}return e&&(document.addEventListener("mousedown",a),document.addEventListener("keydown",s),document.body.style.overflow="hidden"),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",s),document.body.style.overflow="unset";}},[e,n]),e?jsx("div",{className:"luthor-dialog-overlay",children:jsxs("div",{className:"luthor-dialog",ref:r,children:[jsxs("div",{className:"luthor-dialog-header",children:[jsx("h3",{className:"luthor-dialog-title",children:i}),jsx("button",{className:"luthor-dialog-close",onClick:n,type:"button",children:jsx($e,{size:16})})]}),jsx("div",{className:"luthor-dialog-content",children:l})]})}):null}function We(e){let{isVisible:n,selectionRect:i,commands:l,activeStates:r}=e;if(!n||!i)return null;let a={position:"absolute",top:i.y,left:i.positionFromRight?"auto":i.x,right:i.positionFromRight?10:"auto",zIndex:9999,pointerEvents:"auto"};return r?.imageSelected?jsxs("div",{className:"luthor-floating-toolbar",style:a,children:[jsx(c,{onClick:()=>l.setImageAlignment("left"),active:r.isImageAlignedLeft,title:"Align Left",children:jsx(_,{size:14})}),jsx(c,{onClick:()=>l.setImageAlignment("center"),active:r.isImageAlignedCenter,title:"Align Center",children:jsx(N,{size:14})}),jsx(c,{onClick:()=>l.setImageAlignment("right"),active:r.isImageAlignedRight,title:"Align Right",children:jsx(G,{size:14})}),jsx("div",{className:"luthor-floating-toolbar-separator"}),jsx(c,{onClick:()=>l.setImageCaption(prompt("Enter caption:")||""),title:"Edit Caption",children:jsx(Ke,{size:14})})]}):jsxs("div",{className:"luthor-floating-toolbar",style:a,children:[jsx(c,{onClick:()=>l.toggleBold(),active:r.bold,title:"Bold",children:jsx(O,{size:14})}),jsx(c,{onClick:()=>l.toggleItalic(),active:r.italic,title:"Italic",children:jsx($,{size:14})}),jsx(c,{onClick:()=>l.toggleUnderline(),active:r.underline,title:"Underline",children:jsx(q,{size:14})}),jsx(c,{onClick:()=>l.toggleStrikethrough(),active:r.strikethrough,title:"Strikethrough",children:jsx(j,{size:14})}),jsx("div",{className:"luthor-floating-toolbar-separator"}),jsx(c,{onClick:()=>l.formatText("code"),active:r.code,title:"Inline Code",children:jsx(Q,{size:14})}),jsx(c,{onClick:()=>r.isLink?l.removeLink():l.insertLink(),active:r.isLink,title:r.isLink?"Remove Link":"Insert Link",children:r.isLink?jsx(W,{size:14}):jsx(R,{size:14})}),jsx("div",{className:"luthor-floating-toolbar-separator"}),jsx(c,{onClick:()=>l.toggleUnorderedList(),active:r.unorderedList,title:"Bullet List",children:jsx(V,{size:14})}),jsx(c,{onClick:()=>l.toggleOrderedList(),active:r.orderedList,title:"Numbered List",children:jsx(Y,{size:14})})]})}var K=new MarkdownExtension;K.config={...K.config,customTransformers:ALL_MARKDOWN_TRANSFORMERS};var F=new ImageExtension;F.config={...F.config,uploadHandler:async e=>URL.createObjectURL(e),defaultAlignment:"center",resizable:true,pasteListener:{insert:true,replace:true},debug:false};var he=new TableExtension;he.config={...he.config,enableContextMenu:true,markdownExtension:K};var me=new HTMLEmbedExtension;me.config={...me.config,markdownExtension:K};var J={commands:{},activeStates:{}};function Ve(e,n){J.commands=e,J.activeStates=n;}var ge=new FloatingToolbarExtension;ge.config={...ge.config,render:e=>jsx(We,{...e}),getCommands:()=>J.commands,getActiveStates:()=>J.activeStates};var be=new ContextMenuExtension;be.config={...be.config,preventDefault:true};var Ct=new CommandPaletteExtension,fe=new DraggableBlockExtension;fe.config={...fe.config,showMoveButtons:true,showUpButton:true,showDownButton:true,buttonStackPosition:"left"};var xe=new LinkExtension;xe.config={...xe.config,linkSelectedTextOnPaste:true,autoLinkText:true,autoLinkUrls:true};var z=[boldExtension,italicExtension,underlineExtension,strikethroughExtension,xe,horizontalRuleExtension,he,listExtension,historyExtension,F,blockFormatExtension,htmlExtension,K,codeExtension,codeFormatExtension,me,ge,be,Ct,fe];function Ye(){return [{id:"format.bold",label:"Toggle Bold",description:"Make text bold or remove bold formatting",category:"Format",action:e=>e.toggleBold(),shortcuts:[{key:"b",ctrlKey:true}],keywords:["bold","strong","format"]},{id:"format.italic",label:"Toggle Italic",description:"Make text italic or remove italic formatting",category:"Format",action:e=>e.toggleItalic(),shortcuts:[{key:"i",ctrlKey:true}],keywords:["italic","emphasis","format"]},{id:"format.underline",label:"Toggle Underline",description:"Add or remove underline formatting",category:"Format",action:e=>e.toggleUnderline(),shortcuts:[{key:"u",ctrlKey:true}],keywords:["underline","format"]},{id:"format.strikethrough",label:"Toggle Strikethrough",description:"Add or remove strikethrough formatting",category:"Format",action:e=>e.toggleStrikethrough(),keywords:["strikethrough","format"]},{id:"format.code",label:"Toggle Inline Code",description:"Format text as inline code",category:"Format",action:e=>e.formatText("code"),shortcuts:[{key:"`",ctrlKey:true}],keywords:["code","inline","format"]},{id:"block.heading1",label:"Heading 1",description:"Convert to large heading",category:"Block",action:e=>e.toggleHeading("h1"),shortcuts:[{key:"1",ctrlKey:true,altKey:true}],keywords:["heading","h1"]},{id:"block.heading2",label:"Heading 2",description:"Convert to medium heading",category:"Block",action:e=>e.toggleHeading("h2"),shortcuts:[{key:"2",ctrlKey:true,altKey:true}],keywords:["heading","h2"]},{id:"block.heading3",label:"Heading 3",description:"Convert to small heading",category:"Block",action:e=>e.toggleHeading("h3"),shortcuts:[{key:"3",ctrlKey:true,altKey:true}],keywords:["heading","h3"]},{id:"block.paragraph",label:"Paragraph",description:"Convert to paragraph",category:"Block",action:e=>e.toggleParagraph(),shortcuts:[{key:"0",ctrlKey:true,altKey:true}],keywords:["paragraph","text"]},{id:"block.quote",label:"Quote",description:"Convert to blockquote",category:"Block",action:e=>e.toggleQuote(),keywords:["quote","blockquote"]},{id:"block.codeblock",label:"Code Block",description:"Convert to code block",category:"Block",action:e=>e.toggleCodeBlock(),shortcuts:[{key:"`",ctrlKey:true,shiftKey:true}],keywords:["code","block"]},{id:"list.bullet",label:"Bullet List",description:"Create or toggle bullet list",category:"List",action:e=>e.toggleUnorderedList(),shortcuts:[{key:"l",ctrlKey:true,shiftKey:true}],keywords:["list","bullet"]},{id:"list.numbered",label:"Numbered List",description:"Create or toggle numbered list",category:"List",action:e=>e.toggleOrderedList(),shortcuts:[{key:"l",ctrlKey:true,altKey:true}],keywords:["list","numbered"]},{id:"link.insert",label:"Insert Link",description:"Insert or edit a link",category:"Insert",action:e=>e.insertLink(),shortcuts:[{key:"k",ctrlKey:true}],keywords:["link","url"]},{id:"link.remove",label:"Remove Link",description:"Remove link formatting",category:"Format",action:e=>e.removeLink(),shortcuts:[{key:"k",ctrlKey:true,shiftKey:true}],keywords:["unlink","remove","link"]},{id:"insert.horizontal-rule",label:"Insert Horizontal Rule",description:"Insert a horizontal line separator",category:"Insert",action:e=>e.insertHorizontalRule(),keywords:["horizontal","rule"]},{id:"insert.image",label:"Insert Image",description:"Insert an image from URL",category:"Insert",action:e=>{let n=prompt("Enter image URL:");if(n){let i=prompt("Enter alt text:")||"";e.insertImage({src:n,alt:i});}},keywords:["image","photo"]},{id:"insert.table",label:"Insert Table",description:"Insert a 3x3 table",category:"Insert",action:e=>e.insertTable({rows:3,columns:3,includeHeaders:true}),keywords:["table","grid"]},{id:"insert.html-embed",label:"Insert HTML Embed",description:"Insert a custom HTML block",category:"Insert",action:e=>e.insertHTMLEmbed(),keywords:["html","embed"]},{id:"edit.undo",label:"Undo",description:"Undo the last action",category:"Edit",action:e=>e.undo(),shortcuts:[{key:"z",ctrlKey:true}],keywords:["undo","revert"]},{id:"edit.redo",label:"Redo",description:"Redo the last undone action",category:"Edit",action:e=>e.redo(),shortcuts:[{key:"y",ctrlKey:true},{key:"z",ctrlKey:true,shiftKey:true}],keywords:["redo","repeat"]},{id:"palette.show",label:"Show Command Palette",description:"Open the command palette",category:"View",action:e=>e.showCommandPalette(),shortcuts:[{key:"p",ctrlKey:true,shiftKey:true}],keywords:["command","palette"]}]}function _e(e){return Ye().map(n=>({id:n.id,label:n.label,description:n.description,category:n.category,action:()=>n.action(e),keywords:n.keywords,shortcut:n.shortcuts?.[0]?Pt(n.shortcuts[0]):void 0}))}function Pt(e){let n=[];return e.ctrlKey&&n.push("Ctrl"),e.metaKey&&n.push("Cmd"),e.altKey&&n.push("Alt"),e.shiftKey&&n.push("Shift"),n.push(e.key.toUpperCase()),n.join("+")}function Ge(e,n=document.body){let i=Ye(),l=r=>{for(let a of i)if(a.shortcuts){for(let s of a.shortcuts)if(r.key.toLowerCase()===s.key.toLowerCase()&&!!r.ctrlKey==!!s.ctrlKey&&!!r.metaKey==!!s.metaKey&&!!r.shiftKey==!!s.shiftKey&&!!r.altKey==!!s.altKey){s.preventDefault!==false&&r.preventDefault(),(!a.condition||a.condition(e))&&a.action(e);return}}};return n.addEventListener("keydown",l),()=>n.removeEventListener("keydown",l)}function zt(e,n){let i=useRef(null),l=F.config;return {handlers:useMemo(()=>({insertFromUrl:()=>{let a=prompt("Enter image URL:");if(!a)return;let s=prompt("Enter alt text:")||"",d=prompt("Enter caption (optional):")||void 0;e.insertImage({src:a,alt:s,caption:d});},insertFromFile:()=>i.current?.click(),handleUpload:async a=>{let s=a.target.files?.[0];if(!s)return;let d;if(l.uploadHandler)try{d=await l.uploadHandler(s);}catch{alert("Failed to upload image");return}else d=URL.createObjectURL(s);e.insertImage({src:d,alt:s.name,file:s}),a.target.value="";},setAlignment:a=>{e.setImageAlignment(a);},setCaption:()=>{let a=prompt("Enter caption:")||"";e.setImageCaption(a);}}),[e,l]),fileInputRef:i}}function Je({commands:e,hasExtension:n,activeStates:i,isDark:l,toggleTheme:r,onCommandPaletteOpen:a,editor:s}){let{handlers:d,fileInputRef:v}=zt(e),[y,w]=useState(false),[h,f]=useState(false),[k,L]=useState(false),[P,B]=useState({rows:3,columns:3,includeHeaders:false}),D=[{value:"p",label:"Paragraph"},{value:"h1",label:"Heading 1"},{value:"h2",label:"Heading 2"},{value:"h3",label:"Heading 3"},{value:"h4",label:"Heading 4"},{value:"h5",label:"Heading 5"},{value:"h6",label:"Heading 6"},{value:"quote",label:"Quote"}],we=i.isH1?"h1":i.isH2?"h2":i.isH3?"h3":i.isH4?"h4":i.isH5?"h5":i.isH6?"h6":i.isQuote?"quote":"p",b=m=>{m==="p"?e.toggleParagraph():m.startsWith("h")?e.toggleHeading(m):m==="quote"&&e.toggleQuote();};return jsxs(Fragment,{children:[jsxs("div",{className:"luthor-toolbar",children:[jsxs("div",{className:"luthor-toolbar-section",children:[jsx(c,{onClick:()=>e.toggleBold(),active:i.bold,title:"Bold (Ctrl+B)",children:jsx(O,{size:16})}),jsx(c,{onClick:()=>e.toggleItalic(),active:i.italic,title:"Italic (Ctrl+I)",children:jsx($,{size:16})}),jsx(c,{onClick:()=>e.toggleUnderline(),active:i.underline,title:"Underline (Ctrl+U)",children:jsx(q,{size:16})}),jsx(c,{onClick:()=>e.toggleStrikethrough(),active:i.strikethrough,title:"Strikethrough",children:jsx(j,{size:16})}),jsx(c,{onClick:()=>e.formatText("code"),active:i.code,title:"Inline Code",children:jsx(Q,{size:16})}),jsx(c,{onClick:()=>i.isLink?e.removeLink():e.insertLink(),active:i.isLink,title:i.isLink?"Remove Link":"Insert Link",children:i.isLink?jsx(W,{size:16}):jsx(R,{size:16})})]}),n("blockFormat")&&jsxs("div",{className:"luthor-toolbar-section",children:[jsx(qe,{value:we,onValueChange:b,options:D,placeholder:"Format"}),n("code")&&jsx(c,{onClick:()=>e.toggleCodeBlock(),active:i.isInCodeBlock,title:"Code Block",children:jsx(Ee,{size:16})})]}),n("list")&&jsxs("div",{className:"luthor-toolbar-section",children:[jsx(c,{onClick:()=>e.toggleUnorderedList(),active:i.unorderedList,title:"Bullet List",children:jsx(V,{size:16})}),jsx(c,{onClick:()=>e.toggleOrderedList(),active:i.orderedList,title:"Numbered List",children:jsx(Y,{size:16})}),(i.unorderedList||i.orderedList)&&jsxs(Fragment,{children:[jsx(c,{onClick:()=>e.indentList(),title:"Indent List",children:jsx(Fe,{size:14})}),jsx(c,{onClick:()=>e.outdentList(),title:"Outdent List",children:jsx(Se,{size:14})})]})]}),n("horizontalRule")&&jsx("div",{className:"luthor-toolbar-section",children:jsx(c,{onClick:()=>e.insertHorizontalRule(),title:"Insert Horizontal Rule",children:jsx(Be,{size:16})})}),n("table")&&jsx("div",{className:"luthor-toolbar-section",children:jsx(c,{onClick:()=>L(true),title:"Insert Table",children:jsx(ze,{size:16})})}),n("image")&&jsxs("div",{className:"luthor-toolbar-section",children:[jsxs(pe,{trigger:jsx("button",{className:`luthor-toolbar-button ${i.imageSelected?"active":""}`,title:"Insert Image",children:jsx(Pe,{size:16})}),isOpen:y,onOpenChange:w,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{d.insertFromUrl(),w(false);},children:[jsx(R,{size:16}),jsx("span",{children:"From URL"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{d.insertFromFile(),w(false);},children:[jsx(Le,{size:16}),jsx("span",{children:"Upload File"})]})]}),i.imageSelected&&jsxs(pe,{trigger:jsx("button",{className:"luthor-toolbar-button",title:"Align Image",children:jsx(N,{size:16})}),isOpen:h,onOpenChange:f,children:[jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{d.setAlignment("left"),f(false);},children:[jsx(_,{size:16}),jsx("span",{children:"Align Left"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{d.setAlignment("center"),f(false);},children:[jsx(N,{size:16}),jsx("span",{children:"Align Center"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{d.setAlignment("right"),f(false);},children:[jsx(G,{size:16}),jsx("span",{children:"Align Right"})]}),jsxs("button",{className:"luthor-dropdown-item",onClick:()=>{d.setCaption(),f(false);},children:[jsx(He,{size:16}),jsx("span",{children:"Set Caption"})]})]}),jsx("input",{ref:v,type:"file",accept:"image/*",onChange:d.handleUpload,className:"luthor-file-input"})]}),n("htmlEmbed")&&jsxs("div",{className:"luthor-toolbar-section",children:[jsx(c,{onClick:()=>e.insertHTMLEmbed(),active:i.isHTMLEmbedSelected,title:"Insert HTML Embed",children:jsx(Te,{size:16})}),i.isHTMLEmbedSelected&&jsx(c,{onClick:()=>e.toggleHTMLPreview(),title:"Toggle Preview/Edit",children:i.isHTMLPreviewMode?jsx(Re,{size:16}):jsx(Ne,{size:16})})]}),n("history")&&jsxs("div",{className:"luthor-toolbar-section",children:[jsx(c,{onClick:()=>e.undo(),disabled:!i.canUndo,title:"Undo (Ctrl+Z)",children:jsx(Ce,{size:16})}),jsx(c,{onClick:()=>e.redo(),disabled:!i.canRedo,title:"Redo (Ctrl+Y)",children:jsx(Me,{size:16})})]}),jsx("div",{className:"luthor-toolbar-section",children:jsx(c,{onClick:a,title:"Command Palette (Ctrl+Shift+P)",children:jsx(Z,{size:16})})}),jsx("div",{className:"luthor-toolbar-section",children:jsx(c,{onClick:r,title:l?"Light Mode":"Dark Mode",children:l?jsx(Ae,{size:16}):jsx(Ue,{size:16})})})]}),jsx(je,{isOpen:k,onClose:()=>L(false),title:"Insert Table",children:jsxs("div",{className:"luthor-table-dialog",children:[jsxs("div",{className:"luthor-form-group",children:[jsx("label",{htmlFor:"table-rows",children:"Rows:"}),jsx("input",{id:"table-rows",type:"number",min:"1",max:"20",value:P.rows,onChange:m=>B(I=>({...I,rows:parseInt(m.target.value)||1})),className:"luthor-input"})]}),jsxs("div",{className:"luthor-form-group",children:[jsx("label",{htmlFor:"table-columns",children:"Columns:"}),jsx("input",{id:"table-columns",type:"number",min:"1",max:"20",value:P.columns,onChange:m=>B(I=>({...I,columns:parseInt(m.target.value)||1})),className:"luthor-input"})]}),jsx("div",{className:"luthor-form-group",children:jsxs("label",{className:"luthor-checkbox-label",children:[jsx("input",{type:"checkbox",checked:P.includeHeaders||false,onChange:m=>B(I=>({...I,includeHeaders:m.target.checked})),className:"luthor-checkbox"}),"Include headers"]})}),jsxs("div",{className:"luthor-dialog-actions",children:[jsx(ue,{variant:"secondary",onClick:()=>L(false),children:"Cancel"}),jsx(ue,{variant:"primary",onClick:()=>{e.insertTable(P),L(false);},children:"Insert Table"})]})]})})]})}function et({isOpen:e,onClose:n,commands:i}){let[l,r]=useState(""),[a,s]=useState(0),d=useRef(null),v=i.filter(h=>`${h.label} ${h.description||""} ${h.keywords?.join(" ")||""}`.toLowerCase().includes(l.toLowerCase())),y=v.reduce((h,f)=>{let k=f.category||"Other";return h[k]||(h[k]=[]),h[k].push(f),h},{}),w=v;return useEffect(()=>{s(0);},[l]),useEffect(()=>{e&&d.current&&(d.current.focus(),r(""),s(0));},[e]),useEffect(()=>{let h=f=>{if(e)switch(f.key){case "Escape":f.preventDefault(),n();break;case "ArrowDown":f.preventDefault(),s(k=>Math.min(k+1,w.length-1));break;case "ArrowUp":f.preventDefault(),s(k=>Math.max(k-1,0));break;case "Enter":f.preventDefault(),w[a]&&(w[a].action(),n());break}};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[e,a,w,n]),e?jsx("div",{className:"luthor-command-palette-overlay",onClick:n,children:jsxs("div",{className:"luthor-command-palette",onClick:h=>h.stopPropagation(),children:[jsxs("div",{className:"luthor-command-palette-header",children:[jsx(De,{size:16,className:"luthor-command-palette-icon"}),jsx("input",{ref:d,type:"text",placeholder:"Type a command or search...",value:l,onChange:h=>r(h.target.value),className:"luthor-command-palette-input"}),jsx("kbd",{className:"luthor-command-palette-kbd",children:"ESC"})]}),jsx("div",{className:"luthor-command-palette-list",children:Object.keys(y).length===0?jsx("div",{className:"luthor-command-palette-empty",children:"No commands found"}):Object.entries(y).map(([h,f])=>jsxs("div",{className:"luthor-command-palette-group",children:[jsx("div",{className:"luthor-command-palette-group-title",children:h}),f.map(k=>{let L=w.indexOf(k);return jsxs("div",{className:`luthor-command-palette-item ${L===a?"selected":""}`,onClick:()=>{k.action(),n();},onMouseEnter:()=>s(L),children:[jsxs("div",{className:"luthor-command-palette-item-content",children:[jsx("div",{className:"luthor-command-palette-item-title",children:k.label}),k.description&&jsx("div",{className:"luthor-command-palette-item-description",children:k.description})]}),k.shortcut&&jsx("kbd",{className:"luthor-command-palette-item-shortcut",children:k.shortcut})]},k.id)})]},h))}),jsx("div",{className:"luthor-command-palette-footer",children:jsxs("span",{className:"luthor-command-palette-hint",children:[jsx(Z,{size:14}),jsx("span",{children:"Use arrow keys, Enter, ESC"})]})})]})}):null}var{Provider:St,useEditor:At}=createEditorSystem();function Ut({mode:e,onModeChange:n}){return jsxs("div",{className:"luthor-mode-tabs",children:[jsx("button",{className:`luthor-mode-tab ${e==="visual"?"active":""}`,onClick:()=>n("visual"),children:"Visual"}),jsx("button",{className:`luthor-mode-tab ${e==="html"?"active":""}`,onClick:()=>n("html"),children:"HTML"}),jsx("button",{className:`luthor-mode-tab ${e==="markdown"?"active":""}`,onClick:()=>n("markdown"),children:"Markdown"})]})}function ot({value:e,onChange:n,placeholder:i}){return jsx("textarea",{className:"luthor-source-view",value:e,onChange:l=>n(l.target.value),placeholder:i,spellCheck:false})}function Dt({className:e,isDark:n,toggleTheme:i,onReady:l}){let{commands:r,hasExtension:a,activeStates:s,lexical:d,extensions:v}=At(),[y,w]=useState("visual"),[h,f]=useState({html:"",markdown:""}),[k,L]=useState({isOpen:false,commands:[]}),P=useRef(r),B=useRef(false);useEffect(()=>{P.current=r;},[r]),useEffect(()=>{Ve(r,s);},[r,s]);let D=useMemo(()=>({injectMarkdown:b=>{setTimeout(()=>{d&&d.update(()=>{P.current.importFromMarkdown(b,{immediate:true,preventFocus:true});});},100);},injectHTML:b=>{setTimeout(()=>{d&&d.update(()=>{P.current.importFromHTML(b,{preventFocus:true});});},100);},getMarkdown:()=>P.current.exportToMarkdown(),getHTML:()=>P.current.exportToHTML()}),[d]);return useEffect(()=>{if(!d||!r)return;let b=_e(r);b.forEach(I=>r.registerCommand(I));let m=Ge(r,document.body);return B.current||(B.current=true,l?.(D)),()=>{m(),b.forEach(I=>r.unregisterCommand(I.id));}},[d,r,D,l]),useEffect(()=>{let b=v.find(m=>m.name==="commandPalette");if(!(!b||!b.subscribe))return b.subscribe((m,I)=>{L({isOpen:m,commands:I});})},[v]),jsxs(Fragment,{children:[jsxs("div",{className:"luthor-editor-header",children:[jsx(Ut,{mode:y,onModeChange:async b=>{if(y==="markdown"&&b!=="markdown"&&a("markdown")&&(await r.importFromMarkdown(h.markdown,{immediate:true}),await new Promise(m=>setTimeout(m,50))),y==="html"&&b!=="html"&&a("html")&&(await r.importFromHTML(h.html),await new Promise(m=>setTimeout(m,50))),b==="markdown"&&y!=="markdown"&&a("markdown")){await new Promise(I=>setTimeout(I,50));let m=r.exportToMarkdown();f(I=>({...I,markdown:m}));}if(b==="html"&&y!=="html"&&a("html")){await new Promise(I=>setTimeout(I,50));let m=r.exportToHTML();f(I=>({...I,html:m}));}w(b),b==="visual"&&setTimeout(()=>d?.focus(),100);}}),y==="visual"&&jsx(Je,{commands:r,hasExtension:b=>a(b),activeStates:s,isDark:n,toggleTheme:i,onCommandPaletteOpen:()=>r.showCommandPalette(),editor:d})]}),jsxs("div",{className:"luthor-editor","data-mode":y,children:[y==="visual"&&jsx(RichText,{placeholder:"Write anything...",classNames:{container:"luthor-richtext-container",contentEditable:"luthor-content-editable",placeholder:"luthor-placeholder"}}),y!=="visual"&&jsxs("div",{className:"luthor-source-panel",children:[y==="html"&&jsx(ot,{value:h.html,onChange:b=>f(m=>({...m,html:b})),placeholder:"Enter HTML content..."}),y==="markdown"&&jsx(ot,{value:h.markdown,onChange:b=>f(m=>({...m,markdown:b})),placeholder:"Enter Markdown content..."})]})]}),jsx(et,{isOpen:k.isOpen,onClose:()=>r.hideCommandPalette(),commands:k.commands})]})}var U=forwardRef(({className:e,onReady:n,initialTheme:i="light"},l)=>{let[r,a]=useState(i),s=r==="dark",d=()=>a(s?"light":"dark"),[v,y]=useState(null);Rt.useImperativeHandle(l,()=>v,[v]);let w=h=>{y(h),n?.(h);};return jsx("div",{className:`luthor-editor-wrapper ${e||""}`,"data-editor-theme":r,children:jsx(St,{extensions:z,children:jsx(Dt,{className:e,isDark:s,toggleTheme:d,onReady:w})})})});U.displayName="ExtensiveEditor";var ke={id:"extensive",label:"Extensive",description:"All features enabled for power users.",extensions:[...z],components:{Editor:U},toolbar:["undo","redo","heading","bold","italic","underline","strikethrough","link","image","table","blockquote","code","codeBlock","bulletedList","numberedList"],config:{placeholder:"Write anything..."},css:"extensive/styles.css"};var ye={id:"markdown",label:"Markdown",description:"Markdown first editing with predictable output.",toolbar:["bold","italic","link","code","codeBlock"],config:{placeholder:"Write in markdown..."},css:"markdown/styles.css"};var Ie={id:"minimal",label:"Minimal",description:"Lightweight editor for short text and embeds.",toolbar:["bold","italic","link"],config:{placeholder:"Write something..."},css:"minimal/styles.css"};var wr={minimal:Ie,classic:re,docs:le,blog:te,cms:ne,chat:oe,email:se,markdown:ye,code:ie,default:ae,extensive:ke};export{U as ExtensiveEditor,te as blogPreset,oe as chatPreset,re as classicPreset,ne as cmsPreset,ie as codePreset,ae as defaultPreset,le as docsPreset,se as emailPreset,z as extensiveExtensions,ke as extensivePreset,ye as markdownPreset,Ie as minimalPreset,wr as presetRegistry};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lyfie/luthor",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Luthor presets and plug-and-play configuration for the headless editor",
5
5
  "type": "module",
6
6
  "private": false,
@@ -34,7 +34,18 @@
34
34
  },
35
35
  "homepage": "https://github.com/lyfie-app/luthor#readme",
36
36
  "dependencies": {
37
- "@lyfie/luthor-headless": "1.1.0"
37
+ "@lyfie/luthor-headless": "^2.0.1",
38
+ "@lexical/code": "^0.34.0",
39
+ "@lexical/html": "^0.34.0",
40
+ "@lexical/link": "^0.34.0",
41
+ "@lexical/list": "^0.34.0",
42
+ "@lexical/markdown": "^0.34.0",
43
+ "@lexical/react": "^0.34.0",
44
+ "@lexical/rich-text": "^0.34.0",
45
+ "@lexical/selection": "^0.34.0",
46
+ "@lexical/table": "^0.34.0",
47
+ "@lexical/utils": "^0.34.0",
48
+ "lexical": "^0.34.0"
38
49
  },
39
50
  "devDependencies": {
40
51
  "@types/node": "^20.19.9",
@@ -43,21 +54,10 @@
43
54
  "eslint": "^9.32.0",
44
55
  "tsup": "^8.0.0",
45
56
  "typescript": "^5.7.3",
46
- "@repo/typescript-config": "0.0.0",
47
- "@repo/eslint-config": "0.0.0"
57
+ "@repo/eslint-config": "0.0.0",
58
+ "@repo/typescript-config": "0.0.0"
48
59
  },
49
60
  "peerDependencies": {
50
- "@lexical/code": ">=0.34.0",
51
- "@lexical/html": ">=0.34.0",
52
- "@lexical/link": ">=0.34.0",
53
- "@lexical/list": ">=0.34.0",
54
- "@lexical/markdown": ">=0.34.0",
55
- "@lexical/react": ">=0.34.0",
56
- "@lexical/rich-text": ">=0.34.0",
57
- "@lexical/selection": ">=0.34.0",
58
- "@lexical/table": ">=0.34.0",
59
- "@lexical/utils": ">=0.34.0",
60
- "lexical": ">=0.34.0",
61
61
  "react": "^18.0.0 || ^19.0.0",
62
62
  "react-dom": "^18.0.0 || ^19.0.0"
63
63
  },