editor-markdown.vue 25 KB

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