@atlaskit/editor-common 112.7.4 → 112.8.0

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 (118) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/afm-cc/tsconfig.json +0 -3
  3. package/afm-jira/tsconfig.json +0 -3
  4. package/afm-products/tsconfig.json +0 -3
  5. package/dist/cjs/element-browser/components/CategoryList.js +1 -1
  6. package/dist/cjs/element-browser/components/ElementList/ElementList.js +1 -1
  7. package/dist/cjs/element-browser/components/ElementList/EmptyState.js +1 -1
  8. package/dist/cjs/element-browser/components/ElementSearch.js +1 -1
  9. package/dist/cjs/element-browser/components/StatelessElementBrowser.js +2 -2
  10. package/dist/cjs/extensibility/Extension/Extension/styles.js +2 -2
  11. package/dist/cjs/extensibility/Extension/InlineExtension/styles.js +1 -1
  12. package/dist/cjs/extensibility/Extension/LegacyContentHeader/index.js +1 -1
  13. package/dist/cjs/extensibility/MultiBodiedExtension/styles.js +1 -1
  14. package/dist/cjs/extensions/UnknownMacroPlaceholder.compiled.css +3 -3
  15. package/dist/cjs/extensions/UnknownMacroPlaceholder.js +3 -3
  16. package/dist/cjs/lists/build-replacement-fragment.js +85 -0
  17. package/dist/cjs/lists/flatten-list.js +73 -0
  18. package/dist/cjs/lists/index.js +27 -0
  19. package/dist/cjs/lists/restore-selection.js +66 -0
  20. package/dist/cjs/media-single/CommentBadge.js +3 -3
  21. package/dist/cjs/monitoring/error.js +1 -1
  22. package/dist/cjs/quick-insert/assets/datasource-assets-objects.js +3 -3
  23. package/dist/cjs/quick-insert/assets/five-column-layout.js +1 -1
  24. package/dist/cjs/quick-insert/assets/four-column-layout.js +1 -1
  25. package/dist/cjs/quick-insert/assets/one-column-layout.js +1 -1
  26. package/dist/cjs/quick-insert/assets/three-column-layout.js +1 -1
  27. package/dist/cjs/quick-insert/assets/two-column-layout.js +1 -1
  28. package/dist/cjs/resizer/Resizer.js +1 -1
  29. package/dist/cjs/styles/shared/blockquote.js +1 -1
  30. package/dist/cjs/styles/shared/table.js +3 -3
  31. package/dist/cjs/table/SortingIcon.js +3 -3
  32. package/dist/cjs/ui/DropList/index.js +1 -1
  33. package/dist/cjs/ui/MultiBodiedExtension/index.js +1 -1
  34. package/dist/cjs/ui/TableSelector/index.js +3 -4
  35. package/dist/cjs/ui/TableSelector/table-selector.js +9 -10
  36. package/dist/cjs/ui-color/ColorPalette/Palettes/highlightColorPalette.js +2 -2
  37. package/dist/cjs/ui-color/ColorPalette/Palettes/panelBackgroundPalette.js +1 -2
  38. package/dist/cjs/ui-color/ColorPalette/Palettes/textColorPalette.js +1 -1
  39. package/dist/cjs/ui-menu/DropdownMenu/index.js +3 -4
  40. package/dist/es2019/element-browser/components/CategoryList.js +2 -2
  41. package/dist/es2019/element-browser/components/ElementList/ElementList.js +1 -1
  42. package/dist/es2019/element-browser/components/ElementList/EmptyState.js +1 -1
  43. package/dist/es2019/element-browser/components/ElementSearch.js +1 -1
  44. package/dist/es2019/element-browser/components/StatelessElementBrowser.js +2 -2
  45. package/dist/es2019/extensibility/Extension/Extension/styles.js +2 -2
  46. package/dist/es2019/extensibility/Extension/InlineExtension/styles.js +1 -1
  47. package/dist/es2019/extensibility/Extension/LegacyContentHeader/index.js +1 -1
  48. package/dist/es2019/extensibility/MultiBodiedExtension/styles.js +1 -1
  49. package/dist/es2019/extensions/UnknownMacroPlaceholder.compiled.css +3 -3
  50. package/dist/es2019/extensions/UnknownMacroPlaceholder.js +2 -2
  51. package/dist/es2019/lists/build-replacement-fragment.js +60 -0
  52. package/dist/es2019/lists/flatten-list.js +72 -0
  53. package/dist/es2019/lists/index.js +3 -0
  54. package/dist/es2019/lists/restore-selection.js +59 -0
  55. package/dist/es2019/media-single/CommentBadge.js +3 -3
  56. package/dist/es2019/monitoring/error.js +1 -1
  57. package/dist/es2019/quick-insert/assets/datasource-assets-objects.js +3 -3
  58. package/dist/es2019/quick-insert/assets/five-column-layout.js +1 -1
  59. package/dist/es2019/quick-insert/assets/four-column-layout.js +1 -1
  60. package/dist/es2019/quick-insert/assets/one-column-layout.js +1 -1
  61. package/dist/es2019/quick-insert/assets/three-column-layout.js +1 -1
  62. package/dist/es2019/quick-insert/assets/two-column-layout.js +1 -1
  63. package/dist/es2019/resizer/Resizer.js +1 -1
  64. package/dist/es2019/styles/shared/blockquote.js +2 -2
  65. package/dist/es2019/styles/shared/table.js +13 -14
  66. package/dist/es2019/table/SortingIcon.js +4 -4
  67. package/dist/es2019/ui/DropList/index.js +1 -1
  68. package/dist/es2019/ui/MultiBodiedExtension/index.js +1 -1
  69. package/dist/es2019/ui/TableSelector/index.js +3 -4
  70. package/dist/es2019/ui/TableSelector/table-selector.js +9 -10
  71. package/dist/es2019/ui-color/ColorPalette/Palettes/highlightColorPalette.js +2 -2
  72. package/dist/es2019/ui-color/ColorPalette/Palettes/panelBackgroundPalette.js +1 -2
  73. package/dist/es2019/ui-color/ColorPalette/Palettes/textColorPalette.js +1 -1
  74. package/dist/es2019/ui-menu/DropdownMenu/index.js +7 -8
  75. package/dist/esm/element-browser/components/CategoryList.js +2 -2
  76. package/dist/esm/element-browser/components/ElementList/ElementList.js +1 -1
  77. package/dist/esm/element-browser/components/ElementList/EmptyState.js +1 -1
  78. package/dist/esm/element-browser/components/ElementSearch.js +1 -1
  79. package/dist/esm/element-browser/components/StatelessElementBrowser.js +2 -2
  80. package/dist/esm/extensibility/Extension/Extension/styles.js +2 -2
  81. package/dist/esm/extensibility/Extension/InlineExtension/styles.js +1 -1
  82. package/dist/esm/extensibility/Extension/LegacyContentHeader/index.js +1 -1
  83. package/dist/esm/extensibility/MultiBodiedExtension/styles.js +1 -1
  84. package/dist/esm/extensions/UnknownMacroPlaceholder.compiled.css +3 -3
  85. package/dist/esm/extensions/UnknownMacroPlaceholder.js +3 -3
  86. package/dist/esm/lists/build-replacement-fragment.js +80 -0
  87. package/dist/esm/lists/flatten-list.js +67 -0
  88. package/dist/esm/lists/index.js +3 -0
  89. package/dist/esm/lists/restore-selection.js +59 -0
  90. package/dist/esm/media-single/CommentBadge.js +3 -3
  91. package/dist/esm/monitoring/error.js +1 -1
  92. package/dist/esm/quick-insert/assets/datasource-assets-objects.js +3 -3
  93. package/dist/esm/quick-insert/assets/five-column-layout.js +1 -1
  94. package/dist/esm/quick-insert/assets/four-column-layout.js +1 -1
  95. package/dist/esm/quick-insert/assets/one-column-layout.js +1 -1
  96. package/dist/esm/quick-insert/assets/three-column-layout.js +1 -1
  97. package/dist/esm/quick-insert/assets/two-column-layout.js +1 -1
  98. package/dist/esm/resizer/Resizer.js +1 -1
  99. package/dist/esm/styles/shared/blockquote.js +2 -2
  100. package/dist/esm/styles/shared/table.js +4 -4
  101. package/dist/esm/table/SortingIcon.js +3 -3
  102. package/dist/esm/ui/DropList/index.js +1 -1
  103. package/dist/esm/ui/MultiBodiedExtension/index.js +1 -1
  104. package/dist/esm/ui/TableSelector/index.js +3 -4
  105. package/dist/esm/ui/TableSelector/table-selector.js +9 -10
  106. package/dist/esm/ui-color/ColorPalette/Palettes/highlightColorPalette.js +2 -2
  107. package/dist/esm/ui-color/ColorPalette/Palettes/panelBackgroundPalette.js +1 -2
  108. package/dist/esm/ui-color/ColorPalette/Palettes/textColorPalette.js +1 -1
  109. package/dist/esm/ui-menu/DropdownMenu/index.js +3 -4
  110. package/dist/types/lists/build-replacement-fragment.d.ts +35 -0
  111. package/dist/types/lists/flatten-list.d.ts +47 -0
  112. package/dist/types/lists/index.d.ts +6 -0
  113. package/dist/types/lists/restore-selection.d.ts +41 -0
  114. package/dist/types-ts4.5/lists/build-replacement-fragment.d.ts +35 -0
  115. package/dist/types-ts4.5/lists/flatten-list.d.ts +47 -0
  116. package/dist/types-ts4.5/lists/index.d.ts +6 -0
  117. package/dist/types-ts4.5/lists/restore-selection.d.ts +41 -0
  118. package/package.json +2 -3
@@ -0,0 +1,35 @@
1
+ import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
+ import type { FlattenedItem } from './flatten-list';
4
+ export interface BuildResult {
5
+ /**
6
+ * For each element (by index), the offset within the fragment where the
7
+ * element's content begins.
8
+ *
9
+ * To get the absolute document position after `tr.replaceWith(rangeStart, …)`,
10
+ * add `rangeStart` to the offset.
11
+ */
12
+ contentStartOffsets: number[];
13
+ fragment: Fragment;
14
+ }
15
+ /** Rebuilds a list-like PM node from a flat array of items. */
16
+ type RebuildFn = (items: FlattenedItem[], schema: Schema) => {
17
+ contentStartOffsets: number[];
18
+ node: PMNode;
19
+ } | null;
20
+ /** Extracts top-level content nodes from an item being broken out past the root list. */
21
+ type ExtractContentFn = (item: FlattenedItem, schema: Schema) => PMNode[];
22
+ interface BuildReplacementFragmentOptions {
23
+ extractContentFn: ExtractContentFn;
24
+ items: FlattenedItem[];
25
+ rebuildFn: RebuildFn;
26
+ schema: Schema;
27
+ }
28
+ /**
29
+ * Build a replacement Fragment from a flat array of items.
30
+ *
31
+ * Items with depth >= 0 are grouped and rebuilt via `rebuildFn`.
32
+ * Items with depth < 0 are extracted via `extractContentFn`.
33
+ */
34
+ export declare function buildReplacementFragment({ items, schema, rebuildFn, extractContentFn, }: BuildReplacementFragmentOptions): BuildResult;
35
+ export {};
@@ -0,0 +1,47 @@
1
+ import type { Attrs, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ export interface FlattenedItem {
3
+ depth: number;
4
+ isSelected: boolean;
5
+ listType: string;
6
+ node: PMNode;
7
+ parentListAttrs: Attrs | null;
8
+ pos: number;
9
+ }
10
+ export interface FlattenListOptions {
11
+ doc: PMNode;
12
+ indentDelta: number;
13
+ maxDepth?: number;
14
+ rootListStart: number;
15
+ rootListEnd: number;
16
+ selectionFrom: number;
17
+ selectionTo: number;
18
+ }
19
+ /**
20
+ * Type-specific predicates that vary between regular lists and task lists.
21
+ */
22
+ interface FlattenListPredicates {
23
+ /** Returns true if `node` is a content-bearing item to include in the flattened output. */
24
+ isContentNode: (node: PMNode, parent: PMNode | null) => boolean;
25
+ /** Returns the selection bounds for an item, used to check selection intersection. */
26
+ getSelectionBounds: (node: PMNode, pos: number) => {
27
+ start: number;
28
+ end: number;
29
+ };
30
+ /** Computes the nesting depth for a node given its resolved depth and the root's depth. */
31
+ getDepth: (resolvedDepth: number, rootDepth: number) => number;
32
+ }
33
+ export interface FlattenListResult {
34
+ items: FlattenedItem[];
35
+ startIndex: number;
36
+ endIndex: number;
37
+ }
38
+ /**
39
+ * Flattens a list-like PM structure (regular list or task list) into an
40
+ * array of content-bearing items with computed depths.
41
+ *
42
+ * Uses `doc.nodesBetween` to walk the tree and delegates type-specific
43
+ * decisions to the provided predicates. The core algorithm — selection
44
+ * intersection, depth adjustment, index tracking — is shared.
45
+ */
46
+ export declare function flattenList(options: FlattenListOptions, predicates: FlattenListPredicates): FlattenListResult | null;
47
+ export {};
@@ -3,5 +3,11 @@ export { moveTargetIntoList } from './replace-content';
3
3
  export { JoinDirection, isListNodeValidContent, joinSiblingLists, processNestedTaskListsInSameLevel, } from './node';
4
4
  export { getCommonListAnalyticsAttributes, countListItemsInSelection } from './analytics';
5
5
  export { hasValidListIndentationLevel } from './indentation';
6
+ export { restoreSelection, computeSelectionOffsets } from './restore-selection';
7
+ export { buildReplacementFragment } from './build-replacement-fragment';
8
+ export type { BuildResult } from './build-replacement-fragment';
9
+ export type { FlattenedItem } from './flatten-list';
10
+ export { flattenList } from './flatten-list';
11
+ export type { FlattenListOptions, FlattenListResult } from './flatten-list';
6
12
  export { isListNode, isListItemNode, isBulletList, isParagraphNode } from '../utils';
7
13
  export { messages } from './messages';
@@ -0,0 +1,41 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import { Selection } from '@atlaskit/editor-prosemirror/state';
3
+ import type { FlattenedItem } from './flatten-list';
4
+ interface ComputeSelectionOffsetsOptions {
5
+ contentStartOffsets: number[];
6
+ docSize: number;
7
+ endIndex: number;
8
+ items: FlattenedItem[];
9
+ originalFrom: number;
10
+ originalTo: number;
11
+ rootListStart: number;
12
+ startIndex: number;
13
+ }
14
+ interface RestoreSelectionOptions {
15
+ from: number;
16
+ originalSelection: Selection;
17
+ to: number;
18
+ tr: Transaction;
19
+ }
20
+ /**
21
+ * Compute the new selection offsets after list items have been moved/indented/outdented.
22
+ *
23
+ * Uses the content start offsets computed during fragment rebuild to map each
24
+ * selection endpoint to its new absolute position, accounting for the change
25
+ * in the list structure.
26
+ */
27
+ export declare function computeSelectionOffsets({ items, startIndex, endIndex, originalFrom, originalTo, contentStartOffsets, rootListStart, docSize, }: ComputeSelectionOffsetsOptions): {
28
+ from: number;
29
+ to: number;
30
+ };
31
+ /**
32
+ * Restore the transaction's selection after a list structural change
33
+ * (indent/outdent of list items or task list items).
34
+ *
35
+ * Uses the content start offsets computed during fragment rebuild to
36
+ * map each selection endpoint to its new absolute position.
37
+ *
38
+ * Handles NodeSelection, GapCursorSelection, and TextSelection.
39
+ */
40
+ export declare function restoreSelection({ tr, originalSelection, from, to, }: RestoreSelectionOptions): void;
41
+ export {};
@@ -0,0 +1,35 @@
1
+ import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
+ import { Fragment } from '@atlaskit/editor-prosemirror/model';
3
+ import type { FlattenedItem } from './flatten-list';
4
+ export interface BuildResult {
5
+ /**
6
+ * For each element (by index), the offset within the fragment where the
7
+ * element's content begins.
8
+ *
9
+ * To get the absolute document position after `tr.replaceWith(rangeStart, …)`,
10
+ * add `rangeStart` to the offset.
11
+ */
12
+ contentStartOffsets: number[];
13
+ fragment: Fragment;
14
+ }
15
+ /** Rebuilds a list-like PM node from a flat array of items. */
16
+ type RebuildFn = (items: FlattenedItem[], schema: Schema) => {
17
+ contentStartOffsets: number[];
18
+ node: PMNode;
19
+ } | null;
20
+ /** Extracts top-level content nodes from an item being broken out past the root list. */
21
+ type ExtractContentFn = (item: FlattenedItem, schema: Schema) => PMNode[];
22
+ interface BuildReplacementFragmentOptions {
23
+ extractContentFn: ExtractContentFn;
24
+ items: FlattenedItem[];
25
+ rebuildFn: RebuildFn;
26
+ schema: Schema;
27
+ }
28
+ /**
29
+ * Build a replacement Fragment from a flat array of items.
30
+ *
31
+ * Items with depth >= 0 are grouped and rebuilt via `rebuildFn`.
32
+ * Items with depth < 0 are extracted via `extractContentFn`.
33
+ */
34
+ export declare function buildReplacementFragment({ items, schema, rebuildFn, extractContentFn, }: BuildReplacementFragmentOptions): BuildResult;
35
+ export {};
@@ -0,0 +1,47 @@
1
+ import type { Attrs, Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
+ export interface FlattenedItem {
3
+ depth: number;
4
+ isSelected: boolean;
5
+ listType: string;
6
+ node: PMNode;
7
+ parentListAttrs: Attrs | null;
8
+ pos: number;
9
+ }
10
+ export interface FlattenListOptions {
11
+ doc: PMNode;
12
+ indentDelta: number;
13
+ maxDepth?: number;
14
+ rootListStart: number;
15
+ rootListEnd: number;
16
+ selectionFrom: number;
17
+ selectionTo: number;
18
+ }
19
+ /**
20
+ * Type-specific predicates that vary between regular lists and task lists.
21
+ */
22
+ interface FlattenListPredicates {
23
+ /** Returns true if `node` is a content-bearing item to include in the flattened output. */
24
+ isContentNode: (node: PMNode, parent: PMNode | null) => boolean;
25
+ /** Returns the selection bounds for an item, used to check selection intersection. */
26
+ getSelectionBounds: (node: PMNode, pos: number) => {
27
+ start: number;
28
+ end: number;
29
+ };
30
+ /** Computes the nesting depth for a node given its resolved depth and the root's depth. */
31
+ getDepth: (resolvedDepth: number, rootDepth: number) => number;
32
+ }
33
+ export interface FlattenListResult {
34
+ items: FlattenedItem[];
35
+ startIndex: number;
36
+ endIndex: number;
37
+ }
38
+ /**
39
+ * Flattens a list-like PM structure (regular list or task list) into an
40
+ * array of content-bearing items with computed depths.
41
+ *
42
+ * Uses `doc.nodesBetween` to walk the tree and delegates type-specific
43
+ * decisions to the provided predicates. The core algorithm — selection
44
+ * intersection, depth adjustment, index tracking — is shared.
45
+ */
46
+ export declare function flattenList(options: FlattenListOptions, predicates: FlattenListPredicates): FlattenListResult | null;
47
+ export {};
@@ -3,5 +3,11 @@ export { moveTargetIntoList } from './replace-content';
3
3
  export { JoinDirection, isListNodeValidContent, joinSiblingLists, processNestedTaskListsInSameLevel, } from './node';
4
4
  export { getCommonListAnalyticsAttributes, countListItemsInSelection } from './analytics';
5
5
  export { hasValidListIndentationLevel } from './indentation';
6
+ export { restoreSelection, computeSelectionOffsets } from './restore-selection';
7
+ export { buildReplacementFragment } from './build-replacement-fragment';
8
+ export type { BuildResult } from './build-replacement-fragment';
9
+ export type { FlattenedItem } from './flatten-list';
10
+ export { flattenList } from './flatten-list';
11
+ export type { FlattenListOptions, FlattenListResult } from './flatten-list';
6
12
  export { isListNode, isListItemNode, isBulletList, isParagraphNode } from '../utils';
7
13
  export { messages } from './messages';
@@ -0,0 +1,41 @@
1
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import { Selection } from '@atlaskit/editor-prosemirror/state';
3
+ import type { FlattenedItem } from './flatten-list';
4
+ interface ComputeSelectionOffsetsOptions {
5
+ contentStartOffsets: number[];
6
+ docSize: number;
7
+ endIndex: number;
8
+ items: FlattenedItem[];
9
+ originalFrom: number;
10
+ originalTo: number;
11
+ rootListStart: number;
12
+ startIndex: number;
13
+ }
14
+ interface RestoreSelectionOptions {
15
+ from: number;
16
+ originalSelection: Selection;
17
+ to: number;
18
+ tr: Transaction;
19
+ }
20
+ /**
21
+ * Compute the new selection offsets after list items have been moved/indented/outdented.
22
+ *
23
+ * Uses the content start offsets computed during fragment rebuild to map each
24
+ * selection endpoint to its new absolute position, accounting for the change
25
+ * in the list structure.
26
+ */
27
+ export declare function computeSelectionOffsets({ items, startIndex, endIndex, originalFrom, originalTo, contentStartOffsets, rootListStart, docSize, }: ComputeSelectionOffsetsOptions): {
28
+ from: number;
29
+ to: number;
30
+ };
31
+ /**
32
+ * Restore the transaction's selection after a list structural change
33
+ * (indent/outdent of list items or task list items).
34
+ *
35
+ * Uses the content start offsets computed during fragment rebuild to
36
+ * map each selection endpoint to its new absolute position.
37
+ *
38
+ * Handles NodeSelection, GapCursorSelection, and TextSelection.
39
+ */
40
+ export declare function restoreSelection({ tr, originalSelection, from, to, }: RestoreSelectionOptions): void;
41
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "112.7.4",
3
+ "version": "112.8.0",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -81,8 +81,7 @@
81
81
  "@atlaskit/status": "^3.1.0",
82
82
  "@atlaskit/task-decision": "^19.3.0",
83
83
  "@atlaskit/textfield": "^8.2.0",
84
- "@atlaskit/theme": "^22.0.0",
85
- "@atlaskit/tmp-editor-statsig": "^44.0.0",
84
+ "@atlaskit/tmp-editor-statsig": "^44.1.0",
86
85
  "@atlaskit/tokens": "^11.1.0",
87
86
  "@atlaskit/tooltip": "^21.0.0",
88
87
  "@atlaskit/width-detector": "^5.0.0",