@overlap/rte 0.1.8 → 0.1.9

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.
@@ -1 +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;AAwBjE,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAukBxC,CAAC"}
1
+ {"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../../src/components/Editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAUvE,OAAO,EAA4B,WAAW,EAAE,MAAM,UAAU,CAAC;AAwBjE,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAilBxC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -17,6 +17,107 @@ interface DropdownProps {
17
17
  }
18
18
  declare const Dropdown: React$1.FC<DropdownProps>;
19
19
 
20
+ /**
21
+ * Describes an additional field injected into the link dialog.
22
+ * This allows platform-specific extensions (e.g. page reference, URL extras)
23
+ * without baking them into the core RTE.
24
+ */
25
+ interface LinkCustomField {
26
+ /** Unique identifier (used as key in LinkData.custom) */
27
+ key: string;
28
+ /** Display label */
29
+ label: string;
30
+ /** Input placeholder */
31
+ placeholder?: string;
32
+ /** The HTML attribute to read/write on the <a> element (e.g. "data-page-ref") */
33
+ dataAttribute: string;
34
+ /** If true, this field's value is appended to the href when saving. */
35
+ appendToHref?: boolean;
36
+ /** If true, the URL input is disabled when this field has a value. */
37
+ disablesUrl?: boolean;
38
+ }
39
+ interface AdvancedLinkOptions {
40
+ /** Show "Open in new tab" checkbox. Defaults to true. */
41
+ enableTarget?: boolean;
42
+ /** Additional custom fields rendered in the advanced section. */
43
+ customFields?: LinkCustomField[];
44
+ }
45
+ /**
46
+ * Creates an advanced link plugin with a floating dialog.
47
+ *
48
+ * Core features (always available):
49
+ * - URL input
50
+ * - "Open in new tab" checkbox (enableTarget)
51
+ * - Cmd/Ctrl+Click → open link in new tab
52
+ * - Click on link → edit it inline
53
+ *
54
+ * Platform-specific fields (injected via `customFields`):
55
+ * - Each field is rendered in the "Advanced" section
56
+ * - Values are stored as data-attributes on the <a> element
57
+ * - `appendToHref` fields have their value appended to the href
58
+ * - `disablesUrl` fields disable the URL input when they have a value
59
+ */
60
+ declare function createAdvancedLinkPlugin(options?: AdvancedLinkOptions): Plugin;
61
+ /** Pre-built link plugin with just target enabled (no custom fields). */
62
+ declare const advancedLinkPlugin: Plugin;
63
+
64
+ interface EditorSettings {
65
+ format?: {
66
+ bold?: boolean;
67
+ italic?: boolean;
68
+ underline?: boolean;
69
+ strikethrough?: boolean;
70
+ code?: boolean;
71
+ subscript?: boolean;
72
+ superscript?: boolean;
73
+ bulletList?: boolean;
74
+ numberedList?: boolean;
75
+ quote?: boolean;
76
+ codeBlock?: boolean;
77
+ check?: boolean;
78
+ /** Heading levels to enable, e.g. ["h1", "h2", "h3"] */
79
+ typography?: string[];
80
+ /** Color palette for text color, e.g. ["#000", "#ff0000"] */
81
+ colors?: string[];
82
+ /** Enable font size dropdown */
83
+ fontSize?: boolean;
84
+ /** Alignment options, e.g. ["left", "center", "right", "justify", "indent", "outdent"] */
85
+ alignment?: string[];
86
+ };
87
+ link?: {
88
+ external?: boolean;
89
+ internal?: boolean;
90
+ };
91
+ table?: {
92
+ enabled?: boolean;
93
+ };
94
+ image?: {
95
+ enabled?: boolean;
96
+ };
97
+ }
98
+ /** Default: everything enabled. */
99
+ declare const defaultEditorSettings: EditorSettings;
100
+ interface BuildPluginsOptions {
101
+ /** Callback for image uploads (required when image.enabled is true). */
102
+ onImageUpload?: (file: File) => Promise<string>;
103
+ /** Custom fields for the advanced link dialog (e.g. urlExtra, pageRef). */
104
+ linkCustomFields?: LinkCustomField[];
105
+ /** Custom font sizes for the font size dropdown. */
106
+ fontSizes?: number[];
107
+ }
108
+ /**
109
+ * Builds a Plugin[] array from an EditorSettings object.
110
+ *
111
+ * Usage:
112
+ * ```ts
113
+ * const plugins = buildPluginsFromSettings(settings, {
114
+ * onImageUpload: handleUpload,
115
+ * linkCustomFields: [{ key: 'urlExtra', ... }],
116
+ * });
117
+ * ```
118
+ */
119
+ declare function buildPluginsFromSettings(settings?: EditorSettings, options?: BuildPluginsOptions): Plugin[];
120
+
20
121
  interface EditorNode {
21
122
  type: string;
22
123
  children?: EditorNode[];
@@ -98,6 +199,8 @@ interface EditorProps {
98
199
  primaryColor?: string;
99
200
  };
100
201
  onImageUpload?: (file: File) => Promise<string>;
202
+ settings?: EditorSettings;
203
+ settingsOptions?: BuildPluginsOptions;
101
204
  }
102
205
 
103
206
  declare const Editor: React$1.FC<EditorProps>;
@@ -110,7 +213,7 @@ interface ToolbarProps {
110
213
  declare const Toolbar: React$1.FC<ToolbarProps>;
111
214
 
112
215
  /**
113
- * Standard-Plugins
216
+ * Standard Plugins
114
217
  */
115
218
  declare const boldPlugin: Plugin;
116
219
  declare const italicPlugin: Plugin;
@@ -122,24 +225,32 @@ declare const codeInlinePlugin: Plugin;
122
225
  declare const undoPlugin: Plugin;
123
226
  declare const redoPlugin: Plugin;
124
227
  /**
125
- * Indent List Item Plugin (Tab für Unterliste)
228
+ * Indent List Item Plugin
126
229
  */
127
230
  declare const indentListItemPlugin: Plugin;
128
231
  /**
129
- * Outdent List Item Plugin (Shift+Tab)
232
+ * Outdent List Item Plugin
130
233
  */
131
234
  declare const outdentListItemPlugin: Plugin;
132
235
 
133
236
  declare const defaultPlugins: Plugin[];
134
237
 
238
+ interface BlockFormatOptions {
239
+ bulletList?: boolean;
240
+ numberedList?: boolean;
241
+ quote?: boolean;
242
+ codeBlock?: boolean;
243
+ check?: boolean;
244
+ }
135
245
  /**
136
246
  * Creates a Block Format plugin that combines headings, lists, and quote in a dropdown.
137
247
  * @param headings - Array of heading levels (e.g. ["h1", "h2", "h3"])
248
+ * @param blockOptions - Toggle individual block types (bulletList, numberedList, quote, check, codeBlock)
138
249
  */
139
- declare function createBlockFormatPlugin(headings?: string[]): Plugin;
250
+ declare function createBlockFormatPlugin(headings?: string[], blockOptions?: BlockFormatOptions): Plugin;
140
251
 
141
252
  /**
142
- * Clear Formatting Plugin - Entfernt alle Formatierungen
253
+ * Clear Formatting Plugin - Removes all formatting
143
254
  */
144
255
  declare const clearFormattingPlugin: Plugin;
145
256
 
@@ -156,7 +267,7 @@ declare function createHeadingsPlugin(headings?: string[]): Plugin;
156
267
  declare function createImagePlugin(onImageUpload?: (file: File) => Promise<string>): Plugin;
157
268
 
158
269
  /**
159
- * Link-Plugin mit verbesserter Funktionalität
270
+ * Link plugin with improved functionality
160
271
  */
161
272
  declare function createLinkPlugin(): Plugin;
162
273
  declare const linkPlugin: Plugin;
@@ -186,21 +297,6 @@ declare const TableContextMenuProvider: React$1.FC<{
186
297
  children: React$1.ReactNode;
187
298
  }>;
188
299
 
189
- interface AdvancedLinkOptions {
190
- enablePageRef?: boolean;
191
- enableTarget?: boolean;
192
- enableRel?: boolean;
193
- enableTitle?: boolean;
194
- enableUrlExtra?: boolean;
195
- }
196
- /**
197
- * Creates an advanced link plugin with a floating dialog.
198
- * Supports URL, target, rel, title, page reference, and URL extra.
199
- */
200
- declare function createAdvancedLinkPlugin(options?: AdvancedLinkOptions): Plugin;
201
- /** Pre-built advanced link plugin with target + rel + title enabled */
202
- declare const advancedLinkPlugin: Plugin;
203
-
204
300
  /**
205
301
  * Converts a DOM element (editor root) to EditorContent JSON.
206
302
  * Supports own format, Lexical HTML, and GitHub HTML.
@@ -242,11 +338,11 @@ declare class HistoryManager {
242
338
  }
243
339
 
244
340
  /**
245
- * Erhöht den Einrückungs-Level eines List-Items (Tab)
341
+ * Increases the indent level of a list item (Tab)
246
342
  */
247
343
  declare function indentListItem(selection: Selection): boolean;
248
344
  /**
249
- * Reduziert den Einrückungs-Level eines List-Items (Shift+Tab)
345
+ * Decreases the indent level of a list item (Shift+Tab)
250
346
  */
251
347
  declare function outdentListItem(selection: Selection): boolean;
252
348
 
@@ -255,15 +351,15 @@ declare function outdentListItem(selection: Selection): boolean;
255
351
  */
256
352
  declare function getCurrentFontSize(editor: EditorAPI): string | undefined;
257
353
  /**
258
- * Liest die aktuelle Textfarbe aus dem DOM an der Cursor-Position
354
+ * Reads the current text color from the DOM at the cursor position
259
355
  */
260
356
  declare function getCurrentTextColor(editor: EditorAPI): string | undefined;
261
357
  /**
262
- * Liest die aktuelle Hintergrundfarbe aus dem DOM an der Cursor-Position
358
+ * Reads the current background color from the DOM at the cursor position
263
359
  */
264
360
  declare function getCurrentBackgroundColor(editor: EditorAPI): string | undefined;
265
361
  /**
266
- * Liest das aktuelle Heading-Level aus dem DOM an der Cursor-Position
362
+ * Reads the current heading level from the DOM at the cursor position
267
363
  */
268
364
  declare function getCurrentHeading(editor: EditorAPI, availableHeadings: string[]): string | undefined;
269
365
 
@@ -288,5 +384,5 @@ declare function findClosestCheckboxList(element: HTMLElement): HTMLElement | nu
288
384
  */
289
385
  declare function ensureAllCheckboxes(editor: HTMLElement): void;
290
386
 
291
- export { Dropdown, Editor, HistoryManager, TableContextMenuProvider, Toolbar, advancedLinkPlugin, alignmentPlugin, blockquotePlugin, boldPlugin, clearFormattingPlugin, codeInlinePlugin, contentToDOM, contentToHTML, createAdvancedLinkPlugin, createAlignmentPlugin, createBackgroundColorPlugin, createBlockFormatPlugin, createEmptyContent, createFontSizePlugin, createHeadingsPlugin, createImagePlugin, createLinkPlugin, createTextColorPlugin, Editor as default, defaultPlugins, domToContent, ensureAllCheckboxes, findClosestCheckboxList, getCurrentBackgroundColor, getCurrentFontSize, getCurrentHeading, getCurrentTextColor, htmlToContent, indentListItem, indentListItemPlugin, isCheckboxList, italicPlugin, linkPlugin, orderedListPlugin, outdentListItem, outdentListItemPlugin, redoPlugin, strikethroughPlugin, subscriptPlugin, superscriptPlugin, tablePlugin, underlinePlugin, undoPlugin, unorderedListPlugin };
292
- export type { ButtonProps, CustomRenderer, EditorAPI, EditorContent, EditorNode, EditorProps, Plugin };
387
+ export { Dropdown, Editor, HistoryManager, TableContextMenuProvider, Toolbar, advancedLinkPlugin, alignmentPlugin, blockquotePlugin, boldPlugin, buildPluginsFromSettings, clearFormattingPlugin, codeInlinePlugin, contentToDOM, contentToHTML, createAdvancedLinkPlugin, createAlignmentPlugin, createBackgroundColorPlugin, createBlockFormatPlugin, createEmptyContent, createFontSizePlugin, createHeadingsPlugin, createImagePlugin, createLinkPlugin, createTextColorPlugin, Editor as default, defaultEditorSettings, defaultPlugins, domToContent, ensureAllCheckboxes, findClosestCheckboxList, getCurrentBackgroundColor, getCurrentFontSize, getCurrentHeading, getCurrentTextColor, htmlToContent, indentListItem, indentListItemPlugin, isCheckboxList, italicPlugin, linkPlugin, orderedListPlugin, outdentListItem, outdentListItemPlugin, redoPlugin, strikethroughPlugin, subscriptPlugin, superscriptPlugin, tablePlugin, underlinePlugin, undoPlugin, unorderedListPlugin };
388
+ export type { AdvancedLinkOptions, BlockFormatOptions, BuildPluginsOptions, ButtonProps, CustomRenderer, EditorAPI, EditorContent, EditorNode, EditorProps, EditorSettings, LinkCustomField, Plugin };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,cAAc,WAAW,CAAC;AAC1B,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAq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