-
Notifications
You must be signed in to change notification settings - Fork 2
Define and instantiate Obsidian node type #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define and instantiate Obsidian node type #94
Conversation
@trangdoan982 is attempting to deploy a commit to the Discourse Graphs Team on Vercel. A member of the Team first needs to authorize it. |
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughThe changes restructure the settings UI and functionality of the plugin. The existing Settings component is refactored to separate node type management into a dedicated subcomponent and to add hotkey input handling. A new settings tab class is introduced along with a modal for node type suggestions. Additionally, the settings structure is updated to include node types and hotkey definitions, and new types are defined to support these features. The control flow has been enhanced to allow dynamic updating and validation of node types and associated actions. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SettingsUI
participant Plugin
User->>SettingsUI: Opens settings tab
SettingsUI->>Plugin: Loads nodeTypes & hotkey settings
User->>SettingsUI: Updates node type or hotkey input
SettingsUI->>Plugin: Saves updated settings
sequenceDiagram
participant User
participant Editor
participant CommandHandler
participant Modal
User->>Editor: Triggers hotkey command (open-node-type-menu)
Editor->>CommandHandler: Command received to open node type menu
CommandHandler->>Modal: Instantiate NodeTypeModal
Modal->>User: Display node type suggestions
User->>Modal: Select a suggestion
Modal->>Editor: Insert formatted node type into editor
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (12)
apps/obsidian/src/types.ts (1)
10-14
: Settings type is concise and clear.
IncludingnodeTypeHotkey
accommodates advanced user interactions. Consider adding doc comments explaining each property.apps/obsidian/src/index.ts (3)
8-27
: Default Node Types are set properly.
The preset colors, shortcuts, and formats help unify usage. Consider validating color strings (e.g., hex or other formats) if input can be user-defined.
35-42
: Duplicate default settings may cause drift.
ReusingDEFAULT_SETTINGS
instead of redefining these properties avoids divergence.- settings: Settings = { - mySetting: "default", - nodeTypes: [], - nodeTypeHotkey: { - modifiers: ["Mod", "Shift"], - key: "Backslash", - }, - }; + settings: Settings = { ...DEFAULT_SETTINGS };
46-46
: Optional: remove or refine console log.
Consider a more descriptive message or using a plugin-wide logging pattern.apps/obsidian/src/components/SettingsTab.tsx (2)
21-42
: Creation of dynamic settings for nodeTypes.
Saving on each keystroke may affect performance if nodeTypes grow large. Consider adding a debounce if needed.
44-54
: Button for adding new node types is handy.
Optionally, you could pre-fill default format or name to guide users.apps/obsidian/src/components/Settings.tsx (3)
7-92
: NodeTypeSettings component.
Currently, it only usesname
andformat
; consider integrating optional color/shortcut to keep consistent withDiscourseNodeType
.
173-270
: Settings component ties everything together well.
You might unify save calls to reduce repeated async operations. Also consider more robust validations fornodeTypes
.
286-299
: Commented-out example code.
If no future use is intended, dropping it or relocating to docs may reduce clutter.apps/obsidian/src/utils/registerCommands.ts (3)
13-36
: Good implementation of NodeTypeModal.The NodeTypeModal class is well-structured and properly extends SuggestModal to provide node type selection functionality.
I do have one concern about potential edge cases in line 32:
- const heading = nodeType.format.split(" ")[0]; + const heading = nodeType.format.split(" ")[0] || nodeType.name;Consider adding a fallback to use the node type name if the format doesn't contain spaces, as this would make the code more robust.
58-58
: Remove debug console.log statement.This console.log statement appears to be for debugging purposes and should be removed before merging to production.
81-93
: Well-implemented node type menu command.The command implementation is clean and follows the pattern used for other commands in the file. Good job adding a user-friendly notice when no node types are configured.
Consider adding validation for the hotkey configuration:
- hotkeys: [plugin.settings.nodeTypeHotkey], + hotkeys: [plugin.settings.nodeTypeHotkey].filter(Boolean),This would ensure that even if the hotkey is undefined or null, the command will still function without errors.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/obsidian/src/components/Settings.tsx
(2 hunks)apps/obsidian/src/components/SettingsTab.tsx
(1 hunks)apps/obsidian/src/index.ts
(1 hunks)apps/obsidian/src/types.ts
(1 hunks)apps/obsidian/src/utils/registerCommands.ts
(3 hunks)
🔇 Additional comments (13)
apps/obsidian/src/types.ts (2)
1-2
: No issues with the import statement.
Looks straightforward and correct.
3-9
: Well-defined type for DiscourseNodeType.
Having optional fields (shortcut, color) offers flexibility without forcing every implementer to provide those fields.apps/obsidian/src/index.ts (2)
4-4
: Importing the typed Settings is appropriate.
No concerns; the source reference is well-organized.
28-31
: Hotkey defaults are consistent with typical shortcuts.
No issues here; it's a logical default.apps/obsidian/src/components/SettingsTab.tsx (4)
1-3
: Import statements are succinct and relevant.
All dependencies appear necessary.
4-11
: Straightforward class definition.
UsingPluginSettingTab
is the correct approach for an Obsidian plugin.
12-16
: Display method initializes properly.
Clearing the container and setting up headers is standard for Obsidian tabs.
18-19
: Clear “Node Types” heading.
Enhances user clarity when editing node types.apps/obsidian/src/components/Settings.tsx (3)
1-2
: Imports of React and Obsidian modules are correct.
No concerns at this stage.
94-171
: HotkeyInput component logic is clear.
You account for multiple modifiers—good approach. Ensure “Mod” is interpreted consistently on various platforms.Would you like me to provide a script to search the codebase for references to “Mod” usage across your plugin commands to confirm consistent handling?
306-307
: Rendering inside StrictMode.
Good practice for debugging and future React updates.apps/obsidian/src/utils/registerCommands.ts (2)
1-8
: Imports look good.The necessary imports from the Obsidian API have been added to support the new node type functionality.
11-11
: Type import is appropriately added.Good job importing the DiscourseNodeType from the types file to ensure type safety.
8f66152
to
d741288
Compare
d741288
to
2ee0d28
Compare
Here's a few things I noticed:
|
@mdroidian thanks for the feedback. to your points:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Summary by CodeRabbit
Settings panel
Instantiate a node