@atlaskit/renderer 108.9.1 → 108.10.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,11 @@
1
1
  # @atlaskit/renderer
2
2
 
3
+ ## 108.10.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`b9a083dc04d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b9a083dc04d) - [ux] Adds error boundaries specific to datasource in editor and renderer. Fallback to unsupported block if no url or inline if url
8
+
3
9
  ## 108.9.1
4
10
 
5
11
  ### Patch Changes
@@ -45,7 +45,8 @@ function BlockCard(props) {
45
45
  url: url,
46
46
  data: data,
47
47
  onClick: onClick,
48
- container: portal
48
+ container: portal,
49
+ isDatasource: !!props.datasource
49
50
  };
50
51
  var analyticsData = {
51
52
  attributes: {
@@ -80,7 +81,7 @@ function BlockCard(props) {
80
81
  return (0, _react2.jsx)(_analyticsNext.AnalyticsContext, {
81
82
  data: analyticsData
82
83
  }, (0, _react2.jsx)(_fallback.CardErrorBoundary, (0, _extends2.default)({
83
- unsupportedComponent: _ui.UnsupportedBlock
84
+ unsupportedComponent: _ui.UnsupportedInline
84
85
  }, cardProps), (0, _react2.jsx)(_ui.WidthConsumer, null, function (_ref4) {
85
86
  var width = _ref4.width;
86
87
  return (0, _react2.jsx)("div", {
@@ -13,6 +13,8 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
13
13
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
15
  var _react = _interopRequireDefault(require("react"));
16
+ var _ = require("./");
17
+ var _adfSchema = require("@atlaskit/adf-schema");
16
18
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
17
19
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
18
20
  var CardErrorBoundary = /*#__PURE__*/function (_React$PureComponent) {
@@ -43,14 +45,19 @@ var CardErrorBoundary = /*#__PURE__*/function (_React$PureComponent) {
43
45
  key: "render",
44
46
  value: function render() {
45
47
  if (this.state.isError) {
46
- var _url = this.props.url;
48
+ var _this$props2 = this.props,
49
+ _url = _this$props2.url,
50
+ isDatasource = _this$props2.isDatasource,
51
+ UnsupportedComponent = _this$props2.unsupportedComponent;
47
52
  if (_url) {
53
+ if (isDatasource && (0, _adfSchema.isSafeUrl)(_url)) {
54
+ return /*#__PURE__*/_react.default.createElement(_.InlineCard, this.props);
55
+ }
48
56
  return /*#__PURE__*/_react.default.createElement("a", {
49
57
  href: _url,
50
58
  onClick: this.onClickFallback
51
59
  }, _url);
52
60
  } else {
53
- var UnsupportedComponent = this.props.unsupportedComponent;
54
61
  return /*#__PURE__*/_react.default.createElement(UnsupportedComponent, null);
55
62
  }
56
63
  }
@@ -63,6 +70,13 @@ var CardErrorBoundary = /*#__PURE__*/function (_React$PureComponent) {
63
70
  isError: true
64
71
  });
65
72
  }
73
+ }], [{
74
+ key: "getDerivedStateFromError",
75
+ value: function getDerivedStateFromError() {
76
+ return {
77
+ isError: true
78
+ };
79
+ }
66
80
  }]);
67
81
  return CardErrorBoundary;
68
82
  }(_react.default.PureComponent);
@@ -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.9.1";
58
+ var packageVersion = "108.10.0";
59
59
  var Renderer = /*#__PURE__*/function (_PureComponent) {
60
60
  (0, _inherits2.default)(Renderer, _PureComponent);
61
61
  var _super = _createSuper(Renderer);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "108.9.1",
3
+ "version": "108.10.0",
4
4
  "sideEffects": false
5
5
  }
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  import { useMemo } from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
5
  import { Card } from '@atlaskit/smart-card';
6
- import { UnsupportedBlock, WidthConsumer } from '@atlaskit/editor-common/ui';
6
+ import { UnsupportedBlock, UnsupportedInline, WidthConsumer } from '@atlaskit/editor-common/ui';
7
7
  import { getPlatform } from '../../utils';
8
8
  import { CardErrorBoundary } from './fallback';
9
9
  import { getCardClickHandler } from '../utils/getCardClickHandler';
@@ -39,7 +39,8 @@ export default function BlockCard(props) {
39
39
  url,
40
40
  data,
41
41
  onClick,
42
- container: portal
42
+ container: portal,
43
+ isDatasource: !!props.datasource
43
44
  };
44
45
  const analyticsData = {
45
46
  attributes: {
@@ -74,7 +75,7 @@ export default function BlockCard(props) {
74
75
  return jsx(AnalyticsContext, {
75
76
  data: analyticsData
76
77
  }, jsx(CardErrorBoundary, _extends({
77
- unsupportedComponent: UnsupportedBlock
78
+ unsupportedComponent: UnsupportedInline
78
79
  }, cardProps), jsx(WidthConsumer, null, ({
79
80
  width
80
81
  }) => jsx("div", {
@@ -1,5 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
+ import { InlineCard } from './';
4
+ import { isSafeUrl } from '@atlaskit/adf-schema';
3
5
  export class CardErrorBoundary extends React.PureComponent {
4
6
  constructor(...args) {
5
7
  super(...args);
@@ -17,20 +19,27 @@ export class CardErrorBoundary extends React.PureComponent {
17
19
  }
18
20
  });
19
21
  }
22
+ static getDerivedStateFromError() {
23
+ return {
24
+ isError: true
25
+ };
26
+ }
20
27
  render() {
21
28
  if (this.state.isError) {
22
29
  const {
23
- url
30
+ url,
31
+ isDatasource,
32
+ unsupportedComponent: UnsupportedComponent
24
33
  } = this.props;
25
34
  if (url) {
35
+ if (isDatasource && isSafeUrl(url)) {
36
+ return /*#__PURE__*/React.createElement(InlineCard, this.props);
37
+ }
26
38
  return /*#__PURE__*/React.createElement("a", {
27
39
  href: url,
28
40
  onClick: this.onClickFallback
29
41
  }, url);
30
42
  } else {
31
- const {
32
- unsupportedComponent: UnsupportedComponent
33
- } = this.props;
34
43
  return /*#__PURE__*/React.createElement(UnsupportedComponent, null);
35
44
  }
36
45
  }
@@ -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.9.1";
38
+ const packageVersion = "108.10.0";
39
39
  export class Renderer extends PureComponent {
40
40
  constructor(props) {
41
41
  super(props);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "108.9.1",
3
+ "version": "108.10.0",
4
4
  "sideEffects": false
5
5
  }
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  import { useMemo } from 'react';
4
4
  import { css, jsx } from '@emotion/react';
5
5
  import { Card } from '@atlaskit/smart-card';
6
- import { UnsupportedBlock, WidthConsumer } from '@atlaskit/editor-common/ui';
6
+ import { UnsupportedBlock, UnsupportedInline, WidthConsumer } from '@atlaskit/editor-common/ui';
7
7
  import { getPlatform } from '../../utils';
8
8
  import { CardErrorBoundary } from './fallback';
9
9
  import { getCardClickHandler } from '../utils/getCardClickHandler';
@@ -38,7 +38,8 @@ export default function BlockCard(props) {
38
38
  url: url,
39
39
  data: data,
40
40
  onClick: onClick,
41
- container: portal
41
+ container: portal,
42
+ isDatasource: !!props.datasource
42
43
  };
43
44
  var analyticsData = {
44
45
  attributes: {
@@ -73,7 +74,7 @@ export default function BlockCard(props) {
73
74
  return jsx(AnalyticsContext, {
74
75
  data: analyticsData
75
76
  }, jsx(CardErrorBoundary, _extends({
76
- unsupportedComponent: UnsupportedBlock
77
+ unsupportedComponent: UnsupportedInline
77
78
  }, cardProps), jsx(WidthConsumer, null, function (_ref4) {
78
79
  var width = _ref4.width;
79
80
  return jsx("div", {
@@ -8,6 +8,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
8
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
9
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
10
  import React from 'react';
11
+ import { InlineCard } from './';
12
+ import { isSafeUrl } from '@atlaskit/adf-schema';
11
13
  export var CardErrorBoundary = /*#__PURE__*/function (_React$PureComponent) {
12
14
  _inherits(CardErrorBoundary, _React$PureComponent);
13
15
  var _super = _createSuper(CardErrorBoundary);
@@ -36,14 +38,19 @@ export var CardErrorBoundary = /*#__PURE__*/function (_React$PureComponent) {
36
38
  key: "render",
37
39
  value: function render() {
38
40
  if (this.state.isError) {
39
- var _url = this.props.url;
41
+ var _this$props2 = this.props,
42
+ _url = _this$props2.url,
43
+ isDatasource = _this$props2.isDatasource,
44
+ UnsupportedComponent = _this$props2.unsupportedComponent;
40
45
  if (_url) {
46
+ if (isDatasource && isSafeUrl(_url)) {
47
+ return /*#__PURE__*/React.createElement(InlineCard, this.props);
48
+ }
41
49
  return /*#__PURE__*/React.createElement("a", {
42
50
  href: _url,
43
51
  onClick: this.onClickFallback
44
52
  }, _url);
45
53
  } else {
46
- var UnsupportedComponent = this.props.unsupportedComponent;
47
54
  return /*#__PURE__*/React.createElement(UnsupportedComponent, null);
48
55
  }
49
56
  }
@@ -56,6 +63,13 @@ export var CardErrorBoundary = /*#__PURE__*/function (_React$PureComponent) {
56
63
  isError: true
57
64
  });
58
65
  }
66
+ }], [{
67
+ key: "getDerivedStateFromError",
68
+ value: function getDerivedStateFromError() {
69
+ return {
70
+ isError: true
71
+ };
72
+ }
59
73
  }]);
60
74
  return CardErrorBoundary;
61
75
  }(React.PureComponent);
@@ -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.9.1";
48
+ var packageVersion = "108.10.0";
49
49
  export var Renderer = /*#__PURE__*/function (_PureComponent) {
50
50
  _inherits(Renderer, _PureComponent);
51
51
  var _super = _createSuper(Renderer);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "108.9.1",
3
+ "version": "108.10.0",
4
4
  "sideEffects": false
5
5
  }
@@ -5,11 +5,15 @@ export type CardErrorBoundaryProps = {
5
5
  export declare class CardErrorBoundary extends React.PureComponent<{
6
6
  url?: string;
7
7
  onClick?: (e: React.MouseEvent<HTMLElement>, url?: string) => void;
8
+ isDatasource?: boolean;
8
9
  } & CardErrorBoundaryProps> {
9
10
  state: {
10
11
  isError: boolean;
11
12
  };
12
13
  onClickFallback: (e: React.MouseEvent<HTMLElement>) => void;
14
+ static getDerivedStateFromError(): {
15
+ isError: boolean;
16
+ };
13
17
  render(): React.ReactNode;
14
18
  componentDidCatch(_error: Error): void;
15
19
  }
@@ -5,11 +5,15 @@ export type CardErrorBoundaryProps = {
5
5
  export declare class CardErrorBoundary extends React.PureComponent<{
6
6
  url?: string;
7
7
  onClick?: (e: React.MouseEvent<HTMLElement>, url?: string) => void;
8
+ isDatasource?: boolean;
8
9
  } & CardErrorBoundaryProps> {
9
10
  state: {
10
11
  isError: boolean;
11
12
  };
12
13
  onClickFallback: (e: React.MouseEvent<HTMLElement>) => void;
14
+ static getDerivedStateFromError(): {
15
+ isError: boolean;
16
+ };
13
17
  render(): React.ReactNode;
14
18
  componentDidCatch(_error: Error): void;
15
19
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/renderer",
3
- "version": "108.9.1",
3
+ "version": "108.10.0",
4
4
  "description": "Renderer component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -35,7 +35,7 @@
35
35
  "@atlaskit/editor-json-transformer": "^8.10.0",
36
36
  "@atlaskit/editor-palette": "1.5.1",
37
37
  "@atlaskit/editor-prosemirror": "1.0.2",
38
- "@atlaskit/editor-shared-styles": "^2.5.0",
38
+ "@atlaskit/editor-shared-styles": "^2.6.0",
39
39
  "@atlaskit/emoji": "^67.4.0",
40
40
  "@atlaskit/icon": "^21.12.0",
41
41
  "@atlaskit/link-datasource": "^0.33.0",