CodeFlask icon indicating copy to clipboard operation
CodeFlask copied to clipboard

External highlighter and omit initial callbacks

Open wellenvogel opened this issue 5 years ago • 1 comments

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

wellenvogel avatar Mar 03 '20 18:03 wellenvogel

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

kazzkiq avatar Jun 04 '20 20:06 kazzkiq