From 94cd77dd09f4613cba546f9f54714591ee9d5eed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A2=96=E9=80=B8?= <49649786+Zuoqiu-Yingyi@users.noreply.github.com> Date: Wed, 2 Aug 2023 15:25:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(webview):=20=E4=BF=AE=E5=A4=8D=20`#`=20?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E6=97=A0=E6=B3=95=E8=B7=B3=E8=BD=AC=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20|=20Fix=20the=20issue=20that=20`#`=20link=20cannot?= =?UTF-8?q?=20jump.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Settings.svelte | 8 ++++---- src/configs/default.ts | 4 ++++ src/index.ts | 5 +++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/Settings.svelte b/src/components/Settings.svelte index ad85605..e9bce3e 100644 --- a/src/components/Settings.svelte +++ b/src/components/Settings.svelte @@ -243,9 +243,9 @@ slot="input" type={ItemType.checkbox} settingKey="Checkbox" - settingValue={config.tab.open.targets.hyperlink.editor} + settingValue={config.tab.open.targets.hyperlink.editor.enable} on:changed={e => { - config.tab.open.targets.hyperlink.editor = e.detail.value; + config.tab.open.targets.hyperlink.editor.enable = e.detail.value; updated(); }} /> @@ -260,9 +260,9 @@ slot="input" type={ItemType.checkbox} settingKey="Checkbox" - settingValue={config.tab.open.targets.hyperlink.other} + settingValue={config.tab.open.targets.hyperlink.other.enable} on:changed={e => { - config.tab.open.targets.hyperlink.other = e.detail.value; + config.tab.open.targets.hyperlink.other.enable = e.detail.value; updated(); }} /> diff --git a/src/configs/default.ts b/src/configs/default.ts index af1ac10..d94b8fd 100644 --- a/src/configs/default.ts +++ b/src/configs/default.ts @@ -73,6 +73,10 @@ export const DEFAULT_CONFIG: IConfig = { enable: true, prefix: "//", }, + "#": { // URL hash + enable: false, + prefix: "#", + }, }, }, }, diff --git a/src/index.ts b/src/index.ts index 3552d06..350f8e8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -467,7 +467,8 @@ export default class WebviewPlugin extends siyuan.Plugin { case "a": meta.valid = true; meta.enabled = targets.hyperlink.other.enable; - meta.href = (element as HTMLAnchorElement).href || ""; + // meta.href = (element as HTMLAnchorElement).href || ""; + meta.href = element.getAttribute("href") || ""; meta.title = element.title || element.innerText; break; case "span": @@ -790,7 +791,7 @@ export default class WebviewPlugin extends siyuan.Plugin { /* 判断目标元素是否有效 */ if (meta.valid) { - this.logger.info(meta.href); + this.logger.info(meta); if (this.isUrlSchemeAvailable(meta.href, this.config.tab.open.protocols)) { try { e.preventDefault();