mirror of
https://github.com/xryul/link-navigation.git
synced 2026-07-22 10:50:25 +00:00
feat: A few extra supported file format in particualr for various programming languages. IMproves to regex.
This commit is contained in:
parent
d28914aa0a
commit
abdec14ccc
1 changed files with 20 additions and 5 deletions
25
src/main.ts
25
src/main.ts
|
|
@ -347,17 +347,25 @@ export default class LinkNavigationPlugin extends Plugin {
|
|||
const supportedExtensions = [
|
||||
// Images
|
||||
'avif', 'bmp', 'gif', 'jpeg', 'jpg', 'png', 'svg', 'webp', 'tif', 'tiff', 'psd', 'dng', 'heif', 'heic', 'cr2', 'nef', 'ico',
|
||||
|
||||
// Audio
|
||||
'flac', 'm4a', 'mp3', 'ogg', 'wav', 'webm', '3gp',
|
||||
|
||||
// Video
|
||||
'mkv', 'mov', 'mp4', 'ogv', 'avi',
|
||||
|
||||
// Documents
|
||||
'pdf', 'doc', 'docx', 'xlsx', 'pptx', 'djvu', 'epub',
|
||||
|
||||
// Archives
|
||||
'zip', '7z', 'tar', 'gz', 'rar', 'xc', 'bzip2', 'iso', 'cmg', 'msi'
|
||||
'zip', '7z', 'tar', 'gz', 'rar', 'xc', 'bzip2', 'iso', 'cmg', 'msi',
|
||||
|
||||
// Programming
|
||||
'py', 'js', 'ts', 'html', 'css', 'json', 'xml', 'java', 'cpp', 'cs', 'rb', 'php', 'swift', 'go', 'rs', 'sh'
|
||||
].join('|');
|
||||
|
||||
const attachmentRegex = new RegExp(`!?\\[\\[([^\\]]+\\.(${supportedExtensions}))\\]\\]`, 'gi');
|
||||
const attachmentRegex = new RegExp(`!?\\[\\[([^\\]]+\\.(?:${supportedExtensions}))\\]\\]`, 'gi');
|
||||
|
||||
|
||||
// Check for attachments in embeds
|
||||
if (fileCache && fileCache.embeds) {
|
||||
|
|
@ -413,19 +421,26 @@ export default class LinkNavigationPlugin extends Plugin {
|
|||
const ext = attachment.split('.').pop()?.toLowerCase();
|
||||
let icon = '📎';
|
||||
|
||||
// Define icon mappings
|
||||
const iconMap: {[key: string]: string} = {
|
||||
const iconMap: { [key: string]: string } = {
|
||||
// Images
|
||||
'avif': '🖼️', 'bmp': '🖼️', 'gif': '🖼️', 'jpeg': '🖼️', 'jpg': '🖼️', 'png': '🖼️', 'svg': '🖼️', 'webp': '🖼️',
|
||||
'tif': '🖼️', 'tiff': '🖼️', 'psd': '🖼️', 'dng': '🖼️', 'heif': '🖼️', 'heic': '🖼️', 'cr2': '🖼️', 'nef': '🖼️', 'ico': '🖼️',
|
||||
|
||||
// Audio
|
||||
'flac': '🎵', 'm4a': '🎵', 'mp3': '🎵', 'ogg': '🎵', 'wav': '🎵', '3gp': '🎵',
|
||||
|
||||
// Video
|
||||
'mkv': '🎥', 'mov': '🎥', 'mp4': '🎥', 'ogv': '🎥', 'webm': '🎥', 'avi': '🎥',
|
||||
|
||||
// Documents
|
||||
'pdf': '📄', 'doc': '📄', 'docx': '📄', 'xlsx': '📊', 'pptx': '📊', 'djvu': '📚', 'epub': '📚',
|
||||
|
||||
// Archives
|
||||
'zip': '🗜️', '7z': '🗜️', 'tar': '🗜️', 'gz': '🗜️', 'rar': '🗜️', 'xc': '🗜️', 'bzip2': '🗜️', 'iso': '💿', 'cmg': '💿', 'msi': '💿'
|
||||
'zip': '🗜️', '7z': '🗜️', 'tar': '🗜️', 'gz': '🗜️', 'rar': '🗜️', 'xc': '🗜️', 'bzip2': '🗜️', 'iso': '💿', 'cmg': '💿', 'msi': '💿',
|
||||
|
||||
// Programming (single icon for all)
|
||||
'py': '💻', 'js': '💻', 'ts': '💻', 'html': '💻', 'css': '💻', 'json': '💻', 'xml': '💻', 'java': '💻', 'cpp': '💻', 'cs': '💻',
|
||||
'rb': '💻', 'php': '💻', 'swift': '💻', 'go': '💻', 'rs': '💻', 'sh': '💻'
|
||||
};
|
||||
|
||||
if (ext && ext in iconMap) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue