feat: Support paragraph color (#761)

main
bokuweb 2024-10-15 18:51:20 +09:00 committed by GitHub
parent 60d94921b0
commit 6fdf81d1ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 19 additions and 0 deletions

View File

@ -305,6 +305,11 @@ impl Paragraph {
self
}
pub fn color(mut self, c: impl Into<String>) -> 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

View File

@ -299,6 +299,10 @@ export const setParagraphProperty = <T extends wasm.Paragraph | wasm.Style>(
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) {

View File

@ -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;

View File

@ -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