kazzkiq / CodeFlask

A micro code-editor for awesome web pages.
https://kazzkiq.github.io/CodeFlask/
MIT License
1.07k stars 121 forks source link

External highlighter and omit initial callbacks #110

Open wellenvogel opened 4 years ago

wellenvogel commented 4 years ago

I'm trying to use codeflask in my avnav project. There were 2 drawbacks:

  1. when using the editor initially it always calls the update callback. This makes it slightly complicated to find out if there really was a change. So I introduced a parameter on updateCode and an option "noInitialCallback" to prevent those calls if you intend
  2. I found no easy way to add more languages to prism in a webpack/ES6 environment. I ended up with importing prism by my own again and adding the language to codeflask from the prism instance. But this way we end up having 2 instances of prism - not very nice - and giving some error on startup. So I introduced an option for the highlighter function: highLighter. If you omit it, there is no highlighter at all. This way I could completely remove prism (of I guess it is needed for test - I was not really able to run them). The initial call looks like var editor=new Flask('editor',{ language:'js', highLighter:Prism.highlightElement, noInitialCallback:true}

Maybe you would be interested in considering this PR - or some similar solution.

Best regards Andreas

kazzkiq commented 4 years ago

This is an interesting feature, but would lead to breaks in current API and thus should be released in the next Major version.