Vanessa 2025-05-18 00:02:57 +08:00
parent 4244c18779
commit 7823357e1c
2 changed files with 11 additions and 28 deletions

View file

@ -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)) ||

View file

@ -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);