@atlaskit/code 15.2.1 → 15.3.1
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 +17 -0
- package/__perf__/code-block-syntax-highlighting.tsx +4 -1
- package/__perf__/source-code-examples/100-line-example.tsx +4 -1
- package/dist/cjs/bidi-warning/ui/styled.js +8 -1
- package/dist/cjs/code-block.js +8 -1
- package/dist/cjs/code.js +13 -5
- package/dist/cjs/internal/theme/styles.js +1 -1
- package/dist/cjs/syntax-highlighter/types.js +1 -0
- package/dist/es2019/bidi-warning/ui/styled.js +8 -1
- package/dist/es2019/code-block.js +8 -1
- package/dist/es2019/code.js +14 -5
- package/dist/es2019/internal/theme/styles.js +2 -0
- package/dist/es2019/syntax-highlighter/types.js +3 -0
- package/dist/esm/bidi-warning/ui/styled.js +8 -1
- package/dist/esm/code-block.js +8 -1
- package/dist/esm/code.js +14 -5
- package/dist/esm/internal/theme/styles.js +2 -0
- package/dist/esm/syntax-highlighter/types.js +3 -0
- package/dist/types/bidi-warning/ui/styled.d.ts +3 -0
- package/dist/types/code.d.ts +3 -0
- package/dist/types-ts4.5/bidi-warning/ui/styled.d.ts +3 -0
- package/dist/types-ts4.5/code.d.ts +3 -0
- package/package.json +108 -108
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/code
|
|
2
2
|
|
|
3
|
+
## 15.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#116025](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/116025)
|
|
8
|
+
[`cd506a937e44f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cd506a937e44f) -
|
|
9
|
+
Internal change to how typography is applied. There should be no visual change.
|
|
10
|
+
|
|
11
|
+
## 15.3.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#111878](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/111878)
|
|
16
|
+
[`223959ef57c80`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/223959ef57c80) -
|
|
17
|
+
Explicitly set jsxRuntime to classic via pragma comments in order to avoid issues where jsxRuntime
|
|
18
|
+
is implicitly set to automatic.
|
|
19
|
+
|
|
3
20
|
## 15.2.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -2,7 +2,10 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { CodeBlock } from '../src';
|
|
4
4
|
|
|
5
|
-
export const text = `/**
|
|
5
|
+
export const text = `/**
|
|
6
|
+
* @jsxRuntime classic
|
|
7
|
+
*/
|
|
8
|
+
/** @jsx jsx */
|
|
6
9
|
import React from 'react';
|
|
7
10
|
import ReactDOM from 'react-dom';
|
|
8
11
|
import styled from '@emotion/styled';
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// eslint-disable-file
|
|
2
2
|
export const hundredLineExample = `/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
3
|
+
/**
|
|
4
|
+
* @jsxRuntime classic
|
|
5
|
+
*/
|
|
3
6
|
/** @jsx jsx */
|
|
4
7
|
import React, { CSSProperties, forwardRef } from 'react';
|
|
5
8
|
|
|
@@ -13,8 +16,8 @@ const CSS_VAR_TEXT_COLOR = '--banner-text-color';
|
|
|
13
16
|
|
|
14
17
|
const textStyles = css({
|
|
15
18
|
color: \`var(\${CSS_VAR_TEXT_COLOR})\`,
|
|
19
|
+
font: token('font.body'),
|
|
16
20
|
fontWeight: token('font.weight.medium', '500'),
|
|
17
|
-
lineHeight: token('font.lineHeight.300', '24px'),
|
|
18
21
|
overflow: 'hidden',
|
|
19
22
|
textOverflow: 'ellipsis',
|
|
20
23
|
whiteSpace: 'nowrap',
|
|
@@ -9,8 +9,13 @@ var _react = require("react");
|
|
|
9
9
|
var _react2 = require("@emotion/react");
|
|
10
10
|
var _colors = require("@atlaskit/theme/colors");
|
|
11
11
|
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
12
|
+
/**
|
|
13
|
+
* @jsxRuntime classic
|
|
14
|
+
*/
|
|
12
15
|
/** @jsx jsx */
|
|
13
16
|
|
|
17
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
18
|
+
|
|
14
19
|
var decoration = (0, _react2.css)({
|
|
15
20
|
// Required as otherwise the following bidi characters cause the span
|
|
16
21
|
// to not receive hover events.
|
|
@@ -18,6 +23,7 @@ var decoration = (0, _react2.css)({
|
|
|
18
23
|
// U+2066 LEFT-TO-RIGHT ISOLATE (when using pseudo element before)
|
|
19
24
|
// U+202E RIGHT-TO-LEFT OVERRIDE' (when using pseudo element after)
|
|
20
25
|
position: 'relative',
|
|
26
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
21
27
|
':before': {
|
|
22
28
|
display: 'inline-flex',
|
|
23
29
|
padding: "var(--ds-space-0, 0px)".concat(" ", "var(--ds-space-050, 4px)"),
|
|
@@ -27,7 +33,7 @@ var decoration = (0, _react2.css)({
|
|
|
27
33
|
background: "var(--ds-background-warning, ".concat(_colors.Y75, ")"),
|
|
28
34
|
color: "var(--ds-text-warning, #7F5F01)",
|
|
29
35
|
content: '"<"attr(data-bidi-character-code)">"',
|
|
30
|
-
fontSize:
|
|
36
|
+
fontSize: '14px',
|
|
31
37
|
fontStyle: 'normal',
|
|
32
38
|
lineHeight: '18px',
|
|
33
39
|
/**
|
|
@@ -36,6 +42,7 @@ var decoration = (0, _react2.css)({
|
|
|
36
42
|
*/
|
|
37
43
|
pointerEvents: 'auto'
|
|
38
44
|
},
|
|
45
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
39
46
|
':hover:before': {
|
|
40
47
|
background: "var(--ds-background-warning-hovered, ".concat(_colors.Y75, ")"),
|
|
41
48
|
color: "var(--ds-text-warning, #533F04)"
|
package/dist/cjs/code-block.js
CHANGED
|
@@ -11,8 +11,13 @@ var _useHighlight = require("./internal/hooks/use-highlight");
|
|
|
11
11
|
var _styles = require("./internal/theme/styles");
|
|
12
12
|
var _getNormalizedLanguage = require("./internal/utils/get-normalized-language");
|
|
13
13
|
var _syntaxHighlighter = _interopRequireDefault(require("./syntax-highlighter"));
|
|
14
|
+
/**
|
|
15
|
+
* @jsxRuntime classic
|
|
16
|
+
*/
|
|
14
17
|
/** @jsx jsx */
|
|
15
18
|
|
|
19
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
20
|
+
|
|
16
21
|
/**
|
|
17
22
|
* __Code block__
|
|
18
23
|
*
|
|
@@ -50,7 +55,9 @@ var CodeBlock = /*#__PURE__*/(0, _react.memo)(function CodeBlock(_ref) {
|
|
|
50
55
|
return (0, _styles.getCodeBlockStyles)(theme);
|
|
51
56
|
}, [theme]);
|
|
52
57
|
var styles = (0, _react.useMemo)(function () {
|
|
53
|
-
return (0, _react2.css)(
|
|
58
|
+
return (0, _react2.css)(
|
|
59
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
60
|
+
getStyles(highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines));
|
|
54
61
|
}, [highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines, getStyles]);
|
|
55
62
|
var _useHighlightLines = (0, _useHighlight.useHighlightLines)({
|
|
56
63
|
highlight: highlight,
|
package/dist/cjs/code.js
CHANGED
|
@@ -21,7 +21,11 @@ var _bidiWarningDecorator = _interopRequireDefault(require("./bidi-warning/bidi-
|
|
|
21
21
|
var _styles = require("./internal/theme/styles");
|
|
22
22
|
var _excluded = ["testId"],
|
|
23
23
|
_excluded2 = ["children", "codeBidiWarnings", "codeBidiWarningLabel", "codeBidiWarningTooltipEnabled"];
|
|
24
|
+
/**
|
|
25
|
+
* @jsxRuntime classic
|
|
26
|
+
*/
|
|
24
27
|
/** @jsx jsx */
|
|
28
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
25
29
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
26
30
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
27
31
|
/**
|
|
@@ -36,6 +40,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
36
40
|
var Code = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function Code(_ref, ref) {
|
|
37
41
|
var testId = _ref.testId,
|
|
38
42
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
43
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
39
44
|
var styles = (0, _react2.css)((0, _styles.getCodeStyles)());
|
|
40
45
|
var children = props.children,
|
|
41
46
|
_props$codeBidiWarnin = props.codeBidiWarnings,
|
|
@@ -48,11 +53,14 @@ var Code = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
48
53
|
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
49
54
|
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
50
55
|
}, children) : children;
|
|
51
|
-
return (
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
return (
|
|
57
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
58
|
+
(0, _react2.jsx)("code", (0, _extends2.default)({
|
|
59
|
+
ref: ref,
|
|
60
|
+
"data-testid": testId,
|
|
61
|
+
css: styles
|
|
62
|
+
}, otherProps), decoratedChildren)
|
|
63
|
+
);
|
|
56
64
|
}));
|
|
57
65
|
function RenderCodeChildrenWithBidiWarnings(_ref2) {
|
|
58
66
|
var children = _ref2.children,
|
|
@@ -9,7 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _constants = require("./constants");
|
|
10
10
|
var _getTheme = require("./get-theme");
|
|
11
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; }
|
|
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
|
|
13
13
|
var getLineNumWidth = exports.getLineNumWidth = function getLineNumWidth(numLines) {
|
|
14
14
|
if (!numLines) {
|
|
15
15
|
return '1ch';
|
|
@@ -13,6 +13,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
13
13
|
var _react = _interopRequireDefault(require("react"));
|
|
14
14
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
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
|
|
16
17
|
// This wrapper supports the async loading of refractor and language grammars. The internal Highlight is a memo() functional component as expected
|
|
17
18
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
18
19
|
var SyntaxHighlighter = exports.SyntaxHighlighter = /*#__PURE__*/function (_React$PureComponent) {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
*/
|
|
1
4
|
/** @jsx jsx */
|
|
2
5
|
import { Fragment } from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
8
|
import { css, jsx } from '@emotion/react';
|
|
4
9
|
import { Y75 } from '@atlaskit/theme/colors';
|
|
5
10
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
@@ -10,6 +15,7 @@ const decoration = css({
|
|
|
10
15
|
// U+2066 LEFT-TO-RIGHT ISOLATE (when using pseudo element before)
|
|
11
16
|
// U+202E RIGHT-TO-LEFT OVERRIDE' (when using pseudo element after)
|
|
12
17
|
position: 'relative',
|
|
18
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
13
19
|
':before': {
|
|
14
20
|
display: 'inline-flex',
|
|
15
21
|
padding: `${"var(--ds-space-0, 0px)"} ${"var(--ds-space-050, 4px)"}`,
|
|
@@ -19,7 +25,7 @@ const decoration = css({
|
|
|
19
25
|
background: `var(--ds-background-warning, ${Y75})`,
|
|
20
26
|
color: "var(--ds-text-warning, #7F5F01)",
|
|
21
27
|
content: '"<"attr(data-bidi-character-code)">"',
|
|
22
|
-
fontSize:
|
|
28
|
+
fontSize: '14px',
|
|
23
29
|
fontStyle: 'normal',
|
|
24
30
|
lineHeight: '18px',
|
|
25
31
|
/**
|
|
@@ -28,6 +34,7 @@ const decoration = css({
|
|
|
28
34
|
*/
|
|
29
35
|
pointerEvents: 'auto'
|
|
30
36
|
},
|
|
37
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
31
38
|
':hover:before': {
|
|
32
39
|
background: `var(--ds-background-warning-hovered, ${Y75})`,
|
|
33
40
|
color: "var(--ds-text-warning, #533F04)"
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
*/
|
|
1
4
|
/** @jsx jsx */
|
|
2
5
|
import { memo, useCallback, useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
8
|
import { css, jsx } from '@emotion/react';
|
|
4
9
|
import { useHighlightLines } from './internal/hooks/use-highlight';
|
|
5
10
|
import { getCodeBlockStyles, getCodeBlockTheme } from './internal/theme/styles';
|
|
@@ -31,7 +36,9 @@ const CodeBlock = /*#__PURE__*/memo(function CodeBlock({
|
|
|
31
36
|
const numLines = (text || '').split('\n').length;
|
|
32
37
|
const theme = useMemo(() => getCodeBlockTheme(numLines), [numLines]);
|
|
33
38
|
const getStyles = useMemo(() => getCodeBlockStyles(theme), [theme]);
|
|
34
|
-
const styles = useMemo(() => css(
|
|
39
|
+
const styles = useMemo(() => css(
|
|
40
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
41
|
+
getStyles(highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines)), [highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines, getStyles]);
|
|
35
42
|
const {
|
|
36
43
|
getHighlightStyles,
|
|
37
44
|
highlightedLines
|
package/dist/es2019/code.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/**
|
|
3
|
+
* @jsxRuntime classic
|
|
4
|
+
*/
|
|
2
5
|
/** @jsx jsx */
|
|
3
6
|
import React, { forwardRef, memo } from 'react';
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
4
9
|
import { css, jsx } from '@emotion/react';
|
|
5
10
|
import CodeBidiWarning from './bidi-warning';
|
|
6
11
|
import codeBidiWarningDecorator from './bidi-warning/bidi-warning-decorator';
|
|
@@ -18,6 +23,7 @@ const Code = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Code({
|
|
|
18
23
|
testId,
|
|
19
24
|
...props
|
|
20
25
|
}, ref) {
|
|
26
|
+
// 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
27
|
const styles = css(getCodeStyles());
|
|
22
28
|
const {
|
|
23
29
|
children,
|
|
@@ -30,11 +36,14 @@ const Code = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Code({
|
|
|
30
36
|
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
31
37
|
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
32
38
|
}, children) : children;
|
|
33
|
-
return
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
return (
|
|
40
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
41
|
+
jsx("code", _extends({
|
|
42
|
+
ref: ref,
|
|
43
|
+
"data-testid": testId,
|
|
44
|
+
css: styles
|
|
45
|
+
}, otherProps), decoratedChildren)
|
|
46
|
+
);
|
|
38
47
|
}));
|
|
39
48
|
function RenderCodeChildrenWithBidiWarnings({
|
|
40
49
|
children,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
2
|
+
|
|
1
3
|
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';
|
|
2
4
|
import { getBaseTheme, getColorPalette } from './get-theme';
|
|
3
5
|
export const getLineNumWidth = numLines => {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
4
|
+
|
|
2
5
|
// This wrapper supports the async loading of refractor and language grammars. The internal Highlight is a memo() functional component as expected
|
|
3
6
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
4
7
|
export class SyntaxHighlighter extends React.PureComponent {}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
*/
|
|
1
4
|
/** @jsx jsx */
|
|
2
5
|
import { Fragment } from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
8
|
import { css, jsx } from '@emotion/react';
|
|
4
9
|
import { Y75 } from '@atlaskit/theme/colors';
|
|
5
10
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
@@ -10,6 +15,7 @@ var decoration = css({
|
|
|
10
15
|
// U+2066 LEFT-TO-RIGHT ISOLATE (when using pseudo element before)
|
|
11
16
|
// U+202E RIGHT-TO-LEFT OVERRIDE' (when using pseudo element after)
|
|
12
17
|
position: 'relative',
|
|
18
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
13
19
|
':before': {
|
|
14
20
|
display: 'inline-flex',
|
|
15
21
|
padding: "var(--ds-space-0, 0px)".concat(" ", "var(--ds-space-050, 4px)"),
|
|
@@ -19,7 +25,7 @@ var decoration = css({
|
|
|
19
25
|
background: "var(--ds-background-warning, ".concat(Y75, ")"),
|
|
20
26
|
color: "var(--ds-text-warning, #7F5F01)",
|
|
21
27
|
content: '"<"attr(data-bidi-character-code)">"',
|
|
22
|
-
fontSize:
|
|
28
|
+
fontSize: '14px',
|
|
23
29
|
fontStyle: 'normal',
|
|
24
30
|
lineHeight: '18px',
|
|
25
31
|
/**
|
|
@@ -28,6 +34,7 @@ var decoration = css({
|
|
|
28
34
|
*/
|
|
29
35
|
pointerEvents: 'auto'
|
|
30
36
|
},
|
|
37
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
31
38
|
':hover:before': {
|
|
32
39
|
background: "var(--ds-background-warning-hovered, ".concat(Y75, ")"),
|
|
33
40
|
color: "var(--ds-text-warning, #533F04)"
|
package/dist/esm/code-block.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
*/
|
|
1
4
|
/** @jsx jsx */
|
|
2
5
|
import { memo, useCallback, useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
8
|
import { css, jsx } from '@emotion/react';
|
|
4
9
|
import { useHighlightLines } from './internal/hooks/use-highlight';
|
|
5
10
|
import { getCodeBlockStyles, getCodeBlockTheme } from './internal/theme/styles';
|
|
@@ -43,7 +48,9 @@ var CodeBlock = /*#__PURE__*/memo(function CodeBlock(_ref) {
|
|
|
43
48
|
return getCodeBlockStyles(theme);
|
|
44
49
|
}, [theme]);
|
|
45
50
|
var styles = useMemo(function () {
|
|
46
|
-
return css(
|
|
51
|
+
return css(
|
|
52
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
53
|
+
getStyles(highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines));
|
|
47
54
|
}, [highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines, getStyles]);
|
|
48
55
|
var _useHighlightLines = useHighlightLines({
|
|
49
56
|
highlight: highlight,
|
package/dist/esm/code.js
CHANGED
|
@@ -2,8 +2,13 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
3
|
var _excluded = ["testId"],
|
|
4
4
|
_excluded2 = ["children", "codeBidiWarnings", "codeBidiWarningLabel", "codeBidiWarningTooltipEnabled"];
|
|
5
|
+
/**
|
|
6
|
+
* @jsxRuntime classic
|
|
7
|
+
*/
|
|
5
8
|
/** @jsx jsx */
|
|
6
9
|
import React, { forwardRef, memo } from 'react';
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
12
|
import { css, jsx } from '@emotion/react';
|
|
8
13
|
import CodeBidiWarning from './bidi-warning';
|
|
9
14
|
import codeBidiWarningDecorator from './bidi-warning/bidi-warning-decorator';
|
|
@@ -20,6 +25,7 @@ import { getCodeStyles } from './internal/theme/styles';
|
|
|
20
25
|
var Code = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Code(_ref, ref) {
|
|
21
26
|
var testId = _ref.testId,
|
|
22
27
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
28
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
23
29
|
var styles = css(getCodeStyles());
|
|
24
30
|
var children = props.children,
|
|
25
31
|
_props$codeBidiWarnin = props.codeBidiWarnings,
|
|
@@ -32,11 +38,14 @@ var Code = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Code(_ref, ref) {
|
|
|
32
38
|
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
33
39
|
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
34
40
|
}, children) : children;
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
return (
|
|
42
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
43
|
+
jsx("code", _extends({
|
|
44
|
+
ref: ref,
|
|
45
|
+
"data-testid": testId,
|
|
46
|
+
css: styles
|
|
47
|
+
}, otherProps), decoratedChildren)
|
|
48
|
+
);
|
|
40
49
|
}));
|
|
41
50
|
function RenderCodeChildrenWithBidiWarnings(_ref2) {
|
|
42
51
|
var children = _ref2.children,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
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
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
|
+
|
|
4
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';
|
|
5
7
|
import { getBaseTheme, getColorPalette } from './get-theme';
|
|
6
8
|
export var getLineNumWidth = function getLineNumWidth(numLines) {
|
|
@@ -6,6 +6,9 @@ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
|
6
6
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
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
|
+
|
|
9
12
|
// This wrapper supports the async loading of refractor and language grammars. The internal Highlight is a memo() functional component as expected
|
|
10
13
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
11
14
|
export var SyntaxHighlighter = /*#__PURE__*/function (_React$PureComponent) {
|
package/dist/types/code.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
2
|
+
"name": "@atlaskit/code",
|
|
3
|
+
"version": "15.3.1",
|
|
4
|
+
"description": "Code highlights short strings of code snippets inline with body text.",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"registry": "https://registry.npmjs.org/"
|
|
7
|
+
},
|
|
8
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
9
|
+
"author": "Atlassian Pty Ltd",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"main": "dist/cjs/index.js",
|
|
12
|
+
"module": "dist/esm/index.js",
|
|
13
|
+
"module:es2019": "dist/es2019/index.js",
|
|
14
|
+
"types": "dist/types/index.d.ts",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"atlaskit:src": "src/index.tsx",
|
|
17
|
+
"atlassian": {
|
|
18
|
+
"team": "Design System Team",
|
|
19
|
+
"releaseModel": "continuous",
|
|
20
|
+
"website": {
|
|
21
|
+
"name": "Code",
|
|
22
|
+
"category": "Components"
|
|
23
|
+
},
|
|
24
|
+
"runReact18": true
|
|
25
|
+
},
|
|
26
|
+
"config": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@atlaskit/codemod-utils": "^4.2.0",
|
|
31
|
+
"@atlaskit/theme": "^12.11.0",
|
|
32
|
+
"@atlaskit/tokens": "^1.53.0",
|
|
33
|
+
"@atlaskit/tooltip": "^18.5.0",
|
|
34
|
+
"@atlaskit/visually-hidden": "^1.4.0",
|
|
35
|
+
"@babel/runtime": "^7.0.0",
|
|
36
|
+
"@emotion/react": "^11.7.1",
|
|
37
|
+
"memoize-one": "^6.0.0",
|
|
38
|
+
"refractor": "^3.6.0"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"react": "^16.8.0 || ^17.0.0 || ~18.2.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@af/accessibility-testing": "*",
|
|
45
|
+
"@af/integration-testing": "*",
|
|
46
|
+
"@af/visual-regression": "*",
|
|
47
|
+
"@atlaskit/ds-lib": "^2.3.0",
|
|
48
|
+
"@atlaskit/ssr": "*",
|
|
49
|
+
"@atlaskit/toggle": "^13.2.0",
|
|
50
|
+
"@atlaskit/visual-regression": "*",
|
|
51
|
+
"@testing-library/react": "^12.1.5",
|
|
52
|
+
"@types/jscodeshift": "^0.11.0",
|
|
53
|
+
"@types/refractor": "^3.0.2",
|
|
54
|
+
"color-contrast-checker": "^1.5.0",
|
|
55
|
+
"jscodeshift": "^0.13.0",
|
|
56
|
+
"prismjs": "^1.25.0",
|
|
57
|
+
"react-dom": "^16.8.0",
|
|
58
|
+
"typescript": "~5.4.2"
|
|
59
|
+
},
|
|
60
|
+
"keywords": [
|
|
61
|
+
"atlaskit",
|
|
62
|
+
"react",
|
|
63
|
+
"ui"
|
|
64
|
+
],
|
|
65
|
+
"techstack": {
|
|
66
|
+
"@atlassian/frontend": {
|
|
67
|
+
"import-structure": "atlassian-conventions"
|
|
68
|
+
},
|
|
69
|
+
"@repo/internal": {
|
|
70
|
+
"design-system": "v1",
|
|
71
|
+
"design-tokens": [
|
|
72
|
+
"color",
|
|
73
|
+
"spacing"
|
|
74
|
+
],
|
|
75
|
+
"dom-events": "use-bind-event-listener",
|
|
76
|
+
"ui-components": [
|
|
77
|
+
"lite-mode"
|
|
78
|
+
],
|
|
79
|
+
"analytics": [
|
|
80
|
+
"analytics-next"
|
|
81
|
+
],
|
|
82
|
+
"theming": [
|
|
83
|
+
"react-context"
|
|
84
|
+
],
|
|
85
|
+
"deprecation": "no-deprecated-imports",
|
|
86
|
+
"styling": [
|
|
87
|
+
"emotion"
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"typesVersions": {
|
|
92
|
+
">=4.5 <4.9": {
|
|
93
|
+
"*": [
|
|
94
|
+
"dist/types-ts4.5/*",
|
|
95
|
+
"dist/types-ts4.5/index.d.ts"
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"af:exports": {
|
|
100
|
+
"./types": "./src/entry-points/types.tsx",
|
|
101
|
+
".": "./src/index.tsx",
|
|
102
|
+
"./bidi-warning": "./src/bidi-warning/index.tsx",
|
|
103
|
+
"./bidi-warning-decorator": "./src/bidi-warning/bidi-warning-decorator.tsx",
|
|
104
|
+
"./block": "./src/entry-points/block.tsx",
|
|
105
|
+
"./inline": "./src/entry-points/inline.tsx",
|
|
106
|
+
"./constants": "./src/entry-points/constants.tsx"
|
|
107
|
+
},
|
|
108
|
+
"homepage": "https://atlassian.design/components/code/"
|
|
109
|
+
}
|