@atlaskit/editor-core 187.19.0 → 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 (128) hide show
  1. package/CHANGELOG.md +20 -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/index.js +4 -3
  8. package/dist/cjs/plugins/media/pm-plugins/alt-text/commands.js +10 -7
  9. package/dist/cjs/plugins/media/pm-plugins/alt-text/keymap.js +2 -2
  10. package/dist/cjs/plugins/media/pm-plugins/main.js +22 -10
  11. package/dist/cjs/plugins/media/toolbar/alt-text.js +2 -2
  12. package/dist/cjs/plugins/media/toolbar/index.js +33 -19
  13. package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +15 -3
  14. package/dist/cjs/plugins/media/utils/media-single.js +13 -13
  15. package/dist/cjs/plugins/paste/handlers.js +2 -2
  16. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +2 -2
  17. package/dist/cjs/plugins/paste/pm-plugins/main.js +4 -4
  18. package/dist/cjs/plugins/selection/gap-cursor/styles.js +1 -1
  19. package/dist/cjs/plugins/selection/gap-cursor/utils/place-gap-cursor.js +3 -3
  20. package/dist/cjs/plugins/selection/gap-cursor/utils.js +6 -3
  21. package/dist/cjs/plugins/selection/pm-plugins/gap-cursor-main.js +3 -3
  22. package/dist/cjs/plugins/text-color/commands/toggle-color.js +3 -2
  23. package/dist/cjs/utils/document.js +6 -24
  24. package/dist/cjs/utils/index.js +33 -105
  25. package/dist/cjs/utils/prosemirror/position.js +33 -41
  26. package/dist/cjs/version-wrapper.js +1 -1
  27. package/dist/cjs/version.json +1 -1
  28. package/dist/es2019/plugins/emoji/commands/insert-emoji.js +24 -20
  29. package/dist/es2019/plugins/emoji/index.js +14 -4
  30. package/dist/es2019/plugins/index.js +1 -1
  31. package/dist/es2019/plugins/insert-block/index.js +3 -7
  32. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +6 -3
  33. package/dist/es2019/plugins/media/index.js +6 -3
  34. package/dist/es2019/plugins/media/pm-plugins/alt-text/commands.js +3 -2
  35. package/dist/es2019/plugins/media/pm-plugins/alt-text/keymap.js +2 -2
  36. package/dist/es2019/plugins/media/pm-plugins/main.js +16 -7
  37. package/dist/es2019/plugins/media/toolbar/alt-text.js +2 -2
  38. package/dist/es2019/plugins/media/toolbar/index.js +34 -21
  39. package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +17 -4
  40. package/dist/es2019/plugins/media/utils/media-single.js +7 -8
  41. package/dist/es2019/plugins/paste/handlers.js +2 -3
  42. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +2 -2
  43. package/dist/es2019/plugins/paste/pm-plugins/main.js +4 -4
  44. package/dist/es2019/plugins/selection/gap-cursor/styles.js +2 -1
  45. package/dist/es2019/plugins/selection/gap-cursor/utils/place-gap-cursor.js +4 -4
  46. package/dist/es2019/plugins/selection/gap-cursor/utils.js +5 -2
  47. package/dist/es2019/plugins/selection/pm-plugins/gap-cursor-main.js +4 -4
  48. package/dist/es2019/plugins/text-color/commands/toggle-color.js +3 -2
  49. package/dist/es2019/utils/document.js +1 -20
  50. package/dist/es2019/utils/index.js +1 -99
  51. package/dist/es2019/utils/prosemirror/position.js +1 -51
  52. package/dist/es2019/version-wrapper.js +1 -1
  53. package/dist/es2019/version.json +1 -1
  54. package/dist/esm/plugins/emoji/commands/insert-emoji.js +21 -20
  55. package/dist/esm/plugins/emoji/index.js +14 -4
  56. package/dist/esm/plugins/index.js +1 -1
  57. package/dist/esm/plugins/insert-block/index.js +3 -7
  58. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
  59. package/dist/esm/plugins/media/index.js +4 -3
  60. package/dist/esm/plugins/media/pm-plugins/alt-text/commands.js +10 -7
  61. package/dist/esm/plugins/media/pm-plugins/alt-text/keymap.js +2 -2
  62. package/dist/esm/plugins/media/pm-plugins/main.js +18 -7
  63. package/dist/esm/plugins/media/toolbar/alt-text.js +2 -2
  64. package/dist/esm/plugins/media/toolbar/index.js +35 -21
  65. package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +16 -4
  66. package/dist/esm/plugins/media/utils/media-single.js +7 -7
  67. package/dist/esm/plugins/paste/handlers.js +2 -3
  68. package/dist/esm/plugins/paste/pm-plugins/analytics.js +2 -2
  69. package/dist/esm/plugins/paste/pm-plugins/main.js +4 -4
  70. package/dist/esm/plugins/selection/gap-cursor/styles.js +1 -1
  71. package/dist/esm/plugins/selection/gap-cursor/utils/place-gap-cursor.js +4 -4
  72. package/dist/esm/plugins/selection/gap-cursor/utils.js +5 -2
  73. package/dist/esm/plugins/selection/pm-plugins/gap-cursor-main.js +4 -4
  74. package/dist/esm/plugins/text-color/commands/toggle-color.js +3 -2
  75. package/dist/esm/utils/document.js +1 -22
  76. package/dist/esm/utils/index.js +1 -97
  77. package/dist/esm/utils/prosemirror/position.js +1 -39
  78. package/dist/esm/version-wrapper.js +1 -1
  79. package/dist/esm/version.json +1 -1
  80. package/dist/types/labs/next/presets/default.d.ts +32 -32
  81. package/dist/types/plugins/emoji/commands/insert-emoji.d.ts +2 -2
  82. package/dist/types/plugins/emoji/index.d.ts +9 -4
  83. package/dist/types/plugins/index.d.ts +1 -1
  84. package/dist/types/plugins/insert-block/index.d.ts +3 -1
  85. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -1
  86. package/dist/types/plugins/media/pm-plugins/alt-text/commands.d.ts +2 -1
  87. package/dist/types/plugins/media/pm-plugins/alt-text/keymap.d.ts +2 -1
  88. package/dist/types/plugins/media/pm-plugins/main.d.ts +3 -0
  89. package/dist/types/plugins/media/pm-plugins/types.d.ts +2 -0
  90. package/dist/types/plugins/media/toolbar/alt-text.d.ts +2 -1
  91. package/dist/types/plugins/media/toolbar/index.d.ts +1 -2
  92. package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -0
  93. package/dist/types/plugins/media/utils/media-single.d.ts +3 -3
  94. package/dist/types/plugins/paste/handlers.d.ts +2 -1
  95. package/dist/types/plugins/paste/index.d.ts +3 -1
  96. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +2 -1
  97. package/dist/types/plugins/selection/gap-cursor/utils.d.ts +1 -1
  98. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  99. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  100. package/dist/types/utils/document.d.ts +2 -7
  101. package/dist/types/utils/index.d.ts +2 -6
  102. package/dist/types/utils/prosemirror/position.d.ts +1 -8
  103. package/dist/types-ts4.5/labs/next/presets/default.d.ts +32 -32
  104. package/dist/types-ts4.5/plugins/emoji/commands/insert-emoji.d.ts +2 -2
  105. package/dist/types-ts4.5/plugins/emoji/index.d.ts +9 -4
  106. package/dist/types-ts4.5/plugins/index.d.ts +1 -1
  107. package/dist/types-ts4.5/plugins/insert-block/index.d.ts +3 -1
  108. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -1
  109. package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/commands.d.ts +2 -1
  110. package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/keymap.d.ts +2 -1
  111. package/dist/types-ts4.5/plugins/media/pm-plugins/main.d.ts +3 -0
  112. package/dist/types-ts4.5/plugins/media/pm-plugins/types.d.ts +2 -0
  113. package/dist/types-ts4.5/plugins/media/toolbar/alt-text.d.ts +2 -1
  114. package/dist/types-ts4.5/plugins/media/toolbar/index.d.ts +1 -2
  115. package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -0
  116. package/dist/types-ts4.5/plugins/media/utils/media-single.d.ts +3 -3
  117. package/dist/types-ts4.5/plugins/paste/handlers.d.ts +2 -1
  118. package/dist/types-ts4.5/plugins/paste/index.d.ts +3 -1
  119. package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +2 -1
  120. package/dist/types-ts4.5/plugins/selection/gap-cursor/utils.d.ts +1 -1
  121. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
  122. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  123. package/dist/types-ts4.5/utils/document.d.ts +2 -7
  124. package/dist/types-ts4.5/utils/index.d.ts +2 -6
  125. package/dist/types-ts4.5/utils/prosemirror/position.d.ts +1 -8
  126. package/package.json +4 -4
  127. package/report.api.md +5 -0
  128. package/tmp/api-report-tmp.d.ts +5 -1
@@ -17,7 +17,6 @@ import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } f
17
17
  import { getPluginState as getPastePluginState } from './pm-plugins/plugin-factory';
18
18
  import { doesSelectionWhichStartsOrEndsInListContainEntireList } from '../../utils/lists';
19
19
  import { anyMarkActive } from '@atlaskit/editor-common/mark';
20
-
21
20
  // remove text attribute from mention for copy/paste (GDPR)
22
21
  export function handleMention(slice, schema) {
23
22
  return mapSlice(slice, node => {
@@ -532,12 +531,12 @@ function isOnlyMediaSingle(state, slice) {
532
531
  } = state.schema.nodes;
533
532
  return mediaSingle && slice.content.childCount === 1 && slice.content.firstChild.type === mediaSingle;
534
533
  }
535
- export function handleMediaSingle(inputMethod) {
534
+ export function handleMediaSingle(inputMethod, editorAnalyticsAPI) {
536
535
  return function (slice) {
537
536
  return (state, dispatch, view) => {
538
537
  if (view) {
539
538
  if (isOnlyMedia(state, slice)) {
540
- return insertMediaAsMediaSingle(view, slice.content.firstChild, inputMethod);
539
+ return insertMediaAsMediaSingle(view, slice.content.firstChild, inputMethod, editorAnalyticsAPI);
541
540
  }
542
541
  if (insideTable(state) && isOnlyMediaSingle(state, slice)) {
543
542
  const tr = state.tr.replaceSelection(slice);
@@ -238,9 +238,9 @@ export const handlePasteIntoCaptionWithAnalytics = (view, event, slice, type) =>
238
238
  export const handleCodeBlockWithAnalytics = (view, event, slice, text) => injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
239
239
  type: PasteTypes.plain
240
240
  }))(handleCodeBlock(text));
241
- export const handleMediaSingleWithAnalytics = (view, event, slice, type) => injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
241
+ export const handleMediaSingleWithAnalytics = (view, event, slice, type, editorAnalyticsAPI) => injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
242
242
  type
243
- }))(handleMediaSingle(INPUT_METHOD.CLIPBOARD)(slice));
243
+ }))(handleMediaSingle(INPUT_METHOD.CLIPBOARD, editorAnalyticsAPI)(slice));
244
244
  export const handlePastePreservingMarksWithAnalytics = (view, event, slice, type, pluginInjectionApi) => {
245
245
  var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
246
246
  return injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
@@ -77,7 +77,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
77
77
  }
78
78
  },
79
79
  handlePaste(view, rawEvent, slice) {
80
- var _text, _analyticsPlugin$perf, _analyticsPlugin$perf2, _schema$nodes, _schema$nodes2, _schema$nodes3;
80
+ var _text, _analyticsPlugin$perf, _analyticsPlugin$perf2, _schema$nodes, _schema$nodes2, _schema$nodes3, _pluginInjectionApi$d4, _pluginInjectionApi$d5;
81
81
  const event = rawEvent;
82
82
  if (!event.clipboardData) {
83
83
  return false;
@@ -246,7 +246,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
246
246
  if (handleCodeBlockWithAnalytics(view, event, slice, text)(state, dispatch)) {
247
247
  return true;
248
248
  }
249
- if (handleMediaSingleWithAnalytics(view, event, slice, isPastedFile ? PasteTypes.binary : PasteTypes.richText)(state, dispatch, view)) {
249
+ if (handleMediaSingleWithAnalytics(view, event, slice, isPastedFile ? PasteTypes.binary : PasteTypes.richText, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : (_pluginInjectionApi$d5 = _pluginInjectionApi$d4.analytics) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.actions)(state, dispatch, view)) {
250
250
  return true;
251
251
  }
252
252
  if (handleSelectedTableWithAnalytics(view, event, slice)(state, dispatch)) {
@@ -281,7 +281,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
281
281
 
282
282
  // finally, handle rich-text copy-paste
283
283
  if (isRichText) {
284
- var _pluginInjectionApi$d4, _pluginInjectionApi$d5;
284
+ var _pluginInjectionApi$d6, _pluginInjectionApi$d7;
285
285
  // linkify the text where possible
286
286
  slice = linkifyContent(state.schema)(slice);
287
287
  if (handlePasteLinkOnSelectedTextWithAnalytics(view, event, slice, PasteTypes.richText)(state, dispatch)) {
@@ -289,7 +289,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
289
289
  }
290
290
 
291
291
  // run macro autoconvert prior to other conversions
292
- if (handleMacroAutoConvert(text, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.dependencies.card) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : (_pluginInjectionApi$d5 = _pluginInjectionApi$d4.actions) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.queueCardsFromChangedTr, cardOptions, extensionAutoConverter)(state, dispatch, view)) {
292
+ if (handleMacroAutoConvert(text, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d6 = pluginInjectionApi.dependencies.card) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : (_pluginInjectionApi$d7 = _pluginInjectionApi$d6.actions) === null || _pluginInjectionApi$d7 === void 0 ? void 0 : _pluginInjectionApi$d7.queueCardsFromChangedTr, cardOptions, extensionAutoConverter)(state, dispatch, view)) {
293
293
  // TODO: handleMacroAutoConvert dispatch twice, so we can't use the helper
294
294
  sendPasteAnalyticsEvent(view, event, slice, {
295
295
  type: PasteTypes.richText
@@ -48,7 +48,8 @@ export const gapCursorStyles = css`
48
48
  right: -3px;
49
49
  }
50
50
  & span[layout='full-width'],
51
- & span[layout='wide'] {
51
+ & span[layout='wide'],
52
+ & span[layout='fixed-width'] {
52
53
  margin-left: 50%;
53
54
  transform: translateX(-50%);
54
55
  }
@@ -1,4 +1,4 @@
1
- import { getBreakoutModeFromTargetNode, isLeftCursor } from '../utils';
1
+ import { getLayoutModeFromTargetNode, isLeftCursor } from '../utils';
2
2
  import { Side } from '../selection';
3
3
 
4
4
  /**
@@ -76,9 +76,9 @@ export const toDOM = (view, getPos) => {
76
76
  if (nodeStart !== 0 || node && node.type.name === 'table') {
77
77
  gapCursor.style.marginTop = style.getPropertyValue('margin-top');
78
78
  }
79
- const breakoutMode = node && getBreakoutModeFromTargetNode(node);
80
- if (breakoutMode) {
81
- gapCursor.setAttribute('layout', breakoutMode);
79
+ const layoutMode = node && getLayoutModeFromTargetNode(node);
80
+ if (layoutMode) {
81
+ gapCursor.setAttribute('layout', layoutMode);
82
82
  gapCursor.style.width = `${measureWidth(style)}px`;
83
83
  } else {
84
84
  mutateElementStyle(gapCursor, style, selection.side);
@@ -56,7 +56,7 @@ export const isTextBlockNearPos = (doc, schema, $pos, dir) => {
56
56
  }
57
57
  return false;
58
58
  };
59
- export function getBreakoutModeFromTargetNode(node) {
59
+ export function getLayoutModeFromTargetNode(node) {
60
60
  let layout;
61
61
  if (node.attrs.layout) {
62
62
  layout = node.attrs.layout;
@@ -68,7 +68,10 @@ export function getBreakoutModeFromTargetNode(node) {
68
68
  }
69
69
  }).attrs.mode;
70
70
  }
71
- if (['wide', 'full-width'].indexOf(layout) === -1) {
71
+ if (node.type.name === 'table' && node.attrs.width) {
72
+ layout = 'fixed-width';
73
+ }
74
+ if (['wide', 'full-width', 'fixed-width'].indexOf(layout) === -1) {
72
75
  return '';
73
76
  }
74
77
  return layout;
@@ -5,7 +5,7 @@ import { findPositionOfNodeBefore } from '@atlaskit/editor-prosemirror/utils';
5
5
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
6
6
  import { hideCaretModifier } from '../gap-cursor/styles';
7
7
  import { GapCursorSelection, JSON_ID, Side as GapCursorSide, Side } from '../gap-cursor/selection';
8
- import { getBreakoutModeFromTargetNode, isIgnoredClick } from '../gap-cursor/utils';
8
+ import { getLayoutModeFromTargetNode, isIgnoredClick } from '../gap-cursor/utils';
9
9
  import { toDOM } from '../gap-cursor/utils/place-gap-cursor';
10
10
  import { deleteNode, setGapCursorAtPos } from '../gap-cursor/actions';
11
11
  import { Direction } from '../gap-cursor/direction';
@@ -70,10 +70,10 @@ const plugin = new SafePlugin({
70
70
  }
71
71
  }
72
72
  const node = isRightCursor ? $from.nodeBefore : $from.nodeAfter;
73
- const breakoutMode = node && getBreakoutModeFromTargetNode(node);
73
+ const layoutMode = node && getLayoutModeFromTargetNode(node);
74
74
  return DecorationSet.create(doc, [Decoration.widget(position, toDOM, {
75
- key: `${JSON_ID}-${side}-${breakoutMode}`,
76
- side: breakoutMode ? -1 : 0
75
+ key: `${JSON_ID}-${side}-${layoutMode}`,
76
+ side: layoutMode ? -1 : 0
77
77
  })]);
78
78
  }
79
79
  return null;
@@ -1,6 +1,7 @@
1
1
  import { toggleMark } from '@atlaskit/editor-common/mark';
2
2
  import { ACTIONS, pluginKey } from '../pm-plugins/main';
3
3
  import { getDisabledState } from '../utils/disabled';
4
+ import { pluginCommandToPMCommand } from '@atlaskit/editor-common/preset';
4
5
  export const toggleColor = color => (state, dispatch) => {
5
6
  const {
6
7
  textColor
@@ -21,9 +22,9 @@ export const toggleColor = color => (state, dispatch) => {
21
22
  color
22
23
  });
23
24
  state.tr.scrollIntoView();
24
- toggleMark(textColor, {
25
+ pluginCommandToPMCommand(toggleMark(textColor, {
25
26
  color
26
- })(state, dispatch);
27
+ }))(state, dispatch);
27
28
  }
28
29
  return true;
29
30
  };
@@ -1,6 +1,7 @@
1
1
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
2
2
  import { getBreakoutMode } from './node-width';
3
3
  import { processRawValue, hasDocAsParent, getStepRange, isEmptyParagraph } from '@atlaskit/editor-common/utils';
4
+ export { findFarthestParentNode } from '@atlaskit/editor-common/utils';
4
5
 
5
6
  /**
6
7
  * Checks if a node has any content. Ignores node that only contain empty block nodes.
@@ -46,26 +47,6 @@ export function processRawFragmentValue(schema, value, providerFactory, sanitize
46
47
  }
47
48
  return Fragment.from(adfEntities);
48
49
  }
49
-
50
- /**
51
- * Find the farthest node given a condition
52
- * @param predicate Function to check the node
53
- */
54
- export const findFarthestParentNode = predicate => $pos => {
55
- let candidate = null;
56
- for (let i = $pos.depth; i > 0; i--) {
57
- const node = $pos.node(i);
58
- if (predicate(node)) {
59
- candidate = {
60
- pos: i > 0 ? $pos.before(i) : 0,
61
- start: $pos.start(i),
62
- depth: i,
63
- node
64
- };
65
- }
66
- }
67
- return candidate;
68
- };
69
50
  export const isSelectionEndOfParagraph = state => state.selection.$to.parent.type === state.schema.nodes.paragraph && state.selection.$to.pos === state.doc.resolve(state.selection.$to.pos).end();
70
51
  export function getChangedNodesIn({
71
52
  tr,
@@ -2,7 +2,7 @@ import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
2
2
  import { JSONTransformer } from '@atlaskit/editor-json-transformer';
3
3
  import { FakeTextCursorSelection } from '../plugins/fake-text-cursor/cursor';
4
4
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
5
- import { isNodeEmpty } from './document';
5
+ export { isEmptyNode, isSelectionInsideLastNodeInDocument, checkNodeDown, insideTableCell, isInListItem } from '@atlaskit/editor-common/utils';
6
6
  export { insideTable } from '@atlaskit/editor-common/core-utils';
7
7
  export { isNodeEmpty, findFarthestParentNode, isSelectionEndOfParagraph, nodesBetweenChanged, getNodesCount } from './document';
8
8
  export { sanitiseMarksInSelection } from './mark';
@@ -15,11 +15,6 @@ function isMarkTypeCompatibleWithMark(markType, mark) {
15
15
  function isMarkTypeAllowedInNode(markType, state) {
16
16
  return toggleMark(markType)(state);
17
17
  }
18
- export function isSelectionInsideLastNodeInDocument(selection) {
19
- const docNode = selection.$anchor.node(0);
20
- const rootNode = selection.$anchor.node(1);
21
- return docNode.lastChild === rootNode;
22
- }
23
18
  export function getCursor(selection) {
24
19
  return selection.$cursor || undefined;
25
20
  }
@@ -67,36 +62,6 @@ export function isMarkTypeAllowedInCurrentSelection(markType, state) {
67
62
  return allowedInActiveMarks;
68
63
  });
69
64
  }
70
- export function checkNodeDown(selection, doc, filter) {
71
- const ancestorDepth = findAncestorPosition(doc, selection.$to).depth;
72
-
73
- // Top level node
74
- if (ancestorDepth === 0) {
75
- return false;
76
- }
77
- const res = doc.resolve(selection.$to.after(ancestorDepth));
78
- return res.nodeAfter ? filter(res.nodeAfter) : false;
79
- }
80
-
81
- /**
82
- * Traverse the document until an "ancestor" is found. Any nestable block can be an ancestor.
83
- */
84
- function findAncestorPosition(doc, pos) {
85
- const nestableBlocks = ['blockquote', 'bulletList', 'orderedList'];
86
- if (pos.depth === 1) {
87
- return pos;
88
- }
89
- let node = pos.node(pos.depth);
90
- let newPos = pos;
91
- while (pos.depth >= 1) {
92
- pos = doc.resolve(pos.before(pos.depth));
93
- node = pos.node(pos.depth);
94
- if (node && nestableBlocks.indexOf(node.type.name) !== -1) {
95
- newPos = pos;
96
- }
97
- }
98
- return newPos;
99
- }
100
65
  const transformer = new JSONTransformer();
101
66
  export function toJSON(node) {
102
67
  return transformer.encode(node);
@@ -142,69 +107,6 @@ export function whichTransitionEvent() {
142
107
  export const isTemporary = id => {
143
108
  return id.indexOf('temporary:') === 0;
144
109
  };
145
- export const isEmptyNode = schema => {
146
- const {
147
- doc,
148
- paragraph,
149
- codeBlock,
150
- blockquote,
151
- panel,
152
- heading,
153
- listItem,
154
- bulletList,
155
- orderedList,
156
- taskList,
157
- taskItem,
158
- decisionList,
159
- decisionItem,
160
- media,
161
- mediaGroup,
162
- mediaSingle
163
- } = schema.nodes;
164
- const innerIsEmptyNode = node => {
165
- switch (node.type) {
166
- case media:
167
- case mediaGroup:
168
- case mediaSingle:
169
- return false;
170
- case paragraph:
171
- case codeBlock:
172
- case heading:
173
- case taskItem:
174
- case decisionItem:
175
- return node.content.size === 0;
176
- case blockquote:
177
- case panel:
178
- case listItem:
179
- return node.content.size === 2 && innerIsEmptyNode(node.content.firstChild);
180
- case bulletList:
181
- case orderedList:
182
- return node.content.size === 4 && innerIsEmptyNode(node.content.firstChild);
183
- case taskList:
184
- case decisionList:
185
- return node.content.size === 2 && innerIsEmptyNode(node.content.firstChild);
186
- case doc:
187
- let isEmpty = true;
188
- node.content.forEach(child => {
189
- isEmpty = isEmpty && innerIsEmptyNode(child);
190
- });
191
- return isEmpty;
192
- default:
193
- return isNodeEmpty(node);
194
- }
195
- };
196
- return innerIsEmptyNode;
197
- };
198
- export const insideTableCell = state => {
199
- const {
200
- tableCell,
201
- tableHeader
202
- } = state.schema.nodes;
203
- return hasParentNodeOfType([tableCell, tableHeader])(state.selection);
204
- };
205
- export const isInListItem = state => {
206
- return hasParentNodeOfType(state.schema.nodes.listItem)(state.selection);
207
- };
208
110
  export const hasOpenEnd = slice => {
209
111
  return slice.openStart > 0 || slice.openEnd > 0;
210
112
  };
@@ -1,51 +1 @@
1
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
2
- import { GapCursorSelection } from '../../plugins/selection/gap-cursor/selection';
3
- export function atTheEndOfDoc(state) {
4
- const {
5
- selection,
6
- doc
7
- } = state;
8
- return doc.nodeSize - selection.$to.pos - 2 === selection.$to.depth;
9
- }
10
- export function atTheBeginningOfDoc(state) {
11
- const {
12
- selection
13
- } = state;
14
- return selection.$from.pos === selection.$from.depth;
15
- }
16
- export function atTheEndOfBlock(state) {
17
- const {
18
- selection
19
- } = state;
20
- const {
21
- $to
22
- } = selection;
23
- if (selection instanceof GapCursorSelection) {
24
- return false;
25
- }
26
- if (selection instanceof NodeSelection && selection.node.isBlock) {
27
- return true;
28
- }
29
- return endPositionOfParent($to) === $to.pos + 1;
30
- }
31
- export function atTheBeginningOfBlock(state) {
32
- const {
33
- selection
34
- } = state;
35
- const {
36
- $from
37
- } = selection;
38
- if (selection instanceof GapCursorSelection) {
39
- return false;
40
- }
41
- if (selection instanceof NodeSelection && selection.node.isBlock) {
42
- return true;
43
- }
44
- return startPositionOfParent($from) === $from.pos;
45
- }
46
- export function startPositionOfParent(resolvedPos) {
47
- return resolvedPos.start(resolvedPos.depth);
48
- }
49
- export function endPositionOfParent(resolvedPos) {
50
- return resolvedPos.end(resolvedPos.depth) + 1;
51
- }
1
+ export { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, startPositionOfParent } from '@atlaskit/editor-common/selection';
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.19.0";
2
+ export const version = "187.20.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.19.0",
3
+ "version": "187.20.0",
4
4
  "sideEffects": false
5
5
  }
@@ -7,32 +7,33 @@ import { Selection } from '@atlaskit/editor-prosemirror/state';
7
7
  import { EVENT_TYPE, ACTION_SUBJECT_ID, ACTION_SUBJECT, ACTION } from '@atlaskit/editor-common/analytics';
8
8
  export var insertEmoji = function insertEmoji(editorAnalyticsAPI) {
9
9
  return function (emojiId, inputMethod) {
10
- return function (state, dispatch) {
11
- var emoji = state.schema.nodes.emoji;
10
+ return function (_ref) {
11
+ var tr = _ref.tr;
12
+ var doc = tr.doc,
13
+ selection = tr.selection;
14
+ var emoji = tr.doc.type.schema.nodes.emoji;
12
15
  if (emoji && emojiId) {
13
16
  var node = emoji.createChecked(_objectSpread(_objectSpread({}, emojiId), {}, {
14
17
  text: emojiId.fallback || emojiId.shortName
15
18
  }));
16
- var textNode = state.schema.text(' ');
17
- if (dispatch) {
18
- var fragment = Fragment.fromArray([node, textNode]);
19
- var tr = safeInsert(fragment)(state.tr);
20
- if (inputMethod) {
21
- editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
22
- action: ACTION.INSERTED,
23
- actionSubject: ACTION_SUBJECT.DOCUMENT,
24
- actionSubjectId: ACTION_SUBJECT_ID.EMOJI,
25
- attributes: {
26
- inputMethod: inputMethod
27
- },
28
- eventType: EVENT_TYPE.TRACK
29
- })(tr);
30
- }
31
- dispatch(tr.setSelection(Selection.near(tr.doc.resolve(state.selection.$from.pos + fragment.size))));
19
+ var textNode = doc.type.schema.text(' ');
20
+ var fragment = Fragment.fromArray([node, textNode]);
21
+ var newTr = safeInsert(fragment)(tr);
22
+ if (inputMethod) {
23
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
24
+ action: ACTION.INSERTED,
25
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
26
+ actionSubjectId: ACTION_SUBJECT_ID.EMOJI,
27
+ attributes: {
28
+ inputMethod: inputMethod
29
+ },
30
+ eventType: EVENT_TYPE.TRACK
31
+ })(newTr);
32
32
  }
33
- return true;
33
+ newTr.setSelection(Selection.near(newTr.doc.resolve(selection.$from.pos + fragment.size)));
34
+ return newTr;
34
35
  }
35
- return false;
36
+ return null;
36
37
  };
37
38
  };
38
39
  };
@@ -15,6 +15,7 @@ import { IconEmoji } from '@atlaskit/editor-common/quick-insert';
15
15
  import { EmojiNodeView } from './nodeviews/emoji';
16
16
  import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
17
17
  import { openTypeAheadAtCursor } from '../type-ahead/transforms/open-typeahead-at-cursor';
18
+ import { insertEmoji } from './commands/insert-emoji';
18
19
  export var emojiToTypeaheadItem = function emojiToTypeaheadItem(emoji, emojiProvider) {
19
20
  return {
20
21
  title: emoji.shortName || '',
@@ -60,7 +61,8 @@ var isFullShortName = function isFullShortName(query) {
60
61
  return query && query.length > 1 && query.charAt(0) === ':' && query.charAt(query.length - 1) === ':';
61
62
  };
62
63
  var TRIGGER = ':';
63
- var emojiPlugin = function emojiPlugin(options, api) {
64
+ export var emojiPlugin = function emojiPlugin(options, api) {
65
+ var _api$dependencies$ana9;
64
66
  var typeAhead = {
65
67
  id: TypeAheadAvailableNodes.EMOJI,
66
68
  trigger: TRIGGER,
@@ -182,6 +184,15 @@ var emojiPlugin = function emojiPlugin(options, api) {
182
184
  }
183
185
  }];
184
186
  },
187
+ getSharedState: function getSharedState(editorState) {
188
+ if (!editorState) {
189
+ return undefined;
190
+ }
191
+ return emojiPluginKey.getState(editorState);
192
+ },
193
+ commands: {
194
+ 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)
195
+ },
185
196
  pluginsOptions: {
186
197
  quickInsert: function quickInsert(_ref7) {
187
198
  var formatMessage = _ref7.formatMessage;
@@ -195,13 +206,13 @@ var emojiPlugin = function emojiPlugin(options, api) {
195
206
  return /*#__PURE__*/React.createElement(IconEmoji, null);
196
207
  },
197
208
  action: function action(insert, state) {
198
- var _api$dependencies$ana9;
209
+ var _api$dependencies$ana10;
199
210
  var tr = insert(undefined);
200
211
  openTypeAheadAtCursor({
201
212
  triggerHandler: typeAhead,
202
213
  inputMethod: INPUT_METHOD.QUICK_INSERT
203
214
  })(tr);
204
- 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({
215
+ 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({
205
216
  action: ACTION.INVOKED,
206
217
  actionSubject: ACTION_SUBJECT.TYPEAHEAD,
207
218
  actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_EMOJI,
@@ -218,7 +229,6 @@ var emojiPlugin = function emojiPlugin(options, api) {
218
229
  }
219
230
  };
220
231
  };
221
- export default emojiPlugin;
222
232
 
223
233
  /**
224
234
  * 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';
@@ -65,7 +64,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
65
64
  blockTypeState: blockTypeStateKey,
66
65
  mediaState: mediaStateKey,
67
66
  macroState: macroStateKey,
68
- emojiState: emojiPluginKey,
69
67
  placeholderTextState: placeholderTextStateKey,
70
68
  layoutState: layoutStateKey
71
69
  },
@@ -74,7 +72,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
74
72
  mediaState = _ref2.mediaState,
75
73
  _ref2$macroState = _ref2.macroState,
76
74
  macroState = _ref2$macroState === void 0 ? {} : _ref2$macroState,
77
- emojiState = _ref2.emojiState,
78
75
  placeholderTextState = _ref2.placeholderTextState,
79
76
  layoutState = _ref2.layoutState;
80
77
  return /*#__PURE__*/React.createElement(ToolbarInsertBlockWithInjectionApi, {
@@ -94,7 +91,6 @@ var insertBlockPlugin = function insertBlockPlugin() {
94
91
  blockTypeState: blockTypeState,
95
92
  mediaState: mediaState,
96
93
  macroState: macroState,
97
- emojiState: emojiState,
98
94
  placeholderTextState: placeholderTextState,
99
95
  layoutState: layoutState,
100
96
  providers: providers,
@@ -130,16 +126,16 @@ function ToolbarInsertBlockWithInjectionApi(_ref3) {
130
126
  blockTypeState = _ref3.blockTypeState,
131
127
  mediaState = _ref3.mediaState,
132
128
  macroState = _ref3.macroState,
133
- emojiState = _ref3.emojiState,
134
129
  placeholderTextState = _ref3.placeholderTextState,
135
130
  layoutState = _ref3.layoutState,
136
131
  featureFlags = _ref3.featureFlags;
137
132
  var buttons = toolbarSizeToButtons(toolbarSize);
138
- var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention']),
133
+ var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji']),
139
134
  dateState = _useSharedPluginState.dateState,
140
135
  hyperlinkState = _useSharedPluginState.hyperlinkState,
141
136
  imageUploadState = _useSharedPluginState.imageUploadState,
142
- mentionState = _useSharedPluginState.mentionState;
137
+ mentionState = _useSharedPluginState.mentionState,
138
+ emojiState = _useSharedPluginState.emojiState;
143
139
  return /*#__PURE__*/React.createElement(ToolbarInsertBlock, {
144
140
  pluginInjectionApi: pluginInjectionApi,
145
141
  buttons: buttons,
@@ -27,8 +27,7 @@ import { insertTaskDecisionCommand } from '../../../tasks-and-decisions/commands
27
27
  import { insertExpand } from '../../../expand/commands';
28
28
  import { createTypeAheadTools } from '../../../type-ahead/api';
29
29
  import { updateStatusWithAnalytics } from '../../../status/actions';
30
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '../../../analytics';
31
- import { insertEmoji } from '../../../emoji/commands/insert-emoji';
30
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
32
31
  import { messages } from './messages';
33
32
  import { createItems } from './create-items';
34
33
  import { BlockInsertMenu } from './block-insert-menu';
@@ -277,8 +276,10 @@ export var ToolbarInsertBlock = /*#__PURE__*/function (_React$PureComponent) {
277
276
  };
278
277
  });
279
278
  _defineProperty(_assertThisInitialized(_this), "handleSelectedEmoji", function (emojiId) {
279
+ var _pluginInjectionApi$d8;
280
+ var pluginInjectionApi = _this.props.pluginInjectionApi;
280
281
  _this.props.editorView.focus();
281
- insertEmoji(_this.editorAnalyticsAPI)(emojiId, INPUT_METHOD.PICKER)(_this.props.editorView.state, _this.props.editorView.dispatch);
282
+ 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));
282
283
  _this.toggleEmojiPicker();
283
284
  return true;
284
285
  });
@@ -132,8 +132,9 @@ var mediaPlugin = function mediaPlugin() {
132
132
  pmPlugins.push({
133
133
  name: 'mediaAltTextKeymap',
134
134
  plugin: function plugin(_ref4) {
135
+ var _api$dependencies$ana2;
135
136
  var schema = _ref4.schema;
136
- return keymapMediaAltTextPlugin(schema);
137
+ return keymapMediaAltTextPlugin(schema, api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions);
137
138
  }
138
139
  });
139
140
  }
@@ -228,11 +229,11 @@ var mediaPlugin = function mediaPlugin() {
228
229
  return /*#__PURE__*/React.createElement(IconImages, null);
229
230
  },
230
231
  action: function action(insert, state) {
231
- var _api$dependencies$ana2;
232
+ var _api$dependencies$ana3;
232
233
  var pluginState = pluginKey.getState(state);
233
234
  pluginState === null || pluginState === void 0 ? void 0 : pluginState.showMediaPicker();
234
235
  var tr = insert('');
235
- api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions.attachAnalyticsEvent({
236
+ api === null || api === void 0 ? void 0 : (_api$dependencies$ana3 = api.dependencies.analytics) === null || _api$dependencies$ana3 === void 0 ? void 0 : _api$dependencies$ana3.actions.attachAnalyticsEvent({
236
237
  action: ACTION.OPENED,
237
238
  actionSubject: ACTION_SUBJECT.PICKER,
238
239
  actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
@@ -3,14 +3,17 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
3
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
4
  import { createCommand } from '.';
5
5
  import { isSelectionMediaSingleNode, getMediaNodeFromSelection } from '../../utils/media-common';
6
- import { ACTION_SUBJECT, EVENT_TYPE, withAnalytics, ACTION_SUBJECT_ID, ACTION } from '../../../analytics';
6
+ import { ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID, ACTION } from '@atlaskit/editor-common/analytics';
7
+ import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
7
8
  var createCommandWithAnalytics = function createCommandWithAnalytics(actionType, action, transform) {
8
- return withAnalytics({
9
- action: actionType,
10
- actionSubject: ACTION_SUBJECT.MEDIA,
11
- actionSubjectId: ACTION_SUBJECT_ID.ALT_TEXT,
12
- eventType: EVENT_TYPE.TRACK
13
- })(createCommand(action, transform));
9
+ return function (editorAnalyticsAPI) {
10
+ return withAnalytics(editorAnalyticsAPI, {
11
+ action: actionType,
12
+ actionSubject: ACTION_SUBJECT.MEDIA,
13
+ actionSubjectId: ACTION_SUBJECT_ID.ALT_TEXT,
14
+ eventType: EVENT_TYPE.TRACK
15
+ })(createCommand(action, transform));
16
+ };
14
17
  };
15
18
  export var closeMediaAltTextMenu = createCommand(function (state) {
16
19
  if (isSelectionMediaSingleNode(state)) {