@overlap/rte 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +269 -0
- package/dist/components/Dropdown.d.ts +19 -0
- package/dist/components/Dropdown.d.ts.map +1 -0
- package/dist/components/Editor.d.ts +4 -0
- package/dist/components/Editor.d.ts.map +1 -0
- package/dist/components/FloatingToolbar.d.ts +10 -0
- package/dist/components/FloatingToolbar.d.ts.map +1 -0
- package/dist/components/IconWrapper.d.ts +10 -0
- package/dist/components/IconWrapper.d.ts.map +1 -0
- package/dist/components/Icons.d.ts +32 -0
- package/dist/components/Icons.d.ts.map +1 -0
- package/dist/components/Toolbar.d.ts +10 -0
- package/dist/components/Toolbar.d.ts.map +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/index.d.ts +208 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +2080 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +2116 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins/base.d.ts +10 -0
- package/dist/plugins/base.d.ts.map +1 -0
- package/dist/plugins/clearFormatting.d.ts +6 -0
- package/dist/plugins/clearFormatting.d.ts.map +1 -0
- package/dist/plugins/colors.d.ts +4 -0
- package/dist/plugins/colors.d.ts.map +1 -0
- package/dist/plugins/fontSize.d.ts +3 -0
- package/dist/plugins/fontSize.d.ts.map +1 -0
- package/dist/plugins/headings.d.ts +3 -0
- package/dist/plugins/headings.d.ts.map +1 -0
- package/dist/plugins/image.d.ts +6 -0
- package/dist/plugins/image.d.ts.map +1 -0
- package/dist/plugins/index.d.ts +14 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/optional.d.ts +19 -0
- package/dist/plugins/optional.d.ts.map +1 -0
- package/dist/styles.css +638 -0
- package/dist/types.d.ts +81 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/clearFormatting.d.ts +21 -0
- package/dist/utils/clearFormatting.d.ts.map +1 -0
- package/dist/utils/content.d.ts +12 -0
- package/dist/utils/content.d.ts.map +1 -0
- package/dist/utils/history.d.ts +14 -0
- package/dist/utils/history.d.ts.map +1 -0
- package/dist/utils/listIndent.d.ts +9 -0
- package/dist/utils/listIndent.d.ts.map +1 -0
- package/dist/utils/stateReflection.d.ts +18 -0
- package/dist/utils/stateReflection.d.ts.map +1 -0
- package/package.json +48 -0
- package/src/components/Dropdown.tsx +103 -0
- package/src/components/Editor.css +2 -0
- package/src/components/Editor.tsx +785 -0
- package/src/components/FloatingToolbar.tsx +214 -0
- package/src/components/IconWrapper.tsx +14 -0
- package/src/components/Icons.tsx +145 -0
- package/src/components/Toolbar.tsx +137 -0
- package/src/components/index.ts +3 -0
- package/src/index.ts +19 -0
- package/src/plugins/base.tsx +91 -0
- package/src/plugins/clearFormatting.tsx +31 -0
- package/src/plugins/colors.tsx +122 -0
- package/src/plugins/fontSize.tsx +81 -0
- package/src/plugins/headings.tsx +76 -0
- package/src/plugins/image.tsx +189 -0
- package/src/plugins/index.ts +54 -0
- package/src/plugins/optional.tsx +221 -0
- package/src/styles.css +638 -0
- package/src/types.ts +92 -0
- package/src/utils/clearFormatting.ts +244 -0
- package/src/utils/content.ts +290 -0
- package/src/utils/history.ts +59 -0
- package/src/utils/listIndent.ts +171 -0
- package/src/utils/stateReflection.ts +175 -0
package/README.md
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
# HENDRIKS-RTE
|
|
2
|
+
|
|
3
|
+
Ein leichtgewichtiger, erweiterbarer Rich Text Editor für React.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ✅ **Leichtgewichtig**: Minimale Abhängigkeiten (nur React)
|
|
8
|
+
- ✅ **Erweiterbar**: Einfaches Plugin-System
|
|
9
|
+
- ✅ **Contenteditable-basiert**: Nutzt native Browser-Funktionalität
|
|
10
|
+
- ✅ **Undo/Redo**: Vollständige Historie-Unterstützung
|
|
11
|
+
- ✅ **JSON-Datenmodell**: Strukturierter Export/Import
|
|
12
|
+
- ✅ **TypeScript**: Vollständig typisiert
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install hendriks-rte
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Grundlegende Verwendung
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import React, { useState } from "react";
|
|
24
|
+
import { Editor, EditorContent } from "hendriks-rte";
|
|
25
|
+
import "hendriks-rte/dist/styles.css"; // CSS importieren
|
|
26
|
+
|
|
27
|
+
function App() {
|
|
28
|
+
const [content, setContent] = useState<EditorContent | undefined>();
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Editor
|
|
32
|
+
initialContent={content}
|
|
33
|
+
onChange={(newContent) => {
|
|
34
|
+
setContent(newContent);
|
|
35
|
+
console.log("Content:", newContent);
|
|
36
|
+
}}
|
|
37
|
+
placeholder="Text eingeben..."
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Hinweis:** Das CSS wird automatisch mit dem Editor importiert, wenn du den Editor verwendest. Falls du das CSS separat importieren möchtest, kannst du `import 'hendriks-rte/dist/styles.css'` verwenden.
|
|
44
|
+
|
|
45
|
+
## Mit eigenen Plugins
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import React from "react";
|
|
49
|
+
import { Editor, Plugin, EditorAPI, ButtonProps } from "hendriks-rte";
|
|
50
|
+
|
|
51
|
+
// Eigenes Plugin erstellen
|
|
52
|
+
const customPlugin: Plugin = {
|
|
53
|
+
name: "custom",
|
|
54
|
+
type: "inline",
|
|
55
|
+
command: "bold", // oder eigene Logik
|
|
56
|
+
renderButton: (props: ButtonProps) => (
|
|
57
|
+
<button
|
|
58
|
+
onClick={props.onClick}
|
|
59
|
+
className={`toolbar-button ${props.isActive ? "active" : ""}`}
|
|
60
|
+
>
|
|
61
|
+
⭐ {/* Oder verwende SVG-Icons */}
|
|
62
|
+
</button>
|
|
63
|
+
),
|
|
64
|
+
execute: (editor: EditorAPI) => {
|
|
65
|
+
editor.executeCommand("bold");
|
|
66
|
+
},
|
|
67
|
+
isActive: (editor: EditorAPI) => {
|
|
68
|
+
return document.queryCommandState("bold");
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
function App() {
|
|
73
|
+
return (
|
|
74
|
+
<Editor
|
|
75
|
+
plugins={[customPlugin]}
|
|
76
|
+
onChange={(content) => console.log(content)}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Mit optionalen Plugins
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import React from "react";
|
|
86
|
+
import {
|
|
87
|
+
Editor,
|
|
88
|
+
defaultPlugins,
|
|
89
|
+
linkPlugin,
|
|
90
|
+
blockquotePlugin,
|
|
91
|
+
unorderedListPlugin,
|
|
92
|
+
orderedListPlugin,
|
|
93
|
+
} from "hendriks-rte";
|
|
94
|
+
|
|
95
|
+
function App() {
|
|
96
|
+
const allPlugins = [
|
|
97
|
+
...defaultPlugins,
|
|
98
|
+
linkPlugin,
|
|
99
|
+
blockquotePlugin,
|
|
100
|
+
unorderedListPlugin,
|
|
101
|
+
orderedListPlugin,
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<Editor
|
|
106
|
+
plugins={allPlugins}
|
|
107
|
+
onChange={(content) => console.log(content)}
|
|
108
|
+
/>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## API
|
|
114
|
+
|
|
115
|
+
### Editor Props
|
|
116
|
+
|
|
117
|
+
| Prop | Type | Beschreibung |
|
|
118
|
+
| ------------------ | ----------------------------------- | -------------------------------------------- |
|
|
119
|
+
| `initialContent` | `EditorContent?` | Initialer Editor-Inhalt |
|
|
120
|
+
| `onChange` | `(content: EditorContent) => void?` | Callback bei Änderungen |
|
|
121
|
+
| `plugins` | `Plugin[]?` | Array von Plugins (Standard: defaultPlugins) |
|
|
122
|
+
| `placeholder` | `string?` | Platzhalter-Text |
|
|
123
|
+
| `className` | `string?` | CSS-Klasse für Container |
|
|
124
|
+
| `toolbarClassName` | `string?` | CSS-Klasse für Toolbar |
|
|
125
|
+
| `editorClassName` | `string?` | CSS-Klasse für Editor |
|
|
126
|
+
|
|
127
|
+
### EditorContent
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
interface EditorContent {
|
|
131
|
+
blocks: EditorNode[];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
interface EditorNode {
|
|
135
|
+
type: string;
|
|
136
|
+
children?: EditorNode[];
|
|
137
|
+
text?: string;
|
|
138
|
+
attributes?: Record<string, string>;
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### EditorAPI
|
|
143
|
+
|
|
144
|
+
Die EditorAPI wird an Plugins übergeben und bietet folgende Methoden:
|
|
145
|
+
|
|
146
|
+
- `executeCommand(command: string, value?: string): boolean` - Führt einen Command aus
|
|
147
|
+
- `getSelection(): Selection | null` - Gibt die aktuelle Selection zurück
|
|
148
|
+
- `getContent(): EditorContent` - Gibt den aktuellen Content zurück
|
|
149
|
+
- `setContent(content: EditorContent): void` - Setzt den Content
|
|
150
|
+
- `insertBlock(type: string, attributes?: Record<string, string>): void` - Fügt einen Block ein
|
|
151
|
+
- `insertInline(type: string, attributes?: Record<string, string>): void` - Fügt ein Inline-Element ein
|
|
152
|
+
- `undo(): void` - Macht die letzte Aktion rückgängig
|
|
153
|
+
- `redo(): void` - Wiederholt die letzte Aktion
|
|
154
|
+
- `canUndo(): boolean` - Prüft, ob Undo möglich ist
|
|
155
|
+
- `canRedo(): boolean` - Prüft, ob Redo möglich ist
|
|
156
|
+
|
|
157
|
+
### Plugin Interface
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
interface Plugin {
|
|
161
|
+
name: string;
|
|
162
|
+
type: "inline" | "block" | "command";
|
|
163
|
+
command?: string;
|
|
164
|
+
renderButton?: (props: ButtonProps) => React.ReactElement;
|
|
165
|
+
execute?: (editor: EditorAPI) => void;
|
|
166
|
+
isActive?: (editor: EditorAPI) => boolean;
|
|
167
|
+
canExecute?: (editor: EditorAPI) => boolean;
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Standard-Plugins
|
|
172
|
+
|
|
173
|
+
- `boldPlugin` - Fett
|
|
174
|
+
- `italicPlugin` - Kursiv
|
|
175
|
+
- `underlinePlugin` - Unterstrichen
|
|
176
|
+
- `undoPlugin` - Rückgängig
|
|
177
|
+
- `redoPlugin` - Wiederholen
|
|
178
|
+
|
|
179
|
+
## Optionale Plugins
|
|
180
|
+
|
|
181
|
+
- `linkPlugin` - Links einfügen
|
|
182
|
+
- `blockquotePlugin` - Zitate
|
|
183
|
+
- `unorderedListPlugin` - Aufzählungsliste
|
|
184
|
+
- `orderedListPlugin` - Nummerierte Liste
|
|
185
|
+
|
|
186
|
+
## Plugin erstellen
|
|
187
|
+
|
|
188
|
+
### Beispiel: Einfaches Inline-Plugin
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
import { Plugin, EditorAPI, ButtonProps } from "hendriks-rte";
|
|
192
|
+
import { createInlinePlugin } from "hendriks-rte/plugins/base";
|
|
193
|
+
|
|
194
|
+
const myPlugin = createInlinePlugin(
|
|
195
|
+
"myPlugin",
|
|
196
|
+
"bold", // Command
|
|
197
|
+
"mdi:format-bold", // Icon-Name (wird intern als SVG gerendert)
|
|
198
|
+
"Mein Plugin" // Label
|
|
199
|
+
);
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Hinweis:** Icons werden intern als SVG gerendert. Du kannst auch eigene SVG-Icons in deinen Plugins verwenden.
|
|
203
|
+
|
|
204
|
+
### Beispiel: Komplexes Plugin
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
const customPlugin: Plugin = {
|
|
208
|
+
name: "custom",
|
|
209
|
+
type: "block",
|
|
210
|
+
renderButton: (props: ButtonProps) => (
|
|
211
|
+
<button onClick={props.onClick}>
|
|
212
|
+
{/* Verwende SVG-Icons oder Emojis */}
|
|
213
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">
|
|
214
|
+
<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" />
|
|
215
|
+
</svg>
|
|
216
|
+
</button>
|
|
217
|
+
),
|
|
218
|
+
execute: (editor: EditorAPI) => {
|
|
219
|
+
editor.insertBlock("div", { class: "custom-block" });
|
|
220
|
+
},
|
|
221
|
+
isActive: (editor: EditorAPI) => {
|
|
222
|
+
// Prüfe, ob Plugin aktiv ist
|
|
223
|
+
return false;
|
|
224
|
+
},
|
|
225
|
+
canExecute: (editor: EditorAPI) => {
|
|
226
|
+
// Prüfe, ob Plugin ausgeführt werden kann
|
|
227
|
+
return true;
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Styling
|
|
233
|
+
|
|
234
|
+
Der Editor kommt mit minimalem CSS. Du kannst die Styles überschreiben:
|
|
235
|
+
|
|
236
|
+
```css
|
|
237
|
+
.rte-container {
|
|
238
|
+
/* Container-Styles */
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.rte-toolbar {
|
|
242
|
+
/* Toolbar-Styles */
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.rte-toolbar-button {
|
|
246
|
+
/* Button-Styles */
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.rte-editor {
|
|
250
|
+
/* Editor-Styles */
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Entwicklung
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
# Dependencies installieren
|
|
258
|
+
npm install
|
|
259
|
+
|
|
260
|
+
# Build
|
|
261
|
+
npm run build
|
|
262
|
+
|
|
263
|
+
# Development mit Watch
|
|
264
|
+
npm run dev
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Lizenz
|
|
268
|
+
|
|
269
|
+
MIT
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface DropdownProps {
|
|
3
|
+
icon: string;
|
|
4
|
+
label: string;
|
|
5
|
+
options: Array<{
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
icon?: string;
|
|
9
|
+
color?: string;
|
|
10
|
+
preview?: string;
|
|
11
|
+
headingPreview?: string;
|
|
12
|
+
}>;
|
|
13
|
+
onSelect: (value: string) => void;
|
|
14
|
+
currentValue?: string;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare const Dropdown: React.FC<DropdownProps>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=Dropdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dropdown.d.ts","sourceRoot":"","sources":["../../src/components/Dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,UAAU,aAAa;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC3H,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAyF5C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../../src/components/Editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AASvE,OAAO,EAA4B,WAAW,EAAE,MAAM,UAAU,CAAC;AAmBjE,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAovBxC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { EditorAPI, Plugin } from "../types";
|
|
3
|
+
interface FloatingToolbarProps {
|
|
4
|
+
plugins: Plugin[];
|
|
5
|
+
editorAPI: EditorAPI;
|
|
6
|
+
editorElement: HTMLElement | null;
|
|
7
|
+
}
|
|
8
|
+
export declare const FloatingToolbar: React.FC<FloatingToolbarProps>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=FloatingToolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FloatingToolbar.d.ts","sourceRoot":"","sources":["../../src/components/FloatingToolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAe,SAAS,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAE1D,UAAU,oBAAoB;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,EAAE,WAAW,GAAG,IAAI,CAAC;CACrC;AAQD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAqM1D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconWrapper.d.ts","sourceRoot":"","sources":["../../src/components/IconWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,gBAAgB;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAElD,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface IconProps {
|
|
3
|
+
width?: number;
|
|
4
|
+
height?: number;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const BoldIcon: React.FC<IconProps>;
|
|
8
|
+
export declare const ItalicIcon: React.FC<IconProps>;
|
|
9
|
+
export declare const UnderlineIcon: React.FC<IconProps>;
|
|
10
|
+
export declare const UndoIcon: React.FC<IconProps>;
|
|
11
|
+
export declare const RedoIcon: React.FC<IconProps>;
|
|
12
|
+
export declare const ClearFormattingIcon: React.FC<IconProps>;
|
|
13
|
+
export declare const LinkIcon: React.FC<IconProps>;
|
|
14
|
+
export declare const QuoteIcon: React.FC<IconProps>;
|
|
15
|
+
export declare const BulletListIcon: React.FC<IconProps>;
|
|
16
|
+
export declare const NumberedListIcon: React.FC<IconProps>;
|
|
17
|
+
export declare const TextColorIcon: React.FC<IconProps>;
|
|
18
|
+
export declare const BackgroundColorIcon: React.FC<IconProps>;
|
|
19
|
+
export declare const HeadingIcon: React.FC<IconProps>;
|
|
20
|
+
export declare const FontSizeIcon: React.FC<IconProps>;
|
|
21
|
+
export declare const ImageIcon: React.FC<IconProps>;
|
|
22
|
+
export declare const CloseIcon: React.FC<IconProps>;
|
|
23
|
+
export declare const LoadingIcon: React.FC<IconProps>;
|
|
24
|
+
export declare const UploadIcon: React.FC<IconProps>;
|
|
25
|
+
export declare const Icon: React.FC<{
|
|
26
|
+
icon: string;
|
|
27
|
+
width?: number;
|
|
28
|
+
height?: number;
|
|
29
|
+
className?: string;
|
|
30
|
+
}>;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=Icons.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Icons.d.ts","sourceRoot":"","sources":["../../src/components/Icons.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,UAAU,SAAS;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAIxC,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAI1C,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAI7C,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAIxC,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAIxC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAInD,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAIxC,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAIzC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAI9C,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAIhD,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAI7C,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAInD,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAI3C,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAI5C,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAIzC,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAIzC,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAI3C,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CAI1C,CAAC;AAuBF,eAAO,MAAM,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAMhG,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { EditorAPI, Plugin } from "../types";
|
|
3
|
+
interface ToolbarProps {
|
|
4
|
+
plugins: Plugin[];
|
|
5
|
+
editorAPI: EditorAPI;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const Toolbar: React.FC<ToolbarProps>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=Toolbar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/components/Toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAe,SAAS,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAE1D,UAAU,YAAY;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CA+H1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import React$1 from 'react';
|
|
2
|
+
|
|
3
|
+
interface EditorNode {
|
|
4
|
+
type: string;
|
|
5
|
+
children?: EditorNode[];
|
|
6
|
+
text?: string;
|
|
7
|
+
attributes?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
interface EditorContent {
|
|
10
|
+
blocks: EditorNode[];
|
|
11
|
+
}
|
|
12
|
+
interface Plugin {
|
|
13
|
+
name: string;
|
|
14
|
+
type: 'inline' | 'block' | 'command';
|
|
15
|
+
command?: string;
|
|
16
|
+
renderButton?: (props: ButtonProps & {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}) => React.ReactElement;
|
|
19
|
+
execute?: (editor: EditorAPI, value?: string) => void;
|
|
20
|
+
isActive?: (editor: EditorAPI) => boolean;
|
|
21
|
+
canExecute?: (editor: EditorAPI) => boolean;
|
|
22
|
+
getCurrentValue?: (editor: EditorAPI) => string | undefined;
|
|
23
|
+
}
|
|
24
|
+
interface ButtonProps {
|
|
25
|
+
isActive: boolean;
|
|
26
|
+
onClick: () => void;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
icon?: string;
|
|
29
|
+
label?: string;
|
|
30
|
+
}
|
|
31
|
+
interface EditorAPI {
|
|
32
|
+
executeCommand: (command: string, value?: string) => boolean;
|
|
33
|
+
getSelection: () => Selection | null;
|
|
34
|
+
getContent: () => EditorContent;
|
|
35
|
+
setContent: (content: EditorContent) => void;
|
|
36
|
+
insertBlock: (type: string, attributes?: Record<string, string>) => void;
|
|
37
|
+
insertInline: (type: string, attributes?: Record<string, string>) => void;
|
|
38
|
+
undo: () => void;
|
|
39
|
+
redo: () => void;
|
|
40
|
+
canUndo: () => boolean;
|
|
41
|
+
canRedo: () => boolean;
|
|
42
|
+
importHtml: (htmlString: string) => EditorContent;
|
|
43
|
+
exportHtml: () => string;
|
|
44
|
+
clearFormatting: () => void;
|
|
45
|
+
clearTextColor: () => void;
|
|
46
|
+
clearBackgroundColor: () => void;
|
|
47
|
+
clearFontSize: () => void;
|
|
48
|
+
clearLinks: () => void;
|
|
49
|
+
}
|
|
50
|
+
interface CustomRenderer {
|
|
51
|
+
renderNode?: (node: EditorNode, children: React.ReactNode) => React.ReactElement | null;
|
|
52
|
+
renderMark?: (mark: string, attributes: Record<string, string>, children: React.ReactNode) => React.ReactElement | null;
|
|
53
|
+
}
|
|
54
|
+
interface EditorProps {
|
|
55
|
+
initialContent?: EditorContent;
|
|
56
|
+
onChange?: (content: EditorContent) => void;
|
|
57
|
+
plugins?: Plugin[];
|
|
58
|
+
placeholder?: string;
|
|
59
|
+
className?: string;
|
|
60
|
+
toolbarClassName?: string;
|
|
61
|
+
editorClassName?: string;
|
|
62
|
+
customLinkComponent?: React.ComponentType<{
|
|
63
|
+
href: string;
|
|
64
|
+
children: React.ReactNode;
|
|
65
|
+
[key: string]: any;
|
|
66
|
+
}>;
|
|
67
|
+
fontSizes?: number[];
|
|
68
|
+
colors?: string[];
|
|
69
|
+
headings?: string[];
|
|
70
|
+
customHeadingRenderer?: (level: string, children: React.ReactNode) => React.ReactElement;
|
|
71
|
+
customRenderer?: CustomRenderer;
|
|
72
|
+
onEditorAPIReady?: (api: EditorAPI) => void;
|
|
73
|
+
theme?: {
|
|
74
|
+
borderColor?: string;
|
|
75
|
+
borderRadius?: number;
|
|
76
|
+
toolbarBg?: string;
|
|
77
|
+
buttonHoverBg?: string;
|
|
78
|
+
contentBg?: string;
|
|
79
|
+
primaryColor?: string;
|
|
80
|
+
};
|
|
81
|
+
onImageUpload?: (file: File) => Promise<string>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
declare const Editor: React$1.FC<EditorProps>;
|
|
85
|
+
|
|
86
|
+
interface ToolbarProps {
|
|
87
|
+
plugins: Plugin[];
|
|
88
|
+
editorAPI: EditorAPI;
|
|
89
|
+
className?: string;
|
|
90
|
+
}
|
|
91
|
+
declare const Toolbar: React$1.FC<ToolbarProps>;
|
|
92
|
+
|
|
93
|
+
interface DropdownProps {
|
|
94
|
+
icon: string;
|
|
95
|
+
label: string;
|
|
96
|
+
options: Array<{
|
|
97
|
+
value: string;
|
|
98
|
+
label: string;
|
|
99
|
+
icon?: string;
|
|
100
|
+
color?: string;
|
|
101
|
+
preview?: string;
|
|
102
|
+
headingPreview?: string;
|
|
103
|
+
}>;
|
|
104
|
+
onSelect: (value: string) => void;
|
|
105
|
+
currentValue?: string;
|
|
106
|
+
disabled?: boolean;
|
|
107
|
+
}
|
|
108
|
+
declare const Dropdown: React$1.FC<DropdownProps>;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Standard-Plugins
|
|
112
|
+
*/
|
|
113
|
+
declare const boldPlugin: Plugin;
|
|
114
|
+
declare const italicPlugin: Plugin;
|
|
115
|
+
declare const underlinePlugin: Plugin;
|
|
116
|
+
declare const undoPlugin: Plugin;
|
|
117
|
+
declare const redoPlugin: Plugin;
|
|
118
|
+
/**
|
|
119
|
+
* Standard-Plugin-Liste
|
|
120
|
+
*/
|
|
121
|
+
declare const defaultPlugins: Plugin[];
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Link-Plugin mit verbesserter Funktionalität
|
|
125
|
+
*/
|
|
126
|
+
declare function createLinkPlugin(): Plugin;
|
|
127
|
+
declare const linkPlugin: Plugin;
|
|
128
|
+
/**
|
|
129
|
+
* Blockquote-Plugin
|
|
130
|
+
*/
|
|
131
|
+
declare const blockquotePlugin: Plugin;
|
|
132
|
+
/**
|
|
133
|
+
* Unordered List Plugin
|
|
134
|
+
*/
|
|
135
|
+
declare const unorderedListPlugin: Plugin;
|
|
136
|
+
/**
|
|
137
|
+
* Ordered List Plugin
|
|
138
|
+
*/
|
|
139
|
+
declare const orderedListPlugin: Plugin;
|
|
140
|
+
|
|
141
|
+
declare function createFontSizePlugin(fontSizes?: number[]): Plugin;
|
|
142
|
+
|
|
143
|
+
declare function createTextColorPlugin(colors?: string[]): Plugin;
|
|
144
|
+
declare function createBackgroundColorPlugin(colors?: string[]): Plugin;
|
|
145
|
+
|
|
146
|
+
declare function createHeadingsPlugin(headings?: string[]): Plugin;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Clear Formatting Plugin - Entfernt alle Formatierungen
|
|
150
|
+
*/
|
|
151
|
+
declare const clearFormattingPlugin: Plugin;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Image-Plugin mit URL-Eingabe und File-Upload
|
|
155
|
+
*/
|
|
156
|
+
declare function createImagePlugin(onImageUpload?: (file: File) => Promise<string>): Plugin;
|
|
157
|
+
|
|
158
|
+
declare function domToContent(element: HTMLElement): EditorContent;
|
|
159
|
+
declare function contentToDOM(content: EditorContent, container: HTMLElement, customLinkComponent?: React$1.ComponentType<{
|
|
160
|
+
href: string;
|
|
161
|
+
children: React$1.ReactNode;
|
|
162
|
+
[key: string]: any;
|
|
163
|
+
}>, customHeadingRenderer?: (level: string, children: React$1.ReactNode) => React$1.ReactElement): void;
|
|
164
|
+
declare function createEmptyContent(): EditorContent;
|
|
165
|
+
declare function htmlToContent(htmlString: string): EditorContent;
|
|
166
|
+
declare function contentToHTML(content: EditorContent): string;
|
|
167
|
+
|
|
168
|
+
declare class HistoryManager {
|
|
169
|
+
private history;
|
|
170
|
+
private currentIndex;
|
|
171
|
+
private maxHistorySize;
|
|
172
|
+
push(content: EditorContent): void;
|
|
173
|
+
undo(): EditorContent | null;
|
|
174
|
+
redo(): EditorContent | null;
|
|
175
|
+
canUndo(): boolean;
|
|
176
|
+
canRedo(): boolean;
|
|
177
|
+
getCurrent(): EditorContent | null;
|
|
178
|
+
reset(): void;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Liest die aktuelle Font-Size aus dem DOM an der Cursor-Position
|
|
183
|
+
*/
|
|
184
|
+
declare function getCurrentFontSize(editor: EditorAPI): string | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* Liest die aktuelle Textfarbe aus dem DOM an der Cursor-Position
|
|
187
|
+
*/
|
|
188
|
+
declare function getCurrentTextColor(editor: EditorAPI): string | undefined;
|
|
189
|
+
/**
|
|
190
|
+
* Liest die aktuelle Hintergrundfarbe aus dem DOM an der Cursor-Position
|
|
191
|
+
*/
|
|
192
|
+
declare function getCurrentBackgroundColor(editor: EditorAPI): string | undefined;
|
|
193
|
+
/**
|
|
194
|
+
* Liest das aktuelle Heading-Level aus dem DOM an der Cursor-Position
|
|
195
|
+
*/
|
|
196
|
+
declare function getCurrentHeading(editor: EditorAPI, availableHeadings: string[]): string | undefined;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Erhöht den Einrückungs-Level eines List-Items (Tab)
|
|
200
|
+
*/
|
|
201
|
+
declare function indentListItem(selection: Selection): boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Reduziert den Einrückungs-Level eines List-Items (Shift+Tab)
|
|
204
|
+
*/
|
|
205
|
+
declare function outdentListItem(selection: Selection): boolean;
|
|
206
|
+
|
|
207
|
+
export { Dropdown, Editor, HistoryManager, Toolbar, blockquotePlugin, boldPlugin, clearFormattingPlugin, contentToDOM, contentToHTML, createBackgroundColorPlugin, createEmptyContent, createFontSizePlugin, createHeadingsPlugin, createImagePlugin, createLinkPlugin, createTextColorPlugin, Editor as default, defaultPlugins, domToContent, getCurrentBackgroundColor, getCurrentFontSize, getCurrentHeading, getCurrentTextColor, htmlToContent, indentListItem, italicPlugin, linkPlugin, orderedListPlugin, outdentListItem, redoPlugin, underlinePlugin, undoPlugin, unorderedListPlugin };
|
|
208
|
+
export type { ButtonProps, CustomRenderer, EditorAPI, EditorContent, EditorNode, EditorProps, Plugin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,qBAAqB,CAAC"}
|