props.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import { PropType } from 'vue'
  2. import { ElMessage } from 'element-plus'
  3. import { oneOf } from '@/utils'
  4. import { Config } from './types'
  5. export const editorProps = {
  6. // 基础配置
  7. config: {
  8. type: Object as PropType<Config>,
  9. default: () => {
  10. return {
  11. height: 500,
  12. zIndex: 500,
  13. placeholder: '请输入文本',
  14. focus: false,
  15. onchangeTimeout: 500,
  16. customAlert: (s: string, t: string) => {
  17. switch (t) {
  18. case 'success':
  19. ElMessage.success(s)
  20. break
  21. case 'info':
  22. ElMessage.info(s)
  23. break
  24. case 'warning':
  25. ElMessage.warning(s)
  26. break
  27. case 'error':
  28. ElMessage.error(s)
  29. break
  30. default:
  31. ElMessage.info(s)
  32. break
  33. }
  34. },
  35. menus: [
  36. 'head',
  37. 'bold',
  38. 'fontSize',
  39. 'fontName',
  40. 'italic',
  41. 'underline',
  42. 'strikeThrough',
  43. 'indent',
  44. 'lineHeight',
  45. 'foreColor',
  46. 'backColor',
  47. 'link',
  48. 'list',
  49. 'justify',
  50. 'quote',
  51. 'emoticon',
  52. 'image',
  53. 'video',
  54. 'table',
  55. 'code',
  56. 'splitLine',
  57. 'undo',
  58. 'redo'
  59. ],
  60. colors: [
  61. '#000000',
  62. '#eeece0',
  63. '#1c487f',
  64. '#4d80bf'
  65. ],
  66. fontNames: [
  67. '黑体',
  68. '仿宋',
  69. '楷体',
  70. '标楷体',
  71. '华文仿宋',
  72. '华文楷体',
  73. '宋体',
  74. '微软雅黑',
  75. 'Arial',
  76. 'Tahoma',
  77. 'Verdana',
  78. 'Times New Roman',
  79. 'Courier New'
  80. ],
  81. lineHeights: ['1', '1.15', '1.6', '2', '2.5', '3'],
  82. showFullScreen: true
  83. }
  84. }
  85. },
  86. // 绑定的值的类型, enum: ['html', 'text']
  87. valueType: {
  88. type: String as PropType<string>,
  89. default: 'html',
  90. validator: (val: string) => {
  91. return oneOf(val, ['html', 'text'])
  92. }
  93. },
  94. // 文本内容
  95. value: {
  96. type: String as PropType<string>,
  97. default: ''
  98. }
  99. }