Vanessa 2025-09-26 21:59:31 +08:00
parent 7112605f0d
commit 935e5b6d33

View file

@ -1626,40 +1626,62 @@ export class Gutter {
} }
}, { }, {
id: "headingEmbedMode", id: "headingEmbedMode",
label: `<div class="fn__flex" style="margin-bottom: 4px"> label: window.siyuan.languages.headingEmbedMode,
<span>${window.siyuan.languages.headingEmbedMode}</span> type: "submenu",
<span class="fn__space fn__flex-1"></span> submenu: [{
<select class="b3-select fn__flex-center" style="margin-left: 8px;"> label: window.siyuan.languages.showHeadingWithBlocks,
<option value="0"${nodeElement.getAttribute("custom-heading-mode") === "0" ? " selected" : ""}>${window.siyuan.languages.showHeadingWithBlocks}</option> iconHTML: "",
<option value="1"${nodeElement.getAttribute("custom-heading-mode") === "1" ? " selected" : ""}>${window.siyuan.languages.showHeadingOnlyTitle}</option> checked: nodeElement.getAttribute("custom-heading-mode") === "0",
<option value="2"${nodeElement.getAttribute("custom-heading-mode") === "2" ? " selected" : ""}>${window.siyuan.languages.showHeadingOnlyBlocks}</option> click() {
<option value=""${!nodeElement.getAttribute("custom-heading-mode") ? " selected" : ""}>${window.siyuan.languages.default}</option> nodeElement.setAttribute("custom-heading-mode", "0");
</select> fetchPost("/api/attr/setBlockAttrs", {
</div>`, id,
bind(element) { attrs: {"custom-heading-mode": "0"}
element.addEventListener("change", () => { });
const selectElement = element.querySelector("select") as HTMLSelectElement; nodeElement.removeAttribute("data-render");
const value = selectElement.value; blockRender(protyle, nodeElement);
if (value === "") { }
// 默认设置,清空 custom-heading-mode 属性 }, {
nodeElement.removeAttribute("custom-heading-mode"); label: window.siyuan.languages.showHeadingOnlyTitle,
iconHTML: "",
checked: nodeElement.getAttribute("custom-heading-mode") === "1",
click() {
nodeElement.setAttribute("custom-heading-mode", "1");
fetchPost("/api/attr/setBlockAttrs", {
id,
attrs: {"custom-heading-mode": "1"}
});
nodeElement.removeAttribute("data-render");
blockRender(protyle, nodeElement);
}
}, {
label: window.siyuan.languages.showHeadingWithBlocks,
iconHTML: "",
checked: nodeElement.getAttribute("custom-heading-mode") === "2",
click() {
nodeElement.setAttribute("custom-heading-mode", "2");
fetchPost("/api/attr/setBlockAttrs", {
id,
attrs: {"custom-heading-mode": "2"}
});
nodeElement.removeAttribute("data-render");
blockRender(protyle, nodeElement);
}
}, {
label: window.siyuan.languages.default,
iconHTML: "",
checked: !nodeElement.getAttribute("custom-heading-mode"),
click() {
nodeElement.setAttribute("custom-heading-mode", "0");
fetchPost("/api/attr/setBlockAttrs", { fetchPost("/api/attr/setBlockAttrs", {
id, id,
attrs: {"custom-heading-mode": ""} attrs: {"custom-heading-mode": ""}
}); });
} else {
nodeElement.setAttribute("custom-heading-mode", value);
fetchPost("/api/attr/setBlockAttrs", {
id,
attrs: {"custom-heading-mode": value}
});
}
nodeElement.removeAttribute("data-render"); nodeElement.removeAttribute("data-render");
blockRender(protyle, nodeElement); blockRender(protyle, nodeElement);
window.siyuan.menus.menu.remove();
});
} }
}] }]
}]
}).element); }).element);
} else if (type === "NodeHeading" && !protyle.disabled) { } else if (type === "NodeHeading" && !protyle.disabled) {
window.siyuan.menus.menu.append(new MenuItem({id: "separator_1", type: "separator"}).element); window.siyuan.menus.menu.append(new MenuItem({id: "separator_1", type: "separator"}).element);