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

@shisuipham/editor-react

v0.0.3

Published

A powerful React editor based on Sun

Readme

editor-react

A powerful React rich text editor based on SunEditor, hỗ trợ upload ảnh/video custom, đổi font, responsive toolbar, và nhiều tính năng mở rộng.

Cài đặt

npm i @shisuipham/editor-react
pnpm i @shisuipham/editor-react

Peer dependencies:

  • react >= 18
  • react-dom >= 18

Import font (nếu dùng Google Fonts)

Font mặc định đã được import sẵn trong file CSS, nhưng bạn có thể thêm vào public/index.html hoặc file CSS chính nếu cần:

<link href="https://fonts.googleapis.com/css?family=Manrope:300,700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,700&display=swap" rel="stylesheet">

Sử dụng cơ bản

import { Editor } from 'editor-react';

function App() {
  return (
    <Editor
      value="<p>Hello SunEditor!</p>"
      onChange={val => console.log(val)}
      placeholder="Nhập nội dung..."
      imageConfig={{
        baseUrl: 'https://your-server.com/api/upload-image',
        prefixUrl: 'https://cdn.your-server.com/images/'
      }}
      videoConfig={{
        baseUrl: 'https://your-server.com/api/upload-video',
        prefixUrl: 'https://cdn.your-server.com/videos/'
      }}
      readOnly={false}
    />
  );
}

API

<Editor /> Props

| Prop | Kiểu dữ liệu | Mô tả | |--------------|--------------|----------------------------------------| | value | string | Nội dung HTML | | onChange | function | Hàm callback khi nội dung thay đổi | | placeholder | string | Placeholder cho editor | | readOnly | boolean | Chế độ chỉ đọc | | imageConfig | object | Config upload ảnh (xem bên dưới) | | videoConfig | object | Config upload video (xem bên dưới) | | ...props | SunEditorReactProps | Các props khác của SunEditor |

imageConfig / videoConfig

{
  baseUrl: string; // Endpoint upload file
  prefixUrl?: string; // Prefix cho url trả về (nếu cần)
  notification?: (message: string) => void; // Hàm callback khi upload thành công/thất bại
  files?: File[]; // (ít dùng) override file upload
}

Custom upload handler

Bạn có thể tuỳ chỉnh upload ảnh/video qua các plugin:

Upload ảnh

import { uploadHandler } from 'editor-react';

uploadHandler({
  files, // File[] từ SunEditor
  upload, // Hàm callback của SunEditor
  baseUrl: 'https://your-server.com/api/upload-image',
  prefixUrl: 'https://cdn.your-server.com/images/',
  notification: (msg) => alert(msg),
});

Upload video

import { uploadVideoHandler } from 'editor-react';

uploadVideoHandler({
  files, // File[] từ SunEditor
  upload, // Hàm callback của SunEditor
  baseUrl: 'https://your-server.com/api/upload-video',
  prefixUrl: 'https://cdn.your-server.com/videos/',
  notification: (msg) => alert(msg),
});

Đổi font chữ

  • Đã cấu hình sẵn các font phổ biến (Manrope, Roboto, Montserrat, v.v.).
  • Để font hiển thị đúng, cần import font vào dự án như hướng dẫn trên.
  • Có thể custom thêm font trong setOptions.font.

Responsive toolbar

Toolbar sẽ tự động thay đổi theo kích thước màn hình.

Hiển thị loading khi upload

Bạn có thể tự thêm overlay loading bằng React state.
Ví dụ:

const [loading, setLoading] = useState(false);

<Editor
  // ...
  onImageUploadBefore={async (files, _, upload) => {
    setLoading(true);
    await uploadHandler({ ...imageConfig, files, upload });
    setLoading(false);
    return true;
  }}
  // ...
/>
{loading && <div className="editor-loading-overlay">Đang upload...</div>}

CSS:

.editor-loading-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

Các tính năng nổi bật

  • Upload ảnh/video: Tích hợp sẵn custom handler, dễ dàng mở rộng.
  • Đổi font, màu sắc, định dạng: Đầy đủ các tính năng soạn thảo hiện đại.
  • Responsive: Toolbar tự động co giãn theo màn hình.
  • Dễ mở rộng: Có thể truyền thêm props của SunEditor gốc.

License

MIT


Nếu bạn cần thêm ví dụ hoặc hướng dẫn chi tiết hơn, hãy xem trong source code hoặc liên hệ tác giả.