@atlaskit/renderer 107.2.0 → 107.3.1
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 +19 -0
- package/dist/cjs/analytics/enums.js +61 -1
- package/dist/cjs/react/index.js +10 -1
- 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/media.js +18 -1
- package/dist/cjs/react/nodes/mediaInline.js +19 -4
- package/dist/cjs/ui/Renderer/index.js +14 -4
- package/dist/cjs/ui/Renderer/style.js +10 -4
- 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/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/media.js +18 -1
- package/dist/es2019/react/nodes/mediaInline.js +19 -4
- package/dist/es2019/ui/Renderer/index.js +14 -4
- package/dist/es2019/ui/Renderer/style.js +34 -15
- 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/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/media.js +18 -1
- package/dist/esm/react/nodes/mediaInline.js +19 -4
- package/dist/esm/ui/Renderer/index.js +14 -4
- package/dist/esm/ui/Renderer/style.js +10 -4
- 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/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/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/ui/Renderer/style.d.ts +1 -0
- package/dist/types/ui/renderer-props.d.ts +1 -0
- package/package.json +11 -11
- package/report.api.md +19 -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,6 +7,7 @@ import { jsx } from '@emotion/react';
|
|
|
7
7
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
8
8
|
import { mediaLinkStyle } from '@atlaskit/editor-common/ui';
|
|
9
9
|
import { MediaCard } from '../../ui/MediaCard';
|
|
10
|
+
import { hexToEditorBorderPaletteColor } from '@atlaskit/editor-palette';
|
|
10
11
|
import { getEventHandler } from '../../utils';
|
|
11
12
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
12
13
|
import { MODE, PLATFORM } from '../../analytics/events';
|
|
@@ -14,6 +15,7 @@ export default class Media extends PureComponent {
|
|
|
14
15
|
constructor(...args) {
|
|
15
16
|
super(...args);
|
|
16
17
|
_defineProperty(this, "renderCard", (providers = {}) => {
|
|
18
|
+
var _borderMark$attrs$col, _borderMark$attrs$siz;
|
|
17
19
|
const {
|
|
18
20
|
mediaProvider,
|
|
19
21
|
contextIdentifierProvider
|
|
@@ -26,6 +28,9 @@ export default class Media extends PureComponent {
|
|
|
26
28
|
enableDownloadButton,
|
|
27
29
|
ssr
|
|
28
30
|
} = this.props;
|
|
31
|
+
const borderMark = this.props.marks.find(this.props.isBorderMark);
|
|
32
|
+
const borderColor = (_borderMark$attrs$col = borderMark === null || borderMark === void 0 ? void 0 : borderMark.attrs.color) !== null && _borderMark$attrs$col !== void 0 ? _borderMark$attrs$col : '';
|
|
33
|
+
const borderWidth = (_borderMark$attrs$siz = borderMark === null || borderMark === void 0 ? void 0 : borderMark.attrs.size) !== null && _borderMark$attrs$siz !== void 0 ? _borderMark$attrs$siz : 0;
|
|
29
34
|
const linkMark = this.props.marks.find(this.props.isLinkMark);
|
|
30
35
|
const linkHref = linkMark === null || linkMark === void 0 ? void 0 : linkMark.attrs.href;
|
|
31
36
|
const eventHandlers = linkHref ? undefined : this.props.eventHandlers;
|
|
@@ -41,13 +46,25 @@ export default class Media extends PureComponent {
|
|
|
41
46
|
shouldEnableDownloadButton: enableDownloadButton,
|
|
42
47
|
ssr: ssr
|
|
43
48
|
}));
|
|
49
|
+
const paletteColorValue = hexToEditorBorderPaletteColor(borderColor) || borderColor;
|
|
50
|
+
const mediaComponentWithBorder = borderMark ? jsx("div", {
|
|
51
|
+
"data-mark-type": "border",
|
|
52
|
+
"data-color": borderColor,
|
|
53
|
+
"data-size": borderWidth,
|
|
54
|
+
style: {
|
|
55
|
+
borderColor: paletteColorValue,
|
|
56
|
+
borderWidth: `${borderWidth}px`,
|
|
57
|
+
borderStyle: 'solid',
|
|
58
|
+
borderRadius: `${borderWidth * 2}px`
|
|
59
|
+
}
|
|
60
|
+
}, mediaComponent) : mediaComponent;
|
|
44
61
|
return linkHref ? jsx("a", {
|
|
45
62
|
href: linkHref,
|
|
46
63
|
rel: "noreferrer noopener",
|
|
47
64
|
onClick: this.handleMediaLinkClick,
|
|
48
65
|
"data-block-link": linkHref,
|
|
49
66
|
css: mediaLinkStyle
|
|
50
|
-
},
|
|
67
|
+
}, mediaComponentWithBorder) : mediaComponentWithBorder;
|
|
51
68
|
});
|
|
52
69
|
_defineProperty(this, "handleMediaLinkClick", event => {
|
|
53
70
|
const {
|
|
@@ -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
|
}));
|
|
@@ -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.1";
|
|
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,8 +270,10 @@ export class Renderer extends PureComponent {
|
|
|
269
270
|
allowPlaceholderText,
|
|
270
271
|
allowColumnSorting,
|
|
271
272
|
allowCopyToClipboard,
|
|
273
|
+
allowWrapCodeBlock,
|
|
272
274
|
allowCustomPanels
|
|
273
275
|
} = this.props;
|
|
276
|
+
const featureFlags = this.featureFlags(this.props.featureFlags);
|
|
274
277
|
const allowNestedHeaderLinks = isNestedHeaderLinksEnabled(allowHeadingAnchorLinks);
|
|
275
278
|
/**
|
|
276
279
|
* Handle clicks inside renderer. If the click isn't on media, in the media picker, or on a
|
|
@@ -318,7 +321,7 @@ export class Renderer extends PureComponent {
|
|
|
318
321
|
}
|
|
319
322
|
};
|
|
320
323
|
try {
|
|
321
|
-
var _this$featureFlags, _this$featureFlags$fe, _this$featureFlags$fe2;
|
|
324
|
+
var _featureFlags$feature, _this$featureFlags, _this$featureFlags$fe, _this$featureFlags$fe2;
|
|
322
325
|
const schema = this.getSchema(this.props.schema, this.props.adfStage);
|
|
323
326
|
const {
|
|
324
327
|
result,
|
|
@@ -341,8 +344,10 @@ export class Renderer extends PureComponent {
|
|
|
341
344
|
allowNestedHeaderLinks: allowNestedHeaderLinks,
|
|
342
345
|
allowColumnSorting: allowColumnSorting,
|
|
343
346
|
allowCopyToClipboard: allowCopyToClipboard,
|
|
347
|
+
allowWrapCodeBlock: allowWrapCodeBlock,
|
|
344
348
|
allowCustomPanels: allowCustomPanels,
|
|
345
349
|
allowPlaceholderText: allowPlaceholderText,
|
|
350
|
+
useFragmentMarkBreakoutWidthStylingFix: (_featureFlags$feature = featureFlags.featureFlags.useFragmentMarkBreakoutWidthStylingFix) !== null && _featureFlags$feature !== void 0 ? _featureFlags$feature : true,
|
|
346
351
|
innerRef: this.editorRef,
|
|
347
352
|
onClick: handleWrapperOnClick,
|
|
348
353
|
onMouseDown: this.onMouseDownEditView
|
|
@@ -365,15 +370,18 @@ export class Renderer extends PureComponent {
|
|
|
365
370
|
});
|
|
366
371
|
return jsx(Fragment, null, reRenderTracking, rendererResult);
|
|
367
372
|
} catch (e) {
|
|
373
|
+
var _featureFlags$feature2;
|
|
368
374
|
if (onError) {
|
|
369
375
|
onError(e);
|
|
370
376
|
}
|
|
371
377
|
return jsx(RendererWrapper, {
|
|
372
378
|
appearance: appearance,
|
|
373
379
|
allowCopyToClipboard: allowCopyToClipboard,
|
|
380
|
+
allowWrapCodeBlock: allowWrapCodeBlock,
|
|
374
381
|
allowPlaceholderText: allowPlaceholderText,
|
|
375
382
|
allowColumnSorting: allowColumnSorting,
|
|
376
383
|
allowNestedHeaderLinks: allowNestedHeaderLinks,
|
|
384
|
+
useFragmentMarkBreakoutWidthStylingFix: (_featureFlags$feature2 = featureFlags.featureFlags.useFragmentMarkBreakoutWidthStylingFix) !== null && _featureFlags$feature2 !== void 0 ? _featureFlags$feature2 : true,
|
|
377
385
|
onClick: handleWrapperOnClick
|
|
378
386
|
}, jsx(UnsupportedBlock, null));
|
|
379
387
|
}
|
|
@@ -422,7 +430,8 @@ const RendererWrapper = /*#__PURE__*/React.memo(props => {
|
|
|
422
430
|
appearance,
|
|
423
431
|
children,
|
|
424
432
|
onClick,
|
|
425
|
-
onMouseDown
|
|
433
|
+
onMouseDown,
|
|
434
|
+
useFragmentMarkBreakoutWidthStylingFix
|
|
426
435
|
} = props;
|
|
427
436
|
return jsx(WidthProvider, {
|
|
428
437
|
className: "ak-renderer-wrapper"
|
|
@@ -435,7 +444,8 @@ const RendererWrapper = /*#__PURE__*/React.memo(props => {
|
|
|
435
444
|
css: rendererStyles({
|
|
436
445
|
appearance,
|
|
437
446
|
allowNestedHeaderLinks,
|
|
438
|
-
allowColumnSorting: !!allowColumnSorting
|
|
447
|
+
allowColumnSorting: !!allowColumnSorting,
|
|
448
|
+
useFragmentMarkBreakoutWidthStylingFix
|
|
439
449
|
})
|
|
440
450
|
}, children)));
|
|
441
451
|
});
|
|
@@ -273,6 +273,30 @@ const fullWidthStyles = ({
|
|
|
273
273
|
}
|
|
274
274
|
`;
|
|
275
275
|
};
|
|
276
|
+
const breakoutWidthStyle = useFragmentMarkBreakoutWidthStylingFix => {
|
|
277
|
+
if (useFragmentMarkBreakoutWidthStylingFix) {
|
|
278
|
+
return css`
|
|
279
|
+
*:not([data-mark-type='fragment'])
|
|
280
|
+
.${TableSharedCssClassName.TABLE_CONTAINER} {
|
|
281
|
+
width: 100% !important;
|
|
282
|
+
left: 0 !important;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
[data-mark-type='fragment']
|
|
286
|
+
*
|
|
287
|
+
.${TableSharedCssClassName.TABLE_CONTAINER} {
|
|
288
|
+
width: 100% !important;
|
|
289
|
+
left: 0 !important;
|
|
290
|
+
}
|
|
291
|
+
`;
|
|
292
|
+
}
|
|
293
|
+
return css`
|
|
294
|
+
* .${TableSharedCssClassName.TABLE_CONTAINER} {
|
|
295
|
+
width: 100% !important;
|
|
296
|
+
left: 0 !important;
|
|
297
|
+
}
|
|
298
|
+
`;
|
|
299
|
+
};
|
|
276
300
|
export const rendererStyles = wrapperProps => theme => {
|
|
277
301
|
// This is required to be compatible with styled-components prop structure.
|
|
278
302
|
const themeProps = {
|
|
@@ -435,10 +459,7 @@ export const rendererStyles = wrapperProps => theme => {
|
|
|
435
459
|
|
|
436
460
|
/* Breakout for tables and extensions */
|
|
437
461
|
.${RendererCssClassName.DOCUMENT} > {
|
|
438
|
-
|
|
439
|
-
width: 100% !important;
|
|
440
|
-
left: 0 !important;
|
|
441
|
-
}
|
|
462
|
+
${breakoutWidthStyle(wrapperProps.useFragmentMarkBreakoutWidthStylingFix)}
|
|
442
463
|
|
|
443
464
|
* .${RendererCssClassName.EXTENSION_OVERFLOW_CONTAINER} {
|
|
444
465
|
overflow-x: auto;
|
|
@@ -640,17 +661,6 @@ export const rendererStyles = wrapperProps => theme => {
|
|
|
640
661
|
&:first-child {
|
|
641
662
|
margin-top: 0;
|
|
642
663
|
}
|
|
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
664
|
}
|
|
655
665
|
|
|
656
666
|
${getLightWeightCodeBlockStylesForRootRendererStyleSheet()}
|
|
@@ -667,6 +677,15 @@ export const rendererStyles = wrapperProps => theme => {
|
|
|
667
677
|
margin-left: 0;
|
|
668
678
|
}
|
|
669
679
|
}
|
|
680
|
+
|
|
681
|
+
& .MediaGroup,
|
|
682
|
+
& .code-block {
|
|
683
|
+
margin-top: ${blockNodesVerticalMargin};
|
|
684
|
+
|
|
685
|
+
&:first-child {
|
|
686
|
+
margin-top: 0;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
670
689
|
}
|
|
671
690
|
|
|
672
691
|
& 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,
|
|
@@ -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);
|