parent
2897f0823c
commit
cfe2887387
24
CHANGELOG.md
24
CHANGELOG.md
|
@ -5,6 +5,30 @@ 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-rs@0.4.7 (23. Jun, 2023)
|
||||
|
||||
- Support character space control
|
||||
- Fix widow_control behavior
|
||||
- Support indent right for js
|
||||
- [Breaking] make docGrid optional
|
||||
- Support `<sym />`
|
||||
- Fixed a bug, style.link is not output.
|
||||
- Fixed a bug, escape style name.
|
||||
- Support `link` in style.
|
||||
- fix after contents in toc.
|
||||
- Support outline_level in Paragraph and style.
|
||||
- Support before/after contents in ToC.
|
||||
- Support Toc from instrText.
|
||||
- fix #584 Remove `%` from width.
|
||||
- fixed a bug, `adjustLineHeightInTable` is not affected in js interface.
|
||||
- fix lineRule ts type
|
||||
|
||||
|
||||
## docx-wasm@0.0.278-rc8 (23. Jun, 2023)
|
||||
|
||||
- Support character space control
|
||||
- Fix widow_control behavior
|
||||
|
||||
## docx-wasm@0.0.278-rc7 (19. Jun, 2023)
|
||||
|
||||
- Support indent right for js
|
||||
|
|
|
@ -143,7 +143,7 @@ checksum = "0e25ea47919b1560c4e3b7fe0aaab9becf5b84a10325ddf7db0f0ba5e1026499"
|
|||
|
||||
[[package]]
|
||||
name = "docx-rs"
|
||||
version = "0.4.6"
|
||||
version = "0.4.7"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"image",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "docx-rs"
|
||||
version = "0.4.6"
|
||||
version = "0.4.7"
|
||||
authors = ["bokuweb <bokuweb12@gmail.com>"]
|
||||
repository = "https://github.com/bokuweb/docx-rs"
|
||||
edition = "2018"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use super::*;
|
||||
|
||||
use crate::documents::BuildXML;
|
||||
use crate::types::{CharacterSpacingValues};
|
||||
use crate::types::CharacterSpacingValues;
|
||||
use crate::xml_builder::*;
|
||||
|
||||
use serde::Serialize;
|
||||
|
@ -15,6 +15,7 @@ pub struct Settings {
|
|||
doc_vars: Vec<DocVar>,
|
||||
even_and_odd_headers: bool,
|
||||
adjust_line_height_in_table: bool,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
character_spacing_control: Option<CharacterSpacingValues>,
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
use std::io::Read;
|
||||
use xml::reader::{EventReader, XmlEvent};
|
||||
use std::str::FromStr;
|
||||
use xml::reader::{EventReader, XmlEvent};
|
||||
|
||||
use super::*;
|
||||
use crate::reader::{FromXML, ReaderError};
|
||||
use crate::types::CharacterSpacingValues;
|
||||
|
||||
|
||||
impl FromXML for Settings {
|
||||
fn from_xml<R: Read>(reader: R) -> Result<Self, ReaderError> {
|
||||
let mut parser = EventReader::new(reader);
|
||||
|
@ -56,8 +55,9 @@ impl FromXML for Settings {
|
|||
XMLElement::CharacterSpacingControl => {
|
||||
let val = read_val(&attributes);
|
||||
if let Some(val) = val {
|
||||
settings = settings.character_spacing_control(
|
||||
CharacterSpacingValues::from_str(&val).unwrap());
|
||||
if let Ok(v) = CharacterSpacingValues::from_str(&val) {
|
||||
settings = settings.character_spacing_control(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -382,6 +382,25 @@ export class Docx {
|
|||
docx = docx.set_adjust_line_height_in_table();
|
||||
}
|
||||
|
||||
if (this.settings._characterSpacingControl) {
|
||||
if (this.settings._characterSpacingControl === "compressPunctuation") {
|
||||
docx = docx.character_spacing_control(
|
||||
wasm.CharacterSpacingValues.CompressPunctuation
|
||||
);
|
||||
} else if (this.settings._characterSpacingControl === "doNotCompress") {
|
||||
docx = docx.character_spacing_control(
|
||||
wasm.CharacterSpacingValues.DoNotCompress
|
||||
);
|
||||
} else if (
|
||||
this.settings._characterSpacingControl ===
|
||||
"compressPunctuationAndJapaneseKana"
|
||||
) {
|
||||
docx = docx.character_spacing_control(
|
||||
wasm.CharacterSpacingValues.CompressPunctuationAndJapaneseKana
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
docx = docx.default_tab_stop(this.settings._defaultTabStop);
|
||||
|
||||
this.settings._docVars.forEach((v) => {
|
||||
|
|
|
@ -5,6 +5,7 @@ import { CommentJSON } from "./comment";
|
|||
import { WebSettingsJSON } from "./web-settings";
|
||||
|
||||
import { Theme as ThemeJSON } from "./bindings/Theme";
|
||||
import { CharacterSpacingValues } from "../settings";
|
||||
|
||||
export type DocxJSON = {
|
||||
contentType: {
|
||||
|
@ -57,10 +58,12 @@ export type SettingsJSON = {
|
|||
docId: string | null;
|
||||
defaultTabStop: number;
|
||||
adjustLineHeightInTable: boolean;
|
||||
characterSpacingControl?: CharacterSpacingValues | null;
|
||||
zoom: number;
|
||||
docVars: { name: string; val: string }[];
|
||||
};
|
||||
|
||||
export * from "../settings";
|
||||
export * from "./styles";
|
||||
export * from "./border";
|
||||
export * from "./document";
|
||||
|
|
|
@ -3,11 +3,17 @@ export type DocVar = {
|
|||
val: string;
|
||||
};
|
||||
|
||||
export type CharacterSpacingValues =
|
||||
| "doNotCompress"
|
||||
| "compressPunctuation"
|
||||
| "compressPunctuationAndJapaneseKana";
|
||||
|
||||
export class Settings {
|
||||
_docId: string | null = null;
|
||||
_docVars: DocVar[] = [];
|
||||
_defaultTabStop = 840;
|
||||
_adjustLineHeightInTable = false;
|
||||
_characterSpacingControl: CharacterSpacingValues | null = null;
|
||||
|
||||
docId(id: string) {
|
||||
this._docId = id;
|
||||
|
@ -28,4 +34,9 @@ export class Settings {
|
|||
this._adjustLineHeightInTable = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
characterSpacingControl(t: CharacterSpacingValues) {
|
||||
this._characterSpacingControl = t;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "docx-wasm",
|
||||
"version": "0.0.278-rc7",
|
||||
"version": "0.0.278-rc8",
|
||||
"main": "dist/node/index.js",
|
||||
"browser": "dist/web/index.js",
|
||||
"author": "bokuweb <bokuweb12@gmail.com>",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use super::*;
|
||||
use docx_rs::CharacterSpacingValues;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
extern crate console_error_panic_hook;
|
||||
|
@ -87,6 +88,11 @@ impl Docx {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn character_spacing_control(mut self, v: CharacterSpacingValues) -> Self {
|
||||
self.0.settings = self.0.settings.character_spacing_control(v);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn header(mut self, header: Header) -> Self {
|
||||
self.0 = self.0.header(header.take());
|
||||
self
|
||||
|
|
|
@ -1446,7 +1446,6 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": null,
|
||||
"defaultTabStop": 840,
|
||||
"docId": null,
|
||||
"docVars": Array [],
|
||||
|
@ -5545,7 +5544,6 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": null,
|
||||
"defaultTabStop": 709,
|
||||
"docId": "50d61cff-8055-4197-917b-3993d0243c46",
|
||||
"docVars": Array [],
|
||||
|
@ -20082,7 +20080,6 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": false,
|
||||
"characterSpacingControl": null,
|
||||
"defaultTabStop": 840,
|
||||
"docId": null,
|
||||
"docVars": Array [],
|
||||
|
@ -22920,7 +22917,6 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": null,
|
||||
"defaultTabStop": 840,
|
||||
"docId": null,
|
||||
"docVars": Array [],
|
||||
|
|
Loading…
Reference in New Issue