reuseman / flashcards-obsidian

🎴 An Anki plugin for Obsidian.md
MIT License
872 stars 86 forks source link

Proof of concept: Move flash card context into distinct field #147

Open putzwasser opened 1 year ago

putzwasser commented 1 year ago

This is a proof of concept for #146 It moves the cards context into an additional/distinct flash card anki field.

This allows easy and independent styling of flashcards.

To test this, you must:

  1. Fork/apply this PR
  2. Sync Anki between your devices
  3. Edit your anki cards and add an extra field Context to it. (this needs a force sync, hence step 2)
  4. Edit your flash card templates e.g. for the Obsidian-cloze-source
    
    <div id="context" style="padding:1em;background-color:#444"><small><i>{{Context}}</i></small></div>
    {{cloze:Text}}
5. Create a new flash card note

Flas==card== Test

New flash==card==

Context Headline 1

CTC HDL 2

fl==ash==

test ==cloze==



- The first two flash cards don't have context. It won't be shown in anki, because of the JS, which hides an empty context
- The last two flash cards have context. It will be shown a bit separated from the card itself. In my opinion this makes it easier to tell, which part of the question is the context and which is the actual question asked.
- It makes the `contextAware` setting more or less obsolete, as users could just delete the `<div id="context" style="padding:1em;background-color:#444"><small><i>{{Context}}</i></small></div>` line from their templates.

This PR is a proof of concept because:
- I have no idea if there's something I'm missing
- Someone with more experience would have to change the anki card models to reflect these changes and add the `Context` field to it
- I don't know if existing users would have to add the `Context` field manually, as I did or if it is possible to add it "silently"
  - (I don't know if silently works because of the needed hard sync in step 2)

Please feel free to build upon this PR and/or use the code and create your own PR to implement this feature