nehan
Version:
Html layout engine for paged-media written in Typescript
54 lines • 1.62 kB
JavaScript
import { TextEmphasisStyle, CssCascade, } from "./public-api";
export class TextEmphasis {
constructor() { }
static parseShorthand(cssText) {
let vals = cssText.split();
let declr = [];
if (cssText.value === "none" || vals.length === 0) {
return declr;
}
let stroke = "", mark = "", color = "";
vals.forEach(value => {
if (TextEmphasisStyle.isStrokeValue(value)) {
stroke = value;
}
else if (TextEmphasisStyle.isMarkValue(value)) {
mark = value;
}
else {
color = value;
}
});
let style = [stroke, mark].join(" ").trim();
if (style !== "") {
declr.push({ prop: "text-emphasis-style", value: style });
}
if (color !== "") {
declr.push({ prop: "text-emphasis-color", value: color });
}
return declr;
}
static load(element) {
let textEmpha = new TextEmphasis();
textEmpha.style = TextEmphasisStyle.load(element);
textEmpha.color = TextEmphasis.loadColor(element);
return textEmpha;
}
static loadColor(element) {
return CssCascade.getValue(element, "text-emphasis-color");
}
get textEmphaData() {
return {
text: this.text,
styles: this.style.values,
scale: this.style.scale,
};
}
get text() {
return this.style.text;
}
isNone() {
return this.style.isNone();
}
}
//# sourceMappingURL=text-emphasis.js.map