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

Custom dictionary #34

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Custom dictionary #34

wants to merge 9 commits into from

Conversation

ssylvia
Copy link

@ssylvia ssylvia commented Aug 28, 2024

Adds a settings panel to configure a custom dictionary: #32.

  • Simple UI to:
    • Enable/disable replacement
    • Edit key/value pairs that serve as source and replacer values
    • Change order of replaces so more specific matched text can be replaced first.
  • Automatically replaces text inline for both the note preview and text copied to markdown
Screenshot 2024-08-28 at 4 02 34 PM

Copy link
Owner

@philips philips left a comment

Choose a reason for hiding this comment

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

Overall, I like this idea. I have trouble with a few words myself. But, I need to test it and would like you to consider my feedback.

// Replace text with custom dictionary entries
export function replaceTextWithCustomDictionary(text: string, customDictionary: CustomDictionarySettings['customDictionary']): string {
for (const entry of customDictionary) {
text = text.replace(new RegExp(entry.source, 'g'), entry.replace);
Copy link
Owner

Choose a reason for hiding this comment

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

Hrm. I am curious of two things:

  1. Might it be better to use the strategy here to avoid looping multiple times over the text?

  2. Would it be better to use a word boundary \b to ensure you don't replace things in the middle of words?

Copy link
Author

Choose a reason for hiding this comment

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

@philips Thanks for feedback. I took your feedback use the faster matching strategy. Regarding the work boundary, I often use acronyms or special symbols in my notes that often get broken up as multiple words. To optimize for individual workflows, I added two options to each dictionary entry: case insensitive matching and word boundary matching.

Copy link
Author

Choose a reason for hiding this comment

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

@philips, have you had a chance to test this? I've been using it on my fork for about a month without issues. It would be great to get this merged for others to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants