Add new structured content styling options (#2203)

Allow for arbitrary string assignment to the font-size property.
https://developer.mozilla.org/en-US/docs/Web/CSS/font-size

Add support for the text-align property.
https://developer.mozilla.org/en-US/docs/Web/CSS/text-align

Co-authored-by: stephenmk <stephenmk@users.noreply.github.com>
This commit is contained in:
Stephen Kraus 2022-08-14 12:30:25 -05:00 committed by GitHub
parent 289a61a62f
commit c331ceae99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 3 deletions

View File

@ -252,7 +252,6 @@
}, },
"fontSize": { "fontSize": {
"type": "string", "type": "string",
"enum": ["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "xxx-large"],
"default": "medium" "default": "medium"
}, },
"textDecorationLine": { "textDecorationLine": {
@ -277,6 +276,11 @@
"enum": ["baseline", "sub", "super", "text-top", "text-bottom", "middle", "top", "bottom"], "enum": ["baseline", "sub", "super", "text-top", "text-bottom", "middle", "top", "bottom"],
"default": "baseline" "default": "baseline"
}, },
"textAlign": {
"type": "string",
"enum": ["start", "end", "left", "right", "center", "justify", "justify-all", "match-parent"],
"default": "start"
},
"marginTop": { "marginTop": {
"type": "number", "type": "number",
"default": 0 "default": 0

View File

@ -265,6 +265,7 @@ class StructuredContentGenerator {
fontSize, fontSize,
textDecorationLine, textDecorationLine,
verticalAlign, verticalAlign,
textAlign,
marginTop, marginTop,
marginLeft, marginLeft,
marginRight, marginRight,
@ -275,6 +276,7 @@ class StructuredContentGenerator {
if (typeof fontWeight === 'string') { style.fontWeight = fontWeight; } if (typeof fontWeight === 'string') { style.fontWeight = fontWeight; }
if (typeof fontSize === 'string') { style.fontSize = fontSize; } if (typeof fontSize === 'string') { style.fontSize = fontSize; }
if (typeof verticalAlign === 'string') { style.verticalAlign = verticalAlign; } if (typeof verticalAlign === 'string') { style.verticalAlign = verticalAlign; }
if (typeof textAlign === 'string') { style.textAlign = textAlign; }
if (typeof textDecorationLine === 'string') { if (typeof textDecorationLine === 'string') {
style.textDecoration = textDecorationLine; style.textDecoration = textDecorationLine;
} else if (Array.isArray(textDecorationLine)) { } else if (Array.isArray(textDecorationLine)) {

View File

@ -83,9 +83,13 @@
{"tag": "div", "style": {"fontWeight": "bold"}, "content": "fontWeight:bold"}, {"tag": "div", "style": {"fontWeight": "bold"}, "content": "fontWeight:bold"},
{"tag": "div", "style": {"fontSize": "xx-small"}, "content": "fontSize:xx-small"}, {"tag": "div", "style": {"fontSize": "xx-small"}, "content": "fontSize:xx-small"},
{"tag": "div", "style": {"fontSize": "x-small"}, "content": "fontSize:x-small"}, {"tag": "div", "style": {"fontSize": "x-small"}, "content": "fontSize:x-small"},
{"tag": "div", "style": {"fontSize": "70%"}, "content": "fontSize:70%"},
{"tag": "div", "style": {"fontSize": "smaller"}, "content": "fontSize:smaller"},
{"tag": "div", "style": {"fontSize": "small"}, "content": "fontSize:small"}, {"tag": "div", "style": {"fontSize": "small"}, "content": "fontSize:small"},
{"tag": "div", "style": {"fontSize": "medium"}, "content": "fontSize:medium"}, {"tag": "div", "style": {"fontSize": "medium"}, "content": "fontSize:medium"},
{"tag": "div", "style": {"fontSize": "large"}, "content": "fontSize:large"}, {"tag": "div", "style": {"fontSize": "large"}, "content": "fontSize:large"},
{"tag": "div", "style": {"fontSize": "larger"}, "content": "fontSize:larger"},
{"tag": "div", "style": {"fontSize": "130%"}, "content": "fontSize:130%"},
{"tag": "div", "style": {"fontSize": "x-large"}, "content": "fontSize:x-large"}, {"tag": "div", "style": {"fontSize": "x-large"}, "content": "fontSize:x-large"},
{"tag": "div", "style": {"fontSize": "xx-large"}, "content": "fontSize:xx-large"}, {"tag": "div", "style": {"fontSize": "xx-large"}, "content": "fontSize:xx-large"},
{"tag": "div", "style": {"fontSize": "xxx-large"}, "content": "fontSize:xxx-large"}, {"tag": "div", "style": {"fontSize": "xxx-large"}, "content": "fontSize:xxx-large"},
@ -137,6 +141,15 @@
]}, ]},
{"tag": "tr", "content": [ {"tag": "tr", "content": [
{"tag": "td", "content": "Cell A4"} {"tag": "td", "content": "Cell A4"}
]},
{"tag": "tr", "content": [
{"tag": "td", "content": "Cell A5", "colSpan": 4, "style": {"textAlign": "left"}}
]},
{"tag": "tr", "content": [
{"tag": "td", "content": "Cell A6", "colSpan": 4, "style": {"textAlign": "center"}}
]},
{"tag": "tr", "content": [
{"tag": "td", "content": "Cell A7", "colSpan": 4, "style": {"textAlign": "right"}}
]} ]}
]}, ]},
{"tag": "tfoot", "content": [ {"tag": "tfoot", "content": [
@ -230,8 +243,8 @@
{"tag": "ul", "content": [ {"tag": "ul", "content": [
{"tag": "li", "style": {"listStyleType": "'⇄'"}, "content": ["【", {"tag": "a", "href": "?query=よみ&wildcards=off", "content": ["Antonym"]}, "】"]}, {"tag": "li", "style": {"listStyleType": "'⇄'"}, "content": ["【", {"tag": "a", "href": "?query=よみ&wildcards=off", "content": ["Antonym"]}, "】"]},
{"tag": "li", "style": {"listStyleType": "'🔄'"}, "content": ["【", {"tag": "a", "href": "?query=よみ&wildcards=off", "content": ["References and is referenced by"]}, "】"]}, {"tag": "li", "style": {"listStyleType": "'🔄'"}, "content": ["【", {"tag": "a", "href": "?query=よみ&wildcards=off", "content": ["References and is referenced by"]}, "】"]},
{"tag": "li", "style": {"listStyleType": "'➡'"}, "content": ["【", {"tag": "a", "href": "?query=よみ&wildcards=off", "content": ["References"]}, "】"]}, {"tag": "li", "style": {"listStyleType": "'➡'"}, "content": ["【", {"tag": "a", "href": "?query=よみ&wildcards=off", "content": ["References"]}, "】"]},
{"tag": "li", "style": {"listStyleType": "'⬅'"}, "content": ["【", {"tag": "a", "href": "?query=よみ&wildcards=off", "content": ["Referenced by"]}, "】"]} {"tag": "li", "style": {"listStyleType": "'⬅'"}, "content": ["【", {"tag": "a", "href": "?query=よみ&wildcards=off", "content": ["Referenced by"]}, "】"]}
]} ]}
]}, ]},
{"type": "structured-content", "content": [ {"type": "structured-content", "content": [