MCPcopy
hub / github.com/puckeditor/puck / setupZone

Function setupZone

packages/core/lib/data/setup-zone.ts:7–24  ·  view source on GitHub ↗
(
  data: UserData,
  zoneKey: string
)

Source from the content-addressed store, hash-verified

5type WithZones<T extends Data> = T & { zones: NonNullable<T["zones"]> };
6
7export const setupZone = <UserData extends Data>(
8 data: UserData,
9 zoneKey: string
10): Required<WithZones<UserData>> => {
11 if (zoneKey === rootDroppableId) {
12 return data as Required<WithZones<UserData>>;
13 }
14
15 // Preprocess to ensure zones is not undefined
16 const newData = {
17 ...data,
18 zones: data.zones ? { ...data.zones } : {},
19 };
20
21 newData.zones[zoneKey] = newData.zones[zoneKey] || [];
22
23 return newData as Required<WithZones<UserData>>;
24};

Callers 3

DropZoneRenderFunction · 0.90
index.tsxFile · 0.90
registerZoneActionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected