An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/3454
Vanessa07cc197aab9a
diff --git a/app/src/editor/rename.ts b/app/src/editor/rename.tsindex d0b4cf9e36..3296de93ff 100644--- a/app/src/editor/rename.ts+++ b/app/src/editor/rename.ts@@ -85,6 +85,40 @@ export const rename = (options: {});};+export const renameAsset = (assetPath: string) => {+ const dialog = new Dialog({+ title: window.siyuan.languages.rename,+ content: `<div class="b3-dialog__content"><input class="b3-text-field fn__block" value=""></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>`,+ width: isMobile() ? "80vw" : "520px",+ });+ const inputElement = dialog.element.querySelector("input") as HTMLInputElement;+ const btnsElement = dialog.element.querySelectorAll(".b3-button");+ dialog.bindInput(inputElement, () => {+ (btnsElement[1] as HTMLButtonElement).click();+ });+ const oldName = assetPath.substring(7, assetPath.length - pathPosix().extname(assetPath).length - 23);+ inputElement.value = oldName;+ inputElement.focus();+ inputElement.select();+ btnsElement[0].addEventListener("click", () => {+ dialog.destroy();+ });+ btnsElement[1].addEventListener("click", () => {+ if (!validateName(inputElement.value)) {+ return false;+ }+ if (inputElement.value === oldName || !inputElement.value) {+ dialog.destroy();+ return false;+ }+ fetchPost("/api/asset/renameAsset", {oldPath: assetPath, newName: inputElement.value});+ });+};+export const newFileContentBySelect = (protyle: IProtyle) => {if (getSelection().rangeCount === 0) {return;diff --git a/app/src/menus/protyle.ts b/app/src/menus/protyle.tsindex 5f1cedf098..b7adb2b180 100644--- a/app/src/menus/protyle.ts+++ b/app/src/menus/protyle.ts@@ -34,6 +34,7 @@ import {removeFoldHeading} from "../protyle/util/heading";import {lineNumberRender} from "../protyle/markdown/highlightRender";import * as dayjs from "dayjs";import {blockRender} from "../protyle/markdown/blockRender";+import {renameAsset} from "../editor/rename";export const refMenu = (protyle: IProtyle, element: HTMLElement) => {const nodeElement = hasClosestBlock(element);@@ -509,6 +510,15 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme}}).element);window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);+ const imagePath = imgElement.getAttribute("data-src")+ if (imagePath.startsWith("assets/")) {+ window.siyuan.menus.menu.append(new MenuItem({+ label: window.siyuan.languages.rename,+ click() {+ renameAsset(imagePath);+ }+ }).element);+ }window.siyuan.menus.menu.append(new MenuItem({icon: "iconAlignCenter",label: window.siyuan.languages.alignCenter,