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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nc-doc-editor

v0.1.0

Published

Rich Document Editor React component with annotations and PDF integration

Downloads

10

Readme

NC Document Editor

A professional, high-performance React document editor with PDF annotation capabilities, optimized for production use.

✨ Features

  • 📄 PDF Support - Full PDF viewing and annotation
  • ✍️ Rich Annotations - Signatures, stamps, comments, and drawings
  • 🎨 Modern UI - Beautiful, responsive design with Tailwind CSS
  • ⚡ Performance Optimized - Tree-shaking, memoization, and lazy loading
  • ♿ Accessible - ARIA labels, keyboard navigation, and screen reader support
  • 🔧 Highly Configurable - Extensive customization options
  • 📱 Responsive - Works on desktop, tablet, and mobile
  • 💾 Export Capabilities - Export annotations as JSON
  • 🔄 Undo/Redo - Full history management

🚀 Quick Start

npm install nc-doc-editor
import { DocumentEditor } from "nc-doc-editor";
import "nc-doc-editor/styles.css";

function App() {
  return (
    <DocumentEditor
      title="My Document Editor"
      maxFileSizeMB={25}
      onFileChange={(file, url) => console.log("File loaded:", file?.name)}
      onError={(error) => console.error("Error:", error)}
    />
  );
}

📦 Bundle Size

  • ESM: ~466KB (gzipped: ~120KB)
  • CJS: ~470KB (gzipped: ~125KB)
  • CSS: ~15KB (gzipped: ~5KB)

⚙️ Configuration Options

DocumentEditor Props

| Prop | Type | Default | Description | | ---------------------- | --------------------- | ------------------------------- | ----------------------- | | initialFileUrl | string | undefined | Initial PDF URL to load | | title | string | "Document Editor" | Editor title | | maxFileSizeMB | number | 50 | Maximum file size in MB | | acceptedFileTypes | AcceptedKind[] | ["pdf"] | Accepted file types | | showExportButton | boolean | true | Show export button | | showFileChangeButton | boolean | true | Show file change button | | uploadText | string | "Drop a PDF to start editing" | Upload area text | | uploadSubtext | string | "Use Manage Signatures..." | Upload area subtext | | onFileChange | (file, url) => void | undefined | File change callback | | onError | (error) => void | undefined | Error callback |

File Types

type AcceptedKind = "pdf" | "image";

🎯 Performance Optimizations

Bundle Optimization

  • Tree Shaking: Only imports used components
  • Code Splitting: Lazy loading for heavy components
  • Minification: Production builds are minified
  • External Dependencies: React/React-DOM are external

Runtime Optimization

  • React.memo: Components are memoized
  • useCallback: Event handlers are optimized
  • Lazy Loading: Heavy features load on demand
  • Memory Management: Proper cleanup of object URLs

CSS Optimization

  • Purged CSS: Only used styles are included
  • Minified: CSS is minified for production
  • Critical Path: Essential styles are inlined

🔧 Advanced Usage

Custom Styling

<DocumentEditor
  className="my-custom-editor"
  style={{ border: "1px solid #e5e7eb" }}
/>

Event Handling

<DocumentEditor
  onFileChange={(file, url) => {
    if (file) {
      // File was loaded
      console.log("File:", file.name, "Size:", file.size);
    } else {
      // File was cleared
      console.log("File cleared");
    }
  }}
  onError={(error) => {
    // Handle errors
    console.error("Editor error:", error);
  }}
/>

Custom Configuration

<DocumentEditor
  title="Contract Editor"
  maxFileSizeMB={10}
  acceptedFileTypes={["pdf"]}
  showExportButton={false}
  uploadText="Drop your contract here"
  uploadSubtext="PDF files only, max 10MB"
/>

🎨 UI Components

The editor includes several UI components that can be used independently:

  • DocumentEditor - Main editor component
  • DocumentViewer - PDF viewer with annotations
  • FileUpload - Drag & drop file upload
  • AnnotationToolbar - Annotation tools
  • DrawingToolbar - Drawing tools
  • SignatureManager - Signature management
  • CommentsPanel - Comments interface

🔌 Provider Components

For advanced customization, you can use the provider components directly:

import {
  AnnotationsProvider,
  CommentsProvider,
  DrawingProvider,
  SignatureProvider,
  ToolsProvider,
  HistoryProvider,
} from "nc-doc-editor";

function CustomEditor() {
  return (
    <HistoryProvider>
      <AnnotationsProvider docKey="my-doc">
        <CommentsProvider docKey="my-doc">
          <DrawingProvider docKey="my-doc">
            <SignatureProvider docKey="my-doc">
              <ToolsProvider>{/* Your custom editor */}</ToolsProvider>
            </SignatureProvider>
          </DrawingProvider>
        </CommentsProvider>
      </AnnotationsProvider>
    </HistoryProvider>
  );
}

🚀 Development

# Install dependencies
npm install

# Start development server
npm run dev

# Build for production
npm run build

# Run tests
npm test

📄 License

MIT License - see LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please read our contributing guidelines.

📞 Support

For support, please open an issue on GitHub or contact us.