Skip to main content

Module codemirror

Module codemirror 

Source
Expand description

CodeMirror SQL/代码编辑器桥接:extern 与 EditorHandle 在 #[cfg(wasm32)] 子模块里。 SQL 补全 schema DTO(SqlSchema/SqlTable)是 server function 返回值, 定义在 crate::models::sql_schema,不在本模块。 CodeMirror 编辑器的 wasm-bindgen 绑定层。

封装与 window.CodeMirrorEditor(IIFE 暴露的全局对象字面量)的全部交互, 严格镜像 crate::bridges::tiptap 的结构:wasm-bindgen extern + EditorHandle 仅在 WASM 前端编译(server 构建无 window)。SQL 补全用的 SqlSchema/SqlTable 是 server function 返回值 DTO,定义在 crate::models::sql_schema(不属于本文件——避免 API 层反向依赖桥接层)。

与 tiptap 一样,CodeMirrorEditor 是 IIFE 挂在 window 上的对象字面量{ create }),不是函数——因此用 js_sys::Reflect::get 做属性访问拿到, 不能用 wasm-bindgen 的 extern fn(那会被编成函数调用,“not a function”)。