@@ -390,11 +390,15 @@ export default class ObsidianAdmonition extends Plugin {
390390 . join ( "\n" )
391391 . replace ( / > / g, "" ) ;
392392
393+ const contentEl = this . getAdmonitionContentElement (
394+ type ,
395+ admonition ,
396+ content
397+ ) ;
398+
393399 MarkdownRenderer . renderMarkdown (
394400 content ,
395- admonition
396- . createDiv ( "admonition-content-holder" )
397- . createDiv ( "admonition-content" ) ,
401+ contentEl ,
398402 ctx . sourcePath ,
399403 null
400404 ) ;
@@ -454,14 +458,14 @@ export default class ObsidianAdmonition extends Plugin {
454458 } ) ;
455459 } ;
456460
457- MarkdownRenderer . renderMarkdown (
458- this . content . replace ( / ^ > / gm, "" ) ,
459- admonitionElement
460- . createDiv ( "admonition-content-holder" )
461- . createDiv ( "admonition-content" ) ,
462- "" ,
463- null
461+ const content = this . content . replace ( / ^ > / gm, "" ) ;
462+ const contentEl = self . getAdmonitionContentElement (
463+ this . type ,
464+ admonitionElement ,
465+ content
464466 ) ;
467+
468+ MarkdownRenderer . renderMarkdown ( content , contentEl , "" , null ) ;
465469 return parent ;
466470 }
467471 }
@@ -1064,13 +1068,11 @@ ${editor.getDoc().getSelection()}\n--- admonition\n`
10641068 }
10651069
10661070 if ( content && content . length ) {
1067- const contentHolder = admonitionElement . createDiv (
1068- "admonition-content-holder"
1071+ const admonitionContent = this . getAdmonitionContentElement (
1072+ type ,
1073+ admonitionElement ,
1074+ content
10691075 ) ;
1070-
1071- const admonitionContent =
1072- contentHolder . createDiv ( "admonition-content" ) ;
1073-
10741076 /**
10751077 * Render the content as markdown and append it to the admonition.
10761078 */
@@ -1104,21 +1106,6 @@ ${editor.getDoc().getSelection()}\n--- admonition\n`
11041106 ) ;
11051107 }
11061108
1107- if ( admonition . copy ?? this . data . copyButton ) {
1108- let copy = contentHolder
1109- . createDiv ( "admonition-content-copy" )
1110- . appendChild ( COPY_BUTTON_ICON . cloneNode ( true ) ) ;
1111- copy . addEventListener ( "click" , ( ) => {
1112- navigator . clipboard
1113- . writeText ( content . trim ( ) )
1114- . then ( async ( ) => {
1115- new Notice (
1116- "Admonition content copied to clipboard."
1117- ) ;
1118- } ) ;
1119- } ) ;
1120- }
1121-
11221109 const taskLists =
11231110 admonitionContent . querySelectorAll < HTMLInputElement > (
11241111 ".task-list-item-checkbox"
@@ -1313,6 +1300,27 @@ ${editor.getDoc().getSelection()}\n--- admonition\n`
13131300 }
13141301 return admonition ;
13151302 }
1303+ getAdmonitionContentElement (
1304+ type : string ,
1305+ admonitionElement : HTMLElement ,
1306+ content : string
1307+ ) {
1308+ const contentHolder = admonitionElement . createDiv (
1309+ "admonition-content-holder"
1310+ ) ;
1311+ const contentEl = contentHolder . createDiv ( "admonition-content" ) ;
1312+ if ( this . admonitions [ type ] . copy ?? this . data . copyButton ) {
1313+ let copy = contentHolder
1314+ . createDiv ( "admonition-content-copy" )
1315+ . appendChild ( COPY_BUTTON_ICON . cloneNode ( true ) ) ;
1316+ copy . addEventListener ( "click" , ( ) => {
1317+ navigator . clipboard . writeText ( content . trim ( ) ) . then ( async ( ) => {
1318+ new Notice ( "Admonition content copied to clipboard." ) ;
1319+ } ) ;
1320+ } ) ;
1321+ }
1322+ return contentEl ;
1323+ }
13161324 async getAdmonitionElementAsync (
13171325 type : string ,
13181326 title : string ,
0 commit comments