Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tinymce/tinymce-react

Package Overview
Dependencies
Maintainers
1
Versions
365
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tinymce/tinymce-react

Official TinyMCE React Component

  • 2.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
302K
increased by1.87%
Maintainers
1
Weekly downloads
 
Created

What is @tinymce/tinymce-react?

@tinymce/tinymce-react is a React component for TinyMCE, a popular WYSIWYG (What You See Is What You Get) editor. It allows developers to integrate the TinyMCE editor into their React applications easily, providing a rich text editing experience with a wide range of features and customization options.

What are @tinymce/tinymce-react's main functionalities?

Basic Integration

This code demonstrates how to integrate the TinyMCE editor into a React application with basic configuration. The editor is initialized with some default content and a set of plugins and toolbar options.

import React from 'react';
import { Editor } from '@tinymce/tinymce-react';

function App() {
  return (
    <Editor
      initialValue="<p>This is the initial content of the editor</p>"
      init={{
        height: 500,
        menubar: false,
        plugins: [
          'advlist autolink lists link image charmap print preview anchor',
          'searchreplace visualblocks code fullscreen',
          'insertdatetime media table paste code help wordcount'
        ],
        toolbar:
          'undo redo | formatselect | bold italic backcolor | \
          alignleft aligncenter alignright alignjustify | \
          bullist numlist outdent indent | removeformat | help'
      }}
    />
  );
}

export default App;

Handling Editor Events

This code shows how to handle events from the TinyMCE editor. The `handleEditorChange` function logs the updated content to the console whenever the content of the editor changes.

import React from 'react';
import { Editor } from '@tinymce/tinymce-react';

function App() {
  const handleEditorChange = (content, editor) => {
    console.log('Content was updated:', content);
  };

  return (
    <Editor
      initialValue="<p>This is the initial content of the editor</p>"
      init={{
        height: 500,
        menubar: false,
        plugins: [
          'advlist autolink lists link image charmap print preview anchor',
          'searchreplace visualblocks code fullscreen',
          'insertdatetime media table paste code help wordcount'
        ],
        toolbar:
          'undo redo | formatselect | bold italic backcolor | \
          alignleft aligncenter alignright alignjustify | \
          bullist numlist outdent indent | removeformat | help'
      }}
      onEditorChange={handleEditorChange}
    />
  );
}

export default App;

Customizing the Toolbar

This code demonstrates how to customize the toolbar in the TinyMCE editor. A custom button is added to the toolbar, which shows an alert when clicked.

import React from 'react';
import { Editor } from '@tinymce/tinymce-react';

function App() {
  return (
    <Editor
      initialValue="<p>This is the initial content of the editor</p>"
      init={{
        height: 500,
        menubar: false,
        plugins: [
          'advlist autolink lists link image charmap print preview anchor',
          'searchreplace visualblocks code fullscreen',
          'insertdatetime media table paste code help wordcount'
        ],
        toolbar:
          'myCustomToolbarButton | undo redo | formatselect | bold italic backcolor | \
          alignleft aligncenter alignright alignjustify | \
          bullist numlist outdent indent | removeformat | help',
        setup: (editor) => {
          editor.ui.registry.addButton('myCustomToolbarButton', {
            text: 'My Button',
            onAction: () => alert('Button clicked!')
          });
        }
      }}
    />
  );
}

export default App;

Other packages similar to @tinymce/tinymce-react

FAQs

Package last updated on 05 Apr 2018

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