@atlaskit/code 14.4.7 → 14.5.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/bidi-warning-decorator.js +8 -0
- package/dist/cjs/bidi-warning/ui/index.js +8 -0
- package/dist/cjs/code-block.js +22 -20
- package/dist/cjs/internal/theme/styles.js +20 -9
- package/dist/cjs/syntax-highlighter/async.js +88 -0
- package/dist/cjs/syntax-highlighter/index.js +44 -0
- package/dist/cjs/syntax-highlighter/lib/highlight.js +91 -0
- package/dist/cjs/syntax-highlighter/lib/process/create-line-element.js +74 -0
- package/dist/cjs/syntax-highlighter/lib/process/create-line.js +32 -0
- package/dist/cjs/syntax-highlighter/lib/process/flatten-code-tree.js +29 -0
- package/dist/cjs/syntax-highlighter/lib/process/get-code-tree.js +22 -0
- package/dist/cjs/syntax-highlighter/lib/process/get-inline-line-number.js +23 -0
- package/dist/cjs/syntax-highlighter/lib/process/index.js +122 -0
- package/dist/cjs/syntax-highlighter/lib/react-renderer/create-children.js +21 -0
- package/dist/cjs/syntax-highlighter/lib/react-renderer/create-element.js +57 -0
- package/dist/cjs/syntax-highlighter/lib/react-renderer/index.js +30 -0
- package/dist/cjs/syntax-highlighter/types.js +31 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/bidi-warning/bidi-warning-decorator.js +8 -0
- package/dist/es2019/bidi-warning/ui/index.js +8 -0
- package/dist/es2019/code-block.js +18 -18
- package/dist/es2019/internal/theme/styles.js +20 -9
- package/dist/es2019/syntax-highlighter/async.js +51 -0
- package/dist/es2019/syntax-highlighter/index.js +38 -0
- package/dist/es2019/syntax-highlighter/lib/highlight.js +73 -0
- package/dist/es2019/syntax-highlighter/lib/process/create-line-element.js +65 -0
- package/dist/es2019/syntax-highlighter/lib/process/create-line.js +23 -0
- package/dist/es2019/syntax-highlighter/lib/process/flatten-code-tree.js +18 -0
- package/dist/es2019/syntax-highlighter/lib/process/get-code-tree.js +16 -0
- package/dist/es2019/syntax-highlighter/lib/process/get-inline-line-number.js +17 -0
- package/dist/es2019/syntax-highlighter/lib/process/index.js +114 -0
- package/dist/es2019/syntax-highlighter/lib/react-renderer/create-children.js +12 -0
- package/dist/es2019/syntax-highlighter/lib/react-renderer/create-element.js +53 -0
- package/dist/es2019/syntax-highlighter/lib/react-renderer/index.js +23 -0
- package/dist/es2019/syntax-highlighter/types.js +9 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/bidi-warning/bidi-warning-decorator.js +8 -0
- package/dist/esm/bidi-warning/ui/index.js +8 -0
- package/dist/esm/code-block.js +20 -19
- package/dist/esm/internal/theme/styles.js +20 -9
- package/dist/esm/syntax-highlighter/async.js +76 -0
- package/dist/esm/syntax-highlighter/index.js +38 -0
- package/dist/esm/syntax-highlighter/lib/highlight.js +84 -0
- package/dist/esm/syntax-highlighter/lib/process/create-line-element.js +67 -0
- package/dist/esm/syntax-highlighter/lib/process/create-line.js +24 -0
- package/dist/esm/syntax-highlighter/lib/process/flatten-code-tree.js +22 -0
- package/dist/esm/syntax-highlighter/lib/process/get-code-tree.js +16 -0
- package/dist/esm/syntax-highlighter/lib/process/get-inline-line-number.js +17 -0
- package/dist/esm/syntax-highlighter/lib/process/index.js +115 -0
- package/dist/esm/syntax-highlighter/lib/react-renderer/create-children.js +14 -0
- package/dist/esm/syntax-highlighter/lib/react-renderer/create-element.js +50 -0
- package/dist/esm/syntax-highlighter/lib/react-renderer/index.js +24 -0
- package/dist/esm/syntax-highlighter/types.js +24 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/bidi-warning/bidi-warning-decorator.d.ts +7 -0
- package/dist/types/bidi-warning/ui/index.d.ts +8 -0
- package/dist/types/bidi-warning/ui/types.d.ts +11 -15
- package/dist/types/extract-react-types/code-block.d.ts +24 -14
- package/dist/types/internal/theme/styles.d.ts +1 -1
- package/dist/types/internal/types.d.ts +31 -18
- package/dist/types/syntax-highlighter/async.d.ts +3 -0
- package/dist/types/syntax-highlighter/index.d.ts +36 -0
- package/dist/types/syntax-highlighter/lib/highlight.d.ts +12 -0
- package/dist/types/syntax-highlighter/lib/process/create-line-element.d.ts +9 -0
- package/dist/types/syntax-highlighter/lib/process/create-line.d.ts +3 -0
- package/dist/types/syntax-highlighter/lib/process/flatten-code-tree.d.ts +2 -0
- package/dist/types/syntax-highlighter/lib/process/get-code-tree.d.ts +2 -0
- package/dist/types/syntax-highlighter/lib/process/get-inline-line-number.d.ts +2 -0
- package/dist/types/syntax-highlighter/lib/process/index.d.ts +17 -0
- package/dist/types/syntax-highlighter/lib/react-renderer/create-children.d.ts +3 -0
- package/dist/types/syntax-highlighter/lib/react-renderer/create-element.d.ts +7 -0
- package/dist/types/syntax-highlighter/lib/react-renderer/index.d.ts +15 -0
- package/dist/types/syntax-highlighter/types.d.ts +129 -0
- package/dist/types/types.d.ts +10 -11
- package/package.json +13 -9
- package/report.api.md +1 -0
- package/dist/cjs/react-syntax-highlighter-bidi-warning-renderer.js +0 -156
- package/dist/es2019/react-syntax-highlighter-bidi-warning-renderer.js +0 -149
- package/dist/esm/react-syntax-highlighter-bidi-warning-renderer.js +0 -155
- package/dist/types/react-syntax-highlighter-bidi-warning-renderer.d.ts +0 -9
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import CodeBidiWarning from './bidi-warning';
|
|
5
|
-
import codeBidiWarningDecorator from './bidi-warning/bidi-warning-decorator';
|
|
6
|
-
|
|
7
|
-
// File mostly vendored from react-syntax-highlighter
|
|
8
|
-
//
|
|
9
|
-
// - https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/efc3f7b7537d1729193b7a472067bcbe6cbecaf1/src/highlight.js#L272-L281
|
|
10
|
-
// - https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/efc3f7b7537d1729193b7a472067bcbe6cbecaf1/src/create-element.js
|
|
11
|
-
//
|
|
12
|
-
// Patching react syntax-highlighter with a decoration feature is likely preferable
|
|
13
|
-
|
|
14
|
-
export function createBidiWarningRenderer(codeBidiWarningConfig) {
|
|
15
|
-
return function bidiWarningRenderer({
|
|
16
|
-
rows,
|
|
17
|
-
stylesheet,
|
|
18
|
-
useInlineStyles
|
|
19
|
-
}) {
|
|
20
|
-
return rows.map((node, i) => createElement({
|
|
21
|
-
node,
|
|
22
|
-
stylesheet,
|
|
23
|
-
useInlineStyles,
|
|
24
|
-
codeBidiWarningConfig,
|
|
25
|
-
key: `code-segement${i}`
|
|
26
|
-
}));
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Get all possible permutations of all power sets
|
|
31
|
-
//
|
|
32
|
-
// Super simple, non-algorithmic solution since the
|
|
33
|
-
// number of class names will not be greater than 4
|
|
34
|
-
function powerSetPermutations(arr) {
|
|
35
|
-
const arrLength = arr.length;
|
|
36
|
-
if (arrLength === 0 || arrLength === 1) {
|
|
37
|
-
return arr;
|
|
38
|
-
}
|
|
39
|
-
if (arrLength === 2) {
|
|
40
|
-
// prettier-ignore
|
|
41
|
-
return [arr[0], arr[1], `${arr[0]}.${arr[1]}`, `${arr[1]}.${arr[0]}`];
|
|
42
|
-
}
|
|
43
|
-
if (arrLength === 3) {
|
|
44
|
-
return [arr[0], arr[1], arr[2], `${arr[0]}.${arr[1]}`, `${arr[0]}.${arr[2]}`, `${arr[1]}.${arr[0]}`, `${arr[1]}.${arr[2]}`, `${arr[2]}.${arr[0]}`, `${arr[2]}.${arr[1]}`, `${arr[0]}.${arr[1]}.${arr[2]}`, `${arr[0]}.${arr[2]}.${arr[1]}`, `${arr[1]}.${arr[0]}.${arr[2]}`, `${arr[1]}.${arr[2]}.${arr[0]}`, `${arr[2]}.${arr[0]}.${arr[1]}`, `${arr[2]}.${arr[1]}.${arr[0]}`];
|
|
45
|
-
}
|
|
46
|
-
if (arrLength >= 4) {
|
|
47
|
-
// Currently does not support more than 4 extra
|
|
48
|
-
// class names (after `.token` has been removed)
|
|
49
|
-
return [arr[0], arr[1], arr[2], arr[3], `${arr[0]}.${arr[1]}`, `${arr[0]}.${arr[2]}`, `${arr[0]}.${arr[3]}`, `${arr[1]}.${arr[0]}`, `${arr[1]}.${arr[2]}`, `${arr[1]}.${arr[3]}`, `${arr[2]}.${arr[0]}`, `${arr[2]}.${arr[1]}`, `${arr[2]}.${arr[3]}`, `${arr[3]}.${arr[0]}`, `${arr[3]}.${arr[1]}`, `${arr[3]}.${arr[2]}`, `${arr[0]}.${arr[1]}.${arr[2]}`, `${arr[0]}.${arr[1]}.${arr[3]}`, `${arr[0]}.${arr[2]}.${arr[1]}`, `${arr[0]}.${arr[2]}.${arr[3]}`, `${arr[0]}.${arr[3]}.${arr[1]}`, `${arr[0]}.${arr[3]}.${arr[2]}`, `${arr[1]}.${arr[0]}.${arr[2]}`, `${arr[1]}.${arr[0]}.${arr[3]}`, `${arr[1]}.${arr[2]}.${arr[0]}`, `${arr[1]}.${arr[2]}.${arr[3]}`, `${arr[1]}.${arr[3]}.${arr[0]}`, `${arr[1]}.${arr[3]}.${arr[2]}`, `${arr[2]}.${arr[0]}.${arr[1]}`, `${arr[2]}.${arr[0]}.${arr[3]}`, `${arr[2]}.${arr[1]}.${arr[0]}`, `${arr[2]}.${arr[1]}.${arr[3]}`, `${arr[2]}.${arr[3]}.${arr[0]}`, `${arr[2]}.${arr[3]}.${arr[1]}`, `${arr[3]}.${arr[0]}.${arr[1]}`, `${arr[3]}.${arr[0]}.${arr[2]}`, `${arr[3]}.${arr[1]}.${arr[0]}`, `${arr[3]}.${arr[1]}.${arr[2]}`, `${arr[3]}.${arr[2]}.${arr[0]}`, `${arr[3]}.${arr[2]}.${arr[1]}`, `${arr[0]}.${arr[1]}.${arr[2]}.${arr[3]}`, `${arr[0]}.${arr[1]}.${arr[3]}.${arr[2]}`, `${arr[0]}.${arr[2]}.${arr[1]}.${arr[3]}`, `${arr[0]}.${arr[2]}.${arr[3]}.${arr[1]}`, `${arr[0]}.${arr[3]}.${arr[1]}.${arr[2]}`, `${arr[0]}.${arr[3]}.${arr[2]}.${arr[1]}`, `${arr[1]}.${arr[0]}.${arr[2]}.${arr[3]}`, `${arr[1]}.${arr[0]}.${arr[3]}.${arr[2]}`, `${arr[1]}.${arr[2]}.${arr[0]}.${arr[3]}`, `${arr[1]}.${arr[2]}.${arr[3]}.${arr[0]}`, `${arr[1]}.${arr[3]}.${arr[0]}.${arr[2]}`, `${arr[1]}.${arr[3]}.${arr[2]}.${arr[0]}`, `${arr[2]}.${arr[0]}.${arr[1]}.${arr[3]}`, `${arr[2]}.${arr[0]}.${arr[3]}.${arr[1]}`, `${arr[2]}.${arr[1]}.${arr[0]}.${arr[3]}`, `${arr[2]}.${arr[1]}.${arr[3]}.${arr[0]}`, `${arr[2]}.${arr[3]}.${arr[0]}.${arr[1]}`, `${arr[2]}.${arr[3]}.${arr[1]}.${arr[0]}`, `${arr[3]}.${arr[0]}.${arr[1]}.${arr[2]}`, `${arr[3]}.${arr[0]}.${arr[2]}.${arr[1]}`, `${arr[3]}.${arr[1]}.${arr[0]}.${arr[2]}`, `${arr[3]}.${arr[1]}.${arr[2]}.${arr[0]}`, `${arr[3]}.${arr[2]}.${arr[0]}.${arr[1]}`, `${arr[3]}.${arr[2]}.${arr[1]}.${arr[0]}`];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const classNameCombinations = {};
|
|
53
|
-
function getClassNameCombinations(classNames) {
|
|
54
|
-
if (classNames.length === 0 || classNames.length === 1) {
|
|
55
|
-
return classNames;
|
|
56
|
-
}
|
|
57
|
-
const key = classNames.join('.');
|
|
58
|
-
if (!classNameCombinations[key]) {
|
|
59
|
-
classNameCombinations[key] = powerSetPermutations(classNames);
|
|
60
|
-
}
|
|
61
|
-
return classNameCombinations[key];
|
|
62
|
-
}
|
|
63
|
-
export function createStyleObject(classNames, elementStyle = {}, stylesheet) {
|
|
64
|
-
const nonTokenClassNames = classNames.filter(className => className !== 'token');
|
|
65
|
-
const classNamesCombinations = getClassNameCombinations(nonTokenClassNames);
|
|
66
|
-
return classNamesCombinations.reduce((styleObject, className) => {
|
|
67
|
-
return {
|
|
68
|
-
...styleObject,
|
|
69
|
-
...stylesheet[className]
|
|
70
|
-
};
|
|
71
|
-
}, elementStyle);
|
|
72
|
-
}
|
|
73
|
-
export function createClassNameString(classNames) {
|
|
74
|
-
return classNames.join(' ');
|
|
75
|
-
}
|
|
76
|
-
export function createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig) {
|
|
77
|
-
let childrenCount = 0;
|
|
78
|
-
return children => {
|
|
79
|
-
childrenCount += 1;
|
|
80
|
-
return children.map((child, i) => createElement({
|
|
81
|
-
node: child,
|
|
82
|
-
stylesheet,
|
|
83
|
-
useInlineStyles,
|
|
84
|
-
codeBidiWarningConfig,
|
|
85
|
-
key: `code-segment-${childrenCount}-${i}`
|
|
86
|
-
}));
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
function createElement({
|
|
90
|
-
node,
|
|
91
|
-
stylesheet,
|
|
92
|
-
style = {},
|
|
93
|
-
useInlineStyles,
|
|
94
|
-
codeBidiWarningConfig,
|
|
95
|
-
key
|
|
96
|
-
}) {
|
|
97
|
-
const {
|
|
98
|
-
properties,
|
|
99
|
-
type,
|
|
100
|
-
tagName: TagName,
|
|
101
|
-
value
|
|
102
|
-
} = node;
|
|
103
|
-
if (type === 'text') {
|
|
104
|
-
// occasionally react-syntax-highlighter passes a numeric value when the
|
|
105
|
-
// type is text
|
|
106
|
-
const textValue = value + '';
|
|
107
|
-
const decorated = codeBidiWarningDecorator(textValue, ({
|
|
108
|
-
bidiCharacter,
|
|
109
|
-
index
|
|
110
|
-
}) => /*#__PURE__*/React.createElement(CodeBidiWarning, {
|
|
111
|
-
bidiCharacter: bidiCharacter,
|
|
112
|
-
key: index,
|
|
113
|
-
label: codeBidiWarningConfig.codeBidiWarningLabel,
|
|
114
|
-
tooltipEnabled: codeBidiWarningConfig.codeBidiWarningTooltipEnabled
|
|
115
|
-
}));
|
|
116
|
-
return decorated;
|
|
117
|
-
} else if (TagName) {
|
|
118
|
-
const childrenCreator = createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig);
|
|
119
|
-
let props;
|
|
120
|
-
if (!useInlineStyles) {
|
|
121
|
-
props = {
|
|
122
|
-
...properties,
|
|
123
|
-
className: createClassNameString(properties.className)
|
|
124
|
-
};
|
|
125
|
-
} else {
|
|
126
|
-
const allStylesheetSelectors = Object.keys(stylesheet).reduce((classes, selector) => {
|
|
127
|
-
selector.split('.').forEach(className => {
|
|
128
|
-
if (!classes.includes(className)) {
|
|
129
|
-
classes.push(className);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
return classes;
|
|
133
|
-
}, []);
|
|
134
|
-
|
|
135
|
-
// For compatibility with older versions of react-syntax-highlighter
|
|
136
|
-
const startingClassName = properties.className && properties.className.includes('token') ? ['token'] : [];
|
|
137
|
-
const className = properties.className && startingClassName.concat(properties.className.filter(className => !allStylesheetSelectors.includes(className)));
|
|
138
|
-
props = {
|
|
139
|
-
...properties,
|
|
140
|
-
className: createClassNameString(className) || undefined,
|
|
141
|
-
style: createStyleObject(properties.className, Object.assign({}, properties.style, style), stylesheet)
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
const children = childrenCreator(node.children);
|
|
145
|
-
return /*#__PURE__*/React.createElement(TagName, _extends({
|
|
146
|
-
key: key
|
|
147
|
-
}, props), children);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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; }
|
|
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; }
|
|
5
|
-
// @ts-nocheck
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import CodeBidiWarning from './bidi-warning';
|
|
8
|
-
import codeBidiWarningDecorator from './bidi-warning/bidi-warning-decorator';
|
|
9
|
-
|
|
10
|
-
// File mostly vendored from react-syntax-highlighter
|
|
11
|
-
//
|
|
12
|
-
// - https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/efc3f7b7537d1729193b7a472067bcbe6cbecaf1/src/highlight.js#L272-L281
|
|
13
|
-
// - https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/efc3f7b7537d1729193b7a472067bcbe6cbecaf1/src/create-element.js
|
|
14
|
-
//
|
|
15
|
-
// Patching react syntax-highlighter with a decoration feature is likely preferable
|
|
16
|
-
|
|
17
|
-
export function createBidiWarningRenderer(codeBidiWarningConfig) {
|
|
18
|
-
return function bidiWarningRenderer(_ref) {
|
|
19
|
-
var rows = _ref.rows,
|
|
20
|
-
stylesheet = _ref.stylesheet,
|
|
21
|
-
useInlineStyles = _ref.useInlineStyles;
|
|
22
|
-
return rows.map(function (node, i) {
|
|
23
|
-
return createElement({
|
|
24
|
-
node: node,
|
|
25
|
-
stylesheet: stylesheet,
|
|
26
|
-
useInlineStyles: useInlineStyles,
|
|
27
|
-
codeBidiWarningConfig: codeBidiWarningConfig,
|
|
28
|
-
key: "code-segement".concat(i)
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Get all possible permutations of all power sets
|
|
35
|
-
//
|
|
36
|
-
// Super simple, non-algorithmic solution since the
|
|
37
|
-
// number of class names will not be greater than 4
|
|
38
|
-
function powerSetPermutations(arr) {
|
|
39
|
-
var arrLength = arr.length;
|
|
40
|
-
if (arrLength === 0 || arrLength === 1) {
|
|
41
|
-
return arr;
|
|
42
|
-
}
|
|
43
|
-
if (arrLength === 2) {
|
|
44
|
-
// prettier-ignore
|
|
45
|
-
return [arr[0], arr[1], "".concat(arr[0], ".").concat(arr[1]), "".concat(arr[1], ".").concat(arr[0])];
|
|
46
|
-
}
|
|
47
|
-
if (arrLength === 3) {
|
|
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])];
|
|
49
|
-
}
|
|
50
|
-
if (arrLength >= 4) {
|
|
51
|
-
// Currently does not support more than 4 extra
|
|
52
|
-
// class names (after `.token` has been removed)
|
|
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])];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
var classNameCombinations = {};
|
|
57
|
-
function getClassNameCombinations(classNames) {
|
|
58
|
-
if (classNames.length === 0 || classNames.length === 1) {
|
|
59
|
-
return classNames;
|
|
60
|
-
}
|
|
61
|
-
var key = classNames.join('.');
|
|
62
|
-
if (!classNameCombinations[key]) {
|
|
63
|
-
classNameCombinations[key] = powerSetPermutations(classNames);
|
|
64
|
-
}
|
|
65
|
-
return classNameCombinations[key];
|
|
66
|
-
}
|
|
67
|
-
export function createStyleObject(classNames) {
|
|
68
|
-
var elementStyle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
69
|
-
var stylesheet = arguments.length > 2 ? arguments[2] : undefined;
|
|
70
|
-
var nonTokenClassNames = classNames.filter(function (className) {
|
|
71
|
-
return className !== 'token';
|
|
72
|
-
});
|
|
73
|
-
var classNamesCombinations = getClassNameCombinations(nonTokenClassNames);
|
|
74
|
-
return classNamesCombinations.reduce(function (styleObject, className) {
|
|
75
|
-
return _objectSpread(_objectSpread({}, styleObject), stylesheet[className]);
|
|
76
|
-
}, elementStyle);
|
|
77
|
-
}
|
|
78
|
-
export function createClassNameString(classNames) {
|
|
79
|
-
return classNames.join(' ');
|
|
80
|
-
}
|
|
81
|
-
export function createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig) {
|
|
82
|
-
var childrenCount = 0;
|
|
83
|
-
return function (children) {
|
|
84
|
-
childrenCount += 1;
|
|
85
|
-
return children.map(function (child, i) {
|
|
86
|
-
return createElement({
|
|
87
|
-
node: child,
|
|
88
|
-
stylesheet: stylesheet,
|
|
89
|
-
useInlineStyles: useInlineStyles,
|
|
90
|
-
codeBidiWarningConfig: codeBidiWarningConfig,
|
|
91
|
-
key: "code-segment-".concat(childrenCount, "-").concat(i)
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function createElement(_ref2) {
|
|
97
|
-
var node = _ref2.node,
|
|
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;
|
|
104
|
-
var properties = node.properties,
|
|
105
|
-
type = node.type,
|
|
106
|
-
TagName = node.tagName,
|
|
107
|
-
value = node.value;
|
|
108
|
-
if (type === 'text') {
|
|
109
|
-
// occasionally react-syntax-highlighter passes a numeric value when the
|
|
110
|
-
// type is text
|
|
111
|
-
var textValue = value + '';
|
|
112
|
-
var decorated = codeBidiWarningDecorator(textValue, function (_ref3) {
|
|
113
|
-
var bidiCharacter = _ref3.bidiCharacter,
|
|
114
|
-
index = _ref3.index;
|
|
115
|
-
return /*#__PURE__*/React.createElement(CodeBidiWarning, {
|
|
116
|
-
bidiCharacter: bidiCharacter,
|
|
117
|
-
key: index,
|
|
118
|
-
label: codeBidiWarningConfig.codeBidiWarningLabel,
|
|
119
|
-
tooltipEnabled: codeBidiWarningConfig.codeBidiWarningTooltipEnabled
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
return decorated;
|
|
123
|
-
} else if (TagName) {
|
|
124
|
-
var childrenCreator = createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig);
|
|
125
|
-
var props;
|
|
126
|
-
if (!useInlineStyles) {
|
|
127
|
-
props = _objectSpread(_objectSpread({}, properties), {}, {
|
|
128
|
-
className: createClassNameString(properties.className)
|
|
129
|
-
});
|
|
130
|
-
} else {
|
|
131
|
-
var allStylesheetSelectors = Object.keys(stylesheet).reduce(function (classes, selector) {
|
|
132
|
-
selector.split('.').forEach(function (className) {
|
|
133
|
-
if (!classes.includes(className)) {
|
|
134
|
-
classes.push(className);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
return classes;
|
|
138
|
-
}, []);
|
|
139
|
-
|
|
140
|
-
// For compatibility with older versions of react-syntax-highlighter
|
|
141
|
-
var startingClassName = properties.className && properties.className.includes('token') ? ['token'] : [];
|
|
142
|
-
var className = properties.className && startingClassName.concat(properties.className.filter(function (className) {
|
|
143
|
-
return !allStylesheetSelectors.includes(className);
|
|
144
|
-
}));
|
|
145
|
-
props = _objectSpread(_objectSpread({}, properties), {}, {
|
|
146
|
-
className: createClassNameString(className) || undefined,
|
|
147
|
-
style: createStyleObject(properties.className, Object.assign({}, properties.style, style), stylesheet)
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
var children = childrenCreator(node.children);
|
|
151
|
-
return /*#__PURE__*/React.createElement(TagName, _extends({
|
|
152
|
-
key: key
|
|
153
|
-
}, props), children);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare type CodeBidiWarningConfig = {
|
|
2
|
-
codeBidiWarningLabel?: string;
|
|
3
|
-
codeBidiWarningTooltipEnabled: boolean;
|
|
4
|
-
};
|
|
5
|
-
export declare function createBidiWarningRenderer(codeBidiWarningConfig: CodeBidiWarningConfig): ({ rows, stylesheet, useInlineStyles, }: any) => any;
|
|
6
|
-
export declare function createStyleObject(classNames: any, elementStyle: {} | undefined, stylesheet: any): any;
|
|
7
|
-
export declare function createClassNameString(classNames: any): any;
|
|
8
|
-
export declare function createChildren(stylesheet: any, useInlineStyles: any, codeBidiWarningConfig: any): (children: any) => any;
|
|
9
|
-
export {};
|