From aa6ddbf4b5096f371327a09100666e71a083dff4 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Wed, 1 Jul 2026 01:33:26 +0200 Subject: [PATCH 1/2] text area focus is needed to make gallery work afet file upload --- cmd/web/client/js/controllers/mdeditor_controller.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/web/client/js/controllers/mdeditor_controller.js b/cmd/web/client/js/controllers/mdeditor_controller.js index e6a36d8..e8efbd6 100644 --- a/cmd/web/client/js/controllers/mdeditor_controller.js +++ b/cmd/web/client/js/controllers/mdeditor_controller.js @@ -54,6 +54,7 @@ export default class extends Controller { let runCmd = function(cmd, e) { e.preventDefault() + textarea.focus() switch (cmd) { case "gallery": From 622e3402400712bf090bf997ece5cab553e4d28c Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Wed, 1 Jul 2026 01:33:47 +0200 Subject: [PATCH 2/2] gallery - handle the images within the same paragraph --- .../js/controllers/gallery_controller.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cmd/web/client/js/controllers/gallery_controller.js b/cmd/web/client/js/controllers/gallery_controller.js index 2f86736..ac8e377 100644 --- a/cmd/web/client/js/controllers/gallery_controller.js +++ b/cmd/web/client/js/controllers/gallery_controller.js @@ -72,9 +72,9 @@ export default class extends Controller { // it gets modified and an ordinary loop would screw us while (paragraphs.length > 0) { let p = paragraphs.item(0) - let img = p.querySelector("img") + let imgs = p.querySelectorAll("img") - if (!img) { + if (imgs.length === 0) { // any leading paragraphs without photo cannot be used as captions, hence we're simply // pushing htem outside of gallery @@ -89,17 +89,17 @@ export default class extends Controller { continue } - if (!currentImg) { + // a paragraph may contain multiple images (e.g. when not separated + // by blank lines in markdown), each one becomes its own carousel item + for (let img of imgs) { + if (currentImg) { + addNewItem(inner, fragmentItemsContainer, currentImg, currentCaption, seenFirstItem) + seenFirstItem = true + currentCaption = [] + } currentImg = img - inner.removeChild(p) - continue } - - addNewItem(inner, fragmentItemsContainer, currentImg, currentCaption, seenFirstItem) inner.removeChild(p) - seenFirstItem = true - currentImg = img - currentCaption = [] } if (currentImg) {