Skip to content

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

:bug: Correct tabbed container icons and gutter highlighting https://github.com/siyuan-note/siyuan/issues/17642

Daniel244ded722936
diff --git a/app/appearance/icons/index.html b/app/appearance/icons/index.html
index 86a7e674f6..d549ffd21b 100644
--- a/app/appearance/icons/index.html
+++ b/app/appearance/icons/index.html
@@ -550,6 +550,18 @@
</svg>
iconCloseRound
</div>
+ <div>
+ <svg>
+ <use xlink:href="#iconTabs"></use>
+ </svg>
+ iconTabs
+ </div>
+ <div>
+ <svg>
+ <use xlink:href="#iconTabItem"></use>
+ </svg>
+ iconTabItem
+ </div>
<div>
<svg>
<use xlink:href="#iconLayout"></use>
diff --git a/app/appearance/icons/litheness/icon.js b/app/appearance/icons/litheness/icon.js
index 5119459ac2..318b03b231 100644
--- a/app/appearance/icons/litheness/icon.js
+++ b/app/appearance/icons/litheness/icon.js
@@ -264,6 +264,12 @@ document.body.insertAdjacentHTML('afterbegin', `<svg id="iconsLitheness" style="
<symbol id="iconCloseRound" viewBox="30 -930 900 900">
<path d="m480-437.85 122.92 122.93q8.31 8.3 20.89 8.5 12.57.19 21.27-8.5 8.69-8.7 8.69-21.08 0-12.38-8.69-21.08L522.15-480l122.93-122.92q8.3-8.31 8.5-20.89.19-12.57-8.5-21.27-8.7-8.69-21.08-8.69-12.38 0-21.08 8.69L480-522.15 357.08-645.08q-8.31-8.3-20.89-8.5-12.57-.19-21.27 8.5-8.69 8.7-8.69 21.08 0 12.38 8.69 21.08L437.85-480 314.92-357.08q-8.3 8.31-8.5 20.89-.19 12.57 8.5 21.27 8.7 8.69 21.08 8.69 12.38 0 21.08-8.69L480-437.85Zm.07 337.85q-78.84 0-148.21-29.92t-120.68-81.21q-51.31-51.29-81.25-120.63Q100-401.1 100-479.93q0-78.84 29.92-148.21t81.21-120.68q51.29-51.31 120.63-81.25Q401.1-860 479.93-860q78.84 0 148.21 29.92t120.68 81.21q51.31 51.29 81.25 120.63Q860-558.9 860-480.07q0 78.84-29.92 148.21t-81.21 120.68q-51.29 51.31-120.63 81.25Q558.9-100 480.07-100Z"/>
</symbol>
+ <symbol id="iconTabs" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
+ <rect x="2" y="4" width="20" height="16" rx="2"/><path d="M10 4v4"/><path d="M2 8h20"/><path d="M6 4v4"/>
+ </symbol>
+ <symbol id="iconTabItem" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
+ <rect width="18" height="18" x="3" y="3" rx="2"/><path d="M3 9h18"/>
+ </symbol>
<symbol id="iconLayout" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round">
<rect width="18" height="18" x="3" y="3" rx="2"/><path d="M9 3v18"/><path d="M9 15h12"/>
</symbol>
diff --git a/app/src/assets/scss/protyle/_tabs.scss b/app/src/assets/scss/protyle/_tabs.scss
index 940ec7256e..0142c4496c 100644
--- a/app/src/assets/scss/protyle/_tabs.scss
+++ b/app/src/assets/scss/protyle/_tabs.scss
@@ -97,6 +97,10 @@
}
.tabs[data-tabs-ready="true"] {
+ &.protyle-wysiwyg--hl::after {
+ display: none;
+ }
+
> .tabs-header {
display: flex;
}
diff --git a/app/src/assets/scss/protyle/_wysiwyg.scss b/app/src/assets/scss/protyle/_wysiwyg.scss
index 44fd2cadee..25fb0e37ad 100644
--- a/app/src/assets/scss/protyle/_wysiwyg.scss
+++ b/app/src/assets/scss/protyle/_wysiwyg.scss
@@ -761,7 +761,8 @@
&--select::after,
&--select-mode::after,
- &--hl::after {
+ &--hl::after,
+ .tabs[data-tabs-ready="true"].protyle-wysiwyg--hl > .tab-item::after {
background-color: var(--b3-theme-primary-lightest);
position: absolute;
width: 100%;
diff --git a/app/src/config/tabs/searchTab.ts b/app/src/config/tabs/searchTab.ts
index a7c341ef09..b9dd05525c 100644
--- a/app/src/config/tabs/searchTab.ts
+++ b/app/src/config/tabs/searchTab.ts
@@ -21,8 +21,8 @@ const registerSearchQueryGroup = (tab: SettingTabBuilder) => {
{kind: "switch", id: "search.iframeBlock", label: "IFrame", icon: "iconGlobe"},
{kind: "switch", id: "search.widgetBlock", label: window.siyuan.languages.widget, icon: "iconBoth"},
{kind: "switch", id: "search.blockquote", label: `${window.siyuan.languages.quote} <sup>[1]</sup>`, icon: "iconQuote"},
- {kind: "switch", id: "search.tabs", label: window.siyuan.languages.tabs, icon: "iconLayout"},
- {kind: "switch", id: "search.tabItem", label: window.siyuan.languages.tabItem, icon: "iconLayout"},
+ {kind: "switch", id: "search.tabs", label: window.siyuan.languages.tabs, icon: "iconTabs"},
+ {kind: "switch", id: "search.tabItem", label: window.siyuan.languages.tabItem, icon: "iconTabItem"},
{kind: "switch", id: "search.callout", label: `${window.siyuan.languages.callout} <sup>[1]</sup>`, icon: "iconCallout"},
{kind: "switch", id: "search.superBlock", label: `${window.siyuan.languages.superBlock} <sup>[1]</sup>`, icon: "iconSuper"},
{kind: "switch", id: "search.list", label: `${window.siyuan.languages.list1} <sup>[1]</sup>`, icon: "iconList"},
diff --git a/app/src/editor/getIcon.ts b/app/src/editor/getIcon.ts
index 9348123746..1fd75a6a9c 100644
--- a/app/src/editor/getIcon.ts
+++ b/app/src/editor/getIcon.ts
@@ -21,8 +21,10 @@ export const getIconByType = (type: string, sub?: string) => {
iconName = "iconQuote";
break;
case "NodeTabs":
+ iconName = "iconTabs";
+ break;
case "NodeTabItem":
- iconName = "iconLayout";
+ iconName = "iconTabItem";
break;
case "NodeCallout":
iconName = "iconCallout";
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index 1332f8a05e..2af8997aa7 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -3575,6 +3575,11 @@ export class Gutter {
}
let html = "";
let nodeElement = selectedElement || element;
+ const tabsHeader = !isMultiSelect && nodeElement.getAttribute("data-type") === "NodeTabs" ?
+ nodeElement.querySelector(":scope > .tabs-header") : null;
+ if (tabsHeader) {
+ element = tabsHeader;
+ }
this.element.classList.toggle("protyle-gutters--sb-column",
!!getHorizontalSuperBlockChild(nodeElement, protyle.wysiwyg.element));
let space = 0;
@@ -3629,7 +3634,7 @@ export class Gutter {
}
}
- let topElement = selectedElement || getTopAloneElement(nodeElement);
+ let topElement = selectedElement || (tabsHeader ? nodeElement : getTopAloneElement(nodeElement));
if (embedContext && !embedContext.boundaryElement.contains(topElement)) {
// 单独查询列表项时,渲染器生成的无 ID 列表包装节点不属于可操作边界。
topElement = embedContext.targetElement || nodeElement;
@@ -3644,7 +3649,7 @@ export class Gutter {
getParentBlock(nodeElement) !== topElement) {
topElement = topElement.querySelector("[data-node-id]");
}
- listItem = topElement.querySelector(".li") || topElement.querySelector(".list");
+ listItem = tabsHeader ? undefined : topElement.querySelector(".li") || topElement.querySelector(".list");
// 嵌入块中有列表时块标显示位置错误 https://github.com/siyuan-note/siyuan/issues/6254
if ((!embedContext && isInEmbedBlock(listItem)) || isInAVBlock(listItem) ||
hasClosestByClassName(nodeElement, "callout")) {
diff --git a/app/src/protyle/hint/extend.ts b/app/src/protyle/hint/extend.ts
index ff518bea37..f22879aa78 100644
--- a/app/src/protyle/hint/extend.ts
+++ b/app/src/protyle/hint/extend.ts
@@ -205,7 +205,7 @@ export const getBuiltinSlashMenuItems = (protyle: IProtyle): IHintData[] => {
filter: [window.siyuan.languages.tabs, "tabs", "页签", "yeqian"],
id: "tabs",
value: `:::tabs\n:::tab\n${Lute.Caret}\n:::\n:::tab\n\n:::\n:::\n`,
- html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconLayout"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.tabs}</span></div>`,
+ html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconTabs"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.tabs}</span></div>`,
}, {
filter: [window.siyuan.languages.callout, "callout", "ts", "提示", "tishi", "note"],
id: "calloutNote",
diff --git a/app/src/protyle/ui/initUI.ts b/app/src/protyle/ui/initUI.ts
index 12210d0534..61edb7485e 100644
--- a/app/src/protyle/ui/initUI.ts
+++ b/app/src/protyle/ui/initUI.ts
@@ -232,7 +232,8 @@ export const initUI = (protyle: IProtyle) => {
overAttr = false;
}
- const nodeElement = hasClosestBlock(event.target);
+ const tabsHeader = hasClosestByClassName(event.target, "tabs-header");
+ const nodeElement = tabsHeader ? hasClosestBlock(tabsHeader.parentElement) : hasClosestBlock(event.target);
if (protyle.options.render.gutter && nodeElement) {
if (!protyle.wysiwyg.element.contains(nodeElement)) {
hideElements(["gutter"], protyle);
diff --git a/app/src/search/menu.ts b/app/src/search/menu.ts
index 635e1d6dde..5ed28127a5 100644
--- a/app/src/search/menu.ts
+++ b/app/src/search/menu.ts
@@ -145,7 +145,7 @@ export const filterMenu = (config: Config.IUILayoutTabSearchConfig, cb: () => vo
<span class="fn__space"></span>
<input class="b3-switch fn__flex-center" data-type="blockquote" type="checkbox"${config.types.blockquote ? " checked" : ""}>
</label>
- ${(["tabs", "tabItem"] as const).map(type => `<label class="fn__flex b3-label"><svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconLayout"></use></svg><span class="fn__space"></span><div class="fn__flex-1 fn__flex-center">${window.siyuan.languages[type]}</div><input class="b3-switch fn__flex-center" data-type="${type}" type="checkbox"${config.types[type] ? " checked" : ""}></label>`).join("")}
+ ${(["tabs", "tabItem"] as const).map(type => `<label class="fn__flex b3-label"><svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#${type === "tabs" ? "iconTabs" : "iconTabItem"}"></use></svg><span class="fn__space"></span><div class="fn__flex-1 fn__flex-center">${window.siyuan.languages[type]}</div><input class="b3-switch fn__flex-center" data-type="${type}" type="checkbox"${config.types[type] ? " checked" : ""}></label>`).join("")}
<label class="fn__flex b3-label">
<svg class="ft__on-surface svg fn__flex-center"><use xlink:href="#iconCallout"></use></svg>
<span class="fn__space"></span>