Merge branch 'master' into feat/refactor-bidi
# Conflicts: # demo/demo22.js # src/file/paragraph/run/run.ts
This commit is contained in:
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
# docx
|
# docx
|
||||||
|
|
||||||
|
<img src="https://thumbs.gfycat.com/ComplexEminentEquine-size_restricted.gif" alt="drawing" width="800"/>
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
@ -2,11 +2,23 @@ const docx = require('../build');
|
|||||||
|
|
||||||
var doc = new docx.Document();
|
var doc = new docx.Document();
|
||||||
|
|
||||||
var textRun = new docx.TextRun("שלום עולם").rightToLeft();
|
|
||||||
var paragraph = new docx.Paragraph().bidirectional();
|
|
||||||
paragraph.addRun(textRun);
|
|
||||||
|
|
||||||
doc.addParagraph(paragraph);
|
|
||||||
|
var paragraph1 = new docx.Paragraph().bidirectional();
|
||||||
|
var textRun1 = new docx.TextRun("שלום עולם").rightToLeft();
|
||||||
|
paragraph1.addRun(textRun1);
|
||||||
|
doc.addParagraph(paragraph1);
|
||||||
|
|
||||||
|
var paragraph2 = new docx.Paragraph().bidirectional();
|
||||||
|
var textRun2 = new docx.TextRun("שלום עולם").bold().rightToLeft();
|
||||||
|
paragraph2.addRun(textRun2);
|
||||||
|
doc.addParagraph(paragraph2);
|
||||||
|
|
||||||
|
var paragraph3 = new docx.Paragraph().bidirectional();
|
||||||
|
var textRun3 = new docx.TextRun("שלום עולם").italic().rightToLeft();
|
||||||
|
paragraph3.addRun(textRun3);
|
||||||
|
doc.addParagraph(paragraph3);
|
||||||
|
|
||||||
|
|
||||||
var exporter = new docx.LocalPacker(doc);
|
var exporter = new docx.LocalPacker(doc);
|
||||||
exporter.pack('My Document');
|
exporter.pack('My Document');
|
||||||
|
@ -14,6 +14,17 @@ export class Bold extends XmlComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class BoldComplexScript extends XmlComponent {
|
||||||
|
constructor() {
|
||||||
|
super("w:bCs");
|
||||||
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
|
val: true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class Italics extends XmlComponent {
|
export class Italics extends XmlComponent {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:i");
|
super("w:i");
|
||||||
@ -25,6 +36,17 @@ export class Italics extends XmlComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class ItalicsComplexScript extends XmlComponent {
|
||||||
|
constructor() {
|
||||||
|
super("w:iCs");
|
||||||
|
this.root.push(
|
||||||
|
new Attributes({
|
||||||
|
val: true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class Caps extends XmlComponent {
|
export class Caps extends XmlComponent {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("w:caps");
|
super("w:caps");
|
||||||
|
@ -16,6 +16,7 @@ describe("Run", () => {
|
|||||||
run.bold();
|
run.bold();
|
||||||
const newJson = Utility.jsonify(run);
|
const newJson = Utility.jsonify(run);
|
||||||
assert.equal(newJson.root[0].root[0].rootKey, "w:b");
|
assert.equal(newJson.root[0].root[0].rootKey, "w:b");
|
||||||
|
assert.equal(newJson.root[0].root[1].rootKey, "w:bCs");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ describe("Run", () => {
|
|||||||
run.italic();
|
run.italic();
|
||||||
const newJson = Utility.jsonify(run);
|
const newJson = Utility.jsonify(run);
|
||||||
assert.equal(newJson.root[0].root[0].rootKey, "w:i");
|
assert.equal(newJson.root[0].root[0].rootKey, "w:i");
|
||||||
|
assert.equal(newJson.root[0].root[1].rootKey, "w:iCs");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,7 +1,18 @@
|
|||||||
// http://officeopenxml.com/WPtext.php
|
// http://officeopenxml.com/WPtext.php
|
||||||
import { Break } from "./break";
|
import { Break } from "./break";
|
||||||
import { Caps, SmallCaps } from "./caps";
|
import { Caps, SmallCaps } from "./caps";
|
||||||
import { Bold, Color, DoubleStrike, Italics, RightToLeft, Size, SizeComplexScript, Strike } from "./formatting";
|
import {
|
||||||
|
Bold,
|
||||||
|
BoldComplexScript,
|
||||||
|
Color,
|
||||||
|
DoubleStrike,
|
||||||
|
Italics,
|
||||||
|
ItalicsComplexScript,
|
||||||
|
RightToLeft,
|
||||||
|
Size,
|
||||||
|
SizeComplexScript,
|
||||||
|
Strike,
|
||||||
|
} from "./formatting";
|
||||||
import { Begin, End, Page, Separate } from "./page-number";
|
import { Begin, End, Page, Separate } from "./page-number";
|
||||||
import { RunProperties } from "./properties";
|
import { RunProperties } from "./properties";
|
||||||
import { RunFonts } from "./run-fonts";
|
import { RunFonts } from "./run-fonts";
|
||||||
@ -23,11 +34,13 @@ export class Run extends XmlComponent {
|
|||||||
|
|
||||||
public bold(): Run {
|
public bold(): Run {
|
||||||
this.properties.push(new Bold());
|
this.properties.push(new Bold());
|
||||||
|
this.properties.push(new BoldComplexScript());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public italic(): Run {
|
public italic(): Run {
|
||||||
this.properties.push(new Italics());
|
this.properties.push(new Italics());
|
||||||
|
this.properties.push(new ItalicsComplexScript());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user