refactor: move GM action buttons to Solid components

Migrate GM action button injection from imperative DOM manipulation to
a reactive Solid component (`RevealManager`) using `Portal`. This
improves cleanup reliability and ensures buttons are proper Solid
components rather than raw HTML strings injected into the DOM.

Also adds URI encoding for link paths and simplifies the reveal
store logic.
This commit is contained in:
2026-07-07 23:14:04 +08:00
parent aa326f38a0
commit 4eaf6aab16
3 changed files with 191 additions and 180 deletions
+10 -2
View File
@@ -25,6 +25,14 @@ function fileNameFromPath(path: string): string {
return parts[parts.length - 1] || path;
}
/** Encode a path, preserving / separators but encoding each segment */
function encodePath(path: string): string {
return path
.split("/")
.map((seg) => encodeURIComponent(seg))
.join("/");
}
/** Section slug → human-readable title */
function slugToTitle(slug: string): string {
return slug
@@ -37,8 +45,8 @@ const RevealLink: Component<LinkPayload> = (p) => {
const navigate = useNavigate();
const target = () => {
let t = p.path;
if (p.section) t += `#${p.section}`;
let t = encodePath(p.path);
if (p.section) t += `#${encodeURIComponent(p.section)}`;
return t;
};