@atlaskit/editor-core 187.43.8 → 187.43.11
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.
- package/CHANGELOG.md +9 -0
- package/dist/cjs/labs/next/presets/default.js +2 -2
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +3 -1
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/helpers.js +111 -2
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/main.js +108 -7
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/types.js +12 -0
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/labs/next/presets/default.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +4 -1
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/helpers.js +121 -1
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/main.js +113 -5
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/types.js +5 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/labs/next/presets/default.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +3 -1
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/helpers.js +102 -1
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/main.js +106 -5
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/types.js +5 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/help-dialog/index.d.ts +4 -4
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/insert-block/types.d.ts +2 -2
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/helpers.d.ts +23 -1
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/types.d.ts +8 -0
- package/dist/types/plugins/tasks-and-decisions/ui/Task/index.d.ts +1 -0
- package/dist/types/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.d.ts +1 -0
- package/dist/types-ts4.5/plugins/help-dialog/index.d.ts +4 -4
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/insert-block/types.d.ts +2 -2
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/helpers.d.ts +23 -1
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/types.d.ts +8 -0
- package/dist/types-ts4.5/plugins/tasks-and-decisions/ui/Task/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.d.ts +1 -0
- package/package.json +7 -6
- package/dist/cjs/plugins/quick-insert/commands.js +0 -44
- package/dist/cjs/plugins/quick-insert/index.js +0 -189
- package/dist/cjs/plugins/quick-insert/plugin-key.js +0 -9
- package/dist/cjs/plugins/quick-insert/search.js +0 -33
- package/dist/cjs/plugins/quick-insert/ui/ModalElementBrowser/ModalElementBrowser.js +0 -140
- package/dist/cjs/plugins/quick-insert/ui/ModalElementBrowser/categories.js +0 -100
- package/dist/cjs/plugins/quick-insert/ui/ModalElementBrowser/index.js +0 -61
- package/dist/cjs/plugins/quick-insert/ui/ModalElementBrowser/messages.js +0 -15
- package/dist/es2019/plugins/quick-insert/commands.js +0 -29
- package/dist/es2019/plugins/quick-insert/index.js +0 -151
- package/dist/es2019/plugins/quick-insert/plugin-key.js +0 -2
- package/dist/es2019/plugins/quick-insert/search.js +0 -16
- package/dist/es2019/plugins/quick-insert/ui/ModalElementBrowser/ModalElementBrowser.js +0 -137
- package/dist/es2019/plugins/quick-insert/ui/ModalElementBrowser/categories.js +0 -94
- package/dist/es2019/plugins/quick-insert/ui/ModalElementBrowser/index.js +0 -51
- package/dist/es2019/plugins/quick-insert/ui/ModalElementBrowser/messages.js +0 -8
- package/dist/esm/plugins/quick-insert/commands.js +0 -35
- package/dist/esm/plugins/quick-insert/index.js +0 -181
- package/dist/esm/plugins/quick-insert/plugin-key.js +0 -2
- package/dist/esm/plugins/quick-insert/search.js +0 -25
- package/dist/esm/plugins/quick-insert/ui/ModalElementBrowser/ModalElementBrowser.js +0 -128
- package/dist/esm/plugins/quick-insert/ui/ModalElementBrowser/categories.js +0 -94
- package/dist/esm/plugins/quick-insert/ui/ModalElementBrowser/index.js +0 -50
- package/dist/esm/plugins/quick-insert/ui/ModalElementBrowser/messages.js +0 -8
- package/dist/types/plugins/quick-insert/commands.d.ts +0 -5
- package/dist/types/plugins/quick-insert/index.d.ts +0 -16
- package/dist/types/plugins/quick-insert/plugin-key.d.ts +0 -3
- package/dist/types/plugins/quick-insert/search.d.ts +0 -5
- package/dist/types/plugins/quick-insert/ui/ModalElementBrowser/ModalElementBrowser.d.ts +0 -18
- package/dist/types/plugins/quick-insert/ui/ModalElementBrowser/categories.d.ts +0 -5
- package/dist/types/plugins/quick-insert/ui/ModalElementBrowser/index.d.ts +0 -11
- package/dist/types/plugins/quick-insert/ui/ModalElementBrowser/messages.d.ts +0 -7
- package/dist/types-ts4.5/plugins/quick-insert/commands.d.ts +0 -5
- package/dist/types-ts4.5/plugins/quick-insert/index.d.ts +0 -16
- package/dist/types-ts4.5/plugins/quick-insert/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/quick-insert/search.d.ts +0 -5
- package/dist/types-ts4.5/plugins/quick-insert/ui/ModalElementBrowser/ModalElementBrowser.d.ts +0 -18
- package/dist/types-ts4.5/plugins/quick-insert/ui/ModalElementBrowser/categories.d.ts +0 -5
- package/dist/types-ts4.5/plugins/quick-insert/ui/ModalElementBrowser/index.d.ts +0 -11
- 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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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;
|
|
@@ -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 '
|
|
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';
|
|
@@ -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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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;
|
|
@@ -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 {
|
|
4
|
-
import type
|
|
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<
|
|
13
|
-
OptionalPlugin<
|
|
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
|
|
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<
|
|
25
|
+
OptionalPlugin<QuickInsertPlugin>,
|
|
26
26
|
OptionalPlugin<RulePlugin>,
|
|
27
27
|
OptionalPlugin<typeof codeBlockPlugin>,
|
|
28
28
|
OptionalPlugin<typeof panelPlugin>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Node, NodeType, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import
|
|
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;
|
|
@@ -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 {
|
|
4
|
-
import type
|
|
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<
|
|
13
|
-
OptionalPlugin<
|
|
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
|
|
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<
|
|
25
|
+
OptionalPlugin<QuickInsertPlugin>,
|
|
26
26
|
OptionalPlugin<RulePlugin>,
|
|
27
27
|
OptionalPlugin<typeof codeBlockPlugin>,
|
|
28
28
|
OptionalPlugin<typeof panelPlugin>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Node, NodeType, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import
|
|
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;
|