diff --git a/apps/desktop/changelog/next.md b/apps/desktop/changelog/next.md
index 17888d80b..6bfddc1ff 100644
--- a/apps/desktop/changelog/next.md
+++ b/apps/desktop/changelog/next.md
@@ -2,6 +2,8 @@
## New Features
+- Cubox integration (#3385)
+
## Improvements
## Bug Fixes
diff --git a/apps/desktop/src/renderer/src/hooks/biz/useEntryActions.tsx b/apps/desktop/src/renderer/src/hooks/biz/useEntryActions.tsx
index ce805d9e3..fbdc44319 100644
--- a/apps/desktop/src/renderer/src/hooks/biz/useEntryActions.tsx
+++ b/apps/desktop/src/renderer/src/hooks/biz/useEntryActions.tsx
@@ -122,6 +122,10 @@ export const useEntryActions = ({ entryId, view }: { entryId: string; view?: Fee
id: COMMAND_ID.integration.saveToReadeck,
onClick: runCmdFn(COMMAND_ID.integration.saveToReadeck, [{ entryId }]),
},
+ {
+ id: COMMAND_ID.integration.saveToCubox,
+ onClick: runCmdFn(COMMAND_ID.integration.saveToCubox, [{ entryId }]),
+ },
{
id: COMMAND_ID.entry.tip,
onClick: runCmdFn(COMMAND_ID.entry.tip, [
diff --git a/apps/desktop/src/renderer/src/modules/command/commands/id.ts b/apps/desktop/src/renderer/src/modules/command/commands/id.ts
index dc68451b7..c9dfb03a5 100644
--- a/apps/desktop/src/renderer/src/modules/command/commands/id.ts
+++ b/apps/desktop/src/renderer/src/modules/command/commands/id.ts
@@ -20,6 +20,7 @@ export const COMMAND_ID = {
saveToObsidian: "integration:save-to-obsidian",
saveToOutline: "integration:save-to-outline",
saveToReadeck: "integration:save-to-readeck",
+ saveToCubox: "integration:save-to-cubox",
},
list: {
edit: "list:edit",
diff --git a/apps/desktop/src/renderer/src/modules/command/commands/integration.tsx b/apps/desktop/src/renderer/src/modules/command/commands/integration.tsx
index 1511a75d5..52055fc20 100644
--- a/apps/desktop/src/renderer/src/modules/command/commands/integration.tsx
+++ b/apps/desktop/src/renderer/src/modules/command/commands/integration.tsx
@@ -1,4 +1,5 @@
import {
+ SimpleIconsCubox,
SimpleIconsEagle,
SimpleIconsInstapaper,
SimpleIconsObsidian,
@@ -33,6 +34,7 @@ export const useRegisterIntegrationCommands = () => {
useRegisterObsidianCommands()
useRegisterOutlineCommands()
useRegisterReadeckCommands()
+ useRegisterCuboxCommands()
}
const useRegisterEagleCommands = () => {
@@ -453,3 +455,87 @@ const useRegisterReadeckCommands = () => {
},
)
}
+
+const useRegisterCuboxCommands = () => {
+ const { t } = useTranslation()
+
+ const enableCubox = useIntegrationSettingKey("enableCubox")
+ const cuboxToken = useIntegrationSettingKey("cuboxToken")
+ const enableCuboxAutoMemo = useIntegrationSettingKey("enableCuboxAutoMemo")
+ const cuboxAvailable = enableCubox && !!cuboxToken
+
+ const buildUrlRequestBody = (entry: FlatEntryModel) => {
+ return {
+ type: "url",
+ content: entry.entries.url || "",
+ title: entry.entries.title || "",
+ description: entry.entries.description || "",
+ tags: [],
+ folder: "",
+ }
+ }
+
+ const buildMemoRequestBody = (entry: FlatEntryModel, selectedText: string) => {
+ return {
+ type: "memo",
+ content: selectedText,
+ title: entry.entries.title || "",
+ description: entry.entries.description || "",
+ tags: [],
+ folder: "",
+ source_url: entry.entries.url,
+ }
+ }
+
+ useRegisterCommandEffect(
+ !cuboxAvailable
+ ? []
+ : defineFollowCommand({
+ id: COMMAND_ID.integration.saveToCubox,
+ label: t("entry_actions.save_to_cubox"),
+ icon: ,
+ run: async ({ entryId }) => {
+ const entry = useEntryStore.getState().flatMapEntries[entryId]
+ if (!entry) {
+ toast.error("Failed to save to Cubox: entry is not available", { duration: 3000 })
+ return
+ }
+ try {
+ tracker.integration({
+ type: "cubox",
+ event: "save",
+ })
+
+ const selectedText = window.getSelection()?.toString() || ""
+
+ const requestBody =
+ selectedText && enableCuboxAutoMemo
+ ? buildMemoRequestBody(entry, selectedText)
+ : buildUrlRequestBody(entry)
+
+ await ofetch(cuboxToken, {
+ method: "POST",
+ body: requestBody,
+ headers: {
+ "Content-Type": "application/json",
+ },
+ })
+
+ toast.success(t("entry_actions.saved_to_cubox"), {
+ duration: 3000,
+ })
+ } catch (error) {
+ toast.error(
+ `${t("entry_actions.failed_to_save_to_cubox")}: ${(error as FetchError)?.message || ""}`,
+ {
+ duration: 3000,
+ },
+ )
+ }
+ },
+ }),
+ {
+ deps: [cuboxAvailable, cuboxToken, enableCuboxAutoMemo],
+ },
+ )
+}
diff --git a/apps/desktop/src/renderer/src/modules/command/commands/types.ts b/apps/desktop/src/renderer/src/modules/command/commands/types.ts
index dd3d83653..71e028ff7 100644
--- a/apps/desktop/src/renderer/src/modules/command/commands/types.ts
+++ b/apps/desktop/src/renderer/src/modules/command/commands/types.ts
@@ -120,6 +120,11 @@ export type SaveToReadeckCommand = Command<{
fn: (payload: { entryId: string }) => void
}>
+export type SaveToCuboxCommand = Command<{
+ id: typeof COMMAND_ID.integration.saveToCubox
+ fn: (payload: { entryId: string }) => void
+}>
+
export type IntegrationCommand =
| SaveToEagleCommand
| SaveToReadwiseCommand
@@ -127,5 +132,6 @@ export type IntegrationCommand =
| SaveToObsidianCommand
| SaveToOutlineCommand
| SaveToReadeckCommand
+ | SaveToCuboxCommand
export type BasicCommand = EntryCommand | SettingsCommand | IntegrationCommand
diff --git a/apps/desktop/src/renderer/src/modules/settings/tabs/integration.tsx b/apps/desktop/src/renderer/src/modules/settings/tabs/integration.tsx
index d4ae60921..a12d31158 100644
--- a/apps/desktop/src/renderer/src/modules/settings/tabs/integration.tsx
+++ b/apps/desktop/src/renderer/src/modules/settings/tabs/integration.tsx
@@ -1,5 +1,6 @@
import { Divider } from "@follow/components/ui/divider/index.js"
import {
+ SimpleIconsCubox,
SimpleIconsEagle,
SimpleIconsInstapaper,
SimpleIconsObsidian,
@@ -174,6 +175,41 @@ export const SettingIntegration = () => {
type: "password",
description: t("integration.readeck.token.description"),
}),
+ {
+ type: "title",
+ value: (
+
+
+ {t("integration.cubox.title")}
+
+ ),
+ },
+ defineSettingItem("enableCubox", {
+ label: t("integration.cubox.enable.label"),
+ description: t("integration.cubox.enable.description"),
+ }),
+ defineSettingItem("cuboxToken", {
+ label: t("integration.cubox.token.label"),
+ vertical: true,
+ type: "password",
+ description: (
+ <>
+ {t("integration.cubox.token.description")}{" "}
+
+ https://cubox.pro/my/settings/extensions
+
+ >
+ ),
+ }),
+ defineSettingItem("enableCuboxAutoMemo", {
+ label: t("integration.cubox.autoMemo.label"),
+ description: t("integration.cubox.autoMemo.description"),
+ }),
BottomTip,
]}
/>
diff --git a/locales/app/en.json b/locales/app/en.json
index 694ff32e1..232f191c6 100644
--- a/locales/app/en.json
+++ b/locales/app/en.json
@@ -89,6 +89,7 @@
"entry_actions.deleted": "Deleted.",
"entry_actions.export_as_pdf": "Export as PDF",
"entry_actions.failed_to_delete": "Failed to delete.",
+ "entry_actions.failed_to_save_to_cubox": "Failed to save to Cubox.",
"entry_actions.failed_to_save_to_eagle": "Failed to save to Eagle.",
"entry_actions.failed_to_save_to_instapaper": "Failed to save to Instapaper.",
"entry_actions.failed_to_save_to_obsidian": "Failed to save to Obsidian",
@@ -101,11 +102,13 @@
"entry_actions.open_in_browser": "Open In {{which}}",
"entry_actions.recent_reader": "Recent reader:",
"entry_actions.save_media_to_eagle": "Save Media To Eagle",
+ "entry_actions.save_to_cubox": "Save to Cubox",
"entry_actions.save_to_instapaper": "Save To Instapaper",
"entry_actions.save_to_obsidian": "Save to Obsidian",
"entry_actions.save_to_outline": "Save To Outline",
"entry_actions.save_to_readeck": "Save To Readeck",
"entry_actions.save_to_readwise": "Save To Readwise",
+ "entry_actions.saved_to_cubox": "Saved to Cubox",
"entry_actions.saved_to_eagle": "Saved To Eagle.",
"entry_actions.saved_to_instapaper": "Saved To Instapaper.",
"entry_actions.saved_to_obsidian": "Saved to Obsidian",
diff --git a/locales/app/zh-CN.json b/locales/app/zh-CN.json
index 92819e909..97fb8aa36 100644
--- a/locales/app/zh-CN.json
+++ b/locales/app/zh-CN.json
@@ -89,6 +89,7 @@
"entry_actions.deleted": "已删除",
"entry_actions.export_as_pdf": "导出为 PDF",
"entry_actions.failed_to_delete": "删除失败",
+ "entry_actions.failed_to_save_to_cubox": "保存到 Cubox 失败。",
"entry_actions.failed_to_save_to_eagle": "保存到 Eagle 失败。",
"entry_actions.failed_to_save_to_instapaper": "保存到 Instapaper 失败。",
"entry_actions.failed_to_save_to_obsidian": "保存到 Obsidian 失败。",
@@ -106,6 +107,7 @@
"entry_actions.save_to_outline": "保存到 Outline",
"entry_actions.save_to_readeck": "保存到 Readeck",
"entry_actions.save_to_readwise": "保存到 Readwise",
+ "entry_actions.saved_to_cubox": "已保存到 Cubox",
"entry_actions.saved_to_eagle": "已保存到 Eagle。",
"entry_actions.saved_to_instapaper": "已保存到 Instapaper。",
"entry_actions.saved_to_obsidian": "已保存到 Obsidian。",
diff --git a/locales/settings/en.json b/locales/settings/en.json
index cfaf6c0d2..b812fd505 100644
--- a/locales/settings/en.json
+++ b/locales/settings/en.json
@@ -220,6 +220,13 @@
"general.timeline": "Timeline",
"general.unread": "Unread",
"general.voices": "Voices",
+ "integration.cubox.autoMemo.description": "Automatically use Memo mode when text is selected to save to Cubox.",
+ "integration.cubox.autoMemo.label": "Auto Memo Mode",
+ "integration.cubox.enable.description": "Show 'Save to Cubox' button if available.",
+ "integration.cubox.enable.label": "Enable",
+ "integration.cubox.title": "Cubox",
+ "integration.cubox.token.description": "Please enter the complete Cubox API URL, format: https://cubox.pro/c/api/save/xxxxxxxxx. You can get it here: ",
+ "integration.cubox.token.label": "Cubox API URL",
"integration.eagle.enable.description": "Display 'Save media to Eagle' button when available.",
"integration.eagle.enable.label": "Enable",
"integration.eagle.title": "Eagle",
diff --git a/locales/settings/zh-CN.json b/locales/settings/zh-CN.json
index d0eb7384b..07569d78e 100644
--- a/locales/settings/zh-CN.json
+++ b/locales/settings/zh-CN.json
@@ -220,6 +220,13 @@
"general.timeline": "时间线",
"general.unread": "未读",
"general.voices": "声音",
+ "integration.cubox.autoMemo.description": "自动使用 Memo 模式保存选中的文本到 Cubox。",
+ "integration.cubox.autoMemo.label": "自动 Memo 模式",
+ "integration.cubox.enable.description": "显示「保存到 Cubox」按钮(如果可用)。",
+ "integration.cubox.enable.label": "启用",
+ "integration.cubox.title": "Cubox",
+ "integration.cubox.token.description": "请输入完整的 Cubox API URL,格式如:https://cubox.pro/c/api/save/xxxxxxxxx。你可以在此获取:",
+ "integration.cubox.token.label": "Cubox API URL",
"integration.eagle.enable.description": "显示「保存到 Eagle」按钮(如果可用)。",
"integration.eagle.enable.label": "启用",
"integration.eagle.title": "Eagle",
diff --git a/packages/components/src/ui/platform-icon/collections/cubox.tsx b/packages/components/src/ui/platform-icon/collections/cubox.tsx
new file mode 100644
index 000000000..ac95c8bc8
--- /dev/null
+++ b/packages/components/src/ui/platform-icon/collections/cubox.tsx
@@ -0,0 +1,24 @@
+import { cn } from "@follow/utils/utils"
+import type { SVGProps } from "react"
+
+export function SimpleIconsCubox({ className, ...props }: SVGProps) {
+ return (
+
+ )
+}
diff --git a/packages/components/src/ui/platform-icon/icons.ts b/packages/components/src/ui/platform-icon/icons.ts
index d5eba3fc9..5c4364467 100644
--- a/packages/components/src/ui/platform-icon/icons.ts
+++ b/packages/components/src/ui/platform-icon/icons.ts
@@ -1,3 +1,4 @@
+export * from "./collections/cubox"
export * from "./collections/eagle"
export * from "./collections/instapaper"
export * from "./collections/obsidian"
diff --git a/packages/shared/src/settings/defaults.ts b/packages/shared/src/settings/defaults.ts
index 200f21751..965d28b6a 100644
--- a/packages/shared/src/settings/defaults.ts
+++ b/packages/shared/src/settings/defaults.ts
@@ -114,6 +114,11 @@ export const defaultIntegrationSettings: IntegrationSettings = {
enableReadeck: false,
readeckEndpoint: "",
readeckToken: "",
+
+ // cubox
+ enableCubox: false,
+ cuboxToken: "",
+ enableCuboxAutoMemo: false,
}
export const defaultSettings = {
diff --git a/packages/shared/src/settings/interface.ts b/packages/shared/src/settings/interface.ts
index a5251b798..ed3d89442 100644
--- a/packages/shared/src/settings/interface.ts
+++ b/packages/shared/src/settings/interface.ts
@@ -100,4 +100,9 @@ export interface IntegrationSettings {
enableReadeck: boolean
readeckEndpoint: string
readeckToken: string
+
+ // cubox
+ enableCubox: boolean
+ cuboxToken: string
+ enableCuboxAutoMemo: boolean
}