Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions cmd/web/client/js/controllers/gallery_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions cmd/web/client/js/controllers/mdeditor_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default class extends Controller {

let runCmd = function(cmd, e) {
e.preventDefault()
textarea.focus()

switch (cmd) {
case "gallery":
Expand Down
Loading