[feat] 支持在笔记正文中嵌入可交互组件或沙箱 HTML

Open
#1,320 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
nextjs, tauri, typescript

Research direction

Read the existing show_ui and render_response chat components, the plugin sandbox iframe, and the code block rendering protocol that currently outputs SVG/PNG. Decide whether the note editor should support persistent component blocks or sandboxed HTML embeds, including how content and optional runtime state are saved and restored. Done means users can insert, edit, preview, and reopen an interactive block, with a defined fallback for export formats that cannot run it.

Written by the indexing model from the issue text.

Description

描述你的建议

希望在笔记正文中嵌入可交互的内容块,让文字说明与可操作的表单、计算器、动态图表或 AI 生成的小工具放在同一篇笔记里。

例如,在一段说明后插入一个计算器,修改输入值后实时更新结果;或在学习笔记中插入可调整参数的演示图表。希望用户能直接在正文里操作,而不必跳到浏览器或只查看静态截图。

期望的使用方式
  • 在正文任意块位置插入交互内容,并能切换源码/配置与交互预览。
  • 支持按钮、输入、选择以及组件自身的联动逻辑。
  • 内容可以随笔记保存,重新打开、切换源码/视觉模式后仍可恢复。
  • 是否保存表单填写值等运行状态可以作为独立选项,不要求第一阶段全部实现。
  • 对不支持交互的导出格式,提供静态预览、链接或明确的占位说明。
可考虑的实现方向

不限定必须使用 iframe,可以考虑以下任一路线:

  1. 将现有聊天中的 json-render 组件能力扩展到正文,提供可持久化的交互块,并允许通过插件增加受控组件。
  2. 提供沙箱 HTML Embed 块,在 iframe 中运行独立的 HTML/CSS/JavaScript,适合 AI 生成的小工具和交互演示。

从当前 dev 源码看,show_ui 已有表单等组件,render_response 已有标签页、折叠面板等能力,但主要服务于聊天;插件也已有沙箱 iframe 界面,而代码块渲染协议目前只输出 SVG/PNG。想请教是否可以在这些基础上增加正文交互块,或者开放相应扩展接口。

这里关注的是正文中的独立交互内容块,而不是完整的内置网页浏览器。HTML/脚本如被支持,应在隔离环境中运行,不应获得宿主或本地文件权限;外部资源访问可以按需控制。

相关讨论
  • #1128:自定义组件和样式功能,和本建议的组件扩展方向相关,但该需求主要提到样式及公众号 HTML 输出。
  • #94:内置 WebView 的历史讨论。本建议聚焦正文交互块,不要求实现完整浏览器。

如果已有推荐的插件或实现计划,也希望能指引一下。谢谢!

Dominant language
TypeScript
Stars
12.9k
Forks
975
Avg merge
20h 27m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from codexu/note-gen

All issues in codexu/note-gen

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.