Obsidian_to_Anki icon indicating copy to clipboard operation
Obsidian_to_Anki copied to clipboard

Renaming note-types breaks them

Open ShaddyDC opened this issue 4 years ago • 4 comments

Hey, I'm using this project as the obsidian extension, and I really like it so far. Thank you!
I ran into an issue when using it today though. Namely, I wasn't able to create cards for a specific note type I'd renamed earlier.
After some debugging, I noticed that said type is broken in the Note Type Table too, and none of the fields are shown.

Regenerating the Note Type Table doesn't fix it and yields this error.

I noticed that, while the note type name now provided by anki is the new version, the one populating the dictionary plugin.fields_dict was the old one, thus yielding this error.

I fixed it by manually going into .obsidian/plugins/obsidian-to-anki-plugin/data.json, removing instances of the new name and renaming instances of the old name to the new one.

ShaddyDC avatar Dec 22 '20 17:12 ShaddyDC

Oh, interesting! I’ll see what I can do to fix this

Pseudonium avatar Dec 23 '20 09:12 Pseudonium

Have a similar issue. As a temporary workaround you can do this - open the data.json file located in .obsidian/plugins/obsidian-to-anki-plugin and edit it manually, save the file, and restart obsidian.

serpro69 avatar Feb 01 '21 20:02 serpro69

Ran into this error... I found that I could get it to work be replacing const field_names = plugin.fields_dict[note_type]; by const field_names = await invoke('modelFieldNames', { modelName: note_type }); in main.js. This is not an ideal fix but is one that works for the time being. Is the repo still being maintained?

dkoppstein avatar Oct 23 '22 20:10 dkoppstein

In macOS, Obsidian plugin files reside within the hidden .obsidian directory inside each vault. To navigate to this directory, you'll need to access it from the vault's root folder. Here's how you can find the .obsidian directory:

  1. Open Finder on your Mac.
  2. Navigate to your Obsidian vault's location. If you're not sure where your vault is, you can open Obsidian, go to the vault picker (usually found at the bottom left corner), and right-click the vault name to open its folder in Finder.
  3. Once inside your vault's folder, you need to access the hidden .obsidian folder. Since macOS by default does not show hidden files and folders, you can reveal them by pressing Shift + Command + . (dot) on your keyboard.
  4. After the hidden files become visible, you will see the .obsidian folder. Open it.
  5. Inside the .obsidian folder, there are several subfolders. Plugin files are located in the plugins folder.

Here's the structure you'll see:

VaultFolder/
└── .obsidian/
    ├── plugins/
    │   ├── obsidian-to-anki-plugin/
    │   │   ├── data.json
    │   │   ├── main.js
    │   │   ├── manifest.json
    │   │   └── styles.css
    │   └── another-plugin/
    └── themes/
    └── ...

Each plugin will have its own folder within the plugins directory, containing all its files, including the data file (data.jason) file, main JavaScript file (main.js), a manifest file (manifest.json), and often a CSS file for styles (styles.css).

  1. Open data file (data.jason) file.
  2. Manually type/add the missing field(s) that you have added in Anki note type but were not appearing automatically under Obsidian-to-Ankit plugin’s ‘Note Type Table’.
  3. Save the (data.jason) file by pressing Command + S on your keyboard.
  4. Reopen the Obsidian application/program.
  5. Under Obsidian_to_Anki setting regenerate note type table.

Now you desired field(s) will surely appear in your desired note type.

Karan-ipad avatar Nov 03 '23 05:11 Karan-ipad