@atlaskit/editor-core 189.0.9 → 189.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/plugins/index.js +0 -7
  3. package/dist/cjs/plugins/tasks-and-decisions/index.js +15 -5
  4. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +16 -5
  5. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +40 -0
  6. package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +31 -31
  7. package/dist/cjs/presets/universal.js +2 -1
  8. package/dist/cjs/version-wrapper.js +1 -1
  9. package/dist/es2019/plugins/index.js +0 -1
  10. package/dist/es2019/plugins/tasks-and-decisions/index.js +11 -1
  11. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +16 -6
  12. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +36 -0
  13. package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +29 -30
  14. package/dist/es2019/presets/universal.js +2 -1
  15. package/dist/es2019/version-wrapper.js +1 -1
  16. package/dist/esm/plugins/index.js +0 -1
  17. package/dist/esm/plugins/tasks-and-decisions/index.js +11 -1
  18. package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +16 -5
  19. package/dist/esm/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +34 -0
  20. package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +31 -32
  21. package/dist/esm/presets/universal.js +2 -1
  22. package/dist/esm/version-wrapper.js +1 -1
  23. package/dist/types/plugins/index.d.ts +0 -1
  24. package/dist/types/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.d.ts +11 -0
  25. package/dist/types/plugins/tasks-and-decisions/types.d.ts +4 -0
  26. package/dist/types/types/editor-props.d.ts +1 -1
  27. package/dist/types-ts4.5/plugins/index.d.ts +0 -1
  28. package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.d.ts +11 -0
  29. package/dist/types-ts4.5/plugins/tasks-and-decisions/types.d.ts +4 -0
  30. package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
  31. package/package.json +3 -2
  32. package/report.api.md +1 -12
  33. package/tmp/api-report-tmp.d.ts +1 -12
  34. package/dist/cjs/plugins/text-color/commands/change-color.js +0 -61
  35. package/dist/cjs/plugins/text-color/commands/remove-color.js +0 -59
  36. package/dist/cjs/plugins/text-color/commands/toggle-color.js +0 -36
  37. package/dist/cjs/plugins/text-color/index.js +0 -75
  38. package/dist/cjs/plugins/text-color/pm-plugins/main.js +0 -88
  39. package/dist/cjs/plugins/text-color/types.js +0 -5
  40. package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/icon.js +0 -29
  41. package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +0 -285
  42. package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/styles.js +0 -38
  43. package/dist/cjs/plugins/text-color/utils/color.js +0 -54
  44. package/dist/cjs/plugins/text-color/utils/disabled.js +0 -32
  45. package/dist/es2019/plugins/text-color/commands/change-color.js +0 -54
  46. package/dist/es2019/plugins/text-color/commands/remove-color.js +0 -57
  47. package/dist/es2019/plugins/text-color/commands/toggle-color.js +0 -30
  48. package/dist/es2019/plugins/text-color/index.js +0 -63
  49. package/dist/es2019/plugins/text-color/pm-plugins/main.js +0 -75
  50. package/dist/es2019/plugins/text-color/types.js +0 -1
  51. package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/icon.js +0 -20
  52. package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +0 -265
  53. package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/styles.js +0 -48
  54. package/dist/es2019/plugins/text-color/utils/color.js +0 -48
  55. package/dist/es2019/plugins/text-color/utils/disabled.js +0 -39
  56. package/dist/esm/plugins/text-color/commands/change-color.js +0 -56
  57. package/dist/esm/plugins/text-color/commands/remove-color.js +0 -53
  58. package/dist/esm/plugins/text-color/commands/toggle-color.js +0 -30
  59. package/dist/esm/plugins/text-color/index.js +0 -63
  60. package/dist/esm/plugins/text-color/pm-plugins/main.js +0 -75
  61. package/dist/esm/plugins/text-color/types.js +0 -1
  62. package/dist/esm/plugins/text-color/ui/ToolbarTextColor/icon.js +0 -22
  63. package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +0 -282
  64. package/dist/esm/plugins/text-color/ui/ToolbarTextColor/styles.js +0 -28
  65. package/dist/esm/plugins/text-color/utils/color.js +0 -48
  66. package/dist/esm/plugins/text-color/utils/disabled.js +0 -26
  67. package/dist/types/plugins/text-color/commands/change-color.d.ts +0 -3
  68. package/dist/types/plugins/text-color/commands/remove-color.d.ts +0 -2
  69. package/dist/types/plugins/text-color/commands/toggle-color.d.ts +0 -2
  70. package/dist/types/plugins/text-color/index.d.ts +0 -7
  71. package/dist/types/plugins/text-color/pm-plugins/main.d.ts +0 -25
  72. package/dist/types/plugins/text-color/types.d.ts +0 -10
  73. package/dist/types/plugins/text-color/ui/ToolbarTextColor/icon.d.ts +0 -2
  74. package/dist/types/plugins/text-color/ui/ToolbarTextColor/index.d.ts +0 -53
  75. package/dist/types/plugins/text-color/ui/ToolbarTextColor/styles.d.ts +0 -3
  76. package/dist/types/plugins/text-color/utils/color.d.ts +0 -6
  77. package/dist/types/plugins/text-color/utils/disabled.d.ts +0 -2
  78. package/dist/types-ts4.5/plugins/text-color/commands/change-color.d.ts +0 -3
  79. package/dist/types-ts4.5/plugins/text-color/commands/remove-color.d.ts +0 -2
  80. package/dist/types-ts4.5/plugins/text-color/commands/toggle-color.d.ts +0 -2
  81. package/dist/types-ts4.5/plugins/text-color/index.d.ts +0 -7
  82. package/dist/types-ts4.5/plugins/text-color/pm-plugins/main.d.ts +0 -25
  83. package/dist/types-ts4.5/plugins/text-color/types.d.ts +0 -12
  84. package/dist/types-ts4.5/plugins/text-color/ui/ToolbarTextColor/icon.d.ts +0 -2
  85. package/dist/types-ts4.5/plugins/text-color/ui/ToolbarTextColor/index.d.ts +0 -53
  86. package/dist/types-ts4.5/plugins/text-color/ui/ToolbarTextColor/styles.d.ts +0 -3
  87. package/dist/types-ts4.5/plugins/text-color/utils/color.d.ts +0 -6
  88. package/dist/types-ts4.5/plugins/text-color/utils/disabled.d.ts +0 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 189.0.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [#42153](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42153) [`56e9ac7f76d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/56e9ac7f76d) - Extract text-color plugin from editor-core into @atlaskit/editor-plugin-text-color.
8
+ - Updated dependencies
9
+
10
+ ## 189.0.10
11
+
12
+ ### Patch Changes
13
+
14
+ - [#42139](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42139) [`9474db7141c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9474db7141c) - [ED-20622] Fix task and decision placeholder been removed when the TypeAhead was open
15
+
3
16
  ## 189.0.9
4
17
 
5
18
  ### Patch Changes
@@ -191,12 +191,6 @@ Object.defineProperty(exports, "tasksAndDecisionsPlugin", {
191
191
  return _tasksAndDecisions.default;
192
192
  }
193
193
  });
194
- Object.defineProperty(exports, "textColorPlugin", {
195
- enumerable: true,
196
- get: function get() {
197
- return _textColor.default;
198
- }
199
- });
200
194
  Object.defineProperty(exports, "toolbarListsIndentationPlugin", {
201
195
  enumerable: true,
202
196
  get: function get() {
@@ -230,7 +224,6 @@ var _panel = _interopRequireDefault(require("./panel"));
230
224
  var _paste = _interopRequireDefault(require("./paste"));
231
225
  var _placeholderText = require("./placeholder-text");
232
226
  var _tasksAndDecisions = _interopRequireDefault(require("./tasks-and-decisions"));
233
- var _textColor = _interopRequireDefault(require("./text-color"));
234
227
  var _breakout = _interopRequireDefault(require("./breakout"));
235
228
  var _alignment = _interopRequireDefault(require("./alignment"));
236
229
  var _dataConsumer = _interopRequireDefault(require("./data-consumer"));
@@ -9,8 +9,9 @@ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/hel
9
9
  var _react = require("@emotion/react");
10
10
  var _adfSchema = require("@atlaskit/adf-schema");
11
11
  var _analytics = require("@atlaskit/editor-common/analytics");
12
- var _messages = require("../insert-block/ui/ToolbarInsertBlock/messages");
12
+ var _messages = require("@atlaskit/editor-common/messages");
13
13
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
14
+ var _pluginKey = require("./pm-plugins/plugin-key");
14
15
  var _commands = require("./commands");
15
16
  var _inputRules = _interopRequireDefault(require("./pm-plugins/input-rules"));
16
17
  var _keymaps = _interopRequireDefault(require("./pm-plugins/keymaps"));
@@ -58,6 +59,15 @@ var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
58
59
  node: _adfSchema.taskItem
59
60
  }];
60
61
  },
62
+ getSharedState: function getSharedState(editorState) {
63
+ if (!editorState) {
64
+ return undefined;
65
+ }
66
+ var pluginState = _pluginKey.stateKey.getState(editorState);
67
+ return {
68
+ focusedTaskItemLocalId: (pluginState === null || pluginState === void 0 ? void 0 : pluginState.focusedTaskItemLocalId) || null
69
+ };
70
+ },
61
71
  pmPlugins: function pmPlugins() {
62
72
  return [{
63
73
  name: 'tasksAndDecisions',
@@ -107,8 +117,8 @@ var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
107
117
  var formatMessage = _ref7.formatMessage;
108
118
  return [{
109
119
  id: 'action',
110
- title: formatMessage(_messages.messages.action),
111
- description: formatMessage(_messages.messages.actionDescription),
120
+ title: formatMessage(_messages.toolbarInsertBlockMessages.action),
121
+ description: formatMessage(_messages.toolbarInsertBlockMessages.actionDescription),
112
122
  priority: 100,
113
123
  keywords: ['checkbox', 'task', 'todo'],
114
124
  keyshortcut: '[]',
@@ -121,8 +131,8 @@ var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
121
131
  }
122
132
  }, {
123
133
  id: 'decision',
124
- title: formatMessage(_messages.messages.decision),
125
- description: formatMessage(_messages.messages.decisionDescription),
134
+ title: formatMessage(_messages.toolbarInsertBlockMessages.decision),
135
+ description: formatMessage(_messages.toolbarInsertBlockMessages.decisionDescription),
126
136
  priority: 900,
127
137
  keyshortcut: '<>',
128
138
  icon: function icon() {
@@ -13,19 +13,25 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
13
13
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
14
14
  var _react = _interopRequireDefault(require("react"));
15
15
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
16
- var _hooks = require("@atlaskit/editor-common/hooks");
16
+ var _useShowPlaceholder = require("./hooks/use-show-placeholder");
17
17
  var _Decision = _interopRequireDefault(require("../ui/Decision"));
18
18
  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); }; }
19
19
  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; } }
20
20
  var DecisionItemWrapper = function DecisionItemWrapper(_ref) {
21
21
  var api = _ref.api,
22
+ editorView = _ref.editorView,
22
23
  forwardRef = _ref.forwardRef,
23
- isContentNodeEmpty = _ref.isContentNodeEmpty;
24
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['typeAhead']),
25
- typeAheadState = _useSharedPluginState.typeAheadState;
24
+ isContentNodeEmpty = _ref.isContentNodeEmpty,
25
+ getPos = _ref.getPos;
26
+ var showPlaceholder = (0, _useShowPlaceholder.useShowPlaceholder)({
27
+ editorView: editorView,
28
+ isContentNodeEmpty: isContentNodeEmpty,
29
+ getPos: getPos,
30
+ api: api
31
+ });
26
32
  return /*#__PURE__*/_react.default.createElement(_Decision.default, {
27
33
  contentRef: forwardRef,
28
- showPlaceholder: isContentNodeEmpty && !(typeAheadState !== null && typeAheadState !== void 0 && typeAheadState.isOpen)
34
+ showPlaceholder: showPlaceholder
29
35
  });
30
36
  };
31
37
  var Decision = /*#__PURE__*/function (_ReactNodeView) {
@@ -73,6 +79,11 @@ var Decision = /*#__PURE__*/function (_ReactNodeView) {
73
79
  forwardRef: forwardRef,
74
80
  isContentNodeEmpty: isContentNodeEmpty,
75
81
  api: this.api
82
+ // The getPosHandler type is wrong, there is no `boolean` in the real implementation
83
+ // @ts-expect-error 2322: Type 'getPosHandler' is not assignable to type '() => number | undefined'.
84
+ ,
85
+ getPos: this.getPos,
86
+ editorView: this.view
76
87
  });
77
88
  }
78
89
  }, {
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useShowPlaceholder = void 0;
7
+ var _react = require("react");
8
+ var _state = require("@atlaskit/editor-prosemirror/state");
9
+ var _hooks = require("@atlaskit/editor-common/hooks");
10
+ var useShowPlaceholder = exports.useShowPlaceholder = function useShowPlaceholder(_ref) {
11
+ var editorView = _ref.editorView,
12
+ api = _ref.api,
13
+ isContentNodeEmpty = _ref.isContentNodeEmpty,
14
+ getPos = _ref.getPos;
15
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['typeAhead']),
16
+ typeAheadState = _useSharedPluginState.typeAheadState;
17
+ var isTypeAheadOpen = Boolean(typeAheadState === null || typeAheadState === void 0 ? void 0 : typeAheadState.isOpen);
18
+ var isTypeAheadOpenedInsideItem = (0, _react.useMemo)(function () {
19
+ var _selection$$cursor;
20
+ if (!isTypeAheadOpen) {
21
+ return false;
22
+ }
23
+ var itemPosition = getPos();
24
+ if (typeof itemPosition !== 'number') {
25
+ return false;
26
+ }
27
+ var selection = editorView.state.selection;
28
+ if (!(selection instanceof _state.TextSelection)) {
29
+ return false;
30
+ }
31
+ var maybeItemNode = editorView.state.doc.nodeAt(itemPosition);
32
+ var maybeParentItemNode = (_selection$$cursor = selection.$cursor) === null || _selection$$cursor === void 0 ? void 0 : _selection$$cursor.node();
33
+ if (maybeItemNode && maybeParentItemNode && maybeItemNode.eq(maybeParentItemNode)) {
34
+ return true;
35
+ }
36
+ return false;
37
+ }, [isTypeAheadOpen, getPos, editorView]);
38
+ var showPlaceholder = Boolean(!isTypeAheadOpenedInsideItem && isContentNodeEmpty);
39
+ return showPlaceholder;
40
+ };
@@ -16,35 +16,40 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
16
16
  var _react = _interopRequireDefault(require("react"));
17
17
  var _analyticsNext = require("@atlaskit/analytics-next");
18
18
  var _steps = require("@atlaskit/adf-schema/steps");
19
- var _hooks = require("@atlaskit/editor-common/hooks");
20
19
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
21
- var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
22
- var _pluginKey = require("../pm-plugins/plugin-key");
20
+ var _hooks = require("@atlaskit/editor-common/hooks");
21
+ var _useShowPlaceholder = require("./hooks/use-show-placeholder");
23
22
  var _Task = _interopRequireDefault(require("../ui/Task"));
24
23
  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; }
25
24
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
26
25
  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); }; }
27
26
  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; } }
28
- //import { isTypeAheadOpen } from '../../type-ahead/utils';
29
-
30
27
  var TaskItemWrapper = function TaskItemWrapper(_ref) {
31
28
  var localId = _ref.localId,
32
29
  forwardRef = _ref.forwardRef,
33
30
  isDone = _ref.isDone,
34
31
  onChange = _ref.onChange,
35
- isFocused = _ref.isFocused,
36
- isContentNodeEmpty = _ref.isContentNodeEmpty,
37
32
  providerFactory = _ref.providerFactory,
38
- api = _ref.api;
39
- var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['typeAhead']),
40
- typeAheadState = _useSharedPluginState.typeAheadState;
33
+ isContentNodeEmpty = _ref.isContentNodeEmpty,
34
+ api = _ref.api,
35
+ getPos = _ref.getPos,
36
+ editorView = _ref.editorView;
37
+ var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['taskDecision']),
38
+ taskDecisionState = _useSharedPluginState.taskDecisionState;
39
+ var isFocused = Boolean((taskDecisionState === null || taskDecisionState === void 0 ? void 0 : taskDecisionState.focusedTaskItemLocalId) === localId);
40
+ var showPlaceholder = (0, _useShowPlaceholder.useShowPlaceholder)({
41
+ editorView: editorView,
42
+ isContentNodeEmpty: isContentNodeEmpty,
43
+ getPos: getPos,
44
+ api: api
45
+ });
41
46
  return /*#__PURE__*/_react.default.createElement(_Task.default, {
42
47
  taskId: localId,
43
48
  contentRef: forwardRef,
44
49
  isDone: isDone,
45
50
  onChange: onChange,
46
51
  isFocused: isFocused,
47
- showPlaceholder: isContentNodeEmpty && !(typeAheadState !== null && typeAheadState !== void 0 && typeAheadState.isOpen),
52
+ showPlaceholder: showPlaceholder,
48
53
  providers: providerFactory
49
54
  });
50
55
  };
@@ -150,7 +155,6 @@ var Task = /*#__PURE__*/function (_ReactNodeView) {
150
155
  }, {
151
156
  key: "render",
152
157
  value: function render(props, forwardRef) {
153
- var _this2 = this;
154
158
  var _this$node$attrs = this.node.attrs,
155
159
  localId = _this$node$attrs.localId,
156
160
  state = _this$node$attrs.state;
@@ -158,23 +162,19 @@ var Task = /*#__PURE__*/function (_ReactNodeView) {
158
162
  return /*#__PURE__*/_react.default.createElement(_analyticsNext.AnalyticsListener, {
159
163
  channel: "fabric-elements",
160
164
  onEvent: this.addListAnalyticsData
161
- }, /*#__PURE__*/_react.default.createElement(_withPluginState.WithPluginState, {
162
- plugins: {
163
- taskDecisionPlugin: _pluginKey.stateKey
164
- },
165
- render: function render(_ref2) {
166
- var taskDecisionPlugin = _ref2.taskDecisionPlugin;
167
- return /*#__PURE__*/_react.default.createElement(TaskItemWrapper, {
168
- localId: localId,
169
- forwardRef: forwardRef,
170
- isDone: state === 'DONE',
171
- onChange: _this2.handleOnChange,
172
- isFocused: Boolean((taskDecisionPlugin === null || taskDecisionPlugin === void 0 ? void 0 : taskDecisionPlugin.focusedTaskItemLocalId) === localId),
173
- isContentNodeEmpty: isContentNodeEmpty,
174
- providerFactory: props.providerFactory,
175
- api: _this2.api
176
- });
177
- }
165
+ }, /*#__PURE__*/_react.default.createElement(TaskItemWrapper, {
166
+ localId: localId,
167
+ forwardRef: forwardRef,
168
+ isDone: state === 'DONE',
169
+ onChange: this.handleOnChange,
170
+ isContentNodeEmpty: isContentNodeEmpty,
171
+ providerFactory: props.providerFactory
172
+ // The getPosHandler type is wrong, there is no `boolean` in the real implementation
173
+ // @ts-expect-error 2322: Type 'getPosHandler' is not assignable to type '() => number | undefined'.
174
+ ,
175
+ getPos: this.getPos,
176
+ editorView: this.view,
177
+ api: this.api
178
178
  }));
179
179
  }
180
180
  }, {
@@ -190,11 +190,11 @@ var Task = /*#__PURE__*/function (_ReactNodeView) {
190
190
  }, {
191
191
  key: "update",
192
192
  value: function update(node, decorations) {
193
- var _this3 = this;
193
+ var _this2 = this;
194
194
  return (0, _get2.default)((0, _getPrototypeOf2.default)(Task.prototype), "update", this).call(this, node, decorations, undefined, function (currentNode, newNode) {
195
195
  return (
196
196
  // Toggle the placeholder based on whether user input exists
197
- !_this3.isContentEmpty(newNode) && !!(currentNode.attrs.state === newNode.attrs.state)
197
+ !_this2.isContentEmpty(newNode) && !!(currentNode.attrs.state === newNode.attrs.state)
198
198
  );
199
199
  });
200
200
  }
@@ -8,6 +8,7 @@ exports.default = createUniversalPreset;
8
8
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _plugins = require("../plugins");
11
+ var _editorPluginTextColor = require("@atlaskit/editor-plugin-text-color");
11
12
  var _editorPluginHistory = require("@atlaskit/editor-plugin-history");
12
13
  var _editorPluginStatus = require("@atlaskit/editor-plugin-status");
13
14
  var _editorPluginDate = require("@atlaskit/editor-plugin-date");
@@ -78,7 +79,7 @@ function createUniversalPreset(appearance, props, featureFlags, prevAppearance,
78
79
  return builder.add(plugin);
79
80
  }
80
81
  return builder;
81
- }).maybeAdd(_plugins.textColorPlugin, function (plugin, builder) {
82
+ }).maybeAdd(_editorPluginTextColor.textColorPlugin, function (plugin, builder) {
82
83
  if (props.allowTextColor) {
83
84
  return builder.add([plugin, props.allowTextColor]);
84
85
  }
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/editor-core";
8
- var version = exports.version = "189.0.9";
8
+ var version = exports.version = "189.0.11";
9
9
  var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
10
10
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
11
11
  };
@@ -13,7 +13,6 @@ export { default as panelPlugin } from './panel';
13
13
  export { default as pastePlugin } from './paste';
14
14
  export { placeholderTextPlugin } from './placeholder-text';
15
15
  export { default as tasksAndDecisionsPlugin } from './tasks-and-decisions';
16
- export { default as textColorPlugin } from './text-color';
17
16
  export { default as breakoutPlugin } from './breakout';
18
17
  export { default as alignmentPlugin } from './alignment';
19
18
  export { default as dataConsumerMarkPlugin } from './data-consumer';
@@ -2,8 +2,9 @@
2
2
  import { css, jsx } from '@emotion/react';
3
3
  import { decisionItem, decisionList, taskItem, taskList } from '@atlaskit/adf-schema';
4
4
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
5
- import { messages as insertBlockMessages } from '../insert-block/ui/ToolbarInsertBlock/messages';
5
+ import { toolbarInsertBlockMessages as insertBlockMessages } from '@atlaskit/editor-common/messages';
6
6
  import { IconAction, IconDecision } from '@atlaskit/editor-common/quick-insert';
7
+ import { stateKey as taskPluginKey } from './pm-plugins/plugin-key';
7
8
  import { insertTaskDecisionAction, getListTypes } from './commands';
8
9
  import inputRulePlugin from './pm-plugins/input-rules';
9
10
  import keymap from './pm-plugins/keymaps';
@@ -51,6 +52,15 @@ const tasksAndDecisionsPlugin = ({
51
52
  node: taskItem
52
53
  }];
53
54
  },
55
+ getSharedState(editorState) {
56
+ if (!editorState) {
57
+ return undefined;
58
+ }
59
+ const pluginState = taskPluginKey.getState(editorState);
60
+ return {
61
+ focusedTaskItemLocalId: (pluginState === null || pluginState === void 0 ? void 0 : pluginState.focusedTaskItemLocalId) || null
62
+ };
63
+ },
54
64
  pmPlugins() {
55
65
  return [{
56
66
  name: 'tasksAndDecisions',
@@ -1,18 +1,23 @@
1
1
  import React from 'react';
2
2
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
3
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
3
+ import { useShowPlaceholder } from './hooks/use-show-placeholder';
4
4
  import DecisionItem from '../ui/Decision';
5
5
  const DecisionItemWrapper = ({
6
6
  api,
7
+ editorView,
7
8
  forwardRef,
8
- isContentNodeEmpty
9
+ isContentNodeEmpty,
10
+ getPos
9
11
  }) => {
10
- const {
11
- typeAheadState
12
- } = useSharedPluginState(api, ['typeAhead']);
12
+ const showPlaceholder = useShowPlaceholder({
13
+ editorView,
14
+ isContentNodeEmpty,
15
+ getPos,
16
+ api
17
+ });
13
18
  return /*#__PURE__*/React.createElement(DecisionItem, {
14
19
  contentRef: forwardRef,
15
- showPlaceholder: isContentNodeEmpty && !(typeAheadState !== null && typeAheadState !== void 0 && typeAheadState.isOpen)
20
+ showPlaceholder: showPlaceholder
16
21
  });
17
22
  };
18
23
  class Decision extends ReactNodeView {
@@ -44,6 +49,11 @@ class Decision extends ReactNodeView {
44
49
  forwardRef: forwardRef,
45
50
  isContentNodeEmpty: isContentNodeEmpty,
46
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
47
57
  });
48
58
  }
49
59
  viewShouldUpdate(nextNode) {
@@ -0,0 +1,36 @@
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
+ };
@@ -2,34 +2,38 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React from 'react';
3
3
  import { AnalyticsListener } from '@atlaskit/analytics-next';
4
4
  import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
5
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
6
5
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
7
- import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
8
- import { stateKey as taskPluginKey } from '../pm-plugins/plugin-key';
6
+ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
7
+ import { useShowPlaceholder } from './hooks/use-show-placeholder';
9
8
  import TaskItem from '../ui/Task';
10
-
11
- //import { isTypeAheadOpen } from '../../type-ahead/utils';
12
-
13
9
  const TaskItemWrapper = ({
14
10
  localId,
15
11
  forwardRef,
16
12
  isDone,
17
13
  onChange,
18
- isFocused,
19
- isContentNodeEmpty,
20
14
  providerFactory,
21
- api
15
+ isContentNodeEmpty,
16
+ api,
17
+ getPos,
18
+ editorView
22
19
  }) => {
23
20
  const {
24
- typeAheadState
25
- } = useSharedPluginState(api, ['typeAhead']);
21
+ taskDecisionState
22
+ } = useSharedPluginState(api, ['taskDecision']);
23
+ const isFocused = Boolean((taskDecisionState === null || taskDecisionState === void 0 ? void 0 : taskDecisionState.focusedTaskItemLocalId) === localId);
24
+ const showPlaceholder = useShowPlaceholder({
25
+ editorView,
26
+ isContentNodeEmpty,
27
+ getPos,
28
+ api
29
+ });
26
30
  return /*#__PURE__*/React.createElement(TaskItem, {
27
31
  taskId: localId,
28
32
  contentRef: forwardRef,
29
33
  isDone: isDone,
30
34
  onChange: onChange,
31
35
  isFocused: isFocused,
32
- showPlaceholder: isContentNodeEmpty && !(typeAheadState !== null && typeAheadState !== void 0 && typeAheadState.isOpen),
36
+ showPlaceholder: showPlaceholder,
33
37
  providers: providerFactory
34
38
  });
35
39
  };
@@ -130,24 +134,19 @@ class Task extends ReactNodeView {
130
134
  return /*#__PURE__*/React.createElement(AnalyticsListener, {
131
135
  channel: "fabric-elements",
132
136
  onEvent: this.addListAnalyticsData
133
- }, /*#__PURE__*/React.createElement(WithPluginState, {
134
- plugins: {
135
- taskDecisionPlugin: taskPluginKey
136
- },
137
- render: ({
138
- taskDecisionPlugin
139
- }) => {
140
- return /*#__PURE__*/React.createElement(TaskItemWrapper, {
141
- localId: localId,
142
- forwardRef: forwardRef,
143
- isDone: state === 'DONE',
144
- onChange: this.handleOnChange,
145
- isFocused: Boolean((taskDecisionPlugin === null || taskDecisionPlugin === void 0 ? void 0 : taskDecisionPlugin.focusedTaskItemLocalId) === localId),
146
- isContentNodeEmpty: isContentNodeEmpty,
147
- providerFactory: props.providerFactory,
148
- api: this.api
149
- });
150
- }
137
+ }, /*#__PURE__*/React.createElement(TaskItemWrapper, {
138
+ localId: localId,
139
+ forwardRef: forwardRef,
140
+ isDone: state === 'DONE',
141
+ onChange: this.handleOnChange,
142
+ isContentNodeEmpty: isContentNodeEmpty,
143
+ providerFactory: props.providerFactory
144
+ // The getPosHandler type is wrong, there is no `boolean` in the real implementation
145
+ // @ts-expect-error 2322: Type 'getPosHandler' is not assignable to type '() => number | undefined'.
146
+ ,
147
+ getPos: this.getPos,
148
+ editorView: this.view,
149
+ api: this.api
151
150
  }));
152
151
  }
153
152
  viewShouldUpdate(nextNode) {
@@ -1,4 +1,5 @@
1
- import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, extensionPlugin, fragmentMarkPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, panelPlugin, placeholderTextPlugin, tasksAndDecisionsPlugin, textColorPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, expandPlugin, isExpandInsertionEnabled, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin } from '../plugins';
1
+ import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, extensionPlugin, fragmentMarkPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, toolbarListsIndentationPlugin, macroPlugin, maxContentSizePlugin, panelPlugin, placeholderTextPlugin, tasksAndDecisionsPlugin, alignmentPlugin, indentationPlugin, customAutoformatPlugin, feedbackDialogPlugin, expandPlugin, isExpandInsertionEnabled, mobileDimensionsPlugin, findReplacePlugin, mobileSelectionPlugin, annotationPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, beforePrimaryToolbarPlugin, codeBidiWarningPlugin } from '../plugins';
2
+ import { textColorPlugin } from '@atlaskit/editor-plugin-text-color';
2
3
  import { historyPlugin } from '@atlaskit/editor-plugin-history';
3
4
  import { statusPlugin } from '@atlaskit/editor-plugin-status';
4
5
  import { datePlugin } from '@atlaskit/editor-plugin-date';
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "189.0.9";
2
+ export const version = "189.0.11";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -13,7 +13,6 @@ export { default as panelPlugin } from './panel';
13
13
  export { default as pastePlugin } from './paste';
14
14
  export { placeholderTextPlugin } from './placeholder-text';
15
15
  export { default as tasksAndDecisionsPlugin } from './tasks-and-decisions';
16
- export { default as textColorPlugin } from './text-color';
17
16
  export { default as breakoutPlugin } from './breakout';
18
17
  export { default as alignmentPlugin } from './alignment';
19
18
  export { default as dataConsumerMarkPlugin } from './data-consumer';
@@ -4,8 +4,9 @@ var _templateObject;
4
4
  import { css, jsx } from '@emotion/react';
5
5
  import { decisionItem, decisionList, taskItem, taskList } from '@atlaskit/adf-schema';
6
6
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
7
- import { messages as insertBlockMessages } from '../insert-block/ui/ToolbarInsertBlock/messages';
7
+ import { toolbarInsertBlockMessages as insertBlockMessages } from '@atlaskit/editor-common/messages';
8
8
  import { IconAction, IconDecision } from '@atlaskit/editor-common/quick-insert';
9
+ import { stateKey as taskPluginKey } from './pm-plugins/plugin-key';
9
10
  import { insertTaskDecisionAction, getListTypes } from './commands';
10
11
  import inputRulePlugin from './pm-plugins/input-rules';
11
12
  import keymap from './pm-plugins/keymaps';
@@ -51,6 +52,15 @@ var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
51
52
  node: taskItem
52
53
  }];
53
54
  },
55
+ getSharedState: function getSharedState(editorState) {
56
+ if (!editorState) {
57
+ return undefined;
58
+ }
59
+ var pluginState = taskPluginKey.getState(editorState);
60
+ return {
61
+ focusedTaskItemLocalId: (pluginState === null || pluginState === void 0 ? void 0 : pluginState.focusedTaskItemLocalId) || null
62
+ };
63
+ },
54
64
  pmPlugins: function pmPlugins() {
55
65
  return [{
56
66
  name: 'tasksAndDecisions',
@@ -8,17 +8,23 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
8
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
9
  import React from 'react';
10
10
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
11
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
11
+ import { useShowPlaceholder } from './hooks/use-show-placeholder';
12
12
  import DecisionItem from '../ui/Decision';
13
13
  var DecisionItemWrapper = function DecisionItemWrapper(_ref) {
14
14
  var api = _ref.api,
15
+ editorView = _ref.editorView,
15
16
  forwardRef = _ref.forwardRef,
16
- isContentNodeEmpty = _ref.isContentNodeEmpty;
17
- var _useSharedPluginState = useSharedPluginState(api, ['typeAhead']),
18
- typeAheadState = _useSharedPluginState.typeAheadState;
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
+ });
19
25
  return /*#__PURE__*/React.createElement(DecisionItem, {
20
26
  contentRef: forwardRef,
21
- showPlaceholder: isContentNodeEmpty && !(typeAheadState !== null && typeAheadState !== void 0 && typeAheadState.isOpen)
27
+ showPlaceholder: showPlaceholder
22
28
  });
23
29
  };
24
30
  var Decision = /*#__PURE__*/function (_ReactNodeView) {
@@ -66,6 +72,11 @@ var Decision = /*#__PURE__*/function (_ReactNodeView) {
66
72
  forwardRef: forwardRef,
67
73
  isContentNodeEmpty: isContentNodeEmpty,
68
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
69
80
  });
70
81
  }
71
82
  }, {