diff --git a/packages/eui/changelogs/CHANGELOG_2025.md b/packages/eui/changelogs/CHANGELOG_2025.md index 24e7ffe814b..fc377ebf5e7 100644 --- a/packages/eui/changelogs/CHANGELOG_2025.md +++ b/packages/eui/changelogs/CHANGELOG_2025.md @@ -13,7 +13,7 @@ - Updated `EuiColorPalettePicker` - adds `append` to `EuiColorPalettePickerPaletteProps` to support appending custom content to the title ([#8208](https://github.com/elastic/eui/pull/8208)) - Updated font-weight and font-size of `EuiBetaBadge`s to improve legibility ([#8255](https://github.com/elastic/eui/pull/8255)) -- Added suppport for `titleColor` variant `warning` on `EuiStat` ([#8278](https://github.com/elastic/eui/pull/8278)) +- Added support for `titleColor` variant `warning` on `EuiStat` ([#8278](https://github.com/elastic/eui/pull/8278)) ## [`v99.0.0`](https://github.com/elastic/eui/releases/v99.0.0) diff --git a/packages/eui/changelogs/upcoming/8317.md b/packages/eui/changelogs/upcoming/8317.md new file mode 100644 index 00000000000..3faa3bcc806 --- /dev/null +++ b/packages/eui/changelogs/upcoming/8317.md @@ -0,0 +1 @@ +- Added ES|QL syntax highlighting for `EuiCode`, `EuiCodeBlock`, `EuiMarkdownFormat`, and `EuiMarkdownEditor` components. diff --git a/packages/eui/package.json b/packages/eui/package.json index 23fb7aaed71..f702e28a458 100644 --- a/packages/eui/package.json +++ b/packages/eui/package.json @@ -51,6 +51,7 @@ "url": "https://github.com/elastic/eui.git" }, "dependencies": { + "@elastic/prismjs-esql": "^1.0.0", "@hello-pangea/dnd": "^16.6.0", "@types/lodash": "^4.14.202", "@types/numeral": "^2.0.5", diff --git a/packages/eui/src/components/code/code.styles.ts b/packages/eui/src/components/code/code.styles.ts index 7ac66c1c218..62acdd6fd24 100644 --- a/packages/eui/src/components/code/code.styles.ts +++ b/packages/eui/src/components/code/code.styles.ts @@ -29,6 +29,11 @@ export const euiCodeStyles = (euiThemeContext: UseEuiTheme) => { color: ${codeSyntaxVariables.inlineCodeColor}; ${codeSyntaxVariables.tokensCss} + + .token.atrule .token.rule, + .token.keyword { + color: ${codeSyntaxVariables.inlineCodeKeywordColor}; + } `, transparentBackground: css` background: transparent; diff --git a/packages/eui/src/components/code/code_syntax.styles.ts b/packages/eui/src/components/code/code_syntax.styles.ts index 4a7b9e374bb..50c9b12b2a9 100644 --- a/packages/eui/src/components/code/code_syntax.styles.ts +++ b/packages/eui/src/components/code/code_syntax.styles.ts @@ -32,6 +32,9 @@ export const euiCodeSyntaxVariables = ({ euiTheme }: UseEuiTheme) => { nameColor: makeHighContrastColor(visColors[1])(backgroundColor), numberColor: makeHighContrastColor(visColors[0])(backgroundColor), keywordColor: makeHighContrastColor(visColors[3])(backgroundColor), + inlineCodeKeywordColor: makeHighContrastColor(visColors[6])( + backgroundColor + ), functionTitleColor: 'inherit', typeColor: makeHighContrastColor(visColors[1])(backgroundColor), attributeColor: 'inherit', diff --git a/packages/eui/src/components/code/utils.tsx b/packages/eui/src/components/code/utils.tsx index 9305299919f..7790f58f91e 100644 --- a/packages/eui/src/components/code/utils.tsx +++ b/packages/eui/src/components/code/utils.tsx @@ -12,8 +12,16 @@ import React, { ReactNode, HTMLAttributes, } from 'react'; -import { listLanguages, highlight, AST, RefractorNode } from 'refractor'; +import { + listLanguages, + highlight, + AST, + RefractorNode, + register, + type RefractorSyntax, +} from 'refractor'; import { cx } from '@emotion/css'; +import { esql as esqlLanguage } from '@elastic/prismjs-esql'; import { CommonProps } from '../common'; import { UseEuiTheme } from '../../services'; @@ -24,6 +32,8 @@ import { } from './code_block_annotations'; import { euiCodeBlockLineStyles } from './code_block_line.styles'; +register(esqlLanguage as RefractorSyntax); + /** * Utils shared between EuiCode and EuiCodeBlock */ diff --git a/yarn.lock b/yarn.lock index 017d126fa92..3b021db6653 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4770,6 +4770,7 @@ __metadata: "@cypress/webpack-dev-server": "npm:^1.7.0" "@elastic/charts": "npm:^64.1.0" "@elastic/datemath": "npm:^5.0.3" + "@elastic/prismjs-esql": "npm:^1.0.0" "@emotion/babel-preset-css-prop": "npm:^11.11.0" "@emotion/cache": "npm:^11.11.0" "@emotion/css": "npm:^11.11.0" @@ -4964,6 +4965,13 @@ __metadata: languageName: unknown linkType: soft +"@elastic/prismjs-esql@npm:^1.0.0": + version: 1.0.0 + resolution: "@elastic/prismjs-esql@npm:1.0.0" + checksum: 10c0/3cdf879859da03f5e68d6e730972e4142556c9dfb0eb2bc96bceb2ae2463e2c76a62af7335dd181c5b24716060879c8eac87ee98ae23a218aae3c2e1aabd63ef + languageName: node + linkType: hard + "@elastic/transport@npm:^8.9.1": version: 8.9.4 resolution: "@elastic/transport@npm:8.9.4"