Commit a612646e authored by Peter Leitzen's avatar Peter Leitzen

Merge branch '198353-copying-video-audio' into 'master'

Fix for #198353, copied and pasted markdown video/audio snippets not playable

Closes #198353

See merge request gitlab-org/gitlab!23918
parents 4cc44102 386754a9
...@@ -42,7 +42,7 @@ export default class Playable extends Node { ...@@ -42,7 +42,7 @@ export default class Playable extends Node {
}, },
{ {
tag: `${this.mediaType}[src]`, tag: `${this.mediaType}[src]`,
getAttrs: el => ({ src: el.getAttribute('src'), alt: el.dataset.title }), getAttrs: el => ({ src: el.src, alt: el.dataset.title }),
}, },
]; ];
......
...@@ -172,18 +172,36 @@ describe 'Copy as GFM', :js do ...@@ -172,18 +172,36 @@ describe 'Copy as GFM', :js do
'![Image](https://example.com/image.png)' '![Image](https://example.com/image.png)'
) )
verify_media_with_partial_path(
'![Image](/uploads/a123/image.png)',
project_media_uri(@project, '/uploads/a123/image.png')
)
verify( verify(
'VideoLinkFilter', 'VideoLinkFilter',
'![Video](https://example.com/video.mp4)' '![Video](https://example.com/video.mp4)'
) )
verify_media_with_partial_path(
'![Video](/uploads/a123/video.mp4)',
project_media_uri(@project, '/uploads/a123/video.mp4')
)
verify( verify(
'AudioLinkFilter', 'AudioLinkFilter',
'![Audio](https://example.com/audio.wav)' '![Audio](https://example.com/audio.wav)'
) )
verify_media_with_partial_path(
'![Audio](/uploads/a123/audio.wav)',
project_media_uri(@project, '/uploads/a123/audio.wav')
)
verify( verify(
'MathFilter: math as converted from GFM to HTML', 'MathFilter: math as converted from GFM to HTML',
...@@ -647,6 +665,16 @@ describe 'Copy as GFM', :js do ...@@ -647,6 +665,16 @@ describe 'Copy as GFM', :js do
end end
end end
def project_media_uri(project, media_path)
"#{project_path(project)}#{media_path}"
end
def verify_media_with_partial_path(gfm, media_uri)
html = gfm_to_html(gfm)
output_gfm = html_to_gfm(html)
expect(output_gfm).to include(media_uri)
end
# Fake a `current_user` helper # Fake a `current_user` helper
def current_user def current_user
@feat.user @feat.user
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment