Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

How to add code to highlight? #12

Closed
dczxw opened this issue Apr 26, 2017 · 3 comments
Closed

How to add code to highlight? #12

dczxw opened this issue Apr 26, 2017 · 3 comments

Comments

@dczxw
Copy link

dczxw commented Apr 26, 2017

I want to paste some code,how to add code to highlight?

@surmon-china
Copy link
Owner

// import in your entry
import hljs from 'highlight.js'
import 'highlight.js/styles/monokai-sublime.css'

// and set option
editorOption: {
  modules: {
    syntax: {
      highlight: text => window.hljs.highlightAuto(text).value
      // or
      /*
      highlight(text) {
        const result = window.hljs.highlightAuto(text)
        return result.value
      }
      */
    }
  },
  theme: 'snow'
}

https://quilljs.com/docs/modules/syntax/
https://github.com/quilljs/quill/blob/develop/docs/docs/modules/syntax.md
https://github.com/quilljs/quill/blob/develop/modules/syntax.js#L68
https://github.com/quilljs/quill/blob/develop/modules/syntax.js#L41

@dczxw
Copy link
Author

dczxw commented Apr 28, 2017

thanks

@dczxw
Copy link
Author

dczxw commented Apr 28, 2017

I import the highLight.js ; and set the options ,
this is a error : 'hljs' does not exist on type 'Window'.
@surmon-china

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants