@@ -63,7 +63,7 @@ export default class CssSnippetStore extends Plugin {
63
63
customButton . style . marginLeft = "8px" ;
64
64
65
65
customButton . onclick = ( ) => {
66
- new CssSnippetStoreModal ( this . app , this . snippets ) . open ( ) ;
66
+ new CssSnippetStoreModal ( this . app , this . snippets , this ) . open ( ) ;
67
67
} ;
68
68
69
69
controlElement . appendChild ( customButton ) ;
@@ -92,7 +92,7 @@ export default class CssSnippetStore extends Plugin {
92
92
}
93
93
94
94
class CssSnippetStoreModal extends Modal {
95
- constructor ( app : App , private snippets : Snippet [ ] ) {
95
+ constructor ( app : App , private snippets : Snippet [ ] , private plugin : Plugin ) {
96
96
super ( app ) ;
97
97
this . modalEl . addClass ( 'mod-snippet-store' ) ;
98
98
}
@@ -253,7 +253,8 @@ class CssSnippetStoreModal extends Modal {
253
253
return ;
254
254
}
255
255
const readme = await response . text ( ) ;
256
- new SnippetReadmeModal ( this . app , snippet , readme ) . open ( ) ;
256
+ // Pass the plugin instance (this.plugin)
257
+ new SnippetReadmeModal ( this . app , snippet , readme , this . plugin ) . open ( ) ;
257
258
} else {
258
259
new Notice ( "No Internet connection..." ) ;
259
260
}
@@ -349,7 +350,8 @@ class SnippetReadmeModal extends Modal {
349
350
constructor (
350
351
app : App ,
351
352
private snippet : Snippet ,
352
- private readmeContent : string
353
+ private readmeContent : string ,
354
+ private plugin : Plugin // Add reference to the plugin instance
353
355
) {
354
356
super ( app ) ;
355
357
}
@@ -361,28 +363,20 @@ class SnippetReadmeModal extends Modal {
361
363
this . modalEl . style . width = "80vw" ;
362
364
this . modalEl . style . height = "80vh" ;
363
365
364
- // Title
365
- contentEl . createEl ( "h2" , {
366
- text : `${ this . snippet . name } – README` ,
367
- } ) ;
368
-
369
366
// Rewrite relative image paths to absolute GitHub raw URLs
370
367
const adjustedContent = this . rewriteRelativeMediaPaths ( this . readmeContent ) ;
371
368
372
369
// Markdown container
373
370
const markdownContainer = contentEl . createDiv ( ) ;
374
- markdownContainer . style . overflowY = "auto" ;
375
- markdownContainer . style . maxHeight = "65vh" ;
376
- markdownContainer . style . padding = "1rem" ;
377
- markdownContainer . style . backgroundColor = "var(--background-secondary)" ;
378
- markdownContainer . style . borderRadius = "8px" ;
379
371
380
372
// Render Markdown using Obsidian's renderer
381
- await MarkdownRenderer . renderMarkdown (
373
+ // Use the plugin instance instead of "this"
374
+ await MarkdownRenderer . render (
375
+ this . app ,
382
376
adjustedContent ,
383
377
markdownContainer ,
384
378
"" ,
385
- this
379
+ this . plugin // Pass the plugin instance which is a Component
386
380
) ;
387
381
388
382
markdownContainer . querySelectorAll ( "img" ) . forEach ( ( img ) => {
@@ -401,7 +395,7 @@ class SnippetReadmeModal extends Modal {
401
395
const base = `https://raw.githubusercontent.com/${ this . snippet . repo } /refs/heads/main/${ this . snippet . folder } /` ;
402
396
403
397
// Regex to match image/video markdown with relative path
404
- return content . replace ( / ! \[ ( [ ^ \] ] * ) \ ]\( ( \. \/ [ ^ ) ] + ) \) / g, ( match , alt , relPath ) => {
398
+ return content . replace ( / ! \[ ( [ ^ \] ] * ) ] \( ( \. \/ [ ^ ) ] + ) \) / g, ( match , alt , relPath ) => {
405
399
const url = base + relPath . replace ( "./" , "" ) ;
406
400
return `` ;
407
401
} ) ;
0 commit comments