mirror of
https://github.com/rifts-obsidian-laboratory/anki-integration.git
synced 2026-07-22 05:42:50 +00:00
QoL - AddNoteFromMetadataModal now fetch Yaml metadata at onOpen() start
This commit is contained in:
parent
cce32cfdbe
commit
00ced430b3
1 changed files with 10 additions and 13 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import {
|
||||
App,
|
||||
App, FrontMatterCache,
|
||||
getFrontMatterInfo,
|
||||
Modal,
|
||||
Notice,
|
||||
|
|
@ -62,6 +62,15 @@ export class AddNoteFromMetadataModal extends Modal {
|
|||
*/
|
||||
const { contentEl } = this;
|
||||
|
||||
/**
|
||||
* @type {TFile} activeFileData
|
||||
* The file defined as active in the Obsidian instance.
|
||||
* @type {FrontMatterCache} yaml
|
||||
* The YAML metadata stored in object under the key: "value" format.
|
||||
*/
|
||||
const activeFileData: TFile = this.app.workspace.getActiveFile();
|
||||
const yaml: FrontMatterCache = this.app.metadataCache.getFileCache(activeFileData).frontmatter;
|
||||
|
||||
// Add the title and subtitle to the modal.
|
||||
AddTitle(contentEl, "Add a new note using metadata");
|
||||
AddSubtitle(contentEl, "Deck & Model");
|
||||
|
|
@ -120,18 +129,6 @@ export class AddNoteFromMetadataModal extends Modal {
|
|||
*/
|
||||
const selectedModel: Object = FetchModelByName(this.plugin, value);
|
||||
|
||||
/**
|
||||
* @type {TFile} activeFileData
|
||||
* The file defined as active in the Obsidian instance.
|
||||
* @type {string} fileContent
|
||||
* The raw content of the file, including frontmatter and regular text.
|
||||
* @type {Object} yaml
|
||||
* The YAML metadata stored in object under the key: "value" format.
|
||||
*/
|
||||
const activeFileData: TFile = this.app.workspace.getActiveFile();
|
||||
const fileContent: string = await this.app.vault.cachedRead(activeFileData);
|
||||
const yaml: Object = parseYaml(getFrontMatterInfo(fileContent).frontmatter);
|
||||
|
||||
/**
|
||||
* @type {Array} fieldsGroupData
|
||||
* An array of input data storing as separate object (1 objet = 1 input) the keys used to create each label-input pair and the values of each input.
|
||||
|
|
|
|||
Loading…
Reference in a new issue