Skip to content

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

:meno: fix https://github.com/siyuan-note/siyuan/issues/5732

Vanessaf266eaa3e869
diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json
index a777bb83ad..f5aea941e3 100644
--- a/app/appearance/langs/zh_CN.json
+++ b/app/appearance/langs/zh_CN.json
@@ -1,4 +1,5 @@
{
+ "htmlTip": "形成多个 HTML 块,为防止数据丢失请使用 <code class='fn__code'>&lt;div&gt;</code> 标签包裹",
"katexMacros": "KaTex 宏定义",
"katexMacrosTip": "请使用 JSON 对象格式(<code class='fn__code'>{}</code>)来包裹宏定义,例如 <code class='fn__code'>{ \"\\\\foo\": \"{x^2}\" }</code>",
"systemLogTip": "系统日志中保存了程序运行记录,通过导出系统日志发送给开发者可以更好地帮助开发者诊断程序问题",
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 5484ea250d..e250b7eb71 100644
--- a/app/src/protyle/toolbar/index.ts
+++ b/app/src/protyle/toolbar/index.ts
@@ -41,6 +41,7 @@ import {linkMenu} from "../../menus/protyle";
import {renderAssetsPreview} from "../../asset/renderAssets";
import {electronUndo} from "../undo";
import {previewTemplate} from "./util";
+import {showMessage} from "../../dialog/message";
export class Toolbar {
public element: HTMLElement;
@@ -843,8 +844,8 @@ export class Toolbar {
if (!renderElement.parentElement) {
return;
}
+ const target = event.target as HTMLTextAreaElement;
if (!this.subElement.querySelector('[data-type="refresh"]').classList.contains("block__icon--active")) {
- const target = event.target as HTMLTextAreaElement;
if (type === "NodeHTMLBlock") {
renderElement.querySelector("protyle-html").setAttribute("data-content", Lute.EscapeHTMLStr(target.value));
} else {
@@ -867,6 +868,14 @@ export class Toolbar {
}
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
const newHTML = protyle.lute.SpinBlockDOM(nodeElement.outerHTML);
+ // HTML 块中包含多个 <pre> 时只能保存第一个 https://github.com/siyuan-note/siyuan/issues/5732
+ if (type === "NodeHTMLBlock") {
+ const tempElement = document.createElement("template");
+ tempElement.innerHTML = newHTML;
+ if (tempElement.content.childElementCount > 1) {
+ showMessage(window.siyuan.languages.htmlTip)
+ }
+ }
updateTransaction(protyle, id, newHTML, html);
html = newHTML;
event.stopPropagation();