@1urso/generic-editor 0.1.37 → 0.1.39
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 +52 -27
- package/dist/editor/context.d.ts +18 -0
- package/dist/generic-editor.js +452 -227
- package/dist/generic-editor.umd.cjs +21 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -79,20 +79,46 @@ import "@radix-ui/themes/styles.css";
|
|
|
79
79
|
|
|
80
80
|
This section describes the features available to the **end user** who will use the editor on your platform.
|
|
81
81
|
|
|
82
|
-
### Grouping and Layers Panel
|
|
83
|
-
|
|
84
|
-
- **Group Elements**:
|
|
85
|
-
- Select multiple elements and use the context menu option **Agrupar Seleção**.
|
|
86
|
-
- Groups act as a bounding box; moving the group moves all children.
|
|
87
|
-
- Clicking a child selects its parent group for consistent interactions.
|
|
88
|
-
- **Rename Layers**:
|
|
89
|
-
- Right-click any element or group and choose **Renomear...**.
|
|
90
|
-
- **Layers Panel (Left Sidebar)**:
|
|
91
|
-
- Shows a tree of Groups and their children.
|
|
92
|
-
- Drag any element in the list onto a Group to add it.
|
|
93
|
-
- Drop an element onto the “Soltar aqui para remover do grupo” area to ungroup it.
|
|
94
|
-
- Collapse/expand groups to focus on what matters.
|
|
95
|
-
|
|
82
|
+
### Grouping and Layers Panel
|
|
83
|
+
|
|
84
|
+
- **Group Elements**:
|
|
85
|
+
- Select multiple elements and use the context menu option **Agrupar Seleção**.
|
|
86
|
+
- Groups act as a bounding box; moving the group moves all children.
|
|
87
|
+
- Clicking a child selects its parent group for consistent interactions.
|
|
88
|
+
- **Rename Layers**:
|
|
89
|
+
- Right-click any element or group and choose **Renomear...**.
|
|
90
|
+
- **Layers Panel (Left Sidebar)**:
|
|
91
|
+
- Shows a tree of Groups and their children.
|
|
92
|
+
- Drag any element in the list onto a Group to add it.
|
|
93
|
+
- Drop an element onto the “Soltar aqui para remover do grupo” area to ungroup it.
|
|
94
|
+
- Collapse/expand groups to focus on what matters.
|
|
95
|
+
|
|
96
|
+
### Vínculos de Estilo (Cores por Variável)
|
|
97
|
+
|
|
98
|
+
- **O que é**: vincule propriedades de estilo (cor do texto, cor de fundo, cor da borda) diretamente a variáveis de dados, sem precisar de regras condicionais.
|
|
99
|
+
- **Como usar**:
|
|
100
|
+
- Abra **Configurações Avançadas** do elemento.
|
|
101
|
+
- Na seção **Vínculos de Estilo (Data Binding)**, escolha uma variável para cada propriedade desejada.
|
|
102
|
+
- Propriedades suportadas: `color`, `backgroundColor`, `borderColor`.
|
|
103
|
+
- **Formato dos valores**:
|
|
104
|
+
- Aceita cores CSS válidas: `#RRGGBB`, `#RRGGBBAA` (convertido para `rgba`), nomes CSS (`red`, `blue`), `rgb()`, `rgba()`.
|
|
105
|
+
- **Exemplo (JSON)**:
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"type": "text",
|
|
109
|
+
"content": "Preço: {{price}}",
|
|
110
|
+
"x": 50,
|
|
111
|
+
"y": 50,
|
|
112
|
+
"width": 200,
|
|
113
|
+
"height": 40,
|
|
114
|
+
"styleBindings": {
|
|
115
|
+
"color": "priceColor",
|
|
116
|
+
"backgroundColor": "tagBg"
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
Se `data = { "price": 10, "priceColor": "#FF0000", "tagBg": "rgba(0,0,0,0.1)" }`, o texto será renderizado com `color: #FF0000` e `backgroundColor: rgba(0,0,0,0.1)`.
|
|
121
|
+
|
|
96
122
|
### Basic Manipulation
|
|
97
123
|
|
|
98
124
|
The editor offers an experience similar to design tools like Canva or Figma:
|
|
@@ -124,7 +150,6 @@ The editor offers an experience similar to design tools like Canva or Figma:
|
|
|
124
150
|
**Right-click** and select **Advanced Settings** to access powerful data formatting and conditional styling options.
|
|
125
151
|
|
|
126
152
|
- **Data Formatting**:
|
|
127
|
-
|
|
128
153
|
- _Type_: Choose between Text (Default), Boolean (True/False), Date, or Number/Currency.
|
|
129
154
|
- _Boolean_: Define custom labels for true/false values (e.g., "Active" / "Inactive").
|
|
130
155
|
- _Date_: Custom date patterns (e.g., "DD/MM/YYYY HH:mm").
|
|
@@ -172,18 +197,18 @@ When right-clicking on an **Image** element:
|
|
|
172
197
|
- _Stretch (Fill)_: The image fills the entire box, potentially being cropped or distorted depending on the aspect ratio.
|
|
173
198
|
- **Bind Data**: Connects the image to a dynamic variable (e.g., Product Photo).
|
|
174
199
|
|
|
175
|
-
### Export and Import
|
|
176
|
-
|
|
177
|
-
- **Export**: Saves the full layout (elements, list settings, mock data, canvas height).
|
|
178
|
-
- **Import**: Loads a previously exported JSON to restore the editor state.
|
|
179
|
-
- Images are serialized as **Base64** inside the layout to avoid external dependencies.
|
|
180
|
-
|
|
181
|
-
### Preview and Simulation
|
|
182
|
-
|
|
183
|
-
- **Preview Panel**: See a live rendering of your layout.
|
|
184
|
-
- **Simulation Mode (Lists)**: Visualize entry animations and list behavior for incoming items.
|
|
185
|
-
- **Animations**: Configure entry animations (fade, slide, zoom, etc.) for list items.
|
|
186
|
-
|
|
200
|
+
### Export and Import
|
|
201
|
+
|
|
202
|
+
- **Export**: Saves the full layout (elements, list settings, mock data, canvas height).
|
|
203
|
+
- **Import**: Loads a previously exported JSON to restore the editor state.
|
|
204
|
+
- Images are serialized as **Base64** inside the layout to avoid external dependencies.
|
|
205
|
+
|
|
206
|
+
### Preview and Simulation
|
|
207
|
+
|
|
208
|
+
- **Preview Panel**: See a live rendering of your layout.
|
|
209
|
+
- **Simulation Mode (Lists)**: Visualize entry animations and list behavior for incoming items.
|
|
210
|
+
- **Animations**: Configure entry animations (fade, slide, zoom, etc.) for list items.
|
|
211
|
+
|
|
187
212
|
---
|
|
188
213
|
|
|
189
214
|
## Developer Guide (Integration)
|
package/dist/editor/context.d.ts
CHANGED
|
@@ -69,10 +69,28 @@ interface IEditorState {
|
|
|
69
69
|
historyIndex: number;
|
|
70
70
|
clipboard: IElement[];
|
|
71
71
|
gridSize: number;
|
|
72
|
+
zoom: number;
|
|
73
|
+
pan: {
|
|
74
|
+
x: number;
|
|
75
|
+
y: number;
|
|
76
|
+
};
|
|
77
|
+
snapLines: {
|
|
78
|
+
orientation: 'horizontal' | 'vertical';
|
|
79
|
+
position: number;
|
|
80
|
+
}[];
|
|
72
81
|
}
|
|
73
82
|
interface IEditorContext {
|
|
74
83
|
state: IEditorState;
|
|
75
84
|
setGridSize: (size: number) => void;
|
|
85
|
+
setZoom: (zoom: number) => void;
|
|
86
|
+
setPan: (pan: {
|
|
87
|
+
x: number;
|
|
88
|
+
y: number;
|
|
89
|
+
}) => void;
|
|
90
|
+
setSnapLines: (lines: {
|
|
91
|
+
orientation: 'horizontal' | 'vertical';
|
|
92
|
+
position: number;
|
|
93
|
+
}[]) => void;
|
|
76
94
|
addElement: (element: Omit<IElement, 'id' | 'x' | 'y' | 'width' | 'height'> & Partial<Pick<IElement, 'x' | 'y' | 'width' | 'height'>>) => void;
|
|
77
95
|
removeElement: (id: string) => void;
|
|
78
96
|
removeSelected: () => void;
|