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/6561

Vanessae05e01bfd7b1
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index 526fe34f9e..9fed677a6d 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -33,7 +33,7 @@ import {lineNumberRender} from "../protyle/markdown/highlightRender";
import * as dayjs from "dayjs";
import {blockRender} from "../protyle/markdown/blockRender";
import {renameAsset} from "../editor/rename";
-import {hasNextSibling} from "../protyle/wysiwyg/getBlock";
+import {hasNextSibling, hasPreviousSibling} from "../protyle/wysiwyg/getBlock";
import {electronUndo} from "../protyle/undo";
import {pushBack} from "../mobile/util/MobileBackFoward";
import {exportAsset} from "./util";
@@ -640,6 +640,17 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
break;
}
}
+ let previous = assetElement.previousSibling;
+ while (previous) {
+ if (previous.textContent === "") {
+ previous = previous.previousSibling;
+ } else if (previous.textContent === Constants.ZWSP) {
+ previous.textContent = "";
+ break;
+ } else {
+ break;
+ }
+ }
updateTransaction(protyle, id, nodeElement.outerHTML, html);
}
}).element);
@@ -653,6 +664,9 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
if (!hasNextSibling(assetElement)) {
assetElement.insertAdjacentText("afterend", Constants.ZWSP);
}
+ if (!hasPreviousSibling(assetElement)) {
+ assetElement.insertAdjacentText("beforebegin", Constants.ZWSP);
+ }
updateTransaction(protyle, id, nodeElement.outerHTML, html);
}
}).element);