parent
e363ad8183
commit
637c2a86f4
|
@ -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.278-rc14 (23. Jun, 2023)
|
||||
|
||||
- Support character spacing in run property
|
||||
|
||||
## docx-wasm@0.0.278-rc10 (23. Jun, 2023)
|
||||
|
||||
- Support character space control function
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::fs::File;
|
|||
use std::io::{Read, Write};
|
||||
|
||||
pub fn main() {
|
||||
let mut file = File::open("./584.docx").unwrap();
|
||||
let mut file = File::open("./hello.docx").unwrap();
|
||||
let mut buf = vec![];
|
||||
file.read_to_end(&mut buf).unwrap();
|
||||
|
||||
|
|
|
@ -302,6 +302,11 @@ impl Paragraph {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn character_spacing(mut self, spacing: i32) -> Self {
|
||||
self.property = self.property.character_spacing(spacing);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn delete(mut self, author: impl Into<String>, date: impl Into<String>) -> Self {
|
||||
self.property.run_property.del = Some(Delete::new().author(author).date(date));
|
||||
self
|
||||
|
|
|
@ -85,6 +85,11 @@ impl ParagraphProperty {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn character_spacing(mut self, spacing: i32) -> Self {
|
||||
self.run_property.character_spacing = Some(CharacterSpacing::new(spacing));
|
||||
self
|
||||
}
|
||||
|
||||
pub fn keep_next(mut self, v: bool) -> Self {
|
||||
self.keep_next = Some(v);
|
||||
self
|
||||
|
|
|
@ -89,8 +89,9 @@ impl ElementReader for RunProperty {
|
|||
XMLElement::Size => rp = rp.size(usize::from_str(&attributes[0].value)?),
|
||||
XMLElement::Spacing => {
|
||||
if let Some(v) = read_val(&attributes) {
|
||||
let v = value_to_dax(&v)?;
|
||||
rp = rp.spacing(v)
|
||||
if let Ok(s) = i32::from_str(&v) {
|
||||
rp = rp.spacing(s)
|
||||
}
|
||||
}
|
||||
}
|
||||
XMLElement::RunFonts => {
|
||||
|
|
|
@ -8,6 +8,7 @@ use super::errors;
|
|||
|
||||
#[cfg_attr(feature = "wasm", wasm_bindgen)]
|
||||
#[derive(Copy, Clone, PartialEq, Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum CharacterSpacingValues {
|
||||
DoNotCompress,
|
||||
CompressPunctuation,
|
||||
|
|
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
|
@ -12,10 +12,7 @@ import { setParagraphProperty } from "./paragraph-property";
|
|||
|
||||
import * as wasm from "./pkg";
|
||||
|
||||
type Child = | Paragraph
|
||||
| Table
|
||||
| Comment
|
||||
| Hyperlink;
|
||||
type Child = Paragraph | Table | Comment | Hyperlink;
|
||||
|
||||
function buildHyperlink(child: Hyperlink) {
|
||||
let hyperlink = wasm.createHyperlink(child.v, convertHyperlinkType(child));
|
||||
|
@ -90,6 +87,12 @@ function buildParagraph(child: Paragraph) {
|
|||
);
|
||||
}
|
||||
|
||||
if (child.property.runProperty.characterSpacing != null) {
|
||||
paragraph = paragraph.character_spacing(
|
||||
child.property.runProperty.characterSpacing
|
||||
);
|
||||
}
|
||||
|
||||
if (child.property.paragraphPropertyChange) {
|
||||
let change = wasm.createParagraphPropertyChange();
|
||||
change = change
|
||||
|
|
|
@ -13,8 +13,8 @@ export class DocDefaults {
|
|||
return this;
|
||||
}
|
||||
|
||||
spacing(spacing: number) {
|
||||
this.runProperty = { ...this.runProperty, spacing };
|
||||
characterSpacing(characterSpacing: number) {
|
||||
this.runProperty = { ...this.runProperty, characterSpacing };
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,8 +192,8 @@ export class Docx {
|
|||
return this;
|
||||
}
|
||||
|
||||
defaultSpacing(spacing: number) {
|
||||
this.styles.defaultSpacing(spacing);
|
||||
defaultCharacterSpacing(spacing: number) {
|
||||
this.styles.defaultCharacterSpacing(spacing);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -547,9 +547,9 @@ export class Docx {
|
|||
docx = docx.default_size(this.styles.docDefaults.runProperty.size);
|
||||
}
|
||||
|
||||
if (this.styles.docDefaults.runProperty?.spacing) {
|
||||
if (this.styles.docDefaults.runProperty?.characterSpacing) {
|
||||
docx = docx.default_spacing(
|
||||
this.styles.docDefaults.runProperty.spacing
|
||||
this.styles.docDefaults.runProperty.characterSpacing
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ export type RunPropertyJSON = {
|
|||
italicCs?: boolean | null;
|
||||
vanish?: boolean | null;
|
||||
specVanish?: boolean | null;
|
||||
spacing?: number | null;
|
||||
characterSpacing?: number | null;
|
||||
textBorder?: TextBorderJSON | null;
|
||||
ins?: InsertJSONData | null;
|
||||
del?: DeleteJSONData | null;
|
||||
|
|
|
@ -91,8 +91,8 @@ export class Level {
|
|||
return this;
|
||||
}
|
||||
|
||||
spacing(spacing: number) {
|
||||
this.runProperty = { ...this.runProperty, spacing };
|
||||
characterSpacing(characterSpacing: number) {
|
||||
this.runProperty = { ...this.runProperty, characterSpacing };
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,6 +106,11 @@ export class Paragraph {
|
|||
return this;
|
||||
}
|
||||
|
||||
characterSpacing(spacing: number) {
|
||||
this.property.runProperty.characterSpacing = spacing;
|
||||
return this;
|
||||
}
|
||||
|
||||
keepNext(v: boolean) {
|
||||
this.property = { ...this.property, keepNext: v };
|
||||
return this;
|
||||
|
|
|
@ -40,7 +40,7 @@ export type RunProperty = {
|
|||
underline?: string;
|
||||
vanish?: boolean;
|
||||
fonts?: RunFonts;
|
||||
spacing?: number;
|
||||
characterSpacing?: number;
|
||||
textBorder?: TextBorder;
|
||||
ins?: RunPropertyIns;
|
||||
del?: RunPropertyDel;
|
||||
|
@ -253,8 +253,8 @@ export class Run {
|
|||
return this;
|
||||
}
|
||||
|
||||
spacing(spacing: number) {
|
||||
this.property = { ...this.property, spacing };
|
||||
spacing(characterSpacing: number) {
|
||||
this.property = { ...this.property, characterSpacing };
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -373,8 +373,8 @@ export const setRunProperty = <T extends wasm.Run | wasm.Style>(
|
|||
target = target.vanish() as T;
|
||||
}
|
||||
|
||||
if (property.spacing != null) {
|
||||
target = target.spacing(property.spacing) as T;
|
||||
if (property.characterSpacing != null) {
|
||||
target = target.character_spacing(property.characterSpacing) as T;
|
||||
}
|
||||
|
||||
if (property.textBorder) {
|
||||
|
|
|
@ -128,8 +128,8 @@ export class Style {
|
|||
return this;
|
||||
}
|
||||
|
||||
spacing(spacing: number) {
|
||||
this._runProperty = { ...this._runProperty, spacing };
|
||||
characterSpacing(characterSpacing: number) {
|
||||
this._runProperty = { ...this._runProperty, characterSpacing };
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@ export class Styles {
|
|||
return this;
|
||||
}
|
||||
|
||||
defaultSpacing(spacing: number) {
|
||||
this.docDefaults.spacing(spacing);
|
||||
defaultCharacterSpacing(spacing: number) {
|
||||
this.docDefaults.characterSpacing(spacing);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "docx-wasm",
|
||||
"version": "0.0.278-rc10",
|
||||
"version": "0.0.278-rc14",
|
||||
"main": "dist/node/index.js",
|
||||
"browser": "dist/web/index.js",
|
||||
"author": "bokuweb <bokuweb12@gmail.com>",
|
||||
|
|
|
@ -188,6 +188,11 @@ impl Paragraph {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn character_spacing(mut self, spacing: i32) -> Self {
|
||||
self.0 = self.0.character_spacing(spacing);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn keep_next(mut self, v: bool) -> Self {
|
||||
self.0 = self.0.keep_next(v);
|
||||
self
|
||||
|
|
|
@ -96,7 +96,7 @@ impl Run {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn spacing(mut self, spacing: i32) -> Run {
|
||||
pub fn character_spacing(mut self, spacing: i32) -> Run {
|
||||
self.0.run_property = self.0.run_property.spacing(spacing);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ impl Style {
|
|||
self
|
||||
}
|
||||
|
||||
pub fn spacing(mut self, spacing: i32) -> Self {
|
||||
pub fn character_spacing(mut self, spacing: i32) -> Self {
|
||||
self.0.run_property = self.0.run_property.spacing(spacing);
|
||||
self
|
||||
}
|
||||
|
|
|
@ -581,7 +581,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "FB0AE6E2-8FB8-3345-A8FC-78CE6F3ABE4E",
|
||||
"docVars": Array [],
|
||||
|
@ -2689,7 +2689,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "3A5F0B6E-9417-4662-A075-C7869185C909",
|
||||
"docVars": Array [],
|
||||
|
@ -4235,7 +4235,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "A1898E6C-1AED-3C4D-9CCF-C24208DA732E",
|
||||
"docVars": Array [],
|
||||
|
@ -5908,7 +5908,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "4A9883C0-7AEC-574E-926D-DA6DB000DD90",
|
||||
"docVars": Array [],
|
||||
|
@ -7232,7 +7232,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "60C41423-192A-BA49-94E6-2051A402BFCA",
|
||||
"docVars": Array [],
|
||||
|
@ -10232,7 +10232,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "E43E077A-3477-A242-BD53-4313974E06A2",
|
||||
"docVars": Array [],
|
||||
|
@ -11124,7 +11124,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "B1317C39-ACCF-5B4D-BE97-FD2D73F14B00",
|
||||
"docVars": Array [],
|
||||
|
@ -12757,7 +12757,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "1D08889F-3E41-C046-8805-654C0B247DE3",
|
||||
"docVars": Array [],
|
||||
|
@ -14311,7 +14311,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "932EBF18-9F5F-C245-A499-C2EB430024C4",
|
||||
"docVars": Array [],
|
||||
|
@ -24096,7 +24096,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "10BE20B6-DCA9-7441-B548-606D7D9EDD92",
|
||||
"docVars": Array [],
|
||||
|
@ -26285,7 +26285,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "DoNotCompress",
|
||||
"characterSpacingControl": "doNotCompress",
|
||||
"defaultTabStop": 709,
|
||||
"docId": "70F68831-609A-4ACC-87CE-416E9D216976",
|
||||
"docVars": Array [
|
||||
|
@ -28051,7 +28051,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "A8BB00BC-8D6F-2840-B682-9341438874CF",
|
||||
"docVars": Array [],
|
||||
|
@ -29870,7 +29870,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "F952540B-8E26-9040-BEAB-F11A2F10B576",
|
||||
"docVars": Array [],
|
||||
|
@ -32388,7 +32388,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "D69B5D79-AA39-424E-9D58-EF8E35CE7D20",
|
||||
"docVars": Array [],
|
||||
|
@ -80862,7 +80862,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": false,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 851,
|
||||
"docId": "BF832BC0-91B3-4538-AB66-1291F36977FA",
|
||||
"docVars": Array [
|
||||
|
@ -102003,7 +102003,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": false,
|
||||
"characterSpacingControl": "DoNotCompress",
|
||||
"characterSpacingControl": "doNotCompress",
|
||||
"defaultTabStop": 720,
|
||||
"docId": null,
|
||||
"docVars": Array [
|
||||
|
@ -107948,7 +107948,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "F963E3C9-F24C-354B-A852-391D33A55DB4",
|
||||
"docVars": Array [],
|
||||
|
@ -117074,7 +117074,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": false,
|
||||
"characterSpacingControl": "DoNotCompress",
|
||||
"characterSpacingControl": "doNotCompress",
|
||||
"defaultTabStop": 720,
|
||||
"docId": "D4D4776C-D5E8-4FE1-8892-3B40BC54EF41",
|
||||
"docVars": Array [],
|
||||
|
@ -127785,7 +127785,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "C272B628-6DE8-264A-8734-9D2219FFD42F",
|
||||
"docVars": Array [],
|
||||
|
@ -128806,7 +128806,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "C11ED300-8EA6-3D41-8D67-5E5DE3410CF8",
|
||||
"docVars": Array [],
|
||||
|
@ -130162,7 +130162,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "67BB3557-1628-9C4D-816A-CC1F65CA4B80",
|
||||
"docVars": Array [],
|
||||
|
@ -133611,7 +133611,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "A3F1E202-8404-D445-9EDD-BBC3885575A6",
|
||||
"docVars": Array [],
|
||||
|
@ -137258,7 +137258,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "9F52F717-3F03-584C-ACEF-96E0106FA905",
|
||||
"docVars": Array [],
|
||||
|
@ -138279,7 +138279,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 840,
|
||||
"docId": "7501A506-09EA-0F4C-ACFF-789B81CBED2D",
|
||||
"docVars": Array [],
|
||||
|
@ -147736,7 +147736,7 @@ Object {
|
|||
},
|
||||
"settings": Object {
|
||||
"adjustLineHeightInTable": true,
|
||||
"characterSpacingControl": "CompressPunctuation",
|
||||
"characterSpacingControl": "compressPunctuation",
|
||||
"defaultTabStop": 420,
|
||||
"docId": "A426FE01-5E89-4BAE-8422-F2CC8611EC68",
|
||||
"docVars": Array [],
|
||||
|
|
Loading…
Reference in New Issue