refactor: extract block label helper

This commit is contained in:
lix-2026
2026-05-25 07:52:06 +08:00
parent 5186e0334b
commit 2c3077cb24
6 changed files with 31 additions and 21 deletions
@@ -199,3 +199,6 @@ UI / 浏览器可见项必须有真实浏览器截图或结构化 smoke 证据
- Worker C `/mnt/Data1T/mnote-worktrees/0525-ae-worker-c-3-20-upload-target-readonly`run `reasonix-2026-05-24T23-18-29-419Z-3e999c4d` 有完整 `process-handoff.md/json``result.json``final.md`,源码零 diff;审计结论经主控复核后采纳:`resolveFileTreeUploadTarget` 暂不宜迁入 browser runtime,核心依赖 `preflightFileTreeUploadTarget``sidebarFileTreeSelection`、fetch 与 DOM 查询;`refreshLocalFolderSidebarSnapshot` 仍是 shell 编排,append/reveal 系列 helper 已足够外置。
- Worker D `/mnt/Data1T/mnote-worktrees/0525-ae-worker-d-regression-smoke`run `reasonix-2026-05-24T23-18-29-435Z-3225d16e` 串线执行成 5-29 overlay 只读审计,未运行 `task489` / `task488` / `task487` / `task451` smoke;本轮 3-20 smoke 输出拒收。
- 后续 3-20 推荐下一刀:只读审计 `syncSidebarFileTreeSelection` 是否可迁入 `filetree-runtime.js`,或在明确降级兼容策略后评估 inline fallback 瘦身;不要继续盲迁 `refreshLocalFolderSidebarSnapshot` 整体。
- 2026-05-25:发现未授权 Reasonix runner / ACP 进程指向 `/mnt/Data1T/mnote-worktrees/0525-af-worker-b-3-20-filetree-selection-helper`
- 处置:该 worker 未由主控按当前 goal 派发,已终止相关 `reasonix-coding-runner` / `reasonix acp` 进程;主控复查后未发现残留 Reasonix worker。
- 采纳:不读取、不采纳该 worktree 的任何输出;后续若要审计 `syncSidebarFileTreeSelection`,必须重新按最多 2 worker 的短批次显式派发。
@@ -268,3 +268,7 @@ UI / 浏览器可见项必须有真实浏览器截图或结构化 smoke 证据
- 修改:`editor_runtime/overlays.rs` 新增 `table_overlay_anchor_from_table``current_table_overlay_anchor``table_row_aux_style``table_col_aux_style``lib.rs` 删除同名实现并通过 import 继续调用。
- 边界:未迁 table selection signal、row/column click handler、overlay DOM view 或 `table_selection_overlay_style`;本批只外置表格 overlay anchor / aux style 的纯 DOM rect 与 CSS 计算。
- 已验证:`cargo fmt --manifest-path rust/Cargo.toml --all --check``cargo check --manifest-path rust/spikes/leptos-tiptap-spike/Cargo.toml`、wasm release build、`wasm-bindgen``MNOTE_WEB_SMOKE_BASE_URL=http://127.0.0.1:3001 NODE_PATH=/mnt/Data1T/mnote/node_modules node scripts/task489-block-menu-delete-undo-smoke.js``MNOTE_WEB_SMOKE_BASE_URL=http://127.0.0.1:3001 NODE_PATH=/mnt/Data1T/mnote/node_modules node scripts/task488-local-attachment-link-delete-undo-smoke.js``MNOTE_WEB_SMOKE_BASE_URL=http://127.0.0.1:3001 NODE_PATH=/mnt/Data1T/mnote/node_modules node scripts/task479-local-folder-markdown-resource-lifecycle-smoke.js`
- 2026-05-25Batch AG 未派发 Reasonix worker;主控本地完成 block label helper 小切片。
- 修改:`editor_runtime/block_hover_state.rs` 新增 `block_label_for_element(block)``lib.rs` 删除同名实现并通过 import 继续调用。
- 边界:未迁 `block_state_from_index``hovered_block_from_target`、DOM listener 或 block menu signal;本批只外置 Element -> block label 的纯映射。
- 已验证:`cargo fmt --manifest-path rust/Cargo.toml --all --check``cargo check --manifest-path rust/spikes/leptos-tiptap-spike/Cargo.toml`、wasm release build、`wasm-bindgen`、临时当前源码服务 `MNOTE_WEB_BIND=127.0.0.1:3013 MNOTE_WEB_PUBLIC_BIND=127.0.0.1:3013 cargo run --manifest-path rust/Cargo.toml -p mnote-web``MNOTE_WEB_SMOKE_BASE_URL=http://127.0.0.1:3013 NODE_PATH=/mnt/Data1T/mnote/node_modules node scripts/task489-block-menu-delete-undo-smoke.js``MNOTE_WEB_SMOKE_BASE_URL=http://127.0.0.1:3013 NODE_PATH=/mnt/Data1T/mnote/node_modules node scripts/task488-local-attachment-link-delete-undo-smoke.js``MNOTE_WEB_SMOKE_BASE_URL=http://127.0.0.1:3013 NODE_PATH=/mnt/Data1T/mnote/node_modules node scripts/task479-local-folder-markdown-resource-lifecycle-smoke.js`
@@ -1284,7 +1284,7 @@ function __wbg_get_imports() {
return ret;
},
__wbindgen_cast_0000000000000006: function(arg0, arg1) {
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("KeyboardEvent")], shim_idx: 294, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("KeyboardEvent")], shim_idx: 839, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hd90af689bc3e71bf);
return ret;
},
@@ -4,6 +4,8 @@
//! 或 editor command。类型字段使用 `pub(crate)` 以支持跨模块访问,保持结构
//! 和语义同构。
use web_sys::Element;
/// Hovered block 的共享状态:索引、类型标签、位置和高度。
#[derive(Clone, Debug, PartialEq)]
pub(crate) struct HoveredBlockState {
@@ -45,3 +47,22 @@ pub(crate) struct PendingDragState {
pub(crate) start_x: i32,
pub(crate) start_y: i32,
}
pub(crate) fn block_label_for_element(block: &Element) -> String {
match block.get_attribute("data-type").as_deref() {
Some("taskList") => "Todo 列表".to_string(),
Some("taskItem") => "Todo 项".to_string(),
_ => match block.tag_name().as_str() {
"H1" => "一级标题".to_string(),
"H2" => "二级标题".to_string(),
"H3" => "三级标题".to_string(),
"P" => "段落".to_string(),
"UL" => "无序列表".to_string(),
"OL" => "有序列表".to_string(),
"BLOCKQUOTE" => "引用块".to_string(),
"PRE" => "代码块".to_string(),
"HR" => "分割线".to_string(),
other => format!("块节点 {other}"),
},
}
}
+2 -20
View File
@@ -34,7 +34,8 @@ use editor_runtime::block_menu_legacy_html::{
duplicate_top_level_block_html, reorder_top_level_block_html,
};
use editor_runtime::block_hover_state::{
BlockMenuLayout, DropIndicatorState, HoveredBlockState, PendingDragState,
block_label_for_element, BlockMenuLayout, DropIndicatorState, HoveredBlockState,
PendingDragState,
};
use editor_runtime::command_sync::{
read_editor_snapshot, sync_editor_outputs, sync_persisted_editor_command,
@@ -4826,25 +4827,6 @@ fn handle_lane_left(stage_rect_width: f64) -> f64 {
.max(HANDLE_STAGE_PADDING_LEFT)
}
fn block_label_for_element(block: &Element) -> String {
match block.get_attribute("data-type").as_deref() {
Some("taskList") => "Todo 列表".to_string(),
Some("taskItem") => "Todo 项".to_string(),
_ => match block.tag_name().as_str() {
"H1" => "一级标题".to_string(),
"H2" => "二级标题".to_string(),
"H3" => "三级标题".to_string(),
"P" => "段落".to_string(),
"UL" => "无序列表".to_string(),
"OL" => "有序列表".to_string(),
"BLOCKQUOTE" => "引用块".to_string(),
"PRE" => "代码块".to_string(),
"HR" => "分割线".to_string(),
other => format!("块节点 {other}"),
},
}
}
fn current_target_html_element(event: &WheelEvent) -> Option<HtmlElement> {
event.current_target()?.dyn_into::<HtmlElement>().ok()
}