2
0

editor-markdown.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. <template lang='pug'>
  2. .editor-markdown
  3. v-toolbar.editor-markdown-toolbar(dense, color='primary', dark, flat)
  4. v-btn.animated.fadeInLeft(v-if='isModalShown', flat, @click='closeAllModal')
  5. v-icon(left) chevron_left
  6. span Back
  7. template(v-else)
  8. v-tooltip(bottom, color='primary')
  9. v-btn.animated.fadeIn(icon, slot='activator', @click='toggleMarkup({ start: `**` })').mx-0
  10. v-icon format_bold
  11. span Bold
  12. v-tooltip(bottom, color='primary')
  13. v-btn.animated.fadeIn.wait-p1s(icon, slot='activator', @click='toggleMarkup({ start: `*` })').mx-0
  14. v-icon format_italic
  15. span Italic
  16. v-tooltip(bottom, color='primary')
  17. v-btn.animated.fadeIn.wait-p2s(icon, slot='activator', @click='toggleMarkup({ start: `~~` })').mx-0
  18. v-icon format_strikethrough
  19. span Strikethrough
  20. v-menu(offset-y, open-on-hover)
  21. v-btn.animated.fadeIn.wait-p3s(icon, slot='activator').mx-0
  22. v-icon text_fields
  23. v-list.py-0
  24. template(v-for='(n, idx) in 6')
  25. v-list-tile(@click='setHeaderLine(n)', :key='idx')
  26. v-list-tile-action
  27. v-icon(:size='24 - (idx - 1) * 2') title
  28. v-list-tile-title Heading {{n}}
  29. v-divider(v-if='idx < 5')
  30. v-tooltip(bottom, color='primary')
  31. v-btn.animated.fadeIn.wait-p4s(icon, slot='activator', @click='toggleMarkup({ start: `~` })').mx-0
  32. v-icon vertical_align_bottom
  33. span Subscript
  34. v-tooltip(bottom, color='primary')
  35. v-btn.animated.fadeIn.wait-p5s(icon, slot='activator', @click='toggleMarkup({ start: `^` })').mx-0
  36. v-icon vertical_align_top
  37. span Superscript
  38. v-menu(offset-y, open-on-hover)
  39. v-btn.animated.fadeIn.wait-p6s(icon, slot='activator').mx-0
  40. v-icon format_quote
  41. v-list.py-0
  42. v-list-tile(@click='insertBeforeEachLine({ content: `> `})')
  43. v-list-tile-action
  44. v-icon format_quote
  45. v-list-tile-title Blockquote
  46. v-divider
  47. v-list-tile(@click='insertBeforeEachLine({ content: `> `, after: `{.is-info}`})')
  48. v-list-tile-action
  49. v-icon(color='blue') format_quote
  50. v-list-tile-title Info Blockquote
  51. v-divider
  52. v-list-tile(@click='insertBeforeEachLine({ content: `> `, after: `{.is-success}`})')
  53. v-list-tile-action
  54. v-icon(color='success') format_quote
  55. v-list-tile-title Success Blockquote
  56. v-divider
  57. v-list-tile(@click='insertBeforeEachLine({ content: `> `, after: `{.is-warning}`})')
  58. v-list-tile-action
  59. v-icon(color='warning') format_quote
  60. v-list-tile-title Warning Blockquote
  61. v-divider
  62. v-list-tile(@click='insertBeforeEachLine({ content: `> `, after: `{.is-error}`})')
  63. v-list-tile-action
  64. v-icon(color='error') format_quote
  65. v-list-tile-title Error Blockquote
  66. v-divider
  67. v-tooltip(bottom, color='primary')
  68. v-btn.animated.fadeIn.wait-p7s(icon, slot='activator', @click='insertBeforeEachLine({ content: `- `})').mx-0
  69. v-icon format_list_bulleted
  70. span Unordered List
  71. v-tooltip(bottom, color='primary')
  72. v-btn.animated.fadeIn.wait-p8s(icon, slot='activator', @click='insertBeforeEachLine({ content: `1. `})').mx-0
  73. v-icon format_list_numbered
  74. span Ordered List
  75. v-tooltip(bottom, color='primary')
  76. v-btn.animated.fadeIn.wait-p9s(icon, slot='activator', @click='toggleMarkup({ start: "`" })').mx-0
  77. v-icon space_bar
  78. span Inline Code
  79. v-tooltip(bottom, color='primary')
  80. v-btn.animated.fadeIn.wait-p10s(icon, slot='activator', @click='toggleMarkup({ start: `<kbd>`, end: `</kbd>` })').mx-0
  81. v-icon font_download
  82. span Keyboard Key
  83. v-tooltip(bottom, color='primary')
  84. v-btn.animated.fadeIn.wait-p11s(icon, slot='activator', @click='insertAfter({ content: `---`, newLine: true })').mx-0
  85. v-icon remove
  86. span Horizontal Bar
  87. .editor-markdown-main
  88. .editor-markdown-sidebar
  89. v-tooltip(right, color='teal')
  90. v-btn.animated.fadeInLeft(icon, slot='activator', dark, disabled).mx-0
  91. v-icon link
  92. span Insert Link
  93. v-tooltip(right, color='teal')
  94. v-btn.animated.fadeInLeft.wait-p1s(icon, slot='activator', dark, @click='toggleModal(`editorModalMedia`)').mx-0
  95. v-icon(:color='activeModal === `editorModalMedia` ? `teal` : ``') image
  96. span Insert Image
  97. v-tooltip(right, color='teal')
  98. v-btn.animated.fadeInLeft.wait-p2s(icon, slot='activator', dark, @click='toggleModal(`editorModalBlocks`)').mx-0
  99. v-icon(:color='activeModal === `editorModalBlocks` ? `teal` : ``') dashboard
  100. span Insert Block
  101. v-tooltip(right, color='teal')
  102. v-btn.animated.fadeInLeft.wait-p3s(icon, slot='activator', dark, disabled).mx-0
  103. v-icon insert_drive_file
  104. span Insert File
  105. v-tooltip(right, color='teal')
  106. v-btn.animated.fadeInLeft.wait-p4s(icon, slot='activator', dark, disabled).mx-0
  107. v-icon code
  108. span Insert Code Block
  109. v-tooltip(right, color='teal')
  110. v-btn.animated.fadeInLeft.wait-p5s(icon, slot='activator', dark, disabled).mx-0
  111. v-icon play_circle_outline
  112. span Insert Video / Audio
  113. v-tooltip(right, color='teal')
  114. v-btn.animated.fadeInLeft.wait-p6s(icon, slot='activator', dark, disabled).mx-0
  115. v-icon multiline_chart
  116. span Insert Diagram
  117. v-tooltip(right, color='teal')
  118. v-btn.animated.fadeInLeft.wait-p7s(icon, slot='activator', dark, disabled).mx-0
  119. v-icon functions
  120. span Insert Math Expression
  121. v-tooltip(right, color='teal')
  122. v-btn.animated.fadeInLeft.wait-p8s(icon, slot='activator', dark, disabled).mx-0
  123. v-icon border_outer
  124. span Table Helper
  125. v-spacer
  126. v-tooltip(right, color='teal')
  127. v-btn.animated.fadeInLeft.wait-p9s(icon, slot='activator', dark, @click='toggleFullscreen').mx-0
  128. v-icon crop_free
  129. span Distraction Free Mode
  130. v-tooltip(right, color='teal')
  131. v-btn.animated.fadeInLeft.wait-p10s(icon, slot='activator', dark, @click='toggleHelp').mx-0
  132. v-icon(:color='helpShown ? `teal` : ``') help
  133. span Markdown Formatting Help
  134. .editor-markdown-editor
  135. .editor-markdown-editor-title(v-if='previewShown', @click='previewShown = false') Editor
  136. .editor-markdown-editor-title(v-else='previewShown', @click='previewShown = true'): v-icon(dark) drag_indicator
  137. codemirror(ref='cm', v-model='code', :options='cmOptions', @ready='onCmReady', @input='onCmInput')
  138. transition(name='editor-markdown-preview')
  139. .editor-markdown-preview(v-if='previewShown')
  140. .editor-markdown-preview-title(@click='previewShown = false') Preview
  141. .editor-markdown-preview-content.contents(ref='editorPreview', v-html='previewHTML')
  142. v-system-bar.editor-markdown-sysbar(dark, status, color='grey darken-3')
  143. .caption.editor-markdown-sysbar-locale {{locale.toUpperCase()}}
  144. .caption.px-3 /{{path}}
  145. v-spacer
  146. .caption Markdown
  147. v-spacer
  148. .caption Ln {{cursorPos.line + 1}}, Col {{cursorPos.ch + 1}}
  149. markdown-help(v-if='helpShown')
  150. </template>
  151. <script>
  152. import _ from 'lodash'
  153. import { get, sync } from 'vuex-pathify'
  154. import markdownHelp from './markdown/help.vue'
  155. // ========================================
  156. // IMPORTS
  157. // ========================================
  158. // Code Mirror
  159. import { codemirror } from 'vue-codemirror'
  160. import 'codemirror/lib/codemirror.css'
  161. // Language
  162. import 'codemirror/mode/markdown/markdown.js'
  163. // Addons
  164. import 'codemirror/addon/selection/active-line.js'
  165. import 'codemirror/addon/display/fullscreen.js'
  166. import 'codemirror/addon/display/fullscreen.css'
  167. import 'codemirror/addon/selection/mark-selection.js'
  168. import 'codemirror/addon/search/searchcursor.js'
  169. // Markdown-it
  170. import MarkdownIt from 'markdown-it'
  171. import mdAttrs from 'markdown-it-attrs'
  172. import mdEmoji from 'markdown-it-emoji'
  173. import mdTaskLists from 'markdown-it-task-lists'
  174. import mdExpandTabs from 'markdown-it-expand-tabs'
  175. import mdAbbr from 'markdown-it-abbr'
  176. import mdSup from 'markdown-it-sup'
  177. import mdSub from 'markdown-it-sub'
  178. import mdMark from 'markdown-it-mark'
  179. import mdImsize from 'markdown-it-imsize'
  180. // Prism (Syntax Highlighting)
  181. import Prism from '@/libs/prism/prism.js'
  182. // ========================================
  183. // INIT
  184. // ========================================
  185. // Platform detection
  186. const CtrlKey = /Mac/.test(navigator.platform) ? 'Cmd' : 'Ctrl'
  187. // Markdown Instance
  188. const md = new MarkdownIt({
  189. html: true,
  190. breaks: true,
  191. linkify: true,
  192. typography: true,
  193. highlight(str, lang) {
  194. return `<pre class="line-numbers"><code class="language-${lang}">${str}</code></pre>`
  195. }
  196. })
  197. .use(mdAttrs)
  198. .use(mdEmoji)
  199. .use(mdTaskLists, {label: true, labelAfter: true})
  200. .use(mdExpandTabs)
  201. .use(mdAbbr)
  202. .use(mdSup)
  203. .use(mdSub)
  204. .use(mdMark)
  205. .use(mdImsize)
  206. // ========================================
  207. // HELPER FUNCTIONS
  208. // ========================================
  209. // Inject line numbers for preview scroll sync
  210. let linesMap = []
  211. function injectLineNumbers (tokens, idx, options, env, slf) {
  212. let line
  213. if (tokens[idx].map && tokens[idx].level === 0) {
  214. line = tokens[idx].map[0]
  215. tokens[idx].attrJoin('class', 'line')
  216. tokens[idx].attrSet('data-line', String(line))
  217. linesMap.push(line)
  218. }
  219. return slf.renderToken(tokens, idx, options, env, slf)
  220. }
  221. md.renderer.rules.paragraph_open = injectLineNumbers
  222. md.renderer.rules.heading_open = injectLineNumbers
  223. // ========================================
  224. // Vue Component
  225. // ========================================
  226. export default {
  227. components: {
  228. codemirror,
  229. markdownHelp
  230. },
  231. props: {
  232. save: {
  233. type: Function
  234. }
  235. },
  236. data() {
  237. return {
  238. fabInsertMenu: false,
  239. code: this.$store.get('editor/content'),
  240. cmOptions: {
  241. tabSize: 2,
  242. mode: 'text/markdown',
  243. theme: 'wikijs-dark',
  244. lineNumbers: true,
  245. lineWrapping: true,
  246. line: true,
  247. styleActiveLine: true,
  248. highlightSelectionMatches: {
  249. annotateScrollbar: true
  250. },
  251. viewportMargin: 50
  252. },
  253. cursorPos: { ch: 0, line: 1 },
  254. previewShown: true,
  255. previewHTML: '',
  256. helpShown: false
  257. }
  258. },
  259. computed: {
  260. cm() {
  261. return this.$refs.cm.codemirror
  262. },
  263. isMobile() {
  264. return this.$vuetify.breakpoint.smAndDown
  265. },
  266. isModalShown() {
  267. return this.helpShown || this.activeModal !== ''
  268. },
  269. locale: get('page/locale'),
  270. path: get('page/path'),
  271. activeModal: sync('editor/activeModal')
  272. },
  273. methods: {
  274. toggleModal(key) {
  275. this.activeModal = (this.activeModal === key) ? '' : key
  276. this.helpShown = false
  277. },
  278. closeAllModal() {
  279. this.activeModal = ''
  280. this.helpShown = false
  281. },
  282. onCmReady(cm) {
  283. const keyBindings = {
  284. 'F11' (cm) {
  285. cm.setOption('fullScreen', !cm.getOption('fullScreen'))
  286. },
  287. 'Esc' (cm) {
  288. if (cm.getOption('fullScreen')) cm.setOption('fullScreen', false)
  289. }
  290. }
  291. _.set(keyBindings, `${CtrlKey}-S`, cm => {
  292. this.save()
  293. return false
  294. })
  295. _.set(keyBindings, `${CtrlKey}-B`, cm => {
  296. this.toggleMarkup({ start: `**` })
  297. return false
  298. })
  299. _.set(keyBindings, `${CtrlKey}-I`, cm => {
  300. this.toggleMarkup({ start: `*` })
  301. return false
  302. })
  303. _.set(keyBindings, `${CtrlKey}-Alt-Right`, cm => {
  304. let lvl = this.getHeaderLevel(cm)
  305. if (lvl >= 6) { lvl = 5 }
  306. this.setHeaderLine(lvl + 1)
  307. return false
  308. })
  309. _.set(keyBindings, `${CtrlKey}-Alt-Left`, cm => {
  310. let lvl = this.getHeaderLevel(cm)
  311. if (lvl <= 1) { lvl = 2 }
  312. this.setHeaderLine(lvl - 1)
  313. return false
  314. })
  315. cm.setSize(null, 'calc(100vh - 112px - 24px)')
  316. cm.setOption('extraKeys', keyBindings)
  317. cm.on('cursorActivity', cm => {
  318. this.positionSync(cm)
  319. this.scrollSync(cm)
  320. })
  321. this.onCmInput(this.code)
  322. },
  323. onCmInput: _.debounce(function (newContent) {
  324. linesMap = []
  325. this.$store.set('editor/content', newContent)
  326. this.previewHTML = md.render(newContent)
  327. this.$nextTick(() => {
  328. Prism.highlightAllUnder(this.$refs.editorPreview)
  329. Array.from(this.$refs.editorPreview.querySelectorAll('pre.line-numbers')).forEach(pre => pre.classList.add('prismjs'))
  330. this.scrollSync(this.cm)
  331. })
  332. }, 500),
  333. /**
  334. * Update cursor state
  335. */
  336. positionSync(cm) {
  337. this.cursorPos = cm.getCursor('head')
  338. },
  339. /**
  340. * Wrap selection with start / end tags
  341. */
  342. toggleMarkup({ start, end }) {
  343. if (!end) { end = start }
  344. if (!this.cm.doc.somethingSelected()) {
  345. return this.$store.commit('showNotification', {
  346. message: 'You must select something first!',
  347. style: 'warning',
  348. icon: 'warning'
  349. })
  350. }
  351. this.cm.doc.replaceSelections(this.cm.doc.getSelections().map(s => start + s + end))
  352. },
  353. /**
  354. * Set current line as header
  355. */
  356. setHeaderLine(lvl) {
  357. const curLine = this.cm.doc.getCursor('head').line
  358. let lineContent = this.cm.doc.getLine(curLine)
  359. const lineLength = lineContent.length
  360. if (_.startsWith(lineContent, '#')) {
  361. lineContent = lineContent.replace(/^(#+ )/, '')
  362. }
  363. lineContent = _.times(lvl, n => '#').join('') + ` ` + lineContent
  364. this.cm.doc.replaceRange(lineContent, { line: curLine, ch: 0 }, { line: curLine, ch: lineLength })
  365. },
  366. /**
  367. * Get the header lever of the current line
  368. */
  369. getHeaderLevel(cm) {
  370. const curLine = this.cm.doc.getCursor('head').line
  371. let lineContent = this.cm.doc.getLine(curLine)
  372. let lvl = 0
  373. const result = lineContent.match(/^(#+) /)
  374. if (result) {
  375. lvl = _.get(result, '[1]', '').length
  376. }
  377. return lvl
  378. },
  379. /**
  380. * Insert content after current line
  381. */
  382. insertAfter({ content, newLine }) {
  383. const curLine = this.cm.doc.getCursor('to').line
  384. const lineLength = this.cm.doc.getLine(curLine).length
  385. this.cm.doc.replaceRange(newLine ? `\n${content}\n` : content, { line: curLine, ch: lineLength + 1 })
  386. },
  387. /**
  388. * Insert content before current line
  389. */
  390. insertBeforeEachLine({ content, after }) {
  391. let lines = []
  392. if (!this.cm.doc.somethingSelected()) {
  393. lines.push(this.cm.doc.getCursor('head').line)
  394. } else {
  395. lines = _.flatten(this.cm.doc.listSelections().map(sl => {
  396. const range = Math.abs(sl.anchor.line - sl.head.line) + 1
  397. const lowestLine = (sl.anchor.line > sl.head.line) ? sl.head.line : sl.anchor.line
  398. return _.times(range, l => l + lowestLine)
  399. }))
  400. }
  401. lines.forEach(ln => {
  402. let lineContent = this.cm.doc.getLine(ln)
  403. const lineLength = lineContent.length
  404. if (_.startsWith(lineContent, content)) {
  405. lineContent = lineContent.substring(content.length)
  406. }
  407. this.cm.doc.replaceRange(content + lineContent, { line: ln, ch: 0 }, { line: ln, ch: lineLength })
  408. })
  409. if (after) {
  410. const lastLine = _.last(lines)
  411. this.cm.doc.replaceRange(`\n${after}\n`, { line: lastLine, ch: this.cm.doc.getLine(lastLine).length + 1 })
  412. }
  413. },
  414. /**
  415. * Update scroll sync
  416. */
  417. scrollSync: _.debounce(function (cm) {
  418. if (!this.previewShown || cm.somethingSelected()) { return }
  419. let currentLine = cm.getCursor().line
  420. if (currentLine < 3) {
  421. this.Velocity(this.$refs.editorPreview, 'stop', true)
  422. this.Velocity(this.$refs.editorPreview.firstChild, 'scroll', { offset: '-50', duration: 1000, container: this.$refs.editorPreview })
  423. } else {
  424. let closestLine = _.findLast(linesMap, n => n <= currentLine)
  425. let destElm = this.$refs.editorPreview.querySelector(`[data-line='${closestLine}']`)
  426. if (destElm) {
  427. this.Velocity(this.$refs.editorPreview, 'stop', true)
  428. this.Velocity(destElm, 'scroll', { offset: '-100', duration: 1000, container: this.$refs.editorPreview })
  429. }
  430. }
  431. }, 500),
  432. toggleHelp () {
  433. this.helpShown = !this.helpShown
  434. this.activeModal = ''
  435. },
  436. toggleFullscreen () {
  437. this.cm.setOption('fullScreen', true)
  438. }
  439. }
  440. }
  441. </script>
  442. <style lang='scss'>
  443. $editor-height: calc(100vh - 112px - 24px);
  444. .editor-markdown {
  445. &-main {
  446. display: flex;
  447. width: 100%;
  448. }
  449. &-editor {
  450. background-color: darken(mc('grey', '900'), 4.5%);
  451. flex: 1 1 50%;
  452. display: block;
  453. height: $editor-height;
  454. position: relative;
  455. &-title {
  456. background-color: mc('grey', '800');
  457. border-bottom-left-radius: 5px;
  458. display: inline-flex;
  459. height: 30px;
  460. justify-content: center;
  461. align-items: center;
  462. padding: 0 1rem;
  463. color: mc('grey', '500');
  464. position: absolute;
  465. top: 0;
  466. right: 0;
  467. z-index: 7;
  468. text-transform: uppercase;
  469. font-size: .7rem;
  470. cursor: pointer;
  471. @include until($tablet) {
  472. display: none;
  473. }
  474. }
  475. }
  476. &-preview {
  477. flex: 1 1 50%;
  478. background-color: mc('grey', '100');
  479. position: relative;
  480. height: $editor-height;
  481. overflow: hidden;
  482. @at-root .theme--dark & {
  483. background-color: mc('grey', '900');
  484. }
  485. @include until($tablet) {
  486. display: none;
  487. }
  488. &-enter-active, &-leave-active {
  489. transition: max-width .5s ease;
  490. max-width: 50vw;
  491. .editor-code-preview-content {
  492. width: 50vw;
  493. overflow:hidden;
  494. }
  495. }
  496. &-enter, &-leave-to {
  497. max-width: 0;
  498. }
  499. &-content {
  500. height: $editor-height;
  501. overflow-y: scroll;
  502. padding: 1rem 1rem 1rem 0;
  503. width: calc(100% + 1rem + 17px)
  504. // -ms-overflow-style: none;
  505. // &::-webkit-scrollbar {
  506. // width: 0px;
  507. // background: transparent;
  508. // }
  509. }
  510. &-title {
  511. background-color: rgba(mc('blue', '100'), .75);
  512. border-bottom-right-radius: 5px;
  513. display: inline-flex;
  514. height: 30px;
  515. justify-content: center;
  516. align-items: center;
  517. padding: 0 1rem;
  518. color: mc('blue', '800');
  519. position: absolute;
  520. top: 0;
  521. left: 0;
  522. z-index: 2;
  523. text-transform: uppercase;
  524. font-size: .7rem;
  525. cursor: pointer;
  526. }
  527. }
  528. &-toolbar {
  529. background-color: mc('blue', '700');
  530. background-image: linear-gradient(to bottom, mc('blue', '700') 0%, mc('blue','800') 100%);
  531. color: #FFF;
  532. .v-toolbar__content {
  533. padding-left: 78px;
  534. @include until($tablet) {
  535. padding-left: 8px;
  536. }
  537. }
  538. }
  539. &-insert:not(.v-speed-dial--right) {
  540. @include from($tablet) {
  541. left: 50%;
  542. margin-left: -28px;
  543. }
  544. }
  545. &-sidebar {
  546. background-color: mc('grey', '900');
  547. width: 64px;
  548. display: flex;
  549. flex-direction: column;
  550. justify-content: flex-start;
  551. align-items: center;
  552. padding: 24px 0;
  553. }
  554. &-sysbar {
  555. padding-left: 0;
  556. &-locale {
  557. background-color: rgba(255,255,255,.25);
  558. display:inline-flex;
  559. padding: 0 12px;
  560. height: 24px;
  561. width: 63px;
  562. justify-content: center;
  563. align-items: center;
  564. }
  565. }
  566. // ==========================================
  567. // Fix FAB revealing under codemirror
  568. // ==========================================
  569. .speed-dial--fixed {
  570. z-index: 8;
  571. }
  572. // ==========================================
  573. // CODE MIRROR
  574. // ==========================================
  575. .CodeMirror {
  576. height: auto;
  577. .cm-header-1 {
  578. font-size: 1.5rem;
  579. }
  580. .cm-header-2 {
  581. font-size: 1.25rem;
  582. }
  583. .cm-header-3 {
  584. font-size: 1.15rem;
  585. }
  586. .cm-header-4 {
  587. font-size: 1.1rem;
  588. }
  589. .cm-header-5 {
  590. font-size: 1.05rem;
  591. }
  592. .cm-header-6 {
  593. font-size: 1.025rem;
  594. }
  595. }
  596. .CodeMirror-focused .cm-matchhighlight {
  597. background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFklEQVQI12NgYGBgkKzc8x9CMDAwAAAmhwSbidEoSQAAAABJRU5ErkJggg==);
  598. background-position: bottom;
  599. background-repeat: repeat-x;
  600. }
  601. .cm-matchhighlight {
  602. background-color: mc('grey', '800');
  603. }
  604. .CodeMirror-selection-highlight-scrollbar {
  605. background-color: mc('green', '600');
  606. }
  607. .cm-s-wikijs-dark.CodeMirror {
  608. background: darken(mc('grey','900'), 3%);
  609. color: #e0e0e0;
  610. }
  611. .cm-s-wikijs-dark div.CodeMirror-selected {
  612. background: mc('blue','800');
  613. }
  614. .cm-s-wikijs-dark .cm-matchhighlight {
  615. background: mc('blue','800');
  616. }
  617. .cm-s-wikijs-dark .CodeMirror-line::selection, .cm-s-wikijs-dark .CodeMirror-line > span::selection, .cm-s-wikijs-dark .CodeMirror-line > span > span::selection {
  618. background: mc('red', '500');
  619. }
  620. .cm-s-wikijs-dark .CodeMirror-line::-moz-selection, .cm-s-wikijs-dark .CodeMirror-line > span::-moz-selection, .cm-s-wikijs-dark .CodeMirror-line > span > span::-moz-selection {
  621. background: mc('red', '500');
  622. }
  623. .cm-s-wikijs-dark .CodeMirror-gutters {
  624. background: darken(mc('grey','900'), 6%);
  625. border-right: 1px solid mc('grey','900');
  626. }
  627. .cm-s-wikijs-dark .CodeMirror-guttermarker {
  628. color: #ac4142;
  629. }
  630. .cm-s-wikijs-dark .CodeMirror-guttermarker-subtle {
  631. color: #505050;
  632. }
  633. .cm-s-wikijs-dark .CodeMirror-linenumber {
  634. color: mc('grey','800');
  635. }
  636. .cm-s-wikijs-dark .CodeMirror-cursor {
  637. border-left: 1px solid #b0b0b0;
  638. }
  639. .cm-s-wikijs-dark span.cm-comment {
  640. color: mc('orange','800');
  641. }
  642. .cm-s-wikijs-dark span.cm-atom {
  643. color: #aa759f;
  644. }
  645. .cm-s-wikijs-dark span.cm-number {
  646. color: #aa759f;
  647. }
  648. .cm-s-wikijs-dark span.cm-property, .cm-s-wikijs-dark span.cm-attribute {
  649. color: #90a959;
  650. }
  651. .cm-s-wikijs-dark span.cm-keyword {
  652. color: #ac4142;
  653. }
  654. .cm-s-wikijs-dark span.cm-string {
  655. color: #f4bf75;
  656. }
  657. .cm-s-wikijs-dark span.cm-variable {
  658. color: #90a959;
  659. }
  660. .cm-s-wikijs-dark span.cm-variable-2 {
  661. color: #6a9fb5;
  662. }
  663. .cm-s-wikijs-dark span.cm-def {
  664. color: #d28445;
  665. }
  666. .cm-s-wikijs-dark span.cm-bracket {
  667. color: #e0e0e0;
  668. }
  669. .cm-s-wikijs-dark span.cm-tag {
  670. color: #ac4142;
  671. }
  672. .cm-s-wikijs-dark span.cm-link {
  673. color: #aa759f;
  674. }
  675. .cm-s-wikijs-dark span.cm-error {
  676. background: #ac4142;
  677. color: #b0b0b0;
  678. }
  679. .cm-s-wikijs-dark .CodeMirror-activeline-background {
  680. background: mc('grey','900');
  681. }
  682. .cm-s-wikijs-dark .CodeMirror-matchingbracket {
  683. text-decoration: underline;
  684. color: white !important;
  685. }
  686. }
  687. </style>