add hint type to settingUtil
This commit is contained in:
parent
74d62ac1aa
commit
f84497f6da
6 changed files with 36 additions and 4 deletions
|
@ -7,7 +7,7 @@ import readline from 'node:readline';
|
||||||
|
|
||||||
//Please write the "workspace/data/plugins" directory here
|
//Please write the "workspace/data/plugins" directory here
|
||||||
//请在这里填写你的 "workspace/data/plugins" 目录
|
//请在这里填写你的 "workspace/data/plugins" 目录
|
||||||
let targetDir = '';
|
let targetDir = '/home/zxkmm/文档/siyuan_dev/data/plugins';
|
||||||
//Like this
|
//Like this
|
||||||
// let targetDir = `H:\\SiYuanDevSpace\\data\\plugins`;
|
// let targetDir = `H:\\SiYuanDevSpace\\data\\plugins`;
|
||||||
//********************************************************************************************
|
//********************************************************************************************
|
||||||
|
|
|
@ -14,5 +14,7 @@
|
||||||
"name": "SiYuan",
|
"name": "SiYuan",
|
||||||
"hello": {
|
"hello": {
|
||||||
"makesure": "Before using this template, please read the <a href=\"https://github.com/siyuan-note/plugin-sample\">offical sample</a>, make sure that you've known about the pipeline for plugin developing."
|
"makesure": "Before using this template, please read the <a href=\"https://github.com/siyuan-note/plugin-sample\">offical sample</a>, make sure that you've known about the pipeline for plugin developing."
|
||||||
}
|
},
|
||||||
|
"hintTitle":"About",
|
||||||
|
"hintDesc":"<a href='https://github.com/siyuan-note/plugin-sample-vite-svelte'>plugin-sample-vite-svelte</a><br>@frostime<br>@88250<br>@zxkmm"
|
||||||
}
|
}
|
|
@ -14,5 +14,8 @@
|
||||||
"name": "思源",
|
"name": "思源",
|
||||||
"hello": {
|
"hello": {
|
||||||
"makesure": "使用这个模板之前,请阅读<a href=\"https://github.com/siyuan-note/plugin-sample\">官方教程</a>, 确保自己已经理解了插件的基本开发流程。"
|
"makesure": "使用这个模板之前,请阅读<a href=\"https://github.com/siyuan-note/plugin-sample\">官方教程</a>, 确保自己已经理解了插件的基本开发流程。"
|
||||||
}
|
},
|
||||||
|
"hintTitle":"关于",
|
||||||
|
"hintDesc":"<a href='https://github.com/siyuan-note/plugin-sample-vite-svelte'>🔗 plugin-sample-vite-svelte</a><br>💻 @frostime<br>💻 @88250<br>💻 @zxkmm"
|
||||||
|
|
||||||
}
|
}
|
22
src/index.ts
22
src/index.ts
|
@ -160,6 +160,13 @@ export default class PluginSample extends Plugin {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.settingUtils = new SettingUtils(this, STORAGE_NAME);
|
this.settingUtils = new SettingUtils(this, STORAGE_NAME);
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.settingUtils.load();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error loading settings storage, probably empty config json:", error);
|
||||||
|
}
|
||||||
|
|
||||||
this.settingUtils.addItem({
|
this.settingUtils.addItem({
|
||||||
key: "Input",
|
key: "Input",
|
||||||
value: "",
|
value: "",
|
||||||
|
@ -217,6 +224,13 @@ export default class PluginSample extends Plugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.settingUtils.addItem({
|
||||||
|
key: "Hint",
|
||||||
|
value: "",
|
||||||
|
type: "hint",
|
||||||
|
title: this.i18n.hintTitle,
|
||||||
|
description: this.i18n.hintDesc,
|
||||||
|
});
|
||||||
|
|
||||||
this.protyleSlash = [{
|
this.protyleSlash = [{
|
||||||
filter: ["insert emoji 😊", "插入表情 😊", "crbqwx"],
|
filter: ["insert emoji 😊", "插入表情 😊", "crbqwx"],
|
||||||
|
@ -234,6 +248,14 @@ export default class PluginSample extends Plugin {
|
||||||
// this.loadData(STORAGE_NAME);
|
// this.loadData(STORAGE_NAME);
|
||||||
this.settingUtils.load();
|
this.settingUtils.load();
|
||||||
console.log(`frontend: ${getFrontend()}; backend: ${getBackend()}`);
|
console.log(`frontend: ${getFrontend()}; backend: ${getBackend()}`);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
"Official settings value calling example:\n" +
|
||||||
|
this.settingUtils.get("InputArea") + "\n" +
|
||||||
|
this.settingUtils.get("Slider") + "\n" +
|
||||||
|
this.settingUtils.get("Select") + "\n"
|
||||||
|
);
|
||||||
|
|
||||||
let tabDiv = document.createElement("div");
|
let tabDiv = document.createElement("div");
|
||||||
new HelloExample({
|
new HelloExample({
|
||||||
target: tabDiv,
|
target: tabDiv,
|
||||||
|
|
2
src/libs/index.d.ts
vendored
2
src/libs/index.d.ts
vendored
|
@ -1,4 +1,4 @@
|
||||||
type TSettingItemType = "checkbox" | "select" | "textinput" | "textarea" | "number" | "slider" | "button";
|
type TSettingItemType = "checkbox" | "select" | "textinput" | "textarea" | "number" | "slider" | "button" | "hint";
|
||||||
interface ISettingItem {
|
interface ISettingItem {
|
||||||
key: string;
|
key: string;
|
||||||
value: any;
|
value: any;
|
||||||
|
|
|
@ -144,6 +144,11 @@ export class SettingUtils {
|
||||||
buttonElement.onclick = item.button?.callback ?? (() => {});
|
buttonElement.onclick = item.button?.callback ?? (() => {});
|
||||||
itemElement = buttonElement;
|
itemElement = buttonElement;
|
||||||
break;
|
break;
|
||||||
|
case 'hint':
|
||||||
|
let hintElement: HTMLElement = document.createElement('div');
|
||||||
|
hintElement.className = 'b3-label fn__flex-center';
|
||||||
|
itemElement = hintElement;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
this.elements.set(item.key, itemElement);
|
this.elements.set(item.key, itemElement);
|
||||||
this.plugin.setting.addItem({
|
this.plugin.setting.addItem({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue