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]
#[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),
}

View File

@ -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") {

View File

@ -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";