@atlaskit/editor-tables 2.3.5 → 2.3.6

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.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`5f5ba16de66`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5f5ba16de66) - [ED-13910] Fix prosemirror types
8
+
3
9
  ## 2.3.5
4
10
 
5
11
  ### Patch Changes
@@ -326,7 +326,7 @@ function applyHeaderCells(tr, tableMap, state, tableStart, table, headerRowEnabl
326
326
  var cell = tr.doc.nodeAt(cellPos);
327
327
  var newType = headerEnabled ? schema.nodes.tableHeader : schema.nodes.tableCell;
328
328
  var isCellTypeChanged = newType !== (cell === null || cell === void 0 ? void 0 : cell.type);
329
- var isCellTypeValid = [schema.nodes.tableCell, schema.nodes.tableHeader].includes(cell === null || cell === void 0 ? void 0 : cell.type);
329
+ var isCellTypeValid = !!cell && [schema.nodes.tableCell, schema.nodes.tableHeader].includes(cell.type);
330
330
  if (isCellTypeChanged && isCellTypeValid) {
331
331
  tr.setNodeMarkup(cellPos, newType, cell === null || cell === void 0 ? void 0 : cell.attrs, cell === null || cell === void 0 ? void 0 : cell.marks);
332
332
  }
@@ -96,7 +96,8 @@ function splitCellWithType(getCellType) {
96
96
  }
97
97
  var $lastCellPosition = lastCell && tr.doc.resolve(lastCell);
98
98
  if (sel instanceof _cellSelection.CellSelection && $lastCellPosition instanceof _prosemirrorModel.ResolvedPos) {
99
- tr.setSelection(new _cellSelection.CellSelection(tr.doc.resolve(sel.$anchorCell.pos), $lastCellPosition));
99
+ var cellSelection = new _cellSelection.CellSelection(tr.doc.resolve(sel.$anchorCell.pos), $lastCellPosition);
100
+ tr.setSelection(cellSelection);
100
101
  }
101
102
  dispatch(tr);
102
103
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-tables",
3
- "version": "2.3.5",
3
+ "version": "2.3.6",
4
4
  "sideEffects": false
5
5
  }
@@ -329,7 +329,7 @@ function applyHeaderCells(tr, tableMap, state, tableStart, table, headerRowEnabl
329
329
  const cell = tr.doc.nodeAt(cellPos);
330
330
  const newType = headerEnabled ? schema.nodes.tableHeader : schema.nodes.tableCell;
331
331
  const isCellTypeChanged = newType !== (cell === null || cell === void 0 ? void 0 : cell.type);
332
- const isCellTypeValid = [schema.nodes.tableCell, schema.nodes.tableHeader].includes(cell === null || cell === void 0 ? void 0 : cell.type);
332
+ const isCellTypeValid = !!cell && [schema.nodes.tableCell, schema.nodes.tableHeader].includes(cell.type);
333
333
  if (isCellTypeChanged && isCellTypeValid) {
334
334
  tr.setNodeMarkup(cellPos, newType, cell === null || cell === void 0 ? void 0 : cell.attrs, cell === null || cell === void 0 ? void 0 : cell.marks);
335
335
  }
@@ -88,7 +88,8 @@ export function splitCellWithType(getCellType) {
88
88
  }
89
89
  const $lastCellPosition = lastCell && tr.doc.resolve(lastCell);
90
90
  if (sel instanceof CellSelection && $lastCellPosition instanceof ResolvedPos) {
91
- tr.setSelection(new CellSelection(tr.doc.resolve(sel.$anchorCell.pos), $lastCellPosition));
91
+ const cellSelection = new CellSelection(tr.doc.resolve(sel.$anchorCell.pos), $lastCellPosition);
92
+ tr.setSelection(cellSelection);
92
93
  }
93
94
  dispatch(tr);
94
95
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-tables",
3
- "version": "2.3.5",
3
+ "version": "2.3.6",
4
4
  "sideEffects": false
5
5
  }
@@ -320,7 +320,7 @@ function applyHeaderCells(tr, tableMap, state, tableStart, table, headerRowEnabl
320
320
  var cell = tr.doc.nodeAt(cellPos);
321
321
  var newType = headerEnabled ? schema.nodes.tableHeader : schema.nodes.tableCell;
322
322
  var isCellTypeChanged = newType !== (cell === null || cell === void 0 ? void 0 : cell.type);
323
- var isCellTypeValid = [schema.nodes.tableCell, schema.nodes.tableHeader].includes(cell === null || cell === void 0 ? void 0 : cell.type);
323
+ var isCellTypeValid = !!cell && [schema.nodes.tableCell, schema.nodes.tableHeader].includes(cell.type);
324
324
  if (isCellTypeChanged && isCellTypeValid) {
325
325
  tr.setNodeMarkup(cellPos, newType, cell === null || cell === void 0 ? void 0 : cell.attrs, cell === null || cell === void 0 ? void 0 : cell.marks);
326
326
  }
@@ -88,7 +88,8 @@ export function splitCellWithType(getCellType) {
88
88
  }
89
89
  var $lastCellPosition = lastCell && tr.doc.resolve(lastCell);
90
90
  if (sel instanceof CellSelection && $lastCellPosition instanceof ResolvedPos) {
91
- tr.setSelection(new CellSelection(tr.doc.resolve(sel.$anchorCell.pos), $lastCellPosition));
91
+ var cellSelection = new CellSelection(tr.doc.resolve(sel.$anchorCell.pos), $lastCellPosition);
92
+ tr.setSelection(cellSelection);
92
93
  }
93
94
  dispatch(tr);
94
95
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-tables",
3
- "version": "2.3.5",
3
+ "version": "2.3.6",
4
4
  "sideEffects": false
5
5
  }
@@ -1,10 +1,10 @@
1
1
  import { Node as PMNode } from 'prosemirror-model';
2
- import { Selection } from 'prosemirror-state';
3
- import { Mapping } from 'prosemirror-transform';
4
- export declare class CellBookmark {
2
+ import { Selection, SelectionBookmark } from 'prosemirror-state';
3
+ import { Mappable } from 'prosemirror-transform';
4
+ export declare class CellBookmark implements SelectionBookmark {
5
5
  readonly anchor: number;
6
6
  readonly head: number;
7
7
  constructor(anchor: number, head: number);
8
- map(mapping: Mapping): CellBookmark;
8
+ map(mapping: Mappable): SelectionBookmark;
9
9
  resolve(doc: PMNode): Selection;
10
10
  }
@@ -10,7 +10,7 @@ export declare class CellSelection extends Selection {
10
10
  constructor($anchorCell: ResolvedPos, $headCell?: ResolvedPos);
11
11
  map(doc: PMNode, mapping: Mapping): Selection;
12
12
  content(): Slice;
13
- replace(tr: Transaction, content?: Slice<any>): void;
13
+ replace(tr: Transaction, content?: Slice): void;
14
14
  replaceWith(tr: Transaction, node: PMNode): void;
15
15
  forEachCell(f: (node: PMNode, pos: number) => void): void;
16
16
  isColSelection(): boolean;
@@ -1,4 +1,4 @@
1
1
  import { EditorView } from 'prosemirror-view';
2
- export declare const handleKeyDown: (view: EditorView<any>, event: Event) => boolean;
2
+ export declare const handleKeyDown: (view: EditorView, event: Event) => boolean;
3
3
  export declare function handleTripleClick(view: EditorView, pos: number): boolean;
4
4
  export declare function handleMouseDown(view: EditorView, event: Event): boolean;
@@ -1,3 +1,3 @@
1
1
  import { PluginKey } from 'prosemirror-state';
2
- export declare const tableEditingKey: PluginKey<any, any>;
3
- export declare const fixTablesKey: PluginKey<any, any>;
2
+ export declare const tableEditingKey: PluginKey<any>;
3
+ export declare const fixTablesKey: PluginKey<any>;
@@ -34,3 +34,6 @@ export type SelectionRange = {
34
34
  export type CellAttributesWithColSpan = CellAttributes & {
35
35
  colspan: number;
36
36
  };
37
+ export type Writeable<T> = {
38
+ -readonly [P in keyof T]: T[P];
39
+ };
@@ -1,6 +1,65 @@
1
+ /// <reference path="../../../../../../typings/prosemirror.d.ts" />
1
2
  import { ResolvedPos } from 'prosemirror-model';
2
3
  import { Axis } from '../types';
3
- export declare function pointsAtCell($pos: ResolvedPos): false | import("prosemirror-model").Node<any> | null | undefined;
4
+ export declare function pointsAtCell($pos: ResolvedPos): false | {
5
+ type: import("prosemirror-model").NodeType;
6
+ attrs: {
7
+ [key: string]: any;
8
+ };
9
+ content: import("prosemirror-model").Fragment;
10
+ marks: import("prosemirror-model").Mark[];
11
+ text?: string | null | undefined;
12
+ nodeSize: number;
13
+ childCount: number;
14
+ child(index: number): any;
15
+ maybeChild(index: number): any | null | undefined;
16
+ forEach(f: (node: any, offset: number, index: number) => void): void;
17
+ nodesBetween(from: number, to: number, f: (node: any, pos: number, parent: any, index: number) => boolean | void | null | undefined, startPos?: number | undefined): void;
18
+ descendants(f: (node: any, pos: number, parent: any) => boolean | void | null | undefined): void;
19
+ textContent: string;
20
+ textBetween(from: number, to: number, blockSeparator?: string | undefined, leafText?: string | undefined): string;
21
+ firstChild?: any | null | undefined;
22
+ lastChild?: any | null | undefined;
23
+ eq(other: any): boolean;
24
+ sameMarkup(other: any): boolean;
25
+ hasMarkup(type: import("prosemirror-model").NodeType, attrs?: {
26
+ [key: string]: any;
27
+ } | undefined, marks?: import("prosemirror-model").Mark[] | undefined): boolean;
28
+ copy(content?: import("prosemirror-model").Fragment | undefined): any;
29
+ mark(marks: import("prosemirror-model").Mark[]): any;
30
+ cut(from: number, to?: number | undefined): any;
31
+ slice(from: number, to?: number | undefined): import("prosemirror-model").Slice;
32
+ replace(from: number, to: number, slice: import("prosemirror-model").Slice): any;
33
+ nodeAt(pos: number): any | null | undefined;
34
+ childAfter(pos: number): {
35
+ node?: any | null | undefined;
36
+ index: number;
37
+ offset: number;
38
+ };
39
+ childBefore(pos: number): {
40
+ node?: any | null | undefined;
41
+ index: number;
42
+ offset: number;
43
+ };
44
+ resolve(pos: number): ResolvedPos;
45
+ rangeHasMark(from: number, to: number, type: import("prosemirror-model").Mark | import("prosemirror-model").MarkType): boolean;
46
+ isBlock: boolean;
47
+ isTextblock: boolean;
48
+ inlineContent: boolean;
49
+ isInline: boolean;
50
+ isText: boolean;
51
+ isLeaf: boolean;
52
+ isAtom: boolean;
53
+ toString(): string;
54
+ contentMatchAt(index: number): import("prosemirror-model").ContentMatch;
55
+ canReplace(from: number, to: number, replacement?: import("prosemirror-model").Fragment | undefined, start?: number | undefined, end?: number | undefined): boolean;
56
+ canReplaceWith(from: number, to: number, type: import("prosemirror-model").NodeType, marks?: import("prosemirror-model").Mark[] | undefined): boolean;
57
+ canAppend(other: any): boolean;
58
+ check(): void;
59
+ toJSON(): {
60
+ [key: string]: any;
61
+ };
62
+ } | null | undefined;
4
63
  export declare function cellNear($pos: ResolvedPos): ResolvedPos | null;
5
64
  export declare function cellAround($pos: ResolvedPos): ResolvedPos | null;
6
65
  export declare function nextCell($pos: ResolvedPos, axis: Axis, dir: number): ResolvedPos | null;
@@ -1,10 +1,10 @@
1
1
  import { Node as PMNode } from 'prosemirror-model';
2
- import { Selection } from 'prosemirror-state';
3
- import { Mapping } from 'prosemirror-transform';
4
- export declare class CellBookmark {
2
+ import { Selection, SelectionBookmark } from 'prosemirror-state';
3
+ import { Mappable } from 'prosemirror-transform';
4
+ export declare class CellBookmark implements SelectionBookmark {
5
5
  readonly anchor: number;
6
6
  readonly head: number;
7
7
  constructor(anchor: number, head: number);
8
- map(mapping: Mapping): CellBookmark;
8
+ map(mapping: Mappable): SelectionBookmark;
9
9
  resolve(doc: PMNode): Selection;
10
10
  }
@@ -10,7 +10,7 @@ export declare class CellSelection extends Selection {
10
10
  constructor($anchorCell: ResolvedPos, $headCell?: ResolvedPos);
11
11
  map(doc: PMNode, mapping: Mapping): Selection;
12
12
  content(): Slice;
13
- replace(tr: Transaction, content?: Slice<any>): void;
13
+ replace(tr: Transaction, content?: Slice): void;
14
14
  replaceWith(tr: Transaction, node: PMNode): void;
15
15
  forEachCell(f: (node: PMNode, pos: number) => void): void;
16
16
  isColSelection(): boolean;
@@ -1,4 +1,4 @@
1
1
  import { EditorView } from 'prosemirror-view';
2
- export declare const handleKeyDown: (view: EditorView<any>, event: Event) => boolean;
2
+ export declare const handleKeyDown: (view: EditorView, event: Event) => boolean;
3
3
  export declare function handleTripleClick(view: EditorView, pos: number): boolean;
4
4
  export declare function handleMouseDown(view: EditorView, event: Event): boolean;
@@ -1,3 +1,3 @@
1
1
  import { PluginKey } from 'prosemirror-state';
2
- export declare const tableEditingKey: PluginKey<any, any>;
3
- export declare const fixTablesKey: PluginKey<any, any>;
2
+ export declare const tableEditingKey: PluginKey<any>;
3
+ export declare const fixTablesKey: PluginKey<any>;
@@ -34,3 +34,6 @@ export type SelectionRange = {
34
34
  export type CellAttributesWithColSpan = CellAttributes & {
35
35
  colspan: number;
36
36
  };
37
+ export type Writeable<T> = {
38
+ -readonly [P in keyof T]: T[P];
39
+ };
@@ -1,6 +1,65 @@
1
+ /// <reference path="../../../../../../typings/prosemirror.d.ts" />
1
2
  import { ResolvedPos } from 'prosemirror-model';
2
3
  import { Axis } from '../types';
3
- export declare function pointsAtCell($pos: ResolvedPos): false | import("prosemirror-model").Node<any> | null | undefined;
4
+ export declare function pointsAtCell($pos: ResolvedPos): false | {
5
+ type: import("prosemirror-model").NodeType;
6
+ attrs: {
7
+ [key: string]: any;
8
+ };
9
+ content: import("prosemirror-model").Fragment;
10
+ marks: import("prosemirror-model").Mark[];
11
+ text?: string | null | undefined;
12
+ nodeSize: number;
13
+ childCount: number;
14
+ child(index: number): any;
15
+ maybeChild(index: number): any | null | undefined;
16
+ forEach(f: (node: any, offset: number, index: number) => void): void;
17
+ nodesBetween(from: number, to: number, f: (node: any, pos: number, parent: any, index: number) => boolean | void | null | undefined, startPos?: number | undefined): void;
18
+ descendants(f: (node: any, pos: number, parent: any) => boolean | void | null | undefined): void;
19
+ textContent: string;
20
+ textBetween(from: number, to: number, blockSeparator?: string | undefined, leafText?: string | undefined): string;
21
+ firstChild?: any | null | undefined;
22
+ lastChild?: any | null | undefined;
23
+ eq(other: any): boolean;
24
+ sameMarkup(other: any): boolean;
25
+ hasMarkup(type: import("prosemirror-model").NodeType, attrs?: {
26
+ [key: string]: any;
27
+ } | undefined, marks?: import("prosemirror-model").Mark[] | undefined): boolean;
28
+ copy(content?: import("prosemirror-model").Fragment | undefined): any;
29
+ mark(marks: import("prosemirror-model").Mark[]): any;
30
+ cut(from: number, to?: number | undefined): any;
31
+ slice(from: number, to?: number | undefined): import("prosemirror-model").Slice;
32
+ replace(from: number, to: number, slice: import("prosemirror-model").Slice): any;
33
+ nodeAt(pos: number): any | null | undefined;
34
+ childAfter(pos: number): {
35
+ node?: any | null | undefined;
36
+ index: number;
37
+ offset: number;
38
+ };
39
+ childBefore(pos: number): {
40
+ node?: any | null | undefined;
41
+ index: number;
42
+ offset: number;
43
+ };
44
+ resolve(pos: number): ResolvedPos;
45
+ rangeHasMark(from: number, to: number, type: import("prosemirror-model").Mark | import("prosemirror-model").MarkType): boolean;
46
+ isBlock: boolean;
47
+ isTextblock: boolean;
48
+ inlineContent: boolean;
49
+ isInline: boolean;
50
+ isText: boolean;
51
+ isLeaf: boolean;
52
+ isAtom: boolean;
53
+ toString(): string;
54
+ contentMatchAt(index: number): import("prosemirror-model").ContentMatch;
55
+ canReplace(from: number, to: number, replacement?: import("prosemirror-model").Fragment | undefined, start?: number | undefined, end?: number | undefined): boolean;
56
+ canReplaceWith(from: number, to: number, type: import("prosemirror-model").NodeType, marks?: import("prosemirror-model").Mark[] | undefined): boolean;
57
+ canAppend(other: any): boolean;
58
+ check(): void;
59
+ toJSON(): {
60
+ [key: string]: any;
61
+ };
62
+ } | null | undefined;
4
63
  export declare function cellNear($pos: ResolvedPos): ResolvedPos | null;
5
64
  export declare function cellAround($pos: ResolvedPos): ResolvedPos | null;
6
65
  export declare function nextCell($pos: ResolvedPos, axis: Axis, dir: number): ResolvedPos | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-tables",
3
- "version": "2.3.5",
3
+ "version": "2.3.6",
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/"
@@ -38,7 +38,7 @@
38
38
  "prosemirror-view": "1.23.7"
39
39
  },
40
40
  "devDependencies": {
41
- "@atlaskit/editor-test-helpers": "^18.7.0",
41
+ "@atlaskit/editor-test-helpers": "^18.8.0",
42
42
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1"
43
43
  },
44
44
  "techstack": {
package/report.api.md CHANGED
@@ -16,10 +16,12 @@
16
16
 
17
17
  ```ts
18
18
  import { ContentNodeWithPos } from 'prosemirror-utils';
19
+ import { Mappable } from 'prosemirror-transform';
19
20
  import { Mapping } from 'prosemirror-transform';
20
21
  import { Node as Node_2 } from 'prosemirror-model';
21
22
  import { ResolvedPos } from 'prosemirror-model';
22
23
  import { Selection as Selection_2 } from 'prosemirror-state';
24
+ import { SelectionBookmark } from 'prosemirror-state';
23
25
  import { Slice } from 'prosemirror-model';
24
26
  import { Transaction } from 'prosemirror-state';
25
27
 
@@ -27,14 +29,14 @@ import { Transaction } from 'prosemirror-state';
27
29
  type Axis = 'horiz' | 'vert';
28
30
 
29
31
  // @public (undocumented)
30
- class CellBookmark {
32
+ class CellBookmark implements SelectionBookmark {
31
33
  constructor(anchor: number, head: number);
32
34
  // (undocumented)
33
35
  readonly anchor: number;
34
36
  // (undocumented)
35
37
  readonly head: number;
36
38
  // (undocumented)
37
- map(mapping: Mapping): CellBookmark;
39
+ map(mapping: Mappable): SelectionBookmark;
38
40
  // (undocumented)
39
41
  resolve(doc: Node_2): Selection_2;
40
42
  }
@@ -74,7 +76,7 @@ export class CellSelection extends Selection_2 {
74
76
  // (undocumented)
75
77
  map(doc: Node_2, mapping: Mapping): Selection_2;
76
78
  // (undocumented)
77
- replace(tr: Transaction, content?: Slice<any>): void;
79
+ replace(tr: Transaction, content?: Slice): void;
78
80
  // (undocumented)
79
81
  replaceWith(tr: Transaction, node: Node_2): void;
80
82
  // (undocumented)
@@ -5,10 +5,12 @@
5
5
  ```ts
6
6
 
7
7
  import { ContentNodeWithPos } from 'prosemirror-utils';
8
+ import { Mappable } from 'prosemirror-transform';
8
9
  import { Mapping } from 'prosemirror-transform';
9
10
  import { Node as Node_2 } from 'prosemirror-model';
10
11
  import { ResolvedPos } from 'prosemirror-model';
11
12
  import { Selection as Selection_2 } from 'prosemirror-state';
13
+ import { SelectionBookmark } from 'prosemirror-state';
12
14
  import { Slice } from 'prosemirror-model';
13
15
  import { Transaction } from 'prosemirror-state';
14
16
 
@@ -16,14 +18,14 @@ import { Transaction } from 'prosemirror-state';
16
18
  type Axis = 'horiz' | 'vert';
17
19
 
18
20
  // @public (undocumented)
19
- class CellBookmark {
21
+ class CellBookmark implements SelectionBookmark {
20
22
  constructor(anchor: number, head: number);
21
23
  // (undocumented)
22
24
  readonly anchor: number;
23
25
  // (undocumented)
24
26
  readonly head: number;
25
27
  // (undocumented)
26
- map(mapping: Mapping): CellBookmark;
28
+ map(mapping: Mappable): SelectionBookmark;
27
29
  // (undocumented)
28
30
  resolve(doc: Node_2): Selection_2;
29
31
  }
@@ -56,7 +58,7 @@ export class CellSelection extends Selection_2 {
56
58
  // (undocumented)
57
59
  map(doc: Node_2, mapping: Mapping): Selection_2;
58
60
  // (undocumented)
59
- replace(tr: Transaction, content?: Slice<any>): void;
61
+ replace(tr: Transaction, content?: Slice): void;
60
62
  // (undocumented)
61
63
  replaceWith(tr: Transaction, node: Node_2): void;
62
64
  // (undocumented)