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

@pokapali/comments-tiptap

v0.1.2

Published

Tiptap integration for @pokapali/comments

Readme

@pokapali/comments-tiptap

npm install @pokapali/comments-tiptap

Tiptap/ProseMirror adapter for @pokapali/comments. Bridges Y.RelativePosition anchors to ProseMirror document positions and provides editor extensions for comment highlighting.

React apps: @pokapali/react provides ready-made useComments, CommentSidebar, and CommentPopover components. Use them alongside the Tiptap extensions from this package — see React integration below.

Quick Start

import { Editor } from "@tiptap/core";
import Collaboration from "@tiptap/extension-collaboration";
import {
  anchorFromSelection,
  CommentHighlight,
  PendingAnchorHighlight,
  resolveAnchors,
} from "@pokapali/comments-tiptap";
import { comments } from "@pokapali/comments";

// Set up comments on your Yjs docs
const c = comments<MyData>(commentsDoc, contentDoc, {
  author: myPubkey,
  clientIdMapping,
});

// Configure the editor with comment extensions
const editor = new Editor({
  extensions: [
    Collaboration.configure({
      document: contentDoc,
    }),
    CommentHighlight.configure({
      commentsDoc,
      contentDoc,
      activeCommentId: null,
    }),
    PendingAnchorHighlight,
  ],
});

// Create a comment from the current selection
const anchor = anchorFromSelection(editor);
if (anchor) {
  c.add({ content: "Needs work", anchor, data: {} });
}

Key Exports

Anchor Bridge

  • anchorFromSelection(editor) — creates an Anchor from the current editor selection. Returns null if selection is collapsed or sync plugin is inactive.

Bulk Resolution

  • resolveAnchors(commentsDoc, contentDoc, syncState) — resolves all comment anchors to ProseMirror { id, from, to } positions. Skips orphaned or degenerate anchors.

Extensions

  • CommentHighlight — Tiptap extension that creates inline decorations (.comment-anchor, .active) for resolved comment anchors. Rebuilds on doc changes. Configure with commentsDoc, contentDoc, and activeCommentId.
  • rebuildCommentDecorations(view) — dispatch a transaction to force-rebuild decorations (call when comments change externally).
  • PendingAnchorHighlight — Tiptap extension that highlights the anchor being created before submission (.pending-anchor). Tracks concurrent edits.
  • setPendingAnchorDecoration(view, anchor) / clearPendingAnchorDecoration(view) — control the pending highlight imperatively.

Re-exports

  • Anchor — re-exported from @pokapali/comments

React Integration

For React + Tiptap apps, combine the extensions from this package with the high-level components from @pokapali/react:

npm install @pokapali/comments-tiptap \
  @pokapali/react @pokapali/comments

This package provides the Tiptap-specific parts:

  • CommentHighlight / PendingAnchorHighlight — editor extensions for anchor highlighting
  • anchorFromSelection(editor) — create anchors from the current editor selection
  • resolveAnchors() / getSyncState() — map comment IDs to ProseMirror positions

@pokapali/react provides the data and UI layer:

  • useComments(doc) — reactive comment list with CRUD actions (addComment, addReply, updateComment, deleteComment)
  • CommentSidebar — threaded comment list with spatial anchoring, i18n labels, and resolve/reopen/delete actions
  • CommentPopover — floating button that appears on text selection

Wire them together by passing this package's extensions to the editor and @pokapali/react's components to the UI:

import {
  CommentHighlight,
  PendingAnchorHighlight,
  anchorFromSelection,
  resolveAnchors,
  getSyncState,
} from "@pokapali/comments-tiptap";
import { useComments, CommentSidebar, CommentPopover } from "@pokapali/react";

// 1. useComments() handles the data layer
const { comments, addComment, commentsDoc } = useComments(doc);

// 2. Pass extensions to useEditor()
const editor = useEditor(
  {
    extensions: [
      Collaboration.configure({
        document: doc.channel("content"),
      }),
      CommentHighlight.configure({
        commentsDoc,
        contentDoc: doc.channel("content"),
        activeCommentId: null,
      }),
      PendingAnchorHighlight,
    ],
  },
  [doc],
);

// 3. Create anchors via anchorFromSelection()
const anchor = anchorFromSelection(editor);

// 4. Resolve positions for spatial layout
const syncState = getSyncState(editor);
const positions = resolveAnchors(
  commentsDoc,
  doc.channel("content"),
  syncState,
);

See apps/example/ for a complete working integration with all props wired up.

Peer Dependencies

  • @pokapali/comments
  • @tiptap/core >= 2
  • @tiptap/pm >= 2
  • y-prosemirror >= 1
  • yjs >= 13.6

Links