feat: Unify spark table detection and content resolution
Export isSparkTableHeader from content-registry and use it in both CLI and frontend table parsing. Add resolveContentRef to resolve content references consistently. Write processed registry content back to the file index so browser mode renders identically to CLI mode.
This commit is contained in:
@@ -17,6 +17,7 @@ import {
|
||||
removeHandle,
|
||||
ensurePermission,
|
||||
} from "./file-index-db";
|
||||
import { normalizePathKey } from "../cli/content-registry";
|
||||
|
||||
type FileIndex = Record<string, string>;
|
||||
|
||||
@@ -99,7 +100,7 @@ async function scanDirectory(
|
||||
Object.assign(index, sub);
|
||||
} else if (entry.kind === "file" && acceptedExt.test(name)) {
|
||||
const file = await (entry as FileSystemFileHandle).getFile();
|
||||
const path = prefix + name;
|
||||
const path = normalizePathKey(prefix + name);
|
||||
index[path] = await file.text();
|
||||
}
|
||||
}
|
||||
@@ -211,6 +212,16 @@ export async function getIndexedData(path: string): Promise<string> {
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入/覆盖索引中的文件内容。
|
||||
* 用于将处理后的内容(如 registry 的 stripped markdown)写回索引,
|
||||
* 使浏览器模式与 CLI 模式渲染一致。
|
||||
*/
|
||||
export function setIndexedData(path: string, content: string): void {
|
||||
fileIndex = fileIndex || {};
|
||||
fileIndex[normalizePathKey(path)] = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定扩展名的文件路径
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user