From ada3d5541802821c60cb1b45ff6f0ed8a327a722 Mon Sep 17 00:00:00 2001 From: bokuweb Date: Fri, 12 Jun 2020 14:32:40 +0900 Subject: [PATCH] fix: Add end and distribute (#83) --- docx-core/src/types/alignment_type.rs | 8 +++++++- docx-wasm/js/index.ts | 8 ++++++++ docx-wasm/js/paragraph.ts | 8 +++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/docx-core/src/types/alignment_type.rs b/docx-core/src/types/alignment_type.rs index 1bc52e3..3330a41 100644 --- a/docx-core/src/types/alignment_type.rs +++ b/docx-core/src/types/alignment_type.rs @@ -7,10 +7,12 @@ use super::errors; #[wasm_bindgen] #[derive(Copy, Clone, Debug)] pub enum AlignmentType { + Both, Center, + Distribute, + End, Left, Right, - Both, Justified, Unsupported, } @@ -20,7 +22,9 @@ impl fmt::Display for AlignmentType { match *self { AlignmentType::Center => write!(f, "center"), AlignmentType::Left => write!(f, "left"), + AlignmentType::Distribute => write!(f, "distribute"), AlignmentType::Right => write!(f, "right"), + AlignmentType::End => write!(f, "end"), AlignmentType::Both => write!(f, "both"), AlignmentType::Justified => write!(f, "justified"), _ => write!(f, "unsupported"), @@ -34,8 +38,10 @@ impl FromStr for AlignmentType { match s { "left" => Ok(AlignmentType::Left), "right" => Ok(AlignmentType::Right), + "distribute" => Ok(AlignmentType::Distribute), "center" => Ok(AlignmentType::Center), "both" => Ok(AlignmentType::Both), + "end" => Ok(AlignmentType::End), "justified" => Ok(AlignmentType::Justified), _ => Ok(AlignmentType::Unsupported), } diff --git a/docx-wasm/js/index.ts b/docx-wasm/js/index.ts index d07d887..3de2fd5 100644 --- a/docx-wasm/js/index.ts +++ b/docx-wasm/js/index.ts @@ -223,6 +223,14 @@ export class Docx { paragraph = paragraph.align(wasm.AlignmentType.Left); break; } + case "distribute": { + paragraph = paragraph.align(wasm.AlignmentType.Distribute); + break; + } + case "end": { + paragraph = paragraph.align(wasm.AlignmentType.End); + break; + } } if (typeof p.property.indent !== "undefined") { diff --git a/docx-wasm/js/paragraph.ts b/docx-wasm/js/paragraph.ts index d59bd99..203ddfa 100644 --- a/docx-wasm/js/paragraph.ts +++ b/docx-wasm/js/paragraph.ts @@ -15,7 +15,13 @@ export type ParagraphChild = | Comment | CommentEnd; -export type AlignmentType = "center" | "left" | "right" | "justified"; +export type AlignmentType = + | "center" + | "left" + | "right" + | "justified" + | "distribute" + | "end"; export type SpecialIndentKind = "firstLine" | "hanging";