react-datocms 8.0.0 → 8.0.2
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/dist/cjs/ContentLink/index.js +2 -2
- package/dist/cjs/ContentLink/index.js.map +1 -1
- package/dist/cjs/useContentLink/index.js +3 -2
- package/dist/cjs/useContentLink/index.js.map +1 -1
- package/dist/esm/ContentLink/index.js +2 -2
- package/dist/esm/ContentLink/index.js.map +1 -1
- package/dist/esm/useContentLink/index.js +3 -2
- package/dist/esm/useContentLink/index.js.map +1 -1
- package/dist/types/ContentLink/index.d.ts +5 -0
- package/dist/types/useContentLink/index.d.ts +5 -0
- package/package.json +2 -2
- package/src/ContentLink/index.tsx +7 -0
- package/src/useContentLink/index.ts +8 -2
|
@@ -80,8 +80,8 @@ const index_js_1 = require("../useContentLink/index.js");
|
|
|
80
80
|
* @returns null - This component has no visual output
|
|
81
81
|
*/
|
|
82
82
|
function ContentLink(props) {
|
|
83
|
-
const { currentPath, enableClickToEdit: enableClickToEditOptions, stripStega } = props, useContentLinkOptions = __rest(props, ["currentPath", "enableClickToEdit", "stripStega"]);
|
|
84
|
-
const { enableClickToEdit, setCurrentPath } = (0, index_js_1.useContentLink)(Object.assign(Object.assign({}, useContentLinkOptions), { enabled: stripStega !== undefined ? { stripStega } : true }));
|
|
83
|
+
const { currentPath, enableClickToEdit: enableClickToEditOptions, stripStega, hue } = props, useContentLinkOptions = __rest(props, ["currentPath", "enableClickToEdit", "stripStega", "hue"]);
|
|
84
|
+
const { enableClickToEdit, setCurrentPath } = (0, index_js_1.useContentLink)(Object.assign(Object.assign({}, useContentLinkOptions), { enabled: stripStega !== undefined ? { stripStega } : true, hue }));
|
|
85
85
|
// Sync current path when it changes
|
|
86
86
|
(0, react_1.useEffect)(() => {
|
|
87
87
|
if (currentPath !== undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ContentLink/index.tsx"],"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,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAElD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -37,7 +37,7 @@ Object.defineProperty(exports, "stripStega", { enumerable: true, get: function (
|
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
39
|
function useContentLink(options = {}) {
|
|
40
|
-
const { enabled = true, onNavigateTo, root } = options;
|
|
40
|
+
const { enabled = true, onNavigateTo, root, hue } = options;
|
|
41
41
|
const controllerRef = (0, react_1.useRef)(null);
|
|
42
42
|
// Store the callback in a ref to avoid recreating the controller when it changes
|
|
43
43
|
const onNavigateToRef = (0, react_1.useRef)(onNavigateTo);
|
|
@@ -63,13 +63,14 @@ function useContentLink(options = {}) {
|
|
|
63
63
|
onNavigateTo: (path) => { var _a; return (_a = onNavigateToRef.current) === null || _a === void 0 ? void 0 : _a.call(onNavigateToRef, path); },
|
|
64
64
|
root: (root === null || root === void 0 ? void 0 : root.current) || undefined,
|
|
65
65
|
stripStega,
|
|
66
|
+
hue,
|
|
66
67
|
});
|
|
67
68
|
controllerRef.current = controller;
|
|
68
69
|
return () => {
|
|
69
70
|
controller.dispose();
|
|
70
71
|
controllerRef.current = null;
|
|
71
72
|
};
|
|
72
|
-
}, [enabled, root]);
|
|
73
|
+
}, [enabled, root, hue]);
|
|
73
74
|
// Stable method references that call through to the controller
|
|
74
75
|
const enableClickToEdit = (0, react_1.useCallback)((opts) => {
|
|
75
76
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/useContentLink/index.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/useContentLink/index.ts"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;AAuGb,wCAyFC;AA9LD,wDAA0E;AAC1E,iCAAuD;AAEvD,2EAA2E;AAC3E,sDAAgE;AAAvD,2GAAA,WAAW,OAAA;AAAE,0GAA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AE,EAAE;;QAC/D,MAAA,aAAa,CAAC,OAAO,0CAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IACzD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,cAAc,GAAG,IAAA,mBAAW,EAAC,CAAC,IAAY,EAAE,EAAE;;QAClD,MAAA,aAAa,CAAC,OAAO,0CAAE,cAAc,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,UAAU,EAAE,aAAa,CAAC,OAAO;QACjC,iBAAiB;QACjB,kBAAkB;QAClB,oBAAoB;QACpB,QAAQ;QACR,cAAc;KACf,CAAC;AACJ,CAAC"}
|
|
@@ -77,8 +77,8 @@ import { useContentLink, } from '../useContentLink/index.js';
|
|
|
77
77
|
* @returns null - This component has no visual output
|
|
78
78
|
*/
|
|
79
79
|
export function ContentLink(props) {
|
|
80
|
-
const { currentPath, enableClickToEdit: enableClickToEditOptions, stripStega } = props, useContentLinkOptions = __rest(props, ["currentPath", "enableClickToEdit", "stripStega"]);
|
|
81
|
-
const { enableClickToEdit, setCurrentPath } = useContentLink(Object.assign(Object.assign({}, useContentLinkOptions), { enabled: stripStega !== undefined ? { stripStega } : true }));
|
|
80
|
+
const { currentPath, enableClickToEdit: enableClickToEditOptions, stripStega, hue } = props, useContentLinkOptions = __rest(props, ["currentPath", "enableClickToEdit", "stripStega", "hue"]);
|
|
81
|
+
const { enableClickToEdit, setCurrentPath } = useContentLink(Object.assign(Object.assign({}, useContentLinkOptions), { enabled: stripStega !== undefined ? { stripStega } : true, hue }));
|
|
82
82
|
// Sync current path when it changes
|
|
83
83
|
useEffect(() => {
|
|
84
84
|
if (currentPath !== undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ContentLink/index.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;;;AAEb,OAAO,EAAE,SAAS,EAAE,MAAM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wBAAwB,CACzE,CAAC;IACJ,CAAC,EAAE,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAElD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -31,7 +31,7 @@ export { decodeStega, stripStega } from '@datocms/content-link';
|
|
|
31
31
|
* ```
|
|
32
32
|
*/
|
|
33
33
|
export function useContentLink(options = {}) {
|
|
34
|
-
const { enabled = true, onNavigateTo, root } = options;
|
|
34
|
+
const { enabled = true, onNavigateTo, root, hue } = options;
|
|
35
35
|
const controllerRef = useRef(null);
|
|
36
36
|
// Store the callback in a ref to avoid recreating the controller when it changes
|
|
37
37
|
const onNavigateToRef = useRef(onNavigateTo);
|
|
@@ -57,13 +57,14 @@ export function useContentLink(options = {}) {
|
|
|
57
57
|
onNavigateTo: (path) => { var _a; return (_a = onNavigateToRef.current) === null || _a === void 0 ? void 0 : _a.call(onNavigateToRef, path); },
|
|
58
58
|
root: (root === null || root === void 0 ? void 0 : root.current) || undefined,
|
|
59
59
|
stripStega,
|
|
60
|
+
hue,
|
|
60
61
|
});
|
|
61
62
|
controllerRef.current = controller;
|
|
62
63
|
return () => {
|
|
63
64
|
controller.dispose();
|
|
64
65
|
controllerRef.current = null;
|
|
65
66
|
};
|
|
66
|
-
}, [enabled, root]);
|
|
67
|
+
}, [enabled, root, hue]);
|
|
67
68
|
// Stable method references that call through to the controller
|
|
68
69
|
const enableClickToEdit = useCallback((opts) => {
|
|
69
70
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/useContentLink/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAmB,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAEvD,2EAA2E;AAC3E,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,uBAAuB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E,CAAC,CAAC;IAEP,MAAM,oBAAoB,GAAG,WAAW,CAAC,GAAG,EAAE;;QAC5C,OAAO,MAAA,MAAA,aAAa,CAAC,OAAO,0CAAE,oBAAoB,EAAE,mCAAI,KAAK,CAAC;IAChE,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,qBAA+B,EAAE,EAAE;;QAC/D,MAAA,aAAa,CAAC,OAAO,0CAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IACzD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,cAAc,GAAG,WAAW,CAAC,CAAC,IAAY,EAAE,EAAE;;QAClD,MAAA,aAAa,CAAC,OAAO,0CAAE,cAAc,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,UAAU,EAAE,aAAa,CAAC,OAAO;QACjC,iBAAiB;QACjB,kBAAkB;QAClB,oBAAoB;QACpB,QAAQ;QACR,cAAc;KACf,CAAC;AACJ,CAAC"}
|
|
@@ -20,6 +20,11 @@ export type ContentLinkProps = Omit<UseContentLinkOptions, 'enabled'> & {
|
|
|
20
20
|
enableClickToEdit?: boolean | ClickToEditOptions;
|
|
21
21
|
/** Whether to strip stega encoding from text nodes after stamping. */
|
|
22
22
|
stripStega?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Hue (0–359) of the overlay accent color.
|
|
25
|
+
* @default 17 (orange)
|
|
26
|
+
*/
|
|
27
|
+
hue?: number;
|
|
23
28
|
};
|
|
24
29
|
/**
|
|
25
30
|
* ContentLink component for Visual Editing with DatoCMS.
|
|
@@ -23,6 +23,11 @@ export type UseContentLinkOptions = {
|
|
|
23
23
|
onNavigateTo?: (path: string) => void;
|
|
24
24
|
/** Ref to limit scanning to this root instead of document */
|
|
25
25
|
root?: React.RefObject<HTMLElement>;
|
|
26
|
+
/**
|
|
27
|
+
* Hue (0–359) of the overlay accent color.
|
|
28
|
+
* @default 17 (orange)
|
|
29
|
+
*/
|
|
30
|
+
hue?: number;
|
|
26
31
|
};
|
|
27
32
|
export interface ClickToEditOptions {
|
|
28
33
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-datocms",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.2",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=8.0.0"
|
|
6
6
|
},
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
}
|
|
157
157
|
},
|
|
158
158
|
"dependencies": {
|
|
159
|
-
"@datocms/content-link": "^0.3.
|
|
159
|
+
"@datocms/content-link": "^0.3.19",
|
|
160
160
|
"datocms-listen": "^1.0.2",
|
|
161
161
|
"datocms-structured-text-generic-html-renderer": "^5.0.0",
|
|
162
162
|
"datocms-structured-text-utils": "^5.1.6",
|
|
@@ -28,6 +28,11 @@ export type ContentLinkProps = Omit<UseContentLinkOptions, 'enabled'> & {
|
|
|
28
28
|
enableClickToEdit?: boolean | ClickToEditOptions;
|
|
29
29
|
/** Whether to strip stega encoding from text nodes after stamping. */
|
|
30
30
|
stripStega?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Hue (0–359) of the overlay accent color.
|
|
33
|
+
* @default 17 (orange)
|
|
34
|
+
*/
|
|
35
|
+
hue?: number;
|
|
31
36
|
};
|
|
32
37
|
|
|
33
38
|
/**
|
|
@@ -99,12 +104,14 @@ export function ContentLink(props: ContentLinkProps): null {
|
|
|
99
104
|
currentPath,
|
|
100
105
|
enableClickToEdit: enableClickToEditOptions,
|
|
101
106
|
stripStega,
|
|
107
|
+
hue,
|
|
102
108
|
...useContentLinkOptions
|
|
103
109
|
} = props;
|
|
104
110
|
|
|
105
111
|
const { enableClickToEdit, setCurrentPath } = useContentLink({
|
|
106
112
|
...useContentLinkOptions,
|
|
107
113
|
enabled: stripStega !== undefined ? { stripStega } : true,
|
|
114
|
+
hue,
|
|
108
115
|
});
|
|
109
116
|
|
|
110
117
|
// Sync current path when it changes
|
|
@@ -27,6 +27,11 @@ export type UseContentLinkOptions = {
|
|
|
27
27
|
onNavigateTo?: (path: string) => void;
|
|
28
28
|
/** Ref to limit scanning to this root instead of document */
|
|
29
29
|
root?: React.RefObject<HTMLElement>;
|
|
30
|
+
/**
|
|
31
|
+
* Hue (0–359) of the overlay accent color.
|
|
32
|
+
* @default 17 (orange)
|
|
33
|
+
*/
|
|
34
|
+
hue?: number;
|
|
30
35
|
};
|
|
31
36
|
|
|
32
37
|
export interface ClickToEditOptions {
|
|
@@ -99,7 +104,7 @@ export type UseContentLinkResult = {
|
|
|
99
104
|
export function useContentLink(
|
|
100
105
|
options: UseContentLinkOptions = {},
|
|
101
106
|
): UseContentLinkResult {
|
|
102
|
-
const { enabled = true, onNavigateTo, root } = options;
|
|
107
|
+
const { enabled = true, onNavigateTo, root, hue } = options;
|
|
103
108
|
|
|
104
109
|
const controllerRef = useRef<Controller | null>(null);
|
|
105
110
|
// Store the callback in a ref to avoid recreating the controller when it changes
|
|
@@ -132,6 +137,7 @@ export function useContentLink(
|
|
|
132
137
|
onNavigateTo: (path: string) => onNavigateToRef.current?.(path),
|
|
133
138
|
root: root?.current || undefined,
|
|
134
139
|
stripStega,
|
|
140
|
+
hue,
|
|
135
141
|
});
|
|
136
142
|
|
|
137
143
|
controllerRef.current = controller;
|
|
@@ -140,7 +146,7 @@ export function useContentLink(
|
|
|
140
146
|
controller.dispose();
|
|
141
147
|
controllerRef.current = null;
|
|
142
148
|
};
|
|
143
|
-
}, [enabled, root]);
|
|
149
|
+
}, [enabled, root, hue]);
|
|
144
150
|
|
|
145
151
|
// Stable method references that call through to the controller
|
|
146
152
|
const enableClickToEdit = useCallback((opts?: ClickToEditOptions) => {
|