<template>
  <EditorMD
    v-if="content_type === 'markdown'"
    v-bind="{ ...$props, content_type: undefined }"
    :uploadFile="uploadFile"
    @update:modelValue="(value: any) => emit('update:modelValue', value)"
  />
  <TinyMCE
    v-if="content_type === 'rich_text'"
    v-bind="{ ...$props, content_type: undefined }"
    :uploadFile="uploadFile"
    @update:modelValue="(value: any) => emit('update:modelValue', value)"
  />
</template>

<script setup lang="ts" name="MyEditor">
import { withDefaults } from 'vue';
import { uploadFile } from '../MyUpload/api';

import EditorMD from './EditorMD.vue';
import TinyMCE from './TinyMCE.vue';

interface Props {
  modelValue?: string;
  placeholder?: string;
  height?: number;
  type?: string;
  usageType?: string;
  uploadFile?: Function;

  // export const CONTENT_TYPE_OPTIONS = [
  //   { label: t('pages.memoryRecognitionKnowledge.content_type_enums.rich_text'), value: 'rich_text' },
  //   { label: t('pages.memoryRecognitionKnowledge.content_type_enums.markdown'), value: 'markdown' },
  // ];

  // <t-col :span="8">
  //   <t-form-item :label="$t('pages.memoryRecognitionKnowledge.formBase.content_type')" name="content_type">
  //     <t-radio-group
  //       v-model="formData.content_type"
  //       :default-value="'rich_text'"
  //       name="mode"
  //       :options="CONTENT_TYPE_OPTIONS"
  //       @change="() => {}"
  //     >
  //     </t-radio-group>
  //   </t-form-item>
  // </t-col>
  content_type?: string; // rich_text, markdown
}
const props = withDefaults(defineProps<Props>(), {
  content_type: 'rich_text',
});
const emit = defineEmits(['update:modelValue']);
</script>
