fix: expose outline level (#590)
* fix: expose outline level * fix: js method for style * fix * fixmain
parent
62e1b08205
commit
44a236e6c0
|
@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## docx-wasm@0.0.276 (13. Dec, 2022)
|
||||
|
||||
- Support outline_level in Paragraph and style.
|
||||
|
||||
## docx-wasm@0.0.276-rc39 (13. Dec, 2022)
|
||||
|
||||
- Support before/after contents in ToC.
|
||||
|
|
|
@ -97,6 +97,8 @@ impl ParagraphProperty {
|
|||
|
||||
pub fn outline_lvl(mut self, v: usize) -> Self {
|
||||
if v >= 10 {
|
||||
// clamped
|
||||
self.outline_lvl = Some(OutlineLvl::new(9));
|
||||
return self;
|
||||
}
|
||||
self.outline_lvl = Some(OutlineLvl::new(v));
|
||||
|
|
|
@ -68,6 +68,7 @@ export type ParagraphProperty = {
|
|||
pageBreakBefore: boolean;
|
||||
widowControl: boolean;
|
||||
paragraphPropertyChange?: ParagraphPropertyChange;
|
||||
outlineLvl?: number | null;
|
||||
};
|
||||
|
||||
export const createDefaultParagraphProperty = (): ParagraphProperty => {
|
||||
|
@ -280,5 +281,9 @@ export const setParagraphProperty = <T extends wasm.Paragraph | wasm.Style>(
|
|||
target = target.widow_control(true) as T;
|
||||
}
|
||||
|
||||
if (property.outlineLvl != null) {
|
||||
target = target.outline_lvl(property.outlineLvl) as T;
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
|
|
@ -154,6 +154,11 @@ export class Paragraph {
|
|||
return this;
|
||||
}
|
||||
|
||||
outlineLevel(v: number) {
|
||||
this.property = { ...this.property, outlineLvl: v };
|
||||
return this;
|
||||
}
|
||||
|
||||
paragraphPropertyChange(propertyChange: ParagraphPropertyChange) {
|
||||
this.property.paragraphPropertyChange = propertyChange;
|
||||
return this;
|
||||
|
|
|
@ -207,6 +207,11 @@ export class Style {
|
|||
return this;
|
||||
}
|
||||
|
||||
outlineLevel(v: number) {
|
||||
this._paragraphProperty = { ...this._paragraphProperty, outlineLvl: v };
|
||||
return this;
|
||||
}
|
||||
|
||||
// tableProperty = (n: TableProperty) => {
|
||||
// this._tableProperty = n;
|
||||
// return this;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "docx-wasm",
|
||||
"version": "0.0.276-rc39",
|
||||
"version": "0.0.276",
|
||||
"main": "dist/node/index.js",
|
||||
"browser": "dist/web/index.js",
|
||||
"author": "bokuweb <bokuweb12@gmail.com>",
|
||||
|
|
|
@ -131,6 +131,11 @@ impl Paragraph {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn outline_lvl(mut self, level: usize) -> Paragraph {
|
||||
self.0.property = self.0.property.outline_lvl(level);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn style(mut self, style_id: &str) -> Paragraph {
|
||||
self.0.property = self.0.property.style(style_id);
|
||||
self
|
||||
|
|
Loading…
Reference in New Issue