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/18168
Vanessa6d79e7bedaef
diff --git a/app/src/protyle/wysiwyg/getBlock.ts b/app/src/protyle/wysiwyg/getBlock.tsindex b2b2ee0290..4ba37f3236 100644--- a/app/src/protyle/wysiwyg/getBlock.ts+++ b/app/src/protyle/wysiwyg/getBlock.ts@@ -44,6 +44,14 @@ export const getPreviousBlockSibling = (element: Element): Element => {return previous;};+export const getNextBlockSibling = (element: Element): Element => {+ let next = element.nextElementSibling;+ while (next && !next.getAttribute("data-node-id")) {+ next = next.nextElementSibling;+ }+ return next;+};+export const getLastBlock = (element: Element) => {let lastElement;Array.from(element.querySelectorAll("[data-node-id]")).reverse().find(item => {diff --git a/app/src/protyle/wysiwyg/move.ts b/app/src/protyle/wysiwyg/move.tsindex 50ebc65933..76a84eba15 100644--- a/app/src/protyle/wysiwyg/move.ts+++ b/app/src/protyle/wysiwyg/move.ts@@ -1,10 +1,11 @@-import {getTopAloneElement} from "./getBlock";+import {getNextBlockSibling, getPreviousBlockSibling, getTopAloneElement} from "./getBlock";import {hasClosestByAttribute} from "../util/hasClosest";import {updateListOrder} from "./list";import {transaction, updateTransaction} from "./transaction";import {preventScroll} from "../scroll/preventScroll";import {scrollCenter} from "../../util/highlightById";import {focusByWbr} from "../util/selection";+import {refreshSbResize} from "../../block/util";export const moveToUp = (protyle: IProtyle, nodeElement: HTMLElement, range: Range) => {let previousElement: Element;@@ -88,10 +89,10 @@ export const moveToUp = (protyle: IProtyle, nodeElement: HTMLElement, range: RanscrollCenter(protyle);return;}- if (!sourceElements[0].previousElementSibling || sourceElements[0].previousElementSibling?.classList.contains("protyle-action")) {+ previousElement = getPreviousBlockSibling(sourceElements[0]);+ if (!previousElement) {return;}- previousElement = sourceElements[0].previousElementSibling;if (sourceElements[0].getAttribute("data-subtype") === "o" && type === "NodeListItem") {const html = sourceElements[0].parentElement.outerHTML;const orderIndex = parseInt(sourceElements[0].parentElement.firstElementChild.getAttribute("data-marker"));@@ -107,10 +108,11 @@ export const moveToUp = (protyle: IProtyle, nodeElement: HTMLElement, range: Ran}], [{action: "move",id,- previousID: previousElement.previousElementSibling?.getAttribute("data-node-id"),+ previousID: getPreviousBlockSibling(previousElement)?.getAttribute("data-node-id"),parentID: previousElement.parentElement.getAttribute("data-node-id") || protyle.block.parentID}]);sourceElements[sourceElements.length - 1].after(previousElement);+ refreshSbResize(sourceElements[0].parentElement);}preventScroll(protyle);scrollCenter(protyle);@@ -191,10 +193,10 @@ export const moveToDown = (protyle: IProtyle, nodeElement: HTMLElement, range: RscrollCenter(protyle);return;}- if (!sourceElements[sourceElements.length - 1].nextElementSibling || sourceElements[sourceElements.length - 1].nextElementSibling?.classList.contains("protyle-attr")) {+ nextElement = getNextBlockSibling(sourceElements[sourceElements.length - 1]);+ if (!nextElement) {return;}- nextElement = sourceElements[sourceElements.length - 1].nextElementSibling;if (nextElement.getAttribute("data-subtype") === "o" && nextElement.getAttribute("data-type") === "NodeListItem") {const html = nextElement.parentElement.outerHTML;const orderIndex = parseInt(sourceElements[0].parentElement.firstElementChild.getAttribute("data-marker"));@@ -206,7 +208,7 @@ export const moveToDown = (protyle: IProtyle, nodeElement: HTMLElement, range: Rtransaction(protyle, [{action: "move",id,- previousID: sourceElements[0].previousElementSibling?.getAttribute("data-node-id"),+ previousID: getPreviousBlockSibling(sourceElements[0])?.getAttribute("data-node-id"),parentID: nextElement.parentElement.getAttribute("data-node-id") || protyle.block.parentID}], [{action: "move",@@ -214,6 +216,7 @@ export const moveToDown = (protyle: IProtyle, nodeElement: HTMLElement, range: RpreviousID: sourceElements[sourceElements.length - 1].getAttribute("data-node-id"),}]);sourceElements[0].before(nextElement);+ refreshSbResize(sourceElements[0].parentElement);}preventScroll(protyle);scrollCenter(protyle);