use hexColorValue in borders and underlines

This commit is contained in:
Tom Hunkapiller
2021-05-24 08:42:34 +03:00
parent ee105cdb83
commit 097c6a5962
16 changed files with 59 additions and 52 deletions

View File

@ -10,25 +10,25 @@ describe("Border", () => {
it("should create", () => {
const border = new Border({
top: {
color: "red",
color: "FF0000",
space: 1,
style: BorderStyle.WAVE,
size: 2,
},
bottom: {
color: "red",
color: "FF0000",
space: 3,
style: BorderStyle.WAVE,
size: 4,
},
left: {
color: "red",
color: "FF0000",
space: 5,
style: BorderStyle.WAVE,
size: 6,
},
right: {
color: "red",
color: "FF0000",
space: 7,
style: BorderStyle.WAVE,
size: 8,
@ -42,7 +42,7 @@ describe("Border", () => {
{
"w:top": {
_attr: {
"w:color": "red",
"w:color": "FF0000",
"w:space": 1,
"w:sz": 2,
"w:val": "wave",
@ -52,7 +52,7 @@ describe("Border", () => {
{
"w:bottom": {
_attr: {
"w:color": "red",
"w:color": "FF0000",
"w:space": 3,
"w:sz": 4,
"w:val": "wave",
@ -62,7 +62,7 @@ describe("Border", () => {
{
"w:left": {
_attr: {
"w:color": "red",
"w:color": "FF0000",
"w:space": 5,
"w:sz": 6,
"w:val": "wave",
@ -72,7 +72,7 @@ describe("Border", () => {
{
"w:right": {
_attr: {
"w:color": "red",
"w:color": "FF0000",
"w:space": 7,
"w:sz": 8,
"w:val": "wave",

View File

@ -43,7 +43,7 @@ describe("SymbolRun", () => {
italics: true,
bold: true,
underline: {
color: "red",
color: "ff0000",
type: UnderlineType.DOUBLE,
},
emphasisMark: {
@ -63,7 +63,7 @@ describe("SymbolRun", () => {
{ "w:bCs": { _attr: { "w:val": true } } },
{ "w:i": { _attr: { "w:val": true } } },
{ "w:iCs": { _attr: { "w:val": true } } },
{ "w:u": { _attr: { "w:val": "double", "w:color": "red" } } },
{ "w:u": { _attr: { "w:val": "double", "w:color": "ff0000" } } },
{ "w:em": { _attr: { "w:val": "dot" } } },
{ "w:color": { _attr: { "w:val": "00FF00" } } },
{ "w:sz": { _attr: { "w:val": 40 } } },

View File

@ -1,3 +1,4 @@
import { hexColorValue } from "file/values";
import { Attributes, XmlComponent } from "file/xml-components";
export enum UnderlineType {
@ -26,7 +27,7 @@ export abstract class BaseUnderline extends XmlComponent {
this.root.push(
new Attributes({
val: underlineType,
color: color,
color: color === undefined ? color : hexColorValue(color),
}),
);
}