@atlaskit/adf-schema 29.1.2 → 30.0.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.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/schema/default-schema.js +0 -1
- package/dist/cjs/schema/nodes/tableNodes.js +9 -8
- package/dist/cjs/steps.js +0 -21
- package/dist/es2019/schema/default-schema.js +1 -2
- package/dist/es2019/schema/nodes/tableNodes.js +10 -9
- package/dist/es2019/steps.js +0 -3
- package/dist/esm/schema/default-schema.js +1 -2
- package/dist/esm/schema/nodes/tableNodes.js +9 -8
- package/dist/esm/steps.js +0 -3
- package/dist/json-schema/v1/full.json +3 -0
- package/dist/types/schema/nodes/tableNodes.d.ts +8 -5
- package/dist/types/steps.d.ts +0 -4
- package/json-schema/v1/full.json +3 -0
- package/package.json +1 -2
- package/dist/cjs/steps/table/add-column.js +0 -381
- package/dist/cjs/steps/table/constants.js +0 -12
- package/dist/cjs/steps/table/sort-column.js +0 -68
- package/dist/cjs/steps/table/types.js +0 -5
- package/dist/cjs/steps/table/utils/cell-step.js +0 -202
- package/dist/cjs/steps/table/utils/cells-at-column.js +0 -73
- package/dist/cjs/steps/table/utils/find-column.js +0 -90
- package/dist/cjs/steps/table/utils/get-table-rect-from-doc.js +0 -36
- package/dist/cjs/steps/table/utils/side-effects/rows.js +0 -315
- package/dist/cjs/steps/table/utils/side-effects/side-effects.js +0 -83
- package/dist/cjs/steps/table/utils/side-effects/table.js +0 -110
- package/dist/cjs/steps/table/utils/side-effects/types.js +0 -5
- package/dist/cjs/steps/table/utils/table-map.js +0 -30
- package/dist/es2019/steps/table/add-column.js +0 -306
- package/dist/es2019/steps/table/constants.js +0 -5
- package/dist/es2019/steps/table/sort-column.js +0 -34
- package/dist/es2019/steps/table/types.js +0 -1
- package/dist/es2019/steps/table/utils/cell-step.js +0 -187
- package/dist/es2019/steps/table/utils/cells-at-column.js +0 -52
- package/dist/es2019/steps/table/utils/find-column.js +0 -83
- package/dist/es2019/steps/table/utils/get-table-rect-from-doc.js +0 -31
- package/dist/es2019/steps/table/utils/side-effects/rows.js +0 -257
- package/dist/es2019/steps/table/utils/side-effects/side-effects.js +0 -60
- package/dist/es2019/steps/table/utils/side-effects/table.js +0 -82
- package/dist/es2019/steps/table/utils/side-effects/types.js +0 -1
- package/dist/es2019/steps/table/utils/table-map.js +0 -19
- package/dist/esm/steps/table/add-column.js +0 -373
- package/dist/esm/steps/table/constants.js +0 -5
- package/dist/esm/steps/table/sort-column.js +0 -60
- package/dist/esm/steps/table/types.js +0 -1
- package/dist/esm/steps/table/utils/cell-step.js +0 -192
- package/dist/esm/steps/table/utils/cells-at-column.js +0 -66
- package/dist/esm/steps/table/utils/find-column.js +0 -84
- package/dist/esm/steps/table/utils/get-table-rect-from-doc.js +0 -31
- package/dist/esm/steps/table/utils/side-effects/rows.js +0 -307
- package/dist/esm/steps/table/utils/side-effects/side-effects.js +0 -75
- package/dist/esm/steps/table/utils/side-effects/table.js +0 -102
- package/dist/esm/steps/table/utils/side-effects/types.js +0 -1
- package/dist/esm/steps/table/utils/table-map.js +0 -19
- package/dist/types/steps/table/add-column.d.ts +0 -88
- package/dist/types/steps/table/constants.d.ts +0 -4
- package/dist/types/steps/table/sort-column.d.ts +0 -18
- package/dist/types/steps/table/types.d.ts +0 -39
- package/dist/types/steps/table/utils/cell-step.d.ts +0 -47
- package/dist/types/steps/table/utils/cells-at-column.d.ts +0 -20
- package/dist/types/steps/table/utils/find-column.d.ts +0 -8
- package/dist/types/steps/table/utils/get-table-rect-from-doc.d.ts +0 -8
- package/dist/types/steps/table/utils/side-effects/rows.d.ts +0 -25
- package/dist/types/steps/table/utils/side-effects/side-effects.d.ts +0 -15
- package/dist/types/steps/table/utils/side-effects/table.d.ts +0 -16
- package/dist/types/steps/table/utils/side-effects/types.d.ts +0 -33
- package/dist/types/steps/table/utils/table-map.d.ts +0 -6
@@ -1,88 +0,0 @@
|
|
1
|
-
import { Node as ProseMirrorNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
import { Mappable, Step, StepMap, StepResult } from '@atlaskit/editor-prosemirror/transform';
|
3
|
-
import { AddColumnStepInfo, AddColumnStepJson } from './types';
|
4
|
-
/**
|
5
|
-
* Index and positions looks like
|
6
|
-
* 0 1 2 3 -> Add Column Index
|
7
|
-
* | 5 | 10 | 15 | -> Table with Positions
|
8
|
-
* | 20 | 25 | 30 |
|
9
|
-
* 0 1 2 x -> Remove Column Index
|
10
|
-
*
|
11
|
-
*/
|
12
|
-
export declare class AddColumnStep<S extends Schema = any> extends Step {
|
13
|
-
private readonly tablePos;
|
14
|
-
private readonly isDelete;
|
15
|
-
private columnInfo;
|
16
|
-
private sideEffectsHandler;
|
17
|
-
constructor(tablePos: number, addColumnStepInfo: AddColumnStepInfo, isDelete?: boolean);
|
18
|
-
/**
|
19
|
-
* Detect the column based on all the cells step in column info.
|
20
|
-
* Recreate columnInfo based on the current document. We might need to add new cells added by insert row or unmerge cells.
|
21
|
-
* If isDelete
|
22
|
-
* Decrease colspan if one row has merged cell
|
23
|
-
* Remove all the cells using columnInfo.cellStep[].from
|
24
|
-
* else
|
25
|
-
* Increase colspan if one row had merged cell
|
26
|
-
* Add all new cells at columnInfo.cellStep[].from,
|
27
|
-
* if there is columnInfo.cellStep[].newCell use it
|
28
|
-
* else create an empty cell
|
29
|
-
*
|
30
|
-
* @param doc Current document
|
31
|
-
*/
|
32
|
-
apply(doc: ProseMirrorNode): StepResult;
|
33
|
-
/**
|
34
|
-
* Update tablePos with the new position. If tablePos doesnt exist any more remove the step
|
35
|
-
* Update all the cellStep inside columnInfo. If cellStep.from position gets deleted removed it from column info
|
36
|
-
* if cellStep.length === 0 remove the step
|
37
|
-
* Create a new step with all the position updated
|
38
|
-
* @param mapping
|
39
|
-
*/
|
40
|
-
map(mapping: Mappable): Step | null;
|
41
|
-
/**
|
42
|
-
* if isDelete
|
43
|
-
* Get the original cell node at columnInfo.cellStep[].from to columnInfo.cellStep[].to
|
44
|
-
* Create a copy of the node
|
45
|
-
* Create a new cellStep with the same positions but with the clone node as a content
|
46
|
-
* return new step inverted
|
47
|
-
* else
|
48
|
-
* Remove the content from each columnInfo.cellStep[].content
|
49
|
-
* return new step inverted
|
50
|
-
* @param originalDoc
|
51
|
-
*/
|
52
|
-
invert(originalDoc: ProseMirrorNode): Step;
|
53
|
-
/**
|
54
|
-
* StepMap is created based on columnInfo.
|
55
|
-
* ColumnInfo is created on constructor and once is applied (the document could have new cells that weren't part of the original set)
|
56
|
-
* if isDelete
|
57
|
-
* Create range array based on cell info where each range is [cellStep.from, cellStep.from - cellStep.to, 0]
|
58
|
-
* else
|
59
|
-
* Create range array base on cell info where each range is [cellStep.from, 0, cellStep.content ? cellStep.content.nodeSize : defaultEmptyCellNodeSize]
|
60
|
-
*
|
61
|
-
* Ranges in ProseMirror are represented by each 3 elements in an array.
|
62
|
-
* As [pos, currentSize, newSize, pos2, currentSize2, newSize2] where:
|
63
|
-
* pos: Position in the document
|
64
|
-
* currentSize: Represent the affected range, this will be pos + currentSize
|
65
|
-
* newSize: Represent the new values, pos + newSize
|
66
|
-
*/
|
67
|
-
getMap(): StepMap;
|
68
|
-
/**
|
69
|
-
* Try to merge this step with another one, to be applied directly
|
70
|
-
* after it. Returns the merged step when possible, null if the
|
71
|
-
* steps can't be merged.
|
72
|
-
*/
|
73
|
-
merge(other: Step): Step | null;
|
74
|
-
/**
|
75
|
-
* Create a JSON-serializeable representation of this step. When
|
76
|
-
* defining this for a custom subclass, make sure the result object
|
77
|
-
* includes the step type's [JSON id](#transform.Step^jsonID) under
|
78
|
-
* the `stepType` property.
|
79
|
-
*/
|
80
|
-
toJSON(): AddColumnStepJson;
|
81
|
-
/**
|
82
|
-
* Deserialize a step from its JSON representation. Will call
|
83
|
-
* through to the step class' own implementation of this method.
|
84
|
-
*/
|
85
|
-
static fromJSON<S extends Schema = any>(schema: S, json: AddColumnStepJson): Step;
|
86
|
-
static create(doc: ProseMirrorNode, tablePos: number, column: number, isDelete?: boolean): AddColumnStep<any>;
|
87
|
-
private applyCellSteps;
|
88
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
import { ReplaceStep, Step, StepMap, StepResult } from '@atlaskit/editor-prosemirror/transform';
|
3
|
-
import { TableColumnOrdering } from './types';
|
4
|
-
export declare const tableSortingStepType = "atlaskit-table-sorting-ordering";
|
5
|
-
export declare class TableSortStep extends Step {
|
6
|
-
prev: TableColumnOrdering | undefined;
|
7
|
-
next: TableColumnOrdering | undefined;
|
8
|
-
pos: number;
|
9
|
-
constructor(pos: number, prev?: TableColumnOrdering, next?: TableColumnOrdering);
|
10
|
-
invert(): TableSortStep;
|
11
|
-
apply(doc: PMNode): StepResult;
|
12
|
-
map(): null;
|
13
|
-
getMap(): StepMap;
|
14
|
-
toJSON(): {
|
15
|
-
stepType: string;
|
16
|
-
};
|
17
|
-
static fromJSON(): ReplaceStep;
|
18
|
-
}
|
@@ -1,39 +0,0 @@
|
|
1
|
-
import { Node as ProseMirrorNode } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
import { SideEffects, SideEffectsJSON } from './utils/side-effects/types';
|
3
|
-
import { SortOrder } from './constants';
|
4
|
-
export type ColumnInfo = Map<number, CellStep>;
|
5
|
-
export interface AddColumnStepInfo {
|
6
|
-
cells: CellStep[];
|
7
|
-
sideEffects?: SideEffects;
|
8
|
-
}
|
9
|
-
/**
|
10
|
-
* Information about the cell
|
11
|
-
* from: where the cell will be added removed
|
12
|
-
* to: where the original cell ends
|
13
|
-
* newCell?: the content of the new cells if it's added
|
14
|
-
*/
|
15
|
-
export interface CellStep {
|
16
|
-
from: number;
|
17
|
-
to: number;
|
18
|
-
newCell?: ProseMirrorNode;
|
19
|
-
mergeWith?: number;
|
20
|
-
}
|
21
|
-
export interface CellStepJson {
|
22
|
-
from: number;
|
23
|
-
to: number;
|
24
|
-
newCell?: {
|
25
|
-
[key: string]: any;
|
26
|
-
};
|
27
|
-
mergeWith?: number;
|
28
|
-
}
|
29
|
-
export interface AddColumnStepJson {
|
30
|
-
stepType: 'ak-add-column';
|
31
|
-
tablePos: number;
|
32
|
-
cells: CellStepJson[];
|
33
|
-
sideEffects?: SideEffectsJSON;
|
34
|
-
isDelete: boolean;
|
35
|
-
}
|
36
|
-
export interface TableColumnOrdering {
|
37
|
-
columnIndex: number;
|
38
|
-
order: SortOrder;
|
39
|
-
}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
import { Node as ProseMirrorNode } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
import { Cell } from './cells-at-column';
|
3
|
-
import { CellStep } from '../types';
|
4
|
-
import { Transform, StepMap } from '@atlaskit/editor-prosemirror/transform';
|
5
|
-
import { TableRect } from '@atlaskit/editor-tables/table-map';
|
6
|
-
/**
|
7
|
-
* Given a cell step, this function has to do the specific transformation to executed that step.
|
8
|
-
* It returns the applied cellStep and rows that needs to skip (because it was already handled).
|
9
|
-
* @param tr
|
10
|
-
* @param tableRect
|
11
|
-
* @param cell
|
12
|
-
* @param cellStep
|
13
|
-
* @param isDelete
|
14
|
-
* @param column
|
15
|
-
*/
|
16
|
-
export declare function applyCellStep(tr: Transform, tableRect: TableRect, cell: Cell, cellStep: CellStep, isDelete: boolean, column: number): {
|
17
|
-
tr: Transform;
|
18
|
-
skipRows: number;
|
19
|
-
cellStep: CellStep;
|
20
|
-
};
|
21
|
-
/**
|
22
|
-
* Given a cell step, this functions return un StepMap representing this action.
|
23
|
-
* [position, oldSize, newSize]
|
24
|
-
* @param cellStep
|
25
|
-
* @param isDelete
|
26
|
-
*/
|
27
|
-
export declare function getMapFromCellStep(cellStep: CellStep, isDelete: boolean): [number, number, number];
|
28
|
-
/**
|
29
|
-
* Given a cell step, this function invert that step.
|
30
|
-
* @param doc
|
31
|
-
* @param getTableRectAndColumn
|
32
|
-
* @param cellStep
|
33
|
-
* @param isDelete
|
34
|
-
* @param stepMap
|
35
|
-
*/
|
36
|
-
export declare function invertCellStep(doc: ProseMirrorNode, getTableRectAndColumn: () => {
|
37
|
-
rect: TableRect;
|
38
|
-
column: number;
|
39
|
-
}, cellStep: CellStep, isDelete: boolean, stepMap: StepMap): CellStep;
|
40
|
-
/**
|
41
|
-
* Create a cell step based on the current cell and operation (add/delete)
|
42
|
-
* @param cell
|
43
|
-
* @param column
|
44
|
-
* @param isDelete
|
45
|
-
* @param previousCellStep
|
46
|
-
*/
|
47
|
-
export declare function createCellStep(cell: Cell, column: number, isDelete: boolean, previousCellStep?: CellStep): CellStep;
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import { TableRect } from '@atlaskit/editor-tables/table-map';
|
2
|
-
import { NodeType } from '@atlaskit/editor-prosemirror/model';
|
3
|
-
import { CellAttributes } from '../../../schema/nodes/tableNodes';
|
4
|
-
export interface Cell {
|
5
|
-
from: number;
|
6
|
-
to: number;
|
7
|
-
row: number;
|
8
|
-
col: number;
|
9
|
-
attrs?: CellAttributes;
|
10
|
-
hasMergedCells: boolean;
|
11
|
-
type: NodeType;
|
12
|
-
}
|
13
|
-
/**
|
14
|
-
* Helper to have a consistent way to iterate for all the cells in a column.
|
15
|
-
* You can skip rows by passing the rows to skipped in the next arguments.
|
16
|
-
* For example: `iter.next(1)` to skip the next row
|
17
|
-
* @param rect
|
18
|
-
* @param col
|
19
|
-
*/
|
20
|
-
export declare function cellsAtColumn(rect: TableRect, col: number): Generator<Cell, void, number | undefined>;
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import { TableRect } from '@atlaskit/editor-tables/table-map';
|
2
|
-
import { ColumnInfo } from '../types';
|
3
|
-
/**
|
4
|
-
* Try to find the right column based on the cell steps in column info..
|
5
|
-
* @param columnInfo - Map of cell positions sorted from lower to greather
|
6
|
-
* @param rect - map rect
|
7
|
-
*/
|
8
|
-
export declare function findColumn(columnInfo: ColumnInfo, rect: TableRect): number | null;
|
@@ -1,8 +0,0 @@
|
|
1
|
-
import { Node as ProseMirrorNode } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
import { TableRect } from '@atlaskit/editor-tables/table-map';
|
3
|
-
/**
|
4
|
-
* Util to get the table rect from the docs
|
5
|
-
* @param doc
|
6
|
-
* @param tablePos
|
7
|
-
*/
|
8
|
-
export declare function getTableRectFromDoc(doc: ProseMirrorNode, tablePos: number): TableRect;
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import { Node as ProseMirrorNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
import { Mappable, StepMap, Transform } from '@atlaskit/editor-prosemirror/transform';
|
3
|
-
import { TableRect } from '@atlaskit/editor-tables/table-map';
|
4
|
-
import { RowSideEffect, RowSideEffectJSON } from './types';
|
5
|
-
import { Cell } from '../cells-at-column';
|
6
|
-
interface RowsHandler {
|
7
|
-
handle: (tr: Transform, rect: TableRect, row: number, col: number, cell: Cell) => {
|
8
|
-
handled: boolean;
|
9
|
-
skipRows?: number;
|
10
|
-
};
|
11
|
-
end: (tr: Transform, rect: TableRect, col: number) => void;
|
12
|
-
}
|
13
|
-
export declare class RowsSideEffectHandler {
|
14
|
-
rows?: RowSideEffect[];
|
15
|
-
constructor(rowsSideEffect?: RowSideEffect[]);
|
16
|
-
private deleteHandler;
|
17
|
-
private addHandler;
|
18
|
-
start(isDelete: boolean): RowsHandler;
|
19
|
-
addRowRanges(ranges: number[], isDelete: boolean): number[];
|
20
|
-
map(mapping: Mappable): RowSideEffect[];
|
21
|
-
invert(originalDoc: ProseMirrorNode, isDelete: boolean, map: StepMap): RowSideEffect[] | undefined;
|
22
|
-
toJSON(): RowSideEffectJSON[] | undefined;
|
23
|
-
static fromJSON(schema: Schema, json: RowSideEffectJSON[]): RowSideEffect[];
|
24
|
-
}
|
25
|
-
export {};
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import { Node as ProseMirrorNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
import { Mappable, StepMap } from '@atlaskit/editor-prosemirror/transform';
|
3
|
-
import { SideEffects, SideEffectsJSON } from './types';
|
4
|
-
import { TableSideEffectHandler } from './table';
|
5
|
-
import { RowsSideEffectHandler } from './rows';
|
6
|
-
export declare class SideEffectsHandler {
|
7
|
-
table: TableSideEffectHandler;
|
8
|
-
rows: RowsSideEffectHandler;
|
9
|
-
constructor(sideEffects?: SideEffects);
|
10
|
-
getTableMap(isDelete: boolean): StepMap | undefined;
|
11
|
-
map(mapping: Mappable): SideEffects;
|
12
|
-
invert(originalDoc: ProseMirrorNode, isDelete: boolean, map: StepMap): SideEffects;
|
13
|
-
toJSON(): SideEffectsJSON | undefined;
|
14
|
-
static fromJSON(schema: Schema, json: SideEffectsJSON): SideEffects;
|
15
|
-
}
|
@@ -1,16 +0,0 @@
|
|
1
|
-
import { Node as ProseMirrorNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
import { Mappable, StepMap, Transform } from '@atlaskit/editor-prosemirror/transform';
|
3
|
-
import { TableRect } from '@atlaskit/editor-tables/table-map';
|
4
|
-
import { TableSideEffect, TableSideEffectJSON } from './types';
|
5
|
-
export declare class TableSideEffectHandler {
|
6
|
-
table?: TableSideEffect;
|
7
|
-
constructor(tableSideEffect?: TableSideEffect);
|
8
|
-
private addTableSideEffect;
|
9
|
-
handleAddTable(tr: Transform, isDelete: boolean): boolean;
|
10
|
-
handleRemoveTable(tr: Transform, tablePos: number, tableRect: TableRect, column: number | null, isDelete: boolean): boolean;
|
11
|
-
getTableMap(isDelete: boolean): StepMap | undefined;
|
12
|
-
map(mapping: Mappable): TableSideEffect | undefined;
|
13
|
-
invert(doc: ProseMirrorNode): TableSideEffect | undefined;
|
14
|
-
toJSON(): TableSideEffectJSON | undefined;
|
15
|
-
static fromJSON(schema: Schema, json: TableSideEffectJSON): TableSideEffect;
|
16
|
-
}
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import { Node as ProseMirrorNode } from '@atlaskit/editor-prosemirror/model';
|
2
|
-
export interface TableSideEffect {
|
3
|
-
from: number;
|
4
|
-
to: number;
|
5
|
-
node: ProseMirrorNode;
|
6
|
-
}
|
7
|
-
export interface RowSideEffect {
|
8
|
-
from: number;
|
9
|
-
to: number;
|
10
|
-
rowNode: ProseMirrorNode;
|
11
|
-
}
|
12
|
-
export interface TableSideEffectJSON {
|
13
|
-
from: number;
|
14
|
-
to: number;
|
15
|
-
node: {
|
16
|
-
[key: string]: any;
|
17
|
-
};
|
18
|
-
}
|
19
|
-
export interface RowSideEffectJSON {
|
20
|
-
from: number;
|
21
|
-
to: number;
|
22
|
-
rowNode: {
|
23
|
-
[key: string]: any;
|
24
|
-
};
|
25
|
-
}
|
26
|
-
export type SideEffects = {
|
27
|
-
table?: TableSideEffect;
|
28
|
-
rows?: RowSideEffect[];
|
29
|
-
};
|
30
|
-
export type SideEffectsJSON = {
|
31
|
-
table?: TableSideEffectJSON;
|
32
|
-
rows?: RowSideEffectJSON[];
|
33
|
-
};
|
@@ -1,6 +0,0 @@
|
|
1
|
-
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
2
|
-
export declare const getCellIndex: (map: TableMap, row: number, col: number) => number;
|
3
|
-
export declare function hasMergedColumns(map: TableMap, row: number, col: number): boolean;
|
4
|
-
export declare function hasMergedRows(map: TableMap, row: number, col: number): boolean;
|
5
|
-
export declare function isRootRow(map: TableMap, row: number, col: number): boolean;
|
6
|
-
export declare function isRootCol(map: TableMap, row: number, col: number): boolean;
|