diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index 0ec84e72c..7b3233d97 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -2261,7 +2261,7 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
const location = (dialog.element.querySelector("select") as HTMLSelectElement).value;
const captionElement = nodeElement.querySelector("caption");
if (title) {
- const html = `
${Lute.EscapeHTMLStr(title)}`;
+ const html = `${Lute.EscapeHTMLStr(title)}`;
if (captionElement) {
captionElement.outerHTML = html;
} else {
@@ -2400,8 +2400,8 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
${window.siyuan.languages.insertRowBefore.replace("${x}", ``)}
`,
accelerator: window.siyuan.config.keymap.editor.table.insertRowAbove.custom,
- click: () => {
- insertRowAbove(protyle, range, cellElement, nodeElement);
+ click: (element: HTMLElement) => {
+ insertRowAbove(protyle, range, cellElement, nodeElement, parseInt(element.querySelector("input").value));
}
});
if (!nextHasNone || (nextHasNone && !nextHasRowSpan && nextHasColSpan)) {
diff --git a/app/src/protyle/util/table.ts b/app/src/protyle/util/table.ts
index 5349ace36..9dd58bf47 100644
--- a/app/src/protyle/util/table.ts
+++ b/app/src/protyle/util/table.ts
@@ -121,7 +121,7 @@ export const insertRow = (protyle: IProtyle, range: Range, cellElement: HTMLElem
scrollToView(nodeElement, newRowElememt, protyle);
};
-export const insertRowAbove = (protyle: IProtyle, range: Range, cellElement: HTMLElement, nodeElement: Element) => {
+export const insertRowAbove = (protyle: IProtyle, range: Range, cellElement: HTMLElement, nodeElement: Element, count = 1) => {
const wbrElement = document.createElement("wbr");
range.insertNode(wbrElement);
const html = nodeElement.outerHTML;
@@ -160,10 +160,13 @@ export const insertRowAbove = (protyle: IProtyle, range: Range, cellElement: HTM
if (cellElement.parentElement.parentElement.tagName === "THEAD" && !cellElement.parentElement.previousElementSibling) {
cellElement.parentElement.parentElement.insertAdjacentHTML("beforebegin", `${rowHTML}
`);
newRowElememt = nodeElement.querySelector("thead tr");
+ if (count > 1) {
+ cellElement.parentElement.parentElement.nextElementSibling.insertAdjacentHTML("afterbegin", `${rowHTML.replace(/| /g, "")} |
`.repeat(count - 1));
+ }
cellElement.parentElement.parentElement.nextElementSibling.insertAdjacentHTML("afterbegin", cellElement.parentElement.parentElement.innerHTML.replace(//g, ""));
cellElement.parentElement.parentElement.remove();
} else {
- cellElement.parentElement.insertAdjacentHTML("beforebegin", ` | ${rowHTML}
`);
+ cellElement.parentElement.insertAdjacentHTML("beforebegin", `${rowHTML}
`.repeat(count));
newRowElememt = cellElement.parentElement.previousElementSibling as HTMLTableRowElement;
}
range.selectNodeContents(newRowElememt.cells[getColIndex(cellElement)]);