fix: level disable styles (#799)

* fix: level disable styles

* fix

* fix

* fix
main
bokuweb 2025-01-29 12:08:57 +09:00 committed by GitHub
parent 462239aeb4
commit 5741806734
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 141 additions and 9 deletions

View File

@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<!-- <!--
- Support `TC` - Support `TC`
- Update `Level` styles.
--> -->
## @0.4.17 (26. Apr, 2024) ## @0.4.17 (26. Apr, 2024)
@ -57,7 +58,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- escape author in del/ins. - escape author in del/ins.
## docx-wasm@0.0.278-rc19 (9. Aug, 2023) ## docx-wasm@0.0.278-rc19 (9. Aug, 20)
- use i32 for line instead of u32. - use i32 for line instead of u32.

2
Cargo.lock generated
View File

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 4 version = 3
[[package]] [[package]]
name = "Inflector" name = "Inflector"

View File

@ -94,11 +94,31 @@ impl Level {
self self
} }
pub fn disable_bold(mut self) -> Self {
self.run_property = self.run_property.disable_bold();
self
}
pub fn italic(mut self) -> Self { pub fn italic(mut self) -> Self {
self.run_property = self.run_property.italic(); self.run_property = self.run_property.italic();
self self
} }
pub fn disable_italic(mut self) -> Self {
self.run_property = self.run_property.disable_italic();
self
}
pub fn strike(mut self) -> Self {
self.run_property = self.run_property.strike();
self
}
pub fn disable_strike(mut self) -> Self {
self.run_property = self.run_property.disable_strike();
self
}
pub fn underline(mut self, line_type: impl Into<String>) -> Self { pub fn underline(mut self, line_type: impl Into<String>) -> Self {
self.run_property = self.run_property.underline(line_type); self.run_property = self.run_property.underline(line_type);
self self

View File

@ -119,6 +119,11 @@ impl RunProperty {
self self
} }
pub fn disable_strike(mut self) -> RunProperty {
self.strike = Some(Strike::new().disable());
self
}
pub fn disable_italic(mut self) -> RunProperty { pub fn disable_italic(mut self) -> RunProperty {
self.italic = Some(Italic::new().disable()); self.italic = Some(Italic::new().disable());
self.italic_cs = Some(ItalicCs::new().disable()); self.italic_cs = Some(ItalicCs::new().disable());

View File

@ -298,6 +298,30 @@ export class Docx {
level = level.italic(); level = level.italic();
} }
if (l.runProperty._bold != null) {
if (l.runProperty._bold) {
level = level.bold();
} else {
level = level.disable_bold();
}
}
if (l.runProperty._italic != null) {
if (l.runProperty._italic) {
level = level.italic();
} else {
level = level.disable_italic();
}
}
if (l.runProperty._strike != null) {
if (l.runProperty._strike) {
level = level.strike();
} else {
level = level.disable_strike();
}
}
if (l.runProperty._size) { if (l.runProperty._size) {
level = level.size(l.runProperty._size); level = level.size(l.runProperty._size);
} }

View File

@ -75,11 +75,31 @@ export class Level {
return this; return this;
} }
disableBold() {
this.runProperty.disableBold();
return this;
}
italic() { italic() {
this.runProperty.italic(); this.runProperty.italic();
return this; return this;
} }
disableItalic() {
this.runProperty.disableItalic();
return this;
}
strike() {
this.runProperty.strike();
return this;
}
disableStrike() {
this.runProperty.disableStrike();
return this;
}
underline(type: string) { underline(type: string) {
this.runProperty.underline(type); this.runProperty.underline(type);
return this; return this;

View File

@ -68,16 +68,31 @@ export class RunProperty {
return this; return this;
} }
disableBold() {
this._bold = false;
return this;
}
strike() { strike() {
this._strike = true; this._strike = true;
return this; return this;
} }
disableStrike() {
this._strike = false;
return this;
}
italic() { italic() {
this._italic = true; this._italic = true;
return this; return this;
} }
disableItalic() {
this._italic = false;
return this;
}
underline(type: string) { underline(type: string) {
this._underline = type; this._underline = type;
return this; return this;
@ -340,16 +355,28 @@ export const createRunProperty = (property: RunProperty): wasm.RunProperty => {
} }
} }
if (property._bold) { if (property._bold != null) {
target = target.bold(); if (property._bold) {
target = target.bold();
} else {
target = target.disable_bold();
}
} }
if (property._italic) { if (property._italic != null) {
target = target.italic(); if (property._italic) {
target = target.italic();
} else {
target = target.disable_italic();
}
} }
if (property._strike) { if (property._strike != null) {
target = target.strike(); if (property._strike) {
target = target.strike();
} else {
target = target.disable_strike();
}
} }
if (property._underline) { if (property._underline) {

View File

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

@ -62,11 +62,31 @@ impl Level {
self self
} }
pub fn disable_bold(mut self) -> Self {
self.0 = self.0.disable_bold();
self
}
pub fn italic(mut self) -> Self { pub fn italic(mut self) -> Self {
self.0 = self.0.italic(); self.0 = self.0.italic();
self self
} }
pub fn strike(mut self) -> Self {
self.0 = self.0.strike();
self
}
pub fn disable_strike(mut self) -> Self {
self.0 = self.0.disable_strike();
self
}
pub fn disable_italic(mut self) -> Self {
self.0 = self.0.disable_italic();
self
}
pub fn underline(mut self, line_type: &str) -> Self { pub fn underline(mut self, line_type: &str) -> Self {
self.0 = self.0.underline(line_type); self.0 = self.0.underline(line_type);
self self

View File

@ -26,16 +26,31 @@ impl RunProperty {
self self
} }
pub fn disable_bold(mut self) -> Self {
self.0 = self.0.disable_bold();
self
}
pub fn italic(mut self) -> Self { pub fn italic(mut self) -> Self {
self.0 = self.0.italic(); self.0 = self.0.italic();
self self
} }
pub fn disable_italic(mut self) -> Self {
self.0 = self.0.disable_italic();
self
}
pub fn strike(mut self) -> Self { pub fn strike(mut self) -> Self {
self.0 = self.0.strike(); self.0 = self.0.strike();
self self
} }
pub fn disable_strike(mut self) -> Self {
self.0 = self.0.disable_strike();
self
}
pub fn fonts(mut self, f: RunFonts) -> Self { pub fn fonts(mut self, f: RunFonts) -> Self {
self.0 = self.0.fonts(f.take()); self.0 = self.0.fonts(f.take());
self self