tiptap-editor by xiaolai/vmark
npx skills add https://github.com/xiaolai/vmark --skill tiptap-editor本技能文档记录了 vmark 开发中正确的 Tiptap API 使用模式。它有助于区分何时使用 Tiptap 的高级 API,何时直接访问 ProseMirror。
以下情况应优先使用 Tiptap API:
isActive, getAttributes)应使用的 Tiptap 模式:
// 直接命令
editor.commands.toggleBold()
editor.commands.setHeading({ level: 2 })
editor.commands.setContent(doc, { emitUpdate: false })
// 链式命令(用于多个操作)
editor.chain().focus().setHeading({ level: 2 }).run()
editor.chain().focus().toggleMark("underline").run()
// 状态查询
editor.isActive("blockquote")
editor.isActive("heading", { level: 2 })
editor.getAttributes("link")
以下情况应直接使用 ProseMirror:
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
proseMirrorToMdast.tsmdastToProseMirror.tsMultiSelection.ts)src/hooks/mcpBridge/cursorHandlers.ts 使用了 doc.textContent,这会扁平化文档并丢失块边界。正确的方法是使用 $pos 辅助函数:
// 错误 - 丢失块结构
const text = doc.textContent;
// 正确 - 尊重块边界
const $pos = doc.resolve(from);
const currentNode = $pos.parent;
const blockStart = $pos.before($pos.depth);
const blockEnd = $pos.after($pos.depth);
sourceLine 属性仅在初始解析时设置。在 WYSIWYG 编辑添加/删除块之后,行号不再与源代码匹配。这是一个已知的限制。
src/plugins/markdownArtifacts/HtmlNodeView.ts 将光标信息写入错误的存储。
references/patterns.md - 详细的 API 模式和 $pos 使用references/examples.md - vmark 代码库中的真实代码示例editor.commands.xxx()editor.chain().focus().xxx().run()doc.resolve(pos) 获取 $pos 辅助函数editor.isActive() 或 editor.getAttributes()每周安装量
132
代码仓库
GitHub 星标数
168
首次出现
2026年2月15日
安全审计
安装于
opencode128
github-copilot127
codex127
gemini-cli126
cursor126
kimi-cli124
This skill documents proper Tiptap API usage patterns for vmark development. It helps distinguish when to use Tiptap's high-level API vs direct ProseMirror access.
Always prefer Tiptap API for:
isActive, getAttributes)Tiptap patterns to use:
// Direct commands
editor.commands.toggleBold()
editor.commands.setHeading({ level: 2 })
editor.commands.setContent(doc, { emitUpdate: false })
// Chained commands (for multiple operations)
editor.chain().focus().setHeading({ level: 2 }).run()
editor.chain().focus().toggleMark("underline").run()
// State queries
editor.isActive("blockquote")
editor.isActive("heading", { level: 2 })
editor.getAttributes("link")
Use ProseMirror directly for:
proseMirrorToMdast.ts, mdastToProseMirror.ts)MultiSelection.ts)src/hooks/mcpBridge/cursorHandlers.ts uses doc.textContent which flattens the document and loses block boundaries. The correct approach is to use $pos helpers:
// WRONG - loses block structure
const text = doc.textContent;
// RIGHT - respects block boundaries
const $pos = doc.resolve(from);
const currentNode = $pos.parent;
const blockStart = $pos.before($pos.depth);
const blockEnd = $pos.after($pos.depth);
sourceLine attributes are only set on initial parse. After WYSIWYG edits that add/remove blocks, line numbers no longer match the source. This is a known limitation.
src/plugins/markdownArtifacts/HtmlNodeView.ts writes cursor info to wrong store.
references/patterns.md - Detailed API patterns and $pos usagereferences/examples.md - Real code examples from vmark codebaseeditor.commands.xxx() for single operationseditor.chain().focus().xxx().run() when focus is needed or chainingdoc.resolve(pos) to get $pos helperseditor.isActive() or editor.getAttributes()Weekly Installs
132
Repository
GitHub Stars
168
First Seen
Feb 15, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode128
github-copilot127
codex127
gemini-cli126
cursor126
kimi-cli124
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
115,300 周安装