fix: level suff (#78)

main
bokuweb 2020-06-04 18:09:20 +09:00 committed by GitHub
parent a6245193d0
commit dd8ee73d7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 1 deletions

View File

@ -388,6 +388,15 @@ export class Docx {
let num = wasm.createAbstractNumbering(n.id); let num = wasm.createAbstractNumbering(n.id);
n.levels.forEach((l) => { n.levels.forEach((l) => {
let level = wasm.createLevel(l.id, l.start, l.format, l.text, l.jc); 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) { if (l.paragraphProperty.indent) {
let kind; let kind;
if (l.paragraphProperty.indent.specialIndentKind === "firstLine") { if (l.paragraphProperty.indent.specialIndentKind === "firstLine") {

View File

@ -1,5 +1,7 @@
import { ParagraphProperty, SpecialIndentKind } from "./paragraph"; import { ParagraphProperty, SpecialIndentKind } from "./paragraph";
export type LevelSuffixType = "nothing" | "tab" | "space";
export class Level { export class Level {
id: number; id: number;
start: number; start: number;
@ -7,6 +9,7 @@ export class Level {
text: string; text: string;
jc: string; jc: string;
paragraphProperty: ParagraphProperty = {}; paragraphProperty: ParagraphProperty = {};
levelSuffix: LevelSuffixType;
constructor( constructor(
id: number, id: number,
@ -20,6 +23,7 @@ export class Level {
this.format = format; this.format = format;
this.text = text; this.text = text;
this.jc = jc; this.jc = jc;
this.levelSuffix = "tab";
} }
indent( indent(
@ -34,6 +38,11 @@ export class Level {
}; };
return this; return this;
} }
suffix(s: LevelSuffixType) {
this.levelSuffix = s;
return this;
}
} }
export class LevelOverride { export class LevelOverride {

View File

@ -1,6 +1,6 @@
{ {
"name": "docx-wasm", "name": "docx-wasm",
"version": "0.0.75", "version": "0.0.76",
"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>",

View File

@ -36,4 +36,9 @@ impl Level {
.indent(Some(left), special_indent, None, None); .indent(Some(left), special_indent, None, None);
self self
} }
pub fn suffix(mut self, s: docx_rs::LevelSuffixType) -> Self {
self.0 = self.0.suffix(s);
self
}
} }