@atlaskit/editor-core 187.43.8 → 187.43.12

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 (92) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/labs/next/presets/default.js +2 -2
  3. package/dist/cjs/plugins/index.js +0 -7
  4. package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +1 -1
  5. package/dist/cjs/plugins/media/pm-plugins/main.js +6 -0
  6. package/dist/cjs/plugins/media/toolbar/index.js +3 -5
  7. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +3 -1
  8. package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/helpers.js +111 -2
  9. package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/main.js +108 -7
  10. package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/types.js +12 -0
  11. package/dist/cjs/version-wrapper.js +1 -1
  12. package/dist/es2019/labs/next/presets/default.js +1 -1
  13. package/dist/es2019/plugins/index.js +0 -1
  14. package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +1 -1
  15. package/dist/es2019/plugins/media/pm-plugins/main.js +6 -0
  16. package/dist/es2019/plugins/media/toolbar/index.js +3 -7
  17. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +4 -1
  18. package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/helpers.js +121 -1
  19. package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/main.js +113 -5
  20. package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/types.js +5 -0
  21. package/dist/es2019/version-wrapper.js +1 -1
  22. package/dist/esm/labs/next/presets/default.js +1 -1
  23. package/dist/esm/plugins/index.js +0 -1
  24. package/dist/esm/plugins/media/nodeviews/mediaSingle.js +1 -1
  25. package/dist/esm/plugins/media/pm-plugins/main.js +6 -0
  26. package/dist/esm/plugins/media/toolbar/index.js +3 -5
  27. package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +3 -1
  28. package/dist/esm/plugins/tasks-and-decisions/pm-plugins/helpers.js +102 -1
  29. package/dist/esm/plugins/tasks-and-decisions/pm-plugins/main.js +106 -5
  30. package/dist/esm/plugins/tasks-and-decisions/pm-plugins/types.js +5 -0
  31. package/dist/esm/version-wrapper.js +1 -1
  32. package/dist/types/plugins/help-dialog/index.d.ts +4 -4
  33. package/dist/types/plugins/index.d.ts +0 -1
  34. package/dist/types/plugins/insert-block/types.d.ts +2 -2
  35. package/dist/types/plugins/media/pm-plugins/main.d.ts +1 -0
  36. package/dist/types/plugins/media/pm-plugins/types.d.ts +1 -0
  37. package/dist/types/plugins/tasks-and-decisions/pm-plugins/helpers.d.ts +23 -1
  38. package/dist/types/plugins/tasks-and-decisions/pm-plugins/types.d.ts +8 -0
  39. package/dist/types/plugins/tasks-and-decisions/ui/Task/index.d.ts +1 -0
  40. package/dist/types/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.d.ts +1 -0
  41. package/dist/types-ts4.5/plugins/help-dialog/index.d.ts +4 -4
  42. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  43. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +2 -2
  44. package/dist/types-ts4.5/plugins/media/pm-plugins/main.d.ts +1 -0
  45. package/dist/types-ts4.5/plugins/media/pm-plugins/types.d.ts +1 -0
  46. package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/helpers.d.ts +23 -1
  47. package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/types.d.ts +8 -0
  48. package/dist/types-ts4.5/plugins/tasks-and-decisions/ui/Task/index.d.ts +1 -0
  49. package/dist/types-ts4.5/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.d.ts +1 -0
  50. package/package.json +7 -6
  51. package/report.api.md +2 -0
  52. package/tmp/api-report-tmp.d.ts +2 -0
  53. package/dist/cjs/plugins/quick-insert/commands.js +0 -44
  54. package/dist/cjs/plugins/quick-insert/index.js +0 -189
  55. package/dist/cjs/plugins/quick-insert/plugin-key.js +0 -9
  56. package/dist/cjs/plugins/quick-insert/search.js +0 -33
  57. package/dist/cjs/plugins/quick-insert/ui/ModalElementBrowser/ModalElementBrowser.js +0 -140
  58. package/dist/cjs/plugins/quick-insert/ui/ModalElementBrowser/categories.js +0 -100
  59. package/dist/cjs/plugins/quick-insert/ui/ModalElementBrowser/index.js +0 -61
  60. package/dist/cjs/plugins/quick-insert/ui/ModalElementBrowser/messages.js +0 -15
  61. package/dist/es2019/plugins/quick-insert/commands.js +0 -29
  62. package/dist/es2019/plugins/quick-insert/index.js +0 -151
  63. package/dist/es2019/plugins/quick-insert/plugin-key.js +0 -2
  64. package/dist/es2019/plugins/quick-insert/search.js +0 -16
  65. package/dist/es2019/plugins/quick-insert/ui/ModalElementBrowser/ModalElementBrowser.js +0 -137
  66. package/dist/es2019/plugins/quick-insert/ui/ModalElementBrowser/categories.js +0 -94
  67. package/dist/es2019/plugins/quick-insert/ui/ModalElementBrowser/index.js +0 -51
  68. package/dist/es2019/plugins/quick-insert/ui/ModalElementBrowser/messages.js +0 -8
  69. package/dist/esm/plugins/quick-insert/commands.js +0 -35
  70. package/dist/esm/plugins/quick-insert/index.js +0 -181
  71. package/dist/esm/plugins/quick-insert/plugin-key.js +0 -2
  72. package/dist/esm/plugins/quick-insert/search.js +0 -25
  73. package/dist/esm/plugins/quick-insert/ui/ModalElementBrowser/ModalElementBrowser.js +0 -128
  74. package/dist/esm/plugins/quick-insert/ui/ModalElementBrowser/categories.js +0 -94
  75. package/dist/esm/plugins/quick-insert/ui/ModalElementBrowser/index.js +0 -50
  76. package/dist/esm/plugins/quick-insert/ui/ModalElementBrowser/messages.js +0 -8
  77. package/dist/types/plugins/quick-insert/commands.d.ts +0 -5
  78. package/dist/types/plugins/quick-insert/index.d.ts +0 -16
  79. package/dist/types/plugins/quick-insert/plugin-key.d.ts +0 -3
  80. package/dist/types/plugins/quick-insert/search.d.ts +0 -5
  81. package/dist/types/plugins/quick-insert/ui/ModalElementBrowser/ModalElementBrowser.d.ts +0 -18
  82. package/dist/types/plugins/quick-insert/ui/ModalElementBrowser/categories.d.ts +0 -5
  83. package/dist/types/plugins/quick-insert/ui/ModalElementBrowser/index.d.ts +0 -11
  84. package/dist/types/plugins/quick-insert/ui/ModalElementBrowser/messages.d.ts +0 -7
  85. package/dist/types-ts4.5/plugins/quick-insert/commands.d.ts +0 -5
  86. package/dist/types-ts4.5/plugins/quick-insert/index.d.ts +0 -16
  87. package/dist/types-ts4.5/plugins/quick-insert/plugin-key.d.ts +0 -3
  88. package/dist/types-ts4.5/plugins/quick-insert/search.d.ts +0 -5
  89. package/dist/types-ts4.5/plugins/quick-insert/ui/ModalElementBrowser/ModalElementBrowser.d.ts +0 -18
  90. package/dist/types-ts4.5/plugins/quick-insert/ui/ModalElementBrowser/categories.d.ts +0 -5
  91. package/dist/types-ts4.5/plugins/quick-insert/ui/ModalElementBrowser/index.d.ts +0 -11
  92. package/dist/types-ts4.5/plugins/quick-insert/ui/ModalElementBrowser/messages.d.ts +0 -7
@@ -6,10 +6,9 @@ import { createSelectionClickHandler } from '../../selection/utils';
6
6
  import { decisionItemNodeView } from '../nodeviews/decisionItem';
7
7
  import { taskItemNodeViewFactory } from '../nodeviews/taskItem';
8
8
  import { stateKey } from './plugin-key';
9
- var ACTIONS = /*#__PURE__*/function (ACTIONS) {
10
- ACTIONS[ACTIONS["SET_CONTEXT_PROVIDER"] = 0] = "SET_CONTEXT_PROVIDER";
11
- return ACTIONS;
12
- }(ACTIONS || {});
9
+ import { getTaskItemDataToFocus, getTaskItemDataAtPos, focusCheckboxAndUpdateSelection, removeCheckboxFocus } from './helpers';
10
+ import { GapCursorSelection } from '@atlaskit/editor-common/selection';
11
+ import { ACTIONS } from './types';
13
12
  const setContextIdentifierProvider = provider => (state, dispatch) => {
14
13
  if (dispatch) {
15
14
  dispatch(state.tr.setMeta(stateKey, {
@@ -54,7 +53,110 @@ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory
54
53
  },
55
54
  handleClickOn: createSelectionClickHandler(['decisionItem'], target => target.hasAttribute('data-decision-wrapper') || target.getAttribute('aria-label') === 'Decision', {
56
55
  useLongPressSelection
57
- })
56
+ }),
57
+ handleKeyDown: (view, event) => {
58
+ const {
59
+ state,
60
+ dispatch
61
+ } = view;
62
+ const {
63
+ selection,
64
+ schema
65
+ } = state;
66
+ const {
67
+ $from,
68
+ $to
69
+ } = selection;
70
+ const parentOffset = $from.parentOffset;
71
+ const isInTaskItem = $from.node().type === schema.nodes.taskItem;
72
+ const focusedTaskItemLocalId = stateKey.getState(state).focusedTaskItemLocalId;
73
+ const currentTaskItemData = getTaskItemDataAtPos(view);
74
+ const currentTaskItemFocused = focusedTaskItemLocalId === (currentTaskItemData === null || currentTaskItemData === void 0 ? void 0 : currentTaskItemData.localId);
75
+
76
+ // if task item checkbox not focused and arrow key is not pressed
77
+ // then we don't want to handle event.
78
+ if (!['ArrowUp', 'ArrowDown', 'ArrowRight', 'ArrowLeft'].includes(event.key)) {
79
+ return false;
80
+ }
81
+
82
+ // We want to handle arrow up, down and left key only
83
+ // when selection is inside task item and no text is selected.
84
+ if (['ArrowUp', 'ArrowDown', 'ArrowLeft'].includes(event.key) && (!isInTaskItem || $from.pos !== $to.pos)) {
85
+ return false;
86
+ }
87
+
88
+ // Arrow keys are pressed and shift, ctrl or meta is pressed as well.
89
+ // along with arrow keys and task item checkbox is focused
90
+ // then first move focus to view and proceed with default event handling.
91
+ if (event.shiftKey || event.ctrlKey || event.metaKey) {
92
+ currentTaskItemFocused && removeCheckboxFocus(view);
93
+ return false;
94
+ }
95
+
96
+ // task item checkbox is already focused
97
+ if (focusedTaskItemLocalId) {
98
+ if (event.key === 'ArrowLeft') {
99
+ // Move focus to view and proceed with default keyboard handler.
100
+ // Which will move cursor to previous position.
101
+ removeCheckboxFocus(view);
102
+ return false;
103
+ }
104
+ if (event.key === 'ArrowRight') {
105
+ // Move focus to view and DON'T proceed with default handler.
106
+ // We have assumed that selection is already before first character of task item.
107
+ removeCheckboxFocus(view);
108
+ return true;
109
+ }
110
+ if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
111
+ const taskItemData = getTaskItemDataToFocus(view, event.key === 'ArrowUp' ? 'previous' : 'next');
112
+ if (taskItemData) {
113
+ focusCheckboxAndUpdateSelection(view, taskItemData);
114
+ return true;
115
+ } else {
116
+ // If any how checkbox input not found, then move focus to view
117
+ // and proceed with default keyboard handler.
118
+ removeCheckboxFocus(view);
119
+ return false;
120
+ }
121
+ }
122
+ }
123
+
124
+ // If left arrow key is pressed and cursor is at first position in task-item
125
+ // then focus checkbox and DON'T proceed with default keyboard handler
126
+ if (event.key === 'ArrowLeft' && parentOffset === 0) {
127
+ // here we are not using focusCheckboxAndUpdateSelection() method
128
+ // because it is working incorretly when we are placing is inside the nested items
129
+ dispatch(state.tr.setMeta(stateKey, {
130
+ action: ACTIONS.FOCUS_BY_LOCALID,
131
+ data: currentTaskItemData === null || currentTaskItemData === void 0 ? void 0 : currentTaskItemData.localId
132
+ }));
133
+ return true;
134
+ }
135
+ if (event.key === 'ArrowRight') {
136
+ var _$from$nodeAfter;
137
+ // If gap cursor is just before task list then focus first task item in list.
138
+ if (selection instanceof GapCursorSelection && selection.side === 'left' && ((_$from$nodeAfter = $from.nodeAfter) === null || _$from$nodeAfter === void 0 ? void 0 : _$from$nodeAfter.type) === schema.nodes.taskList) {
139
+ const taskList = $from.nodeAfter;
140
+ const firstTaskItemNode = taskList.child(0);
141
+ const taskItemPos = $from.pos + 1;
142
+ focusCheckboxAndUpdateSelection(view, {
143
+ pos: taskItemPos,
144
+ localId: firstTaskItemNode.attrs.localId
145
+ });
146
+ return true;
147
+ }
148
+ // if cursor is at then end of task item text then focus next task item checkbox
149
+ else if (isInTaskItem && $from.node().content.size === parentOffset) {
150
+ const nextTaskItemData = getTaskItemDataToFocus(view, 'next');
151
+ if (nextTaskItemData) {
152
+ focusCheckboxAndUpdateSelection(view, nextTaskItemData);
153
+ return true;
154
+ }
155
+ } else {
156
+ return false;
157
+ }
158
+ }
159
+ }
58
160
  },
59
161
  state: {
60
162
  init() {
@@ -78,6 +180,12 @@ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory
78
180
  contextIdentifierProvider: data
79
181
  };
80
182
  break;
183
+ case ACTIONS.FOCUS_BY_LOCALID:
184
+ newPluginState = {
185
+ ...pluginState,
186
+ focusedTaskItemLocalId: data
187
+ };
188
+ break;
81
189
  }
82
190
  dispatch(stateKey, newPluginState);
83
191
  return newPluginState;
@@ -0,0 +1,5 @@
1
+ export let ACTIONS = /*#__PURE__*/function (ACTIONS) {
2
+ ACTIONS[ACTIONS["SET_CONTEXT_PROVIDER"] = 0] = "SET_CONTEXT_PROVIDER";
3
+ ACTIONS[ACTIONS["FOCUS_BY_LOCALID"] = 1] = "FOCUS_BY_LOCALID";
4
+ return ACTIONS;
5
+ }({});
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.43.8";
2
+ export const version = "187.43.12";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -21,7 +21,7 @@ import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
21
21
  import { placeholderPlugin } from '@atlaskit/editor-plugin-placeholder';
22
22
  import annotationPlugin from '../../../plugins/annotation';
23
23
  import { compositionPlugin } from '@atlaskit/editor-plugin-composition';
24
- import quickInsertPlugin from '../../../plugins/quick-insert';
24
+ import { quickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
25
25
  import selectionPlugin from '../../../plugins/selection';
26
26
  import codeBlockPlugin from '../../../plugins/code-block';
27
27
  import undoRedoPlugin from '../../../plugins/undo-redo';
@@ -18,7 +18,6 @@ export { default as mentionsPlugin } from './mentions';
18
18
  export { default as panelPlugin } from './panel';
19
19
  export { default as pastePlugin } from './paste';
20
20
  export { default as placeholderTextPlugin } from './placeholder-text';
21
- export { default as quickInsertPlugin } from './quick-insert';
22
21
  export { default as saveOnEnterPlugin } from './save-on-enter';
23
22
  export { default as submitEditorPlugin } from './submit-editor';
24
23
  export { default as tasksAndDecisionsPlugin } from './tasks-and-decisions';
@@ -357,7 +357,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
357
357
  origWidth: width,
358
358
  layout: layout,
359
359
  // This will only be used when calculating legacy media single width
360
- // thus we use the legecy value (exclude table as container node)
360
+ // thus we use the legacy value (exclude table as container node)
361
361
  contentWidth: contentWidthForLegacyExperience,
362
362
  containerWidth: containerWidth,
363
363
  gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
@@ -33,6 +33,7 @@ import { CAPTION_PLACEHOLDER_ID } from '../ui/CaptionPlaceholder';
33
33
  import { RawIntlProvider } from 'react-intl-next';
34
34
  import { MediaTaskManager } from './mediaTaskManager';
35
35
  import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
36
+ import { getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
36
37
  export { stateKey } from './plugin-key';
37
38
  export var MEDIA_CONTENT_WRAP_CLASS_NAME = 'media-content-wrap';
38
39
  export var MEDIA_PLUGIN_IS_RESIZING_KEY = 'mediaSinglePlugin.isResizing';
@@ -498,6 +499,11 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
498
499
  var selectedContainer = this.selectedMediaContainerNode();
499
500
  if (selectedContainer && this.isMediaSchemaNode(selectedContainer)) {
500
501
  newElement = this.getDomElement(this.view.domAtPos.bind(this.view));
502
+ if (selectedContainer.type === this.view.state.schema.nodes.mediaSingle) {
503
+ this.currentMaxWidth = getMaxWidthForNestedNodeNext(this.view, this.view.state.selection.$anchor.pos) || undefined;
504
+ } else {
505
+ this.currentMaxWidth = undefined;
506
+ }
501
507
  }
502
508
  if (this.element !== newElement) {
503
509
  this.element = newElement;
@@ -239,11 +239,9 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
239
239
  var _widthPlugin$sharedSt;
240
240
  var contentWidth = widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength;
241
241
  var selectedNode = getSelectedMediaSingle(state);
242
- if (selectedNode && contentWidth) {
243
- var width = selectedNode.node.attrs.width;
244
- if (width >= contentWidth) {
245
- isChangingLayoutDisabled = true;
246
- }
242
+ var selectedNodeMaxWidth = pluginState.currentMaxWidth || contentWidth;
243
+ if (selectedNode && selectedNodeMaxWidth && selectedNode.node.attrs.width >= selectedNodeMaxWidth) {
244
+ isChangingLayoutDisabled = true;
247
245
  }
248
246
  }
249
247
  var layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
@@ -124,12 +124,14 @@ var Task = /*#__PURE__*/function (_ReactNodeView) {
124
124
  plugins: {
125
125
  taskDecisionPlugin: taskPluginKey
126
126
  },
127
- render: function render() {
127
+ render: function render(_ref) {
128
+ var taskDecisionPlugin = _ref.taskDecisionPlugin;
128
129
  return /*#__PURE__*/React.createElement(TaskItem, {
129
130
  taskId: localId,
130
131
  contentRef: forwardRef,
131
132
  isDone: state === 'DONE',
132
133
  onChange: _this2.handleOnChange,
134
+ isFocused: (taskDecisionPlugin === null || taskDecisionPlugin === void 0 ? void 0 : taskDecisionPlugin.focusedTaskItemLocalId) === localId,
133
135
  showPlaceholder: _this2.isContentEmpty(_this2.node) && !isTypeAheadOpen(_this2.view.state),
134
136
  providers: props.providerFactory
135
137
  });
@@ -1,6 +1,9 @@
1
+ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
1
2
  import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
2
3
  import { findParentNodeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
3
4
  import { findFarthestParentNode } from '../../../utils';
5
+ import { stateKey } from './plugin-key';
6
+ import { ACTIONS } from './types';
4
7
  export var isInsideTaskOrDecisionItem = function isInsideTaskOrDecisionItem(state) {
5
8
  var _state$schema$nodes = state.schema.nodes,
6
9
  decisionItem = _state$schema$nodes.decisionItem,
@@ -181,4 +184,102 @@ export var liftBlock = function liftBlock(tr, $from, $to) {
181
184
  return null;
182
185
  }
183
186
  return tr.lift(blockRange, target).scrollIntoView();
184
- };
187
+ };
188
+ export function getTaskItemDataAtPos(view) {
189
+ var state = view.state;
190
+ var selection = state.selection,
191
+ schema = state.schema;
192
+ var $from = selection.$from;
193
+ var isInTaskItem = $from.node().type === schema.nodes.taskItem;
194
+
195
+ // current selection has to be inside taskitem
196
+ if (isInTaskItem) {
197
+ var taskItemPos = $from.before();
198
+ return {
199
+ pos: taskItemPos,
200
+ localId: $from.node().attrs.localId
201
+ };
202
+ }
203
+ }
204
+ export function getAllTaskItemsDataInRootTaskList(view) {
205
+ var state = view.state;
206
+ var schema = state.schema;
207
+ var $fromPos = state.selection.$from;
208
+ var isInTaskItem = $fromPos.node().type === schema.nodes.taskItem;
209
+ // if not inside task item then return undefined;
210
+ if (!isInTaskItem) {
211
+ return;
212
+ }
213
+ var _schema$nodes = schema.nodes,
214
+ taskList = _schema$nodes.taskList,
215
+ taskItem = _schema$nodes.taskItem;
216
+ var rootTaskListData = findFarthestParentNode(function (node) {
217
+ return node.type === taskList;
218
+ })($fromPos);
219
+ if (rootTaskListData) {
220
+ var rootTaskList = rootTaskListData.node;
221
+ var rootTaskListStartPos = rootTaskListData.start;
222
+ var allTaskItems = [];
223
+ rootTaskList.descendants(function (node, pos, parent, index) {
224
+ if (node.type === taskItem) {
225
+ allTaskItems.push({
226
+ node: node,
227
+ pos: pos + rootTaskListStartPos,
228
+ index: index
229
+ });
230
+ }
231
+ });
232
+ return allTaskItems;
233
+ }
234
+ }
235
+ export function getCurrentTaskItemIndex(view, allTaskItems) {
236
+ var state = view.state;
237
+ var $fromPos = state.selection.$from;
238
+ var allTaskItemNodes = allTaskItems.map(function (nodeData) {
239
+ return nodeData.node;
240
+ });
241
+ var currentTaskItem = $fromPos.node($fromPos.depth);
242
+ var currentTaskItemIndex = allTaskItemNodes.indexOf(currentTaskItem);
243
+ return currentTaskItemIndex;
244
+ }
245
+ export function getTaskItemDataToFocus(view, direction) {
246
+ var allTaskItems = getAllTaskItemsDataInRootTaskList(view);
247
+ // if not inside task item then allTaskItems will be undefined;
248
+ if (!allTaskItems) {
249
+ return;
250
+ }
251
+ var currentTaskItemIndex = getCurrentTaskItemIndex(view, allTaskItems);
252
+ if (direction === 'next' ? currentTaskItemIndex === allTaskItems.length - 1 : currentTaskItemIndex === 0) {
253
+ // checkbox of first or last task item is already focused based on direction.
254
+ return;
255
+ }
256
+ var indexOfTaskItemToFocus = direction === 'next' ? currentTaskItemIndex + 1 : currentTaskItemIndex - 1;
257
+ var taskItemToFocus = allTaskItems[indexOfTaskItemToFocus];
258
+ return {
259
+ pos: taskItemToFocus.pos,
260
+ localId: taskItemToFocus.node.attrs.localId
261
+ };
262
+ }
263
+ export function focusCheckboxAndUpdateSelection(view, taskItemData) {
264
+ var pos = taskItemData.pos,
265
+ localId = taskItemData.localId;
266
+ var state = view.state,
267
+ dispatch = view.dispatch;
268
+ var doc = state.doc,
269
+ tr = state.tr;
270
+ tr.setSelection(new TextSelection(doc.resolve(pos + 1)));
271
+ tr.setMeta(stateKey, {
272
+ action: ACTIONS.FOCUS_BY_LOCALID,
273
+ data: localId
274
+ });
275
+ dispatch(tr);
276
+ }
277
+ export function removeCheckboxFocus(view) {
278
+ var state = view.state,
279
+ dispatch = view.dispatch;
280
+ var tr = state.tr;
281
+ view.focus();
282
+ dispatch(tr.setMeta(stateKey, {
283
+ action: ACTIONS.FOCUS_BY_LOCALID
284
+ }));
285
+ }
@@ -11,10 +11,9 @@ import { createSelectionClickHandler } from '../../selection/utils';
11
11
  import { decisionItemNodeView } from '../nodeviews/decisionItem';
12
12
  import { taskItemNodeViewFactory } from '../nodeviews/taskItem';
13
13
  import { stateKey } from './plugin-key';
14
- var ACTIONS = /*#__PURE__*/function (ACTIONS) {
15
- ACTIONS[ACTIONS["SET_CONTEXT_PROVIDER"] = 0] = "SET_CONTEXT_PROVIDER";
16
- return ACTIONS;
17
- }(ACTIONS || {});
14
+ import { getTaskItemDataToFocus, getTaskItemDataAtPos, focusCheckboxAndUpdateSelection, removeCheckboxFocus } from './helpers';
15
+ import { GapCursorSelection } from '@atlaskit/editor-common/selection';
16
+ import { ACTIONS } from './types';
18
17
  var setContextIdentifierProvider = function setContextIdentifierProvider(provider) {
19
18
  return function (state, dispatch) {
20
19
  if (dispatch) {
@@ -60,7 +59,104 @@ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory
60
59
  return target.hasAttribute('data-decision-wrapper') || target.getAttribute('aria-label') === 'Decision';
61
60
  }, {
62
61
  useLongPressSelection: useLongPressSelection
63
- })
62
+ }),
63
+ handleKeyDown: function handleKeyDown(view, event) {
64
+ var state = view.state,
65
+ dispatch = view.dispatch;
66
+ var selection = state.selection,
67
+ schema = state.schema;
68
+ var $from = selection.$from,
69
+ $to = selection.$to;
70
+ var parentOffset = $from.parentOffset;
71
+ var isInTaskItem = $from.node().type === schema.nodes.taskItem;
72
+ var focusedTaskItemLocalId = stateKey.getState(state).focusedTaskItemLocalId;
73
+ var currentTaskItemData = getTaskItemDataAtPos(view);
74
+ var currentTaskItemFocused = focusedTaskItemLocalId === (currentTaskItemData === null || currentTaskItemData === void 0 ? void 0 : currentTaskItemData.localId);
75
+
76
+ // if task item checkbox not focused and arrow key is not pressed
77
+ // then we don't want to handle event.
78
+ if (!['ArrowUp', 'ArrowDown', 'ArrowRight', 'ArrowLeft'].includes(event.key)) {
79
+ return false;
80
+ }
81
+
82
+ // We want to handle arrow up, down and left key only
83
+ // when selection is inside task item and no text is selected.
84
+ if (['ArrowUp', 'ArrowDown', 'ArrowLeft'].includes(event.key) && (!isInTaskItem || $from.pos !== $to.pos)) {
85
+ return false;
86
+ }
87
+
88
+ // Arrow keys are pressed and shift, ctrl or meta is pressed as well.
89
+ // along with arrow keys and task item checkbox is focused
90
+ // then first move focus to view and proceed with default event handling.
91
+ if (event.shiftKey || event.ctrlKey || event.metaKey) {
92
+ currentTaskItemFocused && removeCheckboxFocus(view);
93
+ return false;
94
+ }
95
+
96
+ // task item checkbox is already focused
97
+ if (focusedTaskItemLocalId) {
98
+ if (event.key === 'ArrowLeft') {
99
+ // Move focus to view and proceed with default keyboard handler.
100
+ // Which will move cursor to previous position.
101
+ removeCheckboxFocus(view);
102
+ return false;
103
+ }
104
+ if (event.key === 'ArrowRight') {
105
+ // Move focus to view and DON'T proceed with default handler.
106
+ // We have assumed that selection is already before first character of task item.
107
+ removeCheckboxFocus(view);
108
+ return true;
109
+ }
110
+ if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
111
+ var taskItemData = getTaskItemDataToFocus(view, event.key === 'ArrowUp' ? 'previous' : 'next');
112
+ if (taskItemData) {
113
+ focusCheckboxAndUpdateSelection(view, taskItemData);
114
+ return true;
115
+ } else {
116
+ // If any how checkbox input not found, then move focus to view
117
+ // and proceed with default keyboard handler.
118
+ removeCheckboxFocus(view);
119
+ return false;
120
+ }
121
+ }
122
+ }
123
+
124
+ // If left arrow key is pressed and cursor is at first position in task-item
125
+ // then focus checkbox and DON'T proceed with default keyboard handler
126
+ if (event.key === 'ArrowLeft' && parentOffset === 0) {
127
+ // here we are not using focusCheckboxAndUpdateSelection() method
128
+ // because it is working incorretly when we are placing is inside the nested items
129
+ dispatch(state.tr.setMeta(stateKey, {
130
+ action: ACTIONS.FOCUS_BY_LOCALID,
131
+ data: currentTaskItemData === null || currentTaskItemData === void 0 ? void 0 : currentTaskItemData.localId
132
+ }));
133
+ return true;
134
+ }
135
+ if (event.key === 'ArrowRight') {
136
+ var _$from$nodeAfter;
137
+ // If gap cursor is just before task list then focus first task item in list.
138
+ if (selection instanceof GapCursorSelection && selection.side === 'left' && ((_$from$nodeAfter = $from.nodeAfter) === null || _$from$nodeAfter === void 0 ? void 0 : _$from$nodeAfter.type) === schema.nodes.taskList) {
139
+ var taskList = $from.nodeAfter;
140
+ var firstTaskItemNode = taskList.child(0);
141
+ var taskItemPos = $from.pos + 1;
142
+ focusCheckboxAndUpdateSelection(view, {
143
+ pos: taskItemPos,
144
+ localId: firstTaskItemNode.attrs.localId
145
+ });
146
+ return true;
147
+ }
148
+ // if cursor is at then end of task item text then focus next task item checkbox
149
+ else if (isInTaskItem && $from.node().content.size === parentOffset) {
150
+ var nextTaskItemData = getTaskItemDataToFocus(view, 'next');
151
+ if (nextTaskItemData) {
152
+ focusCheckboxAndUpdateSelection(view, nextTaskItemData);
153
+ return true;
154
+ }
155
+ } else {
156
+ return false;
157
+ }
158
+ }
159
+ }
64
160
  },
65
161
  state: {
66
162
  init: function init() {
@@ -82,6 +178,11 @@ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory
82
178
  contextIdentifierProvider: data
83
179
  });
84
180
  break;
181
+ case ACTIONS.FOCUS_BY_LOCALID:
182
+ newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
183
+ focusedTaskItemLocalId: data
184
+ });
185
+ break;
85
186
  }
86
187
  dispatch(stateKey, newPluginState);
87
188
  return newPluginState;
@@ -0,0 +1,5 @@
1
+ export var ACTIONS = /*#__PURE__*/function (ACTIONS) {
2
+ ACTIONS[ACTIONS["SET_CONTEXT_PROVIDER"] = 0] = "SET_CONTEXT_PROVIDER";
3
+ ACTIONS[ACTIONS["FOCUS_BY_LOCALID"] = 1] = "FOCUS_BY_LOCALID";
4
+ return ACTIONS;
5
+ }({});
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "187.43.8";
2
+ export var version = "187.43.12";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,7 +1,7 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
- import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
- import type quickInsertPlugin from '../quick-insert';
3
+ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
+ import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
5
5
  export declare function createPlugin(dispatch: Function, imageEnabled: boolean): SafePlugin<any>;
6
6
  interface HelpDialogSharedState {
7
7
  isVisible: boolean;
@@ -9,8 +9,8 @@ interface HelpDialogSharedState {
9
9
  }
10
10
  declare const helpDialog: NextEditorPlugin<'helpDialog', {
11
11
  dependencies: [
12
- OptionalPlugin<typeof analyticsPlugin>,
13
- OptionalPlugin<typeof quickInsertPlugin>
12
+ OptionalPlugin<AnalyticsPlugin>,
13
+ OptionalPlugin<QuickInsertPlugin>
14
14
  ];
15
15
  pluginConfiguration: boolean;
16
16
  sharedState: HelpDialogSharedState | null;
@@ -18,7 +18,6 @@ export { default as mentionsPlugin } from './mentions';
18
18
  export { default as panelPlugin } from './panel';
19
19
  export { default as pastePlugin } from './paste';
20
20
  export { default as placeholderTextPlugin } from './placeholder-text';
21
- export { default as quickInsertPlugin } from './quick-insert';
22
21
  export { default as saveOnEnterPlugin } from './save-on-enter';
23
22
  export { default as submitEditorPlugin } from './submit-editor';
24
23
  export { default as tasksAndDecisionsPlugin } from './tasks-and-decisions';
@@ -7,7 +7,7 @@ import type { hyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
7
7
  import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
8
8
  import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
9
9
  import type mentionsPlugin from '../mentions';
10
- import type quickInsertPlugin from '../quick-insert';
10
+ import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
11
11
  import type { BlockTypePlugin } from '@atlaskit/editor-plugin-block-type';
12
12
  import type codeBlockPlugin from '../code-block';
13
13
  import type panelPlugin from '../panel';
@@ -22,7 +22,7 @@ export type InsertBlockPluginDependencies = [
22
22
  OptionalPlugin<ImageUploadPlugin>,
23
23
  OptionalPlugin<typeof mentionsPlugin>,
24
24
  OptionalPlugin<EmojiPlugin>,
25
- OptionalPlugin<typeof quickInsertPlugin>,
25
+ OptionalPlugin<QuickInsertPlugin>,
26
26
  OptionalPlugin<RulePlugin>,
27
27
  OptionalPlugin<typeof codeBlockPlugin>,
28
28
  OptionalPlugin<typeof panelPlugin>
@@ -37,6 +37,7 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
37
37
  newInsertionBehaviour?: boolean;
38
38
  isResizing: boolean;
39
39
  resizingWidth: number;
40
+ currentMaxWidth?: number;
40
41
  private view;
41
42
  private destroyed;
42
43
  private contextIdentifierProvider?;
@@ -34,6 +34,7 @@ export interface MediaPluginState {
34
34
  mediaOptions?: MediaOptions;
35
35
  isResizing: boolean;
36
36
  resizingWidth: number;
37
+ currentMaxWidth?: number;
37
38
  dispatch?: Dispatch;
38
39
  onContextIdentifierProvider: (_name: string, provider?: Promise<ContextIdentifierProvider>) => Promise<void>;
39
40
  setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
@@ -1,5 +1,7 @@
1
1
  import type { Node, NodeType, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
- import type { EditorState, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import { EditorState, Selection, Transaction } from '@atlaskit/editor-prosemirror/state';
3
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
+ import { TaskItemData } from './types';
3
5
  export declare const isInsideTaskOrDecisionItem: (state: EditorState) => boolean;
4
6
  export declare const isActionOrDecisionList: (node: Node) => boolean;
5
7
  export declare const isActionOrDecisionItem: (node: Node) => boolean;
@@ -52,3 +54,23 @@ export declare const isEmptyTaskDecision: (state: EditorState) => boolean;
52
54
  * @param $to End of range you want to lift (can be same as `$from`)
53
55
  */
54
56
  export declare const liftBlock: (tr: Transaction, $from: ResolvedPos, $to: ResolvedPos) => Transaction | null;
57
+ export declare function getTaskItemDataAtPos(view: EditorView): {
58
+ pos: number;
59
+ localId: any;
60
+ } | undefined;
61
+ export declare function getAllTaskItemsDataInRootTaskList(view: EditorView): {
62
+ node: Node;
63
+ pos: number;
64
+ index: number;
65
+ }[] | undefined;
66
+ export declare function getCurrentTaskItemIndex(view: EditorView, allTaskItems: Array<{
67
+ node: Node;
68
+ pos: number;
69
+ index: number;
70
+ }>): number;
71
+ export declare function getTaskItemDataToFocus(view: EditorView, direction: 'next' | 'previous'): {
72
+ pos: number;
73
+ localId: any;
74
+ } | undefined;
75
+ export declare function focusCheckboxAndUpdateSelection(view: EditorView, taskItemData: TaskItemData): void;
76
+ export declare function removeCheckboxFocus(view: EditorView): void;
@@ -0,0 +1,8 @@
1
+ export declare enum ACTIONS {
2
+ SET_CONTEXT_PROVIDER = 0,
3
+ FOCUS_BY_LOCALID = 1
4
+ }
5
+ export type TaskItemData = {
6
+ pos: number;
7
+ localId: string | null;
8
+ };
@@ -5,6 +5,7 @@ import { ContentRef } from '@atlaskit/task-decision';
5
5
  export interface TaskProps {
6
6
  taskId: string;
7
7
  isDone: boolean;
8
+ isFocused?: boolean;
8
9
  contentRef?: ContentRef;
9
10
  onChange?: (taskId: string, isChecked: boolean) => void;
10
11
  showPlaceholder?: boolean;
@@ -4,6 +4,7 @@ import { ContentRef, TaskDecisionProvider } from '@atlaskit/task-decision';
4
4
  export interface Props {
5
5
  taskId: string;
6
6
  isDone: boolean;
7
+ isFocused?: boolean;
7
8
  contentRef?: ContentRef;
8
9
  onChange?: (taskId: string, isChecked: boolean) => void;
9
10
  showPlaceholder?: boolean;
@@ -1,7 +1,7 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
- import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
- import type quickInsertPlugin from '../quick-insert';
3
+ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
+ import type { QuickInsertPlugin } from '@atlaskit/editor-plugin-quick-insert';
5
5
  export declare function createPlugin(dispatch: Function, imageEnabled: boolean): SafePlugin<any>;
6
6
  interface HelpDialogSharedState {
7
7
  isVisible: boolean;
@@ -9,8 +9,8 @@ interface HelpDialogSharedState {
9
9
  }
10
10
  declare const helpDialog: NextEditorPlugin<'helpDialog', {
11
11
  dependencies: [
12
- OptionalPlugin<typeof analyticsPlugin>,
13
- OptionalPlugin<typeof quickInsertPlugin>
12
+ OptionalPlugin<AnalyticsPlugin>,
13
+ OptionalPlugin<QuickInsertPlugin>
14
14
  ];
15
15
  pluginConfiguration: boolean;
16
16
  sharedState: HelpDialogSharedState | null;