From 626d7566ceda81e68b700f55bcb5f6595a2f9cbc Mon Sep 17 00:00:00 2001 From: jiakun Date: Fri, 11 Apr 2025 16:36:43 +0800 Subject: [PATCH] guidance --- common.ts | 10 +++++++-- main.ts | 52 +++++++++++++++++++---------------------------- manifest.json | 5 ++--- package-lock.json | 2 +- package.json | 2 +- 5 files changed, 33 insertions(+), 38 deletions(-) diff --git a/common.ts b/common.ts index 4534884..ad1089e 100644 --- a/common.ts +++ b/common.ts @@ -25,7 +25,10 @@ const getTexts = () => { enterPort: '输入端口号', error: '必须是一个有效的端口号 (1 - 65535)', welcome: '欢迎使用 ClipperMaster for Obsidian', - fileSaved:'🎉 已保存到:' + fileSaved:'🎉 已保存到:', + guidanceButton: '使用说明', + guidanceDesc: '点击打开使用说明页面', + openGuidance: '打开说明' } } return { @@ -34,7 +37,10 @@ const getTexts = () => { enterPort: 'Enter Port Number', error: 'Must be a valid port number (1 - 65535)', welcome: 'Welcome to ClipperMaster for Obsidian', - fileSaved: '🎉 File saved to:' + fileSaved: '🎉 File saved to:', + guidanceButton: 'Guidance', + guidanceDesc: 'Click to open guidance page', + openGuidance: 'Open Guidance' } } export const texts = getTexts() diff --git a/main.ts b/main.ts index 2bd5957..62e576f 100644 --- a/main.ts +++ b/main.ts @@ -1,11 +1,5 @@ import { texts, upsertFile, Welcome } from "common"; -import { - App, - Plugin, - PluginSettingTab, - Setting, - addIcon, -} from "obsidian"; +import { App, Plugin, PluginSettingTab, Setting, addIcon } from "obsidian"; import { server } from "server"; interface ClipperMasterPluginSettings { @@ -16,7 +10,6 @@ const DEFAULT_SETTINGS: ClipperMasterPluginSettings = { port: 8282, }; - export default class ClipperMasterPlugin extends Plugin { settings: ClipperMasterPluginSettings; @@ -35,18 +28,11 @@ export default class ClipperMasterPlugin extends Plugin { // This adds a settings tab so the user can configure various aspects of the plugin this.addSettingTab(new ClipperMasterSettingTab(this.app, this)); - // If the plugin hooks up any global DOM events (on parts of the app that doesn't belong to this plugin) - // Using this function will automatically remove the event listener when this plugin is disabled. - this.registerDomEvent(document, "click", (evt: MouseEvent) => { - console.log("click", evt); - }); - this.onUserEnable = () => { - upsertFile(this.app, texts.welcome, Welcome) - } - server.start(this.app); } - + onUserEnable() { + upsertFile(this.app, texts.welcome, Welcome); + } onunload() { server.close(); } @@ -70,18 +56,16 @@ class ClipperMasterSettingTab extends PluginSettingTab { constructor(app: App, plugin: ClipperMasterPlugin) { super(app, plugin); this.plugin = plugin; - } display(): void { const { containerEl } = this; containerEl.empty(); - containerEl.createEl("h2", { - text: `${this.plugin.manifest.name} ${this.plugin.manifest.version}`, - }); + + // Port setting const portSetting = new Setting(containerEl) .setName(texts.listeningPort) - .setDesc(texts.desc) + .setDesc(texts.desc); const invalidPortElement = portSetting.infoEl.createDiv(); invalidPortElement.hide(); @@ -90,7 +74,7 @@ class ClipperMasterSettingTab extends PluginSettingTab { .setText(texts.error); portSetting.addText((text) => { - text.setPlaceholder(texts.enterPort) + text.setPlaceholder(texts.enterPort); text.setValue(String(this.plugin.settings.port)); text.onChange(async (value) => { const numValue = Number(value); @@ -103,15 +87,21 @@ class ClipperMasterSettingTab extends PluginSettingTab { await this.saveAndReload(); }); }); + + // Guidance button setting + new Setting(containerEl) + .setName(texts.guidanceButton) + .setDesc(texts.guidanceDesc) + .addButton((btn) => { + btn.setButtonText(texts.openGuidance) + .onClick(() => { + window.open("https://docs.clippermaster.com/docs/integrations/obsidian", "_blank"); + }); + }); } async saveAndReload() { await this.plugin.saveSettings(); - await server.close() - - // const serverIsRunning = !!this.plugin.serverController?.isRunning(); - // if (serverIsRunning) { - // await this.plugin.stopServer(); - // await this.plugin.startServer(); - // } + await server.close(); + server.start(this.plugin.app); } } diff --git a/manifest.json b/manifest.json index a103260..4bf6b99 100644 --- a/manifest.json +++ b/manifest.json @@ -1,11 +1,10 @@ { "id": "clippermaster", "name": "ClipperMaster", - "version": "0.1.8", + "version": "0.1.9", "minAppVersion": "0.15.0", - "description": "ClipperMaster is a plugin that allows you to clip content from the web and save it to your vault.", + "description": "Works with the ClipperMaster Chrome extension to clip structured content from the web and save it to your Obsidian vault as Markdown files.", "author": "ClipperMaster Team", "authorUrl": "https://clippermaster.com/", - "fundingUrl": "https://clippermaster.com/", "isDesktopOnly": true } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d870f04..66725c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "clippermaster-plugin-for-obsidian", - "version": "0.1.8", + "version": "0.1.9", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 8078f6b..fad0c31 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "clippermaster-plugin-for-obsidian", - "version": "0.1.8", + "version": "0.1.9", "description": "This is a ClipperMaster Plugin for Obsidian (https://clippermaster.com)", "main": "main.js", "scripts": {