registerMenu.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { Boot } from '@wangeditor/editor'
  2. import { exp2pdf } from './exportFile'
  3. console.warn('此插件注册富文本自定义按钮')
  4. // 注册一个保存按钮
  5. class SaveBtn {
  6. title = ''
  7. iconSvg = ''
  8. tag = ''
  9. constructor() {
  10. this.title = '导出PDF'
  11. this.iconSvg = '<svg viewBox="0 0 1024 1024" style="width:22px;height:22px;" version="1.1" xmlns="http://www.w3.org/2000/svg" ><path d="M773.696 134.812444l-509.155556 0c-69.76 0-126.520889 56.760889-126.520889 126.542222l0 501.326222c0 69.781333 56.760889 126.499556 126.520889 126.499556l509.141333 0c69.781333 0 126.520889-56.718222 126.520889-126.499556L900.202667 261.361778C900.202667 191.573333 843.441778 134.833778 773.696 134.812444zM324.437333 184.213333l389.347556 0 0 279.608889L324.437333 463.822222 324.437333 184.213333zM850.872889 762.680889c0 42.552889-34.616889 77.191111-77.169778 77.191111l-509.155556 0c-42.552889 0-77.169778-34.638222-77.169778-77.191111L187.377778 261.383111c0-42.574222 34.616889-77.169778 77.169778-77.169778l0-0.021333 10.567111 0 0 329.009778 488.007111 0 0.021333 0L763.143111 184.184889l10.567111 0c42.56 0 77.169778 34.595556 77.169778 77.169778L850.88 762.680889zM591.772444 256.832l49.329778 0 0 164.522667-49.329778 0 0-164.522667ZM591.772444 256.832"></path></svg>'
  12. this.tag = 'button'
  13. }
  14. getValue() {
  15. return ''
  16. }
  17. isActive() {
  18. return false
  19. }
  20. isDisabled() {
  21. return false
  22. }
  23. exec() {
  24. exp2pdf('exportPDF', '测试' + new Date().toLocaleDateString())
  25. console.log('导出');
  26. }
  27. }
  28. Boot.registerMenu({
  29. key: 'SaveBtn',
  30. factory() {
  31. return new SaveBtn()
  32. }
  33. })