npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wpmvc/classic-editor

v0.0.2

Published

A React component for integrating WordPress' classic editor using wp.editor API

Downloads

153

Readme

ClassicEditor

ClassicEditor is a React component that seamlessly integrates the WordPress Classic Editor using the wp.editor API. This component provides a fully customizable TinyMCE editor for your React applications, enabling rich text editing capabilities.

npm downloads License

Installation

To install the @wpmvc/classic-editor package, run:

npm install @wpmvc/classic-editor

Usage

You can use the ClassicEditor component in your React application as follows:

import { useState } from '@wordpress/element';
import ClassicEditor from '@wpmvc/classic-editor';

const MyComponent = () => {
  const [content, setContent] = useState('Initial content here');

  return (
    <div>
      <h2>My Custom Editor</h2>
      <ClassicEditor
        value={content}
        onChange={(newContent) => setContent(newContent)}
        height={300} // Optional, default is 250
        hasMedia={true} // Optional, allows media buttons
        useExtendStyles={true} // Optional, use extended CSS styles
      />
    </div>
  );
};

export default MyComponent;

Props

The ClassicEditor component accepts the following props:

  • value (string): The initial content of the editor.
  • onChange (function): Callback function that is called when the content changes. It receives the updated content as an argument.
  • height (number): The height of the TinyMCE editor in pixels. Defaults to 250.
  • useExtendStyles (boolean): If true, applies extended styles to the editor. Defaults to false.
  • hasMedia (boolean): If true, includes media buttons in the editor. Defaults to true.

PHP Integration

To use the WordPress Classic Editor in your custom theme or plugin, add the following PHP code to your functions.php file or the main plugin file:

<?php
/**
 * Enqueue WordPress Classic Editor and Media for custom usage.
 */

// Ensure this code runs in the correct context
if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}

// Add filter to allow rich text editor
add_filter( 'user_can_richedit', '__return_true' );

// Function to enqueue the editor and media scripts
function enqueue_wp_classic_editor_and_media() {
    // Enqueue the WordPress editor scripts
    wp_enqueue_editor();
    
    // Enqueue the WordPress media scripts
    wp_enqueue_media();
}

// Hook the function to an appropriate action
add_action( 'admin_enqueue_scripts', 'enqueue_wp_classic_editor_and_media' );

Features

  • Fully customizable TinyMCE editor
  • Real-time content updates
  • Optional media button integration
  • Support for extended styling

Dependencies

This component requires react. Ensure that your project includes this dependency.

Contributing

Contributions are welcome! Please open an issue or submit a pull request if you'd like to contribute to the project.

Acknowledgments

  • TinyMCE for the rich text editor functionality.
  • React for the component-based architecture.