@overlap/rte 0.1.1 → 0.1.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 +62 -68
- package/dist/components/Editor.d.ts.map +1 -1
- package/dist/components/Icons.d.ts +3 -1
- package/dist/components/Icons.d.ts.map +1 -1
- package/dist/index.d.ts +59 -45
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +470 -197
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +472 -196
- package/dist/index.js.map +1 -1
- package/dist/plugins/blockFormat.d.ts +7 -0
- package/dist/plugins/blockFormat.d.ts.map +1 -0
- package/dist/plugins/headings.d.ts +1 -1
- package/dist/plugins/headings.d.ts.map +1 -1
- package/dist/plugins/index.d.ts +8 -2
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/listIndent.d.ts +10 -0
- package/dist/plugins/listIndent.d.ts.map +1 -0
- package/dist/plugins/optional.d.ts +1 -1
- package/dist/plugins/optional.d.ts.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +17 -5
- package/src/components/Editor.tsx +92 -49
- package/src/components/Icons.tsx +306 -77
- package/src/index.ts +18 -18
- package/src/plugins/blockFormat.tsx +194 -0
- package/src/plugins/headings.tsx +39 -28
- package/src/plugins/index.tsx +161 -0
- package/src/plugins/listIndent.tsx +90 -0
- package/src/plugins/optional.tsx +216 -194
- package/src/types.ts +3 -0
- package/src/plugins/index.ts +0 -54
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Plugin } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Erstellt ein Block-Format-Plugin, das Headlines, Listen und Quote in einem Dropdown kombiniert
|
|
4
|
+
* @param headings - Array von Heading-Levels (z.B. ["h1", "h2", "h3"])
|
|
5
|
+
*/
|
|
6
|
+
export declare function createBlockFormatPlugin(headings?: string[]): Plugin;
|
|
7
|
+
//# sourceMappingURL=blockFormat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockFormat.d.ts","sourceRoot":"","sources":["../../src/plugins/blockFormat.tsx"],"names":[],"mappings":"AACA,OAAO,EAA0B,MAAM,EAAE,MAAM,UAAU,CAAC;AAa1D;;;GAGG;AACH,wBAAgB,uBAAuB,CACnC,QAAQ,GAAE,MAAM,EAAoB,GACrC,MAAM,CA6KR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headings.d.ts","sourceRoot":"","sources":["../../src/plugins/headings.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"headings.d.ts","sourceRoot":"","sources":["../../src/plugins/headings.tsx"],"names":[],"mappings":"AACA,OAAO,EAA0B,MAAM,EAAE,MAAM,UAAU,CAAC;AAc1D,wBAAgB,oBAAoB,CAChC,QAAQ,GAAE,MAAM,EAAoB,GACrC,MAAM,CAqER"}
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from
|
|
1
|
+
import { Plugin } from "../types";
|
|
2
2
|
/**
|
|
3
3
|
* Standard-Plugins
|
|
4
4
|
*/
|
|
@@ -8,7 +8,13 @@ export declare const underlinePlugin: Plugin;
|
|
|
8
8
|
export declare const undoPlugin: Plugin;
|
|
9
9
|
export declare const redoPlugin: Plugin;
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Indent List Item Plugin (Tab für Unterliste)
|
|
12
12
|
*/
|
|
13
|
+
declare const indentListItemPlugin: Plugin;
|
|
14
|
+
/**
|
|
15
|
+
* Outdent List Item Plugin (Shift+Tab)
|
|
16
|
+
*/
|
|
17
|
+
declare const outdentListItemPlugin: Plugin;
|
|
18
|
+
export { indentListItemPlugin, outdentListItemPlugin };
|
|
13
19
|
export declare const defaultPlugins: Plugin[];
|
|
14
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAA0B,MAAM,EAAE,MAAM,UAAU,CAAC;AAO1D;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,MAKxB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,MAK1B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,MAK7B,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,MAKxB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,MAKxB,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,oBAAoB,EAAE,MAmC3B,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,qBAAqB,EAAE,MA2C5B,CAAC;AAGF,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,CAAC;AAevD,eAAO,MAAM,cAAc,EAAE,MAAM,EAUlC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Plugin } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Indent List Item Plugin (Tab für Unterliste)
|
|
4
|
+
*/
|
|
5
|
+
export declare const indentListItemPlugin: Plugin;
|
|
6
|
+
/**
|
|
7
|
+
* Outdent List Item Plugin (Shift+Tab)
|
|
8
|
+
*/
|
|
9
|
+
export declare const outdentListItemPlugin: Plugin;
|
|
10
|
+
//# sourceMappingURL=listIndent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listIndent.d.ts","sourceRoot":"","sources":["../../src/plugins/listIndent.tsx"],"names":[],"mappings":"AACA,OAAO,EAA0B,MAAM,EAAE,MAAM,UAAU,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAmClC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,MA2CnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optional.d.ts","sourceRoot":"","sources":["../../src/plugins/optional.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"optional.d.ts","sourceRoot":"","sources":["../../src/plugins/optional.tsx"],"names":[],"mappings":"AACA,OAAO,EAA0B,MAAM,EAAE,MAAM,UAAU,CAAC;AAE1D;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CA+FzC;AAED,eAAO,MAAM,UAAU,QAAqB,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MA0D9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAiCjC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAiC/B,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -44,6 +44,8 @@ export interface EditorAPI {
|
|
|
44
44
|
clearBackgroundColor: () => void;
|
|
45
45
|
clearFontSize: () => void;
|
|
46
46
|
clearLinks: () => void;
|
|
47
|
+
indentListItem: () => void;
|
|
48
|
+
outdentListItem: () => void;
|
|
47
49
|
}
|
|
48
50
|
export interface CustomRenderer {
|
|
49
51
|
renderNode?: (node: EditorNode, children: React.ReactNode) => React.ReactElement | null;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,UAAU,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,E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;IAEzF,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC,gBAAgB,CAAC,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,IAAI,CAAC;IAE5C,KAAK,CAAC,EAAE;QACN,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IAEF,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACjD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@overlap/rte",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A lightweight, extensible Rich Text Editor for React",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "rollup -c",
|
|
15
15
|
"dev": "rollup -c -w",
|
|
16
|
-
"prepublishOnly": "npm run build"
|
|
16
|
+
"prepublishOnly": "npm run build",
|
|
17
|
+
"bump": "node tools/scripts/bumpVersion.mjs",
|
|
18
|
+
"publish:package": "node tools/scripts/publish.mjs"
|
|
17
19
|
},
|
|
18
20
|
"keywords": [
|
|
19
21
|
"react",
|
|
@@ -25,7 +27,10 @@
|
|
|
25
27
|
"author": "Almir Nakicevic <a.nakicevic@overlap.at>",
|
|
26
28
|
"repository": {
|
|
27
29
|
"type": "git",
|
|
28
|
-
"url": "https://github.com/overlap-dev/rte"
|
|
30
|
+
"url": "git+https://github.com/overlap-dev/rte.git"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
29
34
|
},
|
|
30
35
|
"peerDependencies": {
|
|
31
36
|
"react": ">=18.0.0",
|
|
@@ -44,5 +49,12 @@
|
|
|
44
49
|
"rollup-plugin-copy": "^3.5.0",
|
|
45
50
|
"rollup-plugin-dts": "^6.1.0",
|
|
46
51
|
"typescript": "^5.3.3"
|
|
47
|
-
}
|
|
48
|
-
|
|
52
|
+
},
|
|
53
|
+
"directories": {
|
|
54
|
+
"example": "example"
|
|
55
|
+
},
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "https://github.com/overlap-dev/rte/issues"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://github.com/overlap-dev/rte#readme"
|
|
60
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
2
|
import { defaultPlugins } from "../plugins";
|
|
3
|
+
import { createBlockFormatPlugin } from "../plugins/blockFormat";
|
|
3
4
|
import {
|
|
4
5
|
createBackgroundColorPlugin,
|
|
5
6
|
createTextColorPlugin,
|
|
6
7
|
} from "../plugins/colors";
|
|
7
8
|
import { createFontSizePlugin } from "../plugins/fontSize";
|
|
8
|
-
import { createHeadingsPlugin } from "../plugins/headings";
|
|
9
9
|
import { createImagePlugin } from "../plugins/image";
|
|
10
10
|
import { EditorAPI, EditorContent, EditorProps } from "../types";
|
|
11
11
|
import {
|
|
@@ -56,8 +56,18 @@ export const Editor: React.FC<EditorProps> = ({
|
|
|
56
56
|
allPlugins.push(createBackgroundColorPlugin(colors));
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
// BlockFormat Plugin ist bereits in defaultPlugins enthalten
|
|
60
|
+
// Wenn custom headings angegeben sind, ersetze das Standard-Plugin
|
|
59
61
|
if (headings && headings.length > 0) {
|
|
60
|
-
|
|
62
|
+
// Entferne das Standard-BlockFormat-Plugin
|
|
63
|
+
const blockFormatIndex = allPlugins.findIndex(
|
|
64
|
+
(p) => p.name === "blockFormat"
|
|
65
|
+
);
|
|
66
|
+
if (blockFormatIndex !== -1) {
|
|
67
|
+
allPlugins.splice(blockFormatIndex, 1);
|
|
68
|
+
}
|
|
69
|
+
// Füge das Plugin mit custom Headlines hinzu
|
|
70
|
+
allPlugins.push(createBlockFormatPlugin(headings));
|
|
61
71
|
}
|
|
62
72
|
|
|
63
73
|
allPlugins.push(createImagePlugin(onImageUpload));
|
|
@@ -78,7 +88,8 @@ export const Editor: React.FC<EditorProps> = ({
|
|
|
78
88
|
);
|
|
79
89
|
|
|
80
90
|
const restoreSelection = useCallback((editor: HTMLElement) => {
|
|
81
|
-
if (typeof window ===
|
|
91
|
+
if (typeof window === "undefined" || typeof document === "undefined")
|
|
92
|
+
return;
|
|
82
93
|
const range = document.createRange();
|
|
83
94
|
const selection = window.getSelection();
|
|
84
95
|
|
|
@@ -310,7 +321,7 @@ export const Editor: React.FC<EditorProps> = ({
|
|
|
310
321
|
executeCommand,
|
|
311
322
|
|
|
312
323
|
getSelection: (): Selection | null => {
|
|
313
|
-
if (typeof window ===
|
|
324
|
+
if (typeof window === "undefined") return null;
|
|
314
325
|
return window.getSelection();
|
|
315
326
|
},
|
|
316
327
|
|
|
@@ -547,6 +558,46 @@ export const Editor: React.FC<EditorProps> = ({
|
|
|
547
558
|
}, 0);
|
|
548
559
|
}
|
|
549
560
|
},
|
|
561
|
+
|
|
562
|
+
indentListItem: (): void => {
|
|
563
|
+
const editor = editorRef.current;
|
|
564
|
+
if (!editor) return;
|
|
565
|
+
|
|
566
|
+
const selection = window.getSelection();
|
|
567
|
+
if (selection && selection.rangeCount > 0) {
|
|
568
|
+
const currentContent = domToContent(editor);
|
|
569
|
+
historyRef.current.push(currentContent);
|
|
570
|
+
|
|
571
|
+
indentListItem(selection);
|
|
572
|
+
|
|
573
|
+
setTimeout(() => {
|
|
574
|
+
if (editor) {
|
|
575
|
+
const content = domToContent(editor);
|
|
576
|
+
notifyChange(content);
|
|
577
|
+
}
|
|
578
|
+
}, 0);
|
|
579
|
+
}
|
|
580
|
+
},
|
|
581
|
+
|
|
582
|
+
outdentListItem: (): void => {
|
|
583
|
+
const editor = editorRef.current;
|
|
584
|
+
if (!editor) return;
|
|
585
|
+
|
|
586
|
+
const selection = window.getSelection();
|
|
587
|
+
if (selection && selection.rangeCount > 0) {
|
|
588
|
+
const currentContent = domToContent(editor);
|
|
589
|
+
historyRef.current.push(currentContent);
|
|
590
|
+
|
|
591
|
+
outdentListItem(selection);
|
|
592
|
+
|
|
593
|
+
setTimeout(() => {
|
|
594
|
+
if (editor) {
|
|
595
|
+
const content = domToContent(editor);
|
|
596
|
+
notifyChange(content);
|
|
597
|
+
}
|
|
598
|
+
}, 0);
|
|
599
|
+
}
|
|
600
|
+
},
|
|
550
601
|
};
|
|
551
602
|
}, [
|
|
552
603
|
notifyChange,
|
|
@@ -599,62 +650,54 @@ export const Editor: React.FC<EditorProps> = ({
|
|
|
599
650
|
const isModifierPressed = e.metaKey || e.ctrlKey;
|
|
600
651
|
|
|
601
652
|
if (e.key === "Tab" && !isModifierPressed && !e.altKey) {
|
|
653
|
+
// Immer preventDefault aufrufen (wie Lexical), damit Tab den Fokus nicht aus dem Editor entfernt
|
|
654
|
+
e.preventDefault();
|
|
655
|
+
e.stopPropagation();
|
|
656
|
+
e.stopImmediatePropagation();
|
|
657
|
+
|
|
602
658
|
const selection = window.getSelection();
|
|
603
659
|
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
selection.getRangeAt(0).commonAncestorContainer
|
|
609
|
-
);
|
|
660
|
+
if (!selection || selection.rangeCount === 0) {
|
|
661
|
+
// Keine Selection: Tab verhindern, Fokus bleibt im Editor
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
610
664
|
|
|
611
|
-
const
|
|
612
|
-
|
|
613
|
-
editor.contains(document.activeElement) ||
|
|
614
|
-
isSelectionInEditor;
|
|
665
|
+
const range = selection.getRangeAt(0);
|
|
666
|
+
const container = range.commonAncestorContainer;
|
|
615
667
|
|
|
616
|
-
if (!
|
|
668
|
+
if (!editor.contains(container)) {
|
|
669
|
+
// Container nicht im Editor: Tab verhindern
|
|
617
670
|
return;
|
|
618
671
|
}
|
|
619
672
|
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
selection &&
|
|
626
|
-
selection.rangeCount > 0
|
|
627
|
-
) {
|
|
628
|
-
const range = selection.getRangeAt(0);
|
|
629
|
-
const container = range.commonAncestorContainer;
|
|
630
|
-
const listItem =
|
|
631
|
-
container.nodeType === Node.TEXT_NODE
|
|
632
|
-
? container.parentElement?.closest("li")
|
|
633
|
-
: (container as HTMLElement).closest("li");
|
|
673
|
+
// Prüfe ob wir in einer Liste sind
|
|
674
|
+
const listItem =
|
|
675
|
+
container.nodeType === Node.TEXT_NODE
|
|
676
|
+
? container.parentElement?.closest("li")
|
|
677
|
+
: (container as HTMLElement).closest("li");
|
|
634
678
|
|
|
635
|
-
|
|
636
|
-
|
|
679
|
+
if (listItem && editor.contains(listItem)) {
|
|
680
|
+
// In Liste: Indent/Outdent durchführen
|
|
681
|
+
const currentContent = domToContent(editor);
|
|
682
|
+
historyRef.current.push(currentContent);
|
|
637
683
|
|
|
638
|
-
|
|
639
|
-
|
|
684
|
+
if (e.shiftKey) {
|
|
685
|
+
outdentListItem(selection);
|
|
686
|
+
} else {
|
|
687
|
+
indentListItem(selection);
|
|
688
|
+
}
|
|
640
689
|
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
690
|
+
setTimeout(() => {
|
|
691
|
+
if (editor) {
|
|
692
|
+
const content = domToContent(editor);
|
|
693
|
+
notifyChange(content);
|
|
645
694
|
}
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
if (editor) {
|
|
649
|
-
const content = domToContent(editor);
|
|
650
|
-
notifyChange(content);
|
|
651
|
-
}
|
|
652
|
-
}, 0);
|
|
653
|
-
return;
|
|
654
|
-
}
|
|
695
|
+
}, 0);
|
|
696
|
+
return;
|
|
655
697
|
}
|
|
656
698
|
|
|
657
|
-
|
|
699
|
+
// Nicht in Liste: Tab verhindern, aber kein Tab-Zeichen einfügen
|
|
700
|
+
// Der Fokus bleibt im Editor (durch preventDefault)
|
|
658
701
|
}
|
|
659
702
|
|
|
660
703
|
if (isModifierPressed && e.key === "z" && !e.shiftKey) {
|
|
@@ -672,11 +715,11 @@ export const Editor: React.FC<EditorProps> = ({
|
|
|
672
715
|
};
|
|
673
716
|
|
|
674
717
|
editor.addEventListener("input", handleInput);
|
|
675
|
-
editor.addEventListener("keydown", handleKeyDown);
|
|
718
|
+
editor.addEventListener("keydown", handleKeyDown, true);
|
|
676
719
|
|
|
677
720
|
return () => {
|
|
678
721
|
editor.removeEventListener("input", handleInput);
|
|
679
|
-
editor.removeEventListener("keydown", handleKeyDown);
|
|
722
|
+
editor.removeEventListener("keydown", handleKeyDown, true);
|
|
680
723
|
if (inputTimeout) {
|
|
681
724
|
clearTimeout(inputTimeout);
|
|
682
725
|
}
|