mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-21 19:41:05 +08:00
This commit is contained in:
parent
1a2eea3d20
commit
414f57a7e1
@ -8,6 +8,7 @@ import {getAssetName, getDisplayName, pathPosix, setNotebookName} from "../util/
|
|||||||
import {fetchPost} from "../util/fetch";
|
import {fetchPost} from "../util/fetch";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
import {showTooltip} from "../dialog/tooltip";
|
import {showTooltip} from "../dialog/tooltip";
|
||||||
|
import {getAllEditor, getAllModels} from "../layout/getAll";
|
||||||
|
|
||||||
export const validateName = (name: string, targetElement?: HTMLElement) => {
|
export const validateName = (name: string, targetElement?: HTMLElement) => {
|
||||||
if (/\r\n|\r|\n|\u2028|\u2029|\t|\//.test(name)) {
|
if (/\r\n|\r|\n|\u2028|\u2029|\t|\//.test(name)) {
|
||||||
@ -132,7 +133,17 @@ export const renameAsset = (assetPath: string) => {
|
|||||||
dialog.destroy();
|
dialog.destroy();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
fetchPost("/api/asset/renameAsset", {oldPath: assetPath, newName: inputElement.value});
|
|
||||||
|
fetchPost("/api/asset/renameAsset", {oldPath: assetPath, newName: inputElement.value}, (response) => {
|
||||||
|
getAllModels().asset.forEach(item => {
|
||||||
|
if (item.path === assetPath) {
|
||||||
|
item.parent.updateTitle(getDisplayName(response.data.newPath));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
getAllEditor().forEach(item => {
|
||||||
|
item.reload(false);
|
||||||
|
})
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user