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

Vanessa980e1bd9d5ce
diff --git a/app/src/protyle/render/util.ts b/app/src/protyle/render/util.ts
index 11a7c818e6..407d22e83c 100644
--- a/app/src/protyle/render/util.ts
+++ b/app/src/protyle/render/util.ts
@@ -34,9 +34,8 @@ export const genRenderFrame = (renderElement: Element) => {
};
export const processClonePHElement = (item: Element) => {
- if (item.getAttribute("data-type") === "NodeHTMLBlock") {
- const phElement = item.querySelector("protyle-html");
+ item.querySelectorAll("protyle-html").forEach((phElement) => {
phElement.setAttribute("data-content", Lute.UnEscapeHTMLStr(phElement.getAttribute("data-content")));
- }
+ });
return item;
};
diff --git a/app/src/protyle/util/insertHTML.ts b/app/src/protyle/util/insertHTML.ts
index 2b92d73601..170eeaee0a 100644
--- a/app/src/protyle/util/insertHTML.ts
+++ b/app/src/protyle/util/insertHTML.ts
@@ -20,6 +20,7 @@ import {input} from "../wysiwyg/input";
import {fetchPost} from "../../util/fetch";
import {isIncludeCell} from "./table";
import {getFieldIdByCellElement} from "../render/av/row";
+import {processClonePHElement} from "../render/util";
const processAV = (range: Range, html: string, protyle: IProtyle, blockElement: HTMLElement) => {
const tempElement = document.createElement("template");
@@ -492,6 +493,7 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
});
}
if (!hasParentHeading) {
+ processClonePHElement(item);
if (insertBefore) {
blockElement.before(item);
} else {
diff --git a/app/src/protyle/wysiwyg/getBlock.ts b/app/src/protyle/wysiwyg/getBlock.ts
index df46bfd3dd..5985ccd699 100644
--- a/app/src/protyle/wysiwyg/getBlock.ts
+++ b/app/src/protyle/wysiwyg/getBlock.ts
@@ -78,6 +78,16 @@ export const getContenteditableElement = (element: Element) => {
};
export const isNotEditBlock = (element: Element) => {
+ if (element.classList.contains("sb")) {
+ let hasEditable = false;
+ Array.from(element.querySelectorAll("[data-node-id]")).find(item => {
+ if (!isNotEditBlock(item)) {
+ hasEditable = true;
+ return true;
+ }
+ });
+ return !hasEditable;
+ }
return ["NodeBlockQueryEmbed", "NodeThematicBreak", "NodeMathBlock", "NodeHTMLBlock", "NodeIFrame", "NodeWidget", "NodeVideo", "NodeAudio"].includes(element.getAttribute("data-type")) ||
(element.getAttribute("data-type") === "NodeCodeBlock" && element.classList.contains("render-node"));
};