mirror of
https://github.com/aqeja/ClipperMaster-for-Obsidian.git
synced 2026-07-22 05:43:22 +00:00
guidance
This commit is contained in:
parent
2648051185
commit
626d7566ce
5 changed files with 33 additions and 38 deletions
10
common.ts
10
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()
|
||||
|
|
|
|||
52
main.ts
52
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "clippermaster-plugin-for-obsidian",
|
||||
"version": "0.1.8",
|
||||
"version": "0.1.9",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue