install prettier
This commit is contained in:
parent
2662c78080
commit
9e2961421d
57 changed files with 2367 additions and 1162 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import {PropertyMappingOption} from './PropertyMapping';
|
||||
import {MEDIA_TYPES} from '../utils/MediaTypeManager';
|
||||
import { PropertyMappingOption } from './PropertyMapping';
|
||||
import { MEDIA_TYPES } from '../utils/MediaTypeManager';
|
||||
import MediaDbPlugin from '../main';
|
||||
|
||||
export class PropertyMapper {
|
||||
|
|
@ -40,7 +40,6 @@ export class PropertyMapper {
|
|||
// @ts-ignore
|
||||
newObj[propertyMapping.newProperty] = value;
|
||||
} else if (propertyMapping.mapping === PropertyMappingOption.Remove) {
|
||||
|
||||
} else if (propertyMapping.mapping === PropertyMappingOption.Default) {
|
||||
// @ts-ignore
|
||||
newObj[key] = value;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {containsOnlyLettersAndUnderscores, PropertyMappingNameConflictError, PropertyMappingValidationError} from '../utils/Utils';
|
||||
import {MediaType} from '../utils/MediaType';
|
||||
import { containsOnlyLettersAndUnderscores, PropertyMappingNameConflictError, PropertyMappingValidationError } from '../utils/Utils';
|
||||
import { MediaType } from '../utils/MediaType';
|
||||
|
||||
export enum PropertyMappingOption {
|
||||
Default = 'default',
|
||||
|
|
@ -18,7 +18,7 @@ export class PropertyMappingModel {
|
|||
this.properties = properties ?? [];
|
||||
}
|
||||
|
||||
validate(): { res: boolean, err?: Error } {
|
||||
validate(): { res: boolean; err?: Error } {
|
||||
console.debug(`MDB | validated property mappings for ${this.type}`);
|
||||
|
||||
// check properties
|
||||
|
|
@ -43,7 +43,9 @@ export class PropertyMappingModel {
|
|||
// two or more properties are mapped to the same property
|
||||
return {
|
||||
res: false,
|
||||
err: new PropertyMappingNameConflictError(`Multiple remapped properties (${propertiesWithSameTarget.map(x => x.toString()).toString()}) may not share the same name.`),
|
||||
err: new PropertyMappingNameConflictError(
|
||||
`Multiple remapped properties (${propertiesWithSameTarget.map(x => x.toString()).toString()}) may not share the same name.`
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -93,7 +95,7 @@ export class PropertyMapping {
|
|||
this.locked = locked ?? false;
|
||||
}
|
||||
|
||||
validate(): { res: boolean, err?: Error } {
|
||||
validate(): { res: boolean; err?: Error } {
|
||||
// locked property may only be default
|
||||
if (this.locked) {
|
||||
if (this.mapping === PropertyMappingOption.Remove) {
|
||||
|
|
@ -111,10 +113,10 @@ export class PropertyMapping {
|
|||
}
|
||||
|
||||
if (this.mapping === PropertyMappingOption.Default) {
|
||||
return {res: true};
|
||||
return { res: true };
|
||||
}
|
||||
if (this.mapping === PropertyMappingOption.Remove) {
|
||||
return {res: true};
|
||||
return { res: true };
|
||||
}
|
||||
|
||||
if (!this.property || !containsOnlyLettersAndUnderscores(this.property)) {
|
||||
|
|
|
|||
|
|
@ -1,45 +1,42 @@
|
|||
import {App, Notice, PluginSettingTab, Setting} from 'obsidian';
|
||||
import { App, Notice, PluginSettingTab, Setting } from 'obsidian';
|
||||
|
||||
import MediaDbPlugin from '../main';
|
||||
import {FolderSuggest} from './suggesters/FolderSuggest';
|
||||
import {FileSuggest} from './suggesters/FileSuggest';
|
||||
import { FolderSuggest } from './suggesters/FolderSuggest';
|
||||
import { FileSuggest } from './suggesters/FileSuggest';
|
||||
import PropertyMappingModelsComponent from './PropertyMappingModelsComponent.svelte';
|
||||
import {PropertyMapping, PropertyMappingModel, PropertyMappingOption} from './PropertyMapping';
|
||||
import {MEDIA_TYPES} from '../utils/MediaTypeManager';
|
||||
import {MediaTypeModel} from '../models/MediaTypeModel';
|
||||
|
||||
import { PropertyMapping, PropertyMappingModel, PropertyMappingOption } from './PropertyMapping';
|
||||
import { MEDIA_TYPES } from '../utils/MediaTypeManager';
|
||||
import { MediaTypeModel } from '../models/MediaTypeModel';
|
||||
|
||||
export interface MediaDbPluginSettings {
|
||||
folder: string,
|
||||
OMDbKey: string,
|
||||
sfwFilter: boolean,
|
||||
folder: string;
|
||||
OMDbKey: string;
|
||||
sfwFilter: boolean;
|
||||
useCustomYamlStringifier: boolean;
|
||||
templates: boolean,
|
||||
templates: boolean;
|
||||
|
||||
movieTemplate: string;
|
||||
seriesTemplate: string;
|
||||
gameTemplate: string;
|
||||
wikiTemplate: string;
|
||||
musicReleaseTemplate: string;
|
||||
boardgameTemplate: string;
|
||||
|
||||
movieTemplate: string,
|
||||
seriesTemplate: string,
|
||||
gameTemplate: string,
|
||||
wikiTemplate: string,
|
||||
musicReleaseTemplate: string,
|
||||
boardgameTemplate: string,
|
||||
movieFileNameTemplate: string;
|
||||
seriesFileNameTemplate: string;
|
||||
gameFileNameTemplate: string;
|
||||
wikiFileNameTemplate: string;
|
||||
musicReleaseFileNameTemplate: string;
|
||||
boardgameFileNameTemplate: string;
|
||||
|
||||
movieFileNameTemplate: string,
|
||||
seriesFileNameTemplate: string,
|
||||
gameFileNameTemplate: string,
|
||||
wikiFileNameTemplate: string,
|
||||
musicReleaseFileNameTemplate: string,
|
||||
boardgameFileNameTemplate: string,
|
||||
|
||||
moviePropertyConversionRules: string,
|
||||
seriesPropertyConversionRules: string,
|
||||
gamePropertyConversionRules: string,
|
||||
wikiPropertyConversionRules: string,
|
||||
musicReleasePropertyConversionRules: string,
|
||||
boardgamePropertyConversionRules: string,
|
||||
|
||||
propertyMappingModels: PropertyMappingModel[],
|
||||
moviePropertyConversionRules: string;
|
||||
seriesPropertyConversionRules: string;
|
||||
gamePropertyConversionRules: string;
|
||||
wikiPropertyConversionRules: string;
|
||||
musicReleasePropertyConversionRules: string;
|
||||
boardgamePropertyConversionRules: string;
|
||||
|
||||
propertyMappingModels: PropertyMappingModel[];
|
||||
}
|
||||
|
||||
const DEFAULT_SETTINGS: MediaDbPluginSettings = {
|
||||
|
|
@ -89,9 +86,7 @@ export function getDefaultSettings(plugin: MediaDbPlugin): MediaDbPluginSettings
|
|||
const propertyMappingModel: PropertyMappingModel = new PropertyMappingModel(mediaType);
|
||||
|
||||
for (const key of Object.keys(metadataObj)) {
|
||||
propertyMappingModel.properties.push(
|
||||
new PropertyMapping(key, '', PropertyMappingOption.Default, lockedPropertyMappings.contains(key)),
|
||||
);
|
||||
propertyMappingModel.properties.push(new PropertyMapping(key, '', PropertyMappingOption.Default, lockedPropertyMappings.contains(key)));
|
||||
}
|
||||
|
||||
propertyMappingModels.push(propertyMappingModel);
|
||||
|
|
@ -110,11 +105,11 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
|||
}
|
||||
|
||||
display(): void {
|
||||
const {containerEl} = this;
|
||||
const { containerEl } = this;
|
||||
|
||||
containerEl.empty();
|
||||
|
||||
containerEl.createEl('h2', {text: 'Media DB Plugin Settings'});
|
||||
containerEl.createEl('h2', { text: 'Media DB Plugin Settings' });
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('New file location')
|
||||
|
|
@ -145,37 +140,33 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
|||
.setName('SFW filter')
|
||||
.setDesc('Only shows SFW results for APIs that offer filtering.')
|
||||
.addToggle(cb => {
|
||||
cb.setValue(this.plugin.settings.sfwFilter)
|
||||
.onChange(data => {
|
||||
this.plugin.settings.sfwFilter = data;
|
||||
this.plugin.saveSettings();
|
||||
});
|
||||
cb.setValue(this.plugin.settings.sfwFilter).onChange(data => {
|
||||
this.plugin.settings.sfwFilter = data;
|
||||
this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('YAML formatter')
|
||||
.setDesc('Add optional quotation marks around strings in the metadata block.')
|
||||
.addToggle(cb => {
|
||||
cb.setValue(this.plugin.settings.useCustomYamlStringifier)
|
||||
.onChange(data => {
|
||||
this.plugin.settings.useCustomYamlStringifier = data;
|
||||
this.plugin.saveSettings();
|
||||
});
|
||||
cb.setValue(this.plugin.settings.useCustomYamlStringifier).onChange(data => {
|
||||
this.plugin.settings.useCustomYamlStringifier = data;
|
||||
this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Resolve {{ tags }} in templates')
|
||||
.setDesc('Whether to resolve {{ tags }} in templates. The spaces inside the curly braces are important.')
|
||||
.addToggle(cb => {
|
||||
cb.setValue(this.plugin.settings.templates)
|
||||
.onChange(data => {
|
||||
this.plugin.settings.templates = data;
|
||||
this.plugin.saveSettings();
|
||||
});
|
||||
cb.setValue(this.plugin.settings.templates).onChange(data => {
|
||||
this.plugin.settings.templates = data;
|
||||
this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
containerEl.createEl('h3', {text: 'Template Settings'});
|
||||
containerEl.createEl('h3', { text: 'Template Settings' });
|
||||
// region templates
|
||||
new Setting(containerEl)
|
||||
.setName('Movie template')
|
||||
|
|
@ -256,7 +247,7 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
|||
});
|
||||
// endregion
|
||||
|
||||
containerEl.createEl('h3', {text: 'File Name Settings'});
|
||||
containerEl.createEl('h3', { text: 'File Name Settings' });
|
||||
// region file name templates
|
||||
new Setting(containerEl)
|
||||
.setName('Movie file name template')
|
||||
|
|
@ -333,7 +324,7 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
|||
|
||||
// region Property Mappings
|
||||
|
||||
containerEl.createEl('h3', {text: 'Property Mappings'});
|
||||
containerEl.createEl('h3', { text: 'Property Mappings' });
|
||||
|
||||
let propertyMappingExplanation = containerEl.createEl('div');
|
||||
propertyMappingExplanation.innerHTML = `
|
||||
|
|
@ -350,7 +341,6 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
|||
Don't forget to save your changes using the save button for each individual category.
|
||||
</p>`;
|
||||
|
||||
|
||||
new PropertyMappingModelsComponent({
|
||||
target: this.containerEl,
|
||||
props: {
|
||||
|
|
@ -374,7 +364,5 @@ export class MediaDbSettingTab extends PluginSettingTab {
|
|||
});
|
||||
|
||||
// endregion
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import {TextInputSuggest} from './Suggest';
|
||||
import {TAbstractFile, TFile} from 'obsidian';
|
||||
import { TextInputSuggest } from './Suggest';
|
||||
import { TAbstractFile, TFile } from 'obsidian';
|
||||
|
||||
export class FileSuggest extends TextInputSuggest<TFile> {
|
||||
getSuggestions(inputStr: string): TFile[] {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// Credits go to Liam's Periodic Notes Plugin: https://github.com/liamcain/obsidian-periodic-notes
|
||||
|
||||
import {TAbstractFile, TFolder} from 'obsidian';
|
||||
import {TextInputSuggest} from './Suggest';
|
||||
import { TAbstractFile, TFolder } from 'obsidian';
|
||||
import { TextInputSuggest } from './Suggest';
|
||||
|
||||
export class FolderSuggest extends TextInputSuggest<TFolder> {
|
||||
getSuggestions(inputStr: string): TFolder[] {
|
||||
|
|
@ -10,10 +10,7 @@ export class FolderSuggest extends TextInputSuggest<TFolder> {
|
|||
const lowerCaseInputStr = inputStr.toLowerCase();
|
||||
|
||||
abstractFiles.forEach((folder: TAbstractFile) => {
|
||||
if (
|
||||
folder instanceof TFolder &&
|
||||
folder.path.toLowerCase().contains(lowerCaseInputStr)
|
||||
) {
|
||||
if (folder instanceof TFolder && folder.path.toLowerCase().contains(lowerCaseInputStr)) {
|
||||
folders.push(folder);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
// Credits go to Liam's Periodic Notes Plugin: https://github.com/liamcain/obsidian-periodic-notes
|
||||
|
||||
import {App, ISuggestOwner, Scope} from 'obsidian';
|
||||
import {createPopper, Instance as PopperInstance} from '@popperjs/core';
|
||||
import {wrapAround} from 'src/utils/Utils';
|
||||
import { App, ISuggestOwner, Scope } from 'obsidian';
|
||||
import { createPopper, Instance as PopperInstance } from '@popperjs/core';
|
||||
import { wrapAround } from 'src/utils/Utils';
|
||||
|
||||
export class Suggest<T> {
|
||||
private owner: ISuggestOwner<T>;
|
||||
|
|
@ -16,27 +16,23 @@ export class Suggest<T> {
|
|||
this.containerEl = containerEl;
|
||||
|
||||
containerEl.on('click', '.suggestion-item', this.onSuggestionClick.bind(this));
|
||||
containerEl.on(
|
||||
'mousemove',
|
||||
'.suggestion-item',
|
||||
this.onSuggestionMouseover.bind(this),
|
||||
);
|
||||
containerEl.on('mousemove', '.suggestion-item', this.onSuggestionMouseover.bind(this));
|
||||
|
||||
scope.register([], 'ArrowUp', (event) => {
|
||||
scope.register([], 'ArrowUp', event => {
|
||||
if (!event.isComposing) {
|
||||
this.setSelectedItem(this.selectedItem - 1, true);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
scope.register([], 'ArrowDown', (event) => {
|
||||
scope.register([], 'ArrowDown', event => {
|
||||
if (!event.isComposing) {
|
||||
this.setSelectedItem(this.selectedItem + 1, true);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
scope.register([], 'Enter', (event) => {
|
||||
scope.register([], 'Enter', event => {
|
||||
if (!event.isComposing) {
|
||||
this.useSelectedItem(event);
|
||||
return false;
|
||||
|
|
@ -61,7 +57,7 @@ export class Suggest<T> {
|
|||
this.containerEl.empty();
|
||||
const suggestionEls: HTMLDivElement[] = [];
|
||||
|
||||
values.forEach((value) => {
|
||||
values.forEach(value => {
|
||||
const suggestionEl = this.containerEl.createDiv('suggestion-item');
|
||||
this.owner.renderSuggestion(value, suggestionEl);
|
||||
suggestionEls.push(suggestionEl);
|
||||
|
|
@ -145,7 +141,7 @@ export abstract class TextInputSuggest<T> implements ISuggestOwner<T> {
|
|||
{
|
||||
name: 'sameWidth',
|
||||
enabled: true,
|
||||
fn: ({state, instance}) => {
|
||||
fn: ({ state, instance }) => {
|
||||
// Note: positioning needs to be calculated twice -
|
||||
// first pass - positioning it according to the width of the popper
|
||||
// second pass - position it with the width bound to the reference element
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue