Skip to content

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

:bug: $$

Vanessa8a4e4e012898
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 4fe9170152..22a5ec4583 100644
--- a/app/src/protyle/toolbar/index.ts
+++ b/app/src/protyle/toolbar/index.ts
@@ -1076,7 +1076,10 @@ export class Toolbar {
}
// 光标定位
- if (getSelection().rangeCount === 0) { // https://ld246.com/article/1665306093005
+ if (getSelection().rangeCount === 0 ||
+ // $$ 中间输入后再 ESC 光标无法定位
+ (getSelection().rangeCount > 0 && hasClosestByClassName(getSelection().getRangeAt(0).startContainer, "protyle-util"))
+ ) { // https://ld246.com/article/1665306093005
if (renderElement.tagName === "SPAN") {
if (inlineLastNode) {
if (inlineLastNode.parentElement) {
diff --git a/app/src/protyle/wysiwyg/input.ts b/app/src/protyle/wysiwyg/input.ts
index 41e7788bb1..32038eae09 100644
--- a/app/src/protyle/wysiwyg/input.ts
+++ b/app/src/protyle/wysiwyg/input.ts
@@ -148,15 +148,14 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:
// 使用 md 闭合后继续输入应为普通文本
blockElement.outerHTML = html.replace("</span><wbr>", "</span>" + Constants.ZWSP + "<wbr>");
}
- // https://github.com/siyuan-note/siyuan/issues/8972
- const mathSize = blockElement.querySelectorAll('[data-type="inline-math"]').length;
protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${id}"]`).forEach((item: HTMLElement) => {
if (item.getAttribute("data-type") === "NodeBlockQueryEmbed" ||
!hasClosestByAttribute(item, "data-type", "NodeBlockQueryEmbed")) {
blockElement = item;
}
});
- if (mathSize > 0 && mathSize < html.split('<span data-type="inline-math" data-subtype="math"').length - 1) {
+ // https://github.com/siyuan-note/siyuan/issues/8972
+ if (html.split('<span data-type="inline-math" data-subtype="math"').length > 1) {
Array.from(blockElement.querySelectorAll('[data-type="inline-math"]')).find((item: HTMLElement) => {
if (item.dataset.content.indexOf("<wbr>") > -1) {
item.setAttribute("data-content", item.dataset.content.replace("<wbr>", ""));