1- import { Image , Music , FileText , Paperclip } from 'lucide' ;
2-
31export class FileUploadManager {
42 constructor ( app ) {
53 this . app = app ;
@@ -23,58 +21,13 @@ export class FileUploadManager {
2321 . replace ( / ' / g, "'" ) ;
2422 }
2523
26- // Helper method to create lucide icons
24+ // Helper method to create lucide icons (delegates to app)
2725 createIcon ( iconName , options = { } ) {
28- const iconMap = {
29- 'image' : Image ,
30- 'music' : Music ,
31- 'file-text' : FileText ,
32- 'paperclip' : Paperclip
33- } ;
34-
35- const IconComponent = iconMap [ iconName ] ;
36- if ( ! IconComponent ) {
37- console . warn ( `Icon "${ iconName } " not found` ) ;
26+ if ( ! this . app || typeof this . app . createIconHTML !== 'function' ) {
27+ console . warn ( 'App.createIconHTML not available' ) ;
3828 return '' ;
3929 }
40-
41- const size = options . size || 16 ;
42- const strokeWidth = options . strokeWidth || 2 ;
43-
44- // Create SVG element
45- const svg = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'svg' ) ;
46- svg . setAttribute ( 'width' , size ) ;
47- svg . setAttribute ( 'height' , size ) ;
48- svg . setAttribute ( 'viewBox' , '0 0 24 24' ) ;
49- svg . setAttribute ( 'fill' , 'none' ) ;
50- svg . setAttribute ( 'stroke' , 'currentColor' ) ;
51- svg . setAttribute ( 'stroke-width' , strokeWidth ) ;
52- svg . setAttribute ( 'stroke-linecap' , 'round' ) ;
53- svg . setAttribute ( 'stroke-linejoin' , 'round' ) ;
54-
55- // Add paths from the icon component
56- IconComponent . forEach ( pathData => {
57- if ( pathData && pathData [ 0 ] === 'path' ) {
58- const path = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'path' ) ;
59- path . setAttribute ( 'd' , pathData [ 1 ] . d || '' ) ;
60- svg . appendChild ( path ) ;
61- } else if ( pathData && pathData [ 0 ] === 'circle' ) {
62- const circle = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'circle' ) ;
63- circle . setAttribute ( 'cx' , pathData [ 1 ] . cx || '' ) ;
64- circle . setAttribute ( 'cy' , pathData [ 1 ] . cy || '' ) ;
65- circle . setAttribute ( 'r' , pathData [ 1 ] . r || '' ) ;
66- svg . appendChild ( circle ) ;
67- } else if ( pathData && pathData [ 0 ] === 'line' ) {
68- const line = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'line' ) ;
69- line . setAttribute ( 'x1' , pathData [ 1 ] . x1 || '' ) ;
70- line . setAttribute ( 'y1' , pathData [ 1 ] . y1 || '' ) ;
71- line . setAttribute ( 'x2' , pathData [ 1 ] . x2 || '' ) ;
72- line . setAttribute ( 'y2' , pathData [ 1 ] . y2 || '' ) ;
73- svg . appendChild ( line ) ;
74- }
75- } ) ;
76-
77- return svg . outerHTML ;
30+ return this . app . createIconHTML ( iconName , options ) ;
7831 }
7932
8033 setupEventListeners ( ) {
@@ -219,12 +172,12 @@ export class FileUploadManager {
219172 }
220173
221174 getFileIcon ( mimeType ) {
222- if ( mimeType . startsWith ( 'image/' ) ) return this . createIcon ( 'image' ) ;
223- if ( mimeType . startsWith ( 'audio/' ) ) return this . createIcon ( 'music' ) ;
224- if ( mimeType === 'application/pdf' ) return this . createIcon ( 'file-text' ) ;
225- if ( mimeType . includes ( 'word' ) ) return this . createIcon ( 'file-text' ) ;
226- if ( mimeType === 'text/plain' ) return this . createIcon ( 'file-text' ) ;
227- return this . createIcon ( 'paperclip' ) ;
175+ if ( mimeType . startsWith ( 'image/' ) ) return this . createIcon ( 'image' , { size : 24 } ) ;
176+ if ( mimeType . startsWith ( 'audio/' ) ) return this . createIcon ( 'music' , { size : 24 } ) ;
177+ if ( mimeType === 'application/pdf' ) return this . createIcon ( 'file-text' , { size : 24 } ) ;
178+ if ( mimeType . includes ( 'word' ) ) return this . createIcon ( 'file-text' , { size : 24 } ) ;
179+ if ( mimeType === 'text/plain' ) return this . createIcon ( 'file-text' , { size : 24 } ) ;
180+ return this . createIcon ( 'paperclip' , { size : 24 } ) ;
228181 }
229182
230183 formatFileSize ( bytes ) {
0 commit comments