Skip to content

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

:art: Move tab layout options to the block icon menu https://github.com/siyuan-note/siyuan/issues/17642

Daniel5757cdebf303
diff --git a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-6yi0dv5/20200924101225-k254i8g.sy b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-6yi0dv5/20200924101225-k254i8g.sy
index 3d994b9210..70472e4dc6 100644
--- a/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-6yi0dv5/20200924101225-k254i8g.sy
+++ b/app/guide/20210808180117-6v0mkxr/20200923234011-ieuun1p/20210808180303-6yi0dv5/20200924101225-k254i8g.sy
@@ -6,7 +6,7 @@
"id": "20200924101225-k254i8g",
"title": "Content Block Type",
"type": "doc",
- "updated": "20260906013806"
+ "updated": "20260906084311"
},
"Children": [
{
@@ -1336,7 +1336,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20210104091538-a55chyw",
- "updated": "20260906013806"
+ "updated": "20260906084311"
},
"Children": [
{
@@ -2696,7 +2696,7 @@
"Type": "NodeHeading",
"Properties": {
"id": "20260905124213-wbxn79t",
- "updated": "20260906013806"
+ "updated": "20260906084311"
},
"HeadingLevel": 3,
"Children": [
@@ -2786,12 +2786,12 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20260906003122-knct56j",
- "updated": "20260906013806"
+ "updated": "20260906084311"
},
"Children": [
{
"Type": "NodeText",
- "Data": "Type / and choose the tabs block to create a group. Use + to add tabs and the more menu to adjust the layout. Double-click a title or use Rename to edit the text directly in the tab. Like callout titles, tab titles support WYSIWYG editing: use the inline toolbar to apply bold, colors, and other styles while preserving existing formatting as you edit the text."
+ "Data": "Type / and choose the tabs block to create a group. Use + to add tabs and open the tabs block icon menu to choose top or left tabs from the Tabs submenu. Double-click a title or use Rename to edit the text directly in the tab. Like callout titles, tab titles support WYSIWYG editing: use the inline toolbar to apply bold, colors, and other styles while preserving existing formatting as you edit the text."
}
]
},
diff --git a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-fqgskfj/20200905090211-2vixtlf.sy b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-fqgskfj/20200905090211-2vixtlf.sy
index 61e9a4eff3..7e719dc92e 100644
--- a/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-fqgskfj/20200905090211-2vixtlf.sy
+++ b/app/guide/20210808180117-czj9bvb/20200812220555-lj3enxa/20210808180320-fqgskfj/20200905090211-2vixtlf.sy
@@ -6,7 +6,7 @@
"id": "20200905090211-2vixtlf",
"title": "内容块类型",
"type": "doc",
- "updated": "20260906013806"
+ "updated": "20260906084311"
},
"Children": [
{
@@ -1369,7 +1369,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20210104090624-9qgquxh",
- "updated": "20260906013806"
+ "updated": "20260906084311"
},
"Children": [
{
@@ -2778,7 +2778,7 @@
"Type": "NodeHeading",
"Properties": {
"id": "20260905124213-9etkynq",
- "updated": "20260906013806"
+ "updated": "20260906084311"
},
"HeadingLevel": 3,
"Children": [
@@ -2868,12 +2868,12 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20260906003122-812ct16",
- "updated": "20260906013806"
+ "updated": "20260906084311"
},
"Children": [
{
"Type": "NodeText",
- "Data": "输入 / 并选择页签块可创建一组页签。通过 + 添加页签,通过更多菜单调整布局。双击标题或使用重命名菜单,可以在页签标题处直接编辑文字。标题与提示块一样支持所见即所得编辑,可通过行级工具栏设置加粗、颜色等样式,修改文字时保留已有格式。"
+ "Data": "输入 / 并选择页签块可创建一组页签。通过 + 添加页签,点击页签块的块标,在页签块子菜单中选择顶部页签或左侧页签。双击标题或使用重命名菜单,可以在页签标题处直接编辑文字。标题与提示块一样支持所见即所得编辑,可通过行级工具栏设置加粗、颜色等样式,修改文字时保留已有格式。"
}
]
},
diff --git a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226115825-mhcslw2/20211226120147-ib6yy3i.sy b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226115825-mhcslw2/20211226120147-ib6yy3i.sy
index 66dd734770..c06c73b9c9 100644
--- a/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226115825-mhcslw2/20211226120147-ib6yy3i.sy
+++ b/app/guide/20211226090932-5lcq56f/20211226115423-d5z1joq/20211226115825-mhcslw2/20211226120147-ib6yy3i.sy
@@ -6,7 +6,7 @@
"id": "20211226120147-ib6yy3i",
"title": "內容區塊類型",
"type": "doc",
- "updated": "20260906013806"
+ "updated": "20260906084311"
},
"Children": [
{
@@ -1365,7 +1365,7 @@
"HeadingLevel": 2,
"Properties": {
"id": "20211226120227-esm6f20",
- "updated": "20260906013806"
+ "updated": "20260906084311"
},
"Children": [
{
@@ -2696,7 +2696,7 @@
"Type": "NodeHeading",
"Properties": {
"id": "20260905124213-371qsy7",
- "updated": "20260906013806"
+ "updated": "20260906084311"
},
"HeadingLevel": 3,
"Children": [
@@ -2786,12 +2786,12 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20260906003122-0jlwsyi",
- "updated": "20260906013806"
+ "updated": "20260906084311"
},
"Children": [
{
"Type": "NodeText",
- "Data": "輸入 / 並選擇頁籤區塊可建立一組頁籤。透過 + 新增頁籤,透過更多選單調整配置。按兩下標題或使用重新命名選單,即可在頁籤標題處直接編輯文字。標題與提示區塊一樣支援所見即所得編輯,可透過行級工具列設定粗體、顏色等樣式,修改文字時保留既有格式。"
+ "Data": "輸入 / 並選擇頁籤區塊可建立一組頁籤。透過 + 新增頁籤,點擊頁籤區塊的區塊圖示,在頁籤區塊子選單中選擇頂部頁籤或左側頁籤。按兩下標題或使用重新命名選單,即可在頁籤標題處直接編輯文字。標題與提示區塊一樣支援所見即所得編輯,可透過行級工具列設定粗體、顏色等樣式,修改文字時保留既有格式。"
}
]
},
diff --git a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-gvtksyj/20240530101000-35bbvcx.sy b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-gvtksyj/20240530101000-35bbvcx.sy
index 0d3c4ba387..a3bf294f2a 100644
--- a/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-gvtksyj/20240530101000-35bbvcx.sy
+++ b/app/guide/20240530133126-axarxgx/20240530101000-4qitucx/20240530101000-gvtksyj/20240530101000-35bbvcx.sy
@@ -7,7 +7,7 @@
"id": "20240530101000-35bbvcx",
"title": "コンテンツブロックの種類",
"type": "doc",
- "updated": "20260906013806"
+ "updated": "20260906084311"
},
"Children": [
{
@@ -1422,7 +1422,7 @@
"Properties": {
"ID": "20240530101000-rjjxxn8",
"id": "20240530101000-p035stn",
- "updated": "20260906013806"
+ "updated": "20260906084311"
},
"Children": [
{
@@ -2890,7 +2890,7 @@
"Type": "NodeHeading",
"Properties": {
"id": "20260905124213-rmj1ui2",
- "updated": "20260906013806"
+ "updated": "20260906084311"
},
"HeadingLevel": 3,
"Children": [
@@ -2980,12 +2980,12 @@
"Type": "NodeParagraph",
"Properties": {
"id": "20260906003122-om7wyo8",
- "updated": "20260906013806"
+ "updated": "20260906084311"
},
"Children": [
{
"Type": "NodeText",
- "Data": "/ を入力してタブブロックを選択すると、タブのグループを作成できます。+ でタブを追加し、その他メニューで配置を調整します。タイトルをダブルクリックするか名前変更メニューを使うと、タブのタイトルをその場で直接編集できます。コールアウトのタイトルと同様に、見たままの状態で編集でき、インラインツールバーから太字や文字色などを設定できます。文字を変更しても既存の書式は保持されます。"
+ "Data": "/ を入力してタブブロックを選択すると、タブのグループを作成できます。+ でタブを追加し、タブブロックのアイコンメニューを開き、タブブロックのサブメニューから上部タブまたは左側タブを選択します。タイトルをダブルクリックするか名前変更メニューを使うと、タブのタイトルをその場で直接編集できます。コールアウトのタイトルと同様に、見たままの状態で編集でき、インラインツールバーから太字や文字色などを設定できます。文字を変更しても既存の書式は保持されます。"
}
]
},
diff --git a/app/src/assets/scss/protyle/_tabs.scss b/app/src/assets/scss/protyle/_tabs.scss
index 95be47ee3f..484e0aa6ff 100644
--- a/app/src/assets/scss/protyle/_tabs.scss
+++ b/app/src/assets/scss/protyle/_tabs.scss
@@ -89,9 +89,6 @@
height: 16px;
}
- &--more {
- margin-left: auto;
- }
}
.tab-item {
diff --git a/app/src/config/entryVisibility/catalog.test.ts b/app/src/config/entryVisibility/catalog.test.ts
index 9f0ec75fdb..09cd3faa8b 100644
--- a/app/src/config/entryVisibility/catalog.test.ts
+++ b/app/src/config/entryVisibility/catalog.test.ts
@@ -700,6 +700,19 @@ test("list block submenu follows the base block entries", () => {
]);
});
+test("tabs layout actions have their own configurable block menu", () => {
+ assert.deepEqual(getEntryCatalogChildren("gutter.single.tabs").map(item => item.key), [
+ "tabsPositionTop", "tabsPositionLeft",
+ ]);
+ const keys = getEntryCatalogChildren("gutter.single").map(item => item.key);
+ const index = keys.indexOf("tabs");
+ assert.deepEqual(keys.slice(index - 1, index + 3), [
+ "separator_tabs", "tabs", "separator_cancelSuperBlock", "superBlock",
+ ]);
+ assert.equal(getEntryCatalogNode("gutter.single.tabs")?.simple, true);
+ assert.equal(getEntryCatalogNode("gutter.single.separator_tabs")?.type, "separator");
+});
+
test("super block actions and vertical alignment use their respective menu groups", () => {
assert.deepEqual(getEntryCatalogChildren("gutter.single.superBlock").map((item) => item.key), [
"cancelSuperBlock",
diff --git a/app/src/config/entryVisibility/catalog.ts b/app/src/config/entryVisibility/catalog.ts
index 3cebefeadd..c6ec94ce43 100644
--- a/app/src/config/entryVisibility/catalog.ts
+++ b/app/src/config/entryVisibility/catalog.ts
@@ -364,6 +364,11 @@ const gutterSingle = () => [
node("prependListItem", lang("prependListItem")),
node("appendListItem", lang("appendListItem")),
]),
+ separator("separator_tabs"),
+ node("tabs", lang("tabs"), true, [
+ node("tabsPositionTop", lang("tabsPositionTop")),
+ node("tabsPositionLeft", lang("tabsPositionLeft")),
+ ]),
separator("separator_cancelSuperBlock"),
node("superBlock", lang("superBlock"), true, [
node("cancelSuperBlock", () => `${window.siyuan.languages.cancel} ${window.siyuan.languages.superBlock}`),
diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.ts
index ff9a7a53f5..567a66ac82 100644
--- a/app/src/protyle/gutter/index.ts
+++ b/app/src/protyle/gutter/index.ts
@@ -128,7 +128,7 @@ import {canShowGutterInsert, genGutterBlockButtonHTML} from "./button";
import {getViewFoldOccurrenceID, hasViewFoldContext, setViewFold} from "../util/viewFold";
import {exportImage} from "../export/util";
import {CALLOUT_PRESETS, updateCalloutType, updateCustomCalloutType} from "../wysiwyg/callout";
-import {unwrapTabs} from "../wysiwyg/tabs";
+import {setTabsPosition, unwrapTabs} from "../wysiwyg/tabs";
// 块类型 data-type 到本地化名称键的映射,用于块标提示中的 ${x}
const BLOCK_TYPE_LANG_KEYS: { [key: string]: string } = {
@@ -2173,6 +2173,28 @@ export class Gutter {
return genListBlockSubmenu(await continueListStartPromise);
} : undefined,
}).element);
+ } else if (type === "NodeTabs" && allowStructuralMutation) {
+ window.siyuan.menus.menu.append(new MenuItem({
+ id: "separator_tabs",
+ type: "separator",
+ }).element);
+ window.siyuan.menus.menu.append(new MenuItem({
+ id: "tabs",
+ icon: "iconTabs",
+ label: window.siyuan.languages.tabs,
+ type: "submenu",
+ submenu: [{
+ id: "tabsPositionTop",
+ label: window.siyuan.languages.tabsPositionTop,
+ icon: (nodeElement.getAttribute("tabs-position") || "top") === "top" ? "iconSelect" : undefined,
+ click: () => setTabsPosition(protyle, nodeElement as HTMLElement, "top"),
+ }, {
+ id: "tabsPositionLeft",
+ label: window.siyuan.languages.tabsPositionLeft,
+ icon: nodeElement.getAttribute("tabs-position") === "left" ? "iconSelect" : undefined,
+ click: () => setTabsPosition(protyle, nodeElement as HTMLElement, "left"),
+ }],
+ }).element);
} else if (type === "NodeSuperBlock" && !protyle.disabled) {
window.siyuan.menus.menu.append(new MenuItem({
id: "separator_cancelSuperBlock",
diff --git a/app/src/protyle/render/tabsRender.ts b/app/src/protyle/render/tabsRender.ts
index 72904a8d4d..913855b635 100644
--- a/app/src/protyle/render/tabsRender.ts
+++ b/app/src/protyle/render/tabsRender.ts
@@ -6,7 +6,6 @@ export interface ITabsRenderOptions {
readonly?: (tabs?: Element) => boolean;
label?: string;
addLabel?: string;
- menuLabel?: string;
select?: (tabs: HTMLElement, id: string) => void;
rename?: (item: HTMLElement) => void;
add?: (tabs: HTMLElement) => void;
@@ -277,16 +276,6 @@ export const tabsRender = (element: Element, options: ITabsRenderOptions = {}) =
controller.options.add?.(tabs);
});
header.appendChild(add);
- const menu = document.createElement("button");
- menu.type = "button";
- menu.className = "tabs-control tabs-control--more ariaLabel";
- menu.innerHTML = '<svg><use xlink:href="#iconMore"></use></svg>';
- menu.setAttribute("aria-label", escapeHtml(controller.options.menuLabel || "..."));
- menu.addEventListener("click", event => {
- event.stopPropagation();
- controller.options.menu?.(tabs, undefined, menu);
- });
- header.appendChild(menu);
}
state.signature = signature;
if (focusedID) {
diff --git a/app/src/protyle/wysiwyg/tabs.ts b/app/src/protyle/wysiwyg/tabs.ts
index 0e54af0fae..94dfb822cc 100644
--- a/app/src/protyle/wysiwyg/tabs.ts
+++ b/app/src/protyle/wysiwyg/tabs.ts
@@ -109,6 +109,12 @@ export const unwrapTabs = (protyle: IProtyle, tabs: HTMLElement) => {
});
};
+export const setTabsPosition = (protyle: IProtyle, tabs: HTMLElement, position: "top" | "left") => {
+ if ((tabs.getAttribute("tabs-position") || "top") !== position) {
+ changeTabs(protyle, [tabs], () => tabs.setAttribute("tabs-position", position));
+ }
+};
+
export const openTabsMenu = (protyle: IProtyle, tabs: HTMLElement, item: HTMLElement, anchor: HTMLElement) => {
if (!canEdit(protyle, tabs)) {
return;
@@ -140,13 +146,6 @@ export const openTabsMenu = (protyle: IProtyle, tabs: HTMLElement, item: HTMLEle
});
focusBlock(tabs);
}});
- } else {
- ["top", "left"].forEach(position => menu.addItem({
- label: position === "top" ? lang.tabsPositionTop : lang.tabsPositionLeft,
- icon: (tabs.getAttribute("tabs-position") || "top") === position ? "iconSelect" : undefined,
- click: () => changeTabs(protyle, [tabs], () => tabs.setAttribute("tabs-position", position)),
- }));
- menu.addItem({icon: "iconSuper", label: lang.tabsUnwrap, click: () => unwrapTabs(protyle, tabs)});
}
const rect = anchor.getBoundingClientRect();
menu.open({x: rect.left, y: rect.bottom});
@@ -159,7 +158,6 @@ export const initEditorTabs = (protyle: IProtyle) => {
readonly: tabs => !canEdit(protyle, tabs || root),
label: window.siyuan.languages.tabItem,
addLabel: window.siyuan.languages.tabItem,
- menuLabel: window.siyuan.languages.more,
select: (tabs, id) => {
if (!canEdit(protyle, tabs) || tabs.getAttribute("tabs-active-id") === id) {
return;