@atlaskit/code 16.2.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 +32 -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/constants.js +4 -0
- 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/constants.js +4 -0
- 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/constants.js +4 -0
- 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/constants.d.ts +4 -0
- 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/constants.d.ts +8 -0
- 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 +6 -6
- 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
|
@@ -1,325 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports.getLineNumWidth = exports.getCodeStyles =
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _constants = require("./constants");
|
|
10
|
-
var _getTheme = require("./get-theme");
|
|
11
|
-
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; }
|
|
12
|
-
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) { (0, _defineProperty2.default)(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; } // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
6
|
+
exports.getLineNumWidth = exports.getCodeStyles = void 0;
|
|
13
7
|
var getLineNumWidth = exports.getLineNumWidth = function getLineNumWidth(numLines) {
|
|
14
|
-
|
|
15
|
-
return '1ch';
|
|
16
|
-
}
|
|
17
|
-
return "".concat(numLines.toFixed(0).length, "ch");
|
|
18
|
-
};
|
|
19
|
-
var lineNumberStyle = function lineNumberStyle(theme) {
|
|
20
|
-
return {
|
|
21
|
-
// width of the line number gutter
|
|
22
|
-
minWidth: "calc(".concat(theme.lineNumberWidth, " + ").concat(_constants.LINE_NUMBER_GUTTER, "px) !important"),
|
|
23
|
-
// this needs to be important or it gets overwritten by inline styles
|
|
24
|
-
fontStyle: 'normal !important',
|
|
25
|
-
// this needs to be important or it gets overwritten by inline styles
|
|
26
|
-
color: "".concat(theme.lineNumberColor, " !important"),
|
|
27
|
-
flexShrink: 0,
|
|
28
|
-
// needed to replicate existing design spec
|
|
29
|
-
boxSizing: 'border-box',
|
|
30
|
-
paddingRight: "".concat(_constants.SPACING, "px !important"),
|
|
31
|
-
paddingLeft: _constants.SPACING,
|
|
32
|
-
marginRight: _constants.SPACING,
|
|
33
|
-
textAlign: 'right',
|
|
34
|
-
userSelect: 'none',
|
|
35
|
-
// this is to fix SSR spacing issue
|
|
36
|
-
display: 'block',
|
|
37
|
-
// This is how we are preventing line numbers being copied to clipboard.
|
|
38
|
-
// (`user-select: none;` was not sufficent).
|
|
39
|
-
// https://product-fabric.atlassian.net/browse/DSP-2729
|
|
40
|
-
'&::after': {
|
|
41
|
-
content: "attr(data-ds--line-number)"
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// order of these keys does matter as it will affect the css precedence
|
|
47
|
-
var syntaxKeywordColors = function syntaxKeywordColors(theme) {
|
|
48
|
-
return {
|
|
49
|
-
'.token': {
|
|
50
|
-
// this specifically stops prism css cascading.
|
|
51
|
-
'&:not([class=token],[data-ds--code--row--highlight],[data-ds--code--row])': {
|
|
52
|
-
all: 'unset'
|
|
53
|
-
},
|
|
54
|
-
// additional specificity required to match the all: unset
|
|
55
|
-
'&.key,&.keyword': {
|
|
56
|
-
color: theme.keywordColor,
|
|
57
|
-
fontWeight: 'bolder'
|
|
58
|
-
},
|
|
59
|
-
'&.attr-name': {
|
|
60
|
-
color: theme.attributeColor
|
|
61
|
-
},
|
|
62
|
-
'&.selector': {
|
|
63
|
-
color: theme.selectorTagColor
|
|
64
|
-
},
|
|
65
|
-
'&.comment,&.block-comment': {
|
|
66
|
-
color: theme.commentColor,
|
|
67
|
-
fontFamily: theme.fontFamilyItalic,
|
|
68
|
-
fontStyle: 'italic'
|
|
69
|
-
},
|
|
70
|
-
'&.function-name': {
|
|
71
|
-
color: theme.sectionColor
|
|
72
|
-
},
|
|
73
|
-
'&.doctype': {
|
|
74
|
-
color: theme.docTagColor
|
|
75
|
-
},
|
|
76
|
-
'&.substr': {
|
|
77
|
-
color: theme.substringColor
|
|
78
|
-
},
|
|
79
|
-
'&.namespace': {
|
|
80
|
-
color: theme.nameColor
|
|
81
|
-
},
|
|
82
|
-
'&.builtin': {
|
|
83
|
-
color: theme.builtInColor
|
|
84
|
-
},
|
|
85
|
-
'&.entity': {
|
|
86
|
-
color: theme.literalColor
|
|
87
|
-
},
|
|
88
|
-
'&.bullet': {
|
|
89
|
-
color: theme.bulletColor
|
|
90
|
-
},
|
|
91
|
-
'&.code': {
|
|
92
|
-
color: theme.codeColor
|
|
93
|
-
},
|
|
94
|
-
'&.regex': {
|
|
95
|
-
color: theme.regexpColor
|
|
96
|
-
},
|
|
97
|
-
'&.symbol': {
|
|
98
|
-
color: theme.symbolColor
|
|
99
|
-
},
|
|
100
|
-
'&.variable': {
|
|
101
|
-
color: theme.variableColor
|
|
102
|
-
},
|
|
103
|
-
'&.url': {
|
|
104
|
-
color: theme.linkColor
|
|
105
|
-
},
|
|
106
|
-
'&.selector-attr': {
|
|
107
|
-
color: theme.selectorAttributeColor
|
|
108
|
-
},
|
|
109
|
-
'&.selector-pseudo': {
|
|
110
|
-
color: theme.selectorPseudoColor
|
|
111
|
-
},
|
|
112
|
-
'&.type': {
|
|
113
|
-
color: theme.typeColor
|
|
114
|
-
},
|
|
115
|
-
'&.quote': {
|
|
116
|
-
color: theme.quoteColor
|
|
117
|
-
},
|
|
118
|
-
'&.tag': {
|
|
119
|
-
color: theme.templateTagColor
|
|
120
|
-
},
|
|
121
|
-
'&.string': {
|
|
122
|
-
color: theme.stringColor
|
|
123
|
-
},
|
|
124
|
-
'&.class-name': {
|
|
125
|
-
color: theme.sectionColor
|
|
126
|
-
},
|
|
127
|
-
'&.title': {
|
|
128
|
-
color: theme.titleColor
|
|
129
|
-
},
|
|
130
|
-
'&.section': {
|
|
131
|
-
color: theme.sectionColor
|
|
132
|
-
},
|
|
133
|
-
'&.meta-keyword': {
|
|
134
|
-
color: theme.metaKeywordColor
|
|
135
|
-
},
|
|
136
|
-
'&.meta': {
|
|
137
|
-
color: theme.metaColor
|
|
138
|
-
},
|
|
139
|
-
'&.italic': {
|
|
140
|
-
fontStyle: 'italic'
|
|
141
|
-
},
|
|
142
|
-
'&.bold': {
|
|
143
|
-
fontWeight: 'bolder'
|
|
144
|
-
},
|
|
145
|
-
'&.function': {
|
|
146
|
-
color: theme.functionColor
|
|
147
|
-
},
|
|
148
|
-
'&.number': {
|
|
149
|
-
color: theme.numberColor
|
|
150
|
-
},
|
|
151
|
-
'&.attr-value': {
|
|
152
|
-
color: theme.attributeColor
|
|
153
|
-
},
|
|
154
|
-
'&.prolog': {
|
|
155
|
-
color: theme.prologColor
|
|
156
|
-
},
|
|
157
|
-
'&.cdata': {
|
|
158
|
-
color: theme.cdataColor
|
|
159
|
-
},
|
|
160
|
-
'&.punctuation': {
|
|
161
|
-
color: theme.punctuationColor
|
|
162
|
-
},
|
|
163
|
-
'&.property': {
|
|
164
|
-
color: theme.propertyColor
|
|
165
|
-
},
|
|
166
|
-
'&.constant': {
|
|
167
|
-
color: theme.constantColor
|
|
168
|
-
},
|
|
169
|
-
'&.deleted': {
|
|
170
|
-
color: theme.deletedColor
|
|
171
|
-
},
|
|
172
|
-
'&.boolean': {
|
|
173
|
-
color: theme.booleanColor
|
|
174
|
-
},
|
|
175
|
-
'&.char': {
|
|
176
|
-
color: theme.charColor
|
|
177
|
-
},
|
|
178
|
-
'&.inserted': {
|
|
179
|
-
color: theme.insertedColor
|
|
180
|
-
},
|
|
181
|
-
'&.operator': {
|
|
182
|
-
color: theme.operatorColor
|
|
183
|
-
},
|
|
184
|
-
'&.atrule': {
|
|
185
|
-
color: theme.atruleColor
|
|
186
|
-
},
|
|
187
|
-
'&.important': {
|
|
188
|
-
color: theme.importantColor,
|
|
189
|
-
fontWeight: "var(--ds-font-weight-bold, 700)"
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
};
|
|
8
|
+
return !numLines ? '1ch' : "".concat(numLines.toFixed(0).length, "ch");
|
|
193
9
|
};
|
|
194
10
|
|
|
11
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required
|
|
195
12
|
/**
|
|
196
|
-
*
|
|
13
|
+
* @deprecated
|
|
197
14
|
*/
|
|
198
|
-
var getBaseCodeStyles = function getBaseCodeStyles(theme) {
|
|
199
|
-
return {
|
|
200
|
-
fontSize: _constants.CODE_FONT_SIZE,
|
|
201
|
-
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
202
|
-
fontFamily: theme.fontFamily,
|
|
203
|
-
fontWeight: "var(--ds-font-weight-regular, 400)",
|
|
204
|
-
backgroundColor: "var(".concat(_constants.VAR_CODE_BG_COLOR, ",").concat(theme.backgroundColor, ")"),
|
|
205
|
-
color: theme.textColor,
|
|
206
|
-
borderStyle: 'none',
|
|
207
|
-
borderRadius: "var(--ds-border-radius, 3px)"
|
|
208
|
-
};
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Takes an implemented CodeBlock theme, and returns styles required for
|
|
213
|
-
* react-syntax-highlighter.
|
|
214
|
-
*
|
|
215
|
-
* @param theme
|
|
216
|
-
*/
|
|
217
|
-
var getCodeBlockStyles = exports.getCodeBlockStyles = function getCodeBlockStyles(theme) {
|
|
218
|
-
return function (highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines) {
|
|
219
|
-
return _objectSpread(_objectSpread(_objectSpread({
|
|
220
|
-
// this is required to account for prismjs styles leaking into the codeblock
|
|
221
|
-
'code[class*="language-"], pre[class*="language-"], code': {
|
|
222
|
-
all: 'unset',
|
|
223
|
-
padding: showLineNumbers ? "".concat(_constants.SPACING, "px 0") : _constants.SPACING,
|
|
224
|
-
tabSize: 4
|
|
225
|
-
},
|
|
226
|
-
display: 'flex',
|
|
227
|
-
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
228
|
-
lineHeight: _constants.CODE_LINE_HEIGHT,
|
|
229
|
-
overflowX: 'auto',
|
|
230
|
-
whiteSpace: 'pre',
|
|
231
|
-
direction: 'ltr'
|
|
232
|
-
}, getBaseCodeStyles(theme)), syntaxKeywordColors(theme)), {}, {
|
|
233
|
-
// this is to account for SSR spacing issue once loaded in browser
|
|
234
|
-
'& .linenumber, .ds-sh-line-number': lineNumberStyle(theme),
|
|
235
|
-
'& .linenumber': {
|
|
236
|
-
display: 'inline-block !important',
|
|
237
|
-
float: 'left'
|
|
238
|
-
},
|
|
239
|
-
// these styles are for line highlighting
|
|
240
|
-
'& [data-ds--code--row]': {
|
|
241
|
-
display: showLineNumbers ? 'flex' : 'block',
|
|
242
|
-
paddingRight: "".concat(_constants.SPACING, "px !important"),
|
|
243
|
-
marginRight: "-".concat(_constants.SPACING, "px")
|
|
244
|
-
},
|
|
245
|
-
'& [data-ds--code--row--highlight]': {
|
|
246
|
-
background: "".concat(theme.highlightedLineBgColor),
|
|
247
|
-
// eslint-disable-next-line @atlaskit/design-system/use-visually-hidden
|
|
248
|
-
'&::before, &::after': {
|
|
249
|
-
clipPath: 'inset(100%)',
|
|
250
|
-
clip: 'rect(1px, 1px, 1px, 1px)',
|
|
251
|
-
height: '1px',
|
|
252
|
-
overflow: 'hidden',
|
|
253
|
-
position: 'absolute',
|
|
254
|
-
whiteSpace: 'nowrap',
|
|
255
|
-
width: '1px'
|
|
256
|
-
},
|
|
257
|
-
// The formatting here is an accessibility convention
|
|
258
|
-
'&::before': {
|
|
259
|
-
content: "\" [".concat(highlightedStartText, "] \"")
|
|
260
|
-
},
|
|
261
|
-
'&::after': {
|
|
262
|
-
content: "\" [".concat(highlightedEndText, "] \"")
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
'& [data-ds--code--row--highlight] .linenumber': {
|
|
266
|
-
borderLeft: "".concat(_constants.HIGHLIGHT_BORDER_WIDTH, " solid ").concat(theme.highlightedLineBorderColor),
|
|
267
|
-
paddingLeft: "".concat(_constants.SPACING / 2, "px !important"),
|
|
268
|
-
position: 'relative'
|
|
269
|
-
},
|
|
270
|
-
// fill in space caused by parent border top
|
|
271
|
-
'& [data-ds--code--row--highlight] .linenumber::before': {
|
|
272
|
-
content: '""',
|
|
273
|
-
position: 'absolute',
|
|
274
|
-
width: _constants.HIGHLIGHT_BORDER_WIDTH,
|
|
275
|
-
top: '-1px',
|
|
276
|
-
left: "-".concat(_constants.HIGHLIGHT_BORDER_WIDTH),
|
|
277
|
-
borderTop: "1px solid ".concat(theme.highlightedLineBorderColor)
|
|
278
|
-
},
|
|
279
|
-
'[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]': {
|
|
280
|
-
borderTop: '1px dashed transparent'
|
|
281
|
-
},
|
|
282
|
-
'[data-ds--code--row--highlight]:last-child': {
|
|
283
|
-
borderBottom: '1px dashed transparent'
|
|
284
|
-
},
|
|
285
|
-
'& code:first-of-type': {
|
|
286
|
-
paddingRight: "0px !important",
|
|
287
|
-
backgroundImage: showLineNumbers ? "linear-gradient(to right, var(".concat(_constants.VAR_CODE_LINE_NUMBER_BG_COLOR, ",").concat(theme.lineNumberBgColor, "), var(").concat(_constants.VAR_CODE_LINE_NUMBER_BG_COLOR, ",").concat(theme.lineNumberBgColor, ")\n calc(").concat(theme.lineNumberWidth, " + ").concat(_constants.LINE_NUMBER_GUTTER, "px), transparent calc(").concat(theme.lineNumberWidth, " + ").concat(_constants.LINE_NUMBER_GUTTER, "px), transparent)") : undefined
|
|
288
|
-
},
|
|
289
|
-
// we need to use last-of-type because when Code is SSR'd
|
|
290
|
-
// 2 <code> elements are created and we don't want this style
|
|
291
|
-
// applied to the first one
|
|
292
|
-
'& code:last-of-type': {
|
|
293
|
-
paddingRight: "".concat(_constants.SPACING, "px !important"),
|
|
294
|
-
flexBasis: 'auto',
|
|
295
|
-
flexGrow: 1,
|
|
296
|
-
// Needed for the highlight line to extend full-width
|
|
297
|
-
flexShrink: shouldWrapLongLines ? 1 : 0,
|
|
298
|
-
wordBreak: 'break-word'
|
|
299
|
-
},
|
|
300
|
-
// Prevents empty code blocks from vertically collapsing
|
|
301
|
-
'code > span:only-child:empty:before, code > span:only-child > span:only-child:empty:before': {
|
|
302
|
-
content: '" "'
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
};
|
|
306
|
-
};
|
|
307
15
|
var getCodeStyles = exports.getCodeStyles = function getCodeStyles() {
|
|
308
|
-
|
|
309
|
-
var baseStyles = getBaseCodeStyles(theme);
|
|
310
|
-
return _objectSpread(_objectSpread({}, baseStyles), {}, {
|
|
16
|
+
return {
|
|
311
17
|
display: 'inline',
|
|
312
18
|
padding: '2px 0.5ch',
|
|
19
|
+
backgroundColor: "var(--ds--code--bg-color,".concat("var(--ds-background-neutral, #091E420F)", ")"),
|
|
20
|
+
borderRadius: "var(--ds-border-radius, 3px)",
|
|
21
|
+
borderStyle: 'none',
|
|
313
22
|
boxDecorationBreak: 'clone',
|
|
23
|
+
color: "var(--ds-text, #172B4D)",
|
|
24
|
+
fontFamily: "var(--ds-font-family-code, ui-monospace, Menlo, \"Segoe UI Mono\", \"Ubuntu Mono\", monospace)",
|
|
314
25
|
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
315
26
|
fontSize: '0.875em',
|
|
27
|
+
fontWeight: "var(--ds-font-weight-regular, 400)",
|
|
316
28
|
overflow: 'auto',
|
|
317
29
|
overflowWrap: 'break-word',
|
|
318
30
|
whiteSpace: 'pre-wrap'
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
var getCodeBlockTheme = exports.getCodeBlockTheme = function getCodeBlockTheme(maxLines) {
|
|
322
|
-
return _objectSpread(_objectSpread(_objectSpread({}, (0, _getTheme.getBaseTheme)()), (0, _getTheme.getColorPalette)()), {}, {
|
|
323
|
-
lineNumberWidth: maxLines ? getLineNumWidth(maxLines) : undefined
|
|
324
|
-
});
|
|
31
|
+
};
|
|
325
32
|
};
|
|
@@ -13,7 +13,6 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
13
13
|
var _react = _interopRequireDefault(require("react"));
|
|
14
14
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
15
15
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
16
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
17
16
|
// This wrapper supports the async loading of refractor and language grammars. The internal Highlight is a memo() functional component as expected
|
|
18
17
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
19
18
|
var SyntaxHighlighter = exports.SyntaxHighlighter = /*#__PURE__*/function (_React$PureComponent) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
._szpl2smr:before{font:var(--ds-font-body,normal 400 14px/20px ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,"Helvetica Neue",sans-serif)}._123w1b66:before{padding-inline-end:var(--ds-space-050,4px)}
|
|
3
|
+
._15nnze3t:before{padding-block-start:var(--ds-space-0,0)}
|
|
4
|
+
._19o61h6o:before{align-items:center}
|
|
5
|
+
._1a354jg8:before{font-style:normal}
|
|
6
|
+
._1cfcvrvc:before{flex-direction:row}
|
|
7
|
+
._1j6r1odn:before{font-family:var(--ds-font-family-code,ui-monospace,Menlo,"Segoe UI Mono","Ubuntu Mono",monospace)}
|
|
8
|
+
._1kt9y7el:before{content:"<"attr(data-bidi-character-code)">"}
|
|
9
|
+
._1rbawx40:hover:before{color:var(--ds-text-warning,#a54800)}
|
|
10
|
+
._1rus1tzq:before{background-color:var(--ds-background-warning,#fff7d6)}
|
|
11
|
+
._1uakf6fq:before{line-height:18px}
|
|
12
|
+
._1xqc1rd4:hover:before{background-color:var(--ds-background-warning-hovered,#f8e6a0)}
|
|
13
|
+
._1xyt1b66:before{padding-inline-start:var(--ds-space-050,4px)}
|
|
14
|
+
._24gj1h6o:before{justify-content:center}
|
|
15
|
+
._cfu1116y:before{display:inline-flex}
|
|
16
|
+
._dsq41wug:before{pointer-events:auto}
|
|
17
|
+
._is06wx40:before{color:var(--ds-text-warning,#a54800)}
|
|
18
|
+
._kqswh2mm{position:relative}
|
|
19
|
+
._rxygze3t:before{padding-block-end:var(--ds-space-0,0)}
|
|
@@ -1,55 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
|
|
1
|
+
/* styled.tsx generated by @compiled/babel-plugin v0.36.1 */
|
|
2
|
+
import "./styled.compiled.css";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
5
5
|
import { Fragment } 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
|
-
import { Y75 } from '@atlaskit/theme/colors';
|
|
10
6
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
11
|
-
const decoration =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
// U+2066 LEFT-TO-RIGHT ISOLATE (when using pseudo element before)
|
|
16
|
-
// U+202E RIGHT-TO-LEFT OVERRIDE' (when using pseudo element after)
|
|
17
|
-
position: 'relative',
|
|
18
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
19
|
-
':before': {
|
|
20
|
-
display: 'inline-flex',
|
|
21
|
-
padding: `${"var(--ds-space-0, 0px)"} ${"var(--ds-space-050, 4px)"}`,
|
|
22
|
-
alignItems: 'center',
|
|
23
|
-
justifyContent: 'center',
|
|
24
|
-
flexDirection: 'row',
|
|
25
|
-
background: `var(--ds-background-warning, ${Y75})`,
|
|
26
|
-
color: "var(--ds-text-warning, #7F5F01)",
|
|
27
|
-
content: '"<"attr(data-bidi-character-code)">"',
|
|
28
|
-
font: "var(--ds-font-body, normal 400 14px/20px ui-sans-serif, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Ubuntu, \"Helvetica Neue\", sans-serif)",
|
|
29
|
-
fontFamily: "var(--ds-font-family-code, ui-monospace, Menlo, \"Segoe UI Mono\", \"Ubuntu Mono\", monospace)",
|
|
30
|
-
fontStyle: 'normal',
|
|
31
|
-
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
|
|
32
|
-
lineHeight: '18px',
|
|
33
|
-
/**
|
|
34
|
-
* Ensures the decoration receives pointer events when it occurs with
|
|
35
|
-
* an ancestor that disables them.
|
|
36
|
-
*/
|
|
37
|
-
pointerEvents: 'auto'
|
|
38
|
-
},
|
|
39
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
40
|
-
':hover:before': {
|
|
41
|
-
background: `var(--ds-background-warning-hovered, ${Y75})`,
|
|
42
|
-
color: "var(--ds-text-warning, #533F04)"
|
|
43
|
-
}
|
|
44
|
-
});
|
|
7
|
+
const decoration = {
|
|
8
|
+
root: "_kqswh2mm _szpl2smr _dsq41wug _1xyt1b66 _123w1b66 _15nnze3t _rxygze3t _1a354jg8 _1j6r1odn _1uakf6fq _1kt9y7el _is06wx40 _1rus1tzq _1cfcvrvc _24gj1h6o _19o61h6o _cfu1116y _1rbawx40 _1xqc1rd4"
|
|
9
|
+
};
|
|
45
10
|
export function Decorator({
|
|
46
11
|
bidiCharacter,
|
|
47
12
|
children,
|
|
48
13
|
testId
|
|
49
14
|
}) {
|
|
50
15
|
const bidiCharacterCode = getBidiCharacterCode(bidiCharacter);
|
|
51
|
-
return
|
|
52
|
-
css: decoration,
|
|
16
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
53
17
|
"data-testid": testId,
|
|
54
18
|
"data-bidi-character-code": bidiCharacterCode
|
|
55
19
|
// This is set to true so that the content is not read out by
|
|
@@ -57,10 +21,11 @@ export function Decorator({
|
|
|
57
21
|
// visual decoration purposes.
|
|
58
22
|
// We use a visually hidden `mark` element below for screen readers
|
|
59
23
|
,
|
|
60
|
-
"aria-hidden": "true"
|
|
61
|
-
|
|
24
|
+
"aria-hidden": "true",
|
|
25
|
+
className: ax([decoration.root])
|
|
26
|
+
}, children), /*#__PURE__*/React.createElement(VisuallyHidden, {
|
|
62
27
|
testId: testId && `${testId}--visually-hidden`
|
|
63
|
-
},
|
|
28
|
+
}, /*#__PURE__*/React.createElement("mark", null, bidiCharacterCode)));
|
|
64
29
|
}
|
|
65
30
|
function getBidiCharacterCode(bidiCharacter) {
|
|
66
31
|
var _bidiCharacter$codePo;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
|
|
2
|
+
._1ozdn7od code, ._7xinn7od code[class*=language-], ._t7aun7od pre[class*=language-]{all:unset}
|
|
3
|
+
._i7ngn7od .token:not([class=token],[data-ds--code--row--highlight],[data-ds--code--row]){all:unset}
|
|
4
|
+
._2rkoglpi{border-radius:var(--ds-border-radius,4px)}
|
|
5
|
+
._1dqoglyw{border-style:none}
|
|
6
|
+
._1agb1dyw [data-ds--code--row--highlight]+[data-ds--code--row]:not([data-ds--code--row--highlight]), ._lkm81dyw [data-ds--code--row]:not([data-ds--code--row--highlight])+[data-ds--code--row--highlight]{border-top:1px dashed transparent}
|
|
7
|
+
._j1w0ww7y [data-ds--code--row--highlight] .linenumber{border-left:4px solid var(--ds-border-focused,#388bff)}
|
|
8
|
+
._tv41hkgb [data-ds--code--row--highlight] .linenumber:before{border-top:1px solid var(--ds-border-focused,#388bff)}
|
|
9
|
+
._wozj1dyw [data-ds--code--row--highlight]:last-child{border-bottom:1px dashed transparent}._113p131l .token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.cdata{color:var(--ds-text-subtlest,#626f86)}
|
|
10
|
+
._12l6ysn8 [data-ds--code--row--highlight]:after, ._uga3ysn8 [data-ds--code--row--highlight]:before{clip-path:inset(100%)}
|
|
11
|
+
._12nh9lu1 .token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.deleted{color:var(--ds-text-accent-red,#ae2e24)}
|
|
12
|
+
._12tu1a66 .linenumber, ._zu0j1a66 .ds-sh-line-number{padding-right:var(--ds-space-100,8px)!important}
|
|
13
|
+
._131n1giz .linenumber, ._gy101giz .ds-sh-line-number{font-style:normal!important}
|
|
14
|
+
._137bh55r .token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.inserted{color:var(--ds-text-accent-green,#216e4e)}
|
|
15
|
+
._13cdh2mm [data-ds--code--row--highlight] .linenumber{position:relative}
|
|
16
|
+
._13dgkb7n code:last-of-type{flex-shrink:1}
|
|
17
|
+
._13zt131l .token.token.token.token.token.token.token.substr{color:var(--ds-text-subtlest,#626f86)}
|
|
18
|
+
._14y71a66 code:last-of-type{padding-right:var(--ds-space-100,8px)!important}
|
|
19
|
+
._1552u2gc .linenumber, ._12afu2gc .ds-sh-line-number{margin-right:var(--ds-space-100,8px)}
|
|
20
|
+
._15ba126e [data-ds--code--row--highlight] .linenumber{padding-left:var(--ds-space-050,4px)!important}
|
|
21
|
+
._17071olh code:first-of-type{background-image:linear-gradient(to right,var(--ds--code--line-number-bg-color,var(--ds-background-neutral,#091e420f)),var(--ds--code--line-number-bg-color,var(--ds-background-neutral,#091e420f)) var(--ads-code-line-number-width),transparent var(--ads-code-line-number-width),transparent)}
|
|
22
|
+
._17wyu2gc code, ._pn28u2gc code[class*=language-], ._gz9fu2gc pre[class*=language-]{padding-bottom:var(--ds-space-100,8px)}
|
|
23
|
+
._19o610m5 .token.token.token.token.token.token.token.token.token.token.url{color:var(--ds-text-accent-purple,#5e4db2)}
|
|
24
|
+
._1b9tpnps .token.token.token.token.token.token.token.token.builtin, ._1tq6pnps .token.token.token.token.token.token.token.token.bullet, ._1rd2pnps .token.token.token.token.token.token.token.token.code, ._1pbkpnps .token.token.token.token.token.token.token.token.entity, ._k3lipnps .token.token.token.token.token.token.token.token.namespace{color:var(--ds-text-accent-blue,#05c)}
|
|
25
|
+
._1d4j1y44 [data-ds--code--row--highlight] .linenumber:before{width:4px}
|
|
26
|
+
._1e0c1txw{display:flex}
|
|
27
|
+
._1eimjvyg{direction:ltr}
|
|
28
|
+
._1exb1q9c [data-ds--code--row--highlight]:after, ._1hgu1q9c [data-ds--code--row--highlight]:before{white-space:nowrap}
|
|
29
|
+
._1f0gpnps .token.token.token.selector{color:var(--ds-text-accent-blue,#05c)}
|
|
30
|
+
._1f8gstnw [data-ds--code--row--highlight] .linenumber:before{position:absolute}
|
|
31
|
+
._1g0517qg .token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.constant{color:var(--ds-text-accent-teal,#206a83)}
|
|
32
|
+
._1gec1a66 [data-ds--code--row]{padding-right:var(--ds-space-100,8px)!important}
|
|
33
|
+
._1gx21e5h .linenumber{float:left}
|
|
34
|
+
._1hmimyb0 [data-ds--code--row--highlight] .linenumber:before{left:-4px}
|
|
35
|
+
._1hmyegat code, ._vblregat code[class*=language-], ._vbulegat pre[class*=language-]{tab-size:4}
|
|
36
|
+
._1huoidpf code, ._1a9lidpf code[class*=language-], ._20bqidpf pre[class*=language-]{padding-right:0}
|
|
37
|
+
._1huou2gc code, ._1a9lu2gc code[class*=language-], ._20bqu2gc pre[class*=language-]{padding-right:var(--ds-space-100,8px)}
|
|
38
|
+
._1i3h1txw [data-ds--code--row]{display:flex}
|
|
39
|
+
._1i3h1ule [data-ds--code--row]{display:block}
|
|
40
|
+
._1k47pnps .token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.number{color:var(--ds-text-accent-blue,#05c)}
|
|
41
|
+
._1k7d1fxt .token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.char{color:var(--ds-text,#172b4d)}
|
|
42
|
+
._1ls01ule .linenumber, ._rude1ule .ds-sh-line-number{display:block}
|
|
43
|
+
._1ls0df4r .linenumber{display:inline-block!important}
|
|
44
|
+
._1m3815vq [data-ds--code--row--highlight]:after, ._qk1e15vq [data-ds--code--row--highlight]:before{overflow-y:hidden}
|
|
45
|
+
._1mgnt94y [data-ds--code--row--highlight]:after, ._nhket94y [data-ds--code--row--highlight]:before{width:1px}
|
|
46
|
+
._1n6tpnps .token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.prolog{color:var(--ds-text-accent-blue,#05c)}
|
|
47
|
+
._1na21hna code:last-of-type{word-break:break-word}
|
|
48
|
+
._1oggidpf code, ._bympidpf code[class*=language-], ._9nnjidpf pre[class*=language-]{padding-left:0}
|
|
49
|
+
._1oggu2gc code, ._bympu2gc code[class*=language-], ._9nnju2gc pre[class*=language-]{padding-left:var(--ds-space-100,8px)}
|
|
50
|
+
._1pzyb3bt [data-ds--code--row--highlight] .linenumber:before{content:""}
|
|
51
|
+
._1q16glyw .linenumber, ._1io6glyw .ds-sh-line-number{-webkit-user-select:none;-ms-user-select:none;user-select:none}
|
|
52
|
+
._1ra01n1a [data-ds--code--row--highlight] .linenumber:before{top:-1px}
|
|
53
|
+
._1reo1wug{overflow-x:auto}
|
|
54
|
+
._1t361fxt .token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.operator{color:var(--ds-text,#172b4d)}
|
|
55
|
+
._1v0lh55r .token.token.token.token.token.token.token.token.token.token.token.token.string{color:var(--ds-text-accent-green,#216e4e)}
|
|
56
|
+
._1v15u2gc code, ._ilvcu2gc code[class*=language-], ._m29uu2gc pre[class*=language-]{padding-top:var(--ds-space-100,8px)}
|
|
57
|
+
._1weckb7n code:last-of-type{flex-grow:1}
|
|
58
|
+
._1wfuwrk5 .linenumber, ._16kzwrk5 .ds-sh-line-number{min-width:var(--ads-code-line-number-width)!important}
|
|
59
|
+
._1wyb1crf{font-size:9pt}
|
|
60
|
+
._1xcoh55r .token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.atrule{color:var(--ds-text-accent-green,#216e4e)}
|
|
61
|
+
._1xx2grf3 code:first-of-type{padding-right:0!important}
|
|
62
|
+
._1yvq10m5 .token.token.token.token.token.token.token.token.token.token.token.token.token.class-name, ._1vww10m5 .token.token.token.token.token.token.token.token.token.token.token.token.token.section, ._1rju10m5 .token.token.token.token.token.token.token.token.token.token.token.token.token.title{color:var(--ds-text-accent-purple,#5e4db2)}
|
|
63
|
+
._28ddu2gc .linenumber, ._1i8zu2gc .ds-sh-line-number{padding-left:var(--ds-space-100,8px)}
|
|
64
|
+
._2g12fb2s .token.token.token.token.token.token.doctype{color:var(--ds-text-accent-yellow,#7f5f01)}
|
|
65
|
+
._326z1fxt .token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.punctuation{color:var(--ds-text,#172b4d)}
|
|
66
|
+
._7gp8h55r .token.token.token.token.token.token.token.token.token.token.token.token.token.token.meta-keyword{color:var(--ds-text-accent-green,#216e4e)}
|
|
67
|
+
._97lipnps .token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.boolean{color:var(--ds-text-accent-blue,#05c)}
|
|
68
|
+
._9d3e17qg .token.token.attr-name{color:var(--ds-text-accent-teal,#206a83)}
|
|
69
|
+
._9k2r1m30 .token.italic{font-style:italic}
|
|
70
|
+
._9kk3moej .token.important{font-weight:var(--ds-font-weight-bold,700)}
|
|
71
|
+
._9wu1fb2s .token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.important{color:var(--ds-text-accent-yellow,#7f5f01)}
|
|
72
|
+
._b5iy131l .token.token.token.token.block-comment, ._gti3131l .token.token.token.token.comment{color:var(--ds-text-subtlest,#626f86)}
|
|
73
|
+
._bfhktkvp{background-color:var(--ds--code--bg-color,var(--ds-background-neutral,#091e420f))}
|
|
74
|
+
._cjus1w1g .token.bold:not(.important){font-weight:bolder}
|
|
75
|
+
._ect41odn{font-family:var(--ds-font-family-code,ui-monospace,Menlo,"Segoe UI Mono","Ubuntu Mono",monospace)}
|
|
76
|
+
._eiht5x2v .token.block-comment:not(.italic), ._t9zb5x2v .token.comment:not(.italic){font-family:SFMono-MediumItalic,var(--ds-font-family-code,ui-monospace,Menlo,"Segoe UI Mono","Ubuntu Mono",monospace)}
|
|
77
|
+
._euyxusvi .linenumber, ._cahfusvi .ds-sh-line-number{box-sizing:border-box}
|
|
78
|
+
._g0lx1fxt .token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.function{color:var(--ds-text,#172b4d)}
|
|
79
|
+
._h909m7j4 [data-ds--code--row--highlight]{background-color:var(--ds-background-neutral,#091e420f)}
|
|
80
|
+
._i2ig10m5 .token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.property{color:var(--ds-text-accent-purple,#5e4db2)}
|
|
81
|
+
._ipl81e17 [data-ds--code--row--highlight]:before{content:" [var(--ads-highlighted-start-text)] "}
|
|
82
|
+
._j0l11wug code:last-of-type{flex-basis:auto}
|
|
83
|
+
._jeky1l04 [data-ds--code--row]{margin-right:-var(--ds-space-100,8px)}
|
|
84
|
+
._juomusic .linenumber, ._lcwuusic .ds-sh-line-number{text-align:right}
|
|
85
|
+
._k48pi7a9{font-weight:var(--ds-font-weight-regular,400)}
|
|
86
|
+
._k86b10m5 .token.token.token.token.token.function-name{color:var(--ds-text-accent-purple,#5e4db2)}
|
|
87
|
+
._kxov17qg .token.token.token.token.token.token.token.token.token.regex, ._1np517qg .token.token.token.token.token.token.token.token.token.symbol, ._m2f517qg .token.token.token.token.token.token.token.token.token.variable{color:var(--ds-text-accent-teal,#206a83)}
|
|
88
|
+
._mbgcpf9b .linenumber, ._bu7zpf9b .ds-sh-line-number{color:var(--ds-text-subtlest,#626f86)!important}
|
|
89
|
+
._mqok1w1g .token.key:not(.important,.bold), ._3hsg1w1g .token.keyword:not(.important,.bold){font-weight:bolder}
|
|
90
|
+
._mx8b7mnp [data-ds--code--row--highlight]:after, ._1kr87mnp [data-ds--code--row--highlight]:before{clip:rect(1px,1px,1px,1px)}
|
|
91
|
+
._nalpstnw [data-ds--code--row--highlight]:after, ._151dstnw [data-ds--code--row--highlight]:before{position:absolute}
|
|
92
|
+
._nhmw1m30 .token.block-comment:not(.italic), ._yl021m30 .token.comment:not(.italic){font-style:italic}
|
|
93
|
+
._o572qvpr{white-space:pre}
|
|
94
|
+
._qdiapnps .token.key, ._72uvpnps .token.keyword{color:var(--ds-text-accent-blue,#05c)}
|
|
95
|
+
._scgayz1z [data-ds--code--row--highlight]:after{content:" [var(--ads-highlighted-end-text)] "}
|
|
96
|
+
._syaz1fxt{color:var(--ds-text,#172b4d)}
|
|
97
|
+
._tgu817qg .token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.attr-value{color:var(--ds-text-accent-teal,#206a83)}
|
|
98
|
+
._vm2c1rh5 .linenumber:after, ._12ok1rh5 .ds-sh-line-number:after{content:attr(data-ds--line-number)}
|
|
99
|
+
._vwz4gktf{line-height:20px}
|
|
100
|
+
._wmyy17qg .token.token.token.token.token.token.token.token.token.token.token.quote, ._748n17qg .token.token.token.token.token.token.token.token.token.token.token.selector-attr, ._1mfn17qg .token.token.token.token.token.token.token.token.token.token.token.selector-pseudo, ._1d7e17qg .token.token.token.token.token.token.token.token.token.token.token.tag, ._p2vr17qg .token.token.token.token.token.token.token.token.token.token.token.type{color:var(--ds-text-accent-teal,#206a83)}
|
|
101
|
+
._x7c815vq [data-ds--code--row--highlight]:after, ._lh0y15vq [data-ds--code--row--highlight]:before{overflow-x:hidden}
|
|
102
|
+
._xo19t94y [data-ds--code--row--highlight]:after, ._1bemt94y [data-ds--code--row--highlight]:before{height:1px}
|
|
103
|
+
._ys4e131l .token.token.token.token.token.token.token.token.token.token.token.token.token.token.token.meta{color:var(--ds-text-subtlest,#626f86)}
|
|
104
|
+
._zhnuidpf .linenumber, ._1amdidpf .ds-sh-line-number{flex-shrink:0}
|
|
105
|
+
._zvy9f705 code>span:only-child:empty:before, ._qcxof705 code>span:only-child>span:only-child:empty:before{content:" "}
|
|
@@ -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
|
+
const 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__
|
|
@@ -35,11 +41,7 @@ const CodeBlock = /*#__PURE__*/memo(function CodeBlock({
|
|
|
35
41
|
shouldWrapLongLines = false
|
|
36
42
|
}) {
|
|
37
43
|
const numLines = (text || '').split('\n').length + (firstLineNumber > 0 ? firstLineNumber : 1) - 1;
|
|
38
|
-
const
|
|
39
|
-
const getStyles = useMemo(() => getCodeBlockStyles(theme), [theme]);
|
|
40
|
-
const styles = useMemo(() => css(
|
|
41
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
42
|
-
getStyles(highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines)), [highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines, getStyles]);
|
|
44
|
+
const lineNumberWidth = numLines ? getLineNumWidth(numLines) : 0;
|
|
43
45
|
const {
|
|
44
46
|
getHighlightStyles,
|
|
45
47
|
highlightedLines
|
|
@@ -52,12 +54,16 @@ const CodeBlock = /*#__PURE__*/memo(function CodeBlock({
|
|
|
52
54
|
|
|
53
55
|
// https://product-fabric.atlassian.net/browse/DST-2472
|
|
54
56
|
const languageToUse = text ? language : 'text';
|
|
55
|
-
return
|
|
57
|
+
return /*#__PURE__*/React.createElement(SyntaxHighlighter, {
|
|
56
58
|
"data-code-lang": language,
|
|
57
59
|
"data-ds--code--code-block": "",
|
|
58
60
|
testId: testId,
|
|
59
61
|
language: languageToUse,
|
|
60
|
-
|
|
62
|
+
style: {
|
|
63
|
+
'--ads-code-line-number-width': `calc(${lineNumberWidth} + 16px)`,
|
|
64
|
+
'--ads-highlighted-start-text': highlightedStartText,
|
|
65
|
+
'--ads-highlighted-end-text': highlightedEndText
|
|
66
|
+
},
|
|
61
67
|
showLineNumbers: showLineNumbers,
|
|
62
68
|
firstLineNumber: firstLineNumber,
|
|
63
69
|
lineProps: getLineProps
|
|
@@ -70,7 +76,8 @@ const CodeBlock = /*#__PURE__*/memo(function CodeBlock({
|
|
|
70
76
|
codeBidiWarnings: codeBidiWarnings,
|
|
71
77
|
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
72
78
|
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled,
|
|
73
|
-
text: text
|
|
79
|
+
text: text,
|
|
80
|
+
className: ax([getCodeBlockStyles.root, shouldWrapLongLines ? getCodeBlockStyles.shouldWrapLongLines : getCodeBlockStyles.dontWrapLongLines, showLineNumbers ? getCodeBlockStyles.showLineNumbers : getCodeBlockStyles.dontShowLineNumbers])
|
|
74
81
|
});
|
|
75
82
|
});
|
|
76
83
|
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}
|