@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
|
@@ -55,7 +55,7 @@ exports.NORMAL_SEVERITY_THRESHOLD = NORMAL_SEVERITY_THRESHOLD;
|
|
|
55
55
|
var DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
56
56
|
exports.DEGRADED_SEVERITY_THRESHOLD = DEGRADED_SEVERITY_THRESHOLD;
|
|
57
57
|
var packageName = "@atlaskit/renderer";
|
|
58
|
-
var packageVersion = "107.
|
|
58
|
+
var packageVersion = "107.3.1";
|
|
59
59
|
var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
60
60
|
(0, _inherits2.default)(Renderer, _PureComponent);
|
|
61
61
|
var _super = _createSuper(Renderer);
|
|
@@ -267,6 +267,7 @@ var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
267
267
|
emojiResourceConfig: props.emojiResourceConfig,
|
|
268
268
|
smartLinks: props.smartLinks,
|
|
269
269
|
allowCopyToClipboard: props.allowCopyToClipboard,
|
|
270
|
+
allowWrapCodeBlock: props.allowWrapCodeBlock,
|
|
270
271
|
allowCustomPanels: props.allowCustomPanels,
|
|
271
272
|
allowAnnotations: props.allowAnnotations,
|
|
272
273
|
allowSelectAllTrap: props.allowSelectAllTrap,
|
|
@@ -294,7 +295,9 @@ var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
294
295
|
allowPlaceholderText = _this$props.allowPlaceholderText,
|
|
295
296
|
allowColumnSorting = _this$props.allowColumnSorting,
|
|
296
297
|
allowCopyToClipboard = _this$props.allowCopyToClipboard,
|
|
298
|
+
allowWrapCodeBlock = _this$props.allowWrapCodeBlock,
|
|
297
299
|
allowCustomPanels = _this$props.allowCustomPanels;
|
|
300
|
+
var featureFlags = this.featureFlags(this.props.featureFlags);
|
|
298
301
|
var allowNestedHeaderLinks = (0, _links.isNestedHeaderLinksEnabled)(allowHeadingAnchorLinks);
|
|
299
302
|
/**
|
|
300
303
|
* Handle clicks inside renderer. If the click isn't on media, in the media picker, or on a
|
|
@@ -342,7 +345,7 @@ var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
342
345
|
}
|
|
343
346
|
};
|
|
344
347
|
try {
|
|
345
|
-
var _this$featureFlags2, _this$featureFlags2$f, _this$featureFlags2$f2;
|
|
348
|
+
var _featureFlags$feature, _this$featureFlags2, _this$featureFlags2$f, _this$featureFlags2$f2;
|
|
346
349
|
var schema = this.getSchema(this.props.schema, this.props.adfStage);
|
|
347
350
|
var _renderDocument = (0, _.renderDocument)(adfDocument, this.serializer, schema, adfStage, this.props.useSpecBasedValidator, this.id, this.fireAnalyticsEvent, this.props.unsupportedContentLevelsTracking, this.props.appearance),
|
|
348
351
|
result = _renderDocument.result,
|
|
@@ -366,8 +369,10 @@ var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
366
369
|
allowNestedHeaderLinks: allowNestedHeaderLinks,
|
|
367
370
|
allowColumnSorting: allowColumnSorting,
|
|
368
371
|
allowCopyToClipboard: allowCopyToClipboard,
|
|
372
|
+
allowWrapCodeBlock: allowWrapCodeBlock,
|
|
369
373
|
allowCustomPanels: allowCustomPanels,
|
|
370
374
|
allowPlaceholderText: allowPlaceholderText,
|
|
375
|
+
useFragmentMarkBreakoutWidthStylingFix: (_featureFlags$feature = featureFlags.featureFlags.useFragmentMarkBreakoutWidthStylingFix) !== null && _featureFlags$feature !== void 0 ? _featureFlags$feature : true,
|
|
371
376
|
innerRef: this.editorRef,
|
|
372
377
|
onClick: handleWrapperOnClick,
|
|
373
378
|
onMouseDown: this.onMouseDownEditView
|
|
@@ -390,15 +395,18 @@ var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
390
395
|
});
|
|
391
396
|
return (0, _react2.jsx)(_react.Fragment, null, reRenderTracking, rendererResult);
|
|
392
397
|
} catch (e) {
|
|
398
|
+
var _featureFlags$feature2;
|
|
393
399
|
if (onError) {
|
|
394
400
|
onError(e);
|
|
395
401
|
}
|
|
396
402
|
return (0, _react2.jsx)(RendererWrapper, {
|
|
397
403
|
appearance: appearance,
|
|
398
404
|
allowCopyToClipboard: allowCopyToClipboard,
|
|
405
|
+
allowWrapCodeBlock: allowWrapCodeBlock,
|
|
399
406
|
allowPlaceholderText: allowPlaceholderText,
|
|
400
407
|
allowColumnSorting: allowColumnSorting,
|
|
401
408
|
allowNestedHeaderLinks: allowNestedHeaderLinks,
|
|
409
|
+
useFragmentMarkBreakoutWidthStylingFix: (_featureFlags$feature2 = featureFlags.featureFlags.useFragmentMarkBreakoutWidthStylingFix) !== null && _featureFlags$feature2 !== void 0 ? _featureFlags$feature2 : true,
|
|
402
410
|
onClick: handleWrapperOnClick
|
|
403
411
|
}, (0, _react2.jsx)(_ui.UnsupportedBlock, null));
|
|
404
412
|
}
|
|
@@ -451,7 +459,8 @@ var RendererWrapper = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
451
459
|
appearance = props.appearance,
|
|
452
460
|
children = props.children,
|
|
453
461
|
onClick = props.onClick,
|
|
454
|
-
onMouseDown = props.onMouseDown
|
|
462
|
+
onMouseDown = props.onMouseDown,
|
|
463
|
+
useFragmentMarkBreakoutWidthStylingFix = props.useFragmentMarkBreakoutWidthStylingFix;
|
|
455
464
|
return (0, _react2.jsx)(_ui.WidthProvider, {
|
|
456
465
|
className: "ak-renderer-wrapper"
|
|
457
466
|
}, (0, _react2.jsx)(_ui.BaseTheme, {
|
|
@@ -463,7 +472,8 @@ var RendererWrapper = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
463
472
|
css: (0, _style.rendererStyles)({
|
|
464
473
|
appearance: appearance,
|
|
465
474
|
allowNestedHeaderLinks: allowNestedHeaderLinks,
|
|
466
|
-
allowColumnSorting: !!allowColumnSorting
|
|
475
|
+
allowColumnSorting: !!allowColumnSorting,
|
|
476
|
+
useFragmentMarkBreakoutWidthStylingFix: useFragmentMarkBreakoutWidthStylingFix
|
|
467
477
|
})
|
|
468
478
|
}, children)));
|
|
469
479
|
});
|
|
@@ -19,7 +19,7 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
|
19
19
|
var _consts = require("../../consts");
|
|
20
20
|
var _headingAnchor = require("../../react/nodes/heading-anchor");
|
|
21
21
|
var _lightWeightCodeBlock = require("../../react/nodes/codeBlock/components/lightWeightCodeBlock");
|
|
22
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
22
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
|
23
23
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
25
|
var FullPagePadding = 32;
|
|
@@ -85,13 +85,19 @@ var fullWidthStyles = function fullWidthStyles(_ref5) {
|
|
|
85
85
|
}
|
|
86
86
|
return (0, _react.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n max-width: ", "px;\n margin: 0 auto;\n\n .fabric-editor-breakout-mark,\n .pm-table-container,\n .ak-renderer-extension {\n width: 100% !important;\n }\n "])), _editorSharedStyles.akEditorFullWidthLayoutWidth);
|
|
87
87
|
};
|
|
88
|
+
var breakoutWidthStyle = function breakoutWidthStyle(useFragmentMarkBreakoutWidthStylingFix) {
|
|
89
|
+
if (useFragmentMarkBreakoutWidthStylingFix) {
|
|
90
|
+
return (0, _react.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n *:not([data-mark-type='fragment'])\n .", " {\n width: 100% !important;\n left: 0 !important;\n }\n\n [data-mark-type='fragment']\n *\n .", " {\n width: 100% !important;\n left: 0 !important;\n }\n "])), _styles.TableSharedCssClassName.TABLE_CONTAINER, _styles.TableSharedCssClassName.TABLE_CONTAINER);
|
|
91
|
+
}
|
|
92
|
+
return (0, _react.css)(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n * .", " {\n width: 100% !important;\n left: 0 !important;\n }\n "])), _styles.TableSharedCssClassName.TABLE_CONTAINER);
|
|
93
|
+
};
|
|
88
94
|
var rendererStyles = function rendererStyles(wrapperProps) {
|
|
89
95
|
return function (theme) {
|
|
90
96
|
// This is required to be compatible with styled-components prop structure.
|
|
91
97
|
var themeProps = {
|
|
92
98
|
theme: theme
|
|
93
99
|
};
|
|
94
|
-
return (0, _react.css)(
|
|
100
|
+
return (0, _react.css)(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n font-size: ", "px;\n line-height: 1.5rem;\n color: ", ";\n\n .", "::after {\n // we add a clearfix after ak-renderer-document in order to\n // contain internal floats (such as media images that are \"wrap-left\")\n // to just the renderer (and not spill outside of it)\n content: '';\n visibility: hidden;\n display: block;\n height: 0;\n clear: both;\n }\n\n ", "\n ", "\n\n & h1 {\n ", "\n }\n\n & h2 {\n ", "\n }\n\n & h3 {\n ", "\n }\n\n & h4 {\n ", "\n }\n\n & h5 {\n ", "\n }\n\n & h6 {\n ", "\n }\n\n & span.akActionMark {\n color: ", ";\n text-decoration: none;\n\n &:hover {\n color: ", ";\n text-decoration: underline;\n }\n\n &:active {\n color: ", ";\n }\n }\n\n & span.akActionMark {\n cursor: pointer;\n }\n\n & span[data-placeholder] {\n color: ", ";\n }\n\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", ";\n ", "\n\n & .UnknownBlock {\n font-family: ", ";\n font-size: ", ";\n font-weight: 400;\n white-space: pre-wrap;\n word-wrap: break-word;\n }\n\n & span.date-node {\n background: ", ";\n border-radius: ", "px;\n color: ", ";\n padding: 2px 4px;\n margin: 0 1px;\n transition: background 0.3s;\n }\n\n & span.date-node-highlighted {\n background: ", ";\n color: ", ";\n }\n\n & .renderer-image {\n max-width: 100%;\n display: block;\n margin: ", "px 0;\n }\n\n .", ".rich-media-wrapped\n + .", ":not(.rich-media-wrapped) {\n clear: both;\n }\n\n & .code-block,\n & blockquote,\n & hr,\n & > div > div:not(.rich-media-wrapped),\n .", ".rich-media-wrapped\n + .rich-media-wrapped\n + *:not(.rich-media-wrapped),\n .", ".rich-media-wrapped + div:not(.rich-media-wrapped),\n .", ".image-align-start,\n .", ".image-center,\n .", ".image-align-end {\n clear: both;\n }\n\n & .rich-media-wrapped {\n & + h1,\n & + h2,\n & + h3,\n & + h4,\n & + h5,\n & + h6 {\n margin-top: 8px;\n }\n }\n\n ", "\n /* plugin styles */\n ", " &\n div[class^='image-wrap-'] + div[class^='image-wrap-'] {\n margin-left: 0;\n margin-right: 0;\n }\n\n /* Breakout for tables and extensions */\n .", " > {\n ", "\n\n * .", " {\n overflow-x: auto;\n }\n\n & .", ":first-child {\n margin-top: 0;\n }\n }\n\n .", " {\n .", " {\n margin-top: ", ";\n }\n\n .", " {\n margin-left: 50%;\n transform: translateX(-50%);\n }\n\n .", " {\n overflow-x: auto;\n }\n\n .", "\n .", " {\n display: flex;\n }\n }\n\n ", "\n\n .", " .", " {\n z-index: 0;\n transition: all 0.1s linear;\n display: flex; /* needed to avoid position: fixed jumpiness in Chrome */\n\n /** Shadow overrides */\n &.", "::after,\n &.", "::before {\n top: ", "px;\n height: calc(100% - ", "px);\n z-index: ", ";\n }\n\n &\n .", ",\n &\n .", " {\n height: calc(100% - ", "px);\n }\n\n /**\n * A hack for making all the <th /> heights equal in case some have shorter\n * content than others.\n *\n * This is done to make sort buttons fill entire <th />.\n */\n table {\n height: 1px; /* will be ignored */\n ", ";\n margin-left: 0;\n margin-right: 0;\n }\n\n table tr:first-of-type {\n height: 100%;\n\n td,\n th {\n position: relative;\n }\n }\n\n table[data-number-column='true'] {\n .", " {\n background-color: ", ";\n border-right: 1px solid\n ", ";\n width: ", "px;\n text-align: center;\n color: ", ";\n font-size: ", ";\n }\n\n .fixed .", " {\n border-right: 0px none;\n }\n }\n }\n\n tr[data-header-row].fixed {\n position: fixed !important;\n display: flex;\n overflow: hidden;\n z-index: ", ";\n\n border-right: 1px solid\n ", ";\n border-bottom: 1px solid\n ", ";\n\n /* this is to compensate for the table border */\n transform: translateX(-1px);\n }\n\n .sticky > th {\n z-index: ", ";\n position: sticky !important;\n top: 0;\n }\n\n /* Make the number column header sticky */\n .sticky > td {\n position: sticky !important;\n top: 0;\n }\n\n /* add border for position: sticky\n and work around background-clip: padding-box\n bug for FF causing box-shadow bug in Chrome */\n .sticky th,\n .sticky td {\n box-shadow: 0px 1px\n ", ",\n 0px -0.5px ", ",\n inset -1px 0px ", ",\n 0px -1px ", ";\n }\n\n /* this will remove jumpiness caused in Chrome for sticky headers */\n .fixed + tr {\n min-height: 0px;\n }\n\n /*\n * We wrap CodeBlock in a grid to prevent it from overflowing the container of the renderer.\n * See ED-4159.\n */\n & .code-block {\n max-width: 100%;\n /* -ms- properties are necessary until MS supports the latest version of the grid spec */\n /* stylelint-disable value-no-vendor-prefix, declaration-block-no-duplicate-properties */\n display: -ms-grid;\n display: grid;\n -ms-grid-columns: auto 1fr;\n /* stylelint-enable */\n\n grid-template-columns: minmax(0, 1fr);\n position: relative;\n border-radius: ", "px;\n\n /*\n * The overall renderer has word-wrap: break; which causes issues with\n * code block line numbers in Safari / iOS.\n */\n word-wrap: normal;\n\n & > span {\n /* stylelint-disable value-no-vendor-prefix */\n -ms-grid-row: 1;\n -ms-grid-column: 2;\n /* stylelint-enable */\n grid-column: 1;\n }\n }\n\n & .MediaGroup,\n & .code-block {\n margin-top: ", ";\n\n &:first-child {\n margin-top: 0;\n }\n }\n\n ", "\n\n ", ";\n & [data-layout-section] {\n margin-top: ", "px;\n & > div + div {\n margin-left: ", "px;\n }\n\n @media screen and (max-width: ", "px) {\n & > div + div {\n margin-left: 0;\n }\n }\n\n & .MediaGroup,\n & .code-block {\n margin-top: ", ";\n\n &:first-child {\n margin-top: 0;\n }\n }\n }\n\n & li {\n > .code-block {\n margin: ", " 0 0 0;\n }\n > .code-block:first-child {\n margin-top: 0;\n }\n\n > div:last-of-type.code-block {\n margin-bottom: ", ";\n }\n }\n\n & :not([data-node-type='decisionList']) > li {\n ", "\n }\n "])), (0, _editorSharedStyles.editorFontSize)(themeProps), (0, _components.themed)({
|
|
95
101
|
light: "var(--ds-text, ".concat(colors.N800, ")"),
|
|
96
102
|
dark: "var(--ds-text, #B8C7E0)"
|
|
97
103
|
})(themeProps), _consts.RendererCssClassName.DOCUMENT, fullPageStyles(wrapperProps, themeProps), fullWidthStyles(wrapperProps), headingAnchorStyle('h1'), headingAnchorStyle('h2'), headingAnchorStyle('h3'), headingAnchorStyle('h4'), headingAnchorStyle('h5'), headingAnchorStyle('h6'), "var(--ds-link, ".concat(colors.B400, ")"), "var(--ds-link, ".concat(colors.B300, ")"), "var(--ds-link-pressed, ".concat(colors.B500, ")"), colors.placeholderText(themeProps), _styles.whitespaceSharedStyles, _styles.blockquoteSharedStyles, (0, _styles.headingsSharedStyles)(themeProps), (0, _styles.ruleSharedStyles)(themeProps), _styles.paragraphSharedStyles, _styles.listsSharedStyles, _styles.indentationSharedStyles, _styles.blockMarksSharedStyles, (0, _styles.codeMarkSharedStyles)(themeProps), _styles.shadowSharedStyle, _styles.dateSharedStyle, _styles.textColorStyles, _styles.tasksAndDecisionsStyles, _styles.smartCardSharedStyles, (0, _constants.fontFamily)(), (0, _editorSharedStyles.relativeFontSizeToBase16)((0, _constants.fontSize)()), (0, _components.themed)({
|
|
@@ -100,7 +106,7 @@ var rendererStyles = function rendererStyles(wrapperProps) {
|
|
|
100
106
|
})(themeProps), (0, _constants.borderRadius)(), (0, _components.themed)({
|
|
101
107
|
light: "var(--ds-text, ".concat(colors.N800, ")"),
|
|
102
108
|
dark: "var(--ds-text, ".concat(colors.DN600, ")")
|
|
103
|
-
})(themeProps), "var(--ds-background-danger, ".concat(colors.R50, ")"), "var(--ds-text-danger, ".concat(colors.R500, ")"), (0, _constants.gridSize)() * 3, _styles.richMediaClassName, _styles.richMediaClassName, _styles.richMediaClassName, _styles.richMediaClassName, _styles.richMediaClassName, _styles.richMediaClassName, _styles.richMediaClassName, alignedHeadingAnchorStyle(wrapperProps), _styles.mediaSingleSharedStyle, _consts.RendererCssClassName.DOCUMENT,
|
|
109
|
+
})(themeProps), "var(--ds-background-danger, ".concat(colors.R50, ")"), "var(--ds-text-danger, ".concat(colors.R500, ")"), (0, _constants.gridSize)() * 3, _styles.richMediaClassName, _styles.richMediaClassName, _styles.richMediaClassName, _styles.richMediaClassName, _styles.richMediaClassName, _styles.richMediaClassName, _styles.richMediaClassName, alignedHeadingAnchorStyle(wrapperProps), _styles.mediaSingleSharedStyle, _consts.RendererCssClassName.DOCUMENT, breakoutWidthStyle(wrapperProps.useFragmentMarkBreakoutWidthStylingFix), _consts.RendererCssClassName.EXTENSION_OVERFLOW_CONTAINER, _consts.RendererCssClassName.EXTENSION, _consts.RendererCssClassName.DOCUMENT, _consts.RendererCssClassName.EXTENSION, _editorSharedStyles.blockNodesVerticalMargin, _consts.RendererCssClassName.EXTENSION_CENTER_ALIGN, _styles.TableSharedCssClassName.TABLE_NODE_WRAPPER, _ui.shadowObserverClassNames.SHADOW_CONTAINER, _styles.TableSharedCssClassName.TABLE_NODE_WRAPPER, (0, _styles.tableSharedStyle)(themeProps), _consts.RendererCssClassName.DOCUMENT, _styles.TableSharedCssClassName.TABLE_CONTAINER, _ui.shadowClassNames.RIGHT_SHADOW, _ui.shadowClassNames.LEFT_SHADOW, _styles.tableMarginTop - 1, _styles.tableMarginTop, _editorSharedStyles.akEditorStickyHeaderZIndex, _ui.shadowObserverClassNames.SENTINEL_LEFT, _ui.shadowObserverClassNames.SENTINEL_RIGHT, _styles.tableMarginTop, tableSortableColumnStyle(wrapperProps), _consts.RendererCssClassName.NUMBER_COLUMN, (0, _components.themed)({
|
|
104
110
|
light: "var(--ds-background-neutral, ".concat(_editorSharedStyles.akEditorTableToolbar, ")"),
|
|
105
111
|
dark: "var(--ds-background-neutral, ".concat(_editorSharedStyles.akEditorTableToolbarDark, ")")
|
|
106
112
|
})(themeProps), (0, _components.themed)({
|
|
@@ -127,7 +133,7 @@ var rendererStyles = function rendererStyles(wrapperProps) {
|
|
|
127
133
|
})(themeProps), (0, _components.themed)({
|
|
128
134
|
light: "var(--ds-border, ".concat(_editorSharedStyles.akEditorTableToolbar, ")"),
|
|
129
135
|
dark: "var(--ds-border, ".concat(_editorSharedStyles.akEditorTableToolbarDark, ")")
|
|
130
|
-
})(themeProps), (0, _constants.borderRadius)(), _editorSharedStyles.blockNodesVerticalMargin, (0, _lightWeightCodeBlock.getLightWeightCodeBlockStylesForRootRendererStyleSheet)(), _styles.columnLayoutSharedStyle, (0, _constants.gridSize)() * 2.5, (0, _constants.gridSize)() * 4, _editorSharedStyles.gridMediumMaxWidth, _editorSharedStyles.blockNodesVerticalMargin, _editorSharedStyles.blockNodesVerticalMargin, _utils.browser.safari ? _styles.codeBlockInListSafariFix : '');
|
|
136
|
+
})(themeProps), (0, _constants.borderRadius)(), _editorSharedStyles.blockNodesVerticalMargin, (0, _lightWeightCodeBlock.getLightWeightCodeBlockStylesForRootRendererStyleSheet)(), _styles.columnLayoutSharedStyle, (0, _constants.gridSize)() * 2.5, (0, _constants.gridSize)() * 4, _editorSharedStyles.gridMediumMaxWidth, _editorSharedStyles.blockNodesVerticalMargin, _editorSharedStyles.blockNodesVerticalMargin, _editorSharedStyles.blockNodesVerticalMargin, _utils.browser.safari ? _styles.codeBlockInListSafariFix : '');
|
|
131
137
|
};
|
|
132
138
|
};
|
|
133
139
|
exports.rendererStyles = rendererStyles;
|
package/dist/cjs/version.json
CHANGED
|
@@ -1 +1,55 @@
|
|
|
1
|
-
export
|
|
1
|
+
export let 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 let 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 let 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 let 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 = {}));
|
|
@@ -37,6 +37,7 @@ export default class ReactSerializer {
|
|
|
37
37
|
_defineProperty(this, "headingIds", []);
|
|
38
38
|
_defineProperty(this, "expandHeadingIds", []);
|
|
39
39
|
_defineProperty(this, "allowCopyToClipboard", false);
|
|
40
|
+
_defineProperty(this, "allowWrapCodeBlock", false);
|
|
40
41
|
_defineProperty(this, "allowPlaceholderText", true);
|
|
41
42
|
_defineProperty(this, "allowCustomPanels", false);
|
|
42
43
|
_defineProperty(this, "startPos", 1);
|
|
@@ -145,6 +146,7 @@ export default class ReactSerializer {
|
|
|
145
146
|
this.disableActions = init.disableActions;
|
|
146
147
|
this.allowHeadingAnchorLinks = init.allowHeadingAnchorLinks;
|
|
147
148
|
this.allowCopyToClipboard = init.allowCopyToClipboard;
|
|
149
|
+
this.allowWrapCodeBlock = init.allowWrapCodeBlock;
|
|
148
150
|
this.allowPlaceholderText = init.allowPlaceholderText;
|
|
149
151
|
this.allowCustomPanels = init.allowCustomPanels;
|
|
150
152
|
this.allowColumnSorting = init.allowColumnSorting;
|
|
@@ -336,14 +338,17 @@ export default class ReactSerializer {
|
|
|
336
338
|
var _this$media;
|
|
337
339
|
const {
|
|
338
340
|
marks: {
|
|
339
|
-
link
|
|
341
|
+
link,
|
|
342
|
+
border
|
|
340
343
|
}
|
|
341
344
|
} = node.type.schema;
|
|
342
345
|
const isLinkMark = mark => mark.type === link;
|
|
346
|
+
const isBorderMark = mark => mark.type === border;
|
|
343
347
|
return {
|
|
344
348
|
...this.getProps(node),
|
|
345
349
|
marks: node.marks.filter(m => !isLinkMark(m) || this.allowMediaLinking === true),
|
|
346
350
|
isLinkMark,
|
|
351
|
+
isBorderMark,
|
|
347
352
|
allowAltTextOnImages: this.allowAltTextOnImages,
|
|
348
353
|
featureFlags: this.media && this.media.featureFlags,
|
|
349
354
|
shouldOpenMediaViewer: this.shouldOpenMediaViewer,
|
|
@@ -436,6 +441,7 @@ export default class ReactSerializer {
|
|
|
436
441
|
content: node.content ? node.content.toJSON() : undefined,
|
|
437
442
|
allowHeadingAnchorLinks: this.allowHeadingAnchorLinks,
|
|
438
443
|
allowCopyToClipboard: this.allowCopyToClipboard,
|
|
444
|
+
allowWrapCodeBlock: this.allowWrapCodeBlock,
|
|
439
445
|
allowPlaceholderText: this.allowPlaceholderText,
|
|
440
446
|
rendererAppearance: this.appearance,
|
|
441
447
|
fireAnalyticsEvent: this.fireAnalyticsEvent,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
import { useState } from 'react';
|
|
2
3
|
import { jsx } from '@emotion/react';
|
|
3
4
|
import { injectIntl } from 'react-intl-next';
|
|
4
5
|
import { CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
@@ -10,19 +11,25 @@ function CodeBlock(props) {
|
|
|
10
11
|
text,
|
|
11
12
|
language,
|
|
12
13
|
allowCopyToClipboard = false,
|
|
14
|
+
allowWrapCodeBlock = false,
|
|
13
15
|
codeBidiWarningTooltipEnabled
|
|
14
16
|
} = props;
|
|
15
17
|
const codeBidiWarningLabel = props.intl.formatMessage(codeBidiWarningMessages.label);
|
|
16
18
|
const className = [CodeBlockSharedCssClassName.CODEBLOCK_CONTAINER, props.className].join(' ');
|
|
19
|
+
const [wrapLongLines, setWrapLongLines] = useState(false);
|
|
17
20
|
return jsx(CodeBlockContainer, {
|
|
18
|
-
|
|
21
|
+
allowCopyToClipboard: allowCopyToClipboard,
|
|
22
|
+
allowWrapCodeBlock: allowWrapCodeBlock,
|
|
19
23
|
className: className,
|
|
20
|
-
|
|
24
|
+
setWrapLongLines: setWrapLongLines,
|
|
25
|
+
text: text,
|
|
26
|
+
wrapLongLines: wrapLongLines
|
|
21
27
|
}, jsx(AkCodeBlock, {
|
|
22
28
|
language: language,
|
|
23
29
|
text: text,
|
|
24
30
|
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
25
|
-
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
31
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled,
|
|
32
|
+
shouldWrapLongLines: allowWrapCodeBlock && wrapLongLines
|
|
26
33
|
}));
|
|
27
34
|
}
|
|
28
35
|
export default injectIntl(CodeBlock);
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
const codeBlockButtonsWrapper = css({
|
|
7
|
+
position: 'sticky',
|
|
8
|
+
top: '0px'
|
|
9
|
+
});
|
|
10
|
+
const 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 ${`var(--ds-border-inverse, ${N0})`}`,
|
|
23
|
+
borderRadius: '4px',
|
|
24
|
+
marginLeft: '4px',
|
|
25
|
+
padding: '2px',
|
|
26
|
+
background: `${`var(--ds-background-neutral-subtle, ${N20})`}`,
|
|
27
|
+
color: `${"var(--ds-icon, rgb(66, 82, 110))"}`,
|
|
28
|
+
'&:hover': {
|
|
29
|
+
borderWidth: '2px',
|
|
30
|
+
backgroundColor: `${`var(--ds-background-neutral-hovered, ${N30})`}`,
|
|
31
|
+
height: '32px',
|
|
32
|
+
width: '32px'
|
|
33
|
+
},
|
|
34
|
+
'&.clicked': {
|
|
35
|
+
backgroundColor: `${`var(--ds-background-neutral-bold-pressed, ${N700})`}`,
|
|
36
|
+
borderRadius: '4px',
|
|
37
|
+
color: `${`var(--ds-icon-inverse, ${N0})`} !important`
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const CodeBlockButtonContainer = ({
|
|
42
|
+
allowCopyToClipboard,
|
|
43
|
+
allowWrapCodeBlock,
|
|
44
|
+
setWrapLongLines,
|
|
45
|
+
text,
|
|
46
|
+
wrapLongLines
|
|
47
|
+
}) => {
|
|
48
|
+
return jsx("div", {
|
|
49
|
+
css: codeBlockButtonsWrapper
|
|
50
|
+
}, jsx("div", {
|
|
51
|
+
css: codeBlockButtonsStyle
|
|
52
|
+
}, allowWrapCodeBlock && jsx(CodeWrapButton, {
|
|
53
|
+
setWrapLongLines: setWrapLongLines,
|
|
54
|
+
wrapLongLines: wrapLongLines
|
|
55
|
+
}), allowCopyToClipboard && jsx(CopyButton, {
|
|
56
|
+
content: text
|
|
57
|
+
})));
|
|
58
|
+
};
|
|
59
|
+
export default CodeBlockButtonContainer;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
|
|
3
2
|
import { jsx, css } from '@emotion/react';
|
|
4
3
|
import { overflowShadow, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
5
4
|
import { N20, DN50 } from '@atlaskit/theme/colors';
|
|
6
5
|
import { themed } from '@atlaskit/theme/components';
|
|
7
6
|
import { fontSize, gridSize } from '@atlaskit/theme/constants';
|
|
8
7
|
import { CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
9
|
-
import
|
|
8
|
+
import CodeBlockButtonContainer from './codeBlockButtonContainer';
|
|
10
9
|
const codeBlockStyleOverrides = props => css`
|
|
11
10
|
tab-size: 4;
|
|
12
11
|
background-color: ${themed({
|
|
@@ -14,6 +13,17 @@ const codeBlockStyleOverrides = props => css`
|
|
|
14
13
|
dark: `var(--ds-surface-raised, ${DN50})`
|
|
15
14
|
})(props)};
|
|
16
15
|
|
|
16
|
+
&:hover {
|
|
17
|
+
button {
|
|
18
|
+
opacity: 1;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
button {
|
|
23
|
+
opacity: 0;
|
|
24
|
+
transition: opacity 0.2s ease 0s;
|
|
25
|
+
}
|
|
26
|
+
|
|
17
27
|
${CodeBlockSharedCssClassName.DS_CODEBLOCK} {
|
|
18
28
|
font-size: ${relativeFontSizeToBase16(fontSize())};
|
|
19
29
|
line-height: 1.5rem;
|
|
@@ -30,16 +40,23 @@ const codeBlockStyleOverrides = props => css`
|
|
|
30
40
|
}
|
|
31
41
|
`;
|
|
32
42
|
const CodeBlockContainer = ({
|
|
33
|
-
text,
|
|
34
|
-
className,
|
|
35
43
|
allowCopyToClipboard,
|
|
36
|
-
|
|
44
|
+
allowWrapCodeBlock,
|
|
45
|
+
children,
|
|
46
|
+
className,
|
|
47
|
+
setWrapLongLines,
|
|
48
|
+
text,
|
|
49
|
+
wrapLongLines
|
|
37
50
|
}) => {
|
|
38
51
|
return jsx("div", {
|
|
39
52
|
className: className,
|
|
40
53
|
css: codeBlockStyleOverrides
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
}, jsx(CodeBlockButtonContainer, {
|
|
55
|
+
allowCopyToClipboard: allowCopyToClipboard,
|
|
56
|
+
allowWrapCodeBlock: allowWrapCodeBlock,
|
|
57
|
+
setWrapLongLines: setWrapLongLines,
|
|
58
|
+
text: text,
|
|
59
|
+
wrapLongLines: wrapLongLines
|
|
60
|
+
}), children);
|
|
44
61
|
};
|
|
45
62
|
export default CodeBlockContainer;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import React, { useState } 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 CopyIcon from '@atlaskit/icon/glyph/copy';
|
|
8
|
+
import { copyTextToClipboard } from '../../../utils/clipboard';
|
|
9
|
+
import { codeBlockButtonMessages } from '@atlaskit/editor-common/messages';
|
|
10
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../../../../analytics/enums';
|
|
11
|
+
import AnalyticsContext from '../../../../analytics/analyticsContext';
|
|
12
|
+
const CopyButton = ({
|
|
13
|
+
content,
|
|
14
|
+
intl
|
|
15
|
+
}) => {
|
|
16
|
+
const [tooltip, setTooltip] = useState(intl.formatMessage(codeBlockButtonMessages.copyCodeToClipboard));
|
|
17
|
+
const [className, setClassName] = useState('copy-to-clipboard');
|
|
18
|
+
const onMouseLeave = () => {
|
|
19
|
+
setTooltip(intl.formatMessage(codeBlockButtonMessages.copyCodeToClipboard));
|
|
20
|
+
setClassName('copy-to-clipboard');
|
|
21
|
+
};
|
|
22
|
+
return jsx(AnalyticsContext.Consumer, null, ({
|
|
23
|
+
fireAnalyticsEvent
|
|
24
|
+
}) => jsx("span", null, jsx(Tooltip, {
|
|
25
|
+
content: tooltip,
|
|
26
|
+
hideTooltipOnClick: false,
|
|
27
|
+
position: "top"
|
|
28
|
+
}, jsx("div", {
|
|
29
|
+
onMouseLeave: onMouseLeave
|
|
30
|
+
}, jsx(Button, {
|
|
31
|
+
appearance: "subtle",
|
|
32
|
+
"aria-haspopup": true,
|
|
33
|
+
"aria-label": tooltip,
|
|
34
|
+
className: className,
|
|
35
|
+
iconBefore: jsx(CopyIcon, {
|
|
36
|
+
label: tooltip
|
|
37
|
+
}),
|
|
38
|
+
onClick: () => {
|
|
39
|
+
fireAnalyticsEvent({
|
|
40
|
+
action: ACTION.CLICKED,
|
|
41
|
+
actionSubject: ACTION_SUBJECT.BUTTON,
|
|
42
|
+
actionSubjectId: ACTION_SUBJECT_ID.CODEBLOCK_COPY,
|
|
43
|
+
eventType: EVENT_TYPE.UI
|
|
44
|
+
});
|
|
45
|
+
copyTextToClipboard(content);
|
|
46
|
+
setTooltip(intl.formatMessage(codeBlockButtonMessages.copiedCodeToClipboard));
|
|
47
|
+
setClassName('copy-to-clipboard clicked');
|
|
48
|
+
},
|
|
49
|
+
spacing: "compact"
|
|
50
|
+
})))));
|
|
51
|
+
};
|
|
52
|
+
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
|
+
const 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
|
+
const CodeBlockWrapButton = ({
|
|
31
|
+
setWrapLongLines,
|
|
32
|
+
wrapLongLines,
|
|
33
|
+
intl
|
|
34
|
+
}) => {
|
|
35
|
+
const wrapMessage = intl.formatMessage(wrapLongLines ? codeBlockButtonMessages.unwrapCode : codeBlockButtonMessages.wrapCode);
|
|
36
|
+
return jsx(AnalyticsContext.Consumer, null, ({
|
|
37
|
+
fireAnalyticsEvent
|
|
38
|
+
}) => jsx("span", null, jsx(Tooltip, {
|
|
39
|
+
content: wrapMessage,
|
|
40
|
+
hideTooltipOnClick: false,
|
|
41
|
+
position: "top"
|
|
42
|
+
}, jsx(Button, {
|
|
43
|
+
appearance: "subtle",
|
|
44
|
+
"aria-haspopup": true,
|
|
45
|
+
"aria-label": wrapMessage,
|
|
46
|
+
className: `wrap-code ${wrapLongLines ? 'clicked' : ''}`,
|
|
47
|
+
iconBefore: jsx(Icon, {
|
|
48
|
+
glyph: WrapIcon,
|
|
49
|
+
label: ""
|
|
50
|
+
}),
|
|
51
|
+
isSelected: wrapLongLines,
|
|
52
|
+
onClick: () => {
|
|
53
|
+
fireAnalyticsEvent({
|
|
54
|
+
action: ACTION.CLICKED,
|
|
55
|
+
actionSubject: ACTION_SUBJECT.BUTTON,
|
|
56
|
+
actionSubjectId: ACTION_SUBJECT_ID.CODEBLOCK_WRAP,
|
|
57
|
+
attributes: {
|
|
58
|
+
wrapped: !wrapLongLines
|
|
59
|
+
},
|
|
60
|
+
eventType: EVENT_TYPE.UI
|
|
61
|
+
});
|
|
62
|
+
setWrapLongLines(!wrapLongLines);
|
|
63
|
+
},
|
|
64
|
+
spacing: "compact"
|
|
65
|
+
}))));
|
|
66
|
+
};
|
|
67
|
+
export default injectIntl(CodeBlockWrapButton);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { Fragment, memo } from 'react';
|
|
3
|
-
import { lazy, Suspense } from 'react';
|
|
2
|
+
import { Fragment, lazy, memo, Suspense, useState } from 'react';
|
|
4
3
|
import { jsx } from '@emotion/react';
|
|
5
4
|
import { CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
6
5
|
import { useInViewport } from '../../hooks/use-in-viewport';
|
|
@@ -15,6 +14,7 @@ const WindowedCodeBlock = ({
|
|
|
15
14
|
text,
|
|
16
15
|
language,
|
|
17
16
|
allowCopyToClipboard,
|
|
17
|
+
allowWrapCodeBlock = false,
|
|
18
18
|
codeBidiWarningTooltipEnabled,
|
|
19
19
|
className: rootClassName
|
|
20
20
|
}) => {
|
|
@@ -34,17 +34,22 @@ const WindowedCodeBlock = ({
|
|
|
34
34
|
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled,
|
|
35
35
|
className: rootClassName
|
|
36
36
|
});
|
|
37
|
+
const [wrapLongLines, setWrapLongLines] = useState(false);
|
|
37
38
|
return isInViewport ? jsx(Fragment, null, jsx(Suspense, {
|
|
38
39
|
fallback: memoizedLightWeightCodeBlock
|
|
39
40
|
}, jsx(CodeBlockContainer, {
|
|
41
|
+
allowCopyToClipboard: allowCopyToClipboard,
|
|
42
|
+
allowWrapCodeBlock: allowWrapCodeBlock,
|
|
40
43
|
className: className,
|
|
44
|
+
setWrapLongLines: setWrapLongLines,
|
|
41
45
|
text: text,
|
|
42
|
-
|
|
46
|
+
wrapLongLines: wrapLongLines
|
|
43
47
|
}, jsx(LazyAkCodeBlock, {
|
|
44
48
|
language: language,
|
|
45
49
|
text: text,
|
|
46
50
|
codeBidiWarningLabel: warningLabel,
|
|
47
|
-
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
51
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled,
|
|
52
|
+
shouldWrapLongLines: allowWrapCodeBlock && wrapLongLines
|
|
48
53
|
})))) : memoizedLightWeightCodeBlock;
|
|
49
54
|
};
|
|
50
55
|
export default WindowedCodeBlock;
|