Compare commits

..

4 Commits
2.0.0 ... 2.0.1

Author SHA1 Message Date
Jiaxin Peng
f670dd972a Update version to 2.0.1 2024-01-03 00:37:47 +00:00
Jiaxin Peng
e6de2d036a add preview and edit function 2024-01-03 00:37:34 +00:00
Jiaxin Peng
dd131f5df1 readme update 2023-12-29 00:41:02 +00:00
Jiaxin Peng
a9fb81fc1b readme error 2023-12-29 00:39:18 +00:00
7 changed files with 238 additions and 75 deletions

View File

@@ -3,7 +3,7 @@
[![Test](https://github.com/jxpeng98/obsidian-to-NotionNext/actions/workflows/test.yml/badge.svg)](https://github.com/jxpeng98/obsidian-to-NotionNext/actions/workflows/test.yml) [![Test](https://github.com/jxpeng98/obsidian-to-NotionNext/actions/workflows/test.yml/badge.svg)](https://github.com/jxpeng98/obsidian-to-NotionNext/actions/workflows/test.yml)
[![Release](https://github.com/jxpeng98/obsidian-to-NotionNext/actions/workflows/release.yml/badge.svg)](https://github.com/jxpeng98/obsidian-to-NotionNext/actions/workflows/release.yml) [![Release](https://github.com/jxpeng98/obsidian-to-NotionNext/actions/workflows/release.yml/badge.svg)](https://github.com/jxpeng98/obsidian-to-NotionNext/actions/workflows/release.yml)
[![Github all releases](https://img.shields.io/github/downloads/jxpeng98/obsidian-to-NotionNext/total.svg)](https://GitHub.com/jxpeng98/obsidian-to-NotionNext/releases/) [![Github all releases](https://img.shields.io/github/downloads/jxpeng98/obsidian-to-NotionNext/total.svg)](https://GitHub.com/jxpeng98/obsidian-to-NotionNext/releases/)
[![GitLab latest release](https://badgen.net/github/release/jxpeng98/obsidian-to-NotionNext)](https://github.com/jxpeng98/obsidian-to-NotionNext/releases) [![GitHub release (with filter)](https://img.shields.io/github/v/release/jxpeng98/obsidian-to-NotionNext)](https://github.com/jxpeng98/obsidian-to-NotionNext/releases/)
[中文文档](README-zh.md) [中文文档](README-zh.md)
@@ -18,10 +18,21 @@ Thus, based on the [original author's work](https://github.com/EasyChris/obsidia
## TODO List ## TODO List
- [ ] Support custom properties for Notion General database. 支持自定义属性 - [ ] Support custom properties for Notion General database. 支持自定义属性
- [ ] Support preview for database details in plugin settings. 支持预览数据库详情 - [x] Support preview for database details in plugin settings. 支持预览数据库详情
- [ ] Support edit for database details in plugin settings. 支持编辑数据库详情 - [x] Support edit for database details in plugin settings. 支持编辑数据库详情
## Update ## Update
### 2.0.1
- Add the preview and edit function for database details in the plugin settings. 增加插件设置中数据库详情的预览和编辑功能。
![](https://minioapi.pjx.ac.cn/img1/2024/01/952f1e579daeac35b257ff7d744b0a3d.png)
- Preview:
![](https://minioapi.pjx.ac.cn/img1/2024/01/952f1e579daeac35b257ff7d744b0a3d.png)
- Edit:
![](https://minioapi.pjx.ac.cn/img1/2024/01/ded3d62660f5488c76488304a3fb269e.png)
### 2.0.0 (Big Update) ### 2.0.0 (Big Update)
- redesign the plugin settings UI. From this version, the settings UI will be separated into two parts: - redesign the plugin settings UI. From this version, the settings UI will be separated into two parts:
@@ -30,11 +41,12 @@ Thus, based on the [original author's work](https://github.com/EasyChris/obsidia
- 重新设计了插件设置界面。从这个版本开始,设置界面将被分成两部分: - 重新设计了插件设置界面。从这个版本开始,设置界面将被分成两部分:
- 一部分是通用设置bannerUrl和你的notion用户名ID - 一部分是通用设置bannerUrl和你的notion用户名ID
- 一部分是数据库列表:你可以添加新的数据库或者删除数据库。 - 一部分是数据库列表:你可以添加新的数据库或者删除数据库。
![](https://minioapi.pjx.ac.cn/img1/2023/12/f7e89241f45cfee6b902ec4b69dd6f63.png) ![](https://minioapi.pjx.ac.cn/img1/2023/12/f7e89241f45cfee6b902ec4b69dd6f63.png)
- You can add more databases in the plugin settings. - You can add more databases in the plugin settings.
- 你可以在插件设置中添加更多的数据库。 - 你可以在插件设置中添加更多的数据库。
![](https://minioapi.pjx.ac.cn/img1/2023/12/023bf46ebbc92c3991d2c443c575bc80.gif) ![](https://minioapi.pjx.ac.cn/img1/2023/12/023bf46ebbc92c3991d2c443c575bc80.gif)
- You can sync one note to multiple databases. - You can sync one note to multiple databases.

View File

@@ -1,7 +1,7 @@
{ {
"id": "share-to-notionnext", "id": "share-to-notionnext",
"name": "Share to NotionNext", "name": "Share to NotionNext",
"version": "2.0.0", "version": "2.0.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",

View File

@@ -1,6 +1,6 @@
{ {
"name": "share-to-notionnext", "name": "share-to-notionnext",
"version": "2.0.0", "version": "2.0.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",

View File

@@ -81,10 +81,7 @@ export default class ObsidianSyncNotionPlugin extends Plugin {
await this.saveSettings(); await this.saveSettings();
} }
// previewDatabase(dbDetails: DatabaseDetails) {
//
// }
} }

125
src/ui/PreviewModal.ts Normal file
View File

@@ -0,0 +1,125 @@
import {App, ExtraButtonComponent, Modal, Notice, Setting} from "obsidian";
import ObsidianSyncNotionPlugin from "../main";
import {DatabaseDetails, ObsidianSettingTab} from "./settingTabs";
export class PreviewModal extends Modal {
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(): void {
this.containerEl.addClass('preview-modal')
this.titleEl.setText('Preview')
let { contentEl } = this;
const previewEl = contentEl.createDiv('preview-content')
const dbFormatEl = new Setting(previewEl)
dbFormatEl
.setName('Database Format')
.addText(text => text
.setValue(this.dbDetails.format)
.setDisabled(true));
const dbFullEl = new Setting(previewEl)
dbFullEl
.setName('Database Full Name')
.addText(text => text
.setValue(this.dbDetails.fullName)
.setDisabled(true));
const dbAbbrEl = new Setting(previewEl)
dbAbbrEl
.setName('Database Abbreviate Name')
.addText(text => text
.setValue(this.dbDetails.abName)
.setDisabled(true));
// .controlEl.createEl('p', { text: this.dbDetails.abName })
// Setting for toggle and copy buttons
new Setting(previewEl)
.setName('Notion API Key')
.addExtraButton((button: ExtraButtonComponent) => {
let isApiKeyVisible = false;
return button
.setTooltip('Toggle API Key Visibility')
.setIcon('eye')
.onClick(() => {
isApiKeyVisible = !isApiKeyVisible;
button.setIcon(isApiKeyVisible ? 'eye-off' : 'eye');
apiKeySetting.settingEl.style.display = isApiKeyVisible ? '' : 'none'; // Toggle visibility
});
})
// Setting for displaying the API key
const apiKeySetting = new Setting(previewEl)
apiKeySetting.infoEl.createEl('p', { text: this.dbDetails.notionAPI })
apiKeySetting
.addExtraButton((button: ExtraButtonComponent) => {
return button
.setTooltip('Copy API Key')
.setIcon('clipboard')
.onClick(() => {
navigator.clipboard.writeText(this.dbDetails.notionAPI)
new Notice('API Key copied to clipboard');
});
});
apiKeySetting.settingEl.style.display = 'none'; // Hide initially
new Setting(previewEl)
.setName('Database ID')
.addExtraButton((button: ExtraButtonComponent) => {
let isDbIdVisible = false;
return button
.setTooltip('Toggle Database ID Visibility')
.setIcon('eye')
.onClick(() => {
isDbIdVisible = !isDbIdVisible;
button.setIcon(isDbIdVisible ? 'eye-off' : 'eye');
dbIdSetting.settingEl.style.display = isDbIdVisible ? '' : 'none'; // Toggle visibility
});
})
const dbIdSetting = new Setting(previewEl)
dbIdSetting.infoEl.createEl('p', { text: this.dbDetails.databaseID })
dbIdSetting
.addExtraButton((button: ExtraButtonComponent) => {
return button
.setTooltip('Copy Database ID')
.setIcon('clipboard')
.onClick(() => {
navigator.clipboard.writeText(this.dbDetails.databaseID)
new Notice('Database ID copied to clipboard');
});
});
dbIdSetting.settingEl.style.display = 'none'; // Hide initially
}
onOpen() {
this.display()
}
}

View File

@@ -42,6 +42,7 @@ export class SettingModal extends Modal {
this.data.customTitleButton = dbDetails.customTitleButton; this.data.customTitleButton = dbDetails.customTitleButton;
this.data.customTitleName = dbDetails.customTitleName; this.data.customTitleName = dbDetails.customTitleName;
// this.data.customValues = dbDetails.customValues; // this.data.customValues = dbDetails.customValues;
this.data.saved = dbDetails.saved;
} }
} }
@@ -58,28 +59,53 @@ export class SettingModal extends Modal {
const nextTabs = contentEl.createDiv('next-tabs'); const nextTabs = contentEl.createDiv('next-tabs');
new Setting(settingDiv)
.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.data.databaseFormat)
.onChange(async (value) => {
this.data.databaseFormat = value;
nextTabs.empty();
this.updateContentBasedOnSelection(value, nextTabs);
});
// Initialize content based on the current dropdown value if (this.data.saved) {
this.updateContentBasedOnSelection(this.plugin.settings.databaseFormat, nextTabs); new Setting(settingDiv)
}); .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.data.databaseFormat)
.onChange(async (value) => {
this.data.databaseFormat = value;
nextTabs.empty();
this.updateContentBasedOnSelection(value, nextTabs);
});
// Initialize content based on the current dropdown value
this.updateContentBasedOnSelection(this.data.databaseFormat, nextTabs);
});
} else {
new Setting(settingDiv)
.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.data.databaseFormat)
.onChange(async (value) => {
this.data.databaseFormat = value;
nextTabs.empty();
this.updateContentBasedOnSelection(value, nextTabs);
});
// Initialize content based on the current dropdown value
this.updateContentBasedOnSelection(this.plugin.settings.databaseFormat, nextTabs);
});
}
// add save button // add save button
let footerEl = contentEl.createDiv('save-button'); let footerEl = contentEl.createDiv('save-button');
let saveButton = new Setting(footerEl) let saveButton = new Setting(footerEl)
saveButton.addButton((button: ButtonComponent) => { saveButton.addButton((button: ButtonComponent) => {

View File

@@ -5,6 +5,7 @@ import {SettingModal} from "./settingModal";
import {SettingNextTabs} from "./settingNextTabs"; import {SettingNextTabs} from "./settingNextTabs";
import {SettingGeneralTabs} from "./settingGeneralTabs"; 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";
export interface PluginSettings { export interface PluginSettings {
NextButton: boolean; NextButton: boolean;
@@ -37,6 +38,7 @@ export interface DatabaseDetails {
customTitleButton: boolean; customTitleButton: boolean;
customTitleName: string; customTitleName: string;
// customValues: string; // customValues: string;
saved: boolean;
} }
export const DEFAULT_SETTINGS: PluginSettings = { export const DEFAULT_SETTINGS: PluginSettings = {
@@ -82,7 +84,6 @@ export class ObsidianSettingTab extends PluginSettingTab {
this.createSettingEl(containerEl, i18nConfig.NotionUser, i18nConfig.NotionUserDesc, 'text', i18nConfig.NotionUserText, this.plugin.settings.notionUser, 'notionUser') this.createSettingEl(containerEl, i18nConfig.NotionUser, i18nConfig.NotionUserDesc, 'text', i18nConfig.NotionUserText, this.plugin.settings.notionUser, 'notionUser')
// add new button // add new button
new Setting(containerEl) new Setting(containerEl)
@@ -107,6 +108,7 @@ export class ObsidianSettingTab extends PluginSettingTab {
customTitleButton: modal.data.customTitleButton, customTitleButton: modal.data.customTitleButton,
customTitleName: modal.data.customTitleName, customTitleName: modal.data.customTitleName,
// customValues: modal.data.customValues, // customValues: modal.data.customValues,
saved: modal.data.saved,
} }
this.plugin.addDatabaseDetails(dbDetails); this.plugin.addDatabaseDetails(dbDetails);
@@ -237,49 +239,52 @@ export class ObsidianSettingTab extends PluginSettingTab {
// add a button for preview data // add a button for preview data
// settingEl settingEl
// .addButton((button: ButtonComponent): ButtonComponent => { .addButton((button: ButtonComponent): ButtonComponent => {
// return button return button
// .setTooltip("Preview Database") .setTooltip("Preview Database")
// .setIcon("eye") .setIcon("eye")
// .onClick(async () => { .onClick(async () => {
// this.plugin.previewDatabase(dbDetails); let modal = new PreviewModal(this.app, this.plugin, this, dbDetails);
// });
// });
// settingEl modal.open();
// .addButton((button: ButtonComponent): ButtonComponent => { });
// return button });
// .setTooltip("Edit Database")
// .setIcon("pencil") settingEl
// .onClick(async () => { .addButton((button: ButtonComponent): ButtonComponent => {
// let modal = new SettingModal(this.app, this.plugin, this, dbDetails); return button
// .setTooltip("Edit Database")
// modal.onClose = () => { .setIcon("pencil")
// if (modal.data.saved) { .onClick(async () => {
// const dbDetails = { let modal = new SettingModal(this.app, this.plugin, this, dbDetails);
// format: modal.data.databaseFormat,
// fullName: modal.data.databaseFullName, modal.onClose = () => {
// abName: modal.data.databaseAbbreviateName, if (modal.data.saved) {
// notionAPI: modal.data.notionAPI, const dbDetails = {
// databaseID: modal.data.databaseID, format: modal.data.databaseFormat,
// tagButton: modal.data.tagButton, fullName: modal.data.databaseFullName,
// customTitleButton: modal.data.customTitleButton, abName: modal.data.databaseAbbreviateName,
// customTitleName: modal.data.customTitleName, notionAPI: modal.data.notionAPI,
// // customValues: modal.data.customValues, databaseID: modal.data.databaseID,
// } tagButton: modal.data.tagButton,
// customTitleButton: modal.data.customTitleButton,
// this.plugin.updateDatabaseDetails(dbDetails); customTitleName: modal.data.customTitleName,
// // customValues: modal.data.customValues,
// this.plugin.commands.updateCommand(); saved: modal.data.saved,
// }
// this.display()
// } this.plugin.updateDatabaseDetails(dbDetails);
// }
// this.plugin.commands.updateCommand();
// modal.open();
// }); this.display()
// }); }
}
modal.open();
});
});
settingEl settingEl
.addButton((button: ButtonComponent): ButtonComponent => { .addButton((button: ButtonComponent): ButtonComponent => {
@@ -297,7 +302,5 @@ export class ObsidianSettingTab extends PluginSettingTab {
} }
} }
} }
function addExtraButton(arg0: (button: ButtonComponent) => ButtonComponent): any {
throw new Error("Function not implemented.");
}