calumk / editorjs-columns

116 stars 27 forks source link

@calumk/editorjs-Columns

A BETA plugin which allows the user to have columns

Pull requests welcomed!

Installation

npm i @calumk/editorjs-columns

https://cdn.jsdelivr.net/npm/@calumk/editorjs-columns@latest

Demo

demo

Features

ChangeLog

28/04/23 - Re-added feature - EditorJs must now be passed as instance through tool to child, to avoid duplicate editorjs installs, and ensure only one editor js instance is used. 16/05/22 - Removed global tool varable. Switched to config variable for column tools (see Example) 22/05/22 - EditorJs must now be passed as instance through tool to child, to avoid duplicate editorjs installs - Rolled Back

Known Bugs

Docs

None yet, see example/example.html for useage.


Note : Tools are passed to editorjs-columns using config.tools property

// first define the tools to be made avaliable in the columns
let column_tools = {
    header: Header,
    alert : Alert,
    paragraph : editorjsParagraphLinebreakable,
    delimiter : Delimiter
}

// next define the tools in the main block
// Warning - Dont just use main_tools - you will probably generate a circular reference 
let main_tools = {
// Load Official Tools
    header: Header,
    alert : Alert,
    paragraph : editorjsParagraphLinebreakable,
    delimiter : Delimiter,

    columns : {
        class : editorjsColumns,
        config : {
          EditorJsLibrary : EditorJs, // Pass the library instance to the columns instance.
          tools : column_tools // IMPORTANT! ref the column_tools
        }
      },
}

editor = new EditorJS({
    tools : main_tools,
});