Merge branch 'dev'
This commit is contained in:
commit
e2ed03218d
9 changed files with 112 additions and 45 deletions
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -1,7 +1,23 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.2.7 2023-10
|
||||||
|
|
||||||
|
## 0.2.6 2023-10-24
|
||||||
|
|
||||||
|
* [Deprecated `loaded-protyle` use `loaded-protyle-static` instead](https://github.com/siyuan-note/siyuan/issues/9468)
|
||||||
|
|
||||||
|
## 0.2.5 2023-10-10
|
||||||
|
|
||||||
|
* [Add plugin event bus `open-menu-doctree`](https://github.com/siyuan-note/siyuan/issues/9351)
|
||||||
|
|
||||||
|
## 0.2.4 2023-09-19
|
||||||
|
|
||||||
|
* Supports use in windows
|
||||||
|
* [Add plugin function `transaction`](https://github.com/siyuan-note/siyuan/issues/9172)
|
||||||
|
|
||||||
## 0.2.3 2023-09-05
|
## 0.2.3 2023-09-05
|
||||||
|
|
||||||
|
* [Add plugin function `transaction`](https://github.com/siyuan-note/siyuan/issues/9172)
|
||||||
* [Plugin API add openWindow and command.globalCallback](https://github.com/siyuan-note/siyuan/issues/9032)
|
* [Plugin API add openWindow and command.globalCallback](https://github.com/siyuan-note/siyuan/issues/9032)
|
||||||
|
|
||||||
## 0.2.2 2023-08-29
|
## 0.2.2 2023-08-29
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
[中文版](./README_zh_CN.md)
|
[中文版](./README_zh_CN.md)
|
||||||
|
|
||||||
> Consistent with [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.2.3](https://github.com/siyuan-note/plugin-sample/tree/v0.2.3)
|
> Consistent with [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.2.6](https://github.com/siyuan-note/plugin-sample/tree/v0.2.6)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
[English](./README.md)
|
[English](./README.md)
|
||||||
|
|
||||||
|
|
||||||
> 本例和 [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.2.3](https://github.com/siyuan-note/plugin-sample/tree/v0.2.3)
|
> 本例和 [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.2.6](https://github.com/siyuan-note/plugin-sample/tree/v0.2.6)
|
||||||
|
|
||||||
1. 使用 vite 打包
|
1. 使用 vite 打包
|
||||||
2. 使用符号链接、而不是把项目放到插件目录下的模式进行开发
|
2. 使用符号链接、而不是把项目放到插件目录下的模式进行开发
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "plugin-sample-vite-svelte",
|
"name": "plugin-sample-vite-svelte",
|
||||||
"version": "0.2.3",
|
"version": "0.2.6",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "",
|
"description": "This is a sample plugin based on vite and svelte for Siyuan (https://b3log.org/siyuan)",
|
||||||
"repository": "",
|
"repository": "",
|
||||||
"homepage": "",
|
"homepage": "",
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "GPL-3.0",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"make-link": "node --no-warnings ./scripts/make_dev_link.js",
|
"make-link": "node --no-warnings ./scripts/make_dev_link.js",
|
||||||
"dev": "vite build --watch",
|
"dev": "vite build --watch",
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
"minimist": "^1.2.8",
|
"minimist": "^1.2.8",
|
||||||
"rollup-plugin-livereload": "^2.0.5",
|
"rollup-plugin-livereload": "^2.0.5",
|
||||||
"sass": "^1.62.1",
|
"sass": "^1.62.1",
|
||||||
"siyuan": "0.8.3",
|
"siyuan": "0.8.7",
|
||||||
"svelte": "^3.57.0",
|
"svelte": "^3.57.0",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"typescript": "^5.0.4",
|
"typescript": "^5.0.4",
|
||||||
|
|
15
plugin.json
15
plugin.json
|
@ -2,10 +2,17 @@
|
||||||
"name": "plugin-sample-vite-svelte",
|
"name": "plugin-sample-vite-svelte",
|
||||||
"author": "frostime",
|
"author": "frostime",
|
||||||
"url": "https://github.com/siyuan-note/plugin-sample-vite-svelte",
|
"url": "https://github.com/siyuan-note/plugin-sample-vite-svelte",
|
||||||
"version": "0.2.3",
|
"version": "0.2.6",
|
||||||
"minAppVersion": "2.10.3",
|
"minAppVersion": "2.10.12",
|
||||||
"backends": ["all"],
|
"backends": [
|
||||||
"frontends": ["all"],
|
"windows",
|
||||||
|
"linux",
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"frontends": [
|
||||||
|
"desktop",
|
||||||
|
"desktop-window"
|
||||||
|
],
|
||||||
"displayName": {
|
"displayName": {
|
||||||
"en_US": "Plugin sample with vite and svelte",
|
"en_US": "Plugin sample with vite and svelte",
|
||||||
"zh_CN": "插件样例 vite + svelte 版"
|
"zh_CN": "插件样例 vite + svelte 版"
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
export let app;
|
export let app;
|
||||||
|
|
||||||
let time: string = "";
|
let time: string = "";
|
||||||
let ver: string;
|
let ver: string = "";
|
||||||
|
|
||||||
let divProtyle: HTMLDivElement;
|
let divProtyle: HTMLDivElement;
|
||||||
let protyle: any;
|
let protyle: any;
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
"removedData": "Data deleted",
|
"removedData": "Data deleted",
|
||||||
"confirmRemove": "Confirm to delete the data in ${name}?",
|
"confirmRemove": "Confirm to delete the data in ${name}?",
|
||||||
"insertEmoji": "Insert Emoji",
|
"insertEmoji": "Insert Emoji",
|
||||||
|
"removeSpace": "Remove Space",
|
||||||
"getTab": "Print out all opened custom tabs in the debugger",
|
"getTab": "Print out all opened custom tabs in the debugger",
|
||||||
"name": "SiYuan",
|
"name": "SiYuan",
|
||||||
"hello": {
|
"hello": {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
"removedData": "数据已删除",
|
"removedData": "数据已删除",
|
||||||
"confirmRemove": "确认删除 ${name} 中的数据?",
|
"confirmRemove": "确认删除 ${name} 中的数据?",
|
||||||
"insertEmoji": "插入表情",
|
"insertEmoji": "插入表情",
|
||||||
|
"removeSpace": "移除空格",
|
||||||
"getTab": "在日志中打印出已打开的所有自定义页签",
|
"getTab": "在日志中打印出已打开的所有自定义页签",
|
||||||
"name": "思源",
|
"name": "思源",
|
||||||
"hello": {
|
"hello": {
|
||||||
|
|
110
src/index.ts
110
src/index.ts
|
@ -11,7 +11,7 @@ import {
|
||||||
IModel,
|
IModel,
|
||||||
Setting,
|
Setting,
|
||||||
fetchPost,
|
fetchPost,
|
||||||
Protyle, openWindow
|
Protyle, openWindow, IOperation
|
||||||
} from "siyuan";
|
} from "siyuan";
|
||||||
import "@/index.scss";
|
import "@/index.scss";
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ export default class PluginSample extends Plugin {
|
||||||
});
|
});
|
||||||
|
|
||||||
const statusIconTemp = document.createElement("template");
|
const statusIconTemp = document.createElement("template");
|
||||||
statusIconTemp.innerHTML = `<div class="toolbar__item b3-tooltips b3-tooltips__w" aria-label="Remove plugin-sample Data">
|
statusIconTemp.innerHTML = `<div class="toolbar__item ariaLabel" aria-label="Remove plugin-sample Data">
|
||||||
<svg>
|
<svg>
|
||||||
<use xlink:href="#iconTrashcan"></use>
|
<use xlink:href="#iconTrashcan"></use>
|
||||||
</svg>
|
</svg>
|
||||||
|
@ -85,27 +85,6 @@ export default class PluginSample extends Plugin {
|
||||||
element: statusIconTemp.content.firstElementChild as HTMLElement,
|
element: statusIconTemp.content.firstElementChild as HTMLElement,
|
||||||
});
|
});
|
||||||
|
|
||||||
let tabDiv = document.createElement("div");
|
|
||||||
new HelloExample({
|
|
||||||
target: tabDiv,
|
|
||||||
props: {
|
|
||||||
app: this.app,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.customTab = this.addTab({
|
|
||||||
type: TAB_TYPE,
|
|
||||||
init() {
|
|
||||||
this.element.appendChild(tabDiv);
|
|
||||||
console.log(this.element);
|
|
||||||
},
|
|
||||||
beforeDestroy() {
|
|
||||||
console.log("before destroy tab:", TAB_TYPE);
|
|
||||||
},
|
|
||||||
destroy() {
|
|
||||||
console.log("destroy tab:", TAB_TYPE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.addCommand({
|
this.addCommand({
|
||||||
langKey: "showDialog",
|
langKey: "showDialog",
|
||||||
hotkey: "⇧⌘O",
|
hotkey: "⇧⌘O",
|
||||||
|
@ -244,6 +223,26 @@ 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()}`);
|
||||||
|
let tabDiv = document.createElement("div");
|
||||||
|
new HelloExample({
|
||||||
|
target: tabDiv,
|
||||||
|
props: {
|
||||||
|
app: this.app,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.customTab = this.addTab({
|
||||||
|
type: TAB_TYPE,
|
||||||
|
init() {
|
||||||
|
this.element.appendChild(tabDiv);
|
||||||
|
console.log(this.element);
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
console.log("before destroy tab:", TAB_TYPE);
|
||||||
|
},
|
||||||
|
destroy() {
|
||||||
|
console.log("destroy tab:", TAB_TYPE);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async onunload() {
|
async onunload() {
|
||||||
|
@ -272,19 +271,38 @@ export default class PluginSample extends Plugin {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private eventBusPaste(event: any) {
|
||||||
|
// 如果需异步处理请调用 preventDefault, 否则会进行默认处理
|
||||||
|
event.preventDefault();
|
||||||
|
// 如果使用了 preventDefault,必须调用 resolve,否则程序会卡死
|
||||||
|
event.detail.resolve({
|
||||||
|
textPlain: event.detail.textPlain.trim(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private eventBusLog({ detail }: any) {
|
private eventBusLog({ detail }: any) {
|
||||||
console.log(detail);
|
console.log(detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
private blockIconEvent({ detail }: any) {
|
private blockIconEvent({ detail }: any) {
|
||||||
const ids: string[] = [];
|
|
||||||
detail.blockElements.forEach((item: HTMLElement) => {
|
|
||||||
ids.push(item.getAttribute("data-node-id"));
|
|
||||||
});
|
|
||||||
detail.menu.addItem({
|
detail.menu.addItem({
|
||||||
iconHTML: "",
|
iconHTML: "",
|
||||||
type: "readonly",
|
label: this.i18n.removeSpace,
|
||||||
label: "IDs<br>" + ids.join("<br>"),
|
click: () => {
|
||||||
|
const doOperations: IOperation[] = [];
|
||||||
|
detail.blockElements.forEach((item: HTMLElement) => {
|
||||||
|
const editElement = item.querySelector('[contenteditable="true"]');
|
||||||
|
if (editElement) {
|
||||||
|
editElement.textContent = editElement.textContent.replace(/ /g, "");
|
||||||
|
doOperations.push({
|
||||||
|
id: item.dataset.nodeId,
|
||||||
|
data: item.outerHTML,
|
||||||
|
action: "update"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
detail.protyle.getInstance().transaction(doOperations);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,9 +506,15 @@ export default class PluginSample extends Plugin {
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
icon: "iconSelect",
|
icon: "iconSelect",
|
||||||
label: "On loaded-protyle",
|
label: "On loaded-protyle-static",
|
||||||
click: () => {
|
click: () => {
|
||||||
this.eventBus.on("loaded-protyle", this.eventBusLog);
|
this.eventBus.on("loaded-protyle-static", this.eventBusLog);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
icon: "iconClose",
|
||||||
|
label: "Off loaded-protyle-static",
|
||||||
|
click: () => {
|
||||||
|
this.eventBus.off("loaded-protyle-static", this.eventBusLog);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
icon: "iconSelect",
|
icon: "iconSelect",
|
||||||
|
@ -517,10 +541,16 @@ export default class PluginSample extends Plugin {
|
||||||
this.eventBus.off("destroy-protyle", this.eventBusLog);
|
this.eventBus.off("destroy-protyle", this.eventBusLog);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
icon: "iconClose",
|
icon: "iconSelect",
|
||||||
label: "Off loaded-protyle",
|
label: "On open-menu-doctree",
|
||||||
click: () => {
|
click: () => {
|
||||||
this.eventBus.off("loaded-protyle", this.eventBusLog);
|
this.eventBus.on("open-menu-doctree", this.eventBusLog);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
icon: "iconClose",
|
||||||
|
label: "Off open-menu-doctree",
|
||||||
|
click: () => {
|
||||||
|
this.eventBus.off("open-menu-doctree", this.eventBusLog);
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
icon: "iconSelect",
|
icon: "iconSelect",
|
||||||
|
@ -630,6 +660,18 @@ export default class PluginSample extends Plugin {
|
||||||
click: () => {
|
click: () => {
|
||||||
this.eventBus.off("input-search", this.eventBusLog);
|
this.eventBus.off("input-search", this.eventBusLog);
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
icon: "iconSelect",
|
||||||
|
label: "On paste",
|
||||||
|
click: () => {
|
||||||
|
this.eventBus.on("paste", this.eventBusPaste);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
icon: "iconClose",
|
||||||
|
label: "Off paste",
|
||||||
|
click: () => {
|
||||||
|
this.eventBus.off("paste", this.eventBusPaste);
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
icon: "iconSelect",
|
icon: "iconSelect",
|
||||||
label: "On open-siyuan-url-plugin",
|
label: "On open-siyuan-url-plugin",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue