Socket
Socket
Sign inDemoInstall

@ckeditor/ckeditor5-react

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckeditor/ckeditor5-react

Official React component for CKEditor 5 – the best browser-based rich text editor.


Version published
Weekly downloads
189K
decreased by-3.9%
Maintainers
1
Weekly downloads
 
Created

What is @ckeditor/ckeditor5-react?

@ckeditor/ckeditor5-react is a React component that integrates CKEditor 5, a modern JavaScript rich text editor, into React applications. It provides a rich set of features for creating and editing content, including text formatting, image and media embedding, and collaborative editing.

What are @ckeditor/ckeditor5-react's main functionalities?

Basic Usage

This code demonstrates the basic usage of the @ckeditor/ckeditor5-react package. It imports the CKEditor component and the ClassicEditor build, then renders the editor with some initial data and event handlers for ready, change, blur, and focus events.

import React from 'react';
import { CKEditor } from '@ckeditor/ckeditor5-react';
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';

function App() {
  return (
    <div className="App">
      <h2>Using CKEditor 5 with React</h2>
      <CKEditor
        editor={ ClassicEditor }
        data="<p>Hello from CKEditor 5!</p>"
        onReady={ editor => {
          console.log( 'Editor is ready to use!', editor );
        } }
        onChange={ ( event, editor ) => {
          const data = editor.getData();
          console.log( { event, editor, data } );
        } }
        onBlur={ ( event, editor ) => {
          console.log( 'Blur.', editor );
        } }
        onFocus={ ( event, editor ) => {
          console.log( 'Focus.', editor );
        } }
      />
    </div>
  );
}

export default App;

Custom Configuration

This code demonstrates how to use a custom configuration with the CKEditor component. The editorConfiguration object specifies a custom toolbar and heading options, which are then passed to the CKEditor component via the config prop.

import React from 'react';
import { CKEditor } from '@ckeditor/ckeditor5-react';
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';

function App() {
  const editorConfiguration = {
    toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'bulletedList', 'numberedList', 'blockQuote' ],
    heading: {
      options: [
        { model: 'paragraph', title: 'Paragraph', class: 'ck-heading_paragraph' },
        { model: 'heading1', view: 'h1', title: 'Heading 1', class: 'ck-heading_heading1' },
        { model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2' }
      ]
    }
  };

  return (
    <div className="App">
      <h2>Using CKEditor 5 with Custom Configuration</h2>
      <CKEditor
        editor={ ClassicEditor }
        config={ editorConfiguration }
        data="<p>Custom configuration example.</p>"
      />
    </div>
  );
}

export default App;

Using Plugins

This code demonstrates how to use plugins with the CKEditor component. The Alignment plugin is imported and added to the ClassicEditor build. The editorConfiguration object includes the alignment options, which are then passed to the CKEditor component via the config prop.

import React from 'react';
import { CKEditor } from '@ckeditor/ckeditor5-react';
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';
import Alignment from '@ckeditor/ckeditor5-alignment/src/alignment';

ClassicEditor.builtinPlugins.push( Alignment );

function App() {
  const editorConfiguration = {
    toolbar: [ 'heading', '|', 'bold', 'italic', 'link', 'alignment', 'bulletedList', 'numberedList', 'blockQuote' ],
    alignment: {
      options: [ 'left', 'center', 'right', 'justify' ]
    }
  };

  return (
    <div className="App">
      <h2>Using CKEditor 5 with Plugins</h2>
      <CKEditor
        editor={ ClassicEditor }
        config={ editorConfiguration }
        data="<p>Plugin example with text alignment.</p>"
      />
    </div>
  );
}

export default App;

Other packages similar to @ckeditor/ckeditor5-react

Keywords

FAQs

Package last updated on 01 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc