@atlaskit/editor-core 172.3.2 → 173.0.1

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 (194) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/cjs/index.js +0 -6
  3. package/dist/cjs/plugins/base/index.js +8 -0
  4. package/dist/cjs/plugins/base/pm-plugins/composition.js +60 -0
  5. package/dist/cjs/plugins/breakout/index.js +5 -4
  6. package/dist/cjs/plugins/breakout/ui/LayoutButton.js +1 -3
  7. package/dist/cjs/plugins/card/pm-plugins/doc.js +8 -1
  8. package/dist/cjs/plugins/code-block/pm-plugins/ide-ux.js +2 -36
  9. package/dist/cjs/plugins/collab-edit/plugin-state.js +16 -9
  10. package/dist/cjs/plugins/collab-edit/utils.js +16 -2
  11. package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +24 -22
  12. package/dist/cjs/plugins/floating-toolbar/ui/Dropdown.js +20 -15
  13. package/dist/cjs/plugins/floating-toolbar/ui/DropdownMenu.js +8 -5
  14. package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +3 -3
  15. package/dist/cjs/plugins/paste/actions.js +13 -0
  16. package/dist/cjs/plugins/paste/commands.js +44 -0
  17. package/dist/cjs/plugins/paste/handlers.js +48 -7
  18. package/dist/cjs/plugins/paste/index.js +3 -2
  19. package/dist/cjs/plugins/paste/pm-plugins/main.js +34 -9
  20. package/dist/cjs/plugins/paste/pm-plugins/plugin-factory.js +62 -0
  21. package/dist/cjs/plugins/paste/reducer.js +47 -0
  22. package/dist/cjs/plugins/paste/types.js +5 -0
  23. package/dist/cjs/plugins/placeholder/index.js +3 -1
  24. package/dist/cjs/plugins/placeholder-text/index.js +9 -3
  25. package/dist/cjs/plugins/status/ui/statusPicker.js +4 -1
  26. package/dist/cjs/plugins/table/commands-with-analytics.js +59 -52
  27. package/dist/cjs/plugins/table/index.js +53 -36
  28. package/dist/cjs/plugins/table/toolbar.js +136 -20
  29. package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  30. package/dist/cjs/plugins/tasks-and-decisions/commands.js +1 -16
  31. package/dist/cjs/plugins/type-ahead/constants.js +3 -1
  32. package/dist/cjs/plugins/type-ahead/messages.js +16 -1
  33. package/dist/cjs/plugins/type-ahead/pm-plugins/main.js +1 -1
  34. package/dist/cjs/plugins/type-ahead/pm-plugins/reducer.js +2 -2
  35. package/dist/cjs/plugins/type-ahead/ui/AssistiveText.js +143 -0
  36. package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +59 -11
  37. package/dist/cjs/plugins/type-ahead/ui/TypeAheadList.js +156 -31
  38. package/dist/cjs/plugins/type-ahead/ui/TypeAheadListItem.js +55 -29
  39. package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.js +3 -3
  40. package/dist/cjs/plugins/type-ahead/ui/WrapperTypeAhead.js +5 -2
  41. package/dist/cjs/plugins/type-ahead/utils.js +1 -1
  42. package/dist/cjs/ui/MediaAndEmbedsToolbar/index.js +8 -0
  43. package/dist/cjs/ui/PortalProvider/PortalProviderThemesProvider.js +2 -6
  44. package/dist/cjs/ui/PortalProvider/index.js +26 -32
  45. package/dist/cjs/utils/index.js +8 -1
  46. package/dist/cjs/utils/selection.js +6 -8
  47. package/dist/cjs/version-wrapper.js +1 -1
  48. package/dist/cjs/version.json +1 -1
  49. package/dist/es2019/index.js +1 -1
  50. package/dist/es2019/plugins/base/index.js +5 -0
  51. package/dist/es2019/plugins/base/pm-plugins/composition.js +45 -0
  52. package/dist/es2019/plugins/breakout/index.js +5 -4
  53. package/dist/es2019/plugins/breakout/ui/LayoutButton.js +1 -3
  54. package/dist/es2019/plugins/card/pm-plugins/doc.js +10 -1
  55. package/dist/es2019/plugins/code-block/pm-plugins/ide-ux.js +3 -40
  56. package/dist/es2019/plugins/collab-edit/plugin-state.js +9 -3
  57. package/dist/es2019/plugins/collab-edit/utils.js +17 -3
  58. package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +24 -22
  59. package/dist/es2019/plugins/floating-toolbar/ui/Dropdown.js +15 -7
  60. package/dist/es2019/plugins/floating-toolbar/ui/DropdownMenu.js +9 -5
  61. package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +3 -3
  62. package/dist/es2019/plugins/paste/actions.js +6 -0
  63. package/dist/es2019/plugins/paste/commands.js +27 -0
  64. package/dist/es2019/plugins/paste/handlers.js +50 -8
  65. package/dist/es2019/plugins/paste/index.js +3 -2
  66. package/dist/es2019/plugins/paste/pm-plugins/main.js +29 -6
  67. package/dist/es2019/plugins/paste/pm-plugins/plugin-factory.js +33 -0
  68. package/dist/es2019/plugins/paste/reducer.js +24 -0
  69. package/dist/es2019/plugins/paste/types.js +1 -0
  70. package/dist/es2019/plugins/placeholder/index.js +2 -1
  71. package/dist/es2019/plugins/placeholder-text/index.js +13 -3
  72. package/dist/es2019/plugins/status/ui/statusPicker.js +5 -1
  73. package/dist/es2019/plugins/table/commands-with-analytics.js +6 -3
  74. package/dist/es2019/plugins/table/index.js +22 -4
  75. package/dist/es2019/plugins/table/toolbar.js +118 -14
  76. package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  77. package/dist/es2019/plugins/tasks-and-decisions/commands.js +0 -9
  78. package/dist/es2019/plugins/type-ahead/constants.js +1 -0
  79. package/dist/es2019/plugins/type-ahead/messages.js +16 -1
  80. package/dist/es2019/plugins/type-ahead/pm-plugins/main.js +1 -1
  81. package/dist/es2019/plugins/type-ahead/pm-plugins/reducer.js +2 -2
  82. package/dist/es2019/plugins/type-ahead/ui/AssistiveText.js +95 -0
  83. package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +49 -12
  84. package/dist/es2019/plugins/type-ahead/ui/TypeAheadList.js +143 -29
  85. package/dist/es2019/plugins/type-ahead/ui/TypeAheadListItem.js +64 -31
  86. package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +3 -3
  87. package/dist/es2019/plugins/type-ahead/ui/WrapperTypeAhead.js +5 -2
  88. package/dist/es2019/plugins/type-ahead/utils.js +1 -1
  89. package/dist/es2019/ui/MediaAndEmbedsToolbar/index.js +17 -0
  90. package/dist/es2019/ui/PortalProvider/PortalProviderThemesProvider.js +2 -5
  91. package/dist/es2019/ui/PortalProvider/index.js +5 -8
  92. package/dist/es2019/utils/index.js +6 -0
  93. package/dist/es2019/utils/selection.js +1 -9
  94. package/dist/es2019/version-wrapper.js +1 -1
  95. package/dist/es2019/version.json +1 -1
  96. package/dist/esm/index.js +1 -1
  97. package/dist/esm/plugins/base/index.js +7 -0
  98. package/dist/esm/plugins/base/pm-plugins/composition.js +45 -0
  99. package/dist/esm/plugins/breakout/index.js +5 -4
  100. package/dist/esm/plugins/breakout/ui/LayoutButton.js +1 -3
  101. package/dist/esm/plugins/card/pm-plugins/doc.js +8 -1
  102. package/dist/esm/plugins/code-block/pm-plugins/ide-ux.js +3 -37
  103. package/dist/esm/plugins/collab-edit/plugin-state.js +9 -3
  104. package/dist/esm/plugins/collab-edit/utils.js +17 -3
  105. package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +24 -22
  106. package/dist/esm/plugins/floating-toolbar/ui/Dropdown.js +20 -15
  107. package/dist/esm/plugins/floating-toolbar/ui/DropdownMenu.js +8 -5
  108. package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +3 -3
  109. package/dist/esm/plugins/paste/actions.js +6 -0
  110. package/dist/esm/plugins/paste/commands.js +31 -0
  111. package/dist/esm/plugins/paste/handlers.js +46 -8
  112. package/dist/esm/plugins/paste/index.js +3 -2
  113. package/dist/esm/plugins/paste/pm-plugins/main.js +27 -6
  114. package/dist/esm/plugins/paste/pm-plugins/plugin-factory.js +46 -0
  115. package/dist/esm/plugins/paste/reducer.js +34 -0
  116. package/dist/esm/plugins/paste/types.js +1 -0
  117. package/dist/esm/plugins/placeholder/index.js +2 -1
  118. package/dist/esm/plugins/placeholder-text/index.js +9 -3
  119. package/dist/esm/plugins/status/ui/statusPicker.js +4 -1
  120. package/dist/esm/plugins/table/commands-with-analytics.js +56 -49
  121. package/dist/esm/plugins/table/index.js +54 -37
  122. package/dist/esm/plugins/table/toolbar.js +124 -15
  123. package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +3 -3
  124. package/dist/esm/plugins/tasks-and-decisions/commands.js +0 -12
  125. package/dist/esm/plugins/type-ahead/constants.js +1 -0
  126. package/dist/esm/plugins/type-ahead/messages.js +16 -1
  127. package/dist/esm/plugins/type-ahead/pm-plugins/main.js +1 -1
  128. package/dist/esm/plugins/type-ahead/pm-plugins/reducer.js +2 -2
  129. package/dist/esm/plugins/type-ahead/ui/AssistiveText.js +129 -0
  130. package/dist/esm/plugins/type-ahead/ui/InputQuery.js +56 -12
  131. package/dist/esm/plugins/type-ahead/ui/TypeAheadList.js +151 -32
  132. package/dist/esm/plugins/type-ahead/ui/TypeAheadListItem.js +54 -31
  133. package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +3 -3
  134. package/dist/esm/plugins/type-ahead/ui/WrapperTypeAhead.js +5 -2
  135. package/dist/esm/plugins/type-ahead/utils.js +1 -1
  136. package/dist/esm/ui/MediaAndEmbedsToolbar/index.js +7 -0
  137. package/dist/esm/ui/PortalProvider/PortalProviderThemesProvider.js +2 -5
  138. package/dist/esm/ui/PortalProvider/index.js +26 -35
  139. package/dist/esm/utils/index.js +4 -0
  140. package/dist/esm/utils/selection.js +1 -7
  141. package/dist/esm/version-wrapper.js +1 -1
  142. package/dist/esm/version.json +1 -1
  143. package/dist/types/index.d.ts +1 -1
  144. package/dist/types/plugins/base/pm-plugins/composition.d.ts +8 -0
  145. package/dist/types/plugins/code-block/pm-plugins/ide-ux.d.ts +1 -4
  146. package/dist/types/plugins/floating-toolbar/ui/Dropdown.d.ts +2 -0
  147. package/dist/types/plugins/floating-toolbar/ui/DropdownMenu.d.ts +1 -0
  148. package/dist/types/plugins/paste/actions.d.ts +15 -0
  149. package/dist/types/plugins/paste/commands.d.ts +16 -0
  150. package/dist/types/plugins/paste/handlers.d.ts +1 -1
  151. package/dist/types/plugins/paste/pm-plugins/main.d.ts +3 -3
  152. package/dist/types/plugins/paste/pm-plugins/plugin-factory.d.ts +3 -0
  153. package/dist/types/plugins/paste/reducer.d.ts +3 -0
  154. package/dist/types/plugins/paste/types.d.ts +6 -0
  155. package/dist/types/plugins/table/commands-with-analytics.d.ts +5 -5
  156. package/dist/types/plugins/tasks-and-decisions/commands.d.ts +0 -2
  157. package/dist/types/plugins/type-ahead/constants.d.ts +1 -0
  158. package/dist/types/plugins/type-ahead/messages.d.ts +15 -0
  159. package/dist/types/plugins/type-ahead/ui/AssistiveText.d.ts +33 -0
  160. package/dist/types/plugins/type-ahead/ui/InputQuery.d.ts +3 -0
  161. package/dist/types/plugins/type-ahead/ui/TypeAheadList.d.ts +6 -3
  162. package/dist/types/plugins/type-ahead/ui/TypeAheadListItem.d.ts +2 -2
  163. package/dist/types/plugins/type-ahead/ui/TypeAheadPopup.d.ts +1 -1
  164. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  165. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  166. package/dist/types/utils/index.d.ts +1 -0
  167. package/dist/types/utils/selection.d.ts +1 -2
  168. package/dist/types-ts4.0/index.d.ts +1 -1
  169. package/dist/types-ts4.0/plugins/base/pm-plugins/composition.d.ts +8 -0
  170. package/dist/types-ts4.0/plugins/code-block/pm-plugins/ide-ux.d.ts +1 -4
  171. package/dist/types-ts4.0/plugins/floating-toolbar/ui/Dropdown.d.ts +2 -0
  172. package/dist/types-ts4.0/plugins/floating-toolbar/ui/DropdownMenu.d.ts +1 -0
  173. package/dist/types-ts4.0/plugins/paste/actions.d.ts +15 -0
  174. package/dist/types-ts4.0/plugins/paste/commands.d.ts +16 -0
  175. package/dist/types-ts4.0/plugins/paste/handlers.d.ts +1 -1
  176. package/dist/types-ts4.0/plugins/paste/pm-plugins/main.d.ts +3 -3
  177. package/dist/types-ts4.0/plugins/paste/pm-plugins/plugin-factory.d.ts +3 -0
  178. package/dist/types-ts4.0/plugins/paste/reducer.d.ts +3 -0
  179. package/dist/types-ts4.0/plugins/paste/types.d.ts +6 -0
  180. package/dist/types-ts4.0/plugins/table/commands-with-analytics.d.ts +5 -5
  181. package/dist/types-ts4.0/plugins/tasks-and-decisions/commands.d.ts +0 -2
  182. package/dist/types-ts4.0/plugins/type-ahead/constants.d.ts +1 -0
  183. package/dist/types-ts4.0/plugins/type-ahead/messages.d.ts +15 -0
  184. package/dist/types-ts4.0/plugins/type-ahead/ui/AssistiveText.d.ts +33 -0
  185. package/dist/types-ts4.0/plugins/type-ahead/ui/InputQuery.d.ts +3 -0
  186. package/dist/types-ts4.0/plugins/type-ahead/ui/TypeAheadList.d.ts +6 -3
  187. package/dist/types-ts4.0/plugins/type-ahead/ui/TypeAheadListItem.d.ts +2 -2
  188. package/dist/types-ts4.0/plugins/type-ahead/ui/TypeAheadPopup.d.ts +1 -1
  189. package/dist/types-ts4.0/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  190. package/dist/types-ts4.0/ui/ContentStyles/index.d.ts +2 -2
  191. package/dist/types-ts4.0/utils/index.d.ts +1 -0
  192. package/dist/types-ts4.0/utils/selection.d.ts +1 -2
  193. package/package.json +30 -31
  194. package/report.api.md +161 -49
@@ -2,9 +2,9 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { Slice, Fragment } from 'prosemirror-model';
4
4
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
- import { PluginKey } from 'prosemirror-state';
6
5
  import uuid from 'uuid';
7
6
  import { MarkdownTransformer } from '@atlaskit/editor-markdown-transformer';
7
+ import { mapChildren } from '../../../utils/slice';
8
8
  import { getExtensionAutoConvertersFromProvider } from '@atlaskit/editor-common/extensions';
9
9
  sendPasteAnalyticsEvent;
10
10
  import * as clipboard from '../../../utils/clipboard';
@@ -16,7 +16,7 @@ import { handleMacroAutoConvert, handleMention, handleParagraphBlockMarks } from
16
16
  import { transformSliceToJoinAdjacentCodeBlocks, transformSingleLineCodeBlockToCodeMark } from '../../code-block/utils';
17
17
  import { createPasteMeasurePayload, getContentNodeTypes, handlePasteAsPlainTextWithAnalytics, handlePasteIntoTaskAndDecisionWithAnalytics, handleCodeBlockWithAnalytics, handleMediaSingleWithAnalytics, handlePastePreservingMarksWithAnalytics, handleMarkdownWithAnalytics, handleRichTextWithAnalytics, handleExpandWithAnalytics, handleSelectedTableWithAnalytics, handlePasteLinkOnSelectedTextWithAnalytics, sendPasteAnalyticsEvent, handlePasteIntoCaptionWithAnalytics, handlePastePanelIntoListWithAnalytics } from './analytics';
18
18
  import { analyticsPluginKey, PasteTypes } from '../../analytics';
19
- import { insideTable, measurements } from '../../../utils';
19
+ import { isInsideBlockQuote, insideTable, measurements } from '../../../utils';
20
20
  import { measureRender } from '@atlaskit/editor-common/utils';
21
21
  import { transformSliceToCorrectMediaWrapper, unwrapNestedMediaElements } from '../../media/utils/media-common';
22
22
  import { upgradeTextToLists, splitParagraphs } from '../../list/transforms';
@@ -29,16 +29,17 @@ import { clipboardTextSerializer } from './clipboard-text-serializer';
29
29
  import { htmlHasIncompleteTable, tryRebuildCompleteTableHtml, isPastedFromTinyMCEConfluence } from '../util/tinyMCE';
30
30
  import { handlePaste as handlePasteTable } from '@atlaskit/editor-tables/utils';
31
31
  import { extractSliceFromStep } from '../../../utils/step';
32
- export var stateKey = new PluginKey('pastePlugin');
32
+ import { pluginKey as stateKey, createPluginState } from './plugin-factory';
33
+ export { pluginKey as stateKey } from './plugin-factory';
33
34
  export { md } from '../md';
34
- export function createPlugin(schema, dispatchAnalyticsEvent, plainTextPasteLinkification, cardOptions, sanitizePrivateContent, providerFactory) {
35
+ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, plainTextPasteLinkification, cardOptions, sanitizePrivateContent, providerFactory) {
35
36
  var atlassianMarkDownParser = new MarkdownTransformer(schema, md);
36
37
 
37
38
  function getMarkdownSlice(text, openStart, openEnd) {
38
39
  var textInput = text;
39
40
 
40
- if (textInput.includes(':\\\\')) {
41
- textInput = textInput.replace(/:\\\\/g, ':\\\\\\\\');
41
+ if (textInput.includes('\\')) {
42
+ textInput = textInput.replace(/\\/g, '\\\\');
42
43
  }
43
44
 
44
45
  var doc = atlassianMarkDownParser.parse(escapeLinks(textInput));
@@ -103,6 +104,9 @@ export function createPlugin(schema, dispatchAnalyticsEvent, plainTextPasteLinki
103
104
  var pastedFromBitBucket = false;
104
105
  return new SafePlugin({
105
106
  key: stateKey,
107
+ state: createPluginState(dispatch, {
108
+ pastedMacroPositions: {}
109
+ }),
106
110
  props: {
107
111
  // For serialising to plain text
108
112
  clipboardTextSerializer: clipboardTextSerializer,
@@ -295,6 +299,23 @@ export function createPlugin(schema, dispatchAnalyticsEvent, plainTextPasteLinki
295
299
  }
296
300
 
297
301
  return handleMarkdownWithAnalytics(view, event, markdownSlice)(state, dispatch);
302
+ }
303
+
304
+ if (isRichText && isInsideBlockQuote(state)) {
305
+ //If pasting inside blockquote
306
+ //Skip the blockquote node and keep remaining nodes as they are
307
+ var blockquote = schema.nodes.blockquote;
308
+ var children = [];
309
+ mapChildren(slice.content, function (node) {
310
+ if (node.type === blockquote) {
311
+ for (var i = 0; i < node.childCount; i++) {
312
+ children.push(node.child(i));
313
+ }
314
+ } else {
315
+ children.push(node);
316
+ }
317
+ });
318
+ slice = new Slice(Fragment.fromArray(children), slice.openStart, slice.openEnd);
298
319
  } // finally, handle rich-text copy-paste
299
320
 
300
321
 
@@ -0,0 +1,46 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+
6
+ 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; }
7
+
8
+ import { PluginKey } from 'prosemirror-state';
9
+ import { pluginFactory } from '../../../utils/plugin-state-factory';
10
+ import { reducer } from '../reducer';
11
+ export var pluginKey = new PluginKey('pastePlugin');
12
+
13
+ var _pluginFactory = pluginFactory(pluginKey, reducer, {
14
+ mapping: function mapping(tr, pluginState) {
15
+ if (tr.docChanged) {
16
+ var atLeastOnePositionChanged = false;
17
+ var positionsMappedThroughChanges = Object.entries(pluginState.pastedMacroPositions).reduce(function (acc, _ref) {
18
+ var _ref2 = _slicedToArray(_ref, 2),
19
+ key = _ref2[0],
20
+ position = _ref2[1];
21
+
22
+ var mappedPosition = tr.mapping.map(position);
23
+
24
+ if (position !== mappedPosition) {
25
+ atLeastOnePositionChanged = true;
26
+ }
27
+
28
+ acc[key] = tr.mapping.map(position);
29
+ return acc;
30
+ }, {});
31
+
32
+ if (atLeastOnePositionChanged) {
33
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
34
+ pastedMacroPositions: positionsMappedThroughChanges
35
+ });
36
+ }
37
+ }
38
+
39
+ return pluginState;
40
+ }
41
+ }),
42
+ createPluginState = _pluginFactory.createPluginState,
43
+ createCommand = _pluginFactory.createCommand,
44
+ getPluginState = _pluginFactory.getPluginState;
45
+
46
+ export { createPluginState, createCommand, getPluginState };
@@ -0,0 +1,34 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+
6
+ 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; }
7
+
8
+ import { PastePluginActionTypes as ActionTypes } from './actions';
9
+ export var reducer = function reducer(state, action) {
10
+ switch (action.type) {
11
+ case ActionTypes.START_TRACKING_PASTED_MACRO_POSITIONS:
12
+ {
13
+ return _objectSpread(_objectSpread({}, state), {}, {
14
+ pastedMacroPositions: _objectSpread(_objectSpread({}, state.pastedMacroPositions), action.pastedMacroPositions)
15
+ });
16
+ }
17
+
18
+ case ActionTypes.STOP_TRACKING_PASTED_MACRO_POSITIONS:
19
+ {
20
+ var filteredMacroPositions = Object.fromEntries(Object.entries(state.pastedMacroPositions).filter(function (_ref) {
21
+ var _ref2 = _slicedToArray(_ref, 1),
22
+ key = _ref2[0];
23
+
24
+ return !action.pastedMacroPositionKeys.includes(key);
25
+ }));
26
+ return _objectSpread(_objectSpread({}, state), {}, {
27
+ pastedMacroPositions: filteredMacroPositions
28
+ });
29
+ }
30
+
31
+ default:
32
+ return state;
33
+ }
34
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -8,6 +8,7 @@ import { placeHolderClassName } from './styles';
8
8
  export var pluginKey = new PluginKey('placeholderPlugin');
9
9
  import { focusStateKey } from '../base/pm-plugins/focus-handler';
10
10
  import { isTypeAheadOpen } from '../type-ahead/utils';
11
+ import { isComposing } from '../base/pm-plugins/composition';
11
12
 
12
13
  function getPlaceholderState(editorState) {
13
14
  return pluginKey.getState(editorState);
@@ -134,7 +135,7 @@ export function createPlugin(defaultPlaceholderText, placeholderHints, bracketPl
134
135
  placeholderText = _getPlaceholderState.placeholderText,
135
136
  pos = _getPlaceholderState.pos;
136
137
 
137
- if (hasPlaceholder && placeholderText && pos !== undefined) {
138
+ if (hasPlaceholder && placeholderText && pos !== undefined && !isComposing(editorState)) {
138
139
  return createPlaceholderDecoration(editorState, placeholderText, pos);
139
140
  }
140
141
 
@@ -72,10 +72,16 @@ export function createPlugin(dispatch, options) {
72
72
  var placeholderNodeType = newState.schema.nodes.placeholder;
73
73
 
74
74
  if (adjacentNode && adjacentNode.type === placeholderNodeType && didPlaceholderExistBeforeTxn) {
75
- // Check that cursor has moved forward in the document **and** that there is content before the cursor
76
- var wasContentAdded = oldState.selection.$head.pos < newState.selection.$head.pos && !isNodeEmpty(newState.selection.$head.nodeBefore);
75
+ var _$newHead$nodeBefore;
77
76
 
78
- if (wasContentAdded) {
77
+ var $newHead = newState.selection.$head;
78
+ var $oldHead = oldState.selection.$head; // Check that cursor has moved forward in the document **and** that there is content before the cursor
79
+
80
+ var cursorMoved = $oldHead.pos < $newHead.pos;
81
+ var nodeBeforeHasContent = !isNodeEmpty($newHead.nodeBefore);
82
+ var nodeBeforeIsInline = (_$newHead$nodeBefore = $newHead.nodeBefore) === null || _$newHead$nodeBefore === void 0 ? void 0 : _$newHead$nodeBefore.type.isInline;
83
+
84
+ if (cursorMoved && (nodeBeforeHasContent || nodeBeforeIsInline)) {
79
85
  var _NodeSelection$create = NodeSelection.create(newState.doc, adjacentNodePos),
80
86
  $from = _NodeSelection$create.$from,
81
87
  $to = _NodeSelection$create.$to;
@@ -51,8 +51,11 @@ export var StatusPickerWithoutAnalytcs = /*#__PURE__*/function (_React$Component
51
51
  _defineProperty(_assertThisInitialized(_this), "handleClickOutside", function (event) {
52
52
  event.preventDefault();
53
53
  _this.inputMethod = InputMethod.blur;
54
+ var selectedText = window.getSelection();
54
55
 
55
- _this.props.closeStatusPicker();
56
+ if (!selectedText) {
57
+ _this.props.closeStatusPicker();
58
+ }
56
59
  });
57
60
 
58
61
  _defineProperty(_assertThisInitialized(_this), "handleEscapeKeydown", function (event) {
@@ -55,71 +55,77 @@ export var emptyMultipleCellsWithAnalytics = function emptyMultipleCellsWithAnal
55
55
  };
56
56
  };
57
57
  export var mergeCellsWithAnalytics = function mergeCellsWithAnalytics(editorAnalyticsAPI) {
58
- return withEditorAnalyticsAPI(function (_ref2) {
59
- var selection = _ref2.selection;
60
-
61
- var _getSelectedCellInfo2 = getSelectedCellInfo(selection),
62
- horizontalCells = _getSelectedCellInfo2.horizontalCells,
63
- verticalCells = _getSelectedCellInfo2.verticalCells,
64
- totalCells = _getSelectedCellInfo2.totalCells,
65
- totalRowCount = _getSelectedCellInfo2.totalRowCount,
66
- totalColumnCount = _getSelectedCellInfo2.totalColumnCount;
67
-
68
- return {
69
- action: TABLE_ACTION.MERGED,
70
- actionSubject: ACTION_SUBJECT.TABLE,
71
- actionSubjectId: null,
72
- attributes: {
73
- horizontalCells: horizontalCells,
74
- verticalCells: verticalCells,
75
- totalCells: totalCells,
76
- totalRowCount: totalRowCount,
77
- totalColumnCount: totalColumnCount
78
- },
79
- eventType: EVENT_TYPE.TRACK
80
- };
81
- })(editorAnalyticsAPI)(function (state, dispatch) {
82
- if (dispatch) {
83
- dispatch(mergeCells(state.tr));
84
- }
85
-
86
- return true;
87
- });
88
- };
89
- export var splitCellWithAnalytics = function splitCellWithAnalytics(editorAnalyticsAPI) {
90
- return withEditorAnalyticsAPI(function (_ref3) {
91
- var selection = _ref3.selection;
92
-
93
- var _getSelectedCellInfo3 = getSelectedCellInfo(selection),
94
- totalRowCount = _getSelectedCellInfo3.totalRowCount,
95
- totalColumnCount = _getSelectedCellInfo3.totalColumnCount;
58
+ return function (inputMethod) {
59
+ return withEditorAnalyticsAPI(function (_ref2) {
60
+ var selection = _ref2.selection;
96
61
 
97
- var cell = findCellClosestToPos(selection.$anchor);
62
+ var _getSelectedCellInfo2 = getSelectedCellInfo(selection),
63
+ horizontalCells = _getSelectedCellInfo2.horizontalCells,
64
+ verticalCells = _getSelectedCellInfo2.verticalCells,
65
+ totalCells = _getSelectedCellInfo2.totalCells,
66
+ totalRowCount = _getSelectedCellInfo2.totalRowCount,
67
+ totalColumnCount = _getSelectedCellInfo2.totalColumnCount;
98
68
 
99
- if (cell) {
100
- var _cell$node$attrs = cell.node.attrs,
101
- verticalCells = _cell$node$attrs.rowspan,
102
- horizontalCells = _cell$node$attrs.colspan;
103
69
  return {
104
- action: TABLE_ACTION.SPLIT,
70
+ action: TABLE_ACTION.MERGED,
105
71
  actionSubject: ACTION_SUBJECT.TABLE,
106
72
  actionSubjectId: null,
107
73
  attributes: {
74
+ inputMethod: inputMethod,
108
75
  horizontalCells: horizontalCells,
109
76
  verticalCells: verticalCells,
110
- totalCells: horizontalCells * verticalCells,
77
+ totalCells: totalCells,
111
78
  totalRowCount: totalRowCount,
112
79
  totalColumnCount: totalColumnCount
113
80
  },
114
81
  eventType: EVENT_TYPE.TRACK
115
82
  };
116
- }
83
+ })(editorAnalyticsAPI)(function (state, dispatch) {
84
+ if (dispatch) {
85
+ dispatch(mergeCells(state.tr));
86
+ }
117
87
 
118
- return;
119
- })(editorAnalyticsAPI)(splitCell);
88
+ return true;
89
+ });
90
+ };
91
+ };
92
+ export var splitCellWithAnalytics = function splitCellWithAnalytics(editorAnalyticsAPI) {
93
+ return function (inputMethod) {
94
+ return withEditorAnalyticsAPI(function (_ref3) {
95
+ var selection = _ref3.selection;
96
+
97
+ var _getSelectedCellInfo3 = getSelectedCellInfo(selection),
98
+ totalRowCount = _getSelectedCellInfo3.totalRowCount,
99
+ totalColumnCount = _getSelectedCellInfo3.totalColumnCount;
100
+
101
+ var cell = findCellClosestToPos(selection.$anchor);
102
+
103
+ if (cell) {
104
+ var _cell$node$attrs = cell.node.attrs,
105
+ verticalCells = _cell$node$attrs.rowspan,
106
+ horizontalCells = _cell$node$attrs.colspan;
107
+ return {
108
+ action: TABLE_ACTION.SPLIT,
109
+ actionSubject: ACTION_SUBJECT.TABLE,
110
+ actionSubjectId: null,
111
+ attributes: {
112
+ inputMethod: inputMethod,
113
+ horizontalCells: horizontalCells,
114
+ verticalCells: verticalCells,
115
+ totalCells: horizontalCells * verticalCells,
116
+ totalRowCount: totalRowCount,
117
+ totalColumnCount: totalColumnCount
118
+ },
119
+ eventType: EVENT_TYPE.TRACK
120
+ };
121
+ }
122
+
123
+ return;
124
+ })(editorAnalyticsAPI)(splitCell);
125
+ };
120
126
  };
121
127
  export var setColorWithAnalytics = function setColorWithAnalytics(editorAnalyticsAPI) {
122
- return function (cellColor, targetCellPosition) {
128
+ return function (inputMethod, cellColor, targetCellPosition) {
123
129
  return withEditorAnalyticsAPI(function (_ref4) {
124
130
  var selection = _ref4.selection;
125
131
 
@@ -135,6 +141,7 @@ export var setColorWithAnalytics = function setColorWithAnalytics(editorAnalytic
135
141
  actionSubject: ACTION_SUBJECT.TABLE,
136
142
  actionSubjectId: null,
137
143
  attributes: {
144
+ inputMethod: inputMethod,
138
145
  cellColor: (tableBackgroundColorPalette.get(cellColor.toLowerCase()) || cellColor).toLowerCase(),
139
146
  horizontalCells: horizontalCells,
140
147
  verticalCells: verticalCells,
@@ -5,7 +5,7 @@ import { createTable } from '@atlaskit/editor-tables/utils';
5
5
  import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
6
6
  import { toggleTable, tooltip } from '../../keymaps';
7
7
  import WithPluginState from '../../ui/WithPluginState';
8
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
8
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
9
9
  import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
10
10
  import { IconTable } from '@atlaskit/editor-common/icons';
11
11
  import { pluginConfig } from './create-plugin-config';
@@ -116,21 +116,38 @@ var tablesPlugin = function tablesPlugin(options) {
116
116
  }, {
117
117
  name: 'tableEditing',
118
118
  plugin: function plugin() {
119
- return tableEditing();
119
+ return tableEditing({
120
+ reportFixedTable: function reportFixedTable(_ref5) {
121
+ var _options$editorAnalyt;
122
+
123
+ var state = _ref5.state,
124
+ tr = _ref5.tr,
125
+ reason = _ref5.reason;
126
+ options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
127
+ action: TABLE_ACTION.FIXED,
128
+ actionSubject: ACTION_SUBJECT.TABLE,
129
+ actionSubjectId: null,
130
+ attributes: {
131
+ reason: reason
132
+ },
133
+ eventType: EVENT_TYPE.TRACK
134
+ })(tr);
135
+ }
136
+ });
120
137
  }
121
138
  }, {
122
139
  name: 'tableStickyHeaders',
123
- plugin: function plugin(_ref5) {
124
- var dispatch = _ref5.dispatch,
125
- eventDispatcher = _ref5.eventDispatcher;
140
+ plugin: function plugin(_ref6) {
141
+ var dispatch = _ref6.dispatch,
142
+ eventDispatcher = _ref6.eventDispatcher;
126
143
  return options && options.tableOptions.stickyHeaders ? createStickyHeadersPlugin(dispatch, eventDispatcher, function () {
127
144
  return [];
128
145
  }, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags) : undefined;
129
146
  }
130
147
  }, {
131
148
  name: 'tableLocalId',
132
- plugin: function plugin(_ref6) {
133
- var dispatch = _ref6.dispatch;
149
+ plugin: function plugin(_ref7) {
150
+ var dispatch = _ref7.dispatch;
134
151
  return createTableLocalIdPlugin(dispatch);
135
152
  }
136
153
  }]; // workaround for prosemirrors delayed dom selection syncing during pointer drag
@@ -161,12 +178,12 @@ var tablesPlugin = function tablesPlugin(options) {
161
178
 
162
179
  return plugins;
163
180
  },
164
- contentComponent: function contentComponent(_ref7) {
165
- var editorView = _ref7.editorView,
166
- popupsMountPoint = _ref7.popupsMountPoint,
167
- popupsBoundariesElement = _ref7.popupsBoundariesElement,
168
- popupsScrollableElement = _ref7.popupsScrollableElement,
169
- dispatchAnalyticsEvent = _ref7.dispatchAnalyticsEvent;
181
+ contentComponent: function contentComponent(_ref8) {
182
+ var editorView = _ref8.editorView,
183
+ popupsMountPoint = _ref8.popupsMountPoint,
184
+ popupsBoundariesElement = _ref8.popupsBoundariesElement,
185
+ popupsScrollableElement = _ref8.popupsScrollableElement,
186
+ dispatchAnalyticsEvent = _ref8.dispatchAnalyticsEvent;
170
187
  return /*#__PURE__*/React.createElement(ErrorBoundary, {
171
188
  component: ACTION_SUBJECT.TABLES_PLUGIN,
172
189
  dispatchAnalyticsEvent: dispatchAnalyticsEvent,
@@ -177,25 +194,25 @@ var tablesPlugin = function tablesPlugin(options) {
177
194
  tableResizingPluginState: tableResizingPluginKey,
178
195
  stickyHeadersState: stickyHeadersPluginKey
179
196
  },
180
- render: function render(_ref8) {
181
- var resizingPluginState = _ref8.tableResizingPluginState,
182
- stickyHeadersState = _ref8.stickyHeadersState,
183
- tablePluginState = _ref8.tablePluginState;
197
+ render: function render(_ref9) {
198
+ var resizingPluginState = _ref9.tableResizingPluginState,
199
+ stickyHeadersState = _ref9.stickyHeadersState,
200
+ tablePluginState = _ref9.tablePluginState;
184
201
  var state = editorView.state;
185
202
  var isDragging = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
186
- var _ref9 = tablePluginState,
187
- tableNode = _ref9.tableNode,
188
- tablePos = _ref9.tablePos,
189
- targetCellPosition = _ref9.targetCellPosition,
190
- isContextualMenuOpen = _ref9.isContextualMenuOpen,
191
- layout = _ref9.layout,
192
- tableRef = _ref9.tableRef,
193
- pluginConfig = _ref9.pluginConfig,
194
- insertColumnButtonIndex = _ref9.insertColumnButtonIndex,
195
- insertRowButtonIndex = _ref9.insertRowButtonIndex,
196
- isHeaderColumnEnabled = _ref9.isHeaderColumnEnabled,
197
- isHeaderRowEnabled = _ref9.isHeaderRowEnabled,
198
- tableWrapperTarget = _ref9.tableWrapperTarget;
203
+ var _ref10 = tablePluginState,
204
+ tableNode = _ref10.tableNode,
205
+ tablePos = _ref10.tablePos,
206
+ targetCellPosition = _ref10.targetCellPosition,
207
+ isContextualMenuOpen = _ref10.isContextualMenuOpen,
208
+ layout = _ref10.layout,
209
+ tableRef = _ref10.tableRef,
210
+ pluginConfig = _ref10.pluginConfig,
211
+ insertColumnButtonIndex = _ref10.insertColumnButtonIndex,
212
+ insertRowButtonIndex = _ref10.insertRowButtonIndex,
213
+ isHeaderColumnEnabled = _ref10.isHeaderColumnEnabled,
214
+ isHeaderRowEnabled = _ref10.isHeaderRowEnabled,
215
+ tableWrapperTarget = _ref10.tableWrapperTarget;
199
216
  var allowControls = pluginConfig.allowControls;
200
217
  var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
201
218
  return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && tableRef && !isDragging && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
@@ -260,9 +277,9 @@ var tablesPlugin = function tablesPlugin(options) {
260
277
  pluginsOptions: {
261
278
  // TODO: ED-14676 This is not the final API design
262
279
  // For now, we are using this on (insert-api/api.ts) but we may create a proper place for it
263
- createNodeHandler: function createNodeHandler(_ref10) {
264
- var nodeName = _ref10.nodeName,
265
- schema = _ref10.schema;
280
+ createNodeHandler: function createNodeHandler(_ref11) {
281
+ var nodeName = _ref11.nodeName,
282
+ schema = _ref11.schema;
266
283
 
267
284
  // An EditorPlugin may manage more than one node.
268
285
  if (nodeName !== 'table') {
@@ -274,8 +291,8 @@ var tablesPlugin = function tablesPlugin(options) {
274
291
  });
275
292
  return table;
276
293
  },
277
- quickInsert: function quickInsert(_ref11) {
278
- var formatMessage = _ref11.formatMessage;
294
+ quickInsert: function quickInsert(_ref12) {
295
+ var formatMessage = _ref12.formatMessage;
279
296
  return [{
280
297
  id: 'table',
281
298
  title: formatMessage(messages.table),
@@ -287,12 +304,12 @@ var tablesPlugin = function tablesPlugin(options) {
287
304
  return /*#__PURE__*/React.createElement(IconTable, null);
288
305
  },
289
306
  action: function action(insert, state) {
290
- var _options$editorAnalyt;
307
+ var _options$editorAnalyt2;
291
308
 
292
309
  var tr = insert(createTable({
293
310
  schema: state.schema
294
311
  }));
295
- options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
312
+ options === null || options === void 0 ? void 0 : (_options$editorAnalyt2 = options.editorAnalyticsAPI) === null || _options$editorAnalyt2 === void 0 ? void 0 : _options$editorAnalyt2.attachAnalyticsEvent({
296
313
  action: ACTION.INSERTED,
297
314
  actionSubject: ACTION_SUBJECT.DOCUMENT,
298
315
  actionSubjectId: ACTION_SUBJECT_ID.TABLE,