Skip to main content

write_editor

Function write_editor 

Source
fn write_editor(post_id: Option<i32>) -> Element
Expand description

文章编辑器核心组件,支持新建(post_id == None)与编辑模式。

负责:

  • 编辑模式下通过 server function 拉取文章数据;
  • 在 WASM 前端通过 tiptap_bridge 的 closure 回调初始化 Tiptap 富文本编辑器;
  • 编辑模式下将 Markdown 内容回填到编辑器;
  • 提交时读取编辑器 Markdown、校验并调用 create_post / update_post;
  • 组件卸载时销毁 Tiptap 实例(EditorHandle::drop 自动 destroy + 释放 closure)。