@commentray/render 0.3.5 → 0.4.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.
|
@@ -936,16 +936,16 @@ function emptySearchBrowsePreviewInnerHtml(hint, rows, ctx) {
|
|
|
936
936
|
function scrollDocToMarkdownLine0(docScrollEl, line0, mdLineCount) {
|
|
937
937
|
const el = docScrollEl.querySelector(`#commentray-md-line-${String(line0)}`);
|
|
938
938
|
if (el instanceof HTMLElement) {
|
|
939
|
-
|
|
940
|
-
const maxY = Math.round(Math.max(0, docScrollEl.scrollHeight - docScrollEl.clientHeight));
|
|
941
|
-
docScrollEl.scrollTo({ top: clamp(top, 0, maxY), behavior: "smooth" });
|
|
939
|
+
applyRevealChildInPane(docScrollEl, el, DUAL_PANE_BLOCK_REVEAL_LEAD_CSS_PX);
|
|
942
940
|
return;
|
|
943
941
|
}
|
|
944
942
|
if (mdLineCount <= 1)
|
|
945
943
|
return;
|
|
946
|
-
const
|
|
947
|
-
const
|
|
948
|
-
|
|
944
|
+
const lineClamped = clamp(line0, 0, Math.max(0, mdLineCount - 1));
|
|
945
|
+
const scrollTarget = paneUsesInternalYScroll(docScrollEl) ? docScrollEl : rootScrollingElement();
|
|
946
|
+
const maxScroll = Math.max(0, scrollTarget.scrollHeight - scrollTarget.clientHeight);
|
|
947
|
+
const top = clamp((lineClamped / Math.max(1, mdLineCount - 1)) * maxScroll, 0, maxScroll);
|
|
948
|
+
scrollTarget.scrollTo({ top, behavior: "smooth" });
|
|
949
949
|
}
|
|
950
950
|
function navigateToDocumentedPair(pair, mdLine0) {
|
|
951
951
|
if (pair.staticBrowseUrl?.trim()) {
|
|
@@ -1028,7 +1028,10 @@ function handlePathSearchHit(button, deps) {
|
|
|
1028
1028
|
const hitSp = (button.getAttribute("data-sp-path") ?? "").trim();
|
|
1029
1029
|
const pair = findDocumentedPair(deps.mutable.documentedPairs, hitCr, hitSp);
|
|
1030
1030
|
if (pair && isSameDocumentedPair(pair, deps.filePathLabel, deps.mutable.commentrayPathLabel)) {
|
|
1031
|
-
deps.docScrollEl
|
|
1031
|
+
const scrollTarget = paneUsesInternalYScroll(deps.docScrollEl)
|
|
1032
|
+
? deps.docScrollEl
|
|
1033
|
+
: rootScrollingElement();
|
|
1034
|
+
scrollTarget.scrollTo({ top: 0, behavior: "smooth" });
|
|
1032
1035
|
return;
|
|
1033
1036
|
}
|
|
1034
1037
|
if (pair)
|
|
@@ -3290,6 +3293,27 @@ function initialCommentrayScopePathState(shell, scope, filePathLabel, commentray
|
|
|
3290
3293
|
: [filePathLabel, commentrayPathLabel].filter((s) => s.trim().length > 0).join("\n");
|
|
3291
3294
|
return { documentedPairs, pathRowsForOrdering, pathBlobWide };
|
|
3292
3295
|
}
|
|
3296
|
+
function effectiveCommentrayPathLabelFromDocumentedPairs(scope, filePathLabel, commentrayPathLabel, documentedPairs) {
|
|
3297
|
+
if (scope !== "commentray-and-paths")
|
|
3298
|
+
return commentrayPathLabel;
|
|
3299
|
+
const sourcePath = filePathLabel.trim();
|
|
3300
|
+
if (sourcePath.length === 0)
|
|
3301
|
+
return commentrayPathLabel;
|
|
3302
|
+
const pair = findDocumentedPair(documentedPairs, "", sourcePath);
|
|
3303
|
+
if (!pair)
|
|
3304
|
+
return commentrayPathLabel;
|
|
3305
|
+
const fromShell = commentrayPathLabel.trim();
|
|
3306
|
+
const fromPair = pair.commentrayPath.trim();
|
|
3307
|
+
if (fromPair.length === 0)
|
|
3308
|
+
return commentrayPathLabel;
|
|
3309
|
+
if (fromShell.length === 0)
|
|
3310
|
+
return fromPair;
|
|
3311
|
+
// Older hub HTML can carry placeholder `commentray.md` while documentedPairs already has the real path.
|
|
3312
|
+
if (normPosixPath(fromShell) === "commentray.md" && normPosixPath(fromPair) !== "commentray.md") {
|
|
3313
|
+
return fromPair;
|
|
3314
|
+
}
|
|
3315
|
+
return commentrayPathLabel;
|
|
3316
|
+
}
|
|
3293
3317
|
/**
|
|
3294
3318
|
* Fetched `commentray-nav-search.json` sometimes omits `staticBrowseUrl` on pairs; the hub embed
|
|
3295
3319
|
* carries browse URLs from the same build — merge so search hits open `_site/browse/…`, not GitHub.
|
|
@@ -3518,6 +3542,15 @@ function buildDualPaneSearcherBundle(shell, codePane) {
|
|
|
3518
3542
|
const scrollLinksRef = { current: scrollLinks };
|
|
3519
3543
|
const { scope, filePathLabel, commentrayPathLabel } = readSearchScopeFromShell(shell);
|
|
3520
3544
|
const pathInit = initialCommentrayScopePathState(shell, scope, filePathLabel, commentrayPathLabel);
|
|
3545
|
+
const effectiveCommentrayPathLabel = effectiveCommentrayPathLabelFromDocumentedPairs(scope, filePathLabel, commentrayPathLabel, pathInit.documentedPairs);
|
|
3546
|
+
if (effectiveCommentrayPathLabel.trim().length > 0) {
|
|
3547
|
+
shell.setAttribute("data-search-commentray-path", effectiveCommentrayPathLabel);
|
|
3548
|
+
const docPathEl = document.getElementById("nav-rail-doc-path");
|
|
3549
|
+
if (docPathEl) {
|
|
3550
|
+
docPathEl.textContent = effectiveCommentrayPathLabel;
|
|
3551
|
+
docPathEl.setAttribute("title", effectiveCommentrayPathLabel);
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3521
3554
|
const indexState = {
|
|
3522
3555
|
hubNavRows: [],
|
|
3523
3556
|
documentedPairs: pathInit.documentedPairs,
|
|
@@ -3526,7 +3559,7 @@ function buildDualPaneSearcherBundle(shell, codePane) {
|
|
|
3526
3559
|
const mutable = {
|
|
3527
3560
|
rawMd,
|
|
3528
3561
|
mdLines: rawMd.split("\n"),
|
|
3529
|
-
commentrayPathLabel,
|
|
3562
|
+
commentrayPathLabel: effectiveCommentrayPathLabel,
|
|
3530
3563
|
searcher: indexSearchLineRows([]),
|
|
3531
3564
|
pathBlobWide: pathInit.pathBlobWide,
|
|
3532
3565
|
pathRowsForOrdering: indexState.pathRowsForOrdering,
|
|
@@ -3550,7 +3583,7 @@ function buildDualPaneSearcherBundle(shell, codePane) {
|
|
|
3550
3583
|
scrollLinksRef,
|
|
3551
3584
|
scope,
|
|
3552
3585
|
filePathLabel,
|
|
3553
|
-
commentrayPathLabel,
|
|
3586
|
+
commentrayPathLabel: effectiveCommentrayPathLabel,
|
|
3554
3587
|
pathInit,
|
|
3555
3588
|
indexState,
|
|
3556
3589
|
mutable,
|