@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.
@@ -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: unknown) => void
46
+ onEvent: (data: EventDataByEventName<TEventName>) => void
30
47
  ) =>
31
48
  Events.on(
32
49
  emitter,
33
50
  normalizeEventName(eventName),
34
- (eventData: unknown) => {
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: unknown;
64
+ data: TEventName extends keyof EventData
65
+ ? EventData[TEventName]
66
+ : unknown;
48
67
  }) => {
49
68
  Events.emit(emitter, normalizeEventName(type), data);
50
69
  },
@@ -37,7 +37,7 @@ const getToolbarTheme = (theme: GlobalTheme) => {
37
37
  const sizes = {
38
38
  itemWrapperHeight: scale(64),
39
39
  messageWrapperHeight: scale(64),
40
- messageInputHeight: 40,
40
+ messageInputHeight: scale(40),
41
41
  };
42
42
 
43
43
  const radii = {