Skip to content

Commit 14b2ffc

Browse files
committed
add controls attr to ::video
1 parent 4adb31a commit 14b2ffc

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

docs/tdev/gallery/markdown/remark-media/video.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,18 @@ Fügt ein lokales Video ein.
3636
: Breite des Videos.
3737
: Standardmässig auf die natürliche Breite des Videos gesetzt (wobei `max-width=100%` gesetzt wird).
3838
: z.B. `width=200px`
39+
`controls`
40+
: Blendet die Steuerelemente des Videos ein oder aus.
41+
: Standardmässig `true`.
42+
: z.B. `controls=false`
3943
css Eigenschaften
4044
: Es können beliebige css-Eigenschaften in Form `eigenschaft=wert` angegeben werden, die auf das Video angewendet werden.
4145

4246

4347
```mdx
44-
::video[./assets/yogi-bear.mp4]{width=300px height=200px muted autoplay loop border="2px solid red"}
48+
::video[./assets/yogi-bear.mp4]{width=300px height=200px muted autoplay loop border="2px solid red" controls=false}
4549
```
4650

4751
<BrowserWindow>
48-
::video[./assets/yogi-bear.mp4]{width=300px height=200px muted autoplay loop border="2px solid red"}
52+
::video[./assets/yogi-bear.mp4]{width=300px height=200px muted autoplay loop border="2px solid red" controls=false}
4953
</BrowserWindow>

src/plugins/remark-media/plugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ const plugin: Plugin<unknown[], Root> = function plugin(): Transformer<Root> {
5252
newNode.attributes.push(toJsxAttribute('loop', attributes.loop));
5353
}
5454
newNode.attributes.push(toJsxAttribute('style', { maxWidth: '100%', ...style }));
55-
newNode.attributes.push(toJsxAttribute('controls', ''));
55+
if (!('controls' in attributes) || attributes.controls) {
56+
newNode.attributes.push(toJsxAttribute('controls', ''));
57+
}
5658
newNode.children.push({
5759
type: 'mdxJsxFlowElement',
5860
name: 'source',

src/plugins/remark-media/tests/plugin.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ describe('#medialinks', () => {
4949
"
5050
`);
5151
});
52+
it('respects controls=false for video', async () => {
53+
const input = `
54+
::video[./bunny.mp4]{controls=false}
55+
`;
56+
const result = await process(input);
57+
expect(result).toMatchInlineSnapshot(`
58+
"<video style={{"maxWidth":"100%"}}>
59+
<source src={require('./bunny.mp4').default} />
60+
</video>
61+
"
62+
`);
63+
});
5264
it('can convert audio directive', async () => {
5365
const input = `
5466
::audio[./song.mp3]

0 commit comments

Comments
 (0)