]> BookStack Code Mirror - bookstack/blob - resources/assets/sass/_codemirror.scss
Added copy button to codemirror-rendered code blocks
[bookstack] / resources / assets / sass / _codemirror.scss
1 /* BASICS */
2
3 .CodeMirror {
4   /* Set height, width, borders, and global font properties here */
5   height: 300px;
6   color: black;
7 }
8
9 /* PADDING */
10
11 .CodeMirror-lines {
12   padding: 4px 0; /* Vertical padding around content */
13 }
14 .CodeMirror pre {
15   padding: 0 4px; /* Horizontal padding of content */
16 }
17
18 .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
19   background-color: white; /* The little square between H and V scrollbars */
20 }
21
22 /* GUTTER */
23
24 .CodeMirror-gutters {
25   border-right: 1px solid #ddd;
26   background-color: #f7f7f7;
27   white-space: nowrap;
28 }
29 .CodeMirror-linenumbers {}
30 .CodeMirror-linenumber {
31   padding: 0 3px 0 5px;
32   min-width: 20px;
33   text-align: right;
34   color: #999;
35   white-space: nowrap;
36 }
37
38 .CodeMirror-guttermarker { color: black; }
39 .CodeMirror-guttermarker-subtle { color: #999; }
40
41 /* CURSOR */
42
43 .CodeMirror-cursor {
44   border-left: 1px solid black;
45   border-right: none;
46   width: 0;
47 }
48 /* Shown when moving in bi-directional text */
49 .CodeMirror div.CodeMirror-secondarycursor {
50   border-left: 1px solid silver;
51 }
52 .cm-fat-cursor .CodeMirror-cursor {
53   width: auto;
54   border: 0 !important;
55   background: #7e7;
56 }
57 .cm-fat-cursor div.CodeMirror-cursors {
58   z-index: 1;
59 }
60
61 .cm-animate-fat-cursor {
62   width: auto;
63   border: 0;
64   -webkit-animation: blink 1.06s steps(1) infinite;
65   -moz-animation: blink 1.06s steps(1) infinite;
66   animation: blink 1.06s steps(1) infinite;
67   background-color: #7e7;
68 }
69 @-moz-keyframes blink {
70   0% {}
71   50% { background-color: transparent; }
72   100% {}
73 }
74 @-webkit-keyframes blink {
75   0% {}
76   50% { background-color: transparent; }
77   100% {}
78 }
79 @keyframes blink {
80   0% {}
81   50% { background-color: transparent; }
82   100% {}
83 }
84
85 /* Can style cursor different in overwrite (non-insert) mode */
86 .CodeMirror-overwrite .CodeMirror-cursor {}
87
88 .cm-tab { display: inline-block; text-decoration: inherit; }
89
90 .CodeMirror-rulers {
91   position: absolute;
92   left: 0; right: 0; top: -50px; bottom: -20px;
93   overflow: hidden;
94 }
95 .CodeMirror-ruler {
96   border-left: 1px solid #ccc;
97   top: 0; bottom: 0;
98   position: absolute;
99 }
100
101 /* DEFAULT THEME */
102
103 .cm-s-default .cm-header {color: blue;}
104 .cm-s-default .cm-quote {color: #090;}
105 .cm-negative {color: #d44;}
106 .cm-positive {color: #292;}
107 .cm-header, .cm-strong {font-weight: bold;}
108 .cm-em {font-style: italic;}
109 .cm-link {text-decoration: underline;}
110 .cm-strikethrough {text-decoration: line-through;}
111
112 .cm-s-default .cm-keyword {color: #708;}
113 .cm-s-default .cm-atom {color: #219;}
114 .cm-s-default .cm-number {color: #164;}
115 .cm-s-default .cm-def {color: #00f;}
116 .cm-s-default .cm-variable,
117 .cm-s-default .cm-punctuation,
118 .cm-s-default .cm-property,
119 .cm-s-default .cm-operator {}
120 .cm-s-default .cm-variable-2 {color: #05a;}
121 .cm-s-default .cm-variable-3 {color: #085;}
122 .cm-s-default .cm-comment {color: #a50;}
123 .cm-s-default .cm-string {color: #a11;}
124 .cm-s-default .cm-string-2 {color: #f50;}
125 .cm-s-default .cm-meta {color: #555;}
126 .cm-s-default .cm-qualifier {color: #555;}
127 .cm-s-default .cm-builtin {color: #30a;}
128 .cm-s-default .cm-bracket {color: #997;}
129 .cm-s-default .cm-tag {color: #170;}
130 .cm-s-default .cm-attribute {color: #00c;}
131 .cm-s-default .cm-hr {color: #999;}
132 .cm-s-default .cm-link {color: #00c;}
133
134 .cm-s-default .cm-error {color: #f00;}
135 .cm-invalidchar {color: #f00;}
136
137 .CodeMirror-composing { border-bottom: 2px solid; }
138
139 /* Default styles for common addons */
140
141 div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
142 div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
143 .CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
144 .CodeMirror-activeline-background {background: #e8f2ff;}
145
146 /* STOP */
147
148 /* The rest of this file contains styles related to the mechanics of
149    the editor. You probably shouldn't touch them. */
150
151 .CodeMirror {
152   position: relative;
153   overflow: hidden;
154   background: white;
155 }
156
157 .CodeMirror-scroll {
158   overflow: scroll !important; /* Things will break if this is overridden */
159   /* 30px is the magic margin used to hide the element's real scrollbars */
160   /* See overflow: hidden in .CodeMirror */
161   margin-bottom: -30px; margin-right: -30px;
162   padding-bottom: 30px;
163   height: 100%;
164   outline: none; /* Prevent dragging from highlighting the element */
165   position: relative;
166 }
167 .CodeMirror-sizer {
168   position: relative;
169   border-right: 30px solid transparent;
170 }
171
172 /* The fake, visible scrollbars. Used to force redraw during scrolling
173    before actual scrolling happens, thus preventing shaking and
174    flickering artifacts. */
175 .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
176   position: absolute;
177   z-index: 6;
178   display: none;
179 }
180 .CodeMirror-vscrollbar {
181   right: 0; top: 0;
182   overflow-x: hidden;
183   overflow-y: scroll;
184 }
185 .CodeMirror-hscrollbar {
186   bottom: 0; left: 0;
187   overflow-y: hidden;
188   overflow-x: scroll;
189 }
190 .CodeMirror-scrollbar-filler {
191   right: 0; bottom: 0;
192 }
193 .CodeMirror-gutter-filler {
194   left: 0; bottom: 0;
195 }
196
197 .CodeMirror-gutters {
198   position: absolute; left: 0; top: 0;
199   min-height: 100%;
200   z-index: 3;
201 }
202 .CodeMirror-gutter {
203   white-space: normal;
204   height: 100%;
205   display: inline-block;
206   vertical-align: top;
207   margin-bottom: -30px;
208 }
209 .CodeMirror-gutter-wrapper {
210   position: absolute;
211   z-index: 4;
212   background: none !important;
213   border: none !important;
214 }
215 .CodeMirror-gutter-background {
216   position: absolute;
217   top: 0; bottom: 0;
218   z-index: 4;
219 }
220 .CodeMirror-gutter-elt {
221   position: absolute;
222   cursor: default;
223   z-index: 4;
224 }
225 .CodeMirror-gutter-wrapper ::selection { background-color: transparent }
226 .CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
227
228 .CodeMirror-lines {
229   cursor: text;
230   min-height: 1px; /* prevents collapsing before first draw */
231 }
232 .CodeMirror pre {
233   /* Reset some styles that the rest of the page might have set */
234   -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
235   border-width: 0;
236   background: transparent;
237   font-size: inherit;
238   margin: 0;
239   white-space: pre;
240   word-wrap: normal;
241   line-height: inherit;
242   color: inherit;
243   z-index: 2;
244   position: relative;
245   overflow: visible;
246   -webkit-tap-highlight-color: transparent;
247   -webkit-font-variant-ligatures: contextual;
248   font-variant-ligatures: contextual;
249   &:after {
250     content: none;
251     display: none;
252   }
253 }
254 .CodeMirror-wrap pre {
255   word-wrap: break-word;
256   white-space: pre-wrap;
257   word-break: normal;
258 }
259
260 .CodeMirror-linebackground {
261   position: absolute;
262   left: 0; right: 0; top: 0; bottom: 0;
263   z-index: 0;
264 }
265
266 .CodeMirror-linewidget {
267   position: relative;
268   z-index: 2;
269   overflow: auto;
270 }
271
272 .CodeMirror-widget {}
273
274 .CodeMirror-rtl pre { direction: rtl; }
275
276 .CodeMirror-code {
277   outline: none;
278 }
279
280 /* Force content-box sizing for the elements where we expect it */
281 .CodeMirror-scroll,
282 .CodeMirror-sizer,
283 .CodeMirror-gutter,
284 .CodeMirror-gutters,
285 .CodeMirror-linenumber {
286   -moz-box-sizing: content-box;
287   box-sizing: content-box;
288 }
289
290 .CodeMirror-measure {
291   position: absolute;
292   width: 100%;
293   height: 0;
294   overflow: hidden;
295   visibility: hidden;
296 }
297
298 .CodeMirror-cursor {
299   position: absolute;
300   pointer-events: none;
301 }
302 .CodeMirror-measure pre { position: static; }
303
304 div.CodeMirror-cursors {
305   visibility: hidden;
306   position: relative;
307   z-index: 3;
308 }
309 div.CodeMirror-dragcursors {
310   visibility: visible;
311 }
312
313 .CodeMirror-focused div.CodeMirror-cursors {
314   visibility: visible;
315 }
316
317 .CodeMirror-selected { background: #d9d9d9; }
318 .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
319 .CodeMirror-crosshair { cursor: crosshair; }
320 .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
321 .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
322
323 .cm-searching {
324   background: #ffa;
325   background: rgba(255, 255, 0, .4);
326 }
327
328 /* Used to force a border model for a node */
329 .cm-force-border { padding-right: .1px; }
330
331 @media print {
332   /* Hide the cursor when printing */
333   .CodeMirror div.CodeMirror-cursors {
334     visibility: hidden;
335   }
336 }
337
338 /* See issue #2901 */
339 .cm-tab-wrap-hack:after { content: ''; }
340
341 /* Help users use markselection to safely style text background */
342 span.CodeMirror-selectedtext { background: none; }
343
344
345 /*
346
347     Name:       Base16 Default Light
348     Author:     Chris Kempson (http://chriskempson.com)
349
350     CodeMirror template by Jan T. Sott (https://github.com/idleberg/base16-codemirror)
351     Original Base16 color scheme by Chris Kempson (https://github.com/chriskempson/base16)
352
353 */
354
355 .cm-s-base16-light.CodeMirror { background: #f8f8f8; color: #444444; }
356 .cm-s-base16-light div.CodeMirror-selected { background: #e0e0e0; }
357 .cm-s-base16-light .CodeMirror-line::selection, .cm-s-base16-light .CodeMirror-line > span::selection, .cm-s-base16-light .CodeMirror-line > span > span::selection { background: #e0e0e0; }
358 .cm-s-base16-light .CodeMirror-line::-moz-selection, .cm-s-base16-light .CodeMirror-line > span::-moz-selection, .cm-s-base16-light .CodeMirror-line > span > span::-moz-selection { background: #e0e0e0; }
359 .cm-s-base16-light .CodeMirror-gutters { background: #f5f5f5; border-right: 0px; }
360 .cm-s-base16-light .CodeMirror-guttermarker { color: #ac4142; }
361 .cm-s-base16-light .CodeMirror-guttermarker-subtle { color: #b0b0b0; }
362 .cm-s-base16-light .CodeMirror-linenumber { color: #b0b0b0; }
363 .cm-s-base16-light .CodeMirror-cursor { border-left: 1px solid #505050; }
364
365 .cm-s-base16-light span.cm-comment { color: #8f5536; }
366 .cm-s-base16-light span.cm-atom { color: #aa759f; }
367 .cm-s-base16-light span.cm-number { color: #aa759f; }
368
369 .cm-s-base16-light span.cm-property, .cm-s-base16-light span.cm-attribute { color: #678c30; }
370 .cm-s-base16-light span.cm-keyword { color: #ac4142; }
371 .cm-s-base16-light span.cm-string { color: #e09c3c; }
372
373 .cm-s-base16-light span.cm-builtin { color: #4c7f9e; }
374 .cm-s-base16-light span.cm-variable { color: #90a959; }
375 .cm-s-base16-light span.cm-variable-2 { color: #6a9fb5; }
376 .cm-s-base16-light span.cm-def { color: #d28445; }
377 .cm-s-base16-light span.cm-bracket { color: #202020; }
378 .cm-s-base16-light span.cm-tag { color: #ac4142; }
379 .cm-s-base16-light span.cm-link { color: #aa759f; }
380 .cm-s-base16-light span.cm-error { background: #ac4142; color: #505050; }
381
382 .cm-s-base16-light .CodeMirror-activeline-background { background: #DDDCDC; }
383 .cm-s-base16-light .CodeMirror-matchingbracket { text-decoration: underline; color: white !important; }
384
385 /**
386  * Custom BookStack overrides
387  */
388 .CodeMirror, .CodeMirror pre {
389   font-size: 12px;
390 }
391 .CodeMirror {
392   font-size: 12px;
393   height: auto;
394   margin-bottom: $-l;
395   border: 1px solid #DDD;;
396 }
397 .cm-s-base16-light .CodeMirror-gutters { background: #f5f5f5; border-right: 1px solid #DDD; }
398
399 .code-fill .CodeMirror {
400   position: absolute;
401   top: 0;
402   bottom: 0;
403   left: 0;
404   width: 100%;
405   height: 100%;
406 }
407
408 /**
409  * Custom Copy Button
410  */
411 .CodeMirror-copy {
412   position: absolute;
413   top: -1px;
414   right: -1px;
415   background-color: #EEE;
416   padding: $-xs;
417   line-height: 0;
418   border: 1px solid #DDD;
419   cursor: pointer;
420   fill: #444;
421   z-index: 5;
422   transition: all ease-in 180ms;
423   user-select: none;
424   opacity: 0.7;
425   svg {
426     transition: transform ease-in 180ms;
427     transform: translateY(0);
428   }
429   &.success {
430     background-color: lighten($positive, 10%);
431     fill: #FFF;
432     svg {
433       transform: translateY(-3px);
434     }
435   }
436 }
437 .CodeMirror:hover .CodeMirror-copy {
438   user-select: all;
439   opacity: 1;
440 }