Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/14324

Vanessa7823357e1cfd
diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts
index 65f686efcc..4d7b4364be 100644
--- a/app/src/protyle/hint/index.ts
+++ b/app/src/protyle/hint/index.ts
@@ -986,6 +986,8 @@ ${genHintItemHTML(item)}
}
private getKey(currentLineValue: string, extend: IHintExtend[]) {
+ const prevSplit = this.splitChar;
+ const prevLastIndex = this.lastIndex;
this.lastIndex = -1;
this.splitChar = "";
extend.forEach((item) => {
@@ -998,21 +1000,18 @@ ${genHintItemHTML(item)}
}
}
if (this.lastIndex < currentLastIndex) {
- if (Constants.BLOCK_HINT_KEYS.includes(this.splitChar) &&
- (item.key === ":" || item.key === "#" || item.key === "/" || item.key === "、")) {
- // 块搜索中忽略以上符号
- } else if (this.splitChar === "#" &&
- (item.key === "/" || item.key === "、")) {
- // 标签中忽略以上符号
- } else {
- this.splitChar = item.key;
- this.lastIndex = currentLastIndex;
- }
+ this.splitChar = item.key;
+ this.lastIndex = currentLastIndex;
}
});
if (this.lastIndex === -1) {
return undefined;
}
+ // 上一次提示没有结束时不能被其余提示干扰 https://github.com/siyuan-note/siyuan/issues/14324
+ if (!this.element.classList.contains("fn__none") && prevSplit && prevSplit !== this.splitChar) {
+ this.splitChar = prevSplit;
+ this.lastIndex = prevLastIndex;
+ }
// 冒号前为数字或冒号不进行emoji提示
if (this.splitChar === ":") {
this.enableEmoji = !(/\d/.test(currentLineValue.substr(this.lastIndex - 1, 1)) ||
diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.ts
index 6bc7140479..90b9d26c52 100644
--- a/app/src/protyle/util/paste.ts
+++ b/app/src/protyle/util/paste.ts
@@ -142,19 +142,6 @@ export const pasteEscaped = async (protyle: IProtyle, nodeElement: Element) => {
}
};
-const filterClipboardHint = (protyle: IProtyle, textPlain: string) => {
- let needRender = true;
- protyle.options.hint.extend.find(item => {
- if (item.key === textPlain) {
- needRender = false;
- return true;
- }
- });
- if (needRender) {
- protyle.hint.render(protyle);
- }
-};
-
export const pasteAsPlainText = async (protyle: IProtyle) => {
let localFiles: string[] = [];
/// #if !BROWSER
@@ -210,7 +197,6 @@ export const pasteAsPlainText = async (protyle: IProtyle) => {
// insertHTML 会进行内部反转义
insertHTML(content, protyle, false, false, true);
- filterClipboardHint(protyle, textPlain);
}
};
@@ -266,6 +252,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
}) & {
target: HTMLElement
}) => {
+ protyle.hint.enableExtend = false;
if ("clipboardData" in event || "dataTransfer" in event) {
event.stopPropagation();
event.preventDefault();
@@ -383,7 +370,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
}
return;
}
- hideElements(["select"], protyle);
+ hideElements(["select", "hint"], protyle);
protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--hl").forEach(item => {
item.classList.remove("protyle-wysiwyg--hl");
});
@@ -476,7 +463,6 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
insertHTML(tempInnerHTML, protyle, isBlock, false, true);
}
- filterClipboardHint(protyle, protyle.lute.BlockDOM2StdMd(tempInnerHTML));
blockRender(protyle, protyle.wysiwyg.element);
processRender(protyle.wysiwyg.element);
highlightRender(protyle.wysiwyg.element);
@@ -569,7 +555,6 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
processRender(protyle.wysiwyg.element);
highlightRender(protyle.wysiwyg.element);
avRender(protyle.wysiwyg.element, protyle);
- filterClipboardHint(protyle, response.data);
scrollCenter(protyle, undefined, false, "smooth");
});
return;
@@ -610,7 +595,6 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
const textPlainDom = protyle.lute.Md2BlockDOM(textPlain);
insertHTML(textPlainDom, protyle, false, false, true);
- filterClipboardHint(protyle, textPlain);
}
blockRender(protyle, protyle.wysiwyg.element);
processRender(protyle.wysiwyg.element);