🎨 Add more file formats supporting snapshots comparing https://github.com/siyuan-note/siyuan/issues/8438

This commit is contained in:
Daniel 2023-06-03 17:42:01 +08:00
parent e50a9b4e11
commit 30e70ade73
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 47 additions and 2 deletions

View file

@ -193,3 +193,26 @@ func FilterSelfChildDocs(paths []string) (ret []string) {
func IsAssetLinkDest(dest []byte) bool {
return bytes.HasPrefix(dest, []byte("assets/"))
}
var (
SiYuanAssetsImage = []string{".apng", ".ico", ".cur", ".jpg", ".jpe", ".jpeg", ".jfif", ".pjp", ".pjpeg", ".png", ".gif", ".webp", ".bmp", ".svg", ".avif"}
SiYuanAssetsAudio = []string{".mp3", ".wav", ".ogg", ".m4a"}
SiYuanAssetsVideo = []string{".mov", ".weba", ".mkv", ".mp4", ".webm"}
)
func IsDisplayableAsset(p string) bool {
ext := strings.ToLower(filepath.Ext(p))
if "" == ext {
return false
}
if gulu.Str.Contains(ext, SiYuanAssetsImage) {
return true
}
if gulu.Str.Contains(ext, SiYuanAssetsAudio) {
return true
}
if gulu.Str.Contains(ext, SiYuanAssetsVideo) {
return true
}
return false
}