@atlaskit/code 14.4.5 → 14.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/__perf__/code-block-100-lines.tsx +7 -0
- package/__perf__/code-block-1000-lines.tsx +7 -0
- package/__perf__/code-block-4458-lines.tsx +7 -0
- package/__perf__/code-block-500-lines.tsx +7 -0
- package/__perf__/{code-block-text.tsx → code-block-no-syntax-highlighting.tsx} +1 -1
- package/__perf__/{code-block-jsx.tsx → code-block-syntax-highlighting.tsx} +0 -0
- package/__perf__/{default.tsx → inline-code.tsx} +0 -0
- package/__perf__/source-code-examples/100-line-example.tsx +101 -0
- package/__perf__/source-code-examples/1000-line-example.tsx +1000 -0
- package/__perf__/source-code-examples/4458-line-example.tsx +4461 -0
- package/__perf__/source-code-examples/500-line-example.tsx +501 -0
- package/dist/cjs/bidi-warning/bidi-warning-decorator.js +6 -19
- package/dist/cjs/bidi-warning/index.js +0 -2
- package/dist/cjs/bidi-warning/ui/index.js +6 -17
- package/dist/cjs/bidi-warning/ui/styled.js +7 -12
- package/dist/cjs/code-block.js +25 -34
- package/dist/cjs/code.js +11 -33
- package/dist/cjs/constants.js +0 -2
- package/dist/cjs/entry-points/block.js +0 -2
- package/dist/cjs/entry-points/constants.js +0 -1
- package/dist/cjs/entry-points/inline.js +0 -4
- package/dist/cjs/extract-react-types/code-block.js +0 -1
- package/dist/cjs/extract-react-types/code.js +0 -1
- package/dist/cjs/index.js +0 -7
- package/dist/cjs/internal/hooks/use-highlight.js +10 -24
- package/dist/cjs/internal/theme/constants.js +2 -3
- package/dist/cjs/internal/theme/get-theme.js +0 -16
- package/dist/cjs/internal/theme/styles.js +4 -23
- package/dist/cjs/internal/utils/get-normalized-language.js +2 -8
- package/dist/cjs/react-syntax-highlighter-bidi-warning-renderer.js +17 -41
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/bidi-warning/bidi-warning-decorator.js +5 -9
- package/dist/es2019/bidi-warning/ui/index.js +0 -1
- package/dist/es2019/bidi-warning/ui/styled.js +5 -6
- package/dist/es2019/code-block.js +5 -3
- package/dist/es2019/code.js +0 -7
- package/dist/es2019/internal/hooks/use-highlight.js +4 -8
- package/dist/es2019/internal/theme/constants.js +2 -1
- package/dist/es2019/internal/theme/get-theme.js +2 -3
- package/dist/es2019/internal/theme/styles.js +8 -9
- package/dist/es2019/internal/utils/get-normalized-language.js +2 -3
- package/dist/es2019/react-syntax-highlighter-bidi-warning-renderer.js +14 -21
- package/dist/es2019/version.json +1 -1
- package/dist/esm/bidi-warning/bidi-warning-decorator.js +6 -16
- package/dist/esm/bidi-warning/ui/index.js +6 -9
- package/dist/esm/bidi-warning/ui/styled.js +7 -8
- package/dist/esm/code-block.js +26 -26
- package/dist/esm/code.js +11 -21
- package/dist/esm/internal/hooks/use-highlight.js +10 -19
- package/dist/esm/internal/theme/constants.js +2 -1
- package/dist/esm/internal/theme/get-theme.js +0 -5
- package/dist/esm/internal/theme/styles.js +4 -10
- package/dist/esm/internal/utils/get-normalized-language.js +2 -3
- package/dist/esm/react-syntax-highlighter-bidi-warning-renderer.js +20 -33
- package/dist/esm/version.json +1 -1
- package/package.json +1 -1
- package/report.api.md +14 -1
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
|
|
4
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
|
|
6
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
-
|
|
8
5
|
// @ts-nocheck
|
|
9
6
|
import React from 'react';
|
|
10
7
|
import CodeBidiWarning from './bidi-warning';
|
|
11
|
-
import codeBidiWarningDecorator from './bidi-warning/bidi-warning-decorator';
|
|
8
|
+
import codeBidiWarningDecorator from './bidi-warning/bidi-warning-decorator';
|
|
9
|
+
|
|
10
|
+
// File mostly vendored from react-syntax-highlighter
|
|
12
11
|
//
|
|
13
12
|
// - https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/efc3f7b7537d1729193b7a472067bcbe6cbecaf1/src/highlight.js#L272-L281
|
|
14
13
|
// - https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/efc3f7b7537d1729193b7a472067bcbe6cbecaf1/src/create-element.js
|
|
@@ -18,8 +17,8 @@ import codeBidiWarningDecorator from './bidi-warning/bidi-warning-decorator'; //
|
|
|
18
17
|
export function createBidiWarningRenderer(codeBidiWarningConfig) {
|
|
19
18
|
return function bidiWarningRenderer(_ref) {
|
|
20
19
|
var rows = _ref.rows,
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
stylesheet = _ref.stylesheet,
|
|
21
|
+
useInlineStyles = _ref.useInlineStyles;
|
|
23
22
|
return rows.map(function (node, i) {
|
|
24
23
|
return createElement({
|
|
25
24
|
node: node,
|
|
@@ -30,50 +29,41 @@ export function createBidiWarningRenderer(codeBidiWarningConfig) {
|
|
|
30
29
|
});
|
|
31
30
|
});
|
|
32
31
|
};
|
|
33
|
-
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Get all possible permutations of all power sets
|
|
34
35
|
//
|
|
35
36
|
// Super simple, non-algorithmic solution since the
|
|
36
37
|
// number of class names will not be greater than 4
|
|
37
|
-
|
|
38
38
|
function powerSetPermutations(arr) {
|
|
39
39
|
var arrLength = arr.length;
|
|
40
|
-
|
|
41
40
|
if (arrLength === 0 || arrLength === 1) {
|
|
42
41
|
return arr;
|
|
43
42
|
}
|
|
44
|
-
|
|
45
43
|
if (arrLength === 2) {
|
|
46
44
|
// prettier-ignore
|
|
47
45
|
return [arr[0], arr[1], "".concat(arr[0], ".").concat(arr[1]), "".concat(arr[1], ".").concat(arr[0])];
|
|
48
46
|
}
|
|
49
|
-
|
|
50
47
|
if (arrLength === 3) {
|
|
51
48
|
return [arr[0], arr[1], arr[2], "".concat(arr[0], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[0]), "".concat(arr[1], ".").concat(arr[2]), "".concat(arr[2], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[1], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[2], ".").concat(arr[1]), "".concat(arr[1], ".").concat(arr[0], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[2], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[0], ".").concat(arr[1]), "".concat(arr[2], ".").concat(arr[1], ".").concat(arr[0])];
|
|
52
49
|
}
|
|
53
|
-
|
|
54
50
|
if (arrLength >= 4) {
|
|
55
51
|
// Currently does not support more than 4 extra
|
|
56
52
|
// class names (after `.token` has been removed)
|
|
57
53
|
return [arr[0], arr[1], arr[2], arr[3], "".concat(arr[0], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[3]), "".concat(arr[1], ".").concat(arr[0]), "".concat(arr[1], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[3]), "".concat(arr[2], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[1]), "".concat(arr[2], ".").concat(arr[3]), "".concat(arr[3], ".").concat(arr[0]), "".concat(arr[3], ".").concat(arr[1]), "".concat(arr[3], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[1], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[1], ".").concat(arr[3]), "".concat(arr[0], ".").concat(arr[2], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[2], ".").concat(arr[3]), "".concat(arr[0], ".").concat(arr[3], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[3], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[0], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[0], ".").concat(arr[3]), "".concat(arr[1], ".").concat(arr[2], ".").concat(arr[0]), "".concat(arr[1], ".").concat(arr[2], ".").concat(arr[3]), "".concat(arr[1], ".").concat(arr[3], ".").concat(arr[0]), "".concat(arr[1], ".").concat(arr[3], ".").concat(arr[2]), "".concat(arr[2], ".").concat(arr[0], ".").concat(arr[1]), "".concat(arr[2], ".").concat(arr[0], ".").concat(arr[3]), "".concat(arr[2], ".").concat(arr[1], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[1], ".").concat(arr[3]), "".concat(arr[2], ".").concat(arr[3], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[3], ".").concat(arr[1]), "".concat(arr[3], ".").concat(arr[0], ".").concat(arr[1]), "".concat(arr[3], ".").concat(arr[0], ".").concat(arr[2]), "".concat(arr[3], ".").concat(arr[1], ".").concat(arr[0]), "".concat(arr[3], ".").concat(arr[1], ".").concat(arr[2]), "".concat(arr[3], ".").concat(arr[2], ".").concat(arr[0]), "".concat(arr[3], ".").concat(arr[2], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[1], ".").concat(arr[2], ".").concat(arr[3]), "".concat(arr[0], ".").concat(arr[1], ".").concat(arr[3], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[2], ".").concat(arr[1], ".").concat(arr[3]), "".concat(arr[0], ".").concat(arr[2], ".").concat(arr[3], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[3], ".").concat(arr[1], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[3], ".").concat(arr[2], ".").concat(arr[1]), "".concat(arr[1], ".").concat(arr[0], ".").concat(arr[2], ".").concat(arr[3]), "".concat(arr[1], ".").concat(arr[0], ".").concat(arr[3], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[2], ".").concat(arr[0], ".").concat(arr[3]), "".concat(arr[1], ".").concat(arr[2], ".").concat(arr[3], ".").concat(arr[0]), "".concat(arr[1], ".").concat(arr[3], ".").concat(arr[0], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[3], ".").concat(arr[2], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[0], ".").concat(arr[1], ".").concat(arr[3]), "".concat(arr[2], ".").concat(arr[0], ".").concat(arr[3], ".").concat(arr[1]), "".concat(arr[2], ".").concat(arr[1], ".").concat(arr[0], ".").concat(arr[3]), "".concat(arr[2], ".").concat(arr[1], ".").concat(arr[3], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[3], ".").concat(arr[0], ".").concat(arr[1]), "".concat(arr[2], ".").concat(arr[3], ".").concat(arr[1], ".").concat(arr[0]), "".concat(arr[3], ".").concat(arr[0], ".").concat(arr[1], ".").concat(arr[2]), "".concat(arr[3], ".").concat(arr[0], ".").concat(arr[2], ".").concat(arr[1]), "".concat(arr[3], ".").concat(arr[1], ".").concat(arr[0], ".").concat(arr[2]), "".concat(arr[3], ".").concat(arr[1], ".").concat(arr[2], ".").concat(arr[0]), "".concat(arr[3], ".").concat(arr[2], ".").concat(arr[0], ".").concat(arr[1]), "".concat(arr[3], ".").concat(arr[2], ".").concat(arr[1], ".").concat(arr[0])];
|
|
58
54
|
}
|
|
59
55
|
}
|
|
60
|
-
|
|
61
56
|
var classNameCombinations = {};
|
|
62
|
-
|
|
63
57
|
function getClassNameCombinations(classNames) {
|
|
64
58
|
if (classNames.length === 0 || classNames.length === 1) {
|
|
65
59
|
return classNames;
|
|
66
60
|
}
|
|
67
|
-
|
|
68
61
|
var key = classNames.join('.');
|
|
69
|
-
|
|
70
62
|
if (!classNameCombinations[key]) {
|
|
71
63
|
classNameCombinations[key] = powerSetPermutations(classNames);
|
|
72
64
|
}
|
|
73
|
-
|
|
74
65
|
return classNameCombinations[key];
|
|
75
66
|
}
|
|
76
|
-
|
|
77
67
|
export function createStyleObject(classNames) {
|
|
78
68
|
var elementStyle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
79
69
|
var stylesheet = arguments.length > 2 ? arguments[2] : undefined;
|
|
@@ -103,27 +93,25 @@ export function createChildren(stylesheet, useInlineStyles, codeBidiWarningConfi
|
|
|
103
93
|
});
|
|
104
94
|
};
|
|
105
95
|
}
|
|
106
|
-
|
|
107
96
|
function createElement(_ref2) {
|
|
108
97
|
var node = _ref2.node,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
98
|
+
stylesheet = _ref2.stylesheet,
|
|
99
|
+
_ref2$style = _ref2.style,
|
|
100
|
+
style = _ref2$style === void 0 ? {} : _ref2$style,
|
|
101
|
+
useInlineStyles = _ref2.useInlineStyles,
|
|
102
|
+
codeBidiWarningConfig = _ref2.codeBidiWarningConfig,
|
|
103
|
+
key = _ref2.key;
|
|
115
104
|
var properties = node.properties,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
105
|
+
type = node.type,
|
|
106
|
+
TagName = node.tagName,
|
|
107
|
+
value = node.value;
|
|
120
108
|
if (type === 'text') {
|
|
121
109
|
// occasionally react-syntax-highlighter passes a numeric value when the
|
|
122
110
|
// type is text
|
|
123
111
|
var textValue = value + '';
|
|
124
112
|
var decorated = codeBidiWarningDecorator(textValue, function (_ref3) {
|
|
125
113
|
var bidiCharacter = _ref3.bidiCharacter,
|
|
126
|
-
|
|
114
|
+
index = _ref3.index;
|
|
127
115
|
return /*#__PURE__*/React.createElement(CodeBidiWarning, {
|
|
128
116
|
bidiCharacter: bidiCharacter,
|
|
129
117
|
key: index,
|
|
@@ -135,7 +123,6 @@ function createElement(_ref2) {
|
|
|
135
123
|
} else if (TagName) {
|
|
136
124
|
var childrenCreator = createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig);
|
|
137
125
|
var props;
|
|
138
|
-
|
|
139
126
|
if (!useInlineStyles) {
|
|
140
127
|
props = _objectSpread(_objectSpread({}, properties), {}, {
|
|
141
128
|
className: createClassNameString(properties.className)
|
|
@@ -148,8 +135,9 @@ function createElement(_ref2) {
|
|
|
148
135
|
}
|
|
149
136
|
});
|
|
150
137
|
return classes;
|
|
151
|
-
}, []);
|
|
138
|
+
}, []);
|
|
152
139
|
|
|
140
|
+
// For compatibility with older versions of react-syntax-highlighter
|
|
153
141
|
var startingClassName = properties.className && properties.className.includes('token') ? ['token'] : [];
|
|
154
142
|
var className = properties.className && startingClassName.concat(properties.className.filter(function (className) {
|
|
155
143
|
return !allStylesheetSelectors.includes(className);
|
|
@@ -159,7 +147,6 @@ function createElement(_ref2) {
|
|
|
159
147
|
style: createStyleObject(properties.className, Object.assign({}, properties.style, style), stylesheet)
|
|
160
148
|
});
|
|
161
149
|
}
|
|
162
|
-
|
|
163
150
|
var children = childrenCreator(node.children);
|
|
164
151
|
return /*#__PURE__*/React.createElement(TagName, _extends({
|
|
165
152
|
key: key
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
package/report.api.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- API Report Version: 2.
|
|
1
|
+
<!-- API Report Version: 2.3 -->
|
|
2
2
|
|
|
3
3
|
## API Report File for "@atlaskit/code"
|
|
4
4
|
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
### Table of contents
|
|
9
9
|
|
|
10
10
|
- [Main Entry Types](#main-entry-types)
|
|
11
|
+
- [Peer Dependencies](#peer-dependencies)
|
|
11
12
|
|
|
12
13
|
### Main Entry Types
|
|
13
14
|
|
|
@@ -848,3 +849,15 @@ export type SupportedLanguages = LanguageAlias | LanguageName;
|
|
|
848
849
|
```
|
|
849
850
|
|
|
850
851
|
<!--SECTION END: Main Entry Types-->
|
|
852
|
+
|
|
853
|
+
### Peer Dependencies
|
|
854
|
+
|
|
855
|
+
<!--SECTION START: Peer Dependencies-->
|
|
856
|
+
|
|
857
|
+
```json
|
|
858
|
+
{
|
|
859
|
+
"react": "^16.8.0"
|
|
860
|
+
}
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
<!--SECTION END: Peer Dependencies-->
|