@atlaskit/editor-plugin-list 10.1.2 → 10.1.3
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 +11 -0
- package/dist/cjs/pm-plugins/actions/move-selected-list-items.js +7 -10
- package/dist/cjs/pm-plugins/utils/mark.js +19 -1
- package/dist/es2019/pm-plugins/actions/move-selected-list-items.js +8 -11
- package/dist/es2019/pm-plugins/utils/mark.js +17 -1
- package/dist/esm/pm-plugins/actions/move-selected-list-items.js +8 -11
- package/dist/esm/pm-plugins/utils/mark.js +19 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-list
|
|
2
2
|
|
|
3
|
+
## 10.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`9b33b26d69865`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9b33b26d69865) -
|
|
8
|
+
Narrow list replacement range during indent/outdent for collab-friendly cursor preservation
|
|
9
|
+
- [`3f6f3c13a6033`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3f6f3c13a6033) -
|
|
10
|
+
Fix fontSize mark not being stripped during paragraph to list conversion by checking listItem mark
|
|
11
|
+
compatibility instead of list container
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 10.1.2
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -13,8 +13,6 @@ var _listIndentation = require("../utils/list-indentation");
|
|
|
13
13
|
*/
|
|
14
14
|
function moveSelectedListItems(tr, indentDelta) {
|
|
15
15
|
var originalSelection = tr.selection;
|
|
16
|
-
|
|
17
|
-
// Find the root list so depth adjustments are absolute
|
|
18
16
|
var rootListResolved = (0, _find.findRootParentListNode)(originalSelection.$from);
|
|
19
17
|
if (!rootListResolved) {
|
|
20
18
|
return;
|
|
@@ -40,30 +38,29 @@ function moveSelectedListItems(tr, indentDelta) {
|
|
|
40
38
|
var items = result.items,
|
|
41
39
|
startIndex = result.startIndex,
|
|
42
40
|
endIndex = result.endIndex;
|
|
43
|
-
|
|
44
|
-
// Build replacement — handles both indent (all depths >= 0)
|
|
45
|
-
// and outdent (some depths may be < 0, producing extracted paragraphs).
|
|
46
41
|
var _buildReplacementFrag = (0, _listIndentation.buildReplacementFragment)(items, tr.doc.type.schema),
|
|
47
42
|
fragment = _buildReplacementFrag.fragment,
|
|
48
43
|
contentStartOffsets = _buildReplacementFrag.contentStartOffsets;
|
|
49
44
|
if (fragment.size === 0) {
|
|
50
45
|
return;
|
|
51
46
|
}
|
|
52
|
-
|
|
47
|
+
|
|
48
|
+
// Narrow the replacement to the minimal changed range for collab-friendly
|
|
49
|
+
// cursor preservation on unaffected list items.
|
|
50
|
+
var narrowed = (0, _lists.narrowReplacementRange)(tr.doc, rootListStart, rootListEnd, fragment, contentStartOffsets);
|
|
51
|
+
tr.replaceWith(narrowed.start, narrowed.end, narrowed.fragment);
|
|
53
52
|
var _computeSelectionOffs = (0, _lists.computeSelectionOffsets)({
|
|
54
53
|
items: items,
|
|
55
54
|
startIndex: startIndex,
|
|
56
55
|
endIndex: endIndex,
|
|
57
56
|
originalFrom: originalSelection.from,
|
|
58
57
|
originalTo: originalSelection.to,
|
|
59
|
-
contentStartOffsets:
|
|
60
|
-
rootListStart:
|
|
58
|
+
contentStartOffsets: narrowed.adjustedContentStartOffsets,
|
|
59
|
+
rootListStart: narrowed.start,
|
|
61
60
|
docSize: tr.doc.content.size
|
|
62
61
|
}),
|
|
63
62
|
from = _computeSelectionOffs.from,
|
|
64
63
|
to = _computeSelectionOffs.to;
|
|
65
|
-
|
|
66
|
-
// Restore selection using the positional offsets from the rebuild.
|
|
67
64
|
(0, _lists.restoreSelection)({
|
|
68
65
|
tr: tr,
|
|
69
66
|
originalSelection: originalSelection,
|
|
@@ -4,6 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.sanitiseMarksInSelection = void 0;
|
|
7
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
8
|
+
var listContainerTypes = new Set(['bulletList', 'orderedList']);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* When wrapping in a list, the paragraph's direct parent will be listItem,
|
|
12
|
+
* not the list container itself. For fontSize marks, resolve to listItem
|
|
13
|
+
* so mark compatibility is checked against the actual parent.
|
|
14
|
+
*/
|
|
15
|
+
var resolveEffectiveParentType = function resolveEffectiveParentType(newParentType) {
|
|
16
|
+
if (newParentType && listContainerTypes.has(newParentType.name) && (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
17
|
+
return newParentType.schema.nodes.listItem;
|
|
18
|
+
}
|
|
19
|
+
return newParentType;
|
|
20
|
+
};
|
|
21
|
+
var isMarkDisallowed = function isMarkDisallowed(mark, parent, effectiveParentType) {
|
|
22
|
+
return !(parent !== null && parent !== void 0 && parent.type.allowsMarkType(mark.type)) || effectiveParentType && !effectiveParentType.allowsMarkType(mark.type);
|
|
23
|
+
};
|
|
7
24
|
var sanitiseMarksInSelection = exports.sanitiseMarksInSelection = function sanitiseMarksInSelection(tr, newParentType) {
|
|
8
25
|
var _tr$selection = tr.selection,
|
|
9
26
|
from = _tr$selection.from,
|
|
@@ -19,7 +36,8 @@ var sanitiseMarksInSelection = exports.sanitiseMarksInSelection = function sanit
|
|
|
19
36
|
return true;
|
|
20
37
|
}
|
|
21
38
|
node.marks.forEach(function (mark) {
|
|
22
|
-
|
|
39
|
+
var effectiveParentType = resolveEffectiveParentType(newParentType);
|
|
40
|
+
if (isMarkDisallowed(mark, parent, effectiveParentType)) {
|
|
23
41
|
var filteredMarks = node.marks.filter(function (m) {
|
|
24
42
|
return m.type !== mark.type;
|
|
25
43
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { computeSelectionOffsets, narrowReplacementRange, restoreSelection } from '@atlaskit/editor-common/lists';
|
|
2
2
|
import { MAX_NESTED_LIST_INDENTATION } from '../../types';
|
|
3
3
|
import { findFirstParentListNode, findRootParentListNode } from '../utils/find';
|
|
4
4
|
import { buildReplacementFragment, flattenList } from '../utils/list-indentation';
|
|
@@ -8,8 +8,6 @@ import { buildReplacementFragment, flattenList } from '../utils/list-indentation
|
|
|
8
8
|
*/
|
|
9
9
|
export function moveSelectedListItems(tr, indentDelta) {
|
|
10
10
|
const originalSelection = tr.selection;
|
|
11
|
-
|
|
12
|
-
// Find the root list so depth adjustments are absolute
|
|
13
11
|
const rootListResolved = findRootParentListNode(originalSelection.$from);
|
|
14
12
|
if (!rootListResolved) {
|
|
15
13
|
return;
|
|
@@ -37,9 +35,6 @@ export function moveSelectedListItems(tr, indentDelta) {
|
|
|
37
35
|
startIndex,
|
|
38
36
|
endIndex
|
|
39
37
|
} = result;
|
|
40
|
-
|
|
41
|
-
// Build replacement — handles both indent (all depths >= 0)
|
|
42
|
-
// and outdent (some depths may be < 0, producing extracted paragraphs).
|
|
43
38
|
const {
|
|
44
39
|
fragment,
|
|
45
40
|
contentStartOffsets
|
|
@@ -47,7 +42,11 @@ export function moveSelectedListItems(tr, indentDelta) {
|
|
|
47
42
|
if (fragment.size === 0) {
|
|
48
43
|
return;
|
|
49
44
|
}
|
|
50
|
-
|
|
45
|
+
|
|
46
|
+
// Narrow the replacement to the minimal changed range for collab-friendly
|
|
47
|
+
// cursor preservation on unaffected list items.
|
|
48
|
+
const narrowed = narrowReplacementRange(tr.doc, rootListStart, rootListEnd, fragment, contentStartOffsets);
|
|
49
|
+
tr.replaceWith(narrowed.start, narrowed.end, narrowed.fragment);
|
|
51
50
|
const {
|
|
52
51
|
from,
|
|
53
52
|
to
|
|
@@ -57,12 +56,10 @@ export function moveSelectedListItems(tr, indentDelta) {
|
|
|
57
56
|
endIndex,
|
|
58
57
|
originalFrom: originalSelection.from,
|
|
59
58
|
originalTo: originalSelection.to,
|
|
60
|
-
contentStartOffsets,
|
|
61
|
-
rootListStart,
|
|
59
|
+
contentStartOffsets: narrowed.adjustedContentStartOffsets,
|
|
60
|
+
rootListStart: narrowed.start,
|
|
62
61
|
docSize: tr.doc.content.size
|
|
63
62
|
});
|
|
64
|
-
|
|
65
|
-
// Restore selection using the positional offsets from the rebuild.
|
|
66
63
|
restoreSelection({
|
|
67
64
|
tr,
|
|
68
65
|
originalSelection,
|
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
|
+
const listContainerTypes = new Set(['bulletList', 'orderedList']);
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* When wrapping in a list, the paragraph's direct parent will be listItem,
|
|
6
|
+
* not the list container itself. For fontSize marks, resolve to listItem
|
|
7
|
+
* so mark compatibility is checked against the actual parent.
|
|
8
|
+
*/
|
|
9
|
+
const resolveEffectiveParentType = newParentType => {
|
|
10
|
+
if (newParentType && listContainerTypes.has(newParentType.name) && expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
11
|
+
return newParentType.schema.nodes.listItem;
|
|
12
|
+
}
|
|
13
|
+
return newParentType;
|
|
14
|
+
};
|
|
15
|
+
const isMarkDisallowed = (mark, parent, effectiveParentType) => !(parent !== null && parent !== void 0 && parent.type.allowsMarkType(mark.type)) || effectiveParentType && !effectiveParentType.allowsMarkType(mark.type);
|
|
1
16
|
export const sanitiseMarksInSelection = (tr, newParentType) => {
|
|
2
17
|
const {
|
|
3
18
|
from,
|
|
@@ -14,7 +29,8 @@ export const sanitiseMarksInSelection = (tr, newParentType) => {
|
|
|
14
29
|
return true;
|
|
15
30
|
}
|
|
16
31
|
node.marks.forEach(mark => {
|
|
17
|
-
|
|
32
|
+
const effectiveParentType = resolveEffectiveParentType(newParentType);
|
|
33
|
+
if (isMarkDisallowed(mark, parent, effectiveParentType)) {
|
|
18
34
|
const filteredMarks = node.marks.filter(m => m.type !== mark.type);
|
|
19
35
|
const position = pos > 0 ? pos : 0;
|
|
20
36
|
const marksRemoved = node.marks.filter(m => m.type === mark.type);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { computeSelectionOffsets, narrowReplacementRange, restoreSelection } from '@atlaskit/editor-common/lists';
|
|
2
2
|
import { MAX_NESTED_LIST_INDENTATION } from '../../types';
|
|
3
3
|
import { findFirstParentListNode, findRootParentListNode } from '../utils/find';
|
|
4
4
|
import { buildReplacementFragment, flattenList } from '../utils/list-indentation';
|
|
@@ -8,8 +8,6 @@ import { buildReplacementFragment, flattenList } from '../utils/list-indentation
|
|
|
8
8
|
*/
|
|
9
9
|
export function moveSelectedListItems(tr, indentDelta) {
|
|
10
10
|
var originalSelection = tr.selection;
|
|
11
|
-
|
|
12
|
-
// Find the root list so depth adjustments are absolute
|
|
13
11
|
var rootListResolved = findRootParentListNode(originalSelection.$from);
|
|
14
12
|
if (!rootListResolved) {
|
|
15
13
|
return;
|
|
@@ -35,30 +33,29 @@ export function moveSelectedListItems(tr, indentDelta) {
|
|
|
35
33
|
var items = result.items,
|
|
36
34
|
startIndex = result.startIndex,
|
|
37
35
|
endIndex = result.endIndex;
|
|
38
|
-
|
|
39
|
-
// Build replacement — handles both indent (all depths >= 0)
|
|
40
|
-
// and outdent (some depths may be < 0, producing extracted paragraphs).
|
|
41
36
|
var _buildReplacementFrag = buildReplacementFragment(items, tr.doc.type.schema),
|
|
42
37
|
fragment = _buildReplacementFrag.fragment,
|
|
43
38
|
contentStartOffsets = _buildReplacementFrag.contentStartOffsets;
|
|
44
39
|
if (fragment.size === 0) {
|
|
45
40
|
return;
|
|
46
41
|
}
|
|
47
|
-
|
|
42
|
+
|
|
43
|
+
// Narrow the replacement to the minimal changed range for collab-friendly
|
|
44
|
+
// cursor preservation on unaffected list items.
|
|
45
|
+
var narrowed = narrowReplacementRange(tr.doc, rootListStart, rootListEnd, fragment, contentStartOffsets);
|
|
46
|
+
tr.replaceWith(narrowed.start, narrowed.end, narrowed.fragment);
|
|
48
47
|
var _computeSelectionOffs = computeSelectionOffsets({
|
|
49
48
|
items: items,
|
|
50
49
|
startIndex: startIndex,
|
|
51
50
|
endIndex: endIndex,
|
|
52
51
|
originalFrom: originalSelection.from,
|
|
53
52
|
originalTo: originalSelection.to,
|
|
54
|
-
contentStartOffsets:
|
|
55
|
-
rootListStart:
|
|
53
|
+
contentStartOffsets: narrowed.adjustedContentStartOffsets,
|
|
54
|
+
rootListStart: narrowed.start,
|
|
56
55
|
docSize: tr.doc.content.size
|
|
57
56
|
}),
|
|
58
57
|
from = _computeSelectionOffs.from,
|
|
59
58
|
to = _computeSelectionOffs.to;
|
|
60
|
-
|
|
61
|
-
// Restore selection using the positional offsets from the rebuild.
|
|
62
59
|
restoreSelection({
|
|
63
60
|
tr: tr,
|
|
64
61
|
originalSelection: originalSelection,
|
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
2
|
+
var listContainerTypes = new Set(['bulletList', 'orderedList']);
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* When wrapping in a list, the paragraph's direct parent will be listItem,
|
|
6
|
+
* not the list container itself. For fontSize marks, resolve to listItem
|
|
7
|
+
* so mark compatibility is checked against the actual parent.
|
|
8
|
+
*/
|
|
9
|
+
var resolveEffectiveParentType = function resolveEffectiveParentType(newParentType) {
|
|
10
|
+
if (newParentType && listContainerTypes.has(newParentType.name) && expValEquals('platform_editor_small_font_size', 'isEnabled', true)) {
|
|
11
|
+
return newParentType.schema.nodes.listItem;
|
|
12
|
+
}
|
|
13
|
+
return newParentType;
|
|
14
|
+
};
|
|
15
|
+
var isMarkDisallowed = function isMarkDisallowed(mark, parent, effectiveParentType) {
|
|
16
|
+
return !(parent !== null && parent !== void 0 && parent.type.allowsMarkType(mark.type)) || effectiveParentType && !effectiveParentType.allowsMarkType(mark.type);
|
|
17
|
+
};
|
|
1
18
|
export var sanitiseMarksInSelection = function sanitiseMarksInSelection(tr, newParentType) {
|
|
2
19
|
var _tr$selection = tr.selection,
|
|
3
20
|
from = _tr$selection.from,
|
|
@@ -13,7 +30,8 @@ export var sanitiseMarksInSelection = function sanitiseMarksInSelection(tr, newP
|
|
|
13
30
|
return true;
|
|
14
31
|
}
|
|
15
32
|
node.marks.forEach(function (mark) {
|
|
16
|
-
|
|
33
|
+
var effectiveParentType = resolveEffectiveParentType(newParentType);
|
|
34
|
+
if (isMarkDisallowed(mark, parent, effectiveParentType)) {
|
|
17
35
|
var filteredMarks = node.marks.filter(function (m) {
|
|
18
36
|
return m.type !== mark.type;
|
|
19
37
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-list",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.3",
|
|
4
4
|
"description": "List plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
39
39
|
"@atlaskit/prosemirror-history": "^0.2.0",
|
|
40
40
|
"@atlaskit/prosemirror-input-rules": "^3.6.0",
|
|
41
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
41
|
+
"@atlaskit/tmp-editor-statsig": "^46.0.0",
|
|
42
42
|
"@babel/runtime": "^7.0.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@atlaskit/editor-common": "^112.
|
|
45
|
+
"@atlaskit/editor-common": "^112.9.0",
|
|
46
46
|
"react": "^18.2.0",
|
|
47
47
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
48
48
|
},
|