mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-30 00:48:36 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
388693d5b4 | ||
|
|
dda6710fe9 | ||
|
|
76ea9a4aee | ||
|
|
856f83e8a1 |
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@@ -20,6 +20,14 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: "18"
|
node-version: "18"
|
||||||
|
|
||||||
|
- name: Generate changelog
|
||||||
|
id: changelog
|
||||||
|
uses: release-changelog/action@v1.0.0
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.REPO_ACCESS_TOKEN }}
|
||||||
|
version: ${{ github.ref }}
|
||||||
|
file: CHANGELOG.md
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
id: build
|
id: build
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
18
CHANGELOG.md
Normal file
18
CHANGELOG.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Changelog v2.1.0
|
||||||
|
|
||||||
|
## Feature
|
||||||
|
|
||||||
|
- add confirmation interface for deleting a database
|
||||||
|
- 增加删除数据库的确认界面
|
||||||
|
|
||||||
|
## Fix
|
||||||
|
|
||||||
|
- fix the typo in the edit database modal
|
||||||
|
- improve the logic for the database editing
|
||||||
|
- 修复编辑数据库界面的标题错误
|
||||||
|
- 改进数据库编辑界面的逻辑
|
||||||
|
|
||||||
|
## TODO
|
||||||
|
|
||||||
|
- [ ] add the support for the customised properties of general databases
|
||||||
|
- [ ] 增加对普通数据库自定义属性的支持
|
||||||
10
README.md
10
README.md
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
[](https://github.com/jxpeng98/obsidian-to-NotionNext/actions/workflows/test.yml)
|
[](https://github.com/jxpeng98/obsidian-to-NotionNext/actions/workflows/test.yml)
|
||||||
[](https://github.com/jxpeng98/obsidian-to-NotionNext/actions/workflows/release.yml)
|
[](https://github.com/jxpeng98/obsidian-to-NotionNext/actions/workflows/release.yml)
|
||||||
[](https://GitHub.com/jxpeng98/obsidian-to-NotionNext/releases/)
|
[](https://GitHub.com/jxpeng98/obsidian-to-NotionNext/releases/)
|
||||||
[](https://github.com/jxpeng98/obsidian-to-NotionNext/releases/)
|
[](https://github.com/jxpeng98/obsidian-to-NotionNext/releases/)
|
||||||
|
|
||||||
|
[//]: # ([](https://GitHub.com/jxpeng98/obsidian-to-NotionNext/releases/))
|
||||||
|
|
||||||
[中文文档](README-zh.md)
|
[中文文档](README-zh.md)
|
||||||
|
|
||||||
Thanks to the [original author](https://github.com/EasyChris/obsidian-to-notion) for developing such a useful plugin that can synchronize Obsidian to Notion. However, the original repository can only sync Name and Tag information. For those like me who use [NotionNext](https://github.com/tangly1024/NotionNext) to set up their website, this presents some limitations. Every time I import, I need to make a lot of modifications.
|
Thanks to the [original author](https://github.com/EasyChris/obsidian-to-notion) for developing such a useful plugin that can synchronize Obsidian to Notion. However, the original repository can only sync Name and Tag information. For those like me who use [NotionNext](https://github.com/tangly1024/NotionNext) to set up their website, this presents some limitations. Every time I import, I need to make a lot of modifications.
|
||||||
@@ -23,6 +25,12 @@ Thus, based on the [original author's work](https://github.com/EasyChris/obsidia
|
|||||||
|
|
||||||
## Update
|
## Update
|
||||||
|
|
||||||
|
### 2.1.0
|
||||||
|
|
||||||
|
- add confirmation interface for deleting a database 增加删除数据库的确认界面
|
||||||
|
- fix the typo in the edit database modal 修复编辑数据库界面的标题错误
|
||||||
|
- improve the logic for the database editing 改进数据库编辑界面的逻辑
|
||||||
|
|
||||||
### 2.0.1
|
### 2.0.1
|
||||||
|
|
||||||
- Add the preview and edit function for database details in the plugin settings. 增加插件设置中数据库详情的预览和编辑功能。
|
- Add the preview and edit function for database details in the plugin settings. 增加插件设置中数据库详情的预览和编辑功能。
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"id": "share-to-notionnext",
|
"id": "share-to-notionnext",
|
||||||
"name": "Share to NotionNext",
|
"name": "Share to NotionNext",
|
||||||
"version": "2.0.1",
|
"version": "2.1.1",
|
||||||
"minAppVersion": "0.0.1",
|
"minAppVersion": "0.0.1",
|
||||||
"description": "Shares obsidian md file to notion with notion api for NotionNext web deploy, originally created by EasyChris/obsidian-to-notion.",
|
"description": "Shares obsidian md file to notion with notion api for NotionNext web deploy, originally created by EasyChris/obsidian-to-notion.",
|
||||||
"author": "EasyChris, jxpeng98",
|
"author": "EasyChris, jxpeng98",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "share-to-notionnext",
|
"name": "share-to-notionnext",
|
||||||
"version": "2.0.1",
|
"version": "2.1.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "Shares obsidian md file to notion with notion api for NotionNext web deploy, originally created by EasyChris/obsidian-to-notion.",
|
"description": "Shares obsidian md file to notion with notion api for NotionNext web deploy, originally created by EasyChris/obsidian-to-notion.",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
|
|||||||
64
src/ui/DeleteModal.ts
Normal file
64
src/ui/DeleteModal.ts
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
import {App, ButtonComponent, Modal, Setting} from "obsidian";
|
||||||
|
import {DatabaseDetails, ObsidianSettingTab} from "./settingTabs";
|
||||||
|
import ObsidianSyncNotionPlugin from "../main";
|
||||||
|
|
||||||
|
export class DeleteModal extends Modal {
|
||||||
|
data: Record<string, any> = {
|
||||||
|
deleted: false,
|
||||||
|
}
|
||||||
|
plugin: ObsidianSyncNotionPlugin;
|
||||||
|
settingTab: ObsidianSettingTab;
|
||||||
|
dbDetails: DatabaseDetails
|
||||||
|
|
||||||
|
constructor(app: App, plugin: ObsidianSyncNotionPlugin, settingTab: ObsidianSettingTab, dbDetails: DatabaseDetails) {
|
||||||
|
super(app);
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.settingTab = settingTab;
|
||||||
|
this.dbDetails = dbDetails;
|
||||||
|
}
|
||||||
|
|
||||||
|
display() {
|
||||||
|
this.containerEl.addClass("delete-modal");
|
||||||
|
this.titleEl.setText('Delete Database');
|
||||||
|
|
||||||
|
let {contentEl} = this;
|
||||||
|
contentEl.empty();
|
||||||
|
|
||||||
|
const deleteDiv = contentEl.createDiv('delete-div');
|
||||||
|
deleteDiv.createEl('h4', {text: 'Are you sure you want to delete the following database?'});
|
||||||
|
deleteDiv.createEl('h2', {text: this.dbDetails.fullName + ' (' + this.dbDetails.abName + ', ' + this.dbDetails.format +')'});
|
||||||
|
|
||||||
|
|
||||||
|
// add delete button
|
||||||
|
let footerEl = contentEl.createDiv('save-button');
|
||||||
|
let deleteButton = new Setting(footerEl)
|
||||||
|
|
||||||
|
deleteButton
|
||||||
|
.addButton((button: ButtonComponent): ButtonComponent => {
|
||||||
|
return button
|
||||||
|
.setTooltip("Delete")
|
||||||
|
.setIcon("trash")
|
||||||
|
.onClick(async () => {
|
||||||
|
this.data.deleted = true;
|
||||||
|
this.close();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
deleteButton.addExtraButton((button) => {
|
||||||
|
return button
|
||||||
|
.setTooltip('Cancel')
|
||||||
|
.setIcon('cross')
|
||||||
|
.onClick(() => {
|
||||||
|
this.data.deleted = false;
|
||||||
|
this.close();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
onOpen() {
|
||||||
|
this.display();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
294
src/ui/EditModal.ts
Normal file
294
src/ui/EditModal.ts
Normal file
@@ -0,0 +1,294 @@
|
|||||||
|
import {App, ButtonComponent, Modal, Setting} from "obsidian";
|
||||||
|
import {SettingModal} from "./settingModal";
|
||||||
|
import ObsidianSyncNotionPlugin from "../main";
|
||||||
|
import {DatabaseDetails, ObsidianSettingTab} from "./settingTabs";
|
||||||
|
import {i18nConfig} from "../lang/I18n";
|
||||||
|
|
||||||
|
export class EditModal extends SettingModal {
|
||||||
|
dataTemp: Record<string, any> = {
|
||||||
|
databaseFormatTemp: '',
|
||||||
|
// databaseFormatTempInd: false,
|
||||||
|
databaseFullNameTemp: '',
|
||||||
|
// databaseFullNameTempInd: false,
|
||||||
|
databaseAbbreviateNameTemp: '',
|
||||||
|
// databaseAbbreviateNameTempInd: false,
|
||||||
|
notionAPITemp: '',
|
||||||
|
// notionAPITempInd: false,
|
||||||
|
databaseIDTemp: '',
|
||||||
|
// databaseIDTempInd: false,
|
||||||
|
tagButtonTemp: false,
|
||||||
|
// tagButtonTempInd: false,
|
||||||
|
customTitleButtonTemp: false,
|
||||||
|
// customTitleButtonTempInd: false,
|
||||||
|
customTitleNameTemp: '',
|
||||||
|
// customTitleNameTempInd: false,
|
||||||
|
// customValues: '',
|
||||||
|
savedTemp: false,
|
||||||
|
savedTempInd: false,
|
||||||
|
};
|
||||||
|
dataPrev: Record<string, any> = {
|
||||||
|
databaseFormatPrev: '',
|
||||||
|
// databaseFormatPrevInd: false,
|
||||||
|
databaseFullNamePrev: '',
|
||||||
|
// databaseFullNamePrevInd: false,
|
||||||
|
databaseAbbreviateNamePrev: '',
|
||||||
|
// databaseAbbreviateNamePrevInd: false,
|
||||||
|
notionAPIPrev: '',
|
||||||
|
// notionAPIPrevInd: false,
|
||||||
|
databaseIDPrev: '',
|
||||||
|
// databaseIDPrevInd: false,
|
||||||
|
tagButtonPrev: false,
|
||||||
|
// tagButtonPrevInd: false,
|
||||||
|
customTitleButtonPrev: false,
|
||||||
|
// customTitleButtonPrevInd: false,
|
||||||
|
customTitleNamePrev: '',
|
||||||
|
// customTitleNamePrevInd: false,
|
||||||
|
// customValues: '',
|
||||||
|
savedPrev: false,
|
||||||
|
savedPrevInd: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
plugin: ObsidianSyncNotionPlugin;
|
||||||
|
settingTab: ObsidianSettingTab;
|
||||||
|
dbDetails: DatabaseDetails;
|
||||||
|
|
||||||
|
constructor(app: App, plugin: ObsidianSyncNotionPlugin, settingTab: ObsidianSettingTab, dbDetails: DatabaseDetails) {
|
||||||
|
super(app, plugin, settingTab);
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.settingTab = settingTab;
|
||||||
|
if (dbDetails) {
|
||||||
|
// Temp details
|
||||||
|
this.dataTemp.databaseFormatTemp = dbDetails.format;
|
||||||
|
this.dataTemp.databaseFullNameTemp = dbDetails.fullName;
|
||||||
|
this.dataTemp.databaseAbbreviateNameTemp = dbDetails.abName;
|
||||||
|
this.dataTemp.notionAPITemp = dbDetails.notionAPI;
|
||||||
|
this.dataTemp.databaseIDTemp = dbDetails.databaseID;
|
||||||
|
this.dataTemp.tagButtonTemp = dbDetails.tagButton;
|
||||||
|
this.dataTemp.customTitleButtonTemp = dbDetails.customTitleButton;
|
||||||
|
this.dataTemp.customTitleNameTemp = dbDetails.customTitleName;
|
||||||
|
// this.dataTemp.customValues = dbDetails.customValues;
|
||||||
|
this.dataTemp.savedTemp = dbDetails.saved;
|
||||||
|
|
||||||
|
// Prev details
|
||||||
|
this.dataPrev.databaseFormatPrev = dbDetails.format;
|
||||||
|
this.dataPrev.databaseFullNamePrev = dbDetails.fullName;
|
||||||
|
this.dataPrev.databaseAbbreviateNamePrev = dbDetails.abName;
|
||||||
|
this.dataPrev.notionAPIPrev = dbDetails.notionAPI;
|
||||||
|
this.dataPrev.databaseIDPrev = dbDetails.databaseID;
|
||||||
|
this.dataPrev.tagButtonPrev = dbDetails.tagButton;
|
||||||
|
this.dataPrev.customTitleButtonPrev = dbDetails.customTitleButton;
|
||||||
|
this.dataPrev.customTitleNamePrev = dbDetails.customTitleName;
|
||||||
|
// this.dataTemp.customValues = dbDetails.customValues;
|
||||||
|
this.dataPrev.savedPrev = dbDetails.saved;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
display(): void {
|
||||||
|
this.containerEl.addClass("edit-modal");
|
||||||
|
this.titleEl.setText('Edit Database');
|
||||||
|
|
||||||
|
let {contentEl} = this;
|
||||||
|
contentEl.empty();
|
||||||
|
|
||||||
|
const editDiv = contentEl.createDiv('edit-div');
|
||||||
|
const nextTabs = contentEl.createDiv('next-tabs');
|
||||||
|
|
||||||
|
new Setting(editDiv)
|
||||||
|
.setName(i18nConfig.databaseFormat)
|
||||||
|
.setDesc(i18nConfig.databaseFormatDesc)
|
||||||
|
.addDropdown((component) => {
|
||||||
|
component
|
||||||
|
.addOption('none', '')
|
||||||
|
.addOption('general', i18nConfig.databaseGeneral)
|
||||||
|
.addOption('next', i18nConfig.databaseNext)
|
||||||
|
// .addOption('custom', i18nConfig.databaseCustom)
|
||||||
|
.setValue(this.dataTemp.databaseFormatTemp)
|
||||||
|
.onChange(async (value) => {
|
||||||
|
this.dataTemp.databaseFormatTemp = value;
|
||||||
|
nextTabs.empty();
|
||||||
|
this.updateContentBasedOnSelection(value, nextTabs);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Initialize content based on the current dropdown value
|
||||||
|
this.updateContentBasedOnSelection(this.dataTemp.databaseFormatTemp, nextTabs);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// add save button
|
||||||
|
let footerEl = contentEl.createDiv('save-button');
|
||||||
|
let saveButton = new Setting(footerEl)
|
||||||
|
saveButton.addButton((button: ButtonComponent) => {
|
||||||
|
return button
|
||||||
|
.setTooltip('Save')
|
||||||
|
.setIcon('checkmark')
|
||||||
|
.onClick(async () => {
|
||||||
|
this.dataTemp.savedTempInd = true;
|
||||||
|
this.dataTemp.savedTemp = true;
|
||||||
|
this.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
saveButton.addExtraButton((button) => {
|
||||||
|
return button
|
||||||
|
.setTooltip('Cancel')
|
||||||
|
.setIcon('cross')
|
||||||
|
.onClick(() => {
|
||||||
|
this.dataTemp.savedTempInd = false;
|
||||||
|
this.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
onOpen(): void {
|
||||||
|
this.display()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
updateContentBasedOnSelection(value: string, nextTabs: HTMLElement): void {
|
||||||
|
// Clear existing content
|
||||||
|
nextTabs.empty();
|
||||||
|
|
||||||
|
// Generate content based on the selected value
|
||||||
|
if (value === 'general') {
|
||||||
|
nextTabs.createEl('h3', { text: i18nConfig.NotionGeneralSettingHeader });
|
||||||
|
|
||||||
|
// add full name
|
||||||
|
this.createSettingEl(nextTabs, i18nConfig.databaseFullName, i18nConfig.databaseFullNameDesc, 'text', i18nConfig.databaseFullNameText, this.dataTemp.databaseFullNameTemp,'dataTemp', 'databaseFullNameTemp')
|
||||||
|
|
||||||
|
// add abbreviate name
|
||||||
|
this.createSettingEl(nextTabs, i18nConfig.databaseAbbreviateName, i18nConfig.databaseAbbreviateNameDesc, 'text', i18nConfig.databaseAbbreviateNameText, this.dataTemp.databaseAbbreviateNameTemp, 'dataTemp','databaseAbbreviateNameTemp')
|
||||||
|
|
||||||
|
// tag button
|
||||||
|
this.createSettingEl(nextTabs, i18nConfig.NotionTagButton, i18nConfig.NotionTagButtonDesc, 'toggle', i18nConfig.NotionCustomTitleText, this.dataTemp.tagButtonTemp, 'dataTemp','tagButtonTemp')
|
||||||
|
|
||||||
|
// add custom title button
|
||||||
|
|
||||||
|
new Setting(nextTabs)
|
||||||
|
.setName(i18nConfig.NotionCustomTitle)
|
||||||
|
.setDesc(i18nConfig.NotionCustomTitleDesc)
|
||||||
|
.addToggle((toggle) =>
|
||||||
|
toggle
|
||||||
|
.setValue(this.dataTemp.CustomTitleButtonTemp)
|
||||||
|
.onChange(async (value) => {
|
||||||
|
this.dataTemp.CustomTitleButtonTemp = value;
|
||||||
|
|
||||||
|
this.updateSettingEl(CustomNameEl, value)
|
||||||
|
|
||||||
|
// this.updateSettingEl(CustomValuesEl, value)
|
||||||
|
|
||||||
|
// await this.plugin.saveSettings();
|
||||||
|
// await this.plugin.commands.updateCommand();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// add custom title name
|
||||||
|
const CustomNameEl = this.createStyleDiv('custom-name', (this.dataTemp.CustomTitleButtonTemp), nextTabs);
|
||||||
|
this.createSettingEl(CustomNameEl, i18nConfig.NotionCustomTitleName, i18nConfig.NotionCustomTitleNameDesc, 'text', i18nConfig.NotionCustomTitleText, this.dataTemp.CustomTitleNameTemp,'dataTemp', 'CustomTitleNameTemp')
|
||||||
|
|
||||||
|
|
||||||
|
// add api key
|
||||||
|
this.createSettingEl(nextTabs, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.dataTemp.notionAPITemp, 'dataTemp','notionAPITemp')
|
||||||
|
|
||||||
|
// add database id
|
||||||
|
this.createSettingEl(nextTabs, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.dataTemp.databaseIDTemp, 'dataTemp','databaseIDTemp')
|
||||||
|
|
||||||
|
|
||||||
|
} else if (value === 'next') {
|
||||||
|
|
||||||
|
nextTabs.createEl('h3', { text: i18nConfig.NotionNextSettingHeader });
|
||||||
|
|
||||||
|
// add full name
|
||||||
|
this.createSettingEl(nextTabs, i18nConfig.databaseFullName, i18nConfig.databaseFullNameDesc, 'text', i18nConfig.databaseFullNameText, this.dataTemp.databaseFullNameTemp, 'dataTemp','databaseFullNameTemp')
|
||||||
|
|
||||||
|
// add abbreviate name
|
||||||
|
this.createSettingEl(nextTabs, i18nConfig.databaseAbbreviateName, i18nConfig.databaseAbbreviateNameDesc, 'text', i18nConfig.databaseAbbreviateNameText, this.dataTemp.databaseAbbreviateNameTemp, 'dataTemp','databaseAbbreviateNameTemp')
|
||||||
|
|
||||||
|
// add api key
|
||||||
|
this.createSettingEl(nextTabs, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.dataTemp.notionAPITemp, 'dataTemp','notionAPITemp')
|
||||||
|
|
||||||
|
|
||||||
|
// add database id
|
||||||
|
this.createSettingEl(nextTabs, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.dataTemp.databaseIDTemp, 'dataTemp','databaseIDTemp')
|
||||||
|
|
||||||
|
} else if (value === 'custom') {
|
||||||
|
nextTabs.createEl('h3', { text: i18nConfig.NotionCustomSettingHeader});
|
||||||
|
|
||||||
|
// add full name
|
||||||
|
this.createSettingEl(nextTabs, i18nConfig.databaseFullName, i18nConfig.databaseFullNameDesc, 'text', i18nConfig.databaseFullNameText, this.dataTemp.databaseFullNameTemp,'dataTemp', 'databaseFullNameTemp')
|
||||||
|
|
||||||
|
// add abbreviate name
|
||||||
|
this.createSettingEl(nextTabs, i18nConfig.databaseAbbreviateName, i18nConfig.databaseAbbreviateNameDesc, 'text', i18nConfig.databaseAbbreviateNameText, this.dataTemp.databaseAbbreviateNameTemp, 'dataTemp','databaseAbbreviateNameTemp')
|
||||||
|
|
||||||
|
// tag button
|
||||||
|
this.createSettingEl(nextTabs, i18nConfig.NotionTagButton, i18nConfig.NotionTagButtonDesc, 'toggle', i18nConfig.NotionCustomTitleText, this.dataTemp.tagButtonTemp, 'dataTemp','tagButtonTemp')
|
||||||
|
|
||||||
|
// add custom title button
|
||||||
|
|
||||||
|
new Setting(nextTabs)
|
||||||
|
.setName(i18nConfig.NotionCustomTitle)
|
||||||
|
.setDesc(i18nConfig.NotionCustomTitleDesc)
|
||||||
|
.addToggle((toggle) =>
|
||||||
|
toggle
|
||||||
|
.setValue(this.dataTemp.CustomTitleButtonTemp)
|
||||||
|
.onChange(async (value) => {
|
||||||
|
this.dataTemp.CustomTitleButtonTemp = value;
|
||||||
|
|
||||||
|
this.updateSettingEl(CustomNameEl, value)
|
||||||
|
|
||||||
|
// this.updateSettingEl(CustomValuesEl, value)
|
||||||
|
|
||||||
|
// await this.plugin.saveSettings();
|
||||||
|
// await this.plugin.commands.updateCommand();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// add custom title name
|
||||||
|
const CustomNameEl = this.createStyleDiv('custom-name', (this.dataTemp.CustomTitleButtonTemp), nextTabs);
|
||||||
|
this.createSettingEl(CustomNameEl, i18nConfig.NotionCustomTitleName, i18nConfig.NotionCustomTitleNameDesc, 'text', i18nConfig.NotionCustomTitleText, this.dataTemp.CustomTitleNameTemp,'dataTemp', 'CustomTitleNameTemp')
|
||||||
|
|
||||||
|
// // add custom values
|
||||||
|
// const CustomValuesEl = this.createStyleDiv('custom-values', (this.dataTemp.CustomTitleButton), nextTabs);
|
||||||
|
// new Setting(CustomValuesEl)
|
||||||
|
// .setName(i18nConfig.NotionCustomValues)
|
||||||
|
// .setDesc(i18nConfig.NotionCustomValuesDesc)
|
||||||
|
// .addTextArea((text) => {
|
||||||
|
// return text
|
||||||
|
// .setPlaceholder(i18nConfig.NotionCustomValuesText)
|
||||||
|
// .setValue(this.dataTemp.CustomValues)
|
||||||
|
// .onChange(async (value) => {
|
||||||
|
// this.dataTemp.CustomValues = value;
|
||||||
|
// await this.plugin.saveSettings();
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
// add api key
|
||||||
|
const notionAPIGeneralEl = this.createStyleDiv('api-general', this.plugin.settings.GeneralButton, nextTabs);
|
||||||
|
this.createSettingEl(notionAPIGeneralEl, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.dataTemp.notionAPITemp, 'dataTemp','notionAPITemp')
|
||||||
|
|
||||||
|
// add database id
|
||||||
|
const databaseIDGeneralEl = this.createStyleDiv('databaseID-general', this.plugin.settings.GeneralButton, nextTabs);
|
||||||
|
this.createSettingEl(databaseIDGeneralEl, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.dataTemp.databaseIDTemp, 'dataTemp', 'databaseIDTemp')
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
createStyleDiv(className: string, commandValue: boolean = false, parentEl: HTMLElement): HTMLDivElement {
|
||||||
|
return super.createStyleDiv(className, commandValue, parentEl);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSettingEl(element: HTMLElement, commandValue: boolean) {
|
||||||
|
super.updateSettingEl(element, commandValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
createSettingEl(contentEl: HTMLElement, name: string, desc: string, type: string, placeholder: string, holderValue: any, dataRecord: string, settingsKey: string): Setting {
|
||||||
|
return super.createSettingEl(contentEl, name, desc, type, placeholder, holderValue, dataRecord, settingsKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
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')
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -8,11 +8,10 @@ import {
|
|||||||
import { i18nConfig } from "../lang/I18n";
|
import { i18nConfig } from "../lang/I18n";
|
||||||
import ObsidianSyncNotionPlugin from "../main";
|
import ObsidianSyncNotionPlugin from "../main";
|
||||||
import {DatabaseDetails, ObsidianSettingTab} from "./settingTabs";
|
import {DatabaseDetails, ObsidianSettingTab} from "./settingTabs";
|
||||||
import {SettingNextTabs} from "./settingNextTabs";
|
|
||||||
import {SettingGeneralTabs} from "./settingGeneralTabs";
|
|
||||||
|
|
||||||
|
|
||||||
export class SettingModal extends Modal {
|
export class SettingModal extends Modal {
|
||||||
|
[key: string]: any; // Index signature
|
||||||
data: Record<string, any> = {
|
data: Record<string, any> = {
|
||||||
databaseFormat: 'none',
|
databaseFormat: 'none',
|
||||||
databaseFullName: '',
|
databaseFullName: '',
|
||||||
@@ -139,13 +138,13 @@ export class SettingModal extends Modal {
|
|||||||
nextTabs.createEl('h3', { text: i18nConfig.NotionGeneralSettingHeader });
|
nextTabs.createEl('h3', { text: i18nConfig.NotionGeneralSettingHeader });
|
||||||
|
|
||||||
// add full name
|
// add full name
|
||||||
this.createSettingEl(nextTabs, i18nConfig.databaseFullName, i18nConfig.databaseFullNameDesc, 'text', i18nConfig.databaseFullNameText, this.data.databaseFullName, 'databaseFullName')
|
this.createSettingEl(nextTabs, i18nConfig.databaseFullName, i18nConfig.databaseFullNameDesc, 'text', i18nConfig.databaseFullNameText, this.data.databaseFullName, 'data','databaseFullName')
|
||||||
|
|
||||||
// add abbreviate name
|
// add abbreviate name
|
||||||
this.createSettingEl(nextTabs, i18nConfig.databaseAbbreviateName, i18nConfig.databaseAbbreviateNameDesc, 'text', i18nConfig.databaseAbbreviateNameText, this.data.databaseAbbreviateName, 'databaseAbbreviateName')
|
this.createSettingEl(nextTabs, i18nConfig.databaseAbbreviateName, i18nConfig.databaseAbbreviateNameDesc, 'text', i18nConfig.databaseAbbreviateNameText, this.data.databaseAbbreviateName, 'data','databaseAbbreviateName')
|
||||||
|
|
||||||
// tag button
|
// tag button
|
||||||
this.createSettingEl(nextTabs, i18nConfig.NotionTagButton, i18nConfig.NotionTagButtonDesc, 'toggle', i18nConfig.NotionCustomTitleText, this.data.tagButton, 'tagButton')
|
this.createSettingEl(nextTabs, i18nConfig.NotionTagButton, i18nConfig.NotionTagButtonDesc, 'toggle', i18nConfig.NotionCustomTitleText, this.data.tagButton, 'data','tagButton')
|
||||||
|
|
||||||
// add custom title button
|
// add custom title button
|
||||||
|
|
||||||
@@ -162,22 +161,22 @@ export class SettingModal extends Modal {
|
|||||||
|
|
||||||
// this.updateSettingEl(CustomValuesEl, value)
|
// this.updateSettingEl(CustomValuesEl, value)
|
||||||
|
|
||||||
await this.plugin.saveSettings();
|
// await this.plugin.saveSettings();
|
||||||
await this.plugin.commands.updateCommand();
|
// await this.plugin.commands.updateCommand();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// add custom title name
|
// add custom title name
|
||||||
const CustomNameEl = this.createStyleDiv('custom-name', (this.data.CustomTitleButton), nextTabs);
|
const CustomNameEl = this.createStyleDiv('custom-name', (this.data.CustomTitleButton), nextTabs);
|
||||||
this.createSettingEl(CustomNameEl, i18nConfig.NotionCustomTitleName, i18nConfig.NotionCustomTitleNameDesc, 'text', i18nConfig.NotionCustomTitleText, this.data.CustomTitleName, 'CustomTitleName')
|
this.createSettingEl(CustomNameEl, i18nConfig.NotionCustomTitleName, i18nConfig.NotionCustomTitleNameDesc, 'text', i18nConfig.NotionCustomTitleText, this.data.CustomTitleName, 'data','CustomTitleName')
|
||||||
|
|
||||||
|
|
||||||
// add api key
|
// add api key
|
||||||
this.createSettingEl(nextTabs, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.data.notionAPI, 'notionAPI')
|
this.createSettingEl(nextTabs, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.data.notionAPI, 'data','notionAPI')
|
||||||
|
|
||||||
// add database id
|
// add database id
|
||||||
this.createSettingEl(nextTabs, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.data.databaseID, 'databaseID')
|
this.createSettingEl(nextTabs, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.data.databaseID, 'data','databaseID')
|
||||||
|
|
||||||
|
|
||||||
} else if (value === 'next') {
|
} else if (value === 'next') {
|
||||||
@@ -185,29 +184,29 @@ export class SettingModal extends Modal {
|
|||||||
nextTabs.createEl('h3', { text: i18nConfig.NotionNextSettingHeader });
|
nextTabs.createEl('h3', { text: i18nConfig.NotionNextSettingHeader });
|
||||||
|
|
||||||
// add full name
|
// add full name
|
||||||
this.createSettingEl(nextTabs, i18nConfig.databaseFullName, i18nConfig.databaseFullNameDesc, 'text', i18nConfig.databaseFullNameText, this.data.databaseFullName, 'databaseFullName')
|
this.createSettingEl(nextTabs, i18nConfig.databaseFullName, i18nConfig.databaseFullNameDesc, 'text', i18nConfig.databaseFullNameText, this.data.databaseFullName,'data','databaseFullName')
|
||||||
|
|
||||||
// add abbreviate name
|
// add abbreviate name
|
||||||
this.createSettingEl(nextTabs, i18nConfig.databaseAbbreviateName, i18nConfig.databaseAbbreviateNameDesc, 'text', i18nConfig.databaseAbbreviateNameText, this.data.databaseAbbreviateName, 'databaseAbbreviateName')
|
this.createSettingEl(nextTabs, i18nConfig.databaseAbbreviateName, i18nConfig.databaseAbbreviateNameDesc, 'text', i18nConfig.databaseAbbreviateNameText, this.data.databaseAbbreviateName, 'data','databaseAbbreviateName')
|
||||||
|
|
||||||
// add api key
|
// add api key
|
||||||
this.createSettingEl(nextTabs, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.data.notionAPI, 'notionAPI')
|
this.createSettingEl(nextTabs, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.data.notionAPI, 'data','notionAPI')
|
||||||
|
|
||||||
|
|
||||||
// add database id
|
// add database id
|
||||||
this.createSettingEl(nextTabs, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.data.databaseID, 'databaseID')
|
this.createSettingEl(nextTabs, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.data.databaseID, 'data','databaseID')
|
||||||
|
|
||||||
} else if (value === 'custom') {
|
} else if (value === 'custom') {
|
||||||
nextTabs.createEl('h3', { text: i18nConfig.NotionCustomSettingHeader});
|
nextTabs.createEl('h3', { text: i18nConfig.NotionCustomSettingHeader});
|
||||||
|
|
||||||
// add full name
|
// add full name
|
||||||
this.createSettingEl(nextTabs, i18nConfig.databaseFullName, i18nConfig.databaseFullNameDesc, 'text', i18nConfig.databaseFullNameText, this.data.databaseFullName, 'databaseFullName')
|
this.createSettingEl(nextTabs, i18nConfig.databaseFullName, i18nConfig.databaseFullNameDesc, 'text', i18nConfig.databaseFullNameText, this.data.databaseFullName, 'data','databaseFullName')
|
||||||
|
|
||||||
// add abbreviate name
|
// add abbreviate name
|
||||||
this.createSettingEl(nextTabs, i18nConfig.databaseAbbreviateName, i18nConfig.databaseAbbreviateNameDesc, 'text', i18nConfig.databaseAbbreviateNameText, this.data.databaseAbbreviateName, 'databaseAbbreviateName')
|
this.createSettingEl(nextTabs, i18nConfig.databaseAbbreviateName, i18nConfig.databaseAbbreviateNameDesc, 'text', i18nConfig.databaseAbbreviateNameText, this.data.databaseAbbreviateName, 'data','databaseAbbreviateName')
|
||||||
|
|
||||||
// tag button
|
// tag button
|
||||||
this.createSettingEl(nextTabs, i18nConfig.NotionTagButton, i18nConfig.NotionTagButtonDesc, 'toggle', i18nConfig.NotionCustomTitleText, this.data.tagButton, 'tagButton')
|
this.createSettingEl(nextTabs, i18nConfig.NotionTagButton, i18nConfig.NotionTagButtonDesc, 'toggle', i18nConfig.NotionCustomTitleText, this.data.tagButton,'data', 'tagButton')
|
||||||
|
|
||||||
// add custom title button
|
// add custom title button
|
||||||
|
|
||||||
@@ -224,15 +223,15 @@ export class SettingModal extends Modal {
|
|||||||
|
|
||||||
// this.updateSettingEl(CustomValuesEl, value)
|
// this.updateSettingEl(CustomValuesEl, value)
|
||||||
|
|
||||||
await this.plugin.saveSettings();
|
// await this.plugin.saveSettings();
|
||||||
await this.plugin.commands.updateCommand();
|
// await this.plugin.commands.updateCommand();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// add custom title name
|
// add custom title name
|
||||||
const CustomNameEl = this.createStyleDiv('custom-name', (this.data.CustomTitleButton), nextTabs);
|
const CustomNameEl = this.createStyleDiv('custom-name', (this.data.CustomTitleButton), nextTabs);
|
||||||
this.createSettingEl(CustomNameEl, i18nConfig.NotionCustomTitleName, i18nConfig.NotionCustomTitleNameDesc, 'text', i18nConfig.NotionCustomTitleText, this.data.CustomTitleName, 'CustomTitleName')
|
this.createSettingEl(CustomNameEl, i18nConfig.NotionCustomTitleName, i18nConfig.NotionCustomTitleNameDesc, 'text', i18nConfig.NotionCustomTitleText, this.data.CustomTitleName,'data', 'CustomTitleName')
|
||||||
|
|
||||||
// // add custom values
|
// // add custom values
|
||||||
// const CustomValuesEl = this.createStyleDiv('custom-values', (this.data.CustomTitleButton), nextTabs);
|
// const CustomValuesEl = this.createStyleDiv('custom-values', (this.data.CustomTitleButton), nextTabs);
|
||||||
@@ -252,11 +251,11 @@ export class SettingModal extends Modal {
|
|||||||
|
|
||||||
// add api key
|
// add api key
|
||||||
const notionAPIGeneralEl = this.createStyleDiv('api-general', this.plugin.settings.GeneralButton, nextTabs);
|
const notionAPIGeneralEl = this.createStyleDiv('api-general', this.plugin.settings.GeneralButton, nextTabs);
|
||||||
this.createSettingEl(notionAPIGeneralEl, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.data.notionAPI, 'notionAPI')
|
this.createSettingEl(notionAPIGeneralEl, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.data.notionAPI,'data', 'notionAPI')
|
||||||
|
|
||||||
// add database id
|
// add database id
|
||||||
const databaseIDGeneralEl = this.createStyleDiv('databaseID-general', this.plugin.settings.GeneralButton, nextTabs);
|
const databaseIDGeneralEl = this.createStyleDiv('databaseID-general', this.plugin.settings.GeneralButton, nextTabs);
|
||||||
this.createSettingEl(databaseIDGeneralEl, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.data.databaseID, 'databaseID')
|
this.createSettingEl(databaseIDGeneralEl, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.data.databaseID, 'data', 'databaseID')
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -285,7 +284,7 @@ export class SettingModal extends Modal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// function to add one setting element in the setting tab.
|
// function to add one setting element in the setting tab.
|
||||||
public createSettingEl(contentEl: HTMLElement, name: string, desc: string, type: string, placeholder: string, holderValue: any,settingsKey: string) {
|
public createSettingEl(contentEl: HTMLElement, name: string, desc: string, type: string, placeholder: string, holderValue: any, dataRecord: string, settingsKey: string) {
|
||||||
if (type === 'password') {
|
if (type === 'password') {
|
||||||
return new Setting(contentEl)
|
return new Setting(contentEl)
|
||||||
.setName(name)
|
.setName(name)
|
||||||
@@ -296,7 +295,7 @@ export class SettingModal extends Modal {
|
|||||||
.setPlaceholder(placeholder)
|
.setPlaceholder(placeholder)
|
||||||
.setValue(holderValue)
|
.setValue(holderValue)
|
||||||
.onChange(async (value) => {
|
.onChange(async (value) => {
|
||||||
this.data[settingsKey] = value; // Update the settings dictionary await this.plugin.saveSettings();
|
this[dataRecord][settingsKey] = value; // Update the settings dictionary await this.plugin.saveSettings();
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
} else if (type === 'toggle') {
|
} else if (type === 'toggle') {
|
||||||
@@ -307,7 +306,7 @@ export class SettingModal extends Modal {
|
|||||||
toggle
|
toggle
|
||||||
.setValue(holderValue)
|
.setValue(holderValue)
|
||||||
.onChange(async (value) => {
|
.onChange(async (value) => {
|
||||||
this.data[settingsKey] = value; // Update the settings dictionary await this.plugin.saveSettings();
|
this[dataRecord][settingsKey] = value; // Update the settings dictionary await this.plugin.saveSettings();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else if (type === 'text') {
|
} else if (type === 'text') {
|
||||||
@@ -319,7 +318,7 @@ export class SettingModal extends Modal {
|
|||||||
.setPlaceholder(placeholder)
|
.setPlaceholder(placeholder)
|
||||||
.setValue(holderValue)
|
.setValue(holderValue)
|
||||||
.onChange(async (value) => {
|
.onChange(async (value) => {
|
||||||
this.data[settingsKey] = value; // Update the settings dictionary await this.plugin.saveSettings();
|
this[dataRecord][settingsKey] = value; // Update the settings dictionary await this.plugin.saveSettings();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
import {App, PluginSettingTab, Setting} from "obsidian";
|
|
||||||
import ObsidianSyncNotionPlugin from "../main";
|
|
||||||
import {i18nConfig} from "../lang/I18n";
|
|
||||||
import {ObsidianSettingTab} from "./settingTabs";
|
|
||||||
import {SettingModal} from "./settingModal";
|
|
||||||
|
|
||||||
export class SettingNextTabs extends PluginSettingTab {
|
|
||||||
plugin: ObsidianSyncNotionPlugin;
|
|
||||||
settingModal: SettingModal;
|
|
||||||
|
|
||||||
constructor(app: App, plugin: ObsidianSyncNotionPlugin, settingTab: ObsidianSettingTab) {
|
|
||||||
super(app, plugin);
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
display(): void {
|
|
||||||
|
|
||||||
// notion next database settings
|
|
||||||
this.containerEl.createEl('h2', { text: i18nConfig.NotionNextSettingHeader });
|
|
||||||
|
|
||||||
const NextButtonEl = this.containerEl.createDiv();
|
|
||||||
|
|
||||||
new Setting(NextButtonEl)
|
|
||||||
.setName(i18nConfig.NotionNextButton)
|
|
||||||
.setDesc(i18nConfig.NotionNextButtonDesc)
|
|
||||||
.addToggle((toggle) =>
|
|
||||||
toggle
|
|
||||||
.setValue(this.plugin.settings.NextButton)
|
|
||||||
.onChange(async (value) => {
|
|
||||||
this.plugin.settings.NextButton = value;
|
|
||||||
|
|
||||||
this.settingModal.updateSettingEl(notionAPINextEl, value)
|
|
||||||
|
|
||||||
this.settingModal.updateSettingEl(databaseIDNextEl, value)
|
|
||||||
|
|
||||||
await this.plugin.saveSettings();
|
|
||||||
await this.plugin.commands.updateCommand();
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
const notionAPINextEl = this.settingModal.createStyleDiv('api-next', this.plugin.settings.NextButton,NextButtonEl)
|
|
||||||
this.settingModal.createSettingEl(notionAPINextEl, i18nConfig.NotionAPI, i18nConfig.NotionAPIDesc, 'password', i18nConfig.NotionAPIText, this.plugin.settings.notionAPINext,'notionAPINext')
|
|
||||||
|
|
||||||
const databaseIDNextEl = this.settingModal.createStyleDiv('databaseID-next', this.plugin.settings.NextButton,NextButtonEl)
|
|
||||||
this.settingModal.createSettingEl(databaseIDNextEl, i18nConfig.DatabaseID, i18nConfig.NotionAPIDesc, 'password', i18nConfig.DatabaseIDText, this.plugin.settings.databaseIDNext,'databaseIDNext')
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import {App, ButtonComponent, PluginSettingTab, Setting} from "obsidian";
|
import {App, ButtonComponent, Modal, 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 {SettingNextTabs} from "./settingNextTabs";
|
|
||||||
import {SettingGeneralTabs} from "./settingGeneralTabs";
|
|
||||||
import {set} from "yaml/dist/schema/yaml-1.1/set";
|
import {set} from "yaml/dist/schema/yaml-1.1/set";
|
||||||
import {PreviewModal} from "./PreviewModal";
|
import {PreviewModal} from "./PreviewModal";
|
||||||
|
import {EditModal} from "./EditModal";
|
||||||
|
import {DeleteModal} from "./DeleteModal";
|
||||||
|
|
||||||
export interface PluginSettings {
|
export interface PluginSettings {
|
||||||
NextButton: boolean;
|
NextButton: boolean;
|
||||||
@@ -251,30 +251,45 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// add a button for edit data
|
||||||
settingEl
|
settingEl
|
||||||
.addButton((button: ButtonComponent): ButtonComponent => {
|
.addButton((button: ButtonComponent): ButtonComponent => {
|
||||||
return button
|
return button
|
||||||
.setTooltip("Edit Database")
|
.setTooltip("Edit Database")
|
||||||
.setIcon("pencil")
|
.setIcon("pencil")
|
||||||
.onClick(async () => {
|
.onClick(async () => {
|
||||||
let modal = new SettingModal(this.app, this.plugin, this, dbDetails);
|
let modal = new EditModal(this.app, this.plugin, this, dbDetails);
|
||||||
|
|
||||||
modal.onClose = () => {
|
modal.onClose = () => {
|
||||||
if (modal.data.saved) {
|
if (modal.dataTemp.savedTempInd) {
|
||||||
const dbDetails = {
|
const dbDetailsNew: DatabaseDetails = {
|
||||||
format: modal.data.databaseFormat,
|
format: modal.dataTemp.databaseFormatTemp,
|
||||||
fullName: modal.data.databaseFullName,
|
fullName: modal.dataTemp.databaseFullNameTemp,
|
||||||
abName: modal.data.databaseAbbreviateName,
|
abName: modal.dataTemp.databaseAbbreviateNameTemp,
|
||||||
notionAPI: modal.data.notionAPI,
|
notionAPI: modal.dataTemp.notionAPITemp,
|
||||||
databaseID: modal.data.databaseID,
|
databaseID: modal.dataTemp.databaseIDTemp,
|
||||||
tagButton: modal.data.tagButton,
|
tagButton: modal.dataTemp.tagButtonTemp,
|
||||||
customTitleButton: modal.data.customTitleButton,
|
customTitleButton: modal.dataTemp.customTitleButtonTemp,
|
||||||
customTitleName: modal.data.customTitleName,
|
customTitleName: modal.dataTemp.customTitleNameTemp,
|
||||||
// customValues: modal.data.customValues,
|
// customValues: modal.data.customValues,
|
||||||
saved: modal.data.saved,
|
saved: modal.dataTemp.savedTemp,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.plugin.updateDatabaseDetails(dbDetails);
|
const dbDetailsPrev: DatabaseDetails = {
|
||||||
|
format: modal.dataPrev.databaseFormatPrev,
|
||||||
|
fullName: modal.dataPrev.databaseFullNamePrev,
|
||||||
|
abName: modal.dataPrev.databaseAbbreviateNamePrev,
|
||||||
|
notionAPI: modal.dataPrev.notionAPIPrev,
|
||||||
|
databaseID: modal.dataPrev.databaseIDPrev,
|
||||||
|
tagButton: modal.dataPrev.tagButtonPrev,
|
||||||
|
customTitleButton: modal.dataPrev.customTitleButtonPrev,
|
||||||
|
customTitleName: modal.dataPrev.customTitleNamePrev,
|
||||||
|
// customValues: modal.data.customValues,
|
||||||
|
saved: modal.dataPrev.savedPrev,
|
||||||
|
}
|
||||||
|
|
||||||
|
this.plugin.deleteDatabaseDetails(dbDetailsPrev);
|
||||||
|
this.plugin.updateDatabaseDetails(dbDetailsNew);
|
||||||
|
|
||||||
this.plugin.commands.updateCommand();
|
this.plugin.commands.updateCommand();
|
||||||
|
|
||||||
@@ -292,11 +307,20 @@ export class ObsidianSettingTab extends PluginSettingTab {
|
|||||||
.setTooltip("Delete Database")
|
.setTooltip("Delete Database")
|
||||||
.setIcon("trash")
|
.setIcon("trash")
|
||||||
.onClick(async () => {
|
.onClick(async () => {
|
||||||
await this.plugin.deleteDatabaseDetails(dbDetails);
|
let modal = new DeleteModal(this.app, this.plugin, this, dbDetails);
|
||||||
|
|
||||||
await this.plugin.commands.updateCommand();
|
modal.onClose = () => {
|
||||||
|
if (modal.data.deleted) {
|
||||||
|
this.plugin.deleteDatabaseDetails(dbDetails);
|
||||||
|
|
||||||
|
this.plugin.commands.updateCommand();
|
||||||
|
|
||||||
|
this.display()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
modal.open();
|
||||||
|
|
||||||
this.display()
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user