@atlaskit/editor-core 188.12.0 → 188.12.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 (71) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/cjs/labs/next/presets/universal.js +12 -1
  3. package/dist/cjs/plugins/annotation/index.js +12 -1
  4. package/dist/cjs/plugins/annotation/pm-plugins/inline-comment.js +2 -1
  5. package/dist/cjs/plugins/annotation/pm-plugins/plugin-factory.js +5 -0
  6. package/dist/cjs/plugins/annotation/pm-plugins/reducer.js +2 -1
  7. package/dist/cjs/plugins/annotation/toolbar.js +2 -156
  8. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +33 -31
  9. package/dist/cjs/plugins/layout/actions.js +20 -17
  10. package/dist/cjs/plugins/layout/index.js +6 -2
  11. package/dist/cjs/plugins/panel/index.js +1 -1
  12. package/dist/cjs/plugins/panel/toolbar.js +9 -7
  13. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +0 -6
  14. package/dist/cjs/plugins/rank.js +1 -1
  15. package/dist/cjs/plugins/tasks-and-decisions/index.js +1 -1
  16. package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/keymaps.js +104 -90
  17. package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +4 -2
  18. package/dist/cjs/version-wrapper.js +1 -1
  19. package/dist/es2019/labs/next/presets/universal.js +12 -1
  20. package/dist/es2019/plugins/annotation/index.js +14 -1
  21. package/dist/es2019/plugins/annotation/pm-plugins/inline-comment.js +2 -1
  22. package/dist/es2019/plugins/annotation/pm-plugins/plugin-factory.js +6 -0
  23. package/dist/es2019/plugins/annotation/pm-plugins/reducer.js +2 -1
  24. package/dist/es2019/plugins/annotation/toolbar.js +1 -156
  25. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
  26. package/dist/es2019/plugins/layout/actions.js +4 -3
  27. package/dist/es2019/plugins/layout/index.js +63 -57
  28. package/dist/es2019/plugins/panel/index.js +1 -1
  29. package/dist/es2019/plugins/panel/toolbar.js +9 -7
  30. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +1 -4
  31. package/dist/es2019/plugins/rank.js +1 -1
  32. package/dist/es2019/plugins/tasks-and-decisions/index.js +1 -1
  33. package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +22 -14
  34. package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +4 -2
  35. package/dist/es2019/version-wrapper.js +1 -1
  36. package/dist/esm/labs/next/presets/universal.js +12 -1
  37. package/dist/esm/plugins/annotation/index.js +12 -1
  38. package/dist/esm/plugins/annotation/pm-plugins/inline-comment.js +2 -1
  39. package/dist/esm/plugins/annotation/pm-plugins/plugin-factory.js +5 -0
  40. package/dist/esm/plugins/annotation/pm-plugins/reducer.js +2 -1
  41. package/dist/esm/plugins/annotation/toolbar.js +1 -156
  42. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +33 -31
  43. package/dist/esm/plugins/layout/actions.js +15 -12
  44. package/dist/esm/plugins/layout/index.js +7 -3
  45. package/dist/esm/plugins/panel/index.js +1 -1
  46. package/dist/esm/plugins/panel/toolbar.js +9 -7
  47. package/dist/esm/plugins/paste/pm-plugins/analytics.js +1 -6
  48. package/dist/esm/plugins/rank.js +1 -1
  49. package/dist/esm/plugins/tasks-and-decisions/index.js +1 -1
  50. package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +104 -90
  51. package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +4 -2
  52. package/dist/esm/version-wrapper.js +1 -1
  53. package/dist/types/plugins/annotation/pm-plugins/types.d.ts +1 -0
  54. package/dist/types/plugins/insert-block/types.d.ts +3 -1
  55. package/dist/types/plugins/layout/actions.d.ts +2 -1
  56. package/dist/types/plugins/layout/index.d.ts +4 -0
  57. package/dist/types/plugins/panel/index.d.ts +2 -2
  58. package/dist/types/plugins/panel/toolbar.d.ts +5 -3
  59. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +0 -1
  60. package/dist/types/plugins/tasks-and-decisions/pm-plugins/keymaps.d.ts +7 -4
  61. package/dist/types/plugins/tasks-and-decisions/types.d.ts +5 -1
  62. package/dist/types-ts4.5/plugins/annotation/pm-plugins/types.d.ts +1 -0
  63. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +3 -1
  64. package/dist/types-ts4.5/plugins/layout/actions.d.ts +2 -1
  65. package/dist/types-ts4.5/plugins/layout/index.d.ts +4 -0
  66. package/dist/types-ts4.5/plugins/panel/index.d.ts +2 -2
  67. package/dist/types-ts4.5/plugins/panel/toolbar.d.ts +5 -3
  68. package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +0 -1
  69. package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/keymaps.d.ts +7 -4
  70. package/dist/types-ts4.5/plugins/tasks-and-decisions/types.d.ts +3 -1
  71. package/package.json +6 -2
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { layoutColumn, layoutSection } from '@atlaskit/adf-schema';
3
3
  import { default as createLayoutPlugin } from './pm-plugins/main';
4
4
  import { buildToolbar } from './toolbar';
5
- import { createDefaultLayoutSection } from './actions';
5
+ import { createDefaultLayoutSection, insertLayoutColumnsWithAnalytics } from './actions';
6
6
  import { IconLayout } from '@atlaskit/editor-common/quick-insert';
7
7
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
8
8
  import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
@@ -11,61 +11,67 @@ export { pluginKey };
11
11
  const layoutPlugin = ({
12
12
  config: options = {},
13
13
  api
14
- }) => ({
15
- name: 'layout',
16
- nodes() {
17
- return [{
18
- name: 'layoutSection',
19
- node: layoutSection
20
- }, {
21
- name: 'layoutColumn',
22
- node: layoutColumn
23
- }];
24
- },
25
- pmPlugins() {
26
- return [{
27
- name: 'layout',
28
- plugin: () => createLayoutPlugin(options)
29
- }];
30
- },
31
- pluginsOptions: {
32
- floatingToolbar(state, intl) {
33
- const {
34
- pos,
35
- allowBreakout,
36
- addSidebarLayouts,
37
- allowSingleColumnLayout
38
- } = pluginKey.getState(state);
39
- if (pos !== null) {
40
- var _api$decorations$acti;
41
- return buildToolbar(state, intl, pos, allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api === null || api === void 0 ? void 0 : (_api$decorations$acti = api.decorations.actions) === null || _api$decorations$acti === void 0 ? void 0 : _api$decorations$acti.hoverDecoration);
42
- }
43
- return undefined;
14
+ }) => {
15
+ var _api$analytics;
16
+ return {
17
+ name: 'layout',
18
+ nodes() {
19
+ return [{
20
+ name: 'layoutSection',
21
+ node: layoutSection
22
+ }, {
23
+ name: 'layoutColumn',
24
+ node: layoutColumn
25
+ }];
44
26
  },
45
- quickInsert: ({
46
- formatMessage
47
- }) => [{
48
- id: 'layout',
49
- title: formatMessage(messages.columns),
50
- description: formatMessage(messages.columnsDescription),
51
- keywords: ['column', 'section'],
52
- priority: 1100,
53
- icon: () => /*#__PURE__*/React.createElement(IconLayout, null),
54
- action(insert, state) {
55
- var _api$analytics, _api$analytics$action;
56
- const tr = insert(createDefaultLayoutSection(state));
57
- api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.attachAnalyticsEvent({
58
- action: ACTION.INSERTED,
59
- actionSubject: ACTION_SUBJECT.DOCUMENT,
60
- actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
61
- attributes: {
62
- inputMethod: INPUT_METHOD.QUICK_INSERT
63
- },
64
- eventType: EVENT_TYPE.TRACK
65
- })(tr);
66
- return tr;
67
- }
68
- }]
69
- }
70
- });
27
+ pmPlugins() {
28
+ return [{
29
+ name: 'layout',
30
+ plugin: () => createLayoutPlugin(options)
31
+ }];
32
+ },
33
+ actions: {
34
+ insertLayoutColumns: insertLayoutColumnsWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)
35
+ },
36
+ pluginsOptions: {
37
+ floatingToolbar(state, intl) {
38
+ const {
39
+ pos,
40
+ allowBreakout,
41
+ addSidebarLayouts,
42
+ allowSingleColumnLayout
43
+ } = pluginKey.getState(state);
44
+ if (pos !== null) {
45
+ var _api$decorations$acti;
46
+ return buildToolbar(state, intl, pos, allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api === null || api === void 0 ? void 0 : (_api$decorations$acti = api.decorations.actions) === null || _api$decorations$acti === void 0 ? void 0 : _api$decorations$acti.hoverDecoration);
47
+ }
48
+ return undefined;
49
+ },
50
+ quickInsert: ({
51
+ formatMessage
52
+ }) => [{
53
+ id: 'layout',
54
+ title: formatMessage(messages.columns),
55
+ description: formatMessage(messages.columnsDescription),
56
+ keywords: ['column', 'section'],
57
+ priority: 1100,
58
+ icon: () => /*#__PURE__*/React.createElement(IconLayout, null),
59
+ action(insert, state) {
60
+ var _api$analytics2, _api$analytics2$actio;
61
+ const tr = insert(createDefaultLayoutSection(state));
62
+ api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : (_api$analytics2$actio = _api$analytics2.actions) === null || _api$analytics2$actio === void 0 ? void 0 : _api$analytics2$actio.attachAnalyticsEvent({
63
+ action: ACTION.INSERTED,
64
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
65
+ actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
66
+ attributes: {
67
+ inputMethod: INPUT_METHOD.QUICK_INSERT
68
+ },
69
+ eventType: EVENT_TYPE.TRACK
70
+ })(tr);
71
+ return tr;
72
+ }
73
+ }]
74
+ }
75
+ };
76
+ };
71
77
  export default layoutPlugin;
@@ -142,7 +142,7 @@ const panelPlugin = ({
142
142
  }
143
143
  return quickInsertOptions;
144
144
  },
145
- floatingToolbar: (state, intl, providerFactory) => getToolbarConfig(state, intl, options, providerFactory, api === null || api === void 0 ? void 0 : api.decorations.actions.hoverDecoration)
145
+ floatingToolbar: (state, intl, providerFactory) => getToolbarConfig(state, intl, options, providerFactory, api)
146
146
  }
147
147
  });
148
148
 
@@ -13,7 +13,8 @@ import { findPanel } from './utils';
13
13
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
14
14
  import { DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
15
15
  import { PanelType } from '@atlaskit/adf-schema';
16
- import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID, withAnalytics } from '../analytics';
16
+ import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
17
+ import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
17
18
  import { messages } from './message';
18
19
  export const panelIconMap = {
19
20
  [PanelType.INFO]: {
@@ -41,7 +42,7 @@ export const panelIconMap = {
41
42
  id: 'atlassian-tip'
42
43
  }
43
44
  };
44
- export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabled, isCustomPanelEditable, providerFactory, hoverDecoration, activePanelType, activePanelColor, activePanelIcon, state) => {
45
+ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabled, isCustomPanelEditable, providerFactory, hoverDecoration, editorAnalyticsAPI, activePanelType, activePanelColor, activePanelIcon, state) => {
45
46
  // TODO: ED-14403 investigate why these titles are not getting translated for the tooltips
46
47
  const items = [{
47
48
  id: 'editor.panel.info',
@@ -114,7 +115,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
114
115
  },
115
116
  eventType: EVENT_TYPE.TRACK
116
117
  };
117
- withAnalytics(payload)(changePanelType(PanelType.CUSTOM, {
118
+ withAnalytics(editorAnalyticsAPI, payload)(changePanelType(PanelType.CUSTOM, {
118
119
  color,
119
120
  ...previousEmoji
120
121
  }, isCustomPanelEnabled))(state, dispatch);
@@ -144,7 +145,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
144
145
  },
145
146
  eventType: EVENT_TYPE.TRACK
146
147
  };
147
- withAnalytics(payload)(changePanelType(PanelType.CUSTOM, {
148
+ withAnalytics(editorAnalyticsAPI, payload)(changePanelType(PanelType.CUSTOM, {
148
149
  emoji: emoji.shortName,
149
150
  emojiId: emoji.id,
150
151
  emojiText: emoji.fallback
@@ -168,7 +169,7 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
168
169
  },
169
170
  eventType: EVENT_TYPE.TRACK
170
171
  };
171
- withAnalytics(payload)(changePanelType(PanelType.CUSTOM, {
172
+ withAnalytics(editorAnalyticsAPI, payload)(changePanelType(PanelType.CUSTOM, {
172
173
  emoji: undefined,
173
174
  emojiId: undefined,
174
175
  emojiText: undefined
@@ -243,12 +244,13 @@ export const getToolbarItems = (formatMessage, panelNodeType, isCustomPanelEnabl
243
244
  });
244
245
  return items;
245
246
  };
246
- export const getToolbarConfig = (state, intl, options = {}, providerFactory, hoverDecoration) => {
247
+ export const getToolbarConfig = (state, intl, options = {}, providerFactory, api) => {
247
248
  const {
248
249
  formatMessage
249
250
  } = intl;
250
251
  const panelObject = findPanel(state);
251
252
  if (panelObject) {
253
+ var _api$analytics;
252
254
  const nodeType = state.schema.nodes.panel;
253
255
  const {
254
256
  panelType,
@@ -260,7 +262,7 @@ export const getToolbarConfig = (state, intl, options = {}, providerFactory, hov
260
262
  };
261
263
 
262
264
  // force toolbar to be turned on
263
- const items = getToolbarItems(formatMessage, nodeType, options.allowCustomPanel || false, options.allowCustomPanel && options.allowCustomPanelEdit || false, providerFactory, hoverDecoration, panelType, options.allowCustomPanel ? panelColor : undefined, options.allowCustomPanel ? panelIcon || isStandardPanel(panelType) : undefined, state);
265
+ const items = getToolbarItems(formatMessage, nodeType, options.allowCustomPanel || false, options.allowCustomPanel && options.allowCustomPanelEdit || false, providerFactory, api === null || api === void 0 ? void 0 : api.decorations.actions.hoverDecoration, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, panelType, options.allowCustomPanel ? panelColor : undefined, options.allowCustomPanel ? panelIcon || isStandardPanel(panelType) : undefined, state);
264
266
  const getDomRef = editorView => {
265
267
  const domAtPos = editorView.domAtPos.bind(editorView);
266
268
  const element = findDomRefAtPos(panelObject.pos, domAtPos);
@@ -1,4 +1,4 @@
1
- import { ACTION, INPUT_METHOD, EVENT_TYPE, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, PasteTypes, PasteContents, withAnalytics } from '../../analytics';
1
+ import { ACTION, INPUT_METHOD, EVENT_TYPE, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, PasteTypes, PasteContents } from '../../analytics';
2
2
  import { getPasteSource } from '../util';
3
3
  import { handlePasteAsPlainText, handlePasteIntoTaskOrDecisionOrPanel, handleCodeBlock, handleMediaSingle, handlePastePreservingMarks, handleMarkdown, handleRichText, handleExpandPasteInTable, handleSelectedTable, handlePasteLinkOnSelectedText, handlePasteIntoCaption, handlePastePanelOrDecisionContentIntoList, handlePasteNonNestableBlockNodesIntoList } from '../handlers';
4
4
  import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
@@ -219,9 +219,6 @@ export function sendPasteAnalyticsEvent(view, event, slice, pasteContext) {
219
219
  const payload = createPasteAnalyticsPayload(view, event, slice, pasteContext);
220
220
  view.dispatch(addAnalytics(view.state, view.state.tr, payload));
221
221
  }
222
- export function pasteCommandWithAnalytics(view, event, slice, pasteContext) {
223
- return withAnalytics(() => createPasteAnalyticsPayload(view, event, slice, pasteContext));
224
- }
225
222
  export const handlePasteAsPlainTextWithAnalytics = (view, event, slice) => injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
226
223
  type: PasteTypes.plain,
227
224
  asPlain: true
@@ -13,7 +13,7 @@ export default {
13
13
  'mediaKeymap',
14
14
  // selection keymap needs to be above gap cursor keymap so it can set node selections from
15
15
  // left/right arrows
16
- 'selectionKeymap', 'gapCursorKeymap', 'gapCursor', 'syncUrlText', 'fakeCursorToolbarPlugin', 'hyperLink', 'table', 'tableDecorations', 'hyperlinkInputRule', 'tablePMColResizing', 'hyperlinkKeymap', 'tableColResizing', 'undoRedoKeyMap', 'blockTypeKeyMap', 'tableEditing', 'filterStepsPlugin', 'pmCollab', 'collab', 'ruleInputRule', 'ruleKeymap', 'panel', 'media', 'mediaSingleKeymap', 'mediaEditor', 'unsupportedContent', 'jiraIssue', 'fakeTextCursor', 'helpDialog', 'helpDialogKeymap', 'macro', 'expand', 'extension', 'layout', 'contextPanel', 'floatingToolbar', 'clearMarksOnChange', 'reactNodeView', 'history', 'undoRedoPlugin', 'codeBlockIndent', 'placeholder', 'width', 'maxContentSize', 'multilineContent', 'grid', 'mobileDimensions', 'scrollGutterPlugin', 'analytics', 'findReplace', 'selection', 'avatarGroup', 'viewUpdateSubscription', 'beforePrimaryToolbar', 'inlineCode'],
16
+ 'selectionKeymap', 'gapCursorKeymap', 'gapCursor', 'syncUrlText', 'fakeCursorToolbarPlugin', 'hyperLink', 'table', 'tableDecorations', 'hyperlinkInputRule', 'tablePMColResizing', 'hyperlinkKeymap', 'tableColResizing', 'undoRedoKeyMap', 'blockTypeKeyMap', 'tableEditing', 'filterStepsPlugin', 'pmCollab', 'collab', 'ruleInputRule', 'ruleKeymap', 'panel', 'media', 'mediaSingleKeymap', 'mediaEditor', 'unsupportedContent', 'jiraIssue', 'fakeTextCursor', 'helpDialog', 'helpDialogKeymap', 'macro', 'expand', 'extension', 'layout', 'contextPanel', 'selectionToolbar', 'floatingToolbar', 'clearMarksOnChange', 'reactNodeView', 'history', 'undoRedoPlugin', 'codeBlockIndent', 'placeholder', 'width', 'maxContentSize', 'multilineContent', 'grid', 'mobileDimensions', 'scrollGutterPlugin', 'analytics', 'findReplace', 'selection', 'avatarGroup', 'viewUpdateSubscription', 'beforePrimaryToolbar', 'inlineCode'],
17
17
  nodes: ['doc', 'paragraph', 'text', 'bulletList', 'orderedList', 'listItem', 'heading', 'blockquote', 'codeBlock', 'rule', 'panel', 'mention', 'confluenceUnsupportedBlock', 'confluenceUnsupportedInline', 'unsupportedBlock', 'unsupportedInline', 'confluenceJiraIssue', 'hardBreak', 'emoji', 'placeholder', 'mediaSingle', 'mediaGroup', 'table', 'expand', 'nestedExpand', 'media', 'tableHeader', 'decisionList', 'tableRow', 'decisionItem', 'tableCell', 'taskList', 'taskItem', 'extension', 'bodiedExtension', 'inlineExtension', 'layoutSection', 'layoutColumn', 'inlineCard', 'blockCard', 'embedCard'],
18
18
  marks: [
19
19
  // Fragment mark is both for inline and block elements
@@ -72,7 +72,7 @@ const tasksAndDecisionsPlugin = ({
72
72
  name: 'tasksAndDecisionsKeyMap',
73
73
  plugin: ({
74
74
  schema
75
- }) => keymap(schema, allowNestedTasks, consumeTabs)
75
+ }) => keymap(schema, api, allowNestedTasks, consumeTabs)
76
76
  } // Needs to be after "save-on-enter"
77
77
  ];
78
78
  },
@@ -6,7 +6,8 @@ import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
6
6
  import { findParentNodeOfType, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
7
7
  import { uuid } from '@atlaskit/adf-schema';
8
8
  import { filterCommand as filter, isEmptySelectionAtStart, isEmptySelectionAtEnd, deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
9
- import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INDENT_DIRECTION, INDENT_TYPE, INPUT_METHOD, withAnalytics } from '../../analytics';
9
+ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INDENT_DIRECTION, INDENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
10
+ import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
10
11
  import { insertTaskDecisionWithAnalytics } from '../commands';
11
12
  import { joinAtCut, liftSelection, wrapSelectionInTaskList } from './commands';
12
13
  import { getBlockRange, getCurrentIndentLevel, isActionOrDecisionItem, isActionOrDecisionList, isEmptyTaskDecision, isInsideTask, isInsideTaskOrDecisionItem, liftBlock, walkOut, getTaskItemIndex, isInsideDecision, isTable } from './helpers';
@@ -82,13 +83,13 @@ const joinTaskDecisionFollowing = (state, dispatch) => {
82
83
  }
83
84
  return false;
84
85
  };
85
- export const getUnindentCommand = (inputMethod = INPUT_METHOD.KEYBOARD) => filter(isInsideTask, (state, dispatch) => {
86
+ export const getUnindentCommand = editorAnalyticsAPI => (inputMethod = INPUT_METHOD.KEYBOARD) => filter(isInsideTask, (state, dispatch) => {
86
87
  const normalizedSelection = normalizeTaskItemsSelection(state.selection);
87
88
  const curIndentLevel = getCurrentIndentLevel(normalizedSelection);
88
89
  if (!curIndentLevel || curIndentLevel === 1) {
89
90
  return false;
90
91
  }
91
- return withAnalytics(indentationAnalytics(curIndentLevel, INDENT_DIRECTION.OUTDENT, inputMethod))(autoJoin(liftSelection, ['taskList']))(state, dispatch);
92
+ return withAnalytics(editorAnalyticsAPI, indentationAnalytics(curIndentLevel, INDENT_DIRECTION.OUTDENT, inputMethod))(autoJoin(liftSelection, ['taskList']))(state, dispatch);
92
93
  });
93
94
 
94
95
  // if selection is decision item or first action item in table cell
@@ -106,15 +107,15 @@ const shouldLetTabThroughInTable = state => {
106
107
  }
107
108
  return false;
108
109
  };
109
- export const getIndentCommand = (inputMethod = INPUT_METHOD.KEYBOARD) => filter(isInsideTask, (state, dispatch) => {
110
+ export const getIndentCommand = editorAnalyticsAPI => (inputMethod = INPUT_METHOD.KEYBOARD) => filter(isInsideTask, (state, dispatch) => {
110
111
  const normalizedSelection = normalizeTaskItemsSelection(state.selection);
111
112
  const curIndentLevel = getCurrentIndentLevel(normalizedSelection);
112
113
  if (!curIndentLevel || curIndentLevel >= 6) {
113
114
  return true;
114
115
  }
115
- return withAnalytics(indentationAnalytics(curIndentLevel, INDENT_DIRECTION.INDENT, inputMethod))(autoJoin(wrapSelectionInTaskList, ['taskList']))(state, dispatch);
116
+ return withAnalytics(editorAnalyticsAPI, indentationAnalytics(curIndentLevel, INDENT_DIRECTION.INDENT, inputMethod))(autoJoin(wrapSelectionInTaskList, ['taskList']))(state, dispatch);
116
117
  });
117
- const backspaceFrom = $from => (state, dispatch) => {
118
+ const backspaceFrom = editorAnalyticsAPI => $from => (state, dispatch) => {
118
119
  // previous was empty, just delete backwards
119
120
  const taskBefore = $from.doc.resolve($from.before());
120
121
  if (taskBefore.nodeBefore && isActionOrDecisionItem(taskBefore.nodeBefore) && taskBefore.nodeBefore.nodeSize === 2) {
@@ -127,7 +128,7 @@ const backspaceFrom = $from => (state, dispatch) => {
127
128
  paragraph
128
129
  } = state.schema.nodes;
129
130
  if ($from.node($from.depth - 2).type === taskList) {
130
- return getUnindentCommand()(state, dispatch);
131
+ return getUnindentCommand(editorAnalyticsAPI)()(state, dispatch);
131
132
  }
132
133
 
133
134
  // bottom level, should "unwrap" taskItem contents into paragraph
@@ -144,7 +145,7 @@ const backspaceFrom = $from => (state, dispatch) => {
144
145
  }
145
146
  return false;
146
147
  };
147
- const backspace = filter(isEmptySelectionAtStart, autoJoin(chainCommands((state, dispatch) => joinAtCut(state.selection.$from)(state, dispatch), filter(isInsideTaskOrDecisionItem, (state, dispatch) => backspaceFrom(state.selection.$from)(state, dispatch))), ['taskList', 'decisionList']));
148
+ const backspace = editorAnalyticsAPI => filter(isEmptySelectionAtStart, autoJoin(chainCommands((state, dispatch) => joinAtCut(state.selection.$from)(state, dispatch), filter(isInsideTaskOrDecisionItem, (state, dispatch) => backspaceFrom(editorAnalyticsAPI)(state.selection.$from)(state, dispatch))), ['taskList', 'decisionList']));
148
149
  const unindentTaskOrUnwrapTaskDecisionFollowing = (state, dispatch) => {
149
150
  const {
150
151
  selection: {
@@ -271,7 +272,7 @@ const splitListItem = (state, dispatch) => {
271
272
  }
272
273
  return false;
273
274
  };
274
- const enter = filter(isInsideTaskOrDecisionItem, chainCommands(filter(isEmptyTaskDecision, chainCommands(getUnindentCommand(), splitListItem)), (state, dispatch) => {
275
+ const enter = editorAnalyticsAPI => filter(isInsideTaskOrDecisionItem, chainCommands(filter(isEmptyTaskDecision, chainCommands(getUnindentCommand(editorAnalyticsAPI)(), splitListItem)), (state, dispatch) => {
275
276
  const {
276
277
  selection,
277
278
  schema
@@ -340,20 +341,27 @@ const cmdOptEnter = filter(isInsideTaskOrDecisionItem, (state, dispatch) => {
340
341
  }
341
342
  return true;
342
343
  });
343
- export function keymapPlugin(schema, allowNestedTasks, consumeTabs) {
344
+ export function keymapPlugin(schema, api, allowNestedTasks, consumeTabs) {
345
+ var _api$analytics3, _api$analytics4;
344
346
  const indentHandlers = {
345
- 'Shift-Tab': filter([isInsideTaskOrDecisionItem, state => !shouldLetTabThroughInTable(state)], (state, dispatch) => getUnindentCommand(INPUT_METHOD.KEYBOARD)(state, dispatch) || !!consumeTabs),
346
- Tab: filter([isInsideTaskOrDecisionItem, state => !shouldLetTabThroughInTable(state)], (state, dispatch) => getIndentCommand(INPUT_METHOD.KEYBOARD)(state, dispatch) || !!consumeTabs)
347
+ 'Shift-Tab': filter([isInsideTaskOrDecisionItem, state => !shouldLetTabThroughInTable(state)], (state, dispatch) => {
348
+ var _api$analytics;
349
+ return getUnindentCommand(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(INPUT_METHOD.KEYBOARD)(state, dispatch) || !!consumeTabs;
350
+ }),
351
+ Tab: filter([isInsideTaskOrDecisionItem, state => !shouldLetTabThroughInTable(state)], (state, dispatch) => {
352
+ var _api$analytics2;
353
+ return getIndentCommand(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(INPUT_METHOD.KEYBOARD)(state, dispatch) || !!consumeTabs;
354
+ })
347
355
  };
348
356
  const defaultHandlers = consumeTabs ? {
349
357
  'Shift-Tab': isInsideTaskOrDecisionItem,
350
358
  Tab: isInsideTaskOrDecisionItem
351
359
  } : {};
352
360
  const keymaps = {
353
- Backspace: backspace,
361
+ Backspace: backspace(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
354
362
  Delete: deleteForwards,
355
363
  'Ctrl-d': deleteForwards,
356
- Enter: enter,
364
+ Enter: enter(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions),
357
365
  [toggleTaskItemCheckbox.common]: cmdOptEnter,
358
366
  ...(allowNestedTasks ? indentHandlers : defaultHandlers)
359
367
  };
@@ -24,7 +24,8 @@ export const onItemActivated = pluginInjectionApi => ({
24
24
  pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.commands.indentList(INPUT_METHOD.TOOLBAR));
25
25
  }
26
26
  if (node === 'taskList') {
27
- indentTaskList(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
27
+ var _pluginInjectionApi$a;
28
+ indentTaskList(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
28
29
  }
29
30
  break;
30
31
  }
@@ -39,7 +40,8 @@ export const onItemActivated = pluginInjectionApi => ({
39
40
  pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.commands.outdentList(INPUT_METHOD.TOOLBAR));
40
41
  }
41
42
  if (node === 'taskList') {
42
- outdentTaskList(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
43
+ var _pluginInjectionApi$a2;
44
+ outdentTaskList(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
43
45
  }
44
46
  break;
45
47
  }
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "188.12.0";
2
+ export const version = "188.12.1";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -24,6 +24,7 @@ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
24
24
  import { saveOnEnterPlugin } from '@atlaskit/editor-plugin-save-on-enter';
25
25
  import { scrollIntoViewPlugin } from '@atlaskit/editor-plugin-scroll-into-view';
26
26
  import { mentionsPlugin } from '@atlaskit/editor-plugin-mentions';
27
+ import { selectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
27
28
  import { isFullPage as fullPageCheck } from '../../../utils/is-full-page';
28
29
  import { getMediaFeatureFlag } from '@atlaskit/media-common';
29
30
  import { createDefaultPreset } from './default';
@@ -394,6 +395,16 @@ export default function createUniversalPreset(appearance, props, featureFlags, p
394
395
  return builder;
395
396
  }).add([codeBidiWarningPlugin, {
396
397
  appearance: appearance
397
- }]);
398
+ }])
399
+ /**
400
+ * Do not use this plugin - it is for AI purposes only.
401
+ */.maybeAdd(selectionToolbarPlugin, function (plugin, builder) {
402
+ if (getBooleanFF('platform.editor.enable-selection-toolbar_ucdwd')) {
403
+ return builder.add([plugin, {
404
+ preferenceToolbarAboveSelection: false
405
+ }]);
406
+ }
407
+ return builder;
408
+ });
398
409
  return finalPreset;
399
410
  }
@@ -7,6 +7,7 @@ import { getPluginState } from './utils';
7
7
  import { buildToolbar } from './toolbar';
8
8
  import { InlineCommentView } from './ui/InlineCommentView';
9
9
  import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
10
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
11
  var annotationPlugin = function annotationPlugin(_ref) {
11
12
  var annotationProviders = _ref.config,
12
13
  api = _ref.api;
@@ -53,7 +54,17 @@ var annotationPlugin = function annotationPlugin(_ref) {
53
54
  },
54
55
  pluginsOptions: {
55
56
  floatingToolbar: function floatingToolbar(state, intl) {
56
- if (!annotationProviders) {
57
+ if (getBooleanFF('platform.editor.enable-selection-toolbar_ucdwd') || !annotationProviders) {
58
+ return;
59
+ }
60
+ var pluginState = getPluginState(state);
61
+ if (pluginState && pluginState.isVisible && !pluginState.bookmark && !pluginState.mouseData.isSelecting) {
62
+ var isToolbarAbove = annotationProviders.inlineComment.isToolbarAbove;
63
+ return buildToolbar(state, intl, isToolbarAbove);
64
+ }
65
+ },
66
+ selectionToolbar: function selectionToolbar(state, intl) {
67
+ if (!getBooleanFF('platform.editor.enable-selection-toolbar_ucdwd') || !annotationProviders) {
57
68
  return;
58
69
  }
59
70
  var pluginState = getPluginState(state);
@@ -77,7 +77,8 @@ var initialState = function initialState() {
77
77
  isSelecting: false
78
78
  },
79
79
  disallowOnWhitespace: disallowOnWhitespace,
80
- isVisible: true
80
+ isVisible: true,
81
+ skipSelectionHandling: false
81
82
  };
82
83
  };
83
84
  var hideToolbar = function hideToolbar(state, dispatch) {
@@ -13,6 +13,11 @@ var handleDocChanged = function handleDocChanged(tr, prevPluginState) {
13
13
  });
14
14
  };
15
15
  var handleSelectionChanged = function handleSelectionChanged(tr, pluginState) {
16
+ if (pluginState.skipSelectionHandling) {
17
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
18
+ skipSelectionHandling: false
19
+ });
20
+ }
16
21
  var selectedAnnotations = findAnnotationsInSelection(tr.selection, tr.doc);
17
22
  var changed = selectedAnnotations.length !== pluginState.selectedAnnotations.length || selectedAnnotations.some(function (annotationInfo) {
18
23
  return !pluginState.selectedAnnotations.some(function (aInfo) {
@@ -43,7 +43,8 @@ export default (function (pluginState, action) {
43
43
  });
44
44
  case ACTIONS.SET_SELECTED_ANNOTATION:
45
45
  return _objectSpread(_objectSpread({}, pluginState), {}, {
46
- selectedAnnotations: _toConsumableArray(action.data.selectedAnnotations)
46
+ selectedAnnotations: _toConsumableArray(action.data.selectedAnnotations),
47
+ skipSelectionHandling: true
47
48
  });
48
49
  default:
49
50
  return pluginState;
@@ -1,166 +1,11 @@
1
1
  import React from 'react';
2
2
  import CommentIcon from '@atlaskit/icon/glyph/comment';
3
- // AFP-2532 TODO: Fix automatic suppressions below
4
- // eslint-disable-next-line @atlassian/tangerine/import/entry-points
5
3
  import { addInlineComment, ToolTipContent } from '../../keymaps';
6
4
  import { setInlineCommentDraftState } from './commands';
7
5
  import { AnnotationTestIds, AnnotationSelectionType } from './types';
8
6
  import { isSelectionValid } from './utils';
9
7
  import { annotationMessages } from '@atlaskit/editor-common/messages';
10
-
11
- /**
12
- * Returns the coordintes at the bottom the selection.
13
- */
14
- var getCoordsBelowSelection = function getCoordsBelowSelection(bottomCoords, toolbarRect) {
15
- return {
16
- top: (bottomCoords.top || 0) + toolbarRect.height / 1.15,
17
- left: bottomCoords.right - toolbarRect.width / 2
18
- };
19
- };
20
-
21
- /*
22
- Calculates the position of the floating toolbar relative to the selection.
23
-
24
- This is a re-implementation which closely matches the behaviour on Confluence renderer.
25
- The main difference is the popup is always above the selection.
26
-
27
- Things to consider:
28
- - popup is always above the selection
29
- - coordinates of head X and getBoundingClientRect() are absolute in client viewport (not including scroll offsets)
30
- - popup may appear in '.fabric-editor-popup-scroll-parent' (or body)
31
- - we use the toolbarRect to center align toolbar
32
- - use wrapperBounds to clamp values
33
- - editorView.dom bounds differ to wrapperBounds, convert at the end
34
- */
35
- var calculateToolbarPositionAboveSelection = function calculateToolbarPositionAboveSelection(toolbarTitle) {
36
- return function (editorView, nextPos) {
37
- var toolbar = document.querySelector("div[aria-label=\"".concat(toolbarTitle, "\"]"));
38
- if (!toolbar) {
39
- return nextPos;
40
- }
41
-
42
- // scroll wrapper for full page, fall back to document body
43
- // TODO: look into using getScrollGutterOptions()
44
- var scrollWrapper = editorView.dom.closest('.fabric-editor-popup-scroll-parent') || document.body;
45
- var wrapperBounds = scrollWrapper.getBoundingClientRect();
46
- var selection = window && window.getSelection();
47
- var range = selection && !selection.isCollapsed && selection.getRangeAt(0);
48
- if (!range) {
49
- return nextPos;
50
- }
51
- var toolbarRect = toolbar.getBoundingClientRect();
52
- var _editorView$state$sel = editorView.state.selection,
53
- head = _editorView$state$sel.head,
54
- anchor = _editorView$state$sel.anchor;
55
- var topCoords = editorView.coordsAtPos(Math.min(head, anchor));
56
- var bottomCoords = editorView.coordsAtPos(Math.max(head, anchor) - Math.min(range.endOffset, 1));
57
- var top = (topCoords.top || 0) - toolbarRect.height * 1.5;
58
- var left = 0;
59
-
60
- // If not on the same line
61
- if (topCoords.top !== bottomCoords.top) {
62
- // selecting downwards
63
- if (head > anchor) {
64
- left = Math.max(topCoords.right, bottomCoords.right);
65
- } else {
66
- left = Math.min(topCoords.left, bottomCoords.left);
67
- }
68
-
69
- /*
70
- short selection above a long paragraph
71
- eg. short {<}heading
72
- The purpose of this text is to show the selection range{>}.
73
- The horizontal positioning should center around "heading",
74
- not where it ends at "range".
75
- Note: if it was "head<b>ing</b>" then it would only center
76
- around "head". Undesireable but matches the current renderer.
77
- */
78
- var cliffPosition = range.getClientRects()[0];
79
- if (cliffPosition.right < left) {
80
- left = cliffPosition.left + cliffPosition.width / 2;
81
- }
82
- } else {
83
- // Otherwise center on the single line selection
84
- left = topCoords.left + (bottomCoords.right - topCoords.left) / 2;
85
- }
86
- left -= toolbarRect.width / 2;
87
-
88
- // Place toolbar below selection if not sufficient space above
89
- if (top < wrapperBounds.top) {
90
- var _getCoordsBelowSelect = getCoordsBelowSelection(bottomCoords, toolbarRect);
91
- top = _getCoordsBelowSelect.top;
92
- left = _getCoordsBelowSelect.left;
93
- }
94
-
95
- // remap positions from browser document to wrapperBounds
96
- return {
97
- top: top - wrapperBounds.top + scrollWrapper.scrollTop,
98
- left: Math.max(0, left - wrapperBounds.left)
99
- };
100
- };
101
- };
102
-
103
- /*
104
- Calculates the position of the floating toolbar relative to the selection.
105
-
106
- This is a re-implementation which closely matches the behaviour on Confluence renderer.
107
- The main difference is the popup is always above the selection.
108
-
109
- Things to consider:
110
- - stick as close to the head X release coordinates as possible
111
- - coordinates of head X and getBoundingClientRect() are absolute in client viewport (not including scroll offsets)
112
- - popup may appear in '.fabric-editor-popup-scroll-parent' (or body)
113
- - we use the toolbarRect to center align toolbar
114
- - use wrapperBounds to clamp values
115
- - editorView.dom bounds differ to wrapperBounds, convert at the end
116
- */
117
- var calculateToolbarPositionTrackHead = function calculateToolbarPositionTrackHead(toolbarTitle) {
118
- return function (editorView, nextPos) {
119
- var toolbar = document.querySelector("div[aria-label=\"".concat(toolbarTitle, "\"]"));
120
- if (!toolbar) {
121
- return nextPos;
122
- }
123
-
124
- // scroll wrapper for full page, fall back to document body
125
- // TODO: look into using getScrollGutterOptions()
126
- var scrollWrapper = editorView.dom.closest('.fabric-editor-popup-scroll-parent') || document.body;
127
- var wrapperBounds = scrollWrapper.getBoundingClientRect();
128
- var selection = window && window.getSelection();
129
- var range = selection && !selection.isCollapsed && selection.getRangeAt(0);
130
- if (!range) {
131
- return nextPos;
132
- }
133
- var toolbarRect = toolbar.getBoundingClientRect();
134
- var _editorView$state$sel2 = editorView.state.selection,
135
- head = _editorView$state$sel2.head,
136
- anchor = _editorView$state$sel2.anchor;
137
- var topCoords = editorView.coordsAtPos(Math.min(head, anchor));
138
- var bottomCoords = editorView.coordsAtPos(Math.max(head, anchor) - Math.min(range.endOffset, 1));
139
- var top;
140
- // If not the same line, display toolbar below.
141
- if (head > anchor && topCoords.top !== bottomCoords.top) {
142
- // We are taking the previous pos to the maxium, so avoid end of line positions
143
- // returning the next line's rect.
144
- top = (bottomCoords.top || 0) + toolbarRect.height / 1.15;
145
- } else {
146
- top = (topCoords.top || 0) - toolbarRect.height * 1.5;
147
- }
148
- var left = (head > anchor ? bottomCoords.right : topCoords.left) - toolbarRect.width / 2;
149
-
150
- // Place toolbar below selection if not sufficient space above
151
- if (top < wrapperBounds.top) {
152
- var _getCoordsBelowSelect2 = getCoordsBelowSelection(bottomCoords, toolbarRect);
153
- top = _getCoordsBelowSelect2.top;
154
- left = _getCoordsBelowSelect2.left;
155
- }
156
-
157
- // remap positions from browser document to wrapperBounds
158
- return {
159
- top: top - wrapperBounds.top + scrollWrapper.scrollTop,
160
- left: Math.max(0, left - wrapperBounds.left)
161
- };
162
- };
163
- };
8
+ import { calculateToolbarPositionAboveSelection, calculateToolbarPositionTrackHead } from '@atlaskit/editor-common/utils';
164
9
  export var buildToolbar = function buildToolbar(state, intl) {
165
10
  var isToolbarAbove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
166
11
  var schema = state.schema;