@overlap/rte 0.1.11 → 1.0.2
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 +45 -5
- package/dist/components/Dropdown.d.ts.map +1 -1
- package/dist/components/Editor.d.ts.map +1 -1
- package/dist/components/LinkTooltip.d.ts.map +1 -1
- package/dist/components/Toolbar.d.ts.map +1 -1
- package/dist/hooks/useEditorEvents.d.ts +4 -1
- package/dist/hooks/useEditorEvents.d.ts.map +1 -1
- package/dist/hooks/useEditorInit.d.ts.map +1 -1
- package/dist/index.d.ts +10 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +353 -151
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +353 -150
- package/dist/index.js.map +1 -1
- package/dist/plugins/image.d.ts +1 -1
- package/dist/plugins/image.d.ts.map +1 -1
- package/dist/plugins/linkDialog.d.ts.map +1 -1
- package/dist/plugins/optional.d.ts.map +1 -1
- package/dist/utils/autoLink.d.ts.map +1 -1
- package/dist/utils/content.d.ts +1 -0
- package/dist/utils/content.d.ts.map +1 -1
- package/dist/utils/sanitize.d.ts +6 -0
- package/dist/utils/sanitize.d.ts.map +1 -1
- package/dist/utils/settings.d.ts +1 -0
- package/dist/utils/settings.d.ts.map +1 -1
- package/package.json +1 -4
package/README.md
CHANGED
|
@@ -15,16 +15,25 @@ npm install @overlap/rte
|
|
|
15
15
|
- **Settings object** -- configure features with a single object instead of assembling plugins manually
|
|
16
16
|
- **Contenteditable-based** -- uses native browser editing for performance
|
|
17
17
|
- **Full formatting** -- bold, italic, underline, strikethrough, subscript, superscript, inline code
|
|
18
|
-
- **Block formats** -- headings (h1-h6), bullet lists, numbered lists, checkbox lists, blockquote, code block
|
|
18
|
+
- **Block formats** -- headings (h1-h6), bullet lists, numbered lists, checkbox lists, blockquote, code block, horizontal rule
|
|
19
19
|
- **Tables** -- insert, row/column operations, context menu
|
|
20
|
-
- **Images** -- upload via callback, URL insert, drag & drop, paste
|
|
21
|
-
- **Links** -- floating editor, advanced attributes, custom fields
|
|
22
|
-
- **Colors** -- text color and background color pickers
|
|
20
|
+
- **Images** -- upload via callback, URL insert, drag & drop, paste, alt text support
|
|
21
|
+
- **Links** -- floating editor, advanced attributes, custom fields, hover tooltip
|
|
22
|
+
- **Colors** -- text color and background color pickers with custom hex input
|
|
23
23
|
- **Font sizes** -- configurable size dropdown
|
|
24
24
|
- **Alignment** -- left, center, right, justify
|
|
25
25
|
- **Indent / Outdent** -- nested list support via Tab / Shift+Tab
|
|
26
|
-
- **Undo / Redo** -- full history management
|
|
26
|
+
- **Undo / Redo** -- full history management with cursor restoration
|
|
27
27
|
- **HTML import/export** -- `htmlToContent()` and `contentToHTML()`
|
|
28
|
+
- **Keyboard shortcuts** -- Cmd/Ctrl+B, I, U, E, Shift+X, Shift+7, Shift+8 and more
|
|
29
|
+
- **Markdown shortcuts** -- type `#`, `-`, `>`, `[]`, `---`, `` ``` `` to auto-format
|
|
30
|
+
- **Auto-linking** -- URLs are auto-detected and converted to links on Space/Enter
|
|
31
|
+
- **Read-only mode** -- `readOnly` prop disables editing and hides toolbars
|
|
32
|
+
- **Floating toolbar** -- appears on text selection with formatting options
|
|
33
|
+
- **Word/character count** -- optional `showWordCount` display
|
|
34
|
+
- **Max length** -- enforce character limit with `maxLength` prop
|
|
35
|
+
- **Focus/blur callbacks** -- `onFocus` / `onBlur` props
|
|
36
|
+
- **HTML sanitization** -- built-in XSS protection on paste, import, and JSON rendering
|
|
28
37
|
- **Theming** -- CSS variables + theme prop for brand colors
|
|
29
38
|
- **Lexical compatible** -- correctly parses and renders HTML generated by Lexical editors
|
|
30
39
|
- **TypeScript** -- fully typed, ships `.d.ts`
|
|
@@ -391,6 +400,11 @@ function MyEditor() {
|
|
|
391
400
|
| `onImageUpload` | `(file: File) => Promise<string>` | Image upload callback |
|
|
392
401
|
| `onEditorAPIReady` | `(api: EditorAPI) => void` | Callback when editor API is ready |
|
|
393
402
|
| `theme` | `object?` | Theme overrides (see Theming section) |
|
|
403
|
+
| `readOnly` | `boolean?` | When `true`, hides toolbars and disables editing |
|
|
404
|
+
| `onFocus` | `() => void` | Called when the editor receives focus |
|
|
405
|
+
| `onBlur` | `() => void` | Called when the editor loses focus |
|
|
406
|
+
| `maxLength` | `number?` | Maximum character count; prevents input beyond this limit |
|
|
407
|
+
| `showWordCount` | `boolean?` | Shows a word/character count bar below the editor |
|
|
394
408
|
|
|
395
409
|
---
|
|
396
410
|
|
|
@@ -417,6 +431,7 @@ Available via `onEditorAPIReady` callback or passed to plugin functions:
|
|
|
417
431
|
| `clearBackgroundColor()` | Remove background color |
|
|
418
432
|
| `clearFontSize()` | Remove font size |
|
|
419
433
|
| `clearLinks()` | Remove links (keep text) |
|
|
434
|
+
| `getTextStats()` | Get `{ characters, words }` count |
|
|
420
435
|
|
|
421
436
|
---
|
|
422
437
|
|
|
@@ -467,6 +482,7 @@ export { boldPlugin, italicPlugin, underlinePlugin, strikethroughPlugin };
|
|
|
467
482
|
export { subscriptPlugin, superscriptPlugin, codeInlinePlugin };
|
|
468
483
|
export { undoPlugin, redoPlugin, clearFormattingPlugin };
|
|
469
484
|
export { indentListItemPlugin, outdentListItemPlugin };
|
|
485
|
+
export { horizontalRulePlugin };
|
|
470
486
|
export { defaultPlugins };
|
|
471
487
|
|
|
472
488
|
// Plugin factories
|
|
@@ -481,6 +497,7 @@ export { tablePlugin };
|
|
|
481
497
|
// Utilities
|
|
482
498
|
export { htmlToContent, contentToHTML, contentToDOM, domToContent, createEmptyContent };
|
|
483
499
|
export { HistoryManager };
|
|
500
|
+
export { sanitizeHtml, isUrlSafe };
|
|
484
501
|
|
|
485
502
|
// Types
|
|
486
503
|
export { Plugin, EditorAPI, EditorContent, EditorNode, EditorProps, ButtonProps };
|
|
@@ -488,6 +505,29 @@ export { Plugin, EditorAPI, EditorContent, EditorNode, EditorProps, ButtonProps
|
|
|
488
505
|
|
|
489
506
|
---
|
|
490
507
|
|
|
508
|
+
## Security
|
|
509
|
+
|
|
510
|
+
The editor includes built-in XSS protection:
|
|
511
|
+
|
|
512
|
+
- **HTML sanitization** -- `htmlToContent()` automatically sanitizes incoming HTML, stripping `<script>`, `<iframe>`, event handlers (`onclick`, `onerror`, etc.), and `javascript:` URLs.
|
|
513
|
+
- **URL validation** -- `isUrlSafe(url)` is available as an export to validate URLs against a safe scheme allowlist. It is used internally for links, images, and auto-linking.
|
|
514
|
+
- **Paste protection** -- pasted HTML is sanitized before insertion.
|
|
515
|
+
- **Allowlist-based** -- the sanitizer uses a tag and attribute allowlist approach, removing dangerous elements (`<script>`, `<iframe>`, `<object>`, `<embed>`, `<form>`, `<template>`, `<video>`, `<audio>`, `<marquee>`, etc.) and filtering attributes that start with `on` or contain unsafe values.
|
|
516
|
+
|
|
517
|
+
```tsx
|
|
518
|
+
import { sanitizeHtml, isUrlSafe } from "@overlap/rte";
|
|
519
|
+
|
|
520
|
+
// Sanitize untrusted HTML
|
|
521
|
+
const clean = sanitizeHtml('<p>Hello</p><script>alert("xss")</script>');
|
|
522
|
+
|
|
523
|
+
// Validate a URL
|
|
524
|
+
if (isUrlSafe(userUrl)) {
|
|
525
|
+
// safe to use
|
|
526
|
+
}
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
---
|
|
530
|
+
|
|
491
531
|
## Development
|
|
492
532
|
|
|
493
533
|
```bash
|
|
@@ -1 +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;IACnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,
|
|
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;IACnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAsJ5C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../../src/components/Editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAYjF,OAAO,EAA4B,WAAW,EAAE,MAAM,UAAU,CAAC;AA4BjE,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"Editor.d.ts","sourceRoot":"","sources":["../../src/components/Editor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAYjF,OAAO,EAA4B,WAAW,EAAE,MAAM,UAAU,CAAC;AA4BjE,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAktBxC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkTooltip.d.ts","sourceRoot":"","sources":["../../src/components/LinkTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"LinkTooltip.d.ts","sourceRoot":"","sources":["../../src/components/LinkTooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAIxE,UAAU,gBAAgB;IACtB,aAAa,EAAE,WAAW,GAAG,IAAI,CAAC;CACrC;AAUD;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA4IlD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/components/Toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AACxE,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,
|
|
1
|
+
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/components/Toolbar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AACxE,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,CA6L1C,CAAC"}
|
|
@@ -8,6 +8,9 @@ interface UseEditorEventsOptions {
|
|
|
8
8
|
isUpdatingRef: {
|
|
9
9
|
current: boolean;
|
|
10
10
|
};
|
|
11
|
+
mountedRef: {
|
|
12
|
+
current: boolean;
|
|
13
|
+
};
|
|
11
14
|
notifyChange: (content: EditorContent) => void;
|
|
12
15
|
handleCheckboxKeyDown: (e: KeyboardEvent) => boolean;
|
|
13
16
|
handleCheckboxEnter: (e: KeyboardEvent) => boolean;
|
|
@@ -17,6 +20,6 @@ interface UseEditorEventsOptions {
|
|
|
17
20
|
/**
|
|
18
21
|
* Hook that sets up input and keydown event listeners on the editor.
|
|
19
22
|
*/
|
|
20
|
-
export declare function useEditorEvents({ editorRef, historyRef, isUpdatingRef, notifyChange, handleCheckboxKeyDown, handleCheckboxEnter, undo, redo, }: UseEditorEventsOptions): void;
|
|
23
|
+
export declare function useEditorEvents({ editorRef, historyRef, isUpdatingRef, mountedRef, notifyChange, handleCheckboxKeyDown, handleCheckboxEnter, undo, redo, }: UseEditorEventsOptions): void;
|
|
21
24
|
export {};
|
|
22
25
|
//# sourceMappingURL=useEditorEvents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditorEvents.d.ts","sourceRoot":"","sources":["../../src/hooks/useEditorEvents.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAOlD,UAAU,sB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U,EACV,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,qBAAqB,GACxB,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"useEditorInit.d.ts","sourceRoot":"","sources":["../../src/hooks/useEditorInit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,UAAU,oBAAoB;IAC1B,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAClD,UAAU,EAAE;QAAE,OAAO,EAAE,cAAc,CAAA;KAAE,CAAC;IACxC,aAAa,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IACpC,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B,YAAY,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/C,mBAAmB,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;QACtC,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;QAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KAC1B,CAAC,CAAC;IACH,qBAAqB,CAAC,EAAE,CACpB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,KAAK,CAAC,SAAS,KACxB,KAAK,CAAC,SAAS,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAC1B,SAAS,EACT,UAAU,EACV,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,qBAAqB,GACxB,EAAE,oBAAoB,QAwEtB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -75,6 +75,7 @@ interface EditorSettings {
|
|
|
75
75
|
numberedList?: boolean;
|
|
76
76
|
quote?: boolean;
|
|
77
77
|
codeBlock?: boolean;
|
|
78
|
+
horizontalRule?: boolean;
|
|
78
79
|
check?: boolean;
|
|
79
80
|
/** Heading levels to enable, e.g. ["h1", "h2", "h3"] */
|
|
80
81
|
typography?: string[];
|
|
@@ -287,7 +288,7 @@ declare function createFontSizePlugin(fontSizes?: number[]): Plugin;
|
|
|
287
288
|
declare function createHeadingsPlugin(headings?: string[]): Plugin;
|
|
288
289
|
|
|
289
290
|
/**
|
|
290
|
-
* Image
|
|
291
|
+
* Image plugin with URL input and file upload support.
|
|
291
292
|
*/
|
|
292
293
|
declare function createImagePlugin(onImageUpload?: (file: File) => Promise<string>): Plugin;
|
|
293
294
|
|
|
@@ -346,6 +347,7 @@ declare function contentToHTML(content: EditorContent): string;
|
|
|
346
347
|
/**
|
|
347
348
|
* Converts an HTML string to EditorContent.
|
|
348
349
|
* Supports Lexical, GitHub, and standard HTML formats.
|
|
350
|
+
* Sanitizes HTML before parsing to prevent XSS.
|
|
349
351
|
*/
|
|
350
352
|
declare function htmlToContent(htmlString: string): EditorContent;
|
|
351
353
|
|
|
@@ -426,6 +428,12 @@ declare function getCurrentHeading(editor: EditorAPI, availableHeadings: string[
|
|
|
426
428
|
* Uses an allowlist approach to strip dangerous elements and attributes
|
|
427
429
|
* from pasted/imported HTML before it enters the editor.
|
|
428
430
|
*/
|
|
431
|
+
/**
|
|
432
|
+
* Check if a URL is safe to set as href/src.
|
|
433
|
+
* Blocks javascript:, data:, vbscript:, and unknown schemes.
|
|
434
|
+
* Strips control characters before checking.
|
|
435
|
+
*/
|
|
436
|
+
declare function isUrlSafe(url: string): boolean;
|
|
429
437
|
/**
|
|
430
438
|
* Sanitize an HTML string by stripping dangerous tags and attributes.
|
|
431
439
|
*
|
|
@@ -455,5 +463,5 @@ declare function findClosestCheckboxList(element: HTMLElement): HTMLElement | nu
|
|
|
455
463
|
*/
|
|
456
464
|
declare function ensureAllCheckboxes(editor: HTMLElement): void;
|
|
457
465
|
|
|
458
|
-
export { Dropdown, Editor, FloatingToolbar, 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, horizontalRulePlugin, htmlToContent, indentListItem, indentListItemPlugin, isCheckboxList, italicPlugin, linkPlugin, orderedListPlugin, outdentListItem, outdentListItemPlugin, redoPlugin, restoreSerializedSelection, sanitizeHtml, serializeSelection, strikethroughPlugin, subscriptPlugin, superscriptPlugin, tablePlugin, underlinePlugin, undoPlugin, unorderedListPlugin };
|
|
466
|
+
export { Dropdown, Editor, FloatingToolbar, 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, horizontalRulePlugin, htmlToContent, indentListItem, indentListItemPlugin, isCheckboxList, isUrlSafe, italicPlugin, linkPlugin, orderedListPlugin, outdentListItem, outdentListItemPlugin, redoPlugin, restoreSerializedSelection, sanitizeHtml, serializeSelection, strikethroughPlugin, subscriptPlugin, superscriptPlugin, tablePlugin, underlinePlugin, undoPlugin, unorderedListPlugin };
|
|
459
467
|
export type { AdvancedLinkOptions, BlockFormatOptions, BuildPluginsOptions, ButtonProps, CustomRenderer, EditorAPI, EditorContent, EditorNode, EditorProps, EditorSettings, HistoryEntry, LinkCustomField, Plugin, SelectionPoint, SelectionState };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,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,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,SAAS,CAAC;AAGxB,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG/D,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AACnF,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrE,cAAc,yBAAyB,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
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