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