From 9b8c8b6e97fa37e437263a5fe081e4e943f4adef Mon Sep 17 00:00:00 2001 From: bokuweb Date: Thu, 27 Feb 2025 15:53:59 +0900 Subject: [PATCH] fix: snap to grid for style (#805) --- docx-core/src/documents/elements/style.rs | 5 +++++ docx-core/src/documents/preset_styles/toc.rs | 1 + docx-wasm/js/style.ts | 5 +++++ docx-wasm/package.json | 2 +- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docx-core/src/documents/elements/style.rs b/docx-core/src/documents/elements/style.rs index 6b645f4..9a5c4be 100644 --- a/docx-core/src/documents/elements/style.rs +++ b/docx-core/src/documents/elements/style.rs @@ -130,6 +130,11 @@ impl Style { self } + pub fn snap_to_grid(mut self, v: bool) -> Self { + self.paragraph_property = self.paragraph_property.snap_to_grid(v); + self + } + pub fn indent( mut self, left: Option, diff --git a/docx-core/src/documents/preset_styles/toc.rs b/docx-core/src/documents/preset_styles/toc.rs index f80d20e..5147032 100644 --- a/docx-core/src/documents/preset_styles/toc.rs +++ b/docx-core/src/documents/preset_styles/toc.rs @@ -5,5 +5,6 @@ pub fn toc(level: i32) -> Style { Style::new(format!("ToC{}", level), StyleType::Paragraph) .name(format!("toc {}", level)) .align(AlignmentType::Both) + .snap_to_grid(false) .indent(Some((level - 1) * 200), None, None, Some((level - 1) * 100)) } diff --git a/docx-wasm/js/style.ts b/docx-wasm/js/style.ts index 86c3d72..c27c832 100644 --- a/docx-wasm/js/style.ts +++ b/docx-wasm/js/style.ts @@ -189,6 +189,11 @@ export class Style { return this; } + snapToGrid(v: boolean) { + this._paragraphProperty._snapToGrid = v; + return this; + } + pageBreakBefore(v: boolean) { this._paragraphProperty.pageBreakBefore = v; return this; diff --git a/docx-wasm/package.json b/docx-wasm/package.json index d10af73..5fe21f4 100644 --- a/docx-wasm/package.json +++ b/docx-wasm/package.json @@ -1,6 +1,6 @@ { "name": "docx-wasm", - "version": "0.4.18-rc38", + "version": "0.4.18-rc39", "main": "dist/node/index.js", "browser": "dist/web/index.js", "author": "bokuweb ",