@bolttech/template-editor 0.1.7 → 0.1.9

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
@@ -121,15 +121,93 @@ function App() {
121
121
 
122
122
  ### Props
123
123
 
124
- The `TemplateEditor` component accepts one optional prop:
124
+ | Prop | Type | Default | Description |
125
+ | -------------- | ------------------------- | -------- | -------------------------------------------------------------------------------------- |
126
+ | `templateId` | `string` | — | ID of the template to load from the templating service |
127
+ | `sdk` | `TemplatingSdkConfig` | — | SDK configuration (baseUrl, workspace) to connect to the templating service |
128
+ | `placeholders` | `PlaceholderData` | `{}` | Unified data structure supporting primitives, schemas, and nested values |
129
+ | `auth` | `AuthConfig` | — | Authentication configuration (bearer token or function) |
130
+ | `goBackUrl` | `string` | — | URL to navigate to when the user clicks "Go Back". Defaults to `window.history.back()` |
131
+ | `storageKey` | `string` | — | Key used for local storage (e.g. for editor state persistence) |
132
+ | `height` | `CSSProperties['height']` | `'100%'` | Height of the editor container |
133
+ | `width` | `CSSProperties['width']` | `'100%'` | Width of the editor container |
134
+
135
+ ### With SDK and Template
125
136
 
126
- | Prop | Type | Description |
127
- | -------------- | ----------------- | ------------------------------------------------------------------------ |
128
- | `placeholders` | `PlaceholderData` | Unified data structure supporting primitives, schemas, and nested values |
137
+ ```tsx
138
+ import { TemplateEditor } from '@bolttech/template-editor';
139
+
140
+ function App() {
141
+ return (
142
+ <div style={{ height: '100vh' }}>
143
+ <TemplateEditor
144
+ templateId="507f1f77bcf86cd799439011"
145
+ sdk={{
146
+ baseUrl: 'https://templating-service.example.com',
147
+ workspace: 'my-workspace',
148
+ }}
149
+ />
150
+ </div>
151
+ );
152
+ }
153
+ ```
154
+
155
+ ### With Authentication
129
156
 
130
- ### Example with Mixed Values
157
+ The editor supports bearer token authentication to communicate with a protected templating service:
131
158
 
132
159
  ```tsx
160
+ import { TemplateEditor } from '@bolttech/template-editor';
161
+
162
+ // Static bearer token
163
+ function App() {
164
+ return (
165
+ <TemplateEditor
166
+ templateId="507f1f77bcf86cd799439011"
167
+ sdk={{ baseUrl: 'https://templating-service.example.com', workspace: 'my-workspace' }}
168
+ auth={{ token: 'your-bearer-token' }}
169
+ />
170
+ );
171
+ }
172
+
173
+ // Dynamic token (e.g. refreshed via OAuth2)
174
+ function App() {
175
+ return (
176
+ <TemplateEditor
177
+ templateId="507f1f77bcf86cd799439011"
178
+ sdk={{ baseUrl: 'https://templating-service.example.com', workspace: 'my-workspace' }}
179
+ auth={{ token: async () => await getAccessToken() }}
180
+ />
181
+ );
182
+ }
183
+ ```
184
+
185
+ ### With Go Back Navigation
186
+
187
+ ```tsx
188
+ import { TemplateEditor } from '@bolttech/template-editor';
189
+
190
+ function App() {
191
+ return (
192
+ <TemplateEditor
193
+ templateId="507f1f77bcf86cd799439011"
194
+ sdk={{
195
+ baseUrl: 'https://templating-service.example.com',
196
+ workspace: 'my-workspace',
197
+ }}
198
+ goBackUrl="/templates"
199
+ />
200
+ );
201
+ }
202
+ ```
203
+
204
+ > **Note**: If `goBackUrl` is not provided, clicking "Go Back" calls `window.history.back()`. If there are unsaved changes, the editor will prompt the user before navigating.
205
+
206
+ ### With Variables
207
+
208
+ ```tsx
209
+ import { PlaceholderData, TemplateEditor } from '@bolttech/template-editor';
210
+
133
211
  const placeholders: PlaceholderData = {
134
212
  // Primitive values (auto-converted to schemas in the UI)
135
213
  userName: 'John Doe',
@@ -153,7 +231,13 @@ const placeholders: PlaceholderData = {
153
231
  },
154
232
  };
155
233
 
156
- <TemplateEditor placeholders={placeholders} />;
234
+ function App() {
235
+ return (
236
+ <div style={{ height: '100vh' }}>
237
+ <TemplateEditor placeholders={placeholders} />
238
+ </div>
239
+ );
240
+ }
157
241
  ```
158
242
 
159
243
  📋 **Need more details?** See [complete API reference](docs/api/types.md) for full TypeScript definitions.