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

Feature Request: API for Dictionary registration #118

Closed
MSzturc opened this issue Apr 30, 2022 · 23 comments
Closed

Feature Request: API for Dictionary registration #118

MSzturc opened this issue Apr 30, 2022 · 23 comments
Assignees
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@MSzturc
Copy link

MSzturc commented Apr 30, 2022

Hi,

i've created a custom dictionary to for Advanced Slides syntax. I would like to ship this dictionary with the current build of advanced slides and register it dynamically when the user also has installed various complements plugin. Therefore it would be be cool when provide me such an api for integration

@tadashi-aikawa
Copy link
Owner

Hi, @MSzturc :)

Does that mean it is needed to add the path(URL) to the Custom dictionary paths via the API? (ex: addCustomDictionaryPath(path: string) )

@MSzturc
Copy link
Author

MSzturc commented Apr 30, 2022

Yes exactly, with a path like .obsidian/plugins/obsidian-advanced-slides/autoComplete/dict.md. I would call it when advanced slides get's initialized so you have to check if the path exists in custom dictionary list

@tadashi-aikawa
Copy link
Owner

OK. LGTM 👍

Probably, I will add the API such a ensureCustomDictionaryPath(path: string, state: "present" | "absent").

@tadashi-aikawa tadashi-aikawa self-assigned this Apr 30, 2022
@tadashi-aikawa tadashi-aikawa added the enhancement New feature or request label Apr 30, 2022
@tadashi-aikawa
Copy link
Owner

@MSzturc
I have released v6.1.0-beta1 🚀

Please confirm whether it works as you expected via BRAT.

P.S.
This is my first time creating a public API as the Obsidian plugin, so if you know a better implementation, It would be great to hear about it :)

@MSzturc
Copy link
Author

MSzturc commented Apr 30, 2022

Awesome, works as expected! The implementation is fine. One think i would introduce with v.6.1 is an API Method isFeatureSupported(featureName: string) => boolean With this method every user of the API can check if the installed variousComponents Version supports a feature. This allows a more robust implementation since it could be used to handle version mismatches.

Thx ;-)

@MSzturc
Copy link
Author

MSzturc commented Apr 30, 2022

Got a prototype running ;-)

autoComplete.mov

@tadashi-aikawa
Copy link
Owner

isFeatureSupported(featureName: string) => boolean

Thank you! I'll add the function 👍

tadashi-aikawa added a commit that referenced this issue May 1, 2022
@tadashi-aikawa
Copy link
Owner

tadashi-aikawa commented May 1, 2022

@MSzturc
I have released v6.1.0-beta2 🚀

There is a bit of breaking change. Please fix the code as follows.

- app.plugins.plugins["various-complements"].ensureCustomDictionaryPath("./your-dictionary.md", "present")
+ app.plugins.plugins["various-complements"].api.ensureCustomDictionaryPath("./your-dictionary.md", "present")

@MSzturc
Copy link
Author

MSzturc commented May 1, 2022

done.

@tadashi-aikawa
Copy link
Owner

I noticed that the current version couldn't have settings for each custom dictionary file.

image

I think we need to embed the settings in custom dictionary files. So I'll support JSON format as a dictionary file that includes the settings.

@tadashi-aikawa
Copy link
Owner

Ah... it doesn't need settings except for Caret location symbol after complement in the case of JSON file format :)

@MSzturc
Copy link
Author

MSzturc commented May 1, 2022

I noticed that the current version couldn't have settings for each custom dictionary file.

That would be a nice feature since there are some Settings to get the dict working properly:

settings.maxNumberOfSuggestions = 15; //this one is optional but more than 5 feels better using it
settings.enableCustomDictionaryComplement = true; // this could be activated automatically when ensureCustomDictionaryPath was called
settings.insertAfterCompletion = false; //feels better, otherwise you have to move the cursor back after many completion (would be cool when this one would be dict specific
settings.caretLocationSymbolAfterComplement = "<CARET>"; //would be cool if it's dict specific

A dict based on a JSON file would make a hierarchically dictionary easier to implement since we wont have to parse a md file

@tadashi-aikawa
Copy link
Owner

tadashi-aikawa commented May 1, 2022

settings.caretLocationSymbolAfterComplement = ""; //would be cool if it's dict specific

I'll add this option certainly. However, I think that I will not add other settings for now.

A dict based on a JSON file would make a hierarchically dictionary easier to implement since we wont have to parse a md file

Yes. Originally I don't use Custom dictionary (I do now), so I selected the specifications based on the IME dictionary, but already the expressions are pushing the limits 😅

@tadashi-aikawa
Copy link
Owner

@MSzturc
Mostly done. However, I am afraid of degradation. Therefore it would be great if you try it for a few days after I release it as v6.1.0-beta4 🙏

2022-05-04_00h33_30.mp4

@tadashi-aikawa
Copy link
Owner

tadashi-aikawa commented May 3, 2022

Supported properties.

{
  "caretSymbol": "[[CARET]]",
  "ignoreSpaceAfterCompletion": true,
  "words": [
    { "value": "custom dictionary1" },
    { "value": "custom dictionary2", "description": "hogehoge" },
    { "value": "custom dictionary3", "aliases": ["w3", "word3"] },
    { "value": "```json\n[[CARET]]\n```", "displayed": "code-json" }
  ]
}

settings.insertAfterCompletion = false; //feels better, otherwise you have to move the cursor back after many completion (would be cool when this one would be dict specific
settings.caretLocationSymbolAfterComplement = ""; //would be cool if it's dict specific

@MSzturc
Copy link
Author

MSzturc commented May 3, 2022

Uhhh... looks neat! Will test it tomorrow and give you feedback. Thx

@MSzturc
Copy link
Author

MSzturc commented May 3, 2022

Will v6.1.0-beta4 support dict hierarchy (as described in #119 )?

@tadashi-aikawa
Copy link
Owner

No it doesn't because of #119 (comment).

@tadashi-aikawa
Copy link
Owner

@MSzturc
I have released v6.1.0-beta4 🚀

@MSzturc
Copy link
Author

MSzturc commented May 5, 2022

Played a bit with it! Works like intended! Thx man

@tadashi-aikawa
Copy link
Owner

@MSzturc
Thanks for conforming!

By the way, can I remove the API of this issue by any chance? Because Advanced Slides for Obsidian seems not to use this feature.

Best regards.

@MSzturc
Copy link
Author

MSzturc commented May 5, 2022

Yeah, if you want you may remove it. I experimented yesterday a bit with it and i was not comfortable with my dictionary without the hierarchy feature, Advanced Slides is too complex for a basic auto complete, so i hacked an own suggester... but i have to rewrite it after its stable.. the code is too complex

@tadashi-aikawa
Copy link
Owner

OK! Thanks for reply 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
Development

No branches or pull requests

2 participants