@hero-design/rn 8.109.1 → 8.110.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/.turbo/turbo-build.log +5 -5
- package/CHANGELOG.md +14 -0
- package/es/index.js +2128 -1956
- package/lib/index.js +2128 -1956
- package/package.json +2 -2
- package/src/components/RichTextEditor/BaseRichTextEditor.tsx +37 -14
- package/src/components/RichTextEditor/EditorToolbar.tsx +18 -59
- package/src/components/RichTextEditor/RichTextEditor.tsx +1 -1
- package/src/components/RichTextEditor/__tests__/EditorToolbar.spec.tsx +31 -10
- package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +23 -1
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +126 -92
- package/src/components/RichTextEditor/constants.ts +4 -0
- package/src/components/RichTextEditor/hooks/useRichTextEditorEvents.ts +22 -3
- package/src/theme/components/toolbar.ts +1 -1
- package/stats/8.109.1/rn-stats.html +3 -1
- package/stats/8.109.2/rn-stats.html +4842 -0
- package/stats/8.110.0/rn-stats.html +4844 -0
- package/types/components/RichTextEditor/constants.d.ts +6 -2
- package/types/components/RichTextEditor/hooks/useRichTextEditorEvents.d.ts +17 -2
- package/types/components/RichTextEditor/index.d.ts +54 -2
|
@@ -6,6 +6,23 @@ import type { EditorEvents, ToolbarEvents } from '../constants';
|
|
|
6
6
|
|
|
7
7
|
type SubscribableEvent = ToolbarEvents | EditorEvents;
|
|
8
8
|
|
|
9
|
+
type EventData = {
|
|
10
|
+
[EditorEvents.UpsertLink]: {
|
|
11
|
+
text: string;
|
|
12
|
+
url: string;
|
|
13
|
+
};
|
|
14
|
+
[EditorEvents.EditorChange]: {
|
|
15
|
+
value: string;
|
|
16
|
+
toolbarState: Record<string, boolean>;
|
|
17
|
+
};
|
|
18
|
+
[ToolbarEvents.ApplyLink]: {
|
|
19
|
+
text: string;
|
|
20
|
+
url: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type EventDataByEventName<T> = T extends keyof EventData ? EventData[T] : void;
|
|
25
|
+
|
|
9
26
|
/**
|
|
10
27
|
* Hook to subscribe to events for a rich text editor
|
|
11
28
|
* @param editorName - The name of the editor to subscribe to events for
|
|
@@ -26,12 +43,12 @@ const useRichTextEditorEvents = (editorName: string) => {
|
|
|
26
43
|
const subscribeToEvents = useCallback(
|
|
27
44
|
<TEventName extends SubscribableEvent>(
|
|
28
45
|
eventName: TEventName,
|
|
29
|
-
onEvent: (data:
|
|
46
|
+
onEvent: (data: EventDataByEventName<TEventName>) => void
|
|
30
47
|
) =>
|
|
31
48
|
Events.on(
|
|
32
49
|
emitter,
|
|
33
50
|
normalizeEventName(eventName),
|
|
34
|
-
(eventData:
|
|
51
|
+
(eventData: EventDataByEventName<TEventName>) => {
|
|
35
52
|
onEvent(eventData);
|
|
36
53
|
}
|
|
37
54
|
),
|
|
@@ -44,7 +61,9 @@ const useRichTextEditorEvents = (editorName: string) => {
|
|
|
44
61
|
data,
|
|
45
62
|
}: {
|
|
46
63
|
type: TEventName;
|
|
47
|
-
data:
|
|
64
|
+
data: TEventName extends keyof EventData
|
|
65
|
+
? EventData[TEventName]
|
|
66
|
+
: unknown;
|
|
48
67
|
}) => {
|
|
49
68
|
Events.emit(emitter, normalizeEventName(type), data);
|
|
50
69
|
},
|