@atlaskit/code 16.3.0 → 17.0.0
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 +24 -0
- package/dist/cjs/bidi-warning/ui/styled.compiled.css +19 -0
- package/dist/cjs/bidi-warning/ui/styled.js +16 -49
- package/dist/cjs/code-block.compiled.css +105 -0
- package/dist/cjs/code-block.js +26 -22
- package/dist/cjs/code.compiled.css +16 -0
- package/dist/cjs/code.js +16 -35
- package/dist/cjs/internal/theme/constants.js +1 -12
- package/dist/cjs/internal/theme/styles.js +12 -305
- package/dist/cjs/syntax-highlighter/types.js +0 -1
- package/dist/es2019/bidi-warning/ui/styled.compiled.css +19 -0
- package/dist/es2019/bidi-warning/ui/styled.js +12 -47
- package/dist/es2019/code-block.compiled.css +105 -0
- package/dist/es2019/code-block.js +23 -16
- package/dist/es2019/code.compiled.css +16 -0
- package/dist/es2019/code.js +16 -36
- package/dist/es2019/internal/theme/constants.js +0 -10
- package/dist/es2019/internal/theme/styles.js +9 -295
- package/dist/es2019/syntax-highlighter/types.js +0 -3
- package/dist/esm/bidi-warning/ui/styled.compiled.css +19 -0
- package/dist/esm/bidi-warning/ui/styled.js +12 -47
- package/dist/esm/code-block.compiled.css +105 -0
- package/dist/esm/code-block.js +23 -22
- package/dist/esm/code.compiled.css +16 -0
- package/dist/esm/code.js +16 -36
- package/dist/esm/internal/theme/constants.js +0 -10
- package/dist/esm/internal/theme/styles.js +11 -305
- package/dist/esm/syntax-highlighter/types.js +0 -3
- package/dist/types/bidi-warning/ui/styled.d.ts +1 -2
- package/dist/types/internal/theme/constants.d.ts +0 -7
- package/dist/types/internal/theme/styles.d.ts +16 -9
- package/dist/types/syntax-highlighter/types.d.ts +3 -3
- package/dist/types-ts4.5/bidi-warning/ui/styled.d.ts +1 -2
- package/dist/types-ts4.5/internal/theme/constants.d.ts +0 -7
- package/dist/types-ts4.5/internal/theme/styles.d.ts +16 -9
- package/dist/types-ts4.5/syntax-highlighter/types.d.ts +3 -3
- package/package.json +4 -4
- package/report.api.md +1 -2
- package/dist/cjs/internal/theme/get-theme.js +0 -83
- package/dist/es2019/internal/theme/get-theme.js +0 -69
- package/dist/esm/internal/theme/get-theme.js +0 -73
- package/dist/types/internal/theme/get-theme.d.ts +0 -5
- package/dist/types-ts4.5/internal/theme/get-theme.d.ts +0 -5
package/dist/esm/code-block.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/* code-block.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
/* eslint-disable @atlaskit/ui-styling-standard/no-unsafe-selectors */
|
|
3
|
+
/* eslint-disable @atlaskit/ui-styling-standard/no-nested-selectors */
|
|
4
|
+
import "./code-block.compiled.css";
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
7
|
import { memo, useCallback, useMemo } from 'react';
|
|
6
|
-
|
|
7
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
|
-
import { css, jsx } from '@emotion/react';
|
|
9
8
|
import { useHighlightLines } from './internal/hooks/use-highlight';
|
|
10
|
-
import {
|
|
9
|
+
import { getLineNumWidth } from './internal/theme/styles';
|
|
11
10
|
import { normalizeLanguage } from './internal/utils/get-normalized-language';
|
|
12
11
|
import SyntaxHighlighter from './syntax-highlighter';
|
|
12
|
+
var getCodeBlockStyles = {
|
|
13
|
+
root: "_2rkoglpi _1dqoglyw _1wyb1crf _k48pi7a9 _1e0c1txw _vwz4gktf _1reo1wug _o572qvpr _1eimjvyg _bfhktkvp _syaz1fxt _ect41odn _1ozdn7od _7xinn7od _t7aun7od _1v15u2gc _ilvcu2gc _m29uu2gc _17wyu2gc _pn28u2gc _gz9fu2gc _1hmyegat _vblregat _vbulegat _wozj1dyw _1agb1dyw _lkm81dyw _tv41hkgb _1hmimyb0 _1ra01n1a _1d4j1y44 _1f8gstnw _1pzyb3bt _j1w0ww7y _13cdh2mm _15ba126e _zvy9f705 _qcxof705 _14y71a66 _j0l11wug _1weckb7n _1na21hna _1xx2grf3 _x7c815vq _lh0y15vq _1m3815vq _qk1e15vq _12l6ysn8 _uga3ysn8 _mx8b7mnp _1kr87mnp _xo19t94y _1bemt94y _nalpstnw _151dstnw _1exb1q9c _1hgu1q9c _1mgnt94y _nhket94y _h909m7j4 _scgayz1z _ipl81e17 _jeky1l04 _1gec1a66 _1gx21e5h _1ls0df4r _vm2c1rh5 _12ok1rh5 _1ls01ule _rude1ule _1q16glyw _1io6glyw _juomusic _lcwuusic _1552u2gc _12afu2gc _28ddu2gc _1i8zu2gc _12tu1a66 _zu0j1a66 _euyxusvi _cahfusvi _zhnuidpf _1amdidpf _mbgcpf9b _bu7zpf9b _131n1giz _gy101giz _1wfuwrk5 _16kzwrk5 _9kk3moej _cjus1w1g _9k2r1m30 _nhmw1m30 _yl021m30 _eiht5x2v _t9zb5x2v _mqok1w1g _3hsg1w1g _i7ngn7od _9wu1fb2s _1xcoh55r _1t361fxt _137bh55r _1k7d1fxt _97lipnps _12nh9lu1 _1g0517qg _i2ig10m5 _326z1fxt _113p131l _1n6tpnps _tgu817qg _1k47pnps _g0lx1fxt _ys4e131l _7gp8h55r _1yvq10m5 _1vww10m5 _1rju10m5 _1v0lh55r _wmyy17qg _748n17qg _1mfn17qg _1d7e17qg _p2vr17qg _19o610m5 _kxov17qg _1np517qg _m2f517qg _1b9tpnps _1tq6pnps _1rd2pnps _1pbkpnps _k3lipnps _13zt131l _2g12fb2s _k86b10m5 _b5iy131l _gti3131l _1f0gpnps _9d3e17qg _qdiapnps _72uvpnps",
|
|
14
|
+
showLineNumbers: "_17071olh _1i3h1txw _1huoidpf _1a9lidpf _20bqidpf _1oggidpf _bympidpf _9nnjidpf",
|
|
15
|
+
dontShowLineNumbers: "_1i3h1ule _1huou2gc _1a9lu2gc _20bqu2gc _1oggu2gc _bympu2gc _9nnju2gc",
|
|
16
|
+
shouldWrapLongLines: "_13dgkb7n",
|
|
17
|
+
dontWrapLongLines: "_13dgkb7n"
|
|
18
|
+
};
|
|
13
19
|
|
|
14
20
|
/**
|
|
15
21
|
* __Code block__
|
|
@@ -43,17 +49,7 @@ var CodeBlock = /*#__PURE__*/memo(function CodeBlock(_ref) {
|
|
|
43
49
|
_ref$shouldWrapLongLi = _ref.shouldWrapLongLines,
|
|
44
50
|
shouldWrapLongLines = _ref$shouldWrapLongLi === void 0 ? false : _ref$shouldWrapLongLi;
|
|
45
51
|
var numLines = (text || '').split('\n').length + (firstLineNumber > 0 ? firstLineNumber : 1) - 1;
|
|
46
|
-
var
|
|
47
|
-
return getCodeBlockTheme(numLines);
|
|
48
|
-
}, [numLines]);
|
|
49
|
-
var getStyles = useMemo(function () {
|
|
50
|
-
return getCodeBlockStyles(theme);
|
|
51
|
-
}, [theme]);
|
|
52
|
-
var styles = useMemo(function () {
|
|
53
|
-
return css(
|
|
54
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
55
|
-
getStyles(highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines));
|
|
56
|
-
}, [highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines, getStyles]);
|
|
52
|
+
var lineNumberWidth = numLines ? getLineNumWidth(numLines) : 0;
|
|
57
53
|
var _useHighlightLines = useHighlightLines({
|
|
58
54
|
highlight: highlight,
|
|
59
55
|
testId: testId
|
|
@@ -69,12 +65,16 @@ var CodeBlock = /*#__PURE__*/memo(function CodeBlock(_ref) {
|
|
|
69
65
|
|
|
70
66
|
// https://product-fabric.atlassian.net/browse/DST-2472
|
|
71
67
|
var languageToUse = text ? language : 'text';
|
|
72
|
-
return
|
|
68
|
+
return /*#__PURE__*/React.createElement(SyntaxHighlighter, {
|
|
73
69
|
"data-code-lang": language,
|
|
74
70
|
"data-ds--code--code-block": "",
|
|
75
71
|
testId: testId,
|
|
76
72
|
language: languageToUse,
|
|
77
|
-
|
|
73
|
+
style: {
|
|
74
|
+
'--ads-code-line-number-width': "calc(".concat(lineNumberWidth, " + 16px)"),
|
|
75
|
+
'--ads-highlighted-start-text': highlightedStartText,
|
|
76
|
+
'--ads-highlighted-end-text': highlightedEndText
|
|
77
|
+
},
|
|
78
78
|
showLineNumbers: showLineNumbers,
|
|
79
79
|
firstLineNumber: firstLineNumber,
|
|
80
80
|
lineProps: getLineProps
|
|
@@ -87,7 +87,8 @@ var CodeBlock = /*#__PURE__*/memo(function CodeBlock(_ref) {
|
|
|
87
87
|
codeBidiWarnings: codeBidiWarnings,
|
|
88
88
|
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
89
89
|
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled,
|
|
90
|
-
text: text
|
|
90
|
+
text: text,
|
|
91
|
+
className: ax([getCodeBlockStyles.root, shouldWrapLongLines ? getCodeBlockStyles.shouldWrapLongLines : getCodeBlockStyles.dontWrapLongLines, showLineNumbers ? getCodeBlockStyles.showLineNumbers : getCodeBlockStyles.dontShowLineNumbers])
|
|
91
92
|
});
|
|
92
93
|
});
|
|
93
94
|
CodeBlock.displayName = 'CodeBlock';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
._11c81u0j{font:var(--ds-font-code,normal 400 .875em/1 ui-monospace,Menlo,"Segoe UI Mono","Ubuntu Mono",monospace)}
|
|
2
|
+
._2rko1sit{border-radius:var(--ds-border-radius,3px)}
|
|
3
|
+
._1dqoglyw{border-style:none}
|
|
4
|
+
._16d9qvcn{-webkit-box-decoration-break:clone;box-decoration-break:clone}
|
|
5
|
+
._18m91wug{overflow-y:auto}
|
|
6
|
+
._19bvm5ip{padding-left:.5ch}
|
|
7
|
+
._1e0c1nu9{display:inline}
|
|
8
|
+
._1i4q1hna{overflow-wrap:break-word}
|
|
9
|
+
._1reo1wug{overflow-x:auto}
|
|
10
|
+
._bfhktkvp{background-color:var(--ds--code--bg-color,var(--ds-background-neutral,#091e420f))}
|
|
11
|
+
._ca0qyh40{padding-top:2px}
|
|
12
|
+
._n3tdyh40{padding-bottom:2px}
|
|
13
|
+
._o5721jtm{white-space:pre-wrap}
|
|
14
|
+
._syaz1fxt{color:var(--ds-text,#172b4d)}
|
|
15
|
+
._u5f3m5ip{padding-right:.5ch}
|
|
16
|
+
._vwz41kw7{line-height:inherit}
|
package/dist/esm/code.js
CHANGED
|
@@ -1,35 +1,17 @@
|
|
|
1
|
+
/* code.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
1
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
4
|
var _excluded = ["testId"],
|
|
4
5
|
_excluded2 = ["children", "codeBidiWarnings", "codeBidiWarningLabel", "codeBidiWarningTooltipEnabled"];
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @jsx jsx
|
|
8
|
-
*/
|
|
6
|
+
import "./code.compiled.css";
|
|
7
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
9
8
|
import React, { forwardRef, memo } from 'react';
|
|
10
|
-
|
|
11
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
12
|
-
import { css, jsx } from '@emotion/react';
|
|
13
9
|
import CodeBidiWarning from './bidi-warning';
|
|
14
10
|
import codeBidiWarningDecorator from './bidi-warning/bidi-warning-decorator';
|
|
15
|
-
import { VAR_CODE_BG_COLOR } from './internal/theme/constants';
|
|
16
11
|
import { getCodeStyles } from './internal/theme/styles';
|
|
17
|
-
var styles =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
21
|
-
backgroundColor: "var(".concat(VAR_CODE_BG_COLOR, ", ", "var(--ds-background-neutral, #091E420F)", ")"),
|
|
22
|
-
borderRadius: "var(--ds-border-radius, 3px)",
|
|
23
|
-
borderStyle: 'none',
|
|
24
|
-
boxDecorationBreak: 'clone',
|
|
25
|
-
color: "var(--ds-text, #172B4D)",
|
|
26
|
-
font: "var(--ds-font-code, normal 400 0.875em/1 ui-monospace, Menlo, \"Segoe UI Mono\", \"Ubuntu Mono\", monospace)",
|
|
27
|
-
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
28
|
-
lineHeight: 'inherit',
|
|
29
|
-
overflow: 'auto',
|
|
30
|
-
overflowWrap: 'break-word',
|
|
31
|
-
whiteSpace: 'pre-wrap'
|
|
32
|
-
});
|
|
12
|
+
var styles = {
|
|
13
|
+
base: "_ca0qyh40 _u5f3m5ip _n3tdyh40 _19bvm5ip _2rko1sit _11c81u0j _1reo1wug _18m91wug _1dqoglyw _1e0c1nu9 _bfhktkvp _16d9qvcn _syaz1fxt _vwz41kw7 _1i4q1hna _o5721jtm"
|
|
14
|
+
};
|
|
33
15
|
|
|
34
16
|
/**
|
|
35
17
|
* __Code__
|
|
@@ -52,18 +34,16 @@ var Code = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Code(_ref, ref) {
|
|
|
52
34
|
_props$codeBidiWarnin2 = props.codeBidiWarningTooltipEnabled,
|
|
53
35
|
codeBidiWarningTooltipEnabled = _props$codeBidiWarnin2 === void 0 ? true : _props$codeBidiWarnin2,
|
|
54
36
|
otherProps = _objectWithoutProperties(props, _excluded2);
|
|
55
|
-
var decoratedChildren = codeBidiWarnings ?
|
|
37
|
+
var decoratedChildren = codeBidiWarnings ? /*#__PURE__*/React.createElement(RenderCodeChildrenWithBidiWarnings, {
|
|
56
38
|
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
57
39
|
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
58
40
|
}, children) : children;
|
|
59
|
-
return (
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}, otherProps), decoratedChildren)
|
|
66
|
-
);
|
|
41
|
+
return /*#__PURE__*/React.createElement("code", _extends({
|
|
42
|
+
ref: ref,
|
|
43
|
+
"data-testid": testId
|
|
44
|
+
}, otherProps, {
|
|
45
|
+
className: ax([styles.base])
|
|
46
|
+
}), decoratedChildren);
|
|
67
47
|
}));
|
|
68
48
|
function RenderCodeChildrenWithBidiWarnings(_ref2) {
|
|
69
49
|
var children = _ref2.children,
|
|
@@ -74,7 +54,7 @@ function RenderCodeChildrenWithBidiWarnings(_ref2) {
|
|
|
74
54
|
var decorated = codeBidiWarningDecorator(childNode, function (_ref3) {
|
|
75
55
|
var bidiCharacter = _ref3.bidiCharacter,
|
|
76
56
|
index = _ref3.index;
|
|
77
|
-
return
|
|
57
|
+
return /*#__PURE__*/React.createElement(CodeBidiWarning, {
|
|
78
58
|
bidiCharacter: bidiCharacter,
|
|
79
59
|
key: index,
|
|
80
60
|
label: codeBidiWarningLabel,
|
|
@@ -86,7 +66,7 @@ function RenderCodeChildrenWithBidiWarnings(_ref2) {
|
|
|
86
66
|
if (isReactElement(childNode) && childNode.props.children) {
|
|
87
67
|
// eslint-disable-next-line @repo/internal/react/no-clone-element
|
|
88
68
|
var newChildNode = /*#__PURE__*/React.cloneElement(childNode, {
|
|
89
|
-
children:
|
|
69
|
+
children: /*#__PURE__*/React.createElement(RenderCodeChildrenWithBidiWarnings, {
|
|
90
70
|
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
91
71
|
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
92
72
|
}, childNode.props.children)
|
|
@@ -95,7 +75,7 @@ function RenderCodeChildrenWithBidiWarnings(_ref2) {
|
|
|
95
75
|
}
|
|
96
76
|
return childNode;
|
|
97
77
|
});
|
|
98
|
-
return
|
|
78
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, replacedChildren);
|
|
99
79
|
}
|
|
100
80
|
function isReactElement(child) {
|
|
101
81
|
return !!child.type;
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
2
|
-
import { gridSize } from '@atlaskit/theme/constants';
|
|
3
|
-
export var CODE_FONT_SIZE = 12;
|
|
4
|
-
export var CODE_LINE_HEIGHT = '20px';
|
|
5
|
-
export var HIGHLIGHT_BORDER_WIDTH = '4px';
|
|
6
|
-
export var SPACING = gridSize();
|
|
7
|
-
export var LINE_NUMBER_GUTTER = SPACING * 2;
|
|
8
|
-
export var VAR_CODE_LINE_NUMBER_BG_COLOR = '--ds--code--line-number-bg-color';
|
|
9
|
-
export var VAR_CODE_BG_COLOR = '--ds--code--bg-color';
|
|
10
|
-
|
|
11
1
|
// selector for codeblock
|
|
12
2
|
export var CODE_BLOCK_SELECTOR = "data-ds--code--code-block";
|
|
@@ -1,320 +1,26 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
5
|
-
|
|
6
|
-
import { CODE_FONT_SIZE, CODE_LINE_HEIGHT, HIGHLIGHT_BORDER_WIDTH, LINE_NUMBER_GUTTER, SPACING, VAR_CODE_BG_COLOR, VAR_CODE_LINE_NUMBER_BG_COLOR } from './constants';
|
|
7
|
-
import { getBaseTheme, getColorPalette } from './get-theme';
|
|
8
1
|
export var getLineNumWidth = function getLineNumWidth(numLines) {
|
|
9
|
-
|
|
10
|
-
return '1ch';
|
|
11
|
-
}
|
|
12
|
-
return "".concat(numLines.toFixed(0).length, "ch");
|
|
13
|
-
};
|
|
14
|
-
var lineNumberStyle = function lineNumberStyle(theme) {
|
|
15
|
-
return {
|
|
16
|
-
// width of the line number gutter
|
|
17
|
-
minWidth: "calc(".concat(theme.lineNumberWidth, " + ").concat(LINE_NUMBER_GUTTER, "px) !important"),
|
|
18
|
-
// this needs to be important or it gets overwritten by inline styles
|
|
19
|
-
fontStyle: 'normal !important',
|
|
20
|
-
// this needs to be important or it gets overwritten by inline styles
|
|
21
|
-
color: "".concat(theme.lineNumberColor, " !important"),
|
|
22
|
-
flexShrink: 0,
|
|
23
|
-
// needed to replicate existing design spec
|
|
24
|
-
boxSizing: 'border-box',
|
|
25
|
-
paddingRight: "".concat(SPACING, "px !important"),
|
|
26
|
-
paddingLeft: SPACING,
|
|
27
|
-
marginRight: SPACING,
|
|
28
|
-
textAlign: 'right',
|
|
29
|
-
userSelect: 'none',
|
|
30
|
-
// this is to fix SSR spacing issue
|
|
31
|
-
display: 'block',
|
|
32
|
-
// This is how we are preventing line numbers being copied to clipboard.
|
|
33
|
-
// (`user-select: none;` was not sufficent).
|
|
34
|
-
// https://product-fabric.atlassian.net/browse/DSP-2729
|
|
35
|
-
'&::after': {
|
|
36
|
-
content: "attr(data-ds--line-number)"
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// order of these keys does matter as it will affect the css precedence
|
|
42
|
-
var syntaxKeywordColors = function syntaxKeywordColors(theme) {
|
|
43
|
-
return {
|
|
44
|
-
'.token': {
|
|
45
|
-
// this specifically stops prism css cascading.
|
|
46
|
-
'&:not([class=token],[data-ds--code--row--highlight],[data-ds--code--row])': {
|
|
47
|
-
all: 'unset'
|
|
48
|
-
},
|
|
49
|
-
// additional specificity required to match the all: unset
|
|
50
|
-
'&.key,&.keyword': {
|
|
51
|
-
color: theme.keywordColor,
|
|
52
|
-
fontWeight: 'bolder'
|
|
53
|
-
},
|
|
54
|
-
'&.attr-name': {
|
|
55
|
-
color: theme.attributeColor
|
|
56
|
-
},
|
|
57
|
-
'&.selector': {
|
|
58
|
-
color: theme.selectorTagColor
|
|
59
|
-
},
|
|
60
|
-
'&.comment,&.block-comment': {
|
|
61
|
-
color: theme.commentColor,
|
|
62
|
-
fontFamily: theme.fontFamilyItalic,
|
|
63
|
-
fontStyle: 'italic'
|
|
64
|
-
},
|
|
65
|
-
'&.function-name': {
|
|
66
|
-
color: theme.sectionColor
|
|
67
|
-
},
|
|
68
|
-
'&.doctype': {
|
|
69
|
-
color: theme.docTagColor
|
|
70
|
-
},
|
|
71
|
-
'&.substr': {
|
|
72
|
-
color: theme.substringColor
|
|
73
|
-
},
|
|
74
|
-
'&.namespace': {
|
|
75
|
-
color: theme.nameColor
|
|
76
|
-
},
|
|
77
|
-
'&.builtin': {
|
|
78
|
-
color: theme.builtInColor
|
|
79
|
-
},
|
|
80
|
-
'&.entity': {
|
|
81
|
-
color: theme.literalColor
|
|
82
|
-
},
|
|
83
|
-
'&.bullet': {
|
|
84
|
-
color: theme.bulletColor
|
|
85
|
-
},
|
|
86
|
-
'&.code': {
|
|
87
|
-
color: theme.codeColor
|
|
88
|
-
},
|
|
89
|
-
'&.regex': {
|
|
90
|
-
color: theme.regexpColor
|
|
91
|
-
},
|
|
92
|
-
'&.symbol': {
|
|
93
|
-
color: theme.symbolColor
|
|
94
|
-
},
|
|
95
|
-
'&.variable': {
|
|
96
|
-
color: theme.variableColor
|
|
97
|
-
},
|
|
98
|
-
'&.url': {
|
|
99
|
-
color: theme.linkColor
|
|
100
|
-
},
|
|
101
|
-
'&.selector-attr': {
|
|
102
|
-
color: theme.selectorAttributeColor
|
|
103
|
-
},
|
|
104
|
-
'&.selector-pseudo': {
|
|
105
|
-
color: theme.selectorPseudoColor
|
|
106
|
-
},
|
|
107
|
-
'&.type': {
|
|
108
|
-
color: theme.typeColor
|
|
109
|
-
},
|
|
110
|
-
'&.quote': {
|
|
111
|
-
color: theme.quoteColor
|
|
112
|
-
},
|
|
113
|
-
'&.tag': {
|
|
114
|
-
color: theme.templateTagColor
|
|
115
|
-
},
|
|
116
|
-
'&.string': {
|
|
117
|
-
color: theme.stringColor
|
|
118
|
-
},
|
|
119
|
-
'&.class-name': {
|
|
120
|
-
color: theme.sectionColor
|
|
121
|
-
},
|
|
122
|
-
'&.title': {
|
|
123
|
-
color: theme.titleColor
|
|
124
|
-
},
|
|
125
|
-
'&.section': {
|
|
126
|
-
color: theme.sectionColor
|
|
127
|
-
},
|
|
128
|
-
'&.meta-keyword': {
|
|
129
|
-
color: theme.metaKeywordColor
|
|
130
|
-
},
|
|
131
|
-
'&.meta': {
|
|
132
|
-
color: theme.metaColor
|
|
133
|
-
},
|
|
134
|
-
'&.italic': {
|
|
135
|
-
fontStyle: 'italic'
|
|
136
|
-
},
|
|
137
|
-
'&.bold': {
|
|
138
|
-
fontWeight: 'bolder'
|
|
139
|
-
},
|
|
140
|
-
'&.function': {
|
|
141
|
-
color: theme.functionColor
|
|
142
|
-
},
|
|
143
|
-
'&.number': {
|
|
144
|
-
color: theme.numberColor
|
|
145
|
-
},
|
|
146
|
-
'&.attr-value': {
|
|
147
|
-
color: theme.attributeColor
|
|
148
|
-
},
|
|
149
|
-
'&.prolog': {
|
|
150
|
-
color: theme.prologColor
|
|
151
|
-
},
|
|
152
|
-
'&.cdata': {
|
|
153
|
-
color: theme.cdataColor
|
|
154
|
-
},
|
|
155
|
-
'&.punctuation': {
|
|
156
|
-
color: theme.punctuationColor
|
|
157
|
-
},
|
|
158
|
-
'&.property': {
|
|
159
|
-
color: theme.propertyColor
|
|
160
|
-
},
|
|
161
|
-
'&.constant': {
|
|
162
|
-
color: theme.constantColor
|
|
163
|
-
},
|
|
164
|
-
'&.deleted': {
|
|
165
|
-
color: theme.deletedColor
|
|
166
|
-
},
|
|
167
|
-
'&.boolean': {
|
|
168
|
-
color: theme.booleanColor
|
|
169
|
-
},
|
|
170
|
-
'&.char': {
|
|
171
|
-
color: theme.charColor
|
|
172
|
-
},
|
|
173
|
-
'&.inserted': {
|
|
174
|
-
color: theme.insertedColor
|
|
175
|
-
},
|
|
176
|
-
'&.operator': {
|
|
177
|
-
color: theme.operatorColor
|
|
178
|
-
},
|
|
179
|
-
'&.atrule': {
|
|
180
|
-
color: theme.atruleColor
|
|
181
|
-
},
|
|
182
|
-
'&.important': {
|
|
183
|
-
color: theme.importantColor,
|
|
184
|
-
fontWeight: "var(--ds-font-weight-bold, 700)"
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Styles applied at the root element level, common across code/codeblock
|
|
192
|
-
*/
|
|
193
|
-
var getBaseCodeStyles = function getBaseCodeStyles(theme) {
|
|
194
|
-
return {
|
|
195
|
-
fontSize: CODE_FONT_SIZE,
|
|
196
|
-
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
197
|
-
fontFamily: theme.fontFamily,
|
|
198
|
-
fontWeight: "var(--ds-font-weight-regular, 400)",
|
|
199
|
-
backgroundColor: "var(".concat(VAR_CODE_BG_COLOR, ",").concat(theme.backgroundColor, ")"),
|
|
200
|
-
color: theme.textColor,
|
|
201
|
-
borderStyle: 'none',
|
|
202
|
-
borderRadius: "var(--ds-border-radius, 3px)"
|
|
203
|
-
};
|
|
2
|
+
return !numLines ? '1ch' : "".concat(numLines.toFixed(0).length, "ch");
|
|
204
3
|
};
|
|
205
4
|
|
|
5
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required
|
|
206
6
|
/**
|
|
207
|
-
*
|
|
208
|
-
* react-syntax-highlighter.
|
|
209
|
-
*
|
|
210
|
-
* @param theme
|
|
7
|
+
* @deprecated
|
|
211
8
|
*/
|
|
212
|
-
export var getCodeBlockStyles = function getCodeBlockStyles(theme) {
|
|
213
|
-
return function (highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines) {
|
|
214
|
-
return _objectSpread(_objectSpread(_objectSpread({
|
|
215
|
-
// this is required to account for prismjs styles leaking into the codeblock
|
|
216
|
-
'code[class*="language-"], pre[class*="language-"], code': {
|
|
217
|
-
all: 'unset',
|
|
218
|
-
padding: showLineNumbers ? "".concat(SPACING, "px 0") : SPACING,
|
|
219
|
-
tabSize: 4
|
|
220
|
-
},
|
|
221
|
-
display: 'flex',
|
|
222
|
-
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
223
|
-
lineHeight: CODE_LINE_HEIGHT,
|
|
224
|
-
overflowX: 'auto',
|
|
225
|
-
whiteSpace: 'pre',
|
|
226
|
-
direction: 'ltr'
|
|
227
|
-
}, getBaseCodeStyles(theme)), syntaxKeywordColors(theme)), {}, {
|
|
228
|
-
// this is to account for SSR spacing issue once loaded in browser
|
|
229
|
-
'& .linenumber, .ds-sh-line-number': lineNumberStyle(theme),
|
|
230
|
-
'& .linenumber': {
|
|
231
|
-
display: 'inline-block !important',
|
|
232
|
-
float: 'left'
|
|
233
|
-
},
|
|
234
|
-
// these styles are for line highlighting
|
|
235
|
-
'& [data-ds--code--row]': {
|
|
236
|
-
display: showLineNumbers ? 'flex' : 'block',
|
|
237
|
-
paddingRight: "".concat(SPACING, "px !important"),
|
|
238
|
-
marginRight: "-".concat(SPACING, "px")
|
|
239
|
-
},
|
|
240
|
-
'& [data-ds--code--row--highlight]': {
|
|
241
|
-
background: "".concat(theme.highlightedLineBgColor),
|
|
242
|
-
// eslint-disable-next-line @atlaskit/design-system/use-visually-hidden
|
|
243
|
-
'&::before, &::after': {
|
|
244
|
-
clipPath: 'inset(100%)',
|
|
245
|
-
clip: 'rect(1px, 1px, 1px, 1px)',
|
|
246
|
-
height: '1px',
|
|
247
|
-
overflow: 'hidden',
|
|
248
|
-
position: 'absolute',
|
|
249
|
-
whiteSpace: 'nowrap',
|
|
250
|
-
width: '1px'
|
|
251
|
-
},
|
|
252
|
-
// The formatting here is an accessibility convention
|
|
253
|
-
'&::before': {
|
|
254
|
-
content: "\" [".concat(highlightedStartText, "] \"")
|
|
255
|
-
},
|
|
256
|
-
'&::after': {
|
|
257
|
-
content: "\" [".concat(highlightedEndText, "] \"")
|
|
258
|
-
}
|
|
259
|
-
},
|
|
260
|
-
'& [data-ds--code--row--highlight] .linenumber': {
|
|
261
|
-
borderLeft: "".concat(HIGHLIGHT_BORDER_WIDTH, " solid ").concat(theme.highlightedLineBorderColor),
|
|
262
|
-
paddingLeft: "".concat(SPACING / 2, "px !important"),
|
|
263
|
-
position: 'relative'
|
|
264
|
-
},
|
|
265
|
-
// fill in space caused by parent border top
|
|
266
|
-
'& [data-ds--code--row--highlight] .linenumber::before': {
|
|
267
|
-
content: '""',
|
|
268
|
-
position: 'absolute',
|
|
269
|
-
width: HIGHLIGHT_BORDER_WIDTH,
|
|
270
|
-
top: '-1px',
|
|
271
|
-
left: "-".concat(HIGHLIGHT_BORDER_WIDTH),
|
|
272
|
-
borderTop: "1px solid ".concat(theme.highlightedLineBorderColor)
|
|
273
|
-
},
|
|
274
|
-
'[data-ds--code--row--highlight] + [data-ds--code--row]:not([data-ds--code--row--highlight]), [data-ds--code--row]:not([data-ds--code--row--highlight]) + [data-ds--code--row--highlight]': {
|
|
275
|
-
borderTop: '1px dashed transparent'
|
|
276
|
-
},
|
|
277
|
-
'[data-ds--code--row--highlight]:last-child': {
|
|
278
|
-
borderBottom: '1px dashed transparent'
|
|
279
|
-
},
|
|
280
|
-
'& code:first-of-type': {
|
|
281
|
-
paddingRight: "0px !important",
|
|
282
|
-
backgroundImage: showLineNumbers ? "linear-gradient(to right, var(".concat(VAR_CODE_LINE_NUMBER_BG_COLOR, ",").concat(theme.lineNumberBgColor, "), var(").concat(VAR_CODE_LINE_NUMBER_BG_COLOR, ",").concat(theme.lineNumberBgColor, ")\n calc(").concat(theme.lineNumberWidth, " + ").concat(LINE_NUMBER_GUTTER, "px), transparent calc(").concat(theme.lineNumberWidth, " + ").concat(LINE_NUMBER_GUTTER, "px), transparent)") : undefined
|
|
283
|
-
},
|
|
284
|
-
// we need to use last-of-type because when Code is SSR'd
|
|
285
|
-
// 2 <code> elements are created and we don't want this style
|
|
286
|
-
// applied to the first one
|
|
287
|
-
'& code:last-of-type': {
|
|
288
|
-
paddingRight: "".concat(SPACING, "px !important"),
|
|
289
|
-
flexBasis: 'auto',
|
|
290
|
-
flexGrow: 1,
|
|
291
|
-
// Needed for the highlight line to extend full-width
|
|
292
|
-
flexShrink: shouldWrapLongLines ? 1 : 0,
|
|
293
|
-
wordBreak: 'break-word'
|
|
294
|
-
},
|
|
295
|
-
// Prevents empty code blocks from vertically collapsing
|
|
296
|
-
'code > span:only-child:empty:before, code > span:only-child > span:only-child:empty:before': {
|
|
297
|
-
content: '" "'
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
};
|
|
301
|
-
};
|
|
302
9
|
export var getCodeStyles = function getCodeStyles() {
|
|
303
|
-
|
|
304
|
-
var baseStyles = getBaseCodeStyles(theme);
|
|
305
|
-
return _objectSpread(_objectSpread({}, baseStyles), {}, {
|
|
10
|
+
return {
|
|
306
11
|
display: 'inline',
|
|
307
12
|
padding: '2px 0.5ch',
|
|
13
|
+
backgroundColor: "var(--ds--code--bg-color,".concat("var(--ds-background-neutral, #091E420F)", ")"),
|
|
14
|
+
borderRadius: "var(--ds-border-radius, 3px)",
|
|
15
|
+
borderStyle: 'none',
|
|
308
16
|
boxDecorationBreak: 'clone',
|
|
17
|
+
color: "var(--ds-text, #172B4D)",
|
|
18
|
+
fontFamily: "var(--ds-font-family-code, ui-monospace, Menlo, \"Segoe UI Mono\", \"Ubuntu Mono\", monospace)",
|
|
309
19
|
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
310
20
|
fontSize: '0.875em',
|
|
21
|
+
fontWeight: "var(--ds-font-weight-regular, 400)",
|
|
311
22
|
overflow: 'auto',
|
|
312
23
|
overflowWrap: 'break-word',
|
|
313
24
|
whiteSpace: 'pre-wrap'
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
export var getCodeBlockTheme = function getCodeBlockTheme(maxLines) {
|
|
317
|
-
return _objectSpread(_objectSpread(_objectSpread({}, getBaseTheme()), getColorPalette()), {}, {
|
|
318
|
-
lineNumberWidth: maxLines ? getLineNumWidth(maxLines) : undefined
|
|
319
|
-
});
|
|
25
|
+
};
|
|
320
26
|
};
|
|
@@ -6,9 +6,6 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
6
6
|
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
7
7
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
8
8
|
import React from 'react';
|
|
9
|
-
|
|
10
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
11
|
-
|
|
12
9
|
// This wrapper supports the async loading of refractor and language grammars. The internal Highlight is a memo() functional component as expected
|
|
13
10
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
14
11
|
export var SyntaxHighlighter = /*#__PURE__*/function (_React$PureComponent) {
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
5
|
import { type ReactNode } from 'react';
|
|
6
|
-
import { jsx } from '@emotion/react';
|
|
7
6
|
export declare function Decorator({ bidiCharacter, children, testId, }: {
|
|
8
7
|
bidiCharacter: string;
|
|
9
8
|
children: ReactNode;
|
|
10
9
|
testId?: string;
|
|
11
|
-
}):
|
|
10
|
+
}): JSX.Element;
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
export declare const CODE_FONT_SIZE = 12;
|
|
2
|
-
export declare const CODE_LINE_HEIGHT = "20px";
|
|
3
|
-
export declare const HIGHLIGHT_BORDER_WIDTH = "4px";
|
|
4
|
-
export declare const SPACING: number;
|
|
5
|
-
export declare const LINE_NUMBER_GUTTER: number;
|
|
6
|
-
export declare const VAR_CODE_LINE_NUMBER_BG_COLOR = "--ds--code--line-number-bg-color";
|
|
7
|
-
export declare const VAR_CODE_BG_COLOR = "--ds--code--bg-color";
|
|
8
1
|
export declare const CODE_BLOCK_SELECTOR = "data-ds--code--code-block";
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import type { CSSObject } from '@emotion/react';
|
|
2
|
-
import type { CodeBlockTheme } from './types';
|
|
3
1
|
export declare const getLineNumWidth: (numLines: number) => string;
|
|
4
2
|
/**
|
|
5
|
-
*
|
|
6
|
-
* react-syntax-highlighter.
|
|
7
|
-
*
|
|
8
|
-
* @param theme
|
|
3
|
+
* @deprecated
|
|
9
4
|
*/
|
|
10
|
-
export declare const
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
export declare const getCodeStyles: () => {
|
|
6
|
+
display: string;
|
|
7
|
+
padding: string;
|
|
8
|
+
backgroundColor: string;
|
|
9
|
+
borderRadius: "var(--ds-border-radius)";
|
|
10
|
+
borderStyle: string;
|
|
11
|
+
boxDecorationBreak: string;
|
|
12
|
+
color: "var(--ds-text)";
|
|
13
|
+
fontFamily: "var(--ds-font-family-code)";
|
|
14
|
+
fontSize: string;
|
|
15
|
+
fontWeight: "var(--ds-font-weight-regular)";
|
|
16
|
+
overflow: string;
|
|
17
|
+
overflowWrap: string;
|
|
18
|
+
whiteSpace: string;
|
|
19
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { XCSSAllProperties, XCSSAllPseudos, XCSSProp } from '@compiled/react';
|
|
3
3
|
import { type AST, type RefractorNode } from 'refractor';
|
|
4
4
|
export type { AST, RefractorNode } from 'refractor';
|
|
5
5
|
export declare class SyntaxHighlighter extends React.PureComponent<SyntaxHighlighterProps> {
|
|
@@ -68,9 +68,9 @@ export interface SyntaxHighlighterProps {
|
|
|
68
68
|
*/
|
|
69
69
|
shouldWrapLongLines?: boolean;
|
|
70
70
|
/**
|
|
71
|
-
* Serialized styles returned from
|
|
71
|
+
* Serialized styles returned from Compiled's `css()` function.
|
|
72
72
|
*/
|
|
73
|
-
styles?:
|
|
73
|
+
styles?: XCSSProp<XCSSAllProperties, XCSSAllPseudos>;
|
|
74
74
|
/**
|
|
75
75
|
* `codeBidiWarnings` is set via a prop on @atlaskit/code/CodeBlock.
|
|
76
76
|
*
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
* @jsx jsx
|
|
4
4
|
*/
|
|
5
5
|
import { type ReactNode } from 'react';
|
|
6
|
-
import { jsx } from '@emotion/react';
|
|
7
6
|
export declare function Decorator({ bidiCharacter, children, testId, }: {
|
|
8
7
|
bidiCharacter: string;
|
|
9
8
|
children: ReactNode;
|
|
10
9
|
testId?: string;
|
|
11
|
-
}):
|
|
10
|
+
}): JSX.Element;
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
export declare const CODE_FONT_SIZE = 12;
|
|
2
|
-
export declare const CODE_LINE_HEIGHT = "20px";
|
|
3
|
-
export declare const HIGHLIGHT_BORDER_WIDTH = "4px";
|
|
4
|
-
export declare const SPACING: number;
|
|
5
|
-
export declare const LINE_NUMBER_GUTTER: number;
|
|
6
|
-
export declare const VAR_CODE_LINE_NUMBER_BG_COLOR = "--ds--code--line-number-bg-color";
|
|
7
|
-
export declare const VAR_CODE_BG_COLOR = "--ds--code--bg-color";
|
|
8
1
|
export declare const CODE_BLOCK_SELECTOR = "data-ds--code--code-block";
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import type { CSSObject } from '@emotion/react';
|
|
2
|
-
import type { CodeBlockTheme } from './types';
|
|
3
1
|
export declare const getLineNumWidth: (numLines: number) => string;
|
|
4
2
|
/**
|
|
5
|
-
*
|
|
6
|
-
* react-syntax-highlighter.
|
|
7
|
-
*
|
|
8
|
-
* @param theme
|
|
3
|
+
* @deprecated
|
|
9
4
|
*/
|
|
10
|
-
export declare const
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
export declare const getCodeStyles: () => {
|
|
6
|
+
display: string;
|
|
7
|
+
padding: string;
|
|
8
|
+
backgroundColor: string;
|
|
9
|
+
borderRadius: "var(--ds-border-radius)";
|
|
10
|
+
borderStyle: string;
|
|
11
|
+
boxDecorationBreak: string;
|
|
12
|
+
color: "var(--ds-text)";
|
|
13
|
+
fontFamily: "var(--ds-font-family-code)";
|
|
14
|
+
fontSize: string;
|
|
15
|
+
fontWeight: "var(--ds-font-weight-regular)";
|
|
16
|
+
overflow: string;
|
|
17
|
+
overflowWrap: string;
|
|
18
|
+
whiteSpace: string;
|
|
19
|
+
};
|