An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: The alignment settings in the table block icon apply to all columns https://github.com/siyuan-note/siyuan/issues/18080
Danielf941b07945fa
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.tsindex 715c9470d1..b38497f51c 100644--- a/app/src/menus/protyle.ts+++ b/app/src/menus/protyle.ts@@ -2147,7 +2147,8 @@ export const videoMenu = (protyle: IProtyle, nodeElement: Element, type: string)return subMenus;};-export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement: HTMLTableCellElement, range: Range) => {+export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement: HTMLTableCellElement,+ range: Range, wholeTable = false) => {const otherMenus: IMenu[] = [];const colIndex = getColIndex(cellElement);if (cellElement.rowSpan > 1 || cellElement.colSpan > 1) {@@ -2245,6 +2246,19 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:updateTableTitle(protyle, nodeElement);}});+ // 对齐作用范围:单元格右键菜单/快捷键只作用于当前列;块标菜单作用于整表+ let alignCells: HTMLElement[] = [cellElement];+ if (wholeTable) {+ // 整表对齐:取首行所有可见单元格作为列定位基准,跳过被合并隐藏的单元格+ const tableElementForAlign = nodeElement.querySelector("table");+ alignCells = [];+ for (let i = 0; i < tableElementForAlign.rows[0].cells.length; i++) {+ const c = tableElementForAlign.rows[0].cells[i] as HTMLElement;+ if (!c.classList.contains("fn__none")) {+ alignCells.push(c);+ }+ }+ }otherMenus.push({id: "separator_1", type: "separator"});otherMenus.push({id: "alignLeft",@@ -2252,7 +2266,7 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:accelerator: window.siyuan.config.keymap.editor.general.alignLeft.custom,label: window.siyuan.languages.alignLeft,click: () => {- setTableAlign(protyle, [cellElement], nodeElement, "left", range);+ setTableAlign(protyle, alignCells, nodeElement, "left", range);}});otherMenus.push({@@ -2261,7 +2275,7 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:label: window.siyuan.languages.alignCenter,accelerator: window.siyuan.config.keymap.editor.general.alignCenter.custom,click: () => {- setTableAlign(protyle, [cellElement], nodeElement, "center", range);+ setTableAlign(protyle, alignCells, nodeElement, "center", range);}});otherMenus.push({@@ -2270,7 +2284,7 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:label: window.siyuan.languages.alignRight,accelerator: window.siyuan.config.keymap.editor.general.alignRight.custom,click: () => {- setTableAlign(protyle, [cellElement], nodeElement, "right", range);+ setTableAlign(protyle, alignCells, nodeElement, "right", range);}});otherMenus.push({@@ -2278,7 +2292,7 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:icon: "",label: window.siyuan.languages.useDefaultAlign,click: () => {- setTableAlign(protyle, [cellElement], nodeElement, "", range);+ setTableAlign(protyle, alignCells, nodeElement, "", range);}});const menus: IMenu[] = [];diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 1f8b0c64e2..afed5a618a 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -1849,7 +1849,7 @@ export class Gutter {type: "submenu",icon: "iconTable",label: window.siyuan.languages.table,- submenu: tableMenu(protyle, nodeElement, cellElement as HTMLTableCellElement, range).menus as IMenu[]+ submenu: tableMenu(protyle, nodeElement, cellElement as HTMLTableCellElement, range, true).menus as IMenu[]}).element);}} else if (type === "NodeAttributeView") {