Forráskód Böngészése

:art: https://github.com/siyuan-note/siyuan/issues/12360

Vanessa 11 hónapja
szülő
commit
fe7b942225

+ 1 - 0
app/appearance/langs/en_US.json

@@ -588,6 +588,7 @@
   "mergeCell": "Merge Cell",
   "cancelMerged": "Cancel cell merge",
   "useDefaultWidth": "Use Default Column Width",
+  "useDefaultAlign": "Use default alignment",
   "type": "Type",
   "replaceType": "Replace type",
   "searchType": "Search type",

+ 1 - 0
app/appearance/langs/es_ES.json

@@ -588,6 +588,7 @@
   "mergeCell": "Merge Cell",
   "cancelMerged": "Cancelar fusión de celda",
   "useDefaultWidth": "Usar el ancho de columna por defecto",
+  "useDefaultAlign": "Usar alineación predeterminada",
   "type": "Tipo",
   "replaceType": "Reemplazar tipo",
   "searchType": "Tipo de búsqueda",

+ 1 - 0
app/appearance/langs/fr_FR.json

@@ -588,6 +588,7 @@
   "mergeCell": "Fusionner la cellule",
   "cancelMerged": "Annuler la fusion de cellules",
   "useDefaultWidth": "Utiliser la largeur de colonne par défaut",
+  "useDefaultAlign": "Utiliser l'alignement par défaut",
   "type": "Type",
   "replaceType": "Remplacer le type",
   "searchType": "Type de recherche",

+ 1 - 0
app/appearance/langs/ja_JP.json

@@ -588,6 +588,7 @@
   "mergeCell": "セルの結合",
   "cancelMerged": "セルの結合を解除",
   "useDefaultWidth": "デフォルトの列幅を使用",
+  "useDefaultAlign": "デフォルトの配置を使用する",
   "type": "種類",
   "replaceType": "種類の置換",
   "searchType": "検索フィルタ",

+ 1 - 0
app/appearance/langs/zh_CHT.json

@@ -588,6 +588,7 @@
   "mergeCell": "合併單元格",
   "cancelMerged": "拆分單元格",
   "useDefaultWidth": "使用預設列寬",
+  "useDefaultAlign": "使用預設對齊",
   "type": "類型",
   "replaceType": "替換類型",
   "searchType": "搜尋類型",

+ 1 - 0
app/appearance/langs/zh_CN.json

@@ -588,6 +588,7 @@
   "mergeCell": "合并单元格",
   "cancelMerged": "拆分单元格",
   "useDefaultWidth": "使用默认列宽",
+  "useDefaultAlign": "使用默认对齐",
   "type": "类型",
   "replaceType": "替换类型",
   "searchType": "搜索类型",

+ 7 - 0
app/src/menus/protyle.ts

@@ -1880,6 +1880,13 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
             setTableAlign(protyle, [cellElement], nodeElement, "right", range);
         }
     });
+    otherMenus.push({
+        icon: "",
+        label: window.siyuan.languages.useDefaultAlign,
+        click: () => {
+            setTableAlign(protyle, [cellElement], nodeElement, "", range);
+        }
+    });
     const menus: IMenu[] = [];
     menus.push(...otherMenus);
     menus.push({

+ 20 - 0
app/src/protyle/wysiwyg/index.ts

@@ -1201,6 +1201,26 @@ export class WYSIWYG {
                                 }
                             }
                         }).element);
+                        window.siyuan.menus.menu.append(new MenuItem({
+                            icon: "",
+                            label: window.siyuan.languages.useDefaultAlign,
+                            click: () => {
+                                if (tableBlockElement) {
+                                    const selectCellElements: HTMLTableCellElement[] = [];
+                                    const scrollLeft = tableBlockElement.firstElementChild.scrollLeft;
+                                    tableBlockElement.querySelectorAll("th, td").forEach((item: HTMLTableCellElement) => {
+                                        if (!item.classList.contains("fn__none") &&
+                                            item.offsetLeft + 6 > tableSelectElement.offsetLeft + scrollLeft && item.offsetLeft + item.clientWidth - 6 < tableSelectElement.offsetLeft + scrollLeft + tableSelectElement.clientWidth &&
+                                            item.offsetTop + 6 > tableSelectElement.offsetTop && item.offsetTop + item.clientHeight - 6 < tableSelectElement.offsetTop + tableSelectElement.clientHeight &&
+                                            (selectCellElements.length === 0 || (selectCellElements.length > 0 && item.offsetTop === selectCellElements[0].offsetTop))) {
+                                            selectCellElements.push(item);
+                                        }
+                                    });
+                                    tableSelectElement.removeAttribute("style");
+                                    setTableAlign(protyle, selectCellElements, tableBlockElement, "", getEditorRange(tableBlockElement));
+                                }
+                            }
+                        }).element);
                         window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
                         window.siyuan.menus.menu.append(new MenuItem({
                             label: window.siyuan.languages.clear,