mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-29 16:35:57 +08:00
update packages and complete the setting UI
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {App, PluginSettingTab, Setting} from "obsidian";
|
||||
import {i18nConfig} from "../lang/I18n";
|
||||
import { App, PluginSettingTab, Setting } from "obsidian";
|
||||
import { i18nConfig } from "../lang/I18n";
|
||||
import ObsidianSyncNotionPlugin from "../main";
|
||||
|
||||
export interface PluginSettings {
|
||||
@@ -9,12 +9,14 @@ export interface PluginSettings {
|
||||
bannerUrl: string;
|
||||
notionUser: string;
|
||||
proxy: string;
|
||||
GeneralButton: boolean;
|
||||
GeneralButton: boolean;
|
||||
CustomTitleButton: boolean;
|
||||
CustomTitleName: string;
|
||||
notionAPIGeneral: string;
|
||||
databaseIDGeneral: string;
|
||||
CustomButton: boolean;
|
||||
notionAPICustom: string;
|
||||
databaseIDCustom: string;
|
||||
CustomButton: boolean;
|
||||
notionAPICustom: string;
|
||||
databaseIDCustom: string;
|
||||
}
|
||||
|
||||
export const DEFAULT_SETTINGS: PluginSettings = {
|
||||
@@ -24,12 +26,14 @@ export const DEFAULT_SETTINGS: PluginSettings = {
|
||||
bannerUrl: "",
|
||||
notionUser: "",
|
||||
proxy: "",
|
||||
GeneralButton: true,
|
||||
GeneralButton: true,
|
||||
CustomTitleButton: false,
|
||||
CustomTitleName: "",
|
||||
notionAPIGeneral: "",
|
||||
databaseIDGeneral: "",
|
||||
CustomButton: false,
|
||||
notionAPICustom: "",
|
||||
databaseIDCustom: "",
|
||||
CustomButton: false,
|
||||
notionAPICustom: "",
|
||||
databaseIDCustom: "",
|
||||
};
|
||||
|
||||
|
||||
@@ -42,11 +46,11 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
||||
}
|
||||
|
||||
display(): void {
|
||||
const {containerEl} = this;
|
||||
const { containerEl } = this;
|
||||
|
||||
containerEl.empty();
|
||||
|
||||
containerEl.createEl('h2', {text: i18nConfig.GeneralSetting})
|
||||
containerEl.createEl('h2', { text: i18nConfig.GeneralSetting })
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(i18nConfig.BannerUrl)
|
||||
@@ -75,20 +79,20 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
||||
})
|
||||
);
|
||||
|
||||
containerEl.createEl('h2', {text: i18nConfig.NotionNextSettingHeader})
|
||||
containerEl.createEl('h2', { text: i18nConfig.NotionNextSettingHeader })
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(i18nConfig.NotionNextButton)
|
||||
.setDesc(i18nConfig.NotionNextButtonDesc)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.NextButton)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.NextButton = value;
|
||||
await this.plugin.saveSettings();
|
||||
await this.plugin.commands.updateCommand();
|
||||
})
|
||||
);
|
||||
new Setting(containerEl)
|
||||
.setName(i18nConfig.NotionNextButton)
|
||||
.setDesc(i18nConfig.NotionNextButtonDesc)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.NextButton)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.NextButton = value;
|
||||
await this.plugin.saveSettings();
|
||||
await this.plugin.commands.updateCommand();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(i18nConfig.NotionAPI)
|
||||
@@ -109,38 +113,83 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
||||
.setName(i18nConfig.DatabaseID)
|
||||
.setDesc(i18nConfig.NotionAPIDesc)
|
||||
.addText((text) => {
|
||||
text.inputEl.type = 'password';
|
||||
return text
|
||||
.setPlaceholder(i18nConfig.DatabaseIDText)
|
||||
.setValue(this.plugin.settings.databaseIDNext)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.databaseIDNext = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
}
|
||||
text.inputEl.type = 'password';
|
||||
return text
|
||||
.setPlaceholder(i18nConfig.DatabaseIDText)
|
||||
.setValue(this.plugin.settings.databaseIDNext)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.databaseIDNext = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
// notionDatabaseID.controlEl.querySelector('input').type='password'
|
||||
|
||||
|
||||
// General Database Settings
|
||||
containerEl.createEl('h2', {text: i18nConfig.NotionGeneralSettingHeader});
|
||||
containerEl.createEl('h2', { text: i18nConfig.NotionGeneralSettingHeader });
|
||||
|
||||
// new Setting(containerEl)
|
||||
// .setName(i18nConfig.NotYetFinish)
|
||||
new Setting(containerEl)
|
||||
.setName(i18nConfig.NotionGeneralButton)
|
||||
.setDesc(i18nConfig.NotionGeneralButtonDesc)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.GeneralButton)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.GeneralButton = value;
|
||||
await this.plugin.saveSettings();
|
||||
await this.plugin.commands.updateCommand();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(i18nConfig.NotionGeneralButton)
|
||||
.setDesc(i18nConfig.NotionGeneralButtonDesc)
|
||||
.setName(i18nConfig.NotionCustomTitle)
|
||||
.setDesc(i18nConfig.NotionCustomTitleDesc)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.GeneralButton)
|
||||
.setValue(this.plugin.settings.CustomTitleButton)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.GeneralButton = value;
|
||||
this.plugin.settings.CustomTitleButton = value;
|
||||
await this.plugin.saveSettings();
|
||||
await this.plugin.commands.updateCommand();
|
||||
|
||||
// Clear existing components
|
||||
dynamicSettingContainer.empty();
|
||||
|
||||
// Add new components based on the toggle value
|
||||
if (this.plugin.settings.CustomTitleButton) {
|
||||
new Setting(dynamicSettingContainer)
|
||||
.setName(i18nConfig.NotionCustomTitleName)
|
||||
.setDesc(i18nConfig.NotionCustomTitleNameDesc)
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder(i18nConfig.NotionCustomTitleText)
|
||||
.setValue(this.plugin.settings.CustomTitleName)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.CustomTitleName = value;
|
||||
await this.plugin.saveSettings();
|
||||
await this.plugin.commands.updateCommand();
|
||||
})
|
||||
);
|
||||
dynamicSettingContainer.style.borderTop = value ? "1px solid var(--background-modifier-border)" : "none";
|
||||
dynamicSettingContainer.style.paddingTop = value ? "0.75em" : "0";
|
||||
} else {
|
||||
dynamicSettingContainer.style.borderTop = "none";
|
||||
dynamicSettingContainer.style.paddingTop = "0";
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
const dynamicSettingContainer = containerEl.createDiv('setting-popover', (div) => {
|
||||
div.style.display = "flex";
|
||||
div.style.alignItems = "center";
|
||||
div.style.borderTop = "none";
|
||||
div.style.paddingBottom = "0";
|
||||
});
|
||||
|
||||
// new Setting(containerEl)
|
||||
// .setName("Convert tags(optional)")
|
||||
// .setDesc("Transfer the Obsidian tags to the Notion table. It requires the column with the name 'Tags'")
|
||||
@@ -171,31 +220,31 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
||||
.setName(i18nConfig.DatabaseID)
|
||||
.setDesc(i18nConfig.NotionAPIDesc)
|
||||
.addText((text) => {
|
||||
text.inputEl.type = 'password';
|
||||
return text
|
||||
.setPlaceholder(i18nConfig.NotionIDText)
|
||||
.setValue(this.plugin.settings.databaseIDGeneral)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.databaseIDGeneral = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
}
|
||||
text.inputEl.type = 'password';
|
||||
return text
|
||||
.setPlaceholder(i18nConfig.NotionIDText)
|
||||
.setValue(this.plugin.settings.databaseIDGeneral)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.databaseIDGeneral = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
// Custom Database Settings
|
||||
// Custom Database Settings
|
||||
|
||||
// containerEl.createEl('h2', {text: i18nConfig.NotionCustomSettingHeader});
|
||||
//
|
||||
// new Setting(containerEl)
|
||||
// .setName(i18nConfig.NotionCustomButton)
|
||||
// .setDesc(i18nConfig.NotionCustomButtonDesc)
|
||||
// .addToggle((toggle) =>
|
||||
// toggle
|
||||
// .setValue(this.plugin.settings.CustomButton)
|
||||
// .onChange(async (value) => {
|
||||
// this.plugin.settings.CustomButton = value;
|
||||
// await this.plugin.saveSettings();
|
||||
// })
|
||||
// );
|
||||
// containerEl.createEl('h2', {text: i18nConfig.NotionCustomSettingHeader});
|
||||
//
|
||||
// new Setting(containerEl)
|
||||
// .setName(i18nConfig.NotionCustomButton)
|
||||
// .setDesc(i18nConfig.NotionCustomButtonDesc)
|
||||
// .addToggle((toggle) =>
|
||||
// toggle
|
||||
// .setValue(this.plugin.settings.CustomButton)
|
||||
// .onChange(async (value) => {
|
||||
// this.plugin.settings.CustomButton = value;
|
||||
// await this.plugin.saveSettings();
|
||||
// })
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user