fix: Add end and distribute (#83)

main
bokuweb 2020-06-12 14:32:40 +09:00 committed by GitHub
parent 6ed69bdf5d
commit ada3d55418
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View File

@ -7,10 +7,12 @@ use super::errors;
#[wasm_bindgen] #[wasm_bindgen]
#[derive(Copy, Clone, Debug)] #[derive(Copy, Clone, Debug)]
pub enum AlignmentType { pub enum AlignmentType {
Both,
Center, Center,
Distribute,
End,
Left, Left,
Right, Right,
Both,
Justified, Justified,
Unsupported, Unsupported,
} }
@ -20,7 +22,9 @@ impl fmt::Display for AlignmentType {
match *self { match *self {
AlignmentType::Center => write!(f, "center"), AlignmentType::Center => write!(f, "center"),
AlignmentType::Left => write!(f, "left"), AlignmentType::Left => write!(f, "left"),
AlignmentType::Distribute => write!(f, "distribute"),
AlignmentType::Right => write!(f, "right"), AlignmentType::Right => write!(f, "right"),
AlignmentType::End => write!(f, "end"),
AlignmentType::Both => write!(f, "both"), AlignmentType::Both => write!(f, "both"),
AlignmentType::Justified => write!(f, "justified"), AlignmentType::Justified => write!(f, "justified"),
_ => write!(f, "unsupported"), _ => write!(f, "unsupported"),
@ -34,8 +38,10 @@ impl FromStr for AlignmentType {
match s { match s {
"left" => Ok(AlignmentType::Left), "left" => Ok(AlignmentType::Left),
"right" => Ok(AlignmentType::Right), "right" => Ok(AlignmentType::Right),
"distribute" => Ok(AlignmentType::Distribute),
"center" => Ok(AlignmentType::Center), "center" => Ok(AlignmentType::Center),
"both" => Ok(AlignmentType::Both), "both" => Ok(AlignmentType::Both),
"end" => Ok(AlignmentType::End),
"justified" => Ok(AlignmentType::Justified), "justified" => Ok(AlignmentType::Justified),
_ => Ok(AlignmentType::Unsupported), _ => Ok(AlignmentType::Unsupported),
} }

View File

@ -223,6 +223,14 @@ export class Docx {
paragraph = paragraph.align(wasm.AlignmentType.Left); paragraph = paragraph.align(wasm.AlignmentType.Left);
break; 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") { if (typeof p.property.indent !== "undefined") {

View File

@ -15,7 +15,13 @@ export type ParagraphChild =
| Comment | Comment
| CommentEnd; | CommentEnd;
export type AlignmentType = "center" | "left" | "right" | "justified"; export type AlignmentType =
| "center"
| "left"
| "right"
| "justified"
| "distribute"
| "end";
export type SpecialIndentKind = "firstLine" | "hanging"; export type SpecialIndentKind = "firstLine" | "hanging";