@atlaskit/editor-plugin-tasks-and-decisions 21.0.11 → 22.0.1
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 +28 -0
- package/dist/cjs/pm-plugins/commands.js +1 -74
- package/dist/cjs/pm-plugins/helpers.js +1 -51
- package/dist/cjs/pm-plugins/keymaps.js +25 -39
- package/dist/cjs/pm-plugins/main.js +0 -20
- package/dist/cjs/pm-plugins/task-list-indentation.js +3 -34
- package/dist/cjs/tasksAndDecisionsPlugin.js +44 -51
- package/dist/es2019/pm-plugins/commands.js +2 -80
- package/dist/es2019/pm-plugins/helpers.js +0 -48
- package/dist/es2019/pm-plugins/keymaps.js +28 -42
- package/dist/es2019/pm-plugins/main.js +0 -18
- package/dist/es2019/pm-plugins/task-list-indentation.js +3 -32
- package/dist/es2019/tasksAndDecisionsPlugin.js +45 -52
- package/dist/esm/pm-plugins/commands.js +2 -74
- package/dist/esm/pm-plugins/helpers.js +0 -50
- package/dist/esm/pm-plugins/keymaps.js +26 -40
- package/dist/esm/pm-plugins/main.js +0 -20
- package/dist/esm/pm-plugins/task-list-indentation.js +3 -35
- package/dist/esm/tasksAndDecisionsPlugin.js +45 -52
- package/dist/types/pm-plugins/commands.d.ts +0 -19
- package/dist/types/pm-plugins/helpers.d.ts +1 -14
- package/package.json +12 -15
- package/dist/cjs/pm-plugins/transforms.js +0 -150
- package/dist/es2019/pm-plugins/transforms.js +0 -104
- package/dist/esm/pm-plugins/transforms.js +0 -143
- package/dist/types/pm-plugins/transforms.d.ts +0 -10
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
4
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
5
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
6
|
-
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
7
|
-
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
8
|
-
function getAffectedTaskListsFromTransactions(transactions, doc, schema) {
|
|
9
|
-
var taskList = schema.nodes.taskList;
|
|
10
|
-
if (!taskList) {
|
|
11
|
-
return new Map();
|
|
12
|
-
}
|
|
13
|
-
var result = new Map();
|
|
14
|
-
var _iterator = _createForOfIteratorHelper(transactions),
|
|
15
|
-
_step;
|
|
16
|
-
try {
|
|
17
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
18
|
-
var tr = _step.value;
|
|
19
|
-
var _iterator2 = _createForOfIteratorHelper(tr.steps),
|
|
20
|
-
_step2;
|
|
21
|
-
try {
|
|
22
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
23
|
-
var step = _step2.value;
|
|
24
|
-
// ReplaceStep and ReplaceAroundStep both have from/to — other step types are skipped.
|
|
25
|
-
if (!(step instanceof ReplaceStep) && !(step instanceof ReplaceAroundStep)) {
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
// Check both the start and end of each changed range, mapped to post-transaction positions.
|
|
29
|
-
for (var _i = 0, _arr = [step.from, step.to]; _i < _arr.length; _i++) {
|
|
30
|
-
var rawPos = _arr[_i];
|
|
31
|
-
var mappedPos = Math.min(tr.mapping.map(rawPos), doc.content.size - 1);
|
|
32
|
-
var $pos = doc.resolve(mappedPos);
|
|
33
|
-
// Walk ancestors from inner to outer, recording the outermost taskList node.
|
|
34
|
-
// Once we find a taskList and then exit list structure (hit a non-taskList ancestor),
|
|
35
|
-
// break early — prevents container nodes (e.g. panel) from causing us to
|
|
36
|
-
// return an outer taskList in a different structural context.
|
|
37
|
-
var rootTaskListPos = null;
|
|
38
|
-
var rootTaskListNode = null;
|
|
39
|
-
for (var depth = $pos.depth; depth >= 0; depth--) {
|
|
40
|
-
var node = $pos.node(depth);
|
|
41
|
-
if (node.type === taskList) {
|
|
42
|
-
rootTaskListPos = $pos.before(depth);
|
|
43
|
-
rootTaskListNode = node;
|
|
44
|
-
} else if (rootTaskListNode !== null && node.type !== schema.nodes.taskItem) {
|
|
45
|
-
// We've exited the taskList structure — stop walking.
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (rootTaskListPos !== null && rootTaskListNode !== null) {
|
|
50
|
-
result.set(rootTaskListPos, rootTaskListNode);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
} catch (err) {
|
|
55
|
-
_iterator2.e(err);
|
|
56
|
-
} finally {
|
|
57
|
-
_iterator2.f();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
} catch (err) {
|
|
61
|
-
_iterator.e(err);
|
|
62
|
-
} finally {
|
|
63
|
-
_iterator.f();
|
|
64
|
-
}
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
export function applyTaskListNormalisationFixes(_ref) {
|
|
68
|
-
var doc = _ref.doc,
|
|
69
|
-
schema = _ref.schema,
|
|
70
|
-
tr = _ref.tr,
|
|
71
|
-
transactions = _ref.transactions;
|
|
72
|
-
var _schema$nodes = schema.nodes,
|
|
73
|
-
taskList = _schema$nodes.taskList,
|
|
74
|
-
taskItem = _schema$nodes.taskItem;
|
|
75
|
-
if (!taskList || !taskItem) {
|
|
76
|
-
return tr;
|
|
77
|
-
}
|
|
78
|
-
var affectedTaskLists = getAffectedTaskListsFromTransactions(transactions, doc, schema);
|
|
79
|
-
if (affectedTaskLists.size === 0) {
|
|
80
|
-
return tr;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Sort by position descending so we process deeper/later positions first,
|
|
84
|
-
// preventing earlier insertions from shifting later positions.
|
|
85
|
-
var sortedEntries = _toConsumableArray(affectedTaskLists.entries()).sort(function (_ref2, _ref3) {
|
|
86
|
-
var _ref4 = _slicedToArray(_ref2, 1),
|
|
87
|
-
a = _ref4[0];
|
|
88
|
-
var _ref5 = _slicedToArray(_ref3, 1),
|
|
89
|
-
b = _ref5[0];
|
|
90
|
-
return b - a;
|
|
91
|
-
});
|
|
92
|
-
var _iterator3 = _createForOfIteratorHelper(sortedEntries),
|
|
93
|
-
_step3;
|
|
94
|
-
try {
|
|
95
|
-
var _loop = function _loop() {
|
|
96
|
-
var _step3$value = _slicedToArray(_step3.value, 1),
|
|
97
|
-
taskListPos = _step3$value[0];
|
|
98
|
-
// Re-resolve the taskList node from the current transaction doc (post-operation state).
|
|
99
|
-
var mappedTaskListPos = tr.mapping.map(taskListPos);
|
|
100
|
-
var currentTaskListNode = tr.doc.nodeAt(mappedTaskListPos);
|
|
101
|
-
if (!currentTaskListNode) {
|
|
102
|
-
return 1; // continue
|
|
103
|
-
}
|
|
104
|
-
if (!expValEqualsNoExposure('platform_editor_flexible_list_indentation', 'isEnabled', true)) {
|
|
105
|
-
// Collect positions of all taskList nodes (at any depth) whose direct children
|
|
106
|
-
// include a taskList — this is the invalid structure. The taskList schema requires
|
|
107
|
-
// taskItem as children, not nested taskLists directly.
|
|
108
|
-
// Process in reverse order so higher-position insertions don't shift lower positions.
|
|
109
|
-
var invalidTaskListPositions = [];
|
|
110
|
-
currentTaskListNode.descendants(function (node, offsetPos) {
|
|
111
|
-
if (node.type === taskList) {
|
|
112
|
-
// A taskList as the FIRST child of another taskList is invalid — it means a
|
|
113
|
-
// delete or paste removed the leading taskItem, leaving a bare nested list.
|
|
114
|
-
// A taskList that follows a taskItem is valid (that's normal indentation).
|
|
115
|
-
var firstChild = node.firstChild;
|
|
116
|
-
if (firstChild && firstChild.type === taskList) {
|
|
117
|
-
var pos = mappedTaskListPos + 1 + offsetPos + 1;
|
|
118
|
-
invalidTaskListPositions.push(pos);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return true;
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
// Process in reverse (highest positions first).
|
|
125
|
-
for (var i = invalidTaskListPositions.length - 1; i >= 0; i--) {
|
|
126
|
-
var remappedPos = tr.mapping.map(invalidTaskListPositions[i]);
|
|
127
|
-
var emptyTaskItem = taskItem.createAndFill();
|
|
128
|
-
if (emptyTaskItem) {
|
|
129
|
-
tr.insert(remappedPos, emptyTaskItem);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
135
|
-
if (_loop()) continue;
|
|
136
|
-
}
|
|
137
|
-
} catch (err) {
|
|
138
|
-
_iterator3.e(err);
|
|
139
|
-
} finally {
|
|
140
|
-
_iterator3.f();
|
|
141
|
-
}
|
|
142
|
-
return tr;
|
|
143
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Node, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
-
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
interface ApplyTaskListNormalisationFixesOptions {
|
|
4
|
-
doc: Node;
|
|
5
|
-
schema: Schema;
|
|
6
|
-
tr: Transaction;
|
|
7
|
-
transactions: readonly Transaction[];
|
|
8
|
-
}
|
|
9
|
-
export declare function applyTaskListNormalisationFixes({ doc, schema, tr, transactions, }: ApplyTaskListNormalisationFixesOptions): Transaction;
|
|
10
|
-
export {};
|