@1urso/generic-editor 0.1.64 → 0.1.67
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 +55 -1
- package/dist/generic-editor.js +1665 -1409
- package/dist/generic-editor.umd.cjs +40 -30
- package/dist/index.d.ts +2 -4
- package/dist/{editor → src/editor}/context.d.ts +6 -5
- package/dist/{editor → src/editor}/index.d.ts +4 -1
- package/dist/src/editor/types.d.ts +16 -0
- package/dist/src/editor/utils/helpers.d.ts +3 -0
- package/dist/{editor → src/editor}/utils/htmlGenerator.d.ts +2 -1
- package/dist/{editor → src/editor}/utils/layoutEngine.d.ts +2 -1
- package/dist/src/index.d.ts +4 -0
- package/package.json +1 -1
- package/dist/editor/types.d.ts +0 -10
- package/dist/editor/utils/helpers.d.ts +0 -3
- /package/dist/{App.d.ts → src/App.d.ts} +0 -0
- /package/dist/{editor → src/editor}/components/AlignmentToolbar.d.ts +0 -0
- /package/dist/{editor → src/editor}/components/AssetsPanel.d.ts +0 -0
- /package/dist/{editor → src/editor}/components/Canvas.d.ts +0 -0
- /package/dist/{editor → src/editor}/components/ColorPicker.d.ts +0 -0
- /package/dist/{editor → src/editor}/components/DraggableElement.d.ts +0 -0
- /package/dist/{editor → src/editor}/components/EditorSettings.d.ts +0 -0
- /package/dist/{editor → src/editor}/components/ElementAdvancedSettings.d.ts +0 -0
- /package/dist/{editor → src/editor}/components/ElementContextMenu.d.ts +0 -0
- /package/dist/{editor → src/editor}/components/ExportDialog.d.ts +0 -0
- /package/dist/{editor → src/editor}/components/HistoryPanel.d.ts +0 -0
- /package/dist/{editor → src/editor}/components/LayersPanel.d.ts +0 -0
- /package/dist/{editor → src/editor}/components/Minimap.d.ts +0 -0
- /package/dist/{editor → src/editor}/components/Preview.d.ts +0 -0
- /package/dist/{editor → src/editor}/components/Ruler.d.ts +0 -0
- /package/dist/{editor → src/editor}/components/ShortcutsDialog.d.ts +0 -0
- /package/dist/{editor → src/editor}/components/SmartGuides.d.ts +0 -0
- /package/dist/{editor → src/editor}/components/ViewToolbar.d.ts +0 -0
- /package/dist/{main.d.ts → src/main.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -382,6 +382,57 @@ The injected script automatically handles:
|
|
|
382
382
|
|
|
383
383
|
---
|
|
384
384
|
|
|
385
|
+
## Templates
|
|
386
|
+
|
|
387
|
+
Use templates to let your system provide ready-to-use layouts and let the editor apply them.
|
|
388
|
+
|
|
389
|
+
### Enable
|
|
390
|
+
|
|
391
|
+
```tsx
|
|
392
|
+
const templates = [
|
|
393
|
+
{ id: 'classic', name: 'Clássico', state: savedJsonClassic },
|
|
394
|
+
{ id: 'card', name: 'Cartão', state: savedJsonCard },
|
|
395
|
+
];
|
|
396
|
+
|
|
397
|
+
const [activeTemplateId, setActiveTemplateId] = useState('classic');
|
|
398
|
+
|
|
399
|
+
<EditorContent
|
|
400
|
+
layout={editorLayout}
|
|
401
|
+
templates={templates}
|
|
402
|
+
activeTemplateId={activeTemplateId}
|
|
403
|
+
onTemplateChange={setActiveTemplateId}
|
|
404
|
+
/>
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Send
|
|
408
|
+
|
|
409
|
+
Provide templates from your backend or local store. The `state` field accepts:
|
|
410
|
+
|
|
411
|
+
- Full saved JSON (with `elements`, `listSettings`, `canvasHeight`, etc.)
|
|
412
|
+
- A simple array of elements
|
|
413
|
+
|
|
414
|
+
```json
|
|
415
|
+
{
|
|
416
|
+
"templates": [
|
|
417
|
+
{
|
|
418
|
+
"id": "classic",
|
|
419
|
+
"name": "Clássico",
|
|
420
|
+
"description": "Layout simples com nome e mensagem.",
|
|
421
|
+
"state": {
|
|
422
|
+
"elements": [{ "type": "text", "content": "{{displayName}}", "x": 20, "y": 20, "width": 240, "height": 40 }]
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
]
|
|
426
|
+
}
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
### Use
|
|
430
|
+
|
|
431
|
+
- When `activeTemplateId` changes, the editor applies the template state to the canvas.
|
|
432
|
+
- If you omit `activeTemplateId` and `onTemplateChange`, the editor applies the template the user selects locally.
|
|
433
|
+
|
|
434
|
+
---
|
|
435
|
+
|
|
385
436
|
## API Reference
|
|
386
437
|
|
|
387
438
|
### Component `<EditorContent />`
|
|
@@ -421,4 +472,7 @@ interface IProp {
|
|
|
421
472
|
| `layout` | `ILayout` | Yes | Initial configuration and metadata. |
|
|
422
473
|
| `onSave` | `(json: string) => void` | No | Callback triggered on save. |
|
|
423
474
|
| `initialState` | `any` | No | Previously saved state (parsed JSON). |
|
|
424
|
-
| `theme` | `'light' \| 'dark'` | No | Interface theme (default: `'light'`). |
|
|
475
|
+
| `theme` | `'light' \| 'dark'` | No | Interface theme (default: `'light'`). |
|
|
476
|
+
| `templates` | `ITemplate[]` | No | Lista de templates fornecidos pelo sistema. |
|
|
477
|
+
| `activeTemplateId` | `string` | No | Template ativo controlado externamente. |
|
|
478
|
+
| `onTemplateChange` | `(id: string) => void` | No | Callback para o sistema trocar template. |
|