-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tooltip): adds detection for mobile youtube video
This allows to convert m.youtube.com and www.youtube.com to embedded url as well Finishes work of #1155
- Loading branch information
Sergii Stotskyi
committed
Jun 5, 2017
1 parent
e77502a
commit d45b365
Showing
3 changed files
with
74 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import Quill from '../../../../core'; | ||
import { BaseTooltip } from '../../../../themes/base' | ||
|
||
class Tooltip extends BaseTooltip { | ||
} | ||
|
||
Tooltip.TEMPLATE = '<input type="text">'; | ||
|
||
describe('BaseTooltip', function() { | ||
describe('save', function() { | ||
beforeEach(function() { | ||
this.quill = this.initialize(Quill, ''); | ||
this.tooltip = new Tooltip(this.quill) | ||
}); | ||
|
||
it('converts youtube video url to embedded', function() { | ||
insertVideo(this.tooltip, 'http://youtube.com/watch?v=QHH3iSeDBLo'); | ||
expect(this.container.querySelector('.ql-video').src).toContain('http://www.youtube.com/embed/QHH3iSeDBLo'); | ||
}); | ||
|
||
it('converts www.youtube video url to embedded', function() { | ||
insertVideo(this.tooltip, 'http://www.youtube.com/watch?v=QHH3iSeDBLo'); | ||
expect(this.container.querySelector('.ql-video').src).toContain('http://www.youtube.com/embed/QHH3iSeDBLo'); | ||
}); | ||
|
||
it('converts m.youtube video url to embedded', function() { | ||
insertVideo(this.tooltip, 'http://m.youtube.com/watch?v=QHH3iSeDBLo'); | ||
expect(this.container.querySelector('.ql-video').src).toContain('http://www.youtube.com/embed/QHH3iSeDBLo'); | ||
}); | ||
|
||
it('preserves youtube video url protocol', function() { | ||
insertVideo(this.tooltip, 'https://m.youtube.com/watch?v=QHH3iSeDBLo'); | ||
expect(this.container.querySelector('.ql-video').src).toContain('https://www.youtube.com/embed/QHH3iSeDBLo'); | ||
}); | ||
|
||
it('converts vimeo video url to embedded', function() { | ||
insertVideo(this.tooltip, 'http://vimeo.com/47762693'); | ||
expect(this.container.querySelector('.ql-video').src).toContain('http://player.vimeo.com/video/47762693/'); | ||
}); | ||
|
||
it('converts www.vimeo video url to embedded', function() { | ||
insertVideo(this.tooltip, 'http://www.vimeo.com/47762693'); | ||
expect(this.container.querySelector('.ql-video').src).toContain('http://player.vimeo.com/video/47762693/'); | ||
}); | ||
|
||
it('preserves vimeo video url protocol', function() { | ||
insertVideo(this.tooltip, 'https://www.vimeo.com/47762693'); | ||
expect(this.container.querySelector('.ql-video').src).toContain('https://player.vimeo.com/video/47762693/'); | ||
}); | ||
|
||
function insertVideo(tooltip, url) { | ||
tooltip.textbox.value = url; | ||
tooltip.root.setAttribute('data-mode', 'video'); | ||
tooltip.save(); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters