@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,410 +0,0 @@
1
- @import '../variable.scss';
2
-
3
- $VIOLET0: #f3f0ff;
4
- $VIOLET1: #e5dbff;
5
- $VIOLET2: #d0bfff;
6
- $VIOLET3: #b197fc;
7
- $VIOLET4: #9775fa;
8
- $VIOLET5: #845ef7;
9
- $VIOLET6: #7950f2;
10
- $VIOLET7: #7048e8;
11
- $VIOLET8: #6741d9;
12
- $VIOLET9: #5f3dc4;
13
-
14
- /** 工具栏样式 */
15
- $toolbarBg: #FFF;
16
- $toolbarBtnColor: $VIOLET9;
17
- $toolbarBtnBgHover: $VIOLET5;
18
- $toolbarBtnHoverColor: $VIOLET0;
19
- $toolbarColorItemHoverBorderColor: $VIOLET9;
20
- $sidebarShadow: $shadow;
21
- /** 编辑区域样式 */
22
- $editorBg: #FFF;
23
- $editorColor: $VIOLET9;
24
- $editorSelectedBg: $VIOLET2;
25
- $editorUrlBg: $VIOLET0;
26
- $editorCursorColor: $VIOLET9;
27
- $editorImportantColor: $VIOLET7;
28
- $editorCodeColor: $VIOLET6;
29
- /** 预览区域样式 */
30
- $previewBg: #FFF;
31
- $previewMobileBgColor: #FFF;
32
- /** markdown样式 */
33
- $mdColor: $editorColor;
34
- $mdHeaderColor: $editorImportantColor;
35
- $mdLineColor: $VIOLET8;
36
- $mdAColor: $editorCodeColor;
37
- $mdAHoverColor: $editorImportantColor;
38
- $mdInlineCodeColor: $editorCodeColor;
39
- $mdInlineCodeBg: $VIOLET1;
40
- $mdBlockquoteBg: $VIOLET1;
41
-
42
- /** 编辑器样式 */
43
- .cherry.theme__violet {
44
-
45
- /** 顶部按钮, 选中文字时弹出的按钮, 光标focus到空行时联想出的按钮, 侧边栏按钮 */
46
- .cherry-toolbar,
47
- .cherry-floatmenu,
48
- .cherry-bubble,
49
- .cherry-sidebar {
50
- background: $toolbarBg;
51
- border-color: $toolbarBg;
52
-
53
- .cherry-toolbar-button {
54
- color: $toolbarBtnColor;
55
-
56
- i {
57
- color: $toolbarBtnColor;
58
- }
59
-
60
- &:hover {
61
- background-color: $toolbarBtnBgHover;
62
- color: $toolbarBtnHoverColor !important;
63
- border-color: $toolbarBg;
64
-
65
- i {
66
- color: $toolbarBtnHoverColor !important;
67
- }
68
- }
69
- }
70
- }
71
-
72
- /** 二级菜单 */
73
- .cherry-dropdown {
74
- background: $toolbarBg;
75
-
76
- .cherry-dropdown-item {
77
- color: $toolbarBtnColor;
78
-
79
- // 选中子菜单高亮
80
- &__selected {
81
- background-color: $toolbarBtnBgHover;
82
- color: $toolbarBtnHoverColor;
83
- }
84
-
85
- &:hover {
86
- background-color: $toolbarBtnBgHover;
87
- color: $toolbarBtnHoverColor;
88
- }
89
- }
90
-
91
- /** 选择颜色的按钮 */
92
- &.cherry-color-wrap {
93
-
94
- /** 色盘的标题 */
95
- h3 {
96
- color: $toolbarBtnColor;
97
- }
98
-
99
- /** 色盘里的每一个色块 */
100
- .cherry-color-item {
101
- // width: 15px;
102
- // border: none;
103
- border-color: $toolbarBtnBgHover;
104
-
105
- &:hover {
106
- border-color: $toolbarColorItemHoverBorderColor;
107
- }
108
- }
109
- }
110
-
111
- /** 选择表格的按钮 */
112
- .cherry-insert-table-menu-item {
113
- border-color: $toolbarBtnBgHover;
114
- }
115
- }
116
-
117
- /** 选中文字时弹出的按钮 */
118
- .cherry-bubble {
119
- .cherry-bubble-bottom {
120
- border-top-color: $toolbarBg;
121
- }
122
-
123
- .cherry-bubble-top {
124
- border-bottom-color: $toolbarBg;
125
- }
126
-
127
- /** 粘贴HTML内容时弹出的选择按钮 */
128
- &.cherry-switch-paste {}
129
- }
130
-
131
-
132
- /** 光标focus到空行时联想出的按钮 */
133
-
134
- .cherry-editor {
135
- background-color: $editorBg;
136
-
137
- .CodeMirror {
138
- background-color: $editorBg;
139
-
140
- .CodeMirror-cursor {
141
- border-left: 1px solid $editorCursorColor;
142
- }
143
-
144
- .CodeMirror-scroll {
145
-
146
- span,
147
- .cm-variable-2,
148
- .cm-string,
149
- .cm-strong,
150
- .cm-em,
151
- .cm-meta {
152
- color: $editorColor;
153
- }
154
-
155
- .cm-image-marker,
156
- .cm-quote,
157
- .cm-header,
158
- .cm-atom {
159
- color: $editorImportantColor;
160
- }
161
-
162
- .cm-url {
163
- background-color: $editorUrlBg;
164
- }
165
-
166
- .cm-comment,
167
- .cm-url {
168
- color: $editorCodeColor;
169
- }
170
- }
171
-
172
- .CodeMirror-selected {
173
- background-color: $editorSelectedBg;
174
- }
175
- }
176
- }
177
-
178
- .cherry-sidebar {
179
- box-shadow: $sidebarShadow;
180
- }
181
-
182
- .cherry-previewer {
183
- background-color: $previewBg;
184
-
185
- .cherry-mobile-previewer-content {
186
- background-color: $previewMobileBgColor;
187
- }
188
- }
189
-
190
- .cherry-previewer-table-content-handler {
191
- .cherry-previewer-table-content-handler__input {
192
- textarea {
193
- background-color: $editorBg;
194
- color: $editorColor;
195
- outline-color: $editorImportantColor;
196
- }
197
- }
198
- }
199
-
200
- }
201
-
202
- /** 预览区域样式 */
203
- .cherry-markdown.theme__violet {
204
- color: $mdColor;
205
- background-color: $previewBg;
206
-
207
- p,
208
- div {}
209
-
210
- h1,
211
- h2,
212
- h3,
213
- h4,
214
- h5 {
215
- color: $mdHeaderColor;
216
- text-align: center;
217
- margin-bottom: 35px;
218
- }
219
-
220
- h1 {}
221
-
222
- h2 {}
223
-
224
- h3 {}
225
-
226
- h4 {}
227
-
228
- h5 {}
229
-
230
- h1,
231
- h2,
232
- h3,
233
- h4,
234
- h5,
235
- h6 {
236
-
237
- /** 标题前面的锚点或序号 */
238
- .anchor {}
239
- }
240
-
241
- ul {
242
- &.cherry-list__upper-roman {
243
- list-style: upper-roman;
244
- }
245
-
246
- &.cherry-list__lower-greek {
247
- list-style: lower-greek;
248
- }
249
-
250
- &.cherry-list__lower-alpha {
251
- list-style: lower-alpha;
252
- }
253
-
254
- &.cherry-list__cjk-ideographic {
255
- list-style: cjk-ideographic;
256
- }
257
-
258
- &.cherry-list__circle {
259
- list-style: circle;
260
- }
261
-
262
- &.cherry-list__square {
263
- list-style: square;
264
- }
265
-
266
- &.cherry-list__default {}
267
-
268
- /** checklist 模式,未勾选时 */
269
- .ch-icon-square {}
270
-
271
- /** checklist 模式,勾选时 */
272
- .ch-icon-check {}
273
- }
274
-
275
- ol {
276
- li {}
277
- }
278
-
279
-
280
- blockquote {
281
- color: $mdColor;
282
- background-color: $mdBlockquoteBg;
283
- border-color: $mdLineColor;
284
- }
285
-
286
- a {
287
- text-decoration: none;
288
- color: $mdAColor;
289
-
290
- &:hover {
291
- text-decoration: underline;
292
- color: $mdAHoverColor;
293
- }
294
- }
295
-
296
- strong {}
297
-
298
- em {}
299
-
300
- del {}
301
-
302
- sup {}
303
-
304
- sub {}
305
-
306
- hr {
307
- border-color: $mdLineColor;
308
- }
309
-
310
- img {}
311
-
312
- video {}
313
-
314
- audio {}
315
-
316
- /** 行内代码 */
317
- p code,
318
- li code {
319
- background-color: $mdInlineCodeBg;
320
- color: $mdInlineCodeColor;
321
- border: 1px solid $mdLineColor;
322
- }
323
-
324
- /**
325
- * 代码块
326
- */
327
- pre code {}
328
-
329
- /**
330
- * 表格
331
- */
332
- table,
333
- .cherry-table {
334
- color: $mdColor;
335
-
336
- th {
337
- background-color: $mdInlineCodeBg;
338
- }
339
-
340
- tr,
341
- th,
342
- td {
343
- border-color: $mdLineColor;
344
- }
345
- }
346
-
347
- /** 可以理解为上下结构的音标,下部是文字,上部是对应的拼音 */
348
- ruby {
349
-
350
- /** 上部的拼音 */
351
- rt {}
352
- }
353
-
354
- /** 脚注 */
355
- .footnote {
356
- border-color: $mdLineColor;
357
-
358
- .footnote-title {
359
- background-color: $mdInlineCodeBg;
360
- }
361
-
362
- .one-footnote {
363
- color: $mdColor;
364
- border-color: $mdLineColor;
365
-
366
- a.footnote-ref {
367
- padding: 5px;
368
- }
369
- }
370
- }
371
-
372
- /** 行间公式 */
373
- .Cherry-InlineMath {}
374
-
375
- /** 段落公式 */
376
- .Cherry-Math {}
377
-
378
- /** 目录 */
379
- .toc {
380
- border-bottom: 1px solid $mdLineColor;
381
- padding-bottom: 15px;
382
- margin-bottom: 30px;
383
-
384
- .toc-title {
385
- text-align: center;
386
- padding-bottom: 15px;
387
- margin-top: 30px;
388
- margin-bottom: 15px;
389
- border-bottom: 1px solid $mdLineColor;
390
- }
391
-
392
- .toc-li {
393
- border: none;
394
-
395
- .level-1 {}
396
-
397
- .level-2 {}
398
-
399
- .level-3 {}
400
-
401
- a {
402
- color: $mdColor;
403
-
404
- &:hover {
405
- color: $mdAHoverColor;
406
- }
407
- }
408
- }
409
- }
410
- }
@@ -1,84 +0,0 @@
1
- //基础样式
2
-
3
- $fontFamily: "Helvetica Neue",
4
- Arial,
5
- "Hiragino Sans GB",
6
- "STHeiti",
7
- "Microsoft YaHei",
8
- "WenQuanYi Micro Hei",
9
- sans-serif;
10
- $monospaceFont: 'Menlo', 'Liberation Mono', 'Consolas', 'DejaVu Sans Mono', 'Ubuntu Mono', 'Courier New', 'andale mono', 'lucida console', monospace;
11
- $fontSize: 16px;
12
- $fontSizeLarge: 18px;
13
- $lineHeight: 27px;
14
- $editorBg: #FFF;
15
- $previewBg: #FFF;
16
- $fontColor: #3f4a56;
17
- $linkColor: #3582fb;
18
- $linkHoverColor: #056bad;
19
- $borderColor: #dfe6ee;
20
- $toolbarSplitColor: #dfe6ee;
21
- $fullWidthColor: #d71616;
22
- $toolbarFontSize: 14px;
23
- $toolbarHeight: 48px;
24
- $elementGap: 16px;
25
- $elementLittleGap: 12px;
26
- $borderRadius: 3px;
27
-
28
- $errorColor: #f85353;
29
- $warnColor: #ffaf21;
30
-
31
- $shadow: 0 0 10px rgba(128, 145, 165, 0.2);
32
-
33
- // 标题
34
- $subTitle: #6d6e6f;
35
- // 滚动条
36
-
37
- // 列表
38
-
39
- // 代码块
40
- $codeBackground: #e5e5e5;
41
- $codeColor: $errorColor;
42
- $codeBlockBg: #00212b;
43
-
44
-
45
- // 引用
46
- $quoteBorderColor: #D6DBDF;
47
- $quoteBackground: rgba(102, 128, 153, .05);
48
- $quoteColor: $subTitle;
49
-
50
- // 公式
51
-
52
-
53
- // 编辑器主题
54
-
55
- $editorHeaderColor: $fontColor;
56
- $editorCommentColor: $linkColor;
57
- $editorQuoteColor: $editorCommentColor;
58
- $editorStringColor: $fontColor;
59
- $editorLinkColor: $linkColor;
60
- $editorUrlBgColor: #d7e6fe;
61
-
62
- $editorV2Color: $fontColor;
63
- $editorV3Color: $fontColor;
64
- $editorKeywordColor: $fontColor;
65
-
66
-
67
- // 工具栏
68
- // 暗色
69
- $toolbarBgDark: #20304b;
70
- $toolbarShadowDark: $shadow;
71
- $toolbarBtnBgDark: transparent;
72
- $toolbarBtnColorDark: #d7e6fe;
73
- $toolbarBtnBgHoverDark: rgba(255, 255, 255, 0.1);
74
- $toolbarBtnHoverColorDark: #fff;
75
- $toolbarBtnDisabledDark: #ccc;
76
-
77
- // 亮色
78
- $toolbarBgLight: white;
79
- $toolbarShadowLight: $shadow;
80
- $toolbarBtnBgLight: transparent;
81
- $toolbarBtnColorLight: #3f4a56;
82
- $toolbarBtnBgHoverLight: #ebf3ff;
83
- $toolbarBtnHoverColorLight: #5d9bfc;
84
- $toolbarBtnDisabledLight: #ccc;
@@ -1,234 +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 Toolbar from './Toolbar';
17
- /**
18
- * 在编辑区域选中文本时浮现的bubble工具栏
19
- */
20
- export default class Bubble extends Toolbar {
21
- /**
22
- * @type {'flex' | 'block'}
23
- */
24
- static displayType = 'flex';
25
- // constructor(options) {
26
- // super(options);
27
- // }
28
-
29
- set visible(visible) {
30
- const bubbleStyle = window.getComputedStyle(this.bubbleDom);
31
- if (visible) {
32
- bubbleStyle.display === 'none' && (this.bubbleDom.style.display = Bubble.displayType);
33
- // bubbleStyle.visibility !== 'visible' && (this.bubbleBottom.style.visibility = 'visible');
34
- } else {
35
- bubbleStyle.display !== 'none' && (this.bubbleDom.style.display = 'none');
36
- // bubbleStyle.visibility !== 'hidden' && (this.bubbleBottom.style.visibility = 'hidden');
37
- }
38
- }
39
-
40
- get visible() {
41
- const bubbleStyle = window.getComputedStyle(this.bubbleDom);
42
- return bubbleStyle.display !== 'none' && bubbleStyle.visibility !== 'hidden';
43
- }
44
-
45
- init() {
46
- this.options.editor = this.$cherry.editor;
47
- this.addSelectionChangeListener();
48
- this.bubbleDom = this.options.dom;
49
- this.editorDom = this.options.editor.getEditorDom();
50
- this.initBubbleDom();
51
- this.editorDom.querySelector('.CodeMirror').appendChild(this.bubbleDom);
52
- Object.entries(this.shortcutKeyMap).forEach(([key, value]) => {
53
- this.$cherry.toolbar.shortcutKeyMap[key] = value;
54
- });
55
- }
56
-
57
- appendMenusToDom(menus) {
58
- this.options.dom.appendChild(menus);
59
- }
60
-
61
- /**
62
- * 计算编辑区域的偏移量
63
- * @returns {number} 编辑区域的滚动区域
64
- */
65
- getScrollTop() {
66
- return this.options.editor.editor.getScrollInfo().top;
67
- }
68
-
69
- /**
70
- * 当编辑区域滚动的时候自动隐藏bubble工具栏和子工具栏
71
- */
72
- updatePositionWhenScroll() {
73
- if (this.bubbleDom.style.display === Bubble.displayType) {
74
- this.bubbleDom.style.marginTop = `${parseFloat(this.bubbleDom.dataset.scrollTop) - this.getScrollTop()}px`;
75
- }
76
- }
77
-
78
- /**
79
- * 根据高度计算bubble工具栏出现的位置的高度
80
- * 根据宽度计算bubble工具栏出现的位置的left值,以及bubble工具栏三角箭头的left值
81
- * @param {number} top 高度
82
- * @param {number} width 选中文本内容的宽度
83
- */
84
- showBubble(top, width) {
85
- if (!this.visible) {
86
- this.visible = true;
87
- this.bubbleDom.style.marginTop = '0';
88
- this.bubbleDom.dataset.scrollTop = String(this.getScrollTop());
89
- }
90
- const positionLimit = this.editorDom.querySelector('.CodeMirror-lines').firstChild.getBoundingClientRect();
91
- const editorPosition = this.editorDom.getBoundingClientRect();
92
- const minLeft = positionLimit.left - editorPosition.left;
93
- const maxLeft = positionLimit.width + minLeft;
94
- const minTop = this.bubbleDom.offsetHeight * 2;
95
- let $top = top;
96
- if ($top < minTop) {
97
- // 如果高度小于编辑器的顶部,则让bubble工具栏出现在选中文本的下放
98
- $top += this.bubbleDom.offsetHeight - this.bubbleTop.getBoundingClientRect().height;
99
- this.bubbleTop.style.display = 'block';
100
- this.bubbleBottom.style.display = 'none';
101
- } else {
102
- // 反之出现在选中文本内容的上方
103
- $top -= this.bubbleDom.offsetHeight + 2 * this.bubbleBottom.getBoundingClientRect().height;
104
- this.bubbleTop.style.display = 'none';
105
- this.bubbleBottom.style.display = 'block';
106
- }
107
- this.bubbleDom.style.top = `${$top}px`;
108
- let left = width - this.bubbleDom.offsetWidth / 2;
109
- if (left < minLeft) {
110
- // 如果位置超过了编辑器的最左边,则控制bubble工具栏不超出编辑器最左边
111
- // 同时bubble工具栏上的箭头尽量指向选中文本内容的中间位置
112
- left = minLeft;
113
- this.$setBubbleCursorPosition(`${width - minLeft}px`);
114
- } else if (left + this.bubbleDom.offsetWidth > maxLeft) {
115
- // 如果位置超过了编辑器的最右边,则控制bubble工具栏不超出编辑器最右边
116
- // 同时bubble工具栏上的箭头尽量指向选中文本内容的中间位置
117
- left = maxLeft - this.bubbleDom.offsetWidth;
118
- this.$setBubbleCursorPosition(`${width - left}px`);
119
- } else {
120
- // 让bubble工具栏的箭头处于工具栏的中间位置
121
- this.$setBubbleCursorPosition('50%');
122
- }
123
- // 安全边距 20px
124
- this.bubbleDom.style.left = `${Math.max(20, left)}px`;
125
- }
126
-
127
- hideBubble() {
128
- this.visible = false;
129
- }
130
-
131
- /**
132
- * 控制bubble工具栏的箭头的位置
133
- * @param {string} left 左偏移量
134
- */
135
- $setBubbleCursorPosition(left = '50%') {
136
- if (left === '50%') {
137
- this.bubbleTop.style.left = '50%';
138
- this.bubbleBottom.style.left = '50%';
139
- } else {
140
- const $left = parseFloat(left) < 10 ? '10px' : left;
141
- this.bubbleTop.style.left = $left;
142
- this.bubbleBottom.style.left = $left;
143
- }
144
- }
145
-
146
- initBubbleDom() {
147
- const top = document.createElement('div');
148
- top.className = 'cherry-bubble-top';
149
- const bottom = document.createElement('div');
150
- bottom.className = 'cherry-bubble-bottom';
151
- this.bubbleTop = top;
152
- this.bubbleBottom = bottom;
153
- this.bubbleDom.appendChild(top);
154
- this.bubbleDom.appendChild(bottom);
155
- // 默认不可见
156
- this.visible = false;
157
- }
158
-
159
- getBubbleDom() {
160
- return this.bubbleDom;
161
- }
162
-
163
- addSelectionChangeListener() {
164
- this.options.editor.addListener('change', (codemirror) => {
165
- // 当编辑区内容变更时自动隐藏bubble工具栏
166
- this.hideBubble();
167
- });
168
- this.options.editor.addListener('refresh', (codemirror) => {
169
- // 当编辑区内容刷新时自动隐藏bubble工具栏
170
- this.hideBubble();
171
- });
172
- this.options.editor.addListener('scroll', (codemirror) => {
173
- // 当编辑区滚动时,需要实时同步bubble工具栏的位置
174
- this.updatePositionWhenScroll();
175
- });
176
- this.options.editor.addListener('beforeSelectionChange', (codemirror, info) => {
177
- setTimeout(() => {
178
- const selections = codemirror.getSelections();
179
- const selectionStr = selections.join('');
180
- if (selectionStr !== this.lastSelectionsStr && (selectionStr || this.lastSelectionsStr)) {
181
- this.lastSelections = !this.lastSelections ? [] : this.lastSelections;
182
- this.$cherry.$event.emit('selectionChange', { selections, lastSelections: this.lastSelections, info });
183
- this.lastSelections = selections;
184
- this.lastSelectionsStr = selectionStr;
185
- }
186
- }, 10);
187
- // 当编辑区选中内容改变时,需要展示/隐藏bubble工具栏,并计算工具栏位置
188
- if (info.origin !== '*mouse' && (info.origin !== null || typeof info.origin === 'undefined')) {
189
- return true;
190
- }
191
- if (!info.ranges[0]) {
192
- return true;
193
- }
194
- const anchor = info.ranges[0].anchor.line * 1000000 + info.ranges[0].anchor.ch;
195
- const head = info.ranges[0].head.line * 1000000 + info.ranges[0].head.ch;
196
- let direction = 'asc';
197
- if (anchor > head) {
198
- direction = 'desc';
199
- }
200
- setTimeout(() => {
201
- const selections = codemirror.getSelections();
202
- if (selections.join('').length <= 0) {
203
- this.hideBubble();
204
- return;
205
- }
206
- const selectedObjs = codemirror.getWrapperElement().getElementsByClassName('CodeMirror-selected');
207
- const editorPosition = this.editorDom.getBoundingClientRect();
208
- let width = 0;
209
- let top = 0;
210
- if (typeof selectedObjs !== 'object' || selectedObjs.length <= 0) {
211
- this.hideBubble();
212
- return;
213
- }
214
- for (let key = 0; key < selectedObjs.length; key++) {
215
- const one = selectedObjs[key];
216
- const position = one.getBoundingClientRect();
217
- const targetTop = position.top - editorPosition.top;
218
- if (direction === 'asc') {
219
- if (targetTop >= top) {
220
- top = targetTop;
221
- width = position.left - editorPosition.left + position.width / 2;
222
- }
223
- } else {
224
- if (targetTop <= top || top <= 0) {
225
- top = targetTop;
226
- width = position.left - editorPosition.left + position.width / 2;
227
- }
228
- }
229
- }
230
- this.showBubble(top, width);
231
- }, 10);
232
- });
233
- }
234
- }