@atlaskit/code 14.6.1 → 14.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/internal/theme/constants.js +2 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/internal/theme/constants.js +1 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/internal/theme/constants.js +1 -0
- package/dist/esm/version.json +1 -1
- package/dist/types-ts4.5/bidi-warning/bidi-warning-decorator.d.ts +12 -0
- package/dist/types-ts4.5/bidi-warning/index.d.ts +1 -0
- package/dist/types-ts4.5/bidi-warning/ui/index.d.ts +11 -0
- package/dist/types-ts4.5/bidi-warning/ui/styled.d.ts +8 -0
- package/dist/types-ts4.5/bidi-warning/ui/types.d.ts +29 -0
- package/dist/types-ts4.5/code-block.d.ts +13 -0
- package/dist/types-ts4.5/code.d.ts +16 -0
- package/dist/types-ts4.5/constants.d.ts +625 -0
- package/dist/types-ts4.5/entry-points/block.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/constants.d.ts +1 -0
- package/dist/types-ts4.5/entry-points/inline.d.ts +2 -0
- package/dist/types-ts4.5/entry-points/types.d.ts +1 -0
- package/dist/types-ts4.5/extract-react-types/code-block.d.ts +47 -0
- package/dist/types-ts4.5/extract-react-types/code.d.ts +2 -0
- package/dist/types-ts4.5/index.d.ts +4 -0
- package/dist/types-ts4.5/internal/hooks/use-highlight.d.ts +6 -0
- package/dist/types-ts4.5/internal/theme/constants.d.ts +8 -0
- package/dist/types-ts4.5/internal/theme/get-theme.d.ts +7 -0
- package/dist/types-ts4.5/internal/theme/styles.d.ts +27 -0
- package/dist/types-ts4.5/internal/theme/types.d.ts +57 -0
- package/dist/types-ts4.5/internal/types.d.ts +70 -0
- package/dist/types-ts4.5/internal/utils/get-normalized-language.d.ts +2 -0
- package/dist/types-ts4.5/syntax-highlighter/async.d.ts +3 -0
- package/dist/types-ts4.5/syntax-highlighter/index.d.ts +36 -0
- package/dist/types-ts4.5/syntax-highlighter/lib/highlight.d.ts +12 -0
- package/dist/types-ts4.5/syntax-highlighter/lib/process/create-line-element.d.ts +9 -0
- package/dist/types-ts4.5/syntax-highlighter/lib/process/create-line.d.ts +3 -0
- package/dist/types-ts4.5/syntax-highlighter/lib/process/flatten-code-tree.d.ts +2 -0
- package/dist/types-ts4.5/syntax-highlighter/lib/process/get-code-tree.d.ts +2 -0
- package/dist/types-ts4.5/syntax-highlighter/lib/process/get-inline-line-number.d.ts +2 -0
- package/dist/types-ts4.5/syntax-highlighter/lib/process/index.d.ts +17 -0
- package/dist/types-ts4.5/syntax-highlighter/lib/react-renderer/create-children.d.ts +3 -0
- package/dist/types-ts4.5/syntax-highlighter/lib/react-renderer/create-element.d.ts +7 -0
- package/dist/types-ts4.5/syntax-highlighter/lib/react-renderer/index.d.ts +15 -0
- package/dist/types-ts4.5/syntax-highlighter/types.d.ts +129 -0
- package/dist/types-ts4.5/types.d.ts +31 -0
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Theme } from '@atlaskit/theme/types';
|
|
2
|
+
import type { CodeBlockTheme, CodeTheme } from './types';
|
|
3
|
+
export declare const getBaseTheme: (theme: Theme) => CodeTheme;
|
|
4
|
+
export declare const defaultBaseTheme: CodeTheme;
|
|
5
|
+
export declare const getColorPalette: import("memoize-one").MemoizedFn<(theme: Theme) => CodeBlockTheme>;
|
|
6
|
+
declare const getTheme: (theme: Theme) => CodeBlockTheme;
|
|
7
|
+
export default getTheme;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CSSObject } from '@emotion/react';
|
|
2
|
+
import type { Theme } from '@atlaskit/theme/types';
|
|
3
|
+
import type { CodeBlockTheme, CodeTheme } from './types';
|
|
4
|
+
export declare const getLineNumWidth: (numLines: number) => string;
|
|
5
|
+
/**
|
|
6
|
+
* Styles applied at the root element level, common across code/codeblock
|
|
7
|
+
*/
|
|
8
|
+
export declare const getBaseCodeStyles: (theme: CodeTheme) => {
|
|
9
|
+
fontSize: number;
|
|
10
|
+
fontFamily: string | undefined;
|
|
11
|
+
fontWeight: string;
|
|
12
|
+
backgroundColor: string;
|
|
13
|
+
color: string | undefined;
|
|
14
|
+
borderStyle: string;
|
|
15
|
+
borderRadius: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Takes an implemented CodeBlock theme, and returns styles required for
|
|
19
|
+
* react-syntax-highlighter.
|
|
20
|
+
*
|
|
21
|
+
* @param theme
|
|
22
|
+
*/
|
|
23
|
+
export declare const getCodeBlockStyles: (theme: CodeBlockTheme) => (highlightedStartText: string, highlightedEndText: string, showLineNumbers: boolean, shouldWrapLongLines: boolean) => CSSObject;
|
|
24
|
+
export declare const getCodeStyles: (globalTheme: Theme | {
|
|
25
|
+
theme: Theme;
|
|
26
|
+
}) => CSSObject;
|
|
27
|
+
export declare const getCodeBlockTheme: (globalTheme: Theme, maxLines?: number) => CodeBlockTheme;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export interface CodeTheme {
|
|
2
|
+
backgroundColor?: string;
|
|
3
|
+
textColor?: string;
|
|
4
|
+
fontFamilyItalic?: string;
|
|
5
|
+
fontFamily?: string;
|
|
6
|
+
lineNumberColor?: string;
|
|
7
|
+
lineNumberBgColor?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface CodeBlockTheme extends CodeTheme {
|
|
10
|
+
substringColor?: string;
|
|
11
|
+
keywordColor?: string;
|
|
12
|
+
attributeColor?: string;
|
|
13
|
+
selectorTagColor?: string;
|
|
14
|
+
docTagColor?: string;
|
|
15
|
+
nameColor?: string;
|
|
16
|
+
builtInColor?: string;
|
|
17
|
+
literalColor?: string;
|
|
18
|
+
bulletColor?: string;
|
|
19
|
+
codeColor?: string;
|
|
20
|
+
additionColor?: string;
|
|
21
|
+
regexpColor?: string;
|
|
22
|
+
symbolColor?: string;
|
|
23
|
+
variableColor?: string;
|
|
24
|
+
templateVariableColor?: string;
|
|
25
|
+
linkColor?: string;
|
|
26
|
+
selectorAttributeColor?: string;
|
|
27
|
+
selectorPseudoColor?: string;
|
|
28
|
+
typeColor?: string;
|
|
29
|
+
stringColor?: string;
|
|
30
|
+
selectorIdColor?: string;
|
|
31
|
+
selectorClassColor?: string;
|
|
32
|
+
quoteColor?: string;
|
|
33
|
+
templateTagColor?: string;
|
|
34
|
+
deletionColor?: string;
|
|
35
|
+
titleColor?: string;
|
|
36
|
+
sectionColor?: string;
|
|
37
|
+
commentColor?: string;
|
|
38
|
+
metaKeywordColor?: string;
|
|
39
|
+
metaColor?: string;
|
|
40
|
+
functionColor?: string;
|
|
41
|
+
numberColor?: string;
|
|
42
|
+
prologColor?: string;
|
|
43
|
+
cdataColor?: string;
|
|
44
|
+
punctuationColor?: string;
|
|
45
|
+
propertyColor?: string;
|
|
46
|
+
constantColor?: string;
|
|
47
|
+
deletedColor?: string;
|
|
48
|
+
booleanColor?: string;
|
|
49
|
+
charColor?: string;
|
|
50
|
+
insertedColor?: string;
|
|
51
|
+
operatorColor?: string;
|
|
52
|
+
atruleColor?: string;
|
|
53
|
+
importantColor?: string;
|
|
54
|
+
highlightedLineBgColor?: string;
|
|
55
|
+
highlightedLineBorderColor?: string;
|
|
56
|
+
lineNumberWidth?: string | number;
|
|
57
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { SupportedLanguages } from '../constants';
|
|
2
|
+
export interface CodeBlockProps {
|
|
3
|
+
/**
|
|
4
|
+
* The code to be formatted.
|
|
5
|
+
*/
|
|
6
|
+
text: string;
|
|
7
|
+
/**
|
|
8
|
+
* A unique string that appears as a data attribute `data-testid` in the
|
|
9
|
+
* rendered code. Serves as a hook for automated tests.
|
|
10
|
+
*/
|
|
11
|
+
testId?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Sets whether to display code line numbers or not.
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
showLineNumbers?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Language reference designed to be populated from `SUPPORTED_LANGUAGES` in
|
|
19
|
+
* `design-system/code`. Run against language grammars from PrismJS (full list
|
|
20
|
+
* available at [PrismJS documentation](https://prismjs.com/#supported-languages)).
|
|
21
|
+
*
|
|
22
|
+
* When set to "text" will not perform highlighting. If unsupported language
|
|
23
|
+
* provided - code will be treated as "text" with no highlighting.
|
|
24
|
+
*
|
|
25
|
+
* @default 'text'
|
|
26
|
+
*/
|
|
27
|
+
language?: SupportedLanguages;
|
|
28
|
+
/**
|
|
29
|
+
* Comma delimited lines to highlight.
|
|
30
|
+
*
|
|
31
|
+
* Example uses:
|
|
32
|
+
* - To highlight one line `highlight="3"`
|
|
33
|
+
* - To highlight a group of lines `highlight="1-5"`
|
|
34
|
+
* - To highlight multiple groups `highlight="1-5,7,10,15-20"`
|
|
35
|
+
*/
|
|
36
|
+
highlight?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Screen reader text for the start of a highlighted line.
|
|
39
|
+
*/
|
|
40
|
+
highlightedStartText?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Screen reader text for the end of a highlighted line.
|
|
43
|
+
*/
|
|
44
|
+
highlightedEndText?: string;
|
|
45
|
+
/**
|
|
46
|
+
* When set to `false`, disables code decorating with bidi warnings.
|
|
47
|
+
* @default true
|
|
48
|
+
*/
|
|
49
|
+
codeBidiWarnings?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Label for the bidi warning tooltip.
|
|
52
|
+
* @default 'Bidirectional characters change the order that text is rendered. This could be used to obscure malicious code.'
|
|
53
|
+
*/
|
|
54
|
+
codeBidiWarningLabel?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Sets whether to render tooltip with the warning or not.
|
|
57
|
+
* Intended to be disabled when used in a mobile view, such as in the editor via mobile bridge,
|
|
58
|
+
* where the tooltip could end up being cut off or otherwise not work as expected.
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
codeBidiWarningTooltipEnabled?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Sets whether long lines will create a horizontally scrolling container.
|
|
64
|
+
* When set to `true`, these lines will visually wrap instead.
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
shouldWrapLongLines?: boolean;
|
|
68
|
+
}
|
|
69
|
+
export type { SupportedLanguages, LanguageAlias, Language } from '../constants';
|
|
70
|
+
export type { CodeBlockTheme, CodeTheme } from './theme/types';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Original library: https://github.com/react-syntax-highlighter/react-syntax-highlighter
|
|
3
|
+
* All modifications by Atlassian
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* MIT License
|
|
7
|
+
*
|
|
8
|
+
* Copyright (c) 2019 Conor Hastings
|
|
9
|
+
*
|
|
10
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
* in the Software without restriction, including without limitation the rights
|
|
13
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
* furnished to do so, subject to the following conditions:
|
|
16
|
+
*
|
|
17
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
* copies or substantial portions of the Software.
|
|
19
|
+
*
|
|
20
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
* SOFTWARE.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* __Syntax Highlighter__
|
|
30
|
+
*
|
|
31
|
+
* A syntax highlighter based on top of [refractor](https://github.com/wooorm/refractor).
|
|
32
|
+
* @atlaskit/code uses this under-the-hood, but it is not intended for public consumption.
|
|
33
|
+
* You should be using @atlaskit/code directly.
|
|
34
|
+
*/
|
|
35
|
+
import SyntaxHighlighter from './async';
|
|
36
|
+
export default SyntaxHighlighter;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SyntaxHighlighterProps } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Takes in a code string and (in the default behaviour):
|
|
5
|
+
* - Uses refractor to turn it into a tree structure with highlighting metadata
|
|
6
|
+
* - Collapses this tree into lines for a renderer
|
|
7
|
+
* - Passes these lines to a React renderer
|
|
8
|
+
*
|
|
9
|
+
* In future, the final step could have a custom renderer.
|
|
10
|
+
*/
|
|
11
|
+
declare const Highlight: import("react").NamedExoticComponent<SyntaxHighlighterProps>;
|
|
12
|
+
export default Highlight;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AST, RefractorNode, SyntaxHighlighterLineProps } from '../../types';
|
|
2
|
+
export type CreateLineElementProps = {
|
|
3
|
+
children: RefractorNode[];
|
|
4
|
+
lineNumber: number;
|
|
5
|
+
showLineNumbers?: boolean;
|
|
6
|
+
lineProps?: SyntaxHighlighterLineProps;
|
|
7
|
+
className?: string[];
|
|
8
|
+
};
|
|
9
|
+
export default function createLineElement({ children, lineNumber, showLineNumbers, lineProps, className, }: CreateLineElementProps): AST.Element;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { RefractorNode, SyntaxHighlighterLineProps } from '../../types';
|
|
2
|
+
declare function createLineGenerator(lineProps: SyntaxHighlighterLineProps, shouldCreateParentElementForLines: boolean, showLineNumbers: boolean): (children: RefractorNode[], lineNumber: number, className?: string[]) => RefractorNode | RefractorNode[];
|
|
3
|
+
export default createLineGenerator;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AstGenerator, RefractorNode, SyntaxHighlighterLineProps } from '../../types';
|
|
2
|
+
interface ProcessLines {
|
|
3
|
+
astGenerator: AstGenerator;
|
|
4
|
+
code: string;
|
|
5
|
+
language: string;
|
|
6
|
+
shouldCreateParentElementForLines: boolean;
|
|
7
|
+
lineProps: SyntaxHighlighterLineProps;
|
|
8
|
+
showLineNumbers: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* __Line Processor__
|
|
12
|
+
*
|
|
13
|
+
* A line processor, that uses refractor to turn code into a tree structure
|
|
14
|
+
* with highlighting metadata and collapses this tree into lines for a renderer.
|
|
15
|
+
*/
|
|
16
|
+
export default function processLines({ astGenerator, code, language, shouldCreateParentElementForLines, lineProps, showLineNumbers, }: ProcessLines): RefractorNode[];
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { CodeBidiWarningConfig, RefractorNode } from '../../types';
|
|
3
|
+
export default function createElement({ node, codeBidiWarningConfig, key, }: {
|
|
4
|
+
node: RefractorNode;
|
|
5
|
+
codeBidiWarningConfig: CodeBidiWarningConfig;
|
|
6
|
+
key: string;
|
|
7
|
+
}): ReactNode;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CodeBidiWarningConfig, RefractorNode } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* __React Renderer__
|
|
5
|
+
*
|
|
6
|
+
* A component that receives processed code lines and renders them into the code
|
|
7
|
+
* rows inside the wrapping span and nested code tag, applying passed props and
|
|
8
|
+
* code bidi warning config settings.
|
|
9
|
+
*/
|
|
10
|
+
export default function ReactRenderer({ containerProps, codeTagProps, rows, codeBidiWarningConfig, }: {
|
|
11
|
+
containerProps: React.HTMLProps<HTMLElement>;
|
|
12
|
+
codeTagProps: React.HTMLProps<HTMLElement>;
|
|
13
|
+
rows: RefractorNode[];
|
|
14
|
+
codeBidiWarningConfig: CodeBidiWarningConfig;
|
|
15
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SerializedStyles } from '@emotion/react';
|
|
3
|
+
import { AST, RefractorNode } from 'refractor';
|
|
4
|
+
export type { AST, RefractorNode } from 'refractor';
|
|
5
|
+
export declare class SyntaxHighlighter extends React.PureComponent<SyntaxHighlighterProps> {
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Function that receives current line number as argument and returns a
|
|
9
|
+
* line props object to be applied to each `span` wrapping code line.
|
|
10
|
+
*/
|
|
11
|
+
type lineTagPropsFunction = (lineNumber?: number) => AST.Properties;
|
|
12
|
+
/**
|
|
13
|
+
* Props to be passed to the `span` wrapping each code line. Can be an
|
|
14
|
+
* object or a function that receives current line number as argument and
|
|
15
|
+
* returns a props object.
|
|
16
|
+
*/
|
|
17
|
+
export type SyntaxHighlighterLineProps = lineTagPropsFunction | AST.Properties;
|
|
18
|
+
export interface SyntaxHighlighterProps {
|
|
19
|
+
/**
|
|
20
|
+
* A unique string that appears as a data attribute `data-testid`
|
|
21
|
+
* in the rendered code. Serves as a hook for automated tests.
|
|
22
|
+
*/
|
|
23
|
+
testId?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Language reference designed to be populated from `SUPPORTED_LANGUAGES` in
|
|
26
|
+
* `design-system/code`. Run against language grammars from PrismJS (full list
|
|
27
|
+
* available at [PrismJS documentation](https://prismjs.com/#supported-languages)).
|
|
28
|
+
*
|
|
29
|
+
* When set to "text" will not perform highlighting. If unsupported language
|
|
30
|
+
* provided - code will be treated as "text" with no highlighting.
|
|
31
|
+
* @default 'text'
|
|
32
|
+
*/
|
|
33
|
+
language?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Props to be passed to the `span` wrapping each line if
|
|
36
|
+
* `shouldCreateParentElementForLines` is `true`. Can be an object or a function
|
|
37
|
+
* that receives current line number as argument and returns a props object.
|
|
38
|
+
*/
|
|
39
|
+
lineProps?: SyntaxHighlighterLineProps;
|
|
40
|
+
/**
|
|
41
|
+
* Props to be passed to the `code` element that is the parent of all lines of code.
|
|
42
|
+
*/
|
|
43
|
+
codeTagProps?: React.HTMLProps<HTMLElement>;
|
|
44
|
+
/**
|
|
45
|
+
* Sets whether to display code line numbers or not. Defaults to `true`
|
|
46
|
+
*/
|
|
47
|
+
showLineNumbers?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Determines whether or not each line of code should be wrapped in a parent
|
|
50
|
+
* element.
|
|
51
|
+
*
|
|
52
|
+
* When set to false, can not take action on an element on the line level,
|
|
53
|
+
* meaning, for example, that props will not be passed down.
|
|
54
|
+
*
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
shouldCreateParentElementForLines?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Sets whether long lines will create a horizontally scrolling container.
|
|
60
|
+
* When set to `true`, these lines will visually wrap instead.
|
|
61
|
+
*
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
shouldWrapLongLines?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Serialized styles returned from Emotion's `css()` function.
|
|
67
|
+
*/
|
|
68
|
+
styles?: SerializedStyles;
|
|
69
|
+
/**
|
|
70
|
+
* `codeBidiWarnings` is set via a prop on @atlaskit/code/CodeBlock.
|
|
71
|
+
*
|
|
72
|
+
* When set to `false`, disables code decorating with bidi warnings.
|
|
73
|
+
*
|
|
74
|
+
* @default true
|
|
75
|
+
*/
|
|
76
|
+
codeBidiWarnings?: CodeBidiWarningConfig['codeBidiWarnings'];
|
|
77
|
+
/**
|
|
78
|
+
* `codeBidiWarningLabel` is set via a prop on @atlaskit/code/CodeBlock.
|
|
79
|
+
*
|
|
80
|
+
* Label for the bidi warning tooltip.
|
|
81
|
+
*
|
|
82
|
+
* @default 'Bidirectional characters change the order that text is rendered. This could be used to obscure malicious code.'
|
|
83
|
+
*/
|
|
84
|
+
codeBidiWarningLabel?: CodeBidiWarningConfig['codeBidiWarningLabel'];
|
|
85
|
+
/**
|
|
86
|
+
* `codeBidiWarningTooltipEnabled` is set via a prop on @atlaskit/code/CodeBlock.
|
|
87
|
+
*
|
|
88
|
+
* Sets whether to render tooltip with the warning or not.
|
|
89
|
+
* Intended to be disabled when used in a mobile view, such as in the editor via mobile bridge,
|
|
90
|
+
* where the tooltip could end up being cut off or otherwise not work as expected.
|
|
91
|
+
* @default true
|
|
92
|
+
*/
|
|
93
|
+
codeBidiWarningTooltipEnabled?: CodeBidiWarningConfig['codeBidiWarningTooltipEnabled'];
|
|
94
|
+
/**
|
|
95
|
+
* Code to render; equivalent of `text` prop on @atlaskit/code/CodeBlock.
|
|
96
|
+
*/
|
|
97
|
+
text?: string;
|
|
98
|
+
[spread: string]: any;
|
|
99
|
+
}
|
|
100
|
+
export interface CodeBidiWarningConfig {
|
|
101
|
+
/**
|
|
102
|
+
* `codeBidiWarnings` is set via a prop on @atlaskit/code/CodeBlock.
|
|
103
|
+
*
|
|
104
|
+
* When set to `false`, disables code decorating with bidi warnings.
|
|
105
|
+
* @default true
|
|
106
|
+
*/
|
|
107
|
+
codeBidiWarnings?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* `codeBidiWarningLabel` is set via a prop on @atlaskit/code/CodeBlock.
|
|
110
|
+
*
|
|
111
|
+
* Label for the bidi warning tooltip.
|
|
112
|
+
*
|
|
113
|
+
* @default 'Bidirectional characters change the order that text is rendered. This could be used to obscure malicious code.'
|
|
114
|
+
*/
|
|
115
|
+
codeBidiWarningLabel?: string;
|
|
116
|
+
/**
|
|
117
|
+
* `codeBidiWarningTooltipEnabled` is set via a prop on @atlaskit/code/CodeBlock.
|
|
118
|
+
*
|
|
119
|
+
* Sets whether to render tooltip with the warning or not.
|
|
120
|
+
* Intended to be disabled when used in a mobile view, such as in the editor via mobile bridge,
|
|
121
|
+
* where the tooltip could end up being cut off or otherwise not work as expected.
|
|
122
|
+
* @default true
|
|
123
|
+
*/
|
|
124
|
+
codeBidiWarningTooltipEnabled?: boolean;
|
|
125
|
+
}
|
|
126
|
+
interface IAstGenerator {
|
|
127
|
+
highlight: (code: string, language: string) => RefractorNode[];
|
|
128
|
+
}
|
|
129
|
+
export type AstGenerator = IAstGenerator | null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { HTMLProps, ReactNode } from 'react';
|
|
2
|
+
export type { SupportedLanguages, Language, LanguageAlias, CodeBlockProps, } from './internal/types';
|
|
3
|
+
export interface CodeProps extends HTMLProps<HTMLElement> {
|
|
4
|
+
/**
|
|
5
|
+
* A unique string that appears as a data attribute `data-testid`
|
|
6
|
+
* in the rendered code. Serves as a hook for automated tests.
|
|
7
|
+
*/
|
|
8
|
+
testId?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Content to be rendered in the inline code block.
|
|
11
|
+
*/
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* When set to `false`, disables code decorating with bidi warnings. Defaults to `true`.
|
|
15
|
+
*/
|
|
16
|
+
codeBidiWarnings?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
Label for the bidi warning tooltip.
|
|
19
|
+
|
|
20
|
+
Defaults to `Bidirectional characters change the order that text is rendered.
|
|
21
|
+
This could be used to obscure malicious code.`
|
|
22
|
+
*/
|
|
23
|
+
codeBidiWarningLabel?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Sets whether to render tooltip with the warning or not. Intended to be
|
|
26
|
+
* disabled when used in a mobile view, such as in the editor via mobile
|
|
27
|
+
* bridge, where the tooltip could end up being cut off or otherwise not work
|
|
28
|
+
* as expected. Defaults to `true`.
|
|
29
|
+
*/
|
|
30
|
+
codeBidiWarningTooltipEnabled?: boolean;
|
|
31
|
+
}
|