Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 34 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docx-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ serde_json = {version = "1.0" }
base64 = "0.13.1"
image = { version = "0.24.4", default-features = false, features=["gif", "jpeg", "png", "bmp", "tiff"] }
wasm-bindgen = { version = "0.2.78", optional = true }
ts-rs = { version = "6.1", optional = true }
ts-rs = { version = "7.1", optional = true }

[dev-dependencies]
pretty_assertions = "1.3.0"
Expand Down
1 change: 1 addition & 0 deletions docx-core/bindings/FontGroup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FontSchemeFont } from "./FontSchemeFont";

export interface FontGroup { latin: string, ea: string, cs: string, fonts: Array<FontSchemeFont>, }
1 change: 1 addition & 0 deletions docx-core/bindings/FontScheme.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FontGroup } from "./FontGroup";

export interface FontScheme { majorFont: FontGroup, minorFont: FontGroup, }
1 change: 1 addition & 0 deletions docx-core/bindings/FontSchemeFont.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.

export interface FontSchemeFont { script: string, typeface: string, }
1 change: 1 addition & 0 deletions docx-core/bindings/Theme.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { FontScheme } from "./FontScheme";

export interface Theme { fontSchema: FontScheme, }
12 changes: 6 additions & 6 deletions docx-core/src/documents/elements/bold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ use crate::documents::BuildXML;
use crate::xml_builder::*;

#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct Bold {
val: bool,
}
#[cfg_attr(feature = "wasm", derive(ts_rs::TS))]
#[cfg_attr(feature = "wasm", ts(export))]
pub struct Bold(pub bool);

impl Bold {
pub fn new() -> Bold {
Default::default()
}

pub fn disable(mut self) -> Bold {
self.val = false;
self.0 = false;
self
}
}

impl Default for Bold {
fn default() -> Self {
Self { val: true }
Self(true)
}
}

Expand All @@ -30,7 +30,7 @@ impl Serialize for Bold {
where
S: Serializer,
{
serializer.serialize_bool(self.val)
serializer.serialize_bool(self.0)
}
}

Expand Down
12 changes: 6 additions & 6 deletions docx-core/src/documents/elements/bold_cs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ use crate::documents::BuildXML;
use crate::xml_builder::*;

#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct BoldCs {
val: bool,
}
#[cfg_attr(feature = "wasm", derive(ts_rs::TS))]
#[cfg_attr(feature = "wasm", ts(export))]
pub struct BoldCs(pub bool);

impl BoldCs {
pub fn new() -> BoldCs {
Default::default()
}
pub fn disable(mut self) -> BoldCs {
self.val = false;
self.0 = false;
self
}
}

impl Default for BoldCs {
fn default() -> Self {
Self { val: true }
Self(true)
}
}

Expand All @@ -29,7 +29,7 @@ impl Serialize for BoldCs {
where
S: Serializer,
{
serializer.serialize_bool(self.val)
serializer.serialize_bool(self.0)
}
}

Expand Down
2 changes: 2 additions & 0 deletions docx-core/src/documents/elements/br.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use crate::types::*;
use crate::xml_builder::*;

#[derive(Debug, Clone, Deserialize, PartialEq)]
#[cfg_attr(feature = "wasm", derive(ts_rs::TS))]
#[cfg_attr(feature = "wasm", ts(export))]
pub struct Break {
break_type: BreakType,
}
Expand Down
12 changes: 6 additions & 6 deletions docx-core/src/documents/elements/caps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ use serde::{Deserialize, Serialize, Serializer};
// use crate::xml_builder::*;

#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct Caps {
val: bool,
}
#[cfg_attr(feature = "wasm", derive(ts_rs::TS))]
#[cfg_attr(feature = "wasm", ts(export))]
pub struct Caps(pub bool);

impl Caps {
pub fn new() -> Caps {
Default::default()
}

pub fn disable(mut self) -> Caps {
self.val = false;
self.0 = false;
self
}
}

impl Default for Caps {
fn default() -> Self {
Self { val: true }
Self(true)
}
}

Expand All @@ -30,6 +30,6 @@ impl Serialize for Caps {
where
S: Serializer,
{
serializer.serialize_bool(self.val)
serializer.serialize_bool(self.0)
}
}
15 changes: 7 additions & 8 deletions docx-core/src/documents/elements/character_spacing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@ use crate::xml_builder::*;
use serde::*;

#[derive(Debug, Clone, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CharacterSpacing {
value: i32,
}
#[cfg_attr(feature = "wasm", derive(ts_rs::TS))]
#[cfg_attr(feature = "wasm", ts(export))]
pub struct CharacterSpacing(pub i32);

impl CharacterSpacing {
pub fn new(s: i32) -> CharacterSpacing {
Self { value: s }
Self(s)
}
}

impl BuildXML for CharacterSpacing {
fn build(&self) -> Vec<u8> {
let b = XMLBuilder::new();
b.spacing(self.value).build()
b.spacing(self.0).build()
}
}

Expand All @@ -27,7 +26,7 @@ impl Serialize for CharacterSpacing {
where
S: Serializer,
{
serializer.serialize_i32(self.value)
serializer.serialize_i32(self.0)
}
}

Expand All @@ -47,7 +46,7 @@ mod tests {

#[test]
fn test_spacing_json() {
let s = CharacterSpacing { value: 100 };
let s = CharacterSpacing(100);
assert_eq!(serde_json::to_string(&s).unwrap(), r#"100"#);
}
}
12 changes: 6 additions & 6 deletions docx-core/src/documents/elements/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ use crate::documents::BuildXML;
use crate::xml_builder::*;

#[derive(Deserialize, Debug, Clone, PartialEq)]
pub struct Color {
val: String,
}
#[cfg_attr(feature = "wasm", derive(ts_rs::TS))]
#[cfg_attr(feature = "wasm", ts(export))]
pub struct Color(pub String);

impl Color {
pub fn new(val: impl Into<String>) -> Color {
Color { val: val.into() }
Self(val.into())
}
}

impl BuildXML for Color {
fn build(&self) -> Vec<u8> {
XMLBuilder::new().color(&self.val).build()
XMLBuilder::new().color(&self.0).build()
}
}

Expand All @@ -25,7 +25,7 @@ impl Serialize for Color {
where
S: Serializer,
{
serializer.serialize_str(&self.val)
serializer.serialize_str(&self.0)
}
}

Expand Down
3 changes: 3 additions & 0 deletions docx-core/src/documents/elements/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ use crate::xml_builder::*;

#[derive(Serialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(feature = "wasm", derive(ts_rs::TS))]
#[cfg_attr(feature = "wasm", ts(export))]
pub struct Comment {
pub id: usize,
pub author: String,
pub date: String,
#[cfg_attr(feature = "wasm", ts(type = "any[]"))] // TODO:
pub children: Vec<CommentChild>,
pub parent_comment_id: Option<usize>,
}
Expand Down
2 changes: 2 additions & 0 deletions docx-core/src/documents/elements/comment_range_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use crate::documents::BuildXML;
use crate::xml_builder::*;

#[derive(Serialize, Debug, Clone, PartialEq)]
#[cfg_attr(feature = "wasm", derive(ts_rs::TS))]
#[cfg_attr(feature = "wasm", ts(export))]
pub struct CommentRangeEnd {
id: usize,
}
Expand Down
Loading