@atlaskit/editor-plugin-tasks-and-decisions 9.0.5 → 9.0.7

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-tasks-and-decisions
2
2
 
3
+ ## 9.0.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 9.0.6
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 9.0.5
4
16
 
5
17
  ### Patch Changes
@@ -22,6 +22,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
22
22
  var _state = require("@atlaskit/editor-prosemirror/state");
23
23
  var _transform = require("@atlaskit/editor-prosemirror/transform");
24
24
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
25
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
25
26
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
26
27
  var _pluginKey = require("./plugin-key");
27
28
  var _types = require("./types");
@@ -265,14 +266,30 @@ var subtreeHeight = exports.subtreeHeight = function subtreeHeight($from, $to, t
265
266
  };
266
267
 
267
268
  /**
268
- * Returns `true` if the taskItem or decisionItem has no text.
269
+ * Determines if the current selection is inside an empty taskItem, decisionItem, or blockTaskItem.
270
+ *
271
+ * @param state - The current EditorState.
272
+ * @returns `true` if the taskItem, decisionItem, or blockTaskItem is empty; otherwise, `false`.
269
273
  */
270
274
  var isEmptyTaskDecision = exports.isEmptyTaskDecision = function isEmptyTaskDecision(state) {
271
275
  var selection = state.selection,
272
276
  schema = state.schema;
277
+ var _schema$nodes = schema.nodes,
278
+ paragraph = _schema$nodes.paragraph,
279
+ blockTaskItem = _schema$nodes.blockTaskItem,
280
+ decisionItem = _schema$nodes.decisionItem,
281
+ taskItem = _schema$nodes.taskItem;
273
282
  var $from = selection.$from;
274
283
  var node = $from.node($from.depth);
275
- return node && (node.type === schema.nodes.taskItem || node.type === schema.nodes.decisionItem) && node.content.size === 0;
284
+ var isEmptyTaskOrDecisionItem = node && (node.type === taskItem || node.type === decisionItem) && node.content.size === 0;
285
+
286
+ // Block task items must contain a single empty paragraph to be considered empty
287
+ var isInEmptyBlockTaskItem =
288
+ // If in an empty paragraph that's not at the doc level
289
+ node.content.size === 0 && node.type === paragraph && $from.depth > 0 &&
290
+ // and it's parent is a blockTaskItem with only this paragraph inside it
291
+ $from.node($from.depth - 1).type === blockTaskItem && $from.node($from.depth - 1).childCount === 1 && (0, _platformFeatureFlags.fg)('platform_editor_blocktaskitem_patch_3');
292
+ return isEmptyTaskOrDecisionItem || isInEmptyBlockTaskItem;
276
293
  };
277
294
 
278
295
  /**
@@ -305,9 +322,9 @@ function getTaskItemDataAtPos(view) {
305
322
  schema = state.schema;
306
323
  var $from = selection.$from;
307
324
  if ((0, _expValEquals.expValEquals)('platform_editor_blocktaskitem_patch_1', 'isEnabled', true)) {
308
- var _schema$nodes = schema.nodes,
309
- taskItem = _schema$nodes.taskItem,
310
- blockTaskItem = _schema$nodes.blockTaskItem;
325
+ var _schema$nodes2 = schema.nodes,
326
+ taskItem = _schema$nodes2.taskItem,
327
+ blockTaskItem = _schema$nodes2.blockTaskItem;
311
328
  var maybeTask = (0, _utils2.findParentNodeOfTypeClosestToPos)($from, [taskItem, blockTaskItem]);
312
329
 
313
330
  // current selection has to be inside taskitem
@@ -339,10 +356,10 @@ function getAllTaskItemsDataInRootTaskList(view) {
339
356
  if (!isInTaskItem) {
340
357
  return;
341
358
  }
342
- var _schema$nodes2 = schema.nodes,
343
- taskList = _schema$nodes2.taskList,
344
- taskItem = _schema$nodes2.taskItem,
345
- blockTaskItem = _schema$nodes2.blockTaskItem;
359
+ var _schema$nodes3 = schema.nodes,
360
+ taskList = _schema$nodes3.taskList,
361
+ taskItem = _schema$nodes3.taskItem,
362
+ blockTaskItem = _schema$nodes3.blockTaskItem;
346
363
  var rootTaskListData = (0, _utils.findFarthestParentNode)(function (node) {
347
364
  return node.type === taskList;
348
365
  })($fromPos);
@@ -366,9 +383,9 @@ function getCurrentTaskItemIndex(view, allTaskItems) {
366
383
  var _findParentNodeOfType;
367
384
  var state = view.state;
368
385
  var schema = state.schema;
369
- var _schema$nodes3 = schema.nodes,
370
- taskItem = _schema$nodes3.taskItem,
371
- blockTaskItem = _schema$nodes3.blockTaskItem;
386
+ var _schema$nodes4 = schema.nodes,
387
+ taskItem = _schema$nodes4.taskItem,
388
+ blockTaskItem = _schema$nodes4.blockTaskItem;
372
389
  var $fromPos = state.selection.$from;
373
390
  var allTaskItemNodes = allTaskItems.map(function (nodeData) {
374
391
  return nodeData.node;
@@ -548,10 +548,26 @@ var creatParentListItemFragement = function creatParentListItemFragement(state)
548
548
  var splitListItem = function splitListItem(state, dispatch) {
549
549
  var tr = state.tr,
550
550
  $from = state.selection.$from;
551
- var paragraph = state.schema.nodes.paragraph;
552
- var listItem = state.schema.nodes.listItem;
551
+ var _state$schema$nodes5 = state.schema.nodes,
552
+ listItem = _state$schema$nodes5.listItem,
553
+ blockTaskItem = _state$schema$nodes5.blockTaskItem,
554
+ taskItem = _state$schema$nodes5.taskItem,
555
+ paragraph = _state$schema$nodes5.paragraph;
553
556
  if (actionDecisionFollowsOrNothing($from)) {
554
557
  if (dispatch) {
558
+ if ((0, _platformFeatureFlags.fg)('platform_editor_blocktaskitem_patch_3')) {
559
+ // If previous node is a blockTaskItem we just want to delete the existing node and replace it with a paragraph
560
+ var nodeBefore = state.doc.resolve($from.pos - 1).nodeBefore;
561
+ if (blockTaskItem && (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type) === blockTaskItem) {
562
+ if ($from.parent.type === taskItem) {
563
+ var nodeSize = $from.parent.nodeSize;
564
+ tr.delete($from.pos - Math.floor(nodeSize / 2), $from.pos + Math.ceil(nodeSize / 2));
565
+ tr.insert($from.pos, paragraph.createChecked());
566
+ dispatch(tr);
567
+ return true;
568
+ }
569
+ }
570
+ }
555
571
  if ((0, _utils2.hasParentNodeOfType)(listItem)(tr.selection)) {
556
572
  // if we're inside a list item, then we pass in a fragment containing a new list item not a paragraph
557
573
  dispatch(splitListItemWith(tr, creatParentListItemFragement(state), $from, true));
@@ -4,6 +4,7 @@ import { NodeRange } from '@atlaskit/editor-prosemirror/model';
4
4
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
6
6
  import { findParentNodeClosestToPos, findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
9
  import { stateKey } from './plugin-key';
9
10
  import { ACTIONS } from './types';
@@ -253,18 +254,35 @@ export const subtreeHeight = ($from, $to, types) => {
253
254
  };
254
255
 
255
256
  /**
256
- * Returns `true` if the taskItem or decisionItem has no text.
257
+ * Determines if the current selection is inside an empty taskItem, decisionItem, or blockTaskItem.
258
+ *
259
+ * @param state - The current EditorState.
260
+ * @returns `true` if the taskItem, decisionItem, or blockTaskItem is empty; otherwise, `false`.
257
261
  */
258
262
  export const isEmptyTaskDecision = state => {
259
263
  const {
260
264
  selection,
261
265
  schema
262
266
  } = state;
267
+ const {
268
+ paragraph,
269
+ blockTaskItem,
270
+ decisionItem,
271
+ taskItem
272
+ } = schema.nodes;
263
273
  const {
264
274
  $from
265
275
  } = selection;
266
276
  const node = $from.node($from.depth);
267
- return node && (node.type === schema.nodes.taskItem || node.type === schema.nodes.decisionItem) && node.content.size === 0;
277
+ const isEmptyTaskOrDecisionItem = node && (node.type === taskItem || node.type === decisionItem) && node.content.size === 0;
278
+
279
+ // Block task items must contain a single empty paragraph to be considered empty
280
+ const isInEmptyBlockTaskItem =
281
+ // If in an empty paragraph that's not at the doc level
282
+ node.content.size === 0 && node.type === paragraph && $from.depth > 0 &&
283
+ // and it's parent is a blockTaskItem with only this paragraph inside it
284
+ $from.node($from.depth - 1).type === blockTaskItem && $from.node($from.depth - 1).childCount === 1 && fg('platform_editor_blocktaskitem_patch_3');
285
+ return isEmptyTaskOrDecisionItem || isInEmptyBlockTaskItem;
268
286
  };
269
287
 
270
288
  /**
@@ -533,17 +533,26 @@ const splitListItem = (state, dispatch) => {
533
533
  }
534
534
  } = state;
535
535
  const {
536
- schema: {
537
- nodes: {
538
- paragraph
539
- }
540
- }
541
- } = state;
542
- const {
543
- listItem
536
+ listItem,
537
+ blockTaskItem,
538
+ taskItem,
539
+ paragraph
544
540
  } = state.schema.nodes;
545
541
  if (actionDecisionFollowsOrNothing($from)) {
546
542
  if (dispatch) {
543
+ if (fg('platform_editor_blocktaskitem_patch_3')) {
544
+ // If previous node is a blockTaskItem we just want to delete the existing node and replace it with a paragraph
545
+ const nodeBefore = state.doc.resolve($from.pos - 1).nodeBefore;
546
+ if (blockTaskItem && (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type) === blockTaskItem) {
547
+ if ($from.parent.type === taskItem) {
548
+ const nodeSize = $from.parent.nodeSize;
549
+ tr.delete($from.pos - Math.floor(nodeSize / 2), $from.pos + Math.ceil(nodeSize / 2));
550
+ tr.insert($from.pos, paragraph.createChecked());
551
+ dispatch(tr);
552
+ return true;
553
+ }
554
+ }
555
+ }
547
556
  if (hasParentNodeOfType(listItem)(tr.selection)) {
548
557
  // if we're inside a list item, then we pass in a fragment containing a new list item not a paragraph
549
558
  dispatch(splitListItemWith(tr, creatParentListItemFragement(state), $from, true));
@@ -4,6 +4,7 @@ import { NodeRange } from '@atlaskit/editor-prosemirror/model';
4
4
  import { TextSelection } from '@atlaskit/editor-prosemirror/state';
5
5
  import { liftTarget } from '@atlaskit/editor-prosemirror/transform';
6
6
  import { findParentNodeClosestToPos, findParentNodeOfTypeClosestToPos, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
+ import { fg } from '@atlaskit/platform-feature-flags';
7
8
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
9
  import { stateKey } from './plugin-key';
9
10
  import { ACTIONS } from './types';
@@ -247,14 +248,30 @@ export var subtreeHeight = function subtreeHeight($from, $to, types) {
247
248
  };
248
249
 
249
250
  /**
250
- * Returns `true` if the taskItem or decisionItem has no text.
251
+ * Determines if the current selection is inside an empty taskItem, decisionItem, or blockTaskItem.
252
+ *
253
+ * @param state - The current EditorState.
254
+ * @returns `true` if the taskItem, decisionItem, or blockTaskItem is empty; otherwise, `false`.
251
255
  */
252
256
  export var isEmptyTaskDecision = function isEmptyTaskDecision(state) {
253
257
  var selection = state.selection,
254
258
  schema = state.schema;
259
+ var _schema$nodes = schema.nodes,
260
+ paragraph = _schema$nodes.paragraph,
261
+ blockTaskItem = _schema$nodes.blockTaskItem,
262
+ decisionItem = _schema$nodes.decisionItem,
263
+ taskItem = _schema$nodes.taskItem;
255
264
  var $from = selection.$from;
256
265
  var node = $from.node($from.depth);
257
- return node && (node.type === schema.nodes.taskItem || node.type === schema.nodes.decisionItem) && node.content.size === 0;
266
+ var isEmptyTaskOrDecisionItem = node && (node.type === taskItem || node.type === decisionItem) && node.content.size === 0;
267
+
268
+ // Block task items must contain a single empty paragraph to be considered empty
269
+ var isInEmptyBlockTaskItem =
270
+ // If in an empty paragraph that's not at the doc level
271
+ node.content.size === 0 && node.type === paragraph && $from.depth > 0 &&
272
+ // and it's parent is a blockTaskItem with only this paragraph inside it
273
+ $from.node($from.depth - 1).type === blockTaskItem && $from.node($from.depth - 1).childCount === 1 && fg('platform_editor_blocktaskitem_patch_3');
274
+ return isEmptyTaskOrDecisionItem || isInEmptyBlockTaskItem;
258
275
  };
259
276
 
260
277
  /**
@@ -287,9 +304,9 @@ export function getTaskItemDataAtPos(view) {
287
304
  schema = state.schema;
288
305
  var $from = selection.$from;
289
306
  if (expValEquals('platform_editor_blocktaskitem_patch_1', 'isEnabled', true)) {
290
- var _schema$nodes = schema.nodes,
291
- taskItem = _schema$nodes.taskItem,
292
- blockTaskItem = _schema$nodes.blockTaskItem;
307
+ var _schema$nodes2 = schema.nodes,
308
+ taskItem = _schema$nodes2.taskItem,
309
+ blockTaskItem = _schema$nodes2.blockTaskItem;
293
310
  var maybeTask = findParentNodeOfTypeClosestToPos($from, [taskItem, blockTaskItem]);
294
311
 
295
312
  // current selection has to be inside taskitem
@@ -321,10 +338,10 @@ export function getAllTaskItemsDataInRootTaskList(view) {
321
338
  if (!isInTaskItem) {
322
339
  return;
323
340
  }
324
- var _schema$nodes2 = schema.nodes,
325
- taskList = _schema$nodes2.taskList,
326
- taskItem = _schema$nodes2.taskItem,
327
- blockTaskItem = _schema$nodes2.blockTaskItem;
341
+ var _schema$nodes3 = schema.nodes,
342
+ taskList = _schema$nodes3.taskList,
343
+ taskItem = _schema$nodes3.taskItem,
344
+ blockTaskItem = _schema$nodes3.blockTaskItem;
328
345
  var rootTaskListData = findFarthestParentNode(function (node) {
329
346
  return node.type === taskList;
330
347
  })($fromPos);
@@ -348,9 +365,9 @@ export function getCurrentTaskItemIndex(view, allTaskItems) {
348
365
  var _findParentNodeOfType;
349
366
  var state = view.state;
350
367
  var schema = state.schema;
351
- var _schema$nodes3 = schema.nodes,
352
- taskItem = _schema$nodes3.taskItem,
353
- blockTaskItem = _schema$nodes3.blockTaskItem;
368
+ var _schema$nodes4 = schema.nodes,
369
+ taskItem = _schema$nodes4.taskItem,
370
+ blockTaskItem = _schema$nodes4.blockTaskItem;
354
371
  var $fromPos = state.selection.$from;
355
372
  var allTaskItemNodes = allTaskItems.map(function (nodeData) {
356
373
  return nodeData.node;
@@ -540,10 +540,26 @@ var creatParentListItemFragement = function creatParentListItemFragement(state)
540
540
  var splitListItem = function splitListItem(state, dispatch) {
541
541
  var tr = state.tr,
542
542
  $from = state.selection.$from;
543
- var paragraph = state.schema.nodes.paragraph;
544
- var listItem = state.schema.nodes.listItem;
543
+ var _state$schema$nodes5 = state.schema.nodes,
544
+ listItem = _state$schema$nodes5.listItem,
545
+ blockTaskItem = _state$schema$nodes5.blockTaskItem,
546
+ taskItem = _state$schema$nodes5.taskItem,
547
+ paragraph = _state$schema$nodes5.paragraph;
545
548
  if (actionDecisionFollowsOrNothing($from)) {
546
549
  if (dispatch) {
550
+ if (fg('platform_editor_blocktaskitem_patch_3')) {
551
+ // If previous node is a blockTaskItem we just want to delete the existing node and replace it with a paragraph
552
+ var nodeBefore = state.doc.resolve($from.pos - 1).nodeBefore;
553
+ if (blockTaskItem && (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type) === blockTaskItem) {
554
+ if ($from.parent.type === taskItem) {
555
+ var nodeSize = $from.parent.nodeSize;
556
+ tr.delete($from.pos - Math.floor(nodeSize / 2), $from.pos + Math.ceil(nodeSize / 2));
557
+ tr.insert($from.pos, paragraph.createChecked());
558
+ dispatch(tr);
559
+ return true;
560
+ }
561
+ }
562
+ }
547
563
  if (hasParentNodeOfType(listItem)(tr.selection)) {
548
564
  // if we're inside a list item, then we pass in a fragment containing a new list item not a paragraph
549
565
  dispatch(splitListItemWith(tr, creatParentListItemFragement(state), $from, true));
@@ -56,7 +56,10 @@ export declare const walkOut: ($startPos: ResolvedPos) => ResolvedPos;
56
56
  */
57
57
  export declare const subtreeHeight: ($from: ResolvedPos, $to: ResolvedPos, types: NodeType[]) => number;
58
58
  /**
59
- * Returns `true` if the taskItem or decisionItem has no text.
59
+ * Determines if the current selection is inside an empty taskItem, decisionItem, or blockTaskItem.
60
+ *
61
+ * @param state - The current EditorState.
62
+ * @returns `true` if the taskItem, decisionItem, or blockTaskItem is empty; otherwise, `false`.
60
63
  */
61
64
  export declare const isEmptyTaskDecision: (state: EditorState) => boolean;
62
65
  /**
@@ -56,7 +56,10 @@ export declare const walkOut: ($startPos: ResolvedPos) => ResolvedPos;
56
56
  */
57
57
  export declare const subtreeHeight: ($from: ResolvedPos, $to: ResolvedPos, types: NodeType[]) => number;
58
58
  /**
59
- * Returns `true` if the taskItem or decisionItem has no text.
59
+ * Determines if the current selection is inside an empty taskItem, decisionItem, or blockTaskItem.
60
+ *
61
+ * @param state - The current EditorState.
62
+ * @returns `true` if the taskItem, decisionItem, or blockTaskItem is empty; otherwise, `false`.
60
63
  */
61
64
  export declare const isEmptyTaskDecision: (state: EditorState) => boolean;
62
65
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-tasks-and-decisions",
3
- "version": "9.0.5",
3
+ "version": "9.0.7",
4
4
  "description": "Tasks and decisions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -38,20 +38,20 @@
38
38
  "@atlaskit/editor-plugin-context-identifier": "^6.0.0",
39
39
  "@atlaskit/editor-plugin-editor-viewmode": "^8.0.0",
40
40
  "@atlaskit/editor-plugin-selection": "^6.0.0",
41
- "@atlaskit/editor-plugin-toolbar": "^3.0.0",
42
- "@atlaskit/editor-plugin-type-ahead": "^6.1.0",
41
+ "@atlaskit/editor-plugin-toolbar": "^3.1.0",
42
+ "@atlaskit/editor-plugin-type-ahead": "^6.2.0",
43
43
  "@atlaskit/editor-prosemirror": "7.0.0",
44
44
  "@atlaskit/editor-shared-styles": "^3.6.0",
45
- "@atlaskit/editor-toolbar": "^0.11.0",
45
+ "@atlaskit/editor-toolbar": "^0.13.0",
46
46
  "@atlaskit/editor-toolbar-model": "^0.2.0",
47
47
  "@atlaskit/heading": "^5.2.0",
48
- "@atlaskit/icon": "^28.3.0",
48
+ "@atlaskit/icon": "^28.4.0",
49
49
  "@atlaskit/platform-feature-flags": "^1.1.0",
50
50
  "@atlaskit/popup": "^4.4.0",
51
51
  "@atlaskit/primitives": "^14.15.0",
52
52
  "@atlaskit/prosemirror-input-rules": "^3.4.0",
53
53
  "@atlaskit/task-decision": "^19.2.0",
54
- "@atlaskit/tmp-editor-statsig": "^13.0.0",
54
+ "@atlaskit/tmp-editor-statsig": "^13.2.0",
55
55
  "@atlaskit/tokens": "^6.4.0",
56
56
  "@babel/runtime": "^7.0.0",
57
57
  "@compiled/react": "^0.18.3",