editor-markdown.vue 24 KB

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