format and update packages
This commit is contained in:
parent
e416434bf3
commit
f1f8a3f7b0
8 changed files with 1222 additions and 5263 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import {ButtonComponent, Component, MarkdownRenderer, Modal, Setting} from 'obsidian';
|
||||
import { ButtonComponent, Component, MarkdownRenderer, Modal, Setting } from 'obsidian';
|
||||
import MediaDbPlugin from 'src/main';
|
||||
import { MediaTypeModel } from 'src/models/MediaTypeModel';
|
||||
import { PREVIEW_MODAL_DEFAULT_OPTIONS, PreviewModalData, PreviewModalOptions } from '../utils/ModalHelper';
|
||||
|
|
@ -51,13 +51,13 @@ export class MediaDbPreviewModal extends Modal {
|
|||
|
||||
for (const result of this.elements) {
|
||||
previewWrapper.createEl('h3', { text: result.englishTitle });
|
||||
const fileDiv = previewWrapper.createDiv({ cls: 'media-db-plugin-preview'});
|
||||
const fileDiv = previewWrapper.createDiv({ cls: 'media-db-plugin-preview' });
|
||||
|
||||
let fileContent = await this.plugin.generateMediaDbNoteContents(result, this.createNoteOptions);
|
||||
fileContent = `\n${fileContent}\n`;
|
||||
|
||||
try {
|
||||
await MarkdownRenderer.renderMarkdown(fileContent, fileDiv, "", this.markdownComponent);
|
||||
await MarkdownRenderer.renderMarkdown(fileContent, fileDiv, '', this.markdownComponent);
|
||||
} catch (e) {
|
||||
console.warn(`mdb | error during rendering of preview`, e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,10 +170,15 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
|||
|
||||
new Setting(containerEl)
|
||||
.setName('Date format')
|
||||
.setDesc(fragWithHTML("Your custom date format. Use <em>\'YYYY-MM-DD\'</em> for example.<br>" +
|
||||
"For more syntax, refer to <a href='https://momentjs.com/docs/#/displaying/format/'>format reference</a>.<br>" +
|
||||
"Your current syntax looks like this: <b><a id='media-db-dateformat-preview' style='pointer-events: none; cursor: default; text-decoration: none;'>" +
|
||||
this.plugin.dateFormatter.getPreview() + "</a></b>"))
|
||||
.setDesc(
|
||||
fragWithHTML(
|
||||
"Your custom date format. Use <em>'YYYY-MM-DD'</em> for example.<br>" +
|
||||
"For more syntax, refer to <a href='https://momentjs.com/docs/#/displaying/format/'>format reference</a>.<br>" +
|
||||
"Your current syntax looks like this: <b><a id='media-db-dateformat-preview' style='pointer-events: none; cursor: default; text-decoration: none;'>" +
|
||||
this.plugin.dateFormatter.getPreview() +
|
||||
'</a></b>'
|
||||
)
|
||||
)
|
||||
.addText(cb => {
|
||||
cb.setPlaceholder(DEFAULT_SETTINGS.customDateFormat)
|
||||
.setValue(this.plugin.settings.customDateFormat === DEFAULT_SETTINGS.customDateFormat ? '' : this.plugin.settings.customDateFormat)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
// obsidian already uses moment, so no need to package it twice!
|
||||
// import { moment } from 'obsidian'; // doesn't work for release build
|
||||
// obsidian uses a namespace-style import for moment, which ES6 doesn't allow anymore
|
||||
const obsidian = require('obsidian');
|
||||
const moment = obsidian.moment;
|
||||
// const obsidian = require('obsidian');
|
||||
// const moment = obsidian.moment;
|
||||
|
||||
import { moment } from 'obsidian';
|
||||
|
||||
export class DateFormatter {
|
||||
toFormat: string;
|
||||
|
|
@ -33,7 +35,7 @@ export class DateFormatter {
|
|||
* You can set a date format by calling `setFormat()`.
|
||||
*
|
||||
* @param dateString the date string to be formatted
|
||||
* @param dateFormat the current format of `dateString`. When this is `null` and the actual format of the
|
||||
* @param dateFormat the current format of `dateString`. When this is `null` and the actual format of the
|
||||
* given date string is not `C2822` or `ISO` format, this function will try to guess the format by using the native `Date` module.
|
||||
* @param locale the locale of `dateString`. This is needed when `dateString` includes a month or day name and its locale format differs
|
||||
* from the locale of this machine.
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export class YAMLConverter {
|
|||
} else if (typeof value === 'number') {
|
||||
return value.toString();
|
||||
} else if (typeof value === 'string') {
|
||||
return '"' + value.replace("\"", "\\\"") + '"';
|
||||
return '"' + value.replace('"', '\\"') + '"';
|
||||
} else if (typeof value === 'object') {
|
||||
let output = '';
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue