srich-editor 1.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.
package/README.md ADDED
@@ -0,0 +1,488 @@
1
+ # SRich Editor
2
+
3
+ A lightweight, dependency-free rich text editor built with Vanilla JavaScript.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/srich-editor.svg)](https://www.npmjs.com/package/srich-editor)
6
+ [![license](https://img.shields.io/npm/l/srich-editor.svg)](https://github.com/nbhson/srich-editor/blob/main/LICENSE)
7
+
8
+ ## Features
9
+
10
+ - 🚀 **Lightweight** - No dependencies, tiny bundle size
11
+ - 🎨 **Customizable** - Configurable toolbar and styling
12
+ - 🌙 **Dark Mode** - Automatic dark mode support
13
+ - ♿ **Accessible** - ARIA labels and keyboard shortcuts
14
+ - 📱 **Responsive** - Works on all screen sizes
15
+ - 🔧 **Simple API** - Easy to integrate and use
16
+ - ⌨️ **Keyboard Shortcuts** - Ctrl+B, Ctrl+I, Ctrl+U support
17
+ - 📊 **Status Bar** - Word and character count
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ npm install srich-editor
23
+ ```
24
+
25
+ ## Quick Start
26
+
27
+ ### Using ES Modules (Recommended)
28
+
29
+ ```javascript
30
+ import { createEditor } from 'srich-editor';
31
+ import 'srich-editor/dist/styles.css';
32
+
33
+ const editor = createEditor({
34
+ container: '#editor',
35
+ placeholder: 'Start typing here...',
36
+ onChange: (content) => {
37
+ console.log('Content changed:', content);
38
+ },
39
+ });
40
+
41
+ // Get content
42
+ const html = editor.getContent();
43
+
44
+ // Set content
45
+ editor.setContent('<p>Hello World</p>');
46
+ ```
47
+
48
+ ### Using UMD (via script tag in plain HTML)
49
+
50
+ If you're using a bundler (Webpack, Vite, Parcel, etc.), install the package and use ES Modules:
51
+
52
+ ```bash
53
+ npm install srich-editor
54
+ ```
55
+
56
+ ```javascript
57
+ import { createEditor } from 'srich-editor';
58
+ import 'srich-editor/dist/styles.css';
59
+
60
+ const editor = createEditor({
61
+ container: '#editor',
62
+ placeholder: 'Start typing here...',
63
+ });
64
+ ```
65
+
66
+ #### Option 1: Via CDN (unpkg / jsDelivr)
67
+
68
+ No installation needed — just add these to your HTML `<head>`:
69
+
70
+ ```html
71
+ <!DOCTYPE html>
72
+ <html lang="en">
73
+ <head>
74
+ <meta charset="UTF-8">
75
+ <title>My Page</title>
76
+ <!-- 1. Load CSS -->
77
+ <link rel="stylesheet" href="https://unpkg.com/srich-editor/dist/styles.css">
78
+ </head>
79
+ <body>
80
+ <!-- 2. Add a container div -->
81
+ <div id="editor"></div>
82
+
83
+ <!-- 3. Load UMD script (exposes global `SRichEditor`) -->
84
+ <script src="https://unpkg.com/srich-editor/dist/srich-editor.umd.js"></script>
85
+ <script>
86
+ const editor = SRichEditor.createEditor({
87
+ container: '#editor',
88
+ placeholder: 'Start typing here...',
89
+ onChange: (content) => console.log(content),
90
+ });
91
+ </script>
92
+ </body>
93
+ </html>
94
+ ```
95
+
96
+ > **Note:** When using the UMD build via `<script>` tag, the library is available as the global variable `SRichEditor`. Call `SRichEditor.createEditor(...)` to create an editor instance.
97
+
98
+ #### Option 2: Using importmap (modern browsers, no bundler)
99
+
100
+ ```html
101
+ <!DOCTYPE html>
102
+ <html lang="en">
103
+ <head>
104
+ <meta charset="UTF-8">
105
+ <title>My Page</title>
106
+ <link rel="stylesheet" href="https://unpkg.com/srich-editor/dist/styles.css">
107
+ </head>
108
+ <body>
109
+ <div id="editor"></div>
110
+
111
+ <script type="importmap">
112
+ {
113
+ "imports": {
114
+ "srich-editor": "https://unpkg.com/srich-editor/dist/srich-editor.esm.js"
115
+ }
116
+ }
117
+ </script>
118
+ <script type="module">
119
+ import { createEditor } from 'srich-editor';
120
+
121
+ const editor = createEditor({
122
+ container: '#editor',
123
+ placeholder: 'Start typing here...',
124
+ onChange: (content) => console.log(content),
125
+ });
126
+ </script>
127
+ </body>
128
+ </html>
129
+ ```
130
+
131
+ ## API
132
+
133
+ ### `createEditor(options)`
134
+
135
+ Creates a new editor instance.
136
+
137
+ #### Options
138
+
139
+ | Option | Type | Default | Description |
140
+ |--------|------|---------|-------------|
141
+ | `container` | `string \| HTMLElement` | **required** | CSS selector or DOM element |
142
+ | `content` | `string` | `''` | Initial HTML content |
143
+ | `placeholder` | `string` | `'Start typing...'` | Placeholder text |
144
+ | `height` | `string` | `'300px'` | Editor height |
145
+ | `toolbar` | `ToolbarItem[]` | default toolbar | Custom toolbar config |
146
+ | `customButtons` | `CustomButton[]` | `[]` | Custom toolbar buttons |
147
+ | `readOnly` | `boolean` | `false` | Read-only mode |
148
+ | `onChange` | `(content: string) => void` | - | Content change callback |
149
+ | `onReady` | `() => void` | - | Editor ready callback |
150
+
151
+ #### Editor Instance Methods
152
+
153
+ | Method | Returns | Description |
154
+ |--------|---------|-------------|
155
+ | `getContent()` | `string` | Get HTML content |
156
+ | `setContent(html)` | `void` | Set HTML content |
157
+ | `getText()` | `string` | Get plain text content |
158
+ | `getCharacterCount()` | `number` | Get character count |
159
+ | `getWordCount()` | `number` | Get word count |
160
+ | `execCommand(cmd, val?)` | `void` | Execute a command |
161
+ | `queryCommandState(cmd)` | `boolean` | Check if command is active |
162
+ | `focus()` | `void` | Focus the editor |
163
+ | `isEmpty()` | `boolean` | Check if editor is empty |
164
+ | `enable()` | `void` | Enable the editor |
165
+ | `disable()` | `void` | Disable the editor |
166
+ | `getElement()` | `HTMLElement` | Get wrapper element |
167
+ | `destroy()` | `void` | Remove the editor |
168
+ | `undo()` | `void` | Undo last change |
169
+ | `redo()` | `void` | Redo last undone change |
170
+ | `canUndo()` | `boolean` | Check if undo is available |
171
+ | `canRedo()` | `boolean` | Check if redo is available |
172
+
173
+ ### Getting Content with `getContent()`
174
+
175
+ `getContent()` returns the current HTML content of the editor as a string. This is useful for saving or processing the editor's content.
176
+
177
+ ```javascript
178
+ import { createEditor } from 'srich-editor';
179
+
180
+ const editor = createEditor({
181
+ container: '#editor',
182
+ placeholder: 'Start typing...',
183
+ });
184
+
185
+ // Get HTML content at any time
186
+ const html = editor.getContent();
187
+ console.log(html); // e.g. "<p>Hello <strong>World</strong></p>"
188
+
189
+ // Example: Save content on a button click
190
+ document.getElementById('save-btn').addEventListener('click', () => {
191
+ const content = editor.getContent();
192
+ // Send to server, save to localStorage, etc.
193
+ fetch('/api/save', {
194
+ method: 'POST',
195
+ headers: { 'Content-Type': 'application/json' },
196
+ body: JSON.stringify({ content }),
197
+ });
198
+ });
199
+
200
+ // Example: Check if editor has content before submitting
201
+ if (!editor.isEmpty()) {
202
+ const html = editor.getContent();
203
+ // proceed with form submission
204
+ }
205
+ ```
206
+
207
+ #### Using `getContent()` with onChange callback
208
+
209
+ ```javascript
210
+ const editor = createEditor({
211
+ container: '#editor',
212
+ onChange: (content) => {
213
+ // 'content' is the same HTML string as getContent()
214
+ console.log('Current HTML:', content);
215
+ },
216
+ });
217
+ ```
218
+
219
+ ## Custom Toolbar
220
+
221
+ ```javascript
222
+ import { createEditor } from 'srich-editor';
223
+ import { defaultToolbar } from 'srich-editor';
224
+
225
+ const editor = createEditor({
226
+ container: '#editor',
227
+ toolbar: [
228
+ // Only show bold, italic, underline
229
+ { type: 'button', name: 'bold', icon: 'bold', tooltip: 'Bold', command: 'bold' },
230
+ { type: 'button', name: 'italic', icon: 'italic', tooltip: 'Italic', command: 'italic' },
231
+ { type: 'button', name: 'underline', icon: 'underline', tooltip: 'Underline', command: 'underline' },
232
+ { type: 'separator' },
233
+ { type: 'button', name: 'link', icon: 'link', tooltip: 'Insert Link', command: 'createLink' },
234
+ ],
235
+ });
236
+ ```
237
+
238
+ ## Available Toolbar Icons
239
+
240
+ The editor comes with 21 built-in toolbar icons:
241
+
242
+ | Icon | Command | Description |
243
+ |------|---------|-------------|
244
+ | `undo` | `undo` | Undo last action |
245
+ | `redo` | `redo` | Redo last action |
246
+ | `bold` | `bold` | Bold text |
247
+ | `italic` | `italic` | Italic text |
248
+ | `underline` | `underline` | Underline text |
249
+ | `strikethrough` | `strikeThrough` | Strikethrough text |
250
+ | `heading1` | `formatBlock: H1` | Heading level 1 |
251
+ | `heading2` | `formatBlock: H2` | Heading level 2 |
252
+ | `heading3` | `formatBlock: H3` | Heading level 3 |
253
+ | `justifyLeft` | `justifyLeft` | Align left |
254
+ | `justifyCenter` | `justifyCenter` | Align center |
255
+ | `justifyRight` | `justifyRight` | Align right |
256
+ | `unorderedList` | `insertUnorderedList` | Bullet list |
257
+ | `orderedList` | `insertOrderedList` | Numbered list |
258
+ | `blockquote` | `formatBlock: BLOCKQUOTE` | Block quote |
259
+ | `link` | `createLink` | Insert link (prompts for URL) |
260
+ | `image` | `insertImage` | Insert image (prompts for URL) |
261
+ | `horizontalRule` | `insertHorizontalRule` | Horizontal line |
262
+ | `code` | `formatBlock: PRE` | Code block |
263
+ | `removeFormat` | `removeFormat` | Clear formatting |
264
+
265
+ ## Keyboard Shortcuts
266
+
267
+ | Shortcut | Action |
268
+ |----------|--------|
269
+ | Ctrl+B | Bold |
270
+ | Ctrl+I | Italic |
271
+ | Ctrl+U | Underline |
272
+ | Ctrl+Z | Undo |
273
+ | Ctrl+Y | Redo |
274
+ | Ctrl+Shift+Z | Redo (Mac) |
275
+
276
+ ## Bundle Sizes
277
+
278
+ | File | Size | Format |
279
+ |------|------|--------|
280
+ | `srich-editor.umd.js` | ~24 KB | UMD (script tags) |
281
+ | `srich-editor.esm.js` | ~24 KB | ES Modules |
282
+ | `styles.css` | ~8 KB | CSS |
283
+ | **Total package** | **~24 KB** | minified |
284
+
285
+ ## Framework Integration
286
+
287
+ ### React
288
+
289
+ ```jsx
290
+ import { useEffect, useRef } from 'react';
291
+ import { createEditor } from 'srich-editor';
292
+ import 'srich-editor/dist/styles.css';
293
+
294
+ function SRichEditor({ onChange }) {
295
+ const containerRef = useRef(null);
296
+ const editorRef = useRef(null);
297
+
298
+ useEffect(() => {
299
+ editorRef.current = createEditor({
300
+ container: containerRef.current,
301
+ onChange,
302
+ });
303
+ return () => editorRef.current?.destroy();
304
+ }, []);
305
+
306
+ return <div ref={containerRef} />;
307
+ }
308
+ ```
309
+
310
+ ### Vue
311
+
312
+ ```vue
313
+ <template>
314
+ <div ref="editorContainer"></div>
315
+ </template>
316
+
317
+ <script setup>
318
+ import { onMounted, onUnmounted, ref } from 'vue';
319
+ import { createEditor } from 'srich-editor';
320
+ import 'srich-editor/dist/styles.css';
321
+
322
+ const editorContainer = ref(null);
323
+ let editor = null;
324
+
325
+ onMounted(() => {
326
+ editor = createEditor({
327
+ container: editorContainer.value,
328
+ onChange: (content) => console.log(content),
329
+ });
330
+ });
331
+
332
+ onUnmounted(() => editor?.destroy());
333
+ </script>
334
+ ```
335
+
336
+ ### Angular
337
+
338
+ #### 1. Install the package
339
+
340
+ ```bash
341
+ npm install srich-editor
342
+ ```
343
+
344
+ #### 2. Create a wrapper component
345
+
346
+ **srich-editor.component.ts**
347
+
348
+ ```typescript
349
+ import {
350
+ Component,
351
+ ElementRef,
352
+ EventEmitter,
353
+ OnDestroy,
354
+ OnInit,
355
+ Output,
356
+ ViewChild,
357
+ AfterViewInit,
358
+ Input,
359
+ } from '@angular/core';
360
+ import { CommonModule } from '@angular/common';
361
+ import { createEditor, RichEditorInstance } from 'srich-editor';
362
+ import 'srich-editor/dist/styles.css';
363
+
364
+ @Component({
365
+ selector: 'app-srich-editor',
366
+ standalone: true,
367
+ imports: [CommonModule],
368
+ template: `<div #editorContainer></div>`,
369
+ styles: [`:host { display: block; }`],
370
+ })
371
+ export class SRichEditorComponent implements AfterViewInit, OnDestroy {
372
+ @ViewChild('editorContainer', { static: true }) editorContainer!: ElementRef;
373
+ @Output() contentChanged = new EventEmitter<string>();
374
+ @Input() placeholder = 'Start typing...';
375
+ @Input() height = '300px';
376
+ @Input() content = '';
377
+
378
+ private editor!: RichEditorInstance;
379
+
380
+ ngAfterViewInit(): void {
381
+ this.editor = createEditor({
382
+ container: this.editorContainer.nativeElement,
383
+ placeholder: this.placeholder,
384
+ height: this.height,
385
+ content: this.content,
386
+ onChange: (html: string) => this.contentChanged.emit(html),
387
+ });
388
+ }
389
+
390
+ getContent(): string {
391
+ return this.editor?.getContent() ?? '';
392
+ }
393
+
394
+ setContent(html: string): void {
395
+ this.editor?.setContent(html);
396
+ }
397
+
398
+ ngOnDestroy(): void {
399
+ this.editor?.destroy();
400
+ }
401
+ }
402
+ ```
403
+
404
+ #### 3. Use in a page
405
+
406
+ **app.component.ts**
407
+
408
+ ```typescript
409
+ import { Component } from '@angular/core';
410
+ import { SRichEditorComponent } from './srich-editor.component';
411
+
412
+ @Component({
413
+ selector: 'app-root',
414
+ standalone: true,
415
+ imports: [SRichEditorComponent],
416
+ template: `
417
+ <app-srich-editor
418
+ placeholder="Write something..."
419
+ (contentChanged)="onContentChange($event)">
420
+ </app-srich-editor>
421
+ `,
422
+ })
423
+ export class AppComponent {
424
+ onContentChange(content: string) {
425
+ console.log('Content:', content);
426
+ }
427
+ }
428
+ ```
429
+ ## Development
430
+
431
+ ```bash
432
+ # Install dependencies
433
+ npm install
434
+
435
+ # Development mode with watch
436
+ npm run dev
437
+
438
+ # Build for production
439
+ npm run build
440
+
441
+ # Open demo
442
+ npm run demo
443
+ ```
444
+
445
+ ## Publishing to npm
446
+
447
+ ```bash
448
+ # Login to npm
449
+ npm login
450
+
451
+ # (Optional) Dry run to check what will be published
452
+ npm pack --dry-run
453
+
454
+ # Publish
455
+ npm publish
456
+
457
+ # Publish with tag
458
+ npm publish --tag beta
459
+
460
+ # Update version and publish
461
+ npm version patch # or minor / major
462
+ npm publish
463
+ ```
464
+
465
+ ## Project Structure
466
+
467
+ ```
468
+ srichEditor/
469
+ ├── src/
470
+ │ ├── index.ts # Entry point, exports
471
+ │ ├── types.ts # TypeScript interfaces
472
+ │ ├── toolbar.ts # Toolbar config + SVG icons
473
+ │ ├── editor.ts # Core editor logic
474
+ │ ├── styles.css # Editor styles (light + dark mode)
475
+ │ └── global.d.ts # CSS module declaration
476
+ ├── dist/ # Build output (git-ignored)
477
+ ├── demo/
478
+ │ └── index.html # Demo page
479
+ ├── package.json
480
+ ├── rollup.config.mjs # Rollup build config
481
+ ├── tsconfig.json # TypeScript config
482
+ ├── .gitignore
483
+ └── README.md
484
+ ```
485
+
486
+ ## License
487
+
488
+ MIT
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * SRich Editor v1.0.0
3
+ * A lightweight, dependency-free rich text editor
4
+ * MIT License
5
+ */
6
+ const e={bold:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"/></svg>',italic:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"/></svg>',underline:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z"/></svg>',strikethrough:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"/></svg>',heading1:'<svg viewBox="0 0 24 24" width="18" height="18"><text x="3" y="18" font-size="16" font-weight="bold" fill="currentColor" font-family="sans-serif">H1</text></svg>',heading2:'<svg viewBox="0 0 24 24" width="18" height="18"><text x="3" y="18" font-size="16" font-weight="bold" fill="currentColor" font-family="sans-serif">H2</text></svg>',heading3:'<svg viewBox="0 0 24 24" width="18" height="18"><text x="3" y="18" font-size="16" font-weight="bold" fill="currentColor" font-family="sans-serif">H3</text></svg>',unorderedList:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"/></svg>',orderedList:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"/></svg>',justifyLeft:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z"/></svg>',justifyCenter:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z"/></svg>',justifyRight:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z"/></svg>',link:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg>',image:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/></svg>',code:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"/></svg>',undo:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"/></svg>',redo:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"/></svg>',blockquote:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"/></svg>',horizontalRule:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M2 11h20v2H2z"/></svg>',removeFormat:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M3.27 5L2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21 18 19.73 3.27 5zM6 5v.18L8.82 8h2.4l-.72 1.68 2.1 2.1L14.21 8H20V5H6z"/></svg>',textColor:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M11 2L5.5 16h2.25l1.12-3h6.25l1.12 3h2.25L13 2h-2zm-1.38 9L12 4.67 14.38 11H9.62z"/></svg>',bgColor:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M16.56 8.94L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.59-.59 1.54 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.58.59-1.53 0-2.12zM5.21 10L10 5.21 14.79 10H5.21zM19 11.5s-2 2.17-2 3.5c0 1.1.9 2 2 2s2-.9 2-2c0-1.33-2-3.5-2-3.5z"/><rect fill="currentColor" x="3" y="19" width="18" height="4"/></svg>'},t=[{type:"button",name:"undo",icon:"undo",tooltip:"Undo",command:"undo"},{type:"button",name:"redo",icon:"redo",tooltip:"Redo",command:"redo"},{type:"separator"},{type:"button",name:"bold",icon:"bold",tooltip:"Bold (Ctrl+B)",command:"bold"},{type:"button",name:"italic",icon:"italic",tooltip:"Italic (Ctrl+I)",command:"italic"},{type:"button",name:"underline",icon:"underline",tooltip:"Underline (Ctrl+U)",command:"underline"},{type:"button",name:"strikethrough",icon:"strikethrough",tooltip:"Strikethrough",command:"strikeThrough"},{type:"separator"},{type:"button",name:"heading1",icon:"heading1",tooltip:"Heading 1",command:"formatBlock",value:"H1"},{type:"button",name:"heading2",icon:"heading2",tooltip:"Heading 2",command:"formatBlock",value:"H2"},{type:"button",name:"heading3",icon:"heading3",tooltip:"Heading 3",command:"formatBlock",value:"H3"},{type:"separator"},{type:"button",name:"justifyLeft",icon:"justifyLeft",tooltip:"Align Left",command:"justifyLeft"},{type:"button",name:"justifyCenter",icon:"justifyCenter",tooltip:"Align Center",command:"justifyCenter"},{type:"button",name:"justifyRight",icon:"justifyRight",tooltip:"Align Right",command:"justifyRight"},{type:"separator"},{type:"button",name:"unorderedList",icon:"unorderedList",tooltip:"Bullet List",command:"insertUnorderedList"},{type:"button",name:"orderedList",icon:"orderedList",tooltip:"Numbered List",command:"insertOrderedList"},{type:"button",name:"blockquote",icon:"blockquote",tooltip:"Block Quote",command:"formatBlock",value:"BLOCKQUOTE"},{type:"separator"},{type:"button",name:"link",icon:"link",tooltip:"Insert Link",command:"createLink"},{type:"button",name:"image",icon:"image",tooltip:"Insert Image",command:"insertImage"},{type:"button",name:"horizontalRule",icon:"horizontalRule",tooltip:"Horizontal Line",command:"insertHorizontalRule"},{type:"separator"},{type:"button",name:"code",icon:"code",tooltip:"Code Block",command:"formatBlock",value:"PRE"},{type:"separator"},{type:"button",name:"removeFormat",icon:"removeFormat",tooltip:"Clear Formatting",command:"removeFormat"},{type:"button",name:"textColor",icon:"textColor",tooltip:"Text Color",command:"foreColor"},{type:"button",name:"bgColor",icon:"bgColor",tooltip:"Background Color",command:"hiliteColor"}],n={insertLink:"Insert Link",editLink:"Edit Link",insertImage:"Insert Image",editImage:"Edit Image",displayText:"Display Text",url:"URL",imageUrl:"Image URL",altText:"Alt Text",preview:"Preview",cancel:"Cancel",insert:"Insert",save:"Save",removeLink:"Remove Link",close:"Close",unableToLoadImage:"Unable to load image"};function o(e="",t="",o){const i={...n,...o};return new Promise(n=>{const o=document.createElement("div");o.className="re-dialog-overlay";const r=document.createElement("div");r.className="re-dialog",r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("aria-label",t?i.editLink:i.insertLink);const a=document.createElement("div");a.className="re-dialog-header";const l=document.createElement("span");l.className="re-dialog-title",l.textContent=t?i.editLink:i.insertLink;const s=document.createElement("button");s.className="re-dialog-close",s.type="button",s.setAttribute("aria-label",i.close),s.innerHTML="×",a.appendChild(l),a.appendChild(s);const c=document.createElement("div");c.className="re-dialog-body";const d=document.createElement("div");d.className="re-dialog-field";const u=document.createElement("label");u.className="re-dialog-label",u.setAttribute("for","re-link-text"),u.textContent=i.displayText;const m=document.createElement("input");m.className="re-dialog-input",m.type="text",m.id="re-link-text",m.placeholder="Text to display",m.value=e,d.appendChild(u),d.appendChild(m);const h=document.createElement("div");h.className="re-dialog-field";const p=document.createElement("label");p.className="re-dialog-label",p.setAttribute("for","re-link-url"),p.textContent=i.url;const v=document.createElement("input");v.className="re-dialog-input",v.type="url",v.id="re-link-url",v.placeholder="https://example.com",v.value=t,h.appendChild(p),h.appendChild(v),c.appendChild(d),c.appendChild(h);const g=document.createElement("div");if(g.className="re-dialog-footer",t){const e=document.createElement("button");e.className="re-dialog-btn re-dialog-btn-remove",e.type="button",e.textContent=i.removeLink,e.addEventListener("click",()=>{C(),n({action:"remove",text:"",url:""})}),g.appendChild(e)}const f=document.createElement("button");f.className="re-dialog-btn re-dialog-btn-cancel",f.type="button",f.textContent=i.cancel;const b=document.createElement("button");function C(){o.remove()}function y(){const e=m.value.trim(),t=v.value.trim();if(!t)return v.focus(),v.classList.add("re-dialog-input-error"),void setTimeout(()=>v.classList.remove("re-dialog-input-error"),1500);n({action:"insert",text:e||t,url:t}),C()}function L(){n(null),C()}b.className="re-dialog-btn re-dialog-btn-confirm",b.type="button",b.textContent=t?i.save:i.insert,g.appendChild(f),g.appendChild(b),r.appendChild(a),r.appendChild(c),r.appendChild(g),o.appendChild(r),document.body.appendChild(o),setTimeout(()=>{t?(v.focus(),v.select()):m.focus()},50),s.addEventListener("click",L),f.addEventListener("click",L),b.addEventListener("click",y),o.addEventListener("click",e=>{e.target===o&&L()}),r.addEventListener("keydown",e=>{if("Escape"===e.key)e.preventDefault(),L();else if("Enter"===e.key&&document.activeElement===v)e.preventDefault(),y();else if("Tab"===e.key){const t=r.querySelectorAll('input, button, [tabindex]:not([tabindex="-1"])'),n=t[0],o=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),o.focus()):e.shiftKey||document.activeElement!==o||(e.preventDefault(),n.focus())}})})}function i(e="",t="",o){const i={...n,...o};return new Promise(n=>{const o=document.createElement("div");o.className="re-dialog-overlay";const r=document.createElement("div");r.className="re-dialog",r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("aria-label",e?i.editImage:i.insertImage);const a=document.createElement("div");a.className="re-dialog-header";const l=document.createElement("span");l.className="re-dialog-title",l.textContent=e?i.editImage:i.insertImage;const s=document.createElement("button");s.className="re-dialog-close",s.type="button",s.setAttribute("aria-label",i.close),s.innerHTML="×",a.appendChild(l),a.appendChild(s);const c=document.createElement("div");c.className="re-dialog-body";const d=document.createElement("div");d.className="re-dialog-field";const u=document.createElement("label");u.className="re-dialog-label",u.setAttribute("for","re-image-url"),u.textContent=i.imageUrl;const m=document.createElement("input");m.className="re-dialog-input",m.type="url",m.id="re-image-url",m.placeholder="https://example.com/image.jpg",m.value=e,d.appendChild(u),d.appendChild(m);const h=document.createElement("div");h.className="re-dialog-field";const p=document.createElement("label");p.className="re-dialog-label",p.setAttribute("for","re-image-alt"),p.textContent=i.altText;const v=document.createElement("input");v.className="re-dialog-input",v.type="text",v.id="re-image-alt",v.placeholder="Description of the image",v.value=t,h.appendChild(p),h.appendChild(v);const g=document.createElement("div");g.className="re-dialog-field";const f=document.createElement("span");f.className="re-dialog-label",f.textContent=i.preview;const b=document.createElement("div");b.className="re-dialog-image-preview",m.addEventListener("input",function(){const e=m.value.trim();if(b.innerHTML="",e){const t=document.createElement("img");t.src=e,t.alt=v.value,t.onerror=()=>{b.innerHTML=`<span class="re-dialog-image-error">${i.unableToLoadImage}</span>`},b.appendChild(t)}}),g.appendChild(f),g.appendChild(b),c.appendChild(d),c.appendChild(h),c.appendChild(g);const C=document.createElement("div");C.className="re-dialog-footer";const y=document.createElement("button");y.className="re-dialog-btn re-dialog-btn-cancel",y.type="button",y.textContent=i.cancel;const L=document.createElement("button");function x(){o.remove()}function E(){const e=m.value.trim(),t=v.value.trim();if(!e)return m.focus(),m.classList.add("re-dialog-input-error"),void setTimeout(()=>m.classList.remove("re-dialog-input-error"),1500);n({url:e,alt:t}),x()}function w(){n(null),x()}L.className="re-dialog-btn re-dialog-btn-confirm",L.type="button",L.textContent=e?i.save:i.insert,C.appendChild(y),C.appendChild(L),r.appendChild(a),r.appendChild(c),r.appendChild(C),o.appendChild(r),document.body.appendChild(o),setTimeout(()=>{m.focus(),m.select()},50),s.addEventListener("click",w),y.addEventListener("click",w),L.addEventListener("click",E),o.addEventListener("click",e=>{e.target===o&&w()}),r.addEventListener("keydown",e=>{if("Escape"===e.key)e.preventDefault(),w();else if("Enter"===e.key&&document.activeElement===m)e.preventDefault(),E();else if("Tab"===e.key){const t=r.querySelectorAll('input, button, [tabindex]:not([tabindex="-1"])'),n=t[0],o=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),o.focus()):e.shiftKey||document.activeElement!==o||(e.preventDefault(),n.focus())}})})}const r=new Set(["script","iframe","object","embed","applet","form","input","textarea","select","button","link","meta","style","base","noscript","template","slot","shadow"]),a=new Set(["font","center"]),l=[/^on/i,/expression\(/i,/url\(/i,/javascript:/i,/vbscript:/i],s=new Set(["http:","https:","mailto:","tel:","ftp:","#",""]);function c(e){if(!e)return"";const t=(new DOMParser).parseFromString(e,"text/html").body;return d(t),t.innerHTML}function d(e){const t=Array.from(e.childNodes);for(const e of t)if(e.nodeType===Node.ELEMENT_NODE){const t=e,n=t.tagName.toLowerCase();if(r.has(n)){t.remove();continue}if(a.has(n)){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);t.remove()}continue}const o=Array.from(t.attributes);for(const e of o){const n=e.name.toLowerCase(),o=e.value;if(l.some(e=>e.test(n)))t.removeAttribute(e.name);else if(["srcdoc","dynsrc","lowsrc","action","formaction","xlink:href"].includes(n))t.removeAttribute(e.name);else{if("style"===n){const e=m(o);e?t.setAttribute("style",e):t.removeAttribute("style");continue}["href","src","action","poster","background"].includes(n)&&(u(o)||t.removeAttribute(e.name))}}d(t)}}function u(e){if(!e)return!0;const t=e.trim().toLowerCase();if(t.startsWith("/")||t.startsWith("./")||t.startsWith("../")||!t.includes(":"))return!0;if(t.startsWith("#"))return!0;const n=t.match(/^([a-z][a-z0-9+.-]*):/);if(!n)return!0;const o=n[1]+":";return s.has(o)}function m(e){if(!e)return"";return[/expression\s*\(/i,/javascript\s*:/i,/vbscript\s*:/i,/url\s*\(\s*['"]?\s*javascript:/i,/-moz-binding/i,/behavior\s*:/i].some(t=>t.test(e))?"":e}function h(e){if(!e)return"";const t=e.trim();if(t.startsWith("#"))return t;if(!t.includes(":")||t.startsWith("/"))return t;try{const e=new URL(t).protocol.toLowerCase();if(s.has(e))return t;return new URL("https://"+t).href}catch(e){return""}}function p(e){if(!e)return"";const t=e.trim();if(!t.includes(":")||t.startsWith("/"))return t;try{const e=new URL(t),n=e.protocol.toLowerCase();if("http:"===n||"https:"===n)return t;if("data:"===n){return e.pathname.split(";")[0].split(",")[0].toLowerCase().startsWith("image/")?t:""}return""}catch(e){return""}}const v={content:"",placeholder:"Start typing...",height:"300px",readOnly:!1,maxLength:0,maxUndoLevels:100,autoFocus:!1},g={words:"words",characters:"characters",insertLink:"Insert Link",editLink:"Edit Link",insertImage:"Insert Image",editImage:"Edit Image",displayText:"Display Text",url:"URL",imageUrl:"Image URL",altText:"Alt Text",preview:"Preview",cancel:"Cancel",insert:"Insert",save:"Save",removeLink:"Remove Link",close:"Close",unableToLoadImage:"Unable to load image"};function f(n){const r={...v,...n},a={...g,...r.locale};let l;if("string"==typeof r.container){const e=document.querySelector(r.container);if(!e)throw new Error(`SRich Editor: Container element not found for selector "${r.container}"`);l=e}else l=r.container;const s=document.createElement("div");s.className="re-wrapper",s.setAttribute("dir","ltr");const d=document.createElement("div");d.className="re-toolbar",d.setAttribute("role","toolbar"),d.setAttribute("aria-label","Formatting toolbar");const u=document.createElement("div");u.className="re-content",u.setAttribute("contenteditable","true"),u.setAttribute("role","textbox"),u.setAttribute("aria-multiline","true"),u.setAttribute("aria-label","Rich text editor"),u.style.minHeight=r.height||"300px";const m=document.createElement("div");m.className="re-placeholder",m.textContent=r.placeholder||"Start typing...";const f=document.createElement("div");f.className="re-statusbar",f.setAttribute("aria-live","polite"),s.appendChild(d),s.appendChild(document.createElement("div")).className="re-content-wrapper";const b=s.querySelector(".re-content-wrapper");b.appendChild(m),b.appendChild(u),s.appendChild(f),l.appendChild(s);let C=!1;r.className;const y=[],L=[],x=r.maxUndoLevels||100;let E=!1,w="";function k(){if(E)return;const e=u.innerHTML;e!==w&&(y.push(w),y.length>x&&y.shift(),w=e,L.length=0,H())}function H(){const e=d.querySelector('[data-command="undo"]'),t=d.querySelector('[data-command="redo"]');e&&(e.classList.toggle("re-disabled",0===y.length),e.setAttribute("aria-disabled",String(0===y.length))),t&&(t.classList.toggle("re-disabled",0===L.length),t.setAttribute("aria-disabled",String(0===L.length)))}function z(){var e;const t=""===(null===(e=u.textContent)||void 0===e?void 0:e.trim())&&""===u.innerHTML.replace(/<br\s*\/?>/gi,"").trim();m.style.display=t?"block":"none"}function N(){d.querySelectorAll(".re-btn[data-command]").forEach(e=>{const t=e.dataset.command,n=e.dataset.value;if(t&&"undo"!==t&&"redo"!==t){let o=!1;try{o="formatBlock"===t&&n?document.queryCommandValue("formatBlock").toUpperCase()===n.toUpperCase():document.queryCommandState(t)}catch(e){}e.classList.toggle("re-active",o),e.setAttribute("aria-pressed",String(o))}}),H()}function A(){const e=u.textContent||"",t=e.length,n=""===e.trim()?0:e.trim().split(/\s+/).length;f.textContent=`${n} ${a.words} · ${t} ${a.characters}`}let T=null;function M(){T||(T=setTimeout(()=>{T=null,B()},0))}function B(){z(),A(),N(),r.onChange&&r.onChange(u.innerHTML)}function R(){if(!r.maxLength||r.maxLength<=0)return!0;return!((u.textContent||"").length>r.maxLength)||(u.innerHTML=w,!1)}function S(){const e=window.getSelection();return e&&e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function I(e){if(!e)return!1;const t=window.getSelection();return!!t&&(t.removeAllRanges(),t.addRange(e),!0)}async function D(){var e;const{selectedText:t,linkUrl:n,linkNode:i}=function(){const e=window.getSelection();let t="",n=null,o=null;if(e&&e.rangeCount>0){t=e.toString();let i=e.anchorNode;for(;i&&i!==u;){if(i.nodeType===Node.ELEMENT_NODE&&"A"===i.tagName){o=i,n=o.getAttribute("href")||"",t||(t=o.textContent||"");break}i=i.parentNode}}return{selectedText:t,linkUrl:n,linkNode:o}}(),r=S(),l=await o(t,n||"",a);if(l){if(k(),"remove"===l.action){if(i){const t=document.createTextNode(i.textContent||"");null===(e=i.parentNode)||void 0===e||e.replaceChild(t,i),B()}return}if(i)i.setAttribute("href",h(l.url)),l.text&&i.textContent!==l.text&&(i.textContent=l.text),B();else if(u.focus(),I(r),t){const e=window.getSelection();if(e&&e.rangeCount>0){const n=e.getRangeAt(0);if(u.contains(n.commonAncestorContainer)){const o=n.extractContents(),i=document.createElement("a");i.href=h(l.url),l.text&&l.text!==t?i.textContent=l.text:i.appendChild(o),n.insertNode(i),n.setStartAfter(i),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}else{const e=document.createElement("a");e.href=h(l.url),e.textContent=l.text||t,u.appendChild(e)}B()}}else{const e=document.createElement("a");e.href=h(l.url),e.textContent=l.text||l.url;const t=window.getSelection();if(t&&t.rangeCount>0){const n=t.getRangeAt(0);n.insertNode(e),n.setStartAfter(e),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}else u.appendChild(e);B()}}}function V(e,t){C||("undo"!==e?"redo"!==e?(u.focus(),"createLink"!==e?"insertImage"!==e?(k(),"formatBlock"===e&&t?document.execCommand("formatBlock",!1,t):(document.execCommand(e,!1,t||""),k(),N(),M())):async function(){const e=S(),t=await i("","",a);if(t){u.focus(),I(e),k();const n=document.createElement("img");n.src=p(t.url),n.alt=t.alt;const o=window.getSelection();if(o&&o.rangeCount>0){const e=o.getRangeAt(0);u.contains(e.commonAncestorContainer)?(e.deleteContents(),e.insertNode(n),e.setStartAfter(n),e.collapse(!0),o.removeAllRanges(),o.addRange(e)):u.appendChild(n)}else u.appendChild(n);B()}}():D()):j():U())}function U(){if(0===y.length)return;const e=u.innerHTML,t=y.pop();L.push(e),E=!0,u.innerHTML=t,w=t,E=!1,B(),H()}function j(){if(0===L.length)return;const e=u.innerHTML,t=L.pop();y.push(e),E=!0,u.innerHTML=t,w=t,E=!1,B(),H()}function q(e){if(!C){if(r.onKeyDown){if(!1===r.onKeyDown(e))return}if((e.ctrlKey||e.metaKey)&&!e.shiftKey)switch(e.key.toLowerCase()){case"b":e.preventDefault(),V("bold");break;case"i":e.preventDefault(),V("italic");break;case"u":e.preventDefault(),V("underline");break;case"z":e.preventDefault(),U();break;case"y":e.preventDefault(),j()}(e.ctrlKey||e.metaKey)&&e.shiftKey&&"z"===e.key.toLowerCase()&&(e.preventDefault(),j()),"Tab"===e.key&&(e.preventDefault(),document.execCommand("insertHTML",!1,"&nbsp;&nbsp;&nbsp;&nbsp;"),M())}}function K(e){if(r.onPaste){if(!1===r.onPaste(e))return}k(),setTimeout(()=>{R(),B()},0)}let F=0;function O(e){F=e.touches[0].clientY}function W(e){const t=e.changedTouches[0].clientY;Math.abs(t-F)<10&&N()}function P(){N(),r.onFocus&&r.onFocus()}function $(){N(),r.onBlur&&r.onBlur()}let Q=null;const Y=new MutationObserver(function(){Q&&clearTimeout(Q),Q=setTimeout(()=>{E||(z(),A(),N())},100)});u.addEventListener("input",()=>{R()&&(k(),M())}),u.addEventListener("keyup",N),u.addEventListener("mouseup",N),u.addEventListener("keydown",q),u.addEventListener("paste",K),u.addEventListener("focus",P),u.addEventListener("blur",$),u.addEventListener("touchstart",O,{passive:!0}),u.addEventListener("touchend",W,{passive:!0}),Y.observe(u,{childList:!0,subtree:!0,characterData:!0}),r.content&&(u.innerHTML=c(r.content)),r.readOnly&&(u.setAttribute("contenteditable","false"),s.classList.add("re-readonly"),C=!0),r.className&&(r.className,s.classList.add(...r.className.split(/\s+/).filter(Boolean))),!1===r.toolbarVisible&&(d.style.display="none"),!1===r.statusBarVisible&&(f.style.display="none"),(r.toolbar||t).forEach(t=>{if("separator"===t.type){const e=document.createElement("div");return e.className="re-separator",e.setAttribute("role","separator"),e.setAttribute("aria-orientation","vertical"),void d.appendChild(e)}if("button"===t.type&&t.command){const n=document.createElement("button");n.className="re-btn",n.type="button",n.setAttribute("aria-label",t.tooltip||t.name||""),n.setAttribute("aria-pressed","false"),n.setAttribute("title",t.tooltip||""),n.dataset.command=t.command,t.value&&(n.dataset.value=t.value);const o=t.icon||t.name||"";e[o]?n.innerHTML=e[o]:n.textContent=t.name||t.command,n.addEventListener("mousedown",e=>{e.preventDefault()}),n.addEventListener("click",e=>{e.preventDefault(),V(t.command,t.value)}),d.appendChild(n)}}),r.customButtons&&0!==r.customButtons.length&&r.customButtons.forEach(e=>{const t=document.createElement("button");t.className="re-btn",t.type="button",t.setAttribute("aria-label",e.tooltip),t.setAttribute("title",e.tooltip),t.dataset.command="custom",t.dataset.customName=e.name,e.icon?t.innerHTML=e.icon:t.textContent=e.name,t.addEventListener("mousedown",e=>{e.preventDefault()}),t.addEventListener("click",t=>{t.preventDefault(),C||e.command(_)}),void 0!==e.position&&e.position<d.children.length?d.insertBefore(t,d.children[e.position]):d.appendChild(t)}),z(),A(),w=u.innerHTML,y.length=0,L.length=0,H(),r.autoFocus&&u.focus(),r.onReady&&r.onReady();const _={getContent:()=>u.innerHTML,setContent(e){k(),u.innerHTML=c(e),w=u.innerHTML,B()},getText:()=>u.textContent||"",execCommand(e,t){V(e,t)},queryCommandState(e){try{return document.queryCommandState(e)}catch(e){return!1}},destroy(){u.removeEventListener("input",M),u.removeEventListener("keyup",N),u.removeEventListener("mouseup",N),u.removeEventListener("keydown",q),u.removeEventListener("paste",K),u.removeEventListener("focus",P),u.removeEventListener("blur",$),u.removeEventListener("touchstart",O),u.removeEventListener("touchend",W),Y.disconnect(),T&&clearTimeout(T),Q&&clearTimeout(Q),document.querySelectorAll(".re-dialog-overlay").forEach(e=>e.remove()),s.remove()},getElement:()=>s,enable(){u.setAttribute("contenteditable","true"),s.classList.remove("re-readonly"),C=!1,B()},disable(){u.setAttribute("contenteditable","false"),s.classList.add("re-readonly"),C=!0},focus(){u.focus()},isEmpty(){var e;return""===(null===(e=u.textContent)||void 0===e?void 0:e.trim())&&""===u.innerHTML.replace(/<br\s*\/?>/gi,"").trim()},canUndo:()=>y.length>0,canRedo:()=>L.length>0,undo(){U()},redo(){j()},getCharacterCount:()=>(u.textContent||"").length,getWordCount(){const e=(u.textContent||"").trim();return""===e?0:e.split(/\s+/).length}};return _}var b={createEditor:f};export{f as createEditor,b as default,t as defaultToolbar,e as icons,c as sanitizeHTML,p as sanitizeImageURL,h as sanitizeLinkURL,i as showImageDialog,o as showLinkDialog};
7
+ //# sourceMappingURL=srich-editor.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"srich-editor.esm.js","sources":["../src/toolbar.ts","../src/dialog.ts","../src/sanitizer.ts","../src/editor.ts","../src/index.ts"],"sourcesContent":[null,null,null,null,null],"names":["icons","bold","italic","underline","strikethrough","heading1","heading2","heading3","unorderedList","orderedList","justifyLeft","justifyCenter","justifyRight","link","image","code","undo","redo","blockquote","horizontalRule","removeFormat","textColor","bgColor","defaultToolbar","type","name","icon","tooltip","command","value","defaultDialogLocale","insertLink","editLink","insertImage","editImage","displayText","url","imageUrl","altText","preview","cancel","insert","save","removeLink","close","unableToLoadImage","showLinkDialog","currentText","currentUrl","locale","loc","Promise","resolve","overlay","document","createElement","className","dialog","setAttribute","header","title","textContent","closeBtn","innerHTML","appendChild","body","textField","textLabel","textInput","id","placeholder","urlField","urlLabel","urlInput","footer","removeBtn","addEventListener","cleanup","action","text","cancelBtn","confirmBtn","remove","confirm","trim","focus","classList","add","setTimeout","select","e","target","key","preventDefault","activeElement","focusable","querySelectorAll","firstEl","lastEl","length","shiftKey","showImageDialog","currentAlt","altField","altLabel","altInput","previewField","previewLabel","previewContainer","img","src","alt","onerror","DANGEROUS_ELEMENTS","Set","UNWRAP_ELEMENTS","DANGEROUS_ATTR_PATTERNS","SAFE_LINK_PROTOCOLS","sanitizeHTML","html","DOMParser","parseFromString","sanitizeNode","node","childNodes","Array","from","child","nodeType","Node","ELEMENT_NODE","el","tagName","toLowerCase","has","parent","parentNode","firstChild","insertBefore","attrs","attributes","attr","attrName","attrValue","some","pattern","test","removeAttribute","includes","safeStyle","sanitizeStyle","isSafeURL","trimmed","startsWith","protocolMatch","match","protocol","style","sanitizeLinkURL","URL","href","_a","sanitizeImageURL","parsed","pathname","split","defaultOptions","content","height","readOnly","maxLength","maxUndoLevels","autoFocus","defaultLocale","words","characters","createEditor","options","config","containerEl","container","querySelector","Error","wrapper","toolbar","contentArea","minHeight","statusBar","contentWrapper","isDisabled","undoStack","redoStack","isUndoRedoAction","lastSavedContent","saveToUndoStack","current","push","shift","updateUndoRedoButtons","undoBtn","redoBtn","toggle","String","updatePlaceholder","isEmpty","replace","display","updateToolbarState","forEach","btn","dataset","isActive","queryCommandValue","toUpperCase","queryCommandState","updateStatusBar","chars","throttleTimer","throttledHandleInput","handleInput","onChange","checkMaxLength","saveSelection","selection","window","getSelection","rangeCount","getRangeAt","cloneRange","restoreSelection","savedRange","removeAllRanges","addRange","async","handleCreateLink","selectedText","linkUrl","linkNode","toString","anchorNode","getAttribute","getSelectionInfo","result","textNode","createTextNode","replaceChild","range","contains","commonAncestorContainer","selectedContent","extractContents","anchor","insertNode","setStartAfter","collapse","handleToolbarAction","execCommand","deleteContents","handleInsertImage","performRedo","performUndo","prev","pop","next","handleKeydown","onKeyDown","ctrlKey","metaKey","handlePaste","onPaste","touchStartY","handleTouchStart","touches","clientY","handleTouchEnd","touchEndY","changedTouches","Math","abs","handleFocus","onFocus","handleBlur","onBlur","debounceTimer","observer","MutationObserver","clearTimeout","passive","observe","childList","subtree","characterData","filter","Boolean","toolbarVisible","statusBarVisible","item","sep","iconName","customButtons","customBtn","customName","instance","undefined","position","children","onReady","getContent","setContent","getText","destroy","removeEventListener","disconnect","getElement","enable","disable","canUndo","canRedo","getCharacterCount","getWordCount","index"],"mappings":";;;;;AAKO,MAAMA,EAAQ,CACnBC,KAAM,8TACNC,OAAQ,yIACRC,UAAW,4MACXC,cAAe,+IACfC,SAAU,oKACVC,SAAU,oKACVC,SAAU,oKACVC,cAAe,wWACfC,YAAa,mOACbC,YAAa,qKACbC,c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AY/H,aAAa,kBAAmB,QAC5C6H,EAAQjG,UAAUJ,OAAO,eACzB2G,GAAa,EACb8B,GACF,EAEA,OAAAgG,GACElI,EAAY/H,aAAa,kBAAmB,SAC5C6H,EAAQjG,UAAUC,IAAI,eACtBsG,GAAa,CACf,EAEA,KAAAxG,GACEoG,EAAYpG,OACd,EAEA,OAAAuH,SACE,MAA2C,MAAb,UAAvBnB,EAAY5H,mBAAW,IAAAoG,OAAA,EAAAA,EAAE7E,SAC+B,KAA7DqG,EAAY1H,UAAU8I,QAAQ,eAAgB,IAAIzH,MACtD,EAEAwO,QAAO,IACE9H,EAAU3F,OAAS,EAG5B0N,QAAO,IACE9H,EAAU5F,OAAS,EAG5B,IAAAnF,GACEoP,GACF,EAEA,IAAAnP,GACEkP,GACF,EAEA2D,kBAAiB,KACPrI,EAAY5H,aAAe,IAAIsC,OAGzC,YAAA4N,GACE,MAAMhP,GAAQ0G,EAAY5H,aAAe,IAAIuB,OAC7C,MAAgB,KAATL,EAAc,EAAIA,EAAKsF,MAAM,OAAOlE,MAC7C,GAGF,OAAO2M,CACT,CCvuBA,IAAAkB,EAAe,CAAEhJ"}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * SRich Editor v1.0.0
3
+ * A lightweight, dependency-free rich text editor
4
+ * MIT License
5
+ */
6
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SRichEditor={})}(this,function(e){"use strict";const t={bold:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"/></svg>',italic:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"/></svg>',underline:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z"/></svg>',strikethrough:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"/></svg>',heading1:'<svg viewBox="0 0 24 24" width="18" height="18"><text x="3" y="18" font-size="16" font-weight="bold" fill="currentColor" font-family="sans-serif">H1</text></svg>',heading2:'<svg viewBox="0 0 24 24" width="18" height="18"><text x="3" y="18" font-size="16" font-weight="bold" fill="currentColor" font-family="sans-serif">H2</text></svg>',heading3:'<svg viewBox="0 0 24 24" width="18" height="18"><text x="3" y="18" font-size="16" font-weight="bold" fill="currentColor" font-family="sans-serif">H3</text></svg>',unorderedList:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z"/></svg>',orderedList:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z"/></svg>',justifyLeft:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z"/></svg>',justifyCenter:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z"/></svg>',justifyRight:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z"/></svg>',link:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/></svg>',image:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/></svg>',code:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z"/></svg>',undo:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z"/></svg>',redo:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"/></svg>',blockquote:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"/></svg>',horizontalRule:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M2 11h20v2H2z"/></svg>',removeFormat:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M3.27 5L2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21 18 19.73 3.27 5zM6 5v.18L8.82 8h2.4l-.72 1.68 2.1 2.1L14.21 8H20V5H6z"/></svg>',textColor:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M11 2L5.5 16h2.25l1.12-3h6.25l1.12 3h2.25L13 2h-2zm-1.38 9L12 4.67 14.38 11H9.62z"/></svg>',bgColor:'<svg viewBox="0 0 24 24" width="18" height="18"><path fill="currentColor" d="M16.56 8.94L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.59-.59 1.54 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.58.59-1.53 0-2.12zM5.21 10L10 5.21 14.79 10H5.21zM19 11.5s-2 2.17-2 3.5c0 1.1.9 2 2 2s2-.9 2-2c0-1.33-2-3.5-2-3.5z"/><rect fill="currentColor" x="3" y="19" width="18" height="4"/></svg>'},n=[{type:"button",name:"undo",icon:"undo",tooltip:"Undo",command:"undo"},{type:"button",name:"redo",icon:"redo",tooltip:"Redo",command:"redo"},{type:"separator"},{type:"button",name:"bold",icon:"bold",tooltip:"Bold (Ctrl+B)",command:"bold"},{type:"button",name:"italic",icon:"italic",tooltip:"Italic (Ctrl+I)",command:"italic"},{type:"button",name:"underline",icon:"underline",tooltip:"Underline (Ctrl+U)",command:"underline"},{type:"button",name:"strikethrough",icon:"strikethrough",tooltip:"Strikethrough",command:"strikeThrough"},{type:"separator"},{type:"button",name:"heading1",icon:"heading1",tooltip:"Heading 1",command:"formatBlock",value:"H1"},{type:"button",name:"heading2",icon:"heading2",tooltip:"Heading 2",command:"formatBlock",value:"H2"},{type:"button",name:"heading3",icon:"heading3",tooltip:"Heading 3",command:"formatBlock",value:"H3"},{type:"separator"},{type:"button",name:"justifyLeft",icon:"justifyLeft",tooltip:"Align Left",command:"justifyLeft"},{type:"button",name:"justifyCenter",icon:"justifyCenter",tooltip:"Align Center",command:"justifyCenter"},{type:"button",name:"justifyRight",icon:"justifyRight",tooltip:"Align Right",command:"justifyRight"},{type:"separator"},{type:"button",name:"unorderedList",icon:"unorderedList",tooltip:"Bullet List",command:"insertUnorderedList"},{type:"button",name:"orderedList",icon:"orderedList",tooltip:"Numbered List",command:"insertOrderedList"},{type:"button",name:"blockquote",icon:"blockquote",tooltip:"Block Quote",command:"formatBlock",value:"BLOCKQUOTE"},{type:"separator"},{type:"button",name:"link",icon:"link",tooltip:"Insert Link",command:"createLink"},{type:"button",name:"image",icon:"image",tooltip:"Insert Image",command:"insertImage"},{type:"button",name:"horizontalRule",icon:"horizontalRule",tooltip:"Horizontal Line",command:"insertHorizontalRule"},{type:"separator"},{type:"button",name:"code",icon:"code",tooltip:"Code Block",command:"formatBlock",value:"PRE"},{type:"separator"},{type:"button",name:"removeFormat",icon:"removeFormat",tooltip:"Clear Formatting",command:"removeFormat"},{type:"button",name:"textColor",icon:"textColor",tooltip:"Text Color",command:"foreColor"},{type:"button",name:"bgColor",icon:"bgColor",tooltip:"Background Color",command:"hiliteColor"}],o={insertLink:"Insert Link",editLink:"Edit Link",insertImage:"Insert Image",editImage:"Edit Image",displayText:"Display Text",url:"URL",imageUrl:"Image URL",altText:"Alt Text",preview:"Preview",cancel:"Cancel",insert:"Insert",save:"Save",removeLink:"Remove Link",close:"Close",unableToLoadImage:"Unable to load image"};function i(e="",t="",n){const i={...o,...n};return new Promise(n=>{const o=document.createElement("div");o.className="re-dialog-overlay";const a=document.createElement("div");a.className="re-dialog",a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),a.setAttribute("aria-label",t?i.editLink:i.insertLink);const r=document.createElement("div");r.className="re-dialog-header";const l=document.createElement("span");l.className="re-dialog-title",l.textContent=t?i.editLink:i.insertLink;const s=document.createElement("button");s.className="re-dialog-close",s.type="button",s.setAttribute("aria-label",i.close),s.innerHTML="×",r.appendChild(l),r.appendChild(s);const c=document.createElement("div");c.className="re-dialog-body";const d=document.createElement("div");d.className="re-dialog-field";const u=document.createElement("label");u.className="re-dialog-label",u.setAttribute("for","re-link-text"),u.textContent=i.displayText;const m=document.createElement("input");m.className="re-dialog-input",m.type="text",m.id="re-link-text",m.placeholder="Text to display",m.value=e,d.appendChild(u),d.appendChild(m);const h=document.createElement("div");h.className="re-dialog-field";const p=document.createElement("label");p.className="re-dialog-label",p.setAttribute("for","re-link-url"),p.textContent=i.url;const v=document.createElement("input");v.className="re-dialog-input",v.type="url",v.id="re-link-url",v.placeholder="https://example.com",v.value=t,h.appendChild(p),h.appendChild(v),c.appendChild(d),c.appendChild(h);const g=document.createElement("div");if(g.className="re-dialog-footer",t){const e=document.createElement("button");e.className="re-dialog-btn re-dialog-btn-remove",e.type="button",e.textContent=i.removeLink,e.addEventListener("click",()=>{C(),n({action:"remove",text:"",url:""})}),g.appendChild(e)}const f=document.createElement("button");f.className="re-dialog-btn re-dialog-btn-cancel",f.type="button",f.textContent=i.cancel;const b=document.createElement("button");function C(){o.remove()}function y(){const e=m.value.trim(),t=v.value.trim();if(!t)return v.focus(),v.classList.add("re-dialog-input-error"),void setTimeout(()=>v.classList.remove("re-dialog-input-error"),1500);n({action:"insert",text:e||t,url:t}),C()}function L(){n(null),C()}b.className="re-dialog-btn re-dialog-btn-confirm",b.type="button",b.textContent=t?i.save:i.insert,g.appendChild(f),g.appendChild(b),a.appendChild(r),a.appendChild(c),a.appendChild(g),o.appendChild(a),document.body.appendChild(o),setTimeout(()=>{t?(v.focus(),v.select()):m.focus()},50),s.addEventListener("click",L),f.addEventListener("click",L),b.addEventListener("click",y),o.addEventListener("click",e=>{e.target===o&&L()}),a.addEventListener("keydown",e=>{if("Escape"===e.key)e.preventDefault(),L();else if("Enter"===e.key&&document.activeElement===v)e.preventDefault(),y();else if("Tab"===e.key){const t=a.querySelectorAll('input, button, [tabindex]:not([tabindex="-1"])'),n=t[0],o=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),o.focus()):e.shiftKey||document.activeElement!==o||(e.preventDefault(),n.focus())}})})}function a(e="",t="",n){const i={...o,...n};return new Promise(n=>{const o=document.createElement("div");o.className="re-dialog-overlay";const a=document.createElement("div");a.className="re-dialog",a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),a.setAttribute("aria-label",e?i.editImage:i.insertImage);const r=document.createElement("div");r.className="re-dialog-header";const l=document.createElement("span");l.className="re-dialog-title",l.textContent=e?i.editImage:i.insertImage;const s=document.createElement("button");s.className="re-dialog-close",s.type="button",s.setAttribute("aria-label",i.close),s.innerHTML="×",r.appendChild(l),r.appendChild(s);const c=document.createElement("div");c.className="re-dialog-body";const d=document.createElement("div");d.className="re-dialog-field";const u=document.createElement("label");u.className="re-dialog-label",u.setAttribute("for","re-image-url"),u.textContent=i.imageUrl;const m=document.createElement("input");m.className="re-dialog-input",m.type="url",m.id="re-image-url",m.placeholder="https://example.com/image.jpg",m.value=e,d.appendChild(u),d.appendChild(m);const h=document.createElement("div");h.className="re-dialog-field";const p=document.createElement("label");p.className="re-dialog-label",p.setAttribute("for","re-image-alt"),p.textContent=i.altText;const v=document.createElement("input");v.className="re-dialog-input",v.type="text",v.id="re-image-alt",v.placeholder="Description of the image",v.value=t,h.appendChild(p),h.appendChild(v);const g=document.createElement("div");g.className="re-dialog-field";const f=document.createElement("span");f.className="re-dialog-label",f.textContent=i.preview;const b=document.createElement("div");b.className="re-dialog-image-preview",m.addEventListener("input",function(){const e=m.value.trim();if(b.innerHTML="",e){const t=document.createElement("img");t.src=e,t.alt=v.value,t.onerror=()=>{b.innerHTML=`<span class="re-dialog-image-error">${i.unableToLoadImage}</span>`},b.appendChild(t)}}),g.appendChild(f),g.appendChild(b),c.appendChild(d),c.appendChild(h),c.appendChild(g);const C=document.createElement("div");C.className="re-dialog-footer";const y=document.createElement("button");y.className="re-dialog-btn re-dialog-btn-cancel",y.type="button",y.textContent=i.cancel;const L=document.createElement("button");function x(){o.remove()}function E(){const e=m.value.trim(),t=v.value.trim();if(!e)return m.focus(),m.classList.add("re-dialog-input-error"),void setTimeout(()=>m.classList.remove("re-dialog-input-error"),1500);n({url:e,alt:t}),x()}function w(){n(null),x()}L.className="re-dialog-btn re-dialog-btn-confirm",L.type="button",L.textContent=e?i.save:i.insert,C.appendChild(y),C.appendChild(L),a.appendChild(r),a.appendChild(c),a.appendChild(C),o.appendChild(a),document.body.appendChild(o),setTimeout(()=>{m.focus(),m.select()},50),s.addEventListener("click",w),y.addEventListener("click",w),L.addEventListener("click",E),o.addEventListener("click",e=>{e.target===o&&w()}),a.addEventListener("keydown",e=>{if("Escape"===e.key)e.preventDefault(),w();else if("Enter"===e.key&&document.activeElement===m)e.preventDefault(),E();else if("Tab"===e.key){const t=a.querySelectorAll('input, button, [tabindex]:not([tabindex="-1"])'),n=t[0],o=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),o.focus()):e.shiftKey||document.activeElement!==o||(e.preventDefault(),n.focus())}})})}const r=new Set(["script","iframe","object","embed","applet","form","input","textarea","select","button","link","meta","style","base","noscript","template","slot","shadow"]),l=new Set(["font","center"]),s=[/^on/i,/expression\(/i,/url\(/i,/javascript:/i,/vbscript:/i],c=new Set(["http:","https:","mailto:","tel:","ftp:","#",""]);function d(e){if(!e)return"";const t=(new DOMParser).parseFromString(e,"text/html").body;return u(t),t.innerHTML}function u(e){const t=Array.from(e.childNodes);for(const e of t)if(e.nodeType===Node.ELEMENT_NODE){const t=e,n=t.tagName.toLowerCase();if(r.has(n)){t.remove();continue}if(l.has(n)){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);t.remove()}continue}const o=Array.from(t.attributes);for(const e of o){const n=e.name.toLowerCase(),o=e.value;if(s.some(e=>e.test(n)))t.removeAttribute(e.name);else if(["srcdoc","dynsrc","lowsrc","action","formaction","xlink:href"].includes(n))t.removeAttribute(e.name);else{if("style"===n){const e=h(o);e?t.setAttribute("style",e):t.removeAttribute("style");continue}["href","src","action","poster","background"].includes(n)&&(m(o)||t.removeAttribute(e.name))}}u(t)}}function m(e){if(!e)return!0;const t=e.trim().toLowerCase();if(t.startsWith("/")||t.startsWith("./")||t.startsWith("../")||!t.includes(":"))return!0;if(t.startsWith("#"))return!0;const n=t.match(/^([a-z][a-z0-9+.-]*):/);if(!n)return!0;const o=n[1]+":";return c.has(o)}function h(e){if(!e)return"";return[/expression\s*\(/i,/javascript\s*:/i,/vbscript\s*:/i,/url\s*\(\s*['"]?\s*javascript:/i,/-moz-binding/i,/behavior\s*:/i].some(t=>t.test(e))?"":e}function p(e){if(!e)return"";const t=e.trim();if(t.startsWith("#"))return t;if(!t.includes(":")||t.startsWith("/"))return t;try{const e=new URL(t).protocol.toLowerCase();if(c.has(e))return t;return new URL("https://"+t).href}catch(e){return""}}function v(e){if(!e)return"";const t=e.trim();if(!t.includes(":")||t.startsWith("/"))return t;try{const e=new URL(t),n=e.protocol.toLowerCase();if("http:"===n||"https:"===n)return t;if("data:"===n){return e.pathname.split(";")[0].split(",")[0].toLowerCase().startsWith("image/")?t:""}return""}catch(e){return""}}const g={content:"",placeholder:"Start typing...",height:"300px",readOnly:!1,maxLength:0,maxUndoLevels:100,autoFocus:!1},f={words:"words",characters:"characters",insertLink:"Insert Link",editLink:"Edit Link",insertImage:"Insert Image",editImage:"Edit Image",displayText:"Display Text",url:"URL",imageUrl:"Image URL",altText:"Alt Text",preview:"Preview",cancel:"Cancel",insert:"Insert",save:"Save",removeLink:"Remove Link",close:"Close",unableToLoadImage:"Unable to load image"};function b(e){const o={...g,...e},r={...f,...o.locale};let l;if("string"==typeof o.container){const e=document.querySelector(o.container);if(!e)throw new Error(`SRich Editor: Container element not found for selector "${o.container}"`);l=e}else l=o.container;const s=document.createElement("div");s.className="re-wrapper",s.setAttribute("dir","ltr");const c=document.createElement("div");c.className="re-toolbar",c.setAttribute("role","toolbar"),c.setAttribute("aria-label","Formatting toolbar");const u=document.createElement("div");u.className="re-content",u.setAttribute("contenteditable","true"),u.setAttribute("role","textbox"),u.setAttribute("aria-multiline","true"),u.setAttribute("aria-label","Rich text editor"),u.style.minHeight=o.height||"300px";const m=document.createElement("div");m.className="re-placeholder",m.textContent=o.placeholder||"Start typing...";const h=document.createElement("div");h.className="re-statusbar",h.setAttribute("aria-live","polite"),s.appendChild(c),s.appendChild(document.createElement("div")).className="re-content-wrapper";const b=s.querySelector(".re-content-wrapper");b.appendChild(m),b.appendChild(u),s.appendChild(h),l.appendChild(s);let C=!1;o.className;const y=[],L=[],x=o.maxUndoLevels||100;let E=!1,w="";function k(){if(E)return;const e=u.innerHTML;e!==w&&(y.push(w),y.length>x&&y.shift(),w=e,L.length=0,H())}function H(){const e=c.querySelector('[data-command="undo"]'),t=c.querySelector('[data-command="redo"]');e&&(e.classList.toggle("re-disabled",0===y.length),e.setAttribute("aria-disabled",String(0===y.length))),t&&(t.classList.toggle("re-disabled",0===L.length),t.setAttribute("aria-disabled",String(0===L.length)))}function z(){var e;const t=""===(null===(e=u.textContent)||void 0===e?void 0:e.trim())&&""===u.innerHTML.replace(/<br\s*\/?>/gi,"").trim();m.style.display=t?"block":"none"}function N(){c.querySelectorAll(".re-btn[data-command]").forEach(e=>{const t=e.dataset.command,n=e.dataset.value;if(t&&"undo"!==t&&"redo"!==t){let o=!1;try{o="formatBlock"===t&&n?document.queryCommandValue("formatBlock").toUpperCase()===n.toUpperCase():document.queryCommandState(t)}catch(e){}e.classList.toggle("re-active",o),e.setAttribute("aria-pressed",String(o))}}),H()}function A(){const e=u.textContent||"",t=e.length,n=""===e.trim()?0:e.trim().split(/\s+/).length;h.textContent=`${n} ${r.words} · ${t} ${r.characters}`}let T=null;function M(){T||(T=setTimeout(()=>{T=null,B()},0))}function B(){z(),A(),N(),o.onChange&&o.onChange(u.innerHTML)}function R(){if(!o.maxLength||o.maxLength<=0)return!0;return!((u.textContent||"").length>o.maxLength)||(u.innerHTML=w,!1)}function S(){const e=window.getSelection();return e&&e.rangeCount>0?e.getRangeAt(0).cloneRange():null}function I(e){if(!e)return!1;const t=window.getSelection();return!!t&&(t.removeAllRanges(),t.addRange(e),!0)}async function D(){var e;const{selectedText:t,linkUrl:n,linkNode:o}=function(){const e=window.getSelection();let t="",n=null,o=null;if(e&&e.rangeCount>0){t=e.toString();let i=e.anchorNode;for(;i&&i!==u;){if(i.nodeType===Node.ELEMENT_NODE&&"A"===i.tagName){o=i,n=o.getAttribute("href")||"",t||(t=o.textContent||"");break}i=i.parentNode}}return{selectedText:t,linkUrl:n,linkNode:o}}(),a=S(),l=await i(t,n||"",r);if(l){if(k(),"remove"===l.action){if(o){const t=document.createTextNode(o.textContent||"");null===(e=o.parentNode)||void 0===e||e.replaceChild(t,o),B()}return}if(o)o.setAttribute("href",p(l.url)),l.text&&o.textContent!==l.text&&(o.textContent=l.text),B();else if(u.focus(),I(a),t){const e=window.getSelection();if(e&&e.rangeCount>0){const n=e.getRangeAt(0);if(u.contains(n.commonAncestorContainer)){const o=n.extractContents(),i=document.createElement("a");i.href=p(l.url),l.text&&l.text!==t?i.textContent=l.text:i.appendChild(o),n.insertNode(i),n.setStartAfter(i),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}else{const e=document.createElement("a");e.href=p(l.url),e.textContent=l.text||t,u.appendChild(e)}B()}}else{const e=document.createElement("a");e.href=p(l.url),e.textContent=l.text||l.url;const t=window.getSelection();if(t&&t.rangeCount>0){const n=t.getRangeAt(0);n.insertNode(e),n.setStartAfter(e),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}else u.appendChild(e);B()}}}function U(e,t){C||("undo"!==e?"redo"!==e?(u.focus(),"createLink"!==e?"insertImage"!==e?(k(),"formatBlock"===e&&t?document.execCommand("formatBlock",!1,t):(document.execCommand(e,!1,t||""),k(),N(),M())):async function(){const e=S(),t=await a("","",r);if(t){u.focus(),I(e),k();const n=document.createElement("img");n.src=v(t.url),n.alt=t.alt;const o=window.getSelection();if(o&&o.rangeCount>0){const e=o.getRangeAt(0);u.contains(e.commonAncestorContainer)?(e.deleteContents(),e.insertNode(n),e.setStartAfter(n),e.collapse(!0),o.removeAllRanges(),o.addRange(e)):u.appendChild(n)}else u.appendChild(n);B()}}():D()):j():V())}function V(){if(0===y.length)return;const e=u.innerHTML,t=y.pop();L.push(e),E=!0,u.innerHTML=t,w=t,E=!1,B(),H()}function j(){if(0===L.length)return;const e=u.innerHTML,t=L.pop();y.push(e),E=!0,u.innerHTML=t,w=t,E=!1,B(),H()}function q(e){if(!C){if(o.onKeyDown){if(!1===o.onKeyDown(e))return}if((e.ctrlKey||e.metaKey)&&!e.shiftKey)switch(e.key.toLowerCase()){case"b":e.preventDefault(),U("bold");break;case"i":e.preventDefault(),U("italic");break;case"u":e.preventDefault(),U("underline");break;case"z":e.preventDefault(),V();break;case"y":e.preventDefault(),j()}(e.ctrlKey||e.metaKey)&&e.shiftKey&&"z"===e.key.toLowerCase()&&(e.preventDefault(),j()),"Tab"===e.key&&(e.preventDefault(),document.execCommand("insertHTML",!1,"&nbsp;&nbsp;&nbsp;&nbsp;"),M())}}function K(e){if(o.onPaste){if(!1===o.onPaste(e))return}k(),setTimeout(()=>{R(),B()},0)}let F=0;function O(e){F=e.touches[0].clientY}function P(e){const t=e.changedTouches[0].clientY;Math.abs(t-F)<10&&N()}function W(){N(),o.onFocus&&o.onFocus()}function $(){N(),o.onBlur&&o.onBlur()}let _=null;const Q=new MutationObserver(function(){_&&clearTimeout(_),_=setTimeout(()=>{E||(z(),A(),N())},100)});u.addEventListener("input",()=>{R()&&(k(),M())}),u.addEventListener("keyup",N),u.addEventListener("mouseup",N),u.addEventListener("keydown",q),u.addEventListener("paste",K),u.addEventListener("focus",W),u.addEventListener("blur",$),u.addEventListener("touchstart",O,{passive:!0}),u.addEventListener("touchend",P,{passive:!0}),Q.observe(u,{childList:!0,subtree:!0,characterData:!0}),o.content&&(u.innerHTML=d(o.content)),o.readOnly&&(u.setAttribute("contenteditable","false"),s.classList.add("re-readonly"),C=!0),o.className&&(o.className,s.classList.add(...o.className.split(/\s+/).filter(Boolean))),!1===o.toolbarVisible&&(c.style.display="none"),!1===o.statusBarVisible&&(h.style.display="none"),(o.toolbar||n).forEach(e=>{if("separator"===e.type){const e=document.createElement("div");return e.className="re-separator",e.setAttribute("role","separator"),e.setAttribute("aria-orientation","vertical"),void c.appendChild(e)}if("button"===e.type&&e.command){const n=document.createElement("button");n.className="re-btn",n.type="button",n.setAttribute("aria-label",e.tooltip||e.name||""),n.setAttribute("aria-pressed","false"),n.setAttribute("title",e.tooltip||""),n.dataset.command=e.command,e.value&&(n.dataset.value=e.value);const o=e.icon||e.name||"";t[o]?n.innerHTML=t[o]:n.textContent=e.name||e.command,n.addEventListener("mousedown",e=>{e.preventDefault()}),n.addEventListener("click",t=>{t.preventDefault(),U(e.command,e.value)}),c.appendChild(n)}}),o.customButtons&&0!==o.customButtons.length&&o.customButtons.forEach(e=>{const t=document.createElement("button");t.className="re-btn",t.type="button",t.setAttribute("aria-label",e.tooltip),t.setAttribute("title",e.tooltip),t.dataset.command="custom",t.dataset.customName=e.name,e.icon?t.innerHTML=e.icon:t.textContent=e.name,t.addEventListener("mousedown",e=>{e.preventDefault()}),t.addEventListener("click",t=>{t.preventDefault(),C||e.command(Y)}),void 0!==e.position&&e.position<c.children.length?c.insertBefore(t,c.children[e.position]):c.appendChild(t)}),z(),A(),w=u.innerHTML,y.length=0,L.length=0,H(),o.autoFocus&&u.focus(),o.onReady&&o.onReady();const Y={getContent:()=>u.innerHTML,setContent(e){k(),u.innerHTML=d(e),w=u.innerHTML,B()},getText:()=>u.textContent||"",execCommand(e,t){U(e,t)},queryCommandState(e){try{return document.queryCommandState(e)}catch(e){return!1}},destroy(){u.removeEventListener("input",M),u.removeEventListener("keyup",N),u.removeEventListener("mouseup",N),u.removeEventListener("keydown",q),u.removeEventListener("paste",K),u.removeEventListener("focus",W),u.removeEventListener("blur",$),u.removeEventListener("touchstart",O),u.removeEventListener("touchend",P),Q.disconnect(),T&&clearTimeout(T),_&&clearTimeout(_),document.querySelectorAll(".re-dialog-overlay").forEach(e=>e.remove()),s.remove()},getElement:()=>s,enable(){u.setAttribute("contenteditable","true"),s.classList.remove("re-readonly"),C=!1,B()},disable(){u.setAttribute("contenteditable","false"),s.classList.add("re-readonly"),C=!0},focus(){u.focus()},isEmpty(){var e;return""===(null===(e=u.textContent)||void 0===e?void 0:e.trim())&&""===u.innerHTML.replace(/<br\s*\/?>/gi,"").trim()},canUndo:()=>y.length>0,canRedo:()=>L.length>0,undo(){V()},redo(){j()},getCharacterCount:()=>(u.textContent||"").length,getWordCount(){const e=(u.textContent||"").trim();return""===e?0:e.split(/\s+/).length}};return Y}var C={createEditor:b};e.createEditor=b,e.default=C,e.defaultToolbar=n,e.icons=t,e.sanitizeHTML=d,e.sanitizeImageURL=v,e.sanitizeLinkURL=p,e.showImageDialog=a,e.showLinkDialog=i,Object.defineProperty(e,"__esModule",{value:!0})});
7
+ //# sourceMappingURL=srich-editor.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"srich-editor.umd.js","sources":["../src/toolbar.ts","../src/dialog.ts","../src/sanitizer.ts","../src/editor.ts","../src/index.ts"],"sourcesContent":[null,null,null,null,null],"names":["icons","bold","italic","underline","strikethrough","heading1","heading2","heading3","unorderedList","orderedList","justifyLeft","justifyCenter","justifyRight","link","image","code","undo","redo","blockquote","horizontalRule","removeFormat","textColor","bgColor","defaultToolbar","type","name","icon","tooltip","command","value","defaultDialogLocale","insertLink","editLink","insertImage","editImage","displayText","url","imageUrl","altText","preview","cancel","insert","save","removeLink","close","unableToLoadImage","showLinkDialog","currentText","currentUrl","locale","loc","Promise","resolve","overlay","document","createElement","className","dialog","setAttribute","header","title","textContent","closeBtn","innerHTML","appendChild","body","textField","textLabel","textInput","id","placeholder","urlField","urlLabel","urlInput","footer","removeBtn","addEventListener","cleanup","action","text","cancelBtn","confirmBtn","remove","confirm","trim","focus","classList","add","setTimeout","select","e","target","key","preventDefault","activeElement","focusable","querySelectorAll","firstEl","lastEl","length","shiftKey","showImageDialog","currentAlt","altField","altLabel","altInput","previewField","previewLabel","previewContainer","img","src","alt","onerror","DANGEROUS_ELEMENTS","Set","UNWRAP_ELEMENTS","DANGEROUS_ATTR_PATTERNS","SAFE_LINK_PROTOCOLS","sanitizeHTML","html","DOMParser","parseFromString","sanitizeNode","node","childNodes","Array","from","child","nodeType","Node","ELEMENT_NODE","el","tagName","toLowerCase","has","parent","parentNode","firstChild","insertBefore","attrs","attributes","attr","attrName","attrValue","some","pattern","test","removeAttribute","includes","safeStyle","sanitizeStyle","isSafeURL","trimmed","startsWith","protocolMatch","match","protocol","style","sanitizeLinkURL","URL","href","_a","sanitizeImageURL","parsed","pathname","split","defaultOptions","content","height","readOnly","maxLength","maxUndoLevels","autoFocus","defaultLocale","words","characters","createEditor","options","config","containerEl","container","querySelector","Error","wrapper","toolbar","contentArea","minHeight","statusBar","contentWrapper","isDisabled","undoStack","redoStack","isUndoRedoAction","lastSavedContent","saveToUndoStack","current","push","shift","updateUndoRedoButtons","undoBtn","redoBtn","toggle","String","updatePlaceholder","isEmpty","replace","display","updateToolbarState","forEach","btn","dataset","isActive","queryCommandValue","toUpperCase","queryCommandState","updateStatusBar","chars","throttleTimer","throttledHandleInput","handleInput","onChange","checkMaxLength","saveSelection","selection","window","getSelection","rangeCount","getRangeAt","cloneRange","restoreSelection","savedRange","removeAllRanges","addRange","async","handleCreateLink","selectedText","linkUrl","linkNode","toString","anchorNode","getAttribute","getSelectionInfo","result","textNode","createTextNode","replaceChild","range","contains","commonAncestorContainer","selectedContent","extractContents","anchor","insertNode","setStartAfter","collapse","handleToolbarAction","execCommand","deleteContents","handleInsertImage","performRedo","performUndo","prev","pop","next","handleKeydown","onKeyDown","ctrlKey","metaKey","handlePaste","onPaste","touchStartY","handleTouchStart","touches","clientY","handleTouchEnd","touchEndY","changedTouches","Math","abs","handleFocus","onFocus","handleBlur","onBlur","debounceTimer","observer","MutationObserver","clearTimeout","passive","observe","childList","subtree","characterData","filter","Boolean","toolbarVisible","statusBarVisible","item","sep","iconName","customButtons","customBtn","customName","instance","undefined","position","children","onReady","getContent","setContent","getText","destroy","removeEventListener","disconnect","getElement","enable","disable","canUndo","canRedo","getCharacterCount","getWordCount","index"],"mappings":";;;;;kPAKO,MAAMA,EAAQ,CACnBC,KAAM,8TACNC,OAAQ,yIACRC,UAAW,4MACXC,cAAe,+IACfC,SAAU,oKACVC,SAAU,oKACVC,SAAU,oKACVC,cAAe,wWACfC,YAAa,mOACbC,YAAa,qKACbC,cAAe,oKACfC,aAAc,oKACdC,KAAM,4SACNC,MAAO,iNACPC,KAAM,mLACNC,KAAM,uOACNC,KAAM,wOACNC,WAAY,iIACZC,eAAgB,sGAChBC,aAAc,mNACdC,UAAW,0KACXC,QAAS,8YAMEC,EAAgC,CAE3C,CAAEC,KAAM,SAAUC,KAAM,OAAQC,KAAM,OAAQC,QAAS,OAAQC,QAAS,QACxE,CAAEJ,KAAM,SAAUC,KAAM,OAAQC,KAAM,OAAQC,QAAS,OAAQC,QAAS,QACxE,CAAEJ,KAAM,aAGR,CAAEA,KAAM,SAAUC,KAAM,OAAQC,KAAM,OAAQC,QAAS,gBAAiBC,QAAS,QACjF,CAAEJ,KAAM,SAAUC,KAAM,SAAUC,KAAM,SAAUC,QAAS,kB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,GACEkP,GACF,EAEA2D,kBAAiB,KACPrI,EAAY5H,aAAe,IAAIsC,OAGzC,YAAA4N,GACE,MAAMhP,GAAQ0G,EAAY5H,aAAe,IAAIuB,OAC7C,MAAgB,KAATL,EAAc,EAAIA,EAAKsF,MAAM,OAAOlE,MAC7C,GAGF,OAAO2M,CACT,CCvuBA,IAAAkB,EAAe,CAAEhJ"}
@@ -0,0 +1 @@
1
+ :root{--re-font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;--re-font-size:15px;--re-line-height:1.6;--re-border-color:#d1d5db;--re-border-radius:8px;--re-bg-primary:#fff;--re-bg-secondary:#f8f9fa;--re-bg-tertiary:#f9fafb;--re-text-primary:#212529;--re-text-secondary:#495057;--re-text-muted:#868e96;--re-text-placeholder:#adb5bd;--re-accent-color:#3b82f6;--re-accent-hover:#2563eb;--re-accent-bg:#cce5ff;--re-accent-bg-hover:#b6d4fe;--re-accent-border:#9ec5fe;--re-accent-text:#084298;--re-focus-ring-color:rgba(59,130,246,.3);--re-shadow:0 1px 3px rgba(0,0,0,.08);--re-shadow-focus:0 0 0 2px var(--re-focus-ring-color);--re-separator-color:#dee2e6;--re-btn-hover-bg:#e9ecef;--re-btn-active-bg:#dee2e6;--re-dialog-overlay-bg:rgba(0,0,0,.5);--re-dialog-shadow:0 20px 60px rgba(0,0,0,.3);--re-danger-color:#dc2626;--re-danger-border:#fca5a5;--re-danger-bg:#fef2f2;--re-code-bg:#212529;--re-code-text:#e9ecef;--re-code-inline-bg:#f1f3f5;--re-code-inline-text:#e83e8c}.re-wrapper{background:var(--re-bg-primary);border:1px solid var(--re-border-color);border-radius:var(--re-border-radius);box-shadow:var(--re-shadow);font-family:var(--re-font-family);overflow:hidden;transition:box-shadow .2s ease}.re-wrapper:focus-within{border-color:var(--re-accent-color);box-shadow:var(--re-shadow-focus)}.re-toolbar{align-items:center;background:var(--re-bg-secondary);border-bottom:1px solid var(--re-separator-color);display:flex;flex-wrap:wrap;gap:2px;padding:6px 8px;user-select:none}.re-btn{align-items:center;background:transparent;border:1px solid transparent;border-radius:6px;color:var(--re-text-secondary);cursor:pointer;display:inline-flex;height:32px;justify-content:center;padding:0;transition:all .15s ease;width:32px}.re-btn:hover{background:var(--re-btn-hover-bg);border-color:var(--re-separator-color);color:var(--re-text-primary)}.re-btn:active{background:var(--re-btn-active-bg)}.re-btn.re-active{background:var(--re-accent-bg);border-color:var(--re-accent-border);color:var(--re-accent-text)}.re-btn.re-active:hover{background:var(--re-accent-bg-hover)}.re-btn.re-disabled,.re-btn[aria-disabled=true]{cursor:not-allowed;opacity:.35;pointer-events:none}.re-separator{background:var(--re-separator-color);flex-shrink:0;height:20px;margin:0 4px;width:1px}.re-content-wrapper{position:relative}.re-placeholder{color:var(--re-text-placeholder);left:16px;pointer-events:none;position:absolute;right:16px;top:12px;user-select:none}.re-content,.re-placeholder{font-size:var(--re-font-size);line-height:var(--re-line-height)}.re-content{word-wrap:break-word;background:var(--re-bg-primary);color:var(--re-text-primary);outline:none;overflow-wrap:break-word;overflow-y:auto;padding:12px 16px}.re-content:empty:before{color:var(--re-text-placeholder);content:attr(data-placeholder);pointer-events:none}.re-content h1{font-size:2em;font-weight:700;line-height:1.3;margin:.5em 0}.re-content h2{font-size:1.5em;font-weight:600;line-height:1.3;margin:.5em 0}.re-content h3{font-size:1.17em;font-weight:600;line-height:1.4;margin:.5em 0}.re-content p{margin:.5em 0}.re-content ol,.re-content ul{margin:.5em 0;padding-left:1.5em}.re-content li{margin:.25em 0}.re-content blockquote{background:var(--re-bg-secondary);border-left:4px solid var(--re-accent-color);color:var(--re-text-secondary);font-style:italic;margin:.5em 0;padding:.5em 1em}.re-content pre{word-wrap:break-word;background:var(--re-code-bg);border-radius:var(--re-border-radius);color:var(--re-code-text);font-size:13px;line-height:1.5;margin:.5em 0;overflow-x:auto;padding:12px 16px;white-space:pre-wrap}.re-content code,.re-content pre{font-family:SF Mono,Fira Code,Fira Mono,Roboto Mono,monospace}.re-content code{background:var(--re-code-inline-bg);border-radius:4px;color:var(--re-code-inline-text);font-size:.9em;padding:2px 6px}.re-content pre code{background:none;border-radius:0;color:inherit;font-size:inherit;padding:0}.re-content a{color:var(--re-accent-color);text-decoration:underline}.re-content a:hover{color:var(--re-accent-hover)}.re-content img{border-radius:4px;height:auto;margin:.5em 0;max-width:100%}.re-content hr{border:none;border-top:2px solid var(--re-separator-color);margin:1em 0}.re-content table{border-collapse:collapse;margin:.5em 0;width:100%}.re-content table td,.re-content table th{border:1px solid var(--re-separator-color);padding:8px 12px;text-align:left}.re-content table th{background:var(--re-bg-secondary);font-weight:600}.re-statusbar{align-items:center;background:var(--re-bg-secondary);border-top:1px solid var(--re-separator-color);color:var(--re-text-muted);display:flex;font-size:12px;padding:4px 12px}.re-dialog-overlay{align-items:center;animation:re-dialog-fade-in .15s ease;background:var(--re-dialog-overlay-bg);display:flex;height:100%;justify-content:center;left:0;position:fixed;top:0;width:100%;z-index:10000}@keyframes re-dialog-fade-in{0%{opacity:0}to{opacity:1}}.re-dialog{animation:re-dialog-slide-in .2s ease;background:var(--re-bg-primary);border-radius:12px;box-shadow:var(--re-dialog-shadow);max-width:90vw;overflow:hidden;width:400px}@keyframes re-dialog-slide-in{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}.re-dialog-header{align-items:center;border-bottom:1px solid var(--re-separator-color);display:flex;justify-content:space-between;padding:16px 20px}.re-dialog-title{color:var(--re-text-primary);font-size:16px;font-weight:600}.re-dialog-close{align-items:center;background:transparent;border:none;border-radius:6px;color:var(--re-text-muted);cursor:pointer;display:flex;font-size:18px;height:28px;justify-content:center;transition:all .15s;width:28px}.re-dialog-close:hover{background:var(--re-btn-hover-bg);color:var(--re-text-primary)}.re-dialog-body{padding:20px}.re-dialog-field{margin-bottom:16px}.re-dialog-field:last-child{margin-bottom:0}.re-dialog-label{color:var(--re-text-secondary);display:block;font-size:13px;font-weight:500;margin-bottom:6px}.re-dialog-input{background:var(--re-bg-primary);border:1px solid var(--re-border-color);border-radius:var(--re-border-radius);color:var(--re-text-primary);font-size:14px;padding:8px 12px;transition:border-color .15s,box-shadow .15s;width:100%}.re-dialog-input:focus{border-color:var(--re-accent-color);box-shadow:0 0 0 3px rgba(59,130,246,.15);outline:none}.re-dialog-input::placeholder{color:var(--re-text-placeholder)}.re-dialog-input-error{border-color:#ef4444;box-shadow:0 0 0 3px rgba(239,68,68,.15)}.re-dialog-footer{align-items:center;background:var(--re-bg-tertiary);border-top:1px solid var(--re-separator-color);display:flex;gap:8px;justify-content:flex-end;padding:16px 20px}.re-dialog-btn{border:1px solid var(--re-border-color);border-radius:var(--re-border-radius);cursor:pointer;font-size:14px;font-weight:500;padding:8px 16px;transition:all .15s}.re-dialog-btn-cancel{background:var(--re-bg-primary);color:var(--re-text-secondary)}.re-dialog-btn-cancel:hover{background:var(--re-btn-hover-bg);border-color:var(--re-text-muted)}.re-dialog-btn-confirm{background:var(--re-accent-color);border-color:var(--re-accent-color);color:#fff}.re-dialog-btn-confirm:hover{background:var(--re-accent-hover);border-color:var(--re-accent-hover)}.re-dialog-btn-confirm:active{background:#1d4ed8}.re-dialog-btn-remove{background:var(--re-bg-primary);border-color:var(--re-danger-border);color:var(--re-danger-color);margin-right:auto}.re-dialog-btn-remove:hover{background:var(--re-danger-bg);border-color:var(--re-danger-color)}.re-dialog-image-preview{align-items:center;background:var(--re-bg-tertiary);border:1px solid var(--re-separator-color);border-radius:var(--re-border-radius);display:flex;justify-content:center;max-height:200px;min-height:60px;overflow:hidden}.re-dialog-image-preview img{max-height:180px;max-width:100%;object-fit:contain}.re-dialog-image-error{color:var(--re-text-muted);font-size:13px;padding:12px;text-align:center}.re-readonly .re-content{cursor:default}.re-readonly .re-toolbar{opacity:.5;pointer-events:none}@media screen and (max-width:600px){.re-wrapper{--re-font-size:14px;--re-border-radius:6px}.re-toolbar{gap:1px;padding:4px}.re-btn{height:36px;width:36px}.re-separator{height:16px;margin:0 2px}.re-content{padding:10px 12px}.re-placeholder{left:12px;right:12px;top:10px}.re-dialog{max-width:400px;width:calc(100vw - 32px)}.re-dialog-body,.re-dialog-footer,.re-dialog-header{padding:12px 16px}}@media print{.re-statusbar,.re-toolbar{display:none!important}.re-wrapper{border:none;box-shadow:none}.re-content{overflow:visible;padding:0}}
@@ -0,0 +1,284 @@
1
+ /**
2
+ * Configuration options for the Rich Editor
3
+ */
4
+ interface RichEditorOptions {
5
+ /** The container element or CSS selector */
6
+ container: string | HTMLElement;
7
+ /** Initial HTML content */
8
+ content?: string;
9
+ /** Placeholder text when editor is empty */
10
+ placeholder?: string;
11
+ /** Height of the editor (CSS value) */
12
+ height?: string;
13
+ /** Available toolbar buttons */
14
+ toolbar?: ToolbarItem[];
15
+ /** Callback when content changes */
16
+ onChange?: (content: string) => void;
17
+ /** Callback when editor is ready */
18
+ onReady?: () => void;
19
+ /** Callback when editor gains focus */
20
+ onFocus?: () => void;
21
+ /** Callback when editor loses focus */
22
+ onBlur?: () => void;
23
+ /** Callback before a key is processed (return false to prevent) */
24
+ onKeyDown?: (e: KeyboardEvent) => boolean | void;
25
+ /** Callback when content is pasted (return false to prevent default) */
26
+ onPaste?: (e: ClipboardEvent) => boolean | void;
27
+ /** Custom toolbar button definitions */
28
+ customButtons?: CustomButton[];
29
+ /** Whether the editor is read-only */
30
+ readOnly?: boolean;
31
+ /** Whether the toolbar is visible */
32
+ toolbarVisible?: boolean;
33
+ /** Whether the status bar is visible */
34
+ statusBarVisible?: boolean;
35
+ /** Custom CSS class for the editor wrapper */
36
+ className?: string;
37
+ /** Maximum character length (0 = unlimited) */
38
+ maxLength?: number;
39
+ /** Locale for UI strings */
40
+ locale?: LocaleStrings;
41
+ /** Number of undo levels to keep */
42
+ maxUndoLevels?: number;
43
+ /** Auto-focus editor on creation */
44
+ autoFocus?: boolean;
45
+ }
46
+ /**
47
+ * Locale strings for internationalization
48
+ */
49
+ interface LocaleStrings {
50
+ words?: string;
51
+ characters?: string;
52
+ insertLink?: string;
53
+ editLink?: string;
54
+ insertImage?: string;
55
+ editImage?: string;
56
+ displayText?: string;
57
+ url?: string;
58
+ imageUrl?: string;
59
+ altText?: string;
60
+ preview?: string;
61
+ cancel?: string;
62
+ insert?: string;
63
+ save?: string;
64
+ removeLink?: string;
65
+ close?: string;
66
+ unableToLoadImage?: string;
67
+ }
68
+ /**
69
+ * Toolbar item definition
70
+ */
71
+ interface ToolbarItem {
72
+ type: 'button' | 'separator' | 'dropdown';
73
+ name?: string;
74
+ icon?: string;
75
+ tooltip?: string;
76
+ command?: string;
77
+ value?: string;
78
+ items?: ToolbarItem[];
79
+ }
80
+ /**
81
+ * Custom button definition
82
+ */
83
+ interface CustomButton {
84
+ /** Unique name for the button */
85
+ name: string;
86
+ /** SVG icon markup */
87
+ icon: string;
88
+ /** Tooltip text */
89
+ tooltip: string;
90
+ /** Click handler */
91
+ command: (editor: RichEditorInstance) => void;
92
+ /** Optional position in toolbar (0-based index) */
93
+ position?: number;
94
+ }
95
+ /**
96
+ * Editor instance interface
97
+ */
98
+ interface RichEditorInstance {
99
+ /** Get the editor content as HTML */
100
+ getContent(): string;
101
+ /** Set the editor content as HTML */
102
+ setContent(html: string): void;
103
+ /** Get the editor content as plain text */
104
+ getText(): string;
105
+ /** Execute a document command */
106
+ execCommand(command: string, value?: string): void;
107
+ /** Check if a command is active */
108
+ queryCommandState(command: string): boolean;
109
+ /** Destroy the editor instance */
110
+ destroy(): void;
111
+ /** Get the underlying DOM element */
112
+ getElement(): HTMLElement;
113
+ /** Enable the editor */
114
+ enable(): void;
115
+ /** Disable the editor */
116
+ disable(): void;
117
+ /** Set focus to the editor */
118
+ focus(): void;
119
+ /** Check if editor is empty */
120
+ isEmpty(): boolean;
121
+ /** Check if undo is available */
122
+ canUndo(): boolean;
123
+ /** Check if redo is available */
124
+ canRedo(): boolean;
125
+ /** Undo the last change */
126
+ undo(): void;
127
+ /** Redo the last change */
128
+ redo(): void;
129
+ /** Get current character count */
130
+ getCharacterCount(): number;
131
+ /** Get current word count */
132
+ getWordCount(): number;
133
+ }
134
+
135
+ /**
136
+ * Creates a new SRich Editor instance
137
+ */
138
+ declare function createEditor(options: RichEditorOptions): RichEditorInstance;
139
+
140
+ /**
141
+ * SVG icon definitions for toolbar buttons
142
+ */
143
+ declare const icons: {
144
+ readonly bold: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z\"/></svg>";
145
+ readonly italic: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z\"/></svg>";
146
+ readonly underline: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z\"/></svg>";
147
+ readonly strikethrough: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z\"/></svg>";
148
+ readonly heading1: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><text x=\"3\" y=\"18\" font-size=\"16\" font-weight=\"bold\" fill=\"currentColor\" font-family=\"sans-serif\">H1</text></svg>";
149
+ readonly heading2: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><text x=\"3\" y=\"18\" font-size=\"16\" font-weight=\"bold\" fill=\"currentColor\" font-family=\"sans-serif\">H2</text></svg>";
150
+ readonly heading3: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><text x=\"3\" y=\"18\" font-size=\"16\" font-weight=\"bold\" fill=\"currentColor\" font-family=\"sans-serif\">H3</text></svg>";
151
+ readonly unorderedList: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z\"/></svg>";
152
+ readonly orderedList: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z\"/></svg>";
153
+ readonly justifyLeft: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zm0 8h18v-2H3v2zM3 3v2h18V3H3z\"/></svg>";
154
+ readonly justifyCenter: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z\"/></svg>";
155
+ readonly justifyRight: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z\"/></svg>";
156
+ readonly link: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z\"/></svg>";
157
+ readonly image: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z\"/></svg>";
158
+ readonly code: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z\"/></svg>";
159
+ readonly undo: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z\"/></svg>";
160
+ readonly redo: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z\"/></svg>";
161
+ readonly blockquote: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z\"/></svg>";
162
+ readonly horizontalRule: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M2 11h20v2H2z\"/></svg>";
163
+ readonly removeFormat: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M3.27 5L2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21 18 19.73 3.27 5zM6 5v.18L8.82 8h2.4l-.72 1.68 2.1 2.1L14.21 8H20V5H6z\"/></svg>";
164
+ readonly textColor: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M11 2L5.5 16h2.25l1.12-3h6.25l1.12 3h2.25L13 2h-2zm-1.38 9L12 4.67 14.38 11H9.62z\"/></svg>";
165
+ readonly bgColor: "<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\"><path fill=\"currentColor\" d=\"M16.56 8.94L7.62 0 6.21 1.41l2.38 2.38-5.15 5.15c-.59.59-.59 1.54 0 2.12l5.5 5.5c.29.29.68.44 1.06.44s.77-.15 1.06-.44l5.5-5.5c.59-.58.59-1.53 0-2.12zM5.21 10L10 5.21 14.79 10H5.21zM19 11.5s-2 2.17-2 3.5c0 1.1.9 2 2 2s2-.9 2-2c0-1.33-2-3.5-2-3.5z\"/><rect fill=\"currentColor\" x=\"3\" y=\"19\" width=\"18\" height=\"4\"/></svg>";
166
+ };
167
+ /**
168
+ * Default toolbar configuration
169
+ */
170
+ declare const defaultToolbar: ToolbarItem[];
171
+
172
+ /**
173
+ * Custom dialog components for the SRich Editor
174
+ */
175
+ interface LinkDialogResult {
176
+ action: 'insert' | 'remove';
177
+ text: string;
178
+ url: string;
179
+ }
180
+ interface ImageDialogResult {
181
+ url: string;
182
+ alt: string;
183
+ }
184
+ /** Default locale strings for dialogs */
185
+ declare const defaultDialogLocale: {
186
+ insertLink: string;
187
+ editLink: string;
188
+ insertImage: string;
189
+ editImage: string;
190
+ displayText: string;
191
+ url: string;
192
+ imageUrl: string;
193
+ altText: string;
194
+ preview: string;
195
+ cancel: string;
196
+ insert: string;
197
+ save: string;
198
+ removeLink: string;
199
+ close: string;
200
+ unableToLoadImage: string;
201
+ };
202
+ type DialogLocale = typeof defaultDialogLocale;
203
+ /**
204
+ * Show a custom link dialog
205
+ * @param currentText - The currently selected text (if any)
206
+ * @param currentUrl - The current URL (if editing an existing link)
207
+ * @param locale - Optional locale strings
208
+ * @returns Promise that resolves with the user's input or null if cancelled
209
+ */
210
+ declare function showLinkDialog(currentText?: string, currentUrl?: string, locale?: Partial<DialogLocale>): Promise<LinkDialogResult | null>;
211
+ /**
212
+ * Show a custom image dialog
213
+ * @param currentUrl - The current image URL (if editing)
214
+ * @param currentAlt - The current alt text (if editing)
215
+ * @param locale - Optional locale strings
216
+ * @returns Promise that resolves with the user's input or null if cancelled
217
+ */
218
+ declare function showImageDialog(currentUrl?: string, currentAlt?: string, locale?: Partial<DialogLocale>): Promise<ImageDialogResult | null>;
219
+
220
+ /**
221
+ * HTML Sanitizer for SRich Editor
222
+ * Strips dangerous elements, attributes, and protocols to prevent XSS attacks.
223
+ */
224
+ /**
225
+ * Sanitize an HTML string by removing dangerous elements and attributes.
226
+ * @param html - The raw HTML string to sanitize
227
+ * @returns Sanitized HTML string
228
+ */
229
+ declare function sanitizeHTML(html: string): string;
230
+ /**
231
+ * Validate a URL for use in links.
232
+ * Only allows safe protocols: http, https, mailto, tel, ftp, and fragment-only (#).
233
+ * @param url - The URL to validate
234
+ * @returns The validated URL, or empty string if invalid
235
+ */
236
+ declare function sanitizeLinkURL(url: string): string;
237
+ /**
238
+ * Validate a URL for use in images.
239
+ * Only allows safe protocols: http, https, and data:image/*.
240
+ * @param url - The URL to validate
241
+ * @returns The validated URL, or empty string if invalid
242
+ */
243
+ declare function sanitizeImageURL(url: string): string;
244
+
245
+ /**
246
+ * SRich Editor - A lightweight, dependency-free rich text editor
247
+ *
248
+ * @example
249
+ * ```js
250
+ * import { createEditor } from 'srich-editor';
251
+ * import 'srich-editor/dist/styles.css';
252
+ *
253
+ * const editor = createEditor({
254
+ * container: '#editor',
255
+ * placeholder: 'Start typing...',
256
+ * onChange: (content) => console.log(content),
257
+ * onFocus: () => console.log('focused'),
258
+ * onBlur: () => console.log('blurred'),
259
+ * locale: {
260
+ * words: 'từ',
261
+ * characters: 'ký tự',
262
+ * },
263
+ * });
264
+ *
265
+ * // New API methods
266
+ * editor.getText(); // plain text
267
+ * editor.getCharacterCount(); // character count
268
+ * editor.getWordCount(); // word count
269
+ * editor.undo(); // undo last change
270
+ * editor.redo(); // redo last undone change
271
+ * editor.canUndo(); // check if undo is available
272
+ * editor.canRedo(); // check if redo is available
273
+ *
274
+ * // Custom buttons
275
+ * editor.execCommand('customButtonName');
276
+ * ```
277
+ */
278
+
279
+ declare const _default: {
280
+ createEditor: typeof createEditor;
281
+ };
282
+
283
+ export { createEditor, _default as default, defaultToolbar, icons, sanitizeHTML, sanitizeImageURL, sanitizeLinkURL, showImageDialog, showLinkDialog };
284
+ export type { CustomButton, LocaleStrings, RichEditorInstance, RichEditorOptions, ToolbarItem };
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "srich-editor",
3
+ "version": "1.0.0",
4
+ "description": "A lightweight, dependency-free rich text editor built with Vanilla JavaScript",
5
+ "main": "dist/srich-editor.umd.js",
6
+ "module": "dist/srich-editor.esm.js",
7
+ "types": "dist/types/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "README.md"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/srich-editor.esm.js",
15
+ "require": "./dist/srich-editor.umd.js",
16
+ "types": "./dist/types/index.d.ts"
17
+ },
18
+ "./dist/styles.css": "./dist/styles.css"
19
+ },
20
+ "scripts": {
21
+ "build": "rollup -c",
22
+ "dev": "rollup -c -w",
23
+ "test": "npx playwright test",
24
+ "test:e2e": "npx playwright test",
25
+ "lint": "eslint src/",
26
+ "prepublishOnly": "npm run build",
27
+ "demo": "open demo/index.html"
28
+ },
29
+ "keywords": [
30
+ "rich-text-editor",
31
+ "editor",
32
+ "wysiwyg",
33
+ "contenteditable",
34
+ "vanilla-js",
35
+ "lightweight",
36
+ "dependency-free"
37
+ ],
38
+ "author": "Son Nguyen (https://github.com/nbhson)",
39
+ "license": "MIT",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/nbhson/srich-editor.git"
43
+ },
44
+ "homepage": "https://github.com/nbhson/srich-editor#readme",
45
+ "bugs": {
46
+ "url": "https://github.com/nbhson/srich-editor/issues"
47
+ },
48
+ "devDependencies": {
49
+ "@rollup/plugin-terser": "^0.4.4",
50
+ "@rollup/plugin-typescript": "^12.3.0",
51
+ "rollup": "^4.9.0",
52
+ "rollup-plugin-css-only": "^4.5.2",
53
+ "rollup-plugin-dts": "^6.1.0",
54
+ "rollup-plugin-postcss": "^4.0.2",
55
+ "tslib": "^2.8.1",
56
+ "typescript": "^5.3.3"
57
+ },
58
+ "sideEffects": [
59
+ "**/*.css"
60
+ ],
61
+ "engines": {
62
+ "node": ">=16.0.0"
63
+ }
64
+ }