@apify/ui-library 0.65.1 → 0.65.3-featuresyntaxhighlighter-48cb44.36
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 +11 -0
- package/dist/src/components/code/code_block/code_block.d.ts.map +1 -1
- package/dist/src/components/code/code_block/code_block.js +14 -20
- package/dist/src/components/code/code_block/code_block.js.map +1 -1
- package/dist/src/components/code/code_block/code_block.styled.d.ts +8 -2
- package/dist/src/components/code/code_block/code_block.styled.d.ts.map +1 -1
- package/dist/src/components/code/code_block/code_block.styled.js +14 -68
- package/dist/src/components/code/code_block/code_block.styled.js.map +1 -1
- package/dist/src/components/code/code_block/utils.d.ts +5 -1
- package/dist/src/components/code/code_block/utils.d.ts.map +1 -1
- package/dist/src/components/code/code_block/utils.js +23 -12
- package/dist/src/components/code/code_block/utils.js.map +1 -1
- package/dist/src/components/code/index.d.ts +1 -0
- package/dist/src/components/code/index.d.ts.map +1 -1
- package/dist/src/components/code/index.js +1 -0
- package/dist/src/components/code/index.js.map +1 -1
- package/dist/src/components/code/one_line_code/one_line_code.d.ts.map +1 -1
- package/dist/src/components/code/one_line_code/one_line_code.js +5 -23
- package/dist/src/components/code/one_line_code/one_line_code.js.map +1 -1
- package/dist/src/components/code/prism_highlighter.d.ts +13 -0
- package/dist/src/components/code/prism_highlighter.d.ts.map +1 -0
- package/dist/src/components/code/prism_highlighter.js +116 -0
- package/dist/src/components/code/prism_highlighter.js.map +1 -0
- package/dist/src/components/to_consolidate/markdown.d.ts.map +1 -1
- package/dist/src/components/to_consolidate/markdown.js +2 -1
- package/dist/src/components/to_consolidate/markdown.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/components/code/code_block/code_block.styled.tsx +21 -69
- package/src/components/code/code_block/code_block.tsx +25 -36
- package/src/components/code/code_block/utils.tsx +50 -0
- package/src/components/code/index.ts +1 -0
- package/src/components/code/one_line_code/one_line_code.tsx +9 -28
- package/src/components/code/prism_highlighter.tsx +178 -0
- package/src/components/to_consolidate/markdown.tsx +4 -2
- package/dist/src/components/code/syntax_highlighter.d.ts +0 -15
- package/dist/src/components/code/syntax_highlighter.d.ts.map +0 -1
- package/dist/src/components/code/syntax_highlighter.js +0 -103
- package/dist/src/components/code/syntax_highlighter.js.map +0 -1
- package/src/components/code/code_block/utils.ts +0 -19
- package/src/components/code/syntax_highlighter.tsx +0 -134
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.65.2](https://github.com/apify/apify-core/compare/@apify/ui-library@0.65.1...@apify/ui-library@0.65.2) (2025-04-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **packages:** Fixed rendering images in markdown with invalid property [internal] ([#20618](https://github.com/apify/apify-core/issues/20618)) ([0ba19b4](https://github.com/apify/apify-core/commit/0ba19b4c89777eb6bda343c8585203886873df8b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [0.65.1](https://github.com/apify/apify-core/compare/@apify/ui-library@0.65.0...@apify/ui-library@0.65.1) (2025-04-10)
|
|
7
18
|
|
|
8
19
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code_block.d.ts","sourceRoot":"","sources":["../../../../../src/components/code/code_block/code_block.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"code_block.d.ts","sourceRoot":"","sources":["../../../../../src/components/code/code_block/code_block.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAIpD,OAAO,KAAK,EAAE,cAAc,EAAE,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AAsB,CAAC,EAAE,OAAO,CAAC;IACjC,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACzC,CAAA;AAED,eAAO,MAAM,SAAS,ySAqBnB,cAAc,4CAwFhB,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import clsx from 'clsx';
|
|
3
|
-
import {
|
|
3
|
+
import { useMemo, useRef, useState } from 'react';
|
|
4
4
|
import { ColorWheelGradient } from '../../color_wheel_gradient.js';
|
|
5
5
|
import { Link } from '../../link.js';
|
|
6
6
|
import { Text } from '../../text/index.js';
|
|
7
7
|
import { ActionButton, CopyButton } from '../action_button.js';
|
|
8
|
-
import {
|
|
8
|
+
import { PrismSyntaxHighlighter } from '../prism_highlighter.js';
|
|
9
9
|
import { CodeBlockWrapper } from './code_block.styled.js';
|
|
10
|
-
import {
|
|
10
|
+
import { getBashLinePrefixes, getNumberLinePrefixes } from './utils.js';
|
|
11
11
|
const LANGUAGES_WITHOUT_LINE_NUMBERS = ['json', 'jsonp', 'jsonp', 'rss', 'yaml', 'xml', 'html', 'bash', 'text', 'dockerfile', 'http'];
|
|
12
12
|
const HeaderDots = () => {
|
|
13
13
|
return (_jsxs("div", { className: "CodeBlock-HederDotsWrapper", children: [_jsx("div", { className: "CodeBlock-HeaderDot" }), _jsx("div", { className: "CodeBlock-HeaderDot" }), _jsx("div", { className: "CodeBlock-HeaderDot" })] }));
|
|
@@ -38,9 +38,7 @@ export const CodeBlock = ({ content, size, language, highlightLines, onTabChange
|
|
|
38
38
|
const currentLanguage = language ?? currentTab?.language;
|
|
39
39
|
const currentHighlightLines = useMemo(() => (isMultiTab ? currentTab?.highlightLines ?? [] : highlightLines), [isMultiTab, currentTab, highlightLines]);
|
|
40
40
|
const isBash = currentLanguage === 'bash';
|
|
41
|
-
const showLineNumbers = !hideLineNumbers
|
|
42
|
-
&& !LANGUAGES_WITHOUT_LINE_NUMBERS.includes(currentLanguage ?? '');
|
|
43
|
-
const showBashPrompt = isBash && !hideBashPromptPrefixes;
|
|
41
|
+
const showLineNumbers = !hideLineNumbers && !LANGUAGES_WITHOUT_LINE_NUMBERS.includes(currentLanguage ?? '');
|
|
44
42
|
const showBashHeader = isBash && !hideBashHeader && !isMultiTab;
|
|
45
43
|
const showHeader = isMultiTab || !!title || showBashHeader;
|
|
46
44
|
const syntaxHighlighterRef = useRef(null);
|
|
@@ -49,21 +47,17 @@ export const CodeBlock = ({ content, size, language, highlightLines, onTabChange
|
|
|
49
47
|
setCurrentTab(tab);
|
|
50
48
|
syntaxHighlighterRef.current?.scrollTo(0, 0);
|
|
51
49
|
};
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return mapPrefixToBashLine(currentCode, currentTab?.bashCommandsStart ?? bashCommandsStart);
|
|
56
|
-
}, [currentCode, bashCommandsStart, showBashPrompt, currentTab]);
|
|
57
|
-
const getLineProps = useCallback((lineNumber) => {
|
|
58
|
-
const data = [];
|
|
59
|
-
if (currentHighlightLines?.includes(lineNumber)) {
|
|
60
|
-
data.push('highlighted');
|
|
61
|
-
}
|
|
50
|
+
const showBashPrompt = isBash && !hideBashPromptPrefixes;
|
|
51
|
+
const effectiveBashCommandsStart = currentTab?.bashCommandsStart ?? bashCommandsStart;
|
|
52
|
+
const linePrefixes = useMemo(() => {
|
|
62
53
|
if (showBashPrompt) {
|
|
63
|
-
|
|
54
|
+
return getBashLinePrefixes(currentCode, effectiveBashCommandsStart);
|
|
55
|
+
}
|
|
56
|
+
if (showLineNumbers) {
|
|
57
|
+
return getNumberLinePrefixes(currentCode);
|
|
64
58
|
}
|
|
65
|
-
return {
|
|
66
|
-
}, [
|
|
67
|
-
return (_jsxs(CodeBlockWrapper, { "$hasHeader": showHeader, "$gradientRotation": gradientRotation, "$hasActionButton": showActionButton, "$hasTabs": isMultiTab, "$fullWidth": fullWidth, "$fullHeight": fullHeight, "$showLineNumbers": showLineNumbers, ...rest, children: [showHeader && (_jsx(Header, { tabs: isMultiTab ? content : null, currentTab: currentTab, onTabChange: handleTabClick, showBashHeader: showBashHeader, title: title })), _jsx(
|
|
59
|
+
return {};
|
|
60
|
+
}, [showLineNumbers, showBashPrompt, currentCode, effectiveBashCommandsStart]);
|
|
61
|
+
return (_jsxs(CodeBlockWrapper, { "$hasHeader": showHeader, "$gradientRotation": gradientRotation, "$hasActionButton": showActionButton, "$hasTabs": isMultiTab, "$fullWidth": fullWidth, "$fullHeight": fullHeight, "$showLineNumbers": showLineNumbers, ...rest, children: [showHeader && (_jsx(Header, { tabs: isMultiTab ? content : null, currentTab: currentTab, onTabChange: handleTabClick, showBashHeader: showBashHeader, title: title })), _jsx(PrismSyntaxHighlighter, { code: currentCode, linePrefixes: linePrefixes, highlightLines: currentHighlightLines, language: currentLanguage || 'text', size: size, ref: syntaxHighlighterRef, isSingleLine: false }), _jsxs("div", { className: "CodeBlock-TopRightActionsWrapper", children: [showActionButton && _jsx(ActionButton, { successStyle: true, onClick: onActionButtonClick, children: actionButtonLabel ?? 'Run on Apify' }), !hideCopyButton && _jsx(CopyButton, { code: currentCode })] }), showGradient && (_jsx(ColorWheelGradient, { className: "CodeBlock-Gradient", blurSize: 69 }))] }));
|
|
68
62
|
};
|
|
69
63
|
//# sourceMappingURL=code_block.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code_block.js","sourceRoot":"","sources":["../../../../../src/components/code/code_block/code_block.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"code_block.js","sourceRoot":"","sources":["../../../../../src/components/code/code_block/code_block.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAc,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+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,EAEL,YAAY,IAAI,CACb,KAAC,kBAAkB,IACf,SAAS,EAAC,oBAAoB,EAC9B,QAAQ,EAAE,EAAE,GACd,CACL,IACe,CACvB,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import type { SharedTextSize } from '../../text/text_shared.js';
|
|
2
|
-
export
|
|
1
|
+
import type { SharedTextProps, SharedTextSize } from '../../text/text_shared.js';
|
|
2
|
+
export type SyntaxHighlighterBaseStylesWrapperProps = SharedTextProps & {
|
|
3
|
+
$fullWidth?: boolean;
|
|
4
|
+
$fullHeight?: string;
|
|
5
|
+
$showLineNumbers?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare const SyntaxHighlighterBaseStylesWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../../box.js").BoxProps & import("react").RefAttributes<HTMLElement>>, any, SyntaxHighlighterBaseStylesWrapperProps, never>;
|
|
8
|
+
export declare const CodeBlockWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../../box.js").BoxProps & import("react").RefAttributes<HTMLElement>>, any, SyntaxHighlighterBaseStylesWrapperProps & {
|
|
3
9
|
$hasHeader: boolean;
|
|
4
10
|
$gradientRotation?: number;
|
|
5
11
|
$highlightLines?: number[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code_block.styled.d.ts","sourceRoot":"","sources":["../../../../../src/components/code/code_block/code_block.styled.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"code_block.styled.d.ts","sourceRoot":"","sources":["../../../../../src/components/code/code_block/code_block.styled.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEjF,MAAM,MAAM,uCAAuC,GAAG,eAAe,GAAG;IACpE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAA;AAED,eAAO,MAAM,kCAAkC,2NAY9C,CAAC;AAEF,eAAO,MAAM,gBAAgB;gBACb,OAAO;wBACC,MAAM;sBACR,MAAM,EAAE;uBACP,OAAO;eACf,OAAO;iBACL,OAAO;uBACD,OAAO;kBACZ,OAAO;WACd,cAAc;SAgJxB,CAAC"}
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
2
|
import { theme } from '../../../design_system/theme.js';
|
|
3
|
-
import {
|
|
4
|
-
const
|
|
3
|
+
import { Box } from '../../box.js';
|
|
4
|
+
export const SyntaxHighlighterBaseStylesWrapper = styled(Box) `
|
|
5
|
+
background-color: ${theme.color.neutral.backgroundMuted} !important;
|
|
6
|
+
border: 1px solid ${theme.color.neutral.border};
|
|
7
|
+
border-radius: ${theme.radius.radius12};
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
|
|
10
|
+
width: 100%;
|
|
11
|
+
${({ $fullWidth }) => !$fullWidth && css `max-width: 860px;`}
|
|
12
|
+
${({ $fullHeight }) => !$fullHeight && css `max-height: 600px;`}
|
|
13
|
+
|
|
14
|
+
background-color: transparent;
|
|
15
|
+
position: relative;
|
|
16
|
+
`;
|
|
5
17
|
export const CodeBlockWrapper = styled(SyntaxHighlighterBaseStylesWrapper) `
|
|
6
18
|
position: relative;
|
|
7
19
|
display: flex;
|
|
@@ -91,72 +103,6 @@ export const CodeBlockWrapper = styled(SyntaxHighlighterBaseStylesWrapper) `
|
|
|
91
103
|
}
|
|
92
104
|
}
|
|
93
105
|
|
|
94
|
-
.CodePre {
|
|
95
|
-
z-index: 2;
|
|
96
|
-
padding: ${theme.space.space16} 0 !important;
|
|
97
|
-
|
|
98
|
-
code {
|
|
99
|
-
& > span {
|
|
100
|
-
display: block;
|
|
101
|
-
padding-left: ${({ $showLineNumbers }) => ($showLineNumbers ? theme.space.space8 : theme.space.space16)};
|
|
102
|
-
padding-right: ${theme.space.space16};
|
|
103
|
-
&:hover {
|
|
104
|
-
background-color: ${HIGHLIGHT_BACKGROUND_COLOR} !important;
|
|
105
|
-
border-left: 6px solid ${theme.color.neutral.border} !important;
|
|
106
|
-
padding-left: ${({ $showLineNumbers }) => ($showLineNumbers ? '0.2' : '1')}rem;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// Common styles
|
|
111
|
-
[data*='bash']{
|
|
112
|
-
&::before {
|
|
113
|
-
color: ${theme.color.lavender.base};
|
|
114
|
-
padding-right: ${theme.space.space16};
|
|
115
|
-
min-width: ${theme.space.space24};
|
|
116
|
-
user-select: none;
|
|
117
|
-
-webkit-user-select: none;
|
|
118
|
-
font-size: 1em;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
[data*='bashStartCommand'] {
|
|
123
|
-
&::before {
|
|
124
|
-
content: '$';
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
[data*='bashCommand'] {
|
|
129
|
-
&::before {
|
|
130
|
-
content: '>';
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
[data*='bashEmptyLine'] {
|
|
135
|
-
&::before {
|
|
136
|
-
content: ' ';
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
[data*='highlighted'] {
|
|
141
|
-
background-color: ${HIGHLIGHT_BACKGROUND_COLOR} !important;
|
|
142
|
-
border-left: 6px solid ${theme.color.neutral.border} !important;
|
|
143
|
-
padding-left: ${({ $showLineNumbers }) => ($showLineNumbers ? '0.2' : '1')}rem;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
.linenumber {
|
|
148
|
-
color: ${theme.color.neutral.textSubtle} !important;
|
|
149
|
-
padding-right: ${theme.space.space16} !important;
|
|
150
|
-
min-width: ${theme.space.space24} !important;
|
|
151
|
-
box-sizing: unset !important;
|
|
152
|
-
user-select: none;
|
|
153
|
-
-webkit-user-select: none;
|
|
154
|
-
|
|
155
|
-
${({ $showLineNumbers }) => (!$showLineNumbers && css `display: none !important;`)}
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
106
|
|
|
161
107
|
.CodeBlock-TopRightActionsWrapper {
|
|
162
108
|
position: absolute;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code_block.styled.js","sourceRoot":"","sources":["../../../../../src/components/code/code_block/code_block.styled.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"code_block.styled.js","sourceRoot":"","sources":["../../../../../src/components/code/code_block/code_block.styled.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AACxD,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AASnC,MAAM,CAAC,MAAM,kCAAkC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAyC;wBAC9E,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe;wBACnC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM;qBAC7B,KAAK,CAAC,MAAM,CAAC,QAAQ;;;;MAIpC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC,UAAU,IAAI,GAAG,CAAA,mBAAmB;MACzD,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC,WAAW,IAAI,GAAG,CAAA,oBAAoB;;;;CAIjE,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,kCAAkC,CAAC,CAUxE;;;;;;;;eAQa,KAAK,CAAC,KAAK,CAAC,MAAM;4BACL,KAAK,CAAC,KAAK,C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B,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,IAAI,GAAG,CAAA;gCACf,KAAK,CAAC,KAAK,CAAC,OAAO;;;;sBAI7B,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB;;aAE7C;;;;;;;;;;gDAUmC,CAAC,EAAE,iBAAiB,EAAE,EAAE,EAAE,CAAC,iBAAiB,IAAI,CAAC;;;;;mBAK9E,KAAK,CAAC,KAAK,CAAC,MAAM;;eAEtB,KAAK,CAAC,KAAK,CAAC,MAAM;;uBAEV,KAAK,CAAC,KAAK,CAAC,MAAM;;;;;;;gCAOT,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU;;;CAG7D,CAAC"}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export declare const getBashLinePrefixes: (code: string, bashCommandsStart?: number[]) => {
|
|
3
|
+
[k: string]: import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
};
|
|
5
|
+
export declare const getNumberLinePrefixes: (code: string) => Record<number, ReactNode>;
|
|
2
6
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/code/code_block/utils.
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/components/code/code_block/utils.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASvC,eAAO,MAAM,mBAAmB,SAAU,MAAM,sBAAqB,MAAM,EAAE;;CAiC5E,CAAC;AAEF,eAAO,MAAM,qBAAqB,SAAU,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAK5E,CAAC"}
|
|
@@ -1,20 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { theme } from '../../../design_system/theme.js';
|
|
3
|
+
import { CodeHighlighterLinePrefix } from '../prism_highlighter.js';
|
|
1
4
|
// input: [2, 4, 5, 6, 8, 10, 11, 12]
|
|
2
5
|
// returns string indicating what type of line it is (bashStartCommand, bashCommand, bashEmptyLine)
|
|
3
6
|
// commands start -> bashStartCommand
|
|
4
7
|
// every next line after command start until next command start or empty line -> bashCommand
|
|
5
|
-
|
|
6
|
-
export const mapPrefixToBashLine = (code, bashCommandsStart = []) => {
|
|
8
|
+
export const getBashLinePrefixes = (code, bashCommandsStart = []) => {
|
|
7
9
|
const lines = code.split('\n').map((line) => line.trim());
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
const bashLinePrefixesArray = lines.map((line, i) => {
|
|
11
|
+
const isEmptyLine = line.startsWith('#') || !line;
|
|
12
|
+
// by default each line that is not empty or comment is a command start
|
|
13
|
+
if (bashCommandsStart.length === 0) {
|
|
14
|
+
return isEmptyLine ? (_jsx(CodeHighlighterLinePrefix, {})) : (_jsx(CodeHighlighterLinePrefix, { color: theme.color.lavender.base, children: "$" }));
|
|
15
|
+
}
|
|
16
|
+
if (bashCommandsStart.includes(i + 1)) {
|
|
17
|
+
return (_jsx(CodeHighlighterLinePrefix, { color: theme.color.lavender.base, children: "$" }));
|
|
18
|
+
}
|
|
19
|
+
if (isEmptyLine) {
|
|
20
|
+
return (_jsx(CodeHighlighterLinePrefix, {}));
|
|
21
|
+
}
|
|
22
|
+
return (_jsx(CodeHighlighterLinePrefix, { color: theme.color.lavender.base, children: "<" }));
|
|
18
23
|
});
|
|
24
|
+
return Object.fromEntries(bashLinePrefixesArray.map((linePrefix, i) => [i + 1, linePrefix]));
|
|
25
|
+
};
|
|
26
|
+
export const getNumberLinePrefixes = (code) => {
|
|
27
|
+
const numberOfLines = code.split('\n').length;
|
|
28
|
+
const numbersArray = Array.from({ length: numberOfLines }, (_, i) => i + 1);
|
|
29
|
+
return Object.fromEntries(numbersArray.map((number) => [number, _jsx(CodeHighlighterLinePrefix, { children: number })]));
|
|
19
30
|
};
|
|
20
31
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/components/code/code_block/utils.
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/components/code/code_block/utils.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEpE,qCAAqC;AACrC,mGAAmG;AACnG,qCAAqC;AACrC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAE,oBAA8B,EAAE,EAAE,EAAE;IAClF,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAE1D,MAAM,qBAAqB,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;QAChD,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;QAElD,uEAAuE;QACvE,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACjC,OAAO,WAAW,CAAC,CAAC,CAAC,CACjB,KAAC,yBAAyB,KAAG,CAChC,CAAC,CAAC,CAAC,CACA,KAAC,yBAAyB,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,kBAA+B,CAC7F,CAAC;QACN,CAAC;QAED,IAAI,iBAAiB,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACpC,OAAO,CACH,KAAC,yBAAyB,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,kBAA+B,CAC7F,CAAC;QACN,CAAC;QAED,IAAI,WAAW,EAAE,CAAC;YACd,OAAO,CACH,KAAC,yBAAyB,KAAG,CAChC,CAAC;QACN,CAAC;QAED,OAAO,CACH,KAAC,yBAAyB,IAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,kBAAkC,CAChG,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,WAAW,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;AACjG,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAY,EAA6B,EAAE;IAC7E,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IAC9C,MAAM,YAAY,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAE5E,OAAO,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,KAAC,yBAAyB,cAAE,MAAM,GAA6B,CAAC,CAAC,CAAC,CAAC;AACvI,CAAC,CAAC"}
|
|
@@ -2,4 +2,5 @@ export * from './code_block/code_block.js';
|
|
|
2
2
|
export * from './code_block/code_block_with_tabs.js';
|
|
3
3
|
export * from './one_line_code/one_line_code.js';
|
|
4
4
|
export * from './inline_code/inline_code.js';
|
|
5
|
+
export * from './prism_highlighter.js';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/code/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/code/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC"}
|
|
@@ -2,4 +2,5 @@ export * from './code_block/code_block.js';
|
|
|
2
2
|
export * from './code_block/code_block_with_tabs.js';
|
|
3
3
|
export * from './one_line_code/one_line_code.js';
|
|
4
4
|
export * from './inline_code/inline_code.js';
|
|
5
|
+
export * from './prism_highlighter.js';
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/code/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/code/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"one_line_code.d.ts","sourceRoot":"","sources":["../../../../../src/components/code/one_line_code/one_line_code.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"one_line_code.d.ts","sourceRoot":"","sources":["../../../../../src/components/code/one_line_code/one_line_code.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAMhE,eAAO,MAAM,qBAAqB;;;;;;CAMjC,CAAC;AAEF,KAAK,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AA0GvE,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,mBAAmB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACjD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAA;AAED,wBAAgB,WAAW,CAAC,EACxB,QAAQ,EACR,QAAQ,EACR,IAAI,EACJ,UAAU,EACV,iBAAiB,EACjB,mBAAmB,EACnB,SAAS,EACT,iBAAyB,EACzB,MAAM,EACN,QAAQ,EACR,cAAc,EACd,GAAG,IAAI,EACV,EAAE,gBAAgB,2CAyDlB"}
|
|
@@ -5,7 +5,8 @@ import { EyeIcon, EyeOffIcon } from '@apify/ui-icons';
|
|
|
5
5
|
import { theme } from '../../../design_system/theme.js';
|
|
6
6
|
import { Text } from '../../text/index.js';
|
|
7
7
|
import { ActionButton, CopyButton } from '../action_button.js';
|
|
8
|
-
import {
|
|
8
|
+
import { SyntaxHighlighterBaseStylesWrapper } from '../code_block/code_block.styled.js';
|
|
9
|
+
import { PrismSyntaxHighlighter } from '../prism_highlighter.js';
|
|
9
10
|
export const oneLineCodeClassNames = {
|
|
10
11
|
gradientWrapper: 'OneLineCode-GradientWrapper',
|
|
11
12
|
scrollableWrapper: 'OneLineCode-ScrollableWrapper',
|
|
@@ -71,6 +72,7 @@ const OneLineCodeWrapper = styled(SyntaxHighlighterBaseStylesWrapper) `
|
|
|
71
72
|
top: 0;
|
|
72
73
|
bottom: 0;
|
|
73
74
|
width: 4rem;
|
|
75
|
+
z-index: 5;
|
|
74
76
|
background: linear-gradient(
|
|
75
77
|
to right,
|
|
76
78
|
transparent,
|
|
@@ -93,32 +95,12 @@ const OneLineCodeWrapper = styled(SyntaxHighlighterBaseStylesWrapper) `
|
|
|
93
95
|
scrollbar-color: ${theme.color.neutral.border} transparent;
|
|
94
96
|
|
|
95
97
|
|
|
96
|
-
|
|
98
|
+
pre {
|
|
97
99
|
overflow: unset !important;
|
|
98
100
|
display: flex;
|
|
99
101
|
flex: 1;
|
|
100
102
|
align-items: center;
|
|
101
103
|
height: 2.8rem;
|
|
102
|
-
|
|
103
|
-
code {
|
|
104
|
-
& > span {
|
|
105
|
-
text-overflow: ellipsis;
|
|
106
|
-
overflow: hidden;
|
|
107
|
-
white-space: nowrap;
|
|
108
|
-
vertical-align: text-top;
|
|
109
|
-
${({ $showBashPrefixes }) => $showBashPrefixes && css `
|
|
110
|
-
&::before {
|
|
111
|
-
color: ${theme.color.lavender.base};
|
|
112
|
-
padding-right: ${theme.space.space16};
|
|
113
|
-
min-width: ${theme.space.space24};
|
|
114
|
-
user-select: none;
|
|
115
|
-
-webkit-user-select: none;
|
|
116
|
-
content: "$";
|
|
117
|
-
font-size: 1em;
|
|
118
|
-
}
|
|
119
|
-
`}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
104
|
}
|
|
123
105
|
}
|
|
124
106
|
`;
|
|
@@ -132,6 +114,6 @@ export function OneLineCode({ children, language, size, httpMethod, actionButton
|
|
|
132
114
|
}, [children, secret, hasSecret, secretPlaceholder]);
|
|
133
115
|
const code = showSecret ? codeWithSecret : children;
|
|
134
116
|
const showBashPrefixes = language === 'bash';
|
|
135
|
-
return (_jsxs(OneLineCodeWrapper, { "$httpMethod": httpMethod, "$fullWidth": fullWidth, "$showBashPrefixes": showBashPrefixes, "$disabled": disabled, ...rest, children: [_jsxs("div", { className: oneLineCodeClassNames.gradientWrapper, children: [_jsxs("div", { className: oneLineCodeClassNames.scrollableWrapper, children: [httpMethod && (_jsx(Text, { className: oneLineCodeClassNames.methodChip, as: 'div', children: httpMethod })), _jsx(
|
|
117
|
+
return (_jsxs(OneLineCodeWrapper, { "$httpMethod": httpMethod, "$fullWidth": fullWidth, "$showBashPrefixes": showBashPrefixes, "$disabled": disabled, ...rest, children: [_jsxs("div", { className: oneLineCodeClassNames.gradientWrapper, children: [_jsxs("div", { className: oneLineCodeClassNames.scrollableWrapper, children: [httpMethod && (_jsx(Text, { className: oneLineCodeClassNames.methodChip, as: 'div', children: httpMethod })), _jsx(PrismSyntaxHighlighter, { language: language, size: size, code: code, isSingleLine: true })] }), _jsx("div", { className: oneLineCodeClassNames.gradient })] }), _jsxs("div", { className: oneLineCodeClassNames.buttons, children: [hasSecret && (_jsx(ActionButton, { onClick: () => setShowSecret((prev) => !prev), "data-test": 'toggle-visibility-button', children: showSecret ? (_jsx(EyeOffIcon, { size: "16" })) : (_jsx(EyeIcon, { size: "16" })) })), !hideCopyButton && _jsx(CopyButton, { code: codeWithSecret }), !!onActionButtonClick && (_jsx(ActionButton, { onClick: onActionButtonClick, children: actionButtonLabel }))] })] }));
|
|
136
118
|
}
|
|
137
119
|
//# sourceMappingURL=one_line_code.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"one_line_code.js","sourceRoot":"","sources":["../../../../../src/components/code/one_line_code/one_line_code.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAExD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"one_line_code.js","sourceRoot":"","sources":["../../../../../src/components/code/one_line_code/one_line_code.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAExD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,kCAAkC,EAAE,MAAM,oCAAoC,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACjC,eAAe,EAAE,6BAA6B;IAC9C,iBAAiB,EAAE,+BAA+B;IAClD,UAAU,EAAE,wBAAwB;IACpC,QAAQ,EAAE,sBAAsB;IAChC,OAAO,EAAE,qBAAqB;CACjC,CAAC;AAQF,MAAM,uBAAuB,GAAkC;IAC3D,GAAG,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,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,IAAI,GACpB,IACA,EACN,cAAK,SAAS,EAAE,qBAAqB,CAAC,QAAQ,GAAI,IAChD,EACN,eAAK,SAAS,EAAE,qBAAqB,CAAC,OAAO,aACxC,SAAS,IAAI,CACV,KAAC,YAAY,IACT,OAAO,EAAE,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,eACnC,0BAA0B,YAEnC,UAAU,CAAC,CAAC,CAAC,CACV,KAAC,UAAU,IAAC,IAAI,EAAC,IAAI,GAAG,CAC3B,CAAC,CAAC,CAAC,CACA,KAAC,OAAO,IAAC,IAAI,EAAC,IAAI,GAAG,CACxB,GACU,CAClB,EACA,CAAC,cAAc,IAAI,KAAC,UAAU,IAAC,IAAI,EAAE,cAAc,GAAI,EACvD,CAAC,CAAC,mBAAmB,IAAI,CACtB,KAAC,YAAY,IAAC,OAAO,EAAE,mBAAmB,YACrC,iBAAiB,GACP,CAClB,IACC,IACY,CACzB,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HighlightProps } from 'prism-react-renderer';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { SharedTextSize } from '../text/text_shared.js';
|
|
4
|
+
export declare const CodeHighlighterLinePrefix: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../text/text_shared.js").SharedTextProps & import("react").RefAttributes<HTMLElement | undefined>>, any, {}, never>;
|
|
5
|
+
export declare const PrismSyntaxHighlighter: import("react").ForwardRefExoticComponent<Omit<HighlightProps, "children" | "language"> & {
|
|
6
|
+
size?: SharedTextSize;
|
|
7
|
+
linePrefixes?: Record<string, ReactNode>;
|
|
8
|
+
highlightLines?: number[];
|
|
9
|
+
language?: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
isSingleLine: boolean;
|
|
12
|
+
} & import("react").RefAttributes<HTMLPreElement>>;
|
|
13
|
+
//# sourceMappingURL=prism_highlighter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prism_highlighter.d.ts","sourceRoot":"","sources":["../../../../src/components/code/prism_highlighter.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAOvC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAuG7D,eAAO,MAAM,yBAAyB,mNAQrC,CAAC;AAWF,eAAO,MAAM,sBAAsB;WARxB,cAAc;mBACN,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;qBACvB,MAAM,EAAE;eACd,MAAM;gBACL,MAAM;kBACJ,OAAO;kDA+CvB,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import { Highlight, Prism, themes } from 'prism-react-renderer';
|
|
5
|
+
import { forwardRef, useRef } from 'react';
|
|
6
|
+
import styled, { css } from 'styled-components';
|
|
7
|
+
import { theme } from '../../design_system/theme.js';
|
|
8
|
+
import { useSharedUiDependencies } from '../../ui_dependency_provider.js';
|
|
9
|
+
import { Text } from '../text/index.js';
|
|
10
|
+
(typeof global !== 'undefined' ? global : window).Prism = Prism;
|
|
11
|
+
const HIGHLIGHT_BACKGROUND_COLOR = 'rgba(22, 114, 235, 0.05)';
|
|
12
|
+
const loadLanguages = async () => {
|
|
13
|
+
await Promise.all([
|
|
14
|
+
// @ts-expect-error The library is badly typed and does not export the type
|
|
15
|
+
import('prismjs/components/prism-bash.js'),
|
|
16
|
+
// @ts-expect-error The library is badly typed and does not export the type
|
|
17
|
+
import('prismjs/components/prism-rust.js'),
|
|
18
|
+
// @ts-expect-error The library is badly typed and does not export the type
|
|
19
|
+
import('prismjs/components/prism-bash.js'),
|
|
20
|
+
// @ts-expect-error The library is badly typed and does not export the type
|
|
21
|
+
import('prismjs/components/prism-docker.js'),
|
|
22
|
+
// @ts-expect-error The library is badly typed and does not export the type
|
|
23
|
+
import('prismjs/components/prism-http.js'),
|
|
24
|
+
// @ts-expect-error The library is badly typed and does not export the type
|
|
25
|
+
import('prismjs/components/prism-javascript.js'),
|
|
26
|
+
// @ts-expect-error The library is badly typed and does not export the type
|
|
27
|
+
import('prismjs/components/prism-json.js'),
|
|
28
|
+
// @ts-expect-error The library is badly typed and does not export the type
|
|
29
|
+
import('prismjs/components/prism-markup.js'),
|
|
30
|
+
// @ts-expect-error The library is badly typed and does not export the type
|
|
31
|
+
import('prismjs/components/prism-python.js'),
|
|
32
|
+
// @ts-expect-error The library is badly typed and does not export the type
|
|
33
|
+
import('prismjs/components/prism-typescript.js'),
|
|
34
|
+
// @ts-expect-error The library is badly typed and does not export the type
|
|
35
|
+
import('prismjs/components/prism-xml-doc.js'),
|
|
36
|
+
// @ts-expect-error The library is badly typed and does not export the type
|
|
37
|
+
import('prismjs/components/prism-yaml.js'),
|
|
38
|
+
]);
|
|
39
|
+
};
|
|
40
|
+
void loadLanguages();
|
|
41
|
+
const StyledPre = styled.pre `
|
|
42
|
+
width: 100%;
|
|
43
|
+
position: relative;
|
|
44
|
+
overflow: auto;
|
|
45
|
+
z-index: 2;
|
|
46
|
+
padding: ${({ $isSingleLine }) => ($isSingleLine ? 0 : `${theme.space.space16} 0`)};
|
|
47
|
+
margin: 0;
|
|
48
|
+
|
|
49
|
+
*,
|
|
50
|
+
*::before,
|
|
51
|
+
*::after {
|
|
52
|
+
text-shadow: none !important;
|
|
53
|
+
font-style: normal !important;
|
|
54
|
+
font-family: inherit !important;
|
|
55
|
+
font-size: inherit !important;
|
|
56
|
+
font-weight: inherit !important;
|
|
57
|
+
line-height: inherit !important;
|
|
58
|
+
background-color: transparent !important;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
code {
|
|
62
|
+
min-width: 100%;
|
|
63
|
+
display: inline-block;
|
|
64
|
+
vertical-align: middle;
|
|
65
|
+
|
|
66
|
+
& > div {
|
|
67
|
+
display: block;
|
|
68
|
+
|
|
69
|
+
&.highlighted {
|
|
70
|
+
background-color: ${HIGHLIGHT_BACKGROUND_COLOR} !important;
|
|
71
|
+
border-left: 6px solid ${theme.color.neutral.border} !important;
|
|
72
|
+
padding-left: ${({ $hasLinePrefixes }) => ($hasLinePrefixes ? '0.2' : '1')}rem;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
${({ $isSingleLine }) => !$isSingleLine && css `
|
|
76
|
+
&:hover {
|
|
77
|
+
background-color: ${HIGHLIGHT_BACKGROUND_COLOR} !important;
|
|
78
|
+
border-left: 6px solid ${theme.color.neutral.border} !important;
|
|
79
|
+
padding-left: ${({ $hasLinePrefixes }) => ($hasLinePrefixes ? '0.2' : '1')}rem;
|
|
80
|
+
}
|
|
81
|
+
`}
|
|
82
|
+
|
|
83
|
+
${({ $isSingleLine }) => ($isSingleLine ? css `
|
|
84
|
+
text-overflow: ellipsis;
|
|
85
|
+
overflow: hidden;
|
|
86
|
+
white-space: nowrap;
|
|
87
|
+
vertical-align: text-top;
|
|
88
|
+
` : css `
|
|
89
|
+
padding-left: ${({ $hasLinePrefixes }) => ($hasLinePrefixes ? theme.space.space8 : theme.space.space16)};
|
|
90
|
+
padding-right: ${theme.space.space16};
|
|
91
|
+
|
|
92
|
+
&:hover {
|
|
93
|
+
background-color: ${HIGHLIGHT_BACKGROUND_COLOR} !important;
|
|
94
|
+
border-left: 6px solid ${theme.color.neutral.border} !important;
|
|
95
|
+
padding-left: ${({ $hasLinePrefixes }) => ($hasLinePrefixes ? '0.2' : '1')}rem;
|
|
96
|
+
}
|
|
97
|
+
`)}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
`;
|
|
101
|
+
export const CodeHighlighterLinePrefix = styled(Text) `
|
|
102
|
+
display: inline-block;
|
|
103
|
+
margin-right: ${theme.space.space16};
|
|
104
|
+
text-align: right;
|
|
105
|
+
min-width: ${theme.space.space24};
|
|
106
|
+
color: ${({ color }) => color || theme.color.neutral.textSubtle};
|
|
107
|
+
user-select: none;
|
|
108
|
+
-webkit-user-select: none;
|
|
109
|
+
`;
|
|
110
|
+
export const PrismSyntaxHighlighter = forwardRef(({ size = 'regular', linePrefixes = {}, highlightLines = [], language = 'javascript', className, isSingleLine, ...rest }, ref) => {
|
|
111
|
+
const { uiTheme } = useSharedUiDependencies();
|
|
112
|
+
const hasLinePrefixes = !_.isEmpty(linePrefixes);
|
|
113
|
+
const highlightedLinesObject = useRef(Object.fromEntries(highlightLines.map((e) => [e, true])));
|
|
114
|
+
return (_jsx(Highlight, { theme: uiTheme === 'DARK' ? themes.nightOwl : themes.oneLight, language: language, ...rest, children: ({ className: prismClassName, tokens, getLineProps, getTokenProps }) => (_jsx(StyledPre, { className: clsx(className, prismClassName), "$hasLinePrefixes": hasLinePrefixes, "$isSingleLine": isSingleLine, ref: ref, children: _jsx(Text, { size: size, type: 'code', as: 'code', children: tokens.map((line, i) => (_jsxs("div", { ...getLineProps({ line, className: highlightedLinesObject.current[i + 1] ? 'highlighted' : '' }), children: [hasLinePrefixes && (linePrefixes[i + 1] || _jsx(CodeHighlighterLinePrefix, {})), line.map((token, key) => (_jsx("span", { ...getTokenProps({ token }) }, key)))] }, i))) }) })) }));
|
|
115
|
+
});
|
|
116
|
+
//# sourceMappingURL=prism_highlighter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prism_highlighter.js","sourceRoot":"","sources":["../../../../src/components/code/prism_highlighter.tsx"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,CAAC,MAAM,QAAQ,CAAC;AAEvB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAAE,UAAU,EAA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AAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CACrB,kBAAiB,YAAY,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aACzG,eAAe,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAC,yBAAyB,KAAG,CAAC,EACzE,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CACtB,kBAAoB,aAAa,CAAC,EAAE,KAAK,EAAE,CAAC,IAAjC,GAAG,CAAkC,CACnD,CAAC,KAJI,CAAC,CAKL,CACT,CAAC,GACC,GACC,CACf,GACO,CACf,CAAC;AACN,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../../src/components/to_consolidate/markdown.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../../../src/components/to_consolidate/markdown.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,YAAY,EAAQ,MAAM,kCAAkC,CAAC;AAO3E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAsQlE,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE;QACF,OAAO,EAAE,MAAM,GAAG,CAAC,iBAAiB,CAAC;KACxC,CAAC;IACF,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC7B;AAoFD,eAAO,MAAM,eAAe,UAU3B,CAAC;AAEF,UAAU,iBAAkB,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;IAC7E,IAAI,EAAE;QACF,UAAU,EAAE;YACR,mBAAmB,EAAE,OAAO,CAAC;SAChC,CAAC;KACL,CAAC;IACF,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,mBAAmB;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;CAC5B;AAmHD,MAAM,WAAW,aAAa;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5C,iBAAiB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,YAAY,CAAC,EAAE,YAAY,CAAA;IAC3B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,IAAI,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;IACzB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,CAAC,EAAE,OAAO,KAAK,KAAK,CAAC,YAAY,CAAC;IAChI,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B;AAmFD,QAAA,MAAM,gBAAgB,iOApEnB,aAAa,6CAoEwF,CAAC;AACzG,OAAO,EAAE,gBAAgB,IAAI,QAAQ,EAAE,CAAC"}
|
|
@@ -438,7 +438,8 @@ const Markdown = ({ markdown, transformLinkUri, transformImageUri, className, sc
|
|
|
438
438
|
: DefaultLinkRenderer(linkProps, { hostname: currentPathHostname, Link }, isUserGeneratedContent)),
|
|
439
439
|
code: (codeProps) => CodeRenderer(codeProps),
|
|
440
440
|
p: ParagraphRenderer,
|
|
441
|
-
img: (imageProps) => _jsx("img", { ...imageProps, ...(lazyLoadImages ? { loading: 'lazy' } : {}) })
|
|
441
|
+
img: ({ node, ...imageProps }) => (_jsx("img", { ...imageProps, ...(lazyLoadImages ? { loading: 'lazy' } : {}) }) // node is injected by rehype-raw plugin and causing invalid prop
|
|
442
|
+
),
|
|
442
443
|
}, transformLinkUri: (href) => (transformLinkUri ? uriTransformer(transformLinkUri(href)) : uriTransformer(href)), transformImageUri: transformImageUri, children: cleanedMarkdown }));
|
|
443
444
|
};
|
|
444
445
|
const MemoizedMarkdown = React.memo(Markdown, (prevProps, nextProps) => _.isEqual(prevProps, nextProps));
|