Skip to content

Commit 998b67e

Browse files
committed
Allow enableClickToEdit prop to accept false value
Change the type from `true | { scrollToNearestTarget: true }` to `boolean | { scrollToNearestTarget: true }` for a more intuitive API.
1 parent fb665e4 commit 998b67e

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/ContentLink/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import {
99
export type ContentLinkProps = Omit<UseContentLinkOptions, 'enabled'> & {
1010
/** Current pathname to sync with Web Previews plugin */
1111
currentPath?: string;
12-
/** Enable click-to-edit on mount. Pass true for default behavior or an object with scrollToNearestTarget. If undefined, click-to-edit is disabled. */
13-
enableClickToEdit?: true | { scrollToNearestTarget: true };
12+
/** Enable click-to-edit on mount. Pass true for default behavior or an object with scrollToNearestTarget. If undefined or false, click-to-edit is disabled. */
13+
enableClickToEdit?: boolean | { scrollToNearestTarget: true };
1414
/** Whether to strip stega encoding from text nodes after stamping. */
1515
stripStega?: boolean;
1616
};
@@ -101,7 +101,10 @@ export function ContentLink(props: ContentLinkProps): null {
101101

102102
// Enable click-to-edit on mount if requested
103103
useEffect(() => {
104-
if (enableClickToEditOptions !== undefined) {
104+
if (
105+
enableClickToEditOptions !== undefined &&
106+
enableClickToEditOptions !== false
107+
) {
105108
enableClickToEdit(
106109
enableClickToEditOptions === true
107110
? undefined

0 commit comments

Comments
 (0)