@atlaskit/renderer 107.1.0 → 107.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 +23 -0
- package/dist/cjs/analytics/enums.js +61 -1
- package/dist/cjs/react/index.js +10 -1
- package/dist/cjs/react/nodes/blockCard.js +6 -2
- package/dist/cjs/react/nodes/codeBlock/codeBlock.js +18 -6
- package/dist/cjs/react/nodes/codeBlock/components/codeBlockButtonContainer.js +67 -0
- package/dist/cjs/react/nodes/codeBlock/components/codeBlockContainer.js +15 -8
- package/dist/cjs/react/nodes/codeBlock/components/codeBlockCopyButton.js +71 -0
- package/dist/cjs/react/nodes/codeBlock/components/codeBlockWrapButton.js +76 -0
- package/dist/cjs/react/nodes/codeBlock/windowedCodeBlock.js +13 -2
- package/dist/cjs/react/nodes/inlineCard.js +5 -2
- package/dist/cjs/react/nodes/media.js +18 -1
- package/dist/cjs/react/nodes/mediaInline.js +19 -4
- package/dist/cjs/react/nodes/tableCell.js +6 -1
- package/dist/cjs/ui/Renderer/index.js +5 -1
- package/dist/cjs/ui/Renderer/style.js +2 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/enums.js +55 -1
- package/dist/es2019/react/index.js +7 -1
- package/dist/es2019/react/nodes/blockCard.js +7 -2
- package/dist/es2019/react/nodes/codeBlock/codeBlock.js +10 -3
- package/dist/es2019/react/nodes/codeBlock/components/codeBlockButtonContainer.js +59 -0
- package/dist/es2019/react/nodes/codeBlock/components/codeBlockContainer.js +25 -8
- package/dist/es2019/react/nodes/codeBlock/components/codeBlockCopyButton.js +52 -0
- package/dist/es2019/react/nodes/codeBlock/components/codeBlockWrapButton.js +67 -0
- package/dist/es2019/react/nodes/codeBlock/windowedCodeBlock.js +9 -4
- package/dist/es2019/react/nodes/inlineCard.js +5 -2
- package/dist/es2019/react/nodes/media.js +18 -1
- package/dist/es2019/react/nodes/mediaInline.js +19 -4
- package/dist/es2019/react/nodes/tableCell.js +6 -1
- package/dist/es2019/ui/Renderer/index.js +5 -1
- package/dist/es2019/ui/Renderer/style.js +9 -11
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/enums.js +55 -1
- package/dist/esm/react/index.js +10 -1
- package/dist/esm/react/nodes/blockCard.js +6 -2
- package/dist/esm/react/nodes/codeBlock/codeBlock.js +15 -3
- package/dist/esm/react/nodes/codeBlock/components/codeBlockButtonContainer.js +58 -0
- package/dist/esm/react/nodes/codeBlock/components/codeBlockContainer.js +15 -9
- package/dist/esm/react/nodes/codeBlock/components/codeBlockCopyButton.js +59 -0
- package/dist/esm/react/nodes/codeBlock/components/codeBlockWrapButton.js +67 -0
- package/dist/esm/react/nodes/codeBlock/windowedCodeBlock.js +14 -4
- package/dist/esm/react/nodes/inlineCard.js +5 -2
- package/dist/esm/react/nodes/media.js +18 -1
- package/dist/esm/react/nodes/mediaInline.js +19 -4
- package/dist/esm/react/nodes/tableCell.js +6 -1
- package/dist/esm/ui/Renderer/index.js +5 -1
- package/dist/esm/ui/Renderer/style.js +2 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/enums.d.ts +51 -0
- package/dist/types/analytics/events.d.ts +5 -1
- package/dist/types/react/index.d.ts +2 -0
- package/dist/types/react/nodes/blockCard.d.ts +2 -0
- package/dist/types/react/nodes/codeBlock/codeBlock.d.ts +1 -0
- package/dist/types/react/nodes/codeBlock/components/codeBlockButtonContainer.d.ts +12 -0
- package/dist/types/react/nodes/codeBlock/components/codeBlockContainer.d.ts +5 -7
- package/dist/types/react/nodes/codeBlock/components/codeBlockWrapButton.d.ts +11 -0
- package/dist/types/react/nodes/codeBlock/windowedCodeBlock.d.ts +1 -1
- package/dist/types/react/nodes/index.d.ts +1 -0
- package/dist/types/react/nodes/media.d.ts +3 -2
- package/dist/types/react/nodes/mediaInline.d.ts +6 -0
- package/dist/types/react/types.d.ts +1 -0
- package/dist/types/types/smartLinksOptions.d.ts +1 -0
- package/dist/types/ui/renderer-props.d.ts +1 -0
- package/package.json +20 -20
- package/report.api.md +21 -2
- package/dist/cjs/react/nodes/codeBlockCopyButton.js +0 -64
- package/dist/es2019/react/nodes/codeBlockCopyButton.js +0 -86
- package/dist/esm/react/nodes/codeBlockCopyButton.js +0 -54
- /package/dist/types/react/nodes/{codeBlockCopyButton.d.ts → codeBlock/components/codeBlockCopyButton.d.ts} +0 -0
|
@@ -7,7 +7,8 @@ import { getClipboardAttrs } from '../../ui/MediaCard';
|
|
|
7
7
|
import { createIntl, injectIntl } from 'react-intl-next';
|
|
8
8
|
export const RenderMediaInline = props => {
|
|
9
9
|
const {
|
|
10
|
-
mediaProvider
|
|
10
|
+
mediaProvider,
|
|
11
|
+
rendererAppearance
|
|
11
12
|
} = props;
|
|
12
13
|
const [viewMediaClientConfigState, setViewMediaClientConfigState] = useState();
|
|
13
14
|
useEffect(() => {
|
|
@@ -30,9 +31,20 @@ export const RenderMediaInline = props => {
|
|
|
30
31
|
isSelected: false
|
|
31
32
|
});
|
|
32
33
|
}
|
|
34
|
+
const handleMediaInlineClick = result => {
|
|
35
|
+
var _props$eventHandlers, _props$eventHandlers$;
|
|
36
|
+
if ((_props$eventHandlers = props.eventHandlers) !== null && _props$eventHandlers !== void 0 && (_props$eventHandlers$ = _props$eventHandlers.media) !== null && _props$eventHandlers$ !== void 0 && _props$eventHandlers$.onClick) {
|
|
37
|
+
var _props$eventHandlers2, _props$eventHandlers3;
|
|
38
|
+
(_props$eventHandlers2 = props.eventHandlers) === null || _props$eventHandlers2 === void 0 ? void 0 : (_props$eventHandlers3 = _props$eventHandlers2.media) === null || _props$eventHandlers3 === void 0 ? void 0 : _props$eventHandlers3.onClick(result);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const shouldOpenMediaViewer = rendererAppearance !== 'mobile';
|
|
42
|
+
const shouldDisplayToolTip = rendererAppearance !== 'mobile';
|
|
33
43
|
return /*#__PURE__*/React.createElement(MediaInlineCard, {
|
|
34
44
|
identifier: props.identifier,
|
|
35
|
-
|
|
45
|
+
onClick: handleMediaInlineClick,
|
|
46
|
+
shouldOpenMediaViewer: shouldOpenMediaViewer,
|
|
47
|
+
shouldDisplayToolTip: shouldDisplayToolTip,
|
|
36
48
|
mediaClientConfig: viewMediaClientConfigState
|
|
37
49
|
});
|
|
38
50
|
};
|
|
@@ -41,7 +53,8 @@ const MediaInline = props => {
|
|
|
41
53
|
collection,
|
|
42
54
|
id,
|
|
43
55
|
providers,
|
|
44
|
-
intl
|
|
56
|
+
intl,
|
|
57
|
+
rendererAppearance
|
|
45
58
|
} = props;
|
|
46
59
|
const identifier = {
|
|
47
60
|
id,
|
|
@@ -70,7 +83,9 @@ const MediaInline = props => {
|
|
|
70
83
|
}
|
|
71
84
|
return /*#__PURE__*/React.createElement(RenderMediaInline, {
|
|
72
85
|
identifier: identifier,
|
|
73
|
-
mediaProvider: mediaProvider
|
|
86
|
+
mediaProvider: mediaProvider,
|
|
87
|
+
eventHandlers: props.eventHandlers,
|
|
88
|
+
rendererAppearance: rendererAppearance
|
|
74
89
|
});
|
|
75
90
|
}
|
|
76
91
|
}));
|
|
@@ -4,6 +4,8 @@ import React from 'react';
|
|
|
4
4
|
import { tableBackgroundColorPalette } from '@atlaskit/adf-schema';
|
|
5
5
|
import { compose } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { SortOrder } from '@atlaskit/editor-common/types';
|
|
7
|
+
import { hexToEditorBackgroundPaletteColorTokenName } from '@atlaskit/editor-palette';
|
|
8
|
+
import { getTokenValue } from '@atlaskit/tokens';
|
|
7
9
|
import SortingIcon from '../../ui/SortingIcon';
|
|
8
10
|
import { MODE, PLATFORM } from '../../analytics/events';
|
|
9
11
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
@@ -68,7 +70,10 @@ const getStyle = (background, colGroupWidth, offsetTop) => {
|
|
|
68
70
|
if (background &&
|
|
69
71
|
// ignore setting inline styles if ds neutral token is detected
|
|
70
72
|
!background.includes('--ds-background-neutral')) {
|
|
71
|
-
|
|
73
|
+
const tokenName = hexToEditorBackgroundPaletteColorTokenName(background);
|
|
74
|
+
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-design-token-usage
|
|
75
|
+
const tokenColor = tokenName ? getTokenValue(tokenName) : background;
|
|
76
|
+
style.backgroundColor = tokenColor;
|
|
72
77
|
}
|
|
73
78
|
if (colGroupWidth) {
|
|
74
79
|
style.width = colGroupWidth;
|
|
@@ -35,7 +35,7 @@ import { RenderTracking } from '../../react/utils/performance/RenderTracking';
|
|
|
35
35
|
export const NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
36
36
|
export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
37
37
|
const packageName = "@atlaskit/renderer";
|
|
38
|
-
const packageVersion = "107.
|
|
38
|
+
const packageVersion = "107.3.0";
|
|
39
39
|
export class Renderer extends PureComponent {
|
|
40
40
|
/**
|
|
41
41
|
* This is used in measuring the Renderer Mount time and is then
|
|
@@ -245,6 +245,7 @@ export class Renderer extends PureComponent {
|
|
|
245
245
|
emojiResourceConfig: props.emojiResourceConfig,
|
|
246
246
|
smartLinks: props.smartLinks,
|
|
247
247
|
allowCopyToClipboard: props.allowCopyToClipboard,
|
|
248
|
+
allowWrapCodeBlock: props.allowWrapCodeBlock,
|
|
248
249
|
allowCustomPanels: props.allowCustomPanels,
|
|
249
250
|
allowAnnotations: props.allowAnnotations,
|
|
250
251
|
allowSelectAllTrap: props.allowSelectAllTrap,
|
|
@@ -269,6 +270,7 @@ export class Renderer extends PureComponent {
|
|
|
269
270
|
allowPlaceholderText,
|
|
270
271
|
allowColumnSorting,
|
|
271
272
|
allowCopyToClipboard,
|
|
273
|
+
allowWrapCodeBlock,
|
|
272
274
|
allowCustomPanels
|
|
273
275
|
} = this.props;
|
|
274
276
|
const allowNestedHeaderLinks = isNestedHeaderLinksEnabled(allowHeadingAnchorLinks);
|
|
@@ -341,6 +343,7 @@ export class Renderer extends PureComponent {
|
|
|
341
343
|
allowNestedHeaderLinks: allowNestedHeaderLinks,
|
|
342
344
|
allowColumnSorting: allowColumnSorting,
|
|
343
345
|
allowCopyToClipboard: allowCopyToClipboard,
|
|
346
|
+
allowWrapCodeBlock: allowWrapCodeBlock,
|
|
344
347
|
allowCustomPanels: allowCustomPanels,
|
|
345
348
|
allowPlaceholderText: allowPlaceholderText,
|
|
346
349
|
innerRef: this.editorRef,
|
|
@@ -371,6 +374,7 @@ export class Renderer extends PureComponent {
|
|
|
371
374
|
return jsx(RendererWrapper, {
|
|
372
375
|
appearance: appearance,
|
|
373
376
|
allowCopyToClipboard: allowCopyToClipboard,
|
|
377
|
+
allowWrapCodeBlock: allowWrapCodeBlock,
|
|
374
378
|
allowPlaceholderText: allowPlaceholderText,
|
|
375
379
|
allowColumnSorting: allowColumnSorting,
|
|
376
380
|
allowNestedHeaderLinks: allowNestedHeaderLinks,
|
|
@@ -640,17 +640,6 @@ export const rendererStyles = wrapperProps => theme => {
|
|
|
640
640
|
&:first-child {
|
|
641
641
|
margin-top: 0;
|
|
642
642
|
}
|
|
643
|
-
|
|
644
|
-
&:hover button.copy-to-clipboard,
|
|
645
|
-
.copy-to-clipboard:focus {
|
|
646
|
-
opacity: 1;
|
|
647
|
-
position: absolute;
|
|
648
|
-
height: 32px;
|
|
649
|
-
width: 32px;
|
|
650
|
-
right: 6px;
|
|
651
|
-
top: 4px;
|
|
652
|
-
padding: 2px;
|
|
653
|
-
}
|
|
654
643
|
}
|
|
655
644
|
|
|
656
645
|
${getLightWeightCodeBlockStylesForRootRendererStyleSheet()}
|
|
@@ -667,6 +656,15 @@ export const rendererStyles = wrapperProps => theme => {
|
|
|
667
656
|
margin-left: 0;
|
|
668
657
|
}
|
|
669
658
|
}
|
|
659
|
+
|
|
660
|
+
& .MediaGroup,
|
|
661
|
+
& .code-block {
|
|
662
|
+
margin-top: ${blockNodesVerticalMargin};
|
|
663
|
+
|
|
664
|
+
&:first-child {
|
|
665
|
+
margin-top: 0;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
670
668
|
}
|
|
671
669
|
|
|
672
670
|
& li {
|
package/dist/es2019/version.json
CHANGED
|
@@ -1 +1,55 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var EVENT_TYPE;
|
|
2
|
+
(function (EVENT_TYPE) {
|
|
3
|
+
EVENT_TYPE["OPERATIONAL"] = "operational";
|
|
4
|
+
EVENT_TYPE["SCREEN"] = "screen";
|
|
5
|
+
EVENT_TYPE["TRACK"] = "track";
|
|
6
|
+
EVENT_TYPE["UI"] = "ui";
|
|
7
|
+
})(EVENT_TYPE || (EVENT_TYPE = {}));
|
|
8
|
+
export var ACTION;
|
|
9
|
+
(function (ACTION) {
|
|
10
|
+
ACTION["STARTED"] = "started";
|
|
11
|
+
ACTION["RENDERED"] = "rendered";
|
|
12
|
+
ACTION["RE_RENDERED"] = "reRendered";
|
|
13
|
+
ACTION["RENDERER_TTI"] = "tti";
|
|
14
|
+
ACTION["CRASHED"] = "unhandledErrorCaught";
|
|
15
|
+
ACTION["INVALID_PROSEMIRROR_DOCUMENT"] = "invalidProsemirrorDocument";
|
|
16
|
+
ACTION["SELECT_ALL_CAUGHT"] = "selectAllCaught";
|
|
17
|
+
ACTION["SELECT_ALL_ESCAPED"] = "selectAllEscaped";
|
|
18
|
+
ACTION["CLICKED"] = "clicked";
|
|
19
|
+
ACTION["VIEWED"] = "viewed";
|
|
20
|
+
ACTION["VISITED"] = "visited";
|
|
21
|
+
ACTION["SORT_COLUMN"] = "sortedColumn";
|
|
22
|
+
ACTION["SORT_COLUMN_NOT_ALLOWED"] = "sortColumnNotAllowed";
|
|
23
|
+
ACTION["TOGGLE_EXPAND"] = "toggleExpand";
|
|
24
|
+
ACTION["INSERTED"] = "inserted";
|
|
25
|
+
ACTION["OPENED"] = "opened";
|
|
26
|
+
ACTION["CLOSED"] = "closed";
|
|
27
|
+
ACTION["DELETED"] = "deleted";
|
|
28
|
+
ACTION["EDITED"] = "edited";
|
|
29
|
+
ACTION["RESOLVED"] = "resolved";
|
|
30
|
+
ACTION["CREATE_NOT_ALLOWED"] = "createNotAllowed";
|
|
31
|
+
ACTION["UNSUPPORTED_CONTENT_LEVELS_TRACKING_SUCCEEDED"] = "unsupportedContentLevelsTrackingSucceeded";
|
|
32
|
+
ACTION["UNSUPPORTED_CONTENT_LEVELS_TRACKING_ERRORED"] = "unsupportedContentLevelsTrackingErrored";
|
|
33
|
+
ACTION["MEDIA_LINK_TRANSFORMED"] = "mediaLinkTransformed";
|
|
34
|
+
})(ACTION || (ACTION = {}));
|
|
35
|
+
export var ACTION_SUBJECT;
|
|
36
|
+
(function (ACTION_SUBJECT) {
|
|
37
|
+
ACTION_SUBJECT["RENDERER"] = "renderer";
|
|
38
|
+
ACTION_SUBJECT["BUTTON"] = "button";
|
|
39
|
+
ACTION_SUBJECT["ANCHOR_LINK"] = "anchorLink";
|
|
40
|
+
ACTION_SUBJECT["TABLE"] = "table";
|
|
41
|
+
ACTION_SUBJECT["EXPAND"] = "expand";
|
|
42
|
+
ACTION_SUBJECT["NESTED_EXPAND"] = "nestedExpand";
|
|
43
|
+
ACTION_SUBJECT["MEDIA_SINGLE"] = "mediaSingle";
|
|
44
|
+
ACTION_SUBJECT["LINK"] = "link";
|
|
45
|
+
ACTION_SUBJECT["ANNOTATION"] = "annotation";
|
|
46
|
+
ACTION_SUBJECT["MEDIA"] = "media";
|
|
47
|
+
})(ACTION_SUBJECT || (ACTION_SUBJECT = {}));
|
|
48
|
+
export var ACTION_SUBJECT_ID;
|
|
49
|
+
(function (ACTION_SUBJECT_ID) {
|
|
50
|
+
ACTION_SUBJECT_ID["HEADING_ANCHOR_LINK"] = "headingAnchorLink";
|
|
51
|
+
ACTION_SUBJECT_ID["LINK"] = "link";
|
|
52
|
+
ACTION_SUBJECT_ID["INLINE_COMMENT"] = "inlineComment";
|
|
53
|
+
ACTION_SUBJECT_ID["CODEBLOCK_COPY"] = "codeBlockCopy";
|
|
54
|
+
ACTION_SUBJECT_ID["CODEBLOCK_WRAP"] = "codeBlockWrap";
|
|
55
|
+
})(ACTION_SUBJECT_ID || (ACTION_SUBJECT_ID = {}));
|
package/dist/esm/react/index.js
CHANGED
|
@@ -46,6 +46,7 @@ var ReactSerializer = /*#__PURE__*/function () {
|
|
|
46
46
|
_defineProperty(this, "headingIds", []);
|
|
47
47
|
_defineProperty(this, "expandHeadingIds", []);
|
|
48
48
|
_defineProperty(this, "allowCopyToClipboard", false);
|
|
49
|
+
_defineProperty(this, "allowWrapCodeBlock", false);
|
|
49
50
|
_defineProperty(this, "allowPlaceholderText", true);
|
|
50
51
|
_defineProperty(this, "allowCustomPanels", false);
|
|
51
52
|
_defineProperty(this, "startPos", 1);
|
|
@@ -151,6 +152,7 @@ var ReactSerializer = /*#__PURE__*/function () {
|
|
|
151
152
|
this.disableActions = init.disableActions;
|
|
152
153
|
this.allowHeadingAnchorLinks = init.allowHeadingAnchorLinks;
|
|
153
154
|
this.allowCopyToClipboard = init.allowCopyToClipboard;
|
|
155
|
+
this.allowWrapCodeBlock = init.allowWrapCodeBlock;
|
|
154
156
|
this.allowPlaceholderText = init.allowPlaceholderText;
|
|
155
157
|
this.allowCustomPanels = init.allowCustomPanels;
|
|
156
158
|
this.allowColumnSorting = init.allowColumnSorting;
|
|
@@ -379,15 +381,21 @@ var ReactSerializer = /*#__PURE__*/function () {
|
|
|
379
381
|
var _this6 = this,
|
|
380
382
|
_this$media;
|
|
381
383
|
var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
382
|
-
var
|
|
384
|
+
var _node$type$schema$mar = node.type.schema.marks,
|
|
385
|
+
link = _node$type$schema$mar.link,
|
|
386
|
+
border = _node$type$schema$mar.border;
|
|
383
387
|
var isLinkMark = function isLinkMark(mark) {
|
|
384
388
|
return mark.type === link;
|
|
385
389
|
};
|
|
390
|
+
var isBorderMark = function isBorderMark(mark) {
|
|
391
|
+
return mark.type === border;
|
|
392
|
+
};
|
|
386
393
|
return _objectSpread(_objectSpread({}, this.getProps(node)), {}, {
|
|
387
394
|
marks: node.marks.filter(function (m) {
|
|
388
395
|
return !isLinkMark(m) || _this6.allowMediaLinking === true;
|
|
389
396
|
}),
|
|
390
397
|
isLinkMark: isLinkMark,
|
|
398
|
+
isBorderMark: isBorderMark,
|
|
391
399
|
allowAltTextOnImages: this.allowAltTextOnImages,
|
|
392
400
|
featureFlags: this.media && this.media.featureFlags,
|
|
393
401
|
shouldOpenMediaViewer: this.shouldOpenMediaViewer,
|
|
@@ -496,6 +504,7 @@ var ReactSerializer = /*#__PURE__*/function () {
|
|
|
496
504
|
content: node.content ? node.content.toJSON() : undefined,
|
|
497
505
|
allowHeadingAnchorLinks: this.allowHeadingAnchorLinks,
|
|
498
506
|
allowCopyToClipboard: this.allowCopyToClipboard,
|
|
507
|
+
allowWrapCodeBlock: this.allowWrapCodeBlock,
|
|
499
508
|
allowPlaceholderText: this.allowPlaceholderText,
|
|
500
509
|
rendererAppearance: this.appearance,
|
|
501
510
|
fireAnalyticsEvent: this.fireAnalyticsEvent,
|
|
@@ -10,7 +10,10 @@ export default function BlockCard(props) {
|
|
|
10
10
|
data = props.data,
|
|
11
11
|
eventHandlers = props.eventHandlers,
|
|
12
12
|
portal = props.portal,
|
|
13
|
-
rendererAppearance = props.rendererAppearance
|
|
13
|
+
rendererAppearance = props.rendererAppearance,
|
|
14
|
+
smartLinks = props.smartLinks;
|
|
15
|
+
var _ref = smartLinks || {},
|
|
16
|
+
showServerActions = _ref.showServerActions;
|
|
14
17
|
var onClick = getCardClickHandler(eventHandlers, url);
|
|
15
18
|
var platform = useMemo(function () {
|
|
16
19
|
return getPlatform(rendererAppearance);
|
|
@@ -31,6 +34,7 @@ export default function BlockCard(props) {
|
|
|
31
34
|
}, cardProps), /*#__PURE__*/React.createElement(Card, _extends({
|
|
32
35
|
appearance: "block",
|
|
33
36
|
showActions: rendererAppearance !== 'mobile',
|
|
34
|
-
platform: platform
|
|
37
|
+
platform: platform,
|
|
38
|
+
showServerActions: showServerActions
|
|
35
39
|
}, cardProps))));
|
|
36
40
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
/** @jsx jsx */
|
|
3
|
+
import { useState } from 'react';
|
|
2
4
|
import { jsx } from '@emotion/react';
|
|
3
5
|
import { injectIntl } from 'react-intl-next';
|
|
4
6
|
import { CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
@@ -10,18 +12,28 @@ function CodeBlock(props) {
|
|
|
10
12
|
language = props.language,
|
|
11
13
|
_props$allowCopyToCli = props.allowCopyToClipboard,
|
|
12
14
|
allowCopyToClipboard = _props$allowCopyToCli === void 0 ? false : _props$allowCopyToCli,
|
|
15
|
+
_props$allowWrapCodeB = props.allowWrapCodeBlock,
|
|
16
|
+
allowWrapCodeBlock = _props$allowWrapCodeB === void 0 ? false : _props$allowWrapCodeB,
|
|
13
17
|
codeBidiWarningTooltipEnabled = props.codeBidiWarningTooltipEnabled;
|
|
14
18
|
var codeBidiWarningLabel = props.intl.formatMessage(codeBidiWarningMessages.label);
|
|
15
19
|
var className = [CodeBlockSharedCssClassName.CODEBLOCK_CONTAINER, props.className].join(' ');
|
|
20
|
+
var _useState = useState(false),
|
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
+
wrapLongLines = _useState2[0],
|
|
23
|
+
setWrapLongLines = _useState2[1];
|
|
16
24
|
return jsx(CodeBlockContainer, {
|
|
17
|
-
|
|
25
|
+
allowCopyToClipboard: allowCopyToClipboard,
|
|
26
|
+
allowWrapCodeBlock: allowWrapCodeBlock,
|
|
18
27
|
className: className,
|
|
19
|
-
|
|
28
|
+
setWrapLongLines: setWrapLongLines,
|
|
29
|
+
text: text,
|
|
30
|
+
wrapLongLines: wrapLongLines
|
|
20
31
|
}, jsx(AkCodeBlock, {
|
|
21
32
|
language: language,
|
|
22
33
|
text: text,
|
|
23
34
|
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
24
|
-
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
35
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled,
|
|
36
|
+
shouldWrapLongLines: allowWrapCodeBlock && wrapLongLines
|
|
25
37
|
}));
|
|
26
38
|
}
|
|
27
39
|
export default injectIntl(CodeBlock);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx, css } from '@emotion/react';
|
|
3
|
+
import CopyButton from './codeBlockCopyButton';
|
|
4
|
+
import CodeWrapButton from './codeBlockWrapButton';
|
|
5
|
+
import { N0, N20, N30, N700 } from '@atlaskit/theme/colors';
|
|
6
|
+
var codeBlockButtonsWrapper = css({
|
|
7
|
+
position: 'sticky',
|
|
8
|
+
top: '0px'
|
|
9
|
+
});
|
|
10
|
+
var codeBlockButtonsStyle = css({
|
|
11
|
+
display: 'flex',
|
|
12
|
+
justifyContent: 'flex-end',
|
|
13
|
+
position: 'absolute',
|
|
14
|
+
height: '0',
|
|
15
|
+
width: '100%',
|
|
16
|
+
right: '6px',
|
|
17
|
+
top: '4px',
|
|
18
|
+
padding: '2px',
|
|
19
|
+
button: {
|
|
20
|
+
height: '32px',
|
|
21
|
+
width: '32px',
|
|
22
|
+
border: "2px solid ".concat("var(--ds-border-inverse, ".concat(N0, ")")),
|
|
23
|
+
borderRadius: '4px',
|
|
24
|
+
marginLeft: '4px',
|
|
25
|
+
padding: '2px',
|
|
26
|
+
background: "".concat("var(--ds-background-neutral-subtle, ".concat(N20, ")")),
|
|
27
|
+
color: "var(--ds-icon, rgb(66, 82, 110))",
|
|
28
|
+
'&:hover': {
|
|
29
|
+
borderWidth: '2px',
|
|
30
|
+
backgroundColor: "".concat("var(--ds-background-neutral-hovered, ".concat(N30, ")")),
|
|
31
|
+
height: '32px',
|
|
32
|
+
width: '32px'
|
|
33
|
+
},
|
|
34
|
+
'&.clicked': {
|
|
35
|
+
backgroundColor: "".concat("var(--ds-background-neutral-bold-pressed, ".concat(N700, ")")),
|
|
36
|
+
borderRadius: '4px',
|
|
37
|
+
color: "".concat("var(--ds-icon-inverse, ".concat(N0, ")"), " !important")
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
var CodeBlockButtonContainer = function CodeBlockButtonContainer(_ref) {
|
|
42
|
+
var allowCopyToClipboard = _ref.allowCopyToClipboard,
|
|
43
|
+
allowWrapCodeBlock = _ref.allowWrapCodeBlock,
|
|
44
|
+
setWrapLongLines = _ref.setWrapLongLines,
|
|
45
|
+
text = _ref.text,
|
|
46
|
+
wrapLongLines = _ref.wrapLongLines;
|
|
47
|
+
return jsx("div", {
|
|
48
|
+
css: codeBlockButtonsWrapper
|
|
49
|
+
}, jsx("div", {
|
|
50
|
+
css: codeBlockButtonsStyle
|
|
51
|
+
}, allowWrapCodeBlock && jsx(CodeWrapButton, {
|
|
52
|
+
setWrapLongLines: setWrapLongLines,
|
|
53
|
+
wrapLongLines: wrapLongLines
|
|
54
|
+
}), allowCopyToClipboard && jsx(CopyButton, {
|
|
55
|
+
content: text
|
|
56
|
+
})));
|
|
57
|
+
};
|
|
58
|
+
export default CodeBlockButtonContainer;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
var _templateObject;
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
|
|
5
4
|
import { jsx, css } from '@emotion/react';
|
|
6
5
|
import { overflowShadow, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
7
6
|
import { N20, DN50 } from '@atlaskit/theme/colors';
|
|
8
7
|
import { themed } from '@atlaskit/theme/components';
|
|
9
8
|
import { fontSize, gridSize } from '@atlaskit/theme/constants';
|
|
10
9
|
import { CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
11
|
-
import
|
|
10
|
+
import CodeBlockButtonContainer from './codeBlockButtonContainer';
|
|
12
11
|
var codeBlockStyleOverrides = function codeBlockStyleOverrides(props) {
|
|
13
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n tab-size: 4;\n background-color: ", ";\n\n ", " {\n font-size: ", ";\n line-height: 1.5rem;\n background-image: ", ";\n background-attachment: local, local, local, local, scroll, scroll, scroll,\n scroll;\n background-position: 0 0, 0 0, 100% 0, 100% 0, 100% 0, 100% 0, 0 0, 0 0;\n }\n "])), themed({
|
|
12
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n tab-size: 4;\n background-color: ", ";\n\n &:hover {\n button {\n opacity: 1;\n }\n }\n\n button {\n opacity: 0;\n transition: opacity 0.2s ease 0s;\n }\n\n ", " {\n font-size: ", ";\n line-height: 1.5rem;\n background-image: ", ";\n background-attachment: local, local, local, local, scroll, scroll, scroll,\n scroll;\n background-position: 0 0, 0 0, 100% 0, 100% 0, 100% 0, 100% 0, 0 0, 0 0;\n }\n "])), themed({
|
|
14
13
|
light: "var(--ds-surface-raised, ".concat(N20, ")"),
|
|
15
14
|
dark: "var(--ds-surface-raised, ".concat(DN50, ")")
|
|
16
15
|
})(props), CodeBlockSharedCssClassName.DS_CODEBLOCK, relativeFontSizeToBase16(fontSize()), overflowShadow({
|
|
@@ -22,15 +21,22 @@ var codeBlockStyleOverrides = function codeBlockStyleOverrides(props) {
|
|
|
22
21
|
}));
|
|
23
22
|
};
|
|
24
23
|
var CodeBlockContainer = function CodeBlockContainer(_ref) {
|
|
25
|
-
var
|
|
24
|
+
var allowCopyToClipboard = _ref.allowCopyToClipboard,
|
|
25
|
+
allowWrapCodeBlock = _ref.allowWrapCodeBlock,
|
|
26
|
+
children = _ref.children,
|
|
26
27
|
className = _ref.className,
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
setWrapLongLines = _ref.setWrapLongLines,
|
|
29
|
+
text = _ref.text,
|
|
30
|
+
wrapLongLines = _ref.wrapLongLines;
|
|
29
31
|
return jsx("div", {
|
|
30
32
|
className: className,
|
|
31
33
|
css: codeBlockStyleOverrides
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
}, jsx(CodeBlockButtonContainer, {
|
|
35
|
+
allowCopyToClipboard: allowCopyToClipboard,
|
|
36
|
+
allowWrapCodeBlock: allowWrapCodeBlock,
|
|
37
|
+
setWrapLongLines: setWrapLongLines,
|
|
38
|
+
text: text,
|
|
39
|
+
wrapLongLines: wrapLongLines
|
|
40
|
+
}), children);
|
|
35
41
|
};
|
|
36
42
|
export default CodeBlockContainer;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import { injectIntl } from 'react-intl-next';
|
|
6
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
7
|
+
import Button from '@atlaskit/button/custom-theme-button';
|
|
8
|
+
import CopyIcon from '@atlaskit/icon/glyph/copy';
|
|
9
|
+
import { copyTextToClipboard } from '../../../utils/clipboard';
|
|
10
|
+
import { codeBlockButtonMessages } from '@atlaskit/editor-common/messages';
|
|
11
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../../../../analytics/enums';
|
|
12
|
+
import AnalyticsContext from '../../../../analytics/analyticsContext';
|
|
13
|
+
var CopyButton = function CopyButton(_ref) {
|
|
14
|
+
var content = _ref.content,
|
|
15
|
+
intl = _ref.intl;
|
|
16
|
+
var _useState = useState(intl.formatMessage(codeBlockButtonMessages.copyCodeToClipboard)),
|
|
17
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
18
|
+
tooltip = _useState2[0],
|
|
19
|
+
setTooltip = _useState2[1];
|
|
20
|
+
var _useState3 = useState('copy-to-clipboard'),
|
|
21
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
22
|
+
className = _useState4[0],
|
|
23
|
+
setClassName = _useState4[1];
|
|
24
|
+
var onMouseLeave = function onMouseLeave() {
|
|
25
|
+
setTooltip(intl.formatMessage(codeBlockButtonMessages.copyCodeToClipboard));
|
|
26
|
+
setClassName('copy-to-clipboard');
|
|
27
|
+
};
|
|
28
|
+
return jsx(AnalyticsContext.Consumer, null, function (_ref2) {
|
|
29
|
+
var fireAnalyticsEvent = _ref2.fireAnalyticsEvent;
|
|
30
|
+
return jsx("span", null, jsx(Tooltip, {
|
|
31
|
+
content: tooltip,
|
|
32
|
+
hideTooltipOnClick: false,
|
|
33
|
+
position: "top"
|
|
34
|
+
}, jsx("div", {
|
|
35
|
+
onMouseLeave: onMouseLeave
|
|
36
|
+
}, jsx(Button, {
|
|
37
|
+
appearance: "subtle",
|
|
38
|
+
"aria-haspopup": true,
|
|
39
|
+
"aria-label": tooltip,
|
|
40
|
+
className: className,
|
|
41
|
+
iconBefore: jsx(CopyIcon, {
|
|
42
|
+
label: tooltip
|
|
43
|
+
}),
|
|
44
|
+
onClick: function onClick() {
|
|
45
|
+
fireAnalyticsEvent({
|
|
46
|
+
action: ACTION.CLICKED,
|
|
47
|
+
actionSubject: ACTION_SUBJECT.BUTTON,
|
|
48
|
+
actionSubjectId: ACTION_SUBJECT_ID.CODEBLOCK_COPY,
|
|
49
|
+
eventType: EVENT_TYPE.UI
|
|
50
|
+
});
|
|
51
|
+
copyTextToClipboard(content);
|
|
52
|
+
setTooltip(intl.formatMessage(codeBlockButtonMessages.copiedCodeToClipboard));
|
|
53
|
+
setClassName('copy-to-clipboard clicked');
|
|
54
|
+
},
|
|
55
|
+
spacing: "compact"
|
|
56
|
+
}))));
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
export default injectIntl(CopyButton);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { injectIntl } from 'react-intl-next';
|
|
5
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
6
|
+
import Button from '@atlaskit/button/custom-theme-button';
|
|
7
|
+
import Icon from '@atlaskit/icon';
|
|
8
|
+
import { codeBlockButtonMessages } from '@atlaskit/editor-common/messages';
|
|
9
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../../../../analytics/enums';
|
|
10
|
+
import AnalyticsContext from '../../../../analytics/analyticsContext';
|
|
11
|
+
var WrapIcon = function WrapIcon() {
|
|
12
|
+
return jsx("svg", {
|
|
13
|
+
width: "24",
|
|
14
|
+
height: "24",
|
|
15
|
+
fill: "none",
|
|
16
|
+
viewBox: "0 0 24 24"
|
|
17
|
+
}, jsx("g", {
|
|
18
|
+
fill: "currentColor",
|
|
19
|
+
clipPath: "url(#clip0_654_431)"
|
|
20
|
+
}, jsx("rect", {
|
|
21
|
+
width: "24",
|
|
22
|
+
height: "24",
|
|
23
|
+
fillOpacity: "0.01"
|
|
24
|
+
}), jsx("path", {
|
|
25
|
+
d: "M20 4h-1v16h1V4ZM3 8a1 1 0 0 1 1-1h9.5a4.5 4.5 0 1 1 0 9h-2.086l.293.293a1 1 0 0 1-1.414 1.414l-2-2a1 1 0 0 1 0-1.414l2-2a1 1 0 0 1 1.414 1.414l-.293.293H13.5a2.5 2.5 0 0 0 0-5H4a1 1 0 0 1-1-1Z",
|
|
26
|
+
clipRule: "evenodd",
|
|
27
|
+
fillRule: "evenodd"
|
|
28
|
+
})));
|
|
29
|
+
};
|
|
30
|
+
var CodeBlockWrapButton = function CodeBlockWrapButton(_ref) {
|
|
31
|
+
var setWrapLongLines = _ref.setWrapLongLines,
|
|
32
|
+
wrapLongLines = _ref.wrapLongLines,
|
|
33
|
+
intl = _ref.intl;
|
|
34
|
+
var wrapMessage = intl.formatMessage(wrapLongLines ? codeBlockButtonMessages.unwrapCode : codeBlockButtonMessages.wrapCode);
|
|
35
|
+
return jsx(AnalyticsContext.Consumer, null, function (_ref2) {
|
|
36
|
+
var fireAnalyticsEvent = _ref2.fireAnalyticsEvent;
|
|
37
|
+
return jsx("span", null, jsx(Tooltip, {
|
|
38
|
+
content: wrapMessage,
|
|
39
|
+
hideTooltipOnClick: false,
|
|
40
|
+
position: "top"
|
|
41
|
+
}, jsx(Button, {
|
|
42
|
+
appearance: "subtle",
|
|
43
|
+
"aria-haspopup": true,
|
|
44
|
+
"aria-label": wrapMessage,
|
|
45
|
+
className: "wrap-code ".concat(wrapLongLines ? 'clicked' : ''),
|
|
46
|
+
iconBefore: jsx(Icon, {
|
|
47
|
+
glyph: WrapIcon,
|
|
48
|
+
label: ""
|
|
49
|
+
}),
|
|
50
|
+
isSelected: wrapLongLines,
|
|
51
|
+
onClick: function onClick() {
|
|
52
|
+
fireAnalyticsEvent({
|
|
53
|
+
action: ACTION.CLICKED,
|
|
54
|
+
actionSubject: ACTION_SUBJECT.BUTTON,
|
|
55
|
+
actionSubjectId: ACTION_SUBJECT_ID.CODEBLOCK_WRAP,
|
|
56
|
+
attributes: {
|
|
57
|
+
wrapped: !wrapLongLines
|
|
58
|
+
},
|
|
59
|
+
eventType: EVENT_TYPE.UI
|
|
60
|
+
});
|
|
61
|
+
setWrapLongLines(!wrapLongLines);
|
|
62
|
+
},
|
|
63
|
+
spacing: "compact"
|
|
64
|
+
})));
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
export default injectIntl(CodeBlockWrapButton);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
4
|
/** @jsx jsx */
|
|
4
|
-
import { Fragment, memo } from 'react';
|
|
5
|
-
import { lazy, Suspense } from 'react';
|
|
5
|
+
import { Fragment, lazy, memo, Suspense, useState } from 'react';
|
|
6
6
|
import { jsx } from '@emotion/react';
|
|
7
7
|
import { CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
8
8
|
import { useInViewport } from '../../hooks/use-in-viewport';
|
|
@@ -34,6 +34,8 @@ var WindowedCodeBlock = function WindowedCodeBlock(_ref2) {
|
|
|
34
34
|
var text = _ref2.text,
|
|
35
35
|
language = _ref2.language,
|
|
36
36
|
allowCopyToClipboard = _ref2.allowCopyToClipboard,
|
|
37
|
+
_ref2$allowWrapCodeBl = _ref2.allowWrapCodeBlock,
|
|
38
|
+
allowWrapCodeBlock = _ref2$allowWrapCodeBl === void 0 ? false : _ref2$allowWrapCodeBl,
|
|
37
39
|
codeBidiWarningTooltipEnabled = _ref2.codeBidiWarningTooltipEnabled,
|
|
38
40
|
rootClassName = _ref2.className;
|
|
39
41
|
var _useBidiWarnings = useBidiWarnings({
|
|
@@ -50,17 +52,25 @@ var WindowedCodeBlock = function WindowedCodeBlock(_ref2) {
|
|
|
50
52
|
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled,
|
|
51
53
|
className: rootClassName
|
|
52
54
|
});
|
|
55
|
+
var _useState = useState(false),
|
|
56
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
57
|
+
wrapLongLines = _useState2[0],
|
|
58
|
+
setWrapLongLines = _useState2[1];
|
|
53
59
|
return isInViewport ? jsx(Fragment, null, jsx(Suspense, {
|
|
54
60
|
fallback: memoizedLightWeightCodeBlock
|
|
55
61
|
}, jsx(CodeBlockContainer, {
|
|
62
|
+
allowCopyToClipboard: allowCopyToClipboard,
|
|
63
|
+
allowWrapCodeBlock: allowWrapCodeBlock,
|
|
56
64
|
className: className,
|
|
65
|
+
setWrapLongLines: setWrapLongLines,
|
|
57
66
|
text: text,
|
|
58
|
-
|
|
67
|
+
wrapLongLines: wrapLongLines
|
|
59
68
|
}, jsx(LazyAkCodeBlock, {
|
|
60
69
|
language: language,
|
|
61
70
|
text: text,
|
|
62
71
|
codeBidiWarningLabel: warningLabel,
|
|
63
|
-
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
72
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled,
|
|
73
|
+
shouldWrapLongLines: allowWrapCodeBlock && wrapLongLines
|
|
64
74
|
})))) : memoizedLightWeightCodeBlock;
|
|
65
75
|
};
|
|
66
76
|
export default WindowedCodeBlock;
|
|
@@ -23,12 +23,14 @@ var InlineCard = function InlineCard(props) {
|
|
|
23
23
|
var featureFlags = useFeatureFlags();
|
|
24
24
|
var _ref = smartLinks || {},
|
|
25
25
|
showAuthTooltip = _ref.showAuthTooltip,
|
|
26
|
+
showServerActions = _ref.showServerActions,
|
|
26
27
|
ssr = _ref.ssr;
|
|
27
28
|
if (ssr && url) {
|
|
28
29
|
return /*#__PURE__*/React.createElement(CardSSR, {
|
|
29
30
|
appearance: "inline",
|
|
30
31
|
url: url,
|
|
31
|
-
showAuthTooltip: showAuthTooltip
|
|
32
|
+
showAuthTooltip: showAuthTooltip,
|
|
33
|
+
showServerActions: showServerActions
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
36
|
return /*#__PURE__*/React.createElement("span", {
|
|
@@ -40,7 +42,8 @@ var InlineCard = function InlineCard(props) {
|
|
|
40
42
|
}, cardProps), /*#__PURE__*/React.createElement(Card, _extends({
|
|
41
43
|
appearance: "inline",
|
|
42
44
|
showHoverPreview: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.showHoverPreview,
|
|
43
|
-
showAuthTooltip: showAuthTooltip
|
|
45
|
+
showAuthTooltip: showAuthTooltip,
|
|
46
|
+
showServerActions: showServerActions
|
|
44
47
|
}, cardProps, {
|
|
45
48
|
onResolve: function onResolve(data) {
|
|
46
49
|
if (!data.url || !data.title) {
|