diff --git a/apps/obsidian/package.json b/apps/obsidian/package.json index 4cb48a41d..c8171caee 100644 --- a/apps/obsidian/package.json +++ b/apps/obsidian/package.json @@ -36,11 +36,12 @@ "zod": "^3.24.1" }, "dependencies": { + "@codemirror/view": "^6.38.8", + "date-fns": "^4.1.0", "nanoid": "^4.0.2", "react": "catalog:obsidian", "react-dom": "catalog:obsidian", - "date-fns": "^4.1.0", "tailwindcss-animate": "^1.0.7", "tldraw": "3.14.2" } -} +} \ No newline at end of file diff --git a/apps/obsidian/src/components/GeneralSettings.tsx b/apps/obsidian/src/components/GeneralSettings.tsx index 0389d93ae..9adf78467 100644 --- a/apps/obsidian/src/components/GeneralSettings.tsx +++ b/apps/obsidian/src/components/GeneralSettings.tsx @@ -154,6 +154,9 @@ const GeneralSettings = () => { ); const [canvasAttachmentsFolderPath, setCanvasAttachmentsFolderPath] = useState(plugin.settings.canvasAttachmentsFolderPath); + const [nodeTagHotkey, setNodeTagHotkey] = useState( + plugin.settings.nodeTagHotkey, + ); const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false); const handleToggleChange = (newValue: boolean) => { @@ -179,11 +182,20 @@ const GeneralSettings = () => { [], ); + const handleNodeTagHotkeyChange = useCallback((newValue: string) => { + // Only allow single character + if (newValue.length <= 1) { + setNodeTagHotkey(newValue); + setHasUnsavedChanges(true); + } + }, []); + const handleSave = async () => { plugin.settings.showIdsInFrontmatter = showIdsInFrontmatter; plugin.settings.nodesFolderPath = nodesFolderPath; plugin.settings.canvasFolderPath = canvasFolderPath; plugin.settings.canvasAttachmentsFolderPath = canvasAttachmentsFolderPath; + plugin.settings.nodeTagHotkey = nodeTagHotkey || ""; await plugin.saveSettings(); new Notice("General settings saved"); setHasUnsavedChanges(false); @@ -262,6 +274,35 @@ const GeneralSettings = () => { +
+
+
Node tag hotkey
+
+ Key to press after a space to open the node tags menu. Default: + "\". +
+
+
+ handleNodeTagHotkeyChange(e.target.value)} + onKeyDown={(e) => { + // Capture the key pressed + if (e.key.length === 1) { + e.preventDefault(); + handleNodeTagHotkeyChange(e.key); + } else if (e.key === "Backspace") { + handleNodeTagHotkeyChange(""); + } + }} + placeholder="\\" + maxLength={1} + className="setting-item-control" + /> +
+
+