Skip to content

Commit

Permalink
Merge pull request #70 from n4ze3m/next
Browse files Browse the repository at this point in the history
v1.1.8
  • Loading branch information
n4ze3m committed May 18, 2024
2 parents 579d8ea + b87e91b commit dfaffa0
Show file tree
Hide file tree
Showing 20 changed files with 391 additions and 96 deletions.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ This will start a development server and watch for changes in the source files.
| Chrome ||||
| Brave ||||
| Firefox ||||
| Vivaldi ||||
| Edge ||||
| Opera GX ||||
| Opera ||||
| Arc ||||

## Local AI Provider
Expand All @@ -134,6 +135,13 @@ This will start a development server and watch for changes in the source files.
- [ ] More Customization Options
- [ ] Better UI/UX


## Privacy

Page Assist does not collect any personal data. The only time the extension communicates with the server is when you are using the share feature, which can be disabled from the settings.

All the data is stored locally in the browser storage. You can view the source code and verify it yourself.

## Contributing

Contributions are welcome. If you have any feature requests, bug reports, or questions, feel free to create an issue.
Expand All @@ -146,6 +154,17 @@ If you like the project and want to support it, you can buy me a coffee. It will

or you can sponsor me on GitHub.


## Blogs and Videos About Page Assist

This are some of the blogs and videos about Page Assist. If you have written a blog or made a video about Page Assist, feel free to create a PR and add it here.

- [OllamaをChromeAddonのPage Assistで簡単操作](https://note.com/lucas_san/n/nf00d01a02c3a) by [LucasChatGPT](https://twitter.com/LucasChatGPT)

- [This Chrome Extension Surprised Me](https://www.youtube.com/watch?v=IvLTlDy9G8c) by [Matt Williams](https://www.youtube.com/@technovangelist)

- [Ollama With 1 Click](https://www.youtube.com/watch?v=61uN5jtj2wo) by [Yaron Been From EcomXFactor](https://www.youtube.com/@ecomxfactor-YaronBeen)

## License

MIT
Expand Down
2 changes: 1 addition & 1 deletion src/assets/locale/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
"delete": "Are you sure you want to delete this share? This action cannot be undone."
},
"label": "Manage Page Share",
"description": "Enable or disable the page share feature. By default, the page share feature is enabled."
"description": "Enable or disable the page share feature"
},
"notification": {
"pageShareSuccess": "Page Share URL updated successfully",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/locale/ja-JP/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
"delete": "本当にこの共有を削除しますか?この操作は元に戻せません。"
},
"label": "ページ共有を管理する",
"description": "ページ共有機能を有効または無効にします。デフォルトでは、ページ共有機能は有効になっています。"
"description": "ページ共有機能を有効または無効にする"
},
"notification": {
"pageShareSuccess": "ページ共有URLが正常に更新されました",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/locale/ml/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
"delete": "ഈ പങ്കിടല്‍ ഇല്ലാതാക്കണമെന്ന് തീർച്ചയാണോ? ഈ പ്രവർത്തനം പിന്നീട് പിൻവലിക്കാനാകില്ല."
},
"label": "പേജ് ഷെയർ നിയന്ത്രിക്കുക",
"description": "പേജ് ഷെയർ സവിശേഷത സജീവമാക്കുകയോ അക്ഷമമാക്കുകയോ ചെയ്യുക. സ്ഥിരംമായി, പേജ് ഷെയർ സവിശേഷത സജീവമാക്കപ്പെടുന്നു."
"description": "പേജ് ഷെയർ സാങ്കേതികത സജ്ജീകരിക്കുക അല്ലെങ്കിൽ നിലവിളിക്കുക ."
},
"notification": {
"pageShareSuccess": "പേജ് പങ്കിടാനുള്ള URL വിജയകരമായി അപ്ഡേറ്റ് ചെയ്തു",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/locale/ru/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
"delete": "Вы уверены, что хотите удалить этот обмен? Это действие нельзя отменить."
},
"label": "Управление общим доступом к странице",
"description": "Включите или отключите функцию общего доступа к странице. По умолчанию функция общего доступа к странице включена."
"description": "Включить или отключить функцию обмена страницей"
},
"notification": {
"pageShareSuccess": "URL обмена страницей успешно обновлен",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/locale/zh/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
"delete": "您确定要删除此对话共享吗?这个操作不能撤销。"
},
"label": "管理页面分享",
"description": "启用或禁用页面分享功能。默认情况下,页面分享功能已启用。"
"description": "启用或禁用页面分享功能 "
},
"notification": {
"pageShareSuccess": "对话共享服务 URL 已成功更新",
Expand Down
90 changes: 90 additions & 0 deletions src/components/Common/PromptSelect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { useQuery } from "@tanstack/react-query"
import { Dropdown, Empty, Tooltip } from "antd"
import { BookIcon, ComputerIcon, ZapIcon } from "lucide-react"
import React from "react"
import { useTranslation } from "react-i18next"
import { getAllPrompts } from "@/db"
import { useMessageOption } from "@/hooks/useMessageOption"

export const PromptSelect: React.FC = () => {
const { t } = useTranslation("option")
const {
selectedSystemPrompt,
setSelectedQuickPrompt,
setSelectedSystemPrompt
} = useMessageOption()

const { data } = useQuery({
queryKey: ["getAllPromptsForSelect"],
queryFn: getAllPrompts
})
const handlePromptChange = (value?: string) => {
if (!value) {
setSelectedSystemPrompt(undefined)
setSelectedQuickPrompt(undefined)
return
}
const prompt = data?.find((prompt) => prompt.id === value)
if (prompt?.is_system) {
setSelectedSystemPrompt(prompt.id)
} else {
setSelectedSystemPrompt(undefined)
setSelectedQuickPrompt(prompt!.content)
}
}
return (
<>
{data && (
<Dropdown
menu={{
items:
data.length > 0
? data?.map((prompt) => ({
key: prompt.id,
label: (
<div className="w-52 gap-2 text-lg truncate inline-flex line-clamp-3 items-center dark:border-gray-700">
<span
key={prompt.title}
className="flex flex-row gap-3 items-center">
{prompt.is_system ? (
<ComputerIcon className="w-4 h-4" />
) : (
<ZapIcon className="w-4 h-4" />
)}
{prompt.title}
</span>
</div>
),
onClick: () => {
if (selectedSystemPrompt === prompt.id) {
setSelectedSystemPrompt(undefined)
} else {
handlePromptChange(prompt.id)
}
}
}))
: [
{
key: "empty",
label: <Empty />
}
],
style: {
maxHeight: 500,
overflowY: "scroll"
},
className: "no-scrollbar",
activeKey: selectedSystemPrompt
}}
placement={"topLeft"}
trigger={["click"]}>
<Tooltip title={t("selectAPrompt")}>
<button type="button" className="dark:text-gray-300">
<BookIcon className="h-5 w-5" />
</button>
</Tooltip>
</Dropdown>
)}
</>
)
}
27 changes: 19 additions & 8 deletions src/components/Layouts/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
ComputerIcon,
GithubIcon,
PanelLeftIcon,
SlashIcon,
SquarePen,
ZapIcon
} from "lucide-react"
Expand All @@ -21,6 +22,8 @@ import { useTranslation } from "react-i18next"
import { OllamaIcon } from "../Icons/Ollama"
import { SelectedKnowledge } from "../Option/Knowledge/SelectedKnwledge"
import { useStorage } from "@plasmohq/storage/hook"
import { ModelSelect } from "../Common/ModelSelect"
import { PromptSelect } from "../Common/PromptSelect"

export default function OptionLayout({
children
Expand All @@ -29,7 +32,7 @@ export default function OptionLayout({
}) {
const [sidebarOpen, setSidebarOpen] = useState(false)
const { t } = useTranslation(["option", "common"])
const [shareModeEnabled] = useStorage("shareMode", true)
const [shareModeEnabled] = useStorage("shareMode", false)

const {
selectedModel,
Expand Down Expand Up @@ -89,7 +92,7 @@ export default function OptionLayout({
<NavLink
to="/"
className="text-gray-500 items-center dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors">
<ChevronLeft className="w-6 h-6" />
<ChevronLeft className="w-4 h-4" />
</NavLink>
</div>
)}
Expand All @@ -103,15 +106,17 @@ export default function OptionLayout({
<div>
<button
onClick={clearChat}
className="inline-flex dark:bg-transparent bg-white items-center rounded-lg border dark:border-gray-700 bg-transparent px-3 py-3 text-sm font-medium leading-4 text-gray-800 dark:text-white disabled:opacity-50 ease-in-out transition-colors duration-200 hover:bg-gray-100 dark:hover:bg-gray-800 dark:hover:text-white">
<SquarePen className="h-4 w-4 mr-3" />
{t("newChat")}
className="inline-flex dark:bg-transparent bg-white items-center rounded-lg border dark:border-gray-700 bg-transparent px-3 py-2.5 text-xs lg:text-sm font-medium leading-4 text-gray-800 dark:text-white disabled:opacity-50 ease-in-out transition-colors duration-200 hover:bg-gray-100 dark:hover:bg-gray-800 dark:hover:text-white">
<SquarePen className="h-5 w-5 " />
<span className=" truncate ml-3">
{t("newChat")}
</span>
</button>
</div>
<span className="text-lg font-thin text-zinc-300 dark:text-zinc-600">
{"/"}
</span>
<div>
<div className="hidden lg:block">
<Select
value={selectedModel}
onChange={(e) => {
Expand Down Expand Up @@ -141,10 +146,13 @@ export default function OptionLayout({
}))}
/>
</div>
<div className="lg:hidden">
<ModelSelect />
</div>
<span className="text-lg font-thin text-zinc-300 dark:text-zinc-600">
{"/"}
</span>
<div>
<div className="hidden lg:block">
<Select
size="large"
loading={isPromptLoading}
Expand Down Expand Up @@ -177,6 +185,9 @@ export default function OptionLayout({
}))}
/>
</div>
<div className="lg:hidden">
<PromptSelect />
</div>
<SelectedKnowledge />
</div>
<div className="flex flex-1 justify-end px-4">
Expand All @@ -190,7 +201,7 @@ export default function OptionLayout({
<a
href="https://github.com/n4ze3m/page-assist"
target="_blank"
className="!text-gray-500 dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors">
className="!text-gray-500 hidden lg:block dark:text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors">
<GithubIcon className="w-6 h-6" />
</a>
</Tooltip>
Expand Down
15 changes: 10 additions & 5 deletions src/components/Option/Knowledge/SelectedKnwledge.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Blocks, XIcon } from "lucide-react"
import { useMessageOption } from "@/hooks/useMessageOption"
import { Tooltip } from "antd"

export const SelectedKnowledge = () => {
const { selectedKnowledge: knowledge, setSelectedKnowledge } =
Expand All @@ -8,17 +9,21 @@ export const SelectedKnowledge = () => {
if (!knowledge) return <></>

return (
<div className="flex flex-row items-center gap-3">
<div className="flex flex-row items-center gap-3">
<span className="text-lg font-thin text-zinc-300 dark:text-zinc-600">
{"/"}
</span>
<div className="border flex justify-between items-center rounded-full px-2 py-1 gap-2 bg-gray-100 dark:bg-slate-800 dark:border-slate-700">
<div className="inline-flex items-center gap-2">
<Blocks className="h-5 w-5 text-gray-400" />
<span className="text-xs font-semibold dark:text-gray-100">
<div className="border flex justify-between items-center rounded-full px-2 py-1 gap-2 bg-gray-100 dark:bg-slate-800 dark:border-slate-700">
<Tooltip
title={knowledge.title}
>
<div className="inline-flex truncate items-center gap-2">
<Blocks className="h-5 w-5 text-gray-400" />
<span className="text-xs hidden lg:inline-block font-semibold dark:text-gray-100">
{knowledge.title}
</span>
</div>
</Tooltip>
<div>
<button
onClick={() => setSelectedKnowledge(null)}
Expand Down
6 changes: 5 additions & 1 deletion src/components/Option/Models/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ export const ModelsBody = () => {
{status === "pending" && <Skeleton paragraph={{ rows: 8 }} />}

{status === "success" && (
<Table
<div
className="overflow-x-auto"
>
<Table
columns={[
{
title: t("manageModels.columns.name"),
Expand Down Expand Up @@ -207,6 +210,7 @@ export const ModelsBody = () => {
dataSource={data}
rowKey={(record) => `${record.model}-${record.digest}`}
/>
</div>
)}
</div>

Expand Down
7 changes: 6 additions & 1 deletion src/components/Option/Playground/PlaygroundForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
}
}
}

const handlePaste = (e: React.ClipboardEvent) => {
if (e.clipboardData.files.length > 0) {
onInputChange(e.clipboardData.files[0])
}
}
React.useEffect(() => {
if (dropedFile) {
onInputChange(dropedFile)
Expand Down Expand Up @@ -219,6 +223,7 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
ref={textareaRef}
className="px-2 py-2 w-full resize-none bg-transparent focus-within:outline-none focus:ring-0 focus-visible:ring-0 ring-0 dark:ring-0 border-0 dark:text-gray-100"
required
onPaste={handlePaste}
rows={1}
style={{ minHeight: "60px" }}
tabIndex={0}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Option/Settings/other.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const SettingOther = () => {

if (confirm) {
const db = new PageAssitDatabase()
await db.deleteChatHistory()
await db.deleteAllChatHistory()
queryClient.invalidateQueries({
queryKey: ["fetchChatHistory"]
})
Expand Down
13 changes: 10 additions & 3 deletions src/components/Option/Share/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import { useStorage } from "@plasmohq/storage/hook"
export const OptionShareBody = () => {
const queryClient = useQueryClient()
const { t } = useTranslation(["settings"])
const [shareModeEnabled, setShareModelEnabled] = useStorage("shareMode", true)
const [shareModeEnabled, setShareModelEnabled] = useStorage(
"shareMode",
false
)

const { status, data } = useQuery({
queryKey: ["fetchShareInfo"],
Expand All @@ -25,8 +28,12 @@ export const OptionShareBody = () => {
})

const onSubmit = async (values: { url: string }) => {
const isOk = await verifyPageShareURL(values.url)
if (isOk) {
if (shareModeEnabled) {
const isOk = await verifyPageShareURL(values.url)
if (isOk) {
await setPageShareUrl(values.url)
}
} else {
await setPageShareUrl(values.url)
}
}
Expand Down
Loading

0 comments on commit dfaffa0

Please sign in to comment.