@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,368 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
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; }
|
|
3
|
-
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) { _defineProperty(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; }
|
|
4
|
-
import { autoJoin, chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
5
|
-
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
6
|
-
import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
7
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
-
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
9
|
-
import { findParentNodeOfType, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
10
|
-
import { uuid } from '@atlaskit/adf-schema';
|
|
11
|
-
import { filterCommand as filter, isEmptySelectionAtStart, isEmptySelectionAtEnd, deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
|
|
12
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INDENT_DIRECTION, INDENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
13
|
-
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
14
|
-
import { insertTaskDecisionWithAnalytics } from '../commands';
|
|
15
|
-
import { joinAtCut, liftSelection, wrapSelectionInTaskList } from './commands';
|
|
16
|
-
import { getBlockRange, getCurrentIndentLevel, isActionOrDecisionItem, isActionOrDecisionList, isEmptyTaskDecision, isInsideTask, isInsideTaskOrDecisionItem, liftBlock, walkOut, getTaskItemIndex, isInsideDecision, isTable } from './helpers';
|
|
17
|
-
import { normalizeTaskItemsSelection } from '../utils';
|
|
18
|
-
import { toggleTaskItemCheckbox } from '../../../keymaps';
|
|
19
|
-
var indentationAnalytics = function indentationAnalytics(curIndentLevel, direction, inputMethod) {
|
|
20
|
-
return {
|
|
21
|
-
action: ACTION.FORMATTED,
|
|
22
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
23
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_INDENT,
|
|
24
|
-
eventType: EVENT_TYPE.TRACK,
|
|
25
|
-
attributes: {
|
|
26
|
-
inputMethod: inputMethod,
|
|
27
|
-
previousIndentationLevel: curIndentLevel,
|
|
28
|
-
newIndentLevel: direction === INDENT_DIRECTION.OUTDENT ? curIndentLevel - 1 : curIndentLevel + 1,
|
|
29
|
-
direction: direction,
|
|
30
|
-
indentType: INDENT_TYPE.TASK_LIST
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
var nodeAfter = function nodeAfter($pos) {
|
|
35
|
-
return $pos.doc.resolve($pos.end()).nodeAfter;
|
|
36
|
-
};
|
|
37
|
-
var actionDecisionFollowsOrNothing = function actionDecisionFollowsOrNothing($pos) {
|
|
38
|
-
var after = nodeAfter($pos);
|
|
39
|
-
return !after || isActionOrDecisionItem(after);
|
|
40
|
-
};
|
|
41
|
-
var joinTaskDecisionFollowing = function joinTaskDecisionFollowing(state, dispatch) {
|
|
42
|
-
// only run if selection is at end of text, and inside a task or decision item
|
|
43
|
-
if (!isEmptySelectionAtEnd(state) || !isInsideTaskOrDecisionItem(state) || !dispatch) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
// look for the node after this current one
|
|
47
|
-
var $next = walkOut(state.selection.$from);
|
|
48
|
-
|
|
49
|
-
// if there's no taskItem or taskList following, then
|
|
50
|
-
// we just do the normal behaviour
|
|
51
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
52
|
-
taskList = _state$schema$nodes.taskList,
|
|
53
|
-
taskItem = _state$schema$nodes.taskItem,
|
|
54
|
-
decisionList = _state$schema$nodes.decisionList,
|
|
55
|
-
decisionItem = _state$schema$nodes.decisionItem,
|
|
56
|
-
paragraph = _state$schema$nodes.paragraph,
|
|
57
|
-
bulletList = _state$schema$nodes.bulletList,
|
|
58
|
-
orderedList = _state$schema$nodes.orderedList,
|
|
59
|
-
listItem = _state$schema$nodes.listItem;
|
|
60
|
-
var parentList = findParentNodeOfTypeClosestToPos($next, [taskList, taskItem, decisionList, decisionItem]);
|
|
61
|
-
if (!parentList) {
|
|
62
|
-
if ($next.parent.type === paragraph) {
|
|
63
|
-
// try to join paragraph and taskList when backspacing
|
|
64
|
-
return joinAtCut($next.doc.resolve($next.pos))(state, dispatch);
|
|
65
|
-
}
|
|
66
|
-
// If the item we are joining is a list
|
|
67
|
-
if ($next.parent.type === bulletList || $next.parent.type === orderedList) {
|
|
68
|
-
// If the list has an item
|
|
69
|
-
if ($next.parent.firstChild && $next.parent.firstChild.type === listItem) {
|
|
70
|
-
// Place the cursor at the first listItem
|
|
71
|
-
var resolvedStartPos = state.doc.resolve($next.pos + 1);
|
|
72
|
-
// Unindent the first listItem.
|
|
73
|
-
// As if placing your cursor just after the first dot of the list (before the text)
|
|
74
|
-
// and pressing Shift-Tab.
|
|
75
|
-
var tr = liftBlock(state.tr, resolvedStartPos, resolvedStartPos);
|
|
76
|
-
|
|
77
|
-
// If autoJoin not used, two ul/ol elements appear rather than one with multiple li elements
|
|
78
|
-
return autoJoin(function (state, dispatch) {
|
|
79
|
-
if (tr) {
|
|
80
|
-
if (dispatch) {
|
|
81
|
-
dispatch(tr);
|
|
82
|
-
}
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
|
-
return false;
|
|
86
|
-
}, ['bulletList', 'orderedList'])(state, dispatch);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return false;
|
|
91
|
-
};
|
|
92
|
-
export var getUnindentCommand = function getUnindentCommand(editorAnalyticsAPI) {
|
|
93
|
-
return function () {
|
|
94
|
-
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INPUT_METHOD.KEYBOARD;
|
|
95
|
-
return filter(isInsideTask, function (state, dispatch) {
|
|
96
|
-
var normalizedSelection = normalizeTaskItemsSelection(state.selection);
|
|
97
|
-
var curIndentLevel = getCurrentIndentLevel(normalizedSelection);
|
|
98
|
-
if (!curIndentLevel || curIndentLevel === 1) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
return withAnalytics(editorAnalyticsAPI, indentationAnalytics(curIndentLevel, INDENT_DIRECTION.OUTDENT, inputMethod))(autoJoin(liftSelection, ['taskList']))(state, dispatch);
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
// if selection is decision item or first action item in table cell
|
|
107
|
-
// then dont consume the Tab, as table-keymap should tab to the next cell
|
|
108
|
-
var shouldLetTabThroughInTable = function shouldLetTabThroughInTable(state) {
|
|
109
|
-
var curIndentLevel = getCurrentIndentLevel(state.selection);
|
|
110
|
-
var curIndex = getTaskItemIndex(state);
|
|
111
|
-
var _state$schema$nodes2 = state.schema.nodes,
|
|
112
|
-
tableCell = _state$schema$nodes2.tableCell,
|
|
113
|
-
tableHeader = _state$schema$nodes2.tableHeader;
|
|
114
|
-
var cell = findParentNodeOfType([tableCell, tableHeader])(state.selection);
|
|
115
|
-
if ((curIndentLevel === 1 && curIndex === 0 || isInsideDecision(state)) && cell) {
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
return false;
|
|
119
|
-
};
|
|
120
|
-
export var getIndentCommand = function getIndentCommand(editorAnalyticsAPI) {
|
|
121
|
-
return function () {
|
|
122
|
-
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INPUT_METHOD.KEYBOARD;
|
|
123
|
-
return filter(isInsideTask, function (state, dispatch) {
|
|
124
|
-
var normalizedSelection = normalizeTaskItemsSelection(state.selection);
|
|
125
|
-
var curIndentLevel = getCurrentIndentLevel(normalizedSelection);
|
|
126
|
-
if (!curIndentLevel || curIndentLevel >= 6) {
|
|
127
|
-
return true;
|
|
128
|
-
}
|
|
129
|
-
return withAnalytics(editorAnalyticsAPI, indentationAnalytics(curIndentLevel, INDENT_DIRECTION.INDENT, inputMethod))(autoJoin(wrapSelectionInTaskList, ['taskList']))(state, dispatch);
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
};
|
|
133
|
-
var backspaceFrom = function backspaceFrom(editorAnalyticsAPI) {
|
|
134
|
-
return function ($from) {
|
|
135
|
-
return function (state, dispatch) {
|
|
136
|
-
// previous was empty, just delete backwards
|
|
137
|
-
var taskBefore = $from.doc.resolve($from.before());
|
|
138
|
-
if (taskBefore.nodeBefore && isActionOrDecisionItem(taskBefore.nodeBefore) && taskBefore.nodeBefore.nodeSize === 2) {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// if nested, just unindent
|
|
143
|
-
var _state$schema$nodes3 = state.schema.nodes,
|
|
144
|
-
taskList = _state$schema$nodes3.taskList,
|
|
145
|
-
paragraph = _state$schema$nodes3.paragraph;
|
|
146
|
-
if ($from.node($from.depth - 2).type === taskList) {
|
|
147
|
-
return getUnindentCommand(editorAnalyticsAPI)()(state, dispatch);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// bottom level, should "unwrap" taskItem contents into paragraph
|
|
151
|
-
// we achieve this by slicing the content out, and replacing
|
|
152
|
-
if (actionDecisionFollowsOrNothing($from)) {
|
|
153
|
-
if (dispatch) {
|
|
154
|
-
var taskContent = state.doc.slice($from.start(), $from.end()).content;
|
|
155
|
-
|
|
156
|
-
// might be end of document after
|
|
157
|
-
var slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : paragraph.createChecked();
|
|
158
|
-
dispatch(splitListItemWith(state.tr, slice, $from, true));
|
|
159
|
-
}
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
return false;
|
|
163
|
-
};
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
var backspace = function backspace(editorAnalyticsAPI) {
|
|
167
|
-
return filter(isEmptySelectionAtStart, autoJoin(chainCommands(function (state, dispatch) {
|
|
168
|
-
return joinAtCut(state.selection.$from)(state, dispatch);
|
|
169
|
-
}, filter(isInsideTaskOrDecisionItem, function (state, dispatch) {
|
|
170
|
-
return backspaceFrom(editorAnalyticsAPI)(state.selection.$from)(state, dispatch);
|
|
171
|
-
})), ['taskList', 'decisionList']));
|
|
172
|
-
};
|
|
173
|
-
var unindentTaskOrUnwrapTaskDecisionFollowing = function unindentTaskOrUnwrapTaskDecisionFollowing(state, dispatch) {
|
|
174
|
-
var $from = state.selection.$from,
|
|
175
|
-
_state$schema$nodes4 = state.schema.nodes,
|
|
176
|
-
taskList = _state$schema$nodes4.taskList,
|
|
177
|
-
doc = _state$schema$nodes4.doc,
|
|
178
|
-
paragraph = _state$schema$nodes4.paragraph,
|
|
179
|
-
tr = state.tr;
|
|
180
|
-
|
|
181
|
-
// only run if cursor is at the end of the node
|
|
182
|
-
if (!isEmptySelectionAtEnd(state) || !dispatch) {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// look for the node after this current one
|
|
187
|
-
var $next = walkOut($from);
|
|
188
|
-
|
|
189
|
-
// this is a top-level node it wont have $next.before()
|
|
190
|
-
if (!$next.parent || $next.parent.type === doc) {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// if nested, just unindent
|
|
195
|
-
if ($next.node($next.depth - 2).type === taskList ||
|
|
196
|
-
// this is for the case when we are on a non-nested item and next one is nested
|
|
197
|
-
$next.node($next.depth - 1).type === taskList && $next.parent.type === taskList) {
|
|
198
|
-
liftBlock(tr, $next, $next);
|
|
199
|
-
dispatch(tr);
|
|
200
|
-
return true;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// if next node is of same type, remove the node wrapping and create paragraph
|
|
204
|
-
if (!isTable($next.nodeAfter) && isActionOrDecisionItem($from.parent) && actionDecisionFollowsOrNothing($from) &&
|
|
205
|
-
// only forward delete if the node is same type
|
|
206
|
-
$next.node().type.name === $from.node().type.name) {
|
|
207
|
-
var taskContent = state.doc.slice($next.start(), $next.end()).content;
|
|
208
|
-
|
|
209
|
-
// might be end of document after
|
|
210
|
-
var slice = taskContent.size ? paragraph.createChecked(undefined, taskContent) : [];
|
|
211
|
-
dispatch(splitListItemWith(tr, slice, $next, false));
|
|
212
|
-
return true;
|
|
213
|
-
}
|
|
214
|
-
return false;
|
|
215
|
-
};
|
|
216
|
-
var deleteForwards = autoJoin(chainCommands(deleteEmptyParagraphAndMoveBlockUp(isActionOrDecisionList), joinTaskDecisionFollowing, unindentTaskOrUnwrapTaskDecisionFollowing), ['taskList', 'decisionList']);
|
|
217
|
-
var splitListItemWith = function splitListItemWith(tr, content, $from, setSelection) {
|
|
218
|
-
var origDoc = tr.doc;
|
|
219
|
-
|
|
220
|
-
// split just before the current item
|
|
221
|
-
// we can only split if there was a list item before us
|
|
222
|
-
var container = $from.node($from.depth - 2);
|
|
223
|
-
var posInList = $from.index($from.depth - 1);
|
|
224
|
-
var shouldSplit = !(!isActionOrDecisionList(container) && posInList === 0);
|
|
225
|
-
if (shouldSplit) {
|
|
226
|
-
// this only splits a node to delete it, so we probably don't need a random uuid
|
|
227
|
-
// but generate one anyway for correctness
|
|
228
|
-
tr = tr.split($from.pos, 1, [{
|
|
229
|
-
type: $from.parent.type,
|
|
230
|
-
attrs: {
|
|
231
|
-
localId: uuid.generate()
|
|
232
|
-
}
|
|
233
|
-
}]);
|
|
234
|
-
}
|
|
235
|
-
// and delete the action at the current pos
|
|
236
|
-
// we can do this because we know either first new child will be taskItem or nothing at all
|
|
237
|
-
var frag = Fragment.from(content);
|
|
238
|
-
tr = tr.replace(tr.mapping.map($from.start() - 2), tr.mapping.map($from.end() + 2), frag.size ? new Slice(frag, 0, 0) : Slice.empty);
|
|
239
|
-
|
|
240
|
-
// put cursor inside paragraph
|
|
241
|
-
if (setSelection) {
|
|
242
|
-
tr = tr.setSelection(new TextSelection(tr.doc.resolve($from.pos + 1 - (shouldSplit ? 0 : 2))));
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// lift list up if the node after the initial one was a taskList
|
|
246
|
-
// which means it would have empty placeholder content if we just immediately delete it
|
|
247
|
-
//
|
|
248
|
-
// if it's a taskItem then it can stand alone, so it's fine
|
|
249
|
-
var $oldAfter = origDoc.resolve($from.after());
|
|
250
|
-
|
|
251
|
-
// if different levels then we shouldn't lift
|
|
252
|
-
if ($oldAfter.depth === $from.depth - 1) {
|
|
253
|
-
if ($oldAfter.nodeAfter && isActionOrDecisionList($oldAfter.nodeAfter)) {
|
|
254
|
-
// getBlockRange expects to be inside the taskItem
|
|
255
|
-
var pos = tr.mapping.map($oldAfter.pos + 2);
|
|
256
|
-
var $after = tr.doc.resolve(pos);
|
|
257
|
-
var blockRange = getBlockRange($after, tr.doc.resolve($after.after($after.depth - 1) - 1));
|
|
258
|
-
if (blockRange) {
|
|
259
|
-
tr = tr.lift(blockRange, blockRange.depth - 1).scrollIntoView();
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// we delete 1 past the range of the empty taskItem
|
|
263
|
-
// otherwise we hit a bug in prosemirror-transform:
|
|
264
|
-
// Cannot read property 'content' of undefined
|
|
265
|
-
tr = tr.deleteRange(pos - 3, pos - 1);
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
return tr;
|
|
269
|
-
};
|
|
270
|
-
var splitListItem = function splitListItem(state, dispatch) {
|
|
271
|
-
var tr = state.tr,
|
|
272
|
-
$from = state.selection.$from;
|
|
273
|
-
var paragraph = state.schema.nodes.paragraph;
|
|
274
|
-
if (actionDecisionFollowsOrNothing($from)) {
|
|
275
|
-
if (dispatch) {
|
|
276
|
-
dispatch(splitListItemWith(tr, paragraph.createChecked(), $from, true));
|
|
277
|
-
}
|
|
278
|
-
return true;
|
|
279
|
-
}
|
|
280
|
-
return false;
|
|
281
|
-
};
|
|
282
|
-
var enter = function enter(editorAnalyticsAPI) {
|
|
283
|
-
return filter(isInsideTaskOrDecisionItem, chainCommands(filter(isEmptyTaskDecision, chainCommands(getUnindentCommand(editorAnalyticsAPI)(), splitListItem)), function (state, dispatch) {
|
|
284
|
-
var selection = state.selection,
|
|
285
|
-
schema = state.schema;
|
|
286
|
-
var taskItem = schema.nodes.taskItem;
|
|
287
|
-
var $from = selection.$from,
|
|
288
|
-
$to = selection.$to;
|
|
289
|
-
var node = $from.node($from.depth);
|
|
290
|
-
var nodeType = node && node.type;
|
|
291
|
-
var listType = nodeType === taskItem ? 'taskList' : 'decisionList';
|
|
292
|
-
var addItem = function addItem(_ref) {
|
|
293
|
-
var tr = _ref.tr,
|
|
294
|
-
itemLocalId = _ref.itemLocalId;
|
|
295
|
-
// ED-8932: When cursor is at the beginning of a task item, instead of split, we insert above.
|
|
296
|
-
if ($from.pos === $to.pos && $from.parentOffset === 0) {
|
|
297
|
-
var newTask = nodeType.createAndFill({
|
|
298
|
-
localId: itemLocalId
|
|
299
|
-
});
|
|
300
|
-
if (newTask) {
|
|
301
|
-
// Current position will point to text node, but we want to insert above the taskItem node
|
|
302
|
-
return tr.insert($from.pos - 1, newTask);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
return tr.split($from.pos, 1, [{
|
|
306
|
-
type: nodeType,
|
|
307
|
-
attrs: {
|
|
308
|
-
localId: itemLocalId
|
|
309
|
-
}
|
|
310
|
-
}]);
|
|
311
|
-
};
|
|
312
|
-
var insertTr = insertTaskDecisionWithAnalytics(editorAnalyticsAPI)(state, listType, INPUT_METHOD.KEYBOARD, addItem);
|
|
313
|
-
if (insertTr && dispatch) {
|
|
314
|
-
insertTr.scrollIntoView();
|
|
315
|
-
dispatch(insertTr);
|
|
316
|
-
}
|
|
317
|
-
return true;
|
|
318
|
-
}));
|
|
319
|
-
};
|
|
320
|
-
var cmdOptEnter = filter(isInsideTaskOrDecisionItem, function (state, dispatch) {
|
|
321
|
-
var selection = state.selection,
|
|
322
|
-
schema = state.schema;
|
|
323
|
-
var taskItem = schema.nodes.taskItem;
|
|
324
|
-
var $from = selection.$from;
|
|
325
|
-
var node = $from.node($from.depth);
|
|
326
|
-
var nodeType = node && node.type;
|
|
327
|
-
var nodePos = $from.before($from.depth);
|
|
328
|
-
if (nodeType === taskItem) {
|
|
329
|
-
var tr = state.tr;
|
|
330
|
-
tr.step(new SetAttrsStep(nodePos, {
|
|
331
|
-
state: node.attrs.state === 'TODO' ? 'DONE' : 'TODO',
|
|
332
|
-
localId: node.attrs.localId
|
|
333
|
-
}));
|
|
334
|
-
if (tr && dispatch) {
|
|
335
|
-
dispatch(tr);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
return true;
|
|
339
|
-
});
|
|
340
|
-
export function keymapPlugin(schema, api, allowNestedTasks, consumeTabs) {
|
|
341
|
-
var _api$analytics3, _api$analytics4;
|
|
342
|
-
var indentHandlers = {
|
|
343
|
-
'Shift-Tab': filter([isInsideTaskOrDecisionItem, function (state) {
|
|
344
|
-
return !shouldLetTabThroughInTable(state);
|
|
345
|
-
}], function (state, dispatch) {
|
|
346
|
-
var _api$analytics;
|
|
347
|
-
return getUnindentCommand(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(INPUT_METHOD.KEYBOARD)(state, dispatch) || !!consumeTabs;
|
|
348
|
-
}),
|
|
349
|
-
Tab: filter([isInsideTaskOrDecisionItem, function (state) {
|
|
350
|
-
return !shouldLetTabThroughInTable(state);
|
|
351
|
-
}], function (state, dispatch) {
|
|
352
|
-
var _api$analytics2;
|
|
353
|
-
return getIndentCommand(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(INPUT_METHOD.KEYBOARD)(state, dispatch) || !!consumeTabs;
|
|
354
|
-
})
|
|
355
|
-
};
|
|
356
|
-
var defaultHandlers = consumeTabs ? {
|
|
357
|
-
'Shift-Tab': isInsideTaskOrDecisionItem,
|
|
358
|
-
Tab: isInsideTaskOrDecisionItem
|
|
359
|
-
} : {};
|
|
360
|
-
var keymaps = _objectSpread(_defineProperty({
|
|
361
|
-
Backspace: backspace(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions),
|
|
362
|
-
Delete: deleteForwards,
|
|
363
|
-
'Ctrl-d': deleteForwards,
|
|
364
|
-
Enter: enter(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)
|
|
365
|
-
}, toggleTaskItemCheckbox.common, cmdOptEnter), allowNestedTasks ? indentHandlers : defaultHandlers);
|
|
366
|
-
return keymap(keymaps);
|
|
367
|
-
}
|
|
368
|
-
export default keymapPlugin;
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
-
var _excluded = ["localId"];
|
|
4
|
-
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; }
|
|
5
|
-
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) { _defineProperty(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; }
|
|
6
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
|
-
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
-
import { uuid } from '@atlaskit/adf-schema';
|
|
9
|
-
import { getStepRange } from '@atlaskit/editor-common/utils';
|
|
10
|
-
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
11
|
-
import { createSelectionClickHandler, GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
12
|
-
import { decisionItemNodeView } from '../nodeviews/decisionItem';
|
|
13
|
-
import { taskItemNodeViewFactory } from '../nodeviews/taskItem';
|
|
14
|
-
import { stateKey } from './plugin-key';
|
|
15
|
-
import { getTaskItemDataToFocus, getTaskItemDataAtPos, focusCheckboxAndUpdateSelection, removeCheckboxFocus } from './helpers';
|
|
16
|
-
import { ACTIONS } from './types';
|
|
17
|
-
function nodesBetweenChanged(tr, f, startPos) {
|
|
18
|
-
var stepRange = getStepRange(tr);
|
|
19
|
-
if (!stepRange) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
tr.doc.nodesBetween(stepRange.from, stepRange.to, f, startPos);
|
|
23
|
-
}
|
|
24
|
-
var setContextIdentifierProvider = function setContextIdentifierProvider(provider) {
|
|
25
|
-
return function (state, dispatch) {
|
|
26
|
-
if (dispatch) {
|
|
27
|
-
dispatch(state.tr.setMeta(stateKey, {
|
|
28
|
-
action: ACTIONS.SET_CONTEXT_PROVIDER,
|
|
29
|
-
data: provider
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
return true;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api) {
|
|
36
|
-
var useLongPressSelection = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
|
|
37
|
-
return new SafePlugin({
|
|
38
|
-
props: {
|
|
39
|
-
nodeViews: {
|
|
40
|
-
taskItem: taskItemNodeViewFactory(portalProviderAPI, eventDispatcher, providerFactory, api),
|
|
41
|
-
decisionItem: decisionItemNodeView(portalProviderAPI, eventDispatcher, api)
|
|
42
|
-
},
|
|
43
|
-
handleTextInput: function handleTextInput(view, from, to, text) {
|
|
44
|
-
// When a decision item is selected and the user starts typing, the entire node
|
|
45
|
-
// should be replaced with what was just typed. This custom text input handler
|
|
46
|
-
// is needed to implement that behaviour.
|
|
47
|
-
|
|
48
|
-
// TODO: ProseMirror should already do this by default
|
|
49
|
-
// Tech debt to investigate why we need a custom handler here:
|
|
50
|
-
// https://product-fabric.atlassian.net/browse/ED-9278
|
|
51
|
-
|
|
52
|
-
var state = view.state,
|
|
53
|
-
dispatch = view.dispatch;
|
|
54
|
-
var tr = state.tr;
|
|
55
|
-
if (state.selection instanceof NodeSelection && state.selection.node.type === view.state.schema.nodes.decisionItem) {
|
|
56
|
-
state.selection.replace(tr);
|
|
57
|
-
tr.insertText(text);
|
|
58
|
-
if (dispatch) {
|
|
59
|
-
dispatch(tr);
|
|
60
|
-
}
|
|
61
|
-
return true;
|
|
62
|
-
}
|
|
63
|
-
return false;
|
|
64
|
-
},
|
|
65
|
-
handleClickOn: createSelectionClickHandler(['decisionItem'], function (target) {
|
|
66
|
-
return target.hasAttribute('data-decision-wrapper') || target.getAttribute('aria-label') === 'Decision';
|
|
67
|
-
}, {
|
|
68
|
-
useLongPressSelection: useLongPressSelection
|
|
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 = stateKey.getState(state).focusedTaskItemLocalId;
|
|
80
|
-
var currentTaskItemData = 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 && 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
|
-
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
|
-
removeCheckboxFocus(view);
|
|
115
|
-
return true;
|
|
116
|
-
}
|
|
117
|
-
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
118
|
-
var taskItemData = getTaskItemDataToFocus(view, event.key === 'ArrowUp' ? 'previous' : 'next');
|
|
119
|
-
if (taskItemData) {
|
|
120
|
-
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
|
-
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(stateKey, {
|
|
137
|
-
action: 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 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
|
-
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 = getTaskItemDataToFocus(view, 'next');
|
|
158
|
-
if (nextTaskItemData) {
|
|
159
|
-
focusCheckboxAndUpdateSelection(view, nextTaskItemData);
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
} else {
|
|
163
|
-
return false;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
state: {
|
|
169
|
-
init: function init() {
|
|
170
|
-
return {
|
|
171
|
-
insideTaskDecisionItem: false
|
|
172
|
-
};
|
|
173
|
-
},
|
|
174
|
-
apply: function apply(tr, pluginState) {
|
|
175
|
-
var _ref = tr.getMeta(stateKey) || {
|
|
176
|
-
action: null,
|
|
177
|
-
data: null
|
|
178
|
-
},
|
|
179
|
-
action = _ref.action,
|
|
180
|
-
data = _ref.data;
|
|
181
|
-
var newPluginState = pluginState;
|
|
182
|
-
switch (action) {
|
|
183
|
-
case ACTIONS.SET_CONTEXT_PROVIDER:
|
|
184
|
-
newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
185
|
-
contextIdentifierProvider: data
|
|
186
|
-
});
|
|
187
|
-
break;
|
|
188
|
-
case ACTIONS.FOCUS_BY_LOCALID:
|
|
189
|
-
newPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
190
|
-
focusedTaskItemLocalId: data
|
|
191
|
-
});
|
|
192
|
-
break;
|
|
193
|
-
}
|
|
194
|
-
dispatch(stateKey, newPluginState);
|
|
195
|
-
return newPluginState;
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
view: function view(editorView) {
|
|
199
|
-
var providerHandler = function providerHandler(name, providerPromise) {
|
|
200
|
-
if (name === 'contextIdentifierProvider') {
|
|
201
|
-
if (!providerPromise) {
|
|
202
|
-
setContextIdentifierProvider(undefined)(editorView.state, editorView.dispatch);
|
|
203
|
-
} else {
|
|
204
|
-
providerPromise.then(function (provider) {
|
|
205
|
-
setContextIdentifierProvider(provider)(editorView.state, editorView.dispatch);
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
providerFactory.subscribe('contextIdentifierProvider', providerHandler);
|
|
211
|
-
return {};
|
|
212
|
-
},
|
|
213
|
-
key: stateKey,
|
|
214
|
-
/*
|
|
215
|
-
* After each transaction, we search through the document for any decisionList/Item & taskList/Item nodes
|
|
216
|
-
* that do not have the localId attribute set and generate a random UUID to use. This is to replace a previous
|
|
217
|
-
* Prosemirror capabibility where node attributes could be generated dynamically.
|
|
218
|
-
* See https://discuss.prosemirror.net/t/release-0-23-0-possibly-to-be-1-0-0/959/17 for a discussion of this approach.
|
|
219
|
-
*
|
|
220
|
-
* Note: we currently do not handle the edge case where two nodes may have the same localId
|
|
221
|
-
*/
|
|
222
|
-
appendTransaction: function appendTransaction(transactions, _oldState, newState) {
|
|
223
|
-
var tr = newState.tr;
|
|
224
|
-
var modified = false;
|
|
225
|
-
transactions.forEach(function (transaction) {
|
|
226
|
-
if (!transaction.docChanged) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// Adds a unique id to a node
|
|
231
|
-
nodesBetweenChanged(transaction, function (node, pos) {
|
|
232
|
-
var _newState$schema$node = newState.schema.nodes,
|
|
233
|
-
decisionList = _newState$schema$node.decisionList,
|
|
234
|
-
decisionItem = _newState$schema$node.decisionItem,
|
|
235
|
-
taskList = _newState$schema$node.taskList,
|
|
236
|
-
taskItem = _newState$schema$node.taskItem;
|
|
237
|
-
if (!!node.type && (node.type === decisionList || node.type === decisionItem || node.type === taskList || node.type === taskItem)) {
|
|
238
|
-
var _node$attrs = node.attrs,
|
|
239
|
-
localId = _node$attrs.localId,
|
|
240
|
-
rest = _objectWithoutProperties(_node$attrs, _excluded);
|
|
241
|
-
if (localId === undefined || localId === null || localId === '') {
|
|
242
|
-
tr.step(new SetAttrsStep(pos, _objectSpread({
|
|
243
|
-
localId: uuid.generate()
|
|
244
|
-
}, rest)));
|
|
245
|
-
modified = true;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
if (modified) {
|
|
251
|
-
return tr.setMeta('addToHistory', false);
|
|
252
|
-
}
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
});
|
|
256
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|