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

@editora/doc-schema

v1.0.3

Published

Native structured document schema plugin for Editora with section validation and guided insertion

Readme

@editora/doc-schema

Version License TypeScript Size

[!IMPORTANT] Live Website: https://editora-ecosystem.netlify.app/
Storybook: https://editora-ecosystem-storybook.netlify.app/

@editora/doc-schema provides structured authoring workflows for contracts, SOPs, and policy documents. It validates heading structure, highlights schema violations, and can insert missing required sections.

Features

  • Native plugin (no framework dependency)
  • Works in React (Vite/CRA) and Web Components without modification
  • Built-in schemas: Contract, SOP, Policy
  • Runtime schema switching per editor instance
  • Realtime or on-demand schema validation
  • Insert missing required sections in one action
  • Strict-order insertion places missing sections near schema-correct boundaries (not always at end)
  • Inserted headings inherit the dominant heading level used by schema sections in current document
  • Multi-instance-safe command targeting and toolbar active states
  • Light/dark theme support
  • Accessible panel (role="dialog", keyboard-operable controls, live region updates)

Install

npm install @editora/doc-schema

Basic Usage (React)

import { EditoraEditor } from '@editora/react';
import { DocSchemaPlugin, HistoryPlugin } from '@editora/plugins';

export default function App() {
  return (
    <EditoraEditor
      plugins={[
        HistoryPlugin(),
        DocSchemaPlugin({
          defaultSchemaId: 'policy',
          enableRealtime: true,
        }),
      ]}
    />
  );
}

Basic Usage (Web Component)

<editora-editor id="editor"></editora-editor>
<script>
  const editor = document.getElementById('editor');
  editor.setConfig({
    plugins: 'history doc-schema',
    toolbar: {
      items: 'undo redo | toggleDocSchemaPanel runDocSchemaValidation toggleDocSchemaRealtime',
    },
  });
</script>

Accepted aliases: docSchema, doc-schema, docschema.

Step-by-Step Scenario (Policy Team)

Scenario: Security governance team writes a quarterly access-control policy. The document must always include Policy Statement, Applicability, Controls, Exceptions, and Enforcement in order.

  1. Open schema panel: Ctrl/Cmd + Alt + Shift + G.
  2. Select schema: Policy.
  3. Click Run Validation.
  4. Review issues list.
  5. Click Insert Missing Sections to place required missing headings in schema-correct order.
  6. Fill content under each inserted heading.
  7. Re-run validation or keep realtime enabled.

Why it helps:

  • Prevents missing critical sections before legal/compliance review.
  • Keeps document structure consistent across teams and releases.
  • Reduces manual checklist/rework cycles.

Toolbar Commands

  • toggleDocSchemaPanel
  • openDocSchemaPanel
  • runDocSchemaValidation
  • insertMissingDocSchemaSections
  • toggleDocSchemaRealtime
  • setDocSchemaMode
  • setDocSchemaOptions
  • getDocSchemaState

Keyboard Shortcuts

  • Ctrl/Cmd + Alt + Shift + G -> toggle schema panel
  • Ctrl/Cmd + Alt + Shift + J -> run schema validation

Advanced Usage

1. Custom schema library

DocSchemaPlugin({
  defaultSchemaId: 'incident-postmortem',
  schemas: [
    {
      id: 'incident-postmortem',
      label: 'Incident Postmortem',
      strictOrder: true,
      allowUnknownHeadings: true,
      sections: [
        { id: 'summary', title: 'Summary' },
        { id: 'impact', title: 'Impact' },
        { id: 'timeline', title: 'Timeline', maxOccurrences: 10 },
        { id: 'root-cause', title: 'Root Cause' },
        { id: 'actions', title: 'Action Items' },
      ],
    },
  ],
});

2. Runtime schema/profile update per editor instance

(window as any).executeEditorCommand?.('setDocSchemaOptions', {
  defaultSchemaId: 'contract',
  enableRealtime: false,
  labels: {
    panelTitle: 'Governance Schema',
    validateText: 'Audit Structure',
  },
});

3. Programmatic schema switch + validation

(window as any).executeEditorCommand?.('setDocSchemaMode', 'sop');
(window as any).executeEditorCommand?.('runDocSchemaValidation');

4. Read runtime state

(window as any).executeEditorCommand?.('getDocSchemaState', (state) => {
  console.log(state.activeSchemaId, state.issues.length);
});

Edge Cases Covered

  • Multi-editor pages: explicit command context is consumed for safe targeting.
  • Detached editors: internal state/panel cleanup on unmount/removal.
  • Read-only mode: insertion blocked with live-region feedback.
  • Long sessions: realtime validation is debounced and bounded by maxIssues.
  • Numbered headings (for example 1. Scope): normalized matching handles common numbering prefixes.
  • Unknown headings policy: configurable per schema via allowUnknownHeadings.
  • Strict order insertion: missing sections are placed before the next higher-order section (or after lower-order sections) to avoid creating new ordering violations.
  • Heading hierarchy preservation: inserted headings use the dominant existing schema heading level (for example h3 in nested policy docs).