editor.vue 701 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <template>
  2. <div contenteditable ref="editor" v-html="rawText" class="text" @input="input"></div>
  3. </template>
  4. <script>
  5. import '@wangeditor/editor/dist/css/style.css'; // 引入 css
  6. // import { ref, onMounted } from 'vue';
  7. export default {
  8. props: {
  9. rawText: {
  10. type: String,
  11. default: '',
  12. },
  13. },
  14. setup() {},
  15. methods: {
  16. input(e) {
  17. this.$emit('update:rawText', e.target.innerHTML);
  18. },
  19. },
  20. emits: ['update:rawText'],
  21. };
  22. </script>
  23. <style scoped>
  24. .selectSpan {
  25. border-bottom: 3px solid #fff;
  26. }
  27. .text {
  28. height: calc(100vh - 186px);
  29. overflow-y: auto;
  30. outline: none;
  31. padding: 1em;
  32. }
  33. .text img {
  34. margin: 0 auto;
  35. }
  36. .text p {
  37. text-indent: 2em;
  38. }
  39. </style>