mirror of
https://github.com/XFox111/TabsAsideExtension.git
synced 2026-04-22 07:58:01 +03:00
fix: copilot fixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useDialog } from "@/contexts/DialogProvider";
|
||||
import { Body1, Button, makeStyles, MessageBar, MessageBarBody, Subtitle2, tokens } from "@fluentui/react-components";
|
||||
import { ArrowDownload24Regular, ArrowUpload24Regular } from "@fluentui/react-icons";
|
||||
import { ArrowDownload20Regular, ArrowUpload20Regular } from "@fluentui/react-icons";
|
||||
import importBookmarks from "../utils/importBookmarks";
|
||||
import exportBookmarks from "../utils/exportBookmarks";
|
||||
|
||||
@@ -39,10 +39,10 @@ export default function BookmarksSection(): React.ReactElement
|
||||
}
|
||||
|
||||
<div className={ cls.buttons }>
|
||||
<Button icon={ <ArrowDownload24Regular /> } onClick={ exportBookmarks }>
|
||||
<Button icon={ <ArrowDownload20Regular /> } onClick={ exportBookmarks }>
|
||||
{ i18n.t("features.netscape_bookmarks.export") }
|
||||
</Button>
|
||||
<Button icon={ <ArrowUpload24Regular /> } onClick={ handleImport }>
|
||||
<Button icon={ <ArrowUpload20Regular /> } onClick={ handleImport }>
|
||||
{ i18n.t("features.netscape_bookmarks.import") }
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -19,7 +19,7 @@ export default function convertBookmarks(bookmarks: Bookmark[]): [CollectionItem
|
||||
untitled.items.push(getTab(bookmark, graphics));
|
||||
count++;
|
||||
}
|
||||
else if (bookmark.type === "folder" && bookmark.children)
|
||||
else if (bookmark.type === "folder")
|
||||
{
|
||||
const collection: CollectionItem = getCollection(bookmark, graphics);
|
||||
items.push(collection);
|
||||
@@ -34,6 +34,9 @@ export default function convertBookmarks(bookmarks: Bookmark[]): [CollectionItem
|
||||
}
|
||||
}
|
||||
|
||||
if (untitled.items.length > 0)
|
||||
items.unshift(untitled);
|
||||
|
||||
return [items, graphics, count];
|
||||
}
|
||||
|
||||
@@ -60,13 +63,14 @@ function getCollection(bookmark: Bookmark, graphics: GraphicsStorage): Collectio
|
||||
type: "collection"
|
||||
};
|
||||
|
||||
for (const child of bookmark.children!)
|
||||
{
|
||||
if (child.type === "bookmark")
|
||||
collection.items.push(getTab(child, graphics));
|
||||
else if (child.type === "folder" && child.children)
|
||||
collection.items.push(getGroup(child, graphics));
|
||||
}
|
||||
if (bookmark.children)
|
||||
for (const child of bookmark.children)
|
||||
{
|
||||
if (child.type === "bookmark")
|
||||
collection.items.push(getTab(child, graphics));
|
||||
else if (child.type === "folder" && child.children)
|
||||
collection.items.push(getGroup(child, graphics));
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
@@ -81,13 +85,14 @@ function getGroup(bookmark: Bookmark, graphics: GraphicsStorage): GroupItem
|
||||
color: getRandomColor()
|
||||
};
|
||||
|
||||
for (const child of bookmark.children!)
|
||||
{
|
||||
if (child.type === "bookmark")
|
||||
group.items.push(getTab(child, graphics));
|
||||
else if (child.type === "folder")
|
||||
group.items.push(...getGroup(child, graphics).items);
|
||||
}
|
||||
if (bookmark.children)
|
||||
for (const child of bookmark.children)
|
||||
{
|
||||
if (child.type === "bookmark")
|
||||
group.items.push(getTab(child, graphics));
|
||||
else if (child.type === "folder")
|
||||
group.items.push(...getGroup(child, graphics).items);
|
||||
}
|
||||
|
||||
return group;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ function createFolder(item: CollectionItem | GroupItem): string[]
|
||||
for (const subItem of item.items)
|
||||
{
|
||||
if (subItem.type === "tab")
|
||||
lines.push(`<DT><A HREF="${encodeURI(subItem.url)}">${sanitizeString(subItem.title || subItem.url)}</A>`);
|
||||
lines.push(`<DT><A HREF="${encodeURI(subItem.url).replace(/"/g, "%22")}">${sanitizeString(subItem.title || subItem.url)}</A>`);
|
||||
else if (subItem.type === "group")
|
||||
lines.push(...createFolder(subItem));
|
||||
}
|
||||
@@ -61,5 +61,9 @@ function createFolder(item: CollectionItem | GroupItem): string[]
|
||||
|
||||
function sanitizeString(str: string): string
|
||||
{
|
||||
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
||||
return str
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user