Vanessa
2026-06-13 10:52:12 +08:00
parent bf4e061be4
commit 84cae31021
3 changed files with 22 additions and 0 deletions
+10
View File
@@ -2190,6 +2190,16 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
const tbodyElement = nodeElement.querySelector("tbody");
const theadElement = nodeElement.querySelector("thead");
while (prueTrElement !== theadElement.lastElementChild) {
theadElement.lastElementChild.querySelectorAll("th").forEach(item => {
const td = document.createElement('td');
Array.from(item.attributes).forEach(attr => {
td.setAttribute(attr.name, attr.value);
});
while (item.firstChild) {
td.appendChild(item.firstChild);
}
item.replaceWith(td);
});
tbodyElement.insertAdjacentElement("afterbegin", theadElement.lastElementChild);
}
}
+6
View File
@@ -254,6 +254,9 @@ export const getSelectionPosition = (nodeElement: Element, range?: Range, useDir
let firstNode = range.startContainer.childNodes[range.startOffset] || range.startContainer.firstChild;
while (firstNode) {
if (firstNode.textContent === "" && firstNode.nodeType === 3) {
if (!firstNode.previousSibling) {
break;
}
firstNode = firstNode.previousSibling;
} else {
break;
@@ -265,6 +268,9 @@ export const getSelectionPosition = (nodeElement: Element, range?: Range, useDir
let lastNode = range.startContainer.childNodes[range.startOffset] || range.startContainer.lastChild;
while (lastNode) {
if (lastNode.textContent === "" && lastNode.nodeType === 3) {
if (!lastNode.previousSibling) {
break;
}
lastNode = lastNode.previousSibling;
} else {
break;
+6
View File
@@ -491,6 +491,9 @@ export const fixTable = (protyle: IProtyle, event: KeyboardEvent, range: Range)
let firstChild = cellElement.firstChild;
while (firstChild) {
if (firstChild.textContent === "" && firstChild.nodeType === 3) {
if (!firstChild.nextSibling) {
break;
}
firstChild = firstChild.nextSibling;
} else {
break;
@@ -525,6 +528,9 @@ export const fixTable = (protyle: IProtyle, event: KeyboardEvent, range: Range)
let lastChild = cellElement.lastChild;
while (lastChild) {
if (lastChild.textContent === "" && lastChild.nodeType === 3) {
if (!lastChild.previousSibling) {
break;
}
lastChild = lastChild.previousSibling;
} else {
break;