From 8bc4e522aa57dee41fc3c03c0d7cb44bb8ec6422 Mon Sep 17 00:00:00 2001 From: bokuweb Date: Wed, 16 Mar 2022 12:54:17 +0900 Subject: [PATCH] 0.0.247 (#449) * fix: js * fix --- CHANGELOG.md | 4 ++++ docx-wasm/js/index.ts | 4 ++++ docx-wasm/js/json/run.ts | 1 + docx-wasm/js/run.ts | 6 ++++++ docx-wasm/package.json | 2 +- docx-wasm/src/run.rs | 5 +++++ 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34216e6..05ee126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.24y (16. March, 2022) + +- Add js interface for `rStyle`. + ## docx-wasm@0.0.246, docx-rs@0.3.4 (16. March, 2022) - Support `rStyle`. diff --git a/docx-wasm/js/index.ts b/docx-wasm/js/index.ts index bd4657f..ff2e963 100644 --- a/docx-wasm/js/index.ts +++ b/docx-wasm/js/index.ts @@ -289,6 +289,10 @@ export class Docx { } }); + if (r.property.style) { + run = run.style(r.property.style); + } + if (typeof r.property.size !== "undefined") { run = run.size(r.property.size); } diff --git a/docx-wasm/js/json/run.ts b/docx-wasm/js/json/run.ts index 12c2f2f..c9324ef 100644 --- a/docx-wasm/js/json/run.ts +++ b/docx-wasm/js/json/run.ts @@ -24,6 +24,7 @@ export type RunFontsJSON = { }; export type RunPropertyJSON = { + style?: string | null; sz?: number | null; szCs?: number | null; fonts?: RunFontsJSON | null; diff --git a/docx-wasm/js/run.ts b/docx-wasm/js/run.ts index 8735155..2cf6940 100644 --- a/docx-wasm/js/run.ts +++ b/docx-wasm/js/run.ts @@ -28,6 +28,7 @@ export type RunPropertyIns = { }; export type RunProperty = { + style?: string; size?: number; color?: string; highlight?: string; @@ -164,6 +165,11 @@ export class Run { return this; } + style(style: string) { + this.property = { ...this.property, style }; + return this; + } + size(size: number) { this.property = { ...this.property, size }; return this; diff --git a/docx-wasm/package.json b/docx-wasm/package.json index 70c5d3e..d7e5187 100644 --- a/docx-wasm/package.json +++ b/docx-wasm/package.json @@ -1,6 +1,6 @@ { "name": "docx-wasm", - "version": "0.0.246", + "version": "0.0.247", "main": "dist/node/index.js", "browser": "dist/web/index.js", "author": "bokuweb ", diff --git a/docx-wasm/src/run.rs b/docx-wasm/src/run.rs index 46a859b..574adbb 100644 --- a/docx-wasm/src/run.rs +++ b/docx-wasm/src/run.rs @@ -41,6 +41,11 @@ impl Run { self } + pub fn style(mut self, style: &str) -> Run { + self.0.run_property = self.0.run_property.style(style); + self + } + pub fn size(mut self, size: usize) -> Run { self.0.run_property = self.0.run_property.size(size); self