2022-07-16 23:20:50 +08:00
|
|
|
import {Constants} from "../constants";
|
|
|
|
|
import {pathPosix} from "../util/pathName";
|
|
|
|
|
|
|
|
|
|
export const renderAssetsPreview = (pathString: string) => {
|
2022-07-17 11:06:57 +08:00
|
|
|
const type = pathPosix().extname(pathString).toLowerCase();
|
2022-07-16 23:20:50 +08:00
|
|
|
if (Constants.SIYUAN_ASSETS_IMAGE.includes(type)) {
|
|
|
|
|
return `<img style="max-height: 100%" src="${pathString}">`;
|
|
|
|
|
} else if (Constants.SIYUAN_ASSETS_AUDIO.includes(type)) {
|
|
|
|
|
return `<audio style="max-width: 100%" controls="controls" src="${pathString}"></audio>`;
|
|
|
|
|
} else if (Constants.SIYUAN_ASSETS_VIDEO.includes(type)) {
|
|
|
|
|
return `<video style="max-width: 100%" controls="controls" src="${pathString}"></video>`;
|
|
|
|
|
} else {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
2022-07-17 11:06:57 +08:00
|
|
|
};
|