Skip to content

feat(react): add attach file slash command#261

Merged
ocavue merged 1 commit into
prosekit:masterfrom
maccman:codex/attach-file-slash-menu
Jul 8, 2026
Merged

feat(react): add attach file slash command#261
ocavue merged 1 commit into
prosekit:masterfrom
maccman:codex/attach-file-slash-menu

Conversation

@maccman

@maccman maccman commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Problem

Hosts can persist pasted or dropped files through onFilePaste, but users who prefer command menus had no built-in slash command for choosing a file from disk. The slash menu also needed to keep using the same markdown shape as paste/drop so attachments render consistently as images or file pills.

Before -> After

Before After
/ showed the built-in formatting/table/time commands plus host items. When onFilePaste is configured, /attach shows Attach file and opens a hidden file picker.
Hosts had to add their own slash item to persist selected files. The React slash menu reuses onFilePaste, onFileSaveError, and buildFileMarkdown.

Changes

  1. Added an optional Attach file slash menu item in SlashMenu when onFilePaste is present.
  2. Added hidden multi-file input handling that persists files sequentially, formats each result with buildFileMarkdown, and inserts the markdown at the current editor selection.
  3. Threaded onFilePaste and onFileSaveError from ProseKitEditor into SlashMenu.
  4. Covered the attach flow in slash-menu.test.tsx, including query removal before insertion.

Verification

  • git diff --check passed.
  • pnpm vitest run packages/react/src/components/slash-menu.test.tsx passed.
  • pnpm exec oxfmt --check packages/react/src/components/slash-menu.tsx packages/react/src/components/prosekit-editor.tsx packages/react/src/components/slash-menu.test.tsx passed.
  • pnpm exec eslint --max-warnings 0 packages/react/src/components/slash-menu.tsx packages/react/src/components/prosekit-editor.tsx packages/react/src/components/slash-menu.test.tsx passed.
  • pnpm typecheck passed.

Risk / Rollout

No migrations or rollout steps. The command is only shown when a host has already opted into file persistence via onFilePaste; hosts without that handler keep the existing menu behavior.

@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

@maccman is attempting to deploy a commit to the ocavue's projects Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new

pkg-pr-new Bot commented Jul 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/prosekit/meowdown/@meowdown/core@261
npm i https://pkg.pr.new/prosekit/meowdown/@meowdown/react@261

commit: e5908c0

@maccman maccman requested a review from ocavue July 8, 2026 09:38
@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
meowdown Ready Ready Preview, Comment Jul 8, 2026 9:40am

@ocavue ocavue merged commit 0bb1d73 into prosekit:master Jul 8, 2026
11 checks passed
@ocavuebot ocavuebot mentioned this pull request Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants