static.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <!DOCTYPE html>
  2. <html lang="zh-cmn-Hans">
  3. <head>
  4. <meta charset="utf-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
  7. <meta name="theme-color" content="#f1f7fe">
  8. <meta name="apple-mobile-web-app-capable" content="yes">
  9. <meta name="mobile-web-app-capable" content="yes"/>
  10. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  11. <title>Vditor - A markdown editor written in TypeScript.</title>
  12. <meta name="description"
  13. content="B3log 开源社区 markdown 编辑器,使用 TypeScript 编写。支持在线预览、表情插入、at 用户提示、HTML 转换等必要功能。"/>
  14. <meta property="og:description"
  15. content="B3log 开源社区 markdown 编辑器,使用 TypeScript 编写。支持在线预览、表情插入、at 用户提示、HTML 转换等必要功能。"/>
  16. <meta name="twitter:description" property="og:description" itemprop="description"
  17. content="B3log 开源社区 markdown 编辑器,使用 TypeScript 编写。支持在线预览、表情插入、at 用户提示、HTML 转换等必要功能。"/>
  18. <link rel="dns-prefetch" href="//cdn.jsdelivr.net/"/>
  19. <link rel="preconnect" href="https://cdn.jsdelivr.net">
  20. <link rel="icon" type="image/png" href="https://cdn.jsdelivr.net/npm/vditor/dist/images/logo.png"/>
  21. <link rel="apple-touch-icon" href="https://cdn.jsdelivr.net/npm/vditor/dist/images/logo.png">
  22. <link rel="shortcut icon" type="image/x-icon" href="https://cdn.jsdelivr.net/npm/vditor/dist/images/logo.png">
  23. <meta name="copyright" content="B3log"/>
  24. <meta http-equiv="Window-target" content="_top"/>
  25. <meta property="og:locale" content="zh-cmn-Hans"/>
  26. <meta property="og:title" content="Vditor - A markdown editor written in TypeScript."/>
  27. <meta property="og:site_name" content="Blog-vditor"/>
  28. <meta property="og:url" content="https://hacpai.com/tag/vditor"/>
  29. <meta name="twitter:card" content="summary"/>
  30. <meta name="twitter:domain" content="b3log.org"/>
  31. <meta name="twitter:title" property="og:title" itemprop="b3lig vditor"
  32. content="Vditor - A markdown editor written in TypeScript."/>
  33. <meta name="twitter:site" content="@B3logOS"/>
  34. <meta name="twitter:url" content="https://hacpai.com/tag/vditor"/>
  35. <meta property="og:image" content="https://cdn.jsdelivr.net/npm/vditor/dist/images/logo.png"/>
  36. <meta name="twitter:image" content="https://cdn.jsdelivr.net/npm/vditor/dist/images/logo.png"/>
  37. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.css"/>
  38. <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.min.js"></script>
  39. <style>
  40. a {
  41. color: #4285f4;
  42. }
  43. </style>
  44. </head>
  45. <body>
  46. <h2>
  47. <a href="https://hacpai.com/article/1549638745630?r=Vanessa" target="_blank">API</a> |
  48. <a href="static-preview.html?lang=zh_CN">中文预览</a>
  49. <a href="static-preview.html?lang=ko_KR">한글预览</a> |
  50. <button onclick="window.vditor.setTheme('dark', 'dark', 'native');document.querySelector('body').style.backgroundColor='#2f363d'">Dark Mode</button>
  51. <button onclick="window.vditor.setTheme('light', 'light', 'github');document.querySelector('body').style.backgroundColor=''">Light Mode</button>
  52. </h2>
  53. <div id="vditor">
  54. <h1>Vditor</h1>
  55. <ul>
  56. <li>foo</li>
  57. <li>bar</li>
  58. </ul>
  59. </div>
  60. <script>
  61. let toolbar
  62. if (window.innerWidth < 768) {
  63. toolbar = [
  64. 'emoji',
  65. 'headings',
  66. 'bold',
  67. 'italic',
  68. 'strike',
  69. 'link',
  70. '|',
  71. 'list',
  72. 'ordered-list',
  73. 'check',
  74. 'outdent',
  75. 'indent',
  76. '|',
  77. 'quote',
  78. 'line',
  79. 'code',
  80. 'inline-code',
  81. 'insert-before',
  82. 'insert-after',
  83. '|',
  84. 'upload',
  85. 'record',
  86. 'table',
  87. '|',
  88. 'undo',
  89. 'redo',
  90. '|',
  91. 'edit-mode',
  92. 'content-theme',
  93. 'code-theme',
  94. {
  95. name: 'more',
  96. toolbar: [
  97. 'fullscreen',
  98. 'both',
  99. 'format',
  100. 'preview',
  101. 'info',
  102. 'help',
  103. ],
  104. }]
  105. }
  106. window.vditor = new Vditor('vditor', {
  107. toolbar,
  108. debugger: true,
  109. typewriterMode: true,
  110. placeholder: 'placeholder',
  111. preview: {
  112. markdown: {
  113. toc: true,
  114. },
  115. },
  116. toolbarConfig: {
  117. pin: true,
  118. },
  119. counter: {
  120. enable: true,
  121. type: 'text',
  122. },
  123. hint: {
  124. emojiPath: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/images/emoji',
  125. emojiTail: '<a href="https://hacpai.com/settings/function" target="_blank">设置常用表情</a>',
  126. emoji: {
  127. 'sd': '💔',
  128. 'j': 'https://unpkg.com/[email protected]/dist/images/emoji/j.png',
  129. },
  130. },
  131. tab: '\t',
  132. upload: {
  133. accept: 'image/*,.mp3, .wav, .rar',
  134. token: 'test',
  135. url: '/api/upload/editor',
  136. linkToImgUrl: '/api/upload/fetch',
  137. filename (name) {
  138. return name.replace(/[^(a-zA-Z0-9\u4e00-\u9fa5\.)]/g, '').
  139. replace(/[\?\\/:|<>\*\[\]\(\)\$%\{\}@~]/g, '').
  140. replace('/\\s/g', '')
  141. },
  142. },
  143. })
  144. </script>
  145. </body>
  146. </html>