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: fix https://github.com/siyuan-note/siyuan/issues/5419
Vanessa24eb93a752c9
diff --git a/app/src/editor/rename.ts b/app/src/editor/rename.tsindex 56ca3a6751..d74d844bfe 100644--- a/app/src/editor/rename.ts+++ b/app/src/editor/rename.ts@@ -6,7 +6,7 @@ import {removeEmbed} from "../protyle/wysiwyg/removeEmbed";import {insertHTML} from "../protyle/util/insertHTML";import {genEmptyBlock} from "../block/util";import {isMobile} from "../util/functions";-import {getDisplayName, pathPosix, setNotebookName} from "../util/pathName";+import {getAssetName, getDisplayName, pathPosix, setNotebookName} from "../util/pathName";import {fetchPost} from "../util/fetch";import {escapeHtml} from "../util/escape";@@ -100,7 +100,7 @@ export const renameAsset = (assetPath: string) => {dialog.bindInput(inputElement, () => {(btnsElement[1] as HTMLButtonElement).click();});- const oldName = assetPath.substring(7, assetPath.length - pathPosix().extname(assetPath).length - 23);+ const oldName = getAssetName(assetPath);inputElement.value = oldName;inputElement.focus();inputElement.select();diff --git a/app/src/protyle/hint/extend.ts b/app/src/protyle/hint/extend.tsindex 26af5ffb4d..34a9e94f7e 100644--- a/app/src/protyle/hint/extend.ts+++ b/app/src/protyle/hint/extend.ts@@ -11,7 +11,7 @@ import {hasClosestBlock, hasClosestByClassName} from "../util/hasClosest";import {getContenteditableElement, getTopAloneElement} from "../wysiwyg/getBlock";import {replaceFileName} from "../../editor/rename";import {transaction} from "../wysiwyg/transaction";-import {getDisplayName} from "../../util/pathName";+import {getAssetName, getDisplayName, pathPosix} from "../../util/pathName";import {genEmptyElement} from "../../block/util";import {updateListOrder} from "../wysiwyg/list";import {escapeHtml} from "../../util/escape";@@ -425,8 +425,8 @@ export const hintRenderWidget = (value: string, protyle: IProtyle) => {export const hintRenderAssets = (value: string, protyle: IProtyle) => {focusByRange(protyle.toolbar.range);- const type = value.substring(value.lastIndexOf("."));- const filename = value.replace("assets/", "");+ const type = pathPosix().extname(value).toLowerCase();+ const filename = value.startsWith("assets/") ? getAssetName(value) : value;let fileMD = "";if (Constants.SIYUAN_ASSETS_AUDIO.includes(type)) {fileMD += `<audio controls="controls" src="${value}"></audio>`;@@ -435,7 +435,7 @@ export const hintRenderAssets = (value: string, protyle: IProtyle) => {} else if (Constants.SIYUAN_ASSETS_VIDEO.includes(type)) {fileMD += `<video controls="controls" src="${value}"></video>`;} else {- fileMD += `[${filename}](${value})`;+ fileMD += `[${value.startsWith("assets/") ? filename + type : value}](${value})`;}insertHTML(protyle.lute.SpinBlockDOM(fileMD), protyle);protyle.toolbar.subElement.classList.add("fn__none");diff --git a/app/src/protyle/upload/index.ts b/app/src/protyle/upload/index.tsindex b6735730c4..53b1175193 100644--- a/app/src/protyle/upload/index.ts+++ b/app/src/protyle/upload/index.ts@@ -4,6 +4,7 @@ import {Constants} from "../../constants";import {destroy} from "../util/destroy";import {fetchPost} from "../../util/fetch";import {getEditorRange} from "../util/selection";+import {pathPosix} from "../../util/pathName";export class Upload {public element: HTMLElement;@@ -99,18 +100,12 @@ const genUploadedLabel = (responseText: string, protyle: IProtyle) => {const keys = Object.keys(response.data.succMap);keys.forEach((key, index) => {const path = response.data.succMap[key];- const lastIndex = key.lastIndexOf(".");- let type = key.substr(lastIndex);- let filename = protyle.options.upload.filename(key.substr(0, lastIndex)) + type;- if (-1 === lastIndex) {- type = "";- filename = protyle.options.upload.filename(key);- }- type = type.toLowerCase();+ const type = pathPosix().extname(key).toLowerCase();+ const filename = protyle.options.upload.filename(key);if (Constants.SIYUAN_ASSETS_AUDIO.includes(type)) {succFileText += `<audio controls="controls" src="${path}"></audio>`;} else if (Constants.SIYUAN_ASSETS_IMAGE.includes(type)) {- succFileText += ``;+ succFileText += ``;} else if (Constants.SIYUAN_ASSETS_VIDEO.includes(type)) {succFileText += `<video controls="controls" src="${path}"></video>`;} else {diff --git a/app/src/util/pathName.ts b/app/src/util/pathName.tsindex f8dc8fccb3..75d1d56589 100644--- a/app/src/util/pathName.ts+++ b/app/src/util/pathName.ts@@ -28,6 +28,10 @@ export const getDisplayName = (filePath: string, basename = true, removeSY = falreturn name;};+export const getAssetName = (assetPath: string) => {+ return assetPath.substring(7, assetPath.length - pathPosix().extname(assetPath).length - 23)+}+export const isLocalPath = (link: string) => {if (!link) {return false;