@atlaskit/renderer 108.5.1 → 108.6.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @atlaskit/renderer
2
2
 
3
+ ## 108.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`cb69e6847ec`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cb69e6847ec) - [ux] The table colgroup will always set the width to the min width when the custom-table-width flag is enabled
8
+
9
+ ### Patch Changes
10
+
11
+ - [`0c22ffc68ac`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0c22ffc68ac) - Fix issue where attempting to add an inline comment (annotation) on inline code nodes wrapped in bidi warnings would result in the editor crashing
12
+ - Updated dependencies
13
+
3
14
  ## 108.5.1
4
15
 
5
16
  ### Patch Changes
@@ -39,7 +39,7 @@ var fixColumnWidth = function fixColumnWidth(columnWidth, _tableWidth, _layoutWi
39
39
  // If the tables total width (including no zero widths col or cols without width) is less than the current layout
40
40
  // We scale up the columns to meet the minimum of the table layout.
41
41
  if (zeroWidthColumnsCount === 0 && scaleDownPercent) {
42
- return Math.floor((1 - scaleDownPercent) * columnWidth);
42
+ return Math.max(Math.floor((1 - scaleDownPercent) * columnWidth), _styles.tableCellMinWidth);
43
43
  }
44
44
  return Math.max(
45
45
  // We need to take tableCellBorderWidth, to avoid unneccesary overflow.
@@ -59,7 +59,24 @@ var Colgroup = function Colgroup(props) {
59
59
  isNumberColumnEnabled = props.isNumberColumnEnabled,
60
60
  renderWidth = props.renderWidth,
61
61
  tableNode = props.tableNode;
62
- if (!columnWidths || !isTableResized(columnWidths)) {
62
+ if (!columnWidths) {
63
+ return null;
64
+ }
65
+ var tableResized = isTableResized(columnWidths);
66
+ if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.custom-table-width') && !tableResized) {
67
+ return /*#__PURE__*/_react.default.createElement("colgroup", null, isNumberColumnEnabled && /*#__PURE__*/_react.default.createElement("col", {
68
+ style: {
69
+ width: _editorSharedStyles.akEditorTableNumberColumnWidth
70
+ }
71
+ }), columnWidths.map(function (_, idx) {
72
+ return /*#__PURE__*/_react.default.createElement("col", {
73
+ key: idx,
74
+ style: {
75
+ width: "".concat(_styles.tableCellMinWidth, "px")
76
+ }
77
+ });
78
+ }));
79
+ } else if (!tableResized) {
63
80
  return null;
64
81
  }
65
82
  var tableContainerWidth;
@@ -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 = "108.5.1";
58
+ var packageVersion = "108.6.0";
59
59
  var Renderer = /*#__PURE__*/function (_PureComponent) {
60
60
  (0, _inherits2.default)(Renderer, _PureComponent);
61
61
  var _super = _createSuper(Renderer);
@@ -90,8 +90,12 @@ var TextWithAnnotationDraft = function TextWithAnnotationDraft(_ref3) {
90
90
  draftPosition: nextDraftPosition
91
91
  }, children);
92
92
  }
93
- var offsets = (0, _text.calcTextSplitOffset)(nextDraftPosition, textPosition, children);
94
- var texts = (0, _text.splitText)(children, offsets);
93
+ var textString = (0, _text.findTextString)(children);
94
+ if (!textString) {
95
+ return (0, _react2.jsx)(_react.Fragment, null, children);
96
+ }
97
+ var offsets = (0, _text.calcTextSplitOffset)(nextDraftPosition, textPosition, textString);
98
+ var texts = (0, _text.splitText)(textString, offsets);
95
99
  if (!texts) {
96
100
  return (0, _react2.jsx)(_react.Fragment, null, children);
97
101
  }
@@ -1,9 +1,41 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
- exports.splitText = exports.calcTextSplitOffset = void 0;
7
+ exports.splitText = exports.findTextString = exports.calcTextSplitOffset = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
10
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
12
+ var findTextString = function findTextString(reactNode) {
13
+ var result = null;
14
+ var children = _react.default.Children.toArray(reactNode);
15
+ var _iterator = _createForOfIteratorHelper(children),
16
+ _step;
17
+ try {
18
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
19
+ var childNode = _step.value;
20
+ if (result) {
21
+ break;
22
+ } else if (typeof childNode === 'string') {
23
+ result = childNode;
24
+ } else if (isReactElement(childNode) && childNode.props.children) {
25
+ result = findTextString(childNode.props.children);
26
+ }
27
+ }
28
+ } catch (err) {
29
+ _iterator.e(err);
30
+ } finally {
31
+ _iterator.f();
32
+ }
33
+ return result;
34
+ };
35
+ exports.findTextString = findTextString;
36
+ function isReactElement(child) {
37
+ return !!child.type;
38
+ }
7
39
  var splitText = function splitText(text, _ref) {
8
40
  var startOffset = _ref.startOffset,
9
41
  endOffset = _ref.endOffset;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "108.5.1",
3
+ "version": "108.6.0",
4
4
  "sideEffects": false
5
5
  }
@@ -30,7 +30,7 @@ const fixColumnWidth = (columnWidth, _tableWidth, _layoutWidth, zeroWidthColumns
30
30
  // If the tables total width (including no zero widths col or cols without width) is less than the current layout
31
31
  // We scale up the columns to meet the minimum of the table layout.
32
32
  if (zeroWidthColumnsCount === 0 && scaleDownPercent) {
33
- return Math.floor((1 - scaleDownPercent) * columnWidth);
33
+ return Math.max(Math.floor((1 - scaleDownPercent) * columnWidth), tableCellMinWidth);
34
34
  }
35
35
  return Math.max(
36
36
  // We need to take tableCellBorderWidth, to avoid unneccesary overflow.
@@ -52,7 +52,22 @@ export const Colgroup = props => {
52
52
  renderWidth,
53
53
  tableNode
54
54
  } = props;
55
- if (!columnWidths || !isTableResized(columnWidths)) {
55
+ if (!columnWidths) {
56
+ return null;
57
+ }
58
+ const tableResized = isTableResized(columnWidths);
59
+ if (getBooleanFF('platform.editor.custom-table-width') && !tableResized) {
60
+ return /*#__PURE__*/React.createElement("colgroup", null, isNumberColumnEnabled && /*#__PURE__*/React.createElement("col", {
61
+ style: {
62
+ width: akEditorTableNumberColumnWidth
63
+ }
64
+ }), columnWidths.map((_, idx) => /*#__PURE__*/React.createElement("col", {
65
+ key: idx,
66
+ style: {
67
+ width: `${tableCellMinWidth}px`
68
+ }
69
+ })));
70
+ } else if (!tableResized) {
56
71
  return null;
57
72
  }
58
73
  let tableContainerWidth;
@@ -35,7 +35,7 @@ import { RenderTracking } from '../../react/utils/performance/RenderTracking';
35
35
  export const NORMAL_SEVERITY_THRESHOLD = 2000;
36
36
  export const DEGRADED_SEVERITY_THRESHOLD = 3000;
37
37
  const packageName = "@atlaskit/renderer";
38
- const packageVersion = "108.5.1";
38
+ const packageVersion = "108.6.0";
39
39
  export class Renderer extends PureComponent {
40
40
  constructor(props) {
41
41
  super(props);
@@ -4,7 +4,7 @@ import React, { Fragment } from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
5
  import { InsertDraftPosition } from '../types';
6
6
  import { AnnotationsDraftContext } from '../context';
7
- import { splitText, calcTextSplitOffset } from './text';
7
+ import { splitText, calcTextSplitOffset, findTextString } from './text';
8
8
  import { calcInsertDraftPositionOnText } from './position';
9
9
  import { dataAttributes } from './dom';
10
10
  import { AnnotationSharedCSSByState } from '@atlaskit/editor-common/styles';
@@ -80,8 +80,12 @@ export const TextWithAnnotationDraft = ({
80
80
  draftPosition: nextDraftPosition
81
81
  }, children);
82
82
  }
83
- const offsets = calcTextSplitOffset(nextDraftPosition, textPosition, children);
84
- const texts = splitText(children, offsets);
83
+ const textString = findTextString(children);
84
+ if (!textString) {
85
+ return jsx(Fragment, null, children);
86
+ }
87
+ const offsets = calcTextSplitOffset(nextDraftPosition, textPosition, textString);
88
+ const texts = splitText(textString, offsets);
85
89
  if (!texts) {
86
90
  return jsx(Fragment, null, children);
87
91
  }
@@ -1,3 +1,21 @@
1
+ import React from 'react';
2
+ export const findTextString = reactNode => {
3
+ let result = null;
4
+ const children = React.Children.toArray(reactNode);
5
+ for (const childNode of children) {
6
+ if (result) {
7
+ break;
8
+ } else if (typeof childNode === 'string') {
9
+ result = childNode;
10
+ } else if (isReactElement(childNode) && childNode.props.children) {
11
+ result = findTextString(childNode.props.children);
12
+ }
13
+ }
14
+ return result;
15
+ };
16
+ function isReactElement(child) {
17
+ return !!child.type;
18
+ }
1
19
  export const splitText = (text, {
2
20
  startOffset,
3
21
  endOffset
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "108.5.1",
3
+ "version": "108.6.0",
4
4
  "sideEffects": false
5
5
  }
@@ -32,7 +32,7 @@ var fixColumnWidth = function fixColumnWidth(columnWidth, _tableWidth, _layoutWi
32
32
  // If the tables total width (including no zero widths col or cols without width) is less than the current layout
33
33
  // We scale up the columns to meet the minimum of the table layout.
34
34
  if (zeroWidthColumnsCount === 0 && scaleDownPercent) {
35
- return Math.floor((1 - scaleDownPercent) * columnWidth);
35
+ return Math.max(Math.floor((1 - scaleDownPercent) * columnWidth), tableCellMinWidth);
36
36
  }
37
37
  return Math.max(
38
38
  // We need to take tableCellBorderWidth, to avoid unneccesary overflow.
@@ -51,7 +51,24 @@ export var Colgroup = function Colgroup(props) {
51
51
  isNumberColumnEnabled = props.isNumberColumnEnabled,
52
52
  renderWidth = props.renderWidth,
53
53
  tableNode = props.tableNode;
54
- if (!columnWidths || !isTableResized(columnWidths)) {
54
+ if (!columnWidths) {
55
+ return null;
56
+ }
57
+ var tableResized = isTableResized(columnWidths);
58
+ if (getBooleanFF('platform.editor.custom-table-width') && !tableResized) {
59
+ return /*#__PURE__*/React.createElement("colgroup", null, isNumberColumnEnabled && /*#__PURE__*/React.createElement("col", {
60
+ style: {
61
+ width: akEditorTableNumberColumnWidth
62
+ }
63
+ }), columnWidths.map(function (_, idx) {
64
+ return /*#__PURE__*/React.createElement("col", {
65
+ key: idx,
66
+ style: {
67
+ width: "".concat(tableCellMinWidth, "px")
68
+ }
69
+ });
70
+ }));
71
+ } else if (!tableResized) {
55
72
  return null;
56
73
  }
57
74
  var tableContainerWidth;
@@ -45,7 +45,7 @@ import { RenderTracking } from '../../react/utils/performance/RenderTracking';
45
45
  export var NORMAL_SEVERITY_THRESHOLD = 2000;
46
46
  export var DEGRADED_SEVERITY_THRESHOLD = 3000;
47
47
  var packageName = "@atlaskit/renderer";
48
- var packageVersion = "108.5.1";
48
+ var packageVersion = "108.6.0";
49
49
  export var Renderer = /*#__PURE__*/function (_PureComponent) {
50
50
  _inherits(Renderer, _PureComponent);
51
51
  var _super = _createSuper(Renderer);
@@ -6,7 +6,7 @@ import React, { Fragment } from 'react';
6
6
  import { css, jsx } from '@emotion/react';
7
7
  import { InsertDraftPosition } from '../types';
8
8
  import { AnnotationsDraftContext } from '../context';
9
- import { splitText, calcTextSplitOffset } from './text';
9
+ import { splitText, calcTextSplitOffset, findTextString } from './text';
10
10
  import { calcInsertDraftPositionOnText } from './position';
11
11
  import { dataAttributes } from './dom';
12
12
  import { AnnotationSharedCSSByState } from '@atlaskit/editor-common/styles';
@@ -77,8 +77,12 @@ export var TextWithAnnotationDraft = function TextWithAnnotationDraft(_ref3) {
77
77
  draftPosition: nextDraftPosition
78
78
  }, children);
79
79
  }
80
- var offsets = calcTextSplitOffset(nextDraftPosition, textPosition, children);
81
- var texts = splitText(children, offsets);
80
+ var textString = findTextString(children);
81
+ if (!textString) {
82
+ return jsx(Fragment, null, children);
83
+ }
84
+ var offsets = calcTextSplitOffset(nextDraftPosition, textPosition, textString);
85
+ var texts = splitText(textString, offsets);
82
86
  if (!texts) {
83
87
  return jsx(Fragment, null, children);
84
88
  }
@@ -1,3 +1,33 @@
1
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
4
+ import React from 'react';
5
+ export var findTextString = function findTextString(reactNode) {
6
+ var result = null;
7
+ var children = React.Children.toArray(reactNode);
8
+ var _iterator = _createForOfIteratorHelper(children),
9
+ _step;
10
+ try {
11
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
12
+ var childNode = _step.value;
13
+ if (result) {
14
+ break;
15
+ } else if (typeof childNode === 'string') {
16
+ result = childNode;
17
+ } else if (isReactElement(childNode) && childNode.props.children) {
18
+ result = findTextString(childNode.props.children);
19
+ }
20
+ }
21
+ } catch (err) {
22
+ _iterator.e(err);
23
+ } finally {
24
+ _iterator.f();
25
+ }
26
+ return result;
27
+ };
28
+ function isReactElement(child) {
29
+ return !!child.type;
30
+ }
1
31
  export var splitText = function splitText(text, _ref) {
2
32
  var startOffset = _ref.startOffset,
3
33
  endOffset = _ref.endOffset;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "108.5.1",
3
+ "version": "108.6.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,8 +1,8 @@
1
- /// <reference types="react" />
1
+ import { ReactNode } from 'react';
2
2
  type Props = {
3
3
  startPos: number;
4
4
  endPos: number;
5
- children?: string | null;
5
+ children?: ReactNode | null;
6
6
  };
7
7
  declare const TextWrapper: (props: Props) => JSX.Element | null;
8
8
  export default TextWrapper;
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
- import React from 'react';
2
+ import React, { ReactNode } from 'react';
3
3
  import { InsertDraftPosition, Position } from '../types';
4
4
  export declare const AnnotationDraft: React.FC<{
5
5
  draftPosition: Position;
@@ -14,7 +14,7 @@ export declare const applyAnnotationOnText: ({ texts, shouldApplyAnnotationAt, d
14
14
  type Props = {
15
15
  startPos: number;
16
16
  endPos: number;
17
- children: string;
17
+ children: ReactNode;
18
18
  };
19
19
  export declare const TextWithAnnotationDraft: React.FC<Props>;
20
20
  export {};
@@ -1,4 +1,6 @@
1
+ import React from 'react';
1
2
  import { TextPosition, Position } from '../types';
3
+ export declare const findTextString: (reactNode: React.ReactNode) => string | null;
2
4
  type Offset = {
3
5
  startOffset: number;
4
6
  endOffset: number;
@@ -1,8 +1,8 @@
1
- /// <reference types="react" />
1
+ import { ReactNode } from 'react';
2
2
  type Props = {
3
3
  startPos: number;
4
4
  endPos: number;
5
- children?: string | null;
5
+ children?: ReactNode | null;
6
6
  };
7
7
  declare const TextWrapper: (props: Props) => JSX.Element | null;
8
8
  export default TextWrapper;
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
- import React from 'react';
2
+ import React, { ReactNode } from 'react';
3
3
  import { InsertDraftPosition, Position } from '../types';
4
4
  export declare const AnnotationDraft: React.FC<{
5
5
  draftPosition: Position;
@@ -14,7 +14,7 @@ export declare const applyAnnotationOnText: ({ texts, shouldApplyAnnotationAt, d
14
14
  type Props = {
15
15
  startPos: number;
16
16
  endPos: number;
17
- children: string;
17
+ children: ReactNode;
18
18
  };
19
19
  export declare const TextWithAnnotationDraft: React.FC<Props>;
20
20
  export {};
@@ -1,4 +1,6 @@
1
+ import React from 'react';
1
2
  import { TextPosition, Position } from '../types';
3
+ export declare const findTextString: (reactNode: React.ReactNode) => string | null;
2
4
  type Offset = {
3
5
  startOffset: number;
4
6
  endOffset: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "108.5.1",
3
+ "version": "108.6.0",
4
4
  "description": "Renderer component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -57,7 +57,7 @@
57
57
  "@atlaskit/status": "^1.3.0",
58
58
  "@atlaskit/task-decision": "^17.6.0",
59
59
  "@atlaskit/theme": "^12.5.0",
60
- "@atlaskit/tokens": "^1.10.0",
60
+ "@atlaskit/tokens": "^1.11.0",
61
61
  "@atlaskit/tooltip": "^17.8.0",
62
62
  "@babel/runtime": "^7.0.0",
63
63
  "@emotion/react": "^11.7.1",