An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: fix https://github.com/siyuan-note/siyuan/issues/8037
Vanessa9d27198c70f8
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.tsindex 312a938c84..54be10d2b8 100644--- a/app/src/menus/protyle.ts+++ b/app/src/menus/protyle.ts@@ -54,7 +54,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {let oldHTML = nodeElement.outerHTML;window.siyuan.menus.menu.remove();window.siyuan.menus.menu.append(new MenuItem({- label: `<input style="margin: 4px 0" class="b3-text-field" placeholder="${window.siyuan.languages.anchor}">`,+ label: `<input style="margin: 4px 0" class="b3-text-field fn__block" placeholder="${window.siyuan.languages.anchor}">`,bind(menuItemElement) {const inputElement = menuItemElement.querySelector("input");inputElement.value = element.getAttribute("data-subtype") === "d" ? "" : element.textContent;diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.tsindex 89feac8fd4..82c57a8cfb 100644--- a/app/src/protyle/hint/index.ts+++ b/app/src/protyle/hint/index.ts@@ -31,6 +31,7 @@ import {getIconByType} from "../../editor/getIcon";import {processRender} from "../util/processCode";import {AIChat} from "../../ai/chat";import {isMobile} from "../../util/functions";+import {isCtrl} from "../util/compatibility";export class Hint {public timeId: number;@@ -56,7 +57,7 @@ export class Hint {const btnElement = hasClosestByMatchTag(eventTarget, "BUTTON");if (btnElement && !btnElement.classList.contains("emojis__item")) {if (btnElement.parentElement.classList.contains("b3-list")) {- this.fill(decodeURIComponent(btnElement.getAttribute("data-value")), protyle);+ this.fill(decodeURIComponent(btnElement.getAttribute("data-value")), protyle, true, isCtrl(event));} else {// 划选引用点击,需先重置 rangesetTimeout(() => {@@ -163,7 +164,7 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;}// https://github.com/siyuan-note/siyuan/issues/7933- if (this.splitChar === "#" ) {+ if (this.splitChar === "#") {const blockElement = hasClosestBlock(protyle.toolbar.range.startContainer);if (blockElement && blockElement.getAttribute("data-type") === "NodeHeading") {const blockIndex = getSelectionOffset(protyle.toolbar.range.startContainer, blockElement).start;@@ -406,7 +407,7 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;}}- public fill(value: string, protyle: IProtyle, updateRange = true) {+ public fill(value: string, protyle: IProtyle, updateRange = true, refIsS = false) {hideElements(["hint", "toolbar"], protyle);if (updateRange) {protyle.toolbar.range = getEditorRange(protyle.wysiwyg.element);@@ -486,6 +487,10 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;let tempElement = document.createElement("div");tempElement.innerHTML = value.replace(/<mark>/g, "").replace(/<\/mark>/g, "");tempElement = tempElement.firstElementChild as HTMLDivElement;+ if (refIsS) {+ tempElement.setAttribute("data-subtype", "s");+ tempElement.innerText = range.toString().replace(this.splitChar, "");+ }protyle.toolbar.setInlineMark(protyle, "block-ref", "range", {type: "id",color: `${tempElement.getAttribute("data-id")}${Constants.ZWSP}${tempElement.getAttribute("data-subtype")}${Constants.ZWSP}${tempElement.textContent}`@@ -743,7 +748,7 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;if (mark === Constants.ZWSP + 3) {(this.element.querySelector(".b3-list-item--focus input") as HTMLElement).click();} else {- this.fill(mark, protyle);+ this.fill(mark, protyle, true, isCtrl(event));}}event.preventDefault();diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.tsindex bbbd0259d8..734a4a4bfe 100644--- a/app/src/protyle/util/compatibility.ts+++ b/app/src/protyle/util/compatibility.ts@@ -74,7 +74,7 @@ export const getEventName = () => {};// 区别 mac 上的 ctrl 和 meta-export const isCtrl = (event: KeyboardEvent) => {+export const isCtrl = (event: KeyboardEvent | MouseEvent) => {if (isMac()) {// macif (event.metaKey && !event.ctrlKey) {diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.tsindex 41ab859fec..8c299e75db 100644--- a/app/src/protyle/wysiwyg/keydown.ts+++ b/app/src/protyle/wysiwyg/keydown.ts@@ -515,7 +515,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {return;}// hint: 上下、回车选择- if (!event.altKey && !event.shiftKey && !isCtrl(event) && (event.key.indexOf("Arrow") > -1 || event.key === "Enter") &&+ if (!event.altKey && !event.shiftKey &&+ ((event.key.indexOf("Arrow") > -1 && !isCtrl(event)) || event.key === "Enter") &&!protyle.hint.element.classList.contains("fn__none") && protyle.hint.select(event, protyle)) {event.stopPropagation();event.preventDefault();