Skip to content
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

feat(settings): add toggle for relative path #386

Merged
merged 3 commits into from
Mar 4, 2025
Merged

Conversation

Mara-Li
Copy link
Member

@Mara-Li Mara-Li commented Mar 4, 2025

  • Allow to enable or disabling the relative path creation when a path is created between two files.
  • To allow absolute (or not) path, add a settings for prefixing text . By default, use / for absolute path. Can be disabled when empty. This settings only appear if relative path is disabled.

Output:
Before:

[[../_pages/my-digital-workbench|_pages/my-digital-workbench]]
[[./_posts/2022-10-15-jekyll-with-obsidian|guide/_posts/2022-10-15-jekyll-with-obsidian]]

After :

[[/hidden/_pages/my-digital-workbench|_pages/my-digital-workbench]]

[[/hidden/guide/_posts/2022-10-15-jekyll-with-obsidian|guide/_posts/2022-10-15-jekyll-with-obsidian]]

Relative to #384

Copy link

coderabbitai bot commented Mar 4, 2025

Walkthrough

The changes update the handling of link paths and settings across multiple files. A new conditional in the createRelativePath function returns a custom link when relative paths are disabled. Default and type configurations for link settings now include relativePath and textPrefix properties. Additionally, the HTML rendering in the settings tab has been improved by switching to sanitizeHTMLToDom, and minor documentation was added in the status bar code.

Changes

File(s) Change Summary
src/conversion/file_path.ts Refactored import of EnveloppeSettings and added a new conditional branch in createRelativePath to return a custom link object when relative paths are disabled.
src/interfaces/constant.ts,
src/interfaces/settings.ts
Added relativePath (boolean) and textPrefix (string) properties to the links configuration in both default settings and the Conversion interface.
src/settings.ts Updated renderTextConversion in EnveloppeSettingsTab to use sanitizeHTMLToDom for HTML creation and modified the control flow for handling internal link settings.
src/utils/status_bar.ts Added a lint ignore comment before querying the active document in the finish method of ShareStatusBar.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Function Caller
    participant FP as createRelativePath
    participant Settings as Settings Object

    Caller->>FP: Call createRelativePath(settings, targetPath)
    alt relativePath is disabled
        FP->>FP: Return { link: settings.textPrefix + targetPath }
    else
        FP->>FP: Process normal logic branch
    end
Loading
sequenceDiagram
    participant User as End User
    participant EST as EnveloppeSettingsTab
    participant Sanitizer as sanitizeHTMLToDom

    User->>EST: Trigger renderTextConversion
    EST->>Sanitizer: Create HTML for text conversion description
    alt shareAll disabled
        EST->>Sanitizer: Create HTML for relative path settings
    end
    EST->>User: Render updated settings UI
Loading

Poem

I'm a happy rabbit on a coding spree, 🐰
Hopping through conditionals with joyful glee.
New paths and prefixes in the code do bloom,
Sanitized and branching, banishing the gloom.
With each clever line I waddle and spin,
Celebrating change—let the updates begin!
🥕 Happy coding days from my burrow within!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3432ab and ad87bee.

📒 Files selected for processing (1)
  • src/utils/status_bar.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/utils/status_bar.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript-typescript)

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Mara-Li Mara-Li self-assigned this Mar 4, 2025
@Mara-Li Mara-Li added the [AI] To auto review with AI label Mar 4, 2025
@Mara-Li
Copy link
Member Author

Mara-Li commented Mar 4, 2025

@coderabbitai review

Copy link

coderabbitai bot commented Mar 4, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Mara-Li Mara-Li requested a review from Copilot March 4, 2025 09:08
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR introduces a new settings toggle to allow disabling relative path creation and specifying a text prefix (by default "/") for file paths. Key changes include:

  • Adding a new toggle and text input in the settings page for configuring relative path behavior.
  • Adjusting file path generation to use a customizable text prefix when relative path is disabled.
  • Updating interfaces and default settings to support the new configuration.

Reviewed Changes

File Description
src/settings.ts Added UI elements for relative path toggle and text prefix input to the settings page.
src/conversion/file_path.ts Updated path creation logic to check the new relativePath setting and apply the text prefix.
src/interfaces/constant.ts Extended default settings to include relativePath and textPrefix.
src/interfaces/settings.ts Updated interface definitions to include the new relativePath and textPrefix fields.
src/utils/status_bar.ts Inserted a biome-ignore lint comment with a placeholder explanation.

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

@Mara-Li Mara-Li merged commit 757a277 into master Mar 4, 2025
3 checks passed
@Mara-Li Mara-Li deleted the disable-relative branch March 4, 2025 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[AI] To auto review with AI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant