@edsdk/n1ed-react

中文文档
1.0.19发布于 2024/09/23LGPL v3TypeScriptESM + CJS近 30 天下载 1.8亿

N1ED editor as a React component

原始使用文档
文档目录6 节
  1. Install
  2. Usage
  3. Examples
  4. Technical details
  5. TypeScript support
  6. License

TinyMCE + N1ED React component

Create and edit HTML content with a powerful visual page builder based on TinyMCE

Q: What can be better than TinyMCE?
A: The latest TinyMCE 6 + a free set of widgets, custom templates, modern UI, Flmngr file manager, ImgPen image editor, Bootstrap column editor, and visual configuration: N1ED.

N1ED screenshot

This module will help to integrate N1ED (bundled TinyMCE + all required free add-ons that power up it) into your React app.

Install

With npm installed, run

$ npm install --save @edsdk/n1ed-react

See full React + TinyMCE + N1ED installation manual for more.

Usage

Here is an example of the usage of TinyMCE + N1ED in your React component. This is a JS sample, see the links below for TypeScript and JavaScript GitHub sample projects.

In this example we use add N1ED and additionally (this is an optional) define a custom toolbar and create inside it a custom TinyMCE button in order to show how to work with basic TinyMCE features from N1ED.

import React from 'react';
import {N1ED} from '@edsdk/n1ed-react';


class YourReactComponent {

    handleEditorChange(content, editor) {
        console.log('Content was updated:', content);
    };
    
    render() {
        
        return <div>
            Edit the content:
            <N1ED
                apiKey="REACDFLT" // you will use your own key later
                initialValue="<p>N1ED react demo</p>"
                onEditorChange={this.handleEditorChange}

                init={{
                    height: 500,
                    toolbar: 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | outdent indent | myCustomToolbarButton',
                    setup: (editor) => {
                        // Just a sample of creating a custom button
                        // N1ED does not block this TinyMCE feature
                        // and also does not conflict with TinyMCE plugins
                        console.log("TinyMCE initialized");
                        editor.ui.registry.addButton('myCustomToolbarButton', {
                            text: 'My Custom Button',
                            onAction: () => alert('Custom button clicked!'),
                        });
                    },
                }}
            />
        </div>;
        
    }
    
}

Important note:: do NOT use TinyMCE as a controlled component (do NOT try to control the state of TinyMCE with a pair of initialValue/onEditorChange). TinyMCE supports only setting of initial value once and then notifies your code about its change using the onEditorChange callback. React TinyMCE implementation is a classic uncontrolled component.

All the attributes of <N1ED> element are described in official TinyMCE React docs.

The only difference is:

  • apiKey attribute here is related not to TinyMCE Cloud, but to N1ED cloud and is optional until you need to visually configure it or add some other add-on from N1ED Ecosystem.

  • You do not need to define plugins parameter with the N1ED value: it is already defined until you specify something another.

Examples

We have two examples of how to use the N1ED React component:

Technical details

@edsdk/n1ed-react uses @tinymce/tinymce-react module inside and delegates all calls to TinyMCE, except some special actions it does for initialization of correct environment related to connection with dynamic CDN (which makes possible configuring your N1ED+TinyMCE instance visually online using Dashboard).

TypeScript support

This module is written with TypeScript and can be used in both JS and TS projects. You do not need to install typings separately, they are built into the project.

License

This module is released under LGPL v3 and free to use in your projects. N1ED itself is also a free product.

版本与发布记录

@edsdk/n1ed-react 共发布 20 个版本,首次发布于 2020/02/10;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.19latest2024/09/232 年前
1.0.182024/09/232 年前
1.0.172022/11/303 年前
1.0.162022/11/303 年前
1.0.152022/11/303 年前
1.0.142022/02/154 年前

关于 @edsdk/n1ed-react 的常见问题

@edsdk/n1ed-react 是什么?

N1ED editor as a React component

如何安装 @edsdk/n1ed-react?

在项目目录运行 npm install @edsdk/n1ed-react,或使用 pnpm add / yarn add / bun add。

@edsdk/n1ed-react 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@edsdk/n1ed-react 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@edsdk/n1ed-react 可以商用吗?

@edsdk/n1ed-react 使用 LGPL v3 许可。声明的许可为 LGPL v3,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@edsdk/n1ed-react 的下载量有多少?

根据 npm 官方下载统计,@edsdk/n1ed-react 在 2026/10/13 – 2026/11/11 这 30 天内被下载 181,413,062 次,日均约 6,047,102 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@edsdk/n1ed-react 还在维护吗?

最新版本 1.0.19 发布于 2024/09/23(2 年前);至今共发布 20 个版本,其中过去 12 个月发布了 0 个;首次发布于 2020/02/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。