hanbiro-react16-sdk 1.0.11 → 1.0.13

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 CHANGED
@@ -166,8 +166,67 @@ angular.module('myApp').directive('chatAiDraft', function() {
166
166
 
167
167
  ---
168
168
 
169
+ ## ChatAIDraft — Imperative API (Ref)
170
+
171
+ `ChatAIDraft` exposes `setAIContext` via ref, allowing you to programmatically set the HTML content of the **AI Context** editor inside the Settings panel.
172
+
173
+ ```ts
174
+ interface ChatAIDraftRef {
175
+ setAIContext: (html: string) => void;
176
+ }
177
+ ```
178
+
179
+ ### React 18 / React 16.8+ (useRef)
180
+
181
+ ```tsx
182
+ import React, { useRef } from 'react';
183
+ import { ChatAIDraft } from 'hanbiro-react16-sdk/components';
184
+
185
+ function MailComposer() {
186
+ const chatRef = useRef<ChatAIDraft>(null);
187
+
188
+ const handleOpenAI = () => {
189
+ chatRef.current?.setAIContext('<p>Original email content...</p>');
190
+ };
191
+
192
+ return (
193
+ <>
194
+ <button onClick={handleOpenAI}>Open AI</button>
195
+ <ChatAIDraft
196
+ ref={chatRef}
197
+ onApply={(params) => console.log(params.html)}
198
+ />
199
+ </>
200
+ );
201
+ }
202
+ ```
203
+
204
+ ### AngularJS / UMD (callback ref)
205
+
206
+ ```js
207
+ let chatAIInstance = null;
208
+
209
+ ReactDOM.render(
210
+ React.createElement(HanbiroReact16SDK.ChatAIDraft, {
211
+ ref: function(instance) { chatAIInstance = instance; },
212
+ onApply: function(result) { /* ... */ },
213
+ }),
214
+ document.getElementById('chat-ai-container')
215
+ );
216
+
217
+ // Call anytime — e.g. when opening the AI panel
218
+ function setEmailContext(html) {
219
+ if (chatAIInstance) {
220
+ chatAIInstance.setAIContext(html);
221
+ }
222
+ }
223
+ ```
224
+
225
+ ---
226
+
169
227
  ## Development Commands
170
228
 
229
+
171
230
  - Run playground locally: `npm run dev`
172
231
  - Build library for production: `npm run build`
173
232
  - Build playground for production: `npm run build:playground`
@@ -6,6 +6,10 @@ export interface AIPaneProps {
6
6
  html: string;
7
7
  }) => void;
8
8
  }
9
+ /** Public imperative API exposed via ref */
10
+ export interface ChatAIDraftRef {
11
+ setAIContext: (html: string) => void;
12
+ }
9
13
  export interface AIMessage {
10
14
  id: string;
11
15
  question: string;
@@ -22,10 +26,10 @@ interface AIPaneState {
22
26
  conversationId: string;
23
27
  originalEmail: string;
24
28
  }
25
- declare class ChatAIDraft extends React.Component<AIPaneProps, AIPaneState> {
29
+ declare class ChatAIDraft extends React.Component<AIPaneProps, AIPaneState> implements ChatAIDraftRef {
26
30
  private rootRef;
27
31
  constructor(props: AIPaneProps);
28
- setAiContext: (nVal: string) => void;
32
+ setAIContext: (html: string) => void;
29
33
  handleMessageChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
30
34
  handleSubmit: () => Promise<void>;
31
35
  handleKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
@@ -1,4 +1,4 @@
1
- export { default as ChatAIDraft } from './ChatAIDraft';
1
+ export { default as ChatAIDraft, type ChatAIDraftRef } from './ChatAIDraft';
2
2
  export { default as LoadingCircular } from './LoadingCircular';
3
3
  export { default as LoadingContainer } from './LoadingContainer';
4
4
  export { default as Tooltip } from './Tooltip';