mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-07-03 14:09:06 +02:00
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user