2
0

style.tsx 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. import { Theme } from '@mui/material';
  2. export const getCMStyle = (theme: Theme) => {
  3. const isDark = theme.palette.mode === 'dark';
  4. return {
  5. '&.cm-editor': {
  6. backgroundColor: theme.palette.background.paper,
  7. color: theme.palette.text.primary,
  8. height: '100%',
  9. borderRadius: '4px',
  10. },
  11. '&.cm-editor.cm-focused': {
  12. outline: 'none',
  13. },
  14. '&.cm-editor .cm-cursor': {
  15. borderColor: theme.palette.text.primary,
  16. },
  17. '&.cm-editor .cm-scroller': {
  18. padding: '12px 0',
  19. borderRadius: '4px',
  20. overflow: 'auto',
  21. },
  22. '.cm-line': { padding: ' 0 4px 0 2px' },
  23. '.cm-line .cm-foldPlaceholder': {
  24. backgroundColor: 'transparent',
  25. border: 'none',
  26. },
  27. '.cm-content': {
  28. fontSize: '13px',
  29. fontFamily: 'IBM Plex Mono, monospace',
  30. padding: 0,
  31. },
  32. '.cm-activeLine': { backgroundColor: 'transparent' },
  33. '.cm-gutters': {
  34. fontSize: '13px',
  35. backgroundColor: theme.palette.background.paper,
  36. color: theme.palette.text.primary,
  37. border: 'none',
  38. },
  39. '.cm-lineNumbers .cm-gutterElement': {
  40. padding: '0 2px 0 20px',
  41. },
  42. '.cm-activeLineGutter': {
  43. backgroundColor: 'transparent',
  44. color: theme.palette.text.primary,
  45. },
  46. '&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection':
  47. {
  48. backgroundColor: theme.palette.primary.main,
  49. color: theme.palette.primary.contrastText,
  50. },
  51. // auto completion box style
  52. '.cm-tooltip.cm-tooltip-autocomplete': {
  53. border: 'none',
  54. borderRadius: '4px',
  55. transform: 'translateX(-20px)', // adjust box position to align with the text
  56. backgroundColor:
  57. theme.palette.mode === 'dark'
  58. ? theme.palette.grey[800]
  59. : theme.palette.background.paper,
  60. },
  61. '.cm-tooltip.cm-tooltip-autocomplete>ul': {
  62. fontFamily: 'IBM Plex Mono, monospace',
  63. maxHeight: '208px',
  64. border: '1px solid transparent',
  65. borderRadius: '4px',
  66. boxShadow: '0 4px 16px rgb(52 56 59 / 13%)',
  67. },
  68. '.cm-tooltip.cm-tooltip-autocomplete>ul li': {
  69. display: 'flex',
  70. gap: '12px',
  71. flexDirection: 'row',
  72. maxWidth: '400px',
  73. minWidth: '300px',
  74. whiteSpace: 'normal',
  75. paddingTop: '6px',
  76. border: 'none',
  77. borderColor: '#e2e3e5',
  78. paddingBottom: '8px',
  79. padding: '6px 12px 8px',
  80. transition: 'background 0.2s ease-in-out',
  81. },
  82. '.cm-tooltip-autocomplete .cm-completionLabel': {
  83. flex: 1,
  84. display: 'block',
  85. fontSize: '13.5px',
  86. fontWeight: 500,
  87. order: 1,
  88. },
  89. '.cm-tooltip-autocomplete .cm-completionLabel .cm-completionMatchedText': {
  90. textDecoration: 'none',
  91. fontWeight: 'bold',
  92. },
  93. '.cm-tooltip-autocomplete .cm-completionIcon': {
  94. display: 'block',
  95. fontSize: '13.5px',
  96. order: 2,
  97. },
  98. '.cm-tooltip-autocomplete .cm-completionDetail': {
  99. display: 'block',
  100. fontSize: '13.5px',
  101. order: 2,
  102. },
  103. '.cm-tooltip-autocomplete>ul>li[aria-selected=true]': {
  104. color: theme.palette.text.primary,
  105. backgroundColor: isDark
  106. ? 'rgba(10, 206, 130, 0.4)'
  107. : 'rgba(10, 206, 130, 0.2)',
  108. },
  109. '.cm-tooltip-autocomplete>ul>li[aria-selected=true] .cm-autocomplete-option-tab-badge':
  110. {
  111. opacity: 1,
  112. },
  113. '.cm-tooltip-autocomplete .cm-autocomplete-option-tab-badge': {
  114. display: 'inline-block',
  115. fontSize: '10px',
  116. color: theme.palette.primary.main,
  117. border: `1px solid ${theme.palette.primary.main}`,
  118. borderRadius: '2px',
  119. padding: '0 2px',
  120. height: '14px',
  121. lineHeight: '14px',
  122. opacity: 0,
  123. transition: 'opacity 0.2s ease-in-out',
  124. order: 3,
  125. },
  126. '.milvus-http-request-highlight': {
  127. backgroundColor: isDark
  128. ? 'rgba(255, 255, 255, 0.15)'
  129. : 'rgba(10, 206, 130, 0.08)',
  130. borderRadius: '3px',
  131. },
  132. '.milvus-http-request-error': {
  133. backgroundColor: 'rgba(255, 0, 0, 0.2)',
  134. borderRadius: '3px',
  135. },
  136. '.playground-toolbar': {
  137. display: 'inline',
  138. backgroundColor: 'rgba(0, 0, 0, 0.1)',
  139. borderRadius: '4px',
  140. },
  141. '.playground-codelens': {
  142. display: 'flex',
  143. alignItems: 'center',
  144. },
  145. '.playground-codelens .codelens-item': {
  146. position: 'relative',
  147. color: isDark ? '#999999' : '#919191',
  148. cursor: 'pointer',
  149. fontSize: '11px',
  150. lineHeight: '17px',
  151. letterSpacing: '0.5px',
  152. textDecoration: 'none',
  153. transition: 'color 0.2s ease-in-out',
  154. '&:hover': {
  155. color: theme.palette.primary.main,
  156. },
  157. '&:not(:last-child)': {
  158. marginRight: '16px',
  159. '&::after': {
  160. position: 'absolute',
  161. right: '-8px',
  162. top: '3px',
  163. display: 'inline-block',
  164. content: '""',
  165. borderRight: `1px solid ${isDark ? '#666666' : '#e0e0e0'}`,
  166. height: '10px',
  167. },
  168. },
  169. },
  170. '.cm-line .token-node': {
  171. color: isDark ? '#50fa7b' : '#006600',
  172. },
  173. '.cm-line .cm-widgetBuffer': {
  174. height: '17px',
  175. },
  176. '.cm-gutter .cm-codelens-marker': {
  177. paddingTop: '17px',
  178. },
  179. '.cm-content[data-language="json"]': {
  180. paddingLeft: '18px',
  181. },
  182. };
  183. };