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