Limit the list of supported highlight colors (#2522)

* Limit the list of supported highlight colors

* Fix tests: use fixed highlight color values

---------

Co-authored-by: ilyasogonov <sogonov.ilya@customscard.ru>
This commit is contained in:
octoultra
2024-01-12 02:16:15 +02:00
committed by GitHub
parent 6b8e22368b
commit e20bd66663
5 changed files with 59 additions and 29 deletions

View File

@ -4,6 +4,7 @@ import { Formatter } from "@export/formatter";
import { AlignmentType, EmphasisMarkType, TabStopPosition } from "../paragraph";
import { UnderlineType } from "../paragraph/run/underline";
import { HighlightColor } from "../paragraph/run/properties";
import { ShadingType } from "../shading";
import { AbstractNumbering } from "./abstract-numbering";
import { LevelFormat, LevelSuffix } from "./level";
@ -2048,23 +2049,23 @@ describe("AbstractNumbering", () => {
const highlightTests = [
{
highlight: "005599",
expected: [{ "w:highlight": { _attr: { "w:val": "005599" } } }, { "w:highlightCs": { _attr: { "w:val": "005599" } } }],
highlight: HighlightColor.YELLOW,
expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }, { "w:highlightCs": { _attr: { "w:val": "yellow" } } }],
},
{
highlight: "005599",
highlight: HighlightColor.YELLOW,
highlightComplexScript: true,
expected: [{ "w:highlight": { _attr: { "w:val": "005599" } } }, { "w:highlightCs": { _attr: { "w:val": "005599" } } }],
expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }, { "w:highlightCs": { _attr: { "w:val": "yellow" } } }],
},
{
highlight: "005599",
highlight: HighlightColor.YELLOW,
highlightComplexScript: false,
expected: [{ "w:highlight": { _attr: { "w:val": "005599" } } }],
expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }],
},
{
highlight: "005599",
highlight: HighlightColor.YELLOW,
highlightComplexScript: "550099",
expected: [{ "w:highlight": { _attr: { "w:val": "005599" } } }, { "w:highlightCs": { _attr: { "w:val": "550099" } } }],
expected: [{ "w:highlight": { _attr: { "w:val": "yellow" } } }, { "w:highlightCs": { _attr: { "w:val": "550099" } } }],
},
];
highlightTests.forEach(({ highlight, highlightComplexScript, expected }) => {