@atlaskit/code 14.6.8 → 14.6.9
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/bidi-warning-decorator.js +1 -2
- package/dist/cjs/code-block.js +1 -2
- package/dist/cjs/code.js +1 -2
- package/dist/cjs/constants.js +2 -3
- package/dist/cjs/internal/hooks/use-highlight.js +2 -3
- package/dist/cjs/internal/theme/constants.js +8 -16
- package/dist/cjs/internal/theme/get-theme.js +4 -8
- package/dist/cjs/internal/theme/styles.js +6 -11
- package/dist/cjs/internal/utils/get-normalized-language.js +2 -3
- package/dist/cjs/syntax-highlighter/async.js +2 -3
- package/dist/cjs/syntax-highlighter/index.js +1 -2
- package/dist/cjs/syntax-highlighter/lib/highlight.js +1 -2
- package/dist/cjs/syntax-highlighter/lib/process/create-line.js +1 -2
- package/dist/cjs/syntax-highlighter/lib/process/index.js +2 -3
- package/dist/cjs/syntax-highlighter/types.js +2 -3
- package/dist/esm/syntax-highlighter/lib/process/index.js +2 -3
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -10,7 +10,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
10
10
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
11
11
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
12
12
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
13
|
-
var bidiCharacterRegex = /[\u202A-\u202E\u2066-\u2069]/g;
|
|
13
|
+
var bidiCharacterRegex = exports.bidiCharacterRegex = /[\u202A-\u202E\u2066-\u2069]/g;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* __Code Bidi Warning Decorator__
|
|
@@ -19,7 +19,6 @@ var bidiCharacterRegex = /[\u202A-\u202E\u2066-\u2069]/g;
|
|
|
19
19
|
* In case if bidi characters found - returns children with decorated
|
|
20
20
|
* bidi characters. If no bidi characters found - original text returned.
|
|
21
21
|
*/
|
|
22
|
-
exports.bidiCharacterRegex = bidiCharacterRegex;
|
|
23
22
|
function codeBidiWarningDecorator(originalText, decorate) {
|
|
24
23
|
var matches = (0, _toConsumableArray2.default)(originalText.matchAll(bidiCharacterRegex));
|
|
25
24
|
if (matches.length === 0) {
|
package/dist/cjs/code-block.js
CHANGED
package/dist/cjs/code.js
CHANGED
package/dist/cjs/constants.js
CHANGED
|
@@ -11,7 +11,7 @@ Object.defineProperty(exports, "CODE_BLOCK_SELECTOR", {
|
|
|
11
11
|
});
|
|
12
12
|
exports.SUPPORTED_LANGUAGES = void 0;
|
|
13
13
|
var _constants = require("./internal/theme/constants");
|
|
14
|
-
var SUPPORTED_LANGUAGES = [{
|
|
14
|
+
var SUPPORTED_LANGUAGES = exports.SUPPORTED_LANGUAGES = [{
|
|
15
15
|
name: 'PHP',
|
|
16
16
|
alias: ['php', 'php3', 'php4', 'php5'],
|
|
17
17
|
value: 'php'
|
|
@@ -319,5 +319,4 @@ var SUPPORTED_LANGUAGES = [{
|
|
|
319
319
|
name: 'SplunkSPL',
|
|
320
320
|
alias: ['splunk-spl'],
|
|
321
321
|
value: 'splunk-spl'
|
|
322
|
-
}];
|
|
323
|
-
exports.SUPPORTED_LANGUAGES = SUPPORTED_LANGUAGES;
|
|
322
|
+
}];
|
|
@@ -18,7 +18,7 @@ var getLineStyleObject = function getLineStyleObject(lineNumber, testId) {
|
|
|
18
18
|
'data-testid': "".concat(testId, "-line-").concat(lineNumber)
|
|
19
19
|
}, DEFAULT_LINE_EL_ATTR_OBJ) : DEFAULT_LINE_EL_ATTR_OBJ;
|
|
20
20
|
};
|
|
21
|
-
var useHighlightLines = function useHighlightLines(_ref) {
|
|
21
|
+
var useHighlightLines = exports.useHighlightLines = function useHighlightLines(_ref) {
|
|
22
22
|
var _ref$highlight = _ref.highlight,
|
|
23
23
|
highlight = _ref$highlight === void 0 ? '' : _ref$highlight,
|
|
24
24
|
testId = _ref.testId;
|
|
@@ -62,5 +62,4 @@ var useHighlightLines = function useHighlightLines(_ref) {
|
|
|
62
62
|
getHighlightStyles: getHighlightStyles,
|
|
63
63
|
highlightedLines: highlightedLines
|
|
64
64
|
};
|
|
65
|
-
};
|
|
66
|
-
exports.useHighlightLines = useHighlightLines;
|
|
65
|
+
};
|
|
@@ -7,21 +7,13 @@ exports.VAR_CODE_LINE_NUMBER_BG_COLOR = exports.VAR_CODE_BG_COLOR = exports.SPAC
|
|
|
7
7
|
var _constants = require("@atlaskit/theme/constants");
|
|
8
8
|
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
9
9
|
|
|
10
|
-
var CODE_FONT_SIZE = 12;
|
|
11
|
-
exports.
|
|
12
|
-
var
|
|
13
|
-
exports.
|
|
14
|
-
var
|
|
15
|
-
exports.
|
|
16
|
-
var
|
|
17
|
-
exports.SPACING = SPACING;
|
|
18
|
-
var LINE_NUMBER_GUTTER = SPACING * 2;
|
|
19
|
-
exports.LINE_NUMBER_GUTTER = LINE_NUMBER_GUTTER;
|
|
20
|
-
var VAR_CODE_LINE_NUMBER_BG_COLOR = '--ds--code--line-number-bg-color';
|
|
21
|
-
exports.VAR_CODE_LINE_NUMBER_BG_COLOR = VAR_CODE_LINE_NUMBER_BG_COLOR;
|
|
22
|
-
var VAR_CODE_BG_COLOR = '--ds--code--bg-color';
|
|
10
|
+
var CODE_FONT_SIZE = exports.CODE_FONT_SIZE = 12;
|
|
11
|
+
var CODE_LINE_HEIGHT = exports.CODE_LINE_HEIGHT = '20px';
|
|
12
|
+
var HIGHLIGHT_BORDER_WIDTH = exports.HIGHLIGHT_BORDER_WIDTH = '4px';
|
|
13
|
+
var SPACING = exports.SPACING = (0, _constants.gridSize)();
|
|
14
|
+
var LINE_NUMBER_GUTTER = exports.LINE_NUMBER_GUTTER = SPACING * 2;
|
|
15
|
+
var VAR_CODE_LINE_NUMBER_BG_COLOR = exports.VAR_CODE_LINE_NUMBER_BG_COLOR = '--ds--code--line-number-bg-color';
|
|
16
|
+
var VAR_CODE_BG_COLOR = exports.VAR_CODE_BG_COLOR = '--ds--code--bg-color';
|
|
23
17
|
|
|
24
18
|
// selector for codeblock
|
|
25
|
-
exports.
|
|
26
|
-
var CODE_BLOCK_SELECTOR = "data-ds--code--code-block";
|
|
27
|
-
exports.CODE_BLOCK_SELECTOR = CODE_BLOCK_SELECTOR;
|
|
19
|
+
var CODE_BLOCK_SELECTOR = exports.CODE_BLOCK_SELECTOR = "data-ds--code--code-block";
|
|
@@ -20,7 +20,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
20
20
|
var T800 = '#067384';
|
|
21
21
|
var Y1100 = '#7A5D1A';
|
|
22
22
|
var PLUS20 = '#3A434E';
|
|
23
|
-
var getBaseTheme = function getBaseTheme(theme) {
|
|
23
|
+
var getBaseTheme = exports.getBaseTheme = function getBaseTheme(theme) {
|
|
24
24
|
return {
|
|
25
25
|
fontFamily: (0, _constants.codeFontFamily)(),
|
|
26
26
|
fontFamilyItalic: "SFMono-MediumItalic, ".concat((0, _constants.codeFontFamily)()),
|
|
@@ -50,12 +50,10 @@ var getBaseTheme = function getBaseTheme(theme) {
|
|
|
50
50
|
})
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
-
exports.
|
|
54
|
-
var defaultBaseTheme = getBaseTheme({
|
|
53
|
+
var defaultBaseTheme = exports.defaultBaseTheme = getBaseTheme({
|
|
55
54
|
mode: 'light'
|
|
56
55
|
});
|
|
57
|
-
exports.
|
|
58
|
-
var getColorPalette = (0, _memoizeOne.default)(function (theme) {
|
|
56
|
+
var getColorPalette = exports.getColorPalette = (0, _memoizeOne.default)(function (theme) {
|
|
59
57
|
var akTheme = {
|
|
60
58
|
theme: theme
|
|
61
59
|
};
|
|
@@ -238,9 +236,7 @@ var getColorPalette = (0, _memoizeOne.default)(function (theme) {
|
|
|
238
236
|
})(akTheme)
|
|
239
237
|
};
|
|
240
238
|
});
|
|
241
|
-
exports.getColorPalette = getColorPalette;
|
|
242
239
|
var getTheme = function getTheme(theme) {
|
|
243
240
|
return _objectSpread(_objectSpread({}, getBaseTheme(theme)), getColorPalette(theme));
|
|
244
241
|
};
|
|
245
|
-
var _default = getTheme;
|
|
246
|
-
exports.default = _default;
|
|
242
|
+
var _default = exports.default = getTheme;
|
|
@@ -11,13 +11,12 @@ var _constants2 = require("./constants");
|
|
|
11
11
|
var _getTheme = require("./get-theme");
|
|
12
12
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
13
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
-
var getLineNumWidth = function getLineNumWidth(numLines) {
|
|
14
|
+
var getLineNumWidth = exports.getLineNumWidth = function getLineNumWidth(numLines) {
|
|
15
15
|
if (!numLines) {
|
|
16
16
|
return '1ch';
|
|
17
17
|
}
|
|
18
18
|
return "".concat(numLines.toFixed(0).length, "ch");
|
|
19
19
|
};
|
|
20
|
-
exports.getLineNumWidth = getLineNumWidth;
|
|
21
20
|
var lineNumberStyle = function lineNumberStyle(theme) {
|
|
22
21
|
return {
|
|
23
22
|
// width of the line number gutter
|
|
@@ -197,7 +196,7 @@ var syntaxKeywordColors = function syntaxKeywordColors(theme) {
|
|
|
197
196
|
/**
|
|
198
197
|
* Styles applied at the root element level, common across code/codeblock
|
|
199
198
|
*/
|
|
200
|
-
var getBaseCodeStyles = function getBaseCodeStyles(theme) {
|
|
199
|
+
var getBaseCodeStyles = exports.getBaseCodeStyles = function getBaseCodeStyles(theme) {
|
|
201
200
|
return {
|
|
202
201
|
fontSize: _constants2.CODE_FONT_SIZE,
|
|
203
202
|
fontFamily: theme.fontFamily,
|
|
@@ -215,8 +214,7 @@ var getBaseCodeStyles = function getBaseCodeStyles(theme) {
|
|
|
215
214
|
*
|
|
216
215
|
* @param theme
|
|
217
216
|
*/
|
|
218
|
-
exports.
|
|
219
|
-
var getCodeBlockStyles = function getCodeBlockStyles(theme) {
|
|
217
|
+
var getCodeBlockStyles = exports.getCodeBlockStyles = function getCodeBlockStyles(theme) {
|
|
220
218
|
return function (highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines) {
|
|
221
219
|
return _objectSpread(_objectSpread(_objectSpread({
|
|
222
220
|
// this is required to account for prismjs styles leaking into the codeblock
|
|
@@ -304,8 +302,7 @@ var getCodeBlockStyles = function getCodeBlockStyles(theme) {
|
|
|
304
302
|
});
|
|
305
303
|
};
|
|
306
304
|
};
|
|
307
|
-
exports.
|
|
308
|
-
var getCodeStyles = function getCodeStyles(globalTheme) {
|
|
305
|
+
var getCodeStyles = exports.getCodeStyles = function getCodeStyles(globalTheme) {
|
|
309
306
|
// Required to have proper compatibility with styled components interpolations
|
|
310
307
|
var akTheme = 'theme' in globalTheme ? globalTheme.theme : globalTheme;
|
|
311
308
|
var theme = (0, _getTheme.getBaseTheme)(akTheme);
|
|
@@ -320,10 +317,8 @@ var getCodeStyles = function getCodeStyles(globalTheme) {
|
|
|
320
317
|
whiteSpace: 'pre-wrap'
|
|
321
318
|
});
|
|
322
319
|
};
|
|
323
|
-
exports.
|
|
324
|
-
var getCodeBlockTheme = function getCodeBlockTheme(globalTheme, maxLines) {
|
|
320
|
+
var getCodeBlockTheme = exports.getCodeBlockTheme = function getCodeBlockTheme(globalTheme, maxLines) {
|
|
325
321
|
return _objectSpread(_objectSpread(_objectSpread({}, (0, _getTheme.getBaseTheme)(globalTheme)), (0, _getTheme.getColorPalette)(globalTheme)), {}, {
|
|
326
322
|
lineNumberWidth: maxLines ? getLineNumWidth(maxLines) : undefined
|
|
327
323
|
});
|
|
328
|
-
};
|
|
329
|
-
exports.getCodeBlockTheme = getCodeBlockTheme;
|
|
324
|
+
};
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.normalizeLanguage = void 0;
|
|
8
8
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
9
9
|
var _constants = require("../../constants");
|
|
10
|
-
var normalizeLanguage = (0, _memoizeOne.default)(function (language) {
|
|
10
|
+
var normalizeLanguage = exports.normalizeLanguage = (0, _memoizeOne.default)(function (language) {
|
|
11
11
|
if (!language) {
|
|
12
12
|
return '';
|
|
13
13
|
}
|
|
@@ -16,5 +16,4 @@ var normalizeLanguage = (0, _memoizeOne.default)(function (language) {
|
|
|
16
16
|
});
|
|
17
17
|
// Fallback to plain monospaced text if language passed but not supported
|
|
18
18
|
return match ? match.value : 'text';
|
|
19
|
-
});
|
|
20
|
-
exports.normalizeLanguage = normalizeLanguage;
|
|
19
|
+
});
|
|
@@ -75,7 +75,7 @@ var generator = function generator(options) {
|
|
|
75
75
|
(0, _defineProperty2.default)(AsyncHighlighter, "highlightInstance", _highlight.default);
|
|
76
76
|
return AsyncHighlighter;
|
|
77
77
|
};
|
|
78
|
-
var _default = generator({
|
|
78
|
+
var _default = exports.default = generator({
|
|
79
79
|
loader: function loader() {
|
|
80
80
|
return Promise.resolve().then(function () {
|
|
81
81
|
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_refractor-import" */
|
|
@@ -85,5 +85,4 @@ var _default = generator({
|
|
|
85
85
|
return module.default || module;
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
});
|
|
89
|
-
exports.default = _default;
|
|
88
|
+
});
|
|
@@ -40,5 +40,4 @@ var _async = _interopRequireDefault(require("./async"));
|
|
|
40
40
|
* @atlaskit/code uses this under-the-hood, but it is not intended for public consumption.
|
|
41
41
|
* You should be using @atlaskit/code directly.
|
|
42
42
|
*/
|
|
43
|
-
var _default = _async.default;
|
|
44
|
-
exports.default = _default;
|
|
43
|
+
var _default = exports.default = _async.default;
|
|
@@ -39,7 +39,7 @@ function processLines(_ref) {
|
|
|
39
39
|
var testNode = tree[index];
|
|
40
40
|
if (testNode.type === 'text') {
|
|
41
41
|
index++;
|
|
42
|
-
return
|
|
42
|
+
return 1; // continue
|
|
43
43
|
}
|
|
44
44
|
var node = testNode;
|
|
45
45
|
var firstChildNode = node.children[0];
|
|
@@ -100,8 +100,7 @@ function processLines(_ref) {
|
|
|
100
100
|
index++;
|
|
101
101
|
};
|
|
102
102
|
while (index < tree.length) {
|
|
103
|
-
|
|
104
|
-
if (_ret === "continue") continue;
|
|
103
|
+
if (_loop()) continue;
|
|
105
104
|
}
|
|
106
105
|
if (lastLineBreakIndex !== tree.length - 1) {
|
|
107
106
|
var children = tree.slice(lastLineBreakIndex + 1, tree.length);
|
|
@@ -15,7 +15,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
15
15
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
16
16
|
// This wrapper supports the async loading of refractor and language grammars. The internal Highlight is a memo() functional component as expected
|
|
17
17
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
18
|
-
var SyntaxHighlighter = /*#__PURE__*/function (_React$PureComponent) {
|
|
18
|
+
var SyntaxHighlighter = exports.SyntaxHighlighter = /*#__PURE__*/function (_React$PureComponent) {
|
|
19
19
|
(0, _inherits2.default)(SyntaxHighlighter, _React$PureComponent);
|
|
20
20
|
var _super = _createSuper(SyntaxHighlighter);
|
|
21
21
|
function SyntaxHighlighter() {
|
|
@@ -32,5 +32,4 @@ var SyntaxHighlighter = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
32
32
|
* Props to be passed to the `span` wrapping each code line. Can be an
|
|
33
33
|
* object or a function that receives current line number as argument and
|
|
34
34
|
* returns a props object.
|
|
35
|
-
*/
|
|
36
|
-
exports.SyntaxHighlighter = SyntaxHighlighter;
|
|
35
|
+
*/
|
|
@@ -32,7 +32,7 @@ export default function processLines(_ref) {
|
|
|
32
32
|
var testNode = tree[index];
|
|
33
33
|
if (testNode.type === 'text') {
|
|
34
34
|
index++;
|
|
35
|
-
return
|
|
35
|
+
return 1; // continue
|
|
36
36
|
}
|
|
37
37
|
var node = testNode;
|
|
38
38
|
var firstChildNode = node.children[0];
|
|
@@ -93,8 +93,7 @@ export default function processLines(_ref) {
|
|
|
93
93
|
index++;
|
|
94
94
|
};
|
|
95
95
|
while (index < tree.length) {
|
|
96
|
-
|
|
97
|
-
if (_ret === "continue") continue;
|
|
96
|
+
if (_loop()) continue;
|
|
98
97
|
}
|
|
99
98
|
if (lastLineBreakIndex !== tree.length - 1) {
|
|
100
99
|
var children = tree.slice(lastLineBreakIndex + 1, tree.length);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/code",
|
|
3
|
-
"version": "14.6.
|
|
3
|
+
"version": "14.6.9",
|
|
4
4
|
"description": "Code highlights short strings of code snippets inline with body text.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@atlaskit/codemod-utils": "^4.2.0",
|
|
30
30
|
"@atlaskit/theme": "^12.6.0",
|
|
31
|
-
"@atlaskit/tokens": "^1.
|
|
32
|
-
"@atlaskit/tooltip": "^
|
|
31
|
+
"@atlaskit/tokens": "^1.28.0",
|
|
32
|
+
"@atlaskit/tooltip": "^18.0.0",
|
|
33
33
|
"@atlaskit/visually-hidden": "^1.2.0",
|
|
34
34
|
"@babel/runtime": "^7.0.0",
|
|
35
35
|
"@emotion/react": "^11.7.1",
|