@atlaskit/renderer 107.1.0 → 107.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/dist/cjs/analytics/enums.js +61 -1
- package/dist/cjs/react/index.js +10 -1
- package/dist/cjs/react/nodes/blockCard.js +6 -2
- package/dist/cjs/react/nodes/codeBlock/codeBlock.js +18 -6
- package/dist/cjs/react/nodes/codeBlock/components/codeBlockButtonContainer.js +67 -0
- package/dist/cjs/react/nodes/codeBlock/components/codeBlockContainer.js +15 -8
- package/dist/cjs/react/nodes/codeBlock/components/codeBlockCopyButton.js +71 -0
- package/dist/cjs/react/nodes/codeBlock/components/codeBlockWrapButton.js +76 -0
- package/dist/cjs/react/nodes/codeBlock/windowedCodeBlock.js +13 -2
- package/dist/cjs/react/nodes/inlineCard.js +5 -2
- package/dist/cjs/react/nodes/media.js +18 -1
- package/dist/cjs/react/nodes/mediaInline.js +19 -4
- package/dist/cjs/react/nodes/tableCell.js +6 -1
- package/dist/cjs/ui/Renderer/index.js +5 -1
- package/dist/cjs/ui/Renderer/style.js +2 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/enums.js +55 -1
- package/dist/es2019/react/index.js +7 -1
- package/dist/es2019/react/nodes/blockCard.js +7 -2
- package/dist/es2019/react/nodes/codeBlock/codeBlock.js +10 -3
- package/dist/es2019/react/nodes/codeBlock/components/codeBlockButtonContainer.js +59 -0
- package/dist/es2019/react/nodes/codeBlock/components/codeBlockContainer.js +25 -8
- package/dist/es2019/react/nodes/codeBlock/components/codeBlockCopyButton.js +52 -0
- package/dist/es2019/react/nodes/codeBlock/components/codeBlockWrapButton.js +67 -0
- package/dist/es2019/react/nodes/codeBlock/windowedCodeBlock.js +9 -4
- package/dist/es2019/react/nodes/inlineCard.js +5 -2
- package/dist/es2019/react/nodes/media.js +18 -1
- package/dist/es2019/react/nodes/mediaInline.js +19 -4
- package/dist/es2019/react/nodes/tableCell.js +6 -1
- package/dist/es2019/ui/Renderer/index.js +5 -1
- package/dist/es2019/ui/Renderer/style.js +9 -11
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/enums.js +55 -1
- package/dist/esm/react/index.js +10 -1
- package/dist/esm/react/nodes/blockCard.js +6 -2
- package/dist/esm/react/nodes/codeBlock/codeBlock.js +15 -3
- package/dist/esm/react/nodes/codeBlock/components/codeBlockButtonContainer.js +58 -0
- package/dist/esm/react/nodes/codeBlock/components/codeBlockContainer.js +15 -9
- package/dist/esm/react/nodes/codeBlock/components/codeBlockCopyButton.js +59 -0
- package/dist/esm/react/nodes/codeBlock/components/codeBlockWrapButton.js +67 -0
- package/dist/esm/react/nodes/codeBlock/windowedCodeBlock.js +14 -4
- package/dist/esm/react/nodes/inlineCard.js +5 -2
- package/dist/esm/react/nodes/media.js +18 -1
- package/dist/esm/react/nodes/mediaInline.js +19 -4
- package/dist/esm/react/nodes/tableCell.js +6 -1
- package/dist/esm/ui/Renderer/index.js +5 -1
- package/dist/esm/ui/Renderer/style.js +2 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/enums.d.ts +51 -0
- package/dist/types/analytics/events.d.ts +5 -1
- package/dist/types/react/index.d.ts +2 -0
- package/dist/types/react/nodes/blockCard.d.ts +2 -0
- package/dist/types/react/nodes/codeBlock/codeBlock.d.ts +1 -0
- package/dist/types/react/nodes/codeBlock/components/codeBlockButtonContainer.d.ts +12 -0
- package/dist/types/react/nodes/codeBlock/components/codeBlockContainer.d.ts +5 -7
- package/dist/types/react/nodes/codeBlock/components/codeBlockWrapButton.d.ts +11 -0
- package/dist/types/react/nodes/codeBlock/windowedCodeBlock.d.ts +1 -1
- package/dist/types/react/nodes/index.d.ts +1 -0
- package/dist/types/react/nodes/media.d.ts +3 -2
- package/dist/types/react/nodes/mediaInline.d.ts +6 -0
- package/dist/types/react/types.d.ts +1 -0
- package/dist/types/types/smartLinksOptions.d.ts +1 -0
- package/dist/types/ui/renderer-props.d.ts +1 -0
- package/package.json +20 -20
- package/report.api.md +21 -2
- package/dist/cjs/react/nodes/codeBlockCopyButton.js +0 -64
- package/dist/es2019/react/nodes/codeBlockCopyButton.js +0 -86
- package/dist/esm/react/nodes/codeBlockCopyButton.js +0 -54
- /package/dist/types/react/nodes/{codeBlockCopyButton.d.ts → codeBlock/components/codeBlockCopyButton.d.ts} +0 -0
|
@@ -17,6 +17,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
17
17
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
18
18
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
19
19
|
var _types = require("@atlaskit/editor-common/types");
|
|
20
|
+
var _editorPalette = require("@atlaskit/editor-palette");
|
|
21
|
+
var _tokens = require("@atlaskit/tokens");
|
|
20
22
|
var _SortingIcon = _interopRequireDefault(require("../../ui/SortingIcon"));
|
|
21
23
|
var _events = require("../../analytics/events");
|
|
22
24
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
@@ -81,7 +83,10 @@ var getStyle = function getStyle(background, colGroupWidth, offsetTop) {
|
|
|
81
83
|
if (background &&
|
|
82
84
|
// ignore setting inline styles if ds neutral token is detected
|
|
83
85
|
!background.includes('--ds-background-neutral')) {
|
|
84
|
-
|
|
86
|
+
var tokenName = (0, _editorPalette.hexToEditorBackgroundPaletteColorTokenName)(background);
|
|
87
|
+
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-design-token-usage
|
|
88
|
+
var tokenColor = tokenName ? (0, _tokens.getTokenValue)(tokenName) : background;
|
|
89
|
+
style.backgroundColor = tokenColor;
|
|
85
90
|
}
|
|
86
91
|
if (colGroupWidth) {
|
|
87
92
|
style.width = colGroupWidth;
|
|
@@ -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.0";
|
|
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,6 +295,7 @@ 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;
|
|
298
300
|
var allowNestedHeaderLinks = (0, _links.isNestedHeaderLinksEnabled)(allowHeadingAnchorLinks);
|
|
299
301
|
/**
|
|
@@ -366,6 +368,7 @@ var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
366
368
|
allowNestedHeaderLinks: allowNestedHeaderLinks,
|
|
367
369
|
allowColumnSorting: allowColumnSorting,
|
|
368
370
|
allowCopyToClipboard: allowCopyToClipboard,
|
|
371
|
+
allowWrapCodeBlock: allowWrapCodeBlock,
|
|
369
372
|
allowCustomPanels: allowCustomPanels,
|
|
370
373
|
allowPlaceholderText: allowPlaceholderText,
|
|
371
374
|
innerRef: this.editorRef,
|
|
@@ -396,6 +399,7 @@ var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
396
399
|
return (0, _react2.jsx)(RendererWrapper, {
|
|
397
400
|
appearance: appearance,
|
|
398
401
|
allowCopyToClipboard: allowCopyToClipboard,
|
|
402
|
+
allowWrapCodeBlock: allowWrapCodeBlock,
|
|
399
403
|
allowPlaceholderText: allowPlaceholderText,
|
|
400
404
|
allowColumnSorting: allowColumnSorting,
|
|
401
405
|
allowNestedHeaderLinks: allowNestedHeaderLinks,
|
|
@@ -91,7 +91,7 @@ var rendererStyles = function rendererStyles(wrapperProps) {
|
|
|
91
91
|
var themeProps = {
|
|
92
92
|
theme: theme
|
|
93
93
|
};
|
|
94
|
-
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
|
|
94
|
+
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\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
95
|
light: "var(--ds-text, ".concat(colors.N800, ")"),
|
|
96
96
|
dark: "var(--ds-text, #B8C7E0)"
|
|
97
97
|
})(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)({
|
|
@@ -127,7 +127,7 @@ var rendererStyles = function rendererStyles(wrapperProps) {
|
|
|
127
127
|
})(themeProps), (0, _components.themed)({
|
|
128
128
|
light: "var(--ds-border, ".concat(_editorSharedStyles.akEditorTableToolbar, ")"),
|
|
129
129
|
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 : '');
|
|
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, _editorSharedStyles.blockNodesVerticalMargin, _utils.browser.safari ? _styles.codeBlockInListSafariFix : '');
|
|
131
131
|
};
|
|
132
132
|
};
|
|
133
133
|
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,
|
|
@@ -11,8 +11,12 @@ export default function BlockCard(props) {
|
|
|
11
11
|
data,
|
|
12
12
|
eventHandlers,
|
|
13
13
|
portal,
|
|
14
|
-
rendererAppearance
|
|
14
|
+
rendererAppearance,
|
|
15
|
+
smartLinks
|
|
15
16
|
} = props;
|
|
17
|
+
const {
|
|
18
|
+
showServerActions
|
|
19
|
+
} = smartLinks || {};
|
|
16
20
|
const onClick = getCardClickHandler(eventHandlers, url);
|
|
17
21
|
const platform = useMemo(() => getPlatform(rendererAppearance), [rendererAppearance]);
|
|
18
22
|
const cardProps = {
|
|
@@ -31,6 +35,7 @@ export default function BlockCard(props) {
|
|
|
31
35
|
}, cardProps), /*#__PURE__*/React.createElement(Card, _extends({
|
|
32
36
|
appearance: "block",
|
|
33
37
|
showActions: rendererAppearance !== 'mobile',
|
|
34
|
-
platform: platform
|
|
38
|
+
platform: platform,
|
|
39
|
+
showServerActions: showServerActions
|
|
35
40
|
}, cardProps))));
|
|
36
41
|
}
|
|
@@ -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;
|
|
@@ -25,13 +25,15 @@ const InlineCard = props => {
|
|
|
25
25
|
const featureFlags = useFeatureFlags();
|
|
26
26
|
const {
|
|
27
27
|
showAuthTooltip,
|
|
28
|
+
showServerActions,
|
|
28
29
|
ssr
|
|
29
30
|
} = smartLinks || {};
|
|
30
31
|
if (ssr && url) {
|
|
31
32
|
return /*#__PURE__*/React.createElement(CardSSR, {
|
|
32
33
|
appearance: "inline",
|
|
33
34
|
url: url,
|
|
34
|
-
showAuthTooltip: showAuthTooltip
|
|
35
|
+
showAuthTooltip: showAuthTooltip,
|
|
36
|
+
showServerActions: showServerActions
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
39
|
return /*#__PURE__*/React.createElement("span", {
|
|
@@ -43,7 +45,8 @@ const InlineCard = props => {
|
|
|
43
45
|
}, cardProps), /*#__PURE__*/React.createElement(Card, _extends({
|
|
44
46
|
appearance: "inline",
|
|
45
47
|
showHoverPreview: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.showHoverPreview,
|
|
46
|
-
showAuthTooltip: showAuthTooltip
|
|
48
|
+
showAuthTooltip: showAuthTooltip,
|
|
49
|
+
showServerActions: showServerActions
|
|
47
50
|
}, cardProps, {
|
|
48
51
|
onResolve: data => {
|
|
49
52
|
if (!data.url || !data.title) {
|
|
@@ -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 {
|