feat: added captions, plain_text() method for RichText

fix: disabled certain properties that caused problems during parsing
This commit is contained in:
Bram Dingelstad 2025-03-15 22:16:17 +01:00
parent 43e5fc6005
commit c13ee32911

View file

@ -1114,7 +1114,7 @@ pub struct QueryResponse<T> {
pub has_more: Option<bool>, pub has_more: Option<bool>,
pub next_cursor: Option<String>, pub next_cursor: Option<String>,
pub results: Vec<T>, pub results: Vec<T>,
pub page_or_database: Value, // pub page_or_database: Value,
} }
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
@ -1501,6 +1501,19 @@ pub enum RichText {
Unsupported, Unsupported,
} }
impl RichText {
pub fn plain_text(&self) -> String {
use RichText::*;
match self {
Text { plain_text, .. } | Mention { plain_text, .. } | Equation { plain_text, .. } => {
plain_text
}
Unsupported => "",
}
.to_string()
}
}
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
pub struct Text { pub struct Text {
pub content: String, pub content: String,
@ -1687,6 +1700,7 @@ pub enum File {
}, },
External { External {
external: ExternalFile, external: ExternalFile,
caption: Option<Vec<RichText>>,
}, },
#[serde(other)] #[serde(other)]