Skip to content

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

:bug: Avoid editor focus after mobile outline heading conversion https://github.com/siyuan-note/siyuan/issues/18292

Daniel05a86cd2b147
diff --git a/app/src/mobile/dock/MobileOutline.ts b/app/src/mobile/dock/MobileOutline.ts
index fe8822ee19..0d8bb4b2c2 100644
--- a/app/src/mobile/dock/MobileOutline.ts
+++ b/app/src/mobile/dock/MobileOutline.ts
@@ -847,11 +847,13 @@ export class MobileOutline extends Model {
click: () => {
const data = this.getProtyleAndBlockElement(element);
if (data) {
+ getSelection()?.removeAllRanges();
turnsIntoTransaction({
protyle: data.protyle,
selectsElement: [data.blockElement],
type: "Blocks2Hs",
- level: currentLevel - 1
+ level: currentLevel - 1,
+ unfocus: true,
});
}
}
@@ -867,11 +869,13 @@ export class MobileOutline extends Model {
click: () => {
const data = this.getProtyleAndBlockElement(element);
if (data) {
+ getSelection()?.removeAllRanges();
turnsIntoTransaction({
protyle: data.protyle,
selectsElement: [data.blockElement],
type: "Blocks2Hs",
- level: currentLevel + 1
+ level: currentLevel + 1,
+ unfocus: true,
});
}
}
@@ -1265,7 +1269,6 @@ export class MobileOutline extends Model {
}
});
transaction(protyle, response.data.doOperations, response.data.undoOperations);
- focusBlock(protyle.wysiwyg.element.querySelector(`[data-node-id="${id}"]`));
});
}
};
diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.ts
index 3f1cd310cd..681394a642 100644
--- a/app/src/protyle/wysiwyg/transaction.ts
+++ b/app/src/protyle/wysiwyg/transaction.ts
@@ -1320,7 +1320,8 @@ export const turnsIntoTransaction = (options: {
type: TTurnInto,
level?: number,
isContinue?: boolean,
- range?: Range
+ range?: Range,
+ unfocus?: boolean,
}) => {
// https://github.com/siyuan-note/siyuan/issues/14505
options.protyle.observerLoad?.disconnect();
@@ -1482,10 +1483,12 @@ export const turnsIntoTransaction = (options: {
highlightRender(options.protyle.wysiwyg.element);
avRender(options.protyle.wysiwyg.element, options.protyle);
blockRender(options.protyle, options.protyle.wysiwyg.element);
- if (range || options.range) {
- focusByWbr(options.protyle.wysiwyg.element, range || options.range);
- } else {
- focusBlock(options.protyle.wysiwyg.element.querySelector(`[data-node-id="${selectsElement[0].getAttribute("data-node-id")}"]`));
+ if (!options.unfocus) {
+ if (range || options.range) {
+ focusByWbr(options.protyle.wysiwyg.element, range || options.range);
+ } else {
+ focusBlock(options.protyle.wysiwyg.element.querySelector(`[data-node-id="${selectsElement[0].getAttribute("data-node-id")}"]`));
+ }
}
hideElements(["gutter"], options.protyle);
};