source.js 802 B

123456789101112131415161718192021222324
  1. 'use strict'
  2. import $ from 'jquery'
  3. import * as ace from 'brace'
  4. import 'brace/theme/tomorrow_night'
  5. import 'brace/mode/markdown'
  6. module.exports = (alerts) => {
  7. if ($('#page-type-source').length) {
  8. var scEditor = ace.edit('source-display')
  9. scEditor.setTheme('ace/theme/tomorrow_night')
  10. scEditor.getSession().setMode('ace/mode/markdown')
  11. scEditor.setOption('fontSize', '14px')
  12. scEditor.setOption('hScrollBarAlwaysVisible', false)
  13. scEditor.setOption('wrap', true)
  14. scEditor.setReadOnly(true)
  15. scEditor.renderer.updateFull()
  16. let currentBasePath = ($('#page-type-source').data('entrypath') !== 'home') ? $('#page-type-source').data('entrypath') : ''
  17. require('../modals/create.js')(currentBasePath)
  18. require('../modals/move.js')(currentBasePath, alerts)
  19. }
  20. }