use std::cell::RefCell;
use std::rc::Rc;
pub trait ContentProvider {
fn get_content(&self) -> String;
}
impl ContentProvider
for Rc<RefCell<crate::richtext::structured_rich_display::StructuredRichDisplay>>
{
fn get_content(&self) -> String {
use crate::richtext::markdown_converter::document_to_markdown;
let disp = self.borrow();
let doc = disp.editor().document();
document_to_markdown(doc)
}
}
pub trait ContentLoader {
fn set_content_from_markdown(&mut self, markdown: &str);
}
impl ContentLoader for crate::richtext::structured_rich_display::StructuredRichDisplay {
fn set_content_from_markdown(&mut self, markdown: &str) {
use crate::richtext::markdown_converter::markdown_to_document;
let editor = self.editor_mut();
*editor.document_mut() = markdown_to_document(markdown);
editor.clear_selection();
self.set_scroll(0);
}
}