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

Vanessa82199c373306
diff --git a/app/appearance/langs/zh_CN.json b/app/appearance/langs/zh_CN.json
index a3fea08781..524b6c7b2f 100644
--- a/app/appearance/langs/zh_CN.json
+++ b/app/appearance/langs/zh_CN.json
@@ -1,4 +1,5 @@
{
+ "location": "位置",
"noSplitScreenWhenOpenTab": "打开页签时不分屏",
"noSplitScreenWhenOpenTabTip": "打开搜索、PDF 等页签时不自动分屏",
"useChrome": "仅支持在基于 Chromium 内核的浏览器(比如 Chrome/Edge)中使用,使用其他浏览器会遇到无法解决的兼容性问题",
diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.ts
index 3e5528111e..5be25eae60 100644
--- a/app/src/menus/protyle.ts
+++ b/app/src/menus/protyle.ts
@@ -64,6 +64,7 @@ import {hideTooltip} from "../dialog/tooltip";
import {clearSelect} from "../protyle/util/clear";
import {scrollCenter} from "../util/highlightById";
import {base64ToURL} from "../util/image";
+import {Dialog} from "../dialog";
const renderAssetList = (element: Element, k: string, position: IPosition, exts: string[] = []) => {
fetchPost("/api/search/searchAsset", {
@@ -2214,6 +2215,61 @@ export const tableMenu = (protyle: IProtyle, nodeElement: Element, cellElement:
updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, html);
}
});
+ otherMenus.push({
+ icon: "iconHeadings",
+ label: window.siyuan.languages.title,
+ click: () => {
+ window.siyuan.menus.menu.remove();
+ const dialog = new Dialog({
+ title: window.siyuan.languages.title,
+ width: isMobile() ? "92vw" : "520px",
+ content: `<div class="b3-dialog__content">
+ <input class="b3-text-field fn__block">
+ <div class="fn__hr"></div>
+ <select class="b3-select fn__block">
+ <option value="top">${window.siyuan.languages.up}</option>
+ <option value="bottom">${window.siyuan.languages.down}</option>
+ </select>
+</div>
+<div class="b3-dialog__action">
+ <button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
+ <button class="b3-button b3-button--text">${window.siyuan.languages.confirm}</button>
+</div>
+<div>`,
+ });
+ const html = nodeElement.outerHTML;
+ const inputElement = dialog.element.querySelector(".b3-text-field") as HTMLInputElement;
+ const btnsElement = dialog.element.querySelectorAll(".b3-button");
+ dialog.bindInput(inputElement, () => {
+ (btnsElement[1] as HTMLButtonElement).click();
+ });
+ inputElement.focus();
+ inputElement.value = nodeElement.querySelector("caption")?.innerHTML || "";
+ btnsElement[0].addEventListener("click", () => {
+ dialog.destroy();
+ });
+ btnsElement[1].addEventListener("click", () => {
+ const title = inputElement.value.trim();
+ const location = (dialog.element.querySelector("select") as HTMLSelectElement).value;
+ const captionElement = nodeElement.querySelector("caption");
+ if (title) {
+ const html = `<caption${location === "bottom" ? "caption-side: bottom;" : ""}>${Lute.EscapeHTMLStr(title)}</caption>`;
+ if (captionElement) {
+ captionElement.outerHTML = html;
+ } else {
+ nodeElement.querySelector("table").insertAdjacentHTML("afterbegin", html);
+ }
+ nodeElement.setAttribute("caption", html);
+ } else {
+ if (captionElement) {
+ captionElement.remove();
+ }
+ nodeElement.removeAttribute("caption");
+ }
+ updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, html);
+ });
+ }
+ });
otherMenus.push({id: "separator_1", type: "separator"});
otherMenus.push({
id: "alignLeft",