@atlaskit/editor-plugin-emoji 11.1.1 → 11.1.2
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 +6 -0
- package/dist/cjs/nodeviews/EmojiNodeView.js +40 -5
- package/dist/es2019/nodeviews/EmojiNodeView.js +38 -5
- package/dist/esm/nodeviews/EmojiNodeView.js +40 -5
- package/dist/types/nodeviews/EmojiNodeView.d.ts +1 -0
- package/dist/types-ts4.5/nodeviews/EmojiNodeView.d.ts +1 -0
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,7 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
12
12
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
14
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
15
|
+
var _browserApis = require("@atlaskit/browser-apis");
|
|
15
16
|
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
16
17
|
var _emoji = require("@atlaskit/editor-common/emoji");
|
|
17
18
|
var _monitoring = require("@atlaskit/editor-common/monitoring");
|
|
@@ -223,7 +224,12 @@ var EmojiNodeView = exports.EmojiNodeView = /*#__PURE__*/function () {
|
|
|
223
224
|
value: function renderFallback() {
|
|
224
225
|
this.renderingFallback = true;
|
|
225
226
|
this.cleanUpAndRenderCommonAttributes();
|
|
226
|
-
var
|
|
227
|
+
var doc = (0, _browserApis.getDocument)();
|
|
228
|
+
if (!doc) {
|
|
229
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
230
|
+
doc = document;
|
|
231
|
+
}
|
|
232
|
+
var fallbackElement = doc.createElement('span');
|
|
227
233
|
fallbackElement.innerText = this.node.attrs.text || this.node.attrs.shortName;
|
|
228
234
|
fallbackElement.setAttribute('data-testid', "fallback-emoji-".concat(this.node.attrs.shortName));
|
|
229
235
|
fallbackElement.setAttribute('data-emoji-type', 'fallback');
|
|
@@ -235,23 +241,47 @@ var EmojiNodeView = exports.EmojiNodeView = /*#__PURE__*/function () {
|
|
|
235
241
|
this.renderingFallback = false;
|
|
236
242
|
this.cleanUpAndRenderCommonAttributes();
|
|
237
243
|
var emojiType = 'sprite' in representation ? 'sprite' : 'image';
|
|
244
|
+
var doc = (0, _browserApis.getDocument)();
|
|
245
|
+
if (!doc) {
|
|
246
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
247
|
+
doc = document;
|
|
248
|
+
}
|
|
238
249
|
|
|
239
250
|
// Add wrapper for the emoji
|
|
240
|
-
var containerElement =
|
|
251
|
+
var containerElement = doc.createElement('span');
|
|
241
252
|
containerElement.setAttribute('role', 'img');
|
|
242
253
|
containerElement.setAttribute('title', description.shortName);
|
|
243
254
|
containerElement.classList.add(_emoji.EmojiSharedCssClassName.EMOJI_CONTAINER);
|
|
244
255
|
containerElement.setAttribute('data-testid', "".concat(emojiType, "-emoji-").concat(description.shortName));
|
|
245
256
|
containerElement.setAttribute('data-emoji-type', emojiType);
|
|
246
257
|
containerElement.setAttribute('aria-label', "".concat(this.intl.formatMessage(_emoji.messages.emojiNodeLabel), " ").concat(description.shortName));
|
|
247
|
-
var emojiElement = 'sprite' in representation ? this.createSpriteEmojiElement(representation) : this.createImageEmojiElement(description, representation);
|
|
258
|
+
var emojiElement = 'unicodeEmoji' in representation ? this.createUnicodeEmojiElement(representation.unicodeEmoji) : 'sprite' in representation ? this.createSpriteEmojiElement(representation) : this.createImageEmojiElement(description, representation);
|
|
248
259
|
containerElement.appendChild(emojiElement);
|
|
249
260
|
this.dom.appendChild(containerElement);
|
|
250
261
|
}
|
|
262
|
+
}, {
|
|
263
|
+
key: "createUnicodeEmojiElement",
|
|
264
|
+
value: function createUnicodeEmojiElement(_) {
|
|
265
|
+
var doc = (0, _browserApis.getDocument)();
|
|
266
|
+
if (!doc) {
|
|
267
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
268
|
+
doc = document;
|
|
269
|
+
}
|
|
270
|
+
var spanElement = doc.createElement('span');
|
|
271
|
+
|
|
272
|
+
// NOTE: Implement unicode emoji element creation
|
|
273
|
+
|
|
274
|
+
return spanElement;
|
|
275
|
+
}
|
|
251
276
|
}, {
|
|
252
277
|
key: "createSpriteEmojiElement",
|
|
253
278
|
value: function createSpriteEmojiElement(representation) {
|
|
254
|
-
var
|
|
279
|
+
var doc = (0, _browserApis.getDocument)();
|
|
280
|
+
if (!doc) {
|
|
281
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
282
|
+
doc = document;
|
|
283
|
+
}
|
|
284
|
+
var spriteElement = doc.createElement('span');
|
|
255
285
|
spriteElement.classList.add(_emoji.EmojiSharedCssClassName.EMOJI_SPRITE);
|
|
256
286
|
var sprite = representation.sprite;
|
|
257
287
|
var xPositionInPercent = 100 / (sprite.column - 1) * representation.xIndex;
|
|
@@ -271,7 +301,12 @@ var EmojiNodeView = exports.EmojiNodeView = /*#__PURE__*/function () {
|
|
|
271
301
|
key: "createImageEmojiElement",
|
|
272
302
|
value: function createImageEmojiElement(emojiDescription, representation) {
|
|
273
303
|
var _this2 = this;
|
|
274
|
-
var
|
|
304
|
+
var doc = (0, _browserApis.getDocument)();
|
|
305
|
+
if (!doc) {
|
|
306
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
307
|
+
doc = document;
|
|
308
|
+
}
|
|
309
|
+
var imageElement = doc.createElement('img');
|
|
275
310
|
imageElement.classList.add(_emoji.EmojiSharedCssClassName.EMOJI_IMAGE);
|
|
276
311
|
imageElement.src = 'imagePath' in representation ? representation.imagePath : representation.mediaPath;
|
|
277
312
|
imageElement.loading = 'lazy';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import isEqual from 'lodash/isEqual';
|
|
3
|
+
import { getDocument } from '@atlaskit/browser-apis';
|
|
3
4
|
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
4
5
|
import { messages, EmojiSharedCssClassName, defaultEmojiHeight } from '@atlaskit/editor-common/emoji';
|
|
5
6
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
@@ -191,7 +192,12 @@ export class EmojiNodeView {
|
|
|
191
192
|
renderFallback() {
|
|
192
193
|
this.renderingFallback = true;
|
|
193
194
|
this.cleanUpAndRenderCommonAttributes();
|
|
194
|
-
|
|
195
|
+
let doc = getDocument();
|
|
196
|
+
if (!doc) {
|
|
197
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
198
|
+
doc = document;
|
|
199
|
+
}
|
|
200
|
+
const fallbackElement = doc.createElement('span');
|
|
195
201
|
fallbackElement.innerText = this.node.attrs.text || this.node.attrs.shortName;
|
|
196
202
|
fallbackElement.setAttribute('data-testid', `fallback-emoji-${this.node.attrs.shortName}`);
|
|
197
203
|
fallbackElement.setAttribute('data-emoji-type', 'fallback');
|
|
@@ -201,21 +207,43 @@ export class EmojiNodeView {
|
|
|
201
207
|
this.renderingFallback = false;
|
|
202
208
|
this.cleanUpAndRenderCommonAttributes();
|
|
203
209
|
const emojiType = 'sprite' in representation ? 'sprite' : 'image';
|
|
210
|
+
let doc = getDocument();
|
|
211
|
+
if (!doc) {
|
|
212
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
213
|
+
doc = document;
|
|
214
|
+
}
|
|
204
215
|
|
|
205
216
|
// Add wrapper for the emoji
|
|
206
|
-
const containerElement =
|
|
217
|
+
const containerElement = doc.createElement('span');
|
|
207
218
|
containerElement.setAttribute('role', 'img');
|
|
208
219
|
containerElement.setAttribute('title', description.shortName);
|
|
209
220
|
containerElement.classList.add(EmojiSharedCssClassName.EMOJI_CONTAINER);
|
|
210
221
|
containerElement.setAttribute('data-testid', `${emojiType}-emoji-${description.shortName}`);
|
|
211
222
|
containerElement.setAttribute('data-emoji-type', emojiType);
|
|
212
223
|
containerElement.setAttribute('aria-label', `${this.intl.formatMessage(messages.emojiNodeLabel)} ${description.shortName}`);
|
|
213
|
-
const emojiElement = 'sprite' in representation ? this.createSpriteEmojiElement(representation) : this.createImageEmojiElement(description, representation);
|
|
224
|
+
const emojiElement = 'unicodeEmoji' in representation ? this.createUnicodeEmojiElement(representation.unicodeEmoji) : 'sprite' in representation ? this.createSpriteEmojiElement(representation) : this.createImageEmojiElement(description, representation);
|
|
214
225
|
containerElement.appendChild(emojiElement);
|
|
215
226
|
this.dom.appendChild(containerElement);
|
|
216
227
|
}
|
|
228
|
+
createUnicodeEmojiElement(_) {
|
|
229
|
+
let doc = getDocument();
|
|
230
|
+
if (!doc) {
|
|
231
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
232
|
+
doc = document;
|
|
233
|
+
}
|
|
234
|
+
const spanElement = doc.createElement('span');
|
|
235
|
+
|
|
236
|
+
// NOTE: Implement unicode emoji element creation
|
|
237
|
+
|
|
238
|
+
return spanElement;
|
|
239
|
+
}
|
|
217
240
|
createSpriteEmojiElement(representation) {
|
|
218
|
-
|
|
241
|
+
let doc = getDocument();
|
|
242
|
+
if (!doc) {
|
|
243
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
244
|
+
doc = document;
|
|
245
|
+
}
|
|
246
|
+
const spriteElement = doc.createElement('span');
|
|
219
247
|
spriteElement.classList.add(EmojiSharedCssClassName.EMOJI_SPRITE);
|
|
220
248
|
const sprite = representation.sprite;
|
|
221
249
|
const xPositionInPercent = 100 / (sprite.column - 1) * representation.xIndex;
|
|
@@ -232,7 +260,12 @@ export class EmojiNodeView {
|
|
|
232
260
|
return spriteElement;
|
|
233
261
|
}
|
|
234
262
|
createImageEmojiElement(emojiDescription, representation) {
|
|
235
|
-
|
|
263
|
+
let doc = getDocument();
|
|
264
|
+
if (!doc) {
|
|
265
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
266
|
+
doc = document;
|
|
267
|
+
}
|
|
268
|
+
const imageElement = doc.createElement('img');
|
|
236
269
|
imageElement.classList.add(EmojiSharedCssClassName.EMOJI_IMAGE);
|
|
237
270
|
imageElement.src = 'imagePath' in representation ? representation.imagePath : representation.mediaPath;
|
|
238
271
|
imageElement.loading = 'lazy';
|
|
@@ -4,6 +4,7 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
6
|
import isEqual from 'lodash/isEqual';
|
|
7
|
+
import { getDocument } from '@atlaskit/browser-apis';
|
|
7
8
|
import { isSSR } from '@atlaskit/editor-common/core-utils';
|
|
8
9
|
import { messages, EmojiSharedCssClassName, defaultEmojiHeight } from '@atlaskit/editor-common/emoji';
|
|
9
10
|
import { logException } from '@atlaskit/editor-common/monitoring';
|
|
@@ -215,7 +216,12 @@ export var EmojiNodeView = /*#__PURE__*/function () {
|
|
|
215
216
|
value: function renderFallback() {
|
|
216
217
|
this.renderingFallback = true;
|
|
217
218
|
this.cleanUpAndRenderCommonAttributes();
|
|
218
|
-
var
|
|
219
|
+
var doc = getDocument();
|
|
220
|
+
if (!doc) {
|
|
221
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
222
|
+
doc = document;
|
|
223
|
+
}
|
|
224
|
+
var fallbackElement = doc.createElement('span');
|
|
219
225
|
fallbackElement.innerText = this.node.attrs.text || this.node.attrs.shortName;
|
|
220
226
|
fallbackElement.setAttribute('data-testid', "fallback-emoji-".concat(this.node.attrs.shortName));
|
|
221
227
|
fallbackElement.setAttribute('data-emoji-type', 'fallback');
|
|
@@ -227,23 +233,47 @@ export var EmojiNodeView = /*#__PURE__*/function () {
|
|
|
227
233
|
this.renderingFallback = false;
|
|
228
234
|
this.cleanUpAndRenderCommonAttributes();
|
|
229
235
|
var emojiType = 'sprite' in representation ? 'sprite' : 'image';
|
|
236
|
+
var doc = getDocument();
|
|
237
|
+
if (!doc) {
|
|
238
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
239
|
+
doc = document;
|
|
240
|
+
}
|
|
230
241
|
|
|
231
242
|
// Add wrapper for the emoji
|
|
232
|
-
var containerElement =
|
|
243
|
+
var containerElement = doc.createElement('span');
|
|
233
244
|
containerElement.setAttribute('role', 'img');
|
|
234
245
|
containerElement.setAttribute('title', description.shortName);
|
|
235
246
|
containerElement.classList.add(EmojiSharedCssClassName.EMOJI_CONTAINER);
|
|
236
247
|
containerElement.setAttribute('data-testid', "".concat(emojiType, "-emoji-").concat(description.shortName));
|
|
237
248
|
containerElement.setAttribute('data-emoji-type', emojiType);
|
|
238
249
|
containerElement.setAttribute('aria-label', "".concat(this.intl.formatMessage(messages.emojiNodeLabel), " ").concat(description.shortName));
|
|
239
|
-
var emojiElement = 'sprite' in representation ? this.createSpriteEmojiElement(representation) : this.createImageEmojiElement(description, representation);
|
|
250
|
+
var emojiElement = 'unicodeEmoji' in representation ? this.createUnicodeEmojiElement(representation.unicodeEmoji) : 'sprite' in representation ? this.createSpriteEmojiElement(representation) : this.createImageEmojiElement(description, representation);
|
|
240
251
|
containerElement.appendChild(emojiElement);
|
|
241
252
|
this.dom.appendChild(containerElement);
|
|
242
253
|
}
|
|
254
|
+
}, {
|
|
255
|
+
key: "createUnicodeEmojiElement",
|
|
256
|
+
value: function createUnicodeEmojiElement(_) {
|
|
257
|
+
var doc = getDocument();
|
|
258
|
+
if (!doc) {
|
|
259
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
260
|
+
doc = document;
|
|
261
|
+
}
|
|
262
|
+
var spanElement = doc.createElement('span');
|
|
263
|
+
|
|
264
|
+
// NOTE: Implement unicode emoji element creation
|
|
265
|
+
|
|
266
|
+
return spanElement;
|
|
267
|
+
}
|
|
243
268
|
}, {
|
|
244
269
|
key: "createSpriteEmojiElement",
|
|
245
270
|
value: function createSpriteEmojiElement(representation) {
|
|
246
|
-
var
|
|
271
|
+
var doc = getDocument();
|
|
272
|
+
if (!doc) {
|
|
273
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
274
|
+
doc = document;
|
|
275
|
+
}
|
|
276
|
+
var spriteElement = doc.createElement('span');
|
|
247
277
|
spriteElement.classList.add(EmojiSharedCssClassName.EMOJI_SPRITE);
|
|
248
278
|
var sprite = representation.sprite;
|
|
249
279
|
var xPositionInPercent = 100 / (sprite.column - 1) * representation.xIndex;
|
|
@@ -263,7 +293,12 @@ export var EmojiNodeView = /*#__PURE__*/function () {
|
|
|
263
293
|
key: "createImageEmojiElement",
|
|
264
294
|
value: function createImageEmojiElement(emojiDescription, representation) {
|
|
265
295
|
var _this2 = this;
|
|
266
|
-
var
|
|
296
|
+
var doc = getDocument();
|
|
297
|
+
if (!doc) {
|
|
298
|
+
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
299
|
+
doc = document;
|
|
300
|
+
}
|
|
301
|
+
var imageElement = doc.createElement('img');
|
|
267
302
|
imageElement.classList.add(EmojiSharedCssClassName.EMOJI_IMAGE);
|
|
268
303
|
imageElement.src = 'imagePath' in representation ? representation.imagePath : representation.mediaPath;
|
|
269
304
|
imageElement.loading = 'lazy';
|
|
@@ -50,6 +50,7 @@ export declare class EmojiNodeView implements NodeView {
|
|
|
50
50
|
private cleanUpAndRenderCommonAttributes;
|
|
51
51
|
private renderFallback;
|
|
52
52
|
private renderEmoji;
|
|
53
|
+
private createUnicodeEmojiElement;
|
|
53
54
|
private createSpriteEmojiElement;
|
|
54
55
|
private createImageEmojiElement;
|
|
55
56
|
}
|
|
@@ -50,6 +50,7 @@ export declare class EmojiNodeView implements NodeView {
|
|
|
50
50
|
private cleanUpAndRenderCommonAttributes;
|
|
51
51
|
private renderFallback;
|
|
52
52
|
private renderEmoji;
|
|
53
|
+
private createUnicodeEmojiElement;
|
|
53
54
|
private createSpriteEmojiElement;
|
|
54
55
|
private createImageEmojiElement;
|
|
55
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-emoji",
|
|
3
|
-
"version": "11.1.
|
|
3
|
+
"version": "11.1.2",
|
|
4
4
|
"description": "Emoji plugin for @atlaskit/editor-core",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@atlaskit/adf-schema": "^52.11.0",
|
|
25
|
+
"@atlaskit/browser-apis": "^0.0.1",
|
|
25
26
|
"@atlaskit/editor-plugin-analytics": "^10.1.0",
|
|
26
27
|
"@atlaskit/editor-plugin-annotation": "^10.4.0",
|
|
27
28
|
"@atlaskit/editor-plugin-base": "^11.1.0",
|
|
@@ -31,12 +32,12 @@
|
|
|
31
32
|
"@atlaskit/editor-plugin-type-ahead": "^10.1.0",
|
|
32
33
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
33
34
|
"@atlaskit/editor-shared-styles": "^3.11.0",
|
|
34
|
-
"@atlaskit/emoji": "^70.
|
|
35
|
-
"@atlaskit/icon": "^
|
|
35
|
+
"@atlaskit/emoji": "^70.9.0",
|
|
36
|
+
"@atlaskit/icon": "^35.0.0",
|
|
36
37
|
"@atlaskit/node-data-provider": "^11.1.0",
|
|
37
38
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
38
39
|
"@atlaskit/prosemirror-input-rules": "^3.7.0",
|
|
39
|
-
"@atlaskit/tmp-editor-statsig": "^81.
|
|
40
|
+
"@atlaskit/tmp-editor-statsig": "^81.1.0",
|
|
40
41
|
"@atlaskit/tokens": "^13.0.0",
|
|
41
42
|
"@babel/runtime": "^7.0.0",
|
|
42
43
|
"@emotion/react": "^11.7.1",
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
"react-loadable": "^5.1.0"
|
|
45
46
|
},
|
|
46
47
|
"peerDependencies": {
|
|
47
|
-
"@atlaskit/editor-common": "^114.
|
|
48
|
+
"@atlaskit/editor-common": "^114.35.0",
|
|
48
49
|
"react": "^18.2.0",
|
|
49
50
|
"react-dom": "^18.2.0",
|
|
50
51
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|