Skip to content

feat: add @docmd/plugin-threads — inline discussion threads#98

Merged
mgks merged 2 commits intodocmd-io:mainfrom
svallory:feat/plugin-threads
Apr 9, 2026
Merged

feat: add @docmd/plugin-threads — inline discussion threads#98
mgks merged 2 commits intodocmd-io:mainfrom
svallory:feat/plugin-threads

Conversation

@svallory
Copy link
Copy Markdown
Contributor

@svallory svallory commented Apr 5, 2026

Summary

Adds @docmd/plugin-threads — a plugin for inline discussion threads stored directly in markdown files. Comments are the source of truth in the .md files, no database needed.

Features

  • Text selection → highlight → comment threads (like Google Docs)
  • Nested replies with collapsible threads
  • User identity (GitHub/Gravatar avatars, localStorage persistence)
  • Emoji reactions on comments
  • Thread resolution (mark as resolved/unresolved)
  • Dark mode support
  • Static build support (renders threads without WebSocket)

Markdown syntax

This has a ==highlighted snippet=={t-abc123} that links to a thread.

::: threads
  ::: thread t-abc123
    ::: comment c-def456 "Alice" "2026-01-15"
      This is a comment with **markdown** support.
    :::
  :::
:::

Context

This is the plugin discussed in #73. Depends on #94 (parser export), #95 (plugin hooks), #96 (action dispatcher), and #97 (WebSocket RPC).

The plugin is fully TypeScript/ESM, targeting @docmd/core@^0.6.5 and @docmd/parser@^0.6.5.

Architecture

  • Server-side (src/plugin/): Markdown parser/serializer, container rules, highlight syntax rule, 8 WebSocket action handlers (CRUD for threads, comments, reactions)
  • Client-side (src/client/): Lit web components — text selection UI, inline editor, identity panel, thread cards, comment display
  • Types (src/types.ts): Thread, Comment, Reaction, Anchor interfaces

Test plan

  • pnpm build — tsc compiles server code, esbuild bundles client
  • Unit tests for parser (serialize/deserialize round-trip)
  • Unit tests for containers (markdown-it rendering)
  • Unit tests for highlight rule
  • Unit tests for actions (mock ctx)
  • E2E tests (Playwright) against a running dev server
  • Manual: start docmd dev, select text, create thread, add reply, verify reload

svallory added 2 commits April 3, 2026 17:30
Converts all server-side plugin code from JavaScript/CommonJS to
TypeScript/ESM targeting @docmd/core@^0.6.5 and @docmd/parser@^0.6.5.
Client code was already TypeScript and is unchanged. Renames package
from @svallory/docmd-plugin-threads to @docmd/plugin-threads.

Files converted:
- index.js -> src/index.ts
- src/plugin/parser.js -> src/plugin/parser.ts
- src/plugin/containers.js -> src/plugin/containers.ts
- src/plugin/highlight-rule.js -> src/plugin/highlight-rule.ts
- src/plugin/actions.js -> src/plugin/actions.ts

Added tsconfig.json for server-side compilation (client uses esbuild).
Updated package.json with ESM type, exports map, and peer dependencies.
This was referenced Apr 5, 2026
@mgks mgks merged commit 209d952 into docmd-io:main Apr 9, 2026
@mgks
Copy link
Copy Markdown
Member

mgks commented Apr 9, 2026

Merged! Looking forward to building on the threads plugin. 🎉
I will be refining it further with newer releases. Thanks!

@mgks mgks added the Feature / Enhancement New feature addition or request/suggestion label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature / Enhancement New feature addition or request/suggestion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants