Skip to content

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

:bug: Preserve outline highlights inside tabs https://github.com/siyuan-note/siyuan/issues/20225

Danielbbef0e1f8b11
diff --git a/app/src/editor/outlineContainers.test.ts b/app/src/editor/outlineContainers.test.ts
index 0f2af4be76..242ce48d44 100644
--- a/app/src/editor/outlineContainers.test.ts
+++ b/app/src/editor/outlineContainers.test.ts
@@ -15,7 +15,7 @@ for (const path of ["src/layout/dock/Outline.ts", "src/mobile/dock/MobileOutline
}
globalThis.Harness = Harness;`, {compilerOptions: {target: ScriptTarget.ES2021}}).outputText;
- for (const container of ["bq", "callout-content"]) {
+ for (const container of ["bq", "callout-content", "tab-item"]) {
for (const caret of ["heading", "paragraph"]) {
test(`${path}: ${caret} inside ${container} highlights the preceding outer heading`, async () => {
const outer = {id: "outer", type: "NodeHeading", container: "", previous: undefined as {id: string} | undefined};
diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.ts
index 4314b1232c..fe3ea5b0bc 100644
--- a/app/src/layout/dock/Outline.ts
+++ b/app/src/layout/dock/Outline.ts
@@ -584,14 +584,16 @@ export class Outline extends Model {
}
if (nodeElement.getAttribute("data-type") === "NodeHeading" &&
!hasClosestByClassName(nodeElement, "bq") &&
- !hasClosestByClassName(nodeElement, "callout-content")) {
+ !hasClosestByClassName(nodeElement, "callout-content") &&
+ !hasClosestByClassName(nodeElement, "tab-item")) {
this.setCurrentById(nodeElement.getAttribute("data-node-id"));
} else {
let previousElement = getPreviousBlock(nodeElement);
while (previousElement) {
if (previousElement.getAttribute("data-type") === "NodeHeading" &&
!hasClosestByClassName(previousElement, "bq") &&
- !hasClosestByClassName(previousElement, "callout-content")) {
+ !hasClosestByClassName(previousElement, "callout-content") &&
+ !hasClosestByClassName(previousElement, "tab-item")) {
break;
} else {
previousElement = getPreviousBlock(previousElement);
diff --git a/app/src/mobile/dock/MobileOutline.ts b/app/src/mobile/dock/MobileOutline.ts
index a5b16fe7f7..83544d9f6e 100644
--- a/app/src/mobile/dock/MobileOutline.ts
+++ b/app/src/mobile/dock/MobileOutline.ts
@@ -433,14 +433,16 @@ export class MobileOutline extends Model {
}
if (nodeElement.getAttribute("data-type") === "NodeHeading" &&
!hasClosestByClassName(nodeElement, "bq") &&
- !hasClosestByClassName(nodeElement, "callout-content")) {
+ !hasClosestByClassName(nodeElement, "callout-content") &&
+ !hasClosestByClassName(nodeElement, "tab-item")) {
this.setCurrentById(nodeElement.getAttribute("data-node-id"));
} else {
let previousElement = getPreviousBlock(nodeElement);
while (previousElement) {
if (previousElement.getAttribute("data-type") === "NodeHeading" &&
!hasClosestByClassName(previousElement, "bq") &&
- !hasClosestByClassName(previousElement, "callout-content")) {
+ !hasClosestByClassName(previousElement, "callout-content") &&
+ !hasClosestByClassName(previousElement, "tab-item")) {
break;
} else {
previousElement = getPreviousBlock(previousElement);