@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.
Files changed (33) hide show
  1. package/README.md +55 -1
  2. package/dist/generic-editor.js +1665 -1409
  3. package/dist/generic-editor.umd.cjs +40 -30
  4. package/dist/index.d.ts +2 -4
  5. package/dist/{editor → src/editor}/context.d.ts +6 -5
  6. package/dist/{editor → src/editor}/index.d.ts +4 -1
  7. package/dist/src/editor/types.d.ts +16 -0
  8. package/dist/src/editor/utils/helpers.d.ts +3 -0
  9. package/dist/{editor → src/editor}/utils/htmlGenerator.d.ts +2 -1
  10. package/dist/{editor → src/editor}/utils/layoutEngine.d.ts +2 -1
  11. package/dist/src/index.d.ts +4 -0
  12. package/package.json +1 -1
  13. package/dist/editor/types.d.ts +0 -10
  14. package/dist/editor/utils/helpers.d.ts +0 -3
  15. /package/dist/{App.d.ts → src/App.d.ts} +0 -0
  16. /package/dist/{editor → src/editor}/components/AlignmentToolbar.d.ts +0 -0
  17. /package/dist/{editor → src/editor}/components/AssetsPanel.d.ts +0 -0
  18. /package/dist/{editor → src/editor}/components/Canvas.d.ts +0 -0
  19. /package/dist/{editor → src/editor}/components/ColorPicker.d.ts +0 -0
  20. /package/dist/{editor → src/editor}/components/DraggableElement.d.ts +0 -0
  21. /package/dist/{editor → src/editor}/components/EditorSettings.d.ts +0 -0
  22. /package/dist/{editor → src/editor}/components/ElementAdvancedSettings.d.ts +0 -0
  23. /package/dist/{editor → src/editor}/components/ElementContextMenu.d.ts +0 -0
  24. /package/dist/{editor → src/editor}/components/ExportDialog.d.ts +0 -0
  25. /package/dist/{editor → src/editor}/components/HistoryPanel.d.ts +0 -0
  26. /package/dist/{editor → src/editor}/components/LayersPanel.d.ts +0 -0
  27. /package/dist/{editor → src/editor}/components/Minimap.d.ts +0 -0
  28. /package/dist/{editor → src/editor}/components/Preview.d.ts +0 -0
  29. /package/dist/{editor → src/editor}/components/Ruler.d.ts +0 -0
  30. /package/dist/{editor → src/editor}/components/ShortcutsDialog.d.ts +0 -0
  31. /package/dist/{editor → src/editor}/components/SmartGuides.d.ts +0 -0
  32. /package/dist/{editor → src/editor}/components/ViewToolbar.d.ts +0 -0
  33. /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. |