demo.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // webpack.demo.js
  2. import Vditor from '../src/index'
  3. // import Vditor from 'vditor'
  4. // import Vditor from '../dist/index.min'
  5. const vditor = new Vditor('vditor', {
  6. height: 200,
  7. width: '50%',
  8. counter: 100,
  9. draggable: true,
  10. placeholder: 'say sth...',
  11. lang: 'en_US',
  12. previewShow: true,
  13. classes: {
  14. preview: 'content-reset',
  15. },
  16. commonEmoji: {
  17. '+1': '👍',
  18. '-1': '👎',
  19. },
  20. focus: (val) => {
  21. console.log(`focus: ${val}`)
  22. },
  23. blur: (val) => {
  24. console.log(`blur: ${val}`)
  25. },
  26. input: (val, mdElement) => {
  27. console.log('change:' + val, mdElement)
  28. },
  29. esc: (val) => {
  30. console.log(`esc: ${val}`)
  31. },
  32. ctrlEnter: (val) => {
  33. console.log(`ctrlEnter: ${val}`)
  34. },
  35. select: (val) => {
  36. console.log(`select: ${val}`)
  37. },
  38. atUser: (key) => {
  39. console.log(`atUser: ${key}`)
  40. return [
  41. {
  42. value: '@88250',
  43. html: '<img src="https://img.hacpai.com/avatar/1353745196354_1535379434567.png?imageView2/1/w/52/h/52/interlace/0/q"> 88250',
  44. },
  45. {
  46. value: '@Vanessa',
  47. html: '<img src="https://img.hacpai.com/avatar/1353745196354_1535379434567.png?imageView2/1/w/52/h/52/interlace/0/q"> Vanessa',
  48. }]
  49. },
  50. toolbar: [
  51. {
  52. name: 'preview',
  53. tipPosition: 'ne',
  54. },
  55. 'br'
  56. , {
  57. name: 'emoji',
  58. tail: '<a href="https://hacpai.com/settings/function" target="_blank">设置常用表情</a>',
  59. },
  60. 'strike',
  61. ],
  62. })
  63. const vditor2 = new Vditor('vditor2')
  64. console.log(vditor2)