jacquard_api/pub_leaflet/blocks/
text.rs1use jacquard_common::CowStr;
9
10#[allow(unused_imports)]
11use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
12use jacquard_derive::{IntoStatic, lexicon};
13use jacquard_lexicon::lexicon::LexiconDoc;
14use jacquard_lexicon::schema::LexiconSchema;
15
16#[allow(unused_imports)]
17use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
18use serde::{Serialize, Deserialize};
19use crate::pub_leaflet::richtext::facet::Facet;
20
21#[lexicon]
22#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
23#[serde(rename_all = "camelCase")]
24pub struct Text<'a> {
25 #[serde(skip_serializing_if = "Option::is_none")]
26 #[serde(borrow)]
27 pub facets: Option<Vec<Facet<'a>>>,
28 #[serde(borrow)]
29 pub plaintext: CowStr<'a>,
30 #[serde(skip_serializing_if = "Option::is_none")]
31 #[serde(borrow)]
32 pub text_size: Option<CowStr<'a>>,
33}
34
35impl<'a> LexiconSchema for Text<'a> {
36 fn nsid() -> &'static str {
37 "pub.leaflet.blocks.text"
38 }
39 fn def_name() -> &'static str {
40 "main"
41 }
42 fn lexicon_doc() -> LexiconDoc<'static> {
43 lexicon_doc_pub_leaflet_blocks_text()
44 }
45 fn validate(&self) -> Result<(), ConstraintError> {
46 Ok(())
47 }
48}
49
50fn lexicon_doc_pub_leaflet_blocks_text() -> LexiconDoc<'static> {
51 #[allow(unused_imports)]
52 use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
53 use jacquard_lexicon::lexicon::*;
54 use alloc::collections::BTreeMap;
55 LexiconDoc {
56 lexicon: Lexicon::Lexicon1,
57 id: CowStr::new_static("pub.leaflet.blocks.text"),
58 defs: {
59 let mut map = BTreeMap::new();
60 map.insert(
61 SmolStr::new_static("main"),
62 LexUserType::Object(LexObject {
63 required: Some(vec![SmolStr::new_static("plaintext")]),
64 properties: {
65 #[allow(unused_mut)]
66 let mut map = BTreeMap::new();
67 map.insert(
68 SmolStr::new_static("facets"),
69 LexObjectProperty::Array(LexArray {
70 items: LexArrayItem::Ref(LexRef {
71 r#ref: CowStr::new_static("pub.leaflet.richtext.facet"),
72 ..Default::default()
73 }),
74 ..Default::default()
75 }),
76 );
77 map.insert(
78 SmolStr::new_static("plaintext"),
79 LexObjectProperty::String(LexString { ..Default::default() }),
80 );
81 map.insert(
82 SmolStr::new_static("textSize"),
83 LexObjectProperty::String(LexString { ..Default::default() }),
84 );
85 map
86 },
87 ..Default::default()
88 }),
89 );
90 map
91 },
92 ..Default::default()
93 }
94}