Skip to content

Commit

Permalink
fix(webview): 修复 # 链接无法跳转问题 | Fix the issue that # link cannot jump.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuoqiu-Yingyi committed Aug 2, 2023
1 parent e065f20 commit 94cd77d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/components/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}}
/>
Expand All @@ -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();
}}
/>
Expand Down
4 changes: 4 additions & 0 deletions src/configs/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ export const DEFAULT_CONFIG: IConfig = {
enable: true,
prefix: "//",
},
"#": { // URL hash
enable: false,
prefix: "#",
},
},
},
},
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 94cd77d

Please sign in to comment.