diff --git a/apps/obsidian/src/components/AdminPanelSettings.tsx b/apps/obsidian/src/components/AdminPanelSettings.tsx new file mode 100644 index 000000000..80e24ce8e --- /dev/null +++ b/apps/obsidian/src/components/AdminPanelSettings.tsx @@ -0,0 +1,34 @@ +import { useState } from "react"; +import { usePlugin } from "./PluginContext"; +import { Notice } from "obsidian"; + +export const AdminPanelSettings = () => { + const plugin = usePlugin(); + const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false); + + const handleSave = async () => { + await plugin.saveSettings(); + new Notice("Admin panel settings saved"); + setHasUnsavedChanges(false); + }; + + return ( +
+ {/* Add more admin panel settings sections here */} + +
+ +
+ + {hasUnsavedChanges && ( +
You have unsaved changes
+ )} +
+ ); +}; diff --git a/apps/obsidian/src/components/Settings.tsx b/apps/obsidian/src/components/Settings.tsx index bb40f3ef1..cb93ba49a 100644 --- a/apps/obsidian/src/components/Settings.tsx +++ b/apps/obsidian/src/components/Settings.tsx @@ -1,4 +1,4 @@ -import { StrictMode, useState } from "react"; +import { StrictMode, useState, useEffect } from "react"; import { App, PluginSettingTab } from "obsidian"; import type DiscourseGraphPlugin from "~/index"; import { Root, createRoot } from "react-dom/client"; @@ -7,11 +7,26 @@ import RelationshipTypeSettings from "./RelationshipTypeSettings"; import RelationshipSettings from "./RelationshipSettings"; import NodeTypeSettings from "./NodeTypeSettings"; import GeneralSettings from "./GeneralSettings"; +import { AdminPanelSettings } from "./AdminPanelSettings"; import { PluginProvider } from "./PluginContext"; const Settings = () => { const [activeTab, setActiveTab] = useState("general"); + useEffect(() => { + const handleKeyPress = (e: KeyboardEvent) => { + const isMod = e.metaKey || e.ctrlKey; + if (isMod && e.shiftKey && e.key.toLowerCase() === "a") { + e.stopPropagation(); + e.preventDefault(); + setActiveTab("admin-panel"); + } + }; + + window.addEventListener("keydown", handleKeyPress); + return () => window.removeEventListener("keydown", handleKeyPress); + }, []); + return (

Discourse Graph Settings

@@ -56,6 +71,12 @@ const Settings = () => { > Discourse Relations + {/* Hidden Admin Panel tab - only visible when activeTab is "admin-panel" */} + {activeTab === "admin-panel" && ( + + )}
{activeTab === "general" && } @@ -63,6 +84,7 @@ const Settings = () => { {activeTab === "relationTypes" && } {activeTab === "relations" && } {activeTab === "frontmatter" && } + {activeTab === "admin-panel" && } ); }; diff --git a/apps/obsidian/src/constants.ts b/apps/obsidian/src/constants.ts index 432649d51..59fc5564b 100644 --- a/apps/obsidian/src/constants.ts +++ b/apps/obsidian/src/constants.ts @@ -71,6 +71,13 @@ export const DEFAULT_SETTINGS: Settings = { canvasAttachmentsFolderPath: "attachments", nodeTagHotkey: "\\", }; + +export const FEATURE_FLAGS = { + // settings for these features are in the Admin Panel (hidden tab in Settings, toggle with Ctrl+Shift+A) + DATABASE_SYNC: "databaseSync", +} as const; + +export type FeatureFlagKey = (typeof FEATURE_FLAGS)[keyof typeof FEATURE_FLAGS]; export const FRONTMATTER_KEY = "tldr-dg"; export const TLDATA_DELIMITER_START = "!!!_START_OF_TLDRAW_DG_DATA__DO_NOT_CHANGE_THIS_PHRASE_!!!"; diff --git a/apps/obsidian/src/utils/registerCommands.ts b/apps/obsidian/src/utils/registerCommands.ts index 1ab7fb382..67c629703 100644 --- a/apps/obsidian/src/utils/registerCommands.ts +++ b/apps/obsidian/src/utils/registerCommands.ts @@ -51,10 +51,10 @@ export const registerCommands = (plugin: DiscourseGraphPlugin) => { } else { await createDiscourseNode({ plugin, - nodeType, - text: title, - editor, - }); + nodeType, + text: title, + editor, + }); } }, }).open();