editor-js / code

Code Tool for Editor.js 2.0
MIT License
71 stars 52 forks source link

Specifying the language of the written code #44

Open Al3bad opened 3 years ago

Al3bad commented 3 years ago

Hi,

Recently I was developing a blog for my website and I used Editor JS + code plugin as a text editor. There is only one thing missing, and that is specifying the language of the code written in the textarea. So, I’ve added this feature where if the user specified an array of languages in the config object, there will be a dropdown menu rendered that containing the languages.

Here is an example:

const editor = new EditorJS({
  holder: "editorjs",
  tools: {
    code: {
      class: CodeTool,
      config: {
        languages: ["HTML", "CSS", "Javascript"],
      },
    },
  },
});

And here are the screenshots of the component that was rendered and the output on saving:

image

image

image

MrMooky commented 2 years ago

Please merge this.