refactor: split document pane runtime

This commit is contained in:
lix-2026
2026-05-26 00:47:51 +08:00
parent b4d7360cd7
commit 6197ca5d3a
5 changed files with 199 additions and 146 deletions
+5
View File
@@ -142,6 +142,10 @@ pub fn build_router(state: AppState) -> Router {
"/api/mnote-browser-runtime/document-conflict-panel-runtime.js",
get(web_shell::document_conflict_panel_runtime_asset),
)
.route(
"/api/mnote-browser-runtime/document-pane-runtime.js",
get(web_shell::document_pane_runtime_asset),
)
.route(
"/api/mnote-browser-runtime/document-tiptap-conversion-runtime.js",
get(web_shell::document_tiptap_conversion_runtime_asset),
@@ -563,6 +567,7 @@ mod tests {
"/api/mnote-browser-runtime/tree-live-controller.js",
"/api/mnote-browser-runtime/tree-shell-runtime.js",
"/api/mnote-browser-runtime/document-conflict-panel-runtime.js",
"/api/mnote-browser-runtime/document-pane-runtime.js",
"/api/mnote-browser-runtime/document-tiptap-conversion-runtime.js",
"/api/mnote-browser-runtime/document-editor-adapter-runtime.js",
] {
@@ -855,6 +855,20 @@ pub async fn document_conflict_panel_runtime_asset() -> Response {
.unwrap_or_else(|_| Response::new(Body::empty()))
}
pub async fn document_pane_runtime_asset() -> Response {
const JS: &str = include_str!("../../browser/document-pane-runtime.js");
Response::builder()
.status(StatusCode::OK)
.header(
header::CONTENT_TYPE,
"application/javascript; charset=utf-8",
)
.header(header::CACHE_CONTROL, "no-store")
.header(HEADER_MNOTE_WEB_OWNER, "mnote-web")
.body(Body::from(JS))
.unwrap_or_else(|_| Response::new(Body::empty()))
}
pub async fn document_tiptap_conversion_runtime_asset() -> Response {
const JS: &str = include_str!("../../browser/document-tiptap-conversion-runtime.js");
Response::builder()
@@ -1292,6 +1306,7 @@ mod tests {
const DOCUMENT_EDITOR_ADAPTER_RUNTIME_JS: &str =
include_str!("../../browser/document-editor-adapter-runtime.js");
const DOCUMENT_PANE_RUNTIME_JS: &str = include_str!("../../browser/document-pane-runtime.js");
const DOCUMENT_TIPTAP_CONVERSION_RUNTIME_JS: &str =
include_str!("../../browser/document-tiptap-conversion-runtime.js");
@@ -2041,6 +2056,9 @@ mod tests {
assert!(DOCUMENT_EDITOR_ADAPTER_RUNTIME_JS.contains("PANES_BOOTSTRAP_ID"));
assert!(DOCUMENT_EDITOR_ADAPTER_RUNTIME_JS.contains("ROOT_SELECTOR"));
assert!(DOCUMENT_EDITOR_ADAPTER_RUNTIME_JS.contains("BRIDGE_PROTOCOL"));
assert!(DOCUMENT_EDITOR_ADAPTER_RUNTIME_JS.contains("document-pane-runtime.js"));
assert!(DOCUMENT_PANE_RUNTIME_JS.contains("openDocumentInSecondaryPane"));
assert!(DOCUMENT_PANE_RUNTIME_JS.contains("buildPaneRuntime"));
assert!(
DOCUMENT_EDITOR_ADAPTER_RUNTIME_JS.contains("document-tiptap-conversion-runtime.js")
);