editor-markdown.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  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 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 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 format_strikethrough
  21. span {{$t('editor:markup.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 {{$t('editor:markup.heading', { level: 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 {{$t('editor:markup.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 {{$t('editor:markup.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 {{$t('editor:markup.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 {{$t('editor:markup.blockquoteInfo')}}
  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 {{$t('editor:markup.blockquoteSuccess')}}
  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 {{$t('editor:markup.blockquoteWarning')}}
  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 {{$t('editor:markup.blockquoteError')}}
  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 {{$t('editor:markup.unorderedList')}}
  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 {{$t('editor:markup.orderedList')}}
  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 {{$t('editor:markup.inlineCode')}}
  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 {{$t('editor:markup.keyboardKey')}}
  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 {{$t('editor:markup.horizontalBar')}}
  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 {{$t('editor:markup.togglePreviewPane')}}
  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 {{$t('editor:markup.insertLink')}}
  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 {{$t('editor:markup.insertAssets')}}
  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 {{$t('editor:markup.insertBlock')}}
  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 {{$t('editor:markup.insertCodeBlock')}}
  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 {{$t('editor:markup.insertVideoAudio')}}
  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 {{$t('editor:markup.insertDiagram')}}
  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 {{$t('editor:markup.insertMathExpression')}}
  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 {{$t('editor:markup.tableHelper')}}
  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 {{$t('editor:markup.distractionFreeMode')}}
  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 {{$t('editor:markup.markdownFormattingHelp')}}
  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 'prismjs'
  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. default: () => {}
  238. }
  239. },
  240. data() {
  241. return {
  242. fabInsertMenu: false,
  243. code: this.$store.get('editor/content'),
  244. cmOptions: {
  245. tabSize: 2,
  246. mode: 'text/markdown',
  247. theme: 'wikijs-dark',
  248. lineNumbers: true,
  249. lineWrapping: true,
  250. line: true,
  251. styleActiveLine: true,
  252. highlightSelectionMatches: {
  253. annotateScrollbar: true
  254. },
  255. viewportMargin: 50,
  256. inputStyle: 'contenteditable',
  257. allowDropFileTypes: ['image/jpg', 'image/png', 'image/svg', 'image/jpeg', 'image/gif']
  258. },
  259. cursorPos: { ch: 0, line: 1 },
  260. previewShown: true,
  261. previewHTML: '',
  262. helpShown: false
  263. }
  264. },
  265. computed: {
  266. cm() {
  267. return this.$refs.cm.codemirror
  268. },
  269. isMobile() {
  270. return this.$vuetify.breakpoint.smAndDown
  271. },
  272. isModalShown() {
  273. return this.helpShown || this.activeModal !== ''
  274. },
  275. locale: get('page/locale'),
  276. path: get('page/path'),
  277. activeModal: sync('editor/activeModal')
  278. },
  279. methods: {
  280. toggleModal(key) {
  281. this.activeModal = (this.activeModal === key) ? '' : key
  282. this.helpShown = false
  283. },
  284. closeAllModal() {
  285. this.activeModal = ''
  286. this.helpShown = false
  287. },
  288. onCmReady(cm) {
  289. const keyBindings = {
  290. 'F11' (cm) {
  291. cm.setOption('fullScreen', !cm.getOption('fullScreen'))
  292. },
  293. 'Esc' (cm) {
  294. if (cm.getOption('fullScreen')) cm.setOption('fullScreen', false)
  295. }
  296. }
  297. _.set(keyBindings, `${CtrlKey}-S`, cm => {
  298. this.save()
  299. return false
  300. })
  301. _.set(keyBindings, `${CtrlKey}-B`, cm => {
  302. this.toggleMarkup({ start: `**` })
  303. return false
  304. })
  305. _.set(keyBindings, `${CtrlKey}-I`, cm => {
  306. this.toggleMarkup({ start: `*` })
  307. return false
  308. })
  309. _.set(keyBindings, `${CtrlKey}-Alt-Right`, cm => {
  310. let lvl = this.getHeaderLevel(cm)
  311. if (lvl >= 6) { lvl = 5 }
  312. this.setHeaderLine(lvl + 1)
  313. return false
  314. })
  315. _.set(keyBindings, `${CtrlKey}-Alt-Left`, cm => {
  316. let lvl = this.getHeaderLevel(cm)
  317. if (lvl <= 1) { lvl = 2 }
  318. this.setHeaderLine(lvl - 1)
  319. return false
  320. })
  321. if (this.$vuetify.breakpoint.mdAndUp) {
  322. cm.setSize(null, 'calc(100vh - 112px - 24px)')
  323. } else {
  324. cm.setSize(null, 'calc(100vh - 112px - 16px)')
  325. }
  326. cm.setOption('extraKeys', keyBindings)
  327. cm.on('cursorActivity', cm => {
  328. this.positionSync(cm)
  329. this.scrollSync(cm)
  330. })
  331. cm.on('paste', this.onCmPaste)
  332. this.onCmInput(this.code)
  333. },
  334. onCmInput: _.debounce(function (newContent) {
  335. linesMap = []
  336. this.$store.set('editor/content', newContent)
  337. this.previewHTML = md.render(newContent)
  338. this.$nextTick(() => {
  339. Prism.highlightAllUnder(this.$refs.editorPreview)
  340. Array.from(this.$refs.editorPreview.querySelectorAll('pre.line-numbers')).forEach(pre => pre.classList.add('prismjs'))
  341. this.scrollSync(this.cm)
  342. })
  343. }, 500),
  344. onCmPaste (cm, ev) {
  345. const clipItems = (ev.clipboardData || ev.originalEvent.clipboardData).items
  346. for (const clipItem of clipItems) {
  347. if (_.startsWith(clipItem.type, 'image/')) {
  348. const file = clipItem.getAsFile()
  349. const reader = new FileReader()
  350. reader.onload = evt => {
  351. this.$store.commit(`loadingStart`, 'editor-paste-image')
  352. this.insertAfter({
  353. content: `![${file.name}](${evt.target.result})`,
  354. newLine: true
  355. })
  356. }
  357. reader.readAsDataURL(file)
  358. }
  359. }
  360. },
  361. /**
  362. * Update cursor state
  363. */
  364. positionSync(cm) {
  365. this.cursorPos = cm.getCursor('head')
  366. },
  367. /**
  368. * Wrap selection with start / end tags
  369. */
  370. toggleMarkup({ start, end }) {
  371. if (!end) { end = start }
  372. if (!this.cm.doc.somethingSelected()) {
  373. return this.$store.commit('showNotification', {
  374. message: this.$t('editor:markup.noSelectionError'),
  375. style: 'warning',
  376. icon: 'warning'
  377. })
  378. }
  379. this.cm.doc.replaceSelections(this.cm.doc.getSelections().map(s => start + s + end))
  380. },
  381. /**
  382. * Set current line as header
  383. */
  384. setHeaderLine(lvl) {
  385. const curLine = this.cm.doc.getCursor('head').line
  386. let lineContent = this.cm.doc.getLine(curLine)
  387. const lineLength = lineContent.length
  388. if (_.startsWith(lineContent, '#')) {
  389. lineContent = lineContent.replace(/^(#+ )/, '')
  390. }
  391. lineContent = _.times(lvl, n => '#').join('') + ` ` + lineContent
  392. this.cm.doc.replaceRange(lineContent, { line: curLine, ch: 0 }, { line: curLine, ch: lineLength })
  393. },
  394. /**
  395. * Get the header lever of the current line
  396. */
  397. getHeaderLevel(cm) {
  398. const curLine = this.cm.doc.getCursor('head').line
  399. let lineContent = this.cm.doc.getLine(curLine)
  400. let lvl = 0
  401. const result = lineContent.match(/^(#+) /)
  402. if (result) {
  403. lvl = _.get(result, '[1]', '').length
  404. }
  405. return lvl
  406. },
  407. /**
  408. * Insert content at cursor
  409. */
  410. insertAtCursor({ content }) {
  411. const cursor = this.cm.doc.getCursor('head')
  412. this.cm.doc.replaceRange(content, cursor)
  413. },
  414. /**
  415. * Insert content after current line
  416. */
  417. insertAfter({ content, newLine }) {
  418. const curLine = this.cm.doc.getCursor('to').line
  419. const lineLength = this.cm.doc.getLine(curLine).length
  420. this.cm.doc.replaceRange(newLine ? `\n${content}\n` : content, { line: curLine, ch: lineLength + 1 })
  421. },
  422. /**
  423. * Insert content before current line
  424. */
  425. insertBeforeEachLine({ content, after }) {
  426. let lines = []
  427. if (!this.cm.doc.somethingSelected()) {
  428. lines.push(this.cm.doc.getCursor('head').line)
  429. } else {
  430. lines = _.flatten(this.cm.doc.listSelections().map(sl => {
  431. const range = Math.abs(sl.anchor.line - sl.head.line) + 1
  432. const lowestLine = (sl.anchor.line > sl.head.line) ? sl.head.line : sl.anchor.line
  433. return _.times(range, l => l + lowestLine)
  434. }))
  435. }
  436. lines.forEach(ln => {
  437. let lineContent = this.cm.doc.getLine(ln)
  438. const lineLength = lineContent.length
  439. if (_.startsWith(lineContent, content)) {
  440. lineContent = lineContent.substring(content.length)
  441. }
  442. this.cm.doc.replaceRange(content + lineContent, { line: ln, ch: 0 }, { line: ln, ch: lineLength })
  443. })
  444. if (after) {
  445. const lastLine = _.last(lines)
  446. this.cm.doc.replaceRange(`\n${after}\n`, { line: lastLine, ch: this.cm.doc.getLine(lastLine).length + 1 })
  447. }
  448. },
  449. /**
  450. * Update scroll sync
  451. */
  452. scrollSync: _.debounce(function (cm) {
  453. if (!this.previewShown || cm.somethingSelected()) { return }
  454. let currentLine = cm.getCursor().line
  455. if (currentLine < 3) {
  456. this.Velocity(this.$refs.editorPreview, 'stop', true)
  457. this.Velocity(this.$refs.editorPreview.firstChild, 'scroll', { offset: '-50', duration: 1000, container: this.$refs.editorPreview })
  458. } else {
  459. let closestLine = _.findLast(linesMap, n => n <= currentLine)
  460. let destElm = this.$refs.editorPreview.querySelector(`[data-line='${closestLine}']`)
  461. if (destElm) {
  462. this.Velocity(this.$refs.editorPreview, 'stop', true)
  463. this.Velocity(destElm, 'scroll', { offset: '-100', duration: 1000, container: this.$refs.editorPreview })
  464. }
  465. }
  466. }, 500),
  467. toggleHelp () {
  468. this.helpShown = !this.helpShown
  469. this.activeModal = ''
  470. },
  471. toggleFullscreen () {
  472. this.cm.setOption('fullScreen', true)
  473. }
  474. },
  475. mounted() {
  476. this.$root.$on('editorInsert', opts => {
  477. switch (opts.kind) {
  478. case 'IMAGE':
  479. let img = `![${opts.text}](${opts.path})`
  480. if (opts.align && opts.align !== '') {
  481. img += `{.align-${opts.align}}`
  482. }
  483. this.insertAtCursor({
  484. content: img
  485. })
  486. break
  487. case 'BINARY':
  488. this.insertAtCursor({
  489. content: `[${opts.text}](${opts.path})`
  490. })
  491. break
  492. }
  493. })
  494. },
  495. beforeDestroy() {
  496. this.$root.$off('editorInsert')
  497. }
  498. }
  499. </script>
  500. <style lang='scss'>
  501. $editor-height: calc(100vh - 112px - 24px);
  502. $editor-height-mobile: calc(100vh - 112px - 16px);
  503. .editor-markdown {
  504. &-main {
  505. display: flex;
  506. width: 100%;
  507. }
  508. &-editor {
  509. background-color: darken(mc('grey', '900'), 4.5%);
  510. flex: 1 1 50%;
  511. display: block;
  512. height: $editor-height;
  513. position: relative;
  514. @include until($tablet) {
  515. height: $editor-height-mobile;
  516. }
  517. }
  518. &-preview {
  519. flex: 1 1 50%;
  520. background-color: mc('grey', '100');
  521. position: relative;
  522. height: $editor-height;
  523. overflow: hidden;
  524. @at-root .theme--dark & {
  525. background-color: mc('grey', '900');
  526. }
  527. @include until($tablet) {
  528. display: none;
  529. }
  530. &-enter-active, &-leave-active {
  531. transition: max-width .5s ease;
  532. max-width: 50vw;
  533. .editor-code-preview-content {
  534. width: 50vw;
  535. overflow:hidden;
  536. }
  537. }
  538. &-enter, &-leave-to {
  539. max-width: 0;
  540. }
  541. &-content {
  542. height: $editor-height;
  543. overflow-y: scroll;
  544. padding: 1rem 1rem 1rem 0;
  545. width: calc(100% + 1rem + 17px);
  546. // -ms-overflow-style: none;
  547. // &::-webkit-scrollbar {
  548. // width: 0px;
  549. // background: transparent;
  550. // }
  551. @include until($tablet) {
  552. height: $editor-height-mobile;
  553. }
  554. }
  555. }
  556. &-toolbar {
  557. background-color: mc('blue', '700');
  558. background-image: linear-gradient(to bottom, mc('blue', '700') 0%, mc('blue','800') 100%);
  559. color: #FFF;
  560. .v-toolbar__content {
  561. padding-left: 78px;
  562. @include until($tablet) {
  563. padding-left: 8px;
  564. }
  565. }
  566. }
  567. &-insert:not(.v-speed-dial--right) {
  568. @include from($tablet) {
  569. left: 50%;
  570. margin-left: -28px;
  571. }
  572. }
  573. &-sidebar {
  574. background-color: mc('grey', '900');
  575. width: 64px;
  576. display: flex;
  577. flex-direction: column;
  578. justify-content: flex-start;
  579. align-items: center;
  580. padding: 24px 0;
  581. @include until($tablet) {
  582. padding: 12px 0;
  583. width: 40px;
  584. }
  585. }
  586. &-sysbar {
  587. padding-left: 0;
  588. &-locale {
  589. background-color: rgba(255,255,255,.25);
  590. display:inline-flex;
  591. padding: 0 12px;
  592. height: 24px;
  593. width: 63px;
  594. justify-content: center;
  595. align-items: center;
  596. }
  597. }
  598. // ==========================================
  599. // Fix FAB revealing under codemirror
  600. // ==========================================
  601. .speed-dial--fixed {
  602. z-index: 8;
  603. }
  604. // ==========================================
  605. // CODE MIRROR
  606. // ==========================================
  607. .CodeMirror {
  608. height: auto;
  609. .cm-header-1 {
  610. font-size: 1.5rem;
  611. }
  612. .cm-header-2 {
  613. font-size: 1.25rem;
  614. }
  615. .cm-header-3 {
  616. font-size: 1.15rem;
  617. }
  618. .cm-header-4 {
  619. font-size: 1.1rem;
  620. }
  621. .cm-header-5 {
  622. font-size: 1.05rem;
  623. }
  624. .cm-header-6 {
  625. font-size: 1.025rem;
  626. }
  627. }
  628. .CodeMirror-focused .cm-matchhighlight {
  629. background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAYAAABytg0kAAAAFklEQVQI12NgYGBgkKzc8x9CMDAwAAAmhwSbidEoSQAAAABJRU5ErkJggg==);
  630. background-position: bottom;
  631. background-repeat: repeat-x;
  632. }
  633. .cm-matchhighlight {
  634. background-color: mc('grey', '800');
  635. }
  636. .CodeMirror-selection-highlight-scrollbar {
  637. background-color: mc('green', '600');
  638. }
  639. .cm-s-wikijs-dark.CodeMirror {
  640. background: darken(mc('grey','900'), 3%);
  641. color: #e0e0e0;
  642. }
  643. .cm-s-wikijs-dark div.CodeMirror-selected {
  644. background: mc('blue','800');
  645. }
  646. .cm-s-wikijs-dark .cm-matchhighlight {
  647. background: mc('blue','800');
  648. }
  649. .cm-s-wikijs-dark .CodeMirror-line::selection, .cm-s-wikijs-dark .CodeMirror-line > span::selection, .cm-s-wikijs-dark .CodeMirror-line > span > span::selection {
  650. background: mc('red', '500');
  651. }
  652. .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 {
  653. background: mc('red', '500');
  654. }
  655. .cm-s-wikijs-dark .CodeMirror-gutters {
  656. background: darken(mc('grey','900'), 6%);
  657. border-right: 1px solid mc('grey','900');
  658. }
  659. .cm-s-wikijs-dark .CodeMirror-guttermarker {
  660. color: #ac4142;
  661. }
  662. .cm-s-wikijs-dark .CodeMirror-guttermarker-subtle {
  663. color: #505050;
  664. }
  665. .cm-s-wikijs-dark .CodeMirror-linenumber {
  666. color: mc('grey','800');
  667. }
  668. .cm-s-wikijs-dark .CodeMirror-cursor {
  669. border-left: 1px solid #b0b0b0;
  670. }
  671. .cm-s-wikijs-dark span.cm-comment {
  672. color: mc('orange','800');
  673. }
  674. .cm-s-wikijs-dark span.cm-atom {
  675. color: #aa759f;
  676. }
  677. .cm-s-wikijs-dark span.cm-number {
  678. color: #aa759f;
  679. }
  680. .cm-s-wikijs-dark span.cm-property, .cm-s-wikijs-dark span.cm-attribute {
  681. color: #90a959;
  682. }
  683. .cm-s-wikijs-dark span.cm-keyword {
  684. color: #ac4142;
  685. }
  686. .cm-s-wikijs-dark span.cm-string {
  687. color: #f4bf75;
  688. }
  689. .cm-s-wikijs-dark span.cm-variable {
  690. color: #90a959;
  691. }
  692. .cm-s-wikijs-dark span.cm-variable-2 {
  693. color: #6a9fb5;
  694. }
  695. .cm-s-wikijs-dark span.cm-def {
  696. color: #d28445;
  697. }
  698. .cm-s-wikijs-dark span.cm-bracket {
  699. color: #e0e0e0;
  700. }
  701. .cm-s-wikijs-dark span.cm-tag {
  702. color: #ac4142;
  703. }
  704. .cm-s-wikijs-dark span.cm-link {
  705. color: #aa759f;
  706. }
  707. .cm-s-wikijs-dark span.cm-error {
  708. background: #ac4142;
  709. color: #b0b0b0;
  710. }
  711. .cm-s-wikijs-dark .CodeMirror-activeline-background {
  712. background: mc('grey','900');
  713. }
  714. .cm-s-wikijs-dark .CodeMirror-matchingbracket {
  715. text-decoration: underline;
  716. color: white !important;
  717. }
  718. }
  719. </style>