//! Text editor: an editable CodeMirror with save, a dirty-state indicator,
//! Ctrl/Cmd+S, and save-time conflict handling (the file changed on disk
//! since it was opened).
//!
//! The editor fills the whole content area; its title, Save button and close
//! action live in the top bar (see `views::file_view`). The editor
//! registers its save callback via `register_save` and reports its
//! dirty/saving state through the shared signals.
use leptos::prelude::*;
use wasm_bindgen::closure::Closure;
use wasm_bindgen::{JsCast, JsValue};
use wasm_bindgen_futures::spawn_local;
use crate::api::{self, ApiError};
use crate::cm;
use crate::components::icon::icon_svg;
use crate::components::modal::Modal;
use crate::components::toast::{ToastMsg, show};
use crate::i18n;
use crate::icons::IconName;
use crate::views::dialogs::ConfirmDialog;
use crate::views::file_view::FileView;
/// The full-page editor (no window chrome: the top bar carries the title,
/// save and close).
#[component]
pub fn Editor(
target: FileView,
/// The editor stores its save callback here (top-bar Save button);
/// cleared on unmount. Absent in read-only mode.
register_save: WriteSignal