Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/14114

Vanessa7fdd50737c2e
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index b014553e62..831f34634f 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -1546,52 +1546,10 @@ export class WYSIWYG {
startContainer = nextSibling;
}
}
- // 选中整个标题 https://github.com/siyuan-note/siyuan/issues/4329
const headElement = hasClosestByAttribute(startContainer, "data-type", "NodeHeading");
- let isFoldHeading = false;
if (headElement && range.toString() === headElement.firstElementChild.textContent) {
- const doOperations: IOperation[] = [{
- action: "delete",
- 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);
+ tempElement.insertAdjacentHTML("afterbegin", headElement.firstElementChild.innerHTML);
+ headElement.firstElementChild.innerHTML = "";
} else if (range.toString() !== "" && startContainer.isSameNode(range.endContainer) && range.startContainer.nodeType === 3
&& range.endOffset === range.endContainer.textContent.length && range.startOffset === 0 &&
!["DIV", "TD", "TH", "TR"].includes(range.startContainer.parentElement.tagName)) {
@@ -1678,7 +1636,7 @@ export class WYSIWYG {
nodeElement.querySelector('[data-render="true"]')?.removeAttribute("data-render");
highlightRender(nodeElement);
}
- if (nodeElement.parentElement.parentElement && !isFoldHeading && !nodeElement.classList.contains("av")) {
+ if (nodeElement.parentElement.parentElement && !nodeElement.classList.contains("av")) {
// 选中 heading 时,使用删除的 transaction
setInsertWbrHTML(nodeElement, range, protyle);
updateTransaction(protyle, id, protyle.wysiwyg.lastHTMLs[id] || nodeElement.outerHTML, oldHTML);