@atlaskit/editor-core 187.43.5 → 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 +15 -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 +9 -8
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 187.43.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`65b155b2787`](https://bitbucket.org/atlassian/atlassian-frontend/commits/65b155b2787) - [ux] ED-19172: Updated tableHeaderCellBackgroundColor to use non-transparent token."
|
|
8
|
+
- [`96f4e9fe6de`](https://bitbucket.org/atlassian/atlassian-frontend/commits/96f4e9fe6de) - [ux] ECA11Y-1 Added keyboard support to focus checkbox, check or uncheck, inside action item
|
|
9
|
+
- [`9131a0a2ffa`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9131a0a2ffa) - Extract quick-insert plugin from @atlaskit/editor-core to @atlaskit/editor-plugin-quick-insert.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 187.43.8
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
3
18
|
## 187.43.5
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -27,7 +27,7 @@ var _editorPluginAnalytics = require("@atlaskit/editor-plugin-analytics");
|
|
|
27
27
|
var _editorPluginPlaceholder = require("@atlaskit/editor-plugin-placeholder");
|
|
28
28
|
var _annotation = _interopRequireDefault(require("../../../plugins/annotation"));
|
|
29
29
|
var _editorPluginComposition = require("@atlaskit/editor-plugin-composition");
|
|
30
|
-
var
|
|
30
|
+
var _editorPluginQuickInsert = require("@atlaskit/editor-plugin-quick-insert");
|
|
31
31
|
var _selection = _interopRequireDefault(require("../../../plugins/selection"));
|
|
32
32
|
var _codeBlock = _interopRequireDefault(require("../../../plugins/code-block"));
|
|
33
33
|
var _undoRedo = _interopRequireDefault(require("../../../plugins/undo-redo"));
|
|
@@ -74,7 +74,7 @@ function createDefaultPreset(options) {
|
|
|
74
74
|
return builder.add([p, options.annotationProviders]);
|
|
75
75
|
}
|
|
76
76
|
return builder;
|
|
77
|
-
}).add([_editorPluginHyperlink.hyperlinkPlugin, options.hyperlinkOptions]).add([_editorPluginTextFormatting.textFormattingPlugin, options.textFormatting]).add(_editorPluginWidth.widthPlugin).add([
|
|
77
|
+
}).add([_editorPluginHyperlink.hyperlinkPlugin, options.hyperlinkOptions]).add([_editorPluginTextFormatting.textFormattingPlugin, options.textFormatting]).add(_editorPluginWidth.widthPlugin).add([_editorPluginQuickInsert.quickInsertPlugin, options.quickInsert]).add([_typeAhead.default, options.typeAhead || {
|
|
78
78
|
createAnalyticsEvent: options.createAnalyticsEvent
|
|
79
79
|
}]).add([_editorPluginPlaceholder.placeholderPlugin, options.placeholder]).add(_editorPluginUnsupportedContent.unsupportedContentPlugin).add(_editorPluginEditorDisabled.editorDisabledPlugin).add([_submitEditor.default, options.submitEditor]).add(_fakeTextCursor.default).add(_floatingToolbar.default).add([_selection.default, options.selection]).add([_codeBlock.default, options.codeBlock || {
|
|
80
80
|
appearance: 'full-page'
|
|
@@ -257,12 +257,6 @@ Object.defineProperty(exports, "placeholderTextPlugin", {
|
|
|
257
257
|
return _placeholderText.default;
|
|
258
258
|
}
|
|
259
259
|
});
|
|
260
|
-
Object.defineProperty(exports, "quickInsertPlugin", {
|
|
261
|
-
enumerable: true,
|
|
262
|
-
get: function get() {
|
|
263
|
-
return _quickInsert.default;
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
260
|
Object.defineProperty(exports, "saveOnEnterPlugin", {
|
|
267
261
|
enumerable: true,
|
|
268
262
|
get: function get() {
|
|
@@ -349,7 +343,6 @@ var _mentions = _interopRequireDefault(require("./mentions"));
|
|
|
349
343
|
var _panel = _interopRequireDefault(require("./panel"));
|
|
350
344
|
var _paste = _interopRequireDefault(require("./paste"));
|
|
351
345
|
var _placeholderText = _interopRequireDefault(require("./placeholder-text"));
|
|
352
|
-
var _quickInsert = _interopRequireDefault(require("./quick-insert"));
|
|
353
346
|
var _saveOnEnter = _interopRequireDefault(require("./save-on-enter"));
|
|
354
347
|
var _submitEditor = _interopRequireDefault(require("./submit-editor"));
|
|
355
348
|
var _tasksAndDecisions = _interopRequireDefault(require("./tasks-and-decisions"));
|
|
@@ -131,12 +131,14 @@ var Task = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
131
131
|
plugins: {
|
|
132
132
|
taskDecisionPlugin: _pluginKey.stateKey
|
|
133
133
|
},
|
|
134
|
-
render: function render() {
|
|
134
|
+
render: function render(_ref) {
|
|
135
|
+
var taskDecisionPlugin = _ref.taskDecisionPlugin;
|
|
135
136
|
return /*#__PURE__*/_react.default.createElement(_Task.default, {
|
|
136
137
|
taskId: localId,
|
|
137
138
|
contentRef: forwardRef,
|
|
138
139
|
isDone: state === 'DONE',
|
|
139
140
|
onChange: _this2.handleOnChange,
|
|
141
|
+
isFocused: (taskDecisionPlugin === null || taskDecisionPlugin === void 0 ? void 0 : taskDecisionPlugin.focusedTaskItemLocalId) === localId,
|
|
140
142
|
showPlaceholder: _this2.isContentEmpty(_this2.node) && !(0, _utils.isTypeAheadOpen)(_this2.view.state),
|
|
141
143
|
providers: props.providerFactory
|
|
142
144
|
});
|
|
@@ -3,10 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.focusCheckboxAndUpdateSelection = focusCheckboxAndUpdateSelection;
|
|
7
|
+
exports.getAllTaskItemsDataInRootTaskList = getAllTaskItemsDataInRootTaskList;
|
|
8
|
+
exports.getCurrentIndentLevel = exports.getBlockRange = void 0;
|
|
9
|
+
exports.getCurrentTaskItemIndex = getCurrentTaskItemIndex;
|
|
10
|
+
exports.getTaskItemDataAtPos = getTaskItemDataAtPos;
|
|
11
|
+
exports.getTaskItemDataToFocus = getTaskItemDataToFocus;
|
|
12
|
+
exports.liftBlock = exports.isTable = exports.isInsideTaskOrDecisionItem = exports.isInsideTask = exports.isInsideDecision = exports.isEmptyTaskDecision = exports.isActionOrDecisionList = exports.isActionOrDecisionItem = exports.getTaskItemIndex = void 0;
|
|
13
|
+
exports.removeCheckboxFocus = removeCheckboxFocus;
|
|
14
|
+
exports.walkOut = exports.subtreeHeight = void 0;
|
|
15
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
7
16
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
8
17
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
18
|
var _utils2 = require("../../../utils");
|
|
19
|
+
var _pluginKey = require("./plugin-key");
|
|
20
|
+
var _types = require("./types");
|
|
10
21
|
var isInsideTaskOrDecisionItem = function isInsideTaskOrDecisionItem(state) {
|
|
11
22
|
var _state$schema$nodes = state.schema.nodes,
|
|
12
23
|
decisionItem = _state$schema$nodes.decisionItem,
|
|
@@ -200,4 +211,102 @@ var liftBlock = function liftBlock(tr, $from, $to) {
|
|
|
200
211
|
}
|
|
201
212
|
return tr.lift(blockRange, target).scrollIntoView();
|
|
202
213
|
};
|
|
203
|
-
exports.liftBlock = liftBlock;
|
|
214
|
+
exports.liftBlock = liftBlock;
|
|
215
|
+
function getTaskItemDataAtPos(view) {
|
|
216
|
+
var state = view.state;
|
|
217
|
+
var selection = state.selection,
|
|
218
|
+
schema = state.schema;
|
|
219
|
+
var $from = selection.$from;
|
|
220
|
+
var isInTaskItem = $from.node().type === schema.nodes.taskItem;
|
|
221
|
+
|
|
222
|
+
// current selection has to be inside taskitem
|
|
223
|
+
if (isInTaskItem) {
|
|
224
|
+
var taskItemPos = $from.before();
|
|
225
|
+
return {
|
|
226
|
+
pos: taskItemPos,
|
|
227
|
+
localId: $from.node().attrs.localId
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function getAllTaskItemsDataInRootTaskList(view) {
|
|
232
|
+
var state = view.state;
|
|
233
|
+
var schema = state.schema;
|
|
234
|
+
var $fromPos = state.selection.$from;
|
|
235
|
+
var isInTaskItem = $fromPos.node().type === schema.nodes.taskItem;
|
|
236
|
+
// if not inside task item then return undefined;
|
|
237
|
+
if (!isInTaskItem) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
var _schema$nodes = schema.nodes,
|
|
241
|
+
taskList = _schema$nodes.taskList,
|
|
242
|
+
taskItem = _schema$nodes.taskItem;
|
|
243
|
+
var rootTaskListData = (0, _utils2.findFarthestParentNode)(function (node) {
|
|
244
|
+
return node.type === taskList;
|
|
245
|
+
})($fromPos);
|
|
246
|
+
if (rootTaskListData) {
|
|
247
|
+
var rootTaskList = rootTaskListData.node;
|
|
248
|
+
var rootTaskListStartPos = rootTaskListData.start;
|
|
249
|
+
var allTaskItems = [];
|
|
250
|
+
rootTaskList.descendants(function (node, pos, parent, index) {
|
|
251
|
+
if (node.type === taskItem) {
|
|
252
|
+
allTaskItems.push({
|
|
253
|
+
node: node,
|
|
254
|
+
pos: pos + rootTaskListStartPos,
|
|
255
|
+
index: index
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
return allTaskItems;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function getCurrentTaskItemIndex(view, allTaskItems) {
|
|
263
|
+
var state = view.state;
|
|
264
|
+
var $fromPos = state.selection.$from;
|
|
265
|
+
var allTaskItemNodes = allTaskItems.map(function (nodeData) {
|
|
266
|
+
return nodeData.node;
|
|
267
|
+
});
|
|
268
|
+
var currentTaskItem = $fromPos.node($fromPos.depth);
|
|
269
|
+
var currentTaskItemIndex = allTaskItemNodes.indexOf(currentTaskItem);
|
|
270
|
+
return currentTaskItemIndex;
|
|
271
|
+
}
|
|
272
|
+
function getTaskItemDataToFocus(view, direction) {
|
|
273
|
+
var allTaskItems = getAllTaskItemsDataInRootTaskList(view);
|
|
274
|
+
// if not inside task item then allTaskItems will be undefined;
|
|
275
|
+
if (!allTaskItems) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
var currentTaskItemIndex = getCurrentTaskItemIndex(view, allTaskItems);
|
|
279
|
+
if (direction === 'next' ? currentTaskItemIndex === allTaskItems.length - 1 : currentTaskItemIndex === 0) {
|
|
280
|
+
// checkbox of first or last task item is already focused based on direction.
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
var indexOfTaskItemToFocus = direction === 'next' ? currentTaskItemIndex + 1 : currentTaskItemIndex - 1;
|
|
284
|
+
var taskItemToFocus = allTaskItems[indexOfTaskItemToFocus];
|
|
285
|
+
return {
|
|
286
|
+
pos: taskItemToFocus.pos,
|
|
287
|
+
localId: taskItemToFocus.node.attrs.localId
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function focusCheckboxAndUpdateSelection(view, taskItemData) {
|
|
291
|
+
var pos = taskItemData.pos,
|
|
292
|
+
localId = taskItemData.localId;
|
|
293
|
+
var state = view.state,
|
|
294
|
+
dispatch = view.dispatch;
|
|
295
|
+
var doc = state.doc,
|
|
296
|
+
tr = state.tr;
|
|
297
|
+
tr.setSelection(new _state.TextSelection(doc.resolve(pos + 1)));
|
|
298
|
+
tr.setMeta(_pluginKey.stateKey, {
|
|
299
|
+
action: _types.ACTIONS.FOCUS_BY_LOCALID,
|
|
300
|
+
data: localId
|
|
301
|
+
});
|
|
302
|
+
dispatch(tr);
|
|
303
|
+
}
|
|
304
|
+
function removeCheckboxFocus(view) {
|
|
305
|
+
var state = view.state,
|
|
306
|
+
dispatch = view.dispatch;
|
|
307
|
+
var tr = state.tr;
|
|
308
|
+
view.focus();
|
|
309
|
+
dispatch(tr.setMeta(_pluginKey.stateKey, {
|
|
310
|
+
action: _types.ACTIONS.FOCUS_BY_LOCALID
|
|
311
|
+
}));
|
|
312
|
+
}
|
|
@@ -15,18 +15,17 @@ var _utils2 = require("../../selection/utils");
|
|
|
15
15
|
var _decisionItem = require("../nodeviews/decisionItem");
|
|
16
16
|
var _taskItem = require("../nodeviews/taskItem");
|
|
17
17
|
var _pluginKey = require("./plugin-key");
|
|
18
|
+
var _helpers = require("./helpers");
|
|
19
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
20
|
+
var _types = require("./types");
|
|
18
21
|
var _excluded = ["localId"];
|
|
19
22
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
23
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
|
-
var ACTIONS = /*#__PURE__*/function (ACTIONS) {
|
|
22
|
-
ACTIONS[ACTIONS["SET_CONTEXT_PROVIDER"] = 0] = "SET_CONTEXT_PROVIDER";
|
|
23
|
-
return ACTIONS;
|
|
24
|
-
}(ACTIONS || {});
|
|
25
24
|
var setContextIdentifierProvider = function setContextIdentifierProvider(provider) {
|
|
26
25
|
return function (state, dispatch) {
|
|
27
26
|
if (dispatch) {
|
|
28
27
|
dispatch(state.tr.setMeta(_pluginKey.stateKey, {
|
|
29
|
-
action: ACTIONS.SET_CONTEXT_PROVIDER,
|
|
28
|
+
action: _types.ACTIONS.SET_CONTEXT_PROVIDER,
|
|
30
29
|
data: provider
|
|
31
30
|
}));
|
|
32
31
|
}
|
|
@@ -67,7 +66,104 @@ function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispa
|
|
|
67
66
|
return target.hasAttribute('data-decision-wrapper') || target.getAttribute('aria-label') === 'Decision';
|
|
68
67
|
}, {
|
|
69
68
|
useLongPressSelection: useLongPressSelection
|
|
70
|
-
})
|
|
69
|
+
}),
|
|
70
|
+
handleKeyDown: function handleKeyDown(view, event) {
|
|
71
|
+
var state = view.state,
|
|
72
|
+
dispatch = view.dispatch;
|
|
73
|
+
var selection = state.selection,
|
|
74
|
+
schema = state.schema;
|
|
75
|
+
var $from = selection.$from,
|
|
76
|
+
$to = selection.$to;
|
|
77
|
+
var parentOffset = $from.parentOffset;
|
|
78
|
+
var isInTaskItem = $from.node().type === schema.nodes.taskItem;
|
|
79
|
+
var focusedTaskItemLocalId = _pluginKey.stateKey.getState(state).focusedTaskItemLocalId;
|
|
80
|
+
var currentTaskItemData = (0, _helpers.getTaskItemDataAtPos)(view);
|
|
81
|
+
var currentTaskItemFocused = focusedTaskItemLocalId === (currentTaskItemData === null || currentTaskItemData === void 0 ? void 0 : currentTaskItemData.localId);
|
|
82
|
+
|
|
83
|
+
// if task item checkbox not focused and arrow key is not pressed
|
|
84
|
+
// then we don't want to handle event.
|
|
85
|
+
if (!['ArrowUp', 'ArrowDown', 'ArrowRight', 'ArrowLeft'].includes(event.key)) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// We want to handle arrow up, down and left key only
|
|
90
|
+
// when selection is inside task item and no text is selected.
|
|
91
|
+
if (['ArrowUp', 'ArrowDown', 'ArrowLeft'].includes(event.key) && (!isInTaskItem || $from.pos !== $to.pos)) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Arrow keys are pressed and shift, ctrl or meta is pressed as well.
|
|
96
|
+
// along with arrow keys and task item checkbox is focused
|
|
97
|
+
// then first move focus to view and proceed with default event handling.
|
|
98
|
+
if (event.shiftKey || event.ctrlKey || event.metaKey) {
|
|
99
|
+
currentTaskItemFocused && (0, _helpers.removeCheckboxFocus)(view);
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// task item checkbox is already focused
|
|
104
|
+
if (focusedTaskItemLocalId) {
|
|
105
|
+
if (event.key === 'ArrowLeft') {
|
|
106
|
+
// Move focus to view and proceed with default keyboard handler.
|
|
107
|
+
// Which will move cursor to previous position.
|
|
108
|
+
(0, _helpers.removeCheckboxFocus)(view);
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
if (event.key === 'ArrowRight') {
|
|
112
|
+
// Move focus to view and DON'T proceed with default handler.
|
|
113
|
+
// We have assumed that selection is already before first character of task item.
|
|
114
|
+
(0, _helpers.removeCheckboxFocus)(view);
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
118
|
+
var taskItemData = (0, _helpers.getTaskItemDataToFocus)(view, event.key === 'ArrowUp' ? 'previous' : 'next');
|
|
119
|
+
if (taskItemData) {
|
|
120
|
+
(0, _helpers.focusCheckboxAndUpdateSelection)(view, taskItemData);
|
|
121
|
+
return true;
|
|
122
|
+
} else {
|
|
123
|
+
// If any how checkbox input not found, then move focus to view
|
|
124
|
+
// and proceed with default keyboard handler.
|
|
125
|
+
(0, _helpers.removeCheckboxFocus)(view);
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// If left arrow key is pressed and cursor is at first position in task-item
|
|
132
|
+
// then focus checkbox and DON'T proceed with default keyboard handler
|
|
133
|
+
if (event.key === 'ArrowLeft' && parentOffset === 0) {
|
|
134
|
+
// here we are not using focusCheckboxAndUpdateSelection() method
|
|
135
|
+
// because it is working incorretly when we are placing is inside the nested items
|
|
136
|
+
dispatch(state.tr.setMeta(_pluginKey.stateKey, {
|
|
137
|
+
action: _types.ACTIONS.FOCUS_BY_LOCALID,
|
|
138
|
+
data: currentTaskItemData === null || currentTaskItemData === void 0 ? void 0 : currentTaskItemData.localId
|
|
139
|
+
}));
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
if (event.key === 'ArrowRight') {
|
|
143
|
+
var _$from$nodeAfter;
|
|
144
|
+
// If gap cursor is just before task list then focus first task item in list.
|
|
145
|
+
if (selection instanceof _selection.GapCursorSelection && selection.side === 'left' && ((_$from$nodeAfter = $from.nodeAfter) === null || _$from$nodeAfter === void 0 ? void 0 : _$from$nodeAfter.type) === schema.nodes.taskList) {
|
|
146
|
+
var taskList = $from.nodeAfter;
|
|
147
|
+
var firstTaskItemNode = taskList.child(0);
|
|
148
|
+
var taskItemPos = $from.pos + 1;
|
|
149
|
+
(0, _helpers.focusCheckboxAndUpdateSelection)(view, {
|
|
150
|
+
pos: taskItemPos,
|
|
151
|
+
localId: firstTaskItemNode.attrs.localId
|
|
152
|
+
});
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
// if cursor is at then end of task item text then focus next task item checkbox
|
|
156
|
+
else if (isInTaskItem && $from.node().content.size === parentOffset) {
|
|
157
|
+
var nextTaskItemData = (0, _helpers.getTaskItemDataToFocus)(view, 'next');
|
|
158
|
+
if (nextTaskItemData) {
|
|
159
|
+
(0, _helpers.focusCheckboxAndUpdateSelection)(view, nextTaskItemData);
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
71
167
|
},
|
|
72
168
|
state: {
|
|
73
169
|
init: function init() {
|
|
@@ -84,11 +180,16 @@ function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispa
|
|
|
84
180
|
data = _ref.data;
|
|
85
181
|
var newPluginState = pluginState;
|
|
86
182
|
switch (action) {
|
|
87
|
-
case ACTIONS.SET_CONTEXT_PROVIDER:
|
|
183
|
+
case _types.ACTIONS.SET_CONTEXT_PROVIDER:
|
|
88
184
|
newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
89
185
|
contextIdentifierProvider: data
|
|
90
186
|
});
|
|
91
187
|
break;
|
|
188
|
+
case _types.ACTIONS.FOCUS_BY_LOCALID:
|
|
189
|
+
newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
190
|
+
focusedTaskItemLocalId: data
|
|
191
|
+
});
|
|
192
|
+
break;
|
|
92
193
|
}
|
|
93
194
|
dispatch(_pluginKey.stateKey, newPluginState);
|
|
94
195
|
return newPluginState;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ACTIONS = void 0;
|
|
7
|
+
var ACTIONS = /*#__PURE__*/function (ACTIONS) {
|
|
8
|
+
ACTIONS[ACTIONS["SET_CONTEXT_PROVIDER"] = 0] = "SET_CONTEXT_PROVIDER";
|
|
9
|
+
ACTIONS[ACTIONS["FOCUS_BY_LOCALID"] = 1] = "FOCUS_BY_LOCALID";
|
|
10
|
+
return ACTIONS;
|
|
11
|
+
}({});
|
|
12
|
+
exports.ACTIONS = ACTIONS;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = "@atlaskit/editor-core";
|
|
8
8
|
exports.name = name;
|
|
9
|
-
var version = "187.43.
|
|
9
|
+
var version = "187.43.11";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
@@ -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';
|
|
@@ -102,12 +102,15 @@ class Task extends ReactNodeView {
|
|
|
102
102
|
plugins: {
|
|
103
103
|
taskDecisionPlugin: taskPluginKey
|
|
104
104
|
},
|
|
105
|
-
render: (
|
|
105
|
+
render: ({
|
|
106
|
+
taskDecisionPlugin
|
|
107
|
+
}) => {
|
|
106
108
|
return /*#__PURE__*/React.createElement(TaskItem, {
|
|
107
109
|
taskId: localId,
|
|
108
110
|
contentRef: forwardRef,
|
|
109
111
|
isDone: state === 'DONE',
|
|
110
112
|
onChange: this.handleOnChange,
|
|
113
|
+
isFocused: (taskDecisionPlugin === null || taskDecisionPlugin === void 0 ? void 0 : taskDecisionPlugin.focusedTaskItemLocalId) === localId,
|
|
111
114
|
showPlaceholder: this.isContentEmpty(this.node) && !isTypeAheadOpen(this.view.state),
|
|
112
115
|
providers: props.providerFactory
|
|
113
116
|
});
|
|
@@ -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 const isInsideTaskOrDecisionItem = state => {
|
|
5
8
|
const {
|
|
6
9
|
decisionItem,
|
|
@@ -193,4 +196,121 @@ export const liftBlock = (tr, $from, $to) => {
|
|
|
193
196
|
return null;
|
|
194
197
|
}
|
|
195
198
|
return tr.lift(blockRange, target).scrollIntoView();
|
|
196
|
-
};
|
|
199
|
+
};
|
|
200
|
+
export function getTaskItemDataAtPos(view) {
|
|
201
|
+
const {
|
|
202
|
+
state
|
|
203
|
+
} = view;
|
|
204
|
+
const {
|
|
205
|
+
selection,
|
|
206
|
+
schema
|
|
207
|
+
} = state;
|
|
208
|
+
const {
|
|
209
|
+
$from
|
|
210
|
+
} = selection;
|
|
211
|
+
const isInTaskItem = $from.node().type === schema.nodes.taskItem;
|
|
212
|
+
|
|
213
|
+
// current selection has to be inside taskitem
|
|
214
|
+
if (isInTaskItem) {
|
|
215
|
+
const taskItemPos = $from.before();
|
|
216
|
+
return {
|
|
217
|
+
pos: taskItemPos,
|
|
218
|
+
localId: $from.node().attrs.localId
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
export function getAllTaskItemsDataInRootTaskList(view) {
|
|
223
|
+
const {
|
|
224
|
+
state
|
|
225
|
+
} = view;
|
|
226
|
+
const {
|
|
227
|
+
schema
|
|
228
|
+
} = state;
|
|
229
|
+
const $fromPos = state.selection.$from;
|
|
230
|
+
const isInTaskItem = $fromPos.node().type === schema.nodes.taskItem;
|
|
231
|
+
// if not inside task item then return undefined;
|
|
232
|
+
if (!isInTaskItem) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const {
|
|
236
|
+
taskList,
|
|
237
|
+
taskItem
|
|
238
|
+
} = schema.nodes;
|
|
239
|
+
const rootTaskListData = findFarthestParentNode(node => node.type === taskList)($fromPos);
|
|
240
|
+
if (rootTaskListData) {
|
|
241
|
+
const rootTaskList = rootTaskListData.node;
|
|
242
|
+
const rootTaskListStartPos = rootTaskListData.start;
|
|
243
|
+
const allTaskItems = [];
|
|
244
|
+
rootTaskList.descendants((node, pos, parent, index) => {
|
|
245
|
+
if (node.type === taskItem) {
|
|
246
|
+
allTaskItems.push({
|
|
247
|
+
node,
|
|
248
|
+
pos: pos + rootTaskListStartPos,
|
|
249
|
+
index
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
return allTaskItems;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
export function getCurrentTaskItemIndex(view, allTaskItems) {
|
|
257
|
+
const {
|
|
258
|
+
state
|
|
259
|
+
} = view;
|
|
260
|
+
const $fromPos = state.selection.$from;
|
|
261
|
+
const allTaskItemNodes = allTaskItems.map(nodeData => nodeData.node);
|
|
262
|
+
const currentTaskItem = $fromPos.node($fromPos.depth);
|
|
263
|
+
const currentTaskItemIndex = allTaskItemNodes.indexOf(currentTaskItem);
|
|
264
|
+
return currentTaskItemIndex;
|
|
265
|
+
}
|
|
266
|
+
export function getTaskItemDataToFocus(view, direction) {
|
|
267
|
+
const allTaskItems = getAllTaskItemsDataInRootTaskList(view);
|
|
268
|
+
// if not inside task item then allTaskItems will be undefined;
|
|
269
|
+
if (!allTaskItems) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const currentTaskItemIndex = getCurrentTaskItemIndex(view, allTaskItems);
|
|
273
|
+
if (direction === 'next' ? currentTaskItemIndex === allTaskItems.length - 1 : currentTaskItemIndex === 0) {
|
|
274
|
+
// checkbox of first or last task item is already focused based on direction.
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
const indexOfTaskItemToFocus = direction === 'next' ? currentTaskItemIndex + 1 : currentTaskItemIndex - 1;
|
|
278
|
+
const taskItemToFocus = allTaskItems[indexOfTaskItemToFocus];
|
|
279
|
+
return {
|
|
280
|
+
pos: taskItemToFocus.pos,
|
|
281
|
+
localId: taskItemToFocus.node.attrs.localId
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
export function focusCheckboxAndUpdateSelection(view, taskItemData) {
|
|
285
|
+
const {
|
|
286
|
+
pos,
|
|
287
|
+
localId
|
|
288
|
+
} = taskItemData;
|
|
289
|
+
const {
|
|
290
|
+
state,
|
|
291
|
+
dispatch
|
|
292
|
+
} = view;
|
|
293
|
+
const {
|
|
294
|
+
doc,
|
|
295
|
+
tr
|
|
296
|
+
} = state;
|
|
297
|
+
tr.setSelection(new TextSelection(doc.resolve(pos + 1)));
|
|
298
|
+
tr.setMeta(stateKey, {
|
|
299
|
+
action: ACTIONS.FOCUS_BY_LOCALID,
|
|
300
|
+
data: localId
|
|
301
|
+
});
|
|
302
|
+
dispatch(tr);
|
|
303
|
+
}
|
|
304
|
+
export function removeCheckboxFocus(view) {
|
|
305
|
+
const {
|
|
306
|
+
state,
|
|
307
|
+
dispatch
|
|
308
|
+
} = view;
|
|
309
|
+
const {
|
|
310
|
+
tr
|
|
311
|
+
} = state;
|
|
312
|
+
view.focus();
|
|
313
|
+
dispatch(tr.setMeta(stateKey, {
|
|
314
|
+
action: ACTIONS.FOCUS_BY_LOCALID
|
|
315
|
+
}));
|
|
316
|
+
}
|