RichTextEdit.vue 1.42 KB
Newer Older
hucy's avatar
hucy committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
<!--
 * System ReceiveBatch page
 * @author: Toplinker
 * @copyright: ©2009-2022 Toplinker, Inc. All rights reserved
-->
<script setup lang="ts">
import { ref } from 'vue';
import { useMessage } from 'src/common/hooks';
// interface IDetailProps {
//   type: string;
//   data: any;
// }
// const props = withDefaults(defineProps<IDetailProps>(), {
//   type: '',
//   data: {},
// });

const { info } = useMessage();

const editor = ref('What you see is <b>what</b> you get.');

function getView() {
  console.log('editor >>>>', editor.value);
}

function saveWork() {
  info('保存');
  console.log('保存 >>>>', editor.value);
}

function uploadIt() {
  info('上传文件');
}
</script>
<template>
  <div class="my-editor">
    <q-btn label="点我查看" @click="getView" />
    <q-card flat bordered>
      <q-card-section v-html="editor" />
    </q-card>
    <q-editor
      v-model="editor"
      :definitions="{
        save: {
          tip: '保存',
          icon: 'save',
          label: '保存',
          handler: saveWork
        },
        upload: {
          tip: '上传文件',
          icon: 'cloud_upload',
          label: '上传文件',
          handler: uploadIt
        }
      } as any"
      :toolbar="[
        ['bold', 'italic', 'strike', 'underline'],
        ['upload', 'save'],
      ]"
      min-height="20rem"
    />
  </div>
</template>

<style lang="scss" scoped>
.my-editor {
  border: 1px solid red;
}
</style>