feat: integrate pi rust lab runtime
This commit is contained in:
@@ -1,7 +1,3 @@
|
||||
use crate::{
|
||||
current_page_anchor_url, editor_block_by_id, request_ai_edit_bridge,
|
||||
write_mnote_text_to_clipboard,
|
||||
};
|
||||
use crate::editor_runtime::{
|
||||
block_hover_state::{BlockMenuLayout, HoveredBlockState},
|
||||
block_transform::{
|
||||
@@ -17,6 +13,10 @@ use crate::editor_runtime::{
|
||||
persistence::{persist_document_state, persisted_document_identity, PersistedDocumentIdentity},
|
||||
slash_actions::{SlashActionKind, SLASH_ACTIONS},
|
||||
};
|
||||
use crate::{
|
||||
current_page_anchor_url, editor_block_by_id, request_ai_edit_bridge,
|
||||
write_mnote_text_to_clipboard,
|
||||
};
|
||||
use leptos::prelude::*;
|
||||
use leptos_tiptap::{TiptapEditorHandle, TiptapSelectionState, TiptapTextAlign};
|
||||
use serde_json::Value;
|
||||
@@ -132,10 +132,9 @@ fn handle_turn_into_action_click(
|
||||
&snapshot,
|
||||
Some(html),
|
||||
) {
|
||||
Ok(()) => signals.set_command_feedback.set(format!(
|
||||
"{}:块 -> {},并已写入本地草稿",
|
||||
message, label,
|
||||
)),
|
||||
Ok(()) => signals
|
||||
.set_command_feedback
|
||||
.set(format!("{}:块 -> {},并已写入本地草稿", message, label,)),
|
||||
Err(err) => signals.set_command_feedback.set(format!(
|
||||
"{}:块 -> {},但本地保存失败:{}",
|
||||
message, label, err,
|
||||
@@ -245,7 +244,7 @@ fn block_transform_submenu_view(
|
||||
handle_turn_into_action_click(editor, block_index, kind, label, signals);
|
||||
}
|
||||
>
|
||||
<span class="block-drag-menu-icon material-symbols-outlined">{icon}</span>
|
||||
<span class="block-drag-menu-icon material-symbols-outlined" data-icon=icon></span>
|
||||
<span>{label}</span>
|
||||
<span class="block-drag-menu-shortcut">{shortcut}</span>
|
||||
</button>
|
||||
@@ -331,7 +330,7 @@ fn block_transform_submenu_view(
|
||||
handle_folded_heading_click(editor, block_index, action, signals);
|
||||
}
|
||||
>
|
||||
<span class="block-drag-menu-icon material-symbols-outlined">{action.icon}</span>
|
||||
<span class="block-drag-menu-icon material-symbols-outlined" data-icon=action.icon></span>
|
||||
<span>{action.label}</span>
|
||||
</button>
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
//! Unified icon helpers — Material Symbols ligatures for all editor runtime icons.
|
||||
//!
|
||||
//! Every icon rendered in the leptos-tiptap editor shell should flow through
|
||||
//! `material_icon()` or consume `ICON_MAP` so that the set of Material Symbols
|
||||
//! ligatures stays centralised and we can swap font providers later.
|
||||
//! `material_icon()` or consume `ICON_MAP` so that icon names stay centralised
|
||||
//! and the host stylesheet can render local fallback masks without leaking
|
||||
//! Material Symbols ligature text.
|
||||
|
||||
use leptos::prelude::*;
|
||||
|
||||
/// Semantic name → Material Symbols ligature.
|
||||
/// Semantic name → icon identifier.
|
||||
///
|
||||
/// Keys are stable semantic identifiers; values are the literal text content
|
||||
/// that `material-symbols-outlined` will turn into a glyph via ligature.
|
||||
/// Keys are stable semantic identifiers; values are the `data-icon` identifier
|
||||
/// consumed by the host stylesheet.
|
||||
pub(crate) const ICON_MAP: &[(&str, &str)] = &[
|
||||
("heading_1", "looks_one"),
|
||||
("heading_2", "looks_two"),
|
||||
@@ -75,10 +76,10 @@ pub(crate) fn icon_ligature(name: &str) -> Option<&'static str> {
|
||||
|
||||
/// Render a `<span class="material-symbols-outlined">` icon.
|
||||
///
|
||||
/// The `name` parameter must be a Material Symbols ligature name
|
||||
/// The `name` parameter must be a known icon identifier
|
||||
/// (e.g. `"auto_awesome"`, `"chevron_right"`, `"looks_one"`).
|
||||
pub(crate) fn material_icon(name: &'static str) -> impl IntoView {
|
||||
view! {
|
||||
<span class="material-symbols-outlined" aria-hidden="true">{name}</span>
|
||||
<span class="material-symbols-outlined" data-icon=name aria-hidden="true"></span>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,12 +83,8 @@ fn render_slash_shortcut(shortcut: &str) -> impl IntoView {
|
||||
}
|
||||
}
|
||||
|
||||
fn filtered_slash_intro_view(
|
||||
query: &str,
|
||||
command_feedback: WriteSignal<String>,
|
||||
) -> impl IntoView {
|
||||
let show_turn_into = !query.is_empty()
|
||||
&& ("zhw".contains(query) || "转换为".contains(query));
|
||||
fn filtered_slash_intro_view(query: &str, command_feedback: WriteSignal<String>) -> impl IntoView {
|
||||
let show_turn_into = !query.is_empty() && ("zhw".contains(query) || "转换为".contains(query));
|
||||
let show_page = !query.is_empty() && ("ym".contains(query) || "页面".contains(query));
|
||||
|
||||
if show_turn_into || show_page {
|
||||
@@ -213,9 +209,7 @@ fn handle_slash_item_click(
|
||||
}
|
||||
Err(err) => {
|
||||
signals.set_slash_open.set(false);
|
||||
signals
|
||||
.command_feedback
|
||||
.set(format!("命令执行失败:{err}"));
|
||||
signals.command_feedback.set(format!("命令执行失败:{err}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -282,7 +276,7 @@ pub(crate) fn slash_menu_view(props: SlashMenuViewProps) -> impl IntoView {
|
||||
}
|
||||
>
|
||||
<span class="slash-item-row">
|
||||
<span class="slash-item-icon material-symbols-outlined">{icon}</span>
|
||||
<span class="slash-item-icon material-symbols-outlined" data-icon=icon></span>
|
||||
<span class="slash-item-copy">
|
||||
<strong>{label}</strong>
|
||||
<span>{description}</span>
|
||||
|
||||
Reference in New Issue
Block a user