@atlaskit/editor-core 187.19.1 → 187.20.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/plugins/emoji/commands/insert-emoji.js +21 -20
  3. package/dist/cjs/plugins/emoji/index.js +16 -5
  4. package/dist/cjs/plugins/index.js +2 -2
  5. package/dist/cjs/plugins/insert-block/index.js +3 -7
  6. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
  7. package/dist/cjs/plugins/media/pm-plugins/main.js +13 -1
  8. package/dist/cjs/plugins/media/toolbar/index.js +21 -8
  9. package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +15 -3
  10. package/dist/cjs/plugins/text-color/commands/toggle-color.js +3 -2
  11. package/dist/cjs/utils/document.js +6 -24
  12. package/dist/cjs/utils/index.js +33 -105
  13. package/dist/cjs/utils/prosemirror/position.js +33 -41
  14. package/dist/cjs/version-wrapper.js +1 -1
  15. package/dist/cjs/version.json +1 -1
  16. package/dist/es2019/plugins/emoji/commands/insert-emoji.js +24 -20
  17. package/dist/es2019/plugins/emoji/index.js +14 -4
  18. package/dist/es2019/plugins/index.js +1 -1
  19. package/dist/es2019/plugins/insert-block/index.js +3 -7
  20. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +6 -3
  21. package/dist/es2019/plugins/media/pm-plugins/main.js +9 -0
  22. package/dist/es2019/plugins/media/toolbar/index.js +22 -10
  23. package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +17 -4
  24. package/dist/es2019/plugins/text-color/commands/toggle-color.js +3 -2
  25. package/dist/es2019/utils/document.js +1 -20
  26. package/dist/es2019/utils/index.js +1 -99
  27. package/dist/es2019/utils/prosemirror/position.js +1 -51
  28. package/dist/es2019/version-wrapper.js +1 -1
  29. package/dist/es2019/version.json +1 -1
  30. package/dist/esm/plugins/emoji/commands/insert-emoji.js +21 -20
  31. package/dist/esm/plugins/emoji/index.js +14 -4
  32. package/dist/esm/plugins/index.js +1 -1
  33. package/dist/esm/plugins/insert-block/index.js +3 -7
  34. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
  35. package/dist/esm/plugins/media/pm-plugins/main.js +11 -0
  36. package/dist/esm/plugins/media/toolbar/index.js +23 -10
  37. package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +16 -4
  38. package/dist/esm/plugins/text-color/commands/toggle-color.js +3 -2
  39. package/dist/esm/utils/document.js +1 -22
  40. package/dist/esm/utils/index.js +1 -97
  41. package/dist/esm/utils/prosemirror/position.js +1 -39
  42. package/dist/esm/version-wrapper.js +1 -1
  43. package/dist/esm/version.json +1 -1
  44. package/dist/types/labs/next/presets/default.d.ts +32 -32
  45. package/dist/types/plugins/emoji/commands/insert-emoji.d.ts +2 -2
  46. package/dist/types/plugins/emoji/index.d.ts +9 -4
  47. package/dist/types/plugins/index.d.ts +1 -1
  48. package/dist/types/plugins/insert-block/index.d.ts +3 -1
  49. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -1
  50. package/dist/types/plugins/media/pm-plugins/main.d.ts +3 -0
  51. package/dist/types/plugins/media/pm-plugins/types.d.ts +2 -0
  52. package/dist/types/plugins/media/toolbar/index.d.ts +1 -2
  53. package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -0
  54. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  55. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  56. package/dist/types/utils/document.d.ts +2 -7
  57. package/dist/types/utils/index.d.ts +2 -6
  58. package/dist/types/utils/prosemirror/position.d.ts +1 -8
  59. package/dist/types-ts4.5/labs/next/presets/default.d.ts +32 -32
  60. package/dist/types-ts4.5/plugins/emoji/commands/insert-emoji.d.ts +2 -2
  61. package/dist/types-ts4.5/plugins/emoji/index.d.ts +9 -4
  62. package/dist/types-ts4.5/plugins/index.d.ts +1 -1
  63. package/dist/types-ts4.5/plugins/insert-block/index.d.ts +3 -1
  64. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -1
  65. package/dist/types-ts4.5/plugins/media/pm-plugins/main.d.ts +3 -0
  66. package/dist/types-ts4.5/plugins/media/pm-plugins/types.d.ts +2 -0
  67. package/dist/types-ts4.5/plugins/media/toolbar/index.d.ts +1 -2
  68. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -0
  69. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  70. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  71. package/dist/types-ts4.5/utils/document.d.ts +2 -7
  72. package/dist/types-ts4.5/utils/index.d.ts +2 -6
  73. package/dist/types-ts4.5/utils/prosemirror/position.d.ts +1 -8
  74. package/package.json +4 -4
  75. package/report.api.md +4 -0
  76. package/tmp/api-report-tmp.d.ts +4 -0
@@ -10,7 +10,12 @@ Object.defineProperty(exports, "SetAttrsStep", {
10
10
  return _steps.SetAttrsStep;
11
11
  }
12
12
  });
13
- exports.checkNodeDown = checkNodeDown;
13
+ Object.defineProperty(exports, "checkNodeDown", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _utils2.checkNodeDown;
17
+ }
18
+ });
14
19
  exports.compose = compose;
15
20
  exports.dedupe = dedupe;
16
21
  Object.defineProperty(exports, "findFarthestParentNode", {
@@ -33,14 +38,31 @@ Object.defineProperty(exports, "insideTable", {
33
38
  return _coreUtils.insideTable;
34
39
  }
35
40
  });
36
- exports.insideTableCell = void 0;
41
+ Object.defineProperty(exports, "insideTableCell", {
42
+ enumerable: true,
43
+ get: function get() {
44
+ return _utils2.insideTableCell;
45
+ }
46
+ });
37
47
  Object.defineProperty(exports, "isElementInTableCell", {
38
48
  enumerable: true,
39
49
  get: function get() {
40
50
  return _utils2.isElementInTableCell;
41
51
  }
42
52
  });
43
- exports.isInsideBlockQuote = exports.isInListItem = exports.isEmptyNode = void 0;
53
+ Object.defineProperty(exports, "isEmptyNode", {
54
+ enumerable: true,
55
+ get: function get() {
56
+ return _utils2.isEmptyNode;
57
+ }
58
+ });
59
+ Object.defineProperty(exports, "isInListItem", {
60
+ enumerable: true,
61
+ get: function get() {
62
+ return _utils2.isInListItem;
63
+ }
64
+ });
65
+ exports.isInsideBlockQuote = void 0;
44
66
  Object.defineProperty(exports, "isLastItemMediaGroup", {
45
67
  enumerable: true,
46
68
  get: function get() {
@@ -72,7 +94,12 @@ Object.defineProperty(exports, "isSelectionEndOfParagraph", {
72
94
  return _document.isSelectionEndOfParagraph;
73
95
  }
74
96
  });
75
- exports.isSelectionInsideLastNodeInDocument = isSelectionInsideLastNodeInDocument;
97
+ Object.defineProperty(exports, "isSelectionInsideLastNodeInDocument", {
98
+ enumerable: true,
99
+ get: function get() {
100
+ return _utils2.isSelectionInsideLastNodeInDocument;
101
+ }
102
+ });
76
103
  exports.isTemporary = void 0;
77
104
  Object.defineProperty(exports, "isText", {
78
105
  enumerable: true,
@@ -138,13 +165,13 @@ var _commands = require("@atlaskit/editor-prosemirror/commands");
138
165
  var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
139
166
  var _cursor = require("../plugins/fake-text-cursor/cursor");
140
167
  var _utils = require("@atlaskit/editor-prosemirror/utils");
141
- var _document = require("./document");
168
+ var _utils2 = require("@atlaskit/editor-common/utils");
142
169
  var _coreUtils = require("@atlaskit/editor-common/core-utils");
170
+ var _document = require("./document");
143
171
  var _mark = require("./mark");
144
172
  var _nodes = require("./nodes");
145
173
  var _selection = require("./selection");
146
174
  var _measureEnum = _interopRequireDefault(require("./performance/measure-enum"));
147
- var _utils2 = require("@atlaskit/editor-common/utils");
148
175
  var _steps = require("@atlaskit/adf-schema/steps");
149
176
  function isMarkTypeCompatibleWithMark(markType, mark) {
150
177
  return !mark.type.excludes(markType) && !markType.excludes(mark.type);
@@ -152,11 +179,6 @@ function isMarkTypeCompatibleWithMark(markType, mark) {
152
179
  function isMarkTypeAllowedInNode(markType, state) {
153
180
  return (0, _commands.toggleMark)(markType)(state);
154
181
  }
155
- function isSelectionInsideLastNodeInDocument(selection) {
156
- var docNode = selection.$anchor.node(0);
157
- var rootNode = selection.$anchor.node(1);
158
- return docNode.lastChild === rootNode;
159
- }
160
182
  function getCursor(selection) {
161
183
  return selection.$cursor || undefined;
162
184
  }
@@ -204,36 +226,6 @@ function isMarkTypeAllowedInCurrentSelection(markType, state) {
204
226
  return allowedInActiveMarks;
205
227
  });
206
228
  }
207
- function checkNodeDown(selection, doc, filter) {
208
- var ancestorDepth = findAncestorPosition(doc, selection.$to).depth;
209
-
210
- // Top level node
211
- if (ancestorDepth === 0) {
212
- return false;
213
- }
214
- var res = doc.resolve(selection.$to.after(ancestorDepth));
215
- return res.nodeAfter ? filter(res.nodeAfter) : false;
216
- }
217
-
218
- /**
219
- * Traverse the document until an "ancestor" is found. Any nestable block can be an ancestor.
220
- */
221
- function findAncestorPosition(doc, pos) {
222
- var nestableBlocks = ['blockquote', 'bulletList', 'orderedList'];
223
- if (pos.depth === 1) {
224
- return pos;
225
- }
226
- var node = pos.node(pos.depth);
227
- var newPos = pos;
228
- while (pos.depth >= 1) {
229
- pos = doc.resolve(pos.before(pos.depth));
230
- node = pos.node(pos.depth);
231
- if (node && nestableBlocks.indexOf(node.type.name) !== -1) {
232
- newPos = pos;
233
- }
234
- }
235
- return newPos;
236
- }
237
229
  var transformer = new _editorJsonTransformer.JSONTransformer();
238
230
  function toJSON(node) {
239
231
  return transformer.encode(node);
@@ -280,70 +272,6 @@ var isTemporary = function isTemporary(id) {
280
272
  return id.indexOf('temporary:') === 0;
281
273
  };
282
274
  exports.isTemporary = isTemporary;
283
- var isEmptyNode = function isEmptyNode(schema) {
284
- var _schema$nodes = schema.nodes,
285
- doc = _schema$nodes.doc,
286
- paragraph = _schema$nodes.paragraph,
287
- codeBlock = _schema$nodes.codeBlock,
288
- blockquote = _schema$nodes.blockquote,
289
- panel = _schema$nodes.panel,
290
- heading = _schema$nodes.heading,
291
- listItem = _schema$nodes.listItem,
292
- bulletList = _schema$nodes.bulletList,
293
- orderedList = _schema$nodes.orderedList,
294
- taskList = _schema$nodes.taskList,
295
- taskItem = _schema$nodes.taskItem,
296
- decisionList = _schema$nodes.decisionList,
297
- decisionItem = _schema$nodes.decisionItem,
298
- media = _schema$nodes.media,
299
- mediaGroup = _schema$nodes.mediaGroup,
300
- mediaSingle = _schema$nodes.mediaSingle;
301
- var innerIsEmptyNode = function innerIsEmptyNode(node) {
302
- switch (node.type) {
303
- case media:
304
- case mediaGroup:
305
- case mediaSingle:
306
- return false;
307
- case paragraph:
308
- case codeBlock:
309
- case heading:
310
- case taskItem:
311
- case decisionItem:
312
- return node.content.size === 0;
313
- case blockquote:
314
- case panel:
315
- case listItem:
316
- return node.content.size === 2 && innerIsEmptyNode(node.content.firstChild);
317
- case bulletList:
318
- case orderedList:
319
- return node.content.size === 4 && innerIsEmptyNode(node.content.firstChild);
320
- case taskList:
321
- case decisionList:
322
- return node.content.size === 2 && innerIsEmptyNode(node.content.firstChild);
323
- case doc:
324
- var isEmpty = true;
325
- node.content.forEach(function (child) {
326
- isEmpty = isEmpty && innerIsEmptyNode(child);
327
- });
328
- return isEmpty;
329
- default:
330
- return (0, _document.isNodeEmpty)(node);
331
- }
332
- };
333
- return innerIsEmptyNode;
334
- };
335
- exports.isEmptyNode = isEmptyNode;
336
- var insideTableCell = function insideTableCell(state) {
337
- var _state$schema$nodes = state.schema.nodes,
338
- tableCell = _state$schema$nodes.tableCell,
339
- tableHeader = _state$schema$nodes.tableHeader;
340
- return (0, _utils.hasParentNodeOfType)([tableCell, tableHeader])(state.selection);
341
- };
342
- exports.insideTableCell = insideTableCell;
343
- var isInListItem = function isInListItem(state) {
344
- return (0, _utils.hasParentNodeOfType)(state.schema.nodes.listItem)(state.selection);
345
- };
346
- exports.isInListItem = isInListItem;
347
275
  var hasOpenEnd = function hasOpenEnd(slice) {
348
276
  return slice.openStart > 0 || slice.openEnd > 0;
349
277
  };
@@ -3,48 +3,40 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.atTheBeginningOfBlock = atTheBeginningOfBlock;
7
- exports.atTheBeginningOfDoc = atTheBeginningOfDoc;
8
- exports.atTheEndOfBlock = atTheEndOfBlock;
9
- exports.atTheEndOfDoc = atTheEndOfDoc;
10
- exports.endPositionOfParent = endPositionOfParent;
11
- exports.startPositionOfParent = startPositionOfParent;
12
- var _state = require("@atlaskit/editor-prosemirror/state");
13
- var _selection = require("../../plugins/selection/gap-cursor/selection");
14
- function atTheEndOfDoc(state) {
15
- var selection = state.selection,
16
- doc = state.doc;
17
- return doc.nodeSize - selection.$to.pos - 2 === selection.$to.depth;
18
- }
19
- function atTheBeginningOfDoc(state) {
20
- var selection = state.selection;
21
- return selection.$from.pos === selection.$from.depth;
22
- }
23
- function atTheEndOfBlock(state) {
24
- var selection = state.selection;
25
- var $to = selection.$to;
26
- if (selection instanceof _selection.GapCursorSelection) {
27
- return false;
6
+ Object.defineProperty(exports, "atTheBeginningOfBlock", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _selection.atTheBeginningOfBlock;
28
10
  }
29
- if (selection instanceof _state.NodeSelection && selection.node.isBlock) {
30
- return true;
11
+ });
12
+ Object.defineProperty(exports, "atTheBeginningOfDoc", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _selection.atTheBeginningOfDoc;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "atTheEndOfBlock", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _selection.atTheEndOfBlock;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "atTheEndOfDoc", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _selection.atTheEndOfDoc;
31
28
  }
32
- return endPositionOfParent($to) === $to.pos + 1;
33
- }
34
- function atTheBeginningOfBlock(state) {
35
- var selection = state.selection;
36
- var $from = selection.$from;
37
- if (selection instanceof _selection.GapCursorSelection) {
38
- return false;
29
+ });
30
+ Object.defineProperty(exports, "endPositionOfParent", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _selection.endPositionOfParent;
39
34
  }
40
- if (selection instanceof _state.NodeSelection && selection.node.isBlock) {
41
- return true;
35
+ });
36
+ Object.defineProperty(exports, "startPositionOfParent", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _selection.startPositionOfParent;
42
40
  }
43
- return startPositionOfParent($from) === $from.pos;
44
- }
45
- function startPositionOfParent(resolvedPos) {
46
- return resolvedPos.start(resolvedPos.depth);
47
- }
48
- function endPositionOfParent(resolvedPos) {
49
- return resolvedPos.end(resolvedPos.depth) + 1;
50
- }
41
+ });
42
+ var _selection = require("@atlaskit/editor-common/selection");
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "187.19.1";
9
+ var version = "187.20.0";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.19.1",
3
+ "version": "187.20.0",
4
4
  "sideEffects": false
5
5
  }
@@ -3,34 +3,38 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
3
  import { Selection } from '@atlaskit/editor-prosemirror/state';
4
4
  import { EVENT_TYPE, ACTION_SUBJECT_ID, ACTION_SUBJECT, ACTION } from '@atlaskit/editor-common/analytics';
5
5
  export const insertEmoji = editorAnalyticsAPI => (emojiId, inputMethod) => {
6
- return (state, dispatch) => {
6
+ return ({
7
+ tr
8
+ }) => {
9
+ const {
10
+ doc,
11
+ selection
12
+ } = tr;
7
13
  const {
8
14
  emoji
9
- } = state.schema.nodes;
15
+ } = tr.doc.type.schema.nodes;
10
16
  if (emoji && emojiId) {
11
17
  const node = emoji.createChecked({
12
18
  ...emojiId,
13
19
  text: emojiId.fallback || emojiId.shortName
14
20
  });
15
- const textNode = state.schema.text(' ');
16
- if (dispatch) {
17
- const fragment = Fragment.fromArray([node, textNode]);
18
- const tr = safeInsert(fragment)(state.tr);
19
- if (inputMethod) {
20
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
21
- action: ACTION.INSERTED,
22
- actionSubject: ACTION_SUBJECT.DOCUMENT,
23
- actionSubjectId: ACTION_SUBJECT_ID.EMOJI,
24
- attributes: {
25
- inputMethod
26
- },
27
- eventType: EVENT_TYPE.TRACK
28
- })(tr);
29
- }
30
- dispatch(tr.setSelection(Selection.near(tr.doc.resolve(state.selection.$from.pos + fragment.size))));
21
+ const textNode = doc.type.schema.text(' ');
22
+ const fragment = Fragment.fromArray([node, textNode]);
23
+ const newTr = safeInsert(fragment)(tr);
24
+ if (inputMethod) {
25
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
26
+ action: ACTION.INSERTED,
27
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
28
+ actionSubjectId: ACTION_SUBJECT_ID.EMOJI,
29
+ attributes: {
30
+ inputMethod
31
+ },
32
+ eventType: EVENT_TYPE.TRACK
33
+ })(newTr);
31
34
  }
32
- return true;
35
+ newTr.setSelection(Selection.near(newTr.doc.resolve(selection.$from.pos + fragment.size)));
36
+ return newTr;
33
37
  }
34
- return false;
38
+ return null;
35
39
  };
36
40
  };
@@ -12,6 +12,7 @@ import { IconEmoji } from '@atlaskit/editor-common/quick-insert';
12
12
  import { EmojiNodeView } from './nodeviews/emoji';
13
13
  import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
14
14
  import { openTypeAheadAtCursor } from '../type-ahead/transforms/open-typeahead-at-cursor';
15
+ import { insertEmoji } from './commands/insert-emoji';
15
16
  export const emojiToTypeaheadItem = (emoji, emojiProvider) => ({
16
17
  title: emoji.shortName || '',
17
18
  key: emoji.id || emoji.shortName,
@@ -54,7 +55,8 @@ const memoizedToItem = memoize(emojiToTypeaheadItem);
54
55
  export const defaultListLimit = 50;
55
56
  const isFullShortName = query => query && query.length > 1 && query.charAt(0) === ':' && query.charAt(query.length - 1) === ':';
56
57
  const TRIGGER = ':';
57
- const emojiPlugin = (options, api) => {
58
+ export const emojiPlugin = (options, api) => {
59
+ var _api$dependencies$ana9;
58
60
  const typeAhead = {
59
61
  id: TypeAheadAvailableNodes.EMOJI,
60
62
  trigger: TRIGGER,
@@ -175,6 +177,15 @@ const emojiPlugin = (options, api) => {
175
177
  }
176
178
  }];
177
179
  },
180
+ getSharedState(editorState) {
181
+ if (!editorState) {
182
+ return undefined;
183
+ }
184
+ return emojiPluginKey.getState(editorState);
185
+ },
186
+ commands: {
187
+ insertEmoji: insertEmoji(api === null || api === void 0 ? void 0 : (_api$dependencies$ana9 = api.dependencies.analytics) === null || _api$dependencies$ana9 === void 0 ? void 0 : _api$dependencies$ana9.actions)
188
+ },
178
189
  pluginsOptions: {
179
190
  quickInsert: ({
180
191
  formatMessage
@@ -186,13 +197,13 @@ const emojiPlugin = (options, api) => {
186
197
  keyshortcut: ':',
187
198
  icon: () => /*#__PURE__*/React.createElement(IconEmoji, null),
188
199
  action(insert, state) {
189
- var _api$dependencies$ana9;
200
+ var _api$dependencies$ana10;
190
201
  const tr = insert(undefined);
191
202
  openTypeAheadAtCursor({
192
203
  triggerHandler: typeAhead,
193
204
  inputMethod: INPUT_METHOD.QUICK_INSERT
194
205
  })(tr);
195
- api === null || api === void 0 ? void 0 : (_api$dependencies$ana9 = api.dependencies.analytics) === null || _api$dependencies$ana9 === void 0 ? void 0 : _api$dependencies$ana9.actions.attachAnalyticsEvent({
206
+ api === null || api === void 0 ? void 0 : (_api$dependencies$ana10 = api.dependencies.analytics) === null || _api$dependencies$ana10 === void 0 ? void 0 : _api$dependencies$ana10.actions.attachAnalyticsEvent({
196
207
  action: ACTION.INVOKED,
197
208
  actionSubject: ACTION_SUBJECT.TYPEAHEAD,
198
209
  actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_EMOJI,
@@ -208,7 +219,6 @@ const emojiPlugin = (options, api) => {
208
219
  }
209
220
  };
210
221
  };
211
- export default emojiPlugin;
212
222
 
213
223
  /**
214
224
  * Actions
@@ -6,7 +6,7 @@ export { default as clearMarksOnChangeToEmptyDocumentPlugin } from './clear-mark
6
6
  export { default as codeBlockPlugin } from './code-block';
7
7
  export { default as collabEditPlugin } from './collab-edit';
8
8
  export { default as datePlugin } from './date';
9
- export { default as emojiPlugin } from './emoji';
9
+ export { emojiPlugin } from './emoji';
10
10
  export { default as extensionPlugin } from './extension';
11
11
  export { default as fakeTextCursorPlugin } from './fake-text-cursor';
12
12
  export { default as helpDialogPlugin } from './help-dialog';
@@ -5,7 +5,6 @@ import { stateKey as mediaStateKey } from '../media/pm-plugins/plugin-key';
5
5
  import { isTypeAheadAllowed } from '../type-ahead/utils';
6
6
  import { pluginKey as layoutStateKey } from '../layout';
7
7
  import { insertMacroFromMacroBrowser } from '../macro';
8
- import { emojiPluginKey } from '../emoji';
9
8
  import WithPluginState from '../../ui/WithPluginState';
10
9
  import ToolbarInsertBlock from './ui/ToolbarInsertBlock';
11
10
  import { pluginKey as typeAheadPluginKey } from '../type-ahead/pm-plugins/key';
@@ -62,7 +61,6 @@ const insertBlockPlugin = (options = {}, api) => {
62
61
  blockTypeState: blockTypeStateKey,
63
62
  mediaState: mediaStateKey,
64
63
  macroState: macroStateKey,
65
- emojiState: emojiPluginKey,
66
64
  placeholderTextState: placeholderTextStateKey,
67
65
  layoutState: layoutStateKey
68
66
  },
@@ -70,7 +68,6 @@ const insertBlockPlugin = (options = {}, api) => {
70
68
  blockTypeState,
71
69
  mediaState,
72
70
  macroState = {},
73
- emojiState,
74
71
  placeholderTextState,
75
72
  layoutState
76
73
  }) => /*#__PURE__*/React.createElement(ToolbarInsertBlockWithInjectionApi, {
@@ -90,7 +87,6 @@ const insertBlockPlugin = (options = {}, api) => {
90
87
  blockTypeState: blockTypeState,
91
88
  mediaState: mediaState,
92
89
  macroState: macroState,
93
- emojiState: emojiState,
94
90
  placeholderTextState: placeholderTextState,
95
91
  layoutState: layoutState,
96
92
  providers: providers,
@@ -124,7 +120,6 @@ function ToolbarInsertBlockWithInjectionApi({
124
120
  blockTypeState,
125
121
  mediaState,
126
122
  macroState,
127
- emojiState,
128
123
  placeholderTextState,
129
124
  layoutState,
130
125
  featureFlags
@@ -135,8 +130,9 @@ function ToolbarInsertBlockWithInjectionApi({
135
130
  dateState,
136
131
  hyperlinkState,
137
132
  imageUploadState,
138
- mentionState
139
- } = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention']);
133
+ mentionState,
134
+ emojiState
135
+ } = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji']);
140
136
  return /*#__PURE__*/React.createElement(ToolbarInsertBlock, {
141
137
  pluginInjectionApi: pluginInjectionApi,
142
138
  buttons: buttons,
@@ -16,8 +16,7 @@ import { insertTaskDecisionCommand } from '../../../tasks-and-decisions/commands
16
16
  import { insertExpand } from '../../../expand/commands';
17
17
  import { createTypeAheadTools } from '../../../type-ahead/api';
18
18
  import { updateStatusWithAnalytics } from '../../../status/actions';
19
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '../../../analytics';
20
- import { insertEmoji } from '../../../emoji/commands/insert-emoji';
19
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
21
20
  import { messages } from './messages';
22
21
  import { createItems } from './create-items';
23
22
  import { BlockInsertMenu } from './block-insert-menu';
@@ -283,8 +282,12 @@ export class ToolbarInsertBlock extends React.PureComponent {
283
282
  return true;
284
283
  });
285
284
  _defineProperty(this, "handleSelectedEmoji", emojiId => {
285
+ var _pluginInjectionApi$d8;
286
+ const {
287
+ pluginInjectionApi
288
+ } = this.props;
286
289
  this.props.editorView.focus();
287
- insertEmoji(this.editorAnalyticsAPI)(emojiId, INPUT_METHOD.PICKER)(this.props.editorView.state, this.props.editorView.dispatch);
290
+ pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.executeCommand((_pluginInjectionApi$d8 = pluginInjectionApi.dependencies.emoji) === null || _pluginInjectionApi$d8 === void 0 ? void 0 : _pluginInjectionApi$d8.commands.insertEmoji(emojiId, INPUT_METHOD.PICKER));
288
291
  this.toggleEmojiPicker();
289
292
  return true;
290
293
  });
@@ -27,6 +27,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
27
27
  export { stateKey } from './plugin-key';
28
28
  export const MEDIA_CONTENT_WRAP_CLASS_NAME = 'media-content-wrap';
29
29
  export const MEDIA_PLUGIN_IS_RESIZING_KEY = 'mediaSinglePlugin.isResizing';
30
+ export const MEDIA_PLUGIN_RESIZING_WIDTH_KEY = 'mediaSinglePlugin.resizing-width';
30
31
  const createDropPlaceholder = (intl, allowDropLine) => {
31
32
  const dropPlaceholder = document.createElement('div');
32
33
  const createElement = React.createElement;
@@ -55,6 +56,7 @@ export class MediaPluginStateImplementation {
55
56
  _defineProperty(this, "layout", 'center');
56
57
  _defineProperty(this, "mediaNodes", []);
57
58
  _defineProperty(this, "isResizing", false);
59
+ _defineProperty(this, "resizingWidth", 0);
58
60
  _defineProperty(this, "destroyed", false);
59
61
  _defineProperty(this, "removeOnCloseListener", () => {});
60
62
  _defineProperty(this, "onPopupToggleCallback", () => {});
@@ -428,6 +430,9 @@ export class MediaPluginStateImplementation {
428
430
  setIsResizing(isResizing) {
429
431
  this.isResizing = isResizing;
430
432
  }
433
+ setResizingWidth(width) {
434
+ this.resizingWidth = width;
435
+ }
431
436
  updateElement() {
432
437
  let newElement;
433
438
  const selectedContainer = this.selectedMediaContainerNode();
@@ -530,9 +535,13 @@ export const createPlugin = (_schema, options, reactContext, getIntl, dispatch,
530
535
  },
531
536
  apply(tr, pluginState) {
532
537
  const isResizing = tr.getMeta(MEDIA_PLUGIN_IS_RESIZING_KEY);
538
+ const resizingWidth = tr.getMeta(MEDIA_PLUGIN_RESIZING_WIDTH_KEY);
533
539
  if (isResizing !== undefined) {
534
540
  pluginState.setIsResizing(isResizing);
535
541
  }
542
+ if (resizingWidth) {
543
+ pluginState.setResizingWidth(resizingWidth);
544
+ }
536
545
 
537
546
  // remap editing media single position if we're in collab
538
547
  if (typeof pluginState.editingMediaSinglePos === 'number') {
@@ -25,8 +25,8 @@ import ImageBorderItem from '../ui/ImageBorder';
25
25
  import { currentMediaNodeBorderMark } from '../utils/current-media-node';
26
26
  import { shouldShowImageBorder } from './imageBorder';
27
27
  import { PixelEntry } from '../ui/PixelEntry';
28
- import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
29
- import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
28
+ import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_GUTTER_SIZE, calcMediaSinglePixelWidth } from '@atlaskit/editor-common/media-single';
29
+ import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
30
30
  const remove = (state, dispatch) => {
31
31
  if (dispatch) {
32
32
  dispatch(removeSelectedNode(state.tr));
@@ -266,6 +266,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
266
266
  type: 'custom',
267
267
  fallback: [],
268
268
  render: editorView => {
269
+ var _widthPlugin$sharedSt2, _widthPlugin$sharedSt3;
269
270
  if (!editorView) {
270
271
  return null;
271
272
  }
@@ -274,6 +275,8 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
274
275
  dispatch
275
276
  } = editorView;
276
277
  const selectedMediaSingleNode = getSelectedMediaSingle(state);
278
+ const contentWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength) || akEditorDefaultLayoutWidth;
279
+ const containerWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.width) || akEditorFullWidthLayoutWidth;
277
280
  if (!selectedMediaSingleNode) {
278
281
  return null;
279
282
  }
@@ -282,15 +285,26 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
282
285
  return null;
283
286
  }
284
287
  const {
285
- width: singleMediaWidth
288
+ width: singleMediaWidth,
289
+ widthType,
290
+ layout
286
291
  } = selectedMediaSingleNode.node.attrs;
287
292
  const {
288
293
  width: mediaWidth,
289
294
  height: mediaHeight
290
295
  } = selectedMediaNode.attrs;
296
+ const pixelWidth = calcMediaSinglePixelWidth({
297
+ width: singleMediaWidth,
298
+ widthType,
299
+ origWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
300
+ layout,
301
+ contentWidth,
302
+ containerWidth,
303
+ gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
304
+ });
291
305
  return /*#__PURE__*/React.createElement(PixelEntry, {
292
306
  intl: intl,
293
- width: singleMediaWidth,
307
+ width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
294
308
  mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
295
309
  mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
296
310
  validate: value => {
@@ -312,11 +326,9 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
312
326
  });
313
327
  }
314
328
  });
315
- if (!pluginState.isResizing) {
316
- toolbarButtons.push({
317
- type: 'separator'
318
- });
319
- }
329
+ toolbarButtons.push({
330
+ type: 'separator'
331
+ });
320
332
  }
321
333
  if (allowLinking && shouldShowMediaLinkToolbar(state)) {
322
334
  toolbarButtons.push({
@@ -423,7 +435,7 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
423
435
  const {
424
436
  hoverDecoration
425
437
  } = (_pluginInjectionApi$d9 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d9 !== void 0 ? _pluginInjectionApi$d9 : {};
426
- if (!mediaPluginState || mediaPluginState.isResizing) {
438
+ if (!mediaPluginState) {
427
439
  return;
428
440
  }
429
441
  const nodeType = allowMediaInline ? [mediaInline, mediaSingle, media] : [mediaSingle];