parent
0e6ab1b648
commit
2c06b30b68
|
@ -7,6 +7,7 @@ use crate::xml_builder::*;
|
|||
#[derive(Serialize, Debug, Clone, PartialEq)]
|
||||
pub struct PageNum {
|
||||
pub instr: InstrPAGE,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub frame_property: Option<FrameProperty>,
|
||||
}
|
||||
|
||||
|
@ -14,14 +15,7 @@ impl Default for PageNum {
|
|||
fn default() -> Self {
|
||||
Self {
|
||||
instr: InstrPAGE {},
|
||||
frame_property: Some(FrameProperty {
|
||||
wrap: Some("none".to_owned()),
|
||||
v_anchor: Some("text".to_owned()),
|
||||
h_anchor: Some("margin".to_owned()),
|
||||
x_align: Some("right".to_owned()),
|
||||
y: Some(1),
|
||||
..Default::default()
|
||||
}),
|
||||
frame_property: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -180,7 +174,7 @@ mod tests {
|
|||
let b = PageNum::new().build();
|
||||
assert_eq!(
|
||||
str::from_utf8(&b).unwrap(),
|
||||
r#"<w:sdt><w:sdtPr><w:rPr /></w:sdtPr><w:sdtContent><w:p w14:paraId="12345678"><w:pPr><w:rPr /><w:framePr w:wrap="none" w:hAnchor="margin" w:vAnchor="text" w:xAlign="right" w:y="1" /></w:pPr><w:r><w:rPr /><w:fldChar w:fldCharType="begin" w:dirty="false" /><w:instrText>PAGE</w:instrText><w:fldChar w:fldCharType="separate" w:dirty="false" /><w:t xml:space="preserve">1</w:t><w:fldChar w:fldCharType="end" w:dirty="false" /></w:r></w:p></w:sdtContent>
|
||||
r#"<w:sdt><w:sdtPr><w:rPr /></w:sdtPr><w:sdtContent><w:p w14:paraId="12345678"><w:pPr><w:rPr /></w:pPr><w:r><w:rPr /><w:fldChar w:fldCharType="begin" w:dirty="false" /><w:instrText>PAGE</w:instrText><w:fldChar w:fldCharType="separate" w:dirty="false" /><w:t xml:space="preserve">1</w:t><w:fldChar w:fldCharType="end" w:dirty="false" /></w:r></w:p></w:sdtContent>
|
||||
</w:sdt>"#
|
||||
);
|
||||
}
|
||||
|
@ -190,7 +184,7 @@ mod tests {
|
|||
let b = PageNum::new().wrap("none").x_align("left").build();
|
||||
assert_eq!(
|
||||
str::from_utf8(&b).unwrap(),
|
||||
r#"<w:sdt><w:sdtPr><w:rPr /></w:sdtPr><w:sdtContent><w:p w14:paraId="12345678"><w:pPr><w:rPr /><w:framePr w:wrap="none" w:hAnchor="margin" w:vAnchor="text" w:xAlign="left" w:y="1" /></w:pPr><w:r><w:rPr /><w:fldChar w:fldCharType="begin" w:dirty="false" /><w:instrText>PAGE</w:instrText><w:fldChar w:fldCharType="separate" w:dirty="false" /><w:t xml:space="preserve">1</w:t><w:fldChar w:fldCharType="end" w:dirty="false" /></w:r></w:p></w:sdtContent>
|
||||
r#"<w:sdt><w:sdtPr><w:rPr /></w:sdtPr><w:sdtContent><w:p w14:paraId="12345678"><w:pPr><w:rPr /><w:framePr w:wrap="none" w:xAlign="left" /></w:pPr><w:r><w:rPr /><w:fldChar w:fldCharType="begin" w:dirty="false" /><w:instrText>PAGE</w:instrText><w:fldChar w:fldCharType="separate" w:dirty="false" /><w:t xml:space="preserve">1</w:t><w:fldChar w:fldCharType="end" w:dirty="false" /></w:r></w:p></w:sdtContent>
|
||||
</w:sdt>"#
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use serde::Serialize;
|
||||
use std::fmt;
|
||||
use std::str::FromStr;
|
||||
#[cfg(feature = "wasm")]
|
||||
|
@ -6,7 +7,10 @@ use wasm_bindgen::prelude::*;
|
|||
use super::errors;
|
||||
|
||||
#[cfg_attr(feature = "wasm", wasm_bindgen)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[cfg_attr(feature = "wasm", derive(ts_rs::TS))]
|
||||
#[cfg_attr(feature = "wasm", ts(export))]
|
||||
#[derive(Copy, Clone, Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum AlignmentType {
|
||||
Both,
|
||||
Center,
|
||||
|
@ -16,7 +20,6 @@ pub enum AlignmentType {
|
|||
Left,
|
||||
Right,
|
||||
Justified,
|
||||
Unsupported,
|
||||
}
|
||||
|
||||
impl fmt::Display for AlignmentType {
|
||||
|
@ -30,7 +33,6 @@ impl fmt::Display for AlignmentType {
|
|||
AlignmentType::End => write!(f, "end"),
|
||||
AlignmentType::Both => write!(f, "both"),
|
||||
AlignmentType::Justified => write!(f, "justified"),
|
||||
_ => write!(f, "unsupported"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +49,7 @@ impl FromStr for AlignmentType {
|
|||
"start" => Ok(AlignmentType::Start),
|
||||
"end" => Ok(AlignmentType::End),
|
||||
"justified" => Ok(AlignmentType::Justified),
|
||||
_ => Ok(AlignmentType::Unsupported),
|
||||
_ => Ok(AlignmentType::Left),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
|
||||
export type AlignmentType = "both" | "center" | "distribute" | "start" | "end" | "left" | "right" | "justified";
|
|
@ -8,6 +8,7 @@ import {
|
|||
import { LineSpacingJSON } from "./line_spacing";
|
||||
import { FrameProperty as FramePropertyJSON } from "./bindings/FrameProperty";
|
||||
import { TextAlignmentType } from "./bindings/TextAlignmentType";
|
||||
import { AlignmentType } from "./bindings/AlignmentType";
|
||||
|
||||
export { FrameProperty as FramePropertyJSON } from "./bindings/FrameProperty";
|
||||
|
||||
|
@ -56,15 +57,7 @@ export type ParagraphPropertyJSON = {
|
|||
runProperty: RunPropertyJSON;
|
||||
style?: string | null;
|
||||
numberingProperty?: NumberingPropertyJSON | null;
|
||||
alignment?:
|
||||
| "left"
|
||||
| "center"
|
||||
| "right"
|
||||
| "justified"
|
||||
| "both"
|
||||
| "start"
|
||||
| "end"
|
||||
| "unsupported";
|
||||
alignment?: AlignmentType;
|
||||
textAlignment?: TextAlignmentType;
|
||||
adjustRightInd?: number;
|
||||
indent?: IndentJSON | null;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "docx-wasm",
|
||||
"version": "0.4.14-beta2",
|
||||
"version": "0.4.14-beta4",
|
||||
"main": "dist/node/index.js",
|
||||
"browser": "dist/web/index.js",
|
||||
"author": "bokuweb <bokuweb12@gmail.com>",
|
||||
|
|
Loading…
Reference in New Issue