mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-22 08:16:10 +01:00
This commit is contained in:
parent
a13462a52a
commit
7fdd50737c
1 changed files with 3 additions and 45 deletions
|
|
@ -1546,52 +1546,10 @@ export class WYSIWYG {
|
||||||
startContainer = nextSibling;
|
startContainer = nextSibling;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 选中整个标题 https://github.com/siyuan-note/siyuan/issues/4329
|
|
||||||
const headElement = hasClosestByAttribute(startContainer, "data-type", "NodeHeading");
|
const headElement = hasClosestByAttribute(startContainer, "data-type", "NodeHeading");
|
||||||
let isFoldHeading = false;
|
|
||||||
if (headElement && range.toString() === headElement.firstElementChild.textContent) {
|
if (headElement && range.toString() === headElement.firstElementChild.textContent) {
|
||||||
const doOperations: IOperation[] = [{
|
tempElement.insertAdjacentHTML("afterbegin", headElement.firstElementChild.innerHTML);
|
||||||
action: "delete",
|
headElement.firstElementChild.innerHTML = "";
|
||||||
id: headElement.getAttribute("data-node-id")
|
|
||||||
}];
|
|
||||||
const undoOperations: IOperation[] = [{
|
|
||||||
action: "insert",
|
|
||||||
id: headElement.getAttribute("data-node-id"),
|
|
||||||
data: headElement.outerHTML,
|
|
||||||
previousID: headElement.previousElementSibling?.getAttribute("data-node-id"),
|
|
||||||
parentID: headElement.parentElement?.getAttribute("data-node-id") || protyle.block.parentID
|
|
||||||
}];
|
|
||||||
if (headElement.getAttribute("fold") === "1") {
|
|
||||||
isFoldHeading = true;
|
|
||||||
const headCloneElement = headElement.cloneNode(true) as HTMLElement;
|
|
||||||
headCloneElement.removeAttribute("fold");
|
|
||||||
tempElement.append(headCloneElement);
|
|
||||||
undoOperations[0].data = headCloneElement.outerHTML;
|
|
||||||
setFold(protyle, headElement, undefined, true);
|
|
||||||
} else {
|
|
||||||
if ((headElement.parentElement.childElementCount === 3 && headElement.parentElement.classList.contains("li")) ||
|
|
||||||
(headElement.parentElement.childElementCount === 2 && (headElement.parentElement.classList.contains("bq") || headElement.parentElement.classList.contains("sb"))) ||
|
|
||||||
(headElement.parentElement.childElementCount === 1 && headElement.parentElement.classList.contains("protyle-wysiwyg")) // 全选剪切标题
|
|
||||||
) {
|
|
||||||
// https://github.com/siyuan-note/siyuan/issues/4040
|
|
||||||
const emptyId = Lute.NewNodeID();
|
|
||||||
const emptyElement = genEmptyElement(false, false, emptyId);
|
|
||||||
doOperations.push({
|
|
||||||
id: emptyId,
|
|
||||||
data: emptyElement.outerHTML,
|
|
||||||
action: "insert",
|
|
||||||
parentID: headElement.parentElement.getAttribute("data-node-id") || protyle.block.parentID
|
|
||||||
});
|
|
||||||
undoOperations.push({
|
|
||||||
id: emptyId,
|
|
||||||
action: "delete",
|
|
||||||
});
|
|
||||||
headElement.before(emptyElement);
|
|
||||||
}
|
|
||||||
focusSideBlock(headElement);
|
|
||||||
tempElement.append(headElement);
|
|
||||||
}
|
|
||||||
transaction(protyle, doOperations, undoOperations);
|
|
||||||
} else if (range.toString() !== "" && startContainer.isSameNode(range.endContainer) && range.startContainer.nodeType === 3
|
} else if (range.toString() !== "" && startContainer.isSameNode(range.endContainer) && range.startContainer.nodeType === 3
|
||||||
&& range.endOffset === range.endContainer.textContent.length && range.startOffset === 0 &&
|
&& range.endOffset === range.endContainer.textContent.length && range.startOffset === 0 &&
|
||||||
!["DIV", "TD", "TH", "TR"].includes(range.startContainer.parentElement.tagName)) {
|
!["DIV", "TD", "TH", "TR"].includes(range.startContainer.parentElement.tagName)) {
|
||||||
|
|
@ -1678,7 +1636,7 @@ export class WYSIWYG {
|
||||||
nodeElement.querySelector('[data-render="true"]')?.removeAttribute("data-render");
|
nodeElement.querySelector('[data-render="true"]')?.removeAttribute("data-render");
|
||||||
highlightRender(nodeElement);
|
highlightRender(nodeElement);
|
||||||
}
|
}
|
||||||
if (nodeElement.parentElement.parentElement && !isFoldHeading && !nodeElement.classList.contains("av")) {
|
if (nodeElement.parentElement.parentElement && !nodeElement.classList.contains("av")) {
|
||||||
// 选中 heading 时,使用删除的 transaction
|
// 选中 heading 时,使用删除的 transaction
|
||||||
setInsertWbrHTML(nodeElement, range, protyle);
|
setInsertWbrHTML(nodeElement, range, protyle);
|
||||||
updateTransaction(protyle, id, protyle.wysiwyg.lastHTMLs[id] || nodeElement.outerHTML, oldHTML);
|
updateTransaction(protyle, id, protyle.wysiwyg.lastHTMLs[id] || nodeElement.outerHTML, oldHTML);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue