@atlaskit/code 14.2.0 → 14.3.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 +6 -0
- package/dist/cjs/bidi-warning/ui/index.js +21 -12
- package/dist/cjs/code-block.js +7 -2
- package/dist/cjs/code.js +11 -5
- package/dist/cjs/react-syntax-highlighter-bidi-warning-renderer.js +8 -13
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/bidi-warning/ui/index.js +20 -12
- package/dist/es2019/code-block.js +6 -2
- package/dist/es2019/code.js +9 -4
- package/dist/es2019/react-syntax-highlighter-bidi-warning-renderer.js +8 -7
- package/dist/es2019/version.json +1 -1
- package/dist/esm/bidi-warning/ui/index.js +21 -12
- package/dist/esm/code-block.js +7 -2
- package/dist/esm/code.js +11 -5
- package/dist/esm/react-syntax-highlighter-bidi-warning-renderer.js +8 -7
- package/dist/esm/version.json +1 -1
- package/dist/types/bidi-warning/ui/index.d.ts +1 -1
- package/dist/types/bidi-warning/ui/types.d.ts +8 -0
- package/dist/types/code.d.ts +1 -1
- package/dist/types/internal/types.d.ts +8 -0
- package/dist/types/react-syntax-highlighter-bidi-warning-renderer.d.ts +7 -2
- package/dist/types/types.d.ts +8 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/code
|
|
2
2
|
|
|
3
|
+
## 14.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`db3477abb18`](https://bitbucket.org/atlassian/atlassian-frontend/commits/db3477abb18) - [ux] ED-13938 disabled code-bidi warning tooltip for mobile, reworked TextWrapper to fix bidi mitigation, and fixed issue where bidi warnings were not presented when renderer used with an annotation provider with draftMode set to true
|
|
8
|
+
|
|
3
9
|
## 14.2.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -21,20 +21,29 @@ function BidiWarning(_ref) {
|
|
|
21
21
|
var testId = _ref.testId,
|
|
22
22
|
bidiCharacter = _ref.bidiCharacter,
|
|
23
23
|
skipChildren = _ref.skipChildren,
|
|
24
|
+
tooltipEnabled = _ref.tooltipEnabled,
|
|
24
25
|
_ref$label = _ref.label,
|
|
25
26
|
label = _ref$label === void 0 ? 'Bidirectional characters change the order that text is rendered. This could be used to obscure malicious code.' : _ref$label;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
|
|
28
|
+
if (tooltipEnabled) {
|
|
29
|
+
return (
|
|
30
|
+
/*#__PURE__*/
|
|
31
|
+
// Following patches, this should be updated to use the render props signature which will provide aria attributes.
|
|
32
|
+
// Note: this should be tested, as initial testing did not see attributes work with current tooltip implementation.
|
|
33
|
+
_react.default.createElement(_tooltip.default, {
|
|
34
|
+
content: label,
|
|
35
|
+
tag: CustomizedTagWithRef
|
|
36
|
+
}, /*#__PURE__*/_react.default.createElement(_styled.Decorator, {
|
|
37
|
+
testId: testId,
|
|
38
|
+
bidiCharacter: bidiCharacter
|
|
39
|
+
}, skipChildren ? null : bidiCharacter))
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return /*#__PURE__*/_react.default.createElement(_styled.Decorator, {
|
|
44
|
+
testId: testId,
|
|
45
|
+
bidiCharacter: bidiCharacter
|
|
46
|
+
}, skipChildren ? null : bidiCharacter);
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
var CustomizedTagWithRef = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
package/dist/cjs/code-block.js
CHANGED
|
@@ -37,7 +37,9 @@ var CodeBlock = /*#__PURE__*/(0, _react.memo)(function CodeBlock(_ref) {
|
|
|
37
37
|
text = _ref.text,
|
|
38
38
|
_ref$codeBidiWarnings = _ref.codeBidiWarnings,
|
|
39
39
|
codeBidiWarnings = _ref$codeBidiWarnings === void 0 ? true : _ref$codeBidiWarnings,
|
|
40
|
-
codeBidiWarningLabel = _ref.codeBidiWarningLabel
|
|
40
|
+
codeBidiWarningLabel = _ref.codeBidiWarningLabel,
|
|
41
|
+
_ref$codeBidiWarningT = _ref.codeBidiWarningTooltipEnabled,
|
|
42
|
+
codeBidiWarningTooltipEnabled = _ref$codeBidiWarningT === void 0 ? true : _ref$codeBidiWarningT;
|
|
41
43
|
var numLines = (text || '').split('\n').length;
|
|
42
44
|
var globalTheme = (0, _components.useGlobalTheme)();
|
|
43
45
|
var theme = (0, _react.useMemo)(function () {
|
|
@@ -65,7 +67,10 @@ var CodeBlock = /*#__PURE__*/(0, _react.memo)(function CodeBlock(_ref) {
|
|
|
65
67
|
}, [providedLanguage]); // https://product-fabric.atlassian.net/browse/DST-2472
|
|
66
68
|
|
|
67
69
|
var languageToUse = text ? language : 'text';
|
|
68
|
-
var renderer = codeBidiWarnings ? (0, _reactSyntaxHighlighterBidiWarningRenderer.createBidiWarningRenderer)(
|
|
70
|
+
var renderer = codeBidiWarnings ? (0, _reactSyntaxHighlighterBidiWarningRenderer.createBidiWarningRenderer)({
|
|
71
|
+
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
72
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
73
|
+
}) : undefined;
|
|
69
74
|
return (0, _core.jsx)(_reactSyntaxHighlighter.PrismAsync, {
|
|
70
75
|
"data-testid": testId,
|
|
71
76
|
"data-code-lang": language,
|
package/dist/cjs/code.js
CHANGED
|
@@ -47,9 +47,12 @@ var Code = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
47
47
|
_props$codeBidiWarnin = props.codeBidiWarnings,
|
|
48
48
|
codeBidiWarnings = _props$codeBidiWarnin === void 0 ? true : _props$codeBidiWarnin,
|
|
49
49
|
codeBidiWarningLabel = props.codeBidiWarningLabel,
|
|
50
|
-
|
|
50
|
+
_props$codeBidiWarnin2 = props.codeBidiWarningTooltipEnabled,
|
|
51
|
+
codeBidiWarningTooltipEnabled = _props$codeBidiWarnin2 === void 0 ? true : _props$codeBidiWarnin2,
|
|
52
|
+
otherProps = (0, _objectWithoutProperties2.default)(props, ["children", "codeBidiWarnings", "codeBidiWarningLabel", "codeBidiWarningTooltipEnabled"]);
|
|
51
53
|
var decoratedChildren = codeBidiWarnings ? (0, _core.jsx)(RenderCodeChildrenWithBidiWarnings, {
|
|
52
|
-
codeBidiWarningLabel: codeBidiWarningLabel
|
|
54
|
+
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
55
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
53
56
|
}, children) : children;
|
|
54
57
|
return (0, _core.jsx)("code", (0, _extends2.default)({
|
|
55
58
|
ref: ref,
|
|
@@ -60,7 +63,8 @@ var Code = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(fu
|
|
|
60
63
|
|
|
61
64
|
function RenderCodeChildrenWithBidiWarnings(_ref2) {
|
|
62
65
|
var children = _ref2.children,
|
|
63
|
-
codeBidiWarningLabel = _ref2.codeBidiWarningLabel
|
|
66
|
+
codeBidiWarningLabel = _ref2.codeBidiWarningLabel,
|
|
67
|
+
codeBidiWarningTooltipEnabled = _ref2.codeBidiWarningTooltipEnabled;
|
|
64
68
|
|
|
65
69
|
var replacedChildren = _react.default.Children.map(children, function (childNode) {
|
|
66
70
|
if (typeof childNode === 'string') {
|
|
@@ -70,7 +74,8 @@ function RenderCodeChildrenWithBidiWarnings(_ref2) {
|
|
|
70
74
|
return (0, _core.jsx)(_bidiWarning.default, {
|
|
71
75
|
bidiCharacter: bidiCharacter,
|
|
72
76
|
key: index,
|
|
73
|
-
label: codeBidiWarningLabel
|
|
77
|
+
label: codeBidiWarningLabel,
|
|
78
|
+
tooltipEnabled: codeBidiWarningTooltipEnabled
|
|
74
79
|
});
|
|
75
80
|
});
|
|
76
81
|
return decorated;
|
|
@@ -79,7 +84,8 @@ function RenderCodeChildrenWithBidiWarnings(_ref2) {
|
|
|
79
84
|
if (isReactElement(childNode) && childNode.props.children) {
|
|
80
85
|
var newChildNode = /*#__PURE__*/_react.default.cloneElement(childNode, {
|
|
81
86
|
children: (0, _core.jsx)(RenderCodeChildrenWithBidiWarnings, {
|
|
82
|
-
codeBidiWarningLabel: codeBidiWarningLabel
|
|
87
|
+
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
88
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
83
89
|
}, childNode.props.children)
|
|
84
90
|
});
|
|
85
91
|
|
|
@@ -24,13 +24,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
24
24
|
|
|
25
25
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
// - https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/efc3f7b7537d1729193b7a472067bcbe6cbecaf1/src/highlight.js#L272-L281
|
|
30
|
-
// - https://github.com/react-syntax-highlighter/react-syntax-highlighter/blob/efc3f7b7537d1729193b7a472067bcbe6cbecaf1/src/create-element.js
|
|
31
|
-
//
|
|
32
|
-
// Patching react syntax-highlighter with a decoration feature is likely preferable
|
|
33
|
-
function createBidiWarningRenderer(codeBidiWarningLabel) {
|
|
27
|
+
function createBidiWarningRenderer(codeBidiWarningConfig) {
|
|
34
28
|
return function bidiWarningRenderer(_ref) {
|
|
35
29
|
var rows = _ref.rows,
|
|
36
30
|
stylesheet = _ref.stylesheet,
|
|
@@ -40,7 +34,7 @@ function createBidiWarningRenderer(codeBidiWarningLabel) {
|
|
|
40
34
|
node: node,
|
|
41
35
|
stylesheet: stylesheet,
|
|
42
36
|
useInlineStyles: useInlineStyles,
|
|
43
|
-
|
|
37
|
+
codeBidiWarningConfig: codeBidiWarningConfig,
|
|
44
38
|
key: "code-segement".concat(i)
|
|
45
39
|
});
|
|
46
40
|
});
|
|
@@ -106,7 +100,7 @@ function createClassNameString(classNames) {
|
|
|
106
100
|
return classNames.join(' ');
|
|
107
101
|
}
|
|
108
102
|
|
|
109
|
-
function createChildren(stylesheet, useInlineStyles,
|
|
103
|
+
function createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig) {
|
|
110
104
|
var childrenCount = 0;
|
|
111
105
|
return function (children) {
|
|
112
106
|
childrenCount += 1;
|
|
@@ -115,7 +109,7 @@ function createChildren(stylesheet, useInlineStyles, codeBidiWarningLabel) {
|
|
|
115
109
|
node: child,
|
|
116
110
|
stylesheet: stylesheet,
|
|
117
111
|
useInlineStyles: useInlineStyles,
|
|
118
|
-
|
|
112
|
+
codeBidiWarningConfig: codeBidiWarningConfig,
|
|
119
113
|
key: "code-segment-".concat(childrenCount, "-").concat(i)
|
|
120
114
|
});
|
|
121
115
|
});
|
|
@@ -128,7 +122,7 @@ function createElement(_ref2) {
|
|
|
128
122
|
_ref2$style = _ref2.style,
|
|
129
123
|
style = _ref2$style === void 0 ? {} : _ref2$style,
|
|
130
124
|
useInlineStyles = _ref2.useInlineStyles,
|
|
131
|
-
|
|
125
|
+
codeBidiWarningConfig = _ref2.codeBidiWarningConfig,
|
|
132
126
|
key = _ref2.key;
|
|
133
127
|
var properties = node.properties,
|
|
134
128
|
type = node.type,
|
|
@@ -145,12 +139,13 @@ function createElement(_ref2) {
|
|
|
145
139
|
return /*#__PURE__*/_react.default.createElement(_bidiWarning.default, {
|
|
146
140
|
bidiCharacter: bidiCharacter,
|
|
147
141
|
key: index,
|
|
148
|
-
label: codeBidiWarningLabel
|
|
142
|
+
label: codeBidiWarningConfig.codeBidiWarningLabel,
|
|
143
|
+
tooltipEnabled: codeBidiWarningConfig.codeBidiWarningTooltipEnabled
|
|
149
144
|
});
|
|
150
145
|
});
|
|
151
146
|
return decorated;
|
|
152
147
|
} else if (TagName) {
|
|
153
|
-
var childrenCreator = createChildren(stylesheet, useInlineStyles,
|
|
148
|
+
var childrenCreator = createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig);
|
|
154
149
|
var props;
|
|
155
150
|
|
|
156
151
|
if (!useInlineStyles) {
|
package/dist/cjs/version.json
CHANGED
|
@@ -6,20 +6,28 @@ export default function BidiWarning({
|
|
|
6
6
|
testId,
|
|
7
7
|
bidiCharacter,
|
|
8
8
|
skipChildren,
|
|
9
|
+
tooltipEnabled,
|
|
9
10
|
label = 'Bidirectional characters change the order that text is rendered. This could be used to obscure malicious code.'
|
|
10
11
|
}) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
if (tooltipEnabled) {
|
|
13
|
+
return (
|
|
14
|
+
/*#__PURE__*/
|
|
15
|
+
// Following patches, this should be updated to use the render props signature which will provide aria attributes.
|
|
16
|
+
// Note: this should be tested, as initial testing did not see attributes work with current tooltip implementation.
|
|
17
|
+
React.createElement(Tooltip, {
|
|
18
|
+
content: label,
|
|
19
|
+
tag: CustomizedTagWithRef
|
|
20
|
+
}, /*#__PURE__*/React.createElement(Decorator, {
|
|
21
|
+
testId: testId,
|
|
22
|
+
bidiCharacter: bidiCharacter
|
|
23
|
+
}, skipChildren ? null : bidiCharacter))
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return /*#__PURE__*/React.createElement(Decorator, {
|
|
28
|
+
testId: testId,
|
|
29
|
+
bidiCharacter: bidiCharacter
|
|
30
|
+
}, skipChildren ? null : bidiCharacter);
|
|
23
31
|
}
|
|
24
32
|
const CustomizedTagWithRef = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
25
33
|
const {
|
|
@@ -16,7 +16,8 @@ const CodeBlock = /*#__PURE__*/memo(function CodeBlock({
|
|
|
16
16
|
testId,
|
|
17
17
|
text,
|
|
18
18
|
codeBidiWarnings = true,
|
|
19
|
-
codeBidiWarningLabel
|
|
19
|
+
codeBidiWarningLabel,
|
|
20
|
+
codeBidiWarningTooltipEnabled = true
|
|
20
21
|
}) {
|
|
21
22
|
const numLines = (text || '').split('\n').length;
|
|
22
23
|
const globalTheme = useGlobalTheme();
|
|
@@ -34,7 +35,10 @@ const CodeBlock = /*#__PURE__*/memo(function CodeBlock({
|
|
|
34
35
|
const language = useMemo(() => normalizeLanguage(providedLanguage), [providedLanguage]); // https://product-fabric.atlassian.net/browse/DST-2472
|
|
35
36
|
|
|
36
37
|
const languageToUse = text ? language : 'text';
|
|
37
|
-
const renderer = codeBidiWarnings ? createBidiWarningRenderer(
|
|
38
|
+
const renderer = codeBidiWarnings ? createBidiWarningRenderer({
|
|
39
|
+
codeBidiWarningLabel,
|
|
40
|
+
codeBidiWarningTooltipEnabled
|
|
41
|
+
}) : undefined;
|
|
38
42
|
return jsx(SyntaxHighlighter, {
|
|
39
43
|
"data-testid": testId,
|
|
40
44
|
"data-code-lang": language,
|
package/dist/es2019/code.js
CHANGED
|
@@ -17,10 +17,12 @@ const Code = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Code({
|
|
|
17
17
|
children,
|
|
18
18
|
codeBidiWarnings = true,
|
|
19
19
|
codeBidiWarningLabel,
|
|
20
|
+
codeBidiWarningTooltipEnabled = true,
|
|
20
21
|
...otherProps
|
|
21
22
|
} = props;
|
|
22
23
|
const decoratedChildren = codeBidiWarnings ? jsx(RenderCodeChildrenWithBidiWarnings, {
|
|
23
|
-
codeBidiWarningLabel: codeBidiWarningLabel
|
|
24
|
+
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
25
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
24
26
|
}, children) : children;
|
|
25
27
|
return jsx("code", _extends({
|
|
26
28
|
ref: ref,
|
|
@@ -31,7 +33,8 @@ const Code = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Code({
|
|
|
31
33
|
|
|
32
34
|
function RenderCodeChildrenWithBidiWarnings({
|
|
33
35
|
children,
|
|
34
|
-
codeBidiWarningLabel
|
|
36
|
+
codeBidiWarningLabel,
|
|
37
|
+
codeBidiWarningTooltipEnabled
|
|
35
38
|
}) {
|
|
36
39
|
const replacedChildren = React.Children.map(children, childNode => {
|
|
37
40
|
if (typeof childNode === 'string') {
|
|
@@ -41,7 +44,8 @@ function RenderCodeChildrenWithBidiWarnings({
|
|
|
41
44
|
}) => jsx(CodeBidiWarning, {
|
|
42
45
|
bidiCharacter: bidiCharacter,
|
|
43
46
|
key: index,
|
|
44
|
-
label: codeBidiWarningLabel
|
|
47
|
+
label: codeBidiWarningLabel,
|
|
48
|
+
tooltipEnabled: codeBidiWarningTooltipEnabled
|
|
45
49
|
}));
|
|
46
50
|
return decorated;
|
|
47
51
|
}
|
|
@@ -49,7 +53,8 @@ function RenderCodeChildrenWithBidiWarnings({
|
|
|
49
53
|
if (isReactElement(childNode) && childNode.props.children) {
|
|
50
54
|
const newChildNode = /*#__PURE__*/React.cloneElement(childNode, {
|
|
51
55
|
children: jsx(RenderCodeChildrenWithBidiWarnings, {
|
|
52
|
-
codeBidiWarningLabel: codeBidiWarningLabel
|
|
56
|
+
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
57
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
53
58
|
}, childNode.props.children)
|
|
54
59
|
});
|
|
55
60
|
return newChildNode;
|
|
@@ -9,7 +9,7 @@ import codeBidiWarningDecorator from './bidi-warning/bidi-warning-decorator'; //
|
|
|
9
9
|
//
|
|
10
10
|
// Patching react syntax-highlighter with a decoration feature is likely preferable
|
|
11
11
|
|
|
12
|
-
export function createBidiWarningRenderer(
|
|
12
|
+
export function createBidiWarningRenderer(codeBidiWarningConfig) {
|
|
13
13
|
return function bidiWarningRenderer({
|
|
14
14
|
rows,
|
|
15
15
|
stylesheet,
|
|
@@ -19,7 +19,7 @@ export function createBidiWarningRenderer(codeBidiWarningLabel) {
|
|
|
19
19
|
node,
|
|
20
20
|
stylesheet,
|
|
21
21
|
useInlineStyles,
|
|
22
|
-
|
|
22
|
+
codeBidiWarningConfig,
|
|
23
23
|
key: `code-segement${i}`
|
|
24
24
|
}));
|
|
25
25
|
};
|
|
@@ -79,7 +79,7 @@ export function createStyleObject(classNames, elementStyle = {}, stylesheet) {
|
|
|
79
79
|
export function createClassNameString(classNames) {
|
|
80
80
|
return classNames.join(' ');
|
|
81
81
|
}
|
|
82
|
-
export function createChildren(stylesheet, useInlineStyles,
|
|
82
|
+
export function createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig) {
|
|
83
83
|
let childrenCount = 0;
|
|
84
84
|
return children => {
|
|
85
85
|
childrenCount += 1;
|
|
@@ -87,7 +87,7 @@ export function createChildren(stylesheet, useInlineStyles, codeBidiWarningLabel
|
|
|
87
87
|
node: child,
|
|
88
88
|
stylesheet,
|
|
89
89
|
useInlineStyles,
|
|
90
|
-
|
|
90
|
+
codeBidiWarningConfig,
|
|
91
91
|
key: `code-segment-${childrenCount}-${i}`
|
|
92
92
|
}));
|
|
93
93
|
};
|
|
@@ -98,7 +98,7 @@ function createElement({
|
|
|
98
98
|
stylesheet,
|
|
99
99
|
style = {},
|
|
100
100
|
useInlineStyles,
|
|
101
|
-
|
|
101
|
+
codeBidiWarningConfig,
|
|
102
102
|
key
|
|
103
103
|
}) {
|
|
104
104
|
const {
|
|
@@ -118,11 +118,12 @@ function createElement({
|
|
|
118
118
|
}) => /*#__PURE__*/React.createElement(CodeBidiWarning, {
|
|
119
119
|
bidiCharacter: bidiCharacter,
|
|
120
120
|
key: index,
|
|
121
|
-
label: codeBidiWarningLabel
|
|
121
|
+
label: codeBidiWarningConfig.codeBidiWarningLabel,
|
|
122
|
+
tooltipEnabled: codeBidiWarningConfig.codeBidiWarningTooltipEnabled
|
|
122
123
|
}));
|
|
123
124
|
return decorated;
|
|
124
125
|
} else if (TagName) {
|
|
125
|
-
const childrenCreator = createChildren(stylesheet, useInlineStyles,
|
|
126
|
+
const childrenCreator = createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig);
|
|
126
127
|
let props;
|
|
127
128
|
|
|
128
129
|
if (!useInlineStyles) {
|
package/dist/es2019/version.json
CHANGED
|
@@ -7,20 +7,29 @@ export default function BidiWarning(_ref) {
|
|
|
7
7
|
var testId = _ref.testId,
|
|
8
8
|
bidiCharacter = _ref.bidiCharacter,
|
|
9
9
|
skipChildren = _ref.skipChildren,
|
|
10
|
+
tooltipEnabled = _ref.tooltipEnabled,
|
|
10
11
|
_ref$label = _ref.label,
|
|
11
12
|
label = _ref$label === void 0 ? 'Bidirectional characters change the order that text is rendered. This could be used to obscure malicious code.' : _ref$label;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
|
|
14
|
+
if (tooltipEnabled) {
|
|
15
|
+
return (
|
|
16
|
+
/*#__PURE__*/
|
|
17
|
+
// Following patches, this should be updated to use the render props signature which will provide aria attributes.
|
|
18
|
+
// Note: this should be tested, as initial testing did not see attributes work with current tooltip implementation.
|
|
19
|
+
React.createElement(Tooltip, {
|
|
20
|
+
content: label,
|
|
21
|
+
tag: CustomizedTagWithRef
|
|
22
|
+
}, /*#__PURE__*/React.createElement(Decorator, {
|
|
23
|
+
testId: testId,
|
|
24
|
+
bidiCharacter: bidiCharacter
|
|
25
|
+
}, skipChildren ? null : bidiCharacter))
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return /*#__PURE__*/React.createElement(Decorator, {
|
|
30
|
+
testId: testId,
|
|
31
|
+
bidiCharacter: bidiCharacter
|
|
32
|
+
}, skipChildren ? null : bidiCharacter);
|
|
24
33
|
}
|
|
25
34
|
var CustomizedTagWithRef = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
26
35
|
var children = props.children,
|
package/dist/esm/code-block.js
CHANGED
|
@@ -22,7 +22,9 @@ var CodeBlock = /*#__PURE__*/memo(function CodeBlock(_ref) {
|
|
|
22
22
|
text = _ref.text,
|
|
23
23
|
_ref$codeBidiWarnings = _ref.codeBidiWarnings,
|
|
24
24
|
codeBidiWarnings = _ref$codeBidiWarnings === void 0 ? true : _ref$codeBidiWarnings,
|
|
25
|
-
codeBidiWarningLabel = _ref.codeBidiWarningLabel
|
|
25
|
+
codeBidiWarningLabel = _ref.codeBidiWarningLabel,
|
|
26
|
+
_ref$codeBidiWarningT = _ref.codeBidiWarningTooltipEnabled,
|
|
27
|
+
codeBidiWarningTooltipEnabled = _ref$codeBidiWarningT === void 0 ? true : _ref$codeBidiWarningT;
|
|
26
28
|
var numLines = (text || '').split('\n').length;
|
|
27
29
|
var globalTheme = useGlobalTheme();
|
|
28
30
|
var theme = useMemo(function () {
|
|
@@ -50,7 +52,10 @@ var CodeBlock = /*#__PURE__*/memo(function CodeBlock(_ref) {
|
|
|
50
52
|
}, [providedLanguage]); // https://product-fabric.atlassian.net/browse/DST-2472
|
|
51
53
|
|
|
52
54
|
var languageToUse = text ? language : 'text';
|
|
53
|
-
var renderer = codeBidiWarnings ? createBidiWarningRenderer(
|
|
55
|
+
var renderer = codeBidiWarnings ? createBidiWarningRenderer({
|
|
56
|
+
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
57
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
58
|
+
}) : undefined;
|
|
54
59
|
return jsx(SyntaxHighlighter, {
|
|
55
60
|
"data-testid": testId,
|
|
56
61
|
"data-code-lang": language,
|
package/dist/esm/code.js
CHANGED
|
@@ -21,10 +21,13 @@ var Code = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Code(_ref, ref) {
|
|
|
21
21
|
_props$codeBidiWarnin = props.codeBidiWarnings,
|
|
22
22
|
codeBidiWarnings = _props$codeBidiWarnin === void 0 ? true : _props$codeBidiWarnin,
|
|
23
23
|
codeBidiWarningLabel = props.codeBidiWarningLabel,
|
|
24
|
-
|
|
24
|
+
_props$codeBidiWarnin2 = props.codeBidiWarningTooltipEnabled,
|
|
25
|
+
codeBidiWarningTooltipEnabled = _props$codeBidiWarnin2 === void 0 ? true : _props$codeBidiWarnin2,
|
|
26
|
+
otherProps = _objectWithoutProperties(props, ["children", "codeBidiWarnings", "codeBidiWarningLabel", "codeBidiWarningTooltipEnabled"]);
|
|
25
27
|
|
|
26
28
|
var decoratedChildren = codeBidiWarnings ? jsx(RenderCodeChildrenWithBidiWarnings, {
|
|
27
|
-
codeBidiWarningLabel: codeBidiWarningLabel
|
|
29
|
+
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
30
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
28
31
|
}, children) : children;
|
|
29
32
|
return jsx("code", _extends({
|
|
30
33
|
ref: ref,
|
|
@@ -35,7 +38,8 @@ var Code = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Code(_ref, ref) {
|
|
|
35
38
|
|
|
36
39
|
function RenderCodeChildrenWithBidiWarnings(_ref2) {
|
|
37
40
|
var children = _ref2.children,
|
|
38
|
-
codeBidiWarningLabel = _ref2.codeBidiWarningLabel
|
|
41
|
+
codeBidiWarningLabel = _ref2.codeBidiWarningLabel,
|
|
42
|
+
codeBidiWarningTooltipEnabled = _ref2.codeBidiWarningTooltipEnabled;
|
|
39
43
|
var replacedChildren = React.Children.map(children, function (childNode) {
|
|
40
44
|
if (typeof childNode === 'string') {
|
|
41
45
|
var decorated = codeBidiWarningDecorator(childNode, function (_ref3) {
|
|
@@ -44,7 +48,8 @@ function RenderCodeChildrenWithBidiWarnings(_ref2) {
|
|
|
44
48
|
return jsx(CodeBidiWarning, {
|
|
45
49
|
bidiCharacter: bidiCharacter,
|
|
46
50
|
key: index,
|
|
47
|
-
label: codeBidiWarningLabel
|
|
51
|
+
label: codeBidiWarningLabel,
|
|
52
|
+
tooltipEnabled: codeBidiWarningTooltipEnabled
|
|
48
53
|
});
|
|
49
54
|
});
|
|
50
55
|
return decorated;
|
|
@@ -53,7 +58,8 @@ function RenderCodeChildrenWithBidiWarnings(_ref2) {
|
|
|
53
58
|
if (isReactElement(childNode) && childNode.props.children) {
|
|
54
59
|
var newChildNode = /*#__PURE__*/React.cloneElement(childNode, {
|
|
55
60
|
children: jsx(RenderCodeChildrenWithBidiWarnings, {
|
|
56
|
-
codeBidiWarningLabel: codeBidiWarningLabel
|
|
61
|
+
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
62
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
57
63
|
}, childNode.props.children)
|
|
58
64
|
});
|
|
59
65
|
return newChildNode;
|
|
@@ -15,7 +15,7 @@ import codeBidiWarningDecorator from './bidi-warning/bidi-warning-decorator'; //
|
|
|
15
15
|
//
|
|
16
16
|
// Patching react syntax-highlighter with a decoration feature is likely preferable
|
|
17
17
|
|
|
18
|
-
export function createBidiWarningRenderer(
|
|
18
|
+
export function createBidiWarningRenderer(codeBidiWarningConfig) {
|
|
19
19
|
return function bidiWarningRenderer(_ref) {
|
|
20
20
|
var rows = _ref.rows,
|
|
21
21
|
stylesheet = _ref.stylesheet,
|
|
@@ -25,7 +25,7 @@ export function createBidiWarningRenderer(codeBidiWarningLabel) {
|
|
|
25
25
|
node: node,
|
|
26
26
|
stylesheet: stylesheet,
|
|
27
27
|
useInlineStyles: useInlineStyles,
|
|
28
|
-
|
|
28
|
+
codeBidiWarningConfig: codeBidiWarningConfig,
|
|
29
29
|
key: "code-segement".concat(i)
|
|
30
30
|
});
|
|
31
31
|
});
|
|
@@ -88,7 +88,7 @@ export function createStyleObject(classNames) {
|
|
|
88
88
|
export function createClassNameString(classNames) {
|
|
89
89
|
return classNames.join(' ');
|
|
90
90
|
}
|
|
91
|
-
export function createChildren(stylesheet, useInlineStyles,
|
|
91
|
+
export function createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig) {
|
|
92
92
|
var childrenCount = 0;
|
|
93
93
|
return function (children) {
|
|
94
94
|
childrenCount += 1;
|
|
@@ -97,7 +97,7 @@ export function createChildren(stylesheet, useInlineStyles, codeBidiWarningLabel
|
|
|
97
97
|
node: child,
|
|
98
98
|
stylesheet: stylesheet,
|
|
99
99
|
useInlineStyles: useInlineStyles,
|
|
100
|
-
|
|
100
|
+
codeBidiWarningConfig: codeBidiWarningConfig,
|
|
101
101
|
key: "code-segment-".concat(childrenCount, "-").concat(i)
|
|
102
102
|
});
|
|
103
103
|
});
|
|
@@ -110,7 +110,7 @@ function createElement(_ref2) {
|
|
|
110
110
|
_ref2$style = _ref2.style,
|
|
111
111
|
style = _ref2$style === void 0 ? {} : _ref2$style,
|
|
112
112
|
useInlineStyles = _ref2.useInlineStyles,
|
|
113
|
-
|
|
113
|
+
codeBidiWarningConfig = _ref2.codeBidiWarningConfig,
|
|
114
114
|
key = _ref2.key;
|
|
115
115
|
var properties = node.properties,
|
|
116
116
|
type = node.type,
|
|
@@ -127,12 +127,13 @@ function createElement(_ref2) {
|
|
|
127
127
|
return /*#__PURE__*/React.createElement(CodeBidiWarning, {
|
|
128
128
|
bidiCharacter: bidiCharacter,
|
|
129
129
|
key: index,
|
|
130
|
-
label: codeBidiWarningLabel
|
|
130
|
+
label: codeBidiWarningConfig.codeBidiWarningLabel,
|
|
131
|
+
tooltipEnabled: codeBidiWarningConfig.codeBidiWarningTooltipEnabled
|
|
131
132
|
});
|
|
132
133
|
});
|
|
133
134
|
return decorated;
|
|
134
135
|
} else if (TagName) {
|
|
135
|
-
var childrenCreator = createChildren(stylesheet, useInlineStyles,
|
|
136
|
+
var childrenCreator = createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig);
|
|
136
137
|
var props;
|
|
137
138
|
|
|
138
139
|
if (!useInlineStyles) {
|
package/dist/esm/version.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { CodeBidiWarningProps } from './types';
|
|
2
|
-
export default function BidiWarning({ testId, bidiCharacter, skipChildren, label, }: CodeBidiWarningProps): JSX.Element;
|
|
2
|
+
export default function BidiWarning({ testId, bidiCharacter, skipChildren, tooltipEnabled, label, }: CodeBidiWarningProps): JSX.Element;
|
|
@@ -12,6 +12,14 @@ export declare type CodeBidiWarningProps = {
|
|
|
12
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
13
|
*/
|
|
14
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;
|
|
15
23
|
skipChildren?: boolean;
|
|
16
24
|
/**
|
|
17
25
|
* Labels for the previous and next buttons used in pagination.
|
package/dist/types/code.d.ts
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { getCodeStyles } from './internal/theme/styles';
|
|
4
4
|
import type { CodeProps } from './types';
|
|
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"> & React.RefAttributes<HTMLElement>>>;
|
|
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>>>;
|
|
6
6
|
export { getCodeStyles };
|
|
7
7
|
export default Code;
|
|
@@ -45,6 +45,14 @@ export interface CodeBlockProps {
|
|
|
45
45
|
* Defaults to `Bidirectional characters change the order that text is rendered. This could be used to obscure malicious code.`.
|
|
46
46
|
*/
|
|
47
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;
|
|
48
56
|
}
|
|
49
57
|
export type { SupportedLanguages, LanguageAlias, Language } from '../constants';
|
|
50
58
|
export type { CodeBlockTheme, CodeTheme } from './theme/types';
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
declare type CodeBidiWarningConfig = {
|
|
2
|
+
codeBidiWarningLabel?: string;
|
|
3
|
+
codeBidiWarningTooltipEnabled: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare function createBidiWarningRenderer(codeBidiWarningConfig: CodeBidiWarningConfig): ({ rows, stylesheet, useInlineStyles, }: any) => any;
|
|
2
6
|
export declare function createStyleObject(classNames: any, elementStyle: {} | undefined, stylesheet: any): any;
|
|
3
7
|
export declare function createClassNameString(classNames: any): any;
|
|
4
|
-
export declare function createChildren(stylesheet: any, useInlineStyles: any,
|
|
8
|
+
export declare function createChildren(stylesheet: any, useInlineStyles: any, codeBidiWarningConfig: any): (children: any) => any;
|
|
9
|
+
export {};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -21,4 +21,12 @@ export interface CodeProps extends HTMLProps<HTMLElement> {
|
|
|
21
21
|
* Defaults to `Bidirectional characters change the order that text is rendered. This could be used to obscure malicious code.`.
|
|
22
22
|
*/
|
|
23
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;
|
|
24
32
|
}
|