refactor: clean editor runtime warnings
This commit is contained in:
BIN
Binary file not shown.
@@ -110,6 +110,7 @@ pub(crate) struct HeightPayload {
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[allow(dead_code)]
|
||||
pub(crate) struct HostCommandEnvelope {
|
||||
pub(crate) protocol: Option<String>,
|
||||
pub(crate) runtime: Option<String>,
|
||||
@@ -131,6 +132,7 @@ pub(crate) struct RuntimePageOptions {
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[allow(dead_code)]
|
||||
pub(crate) struct HostCommandPayload {
|
||||
pub(crate) command: Option<String>,
|
||||
pub(crate) document_id: Option<String>,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::editor_runtime::persistence::{persist_document_state, PersistedDocumentIdentity};
|
||||
use leptos::prelude::{GetUntracked, ReadSignal, Set, Update, WriteSignal};
|
||||
use leptos_tiptap::{TiptapContent, TiptapEditorHandle};
|
||||
use leptos_tiptap::TiptapEditorHandle;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
pub(crate) fn read_editor_snapshot(editor: TiptapEditorHandle) -> (String, Value, String) {
|
||||
@@ -31,45 +31,6 @@ pub(crate) fn sync_editor_outputs(
|
||||
json_value
|
||||
}
|
||||
|
||||
pub(crate) fn apply_document_update(
|
||||
editor: TiptapEditorHandle,
|
||||
persisted_identity: &PersistedDocumentIdentity,
|
||||
next_document: Value,
|
||||
set_dirty_count: WriteSignal<u32>,
|
||||
set_html_output: WriteSignal<String>,
|
||||
set_document_json: WriteSignal<Value>,
|
||||
set_json_output: WriteSignal<String>,
|
||||
title: ReadSignal<String>,
|
||||
set_command_feedback: WriteSignal<String>,
|
||||
success_message: impl Into<String>,
|
||||
) {
|
||||
let success_message = success_message.into();
|
||||
let next_payload = next_document
|
||||
.get("content")
|
||||
.and_then(Value::as_array)
|
||||
.cloned()
|
||||
.map(Value::Array)
|
||||
.unwrap_or_else(|| next_document.clone());
|
||||
match editor.set_content(TiptapContent::json(next_payload)) {
|
||||
Ok(()) => {
|
||||
persist_current_editor_snapshot(
|
||||
editor,
|
||||
persisted_identity,
|
||||
set_dirty_count,
|
||||
set_html_output,
|
||||
set_document_json,
|
||||
set_json_output,
|
||||
title,
|
||||
set_command_feedback,
|
||||
success_message,
|
||||
);
|
||||
}
|
||||
Err(err) => {
|
||||
set_command_feedback.set(format!("更新文档失败:{err}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn sync_persisted_editor_command(
|
||||
editor: TiptapEditorHandle,
|
||||
persisted_identity: &PersistedDocumentIdentity,
|
||||
|
||||
@@ -128,16 +128,6 @@ pub(crate) fn selection_summary(selection: &TiptapSelectionState) -> String {
|
||||
format!("当前块:{block} | 行内样式:{mark_text}")
|
||||
}
|
||||
|
||||
pub(crate) fn selection_has_rich_marks(selection: &TiptapSelectionState) -> bool {
|
||||
selection.bold
|
||||
|| selection.italic
|
||||
|| selection.underline
|
||||
|| selection.strike
|
||||
|| selection.highlight
|
||||
|| selection.text_style
|
||||
|| selection.link
|
||||
}
|
||||
|
||||
pub(crate) fn block_id_from_element(block: &Element) -> Option<String> {
|
||||
block
|
||||
.get_attribute("data-block-id")
|
||||
|
||||
@@ -32,6 +32,8 @@ pub(crate) const MINDMAP_SHELL_MINIMAP_EVENT: &str = "mnote:mindmap-shell:minima
|
||||
pub(crate) const MINDMAP_SHELL_ZOOM_EVENT: &str = "mnote:mindmap-shell:zoom";
|
||||
pub(crate) const MINDMAP_SHELL_TOOLBAR_OVERFLOW_EVENT: &str = "mnote:mindmap-shell:toolbar-overflow";
|
||||
pub(crate) struct MountedMindmapShell {
|
||||
// 保留 Leptos mount handle,避免 mindmap shell 被提前释放。
|
||||
#[allow(dead_code)]
|
||||
mount_handle: Box<dyn Any>,
|
||||
}
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
|
||||
@@ -5,9 +5,8 @@ use leptos_dom::helpers::window_event_listener;
|
||||
use leptos_tiptap::{
|
||||
TiptapCodeBlockAttributes, TiptapColorAttributes, TiptapContent, TiptapEditor,
|
||||
TiptapEditorHandle, TiptapExtension, TiptapHeadingLevel, TiptapHighlightAttributes,
|
||||
TiptapImageResource, TiptapInsertContentOptions, TiptapLinkResource, TiptapMarkName,
|
||||
TiptapNodeName, TiptapRange, TiptapSchemaTarget, TiptapSelectionState, TiptapTextAlign,
|
||||
TiptapTocNodeAttrs,
|
||||
TiptapInsertContentOptions, TiptapLinkResource, TiptapMarkName, TiptapNodeName, TiptapRange,
|
||||
TiptapSchemaTarget, TiptapSelectionState, TiptapTextAlign, TiptapTocNodeAttrs,
|
||||
};
|
||||
use send_wrapper::SendWrapper;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -62,9 +61,9 @@ use editor_runtime::overlays::{
|
||||
close_editor_floating_overlays_if_escape, current_table_overlay_anchor,
|
||||
image_element_from_target, image_toolbar_anchor_from_image, open_block_menu_overlay,
|
||||
open_image_toolbar_overlay, open_slash_menu_overlay, selection_bounding_rect,
|
||||
sync_overlays_on_selection_change, table_col_aux_style, table_overlay_anchor_from_table,
|
||||
table_row_aux_style, table_selection_overlay_style, toolbar_overlay_locked,
|
||||
try_sync_editor_overlay_state, FloatingToolbarAnchor, ImageToolbarAnchor,
|
||||
should_auto_close_toolbar_overlays, sync_overlays_on_selection_change, table_col_aux_style,
|
||||
table_overlay_anchor_from_table, table_row_aux_style, table_selection_overlay_style,
|
||||
toolbar_overlay_locked, try_sync_editor_overlay_state, FloatingToolbarAnchor, ImageToolbarAnchor,
|
||||
TableOverlayAnchor, TableSelectionKind, TableSelectionOverlayState,
|
||||
};
|
||||
use editor_runtime::persistence::{
|
||||
@@ -2792,6 +2791,7 @@ const FOLDED_HEADING_ACTIONS: [FoldedHeadingAction; 4] = [
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[allow(dead_code)]
|
||||
struct LegacyHostEnvelope {
|
||||
protocol: Option<String>,
|
||||
runtime: Option<String>,
|
||||
@@ -2977,6 +2977,7 @@ struct RuntimeMountContext {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[allow(dead_code)]
|
||||
struct RuntimeMountOptions {
|
||||
options: MountOptions,
|
||||
mode: RuntimeDeliveryMode,
|
||||
@@ -2989,6 +2990,8 @@ struct MountedRuntimeListener {
|
||||
|
||||
struct MountedRuntime {
|
||||
listeners: Vec<MountedRuntimeListener>,
|
||||
// 保留 Leptos mount handle,避免挂载内容被提前释放。
|
||||
#[allow(dead_code)]
|
||||
mount_handle: Box<dyn Any>,
|
||||
}
|
||||
|
||||
@@ -5053,7 +5056,6 @@ fn App(mount_options: MountOptions) -> impl IntoView {
|
||||
// ── Block-delta listener(Phase B:AI 写入增量通道) ──
|
||||
let delta_editor = editor;
|
||||
let delta_set_document_json = set_document_json;
|
||||
let delta_json_output = json_output;
|
||||
let delta_set_json_output = set_json_output;
|
||||
let delta_set_dirty_count = set_dirty_count;
|
||||
let delta_set_html_output = set_html_output;
|
||||
@@ -5134,15 +5136,15 @@ fn App(mount_options: MountOptions) -> impl IntoView {
|
||||
let set_color_menu_open = set_color_menu_open;
|
||||
let set_more_menu_open = set_more_menu_open;
|
||||
Effect::new(move |_| {
|
||||
let toolbar_locked = toolbar_overlay_locked(
|
||||
if should_auto_close_toolbar_overlays(
|
||||
editor_focused.get(),
|
||||
text_selection_active.get(),
|
||||
turn_into_open.get_untracked(),
|
||||
color_menu_open.get_untracked(),
|
||||
more_menu_open.get_untracked(),
|
||||
);
|
||||
if ((!editor_focused.get() || !text_selection_active.get()) && !toolbar_locked)
|
||||
|| slash_open.get()
|
||||
|| block_menu_open.get()
|
||||
{
|
||||
slash_open.get(),
|
||||
block_menu_open.get(),
|
||||
) {
|
||||
set_turn_into_open.set(false);
|
||||
set_color_menu_open.set(false);
|
||||
set_more_menu_open.set(false);
|
||||
@@ -6489,9 +6491,15 @@ fn App(mount_options: MountOptions) -> impl IntoView {
|
||||
floating_toolbar_anchor.get()
|
||||
};
|
||||
if let Some(anchor) = toolbar_anchor {
|
||||
if ((!editor_focused.get() || !text_selection_active.get()) && !toolbar_locked)
|
||||
|| slash_open.get()
|
||||
|| block_menu_open.get()
|
||||
if should_auto_close_toolbar_overlays(
|
||||
editor_focused.get(),
|
||||
text_selection_active.get(),
|
||||
turn_into_open.get(),
|
||||
color_menu_open.get(),
|
||||
more_menu_open.get(),
|
||||
slash_open.get(),
|
||||
block_menu_open.get(),
|
||||
)
|
||||
|| dragging_block_index.get().is_some()
|
||||
{
|
||||
return ().into_any();
|
||||
|
||||
Reference in New Issue
Block a user