summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector@hecrj.dev>2024-07-21 17:18:53 +0200
committerLibravatar GitHub <noreply@github.com>2024-07-21 17:18:53 +0200
commit5443e4d8289873895587d856dbcf46f980bda6ab (patch)
tree4f0037c07349ba0f1ea3e3ace596d988d9c3d952 /examples
parent4b44079f34aa9e01977a7974e5f49ae79ff6cd90 (diff)
parenta2943798a3cf79e15344063fbf4ea8c84d261d6f (diff)
downloadiced-5443e4d8289873895587d856dbcf46f980bda6ab.tar.gz
iced-5443e4d8289873895587d856dbcf46f980bda6ab.tar.bz2
iced-5443e4d8289873895587d856dbcf46f980bda6ab.zip
Merge pull request #2512 from iced-rs/feature/rich-text-links
Add `Link` support to `rich_text` widget
Diffstat (limited to '')
-rw-r--r--examples/markdown/Cargo.toml2
-rw-r--r--examples/markdown/src/main.rs6
2 files changed, 7 insertions, 1 deletions
diff --git a/examples/markdown/Cargo.toml b/examples/markdown/Cargo.toml
index 9404d5d2..cb74b954 100644
--- a/examples/markdown/Cargo.toml
+++ b/examples/markdown/Cargo.toml
@@ -8,3 +8,5 @@ publish = false
[dependencies]
iced.workspace = true
iced.features = ["markdown", "highlighter", "debug"]
+
+open = "5.3"
diff --git a/examples/markdown/src/main.rs b/examples/markdown/src/main.rs
index 6b7adc12..ee5b5aab 100644
--- a/examples/markdown/src/main.rs
+++ b/examples/markdown/src/main.rs
@@ -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_in_background(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)