kazzkiq / CodeFlask

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

Detatch Prism from CodeFlask #120

Open kazzkiq opened 4 years ago

kazzkiq commented 4 years ago

Related: #110, #66, #65

CodeFlask should be a thin layer built on top of any available web syntax-highlighter out there.

While I still think Prism is the best suited syntax highlighter available, some users raised the possibility of being able to choose between other libs and also configure the highlighter outside of CodeFlask.

For me it makes sense. This lib would then expose an API to connect any highlighter with the editor instance and let users configure the chosen lib as they see fit (with themes, supported languages, etc).

This approach may lead to a leaner core.

Usage example (now):

import CodeFlask from 'codeflask';

const flask = new CodeFlask('#editor', {
  language: 'js'
});

Usage example in v2:

import CodeFlask from 'codeflask';
import Prism from 'prismjs';

const flask = new CodeFlask('#editor', {
  language: 'js',
  highlighter: Prism.highlightElement
});