finally another commit
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use egui::TextEdit;
|
||||
use egui::{TextEdit, text};
|
||||
use egui_commonmark::{CommonMarkCache, CommonMarkViewer};
|
||||
use serde::{self, Deserialize, Serialize};
|
||||
|
||||
use crate::{PROJECT_FOLDER, editors::tags::Tag, util};
|
||||
use crate::{PROJECT_FOLDER, editors::tags::Tag, llm_integration::content_llm::ai_enabled, util};
|
||||
|
||||
pub struct MainEditor {
|
||||
pub content: ContentSection,
|
||||
@@ -95,7 +95,7 @@ impl MainEditor {
|
||||
Self {
|
||||
content: ContentSection::new(),
|
||||
show_editor: false, // Start with editor hidden
|
||||
show_preview: true,
|
||||
show_preview: false,
|
||||
preview_cache: CommonMarkCache::default(),
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,7 @@ impl MainEditor {
|
||||
Self {
|
||||
content,
|
||||
show_editor: true,
|
||||
show_preview: true,
|
||||
show_preview: false,
|
||||
preview_cache: CommonMarkCache::default(),
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ impl MainEditor {
|
||||
}
|
||||
|
||||
fn editor_ui(&mut self, ui: &mut egui::Ui) {
|
||||
egui::ScrollArea::both()
|
||||
let response = egui::ScrollArea::both()
|
||||
.auto_shrink([false, false])
|
||||
.id_salt("editor_scroll")
|
||||
.show(ui, |ui| {
|
||||
@@ -290,14 +290,39 @@ impl MainEditor {
|
||||
.hint_text("Type here...")
|
||||
.desired_width(max_width as f32);
|
||||
|
||||
if ui
|
||||
let mut ctx_menu = false;
|
||||
let response = ui
|
||||
.add_sized(
|
||||
egui::vec2(max_width as f32 - 30.0, ui.available_height()),
|
||||
text_edit,
|
||||
)
|
||||
.changed()
|
||||
{
|
||||
self.content.saved = false;
|
||||
.on_hover_text("Right click to open context menu")
|
||||
.context_menu(|ui| {
|
||||
ctx_menu = true;
|
||||
|
||||
ui.menu_button("AI Actions", |ui| {
|
||||
ui.add_enabled_ui(ai_enabled(), |ui| {
|
||||
if ui.button("Summarise").clicked() {
|
||||
println!("Summarise");
|
||||
}
|
||||
|
||||
if ui.button("Continue").clicked() {
|
||||
let content = self.content.content.clone();
|
||||
let response =
|
||||
crate::llm_integration::content_llm::continue_content(
|
||||
&content, "", 1024,
|
||||
)
|
||||
.unwrap();
|
||||
self.content.content.push_str(&response);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
if let Some(response) = response {
|
||||
if response.response.changed() || ctx_menu {
|
||||
self.content.saved = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user