@atlaskit/editor-plugin-emoji 28.0.5 → 29.0.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 +18 -0
- package/dist/cjs/nodeviews/EmojiNodeView.js +5 -39
- package/dist/cjs/pm-plugins/providers/EmojiNodeDataProvider.js +5 -42
- package/dist/es2019/nodeviews/EmojiNodeView.js +4 -34
- package/dist/es2019/pm-plugins/providers/EmojiNodeDataProvider.js +0 -36
- package/dist/esm/nodeviews/EmojiNodeView.js +5 -39
- package/dist/esm/pm-plugins/providers/EmojiNodeDataProvider.js +5 -42
- package/dist/types/nodeviews/EmojiNodeView.d.ts +0 -2
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-emoji
|
|
2
2
|
|
|
3
|
+
## 29.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4119d93011e41`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4119d93011e41) -
|
|
8
|
+
Remove `platform_use_unicode_emojis` experiment checks and retain Twemoji images and sprites.
|
|
9
|
+
Remove the experiment-only `denormaliseStandardRepresentation` export. Call
|
|
10
|
+
`denormaliseServiceRepresentation` with the service representation instead. Remove the
|
|
11
|
+
`emoji-id-to-emoji` entrypoint and its `emojiIdToEmoji` utility. Use the existing provider image
|
|
12
|
+
or sprite representation for Twemoji rendering. Remove the Unicode representation type, renderer,
|
|
13
|
+
canvas utility, and public `unicode-emoji-image` entrypoint. Remove `renderUnicodeEmojiAsImage`
|
|
14
|
+
props and the Unicode type guard. Remove the editor Unicode node rendering and the `EMOJI_UNICODE`
|
|
15
|
+
shared CSS class. Use provider image and sprite representations instead of Unicode
|
|
16
|
+
representations. Remove the obsolete Unicode rendering props from consumers. Remove the
|
|
17
|
+
feature-only `getCachedEmojiType` provider API. Use the existing provider lookup methods for cache
|
|
18
|
+
or catalogue access.
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 28.0.5
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -23,11 +23,9 @@ var _isSingleEmoji = require("@atlaskit/editor-common/utils/isSingleEmoji");
|
|
|
23
23
|
var _vanillaTooltip = require("@atlaskit/editor-common/vanilla-tooltip");
|
|
24
24
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
25
25
|
var _constants = require("@atlaskit/emoji/constants");
|
|
26
|
-
var _emojiIdToEmoji = require("@atlaskit/emoji/emoji-id-to-emoji");
|
|
27
26
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
28
27
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
29
28
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
30
|
-
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
31
29
|
var _emojiNodeSpec = require("./emojiNodeSpec");
|
|
32
30
|
/**
|
|
33
31
|
* Emoji node view for renderering emoji nodes
|
|
@@ -182,7 +180,7 @@ var EmojiNodeView = exports.EmojiNodeView = /*#__PURE__*/function () {
|
|
|
182
180
|
key: "updateDom",
|
|
183
181
|
value: function () {
|
|
184
182
|
var _updateDom = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(emojiProvider) {
|
|
185
|
-
var _this$node$attrs, shortName, id, fallback, emojiDescription,
|
|
183
|
+
var _this$node$attrs, shortName, id, fallback, emojiDescription, emojiRepresentation, _t;
|
|
186
184
|
return _regenerator.default.wrap(function (_context) {
|
|
187
185
|
while (1) switch (_context.prev = _context.next) {
|
|
188
186
|
case 0:
|
|
@@ -204,10 +202,7 @@ var EmojiNodeView = exports.EmojiNodeView = /*#__PURE__*/function () {
|
|
|
204
202
|
this.renderFallback();
|
|
205
203
|
return _context.abrupt("return");
|
|
206
204
|
case 2:
|
|
207
|
-
|
|
208
|
-
emojiRepresentation = unicodeEmoji ? {
|
|
209
|
-
unicodeEmoji: unicodeEmoji
|
|
210
|
-
} : emojiDescription === null || emojiDescription === void 0 ? void 0 : emojiDescription.representation;
|
|
205
|
+
emojiRepresentation = emojiDescription === null || emojiDescription === void 0 ? void 0 : emojiDescription.representation;
|
|
211
206
|
if (EmojiNodeView.isEmojiRepresentationSupported(emojiRepresentation)) {
|
|
212
207
|
_context.next = 3;
|
|
213
208
|
break;
|
|
@@ -368,7 +363,7 @@ var EmojiNodeView = exports.EmojiNodeView = /*#__PURE__*/function () {
|
|
|
368
363
|
value: function renderEmoji(description, representation) {
|
|
369
364
|
this.renderingFallback = false;
|
|
370
365
|
this.cleanUpAndRenderCommonAttributes();
|
|
371
|
-
var emojiType = '
|
|
366
|
+
var emojiType = 'sprite' in representation ? 'sprite' : 'image';
|
|
372
367
|
var doc = (0, _browserApis.getDocument)();
|
|
373
368
|
if (!doc) {
|
|
374
369
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
@@ -383,35 +378,11 @@ var EmojiNodeView = exports.EmojiNodeView = /*#__PURE__*/function () {
|
|
|
383
378
|
containerElement.setAttribute('data-testid', "".concat(emojiType, "-emoji-").concat(description.shortName));
|
|
384
379
|
containerElement.setAttribute('data-emoji-type', emojiType);
|
|
385
380
|
containerElement.setAttribute('aria-label', "".concat(this.intl.formatMessage(_messages.messages.emojiNodeLabel), " ").concat(description.shortName));
|
|
386
|
-
var emojiElement = '
|
|
381
|
+
var emojiElement = 'sprite' in representation ? this.createSpriteEmojiElement(representation) : this.createImageEmojiElement(description, representation);
|
|
387
382
|
containerElement.appendChild(emojiElement);
|
|
388
383
|
this.dom.appendChild(containerElement);
|
|
389
|
-
if (EmojiNodeView.shouldRecordUnicodeEmojiExposure(description, representation)) {
|
|
390
|
-
(0, _expValEquals.expValEquals)('platform_use_unicode_emojis', 'isEnabled', true);
|
|
391
|
-
}
|
|
392
384
|
this.createTooltip(containerElement, description.shortName);
|
|
393
385
|
}
|
|
394
|
-
}, {
|
|
395
|
-
key: "createUnicodeEmojiElement",
|
|
396
|
-
value: function createUnicodeEmojiElement(emoji) {
|
|
397
|
-
var doc = (0, _browserApis.getDocument)();
|
|
398
|
-
if (!doc) {
|
|
399
|
-
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
400
|
-
doc = document;
|
|
401
|
-
}
|
|
402
|
-
var spanElement = doc.createElement('span');
|
|
403
|
-
spanElement.classList.add(_emoji.EmojiSharedCssClassName.EMOJI_UNICODE);
|
|
404
|
-
spanElement.textContent = emoji;
|
|
405
|
-
spanElement.style.display = 'inline-flex';
|
|
406
|
-
spanElement.style.fontSize = "var(--emoji-common-unicode-size, ".concat(_constants.defaultEmojiHeight, "px)");
|
|
407
|
-
spanElement.style.alignItems = 'center';
|
|
408
|
-
spanElement.style.aspectRatio = '1/1';
|
|
409
|
-
spanElement.style.lineHeight = '1em';
|
|
410
|
-
spanElement.style.margin = '-1px 0';
|
|
411
|
-
spanElement.style.verticalAlign = 'middle'; // to keep vertical alignment consistent with images
|
|
412
|
-
|
|
413
|
-
return spanElement;
|
|
414
|
-
}
|
|
415
386
|
}, {
|
|
416
387
|
key: "createSpriteEmojiElement",
|
|
417
388
|
value: function createSpriteEmojiElement(representation) {
|
|
@@ -475,12 +446,7 @@ var EmojiNodeView = exports.EmojiNodeView = /*#__PURE__*/function () {
|
|
|
475
446
|
}, {
|
|
476
447
|
key: "isEmojiRepresentationSupported",
|
|
477
448
|
value: function isEmojiRepresentationSupported(representation) {
|
|
478
|
-
return !!representation && ('sprite' in representation || 'imagePath' in representation || 'mediaPath' in representation
|
|
479
|
-
}
|
|
480
|
-
}, {
|
|
481
|
-
key: "shouldRecordUnicodeEmojiExposure",
|
|
482
|
-
value: function shouldRecordUnicodeEmojiExposure(description, representation) {
|
|
483
|
-
return description.type === 'STANDARD' || 'unicodeEmoji' in representation;
|
|
449
|
+
return !!representation && ('sprite' in representation || 'imagePath' in representation || 'mediaPath' in representation);
|
|
484
450
|
}
|
|
485
451
|
}]);
|
|
486
452
|
}();
|
|
@@ -15,9 +15,7 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
15
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
16
|
var _isSsr = require("@atlaskit/editor-common/is-ssr");
|
|
17
17
|
var _emoji = require("@atlaskit/emoji");
|
|
18
|
-
var _emojiIdToEmoji = require("@atlaskit/emoji/emoji-id-to-emoji");
|
|
19
18
|
var _nodeDataProvider = require("@atlaskit/node-data-provider/node-data-provider");
|
|
20
|
-
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
21
19
|
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; }
|
|
22
20
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
21
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
@@ -98,26 +96,6 @@ var EmojiNodeDataProvider = exports.EmojiNodeDataProvider = /*#__PURE__*/functio
|
|
|
98
96
|
break;
|
|
99
97
|
}
|
|
100
98
|
return _context2.abrupt("return", nodes.map(function (node) {
|
|
101
|
-
if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_use_unicode_emojis', 'isEnabled', true)) {
|
|
102
|
-
// Skip SSR for nodes without an Id
|
|
103
|
-
if (!node.attrs.id) {
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
106
|
-
var unicodeEmoji = (0, _emojiIdToEmoji.emojiIdToEmoji)(node.attrs.id);
|
|
107
|
-
if (unicodeEmoji) {
|
|
108
|
-
return {
|
|
109
|
-
id: node.attrs.id,
|
|
110
|
-
shortName: node.attrs.shortName,
|
|
111
|
-
fallback: node.attrs.text,
|
|
112
|
-
representation: {
|
|
113
|
-
unicodeEmoji: unicodeEmoji
|
|
114
|
-
},
|
|
115
|
-
searchable: true,
|
|
116
|
-
type: '',
|
|
117
|
-
category: ''
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
99
|
var emojiId = {
|
|
122
100
|
id: node.attrs.id,
|
|
123
101
|
shortName: node.attrs.shortName,
|
|
@@ -147,7 +125,7 @@ var EmojiNodeDataProvider = exports.EmojiNodeDataProvider = /*#__PURE__*/functio
|
|
|
147
125
|
emojiProvider = _context2.sent;
|
|
148
126
|
fetches = nodes.map( /*#__PURE__*/function () {
|
|
149
127
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(node) {
|
|
150
|
-
var emojiId, result,
|
|
128
|
+
var emojiId, result, optimisticImageURL;
|
|
151
129
|
return _regenerator.default.wrap(function (_context) {
|
|
152
130
|
while (1) switch (_context.prev = _context.next) {
|
|
153
131
|
case 0:
|
|
@@ -160,28 +138,13 @@ var EmojiNodeDataProvider = exports.EmojiNodeDataProvider = /*#__PURE__*/functio
|
|
|
160
138
|
return emojiProvider.fetchByEmojiId(emojiId, true);
|
|
161
139
|
case 1:
|
|
162
140
|
result = _context.sent;
|
|
163
|
-
if (!(node.attrs.id && result && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_use_unicode_emojis', 'isEnabled', true))) {
|
|
164
|
-
_context.next = 2;
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
unicodeEmoji = (0, _emojiIdToEmoji.emojiIdToEmoji)(node.attrs.id);
|
|
168
|
-
if (!unicodeEmoji) {
|
|
169
|
-
_context.next = 2;
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
173
|
-
representation: {
|
|
174
|
-
unicodeEmoji: unicodeEmoji
|
|
175
|
-
}
|
|
176
|
-
}));
|
|
177
|
-
case 2:
|
|
178
141
|
if (!(getOptimisticImageUrl && result)) {
|
|
179
|
-
_context.next =
|
|
142
|
+
_context.next = 2;
|
|
180
143
|
break;
|
|
181
144
|
}
|
|
182
145
|
optimisticImageURL = getOptimisticImageUrl(emojiId);
|
|
183
146
|
if (!(result.representation && 'imagePath' in result.representation)) {
|
|
184
|
-
_context.next =
|
|
147
|
+
_context.next = 2;
|
|
185
148
|
break;
|
|
186
149
|
}
|
|
187
150
|
return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
@@ -189,9 +152,9 @@ var EmojiNodeDataProvider = exports.EmojiNodeDataProvider = /*#__PURE__*/functio
|
|
|
189
152
|
imagePath: optimisticImageURL
|
|
190
153
|
})
|
|
191
154
|
}));
|
|
192
|
-
case
|
|
155
|
+
case 2:
|
|
193
156
|
return _context.abrupt("return", result);
|
|
194
|
-
case
|
|
157
|
+
case 3:
|
|
195
158
|
case "end":
|
|
196
159
|
return _context.stop();
|
|
197
160
|
}
|
|
@@ -12,11 +12,9 @@ import { isSingleEmoji } from '@atlaskit/editor-common/utils/isSingleEmoji';
|
|
|
12
12
|
import { VANILLA_TOOLTIP_DEFAULT_CLASS, VanillaTooltip } from '@atlaskit/editor-common/vanilla-tooltip';
|
|
13
13
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
14
14
|
import { defaultEmojiHeight } from '@atlaskit/emoji/constants';
|
|
15
|
-
import { emojiIdToEmoji } from '@atlaskit/emoji/emoji-id-to-emoji';
|
|
16
15
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
17
16
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
18
17
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
19
|
-
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
20
18
|
import { emojiToDom } from './emojiNodeSpec';
|
|
21
19
|
/**
|
|
22
20
|
* Emoji node view for renderering emoji nodes
|
|
@@ -186,10 +184,7 @@ export class EmojiNodeView {
|
|
|
186
184
|
this.renderFallback();
|
|
187
185
|
return;
|
|
188
186
|
}
|
|
189
|
-
const
|
|
190
|
-
const emojiRepresentation = unicodeEmoji ? {
|
|
191
|
-
unicodeEmoji
|
|
192
|
-
} : emojiDescription === null || emojiDescription === void 0 ? void 0 : emojiDescription.representation;
|
|
187
|
+
const emojiRepresentation = emojiDescription === null || emojiDescription === void 0 ? void 0 : emojiDescription.representation;
|
|
193
188
|
if (!EmojiNodeView.isEmojiRepresentationSupported(emojiRepresentation)) {
|
|
194
189
|
EmojiNodeView.logError(new Error('Emoji representation is not supported'));
|
|
195
190
|
this.renderFallback();
|
|
@@ -202,10 +197,7 @@ export class EmojiNodeView {
|
|
|
202
197
|
}
|
|
203
198
|
}
|
|
204
199
|
static isEmojiRepresentationSupported(representation) {
|
|
205
|
-
return !!representation && ('sprite' in representation || 'imagePath' in representation || 'mediaPath' in representation
|
|
206
|
-
}
|
|
207
|
-
static shouldRecordUnicodeEmojiExposure(description, representation) {
|
|
208
|
-
return description.type === 'STANDARD' || 'unicodeEmoji' in representation;
|
|
200
|
+
return !!representation && ('sprite' in representation || 'imagePath' in representation || 'mediaPath' in representation);
|
|
209
201
|
}
|
|
210
202
|
|
|
211
203
|
// Pay attention, this method should be called only when the emoji provider returns
|
|
@@ -332,7 +324,7 @@ export class EmojiNodeView {
|
|
|
332
324
|
renderEmoji(description, representation) {
|
|
333
325
|
this.renderingFallback = false;
|
|
334
326
|
this.cleanUpAndRenderCommonAttributes();
|
|
335
|
-
const emojiType = '
|
|
327
|
+
const emojiType = 'sprite' in representation ? 'sprite' : 'image';
|
|
336
328
|
let doc = getDocument();
|
|
337
329
|
if (!doc) {
|
|
338
330
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
@@ -347,33 +339,11 @@ export class EmojiNodeView {
|
|
|
347
339
|
containerElement.setAttribute('data-testid', `${emojiType}-emoji-${description.shortName}`);
|
|
348
340
|
containerElement.setAttribute('data-emoji-type', emojiType);
|
|
349
341
|
containerElement.setAttribute('aria-label', `${this.intl.formatMessage(messages.emojiNodeLabel)} ${description.shortName}`);
|
|
350
|
-
const emojiElement = '
|
|
342
|
+
const emojiElement = 'sprite' in representation ? this.createSpriteEmojiElement(representation) : this.createImageEmojiElement(description, representation);
|
|
351
343
|
containerElement.appendChild(emojiElement);
|
|
352
344
|
this.dom.appendChild(containerElement);
|
|
353
|
-
if (EmojiNodeView.shouldRecordUnicodeEmojiExposure(description, representation)) {
|
|
354
|
-
expValEquals('platform_use_unicode_emojis', 'isEnabled', true);
|
|
355
|
-
}
|
|
356
345
|
this.createTooltip(containerElement, description.shortName);
|
|
357
346
|
}
|
|
358
|
-
createUnicodeEmojiElement(emoji) {
|
|
359
|
-
let doc = getDocument();
|
|
360
|
-
if (!doc) {
|
|
361
|
-
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
362
|
-
doc = document;
|
|
363
|
-
}
|
|
364
|
-
const spanElement = doc.createElement('span');
|
|
365
|
-
spanElement.classList.add(EmojiSharedCssClassName.EMOJI_UNICODE);
|
|
366
|
-
spanElement.textContent = emoji;
|
|
367
|
-
spanElement.style.display = 'inline-flex';
|
|
368
|
-
spanElement.style.fontSize = `var(--emoji-common-unicode-size, ${defaultEmojiHeight}px)`;
|
|
369
|
-
spanElement.style.alignItems = 'center';
|
|
370
|
-
spanElement.style.aspectRatio = '1/1';
|
|
371
|
-
spanElement.style.lineHeight = '1em';
|
|
372
|
-
spanElement.style.margin = '-1px 0';
|
|
373
|
-
spanElement.style.verticalAlign = 'middle'; // to keep vertical alignment consistent with images
|
|
374
|
-
|
|
375
|
-
return spanElement;
|
|
376
|
-
}
|
|
377
347
|
createSpriteEmojiElement(representation) {
|
|
378
348
|
let doc = getDocument();
|
|
379
349
|
if (!doc) {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { isSSR } from '@atlaskit/editor-common/is-ssr';
|
|
3
3
|
import { defaultEmojiHeight } from '@atlaskit/emoji';
|
|
4
|
-
import { emojiIdToEmoji } from '@atlaskit/emoji/emoji-id-to-emoji';
|
|
5
4
|
import { NodeDataProvider } from '@atlaskit/node-data-provider/node-data-provider';
|
|
6
|
-
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
7
5
|
export class EmojiNodeDataProvider extends NodeDataProvider {
|
|
8
6
|
constructor(resource) {
|
|
9
7
|
super();
|
|
@@ -57,26 +55,6 @@ export class EmojiNodeDataProvider extends NodeDataProvider {
|
|
|
57
55
|
const getOptimisticImageUrl = (_this$emojiResource$e = this.emojiResource.emojiProviderConfig.optimisticImageApi) === null || _this$emojiResource$e === void 0 ? void 0 : _this$emojiResource$e.getUrl;
|
|
58
56
|
if (isSSR() && getOptimisticImageUrl) {
|
|
59
57
|
return nodes.map(node => {
|
|
60
|
-
if (expValEqualsNoExposure('platform_use_unicode_emojis', 'isEnabled', true)) {
|
|
61
|
-
// Skip SSR for nodes without an Id
|
|
62
|
-
if (!node.attrs.id) {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
const unicodeEmoji = emojiIdToEmoji(node.attrs.id);
|
|
66
|
-
if (unicodeEmoji) {
|
|
67
|
-
return {
|
|
68
|
-
id: node.attrs.id,
|
|
69
|
-
shortName: node.attrs.shortName,
|
|
70
|
-
fallback: node.attrs.text,
|
|
71
|
-
representation: {
|
|
72
|
-
unicodeEmoji
|
|
73
|
-
},
|
|
74
|
-
searchable: true,
|
|
75
|
-
type: '',
|
|
76
|
-
category: ''
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
58
|
const emojiId = {
|
|
81
59
|
id: node.attrs.id,
|
|
82
60
|
shortName: node.attrs.shortName,
|
|
@@ -114,20 +92,6 @@ export class EmojiNodeDataProvider extends NodeDataProvider {
|
|
|
114
92
|
// This usually fast because the emojiProvider already has all emojis fetched.
|
|
115
93
|
const result = await emojiProvider.fetchByEmojiId(emojiId, true);
|
|
116
94
|
|
|
117
|
-
// For STANDARD emojis, return a UnicodeRepresentation so they are rendered
|
|
118
|
-
// as native text characters rather than images (twemoji removal).
|
|
119
|
-
if (node.attrs.id && result && expValEqualsNoExposure('platform_use_unicode_emojis', 'isEnabled', true)) {
|
|
120
|
-
const unicodeEmoji = emojiIdToEmoji(node.attrs.id);
|
|
121
|
-
if (unicodeEmoji) {
|
|
122
|
-
return {
|
|
123
|
-
...result,
|
|
124
|
-
representation: {
|
|
125
|
-
unicodeEmoji
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
95
|
// If we have optimisticImageApi, we need to path response and set URL from it to match the URL used in SSR.
|
|
132
96
|
if (getOptimisticImageUrl && result) {
|
|
133
97
|
const optimisticImageURL = getOptimisticImageUrl(emojiId);
|
|
@@ -16,11 +16,9 @@ import { isSingleEmoji } from '@atlaskit/editor-common/utils/isSingleEmoji';
|
|
|
16
16
|
import { VANILLA_TOOLTIP_DEFAULT_CLASS, VanillaTooltip } from '@atlaskit/editor-common/vanilla-tooltip';
|
|
17
17
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
18
18
|
import { defaultEmojiHeight } from '@atlaskit/emoji/constants';
|
|
19
|
-
import { emojiIdToEmoji } from '@atlaskit/emoji/emoji-id-to-emoji';
|
|
20
19
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
21
20
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
22
21
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
23
|
-
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
24
22
|
import { emojiToDom } from './emojiNodeSpec';
|
|
25
23
|
/**
|
|
26
24
|
* Emoji node view for renderering emoji nodes
|
|
@@ -175,7 +173,7 @@ export var EmojiNodeView = /*#__PURE__*/function () {
|
|
|
175
173
|
key: "updateDom",
|
|
176
174
|
value: function () {
|
|
177
175
|
var _updateDom = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(emojiProvider) {
|
|
178
|
-
var _this$node$attrs, shortName, id, fallback, emojiDescription,
|
|
176
|
+
var _this$node$attrs, shortName, id, fallback, emojiDescription, emojiRepresentation, _t;
|
|
179
177
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
180
178
|
while (1) switch (_context.prev = _context.next) {
|
|
181
179
|
case 0:
|
|
@@ -197,10 +195,7 @@ export var EmojiNodeView = /*#__PURE__*/function () {
|
|
|
197
195
|
this.renderFallback();
|
|
198
196
|
return _context.abrupt("return");
|
|
199
197
|
case 2:
|
|
200
|
-
|
|
201
|
-
emojiRepresentation = unicodeEmoji ? {
|
|
202
|
-
unicodeEmoji: unicodeEmoji
|
|
203
|
-
} : emojiDescription === null || emojiDescription === void 0 ? void 0 : emojiDescription.representation;
|
|
198
|
+
emojiRepresentation = emojiDescription === null || emojiDescription === void 0 ? void 0 : emojiDescription.representation;
|
|
204
199
|
if (EmojiNodeView.isEmojiRepresentationSupported(emojiRepresentation)) {
|
|
205
200
|
_context.next = 3;
|
|
206
201
|
break;
|
|
@@ -361,7 +356,7 @@ export var EmojiNodeView = /*#__PURE__*/function () {
|
|
|
361
356
|
value: function renderEmoji(description, representation) {
|
|
362
357
|
this.renderingFallback = false;
|
|
363
358
|
this.cleanUpAndRenderCommonAttributes();
|
|
364
|
-
var emojiType = '
|
|
359
|
+
var emojiType = 'sprite' in representation ? 'sprite' : 'image';
|
|
365
360
|
var doc = getDocument();
|
|
366
361
|
if (!doc) {
|
|
367
362
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
@@ -376,35 +371,11 @@ export var EmojiNodeView = /*#__PURE__*/function () {
|
|
|
376
371
|
containerElement.setAttribute('data-testid', "".concat(emojiType, "-emoji-").concat(description.shortName));
|
|
377
372
|
containerElement.setAttribute('data-emoji-type', emojiType);
|
|
378
373
|
containerElement.setAttribute('aria-label', "".concat(this.intl.formatMessage(messages.emojiNodeLabel), " ").concat(description.shortName));
|
|
379
|
-
var emojiElement = '
|
|
374
|
+
var emojiElement = 'sprite' in representation ? this.createSpriteEmojiElement(representation) : this.createImageEmojiElement(description, representation);
|
|
380
375
|
containerElement.appendChild(emojiElement);
|
|
381
376
|
this.dom.appendChild(containerElement);
|
|
382
|
-
if (EmojiNodeView.shouldRecordUnicodeEmojiExposure(description, representation)) {
|
|
383
|
-
expValEquals('platform_use_unicode_emojis', 'isEnabled', true);
|
|
384
|
-
}
|
|
385
377
|
this.createTooltip(containerElement, description.shortName);
|
|
386
378
|
}
|
|
387
|
-
}, {
|
|
388
|
-
key: "createUnicodeEmojiElement",
|
|
389
|
-
value: function createUnicodeEmojiElement(emoji) {
|
|
390
|
-
var doc = getDocument();
|
|
391
|
-
if (!doc) {
|
|
392
|
-
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
393
|
-
doc = document;
|
|
394
|
-
}
|
|
395
|
-
var spanElement = doc.createElement('span');
|
|
396
|
-
spanElement.classList.add(EmojiSharedCssClassName.EMOJI_UNICODE);
|
|
397
|
-
spanElement.textContent = emoji;
|
|
398
|
-
spanElement.style.display = 'inline-flex';
|
|
399
|
-
spanElement.style.fontSize = "var(--emoji-common-unicode-size, ".concat(defaultEmojiHeight, "px)");
|
|
400
|
-
spanElement.style.alignItems = 'center';
|
|
401
|
-
spanElement.style.aspectRatio = '1/1';
|
|
402
|
-
spanElement.style.lineHeight = '1em';
|
|
403
|
-
spanElement.style.margin = '-1px 0';
|
|
404
|
-
spanElement.style.verticalAlign = 'middle'; // to keep vertical alignment consistent with images
|
|
405
|
-
|
|
406
|
-
return spanElement;
|
|
407
|
-
}
|
|
408
379
|
}, {
|
|
409
380
|
key: "createSpriteEmojiElement",
|
|
410
381
|
value: function createSpriteEmojiElement(representation) {
|
|
@@ -468,12 +439,7 @@ export var EmojiNodeView = /*#__PURE__*/function () {
|
|
|
468
439
|
}, {
|
|
469
440
|
key: "isEmojiRepresentationSupported",
|
|
470
441
|
value: function isEmojiRepresentationSupported(representation) {
|
|
471
|
-
return !!representation && ('sprite' in representation || 'imagePath' in representation || 'mediaPath' in representation
|
|
472
|
-
}
|
|
473
|
-
}, {
|
|
474
|
-
key: "shouldRecordUnicodeEmojiExposure",
|
|
475
|
-
value: function shouldRecordUnicodeEmojiExposure(description, representation) {
|
|
476
|
-
return description.type === 'STANDARD' || 'unicodeEmoji' in representation;
|
|
442
|
+
return !!representation && ('sprite' in representation || 'imagePath' in representation || 'mediaPath' in representation);
|
|
477
443
|
}
|
|
478
444
|
}]);
|
|
479
445
|
}();
|
|
@@ -12,9 +12,7 @@ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstruct
|
|
|
12
12
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
13
|
import { isSSR } from '@atlaskit/editor-common/is-ssr';
|
|
14
14
|
import { defaultEmojiHeight } from '@atlaskit/emoji';
|
|
15
|
-
import { emojiIdToEmoji } from '@atlaskit/emoji/emoji-id-to-emoji';
|
|
16
15
|
import { NodeDataProvider } from '@atlaskit/node-data-provider/node-data-provider';
|
|
17
|
-
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
18
16
|
export var EmojiNodeDataProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
19
17
|
function EmojiNodeDataProvider(resource) {
|
|
20
18
|
var _this;
|
|
@@ -91,26 +89,6 @@ export var EmojiNodeDataProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
91
89
|
break;
|
|
92
90
|
}
|
|
93
91
|
return _context2.abrupt("return", nodes.map(function (node) {
|
|
94
|
-
if (expValEqualsNoExposure('platform_use_unicode_emojis', 'isEnabled', true)) {
|
|
95
|
-
// Skip SSR for nodes without an Id
|
|
96
|
-
if (!node.attrs.id) {
|
|
97
|
-
return undefined;
|
|
98
|
-
}
|
|
99
|
-
var unicodeEmoji = emojiIdToEmoji(node.attrs.id);
|
|
100
|
-
if (unicodeEmoji) {
|
|
101
|
-
return {
|
|
102
|
-
id: node.attrs.id,
|
|
103
|
-
shortName: node.attrs.shortName,
|
|
104
|
-
fallback: node.attrs.text,
|
|
105
|
-
representation: {
|
|
106
|
-
unicodeEmoji: unicodeEmoji
|
|
107
|
-
},
|
|
108
|
-
searchable: true,
|
|
109
|
-
type: '',
|
|
110
|
-
category: ''
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
92
|
var emojiId = {
|
|
115
93
|
id: node.attrs.id,
|
|
116
94
|
shortName: node.attrs.shortName,
|
|
@@ -140,7 +118,7 @@ export var EmojiNodeDataProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
140
118
|
emojiProvider = _context2.sent;
|
|
141
119
|
fetches = nodes.map( /*#__PURE__*/function () {
|
|
142
120
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(node) {
|
|
143
|
-
var emojiId, result,
|
|
121
|
+
var emojiId, result, optimisticImageURL;
|
|
144
122
|
return _regeneratorRuntime.wrap(function (_context) {
|
|
145
123
|
while (1) switch (_context.prev = _context.next) {
|
|
146
124
|
case 0:
|
|
@@ -153,28 +131,13 @@ export var EmojiNodeDataProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
153
131
|
return emojiProvider.fetchByEmojiId(emojiId, true);
|
|
154
132
|
case 1:
|
|
155
133
|
result = _context.sent;
|
|
156
|
-
if (!(node.attrs.id && result && expValEqualsNoExposure('platform_use_unicode_emojis', 'isEnabled', true))) {
|
|
157
|
-
_context.next = 2;
|
|
158
|
-
break;
|
|
159
|
-
}
|
|
160
|
-
unicodeEmoji = emojiIdToEmoji(node.attrs.id);
|
|
161
|
-
if (!unicodeEmoji) {
|
|
162
|
-
_context.next = 2;
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
166
|
-
representation: {
|
|
167
|
-
unicodeEmoji: unicodeEmoji
|
|
168
|
-
}
|
|
169
|
-
}));
|
|
170
|
-
case 2:
|
|
171
134
|
if (!(getOptimisticImageUrl && result)) {
|
|
172
|
-
_context.next =
|
|
135
|
+
_context.next = 2;
|
|
173
136
|
break;
|
|
174
137
|
}
|
|
175
138
|
optimisticImageURL = getOptimisticImageUrl(emojiId);
|
|
176
139
|
if (!(result.representation && 'imagePath' in result.representation)) {
|
|
177
|
-
_context.next =
|
|
140
|
+
_context.next = 2;
|
|
178
141
|
break;
|
|
179
142
|
}
|
|
180
143
|
return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
@@ -182,9 +145,9 @@ export var EmojiNodeDataProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
182
145
|
imagePath: optimisticImageURL
|
|
183
146
|
})
|
|
184
147
|
}));
|
|
185
|
-
case
|
|
148
|
+
case 2:
|
|
186
149
|
return _context.abrupt("return", result);
|
|
187
|
-
case
|
|
150
|
+
case 3:
|
|
188
151
|
case "end":
|
|
189
152
|
return _context.stop();
|
|
190
153
|
}
|
|
@@ -39,7 +39,6 @@ export declare class EmojiNodeView implements NodeView {
|
|
|
39
39
|
private isHTMLElement;
|
|
40
40
|
private updateDom;
|
|
41
41
|
private static isEmojiRepresentationSupported;
|
|
42
|
-
private static shouldRecordUnicodeEmojiExposure;
|
|
43
42
|
private cleanUpAndRenderCommonAttributes;
|
|
44
43
|
/**
|
|
45
44
|
* Lazily creates a VanillaTooltip on the given element showing the emoji shortName.
|
|
@@ -50,7 +49,6 @@ export declare class EmojiNodeView implements NodeView {
|
|
|
50
49
|
private createTooltip;
|
|
51
50
|
private renderFallback;
|
|
52
51
|
private renderEmoji;
|
|
53
|
-
private createUnicodeEmojiElement;
|
|
54
52
|
private createSpriteEmojiElement;
|
|
55
53
|
private createImageEmojiElement;
|
|
56
54
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-emoji",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "29.0.0",
|
|
4
4
|
"description": "Emoji plugin for @atlaskit/editor-core",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -24,20 +24,20 @@
|
|
|
24
24
|
"@atlaskit/adf-schema": "^57.7.0",
|
|
25
25
|
"@atlaskit/browser-apis": "^1.2.0",
|
|
26
26
|
"@atlaskit/editor-json-transformer": "^10.0.0",
|
|
27
|
-
"@atlaskit/editor-plugin-analytics": "^
|
|
28
|
-
"@atlaskit/editor-plugin-annotation": "^
|
|
29
|
-
"@atlaskit/editor-plugin-base": "^
|
|
30
|
-
"@atlaskit/editor-plugin-connectivity": "^
|
|
31
|
-
"@atlaskit/editor-plugin-editor-viewmode": "^
|
|
32
|
-
"@atlaskit/editor-plugin-metrics": "^
|
|
33
|
-
"@atlaskit/editor-plugin-type-ahead": "^
|
|
34
|
-
"@atlaskit/editor-plugin-ui-control-registry": "^
|
|
27
|
+
"@atlaskit/editor-plugin-analytics": "^28.0.0",
|
|
28
|
+
"@atlaskit/editor-plugin-annotation": "^28.0.0",
|
|
29
|
+
"@atlaskit/editor-plugin-base": "^29.0.0",
|
|
30
|
+
"@atlaskit/editor-plugin-connectivity": "^28.0.0",
|
|
31
|
+
"@atlaskit/editor-plugin-editor-viewmode": "^30.0.0",
|
|
32
|
+
"@atlaskit/editor-plugin-metrics": "^29.0.0",
|
|
33
|
+
"@atlaskit/editor-plugin-type-ahead": "^29.0.0",
|
|
34
|
+
"@atlaskit/editor-plugin-ui-control-registry": "^22.0.0",
|
|
35
35
|
"@atlaskit/editor-prosemirror": "^9.0.0",
|
|
36
|
-
"@atlaskit/editor-shared-styles": "^4.
|
|
36
|
+
"@atlaskit/editor-shared-styles": "^4.5.0",
|
|
37
37
|
"@atlaskit/editor-ui-control-model": "^2.10.0",
|
|
38
|
-
"@atlaskit/emoji": "^
|
|
38
|
+
"@atlaskit/emoji": "^73.0.0",
|
|
39
39
|
"@atlaskit/icon": "^38.0.0",
|
|
40
|
-
"@atlaskit/node-data-provider": "^
|
|
40
|
+
"@atlaskit/node-data-provider": "^29.0.0",
|
|
41
41
|
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
42
42
|
"@atlaskit/platform-feature-flags": "^2.2.0",
|
|
43
43
|
"@atlaskit/prosemirror-input-rules": "^4.1.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"react-loadable": "^5.1.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@atlaskit/editor-common": "^
|
|
53
|
+
"@atlaskit/editor-common": "^132.0.0",
|
|
54
54
|
"react": "^18.2.0 || ^19.2.0",
|
|
55
55
|
"react-dom": "^18.2.0 || ^19.2.0",
|
|
56
56
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|