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.
Files changed (2) hide show
  1. package/README.md +63 -90
  2. 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
- Main editor component with API key authentication.
77
+ The main editor component with authentication.
104
78
 
105
79
  #### Props
106
80
 
107
- - `apiKey`: (required) Your API key for authentication
108
- - `initialContent`: Initial HTML content (optional)
109
- - `onChange`: Callback for content changes (optional)
110
- - `defaultFontFamilies`: Array of font names (optional)
111
- - `mentionUserList`: Array of usernames for mention functionality (optional)
112
- - `onAuthSuccess`: Callback when authentication succeeds (optional)
113
- - `onAuthError`: Callback when authentication fails (optional)
114
- - `customVerifyKey`: Custom function for API key verification (optional)
115
-
116
- ## API Authentication
117
-
118
- The editor requires an API key for authentication. Upon providing a valid API key, the editor will fetch the configuration from the server, which determines which features are enabled.
119
-
120
- The default API endpoint is `http://localhost:3000/api/projects/verify-api-key` but you can customize it using the environment variable `VITE_APP_BACKEND_ENDPOINT`.
121
-
122
- ### API Response Format
123
-
124
- ```json
125
- {
126
- "success": true,
127
- "message": "API key verified successfully",
128
- "data": {
129
- "id": "67dbd63359550ada7d899490",
130
- "name": "sampleProject",
131
- "paidPlan": false,
132
- "editorConfig": {
133
- "enableToolbar": true,
134
- "toolbarOptions": {
135
- "enableUndoRedo": true,
136
- "enableTextFormatting": true,
137
- "enableAlignment": true,
138
- "enableFontControls": true,
139
- "enableTableOptions": true,
140
- "enableInsertMenu": true,
141
- "enableColorPicker": true,
142
- "enableClearOptions": true,
143
- "enableEmojiPicker": true,
144
- "enableLinks": true,
145
- "enableFormatTextMenu": true,
146
- "enableCodeFormat": true,
147
- "enableAIChat": true
148
- },
149
- "enableFloatingMenu": true,
150
- "htmlViewOption": true,
151
- "floatingMenuOptions": {
152
- "bold": true,
153
- "italic": true,
154
- "underline": true,
155
- "uppercase": true,
156
- "lowercase": true,
157
- "capitalize": true,
158
- "strikethrough": true,
159
- "subscript": true,
160
- "superscript": true,
161
- "code": true,
162
- "link": true,
163
- "aiChat": true
164
- }
165
- },
166
- "createdAt": "2025-03-20T08:47:47.314Z",
167
- "updatedAt": "2025-03-20T08:47:47.314Z"
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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ct-rich-text-editor",
3
3
  "private": false,
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@9.0.0",
7
7
  "main": "dist/index.js",