@@ -514,13 +514,13 @@ function updateImages() {
514514 } ,
515515 credentials : "same-origin"
516516 } ) . then ( response => response . json ( ) )
517- . then ( data => {
517+ . then ( data => {
518518 let imagesContainer = document . getElementById ( "table-images" ) ;
519519 imagesContainer . innerHTML = "" ;
520520 data . forEach ( image => {
521521 const imageElement = document . createElement ( "div" ) ;
522522 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 ;
524524 let img = document . createElement ( "img" ) ;
525525 img . className = "image-editor-display" ;
526526 img . src = imageUrl ;
@@ -536,6 +536,14 @@ function updateImages() {
536536 navigator . clipboard . writeText ( mdTextToInsert ) ;
537537 } ) ;
538538
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+ } ) ;
539547
540548 let buttonDelete = document . createElement ( "button" ) ;
541549 buttonDelete . type = "button" ;
@@ -559,6 +567,7 @@ function updateImages() {
559567 }
560568 } ) ;
561569 buttonContainer . appendChild ( buttonCopy ) ;
570+ buttonContainer . appendChild ( buttonCustomCopy ) ;
562571 buttonContainer . appendChild ( buttonDelete ) ;
563572 imageElement . appendChild ( img ) ;
564573 imageElement . appendChild ( buttonContainer ) ;
@@ -584,3 +593,26 @@ function insertImageUrl() {
584593 closeToastUiModal ( ) ;
585594}
586595
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