pub use common::entities::Alignment;
use common::entities::Block;
pub use common::entities::MarkerType;
pub use common::entities::TextDirection;
use common::types::EntityId;
use serde::{Deserialize, Serialize};
use std::convert::From;
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct BlockDto {
pub id: EntityId,
pub created_at: chrono::DateTime<chrono::Utc>,
pub updated_at: chrono::DateTime<chrono::Utc>,
pub elements: Vec<EntityId>,
pub list: Option<EntityId>,
pub text_length: i64,
pub document_position: i64,
pub plain_text: String,
pub fmt_alignment: Option<Alignment>,
pub fmt_top_margin: Option<i64>,
pub fmt_bottom_margin: Option<i64>,
pub fmt_left_margin: Option<i64>,
pub fmt_right_margin: Option<i64>,
pub fmt_heading_level: Option<i64>,
pub fmt_indent: Option<i64>,
pub fmt_text_indent: Option<i64>,
pub fmt_marker: Option<MarkerType>,
pub fmt_tab_positions: Vec<i64>,
pub fmt_line_height: Option<i64>,
pub fmt_non_breakable_lines: Option<bool>,
pub fmt_direction: Option<TextDirection>,
pub fmt_background_color: Option<String>,
pub fmt_is_code_block: Option<bool>,
pub fmt_code_language: Option<String>,
}
impl From<BlockDto> for Block {
fn from(dto: BlockDto) -> Self {
Block {
id: dto.id,
created_at: dto.created_at,
updated_at: dto.updated_at,
elements: dto.elements,
list: dto.list,
text_length: dto.text_length,
document_position: dto.document_position,
plain_text: dto.plain_text,
fmt_alignment: dto.fmt_alignment,
fmt_top_margin: dto.fmt_top_margin,
fmt_bottom_margin: dto.fmt_bottom_margin,
fmt_left_margin: dto.fmt_left_margin,
fmt_right_margin: dto.fmt_right_margin,
fmt_heading_level: dto.fmt_heading_level,
fmt_indent: dto.fmt_indent,
fmt_text_indent: dto.fmt_text_indent,
fmt_marker: dto.fmt_marker,
fmt_tab_positions: dto.fmt_tab_positions,
fmt_line_height: dto.fmt_line_height,
fmt_non_breakable_lines: dto.fmt_non_breakable_lines,
fmt_direction: dto.fmt_direction,
fmt_background_color: dto.fmt_background_color,
fmt_is_code_block: dto.fmt_is_code_block,
fmt_code_language: dto.fmt_code_language,
}
}
}
impl From<&BlockDto> for Block {
fn from(dto: &BlockDto) -> Self {
Block {
id: dto.id,
created_at: dto.created_at,
updated_at: dto.updated_at,
elements: dto.elements.clone(),
list: dto.list,
text_length: dto.text_length,
document_position: dto.document_position,
plain_text: dto.plain_text.clone(),
fmt_alignment: dto.fmt_alignment.clone(),
fmt_top_margin: dto.fmt_top_margin,
fmt_bottom_margin: dto.fmt_bottom_margin,
fmt_left_margin: dto.fmt_left_margin,
fmt_right_margin: dto.fmt_right_margin,
fmt_heading_level: dto.fmt_heading_level,
fmt_indent: dto.fmt_indent,
fmt_text_indent: dto.fmt_text_indent,
fmt_marker: dto.fmt_marker.clone(),
fmt_tab_positions: dto.fmt_tab_positions.clone(),
fmt_line_height: dto.fmt_line_height,
fmt_non_breakable_lines: dto.fmt_non_breakable_lines,
fmt_direction: dto.fmt_direction.clone(),
fmt_background_color: dto.fmt_background_color.clone(),
fmt_is_code_block: dto.fmt_is_code_block,
fmt_code_language: dto.fmt_code_language.clone(),
}
}
}
impl From<Block> for BlockDto {
fn from(entity: Block) -> Self {
BlockDto {
id: entity.id,
created_at: entity.created_at,
updated_at: entity.updated_at,
elements: entity.elements,
list: entity.list,
text_length: entity.text_length,
document_position: entity.document_position,
plain_text: entity.plain_text,
fmt_alignment: entity.fmt_alignment,
fmt_top_margin: entity.fmt_top_margin,
fmt_bottom_margin: entity.fmt_bottom_margin,
fmt_left_margin: entity.fmt_left_margin,
fmt_right_margin: entity.fmt_right_margin,
fmt_heading_level: entity.fmt_heading_level,
fmt_indent: entity.fmt_indent,
fmt_text_indent: entity.fmt_text_indent,
fmt_marker: entity.fmt_marker,
fmt_tab_positions: entity.fmt_tab_positions,
fmt_line_height: entity.fmt_line_height,
fmt_non_breakable_lines: entity.fmt_non_breakable_lines,
fmt_direction: entity.fmt_direction,
fmt_background_color: entity.fmt_background_color,
fmt_is_code_block: entity.fmt_is_code_block,
fmt_code_language: entity.fmt_code_language,
}
}
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct CreateBlockDto {
pub created_at: chrono::DateTime<chrono::Utc>,
pub updated_at: chrono::DateTime<chrono::Utc>,
pub elements: Vec<EntityId>,
pub list: Option<EntityId>,
pub text_length: i64,
pub document_position: i64,
pub plain_text: String,
pub fmt_alignment: Option<Alignment>,
pub fmt_top_margin: Option<i64>,
pub fmt_bottom_margin: Option<i64>,
pub fmt_left_margin: Option<i64>,
pub fmt_right_margin: Option<i64>,
pub fmt_heading_level: Option<i64>,
pub fmt_indent: Option<i64>,
pub fmt_text_indent: Option<i64>,
pub fmt_marker: Option<MarkerType>,
pub fmt_tab_positions: Vec<i64>,
pub fmt_line_height: Option<i64>,
pub fmt_non_breakable_lines: Option<bool>,
pub fmt_direction: Option<TextDirection>,
pub fmt_background_color: Option<String>,
pub fmt_is_code_block: Option<bool>,
pub fmt_code_language: Option<String>,
}
impl From<CreateBlockDto> for Block {
fn from(dto: CreateBlockDto) -> Self {
Block {
id: 0,
created_at: dto.created_at,
updated_at: dto.updated_at,
elements: dto.elements,
list: dto.list,
text_length: dto.text_length,
document_position: dto.document_position,
plain_text: dto.plain_text,
fmt_alignment: dto.fmt_alignment,
fmt_top_margin: dto.fmt_top_margin,
fmt_bottom_margin: dto.fmt_bottom_margin,
fmt_left_margin: dto.fmt_left_margin,
fmt_right_margin: dto.fmt_right_margin,
fmt_heading_level: dto.fmt_heading_level,
fmt_indent: dto.fmt_indent,
fmt_text_indent: dto.fmt_text_indent,
fmt_marker: dto.fmt_marker,
fmt_tab_positions: dto.fmt_tab_positions,
fmt_line_height: dto.fmt_line_height,
fmt_non_breakable_lines: dto.fmt_non_breakable_lines,
fmt_direction: dto.fmt_direction,
fmt_background_color: dto.fmt_background_color,
fmt_is_code_block: dto.fmt_is_code_block,
fmt_code_language: dto.fmt_code_language,
}
}
}
impl From<&CreateBlockDto> for Block {
fn from(dto: &CreateBlockDto) -> Self {
Block {
id: 0,
created_at: dto.created_at,
updated_at: dto.updated_at,
elements: dto.elements.clone(),
list: dto.list,
text_length: dto.text_length,
document_position: dto.document_position,
plain_text: dto.plain_text.clone(),
fmt_alignment: dto.fmt_alignment.clone(),
fmt_top_margin: dto.fmt_top_margin,
fmt_bottom_margin: dto.fmt_bottom_margin,
fmt_left_margin: dto.fmt_left_margin,
fmt_right_margin: dto.fmt_right_margin,
fmt_heading_level: dto.fmt_heading_level,
fmt_indent: dto.fmt_indent,
fmt_text_indent: dto.fmt_text_indent,
fmt_marker: dto.fmt_marker.clone(),
fmt_tab_positions: dto.fmt_tab_positions.clone(),
fmt_line_height: dto.fmt_line_height,
fmt_non_breakable_lines: dto.fmt_non_breakable_lines,
fmt_direction: dto.fmt_direction.clone(),
fmt_background_color: dto.fmt_background_color.clone(),
fmt_is_code_block: dto.fmt_is_code_block,
fmt_code_language: dto.fmt_code_language.clone(),
}
}
}
impl From<Block> for CreateBlockDto {
fn from(entity: Block) -> Self {
CreateBlockDto {
created_at: entity.created_at,
updated_at: entity.updated_at,
elements: entity.elements,
list: entity.list,
text_length: entity.text_length,
document_position: entity.document_position,
plain_text: entity.plain_text,
fmt_alignment: entity.fmt_alignment,
fmt_top_margin: entity.fmt_top_margin,
fmt_bottom_margin: entity.fmt_bottom_margin,
fmt_left_margin: entity.fmt_left_margin,
fmt_right_margin: entity.fmt_right_margin,
fmt_heading_level: entity.fmt_heading_level,
fmt_indent: entity.fmt_indent,
fmt_text_indent: entity.fmt_text_indent,
fmt_marker: entity.fmt_marker,
fmt_tab_positions: entity.fmt_tab_positions,
fmt_line_height: entity.fmt_line_height,
fmt_non_breakable_lines: entity.fmt_non_breakable_lines,
fmt_direction: entity.fmt_direction,
fmt_background_color: entity.fmt_background_color,
fmt_is_code_block: entity.fmt_is_code_block,
fmt_code_language: entity.fmt_code_language,
}
}
}
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub struct UpdateBlockDto {
pub id: EntityId,
pub created_at: chrono::DateTime<chrono::Utc>,
pub updated_at: chrono::DateTime<chrono::Utc>,
pub text_length: i64,
pub document_position: i64,
pub plain_text: String,
pub fmt_alignment: Option<Alignment>,
pub fmt_top_margin: Option<i64>,
pub fmt_bottom_margin: Option<i64>,
pub fmt_left_margin: Option<i64>,
pub fmt_right_margin: Option<i64>,
pub fmt_heading_level: Option<i64>,
pub fmt_indent: Option<i64>,
pub fmt_text_indent: Option<i64>,
pub fmt_marker: Option<MarkerType>,
pub fmt_tab_positions: Vec<i64>,
pub fmt_line_height: Option<i64>,
pub fmt_non_breakable_lines: Option<bool>,
pub fmt_direction: Option<TextDirection>,
pub fmt_background_color: Option<String>,
pub fmt_is_code_block: Option<bool>,
pub fmt_code_language: Option<String>,
}
impl From<UpdateBlockDto> for Block {
fn from(dto: UpdateBlockDto) -> Self {
Block {
id: dto.id,
created_at: dto.created_at,
updated_at: dto.updated_at,
text_length: dto.text_length,
document_position: dto.document_position,
plain_text: dto.plain_text,
fmt_alignment: dto.fmt_alignment,
fmt_top_margin: dto.fmt_top_margin,
fmt_bottom_margin: dto.fmt_bottom_margin,
fmt_left_margin: dto.fmt_left_margin,
fmt_right_margin: dto.fmt_right_margin,
fmt_heading_level: dto.fmt_heading_level,
fmt_indent: dto.fmt_indent,
fmt_text_indent: dto.fmt_text_indent,
fmt_marker: dto.fmt_marker,
fmt_tab_positions: dto.fmt_tab_positions,
fmt_line_height: dto.fmt_line_height,
fmt_non_breakable_lines: dto.fmt_non_breakable_lines,
fmt_direction: dto.fmt_direction,
fmt_background_color: dto.fmt_background_color,
fmt_is_code_block: dto.fmt_is_code_block,
fmt_code_language: dto.fmt_code_language,
elements: Default::default(),
list: Default::default(),
}
}
}
impl From<&UpdateBlockDto> for Block {
fn from(dto: &UpdateBlockDto) -> Self {
Block {
id: dto.id,
created_at: dto.created_at,
updated_at: dto.updated_at,
text_length: dto.text_length,
document_position: dto.document_position,
plain_text: dto.plain_text.clone(),
fmt_alignment: dto.fmt_alignment.clone(),
fmt_top_margin: dto.fmt_top_margin,
fmt_bottom_margin: dto.fmt_bottom_margin,
fmt_left_margin: dto.fmt_left_margin,
fmt_right_margin: dto.fmt_right_margin,
fmt_heading_level: dto.fmt_heading_level,
fmt_indent: dto.fmt_indent,
fmt_text_indent: dto.fmt_text_indent,
fmt_marker: dto.fmt_marker.clone(),
fmt_tab_positions: dto.fmt_tab_positions.clone(),
fmt_line_height: dto.fmt_line_height,
fmt_non_breakable_lines: dto.fmt_non_breakable_lines,
fmt_direction: dto.fmt_direction.clone(),
fmt_background_color: dto.fmt_background_color.clone(),
fmt_is_code_block: dto.fmt_is_code_block,
fmt_code_language: dto.fmt_code_language.clone(),
elements: Default::default(),
list: Default::default(),
}
}
}
impl From<Block> for UpdateBlockDto {
fn from(entity: Block) -> Self {
UpdateBlockDto {
id: entity.id,
created_at: entity.created_at,
updated_at: entity.updated_at,
text_length: entity.text_length,
document_position: entity.document_position,
plain_text: entity.plain_text,
fmt_alignment: entity.fmt_alignment,
fmt_top_margin: entity.fmt_top_margin,
fmt_bottom_margin: entity.fmt_bottom_margin,
fmt_left_margin: entity.fmt_left_margin,
fmt_right_margin: entity.fmt_right_margin,
fmt_heading_level: entity.fmt_heading_level,
fmt_indent: entity.fmt_indent,
fmt_text_indent: entity.fmt_text_indent,
fmt_marker: entity.fmt_marker,
fmt_tab_positions: entity.fmt_tab_positions,
fmt_line_height: entity.fmt_line_height,
fmt_non_breakable_lines: entity.fmt_non_breakable_lines,
fmt_direction: entity.fmt_direction,
fmt_background_color: entity.fmt_background_color,
fmt_is_code_block: entity.fmt_is_code_block,
fmt_code_language: entity.fmt_code_language,
}
}
}
impl From<BlockDto> for UpdateBlockDto {
fn from(dto: BlockDto) -> Self {
UpdateBlockDto {
id: dto.id,
created_at: dto.created_at,
updated_at: dto.updated_at,
text_length: dto.text_length,
document_position: dto.document_position,
plain_text: dto.plain_text,
fmt_alignment: dto.fmt_alignment,
fmt_top_margin: dto.fmt_top_margin,
fmt_bottom_margin: dto.fmt_bottom_margin,
fmt_left_margin: dto.fmt_left_margin,
fmt_right_margin: dto.fmt_right_margin,
fmt_heading_level: dto.fmt_heading_level,
fmt_indent: dto.fmt_indent,
fmt_text_indent: dto.fmt_text_indent,
fmt_marker: dto.fmt_marker,
fmt_tab_positions: dto.fmt_tab_positions,
fmt_line_height: dto.fmt_line_height,
fmt_non_breakable_lines: dto.fmt_non_breakable_lines,
fmt_direction: dto.fmt_direction,
fmt_background_color: dto.fmt_background_color,
fmt_is_code_block: dto.fmt_is_code_block,
fmt_code_language: dto.fmt_code_language,
}
}
}
pub use common::direct_access::block::BlockRelationshipField;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct BlockRelationshipDto {
pub id: EntityId,
pub field: BlockRelationshipField,
pub right_ids: Vec<EntityId>,
}