@atlaskit/editor-core 189.3.28 → 189.3.30
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 +13 -0
- package/dist/cjs/create-editor/feature-flags-from-props.js +4 -5
- package/dist/cjs/i18n/cs.js +0 -3
- package/dist/cjs/i18n/da.js +0 -3
- package/dist/cjs/i18n/de.js +0 -3
- package/dist/cjs/i18n/en.js +0 -3
- package/dist/cjs/i18n/en_GB.js +0 -3
- package/dist/cjs/i18n/en_ZZ.js +0 -3
- package/dist/cjs/i18n/es.js +0 -3
- package/dist/cjs/i18n/fi.js +0 -3
- package/dist/cjs/i18n/fr.js +0 -3
- package/dist/cjs/i18n/hu.js +0 -3
- package/dist/cjs/i18n/it.js +0 -3
- package/dist/cjs/i18n/ja.js +0 -3
- package/dist/cjs/i18n/ko.js +0 -3
- package/dist/cjs/i18n/nb.js +0 -3
- package/dist/cjs/i18n/nl.js +0 -3
- package/dist/cjs/i18n/pl.js +0 -3
- package/dist/cjs/i18n/pt_BR.js +0 -3
- package/dist/cjs/i18n/ru.js +0 -3
- package/dist/cjs/i18n/sv.js +0 -3
- package/dist/cjs/i18n/th.js +0 -3
- package/dist/cjs/i18n/tr.js +0 -3
- package/dist/cjs/i18n/uk.js +0 -3
- package/dist/cjs/i18n/vi.js +0 -3
- package/dist/cjs/i18n/zh.js +0 -3
- package/dist/cjs/i18n/zh_TW.js +0 -3
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/presets/universal.js +2 -1
- package/dist/cjs/utils/document.js +0 -6
- package/dist/cjs/utils/index.js +0 -6
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/create-editor/feature-flags-from-props.js +4 -5
- package/dist/es2019/i18n/cs.js +0 -3
- package/dist/es2019/i18n/da.js +0 -3
- package/dist/es2019/i18n/de.js +0 -3
- package/dist/es2019/i18n/en.js +0 -3
- package/dist/es2019/i18n/en_GB.js +0 -3
- package/dist/es2019/i18n/en_ZZ.js +0 -3
- package/dist/es2019/i18n/es.js +0 -3
- package/dist/es2019/i18n/fi.js +0 -3
- package/dist/es2019/i18n/fr.js +0 -3
- package/dist/es2019/i18n/hu.js +0 -3
- package/dist/es2019/i18n/it.js +0 -3
- package/dist/es2019/i18n/ja.js +0 -3
- package/dist/es2019/i18n/ko.js +0 -3
- package/dist/es2019/i18n/nb.js +0 -3
- package/dist/es2019/i18n/nl.js +0 -3
- package/dist/es2019/i18n/pl.js +0 -3
- package/dist/es2019/i18n/pt_BR.js +0 -3
- package/dist/es2019/i18n/ru.js +0 -3
- package/dist/es2019/i18n/sv.js +0 -3
- package/dist/es2019/i18n/th.js +0 -3
- package/dist/es2019/i18n/tr.js +0 -3
- package/dist/es2019/i18n/uk.js +0 -3
- package/dist/es2019/i18n/vi.js +0 -3
- package/dist/es2019/i18n/zh.js +0 -3
- package/dist/es2019/i18n/zh_TW.js +0 -3
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/presets/universal.js +2 -1
- package/dist/es2019/utils/document.js +1 -1
- package/dist/es2019/utils/index.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/create-editor/feature-flags-from-props.js +4 -5
- package/dist/esm/i18n/cs.js +0 -3
- package/dist/esm/i18n/da.js +0 -3
- package/dist/esm/i18n/de.js +0 -3
- package/dist/esm/i18n/en.js +0 -3
- package/dist/esm/i18n/en_GB.js +0 -3
- package/dist/esm/i18n/en_ZZ.js +0 -3
- package/dist/esm/i18n/es.js +0 -3
- package/dist/esm/i18n/fi.js +0 -3
- package/dist/esm/i18n/fr.js +0 -3
- package/dist/esm/i18n/hu.js +0 -3
- package/dist/esm/i18n/it.js +0 -3
- package/dist/esm/i18n/ja.js +0 -3
- package/dist/esm/i18n/ko.js +0 -3
- package/dist/esm/i18n/nb.js +0 -3
- package/dist/esm/i18n/nl.js +0 -3
- package/dist/esm/i18n/pl.js +0 -3
- package/dist/esm/i18n/pt_BR.js +0 -3
- package/dist/esm/i18n/ru.js +0 -3
- package/dist/esm/i18n/sv.js +0 -3
- package/dist/esm/i18n/th.js +0 -3
- package/dist/esm/i18n/tr.js +0 -3
- package/dist/esm/i18n/uk.js +0 -3
- package/dist/esm/i18n/vi.js +0 -3
- package/dist/esm/i18n/zh.js +0 -3
- package/dist/esm/i18n/zh_TW.js +0 -3
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/presets/universal.js +2 -1
- package/dist/esm/utils/document.js +1 -1
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/i18n/cs.d.ts +0 -3
- package/dist/types/i18n/da.d.ts +0 -3
- package/dist/types/i18n/de.d.ts +0 -3
- package/dist/types/i18n/en.d.ts +0 -3
- package/dist/types/i18n/en_GB.d.ts +0 -3
- package/dist/types/i18n/en_ZZ.d.ts +0 -3
- package/dist/types/i18n/es.d.ts +0 -3
- package/dist/types/i18n/fi.d.ts +0 -3
- package/dist/types/i18n/fr.d.ts +0 -3
- package/dist/types/i18n/hu.d.ts +0 -3
- package/dist/types/i18n/it.d.ts +0 -3
- package/dist/types/i18n/ja.d.ts +0 -3
- package/dist/types/i18n/ko.d.ts +0 -3
- package/dist/types/i18n/nb.d.ts +0 -3
- package/dist/types/i18n/nl.d.ts +0 -3
- package/dist/types/i18n/pl.d.ts +0 -3
- package/dist/types/i18n/pt_BR.d.ts +0 -3
- package/dist/types/i18n/ru.d.ts +0 -3
- package/dist/types/i18n/sv.d.ts +0 -3
- package/dist/types/i18n/th.d.ts +0 -3
- package/dist/types/i18n/tr.d.ts +0 -3
- package/dist/types/i18n/uk.d.ts +0 -3
- package/dist/types/i18n/vi.d.ts +0 -3
- package/dist/types/i18n/zh.d.ts +0 -3
- package/dist/types/i18n/zh_TW.d.ts +0 -3
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/insert-block/types.d.ts +2 -2
- package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +2 -2
- package/dist/types/utils/document.d.ts +1 -1
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types-ts4.5/i18n/cs.d.ts +0 -3
- package/dist/types-ts4.5/i18n/da.d.ts +0 -3
- package/dist/types-ts4.5/i18n/de.d.ts +0 -3
- package/dist/types-ts4.5/i18n/en.d.ts +0 -3
- package/dist/types-ts4.5/i18n/en_GB.d.ts +0 -3
- package/dist/types-ts4.5/i18n/en_ZZ.d.ts +0 -3
- package/dist/types-ts4.5/i18n/es.d.ts +0 -3
- package/dist/types-ts4.5/i18n/fi.d.ts +0 -3
- package/dist/types-ts4.5/i18n/fr.d.ts +0 -3
- package/dist/types-ts4.5/i18n/hu.d.ts +0 -3
- package/dist/types-ts4.5/i18n/it.d.ts +0 -3
- package/dist/types-ts4.5/i18n/ja.d.ts +0 -3
- package/dist/types-ts4.5/i18n/ko.d.ts +0 -3
- package/dist/types-ts4.5/i18n/nb.d.ts +0 -3
- package/dist/types-ts4.5/i18n/nl.d.ts +0 -3
- package/dist/types-ts4.5/i18n/pl.d.ts +0 -3
- package/dist/types-ts4.5/i18n/pt_BR.d.ts +0 -3
- package/dist/types-ts4.5/i18n/ru.d.ts +0 -3
- package/dist/types-ts4.5/i18n/sv.d.ts +0 -3
- package/dist/types-ts4.5/i18n/th.d.ts +0 -3
- package/dist/types-ts4.5/i18n/tr.d.ts +0 -3
- package/dist/types-ts4.5/i18n/uk.d.ts +0 -3
- package/dist/types-ts4.5/i18n/vi.d.ts +0 -3
- package/dist/types-ts4.5/i18n/zh.d.ts +0 -3
- package/dist/types-ts4.5/i18n/zh_TW.d.ts +0 -3
- 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/toolbar-lists-indentation/index.d.ts +2 -2
- package/dist/types-ts4.5/utils/document.d.ts +1 -1
- package/dist/types-ts4.5/utils/index.d.ts +1 -1
- package/package.json +5 -5
- package/dist/cjs/plugins/tasks-and-decisions/commands.js +0 -288
- package/dist/cjs/plugins/tasks-and-decisions/index.js +0 -166
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +0 -117
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +0 -40
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +0 -211
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/commands.js +0 -96
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/helpers.js +0 -299
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/input-rules.js +0 -94
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/keymaps.js +0 -376
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/main.js +0 -263
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/plugin-key.js +0 -8
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/types.js +0 -11
- package/dist/cjs/plugins/tasks-and-decisions/types.js +0 -5
- package/dist/cjs/plugins/tasks-and-decisions/ui/Decision/index.js +0 -51
- package/dist/cjs/plugins/tasks-and-decisions/ui/Task/index.js +0 -80
- package/dist/cjs/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.js +0 -137
- package/dist/cjs/plugins/tasks-and-decisions/ui/ToolbarDecision/index.js +0 -76
- package/dist/cjs/plugins/tasks-and-decisions/ui/ToolbarTask/index.js +0 -75
- package/dist/cjs/plugins/tasks-and-decisions/utils.js +0 -41
- package/dist/es2019/plugins/tasks-and-decisions/commands.js +0 -279
- package/dist/es2019/plugins/tasks-and-decisions/index.js +0 -155
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +0 -76
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +0 -36
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +0 -173
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/commands.js +0 -94
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/helpers.js +0 -316
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/input-rules.js +0 -91
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +0 -370
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/main.js +0 -262
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/plugin-key.js +0 -2
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/types.js +0 -5
- package/dist/es2019/plugins/tasks-and-decisions/types.js +0 -1
- package/dist/es2019/plugins/tasks-and-decisions/ui/Decision/index.js +0 -30
- package/dist/es2019/plugins/tasks-and-decisions/ui/Task/index.js +0 -54
- package/dist/es2019/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.js +0 -71
- package/dist/es2019/plugins/tasks-and-decisions/ui/ToolbarDecision/index.js +0 -52
- package/dist/es2019/plugins/tasks-and-decisions/ui/ToolbarTask/index.js +0 -51
- package/dist/es2019/plugins/tasks-and-decisions/utils.js +0 -32
- package/dist/esm/plugins/tasks-and-decisions/commands.js +0 -281
- package/dist/esm/plugins/tasks-and-decisions/index.js +0 -156
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +0 -110
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +0 -34
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +0 -204
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/commands.js +0 -90
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/helpers.js +0 -285
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/input-rules.js +0 -87
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +0 -368
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/main.js +0 -256
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/plugin-key.js +0 -2
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/types.js +0 -5
- package/dist/esm/plugins/tasks-and-decisions/types.js +0 -1
- package/dist/esm/plugins/tasks-and-decisions/ui/Decision/index.js +0 -44
- package/dist/esm/plugins/tasks-and-decisions/ui/Task/index.js +0 -70
- package/dist/esm/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.js +0 -128
- package/dist/esm/plugins/tasks-and-decisions/ui/ToolbarDecision/index.js +0 -66
- package/dist/esm/plugins/tasks-and-decisions/ui/ToolbarTask/index.js +0 -65
- package/dist/esm/plugins/tasks-and-decisions/utils.js +0 -30
- package/dist/types/plugins/tasks-and-decisions/commands.d.ts +0 -16
- package/dist/types/plugins/tasks-and-decisions/index.d.ts +0 -3
- package/dist/types/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +0 -10
- package/dist/types/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.d.ts +0 -11
- package/dist/types/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +0 -14
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/commands.d.ts +0 -15
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/helpers.d.ts +0 -76
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/input-rules.d.ts +0 -6
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/keymaps.d.ts +0 -11
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/main.d.ts +0 -7
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/plugin-key.d.ts +0 -2
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/types.d.ts +0 -8
- package/dist/types/plugins/tasks-and-decisions/types.d.ts +0 -49
- package/dist/types/plugins/tasks-and-decisions/ui/Decision/index.d.ts +0 -14
- package/dist/types/plugins/tasks-and-decisions/ui/Task/index.d.ts +0 -28
- package/dist/types/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.d.ts +0 -29
- package/dist/types/plugins/tasks-and-decisions/ui/ToolbarDecision/index.d.ts +0 -23
- package/dist/types/plugins/tasks-and-decisions/ui/ToolbarTask/index.d.ts +0 -23
- package/dist/types/plugins/tasks-and-decisions/utils.d.ts +0 -4
- package/dist/types-ts4.5/plugins/tasks-and-decisions/commands.d.ts +0 -16
- package/dist/types-ts4.5/plugins/tasks-and-decisions/index.d.ts +0 -3
- package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +0 -10
- package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.d.ts +0 -11
- package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +0 -14
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/commands.d.ts +0 -15
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/helpers.d.ts +0 -76
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/input-rules.d.ts +0 -6
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/keymaps.d.ts +0 -11
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/main.d.ts +0 -7
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/plugin-key.d.ts +0 -2
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/types.d.ts +0 -8
- package/dist/types-ts4.5/plugins/tasks-and-decisions/types.d.ts +0 -49
- package/dist/types-ts4.5/plugins/tasks-and-decisions/ui/Decision/index.d.ts +0 -14
- package/dist/types-ts4.5/plugins/tasks-and-decisions/ui/Task/index.d.ts +0 -28
- package/dist/types-ts4.5/plugins/tasks-and-decisions/ui/Task/task-item-with-providers.d.ts +0 -29
- package/dist/types-ts4.5/plugins/tasks-and-decisions/ui/ToolbarDecision/index.d.ts +0 -23
- package/dist/types-ts4.5/plugins/tasks-and-decisions/ui/ToolbarTask/index.d.ts +0 -23
- package/dist/types-ts4.5/plugins/tasks-and-decisions/utils.d.ts +0 -4
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.inputRulePlugin = exports.default = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
|
-
var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
|
|
12
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
|
-
var _commands = require("../commands");
|
|
14
|
-
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; }
|
|
15
|
-
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; }
|
|
16
|
-
var createListRule = function createListRule(editorAnalyticsAPI) {
|
|
17
|
-
return function (regex, listType, itemAttrs) {
|
|
18
|
-
return (0, _prosemirrorInputRules.createRule)(regex, function (state, _match, start, end) {
|
|
19
|
-
var paragraph = state.schema.nodes.paragraph;
|
|
20
|
-
var _getListTypes = (0, _commands.getListTypes)(listType, state.schema),
|
|
21
|
-
list = _getListTypes.list;
|
|
22
|
-
var $end = state.doc.resolve(end);
|
|
23
|
-
var $endOfParent = state.doc.resolve($end.after());
|
|
24
|
-
// Only allow creating list in nodes that support them.
|
|
25
|
-
// Parent must be a paragraph as we don't want this applying to headings
|
|
26
|
-
if ($end.parent.type !== paragraph || !(0, _utils.canInsert)($endOfParent, list.createAndFill())) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
var insertTr = (0, _commands.insertTaskDecisionAction)(editorAnalyticsAPI)(state, listType, _analytics.INPUT_METHOD.FORMATTING, addItem(start, end), undefined, undefined, itemAttrs);
|
|
30
|
-
return insertTr;
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
var addItem = function addItem(start, end) {
|
|
35
|
-
return function (_ref) {
|
|
36
|
-
var tr = _ref.tr,
|
|
37
|
-
state = _ref.state,
|
|
38
|
-
list = _ref.list,
|
|
39
|
-
item = _ref.item,
|
|
40
|
-
listLocalId = _ref.listLocalId,
|
|
41
|
-
itemLocalId = _ref.itemLocalId,
|
|
42
|
-
itemAttrs = _ref.itemAttrs;
|
|
43
|
-
var $from = state.selection.$from,
|
|
44
|
-
schema = state.schema;
|
|
45
|
-
var hardBreak = schema.nodes.hardBreak;
|
|
46
|
-
var content = $from.node($from.depth).content;
|
|
47
|
-
var shouldBreakNode = false;
|
|
48
|
-
content.forEach(function (node, offset) {
|
|
49
|
-
if (node.type === hardBreak && offset < start) {
|
|
50
|
-
shouldBreakNode = true;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
if (!shouldBreakNode) {
|
|
54
|
-
tr.replaceRangeWith($from.before(), $from.after(), list.create({
|
|
55
|
-
localId: listLocalId
|
|
56
|
-
}, [item.create(_objectSpread({
|
|
57
|
-
localId: itemLocalId
|
|
58
|
-
}, itemAttrs), content)])).delete(start + 1, end + 1).setSelection(new _state.TextSelection(tr.doc.resolve(start + 1)));
|
|
59
|
-
} else {
|
|
60
|
-
var depthAdjustment = (0, _commands.changeInDepth)($from, tr.selection.$from);
|
|
61
|
-
tr.split($from.pos).setSelection(new _state.NodeSelection(tr.doc.resolve($from.pos + 1))).replaceSelectionWith(list.create({
|
|
62
|
-
localId: listLocalId
|
|
63
|
-
}, [item.create(_objectSpread({
|
|
64
|
-
localId: itemLocalId
|
|
65
|
-
}, itemAttrs),
|
|
66
|
-
// TODO: [ts30] handle void and null properly
|
|
67
|
-
tr.doc.nodeAt($from.pos + 1).content)])).setSelection(new _state.TextSelection(tr.doc.resolve($from.pos + depthAdjustment))).delete(start, end + 1);
|
|
68
|
-
}
|
|
69
|
-
return tr;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
var inputRulePlugin = exports.inputRulePlugin = function inputRulePlugin(editorAnalyticsAPI) {
|
|
73
|
-
return function (schema, featureFlags) {
|
|
74
|
-
var rules = [];
|
|
75
|
-
var _schema$nodes = schema.nodes,
|
|
76
|
-
decisionList = _schema$nodes.decisionList,
|
|
77
|
-
decisionItem = _schema$nodes.decisionItem,
|
|
78
|
-
taskList = _schema$nodes.taskList,
|
|
79
|
-
taskItem = _schema$nodes.taskItem;
|
|
80
|
-
if (decisionList && decisionItem) {
|
|
81
|
-
rules.push(createListRule(editorAnalyticsAPI)(new RegExp("(^|".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, ")\\<\\>\\s$")), 'decisionList'));
|
|
82
|
-
}
|
|
83
|
-
if (taskList && taskItem) {
|
|
84
|
-
rules.push(createListRule(editorAnalyticsAPI)(new RegExp("(^|".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, ")\\[\\]\\s$")), 'taskList'));
|
|
85
|
-
rules.push(createListRule(editorAnalyticsAPI)(new RegExp("(^|".concat(_prosemirrorInputRules.leafNodeReplacementCharacter, ")\\[x\\]\\s$")), 'taskList', {
|
|
86
|
-
state: 'DONE'
|
|
87
|
-
}));
|
|
88
|
-
}
|
|
89
|
-
return (0, _prosemirrorInputRules.createPlugin)('tasks-and-decisions', rules, {
|
|
90
|
-
isBlockNodeRule: true
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
var _default = exports.default = inputRulePlugin;
|
|
@@ -1,376 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getUnindentCommand = exports.getIndentCommand = exports.default = void 0;
|
|
8
|
-
exports.keymapPlugin = keymapPlugin;
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
var _commands = require("@atlaskit/editor-prosemirror/commands");
|
|
11
|
-
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
12
|
-
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
13
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
|
-
var _steps = require("@atlaskit/adf-schema/steps");
|
|
15
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
16
|
-
var _adfSchema = require("@atlaskit/adf-schema");
|
|
17
|
-
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
18
|
-
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
19
|
-
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
20
|
-
var _commands2 = require("../commands");
|
|
21
|
-
var _commands3 = require("./commands");
|
|
22
|
-
var _helpers = require("./helpers");
|
|
23
|
-
var _utils3 = require("../utils");
|
|
24
|
-
var _keymaps = require("../../../keymaps");
|
|
25
|
-
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; }
|
|
26
|
-
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; }
|
|
27
|
-
var indentationAnalytics = function indentationAnalytics(curIndentLevel, direction, inputMethod) {
|
|
28
|
-
return {
|
|
29
|
-
action: _analytics.ACTION.FORMATTED,
|
|
30
|
-
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
31
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_INDENT,
|
|
32
|
-
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
33
|
-
attributes: {
|
|
34
|
-
inputMethod: inputMethod,
|
|
35
|
-
previousIndentationLevel: curIndentLevel,
|
|
36
|
-
newIndentLevel: direction === _analytics.INDENT_DIRECTION.OUTDENT ? curIndentLevel - 1 : curIndentLevel + 1,
|
|
37
|
-
direction: direction,
|
|
38
|
-
indentType: _analytics.INDENT_TYPE.TASK_LIST
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
};
|
|
42
|
-
var nodeAfter = function nodeAfter($pos) {
|
|
43
|
-
return $pos.doc.resolve($pos.end()).nodeAfter;
|
|
44
|
-
};
|
|
45
|
-
var actionDecisionFollowsOrNothing = function actionDecisionFollowsOrNothing($pos) {
|
|
46
|
-
var after = nodeAfter($pos);
|
|
47
|
-
return !after || (0, _helpers.isActionOrDecisionItem)(after);
|
|
48
|
-
};
|
|
49
|
-
var joinTaskDecisionFollowing = function joinTaskDecisionFollowing(state, dispatch) {
|
|
50
|
-
// only run if selection is at end of text, and inside a task or decision item
|
|
51
|
-
if (!(0, _utils2.isEmptySelectionAtEnd)(state) || !(0, _helpers.isInsideTaskOrDecisionItem)(state) || !dispatch) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
// look for the node after this current one
|
|
55
|
-
var $next = (0, _helpers.walkOut)(state.selection.$from);
|
|
56
|
-
|
|
57
|
-
// if there's no taskItem or taskList following, then
|
|
58
|
-
// we just do the normal behaviour
|
|
59
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
60
|
-
taskList = _state$schema$nodes.taskList,
|
|
61
|
-
taskItem = _state$schema$nodes.taskItem,
|
|
62
|
-
decisionList = _state$schema$nodes.decisionList,
|
|
63
|
-
decisionItem = _state$schema$nodes.decisionItem,
|
|
64
|
-
paragraph = _state$schema$nodes.paragraph,
|
|
65
|
-
bulletList = _state$schema$nodes.bulletList,
|
|
66
|
-
orderedList = _state$schema$nodes.orderedList,
|
|
67
|
-
listItem = _state$schema$nodes.listItem;
|
|
68
|
-
var parentList = (0, _utils.findParentNodeOfTypeClosestToPos)($next, [taskList, taskItem, decisionList, decisionItem]);
|
|
69
|
-
if (!parentList) {
|
|
70
|
-
if ($next.parent.type === paragraph) {
|
|
71
|
-
// try to join paragraph and taskList when backspacing
|
|
72
|
-
return (0, _commands3.joinAtCut)($next.doc.resolve($next.pos))(state, dispatch);
|
|
73
|
-
}
|
|
74
|
-
// If the item we are joining is a list
|
|
75
|
-
if ($next.parent.type === bulletList || $next.parent.type === orderedList) {
|
|
76
|
-
// If the list has an item
|
|
77
|
-
if ($next.parent.firstChild && $next.parent.firstChild.type === listItem) {
|
|
78
|
-
// Place the cursor at the first listItem
|
|
79
|
-
var resolvedStartPos = state.doc.resolve($next.pos + 1);
|
|
80
|
-
// Unindent the first listItem.
|
|
81
|
-
// As if placing your cursor just after the first dot of the list (before the text)
|
|
82
|
-
// and pressing Shift-Tab.
|
|
83
|
-
var tr = (0, _helpers.liftBlock)(state.tr, resolvedStartPos, resolvedStartPos);
|
|
84
|
-
|
|
85
|
-
// If autoJoin not used, two ul/ol elements appear rather than one with multiple li elements
|
|
86
|
-
return (0, _commands.autoJoin)(function (state, dispatch) {
|
|
87
|
-
if (tr) {
|
|
88
|
-
if (dispatch) {
|
|
89
|
-
dispatch(tr);
|
|
90
|
-
}
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
return false;
|
|
94
|
-
}, ['bulletList', 'orderedList'])(state, dispatch);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return false;
|
|
99
|
-
};
|
|
100
|
-
var getUnindentCommand = exports.getUnindentCommand = function getUnindentCommand(editorAnalyticsAPI) {
|
|
101
|
-
return function () {
|
|
102
|
-
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _analytics.INPUT_METHOD.KEYBOARD;
|
|
103
|
-
return (0, _utils2.filterCommand)(_helpers.isInsideTask, function (state, dispatch) {
|
|
104
|
-
var normalizedSelection = (0, _utils3.normalizeTaskItemsSelection)(state.selection);
|
|
105
|
-
var curIndentLevel = (0, _helpers.getCurrentIndentLevel)(normalizedSelection);
|
|
106
|
-
if (!curIndentLevel || curIndentLevel === 1) {
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, indentationAnalytics(curIndentLevel, _analytics.INDENT_DIRECTION.OUTDENT, inputMethod))((0, _commands.autoJoin)(_commands3.liftSelection, ['taskList']))(state, dispatch);
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
// if selection is decision item or first action item in table cell
|
|
115
|
-
// then dont consume the Tab, as table-keymap should tab to the next cell
|
|
116
|
-
var shouldLetTabThroughInTable = function shouldLetTabThroughInTable(state) {
|
|
117
|
-
var curIndentLevel = (0, _helpers.getCurrentIndentLevel)(state.selection);
|
|
118
|
-
var curIndex = (0, _helpers.getTaskItemIndex)(state);
|
|
119
|
-
var _state$schema$nodes2 = state.schema.nodes,
|
|
120
|
-
tableCell = _state$schema$nodes2.tableCell,
|
|
121
|
-
tableHeader = _state$schema$nodes2.tableHeader;
|
|
122
|
-
var cell = (0, _utils.findParentNodeOfType)([tableCell, tableHeader])(state.selection);
|
|
123
|
-
if ((curIndentLevel === 1 && curIndex === 0 || (0, _helpers.isInsideDecision)(state)) && cell) {
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
return false;
|
|
127
|
-
};
|
|
128
|
-
var getIndentCommand = exports.getIndentCommand = function getIndentCommand(editorAnalyticsAPI) {
|
|
129
|
-
return function () {
|
|
130
|
-
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _analytics.INPUT_METHOD.KEYBOARD;
|
|
131
|
-
return (0, _utils2.filterCommand)(_helpers.isInsideTask, function (state, dispatch) {
|
|
132
|
-
var normalizedSelection = (0, _utils3.normalizeTaskItemsSelection)(state.selection);
|
|
133
|
-
var curIndentLevel = (0, _helpers.getCurrentIndentLevel)(normalizedSelection);
|
|
134
|
-
if (!curIndentLevel || curIndentLevel >= 6) {
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, indentationAnalytics(curIndentLevel, _analytics.INDENT_DIRECTION.INDENT, inputMethod))((0, _commands.autoJoin)(_commands3.wrapSelectionInTaskList, ['taskList']))(state, dispatch);
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
var backspaceFrom = function backspaceFrom(editorAnalyticsAPI) {
|
|
142
|
-
return function ($from) {
|
|
143
|
-
return function (state, dispatch) {
|
|
144
|
-
// previous was empty, just delete backwards
|
|
145
|
-
var taskBefore = $from.doc.resolve($from.before());
|
|
146
|
-
if (taskBefore.nodeBefore && (0, _helpers.isActionOrDecisionItem)(taskBefore.nodeBefore) && taskBefore.nodeBefore.nodeSize === 2) {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// if nested, just unindent
|
|
151
|
-
var _state$schema$nodes3 = state.schema.nodes,
|
|
152
|
-
taskList = _state$schema$nodes3.taskList,
|
|
153
|
-
paragraph = _state$schema$nodes3.paragraph;
|
|
154
|
-
if ($from.node($from.depth - 2).type === taskList) {
|
|
155
|
-
return getUnindentCommand(editorAnalyticsAPI)()(state, dispatch);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// bottom level, should "unwrap" taskItem contents into paragraph
|
|
159
|
-
// we achieve this by slicing the content out, and replacing
|
|
160
|
-
if (actionDecisionFollowsOrNothing($from)) {
|
|
161
|
-
if (dispatch) {
|
|
162
|
-
var taskContent = state.doc.slice($from.start(), $from.end()).content;
|
|
163
|
-
|
|
164
|
-
// might be end of document after
|
|
165
|
-
var slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : paragraph.createChecked();
|
|
166
|
-
dispatch(splitListItemWith(state.tr, slice, $from, true));
|
|
167
|
-
}
|
|
168
|
-
return true;
|
|
169
|
-
}
|
|
170
|
-
return false;
|
|
171
|
-
};
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
var backspace = function backspace(editorAnalyticsAPI) {
|
|
175
|
-
return (0, _utils2.filterCommand)(_utils2.isEmptySelectionAtStart, (0, _commands.autoJoin)((0, _commands.chainCommands)(function (state, dispatch) {
|
|
176
|
-
return (0, _commands3.joinAtCut)(state.selection.$from)(state, dispatch);
|
|
177
|
-
}, (0, _utils2.filterCommand)(_helpers.isInsideTaskOrDecisionItem, function (state, dispatch) {
|
|
178
|
-
return backspaceFrom(editorAnalyticsAPI)(state.selection.$from)(state, dispatch);
|
|
179
|
-
})), ['taskList', 'decisionList']));
|
|
180
|
-
};
|
|
181
|
-
var unindentTaskOrUnwrapTaskDecisionFollowing = function unindentTaskOrUnwrapTaskDecisionFollowing(state, dispatch) {
|
|
182
|
-
var $from = state.selection.$from,
|
|
183
|
-
_state$schema$nodes4 = state.schema.nodes,
|
|
184
|
-
taskList = _state$schema$nodes4.taskList,
|
|
185
|
-
doc = _state$schema$nodes4.doc,
|
|
186
|
-
paragraph = _state$schema$nodes4.paragraph,
|
|
187
|
-
tr = state.tr;
|
|
188
|
-
|
|
189
|
-
// only run if cursor is at the end of the node
|
|
190
|
-
if (!(0, _utils2.isEmptySelectionAtEnd)(state) || !dispatch) {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// look for the node after this current one
|
|
195
|
-
var $next = (0, _helpers.walkOut)($from);
|
|
196
|
-
|
|
197
|
-
// this is a top-level node it wont have $next.before()
|
|
198
|
-
if (!$next.parent || $next.parent.type === doc) {
|
|
199
|
-
return false;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// if nested, just unindent
|
|
203
|
-
if ($next.node($next.depth - 2).type === taskList ||
|
|
204
|
-
// this is for the case when we are on a non-nested item and next one is nested
|
|
205
|
-
$next.node($next.depth - 1).type === taskList && $next.parent.type === taskList) {
|
|
206
|
-
(0, _helpers.liftBlock)(tr, $next, $next);
|
|
207
|
-
dispatch(tr);
|
|
208
|
-
return true;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// if next node is of same type, remove the node wrapping and create paragraph
|
|
212
|
-
if (!(0, _helpers.isTable)($next.nodeAfter) && (0, _helpers.isActionOrDecisionItem)($from.parent) && actionDecisionFollowsOrNothing($from) &&
|
|
213
|
-
// only forward delete if the node is same type
|
|
214
|
-
$next.node().type.name === $from.node().type.name) {
|
|
215
|
-
var taskContent = state.doc.slice($next.start(), $next.end()).content;
|
|
216
|
-
|
|
217
|
-
// might be end of document after
|
|
218
|
-
var slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : [];
|
|
219
|
-
dispatch(splitListItemWith(tr, slice, $next, false));
|
|
220
|
-
return true;
|
|
221
|
-
}
|
|
222
|
-
return false;
|
|
223
|
-
};
|
|
224
|
-
var deleteForwards = (0, _commands.autoJoin)((0, _commands.chainCommands)((0, _utils2.deleteEmptyParagraphAndMoveBlockUp)(_helpers.isActionOrDecisionList), joinTaskDecisionFollowing, unindentTaskOrUnwrapTaskDecisionFollowing), ['taskList', 'decisionList']);
|
|
225
|
-
var splitListItemWith = function splitListItemWith(tr, content, $from, setSelection) {
|
|
226
|
-
var origDoc = tr.doc;
|
|
227
|
-
|
|
228
|
-
// split just before the current item
|
|
229
|
-
// we can only split if there was a list item before us
|
|
230
|
-
var container = $from.node($from.depth - 2);
|
|
231
|
-
var posInList = $from.index($from.depth - 1);
|
|
232
|
-
var shouldSplit = !(!(0, _helpers.isActionOrDecisionList)(container) && posInList === 0);
|
|
233
|
-
if (shouldSplit) {
|
|
234
|
-
// this only splits a node to delete it, so we probably don't need a random uuid
|
|
235
|
-
// but generate one anyway for correctness
|
|
236
|
-
tr = tr.split($from.pos, 1, [{
|
|
237
|
-
type: $from.parent.type,
|
|
238
|
-
attrs: {
|
|
239
|
-
localId: _adfSchema.uuid.generate()
|
|
240
|
-
}
|
|
241
|
-
}]);
|
|
242
|
-
}
|
|
243
|
-
// and delete the action at the current pos
|
|
244
|
-
// we can do this because we know either first new child will be taskItem or nothing at all
|
|
245
|
-
var frag = _model.Fragment.from(content);
|
|
246
|
-
tr = tr.replace(tr.mapping.map($from.start() - 2), tr.mapping.map($from.end() + 2), frag.size ? new _model.Slice(frag, 0, 0) : _model.Slice.empty);
|
|
247
|
-
|
|
248
|
-
// put cursor inside paragraph
|
|
249
|
-
if (setSelection) {
|
|
250
|
-
tr = tr.setSelection(new _state.TextSelection(tr.doc.resolve($from.pos + 1 - (shouldSplit ? 0 : 2))));
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// lift list up if the node after the initial one was a taskList
|
|
254
|
-
// which means it would have empty placeholder content if we just immediately delete it
|
|
255
|
-
//
|
|
256
|
-
// if it's a taskItem then it can stand alone, so it's fine
|
|
257
|
-
var $oldAfter = origDoc.resolve($from.after());
|
|
258
|
-
|
|
259
|
-
// if different levels then we shouldn't lift
|
|
260
|
-
if ($oldAfter.depth === $from.depth - 1) {
|
|
261
|
-
if ($oldAfter.nodeAfter && (0, _helpers.isActionOrDecisionList)($oldAfter.nodeAfter)) {
|
|
262
|
-
// getBlockRange expects to be inside the taskItem
|
|
263
|
-
var pos = tr.mapping.map($oldAfter.pos + 2);
|
|
264
|
-
var $after = tr.doc.resolve(pos);
|
|
265
|
-
var blockRange = (0, _helpers.getBlockRange)($after, tr.doc.resolve($after.after($after.depth - 1) - 1));
|
|
266
|
-
if (blockRange) {
|
|
267
|
-
tr = tr.lift(blockRange, blockRange.depth - 1).scrollIntoView();
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// we delete 1 past the range of the empty taskItem
|
|
271
|
-
// otherwise we hit a bug in prosemirror-transform:
|
|
272
|
-
// Cannot read property 'content' of undefined
|
|
273
|
-
tr = tr.deleteRange(pos - 3, pos - 1);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
return tr;
|
|
277
|
-
};
|
|
278
|
-
var splitListItem = function splitListItem(state, dispatch) {
|
|
279
|
-
var tr = state.tr,
|
|
280
|
-
$from = state.selection.$from;
|
|
281
|
-
var paragraph = state.schema.nodes.paragraph;
|
|
282
|
-
if (actionDecisionFollowsOrNothing($from)) {
|
|
283
|
-
if (dispatch) {
|
|
284
|
-
dispatch(splitListItemWith(tr, paragraph.createChecked(), $from, true));
|
|
285
|
-
}
|
|
286
|
-
return true;
|
|
287
|
-
}
|
|
288
|
-
return false;
|
|
289
|
-
};
|
|
290
|
-
var enter = function enter(editorAnalyticsAPI) {
|
|
291
|
-
return (0, _utils2.filterCommand)(_helpers.isInsideTaskOrDecisionItem, (0, _commands.chainCommands)((0, _utils2.filterCommand)(_helpers.isEmptyTaskDecision, (0, _commands.chainCommands)(getUnindentCommand(editorAnalyticsAPI)(), splitListItem)), function (state, dispatch) {
|
|
292
|
-
var selection = state.selection,
|
|
293
|
-
schema = state.schema;
|
|
294
|
-
var taskItem = schema.nodes.taskItem;
|
|
295
|
-
var $from = selection.$from,
|
|
296
|
-
$to = selection.$to;
|
|
297
|
-
var node = $from.node($from.depth);
|
|
298
|
-
var nodeType = node && node.type;
|
|
299
|
-
var listType = nodeType === taskItem ? 'taskList' : 'decisionList';
|
|
300
|
-
var addItem = function addItem(_ref) {
|
|
301
|
-
var tr = _ref.tr,
|
|
302
|
-
itemLocalId = _ref.itemLocalId;
|
|
303
|
-
// ED-8932: When cursor is at the beginning of a task item, instead of split, we insert above.
|
|
304
|
-
if ($from.pos === $to.pos && $from.parentOffset === 0) {
|
|
305
|
-
var newTask = nodeType.createAndFill({
|
|
306
|
-
localId: itemLocalId
|
|
307
|
-
});
|
|
308
|
-
if (newTask) {
|
|
309
|
-
// Current position will point to text node, but we want to insert above the taskItem node
|
|
310
|
-
return tr.insert($from.pos - 1, newTask);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
return tr.split($from.pos, 1, [{
|
|
314
|
-
type: nodeType,
|
|
315
|
-
attrs: {
|
|
316
|
-
localId: itemLocalId
|
|
317
|
-
}
|
|
318
|
-
}]);
|
|
319
|
-
};
|
|
320
|
-
var insertTr = (0, _commands2.insertTaskDecisionWithAnalytics)(editorAnalyticsAPI)(state, listType, _analytics.INPUT_METHOD.KEYBOARD, addItem);
|
|
321
|
-
if (insertTr && dispatch) {
|
|
322
|
-
insertTr.scrollIntoView();
|
|
323
|
-
dispatch(insertTr);
|
|
324
|
-
}
|
|
325
|
-
return true;
|
|
326
|
-
}));
|
|
327
|
-
};
|
|
328
|
-
var cmdOptEnter = (0, _utils2.filterCommand)(_helpers.isInsideTaskOrDecisionItem, function (state, dispatch) {
|
|
329
|
-
var selection = state.selection,
|
|
330
|
-
schema = state.schema;
|
|
331
|
-
var taskItem = schema.nodes.taskItem;
|
|
332
|
-
var $from = selection.$from;
|
|
333
|
-
var node = $from.node($from.depth);
|
|
334
|
-
var nodeType = node && node.type;
|
|
335
|
-
var nodePos = $from.before($from.depth);
|
|
336
|
-
if (nodeType === taskItem) {
|
|
337
|
-
var tr = state.tr;
|
|
338
|
-
tr.step(new _steps.SetAttrsStep(nodePos, {
|
|
339
|
-
state: node.attrs.state === 'TODO' ? 'DONE' : 'TODO',
|
|
340
|
-
localId: node.attrs.localId
|
|
341
|
-
}));
|
|
342
|
-
if (tr && dispatch) {
|
|
343
|
-
dispatch(tr);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
return true;
|
|
347
|
-
});
|
|
348
|
-
function keymapPlugin(schema, api, allowNestedTasks, consumeTabs) {
|
|
349
|
-
var _api$analytics3, _api$analytics4;
|
|
350
|
-
var indentHandlers = {
|
|
351
|
-
'Shift-Tab': (0, _utils2.filterCommand)([_helpers.isInsideTaskOrDecisionItem, function (state) {
|
|
352
|
-
return !shouldLetTabThroughInTable(state);
|
|
353
|
-
}], function (state, dispatch) {
|
|
354
|
-
var _api$analytics;
|
|
355
|
-
return getUnindentCommand(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(_analytics.INPUT_METHOD.KEYBOARD)(state, dispatch) || !!consumeTabs;
|
|
356
|
-
}),
|
|
357
|
-
Tab: (0, _utils2.filterCommand)([_helpers.isInsideTaskOrDecisionItem, function (state) {
|
|
358
|
-
return !shouldLetTabThroughInTable(state);
|
|
359
|
-
}], function (state, dispatch) {
|
|
360
|
-
var _api$analytics2;
|
|
361
|
-
return getIndentCommand(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(_analytics.INPUT_METHOD.KEYBOARD)(state, dispatch) || !!consumeTabs;
|
|
362
|
-
})
|
|
363
|
-
};
|
|
364
|
-
var defaultHandlers = consumeTabs ? {
|
|
365
|
-
'Shift-Tab': _helpers.isInsideTaskOrDecisionItem,
|
|
366
|
-
Tab: _helpers.isInsideTaskOrDecisionItem
|
|
367
|
-
} : {};
|
|
368
|
-
var keymaps = _objectSpread((0, _defineProperty2.default)({
|
|
369
|
-
Backspace: backspace(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
|
|
370
|
-
Delete: deleteForwards,
|
|
371
|
-
'Ctrl-d': deleteForwards,
|
|
372
|
-
Enter: enter(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)
|
|
373
|
-
}, _keymaps.toggleTaskItemCheckbox.common, cmdOptEnter), allowNestedTasks ? indentHandlers : defaultHandlers);
|
|
374
|
-
return (0, _keymap.keymap)(keymaps);
|
|
375
|
-
}
|
|
376
|
-
var _default = exports.default = keymapPlugin;
|