@atlaskit/editor-core 189.3.29 → 189.3.31
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/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/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/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/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/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 +4 -4
- 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,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = exports.ToolbarTask = void 0;
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
-
var _reactIntlNext = require("react-intl-next");
|
|
18
|
-
var _task = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/task"));
|
|
19
|
-
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
20
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
21
|
-
var _commands = require("../../commands");
|
|
22
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
25
|
-
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; } }
|
|
26
|
-
var ToolbarTask = exports.ToolbarTask = /*#__PURE__*/function (_PureComponent) {
|
|
27
|
-
(0, _inherits2.default)(ToolbarTask, _PureComponent);
|
|
28
|
-
var _super = _createSuper(ToolbarTask);
|
|
29
|
-
function ToolbarTask() {
|
|
30
|
-
var _this;
|
|
31
|
-
(0, _classCallCheck2.default)(this, ToolbarTask);
|
|
32
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
33
|
-
args[_key] = arguments[_key];
|
|
34
|
-
}
|
|
35
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
36
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
37
|
-
disabled: false
|
|
38
|
-
});
|
|
39
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleInsertTask", function () {
|
|
40
|
-
var _editorAPI$analytics;
|
|
41
|
-
var _this$props = _this.props,
|
|
42
|
-
editorView = _this$props.editorView,
|
|
43
|
-
editorAPI = _this$props.editorAPI;
|
|
44
|
-
if (!editorView) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
(0, _commands.insertTaskDecisionCommand)(editorAPI === null || editorAPI === void 0 || (_editorAPI$analytics = editorAPI.analytics) === null || _editorAPI$analytics === void 0 ? void 0 : _editorAPI$analytics.actions)('taskList')(editorView.state, editorView.dispatch);
|
|
48
|
-
return true;
|
|
49
|
-
});
|
|
50
|
-
return _this;
|
|
51
|
-
}
|
|
52
|
-
(0, _createClass2.default)(ToolbarTask, [{
|
|
53
|
-
key: "render",
|
|
54
|
-
value: function render() {
|
|
55
|
-
var disabled = this.state.disabled;
|
|
56
|
-
var _this$props2 = this.props,
|
|
57
|
-
isDisabled = _this$props2.isDisabled,
|
|
58
|
-
isReducedSpacing = _this$props2.isReducedSpacing,
|
|
59
|
-
formatMessage = _this$props2.intl.formatMessage;
|
|
60
|
-
var label = formatMessage(_messages.toolbarInsertBlockMessages.action);
|
|
61
|
-
return /*#__PURE__*/_react.default.createElement(_uiMenu.ToolbarButton, {
|
|
62
|
-
buttonId: _uiMenu.TOOLBAR_BUTTON.TASK_LIST,
|
|
63
|
-
onClick: this.handleInsertTask,
|
|
64
|
-
disabled: disabled || isDisabled,
|
|
65
|
-
spacing: isReducedSpacing ? 'none' : 'default',
|
|
66
|
-
title: "".concat(label, " []"),
|
|
67
|
-
iconBefore: /*#__PURE__*/_react.default.createElement(_task.default, {
|
|
68
|
-
label: label
|
|
69
|
-
})
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}]);
|
|
73
|
-
return ToolbarTask;
|
|
74
|
-
}(_react.PureComponent);
|
|
75
|
-
var _default = exports.default = (0, _reactIntlNext.injectIntl)(ToolbarTask);
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.normalizeTaskItemsSelection = void 0;
|
|
7
|
-
Object.defineProperty(exports, "transformSliceToDecisionList", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function get() {
|
|
10
|
-
return _transforms.transformSliceToDecisionList;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
|
-
var _transforms = require("@atlaskit/editor-common/transforms");
|
|
15
|
-
function isTaskListNode(node) {
|
|
16
|
-
return Boolean(node && node.type && 'taskList' === node.type.name);
|
|
17
|
-
}
|
|
18
|
-
var resolvePositionToStartOfTaskItem = function resolvePositionToStartOfTaskItem($pos) {
|
|
19
|
-
var fromRange = $pos.blockRange($pos, isTaskListNode);
|
|
20
|
-
var fromPosition = fromRange && $pos.textOffset === 0 && fromRange.end - 1 === $pos.pos ? _state.Selection.near($pos.doc.resolve(fromRange.end + 1), 1).$from : $pos;
|
|
21
|
-
return fromPosition;
|
|
22
|
-
};
|
|
23
|
-
var resolvePositionToEndOfTaskItem = function resolvePositionToEndOfTaskItem($pos) {
|
|
24
|
-
var toRange = $pos.blockRange($pos, isTaskListNode);
|
|
25
|
-
var toPosition = toRange && $pos.textOffset === 0 && toRange.start + 1 === $pos.pos ? _state.Selection.near($pos.doc.resolve(toRange.start - 1), -1).$to : $pos;
|
|
26
|
-
return toPosition;
|
|
27
|
-
};
|
|
28
|
-
var normalizeTaskItemsSelection = exports.normalizeTaskItemsSelection = function normalizeTaskItemsSelection(selection) {
|
|
29
|
-
if (selection.empty) {
|
|
30
|
-
return selection;
|
|
31
|
-
}
|
|
32
|
-
var $from = selection.$from,
|
|
33
|
-
$to = selection.$to;
|
|
34
|
-
if (selection instanceof _state.NodeSelection) {
|
|
35
|
-
var _head = resolvePositionToStartOfTaskItem($from);
|
|
36
|
-
return new _state.TextSelection(_head, _head);
|
|
37
|
-
}
|
|
38
|
-
var head = resolvePositionToStartOfTaskItem($from);
|
|
39
|
-
var anchor = resolvePositionToEndOfTaskItem($to);
|
|
40
|
-
return new _state.TextSelection(anchor, head);
|
|
41
|
-
};
|
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
import { NodeRange } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import { findParentNodeOfType, hasParentNodeOfType, replaceParentNodeOfType, safeInsert, setTextSelection } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
-
import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
|
|
5
|
-
import { uuid } from '@atlaskit/adf-schema';
|
|
6
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, USER_CONTEXT } from '@atlaskit/editor-common/analytics';
|
|
7
|
-
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
8
|
-
import { stateKey as taskDecisionStateKey } from './pm-plugins/plugin-key';
|
|
9
|
-
import { autoJoinTr } from '@atlaskit/editor-common/utils';
|
|
10
|
-
const getContextData = (contextProvider = {}) => {
|
|
11
|
-
const {
|
|
12
|
-
objectId,
|
|
13
|
-
containerId
|
|
14
|
-
} = contextProvider;
|
|
15
|
-
const userContext = objectId ? USER_CONTEXT.EDIT : USER_CONTEXT.NEW;
|
|
16
|
-
return {
|
|
17
|
-
objectId,
|
|
18
|
-
containerId,
|
|
19
|
-
userContext
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
const generateAnalyticsPayload = (listType, contextData, inputMethod, itemLocalId, listLocalId, itemIdx, listSize) => {
|
|
23
|
-
let containerId;
|
|
24
|
-
let objectId;
|
|
25
|
-
let userContext;
|
|
26
|
-
if (contextData) {
|
|
27
|
-
({
|
|
28
|
-
containerId,
|
|
29
|
-
objectId,
|
|
30
|
-
userContext
|
|
31
|
-
} = contextData);
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
action: ACTION.INSERTED,
|
|
35
|
-
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
36
|
-
actionSubjectId: listType === 'taskList' ? ACTION_SUBJECT_ID.ACTION : ACTION_SUBJECT_ID.DECISION,
|
|
37
|
-
eventType: EVENT_TYPE.TRACK,
|
|
38
|
-
attributes: {
|
|
39
|
-
inputMethod,
|
|
40
|
-
containerAri: containerId,
|
|
41
|
-
objectAri: objectId,
|
|
42
|
-
userContext,
|
|
43
|
-
localId: itemLocalId,
|
|
44
|
-
listLocalId,
|
|
45
|
-
position: itemIdx,
|
|
46
|
-
listSize
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
export const getListTypes = (listType, schema) => {
|
|
51
|
-
const {
|
|
52
|
-
decisionList,
|
|
53
|
-
decisionItem,
|
|
54
|
-
taskList,
|
|
55
|
-
taskItem
|
|
56
|
-
} = schema.nodes;
|
|
57
|
-
if (listType === 'taskList') {
|
|
58
|
-
return {
|
|
59
|
-
list: taskList,
|
|
60
|
-
item: taskItem
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
list: decisionList,
|
|
65
|
-
item: decisionItem
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
export const insertTaskDecisionAction = editorAnalyticsAPI => (state, listType, inputMethod = INPUT_METHOD.TOOLBAR, addItem, listLocalId, itemLocalId, itemAttrs) => {
|
|
69
|
-
const {
|
|
70
|
-
schema
|
|
71
|
-
} = state;
|
|
72
|
-
const addAndCreateList = ({
|
|
73
|
-
tr,
|
|
74
|
-
list,
|
|
75
|
-
item,
|
|
76
|
-
listLocalId,
|
|
77
|
-
itemLocalId
|
|
78
|
-
}) => createListAtSelection(tr, list, item, schema, state, listLocalId, itemLocalId, itemAttrs);
|
|
79
|
-
const addToList = ({
|
|
80
|
-
state,
|
|
81
|
-
tr,
|
|
82
|
-
item,
|
|
83
|
-
itemLocalId
|
|
84
|
-
}) => {
|
|
85
|
-
const {
|
|
86
|
-
$to
|
|
87
|
-
} = state.selection;
|
|
88
|
-
const endPos = $to.end($to.depth);
|
|
89
|
-
const newItemParagraphPos = endPos + 2;
|
|
90
|
-
return tr.split(endPos, 1, [{
|
|
91
|
-
type: item,
|
|
92
|
-
attrs: {
|
|
93
|
-
localId: itemLocalId
|
|
94
|
-
}
|
|
95
|
-
}]).setSelection(new TextSelection(tr.doc.resolve(newItemParagraphPos)));
|
|
96
|
-
};
|
|
97
|
-
const addAndCreateListFn = addItem !== null && addItem !== void 0 ? addItem : addAndCreateList;
|
|
98
|
-
const tr = insertTaskDecisionWithAnalytics(editorAnalyticsAPI)(state, listType, inputMethod, addAndCreateListFn, addToList, listLocalId, itemLocalId, itemAttrs);
|
|
99
|
-
if (!tr) {
|
|
100
|
-
return state.tr;
|
|
101
|
-
}
|
|
102
|
-
autoJoinTr(tr, ['taskList', 'decisionList']);
|
|
103
|
-
return tr;
|
|
104
|
-
};
|
|
105
|
-
export const insertTaskDecisionCommand = editorAnalyticsAPI => (listType, inputMethod = INPUT_METHOD.TOOLBAR, addItem, listLocalId, itemLocalId) => (state, dispatch) => {
|
|
106
|
-
const tr = insertTaskDecisionAction(editorAnalyticsAPI)(state, listType, inputMethod, addItem, listLocalId, itemLocalId);
|
|
107
|
-
if (dispatch) {
|
|
108
|
-
dispatch(tr);
|
|
109
|
-
}
|
|
110
|
-
return true;
|
|
111
|
-
};
|
|
112
|
-
export const insertTaskDecisionWithAnalytics = editorAnalyticsAPI => (state, listType, inputMethod, addAndCreateList, addToList, listLocalId, itemLocalId, itemAttrs) => {
|
|
113
|
-
const {
|
|
114
|
-
schema
|
|
115
|
-
} = state;
|
|
116
|
-
const {
|
|
117
|
-
list,
|
|
118
|
-
item
|
|
119
|
-
} = getListTypes(listType, schema);
|
|
120
|
-
const {
|
|
121
|
-
tr
|
|
122
|
-
} = state;
|
|
123
|
-
const {
|
|
124
|
-
$to
|
|
125
|
-
} = state.selection;
|
|
126
|
-
const listNode = findParentNodeOfType(list)(state.selection);
|
|
127
|
-
const contextIdentifierProvider = taskDecisionStateKey.getState(state).contextIdentifierProvider;
|
|
128
|
-
const contextData = getContextData(contextIdentifierProvider);
|
|
129
|
-
let insertTrCreator;
|
|
130
|
-
let itemIdx;
|
|
131
|
-
let listSize;
|
|
132
|
-
if (!listNode) {
|
|
133
|
-
// Not a list - convert to one.
|
|
134
|
-
itemIdx = 0;
|
|
135
|
-
listSize = 1;
|
|
136
|
-
insertTrCreator = addAndCreateList;
|
|
137
|
-
} else if ($to.node().textContent.length >= 0) {
|
|
138
|
-
listSize = listNode.node.childCount + 1;
|
|
139
|
-
listLocalId = listLocalId || listNode.node.attrs.localId;
|
|
140
|
-
const listItemNode = findParentNodeOfType(item)(state.selection); // finds current item in list
|
|
141
|
-
itemIdx = listItemNode ? state.doc.resolve(listItemNode.pos).index() + 1 : 0;
|
|
142
|
-
insertTrCreator = addToList ? addToList : addAndCreateList;
|
|
143
|
-
}
|
|
144
|
-
listLocalId = listLocalId || uuid.generate();
|
|
145
|
-
itemLocalId = itemLocalId || uuid.generate();
|
|
146
|
-
if (insertTrCreator) {
|
|
147
|
-
let insertTr = insertTrCreator({
|
|
148
|
-
state,
|
|
149
|
-
tr,
|
|
150
|
-
list,
|
|
151
|
-
item,
|
|
152
|
-
listLocalId,
|
|
153
|
-
itemLocalId,
|
|
154
|
-
itemAttrs
|
|
155
|
-
});
|
|
156
|
-
if (insertTr) {
|
|
157
|
-
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(generateAnalyticsPayload(listType, contextData, inputMethod, itemLocalId, listLocalId, itemIdx || 0, listSize || 0))(insertTr);
|
|
158
|
-
}
|
|
159
|
-
return insertTr;
|
|
160
|
-
}
|
|
161
|
-
return null;
|
|
162
|
-
};
|
|
163
|
-
export const isSupportedSourceNode = (schema, selection) => {
|
|
164
|
-
const {
|
|
165
|
-
paragraph,
|
|
166
|
-
blockquote,
|
|
167
|
-
decisionList,
|
|
168
|
-
taskList
|
|
169
|
-
} = schema.nodes;
|
|
170
|
-
return hasParentNodeOfType([blockquote, paragraph, decisionList, taskList])(selection);
|
|
171
|
-
};
|
|
172
|
-
export const changeInDepth = (before, after) => after.depth - before.depth;
|
|
173
|
-
export const createListAtSelection = (tr, list, item, schema, state, listLocalId = uuid.generate(), itemLocalId = uuid.generate(), itemAttrs) => {
|
|
174
|
-
const {
|
|
175
|
-
selection
|
|
176
|
-
} = state;
|
|
177
|
-
const {
|
|
178
|
-
$from,
|
|
179
|
-
$to
|
|
180
|
-
} = selection;
|
|
181
|
-
if ($from.parent !== $to.parent) {
|
|
182
|
-
// ignore selections across multiple nodes
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
const {
|
|
186
|
-
paragraph,
|
|
187
|
-
blockquote,
|
|
188
|
-
decisionList,
|
|
189
|
-
taskList,
|
|
190
|
-
decisionItem,
|
|
191
|
-
taskItem,
|
|
192
|
-
mediaGroup
|
|
193
|
-
} = schema.nodes;
|
|
194
|
-
if ($from.parent.type === mediaGroup) {
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
const emptyList = list.create({
|
|
198
|
-
localId: listLocalId
|
|
199
|
-
}, [item.create({
|
|
200
|
-
localId: itemLocalId,
|
|
201
|
-
...itemAttrs
|
|
202
|
-
})]);
|
|
203
|
-
|
|
204
|
-
// we don't take the content of a block node next to the gap cursor and always create an empty task
|
|
205
|
-
if (selection instanceof GapCursorSelection) {
|
|
206
|
-
return safeInsert(emptyList)(tr);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// try to replace when selection is in nodes which support it
|
|
210
|
-
if (isSupportedSourceNode(schema, selection)) {
|
|
211
|
-
const {
|
|
212
|
-
type: nodeType,
|
|
213
|
-
childCount
|
|
214
|
-
} = selection.$from.node();
|
|
215
|
-
const newListNode = list.create({
|
|
216
|
-
localId: uuid.generate()
|
|
217
|
-
}, [item.create({
|
|
218
|
-
localId: uuid.generate()
|
|
219
|
-
}, $from.node($from.depth).content)]);
|
|
220
|
-
const hasBlockquoteParent = findParentNodeOfType(blockquote)(selection);
|
|
221
|
-
if (hasBlockquoteParent) {
|
|
222
|
-
const liftedDepth = $from.depth - 1;
|
|
223
|
-
const range = new NodeRange($from, $to, liftedDepth);
|
|
224
|
-
tr.lift(range, liftTarget(range));
|
|
225
|
-
}
|
|
226
|
-
const listParent = findParentNodeOfType(taskList)(selection) || findParentNodeOfType(decisionList)(selection);
|
|
227
|
-
const listItem = findParentNodeOfType(taskItem)(selection) || findParentNodeOfType(decisionItem)(selection);
|
|
228
|
-
|
|
229
|
-
// For a selection inside a task/decision list, we can't just simply replace the
|
|
230
|
-
// node type as it will mess up lists with > 1 item
|
|
231
|
-
if (listParent && listItem) {
|
|
232
|
-
let start;
|
|
233
|
-
let end;
|
|
234
|
-
let selectionPos = selection.from;
|
|
235
|
-
|
|
236
|
-
// if selection is in first item in list, we need to delete extra so that
|
|
237
|
-
// this list isn't split
|
|
238
|
-
if (listParent.node.firstChild === listItem.node) {
|
|
239
|
-
start = listParent.start - 1;
|
|
240
|
-
end = listItem.start + listItem.node.nodeSize;
|
|
241
|
-
if (listParent.node.childCount === 1) {
|
|
242
|
-
end = listParent.start + listParent.node.nodeSize - 1;
|
|
243
|
-
}
|
|
244
|
-
} else {
|
|
245
|
-
start = listItem.start - 1;
|
|
246
|
-
end = listItem.start + listItem.node.nodeSize;
|
|
247
|
-
selectionPos += 2; // as we have added the new list node
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
tr.replaceWith(start, end, newListNode);
|
|
251
|
-
tr = setTextSelection(selectionPos)(tr);
|
|
252
|
-
return tr;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// For a selection inside one of these node types we can just convert the node type
|
|
256
|
-
const nodeTypesToReplace = [blockquote];
|
|
257
|
-
if (nodeType === paragraph && childCount > 0 || hasBlockquoteParent) {
|
|
258
|
-
// Only convert paragraphs containing content.
|
|
259
|
-
// Empty paragraphs use the default flow.
|
|
260
|
-
// This distinction ensures the text selection remains in the correct location.
|
|
261
|
-
|
|
262
|
-
// We also want to replace the paragraph type when we are inside a blockQuote
|
|
263
|
-
// to avoid inserting an extra taskList whilst keeping the paragraph
|
|
264
|
-
nodeTypesToReplace.push(paragraph);
|
|
265
|
-
}
|
|
266
|
-
let newTr = tr;
|
|
267
|
-
newTr = replaceParentNodeOfType(nodeTypesToReplace, newListNode)(tr);
|
|
268
|
-
|
|
269
|
-
// Adjust depth for new selection, if it has changed (e.g. paragraph to list (ol > li))
|
|
270
|
-
const depthAdjustment = changeInDepth($to, newTr.selection.$to);
|
|
271
|
-
tr = tr.setSelection(new TextSelection(tr.doc.resolve($to.pos + depthAdjustment)));
|
|
272
|
-
|
|
273
|
-
// replacing successful
|
|
274
|
-
if (newTr !== tr) {
|
|
275
|
-
return tr;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
return safeInsert(emptyList)(tr);
|
|
279
|
-
};
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { css, jsx } from '@emotion/react';
|
|
3
|
-
import { decisionItem, decisionList, taskItem, taskList } from '@atlaskit/adf-schema';
|
|
4
|
-
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
|
-
import { toolbarInsertBlockMessages as insertBlockMessages } from '@atlaskit/editor-common/messages';
|
|
6
|
-
import { IconAction, IconDecision } from '@atlaskit/editor-common/quick-insert';
|
|
7
|
-
import { stateKey as taskPluginKey } from './pm-plugins/plugin-key';
|
|
8
|
-
import { insertTaskDecisionAction, getListTypes, insertTaskDecisionCommand } from './commands';
|
|
9
|
-
import inputRulePlugin from './pm-plugins/input-rules';
|
|
10
|
-
import keymap, { getIndentCommand, getUnindentCommand } from './pm-plugins/keymaps';
|
|
11
|
-
import { createPlugin } from './pm-plugins/main';
|
|
12
|
-
import ToolbarDecision from './ui/ToolbarDecision';
|
|
13
|
-
import ToolbarTask from './ui/ToolbarTask';
|
|
14
|
-
import { getCurrentIndentLevel, getTaskItemIndex, isInsideTask } from './pm-plugins/helpers';
|
|
15
|
-
import { MAX_INDENTATION_LEVEL } from '@atlaskit/editor-common/indentation';
|
|
16
|
-
const taskDecisionToolbarGroup = css`
|
|
17
|
-
display: flex;
|
|
18
|
-
`;
|
|
19
|
-
const addItem = (insert, listType, schema) => ({
|
|
20
|
-
listLocalId,
|
|
21
|
-
itemLocalId
|
|
22
|
-
}) => {
|
|
23
|
-
const {
|
|
24
|
-
list,
|
|
25
|
-
item
|
|
26
|
-
} = getListTypes(listType, schema);
|
|
27
|
-
return insert(list.createChecked({
|
|
28
|
-
localId: listLocalId
|
|
29
|
-
}, item.createChecked({
|
|
30
|
-
localId: itemLocalId
|
|
31
|
-
})));
|
|
32
|
-
};
|
|
33
|
-
const tasksAndDecisionsPlugin = ({
|
|
34
|
-
config: {
|
|
35
|
-
allowNestedTasks,
|
|
36
|
-
consumeTabs,
|
|
37
|
-
useLongPressSelection
|
|
38
|
-
} = {},
|
|
39
|
-
api
|
|
40
|
-
}) => {
|
|
41
|
-
var _api$analytics, _api$analytics2, _api$analytics3;
|
|
42
|
-
return {
|
|
43
|
-
name: 'taskDecision',
|
|
44
|
-
nodes() {
|
|
45
|
-
return [{
|
|
46
|
-
name: 'decisionList',
|
|
47
|
-
node: decisionList
|
|
48
|
-
}, {
|
|
49
|
-
name: 'decisionItem',
|
|
50
|
-
node: decisionItem
|
|
51
|
-
}, {
|
|
52
|
-
name: 'taskList',
|
|
53
|
-
node: taskList
|
|
54
|
-
}, {
|
|
55
|
-
name: 'taskItem',
|
|
56
|
-
node: taskItem
|
|
57
|
-
}];
|
|
58
|
-
},
|
|
59
|
-
getSharedState(editorState) {
|
|
60
|
-
if (!editorState) {
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
const pluginState = taskPluginKey.getState(editorState);
|
|
64
|
-
const indentLevel = getCurrentIndentLevel(editorState.selection) || 0;
|
|
65
|
-
const itemIndex = getTaskItemIndex(editorState);
|
|
66
|
-
return {
|
|
67
|
-
focusedTaskItemLocalId: (pluginState === null || pluginState === void 0 ? void 0 : pluginState.focusedTaskItemLocalId) || null,
|
|
68
|
-
isInsideTask: isInsideTask(editorState),
|
|
69
|
-
indentDisabled: itemIndex === 0 || indentLevel >= MAX_INDENTATION_LEVEL,
|
|
70
|
-
outdentDisabled: indentLevel <= 1
|
|
71
|
-
};
|
|
72
|
-
},
|
|
73
|
-
actions: {
|
|
74
|
-
insertTaskDecision: insertTaskDecisionCommand(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions),
|
|
75
|
-
indentTaskList: getIndentCommand(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions),
|
|
76
|
-
outdentTaskList: getUnindentCommand(api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions)
|
|
77
|
-
},
|
|
78
|
-
pmPlugins() {
|
|
79
|
-
return [{
|
|
80
|
-
name: 'tasksAndDecisions',
|
|
81
|
-
plugin: ({
|
|
82
|
-
portalProviderAPI,
|
|
83
|
-
providerFactory,
|
|
84
|
-
eventDispatcher,
|
|
85
|
-
dispatch
|
|
86
|
-
}) => {
|
|
87
|
-
return createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection);
|
|
88
|
-
}
|
|
89
|
-
}, {
|
|
90
|
-
name: 'tasksAndDecisionsInputRule',
|
|
91
|
-
plugin: ({
|
|
92
|
-
schema,
|
|
93
|
-
featureFlags
|
|
94
|
-
}) => {
|
|
95
|
-
var _api$analytics4;
|
|
96
|
-
return inputRulePlugin(api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions)(schema, featureFlags);
|
|
97
|
-
}
|
|
98
|
-
}, {
|
|
99
|
-
name: 'tasksAndDecisionsKeyMap',
|
|
100
|
-
plugin: ({
|
|
101
|
-
schema
|
|
102
|
-
}) => keymap(schema, api, allowNestedTasks, consumeTabs)
|
|
103
|
-
} // Needs to be after "save-on-enter"
|
|
104
|
-
];
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
secondaryToolbarComponent({
|
|
108
|
-
editorView,
|
|
109
|
-
disabled
|
|
110
|
-
}) {
|
|
111
|
-
return jsx("div", {
|
|
112
|
-
css: taskDecisionToolbarGroup
|
|
113
|
-
}, jsx(ToolbarDecision, {
|
|
114
|
-
editorView: editorView,
|
|
115
|
-
isDisabled: disabled,
|
|
116
|
-
isReducedSpacing: true,
|
|
117
|
-
editorAPI: api
|
|
118
|
-
}), jsx(ToolbarTask, {
|
|
119
|
-
editorView: editorView,
|
|
120
|
-
isDisabled: disabled,
|
|
121
|
-
isReducedSpacing: true,
|
|
122
|
-
editorAPI: api
|
|
123
|
-
}));
|
|
124
|
-
},
|
|
125
|
-
pluginsOptions: {
|
|
126
|
-
quickInsert: ({
|
|
127
|
-
formatMessage
|
|
128
|
-
}) => [{
|
|
129
|
-
id: 'action',
|
|
130
|
-
title: formatMessage(insertBlockMessages.action),
|
|
131
|
-
description: formatMessage(insertBlockMessages.actionDescription),
|
|
132
|
-
priority: 100,
|
|
133
|
-
keywords: ['checkbox', 'task', 'todo'],
|
|
134
|
-
keyshortcut: '[]',
|
|
135
|
-
icon: () => jsx(IconAction, null),
|
|
136
|
-
action(insert, state) {
|
|
137
|
-
var _api$analytics5;
|
|
138
|
-
return insertTaskDecisionAction(api === null || api === void 0 ? 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));
|
|
139
|
-
}
|
|
140
|
-
}, {
|
|
141
|
-
id: 'decision',
|
|
142
|
-
title: formatMessage(insertBlockMessages.decision),
|
|
143
|
-
description: formatMessage(insertBlockMessages.decisionDescription),
|
|
144
|
-
priority: 900,
|
|
145
|
-
keyshortcut: '<>',
|
|
146
|
-
icon: () => jsx(IconDecision, null),
|
|
147
|
-
action(insert, state) {
|
|
148
|
-
var _api$analytics6;
|
|
149
|
-
return insertTaskDecisionAction(api === null || api === void 0 ? 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
|
-
export default tasksAndDecisionsPlugin;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
3
|
-
import { useShowPlaceholder } from './hooks/use-show-placeholder';
|
|
4
|
-
import DecisionItem from '../ui/Decision';
|
|
5
|
-
const DecisionItemWrapper = ({
|
|
6
|
-
api,
|
|
7
|
-
editorView,
|
|
8
|
-
forwardRef,
|
|
9
|
-
isContentNodeEmpty,
|
|
10
|
-
getPos
|
|
11
|
-
}) => {
|
|
12
|
-
const showPlaceholder = useShowPlaceholder({
|
|
13
|
-
editorView,
|
|
14
|
-
isContentNodeEmpty,
|
|
15
|
-
getPos,
|
|
16
|
-
api
|
|
17
|
-
});
|
|
18
|
-
return /*#__PURE__*/React.createElement(DecisionItem, {
|
|
19
|
-
contentRef: forwardRef,
|
|
20
|
-
showPlaceholder: showPlaceholder
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
class Decision extends ReactNodeView {
|
|
24
|
-
isContentEmpty(node) {
|
|
25
|
-
return node.content.childCount === 0;
|
|
26
|
-
}
|
|
27
|
-
initWithAPI(api) {
|
|
28
|
-
this.api = api;
|
|
29
|
-
this.init();
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
createDomRef() {
|
|
33
|
-
const domRef = document.createElement('li');
|
|
34
|
-
domRef.style['list-style-type'] = 'none';
|
|
35
|
-
return domRef;
|
|
36
|
-
}
|
|
37
|
-
getContentDOM() {
|
|
38
|
-
const dom = document.createElement('div');
|
|
39
|
-
// setting a className prevents PM/Chrome mutation observer from
|
|
40
|
-
// incorrectly deleting nodes
|
|
41
|
-
dom.className = 'decision-item';
|
|
42
|
-
return {
|
|
43
|
-
dom
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
render(_props, forwardRef) {
|
|
47
|
-
const isContentNodeEmpty = this.isContentEmpty(this.node);
|
|
48
|
-
return /*#__PURE__*/React.createElement(DecisionItemWrapper, {
|
|
49
|
-
forwardRef: forwardRef,
|
|
50
|
-
isContentNodeEmpty: isContentNodeEmpty,
|
|
51
|
-
api: this.api
|
|
52
|
-
// The getPosHandler type is wrong, there is no `boolean` in the real implementation
|
|
53
|
-
// @ts-expect-error 2322: Type 'getPosHandler' is not assignable to type '() => number | undefined'.
|
|
54
|
-
,
|
|
55
|
-
getPos: this.getPos,
|
|
56
|
-
editorView: this.view
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
viewShouldUpdate(nextNode) {
|
|
60
|
-
/**
|
|
61
|
-
* To ensure the placeholder is correctly toggled we need to allow react to re-render
|
|
62
|
-
* on first character insertion.
|
|
63
|
-
* Note: last character deletion is handled externally and automatically re-renders.
|
|
64
|
-
*/
|
|
65
|
-
return this.isContentEmpty(this.node) && !!nextNode.content.childCount;
|
|
66
|
-
}
|
|
67
|
-
update(node, decorations) {
|
|
68
|
-
return super.update(node, decorations, undefined,
|
|
69
|
-
// Toggle the placeholder based on whether user input exists.
|
|
70
|
-
(_currentNode, _newNode) => !this.isContentEmpty(_newNode));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
export const decisionItemNodeView = (portalProviderAPI, eventDispatcher, api) => (node, view, getPos) => {
|
|
74
|
-
const hasIntlContext = true;
|
|
75
|
-
return new Decision(node, view, getPos, portalProviderAPI, eventDispatcher, {}, undefined, undefined, undefined, hasIntlContext).initWithAPI(api);
|
|
76
|
-
};
|
|
@@ -1,36 +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 const useShowPlaceholder = ({
|
|
5
|
-
editorView,
|
|
6
|
-
api,
|
|
7
|
-
isContentNodeEmpty,
|
|
8
|
-
getPos
|
|
9
|
-
}) => {
|
|
10
|
-
const {
|
|
11
|
-
typeAheadState
|
|
12
|
-
} = useSharedPluginState(api, ['typeAhead']);
|
|
13
|
-
const isTypeAheadOpen = Boolean(typeAheadState === null || typeAheadState === void 0 ? void 0 : typeAheadState.isOpen);
|
|
14
|
-
const isTypeAheadOpenedInsideItem = useMemo(() => {
|
|
15
|
-
var _selection$$cursor;
|
|
16
|
-
if (!isTypeAheadOpen) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
const itemPosition = getPos();
|
|
20
|
-
if (typeof itemPosition !== 'number') {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
const selection = editorView.state.selection;
|
|
24
|
-
if (!(selection instanceof TextSelection)) {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
const maybeItemNode = editorView.state.doc.nodeAt(itemPosition);
|
|
28
|
-
const maybeParentItemNode = (_selection$$cursor = selection.$cursor) === null || _selection$$cursor === void 0 ? void 0 : _selection$$cursor.node();
|
|
29
|
-
if (maybeItemNode && maybeParentItemNode && maybeItemNode.eq(maybeParentItemNode)) {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
return false;
|
|
33
|
-
}, [isTypeAheadOpen, getPos, editorView]);
|
|
34
|
-
const showPlaceholder = Boolean(!isTypeAheadOpenedInsideItem && isContentNodeEmpty);
|
|
35
|
-
return showPlaceholder;
|
|
36
|
-
};
|