@atlaskit/editor-card-provider 3.0.3 → 3.0.5

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,17 @@
1
1
  # @atlaskit/editor-card-provider
2
2
 
3
+ ## 3.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 3.0.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [`1674b5907b4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1674b5907b4) - [ux] Make confluence whiteboard urls default to embed view
14
+
3
15
  ## 3.0.3
4
16
 
5
17
  ### Patch Changes
@@ -11,6 +11,8 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
11
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
12
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
13
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
14
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
15
+ var _setPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/setPrototypeOf"));
14
16
  require("setimmediate");
15
17
  var _dataloader = _interopRequireDefault(require("dataloader"));
16
18
  var _linkingCommon = require("@atlaskit/linking-common");
@@ -21,9 +23,8 @@ var _linkProvider = require("@atlaskit/link-provider");
21
23
  var api = _interopRequireWildcard(require("./api"));
22
24
  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); }
23
25
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
24
- // import setimmediate to temporary fix dataloader 2.0.0 bug
26
+ function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, void 0, groups); }; var _super = RegExp.prototype, _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = new RegExp(re, flags); return _groups.set(_this, groups || _groups.get(re)), (0, _setPrototypeOf2.default)(_this, BabelRegExp.prototype); } function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { var i = g[name]; if ("number" == typeof i) groups[name] = result[i];else { for (var k = 0; void 0 === result[i[k]] && k + 1 < i.length;) k++; groups[name] = result[i[k]]; } return groups; }, Object.create(null)); } return (0, _inherits2.default)(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) { result.groups = buildGroups(result, this); var indices = result.indices; indices && (indices.groups = buildGroups(indices, this)); } return result; }, BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if ("string" == typeof substitution) { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { var group = groups[name]; return "$" + (Array.isArray(group) ? group.join("$") : group); })); } if ("function" == typeof substitution) { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = arguments; return "object" != _typeof(args[args.length - 1]) && (args = [].slice.call(args)).push(buildGroups(args, _this)), substitution.apply(this, args); }); } return _super[Symbol.replace].call(this, str, substitution); }, _wrapRegExp.apply(this, arguments); } // import setimmediate to temporary fix dataloader 2.0.0 bug
25
27
  // @see https://github.com/graphql/dataloader/issues/249
26
-
27
28
  var BATCH_WAIT_TIME = 50;
28
29
 
29
30
  // Check if it is matching a Jira Roadmaps or Jira Timeline url
@@ -43,9 +44,16 @@ var isGiphyMedia = function isGiphyMedia(url) {
43
44
  var isProformaView = function isProformaView(url) {
44
45
  return url.match(/^https:\/\/[^/]+\/jira\/(core|software(\/c)?|servicedesk)\/projects\/\w+\/forms\/form\/direct\/\d+\/\d+.*$/);
45
46
  };
47
+ var isConfluenceWhiteboard = function isConfluenceWhiteboard(url) {
48
+ return url.match( /*#__PURE__*/_wrapRegExp(/\/wiki\/spaces\/?.*\/whiteboard\/(\d+)(\?\/)?/, {
49
+ resourceId: 1
50
+ })) || url.match( /*#__PURE__*/_wrapRegExp(/\/wiki\/spaces\/?.*\/whiteboard\/([0-9a-fA-F]{8}\b\x2D[0-9a-fA-F]{4}\b\x2D[0-9a-fA-F]{4}\b\x2D[0-9a-fA-F]{4}\b\x2D[0-9a-fA-F]{12})(\?\/)?/, {
51
+ resourceId: 1
52
+ }));
53
+ };
46
54
  var EditorCardProvider = /*#__PURE__*/function () {
47
55
  function EditorCardProvider(envKey, baseUrlOverride) {
48
- var _this = this;
56
+ var _this2 = this;
49
57
  (0, _classCallCheck2.default)(this, EditorCardProvider);
50
58
  this.baseUrl = baseUrlOverride || (0, _environments.getBaseUrl)(envKey);
51
59
  this.resolverUrl = (0, _environments.getResolverUrl)(envKey, baseUrlOverride);
@@ -54,7 +62,7 @@ var EditorCardProvider = /*#__PURE__*/function () {
54
62
  Origin: this.baseUrl
55
63
  };
56
64
  this.providersLoader = new _dataloader.default(function (keys) {
57
- return _this.batchProviders(keys);
65
+ return _this2.batchProviders(keys);
58
66
  }, {
59
67
  batchScheduleFn: function batchScheduleFn(callback) {
60
68
  return setTimeout(callback, BATCH_WAIT_TIME);
@@ -233,7 +241,7 @@ var EditorCardProvider = /*#__PURE__*/function () {
233
241
  value: function () {
234
242
  var _findUserPreference = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(url) {
235
243
  var _this$providersData,
236
- _this2 = this;
244
+ _this3 = this;
237
245
  var userPreferences, defaultAppearance, appearances, allMatchedLabeledAppearances, longestMatchedLabeledAppearance;
238
246
  return _regenerator.default.wrap(function _callee6$(_context6) {
239
247
  while (1) switch (_context6.prev = _context6.next) {
@@ -253,7 +261,7 @@ var EditorCardProvider = /*#__PURE__*/function () {
253
261
  defaultAppearance = userPreferences.defaultAppearance, appearances = userPreferences.appearances;
254
262
  allMatchedLabeledAppearances = appearances.filter(function (_ref) {
255
263
  var urlSegment = _ref.urlSegment;
256
- return _this2.doesUrlMatchPath(urlSegment, url);
264
+ return _this3.doesUrlMatchPath(urlSegment, url);
257
265
  });
258
266
  if (!(allMatchedLabeledAppearances.length > 0)) {
259
267
  _context6.next = 10;
@@ -312,7 +320,7 @@ var EditorCardProvider = /*#__PURE__*/function () {
312
320
  }, {
313
321
  key: "getHardCodedAppearance",
314
322
  value: function getHardCodedAppearance(url) {
315
- if (isJiraRoadmapOrTimeline(url) || isPolarisView(url) || isJwmView(url) || isGiphyMedia(url) || isProformaView(url)) {
323
+ if (isJiraRoadmapOrTimeline(url) || isPolarisView(url) || isJwmView(url) || isGiphyMedia(url) || isProformaView(url) || isConfluenceWhiteboard(url)) {
316
324
  return 'embed';
317
325
  }
318
326
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-card-provider",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "sideEffects": false
5
5
  }
@@ -17,6 +17,7 @@ const isPolarisView = url => url.match(/^https:\/\/.*?\/jira\/polaris\/projects\
17
17
  const isJwmView = url => url.match(/^https:\/\/.*?\/jira\/core\/projects\/[^\/]+?\/(timeline|calendar|list|board|summary|(form\/[^\/]+?))\/?/);
18
18
  const isGiphyMedia = url => url.match(/^https:\/\/(.*?\.)?giphy\.com\/(gifs|media|clips)\//);
19
19
  const isProformaView = url => url.match(/^https:\/\/[^/]+\/jira\/(core|software(\/c)?|servicedesk)\/projects\/\w+\/forms\/form\/direct\/\d+\/\d+.*$/);
20
+ const isConfluenceWhiteboard = url => url.match(/\/wiki\/spaces\/?.*\/whiteboard\/(?<resourceId>\d+)(\?\/)?/) || url.match(/\/wiki\/spaces\/?.*\/whiteboard\/(?<resourceId>[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12})(\?\/)?/);
20
21
  export class EditorCardProvider {
21
22
  constructor(envKey, baseUrlOverride) {
22
23
  this.baseUrl = baseUrlOverride || getBaseUrl(envKey);
@@ -108,7 +109,7 @@ export class EditorCardProvider {
108
109
  return (_this$providersData2 = this.providersData) === null || _this$providersData2 === void 0 ? void 0 : _this$providersData2.patterns.find(pattern => url.match(pattern.source));
109
110
  }
110
111
  getHardCodedAppearance(url) {
111
- if (isJiraRoadmapOrTimeline(url) || isPolarisView(url) || isJwmView(url) || isGiphyMedia(url) || isProformaView(url)) {
112
+ if (isJiraRoadmapOrTimeline(url) || isPolarisView(url) || isJwmView(url) || isGiphyMedia(url) || isProformaView(url) || isConfluenceWhiteboard(url)) {
112
113
  return 'embed';
113
114
  }
114
115
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-card-provider",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "sideEffects": false
5
5
  }
@@ -1,8 +1,12 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
1
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
4
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
5
  import _createClass from "@babel/runtime/helpers/createClass";
6
+ import _inherits from "@babel/runtime/helpers/inherits";
7
+ import _setPrototypeOf from "@babel/runtime/helpers/setPrototypeOf";
5
8
  import _regeneratorRuntime from "@babel/runtime/regenerator";
9
+ function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, void 0, groups); }; var _super = RegExp.prototype, _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = new RegExp(re, flags); return _groups.set(_this, groups || _groups.get(re)), _setPrototypeOf(_this, BabelRegExp.prototype); } function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { var i = g[name]; if ("number" == typeof i) groups[name] = result[i];else { for (var k = 0; void 0 === result[i[k]] && k + 1 < i.length;) k++; groups[name] = result[i[k]]; } return groups; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) { result.groups = buildGroups(result, this); var indices = result.indices; indices && (indices.groups = buildGroups(indices, this)); } return result; }, BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if ("string" == typeof substitution) { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { var group = groups[name]; return "$" + (Array.isArray(group) ? group.join("$") : group); })); } if ("function" == typeof substitution) { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = arguments; return "object" != _typeof(args[args.length - 1]) && (args = [].slice.call(args)).push(buildGroups(args, _this)), substitution.apply(this, args); }); } return _super[Symbol.replace].call(this, str, substitution); }, _wrapRegExp.apply(this, arguments); }
6
10
  // import setimmediate to temporary fix dataloader 2.0.0 bug
7
11
  // @see https://github.com/graphql/dataloader/issues/249
8
12
  import 'setimmediate';
@@ -32,9 +36,16 @@ var isGiphyMedia = function isGiphyMedia(url) {
32
36
  var isProformaView = function isProformaView(url) {
33
37
  return url.match(/^https:\/\/[^/]+\/jira\/(core|software(\/c)?|servicedesk)\/projects\/\w+\/forms\/form\/direct\/\d+\/\d+.*$/);
34
38
  };
39
+ var isConfluenceWhiteboard = function isConfluenceWhiteboard(url) {
40
+ return url.match( /*#__PURE__*/_wrapRegExp(/\/wiki\/spaces\/?.*\/whiteboard\/(\d+)(\?\/)?/, {
41
+ resourceId: 1
42
+ })) || url.match( /*#__PURE__*/_wrapRegExp(/\/wiki\/spaces\/?.*\/whiteboard\/([0-9a-fA-F]{8}\b\x2D[0-9a-fA-F]{4}\b\x2D[0-9a-fA-F]{4}\b\x2D[0-9a-fA-F]{4}\b\x2D[0-9a-fA-F]{12})(\?\/)?/, {
43
+ resourceId: 1
44
+ }));
45
+ };
35
46
  export var EditorCardProvider = /*#__PURE__*/function () {
36
47
  function EditorCardProvider(envKey, baseUrlOverride) {
37
- var _this = this;
48
+ var _this2 = this;
38
49
  _classCallCheck(this, EditorCardProvider);
39
50
  this.baseUrl = baseUrlOverride || getBaseUrl(envKey);
40
51
  this.resolverUrl = getResolverUrl(envKey, baseUrlOverride);
@@ -43,7 +54,7 @@ export var EditorCardProvider = /*#__PURE__*/function () {
43
54
  Origin: this.baseUrl
44
55
  };
45
56
  this.providersLoader = new DataLoader(function (keys) {
46
- return _this.batchProviders(keys);
57
+ return _this2.batchProviders(keys);
47
58
  }, {
48
59
  batchScheduleFn: function batchScheduleFn(callback) {
49
60
  return setTimeout(callback, BATCH_WAIT_TIME);
@@ -222,7 +233,7 @@ export var EditorCardProvider = /*#__PURE__*/function () {
222
233
  value: function () {
223
234
  var _findUserPreference = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(url) {
224
235
  var _this$providersData,
225
- _this2 = this;
236
+ _this3 = this;
226
237
  var userPreferences, defaultAppearance, appearances, allMatchedLabeledAppearances, longestMatchedLabeledAppearance;
227
238
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
228
239
  while (1) switch (_context6.prev = _context6.next) {
@@ -242,7 +253,7 @@ export var EditorCardProvider = /*#__PURE__*/function () {
242
253
  defaultAppearance = userPreferences.defaultAppearance, appearances = userPreferences.appearances;
243
254
  allMatchedLabeledAppearances = appearances.filter(function (_ref) {
244
255
  var urlSegment = _ref.urlSegment;
245
- return _this2.doesUrlMatchPath(urlSegment, url);
256
+ return _this3.doesUrlMatchPath(urlSegment, url);
246
257
  });
247
258
  if (!(allMatchedLabeledAppearances.length > 0)) {
248
259
  _context6.next = 10;
@@ -301,7 +312,7 @@ export var EditorCardProvider = /*#__PURE__*/function () {
301
312
  }, {
302
313
  key: "getHardCodedAppearance",
303
314
  value: function getHardCodedAppearance(url) {
304
- if (isJiraRoadmapOrTimeline(url) || isPolarisView(url) || isJwmView(url) || isGiphyMedia(url) || isProformaView(url)) {
315
+ if (isJiraRoadmapOrTimeline(url) || isPolarisView(url) || isJwmView(url) || isGiphyMedia(url) || isProformaView(url) || isConfluenceWhiteboard(url)) {
305
316
  return 'embed';
306
317
  }
307
318
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-card-provider",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "sideEffects": false
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-card-provider",
3
- "version": "3.0.3",
3
+ "version": "3.0.5",
4
4
  "description": "Contains the EditorCardProvider, for determining smart card behaviour in the editor.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,7 +34,7 @@
34
34
  ".": "./src/index.ts"
35
35
  },
36
36
  "dependencies": {
37
- "@atlaskit/linking-common": "^2.12.0",
37
+ "@atlaskit/linking-common": "^3.0.0",
38
38
  "@babel/runtime": "^7.0.0",
39
39
  "dataloader": "^2.0.0",
40
40
  "json-ld-types": "3.7.0",