fix slash menu dismissal and anchor
This commit is contained in:
+13
-25
@@ -539,10 +539,6 @@ function __wbg_get_imports() {
|
||||
const ret = arg0.getElementsByTagName(getStringFromWasm0(arg1, arg2));
|
||||
return ret;
|
||||
},
|
||||
__wbg_getHours_bba0ffaba65cf3f1: function(arg0) {
|
||||
const ret = arg0.getHours();
|
||||
return ret;
|
||||
},
|
||||
__wbg_getItem_7fe1351b9ea3b2f3: function() { return handleError(function (arg0, arg1, arg2, arg3) {
|
||||
const ret = arg1.getItem(getStringFromWasm0(arg2, arg3));
|
||||
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
||||
@@ -550,18 +546,10 @@ function __wbg_get_imports() {
|
||||
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
||||
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
||||
}, arguments); },
|
||||
__wbg_getMinutes_240bbdd69fb6e5d0: function(arg0) {
|
||||
const ret = arg0.getMinutes();
|
||||
return ret;
|
||||
},
|
||||
__wbg_getRangeAt_b7ea59f2b148e5d9: function() { return handleError(function (arg0, arg1) {
|
||||
const ret = arg0.getRangeAt(arg1 >>> 0);
|
||||
return ret;
|
||||
}, arguments); },
|
||||
__wbg_getSeconds_95f730540087b3b6: function(arg0) {
|
||||
const ret = arg0.getSeconds();
|
||||
return ret;
|
||||
},
|
||||
__wbg_getSelection_dfd0ccff15057bd1: function() { return handleError(function (arg0) {
|
||||
const ret = arg0.getSelection();
|
||||
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
||||
@@ -793,10 +781,6 @@ function __wbg_get_imports() {
|
||||
const ret = arg0.metaKey;
|
||||
return ret;
|
||||
},
|
||||
__wbg_new_0_4d657201ced14de3: function() {
|
||||
const ret = new Date();
|
||||
return ret;
|
||||
},
|
||||
__wbg_new_0c7403db6e782f19: function(arg0) {
|
||||
const ret = new Uint8Array(arg0);
|
||||
return ret;
|
||||
@@ -913,6 +897,10 @@ function __wbg_get_imports() {
|
||||
const ret = arg0.queueMicrotask;
|
||||
return ret;
|
||||
},
|
||||
__wbg_random_ce7f6871aed001dd: function() {
|
||||
const ret = Math.random();
|
||||
return ret;
|
||||
},
|
||||
__wbg_register_blockquote_fd046c8c627399c8: function() { return handleError(function () {
|
||||
register_blockquote();
|
||||
}, arguments); },
|
||||
@@ -1244,47 +1232,47 @@ function __wbg_get_imports() {
|
||||
}
|
||||
}, arguments); },
|
||||
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1148, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1140, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h396914cf76a9e7a5);
|
||||
return ret;
|
||||
},
|
||||
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1200, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1192, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
||||
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h3a3182d847094e12);
|
||||
return ret;
|
||||
},
|
||||
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 976, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 969, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
|
||||
const ret = makeClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__had771ddc65647798);
|
||||
return ret;
|
||||
},
|
||||
__wbindgen_cast_0000000000000004: function(arg0, arg1) {
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 1098, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 1090, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0abd2b2fe4652e2a);
|
||||
return ret;
|
||||
},
|
||||
__wbindgen_cast_0000000000000005: function(arg0, arg1) {
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 1148, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 1140, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h396914cf76a9e7a5_4);
|
||||
return ret;
|
||||
},
|
||||
__wbindgen_cast_0000000000000006: function(arg0, arg1) {
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("KeyboardEvent")], shim_idx: 747, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("KeyboardEvent")], shim_idx: 637, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hd90af689bc3e71bf);
|
||||
return ret;
|
||||
},
|
||||
__wbindgen_cast_0000000000000007: function(arg0, arg1) {
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1100, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1092, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h794babeffd4f821f);
|
||||
return ret;
|
||||
},
|
||||
__wbindgen_cast_0000000000000008: function(arg0, arg1) {
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1115, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1107, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
|
||||
const ret = makeClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h2b648e7ac8ec1fb5);
|
||||
return ret;
|
||||
},
|
||||
__wbindgen_cast_0000000000000009: function(arg0, arg1) {
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1151, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 1143, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
||||
const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h0b7fb40a8610550c);
|
||||
return ret;
|
||||
},
|
||||
|
||||
BIN
Binary file not shown.
@@ -18,7 +18,7 @@ pub(crate) struct SlashMenuViewProps {
|
||||
pub(crate) editor: TiptapEditorHandle,
|
||||
pub(crate) signals: SlashMenuSignals,
|
||||
pub(crate) runtime: SlashMenuRuntimeContext,
|
||||
pub(crate) anchor_style: Arc<dyn Fn() -> String + Send + Sync>,
|
||||
pub(crate) anchor_style: ReadSignal<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
@@ -213,7 +213,14 @@ pub(crate) fn slash_menu_view(props: SlashMenuViewProps) -> impl IntoView {
|
||||
<div
|
||||
class="slash-menu"
|
||||
data-testid="mnote-leptos-tiptap-slash-menu"
|
||||
style=anchor_style()
|
||||
style=move || {
|
||||
let style = anchor_style.get();
|
||||
if style.trim().is_empty() {
|
||||
"top:24px;left:24px;".to_string()
|
||||
} else {
|
||||
style
|
||||
}
|
||||
}
|
||||
>
|
||||
<div class="slash-list">
|
||||
{move || {
|
||||
|
||||
@@ -1159,6 +1159,7 @@ fn App(mount_options: MountOptions) -> impl IntoView {
|
||||
let (slash_open, set_slash_open) = signal(false);
|
||||
let (slash_index, set_slash_index) = signal(0_usize);
|
||||
let (slash_query, set_slash_query) = signal(String::new());
|
||||
let (slash_anchor_style, set_slash_anchor_style) = signal(String::new());
|
||||
let (turn_into_open, set_turn_into_open) = signal(false);
|
||||
let (color_menu_open, set_color_menu_open) = signal(false);
|
||||
let (more_menu_open, set_more_menu_open) = signal(false);
|
||||
@@ -1782,6 +1783,7 @@ fn App(mount_options: MountOptions) -> impl IntoView {
|
||||
let set_slash_index = set_slash_index;
|
||||
let slash_query = slash_query;
|
||||
let set_slash_query = set_slash_query;
|
||||
let set_slash_anchor_style = set_slash_anchor_style;
|
||||
let turn_into_open = turn_into_open;
|
||||
let set_turn_into_open = set_turn_into_open;
|
||||
let color_menu_open = color_menu_open;
|
||||
@@ -2043,6 +2045,7 @@ fn App(mount_options: MountOptions) -> impl IntoView {
|
||||
|
||||
if event.key() == "/" && !event.ctrl_key() && !event.meta_key() && !event.alt_key() {
|
||||
event.prevent_default();
|
||||
let _ = set_slash_anchor_style.try_set(slash_menu_anchor_style());
|
||||
open_slash_menu_overlay(
|
||||
set_slash_open,
|
||||
set_slash_index,
|
||||
@@ -2132,6 +2135,36 @@ fn App(mount_options: MountOptions) -> impl IntoView {
|
||||
on_cleanup(move || drop(keydown_handle));
|
||||
}
|
||||
|
||||
{
|
||||
let set_slash_open = set_slash_open;
|
||||
let set_slash_index = set_slash_index;
|
||||
let set_slash_query = set_slash_query;
|
||||
let set_slash_anchor_style = set_slash_anchor_style;
|
||||
let outside_mousedown_handle =
|
||||
window_event_listener(ev::mousedown, move |event: MouseEvent| {
|
||||
let Some(element) = event.target().and_then(target_element) else {
|
||||
let _ = set_slash_open.try_set(false);
|
||||
let _ = set_slash_index.try_set(0);
|
||||
let _ = set_slash_query.try_set(String::new());
|
||||
let _ = set_slash_anchor_style.try_set(String::new());
|
||||
return;
|
||||
};
|
||||
if element
|
||||
.closest("[data-testid=\"mnote-leptos-tiptap-slash-menu\"]")
|
||||
.ok()
|
||||
.flatten()
|
||||
.is_some()
|
||||
{
|
||||
return;
|
||||
}
|
||||
let _ = set_slash_open.try_set(false);
|
||||
let _ = set_slash_index.try_set(0);
|
||||
let _ = set_slash_query.try_set(String::new());
|
||||
let _ = set_slash_anchor_style.try_set(String::new());
|
||||
});
|
||||
on_cleanup(move || drop(outside_mousedown_handle));
|
||||
}
|
||||
|
||||
{
|
||||
let click_handle = window_event_listener(ev::click, move |event: MouseEvent| {
|
||||
let Some(element) = event.target().and_then(target_element) else {
|
||||
@@ -2251,7 +2284,7 @@ fn App(mount_options: MountOptions) -> impl IntoView {
|
||||
command_feedback: set_command_feedback,
|
||||
},
|
||||
runtime: slash_menu_runtime,
|
||||
anchor_style: std::sync::Arc::new(slash_menu_anchor_style),
|
||||
anchor_style: slash_anchor_style,
|
||||
};
|
||||
|
||||
view! {
|
||||
|
||||
Reference in New Issue
Block a user