Merge branch 'master' of https://github.com/mProjectsCode/obsidian-media-db-plugin
This commit is contained in:
commit
b83aec2845
7 changed files with 2171 additions and 1673 deletions
3818
package-lock.json
generated
3818
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "obsidian-media-db-plugin",
|
"name": "obsidian-media-db-plugin",
|
||||||
"version": "0.5.1",
|
"version": "0.5.2",
|
||||||
"description": "A plugin that can query multiple APIs for movies, series, anime, games, music and wiki articles, and import them into your vault.",
|
"description": "A plugin that can query multiple APIs for movies, series, anime, games, music and wiki articles, and import them into your vault.",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ export class OMDbAPI extends APIModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await fetchData.json();
|
const result = await fetchData.json();
|
||||||
console.debug(result);
|
// console.debug(result);
|
||||||
|
|
||||||
if (result.Response === 'False') {
|
if (result.Response === 'False') {
|
||||||
throw Error(`MDB | Received error from ${this.apiName}: ${result.Error}`);
|
throw Error(`MDB | Received error from ${this.apiName}: ${result.Error}`);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { ButtonComponent, MarkdownRenderer, Modal, Setting } from 'obsidian';
|
import {ButtonComponent, Component, MarkdownRenderer, Modal, Setting} from 'obsidian';
|
||||||
import MediaDbPlugin from 'src/main';
|
import MediaDbPlugin from 'src/main';
|
||||||
import { MediaTypeModel } from 'src/models/MediaTypeModel';
|
import { MediaTypeModel } from 'src/models/MediaTypeModel';
|
||||||
import { PREVIEW_MODAL_DEFAULT_OPTIONS, PreviewModalData, PreviewModalOptions } from '../utils/ModalHelper';
|
import { PREVIEW_MODAL_DEFAULT_OPTIONS, PreviewModalData, PreviewModalOptions } from '../utils/ModalHelper';
|
||||||
|
|
@ -13,6 +13,7 @@ export class MediaDbPreviewModal extends Modal {
|
||||||
title: string;
|
title: string;
|
||||||
cancelButton: ButtonComponent;
|
cancelButton: ButtonComponent;
|
||||||
submitButton: ButtonComponent;
|
submitButton: ButtonComponent;
|
||||||
|
markdownComponent: Component;
|
||||||
|
|
||||||
submitCallback: (previewModalData: PreviewModalData) => void;
|
submitCallback: (previewModalData: PreviewModalData) => void;
|
||||||
closeCallback: (err?: Error) => void;
|
closeCallback: (err?: Error) => void;
|
||||||
|
|
@ -26,6 +27,8 @@ export class MediaDbPreviewModal extends Modal {
|
||||||
this.title = previewModalOptions.modalTitle;
|
this.title = previewModalOptions.modalTitle;
|
||||||
this.elements = previewModalOptions.elements;
|
this.elements = previewModalOptions.elements;
|
||||||
this.createNoteOptions = previewModalOptions.createNoteOptions;
|
this.createNoteOptions = previewModalOptions.createNoteOptions;
|
||||||
|
|
||||||
|
this.markdownComponent = new Component();
|
||||||
}
|
}
|
||||||
|
|
||||||
setSubmitCallback(submitCallback: (previewModalData: PreviewModalData) => void): void {
|
setSubmitCallback(submitCallback: (previewModalData: PreviewModalData) => void): void {
|
||||||
|
|
@ -44,14 +47,20 @@ export class MediaDbPreviewModal extends Modal {
|
||||||
|
|
||||||
const previewWrapper = contentEl.createDiv({ cls: 'media-db-plugin-preview-wrapper' });
|
const previewWrapper = contentEl.createDiv({ cls: 'media-db-plugin-preview-wrapper' });
|
||||||
|
|
||||||
|
this.markdownComponent.load();
|
||||||
|
|
||||||
for (const result of this.elements) {
|
for (const result of this.elements) {
|
||||||
previewWrapper.createEl('h3', { text: result.englishTitle });
|
previewWrapper.createEl('h3', { text: result.englishTitle });
|
||||||
const fileDiv = previewWrapper.createDiv();
|
const fileDiv = previewWrapper.createDiv({ cls: 'media-db-plugin-preview'});
|
||||||
|
|
||||||
let fileContent = await this.plugin.generateMediaDbNoteContents(result, this.createNoteOptions);
|
let fileContent = await this.plugin.generateMediaDbNoteContents(result, this.createNoteOptions);
|
||||||
fileContent = `\n${fileContent}\n`;
|
fileContent = `\n${fileContent}\n`;
|
||||||
|
|
||||||
MarkdownRenderer.renderMarkdown(fileContent, fileDiv, null, null);
|
try {
|
||||||
|
await MarkdownRenderer.renderMarkdown(fileContent, fileDiv, "", this.markdownComponent);
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(`mdb | error during rendering of preview`, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contentEl.createDiv({ cls: 'media-db-plugin-spacer' });
|
contentEl.createDiv({ cls: 'media-db-plugin-spacer' });
|
||||||
|
|
@ -77,6 +86,7 @@ export class MediaDbPreviewModal extends Modal {
|
||||||
}
|
}
|
||||||
|
|
||||||
onClose(): void {
|
onClose(): void {
|
||||||
|
this.markdownComponent.unload();
|
||||||
this.closeCallback();
|
this.closeCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ export class MediaTypeManager {
|
||||||
if (!folderPath) {
|
if (!folderPath) {
|
||||||
folderPath = `/`;
|
folderPath = `/`;
|
||||||
}
|
}
|
||||||
console.log(folderPath);
|
// console.log(folderPath);
|
||||||
|
|
||||||
if (!(await app.vault.adapter.exists(folderPath))) {
|
if (!(await app.vault.adapter.exists(folderPath))) {
|
||||||
await app.vault.createFolder(folderPath);
|
await app.vault.createFolder(folderPath);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { TFile, TFolder } from 'obsidian';
|
||||||
export const pluginName: string = 'obsidian-media-db-plugin';
|
export const pluginName: string = 'obsidian-media-db-plugin';
|
||||||
export const contactEmail: string = 'm.projects.code@gmail.com';
|
export const contactEmail: string = 'm.projects.code@gmail.com';
|
||||||
export const mediaDbTag: string = 'mediaDB';
|
export const mediaDbTag: string = 'mediaDB';
|
||||||
export const mediaDbVersion: string = '0.5.0';
|
export const mediaDbVersion: string = '0.5.2';
|
||||||
export const debug: boolean = true;
|
export const debug: boolean = true;
|
||||||
|
|
||||||
export function wrapAround(value: number, size: number): number {
|
export function wrapAround(value: number, size: number): number {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export class YAMLConverter {
|
||||||
} else if (typeof value === 'number') {
|
} else if (typeof value === 'number') {
|
||||||
return value.toString();
|
return value.toString();
|
||||||
} else if (typeof value === 'string') {
|
} else if (typeof value === 'string') {
|
||||||
return '"' + value + '"';
|
return '"' + value.replace("\"", "\\\"") + '"';
|
||||||
} else if (typeof value === 'object') {
|
} else if (typeof value === 'object') {
|
||||||
let output = '';
|
let output = '';
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue