refactor: clean editor runtime warnings

This commit is contained in:
lix-2026
2026-05-25 20:17:20 +08:00
parent 4537b1a3d6
commit f8decfebd6
8 changed files with 39 additions and 71 deletions
@@ -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)]