refactor: externalize document editor adapter runtime

This commit is contained in:
lix-2026
2026-05-26 00:35:35 +08:00
parent 020545e07f
commit 990df30a0f
5 changed files with 3968 additions and 3925 deletions
@@ -85,14 +85,14 @@ rust/spikes/leptos-tiptap-spike/src/lib.rs 7,951 行
拆分项: 拆分项:
- [ ] A1. 把 `render_editor_island_adapter_script()` 的大型 `<script type="module">...</script>` 主体迁入 `document-editor-adapter-runtime.js` - [x] A1. 把 `render_editor_island_adapter_script()` 的大型 `<script type="module">...</script>` 主体迁入 `document-editor-adapter-runtime.js`
- [ ] A2. `web_shell.rs` 改为输出 `<script type="module" src="/api/mnote-browser-runtime/document-editor-adapter-runtime.js"></script>` - [x] A2. `web_shell.rs` 改为输出 `<script type="module" src="/api/mnote-browser-runtime/document-editor-adapter-runtime.js"></script>`
- [ ] A3. 新增 asset route`/api/mnote-browser-runtime/document-editor-adapter-runtime.js` - [x] A3. 新增 asset route`/api/mnote-browser-runtime/document-editor-adapter-runtime.js`
- [ ] A4. 保留并更新测试断言,至少覆盖: - [x] A4. 保留并更新测试断言,至少覆盖:
- [ ] script tag 出现在 document shell HTML。 - [x] script tag 出现在 document shell HTML。
- [ ] runtime asset 包含 `PANES_BOOTSTRAP_ID``ROOT_SELECTOR``BRIDGE_PROTOCOL` - [x] runtime asset 包含 `PANES_BOOTSTRAP_ID``ROOT_SELECTOR``BRIDGE_PROTOCOL`
- [ ] runtime asset 包含 `legacyInlineContentToTiptap``openSecondaryDocument``openPrimaryMindmap` - [x] runtime asset 包含 `legacyInlineContentToTiptap``openSecondaryDocument``openPrimaryMindmap`
- [ ] A5. `web_shell.rs` 行数显著下降,目标少于 3,200 行。 - [x] A5. `web_shell.rs` 行数显著下降,目标少于 3,200 行。
验收命令: 验收命令:
File diff suppressed because it is too large Load Diff
+7 -1
View File
@@ -2802,7 +2802,13 @@ mod tests {
assert!(html.contains(r#"data-testid="mnote-document-workspace""#)); assert!(html.contains(r#"data-testid="mnote-document-workspace""#));
assert!(html.contains(r#"data-mnote-resource-tab-host="true""#)); assert!(html.contains(r#"data-mnote-resource-tab-host="true""#));
assert!(html.contains("__MNOTE_DOCUMENT_PANES_BOOTSTRAP__")); assert!(html.contains("__MNOTE_DOCUMENT_PANES_BOOTSTRAP__"));
assert!(html.contains("openResourceInActiveTab")); assert!(html.contains(
r#"<script type="module" src="/api/mnote-browser-runtime/document-editor-adapter-runtime.js"></script>"#
));
assert!(
include_str!("../../browser/document-editor-adapter-runtime.js")
.contains("openResourceInActiveTab")
);
assert!(!html.contains(r#"<script id="__MNOTE_PAGE_AGGREGATE__""#)); assert!(!html.contains(r#"<script id="__MNOTE_PAGE_AGGREGATE__""#));
} }
+5
View File
@@ -142,6 +142,10 @@ pub fn build_router(state: AppState) -> Router {
"/api/mnote-browser-runtime/document-conflict-panel-runtime.js", "/api/mnote-browser-runtime/document-conflict-panel-runtime.js",
get(web_shell::document_conflict_panel_runtime_asset), get(web_shell::document_conflict_panel_runtime_asset),
) )
.route(
"/api/mnote-browser-runtime/document-editor-adapter-runtime.js",
get(web_shell::document_editor_adapter_runtime_asset),
)
.route("/api/search/documents", post(search::documents)) .route("/api/search/documents", post(search::documents))
.route( .route(
"/api/search/local-index/refresh", "/api/search/local-index/refresh",
@@ -555,6 +559,7 @@ mod tests {
"/api/mnote-browser-runtime/tree-live-controller.js", "/api/mnote-browser-runtime/tree-live-controller.js",
"/api/mnote-browser-runtime/tree-shell-runtime.js", "/api/mnote-browser-runtime/tree-shell-runtime.js",
"/api/mnote-browser-runtime/document-conflict-panel-runtime.js", "/api/mnote-browser-runtime/document-conflict-panel-runtime.js",
"/api/mnote-browser-runtime/document-editor-adapter-runtime.js",
] { ] {
let response = app(false) let response = app(false)
.oneshot( .oneshot(
File diff suppressed because it is too large Load Diff