@atlaskit/code 14.1.2 → 14.2.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/bidi-warning/package.json +7 -0
  3. package/bidi-warning-decorator/package.json +7 -0
  4. package/dist/cjs/bidi-warning/bidi-warning-decorator.js +73 -0
  5. package/dist/cjs/bidi-warning/index.js +15 -0
  6. package/dist/cjs/bidi-warning/ui/index.js +46 -0
  7. package/dist/cjs/bidi-warning/ui/styled.js +74 -0
  8. package/dist/cjs/bidi-warning/ui/types.js +5 -0
  9. package/dist/cjs/code-block.js +9 -2
  10. package/dist/cjs/code.js +59 -2
  11. package/dist/cjs/internal/hooks/use-highlight.js +1 -2
  12. package/dist/cjs/react-syntax-highlighter-bidi-warning-renderer.js +185 -0
  13. package/dist/cjs/version.json +1 -1
  14. package/dist/es2019/bidi-warning/bidi-warning-decorator.js +42 -0
  15. package/dist/es2019/bidi-warning/index.js +1 -0
  16. package/dist/es2019/bidi-warning/ui/index.js +32 -0
  17. package/dist/es2019/bidi-warning/ui/styled.js +65 -0
  18. package/dist/es2019/bidi-warning/ui/types.js +1 -0
  19. package/dist/es2019/code-block.js +7 -2
  20. package/dist/es2019/code.js +49 -2
  21. package/dist/es2019/react-syntax-highlighter-bidi-warning-renderer.js +155 -0
  22. package/dist/es2019/version.json +1 -1
  23. package/dist/esm/bidi-warning/bidi-warning-decorator.js +61 -0
  24. package/dist/esm/bidi-warning/index.js +1 -0
  25. package/dist/esm/bidi-warning/ui/index.js +32 -0
  26. package/dist/esm/bidi-warning/ui/styled.js +64 -0
  27. package/dist/esm/bidi-warning/ui/types.js +1 -0
  28. package/dist/esm/code-block.js +8 -2
  29. package/dist/esm/code.js +50 -2
  30. package/dist/esm/internal/hooks/use-highlight.js +1 -2
  31. package/dist/esm/react-syntax-highlighter-bidi-warning-renderer.js +167 -0
  32. package/dist/esm/version.json +1 -1
  33. package/dist/types/bidi-warning/bidi-warning-decorator.d.ts +5 -0
  34. package/dist/types/bidi-warning/index.d.ts +1 -0
  35. package/dist/types/bidi-warning/ui/index.d.ts +2 -0
  36. package/dist/types/bidi-warning/ui/styled.d.ts +7 -0
  37. package/dist/types/bidi-warning/ui/types.d.ts +21 -0
  38. package/dist/types/code.d.ts +3 -2
  39. package/dist/types/internal/theme/get-theme.d.ts +1 -1
  40. package/dist/types/internal/types.d.ts +11 -0
  41. package/dist/types/internal/utils/get-normalized-language.d.ts +1 -1
  42. package/dist/types/react-syntax-highlighter-bidi-warning-renderer.d.ts +4 -0
  43. package/dist/types/types.d.ts +11 -0
  44. package/package.json +10 -6
@@ -0,0 +1,167 @@
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); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(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; }
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(codeBidiWarningLabel) {
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
+ codeBidiWarningLabel: codeBidiWarningLabel,
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, codeBidiWarningLabel) {
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
+ codeBidiWarningLabel: codeBidiWarningLabel,
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
+ codeBidiWarningLabel = _ref2.codeBidiWarningLabel,
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: codeBidiWarningLabel
131
+ });
132
+ });
133
+ return decorated;
134
+ } else if (TagName) {
135
+ var childrenCreator = createChildren(stylesheet, useInlineStyles, codeBidiWarningLabel);
136
+ var props;
137
+
138
+ if (!useInlineStyles) {
139
+ props = _objectSpread(_objectSpread({}, properties), {}, {
140
+ className: createClassNameString(properties.className)
141
+ });
142
+ } else {
143
+ var allStylesheetSelectors = Object.keys(stylesheet).reduce(function (classes, selector) {
144
+ selector.split('.').forEach(function (className) {
145
+ if (!classes.includes(className)) {
146
+ classes.push(className);
147
+ }
148
+ });
149
+ return classes;
150
+ }, []); // For compatibility with older versions of react-syntax-highlighter
151
+
152
+ var startingClassName = properties.className && properties.className.includes('token') ? ['token'] : [];
153
+ var className = properties.className && startingClassName.concat(properties.className.filter(function (className) {
154
+ return !allStylesheetSelectors.includes(className);
155
+ }));
156
+ props = _objectSpread(_objectSpread({}, properties), {}, {
157
+ className: createClassNameString(className) || undefined,
158
+ style: createStyleObject(properties.className, Object.assign({}, properties.style, style), stylesheet)
159
+ });
160
+ }
161
+
162
+ var children = childrenCreator(node.children);
163
+ return /*#__PURE__*/React.createElement(TagName, _extends({
164
+ key: key
165
+ }, props), children);
166
+ }
167
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/code",
3
- "version": "14.1.2",
3
+ "version": "14.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,5 @@
1
+ export declare const bidiCharacterRegex: RegExp;
2
+ export default function codeBidiWarningDecorator<DecoratorOutput>(originalText: string, decorate: (options: {
3
+ bidiCharacter: string;
4
+ index?: number;
5
+ }) => DecoratorOutput): string | (string | DecoratorOutput)[];
@@ -0,0 +1 @@
1
+ export { default } from './ui';
@@ -0,0 +1,2 @@
1
+ import { CodeBidiWarningProps } from './types';
2
+ export default function BidiWarning({ testId, bidiCharacter, skipChildren, label, }: CodeBidiWarningProps): JSX.Element;
@@ -0,0 +1,7 @@
1
+ /** @jsx jsx */
2
+ import { ReactNode } from 'react';
3
+ export declare function Decorator({ bidiCharacter, children, testId, }: {
4
+ bidiCharacter: string;
5
+ children: ReactNode;
6
+ testId?: string;
7
+ }): JSX.Element;
@@ -0,0 +1,21 @@
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
+ skipChildren?: boolean;
16
+ /**
17
+ * Labels for the previous and next buttons used in pagination.
18
+ * Defaults to `Bidirectional characters change the order that text is rendered. This could be used to obscure malicious code.`.
19
+ */
20
+ label?: string;
21
+ };
@@ -1,6 +1,7 @@
1
- /// <reference types="react" />
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: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Pick<CodeProps, "as" | "css" | "name" | "color" | "content" | "height" | "width" | "start" | "hidden" | "size" | "style" | "default" | "wrap" | "open" | "multiple" | "disabled" | "testId" | "children" | "accept" | "acceptCharset" | "action" | "allowFullScreen" | "allowTransparency" | "alt" | "async" | "autoComplete" | "autoFocus" | "autoPlay" | "capture" | "cellPadding" | "cellSpacing" | "charSet" | "challenge" | "checked" | "cite" | "classID" | "cols" | "colSpan" | "controls" | "coords" | "crossOrigin" | "data" | "dateTime" | "defer" | "download" | "encType" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "frameBorder" | "headers" | "high" | "href" | "hrefLang" | "htmlFor" | "httpEquiv" | "integrity" | "keyParams" | "keyType" | "kind" | "label" | "list" | "loop" | "low" | "manifest" | "marginHeight" | "marginWidth" | "max" | "maxLength" | "media" | "mediaGroup" | "method" | "min" | "minLength" | "muted" | "nonce" | "noValidate" | "optimum" | "pattern" | "placeholder" | "playsInline" | "poster" | "preload" | "readOnly" | "rel" | "required" | "reversed" | "rows" | "rowSpan" | "sandbox" | "scope" | "scoped" | "scrolling" | "seamless" | "selected" | "shape" | "sizes" | "span" | "src" | "srcDoc" | "srcLang" | "srcSet" | "step" | "summary" | "target" | "type" | "useMap" | "value" | "wmode" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "id" | "lang" | "slot" | "spellCheck" | "tabIndex" | "title" | "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"> & import("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"> & React.RefAttributes<HTMLElement>>>;
5
6
  export { getCodeStyles };
6
7
  export default Code;
@@ -2,6 +2,6 @@ import type { Theme } from '@atlaskit/theme/types';
2
2
  import type { CodeBlockTheme, CodeTheme } from './types';
3
3
  export declare const getBaseTheme: (theme: Theme) => CodeTheme;
4
4
  export declare const defaultBaseTheme: CodeTheme;
5
- export declare const getColorPalette: (theme: Theme) => CodeBlockTheme;
5
+ export declare const getColorPalette: import("memoize-one").MemoizedFn<(theme: Theme) => CodeBlockTheme>;
6
6
  declare const getTheme: (theme: Theme) => CodeBlockTheme;
7
7
  export default getTheme;
@@ -34,6 +34,17 @@ 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;
37
48
  }
38
49
  export type { SupportedLanguages, LanguageAlias, Language } from '../constants';
39
50
  export type { CodeBlockTheme, CodeTheme } from './theme/types';
@@ -1 +1 @@
1
- export declare const normalizeLanguage: (language?: "PHP" | "php" | "php3" | "php4" | "php5" | "Java" | "java" | "CSharp" | "csharp" | "c#" | "Python" | "python" | "py" | "JavaScript" | "javascript" | "js" | "Html" | "html" | "xml" | "C++" | "c++" | "cpp" | "clike" | "Ruby" | "ruby" | "rb" | "duby" | "Objective-C" | "objective-c" | "objectivec" | "obj-c" | "objc" | "C" | "c" | "Swift" | "swift" | "TeX" | "tex" | "latex" | "Shell" | "shell" | "bash" | "sh" | "ksh" | "zsh" | "Scala" | "scala" | "Go" | "go" | "ActionScript" | "actionscript" | "actionscript3" | "as" | "ColdFusion" | "coldfusion" | "JavaFX" | "javafx" | "jfx" | "VbNet" | "vbnet" | "vb.net" | "vfp" | "clipper" | "xbase" | "JSON" | "json" | "MATLAB" | "matlab" | "Groovy" | "groovy" | "SQL" | "sql" | "postgresql" | "postgres" | "plpgsql" | "psql" | "postgresql-console" | "postgres-console" | "tsql" | "t-sql" | "mysql" | "sqlite" | "R" | "r" | "Perl" | "perl" | "pl" | "Lua" | "lua" | "Pascal" | "pas" | "pascal" | "objectpascal" | "delphi" | "XML" | "TypeScript" | "typescript" | "ts" | "CoffeeScript" | "coffeescript" | "coffee-script" | "coffee" | "Haskell" | "haskell" | "hs" | "Puppet" | "puppet" | "Arduino" | "arduino" | "Fortran" | "fortran" | "Erlang" | "erlang" | "erl" | "PowerShell" | "powershell" | "posh" | "ps1" | "psm1" | "Haxe" | "haxe" | "hx" | "hxsl" | "Elixir" | "elixir" | "ex" | "exs" | "Verilog" | "verilog" | "v" | "Rust" | "rust" | "VHDL" | "vhdl" | "Sass" | "sass" | "OCaml" | "ocaml" | "Dart" | "dart" | "CSS" | "css" | "reStructuredText" | "restructuredtext" | "rst" | "rest" | "Kotlin" | "kotlin" | "D" | "d" | "Octave" | "octave" | "QML" | "qbs" | "qml" | "Prolog" | "prolog" | "FoxPro" | "foxpro" | "purebasic" | "Scheme" | "scheme" | "scm" | "CUDA" | "cuda" | "cu" | "Julia" | "julia" | "jl" | "Racket" | "racket" | "rkt" | "Ada" | "ada" | "ada95" | "ada2005" | "Tcl" | "tcl" | "Mathematica" | "mathematica" | "mma" | "nb" | "Autoit" | "autoit" | "StandardML" | "standardmL" | "sml" | "standardml" | "Objective-J" | "objective-j" | "objectivej" | "obj-j" | "objj" | "Smalltalk" | "smalltalk" | "squeak" | "st" | "Vala" | "vala" | "vapi" | "ABAP" | "abap" | "LiveScript" | "livescript" | "live-script" | "XQuery" | "xquery" | "xqy" | "xq" | "xql" | "xqm" | "PlainText" | "text" | "plaintext" | "Yaml" | "yaml" | "yml" | "GraphQL" | "graphql" | "AppleScript" | "applescript" | "Clojure" | "clojure" | "Diff" | "diff" | "VisualBasic" | "visualbasic" | "JSX" | "jsx" | "TSX" | "tsx" | "SplunkSPL" | "splunk-spl" | undefined) => string;
1
+ export declare const normalizeLanguage: import("memoize-one").MemoizedFn<(language?: "PHP" | "php" | "php3" | "php4" | "php5" | "Java" | "java" | "CSharp" | "csharp" | "c#" | "Python" | "python" | "py" | "JavaScript" | "javascript" | "js" | "Html" | "html" | "xml" | "C++" | "c++" | "cpp" | "clike" | "Ruby" | "ruby" | "rb" | "duby" | "Objective-C" | "objective-c" | "objectivec" | "obj-c" | "objc" | "C" | "c" | "Swift" | "swift" | "TeX" | "tex" | "latex" | "Shell" | "shell" | "bash" | "sh" | "ksh" | "zsh" | "Scala" | "scala" | "Go" | "go" | "ActionScript" | "actionscript" | "actionscript3" | "as" | "ColdFusion" | "coldfusion" | "JavaFX" | "javafx" | "jfx" | "VbNet" | "vbnet" | "vb.net" | "vfp" | "clipper" | "xbase" | "JSON" | "json" | "MATLAB" | "matlab" | "Groovy" | "groovy" | "SQL" | "sql" | "postgresql" | "postgres" | "plpgsql" | "psql" | "postgresql-console" | "postgres-console" | "tsql" | "t-sql" | "mysql" | "sqlite" | "R" | "r" | "Perl" | "perl" | "pl" | "Lua" | "lua" | "Pascal" | "pas" | "pascal" | "objectpascal" | "delphi" | "XML" | "TypeScript" | "typescript" | "ts" | "CoffeeScript" | "coffeescript" | "coffee-script" | "coffee" | "Haskell" | "haskell" | "hs" | "Puppet" | "puppet" | "Arduino" | "arduino" | "Fortran" | "fortran" | "Erlang" | "erlang" | "erl" | "PowerShell" | "powershell" | "posh" | "ps1" | "psm1" | "Haxe" | "haxe" | "hx" | "hxsl" | "Elixir" | "elixir" | "ex" | "exs" | "Verilog" | "verilog" | "v" | "Rust" | "rust" | "VHDL" | "vhdl" | "Sass" | "sass" | "OCaml" | "ocaml" | "Dart" | "dart" | "CSS" | "css" | "reStructuredText" | "restructuredtext" | "rst" | "rest" | "Kotlin" | "kotlin" | "D" | "d" | "Octave" | "octave" | "QML" | "qbs" | "qml" | "Prolog" | "prolog" | "FoxPro" | "foxpro" | "purebasic" | "Scheme" | "scheme" | "scm" | "CUDA" | "cuda" | "cu" | "Julia" | "julia" | "jl" | "Racket" | "racket" | "rkt" | "Ada" | "ada" | "ada95" | "ada2005" | "Tcl" | "tcl" | "Mathematica" | "mathematica" | "mma" | "nb" | "Autoit" | "autoit" | "StandardML" | "standardmL" | "sml" | "standardml" | "Objective-J" | "objective-j" | "objectivej" | "obj-j" | "objj" | "Smalltalk" | "smalltalk" | "squeak" | "st" | "Vala" | "vala" | "vapi" | "ABAP" | "abap" | "LiveScript" | "livescript" | "live-script" | "XQuery" | "xquery" | "xqy" | "xq" | "xql" | "xqm" | "PlainText" | "text" | "plaintext" | "Yaml" | "yaml" | "yml" | "GraphQL" | "graphql" | "AppleScript" | "applescript" | "Clojure" | "clojure" | "Diff" | "diff" | "VisualBasic" | "visualbasic" | "JSX" | "jsx" | "TSX" | "tsx" | "SplunkSPL" | "splunk-spl" | undefined) => string>;
@@ -0,0 +1,4 @@
1
+ export declare function createBidiWarningRenderer(codeBidiWarningLabel?: string): ({ rows, stylesheet, useInlineStyles, }: any) => any;
2
+ export declare function createStyleObject(classNames: any, elementStyle: {} | undefined, stylesheet: any): any;
3
+ export declare function createClassNameString(classNames: any): any;
4
+ export declare function createChildren(stylesheet: any, useInlineStyles: any, codeBidiWarningLabel: any): (children: any) => any;
@@ -10,4 +10,15 @@ 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;
13
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/code",
3
- "version": "14.1.2",
3
+ "version": "14.2.0",
4
4
  "description": "Code highlights short strings of code snippets inline with body text.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -26,11 +26,12 @@
26
26
  "access": "public"
27
27
  },
28
28
  "dependencies": {
29
- "@atlaskit/codemod-utils": "^3.2.0",
30
- "@atlaskit/theme": "^11.2.0",
29
+ "@atlaskit/codemod-utils": "^3.4.0",
30
+ "@atlaskit/theme": "^12.0.0",
31
+ "@atlaskit/tooltip": "^17.5.0",
31
32
  "@babel/runtime": "^7.0.0",
32
33
  "@emotion/core": "^10.0.9",
33
- "memoize-one": "^5.1.0",
34
+ "memoize-one": "^6.0.0",
34
35
  "react-syntax-highlighter": "^15.4.3"
35
36
  },
36
37
  "peerDependencies": {
@@ -38,8 +39,9 @@
38
39
  },
39
40
  "devDependencies": {
40
41
  "@atlaskit/build-utils": "*",
41
- "@atlaskit/button": "^15.1.4",
42
+ "@atlaskit/button": "^16.0.0",
42
43
  "@atlaskit/docs": "^9.0.0",
44
+ "@atlaskit/section-message": "^6.0.0",
43
45
  "@atlaskit/ssr": "*",
44
46
  "@atlaskit/visual-regression": "*",
45
47
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
@@ -60,6 +62,8 @@
60
62
  "af:exports": {
61
63
  "./types": "./src/entry-points/types.ts",
62
64
  ".": "./src/index.ts",
65
+ "./bidi-warning": "./src/bidi-warning/index.ts",
66
+ "./bidi-warning-decorator": "./src/bidi-warning/bidi-warning-decorator.tsx",
63
67
  "./block": "./src/entry-points/block.ts",
64
68
  "./inline": "./src/entry-points/inline.ts",
65
69
  "./constants": "./src/entry-points/constants.ts"
@@ -76,7 +80,7 @@
76
80
  "analytics-next"
77
81
  ],
78
82
  "theming": [
79
- "new-theming-api"
83
+ "react-context"
80
84
  ],
81
85
  "deprecation": [
82
86
  "no-deprecated-imports"