This commit is contained in:
Vanessa 2022-07-17 11:06:57 +08:00
parent 7ee9691a8c
commit b6b1ddd24d
3 changed files with 8 additions and 8 deletions

View file

@ -2,7 +2,7 @@ import {Constants} from "../constants";
import {pathPosix} from "../util/pathName";
export const renderAssetsPreview = (pathString: string) => {
const type = pathPosix().extname(pathString).toLowerCase()
const type = pathPosix().extname(pathString).toLowerCase();
if (Constants.SIYUAN_ASSETS_IMAGE.includes(type)) {
return `<img style="max-height: 100%" src="${pathString}">`;
} else if (Constants.SIYUAN_ASSETS_AUDIO.includes(type)) {
@ -12,4 +12,4 @@ export const renderAssetsPreview = (pathString: string) => {
} else {
return "";
}
}
};

View file

@ -1171,9 +1171,9 @@ export class Toolbar {
if (!hoverItemElement) {
return;
}
previewElement.innerHTML = renderAssetsPreview(hoverItemElement.getAttribute("data-value"))
})
const previewElement = this.subElement.firstElementChild.lastElementChild
previewElement.innerHTML = renderAssetsPreview(hoverItemElement.getAttribute("data-value"));
});
const previewElement = this.subElement.firstElementChild.lastElementChild;
previewElement.innerHTML = renderAssetsPreview(listElement.firstElementChild.getAttribute("data-value"));
const inputElement = this.subElement.querySelector("input");
inputElement.addEventListener("keydown", (event: KeyboardEvent) => {
@ -1183,7 +1183,7 @@ export class Toolbar {
}
const currentElement = upDownHint(listElement, event);
if (currentElement) {
previewElement.innerHTML = renderAssetsPreview(currentElement.getAttribute("data-value"))
previewElement.innerHTML = renderAssetsPreview(currentElement.getAttribute("data-value"));
}
if (event.key === "Enter") {
hintRenderAssets(this.subElement.querySelector(".b3-list-item--focus").getAttribute("data-value"), protyle);

View file

@ -29,8 +29,8 @@ export const getDisplayName = (filePath: string, basename = true, removeSY = fal
};
export const getAssetName = (assetPath: string) => {
return assetPath.substring(7, assetPath.length - pathPosix().extname(assetPath).length - 23)
}
return assetPath.substring(7, assetPath.length - pathPosix().extname(assetPath).length - 23);
};
export const isLocalPath = (link: string) => {
if (!link) {