@@ -514,13 +514,13 @@ function updateImages() {
514
514
} ,
515
515
credentials : "same-origin"
516
516
} ) . then ( response => response . json ( ) )
517
- . then ( data => {
517
+ . then ( data => {
518
518
let imagesContainer = document . getElementById ( "table-images" ) ;
519
519
imagesContainer . innerHTML = "" ;
520
520
data . forEach ( image => {
521
521
const imageElement = document . createElement ( "div" ) ;
522
522
imageElement . className = 'image-editor-display' ;
523
- const imageUrl = 'image?resource_type=wiki_image&id=' + parseInt ( image . id ) ;
523
+ const imageUrl = 'image?resource_type=wiki_image&id=' + image . id ;
524
524
let img = document . createElement ( "img" ) ;
525
525
img . className = "image-editor-display" ;
526
526
img . src = imageUrl ;
@@ -536,6 +536,14 @@ function updateImages() {
536
536
navigator . clipboard . writeText ( mdTextToInsert ) ;
537
537
} ) ;
538
538
539
+ let buttonCustomCopy = document . createElement ( "button" ) ;
540
+ buttonCustomCopy . type = "button" ;
541
+ buttonCustomCopy . className = "image-editor-display btn btn-light btn-sm" ;
542
+ buttonCustomCopy . innerText = "Copy Custom" ;
543
+ buttonCustomCopy . addEventListener ( "click" , function ( ) {
544
+ let htmlimageToInsert = "<span style='display: flex; justify-content: space-between;'><p>My text is on my left and the image on my right</p><><img src='" + imageUrl + "' alt='" + image . name + "' title='" + image . name + "' class='' width='600' height='' align=''><figcaption>" + image . name + "</figcaption></figure></span>" ;
545
+ navigator . clipboard . writeText ( "\n" + "$$span\n" + htmlimageToInsert + "\n$$\n" ) ;
546
+ } ) ;
539
547
540
548
let buttonDelete = document . createElement ( "button" ) ;
541
549
buttonDelete . type = "button" ;
@@ -559,6 +567,7 @@ function updateImages() {
559
567
}
560
568
} ) ;
561
569
buttonContainer . appendChild ( buttonCopy ) ;
570
+ buttonContainer . appendChild ( buttonCustomCopy ) ;
562
571
buttonContainer . appendChild ( buttonDelete ) ;
563
572
imageElement . appendChild ( img ) ;
564
573
imageElement . appendChild ( buttonContainer ) ;
@@ -584,3 +593,26 @@ function insertImageUrl() {
584
593
closeToastUiModal ( ) ;
585
594
}
586
595
596
+ function insertCustomImageUrl ( ) {
597
+ let desc = document . getElementById ( "ImageUrlDesc" ) . value ;
598
+ if ( ! desc . length ) {
599
+ desc = "My text below the image" ;
600
+ }
601
+ document . getElementById ( "ImageUrlDesc" ) . value = "" ;
602
+ const url = document . getElementById ( "ImageUrlInput" ) . value ;
603
+ document . getElementById ( "ImageUrlInput" ) . value = "" ;
604
+ if ( ! url . length ) {
605
+ alert ( "Please enter a valid url" ) ;
606
+ return ;
607
+ }
608
+ const htmlImage = "<span style='display: flex; justify-content: space-between;'>" +
609
+ "<p>My text is on my left and the image on my right</p> <figure>" +
610
+ "<img src='" + url + "' alt='' title='' className='' width='600' height='' align=''>" +
611
+ "<figcaption>" + desc + "</figcaption>" +
612
+ "</figure>" +
613
+ "</span>" ;
614
+ const mdImage = "\n" + "$$span\n" + htmlImage + "\n$$\n" ;
615
+ editor . insertText ( mdImage ) ;
616
+ closeToastUiModal ( ) ;
617
+ }
618
+
0 commit comments