summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--library/src/graphics/image.rs4
-rw-r--r--library/src/graphics/shape.rs4
-rw-r--r--library/src/text/link.rs6
-rw-r--r--library/src/text/mod.rs3
-rw-r--r--library/src/text/shaping.rs2
5 files changed, 10 insertions, 9 deletions
diff --git a/library/src/graphics/image.rs b/library/src/graphics/image.rs
index 5524e1c0..12121257 100644
--- a/library/src/graphics/image.rs
+++ b/library/src/graphics/image.rs
@@ -3,7 +3,7 @@ use std::ffi::OsStr;
use typst::image::{Image, ImageFormat, RasterFormat, VectorFormat};
use crate::prelude::*;
-use crate::text::TextNode;
+use crate::text::LinkNode;
/// Show a raster or vector graphic.
#[derive(Debug, Hash)]
@@ -90,7 +90,7 @@ impl LayoutInline for ImageNode {
}
// Apply link if it exists.
- if let Some(url) = styles.get(TextNode::LINK) {
+ if let Some(url) = styles.get(LinkNode::DEST) {
frame.link(url.clone());
}
diff --git a/library/src/graphics/shape.rs b/library/src/graphics/shape.rs
index e336c3a3..d484b993 100644
--- a/library/src/graphics/shape.rs
+++ b/library/src/graphics/shape.rs
@@ -1,7 +1,7 @@
use std::f64::consts::SQRT_2;
use crate::prelude::*;
-use crate::text::TextNode;
+use crate::text::LinkNode;
/// A sizable and fillable shape with optional content.
#[derive(Debug, Hash)]
@@ -161,7 +161,7 @@ impl<const S: ShapeKind> LayoutInline for ShapeNode<S> {
}
// Apply link if it exists.
- if let Some(url) = styles.get(TextNode::LINK) {
+ if let Some(url) = styles.get(LinkNode::DEST) {
frame.link(url.clone());
}
diff --git a/library/src/text/link.rs b/library/src/text/link.rs
index 45e7c7ec..fd7aec8a 100644
--- a/library/src/text/link.rs
+++ b/library/src/text/link.rs
@@ -25,6 +25,10 @@ impl LinkNode {
#[node(Show, Finalize)]
impl LinkNode {
+ /// A destination the text should be linked to.
+ #[property(skip, referenced)]
+ pub(crate) const DEST: Option<Destination> = None;
+
fn construct(_: &mut Vm, args: &mut Args) -> SourceResult<Content> {
let dest = args.expect::<Destination>("destination")?;
Ok(match dest {
@@ -62,6 +66,6 @@ impl Finalize for LinkNode {
_: StyleChain,
realized: Content,
) -> SourceResult<Content> {
- Ok(realized.styled(TextNode::LINK, Some(self.dest.clone())))
+ Ok(realized.styled(Self::DEST, Some(self.dest.clone())))
}
}
diff --git a/library/src/text/mod.rs b/library/src/text/mod.rs
index a00510b6..c12a61cb 100644
--- a/library/src/text/mod.rs
+++ b/library/src/text/mod.rs
@@ -124,9 +124,6 @@ impl TextNode {
/// Whether small capital glyphs should be used. ("smcp")
#[property(skip)]
const SMALLCAPS: bool = false;
- /// A destination the text should be linked to.
- #[property(skip, referenced)]
- pub(crate) const LINK: Option<Destination> = None;
/// Decorative lines.
#[property(skip, fold)]
const DECO: Decoration = vec![];
diff --git a/library/src/text/shaping.rs b/library/src/text/shaping.rs
index ac7218a0..6ce4d671 100644
--- a/library/src/text/shaping.rs
+++ b/library/src/text/shaping.rs
@@ -92,7 +92,7 @@ impl<'a> ShapedText<'a> {
let lang = self.styles.get(TextNode::LANG);
let decos = self.styles.get(TextNode::DECO);
let fill = self.styles.get(TextNode::FILL);
- let link = self.styles.get(TextNode::LINK);
+ let link = self.styles.get(LinkNode::DEST);
for ((font, y_offset), group) in
self.glyphs.as_ref().group_by_key(|g| (g.font.clone(), g.y_offset))