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

anki plugin #189

Merged
merged 12 commits into from
May 31, 2024
Merged

anki plugin #189

merged 12 commits into from
May 31, 2024

Conversation

slayernominee
Copy link
Contributor

adding the anki plugin (#155)

Bildschirmfoto 2024-05-05 um 13 38 01

for this to work anki must be running and the anki connect plugin must be installed. else there will be an error message:
Bildschirmfoto 2024-05-05 um 13 59 02

about the white background from the cards, anki sends the question and answers always as complete html with css so it would be quite troublesome to change this.

currently im using the dangerouslySetInnerHTML attribute to render the answer from anki, im not quite sure if this is the best solution for this case...

@OlegWock
Copy link
Owner

OlegWock commented May 5, 2024

Hello and thanks for the PR. I got sick yesterday, so probably won't be able to review this for at least a few days, probably a week. But I see that your editor changed indentation level from 4 spaces to 2 (and it seems line limit of 80 characters and double quoutes enforcment) in files you edited. This adds a lot of noise to PR and inconsistent with rest of repo. Could you change settings of your editor (there should be an option to change them only for this project, so it won't affect your global setup) to use 4 spaces for indentation and don't format/prettify files you editred?

@slayernominee
Copy link
Contributor Author

i think most of the noise should be now away, i also added a config for my editor, idk if i should put it in the gitignore but i dont think it will bother anyone and if someone other also uses zed they will get the right indent ...

Copy link
Owner

@OlegWock OlegWock left a comment

Choose a reason for hiding this comment

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

Thanks again for the PR! I don't mind including .zed/settings.json. I left a couple of comments, please take a look

about the white background from the cards

That's fine. I'm sure if we try to overwrite styles anyway it will break some users decks or something, it's fine to leave styles from Anki

currently im using the dangerouslySetInnerHTML attribute to render the answer from anki, im not quite sure if this is the best solution for this case...

I was thinking about this, and maybe iframe with srcdoc will work better (so styles from Anki won't bleed into Anori), but that might be tricky to setup and fit into layout. So if you want you can give it a try and change code to use iframe, but if not - no problem

src/plugins/anki/anki-plugin.tsx Outdated Show resolved Hide resolved
src/plugins/anki/anki-plugin.tsx Outdated Show resolved Hide resolved
src/plugins/anki/anki-plugin.tsx Outdated Show resolved Hide resolved
src/plugins/anki/anki-plugin.tsx Outdated Show resolved Hide resolved
src/plugins/anki/anki-plugin.tsx Outdated Show resolved Hide resolved
src/plugins/anki/anki-plugin.tsx Outdated Show resolved Hide resolved
src/plugins/anki/anki-plugin.tsx Outdated Show resolved Hide resolved
src/plugins/anki/anki-plugin.tsx Outdated Show resolved Hide resolved
src/plugins/anki/anki-plugin.tsx Outdated Show resolved Hide resolved
mainScreen: MainScreen,
mock: () => {
return (
<MainScreen
Copy link
Owner

Choose a reason for hiding this comment

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

If I understand correctly, this will just show empty mock widget for users who don't have Anki/AnkiConnect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not quite there will be the error message

Copy link
Owner

Choose a reason for hiding this comment

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

Could you update mock to look like a real widget?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it already uses the default set of anki, another set would be quite troublesome, since we don't know which set the user has any active cards in it ...

Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure I understand what you mean. What I initially meant is to make mock widget look like legit one, it doesn't need to be working per se or have real data. All values can (and should) be hardcoded, so it will work without Anko/AnkiConnect installed. You can create any example card to show there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah okay, since im currently rather busy, i will do it in the coming week

@slayernominee
Copy link
Contributor Author

fixed most of the points and do the rest tomorrow

@slayernominee
Copy link
Contributor Author

so this should be anything except the hard and good button.

is there a way to show a button only if the widget has the size 3?

@OlegWock
Copy link
Owner

You can use useWidgetMetadata hook

Like this: https://github.com/OlegWock/anori/blob/master/src/plugins/math/math-plugin.tsx#L169

@slayernominee
Copy link
Contributor Author

if the widget has now a width of 3 or 4 then all the buttons will be shown

@slayernominee
Copy link
Contributor Author

added the mock example

@OlegWock
Copy link
Owner

Perfect, thanks

@OlegWock OlegWock merged commit 15b8d0c into OlegWock:master May 31, 2024
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