Skip to content

Commit b641d25

Browse files
committed
Upgrade @datocms/content-link to ^0.3.19 and expose hue option
Add the new `hue` option (0–359, default 17/orange) to `useContentLink` and `<ContentLink />`, passing it through to `createController`. Update docs accordingly.
1 parent 9c48d52 commit b641d25

5 files changed

Lines changed: 22 additions & 7 deletions

File tree

docs/content-link.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ The `<ContentLink />` component accepts the following props:
269269
| `enableClickToEdit` | `boolean \| ClickToEditOptions` | - | Enable click-to-edit overlays on mount. Pass `true` or an object with options. If `false`/`undefined`, click-to-edit is disabled (use Alt/Option key to toggle) |
270270
| `stripStega` | `boolean` | - | Whether to strip stega encoding from text nodes after stamping |
271271
| `root` | `React.RefObject<HTMLElement>` | - | Ref to limit scanning to this root element instead of the entire document |
272+
| `hue` | `number` | `17` | Hue (0–359) of the overlay accent color. Default is the DatoCMS hue (`17`). Use this to match your brand or project colors |
272273

273274
## Advanced usage: the `useContentLink` hook
274275

@@ -309,6 +310,7 @@ const {
309310
- `{ stripStega: true }`: Enables the controller and permanently removes stega encoding from text nodes for clean `textContent` access
310311
- `onNavigateTo?: (path: string) => void` - Callback when Web Previews plugin requests navigation
311312
- `root?: React.RefObject<HTMLElement>` - Ref to limit scanning to this root element
313+
- `hue?: number` - Hue (0–359) of the overlay accent color (default: `17`, the DatoCMS hue)
312314

313315
**Note:** The `<ContentLink />` component allows controlling stega stripping through the `stripStega` prop. When undefined, the underlying library's default behavior is used.
314316

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@
156156
}
157157
},
158158
"dependencies": {
159-
"@datocms/content-link": "^0.3.13",
159+
"@datocms/content-link": "^0.3.19",
160160
"datocms-listen": "^1.0.2",
161161
"datocms-structured-text-generic-html-renderer": "^5.0.0",
162162
"datocms-structured-text-utils": "^5.1.6",

src/ContentLink/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export type ContentLinkProps = Omit<UseContentLinkOptions, 'enabled'> & {
2828
enableClickToEdit?: boolean | ClickToEditOptions;
2929
/** Whether to strip stega encoding from text nodes after stamping. */
3030
stripStega?: boolean;
31+
/**
32+
* Hue (0–359) of the overlay accent color.
33+
* @default 17 (orange)
34+
*/
35+
hue?: number;
3136
};
3237

3338
/**
@@ -99,12 +104,14 @@ export function ContentLink(props: ContentLinkProps): null {
99104
currentPath,
100105
enableClickToEdit: enableClickToEditOptions,
101106
stripStega,
107+
hue,
102108
...useContentLinkOptions
103109
} = props;
104110

105111
const { enableClickToEdit, setCurrentPath } = useContentLink({
106112
...useContentLinkOptions,
107113
enabled: stripStega !== undefined ? { stripStega } : true,
114+
hue,
108115
});
109116

110117
// Sync current path when it changes

src/useContentLink/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ export type UseContentLinkOptions = {
2727
onNavigateTo?: (path: string) => void;
2828
/** Ref to limit scanning to this root instead of document */
2929
root?: React.RefObject<HTMLElement>;
30+
/**
31+
* Hue (0–359) of the overlay accent color.
32+
* @default 17 (orange)
33+
*/
34+
hue?: number;
3035
};
3136

3237
export interface ClickToEditOptions {
@@ -99,7 +104,7 @@ export type UseContentLinkResult = {
99104
export function useContentLink(
100105
options: UseContentLinkOptions = {},
101106
): UseContentLinkResult {
102-
const { enabled = true, onNavigateTo, root } = options;
107+
const { enabled = true, onNavigateTo, root, hue } = options;
103108

104109
const controllerRef = useRef<Controller | null>(null);
105110
// Store the callback in a ref to avoid recreating the controller when it changes
@@ -132,6 +137,7 @@ export function useContentLink(
132137
onNavigateTo: (path: string) => onNavigateToRef.current?.(path),
133138
root: root?.current || undefined,
134139
stripStega,
140+
hue,
135141
});
136142

137143
controllerRef.current = controller;
@@ -140,7 +146,7 @@ export function useContentLink(
140146
controller.dispose();
141147
controllerRef.current = null;
142148
};
143-
}, [enabled, root]);
149+
}, [enabled, root, hue]);
144150

145151
// Stable method references that call through to the controller
146152
const enableClickToEdit = useCallback((opts?: ClickToEditOptions) => {

0 commit comments

Comments
 (0)