@pramen/cms-editor 0.0.28 → 0.0.29
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/dist/index.html +1 -1
- package/dist/{main.e0yd6v1m.js → main.y75r3gyx.js} +22 -22
- package/package.json +1 -1
- package/src/components.tsx +15 -2
package/package.json
CHANGED
package/src/components.tsx
CHANGED
|
@@ -184,8 +184,21 @@ export function PageEditor({ api, page, blockTypes, tab, onTab, onBack, onChange
|
|
|
184
184
|
|
|
185
185
|
const addBlock = async (region: string, slug: string) => {
|
|
186
186
|
try {
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
// addBlock echoes the created block + placement, so append it locally instead of a
|
|
188
|
+
// full getContentType+getPage reload — one round trip instead of three.
|
|
189
|
+
const { block, placement } = await api.call<{
|
|
190
|
+
block: { id: string; title?: string | null; fields?: Record<string, unknown> | null };
|
|
191
|
+
placement: { id: string; isShared?: boolean | number };
|
|
192
|
+
}>("addBlock", { pageId: page.id, blockTypeSlug: slug, region, fields: {} });
|
|
193
|
+
const rb: RenderedBlock = {
|
|
194
|
+
id: String(placement.id),
|
|
195
|
+
block_id: String(block.id),
|
|
196
|
+
block_type: slug,
|
|
197
|
+
title: block.title ?? null,
|
|
198
|
+
fields: block.fields ?? {},
|
|
199
|
+
is_shared: Boolean(placement.isShared),
|
|
200
|
+
};
|
|
201
|
+
setAssembled((prev) => (prev ? { ...prev, regions: { ...prev.regions, [region]: [...(prev.regions[region] ?? []), rb] } } : prev));
|
|
189
202
|
flash("block added");
|
|
190
203
|
} catch (e) {
|
|
191
204
|
setErr(errMsg(e));
|