An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: Support tab block references and mobile creation https://github.com/siyuan-note/siyuan/issues/17642
Daniela6e974f1789c
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.syindex 70472e4dc6..78249a889b 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": "20260906084311"+ "updated": "20260906133808"},"Children": [{@@ -1336,7 +1336,7 @@"HeadingLevel": 2,"Properties": {"id": "20210104091538-a55chyw",- "updated": "20260906084311"+ "updated": "20260906133808"},"Children": [{@@ -2696,7 +2696,7 @@"Type": "NodeHeading","Properties": {"id": "20260905124213-wbxn79t",- "updated": "20260906084311"+ "updated": "20260906133808"},"HeadingLevel": 3,"Children": [@@ -2786,12 +2786,30 @@"Type": "NodeParagraph","Properties": {"id": "20260906003122-knct56j",- "updated": "20260906084311"+ "updated": "20260906133808"},"Children": [{"Type": "NodeText",- "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."+ "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. Right-click a tab title and choose "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Copy"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "Copy block ref"+ },+ {+ "Type": "NodeText",+ "Data": " to copy a block reference to that tab. Clicking the reference switches to the target tab and reveals each enclosing tab when nested. On mobile, you can also create a tabs block from the editor insert menu."}]},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.syindex 7e719dc92e..7a19ebdac3 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": "20260906084311"+ "updated": "20260906133808"},"Children": [{@@ -1369,7 +1369,7 @@"HeadingLevel": 2,"Properties": {"id": "20210104090624-9qgquxh",- "updated": "20260906084311"+ "updated": "20260906133808"},"Children": [{@@ -2778,7 +2778,7 @@"Type": "NodeHeading","Properties": {"id": "20260905124213-9etkynq",- "updated": "20260906084311"+ "updated": "20260906133808"},"HeadingLevel": 3,"Children": [@@ -2868,12 +2868,30 @@"Type": "NodeParagraph","Properties": {"id": "20260906003122-812ct16",- "updated": "20260906084311"+ "updated": "20260906133808"},"Children": [{"Type": "NodeText",- "Data": "输入 / 并选择页签块可创建一组页签。通过 + 添加页签,点击页签块的块标,在页签块子菜单中选择顶部页签或左侧页签。双击标题或使用重命名菜单,可以在页签标题处直接编辑文字。标题与提示块一样支持所见即所得编辑,可通过行级工具栏设置加粗、颜色等样式,修改文字时保留已有格式。"+ "Data": "输入 / 并选择页签块可创建一组页签。通过 + 添加页签,点击页签块的块标,在页签块子菜单中选择顶部页签或左侧页签。双击标题或使用重命名菜单,可以在页签标题处直接编辑文字。标题与提示块一样支持所见即所得编辑,可通过行级工具栏设置加粗、颜色等样式,修改文字时保留已有格式。右键点击页签标题,选择 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "复制"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "复制为块引用"+ },+ {+ "Type": "NodeText",+ "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.syindex c06c73b9c9..6403668a3e 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": "20260906084311"+ "updated": "20260906133808"},"Children": [{@@ -1365,7 +1365,7 @@"HeadingLevel": 2,"Properties": {"id": "20211226120227-esm6f20",- "updated": "20260906084311"+ "updated": "20260906133808"},"Children": [{@@ -2696,7 +2696,7 @@"Type": "NodeHeading","Properties": {"id": "20260905124213-371qsy7",- "updated": "20260906084311"+ "updated": "20260906133808"},"HeadingLevel": 3,"Children": [@@ -2786,12 +2786,30 @@"Type": "NodeParagraph","Properties": {"id": "20260906003122-0jlwsyi",- "updated": "20260906084311"+ "updated": "20260906133808"},"Children": [{"Type": "NodeText",- "Data": "輸入 / 並選擇頁籤區塊可建立一組頁籤。透過 + 新增頁籤,點擊頁籤區塊的區塊圖示,在頁籤區塊子選單中選擇頂部頁籤或左側頁籤。按兩下標題或使用重新命名選單,即可在頁籤標題處直接編輯文字。標題與提示區塊一樣支援所見即所得編輯,可透過行級工具列設定粗體、顏色等樣式,修改文字時保留既有格式。"+ "Data": "輸入 / 並選擇頁籤區塊可建立一組頁籤。透過 + 新增頁籤,點擊頁籤區塊的區塊圖示,在頁籤區塊子選單中選擇頂部頁籤或左側頁籤。按兩下標題或使用重新命名選單,即可在頁籤標題處直接編輯文字。標題與提示區塊一樣支援所見即所得編輯,可透過行級工具列設定粗體、顏色等樣式,修改文字時保留既有格式。在頁籤標題上按右鍵,選擇 "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "複製"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "複製為區塊引用"+ },+ {+ "Type": "NodeText",+ "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.syindex a3bf294f2a..a3da613046 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": "20260906084311"+ "updated": "20260906133808"},"Children": [{@@ -1422,7 +1422,7 @@"Properties": {"ID": "20240530101000-rjjxxn8","id": "20240530101000-p035stn",- "updated": "20260906084311"+ "updated": "20260906133808"},"Children": [{@@ -2890,7 +2890,7 @@"Type": "NodeHeading","Properties": {"id": "20260905124213-rmj1ui2",- "updated": "20260906084311"+ "updated": "20260906133808"},"HeadingLevel": 3,"Children": [@@ -2980,12 +2980,30 @@"Type": "NodeParagraph","Properties": {"id": "20260906003122-om7wyo8",- "updated": "20260906084311"+ "updated": "20260906133808"},"Children": [{"Type": "NodeText",- "Data": "/ を入力してタブブロックを選択すると、タブのグループを作成できます。+ でタブを追加し、タブブロックのアイコンメニューを開き、タブブロックのサブメニューから上部タブまたは左側タブを選択します。タイトルをダブルクリックするか名前変更メニューを使うと、タブのタイトルをその場で直接編集できます。コールアウトのタイトルと同様に、見たままの状態で編集でき、インラインツールバーから太字や文字色などを設定できます。文字を変更しても既存の書式は保持されます。"+ "Data": "/ を入力してタブブロックを選択すると、タブのグループを作成できます。+ でタブを追加し、タブブロックのアイコンメニューを開き、タブブロックのサブメニューから上部タブまたは左側タブを選択します。タイトルをダブルクリックするか名前変更メニューを使うと、タブのタイトルをその場で直接編集できます。コールアウトのタイトルと同様に、見たままの状態で編集でき、インラインツールバーから太字や文字色などを設定できます。文字を変更しても既存の書式は保持されます。タイトルを右クリックし、"+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "コピー"+ },+ {+ "Type": "NodeText",+ "Data": " - "+ },+ {+ "Type": "NodeTextMark",+ "TextMarkType": "kbd",+ "TextMarkTextContent": "ブロック参照としてコピー"+ },+ {+ "Type": "NodeText",+ "Data": " を選択すると、そのタブへのブロック参照をコピーできます。参照をクリックすると対象のタブに切り替わり、入れ子の場合は外側のタブから順に表示されます。モバイルでもエディターの挿入メニューからタブブロックを作成できます。"}]},diff --git a/app/src/editor/util.ts b/app/src/editor/util.tsindex d57aa0b72a..79eb0a7748 100644--- a/app/src/editor/util.ts+++ b/app/src/editor/util.ts@@ -37,6 +37,7 @@ import {hideElements} from "../protyle/ui/hideElements";import {isBrowserRenderableImagePath} from "../util/imageURL";import {forEachPluginSubscriber} from "../plugin/EventBusCore";import {getHostCapabilities} from "../util/hostCapabilities";+import {revealTabsForTarget} from "../protyle/render/tabsRender";const isSameCustomTab = (type: string, data: any, options: IOpenFileOptions) => {if (!options.custom || (options.custom.id && options.custom.id !== type)) {@@ -428,6 +429,9 @@ const switchEditor = (editor: Editor, options: IOpenFileOptions, allModels: IModreturn true;}});+ if (nodeElement) {+ revealTabsForTarget(nodeElement);+ }if ((!nodeElement || nodeElement?.clientHeight === 0) && options.id !== options.rootID) {const getDocParam: IObject = {id: options.id,diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.tsindex e6f7f35ee2..268618bb5e 100644--- a/app/src/mobile/util/keyboardToolbar.ts+++ b/app/src/mobile/util/keyboardToolbar.ts@@ -682,6 +682,7 @@ const renderSlashMenu = (protyle: IProtyle, toolbarElement: Element) => {${getSlashItem("1. " + Lute.Caret, "iconOrderedList", window.siyuan.languages["ordered-list"], "true")}${getSlashItem("- [ ] " + Lute.Caret, "iconCheck", window.siyuan.languages.check, "true")}${getSlashItem("> " + Lute.Caret, "iconQuote", window.siyuan.languages.quote, "true")}+ ${getSlashItem(`::: tabs\n@tab\n\n${Lute.Caret}\n\n@tab\n\n:::\n`, "iconTabs", window.siyuan.languages.tabs, "true")}${getSlashItem(`> [!NOTE]\n> ${Lute.Caret}`, '<span class="keyboard__slash-icon">✏️</span>', `${window.siyuan.languages.callout} - <span style="color: var(--b3-callout-note)">Note</span>`, "true")}${getSlashItem(`> [!TIP]\n> ${Lute.Caret}`, '<span class="keyboard__slash-icon">💡</span>', `${window.siyuan.languages.callout} - <span style="color: var(--b3-callout-tip)">Tip</span>`, "true")}${getSlashItem(`> [!IMPORTANT]\n> ${Lute.Caret}`, '<span class="keyboard__slash-icon">❗</span>', `${window.siyuan.languages.callout} - <span style="color: var(--b3-callout-important)">Important</span>`, "true")}diff --git a/app/src/protyle/render/tabsRender.ts b/app/src/protyle/render/tabsRender.tsindex 4d29dd3229..4274a34a10 100644--- a/app/src/protyle/render/tabsRender.ts+++ b/app/src/protyle/render/tabsRender.ts@@ -116,6 +116,10 @@ export const tabsRender = (element: Element, options: ITabsRenderOptions = {}) =const controller: ITabsRoot = {options,select(tabs, id, persist) {+ // 文档刚插入时观察器尚未渲染,先初始化状态以支持立即跳转到隐藏页签。+ if (!states.has(tabs)) {+ controller.render();+ }const state = states.get(tabs);if (!state || !getTabItems(tabs).some(item => itemID(item) === id)) {return;diff --git a/app/src/protyle/wysiwyg/getBlock.ts b/app/src/protyle/wysiwyg/getBlock.tsindex ef264d4faf..90d4959ae7 100644--- a/app/src/protyle/wysiwyg/getBlock.ts+++ b/app/src/protyle/wysiwyg/getBlock.ts@@ -200,6 +200,9 @@ export const getContenteditableElement = (element: Element, target?: Node): Elemif (element.classList.contains("protyle-title__input")) {return element;}+ if (element.classList.contains("tab-item")) {+ return getContenteditableElement(element.querySelector(":scope > .tab-item-content > [data-node-id]"));+ }let blockElement = element;if (!blockElement.getAttribute("data-node-id")) {blockElement = element.querySelector("[data-node-id]");diff --git a/app/src/protyle/wysiwyg/tabs.ts b/app/src/protyle/wysiwyg/tabs.tsindex 94dfb822cc..b26e656b88 100644--- a/app/src/protyle/wysiwyg/tabs.ts+++ b/app/src/protyle/wysiwyg/tabs.ts@@ -11,6 +11,7 @@ import {avRender} from "../render/av/render";import {isHiddenTabContent} from "../render/tabsVisibility";import {queueTransaction} from "../util/transactionQueue";import {remapTabsDOMIDs} from "../util/tabsCopy";+import {copyTextByType} from "../toolbar/util";const canEdit = (protyle: IProtyle, element: Element) => !protyle.disabled &&!protyle.options.action.includes(Constants.CB_GET_HISTORY) && !element.closest(".protyle-wysiwyg__embed");@@ -116,12 +117,17 @@ export const setTabsPosition = (protyle: IProtyle, tabs: HTMLElement, position:};export const openTabsMenu = (protyle: IProtyle, tabs: HTMLElement, item: HTMLElement, anchor: HTMLElement) => {- if (!canEdit(protyle, tabs)) {+ if (!item) {return;}const lang = window.siyuan.languages;const menu = new Menu();- if (item) {+ menu.addItem({icon: "iconCopy", label: lang.copy, submenu: [{+ icon: "iconRef",+ label: lang.copyBlockRef,+ click: () => {copyTextByType([item.dataset.nodeId], "ref");},+ }]});+ if (canEdit(protyle, tabs)) {menu.addItem({icon: "iconEdit", label: lang.rename, click: () => renameTab(protyle, item)});menu.addItem({icon: "iconCopy", label: lang.duplicateCopy, click: () => {const copy = item.cloneNode(true) as HTMLElement;diff --git a/app/src/util/highlightById.ts b/app/src/util/highlightById.tsindex 9c2d46be7c..a895c7de6e 100644--- a/app/src/util/highlightById.ts+++ b/app/src/util/highlightById.ts@@ -17,6 +17,7 @@ export const highlightById = (protyle: IProtyle, id: string, position: ScrollLog// 预览定位nodeElement = document.getElementById(id);if (nodeElement) {+ revealTabsForTarget(nodeElement, false);protyle.preview.element.scrollTop = nodeElement.offsetTop;bgFade(nodeElement);}