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:
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user