@fraczled/sdk 1.0.3 → 1.0.4
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 +54 -0
- package/dist/fraczled-sdk.es.js +1 -1
- package/dist/fraczled-sdk.umd.js +128 -123
- package/dist/{index-B7nKcvyh.js → index-D13RaDcT.js} +8026 -7967
- package/dist/{index.es-DWObXjGN.js → index.es-4X2jOOtZ.js} +1 -1
- package/index.d.ts +17 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,6 +63,7 @@ interface EditorConfig {
|
|
|
63
63
|
injectBaseStyles?: boolean;
|
|
64
64
|
showLoader?: boolean;
|
|
65
65
|
};
|
|
66
|
+
customPanels?: CustomSidebarPanel[];
|
|
66
67
|
}
|
|
67
68
|
```
|
|
68
69
|
|
|
@@ -130,6 +131,59 @@ Creates a new editor instance.
|
|
|
130
131
|
- `select` - Fired when selection changes
|
|
131
132
|
- `export` - Fired when user exports
|
|
132
133
|
|
|
134
|
+
## Custom Sidebar Panels
|
|
135
|
+
|
|
136
|
+
You can add your own sidebar tools and panels inside the editor UI. Custom panels render inside the same side panel shell used by built-in tools, and receive access to the `store` and current `state`.
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
import { createFraczledEditor } from "@fraczled/sdk";
|
|
140
|
+
import { BadgeCheck } from "lucide-react";
|
|
141
|
+
|
|
142
|
+
const editor = createFraczledEditor({
|
|
143
|
+
apiKey: "YOUR_LICENSE_KEY",
|
|
144
|
+
projectId: "YOUR_PROJECT_ID",
|
|
145
|
+
container: document.getElementById("editor"),
|
|
146
|
+
customPanels: [
|
|
147
|
+
{
|
|
148
|
+
id: "my-product:approvals",
|
|
149
|
+
label: "Approvals",
|
|
150
|
+
icon: BadgeCheck,
|
|
151
|
+
feature: "approvals", // optional entitlement key
|
|
152
|
+
render: ({ store, state, closePanel, setActivePanel }) => (
|
|
153
|
+
<div className="space-y-4">
|
|
154
|
+
<div className="rounded-lg border border-slate-200 bg-slate-50 p-3 text-xs text-slate-600">
|
|
155
|
+
Selected elements: {state.selection.length}
|
|
156
|
+
</div>
|
|
157
|
+
<button
|
|
158
|
+
className="w-full rounded-lg bg-slate-900 px-3 py-2 text-sm font-semibold text-white"
|
|
159
|
+
onClick={() =>
|
|
160
|
+
store.addElement({
|
|
161
|
+
type: "text",
|
|
162
|
+
name: "Approved Copy",
|
|
163
|
+
content: "Approved Copy"
|
|
164
|
+
})
|
|
165
|
+
}
|
|
166
|
+
>
|
|
167
|
+
Insert Approved Copy
|
|
168
|
+
</button>
|
|
169
|
+
<button
|
|
170
|
+
className="w-full rounded-lg border border-slate-200 px-3 py-2 text-sm font-medium"
|
|
171
|
+
onClick={closePanel}
|
|
172
|
+
>
|
|
173
|
+
Close
|
|
174
|
+
</button>
|
|
175
|
+
</div>
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Notes:
|
|
183
|
+
- `id` must be unique and should not match built-in tool labels (for example, `Design` or `Elements`).
|
|
184
|
+
- `feature` maps to `entitlements.features[feature]` and controls visibility/access based on licensing.
|
|
185
|
+
- `render` is called when the panel is active, so you can wire buttons directly to `store` methods or read from `state`.
|
|
186
|
+
|
|
133
187
|
## Support
|
|
134
188
|
|
|
135
189
|
- Documentation: [fraczled.com/docs](https://fraczled.com/docs)
|
package/dist/fraczled-sdk.es.js
CHANGED