Improve local evidence search and AI capabilities

This commit is contained in:
lix-2026
2026-06-05 23:00:53 +08:00
parent a1dcfc9f76
commit 4dbd9a978b
52 changed files with 6415 additions and 527 deletions
@@ -267,7 +267,15 @@ import {
root.setAttribute('data-mnote-evidence-open', 'true');
if (blockId) root.setAttribute('data-mnote-evidence-block-id', blockId);
if (lineRange) root.setAttribute('data-mnote-evidence-line-range', lineRange);
const target = blockId ? root.querySelector(`[data-block-id="${cssSafe(blockId)}"]`) : null;
let target = blockId ? root.querySelector(`[data-block-id="${cssSafe(blockId)}"]`) : null;
if (!(target instanceof HTMLElement) && lineRange) {
const start = Number(String(lineRange).split('-')[0] || 0);
if (Number.isFinite(start) && start > 0) {
const blocks = Array.from(root.querySelectorAll('.ProseMirror [data-block-id]'))
.filter((node) => node instanceof HTMLElement);
target = blocks[Math.max(0, Math.min(blocks.length - 1, start - 1))] || null;
}
}
if (target instanceof HTMLElement) {
root.querySelectorAll('[data-mnote-evidence-text-highlight="true"]').forEach((node) => {
if (node instanceof HTMLElement) node.removeAttribute('data-mnote-evidence-text-highlight');
@@ -302,6 +310,12 @@ import {
title,
fileName: title,
openTarget: 'active-tab',
page: url.searchParams.get('page') || undefined,
bbox: url.searchParams.get('bbox') || undefined,
sourceMapPath: String(url.searchParams.get('sourceMapPath') || '').trim(),
blockId: String(url.searchParams.get('blockId') || '').trim(),
lineRange: url.searchParams.get('lineRange') || null,
charRange: url.searchParams.get('charRange') || null,
};
};