UNPKG

nehan

Version:

Html layout engine for paged-media written in Typescript

62 lines 1.87 kB
import { CssText, CssCascade, } from "./public-api"; const EmphaEncodeMaps = { "filled dot": "\u2022", "open dot": "\u25E6", "filled circle": "\u25CF", "open circle": "\u25CB", "filled double-circle": "\u25C9", "open double-circle": "\u25CE", "filled triangle": "\u25B2", "open triangle": "\u25B3", "filled sesame": "\uFE45", "open sesame": "\uFE46" }; export class TextEmphasisStyle { constructor(stroke, mark) { this.stroke = stroke; this.mark = mark; } static isStrokeValue(value) { return value === "filled" || value === "open"; } static isMarkValue(value) { return value === "dot" || value === "circle" || value === "double-circle" || value === "triangle" || value === "sesame"; } static load(element) { const value = CssCascade.getValue(element, this.property); const cssText = new CssText({ prop: this.property, value: value }); let stroke = "none"; let mark = "dot"; cssText.split().forEach(value => { if (this.isStrokeValue(value)) { stroke = value; } else if (this.isMarkValue(value)) { mark = value; } }); return new TextEmphasisStyle(stroke, mark); } get values() { return [this.stroke, this.mark]; } get scale() { switch (this.mark) { case "circle": case "double-circle": case "triangle": case "sesame": return 0.5; } return 1.0; } get text() { const key = this.values.join(" "); return EmphaEncodeMaps[key] || "\u2022"; } isNone() { return this.stroke === 'none'; } } TextEmphasisStyle.property = "text-emphasis-style"; //# sourceMappingURL=text-emphasis-style.js.map