<template>
  <input
    type="hidden"
    class="simple-file-upload-hidden-input"
    role="uploadcare-uploader"
    name="file-upload"
    data-system-dialog
    ref="uploadcare-filedialog">
</template>

<script>
  import uploadcareWidget from 'uploadcare-widget';

  export default {
    mounted() {
      let widget = uploadcareWidget.Widget('[role=uploadcare-uploader]');

      widget.onChange(result => {
        result.done(fileInfo => {
          let urlWithFilename = fileInfo.cdnUrl + fileInfo.name;
          this.$emit('link-change-url', urlWithFilename);
        });
      });
    },

  };
</script>
