An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/9521
Vanessacf64cd26c830
diff --git a/app/src/protyle/wysiwyg/enter.ts b/app/src/protyle/wysiwyg/enter.tsindex d876fc1ac4..140a5d45f2 100644--- a/app/src/protyle/wysiwyg/enter.ts+++ b/app/src/protyle/wysiwyg/enter.ts@@ -20,7 +20,7 @@ import {processRender} from "../util/processCode";import {hasClosestByAttribute, hasClosestByClassName} from "../util/hasClosest";import {blockRender} from "../render/blockRender";-export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle) => {+export const enter = async (blockElement: HTMLElement, range: Range, protyle: IProtyle) => {if (hasClosestByClassName(blockElement, "protyle-wysiwyg__embed") && !blockElement.classList.contains("code-block")) {return;}@@ -154,24 +154,30 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyletopElement.after(blockElement);topElement.remove();}- transaction(protyle, [{+ parentBlockElement = getParentBlock(blockElement);+ const enterDoOperations: IOperation[] = [{action: "delete",id: topId- }, doInsert], [{+ }, doInsert];+ const enterUndoOperations: IOperation[] = [{action: "delete",id: blockId,- }, undoInsert]);- parentBlockElement = getParentBlock(blockElement);+ }, undoInsert];if (topId === blockId && parentBlockElement.classList.contains("sb") &&parentBlockElement.getAttribute("data-sb-layout") === "col") {- turnsIntoOneTransaction({+ // 合并到同一个 transaction,避免新块 id 在第二个 transaction 中找不到+ const sbOperations = await turnsIntoOneTransaction({protyle,selectsElement: [blockElement.previousElementSibling, blockElement],type: "BlocksMergeSuperBlock",level: "row",unfocus: true,+ getOperations: true,});+ enterDoOperations.push(...sbOperations.doOperations);+ enterUndoOperations.splice(0, 0, ...sbOperations.undoOperations);}+ transaction(protyle, enterDoOperations, enterUndoOperations);focusByWbr(blockElement, range);return true;}@@ -362,17 +368,21 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtylereturn true;}});- transaction(protyle, doOperation, undoOperation);if (parentElement.classList.contains("sb") &&parentElement.getAttribute("data-sb-layout") === "col") {- turnsIntoOneTransaction({+ // 合并到同一个 transaction,避免新块 id 在第二个 transaction 中找不到+ const sbOperations = await turnsIntoOneTransaction({protyle,selectsElement,type: "BlocksMergeSuperBlock",level: "row",unfocus: true,+ getOperations: true,});+ doOperation.push(...sbOperations.doOperations);+ undoOperation.splice(0, 0, ...sbOperations.undoOperations);}+ transaction(protyle, doOperation, undoOperation);focusByWbr(currentElement, range);scrollCenter(protyle);return true;diff --git a/app/src/protyle/wysiwyg/transaction.ts b/app/src/protyle/wysiwyg/transaction.tsindex 1c942bf4c5..53190974f6 100644--- a/app/src/protyle/wysiwyg/transaction.ts+++ b/app/src/protyle/wysiwyg/transaction.ts@@ -1021,6 +1021,15 @@ export const turnsIntoOneTransaction = async (options: {const id = Lute.NewNodeID();if (options.type === "BlocksMergeSuperBlock") {parentElement = genSBElement(options.level, id);+ // 回车生成竖排超级块时,将横向超级块子块的宽度迁移到新超级块,并清除子块宽度+ // https://github.com/siyuan-note/siyuan/issues/9521+ const firstChild = options.selectsElement[0] as HTMLElement;+ if (firstChild.style.width) {+ (parentElement as HTMLElement).style.width = firstChild.style.width;+ (parentElement as HTMLElement).style.flex = firstChild.style.flex;+ firstChild.style.width = "";+ firstChild.style.flex = "";+ }} else if (options.type === "Blocks2Blockquote") {parentElement = document.createElement("div");parentElement.classList.add("bq");