mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-29 08:08:34 +08:00
update general tabs
This commit is contained in:
@@ -0,0 +1,116 @@
|
|||||||
|
import {App, PluginSettingTab, Setting} from "obsidian";
|
||||||
|
import ObsidianSyncNotionPlugin from "../main";
|
||||||
|
import {i18nConfig} from "../lang/I18n";
|
||||||
|
import {ObsidianSettingTab} from "./settingTabs";
|
||||||
|
|
||||||
|
export class SettingGeneralTabs extends PluginSettingTab {
|
||||||
|
plugin: ObsidianSyncNotionPlugin;
|
||||||
|
private settingTab: ObsidianSettingTab;
|
||||||
|
|
||||||
|
constructor(app: App, plugin: ObsidianSyncNotionPlugin, settingTab: ObsidianSettingTab) {
|
||||||
|
super(app, plugin);
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.settingTab = settingTab;
|
||||||
|
}
|
||||||
|
|
||||||
|
display(): void {
|
||||||
|
|
||||||
|
// General Database Settings
|
||||||
|
this.settingTab.containerEl.createEl('h2', { text: i18nConfig.NotionGeneralSettingHeader });
|
||||||
|
|
||||||
|
// new Setting(containerEl)
|
||||||
|
// .setName(i18nConfig.NotYetFinish)
|
||||||
|
new Setting(this.settingTab.containerEl)
|
||||||
|
.setName(i18nConfig.NotionGeneralButton)
|
||||||
|
.setDesc(i18nConfig.NotionGeneralButtonDesc)
|
||||||
|
.addToggle((toggle) =>
|
||||||
|
toggle
|
||||||
|
.setValue(this.plugin.settings.GeneralButton)
|
||||||
|
.onChange(async (value) => {
|
||||||
|
this.plugin.settings.GeneralButton = value;
|
||||||
|
|
||||||
|
this.settingTab.updateSettingEl(tagButtonEl, value)
|
||||||
|
this.settingTab.updateSettingEl(CustomTitleEl, value)
|
||||||
|
// name should follow the result of the title button
|
||||||
|
if (value) {
|
||||||
|
this.settingTab.updateSettingEl(CustomNameEl, this.plugin.settings.CustomTitleButton)
|
||||||
|
this.settingTab.updateSettingEl(CustomValuesEl, this.plugin.settings.CustomTitleButton)
|
||||||
|
} else {
|
||||||
|
this.settingTab.updateSettingEl(CustomNameEl, value)
|
||||||
|
this.settingTab.updateSettingEl(CustomValuesEl, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.settingTab.updateSettingEl(notionAPIGeneralEl, value)
|
||||||
|
this.settingTab.updateSettingEl(databaseIDGeneralEl, value)
|
||||||
|
|
||||||
|
|
||||||
|
await this.plugin.saveSettings();
|
||||||
|
await this.plugin.commands.updateCommand();
|
||||||
|
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// add the tagButton to control whether to add tags to the general database
|
||||||
|
const tagButtonEl = this.settingTab.createStyleDiv('tag-button', (this.plugin.settings.GeneralButton && this.plugin.settings.CustomTitleButton));
|
||||||
|
this.settingTab.createSettingEl(tagButtonEl, i18nConfig.NotionTagButton, i18nConfig.NotionTagButtonDesc, 'toggle', i18nConfig.NotionCustomTitleText, this.plugin.settings.tagButton, 'tagButton')
|
||||||
|
|
||||||
|
// Custom Title Button
|
||||||
|
const CustomTitleEl = this.settingTab.createStyleDiv('custom-title', this.plugin.settings.GeneralButton);
|
||||||
|
new Setting(CustomTitleEl)
|
||||||
|
.setName(i18nConfig.NotionCustomTitle)
|
||||||
|
.setDesc(i18nConfig.NotionCustomTitleDesc)
|
||||||
|
.addToggle((toggle) =>
|
||||||
|
toggle
|
||||||
|
.setValue(this.plugin.settings.CustomTitleButton)
|
||||||
|
.onChange(async (value) => {
|
||||||
|
this.plugin.settings.CustomTitleButton = value;
|
||||||
|
|
||||||
|
this.settingTab.updateSettingEl(CustomNameEl, value)
|
||||||
|
|
||||||
|
this.settingTab.updateSettingEl(CustomValuesEl, value)
|
||||||
|
|
||||||
|
await this.plugin.saveSettings();
|
||||||
|
await this.plugin.commands.updateCommand();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// Custom Title Name
|
||||||
|
const CustomNameEl = this.settingTab.createStyleDiv('custom-name', (this.plugin.settings.CustomTitleButton && this.plugin.settings.GeneralButton));
|
||||||
|
this.settingTab.createSettingEl(CustomNameEl, i18nConfig.NotionCustomTitleName, i18nConfig.NotionCustomTitleNameDesc, 'text', i18nConfig.NotionCustomTitleText, this.plugin.settings.CustomTitleName, 'CustomTitleName')
|
||||||
|
|
||||||
|
// Custom database properties
|
||||||
|
const CustomValuesEl = this.settingTab.createStyleDiv('custom-values', (this.plugin.settings.CustomTitleButton && this.plugin.settings.GeneralButton));
|
||||||
|
new Setting(CustomValuesEl)
|
||||||
|
.setName(i18nConfig.NotionCustomValues)
|
||||||
|
.setDesc(i18nConfig.NotionCustomValuesDesc)
|
||||||
|
.addTextArea((text) =>
|
||||||
|
text
|
||||||
|
.setPlaceholder(i18nConfig.NotionCustomValuesText)
|
||||||
|
.setValue(this.plugin.settings.CustomValues)
|
||||||
|
.onChange(async (value) => {
|
||||||
|
this.plugin.settings.CustomValues = value;
|
||||||
|
await this.plugin.saveSettings();
|
||||||
|
await this.plugin.commands.updateCommand();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
// new Setting(containerEl)
|
||||||
|
// .setName("Convert tags(optional)")
|
||||||
|
// .setDesc("Transfer the Obsidian tags to the Notion table. It requires the column with the name 'Tags'")
|
||||||
|
// .addToggle((toggle) =>
|
||||||
|
// toggle
|
||||||
|
// .setValue(this.plugin.settings.allowTags)
|
||||||
|
// .onChange(async (value) => {
|
||||||
|
// this.plugin.settings.allowTags = value;
|
||||||
|
// await this.plugin.saveSettings();
|
||||||
|
// })
|
||||||
|
// );
|
||||||
|
|
||||||
|
const notionAPIGeneralEl = this.settingTab.createStyleDiv('api-general', this.plugin.settings.GeneralButton);
|
||||||
|
this.settingTab.createSettingEl(notionAPIGeneralEl, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.plugin.settings.notionAPIGeneral, 'notionAPIGeneral')
|
||||||
|
|
||||||
|
|
||||||
|
const databaseIDGeneralEl = this.settingTab.createStyleDiv('databaseID-general', this.plugin.settings.GeneralButton);
|
||||||
|
this.settingTab.createSettingEl(databaseIDGeneralEl, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.plugin.settings.databaseIDGeneral, 'databaseIDGeneral')
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import ObsidianSyncNotionPlugin from "../main";
|
|||||||
import {i18nConfig} from "../lang/I18n";
|
import {i18nConfig} from "../lang/I18n";
|
||||||
import {ObsidianSettingTab} from "./settingTabs";
|
import {ObsidianSettingTab} from "./settingTabs";
|
||||||
|
|
||||||
export class SettingNextTab extends PluginSettingTab {
|
export class SettingNextTabs extends PluginSettingTab {
|
||||||
plugin: ObsidianSyncNotionPlugin;
|
plugin: ObsidianSyncNotionPlugin;
|
||||||
private settingTab: ObsidianSettingTab;
|
private settingTab: ObsidianSettingTab;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import {App, ButtonComponent, PluginSettingTab, Setting} from "obsidian";
|
|||||||
import {i18nConfig} from "../lang/I18n";
|
import {i18nConfig} from "../lang/I18n";
|
||||||
import ObsidianSyncNotionPlugin from "../main";
|
import ObsidianSyncNotionPlugin from "../main";
|
||||||
import {SettingModal} from "./settingModal";
|
import {SettingModal} from "./settingModal";
|
||||||
import {SettingNextTab} from "./settingNextTabs";
|
import {SettingNextTabs} from "./settingNextTabs";
|
||||||
|
import {SettingGeneralTabs} from "./settingGeneralTabs";
|
||||||
|
|
||||||
export interface PluginSettings {
|
export interface PluginSettings {
|
||||||
NextButton: boolean;
|
NextButton: boolean;
|
||||||
@@ -98,7 +99,7 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
|
|
||||||
// notion next database settings
|
// notion next database settings
|
||||||
|
|
||||||
const NextTabs = new SettingNextTab(this.app, this.plugin, this);
|
const NextTabs = new SettingNextTabs(this.app, this.plugin, this);
|
||||||
|
|
||||||
NextTabs.display();
|
NextTabs.display();
|
||||||
|
|
||||||
@@ -131,101 +132,106 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
|
|
||||||
|
|
||||||
// General Database Settings
|
// General Database Settings
|
||||||
containerEl.createEl('h2', { text: i18nConfig.NotionGeneralSettingHeader });
|
const GeneralTabs = new SettingGeneralTabs(this.app, this.plugin, this);
|
||||||
|
|
||||||
|
GeneralTabs.display();
|
||||||
|
|
||||||
|
|
||||||
|
// containerEl.createEl('h2', { text: i18nConfig.NotionGeneralSettingHeader });
|
||||||
|
//
|
||||||
|
// // new Setting(containerEl)
|
||||||
|
// // .setName(i18nConfig.NotYetFinish)
|
||||||
// new Setting(containerEl)
|
// new Setting(containerEl)
|
||||||
// .setName(i18nConfig.NotYetFinish)
|
// .setName(i18nConfig.NotionGeneralButton)
|
||||||
new Setting(containerEl)
|
// .setDesc(i18nConfig.NotionGeneralButtonDesc)
|
||||||
.setName(i18nConfig.NotionGeneralButton)
|
// .addToggle((toggle) =>
|
||||||
.setDesc(i18nConfig.NotionGeneralButtonDesc)
|
// toggle
|
||||||
.addToggle((toggle) =>
|
// .setValue(this.plugin.settings.GeneralButton)
|
||||||
toggle
|
// .onChange(async (value) => {
|
||||||
.setValue(this.plugin.settings.GeneralButton)
|
// this.plugin.settings.GeneralButton = value;
|
||||||
.onChange(async (value) => {
|
//
|
||||||
this.plugin.settings.GeneralButton = value;
|
// this.updateSettingEl(tagButtonEl, value)
|
||||||
|
// this.updateSettingEl(CustomTitleEl, value)
|
||||||
this.updateSettingEl(tagButtonEl, value)
|
// // name should follow the result of the title button
|
||||||
this.updateSettingEl(CustomTitleEl, value)
|
// if (value) {
|
||||||
// name should follow the result of the title button
|
// this.updateSettingEl(CustomNameEl, this.plugin.settings.CustomTitleButton)
|
||||||
if (value) {
|
// this.updateSettingEl(CustomValuesEl, this.plugin.settings.CustomTitleButton)
|
||||||
this.updateSettingEl(CustomNameEl, this.plugin.settings.CustomTitleButton)
|
// } else {
|
||||||
this.updateSettingEl(CustomValuesEl, this.plugin.settings.CustomTitleButton)
|
// this.updateSettingEl(CustomNameEl, value)
|
||||||
} else {
|
// this.updateSettingEl(CustomValuesEl, value)
|
||||||
this.updateSettingEl(CustomNameEl, value)
|
// }
|
||||||
this.updateSettingEl(CustomValuesEl, value)
|
//
|
||||||
}
|
// this.updateSettingEl(notionAPIGeneralEl, value)
|
||||||
|
// this.updateSettingEl(databaseIDGeneralEl, value)
|
||||||
this.updateSettingEl(notionAPIGeneralEl, value)
|
//
|
||||||
this.updateSettingEl(databaseIDGeneralEl, value)
|
//
|
||||||
|
// await this.plugin.saveSettings();
|
||||||
|
// await this.plugin.commands.updateCommand();
|
||||||
await this.plugin.saveSettings();
|
//
|
||||||
await this.plugin.commands.updateCommand();
|
// })
|
||||||
|
// );
|
||||||
})
|
//
|
||||||
);
|
// // add the tagButton to control whether to add tags to the general database
|
||||||
|
// const tagButtonEl = this.createStyleDiv('tag-button', (this.plugin.settings.GeneralButton && this.plugin.settings.CustomTitleButton));
|
||||||
// add the tagButton to control whether to add tags to the general database
|
// this.createSettingEl(tagButtonEl, i18nConfig.NotionTagButton, i18nConfig.NotionTagButtonDesc, 'toggle', i18nConfig.NotionCustomTitleText, this.plugin.settings.tagButton, 'tagButton')
|
||||||
const tagButtonEl = this.createStyleDiv('tag-button', (this.plugin.settings.GeneralButton && this.plugin.settings.CustomTitleButton));
|
//
|
||||||
this.createSettingEl(tagButtonEl, i18nConfig.NotionTagButton, i18nConfig.NotionTagButtonDesc, 'toggle', i18nConfig.NotionCustomTitleText, this.plugin.settings.tagButton, 'tagButton')
|
// // Custom Title Button
|
||||||
|
// const CustomTitleEl = this.createStyleDiv('custom-title', this.plugin.settings.GeneralButton);
|
||||||
// Custom Title Button
|
// new Setting(CustomTitleEl)
|
||||||
const CustomTitleEl = this.createStyleDiv('custom-title', this.plugin.settings.GeneralButton);
|
// .setName(i18nConfig.NotionCustomTitle)
|
||||||
new Setting(CustomTitleEl)
|
// .setDesc(i18nConfig.NotionCustomTitleDesc)
|
||||||
.setName(i18nConfig.NotionCustomTitle)
|
// .addToggle((toggle) =>
|
||||||
.setDesc(i18nConfig.NotionCustomTitleDesc)
|
// toggle
|
||||||
.addToggle((toggle) =>
|
// .setValue(this.plugin.settings.CustomTitleButton)
|
||||||
toggle
|
// .onChange(async (value) => {
|
||||||
.setValue(this.plugin.settings.CustomTitleButton)
|
// this.plugin.settings.CustomTitleButton = value;
|
||||||
.onChange(async (value) => {
|
//
|
||||||
this.plugin.settings.CustomTitleButton = value;
|
// this.updateSettingEl(CustomNameEl, value)
|
||||||
|
//
|
||||||
this.updateSettingEl(CustomNameEl, value)
|
// this.updateSettingEl(CustomValuesEl, value)
|
||||||
|
//
|
||||||
this.updateSettingEl(CustomValuesEl, value)
|
// await this.plugin.saveSettings();
|
||||||
|
// await this.plugin.commands.updateCommand();
|
||||||
await this.plugin.saveSettings();
|
// })
|
||||||
await this.plugin.commands.updateCommand();
|
// );
|
||||||
})
|
//
|
||||||
);
|
// // Custom Title Name
|
||||||
|
// const CustomNameEl = this.createStyleDiv('custom-name', (this.plugin.settings.CustomTitleButton && this.plugin.settings.GeneralButton));
|
||||||
// Custom Title Name
|
// this.createSettingEl(CustomNameEl, i18nConfig.NotionCustomTitleName, i18nConfig.NotionCustomTitleNameDesc, 'text', i18nConfig.NotionCustomTitleText, this.plugin.settings.CustomTitleName, 'CustomTitleName')
|
||||||
const CustomNameEl = this.createStyleDiv('custom-name', (this.plugin.settings.CustomTitleButton && this.plugin.settings.GeneralButton));
|
//
|
||||||
this.createSettingEl(CustomNameEl, i18nConfig.NotionCustomTitleName, i18nConfig.NotionCustomTitleNameDesc, 'text', i18nConfig.NotionCustomTitleText, this.plugin.settings.CustomTitleName, 'CustomTitleName')
|
// // Custom database properties
|
||||||
|
// const CustomValuesEl = this.createStyleDiv('custom-values', (this.plugin.settings.CustomTitleButton && this.plugin.settings.GeneralButton));
|
||||||
// Custom database properties
|
// new Setting(CustomValuesEl)
|
||||||
const CustomValuesEl = this.createStyleDiv('custom-values', (this.plugin.settings.CustomTitleButton && this.plugin.settings.GeneralButton));
|
// .setName(i18nConfig.NotionCustomValues)
|
||||||
new Setting(CustomValuesEl)
|
// .setDesc(i18nConfig.NotionCustomValuesDesc)
|
||||||
.setName(i18nConfig.NotionCustomValues)
|
// .addTextArea((text) =>
|
||||||
.setDesc(i18nConfig.NotionCustomValuesDesc)
|
// text
|
||||||
.addTextArea((text) =>
|
// .setPlaceholder(i18nConfig.NotionCustomValuesText)
|
||||||
text
|
// .setValue(this.plugin.settings.CustomValues)
|
||||||
.setPlaceholder(i18nConfig.NotionCustomValuesText)
|
// .onChange(async (value) => {
|
||||||
.setValue(this.plugin.settings.CustomValues)
|
// this.plugin.settings.CustomValues = value;
|
||||||
.onChange(async (value) => {
|
// await this.plugin.saveSettings();
|
||||||
this.plugin.settings.CustomValues = value;
|
// await this.plugin.commands.updateCommand();
|
||||||
await this.plugin.saveSettings();
|
// })
|
||||||
await this.plugin.commands.updateCommand();
|
// );
|
||||||
})
|
// // new Setting(containerEl)
|
||||||
);
|
// // .setName("Convert tags(optional)")
|
||||||
// new Setting(containerEl)
|
// // .setDesc("Transfer the Obsidian tags to the Notion table. It requires the column with the name 'Tags'")
|
||||||
// .setName("Convert tags(optional)")
|
// // .addToggle((toggle) =>
|
||||||
// .setDesc("Transfer the Obsidian tags to the Notion table. It requires the column with the name 'Tags'")
|
// // toggle
|
||||||
// .addToggle((toggle) =>
|
// // .setValue(this.plugin.settings.allowTags)
|
||||||
// toggle
|
// // .onChange(async (value) => {
|
||||||
// .setValue(this.plugin.settings.allowTags)
|
// // this.plugin.settings.allowTags = value;
|
||||||
// .onChange(async (value) => {
|
// // await this.plugin.saveSettings();
|
||||||
// this.plugin.settings.allowTags = value;
|
// // })
|
||||||
// await this.plugin.saveSettings();
|
// // );
|
||||||
// })
|
//
|
||||||
// );
|
// const notionAPIGeneralEl = this.createStyleDiv('api-general', this.plugin.settings.GeneralButton);
|
||||||
|
// this.createSettingEl(notionAPIGeneralEl, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.plugin.settings.notionAPIGeneral, 'notionAPIGeneral')
|
||||||
const notionAPIGeneralEl = this.createStyleDiv('api-general', this.plugin.settings.GeneralButton);
|
//
|
||||||
this.createSettingEl(notionAPIGeneralEl, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.plugin.settings.notionAPIGeneral, 'notionAPIGeneral')
|
//
|
||||||
|
// const databaseIDGeneralEl = this.createStyleDiv('databaseID-general', this.plugin.settings.GeneralButton);
|
||||||
|
// this.createSettingEl(databaseIDGeneralEl, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.plugin.settings.databaseIDGeneral, 'databaseIDGeneral')
|
||||||
const databaseIDGeneralEl = this.createStyleDiv('databaseID-general', this.plugin.settings.GeneralButton);
|
|
||||||
this.createSettingEl(databaseIDGeneralEl, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.plugin.settings.databaseIDGeneral, 'databaseIDGeneral')
|
|
||||||
|
|
||||||
// Custom Database Settings
|
// Custom Database Settings
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user