@atlaskit/editor-plugin-emoji 11.2.4 → 11.3.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/emojiPlugin.js +6 -6
- package/dist/cjs/nodeviews/EmojiNodeView.js +15 -15
- package/dist/cjs/pm-plugins/providers/EmojiNodeDataProvider.js +51 -14
- package/dist/es2019/pm-plugins/providers/EmojiNodeDataProvider.js +36 -0
- package/dist/esm/emojiPlugin.js +6 -6
- package/dist/esm/nodeviews/EmojiNodeView.js +15 -15
- package/dist/esm/pm-plugins/providers/EmojiNodeDataProvider.js +51 -14
- package/package.json +10 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-emoji
|
|
2
2
|
|
|
3
|
+
## 11.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`81637ec91afd1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/81637ec91afd1) -
|
|
8
|
+
Represent standard emojis as native Unicode characters instead of images. Updates
|
|
9
|
+
EmojiNodeDataProvider to support Unicode representations.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 11.2.5
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 11.2.4
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/cjs/emojiPlugin.js
CHANGED
|
@@ -257,25 +257,25 @@ var emojiPlugin = exports.emojiPlugin = function emojiPlugin(_ref2) {
|
|
|
257
257
|
var _setProvider = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(providerPromise) {
|
|
258
258
|
var _api$core$actions$exe;
|
|
259
259
|
var provider;
|
|
260
|
-
return _regenerator.default.wrap(function
|
|
260
|
+
return _regenerator.default.wrap(function (_context) {
|
|
261
261
|
while (1) switch (_context.prev = _context.next) {
|
|
262
262
|
case 0:
|
|
263
|
-
_context.next =
|
|
263
|
+
_context.next = 1;
|
|
264
264
|
return providerPromise;
|
|
265
|
-
case
|
|
265
|
+
case 1:
|
|
266
266
|
provider = _context.sent;
|
|
267
267
|
if (!(previousEmojiProvider === provider || (options === null || options === void 0 ? void 0 : options.emojiProvider) === providerPromise)) {
|
|
268
|
-
_context.next =
|
|
268
|
+
_context.next = 2;
|
|
269
269
|
break;
|
|
270
270
|
}
|
|
271
271
|
return _context.abrupt("return", false);
|
|
272
|
-
case
|
|
272
|
+
case 2:
|
|
273
273
|
previousEmojiProvider = provider;
|
|
274
274
|
return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref0) {
|
|
275
275
|
var tr = _ref0.tr;
|
|
276
276
|
return setProviderTr(provider)(tr);
|
|
277
277
|
})) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false);
|
|
278
|
-
case
|
|
278
|
+
case 3:
|
|
279
279
|
case "end":
|
|
280
280
|
return _context.stop();
|
|
281
281
|
}
|
|
@@ -154,50 +154,50 @@ var EmojiNodeView = exports.EmojiNodeView = /*#__PURE__*/function () {
|
|
|
154
154
|
key: "updateDom",
|
|
155
155
|
value: function () {
|
|
156
156
|
var _updateDom = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(emojiProvider) {
|
|
157
|
-
var _this$node$attrs, shortName, id, fallback, emojiDescription, emojiRepresentation;
|
|
158
|
-
return _regenerator.default.wrap(function
|
|
157
|
+
var _this$node$attrs, shortName, id, fallback, emojiDescription, emojiRepresentation, _t;
|
|
158
|
+
return _regenerator.default.wrap(function (_context) {
|
|
159
159
|
while (1) switch (_context.prev = _context.next) {
|
|
160
160
|
case 0:
|
|
161
161
|
_context.prev = 0;
|
|
162
162
|
_this$node$attrs = this.node.attrs, shortName = _this$node$attrs.shortName, id = _this$node$attrs.id, fallback = _this$node$attrs.text;
|
|
163
|
-
_context.next =
|
|
163
|
+
_context.next = 1;
|
|
164
164
|
return emojiProvider === null || emojiProvider === void 0 ? void 0 : emojiProvider.fetchByEmojiId({
|
|
165
165
|
id: id,
|
|
166
166
|
shortName: shortName,
|
|
167
167
|
fallback: fallback
|
|
168
168
|
}, true);
|
|
169
|
-
case
|
|
169
|
+
case 1:
|
|
170
170
|
emojiDescription = _context.sent;
|
|
171
171
|
if (emojiDescription) {
|
|
172
|
-
_context.next =
|
|
172
|
+
_context.next = 2;
|
|
173
173
|
break;
|
|
174
174
|
}
|
|
175
175
|
EmojiNodeView.logError(new Error('Emoji description is not loaded'));
|
|
176
176
|
this.renderFallback();
|
|
177
177
|
return _context.abrupt("return");
|
|
178
|
-
case
|
|
178
|
+
case 2:
|
|
179
179
|
emojiRepresentation = emojiDescription === null || emojiDescription === void 0 ? void 0 : emojiDescription.representation;
|
|
180
180
|
if (EmojiNodeView.isEmojiRepresentationSupported(emojiRepresentation)) {
|
|
181
|
-
_context.next =
|
|
181
|
+
_context.next = 3;
|
|
182
182
|
break;
|
|
183
183
|
}
|
|
184
184
|
EmojiNodeView.logError(new Error('Emoji representation is not supported'));
|
|
185
185
|
this.renderFallback();
|
|
186
186
|
return _context.abrupt("return");
|
|
187
|
-
case
|
|
187
|
+
case 3:
|
|
188
188
|
this.renderEmoji(emojiDescription, emojiRepresentation);
|
|
189
|
-
_context.next =
|
|
189
|
+
_context.next = 5;
|
|
190
190
|
break;
|
|
191
|
-
case
|
|
192
|
-
_context.prev =
|
|
193
|
-
|
|
194
|
-
EmojiNodeView.logError(
|
|
191
|
+
case 4:
|
|
192
|
+
_context.prev = 4;
|
|
193
|
+
_t = _context["catch"](0);
|
|
194
|
+
EmojiNodeView.logError(_t instanceof Error ? _t : new Error('Unknown error on EmojiNodeView updateDom'));
|
|
195
195
|
this.renderFallback();
|
|
196
|
-
case
|
|
196
|
+
case 5:
|
|
197
197
|
case "end":
|
|
198
198
|
return _context.stop();
|
|
199
199
|
}
|
|
200
|
-
}, _callee, this, [[0,
|
|
200
|
+
}, _callee, this, [[0, 4]]);
|
|
201
201
|
}));
|
|
202
202
|
function updateDom(_x) {
|
|
203
203
|
return _updateDom.apply(this, arguments);
|
|
@@ -15,7 +15,9 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
15
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
16
|
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
17
17
|
var _emoji = require("@atlaskit/emoji");
|
|
18
|
+
var _emojiIdToEmoji = require("@atlaskit/emoji/emoji-id-to-emoji");
|
|
18
19
|
var _nodeDataProvider = require("@atlaskit/node-data-provider");
|
|
20
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
19
21
|
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; }
|
|
20
22
|
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; }
|
|
21
23
|
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)); }
|
|
@@ -78,7 +80,7 @@ var EmojiNodeDataProvider = exports.EmojiNodeDataProvider = /*#__PURE__*/functio
|
|
|
78
80
|
var _fetchNodesData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(nodes) {
|
|
79
81
|
var _this$emojiResource$e;
|
|
80
82
|
var getOptimisticImageUrl, emojiProvider, fetches;
|
|
81
|
-
return _regenerator.default.wrap(function
|
|
83
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
82
84
|
while (1) switch (_context2.prev = _context2.next) {
|
|
83
85
|
case 0:
|
|
84
86
|
// If we have an `optimisticImageApi`, use it to generate a URL immediately.
|
|
@@ -92,10 +94,30 @@ var EmojiNodeDataProvider = exports.EmojiNodeDataProvider = /*#__PURE__*/functio
|
|
|
92
94
|
// and platform/packages/elements/emoji/src/components/common/ResourcedEmojiComponent.tsx
|
|
93
95
|
getOptimisticImageUrl = (_this$emojiResource$e = this.emojiResource.emojiProviderConfig.optimisticImageApi) === null || _this$emojiResource$e === void 0 ? void 0 : _this$emojiResource$e.getUrl;
|
|
94
96
|
if (!((0, _coreUtils.isSSR)() && getOptimisticImageUrl)) {
|
|
95
|
-
_context2.next =
|
|
97
|
+
_context2.next = 1;
|
|
96
98
|
break;
|
|
97
99
|
}
|
|
98
100
|
return _context2.abrupt("return", nodes.map(function (node) {
|
|
101
|
+
if ((0, _platformFeatureFlags.fg)('platform_twemoji_removal_unicode_emojis')) {
|
|
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
|
+
}
|
|
99
121
|
var emojiId = {
|
|
100
122
|
id: node.attrs.id,
|
|
101
123
|
shortName: node.attrs.shortName,
|
|
@@ -118,15 +140,15 @@ var EmojiNodeDataProvider = exports.EmojiNodeDataProvider = /*#__PURE__*/functio
|
|
|
118
140
|
category: ''
|
|
119
141
|
};
|
|
120
142
|
}));
|
|
121
|
-
case
|
|
122
|
-
_context2.next =
|
|
143
|
+
case 1:
|
|
144
|
+
_context2.next = 2;
|
|
123
145
|
return this.emojiProvider;
|
|
124
|
-
case
|
|
146
|
+
case 2:
|
|
125
147
|
emojiProvider = _context2.sent;
|
|
126
148
|
fetches = nodes.map( /*#__PURE__*/function () {
|
|
127
149
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(node) {
|
|
128
|
-
var emojiId, result, optimisticImageURL;
|
|
129
|
-
return _regenerator.default.wrap(function
|
|
150
|
+
var emojiId, result, unicodeEmoji, optimisticImageURL;
|
|
151
|
+
return _regenerator.default.wrap(function (_context) {
|
|
130
152
|
while (1) switch (_context.prev = _context.next) {
|
|
131
153
|
case 0:
|
|
132
154
|
emojiId = {
|
|
@@ -134,17 +156,32 @@ var EmojiNodeDataProvider = exports.EmojiNodeDataProvider = /*#__PURE__*/functio
|
|
|
134
156
|
shortName: node.attrs.shortName,
|
|
135
157
|
fallback: node.attrs.text
|
|
136
158
|
}; // This usually fast because the emojiProvider already has all emojis fetched.
|
|
137
|
-
_context.next =
|
|
159
|
+
_context.next = 1;
|
|
138
160
|
return emojiProvider.fetchByEmojiId(emojiId, true);
|
|
139
|
-
case
|
|
161
|
+
case 1:
|
|
140
162
|
result = _context.sent;
|
|
163
|
+
if (!(node.attrs.id && result && (0, _platformFeatureFlags.fg)('platform_twemoji_removal_unicode_emojis'))) {
|
|
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:
|
|
141
178
|
if (!(getOptimisticImageUrl && result)) {
|
|
142
|
-
_context.next =
|
|
179
|
+
_context.next = 3;
|
|
143
180
|
break;
|
|
144
181
|
}
|
|
145
182
|
optimisticImageURL = getOptimisticImageUrl(emojiId);
|
|
146
183
|
if (!(result.representation && 'imagePath' in result.representation)) {
|
|
147
|
-
_context.next =
|
|
184
|
+
_context.next = 3;
|
|
148
185
|
break;
|
|
149
186
|
}
|
|
150
187
|
return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
@@ -152,9 +189,9 @@ var EmojiNodeDataProvider = exports.EmojiNodeDataProvider = /*#__PURE__*/functio
|
|
|
152
189
|
imagePath: optimisticImageURL
|
|
153
190
|
})
|
|
154
191
|
}));
|
|
155
|
-
case
|
|
192
|
+
case 3:
|
|
156
193
|
return _context.abrupt("return", result);
|
|
157
|
-
case
|
|
194
|
+
case 4:
|
|
158
195
|
case "end":
|
|
159
196
|
return _context.stop();
|
|
160
197
|
}
|
|
@@ -165,7 +202,7 @@ var EmojiNodeDataProvider = exports.EmojiNodeDataProvider = /*#__PURE__*/functio
|
|
|
165
202
|
};
|
|
166
203
|
}());
|
|
167
204
|
return _context2.abrupt("return", Promise.all(fetches));
|
|
168
|
-
case
|
|
205
|
+
case 3:
|
|
169
206
|
case "end":
|
|
170
207
|
return _context2.stop();
|
|
171
208
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
3
3
|
import { defaultEmojiHeight } from '@atlaskit/emoji';
|
|
4
|
+
import { emojiIdToEmoji } from '@atlaskit/emoji/emoji-id-to-emoji';
|
|
4
5
|
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
7
|
export class EmojiNodeDataProvider extends NodeDataProvider {
|
|
6
8
|
constructor(resource) {
|
|
7
9
|
super();
|
|
@@ -55,6 +57,26 @@ export class EmojiNodeDataProvider extends NodeDataProvider {
|
|
|
55
57
|
const getOptimisticImageUrl = (_this$emojiResource$e = this.emojiResource.emojiProviderConfig.optimisticImageApi) === null || _this$emojiResource$e === void 0 ? void 0 : _this$emojiResource$e.getUrl;
|
|
56
58
|
if (isSSR() && getOptimisticImageUrl) {
|
|
57
59
|
return nodes.map(node => {
|
|
60
|
+
if (fg('platform_twemoji_removal_unicode_emojis')) {
|
|
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
|
+
}
|
|
58
80
|
const emojiId = {
|
|
59
81
|
id: node.attrs.id,
|
|
60
82
|
shortName: node.attrs.shortName,
|
|
@@ -92,6 +114,20 @@ export class EmojiNodeDataProvider extends NodeDataProvider {
|
|
|
92
114
|
// This usually fast because the emojiProvider already has all emojis fetched.
|
|
93
115
|
const result = await emojiProvider.fetchByEmojiId(emojiId, true);
|
|
94
116
|
|
|
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 && fg('platform_twemoji_removal_unicode_emojis')) {
|
|
120
|
+
const unicodeEmoji = emojiIdToEmoji(node.attrs.id);
|
|
121
|
+
if (unicodeEmoji) {
|
|
122
|
+
return {
|
|
123
|
+
...result,
|
|
124
|
+
representation: {
|
|
125
|
+
unicodeEmoji
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
95
131
|
// If we have optimisticImageApi, we need to path response and set URL from it to match the URL used in SSR.
|
|
96
132
|
if (getOptimisticImageUrl && result) {
|
|
97
133
|
const optimisticImageURL = getOptimisticImageUrl(emojiId);
|
package/dist/esm/emojiPlugin.js
CHANGED
|
@@ -246,25 +246,25 @@ export var emojiPlugin = function emojiPlugin(_ref2) {
|
|
|
246
246
|
var _setProvider = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(providerPromise) {
|
|
247
247
|
var _api$core$actions$exe;
|
|
248
248
|
var provider;
|
|
249
|
-
return _regeneratorRuntime.wrap(function
|
|
249
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
250
250
|
while (1) switch (_context.prev = _context.next) {
|
|
251
251
|
case 0:
|
|
252
|
-
_context.next =
|
|
252
|
+
_context.next = 1;
|
|
253
253
|
return providerPromise;
|
|
254
|
-
case
|
|
254
|
+
case 1:
|
|
255
255
|
provider = _context.sent;
|
|
256
256
|
if (!(previousEmojiProvider === provider || (options === null || options === void 0 ? void 0 : options.emojiProvider) === providerPromise)) {
|
|
257
|
-
_context.next =
|
|
257
|
+
_context.next = 2;
|
|
258
258
|
break;
|
|
259
259
|
}
|
|
260
260
|
return _context.abrupt("return", false);
|
|
261
|
-
case
|
|
261
|
+
case 2:
|
|
262
262
|
previousEmojiProvider = provider;
|
|
263
263
|
return _context.abrupt("return", (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref0) {
|
|
264
264
|
var tr = _ref0.tr;
|
|
265
265
|
return setProviderTr(provider)(tr);
|
|
266
266
|
})) !== null && _api$core$actions$exe !== void 0 ? _api$core$actions$exe : false);
|
|
267
|
-
case
|
|
267
|
+
case 3:
|
|
268
268
|
case "end":
|
|
269
269
|
return _context.stop();
|
|
270
270
|
}
|
|
@@ -146,50 +146,50 @@ export var EmojiNodeView = /*#__PURE__*/function () {
|
|
|
146
146
|
key: "updateDom",
|
|
147
147
|
value: function () {
|
|
148
148
|
var _updateDom = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(emojiProvider) {
|
|
149
|
-
var _this$node$attrs, shortName, id, fallback, emojiDescription, emojiRepresentation;
|
|
150
|
-
return _regeneratorRuntime.wrap(function
|
|
149
|
+
var _this$node$attrs, shortName, id, fallback, emojiDescription, emojiRepresentation, _t;
|
|
150
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
151
151
|
while (1) switch (_context.prev = _context.next) {
|
|
152
152
|
case 0:
|
|
153
153
|
_context.prev = 0;
|
|
154
154
|
_this$node$attrs = this.node.attrs, shortName = _this$node$attrs.shortName, id = _this$node$attrs.id, fallback = _this$node$attrs.text;
|
|
155
|
-
_context.next =
|
|
155
|
+
_context.next = 1;
|
|
156
156
|
return emojiProvider === null || emojiProvider === void 0 ? void 0 : emojiProvider.fetchByEmojiId({
|
|
157
157
|
id: id,
|
|
158
158
|
shortName: shortName,
|
|
159
159
|
fallback: fallback
|
|
160
160
|
}, true);
|
|
161
|
-
case
|
|
161
|
+
case 1:
|
|
162
162
|
emojiDescription = _context.sent;
|
|
163
163
|
if (emojiDescription) {
|
|
164
|
-
_context.next =
|
|
164
|
+
_context.next = 2;
|
|
165
165
|
break;
|
|
166
166
|
}
|
|
167
167
|
EmojiNodeView.logError(new Error('Emoji description is not loaded'));
|
|
168
168
|
this.renderFallback();
|
|
169
169
|
return _context.abrupt("return");
|
|
170
|
-
case
|
|
170
|
+
case 2:
|
|
171
171
|
emojiRepresentation = emojiDescription === null || emojiDescription === void 0 ? void 0 : emojiDescription.representation;
|
|
172
172
|
if (EmojiNodeView.isEmojiRepresentationSupported(emojiRepresentation)) {
|
|
173
|
-
_context.next =
|
|
173
|
+
_context.next = 3;
|
|
174
174
|
break;
|
|
175
175
|
}
|
|
176
176
|
EmojiNodeView.logError(new Error('Emoji representation is not supported'));
|
|
177
177
|
this.renderFallback();
|
|
178
178
|
return _context.abrupt("return");
|
|
179
|
-
case
|
|
179
|
+
case 3:
|
|
180
180
|
this.renderEmoji(emojiDescription, emojiRepresentation);
|
|
181
|
-
_context.next =
|
|
181
|
+
_context.next = 5;
|
|
182
182
|
break;
|
|
183
|
-
case
|
|
184
|
-
_context.prev =
|
|
185
|
-
|
|
186
|
-
EmojiNodeView.logError(
|
|
183
|
+
case 4:
|
|
184
|
+
_context.prev = 4;
|
|
185
|
+
_t = _context["catch"](0);
|
|
186
|
+
EmojiNodeView.logError(_t instanceof Error ? _t : new Error('Unknown error on EmojiNodeView updateDom'));
|
|
187
187
|
this.renderFallback();
|
|
188
|
-
case
|
|
188
|
+
case 5:
|
|
189
189
|
case "end":
|
|
190
190
|
return _context.stop();
|
|
191
191
|
}
|
|
192
|
-
}, _callee, this, [[0,
|
|
192
|
+
}, _callee, this, [[0, 4]]);
|
|
193
193
|
}));
|
|
194
194
|
function updateDom(_x) {
|
|
195
195
|
return _updateDom.apply(this, arguments);
|
|
@@ -12,7 +12,9 @@ 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/core-utils';
|
|
14
14
|
import { defaultEmojiHeight } from '@atlaskit/emoji';
|
|
15
|
+
import { emojiIdToEmoji } from '@atlaskit/emoji/emoji-id-to-emoji';
|
|
15
16
|
import { NodeDataProvider } from '@atlaskit/node-data-provider';
|
|
17
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
18
|
export var EmojiNodeDataProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
17
19
|
function EmojiNodeDataProvider(resource) {
|
|
18
20
|
var _this;
|
|
@@ -71,7 +73,7 @@ export var EmojiNodeDataProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
71
73
|
var _fetchNodesData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(nodes) {
|
|
72
74
|
var _this$emojiResource$e;
|
|
73
75
|
var getOptimisticImageUrl, emojiProvider, fetches;
|
|
74
|
-
return _regeneratorRuntime.wrap(function
|
|
76
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
75
77
|
while (1) switch (_context2.prev = _context2.next) {
|
|
76
78
|
case 0:
|
|
77
79
|
// If we have an `optimisticImageApi`, use it to generate a URL immediately.
|
|
@@ -85,10 +87,30 @@ export var EmojiNodeDataProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
85
87
|
// and platform/packages/elements/emoji/src/components/common/ResourcedEmojiComponent.tsx
|
|
86
88
|
getOptimisticImageUrl = (_this$emojiResource$e = this.emojiResource.emojiProviderConfig.optimisticImageApi) === null || _this$emojiResource$e === void 0 ? void 0 : _this$emojiResource$e.getUrl;
|
|
87
89
|
if (!(isSSR() && getOptimisticImageUrl)) {
|
|
88
|
-
_context2.next =
|
|
90
|
+
_context2.next = 1;
|
|
89
91
|
break;
|
|
90
92
|
}
|
|
91
93
|
return _context2.abrupt("return", nodes.map(function (node) {
|
|
94
|
+
if (fg('platform_twemoji_removal_unicode_emojis')) {
|
|
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
|
+
}
|
|
92
114
|
var emojiId = {
|
|
93
115
|
id: node.attrs.id,
|
|
94
116
|
shortName: node.attrs.shortName,
|
|
@@ -111,15 +133,15 @@ export var EmojiNodeDataProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
111
133
|
category: ''
|
|
112
134
|
};
|
|
113
135
|
}));
|
|
114
|
-
case
|
|
115
|
-
_context2.next =
|
|
136
|
+
case 1:
|
|
137
|
+
_context2.next = 2;
|
|
116
138
|
return this.emojiProvider;
|
|
117
|
-
case
|
|
139
|
+
case 2:
|
|
118
140
|
emojiProvider = _context2.sent;
|
|
119
141
|
fetches = nodes.map( /*#__PURE__*/function () {
|
|
120
142
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(node) {
|
|
121
|
-
var emojiId, result, optimisticImageURL;
|
|
122
|
-
return _regeneratorRuntime.wrap(function
|
|
143
|
+
var emojiId, result, unicodeEmoji, optimisticImageURL;
|
|
144
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
123
145
|
while (1) switch (_context.prev = _context.next) {
|
|
124
146
|
case 0:
|
|
125
147
|
emojiId = {
|
|
@@ -127,17 +149,32 @@ export var EmojiNodeDataProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
127
149
|
shortName: node.attrs.shortName,
|
|
128
150
|
fallback: node.attrs.text
|
|
129
151
|
}; // This usually fast because the emojiProvider already has all emojis fetched.
|
|
130
|
-
_context.next =
|
|
152
|
+
_context.next = 1;
|
|
131
153
|
return emojiProvider.fetchByEmojiId(emojiId, true);
|
|
132
|
-
case
|
|
154
|
+
case 1:
|
|
133
155
|
result = _context.sent;
|
|
156
|
+
if (!(node.attrs.id && result && fg('platform_twemoji_removal_unicode_emojis'))) {
|
|
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:
|
|
134
171
|
if (!(getOptimisticImageUrl && result)) {
|
|
135
|
-
_context.next =
|
|
172
|
+
_context.next = 3;
|
|
136
173
|
break;
|
|
137
174
|
}
|
|
138
175
|
optimisticImageURL = getOptimisticImageUrl(emojiId);
|
|
139
176
|
if (!(result.representation && 'imagePath' in result.representation)) {
|
|
140
|
-
_context.next =
|
|
177
|
+
_context.next = 3;
|
|
141
178
|
break;
|
|
142
179
|
}
|
|
143
180
|
return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
@@ -145,9 +182,9 @@ export var EmojiNodeDataProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
145
182
|
imagePath: optimisticImageURL
|
|
146
183
|
})
|
|
147
184
|
}));
|
|
148
|
-
case
|
|
185
|
+
case 3:
|
|
149
186
|
return _context.abrupt("return", result);
|
|
150
|
-
case
|
|
187
|
+
case 4:
|
|
151
188
|
case "end":
|
|
152
189
|
return _context.stop();
|
|
153
190
|
}
|
|
@@ -158,7 +195,7 @@ export var EmojiNodeDataProvider = /*#__PURE__*/function (_NodeDataProvider) {
|
|
|
158
195
|
};
|
|
159
196
|
}());
|
|
160
197
|
return _context2.abrupt("return", Promise.all(fetches));
|
|
161
|
-
case
|
|
198
|
+
case 3:
|
|
162
199
|
case "end":
|
|
163
200
|
return _context2.stop();
|
|
164
201
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-emoji",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.3.0",
|
|
4
4
|
"description": "Emoji plugin for @atlaskit/editor-core",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"singleton": true
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@atlaskit/adf-schema": "^52.
|
|
24
|
+
"@atlaskit/adf-schema": "^52.15.0",
|
|
25
25
|
"@atlaskit/browser-apis": "^0.0.2",
|
|
26
26
|
"@atlaskit/editor-plugin-analytics": "^10.1.0",
|
|
27
27
|
"@atlaskit/editor-plugin-annotation": "^10.5.0",
|
|
@@ -29,23 +29,23 @@
|
|
|
29
29
|
"@atlaskit/editor-plugin-connectivity": "^10.1.0",
|
|
30
30
|
"@atlaskit/editor-plugin-editor-viewmode": "^12.1.0",
|
|
31
31
|
"@atlaskit/editor-plugin-metrics": "^11.1.0",
|
|
32
|
-
"@atlaskit/editor-plugin-type-ahead": "^10.
|
|
32
|
+
"@atlaskit/editor-plugin-type-ahead": "^10.3.0",
|
|
33
33
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
34
34
|
"@atlaskit/editor-shared-styles": "^3.11.0",
|
|
35
|
-
"@atlaskit/emoji": "^70.
|
|
35
|
+
"@atlaskit/emoji": "^70.13.0",
|
|
36
36
|
"@atlaskit/icon": "^35.3.0",
|
|
37
37
|
"@atlaskit/node-data-provider": "^11.1.0",
|
|
38
38
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
39
39
|
"@atlaskit/prosemirror-input-rules": "^3.7.0",
|
|
40
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
41
|
-
"@atlaskit/tokens": "^13.
|
|
40
|
+
"@atlaskit/tmp-editor-statsig": "^85.0.0",
|
|
41
|
+
"@atlaskit/tokens": "^13.1.0",
|
|
42
42
|
"@babel/runtime": "^7.0.0",
|
|
43
43
|
"@emotion/react": "^11.7.1",
|
|
44
44
|
"lodash": "^4.17.21",
|
|
45
45
|
"react-loadable": "^5.1.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@atlaskit/editor-common": "^114.
|
|
48
|
+
"@atlaskit/editor-common": "^114.51.0",
|
|
49
49
|
"react": "^18.2.0",
|
|
50
50
|
"react-dom": "^18.2.0",
|
|
51
51
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
@@ -107,6 +107,9 @@
|
|
|
107
107
|
},
|
|
108
108
|
"platform_editor_adf_with_localid": {
|
|
109
109
|
"type": "boolean"
|
|
110
|
+
},
|
|
111
|
+
"platform_twemoji_removal_unicode_emojis": {
|
|
112
|
+
"type": "boolean"
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
115
|
}
|