Halko is content editor powered by React.js plugins.
Join our community on spectrum.chat/halko.
Install editor core and basic plugins:
npm i --save @halko/editor @halko/plugin-text @halko-plugin-imageimport React from 'react'
import { Editor } from '@halko/editor'
import { Image } from '@halko/plugin-image'
import { Text } from '@halko/plugin-text'
const App = () => (
<div>
<h1>Using Halko in React</h1>
<Editor plugins={[Text, Image]} />
</div>
)To configure plugin, wrap it in array and pass config as second array element:
<Editor plugins={[Text, [Image, config]]} /><Editor
initialValue={[
{plugin: 'text', data: '<p>Hello world</p>'},
{plugin: 'text', data: '<p>Second line</p>'},
]}
/><Editor onChange={api => {
this.setState({editorContent: api.getContent()})
} />Content rendering is handled by plugins used to create that content. To render it, use Renderer component and pass the same plugins you passed to Editor.
import React from 'react'
import { Renderer } from '@halko/editor'
import { Image } from '@halko/plugin-image'
import { Text } from '@halko/plugin-text'
const App = () => (
<div>
<h1>Using Halko in React</h1>
<Renerer
plugins={[Text, Image]}
value={[
{plugin: 'text', data: '<p>Hello world</p>'},
{plugin: 'text', data: '<p>Second line</p>'},
]}
/>
</div>
)onInit
<Editor onInit={api => /* handle init */} />onChange
<Editor onChange={api => /* handle change */} />- Fork this repository to your own GitHub account and then clone it to your local device
- Install project dependencies:
npm i - Install packages dependencies:
npm run bootstrap - Run packages build script in watch mode:
npm run watch - Run playground server:
npm run dev - Access playground at: localhost:3000