@milkdown/crepe 7.3.3

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 (241) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +11 -0
  3. package/lib/apl-p0IPP13W.js +76 -0
  4. package/lib/asciiarmor-lJsBxlJJ.js +34 -0
  5. package/lib/asn1-Q9v1zIy5.js +102 -0
  6. package/lib/asterisk-foNkeTjy.js +273 -0
  7. package/lib/brainfuck-0XqyXpNS.js +35 -0
  8. package/lib/clike-ak6Z6Yhe.js +639 -0
  9. package/lib/clojure-iYO8U8Sg.js +810 -0
  10. package/lib/clsx-7d8NmkQq.js +21 -0
  11. package/lib/cmake-SVzjkxV_.js +28 -0
  12. package/lib/cobol-APHEnAOX.js +74 -0
  13. package/lib/coffeescript-KqQa0SYG.js +182 -0
  14. package/lib/commonlisp-bwqNqR5V.js +79 -0
  15. package/lib/core/crepe.d.ts +21 -0
  16. package/lib/core/crepe.d.ts.map +1 -0
  17. package/lib/core/index.d.ts +3 -0
  18. package/lib/core/index.d.ts.map +1 -0
  19. package/lib/core/slice.d.ts +12 -0
  20. package/lib/core/slice.d.ts.map +1 -0
  21. package/lib/crystal-BViWuDpA.js +217 -0
  22. package/lib/css-KHXHXfXg.js +1572 -0
  23. package/lib/cypher-XpTt4zQ3.js +69 -0
  24. package/lib/d-fLig6yqY.js +139 -0
  25. package/lib/diff-WoKGLpy6.js +18 -0
  26. package/lib/dockerfile-u6f6Vw2s.js +194 -0
  27. package/lib/dtd-SIJRUW6K.js +91 -0
  28. package/lib/dylan-4HCLhpWP.js +238 -0
  29. package/lib/ebnf-h_0lged5.js +77 -0
  30. package/lib/ecl-Lf4FF0lf.js +133 -0
  31. package/lib/eiffel-qlw8KUyf.js +112 -0
  32. package/lib/elm-QRnB3zXs.js +108 -0
  33. package/lib/erlang-fyVKb7eK.js +488 -0
  34. package/lib/factor-BEeN4upY.js +65 -0
  35. package/lib/fcl-lRek3hEb.js +106 -0
  36. package/lib/feature/block-edit/handle/component.d.ts +9 -0
  37. package/lib/feature/block-edit/handle/component.d.ts.map +1 -0
  38. package/lib/feature/block-edit/handle/index.d.ts +12 -0
  39. package/lib/feature/block-edit/handle/index.d.ts.map +1 -0
  40. package/lib/feature/block-edit/index.d.ts +3 -0
  41. package/lib/feature/block-edit/index.d.ts.map +1 -0
  42. package/lib/feature/block-edit/menu/component.d.ts +14 -0
  43. package/lib/feature/block-edit/menu/component.d.ts.map +1 -0
  44. package/lib/feature/block-edit/menu/config.d.ts +21 -0
  45. package/lib/feature/block-edit/menu/config.d.ts.map +1 -0
  46. package/lib/feature/block-edit/menu/icons.d.ts +14 -0
  47. package/lib/feature/block-edit/menu/icons.d.ts.map +1 -0
  48. package/lib/feature/block-edit/menu/index.d.ts +9 -0
  49. package/lib/feature/block-edit/menu/index.d.ts.map +1 -0
  50. package/lib/feature/code-mirror/index.d.ts +3 -0
  51. package/lib/feature/code-mirror/index.d.ts.map +1 -0
  52. package/lib/feature/gap-cursor/index.d.ts +3 -0
  53. package/lib/feature/gap-cursor/index.d.ts.map +1 -0
  54. package/lib/feature/image-block/index.d.ts +3 -0
  55. package/lib/feature/image-block/index.d.ts.map +1 -0
  56. package/lib/feature/index.d.ts +18 -0
  57. package/lib/feature/index.d.ts.map +1 -0
  58. package/lib/feature/link-tooltip/consts.d.ts +5 -0
  59. package/lib/feature/link-tooltip/consts.d.ts.map +1 -0
  60. package/lib/feature/link-tooltip/index.d.ts +3 -0
  61. package/lib/feature/link-tooltip/index.d.ts.map +1 -0
  62. package/lib/feature/list-item/consts.d.ts +2 -0
  63. package/lib/feature/list-item/consts.d.ts.map +1 -0
  64. package/lib/feature/list-item/index.d.ts +3 -0
  65. package/lib/feature/list-item/index.d.ts.map +1 -0
  66. package/lib/feature/placeholder/index.d.ts +10 -0
  67. package/lib/feature/placeholder/index.d.ts.map +1 -0
  68. package/lib/feature/shared.d.ts +3 -0
  69. package/lib/feature/shared.d.ts.map +1 -0
  70. package/lib/feature/toolbar/component.d.ts +13 -0
  71. package/lib/feature/toolbar/component.d.ts.map +1 -0
  72. package/lib/feature/toolbar/consts.d.ts +5 -0
  73. package/lib/feature/toolbar/consts.d.ts.map +1 -0
  74. package/lib/feature/toolbar/index.d.ts +3 -0
  75. package/lib/feature/toolbar/index.d.ts.map +1 -0
  76. package/lib/forth-ua2bRd8T.js +60 -0
  77. package/lib/fortran-WnF7znuN.js +443 -0
  78. package/lib/gas-wowve1o7.js +183 -0
  79. package/lib/gherkin-m7GIChu3.js +34 -0
  80. package/lib/go-th443Dhb.js +158 -0
  81. package/lib/groovy-tR4RiZnc.js +161 -0
  82. package/lib/haskell-jxVBofv5.js +375 -0
  83. package/lib/haxe-kWPI2tq3.js +390 -0
  84. package/lib/hooks-82sqkbtE.js +21 -0
  85. package/lib/http-3GIFWUlG.js +45 -0
  86. package/lib/icons-HYkfuR-O.js +50 -0
  87. package/lib/idl-PvpMZg-l.js +947 -0
  88. package/lib/index-0RbcZMbq.js +8 -0
  89. package/lib/index-4afXjFMY.js +517 -0
  90. package/lib/index-7MeyepDG.js +78 -0
  91. package/lib/index-7QgQq3x3.js +551 -0
  92. package/lib/index-7pgP6qYs.js +107 -0
  93. package/lib/index-8DvtgRVa.js +19511 -0
  94. package/lib/index-8Gg-jEP4.js +288 -0
  95. package/lib/index-8S8qcncB.js +507 -0
  96. package/lib/index-9A_GmGh4.js +1039 -0
  97. package/lib/index-EJJfYLzA.js +928 -0
  98. package/lib/index-Eg39w5kL.js +984 -0
  99. package/lib/index-FIk_7oPb.js +168 -0
  100. package/lib/index-LlbrXb_n.js +368 -0
  101. package/lib/index-MovKtgMG.js +121 -0
  102. package/lib/index-N9GtIS4X.js +64 -0
  103. package/lib/index-Pwn25-kf.js +8 -0
  104. package/lib/index-SdFSDosa.js +1295 -0
  105. package/lib/index-W5Th22-Z.js +1744 -0
  106. package/lib/index-XiXSFLmI.js +20975 -0
  107. package/lib/index-bknOViGv.js +47 -0
  108. package/lib/index-bkuIUPFS.js +275 -0
  109. package/lib/index-jPA8J9Eo.js +8 -0
  110. package/lib/index-lsG76a9s.js +552 -0
  111. package/lib/index-oTRzPo3B.js +146 -0
  112. package/lib/index-rrf6_6DC.js +317 -0
  113. package/lib/index-vJbZIHYF.js +81 -0
  114. package/lib/index-vPRh55CO.js +137 -0
  115. package/lib/index-vxy63hib.js +323 -0
  116. package/lib/index-wn1_LgCS.js +99 -0
  117. package/lib/index-xHADmDT3.js +12 -0
  118. package/lib/index-yt2EpMtv.js +141 -0
  119. package/lib/index.d.ts +4 -0
  120. package/lib/index.d.ts.map +1 -0
  121. package/lib/index.es.js +7 -0
  122. package/lib/javascript-8ZHqHagw.js +758 -0
  123. package/lib/jinja2-vsOFe0qD.js +154 -0
  124. package/lib/julia-dlp_pbN1.js +241 -0
  125. package/lib/livescript-Gf5R-LT6.js +273 -0
  126. package/lib/lua-c5Y_JsBp.js +221 -0
  127. package/lib/mathematica-iiGTGmUs.js +35 -0
  128. package/lib/mbox-ZJh86H8B.js +78 -0
  129. package/lib/meta-tAGyVRPE.js +511 -0
  130. package/lib/mirc-i0qkCa0y.js +73 -0
  131. package/lib/mllike-Dy551fZW.js +275 -0
  132. package/lib/modelica-n6tGqUT9.js +94 -0
  133. package/lib/mscgen-aKSbB7D9.js +104 -0
  134. package/lib/mumps-lNiKA6sp.js +25 -0
  135. package/lib/nginx--YmuCfDj.js +93 -0
  136. package/lib/nsis-zhS8iA09.js +62 -0
  137. package/lib/ntriples-E3jQl3MC.js +79 -0
  138. package/lib/octave-EQvkGIeG.js +144 -0
  139. package/lib/oz-W2cpqFf6.js +152 -0
  140. package/lib/pascal-lCh6ouNZ.js +79 -0
  141. package/lib/perl-PxEQBX0B.js +915 -0
  142. package/lib/pig-Y_bNcrzS.js +56 -0
  143. package/lib/powershell-GaQP-TZr.js +249 -0
  144. package/lib/properties-mbRyn54L.js +26 -0
  145. package/lib/prosemirror-noTDkx-k.js +4 -0
  146. package/lib/protobuf-8CJideyJ.js +49 -0
  147. package/lib/puppet-ABBaChNZ.js +45 -0
  148. package/lib/python-sKdHg3Ka.js +321 -0
  149. package/lib/q-_1yG40Nm.js +89 -0
  150. package/lib/r-Ziz56bHT.js +108 -0
  151. package/lib/rpm-ORjGOHaQ.js +57 -0
  152. package/lib/ruby-jlbYq0dT.js +233 -0
  153. package/lib/sas-2n7xeUuO.js +107 -0
  154. package/lib/schema-tKk3m1fu.js +62 -0
  155. package/lib/scheme-XCs-NPeU.js +126 -0
  156. package/lib/shell-0_1Um7Dq.js +184 -0
  157. package/lib/sieve-7uyJD1x1.js +73 -0
  158. package/lib/simple-mode--HIzBxba.js +95 -0
  159. package/lib/smalltalk-PEFzrlQ-.js +48 -0
  160. package/lib/solr-BLBaHahN.js +41 -0
  161. package/lib/sparql-4F9ZWf1b.js +204 -0
  162. package/lib/spreadsheet-SGSo6blj.js +49 -0
  163. package/lib/sql-tebLBzN0.js +291 -0
  164. package/lib/stex-SFJcFGOO.js +130 -0
  165. package/lib/stylus-rwwWYWFm.js +256 -0
  166. package/lib/swift-eorJ0tCv.js +238 -0
  167. package/lib/tcl-IwXMB8U4.js +82 -0
  168. package/lib/textile-ok2VyjwC.js +299 -0
  169. package/lib/theme/classic/index.d.ts +3 -0
  170. package/lib/theme/classic/index.d.ts.map +1 -0
  171. package/lib/theme/classic-dark/index.d.ts +3 -0
  172. package/lib/theme/classic-dark/index.d.ts.map +1 -0
  173. package/lib/theme/headless/index.d.ts +3 -0
  174. package/lib/theme/headless/index.d.ts.map +1 -0
  175. package/lib/theme/index.d.ts +8 -0
  176. package/lib/theme/index.d.ts.map +1 -0
  177. package/lib/theme/shared.d.ts +3 -0
  178. package/lib/theme/shared.d.ts.map +1 -0
  179. package/lib/tiddlywiki-DLhz8_pc.js +156 -0
  180. package/lib/tiki-DFAqFElY.js +183 -0
  181. package/lib/tippy.esm-MZ2vxByW.js +1813 -0
  182. package/lib/toml-ryxpTZEV.js +49 -0
  183. package/lib/tooltip-plugin-gcwyQdiT.js +119 -0
  184. package/lib/troff-ZzZyvNct.js +36 -0
  185. package/lib/ttcn-6gvkqqpW.js +136 -0
  186. package/lib/ttcn-cfg-oSu-Dq5C.js +98 -0
  187. package/lib/turtle-10ofr5au.js +87 -0
  188. package/lib/use-css-light-dom-EKWZDmbJ.js +82 -0
  189. package/lib/utils/index.d.ts +4 -0
  190. package/lib/utils/index.d.ts.map +1 -0
  191. package/lib/vb-a6n6fzrD.js +74 -0
  192. package/lib/vbscript-dgvo8jPt.js +324 -0
  193. package/lib/velocity-CBncCrwO.js +97 -0
  194. package/lib/verilog-KlcACt6C.js +271 -0
  195. package/lib/vhdl-NMd7Gf35.js +117 -0
  196. package/lib/webidl-z1UE5DN_.js +160 -0
  197. package/lib/xquery-hDt5jWTp.js +431 -0
  198. package/lib/yacas-ftgh_qwr.js +74 -0
  199. package/lib/yaml-DnNTfjXK.js +53 -0
  200. package/lib/z80-dA1PqWe1.js +62 -0
  201. package/package.json +87 -0
  202. package/src/core/crepe.ts +98 -0
  203. package/src/core/index.ts +4 -0
  204. package/src/core/slice.ts +44 -0
  205. package/src/feature/block-edit/handle/component.ts +68 -0
  206. package/src/feature/block-edit/handle/index.ts +81 -0
  207. package/src/feature/block-edit/index.ts +17 -0
  208. package/src/feature/block-edit/menu/component.ts +210 -0
  209. package/src/feature/block-edit/menu/config.ts +335 -0
  210. package/src/feature/block-edit/menu/icons.ts +171 -0
  211. package/src/feature/block-edit/menu/index.ts +113 -0
  212. package/src/feature/block-edit/style.css +126 -0
  213. package/src/feature/code-mirror/index.ts +60 -0
  214. package/src/feature/code-mirror/style.css +159 -0
  215. package/src/feature/gap-cursor/index.ts +31 -0
  216. package/src/feature/image-block/index.ts +59 -0
  217. package/src/feature/image-block/style.css +215 -0
  218. package/src/feature/index.ts +66 -0
  219. package/src/feature/link-tooltip/consts.ts +47 -0
  220. package/src/feature/link-tooltip/index.ts +22 -0
  221. package/src/feature/link-tooltip/style.css +107 -0
  222. package/src/feature/list-item/consts.ts +15 -0
  223. package/src/feature/list-item/index.ts +30 -0
  224. package/src/feature/list-item/style.css +23 -0
  225. package/src/feature/placeholder/index.ts +87 -0
  226. package/src/feature/placeholder/style.css +9 -0
  227. package/src/feature/shared.ts +4 -0
  228. package/src/feature/toolbar/component.ts +101 -0
  229. package/src/feature/toolbar/consts.ts +26 -0
  230. package/src/feature/toolbar/index.ts +92 -0
  231. package/src/feature/toolbar/style.css +37 -0
  232. package/src/index.ts +5 -0
  233. package/src/theme/classic/index.ts +12 -0
  234. package/src/theme/classic/style.css +192 -0
  235. package/src/theme/classic-dark/index.ts +12 -0
  236. package/src/theme/classic-dark/style.css +197 -0
  237. package/src/theme/headless/index.ts +9 -0
  238. package/src/theme/index.ts +26 -0
  239. package/src/theme/shared.ts +4 -0
  240. package/src/utils/index.ts +12 -0
  241. package/src/vite-env.d.ts +2 -0
@@ -0,0 +1,126 @@
1
+ .milkdown {
2
+ milkdown-block-handle {
3
+ cursor: pointer;
4
+ display: flex;
5
+ justify-content: center;
6
+ align-items: center;
7
+ gap: 2px;
8
+ padding-right: 4px;
9
+
10
+ .operation-item {
11
+ border-radius: 4px;
12
+ width: 32px;
13
+ height: 32px;
14
+ padding: 4px;
15
+
16
+ svg {
17
+ width: 24px;
18
+ height: 24px;
19
+ }
20
+
21
+ &:hover {
22
+ background: var(--crepe-color-hover);
23
+ }
24
+
25
+ &.active {
26
+ background: var(--crepe-color-selected);
27
+ }
28
+ }
29
+ }
30
+
31
+ milkdown-slash-menu {
32
+ display: block;
33
+ width: 254px;
34
+ font-family: var(--crepe-font-default);
35
+ color: var(--crepe-color-on-surface);
36
+ background: var(--crepe-color-surface);
37
+ border-radius: 12px;
38
+ box-shadow: var(--crepe-shadow-1);
39
+
40
+ ul {
41
+ list-style-type: none;
42
+ li {
43
+ cursor: pointer;
44
+ border-radius: 8px;
45
+ }
46
+ }
47
+
48
+ .tab-group {
49
+ border-bottom: 1px solid color-mix(in srgb, var(--crepe-color-outline), transparent 80%);
50
+ padding: 12px 12px 0;
51
+
52
+ ul {
53
+ padding: 8px 10px;
54
+ display: flex;
55
+ gap: 10px;
56
+ flex-wrap: nowrap;
57
+
58
+ li {
59
+ padding: 6px 10px;
60
+ font-size: 14px;
61
+ font-style: normal;
62
+ font-weight: 600;
63
+ line-height: 20px;
64
+ &:hover {
65
+ background: var(--crepe-color-hover);
66
+ }
67
+ &.selected {
68
+ background: var(--crepe-color-selected);
69
+ }
70
+ }
71
+ }
72
+ }
73
+
74
+ .menu-groups {
75
+ padding: 0 12px 12px;
76
+ max-height: 420px;
77
+ overflow: auto;
78
+
79
+ .menu-group {
80
+ h6 {
81
+ font-size: 14px;
82
+ font-style: normal;
83
+ font-weight: 600;
84
+ line-height: 20px;
85
+ padding: 14px 10px;
86
+ text-transform: uppercase;
87
+ color: color-mix(in srgb, var(--crepe-color-on-surface), transparent 40%)
88
+ }
89
+
90
+ li {
91
+ display: flex;
92
+ justify-content: flex-start;
93
+ align-items: center;
94
+ gap: 16px;
95
+ padding: 14px 10px;
96
+ &.hover {
97
+ background: var(--crepe-color-hover);
98
+ }
99
+ &.active {
100
+ background: var(--crepe-color-selected);
101
+ }
102
+
103
+ & > svg {
104
+ width: 24px;
105
+ height: 24px;
106
+ color: var(--crepe-color-outline);
107
+ }
108
+ & > span {
109
+ font-size: 14px;
110
+ font-style: normal;
111
+ font-weight: 600;
112
+ line-height: 20px;
113
+ }
114
+ }
115
+ }
116
+
117
+ .menu-group + .menu-group::before {
118
+ content: '';
119
+ display: block;
120
+ height: 1px;
121
+ background: color-mix(in srgb, var(--crepe-color-outline), transparent 80%);
122
+ margin: 0 10px;
123
+ }
124
+ }
125
+ }
126
+ }
@@ -0,0 +1,60 @@
1
+ /* Copyright 2021, Milkdown by Mirone. */
2
+ import { codeBlockComponent, codeBlockConfig } from '@milkdown/components/code-block'
3
+ import { languages } from '@codemirror/language-data'
4
+ import { basicSetup } from 'codemirror'
5
+ import { keymap } from '@codemirror/view'
6
+ import { defaultKeymap } from '@codemirror/commands'
7
+ import { bespin, espresso, rosePineDawn } from 'thememirror'
8
+ import { html } from 'atomico'
9
+ import { ThemeCtx, injectStyle } from '../../core/slice'
10
+ import type { DefineFeature } from '../shared'
11
+ import { CrepeTheme } from '../../theme'
12
+ import style from './style.css?inline'
13
+
14
+ function pickTheme(theme: CrepeTheme) {
15
+ switch (theme) {
16
+ case CrepeTheme.Classic:
17
+ return rosePineDawn
18
+ case CrepeTheme.ClassicDark:
19
+ return bespin
20
+ default:
21
+ return espresso
22
+ }
23
+ }
24
+
25
+ const check = html`
26
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
27
+ <path d="M5.99986 10.7799L3.21986 7.9999L2.27319 8.9399L5.99986 12.6666L13.9999 4.66656L13.0599 3.72656L5.99986 10.7799Z" fill="#49454F"/>
28
+ </svg>
29
+ `
30
+
31
+ const clearIcon = html`
32
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
33
+ <g clip-path="url(#clip0_1098_15553)">
34
+ <path d="M18.3007 5.70973C17.9107 5.31973 17.2807 5.31973 16.8907 5.70973L12.0007 10.5897L7.1107 5.69973C6.7207 5.30973 6.0907 5.30973 5.7007 5.69973C5.3107 6.08973 5.3107 6.71973 5.7007 7.10973L10.5907 11.9997L5.7007 16.8897C5.3107 17.2797 5.3107 17.9097 5.7007 18.2997C6.0907 18.6897 6.7207 18.6897 7.1107 18.2997L12.0007 13.4097L16.8907 18.2997C17.2807 18.6897 17.9107 18.6897 18.3007 18.2997C18.6907 17.9097 18.6907 17.2797 18.3007 16.8897L13.4107 11.9997L18.3007 7.10973C18.6807 6.72973 18.6807 6.08973 18.3007 5.70973Z" fill="#817567"/>
35
+ </g>
36
+ <defs>
37
+ <clipPath id="clip0_1098_15553">
38
+ <rect width="24" height="24" fill="white"/>
39
+ </clipPath>
40
+ </defs>
41
+ </svg>
42
+ `
43
+
44
+ export const defineFeature: DefineFeature = (editor) => {
45
+ editor.config(injectStyle(style))
46
+ .config(async (ctx) => {
47
+ const crepeTheme = ctx.get(ThemeCtx)
48
+
49
+ ctx.update(codeBlockConfig.key, defaultConfig => ({
50
+ ...defaultConfig,
51
+ languages,
52
+ clearSearchIcon: () => clearIcon,
53
+ extensions: [basicSetup, keymap.of(defaultKeymap), pickTheme(crepeTheme)],
54
+ renderLanguage: (language, selected) => {
55
+ return html`<span class="leading">${selected ? check : null}</span>${language}`
56
+ },
57
+ }))
58
+ })
59
+ .use(codeBlockComponent)
60
+ }
@@ -0,0 +1,159 @@
1
+ .milkdown {
2
+ milkdown-code-block {
3
+ padding: 24px 40px;
4
+ background: var(--crepe-color-surface);
5
+ margin: 20px 0;
6
+
7
+ &.selected {
8
+ outline: 1px solid var(--crepe-color-primary);
9
+ }
10
+
11
+ .cm-editor {
12
+ outline: none !important;
13
+ background: var(--crepe-color-surface);
14
+ }
15
+
16
+ .cm-gutters {
17
+ border-right: none;
18
+ background: var(--crepe-color-surface);
19
+ }
20
+
21
+ .language-button {
22
+ font-family: var(--crepe-font-default);
23
+ gap: 6px;
24
+ padding: 6px 8px 6px 18px;
25
+ background: var(--crepe-color-surface-low);
26
+ color: var(--crepe-color-on-surface-variant);
27
+ border-radius: 8px;
28
+ font-size: 14px;
29
+ font-weight: 600;
30
+ line-height: 20px;
31
+ margin-bottom: 24px;
32
+ opacity: 0;
33
+ cursor: pointer;
34
+ transition: opacity 0.2s ease-in-out;
35
+ }
36
+
37
+ &:hover .language-button {
38
+ opacity: 1;
39
+ }
40
+
41
+ .language-button:hover {
42
+ background: var(--crepe-color-hover);
43
+ }
44
+
45
+ .language-button .expand-icon {
46
+ transition: transform 0.2s ease-in-out;
47
+ width: 18px;
48
+ height: 18px;
49
+ display: flex;
50
+ justify-content: center;
51
+ align-items: center;
52
+ }
53
+
54
+ .language-button .expand-icon svg {
55
+ width: 14px;
56
+ height: 14px;
57
+ }
58
+
59
+ .language-button[data-expanded="true"] .expand-icon {
60
+ transform: rotate(180deg);
61
+ }
62
+
63
+ .language-button .expand-icon svg:focus,
64
+ .language-button .expand-icon:focus-visible {
65
+ outline: none;
66
+ }
67
+
68
+ .language-picker {
69
+ padding-top: 16px;
70
+ }
71
+
72
+ .list-wrapper {
73
+ background: var(--crepe-color-surface-low);
74
+ border-radius: 12px;
75
+ box-shadow: var(--crepe-shadow-1);
76
+ width: 244px;
77
+ }
78
+
79
+ .language-list {
80
+ height: 410px;
81
+ overflow-y: auto;
82
+ margin: 0;
83
+ padding: 0;
84
+ }
85
+
86
+ .language-list-item {
87
+ cursor: pointer;
88
+ margin: 0;
89
+ display: flex;
90
+ align-items: center;
91
+ gap: 8px;
92
+ padding: 12px 20px 12px 10px;
93
+ font-size: 14px;
94
+ font-weight: 600;
95
+ line-height: 20px;
96
+ }
97
+
98
+ .language-list-item:hover {
99
+ background: var(--crepe-color-hover);
100
+ }
101
+
102
+ .language-list-item:focus-visible {
103
+ outline: none;
104
+ background: var(--crepe-color-hover);
105
+ }
106
+
107
+ .language-list-item .leading,
108
+ .language-list-item .leading svg {
109
+ width: 24px;
110
+ height: 24px;
111
+ }
112
+
113
+ .list-wrapper {
114
+ padding-top: 20px;
115
+ }
116
+
117
+ .search-box {
118
+ margin: 0 16px 12px;
119
+ background: transparent;
120
+ border-radius: 4px;
121
+ outline: 1px solid var(--crepe-color-primary);
122
+ gap: 8px;
123
+ padding: 12px 20px 12px 10px;
124
+ }
125
+
126
+ .search-box .search-input {
127
+ width: 100%;
128
+ color: var(--crepe-color-on-surface);
129
+ }
130
+
131
+ .search-box .search-icon {
132
+ display: none;
133
+ }
134
+
135
+ .search-box .clear-icon {
136
+ width: 24px;
137
+ height: 24px;
138
+ svg {
139
+ width: 24px;
140
+ height: 24px;
141
+ color: var(--crepe-color-primary);
142
+ }
143
+ &:hover {
144
+ background: var(--crepe-color-hover);
145
+ }
146
+ }
147
+
148
+ .search-box input {
149
+ font-family: var(--crepe-font-default);
150
+ font-size: 16px;
151
+ line-height: 24px;
152
+ background: transparent;
153
+ }
154
+
155
+ .search-box input:focus {
156
+ outline: none;
157
+ }
158
+ }
159
+ }
@@ -0,0 +1,31 @@
1
+ /* Copyright 2021, Milkdown by Mirone. */
2
+ import { cursor, dropCursorConfig } from '@milkdown/plugin-cursor'
3
+ import gapCursor from '@milkdown/prose/gapcursor/style/gapcurosr.css?inline'
4
+
5
+ import type { DefineFeature } from '../shared'
6
+ import { CrepeTheme } from '../../theme'
7
+ import { ThemeCtx, injectStyle } from '../../core/slice'
8
+
9
+ function getColorFromTheme(theme: CrepeTheme) {
10
+ switch (theme) {
11
+ case CrepeTheme.Classic:
12
+ return '#1F1B16'
13
+ case CrepeTheme.ClassicDark:
14
+ return '#EAE1D9'
15
+ default:
16
+ return undefined
17
+ }
18
+ }
19
+
20
+ export const defineFeature: DefineFeature = (editor) => {
21
+ editor
22
+ .config(injectStyle(gapCursor))
23
+ .config((ctx) => {
24
+ const theme = ctx.get(ThemeCtx)
25
+ ctx.update(dropCursorConfig.key, value => ({
26
+ ...value,
27
+ color: getColorFromTheme(theme),
28
+ }))
29
+ })
30
+ .use(cursor)
31
+ }
@@ -0,0 +1,59 @@
1
+ /* Copyright 2021, Milkdown by Mirone. */
2
+ import { imageBlockComponent, imageBlockConfig } from '@milkdown/components/image-block'
3
+ import { imageInlineComponent, inlineImageConfig } from '@milkdown/components/image-inline'
4
+ import { html } from 'atomico'
5
+ import type { DefineFeature } from '../shared'
6
+ import { injectStyle } from '../../core/slice'
7
+ import style from './style.css?inline'
8
+
9
+ const imageIcon = html`
10
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
11
+ <g clip-path="url(#clip0_1013_1596)">
12
+ <path d="M19 5V19H5V5H19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM14.14 11.86L11.14 15.73L9 13.14L6 17H18L14.14 11.86Z" fill="#817567"/>
13
+ </g>
14
+ <defs>
15
+ <clipPath id="clip0_1013_1596">
16
+ <rect width="24" height="24" fill="white"/>
17
+ </clipPath>
18
+ </defs>
19
+ </svg>
20
+ `
21
+
22
+ const confirmIcon = html`
23
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
24
+ <g clip-path="url(#clip0_1013_1606)">
25
+ <path d="M9.00012 16.1998L5.50012 12.6998C5.11012 12.3098 4.49012 12.3098 4.10012 12.6998C3.71012 13.0898 3.71012 13.7098 4.10012 14.0998L8.29012 18.2898C8.68012 18.6798 9.31012 18.6798 9.70012 18.2898L20.3001 7.69982C20.6901 7.30982 20.6901 6.68982 20.3001 6.29982C19.9101 5.90982 19.2901 5.90982 18.9001 6.29982L9.00012 16.1998Z" fill="#817567"/>
26
+ </g>
27
+ <defs>
28
+ <clipPath id="clip0_1013_1606">
29
+ <rect width="24" height="24" fill="white"/>
30
+ </clipPath>
31
+ </defs>
32
+ </svg>
33
+ `
34
+
35
+ const captionIcon = html`
36
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M9 22a1 1 0 0 1-1-1v-3H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6.1l-3.7 3.71c-.2.19-.45.29-.7.29zm1-6v3.08L13.08 16H20V4H4v12z"/></svg>
37
+ `
38
+
39
+ export const defineFeature: DefineFeature = (editor) => {
40
+ editor
41
+ .config(injectStyle(style))
42
+ .config((ctx) => {
43
+ ctx.update(inlineImageConfig.key, value => ({
44
+ ...value,
45
+ imageIcon: () => imageIcon,
46
+ confirmButton: () => confirmIcon,
47
+ uploadPlaceholderText: 'or paste link',
48
+ }))
49
+ ctx.update(imageBlockConfig.key, value => ({
50
+ ...value,
51
+ imageIcon: () => imageIcon,
52
+ captionIcon: () => captionIcon,
53
+ confirmButton: () => html`Confirm`,
54
+ captionPlaceholderText: 'Write Image Caption',
55
+ }))
56
+ })
57
+ .use(imageBlockComponent)
58
+ .use(imageInlineComponent)
59
+ }
@@ -0,0 +1,215 @@
1
+ .milkdown {
2
+ milkdown-image-inline {
3
+ &.empty.selected {
4
+ background: none;
5
+ outline: none;
6
+ .empty-image-inline {
7
+ box-shadow: var(--crepe-shadow-1);
8
+ }
9
+ }
10
+
11
+ &.selected {
12
+ background: none;
13
+ outline: 1px solid var(--crepe-color-primary);
14
+ ::selection {
15
+ background: transparent;
16
+ }
17
+ }
18
+
19
+ img.image-inline {
20
+ vertical-align: text-bottom;
21
+ }
22
+
23
+ .empty-image-inline {
24
+ align-items: center;
25
+ padding: 4px 10px;
26
+ gap: 10px;
27
+ background: var(--crepe-color-surface);
28
+ font-family: var(--crepe-font-default);
29
+ border-radius: 8px;
30
+ }
31
+
32
+ .empty-image-inline .image-icon {
33
+ svg {
34
+ width: 18px;
35
+ height: 18px;
36
+ }
37
+ padding: 3px;
38
+ width: 24px;
39
+ height: 24px;
40
+ }
41
+
42
+ .empty-image-inline .link-importer {
43
+ height: 24px;
44
+ }
45
+
46
+ .empty-image-inline .link-importer .placeholder {
47
+ color: color-mix(in srgb, var(--crepe-color-on-background), transparent 60%);
48
+ ::selection {
49
+ background: transparent;
50
+ }
51
+ }
52
+
53
+ .empty-image-inline .link-importer .link-input-area {
54
+ line-height: 24px;
55
+ }
56
+
57
+ .empty-image-inline .link-importer .placeholder .uploader {
58
+ gap: 8px;
59
+ color: var(--crepe-color-primary);
60
+ justify-content: center;
61
+ transition: color 0.2s;
62
+ font-family: var(--crepe-font-default);
63
+ }
64
+
65
+ .empty-image-inline .link-importer.focus .placeholder .uploader {
66
+ color: unset;
67
+ }
68
+
69
+ .empty-image-inline .link-importer .placeholder .uploader:hover {
70
+ color: var(--crepe-color-primary);
71
+ }
72
+
73
+ .empty-image-inline .link-importer .placeholder .text {
74
+ margin-left: 8px;
75
+ }
76
+
77
+ .empty-image-inline .confirm {
78
+ svg {
79
+ width: 18px;
80
+ height: 18px;
81
+ }
82
+ width: 24px;
83
+ height: 24px;
84
+ padding: 3px;
85
+ border-radius: 8px;
86
+ color: var(--crepe-color-primary);
87
+ &:hover {
88
+ background: var(--crepe-color-hover);
89
+ }
90
+ }
91
+ }
92
+
93
+ milkdown-image-block {
94
+ &.selected > .image-edit {
95
+ outline: 1px solid var(--crepe-color-outline);
96
+ }
97
+
98
+ &.selected {
99
+ & > .image-wrapper img {
100
+ outline: 1px solid var(--crepe-color-outline);
101
+ }
102
+ ::selection {
103
+ background: transparent;
104
+ }
105
+ }
106
+
107
+ .image-wrapper {
108
+ display: flex;
109
+ justify-content: center;
110
+ align-items: center;
111
+ }
112
+
113
+ .image-wrapper .operation {
114
+ gap: 16px;
115
+ right: 16px;
116
+ top: 16px;
117
+ opacity: 0;
118
+ transition: all 0.2s;
119
+ }
120
+
121
+ &:hover > .image-wrapper .operation {
122
+ opacity: 1;
123
+ }
124
+
125
+ .image-wrapper .operation > .operation-item {
126
+ color: var(--crepe-color-on-inverse);
127
+ padding: 8px;
128
+ background: var(--crepe-color-inverse);
129
+ opacity: 0.6;
130
+ border-radius: 50%;
131
+ width: 40px;
132
+ height: 40px;
133
+ svg {
134
+ width: 24px;
135
+ height: 24px;
136
+ }
137
+ }
138
+
139
+ .image-wrapper .image-resize-handle {
140
+ height: 4px;
141
+ bottom: -3px;
142
+ max-width: 160px;
143
+ width: 100%;
144
+ background: var(--crepe-color-outline);
145
+ opacity: 0;
146
+ transition: all 0.2s;
147
+ border-radius: 4px;
148
+ }
149
+
150
+ &:hover > .image-wrapper .image-resize-handle {
151
+ opacity: 1;
152
+ }
153
+
154
+ .caption-input {
155
+ margin: 16px auto;
156
+ font-family: var(--crepe-font-default);
157
+ }
158
+
159
+ .image-edit {
160
+ align-items: center;
161
+ padding: 16px 24px;
162
+ gap: 16px;
163
+ background: var(--crepe-color-surface);
164
+ height: 56px;
165
+ }
166
+
167
+ .image-edit .image-icon {
168
+ color: var(--crepe-color-outline);
169
+ }
170
+
171
+ .image-edit .image-icon svg {
172
+ width: 24px;
173
+ height: 24px;
174
+ }
175
+
176
+ .image-edit .link-importer .placeholder {
177
+ color: color-mix(in srgb, var(--crepe-color-on-background), transparent 60%);
178
+ ::selection {
179
+ background: transparent;
180
+ }
181
+ }
182
+
183
+ .image-edit .link-importer .link-input-area {
184
+ line-height: 24px;
185
+ }
186
+
187
+ .image-edit .link-importer .placeholder .uploader {
188
+ gap: 8px;
189
+ color: var(--crepe-color-primary);
190
+ justify-content: center;
191
+ transition: color 0.2s;
192
+ }
193
+
194
+ .image-edit .link-importer.focus .placeholder .uploader {
195
+ color: unset;
196
+ }
197
+
198
+ .image-edit .link-importer .placeholder .uploader:hover {
199
+ color: var(--crepe-color-primary);
200
+ }
201
+
202
+ .image-edit .link-importer .placeholder .text {
203
+ margin-left: 8px;
204
+ }
205
+
206
+ .image-edit .confirm {
207
+ background: var(--crepe-color-secondary);
208
+ color: var(--crepe-color-on-secondary);
209
+ line-height: 40px;
210
+ padding: 0 24px;
211
+ border-radius: 100px;
212
+ font-size: 14px;
213
+ }
214
+ }
215
+ }