Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow clip-path, background, text-emphasis styles in structured content #556

Merged
merged 3 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -348,6 +348,7 @@ export class StructuredContentGenerator {
fontWeight,
fontSize,
color,
background,
backgroundColor,
textDecorationLine,
textDecorationStyle,
Expand All @@ -356,8 +357,10 @@ export class StructuredContentGenerator {
borderStyle,
borderRadius,
borderWidth,
clipPath,
verticalAlign,
textAlign,
textEmphasis,
textShadow,
margin,
marginTop,
Expand All @@ -378,9 +381,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 @@ -397,6 +402,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
Loading