Skip to content

Commit 268d121

Browse files
authored
Fix video width overflow in markdown, and other changes to match img (#24834)
This change makes the CSS for `<video>` in markup match that of `<img>`, and also allows additional attributes to be used. This way the width, padding, alignment should work equally well for both.
1 parent e95b42e commit 268d121

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

modules/markup/sanitizer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func createDefaultPolicy() *bluemonday.Policy {
132132
"div", "ins", "del", "sup", "sub", "p", "ol", "ul", "table", "thead", "tbody", "tfoot", "blockquote",
133133
"dl", "dt", "dd", "kbd", "q", "samp", "var", "hr", "ruby", "rt", "rp", "li", "tr", "td", "th", "s", "strike", "summary",
134134
"details", "caption", "figure", "figcaption",
135-
"abbr", "bdo", "cite", "dfn", "mark", "small", "span", "time", "wbr",
135+
"abbr", "bdo", "cite", "dfn", "mark", "small", "span", "time", "video", "wbr",
136136
}
137137

138138
policy.AllowAttrs(generalSafeAttrs...).OnElements(generalSafeElements...)

web_src/css/markup/content.css

+17-7
Original file line numberDiff line numberDiff line change
@@ -301,25 +301,32 @@
301301
background-color: var(--color-markup-table-row);
302302
}
303303

304-
.markup img {
304+
.markup img,
305+
.markup video {
305306
max-width: 100%;
306307
box-sizing: initial;
307308
}
308309

309310
/* this background ensures images can break <hr>. We can only do this on
310311
cases where the background is known and not transparent. */
311312
.markup.file-view img,
313+
.markup.file-view video,
312314
.comment-body .markup img, /* regular comment */
315+
.comment-body .markup video,
313316
.comment-content .markup img, /* code comment */
314-
.wiki .markup img {
317+
.comment-content .markup video,
318+
.wiki .markup img,
319+
.wiki .markup video {
315320
background: var(--color-box-body);
316321
}
317322

318-
.markup img[align="right"] {
323+
.markup img[align="right"],
324+
.markup video[align="right"] {
319325
padding-left: 20px;
320326
}
321327

322-
.markup img[align="left"] {
328+
.markup img[align="left"],
329+
.markup video[align="left"] {
323330
padding-right: 20px;
324331
}
325332

@@ -343,7 +350,8 @@
343350
border: 1px solid var(--color-secondary);
344351
}
345352

346-
.markup span.frame span img {
353+
.markup span.frame span img,
354+
.markup span.frame span video {
347355
display: block;
348356
float: left;
349357
}
@@ -368,7 +376,8 @@
368376
text-align: center;
369377
}
370378

371-
.markup span.align-center span img {
379+
.markup span.align-center span img
380+
.markup span.align-center span video {
372381
margin: 0 auto;
373382
text-align: center;
374383
}
@@ -386,7 +395,8 @@
386395
text-align: right;
387396
}
388397

389-
.markup span.align-right span img {
398+
.markup span.align-right span img,
399+
.markup span.align-right span video {
390400
margin: 0;
391401
text-align: right;
392402
}

0 commit comments

Comments
 (0)