Skip to content

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

:art: Group table alignment options in submenu https://github.com/siyuan-note/siyuan/issues/18537

Daniel43f7f01feea9
diff --git a/app/src/config/entryVisibility/catalog.test.ts b/app/src/config/entryVisibility/catalog.test.ts
index ddc9acd686..3adcd11fdc 100644
--- a/app/src/config/entryVisibility/catalog.test.ts
+++ b/app/src/config/entryVisibility/catalog.test.ts
@@ -55,10 +55,10 @@ test("simple profile follows the reviewed defaults", () => {
"gutter.single.turnInto.code",
"gutter.single.table.tableHeaderRow",
"gutter.single.table.tableHeaderColumn",
- "gutter.single.table.alignTop",
- "gutter.single.table.alignMiddle",
- "gutter.single.table.alignBottom",
- "gutter.single.table.useDefaultVerticalAlign",
+ "gutter.single.table.alignment.alignTop",
+ "gutter.single.table.alignment.alignMiddle",
+ "gutter.single.table.alignment.alignBottom",
+ "gutter.single.table.alignment.useDefaultVerticalAlign",
"inline.text.more.tableHeaderRow",
"inline.text.more.tableHeaderColumn",
"document.more.keepLazyLoad",
diff --git a/app/src/config/entryVisibility/catalog.ts b/app/src/config/entryVisibility/catalog.ts
index 6a083be186..62c673020f 100644
--- a/app/src/config/entryVisibility/catalog.ts
+++ b/app/src/config/entryVisibility/catalog.ts
@@ -225,15 +225,17 @@ const gutterTable = () => node("table", lang("table"), true, [
node("tableHeaderColumn", lang("tableHeaderColumn")),
node("title", lang("title")),
separator("separator_1"),
- node("alignLeft", lang("alignLeft")),
- node("alignCenter", lang("alignCenter")),
- node("alignRight", lang("alignRight")),
- node("useDefaultAlign", lang("useDefaultAlign")),
- separator("separator_verticalAlign"),
- node("alignTop", lang("alignTop")),
- node("alignMiddle", lang("alignMiddle")),
- node("alignBottom", lang("alignBottom")),
- node("useDefaultVerticalAlign", lang("useDefaultVerticalAlign")),
+ node("alignment", lang("alignment"), true, [
+ node("alignLeft", lang("alignLeft")),
+ node("alignCenter", lang("alignCenter")),
+ node("alignRight", lang("alignRight")),
+ node("useDefaultAlign", lang("useDefaultAlign")),
+ separator("separator_verticalAlign"),
+ node("alignTop", lang("alignTop")),
+ node("alignMiddle", lang("alignMiddle")),
+ node("alignBottom", lang("alignBottom")),
+ node("useDefaultVerticalAlign", lang("useDefaultVerticalAlign")),
+ ]),
separator("separator_insert"),
node("insertRowAbove", lang("insertRowAbove")),
node("insertRowBelow", lang("insertRowBelow")),
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index 21721713f8..79332afd76 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -2301,7 +2301,7 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
});
otherMenus.push({id: "separator_1", type: "separator"});
const horizontalCells = alignWholeTable ? Array.from(tableElement.rows[0].cells) : [cellElement];
- otherMenus.push({
+ const alignmentMenus: IMenu[] = [{
id: "alignLeft",
icon: "iconAlignLeft",
accelerator: window.siyuan.config.keymap.editor.general.alignLeft.custom,
@@ -2309,8 +2309,7 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
click: () => {
setTableAlign(protyle, horizontalCells, nodeElement, "left", range, alignWholeTable);
}
- });
- otherMenus.push({
+ }, {
id: "alignCenter",
icon: "iconAlignCenter",
label: window.siyuan.languages.alignCenter,
@@ -2318,8 +2317,7 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
click: () => {
setTableAlign(protyle, horizontalCells, nodeElement, "center", range, alignWholeTable);
}
- });
- otherMenus.push({
+ }, {
id: "alignRight",
icon: "iconAlignRight",
label: window.siyuan.languages.alignRight,
@@ -2327,21 +2325,29 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
click: () => {
setTableAlign(protyle, horizontalCells, nodeElement, "right", range, alignWholeTable);
}
- });
- otherMenus.push({
+ }, {
id: "useDefaultAlign",
icon: "",
label: window.siyuan.languages.useDefaultAlign,
click: () => {
setTableAlign(protyle, horizontalCells, nodeElement, "", range, alignWholeTable);
}
- });
+ }];
if (alignWholeTable) {
- otherMenus.push({id: "separator_verticalAlign", type: "separator"});
+ alignmentMenus.push({id: "separator_verticalAlign", type: "separator"});
const cells = Array.from(tableElement.querySelectorAll<HTMLTableCellElement>("th, td"));
- otherMenus.push(...getTableCellVerticalAlignmentMenus(cells, (property, value) => {
+ alignmentMenus.push(...getTableCellVerticalAlignmentMenus(cells, (property, value) => {
setTableCellStyle(protyle, nodeElement as HTMLElement, cells, property, value);
}));
+ otherMenus.push({
+ id: "alignment",
+ icon: "iconAlignSettings",
+ label: window.siyuan.languages.alignment,
+ type: "submenu",
+ submenu: alignmentMenus,
+ });
+ } else {
+ otherMenus.push(...alignmentMenus);
}
const menus: IMenu[] = [];
menus.push(...otherMenus);