@atlaskit/editor-plugin-emoji 7.4.2 → 7.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,28 @@
1
1
  # @atlaskit/editor-plugin-emoji
2
2
 
3
+ ## 7.6.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`fdba2e94783b7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fdba2e94783b7) -
8
+ [https://product-fabric.atlassian.net/browse/ED-29638](ED-29638) - fix editor NodeDataProvider
9
+ network requests deduplication
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 7.5.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [`5319dac3f8740`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5319dac3f8740) -
20
+ Do not re-fetch emoji on a client after successful ssr
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies
25
+
3
26
  ## 7.4.2
4
27
 
5
28
  ### Patch Changes
@@ -278,23 +278,33 @@ var EmojiNodeView = exports.EmojiNodeView = /*#__PURE__*/function () {
278
278
  imageElement.src = 'imagePath' in representation ? representation.imagePath : representation.mediaPath;
279
279
  imageElement.loading = 'lazy';
280
280
  imageElement.alt = emojiDescription.name || emojiDescription.shortName;
281
+ if ((0, _expValEquals.expValEquals)('platform_editor_emoji_otp', 'isEnabled', true)) {
282
+ imageElement.style.minWidth = "".concat(_emoji.defaultEmojiHeight, "px");
283
+ imageElement.style.objectFit = 'contain';
284
+ }
281
285
  if (representation.width && representation.height) {
282
286
  imageElement.height = _emoji.defaultEmojiHeight;
283
- // Because img.width is round to the nearest integer.
284
- imageElement.setAttribute('width', "".concat(_emoji.defaultEmojiHeight / representation.height * representation.width));
287
+ if (!(0, _expValEquals.expValEquals)('platform_editor_emoji_otp', 'isEnabled', true)) {
288
+ // Because img.width is round to the nearest integer.
289
+ imageElement.setAttribute('width', "".concat(_emoji.defaultEmojiHeight / representation.height * representation.width));
290
+ }
285
291
  }
286
- if ((0, _experiments.editorExperiment)('platform_editor_offline_editing_web', true)) {
287
- // If there's an error (ie. offline) render the ascii fallback if possible, otherwise
288
- // mark the node to refresh when returning online.
289
- imageElement.onerror = function () {
292
+ imageElement.onerror = function () {
293
+ if ((0, _expValEquals.expValEquals)('platform_editor_emoji_otp', 'isEnabled', true)) {
294
+ _this2.renderFallback();
295
+ return;
296
+ }
297
+ if ((0, _experiments.editorExperiment)('platform_editor_offline_editing_web', true)) {
298
+ // If there's an error (ie. offline) render the ascii fallback if possible, otherwise
299
+ // mark the node to refresh when returning online.
290
300
  // Create a check that confirms if this.node.attrs.text if an ascii emoji
291
301
  if (isSingleEmoji(_this2.node.attrs.text)) {
292
302
  _this2.renderFallback();
293
303
  } else {
294
304
  _this2.renderingFallback = true;
295
305
  }
296
- };
297
- }
306
+ }
307
+ };
298
308
  return imageElement;
299
309
  }
300
310
  }], [{
@@ -42,6 +42,37 @@ var EmojiNodeDataProvider = exports.EmojiNodeDataProvider = /*#__PURE__*/functio
42
42
  var _node$attrs$id;
43
43
  return (_node$attrs$id = node.attrs.id) !== null && _node$attrs$id !== void 0 ? _node$attrs$id : node.attrs.shortName;
44
44
  }
45
+
46
+ /**
47
+ * Implementing different re-fetching strategy for emoji.
48
+ *
49
+ * Default strategy for NodeDataProvider is to:
50
+ * 1. If entry is in cache = return from cache
51
+ * 2. Re-fetch data.
52
+ * 3. Update cache
53
+ * 4. Re-render node with fresh data.
54
+ *
55
+ * This is similar, but doesn't update the node.
56
+ * 1. If entry is in cache = return from cache
57
+ * 2. Re-fetch data.
58
+ * 3. Update cache
59
+ */
60
+ }, {
61
+ key: "getData",
62
+ value: function getData(node, callback) {
63
+ var _this2 = this;
64
+ var cached = this.getNodeDataFromCache(node);
65
+ if (cached !== null && cached !== void 0 && cached.data) {
66
+ callback(cached);
67
+ if (!(0, _coreUtils.isSSR)() && typeof requestAnimationFrame !== 'undefined') {
68
+ requestAnimationFrame(function () {
69
+ return void _this2.getDataAsync(node, function () {});
70
+ });
71
+ }
72
+ } else {
73
+ void this.getDataAsync(node, callback);
74
+ }
75
+ }
45
76
  }, {
46
77
  key: "fetchNodesData",
47
78
  value: function () {
@@ -239,23 +239,33 @@ export class EmojiNodeView {
239
239
  imageElement.src = 'imagePath' in representation ? representation.imagePath : representation.mediaPath;
240
240
  imageElement.loading = 'lazy';
241
241
  imageElement.alt = emojiDescription.name || emojiDescription.shortName;
242
+ if (expValEquals('platform_editor_emoji_otp', 'isEnabled', true)) {
243
+ imageElement.style.minWidth = `${defaultEmojiHeight}px`;
244
+ imageElement.style.objectFit = 'contain';
245
+ }
242
246
  if (representation.width && representation.height) {
243
247
  imageElement.height = defaultEmojiHeight;
244
- // Because img.width is round to the nearest integer.
245
- imageElement.setAttribute('width', `${defaultEmojiHeight / representation.height * representation.width}`);
248
+ if (!expValEquals('platform_editor_emoji_otp', 'isEnabled', true)) {
249
+ // Because img.width is round to the nearest integer.
250
+ imageElement.setAttribute('width', `${defaultEmojiHeight / representation.height * representation.width}`);
251
+ }
246
252
  }
247
- if (editorExperiment('platform_editor_offline_editing_web', true)) {
248
- // If there's an error (ie. offline) render the ascii fallback if possible, otherwise
249
- // mark the node to refresh when returning online.
250
- imageElement.onerror = () => {
253
+ imageElement.onerror = () => {
254
+ if (expValEquals('platform_editor_emoji_otp', 'isEnabled', true)) {
255
+ this.renderFallback();
256
+ return;
257
+ }
258
+ if (editorExperiment('platform_editor_offline_editing_web', true)) {
259
+ // If there's an error (ie. offline) render the ascii fallback if possible, otherwise
260
+ // mark the node to refresh when returning online.
251
261
  // Create a check that confirms if this.node.attrs.text if an ascii emoji
252
262
  if (isSingleEmoji(this.node.attrs.text)) {
253
263
  this.renderFallback();
254
264
  } else {
255
265
  this.renderingFallback = true;
256
266
  }
257
- };
258
- }
267
+ }
268
+ };
259
269
  return imageElement;
260
270
  }
261
271
  }
@@ -16,6 +16,32 @@ export class EmojiNodeDataProvider extends NodeDataProvider {
16
16
  var _node$attrs$id;
17
17
  return (_node$attrs$id = node.attrs.id) !== null && _node$attrs$id !== void 0 ? _node$attrs$id : node.attrs.shortName;
18
18
  }
19
+
20
+ /**
21
+ * Implementing different re-fetching strategy for emoji.
22
+ *
23
+ * Default strategy for NodeDataProvider is to:
24
+ * 1. If entry is in cache = return from cache
25
+ * 2. Re-fetch data.
26
+ * 3. Update cache
27
+ * 4. Re-render node with fresh data.
28
+ *
29
+ * This is similar, but doesn't update the node.
30
+ * 1. If entry is in cache = return from cache
31
+ * 2. Re-fetch data.
32
+ * 3. Update cache
33
+ */
34
+ getData(node, callback) {
35
+ const cached = this.getNodeDataFromCache(node);
36
+ if (cached !== null && cached !== void 0 && cached.data) {
37
+ callback(cached);
38
+ if (!isSSR() && typeof requestAnimationFrame !== 'undefined') {
39
+ requestAnimationFrame(() => void this.getDataAsync(node, () => {}));
40
+ }
41
+ } else {
42
+ void this.getDataAsync(node, callback);
43
+ }
44
+ }
19
45
  async fetchNodesData(nodes) {
20
46
  var _this$emojiResource$e;
21
47
  // If we have an `optimisticImageApi`, use it to generate a URL immediately.
@@ -270,23 +270,33 @@ export var EmojiNodeView = /*#__PURE__*/function () {
270
270
  imageElement.src = 'imagePath' in representation ? representation.imagePath : representation.mediaPath;
271
271
  imageElement.loading = 'lazy';
272
272
  imageElement.alt = emojiDescription.name || emojiDescription.shortName;
273
+ if (expValEquals('platform_editor_emoji_otp', 'isEnabled', true)) {
274
+ imageElement.style.minWidth = "".concat(defaultEmojiHeight, "px");
275
+ imageElement.style.objectFit = 'contain';
276
+ }
273
277
  if (representation.width && representation.height) {
274
278
  imageElement.height = defaultEmojiHeight;
275
- // Because img.width is round to the nearest integer.
276
- imageElement.setAttribute('width', "".concat(defaultEmojiHeight / representation.height * representation.width));
279
+ if (!expValEquals('platform_editor_emoji_otp', 'isEnabled', true)) {
280
+ // Because img.width is round to the nearest integer.
281
+ imageElement.setAttribute('width', "".concat(defaultEmojiHeight / representation.height * representation.width));
282
+ }
277
283
  }
278
- if (editorExperiment('platform_editor_offline_editing_web', true)) {
279
- // If there's an error (ie. offline) render the ascii fallback if possible, otherwise
280
- // mark the node to refresh when returning online.
281
- imageElement.onerror = function () {
284
+ imageElement.onerror = function () {
285
+ if (expValEquals('platform_editor_emoji_otp', 'isEnabled', true)) {
286
+ _this2.renderFallback();
287
+ return;
288
+ }
289
+ if (editorExperiment('platform_editor_offline_editing_web', true)) {
290
+ // If there's an error (ie. offline) render the ascii fallback if possible, otherwise
291
+ // mark the node to refresh when returning online.
282
292
  // Create a check that confirms if this.node.attrs.text if an ascii emoji
283
293
  if (isSingleEmoji(_this2.node.attrs.text)) {
284
294
  _this2.renderFallback();
285
295
  } else {
286
296
  _this2.renderingFallback = true;
287
297
  }
288
- };
289
- }
298
+ }
299
+ };
290
300
  return imageElement;
291
301
  }
292
302
  }], [{
@@ -35,6 +35,37 @@ export var EmojiNodeDataProvider = /*#__PURE__*/function (_NodeDataProvider) {
35
35
  var _node$attrs$id;
36
36
  return (_node$attrs$id = node.attrs.id) !== null && _node$attrs$id !== void 0 ? _node$attrs$id : node.attrs.shortName;
37
37
  }
38
+
39
+ /**
40
+ * Implementing different re-fetching strategy for emoji.
41
+ *
42
+ * Default strategy for NodeDataProvider is to:
43
+ * 1. If entry is in cache = return from cache
44
+ * 2. Re-fetch data.
45
+ * 3. Update cache
46
+ * 4. Re-render node with fresh data.
47
+ *
48
+ * This is similar, but doesn't update the node.
49
+ * 1. If entry is in cache = return from cache
50
+ * 2. Re-fetch data.
51
+ * 3. Update cache
52
+ */
53
+ }, {
54
+ key: "getData",
55
+ value: function getData(node, callback) {
56
+ var _this2 = this;
57
+ var cached = this.getNodeDataFromCache(node);
58
+ if (cached !== null && cached !== void 0 && cached.data) {
59
+ callback(cached);
60
+ if (!isSSR() && typeof requestAnimationFrame !== 'undefined') {
61
+ requestAnimationFrame(function () {
62
+ return void _this2.getDataAsync(node, function () {});
63
+ });
64
+ }
65
+ } else {
66
+ void this.getDataAsync(node, callback);
67
+ }
68
+ }
38
69
  }, {
39
70
  key: "fetchNodesData",
40
71
  value: function () {
@@ -1,5 +1,6 @@
1
1
  import type { EmojiDefinition } from '@atlaskit/adf-schema';
2
2
  import type { JSONNode } from '@atlaskit/editor-json-transformer';
3
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
4
  import { type EmojiResource, type OptionalEmojiDescriptionWithVariations } from '@atlaskit/emoji';
4
5
  import { NodeDataProvider } from '@atlaskit/node-data-provider';
5
6
  export declare class EmojiNodeDataProvider extends NodeDataProvider<EmojiDefinition, OptionalEmojiDescriptionWithVariations> {
@@ -9,5 +10,26 @@ export declare class EmojiNodeDataProvider extends NodeDataProvider<EmojiDefinit
9
10
  constructor(resource: EmojiResource);
10
11
  isNodeSupported(node: JSONNode): node is EmojiDefinition;
11
12
  nodeDataKey(node: EmojiDefinition): string;
13
+ /**
14
+ * Implementing different re-fetching strategy for emoji.
15
+ *
16
+ * Default strategy for NodeDataProvider is to:
17
+ * 1. If entry is in cache = return from cache
18
+ * 2. Re-fetch data.
19
+ * 3. Update cache
20
+ * 4. Re-render node with fresh data.
21
+ *
22
+ * This is similar, but doesn't update the node.
23
+ * 1. If entry is in cache = return from cache
24
+ * 2. Re-fetch data.
25
+ * 3. Update cache
26
+ */
27
+ getData(node: EmojiDefinition | PMNode, callback: (payload: {
28
+ data: OptionalEmojiDescriptionWithVariations;
29
+ error?: undefined;
30
+ } | {
31
+ data?: undefined;
32
+ error: Error;
33
+ }) => void): void;
12
34
  fetchNodesData(nodes: EmojiDefinition[]): Promise<OptionalEmojiDescriptionWithVariations[]>;
13
35
  }
@@ -1,5 +1,6 @@
1
1
  import type { EmojiDefinition } from '@atlaskit/adf-schema';
2
2
  import type { JSONNode } from '@atlaskit/editor-json-transformer';
3
+ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
4
  import { type EmojiResource, type OptionalEmojiDescriptionWithVariations } from '@atlaskit/emoji';
4
5
  import { NodeDataProvider } from '@atlaskit/node-data-provider';
5
6
  export declare class EmojiNodeDataProvider extends NodeDataProvider<EmojiDefinition, OptionalEmojiDescriptionWithVariations> {
@@ -9,5 +10,26 @@ export declare class EmojiNodeDataProvider extends NodeDataProvider<EmojiDefinit
9
10
  constructor(resource: EmojiResource);
10
11
  isNodeSupported(node: JSONNode): node is EmojiDefinition;
11
12
  nodeDataKey(node: EmojiDefinition): string;
13
+ /**
14
+ * Implementing different re-fetching strategy for emoji.
15
+ *
16
+ * Default strategy for NodeDataProvider is to:
17
+ * 1. If entry is in cache = return from cache
18
+ * 2. Re-fetch data.
19
+ * 3. Update cache
20
+ * 4. Re-render node with fresh data.
21
+ *
22
+ * This is similar, but doesn't update the node.
23
+ * 1. If entry is in cache = return from cache
24
+ * 2. Re-fetch data.
25
+ * 3. Update cache
26
+ */
27
+ getData(node: EmojiDefinition | PMNode, callback: (payload: {
28
+ data: OptionalEmojiDescriptionWithVariations;
29
+ error?: undefined;
30
+ } | {
31
+ data?: undefined;
32
+ error: Error;
33
+ }) => void): void;
12
34
  fetchNodesData(nodes: EmojiDefinition[]): Promise<OptionalEmojiDescriptionWithVariations[]>;
13
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-emoji",
3
- "version": "7.4.2",
3
+ "version": "7.6.0",
4
4
  "description": "Emoji plugin for @atlaskit/editor-core",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -32,12 +32,12 @@
32
32
  "@atlaskit/editor-shared-styles": "^3.8.0",
33
33
  "@atlaskit/emoji": "^69.6.0",
34
34
  "@atlaskit/icon": "^28.5.0",
35
- "@atlaskit/node-data-provider": "^7.2.0",
35
+ "@atlaskit/node-data-provider": "^7.4.0",
36
36
  "@atlaskit/platform-feature-flags": "^1.1.0",
37
37
  "@atlaskit/prosemirror-input-rules": "^3.5.0",
38
38
  "@atlaskit/theme": "^21.0.0",
39
- "@atlaskit/tmp-editor-statsig": "^13.18.0",
40
- "@atlaskit/tokens": "^7.0.0",
39
+ "@atlaskit/tmp-editor-statsig": "^13.26.0",
40
+ "@atlaskit/tokens": "^7.1.0",
41
41
  "@babel/runtime": "^7.0.0",
42
42
  "@emotion/react": "^11.7.1",
43
43
  "lodash": "^4.17.21",
@@ -45,7 +45,7 @@
45
45
  "react-loadable": "^5.1.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "@atlaskit/editor-common": "^110.18.0",
48
+ "@atlaskit/editor-common": "^110.21.0",
49
49
  "react": "^18.2.0",
50
50
  "react-dom": "^18.2.0"
51
51
  },