mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-21 22:44:06 +01:00
This commit is contained in:
parent
588abd5001
commit
70b23c351f
2 changed files with 8 additions and 5 deletions
|
|
@ -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 = `<caption${location === "bottom" ? "caption-side: bottom;" : ""}>${Lute.EscapeHTMLStr(title)}</caption>`;
|
||||
const html = `<caption contenteditable="false" ${location === "bottom" ? "caption-side: bottom;" : ""}>${Lute.EscapeHTMLStr(title)}</caption>`;
|
||||
if (captionElement) {
|
||||
captionElement.outerHTML = html;
|
||||
} else {
|
||||
|
|
@ -2400,8 +2400,8 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
|
|||
${window.siyuan.languages.insertRowBefore.replace("${x}", `<span class="fn__space"></span><input style="width:64px" type="number" step="1" min="1" value="1" placeholder="${window.siyuan.languages.enterKey}" class="b3-text-field"><span class="fn__space"></span>`)}
|
||||
</div>`,
|
||||
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)) {
|
||||
|
|
|
|||
|
|
@ -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", `<thead><tr>${rowHTML}</tr></thead>`);
|
||||
newRowElememt = nodeElement.querySelector("thead tr");
|
||||
if (count > 1) {
|
||||
cellElement.parentElement.parentElement.nextElementSibling.insertAdjacentHTML("afterbegin", `<tr>${rowHTML.replace(/<th/g, "<td").replace(/<\/th>/g, "</td>")}</tr>`.repeat(count - 1));
|
||||
}
|
||||
cellElement.parentElement.parentElement.nextElementSibling.insertAdjacentHTML("afterbegin", cellElement.parentElement.parentElement.innerHTML.replace(/<th/g, "<td").replace(/<\/th>/g, "</td>"));
|
||||
cellElement.parentElement.parentElement.remove();
|
||||
} else {
|
||||
cellElement.parentElement.insertAdjacentHTML("beforebegin", `<tr>${rowHTML}</tr>`);
|
||||
cellElement.parentElement.insertAdjacentHTML("beforebegin", `<tr>${rowHTML}</tr>`.repeat(count));
|
||||
newRowElememt = cellElement.parentElement.previousElementSibling as HTMLTableRowElement;
|
||||
}
|
||||
range.selectNodeContents(newRowElememt.cells[getColIndex(cellElement)]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue