@atlaskit/code 14.1.5 → 14.3.2
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/__perf__/default.tsx +1 -1
- package/bidi-warning/package.json +7 -0
- package/bidi-warning-decorator/package.json +7 -0
- package/codemods/__tests__/14.0.0-lite-mode/14.0.0-lite-mode.ts +10 -10
- package/codemods/__tests__/14.0.0-lite-mode/remove-language.ts +6 -6
- package/codemods/__tests__/14.0.0-lite-mode/text-to-child.ts +10 -10
- package/dist/cjs/bidi-warning/bidi-warning-decorator.js +73 -0
- package/dist/cjs/bidi-warning/index.js +15 -0
- package/dist/cjs/bidi-warning/ui/index.js +57 -0
- package/dist/cjs/bidi-warning/ui/styled.js +74 -0
- package/dist/cjs/bidi-warning/ui/types.js +5 -0
- package/dist/cjs/code-block.js +14 -2
- package/dist/cjs/code.js +70 -5
- package/dist/cjs/index.js +6 -6
- package/dist/cjs/internal/hooks/use-highlight.js +2 -2
- package/dist/cjs/internal/theme/constants.js +1 -1
- package/dist/cjs/internal/theme/get-theme.js +3 -3
- package/dist/cjs/internal/theme/styles.js +3 -3
- package/dist/cjs/react-syntax-highlighter-bidi-warning-renderer.js +180 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/bidi-warning/bidi-warning-decorator.js +42 -0
- package/dist/es2019/bidi-warning/index.js +1 -0
- package/dist/es2019/bidi-warning/ui/index.js +40 -0
- package/dist/es2019/bidi-warning/ui/styled.js +65 -0
- package/dist/es2019/bidi-warning/ui/types.js +1 -0
- package/dist/es2019/code-block.js +11 -2
- package/dist/es2019/code.js +54 -2
- package/dist/es2019/react-syntax-highlighter-bidi-warning-renderer.js +156 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/bidi-warning/bidi-warning-decorator.js +61 -0
- package/dist/esm/bidi-warning/index.js +1 -0
- package/dist/esm/bidi-warning/ui/index.js +42 -0
- package/dist/esm/bidi-warning/ui/styled.js +64 -0
- package/dist/esm/bidi-warning/ui/types.js +1 -0
- package/dist/esm/code-block.js +13 -2
- package/dist/esm/code.js +59 -3
- package/dist/esm/internal/hooks/use-highlight.js +2 -2
- package/dist/esm/internal/theme/get-theme.js +2 -2
- package/dist/esm/internal/theme/styles.js +2 -2
- package/dist/esm/react-syntax-highlighter-bidi-warning-renderer.js +168 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/bidi-warning/bidi-warning-decorator.d.ts +5 -0
- package/dist/types/bidi-warning/index.d.ts +1 -0
- package/dist/types/bidi-warning/ui/index.d.ts +3 -0
- package/dist/types/bidi-warning/ui/styled.d.ts +7 -0
- package/dist/types/bidi-warning/ui/types.d.ts +29 -0
- package/dist/types/code.d.ts +3 -2
- package/dist/types/internal/types.d.ts +19 -0
- package/dist/types/react-syntax-highlighter-bidi-warning-renderer.d.ts +9 -0
- package/dist/types/types.d.ts +19 -0
- package/package.json +10 -8
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
|
|
4
|
+
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
|
+
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
|
+
// @ts-nocheck
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import CodeBidiWarning from './bidi-warning';
|
|
11
|
+
import codeBidiWarningDecorator from './bidi-warning/bidi-warning-decorator'; // File mostly vendored from react-syntax-highlighter
|
|
12
|
+
//
|
|
13
|
+
// - https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/efc3f7b7537d1729193b7a472067bcbe6cbecaf1/src/highlight.js#L272-L281
|
|
14
|
+
// - https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/efc3f7b7537d1729193b7a472067bcbe6cbecaf1/src/create-element.js
|
|
15
|
+
//
|
|
16
|
+
// Patching react syntax-highlighter with a decoration feature is likely preferable
|
|
17
|
+
|
|
18
|
+
export function createBidiWarningRenderer(codeBidiWarningConfig) {
|
|
19
|
+
return function bidiWarningRenderer(_ref) {
|
|
20
|
+
var rows = _ref.rows,
|
|
21
|
+
stylesheet = _ref.stylesheet,
|
|
22
|
+
useInlineStyles = _ref.useInlineStyles;
|
|
23
|
+
return rows.map(function (node, i) {
|
|
24
|
+
return createElement({
|
|
25
|
+
node: node,
|
|
26
|
+
stylesheet: stylesheet,
|
|
27
|
+
useInlineStyles: useInlineStyles,
|
|
28
|
+
codeBidiWarningConfig: codeBidiWarningConfig,
|
|
29
|
+
key: "code-segement".concat(i)
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
} // Get all possible permutations of all power sets
|
|
34
|
+
//
|
|
35
|
+
// Super simple, non-algorithmic solution since the
|
|
36
|
+
// number of class names will not be greater than 4
|
|
37
|
+
|
|
38
|
+
function powerSetPermutations(arr) {
|
|
39
|
+
var arrLength = arr.length;
|
|
40
|
+
|
|
41
|
+
if (arrLength === 0 || arrLength === 1) {
|
|
42
|
+
return arr;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (arrLength === 2) {
|
|
46
|
+
// prettier-ignore
|
|
47
|
+
return [arr[0], arr[1], "".concat(arr[0], ".").concat(arr[1]), "".concat(arr[1], ".").concat(arr[0])];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (arrLength === 3) {
|
|
51
|
+
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
|
+
}
|
|
53
|
+
|
|
54
|
+
if (arrLength >= 4) {
|
|
55
|
+
// Currently does not support more than 4 extra
|
|
56
|
+
// class names (after `.token` has been removed)
|
|
57
|
+
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
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var classNameCombinations = {};
|
|
62
|
+
|
|
63
|
+
function getClassNameCombinations(classNames) {
|
|
64
|
+
if (classNames.length === 0 || classNames.length === 1) {
|
|
65
|
+
return classNames;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var key = classNames.join('.');
|
|
69
|
+
|
|
70
|
+
if (!classNameCombinations[key]) {
|
|
71
|
+
classNameCombinations[key] = powerSetPermutations(classNames);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return classNameCombinations[key];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function createStyleObject(classNames) {
|
|
78
|
+
var elementStyle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
79
|
+
var stylesheet = arguments.length > 2 ? arguments[2] : undefined;
|
|
80
|
+
var nonTokenClassNames = classNames.filter(function (className) {
|
|
81
|
+
return className !== 'token';
|
|
82
|
+
});
|
|
83
|
+
var classNamesCombinations = getClassNameCombinations(nonTokenClassNames);
|
|
84
|
+
return classNamesCombinations.reduce(function (styleObject, className) {
|
|
85
|
+
return _objectSpread(_objectSpread({}, styleObject), stylesheet[className]);
|
|
86
|
+
}, elementStyle);
|
|
87
|
+
}
|
|
88
|
+
export function createClassNameString(classNames) {
|
|
89
|
+
return classNames.join(' ');
|
|
90
|
+
}
|
|
91
|
+
export function createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig) {
|
|
92
|
+
var childrenCount = 0;
|
|
93
|
+
return function (children) {
|
|
94
|
+
childrenCount += 1;
|
|
95
|
+
return children.map(function (child, i) {
|
|
96
|
+
return createElement({
|
|
97
|
+
node: child,
|
|
98
|
+
stylesheet: stylesheet,
|
|
99
|
+
useInlineStyles: useInlineStyles,
|
|
100
|
+
codeBidiWarningConfig: codeBidiWarningConfig,
|
|
101
|
+
key: "code-segment-".concat(childrenCount, "-").concat(i)
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function createElement(_ref2) {
|
|
108
|
+
var node = _ref2.node,
|
|
109
|
+
stylesheet = _ref2.stylesheet,
|
|
110
|
+
_ref2$style = _ref2.style,
|
|
111
|
+
style = _ref2$style === void 0 ? {} : _ref2$style,
|
|
112
|
+
useInlineStyles = _ref2.useInlineStyles,
|
|
113
|
+
codeBidiWarningConfig = _ref2.codeBidiWarningConfig,
|
|
114
|
+
key = _ref2.key;
|
|
115
|
+
var properties = node.properties,
|
|
116
|
+
type = node.type,
|
|
117
|
+
TagName = node.tagName,
|
|
118
|
+
value = node.value;
|
|
119
|
+
|
|
120
|
+
if (type === 'text') {
|
|
121
|
+
// occasionally react-syntax-highlighter passes a numeric value when the
|
|
122
|
+
// type is text
|
|
123
|
+
var textValue = value + '';
|
|
124
|
+
var decorated = codeBidiWarningDecorator(textValue, function (_ref3) {
|
|
125
|
+
var bidiCharacter = _ref3.bidiCharacter,
|
|
126
|
+
index = _ref3.index;
|
|
127
|
+
return /*#__PURE__*/React.createElement(CodeBidiWarning, {
|
|
128
|
+
bidiCharacter: bidiCharacter,
|
|
129
|
+
key: index,
|
|
130
|
+
label: codeBidiWarningConfig.codeBidiWarningLabel,
|
|
131
|
+
tooltipEnabled: codeBidiWarningConfig.codeBidiWarningTooltipEnabled
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
return decorated;
|
|
135
|
+
} else if (TagName) {
|
|
136
|
+
var childrenCreator = createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig);
|
|
137
|
+
var props;
|
|
138
|
+
|
|
139
|
+
if (!useInlineStyles) {
|
|
140
|
+
props = _objectSpread(_objectSpread({}, properties), {}, {
|
|
141
|
+
className: createClassNameString(properties.className)
|
|
142
|
+
});
|
|
143
|
+
} else {
|
|
144
|
+
var allStylesheetSelectors = Object.keys(stylesheet).reduce(function (classes, selector) {
|
|
145
|
+
selector.split('.').forEach(function (className) {
|
|
146
|
+
if (!classes.includes(className)) {
|
|
147
|
+
classes.push(className);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
return classes;
|
|
151
|
+
}, []); // For compatibility with older versions of react-syntax-highlighter
|
|
152
|
+
|
|
153
|
+
var startingClassName = properties.className && properties.className.includes('token') ? ['token'] : [];
|
|
154
|
+
var className = properties.className && startingClassName.concat(properties.className.filter(function (className) {
|
|
155
|
+
return !allStylesheetSelectors.includes(className);
|
|
156
|
+
}));
|
|
157
|
+
props = _objectSpread(_objectSpread({}, properties), {}, {
|
|
158
|
+
className: createClassNameString(className) || undefined,
|
|
159
|
+
style: createStyleObject(properties.className, Object.assign({}, properties.style, style), stylesheet)
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
var children = childrenCreator(node.children);
|
|
164
|
+
return /*#__PURE__*/React.createElement(TagName, _extends({
|
|
165
|
+
key: key
|
|
166
|
+
}, props), children);
|
|
167
|
+
}
|
|
168
|
+
}
|
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ui';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare type CodeBidiWarningProps = {
|
|
2
|
+
/**
|
|
3
|
+
* A `testId` prop is provided for specified elements, which is a unique
|
|
4
|
+
* string that appears as a data attribute `data-testid` in the rendered code,
|
|
5
|
+
* serving as a hook for automated tests */
|
|
6
|
+
testId?: string;
|
|
7
|
+
/**
|
|
8
|
+
* A bidi character which can be used to perform a "bidi override attack".
|
|
9
|
+
*
|
|
10
|
+
* See the following document for details.
|
|
11
|
+
*
|
|
12
|
+
* https://hello.atlassian.net/wiki/spaces/PRODSEC/pages/1347434677/PSHELP-2943+Investigate+Trojan+Source+Attack+Vulnerability#1)-Providing-visual-cues-for-our-Customers-in-our-affected-products
|
|
13
|
+
*/
|
|
14
|
+
bidiCharacter: string;
|
|
15
|
+
/**
|
|
16
|
+
* Defaults to enabled (true)
|
|
17
|
+
*
|
|
18
|
+
* Intended to be disabled when used in a mobile view, such as in the editor
|
|
19
|
+
* via mobile bridge, where the tooltip could end up being cut off of otherwise
|
|
20
|
+
* not work as expected.
|
|
21
|
+
*/
|
|
22
|
+
tooltipEnabled?: boolean;
|
|
23
|
+
skipChildren?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Labels for the previous and next buttons used in pagination.
|
|
26
|
+
* Defaults to `Bidirectional characters change the order that text is rendered. This could be used to obscure malicious code.`.
|
|
27
|
+
*/
|
|
28
|
+
label?: string;
|
|
29
|
+
};
|
package/dist/types/code.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React from 'react';
|
|
2
3
|
import { getCodeStyles } from './internal/theme/styles';
|
|
3
4
|
import type { CodeProps } from './types';
|
|
4
|
-
declare const Code:
|
|
5
|
+
declare const Code: React.MemoExoticComponent<React.ForwardRefExoticComponent<Pick<CodeProps, "as" | "css" | "name" | "color" | "content" | "height" | "width" | "start" | "children" | "testId" | "default" | "cite" | "data" | "form" | "label" | "span" | "style" | "summary" | "title" | "pattern" | "accept" | "acceptCharset" | "action" | "allowFullScreen" | "allowTransparency" | "alt" | "async" | "autoComplete" | "autoFocus" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "checked" | "classID" | "cols" | "colSpan" | "controls" | "coords" | "crossOrigin" | "dateTime" | "defer" | "disabled" | "download" | "encType" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "frameBorder" | "headers" | "high" | "href" | "hrefLang" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "list" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "max" | "maxLength" | "media" | "mediaGroup" | "method" | "min" | "minLength" | "multiple" | "muted" | "nonce" | "noValidate" | "open" | "optimum" | "placeholder" | "playsInline" | "poster" | "preload" | "readOnly" | "rel" | "required" | "reversed" | "rows" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "selected" | "shape" | "size" | "sizes" | "src" | "srcDoc" | "srcLang" | "srcSet" | "step" | "target" | "type" | "useMap" | "value" | "wmode" | "wrap" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "slot" | "spellCheck" | "tabIndex" | "inputMode" | "is" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "key" | "codeBidiWarnings" | "codeBidiWarningLabel" | "codeBidiWarningTooltipEnabled"> & React.RefAttributes<HTMLElement>>>;
|
|
5
6
|
export { getCodeStyles };
|
|
6
7
|
export default Code;
|
|
@@ -34,6 +34,25 @@ export interface CodeBlockProps {
|
|
|
34
34
|
* Screen reader text for the end of a highlighted line
|
|
35
35
|
*/
|
|
36
36
|
highlightedEndText?: string;
|
|
37
|
+
/**
|
|
38
|
+
* When false, disables decorating code with bidi warnings
|
|
39
|
+
*
|
|
40
|
+
* defaults to true
|
|
41
|
+
*/
|
|
42
|
+
codeBidiWarnings?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Labels for the previous and next buttons used in pagination.
|
|
45
|
+
* Defaults to `Bidirectional characters change the order that text is rendered. This could be used to obscure malicious code.`.
|
|
46
|
+
*/
|
|
47
|
+
codeBidiWarningLabel?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Defaults to enabled (true)
|
|
50
|
+
*
|
|
51
|
+
* Intended to be disabled when used in a mobile view, such as in the editor
|
|
52
|
+
* via mobile bridge, where the tooltip could end up being cut off of otherwise
|
|
53
|
+
* not work as expected.
|
|
54
|
+
*/
|
|
55
|
+
codeBidiWarningTooltipEnabled?: boolean;
|
|
37
56
|
}
|
|
38
57
|
export type { SupportedLanguages, LanguageAlias, Language } from '../constants';
|
|
39
58
|
export type { CodeBlockTheme, CodeTheme } from './theme/types';
|
|
@@ -0,0 +1,9 @@
|
|
|
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 {};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -10,4 +10,23 @@ export interface CodeProps extends HTMLProps<HTMLElement> {
|
|
|
10
10
|
* Content to be rendered in the inline code block
|
|
11
11
|
*/
|
|
12
12
|
children?: ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* When false, disables decorating code with bidi warnings
|
|
15
|
+
*
|
|
16
|
+
* defaults to true
|
|
17
|
+
*/
|
|
18
|
+
codeBidiWarnings?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Labels for the previous and next buttons used in pagination.
|
|
21
|
+
* Defaults to `Bidirectional characters change the order that text is rendered. This could be used to obscure malicious code.`.
|
|
22
|
+
*/
|
|
23
|
+
codeBidiWarningLabel?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Defaults to enabled (true)
|
|
26
|
+
*
|
|
27
|
+
* Intended to be disabled when used in a mobile view, such as in the editor
|
|
28
|
+
* via mobile bridge, where the tooltip could end up being cut off of otherwise
|
|
29
|
+
* not work as expected.
|
|
30
|
+
*/
|
|
31
|
+
codeBidiWarningTooltipEnabled?: boolean;
|
|
13
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/code",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.3.2",
|
|
4
4
|
"description": "Code highlights short strings of code snippets inline with body text.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"atlaskit:src": "src/index.ts",
|
|
17
17
|
"atlassian": {
|
|
18
18
|
"team": "Design System Team",
|
|
19
|
-
"inPublicMirror": true,
|
|
20
19
|
"releaseModel": "scheduled",
|
|
21
20
|
"website": {
|
|
22
21
|
"name": "Code"
|
|
@@ -27,7 +26,8 @@
|
|
|
27
26
|
},
|
|
28
27
|
"dependencies": {
|
|
29
28
|
"@atlaskit/codemod-utils": "^3.4.0",
|
|
30
|
-
"@atlaskit/theme": "^12.
|
|
29
|
+
"@atlaskit/theme": "^12.1.0",
|
|
30
|
+
"@atlaskit/tooltip": "^17.5.0",
|
|
31
31
|
"@babel/runtime": "^7.0.0",
|
|
32
32
|
"@emotion/core": "^10.0.9",
|
|
33
33
|
"memoize-one": "^6.0.0",
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
"react": "^16.8.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@atlaskit/build-utils": "*",
|
|
41
40
|
"@atlaskit/button": "^16.0.0",
|
|
42
41
|
"@atlaskit/docs": "^9.0.0",
|
|
43
42
|
"@atlaskit/section-message": "^6.0.0",
|
|
@@ -49,7 +48,7 @@
|
|
|
49
48
|
"@types/react-syntax-highlighter": "^13.5.0",
|
|
50
49
|
"color-contrast-checker": "^1.5.0",
|
|
51
50
|
"jscodeshift": "^0.13.0",
|
|
52
|
-
"prismjs": "^1.
|
|
51
|
+
"prismjs": "^1.25.0",
|
|
53
52
|
"react-dom": "^16.8.0",
|
|
54
53
|
"typescript": "3.9.6"
|
|
55
54
|
},
|
|
@@ -61,6 +60,8 @@
|
|
|
61
60
|
"af:exports": {
|
|
62
61
|
"./types": "./src/entry-points/types.ts",
|
|
63
62
|
".": "./src/index.ts",
|
|
63
|
+
"./bidi-warning": "./src/bidi-warning/index.ts",
|
|
64
|
+
"./bidi-warning-decorator": "./src/bidi-warning/bidi-warning-decorator.tsx",
|
|
64
65
|
"./block": "./src/entry-points/block.ts",
|
|
65
66
|
"./inline": "./src/entry-points/inline.ts",
|
|
66
67
|
"./constants": "./src/entry-points/constants.ts"
|
|
@@ -77,10 +78,11 @@
|
|
|
77
78
|
"analytics-next"
|
|
78
79
|
],
|
|
79
80
|
"theming": [
|
|
80
|
-
"
|
|
81
|
+
"react-context"
|
|
81
82
|
],
|
|
82
|
-
"deprecation":
|
|
83
|
-
|
|
83
|
+
"deprecation": "no-deprecated-imports",
|
|
84
|
+
"styling": [
|
|
85
|
+
"emotion"
|
|
84
86
|
]
|
|
85
87
|
}
|
|
86
88
|
},
|