hanbiro-react16-sdk 1.0.6 → 1.0.7
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 +130 -45
- package/dist/components/ChatAIDraft/SettingPopper.d.ts +2 -0
- package/dist/components/ChatAIDraft/index.d.ts +1 -0
- package/dist/components/LoadingCircular/index.d.ts +9 -0
- package/dist/components/LoadingContainer/index.d.ts +10 -0
- package/dist/components/TinyMceEditor/index.d.ts +41 -0
- package/dist/components/TinyMceEditor/scrollStyle.d.ts +1 -0
- package/dist/components/TinyMceEditor/useEditor.d.ts +24 -0
- package/dist/components/index.d.ts +2 -1
- package/dist/hanbiro-react16-sdk.es.js +1595 -835
- package/dist/hanbiro-react16-sdk.style.css +5 -0
- package/dist/hanbiro-react16-sdk.umd.js +84 -33
- package/dist/utils/index.d.ts +1 -1
- package/package.json +4 -2
- package/dist/style.css +0 -1
package/README.md
CHANGED
|
@@ -8,72 +8,77 @@ React 16.2.0 compatible UI components SDK for Hanbiro projects.
|
|
|
8
8
|
npm install hanbiro-react16-sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## CSS Import (Required)
|
|
14
|
+
|
|
15
|
+
You **must** import the SDK stylesheet at the entry point of your project (or in the HTML file when using UMD).
|
|
16
|
+
|
|
17
|
+
**For npm/ES module projects:**
|
|
18
|
+
```ts
|
|
19
|
+
// src/index.tsx or App.tsx
|
|
20
|
+
import 'hanbiro-react16-sdk/dist/hanbiro-react16-sdk.style.css';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**For UMD (script tag):**
|
|
24
|
+
```html
|
|
25
|
+
<link rel="stylesheet" href="path/to/hanbiro-react16-sdk.style.css" />
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Exported Components
|
|
31
|
+
|
|
32
|
+
| Component | Import path |
|
|
33
|
+
|---|---|
|
|
34
|
+
| `ChatAIDraft` | `hanbiro-react16-sdk/components` |
|
|
35
|
+
| `LoadingCircular` | `hanbiro-react16-sdk/components` |
|
|
36
|
+
| `LoadingContainer` | `hanbiro-react16-sdk/components` |
|
|
37
|
+
|
|
38
|
+
## Exported Utils
|
|
39
|
+
|
|
40
|
+
| Function | Description | Import path |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| `initHanbiroReactSDK` | Initialize SDK (baseUrl, signer) | `hanbiro-react16-sdk/utils` |
|
|
43
|
+
| `getBaseUrl` | Get the configured base URL | `hanbiro-react16-sdk/utils` |
|
|
44
|
+
| `getGroupwareUrl` | Get the groupware URL | `hanbiro-react16-sdk/utils` |
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
11
48
|
## Initialization (Required)
|
|
12
49
|
|
|
13
|
-
|
|
50
|
+
Call `initHanbiroReactSDK` at the entry point of your project before rendering any components.
|
|
14
51
|
|
|
15
|
-
```
|
|
16
|
-
// src/index.tsx (Entry point)
|
|
52
|
+
```ts
|
|
17
53
|
import { initHanbiroReactSDK } from 'hanbiro-react16-sdk/utils';
|
|
18
54
|
|
|
19
55
|
initHanbiroReactSDK({
|
|
20
|
-
baseUrl:
|
|
56
|
+
baseUrl: 'https://vndev.hanbiro.com',
|
|
21
57
|
signer: null, // Pass your signer instance here if available
|
|
22
58
|
});
|
|
23
59
|
```
|
|
24
60
|
|
|
25
|
-
|
|
61
|
+
---
|
|
26
62
|
|
|
27
|
-
|
|
63
|
+
## Usage: ES Module (npm)
|
|
28
64
|
|
|
29
65
|
```tsx
|
|
30
66
|
import React, { Component } from 'react';
|
|
31
67
|
import { ChatAIDraft } from 'hanbiro-react16-sdk/components';
|
|
32
68
|
import { getBaseUrl } from 'hanbiro-react16-sdk/utils';
|
|
69
|
+
import 'hanbiro-react16-sdk/dist/hanbiro-react16-sdk.style.css';
|
|
33
70
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
interface AppState {
|
|
38
|
-
draftContent: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
class ChatAIDraftApp extends Component<{}, AppState> {
|
|
42
|
-
constructor(props: {}) {
|
|
43
|
-
super(props);
|
|
44
|
-
this.state = {
|
|
45
|
-
draftContent: ''
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Handle the event when user applies AI generated content
|
|
50
|
-
handleApply = (result: any) => {
|
|
51
|
-
console.log("Applied Output:", result);
|
|
52
|
-
this.setState({ draftContent: result.html });
|
|
53
|
-
alert("Applied content: " + result.html);
|
|
71
|
+
class ChatAIDraftApp extends Component {
|
|
72
|
+
handleApply = (result) => {
|
|
73
|
+
console.log('Applied Output:', result);
|
|
54
74
|
};
|
|
55
75
|
|
|
56
76
|
render() {
|
|
57
77
|
return (
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
{/* Using the component */}
|
|
63
|
-
<ChatAIDraft
|
|
64
|
-
baseUrl={getBaseUrl()}
|
|
65
|
-
onApply={this.handleApply}
|
|
66
|
-
/>
|
|
67
|
-
</div>
|
|
68
|
-
|
|
69
|
-
{/* Display the draft result */}
|
|
70
|
-
{this.state.draftContent && (
|
|
71
|
-
<div style={{ marginTop: '20px' }}>
|
|
72
|
-
<h3>Draft Result:</h3>
|
|
73
|
-
<div dangerouslySetInnerHTML={{ __html: this.state.draftContent }} />
|
|
74
|
-
</div>
|
|
75
|
-
)}
|
|
76
|
-
</div>
|
|
78
|
+
<ChatAIDraft
|
|
79
|
+
baseUrl={getBaseUrl()}
|
|
80
|
+
onApply={this.handleApply}
|
|
81
|
+
/>
|
|
77
82
|
);
|
|
78
83
|
}
|
|
79
84
|
}
|
|
@@ -81,6 +86,86 @@ class ChatAIDraftApp extends Component<{}, AppState> {
|
|
|
81
86
|
export default ChatAIDraftApp;
|
|
82
87
|
```
|
|
83
88
|
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Usage: UMD (Script Tag / AngularJS / Legacy Projects)
|
|
92
|
+
|
|
93
|
+
Load the SDK via `<script>` and `<link>` tags directly in your HTML. React and ReactDOM must be loaded first.
|
|
94
|
+
|
|
95
|
+
```html
|
|
96
|
+
<!-- 1. Load peer dependencies -->
|
|
97
|
+
<script src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
|
|
98
|
+
<script src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
|
|
99
|
+
|
|
100
|
+
<!-- 2. Load SDK stylesheet -->
|
|
101
|
+
<link rel="stylesheet" href="path/to/hanbiro-react16-sdk.style.css" />
|
|
102
|
+
|
|
103
|
+
<!-- 3. Load SDK UMD bundle -->
|
|
104
|
+
<script src="path/to/hanbiro-react16-sdk.umd.js"></script>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The SDK is exposed as a global variable `HanbiroReact16SDK`.
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
// Initialize
|
|
111
|
+
HanbiroReact16SDK.initHanbiroReactSDK({
|
|
112
|
+
baseUrl: 'https://vndev.hanbiro.com',
|
|
113
|
+
signer: null,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
// Mount a component into a DOM element
|
|
117
|
+
ReactDOM.render(
|
|
118
|
+
React.createElement(HanbiroReact16SDK.ChatAIDraft, {
|
|
119
|
+
baseUrl: HanbiroReact16SDK.getBaseUrl(),
|
|
120
|
+
onApply: function(result) {
|
|
121
|
+
console.log('Applied:', result);
|
|
122
|
+
},
|
|
123
|
+
}),
|
|
124
|
+
document.getElementById('chat-ai-container')
|
|
125
|
+
);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Example: AngularJS Directive
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
angular.module('myApp').directive('chatAiDraft', function() {
|
|
132
|
+
return {
|
|
133
|
+
restrict: 'E',
|
|
134
|
+
link: function(scope, element) {
|
|
135
|
+
var container = element[0];
|
|
136
|
+
|
|
137
|
+
HanbiroReact16SDK.initHanbiroReactSDK({
|
|
138
|
+
baseUrl: 'https://vndev.hanbiro.com',
|
|
139
|
+
signer: null,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
ReactDOM.render(
|
|
143
|
+
React.createElement(HanbiroReact16SDK.ChatAIDraft, {
|
|
144
|
+
baseUrl: HanbiroReact16SDK.getBaseUrl(),
|
|
145
|
+
onApply: function(result) {
|
|
146
|
+
scope.$apply(function() {
|
|
147
|
+
scope.draftContent = result.html;
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
}),
|
|
151
|
+
container
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
scope.$on('$destroy', function() {
|
|
155
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
```html
|
|
163
|
+
<!-- In your AngularJS template -->
|
|
164
|
+
<chat-ai-draft></chat-ai-draft>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
84
169
|
## Development Commands
|
|
85
170
|
|
|
86
171
|
- Run playground locally: `npm run dev`
|
|
@@ -6,12 +6,14 @@ interface SettingPopperProps {
|
|
|
6
6
|
originalEmail: string;
|
|
7
7
|
setOriginalEmail: (email: string) => void;
|
|
8
8
|
getEditorContent?: () => string;
|
|
9
|
+
parentRef?: React.RefObject<HTMLDivElement>;
|
|
9
10
|
}
|
|
10
11
|
interface SettingPopperState {
|
|
11
12
|
open: boolean;
|
|
12
13
|
}
|
|
13
14
|
declare class SettingPopper extends React.Component<SettingPopperProps, SettingPopperState> {
|
|
14
15
|
private containerRef;
|
|
16
|
+
private popperRef;
|
|
15
17
|
constructor(props: SettingPopperProps);
|
|
16
18
|
componentDidMount(): void;
|
|
17
19
|
componentWillUnmount(): void;
|
|
@@ -25,6 +25,7 @@ interface AIPaneState {
|
|
|
25
25
|
originalEmail: string;
|
|
26
26
|
}
|
|
27
27
|
declare class ChatAIDraft extends React.Component<AIPaneProps, AIPaneState> {
|
|
28
|
+
private rootRef;
|
|
28
29
|
constructor(props: AIPaneProps);
|
|
29
30
|
setAiContext: (nVal: string) => void;
|
|
30
31
|
handleMessageChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { default as React, CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
interface LoadingContainerProps {
|
|
4
|
+
style?: CSSProperties;
|
|
5
|
+
fullHeight?: boolean;
|
|
6
|
+
label?: string;
|
|
7
|
+
size?: "small" | "medium";
|
|
8
|
+
}
|
|
9
|
+
declare const LoadingContainer: React.FunctionComponent<LoadingContainerProps>;
|
|
10
|
+
export default LoadingContainer;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { default as React, CSSProperties } from 'react';
|
|
2
|
+
import { EditorEvent } from 'tinymce';
|
|
3
|
+
|
|
4
|
+
export interface TinyMceEditorProps {
|
|
5
|
+
value: string;
|
|
6
|
+
onChange?: (v: string) => void;
|
|
7
|
+
isSimple?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
height?: string | number;
|
|
10
|
+
skin?: "tinymce-5" | "oxide";
|
|
11
|
+
onClick?: (e: EditorEvent<MouseEvent>) => void;
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
lang?: string;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
options?: any;
|
|
16
|
+
defaultPlugins?: any;
|
|
17
|
+
defaultToolbar?: any;
|
|
18
|
+
imageUploadBasePath?: string;
|
|
19
|
+
imageUploadUrl?: string;
|
|
20
|
+
supportImageTypes?: any;
|
|
21
|
+
fontfamily?: string;
|
|
22
|
+
filePickerHandle?: any;
|
|
23
|
+
noImage?: boolean;
|
|
24
|
+
defaultFontType?: string;
|
|
25
|
+
defaultFontSize?: number;
|
|
26
|
+
setupFunction?: any;
|
|
27
|
+
}
|
|
28
|
+
interface TinyMceEditorState {
|
|
29
|
+
showEditor: boolean;
|
|
30
|
+
}
|
|
31
|
+
declare class TinyMceEditor extends React.Component<TinyMceEditorProps, TinyMceEditorState> {
|
|
32
|
+
private editorRef;
|
|
33
|
+
constructor(props: TinyMceEditorProps);
|
|
34
|
+
getContent: () => {
|
|
35
|
+
content: any;
|
|
36
|
+
};
|
|
37
|
+
getRawContent: () => any;
|
|
38
|
+
private handleEditorChange;
|
|
39
|
+
render(): React.JSX.Element;
|
|
40
|
+
}
|
|
41
|
+
export default TinyMceEditor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const scrollStyle = "\n::-webkit-scrollbar,\n*::-webkit-scrollbar {\n width: 8px;\n height: 8px;\n}\n\n*::-webkit-scrollbar-track {\n background: transparent;\n backdrop-filter: blur(6px);\n}\n\n::-webkit-scrollbar-thumb,\n*::-webkit-scrollbar-thumb {\n background: #e0e0e0;\n}\n\n::-webkit-scrollbar-thumb:focus,\n*::-webkit-scrollbar-thumb:focus {\n background: #bdbdbd;\n}\n\n::-webkit-scrollbar-thumb:active,\n*::-webkit-scrollbar-thumb:active {\n background: #bdbdbd;\n}\n\n::-webkit-scrollbar-thumb:hover,\n*::-webkit-scrollbar-thumb:hover {\n background: #bdbdbd;\n}\n\n::-webkit-scrollbar-corner,\n*::-webkit-scrollbar-corner {\n background-color: transparent;\n}\n";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Editor as EditorType } from 'tinymce';
|
|
2
|
+
|
|
3
|
+
export declare const EDITOR_CLASS = "annie-editor";
|
|
4
|
+
export declare const isEditorEmpty: (editorValue: string) => boolean;
|
|
5
|
+
interface editorInterface {
|
|
6
|
+
isSimple: boolean;
|
|
7
|
+
noImage: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const useEditor: (options: editorInterface) => {
|
|
10
|
+
defaultPlugins: string;
|
|
11
|
+
defaultToolbar: string;
|
|
12
|
+
imageUploadBasePath: string;
|
|
13
|
+
imageUploadUrl: string;
|
|
14
|
+
supportImageTypes: string;
|
|
15
|
+
fontfamily: string;
|
|
16
|
+
setupFunction: (ed: EditorType) => void;
|
|
17
|
+
filePickerHandle: (cb: (uri: string, fields: {
|
|
18
|
+
title: string;
|
|
19
|
+
}) => void) => void;
|
|
20
|
+
defaultFontType: undefined;
|
|
21
|
+
defaultFontSize: number;
|
|
22
|
+
isFontWeightBold: boolean;
|
|
23
|
+
};
|
|
24
|
+
export default useEditor;
|