refactor: extract block dnd handle predicate
This commit is contained in:
+1
-1
@@ -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: 856, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("KeyboardEvent")], shim_idx: 886, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hd90af689bc3e71bf);
|
||||
return ret;
|
||||
},
|
||||
|
||||
BIN
Binary file not shown.
@@ -4,7 +4,7 @@
|
||||
//! 也不分发 editor command;调用方负责保留编辑器状态编排。
|
||||
|
||||
use crate::editor_runtime::block_hover_state::{DropIndicatorState, DropPlacement};
|
||||
use web_sys::{window, EventTarget};
|
||||
use web_sys::{window, Element, EventTarget};
|
||||
|
||||
pub(crate) struct HandleCorridorGeometry {
|
||||
pub(crate) stage_left: f64,
|
||||
@@ -81,6 +81,10 @@ pub(crate) fn event_target_from_point(client_x: i32, client_y: i32) -> Option<Ev
|
||||
.map(Into::into)
|
||||
}
|
||||
|
||||
pub(crate) fn element_within_handle_shell(element: &Element, handle_selector: &str) -> bool {
|
||||
element.closest(handle_selector).ok().flatten().is_some()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -22,8 +22,8 @@ use web_sys::{
|
||||
|
||||
use editor_runtime::attachment_upload::dispatch_editor_upload_request;
|
||||
use editor_runtime::block_dnd::{
|
||||
drop_indicator_from_geometry, event_target_from_point, pointer_in_handle_corridor_geometry,
|
||||
HandleCorridorGeometry,
|
||||
drop_indicator_from_geometry, element_within_handle_shell, event_target_from_point,
|
||||
pointer_in_handle_corridor_geometry, HandleCorridorGeometry,
|
||||
};
|
||||
use editor_runtime::block_menu_overlay;
|
||||
use editor_runtime::block_menu_legacy_html::{
|
||||
@@ -4914,12 +4914,7 @@ fn hovered_block_from_target(target: web_sys::EventTarget) -> Option<HoveredBloc
|
||||
let root = editor_root_element()?;
|
||||
let element = target_element(target)?;
|
||||
|
||||
if element
|
||||
.closest(HANDLE_SHELL_SELECTOR)
|
||||
.ok()
|
||||
.flatten()
|
||||
.is_some()
|
||||
{
|
||||
if element_within_handle_shell(&element, HANDLE_SHELL_SELECTOR) {
|
||||
return None;
|
||||
}
|
||||
|
||||
@@ -8103,7 +8098,7 @@ fn App(mount_options: MountOptions) -> impl IntoView {
|
||||
};
|
||||
|
||||
if let Some(element) = target_element(target.clone()) {
|
||||
if element.closest(HANDLE_SHELL_SELECTOR).ok().flatten().is_some() {
|
||||
if element_within_handle_shell(&element, HANDLE_SHELL_SELECTOR) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -8155,7 +8150,7 @@ fn App(mount_options: MountOptions) -> impl IntoView {
|
||||
};
|
||||
|
||||
if let Some(element) = target_element(target.clone()) {
|
||||
if element.closest(HANDLE_SHELL_SELECTOR).ok().flatten().is_some() {
|
||||
if element_within_handle_shell(&element, HANDLE_SHELL_SELECTOR) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -8208,7 +8203,7 @@ fn App(mount_options: MountOptions) -> impl IntoView {
|
||||
};
|
||||
|
||||
if let Some(element) = target_element(target.clone()) {
|
||||
if element.closest(HANDLE_SHELL_SELECTOR).ok().flatten().is_some() {
|
||||
if element_within_handle_shell(&element, HANDLE_SHELL_SELECTOR) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user