-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-latest-kb-docs
- Loading branch information
Showing
8 changed files
with
185 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...ns/security_solution/public/assistant/get_comments/custom_codeblock/custom_code_block.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { EuiCodeBlock, EuiFlexGroup, EuiFlexItem, EuiPanel, useEuiTheme } from '@elastic/eui'; | ||
import { css } from '@emotion/css'; | ||
import React from 'react'; | ||
|
||
export const CustomCodeBlock = ({ value }: { value: string }) => { | ||
const theme = useEuiTheme(); | ||
|
||
return ( | ||
<EuiPanel | ||
hasShadow={false} | ||
hasBorder={false} | ||
paddingSize="s" | ||
className={css` | ||
background-color: ${theme.euiTheme.colors.lightestShade}; | ||
.euiCodeBlock__pre { | ||
margin-bottom: 0; | ||
padding: ${theme.euiTheme.size.m}; | ||
min-block-size: 48px; | ||
} | ||
.euiCodeBlock__controls { | ||
inset-block-start: ${theme.euiTheme.size.m}; | ||
inset-inline-end: ${theme.euiTheme.size.m}; | ||
} | ||
`} | ||
> | ||
<EuiFlexGroup direction="column" gutterSize="xs"> | ||
<EuiFlexItem grow={false}> | ||
<EuiCodeBlock isCopyable fontSize="m"> | ||
{value} | ||
</EuiCodeBlock> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiPanel> | ||
); | ||
}; |
35 changes: 35 additions & 0 deletions
35
...ution/public/assistant/get_comments/custom_codeblock/custom_codeblock_markdown_plugin.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { Node } from 'unist'; | ||
import type { Parent } from 'mdast'; | ||
|
||
export const customCodeBlockLanguagePlugin = () => { | ||
const visitor = (node: Node, parent?: Parent) => { | ||
if ('children' in node) { | ||
const nodeAsParent = node as Parent; | ||
nodeAsParent.children.forEach((child) => { | ||
visitor(child, nodeAsParent); | ||
}); | ||
} | ||
|
||
if ( | ||
node.type === 'code' && | ||
(node.lang === 'eql' || | ||
node.lang === 'esql' || | ||
node.lang === 'kql' || | ||
node.lang === 'dsl' || | ||
node.lang === 'json') | ||
) { | ||
node.type = 'customCodeBlock'; | ||
} | ||
}; | ||
|
||
return (tree: Node) => { | ||
visitor(tree); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters