@cherry-markdown/cherry-markdown-dev 0.9.0-dev.202504110650.834443a → 0.9.0-dev.202504160300.d23d141

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/README.md +2 -2
  2. package/dist/addons/advance/cherry-table-echarts-plugin.js +1 -1
  3. package/dist/addons/cherry-code-block-mermaid-plugin.js +1 -1
  4. package/dist/cherry-markdown.core.common.js +1 -1
  5. package/dist/cherry-markdown.core.js +1 -1
  6. package/dist/cherry-markdown.engine.core.common.js +1 -1
  7. package/dist/cherry-markdown.engine.core.esm.js +1 -1
  8. package/dist/cherry-markdown.engine.core.js +1 -1
  9. package/dist/cherry-markdown.esm.js +1 -1
  10. package/dist/cherry-markdown.js +1 -1
  11. package/dist/cherry-markdown.min.js +1 -1
  12. package/dist/fonts/ch-icon.eot +0 -0
  13. package/dist/fonts/ch-icon.ttf +0 -0
  14. package/dist/fonts/ch-icon.woff +0 -0
  15. package/dist/fonts/ch-icon.woff2 +0 -0
  16. package/package.json +1 -3
  17. package/src/Cherry.config.js +0 -634
  18. package/src/Cherry.js +0 -1104
  19. package/src/CherryStatic.js +0 -70
  20. package/src/Editor.js +0 -748
  21. package/src/Engine.js +0 -402
  22. package/src/Event.js +0 -140
  23. package/src/Factory.js +0 -180
  24. package/src/Logger.js +0 -31
  25. package/src/Previewer.js +0 -1192
  26. package/src/Sanitizer.js +0 -4
  27. package/src/Sanitizer.node.js +0 -7
  28. package/src/UrlCache.js +0 -98
  29. package/src/addons/advance/cherry-table-echarts-plugin.js +0 -170
  30. package/src/addons/cherry-code-block-mermaid-plugin.js +0 -158
  31. package/src/addons/cherry-code-block-plantuml-plugin.js +0 -106
  32. package/src/core/HookCenter.js +0 -297
  33. package/src/core/HooksConfig.js +0 -105
  34. package/src/core/ParagraphBase.js +0 -332
  35. package/src/core/SentenceBase.js +0 -65
  36. package/src/core/SyntaxBase.js +0 -194
  37. package/src/core/hooks/AutoLink.js +0 -232
  38. package/src/core/hooks/BackgroundColor.js +0 -46
  39. package/src/core/hooks/Blockquote.js +0 -70
  40. package/src/core/hooks/Br.js +0 -85
  41. package/src/core/hooks/CodeBlock.js +0 -456
  42. package/src/core/hooks/Color.js +0 -46
  43. package/src/core/hooks/CommentReference.js +0 -96
  44. package/src/core/hooks/Detail.js +0 -108
  45. package/src/core/hooks/Emoji.config.js +0 -1825
  46. package/src/core/hooks/Emoji.js +0 -119
  47. package/src/core/hooks/Emphasis.js +0 -113
  48. package/src/core/hooks/Footnote.js +0 -125
  49. package/src/core/hooks/FrontMatter.js +0 -51
  50. package/src/core/hooks/Header.js +0 -234
  51. package/src/core/hooks/HighLight.js +0 -37
  52. package/src/core/hooks/Hr.js +0 -52
  53. package/src/core/hooks/HtmlBlock.js +0 -199
  54. package/src/core/hooks/Image.js +0 -174
  55. package/src/core/hooks/InlineCode.js +0 -48
  56. package/src/core/hooks/InlineMath.js +0 -108
  57. package/src/core/hooks/Link.js +0 -160
  58. package/src/core/hooks/List.js +0 -264
  59. package/src/core/hooks/MathBlock.js +0 -104
  60. package/src/core/hooks/Panel.js +0 -145
  61. package/src/core/hooks/Paragraph.js +0 -84
  62. package/src/core/hooks/Ruby.js +0 -34
  63. package/src/core/hooks/Size.js +0 -51
  64. package/src/core/hooks/Strikethrough.js +0 -54
  65. package/src/core/hooks/Sub.js +0 -47
  66. package/src/core/hooks/SuggestList.js +0 -333
  67. package/src/core/hooks/Suggester.js +0 -707
  68. package/src/core/hooks/Sup.js +0 -47
  69. package/src/core/hooks/Table.js +0 -275
  70. package/src/core/hooks/Toc.js +0 -292
  71. package/src/core/hooks/Transfer.js +0 -47
  72. package/src/core/hooks/Underline.js +0 -37
  73. package/src/index.core.js +0 -29
  74. package/src/index.engine.core.js +0 -68
  75. package/src/index.engine.js +0 -28
  76. package/src/index.js +0 -32
  77. package/src/libs/mermaidAPI.8.4.8.js +0 -1
  78. package/src/libs/mermaidAPI.8.5.2.js +0 -42
  79. package/src/libs/rawdeflate.js +0 -1663
  80. package/src/locales/en_US.js +0 -139
  81. package/src/locales/index.js +0 -25
  82. package/src/locales/ru_RU.js +0 -139
  83. package/src/locales/zh_CN.js +0 -142
  84. package/src/sass/base.scss +0 -26
  85. package/src/sass/bubble_formula.scss +0 -166
  86. package/src/sass/ch-icon.scss +0 -118
  87. package/src/sass/cherry.scss +0 -1116
  88. package/src/sass/components/bubble.scss +0 -173
  89. package/src/sass/components/shortcut_key_config.scss +0 -108
  90. package/src/sass/formula_utils_bubble.scss +0 -82
  91. package/src/sass/icon_template.scss +0 -24
  92. package/src/sass/icons/uEA03-list.svg +0 -19
  93. package/src/sass/icons/uEA04-check.svg +0 -14
  94. package/src/sass/icons/uEA09-square.svg +0 -10
  95. package/src/sass/icons/uEA0A-bold.svg +0 -20
  96. package/src/sass/icons/uEA0B-code.svg +0 -18
  97. package/src/sass/icons/uEA0C-color.svg +0 -13
  98. package/src/sass/icons/uEA0D-header.svg +0 -8
  99. package/src/sass/icons/uEA0E-image.svg +0 -15
  100. package/src/sass/icons/uEA0F-italic.svg +0 -8
  101. package/src/sass/icons/uEA10-link.svg +0 -16
  102. package/src/sass/icons/uEA11-ol.svg +0 -21
  103. package/src/sass/icons/uEA12-size.svg +0 -11
  104. package/src/sass/icons/uEA13-strike.svg +0 -16
  105. package/src/sass/icons/uEA14-table.svg +0 -12
  106. package/src/sass/icons/uEA15-ul.svg +0 -17
  107. package/src/sass/icons/uEA16-underline.svg +0 -13
  108. package/src/sass/icons/uEA17-word.svg +0 -16
  109. package/src/sass/icons/uEA18-blockquote.svg +0 -11
  110. package/src/sass/icons/uEA19-font.svg +0 -10
  111. package/src/sass/icons/uEA1F-insertClass.svg +0 -39
  112. package/src/sass/icons/uEA20-insertFlow.svg +0 -8
  113. package/src/sass/icons/uEA21-insertFormula.svg +0 -23
  114. package/src/sass/icons/uEA22-insertGantt.svg +0 -13
  115. package/src/sass/icons/uEA23-insertGraph.svg +0 -13
  116. package/src/sass/icons/uEA24-insertPie.svg +0 -19
  117. package/src/sass/icons/uEA25-insertSeq.svg +0 -20
  118. package/src/sass/icons/uEA26-insertState.svg +0 -35
  119. package/src/sass/icons/uEA27-line.svg +0 -11
  120. package/src/sass/icons/uEA28-preview.svg +0 -18
  121. package/src/sass/icons/uEA29-previewClose.svg +0 -24
  122. package/src/sass/icons/uEA2A-toc.svg +0 -24
  123. package/src/sass/icons/uEA2D-sub.svg +0 -15
  124. package/src/sass/icons/uEA2E-sup.svg +0 -15
  125. package/src/sass/icons/uEA2F-h1.svg +0 -16
  126. package/src/sass/icons/uEA30-h2.svg +0 -20
  127. package/src/sass/icons/uEA31-h3.svg +0 -23
  128. package/src/sass/icons/uEA32-h4.svg +0 -16
  129. package/src/sass/icons/uEA33-h5.svg +0 -20
  130. package/src/sass/icons/uEA34-h6.svg +0 -17
  131. package/src/sass/icons/uEA35-video.svg +0 -20
  132. package/src/sass/icons/uEA36-insert.svg +0 -25
  133. package/src/sass/icons/uEA37-little_table.svg +0 -30
  134. package/src/sass/icons/uEA38-pdf.svg +0 -27
  135. package/src/sass/icons/uEA39-checklist.svg +0 -22
  136. package/src/sass/icons/uEA40-close.svg +0 -12
  137. package/src/sass/icons/uEA41-fullscreen.svg +0 -81
  138. package/src/sass/icons/uEA42-minscreen.svg +0 -77
  139. package/src/sass/icons/uEA43-insertChart.svg +0 -23
  140. package/src/sass/icons/uEA44-question.svg +0 -25
  141. package/src/sass/icons/uEA45-settings.svg +0 -32
  142. package/src/sass/icons/uEA46-ok.svg +0 -7
  143. package/src/sass/icons/uEA47-br.svg +0 -22
  144. package/src/sass/icons/uEA48-normal.svg +0 -15
  145. package/src/sass/icons/uEA49-undo.svg +0 -19
  146. package/src/sass/icons/uEA50-redo.svg +0 -21
  147. package/src/sass/icons/uEA51-copy.svg +0 -6
  148. package/src/sass/icons/uEA52-phone.svg +0 -5
  149. package/src/sass/icons/uEA53-cherry-table-delete.svg +0 -17
  150. package/src/sass/icons/uEA54-cherry-table-insert-bottom.svg +0 -16
  151. package/src/sass/icons/uEA55-cherry-table-insert-left.svg +0 -15
  152. package/src/sass/icons/uEA56-cherry-table-insert-right.svg +0 -16
  153. package/src/sass/icons/uEA57-cherry-table-insert-top.svg +0 -16
  154. package/src/sass/icons/uEA58-sort-s.svg +0 -13
  155. package/src/sass/icons/uEA59-pinyin.svg +0 -1
  156. package/src/sass/icons/uEA5A-create.svg +0 -24
  157. package/src/sass/icons/uEA5B-download.svg +0 -34
  158. package/src/sass/icons/uEA5C-edit.svg +0 -3
  159. package/src/sass/icons/uEA5D-export.svg +0 -53
  160. package/src/sass/icons/uEA5E-folder-open.svg +0 -3
  161. package/src/sass/icons/uEA5F-folder.svg +0 -3
  162. package/src/sass/icons/uEA60-help.svg +0 -5
  163. package/src/sass/icons/uEA61-pen-fill.svg +0 -13
  164. package/src/sass/icons/uEA62-pen.svg +0 -3
  165. package/src/sass/icons/uEA64-tips.svg +0 -5
  166. package/src/sass/icons/uEA65-warn.svg +0 -5
  167. package/src/sass/icons/uEA66-mistake.svg +0 -4
  168. package/src/sass/icons/uEA67-success.svg +0 -4
  169. package/src/sass/icons/uEA68-danger.svg +0 -4
  170. package/src/sass/icons/uEA69-info.svg +0 -5
  171. package/src/sass/icons/uEA6A-primary.svg +0 -5
  172. package/src/sass/icons/uEA6B-warning.svg +0 -5
  173. package/src/sass/icons/uEA6C-justify.svg +0 -19
  174. package/src/sass/icons/uEA6D-justifyCenter.svg +0 -19
  175. package/src/sass/icons/uEA6E-justifyLeft.svg +0 -19
  176. package/src/sass/icons/uEA6F-justifyRight.svg +0 -19
  177. package/src/sass/icons/uEA70-chevronsLeft.svg +0 -1
  178. package/src/sass/icons/uEA71-chevronsRight.svg +0 -1
  179. package/src/sass/icons/uEA72-trendingUp.svg +0 -1
  180. package/src/sass/icons/uEA74-codeBlock.svg +0 -1
  181. package/src/sass/icons/uEA75-expand.svg +0 -3
  182. package/src/sass/icons/uEA76-unExpand.svg +0 -3
  183. package/src/sass/icons/uEA77-swap-vert.svg +0 -1
  184. package/src/sass/icons/uEA78-swap.svg +0 -1
  185. package/src/sass/icons/uEA79-keyboard.svg +0 -1
  186. package/src/sass/icons/uEA7A-command.svg +0 -1
  187. package/src/sass/icons/uEA7B-search.svg +0 -1
  188. package/src/sass/index.scss +0 -3
  189. package/src/sass/markdown.scss +0 -668
  190. package/src/sass/markdown_pure.scss +0 -9
  191. package/src/sass/prettyprint/prettyprint.scss +0 -118
  192. package/src/sass/previewer.scss +0 -179
  193. package/src/sass/print.scss +0 -13
  194. package/src/sass/prism/coy.scss +0 -220
  195. package/src/sass/prism/dark.scss +0 -132
  196. package/src/sass/prism/default.scss +0 -143
  197. package/src/sass/prism/funky.scss +0 -133
  198. package/src/sass/prism/okaidia.scss +0 -126
  199. package/src/sass/prism/one-dark.scss +0 -440
  200. package/src/sass/prism/one-light.scss +0 -428
  201. package/src/sass/prism/solarized-light.scss +0 -153
  202. package/src/sass/prism/tomorrow-night.scss +0 -125
  203. package/src/sass/prism/twilight.scss +0 -202
  204. package/src/sass/prism/vs-dark.scss +0 -275
  205. package/src/sass/prism/vs-light.scss +0 -168
  206. package/src/sass/themes/blue.scss +0 -411
  207. package/src/sass/themes/dark.scss +0 -517
  208. package/src/sass/themes/default.scss +0 -255
  209. package/src/sass/themes/green.scss +0 -395
  210. package/src/sass/themes/light.scss +0 -368
  211. package/src/sass/themes/red.scss +0 -397
  212. package/src/sass/themes/violet.scss +0 -410
  213. package/src/sass/variable.scss +0 -84
  214. package/src/toolbars/Bubble.js +0 -234
  215. package/src/toolbars/BubbleFormula.js +0 -298
  216. package/src/toolbars/BubbleTable.js +0 -147
  217. package/src/toolbars/FloatMenu.js +0 -131
  218. package/src/toolbars/HiddenToolbar.js +0 -36
  219. package/src/toolbars/HookCenter.js +0 -231
  220. package/src/toolbars/MenuBase.js +0 -569
  221. package/src/toolbars/PreviewerBubble.js +0 -608
  222. package/src/toolbars/ShortcutKeyConfigPanel.js +0 -345
  223. package/src/toolbars/Sidebar.js +0 -36
  224. package/src/toolbars/Toc.js +0 -242
  225. package/src/toolbars/Toolbar.js +0 -449
  226. package/src/toolbars/ToolbarRight.js +0 -37
  227. package/src/toolbars/hooks/Audio.js +0 -79
  228. package/src/toolbars/hooks/BarTable.js +0 -41
  229. package/src/toolbars/hooks/Bold.js +0 -73
  230. package/src/toolbars/hooks/Br.js +0 -34
  231. package/src/toolbars/hooks/ChangeLocale.js +0 -62
  232. package/src/toolbars/hooks/ChatGpt.js +0 -182
  233. package/src/toolbars/hooks/CheckList.js +0 -41
  234. package/src/toolbars/hooks/Code.js +0 -49
  235. package/src/toolbars/hooks/CodeTheme.js +0 -66
  236. package/src/toolbars/hooks/Color.js +0 -298
  237. package/src/toolbars/hooks/Copy.js +0 -141
  238. package/src/toolbars/hooks/Detail.js +0 -69
  239. package/src/toolbars/hooks/DrawIo.js +0 -57
  240. package/src/toolbars/hooks/Export.js +0 -49
  241. package/src/toolbars/hooks/File.js +0 -79
  242. package/src/toolbars/hooks/Formula.js +0 -69
  243. package/src/toolbars/hooks/FullScreen.js +0 -50
  244. package/src/toolbars/hooks/Graph.js +0 -263
  245. package/src/toolbars/hooks/H1.js +0 -71
  246. package/src/toolbars/hooks/H2.js +0 -71
  247. package/src/toolbars/hooks/H3.js +0 -71
  248. package/src/toolbars/hooks/Header.js +0 -118
  249. package/src/toolbars/hooks/Hr.js +0 -35
  250. package/src/toolbars/hooks/Image.js +0 -91
  251. package/src/toolbars/hooks/InlineCode.js +0 -53
  252. package/src/toolbars/hooks/Insert.js +0 -193
  253. package/src/toolbars/hooks/Italic.js +0 -72
  254. package/src/toolbars/hooks/Justify.js +0 -49
  255. package/src/toolbars/hooks/LineTable.js +0 -41
  256. package/src/toolbars/hooks/Link.js +0 -49
  257. package/src/toolbars/hooks/List.js +0 -55
  258. package/src/toolbars/hooks/MobilePreview.js +0 -44
  259. package/src/toolbars/hooks/Ol.js +0 -41
  260. package/src/toolbars/hooks/Panel.js +0 -140
  261. package/src/toolbars/hooks/Pdf.js +0 -78
  262. package/src/toolbars/hooks/Publish.js +0 -123
  263. package/src/toolbars/hooks/QuickTable.js +0 -43
  264. package/src/toolbars/hooks/Quote.js +0 -45
  265. package/src/toolbars/hooks/Redo.js +0 -33
  266. package/src/toolbars/hooks/Ruby.js +0 -59
  267. package/src/toolbars/hooks/Search.js +0 -53
  268. package/src/toolbars/hooks/Settings.js +0 -220
  269. package/src/toolbars/hooks/ShortcutKey.js +0 -62
  270. package/src/toolbars/hooks/Size.js +0 -118
  271. package/src/toolbars/hooks/Split.js +0 -37
  272. package/src/toolbars/hooks/Strikethrough.js +0 -71
  273. package/src/toolbars/hooks/Sub.js +0 -58
  274. package/src/toolbars/hooks/Sup.js +0 -58
  275. package/src/toolbars/hooks/SwitchModel.js +0 -56
  276. package/src/toolbars/hooks/Table.js +0 -56
  277. package/src/toolbars/hooks/Theme.js +0 -62
  278. package/src/toolbars/hooks/Toc.js +0 -35
  279. package/src/toolbars/hooks/TogglePreview.js +0 -91
  280. package/src/toolbars/hooks/Ul.js +0 -41
  281. package/src/toolbars/hooks/Underline.js +0 -68
  282. package/src/toolbars/hooks/Undo.js +0 -30
  283. package/src/toolbars/hooks/Video.js +0 -79
  284. package/src/toolbars/hooks/Word.js +0 -78
  285. package/src/toolbars/hooks/WordCount.js +0 -106
  286. package/src/utils/autoindent.js +0 -58
  287. package/src/utils/cm-search-replace.js +0 -794
  288. package/src/utils/code-preview-language-setting.js +0 -180
  289. package/src/utils/codeBlockContentHandler.js +0 -400
  290. package/src/utils/config.js +0 -174
  291. package/src/utils/copy.js +0 -55
  292. package/src/utils/dialog.js +0 -214
  293. package/src/utils/dom.js +0 -163
  294. package/src/utils/downloadUtil.js +0 -23
  295. package/src/utils/env.js +0 -22
  296. package/src/utils/error.js +0 -61
  297. package/src/utils/event.js +0 -38
  298. package/src/utils/export.js +0 -166
  299. package/src/utils/file.js +0 -164
  300. package/src/utils/formulaUtilsHandler.js +0 -232
  301. package/src/utils/htmlparser.js +0 -976
  302. package/src/utils/image.js +0 -99
  303. package/src/utils/imgSizeHandler.js +0 -279
  304. package/src/utils/lazyLoadImg.js +0 -327
  305. package/src/utils/lineFeed.js +0 -49
  306. package/src/utils/listContentHandler.js +0 -227
  307. package/src/utils/lookbehind-replace.js +0 -81
  308. package/src/utils/mathjax.js +0 -89
  309. package/src/utils/myersDiff.js +0 -211
  310. package/src/utils/pasteHelper.js +0 -253
  311. package/src/utils/platformTransform.js +0 -71
  312. package/src/utils/recount-pos.js +0 -59
  313. package/src/utils/regexp.js +0 -295
  314. package/src/utils/sanitize.js +0 -477
  315. package/src/utils/selection.js +0 -50
  316. package/src/utils/shortcutKey.js +0 -291
  317. package/src/utils/svgUtils.js +0 -96
  318. package/src/utils/tableContentHandler.js +0 -876
  319. package/test/core/CommonMark.spec.ts +0 -62
  320. package/test/core/hooks/AutoLink.spec.ts +0 -28
  321. package/test/core/hooks/List.spec.ts +0 -79
  322. package/test/core/hooks/__snapshots__/List.spec.ts.snap +0 -11
  323. package/test/example.md +0 -778
  324. package/test/node.js +0 -10
  325. package/test/suites/commonmark.spec.json +0 -5218
  326. package/test/tsconfig.test.json +0 -6
  327. package/test/utils/regexp.spec.ts +0 -28
@@ -1,84 +0,0 @@
1
- /**
2
- * Copyright (C) 2021 THL A29 Limited, a Tencent company.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import ParagraphBase from '@/core/ParagraphBase';
17
- import { blockNames } from '@/utils/sanitize';
18
- /**
19
- * 段落级语法
20
- * 段落级语法可以具备以下特性:
21
- * 1、排他性,可以排除将当前语法之后的所有段落语法
22
- * 2、可排序,在../HooksConfig.js里设置排序,顺序在前面的段落语法先渲染
23
- * 3、可嵌套行内语法
24
- *
25
- * 段落级语法有以下义务:
26
- * 1、维护签名,签名用来实现预览区域的局部更新功能
27
- * 2、维护行号,行号用来实现编辑区和预览区同步滚动
28
- * 每个段落语法负责计算上文的行号,上文行号不是0就是1,大于1会由BR语法计算行号
29
- */
30
- export default class Paragraph extends ParagraphBase {
31
- static HOOK_NAME = 'normalParagraph';
32
-
33
- constructor(options) {
34
- super();
35
- this.initBrReg(options.globalConfig.classicBr);
36
- }
37
-
38
- /**
39
- * 段落语法的核心渲染函数
40
- * @param {string} str markdown源码
41
- * @param {Function} sentenceMakeFunc 行内语法渲染器
42
- * @returns {string} html内容
43
- */
44
- makeHtml(str, sentenceMakeFunc) {
45
- if (!this.test(str)) {
46
- return str;
47
- }
48
- return str.replace(this.RULE.reg, (match, preLines, content) => {
49
- if (this.isContainsCache(match, true)) {
50
- return match;
51
- }
52
- // 判断当前内容里是否包含段落渲染引擎暂存缓存关键字
53
- const cacheMixedInMatches = this.isContainsCache(content);
54
- const processor = (p) => {
55
- if (p.trim() === '') {
56
- return '';
57
- }
58
- // 调用行内语法,获得段落的签名和对应html内容
59
- const { sign, html } = sentenceMakeFunc(p);
60
- let domName = 'p';
61
- // 如果包含html块级标签(比如div、blockquote等),则当前段落外层用div包裹,反之用p包裹
62
- const isContainBlockTest = new RegExp(`<(${blockNames})[^>]*>`, 'i');
63
- if (isContainBlockTest.test(html)) {
64
- domName = 'div';
65
- }
66
- // 计算行号
67
- const lines = this.getLineCount(p, p);
68
- return `<${domName} data-sign="${sign}${lines}" data-type="${domName}" data-lines="${lines}">${this.$cleanParagraph(
69
- html,
70
- )}</${domName}>`;
71
- };
72
- if (cacheMixedInMatches) {
73
- return this.makeExcludingCached(`${preLines}${content}`, processor);
74
- }
75
- return processor(`${preLines}${content}`);
76
- });
77
- }
78
-
79
- rule() {
80
- const ret = { begin: '(?:^|\\n)(\\n*)', end: '(?=\\s*$|\\n\\n)', content: '([\\s\\S]+?)' };
81
- ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
82
- return ret;
83
- }
84
- }
@@ -1,34 +0,0 @@
1
- /**
2
- * Copyright (C) 2021 THL A29 Limited, a Tencent company.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import SyntaxBase from '@/core/SyntaxBase';
17
-
18
- // 拼音语法
19
- export default class Ruby extends SyntaxBase {
20
- static HOOK_NAME = 'ruby';
21
-
22
- makeHtml(str) {
23
- if (!this.test(str)) {
24
- return str;
25
- }
26
- return str.replace(this.RULE.reg, `$1<ruby>$2<rt>$3</rt></ruby>$4`);
27
- }
28
-
29
- rule() {
30
- const ret = { begin: '(^| )\\{', end: '\\}( |$)', content: '([^\n]+?)\\|([^\n]+?)' };
31
- ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
32
- return ret;
33
- }
34
- }
@@ -1,51 +0,0 @@
1
- /**
2
- * Copyright (C) 2021 THL A29 Limited, a Tencent company.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import SyntaxBase from '@/core/SyntaxBase';
17
- import { isLookbehindSupported } from '@/utils/regexp';
18
- import { replaceLookbehind } from '@/utils/lookbehind-replace';
19
-
20
- export default class Size extends SyntaxBase {
21
- static HOOK_NAME = 'fontSize';
22
-
23
- // constructor() {
24
- // super();
25
- // }
26
-
27
- toHtml(whole, m1, m2, m3) {
28
- return `${m1}<span style="font-size:${m2}px;line-height:1em;">${m3}</span>`;
29
- }
30
-
31
- makeHtml(str) {
32
- if (!this.test(str)) {
33
- return str;
34
- }
35
-
36
- if (isLookbehindSupported()) {
37
- return str.replace(this.RULE.reg, this.toHtml);
38
- }
39
- return replaceLookbehind(str, this.RULE.reg, this.toHtml, true, 1);
40
- }
41
-
42
- rule() {
43
- const ret = {
44
- begin: isLookbehindSupported() ? '((?<!\\\\))!' : '(^|[^\\\\])!',
45
- end: '!',
46
- content: '([0-9]{1,2})[\\s]([\\w\\W]*?)',
47
- };
48
- ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
49
- return ret;
50
- }
51
- }
@@ -1,54 +0,0 @@
1
- /**
2
- * Copyright (C) 2021 THL A29 Limited, a Tencent company.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import SyntaxBase from '@/core/SyntaxBase';
17
- /**
18
- * 删除线语法
19
- */
20
- export default class Strikethrough extends SyntaxBase {
21
- static HOOK_NAME = 'strikethrough';
22
-
23
- constructor({ config } = { config: undefined }) {
24
- super({ config });
25
- if (!config) {
26
- return;
27
- }
28
- this.needWhitespace = !!config.needWhitespace;
29
- }
30
-
31
- /**
32
- * 主要逻辑
33
- * @param {string} str markdown源码
34
- * @returns {string} html内容
35
- */
36
- makeHtml(str) {
37
- if (!this.test(str)) {
38
- return str;
39
- }
40
- return str.replace(this.RULE.reg, '$1<del>$2</del>');
41
- }
42
-
43
- rule({ config } = { config: undefined }) {
44
- /** @type {import('~types/syntax').BasicHookRegexpRule} */
45
- let ret = /** @type {any} */ ({});
46
- if (!!config.needWhitespace) {
47
- ret = { ...ret, begin: '(^|[\\s])\\~T\\~T', end: '\\~T\\~T(?=\\s|$)', content: '([\\w\\W]+?)' };
48
- } else {
49
- ret = { ...ret, begin: '(^|[^\\\\])\\~T\\~T', end: '\\~T\\~T', content: '([\\w\\W]+?)' };
50
- }
51
- ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
52
- return ret;
53
- }
54
- }
@@ -1,47 +0,0 @@
1
- /**
2
- * Copyright (C) 2021 THL A29 Limited, a Tencent company.
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- import SyntaxBase from '@/core/SyntaxBase';
17
- import { isLookbehindSupported } from '@/utils/regexp';
18
- import { replaceLookbehind } from '@/utils/lookbehind-replace';
19
-
20
- export default class Sub extends SyntaxBase {
21
- static HOOK_NAME = 'sub';
22
-
23
- // constructor() {
24
- // super();
25
- // }
26
-
27
- toHtml(whole, leadingChar, m1) {
28
- return `${leadingChar}<sub>${m1}</sub>`;
29
- }
30
-
31
- makeHtml(str) {
32
- if (isLookbehindSupported()) {
33
- return str.replace(this.RULE.reg, this.toHtml);
34
- }
35
- return replaceLookbehind(str, this.RULE.reg, this.toHtml, true, 1);
36
- }
37
-
38
- rule() {
39
- const ret = {
40
- begin: isLookbehindSupported() ? '((?<!\\\\))\\^\\^' : '(^|[^\\\\])\\^\\^',
41
- end: '\\^\\^',
42
- content: '([\\w\\W]+?)',
43
- };
44
- ret.reg = new RegExp(ret.begin + ret.content + ret.end, 'g');
45
- return ret;
46
- }
47
- }
@@ -1,333 +0,0 @@
1
- /**
2
- * Tencent is pleased to support the open source community by making CherryMarkdown available.
3
- *
4
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
5
- * The below software in this distribution may have been modified by THL A29 Limited ("Tencent Modifications").
6
- *
7
- * All Tencent Modifications are Copyright (C) THL A29 Limited.
8
- *
9
- * CherryMarkdown is licensed under the Apache License, Version 2.0 (the "License");
10
- * you may not use this file except in compliance with the License.
11
- * You may obtain a copy of the License at
12
- *
13
- * http://www.apache.org/licenses/LICENSE-2.0
14
- *
15
- * Unless required by applicable law or agreed to in writing, software
16
- * distributed under the License is distributed on an "AS IS" BASIS,
17
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- * See the License for the specific language governing permissions and
19
- * limitations under the License.
20
- */
21
-
22
- import { codePreviewLangSelectList } from '@/utils/code-preview-language-setting';
23
-
24
- /*
25
- * 外加配置系统联想词
26
- */
27
- export const addonsKeywords = '#';
28
- /*
29
- * 预留联想词
30
- */
31
- export const suggesterKeywords = '/·¥、:“”【】()《》`'.concat(addonsKeywords);
32
- /*
33
- * 系统联想候选表,主要为'、'以及'、'的联想。
34
- */
35
- const SystemSuggestList = [
36
- {
37
- icon: 'h1',
38
- label: 'H1 Heading',
39
- keyword: 'head1',
40
- value: '# ',
41
- },
42
- {
43
- icon: 'h2',
44
- label: 'H2 Heading',
45
- keyword: 'head2',
46
- value: '## ',
47
- },
48
- {
49
- icon: 'h3',
50
- label: 'H3 Heading',
51
- keyword: 'head3',
52
- value: '### ',
53
- },
54
- {
55
- icon: 'table',
56
- label: 'Table',
57
- keyword: 'table',
58
- value: '| Header | Header | Header |\n| --- | --- | --- |\n| Content | Content | Content |\n',
59
- },
60
- {
61
- icon: 'code',
62
- label: 'Code',
63
- keyword: 'code',
64
- value: '```\n\n```\n',
65
- },
66
- {
67
- icon: 'link',
68
- label: 'Link',
69
- keyword: 'link',
70
- value: `[title](https://url)`,
71
- selection: { from: 'title](https://url)'.length, to: '](https://url)'.length },
72
- },
73
- {
74
- icon: 'checklist',
75
- label: 'Checklist',
76
- keyword: 'checklist',
77
- value: `- [ ] item\n- [x] item`,
78
- },
79
- {
80
- icon: 'tips',
81
- label: 'Panel',
82
- keyword: 'panel tips info warning danger success',
83
- value: `::: primary title\ncontent\n:::\n`,
84
- },
85
- {
86
- icon: 'insertFlow',
87
- label: 'Detail',
88
- keyword: 'detail',
89
- value: `+++ 点击展开更多\n内容\n++- 默认展开\n内容\n++ 默认收起\n内容\n+++\n`,
90
- },
91
- // {
92
- // icon: 'pen',
93
- // label: '续写',
94
- // keyword: 'xu xie chatgpt',
95
- // value: () => {
96
- // if (!this.$engine.$cherry.options.openai.apiKey) {
97
- // return '请先配置openai apiKey';
98
- // }
99
- // this.$engine.$cherry.toolbar.toolbarHandlers.chatgpt('complement');
100
- // return `\n`;
101
- // },
102
- // },
103
- // {
104
- // icon: 'pen',
105
- // label: '总结',
106
- // keyword: 'zong jie chatgpt',
107
- // value: () => {
108
- // if (!this.$engine.$cherry.options.openai.apiKey) {
109
- // return '请先配置openai apiKey';
110
- // }
111
- // this.$engine.$cherry.toolbar.toolbarHandlers.chatgpt('summary');
112
- // return `\n`;
113
- // },
114
- // },
115
- ];
116
- /*
117
- * 全角联想候选表,用于将全角转为半角。
118
- */
119
- const HalfWidthSuggestList = [
120
- {
121
- icon: 'FullWidth',
122
- label: '`',
123
- keyword: '···',
124
- value: '`',
125
- },
126
- {
127
- icon: 'FullWidth',
128
- label: '$',
129
- keyword: '¥',
130
- value: '$',
131
- },
132
- {
133
- icon: 'FullWidth',
134
- label: '/',
135
- keyword: '、',
136
- value: '/',
137
- },
138
- {
139
- icon: 'FullWidth',
140
- label: '\\',
141
- keyword: '、',
142
- value: '\\',
143
- },
144
- {
145
- icon: 'FullWidth',
146
- label: '"',
147
- keyword: '“',
148
- value: '"',
149
- },
150
- {
151
- icon: 'FullWidth',
152
- label: '"',
153
- keyword: '”',
154
- value: '"',
155
- },
156
- {
157
- icon: 'FullWidth',
158
- label: '[',
159
- keyword: '【',
160
- value: '[',
161
- },
162
- {
163
- icon: 'FullWidth',
164
- label: ']',
165
- keyword: '】',
166
- value: ']',
167
- },
168
- {
169
- icon: 'FullWidth',
170
- label: '(',
171
- keyword: '(',
172
- value: '(',
173
- },
174
- {
175
- icon: 'FullWidth',
176
- label: ')',
177
- keyword: ')',
178
- value: ')',
179
- },
180
- {
181
- icon: 'FullWidth',
182
- label: '<',
183
- keyword: '《',
184
- value: '<',
185
- },
186
- {
187
- icon: 'FullWidth',
188
- label: '>',
189
- keyword: '》',
190
- value: '>',
191
- },
192
- ];
193
- /*
194
- * 更多候选适配,
195
- * goLeft用于在选中联想之后向左移动一定距离光标,
196
- * selection用于选中光标,from-to即选中范围。
197
- */
198
- const MoreSuggestList = [
199
- {
200
- icon: 'FullWidth',
201
- label: '[]',
202
- keyword: '【】',
203
- value: `[]`,
204
- goLeft: 1,
205
- },
206
- {
207
- icon: 'FullWidth',
208
- label: '【】',
209
- keyword: '【',
210
- value: `【】`,
211
- goLeft: 1,
212
- },
213
- {
214
- icon: 'link',
215
- label: 'Link',
216
- keyword: '【】',
217
- value: `[title](https://url)`,
218
- selection: { from: 'title](https://url)'.length, to: '](https://url)'.length },
219
- },
220
- {
221
- icon: 'FullWidth',
222
- label: '()',
223
- keyword: '(',
224
- value: `()`,
225
- goLeft: 1,
226
- },
227
- {
228
- icon: 'FullWidth',
229
- label: '()',
230
- keyword: '(',
231
- value: `()`,
232
- goLeft: 1,
233
- },
234
- {
235
- icon: 'FullWidth',
236
- label: '<>',
237
- keyword: '《》',
238
- value: `<>`,
239
- goLeft: 1,
240
- },
241
- {
242
- icon: 'FullWidth',
243
- label: '《》',
244
- keyword: '《》',
245
- value: `《》`,
246
- goLeft: 1,
247
- },
248
- {
249
- icon: 'FullWidth',
250
- label: '""',
251
- keyword: '“”',
252
- value: `""`,
253
- goLeft: 1,
254
- },
255
- {
256
- icon: 'FullWidth',
257
- label: '“”',
258
- keyword: '“”',
259
- value: `”“`,
260
- goLeft: 1,
261
- },
262
- {
263
- icon: 'FullWidth',
264
- label: 'inlineCode',
265
- keyword: '`',
266
- value: '``',
267
- goLeft: 1,
268
- },
269
- {
270
- icon: 'FullWidth',
271
- label: 'codeBlock',
272
- keyword: '`',
273
- value: '```\n\n```\n',
274
- goTop: 2,
275
- },
276
- ];
277
-
278
- // TODO 提示列表超过一定长度的时候,需要跟随箭头上下滚动列表,以保证待选择项始终可见
279
-
280
- // 代码语言的候选表
281
- const CodeLangSuggestList = (() => {
282
- const CodePreviewLangSuggestList = codePreviewLangSelectList.map((lang) => ({
283
- icon: 'FullWidth',
284
- label: lang,
285
- keyword: '```',
286
- value: `\`\`\`${lang}\n\n\`\`\`\n`,
287
- goTop: 2,
288
- exactMatch: true,
289
- }));
290
-
291
- const CodePreviewLangSuggestListExact = [];
292
- codePreviewLangSelectList.forEach((lang) => {
293
- let str = '';
294
- for (const i of lang) {
295
- str += i;
296
- CodePreviewLangSuggestListExact.push({
297
- icon: 'FullWidth',
298
- label: lang,
299
- keyword: `\`\`\`${str}`,
300
- value: `\`\`\`${lang}\n\n\`\`\`\n`,
301
- goTop: 2,
302
- exactMatch: true,
303
- });
304
- }
305
- });
306
-
307
- return CodePreviewLangSuggestList.concat(CodePreviewLangSuggestListExact);
308
- })();
309
-
310
- /*
311
- * 除开系统联想候选表的其他所有表之和
312
- */
313
- const OtherSuggestList = HalfWidthSuggestList.concat(MoreSuggestList).concat(CodeLangSuggestList);
314
-
315
- export function allSuggestList(keyword, locales) {
316
- const systemSuggestList = [].concat(SystemSuggestList);
317
- const otherSuggestList = [].concat(OtherSuggestList);
318
- systemSuggestList.forEach((item) => {
319
- item.label = locales[item.label] || item.label;
320
- });
321
- otherSuggestList.forEach((item) => {
322
- item.label = locales[item.label] || item.label;
323
- });
324
- if (keyword[0] === '/' || keyword[0] === '、' || addonsKeywords.includes(keyword[0])) {
325
- systemSuggestList.forEach((item) => {
326
- item.keyword = ''.concat(keyword[0], item.keyword);
327
- });
328
- }
329
- // '、'除了返回系统候选表,还需要返回两个半角字符
330
- return otherSuggestList.concat(systemSuggestList).filter((item) => {
331
- return item.keyword.startsWith(keyword[0]);
332
- });
333
- }