Skip to content

Commit 6d16882

Browse files
committed
optimize: reload editors after configurating plugin
1 parent 16b07d0 commit 6d16882

File tree

8 files changed

+21
-4
lines changed

8 files changed

+21
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ The label of a draw.io image block can be configured in the plugin settings.
7474

7575
## Changelog
7676

77+
+ v0.3.3
78+
+ Optimize: reload editors after configrating plugin
7779
+ v0.3.2
7880
+ change SiYuan version requirement: >= 3.0.0
7981
+ v0.3.1

README_zh_CN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565

6666
## 更新日志
6767

68+
+ v0.3.3
69+
+ 优化:修改配置后重载编辑器
6870
+ v0.3.2
6971
+ 修改思源版本要求:>= 3.0.0
7072
+ v0.3.1

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "siyuan-embed-drawio",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"type": "module",
55
"description": "This is a plugin for siyuan",
66
"author": "",

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "siyuan-embed-drawio",
33
"author": "Yuxin Zhao",
44
"url": "https://github.com/YuxinZhaozyx/siyuan-embed-drawio",
5-
"version": "0.3.2",
5+
"version": "0.3.3",
66
"minAppVersion": "3.0.0",
77
"disabledInPublish": true,
88
"backends": [

preview.png

-66.6 KB
Loading

src/i18n/en_US.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"editDrawio": "Edit draw.io",
33
"drawioLightbox": "draw.io Lightbox",
44
"labelDisplay": "Label Display",
5-
"labelDisplayDescription": "Label display in image block top right corner (Changes require refresh of document)",
5+
"labelDisplayDescription": "Label display in image block top right corner",
66
"noLabel": "No Label",
77
"showLabelAlways": "Show Label Always",
88
"showLabelOnHover": "Show Label On Hover"

src/i18n/zh_CN.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"editDrawio": "编辑 draw.io",
33
"drawioLightbox": "draw.io 灯箱",
44
"labelDisplay": "标签显示",
5-
"labelDisplayDescription": "图像块右上角的标签显示(修改后需刷新文档生效)",
5+
"labelDisplayDescription": "图像块右上角的标签显示",
66
"noLabel": "不显示标签",
77
"showLabelAlways": "始终显示标签",
88
"showLabelOnHover": "悬停时显示标签"

src/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
getFrontend,
55
fetchPost,
66
IWebSocketData,
7+
getAllEditor,
78
} from "siyuan";
89
import "@/index.scss";
910
import PluginInfoString from '@/../plugin.json';
@@ -76,12 +77,19 @@ export default class DrawioPlugin extends Plugin {
7677

7778
this._globalKeyDownHandler = this.globalKeyDownHandler.bind(this);
7879
document.documentElement.addEventListener("keydown", this._globalKeyDownHandler);
80+
81+
this.reloadAllEditor();
7982
}
8083

8184
onunload() {
8285
if (this._mutationObserver) this._mutationObserver.disconnect();
8386
if (this._openMenuImageHandler) this.eventBus.off("open-menu-image", this._openMenuImageHandler);
8487
if (this._globalKeyDownHandler) document.documentElement.removeEventListener("keydown", this._globalKeyDownHandler);
88+
this.reloadAllEditor();
89+
}
90+
91+
uninstall() {
92+
this.removeData(STORAGE_NAME);
8593
}
8694

8795
openSetting() {
@@ -155,6 +163,7 @@ export default class DrawioPlugin extends Plugin {
155163
(dialog.element.querySelector(".b3-dialog__action [data-type='confirm']") as HTMLElement).addEventListener("click", () => {
156164
this.data[STORAGE_NAME].labelDisplay = (dialog.element.querySelector("[data-type='labelDisplay']") as HTMLSelectElement).value;
157165
this.saveData(STORAGE_NAME, this.data[STORAGE_NAME]);
166+
this.reloadAllEditor();
158167
dialog.destroy();
159168
});
160169
}
@@ -588,4 +597,8 @@ export default class DrawioPlugin extends Plugin {
588597
window.removeEventListener("message", messageEventHandler);
589598
});
590599
}
600+
601+
public reloadAllEditor() {
602+
getAllEditor().forEach((protyle) => { protyle.reload(false); });
603+
}
591604
}

0 commit comments

Comments
 (0)