pub mod facet;
#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::value::Data;
use jacquard_derive::{IntoStatic, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
use crate::com_deckbelcher::richtext;
use crate::com_deckbelcher::richtext::facet::Facet;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct BulletListBlock<S: BosStr = DefaultStr> {
pub items: Vec<richtext::ListItem<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct CodeBlock<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub language: Option<S>,
pub text: S,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Document<S: BosStr = DefaultStr> {
pub content: Vec<DocumentContentItem<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum DocumentContentItem<S: BosStr = DefaultStr> {
#[serde(rename = "com.deckbelcher.richtext#paragraphBlock")]
ParagraphBlock(Box<richtext::ParagraphBlock<S>>),
#[serde(rename = "com.deckbelcher.richtext#headingBlock")]
HeadingBlock(Box<richtext::HeadingBlock<S>>),
#[serde(rename = "com.deckbelcher.richtext#codeBlock")]
CodeBlock(Box<richtext::CodeBlock<S>>),
#[serde(rename = "com.deckbelcher.richtext#bulletListBlock")]
BulletListBlock(Box<richtext::BulletListBlock<S>>),
#[serde(rename = "com.deckbelcher.richtext#orderedListBlock")]
OrderedListBlock(Box<richtext::OrderedListBlock<S>>),
#[serde(rename = "com.deckbelcher.richtext#horizontalRuleBlock")]
HorizontalRuleBlock(Box<richtext::HorizontalRuleBlock<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct HeadingBlock<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub facets: Option<Vec<Facet<S>>>,
pub level: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct HorizontalRuleBlock<S: BosStr = DefaultStr> {
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ListItem<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub facets: Option<Vec<Facet<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub sublist: Option<ListItemSublist<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum ListItemSublist<S: BosStr = DefaultStr> {
#[serde(rename = "com.deckbelcher.richtext#bulletListBlock")]
BulletListBlock(Box<richtext::BulletListBlock<S>>),
#[serde(rename = "com.deckbelcher.richtext#orderedListBlock")]
OrderedListBlock(Box<richtext::OrderedListBlock<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Richtext<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub facets: Option<Vec<Facet<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct OrderedListBlock<S: BosStr = DefaultStr> {
pub items: Vec<richtext::ListItem<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub start: Option<i64>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(
rename_all = "camelCase",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct ParagraphBlock<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub facets: Option<Vec<Facet<S>>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for BulletListBlock<S> {
fn nsid() -> &'static str {
"com.deckbelcher.richtext"
}
fn def_name() -> &'static str {
"bulletListBlock"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_deckbelcher_richtext()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for CodeBlock<S> {
fn nsid() -> &'static str {
"com.deckbelcher.richtext"
}
fn def_name() -> &'static str {
"codeBlock"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_deckbelcher_richtext()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.language {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 50usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("language"),
max: 50usize,
actual: <str>::len(value.as_ref()),
});
}
}
{
let value = &self.text;
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("text"),
max: 100000usize,
actual: <str>::len(value.as_ref()),
});
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Document<S> {
fn nsid() -> &'static str {
"com.deckbelcher.richtext"
}
fn def_name() -> &'static str {
"document"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_deckbelcher_richtext()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for HeadingBlock<S> {
fn nsid() -> &'static str {
"com.deckbelcher.richtext"
}
fn def_name() -> &'static str {
"headingBlock"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_deckbelcher_richtext()
}
fn validate(&self) -> Result<(), ConstraintError> {
{
let value = &self.level;
if *value > 6i64 {
return Err(ConstraintError::Maximum {
path: ValidationPath::from_field("level"),
max: 6i64,
actual: *value,
});
}
}
{
let value = &self.level;
if *value < 1i64 {
return Err(ConstraintError::Minimum {
path: ValidationPath::from_field("level"),
min: 1i64,
actual: *value,
});
}
}
if let Some(ref value) = self.text {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 10000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("text"),
max: 10000usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.text {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 1000usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("text"),
max: 1000usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for HorizontalRuleBlock<S> {
fn nsid() -> &'static str {
"com.deckbelcher.richtext"
}
fn def_name() -> &'static str {
"horizontalRuleBlock"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_deckbelcher_richtext()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for ListItem<S> {
fn nsid() -> &'static str {
"com.deckbelcher.richtext"
}
fn def_name() -> &'static str {
"listItem"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_deckbelcher_richtext()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.text {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 100000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("text"),
max: 100000usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.text {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 10000usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("text"),
max: 10000usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for Richtext<S> {
fn nsid() -> &'static str {
"com.deckbelcher.richtext"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_deckbelcher_richtext()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.text {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 500000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("text"),
max: 500000usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.text {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 50000usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("text"),
max: 50000usize,
actual: count,
});
}
}
}
Ok(())
}
}
impl<S: BosStr> LexiconSchema for OrderedListBlock<S> {
fn nsid() -> &'static str {
"com.deckbelcher.richtext"
}
fn def_name() -> &'static str {
"orderedListBlock"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_deckbelcher_richtext()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for ParagraphBlock<S> {
fn nsid() -> &'static str {
"com.deckbelcher.richtext"
}
fn def_name() -> &'static str {
"paragraphBlock"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_com_deckbelcher_richtext()
}
fn validate(&self) -> Result<(), ConstraintError> {
if let Some(ref value) = self.text {
#[allow(unused_comparisons)]
if <str>::len(value.as_ref()) > 500000usize {
return Err(ConstraintError::MaxLength {
path: ValidationPath::from_field("text"),
max: 500000usize,
actual: <str>::len(value.as_ref()),
});
}
}
if let Some(ref value) = self.text {
{
let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
if count > 50000usize {
return Err(ConstraintError::MaxGraphemes {
path: ValidationPath::from_field("text"),
max: 50000usize,
actual: count,
});
}
}
}
Ok(())
}
}
pub mod bullet_list_block_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Items;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Items = Unset;
}
pub struct SetItems<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetItems<St> {}
impl<St: State> State for SetItems<St> {
type Items = Set<members::items>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct items(());
}
}
pub struct BulletListBlockBuilder<S: BosStr, St: bullet_list_block_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<richtext::ListItem<S>>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> BulletListBlock<S> {
pub fn new() -> BulletListBlockBuilder<S, bullet_list_block_state::Empty> {
BulletListBlockBuilder::new()
}
}
impl<S: BosStr> BulletListBlockBuilder<S, bullet_list_block_state::Empty> {
pub fn new() -> Self {
BulletListBlockBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BulletListBlockBuilder<S, St>
where
St: bullet_list_block_state::State,
St::Items: bullet_list_block_state::IsUnset,
{
pub fn items(
mut self,
value: impl Into<Vec<richtext::ListItem<S>>>,
) -> BulletListBlockBuilder<S, bullet_list_block_state::SetItems<St>> {
self._fields.0 = Option::Some(value.into());
BulletListBlockBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> BulletListBlockBuilder<S, St>
where
St: bullet_list_block_state::State,
St::Items: bullet_list_block_state::IsSet,
{
pub fn build(self) -> BulletListBlock<S> {
BulletListBlock {
items: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> BulletListBlock<S> {
BulletListBlock {
items: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_com_deckbelcher_richtext() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("com.deckbelcher.richtext"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("bulletListBlock"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("An unordered (bullet) list.")),
required: Some(vec![SmolStr::new_static("items")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("items"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static("The list items.")),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#listItem"),
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("codeBlock"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"A code block with optional language hint.",
)),
required: Some(vec![SmolStr::new_static("text")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("language"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"Optional language identifier for syntax highlighting.",
)),
max_length: Some(50usize),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("text"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"The code content (plain text, no facets).",
)),
max_length: Some(100000usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("document"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"A multi-block rich text document.\nUsed for primers and other long-form content.",
),
),
required: Some(vec![SmolStr::new_static("content")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("content"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Array of blocks (paragraphs, headings, etc).",
),
),
items: LexArrayItem::Union(LexRefUnion {
refs: vec![
CowStr::new_static("#paragraphBlock"),
CowStr::new_static("#headingBlock"),
CowStr::new_static("#codeBlock"),
CowStr::new_static("#bulletListBlock"),
CowStr::new_static("#orderedListBlock"),
CowStr::new_static("#horizontalRuleBlock")
],
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("headingBlock"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"A heading block with level, text, and optional facets.",
)),
required: Some(vec![SmolStr::new_static("level")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("facets"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static(
"Annotations of text (formatting, mentions, links, etc).",
)),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("com.deckbelcher.richtext.facet"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("level"),
LexObjectProperty::Integer(LexInteger {
minimum: Some(1i64),
maximum: Some(6i64),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("text"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"The plain text content (no markdown symbols).",
)),
max_length: Some(10000usize),
max_graphemes: Some(1000usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("horizontalRuleBlock"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("A horizontal rule (thematic break).")),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("listItem"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"A single list item with text, optional facets, and optional sublist.",
)),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("facets"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static(
"Annotations of text (formatting, mentions, links, etc).",
)),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("com.deckbelcher.richtext.facet"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sublist"),
LexObjectProperty::Union(LexRefUnion {
description: Some(CowStr::new_static(
"Optional nested sublist (bullet or ordered).",
)),
refs: vec![
CowStr::new_static("#bulletListBlock"),
CowStr::new_static("#orderedListBlock"),
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("text"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"The plain text content (no markdown symbols).",
)),
max_length: Some(100000usize),
max_graphemes: Some(10000usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Object(LexObject {
description: Some(
CowStr::new_static(
"A single paragraph of rich text with optional facet annotations.\nUsed for descriptions and other short formatted text.",
),
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("facets"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Annotations of text (mentions, URLs, hashtags, formatting, etc).",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("com.deckbelcher.richtext.facet"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("text"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"The plain text content (no markdown symbols).",
),
),
max_length: Some(500000usize),
max_graphemes: Some(50000usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("orderedListBlock"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static("An ordered (numbered) list.")),
required: Some(vec![SmolStr::new_static("items")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("items"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static("The list items.")),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#listItem"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("start"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("paragraphBlock"),
LexUserType::Object(LexObject {
description: Some(CowStr::new_static(
"A paragraph block with text and optional facets.",
)),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("facets"),
LexObjectProperty::Array(LexArray {
description: Some(CowStr::new_static(
"Annotations of text (formatting, mentions, links, etc).",
)),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("com.deckbelcher.richtext.facet"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("text"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static(
"The plain text content (no markdown symbols).",
)),
max_length: Some(500000usize),
max_graphemes: Some(50000usize),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod document_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Content;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Content = Unset;
}
pub struct SetContent<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetContent<St> {}
impl<St: State> State for SetContent<St> {
type Content = Set<members::content>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct content(());
}
}
pub struct DocumentBuilder<S: BosStr, St: document_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<DocumentContentItem<S>>>,),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Document<S> {
pub fn new() -> DocumentBuilder<S, document_state::Empty> {
DocumentBuilder::new()
}
}
impl<S: BosStr> DocumentBuilder<S, document_state::Empty> {
pub fn new() -> Self {
DocumentBuilder {
_state: PhantomData,
_fields: (None,),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DocumentBuilder<S, St>
where
St: document_state::State,
St::Content: document_state::IsUnset,
{
pub fn content(
mut self,
value: impl Into<Vec<DocumentContentItem<S>>>,
) -> DocumentBuilder<S, document_state::SetContent<St>> {
self._fields.0 = Option::Some(value.into());
DocumentBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St> DocumentBuilder<S, St>
where
St: document_state::State,
St::Content: document_state::IsSet,
{
pub fn build(self) -> Document<S> {
Document {
content: self._fields.0.unwrap(),
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Document<S> {
Document {
content: self._fields.0.unwrap(),
extra_data: Some(extra_data),
}
}
}
pub mod heading_block_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Level;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Level = Unset;
}
pub struct SetLevel<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetLevel<St> {}
impl<St: State> State for SetLevel<St> {
type Level = Set<members::level>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct level(());
}
}
pub struct HeadingBlockBuilder<S: BosStr, St: heading_block_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<Facet<S>>>, Option<i64>, Option<S>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> HeadingBlock<S> {
pub fn new() -> HeadingBlockBuilder<S, heading_block_state::Empty> {
HeadingBlockBuilder::new()
}
}
impl<S: BosStr> HeadingBlockBuilder<S, heading_block_state::Empty> {
pub fn new() -> Self {
HeadingBlockBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: heading_block_state::State> HeadingBlockBuilder<S, St> {
pub fn facets(mut self, value: impl Into<Option<Vec<Facet<S>>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_facets(mut self, value: Option<Vec<Facet<S>>>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> HeadingBlockBuilder<S, St>
where
St: heading_block_state::State,
St::Level: heading_block_state::IsUnset,
{
pub fn level(
mut self,
value: impl Into<i64>,
) -> HeadingBlockBuilder<S, heading_block_state::SetLevel<St>> {
self._fields.1 = Option::Some(value.into());
HeadingBlockBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: heading_block_state::State> HeadingBlockBuilder<S, St> {
pub fn text(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_text(mut self, value: Option<S>) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> HeadingBlockBuilder<S, St>
where
St: heading_block_state::State,
St::Level: heading_block_state::IsSet,
{
pub fn build(self) -> HeadingBlock<S> {
HeadingBlock {
facets: self._fields.0,
level: self._fields.1.unwrap(),
text: self._fields.2,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> HeadingBlock<S> {
HeadingBlock {
facets: self._fields.0,
level: self._fields.1.unwrap(),
text: self._fields.2,
extra_data: Some(extra_data),
}
}
}
pub mod ordered_list_block_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Items;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Items = Unset;
}
pub struct SetItems<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetItems<St> {}
impl<St: State> State for SetItems<St> {
type Items = Set<members::items>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct items(());
}
}
pub struct OrderedListBlockBuilder<S: BosStr, St: ordered_list_block_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<richtext::ListItem<S>>>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> OrderedListBlock<S> {
pub fn new() -> OrderedListBlockBuilder<S, ordered_list_block_state::Empty> {
OrderedListBlockBuilder::new()
}
}
impl<S: BosStr> OrderedListBlockBuilder<S, ordered_list_block_state::Empty> {
pub fn new() -> Self {
OrderedListBlockBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> OrderedListBlockBuilder<S, St>
where
St: ordered_list_block_state::State,
St::Items: ordered_list_block_state::IsUnset,
{
pub fn items(
mut self,
value: impl Into<Vec<richtext::ListItem<S>>>,
) -> OrderedListBlockBuilder<S, ordered_list_block_state::SetItems<St>> {
self._fields.0 = Option::Some(value.into());
OrderedListBlockBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: ordered_list_block_state::State> OrderedListBlockBuilder<S, St> {
pub fn start(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_start(mut self, value: Option<i64>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> OrderedListBlockBuilder<S, St>
where
St: ordered_list_block_state::State,
St::Items: ordered_list_block_state::IsSet,
{
pub fn build(self) -> OrderedListBlock<S> {
OrderedListBlock {
items: self._fields.0.unwrap(),
start: self._fields.1,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> OrderedListBlock<S> {
OrderedListBlock {
items: self._fields.0.unwrap(),
start: self._fields.1,
extra_data: Some(extra_data),
}
}
}