@atlaskit/editor-plugin-list 10.1.2 → 10.1.4

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,24 @@
1
1
  # @atlaskit/editor-plugin-list
2
2
 
3
+ ## 10.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`5892e575833a1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5892e575833a1) -
8
+ Internal changes to remove unnecessary token fallbacks and imports from `@atlaskit/theme`
9
+ - Updated dependencies
10
+
11
+ ## 10.1.3
12
+
13
+ ### Patch Changes
14
+
15
+ - [`9b33b26d69865`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9b33b26d69865) -
16
+ Narrow list replacement range during indent/outdent for collab-friendly cursor preservation
17
+ - [`3f6f3c13a6033`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3f6f3c13a6033) -
18
+ Fix fontSize mark not being stripped during paragraph to list conversion by checking listItem mark
19
+ compatibility instead of list container
20
+ - Updated dependencies
21
+
3
22
  ## 10.1.2
4
23
 
5
24
  ### 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
- tr.replaceWith(rootListStart, rootListEnd, fragment);
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: contentStartOffsets,
60
- rootListStart: 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
- if (!(parent !== null && parent !== void 0 && parent.type.allowsMarkType(mark.type)) || newParentType && !newParentType.allowsMarkType(mark.type)) {
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 { restoreSelection, computeSelectionOffsets } from '@atlaskit/editor-common/lists';
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
- tr.replaceWith(rootListStart, rootListEnd, fragment);
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
- if (!(parent !== null && parent !== void 0 && parent.type.allowsMarkType(mark.type)) || newParentType && !newParentType.allowsMarkType(mark.type)) {
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 { restoreSelection, computeSelectionOffsets } from '@atlaskit/editor-common/lists';
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
- tr.replaceWith(rootListStart, rootListEnd, fragment);
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: contentStartOffsets,
55
- rootListStart: 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
- if (!(parent !== null && parent !== void 0 && parent.type.allowsMarkType(mark.type)) || newParentType && !newParentType.allowsMarkType(mark.type)) {
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.2",
3
+ "version": "10.1.4",
4
4
  "description": "List plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -34,15 +34,15 @@
34
34
  "@atlaskit/editor-plugin-toolbar": "^5.1.0",
35
35
  "@atlaskit/editor-prosemirror": "^7.3.0",
36
36
  "@atlaskit/editor-toolbar": "^0.20.0",
37
- "@atlaskit/icon": "^33.0.0",
37
+ "@atlaskit/icon": "^33.1.0",
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": "^45.0.0",
41
+ "@atlaskit/tmp-editor-statsig": "^46.1.0",
42
42
  "@babel/runtime": "^7.0.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "@atlaskit/editor-common": "^112.8.0",
45
+ "@atlaskit/editor-common": "^112.10.0",
46
46
  "react": "^18.2.0",
47
47
  "react-intl-next": "npm:react-intl@^5.18.1"
48
48
  },