<template>
  <div class="content">
    <div>
      <tinymce v-model="content" :height="720" :width="580"></tinymce>
      <span style="font-size: 12px">tip:图片宽度自适应手机屏幕方法：插入图片时宽度设置为100%,并勾选"保持纵横比"</span>
    </div>

    <div class="preview">
      <span style="font-size: 20px;text-align: center; display: inline-block; width: 360px;">实&nbsp;&nbsp;&nbsp;时&nbsp;&nbsp;&nbsp;预&nbsp;&nbsp;&nbsp;览</span>
      <iframe width="100%" :srcdoc="content"
              style="height: 818px; border: 1px solid #cccccc; margin-top: 15px"></iframe>
    </div>
  </div>
</template>

<script>
import Tinymce from '@/components/Tinymce'

export default {
  name: "richText",
  components: {
    Tinymce
  },
  data() {
    return {
      content: '',
    }
  },
  methods: {
    save() {
      let file = new File(this.content.split(''), "content.html", {
        type: "text/html;charset=utf-8",
        lastModified: Date.now()
      });
      this.$store.dispatch('app/AWSFileUpload', file).then((url) => {
        this.infoForm.contentUrl = url;
        this.$store.dispatch("content/articleAdd", this.infoForm).then(() => {
          this.$message.success("文章添加成功");
          this.$router.go(-1);
        })
      });
    }
  }
}
</script>

<style scoped lang="scss">
.content {
  display: flex;

  .preview {
    margin-left: 20px;
    border: #8c939d solid 1px;
    height: 860px;
    width: 360px;
  }
}
</style>
