@atlaskit/editor-tables 2.9.11 → 2.9.13

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,20 @@
1
1
  # @atlaskit/editor-tables
2
2
 
3
+ ## 2.9.13
4
+
5
+ ### Patch Changes
6
+
7
+ - [`0fdcb6f2f96fd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0fdcb6f2f96fd) -
8
+ Sorted type and interface props to improve Atlaskit docs
9
+ - Updated dependencies
10
+
11
+ ## 2.9.12
12
+
13
+ ### Patch Changes
14
+
15
+ - [`d99dd614bde90`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d99dd614bde90) -
16
+ Add reverse selection support to rowSelection
17
+
3
18
  ## 2.9.11
4
19
 
5
20
  ### Patch Changes
@@ -3,9 +3,9 @@
3
3
  "compilerOptions": {
4
4
  "declaration": true,
5
5
  "target": "es5",
6
- "composite": true,
7
6
  "outDir": "../../../../../confluence/tsDist/@atlaskit__editor-tables",
8
- "rootDir": "../"
7
+ "rootDir": "../",
8
+ "composite": true
9
9
  },
10
10
  "include": [
11
11
  "../src/**/*.ts",
@@ -307,6 +307,7 @@ var CellSelection = exports.CellSelection = /*#__PURE__*/function (_Selection) {
307
307
  key: "rowSelection",
308
308
  value: function rowSelection($anchorCell) {
309
309
  var $headCell = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $anchorCell;
310
+ var reverse = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
310
311
  var $calculatedAnchorCell = $anchorCell;
311
312
  var $calculatedHeadCell = $headCell;
312
313
  var map = _tableMap.TableMap.get($calculatedAnchorCell.node(-1));
@@ -329,7 +330,7 @@ var CellSelection = exports.CellSelection = /*#__PURE__*/function (_Selection) {
329
330
  $calculatedAnchorCell = doc.resolve(start + map.map[map.width * (anchorRect.top + 1) - 1]);
330
331
  }
331
332
  }
332
- return new CellSelection($calculatedAnchorCell, $calculatedHeadCell);
333
+ return reverse ? new CellSelection($calculatedHeadCell, $calculatedAnchorCell) : new CellSelection($calculatedAnchorCell, $calculatedHeadCell);
333
334
  }
334
335
  }, {
335
336
  key: "fromJSON",
@@ -258,7 +258,7 @@ export class CellSelection extends Selection {
258
258
  // :: (ResolvedPos, ?ResolvedPos) → CellSelection
259
259
  // Returns the smallest row selection that covers the given anchor
260
260
  // and head cell.
261
- static rowSelection($anchorCell, $headCell = $anchorCell) {
261
+ static rowSelection($anchorCell, $headCell = $anchorCell, reverse = false) {
262
262
  let $calculatedAnchorCell = $anchorCell;
263
263
  let $calculatedHeadCell = $headCell;
264
264
  const map = TableMap.get($calculatedAnchorCell.node(-1));
@@ -281,7 +281,7 @@ export class CellSelection extends Selection {
281
281
  $calculatedAnchorCell = doc.resolve(start + map.map[map.width * (anchorRect.top + 1) - 1]);
282
282
  }
283
283
  }
284
- return new CellSelection($calculatedAnchorCell, $calculatedHeadCell);
284
+ return reverse ? new CellSelection($calculatedHeadCell, $calculatedAnchorCell) : new CellSelection($calculatedAnchorCell, $calculatedHeadCell);
285
285
  }
286
286
  toJSON() {
287
287
  return {
@@ -306,6 +306,7 @@ export var CellSelection = /*#__PURE__*/function (_Selection) {
306
306
  key: "rowSelection",
307
307
  value: function rowSelection($anchorCell) {
308
308
  var $headCell = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $anchorCell;
309
+ var reverse = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
309
310
  var $calculatedAnchorCell = $anchorCell;
310
311
  var $calculatedHeadCell = $headCell;
311
312
  var map = TableMap.get($calculatedAnchorCell.node(-1));
@@ -328,7 +329,7 @@ export var CellSelection = /*#__PURE__*/function (_Selection) {
328
329
  $calculatedAnchorCell = doc.resolve(start + map.map[map.width * (anchorRect.top + 1) - 1]);
329
330
  }
330
331
  }
331
- return new CellSelection($calculatedAnchorCell, $calculatedHeadCell);
332
+ return reverse ? new CellSelection($calculatedHeadCell, $calculatedAnchorCell) : new CellSelection($calculatedAnchorCell, $calculatedHeadCell);
332
333
  }
333
334
  }, {
334
335
  key: "fromJSON",
@@ -17,7 +17,7 @@ export declare class CellSelection extends Selection {
17
17
  static colSelection($anchorCell: ResolvedPos, $headCell?: ResolvedPos): CellSelection;
18
18
  isRowSelection(): boolean;
19
19
  eq(other: CellSelection): boolean;
20
- static rowSelection($anchorCell: ResolvedPos, $headCell?: ResolvedPos): CellSelection;
20
+ static rowSelection($anchorCell: ResolvedPos, $headCell?: ResolvedPos, reverse?: boolean): CellSelection;
21
21
  toJSON(): SerializedCellSelection;
22
22
  static fromJSON(doc: PMNode, json: SerializedCellSelection): CellSelection;
23
23
  static create(doc: PMNode, anchorCell: number, headCell?: number): CellSelection;
@@ -9,13 +9,13 @@ export declare class Rect {
9
9
  }
10
10
  export interface TableRect extends Rect {
11
11
  map: TableMap;
12
- tableStart: number;
13
12
  table: PMNode;
13
+ tableStart: number;
14
14
  }
15
15
  export type TableContext = {
16
16
  map: TableMap;
17
- tableStart: number;
18
17
  table: PMNode;
18
+ tableStart: number;
19
19
  };
20
20
  export declare enum TableProblemTypes {
21
21
  COLLISION = "collision",
@@ -24,25 +24,25 @@ export declare enum TableProblemTypes {
24
24
  COLWIDTH_MISMATCH = "colwidth mismatch"
25
25
  }
26
26
  export type TableProblemCollision = {
27
- type: TableProblemTypes.COLLISION;
28
- row: number;
29
- pos: number;
30
27
  n: number;
28
+ pos: number;
29
+ row: number;
30
+ type: TableProblemTypes.COLLISION;
31
31
  };
32
32
  export type TableProblemLongRowspan = {
33
- type: TableProblemTypes.OVERLONG_ROWSPAN;
34
- pos: number;
35
33
  n: number;
34
+ pos: number;
35
+ type: TableProblemTypes.OVERLONG_ROWSPAN;
36
36
  };
37
37
  export type TableProblemMissing = {
38
- type: TableProblemTypes.MISSING;
39
- row: number;
40
38
  n: number;
39
+ row: number;
40
+ type: TableProblemTypes.MISSING;
41
41
  };
42
42
  export type TableProblemColWidthMismatch = {
43
- type: TableProblemTypes;
44
- pos: number;
45
43
  colwidth: number;
44
+ pos: number;
45
+ type: TableProblemTypes;
46
46
  };
47
47
  export type TableProblem = TableProblemCollision | TableProblemLongRowspan | TableProblemMissing | TableProblemColWidthMismatch;
48
48
  export declare const tableNewColumnMinWidth = 140;
@@ -2,24 +2,24 @@ import type { Fragment, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  export interface CellAttributes {
5
+ background?: string;
5
6
  colspan?: number;
6
- rowspan?: number;
7
7
  colwidth?: number[];
8
- background?: string;
8
+ rowspan?: number;
9
9
  }
10
10
  export interface SelectionBounds {
11
11
  $from: ResolvedPos;
12
12
  $to: ResolvedPos;
13
13
  }
14
14
  export interface SerializedCellSelection {
15
- type: 'cell';
16
15
  anchor: number;
17
16
  head: number;
17
+ type: 'cell';
18
18
  }
19
19
  export interface CellSelectionRect {
20
20
  height: number;
21
- width: number;
22
21
  rows: Fragment[];
22
+ width: number;
23
23
  }
24
24
  export type Axis = 'horiz' | 'vert';
25
25
  export type Direction = -1 | 1;
@@ -38,12 +38,12 @@ export type Writeable<T> = {
38
38
  -readonly [P in keyof T]: T[P];
39
39
  };
40
40
  export interface MoveOptions {
41
- tryToFit?: boolean;
42
41
  direction?: number;
43
42
  selectAfterMove?: boolean;
43
+ tryToFit?: boolean;
44
44
  }
45
45
  export interface CloneOptions {
46
- tryToFit?: boolean;
47
46
  direction?: number;
48
47
  selectAfterClone?: boolean;
48
+ tryToFit?: boolean;
49
49
  }
@@ -2,6 +2,6 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { TableMap } from '../table-map';
3
3
  import type { TableNodeCache } from './table-node-types';
4
4
  export declare function determineTableHeaderStateFromTableNode(table: PMNode, tableMap: TableMap, types: TableNodeCache): {
5
- rowHeaderEnabled: boolean;
6
5
  columnHeaderEnabled: boolean;
6
+ rowHeaderEnabled: boolean;
7
7
  };
@@ -2,10 +2,10 @@ import { type Selection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { TableMap } from '../table-map';
3
3
  import { findTable } from './find';
4
4
  export declare function getSelectedTableInfo(selection: Selection): {
5
- table: ReturnType<typeof findTable> | undefined;
6
5
  map: TableMap | undefined;
7
- totalRowCount: number;
6
+ table: ReturnType<typeof findTable> | undefined;
8
7
  totalColumnCount: number;
8
+ totalRowCount: number;
9
9
  };
10
10
  export declare function getSelectedCellInfo(selection: Selection): {
11
11
  totalRowCount: number;
@@ -1,12 +1,12 @@
1
1
  import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  type CreateTableProps = {
3
- schema: Schema;
4
- rowsCount?: number;
5
- colsCount?: number;
6
- withHeaderRow?: boolean;
7
3
  cellContent?: PMNode;
8
- tableWidth?: number | 'inherit';
4
+ colsCount?: number;
9
5
  layout?: string;
6
+ rowsCount?: number;
7
+ schema: Schema;
8
+ tableWidth?: number | 'inherit';
9
+ withHeaderRow?: boolean;
10
10
  };
11
11
  export declare const createTable: ({ schema, rowsCount, colsCount, withHeaderRow, cellContent, tableWidth, layout, }: CreateTableProps) => PMNode;
12
12
  export {};
@@ -1,9 +1,9 @@
1
1
  import { type Node } from '@atlaskit/editor-prosemirror/model';
2
2
  import { type EditorState, type Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  export type ReportFixedTable = ({ state, tr, reason, }: {
4
+ reason: string;
4
5
  state: EditorState;
5
6
  tr: Transaction;
6
- reason: string;
7
7
  }) => void;
8
8
  export declare function fixTables(state: EditorState, oldState?: EditorState, reportFixedTable?: ReportFixedTable): Transaction | undefined;
9
9
  export declare function fixTable(state: EditorState, table: Node, tablePos: number, transaction?: Transaction, reportFixedTable?: ReportFixedTable): Transaction | undefined;
@@ -2,9 +2,9 @@ import { type NodeType, type Node as PMNode, ResolvedPos } from '@atlaskit/edito
2
2
  import { type Command } from '../types';
3
3
  export declare function cellWrapping($pos: ResolvedPos): PMNode | null;
4
4
  export type GetCellTypeArgs = {
5
- row: number;
6
5
  col: number;
7
6
  node: PMNode;
7
+ row: number;
8
8
  };
9
9
  type GetCellTypeCallback = (option: GetCellTypeArgs) => NodeType;
10
10
  export declare function splitCellWithType(getCellType: GetCellTypeCallback): Command;
@@ -17,7 +17,7 @@ export declare class CellSelection extends Selection {
17
17
  static colSelection($anchorCell: ResolvedPos, $headCell?: ResolvedPos): CellSelection;
18
18
  isRowSelection(): boolean;
19
19
  eq(other: CellSelection): boolean;
20
- static rowSelection($anchorCell: ResolvedPos, $headCell?: ResolvedPos): CellSelection;
20
+ static rowSelection($anchorCell: ResolvedPos, $headCell?: ResolvedPos, reverse?: boolean): CellSelection;
21
21
  toJSON(): SerializedCellSelection;
22
22
  static fromJSON(doc: PMNode, json: SerializedCellSelection): CellSelection;
23
23
  static create(doc: PMNode, anchorCell: number, headCell?: number): CellSelection;
@@ -9,13 +9,13 @@ export declare class Rect {
9
9
  }
10
10
  export interface TableRect extends Rect {
11
11
  map: TableMap;
12
- tableStart: number;
13
12
  table: PMNode;
13
+ tableStart: number;
14
14
  }
15
15
  export type TableContext = {
16
16
  map: TableMap;
17
- tableStart: number;
18
17
  table: PMNode;
18
+ tableStart: number;
19
19
  };
20
20
  export declare enum TableProblemTypes {
21
21
  COLLISION = "collision",
@@ -24,25 +24,25 @@ export declare enum TableProblemTypes {
24
24
  COLWIDTH_MISMATCH = "colwidth mismatch"
25
25
  }
26
26
  export type TableProblemCollision = {
27
- type: TableProblemTypes.COLLISION;
28
- row: number;
29
- pos: number;
30
27
  n: number;
28
+ pos: number;
29
+ row: number;
30
+ type: TableProblemTypes.COLLISION;
31
31
  };
32
32
  export type TableProblemLongRowspan = {
33
- type: TableProblemTypes.OVERLONG_ROWSPAN;
34
- pos: number;
35
33
  n: number;
34
+ pos: number;
35
+ type: TableProblemTypes.OVERLONG_ROWSPAN;
36
36
  };
37
37
  export type TableProblemMissing = {
38
- type: TableProblemTypes.MISSING;
39
- row: number;
40
38
  n: number;
39
+ row: number;
40
+ type: TableProblemTypes.MISSING;
41
41
  };
42
42
  export type TableProblemColWidthMismatch = {
43
- type: TableProblemTypes;
44
- pos: number;
45
43
  colwidth: number;
44
+ pos: number;
45
+ type: TableProblemTypes;
46
46
  };
47
47
  export type TableProblem = TableProblemCollision | TableProblemLongRowspan | TableProblemMissing | TableProblemColWidthMismatch;
48
48
  export declare const tableNewColumnMinWidth = 140;
@@ -2,24 +2,24 @@ import type { Fragment, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
4
4
  export interface CellAttributes {
5
+ background?: string;
5
6
  colspan?: number;
6
- rowspan?: number;
7
7
  colwidth?: number[];
8
- background?: string;
8
+ rowspan?: number;
9
9
  }
10
10
  export interface SelectionBounds {
11
11
  $from: ResolvedPos;
12
12
  $to: ResolvedPos;
13
13
  }
14
14
  export interface SerializedCellSelection {
15
- type: 'cell';
16
15
  anchor: number;
17
16
  head: number;
17
+ type: 'cell';
18
18
  }
19
19
  export interface CellSelectionRect {
20
20
  height: number;
21
- width: number;
22
21
  rows: Fragment[];
22
+ width: number;
23
23
  }
24
24
  export type Axis = 'horiz' | 'vert';
25
25
  export type Direction = -1 | 1;
@@ -38,12 +38,12 @@ export type Writeable<T> = {
38
38
  -readonly [P in keyof T]: T[P];
39
39
  };
40
40
  export interface MoveOptions {
41
- tryToFit?: boolean;
42
41
  direction?: number;
43
42
  selectAfterMove?: boolean;
43
+ tryToFit?: boolean;
44
44
  }
45
45
  export interface CloneOptions {
46
- tryToFit?: boolean;
47
46
  direction?: number;
48
47
  selectAfterClone?: boolean;
48
+ tryToFit?: boolean;
49
49
  }
@@ -2,6 +2,6 @@ import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
2
  import type { TableMap } from '../table-map';
3
3
  import type { TableNodeCache } from './table-node-types';
4
4
  export declare function determineTableHeaderStateFromTableNode(table: PMNode, tableMap: TableMap, types: TableNodeCache): {
5
- rowHeaderEnabled: boolean;
6
5
  columnHeaderEnabled: boolean;
6
+ rowHeaderEnabled: boolean;
7
7
  };
@@ -2,10 +2,10 @@ import { type Selection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { TableMap } from '../table-map';
3
3
  import { findTable } from './find';
4
4
  export declare function getSelectedTableInfo(selection: Selection): {
5
- table: ReturnType<typeof findTable> | undefined;
6
5
  map: TableMap | undefined;
7
- totalRowCount: number;
6
+ table: ReturnType<typeof findTable> | undefined;
8
7
  totalColumnCount: number;
8
+ totalRowCount: number;
9
9
  };
10
10
  export declare function getSelectedCellInfo(selection: Selection): {
11
11
  totalRowCount: number;
@@ -1,12 +1,12 @@
1
1
  import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  type CreateTableProps = {
3
- schema: Schema;
4
- rowsCount?: number;
5
- colsCount?: number;
6
- withHeaderRow?: boolean;
7
3
  cellContent?: PMNode;
8
- tableWidth?: number | 'inherit';
4
+ colsCount?: number;
9
5
  layout?: string;
6
+ rowsCount?: number;
7
+ schema: Schema;
8
+ tableWidth?: number | 'inherit';
9
+ withHeaderRow?: boolean;
10
10
  };
11
11
  export declare const createTable: ({ schema, rowsCount, colsCount, withHeaderRow, cellContent, tableWidth, layout, }: CreateTableProps) => PMNode;
12
12
  export {};
@@ -1,9 +1,9 @@
1
1
  import { type Node } from '@atlaskit/editor-prosemirror/model';
2
2
  import { type EditorState, type Transaction } from '@atlaskit/editor-prosemirror/state';
3
3
  export type ReportFixedTable = ({ state, tr, reason, }: {
4
+ reason: string;
4
5
  state: EditorState;
5
6
  tr: Transaction;
6
- reason: string;
7
7
  }) => void;
8
8
  export declare function fixTables(state: EditorState, oldState?: EditorState, reportFixedTable?: ReportFixedTable): Transaction | undefined;
9
9
  export declare function fixTable(state: EditorState, table: Node, tablePos: number, transaction?: Transaction, reportFixedTable?: ReportFixedTable): Transaction | undefined;
@@ -2,9 +2,9 @@ import { type NodeType, type Node as PMNode, ResolvedPos } from '@atlaskit/edito
2
2
  import { type Command } from '../types';
3
3
  export declare function cellWrapping($pos: ResolvedPos): PMNode | null;
4
4
  export type GetCellTypeArgs = {
5
- row: number;
6
5
  col: number;
7
6
  node: PMNode;
7
+ row: number;
8
8
  };
9
9
  type GetCellTypeCallback = (option: GetCellTypeArgs) => NodeType;
10
10
  export declare function splitCellWithType(getCellType: GetCellTypeCallback): Command;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-tables",
3
- "version": "2.9.11",
3
+ "version": "2.9.13",
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/"
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@atlaskit/editor-prosemirror": "7.0.0",
31
31
  "@atlaskit/platform-feature-flags": "^1.1.0",
32
- "@atlaskit/tmp-editor-statsig": "^11.0.0",
32
+ "@atlaskit/tmp-editor-statsig": "^11.6.0",
33
33
  "@babel/runtime": "^7.0.0"
34
34
  },
35
35
  "techstack": {