agentleFS
hunghg255hunghg255/reactjs-tiptap-editor/.github/copilot-instructions.md

reactjs-tiptap-editor

Copilot instructions749 starsChanged 2 months agoMITView on GitHub

This is a modular rich-text editor library built on Tiptap 3.x with Shadcn UI patterns. It ships as a pnpm monorepo: Extensions live in src/extensions/{Name}/ with this structure: Extension example (Bold.ts): When creating new extensions: UI components in src/components/ui/ follow Shadcn conventions: Import alias: @/ maps to src/ (see vite.config.ts) Uses reactjs-signal for reactive state: Theme and locale actions are exposed via: Library builds to lib/ with dual format: Package exports are auto-generated from src/extensions/*/ (see vite.config.ts glob logic). Translations…

  • Installs packages
  • Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.

    Of the Copilot instructions files we read, the 2,349 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository5 other files it gives its agents.

The file

We split this copilot-instructions.md into the rules it gives an agent

9 rules. About 0 are common, 2 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    CSS isolation: All Tailwind classes prefixed with richtext- (configured in vite.config.ts postcss)

    line 16
  2. Distinctive:

    When creating new extensions:

    line 51
  3. Very specific:

    Add button option returning { component, componentProps } for toolbar integration

    line 54
  4. Very specific:

    Create matching RichText{Name} component for toolbar

    line 56
  5. Very specific:

    Use Radix primitives (@radix-ui/react-*)

    line 62
  6. Very specific:

    Create src/locales/{lang}.ts following en.ts structure

    line 110
  7. Very specific:

    Use t('editor.{key}') in components

    line 112
  8. Distinctive:

    Always test in playground after modifying extensions:

    line 116
  9. Very specific:

    Import your extension in playground/src/App.tsx

    line 120

≈ “Common” is an estimate: at least 1 in 5 of the 3,779 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

Copilot Instructions for reactjs-tiptap-editor

Architecture Overview

This is a modular rich-text editor library built on Tiptap 3.x with Shadcn UI patterns. It ships as a pnpm monorepo:

  • src/ - Main library source (published to npm)
  • playground/ - Development demo app
  • docs/ - Documentation site (VitePress)

Key Design Decisions

  • Tree-shakable extensions: Each of 40+ extensions is independently importable (reactjs-tiptap-editor/bold)
  • Tiptap-native: Uses @tiptap/react's useEditor hook directly—no custom wrapper
  • Signal-based state: Uses reactjs-signal for theme, locale, and editor state
  • CSS isolation: All Tailwind classes prefixed with richtext- (configured in vite.config.ts postcss)

Extension Pattern

Extensions live in src/extensions/{Name}/ with this structure:

src/extensions/Bold/
├── Bold.ts       # Extends Tiptap extension, adds `button` option
├── index.ts      # Re-exports (export * from './Bold')
└── components/   # Optional React components (RichTextBold toolbar item)

Extension example (Bold.ts):

export const Bold = TiptapBold.extend<BoldOptions>({
  addOptions() {
    return {
      ...this.parent?.(),
      button: ({ editor, t, extension }) => ({
        component: ActionButton,
        componentProps: {
          action: () => editor.commands.toggleBold(),
          isActive: () => editor.isActive('bold'),
          icon: 'Bold',
          shortcutKeys: extension.options.shortcutKeys ?? ['mod', 'B'],
          tooltip: t('editor.bold.tooltip'),
        },
      }),
    };
  },
});

When creating new extensions:

  1. Extend the Tiptap extension using @__PURE__ annotation for tree-shaking
  2. Add button option returning { component, componentProps } for toolbar integration
  3. Export types extending GeneralOptions<T> from src/types.ts
  4. Create matching RichText{Name} component for toolbar

Component Patterns

UI components in src/components/ui/ follow Shadcn conventions:

  • Use Radix primitives (@radix-ui/react-*)
  • Style with class-variance-authority (cva)
  • Prefix all classes with richtext-

Import alias: @/ maps to src/ (see vite.config.ts)

State Management

Uses reactjs-signal for reactive state:

// src/store/store.ts pattern
const signal = createSignal<boolean>(false);
const useValue = () => useSignalValue(signal);
const useSetValue = () => useSetSignal(signal);

Theme and locale actions are exposed via:

  • reactjs-tiptap-editor/theme → themeActions.setTheme(), themeActions.setColor()
  • reactjs-tiptap-editor/locale-bundle → localeActions.setLang()

Development Commands

pnpm install              # Install all workspace dependencies
pnpm build:lib:dev        # Build library with watch mode (required before playground)
pnpm playground           # Start playground dev server
pnpm build:lib            # Production build → outputs to lib/
pnpm lint && pnpm fmt     # Lint (oxlint) and format (oxfmt)
pnpm type-check           # TypeScript validation
pnpm docs:dev             # Run documentation site locally

Build Output

Library builds to lib/ with dual format:

  • ESM: lib/{Extension}.js
  • CJS: lib/{Extension}.cjs
  • Types: lib/extensions/{Extension}/index.d.ts

Package exports are auto-generated from src/extensions/*/ (see vite.config.ts glob logic).

i18n

Translations in src/locales/{lang}.ts. Add new locale:

  1. Create src/locales/{lang}.ts following en.ts structure
  2. Register in src/locales/index.ts LANG.message object
  3. Use t('editor.{key}') in components

Testing Changes

Always test in playground after modifying extensions:

  1. pnpm build:lib:dev (keep running)
  2. pnpm playground (in another terminal)
  3. Import your extension in playground/src/App.tsx

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.