editor-markdown.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. <template lang='pug'>
  2. .editor-markdown
  3. v-toolbar.editor-markdown-toolbar(dense, color='primary', dark, flat, style='overflow-x: hidden;')
  4. template(v-if='isModalShown')
  5. v-spacer
  6. v-btn.animated.fadeInRight(flat, @click='closeAllModal')
  7. v-icon(left) remove_circle_outline
  8. span Back to Editor
  9. template(v-else)
  10. v-tooltip(bottom, color='primary')
  11. v-btn.animated.fadeIn(icon, slot='activator', @click='toggleMarkup({ start: `**` })').mx-0
  12. v-icon format_bold
  13. span Bold
  14. v-tooltip(bottom, color='primary')
  15. v-btn.animated.fadeIn.wait-p1s(icon, slot='activator', @click='toggleMarkup({ start: `*` })').mx-0
  16. v-icon format_italic
  17. span Italic
  18. v-tooltip(bottom, color='primary')
  19. v-btn.animated.fadeIn.wait-p2s(icon, slot='activator', @click='toggleMarkup({ start: `~~` })').mx-0
  20. v-icon format_strikethrough
  21. span Strikethrough
  22. v-menu(offset-y, open-on-hover)
  23. v-btn.animated.fadeIn.wait-p3s(icon, slot='activator').mx-0
  24. v-icon text_fields
  25. v-list.py-0
  26. template(v-for='(n, idx) in 6')
  27. v-list-tile(@click='setHeaderLine(n)', :key='idx')
  28. v-list-tile-action
  29. v-icon(:size='24 - (idx - 1) * 2') title
  30. v-list-tile-title Heading {{n}}
  31. v-divider(v-if='idx < 5')
  32. v-tooltip(bottom, color='primary')
  33. v-btn.animated.fadeIn.wait-p4s(icon, slot='activator', @click='toggleMarkup({ start: `~` })').mx-0
  34. v-icon vertical_align_bottom
  35. span Subscript
  36. v-tooltip(bottom, color='primary')
  37. v-btn.animated.fadeIn.wait-p5s(icon, slot='activator', @click='toggleMarkup({ start: `^` })').mx-0
  38. v-icon vertical_align_top
  39. span Superscript
  40. v-menu(offset-y, open-on-hover)
  41. v-btn.animated.fadeIn.wait-p6s(icon, slot='activator').mx-0
  42. v-icon format_quote
  43. v-list.py-0
  44. v-list-tile(@click='insertBeforeEachLine({ content: `> `})')
  45. v-list-tile-action
  46. v-icon format_quote
  47. v-list-tile-title Blockquote
  48. v-divider
  49. v-list-tile(@click='insertBeforeEachLine({ content: `> `, after: `{.is-info}`})')
  50. v-list-tile-action
  51. v-icon(color='blue') format_quote
  52. v-list-tile-title Info Blockquote
  53. v-divider
  54. v-list-tile(@click='insertBeforeEachLine({ content: `> `, after: `{.is-success}`})')
  55. v-list-tile-action
  56. v-icon(color='success') format_quote
  57. v-list-tile-title Success Blockquote
  58. v-divider
  59. v-list-tile(@click='insertBeforeEachLine({ content: `> `, after: `{.is-warning}`})')
  60. v-list-tile-action
  61. v-icon(color='warning') format_quote
  62. v-list-tile-title Warning Blockquote
  63. v-divider
  64. v-list-tile(@click='insertBeforeEachLine({ content: `> `, after: `{.is-error}`})')
  65. v-list-tile-action
  66. v-icon(color='error') format_quote
  67. v-list-tile-title Error Blockquote
  68. v-divider
  69. v-tooltip(bottom, color='primary')
  70. v-btn.animated.fadeIn.wait-p7s(icon, slot='activator', @click='insertBeforeEachLine({ content: `- `})').mx-0
  71. v-icon format_list_bulleted
  72. span Unordered List
  73. v-tooltip(bottom, color='primary')
  74. v-btn.animated.fadeIn.wait-p8s(icon, slot='activator', @click='insertBeforeEachLine({ content: `1. `})').mx-0
  75. v-icon format_list_numbered
  76. span Ordered List
  77. v-tooltip(bottom, color='primary')
  78. v-btn.animated.fadeIn.wait-p9s(icon, slot='activator', @click='toggleMarkup({ start: "`" })').mx-0
  79. v-icon space_bar
  80. span Inline Code
  81. v-tooltip(bottom, color='primary')
  82. v-btn.animated.fadeIn.wait-p10s(icon, slot='activator', @click='toggleMarkup({ start: `<kbd>`, end: `</kbd>` })').mx-0
  83. v-icon font_download
  84. span Keyboard Key
  85. v-tooltip(bottom, color='primary')
  86. v-btn.animated.fadeIn.wait-p11s(icon, slot='activator', @click='insertAfter({ content: `---`, newLine: true })').mx-0
  87. v-icon remove
  88. span Horizontal Bar
  89. .editor-markdown-main
  90. .editor-markdown-sidebar
  91. v-tooltip(right, color='teal')
  92. v-btn.animated.fadeInLeft(icon, slot='activator', dark, disabled).mx-0
  93. v-icon link
  94. span Insert Link
  95. v-tooltip(right, color='teal')
  96. v-btn.animated.fadeInLeft.wait-p1s(icon, slot='activator', dark, @click='toggleModal(`editorModalMedia`)').mx-0
  97. v-icon(:color='activeModal === `editorModalMedia` ? `teal` : ``') burst_mode
  98. span Insert Assets
  99. v-tooltip(right, color='teal')
  100. v-btn.animated.fadeInLeft.wait-p2s(icon, slot='activator', dark, @click='toggleModal(`editorModalBlocks`)').mx-0
  101. v-icon(:color='activeModal === `editorModalBlocks` ? `teal` : ``') dashboard
  102. span Insert Block
  103. v-tooltip(right, color='teal')
  104. v-btn.animated.fadeInLeft.wait-p3s(icon, slot='activator', dark, disabled).mx-0
  105. v-icon code
  106. span Insert Code Block
  107. v-tooltip(right, color='teal')
  108. v-btn.animated.fadeInLeft.wait-p4s(icon, slot='activator', dark, disabled).mx-0
  109. v-icon play_circle_outline
  110. span Insert Video / Audio
  111. v-tooltip(right, color='teal')
  112. v-btn.animated.fadeInLeft.wait-p5s(icon, slot='activator', dark, disabled).mx-0
  113. v-icon multiline_chart
  114. span Insert Diagram
  115. v-tooltip(right, color='teal')
  116. v-btn.animated.fadeInLeft.wait-p6s(icon, slot='activator', dark, disabled).mx-0
  117. v-icon functions
  118. span Insert Math Expression
  119. v-tooltip(right, color='teal')
  120. v-btn.animated.fadeInLeft.wait-p7s(icon, slot='activator', dark, disabled).mx-0
  121. v-icon border_outer
  122. span Table Helper
  123. template(v-if='$vuetify.breakpoint.mdAndUp')
  124. v-spacer
  125. v-tooltip(right, color='teal')
  126. v-btn.animated.fadeInLeft.wait-p8s(icon, slot='activator', dark, @click='toggleFullscreen').mx-0
  127. v-icon crop_free
  128. span Distraction Free Mode
  129. v-tooltip(right, color='teal')
  130. v-btn.animated.fadeInLeft.wait-p9s(icon, slot='activator', dark, @click='toggleHelp').mx-0
  131. v-icon(:color='helpShown ? `teal` : ``') help
  132. span Markdown Formatting Help
  133. .editor-markdown-editor
  134. .editor-markdown-editor-title(v-if='previewShown', @click='previewShown = false') Editor
  135. .editor-markdown-editor-title(v-else='previewShown', @click='previewShown = true'): v-icon(dark) drag_indicator
  136. codemirror(ref='cm', v-model='code', :options='cmOptions', @ready='onCmReady', @input='onCmInput')
  137. transition(name='editor-markdown-preview')
  138. .editor-markdown-preview(v-if='previewShown')
  139. .editor-markdown-preview-title(@click='previewShown = false') Preview
  140. .editor-markdown-preview-content.contents(ref='editorPreview', v-html='previewHTML')
  141. v-system-bar.editor-markdown-sysbar(dark, status, color='grey darken-3')
  142. .caption.editor-markdown-sysbar-locale {{locale.toUpperCase()}}
  143. .caption.px-3 /{{path}}
  144. template(v-if='$vuetify.breakpoint.mdAndUp')
  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. if (this.$vuetify.breakpoint.mdAndUp) {
  316. cm.setSize(null, 'calc(100vh - 112px - 24px)')
  317. } else {
  318. cm.setSize(null, 'calc(100vh - 112px - 16px)')
  319. }
  320. cm.setOption('extraKeys', keyBindings)
  321. cm.on('cursorActivity', cm => {
  322. this.positionSync(cm)
  323. this.scrollSync(cm)
  324. })
  325. this.onCmInput(this.code)
  326. },
  327. onCmInput: _.debounce(function (newContent) {
  328. linesMap = []
  329. this.$store.set('editor/content', newContent)
  330. this.previewHTML = md.render(newContent)
  331. this.$nextTick(() => {
  332. Prism.highlightAllUnder(this.$refs.editorPreview)
  333. Array.from(this.$refs.editorPreview.querySelectorAll('pre.line-numbers')).forEach(pre => pre.classList.add('prismjs'))
  334. this.scrollSync(this.cm)
  335. })
  336. }, 500),
  337. /**
  338. * Update cursor state
  339. */
  340. positionSync(cm) {
  341. this.cursorPos = cm.getCursor('head')
  342. },
  343. /**
  344. * Wrap selection with start / end tags
  345. */
  346. toggleMarkup({ start, end }) {
  347. if (!end) { end = start }
  348. if (!this.cm.doc.somethingSelected()) {
  349. return this.$store.commit('showNotification', {
  350. message: 'You must select something first!',
  351. style: 'warning',
  352. icon: 'warning'
  353. })
  354. }
  355. this.cm.doc.replaceSelections(this.cm.doc.getSelections().map(s => start + s + end))
  356. },
  357. /**
  358. * Set current line as header
  359. */
  360. setHeaderLine(lvl) {
  361. const curLine = this.cm.doc.getCursor('head').line
  362. let lineContent = this.cm.doc.getLine(curLine)
  363. const lineLength = lineContent.length
  364. if (_.startsWith(lineContent, '#')) {
  365. lineContent = lineContent.replace(/^(#+ )/, '')
  366. }
  367. lineContent = _.times(lvl, n => '#').join('') + ` ` + lineContent
  368. this.cm.doc.replaceRange(lineContent, { line: curLine, ch: 0 }, { line: curLine, ch: lineLength })
  369. },
  370. /**
  371. * Get the header lever of the current line
  372. */
  373. getHeaderLevel(cm) {
  374. const curLine = this.cm.doc.getCursor('head').line
  375. let lineContent = this.cm.doc.getLine(curLine)
  376. let lvl = 0
  377. const result = lineContent.match(/^(#+) /)
  378. if (result) {
  379. lvl = _.get(result, '[1]', '').length
  380. }
  381. return lvl
  382. },
  383. /**
  384. * Insert content at cursor
  385. */
  386. insertAtCursor({ content }) {
  387. const cursor = this.cm.doc.getCursor('head')
  388. this.cm.doc.replaceRange(content, cursor)
  389. },
  390. /**
  391. * Insert content after current line
  392. */
  393. insertAfter({ content, newLine }) {
  394. const curLine = this.cm.doc.getCursor('to').line
  395. const lineLength = this.cm.doc.getLine(curLine).length
  396. this.cm.doc.replaceRange(newLine ? `\n${content}\n` : content, { line: curLine, ch: lineLength + 1 })
  397. },
  398. /**
  399. * Insert content before current line
  400. */
  401. insertBeforeEachLine({ content, after }) {
  402. let lines = []
  403. if (!this.cm.doc.somethingSelected()) {
  404. lines.push(this.cm.doc.getCursor('head').line)
  405. } else {
  406. lines = _.flatten(this.cm.doc.listSelections().map(sl => {
  407. const range = Math.abs(sl.anchor.line - sl.head.line) + 1
  408. const lowestLine = (sl.anchor.line > sl.head.line) ? sl.head.line : sl.anchor.line
  409. return _.times(range, l => l + lowestLine)
  410. }))
  411. }
  412. lines.forEach(ln => {
  413. let lineContent = this.cm.doc.getLine(ln)
  414. const lineLength = lineContent.length
  415. if (_.startsWith(lineContent, content)) {
  416. lineContent = lineContent.substring(content.length)
  417. }
  418. this.cm.doc.replaceRange(content + lineContent, { line: ln, ch: 0 }, { line: ln, ch: lineLength })
  419. })
  420. if (after) {
  421. const lastLine = _.last(lines)
  422. this.cm.doc.replaceRange(`\n${after}\n`, { line: lastLine, ch: this.cm.doc.getLine(lastLine).length + 1 })
  423. }
  424. },
  425. /**
  426. * Update scroll sync
  427. */
  428. scrollSync: _.debounce(function (cm) {
  429. if (!this.previewShown || cm.somethingSelected()) { return }
  430. let currentLine = cm.getCursor().line
  431. if (currentLine < 3) {
  432. this.Velocity(this.$refs.editorPreview, 'stop', true)
  433. this.Velocity(this.$refs.editorPreview.firstChild, 'scroll', { offset: '-50', duration: 1000, container: this.$refs.editorPreview })
  434. } else {
  435. let closestLine = _.findLast(linesMap, n => n <= currentLine)
  436. let destElm = this.$refs.editorPreview.querySelector(`[data-line='${closestLine}']`)
  437. if (destElm) {
  438. this.Velocity(this.$refs.editorPreview, 'stop', true)
  439. this.Velocity(destElm, 'scroll', { offset: '-100', duration: 1000, container: this.$refs.editorPreview })
  440. }
  441. }
  442. }, 500),
  443. toggleHelp () {
  444. this.helpShown = !this.helpShown
  445. this.activeModal = ''
  446. },
  447. toggleFullscreen () {
  448. this.cm.setOption('fullScreen', true)
  449. }
  450. },
  451. mounted() {
  452. this.$root.$on('editorInsert', opts => {
  453. switch (opts.kind) {
  454. case 'IMAGE':
  455. let img = `![${opts.text}](${opts.path})`
  456. if (opts.align && opts.align !== '') {
  457. img += `{.align-${opts.align}}`
  458. }
  459. this.insertAtCursor({
  460. content: img
  461. })
  462. break
  463. case 'BINARY':
  464. this.insertAtCursor({
  465. content: `[${opts.text}](${opts.path})`
  466. })
  467. break
  468. }
  469. })
  470. },
  471. beforeDestroy() {
  472. this.$root.$off('editorInsert')
  473. }
  474. }
  475. </script>
  476. <style lang='scss'>
  477. $editor-height: calc(100vh - 112px - 24px);
  478. $editor-height-mobile: calc(100vh - 112px - 16px);
  479. .editor-markdown {
  480. &-main {
  481. display: flex;
  482. width: 100%;
  483. }
  484. &-editor {
  485. background-color: darken(mc('grey', '900'), 4.5%);
  486. flex: 1 1 50%;
  487. display: block;
  488. height: $editor-height;
  489. position: relative;
  490. @include until($tablet) {
  491. height: $editor-height-mobile;
  492. }
  493. &-title {
  494. background-color: mc('grey', '800');
  495. border-bottom-left-radius: 5px;
  496. display: inline-flex;
  497. height: 30px;
  498. justify-content: center;
  499. align-items: center;
  500. padding: 0 1rem;
  501. color: mc('grey', '500');
  502. position: absolute;
  503. top: 0;
  504. right: 0;
  505. z-index: 7;
  506. text-transform: uppercase;
  507. font-size: .7rem;
  508. cursor: pointer;
  509. @include until($tablet) {
  510. display: none;
  511. }
  512. }
  513. }
  514. &-preview {
  515. flex: 1 1 50%;
  516. background-color: mc('grey', '100');
  517. position: relative;
  518. height: $editor-height;
  519. overflow: hidden;
  520. @at-root .theme--dark & {
  521. background-color: mc('grey', '900');
  522. }
  523. @include until($tablet) {
  524. display: none;
  525. }
  526. &-enter-active, &-leave-active {
  527. transition: max-width .5s ease;
  528. max-width: 50vw;
  529. .editor-code-preview-content {
  530. width: 50vw;
  531. overflow:hidden;
  532. }
  533. }
  534. &-enter, &-leave-to {
  535. max-width: 0;
  536. }
  537. &-content {
  538. height: $editor-height;
  539. overflow-y: scroll;
  540. padding: 1rem 1rem 1rem 0;
  541. width: calc(100% + 1rem + 17px);
  542. // -ms-overflow-style: none;
  543. // &::-webkit-scrollbar {
  544. // width: 0px;
  545. // background: transparent;
  546. // }
  547. @include until($tablet) {
  548. height: $editor-height-mobile;
  549. }
  550. }
  551. &-title {
  552. background-color: rgba(mc('blue', '100'), .75);
  553. border-bottom-right-radius: 5px;
  554. display: inline-flex;
  555. height: 30px;
  556. justify-content: center;
  557. align-items: center;
  558. padding: 0 1rem;
  559. color: mc('blue', '800');
  560. position: absolute;
  561. top: 0;
  562. left: 0;
  563. z-index: 2;
  564. text-transform: uppercase;
  565. font-size: .7rem;
  566. cursor: pointer;
  567. }
  568. }
  569. &-toolbar {
  570. background-color: mc('blue', '700');
  571. background-image: linear-gradient(to bottom, mc('blue', '700') 0%, mc('blue','800') 100%);
  572. color: #FFF;
  573. .v-toolbar__content {
  574. padding-left: 78px;
  575. @include until($tablet) {
  576. padding-left: 8px;
  577. }
  578. }
  579. }
  580. &-insert:not(.v-speed-dial--right) {
  581. @include from($tablet) {
  582. left: 50%;
  583. margin-left: -28px;
  584. }
  585. }
  586. &-sidebar {
  587. background-color: mc('grey', '900');
  588. width: 64px;
  589. display: flex;
  590. flex-direction: column;
  591. justify-content: flex-start;
  592. align-items: center;
  593. padding: 24px 0;
  594. @include until($tablet) {
  595. padding: 12px 0;
  596. width: 40px;
  597. }
  598. }
  599. &-sysbar {
  600. padding-left: 0;
  601. &-locale {
  602. background-color: rgba(255,255,255,.25);
  603. display:inline-flex;
  604. padding: 0 12px;
  605. height: 24px;
  606. width: 63px;
  607. justify-content: center;
  608. align-items: center;
  609. }
  610. }
  611. // ==========================================
  612. // Fix FAB revealing under codemirror
  613. // ==========================================
  614. .speed-dial--fixed {
  615. z-index: 8;
  616. }
  617. // ==========================================
  618. // CODE MIRROR
  619. // ==========================================
  620. .CodeMirror {
  621. height: auto;
  622. .cm-header-1 {
  623. font-size: 1.5rem;
  624. }
  625. .cm-header-2 {
  626. font-size: 1.25rem;
  627. }
  628. .cm-header-3 {
  629. font-size: 1.15rem;
  630. }
  631. .cm-header-4 {
  632. font-size: 1.1rem;
  633. }
  634. .cm-header-5 {
  635. font-size: 1.05rem;
  636. }
  637. .cm-header-6 {
  638. font-size: 1.025rem;
  639. }
  640. }
  641. .CodeMirror-focused .cm-matchhighlight {
  642. background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFklEQVQI12NgYGBgkKzc8x9CMDAwAAAmhwSbidEoSQAAAABJRU5ErkJggg==);
  643. background-position: bottom;
  644. background-repeat: repeat-x;
  645. }
  646. .cm-matchhighlight {
  647. background-color: mc('grey', '800');
  648. }
  649. .CodeMirror-selection-highlight-scrollbar {
  650. background-color: mc('green', '600');
  651. }
  652. .cm-s-wikijs-dark.CodeMirror {
  653. background: darken(mc('grey','900'), 3%);
  654. color: #e0e0e0;
  655. }
  656. .cm-s-wikijs-dark div.CodeMirror-selected {
  657. background: mc('blue','800');
  658. }
  659. .cm-s-wikijs-dark .cm-matchhighlight {
  660. background: mc('blue','800');
  661. }
  662. .cm-s-wikijs-dark .CodeMirror-line::selection, .cm-s-wikijs-dark .CodeMirror-line > span::selection, .cm-s-wikijs-dark .CodeMirror-line > span > span::selection {
  663. background: mc('red', '500');
  664. }
  665. .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 {
  666. background: mc('red', '500');
  667. }
  668. .cm-s-wikijs-dark .CodeMirror-gutters {
  669. background: darken(mc('grey','900'), 6%);
  670. border-right: 1px solid mc('grey','900');
  671. }
  672. .cm-s-wikijs-dark .CodeMirror-guttermarker {
  673. color: #ac4142;
  674. }
  675. .cm-s-wikijs-dark .CodeMirror-guttermarker-subtle {
  676. color: #505050;
  677. }
  678. .cm-s-wikijs-dark .CodeMirror-linenumber {
  679. color: mc('grey','800');
  680. }
  681. .cm-s-wikijs-dark .CodeMirror-cursor {
  682. border-left: 1px solid #b0b0b0;
  683. }
  684. .cm-s-wikijs-dark span.cm-comment {
  685. color: mc('orange','800');
  686. }
  687. .cm-s-wikijs-dark span.cm-atom {
  688. color: #aa759f;
  689. }
  690. .cm-s-wikijs-dark span.cm-number {
  691. color: #aa759f;
  692. }
  693. .cm-s-wikijs-dark span.cm-property, .cm-s-wikijs-dark span.cm-attribute {
  694. color: #90a959;
  695. }
  696. .cm-s-wikijs-dark span.cm-keyword {
  697. color: #ac4142;
  698. }
  699. .cm-s-wikijs-dark span.cm-string {
  700. color: #f4bf75;
  701. }
  702. .cm-s-wikijs-dark span.cm-variable {
  703. color: #90a959;
  704. }
  705. .cm-s-wikijs-dark span.cm-variable-2 {
  706. color: #6a9fb5;
  707. }
  708. .cm-s-wikijs-dark span.cm-def {
  709. color: #d28445;
  710. }
  711. .cm-s-wikijs-dark span.cm-bracket {
  712. color: #e0e0e0;
  713. }
  714. .cm-s-wikijs-dark span.cm-tag {
  715. color: #ac4142;
  716. }
  717. .cm-s-wikijs-dark span.cm-link {
  718. color: #aa759f;
  719. }
  720. .cm-s-wikijs-dark span.cm-error {
  721. background: #ac4142;
  722. color: #b0b0b0;
  723. }
  724. .cm-s-wikijs-dark .CodeMirror-activeline-background {
  725. background: mc('grey','900');
  726. }
  727. .cm-s-wikijs-dark .CodeMirror-matchingbracket {
  728. text-decoration: underline;
  729. color: white !important;
  730. }
  731. }
  732. </style>