@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pramen/cms-editor",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "description": "Visual block/page editor for @pramen/cms — a standalone React SPA that talks to the CMS handlers over HTTP.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -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
- await api.call("addBlock", { pageId: page.id, blockTypeSlug: slug, region, fields: {} });
188
- await reload();
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));