• Sean Hammond's avatar
    Render YouTube and Vimeo links as video embeds · e5beb610
    Sean Hammond authored
    Client-side, replace any links to YouTube or Vimeo videos in annotation
    body texts with <iframe> video embeds for those same videos.
    
    Behind a new feature flag.
    
    markdown.coffee: after rendering the user's markdown text to HTML and
    sanitizing it, compile the HTML string into a DOM element and insert it into
    the DOM using innerHTML from JavaScript, instead of using Angular's
    ng-bind-html to insert the HTML string into the DOM.
    
    This means that our CoffeeScript code in markdown.coffee has the rendered
    annotation body as a DOM element, and can use the DOM API to modify it before
    inserting it into the DOM.
    
    Take advantage of this to find video links in the HTML and replace them with
    embeds. This is done by a standalone media-embedder.js module that
    markdown.coffee calls.
    
    This module is designed to allow functions for generating embeds for different
    kinds of URLs to be plugged in. So far functions for a few different kinds of
    YouTube and Vimeo URLs are implemented, but further functions for more
    media types can be added.
    e5beb610
markdown.coffee 13.3 KB