Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: fix https://github.com/siyuan-note/siyuan/issues/5364

Vanessa25b577fbee34
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index 4e9f5ce493..5f1cedf098 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -594,9 +594,13 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
if ((event.key === "Enter" || event.key === "Escape") && !event.isComposing) {
event.preventDefault();
event.stopPropagation();
- protyle.toolbar.range.selectNodeContents(linkElement);
- protyle.toolbar.range.collapse(false);
- focusByRange(protyle.toolbar.range);
+ if (linkElement.textContent === "" || linkElement.textContent === Constants.ZWSP) {
+ protyle.toolbar.setInlineMark(protyle, "link", "remove");
+ } else {
+ protyle.toolbar.range.selectNodeContents(linkElement);
+ protyle.toolbar.range.collapse(false);
+ focusByRange(protyle.toolbar.range);
+ }
window.siyuan.menus.menu.remove();
}
});
@@ -627,9 +631,13 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
if ((event.key === "Enter" || event.key === "Escape") && !event.isComposing) {
event.preventDefault();
event.stopPropagation();
- protyle.toolbar.range.selectNodeContents(linkElement);
- protyle.toolbar.range.collapse(false);
- focusByRange(protyle.toolbar.range);
+ if (!inputElement.value) {
+ protyle.toolbar.setInlineMark(protyle, "link", "remove");
+ } else {
+ protyle.toolbar.range.selectNodeContents(linkElement);
+ protyle.toolbar.range.collapse(false);
+ focusByRange(protyle.toolbar.range);
+ }
window.siyuan.menus.menu.remove();
}
});
@@ -653,9 +661,13 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
if ((event.key === "Enter" || event.key === "Escape") && !event.isComposing) {
event.preventDefault();
event.stopPropagation();
- protyle.toolbar.range.selectNodeContents(linkElement);
- protyle.toolbar.range.collapse(false);
- focusByRange(protyle.toolbar.range);
+ if (linkElement.textContent === "" || linkElement.textContent === Constants.ZWSP) {
+ protyle.toolbar.setInlineMark(protyle, "link", "remove");
+ } else {
+ protyle.toolbar.range.selectNodeContents(linkElement);
+ protyle.toolbar.range.collapse(false);
+ focusByRange(protyle.toolbar.range);
+ }
window.siyuan.menus.menu.remove();
}
});