@prismicio/react 3.5.0 → 3.5.1
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/SliceBoundary.js +4 -3
- package/dist/SliceBoundary.js.map +1 -1
- package/dist/package.js +1 -1
- package/package.json +2 -2
- package/src/SliceBoundary.tsx +6 -4
package/dist/SliceBoundary.js
CHANGED
|
@@ -15,19 +15,20 @@ function CommentMarker(props) {
|
|
|
15
15
|
const id = useId();
|
|
16
16
|
const isClient = useIsClient();
|
|
17
17
|
const anchorRef = useRef(null);
|
|
18
|
+
const anchorValue = `__prismic_react_internal_comment_anchor_${id}__`;
|
|
18
19
|
useLayoutEffect(() => {
|
|
19
20
|
let anchor = anchorRef.current;
|
|
20
21
|
if (!anchor?.isConnected) {
|
|
21
|
-
anchor = findTextNode(
|
|
22
|
+
anchor = findTextNode(anchorValue);
|
|
22
23
|
if (!anchor) return;
|
|
23
|
-
anchor.data = "";
|
|
24
24
|
anchorRef.current = anchor;
|
|
25
25
|
}
|
|
26
|
+
if (anchor.data !== "") anchor.data = "";
|
|
26
27
|
const comment = document.createComment(value);
|
|
27
28
|
anchor.after(comment);
|
|
28
29
|
return () => comment.remove();
|
|
29
30
|
});
|
|
30
|
-
return isClient ?
|
|
31
|
+
return isClient ? anchorValue : null;
|
|
31
32
|
}
|
|
32
33
|
function useIsClient() {
|
|
33
34
|
return useSyncExternalStore(subscribe, getClientSnapshot, getServerSnapshot);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliceBoundary.js","names":[],"sources":["../src/SliceBoundary.tsx"],"sourcesContent":["\"use client\"\n\nimport { type ReactNode, useId, useLayoutEffect, useRef, useSyncExternalStore } from \"react\"\n\ntype SliceBoundaryProps = {\n\tchildren: ReactNode\n\tsliceId: string\n}\n\nexport function SliceBoundary(props: SliceBoundaryProps): ReactNode {\n\tconst { children, sliceId } = props\n\n\treturn (\n\t\t<>\n\t\t\t<CommentMarker value={`prismic-slice-start:${sliceId}`} />\n\t\t\t{children}\n\t\t\t<CommentMarker value={`prismic-slice-end:${sliceId}`} />\n\t\t</>\n\t)\n}\n\ntype CommentMarkerProps = {\n\tvalue: string\n}\n\nfunction CommentMarker(props: CommentMarkerProps) {\n\tconst { value } = props\n\tconst id = useId()\n\tconst isClient = useIsClient()\n\tconst anchorRef = useRef<Text>(null)\n\n\tuseLayoutEffect(() => {\n\t\tlet anchor = anchorRef.current\n\n\t\tif (!anchor?.isConnected) {\n\t\t\tanchor = findTextNode(
|
|
1
|
+
{"version":3,"file":"SliceBoundary.js","names":[],"sources":["../src/SliceBoundary.tsx"],"sourcesContent":["\"use client\"\n\nimport { type ReactNode, useId, useLayoutEffect, useRef, useSyncExternalStore } from \"react\"\n\ntype SliceBoundaryProps = {\n\tchildren: ReactNode\n\tsliceId: string\n}\n\nexport function SliceBoundary(props: SliceBoundaryProps): ReactNode {\n\tconst { children, sliceId } = props\n\n\treturn (\n\t\t<>\n\t\t\t<CommentMarker value={`prismic-slice-start:${sliceId}`} />\n\t\t\t{children}\n\t\t\t<CommentMarker value={`prismic-slice-end:${sliceId}`} />\n\t\t</>\n\t)\n}\n\ntype CommentMarkerProps = {\n\tvalue: string\n}\n\nfunction CommentMarker(props: CommentMarkerProps) {\n\tconst { value } = props\n\tconst id = useId()\n\tconst isClient = useIsClient()\n\tconst anchorRef = useRef<Text>(null)\n\tconst anchorValue = `__prismic_react_internal_comment_anchor_${id}__`\n\n\tuseLayoutEffect(() => {\n\t\tlet anchor = anchorRef.current\n\n\t\tif (!anchor?.isConnected) {\n\t\t\tanchor = findTextNode(anchorValue)\n\t\t\tif (!anchor) return\n\t\t\tanchorRef.current = anchor\n\t\t}\n\n\t\t// React restores the text when a hidden Suspense or Activity subtree is shown again.\n\t\tif (anchor.data !== \"\") anchor.data = \"\"\n\n\t\tconst comment = document.createComment(value)\n\t\tanchor.after(comment)\n\n\t\treturn () => comment.remove()\n\t})\n\n\treturn isClient ? anchorValue : null\n}\n\nfunction useIsClient() {\n\treturn useSyncExternalStore(subscribe, getClientSnapshot, getServerSnapshot)\n}\n\nfunction subscribe() {\n\treturn () => {}\n}\n\nfunction getClientSnapshot() {\n\treturn true\n}\n\nfunction getServerSnapshot() {\n\treturn false\n}\n\nfunction findTextNode(value: string) {\n\tconst walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT)\n\n\twhile (walker.nextNode()) {\n\t\tconst node = walker.currentNode\n\t\tif (node instanceof Text && node.data === value) return node\n\t}\n\n\treturn null\n}\n"],"mappings":";;;;AASA,SAAgB,cAAc,OAAsC;CACnE,MAAM,EAAE,UAAU,YAAY;CAE9B,OACC,qBAAA,YAAA,EAAA,UAAA;EACC,oBAAC,eAAD,EAAe,OAAO,uBAAuB,UAAY,CAAA;EACxD;EACD,oBAAC,eAAD,EAAe,OAAO,qBAAqB,UAAY,CAAA;CACtD,EAAA,CAAA;AAEJ;AAMA,SAAS,cAAc,OAA2B;CACjD,MAAM,EAAE,UAAU;CAClB,MAAM,KAAK,MAAM;CACjB,MAAM,WAAW,YAAY;CAC7B,MAAM,YAAY,OAAa,IAAI;CACnC,MAAM,cAAc,2CAA2C,GAAG;CAElE,sBAAsB;EACrB,IAAI,SAAS,UAAU;EAEvB,IAAI,CAAC,QAAQ,aAAa;GACzB,SAAS,aAAa,WAAW;GACjC,IAAI,CAAC,QAAQ;GACb,UAAU,UAAU;EACrB;EAGA,IAAI,OAAO,SAAS,IAAI,OAAO,OAAO;EAEtC,MAAM,UAAU,SAAS,cAAc,KAAK;EAC5C,OAAO,MAAM,OAAO;EAEpB,aAAa,QAAQ,OAAO;CAC7B,CAAC;CAED,OAAO,WAAW,cAAc;AACjC;AAEA,SAAS,cAAc;CACtB,OAAO,qBAAqB,WAAW,mBAAmB,iBAAiB;AAC5E;AAEA,SAAS,YAAY;CACpB,aAAa,CAAC;AACf;AAEA,SAAS,oBAAoB;CAC5B,OAAO;AACR;AAEA,SAAS,oBAAoB;CAC5B,OAAO;AACR;AAEA,SAAS,aAAa,OAAe;CACpC,MAAM,SAAS,SAAS,iBAAiB,SAAS,MAAM,WAAW,SAAS;CAE5E,OAAO,OAAO,SAAS,GAAG;EACzB,MAAM,OAAO,OAAO;EACpB,IAAI,gBAAgB,QAAQ,KAAK,SAAS,OAAO,OAAO;CACzD;CAEA,OAAO;AACR"}
|
package/dist/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismicio/react",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.1",
|
|
4
4
|
"description": "React components and hooks to fetch and present Prismic content",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prismic",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@prismicio/types-internal": "^3.17.2",
|
|
59
59
|
"@types/react": "^19.3.0",
|
|
60
60
|
"@types/react-dom": "^19.3.0",
|
|
61
|
-
"dotenv": "^18.0.
|
|
61
|
+
"dotenv": "^18.0.4",
|
|
62
62
|
"oxfmt": "^0.70.0",
|
|
63
63
|
"oxlint": "^1.85.0",
|
|
64
64
|
"playwright": "^1.63.0",
|
package/src/SliceBoundary.tsx
CHANGED
|
@@ -28,25 +28,27 @@ function CommentMarker(props: CommentMarkerProps) {
|
|
|
28
28
|
const id = useId()
|
|
29
29
|
const isClient = useIsClient()
|
|
30
30
|
const anchorRef = useRef<Text>(null)
|
|
31
|
+
const anchorValue = `__prismic_react_internal_comment_anchor_${id}__`
|
|
31
32
|
|
|
32
33
|
useLayoutEffect(() => {
|
|
33
34
|
let anchor = anchorRef.current
|
|
34
35
|
|
|
35
36
|
if (!anchor?.isConnected) {
|
|
36
|
-
anchor = findTextNode(
|
|
37
|
+
anchor = findTextNode(anchorValue)
|
|
37
38
|
if (!anchor) return
|
|
38
|
-
|
|
39
|
-
anchor.data = ""
|
|
40
39
|
anchorRef.current = anchor
|
|
41
40
|
}
|
|
42
41
|
|
|
42
|
+
// React restores the text when a hidden Suspense or Activity subtree is shown again.
|
|
43
|
+
if (anchor.data !== "") anchor.data = ""
|
|
44
|
+
|
|
43
45
|
const comment = document.createComment(value)
|
|
44
46
|
anchor.after(comment)
|
|
45
47
|
|
|
46
48
|
return () => comment.remove()
|
|
47
49
|
})
|
|
48
50
|
|
|
49
|
-
return isClient ?
|
|
51
|
+
return isClient ? anchorValue : null
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
function useIsClient() {
|