<!-- eslint-disable vue/no-v-html -->
<!--
 Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.

 https://www.mall4j.com/

 未经允许，不可做商业用途！

 版权所有，侵权必究！
-->
<template>
  <!-- 发布商品：03、编辑商品详情 -->
  <div class="Mall4j posting-product-details">
    <div class="prod-det-box">
      <div class="prod-content">
        <tiny-mce
          ref="tinymce"
          v-model="contentCn"
          :height="600"
        />
      </div>
      <!-- 详情预览 -->
      <div class="details-preview">
        <div class="preview-box-title">
          {{ $t('product.prodInfo.previewDetailPage') }}
        </div>
        <div
          v-rich="contentCn"
          class="preview-con"
        />
      </div>
    </div>
  </div>
</template>

<script setup>

const emit = defineEmits(['updateContent'])
const Data = reactive({
  contentCn: '',
  contentEn: ''
})

const { contentCn } = toRefs(Data)

watch(() => Data.contentCn, (newVal) => {
  emit('updateContent', newVal, 'cn')
})

watch(() => Data.contentEn, (newVal) => {
  emit('updateContent', newVal, 'en')
})

const init = (dataForm) => {
  Data.contentCn = dataForm.detailList[0]?.detail || ''
}

defineExpose({
  init
})

</script>

<style lang="scss" scoped>
.posting-product-details {
  .prod-det-box {
    display: flex;
    justify-content: space-between;
    .prod-content {
      width: 60%;
      margin-right: 30px;
    }

    // 详情预览
    .details-preview {
      width: 40%;
      border: 1px solid #DCDCDC;
      box-sizing: border-box;
      .preview-box-title {
        height: 45px;
        line-height: 45px;
        background: #f9f9f9;
        text-align: center;
        border-bottom: 1px solid #DCDCDC;
      }
      .preview-con {
        height: 540px;
        word-wrap: break-word;
        overflow-y: auto;
        padding: 0 10px;
        box-sizing: border-box;
        :deep(.wscnph){
          vertical-align: middle;
          max-width: 100%;
        }
      }
    }

    @media only screen and (min-width: 1470px){//当屏幕最小1470时
      .preview-con{
        max-height: 580px;
      }
    }
    @media only screen and (max-width:1469px){//当屏幕最大1469时
      .preview-con{
        max-height: 623px;
      }
    }

  }
}
</style>
