@atlaskit/editor-tables 2.3.15 → 2.3.16

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,11 @@
1
1
  # @atlaskit/editor-tables
2
2
 
3
+ ## 2.3.16
4
+
5
+ ### Patch Changes
6
+
7
+ - [#58433](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58433) [`4d8e164d7760`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4d8e164d7760) - fix shift + click to expand column / row selection bug when `platform.editor.table.drag-and-drop` is enabled
8
+
3
9
  ## 2.3.15
4
10
 
5
11
  ### Patch Changes
@@ -131,7 +131,7 @@ function handleTripleClick(view, pos) {
131
131
  view.dispatch(view.state.tr.setSelection(new _cellSelection.CellSelection($cell)));
132
132
  return true;
133
133
  }
134
- function handleMouseDown(view, event) {
134
+ function handleMouseDown(view, event, dragAndDropEnabled) {
135
135
  var startEvent = event;
136
136
  // Prevent right clicks from making a cell selection https://product-fabric.atlassian.net/browse/ED-12527
137
137
  if (startEvent.ctrlKey || startEvent.metaKey || startEvent.button === 2 // right mouse click
@@ -142,6 +142,9 @@ function handleMouseDown(view, event) {
142
142
  var $anchor = (0, _cells.cellAround)(view.state.selection.$anchor);
143
143
  if (startEvent.shiftKey && view.state.selection instanceof _cellSelection.CellSelection) {
144
144
  // Adding to an existing cell selection
145
+ if (dragAndDropEnabled) {
146
+ return false;
147
+ }
145
148
  setCellSelection(view.state.selection.$anchorCell, startEvent);
146
149
  startEvent.preventDefault();
147
150
  } else if (startEvent.shiftKey && startDOMCell && $anchor !== null && cellUnderMouse(view, startEvent).pos !== $anchor.pos) {
@@ -28,6 +28,8 @@ function tableEditing() {
28
28
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
29
29
  _ref$allowTableNodeSe = _ref.allowTableNodeSelection,
30
30
  allowTableNodeSelection = _ref$allowTableNodeSe === void 0 ? false : _ref$allowTableNodeSe,
31
+ _ref$dragAndDropEnabl = _ref.dragAndDropEnabled,
32
+ dragAndDropEnabled = _ref$dragAndDropEnabl === void 0 ? false : _ref$dragAndDropEnabl,
31
33
  reportFixedTable = _ref.reportFixedTable;
32
34
  return new _state.Plugin({
33
35
  key: _pluginKey.tableEditingKey,
@@ -56,7 +58,9 @@ function tableEditing() {
56
58
  props: {
57
59
  decorations: _drawCellSelection.drawCellSelection,
58
60
  handleDOMEvents: {
59
- mousedown: _input.handleMouseDown
61
+ mousedown: function mousedown(view, event) {
62
+ (0, _input.handleMouseDown)(view, event, dragAndDropEnabled);
63
+ }
60
64
  },
61
65
  createSelectionBetween: function createSelectionBetween(view) {
62
66
  if (_pluginKey.tableEditingKey.getState(view.state) != null) {
@@ -130,7 +130,7 @@ export function handleTripleClick(view, pos) {
130
130
  view.dispatch(view.state.tr.setSelection(new CellSelection($cell)));
131
131
  return true;
132
132
  }
133
- export function handleMouseDown(view, event) {
133
+ export function handleMouseDown(view, event, dragAndDropEnabled) {
134
134
  const startEvent = event;
135
135
  // Prevent right clicks from making a cell selection https://product-fabric.atlassian.net/browse/ED-12527
136
136
  if (startEvent.ctrlKey || startEvent.metaKey || startEvent.button === 2 // right mouse click
@@ -141,6 +141,9 @@ export function handleMouseDown(view, event) {
141
141
  const $anchor = cellAround(view.state.selection.$anchor);
142
142
  if (startEvent.shiftKey && view.state.selection instanceof CellSelection) {
143
143
  // Adding to an existing cell selection
144
+ if (dragAndDropEnabled) {
145
+ return false;
146
+ }
144
147
  setCellSelection(view.state.selection.$anchorCell, startEvent);
145
148
  startEvent.preventDefault();
146
149
  } else if (startEvent.shiftKey && startDOMCell && $anchor !== null && cellUnderMouse(view, startEvent).pos !== $anchor.pos) {
@@ -20,6 +20,7 @@ import { tableEditingKey } from './plugin-key';
20
20
  // perform more specific behavior.
21
21
  export function tableEditing({
22
22
  allowTableNodeSelection = false,
23
+ dragAndDropEnabled = false,
23
24
  reportFixedTable
24
25
  } = {}) {
25
26
  return new Plugin({
@@ -50,7 +51,9 @@ export function tableEditing({
50
51
  props: {
51
52
  decorations: drawCellSelection,
52
53
  handleDOMEvents: {
53
- mousedown: handleMouseDown
54
+ mousedown: (view, event) => {
55
+ handleMouseDown(view, event, dragAndDropEnabled);
56
+ }
54
57
  },
55
58
  createSelectionBetween(view) {
56
59
  if (tableEditingKey.getState(view.state) != null) {
@@ -123,7 +123,7 @@ export function handleTripleClick(view, pos) {
123
123
  view.dispatch(view.state.tr.setSelection(new CellSelection($cell)));
124
124
  return true;
125
125
  }
126
- export function handleMouseDown(view, event) {
126
+ export function handleMouseDown(view, event, dragAndDropEnabled) {
127
127
  var startEvent = event;
128
128
  // Prevent right clicks from making a cell selection https://product-fabric.atlassian.net/browse/ED-12527
129
129
  if (startEvent.ctrlKey || startEvent.metaKey || startEvent.button === 2 // right mouse click
@@ -134,6 +134,9 @@ export function handleMouseDown(view, event) {
134
134
  var $anchor = cellAround(view.state.selection.$anchor);
135
135
  if (startEvent.shiftKey && view.state.selection instanceof CellSelection) {
136
136
  // Adding to an existing cell selection
137
+ if (dragAndDropEnabled) {
138
+ return false;
139
+ }
137
140
  setCellSelection(view.state.selection.$anchorCell, startEvent);
138
141
  startEvent.preventDefault();
139
142
  } else if (startEvent.shiftKey && startDOMCell && $anchor !== null && cellUnderMouse(view, startEvent).pos !== $anchor.pos) {
@@ -22,6 +22,8 @@ export function tableEditing() {
22
22
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
23
23
  _ref$allowTableNodeSe = _ref.allowTableNodeSelection,
24
24
  allowTableNodeSelection = _ref$allowTableNodeSe === void 0 ? false : _ref$allowTableNodeSe,
25
+ _ref$dragAndDropEnabl = _ref.dragAndDropEnabled,
26
+ dragAndDropEnabled = _ref$dragAndDropEnabl === void 0 ? false : _ref$dragAndDropEnabl,
25
27
  reportFixedTable = _ref.reportFixedTable;
26
28
  return new Plugin({
27
29
  key: tableEditingKey,
@@ -50,7 +52,9 @@ export function tableEditing() {
50
52
  props: {
51
53
  decorations: drawCellSelection,
52
54
  handleDOMEvents: {
53
- mousedown: handleMouseDown
55
+ mousedown: function mousedown(view, event) {
56
+ handleMouseDown(view, event, dragAndDropEnabled);
57
+ }
54
58
  },
55
59
  createSelectionBetween: function createSelectionBetween(view) {
56
60
  if (tableEditingKey.getState(view.state) != null) {
@@ -1,4 +1,4 @@
1
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
1
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
2
  export declare const handleKeyDown: (view: EditorView, event: KeyboardEvent) => boolean;
3
3
  export declare function handleTripleClick(view: EditorView, pos: number): boolean;
4
- export declare function handleMouseDown(view: EditorView, event: Event): boolean;
4
+ export declare function handleMouseDown(view: EditorView, event: Event, dragAndDropEnabled: boolean): boolean;
@@ -1,8 +1,9 @@
1
1
  import { Plugin } from '@atlaskit/editor-prosemirror/state';
2
- import { ReportFixedTable } from '../utils/fix-tables';
2
+ import type { ReportFixedTable } from '../utils/fix-tables';
3
3
  type PluginState = number | null;
4
- export declare function tableEditing({ allowTableNodeSelection, reportFixedTable, }?: {
4
+ export declare function tableEditing({ allowTableNodeSelection, dragAndDropEnabled, reportFixedTable, }?: {
5
5
  allowTableNodeSelection?: boolean;
6
+ dragAndDropEnabled?: boolean;
6
7
  reportFixedTable?: ReportFixedTable;
7
8
  }): Plugin<PluginState>;
8
9
  export {};
@@ -1,4 +1,4 @@
1
- import { EditorView } from '@atlaskit/editor-prosemirror/view';
1
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
2
  export declare const handleKeyDown: (view: EditorView, event: KeyboardEvent) => boolean;
3
3
  export declare function handleTripleClick(view: EditorView, pos: number): boolean;
4
- export declare function handleMouseDown(view: EditorView, event: Event): boolean;
4
+ export declare function handleMouseDown(view: EditorView, event: Event, dragAndDropEnabled: boolean): boolean;
@@ -1,8 +1,9 @@
1
1
  import { Plugin } from '@atlaskit/editor-prosemirror/state';
2
- import { ReportFixedTable } from '../utils/fix-tables';
2
+ import type { ReportFixedTable } from '../utils/fix-tables';
3
3
  type PluginState = number | null;
4
- export declare function tableEditing({ allowTableNodeSelection, reportFixedTable, }?: {
4
+ export declare function tableEditing({ allowTableNodeSelection, dragAndDropEnabled, reportFixedTable, }?: {
5
5
  allowTableNodeSelection?: boolean;
6
+ dragAndDropEnabled?: boolean;
6
7
  reportFixedTable?: ReportFixedTable;
7
8
  }): Plugin<PluginState>;
8
9
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-tables",
3
- "version": "2.3.15",
3
+ "version": "2.3.16",
4
4
  "description": "A package that contains common classes and utility functions for editor tables",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -1,183 +0,0 @@
1
- ## API Report File for "@atlaskit/editor-tables"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
-
7
- import { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
8
- import { Mappable } from '@atlaskit/editor-prosemirror/transform';
9
- import { Mapping } from '@atlaskit/editor-prosemirror/transform';
10
- import { Node as Node_2 } from '@atlaskit/editor-prosemirror/model';
11
- import { ResolvedPos } from '@atlaskit/editor-prosemirror/model';
12
- import { Selection as Selection_2 } from '@atlaskit/editor-prosemirror/state';
13
- import { SelectionBookmark } from '@atlaskit/editor-prosemirror/state';
14
- import { Slice } from '@atlaskit/editor-prosemirror/model';
15
- import { Transaction } from '@atlaskit/editor-prosemirror/state';
16
-
17
- // @public (undocumented)
18
- type Axis = 'horiz' | 'vert';
19
-
20
- // @public (undocumented)
21
- class CellBookmark implements SelectionBookmark {
22
- constructor(anchor: number, head: number);
23
- // (undocumented)
24
- readonly anchor: number;
25
- // (undocumented)
26
- readonly head: number;
27
- // (undocumented)
28
- map(mapping: Mappable): SelectionBookmark;
29
- // (undocumented)
30
- resolve(doc: Node_2): Selection_2;
31
- }
32
-
33
- // @public (undocumented)
34
- export class CellSelection extends Selection_2 {
35
- // (undocumented)
36
- readonly $anchorCell: ResolvedPos;
37
- // (undocumented)
38
- readonly $headCell: ResolvedPos;
39
- constructor($anchorCell: ResolvedPos, $headCell?: ResolvedPos);
40
- // (undocumented)
41
- static colSelection($anchorCell: ResolvedPos, $headCell?: ResolvedPos): CellSelection;
42
- // (undocumented)
43
- content(): Slice;
44
- // (undocumented)
45
- static create(doc: Node_2, anchorCell: number, headCell?: number): CellSelection;
46
- // (undocumented)
47
- eq(other: CellSelection): boolean;
48
- // (undocumented)
49
- forEachCell(f: (node: Node_2, pos: number) => void): void;
50
- // (undocumented)
51
- static fromJSON(doc: Node_2, json: SerializedCellSelection): CellSelection;
52
- // (undocumented)
53
- getBookmark(): CellBookmark;
54
- // (undocumented)
55
- isColSelection(): boolean;
56
- // (undocumented)
57
- isRowSelection(): boolean;
58
- // (undocumented)
59
- map(doc: Node_2, mapping: Mapping): Selection_2;
60
- // (undocumented)
61
- replace(tr: Transaction, content?: Slice): void;
62
- // (undocumented)
63
- replaceWith(tr: Transaction, node: Node_2): void;
64
- // (undocumented)
65
- static rowSelection($anchorCell: ResolvedPos, $headCell?: ResolvedPos): CellSelection;
66
- // (undocumented)
67
- toJSON(): SerializedCellSelection;
68
- // (undocumented)
69
- readonly visible: boolean;
70
- }
71
-
72
- // @public (undocumented)
73
- export const findTable: (selection: Selection_2) => ContentNodeWithPos | undefined;
74
-
75
- // @public (undocumented)
76
- export class Rect {
77
- constructor(left: number, top: number, right: number, bottom: number);
78
- // (undocumented)
79
- bottom: number;
80
- // (undocumented)
81
- left: number;
82
- // (undocumented)
83
- right: number;
84
- // (undocumented)
85
- top: number;
86
- }
87
-
88
- // @public (undocumented)
89
- interface SerializedCellSelection {
90
- // (undocumented)
91
- anchor: number;
92
- // (undocumented)
93
- head: number;
94
- // (undocumented)
95
- type: 'cell';
96
- }
97
-
98
- // @public (undocumented)
99
- export class TableMap {
100
- constructor(width: number, height: number, map: number[], problems?: TableProblem[] | null);
101
- // (undocumented)
102
- cellsInRect(rect: Rect): number[];
103
- // (undocumented)
104
- colCount(pos: number): number;
105
- // (undocumented)
106
- findCell(pos: number): Rect;
107
- // (undocumented)
108
- static get(table: Node_2): TableMap;
109
- // (undocumented)
110
- getMaxColInRow(pos: ResolvedPos): number | undefined;
111
- // (undocumented)
112
- height: number;
113
- // (undocumented)
114
- isPosMerged(pos: number): boolean;
115
- // (undocumented)
116
- map: number[];
117
- // (undocumented)
118
- nextCell(pos: number, axis: Axis, dir: number): null | number;
119
- // (undocumented)
120
- positionAt(row: number, col: number, table: Node_2): number;
121
- // (undocumented)
122
- problems?: TableProblem[] | null;
123
- // (undocumented)
124
- rectBetween(a: number, b: number): Rect;
125
- // (undocumented)
126
- rowCount(pos: number): number;
127
- // (undocumented)
128
- width: number;
129
- }
130
-
131
- // @public (undocumented)
132
- type TableProblem = TableProblemColWidthMismatch | TableProblemCollision | TableProblemLongRowspan | TableProblemMissing;
133
-
134
- // @public (undocumented)
135
- type TableProblemCollision = {
136
- type: TableProblemTypes.COLLISION;
137
- row: number;
138
- pos: number;
139
- n: number;
140
- };
141
-
142
- // @public (undocumented)
143
- type TableProblemColWidthMismatch = {
144
- type: TableProblemTypes;
145
- pos: number;
146
- colwidth: number;
147
- };
148
-
149
- // @public (undocumented)
150
- type TableProblemLongRowspan = {
151
- type: TableProblemTypes.OVERLONG_ROWSPAN;
152
- pos: number;
153
- n: number;
154
- };
155
-
156
- // @public (undocumented)
157
- type TableProblemMissing = {
158
- type: TableProblemTypes.MISSING;
159
- row: number;
160
- n: number;
161
- };
162
-
163
- // @public (undocumented)
164
- enum TableProblemTypes {
165
- // (undocumented)
166
- COLLISION = "collision",
167
- // (undocumented)
168
- COLWIDTH_MISMATCH = "colwidth mismatch",
169
- // (undocumented)
170
- MISSING = "missing",
171
- // (undocumented)
172
- OVERLONG_ROWSPAN = "overlong_rowspan"
173
- }
174
-
175
- // @public (undocumented)
176
- export const uuid: {
177
- setStatic(value: false | string): void;
178
- generate(): string;
179
- };
180
-
181
- // (No @packageDocumentation comment for this package)
182
-
183
- ```