Skip to content

Commit

Permalink
Refactor password and notice
Browse files Browse the repository at this point in the history
  • Loading branch information
EasyChris committed Jun 22, 2022
1 parent 2364a6c commit 46e5477
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
2 changes: 0 additions & 2 deletions Upload2Notion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { markdownToBlocks, } from "@tryfabric/martian";
import * as yamlFrontMatter from "yaml-front-matter";
import * as yaml from "yaml"
import MyPlugin from "main";
import { join } from "path";

export class Upload2Notion {
app: MyPlugin;
notion: Client;
Expand Down
52 changes: 29 additions & 23 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ interface PluginSettings {
bannerUrl: string;
notionID: string;
proxy: string;
langConfig: any;
}

const langConfig = NoticeMConfig( window.localStorage.getItem('language') || 'en')

const DEFAULT_SETTINGS: PluginSettings = {
notionAPI: "",
databaseID: "",
bannerUrl: "",
notionID: "",
proxy: "",
langConfig: NoticeMConfig( window.localStorage.getItem('language') || 'en')
};

export default class ObsidianSyncNotionPlugin extends Plugin {
Expand Down Expand Up @@ -88,9 +88,9 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
const upload = new Upload2Notion(this);
const res = await upload.syncMarkdownToNotion(basename, markDownData,nowFile, this.app, this.settings)
if(res.status === 200){
new Notice(`${this.settings.langConfig["sync-success"]}${basename}`)
new Notice(`${langConfig["sync-success"]}${basename}`)
}else {
new Notice(`${this.settings.langConfig["sync-fail"]}${basename}`)
new Notice(`${langConfig["sync-fail"]}${basename}`)
}
}
}
Expand All @@ -104,7 +104,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
nowFile,
};
} else {
new Notice(this.settings.langConfig["open-file"]);
new Notice(langConfig["open-file"]);
return;
}
}
Expand Down Expand Up @@ -142,28 +142,34 @@ class SampleSettingTab extends PluginSettingTab {
const notionApiKye = new Setting(containerEl)
.setName("Notion API Token")
.setDesc("It's a secret")
.addText((text) =>
text
.setPlaceholder("Enter your Notion API Token")
.setValue(this.plugin.settings.notionAPI)
.onChange(async (value) => {
this.plugin.settings.notionAPI = value;
await this.plugin.saveSettings();
})
);
notionApiKye.controlEl.querySelector('input').type='password'
.addText((text) =>{
let t = text
.setPlaceholder("Enter your Notion API Token")
.setValue(this.plugin.settings.notionAPI)
.onChange(async (value) => {
this.plugin.settings.notionAPI = value;
await this.plugin.saveSettings();
})
t.inputEl.type = 'password'
return t
});


const notionDatabaseID = new Setting(containerEl)
.setName("Database ID")
.setDesc("It's a secret")
.addText((text) =>
text
.setPlaceholder("Enter your Database ID")
.setValue(this.plugin.settings.databaseID)
.onChange(async (value) => {
this.plugin.settings.databaseID = value;
await this.plugin.saveSettings();
})
.addText((text) => {
let t = text
.setPlaceholder("Enter your Database ID")
.setValue(this.plugin.settings.databaseID)
.onChange(async (value) => {
this.plugin.settings.databaseID = value;
await this.plugin.saveSettings();
})
t.inputEl.type = 'password'
return t
}

);

notionDatabaseID.controlEl.querySelector('input').type='password'
Expand Down

0 comments on commit 46e5477

Please sign in to comment.