Add Link support to rich_text widget
This commit is contained in:
parent
4b44079f34
commit
9bfaf2840c
9 changed files with 287 additions and 71 deletions
|
|
@ -8,3 +8,5 @@ publish = false
|
|||
[dependencies]
|
||||
iced.workspace = true
|
||||
iced.features = ["markdown", "highlighter", "debug"]
|
||||
|
||||
open = "5.3"
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ struct Markdown {
|
|||
#[derive(Debug, Clone)]
|
||||
enum Message {
|
||||
Edit(text_editor::Action),
|
||||
LinkClicked(String),
|
||||
}
|
||||
|
||||
impl Markdown {
|
||||
|
|
@ -50,6 +51,9 @@ impl Markdown {
|
|||
.collect();
|
||||
}
|
||||
}
|
||||
Message::LinkClicked(link) => {
|
||||
let _ = open::that(link);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +64,7 @@ impl Markdown {
|
|||
.padding(10)
|
||||
.font(Font::MONOSPACE);
|
||||
|
||||
let preview = markdown(&self.items);
|
||||
let preview = markdown(&self.items, Message::LinkClicked);
|
||||
|
||||
row![editor, scrollable(preview).spacing(10).height(Fill)]
|
||||
.spacing(10)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue