# All files / src/lib/markdown-it/plugins/markdown-it-block-embed PluginEnvironment.js

100% Statements 18/18
100% Branches 0/0
100% Functions 3/3
100% Lines 18/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57

    20x
    20x
    20x
    20x
    20x
    20x

    20x
    20x

    20x

    20x

    20x
    20x
    20x
    120x
    120x

    20x

    20x

    20x
     // Copyright (c) Rotorz Limited and portions by original markdown-it-video authors
    // Licensed under the MIT license. See LICENSE file in the project root.

    'use strict';

    const YouTubeService = require('./services/YouTubeService');
    const VimeoService = require('./services/VimeoService');
    const VineService = require('./services/VineService');
    const PreziService = require('./services/PreziService');
    const SlideShareService = require('./services/SlideShareService');
    const PowerPointOnlineService = require('./services/PowerPointOnlineService');

    class PluginEnvironment {

      constructor(md, options) {
        this.md = md;
        this.options = Object.assign(this.getDefaultOptions(), options);

        this._initServices();
      }

      _initServices() {
        let defaultServiceBindings = {
          'youtube': YouTubeService,
          'vimeo': VimeoService,
          'vine': VineService,
          'prezi': PreziService,
          'slideshare': SlideShareService,
          'powerpoint': PowerPointOnlineService,
        };

        let serviceBindings = Object.assign({}, defaultServiceBindings, this.options.services);
        let services = {};
        for (let serviceName of Object.keys(serviceBindings)) {
          let _serviceClass = serviceBindings[serviceName];
          services[serviceName] = new _serviceClass(serviceName, this.options[serviceName], this);
        }

        this.services = services;
      }

      getDefaultOptions() {
        return {
          containerClassName: 'block-embed',
          serviceClassPrefix: 'block-embed-service-',
          outputPlayerSize: true,
          allowFullScreen: true,
          filterUrl: null
        };
      }

    }

    module.exports = PluginEnvironment;