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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mdaemon/html-editor-react

v1.0.0

Published

React wrapper for MDHTMLEditor

Readme

MDHTMLEditor React

React wrapper for MDHTMLEditor, providing a TinyMCE-compatible React component.

Installation

npm install @mdaemon/html-editor-react

Note: This package requires @mdaemon/html-editor as a peer dependency.

Usage

Basic Usage

import React, { useRef } from 'react';
import { MDEditor, EditorRef } from '@mdaemon/html-editor-react';

function MyComponent() {
  const editorRef = useRef<EditorRef>(null);

  const handleInit = (editor) => {
    console.log('Editor ready:', editor);
  };

  const handleChange = (content) => {
    console.log('Content changed:', content);
  };

  return (
    <MDEditor
      ref={editorRef}
      init={{
        height: 400,
        basicEditor: false,
      }}
      initialValue="<p>Hello World</p>"
      onInit={handleInit}
      onEditorChange={handleChange}
    />
  );
}

useEditor Hook

For more control, use the useEditor hook:

import { useEditor } from '@mdaemon/html-editor-react';

function MyComponent() {
  const { containerRef, editor, content, setContent, isDirty } = useEditor({
    initialValue: '<p>Hello</p>',
    onChange: (html) => console.log('Changed:', html),
  });

  const handleSave = () => {
    if (isDirty) {
      saveContent(content);
      editor?.setDirty(false);
    }
  };

  return (
    <div>
      <div ref={containerRef} />
      <button onClick={handleSave}>Save</button>
    </div>
  );
}

Global Access

For legacy compatibility, editors can be accessed globally:

import { getEditorContent, setEditorContent } from '@mdaemon/html-editor-react';

// Get content from any editor by ID
const content = getEditorContent('myEditor');

// Set content
setEditorContent('myEditor', '<p>New content</p>');

Props

| Prop | Type | Description | |------|------|-------------| | id | string | Editor identifier for global access | | init | EditorConfig | Configuration object passed to HTMLEditor | | initialValue | string | Initial HTML content | | value | string | Controlled content value | | disabled | boolean | Disable editing | | onInit | (editor) => void | Called when editor initializes | | onEditorChange | (content) => void | Called on content change | | onDirtyChange | (isDirty) => void | Called when dirty state changes | | onFocus | () => void | Called on focus | | onBlur | () => void | Called on blur |

EditorRef Methods

When using the ref prop, you have access to:

  • getContent(): string - Get current HTML
  • setContent(html: string): void - Set HTML content
  • insertContent(html: string): void - Insert at cursor
  • execCommand(cmd, ui?, value?): boolean - Run command
  • focus(): void - Focus editor
  • isDirty(): boolean - Check dirty state
  • setDirty(state): void - Set dirty state

Configuration

All configuration options from @mdaemon/html-editor are supported in the init prop:

<MDEditor
  init={{
    basicEditor: false,
    includeTemplates: true,
    templates: [
      { title: 'Signature', content: '<p>Best regards,<br/>John</p>' }
    ],
    dropbox: true,
    images_upload_url: '/api/upload',
    font_family_formats: 'Arial=arial;Times=times new roman',
    font_size_formats: '10pt 12pt 14pt 16pt',
    fontName: 'Arial',
    fontSize: '12pt',
    directionality: 'ltr',
    skin: 'oxide',
    height: 400,
  }}
/>

Migration from @tinymce/tinymce-react

This package provides a similar API to @tinymce/tinymce-react:

// Before (TinyMCE)
import { Editor } from '@tinymce/tinymce-react';

<Editor
  init={{ height: 400, plugins: 'link image' }}
  onEditorChange={handleChange}
/>

// After (MDHTMLEditor)
import { MDEditor } from '@mdaemon/html-editor-react';

<MDEditor
  init={{ height: 400 }}
  onEditorChange={handleChange}
/>

Key differences:

  • No licenseKey or apiKey required
  • plugins option not needed (features built-in)
  • Toolbar customization uses basicEditor boolean instead of toolbar string

License

LGPL 3.0 or later - MDaemon Technologies