@atlaskit/editor-plugin-card 36.0.9 → 36.0.11

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,20 @@
1
1
  # @atlaskit/editor-plugin-card
2
2
 
3
+ ## 36.0.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [`8dfd15a14b5d7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8dfd15a14b5d7) -
8
+ Raise the opt-in `trackPastedInlineLinks` cap from 10 to 100 tracked links, so an eligible link
9
+ later in a large paste is still tracked, and count the links dropped once the cap is full in the
10
+ `pastedInlineLinksDropped` plugin state so consumers can see how often it is reached.
11
+
12
+ ## 36.0.10
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 36.0.9
4
19
 
5
20
  ### Patch Changes
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.withPastedInlineLinks = exports.removePastedInlineLink = exports.mapPastedInlineLinks = exports.getResolvedPastedInlineCards = exports.getPastedInlineCards = exports.addPastedInlineLinks = exports.MAX_PASTED_INLINE_LINKS = void 0;
7
+ exports.withPastedInlineLinks = exports.removePastedInlineLink = exports.mapPastedInlineLinks = exports.getResolvedPastedInlineCards = exports.getPastedInlineCards = exports.addPastedInlineLinksWithOverflow = exports.addPastedInlineLinks = exports.MAX_PASTED_INLINE_LINKS = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
10
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -12,8 +12,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
12
12
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
13
13
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
14
14
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
15
- /** Bounds the per-editor work; the first pasted links win. */
16
- var MAX_PASTED_INLINE_LINKS = exports.MAX_PASTED_INLINE_LINKS = 10;
15
+ /**
16
+ * Bounds the per-editor work, since every tracked link is mapped through every transaction. The
17
+ * first pasted links win. Sized well above a typical paste; overflow is counted, not silent.
18
+ */
19
+ var MAX_PASTED_INLINE_LINKS = exports.MAX_PASTED_INLINE_LINKS = 100;
17
20
  var isSameLink = function isSameLink(a, b) {
18
21
  return a.pos === b.pos && a.url === b.url;
19
22
  };
@@ -60,32 +63,43 @@ var mapPastedInlineLinks = exports.mapPastedInlineLinks = function mapPastedInli
60
63
  return changed ? mapped : links;
61
64
  };
62
65
 
63
- /** Append new candidates, skipping duplicates and anything beyond the cap. */
64
- var addPastedInlineLinks = exports.addPastedInlineLinks = function addPastedInlineLinks(links, additions) {
66
+ /** Append new candidates, skipping duplicates and counting any dropped by the cap. */
67
+ var addPastedInlineLinksWithOverflow = exports.addPastedInlineLinksWithOverflow = function addPastedInlineLinksWithOverflow(links, additions) {
65
68
  var next = links;
69
+ var dropped = 0;
66
70
  var _iterator2 = _createForOfIteratorHelper(additions),
67
71
  _step2;
68
72
  try {
69
73
  var _loop = function _loop() {
70
74
  var addition = _step2.value;
71
- if (next.length >= MAX_PASTED_INLINE_LINKS) {
72
- return 1; // break
73
- }
74
- if (!next.some(function (link) {
75
+ if (next.some(function (link) {
75
76
  return isSameLink(link, addition);
76
77
  })) {
78
+ return 1; // continue
79
+ }
80
+ if (next.length >= MAX_PASTED_INLINE_LINKS) {
81
+ dropped += 1;
82
+ } else {
77
83
  next = [].concat((0, _toConsumableArray2.default)(next), [addition]);
78
84
  }
79
85
  };
80
86
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
81
- if (_loop()) break;
87
+ if (_loop()) continue;
82
88
  }
83
89
  } catch (err) {
84
90
  _iterator2.e(err);
85
91
  } finally {
86
92
  _iterator2.f();
87
93
  }
88
- return next;
94
+ return {
95
+ dropped: dropped,
96
+ links: next
97
+ };
98
+ };
99
+
100
+ /** Append new candidates, skipping duplicates and anything beyond the cap. */
101
+ var addPastedInlineLinks = exports.addPastedInlineLinks = function addPastedInlineLinks(links, additions) {
102
+ return addPastedInlineLinksWithOverflow(links, additions).links;
89
103
  };
90
104
  var removePastedInlineLink = exports.removePastedInlineLink = function removePastedInlineLink(links, target) {
91
105
  var next = links.filter(function (link) {
@@ -151,11 +165,19 @@ var getResolvedPastedInlineCards = exports.getResolvedPastedInlineCards = functi
151
165
  };
152
166
  /** Add candidates unless tracking is off or a link has already been displayed. */
153
167
  var withPastedInlineLinks = exports.withPastedInlineLinks = function withPastedInlineLinks(state, additions) {
168
+ var _state$pastedInlineLi;
154
169
  if (!state.pastedInlineLinks || state.pastedInlineLinkShown || !additions.length) {
155
170
  return state;
156
171
  }
157
- var next = addPastedInlineLinks(state.pastedInlineLinks, additions);
158
- return next === state.pastedInlineLinks ? state : _objectSpread(_objectSpread({}, state), {}, {
172
+ var _addPastedInlineLinks = addPastedInlineLinksWithOverflow(state.pastedInlineLinks, additions),
173
+ dropped = _addPastedInlineLinks.dropped,
174
+ next = _addPastedInlineLinks.links;
175
+ if (next === state.pastedInlineLinks && !dropped) {
176
+ return state;
177
+ }
178
+ return _objectSpread(_objectSpread({}, state), {}, {
159
179
  pastedInlineLinks: next
160
- });
180
+ }, dropped ? {
181
+ pastedInlineLinksDropped: ((_state$pastedInlineLi = state.pastedInlineLinksDropped) !== null && _state$pastedInlineLi !== void 0 ? _state$pastedInlineLi : 0) + dropped
182
+ } : {});
161
183
  };
@@ -1,5 +1,8 @@
1
- /** Bounds the per-editor work; the first pasted links win. */
2
- export const MAX_PASTED_INLINE_LINKS = 10;
1
+ /**
2
+ * Bounds the per-editor work, since every tracked link is mapped through every transaction. The
3
+ * first pasted links win. Sized well above a typical paste; overflow is counted, not silent.
4
+ */
5
+ export const MAX_PASTED_INLINE_LINKS = 100;
3
6
  const isSameLink = (a, b) => a.pos === b.pos && a.url === b.url;
4
7
 
5
8
  /**
@@ -35,19 +38,28 @@ export const mapPastedInlineLinks = (links, tr) => {
35
38
  return changed ? mapped : links;
36
39
  };
37
40
 
38
- /** Append new candidates, skipping duplicates and anything beyond the cap. */
39
- export const addPastedInlineLinks = (links, additions) => {
41
+ /** Append new candidates, skipping duplicates and counting any dropped by the cap. */
42
+ export const addPastedInlineLinksWithOverflow = (links, additions) => {
40
43
  let next = links;
44
+ let dropped = 0;
41
45
  for (const addition of additions) {
42
- if (next.length >= MAX_PASTED_INLINE_LINKS) {
43
- break;
46
+ if (next.some(link => isSameLink(link, addition))) {
47
+ continue;
44
48
  }
45
- if (!next.some(link => isSameLink(link, addition))) {
49
+ if (next.length >= MAX_PASTED_INLINE_LINKS) {
50
+ dropped += 1;
51
+ } else {
46
52
  next = [...next, addition];
47
53
  }
48
54
  }
49
- return next;
55
+ return {
56
+ dropped,
57
+ links: next
58
+ };
50
59
  };
60
+
61
+ /** Append new candidates, skipping duplicates and anything beyond the cap. */
62
+ export const addPastedInlineLinks = (links, additions) => addPastedInlineLinksWithOverflow(links, additions).links;
51
63
  export const removePastedInlineLink = (links, target) => {
52
64
  const next = links.filter(link => !isSameLink(link, target));
53
65
  return next.length === links.length ? links : next;
@@ -101,12 +113,22 @@ export const getResolvedPastedInlineCards = (tr, requests, resolvedUrl, clipboar
101
113
  };
102
114
  /** Add candidates unless tracking is off or a link has already been displayed. */
103
115
  export const withPastedInlineLinks = (state, additions) => {
116
+ var _state$pastedInlineLi;
104
117
  if (!state.pastedInlineLinks || state.pastedInlineLinkShown || !additions.length) {
105
118
  return state;
106
119
  }
107
- const next = addPastedInlineLinks(state.pastedInlineLinks, additions);
108
- return next === state.pastedInlineLinks ? state : {
120
+ const {
121
+ dropped,
122
+ links: next
123
+ } = addPastedInlineLinksWithOverflow(state.pastedInlineLinks, additions);
124
+ if (next === state.pastedInlineLinks && !dropped) {
125
+ return state;
126
+ }
127
+ return {
109
128
  ...state,
110
- pastedInlineLinks: next
129
+ pastedInlineLinks: next,
130
+ ...(dropped ? {
131
+ pastedInlineLinksDropped: ((_state$pastedInlineLi = state.pastedInlineLinksDropped) !== null && _state$pastedInlineLi !== void 0 ? _state$pastedInlineLi : 0) + dropped
132
+ } : {})
111
133
  };
112
134
  };
@@ -5,8 +5,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
5
5
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
6
6
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
7
7
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
8
- /** Bounds the per-editor work; the first pasted links win. */
9
- export var MAX_PASTED_INLINE_LINKS = 10;
8
+ /**
9
+ * Bounds the per-editor work, since every tracked link is mapped through every transaction. The
10
+ * first pasted links win. Sized well above a typical paste; overflow is counted, not silent.
11
+ */
12
+ export var MAX_PASTED_INLINE_LINKS = 100;
10
13
  var isSameLink = function isSameLink(a, b) {
11
14
  return a.pos === b.pos && a.url === b.url;
12
15
  };
@@ -53,32 +56,43 @@ export var mapPastedInlineLinks = function mapPastedInlineLinks(links, tr) {
53
56
  return changed ? mapped : links;
54
57
  };
55
58
 
56
- /** Append new candidates, skipping duplicates and anything beyond the cap. */
57
- export var addPastedInlineLinks = function addPastedInlineLinks(links, additions) {
59
+ /** Append new candidates, skipping duplicates and counting any dropped by the cap. */
60
+ export var addPastedInlineLinksWithOverflow = function addPastedInlineLinksWithOverflow(links, additions) {
58
61
  var next = links;
62
+ var dropped = 0;
59
63
  var _iterator2 = _createForOfIteratorHelper(additions),
60
64
  _step2;
61
65
  try {
62
66
  var _loop = function _loop() {
63
67
  var addition = _step2.value;
64
- if (next.length >= MAX_PASTED_INLINE_LINKS) {
65
- return 1; // break
66
- }
67
- if (!next.some(function (link) {
68
+ if (next.some(function (link) {
68
69
  return isSameLink(link, addition);
69
70
  })) {
71
+ return 1; // continue
72
+ }
73
+ if (next.length >= MAX_PASTED_INLINE_LINKS) {
74
+ dropped += 1;
75
+ } else {
70
76
  next = [].concat(_toConsumableArray(next), [addition]);
71
77
  }
72
78
  };
73
79
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
74
- if (_loop()) break;
80
+ if (_loop()) continue;
75
81
  }
76
82
  } catch (err) {
77
83
  _iterator2.e(err);
78
84
  } finally {
79
85
  _iterator2.f();
80
86
  }
81
- return next;
87
+ return {
88
+ dropped: dropped,
89
+ links: next
90
+ };
91
+ };
92
+
93
+ /** Append new candidates, skipping duplicates and anything beyond the cap. */
94
+ export var addPastedInlineLinks = function addPastedInlineLinks(links, additions) {
95
+ return addPastedInlineLinksWithOverflow(links, additions).links;
82
96
  };
83
97
  export var removePastedInlineLink = function removePastedInlineLink(links, target) {
84
98
  var next = links.filter(function (link) {
@@ -144,11 +158,19 @@ export var getResolvedPastedInlineCards = function getResolvedPastedInlineCards(
144
158
  };
145
159
  /** Add candidates unless tracking is off or a link has already been displayed. */
146
160
  export var withPastedInlineLinks = function withPastedInlineLinks(state, additions) {
161
+ var _state$pastedInlineLi;
147
162
  if (!state.pastedInlineLinks || state.pastedInlineLinkShown || !additions.length) {
148
163
  return state;
149
164
  }
150
- var next = addPastedInlineLinks(state.pastedInlineLinks, additions);
151
- return next === state.pastedInlineLinks ? state : _objectSpread(_objectSpread({}, state), {}, {
165
+ var _addPastedInlineLinks = addPastedInlineLinksWithOverflow(state.pastedInlineLinks, additions),
166
+ dropped = _addPastedInlineLinks.dropped,
167
+ next = _addPastedInlineLinks.links;
168
+ if (next === state.pastedInlineLinks && !dropped) {
169
+ return state;
170
+ }
171
+ return _objectSpread(_objectSpread({}, state), {}, {
152
172
  pastedInlineLinks: next
153
- });
173
+ }, dropped ? {
174
+ pastedInlineLinksDropped: ((_state$pastedInlineLi = state.pastedInlineLinksDropped) !== null && _state$pastedInlineLi !== void 0 ? _state$pastedInlineLi : 0) + dropped
175
+ } : {});
154
176
  };
@@ -1,12 +1,20 @@
1
1
  import type { ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
2
2
  import type { PastedInlineLink } from '../../types';
3
- /** Bounds the per-editor work; the first pasted links win. */
4
- export declare const MAX_PASTED_INLINE_LINKS = 10;
3
+ /**
4
+ * Bounds the per-editor work, since every tracked link is mapped through every transaction. The
5
+ * first pasted links win. Sized well above a typical paste; overflow is counted, not silent.
6
+ */
7
+ export declare const MAX_PASTED_INLINE_LINKS = 100;
5
8
  /**
6
9
  * Map candidates through a transaction. Anything that was deleted, replaced by another node or
7
10
  * given a different URL stops being a candidate. Returns the same array when nothing changed.
8
11
  */
9
12
  export declare const mapPastedInlineLinks: (links: PastedInlineLink[], tr: ReadonlyTransaction | Transaction) => PastedInlineLink[];
13
+ /** Append new candidates, skipping duplicates and counting any dropped by the cap. */
14
+ export declare const addPastedInlineLinksWithOverflow: (links: PastedInlineLink[], additions: PastedInlineLink[]) => {
15
+ dropped: number;
16
+ links: PastedInlineLink[];
17
+ };
10
18
  /** Append new candidates, skipping duplicates and anything beyond the cap. */
11
19
  export declare const addPastedInlineLinks: (links: PastedInlineLink[], additions: PastedInlineLink[]) => PastedInlineLink[];
12
20
  export declare const removePastedInlineLink: (links: PastedInlineLink[], target: PastedInlineLink) => PastedInlineLink[];
@@ -21,6 +29,7 @@ export declare const getResolvedPastedInlineCards: (tr: ReadonlyTransaction | Tr
21
29
  }>, resolvedUrl: string, clipboardSource: string) => PastedInlineLink[];
22
30
  type PastedInlineLinkState = {
23
31
  pastedInlineLinks?: PastedInlineLink[];
32
+ pastedInlineLinksDropped?: number;
24
33
  pastedInlineLinkShown?: boolean;
25
34
  };
26
35
  /** Add candidates unless tracking is off or a link has already been displayed. */
@@ -31,6 +31,7 @@ export declare const getPluginStateWithUpdatedPos: (pluginState: CardPluginState
31
31
  layout?: DatasourceTableLayout;
32
32
  overlayCandidatePosition?: number;
33
33
  pastedInlineLinks?: PastedInlineLink[];
34
+ pastedInlineLinksDropped?: number;
34
35
  pastedInlineLinkShown?: boolean;
35
36
  provider: CardProvider | null;
36
37
  removeOverlay?: () => void;
@@ -112,6 +112,8 @@ export type CardPluginState = {
112
112
  * is on. Once the consumer confirms display this holds only the displayed link.
113
113
  */
114
114
  pastedInlineLinks?: PastedInlineLink[];
115
+ /** Candidates dropped because the tracking cap was full. Defined only once that has happened. */
116
+ pastedInlineLinksDropped?: number;
115
117
  /** Permanently stop adding candidates after the consumer confirms actual display. */
116
118
  pastedInlineLinkShown?: boolean;
117
119
  provider: CardProvider | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-card",
3
- "version": "36.0.9",
3
+ "version": "36.0.11",
4
4
  "description": "Card plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -52,7 +52,7 @@
52
52
  "@atlaskit/link": "^5.1.0",
53
53
  "@atlaskit/link-analytics": "^13.0.0",
54
54
  "@atlaskit/link-client-extension": "^8.0.0",
55
- "@atlaskit/link-datasource": "^7.11.0",
55
+ "@atlaskit/link-datasource": "^7.12.0",
56
56
  "@atlaskit/link-extractors": "^5.0.0",
57
57
  "@atlaskit/linking-common": "^13.0.0",
58
58
  "@atlaskit/linking-types": "^16.1.0",
@@ -62,8 +62,8 @@
62
62
  "@atlaskit/platform-feature-flags-react": "^1.2.0",
63
63
  "@atlaskit/primitives": "^22.6.0",
64
64
  "@atlaskit/prosemirror-history": "^1.3.0",
65
- "@atlaskit/smart-card": "^46.12.0",
66
- "@atlaskit/tmp-editor-statsig": "^251.0.0",
65
+ "@atlaskit/smart-card": "^46.13.0",
66
+ "@atlaskit/tmp-editor-statsig": "^252.0.0",
67
67
  "@atlaskit/tokens": "^20.9.0",
68
68
  "@babel/runtime": "^7.0.0",
69
69
  "@emotion/react": "^11.7.1",
@@ -72,7 +72,7 @@
72
72
  "uuid": "^11.1.1"
73
73
  },
74
74
  "peerDependencies": {
75
- "@atlaskit/editor-common": "^134.4.0",
75
+ "@atlaskit/editor-common": "^134.5.0",
76
76
  "@atlaskit/link-provider": "^6.0.0",
77
77
  "react": "^18.2.0 || ^19.2.0",
78
78
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
@@ -103,6 +103,8 @@
103
103
  },
104
104
  "compassUnitTestMetricSourceId": "ari:cloud:compass:a436116f-02ce-4520-8fbb-7301462a1674:metric-source/c5751cc6-3513-4070-9deb-af31e86aed34/e6f3220b-0ca2-445a-a4c5-78cff6ca2a34",
105
105
  "devDependencies": {
106
+ "@atlaskit/editor-common": "^134.5.0",
107
+ "@atlaskit/link-provider": "^6.0.0",
106
108
  "react": "^19.2.0",
107
109
  "react-intl": "^7.0.0"
108
110
  }