Skip to content

Commit

Permalink
perf: 调整打开 siyuan://plugins 链接事件的名称 | Adjust the name of the event …
Browse files Browse the repository at this point in the history
…to open the `siyuan://plugins` link.

REF: siyuan-note/siyuan#8927
  • Loading branch information
Zuoqiu-Yingyi committed Aug 14, 2023
1 parent ca44743 commit 45b6031
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 2023-08-15

- 实现 `wakatime` 插件基础功能 | Implement the basic functions of the `wakatime` plugin.
- 调整打开 `siyuan://plugins` 链接事件的名称 | Adjust the name of the event to open the `siyuan://plugins` link.

## 2023-08-14

Expand Down
12 changes: 6 additions & 6 deletions workspace/packages/types/siyuan/events.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ export interface IOpenSiyuanUrlDetail {
url: string;
}

export interface IOpenSiyuanUrlBlocksDetail extends IOpenSiyuanUrlDetail {
export interface IOpenSiyuanUrlBlockDetail extends IOpenSiyuanUrlDetail {
id: string;
focus: boolean;
exist: boolean;
}

export interface IOpenSiyuanUrlPluginsDetail extends IOpenSiyuanUrlDetail {
export interface IOpenSiyuanUrlPluginDetail extends IOpenSiyuanUrlDetail {
}

export interface ILoadedProtyleDetail extends IProtyle {
Expand Down Expand Up @@ -99,12 +99,12 @@ export interface IOpenSiyuanUrlEvent extends CustomEvent<IOpenSiyuanUrlDetail> {
type: "open-siyuan-url";
}

export interface IOpenSiyuanUrlBlocksEvent extends CustomEvent<IOpenSiyuanUrlBlocksDetail> {
type: "open-siyuan-url-blocks";
export interface IOpenSiyuanUrlBlockEvent extends CustomEvent<IOpenSiyuanUrlBlockDetail> {
type: "open-siyuan-url-block";
}

export interface IOpenSiyuanUrlPluginsEvent extends CustomEvent<IOpenSiyuanUrlPluginsDetail> {
type: "open-siyuan-url-plugins";
export interface IOpenSiyuanUrlPluginEvent extends CustomEvent<IOpenSiyuanUrlPluginDetail> {
type: "open-siyuan-url-plugin";
}

export interface ILoadedProtyleEvent extends CustomEvent<ILoadedProtyleDetail> {
Expand Down
8 changes: 4 additions & 4 deletions workspace/plugins/monaco-editor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ import { EditorWindow } from "./editor/window";
import { HandlerType, type IFacadeOptions } from "./facades/facade";

/* 类型 */
import type { IClickBlockIconEvent, IClickEditorContentEvent, IOpenMenuLinkEvent, IOpenSiyuanUrlPluginsEvent } from "@workspace/types/siyuan/events";
import type { IClickBlockIconEvent, IClickEditorContentEvent, IOpenMenuLinkEvent, IOpenSiyuanUrlPluginEvent } from "@workspace/types/siyuan/events";
import type { BlockID } from "@workspace/types/siyuan";

import type {
Expand Down Expand Up @@ -290,7 +290,7 @@ export default class MonacoEditorPlugin extends siyuan.Plugin {
this.eventBus.on("open-menu-link", this.linkMenuEventListener);

/* 思源 URL */
this.eventBus.on("open-siyuan-url-plugins", this.openSiyuanUrlEventListener);
this.eventBus.on("open-siyuan-url-plugin", this.openSiyuanUrlEventListener);

// /* 快捷键/命令 */
// this.addCommand({
Expand Down Expand Up @@ -332,7 +332,7 @@ export default class MonacoEditorPlugin extends siyuan.Plugin {
this.eventBus.off("click-editortitleicon", this.blockMenuEventListener);
// this.eventBus.off("open-menu-blockref", this.blockRefMenuEventListener);
this.eventBus.off("open-menu-link", this.linkMenuEventListener);
this.eventBus.off("open-siyuan-url-plugins", this.openSiyuanUrlEventListener);
this.eventBus.off("open-siyuan-url-plugin", this.openSiyuanUrlEventListener);
}

openSetting(): void {
Expand Down Expand Up @@ -907,7 +907,7 @@ export default class MonacoEditorPlugin extends siyuan.Plugin {
}

/* 思源 URL 打开事件监听器 */
protected readonly openSiyuanUrlEventListener = async (e: IOpenSiyuanUrlPluginsEvent) => {
protected readonly openSiyuanUrlEventListener = async (e: IOpenSiyuanUrlPluginEvent) => {
// this.logger.debug(e);
const url = new URL(e.detail.url);
if (url.pathname.startsWith(`//plugins/${this.name}/workspace/`)) {
Expand Down

0 comments on commit 45b6031

Please sign in to comment.