Skip to content

Commit

Permalink
Allow clip-path, background, text-emphasis styles in structured…
Browse files Browse the repository at this point in the history
… content (#556)

* Allow `clip-path` and `background` styles in structured content

* Allow `text-emphasis` style in structured content

---------

Co-authored-by: stephenmk <stephenmk@users.noreply.github.com>
  • Loading branch information
stephenmk and stephenmk authored Jan 31, 2024
1 parent 8f48d40 commit 6807b05
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
9 changes: 9 additions & 0 deletions ext/data/schemas/dictionary-term-bank-v3-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@
"color": {
"type": "string"
},
"background": {
"type": "string"
},
"backgroundColor": {
"type": "string"
},
Expand Down Expand Up @@ -318,6 +321,9 @@
"borderWidth": {
"type": "string"
},
"clipPath": {
"type": "string"
},
"verticalAlign": {
"type": "string",
"enum": ["baseline", "sub", "super", "text-top", "text-bottom", "middle", "top", "bottom"],
Expand All @@ -328,6 +334,9 @@
"enum": ["start", "end", "left", "right", "center", "justify", "justify-all", "match-parent"],
"default": "start"
},
"textEmphasis": {
"type": "string"
},
"textShadow": {
"type": "string"
},
Expand Down
6 changes: 6 additions & 0 deletions ext/js/display/sandbox/structured-content-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ export class StructuredContentGenerator {
fontWeight,
fontSize,
color,
background,
backgroundColor,
textDecorationLine,
textDecorationStyle,
Expand All @@ -355,8 +356,10 @@ export class StructuredContentGenerator {
borderStyle,
borderRadius,
borderWidth,
clipPath,
verticalAlign,
textAlign,
textEmphasis,
textShadow,
margin,
marginTop,
Expand All @@ -377,9 +380,11 @@ export class StructuredContentGenerator {
if (typeof fontWeight === 'string') { style.fontWeight = fontWeight; }
if (typeof fontSize === 'string') { style.fontSize = fontSize; }
if (typeof color === 'string') { style.color = color; }
if (typeof background === 'string') { style.background = background; }
if (typeof backgroundColor === 'string') { style.backgroundColor = backgroundColor; }
if (typeof verticalAlign === 'string') { style.verticalAlign = verticalAlign; }
if (typeof textAlign === 'string') { style.textAlign = textAlign; }
if (typeof textEmphasis === 'string') { style.textEmphasis = textEmphasis; }
if (typeof textShadow === 'string') { style.textShadow = textShadow; }
if (typeof textDecorationLine === 'string') {
style.textDecoration = textDecorationLine;
Expand All @@ -396,6 +401,7 @@ export class StructuredContentGenerator {
if (typeof borderStyle === 'string') { style.borderStyle = borderStyle; }
if (typeof borderRadius === 'string') { style.borderRadius = borderRadius; }
if (typeof borderWidth === 'string') { style.borderWidth = borderWidth; }
if (typeof clipPath === 'string') { style.clipPath = clipPath; }
if (typeof margin === 'string') { style.margin = margin; }
if (typeof marginTop === 'number') { style.marginTop = `${marginTop}em`; }
if (typeof marginTop === 'string') { style.marginTop = marginTop; }
Expand Down
8 changes: 4 additions & 4 deletions test/data/dictionaries/valid-dictionary1/term_bank_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
"style": {
"color": "#dd2121",
"textShadow": "0.5px 0.5px 1px gray",
"textEmphasis": "circle crimson",
"textDecorationLine": "underline",
"textDecorationStyle": "wavy",
"textDecorationColor": "red"
Expand Down Expand Up @@ -554,7 +555,7 @@
"padding": "0.15em 0.2em",
"borderRadius": "100%",
"cursor": "help",
"backgroundColor": "purple",
"background": "radial-gradient(purple 55%, black 100%)",
"color": "white"
},
"content": ""
Expand Down Expand Up @@ -609,11 +610,10 @@
"textAlign": "center"
},
"content": {
"tag": "span",
"tag": "div",
"title": "rarely used form",
"style": {
"padding": "0.15em 0.2em",
"borderRadius": "100%",
"clipPath": "circle()",
"cursor": "help",
"backgroundColor": "purple",
"color": "white"
Expand Down
3 changes: 3 additions & 0 deletions types/ext/structured-content.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type StructuredContentStyle = {
fontWeight?: FontWeight;
fontSize?: string;
color?: string;
background?: string;
backgroundColor?: string;
textDecorationLine?: TextDecorationLineOrNone | TextDecorationLine[];
textDecorationStyle?: TextDecorationStyle;
Expand All @@ -63,8 +64,10 @@ export type StructuredContentStyle = {
borderStyle?: string;
borderRadius?: string;
borderWidth?: string;
clipPath?: string;
verticalAlign?: VerticalAlign;
textAlign?: TextAlign;
textEmphasis?: string;
textShadow?: string;
margin?: string;
marginTop?: number | string;
Expand Down

0 comments on commit 6807b05

Please sign in to comment.