Skip to content

Commit 5c238e9

Browse files
committed
LUT-25134 : New image layout
1 parent 0968565 commit 5c238e9

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

webapp/WEB-INF/templates/skin/plugins/wiki/custom_input_editor.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@
131131
<input id="ImageUrlDesc" type="text" />
132132
<div class="toastui-editor-popup-content-footer" style="margin:25px 25px;">
133133
<button class="btn btn-primary" type="button" onclick="insertImageUrl()">Insert</button>
134+
<button class="btn btn-primary" type="button" onclick="insertCustomImageUrl()">Insert custom</button>
134135
<button class="btn btn-default" type="button" onclick="closeToastUiModal()">Cancel</button>
135136
</div>
136137
</div>
137138
</div>
138-
139139
<!------------------- END OF CUSTOM INPUTS -------------------------->

webapp/js/plugins/wiki/wiki_pages/modify_page.js

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)