Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c92d27be53 | |||
|
|
878858308b |
50
main.ts
50
main.ts
@@ -1,24 +1,10 @@
|
||||
import { Editor, MarkdownView, Plugin, TFile, PluginSettingTab, App, Setting } from 'obsidian';
|
||||
import { Editor, MarkdownView, Plugin, TFile } from 'obsidian';
|
||||
import { exec } from "child_process";
|
||||
|
||||
const plist = require('plist');
|
||||
|
||||
interface MacTagSettings {
|
||||
writeOnSave: boolean;
|
||||
}
|
||||
|
||||
const DEFAULT_SETTINGS: MacTagSettings = {
|
||||
writeOnSave: true
|
||||
}
|
||||
|
||||
export default class MacTagPlugin extends Plugin {
|
||||
settings: MacTagSettings;
|
||||
|
||||
async onload() {
|
||||
await this.loadSettings();
|
||||
|
||||
this.addSettingTab(new MacTagSettingTab(this.app, this));
|
||||
|
||||
this.addCommand({
|
||||
id: 'write-macos-tag',
|
||||
name: "Write Mac OS tags",
|
||||
@@ -44,15 +30,6 @@ export default class MacTagPlugin extends Plugin {
|
||||
onunload() {
|
||||
}
|
||||
|
||||
async loadSettings() {
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||
}
|
||||
|
||||
async saveSettings() {
|
||||
await this.saveData(this.settings);
|
||||
}
|
||||
|
||||
|
||||
writeTags(file: TFile) {
|
||||
//@ts-ignore
|
||||
const fileWithPath = `${this.app.vault.adapter.basePath}/${file.path}`;
|
||||
@@ -89,28 +66,3 @@ export default class MacTagPlugin extends Plugin {
|
||||
return tags.map((s: string)=> s.replace("#", ""))
|
||||
}
|
||||
}
|
||||
|
||||
class MacTagSettingTab extends PluginSettingTab {
|
||||
plugin: MacTagPlugin;
|
||||
|
||||
constructor(app: App, plugin: MacTagPlugin) {
|
||||
super(app, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
display(): void {
|
||||
const {containerEl} = this;
|
||||
|
||||
containerEl.empty();
|
||||
containerEl.createEl('h2', {text: 'Settings for Mac Tagger Plugin.'});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Write on Save')
|
||||
.setDesc('Check the box if you want to save tags when saving the file.')
|
||||
.addToggle(tc => tc.onChange(async (value) => {
|
||||
this.plugin.settings.writeOnSave = value;
|
||||
await this.plugin.saveSettings();
|
||||
}))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
3722
package-lock.json
generated
3722
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,7 @@
|
||||
"@typescript-eslint/eslint-plugin": "5.29.0",
|
||||
"@typescript-eslint/parser": "5.29.0",
|
||||
"builtin-modules": "3.3.0",
|
||||
"esbuild": "0.14.47",
|
||||
"esbuild": "0.25.0",
|
||||
"obsidian": "latest",
|
||||
"tslib": "2.4.0",
|
||||
"typescript": "4.7.4"
|
||||
|
||||
Reference in New Issue
Block a user