download (scale = 2, element) {
    element = element.childNodes[0] || document.getElementById(this.renderedCardID).childNodes[0];

    const svgToImage = new SVGToImage(element);

    // Setup default filename
    let filename = 'cardkit-default.jpg';

    // Get the configuration
    const configuration = this.computeConfiguration();

    // If there's a layer that has the useAsFilename property, find it
    const filenameLayerKey = Object.keys(configuration.layers)
                                   .find((key) => {
                                     const layer = configuration.layers[key];

                                     return (layer.useAsFilename === true) && // Has the useAsFilename property
                                            (layer.hidden !== true) && // Is not hidden
                                            (layer.type === 'text'); // Is of type text
                                   });

    // Get the layer that has the filename on it
    const filenameLayer = configuration.layers[filenameLayerKey];

    // Update the filename
    if (filenameLayer) {
      filename = slugify(filenameLayer.text) + '.jpg';
    }

    // Trigger the download
    svgToImage.download(filename, {
      format: 'image/jpeg',
      scale: scale
    });
  }
/**
   * Downloads the card as an image in the browser
   *
   * @param {number} scale - The scale to output at
   * @param {object} element - The element to use to generate the image
   */
Downloads the card as an image in the browser
@param {number} scale - The scale to output at
@param {object} element - The element to use to generate the image
Downloads the card as an image in the browser @param { number } scale - The scale to output at @param { object } element - The element to use to generate the image
download (scale = 2, element) {
    element = element.childNodes[0] || document.getElementById(this.renderedCardID).childNodes[0];
    const svgToImage = new SVGToImage(element);
    let filename = 'cardkit-default.jpg';
    const configuration = this.computeConfiguration();
    const filenameLayerKey = Object.keys(configuration.layers)
                                   .find((key) => {
                                     const layer = configuration.layers[key];
                                     return (layer.useAsFilename === true) && 
                                            (layer.hidden !== true) && 
                                            (layer.type === 'text'); 
                                   });
    const filenameLayer = configuration.layers[filenameLayerKey];
    if (filenameLayer) {
      filename = slugify(filenameLayer.text) + '.jpg';
    }
    svgToImage.download(filename, {
      format: 'image/jpeg',
      scale: scale
    });
  }
download ( scale = 2 , element ) { element = element . childNodes [ 0 ] || document . getElementById ( this . renderedCardID ) . childNodes [ 0 ] ; const svgToImage = new SVGToImage ( element ) ; let filename = 'cardkit-default.jpg' ; const configuration = this . computeConfiguration ( ) ; const filenameLayerKey = Object . keys ( configuration . layers ) . find ( ( key ) => { const layer = configuration . layers [ key ] ; return ( layer . useAsFilename === true ) && ( layer . hidden !== true ) && ( layer . type === 'text' ) ; } ) ; const filenameLayer = configuration . layers [ filenameLayerKey ] ; if ( filenameLayer ) { filename = slugify ( filenameLayer . text ) + '.jpg' ; } svgToImage . download ( filename , { format : 'image/jpeg' , scale : scale } ) ; }
Downloads the card as an image in the browser
 @param {number} scale - The scale to output at
 @param {object} element - The element to use to generate the image
Downloads the card as an image in the browser @param { number } scale - The scale to output at @param { object } element - The element to use to generate the image
// Setup default filename // Get the configuration // If there's a layer that has the useAsFilename property, find it // Has the useAsFilename property // Is not hidden // Is of type text // Get the layer that has the filename on it // Update the filename // Trigger the download