Fevol / obsidian-translate

Translate text and entire notes in Obsidian
MIT License
103 stars 6 forks source link

Use normal callback #7

Closed kometenstaub closed 2 years ago

kometenstaub commented 2 years ago

https://github.com/Fevol/obsidian-translate/blob/d1ad09643e29d7182ef4ab6e57ea3eecfacd79e7/src/main.ts#L107-L114

Currently, the pane can only be opened when there is an editor in focus. But there doesn't need to be an editor for the translation pane to be useful.

Fevol commented 2 years ago

That's a tough one, I originally used regular callbacks, but for some reason, the commands added with those do not show up in the quick access menu for mobile; and I honestly have no clue why this happens. Using editorCallback solved this, though you're completely right that it is useless here.

kometenstaub commented 2 years ago

Ah, probably because they only work with editorCallbacks.

How about a middle ground? You check for Platform.isMobile https://github.com/obsidianmd/obsidian-api/blob/4583a6b8305b05139c6b1bf226ad15e50a9a5987/obsidian.d.ts#L2409 and add the command with the editorCallback to mobile, otherwise add the normal callback.

Fevol commented 2 years ago

Good find and brilliant suggestion! Should be added in release 1.1.4, thank you for all the help!

kometenstaub commented 2 years ago

Works great, thanks!