g-comments 0.2.0 → 0.2.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/CHANGELOG.md +19 -0
- package/README.md +24 -13
- package/dist/{chunk-WACVXJHD.js → chunk-EWWBVJ2B.js} +5 -5
- package/dist/chunk-EWWBVJ2B.js.map +1 -0
- package/dist/{chunk-IBNNENCZ.cjs → chunk-I2L3IAXL.cjs} +5 -4
- package/dist/chunk-I2L3IAXL.cjs.map +1 -0
- package/dist/element.js +985 -962
- package/dist/element.js.map +1 -1
- package/dist/index.cjs +16 -16
- package/dist/index.js +1 -1
- package/dist/react.cjs +71 -45
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +40 -14
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/styles/styles.css +964 -945
- package/dist/chunk-IBNNENCZ.cjs.map +0 -1
- package/dist/chunk-WACVXJHD.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,68 +1,68 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkI2L3IAXL_cjs = require('./chunk-I2L3IAXL.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "CommentsError", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkI2L3IAXL_cjs.CommentsError; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "PACKAGE_NAME", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkI2L3IAXL_cjs.PACKAGE_NAME; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "clientRegistry", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkI2L3IAXL_cjs.clientRegistry; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "createClient", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkI2L3IAXL_cjs.createClient; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "createClientRegistry", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkI2L3IAXL_cjs.createClientRegistry; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "createComposerTimer", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkI2L3IAXL_cjs.createComposerTimer; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "createTranslator", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkI2L3IAXL_cjs.createTranslator; }
|
|
34
34
|
});
|
|
35
35
|
Object.defineProperty(exports, "en", {
|
|
36
36
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkI2L3IAXL_cjs.en; }
|
|
38
38
|
});
|
|
39
39
|
Object.defineProperty(exports, "encodeRef", {
|
|
40
40
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkI2L3IAXL_cjs.encodeRef; }
|
|
42
42
|
});
|
|
43
43
|
Object.defineProperty(exports, "isCommentsError", {
|
|
44
44
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunkI2L3IAXL_cjs.isCommentsError; }
|
|
46
46
|
});
|
|
47
47
|
Object.defineProperty(exports, "isVirtualThread", {
|
|
48
48
|
enumerable: true,
|
|
49
|
-
get: function () { return
|
|
49
|
+
get: function () { return chunkI2L3IAXL_cjs.isVirtualThread; }
|
|
50
50
|
});
|
|
51
51
|
Object.defineProperty(exports, "locales", {
|
|
52
52
|
enumerable: true,
|
|
53
|
-
get: function () { return
|
|
53
|
+
get: function () { return chunkI2L3IAXL_cjs.locales; }
|
|
54
54
|
});
|
|
55
55
|
Object.defineProperty(exports, "memoryStorage", {
|
|
56
56
|
enumerable: true,
|
|
57
|
-
get: function () { return
|
|
57
|
+
get: function () { return chunkI2L3IAXL_cjs.memoryStorage; }
|
|
58
58
|
});
|
|
59
59
|
Object.defineProperty(exports, "ptBR", {
|
|
60
60
|
enumerable: true,
|
|
61
|
-
get: function () { return
|
|
61
|
+
get: function () { return chunkI2L3IAXL_cjs.ptBR; }
|
|
62
62
|
});
|
|
63
63
|
Object.defineProperty(exports, "resolveLocale", {
|
|
64
64
|
enumerable: true,
|
|
65
|
-
get: function () { return
|
|
65
|
+
get: function () { return chunkI2L3IAXL_cjs.resolveLocale; }
|
|
66
66
|
});
|
|
67
67
|
//# sourceMappingURL=index.cjs.map
|
|
68
68
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { CommentsError, PACKAGE_NAME, clientRegistry, createClient, createClientRegistry, createComposerTimer, createTranslator, en, encodeRef, isCommentsError, isVirtualThread, locales, memoryStorage, ptBR, resolveLocale } from './chunk-
|
|
1
|
+
export { CommentsError, PACKAGE_NAME, clientRegistry, createClient, createClientRegistry, createComposerTimer, createTranslator, en, encodeRef, isCommentsError, isVirtualThread, locales, memoryStorage, ptBR, resolveLocale } from './chunk-EWWBVJ2B.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/dist/react.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunkI2L3IAXL_cjs = require('./chunk-I2L3IAXL.cjs');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
|
|
8
8
|
var useIsomorphicLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
|
|
9
9
|
function toCommentsError(error) {
|
|
10
|
-
if (
|
|
10
|
+
if (chunkI2L3IAXL_cjs.isCommentsError(error)) {
|
|
11
11
|
return error;
|
|
12
12
|
}
|
|
13
|
-
return new
|
|
13
|
+
return new chunkI2L3IAXL_cjs.CommentsError("unknown", error instanceof Error ? error.message : String(error), {
|
|
14
14
|
cause: error
|
|
15
15
|
});
|
|
16
16
|
}
|
|
@@ -87,12 +87,12 @@ function formatAbsolute(iso, locale) {
|
|
|
87
87
|
|
|
88
88
|
// src/react/context.ts
|
|
89
89
|
var CommentsContext = react.createContext(null);
|
|
90
|
-
var defaultTranslator =
|
|
90
|
+
var defaultTranslator = chunkI2L3IAXL_cjs.createTranslator();
|
|
91
91
|
function useCommentsContext(forum) {
|
|
92
92
|
const value = useOptionalCommentsContext(forum);
|
|
93
93
|
if (!value) {
|
|
94
94
|
throw new Error(
|
|
95
|
-
`${
|
|
95
|
+
`${chunkI2L3IAXL_cjs.PACKAGE_NAME}: render this inside <DiscourseComments forum="\u2026"> or pass a \`forum\` prop`
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
98
|
return value;
|
|
@@ -100,13 +100,13 @@ function useCommentsContext(forum) {
|
|
|
100
100
|
function useOptionalCommentsContext(forum) {
|
|
101
101
|
const context = react.useContext(CommentsContext);
|
|
102
102
|
const standalone = react.useMemo(() => {
|
|
103
|
-
if (forum === void 0 || context &&
|
|
103
|
+
if (forum === void 0 || context && chunkI2L3IAXL_cjs.normalizeForum(forum).base === context.client.forum) {
|
|
104
104
|
return null;
|
|
105
105
|
}
|
|
106
106
|
return {
|
|
107
|
-
client:
|
|
107
|
+
client: chunkI2L3IAXL_cjs.clientRegistry.acquire({ forum }),
|
|
108
108
|
t: context?.t ?? defaultTranslator,
|
|
109
|
-
locale: context?.locale ??
|
|
109
|
+
locale: context?.locale ?? chunkI2L3IAXL_cjs.resolveLocale(void 0),
|
|
110
110
|
messages: context?.messages,
|
|
111
111
|
theme: context?.theme ?? "auto",
|
|
112
112
|
appearance: context?.appearance,
|
|
@@ -119,7 +119,7 @@ function useOptionalCommentsContext(forum) {
|
|
|
119
119
|
function useClient() {
|
|
120
120
|
const context = react.useContext(CommentsContext);
|
|
121
121
|
if (!context) {
|
|
122
|
-
throw new Error(`${
|
|
122
|
+
throw new Error(`${chunkI2L3IAXL_cjs.PACKAGE_NAME}: useClient() needs a <DiscourseComments> provider`);
|
|
123
123
|
}
|
|
124
124
|
return context.client;
|
|
125
125
|
}
|
|
@@ -138,11 +138,11 @@ function DiscourseComments(props) {
|
|
|
138
138
|
debug
|
|
139
139
|
};
|
|
140
140
|
const client = react.useMemo(
|
|
141
|
-
() => explicitClient ??
|
|
141
|
+
() => explicitClient ?? chunkI2L3IAXL_cjs.clientRegistry.acquire(creation),
|
|
142
142
|
[explicitClient, forum]
|
|
143
143
|
);
|
|
144
144
|
const messagesKey = messages ? JSON.stringify(messages) : "";
|
|
145
|
-
const t = react.useMemo(() =>
|
|
145
|
+
const t = react.useMemo(() => chunkI2L3IAXL_cjs.createTranslator(locale, messages), [locale, messagesKey]);
|
|
146
146
|
const onEventRef = react.useRef(onEvent);
|
|
147
147
|
react.useEffect(() => {
|
|
148
148
|
onEventRef.current = onEvent;
|
|
@@ -151,7 +151,7 @@ function DiscourseComments(props) {
|
|
|
151
151
|
() => ({
|
|
152
152
|
client,
|
|
153
153
|
t,
|
|
154
|
-
locale:
|
|
154
|
+
locale: chunkI2L3IAXL_cjs.resolveLocale(locale),
|
|
155
155
|
messages,
|
|
156
156
|
theme,
|
|
157
157
|
appearance,
|
|
@@ -353,12 +353,15 @@ function forumThemeCss(theme) {
|
|
|
353
353
|
}
|
|
354
354
|
function forumFontFacesCss(theme) {
|
|
355
355
|
let css = "";
|
|
356
|
+
const seen = /* @__PURE__ */ new Set();
|
|
356
357
|
for (const font of Object.values(theme.fonts)) {
|
|
357
358
|
for (const face of font?.faces ?? []) {
|
|
358
359
|
const weight = String(face.weight);
|
|
359
|
-
|
|
360
|
-
css += `@font-face{font-family:"${face.family}";src:${face.src};font-weight:${weight};font-display:swap;}
|
|
360
|
+
const rule = `@font-face{font-family:"${face.family}";src:${face.src};font-weight:${weight};font-display:swap;}
|
|
361
361
|
`;
|
|
362
|
+
if (SAFE_FAMILY.test(face.family) && FONT_SOURCE.test(face.src) && FONT_WEIGHT.test(weight) && !seen.has(rule)) {
|
|
363
|
+
seen.add(rule);
|
|
364
|
+
css += rule;
|
|
362
365
|
}
|
|
363
366
|
}
|
|
364
367
|
}
|
|
@@ -380,6 +383,14 @@ function forumStylesheetUrls(theme, forum) {
|
|
|
380
383
|
}
|
|
381
384
|
return urls;
|
|
382
385
|
}
|
|
386
|
+
function forumThemeStyleText(theme, forum) {
|
|
387
|
+
const imports = forumStylesheetUrls(theme, forum).map((href) => `@import url(${JSON.stringify(href)}) layer(gc-forum);
|
|
388
|
+
`).join("");
|
|
389
|
+
return `@layer gc-defaults, gc-forum;
|
|
390
|
+
${imports}@layer gc-forum{
|
|
391
|
+
${forumThemeCss(theme)}}
|
|
392
|
+
`;
|
|
393
|
+
}
|
|
383
394
|
function documentOf(root) {
|
|
384
395
|
return root.nodeType === 9 ? root : root.ownerDocument;
|
|
385
396
|
}
|
|
@@ -404,15 +415,8 @@ function applyForumTheme(root, theme, forum) {
|
|
|
404
415
|
replaceNodes(container, STYLE_ATTRIBUTE, forum, key, () => {
|
|
405
416
|
const style = doc.createElement("style");
|
|
406
417
|
style.setAttribute(STYLE_ATTRIBUTE, key);
|
|
407
|
-
style.textContent =
|
|
408
|
-
|
|
409
|
-
const link = doc.createElement("link");
|
|
410
|
-
link.rel = "stylesheet";
|
|
411
|
-
link.href = href;
|
|
412
|
-
link.setAttribute(STYLE_ATTRIBUTE, key);
|
|
413
|
-
return link;
|
|
414
|
-
});
|
|
415
|
-
return [style, ...links];
|
|
418
|
+
style.textContent = forumThemeStyleText(theme, forum);
|
|
419
|
+
return [style];
|
|
416
420
|
});
|
|
417
421
|
const faces = forumFontFacesCss(theme);
|
|
418
422
|
if (faces) {
|
|
@@ -545,7 +549,7 @@ function useThreadFor(client, { identifier, url, title, sort }, onOpenError) {
|
|
|
545
549
|
const [opened, setOpened] = react.useState(
|
|
546
550
|
{ thread: null, error: null }
|
|
547
551
|
);
|
|
548
|
-
const pageKey = url === void 0 ?
|
|
552
|
+
const pageKey = url === void 0 ? chunkI2L3IAXL_cjs.currentUrlWithoutHash() ?? "" : "";
|
|
549
553
|
const latest = react.useRef({ title, sort, onOpenError });
|
|
550
554
|
latest.current = { title, sort, onOpenError };
|
|
551
555
|
const requestedSort = react.useRef(sort);
|
|
@@ -611,14 +615,14 @@ var RootContext = react.createContext(null);
|
|
|
611
615
|
function useRootContext(component = "This component") {
|
|
612
616
|
const value = react.useContext(RootContext);
|
|
613
617
|
if (!value) {
|
|
614
|
-
throw new Error(`${
|
|
618
|
+
throw new Error(`${chunkI2L3IAXL_cjs.PACKAGE_NAME}: ${component} must be rendered inside <Comments.Root>`);
|
|
615
619
|
}
|
|
616
620
|
return value;
|
|
617
621
|
}
|
|
618
622
|
function Root(props) {
|
|
619
623
|
const context = useOptionalCommentsContext(props.forum);
|
|
620
624
|
if (!context) {
|
|
621
|
-
return /* @__PURE__ */ jsxRuntime.jsx("section", { className: cx("gc-root", "gc-root--unconfigured", props.className), "data-gc-unconfigured": "", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "gc-notice", children: `${
|
|
625
|
+
return /* @__PURE__ */ jsxRuntime.jsx("section", { className: cx("gc-root", "gc-root--unconfigured", props.className), "data-gc-unconfigured": "", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "gc-notice", children: `${chunkI2L3IAXL_cjs.PACKAGE_NAME}: render <Comments> inside <DiscourseComments forum="\u2026"> or pass a forum prop.` }) });
|
|
622
626
|
}
|
|
623
627
|
return /* @__PURE__ */ jsxRuntime.jsx(ConfiguredRoot, { ...props });
|
|
624
628
|
}
|
|
@@ -647,10 +651,10 @@ function ConfiguredRoot(props) {
|
|
|
647
651
|
const { client, emit } = context;
|
|
648
652
|
const rootRef = react.useRef(null);
|
|
649
653
|
const t = react.useMemo(
|
|
650
|
-
() => localeProp ?
|
|
654
|
+
() => localeProp ? chunkI2L3IAXL_cjs.createTranslator(localeProp, context.messages) : context.t,
|
|
651
655
|
[localeProp, context.messages, context.t]
|
|
652
656
|
);
|
|
653
|
-
const locale = localeProp ?
|
|
657
|
+
const locale = localeProp ? chunkI2L3IAXL_cjs.resolveLocale(localeProp) : context.locale;
|
|
654
658
|
const theme = themeProp ?? context.theme;
|
|
655
659
|
const { variables, elements } = react.useMemo(
|
|
656
660
|
() => mergeAppearance(context.appearance, appearance),
|
|
@@ -779,7 +783,7 @@ function ConfiguredRoot(props) {
|
|
|
779
783
|
const id = requestedHighlight;
|
|
780
784
|
const request = ++viewRequest.current;
|
|
781
785
|
void (async () => {
|
|
782
|
-
let location =
|
|
786
|
+
let location = chunkI2L3IAXL_cjs.findComment(thread.snapshot().comments, id);
|
|
783
787
|
if (!location) {
|
|
784
788
|
try {
|
|
785
789
|
await thread.context(id);
|
|
@@ -789,7 +793,7 @@ function ConfiguredRoot(props) {
|
|
|
789
793
|
}
|
|
790
794
|
return;
|
|
791
795
|
}
|
|
792
|
-
location =
|
|
796
|
+
location = chunkI2L3IAXL_cjs.findComment(thread.snapshot().comments, id);
|
|
793
797
|
}
|
|
794
798
|
if (!location || request !== viewRequest.current) {
|
|
795
799
|
return;
|
|
@@ -797,7 +801,7 @@ function ConfiguredRoot(props) {
|
|
|
797
801
|
if (location.depth > maxDepth) {
|
|
798
802
|
const cut = location.depth - maxDepth;
|
|
799
803
|
const tree = thread.snapshot().comments;
|
|
800
|
-
const ancestors = location.path.slice(0, cut).map((ancestorId) =>
|
|
804
|
+
const ancestors = location.path.slice(0, cut).map((ancestorId) => chunkI2L3IAXL_cjs.findComment(tree, ancestorId)?.node).filter((node) => node !== void 0);
|
|
801
805
|
setFocusView({ id: location.path[cut], ancestors, truncated: false });
|
|
802
806
|
} else {
|
|
803
807
|
setFocusView(null);
|
|
@@ -824,7 +828,7 @@ function ConfiguredRoot(props) {
|
|
|
824
828
|
}, [client, signInMode]);
|
|
825
829
|
const threadKey = snapshot?.thread.key;
|
|
826
830
|
const draftKey = react.useCallback(
|
|
827
|
-
(scope) => threadKey === void 0 ? null : `${
|
|
831
|
+
(scope) => threadKey === void 0 ? null : `${chunkI2L3IAXL_cjs.STORAGE_PREFIX}:${client.forum}:draft:${threadKey}:${scope}`,
|
|
828
832
|
[client.forum, threadKey]
|
|
829
833
|
);
|
|
830
834
|
const value = {
|
|
@@ -1068,7 +1072,7 @@ function ComposerForm({
|
|
|
1068
1072
|
const textareaRef = react.useRef(null);
|
|
1069
1073
|
const fileRef = react.useRef(null);
|
|
1070
1074
|
const pendingSelection = react.useRef(null);
|
|
1071
|
-
const [timer] = react.useState(
|
|
1075
|
+
const [timer] = react.useState(chunkI2L3IAXL_cjs.createComposerTimer);
|
|
1072
1076
|
const draftKey = editing ? null : root.draftKey(replyTo ? `reply:${replyTo.id}` : "root");
|
|
1073
1077
|
const [value, setValueState] = react.useState(() => draftKey ? readDraft(draftKey) : "");
|
|
1074
1078
|
const valueRef = react.useRef(value);
|
|
@@ -1628,7 +1632,7 @@ var ItemContext = react.createContext(null);
|
|
|
1628
1632
|
function useItemContext(component) {
|
|
1629
1633
|
const value = react.useContext(ItemContext);
|
|
1630
1634
|
if (!value) {
|
|
1631
|
-
throw new Error(`${
|
|
1635
|
+
throw new Error(`${chunkI2L3IAXL_cjs.PACKAGE_NAME}: ${component} must be rendered inside <Comments.Item>`);
|
|
1632
1636
|
}
|
|
1633
1637
|
return value;
|
|
1634
1638
|
}
|
|
@@ -1657,7 +1661,7 @@ function UserAvatar({
|
|
|
1657
1661
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx("gc-avatar", "gc-avatar--placeholder", className), "aria-hidden": "true", children: initial3 });
|
|
1658
1662
|
}
|
|
1659
1663
|
function Meta({ className }) {
|
|
1660
|
-
const { comment } = useItemContext("Comments.Meta");
|
|
1664
|
+
const { comment, depth } = useItemContext("Comments.Meta");
|
|
1661
1665
|
const { t, locale, client, elements } = useRootContext("Comments.Meta");
|
|
1662
1666
|
const author = comment.author;
|
|
1663
1667
|
const name = author ? author.name || author.username : null;
|
|
@@ -1678,9 +1682,31 @@ function Meta({ className }) {
|
|
|
1678
1682
|
t("pinned")
|
|
1679
1683
|
] }),
|
|
1680
1684
|
/* @__PURE__ */ jsxRuntime.jsx("a", { className: "gc-comment__time", href: `#gc-${comment.id}`, children: /* @__PURE__ */ jsxRuntime.jsx(RelativeTime, { iso: comment.created_at, locale }) }),
|
|
1681
|
-
comment.edited && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "gc-comment__edited", title: formatAbsolute(comment.updated_at, locale), children: t("edited") })
|
|
1685
|
+
comment.edited && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "gc-comment__edited", title: formatAbsolute(comment.updated_at, locale), children: t("edited") }),
|
|
1686
|
+
comment.reply_to && depth === 0 && /* @__PURE__ */ jsxRuntime.jsx(ReplyReference, { reference: comment.reply_to })
|
|
1682
1687
|
] });
|
|
1683
1688
|
}
|
|
1689
|
+
function ReplyReference({ reference }) {
|
|
1690
|
+
const { t, snapshot, focusComment } = useRootContext("Comments.Meta");
|
|
1691
|
+
const label = t("replyingTo", { username: reference.username ?? "" });
|
|
1692
|
+
const parent = snapshot ? chunkI2L3IAXL_cjs.findByNumber(snapshot.comments, reference.number) : null;
|
|
1693
|
+
if (!parent) {
|
|
1694
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "gc-comment__reply-to", children: label });
|
|
1695
|
+
}
|
|
1696
|
+
const id = parent.node.id;
|
|
1697
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1698
|
+
"a",
|
|
1699
|
+
{
|
|
1700
|
+
className: "gc-comment__reply-to",
|
|
1701
|
+
href: `#gc-${id}`,
|
|
1702
|
+
onClick: (event) => {
|
|
1703
|
+
event.preventDefault();
|
|
1704
|
+
focusComment(id, { scroll: true });
|
|
1705
|
+
},
|
|
1706
|
+
children: label
|
|
1707
|
+
}
|
|
1708
|
+
);
|
|
1709
|
+
}
|
|
1684
1710
|
function RelativeTime({ iso, locale }) {
|
|
1685
1711
|
const [now, setNow] = react.useState(Date.now);
|
|
1686
1712
|
react.useEffect(() => onMinuteTick(() => setNow(Date.now())), []);
|
|
@@ -1749,7 +1775,7 @@ function Actions({ className }) {
|
|
|
1749
1775
|
key: "copy",
|
|
1750
1776
|
label: t("copyLink"),
|
|
1751
1777
|
onSelect: () => {
|
|
1752
|
-
const href = `${
|
|
1778
|
+
const href = `${chunkI2L3IAXL_cjs.currentUrlWithoutHash() ?? ""}#gc-${comment.id}`;
|
|
1753
1779
|
const clipboard = typeof navigator === "undefined" ? void 0 : navigator.clipboard;
|
|
1754
1780
|
if (!clipboard) {
|
|
1755
1781
|
window.location.hash = `gc-${comment.id}`;
|
|
@@ -2091,7 +2117,7 @@ function DevPanel({ className }) {
|
|
|
2091
2117
|
}
|
|
2092
2118
|
return /* @__PURE__ */ jsxRuntime.jsxs("details", { className: cx("gc-devpanel", "gc-devpanel--ok", className), children: [
|
|
2093
2119
|
/* @__PURE__ */ jsxRuntime.jsxs("summary", { className: "gc-devpanel__title", children: [
|
|
2094
|
-
|
|
2120
|
+
chunkI2L3IAXL_cjs.PACKAGE_NAME,
|
|
2095
2121
|
" diagnostics"
|
|
2096
2122
|
] }),
|
|
2097
2123
|
/* @__PURE__ */ jsxRuntime.jsxs("dl", { className: "gc-devpanel__details", children: [
|
|
@@ -2120,10 +2146,10 @@ function DevPanel({ className }) {
|
|
|
2120
2146
|
"aside",
|
|
2121
2147
|
{
|
|
2122
2148
|
className: cx("gc-devpanel", className),
|
|
2123
|
-
"aria-label": `${
|
|
2149
|
+
"aria-label": `${chunkI2L3IAXL_cjs.PACKAGE_NAME} setup diagnostics`,
|
|
2124
2150
|
children: [
|
|
2125
2151
|
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "gc-devpanel__title", children: [
|
|
2126
|
-
|
|
2152
|
+
chunkI2L3IAXL_cjs.PACKAGE_NAME,
|
|
2127
2153
|
" could not load comments"
|
|
2128
2154
|
] }),
|
|
2129
2155
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "gc-devpanel__summary", children: summary }),
|
|
@@ -2301,7 +2327,7 @@ function List({ children, className }) {
|
|
|
2301
2327
|
const listClass = cx("gc-list", elements.list, className);
|
|
2302
2328
|
if (focusView) {
|
|
2303
2329
|
const tree = snapshot.comments;
|
|
2304
|
-
const target =
|
|
2330
|
+
const target = chunkI2L3IAXL_cjs.findComment(tree, focusView.id)?.node;
|
|
2305
2331
|
return /* @__PURE__ */ jsxRuntime.jsx(ListContext.Provider, { value: render, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "gc-focus", children: [
|
|
2306
2332
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2307
2333
|
"button",
|
|
@@ -2319,7 +2345,7 @@ function List({ children, className }) {
|
|
|
2319
2345
|
focusView.ancestors.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("ol", { className: "gc-context", children: focusView.ancestors.map((ancestor) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2320
2346
|
Item,
|
|
2321
2347
|
{
|
|
2322
|
-
comment:
|
|
2348
|
+
comment: chunkI2L3IAXL_cjs.findComment(tree, ancestor.id)?.node ?? ancestor,
|
|
2323
2349
|
showReplies: false
|
|
2324
2350
|
},
|
|
2325
2351
|
ancestor.id
|
|
@@ -2472,7 +2498,7 @@ function Replies() {
|
|
|
2472
2498
|
root.reportError("loadReplies", error);
|
|
2473
2499
|
return;
|
|
2474
2500
|
}
|
|
2475
|
-
const loaded3 =
|
|
2501
|
+
const loaded3 = chunkI2L3IAXL_cjs.findComment(thread.snapshot().comments, comment.id)?.node.children ?? [];
|
|
2476
2502
|
const first = loaded3.find((child) => !before.has(child.id));
|
|
2477
2503
|
if (first) {
|
|
2478
2504
|
root.focusComment(first.id);
|
|
@@ -2717,7 +2743,7 @@ function useCommentCount(ref, options = {}) {
|
|
|
2717
2743
|
}
|
|
2718
2744
|
function safeEncode(ref) {
|
|
2719
2745
|
try {
|
|
2720
|
-
return
|
|
2746
|
+
return chunkI2L3IAXL_cjs.encodeRef(ref);
|
|
2721
2747
|
} catch {
|
|
2722
2748
|
return null;
|
|
2723
2749
|
}
|
|
@@ -2732,7 +2758,7 @@ function CommentCount({
|
|
|
2732
2758
|
className
|
|
2733
2759
|
}) {
|
|
2734
2760
|
const context = useOptionalCommentsContext(forum);
|
|
2735
|
-
const pageUrl = url ??
|
|
2761
|
+
const pageUrl = url ?? chunkI2L3IAXL_cjs.defaultPageUrl();
|
|
2736
2762
|
const ref = topicId !== void 0 ? { topicId } : identifier !== void 0 ? { identifier, host } : pageUrl ? { url: pageUrl } : null;
|
|
2737
2763
|
const { count } = useCommentCount(ref, { forum });
|
|
2738
2764
|
if (!context) {
|