diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json
index a777bb83a..f5aea941e 100644
--- a/app/appearance/langs/zh_CN.json
+++ b/app/appearance/langs/zh_CN.json
@@ -1,4 +1,5 @@
{
+ "htmlTip": "形成多个 HTML 块,为防止数据丢失请使用 <div> 标签包裹",
"katexMacros": "KaTex 宏定义",
"katexMacrosTip": "请使用 JSON 对象格式({})来包裹宏定义,例如 { \"\\\\foo\": \"{x^2}\" }",
"systemLogTip": "系统日志中保存了程序运行记录,通过导出系统日志发送给开发者可以更好地帮助开发者诊断程序问题",
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 5484ea250..e250b7eb7 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 块中包含多个
时只能保存第一个 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();