diff --git a/docx-core/src/documents/elements/paragraph.rs b/docx-core/src/documents/elements/paragraph.rs index 71d744d..84cdf90 100644 --- a/docx-core/src/documents/elements/paragraph.rs +++ b/docx-core/src/documents/elements/paragraph.rs @@ -305,6 +305,11 @@ impl Paragraph { self } + pub fn color(mut self, c: impl Into) -> Self { + self.property.run_property = self.property.run_property.color(c); + self + } + pub fn bold(mut self) -> Self { self.property.run_property = self.property.run_property.bold(); self diff --git a/docx-wasm/js/paragraph-property.ts b/docx-wasm/js/paragraph-property.ts index 8b52a83..46a4435 100644 --- a/docx-wasm/js/paragraph-property.ts +++ b/docx-wasm/js/paragraph-property.ts @@ -299,6 +299,10 @@ export const setParagraphProperty = ( target = target.bold() as T; } + if (property.runProperty.color) { + target = target.color(property.runProperty.color) as T; + } + if (typeof property.lineSpacing !== "undefined") { const spacing = buildLineSpacing(property); if (spacing) { diff --git a/docx-wasm/js/paragraph.ts b/docx-wasm/js/paragraph.ts index 5f00320..2aa93e8 100644 --- a/docx-wasm/js/paragraph.ts +++ b/docx-wasm/js/paragraph.ts @@ -180,6 +180,11 @@ export class Paragraph { return this; } + color(color: string) { + this.property.runProperty = { ...this.property.runProperty, color }; + return this; + } + bold() { this.property.runProperty = { ...this.property.runProperty, bold: true }; return this; diff --git a/docx-wasm/src/paragraph.rs b/docx-wasm/src/paragraph.rs index 0dc265e..8249c96 100644 --- a/docx-wasm/src/paragraph.rs +++ b/docx-wasm/src/paragraph.rs @@ -178,6 +178,11 @@ impl Paragraph { self } + pub fn color(mut self, c: &str) -> Self { + self.0 = self.0.color(c); + self + } + pub fn bold(mut self) -> Self { self.0 = self.0.bold(); self