Skip to content

Commit 60f317f

Browse files
committed
feat: make onPublish prop optional
1 parent 4ba17af commit 60f317f

File tree

3 files changed

+8
-47
lines changed

3 files changed

+8
-47
lines changed

apps/docs/pages/docs/api-reference/components/puck.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function Editor() {
2929
| ----------------------------------------------------- | ------------------------------------ | -------------------------------------------------- | -------- |
3030
| [`config`](#config) | `config: { components: {} }` | [Config](/docs/api-reference/configuration/config) | Required |
3131
| [`data`](#data) | `data: { content: [], root: {} }` | [Data](/docs/api-reference/data) | Required |
32-
| [`onPublish()`](#onpublishdata) | `onPublish: async (data) => {}` | Function | Required |
32+
| [`onPublish()`](#onpublishdata) | `onPublish: async (data) => {}` | Function | - |
3333
| [`headerPath`](#headerpath) | `headerPath: "/my-page"` | String | - |
3434
| [`headerTitle`](#headertitle) | `headerTitle: "My Page"` | String | - |
3535
| [`onChange()`](#onchangedata) | `onChange: (data) => {}` | Function | - |
@@ -91,6 +91,8 @@ export function Editor() {
9191
}
9292
```
9393

94+
## Optional props
95+
9496
### `onPublish(data)`
9597

9698
Callback that triggers when the user hits the "Publish" button. Use this to save the Puck data to your database.
@@ -113,8 +115,6 @@ export function Editor() {
113115
}
114116
```
115117

116-
## Optional props
117-
118118
### `headerPath`
119119

120120
Set a path to show after the header title

packages/core/components/MenuBar/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const MenuBar = ({
2424
appState: AppState;
2525
data: Data;
2626
dispatch: (action: PuckAction) => void;
27-
onPublish: (data: Data) => void;
27+
onPublish?: (data: Data) => void;
2828
menuOpen: boolean;
2929
renderHeaderActions?: (props: {
3030
state: AppState;
@@ -87,7 +87,7 @@ export const MenuBar = ({
8787
<div>
8888
<Button
8989
onClick={() => {
90-
onPublish(data);
90+
onPublish && onPublish(data);
9191
}}
9292
icon={<Globe size="14px" />}
9393
>

packages/core/components/Puck/index.tsx

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function Puck({
5656
data: Data;
5757
ui?: Partial<UiState>;
5858
onChange?: (data: Data) => void;
59-
onPublish: (data: Data) => void;
59+
onPublish?: (data: Data) => void;
6060
plugins?: Plugin[];
6161
customUi?: Partial<CustomUi>;
6262
renderComponentList?: (props: {
@@ -392,7 +392,7 @@ export function Puck({
392392
<CustomHeaderActions />
393393
<Button
394394
onClick={() => {
395-
onPublish(data);
395+
onPublish && onPublish(data);
396396
}}
397397
icon={<Globe size="14px" />}
398398
>
@@ -425,55 +425,16 @@ export function Puck({
425425
</IconButton>
426426
</div>
427427
</div>
428-
<<<<<<< HEAD
429-
<div className={getClassName("rightSideBarToggle")}>
430-
<IconButton
431-
onClick={() => {
432-
toggleSidebars("right");
433-
}}
434-
title="Toggle right sidebar"
435-
>
436-
<Sidebar focusable="false" />
437-
</IconButton>
438-
</div>
439-
</div>
440-
<div className={getClassName("headerTitle")}>
441-
<Heading rank={2} size="xs">
442-
{headerTitle || rootProps.title || "Page"}
443-
{headerPath && (
444-
<>
445-
{" "}
446-
<code className={getClassName("headerPath")}>
447-
{headerPath}
448-
</code>
449-
</>
450-
)}
451-
</Heading>
452-
</div>
453-
<div className={getClassName("headerTools")}>
454-
<div className={getClassName("menuButton")}>
455-
<IconButton
456-
onClick={() => {
457-
return setMenuOpen(!menuOpen);
458-
}}
459-
title="Toggle menu bar"
460-
>
461-
{menuOpen ? (
462-
<ChevronUp focusable="false" />
463-
) : (
464-
<ChevronDown focusable="false" />
465-
=======
466428
<div className={getClassName("headerTitle")}>
467429
<Heading rank={2} size="xs">
468-
{headerTitle || data.root.props.title || "Page"}
430+
{headerTitle || rootProps.title || "Page"}
469431
{headerPath && (
470432
<>
471433
{" "}
472434
<code className={getClassName("headerPath")}>
473435
{headerPath}
474436
</code>
475437
</>
476-
>>>>>>> b9c0ed2 (feat: introduce UI overrides API)
477438
)}
478439
</Heading>
479440
</div>

0 commit comments

Comments
 (0)