ct-rich-text-editor 1.0.0 → 1.0.1
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 +63 -90
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,32 +60,6 @@ function App() {
|
|
|
60
60
|
}
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
-
### Configuring the API Endpoint
|
|
64
|
-
|
|
65
|
-
You can configure the API endpoint by setting an environment variable:
|
|
66
|
-
|
|
67
|
-
#### In Node.js environments:
|
|
68
|
-
|
|
69
|
-
```js
|
|
70
|
-
// Set in your environment
|
|
71
|
-
process.env.VITE_APP_BACKEND_ENDPOINT = 'https://your-custom-api.com/verify-api-key';
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
#### In browser environments:
|
|
75
|
-
|
|
76
|
-
```js
|
|
77
|
-
// Set at the global window level
|
|
78
|
-
window.VITE_APP_BACKEND_ENDPOINT = 'https://your-custom-api.com/verify-api-key';
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Alternatively, you can use a script tag before loading your application:
|
|
82
|
-
|
|
83
|
-
```html
|
|
84
|
-
<script>
|
|
85
|
-
window.VITE_APP_BACKEND_ENDPOINT = 'https://your-custom-api.com/verify-api-key';
|
|
86
|
-
</script>
|
|
87
|
-
```
|
|
88
|
-
|
|
89
63
|
## API Reference
|
|
90
64
|
|
|
91
65
|
### EditorProvider
|
|
@@ -100,75 +74,74 @@ Provides authentication and configuration context for the editor.
|
|
|
100
74
|
|
|
101
75
|
### ConfigurableEditorWithAuth
|
|
102
76
|
|
|
103
|
-
|
|
77
|
+
The main editor component with authentication.
|
|
104
78
|
|
|
105
79
|
#### Props
|
|
106
80
|
|
|
107
|
-
- `apiKey`:
|
|
108
|
-
- `
|
|
109
|
-
- `
|
|
110
|
-
- `
|
|
111
|
-
- `
|
|
112
|
-
- `
|
|
113
|
-
- `
|
|
114
|
-
- `
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
"
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
"
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
"
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
81
|
+
- `apiKey`: Your API key for authentication (required)
|
|
82
|
+
- `onAuthSuccess`: Callback function when authentication is successful (optional)
|
|
83
|
+
- `onAuthError`: Callback function when authentication fails (optional)
|
|
84
|
+
- `showToolbar`: Boolean to show/hide the toolbar (optional, default: true)
|
|
85
|
+
- `showFloatingMenu`: Boolean to show/hide the floating menu (optional, default: true)
|
|
86
|
+
- `showHtmlView`: Boolean to show/hide HTML view option (optional, default: true)
|
|
87
|
+
- `initialContent`: Initial content for the editor (optional)
|
|
88
|
+
- `onChange`: Callback function when editor content changes (optional)
|
|
89
|
+
- `readOnly`: Boolean to make editor read-only (optional, default: false)
|
|
90
|
+
- `placeholder`: Placeholder text when editor is empty (optional)
|
|
91
|
+
- `theme`: Custom theme object for styling (optional)
|
|
92
|
+
- `plugins`: Array of custom plugins (optional)
|
|
93
|
+
- `aiEnabled`: Boolean to enable/disable AI features (optional, default: false)
|
|
94
|
+
- `onAiResponse`: Callback function for AI responses (optional)
|
|
95
|
+
- `onAiError`: Callback function for AI errors (optional)
|
|
96
|
+
|
|
97
|
+
## Examples
|
|
98
|
+
|
|
99
|
+
### Basic Editor with Authentication
|
|
100
|
+
|
|
101
|
+
```jsx
|
|
102
|
+
import React from 'react';
|
|
103
|
+
import { ConfigurableEditorWithAuth, EditorProvider } from 'ct-rich-text-editor';
|
|
104
|
+
import 'ct-rich-text-editor/style.css';
|
|
105
|
+
|
|
106
|
+
function App() {
|
|
107
|
+
return (
|
|
108
|
+
<EditorProvider>
|
|
109
|
+
<ConfigurableEditorWithAuth
|
|
110
|
+
apiKey="your-api-key"
|
|
111
|
+
onAuthSuccess={() => console.log('Authenticated')}
|
|
112
|
+
onAuthError={(error) => console.error(error)}
|
|
113
|
+
/>
|
|
114
|
+
</EditorProvider>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Editor with Custom Configuration
|
|
120
|
+
|
|
121
|
+
```jsx
|
|
122
|
+
import React from 'react';
|
|
123
|
+
import { ConfigurableEditorWithAuth, EditorProvider } from 'ct-rich-text-editor';
|
|
124
|
+
import 'ct-rich-text-editor/style.css';
|
|
125
|
+
|
|
126
|
+
function App() {
|
|
127
|
+
return (
|
|
128
|
+
<EditorProvider>
|
|
129
|
+
<ConfigurableEditorWithAuth
|
|
130
|
+
apiKey="your-api-key"
|
|
131
|
+
showToolbar={true}
|
|
132
|
+
showFloatingMenu={true}
|
|
133
|
+
showHtmlView={true}
|
|
134
|
+
readOnly={false}
|
|
135
|
+
placeholder="Start typing..."
|
|
136
|
+
aiEnabled={true}
|
|
137
|
+
onAiResponse={(response) => console.log('AI Response:', response)}
|
|
138
|
+
onAiError={(error) => console.error('AI Error:', error)}
|
|
139
|
+
/>
|
|
140
|
+
</EditorProvider>
|
|
141
|
+
);
|
|
169
142
|
}
|
|
170
143
|
```
|
|
171
144
|
|
|
172
145
|
## License
|
|
173
146
|
|
|
174
|
-
MIT
|
|
147
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|