@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,156 +0,0 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject;
|
|
3
|
-
/** @jsx jsx */
|
|
4
|
-
import { css, jsx } from '@emotion/react';
|
|
5
|
-
import { decisionItem, decisionList, taskItem, taskList } from '@atlaskit/adf-schema';
|
|
6
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
7
|
-
import { toolbarInsertBlockMessages as insertBlockMessages } from '@atlaskit/editor-common/messages';
|
|
8
|
-
import { IconAction, IconDecision } from '@atlaskit/editor-common/quick-insert';
|
|
9
|
-
import { stateKey as taskPluginKey } from './pm-plugins/plugin-key';
|
|
10
|
-
import { insertTaskDecisionAction, getListTypes, insertTaskDecisionCommand } from './commands';
|
|
11
|
-
import inputRulePlugin from './pm-plugins/input-rules';
|
|
12
|
-
import keymap, { getIndentCommand, getUnindentCommand } from './pm-plugins/keymaps';
|
|
13
|
-
import { createPlugin } from './pm-plugins/main';
|
|
14
|
-
import ToolbarDecision from './ui/ToolbarDecision';
|
|
15
|
-
import ToolbarTask from './ui/ToolbarTask';
|
|
16
|
-
import { getCurrentIndentLevel, getTaskItemIndex, isInsideTask } from './pm-plugins/helpers';
|
|
17
|
-
import { MAX_INDENTATION_LEVEL } from '@atlaskit/editor-common/indentation';
|
|
18
|
-
var taskDecisionToolbarGroup = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n"])));
|
|
19
|
-
var addItem = function addItem(insert, listType, schema) {
|
|
20
|
-
return function (_ref) {
|
|
21
|
-
var listLocalId = _ref.listLocalId,
|
|
22
|
-
itemLocalId = _ref.itemLocalId;
|
|
23
|
-
var _getListTypes = getListTypes(listType, schema),
|
|
24
|
-
list = _getListTypes.list,
|
|
25
|
-
item = _getListTypes.item;
|
|
26
|
-
return insert(list.createChecked({
|
|
27
|
-
localId: listLocalId
|
|
28
|
-
}, item.createChecked({
|
|
29
|
-
localId: itemLocalId
|
|
30
|
-
})));
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
|
|
34
|
-
var _api$analytics, _api$analytics2, _api$analytics3;
|
|
35
|
-
var _ref2$config = _ref2.config,
|
|
36
|
-
_ref2$config2 = _ref2$config === void 0 ? {} : _ref2$config,
|
|
37
|
-
allowNestedTasks = _ref2$config2.allowNestedTasks,
|
|
38
|
-
consumeTabs = _ref2$config2.consumeTabs,
|
|
39
|
-
useLongPressSelection = _ref2$config2.useLongPressSelection,
|
|
40
|
-
api = _ref2.api;
|
|
41
|
-
return {
|
|
42
|
-
name: 'taskDecision',
|
|
43
|
-
nodes: function nodes() {
|
|
44
|
-
return [{
|
|
45
|
-
name: 'decisionList',
|
|
46
|
-
node: decisionList
|
|
47
|
-
}, {
|
|
48
|
-
name: 'decisionItem',
|
|
49
|
-
node: decisionItem
|
|
50
|
-
}, {
|
|
51
|
-
name: 'taskList',
|
|
52
|
-
node: taskList
|
|
53
|
-
}, {
|
|
54
|
-
name: 'taskItem',
|
|
55
|
-
node: taskItem
|
|
56
|
-
}];
|
|
57
|
-
},
|
|
58
|
-
getSharedState: function getSharedState(editorState) {
|
|
59
|
-
if (!editorState) {
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
var pluginState = taskPluginKey.getState(editorState);
|
|
63
|
-
var indentLevel = getCurrentIndentLevel(editorState.selection) || 0;
|
|
64
|
-
var itemIndex = getTaskItemIndex(editorState);
|
|
65
|
-
return {
|
|
66
|
-
focusedTaskItemLocalId: (pluginState === null || pluginState === void 0 ? void 0 : pluginState.focusedTaskItemLocalId) || null,
|
|
67
|
-
isInsideTask: isInsideTask(editorState),
|
|
68
|
-
indentDisabled: itemIndex === 0 || indentLevel >= MAX_INDENTATION_LEVEL,
|
|
69
|
-
outdentDisabled: indentLevel <= 1
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
actions: {
|
|
73
|
-
insertTaskDecision: insertTaskDecisionCommand(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions),
|
|
74
|
-
indentTaskList: getIndentCommand(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
|
|
75
|
-
outdentTaskList: getUnindentCommand(api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)
|
|
76
|
-
},
|
|
77
|
-
pmPlugins: function pmPlugins() {
|
|
78
|
-
return [{
|
|
79
|
-
name: 'tasksAndDecisions',
|
|
80
|
-
plugin: function plugin(_ref3) {
|
|
81
|
-
var portalProviderAPI = _ref3.portalProviderAPI,
|
|
82
|
-
providerFactory = _ref3.providerFactory,
|
|
83
|
-
eventDispatcher = _ref3.eventDispatcher,
|
|
84
|
-
dispatch = _ref3.dispatch;
|
|
85
|
-
return createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection);
|
|
86
|
-
}
|
|
87
|
-
}, {
|
|
88
|
-
name: 'tasksAndDecisionsInputRule',
|
|
89
|
-
plugin: function plugin(_ref4) {
|
|
90
|
-
var _api$analytics4;
|
|
91
|
-
var schema = _ref4.schema,
|
|
92
|
-
featureFlags = _ref4.featureFlags;
|
|
93
|
-
return inputRulePlugin(api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)(schema, featureFlags);
|
|
94
|
-
}
|
|
95
|
-
}, {
|
|
96
|
-
name: 'tasksAndDecisionsKeyMap',
|
|
97
|
-
plugin: function plugin(_ref5) {
|
|
98
|
-
var schema = _ref5.schema;
|
|
99
|
-
return keymap(schema, api, allowNestedTasks, consumeTabs);
|
|
100
|
-
}
|
|
101
|
-
} // Needs to be after "save-on-enter"
|
|
102
|
-
];
|
|
103
|
-
},
|
|
104
|
-
secondaryToolbarComponent: function secondaryToolbarComponent(_ref6) {
|
|
105
|
-
var editorView = _ref6.editorView,
|
|
106
|
-
disabled = _ref6.disabled;
|
|
107
|
-
return jsx("div", {
|
|
108
|
-
css: taskDecisionToolbarGroup
|
|
109
|
-
}, jsx(ToolbarDecision, {
|
|
110
|
-
editorView: editorView,
|
|
111
|
-
isDisabled: disabled,
|
|
112
|
-
isReducedSpacing: true,
|
|
113
|
-
editorAPI: api
|
|
114
|
-
}), jsx(ToolbarTask, {
|
|
115
|
-
editorView: editorView,
|
|
116
|
-
isDisabled: disabled,
|
|
117
|
-
isReducedSpacing: true,
|
|
118
|
-
editorAPI: api
|
|
119
|
-
}));
|
|
120
|
-
},
|
|
121
|
-
pluginsOptions: {
|
|
122
|
-
quickInsert: function quickInsert(_ref7) {
|
|
123
|
-
var formatMessage = _ref7.formatMessage;
|
|
124
|
-
return [{
|
|
125
|
-
id: 'action',
|
|
126
|
-
title: formatMessage(insertBlockMessages.action),
|
|
127
|
-
description: formatMessage(insertBlockMessages.actionDescription),
|
|
128
|
-
priority: 100,
|
|
129
|
-
keywords: ['checkbox', 'task', 'todo'],
|
|
130
|
-
keyshortcut: '[]',
|
|
131
|
-
icon: function icon() {
|
|
132
|
-
return jsx(IconAction, null);
|
|
133
|
-
},
|
|
134
|
-
action: function action(insert, state) {
|
|
135
|
-
var _api$analytics5;
|
|
136
|
-
return insertTaskDecisionAction(api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions)(state, 'taskList', INPUT_METHOD.QUICK_INSERT, addItem(insert, 'taskList', state.schema));
|
|
137
|
-
}
|
|
138
|
-
}, {
|
|
139
|
-
id: 'decision',
|
|
140
|
-
title: formatMessage(insertBlockMessages.decision),
|
|
141
|
-
description: formatMessage(insertBlockMessages.decisionDescription),
|
|
142
|
-
priority: 900,
|
|
143
|
-
keyshortcut: '<>',
|
|
144
|
-
icon: function icon() {
|
|
145
|
-
return jsx(IconDecision, null);
|
|
146
|
-
},
|
|
147
|
-
action: function action(insert, state) {
|
|
148
|
-
var _api$analytics6;
|
|
149
|
-
return insertTaskDecisionAction(api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions)(state, 'decisionList', INPUT_METHOD.QUICK_INSERT, addItem(insert, 'decisionList', state.schema));
|
|
150
|
-
}
|
|
151
|
-
}];
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
export default tasksAndDecisionsPlugin;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _get from "@babel/runtime/helpers/get";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
8
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
9
|
-
import React from 'react';
|
|
10
|
-
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
11
|
-
import { useShowPlaceholder } from './hooks/use-show-placeholder';
|
|
12
|
-
import DecisionItem from '../ui/Decision';
|
|
13
|
-
var DecisionItemWrapper = function DecisionItemWrapper(_ref) {
|
|
14
|
-
var api = _ref.api,
|
|
15
|
-
editorView = _ref.editorView,
|
|
16
|
-
forwardRef = _ref.forwardRef,
|
|
17
|
-
isContentNodeEmpty = _ref.isContentNodeEmpty,
|
|
18
|
-
getPos = _ref.getPos;
|
|
19
|
-
var showPlaceholder = useShowPlaceholder({
|
|
20
|
-
editorView: editorView,
|
|
21
|
-
isContentNodeEmpty: isContentNodeEmpty,
|
|
22
|
-
getPos: getPos,
|
|
23
|
-
api: api
|
|
24
|
-
});
|
|
25
|
-
return /*#__PURE__*/React.createElement(DecisionItem, {
|
|
26
|
-
contentRef: forwardRef,
|
|
27
|
-
showPlaceholder: showPlaceholder
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var Decision = /*#__PURE__*/function (_ReactNodeView) {
|
|
31
|
-
_inherits(Decision, _ReactNodeView);
|
|
32
|
-
var _super = _createSuper(Decision);
|
|
33
|
-
function Decision() {
|
|
34
|
-
_classCallCheck(this, Decision);
|
|
35
|
-
return _super.apply(this, arguments);
|
|
36
|
-
}
|
|
37
|
-
_createClass(Decision, [{
|
|
38
|
-
key: "isContentEmpty",
|
|
39
|
-
value: function isContentEmpty(node) {
|
|
40
|
-
return node.content.childCount === 0;
|
|
41
|
-
}
|
|
42
|
-
}, {
|
|
43
|
-
key: "initWithAPI",
|
|
44
|
-
value: function initWithAPI(api) {
|
|
45
|
-
this.api = api;
|
|
46
|
-
this.init();
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
}, {
|
|
50
|
-
key: "createDomRef",
|
|
51
|
-
value: function createDomRef() {
|
|
52
|
-
var domRef = document.createElement('li');
|
|
53
|
-
domRef.style['list-style-type'] = 'none';
|
|
54
|
-
return domRef;
|
|
55
|
-
}
|
|
56
|
-
}, {
|
|
57
|
-
key: "getContentDOM",
|
|
58
|
-
value: function getContentDOM() {
|
|
59
|
-
var dom = document.createElement('div');
|
|
60
|
-
// setting a className prevents PM/Chrome mutation observer from
|
|
61
|
-
// incorrectly deleting nodes
|
|
62
|
-
dom.className = 'decision-item';
|
|
63
|
-
return {
|
|
64
|
-
dom: dom
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
}, {
|
|
68
|
-
key: "render",
|
|
69
|
-
value: function render(_props, forwardRef) {
|
|
70
|
-
var isContentNodeEmpty = this.isContentEmpty(this.node);
|
|
71
|
-
return /*#__PURE__*/React.createElement(DecisionItemWrapper, {
|
|
72
|
-
forwardRef: forwardRef,
|
|
73
|
-
isContentNodeEmpty: isContentNodeEmpty,
|
|
74
|
-
api: this.api
|
|
75
|
-
// The getPosHandler type is wrong, there is no `boolean` in the real implementation
|
|
76
|
-
// @ts-expect-error 2322: Type 'getPosHandler' is not assignable to type '() => number | undefined'.
|
|
77
|
-
,
|
|
78
|
-
getPos: this.getPos,
|
|
79
|
-
editorView: this.view
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}, {
|
|
83
|
-
key: "viewShouldUpdate",
|
|
84
|
-
value: function viewShouldUpdate(nextNode) {
|
|
85
|
-
/**
|
|
86
|
-
* To ensure the placeholder is correctly toggled we need to allow react to re-render
|
|
87
|
-
* on first character insertion.
|
|
88
|
-
* Note: last character deletion is handled externally and automatically re-renders.
|
|
89
|
-
*/
|
|
90
|
-
return this.isContentEmpty(this.node) && !!nextNode.content.childCount;
|
|
91
|
-
}
|
|
92
|
-
}, {
|
|
93
|
-
key: "update",
|
|
94
|
-
value: function update(node, decorations) {
|
|
95
|
-
var _this = this;
|
|
96
|
-
return _get(_getPrototypeOf(Decision.prototype), "update", this).call(this, node, decorations, undefined,
|
|
97
|
-
// Toggle the placeholder based on whether user input exists.
|
|
98
|
-
function (_currentNode, _newNode) {
|
|
99
|
-
return !_this.isContentEmpty(_newNode);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}]);
|
|
103
|
-
return Decision;
|
|
104
|
-
}(ReactNodeView);
|
|
105
|
-
export var decisionItemNodeView = function decisionItemNodeView(portalProviderAPI, eventDispatcher, api) {
|
|
106
|
-
return function (node, view, getPos) {
|
|
107
|
-
var hasIntlContext = true;
|
|
108
|
-
return new Decision(node, view, getPos, portalProviderAPI, eventDispatcher, {}, undefined, undefined, undefined, hasIntlContext).initWithAPI(api);
|
|
109
|
-
};
|
|
110
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
|
-
export var useShowPlaceholder = function useShowPlaceholder(_ref) {
|
|
5
|
-
var editorView = _ref.editorView,
|
|
6
|
-
api = _ref.api,
|
|
7
|
-
isContentNodeEmpty = _ref.isContentNodeEmpty,
|
|
8
|
-
getPos = _ref.getPos;
|
|
9
|
-
var _useSharedPluginState = useSharedPluginState(api, ['typeAhead']),
|
|
10
|
-
typeAheadState = _useSharedPluginState.typeAheadState;
|
|
11
|
-
var isTypeAheadOpen = Boolean(typeAheadState === null || typeAheadState === void 0 ? void 0 : typeAheadState.isOpen);
|
|
12
|
-
var isTypeAheadOpenedInsideItem = useMemo(function () {
|
|
13
|
-
var _selection$$cursor;
|
|
14
|
-
if (!isTypeAheadOpen) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
var itemPosition = getPos();
|
|
18
|
-
if (typeof itemPosition !== 'number') {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
var selection = editorView.state.selection;
|
|
22
|
-
if (!(selection instanceof TextSelection)) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
var maybeItemNode = editorView.state.doc.nodeAt(itemPosition);
|
|
26
|
-
var maybeParentItemNode = (_selection$$cursor = selection.$cursor) === null || _selection$$cursor === void 0 ? void 0 : _selection$$cursor.node();
|
|
27
|
-
if (maybeItemNode && maybeParentItemNode && maybeItemNode.eq(maybeParentItemNode)) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
return false;
|
|
31
|
-
}, [isTypeAheadOpen, getPos, editorView]);
|
|
32
|
-
var showPlaceholder = Boolean(!isTypeAheadOpenedInsideItem && isContentNodeEmpty);
|
|
33
|
-
return showPlaceholder;
|
|
34
|
-
};
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _get from "@babel/runtime/helpers/get";
|
|
5
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
7
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
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; }
|
|
10
|
-
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; }
|
|
11
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import { AnalyticsListener } from '@atlaskit/analytics-next';
|
|
15
|
-
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
16
|
-
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
17
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
18
|
-
import { useShowPlaceholder } from './hooks/use-show-placeholder';
|
|
19
|
-
import TaskItem from '../ui/Task';
|
|
20
|
-
var TaskItemWrapper = function TaskItemWrapper(_ref) {
|
|
21
|
-
var localId = _ref.localId,
|
|
22
|
-
forwardRef = _ref.forwardRef,
|
|
23
|
-
isDone = _ref.isDone,
|
|
24
|
-
onChange = _ref.onChange,
|
|
25
|
-
providerFactory = _ref.providerFactory,
|
|
26
|
-
isContentNodeEmpty = _ref.isContentNodeEmpty,
|
|
27
|
-
api = _ref.api,
|
|
28
|
-
getPos = _ref.getPos,
|
|
29
|
-
editorView = _ref.editorView;
|
|
30
|
-
var _useSharedPluginState = useSharedPluginState(api, ['taskDecision']),
|
|
31
|
-
taskDecisionState = _useSharedPluginState.taskDecisionState;
|
|
32
|
-
var isFocused = Boolean((taskDecisionState === null || taskDecisionState === void 0 ? void 0 : taskDecisionState.focusedTaskItemLocalId) === localId);
|
|
33
|
-
var showPlaceholder = useShowPlaceholder({
|
|
34
|
-
editorView: editorView,
|
|
35
|
-
isContentNodeEmpty: isContentNodeEmpty,
|
|
36
|
-
getPos: getPos,
|
|
37
|
-
api: api
|
|
38
|
-
});
|
|
39
|
-
return /*#__PURE__*/React.createElement(TaskItem, {
|
|
40
|
-
taskId: localId,
|
|
41
|
-
contentRef: forwardRef,
|
|
42
|
-
isDone: isDone,
|
|
43
|
-
onChange: onChange,
|
|
44
|
-
isFocused: isFocused,
|
|
45
|
-
showPlaceholder: showPlaceholder,
|
|
46
|
-
providers: providerFactory
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
var Task = /*#__PURE__*/function (_ReactNodeView) {
|
|
50
|
-
_inherits(Task, _ReactNodeView);
|
|
51
|
-
var _super = _createSuper(Task);
|
|
52
|
-
function Task() {
|
|
53
|
-
var _this;
|
|
54
|
-
_classCallCheck(this, Task);
|
|
55
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
56
|
-
args[_key] = arguments[_key];
|
|
57
|
-
}
|
|
58
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
59
|
-
_defineProperty(_assertThisInitialized(_this), "handleOnChange", function (taskId, isChecked) {
|
|
60
|
-
var tr = _this.view.state.tr;
|
|
61
|
-
var nodePos = _this.getPos();
|
|
62
|
-
if (typeof nodePos !== 'number') {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// SetAttrsStep should be used to prevent task updates from being dropped when mapping task ticks
|
|
67
|
-
// from a previous version of the document, such as a published page.
|
|
68
|
-
tr.step(new SetAttrsStep(nodePos, {
|
|
69
|
-
state: isChecked ? 'DONE' : 'TODO',
|
|
70
|
-
localId: taskId
|
|
71
|
-
}));
|
|
72
|
-
tr.setMeta('scrollIntoView', false);
|
|
73
|
-
_this.view.dispatch(tr);
|
|
74
|
-
});
|
|
75
|
-
/**
|
|
76
|
-
* Dynamically generates analytics data relating to the parent list.
|
|
77
|
-
*
|
|
78
|
-
* Required to be dynamic, as list (in prosemirror model) may have
|
|
79
|
-
* changed (e.g. item movements, or additional items in list).
|
|
80
|
-
* This node view will have not rerendered for those changes, so
|
|
81
|
-
* cannot render the position and listSize into the
|
|
82
|
-
* AnalyticsContext at initial render time.
|
|
83
|
-
*/
|
|
84
|
-
_defineProperty(_assertThisInitialized(_this), "addListAnalyticsData", function (event) {
|
|
85
|
-
try {
|
|
86
|
-
var nodePos = _this.getPos();
|
|
87
|
-
if (typeof nodePos !== 'number') {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
var resolvedPos = _this.view.state.doc.resolve(nodePos);
|
|
91
|
-
var position = resolvedPos.index();
|
|
92
|
-
var listSize = resolvedPos.parent.childCount;
|
|
93
|
-
var listLocalId = resolvedPos.parent.attrs.localId;
|
|
94
|
-
event.update(function (payload) {
|
|
95
|
-
var _payload$attributes = payload.attributes,
|
|
96
|
-
attributes = _payload$attributes === void 0 ? {} : _payload$attributes,
|
|
97
|
-
actionSubject = payload.actionSubject;
|
|
98
|
-
if (actionSubject !== 'action') {
|
|
99
|
-
// Not action related, ignore
|
|
100
|
-
return payload;
|
|
101
|
-
}
|
|
102
|
-
return _objectSpread(_objectSpread({}, payload), {}, {
|
|
103
|
-
attributes: _objectSpread(_objectSpread({}, attributes), {}, {
|
|
104
|
-
position: position,
|
|
105
|
-
listSize: listSize,
|
|
106
|
-
listLocalId: listLocalId
|
|
107
|
-
})
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
} catch (e) {
|
|
111
|
-
// This can occur if pos is NaN (seen it in some test cases)
|
|
112
|
-
// Act defensively here, and lose some analytics data rather than
|
|
113
|
-
// cause any user facing error.
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
return _this;
|
|
117
|
-
}
|
|
118
|
-
_createClass(Task, [{
|
|
119
|
-
key: "initWithAPI",
|
|
120
|
-
value: function initWithAPI(api) {
|
|
121
|
-
this.api = api;
|
|
122
|
-
this.init();
|
|
123
|
-
return this;
|
|
124
|
-
}
|
|
125
|
-
}, {
|
|
126
|
-
key: "isContentEmpty",
|
|
127
|
-
value: function isContentEmpty(node) {
|
|
128
|
-
return node.content.childCount === 0;
|
|
129
|
-
}
|
|
130
|
-
}, {
|
|
131
|
-
key: "createDomRef",
|
|
132
|
-
value: function createDomRef() {
|
|
133
|
-
var domRef = document.createElement('div');
|
|
134
|
-
domRef.style['list-style-type'] = 'none';
|
|
135
|
-
return domRef;
|
|
136
|
-
}
|
|
137
|
-
}, {
|
|
138
|
-
key: "getContentDOM",
|
|
139
|
-
value: function getContentDOM() {
|
|
140
|
-
var dom = document.createElement('div');
|
|
141
|
-
// setting a className prevents PM/Chrome mutation observer from
|
|
142
|
-
// incorrectly deleting nodes
|
|
143
|
-
dom.className = 'task-item';
|
|
144
|
-
return {
|
|
145
|
-
dom: dom
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
}, {
|
|
149
|
-
key: "render",
|
|
150
|
-
value: function render(props, forwardRef) {
|
|
151
|
-
var _this$node$attrs = this.node.attrs,
|
|
152
|
-
localId = _this$node$attrs.localId,
|
|
153
|
-
state = _this$node$attrs.state;
|
|
154
|
-
var isContentNodeEmpty = this.isContentEmpty(this.node);
|
|
155
|
-
return /*#__PURE__*/React.createElement(AnalyticsListener, {
|
|
156
|
-
channel: "fabric-elements",
|
|
157
|
-
onEvent: this.addListAnalyticsData
|
|
158
|
-
}, /*#__PURE__*/React.createElement(TaskItemWrapper, {
|
|
159
|
-
localId: localId,
|
|
160
|
-
forwardRef: forwardRef,
|
|
161
|
-
isDone: state === 'DONE',
|
|
162
|
-
onChange: this.handleOnChange,
|
|
163
|
-
isContentNodeEmpty: isContentNodeEmpty,
|
|
164
|
-
providerFactory: props.providerFactory
|
|
165
|
-
// The getPosHandler type is wrong, there is no `boolean` in the real implementation
|
|
166
|
-
// @ts-expect-error 2322: Type 'getPosHandler' is not assignable to type '() => number | undefined'.
|
|
167
|
-
,
|
|
168
|
-
getPos: this.getPos,
|
|
169
|
-
editorView: this.view,
|
|
170
|
-
api: this.api
|
|
171
|
-
}));
|
|
172
|
-
}
|
|
173
|
-
}, {
|
|
174
|
-
key: "viewShouldUpdate",
|
|
175
|
-
value: function viewShouldUpdate(nextNode) {
|
|
176
|
-
/**
|
|
177
|
-
* To ensure the placeholder is correctly toggled we need to allow react to re-render
|
|
178
|
-
* on first character insertion.
|
|
179
|
-
* Note: last character deletion is handled externally and automatically re-renders.
|
|
180
|
-
*/
|
|
181
|
-
return this.isContentEmpty(this.node) && !!nextNode.content.childCount;
|
|
182
|
-
}
|
|
183
|
-
}, {
|
|
184
|
-
key: "update",
|
|
185
|
-
value: function update(node, decorations) {
|
|
186
|
-
var _this2 = this;
|
|
187
|
-
return _get(_getPrototypeOf(Task.prototype), "update", this).call(this, node, decorations, undefined, function (currentNode, newNode) {
|
|
188
|
-
return (
|
|
189
|
-
// Toggle the placeholder based on whether user input exists
|
|
190
|
-
!_this2.isContentEmpty(newNode) && !!(currentNode.attrs.state === newNode.attrs.state)
|
|
191
|
-
);
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}]);
|
|
195
|
-
return Task;
|
|
196
|
-
}(ReactNodeView);
|
|
197
|
-
export function taskItemNodeViewFactory(portalProviderAPI, eventDispatcher, providerFactory, api) {
|
|
198
|
-
return function (node, view, getPos) {
|
|
199
|
-
var hasIntlContext = true;
|
|
200
|
-
return new Task(node, view, getPos, portalProviderAPI, eventDispatcher, {
|
|
201
|
-
providerFactory: providerFactory
|
|
202
|
-
}, undefined, undefined, undefined, hasIntlContext).initWithAPI(api);
|
|
203
|
-
};
|
|
204
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { findWrapping, ReplaceAroundStep } from '@atlaskit/editor-prosemirror/transform';
|
|
2
|
-
import { findCutBefore } from '@atlaskit/editor-common/commands';
|
|
3
|
-
import { getBlockRange, isActionOrDecisionItem, isActionOrDecisionList, liftBlock, subtreeHeight } from './helpers';
|
|
4
|
-
import { normalizeTaskItemsSelection } from '../utils';
|
|
5
|
-
export var liftSelection = function liftSelection(state, dispatch) {
|
|
6
|
-
var normalizedSelection = normalizeTaskItemsSelection(state.selection);
|
|
7
|
-
var $from = normalizedSelection.$from,
|
|
8
|
-
$to = normalizedSelection.$to;
|
|
9
|
-
var tr = liftBlock(state.tr, $from, $to);
|
|
10
|
-
if (dispatch && tr) {
|
|
11
|
-
dispatch(tr);
|
|
12
|
-
}
|
|
13
|
-
return !!tr;
|
|
14
|
-
};
|
|
15
|
-
export var wrapSelectionInTaskList = function wrapSelectionInTaskList(state, dispatch) {
|
|
16
|
-
var _normalizeTaskItemsSe = normalizeTaskItemsSelection(state.selection),
|
|
17
|
-
$from = _normalizeTaskItemsSe.$from,
|
|
18
|
-
$to = _normalizeTaskItemsSe.$to;
|
|
19
|
-
|
|
20
|
-
// limit ui indentation to 6 levels
|
|
21
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
22
|
-
taskList = _state$schema$nodes.taskList,
|
|
23
|
-
taskItem = _state$schema$nodes.taskItem;
|
|
24
|
-
var maxDepth = subtreeHeight($from, $to, [taskList, taskItem]);
|
|
25
|
-
if (maxDepth >= 6) {
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
var blockRange = getBlockRange($from, $to);
|
|
29
|
-
if (!blockRange) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
var wrapping = findWrapping(blockRange, state.schema.nodes.taskList);
|
|
33
|
-
if (!wrapping) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
if (dispatch) {
|
|
37
|
-
dispatch(state.tr.wrap(blockRange, wrapping).scrollIntoView());
|
|
38
|
-
}
|
|
39
|
-
return true;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Tries to move the paragraph content near the given position into the taskItem or decisionItem
|
|
44
|
-
* before it.
|
|
45
|
-
*
|
|
46
|
-
* Looks backwards from the given position to find the "cut point" between the last taskItem and the
|
|
47
|
-
* following paragraph. Then tries to move the content from that paragraph into the taskItem.
|
|
48
|
-
*
|
|
49
|
-
* @param $pos Position at the end of, or anywhere in paragraph following, the last taskItem
|
|
50
|
-
* @see {joinToPreviousListItem}
|
|
51
|
-
*/
|
|
52
|
-
export var joinAtCut = function joinAtCut($pos) {
|
|
53
|
-
return function (state, dispatch) {
|
|
54
|
-
var $cut = findCutBefore($pos);
|
|
55
|
-
if (!$cut) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
var paragraph = $cut.doc.type.schema.nodes.paragraph;
|
|
59
|
-
|
|
60
|
-
// find the boundary between the taskList and paragraph
|
|
61
|
-
if ($cut.nodeBefore && isActionOrDecisionList($cut.nodeBefore) && $cut.nodeAfter && $cut.nodeAfter.type === paragraph) {
|
|
62
|
-
// we'll find the boundary of a taskList
|
|
63
|
-
// so resolve -1 to find the inside end of the last taskItem
|
|
64
|
-
var $lastNode = $cut.doc.resolve($cut.pos - 1);
|
|
65
|
-
|
|
66
|
-
// might have deeply nested taskList, keep trying to find it
|
|
67
|
-
while (!isActionOrDecisionItem($lastNode.parent)) {
|
|
68
|
-
$lastNode = state.doc.resolve($lastNode.pos - 1);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// grab the structure between the taskItem and the paragraph
|
|
72
|
-
// note: structure = true in ReplaceAroundStep
|
|
73
|
-
var slice = state.tr.doc.slice($lastNode.pos, $cut.pos);
|
|
74
|
-
|
|
75
|
-
// collapse the range between end of last taskItem and after the paragraph
|
|
76
|
-
// with the gap being the paragraph's content (i.e. take that content)
|
|
77
|
-
//
|
|
78
|
-
// we pass the structure we found earlier to join the p and taskItem nodes
|
|
79
|
-
//
|
|
80
|
-
// see https://prosemirror.net/docs/ref/#transform.ReplaceStep.constructor
|
|
81
|
-
// see https://prosemirror.net/docs/ref/#transform.ReplaceAroundStep.constructor
|
|
82
|
-
var tr = state.tr.step(new ReplaceAroundStep($lastNode.pos, $cut.pos + $cut.nodeAfter.nodeSize, $cut.pos + 1, $cut.pos + $cut.nodeAfter.nodeSize - 1, slice, 0, true));
|
|
83
|
-
if (dispatch) {
|
|
84
|
-
dispatch(tr);
|
|
85
|
-
}
|
|
86
|
-
return true;
|
|
87
|
-
}
|
|
88
|
-
return false;
|
|
89
|
-
};
|
|
90
|
-
};
|