@atlaskit/renderer 98.0.0 → 98.1.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 +16 -0
- package/dist/cjs/react/hooks/use-bidi-warnings.js +45 -0
- package/dist/cjs/react/hooks/use-in-viewport.js +63 -0
- package/dist/cjs/react/index.js +5 -2
- package/dist/cjs/react/nodes/codeBlock/codeBlock.js +49 -0
- package/dist/cjs/react/nodes/codeBlock/components/codeBlockContainer.js +55 -0
- package/dist/cjs/react/nodes/codeBlock/components/lightWeightCodeBlock.js +82 -0
- package/dist/cjs/react/nodes/codeBlock/windowedCodeBlock.js +103 -0
- package/dist/cjs/react/nodes/codeBlockCopyButton.js +24 -27
- package/dist/cjs/react/nodes/heading.js +15 -18
- package/dist/cjs/react/nodes/index.js +34 -5
- package/dist/cjs/react/nodes/layoutColumn.js +7 -2
- package/dist/cjs/react/utils/clipboard.js +24 -0
- package/dist/cjs/ui/Renderer/index.js +12 -7
- package/dist/cjs/ui/Renderer/style.js +4 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/react/hooks/use-bidi-warnings.js +28 -0
- package/dist/es2019/react/hooks/use-in-viewport.js +25 -0
- package/dist/es2019/react/index.js +5 -2
- package/dist/es2019/react/nodes/codeBlock/codeBlock.js +33 -0
- package/dist/es2019/react/nodes/codeBlock/components/codeBlockContainer.js +44 -0
- package/dist/es2019/react/nodes/codeBlock/components/lightWeightCodeBlock.js +58 -0
- package/dist/es2019/react/nodes/codeBlock/windowedCodeBlock.js +58 -0
- package/dist/es2019/react/nodes/codeBlockCopyButton.js +24 -28
- package/dist/es2019/react/nodes/heading.js +16 -20
- package/dist/es2019/react/nodes/index.js +22 -5
- package/dist/es2019/react/nodes/layoutColumn.js +7 -3
- package/dist/es2019/react/utils/clipboard.js +9 -0
- package/dist/es2019/ui/Renderer/index.js +9 -4
- package/dist/es2019/ui/Renderer/style.js +3 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/react/hooks/use-bidi-warnings.js +29 -0
- package/dist/esm/react/hooks/use-in-viewport.js +51 -0
- package/dist/esm/react/index.js +5 -2
- package/dist/esm/react/nodes/codeBlock/codeBlock.js +32 -0
- package/dist/esm/react/nodes/codeBlock/components/codeBlockContainer.js +40 -0
- package/dist/esm/react/nodes/codeBlock/components/lightWeightCodeBlock.js +57 -0
- package/dist/esm/react/nodes/codeBlock/windowedCodeBlock.js +80 -0
- package/dist/esm/react/nodes/codeBlockCopyButton.js +24 -27
- package/dist/esm/react/nodes/heading.js +15 -18
- package/dist/esm/react/nodes/index.js +33 -5
- package/dist/esm/react/nodes/layoutColumn.js +8 -3
- package/dist/esm/react/utils/clipboard.js +15 -0
- package/dist/esm/ui/Renderer/index.js +12 -6
- package/dist/esm/ui/Renderer/style.js +3 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/react/hooks/use-bidi-warnings.d.ts +10 -0
- package/dist/types/react/hooks/use-in-viewport.d.ts +5 -0
- package/dist/types/react/index.d.ts +5 -1
- package/dist/types/react/nodes/{codeBlock.d.ts → codeBlock/codeBlock.d.ts} +1 -1
- package/dist/types/react/nodes/codeBlock/components/codeBlockContainer.d.ts +12 -0
- package/dist/types/react/nodes/codeBlock/components/lightWeightCodeBlock.d.ts +9 -0
- package/dist/types/react/nodes/codeBlock/windowedCodeBlock.d.ts +4 -0
- package/dist/types/react/nodes/index.d.ts +8 -5
- package/dist/types/react/utils/clipboard.d.ts +1 -0
- package/dist/types/ui/Renderer/types.d.ts +4 -0
- package/dist/types/ui/renderer-props.d.ts +2 -1
- package/package.json +15 -14
- package/report.api.md +590 -119
- package/dist/cjs/react/nodes/codeBlock.js +0 -74
- package/dist/cjs/react/nodes/copy-text-provider.js +0 -174
- package/dist/es2019/react/nodes/codeBlock.js +0 -59
- package/dist/es2019/react/nodes/copy-text-provider.js +0 -93
- package/dist/esm/react/nodes/codeBlock.js +0 -55
- package/dist/esm/react/nodes/copy-text-provider.js +0 -140
- package/dist/types/react/nodes/copy-text-provider.d.ts +0 -20
|
@@ -7,13 +7,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = LayoutSection;
|
|
9
9
|
|
|
10
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
+
|
|
10
12
|
var _react = _interopRequireDefault(require("react"));
|
|
11
13
|
|
|
12
14
|
var _react2 = require("@emotion/react");
|
|
13
15
|
|
|
14
16
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
var _templateObject;
|
|
19
|
+
|
|
20
|
+
var layoutColumnClearMarginTopStyles = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n ", "\n ", "\n"])), _ui.clearNextSiblingMarginTopStyle, _ui.clearNextSiblingBlockMarkMarginTopStyle);
|
|
21
|
+
|
|
17
22
|
function LayoutSection(props) {
|
|
18
23
|
return (0, _react2.jsx)("div", {
|
|
19
24
|
"data-layout-column": true,
|
|
@@ -22,6 +27,6 @@ function LayoutSection(props) {
|
|
|
22
27
|
flexBasis: "".concat(props.width, "%")
|
|
23
28
|
}
|
|
24
29
|
}, (0, _react2.jsx)(_ui.WidthProvider, null, (0, _react2.jsx)("div", {
|
|
25
|
-
css:
|
|
30
|
+
css: layoutColumnClearMarginTopStyles
|
|
26
31
|
}), props.children));
|
|
27
32
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.copyTextToClipboard = void 0;
|
|
7
|
+
|
|
8
|
+
var copyTextToClipboard = function copyTextToClipboard(text) {
|
|
9
|
+
return new Promise(function (resolve, reject) {
|
|
10
|
+
var isApiSupported = !!navigator.clipboard && typeof navigator.clipboard.writeText === 'function';
|
|
11
|
+
|
|
12
|
+
if (isApiSupported) {
|
|
13
|
+
navigator.clipboard.writeText(text).then(function () {
|
|
14
|
+
return resolve();
|
|
15
|
+
}, function (e) {
|
|
16
|
+
return reject(e);
|
|
17
|
+
});
|
|
18
|
+
} else {
|
|
19
|
+
reject('Clipboard API is not supported');
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.copyTextToClipboard = copyTextToClipboard;
|
|
@@ -61,8 +61,6 @@ var _events = require("../../analytics/events");
|
|
|
61
61
|
|
|
62
62
|
var _analyticsContext = _interopRequireDefault(require("../../analytics/analyticsContext"));
|
|
63
63
|
|
|
64
|
-
var _copyTextProvider = require("../../react/nodes/copy-text-provider");
|
|
65
|
-
|
|
66
64
|
var _SmartCardStorage = require("../SmartCardStorage");
|
|
67
65
|
|
|
68
66
|
var _version = require("../../version.json");
|
|
@@ -254,6 +252,10 @@ var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
254
252
|
var stickyHeaders = props.stickyHeaders ? props.stickyHeaders === true ? {} : props.stickyHeaders : undefined;
|
|
255
253
|
var annotationProvider = props.annotationProvider;
|
|
256
254
|
var allowAnnotationsDraftMode = Boolean(annotationProvider && annotationProvider.inlineComment && annotationProvider.inlineComment.allowDraftMode);
|
|
255
|
+
|
|
256
|
+
var _this$featureFlags = this.featureFlags(props.featureFlags),
|
|
257
|
+
featureFlags = _this$featureFlags.featureFlags;
|
|
258
|
+
|
|
257
259
|
return {
|
|
258
260
|
providers: this.providerFactory,
|
|
259
261
|
eventHandlers: props.eventHandlers,
|
|
@@ -280,7 +282,10 @@ var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
280
282
|
allowCustomPanels: props.allowCustomPanels,
|
|
281
283
|
allowAnnotations: props.allowAnnotations,
|
|
282
284
|
allowSelectAllTrap: props.allowSelectAllTrap,
|
|
283
|
-
allowPlaceholderText: props.allowPlaceholderText
|
|
285
|
+
allowPlaceholderText: props.allowPlaceholderText,
|
|
286
|
+
nodeComponents: props.nodeComponents,
|
|
287
|
+
// does not currently support SSR, should not be enabled in environments where Renderer is SSR-ed
|
|
288
|
+
allowWindowedCodeBlock: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.allowWindowedCodeBlock
|
|
284
289
|
};
|
|
285
290
|
}
|
|
286
291
|
}, {
|
|
@@ -350,7 +355,7 @@ var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
350
355
|
};
|
|
351
356
|
|
|
352
357
|
try {
|
|
353
|
-
var _this$
|
|
358
|
+
var _this$featureFlags2, _this$featureFlags2$f, _this$featureFlags2$f2;
|
|
354
359
|
|
|
355
360
|
var schema = this.getSchema(this.props.schema, this.props.adfStage);
|
|
356
361
|
|
|
@@ -365,7 +370,7 @@ var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
365
370
|
|
|
366
371
|
var rendererOutput = (0, _react2.jsx)(_rendererContext.RendererContextProvider, {
|
|
367
372
|
value: this.featureFlags(this.props.featureFlags)
|
|
368
|
-
}, (0, _react2.jsx)(
|
|
373
|
+
}, (0, _react2.jsx)(_activeHeaderIdProvider.ActiveHeaderIdProvider, {
|
|
369
374
|
value: (0, _links.getActiveHeadingId)(allowHeadingAnchorLinks)
|
|
370
375
|
}, (0, _react2.jsx)(_analyticsContext.default.Provider, {
|
|
371
376
|
value: {
|
|
@@ -387,12 +392,12 @@ var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
387
392
|
doc: pmDoc,
|
|
388
393
|
schema: schema,
|
|
389
394
|
onAnalyticsEvent: this.fireAnalyticsEvent
|
|
390
|
-
}, result))))))
|
|
395
|
+
}, result))))));
|
|
391
396
|
var rendererResult = truncated ? (0, _react2.jsx)(_truncatedWrapper.TruncatedWrapper, {
|
|
392
397
|
height: maxHeight,
|
|
393
398
|
fadeHeight: fadeOutHeight
|
|
394
399
|
}, rendererOutput) : rendererOutput;
|
|
395
|
-
var rendererRenderTracking = (_this$
|
|
400
|
+
var rendererRenderTracking = (_this$featureFlags2 = this.featureFlags(this.props.featureFlags)) === null || _this$featureFlags2 === void 0 ? void 0 : (_this$featureFlags2$f = _this$featureFlags2.featureFlags) === null || _this$featureFlags2$f === void 0 ? void 0 : (_this$featureFlags2$f2 = _this$featureFlags2$f.rendererRenderTracking) === null || _this$featureFlags2$f2 === void 0 ? void 0 : _this$featureFlags2$f2[_enums.ACTION_SUBJECT.RENDERER];
|
|
396
401
|
var reRenderTracking = (rendererRenderTracking === null || rendererRenderTracking === void 0 ? void 0 : rendererRenderTracking.enabled) && (0, _react2.jsx)(_RenderTracking.RenderTracking, {
|
|
397
402
|
componentProps: this.props,
|
|
398
403
|
action: _enums.ACTION.RE_RENDERED,
|
|
@@ -33,6 +33,8 @@ var _consts = require("../../consts");
|
|
|
33
33
|
|
|
34
34
|
var _headingAnchor = require("../../react/nodes/heading-anchor");
|
|
35
35
|
|
|
36
|
+
var _lightWeightCodeBlock = require("../../react/nodes/codeBlock/components/lightWeightCodeBlock");
|
|
37
|
+
|
|
36
38
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
37
39
|
|
|
38
40
|
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); }
|
|
@@ -126,7 +128,7 @@ var rendererStyles = function rendererStyles(wrapperProps) {
|
|
|
126
128
|
var themeProps = {
|
|
127
129
|
theme: theme
|
|
128
130
|
};
|
|
129
|
-
return (0, _react.css)(_templateObject6 || (_templateObject6 = (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 width: 100% !important;\n left: 0 !important;\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 &:hover button.copy-to-clipboard,\n .copy-to-clipboard:focus {\n opacity: 1;\n position: absolute;\n height: 32px;\n width: 32px;\n right: 6px;\n top: 4px;\n padding: 2px;\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 "])), (0, _editorSharedStyles.editorFontSize)(themeProps), (0, _components.themed)({
|
|
131
|
+
return (0, _react.css)(_templateObject6 || (_templateObject6 = (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 width: 100% !important;\n left: 0 !important;\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 &:hover button.copy-to-clipboard,\n .copy-to-clipboard:focus {\n opacity: 1;\n position: absolute;\n height: 32px;\n width: 32px;\n right: 6px;\n top: 4px;\n padding: 2px;\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 "])), (0, _editorSharedStyles.editorFontSize)(themeProps), (0, _components.themed)({
|
|
130
132
|
light: (0, _tokens.token)('color.text', colors.N800),
|
|
131
133
|
dark: (0, _tokens.token)('color.text', '#B8C7E0')
|
|
132
134
|
})(themeProps), _consts.RendererCssClassName.DOCUMENT, fullPageStyles(wrapperProps, themeProps), fullWidthStyles(wrapperProps), headingAnchorStyle('h1'), headingAnchorStyle('h2'), headingAnchorStyle('h3'), headingAnchorStyle('h4'), headingAnchorStyle('h5'), headingAnchorStyle('h6'), (0, _tokens.token)('color.link', colors.B400), (0, _tokens.token)('color.link', colors.B300), (0, _tokens.token)('color.link.pressed', 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)({
|
|
@@ -162,7 +164,7 @@ var rendererStyles = function rendererStyles(wrapperProps) {
|
|
|
162
164
|
})(themeProps), (0, _components.themed)({
|
|
163
165
|
light: (0, _tokens.token)('color.border', _editorSharedStyles.akEditorTableToolbar),
|
|
164
166
|
dark: (0, _tokens.token)('color.border', _editorSharedStyles.akEditorTableToolbarDark)
|
|
165
|
-
})(themeProps), (0, _constants.borderRadius)(), _editorSharedStyles.blockNodesVerticalMargin, _styles.columnLayoutSharedStyle, (0, _constants.gridSize)() * 2.5, (0, _constants.gridSize)() * 4, _editorSharedStyles.gridMediumMaxWidth);
|
|
167
|
+
})(themeProps), (0, _constants.borderRadius)(), _editorSharedStyles.blockNodesVerticalMargin, (0, _lightWeightCodeBlock.getLightWeightCodeBlockStylesForRootRendererStyleSheet)(), _styles.columnLayoutSharedStyle, (0, _constants.gridSize)() * 2.5, (0, _constants.gridSize)() * 4, _editorSharedStyles.gridMediumMaxWidth);
|
|
166
168
|
};
|
|
167
169
|
};
|
|
168
170
|
|
package/dist/cjs/version.json
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
3
|
+
import CodeBidiWarning from '@atlaskit/code/bidi-warning';
|
|
4
|
+
import { codeBidiWarningMessages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import codeBidiWarningDecorator from '@atlaskit/code/bidi-warning-decorator';
|
|
6
|
+
export const useBidiWarnings = ({
|
|
7
|
+
enableWarningTooltip = true
|
|
8
|
+
}) => {
|
|
9
|
+
const intl = useIntl();
|
|
10
|
+
const warningLabel = intl.formatMessage(codeBidiWarningMessages.label);
|
|
11
|
+
|
|
12
|
+
const renderBidiWarnings = text => {
|
|
13
|
+
return codeBidiWarningDecorator(text, ({
|
|
14
|
+
bidiCharacter,
|
|
15
|
+
index
|
|
16
|
+
}) => /*#__PURE__*/React.createElement(CodeBidiWarning, {
|
|
17
|
+
bidiCharacter: bidiCharacter,
|
|
18
|
+
key: index,
|
|
19
|
+
label: warningLabel,
|
|
20
|
+
tooltipEnabled: enableWarningTooltip
|
|
21
|
+
}));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
renderBidiWarnings,
|
|
26
|
+
warningLabel
|
|
27
|
+
};
|
|
28
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
export const useInViewport = () => {
|
|
3
|
+
const trackingRef = useRef(null);
|
|
4
|
+
const [isInViewport, setIsInViewport] = useState(false);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
if (!trackingRef || !(trackingRef !== null && trackingRef !== void 0 && trackingRef.current)) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const target = trackingRef.current;
|
|
11
|
+
const observer = new IntersectionObserver(entries => {
|
|
12
|
+
for (const entry of entries) {
|
|
13
|
+
if (entry.isIntersecting) {
|
|
14
|
+
setIsInViewport(true);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
observer.observe(target);
|
|
19
|
+
return () => observer.disconnect();
|
|
20
|
+
}, [trackingRef]);
|
|
21
|
+
return {
|
|
22
|
+
isInViewport,
|
|
23
|
+
trackingRef
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -62,8 +62,9 @@ export default class ReactSerializer {
|
|
|
62
62
|
const parentIsIncompleteTask = node.type.name === 'taskItem' && node.attrs.state !== 'DONE';
|
|
63
63
|
const nodeKey = `${node.type.name}__${this.startPos}`;
|
|
64
64
|
const serializedContent = this.serializeFragment(node.content, this.getNodeProps(node, parentInfo), toReact(node, {
|
|
65
|
-
allowSelectAllTrap: this.allowSelectAllTrap
|
|
66
|
-
|
|
65
|
+
allowSelectAllTrap: this.allowSelectAllTrap,
|
|
66
|
+
allowWindowedCodeBlock: this.allowWindowedCodeBlock
|
|
67
|
+
}, this.nodeComponents), nodeKey, {
|
|
67
68
|
parentIsIncompleteTask,
|
|
68
69
|
path: [...currentPath, node],
|
|
69
70
|
pos: this.startPos
|
|
@@ -177,6 +178,8 @@ export default class ReactSerializer {
|
|
|
177
178
|
this.media = init.media;
|
|
178
179
|
this.smartLinks = init.smartLinks;
|
|
179
180
|
this.allowSelectAllTrap = init.allowSelectAllTrap;
|
|
181
|
+
this.nodeComponents = init.nodeComponents;
|
|
182
|
+
this.allowWindowedCodeBlock = init.allowWindowedCodeBlock;
|
|
180
183
|
}
|
|
181
184
|
|
|
182
185
|
resetState() {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import { injectIntl } from 'react-intl-next';
|
|
4
|
+
import { CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
5
|
+
import { CodeBlock as AkCodeBlock } from '@atlaskit/code';
|
|
6
|
+
import { codeBidiWarningMessages } from '@atlaskit/editor-common/messages';
|
|
7
|
+
import { useFeatureFlags } from '../../../use-feature-flags';
|
|
8
|
+
import CodeBlockContainer from './components/codeBlockContainer';
|
|
9
|
+
|
|
10
|
+
function CodeBlock(props) {
|
|
11
|
+
const {
|
|
12
|
+
text,
|
|
13
|
+
language,
|
|
14
|
+
allowCopyToClipboard = false,
|
|
15
|
+
codeBidiWarningTooltipEnabled
|
|
16
|
+
} = props;
|
|
17
|
+
const featureFlags = useFeatureFlags();
|
|
18
|
+
const codeBidiWarningLabel = props.intl.formatMessage(codeBidiWarningMessages.label);
|
|
19
|
+
const className = [CodeBlockSharedCssClassName.CODEBLOCK_CONTAINER, props.className].join(' ');
|
|
20
|
+
return jsx(CodeBlockContainer, {
|
|
21
|
+
text: text,
|
|
22
|
+
className: className,
|
|
23
|
+
allowCopyToClipboard: allowCopyToClipboard
|
|
24
|
+
}, jsx(AkCodeBlock, {
|
|
25
|
+
language: language,
|
|
26
|
+
text: text,
|
|
27
|
+
codeBidiWarnings: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.codeBidiWarnings,
|
|
28
|
+
codeBidiWarningLabel: codeBidiWarningLabel,
|
|
29
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default injectIntl(CodeBlock);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx, css } from '@emotion/react';
|
|
3
|
+
import { overflowShadow, relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
|
|
4
|
+
import { N20, DN50 } from '@atlaskit/theme/colors';
|
|
5
|
+
import { themed } from '@atlaskit/theme/components';
|
|
6
|
+
import { fontSize, gridSize } from '@atlaskit/theme/constants';
|
|
7
|
+
import { CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
8
|
+
import CopyButton from '../../codeBlockCopyButton';
|
|
9
|
+
|
|
10
|
+
// TODO: Quality ticket https://product-fabric.atlassian.net/browse/DSP-4118
|
|
11
|
+
|
|
12
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
13
|
+
const codeBlockStyleOverrides = props => css`
|
|
14
|
+
tab-size: 4;
|
|
15
|
+
${CodeBlockSharedCssClassName.DS_CODEBLOCK} {
|
|
16
|
+
font-size: ${relativeFontSizeToBase16(fontSize())};
|
|
17
|
+
line-height: 1.5rem;
|
|
18
|
+
background-image: ${overflowShadow({
|
|
19
|
+
background: themed({
|
|
20
|
+
light: N20,
|
|
21
|
+
dark: DN50
|
|
22
|
+
})(props),
|
|
23
|
+
width: `${gridSize()}px`
|
|
24
|
+
})};
|
|
25
|
+
background-attachment: local, scroll, scroll;
|
|
26
|
+
background-position: 100% 0, 100% 0, 0 0;
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
const CodeBlockContainer = ({
|
|
31
|
+
text,
|
|
32
|
+
className,
|
|
33
|
+
allowCopyToClipboard,
|
|
34
|
+
children
|
|
35
|
+
}) => {
|
|
36
|
+
return jsx("div", {
|
|
37
|
+
className: className,
|
|
38
|
+
css: codeBlockStyleOverrides
|
|
39
|
+
}, allowCopyToClipboard ? jsx(CopyButton, {
|
|
40
|
+
content: text
|
|
41
|
+
}) : null, children);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default CodeBlockContainer;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import React, { forwardRef, useMemo } from 'react';
|
|
3
|
+
import { css, jsx, useTheme } from '@emotion/react';
|
|
4
|
+
import { blockNodesVerticalMargin } from '@atlaskit/editor-shared-styles';
|
|
5
|
+
import { codeBlockSharedStyles, CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
6
|
+
import { useBidiWarnings } from '../../../hooks/use-bidi-warnings';
|
|
7
|
+
import { RendererCssClassName } from '../../../../consts';
|
|
8
|
+
const lightWeightCodeBlockStyles = css`
|
|
9
|
+
.${CodeBlockSharedCssClassName.CODEBLOCK_CONTAINER} {
|
|
10
|
+
cursor: text;
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
export const LightWeightCodeBlockCssClassName = {
|
|
14
|
+
CONTAINER: 'light-weight-code-block'
|
|
15
|
+
};
|
|
16
|
+
export const getLightWeightCodeBlockStylesForRootRendererStyleSheet = () => {
|
|
17
|
+
// We overwrite the rule that clears margin-top for first nested codeblocks, as
|
|
18
|
+
// our lightweight codeblock dom structure will always nest the codeblock inside
|
|
19
|
+
// an extra container div which would constantly be targeted. Now, top-level
|
|
20
|
+
// lightweight codeblock containers will not be targeted.
|
|
21
|
+
// NOTE: This must be added after other .code-block styles in the root
|
|
22
|
+
// Renderer stylesheet.
|
|
23
|
+
return css`
|
|
24
|
+
.${RendererCssClassName.DOCUMENT}
|
|
25
|
+
> .${LightWeightCodeBlockCssClassName.CONTAINER}
|
|
26
|
+
.${CodeBlockSharedCssClassName.CODEBLOCK_CONTAINER} {
|
|
27
|
+
margin-top: ${blockNodesVerticalMargin};
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
};
|
|
31
|
+
const LightWeightCodeBlock = /*#__PURE__*/forwardRef(({
|
|
32
|
+
text,
|
|
33
|
+
codeBidiWarningTooltipEnabled = true,
|
|
34
|
+
className
|
|
35
|
+
}, ref) => {
|
|
36
|
+
const theme = useTheme();
|
|
37
|
+
const textRows = useMemo(() => (text !== null && text !== void 0 ? text : '').split('\n'), [text]);
|
|
38
|
+
const {
|
|
39
|
+
renderBidiWarnings
|
|
40
|
+
} = useBidiWarnings({
|
|
41
|
+
enableWarningTooltip: codeBidiWarningTooltipEnabled
|
|
42
|
+
});
|
|
43
|
+
const classNames = [LightWeightCodeBlockCssClassName.CONTAINER, className].join(' ');
|
|
44
|
+
return jsx("div", {
|
|
45
|
+
className: classNames,
|
|
46
|
+
ref: ref,
|
|
47
|
+
css: [codeBlockSharedStyles(theme), lightWeightCodeBlockStyles]
|
|
48
|
+
}, jsx("div", {
|
|
49
|
+
className: CodeBlockSharedCssClassName.CODEBLOCK_CONTAINER
|
|
50
|
+
}, jsx("div", {
|
|
51
|
+
className: CodeBlockSharedCssClassName.CODEBLOCK_LINE_NUMBER_GUTTER
|
|
52
|
+
}, textRows.map((_, index) => jsx("span", {
|
|
53
|
+
key: index
|
|
54
|
+
}))), jsx("div", {
|
|
55
|
+
className: CodeBlockSharedCssClassName.CODEBLOCK_CONTENT
|
|
56
|
+
}, jsx("code", null, renderBidiWarnings(text)))));
|
|
57
|
+
});
|
|
58
|
+
export default LightWeightCodeBlock;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { Fragment, memo } from 'react';
|
|
3
|
+
import { lazy, Suspense } from 'react';
|
|
4
|
+
import { jsx } from '@emotion/react';
|
|
5
|
+
import { CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
6
|
+
import { useFeatureFlags } from '../../../use-feature-flags';
|
|
7
|
+
import { useInViewport } from '../../hooks/use-in-viewport';
|
|
8
|
+
import { useBidiWarnings } from '../../hooks/use-bidi-warnings';
|
|
9
|
+
import LightWeightCodeBlock from './components/lightWeightCodeBlock';
|
|
10
|
+
import CodeBlockContainer from './components/codeBlockContainer';
|
|
11
|
+
const LazyAkCodeBlock = /*#__PURE__*/lazy(async () => import(
|
|
12
|
+
/* webpackChunkName: "@atlaskit-internal_renderer-codeBlock" */
|
|
13
|
+
'@atlaskit/code/block'));
|
|
14
|
+
|
|
15
|
+
const joinWithSpaces = (...strs) => strs.join(' ');
|
|
16
|
+
|
|
17
|
+
const MemoizedLightWeightCodeBlock = /*#__PURE__*/memo(LightWeightCodeBlock);
|
|
18
|
+
|
|
19
|
+
const WindowedCodeBlock = ({
|
|
20
|
+
text,
|
|
21
|
+
language,
|
|
22
|
+
allowCopyToClipboard,
|
|
23
|
+
codeBidiWarningTooltipEnabled,
|
|
24
|
+
className: rootClassName
|
|
25
|
+
}) => {
|
|
26
|
+
const featureFlags = useFeatureFlags();
|
|
27
|
+
const {
|
|
28
|
+
warningLabel
|
|
29
|
+
} = useBidiWarnings({
|
|
30
|
+
enableWarningTooltip: codeBidiWarningTooltipEnabled
|
|
31
|
+
});
|
|
32
|
+
const {
|
|
33
|
+
isInViewport,
|
|
34
|
+
trackingRef
|
|
35
|
+
} = useInViewport();
|
|
36
|
+
const className = joinWithSpaces(CodeBlockSharedCssClassName.CODEBLOCK_CONTAINER, rootClassName);
|
|
37
|
+
const memoizedLightWeightCodeBlock = jsx(MemoizedLightWeightCodeBlock, {
|
|
38
|
+
ref: trackingRef,
|
|
39
|
+
text: text,
|
|
40
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled,
|
|
41
|
+
className: rootClassName
|
|
42
|
+
});
|
|
43
|
+
return isInViewport ? jsx(Fragment, null, jsx(Suspense, {
|
|
44
|
+
fallback: memoizedLightWeightCodeBlock
|
|
45
|
+
}, jsx(CodeBlockContainer, {
|
|
46
|
+
className: className,
|
|
47
|
+
text: text,
|
|
48
|
+
allowCopyToClipboard: allowCopyToClipboard
|
|
49
|
+
}, jsx(LazyAkCodeBlock, {
|
|
50
|
+
language: language,
|
|
51
|
+
text: text,
|
|
52
|
+
codeBidiWarnings: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.codeBidiWarnings,
|
|
53
|
+
codeBidiWarningLabel: warningLabel,
|
|
54
|
+
codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
|
|
55
|
+
})))) : memoizedLightWeightCodeBlock;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default WindowedCodeBlock;
|
|
@@ -6,7 +6,7 @@ import Tooltip from '@atlaskit/tooltip';
|
|
|
6
6
|
import Button from '@atlaskit/button/custom-theme-button';
|
|
7
7
|
import CopyIcon from '@atlaskit/icon/glyph/copy';
|
|
8
8
|
import { N20, N30, N700 } from '@atlaskit/theme/colors';
|
|
9
|
-
import {
|
|
9
|
+
import { copyTextToClipboard } from '../utils/clipboard';
|
|
10
10
|
import { codeBlockCopyButtonMessages } from '../../messages';
|
|
11
11
|
import { token } from '@atlaskit/tokens';
|
|
12
12
|
const copyButtonWrapperStyles = css`
|
|
@@ -54,33 +54,29 @@ const CopyButton = ({
|
|
|
54
54
|
setClassName('copy-to-clipboard');
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
return jsx(
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
setClassName('copy-to-clipboard clicked');
|
|
81
|
-
}
|
|
82
|
-
}))));
|
|
83
|
-
});
|
|
57
|
+
return jsx("span", {
|
|
58
|
+
css: copyButtonWrapperStyles
|
|
59
|
+
}, jsx(Tooltip, {
|
|
60
|
+
content: tooltip,
|
|
61
|
+
hideTooltipOnClick: false,
|
|
62
|
+
position: "top"
|
|
63
|
+
}, jsx("div", {
|
|
64
|
+
onMouseLeave: onMouseLeave
|
|
65
|
+
}, jsx(Button, {
|
|
66
|
+
className: className,
|
|
67
|
+
"aria-label": tooltip,
|
|
68
|
+
spacing: "compact",
|
|
69
|
+
appearance: "subtle",
|
|
70
|
+
"aria-haspopup": true,
|
|
71
|
+
iconBefore: jsx(CopyIcon, {
|
|
72
|
+
label: tooltip
|
|
73
|
+
}),
|
|
74
|
+
onClick: () => {
|
|
75
|
+
copyTextToClipboard(content);
|
|
76
|
+
setTooltip(intl.formatMessage(codeBlockCopyButtonMessages.copiedCodeToClipboard));
|
|
77
|
+
setClassName('copy-to-clipboard clicked');
|
|
78
|
+
}
|
|
79
|
+
}))));
|
|
84
80
|
};
|
|
85
81
|
|
|
86
82
|
export default injectIntl(CopyButton);
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import HeadingAnchor from './heading-anchor';
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../../analytics/enums';
|
|
5
5
|
import AnalyticsContext from '../../analytics/analyticsContext';
|
|
6
|
-
import {
|
|
6
|
+
import { copyTextToClipboard } from '../utils/clipboard';
|
|
7
7
|
|
|
8
8
|
const getCurrentUrlWithHash = (hash = '') => {
|
|
9
9
|
const url = new URL(window.location.href);
|
|
@@ -42,25 +42,21 @@ function Heading(props) {
|
|
|
42
42
|
const headingIdToUse = invisible ? undefined : headingId;
|
|
43
43
|
return /*#__PURE__*/React.createElement(HX, _extends({
|
|
44
44
|
id: headingIdToUse
|
|
45
|
-
}, dataAttributes), /*#__PURE__*/React.createElement(React.Fragment, null, showAnchorLink && isRightAligned ? WrapChildTextInSpan(props.children) : props.children, showAnchorLink && /*#__PURE__*/React.createElement(
|
|
46
|
-
|
|
47
|
-
}) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return copyTextToClipboard(getCurrentUrlWithHash(headingId));
|
|
61
|
-
}
|
|
62
|
-
}));
|
|
63
|
-
})));
|
|
45
|
+
}, dataAttributes), /*#__PURE__*/React.createElement(React.Fragment, null, showAnchorLink && isRightAligned ? WrapChildTextInSpan(props.children) : props.children, showAnchorLink && headingId && /*#__PURE__*/React.createElement(AnalyticsContext.Consumer, null, ({
|
|
46
|
+
fireAnalyticsEvent
|
|
47
|
+
}) => /*#__PURE__*/React.createElement(HeadingAnchor, {
|
|
48
|
+
enableNestedHeaderLinks: enableNestedHeaderLinks,
|
|
49
|
+
level: props.level,
|
|
50
|
+
onCopyText: () => {
|
|
51
|
+
fireAnalyticsEvent({
|
|
52
|
+
action: ACTION.CLICKED,
|
|
53
|
+
actionSubject: ACTION_SUBJECT.BUTTON,
|
|
54
|
+
actionSubjectId: ACTION_SUBJECT_ID.HEADING_ANCHOR_LINK,
|
|
55
|
+
eventType: EVENT_TYPE.UI
|
|
56
|
+
});
|
|
57
|
+
return copyTextToClipboard(getCurrentUrlWithHash(headingId));
|
|
58
|
+
}
|
|
59
|
+
}))));
|
|
64
60
|
}
|
|
65
61
|
|
|
66
62
|
export default Heading;
|
|
@@ -20,10 +20,16 @@ import { TableCell, TableHeader } from './tableCell';
|
|
|
20
20
|
import TableRow from './tableRow';
|
|
21
21
|
import UnknownBlock from './unknownBlock';
|
|
22
22
|
import { UnsupportedBlock, UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
23
|
+
const WindowedCodeBlock = Loadable({
|
|
24
|
+
loader: () => import(
|
|
25
|
+
/* webpackChunkName: "@atlaskit-internal_renderer-node_WindowedCodeBlock" */
|
|
26
|
+
'./codeBlock/windowedCodeBlock').then(mod => mod.default),
|
|
27
|
+
loading: () => null
|
|
28
|
+
});
|
|
23
29
|
const CodeBlock = Loadable({
|
|
24
30
|
loader: () => import(
|
|
25
31
|
/* webpackChunkName: "@atlaskit-internal_renderer-node_CodeBlock" */
|
|
26
|
-
'./codeBlock').then(mod => mod.default),
|
|
32
|
+
'./codeBlock/codeBlock').then(mod => mod.default),
|
|
27
33
|
loading: () => null
|
|
28
34
|
});
|
|
29
35
|
const TaskList = Loadable({
|
|
@@ -133,7 +139,6 @@ export const nodeToReact = {
|
|
|
133
139
|
bulletList: BulletList,
|
|
134
140
|
blockCard: BlockCard,
|
|
135
141
|
caption: Caption,
|
|
136
|
-
codeBlock: CodeBlock,
|
|
137
142
|
date: Date,
|
|
138
143
|
decisionItem: DecisionItem,
|
|
139
144
|
decisionList: DecisionList,
|
|
@@ -172,12 +177,24 @@ export const nodeToReact = {
|
|
|
172
177
|
nestedExpand: Expand,
|
|
173
178
|
embedCard: EmbedCard
|
|
174
179
|
};
|
|
175
|
-
export const toReact = (node, flags) => {
|
|
180
|
+
export const toReact = (node, flags, nodeComponents) => {
|
|
176
181
|
if (node.type.name === 'doc' && (flags === null || flags === void 0 ? void 0 : flags.allowSelectAllTrap) === true) {
|
|
177
182
|
return DocWithSelectAllTrap;
|
|
178
183
|
}
|
|
179
184
|
|
|
180
|
-
|
|
185
|
+
if (node.type.name === 'codeBlock') {
|
|
186
|
+
if ((flags === null || flags === void 0 ? void 0 : flags.allowWindowedCodeBlock) === true) {
|
|
187
|
+
return WindowedCodeBlock;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return CodeBlock;
|
|
191
|
+
} // Allowing custom components to override those provided in nodeToReact
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
const nodes = { ...nodeToReact,
|
|
195
|
+
...nodeComponents
|
|
196
|
+
};
|
|
197
|
+
return nodes[node.type.name];
|
|
181
198
|
};
|
|
182
199
|
|
|
183
200
|
/*
|
|
@@ -310,4 +327,4 @@ const isEmojiBlock = pnode => {
|
|
|
310
327
|
return emojiCount > 0;
|
|
311
328
|
};
|
|
312
329
|
|
|
313
|
-
export { Blockquote, BodiedExtension, BulletList, BlockCard, Caption, CodeBlock, Date, DecisionItem, DecisionList, Doc, DocWithSelectAllTrap, Emoji, Extension, Expand, HardBreak, Heading, ListItem, InlineCard, InlineExtension, LayoutSection, LayoutColumn, Media, MediaGroup, MediaInline, MediaSingle, Mention, OrderedList, Panel, Paragraph, Placeholder, Rule, Status, TaskItem, TaskList, Table, TableCell, TableRow, UnknownBlock, EmbedCard };
|
|
330
|
+
export { Blockquote, BodiedExtension, BulletList, BlockCard, Caption, CodeBlock, WindowedCodeBlock, Date, DecisionItem, DecisionList, Doc, DocWithSelectAllTrap, Emoji, Extension, Expand, HardBreak, Heading, ListItem, InlineCard, InlineExtension, LayoutSection, LayoutColumn, Media, MediaGroup, MediaInline, MediaSingle, Mention, OrderedList, Panel, Paragraph, Placeholder, Rule, Status, TaskItem, TaskList, Table, TableCell, TableRow, UnknownBlock, EmbedCard };
|