mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-30 00:48:36 +08:00
update the setting ui
This commit is contained in:
@@ -91,38 +91,71 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
this.plugin.settings.NextButton = value;
|
this.plugin.settings.NextButton = value;
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
await this.plugin.commands.updateCommand();
|
await this.plugin.commands.updateCommand();
|
||||||
|
|
||||||
|
// Clear existing components
|
||||||
|
notionAPINextEl.empty();
|
||||||
|
databaseIDNextEl.empty();
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
new Setting(notionAPINextEl)
|
||||||
|
.setName(i18nConfig.NotionAPI)
|
||||||
|
.setDesc(i18nConfig.NotionAPIDesc)
|
||||||
|
.addText((text) => {
|
||||||
|
text.inputEl.type = 'password';
|
||||||
|
return text
|
||||||
|
.setPlaceholder(i18nConfig.NotionAPIText)
|
||||||
|
.setValue(this.plugin.settings.notionAPINext)
|
||||||
|
.onChange(async (value) => {
|
||||||
|
this.plugin.settings.notionAPINext = value;
|
||||||
|
await this.plugin.saveSettings();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
notionAPINextEl.style.borderTop = value ? "1px solid var(--background-modifier-border)" : "none";
|
||||||
|
notionAPINextEl.style.paddingTop = value ? "0.75em" : "0";
|
||||||
|
|
||||||
|
new Setting(databaseIDNextEl)
|
||||||
|
.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();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
databaseIDNextEl.style.borderTop = value ? "1px solid var(--background-modifier-border)" : "none";
|
||||||
|
databaseIDNextEl.style.paddingTop = value ? "0.75em" : "0";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
notionAPINextEl.style.borderTop = "none";
|
||||||
|
notionAPINextEl.style.paddingTop = "0";
|
||||||
|
databaseIDNextEl.style.borderTop = "none";
|
||||||
|
databaseIDNextEl.style.paddingTop = "0";
|
||||||
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
new Setting(containerEl)
|
const notionAPINextEl = containerEl.createDiv('api-next', (div) => {
|
||||||
.setName(i18nConfig.NotionAPI)
|
div.style.alignItems = "center";
|
||||||
.setDesc(i18nConfig.NotionAPIDesc)
|
div.style.borderTop = "none";
|
||||||
.addText((text) => {
|
div.style.paddingBottom = "0";
|
||||||
text.inputEl.type = 'password';
|
}
|
||||||
return text
|
);
|
||||||
.setPlaceholder(i18nConfig.NotionAPIText)
|
|
||||||
.setValue(this.plugin.settings.notionAPINext)
|
const databaseIDNextEl = containerEl.createDiv('databaseID-next', (div) => {
|
||||||
.onChange(async (value) => {
|
div.style.alignItems = "center";
|
||||||
this.plugin.settings.notionAPINext = value;
|
div.style.borderTop = "none";
|
||||||
await this.plugin.saveSettings();
|
div.style.paddingBottom = "0";
|
||||||
})
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
|
|
||||||
const notionDatabaseID = new Setting(containerEl)
|
|
||||||
.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();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// notionDatabaseID.controlEl.querySelector('input').type='password'
|
// notionDatabaseID.controlEl.querySelector('input').type='password'
|
||||||
|
|
||||||
@@ -142,49 +175,112 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
this.plugin.settings.GeneralButton = value;
|
this.plugin.settings.GeneralButton = value;
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
await this.plugin.commands.updateCommand();
|
await this.plugin.commands.updateCommand();
|
||||||
|
|
||||||
|
// Clear existing components
|
||||||
|
CustomTitleEl.empty();
|
||||||
|
notionAPIGeneralEl.empty();
|
||||||
|
databaseIDGeneralEl.empty();
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
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;
|
||||||
|
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();
|
||||||
|
|
||||||
|
// Clear existing components
|
||||||
|
CustomTitleEl.empty();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
CustomTitleEl.style.borderTop = value ? "1px solid var(--background-modifier-border)" : "none";
|
||||||
|
CustomTitleEl.style.paddingTop = value ? "0.75em" : "0";
|
||||||
|
|
||||||
|
new Setting(notionAPIGeneralEl)
|
||||||
|
.setName(i18nConfig.NotionAPI)
|
||||||
|
.setDesc(i18nConfig.NotionAPIDesc)
|
||||||
|
.addText((text) => {
|
||||||
|
text.inputEl.type = 'password';
|
||||||
|
return text
|
||||||
|
.setPlaceholder(i18nConfig.NotionAPIText)
|
||||||
|
.setValue(this.plugin.settings.notionAPIGeneral)
|
||||||
|
.onChange(async (value) => {
|
||||||
|
this.plugin.settings.notionAPIGeneral = value;
|
||||||
|
await this.plugin.saveSettings();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
notionAPIGeneralEl.style.borderTop = value ? "1px solid var(--background-modifier-border)" : "none";
|
||||||
|
notionAPIGeneralEl.style.paddingTop = value ? "0.75em" : "0";
|
||||||
|
|
||||||
|
|
||||||
|
new Setting(databaseIDGeneralEl)
|
||||||
|
.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();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
databaseIDGeneralEl.style.borderTop = value ? "1px solid var(--background-modifier-border)" : "none";
|
||||||
|
databaseIDGeneralEl.style.paddingTop = value ? "0.75em" : "0";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
CustomTitleEl.style.borderTop = "none";
|
||||||
|
CustomTitleEl.style.paddingTop = "0";
|
||||||
|
notionAPIGeneralEl.style.borderTop = "none";
|
||||||
|
notionAPIGeneralEl.style.paddingTop = "0";
|
||||||
|
databaseIDGeneralEl.style.borderTop = "none";
|
||||||
|
databaseIDGeneralEl.style.paddingTop = "0";
|
||||||
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
new Setting(containerEl)
|
const CustomTitleEl = containerEl.createDiv('api-general', (div) => {
|
||||||
.setName(i18nConfig.NotionCustomTitle)
|
div.style.alignItems = "center";
|
||||||
.setDesc(i18nConfig.NotionCustomTitleDesc)
|
div.style.borderTop = "none";
|
||||||
.addToggle((toggle) =>
|
div.style.paddingBottom = "0";
|
||||||
toggle
|
}
|
||||||
.setValue(this.plugin.settings.CustomTitleButton)
|
);
|
||||||
.onChange(async (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) => {
|
const dynamicSettingContainer = containerEl.createDiv('setting-popover', (div) => {
|
||||||
div.style.display = "flex";
|
|
||||||
div.style.alignItems = "center";
|
div.style.alignItems = "center";
|
||||||
div.style.borderTop = "none";
|
div.style.borderTop = "none";
|
||||||
div.style.paddingBottom = "0";
|
div.style.paddingBottom = "0";
|
||||||
@@ -201,35 +297,22 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
// await this.plugin.saveSettings();
|
// await this.plugin.saveSettings();
|
||||||
// })
|
// })
|
||||||
// );
|
// );
|
||||||
new Setting(containerEl)
|
|
||||||
.setName(i18nConfig.NotionAPI)
|
|
||||||
.setDesc(i18nConfig.NotionAPIDesc)
|
|
||||||
.addText((text) => {
|
|
||||||
text.inputEl.type = 'password';
|
|
||||||
return text
|
|
||||||
.setPlaceholder(i18nConfig.NotionAPIText)
|
|
||||||
.setValue(this.plugin.settings.notionAPIGeneral)
|
|
||||||
.onChange(async (value) => {
|
|
||||||
this.plugin.settings.notionAPIGeneral = value;
|
|
||||||
await this.plugin.saveSettings();
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
new Setting(containerEl)
|
const notionAPIGeneralEl = containerEl.createDiv('api-general', (div) => {
|
||||||
.setName(i18nConfig.DatabaseID)
|
div.style.alignItems = "center";
|
||||||
.setDesc(i18nConfig.NotionAPIDesc)
|
div.style.borderTop = "none";
|
||||||
.addText((text) => {
|
div.style.paddingBottom = "0";
|
||||||
text.inputEl.type = 'password';
|
}
|
||||||
return text
|
);
|
||||||
.setPlaceholder(i18nConfig.NotionIDText)
|
|
||||||
.setValue(this.plugin.settings.databaseIDGeneral)
|
const databaseIDGeneralEl = containerEl.createDiv('databaseID-general', (div) => {
|
||||||
.onChange(async (value) => {
|
div.style.alignItems = "center";
|
||||||
this.plugin.settings.databaseIDGeneral = value;
|
div.style.borderTop = "none";
|
||||||
await this.plugin.saveSettings();
|
div.style.paddingBottom = "0";
|
||||||
})
|
}
|
||||||
}
|
);
|
||||||
);
|
|
||||||
|
|
||||||
// Custom Database Settings
|
// Custom Database Settings
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user