Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: level suff #78

Merged
merged 2 commits into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docx-wasm/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,15 @@ export class Docx {
let num = wasm.createAbstractNumbering(n.id);
n.levels.forEach((l) => {
let level = wasm.createLevel(l.id, l.start, l.format, l.text, l.jc);

if (l.levelSuffix === "nothing") {
level = level.suffix(wasm.LevelSuffixType.Nothing);
} else if (l.levelSuffix === "space") {
level = level.suffix(wasm.LevelSuffixType.Space);
} else {
level = level.suffix(wasm.LevelSuffixType.Tab);
}

if (l.paragraphProperty.indent) {
let kind;
if (l.paragraphProperty.indent.specialIndentKind === "firstLine") {
Expand Down
9 changes: 9 additions & 0 deletions docx-wasm/js/level.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { ParagraphProperty, SpecialIndentKind } from "./paragraph";

export type LevelSuffixType = "nothing" | "tab" | "space";

export class Level {
id: number;
start: number;
format: string;
text: string;
jc: string;
paragraphProperty: ParagraphProperty = {};
levelSuffix: LevelSuffixType;

constructor(
id: number,
Expand All @@ -20,6 +23,7 @@ export class Level {
this.format = format;
this.text = text;
this.jc = jc;
this.levelSuffix = "tab";
}

indent(
Expand All @@ -34,6 +38,11 @@ export class Level {
};
return this;
}

suffix(s: LevelSuffixType) {
this.levelSuffix = s;
return this;
}
}

export class LevelOverride {
Expand Down
2 changes: 1 addition & 1 deletion docx-wasm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docx-wasm",
"version": "0.0.75",
"version": "0.0.76",
"main": "dist/node/index.js",
"browser": "dist/web/index.js",
"author": "bokuweb <bokuweb12@gmail.com>",
Expand Down
5 changes: 5 additions & 0 deletions docx-wasm/src/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ impl Level {
.indent(Some(left), special_indent, None, None);
self
}

pub fn suffix(mut self, s: docx_rs::LevelSuffixType) -> Self {
self.0 = self.0.suffix(s);
self
}
}